summaryrefslogtreecommitdiff
path: root/extensions
diff options
context:
space:
mode:
Diffstat (limited to 'extensions')
-rw-r--r--extensions/inc/abpilot.hrc45
-rw-r--r--extensions/inc/appsettings.hxx45
-rw-r--r--extensions/inc/bibliography.hrc86
-rw-r--r--extensions/inc/dbpilots.hrc55
-rw-r--r--extensions/inc/extensio.hrc75
-rw-r--r--extensions/inc/makefile.mk47
-rw-r--r--extensions/inc/pch/precompiled_extensions.cxx31
-rw-r--r--extensions/inc/pch/precompiled_extensions.hxx551
-rw-r--r--extensions/inc/propctrlr.hrc338
-rw-r--r--extensions/inc/ucbhelper/ext_content.hxx331
-rw-r--r--extensions/inc/update.hrc49
-rw-r--r--extensions/prj/build.lst36
-rw-r--r--extensions/prj/d.lst41
-rw-r--r--extensions/qa/complex/extensions/OfficeResourceLoader.java121
-rw-r--r--extensions/qa/complex/extensions/extensions_all.sce1
-rw-r--r--extensions/qa/complex/extensions/makefile.mk101
-rw-r--r--extensions/qa/complex/extensions/orl_de.src31
-rw-r--r--extensions/qa/complex/extensions/orl_en-US.src31
-rw-r--r--extensions/qa/integration/extensions/ComponentFactory.java106
-rw-r--r--extensions/qa/integration/extensions/ConsoleWait.java128
-rw-r--r--extensions/qa/integration/extensions/Frame.java226
-rw-r--r--extensions/qa/integration/extensions/HelpTextProvider.java50
-rw-r--r--extensions/qa/integration/extensions/MethodHandler.java239
-rw-r--r--extensions/qa/integration/extensions/ObjectInspector.java176
-rw-r--r--extensions/qa/integration/extensions/ServicesHandler.java228
-rw-r--r--extensions/qa/integration/extensions/TestSkeleton.java71
-rw-r--r--extensions/qa/integration/extensions/extensions_complex.sce1
-rw-r--r--extensions/qa/integration/extensions/makefile.mk83
-rw-r--r--extensions/qa/unoapi/Test.java50
-rw-r--r--extensions/qa/unoapi/extensions.sce5
-rw-r--r--extensions/qa/unoapi/makefile.mk48
-rw-r--r--extensions/source/abpilot/abpfinalpage.cxx229
-rw-r--r--extensions/source/abpilot/abpfinalpage.hxx94
-rw-r--r--extensions/source/abpilot/abpresid.hrc219
-rw-r--r--extensions/source/abpilot/abpservices.cxx109
-rw-r--r--extensions/source/abpilot/abptypes.hxx50
-rw-r--r--extensions/source/abpilot/abspage.cxx91
-rw-r--r--extensions/source/abpilot/abspage.hxx75
-rw-r--r--extensions/source/abpilot/abspilot.cxx501
-rw-r--r--extensions/source/abpilot/abspilot.hxx151
-rw-r--r--extensions/source/abpilot/abspilot.src376
-rw-r--r--extensions/source/abpilot/addresssettings.hxx81
-rw-r--r--extensions/source/abpilot/admininvokationimpl.cxx135
-rw-r--r--extensions/source/abpilot/admininvokationimpl.hxx72
-rw-r--r--extensions/source/abpilot/admininvokationpage.cxx116
-rw-r--r--extensions/source/abpilot/admininvokationpage.hxx75
-rw-r--r--extensions/source/abpilot/datasourcehandling.cxx639
-rw-r--r--extensions/source/abpilot/datasourcehandling.hxx217
-rw-r--r--extensions/source/abpilot/exports.dxp3
-rw-r--r--extensions/source/abpilot/fieldmappingimpl.cxx374
-rw-r--r--extensions/source/abpilot/fieldmappingimpl.hxx128
-rw-r--r--extensions/source/abpilot/fieldmappingpage.cxx121
-rw-r--r--extensions/source/abpilot/fieldmappingpage.hxx72
-rw-r--r--extensions/source/abpilot/makefile.mk106
-rw-r--r--extensions/source/abpilot/moduleabp.cxx34
-rw-r--r--extensions/source/abpilot/tableselectionpage.cxx135
-rw-r--r--extensions/source/abpilot/tableselectionpage.hxx75
-rw-r--r--extensions/source/abpilot/typeselectionpage.cxx248
-rw-r--r--extensions/source/abpilot/typeselectionpage.hxx108
-rw-r--r--extensions/source/abpilot/unodialogabp.cxx198
-rw-r--r--extensions/source/abpilot/unodialogabp.hxx103
-rw-r--r--extensions/source/activex/main/README.txt33
-rw-r--r--extensions/source/activex/main/SOActionsApproval.cpp31
-rw-r--r--extensions/source/activex/main/SOActionsApproval.h83
-rw-r--r--extensions/source/activex/main/SOActionsApproval.rgs24
-rw-r--r--extensions/source/activex/main/SOActiveX.cpp1153
-rw-r--r--extensions/source/activex/main/SOActiveX.h178
-rw-r--r--extensions/source/activex/main/SOActiveX.rgs33
-rw-r--r--extensions/source/activex/main/SOComWindowPeer.cpp30
-rw-r--r--extensions/source/activex/main/SOComWindowPeer.h136
-rw-r--r--extensions/source/activex/main/SOComWindowPeer.rgs23
-rw-r--r--extensions/source/activex/main/SODispatchInterceptor.cpp224
-rw-r--r--extensions/source/activex/main/SODispatchInterceptor.h158
-rw-r--r--extensions/source/activex/main/SODispatchInterceptor.rgs23
-rw-r--r--extensions/source/activex/main/StdAfx2.cpp21
-rw-r--r--extensions/source/activex/main/StdAfx2.h45
-rw-r--r--extensions/source/activex/main/com_uno_helper.h26
-rw-r--r--extensions/source/activex/main/example.html26
-rw-r--r--extensions/source/activex/main/makefile.mk155
-rw-r--r--extensions/source/activex/main/resource.h28
-rw-r--r--extensions/source/activex/main/so_activex.cpp692
-rw-r--r--extensions/source/activex/main/so_activex.def13
-rw-r--r--extensions/source/activex/main/so_activex.rc113
-rw-r--r--extensions/source/activex/msidl/makefile.mk62
-rw-r--r--extensions/source/activex/msidl/so_activex.idl210
-rw-r--r--extensions/source/bibliography/bib.hrc111
-rw-r--r--extensions/source/bibliography/bib.src74
-rw-r--r--extensions/source/bibliography/bibbeam.cxx322
-rw-r--r--extensions/source/bibliography/bibbeam.hxx96
-rw-r--r--extensions/source/bibliography/bibconfig.cxx391
-rw-r--r--extensions/source/bibliography/bibconfig.hxx158
-rw-r--r--extensions/source/bibliography/bibcont.cxx278
-rw-r--r--extensions/source/bibliography/bibcont.hxx117
-rw-r--r--extensions/source/bibliography/bibload.cxx805
-rw-r--r--extensions/source/bibliography/bibmod.cxx125
-rw-r--r--extensions/source/bibliography/bibmod.hxx68
-rw-r--r--extensions/source/bibliography/bibprop.hrc45
-rw-r--r--extensions/source/bibliography/bibresid.hxx46
-rw-r--r--extensions/source/bibliography/bibshortcuthandler.hxx90
-rw-r--r--extensions/source/bibliography/bibtools.hxx53
-rw-r--r--extensions/source/bibliography/bibview.cxx233
-rw-r--r--extensions/source/bibliography/bibview.hxx88
-rw-r--r--extensions/source/bibliography/datman.cxx1835
-rw-r--r--extensions/source/bibliography/datman.hrc102
-rw-r--r--extensions/source/bibliography/datman.hxx202
-rw-r--r--extensions/source/bibliography/datman.src469
-rw-r--r--extensions/source/bibliography/formcontrolcontainer.cxx182
-rw-r--r--extensions/source/bibliography/formcontrolcontainer.hxx86
-rw-r--r--extensions/source/bibliography/framectr.cxx979
-rw-r--r--extensions/source/bibliography/framectr.hxx132
-rw-r--r--extensions/source/bibliography/general.cxx895
-rw-r--r--extensions/source/bibliography/general.hxx207
-rw-r--r--extensions/source/bibliography/hidother.src61
-rw-r--r--extensions/source/bibliography/loadlisteneradapter.cxx241
-rw-r--r--extensions/source/bibliography/loadlisteneradapter.hxx187
-rw-r--r--extensions/source/bibliography/makefile.mk91
-rw-r--r--extensions/source/bibliography/menu.src45
-rw-r--r--extensions/source/bibliography/sections.hrc128
-rw-r--r--extensions/source/bibliography/sections.src584
-rw-r--r--extensions/source/bibliography/toolbar.cxx646
-rw-r--r--extensions/source/bibliography/toolbar.hrc46
-rw-r--r--extensions/source/bibliography/toolbar.hxx192
-rw-r--r--extensions/source/bibliography/toolbar.src241
-rw-r--r--extensions/source/bibliography/uiconfig/sbibliography/menubar/menubar.xml92
-rw-r--r--extensions/source/config/ldap/componentdef.cxx83
-rw-r--r--extensions/source/config/ldap/exports.dxp3
-rw-r--r--extensions/source/config/ldap/ldapaccess.cxx321
-rw-r--r--extensions/source/config/ldap/ldapaccess.hxx171
-rw-r--r--extensions/source/config/ldap/ldapuserprofilebe.cxx280
-rw-r--r--extensions/source/config/ldap/ldapuserprofilebe.hxx161
-rw-r--r--extensions/source/config/ldap/makefile.mk97
-rw-r--r--extensions/source/config/ldap/wrapldapinclude.hxx53
-rw-r--r--extensions/source/dbpilots/commonpagesdbp.cxx507
-rw-r--r--extensions/source/dbpilots/commonpagesdbp.hxx148
-rw-r--r--extensions/source/dbpilots/commonpagesdbp.src230
-rw-r--r--extensions/source/dbpilots/controlwizard.cxx779
-rw-r--r--extensions/source/dbpilots/controlwizard.hxx185
-rw-r--r--extensions/source/dbpilots/dbpilots.src78
-rw-r--r--extensions/source/dbpilots/dbpresid.hrc233
-rw-r--r--extensions/source/dbpilots/dbpservices.cxx114
-rw-r--r--extensions/source/dbpilots/dbptools.cxx72
-rw-r--r--extensions/source/dbpilots/dbptools.hxx50
-rw-r--r--extensions/source/dbpilots/dbptypes.hxx49
-rw-r--r--extensions/source/dbpilots/gridpages.src114
-rw-r--r--extensions/source/dbpilots/gridwizard.cxx487
-rw-r--r--extensions/source/dbpilots/gridwizard.hxx138
-rw-r--r--extensions/source/dbpilots/groupboxpages.src226
-rw-r--r--extensions/source/dbpilots/groupboxwiz.cxx563
-rw-r--r--extensions/source/dbpilots/groupboxwiz.hxx231
-rw-r--r--extensions/source/dbpilots/listcombopages.src203
-rw-r--r--extensions/source/dbpilots/listcombowizard.cxx564
-rw-r--r--extensions/source/dbpilots/listcombowizard.hxx229
-rw-r--r--extensions/source/dbpilots/makefile.mk103
-rw-r--r--extensions/source/dbpilots/moduledbp.cxx34
-rw-r--r--extensions/source/dbpilots/optiongrouplayouter.cxx218
-rw-r--r--extensions/source/dbpilots/optiongrouplayouter.hxx77
-rw-r--r--extensions/source/dbpilots/unoautopilot.hxx108
-rw-r--r--extensions/source/dbpilots/unoautopilot.inl134
-rw-r--r--extensions/source/dbpilots/wizardcontext.hxx94
-rw-r--r--extensions/source/dbpilots/wizardservices.cxx122
-rw-r--r--extensions/source/dbpilots/wizardservices.hxx82
-rw-r--r--extensions/source/inc/componentmodule.cxx341
-rw-r--r--extensions/source/inc/componentmodule.hxx280
-rw-r--r--extensions/source/logging/consolehandler.cxx345
-rw-r--r--extensions/source/logging/csvformatter.cxx377
-rw-r--r--extensions/source/logging/filehandler.cxx444
-rw-r--r--extensions/source/logging/log_module.cxx45
-rw-r--r--extensions/source/logging/log_module.hxx47
-rw-r--r--extensions/source/logging/log_services.cxx71
-rw-r--r--extensions/source/logging/logger.cxx406
-rw-r--r--extensions/source/logging/loggerconfig.cxx287
-rw-r--r--extensions/source/logging/loggerconfig.hxx68
-rw-r--r--extensions/source/logging/loghandler.cxx204
-rw-r--r--extensions/source/logging/loghandler.hxx157
-rw-r--r--extensions/source/logging/logrecord.cxx105
-rw-r--r--extensions/source/logging/logrecord.hxx71
-rw-r--r--extensions/source/logging/makefile.mk76
-rw-r--r--extensions/source/logging/methodguard.hxx75
-rw-r--r--extensions/source/logging/plaintextformatter.cxx229
-rw-r--r--extensions/source/macosx/spotlight/GetMetadataForFile.m70
-rw-r--r--extensions/source/macosx/spotlight/OOoContentDataParser.h61
-rw-r--r--extensions/source/macosx/spotlight/OOoContentDataParser.m133
-rw-r--r--extensions/source/macosx/spotlight/OOoMetaDataParser.h55
-rw-r--r--extensions/source/macosx/spotlight/OOoMetaDataParser.m200
-rw-r--r--extensions/source/macosx/spotlight/OOoSpotlightImporter.h45
-rw-r--r--extensions/source/macosx/spotlight/OOoSpotlightImporter.m235
-rw-r--r--extensions/source/macosx/spotlight/delzip0
-rw-r--r--extensions/source/macosx/spotlight/ioapi.h100
-rw-r--r--extensions/source/macosx/spotlight/ioapi.m204
-rw-r--r--extensions/source/macosx/spotlight/main.m225
-rw-r--r--extensions/source/macosx/spotlight/makefile.mk96
-rw-r--r--extensions/source/macosx/spotlight/mdimporter/Info.plist70
-rw-r--r--extensions/source/macosx/spotlight/mdimporter/en.lproj/schema.strings1
-rw-r--r--extensions/source/macosx/spotlight/mdimporter/schema.xml397
-rw-r--r--extensions/source/macosx/spotlight/unzip.h380
-rw-r--r--extensions/source/macosx/spotlight/unzip.m1586
-rw-r--r--extensions/source/macosx/spotlight/version.plist16
-rw-r--r--extensions/source/nsplugin/source/exports.dxp16
-rw-r--r--extensions/source/nsplugin/source/exports_wnt.dxp18
-rw-r--r--extensions/source/nsplugin/source/makefile.mk162
-rw-r--r--extensions/source/nsplugin/source/npshell.cxx933
-rw-r--r--extensions/source/nsplugin/source/npshell.hxx94
-rw-r--r--extensions/source/nsplugin/source/ns_debug.hxx42
-rw-r--r--extensions/source/nsplugin/source/nsp_func.hxx106
-rw-r--r--extensions/source/nsplugin/source/nsp_windows.cxx66
-rw-r--r--extensions/source/nsplugin/source/nsp_windows.hxx38
-rw-r--r--extensions/source/nsplugin/source/nsplugin.rc30
-rw-r--r--extensions/source/nsplugin/source/nsplugin_oo.rc30
-rw-r--r--extensions/source/nsplugin/source/so_closelistener.cxx50
-rw-r--r--extensions/source/nsplugin/source/so_closelistener.hxx56
-rw-r--r--extensions/source/nsplugin/source/so_env.cxx509
-rw-r--r--extensions/source/nsplugin/source/so_env.hxx97
-rw-r--r--extensions/source/nsplugin/source/so_instance.cxx498
-rw-r--r--extensions/source/nsplugin/source/so_instance.hxx113
-rw-r--r--extensions/source/nsplugin/source/so_main.cxx500
-rw-r--r--extensions/source/nsplugin/source/so_msg.hxx57
-rw-r--r--extensions/source/ole/comifaces.hxx72
-rw-r--r--extensions/source/ole/jscriptclasses.cxx324
-rw-r--r--extensions/source/ole/jscriptclasses.hxx163
-rw-r--r--extensions/source/ole/makefile.mk129
-rw-r--r--extensions/source/ole/ole2uno.cxx76
-rw-r--r--extensions/source/ole/ole2uno.hxx147
-rw-r--r--extensions/source/ole/oleautobridge.uno.dxp4
-rw-r--r--extensions/source/ole/oledll.cxx72
-rw-r--r--extensions/source/ole/oleobjw.cxx2391
-rw-r--r--extensions/source/ole/oleobjw.hxx284
-rw-r--r--extensions/source/ole/olethread.cxx79
-rw-r--r--extensions/source/ole/servprov.cxx757
-rw-r--r--extensions/source/ole/servprov.hxx279
-rw-r--r--extensions/source/ole/servreg.cxx176
-rw-r--r--extensions/source/ole/unoconversionutilities.hxx2452
-rw-r--r--extensions/source/ole/unoobjw.cxx1690
-rw-r--r--extensions/source/ole/unoobjw.hxx302
-rw-r--r--extensions/source/ole/unotypewrapper.cxx181
-rw-r--r--extensions/source/ole/unotypewrapper.hxx103
-rw-r--r--extensions/source/ole/windata.cxx42
-rw-r--r--extensions/source/ole/windata.hxx201
-rw-r--r--extensions/source/oooimprovecore/core.cxx193
-rw-r--r--extensions/source/oooimprovecore/makefile.mk77
-rw-r--r--extensions/source/oooimprovecore/oooimprovecore_module.cxx39
-rw-r--r--extensions/source/oooimprovecore/oooimprovecore_module.hxx40
-rw-r--r--extensions/source/oooimprovecore/oooimprovecore_services.cxx55
-rw-r--r--extensions/source/oooimprovement/Jobs.xcu25
-rw-r--r--extensions/source/oooimprovement/Logging.xcu8
-rw-r--r--extensions/source/oooimprovement/config.cxx299
-rw-r--r--extensions/source/oooimprovement/config.hxx71
-rw-r--r--extensions/source/oooimprovement/corecontroller.cxx92
-rw-r--r--extensions/source/oooimprovement/corecontroller.hxx87
-rw-r--r--extensions/source/oooimprovement/errormail.cxx210
-rw-r--r--extensions/source/oooimprovement/errormail.hxx57
-rw-r--r--extensions/source/oooimprovement/invite_job.cxx136
-rw-r--r--extensions/source/oooimprovement/invite_job.hxx85
-rw-r--r--extensions/source/oooimprovement/logpacker.cxx117
-rw-r--r--extensions/source/oooimprovement/logpacker.hxx54
-rw-r--r--extensions/source/oooimprovement/logstorage.cxx149
-rw-r--r--extensions/source/oooimprovement/logstorage.hxx58
-rw-r--r--extensions/source/oooimprovement/makefile.mk104
-rw-r--r--extensions/source/oooimprovement/makefile.pmk29
-rw-r--r--extensions/source/oooimprovement/myconfigurationhelper.cxx181
-rw-r--r--extensions/source/oooimprovement/myconfigurationhelper.hxx217
-rw-r--r--extensions/source/oooimprovement/onlogrotate_job.cxx205
-rw-r--r--extensions/source/oooimprovement/onlogrotate_job.hxx86
-rw-r--r--extensions/source/oooimprovement/oooimprovement_exports.cxx113
-rw-r--r--extensions/source/oooimprovement/soaprequest.cxx203
-rw-r--r--extensions/source/oooimprovement/soaprequest.hxx63
-rw-r--r--extensions/source/oooimprovement/soapsender.cxx163
-rw-r--r--extensions/source/oooimprovement/soapsender.hxx59
-rw-r--r--extensions/source/plugin/aqua/macmgr.cxx648
-rw-r--r--extensions/source/plugin/aqua/makefile.mk74
-rw-r--r--extensions/source/plugin/aqua/sysplug.cxx810
-rw-r--r--extensions/source/plugin/base/context.cxx350
-rw-r--r--extensions/source/plugin/base/evtlstnr.cxx73
-rw-r--r--extensions/source/plugin/base/makefile.mk70
-rw-r--r--extensions/source/plugin/base/manager.cxx233
-rw-r--r--extensions/source/plugin/base/multiplx.cxx335
-rw-r--r--extensions/source/plugin/base/nfuncs.cxx686
-rw-r--r--extensions/source/plugin/base/plcom.cxx79
-rw-r--r--extensions/source/plugin/base/plctrl.cxx325
-rw-r--r--extensions/source/plugin/base/plmodel.cxx206
-rw-r--r--extensions/source/plugin/base/service.cxx129
-rw-r--r--extensions/source/plugin/base/xplugin.cxx1162
-rw-r--r--extensions/source/plugin/inc/plugin/aqua/sysplug.hxx169
-rw-r--r--extensions/source/plugin/inc/plugin/impl.hxx433
-rw-r--r--extensions/source/plugin/inc/plugin/model.hxx139
-rw-r--r--extensions/source/plugin/inc/plugin/multiplx.hxx169
-rw-r--r--extensions/source/plugin/inc/plugin/plcom.hxx88
-rw-r--r--extensions/source/plugin/inc/plugin/plctrl.hxx183
-rw-r--r--extensions/source/plugin/inc/plugin/unx/mediator.hxx186
-rw-r--r--extensions/source/plugin/inc/plugin/unx/plugcon.hxx254
-rw-r--r--extensions/source/plugin/inc/plugin/unx/sysplug.hxx86
-rw-r--r--extensions/source/plugin/inc/plugin/win/sysplug.hxx127
-rw-r--r--extensions/source/plugin/unx/makefile.mk111
-rw-r--r--extensions/source/plugin/unx/mediator.cxx312
-rw-r--r--extensions/source/plugin/unx/npnapi.cxx926
-rw-r--r--extensions/source/plugin/unx/nppapi.cxx630
-rw-r--r--extensions/source/plugin/unx/npwrap.cxx522
-rw-r--r--extensions/source/plugin/unx/plugcon.cxx292
-rw-r--r--extensions/source/plugin/unx/sysplug.cxx141
-rw-r--r--extensions/source/plugin/unx/unxmgr.cxx325
-rw-r--r--extensions/source/plugin/util/makefile.mk109
-rw-r--r--extensions/source/plugin/util/makefile.pmk48
-rw-r--r--extensions/source/plugin/win/makefile.mk65
-rw-r--r--extensions/source/plugin/win/sysplug.cxx446
-rw-r--r--extensions/source/plugin/win/winmgr.cxx472
-rw-r--r--extensions/source/preload/makefile.mk85
-rw-r--r--extensions/source/preload/modulepreload.cxx34
-rw-r--r--extensions/source/preload/oemwiz.cxx469
-rw-r--r--extensions/source/preload/oemwiz.hxx156
-rw-r--r--extensions/source/preload/preload.hrc58
-rw-r--r--extensions/source/preload/preload.src282
-rw-r--r--extensions/source/preload/preloadservices.cxx73
-rw-r--r--extensions/source/preload/preloadservices.hxx57
-rw-r--r--extensions/source/preload/services.cxx109
-rw-r--r--extensions/source/preload/unoautopilot.hxx109
-rw-r--r--extensions/source/preload/unoautopilot.inl133
-rw-r--r--extensions/source/propctrlr/MasterDetailLinkDialog.cxx160
-rw-r--r--extensions/source/propctrlr/MasterDetailLinkDialog.hxx87
-rw-r--r--extensions/source/propctrlr/browserline.cxx550
-rw-r--r--extensions/source/propctrlr/browserline.hxx143
-rw-r--r--extensions/source/propctrlr/browserlistbox.cxx1312
-rw-r--r--extensions/source/propctrlr/browserlistbox.hxx248
-rw-r--r--extensions/source/propctrlr/browserpage.cxx107
-rw-r--r--extensions/source/propctrlr/browserpage.hxx70
-rw-r--r--extensions/source/propctrlr/browserview.cxx146
-rw-r--r--extensions/source/propctrlr/browserview.hxx91
-rw-r--r--extensions/source/propctrlr/buttonnavigationhandler.cxx297
-rw-r--r--extensions/source/propctrlr/buttonnavigationhandler.hxx92
-rw-r--r--extensions/source/propctrlr/cellbindinghandler.cxx507
-rw-r--r--extensions/source/propctrlr/cellbindinghandler.hxx111
-rw-r--r--extensions/source/propctrlr/cellbindinghelper.cxx568
-rw-r--r--extensions/source/propctrlr/cellbindinghelper.hxx293
-rw-r--r--extensions/source/propctrlr/commoncontrol.cxx208
-rw-r--r--extensions/source/propctrlr/commoncontrol.hxx339
-rw-r--r--extensions/source/propctrlr/composeduiupdate.cxx861
-rw-r--r--extensions/source/propctrlr/composeduiupdate.hxx233
-rw-r--r--extensions/source/propctrlr/controlfontdialog.cxx177
-rw-r--r--extensions/source/propctrlr/controlfontdialog.hxx102
-rw-r--r--extensions/source/propctrlr/controltype.hxx56
-rw-r--r--extensions/source/propctrlr/defaultforminspection.cxx267
-rw-r--r--extensions/source/propctrlr/defaultforminspection.hxx93
-rw-r--r--extensions/source/propctrlr/defaulthelpprovider.cxx209
-rw-r--r--extensions/source/propctrlr/defaulthelpprovider.hxx96
-rw-r--r--extensions/source/propctrlr/editpropertyhandler.cxx325
-rw-r--r--extensions/source/propctrlr/editpropertyhandler.hxx84
-rw-r--r--extensions/source/propctrlr/eformshelper.cxx788
-rw-r--r--extensions/source/propctrlr/eformshelper.hxx271
-rw-r--r--extensions/source/propctrlr/eformspropertyhandler.cxx618
-rw-r--r--extensions/source/propctrlr/eformspropertyhandler.hxx110
-rw-r--r--extensions/source/propctrlr/enumrepresentation.hxx78
-rw-r--r--extensions/source/propctrlr/eventhandler.cxx1287
-rw-r--r--extensions/source/propctrlr/eventhandler.hxx269
-rw-r--r--extensions/source/propctrlr/fontdialog.cxx609
-rw-r--r--extensions/source/propctrlr/fontdialog.hxx85
-rw-r--r--extensions/source/propctrlr/fontdialog.src60
-rw-r--r--extensions/source/propctrlr/fontitemids.hxx68
-rw-r--r--extensions/source/propctrlr/formbrowsertools.cxx146
-rw-r--r--extensions/source/propctrlr/formbrowsertools.hxx110
-rw-r--r--extensions/source/propctrlr/formcomponenthandler.cxx3344
-rw-r--r--extensions/source/propctrlr/formcomponenthandler.hxx481
-rw-r--r--extensions/source/propctrlr/formcontroller.cxx300
-rw-r--r--extensions/source/propctrlr/formcontroller.hxx142
-rw-r--r--extensions/source/propctrlr/formgeometryhandler.cxx829
-rw-r--r--extensions/source/propctrlr/formlinkdialog.cxx675
-rw-r--r--extensions/source/propctrlr/formlinkdialog.hrc44
-rw-r--r--extensions/source/propctrlr/formlinkdialog.hxx151
-rw-r--r--extensions/source/propctrlr/formlinkdialog.src160
-rw-r--r--extensions/source/propctrlr/formlocalid.hrc39
-rw-r--r--extensions/source/propctrlr/formmetadata.cxx705
-rw-r--r--extensions/source/propctrlr/formmetadata.hxx351
-rw-r--r--extensions/source/propctrlr/formres.src1527
-rw-r--r--extensions/source/propctrlr/formresid.hrc390
-rw-r--r--extensions/source/propctrlr/formstrings.cxx38
-rw-r--r--extensions/source/propctrlr/formstrings.hxx310
-rw-r--r--extensions/source/propctrlr/genericpropertyhandler.cxx728
-rw-r--r--extensions/source/propctrlr/genericpropertyhandler.hxx163
-rw-r--r--extensions/source/propctrlr/handlerhelper.cxx290
-rw-r--r--extensions/source/propctrlr/handlerhelper.hxx219
-rw-r--r--extensions/source/propctrlr/inspectorhelpwindow.cxx153
-rw-r--r--extensions/source/propctrlr/inspectorhelpwindow.hxx80
-rw-r--r--extensions/source/propctrlr/inspectormodelbase.cxx275
-rw-r--r--extensions/source/propctrlr/inspectormodelbase.hxx110
-rw-r--r--extensions/source/propctrlr/linedescriptor.hxx72
-rw-r--r--extensions/source/propctrlr/listselectiondlg.cxx170
-rw-r--r--extensions/source/propctrlr/listselectiondlg.hrc39
-rw-r--r--extensions/source/propctrlr/listselectiondlg.hxx89
-rw-r--r--extensions/source/propctrlr/listselectiondlg.src80
-rw-r--r--extensions/source/propctrlr/makefile.mk146
-rw-r--r--extensions/source/propctrlr/modulepcr.cxx47
-rw-r--r--extensions/source/propctrlr/modulepcr.hxx47
-rw-r--r--extensions/source/propctrlr/newdatatype.cxx105
-rw-r--r--extensions/source/propctrlr/newdatatype.hrc38
-rw-r--r--extensions/source/propctrlr/newdatatype.hxx77
-rw-r--r--extensions/source/propctrlr/newdatatype.src77
-rw-r--r--extensions/source/propctrlr/objectinspectormodel.cxx245
-rw-r--r--extensions/source/propctrlr/pcr.xml146
-rw-r--r--extensions/source/propctrlr/pcrcommon.cxx71
-rw-r--r--extensions/source/propctrlr/pcrcommon.hxx155
-rw-r--r--extensions/source/propctrlr/pcrcommontypes.hxx53
-rw-r--r--extensions/source/propctrlr/pcrcomponentcontext.cxx108
-rw-r--r--extensions/source/propctrlr/pcrcomponentcontext.hxx170
-rw-r--r--extensions/source/propctrlr/pcrmiscres.src189
-rw-r--r--extensions/source/propctrlr/pcrservices.cxx145
-rw-r--r--extensions/source/propctrlr/pcrstrings.cxx38
-rw-r--r--extensions/source/propctrlr/pcrstrings.hxx48
-rw-r--r--extensions/source/propctrlr/pcrunodialogs.cxx148
-rw-r--r--extensions/source/propctrlr/pcrunodialogs.hxx96
-rw-r--r--extensions/source/propctrlr/propcontroller.cxx1773
-rw-r--r--extensions/source/propctrlr/propcontroller.hxx430
-rw-r--r--extensions/source/propctrlr/propcontrolobserver.hxx58
-rw-r--r--extensions/source/propctrlr/propertycomposer.cxx518
-rw-r--r--extensions/source/propctrlr/propertycomposer.hxx159
-rw-r--r--extensions/source/propctrlr/propertycontrolextender.cxx146
-rw-r--r--extensions/source/propctrlr/propertycontrolextender.hxx77
-rw-r--r--extensions/source/propctrlr/propertyeditor.cxx544
-rw-r--r--extensions/source/propctrlr/propertyeditor.hxx165
-rw-r--r--extensions/source/propctrlr/propertyhandler.cxx466
-rw-r--r--extensions/source/propctrlr/propertyhandler.hxx457
-rw-r--r--extensions/source/propctrlr/propertyinfo.hxx67
-rw-r--r--extensions/source/propctrlr/propeventtranslation.cxx107
-rw-r--r--extensions/source/propctrlr/propeventtranslation.hxx86
-rw-r--r--extensions/source/propctrlr/proplinelistener.hxx53
-rw-r--r--extensions/source/propctrlr/propres.src68
-rw-r--r--extensions/source/propctrlr/propresid.hrc48
-rw-r--r--extensions/source/propctrlr/pushbuttonnavigation.cxx309
-rw-r--r--extensions/source/propctrlr/pushbuttonnavigation.hxx111
-rw-r--r--extensions/source/propctrlr/selectlabeldialog.cxx313
-rw-r--r--extensions/source/propctrlr/selectlabeldialog.hxx89
-rw-r--r--extensions/source/propctrlr/selectlabeldialog.src83
-rw-r--r--extensions/source/propctrlr/sqlcommanddesign.cxx391
-rw-r--r--extensions/source/propctrlr/sqlcommanddesign.hxx225
-rw-r--r--extensions/source/propctrlr/standardcontrol.cxx1440
-rw-r--r--extensions/source/propctrlr/standardcontrol.hxx447
-rw-r--r--extensions/source/propctrlr/stlops.hxx72
-rw-r--r--extensions/source/propctrlr/stringdefine.hxx101
-rw-r--r--extensions/source/propctrlr/stringrepresentation.cxx646
-rw-r--r--extensions/source/propctrlr/submissionhandler.cxx450
-rw-r--r--extensions/source/propctrlr/submissionhandler.hxx127
-rw-r--r--extensions/source/propctrlr/taborder.cxx421
-rw-r--r--extensions/source/propctrlr/taborder.hrc45
-rw-r--r--extensions/source/propctrlr/taborder.hxx127
-rw-r--r--extensions/source/propctrlr/taborder.src103
-rw-r--r--extensions/source/propctrlr/unourl.cxx72
-rw-r--r--extensions/source/propctrlr/unourl.hxx67
-rw-r--r--extensions/source/propctrlr/usercontrol.cxx372
-rw-r--r--extensions/source/propctrlr/usercontrol.hxx174
-rw-r--r--extensions/source/propctrlr/xsddatatypes.cxx252
-rw-r--r--extensions/source/propctrlr/xsddatatypes.hxx116
-rw-r--r--extensions/source/propctrlr/xsdvalidationhelper.cxx414
-rw-r--r--extensions/source/propctrlr/xsdvalidationhelper.hxx152
-rw-r--r--extensions/source/propctrlr/xsdvalidationpropertyhandler.cxx695
-rw-r--r--extensions/source/propctrlr/xsdvalidationpropertyhandler.hxx105
-rw-r--r--extensions/source/resource/exports.dxp3
-rw-r--r--extensions/source/resource/makefile.mk76
-rw-r--r--extensions/source/resource/oooresourceloader.cxx492
-rw-r--r--extensions/source/resource/res_services.cxx131
-rw-r--r--extensions/source/resource/res_services.hxx67
-rw-r--r--extensions/source/resource/resource.cxx472
-rw-r--r--extensions/source/scanner/exports.dxp3
-rw-r--r--extensions/source/scanner/grid.cxx611
-rw-r--r--extensions/source/scanner/grid.hrc42
-rw-r--r--extensions/source/scanner/grid.hxx150
-rw-r--r--extensions/source/scanner/grid.src112
-rw-r--r--extensions/source/scanner/makefile.mk96
-rw-r--r--extensions/source/scanner/sane.cxx1008
-rw-r--r--extensions/source/scanner/sane.hxx203
-rw-r--r--extensions/source/scanner/sanedlg.cxx1433
-rw-r--r--extensions/source/scanner/sanedlg.hrc82
-rw-r--r--extensions/source/scanner/sanedlg.hxx153
-rw-r--r--extensions/source/scanner/sanedlg.src301
-rw-r--r--extensions/source/scanner/scanner.cxx107
-rw-r--r--extensions/source/scanner/scanner.hxx113
-rw-r--r--extensions/source/scanner/scanunx.cxx386
-rw-r--r--extensions/source/scanner/scanwin.cxx1060
-rw-r--r--extensions/source/scanner/scnserv.cxx107
-rw-r--r--extensions/source/scanner/twain.cxx535
-rw-r--r--extensions/source/scanner/twain.hxx101
-rw-r--r--extensions/source/svg/makefile.mk67
-rw-r--r--extensions/source/svg/svgaction.cxx1461
-rw-r--r--extensions/source/svg/svgaction.hxx167
-rw-r--r--extensions/source/svg/svgcom.hxx77
-rw-r--r--extensions/source/svg/svgprinter.cxx331
-rw-r--r--extensions/source/svg/svgprinter.hxx70
-rw-r--r--extensions/source/svg/svguno.cxx131
-rw-r--r--extensions/source/svg/svgwriter.cxx178
-rw-r--r--extensions/source/svg/svgwriter.hxx63
-rw-r--r--extensions/source/unoactivex/main/initwindowpeer.cxx89
-rw-r--r--extensions/source/update/check/Addons.xcu26
-rw-r--r--extensions/source/update/check/Jobs.xcu42
-rw-r--r--extensions/source/update/check/actionlistener.hxx48
-rw-r--r--extensions/source/update/check/download.cxx463
-rw-r--r--extensions/source/update/check/download.hxx86
-rw-r--r--extensions/source/update/check/makefile.mk134
-rw-r--r--extensions/source/update/check/transform.pl61
-rw-r--r--extensions/source/update/check/updatecheck.cxx1691
-rw-r--r--extensions/source/update/check/updatecheck.hxx197
-rw-r--r--extensions/source/update/check/updatecheckconfig.cxx763
-rw-r--r--extensions/source/update/check/updatecheckconfig.hxx241
-rw-r--r--extensions/source/update/check/updatecheckconfiglistener.hxx46
-rw-r--r--extensions/source/update/check/updatecheckjob.cxx413
-rw-r--r--extensions/source/update/check/updatehdl.cxx1422
-rw-r--r--extensions/source/update/check/updatehdl.hrc83
-rw-r--r--extensions/source/update/check/updatehdl.hxx222
-rw-r--r--extensions/source/update/check/updatehdl.src264
-rw-r--r--extensions/source/update/check/updateinfo.hxx89
-rw-r--r--extensions/source/update/check/updateprotocol.cxx334
-rw-r--r--extensions/source/update/check/updateprotocol.hxx58
-rw-r--r--extensions/source/update/check/updateprotocoltest.cxx97
-rw-r--r--extensions/source/update/check/updchk.xml49
-rw-r--r--extensions/source/update/feed/makefile.mk64
-rw-r--r--extensions/source/update/feed/test/makefile.mk58
-rw-r--r--extensions/source/update/feed/test/updatefeedtest.cxx109
-rw-r--r--extensions/source/update/feed/updatefeed.cxx877
-rw-r--r--extensions/source/update/feed/updatefeed.xml49
-rw-r--r--extensions/source/update/tools/makefile.mk68
-rw-r--r--extensions/source/update/tools/ztool.cxx66
-rw-r--r--extensions/source/update/ui/makefile.mk74
-rw-r--r--extensions/source/update/ui/updatecheckui.cxx1085
-rw-r--r--extensions/source/update/ui/updatecheckui.hrc36
-rw-r--r--extensions/source/update/ui/updatecheckui.src51
-rw-r--r--extensions/source/update/ui/updchkui.xml34
-rw-r--r--extensions/source/xmlextract/makefile.mk65
-rw-r--r--extensions/source/xmlextract/xmxcom.hxx66
-rw-r--r--extensions/source/xmlextract/xmxtrct.cxx200
-rw-r--r--extensions/source/xmlextract/xmxtrct.hxx57
-rw-r--r--extensions/source/xmlextract/xmxuno.cxx103
-rw-r--r--extensions/stardiv/fontest/fontest.idl111
-rw-r--r--extensions/stardiv/fontest/makefile.mk48
-rw-r--r--extensions/stardiv/oinstchk/makefile.mk47
-rw-r--r--extensions/stardiv/oinstchk/oinstchk.idl108
-rw-r--r--extensions/stardiv/pgp/makefile.mk53
-rw-r--r--extensions/test/ole/AxTestComponents/AxTestComponents.cpp101
-rw-r--r--extensions/test/ole/AxTestComponents/AxTestComponents.def9
-rw-r--r--extensions/test/ole/AxTestComponents/AxTestComponents.dsp325
-rw-r--r--extensions/test/ole/AxTestComponents/AxTestComponents.idl257
-rw-r--r--extensions/test/ole/AxTestComponents/AxTestComponents.rc164
-rw-r--r--extensions/test/ole/AxTestComponents/AxTestComponents.sln31
-rw-r--r--extensions/test/ole/AxTestComponents/AxTestComponents.vcproj819
-rw-r--r--extensions/test/ole/AxTestComponents/Basic.cpp1366
-rw-r--r--extensions/test/ole/AxTestComponents/Basic.h270
-rw-r--r--extensions/test/ole/AxTestComponents/Basic.rgs50
-rw-r--r--extensions/test/ole/AxTestComponents/Foo.cpp49
-rw-r--r--extensions/test/ole/AxTestComponents/Foo.h66
-rw-r--r--extensions/test/ole/AxTestComponents/StdAfx.cpp35
-rw-r--r--extensions/test/ole/AxTestComponents/StdAfx.h59
-rw-r--r--extensions/test/ole/AxTestComponents/readme.txt4
-rw-r--r--extensions/test/ole/AxTestComponents/resource.h47
-rw-r--r--extensions/test/ole/DCOM/Clients/WriterDemo/Module1.bas8
-rw-r--r--extensions/test/ole/DCOM/Clients/WriterDemo/client_writerdemo.vbp33
-rw-r--r--extensions/test/ole/DCOM/Clients/WriterDemo/client_writerdemo.vbw1
-rw-r--r--extensions/test/ole/DCOM/Clients/WriterDemo/readme.txt4
-rw-r--r--extensions/test/ole/DCOM/dcom_test/Module1.bas38
-rw-r--r--extensions/test/ole/DCOM/dcom_test/dcom_test.vbp37
-rw-r--r--extensions/test/ole/DCOM/dcom_test/dcom_test.vbw1
-rw-r--r--extensions/test/ole/DCOM/dcom_test/readme.txt5
-rw-r--r--extensions/test/ole/DCOM/scriptComponents/WriterDemo.wsc186
-rw-r--r--extensions/test/ole/DCOM/scriptComponents/readme.txt13
-rw-r--r--extensions/test/ole/EventListenerSample/EventListener/EventListener.cpp74
-rw-r--r--extensions/test/ole/EventListenerSample/EventListener/EventListener.def9
-rw-r--r--extensions/test/ole/EventListenerSample/EventListener/EventListener.idl39
-rw-r--r--extensions/test/ole/EventListenerSample/EventListener/EventListener.rc136
-rw-r--r--extensions/test/ole/EventListenerSample/EventListener/EventListener.sln32
-rw-r--r--extensions/test/ole/EventListenerSample/EventListener/EventListener.vcproj927
-rw-r--r--extensions/test/ole/EventListenerSample/EventListener/EvtListener.cpp21
-rw-r--r--extensions/test/ole/EventListenerSample/EventListener/EvtListener.h38
-rw-r--r--extensions/test/ole/EventListenerSample/EventListener/EvtListener.rgs26
-rw-r--r--extensions/test/ole/EventListenerSample/EventListener/StdAfx.cpp15
-rw-r--r--extensions/test/ole/EventListenerSample/EventListener/StdAfx.h30
-rw-r--r--extensions/test/ole/EventListenerSample/EventListener/resource.h20
-rw-r--r--extensions/test/ole/EventListenerSample/VBEventListener/Module1.bas9
-rw-r--r--extensions/test/ole/EventListenerSample/VBEventListener/VBEventListener.cls78
-rw-r--r--extensions/test/ole/EventListenerSample/VBEventListener/VBasicEventListener.dllbin0 -> 24576 bytes
-rw-r--r--extensions/test/ole/EventListenerSample/VBEventListener/VBasicEventListener.vbp38
-rw-r--r--extensions/test/ole/EventListenerSample/VBEventListener/VBasicEventListener.vbw2
-rw-r--r--extensions/test/ole/EventListenerSample/VBEventListener/readme.txt7
-rw-r--r--extensions/test/ole/EventListenerSample/events.htm98
-rw-r--r--extensions/test/ole/EventListenerSample/readme.txt20
-rw-r--r--extensions/test/ole/JScriptNewStyle.htm1054
-rw-r--r--extensions/test/ole/MfcControl/MfcControl.cpp82
-rw-r--r--extensions/test/ole/MfcControl/MfcControl.def9
-rw-r--r--extensions/test/ole/MfcControl/MfcControl.dsp265
-rw-r--r--extensions/test/ole/MfcControl/MfcControl.h36
-rw-r--r--extensions/test/ole/MfcControl/MfcControl.odl82
-rw-r--r--extensions/test/ole/MfcControl/MfcControl.rc145
-rw-r--r--extensions/test/ole/MfcControl/MfcControl.sln25
-rw-r--r--extensions/test/ole/MfcControl/MfcControl.vcproj581
-rw-r--r--extensions/test/ole/MfcControl/MfcControlCtl.cpp347
-rw-r--r--extensions/test/ole/MfcControl/MfcControlCtl.h99
-rw-r--r--extensions/test/ole/MfcControl/MfcControlCtl.pngbin0 -> 204 bytes
-rw-r--r--extensions/test/ole/MfcControl/MfcControlPpg.cpp79
-rw-r--r--extensions/test/ole/MfcControl/MfcControlPpg.h49
-rw-r--r--extensions/test/ole/MfcControl/Resource.h23
-rw-r--r--extensions/test/ole/MfcControl/StdAfx.cpp8
-rw-r--r--extensions/test/ole/MfcControl/StdAfx.h33
-rw-r--r--extensions/test/ole/OleClient/OleClient.ini5
-rw-r--r--extensions/test/ole/OleClient/axhost.cxx58
-rw-r--r--extensions/test/ole/OleClient/axhost.hxx62
-rw-r--r--extensions/test/ole/OleClient/clientTest.cxx1326
-rw-r--r--extensions/test/ole/OleClient/funcs.cxx357
-rw-r--r--extensions/test/ole/OleClient/makefile.mk72
-rw-r--r--extensions/test/ole/OleClient/readme.txt10
-rw-r--r--extensions/test/ole/OleConverterVar1/convTest.cxx658
-rw-r--r--extensions/test/ole/OleConverterVar1/makefile.mk66
-rw-r--r--extensions/test/ole/OleConverterVar1/readme.txt10
-rw-r--r--extensions/test/ole/OleConverterVar1/smartarray.h236
-rw-r--r--extensions/test/ole/OleTest.htm1063
-rw-r--r--extensions/test/ole/ScriptTest.html1555
-rw-r--r--extensions/test/ole/StarBasic_OleClient/oleclient.bas609
-rw-r--r--extensions/test/ole/StarBasic_OleClient/readme.txt10
-rw-r--r--extensions/test/ole/VisualBasic/AssemblyInfo.vb33
-rw-r--r--extensions/test/ole/VisualBasic/Module1.vb853
-rw-r--r--extensions/test/ole/VisualBasic/Project1.sln20
-rw-r--r--extensions/test/ole/VisualBasic/Project1.vbproj90
-rw-r--r--extensions/test/ole/VisualBasic/readme.txt18
-rw-r--r--extensions/test/ole/callUnoToJava.htm538
-rw-r--r--extensions/test/ole/cpnt/cpnt.cxx2126
-rw-r--r--extensions/test/ole/cpnt/exports.dxp3
-rw-r--r--extensions/test/ole/cpnt/makefile.mk102
-rw-r--r--extensions/test/ole/cpnt/readme.txt21
-rw-r--r--extensions/test/ole/cppToUno/makefile.mk65
-rw-r--r--extensions/test/ole/cppToUno/readme.txt9
-rw-r--r--extensions/test/ole/cppToUno/testcppuno.cxx222
-rw-r--r--extensions/test/ole/cpptest/cpptest.cxx116
-rw-r--r--extensions/test/ole/cpptest/makefile.mk64
-rw-r--r--extensions/test/ole/cpptest/readme.txt6
-rw-r--r--extensions/test/ole/idl/oletest.idl308
-rw-r--r--extensions/test/ole/unloading/makefile.mk70
-rw-r--r--extensions/test/ole/unloading/readme.txt6
-rw-r--r--extensions/test/ole/unloading/unloadTest.cxx229
-rw-r--r--extensions/test/ole/unoTocomCalls/Test/StdAfx.cpp37
-rw-r--r--extensions/test/ole/unoTocomCalls/Test/StdAfx.h58
-rw-r--r--extensions/test/ole/unoTocomCalls/Test/Test.cpp249
-rw-r--r--extensions/test/ole/unoTocomCalls/Test/Test.dsp114
-rw-r--r--extensions/test/ole/unoTocomCalls/Test/Test.sln19
-rw-r--r--extensions/test/ole/unoTocomCalls/Test/Test.vcproj247
-rw-r--r--extensions/test/ole/unoTocomCalls/XCallback_Impl/Basic.rgs27
-rw-r--r--extensions/test/ole/unoTocomCalls/XCallback_Impl/BasicTest.rgs27
-rw-r--r--extensions/test/ole/unoTocomCalls/XCallback_Impl/Callback.cpp514
-rw-r--r--extensions/test/ole/unoTocomCalls/XCallback_Impl/Callback.h138
-rw-r--r--extensions/test/ole/unoTocomCalls/XCallback_Impl/Callback.rgs27
-rw-r--r--extensions/test/ole/unoTocomCalls/XCallback_Impl/Simple.cpp82
-rw-r--r--extensions/test/ole/unoTocomCalls/XCallback_Impl/Simple.h67
-rw-r--r--extensions/test/ole/unoTocomCalls/XCallback_Impl/Simple.rgs27
-rw-r--r--extensions/test/ole/unoTocomCalls/XCallback_Impl/StdAfx.cpp41
-rw-r--r--extensions/test/ole/unoTocomCalls/XCallback_Impl/StdAfx.h59
-rw-r--r--extensions/test/ole/unoTocomCalls/XCallback_Impl/XCallback_Impl.cpp103
-rw-r--r--extensions/test/ole/unoTocomCalls/XCallback_Impl/XCallback_Impl.def10
-rw-r--r--extensions/test/ole/unoTocomCalls/XCallback_Impl/XCallback_Impl.dsp337
-rw-r--r--extensions/test/ole/unoTocomCalls/XCallback_Impl/XCallback_Impl.idl151
-rw-r--r--extensions/test/ole/unoTocomCalls/XCallback_Impl/XCallback_Impl.rc163
-rw-r--r--extensions/test/ole/unoTocomCalls/XCallback_Impl/XCallback_Impl.sln31
-rw-r--r--extensions/test/ole/unoTocomCalls/XCallback_Impl/XCallback_Impl.vcproj816
-rw-r--r--extensions/test/ole/unoTocomCalls/XCallback_Impl/resource.h48
-rw-r--r--extensions/test/ole/unoTocomCalls/readme.txt9
-rw-r--r--extensions/test/pgp/TestPGP.java146
-rw-r--r--extensions/test/pgp/makefile.mk124
-rw-r--r--extensions/test/pgp/readme.txt33
-rw-r--r--extensions/test/sax/exports.dxp2
-rw-r--r--extensions/test/sax/factory.hxx33
-rw-r--r--extensions/test/sax/makefile.mk64
-rw-r--r--extensions/test/sax/testsax.cxx910
-rw-r--r--extensions/test/sax/testwriter.cxx772
-rw-r--r--extensions/test/stm/datatest.cxx1073
-rw-r--r--extensions/test/stm/exports.dxp2
-rw-r--r--extensions/test/stm/makefile.mk61
-rw-r--r--extensions/test/stm/marktest.cxx685
-rw-r--r--extensions/test/stm/pipetest.cxx450
-rw-r--r--extensions/test/stm/testfactreg.cxx173
-rw-r--r--extensions/test/stm/testfactreg.hxx113
-rw-r--r--extensions/util/hidother.src428
-rw-r--r--extensions/util/makefile.mk39
-rw-r--r--extensions/util/makefile.pmk29
-rw-r--r--extensions/util/target.pmk35
-rw-r--r--extensions/workben/makefile.mk170
-rw-r--r--extensions/workben/pythonautotest.cxx623
-rw-r--r--extensions/workben/pythontest.cxx557
-rw-r--r--extensions/workben/testcomponent.cxx222
-rw-r--r--extensions/workben/testframecontrol.cxx319
-rw-r--r--extensions/workben/testpgp.cxx842
-rw-r--r--extensions/workben/testresource.cxx92
-rw-r--r--extensions/workben/testresource.src30
680 files changed, 158308 insertions, 0 deletions
diff --git a/extensions/inc/abpilot.hrc b/extensions/inc/abpilot.hrc
new file mode 100644
index 000000000000..aea77a3f3b9b
--- /dev/null
+++ b/extensions/inc/abpilot.hrc
@@ -0,0 +1,45 @@
+/*************************************************************************
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+************************************************************************/
+
+#ifndef EXTENSIONS_ABPILOT_HRC
+#define EXTENSIONS_ABPILOT_HRC
+
+#include "extensio.hrc"
+
+#define HID_ABSPILOT_PREVIOUS ( HID_ABP_START + 0)
+#define HID_ABSPILOT_NEXT ( HID_ABP_START + 1)
+#define HID_ABSPILOT_CANCEL ( HID_ABP_START + 2)
+#define HID_ABSPILOT_FINISH ( HID_ABP_START + 3)
+#define UID_ABSPILOT_HELP ( HID_ABP_START + 4)
+#define HID_ABSPILOT ( HID_ABP_START + 5)
+ // !! if you add new IDs, please also adjust HID_ABP_LAST below !!
+#define HID_ABP_LAST HID_ABSPILOT
+
+#if HID_ABP_LAST > HID_ABP_END
+ #error help id range overflow (ABP)
+#endif
+
+#endif // EXTENSIONS_ABPILOT_HRC
diff --git a/extensions/inc/appsettings.hxx b/extensions/inc/appsettings.hxx
new file mode 100644
index 000000000000..78f38ffb4fe5
--- /dev/null
+++ b/extensions/inc/appsettings.hxx
@@ -0,0 +1,45 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef _APPSETTINGS_HXX
+#define _APPSETTINGS_HXX
+
+#include <stardiv/uno/util/containr.hxx>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+XNameContainer* getApplicationSettings();
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/inc/bibliography.hrc b/extensions/inc/bibliography.hrc
new file mode 100644
index 000000000000..90372fc0b564
--- /dev/null
+++ b/extensions/inc/bibliography.hrc
@@ -0,0 +1,86 @@
+/*************************************************************************
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+************************************************************************/
+
+#ifndef EXTENSIONS_BIBLIOGRAPHY_HRC
+#define EXTENSIONS_BIBLIOGRAPHY_HRC
+
+#include "extensio.hrc"
+
+#define HID_BIB_CHANGESOURCE ( HID_BIBLIO_START + 0)
+#define HID_BIB_MAPPINGDLG ( HID_BIBLIO_START + 1)
+#define HID_BIB_TBX_TABLE ( HID_BIBLIO_START + 2)
+#define HID_BIB_TBX_SEARCH ( HID_BIBLIO_START + 3)
+#define HID_BIB_TBX_AUTOFILTER ( HID_BIBLIO_START + 4)
+#define HID_BIB_IDENTIFIER_POS ( HID_BIBLIO_START + 5)
+#define HID_BIB_AUTHORITYTYPE_POS ( HID_BIBLIO_START + 6)
+#define HID_BIB_AUTHOR_POS ( HID_BIBLIO_START + 7)
+#define HID_BIB_TITLE_POS ( HID_BIBLIO_START + 8)
+#define HID_BIB_YEAR_POS ( HID_BIBLIO_START + 9)
+#define HID_BIB_ISBN_POS ( HID_BIBLIO_START + 10)
+#define HID_BIB_BOOKTITLE_POS ( HID_BIBLIO_START + 11)
+#define HID_BIB_CHAPTER_POS ( HID_BIBLIO_START + 12)
+#define HID_BIB_EDITION_POS ( HID_BIBLIO_START + 13)
+#define HID_BIB_EDITOR_POS ( HID_BIBLIO_START + 14)
+#define HID_BIB_HOWPUBLISHED_POS ( HID_BIBLIO_START + 15)
+#define HID_BIB_INSTITUTION_POS ( HID_BIBLIO_START + 16)
+#define HID_BIB_JOURNAL_POS ( HID_BIBLIO_START + 17)
+#define HID_BIB_MONTH_POS ( HID_BIBLIO_START + 18)
+#define HID_BIB_NOTE_POS ( HID_BIBLIO_START + 19)
+#define HID_BIB_ANNOTE_POS ( HID_BIBLIO_START + 20)
+#define HID_BIB_NUMBER_POS ( HID_BIBLIO_START + 21)
+#define HID_BIB_ORGANIZATIONS_POS ( HID_BIBLIO_START + 22)
+#define HID_BIB_PAGES_POS ( HID_BIBLIO_START + 23)
+#define HID_BIB_PUBLISHER_POS ( HID_BIBLIO_START + 24)
+#define HID_BIB_ADDRESS_POS ( HID_BIBLIO_START + 25)
+#define HID_BIB_SCHOOL_POS ( HID_BIBLIO_START + 26)
+#define HID_BIB_SERIES_POS ( HID_BIBLIO_START + 27)
+#define HID_BIB_REPORTTYPE_POS ( HID_BIBLIO_START + 28)
+#define HID_BIB_VOLUME_POS ( HID_BIBLIO_START + 29)
+#define HID_BIB_URL_POS ( HID_BIBLIO_START + 30)
+#define HID_BIB_CUSTOM1_POS ( HID_BIBLIO_START + 31)
+#define HID_BIB_CUSTOM2_POS ( HID_BIBLIO_START + 32)
+#define HID_BIB_CUSTOM3_POS ( HID_BIBLIO_START + 33)
+#define HID_BIB_CUSTOM4_POS ( HID_BIBLIO_START + 34)
+#define HID_BIB_CUSTOM5_POS ( HID_BIBLIO_START + 35)
+#define HID_BIB_DB_TBX ( HID_BIBLIO_START + 36)
+#define HID_BIB_DB_GHIDCTRL ( HID_BIBLIO_START + 37)
+#define HID_BIB_CONTROL_PAGE ( HID_BIBLIO_START + 38)
+#define HID_BIB_CONTROL_PARENT ( HID_BIBLIO_START + 39)
+#define UID_BIB_FRAME_WINDOW ( HID_BIBLIO_START + 40)
+#define HID_BIB_DELETE_RECORD ( HID_BIBLIO_START + 41)
+#define HID_BIB_INSERT_RECORD ( HID_BIBLIO_START + 42)
+#define HID_BIB_DB_GRIDCTRL ( HID_BIBLIO_START + 43)
+#define HID_DLG_MAPPING ( HID_BIBLIO_START + 44)
+#define HID_DLG_DBCHANGE ( HID_BIBLIO_START + 45)
+#define HID_SELECTION_TLB ( HID_BIBLIO_START + 46)
+ // !! if you add new IDs, please also adjust HID_ABP_LAST below !!
+#define HID_BIB_LAST HID_SELECTION_TLB
+
+#if HID_BIB_LAST > HID_BIBLIO_END
+ #error help id range overflow (BIBLIO)
+#endif
+
+#endif // EXTENSIONS_BIBLIOGRAPHY_HRC
diff --git a/extensions/inc/dbpilots.hrc b/extensions/inc/dbpilots.hrc
new file mode 100644
index 000000000000..38a47138c875
--- /dev/null
+++ b/extensions/inc/dbpilots.hrc
@@ -0,0 +1,55 @@
+/*************************************************************************
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+************************************************************************/
+
+#ifndef EXTENSIONS_DBPILOT_HRC
+#define EXTENSIONS_DBPILOT_HRC
+
+#include "extensio.hrc"
+
+#define HID_GHIDWIZARD_PREVIOUS ( HID_DBP_START + 0)
+#define HID_GHIDWIZARD_NEXT ( HID_DBP_START + 1)
+#define HID_GHIDWIZARD_CANCEL ( HID_DBP_START + 2)
+#define HID_GHIDWIZARD_FINISH ( HID_DBP_START + 3)
+#define HID_GROUPWIZARD_PREVIOUS ( HID_DBP_START + 4)
+#define HID_GROUPWIZARD_NEXT ( HID_DBP_START + 5)
+#define HID_GROUPWIZARD_CANCEL ( HID_DBP_START + 6)
+#define HID_GROUPWIZARD_FINISH ( HID_DBP_START + 7)
+#define HID_LISTWIZARD_PREVIOUS ( HID_DBP_START + 8)
+#define HID_LISTWIZARD_NEXT ( HID_DBP_START + 9)
+#define HID_LISTWIZARD_CANCEL ( HID_DBP_START + 10)
+#define HID_LISTWIZARD_FINISH ( HID_DBP_START + 11)
+#define HID_GRIDWIZARD_PREVIOUS ( HID_DBP_START + 12)
+#define HID_GRIDWIZARD_NEXT ( HID_DBP_START + 13)
+#define HID_GRIDWIZARD_CANCEL ( HID_DBP_START + 14)
+#define HID_GRIDWIZARD_FINISH ( HID_DBP_START + 15)
+ // !! if you add new IDs, please also adjust HID_ABP_LAST below !!
+#define HID_DBP_LAST HID_GRIDWIZARD_FINISH
+
+#if HID_DBP_LAST > HID_DBP_END
+ #error help id range overflow (DBP)
+#endif
+
+#endif // EXTENSIONS_DBPILOT_HRC
diff --git a/extensions/inc/extensio.hrc b/extensions/inc/extensio.hrc
new file mode 100644
index 000000000000..5b1154763738
--- /dev/null
+++ b/extensions/inc/extensio.hrc
@@ -0,0 +1,75 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef EXTENSIONS_INC_EXTENSIO_HRC
+#define EXTENSIONS_INC_EXTENSIO_HRC
+
+#include <svl/solar.hrc>
+
+// -----------------------------------------------------------------------
+// - resource id ranges
+
+#define RID_ABP_START ( RID_MORE_EXTENSIONS_START + 0 )
+#define RID_ABP_END ( RID_MORE_EXTENSIONS_START + 19 )
+
+#define RID_DBP_START ( RID_MORE_EXTENSIONS_START + 20 )
+#define RID_DBP_END ( RID_MORE_EXTENSIONS_START + 39 )
+
+// !!! please adjust RID_LAST_EXTENSIONS_RANGE if you add new ranges here !!!
+
+#define RID_LAST_EXTENSIONS_RANGE RID_DBP_END
+
+#if RID_LAST_EXTENSIONS_RANGE > RID_MORE_EXTENSIONS_END
+ #error id range overflow
+#endif
+
+// -----------------------------------------------------------------------
+// - help id ranges
+
+#define HID_DBP_START ( HID_EXTENSIONS_START + 0 )
+#define HID_DBP_END ( HID_EXTENSIONS_START + 19 )
+
+#define HID_ABP_START ( HID_EXTENSIONS_START + 20 )
+#define HID_ABP_END ( HID_EXTENSIONS_START + 39 )
+
+#define HID_BIBLIO_START ( HID_EXTENSIONS_START + 40 )
+#define HID_BIBLIO_END ( HID_EXTENSIONS_START + 89 )
+
+#define HID_PROPC_START ( HID_EXTENSIONS_START + 90 )
+#define HID_PROPC_END ( HID_EXTENSIONS_START + 499 )
+
+#define HID_UPDATE_START ( HID_EXTENSIONS_START + 500 )
+#define HID_UPDATE_END ( HID_EXTENSIONS_START + 519 )
+
+// !!! please adjust HID_LAST_EXTENSIONS_RANGE if you add new ranges here !!!
+
+#define HID_LAST_EXTENSIONS_RANGE HID_UPDATE_END
+
+#if HID_LAST_EXTENSIONS_RANGE > HID_EXTENSIONS_END
+ #error id range overflow
+#endif
+
+#endif
diff --git a/extensions/inc/makefile.mk b/extensions/inc/makefile.mk
new file mode 100644
index 000000000000..9ea45ec08e14
--- /dev/null
+++ b/extensions/inc/makefile.mk
@@ -0,0 +1,47 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+PRJ=..
+
+PRJNAME=extensions
+TARGET=inc
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+
+# --- Files --------------------------------------------------------
+# --- Targets -------------------------------------------------------
+
+.INCLUDE : target.mk
+
+.IF "$(ENABLE_PCH)"!=""
+ALLTAR : \
+ $(SLO)$/precompiled.pch \
+ $(SLO)$/precompiled_ex.pch
+
+.ENDIF # "$(ENABLE_PCH)"!=""
+
diff --git a/extensions/inc/pch/precompiled_extensions.cxx b/extensions/inc/pch/precompiled_extensions.cxx
new file mode 100644
index 000000000000..6a73045125b8
--- /dev/null
+++ b/extensions/inc/pch/precompiled_extensions.cxx
@@ -0,0 +1,31 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "precompiled_extensions.hxx"
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/inc/pch/precompiled_extensions.hxx b/extensions/inc/pch/precompiled_extensions.hxx
new file mode 100644
index 000000000000..91c1d8849fc9
--- /dev/null
+++ b/extensions/inc/pch/precompiled_extensions.hxx
@@ -0,0 +1,551 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): Generated on 2006-09-01 17:49:41.030262
+
+#ifdef PRECOMPILED_HEADERS
+
+//---MARKER---
+#include "sal/config.h"
+#include "sal/types.h"
+
+
+#include "boost/scoped_array.hpp"
+#include "boost/shared_ptr.hpp"
+
+#include "com/sun/star/awt/FocusChangeReason.hpp"
+#include "com/sun/star/awt/FocusEvent.hpp"
+#include "com/sun/star/awt/FontDescriptor.hpp"
+#include "com/sun/star/awt/FontSlant.hpp"
+#include "com/sun/star/awt/FontStrikeout.hpp"
+#include "com/sun/star/awt/FontUnderline.hpp"
+#include "com/sun/star/awt/FontWeight.hpp"
+#include "com/sun/star/awt/Gradient.hpp"
+#include "com/sun/star/awt/GradientStyle.hpp"
+#include "com/sun/star/awt/InputEvent.hpp"
+#include "com/sun/star/awt/Key.hpp"
+#include "com/sun/star/awt/KeyEvent.hpp"
+#include "com/sun/star/awt/KeyFunction.hpp"
+#include "com/sun/star/awt/KeyGroup.hpp"
+#include "com/sun/star/awt/KeyModifier.hpp"
+#include "com/sun/star/awt/MouseButton.hpp"
+#include "com/sun/star/awt/MouseEvent.hpp"
+#include "com/sun/star/awt/PaintEvent.hpp"
+#include "com/sun/star/awt/PosSize.hpp"
+#include "com/sun/star/awt/RasterOperation.hpp"
+#include "com/sun/star/awt/Rectangle.hpp"
+#include "com/sun/star/awt/Size.hpp"
+#include "com/sun/star/awt/VclWindowPeerAttribute.hpp"
+#include "com/sun/star/awt/VisualEffect.hpp"
+#include "com/sun/star/awt/WindowDescriptor.hpp"
+#include "com/sun/star/awt/WindowEvent.hpp"
+#include "com/sun/star/awt/XActionListener.hpp"
+#include "com/sun/star/awt/XActivateListener.hpp"
+#include "com/sun/star/awt/XAdjustmentListener.hpp"
+#include "com/sun/star/awt/XBitmap.hpp"
+#include "com/sun/star/awt/XControl.hpp"
+#include "com/sun/star/awt/XControlContainer.hpp"
+#include "com/sun/star/awt/XControlModel.hpp"
+#include "com/sun/star/awt/XFocusListener.hpp"
+#include "com/sun/star/awt/XGraphics.hpp"
+#include "com/sun/star/awt/XItemListener.hpp"
+#include "com/sun/star/awt/XKeyListener.hpp"
+#include "com/sun/star/awt/XLayoutConstrains.hpp"
+#include "com/sun/star/awt/XMouseListener.hpp"
+#include "com/sun/star/awt/XMouseMotionListener.hpp"
+#include "com/sun/star/awt/XPaintListener.hpp"
+#include "com/sun/star/awt/XSpinListener.hpp"
+#include "com/sun/star/awt/XSystemChildFactory.hpp"
+#include "com/sun/star/awt/XTabController.hpp"
+#include "com/sun/star/awt/XTabControllerModel.hpp"
+#include "com/sun/star/awt/XTextListener.hpp"
+#include "com/sun/star/awt/XTopWindow.hpp"
+#include "com/sun/star/awt/XTopWindowListener.hpp"
+#include "com/sun/star/awt/XUnoControlContainer.hpp"
+#include "com/sun/star/awt/XVclContainer.hpp"
+#include "com/sun/star/awt/XVclContainerListener.hpp"
+#include "com/sun/star/awt/XVclContainerPeer.hpp"
+#include "com/sun/star/awt/XVclWindowPeer.hpp"
+#include "com/sun/star/awt/XWindow.hpp"
+#include "com/sun/star/awt/XWindowListener.hpp"
+#include "com/sun/star/awt/XWindowPeer.hpp"
+#include "com/sun/star/beans/MethodConcept.hpp"
+#include "com/sun/star/beans/NamedValue.hpp"
+#include "com/sun/star/beans/Optional.hpp"
+#include "com/sun/star/beans/Property.hpp"
+#include "com/sun/star/beans/PropertyAttribute.hpp"
+#include "com/sun/star/beans/PropertyChangeEvent.hpp"
+#include "com/sun/star/beans/PropertyConcept.hpp"
+#include "com/sun/star/beans/PropertyState.hpp"
+#include "com/sun/star/beans/PropertyStateChangeEvent.hpp"
+#include "com/sun/star/beans/PropertyValue.hpp"
+#include "com/sun/star/beans/PropertyValues.hpp"
+#include "com/sun/star/beans/UnknownPropertyException.hpp"
+#include "com/sun/star/beans/XExactName.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/XMultiPropertySet.hpp"
+#include "com/sun/star/beans/XPropertiesChangeListener.hpp"
+#include "com/sun/star/beans/XPropertyAccess.hpp"
+#include "com/sun/star/beans/XPropertyChangeListener.hpp"
+#include "com/sun/star/beans/XPropertyContainer.hpp"
+#include "com/sun/star/beans/XPropertySet.hpp"
+#include "com/sun/star/beans/XPropertySetInfo.hpp"
+#include "com/sun/star/beans/XPropertyState.hpp"
+#include "com/sun/star/beans/XPropertyStateChangeListener.hpp"
+#include "com/sun/star/beans/XVetoableChangeListener.hpp"
+#include "com/sun/star/bridge/ModelDependent.hpp"
+#include "com/sun/star/bridge/XBridgeSupplier2.hpp"
+#include "com/sun/star/bridge/XUnoUrlResolver.hpp"
+#include "com/sun/star/bridge/oleautomation/Currency.hpp"
+#include "com/sun/star/bridge/oleautomation/Date.hpp"
+#include "com/sun/star/bridge/oleautomation/Decimal.hpp"
+#include "com/sun/star/bridge/oleautomation/NamedArgument.hpp"
+#include "com/sun/star/bridge/oleautomation/PropertyPutArgument.hpp"
+#include "com/sun/star/bridge/oleautomation/SCode.hpp"
+#include "com/sun/star/bridge/oleautomation/XAutomationObject.hpp"
+#include "com/sun/star/configuration/backend/BackendAccessException.hpp"
+#include "com/sun/star/configuration/backend/CannotConnectException.hpp"
+#include "com/sun/star/configuration/backend/ConnectionLostException.hpp"
+#include "com/sun/star/configuration/backend/InsufficientAccessRightsException.hpp"
+#include "com/sun/star/configuration/backend/PropertyInfo.hpp"
+#include "com/sun/star/configuration/backend/XLayer.hpp"
+#include "com/sun/star/configuration/backend/XLayerContentDescriber.hpp"
+#include "com/sun/star/configuration/backend/XSingleLayerStratum.hpp"
+#include "com/sun/star/connection/ConnectionSetupException.hpp"
+#include "com/sun/star/container/NoSuchElementException.hpp"
+#include "com/sun/star/container/XChild.hpp"
+#include "com/sun/star/container/XElementAccess.hpp"
+#include "com/sun/star/container/XEnumeration.hpp"
+#include "com/sun/star/container/XEnumerationAccess.hpp"
+#include "com/sun/star/container/XHierarchicalNameAccess.hpp"
+#include "com/sun/star/container/XIndexAccess.hpp"
+#include "com/sun/star/container/XNameAccess.hpp"
+#include "com/sun/star/container/XNameContainer.hpp"
+#include "com/sun/star/container/XNameReplace.hpp"
+#include "com/sun/star/container/XNamed.hpp"
+#include "com/sun/star/container/XSet.hpp"
+#include "com/sun/star/datatransfer/clipboard/XClipboard.hpp"
+#include "com/sun/star/document/EventObject.hpp"
+#include "com/sun/star/document/XEventBroadcaster.hpp"
+#include "com/sun/star/document/XEventListener.hpp"
+#include "com/sun/star/form/FormButtonType.hpp"
+#include "com/sun/star/form/FormComponentType.hpp"
+#include "com/sun/star/form/FormSubmitEncoding.hpp"
+#include "com/sun/star/form/ListSourceType.hpp"
+#include "com/sun/star/form/XBoundComponent.hpp"
+#include "com/sun/star/form/XConfirmDeleteListener.hpp"
+#include "com/sun/star/form/XForm.hpp"
+#include "com/sun/star/form/XFormController.hpp"
+#include "com/sun/star/form/XFormsSupplier.hpp"
+#include "com/sun/star/form/XGridColumnFactory.hpp"
+#include "com/sun/star/form/XLoadListener.hpp"
+#include "com/sun/star/form/XLoadable.hpp"
+#include "com/sun/star/form/binding/XBindableValue.hpp"
+#include "com/sun/star/form/binding/XListEntrySink.hpp"
+#include "com/sun/star/form/binding/XListEntrySource.hpp"
+#include "com/sun/star/form/binding/XValueBinding.hpp"
+#include "com/sun/star/form/submission/XSubmissionSupplier.hpp"
+#include "com/sun/star/frame/CommandGroup.hpp"
+#include "com/sun/star/frame/DispatchResultEvent.hpp"
+#include "com/sun/star/frame/DispatchResultState.hpp"
+#include "com/sun/star/frame/FrameAction.hpp"
+#include "com/sun/star/frame/FrameActionEvent.hpp"
+#include "com/sun/star/frame/FrameSearchFlag.hpp"
+#include "com/sun/star/frame/XComponentLoader.hpp"
+#include "com/sun/star/frame/XController.hpp"
+#include "com/sun/star/frame/XDesktop.hpp"
+#include "com/sun/star/frame/XDispatch.hpp"
+#include "com/sun/star/frame/XDispatchHelper.hpp"
+#include "com/sun/star/frame/XDispatchInformationProvider.hpp"
+#include "com/sun/star/frame/XDispatchProvider.hpp"
+#include "com/sun/star/frame/XDispatchProviderInterception.hpp"
+#include "com/sun/star/frame/XDispatchProviderInterceptor.hpp"
+#include "com/sun/star/frame/XFrame.hpp"
+#include "com/sun/star/frame/XFrameActionListener.hpp"
+#include "com/sun/star/frame/XFrameLoader.hpp"
+#include "com/sun/star/frame/XFrames.hpp"
+#include "com/sun/star/frame/XFramesSupplier.hpp"
+#include "com/sun/star/frame/XModel.hpp"
+#include "com/sun/star/frame/XStatusListener.hpp"
+#include "com/sun/star/frame/XStorable.hpp"
+#include "com/sun/star/graphic/XGraphicProvider.hpp"
+#include "com/sun/star/inspection/LineDescriptor.hpp"
+#include "com/sun/star/inspection/PropertyControlType.hpp"
+#include "com/sun/star/inspection/PropertyLineElement.hpp"
+#include "com/sun/star/inspection/XHyperlinkControl.hpp"
+#include "com/sun/star/inspection/XNumericControl.hpp"
+#include "com/sun/star/inspection/XObjectInspector.hpp"
+#include "com/sun/star/inspection/XObjectInspectorModel.hpp"
+#include "com/sun/star/inspection/XObjectInspectorUI.hpp"
+#include "com/sun/star/inspection/XPropertyControl.hpp"
+#include "com/sun/star/inspection/XPropertyControlFactory.hpp"
+#include "com/sun/star/inspection/XPropertyHandler.hpp"
+#include "com/sun/star/inspection/XStringListControl.hpp"
+#include "com/sun/star/installation/ProtDlgRes.hpp"
+#include "com/sun/star/installation/XProtocolHandlerCheck.hpp"
+#include "com/sun/star/installation/protocols.hpp"
+#include "com/sun/star/io/BufferSizeExceededException.hpp"
+#include "com/sun/star/io/IOException.hpp"
+#include "com/sun/star/io/NotConnectedException.hpp"
+#include "com/sun/star/io/XActiveDataControl.hpp"
+#include "com/sun/star/io/XActiveDataSink.hpp"
+#include "com/sun/star/io/XActiveDataSource.hpp"
+#include "com/sun/star/io/XConnectable.hpp"
+#include "com/sun/star/io/XDataInputStream.hpp"
+#include "com/sun/star/io/XDataOutputStream.hpp"
+#include "com/sun/star/io/XInputStream.hpp"
+#include "com/sun/star/io/XMarkableStream.hpp"
+#include "com/sun/star/io/XObjectInputStream.hpp"
+#include "com/sun/star/io/XObjectOutputStream.hpp"
+#include "com/sun/star/io/XOutputStream.hpp"
+#include "com/sun/star/io/XPersistObject.hpp"
+#include "com/sun/star/io/XSeekable.hpp"
+#include "com/sun/star/io/XStreamListener.hpp"
+#include "com/sun/star/io/XXMLExtractor.hpp"
+#include "com/sun/star/lang/DisposedException.hpp"
+#include "com/sun/star/lang/EventObject.hpp"
+#include "com/sun/star/lang/IllegalArgumentException.hpp"
+#include "com/sun/star/lang/IndexOutOfBoundsException.hpp"
+#include "com/sun/star/lang/NullPointerException.hpp"
+#include "com/sun/star/lang/ServiceNotRegisteredException.hpp"
+#include "com/sun/star/lang/SystemDependent.hpp"
+#include "com/sun/star/lang/WrappedTargetException.hpp"
+#include "com/sun/star/lang/XComponent.hpp"
+#include "com/sun/star/lang/XEventListener.hpp"
+#include "com/sun/star/lang/XInitialization.hpp"
+#include "com/sun/star/lang/XLocalizable.hpp"
+#include "com/sun/star/lang/XMultiComponentFactory.hpp"
+#include "com/sun/star/lang/XMultiServiceFactory.hpp"
+#include "com/sun/star/lang/XServiceInfo.hpp"
+#include "com/sun/star/lang/XServiceName.hpp"
+#include "com/sun/star/lang/XSingleServiceFactory.hpp"
+#include "com/sun/star/lang/XTypeProvider.hpp"
+#include "com/sun/star/lang/XUnoTunnel.hpp"
+#include "com/sun/star/ldap/LdapConnectionException.hpp"
+#include "com/sun/star/ldap/LdapGenericException.hpp"
+#include "com/sun/star/loader/CannotActivateFactoryException.hpp"
+#include "com/sun/star/loader/XImplementationLoader.hpp"
+#include "com/sun/star/plugin/PluginDescription.hpp"
+#include "com/sun/star/plugin/PluginException.hpp"
+#include "com/sun/star/plugin/PluginMode.hpp"
+#include "com/sun/star/plugin/PluginVariable.hpp"
+#include "com/sun/star/plugin/XPlugin.hpp"
+#include "com/sun/star/plugin/XPluginContext.hpp"
+#include "com/sun/star/plugin/XPluginManager.hpp"
+#include "com/sun/star/reflection/InvocationTargetException.hpp"
+#include "com/sun/star/reflection/ParamInfo.hpp"
+#include "com/sun/star/reflection/XEnumTypeDescription.hpp"
+#include "com/sun/star/reflection/XIdlReflection.hpp"
+#include "com/sun/star/registry/InvalidRegistryException.hpp"
+#include "com/sun/star/registry/InvalidValueException.hpp"
+#include "com/sun/star/registry/RegistryKeyType.hpp"
+#include "com/sun/star/registry/RegistryValueType.hpp"
+#include "com/sun/star/registry/XRegistryKey.hpp"
+#include "com/sun/star/registry/XSimpleRegistry.hpp"
+#include "com/sun/star/resource/XResourceBundleLoader.hpp"
+#include "com/sun/star/scanner/ScannerException.hpp"
+#include "com/sun/star/scanner/XScannerManager.hpp"
+#include "com/sun/star/script/ContextInformation.hpp"
+#include "com/sun/star/script/FailReason.hpp"
+#include "com/sun/star/script/FinishEngineEvent.hpp"
+#include "com/sun/star/script/FinishReason.hpp"
+#include "com/sun/star/script/InterruptEngineEvent.hpp"
+#include "com/sun/star/script/InterruptReason.hpp"
+#include "com/sun/star/script/InvocationInfo.hpp"
+#include "com/sun/star/script/MemberType.hpp"
+#include "com/sun/star/script/ScriptEventDescriptor.hpp"
+#include "com/sun/star/script/XDebugging.hpp"
+#include "com/sun/star/script/XEngine.hpp"
+#include "com/sun/star/script/XEngineListener.hpp"
+#include "com/sun/star/script/XEventAttacherManager.hpp"
+#include "com/sun/star/script/XInvocation.hpp"
+#include "com/sun/star/script/XInvocation2.hpp"
+#include "com/sun/star/script/XInvocationAdapterFactory.hpp"
+#include "com/sun/star/script/XInvocationAdapterFactory2.hpp"
+#include "com/sun/star/script/XLibraryAccess.hpp"
+#include "com/sun/star/script/XScriptEventsSupplier.hpp"
+#include "com/sun/star/script/XTypeConverter.hpp"
+#include "com/sun/star/sdb/CommandType.hpp"
+#include "com/sun/star/sdb/RowChangeAction.hpp"
+#include "com/sun/star/sdb/SQLContext.hpp"
+#include "com/sun/star/sdb/XColumn.hpp"
+#include "com/sun/star/sdb/XCompletedConnection.hpp"
+#include "com/sun/star/sdb/XDatabaseEnvironment.hpp"
+#include "com/sun/star/sdb/XDocumentDataSource.hpp"
+#include "com/sun/star/sdb/XQueriesSupplier.hpp"
+#include "com/sun/star/sdb/XSingleSelectQueryComposer.hpp"
+#include "com/sun/star/sdbc/DataType.hpp"
+#include "com/sun/star/sdbc/ResultSetConcurrency.hpp"
+#include "com/sun/star/sdbc/ResultSetType.hpp"
+#include "com/sun/star/sdbc/SQLWarning.hpp"
+#include "com/sun/star/sdbc/XConnection.hpp"
+#include "com/sun/star/sdbc/XDataSource.hpp"
+#include "com/sun/star/sdbc/XDatabaseMetaData.hpp"
+#include "com/sun/star/sdbc/XDriverAccess.hpp"
+#include "com/sun/star/sdbc/XPreparedStatement.hpp"
+#include "com/sun/star/sdbc/XResultSet.hpp"
+#include "com/sun/star/sdbc/XResultSetUpdate.hpp"
+#include "com/sun/star/sdbc/XRowSet.hpp"
+#include "com/sun/star/sdbc/XRowSetListener.hpp"
+#include "com/sun/star/sdbcx/KeyType.hpp"
+#include "com/sun/star/sdbcx/Privilege.hpp"
+#include "com/sun/star/sdbcx/XColumnsSupplier.hpp"
+#include "com/sun/star/sdbcx/XKeysSupplier.hpp"
+#include "com/sun/star/sdbcx/XRowLocate.hpp"
+#include "com/sun/star/sdbcx/XTablesSupplier.hpp"
+#include "com/sun/star/sheet/XSpreadsheetDocument.hpp"
+#include "com/sun/star/sheet/XSpreadsheetView.hpp"
+#include "com/sun/star/svg/XSVGPrinter.hpp"
+#include "com/sun/star/svg/XSVGWriter.hpp"
+#include "com/sun/star/system/SystemShellExecuteException.hpp"
+#include "com/sun/star/system/SystemShellExecuteFlags.hpp"
+#include "com/sun/star/system/XSystemShellExecute.hpp"
+#include "com/sun/star/table/CellAddress.hpp"
+#include "com/sun/star/table/CellRangeAddress.hpp"
+#include "com/sun/star/table/XCellRange.hpp"
+#include "com/sun/star/task/XInteractionAbort.hpp"
+#include "com/sun/star/task/XInteractionApprove.hpp"
+#include "com/sun/star/task/XInteractionContinuation.hpp"
+#include "com/sun/star/task/XInteractionDisapprove.hpp"
+#include "com/sun/star/task/XInteractionHandler.hpp"
+#include "com/sun/star/task/XInteractionRequest.hpp"
+#include "com/sun/star/task/XInteractionRetry.hpp"
+#include "com/sun/star/task/XJob.hpp"
+#include "com/sun/star/text/BibliographyDataField.hpp"
+#include "com/sun/star/text/TextContentAnchorType.hpp"
+#include "com/sun/star/ucb/AlreadyInitializedException.hpp"
+#include "com/sun/star/ucb/Command.hpp"
+#include "com/sun/star/ucb/CommandAbortedException.hpp"
+#include "com/sun/star/ucb/ContentEvent.hpp"
+#include "com/sun/star/ucb/IOErrorCode.hpp"
+#include "com/sun/star/ucb/IllegalIdentifierException.hpp"
+#include "com/sun/star/ucb/InteractiveAugmentedIOException.hpp"
+#include "com/sun/star/ucb/InteractiveWrongMediumException.hpp"
+#include "com/sun/star/ucb/PostCommandArgument.hpp"
+#include "com/sun/star/ucb/PostCommandArgument2.hpp"
+#include "com/sun/star/ucb/XCommandEnvironment.hpp"
+#include "com/sun/star/ucb/XCommandInfo.hpp"
+#include "com/sun/star/ucb/XCommandProcessor.hpp"
+#include "com/sun/star/ucb/XCommandProcessor2.hpp"
+#include "com/sun/star/ucb/XContent.hpp"
+#include "com/sun/star/ucb/XContentAccess.hpp"
+#include "com/sun/star/ucb/XContentEventListener.hpp"
+#include "com/sun/star/ucb/XContentIdentifier.hpp"
+#include "com/sun/star/ucb/XContentIdentifierFactory.hpp"
+#include "com/sun/star/ucb/XContentProvider.hpp"
+#include "com/sun/star/ucb/XProgressHandler.hpp"
+#include "com/sun/star/ucb/XSimpleFileAccess.hpp"
+#include "com/sun/star/ui/dialogs/ExtendedFilePickerElementIds.hpp"
+#include "com/sun/star/ui/dialogs/TemplateDescription.hpp"
+#include "com/sun/star/ui/dialogs/XExecutableDialog.hpp"
+#include "com/sun/star/ui/dialogs/XFilePickerControlAccess.hpp"
+#include "com/sun/star/uno/Any.h"
+#include "com/sun/star/uno/Any.hxx"
+#include "com/sun/star/uno/Exception.hpp"
+#include "com/sun/star/uno/Reference.h"
+#include "com/sun/star/uno/Reference.hxx"
+#include "com/sun/star/uno/RuntimeException.hpp"
+#include "com/sun/star/uno/Sequence.h"
+#include "com/sun/star/uno/Sequence.hxx"
+#include "com/sun/star/uno/Type.h"
+#include "com/sun/star/uno/Type.hxx"
+#include "com/sun/star/uno/TypeClass.hpp"
+#include "com/sun/star/uno/XAdapter.hpp"
+#include "com/sun/star/uno/XComponentContext.hpp"
+#include "com/sun/star/uno/XInterface.hpp"
+#include "com/sun/star/uno/XNamingService.hpp"
+#include "com/sun/star/uno/XReference.hpp"
+#include "com/sun/star/uno/genfunc.h"
+#include "com/sun/star/util/AliasProgrammaticPair.hpp"
+#include "com/sun/star/util/ChangesSet.hpp"
+#include "com/sun/star/util/Color.hpp"
+#include "com/sun/star/util/Date.hpp"
+#include "com/sun/star/util/DateTime.hpp"
+#include "com/sun/star/util/ElementChange.hpp"
+#include "com/sun/star/util/MeasureUnit.hpp"
+#include "com/sun/star/util/NumberFormat.hpp"
+#include "com/sun/star/util/Time.hpp"
+#include "com/sun/star/util/URL.hpp"
+#include "com/sun/star/util/XArchiver.hpp"
+#include "com/sun/star/util/XChangesBatch.hpp"
+#include "com/sun/star/util/XChangesListener.hpp"
+#include "com/sun/star/util/XChangesNotifier.hpp"
+#include "com/sun/star/util/XCloseBroadcaster.hpp"
+#include "com/sun/star/util/XCloseListener.hpp"
+#include "com/sun/star/util/XCloseable.hpp"
+#include "com/sun/star/util/XLocalizedAliases.hpp"
+#include "com/sun/star/util/XModifiable.hpp"
+#include "com/sun/star/util/XNumberFormatTypes.hpp"
+#include "com/sun/star/util/XNumberFormatsSupplier.hpp"
+#include "com/sun/star/util/XTimeStamped.hpp"
+#include "com/sun/star/util/XURLTransformer.hpp"
+#include "com/sun/star/view/XSelectionSupplier.hpp"
+#include "com/sun/star/xforms/XDataTypeRepository.hpp"
+#include "com/sun/star/xforms/XFormsSupplier.hpp"
+#include "com/sun/star/xforms/XFormsUIHelper1.hpp"
+#include "com/sun/star/xforms/XModel.hpp"
+#include "com/sun/star/xforms/XSubmission.hpp"
+#include "com/sun/star/xml/sax/XDocumentHandler.hpp"
+#include "com/sun/star/xml/sax/XExtendedDocumentHandler.hpp"
+#include "com/sun/star/xsd/DataTypeClass.hpp"
+#include "com/sun/star/xsd/WhiteSpaceTreatment.hpp"
+#include "com/sun/star/xsd/XDataType.hpp"
+
+#include "comphelper/broadcasthelper.hxx"
+#include "comphelper/container.hxx"
+#include "comphelper/documentconstants.hxx"
+#include "comphelper/interaction.hxx"
+#include "comphelper/listenernotification.hxx"
+#include "comphelper/namedvaluecollection.hxx"
+#include "comphelper/processfactory.hxx"
+#include "comphelper/sequence.hxx"
+#include "comphelper/types.hxx"
+#include "comphelper/uno3.hxx"
+
+#include "connectivity/dbconversion.hxx"
+#include "connectivity/dbexception.hxx"
+
+#include "cppu/macros.hxx"
+#include "cppu/unotype.hxx"
+
+#include "cppuhelper/bootstrap.hxx"
+#include "cppuhelper/compbase1.hxx"
+#include "cppuhelper/component_context.hxx"
+#include "cppuhelper/exc_hlp.hxx"
+#include "cppuhelper/factory.hxx"
+#include "cppuhelper/implbase1.hxx"
+#include "cppuhelper/implbase2.hxx"
+#include "cppuhelper/implbase3.hxx"
+#include "cppuhelper/implbase4.hxx"
+#include "cppuhelper/implbase5.hxx"
+#include "cppuhelper/implbase7.hxx"
+#include "cppuhelper/implementationentry.hxx"
+#include "cppuhelper/interfacecontainer.h"
+#include "cppuhelper/interfacecontainer.hxx"
+#include "cppuhelper/propshlp.hxx"
+#include "cppuhelper/servicefactory.hxx"
+#include "cppuhelper/typeprovider.hxx"
+#include "cppuhelper/weak.hxx"
+#include "cppuhelper/weakagg.hxx"
+#include "cppuhelper/weakref.hxx"
+
+
+
+#include "i18npool/mslangid.hxx"
+
+
+
+
+#include "osl/conditn.h"
+#include "osl/conditn.hxx"
+#include "osl/diagnose.h"
+#include "osl/doublecheckedlocking.h"
+#include "osl/file.hxx"
+#include "osl/getglobalmutex.hxx"
+#include "osl/interlck.h"
+#include "osl/module.h"
+#include "osl/module.hxx"
+#include "osl/mutex.hxx"
+#include "osl/nlsupport.h"
+#include "osl/pipe.hxx"
+#include "osl/process.h"
+#include "osl/security.hxx"
+#include "osl/thread.h"
+#include "osl/time.h"
+
+
+#include "rtl/alloc.h"
+#include "rtl/bootstrap.hxx"
+#include "rtl/byteseq.h"
+#include "rtl/instance.hxx"
+#include "rtl/locale.h"
+#include "rtl/math.hxx"
+#include "rtl/memory.h"
+#include "rtl/process.h"
+#include "rtl/ref.hxx"
+#include "rtl/strbuf.hxx"
+#include "rtl/string.h"
+#include "rtl/string.hxx"
+#include "rtl/textenc.h"
+#include "rtl/unload.h"
+#include "rtl/ustrbuf.hxx"
+#include "rtl/ustring.hxx"
+#include "rtl/uuid.h"
+
+#include "salhelper/simplereferenceobject.hxx"
+#include "salhelper/timer.hxx"
+
+#include "sane/sane.h"
+
+
+
+
+
+#include "svl/filenotation.hxx"
+#include "svtools/imgdef.hxx"
+#include "svtools/miscopt.hxx"
+#include "unotools/moduleoptions.hxx"
+#include "svl/numuno.hxx"
+
+#include "svx/flagsdef.hxx"
+
+#include "sys/stat.h"
+#include "sys/types.h"
+
+
+#include "tools/diagnose_ex.h"
+
+
+#include "typelib/typeclass.h"
+#include "typelib/typedescription.h"
+#include "typelib/typedescription.hxx"
+
+
+#include "uno/dispatcher.h"
+#include "uno/environment.h"
+#include "uno/lbnames.h"
+
+#include "unotools/configitem.hxx"
+#include "unotools/confignode.hxx"
+#include "unotools/processfactory.hxx"
+
+
+#include "vcl/fldunit.hxx"
+
+#include "osl/module.hxx"
+#include "osl/mutex.hxx"
+
+#include "xmloff/nmspmap.hxx"
+//---MARKER---
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/inc/propctrlr.hrc b/extensions/inc/propctrlr.hrc
new file mode 100644
index 000000000000..ab11bf432117
--- /dev/null
+++ b/extensions/inc/propctrlr.hrc
@@ -0,0 +1,338 @@
+/*************************************************************************
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+************************************************************************/
+
+#ifndef EXTENSIONS_PROPCTRLR_HRC
+#define EXTENSIONS_PROPCTRLR_HRC
+
+#include "extensio.hrc"
+
+#define HID_PROP_INPUT_REQUIRED ( HID_PROPC_START + 0)
+#define HID_PROP_GROUPBOX ( HID_PROPC_START + 1)
+#define HID_PROP_CONTROLSOURCE ( HID_PROPC_START + 2)
+#define HID_PROP_NAME ( HID_PROPC_START + 3)
+#define HID_PROP_TABINDEX ( HID_PROPC_START + 4)
+#define HID_PROP_MASTERFIELDS ( HID_PROPC_START + 5)
+#define HID_PROP_SLAVEFIELDS ( HID_PROPC_START + 6)
+#define HID_PROP_DATASOURCE ( HID_PROPC_START + 7)
+#define HID_PROP_CURSORSOURCE ( HID_PROPC_START + 8)
+#define HID_PROP_CURSORSOURCETYPE ( HID_PROPC_START + 9)
+#define HID_PROP_CURSORTYPE ( HID_PROPC_START + 10)
+#define HID_PROP_READONLY ( HID_PROPC_START + 11)
+#define HID_PROP_DATAENTRY ( HID_PROPC_START + 12)
+#define HID_PROP_NAVIGATION ( HID_PROPC_START + 13)
+#define HID_PROP_CYCLE ( HID_PROPC_START + 14)
+#define HID_PROP_ALLOW_ADDITIONS ( HID_PROPC_START + 15)
+#define HID_PROP_ALLOW_EDITS ( HID_PROPC_START + 16)
+#define HID_PROP_ALLOW_DELETIONS ( HID_PROPC_START + 17)
+#define HID_PROP_DIRTY ( HID_PROPC_START + 18)
+#define HID_PROP_OLDVALUE ( HID_PROPC_START + 19)
+#define HID_PROP_VALUE ( HID_PROPC_START + 20)
+#define HID_PROP_LOCKED ( HID_PROPC_START + 21)
+#define HID_PROP_FORMATKEY ( HID_PROPC_START + 22)
+#define HID_PROP_REQUIRED ( HID_PROPC_START + 23)
+#define HID_PROP_WHEEL_BEHAVIOR ( HID_PROPC_START + 24)
+#define HID_PROP_UNIQUE ( HID_PROPC_START + 25)
+#define HID_PROP_CLASSID ( HID_PROPC_START + 26)
+#define HID_PROP_LEFT ( HID_PROPC_START + 27)
+#define HID_PROP_RIGHT ( HID_PROPC_START + 28)
+#define HID_PROP_HEIGHT ( HID_PROPC_START + 29)
+#define HID_PROP_WIDTH ( HID_PROPC_START + 30)
+#define HID_PROP_BOUNDCOLUMN ( HID_PROPC_START + 31)
+#define HID_PROP_LISTSOURCETYPE ( HID_PROPC_START + 32)
+#define HID_PROP_LISTSOURCE ( HID_PROPC_START + 33)
+#define HID_PROP_LISTINDEX ( HID_PROPC_START + 34)
+#define HID_PROP_TEXT ( HID_PROPC_START + 35)
+#define HID_PROP_LABEL ( HID_PROPC_START + 36)
+#define HID_PROP_STRINGITEMLIST ( HID_PROPC_START + 37)
+#define HID_PROP_SEARCHING ( HID_PROPC_START + 38)
+#define HID_PROP_FONT ( HID_PROPC_START + 39)
+#define HID_PROP_ROWHEIGHT ( HID_PROPC_START + 40)
+#define HID_PROP_BACKGROUNDCOLOR ( HID_PROPC_START + 41)
+#define HID_PROP_FILLCOLOR ( HID_PROPC_START + 42)
+#define HID_PROP_LINECOLOR ( HID_PROPC_START + 43)
+#define HID_PROP_BORDER ( HID_PROPC_START + 44)
+#define HID_PROP_ALIGN ( HID_PROPC_START + 45)
+#define HID_PROP_DROPDOWN ( HID_PROPC_START + 46)
+#define HID_PROP_MULTILINE ( HID_PROPC_START + 47)
+#define HID_PROP_HSCROLL ( HID_PROPC_START + 48)
+#define HID_PROP_VSCROLL ( HID_PROPC_START + 49)
+#define HID_PROP_TABSTOP ( HID_PROPC_START + 50)
+#define HID_PROP_REFVALUE ( HID_PROPC_START + 51)
+#define HID_PROP_BUTTONTYPE ( HID_PROPC_START + 52)
+#define HID_PROP_SUBMIT_ACTION ( HID_PROPC_START + 53)
+#define HID_PROP_SUBMIT_METHOD ( HID_PROPC_START + 54)
+#define HID_PROP_SUBMIT_ENCODING ( HID_PROPC_START + 55)
+#define HID_PROP_DEFAULTVALUE ( HID_PROPC_START + 56)
+#define HID_PROP_SUBMIT_TARGET ( HID_PROPC_START + 57)
+#define HID_PROP_DEFAULT_STATE ( HID_PROPC_START + 58)
+#define HID_PROP_IMAGE_URL ( HID_PROPC_START + 59)
+#define HID_PROP_DEFAULT_SELECT_SEQ ( HID_PROPC_START + 60)
+#define HID_PROP_MULTISELECTION ( HID_PROPC_START + 61)
+#define HID_PROP_DATE ( HID_PROPC_START + 62)
+#define HID_PROP_DATEMIN ( HID_PROPC_START + 63)
+#define HID_PROP_DATEMAX ( HID_PROPC_START + 64)
+#define HID_PROP_DATEFORMAT ( HID_PROPC_START + 65)
+#define HID_PROP_TIME ( HID_PROPC_START + 66)
+#define HID_PROP_TIMEMIN ( HID_PROPC_START + 67)
+#define HID_PROP_TIMEMAX ( HID_PROPC_START + 68)
+#define HID_PROP_TIMEFORMAT ( HID_PROPC_START + 69)
+#define HID_PROP_VALUEMIN ( HID_PROPC_START + 70)
+#define HID_PROP_VALUEMAX ( HID_PROPC_START + 71)
+#define HID_PROP_VALUESTEP ( HID_PROPC_START + 72)
+#define HID_PROP_CURRENCYSYMBOL ( HID_PROPC_START + 73)
+#define HID_PROP_EDITMASK ( HID_PROPC_START + 74)
+#define HID_PROP_LITERALMASK ( HID_PROPC_START + 75)
+#define HID_PROP_ENABLED ( HID_PROPC_START + 76)
+#define HID_PROP_AUTOCOMPLETE ( HID_PROPC_START + 77)
+#define HID_PROP_LINECOUNT ( HID_PROPC_START + 78)
+#define HID_PROP_MAXTEXTLEN ( HID_PROPC_START + 79)
+#define HID_PROP_SPIN ( HID_PROPC_START + 80)
+#define HID_PROP_STRICTFORMAT ( HID_PROPC_START + 81)
+#define HID_PROP_SHOWTHOUSANDSEP ( HID_PROPC_START + 82)
+#define HID_PROP_VERTICAL_ALIGN ( HID_PROPC_START + 83)
+#define HID_PROP_PRINTABLE ( HID_PROPC_START + 84)
+#define HID_PROP_TARGET_URL ( HID_PROPC_START + 85)
+#define HID_PROP_TARGET_FRAME ( HID_PROPC_START + 86)
+#define HID_PROP_TAG ( HID_PROPC_START + 87)
+#define HID_PROP_ECHO_CHAR ( HID_PROPC_START + 88)
+#define HID_PROP_EMPTY_IS_NULL ( HID_PROPC_START + 89)
+#define HID_PROP_DECIMAL_ACCURACY ( HID_PROPC_START + 90)
+#define HID_PROP_ENABLE_VISIBLE ( HID_PROPC_START + 91)
+#define HID_PROP_DEFAULT_BUTTON ( HID_PROPC_START + 92)
+#define HID_PROP_HIDDEN_VALUE ( HID_PROPC_START + 93)
+#define HID_PROP_TRISTATE ( HID_PROPC_START + 94)
+#define HID_PROP_NAVIGATIONBAR ( HID_PROPC_START + 95)
+#define HID_PROP_FILTER ( HID_PROPC_START + 96)
+#define HID_PROP_SORT_CRITERIA ( HID_PROPC_START + 97)
+#define HID_PROP_DEFAULT_LONG_VALUE ( HID_PROPC_START + 98)
+#define HID_PROP_DEFAULT_TIME ( HID_PROPC_START + 99)
+#define HID_PROP_DEFAULT_DATE ( HID_PROPC_START + 100)
+#define HID_PROP_HELPTEXT ( HID_PROPC_START + 101)
+#define HID_PROP_HELPURL ( HID_PROPC_START + 102)
+#define HID_PROP_RECORDMARKER ( HID_PROPC_START + 103)
+#define HID_PROP_FILTERPROPOSAL ( HID_PROPC_START + 104)
+#define HID_PROP_EFFECTIVEMIN ( HID_PROPC_START + 105)
+#define HID_PROP_EFFECTIVEMAX ( HID_PROPC_START + 106)
+#define HID_PROP_EFFECTIVEDEFAULT ( HID_PROPC_START + 107)
+#define HID_PROP_CONTROLLABEL ( HID_PROPC_START + 108)
+#define HID_PROP_CURRSYM_POSITION ( HID_PROPC_START + 109)
+#define HID_PROP_ESCAPE_PROCESSING ( HID_PROPC_START + 110)
+#define HID_PROP_TITLE ( HID_PROPC_START + 111)
+#define HID_PROP_STEP ( HID_PROPC_START + 112)
+#define HID_PROP_PROGRESSVALUE ( HID_PROPC_START + 113)
+#define HID_PROP_PROGRESSVALUE_MIN ( HID_PROPC_START + 114)
+#define HID_PROP_PROGRESSVALUE_MAX ( HID_PROPC_START + 115)
+#define HID_PROP_SCROLLVALUE ( HID_PROPC_START + 116)
+#define HID_PROP_SCROLLVALUE_MAX ( HID_PROPC_START + 117)
+#define HID_PROP_LINEINCREMENT ( HID_PROPC_START + 118)
+#define HID_PROP_BLOCKINCREMENT ( HID_PROPC_START + 119)
+#define HID_PROP_VISIBLESIZE ( HID_PROPC_START + 120)
+#define HID_PROP_ORIENTATION ( HID_PROPC_START + 121)
+#define HID_PROP_POSITIONX ( HID_PROPC_START + 122)
+#define HID_PROP_POSITIONY ( HID_PROPC_START + 123)
+#define HID_PROP_PUSHBUTTONTYPE ( HID_PROPC_START + 124)
+#define HID_PROP_STATE ( HID_PROPC_START + 125)
+#define HID_PROP_SCALEIMAGE ( HID_PROPC_START + 126)
+#define HID_PROP_BOUND_CELL ( HID_PROPC_START + 127)
+#define HID_PROP_LIST_CELL_RANGE ( HID_PROPC_START + 128)
+#define HID_PROP_CELL_EXCHANGE_TYPE ( HID_PROPC_START + 129)
+#define HID_PROP_SELECTEDITEMS ( HID_PROPC_START + 130)
+#define HID_PROP_SCROLLVALUE_MIN ( HID_PROPC_START + 131)
+#define HID_PROP_DEFAULT_SCROLLVALUE ( HID_PROPC_START + 132)
+#define HID_PROP_REPEAT_DELAY ( HID_PROPC_START + 133)
+#define HID_PROP_SYMBOLCOLOR ( HID_PROPC_START + 134)
+#define HID_PROP_SPINVALUE ( HID_PROPC_START + 135)
+#define HID_PROP_SPINVALUE_MIN ( HID_PROPC_START + 136)
+#define HID_PROP_SPINVALUE_MAX ( HID_PROPC_START + 137)
+#define HID_PROP_DEFAULT_SPINVALUE ( HID_PROPC_START + 138)
+#define HID_PROP_SPININCREMENT ( HID_PROPC_START + 139)
+#define HID_PROP_REPEAT ( HID_PROPC_START + 140)
+#define HID_PROP_WORDBREAK ( HID_PROPC_START + 141)
+#define HID_PROP_SHOW_SCROLLBARS ( HID_PROPC_START + 142)
+#define HID_PROP_TABORDER_CONTROLS ( HID_PROPC_START + 143)
+#define HID_FIELDLINK_DETAIL_COLUMN ( HID_PROPC_START + 144)
+#define HID_FIELDLINK_MASTER_COLUMN ( HID_PROPC_START + 145)
+#define UID_FIELDLINK_DETAIL1 ( HID_PROPC_START + 146)
+#define UID_FIELDLINK_MASTER1 ( HID_PROPC_START + 147)
+#define UID_FIELDLINK_DETAIL2 ( HID_PROPC_START + 148)
+#define UID_FIELDLINK_MASTER2 ( HID_PROPC_START + 149)
+#define UID_FIELDLINK_DETAIL3 ( HID_PROPC_START + 150)
+#define UID_FIELDLINK_MASTER3 ( HID_PROPC_START + 151)
+#define UID_FIELDLINK_DETAIL4 ( HID_PROPC_START + 152)
+#define UID_FIELDLINK_MASTER4 ( HID_PROPC_START + 153)
+#define HID_PROP_ICONSIZE ( HID_PROPC_START + 154)
+#define HID_PROP_SHOW_POSITION ( HID_PROPC_START + 155)
+#define HID_PROP_SHOW_NAVIGATION ( HID_PROPC_START + 156)
+#define HID_PROP_SHOW_RECORDACTIONS ( HID_PROPC_START + 157)
+#define HID_PROP_SHOW_FILTERSORT ( HID_PROPC_START + 158)
+#define HID_PROP_AUTOLINEBREAK ( HID_PROPC_START + 159)
+#define HID_PROP_TEXTTYPE ( HID_PROPC_START + 160)
+#define HID_PROP_LINEEND_FORMAT ( HID_PROPC_START + 161)
+#define HID_PROP_XSD_TOTAL_DIGITS ( HID_PROPC_START + 162)
+#define HID_PROP_XSD_FRACTION_DIGITS ( HID_PROPC_START + 163)
+#define HID_PROP_XSD_MAX_INCLUSIVE ( HID_PROPC_START + 164)
+#define HID_PROP_XSD_MAX_EXCLUSIVE ( HID_PROPC_START + 165)
+#define HID_PROP_XSD_MIN_INCLUSIVE ( HID_PROPC_START + 166)
+#define HID_PROP_XSD_MIN_EXCLUSIVE ( HID_PROPC_START + 167)
+#define HID_PROP_UNCHECKEDREFVALUE ( HID_PROPC_START + 168)
+#define HID_PROP_SUBMISSION_ID ( HID_PROPC_START + 169)
+#define UID_PROP_DLG_FONT_TYPE ( HID_PROPC_START + 170)
+#define UID_PROP_DLG_IMAGE_URL ( HID_PROPC_START + 171)
+#define UID_PROP_DLG_BACKGROUNDCOLOR ( HID_PROPC_START + 172)
+#define UID_PROP_DLG_SYMBOLCOLOR ( HID_PROPC_START + 173)
+#define UID_PROP_DLG_ATTR_DATASOURCE ( HID_PROPC_START + 174)
+#define UID_PROP_DLG_ATTR_TARGET_URL ( HID_PROPC_START + 175)
+#define UID_PROP_DLG_NUMBER_FORMAT ( HID_PROPC_START + 176)
+#define UID_PROP_DLG_CONTROLLABEL ( HID_PROPC_START + 177)
+#define UID_PROP_DLG_FILLCOLOR ( HID_PROPC_START + 178)
+#define UID_PROP_DLG_TABINDEX ( HID_PROPC_START + 179)
+#define UID_PROP_DLG_SQLCOMMAND ( HID_PROPC_START + 180)
+#define UID_PROP_DLG_FORMLINKFIELDS ( HID_PROPC_START + 181)
+#define UID_PROP_DLG_FILTER ( HID_PROPC_START + 182)
+#define UID_PROP_DLG_ORDER ( HID_PROPC_START + 183)
+#define UID_PROP_DLG_SELECTION ( HID_PROPC_START + 184)
+#define UID_EVT_MACRODLG ( HID_PROPC_START + 185)
+#define UID_BRWEVT_APPROVEACTIONPERFORMED ( HID_PROPC_START + 186)
+#define UID_BRWEVT_ACTIONPERFORMED ( HID_PROPC_START + 187)
+#define UID_BRWEVT_CHANGED ( HID_PROPC_START + 188)
+#define UID_BRWEVT_TEXTCHANGED ( HID_PROPC_START + 189)
+#define UID_BRWEVT_ITEMSTATECHANGED ( HID_PROPC_START + 190)
+#define UID_BRWEVT_FOCUSGAINED ( HID_PROPC_START + 191)
+#define UID_BRWEVT_FOCUSLOST ( HID_PROPC_START + 192)
+#define UID_BRWEVT_KEYTYPED ( HID_PROPC_START + 193)
+#define UID_BRWEVT_KEYUP ( HID_PROPC_START + 194)
+#define UID_BRWEVT_MOUSEENTERED ( HID_PROPC_START + 195)
+#define UID_BRWEVT_MOUSEDRAGGED ( HID_PROPC_START + 196)
+#define UID_BRWEVT_MOUSEMOVED ( HID_PROPC_START + 197)
+#define UID_BRWEVT_MOUSEPRESSED ( HID_PROPC_START + 198)
+#define UID_BRWEVT_MOUSERELEASED ( HID_PROPC_START + 199)
+#define UID_BRWEVT_MOUSEEXITED ( HID_PROPC_START + 200)
+#define UID_BRWEVT_APPROVERESETTED ( HID_PROPC_START + 201)
+#define UID_BRWEVT_RESETTED ( HID_PROPC_START + 202)
+#define UID_BRWEVT_SUBMITTED ( HID_PROPC_START + 203)
+#define UID_BRWEVT_BEFOREUPDATE ( HID_PROPC_START + 204)
+#define UID_BRWEVT_AFTERUPDATE ( HID_PROPC_START + 205)
+#define UID_BRWEVT_LOADED ( HID_PROPC_START + 206)
+#define UID_BRWEVT_RELOADING ( HID_PROPC_START + 207)
+#define UID_BRWEVT_RELOADED ( HID_PROPC_START + 208)
+#define UID_BRWEVT_UNLOADING ( HID_PROPC_START + 209)
+#define UID_BRWEVT_UNLOADED ( HID_PROPC_START + 210)
+#define UID_BRWEVT_CONFIRMDELETE ( HID_PROPC_START + 211)
+#define UID_BRWEVT_APPROVEROWCHANGE ( HID_PROPC_START + 212)
+#define UID_BRWEVT_ROWCHANGE ( HID_PROPC_START + 213)
+#define UID_BRWEVT_POSITIONING ( HID_PROPC_START + 214)
+#define UID_BRWEVT_POSITIONED ( HID_PROPC_START + 215)
+#define UID_BRWEVT_APPROVEPARAMETER ( HID_PROPC_START + 216)
+#define UID_BRWEVT_ERROROCCURED ( HID_PROPC_START + 217)
+#define UID_BRWEVT_ADJUSTMENTVALUECHANGED ( HID_PROPC_START + 218)
+#define HID_PROP_XML_DATA_MODEL ( HID_PROPC_START + 219)
+#define HID_PROP_BIND_EXPRESSION ( HID_PROPC_START + 220)
+#define HID_PROP_XSD_REQUIRED ( HID_PROPC_START + 221)
+#define HID_PROP_XSD_RELEVANT ( HID_PROPC_START + 222)
+#define HID_PROP_XSD_READONLY ( HID_PROPC_START + 223)
+#define HID_PROP_XSD_CONSTRAINT ( HID_PROPC_START + 224)
+#define HID_PROP_XSD_CALCULATION ( HID_PROPC_START + 225)
+#define HID_PROP_XSD_DATA_TYPE ( HID_PROPC_START + 226)
+#define HID_PROP_XSD_WHITESPACES ( HID_PROPC_START + 227)
+#define HID_PROP_XSD_PATTERN ( HID_PROPC_START + 228)
+#define HID_PROP_XSD_LENGTH ( HID_PROPC_START + 229)
+#define HID_PROP_XSD_MIN_LENGTH ( HID_PROPC_START + 230)
+#define HID_PROP_XSD_MAX_LENGTH ( HID_PROPC_START + 231)
+#define UID_PROP_DLG_BIND_EXPRESSION ( HID_PROPC_START + 232)
+#define UID_PROP_DLG_XSD_REQUIRED ( HID_PROPC_START + 233)
+#define UID_PROP_DLG_XSD_RELEVANT ( HID_PROPC_START + 234)
+#define UID_PROP_DLG_XSD_READONLY ( HID_PROPC_START + 235)
+#define UID_PROP_DLG_XSD_CONSTRAINT ( HID_PROPC_START + 236)
+#define UID_PROP_DLG_XSD_CALCULATION ( HID_PROPC_START + 237)
+#define UID_PROP_ADD_DATA_TYPE ( HID_PROPC_START + 238)
+#define UID_PROP_REMOVE_DATA_TYPE ( HID_PROPC_START + 239)
+#define HID_PROP_LIST_BINDING ( HID_PROPC_START + 240)
+#define HID_PROP_BINDING_NAME ( HID_PROPC_START + 241)
+#define HID_PROP_SELECTION_TYPE ( HID_PROPC_START + 242)
+#define HID_PROP_ROOT_DISPLAYED ( HID_PROPC_START + 243)
+#define HID_PROP_SHOWS_HANDLES ( HID_PROPC_START + 244)
+#define HID_PROP_SHOWS_ROOT_HANDLES ( HID_PROPC_START + 245)
+#define HID_PROP_EDITABLE ( HID_PROPC_START + 246)
+#define HID_PROP_INVOKES_STOP_NOT_EDITING ( HID_PROPC_START + 247)
+#define HID_PROP_ROW_HEIGHT ( HID_PROPC_START + 248)
+#define HID_PROP_DECORATION ( HID_PROPC_START + 249)
+#define HID_EVT_ACTIONPERFORMED ( HID_PROPC_START + 250)
+#define HID_EVT_AFTERUPDATE ( HID_PROPC_START + 251)
+#define HID_EVT_BEFOREUPDATE ( HID_PROPC_START + 252)
+#define HID_EVT_CONFIRMDELETE ( HID_PROPC_START + 253)
+#define HID_EVT_ERROROCCURED ( HID_PROPC_START + 254)
+#define HID_EVT_FOCUSGAINED ( HID_PROPC_START + 255)
+#define HID_EVT_FOCUSLOST ( HID_PROPC_START + 256)
+#define HID_EVT_ITEMSTATECHANGED ( HID_PROPC_START + 257)
+#define HID_EVT_KEYTYPED ( HID_PROPC_START + 258)
+#define HID_EVT_LOADED ( HID_PROPC_START + 259)
+#define HID_EVT_MOUSEDRAGGED ( HID_PROPC_START + 260)
+#define HID_EVT_MOUSEENTERED ( HID_PROPC_START + 261)
+#define HID_EVT_MOUSEEXITED ( HID_PROPC_START + 262)
+#define HID_EVT_MOUSEMOVED ( HID_PROPC_START + 263)
+#define HID_EVT_MOUSEPRESSED ( HID_PROPC_START + 264)
+#define HID_EVT_MOUSERELEASED ( HID_PROPC_START + 265)
+#define HID_EVT_POSITIONED ( HID_PROPC_START + 266)
+#define HID_EVT_RESETTED ( HID_PROPC_START + 267)
+#define HID_EVT_SUBMITTED ( HID_PROPC_START + 268)
+#define HID_EVT_TEXTCHANGED ( HID_PROPC_START + 269)
+#define HID_EVT_UNLOADED ( HID_PROPC_START + 270)
+#define HID_EVT_CHANGED ( HID_PROPC_START + 271)
+#define HID_EVT_APPROVEACTIONPERFORMED ( HID_PROPC_START + 272)
+#define HID_EVT_APPROVERESETTED ( HID_PROPC_START + 273)
+#define HID_EVT_KEYUP ( HID_PROPC_START + 274)
+#define HID_EVT_APPROVEPARAMETER ( HID_PROPC_START + 275)
+#define HID_EVT_POSITIONING ( HID_PROPC_START + 276)
+#define HID_EVT_RELOADED ( HID_PROPC_START + 277)
+#define HID_EVT_APPROVEROWCHANGE ( HID_PROPC_START + 278)
+#define HID_EVT_ROWCHANGE ( HID_PROPC_START + 279)
+#define HID_EVT_RELOADING ( HID_PROPC_START + 280)
+#define HID_EVT_UNLOADING ( HID_PROPC_START + 281)
+#define HID_EVT_ADJUSTMENTVALUECHANGED ( HID_PROPC_START + 282)
+#define HID_PROP_TOGGLE ( HID_PROPC_START + 283)
+#define HID_PROP_FOCUSONCLICK ( HID_PROPC_START + 284)
+#define HID_PROP_HIDEINACTIVESELECTION ( HID_PROPC_START + 285)
+#define HID_PROP_VISUALEFFECT ( HID_PROPC_START + 286)
+#define HID_PROP_BORDERCOLOR ( HID_PROPC_START + 287)
+#define UID_PROP_DLG_BORDERCOLOR ( HID_PROPC_START + 288)
+#define HID_PROP_IMAGEPOSITION ( HID_PROPC_START + 289)
+#define HID_PROP_NOLABEL ( HID_PROPC_START + 290)
+#define HID_PROP_WRITING_MODE ( HID_PROPC_START + 291)
+#define HID_PROP_ANCHOR_TYPE ( HID_PROPC_START + 292)
+#define HID_FM_PROPDLG_TABCTR ( HID_PROPC_START + 293)
+#define HID_FM_PROPDLG_TAB_GENERAL ( HID_PROPC_START + 294)
+#define HID_FM_PROPDLG_TAB_DATA ( HID_PROPC_START + 295)
+#define HID_FM_PROPDLG_TAB_EVT ( HID_PROPC_START + 296)
+#define HID_PROP_GROUP_NAME ( HID_PROPC_START + 297)
+ // please adjust HID_LAST_PROPC_ID if you add new ids here!
+
+#define HID_LAST_PROPC_ID HID_PROP_GROUP_NAME
+
+#if HID_LAST_PROPC_ID > HID_PROPC_END
+ #error help id overflow (PROPC)
+#endif
+
+#endif // EXTENSIONS_PROPCTRLR_HRC
diff --git a/extensions/inc/ucbhelper/ext_content.hxx b/extensions/inc/ucbhelper/ext_content.hxx
new file mode 100644
index 000000000000..50d7f83a3c4e
--- /dev/null
+++ b/extensions/inc/ucbhelper/ext_content.hxx
@@ -0,0 +1,331 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+
+#ifndef _UCBHELPER_CONTENT_HXX_
+#define _UCBHELPER_CONTENT_HXX_
+
+#include <rtl/string.hxx>
+#include <rtl/ustring>
+#include <osl/mutex.hxx>
+#include <osl/thread.h>
+
+#include <cppuhelper/weak.hxx>
+#include <com/sun/star/ucb/XCommandTaskProcessor.hpp>
+#include <com/sun/star/ucb/XCommandInfo.hpp>
+#include <com/sun/star/ucb/XContent.hpp>
+#include <com/sun/star/ucb/XPropertyTaskProcessor.hpp>
+#include <com/sun/star/ucb/XContentIdentifier.hpp>
+#include <com/sun/star/beans/XPropertiesChangeListener.hpp>
+#include <com/sun/star/lang/XComponent.hpp>
+
+#include <list>
+
+using namespace cppu;
+using namespace com::sun::star::ucb;
+using namespace com::sun::star::uno;
+using namespace com::sun::star::beans;
+using namespace com::sun::star::lang;
+using namespace std;
+using namespace rtl;
+using namespace osl;
+
+
+
+template <class Type> class safe_list : public osl::Mutex, public std::list< Type > {};
+
+class OSimpleContentIdentifier : public OWeakObject,
+ public XContentIdentifier
+{
+private:
+ OUString Identifier;
+ OUString ProviderScheme;
+
+public:
+ OSimpleContentIdentifier( const OUString& rIdentifier, const OUString& rProviderScheme );
+
+ // XInterface
+ virtual Any SAL_CALL queryInterface( const Type &type ) throw( RuntimeException );
+ virtual void SAL_CALL acquire() throw(RuntimeException);
+ virtual void SAL_CALL release() throw(RuntimeException);
+
+ // XContentIdentifier
+ virtual OUString SAL_CALL getContentIdentifier() throw(RuntimeException);
+ virtual OUString SAL_CALL getContentProviderScheme() throw(RuntimeException);
+};
+
+
+//---------------------------------------------------------------------------
+//
+// FileSystemContent
+//
+//---------------------------------------------------------------------------
+
+class OContent :
+public OWeakObject,
+public XContent,
+public XCommandTaskProcessor,
+public XPropertyTaskProcessor,
+public XCommandInfo,
+public XPropertySetInfo,
+public XComponent
+{
+public:
+ struct PropertyChangeEventInfo
+ {
+ OUString Name;
+ long Handle;
+
+ PropertyChangeEventInfo() : Handle( -1 ) {}
+
+ inline int operator ==( const PropertyChangeEventInfo& crInfo ) const
+ { return Handle == crInfo.Handle && Handle > 0 || Name == crInfo.Name; }
+ #ifdef __SUNPRO_CC
+ inline int operator <( const PropertyChangeEventInfo& crInfo ) const
+ { return Handle != crInfo.Handle ? Handle < crInfo.Handle : Name < crInfo.Name; }
+ #endif
+ };
+
+ struct PropertyChangeListenerInfo
+ {
+ Reference< XPropertiesChangeListener > xListener;
+ list< PropertyChangeEventInfo > aEventInfos;
+
+ inline int operator ==( const PropertyChangeListenerInfo& crInfo ) const
+ { return xListener == crInfo.xListener; }
+ #ifdef __SUNPRO_CC
+ inline int operator <( const PropertyChangeListenerInfo& crInfo ) const
+ { return xListener < crInfo.xListener; }
+ #endif
+ };
+
+protected:
+ Sequence< PropertyChangeEvent > matchListenerEvents( const Sequence< PropertyChangeEvent >& crEvents, const PropertyChangeListenerInfo & crInfo );
+
+ safe_list< Reference< XContentEventListener > > m_aContentListeners;
+ safe_list< Reference< XEventListener > > m_aComponentListeners;
+ safe_list< PropertyChangeListenerInfo > m_aPropertyChangeListeners;
+public:
+ virtual ~OContent() {}
+
+ virtual void broadcastContentEvent( const ContentEvent & crEvent );
+ virtual void broadcastPropertiesChangeEvents( const Sequence< PropertyChangeEvent >& crEvents );
+
+ // To be implemented by inheritents
+ virtual Any doCommand( const Command & crCommand ) = 0;
+
+ // XInterface
+ virtual Any SAL_CALL queryInterface( const Type &type ) throw( RuntimeException );
+
+ virtual void SAL_CALL acquire() throw(RuntimeException);
+ virtual void SAL_CALL release() throw(RuntimeException);
+
+ // XContent
+ virtual void SAL_CALL addContentEventListener( const Reference< XContentEventListener >& rListener ) throw();
+ virtual void SAL_CALL removeContentEventListener( const Reference< XContentEventListener >& rListener ) throw();
+
+ // XComponent
+ virtual void SAL_CALL dispose() throw();
+ virtual void SAL_CALL addEventListener( const Reference< XEventListener >& xListener ) throw();
+ virtual void SAL_CALL removeEventListener( const Reference< XEventListener >& xListener ) throw();
+
+ // XCommmandTaskProcessor
+ virtual Reference< XCommandInfo > SAL_CALL getCommandsInfo() throw();
+
+ // XCommandInfo
+ virtual CommandInfo SAL_CALL getCommandInfoByName( const OUString& rName ) throw( UnsupportedCommandException );
+ virtual CommandInfo SAL_CALL getCommandInfoByHandle( long nHandle ) throw( UnsupportedCommandException );
+ virtual sal_Bool SAL_CALL hasCommandByName( const OUString& rName ) throw();
+ virtual sal_Bool SAL_CALL hasCommandByHandle( long nHandle ) throw();
+
+ // XPropertyTaskProcessor
+ virtual Reference< XPropertySetInfo > SAL_CALL getPropertySetInfo() throw();
+
+ // XPropertySetInfo
+ virtual Property SAL_CALL getPropertyByName( const OUString& Name ) throw( UnknownPropertyException );
+ virtual sal_Bool SAL_CALL hasPropertyByName( const OUString& Name ) throw();
+ virtual void SAL_CALL addPropertiesChangeListener( const Sequence< OUString >& Names, const Reference< XPropertiesChangeListener >& xListener ) throw();
+ virtual void SAL_CALL removePropertiesChangeListener( const Sequence< OUString >& Names, const Reference< XPropertiesChangeListener >& xListener ) throw();
+};
+
+//---------------------------------------------------------------------------
+//
+// FolderContent
+//
+//---------------------------------------------------------------------------
+
+// supported Commands
+static const sal_Int32 OPEN = 0;
+static const sal_Int32 CLOSE = 1;
+
+class OFolderContent : public OContent
+{
+protected:
+ // Already provided children
+ safe_list< XContent > m_aChildList;
+
+ // OContent
+ virtual Any doCommand( const Command & crCommand );
+
+ // new methods, can be overloaded
+ virtual Any doOpenCommand();
+ virtual Any doCloseCommand();
+
+ // To be implemented by inheritants
+ virtual Sequence< XContent > getAllChildren() = 0;
+
+public:
+
+ // XCommmandTaskProcessor
+ virtual Reference< XCommandTask > SAL_CALL createCommandTask(const Command& rCommand, const Reference< XContentTaskEnvironment >& rEnvironment ) throw();
+
+ // XCommandInfo
+ virtual Sequence< CommandInfo > SAL_CALL getCommands() throw();
+};
+
+//---------------------------------------------------------------------------
+//
+// OContentTask
+//
+//---------------------------------------------------------------------------
+
+class OContentTask :
+public OWeakObject,
+public XContentTask
+{
+ Guard< OContent > m_aContentGuard;
+protected:
+ OContent *m_pContent;
+ Reference< XContentTaskEnvironment > m_xEnvironment;
+ ContentTaskStatus m_eStatus;
+ oslThread m_aThread;
+
+ static void executeWorker( void * );
+ virtual ContentTaskStatus setStatus( ContentTaskStatus eStatus );
+
+ // To be implemented by inheritants
+ virtual void doExecute() = 0;
+public:
+ OContentTask( const Reference< XContentTaskEnvironment >& xEnv, OContent *pContent );
+ virtual ~OContentTask();
+
+ // XInterface
+ virtual Any SAL_CALL queryInterface( const Type &type ) throw( RuntimeException );
+
+ virtual void SAL_CALL acquire() throw(RuntimeException);
+ virtual void SAL_CALL release() throw(RuntimeException);
+
+ // XContentTask
+ virtual void SAL_CALL start() throw();
+ virtual void SAL_CALL execute() throw( Exception );
+ virtual void SAL_CALL abort() throw();
+ virtual ContentTaskStatus SAL_CALL getStatus() throw();
+ virtual Reference< XContentTaskEnvironment > SAL_CALL getEnvironment() throw();
+};
+
+//---------------------------------------------------------------------------
+//
+// OCommandTask
+//
+//---------------------------------------------------------------------------
+
+class OCommandTask :
+public OContentTask,
+public XCommandTask
+{
+protected:
+ Command m_aCommand;
+ Any m_aResult;
+
+public:
+ OCommandTask( const Reference< XContentTaskEnvironment >& xEnv, OContent *pContent, const Command& rCommand );
+ virtual ~OCommandTask();
+
+ virtual void doExecute();
+
+ // XInterface
+ virtual Any SAL_CALL queryInterface( const Type &type ) throw( RuntimeException );
+ virtual void SAL_CALL acquire() throw(RuntimeException);
+ virtual void SAL_CALL release() throw(RuntimeException);
+
+ // XContentTask
+ virtual void SAL_CALL start() throw();
+ virtual void SAL_CALL execute() throw( Exception );
+ virtual void SAL_CALL abort() throw();
+ virtual ContentTaskStatus SAL_CALL getStatus() throw();
+ virtual Reference< XContentTaskEnvironment > SAL_CALL getEnvironment() throw();
+
+ // XCommandTask
+ virtual Command SAL_CALL getCommand() throw();
+ virtual Any SAL_CALL getResult() throw();
+};
+
+//---------------------------------------------------------------------------
+//
+// OPropertyTask
+//
+//---------------------------------------------------------------------------
+
+class OPropertyTask :
+public OContentTask,
+public XPropertyTask
+{
+protected:
+ Sequence< PropertyValueInfo > m_aProperties;
+ PropertyTaskType m_eType;
+public:
+ OPropertyTask(const Reference< XContentTaskEnvironment >& Environment, OContent *pContent, const Sequence< PropertyValue >& Properties, PropertyTaskType Type );
+ virtual ~OPropertyTask();
+
+ virtual void doExecute();
+
+ // To be implemented by inheritants
+ virtual Any setPropertyValue( PropertyValueInfo & rProperty ) = 0;
+ virtual void getPropertyValue( PropertyValueInfo & rProperty ) = 0;
+
+ // XInterface
+ virtual Any SAL_CALL queryInterface( const Type &type ) throw( RuntimeException );
+ virtual void SAL_CALL acquire() throw(RuntimeException);
+ virtual void SAL_CALL release() throw(RuntimeException);
+
+ // XContentTask
+ virtual void SAL_CALL start() throw();
+ virtual void SAL_CALL execute() throw( Exception );
+ virtual void SAL_CALL abort() throw();
+ virtual ContentTaskStatus SAL_CALL getStatus() throw();
+ virtual Reference< XContentTaskEnvironment > SAL_CALL getEnvironment() throw();
+
+ // XPropertyTask
+ PropertyTaskType SAL_CALL getType() throw();
+ Sequence< PropertyValueInfo > SAL_CALL getProperties() throw();
+};
+
+#endif // _UCBHELPER_CONTENT_HXX_
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/inc/update.hrc b/extensions/inc/update.hrc
new file mode 100644
index 000000000000..9dd3463157dc
--- /dev/null
+++ b/extensions/inc/update.hrc
@@ -0,0 +1,49 @@
+/*************************************************************************
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+************************************************************************/
+
+#ifndef EXTENSIONS_UPDATE_HRC
+#define EXTENSIONS_UPDATE_HRC
+
+#include "extensio.hrc"
+
+#define HID_CHECK_FOR_UPD_DLG ( HID_UPDATE_START + 0)
+#define HID_CHECK_FOR_UPD_CLOSE ( HID_UPDATE_START + 1)
+#define HID_CHECK_FOR_UPD_PAUSE ( HID_UPDATE_START + 2)
+#define HID_CHECK_FOR_UPD_RESUME ( HID_UPDATE_START + 3)
+#define HID_CHECK_FOR_UPD_DOWNLOAD ( HID_UPDATE_START + 4)
+#define HID_CHECK_FOR_UPD_DOWNLOAD2 ( HID_UPDATE_START + 5)
+#define HID_CHECK_FOR_UPD_INSTALL ( HID_UPDATE_START + 6)
+#define HID_CHECK_FOR_UPD_STATUS ( HID_UPDATE_START + 7)
+#define HID_CHECK_FOR_UPD_DESCRIPTION ( HID_UPDATE_START + 8)
+#define HID_CHECK_FOR_UPD_CANCEL ( HID_UPDATE_START + 9)
+ // !! if you add new IDs, please also adjust HID_UPDATE_LAST below !!
+#define HID_UPDATE_LAST HID_CHECK_FOR_UPD_CANCEL
+
+#if HID_UPDATE_LAST > HID_UPDATE_END
+ #error help id range overflow (UPDATE)
+#endif
+
+#endif // EXTENSIONS_UPDATE_HRC
diff --git a/extensions/prj/build.lst b/extensions/prj/build.lst
new file mode 100644
index 000000000000..1489e2a4e0e4
--- /dev/null
+++ b/extensions/prj/build.lst
@@ -0,0 +1,36 @@
+ex extensions : officecfg l10n rdbmaker svx SANE:sane TWAIN:twain np_sdk offuh stoc ZLIB:zlib NULL
+
+ex extensions usr1 - all ex_mkout NULL
+ex extensions\inc nmake - all ex_inc NULL
+ex extensions\inc\ucbhelper get - all ex_incucbh ex_inc NULL
+ex extensions\source\plugin\workben get - all ex_plwkb ex_inc NULL
+ex extensions\source\plugin\inc\plugin\win get - all ex_piwi ex_inc NULL
+ex extensions\source\plugin\inc\plugin\unx get - all ex_piux ex_inc NULL
+ex extensions\source\activex\msidl nmake - w ex_axmsidl ex_inc NULL
+ex extensions\source\activex\main nmake - w ex_axmain ex_axmsidl.w ex_inc NULL
+ex extensions\source\ole nmake - w ex_ole ex_xmlextr ex_inc NULL
+ex extensions\source\resource nmake - all ex_resrc ex_inc NULL
+ex extensions\source\plugin\aqua nmake - u ex_plaqua ex_plbase NULL
+ex extensions\source\plugin\base nmake - all ex_plbase ex_inc NULL
+ex extensions\source\plugin\win nmake - w ex_plwin ex_plbase ex_inc NULL
+ex extensions\source\plugin\unx nmake - u ex_plunx ex_inc NULL
+ex extensions\source\plugin\util nmake - all ex_plutil ex_plbase ex_plunx.u ex_plwin.w ex_plaqua.u ex_inc NULL
+ex extensions\source\macosx\spotlight nmake - u ex_mxspotlight NULL
+ex extensions\source\scanner nmake - all ex_scan ex_resrc ex_inc NULL
+ex extensions\source\svg nmake - all ex_svg ex_scan ex_inc NULL
+ex extensions\source\bibliography nmake - all ex_bib ex_inc NULL
+ex extensions\source\xmlextract nmake - all ex_xmlextr ex_svg ex_inc NULL
+ex extensions\source\propctrlr nmake - all ex_propctrlr ex_bib ex_inc NULL
+ex extensions\source\dbpilots nmake - all ex_dbpilots ex_inc NULL
+ex extensions\source\abpilot nmake - all ex_abpilot ex_inc NULL
+ex extensions\source\logging nmake - all ex_logging ex_inc NULL
+ex extensions\source\oooimprovecore nmake - all ex_oooimprovecore ex_inc NULL
+ex extensions\source\oooimprovement nmake - all ex_oooimprovement ex_inc NULL
+ex extensions\source\preload nmake - all ex_preload ex_inc NULL
+ex extensions\source\config\ldap nmake - all ex_ldap ex_inc NULL
+ex extensions\source\nsplugin\source nmake - u ex_nsplugin ex_inc NULL
+ex extensions\source\nsplugin\source nmake - w ex_nsplugin ex_inc NULL
+ex extensions\source\update\feed nmake - all ex_updchkfeed ex_inc NULL
+ex extensions\source\update\check nmake - all ex_updchk ex_inc NULL
+ex extensions\source\update\ui nmake - all ex_updchkui ex_inc NULL
+ex extensions\util nmake - all ex_util ex_preload ex_abpilot ex_dbpilots ex_logging ex_ldap ex_propctrlr ex_bib ex_plutil ex_oooimprovecore NULL
diff --git a/extensions/prj/d.lst b/extensions/prj/d.lst
new file mode 100644
index 000000000000..ecfe0ef9abcd
--- /dev/null
+++ b/extensions/prj/d.lst
@@ -0,0 +1,41 @@
+mkdir: %COMMON_DEST%\bin%_EXT%\hid
+mkdir: %_DEST%\xml%_EXT%\uiconfig
+mkdir: %_DEST%\xml%_EXT%\uiconfig\modules
+mkdir: %_DEST%\xml%_EXT%\uiconfig\modules\sbibliography
+mkdir: %_DEST%\xml%_EXT%\uiconfig\modules\sbibliography\menubar
+mkdir: %_DEST%\bin%_EXT%\odf4ms
+mkdir: %_DEST%\bin%_EXT%\so
+
+..\%COMMON_OUTDIR%\misc\*.hid %COMMON_DEST%\bin%_EXT%\hid\*.hid
+..\%__SRC%\bin\*.dll %_DEST%\bin%_EXT%\*.dll
+..\%__SRC%\lib\lib*.so %_DEST%\lib%_EXT%
+..\%__SRC%\lib\ldapbe2.uno.so %_DEST%\lib%_EXT%\ldapbe2.uno.so
+..\%__SRC%\lib\updchk.uno.so %_DEST%\lib%_EXT%\updchk.uno.so
+..\%__SRC%\lib\updatefeed.uno.so %_DEST%\lib%_EXT%\updatefeed.uno.so
+..\%__SRC%\bin\oleautobridge2.uno.dll %_DEST%\bin%_EXT%\odf4ms\oleautobridge.uno.dll
+..\%__SRC%\lib\*.dylib %_DEST%\lib%_EXT%\*.dylib
+..\%__SRC%\bin\pluginapp.bin %_DEST%\bin%_EXT%\pluginapp.bin
+..\%__SRC%\bin\*.res %_DEST%\bin%_EXT%\*.res
+..\%__SRC%\bin\nsplugin.exe %_DEST%\bin%_EXT%\nsplugin.exe
+..\%__SRC%\bin\nsplugin %_DEST%\bin%_EXT%\nsplugin
+..\%__SRC%\bin\npsoplugin.dll %_DEST%\bin%_EXT%\npsoplugin.dll
+..\%__SRC%\bin\npsoplugin_so.dll %_DEST%\bin%_EXT%\so\npsoplugin.dll
+..\%__SRC%\bin\x64\so_activex.dll %_DEST%\bin%_EXT%\so_activex_x64.dll
+..\%__SRC%\bin\mdibundle.zip %_DEST%\bin%_EXT%\mdibundle.zip
+
+..\source\bibliography\uiconfig\sbibliography\menubar\*.xml %_DEST%\xml%_EXT%\uiconfig\modules\sbibliography\menubar\*.xml
+
+..\source\propctrlr\pcr.xml %_DEST%\xml%_EXT%\pcr.xml
+
+mkdir: %_DEST%\xml%_EXT%\registry\spool
+mkdir: %_DEST%\xml%_EXT%\registry\spool\org
+mkdir: %_DEST%\xml%_EXT%\registry\spool\org\openoffice
+mkdir: %_DEST%\xml%_EXT%\registry\spool\org\openoffice\Office\Addons
+mkdir: %_DEST%\xml%_EXT%\registry\spool\org\openoffice\Office\Jobs
+mkdir: %_DEST%\xml%_EXT%\registry\spool\org\openoffice\Office\Logging
+
+..\%__SRC%\misc\registry\spool\org\openoffice\Office\Addons\*.xcu %_DEST%\xml%_EXT%\registry\spool\org\openoffice\Office\Addons
+..\%__SRC%\misc\registry\spool\org\openoffice\Office\Jobs\*.xcu %_DEST%\xml%_EXT%\registry\spool\org\openoffice\Office\Jobs
+..\%__SRC%\misc\registry\spool\org\openoffice\Office\Logging\*.xcu %_DEST%\xml%_EXT%\registry\spool\org\openoffice\Office\Logging
+
+..\%__SRC%\bin\*.oxt %_DEST%\pck%_EXT%\*
diff --git a/extensions/qa/complex/extensions/OfficeResourceLoader.java b/extensions/qa/complex/extensions/OfficeResourceLoader.java
new file mode 100644
index 000000000000..16bc967cc08b
--- /dev/null
+++ b/extensions/qa/complex/extensions/OfficeResourceLoader.java
@@ -0,0 +1,121 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package complex.extensions;
+
+import com.sun.star.uno.UnoRuntime;
+
+import com.sun.star.resource.XResourceBundle;
+import com.sun.star.resource.XResourceBundleLoader;
+import com.sun.star.beans.XPropertySet;
+import com.sun.star.uno.XComponentContext;
+import com.sun.star.lang.Locale;
+
+public class OfficeResourceLoader extends complexlib.ComplexTestCase
+{
+ XResourceBundleLoader m_loader;
+ XResourceBundle m_bundle;
+
+ /** Creates a new instance of ValueBinding */
+ public OfficeResourceLoader()
+ {
+ }
+
+ /* ------------------------------------------------------------------ */
+ public String[] getTestMethodNames()
+ {
+ return new String[] {
+ "checkSimpleStringAccess",
+ "checkLocales"
+ };
+ }
+
+ /* ------------------------------------------------------------------ */
+ public String getTestObjectName()
+ {
+ return "Extensions - OfficeResourceLoader";
+ }
+
+ /* ------------------------------------------------------------------ */
+ public void before() throws com.sun.star.uno.Exception, java.lang.Exception
+ {
+ XPropertySet orb = (XPropertySet)UnoRuntime.queryInterface( XPropertySet.class, param.getMSF() );
+ XComponentContext context = (XComponentContext)UnoRuntime.queryInterface( XComponentContext.class,
+ orb.getPropertyValue( "DefaultContext" ) );
+
+ m_loader = com.sun.star.resource.OfficeResourceLoader.get( context );
+ }
+
+ /* ------------------------------------------------------------------ */
+ public void after() throws com.sun.star.uno.Exception, java.lang.Exception
+ {
+ }
+
+ /* ------------------------------------------------------------------ */
+ public void checkSimpleStringAccess() throws com.sun.star.uno.Exception, java.lang.Exception
+ {
+ // default bundle (UI locale)
+ m_bundle = m_loader.loadBundle_Default( "orl" );
+
+ Locale resourceLocale = m_bundle.getLocale();
+
+ String testString = (String)m_bundle.getByName( "string:1000" );
+
+ if ( resourceLocale.Language.equals( "en" )
+ && resourceLocale.Country.equals( "US" )
+ && resourceLocale.Variant.equals( "" )
+ )
+ assure( "invalid 'en-US' string", testString.equals( "Dummy String" ) );
+
+ if ( resourceLocale.Language.equals( "de" )
+ && resourceLocale.Country.equals( "" )
+ && resourceLocale.Variant.equals( "" )
+ )
+ assure( "invalid 'de' string", testString.equals( "Attrappen-Zeichenkette" ) );
+
+ if ( resourceLocale.Language.equals( "" )
+ && resourceLocale.Country.equals( "" )
+ && resourceLocale.Variant.equals( "" )
+ )
+ assure( "invalid unlocalized string", testString.equals( "unlocalized string" ) );
+ }
+
+ /* ------------------------------------------------------------------ */
+ public void checkLocales() throws com.sun.star.uno.Exception, java.lang.Exception
+ {
+ // en-US bundle (should always be built and thus present and thus found)
+ m_bundle = m_loader.loadBundle( "orl", new Locale( "en", "US", "" ) );
+ Locale resourceLocale = m_bundle.getLocale();
+ assure( "'en-US' could not be loaded",
+ resourceLocale.Language.equals( "en" ) && resourceLocale.Country.equals( "US" ) && resourceLocale.Variant.equals( "" ) );
+
+ // some (invalid) locale which is usually no built, and should thus fallback to en-US
+ m_bundle = m_loader.loadBundle( "orl", new Locale( "inv", "al", "id" ) );
+ resourceLocale = m_bundle.getLocale();
+ assure( "non-existing locale request does not fallback to en-US",
+ resourceLocale.Language.equals( "en" ) && resourceLocale.Country.equals( "US" ) && resourceLocale.Variant.equals( "" ) );
+ }
+}
diff --git a/extensions/qa/complex/extensions/extensions_all.sce b/extensions/qa/complex/extensions/extensions_all.sce
new file mode 100644
index 000000000000..2d23dd7a1c92
--- /dev/null
+++ b/extensions/qa/complex/extensions/extensions_all.sce
@@ -0,0 +1 @@
+-o complex.extensions.OfficeResourceLoader
diff --git a/extensions/qa/complex/extensions/makefile.mk b/extensions/qa/complex/extensions/makefile.mk
new file mode 100644
index 000000000000..96c2afb40bf3
--- /dev/null
+++ b/extensions/qa/complex/extensions/makefile.mk
@@ -0,0 +1,101 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ = ..$/..$/..
+TARGET = ExtensionsComplexTests
+PRJNAME = extensions
+PACKAGE = complex$/$(PRJNAME)
+
+RES_TARGET = orl
+
+.IF "$(GUI)"=="WNT"
+command_seperator=&&
+.ELSE
+command_seperator=;
+.ENDIF
+
+# --- Settings -----------------------------------------------------
+.INCLUDE : settings.mk
+
+
+#----- resource files for the OfficeResourceLoader test ------------
+
+SRS1NAME=$(RES_TARGET)_A_
+SRC1FILES= \
+ $(RES_TARGET)_en-US.src
+
+RES1FILELIST=\
+ $(SRS)$/$(RES_TARGET)_A_.srs
+
+RESLIB1NAME=$(RES_TARGET)_A_
+RESLIB1SRSFILES=$(RES1FILELIST)
+
+
+
+SRS2NAME=$(RES_TARGET)_B_
+SRC2FILES= \
+ $(RES_TARGET)_de.src
+
+RES2FILELIST=\
+ $(SRS)$/$(RES_TARGET)_B_.srs
+
+RESLIB2NAME=$(RES_TARGET)_B_
+RESLIB2SRSFILES=$(RES2FILELIST)
+
+
+#----- compile .java files -----------------------------------------
+
+JARFILES = ridl.jar unoil.jar jurt.jar juh.jar java_uno.jar OOoRunner.jar ConnectivityTools.jar
+JAVAFILES = $(shell @$(FIND) .$/*.java)
+JAVACLASSFILES = $(foreach,i,$(JAVAFILES) $(CLASSDIR)$/$(PACKAGE)$/$(i:b).class)
+
+#----- make a jar from compiled files ------------------------------
+
+MAXLINELENGTH = 100000
+
+JARCLASSDIRS = $(PACKAGE)
+JARTARGET = $(TARGET).jar
+JARCOMPRESS = TRUE
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : target.mk
+
+RUNNER_CLASSPATH = -cp $(CLASSPATH)$(PATH_SEPERATOR)$(SOLARBINDIR)$/OOoRunner.jar$(PATH_SEPERATOR)$(CLASSPATH)$(PATH_SEPERATOR)$(SOLARBINDIR)$/ConnectivityTools.jar
+RUNNER_ARGS = org.openoffice.Runner -TestBase java_complex
+
+run:copy_resources
+ +java $(RUNNER_CLASSPATH) $(RUNNER_ARGS) -sce extensions_all.sce
+
+run_%:copy_resources
+ +java $(RUNNER_CLASSPATH) $(RUNNER_ARGS) -o complex.$(PRJNAME).$(@:s/run_//)
+
+
+copy_resources: $(RESLIB1TARGETN) $(RESLIB2TARGETN)
+ @$(foreach,i,$(RESLIB1TARGETN) $(COPY) $i $(i:s/de/invalid/:s/_A_//) $(command_seperator)) echo.
+ @$(foreach,i,$(RESLIB2TARGETN) $(COPY) $i $(i:s/en-US/invalid/:s/_B_//) $(command_seperator)) echo.
+
diff --git a/extensions/qa/complex/extensions/orl_de.src b/extensions/qa/complex/extensions/orl_de.src
new file mode 100644
index 000000000000..e92ac818a446
--- /dev/null
+++ b/extensions/qa/complex/extensions/orl_de.src
@@ -0,0 +1,31 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+String 1000
+{
+ Text = "Attrappen-Zeichenkette";
+};
diff --git a/extensions/qa/complex/extensions/orl_en-US.src b/extensions/qa/complex/extensions/orl_en-US.src
new file mode 100644
index 000000000000..bdeaac39a69f
--- /dev/null
+++ b/extensions/qa/complex/extensions/orl_en-US.src
@@ -0,0 +1,31 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+String 1000
+{
+ Text = "Dummy String";
+};
diff --git a/extensions/qa/integration/extensions/ComponentFactory.java b/extensions/qa/integration/extensions/ComponentFactory.java
new file mode 100644
index 000000000000..5edeb1bb65e0
--- /dev/null
+++ b/extensions/qa/integration/extensions/ComponentFactory.java
@@ -0,0 +1,106 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package integration.extensions;
+
+import com.sun.star.uno.XComponentContext;
+import com.sun.star.lang.XSingleComponentFactory;
+import java.lang.reflect.Constructor;
+
+/**
+ *
+ * @author fs93730
+ */
+public class ComponentFactory implements XSingleComponentFactory
+{
+ private Class m_handlerClass;
+ private Constructor m_defaultConstructor;
+ private Constructor m_initConstructor;
+
+ public ComponentFactory( Class _handlerClass )
+ {
+ m_handlerClass = _handlerClass;
+
+ Class objectArrayClass = null;
+ try
+ {
+ objectArrayClass = Class.forName("[Ljava.lang.Object;");
+ }
+ catch ( java.lang.ClassNotFoundException e ) { }
+
+ Constructor ctors[] = _handlerClass.getConstructors();
+ for ( int i = 0; i < ctors.length && ctors != null; ++i)
+ {
+ Class ctorParams[] = ctors[i].getParameterTypes();
+ if ( ( ctorParams.length == 1 ) && ( ctorParams[0].equals( XComponentContext.class ) ) )
+ m_defaultConstructor = ctors[i];
+ if ( ( ctorParams.length == 2 )
+ && ( ctorParams[0].equals( XComponentContext.class ) )
+ && ( ctorParams[1].equals( objectArrayClass ) )
+ )
+ m_initConstructor = ctors[i];
+ }
+ if ( m_defaultConstructor == null )
+ throw new java.lang.IllegalArgumentException();
+ }
+
+ private Object ipml_createInstance( Constructor _ctor, Object[] _arguments )
+ {
+ Object newInstance = null;
+ try
+ {
+ newInstance = _ctor.newInstance( _arguments );
+ }
+ catch( InstantiationException e )
+ {
+ System.err.println( "InstantiationException: Could not instantiate an instance of " + m_handlerClass.getName() );
+ }
+ catch( IllegalAccessException e )
+ {
+ System.err.println( "IllegalAccessException: Could not instantiate an instance of " + m_handlerClass.getName() );
+ }
+ catch( java.lang.reflect.InvocationTargetException e )
+ {
+ System.err.println( "InvocationTargetException: Could not instantiate an instance of " + m_handlerClass.getName() );
+ }
+ return newInstance;
+ }
+
+ public Object createInstanceWithArgumentsAndContext(Object[] _arguments, XComponentContext _componentContext) throws com.sun.star.uno.Exception
+ {
+ if ( m_initConstructor != null )
+ return ipml_createInstance( m_initConstructor, new Object[] { _componentContext, _arguments } );
+ else
+ return createInstanceWithContext( _componentContext );
+ }
+
+ public Object createInstanceWithContext(XComponentContext _componentContext) throws com.sun.star.uno.Exception
+ {
+ return ipml_createInstance( m_defaultConstructor, new Object[] { _componentContext } );
+ }
+}
+
diff --git a/extensions/qa/integration/extensions/ConsoleWait.java b/extensions/qa/integration/extensions/ConsoleWait.java
new file mode 100644
index 000000000000..4c4a4349161b
--- /dev/null
+++ b/extensions/qa/integration/extensions/ConsoleWait.java
@@ -0,0 +1,128 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package integration.extensions;
+
+import com.sun.star.uno.*;
+import com.sun.star.lang.XComponent;
+
+public class ConsoleWait implements com.sun.star.lang.XEventListener
+{
+ private Object m_disposable;
+
+ /** a helper class which waits for a console ENTER key event in a dedicated thread,
+ and notifies a ConsoleWait object if this event happened
+ */
+ private class WaitForEnter extends java.lang.Thread
+ {
+ private ConsoleWait m_toNotify;
+ private boolean m_done;
+
+ public WaitForEnter( ConsoleWait _toNotify )
+ {
+ m_toNotify = _toNotify;
+ m_done = false;
+ }
+
+ public boolean isDone()
+ {
+ return m_done;
+ }
+
+ public void run()
+ {
+ try
+ {
+ System.out.println( "\npress enter to exit" );
+ System.in.read();
+
+ m_done = true;
+ // notify that the user pressed the key
+ synchronized ( m_toNotify )
+ {
+ m_toNotify.notify();
+ }
+ }
+ catch( java.lang.Exception e )
+ {
+ // not really interested in
+ System.err.println( e );
+ }
+ }
+ };
+
+ /** creates a ConsoleWait instance
+ * @param _disposable
+ * a component whose disposal should be monitored. When this component dies,
+ * the ConsoleWait also returns from an waitForConsole call, even if the user
+ * did not yet press the enter key
+ */
+ public ConsoleWait( Object _disposable )
+ {
+ m_disposable = _disposable;
+ XComponent component = (XComponent)UnoRuntime.queryInterface( XComponent.class, _disposable );
+ if ( component != null )
+ component.addEventListener( this );
+ }
+
+ /** waits for the user to press the ENTER key (on the console where she started the java program)
+ or the disposable component to be closed by the user.
+ @return
+ TRUE if the user pressed a key on the console, FALSE if she closed the document
+ */
+ public boolean waitForUserInput() throws java.lang.Exception
+ {
+ synchronized (this)
+ {
+ WaitForEnter keyWaiter = new WaitForEnter( this );
+ keyWaiter.start();
+ wait();
+
+ // if the waiter thread is done, the user pressed enter
+ boolean bKeyPressed = keyWaiter.isDone();
+ if ( !bKeyPressed )
+ keyWaiter.interrupt();
+
+ return bKeyPressed;
+ }
+ }
+
+ /* ------------------------------------------------------------------ */
+ /* XEventListener overridables */
+ /* ------------------------------------------------------------------ */
+ public void disposing( com.sun.star.lang.EventObject eventObject )
+ {
+ if ( eventObject.Source.equals( m_disposable ) )
+ {
+ // notify ourself that we can stop waiting for user input
+ synchronized (this)
+ {
+ notify();
+ }
+ }
+ }
+} \ No newline at end of file
diff --git a/extensions/qa/integration/extensions/Frame.java b/extensions/qa/integration/extensions/Frame.java
new file mode 100644
index 000000000000..a53fe65a29f2
--- /dev/null
+++ b/extensions/qa/integration/extensions/Frame.java
@@ -0,0 +1,226 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package integration.extensions;
+
+import com.sun.star.uno.*;
+import com.sun.star.frame.*;
+import com.sun.star.task.XStatusIndicatorFactory;
+import com.sun.star.util.XCloseable;
+
+/** wraps the coms.sun.star.frame.Frame service
+ *
+ * @author fs93730
+ */
+public class Frame implements XFrame,
+ XDispatchProvider,
+ XDispatchProviderInterception,
+ XFramesSupplier,
+ XStatusIndicatorFactory,
+ XCloseable
+{
+ private XFrame m_frame;
+ private XDispatchProvider m_dispatchProvider;
+ private XDispatchProviderInterception m_dispatchProviderInterception;
+ private XFramesSupplier m_framesSupplier;
+ private XStatusIndicatorFactory m_statusIndicatorFactory;
+ private XCloseable m_closeable;
+
+ /** Creates a new instance of Frame */
+ public Frame( Object _frameComponent )
+ {
+ if ( _frameComponent != null )
+ {
+ m_frame = (XFrame)UnoRuntime.queryInterface( XFrame.class, _frameComponent );
+ m_dispatchProvider = (XDispatchProvider)UnoRuntime.queryInterface( XDispatchProvider.class, _frameComponent );
+ m_dispatchProviderInterception = (XDispatchProviderInterception)UnoRuntime.queryInterface( XDispatchProviderInterception.class, _frameComponent );
+ m_framesSupplier = (XFramesSupplier)UnoRuntime.queryInterface( XFramesSupplier.class, _frameComponent );
+ m_statusIndicatorFactory = (XStatusIndicatorFactory)UnoRuntime.queryInterface( XStatusIndicatorFactory.class, _frameComponent );
+ m_closeable = (XCloseable)UnoRuntime.queryInterface( XCloseable.class, _frameComponent );
+ }
+ }
+
+ public XFrame getXFrame()
+ {
+ return m_frame;
+ }
+
+ public void activate()
+ {
+ m_frame.activate();
+ }
+
+ public void addEventListener(com.sun.star.lang.XEventListener _eventListener)
+ {
+ m_frame.addEventListener( _eventListener );
+ }
+
+ public void addFrameActionListener(XFrameActionListener _frameActionListener)
+ {
+ m_frame.addFrameActionListener( _frameActionListener );
+ }
+
+ public void contextChanged()
+ {
+ m_frame.contextChanged();
+ }
+
+ public com.sun.star.task.XStatusIndicator createStatusIndicator()
+ {
+ return m_statusIndicatorFactory.createStatusIndicator();
+ }
+
+ public void deactivate()
+ {
+ m_frame.deactivate();
+ }
+
+ public void dispose()
+ {
+ m_frame.dispose();
+ }
+
+ public XFrame findFrame(String str, int param)
+ {
+ return m_frame.findFrame( str, param );
+ }
+
+ public XFrame getActiveFrame()
+ {
+ return m_framesSupplier.getActiveFrame();
+ }
+
+ public com.sun.star.awt.XWindow getComponentWindow()
+ {
+ return m_frame.getComponentWindow();
+ }
+
+ public com.sun.star.awt.XWindow getContainerWindow()
+ {
+ return m_frame.getContainerWindow();
+ }
+
+ public XController getController()
+ {
+ return m_frame.getController();
+ }
+
+ public XFramesSupplier getCreator()
+ {
+ return m_frame.getCreator();
+ }
+
+ public XFrames getFrames()
+ {
+ return m_framesSupplier.getFrames();
+ }
+
+ public String getName()
+ {
+ return m_frame.getName();
+ }
+
+ public void initialize(com.sun.star.awt.XWindow _window)
+ {
+ m_frame.initialize( _window );
+ }
+
+ public boolean isActive()
+ {
+ return m_frame.isActive();
+ }
+
+ public boolean isTop()
+ {
+ return m_frame.isTop();
+ }
+
+ public XDispatch queryDispatch(com.sun.star.util.URL _url, String _str, int _param)
+ {
+ return m_dispatchProvider.queryDispatch( _url, _str, _param );
+ }
+
+ public XDispatch[] queryDispatches(DispatchDescriptor[] dispatchDescriptor)
+ {
+ return m_dispatchProvider.queryDispatches( dispatchDescriptor );
+ }
+
+ public void registerDispatchProviderInterceptor(XDispatchProviderInterceptor _dispatchProviderInterceptor)
+ {
+ m_dispatchProviderInterception.registerDispatchProviderInterceptor( _dispatchProviderInterceptor );
+ }
+
+ public void releaseDispatchProviderInterceptor(XDispatchProviderInterceptor _dispatchProviderInterceptor)
+ {
+ m_dispatchProviderInterception.releaseDispatchProviderInterceptor( _dispatchProviderInterceptor );
+ }
+
+ public void removeEventListener(com.sun.star.lang.XEventListener _eventListener)
+ {
+ m_frame.removeEventListener( _eventListener );
+ }
+
+ public void removeFrameActionListener(XFrameActionListener _frameActionListener)
+ {
+ m_frame.removeFrameActionListener( _frameActionListener );
+ }
+
+ public void setActiveFrame(XFrame _frame)
+ {
+ m_framesSupplier.setActiveFrame( _frame );
+ }
+
+ public boolean setComponent(com.sun.star.awt.XWindow _window, XController _controller)
+ {
+ return m_frame.setComponent( _window, _controller );
+ }
+
+ public void setCreator(XFramesSupplier _framesSupplier)
+ {
+ m_frame.setCreator( _framesSupplier );
+ }
+
+ public void setName(String str)
+ {
+ m_frame.setName( str );
+ }
+
+ public void close(boolean _deliverOwnership) throws com.sun.star.util.CloseVetoException
+ {
+ m_closeable.close( _deliverOwnership );
+ }
+
+ public void removeCloseListener(com.sun.star.util.XCloseListener _closeListener)
+ {
+ m_closeable.removeCloseListener( _closeListener );
+ }
+
+ public void addCloseListener(com.sun.star.util.XCloseListener _closeListener)
+ {
+ m_closeable.addCloseListener( _closeListener );
+ }
+}
diff --git a/extensions/qa/integration/extensions/HelpTextProvider.java b/extensions/qa/integration/extensions/HelpTextProvider.java
new file mode 100644
index 000000000000..857b019ee320
--- /dev/null
+++ b/extensions/qa/integration/extensions/HelpTextProvider.java
@@ -0,0 +1,50 @@
+/*
+ * HelpTextProvider.java
+ *
+ * Created on 16. November 2006, 09:44
+ *
+ * To change this template, choose Tools | Template Manager
+ * and open the template in the editor.
+ */
+
+package integration.extensions;
+
+import com.sun.star.inspection.XObjectInspectorUI;
+import com.sun.star.inspection.XPropertyControl;
+import com.sun.star.inspection.XPropertyControlObserver;
+import com.sun.star.lang.NoSupportException;
+
+/** displays help text for the currently selected method
+ */
+public class HelpTextProvider implements XPropertyControlObserver
+{
+ private XObjectInspectorUI m_inspectorUI;
+
+ /**
+ * Creates a new instance of HelpTextProvider
+ */
+ public HelpTextProvider( XObjectInspectorUI _inspectorUI )
+ {
+ m_inspectorUI = _inspectorUI;
+ m_inspectorUI.registerControlObserver( this );
+ }
+
+ public void focusGained( XPropertyControl _propertyControl )
+ {
+ try
+ {
+ String helpText = "here could be the help for:\n";
+ helpText += _propertyControl.getValue().toString();
+ m_inspectorUI.setHelpSectionText( helpText );
+ }
+ catch (NoSupportException ex)
+ {
+ ex.printStackTrace();
+ }
+ }
+
+ public void valueChanged( XPropertyControl _propertyControl )
+ {
+ // not interested in
+ }
+}
diff --git a/extensions/qa/integration/extensions/MethodHandler.java b/extensions/qa/integration/extensions/MethodHandler.java
new file mode 100644
index 000000000000..e75e0205e634
--- /dev/null
+++ b/extensions/qa/integration/extensions/MethodHandler.java
@@ -0,0 +1,239 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package integration.extensions;
+
+import com.sun.star.uno.*;
+import com.sun.star.lang.*;
+import com.sun.star.beans.*;
+import com.sun.star.reflection.*;
+import com.sun.star.inspection.*;
+
+/**
+ *
+ * @author fs93730
+ */
+public class MethodHandler implements XPropertyHandler
+{
+ private XComponentContext m_context;
+ private XIntrospection m_introspection;
+ private XIntrospectionAccess m_introspectionAccess;
+ private XIdlClass m_idlClass;
+ private XIdlMethod[] m_methods;
+ private java.util.HashMap m_methodsHash;
+
+ /** Creates a new instance of MethodHandler */
+ public MethodHandler( XComponentContext _context )
+ {
+ m_context = _context;
+ m_methodsHash = new java.util.HashMap();
+
+ try
+ {
+ m_introspection = (XIntrospection)UnoRuntime.queryInterface( XIntrospection.class,
+ m_context.getServiceManager().createInstanceWithContext( "com.sun.star.beans.Introspection", m_context )
+ );
+ }
+ catch( com.sun.star.uno.Exception e )
+ {
+ System.err.println( "MethodHandler: could not create a Introspection service, not much functionality will be available." );
+ }
+ }
+
+ static public XSingleComponentFactory getFactory()
+ {
+ return new ComponentFactory( MethodHandler.class );
+ }
+
+ public void actuatingPropertyChanged(String _propertyName, Object _newValue, Object _oldValue, com.sun.star.inspection.XObjectInspectorUI _objectInspectorUI, boolean _firstTimeInit) throws com.sun.star.lang.NullPointerException
+ {
+ // not interested in
+ }
+
+ public void addEventListener(com.sun.star.lang.XEventListener _eventListener)
+ {
+ // ingnoring this
+ }
+
+ public void addPropertyChangeListener(com.sun.star.beans.XPropertyChangeListener _propertyChangeListener) throws com.sun.star.lang.NullPointerException
+ {
+ // ingnoring this
+ }
+
+ public Object convertToControlValue(String _propertyName, Object _propertyValue, com.sun.star.uno.Type type) throws com.sun.star.beans.UnknownPropertyException
+ {
+ return _propertyValue;
+ }
+
+ public Object convertToPropertyValue(String _propertyName, Object _controlValue) throws com.sun.star.beans.UnknownPropertyException
+ {
+ return _controlValue;
+ }
+
+ public com.sun.star.inspection.LineDescriptor describePropertyLine(String _propertyName, com.sun.star.inspection.XPropertyControlFactory _propertyControlFactory) throws com.sun.star.beans.UnknownPropertyException, com.sun.star.lang.NullPointerException
+ {
+ com.sun.star.inspection.LineDescriptor descriptor = new com.sun.star.inspection.LineDescriptor();
+
+ descriptor = new LineDescriptor();
+ descriptor.Category = "Methods";
+ descriptor.DisplayName = "has method";
+ descriptor.HasPrimaryButton = descriptor.HasSecondaryButton = false;
+ descriptor.IndentLevel = 0;
+ try
+ {
+ XPropertyControl control = (XPropertyControl)UnoRuntime.queryInterface(
+ XPropertyControl.class, _propertyControlFactory.createPropertyControl(
+ PropertyControlType.TextField, true ) );
+
+ descriptor.Control = control;
+ }
+ catch( com.sun.star.lang.IllegalArgumentException e )
+ {
+ }
+ return descriptor;
+ }
+
+ public void dispose()
+ {
+ // nothing to do
+ }
+
+ public String[] getActuatingProperties()
+ {
+ // none
+ return new String[] { };
+ }
+
+ public com.sun.star.beans.PropertyState getPropertyState(String _propertyName) throws com.sun.star.beans.UnknownPropertyException
+ {
+ return com.sun.star.beans.PropertyState.DIRECT_VALUE;
+ }
+
+ public Object getPropertyValue(String _propertyName) throws com.sun.star.beans.UnknownPropertyException
+ {
+ XIdlMethod method = impl_getMethod( _propertyName );
+
+ String signature = new String();
+ signature += method.getReturnType().getName();
+ signature += " ";
+ signature += method.getName();
+
+ signature += "(";
+
+ XIdlClass[] parameterTypes = method.getParameterTypes();
+ for ( int param = 0; param<parameterTypes.length; ++param )
+ {
+ signature += ( param == 0 ) ? " " : ", ";
+ signature += parameterTypes[param].getName();
+ }
+
+ signature += " )";
+ return signature;
+ }
+
+ public String[] getSupersededProperties()
+ {
+ return new String[] { };
+ }
+
+ public com.sun.star.beans.Property[] getSupportedProperties()
+ {
+ Property[] properties = new Property[] { };
+ if ( m_methods != null )
+ {
+ properties = new Property[ m_methods.length ];
+ for ( int i=0; i<m_methods.length; ++i )
+ {
+ properties[i] = new Property( m_methods[i].getName(), 0, new Type( String.class ), (short)0 );
+ m_methodsHash.put( m_methods[i].getName(), m_methods[i] );
+ }
+ }
+ return properties;
+ }
+
+ public void inspect(Object _component) throws com.sun.star.lang.NullPointerException
+ {
+ if ( m_introspection == null )
+ return;
+
+ m_introspectionAccess = null;
+ m_methods = null;
+ m_methodsHash = new java.util.HashMap();
+
+ m_introspectionAccess = m_introspection.inspect( _component );
+ if ( m_introspectionAccess == null )
+ return;
+
+ m_methods = m_introspectionAccess.getMethods( MethodConcept.ALL );
+ }
+
+ public boolean isComposable(String _propertyName) throws com.sun.star.beans.UnknownPropertyException
+ {
+ return true;
+ }
+
+ public com.sun.star.inspection.InteractiveSelectionResult onInteractivePropertySelection(String str, boolean param, Object[] obj, com.sun.star.inspection.XObjectInspectorUI xObjectInspectorUI) throws com.sun.star.beans.UnknownPropertyException, com.sun.star.lang.NullPointerException
+ {
+ return InteractiveSelectionResult.Cancelled;
+ }
+
+ public void removeEventListener(com.sun.star.lang.XEventListener _eventListener)
+ {
+ // ignoring this
+ }
+
+ public void removePropertyChangeListener(com.sun.star.beans.XPropertyChangeListener _propertyChangeListener)
+ {
+ // ignoring this
+ }
+
+ public void setPropertyValue(String str, Object obj) throws com.sun.star.beans.UnknownPropertyException
+ {
+ // we declared our properties as readonly
+ throw new java.lang.RuntimeException();
+ }
+
+ public boolean suspend(boolean param)
+ {
+ return true;
+ }
+
+ /** returns the descriptor for the method with the given name
+ * @param _propertyName
+ * the name of the method whose descriptor should be obtained
+ * @throws com.sun.star.beans.UnknownPropertyException
+ * if we don't have a method hash, or the given property name does not denote a method of our inspectee
+ */
+ private XIdlMethod impl_getMethod( String _methodName ) throws UnknownPropertyException
+ {
+ XIdlMethod method = (XIdlMethod)m_methodsHash.get( _methodName );
+ if ( method == null )
+ throw new com.sun.star.beans.UnknownPropertyException();
+
+ return method;
+ }
+}
diff --git a/extensions/qa/integration/extensions/ObjectInspector.java b/extensions/qa/integration/extensions/ObjectInspector.java
new file mode 100644
index 000000000000..e6799dfa9d66
--- /dev/null
+++ b/extensions/qa/integration/extensions/ObjectInspector.java
@@ -0,0 +1,176 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package integration.extensions;
+
+import com.sun.star.uno.XComponentContext;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.lang.XMultiServiceFactory;
+
+import com.sun.star.frame.*;
+import com.sun.star.inspection.*;
+import com.sun.star.beans.*;
+
+import integration.extensions.Frame;
+
+public class ObjectInspector extends complexlib.ComplexTestCase
+{
+ private XComponentContext m_context;
+ private XMultiServiceFactory m_orb;
+ private Frame m_desktop;
+
+ final private String m_inspectorFrameName = new String( "ObjectInspector" );
+
+ /** Creates a new instance of ValueBinding */
+ public ObjectInspector()
+ {
+ }
+
+ /* ------------------------------------------------------------------ */
+ public String[] getTestMethodNames()
+ {
+ return new String[] {
+ "interactiveObjectInspector"
+ };
+ }
+
+ /* ------------------------------------------------------------------ */
+ public String getTestObjectName()
+ {
+ return "Test Skeleton";
+ }
+
+ /* ------------------------------------------------------------------ */
+ public void before() throws com.sun.star.uno.Exception, java.lang.Exception
+ {
+ m_orb = (XMultiServiceFactory)param.getMSF();
+ m_context = (XComponentContext)UnoRuntime.queryInterface( XComponentContext.class,
+ ((XPropertySet)UnoRuntime.queryInterface( XPropertySet.class, m_orb )).getPropertyValue( "DefaultContext" ) );
+ m_desktop = new Frame( m_orb.createInstance( "com.sun.star.frame.Desktop" ) );
+ }
+
+ /* ------------------------------------------------------------------ */
+ public void after() throws com.sun.star.uno.Exception, java.lang.Exception
+ {
+ closeExistentInspector();
+ }
+
+ /* ------------------------------------------------------------------ */
+ public void interactiveObjectInspector() throws com.sun.star.uno.Exception, java.lang.Exception
+ {
+ closeExistentInspector();
+
+ // the to-be-inspected object
+ XFrame inspectee = m_desktop.getActiveFrame();
+
+ // the inspector
+ XObjectInspector inspector = createObjectInspector();
+
+ // do inspect
+ inspector.inspect( new Object[] { inspectee } );
+
+ ConsoleWait keyWaiter = new ConsoleWait( inspector );
+ keyWaiter.waitForUserInput();
+ }
+
+ /* ------------------------------------------------------------------ */
+ private XObjectInspector createObjectInspector() throws com.sun.star.uno.Exception
+ {
+ com.sun.star.awt.XWindow floatingWindow = createFloatingWindow();
+
+ Frame inspectorFrame = new Frame( m_orb.createInstance( "com.sun.star.frame.Frame" ) );
+ inspectorFrame.setName( m_inspectorFrameName );
+ inspectorFrame.initialize( floatingWindow );
+ m_desktop.getFrames().append( inspectorFrame.getXFrame() );
+
+ // handler factories:
+ Object[] handlerFactories = new Object[] {
+ "com.sun.star.inspection.GenericPropertyHandler",
+ new ComponentFactory( ServicesHandler.class ),
+ new ComponentFactory( MethodHandler.class )
+ };
+ // a model
+ XObjectInspectorModel model = ObjectInspectorModel.createWithHandlerFactoriesAndHelpSection(
+ m_context, handlerFactories, 4, 4 );
+
+ // create the ObjectInspector
+ XObjectInspector inspector = com.sun.star.inspection.ObjectInspector.createWithModel(
+ m_context, model );
+
+ // add an observer which will emit help texts
+ new HelpTextProvider( inspector.getInspectorUI() );
+
+ // plug it into the frame
+ inspector.attachFrame( inspectorFrame.getXFrame() );
+
+ // make the window visible
+ floatingWindow.setVisible( true );
+
+ // outta here
+ return inspector;
+ }
+
+ /* ------------------------------------------------------------------ */
+ private void closeExistentInspector()
+ {
+ Frame existentInspectorFrame = new Frame( m_desktop.findFrame( m_inspectorFrameName, 255 ) );
+ if ( existentInspectorFrame != null )
+ {
+ try
+ {
+ existentInspectorFrame.close( true );
+ }
+ catch( com.sun.star.util.CloseVetoException e )
+ {
+ failed( "could not close the existent inspector frame" );
+ }
+ }
+ }
+
+ /* ------------------------------------------------------------------ */
+ private com.sun.star.awt.XWindow createFloatingWindow() throws com.sun.star.uno.Exception
+ {
+ com.sun.star.awt.XToolkit toolkit = (com.sun.star.awt.XToolkit)UnoRuntime.queryInterface(
+ com.sun.star.awt.XToolkit.class, m_orb.createInstance( "com.sun.star.awt.Toolkit" ) );
+
+ com.sun.star.awt.WindowDescriptor windowDescriptor = new com.sun.star.awt.WindowDescriptor();
+ windowDescriptor.Type = com.sun.star.awt.WindowClass.TOP;
+ windowDescriptor.WindowServiceName = "modelessdialog"; // "floatingwindow" would need a parent
+ windowDescriptor.ParentIndex = -1;
+ //windowDescriptor.Parent = null;
+
+ windowDescriptor.Bounds = new com.sun.star.awt.Rectangle( 500, 100, 400, 600 );
+ windowDescriptor.WindowAttributes = com.sun.star.awt.WindowAttribute.BORDER
+ + com.sun.star.awt.WindowAttribute.MOVEABLE
+ + com.sun.star.awt.WindowAttribute.SIZEABLE
+ + com.sun.star.awt.WindowAttribute.CLOSEABLE
+ + com.sun.star.awt.VclWindowPeerAttribute.CLIPCHILDREN;
+
+ return (com.sun.star.awt.XWindow)UnoRuntime.queryInterface( com.sun.star.awt.XWindow.class,
+ toolkit.createWindow( windowDescriptor ) );
+ }
+}
diff --git a/extensions/qa/integration/extensions/ServicesHandler.java b/extensions/qa/integration/extensions/ServicesHandler.java
new file mode 100644
index 000000000000..0340a988a31f
--- /dev/null
+++ b/extensions/qa/integration/extensions/ServicesHandler.java
@@ -0,0 +1,228 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package integration.extensions;
+
+import com.sun.star.lang.ClassNotFoundException;
+import com.sun.star.uno.*;
+import com.sun.star.beans.*;
+import com.sun.star.inspection.*;
+import com.sun.star.frame.*;
+import com.sun.star.lang.XServiceInfo;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.lang.XSingleComponentFactory;
+
+/**
+ *
+ * @author fs93730
+ */
+public class ServicesHandler implements XPropertyHandler
+{
+ private XComponentContext m_context;
+ private String[] m_supportedServices;
+
+ private class ClickHandler implements com.sun.star.awt.XActionListener
+ {
+ XComponentContext m_context;
+ private String m_serviceName;
+
+ public ClickHandler( XComponentContext _context, String _serviceName )
+ {
+ m_context = _context;
+ m_serviceName = _serviceName;
+ }
+
+ public void disposing(com.sun.star.lang.EventObject eventObject)
+ {
+ // not interested in
+ }
+
+ public void actionPerformed(com.sun.star.awt.ActionEvent actionEvent)
+ {
+ try
+ {
+ // translate the service name into a URL to dispatch
+ String documentationURL = "http://api.openoffice.org/docs/common/ref/" + m_serviceName.replace('.','/') + ".html";
+ System.out.println( documentationURL );
+
+ // the OpenHyperlink command, to be dispatched to the Desktop
+ com.sun.star.util.URL dispatchURL[] = { new com.sun.star.util.URL() };
+ dispatchURL[0].Complete = ".uno:OpenHyperlink";
+ com.sun.star.util.XURLTransformer transformer = (com.sun.star.util.XURLTransformer)UnoRuntime.queryInterface(
+ com.sun.star.util.XURLTransformer.class,
+ m_context.getServiceManager().createInstanceWithContext( "com.sun.star.util.URLTransformer", m_context ) );
+ transformer.parseStrict( dispatchURL );
+
+ // the dispatcher for the OpenHyperlink command
+ Frame desktop = new Frame(
+ m_context.getServiceManager().createInstanceWithContext( "com.sun.star.frame.Desktop", m_context ) );
+ XDispatch dispatcher = desktop.queryDispatch(dispatchURL[0],"",0);
+
+ // the arguments for the OpenHyperlink command
+ PropertyValue dispatchArgs[] = new PropertyValue[] { new PropertyValue() };
+ dispatchArgs[0].Name = "URL";
+ dispatchArgs[0].Value = documentationURL;
+
+ dispatcher.dispatch(dispatchURL[0], dispatchArgs );
+ }
+ catch( com.sun.star.uno.Exception e )
+ {
+ e.printStackTrace( System.err );
+ }
+ }
+ }
+
+ /** Creates a new instance of ServicesHandler */
+ public ServicesHandler( XComponentContext _context )
+ {
+ m_context = _context;
+ m_supportedServices = new String[] { };
+ }
+
+ public void actuatingPropertyChanged(String _propertyName, Object _newValue, Object _oldValue, com.sun.star.inspection.XObjectInspectorUI _objectInspectorUI, boolean _firstTimeInit) throws com.sun.star.lang.NullPointerException
+ {
+ // not interested in
+ }
+
+ public void addEventListener(com.sun.star.lang.XEventListener _eventListener)
+ {
+ // ingnoring this
+ }
+
+ public void addPropertyChangeListener(com.sun.star.beans.XPropertyChangeListener _propertyChangeListener) throws com.sun.star.lang.NullPointerException
+ {
+ // ingnoring this
+ }
+
+ public Object convertToControlValue(String _propertyName, Object _propertyValue, com.sun.star.uno.Type type) throws com.sun.star.beans.UnknownPropertyException
+ {
+ return _propertyValue;
+ }
+
+ public Object convertToPropertyValue(String _propertyName, Object _controlValue) throws com.sun.star.beans.UnknownPropertyException
+ {
+ return _controlValue;
+ }
+
+ public com.sun.star.inspection.LineDescriptor describePropertyLine(String _propertyName, com.sun.star.inspection.XPropertyControlFactory _propertyControlFactory) throws com.sun.star.beans.UnknownPropertyException, com.sun.star.lang.NullPointerException
+ {
+ com.sun.star.inspection.LineDescriptor descriptor = new com.sun.star.inspection.LineDescriptor();
+
+ descriptor = new LineDescriptor();
+ descriptor.Category = "Services";
+ descriptor.DisplayName = "supports service";
+ descriptor.HasPrimaryButton = descriptor.HasSecondaryButton = false;
+ descriptor.IndentLevel = 0;
+ try
+ {
+ XHyperlinkControl hyperlinkControl = (XHyperlinkControl)UnoRuntime.queryInterface(
+ XHyperlinkControl.class, _propertyControlFactory.createPropertyControl( PropertyControlType.HyperlinkField, true ) );
+ hyperlinkControl.addActionListener( new ClickHandler( m_context, _propertyName ) );
+
+ descriptor.Control = hyperlinkControl;
+ }
+ catch( com.sun.star.lang.IllegalArgumentException e )
+ {
+ }
+ return descriptor;
+ }
+
+ public void dispose()
+ {
+ // nothing to do
+ }
+
+ public String[] getActuatingProperties()
+ {
+ // none
+ return new String[] { };
+ }
+
+ public com.sun.star.beans.PropertyState getPropertyState(String _propertyName) throws com.sun.star.beans.UnknownPropertyException
+ {
+ return com.sun.star.beans.PropertyState.DIRECT_VALUE;
+ }
+
+ public Object getPropertyValue(String _propertyName) throws com.sun.star.beans.UnknownPropertyException
+ {
+ return _propertyName;
+ }
+
+ public String[] getSupersededProperties()
+ {
+ return new String[] { "SupportedServiceNames" };
+ // we're used in conjunction with a GenericPropertyHandler, which (via inspection) finds
+ // a property SupportedServiceNames, resulting from the XServiceInfo.getSupportedServiceNames
+ // method. Since we handle those ourself, we supersede them.
+ }
+
+ public com.sun.star.beans.Property[] getSupportedProperties()
+ {
+ Property[] properties = new Property[ m_supportedServices.length ];
+ for ( int i=0; i<m_supportedServices.length; ++i )
+ properties[i] = new Property( m_supportedServices[i], 0, new Type( String.class ), (short)0 );
+ return properties;
+ }
+
+ public void inspect(Object _component) throws com.sun.star.lang.NullPointerException
+ {
+ XServiceInfo serviceInfo = (XServiceInfo)UnoRuntime.queryInterface( XServiceInfo.class, _component );
+ if ( serviceInfo != null )
+ m_supportedServices = serviceInfo.getSupportedServiceNames();
+ }
+
+ public boolean isComposable(String _propertyName) throws com.sun.star.beans.UnknownPropertyException
+ {
+ return true;
+ }
+
+ public com.sun.star.inspection.InteractiveSelectionResult onInteractivePropertySelection(String str, boolean param, Object[] obj, com.sun.star.inspection.XObjectInspectorUI xObjectInspectorUI) throws com.sun.star.beans.UnknownPropertyException, com.sun.star.lang.NullPointerException
+ {
+ return InteractiveSelectionResult.Cancelled;
+ }
+
+ public void removeEventListener(com.sun.star.lang.XEventListener _eventListener)
+ {
+ // ignoring this
+ }
+
+ public void removePropertyChangeListener(com.sun.star.beans.XPropertyChangeListener _propertyChangeListener)
+ {
+ // ignoring this
+ }
+
+ public void setPropertyValue(String str, Object obj) throws com.sun.star.beans.UnknownPropertyException
+ {
+ // we declared our properties as readonly
+ throw new java.lang.RuntimeException();
+ }
+
+ public boolean suspend(boolean param)
+ {
+ return true;
+ }
+}
diff --git a/extensions/qa/integration/extensions/TestSkeleton.java b/extensions/qa/integration/extensions/TestSkeleton.java
new file mode 100644
index 000000000000..833f06b36a68
--- /dev/null
+++ b/extensions/qa/integration/extensions/TestSkeleton.java
@@ -0,0 +1,71 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package integration.extensions;
+
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.lang.XMultiServiceFactory;
+
+public class TestSkeleton extends complexlib.ComplexTestCase
+{
+ private XMultiServiceFactory m_orb;
+
+ /** Creates a new instance of ValueBinding */
+ public TestSkeleton()
+ {
+ }
+
+ /* ------------------------------------------------------------------ */
+ public String[] getTestMethodNames()
+ {
+ return new String[] {
+ "checkSomething"
+ };
+ }
+
+ /* ------------------------------------------------------------------ */
+ public String getTestObjectName()
+ {
+ return "Test Skeleton";
+ }
+
+ /* ------------------------------------------------------------------ */
+ public void before() throws com.sun.star.uno.Exception, java.lang.Exception
+ {
+ m_orb = (XMultiServiceFactory)param.getMSF();
+ }
+
+ /* ------------------------------------------------------------------ */
+ public void after() throws com.sun.star.uno.Exception, java.lang.Exception
+ {
+ }
+
+ /* ------------------------------------------------------------------ */
+ public void checkSomething() throws com.sun.star.uno.Exception, java.lang.Exception
+ {
+ }
+}
diff --git a/extensions/qa/integration/extensions/extensions_complex.sce b/extensions/qa/integration/extensions/extensions_complex.sce
new file mode 100644
index 000000000000..563376c722d8
--- /dev/null
+++ b/extensions/qa/integration/extensions/extensions_complex.sce
@@ -0,0 +1 @@
+#-o integration.extensions.ObjectInspector \ No newline at end of file
diff --git a/extensions/qa/integration/extensions/makefile.mk b/extensions/qa/integration/extensions/makefile.mk
new file mode 100644
index 000000000000..98e46fde1af9
--- /dev/null
+++ b/extensions/qa/integration/extensions/makefile.mk
@@ -0,0 +1,83 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ = ..$/..$/..
+TARGET = ExtensionsIntegrationTests
+PRJNAME = extensions
+PACKAGE = integration$/$(PRJNAME)
+
+# --- Settings -----------------------------------------------------
+.INCLUDE: settings.mk
+
+
+#----- compile .java files -----------------------------------------
+
+JARFILES = ridl.jar unoil.jar jurt.jar juh.jar java_uno.jar OOoRunner.jar
+JAVAFILES := $(shell @$(FIND) .$/*.java)
+JAVACLASSFILES := $(foreach,i,$(JAVAFILES) $(CLASSDIR)$/$(PACKAGE)$/$(i:b).class)
+
+#----- make a jar from compiled files ------------------------------
+
+MAXLINELENGTH = 100000
+
+JARCLASSDIRS = $(PACKAGE)
+JARTARGET = $(TARGET).jar
+JARCOMPRESS = TRUE
+
+# --- Runner Settings ----------------------------------------------
+
+# create connection string for OOoRunner
+.IF "$(RUNNER_CONNECTION_STRING)" == ""
+ .IF "$(OOO_RUNNER_PORT)" == ""
+ OOO_RUNNER_PORT=8100
+ .ENDIF
+ .IF "$(OOO_RUNNER_HOST)" == ""
+ OOO_RUNNER_HOST=localhost
+ .ENDIF
+ RUNNER_CONNECTION_STRING=socket,host=$(OOO_RUNNER_HOST),port=$(OOO_RUNNER_PORT)
+.ENDIF
+
+# classpath and argument list
+RUNNER_CLASSPATH = -cp $(CLASSPATH)$(PATH_SEPERATOR)$(SOLARBINDIR)$/OOoRunner.jar$(PATH_SEPERATOR)$(CLASSPATH)$(PATH_SEPERATOR)$(SOLARBINDIR)$/ConnectivityTools.jar
+RUNNER_ARGS = org.openoffice.Runner -TestBase java_complex -cs $(RUNNER_CONNECTION_STRING)
+
+# --- Targets ------------------------------------------------------
+
+.IF "$(depend)" == ""
+ALL : ALLTAR
+.ELSE
+ALL: ALLDEP
+.ENDIF
+
+.INCLUDE : target.mk
+
+run:
+ +java $(RUNNER_CLASSPATH) $(RUNNER_ARGS) -sce extensions_complex.sce
+
+run_%:
+ +java $(RUNNER_CLASSPATH) $(RUNNER_ARGS) -o integration.$(PRJNAME).$(@:s/run_//)
+
diff --git a/extensions/qa/unoapi/Test.java b/extensions/qa/unoapi/Test.java
new file mode 100644
index 000000000000..c997cb9ded32
--- /dev/null
+++ b/extensions/qa/unoapi/Test.java
@@ -0,0 +1,50 @@
+/*************************************************************************
+* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+*
+* Copyright 2000, 2010 Oracle and/or its affiliates.
+*
+* OpenOffice.org - a multi-platform office productivity suite
+*
+* This file is part of OpenOffice.org.
+*
+* OpenOffice.org is free software: you can redistribute it and/or modify
+* it under the terms of the GNU Lesser General Public License version 3
+* only, as published by the Free Software Foundation.
+*
+* OpenOffice.org is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU Lesser General Public License version 3 for more details
+* (a copy is included in the LICENSE file that accompanied this code).
+*
+* You should have received a copy of the GNU Lesser General Public License
+* version 3 along with OpenOffice.org. If not, see
+* <http://www.openoffice.org/license.html>
+* for a copy of the LGPLv3 License.
+************************************************************************/
+
+package org.openoffice.extensions.qa.unoapi;
+
+import org.openoffice.Runner;
+import org.openoffice.test.OfficeConnection;
+import static org.junit.Assert.*;
+
+public final class Test {
+ @org.junit.Before public void setUp() throws Exception {
+ connection.setUp();
+ }
+
+ @org.junit.After public void tearDown()
+ throws InterruptedException, com.sun.star.uno.Exception
+ {
+ connection.tearDown();
+ }
+
+ @org.junit.Test public void test() {
+ assertTrue(
+ Runner.run(
+ "-sce", "extensions.sce", "-cs", connection.getDescription()));
+ }
+
+ private final OfficeConnection connection = new OfficeConnection();
+}
diff --git a/extensions/qa/unoapi/extensions.sce b/extensions/qa/unoapi/extensions.sce
new file mode 100644
index 000000000000..cb338fed55de
--- /dev/null
+++ b/extensions/qa/unoapi/extensions.sce
@@ -0,0 +1,5 @@
+-o pcr.ObjectInspector
+# this object must be tests twice since it is the onle one in this module
+# The runner only prints "[0-9]+? of [0-9]+? tests failed"
+# if more then one tests is executed. This is needed by cwscheckapi.
+-o pcr.ObjectInspector
diff --git a/extensions/qa/unoapi/makefile.mk b/extensions/qa/unoapi/makefile.mk
new file mode 100644
index 000000000000..a869a3c1013e
--- /dev/null
+++ b/extensions/qa/unoapi/makefile.mk
@@ -0,0 +1,48 @@
+#*************************************************************************
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#***********************************************************************/
+
+.IF "$(OOO_SUBSEQUENT_TESTS)" == ""
+nothing .PHONY:
+.ELSE
+
+PRJ = ../..
+PRJNAME = extensions
+TARGET = qa_unoapi
+
+.IF "$(OOO_JUNIT_JAR)" != ""
+PACKAGE = org/openoffice/extensions/qa/unoapi
+JAVATESTFILES = Test.java
+JAVAFILES = $(JAVATESTFILES)
+JARFILES = OOoRunner.jar ridl.jar test.jar
+EXTRAJARFILES = $(OOO_JUNIT_JAR)
+.END
+
+.INCLUDE: settings.mk
+.INCLUDE: target.mk
+.INCLUDE: installationtest.mk
+
+ALLTAR : javatest
+
+.END
diff --git a/extensions/source/abpilot/abpfinalpage.cxx b/extensions/source/abpilot/abpfinalpage.cxx
new file mode 100644
index 000000000000..af6e0dc4b5be
--- /dev/null
+++ b/extensions/source/abpilot/abpfinalpage.cxx
@@ -0,0 +1,229 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+#include "abpfinalpage.hxx"
+#include "addresssettings.hxx"
+#include "abspilot.hxx"
+#include <tools/debug.hxx>
+#include <tools/urlobj.hxx>
+#include <unotools/ucbhelper.hxx>
+#include <sfx2/filedlghelper.hxx>
+#include <unotools/pathoptions.hxx>
+#include <svl/filenotation.hxx>
+#include <sfx2/docfilt.hxx>
+#include <vcl/msgbox.hxx>
+#include <comphelper/componentcontext.hxx>
+#include <com/sun/star/ui/dialogs/TemplateDescription.hpp>
+
+//.........................................................................
+namespace abp
+{
+//.........................................................................
+ using namespace ::svt;
+ using namespace ::utl;
+
+ const SfxFilter* lcl_getBaseFilter()
+ {
+ static const String s_sDatabaseType = String::CreateFromAscii("StarOffice XML (Base)");
+ const SfxFilter* pFilter = SfxFilter::GetFilterByName( s_sDatabaseType);
+ OSL_ENSURE(pFilter,"Filter: StarOffice XML (Base) could not be found!");
+ return pFilter;
+ }
+ //=====================================================================
+ //= FinalPage
+ //=====================================================================
+ //---------------------------------------------------------------------
+ FinalPage::FinalPage( OAddessBookSourcePilot* _pParent )
+ :AddressBookSourcePage(_pParent, ModuleRes(RID_PAGE_FINAL))
+ ,m_aExplanation ( this, ModuleRes( FT_FINISH_EXPL ) )
+ ,m_aLocationLabel ( this, ModuleRes( FT_LOCATION ) )
+ ,m_aLocation ( this, ModuleRes( CBB_LOCATION ) )
+ ,m_aBrowse ( this, ModuleRes( PB_BROWSE ) )
+ ,m_aRegisterName ( this, ModuleRes( CB_REGISTER_DS ) )
+ ,m_aNameLabel ( this, ModuleRes( FT_NAME_EXPL ) )
+ ,m_aName ( this, ModuleRes( ET_DATASOURCENAME ) )
+ ,m_aDuplicateNameError ( this, ModuleRes( FT_DUPLICATENAME ) )
+ ,m_aLocationController( ::comphelper::ComponentContext( _pParent->getORB() ), m_aLocation, m_aBrowse )
+ {
+ FreeResource();
+
+ m_aName.SetModifyHdl( LINK(this, FinalPage, OnNameModified) );
+ m_aLocation.SetModifyHdl( LINK(this, FinalPage, OnNameModified) );
+ m_aRegisterName.SetClickHdl( LINK( this, FinalPage, OnRegister ) );
+ m_aRegisterName.Check(TRUE);
+ }
+
+ //---------------------------------------------------------------------
+ sal_Bool FinalPage::isValidName() const
+ {
+ ::rtl::OUString sCurrentName(m_aName.GetText());
+
+ if (0 == sCurrentName.getLength())
+ // the name must not be empty
+ return sal_False;
+
+ if ( m_aInvalidDataSourceNames.find( sCurrentName ) != m_aInvalidDataSourceNames.end() )
+ // there already is a data source with this name
+ return sal_False;
+
+ return sal_True;
+ }
+
+ //---------------------------------------------------------------------
+ void FinalPage::setFields()
+ {
+ AddressSettings& rSettings = getSettings();
+
+ INetURLObject aURL( rSettings.sDataSourceName );
+ if( aURL.GetProtocol() == INET_PROT_NOT_VALID )
+ {
+ String sPath = SvtPathOptions().GetWorkPath();
+ sPath += '/';
+ sPath += String(rSettings.sDataSourceName);
+
+ const SfxFilter* pFilter = lcl_getBaseFilter();
+ if ( pFilter )
+ {
+ String sExt = pFilter->GetDefaultExtension();
+ sPath += sExt.GetToken(1,'*');
+ }
+
+ aURL.SetURL(sPath);
+ }
+ OSL_ENSURE( aURL.GetProtocol() != INET_PROT_NOT_VALID ,"No valid file name!");
+ rSettings.sDataSourceName = aURL.GetMainURL( INetURLObject::NO_DECODE );
+ m_aLocationController.setURL( rSettings.sDataSourceName );
+ String sName = aURL.getName( );
+ xub_StrLen nPos = sName.Search(String(aURL.GetExtension()));
+ if ( nPos != STRING_NOTFOUND )
+ {
+ sName.Erase(nPos-1,4);
+ }
+ m_aName.SetText(sName);
+
+ OnRegister(&m_aRegisterName);
+ }
+
+ //---------------------------------------------------------------------
+ void FinalPage::initializePage()
+ {
+ AddressBookSourcePage::initializePage();
+
+ setFields();
+ }
+
+ //---------------------------------------------------------------------
+ sal_Bool FinalPage::commitPage( ::svt::WizardTypes::CommitPageReason _eReason )
+ {
+ if (!AddressBookSourcePage::commitPage(_eReason))
+ return sal_False;
+
+ if ( ( ::svt::WizardTypes::eTravelBackward != _eReason )
+ && ( !m_aLocationController.prepareCommit() )
+ )
+ return sal_False;
+
+ AddressSettings& rSettings = getSettings();
+ rSettings.sDataSourceName = m_aLocationController.getURL();
+ rSettings.bRegisterDataSource = m_aRegisterName.IsChecked();
+ if ( rSettings.bRegisterDataSource )
+ rSettings.sRegisteredDataSourceName = m_aName.GetText();
+
+ return sal_True;
+ }
+
+ //---------------------------------------------------------------------
+ void FinalPage::ActivatePage()
+ {
+ AddressBookSourcePage::ActivatePage();
+
+ // get the names of all data sources
+ ODataSourceContext aContext( getORB() );
+ aContext.getDataSourceNames( m_aInvalidDataSourceNames );
+
+ // give the name edit the focus
+ m_aLocation.GrabFocus();
+
+ // default the finish button
+ getDialog()->defaultButton( WZB_FINISH );
+ }
+
+ //---------------------------------------------------------------------
+ void FinalPage::DeactivatePage()
+ {
+ AddressBookSourcePage::DeactivatePage();
+
+ // default the "next" button, again
+ getDialog()->defaultButton( WZB_NEXT );
+ // disable the finish button
+ getDialog()->enableButtons( WZB_FINISH, sal_False );
+ }
+
+ //---------------------------------------------------------------------
+ bool FinalPage::canAdvance() const
+ {
+ return false;
+ }
+
+ //---------------------------------------------------------------------
+ void FinalPage::implCheckName()
+ {
+ sal_Bool bValidName = isValidName();
+ sal_Bool bEmptyName = 0 == m_aName.GetText().Len();
+ sal_Bool bEmptyLocation = 0 == m_aLocation.GetText().Len();
+
+ // enable or disable the finish button
+ getDialog()->enableButtons( WZB_FINISH, !bEmptyLocation && (!m_aRegisterName.IsChecked() || bValidName) );
+
+ // show the error message for an invalid name
+ m_aDuplicateNameError.Show( !bValidName && !bEmptyName );
+ }
+
+ //---------------------------------------------------------------------
+ IMPL_LINK( FinalPage, OnNameModified, Edit*, /**/ )
+ {
+ implCheckName();
+ return 0L;
+ }
+
+ // -----------------------------------------------------------------------------
+ IMPL_LINK( FinalPage, OnRegister, CheckBox*, EMPTYARG )
+ {
+ BOOL bEnable = m_aRegisterName.IsChecked();
+ m_aNameLabel.Enable(bEnable);
+ m_aName.Enable(bEnable);
+ implCheckName();
+ return 0L;
+ }
+//.........................................................................
+} // namespace abp
+//.........................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/abpilot/abpfinalpage.hxx b/extensions/source/abpilot/abpfinalpage.hxx
new file mode 100644
index 000000000000..6fbf76b540a4
--- /dev/null
+++ b/extensions/source/abpilot/abpfinalpage.hxx
@@ -0,0 +1,94 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef EXTENSIONS_ABP_ABPFINALPAGE_HXX
+#define EXTENSIONS_ABP_ABPFINALPAGE_HXX
+
+#include "abspage.hxx"
+#include "abptypes.hxx"
+
+#include <svtools/urlcontrol.hxx>
+#include <svx/databaselocationinput.hxx>
+#include <vcl/edit.hxx>
+
+//.........................................................................
+namespace abp
+{
+//.........................................................................
+
+ //=====================================================================
+ //= FinalPage
+ //=====================================================================
+ class FinalPage : public AddressBookSourcePage
+ {
+ protected:
+ FixedText m_aExplanation;
+ FixedText m_aLocationLabel;
+ ::svt::OFileURLControl m_aLocation;
+ PushButton m_aBrowse;
+ CheckBox m_aRegisterName;
+ FixedText m_aNameLabel;
+ Edit m_aName;
+ FixedText m_aDuplicateNameError;
+
+ ::svx::DatabaseLocationInputController
+ m_aLocationController;
+
+ StringBag m_aInvalidDataSourceNames;
+
+ public:
+ FinalPage( OAddessBookSourcePilot* _pParent );
+
+ protected:
+ // OWizardPage overridables
+ virtual void initializePage();
+ virtual sal_Bool commitPage( ::svt::WizardTypes::CommitPageReason _eReason );
+
+ // TabDialog overridables
+ virtual void ActivatePage();
+ virtual void DeactivatePage();
+
+ // OImportPage overridables
+ virtual bool canAdvance() const;
+
+ private:
+ DECL_LINK( OnNameModified, Edit* );
+ DECL_LINK( OnRegister, CheckBox* );
+
+ sal_Bool isValidName() const;
+ void implCheckName();
+ void setFields();
+ };
+
+//.........................................................................
+} // namespace abp
+//.........................................................................
+
+#endif // EXTENSIONS_ABP_ABPFINALPAGE_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/abpilot/abpresid.hrc b/extensions/source/abpilot/abpresid.hrc
new file mode 100644
index 000000000000..273ba6b6efb9
--- /dev/null
+++ b/extensions/source/abpilot/abpresid.hrc
@@ -0,0 +1,219 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef EXTENSIONS_ABPRESID_HRC
+#define EXTENSIONS_ABPRESID_HRC
+
+#include "abpilot.hrc"
+
+//========================================================================
+// basics
+
+#define RID_DIALOG_START RID_ABP_START
+#define RID_PAGE_START RID_ABP_START
+#define RID_STRING_START RID_ABP_START
+#define RID_ERRORBOX_START RID_ABP_START
+#define RID_UNTYPED_START RID_ABP_START
+#define RID_QUERYBOX_START RID_ABP_START
+#define RID_BITMAP_START RID_ABP_START
+
+//========================================================================
+// dialogs
+
+#define RID_DLG_ADDRESSBOOKSOURCEPILOT ( RID_DIALOG_START + 0 )
+// please adjust RID_DIALOG_END (below) when adding new dialogs
+
+#define RID_DIALOG_END RID_DLG_ADDRESSBOOKSOURCEPILOT
+
+//========================================================================
+// tab pages
+
+#define RID_PAGE_SELECTABTYPE ( RID_PAGE_START + 0 )
+#define RID_PAGE_ADMININVOKATION ( RID_PAGE_START + 1 )
+#define RID_PAGE_TABLESELECTION_AB ( RID_PAGE_START + 2 )
+#define RID_PAGE_FIELDMAPPING ( RID_PAGE_START + 3 )
+#define RID_PAGE_FINAL ( RID_PAGE_START + 4 )
+// please adjust RID_PAGE_END (below) when adding new tab pages
+
+#define RID_PAGE_END RID_PAGE_FINAL
+
+//========================================================================
+// strings
+
+#define RID_STR_DEFAULT_NAME ( RID_STRING_START + 0 )
+#define RID_STR_ADMINDIALOGTITLE ( RID_STRING_START + 1 )
+#define RID_STR_NOCONNECTION ( RID_STRING_START + 2 )
+#define RID_STR_PLEASECHECKSETTINGS ( RID_STRING_START + 3 )
+#define RID_STR_FIELDDIALOGTITLE ( RID_STRING_START + 4 )
+#define RID_STR_NOFIELDSASSIGNED ( RID_STRING_START + 5 )
+// please adjust RID_STRING_END (below) when adding new strings
+
+#define RID_STRING_END RID_STR_NOFIELDSASSIGNED
+
+//========================================================================
+// error boxes
+
+#define RID_ERR_NEEDTYPESELECTION ( RID_ERRORBOX_START + 0 )
+// please adjust RID_ERRORBOX_END (below) when adding new error boxes
+
+#define RID_ERRORBOX_END RID_ERR_NEEDTYPESELECTION
+
+//========================================================================
+// query boxes
+
+#define RID_QRY_NOTABLES ( RID_QUERYBOX_START + 0 )
+// please adjust RID_QUERYBOX_END (below) when adding new query boxes
+
+#define RID_QUERYBOX_END RID_QRY_NOTABLES
+
+//========================================================================
+// untyped resources
+
+#define RID_RSC_NOTUSEDYET ( RID_UNTYPED_START + 0 )
+// please adjust RID_UNTYPED_END (below) when adding new untyped resources
+
+#define RID_UNTYPED_END RID_RSC_NOTUSEDYET
+
+//========================================================================
+// bitmaps
+
+#define BMP_HEADERIMAGE ( RID_BITMAP_START + 0 )
+// please adjust RID_BITMAP_END (below) when adding new bitmaps
+
+#define RID_BITMAP_END BMP_HEADERIMAGE
+
+//========================================================================
+//========================================================================
+//= range checks
+
+#if RID_DIALOG_END > RID_ABP_END
+ #error "please adjust the resource id ranges!!"
+#endif
+#if RID_PAGE_END > RID_ABP_END
+ #error "please adjust the resource id ranges!!"
+#endif
+#if RID_STRING_END > RID_ABP_END
+ #error "please adjust the resource id ranges!!"
+#endif
+#if RID_ERRORBOX_END > RID_ABP_END
+ #error "please adjust the resource id ranges!!"
+#endif
+#if RID_QUERYBOX_END > RID_ABP_END
+ #error "please adjust the resource id ranges!!"
+#endif
+#if RID_UNTYPED_END > RID_ABP_END
+ #error "please adjust the resource id ranges!!"
+#endif
+#if RID_BITMAP_END > RID_ABP_END
+ #error "please adjust the resource id ranges!!"
+#endif
+
+//========================================================================
+// local resource ids
+
+//........................................................................
+#define FL_SEPARATOR 1
+#define FL_TYPE 2
+#define FL_NAME 3
+
+//........................................................................
+#define FT_TYPE_HINTS 1
+#define FT_ADMINEXPLANATION 3
+#define FT_NAME_EXPL 4
+#define FT_ERROR 5
+#define FL_TOOMUCHTABLES 6
+#define FT_FIELDASSIGMENTEXPL 7
+#define FT_ASSIGNEDFIELDS 8
+#define FT_FINISH_EXPL 9
+#define FT_DUPLICATENAME 10
+#define FT_LOCATION 11
+
+//........................................................................
+#define RB_MORK 1
+#define RB_THUNDERBIRD 2
+#define RB_EVOLUTION 3
+#define RB_KAB 4
+#define RB_MACAB 5
+#define RB_LDAP 6
+#define RB_OUTLOOK 7
+#define RB_OUTLOOKEXPRESS 8
+#define RB_OTHER 9
+#define RB_EVOLUTION_GROUPWISE 10
+#define RB_EVOLUTION_LDAP 11
+
+//........................................................................
+#define ET_DATASOURCENAME 1
+#define ET_LOCATION 2
+
+//........................................................................
+#define PB_INVOKE_ADMIN_DIALOG 1
+#define PB_INVOKE_FIELDS_DIALOG 2
+#define PB_BROWSE 3
+
+//........................................................................
+#define LB_TABLELIST 1
+
+//........................................................................
+#define CB_REGISTER_DS 1
+
+//........................................................................
+#define CBB_LOCATION 1
+
+//........................................................................
+#define STR_SELECT_ABTYPE 1
+#define STR_INVOKE_ADMIN_DIALOG 2
+#define STR_TABLE_SELECTION 3
+#define STR_MANUAL_FIELD_MAPPING 4
+#define STR_FINAL_CONFIRM 5
+
+//========================================================================
+// some defines
+
+//........................................................................
+#define WINDOW_SIZE_X 240
+#define WINDOW_SIZE_Y 185
+
+#define WINDOW_BORDER_X 12
+#define WINDOW_BORDER_Y 14
+
+#define BUTTON_SIZE_X 50
+#define BUTTON_SIZE_Y 14
+
+#define HEADER_SIZE_Y 30
+
+#define BORDER_X 12
+
+//........................................................................
+
+#endif // EXTENSIONS_ABPRESID_HRC
+
+/*************************************************************************
+ * history:
+ *
+ * Revision 1.0 30.01.01 16:38:29 fs
+ ************************************************************************/
+
diff --git a/extensions/source/abpilot/abpservices.cxx b/extensions/source/abpilot/abpservices.cxx
new file mode 100644
index 000000000000..93818ebc9e79
--- /dev/null
+++ b/extensions/source/abpilot/abpservices.cxx
@@ -0,0 +1,109 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+#include "componentmodule.hxx"
+
+//---------------------------------------------------------------------------------------
+
+using namespace ::rtl;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::registry;
+
+//---------------------------------------------------------------------------------------
+
+extern "C" void SAL_CALL createRegistryInfo_OABSPilotUno();
+
+//---------------------------------------------------------------------------------------
+
+extern "C" void SAL_CALL abp_initializeModule()
+{
+ static sal_Bool s_bInit = sal_False;
+ if (!s_bInit)
+ {
+ createRegistryInfo_OABSPilotUno();
+ ::abp::OModule::setResourceFilePrefix("abp");
+ s_bInit = sal_True;
+ }
+}
+
+//---------------------------------------------------------------------------------------
+
+extern "C" SAL_DLLPUBLIC_EXPORT void SAL_CALL
+component_getImplementationEnvironment(
+ const sal_Char **ppEnvTypeName,
+ uno_Environment ** /*ppEnv*/
+ )
+{
+ abp_initializeModule();
+ *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
+}
+
+//---------------------------------------------------------------------------------------
+extern "C" SAL_DLLPUBLIC_EXPORT sal_Bool SAL_CALL component_writeInfo(
+ void* pServiceManager,
+ void* pRegistryKey
+ )
+{
+ if (pRegistryKey)
+ try
+ {
+ return ::abp::OModule::writeComponentInfos(
+ static_cast<XMultiServiceFactory*>(pServiceManager),
+ static_cast<XRegistryKey*>(pRegistryKey));
+ }
+ catch (InvalidRegistryException& )
+ {
+ OSL_ASSERT("abp::component_writeInfo: could not create a registry key (InvalidRegistryException) !");
+ }
+
+ return sal_False;
+}
+
+//---------------------------------------------------------------------------------------
+extern "C" SAL_DLLPUBLIC_EXPORT void* SAL_CALL component_getFactory(
+ const sal_Char* pImplementationName,
+ void* pServiceManager,
+ void* /*pRegistryKey*/)
+{
+ Reference< XInterface > xRet;
+ if (pServiceManager && pImplementationName)
+ {
+ xRet = ::abp::OModule::getComponentFactory(
+ ::rtl::OUString::createFromAscii(pImplementationName),
+ static_cast< XMultiServiceFactory* >(pServiceManager));
+ }
+
+ if (xRet.is())
+ xRet->acquire();
+ return xRet.get();
+};
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/abpilot/abptypes.hxx b/extensions/source/abpilot/abptypes.hxx
new file mode 100644
index 000000000000..3df98e9a96bc
--- /dev/null
+++ b/extensions/source/abpilot/abptypes.hxx
@@ -0,0 +1,50 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef EXTENSIONS_ABP_ABPTYPES_HXX
+#define EXTENSIONS_ABP_ABPTYPES_HXX
+
+#include <comphelper/stl_types.hxx>
+#include <rtl/ustring.hxx>
+
+//.........................................................................
+namespace abp
+{
+//.........................................................................
+
+ DECLARE_STL_STDKEY_SET( ::rtl::OUString, StringBag );
+
+ DECLARE_STL_USTRINGACCESS_MAP( ::rtl::OUString, MapString2String );
+
+//.........................................................................
+} // namespace abp
+//.........................................................................
+
+#endif // EXTENSIONS_ABP_ABPTYPES_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/abpilot/abspage.cxx b/extensions/source/abpilot/abspage.cxx
new file mode 100644
index 000000000000..993396ab3727
--- /dev/null
+++ b/extensions/source/abpilot/abspage.cxx
@@ -0,0 +1,91 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+#include "abspage.hxx"
+#include "abspilot.hxx"
+
+//.........................................................................
+namespace abp
+{
+//.........................................................................
+
+ using namespace ::svt;
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::lang;
+ //=====================================================================
+ //= AddressBookSourcePage
+ //=====================================================================
+ AddressBookSourcePage::AddressBookSourcePage( OAddessBookSourcePilot* _pParent, const ResId& _rId )
+ :AddressBookSourcePage_Base(_pParent, _rId)
+ {
+ }
+
+ //---------------------------------------------------------------------
+ void AddressBookSourcePage::DeactivatePage()
+ {
+ AddressBookSourcePage_Base::DeactivatePage();
+ getDialog()->enableButtons(WZB_NEXT, sal_True);
+ }
+
+ //---------------------------------------------------------------------
+ OAddessBookSourcePilot* AddressBookSourcePage::getDialog()
+ {
+ return static_cast<OAddessBookSourcePilot*>(GetParent());
+ }
+
+ //---------------------------------------------------------------------
+ const OAddessBookSourcePilot* AddressBookSourcePage::getDialog() const
+ {
+ return static_cast<const OAddessBookSourcePilot*>(GetParent());
+ }
+
+ //---------------------------------------------------------------------
+ AddressSettings& AddressBookSourcePage::getSettings()
+ {
+ return getDialog()->getSettings();
+ }
+
+ //---------------------------------------------------------------------
+ const AddressSettings& AddressBookSourcePage::getSettings() const
+ {
+ return getDialog()->getSettings();
+ }
+
+ //---------------------------------------------------------------------
+ Reference< XMultiServiceFactory > AddressBookSourcePage::getORB()
+ {
+ return getDialog()->getORB();
+ }
+
+//.........................................................................
+} // namespace abp
+//.........................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/abpilot/abspage.hxx b/extensions/source/abpilot/abspage.hxx
new file mode 100644
index 000000000000..c80c8a7a2602
--- /dev/null
+++ b/extensions/source/abpilot/abspage.hxx
@@ -0,0 +1,75 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef EXTENSIONS_ABP_ABSPAGE_HXX
+#define EXTENSIONS_ABP_ABSPAGE_HXX
+
+#include <svtools/wizardmachine.hxx>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include "abpresid.hrc"
+#include "componentmodule.hxx"
+#include <vcl/fixed.hxx>
+
+//.........................................................................
+namespace abp
+{
+//.........................................................................
+
+ class OAddessBookSourcePilot;
+ struct AddressSettings;
+
+ //=====================================================================
+ //= AddressBookSourcePage
+ //=====================================================================
+ typedef ::svt::OWizardPage AddressBookSourcePage_Base;
+ /// the base class for all tab pages in the address book source wizard
+ class AddressBookSourcePage : public AddressBookSourcePage_Base
+ {
+ protected:
+ AddressBookSourcePage( OAddessBookSourcePilot* _pParent, const ResId& _rId );
+
+ protected:
+ // helper
+ OAddessBookSourcePilot* getDialog();
+ const OAddessBookSourcePilot* getDialog() const;
+ ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >
+ getORB();
+ AddressSettings& getSettings();
+ const AddressSettings& getSettings() const;
+
+ // TabDialog overridables
+ virtual void DeactivatePage();
+ };
+
+//.........................................................................
+} // namespace abp
+//.........................................................................
+
+#endif // EXTENSIONS_ABP_ABSPAGE_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/abpilot/abspilot.cxx b/extensions/source/abpilot/abspilot.cxx
new file mode 100644
index 000000000000..d8de0a7c9a0c
--- /dev/null
+++ b/extensions/source/abpilot/abspilot.cxx
@@ -0,0 +1,501 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+#include "abspilot.hxx"
+#include "abpilot.hrc"
+#include "abpresid.hrc"
+#include "componentmodule.hxx"
+#include <tools/debug.hxx>
+#include <svtools/localresaccess.hxx>
+#include "typeselectionpage.hxx"
+#include "admininvokationpage.hxx"
+#include "tableselectionpage.hxx"
+#include <vcl/waitobj.hxx>
+#include <vcl/msgbox.hxx>
+#include "abpfinalpage.hxx"
+#include "fieldmappingpage.hxx"
+#include "fieldmappingimpl.hxx"
+
+//.........................................................................
+namespace abp
+{
+//.........................................................................
+
+#define STATE_SELECT_ABTYPE 0
+#define STATE_INVOKE_ADMIN_DIALOG 1
+#define STATE_TABLE_SELECTION 2
+#define STATE_MANUAL_FIELD_MAPPING 3
+#define STATE_FINAL_CONFIRM 4
+
+#define PATH_COMPLETE 1
+#define PATH_NO_SETTINGS 2
+#define PATH_NO_FIELDS 3
+#define PATH_NO_SETTINGS_NO_FIELDS 4
+
+ using namespace ::svt;
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::lang;
+
+ //=====================================================================
+ //= OAddessBookSourcePilot
+ //=====================================================================
+ //---------------------------------------------------------------------
+ OAddessBookSourcePilot::OAddessBookSourcePilot(Window* _pParent, const Reference< XMultiServiceFactory >& _rxORB)
+ :OAddessBookSourcePilot_Base( _pParent, ModuleRes( RID_DLG_ADDRESSBOOKSOURCEPILOT ),
+ WZB_HELP | WZB_FINISH | WZB_CANCEL | WZB_NEXT | WZB_PREVIOUS )
+ ,m_xORB(_rxORB)
+ ,m_aNewDataSource(_rxORB)
+ ,m_eNewDataSourceType( AST_INVALID )
+ {
+ SetPageSizePixel(LogicToPixel(Size(WINDOW_SIZE_X, WINDOW_SIZE_Y), MAP_APPFONT));
+
+ ShowButtonFixedLine(sal_True);
+
+ declarePath( PATH_COMPLETE,
+ STATE_SELECT_ABTYPE,
+ STATE_INVOKE_ADMIN_DIALOG,
+ STATE_TABLE_SELECTION,
+ STATE_MANUAL_FIELD_MAPPING,
+ STATE_FINAL_CONFIRM,
+ WZS_INVALID_STATE
+ );
+ declarePath( PATH_NO_SETTINGS,
+ STATE_SELECT_ABTYPE,
+ STATE_TABLE_SELECTION,
+ STATE_MANUAL_FIELD_MAPPING,
+ STATE_FINAL_CONFIRM,
+ WZS_INVALID_STATE
+ );
+ declarePath( PATH_NO_FIELDS,
+ STATE_SELECT_ABTYPE,
+ STATE_INVOKE_ADMIN_DIALOG,
+ STATE_TABLE_SELECTION,
+ STATE_FINAL_CONFIRM,
+ WZS_INVALID_STATE
+ );
+ declarePath( PATH_NO_SETTINGS_NO_FIELDS,
+ STATE_SELECT_ABTYPE,
+ STATE_TABLE_SELECTION,
+ STATE_FINAL_CONFIRM,
+ WZS_INVALID_STATE
+ );
+
+ m_pPrevPage->SetHelpId(HID_ABSPILOT_PREVIOUS);
+ m_pNextPage->SetHelpId(HID_ABSPILOT_NEXT);
+ m_pCancel->SetHelpId(HID_ABSPILOT_CANCEL);
+ m_pFinish->SetHelpId(HID_ABSPILOT_FINISH);
+ m_pHelp->SetUniqueId(UID_ABSPILOT_HELP);
+
+ m_pCancel->SetClickHdl( LINK( this, OAddessBookSourcePilot, OnCancelClicked) );
+
+ // some initial settings
+#ifdef UNX
+#ifdef MACOSX
+ m_aSettings.eType = AST_MACAB;
+#else
+// FIXME: if KDE use KAB instead
+ m_aSettings.eType = AST_EVOLUTION;
+#endif
+#else
+ m_aSettings.eType = AST_OTHER;
+#endif
+ m_aSettings.sDataSourceName = String(ModuleRes(RID_STR_DEFAULT_NAME));
+ m_aSettings.bRegisterDataSource = false;
+ m_aSettings.bIgnoreNoTable = false;
+
+ defaultButton(WZB_NEXT);
+ enableButtons(WZB_FINISH, sal_False);
+ ActivatePage();
+
+ typeSelectionChanged( m_aSettings.eType );
+ }
+
+ //---------------------------------------------------------------------
+ String OAddessBookSourcePilot::getStateDisplayName( WizardState _nState ) const
+ {
+ USHORT nResId = 0;
+ switch ( _nState )
+ {
+ case STATE_SELECT_ABTYPE: nResId = STR_SELECT_ABTYPE; break;
+ case STATE_INVOKE_ADMIN_DIALOG: nResId = STR_INVOKE_ADMIN_DIALOG; break;
+ case STATE_TABLE_SELECTION: nResId = STR_TABLE_SELECTION; break;
+ case STATE_MANUAL_FIELD_MAPPING: nResId = STR_MANUAL_FIELD_MAPPING; break;
+ case STATE_FINAL_CONFIRM: nResId = STR_FINAL_CONFIRM; break;
+ }
+ DBG_ASSERT( nResId, "OAddessBookSourcePilot::getStateDisplayName: don't know this state!" );
+
+ String sDisplayName;
+ if ( nResId )
+ {
+ svt::OLocalResourceAccess aAccess( ModuleRes( RID_DLG_ADDRESSBOOKSOURCEPILOT ), RSC_MODALDIALOG );
+ sDisplayName = String( ModuleRes( nResId ) );
+ }
+
+ return sDisplayName;
+ }
+
+ //---------------------------------------------------------------------
+ void OAddessBookSourcePilot::implCommitAll()
+ {
+ // in real, the data source already exists in the data source context
+ // Thus, if the user changed the name, we have to rename the data source
+ if ( m_aSettings.sDataSourceName != m_aNewDataSource.getName() )
+ m_aNewDataSource.rename( m_aSettings.sDataSourceName );
+
+ // 1. the data source
+ m_aNewDataSource.store();
+
+ // 2. check if we need to register the data source
+ if ( m_aSettings.bRegisterDataSource )
+ m_aNewDataSource.registerDataSource(m_aSettings.sRegisteredDataSourceName);
+
+ // 3. write the data source / table names into the configuration
+ addressconfig::writeTemplateAddressSource( getORB(), m_aSettings.bRegisterDataSource ? m_aSettings.sRegisteredDataSourceName : m_aSettings.sDataSourceName, m_aSettings.sSelectedTable );
+
+ // 4. write the field mapping
+ fieldmapping::writeTemplateAddressFieldMapping( getORB(), m_aSettings.aFieldMapping );
+ }
+
+ //---------------------------------------------------------------------
+ void OAddessBookSourcePilot::implCleanup()
+ {
+ if ( m_aNewDataSource.isValid() )
+ m_aNewDataSource.remove();
+ }
+
+ //---------------------------------------------------------------------
+ IMPL_LINK( OAddessBookSourcePilot, OnCancelClicked, void*, /*NOTINTERESTEDIN*/ )
+ {
+ // do cleanups
+ implCleanup();
+
+ // reset the click hdl
+ m_pCancel->SetClickHdl( Link() );
+ // simulate the click again - this time, the default handling of the button will strike ....
+ m_pCancel->Click();
+
+ return 0L;
+ }
+
+ //---------------------------------------------------------------------
+ BOOL OAddessBookSourcePilot::Close()
+ {
+ implCleanup();
+
+ return OAddessBookSourcePilot_Base::Close();
+ }
+
+ //---------------------------------------------------------------------
+ sal_Bool OAddessBookSourcePilot::onFinish()
+ {
+ if ( !OAddessBookSourcePilot_Base::onFinish() )
+ return sal_False;
+
+ implCommitAll();
+
+ addressconfig::markPilotSuccess( getORB() );
+
+ return sal_True;
+ }
+
+ //---------------------------------------------------------------------
+ void OAddessBookSourcePilot::enterState( WizardState _nState )
+ {
+ switch ( _nState )
+ {
+ case STATE_SELECT_ABTYPE:
+ impl_updateRoadmap( static_cast< TypeSelectionPage* >( GetPage( STATE_SELECT_ABTYPE ) )->getSelectedType() );
+ break;
+
+ case STATE_FINAL_CONFIRM:
+ if ( !needManualFieldMapping( ) )
+ implDoAutoFieldMapping();
+ break;
+
+ case STATE_TABLE_SELECTION:
+ implDefaultTableName();
+ break;
+ }
+
+ OAddessBookSourcePilot_Base::enterState(_nState);
+ }
+
+ //---------------------------------------------------------------------
+ sal_Bool OAddessBookSourcePilot::prepareLeaveCurrentState( CommitPageReason _eReason )
+ {
+ if ( !OAddessBookSourcePilot_Base::prepareLeaveCurrentState( _eReason ) )
+ return sal_False;
+
+ if ( _eReason == eTravelBackward )
+ return sal_True;
+
+ sal_Bool bAllow = sal_True;
+
+ switch ( getCurrentState() )
+ {
+ case STATE_SELECT_ABTYPE:
+ implCreateDataSource();
+ if ( needAdminInvokationPage() )
+ break;
+ // no break here
+
+ case STATE_INVOKE_ADMIN_DIALOG:
+ if ( !connectToDataSource( sal_False ) )
+ {
+ // connecting did not succeed -> do not allow proceeding
+ bAllow = sal_False;
+ break;
+ }
+
+ // ........................................................
+ // now that we connected to the data source, check whether we need the "table selection" page
+ const StringBag& aTables = m_aNewDataSource.getTableNames();
+
+ if ( aTables.empty() )
+ {
+ if ( RET_YES != QueryBox( this, ModuleRes( RID_QRY_NOTABLES ) ).Execute() )
+ {
+ // cannot ask the user, or the user chose to use this data source, though there are no tables
+ bAllow = sal_False;
+ break;
+ }
+
+ m_aSettings.bIgnoreNoTable = true;
+ }
+
+ if ( aTables.size() == 1 )
+ // remember the one and only table we have
+ m_aSettings.sSelectedTable = *aTables.begin();
+
+ break;
+ }
+
+ impl_updateRoadmap( m_aSettings.eType );
+ return bAllow;
+ }
+
+ //---------------------------------------------------------------------
+ void OAddessBookSourcePilot::implDefaultTableName()
+ {
+ const StringBag& rTableNames = getDataSource().getTableNames();
+ if ( rTableNames.end() != rTableNames.find( getSettings().sSelectedTable ) )
+ // already a valid table selected
+ return;
+
+ const sal_Char* pGuess = NULL;
+ switch ( getSettings().eType )
+ {
+ case AST_MORK :
+ case AST_THUNDERBIRD : pGuess = "Personal Address book"; break;
+ case AST_LDAP : pGuess = "LDAP Directory"; break;
+ case AST_EVOLUTION :
+ case AST_EVOLUTION_GROUPWISE:
+ case AST_EVOLUTION_LDAP : pGuess = "Personal"; break;
+ default:
+ DBG_ERROR( "OAddessBookSourcePilot::implDefaultTableName: unhandled case!" );
+ return;
+ }
+ const ::rtl::OUString sGuess = ::rtl::OUString::createFromAscii( pGuess );
+ if ( rTableNames.end() != rTableNames.find( sGuess ) )
+ getSettings().sSelectedTable = sGuess;
+ }
+
+ //---------------------------------------------------------------------
+ void OAddessBookSourcePilot::implDoAutoFieldMapping()
+ {
+ DBG_ASSERT( !needManualFieldMapping( ), "OAddessBookSourcePilot::implDoAutoFieldMapping: invalid call!" );
+
+ fieldmapping::defaultMapping( getORB(), m_aSettings.aFieldMapping );
+ }
+
+ //---------------------------------------------------------------------
+ void OAddessBookSourcePilot::implCreateDataSource()
+ {
+ if (m_aNewDataSource.isValid())
+ { // we already have a data source object
+ if ( m_aSettings.eType == m_eNewDataSourceType )
+ // and it already has the correct type
+ return;
+
+ // it has a wrong type -> remove it
+ m_aNewDataSource.remove();
+ }
+
+ ODataSourceContext aContext( getORB() );
+ aContext.disambiguate( m_aSettings.sDataSourceName );
+
+ switch (m_aSettings.eType)
+ {
+ case AST_MORK:
+ m_aNewDataSource = aContext.createNewMORK( m_aSettings.sDataSourceName );
+ break;
+
+ case AST_THUNDERBIRD:
+ m_aNewDataSource = aContext.createNewThunderbird( m_aSettings.sDataSourceName );
+ break;
+
+ case AST_EVOLUTION:
+ m_aNewDataSource = aContext.createNewEvolution( m_aSettings.sDataSourceName );
+ break;
+
+ case AST_EVOLUTION_GROUPWISE:
+ m_aNewDataSource = aContext.createNewEvolutionGroupwise( m_aSettings.sDataSourceName );
+ break;
+
+ case AST_EVOLUTION_LDAP:
+ m_aNewDataSource = aContext.createNewEvolutionLdap( m_aSettings.sDataSourceName );
+ break;
+
+ case AST_KAB:
+ m_aNewDataSource = aContext.createNewKab( m_aSettings.sDataSourceName );
+ break;
+
+ case AST_MACAB:
+ m_aNewDataSource = aContext.createNewMacab( m_aSettings.sDataSourceName );
+ break;
+
+ case AST_LDAP:
+ m_aNewDataSource = aContext.createNewLDAP( m_aSettings.sDataSourceName );
+ break;
+
+ case AST_OUTLOOK:
+ m_aNewDataSource = aContext.createNewOutlook( m_aSettings.sDataSourceName );
+ break;
+
+ case AST_OE:
+ m_aNewDataSource = aContext.createNewOE( m_aSettings.sDataSourceName );
+ break;
+
+ case AST_OTHER:
+ m_aNewDataSource = aContext.createNewDBase( m_aSettings.sDataSourceName );
+ break;
+
+ case AST_INVALID:
+ DBG_ERROR( "OAddessBookSourcePilot::implCreateDataSource: illegal data source type!" );
+ break;
+ }
+ m_eNewDataSourceType = m_aSettings.eType;
+ }
+
+ //---------------------------------------------------------------------
+ sal_Bool OAddessBookSourcePilot::connectToDataSource( sal_Bool _bForceReConnect )
+ {
+ DBG_ASSERT( m_aNewDataSource.isValid(), "OAddessBookSourcePilot::implConnect: invalid current data source!" );
+
+ WaitObject aWaitCursor( this );
+ if ( _bForceReConnect && m_aNewDataSource.isConnected( ) )
+ m_aNewDataSource.disconnect( );
+
+ return m_aNewDataSource.connect( this );
+ }
+
+ //---------------------------------------------------------------------
+ OWizardPage* OAddessBookSourcePilot::createPage(WizardState _nState)
+ {
+ switch (_nState)
+ {
+ case STATE_SELECT_ABTYPE:
+ return new TypeSelectionPage( this );
+
+ case STATE_INVOKE_ADMIN_DIALOG:
+ return new AdminDialogInvokationPage( this );
+
+ case STATE_TABLE_SELECTION:
+ return new TableSelectionPage( this );
+
+ case STATE_MANUAL_FIELD_MAPPING:
+ return new FieldMappingPage( this );
+
+ case STATE_FINAL_CONFIRM:
+ return new FinalPage( this );
+
+ default:
+ DBG_ERROR("OAddessBookSourcePilot::createPage: invalid state!");
+ return NULL;
+ }
+ }
+
+ //---------------------------------------------------------------------
+ void OAddessBookSourcePilot::impl_updateRoadmap( AddressSourceType _eType )
+ {
+ bool bSettingsPage = needAdminInvokationPage( _eType );
+ bool bTablesPage = needTableSelection( _eType );
+ bool bFieldsPage = needManualFieldMapping( _eType );
+
+ bool bConnected = m_aNewDataSource.isConnected();
+ bool bCanSkipTables =
+ ( m_aNewDataSource.hasTable( m_aSettings.sSelectedTable )
+ || m_aSettings.bIgnoreNoTable
+ );
+
+ enableState( STATE_INVOKE_ADMIN_DIALOG, bSettingsPage );
+
+ enableState( STATE_TABLE_SELECTION,
+ bTablesPage && ( bConnected ? !bCanSkipTables : !bSettingsPage )
+ // if we do not need a settings page, we connect upon "Next" on the first page
+ );
+
+ enableState( STATE_MANUAL_FIELD_MAPPING,
+ bFieldsPage && bConnected && m_aNewDataSource.hasTable( m_aSettings.sSelectedTable )
+ );
+
+ enableState( STATE_FINAL_CONFIRM,
+ bConnected && bCanSkipTables
+ );
+ }
+
+ //---------------------------------------------------------------------
+ void OAddessBookSourcePilot::typeSelectionChanged( AddressSourceType _eType )
+ {
+ PathId nCurrentPathID( PATH_COMPLETE );
+ bool bSettingsPage = needAdminInvokationPage( _eType );
+ bool bFieldsPage = needManualFieldMapping( _eType );
+ if ( !bSettingsPage )
+ if ( !bFieldsPage )
+ nCurrentPathID = PATH_NO_SETTINGS_NO_FIELDS;
+ else
+ nCurrentPathID = PATH_NO_SETTINGS;
+ else
+ if ( !bFieldsPage )
+ nCurrentPathID = PATH_NO_FIELDS;
+ else
+ nCurrentPathID = PATH_COMPLETE;
+ activatePath( nCurrentPathID, true );
+
+ m_aNewDataSource.disconnect();
+ m_aSettings.bIgnoreNoTable = false;
+ impl_updateRoadmap( _eType );
+ }
+
+//.........................................................................
+} // namespace abp
+//.........................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/abpilot/abspilot.hxx b/extensions/source/abpilot/abspilot.hxx
new file mode 100644
index 000000000000..c9d7eaba2251
--- /dev/null
+++ b/extensions/source/abpilot/abspilot.hxx
@@ -0,0 +1,151 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef EXTENSIONS_ABSPILOT_HXX
+#define EXTENSIONS_ABSPILOT_HXX
+
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <svtools/roadmapwizard.hxx>
+#include "addresssettings.hxx"
+#include <vcl/fixed.hxx>
+#include "datasourcehandling.hxx"
+
+//.........................................................................
+namespace abp
+{
+//.........................................................................
+
+ //=====================================================================
+ //= OAddessBookSourcePilot
+ //=====================================================================
+ typedef ::svt::RoadmapWizard OAddessBookSourcePilot_Base;
+ class OAddessBookSourcePilot : public OAddessBookSourcePilot_Base
+ {
+ protected:
+ ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >
+ m_xORB;
+ AddressSettings m_aSettings;
+
+ ODataSource m_aNewDataSource;
+ AddressSourceType m_eNewDataSourceType;
+
+ public:
+ /// ctor
+ OAddessBookSourcePilot(
+ Window* _pParent,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB);
+
+ /// get the service factory which was used to create the dialog
+ ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >
+ getORB() { return m_xORB; }
+ AddressSettings& getSettings() { return m_aSettings; }
+ const AddressSettings& getSettings() const { return m_aSettings; }
+
+ const ODataSource& getDataSource() const { return m_aNewDataSource; }
+
+ sal_Bool connectToDataSource( sal_Bool _bForceReConnect );
+
+ void travelNext( ) { OAddessBookSourcePilot_Base::travelNext(); }
+
+ /// to be called when the selected type changed
+ void typeSelectionChanged( AddressSourceType _eType );
+
+ protected:
+ // OWizardMachine overridables
+ virtual ::svt::OWizardPage* createPage( WizardState _nState );
+ virtual void enterState( WizardState _nState );
+ virtual sal_Bool prepareLeaveCurrentState( CommitPageReason _eReason );
+ virtual sal_Bool onFinish();
+
+ // RoadmapWizard
+ virtual String getStateDisplayName( WizardState _nState ) const;
+
+ virtual BOOL Close();
+
+ private:
+ DECL_LINK( OnCancelClicked, void* );
+
+ /** creates a new data source of the type indicated by m_aSettings
+ <p>If another data source has been created before, this one is deleted.</p>
+ */
+ void implCreateDataSource();
+
+ /// does an automatic field mapping (possible for all types except AST_OTHER)
+ void implDoAutoFieldMapping();
+
+ /// guesses a default for the table name, if no valid table is selected
+ void implDefaultTableName();
+
+ inline sal_Bool needAdminInvokationPage( AddressSourceType _eType ) const
+ {
+ return ( ( AST_LDAP == _eType )
+ || ( AST_OTHER == _eType )
+ );
+ }
+ /// check if with the current settings, we would need to invoke he administration dialog for more details about the data source
+ inline sal_Bool needAdminInvokationPage() const
+ {
+ return needAdminInvokationPage( m_aSettings.eType );
+ }
+
+ inline sal_Bool needManualFieldMapping( AddressSourceType _eType ) const
+ {
+ return ( AST_OTHER == _eType ) || ( AST_KAB == _eType ) ||
+ ( AST_EVOLUTION == _eType ) || ( AST_EVOLUTION_GROUPWISE == _eType ) ||
+ ( AST_EVOLUTION_LDAP == _eType );
+ }
+ /// checks if we need a manual (user-guided) field mapping
+ inline sal_Bool needManualFieldMapping() const
+ {
+ return needManualFieldMapping( m_aSettings.eType );
+ }
+
+ /// determines whether the given address book type does provide one table only
+ inline bool needTableSelection( AddressSourceType _eType ) const
+ {
+ return ( AST_LDAP != _eType ) && ( AST_KAB != _eType );
+ }
+
+ inline bool needTableSelection() const
+ {
+ return needTableSelection( m_aSettings.eType );
+ }
+
+ void implCleanup();
+ void implCommitAll();
+
+ void impl_updateRoadmap( AddressSourceType _eType );
+ };
+
+//.........................................................................
+} // namespace abp
+//.........................................................................
+
+#endif // EXTENSIONS_ABSPILOT_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/abpilot/abspilot.src b/extensions/source/abpilot/abspilot.src
new file mode 100644
index 000000000000..a69ac07eba75
--- /dev/null
+++ b/extensions/source/abpilot/abspilot.src
@@ -0,0 +1,376 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef EXTENSIONS_ABPRESID_HRC
+#include "abpresid.hrc"
+#endif
+
+//........................................................................
+ModalDialog RID_DLG_ADDRESSBOOKSOURCEPILOT
+{
+ Text [ en-US ] = "Address Book Data Source Wizard" ;
+
+ HelpId = HID_ABSPILOT;
+
+ OutputSize = TRUE ;
+ SVLook = TRUE ;
+ Moveable = TRUE ;
+ Closeable = TRUE ;
+ Hide = TRUE;
+
+ String STR_SELECT_ABTYPE
+ {
+ Text [ en-US ] = "Address book type";
+ };
+
+ String STR_INVOKE_ADMIN_DIALOG
+ {
+ Text [ en-US ] = "Connection Settings";
+ };
+
+ String STR_TABLE_SELECTION
+ {
+ Text [ en-US ] = "Table selection";
+ };
+
+ String STR_MANUAL_FIELD_MAPPING
+ {
+ Text [ en-US ] = "Field Assignment";
+ };
+
+ String STR_FINAL_CONFIRM
+ {
+ Text [ en-US ] = "Data Source Title";
+ };
+};
+
+//........................................................................
+TabPage RID_PAGE_SELECTABTYPE
+{
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( WINDOW_SIZE_X , WINDOW_SIZE_Y ) ;
+
+ FixedText FT_TYPE_HINTS
+ {
+ Pos = MAP_APPFONT ( BORDER_X, 9 ) ;
+ Size = MAP_APPFONT ( WINDOW_SIZE_X - 2 * BORDER_X, 40 ) ;
+ WordBreak = TRUE;
+
+ Text [ en-US ] = "%PRODUCTNAME lets you access address data already present in your system. To do this, a %PRODUCTNAME data source will be created in which your address data is available in tabular form.\n\nThis wizard helps you create the data source.";
+ };
+
+ FixedLine FL_TYPE
+ {
+ Pos = MAP_APPFONT ( 7, 56 ) ;
+ Size = MAP_APPFONT ( WINDOW_SIZE_X - 14, 8 ) ;
+
+ Text [ en-US ] = "Please select the type of your external address book:";
+ };
+
+ RadioButton RB_EVOLUTION
+ {
+ Size = MAP_APPFONT ( WINDOW_SIZE_X - 30, 8 ) ;
+ Text [ en-US ] = "Evolution";
+ };
+ RadioButton RB_EVOLUTION_GROUPWISE
+ {
+ Size = MAP_APPFONT ( WINDOW_SIZE_X - 30, 8 ) ;
+ Text [ en-US ] = "Groupwise";
+ };
+ RadioButton RB_EVOLUTION_LDAP
+ {
+ Size = MAP_APPFONT ( WINDOW_SIZE_X - 30, 8 ) ;
+ Text [ en-US ] = "Evolution LDAP";
+ };
+ RadioButton RB_MORK
+ {
+ Size = MAP_APPFONT ( WINDOW_SIZE_X - 30, 8 ) ;
+ Text [ en-US ] = "Mozilla / Netscape";
+ };
+ RadioButton RB_THUNDERBIRD
+ {
+ Size = MAP_APPFONT ( WINDOW_SIZE_X - 30, 8 ) ;
+ Text [ en-US ] = "Thunderbird";
+ };
+ RadioButton RB_KAB
+ {
+ Size = MAP_APPFONT ( WINDOW_SIZE_X - 30, 8 ) ;
+ Text [ en-US ] = "KDE address book";
+ };
+ RadioButton RB_MACAB
+ {
+ Size = MAP_APPFONT ( WINDOW_SIZE_X - 30, 8 ) ;
+ Text [ en-US ] = "Mac OS X address book";
+ };
+ RadioButton RB_LDAP
+ {
+ Size = MAP_APPFONT ( WINDOW_SIZE_X - 30, 8 ) ;
+ Text [ en-US ] = "LDAP address data";
+ };
+ RadioButton RB_OUTLOOK
+ {
+ Size = MAP_APPFONT ( WINDOW_SIZE_X - 30, 8 ) ;
+ Text [ en-US ] = "Outlook address book";
+ };
+ RadioButton RB_OUTLOOKEXPRESS
+ {
+ Size = MAP_APPFONT ( WINDOW_SIZE_X - 30, 8 ) ;
+ Text [ en-US ] = "Windows system address book";
+ };
+ RadioButton RB_OTHER
+ {
+ Size = MAP_APPFONT ( WINDOW_SIZE_X - 30, 8 ) ;
+ Text [ en-US ] = "Other external data source";
+ };
+};
+
+//........................................................................
+TabPage RID_PAGE_ADMININVOKATION
+{
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( WINDOW_SIZE_X , WINDOW_SIZE_Y ) ;
+
+ FixedText FT_ADMINEXPLANATION
+ {
+ Pos = MAP_APPFONT ( BORDER_X, 9 ) ;
+ Size = MAP_APPFONT ( WINDOW_SIZE_X - 2 * BORDER_X, 48 ) ;
+ WordBreak = TRUE;
+
+ Text [ en-US ] = "To set up the new data source, additional information is required.\n\nClick the following button to open another dialog in which you then enter the necessary information.";
+ };
+
+ PushButton PB_INVOKE_ADMIN_DIALOG
+ {
+ Pos = MAP_APPFONT ( ( WINDOW_SIZE_X - BUTTON_SIZE_X ) / 2, 60 ) ;
+ Size = MAP_APPFONT ( BUTTON_SIZE_X, BUTTON_SIZE_Y ) ;
+
+ Text [ en-US ] = "Settings";
+ };
+
+ FixedText FT_ERROR
+ {
+ Pos = MAP_APPFONT ( BORDER_X, WINDOW_SIZE_Y - HEADER_SIZE_Y - 7 - 48 ) ;
+ Size = MAP_APPFONT ( WINDOW_SIZE_X - 2 * BORDER_X, 48 ) ;
+ WordBreak = TRUE;
+ Hide = TRUE;
+
+ Text [ en-US ] = "The connection to the data source could not be established.\nBefore you proceed, please check the settings made, or (on the previous page) choose another address data source type.";
+ };
+};
+
+//........................................................................
+TabPage RID_PAGE_TABLESELECTION_AB
+{
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( WINDOW_SIZE_X , WINDOW_SIZE_Y ) ;
+
+ FixedText FL_TOOMUCHTABLES
+ {
+ Pos = MAP_APPFONT ( BORDER_X, 9 ) ;
+ Size = MAP_APPFONT ( WINDOW_SIZE_X - 2 * BORDER_X, 24 ) ;
+ WordBreak = TRUE;
+
+ Text [ en-US ] = "The external data source you have chosen contains more than one address book.\nPlease select the one you mainly want to work with:";
+ };
+
+ ListBox LB_TABLELIST
+ {
+ Pos = MAP_APPFONT ( BORDER_X, 36 ) ;
+ Size = MAP_APPFONT ( WINDOW_SIZE_X - 2 * BORDER_X, 50 ) ;
+ SVLook = TRUE;
+ Sort = TRUE;
+ DropDown = FALSE;
+ AutoHScroll = TRUE;
+ Border = TRUE;
+ };
+};
+
+//........................................................................
+TabPage RID_PAGE_FIELDMAPPING
+{
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( WINDOW_SIZE_X , WINDOW_SIZE_Y ) ;
+
+ FixedText FT_FIELDASSIGMENTEXPL
+ {
+ Pos = MAP_APPFONT ( BORDER_X, 9 ) ;
+ Size = MAP_APPFONT ( WINDOW_SIZE_X - 2 * BORDER_X, 72 ) ;
+ WordBreak = TRUE;
+
+ Text [ en-US ] = "To incorporate the address data in your templates, %PRODUCTNAME has to know which fields contain which data.\n\nFor instance, you could have stored the e-mail addresses in a field named \"email\", or \"E-mail\" or \"EM\" - or something completely different.\n\nClick the button below to open another dialog where you can enter the settings for your data source.";
+ };
+
+ PushButton PB_INVOKE_FIELDS_DIALOG
+ {
+ Pos = MAP_APPFONT ( ( WINDOW_SIZE_X - BUTTON_SIZE_X ) / 2, 84 ) ;
+ Size = MAP_APPFONT ( BUTTON_SIZE_X, BUTTON_SIZE_Y ) ;
+
+ Text [ en-US ] = "Field Assignment";
+ };
+
+ FixedText FT_ASSIGNEDFIELDS
+ {
+ Pos = MAP_APPFONT ( BORDER_X, WINDOW_SIZE_Y - HEADER_SIZE_Y - 7 - 32 ) ;
+ Size = MAP_APPFONT ( WINDOW_SIZE_X - 2 * BORDER_X, 32 ) ;
+ WordBreak = TRUE;
+ };
+};
+
+//........................................................................
+TabPage RID_PAGE_FINAL
+{
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( WINDOW_SIZE_X , WINDOW_SIZE_Y ) ;
+
+ FixedText FT_FINISH_EXPL
+ {
+ Pos = MAP_APPFONT ( BORDER_X, 9 ) ;
+ Size = MAP_APPFONT ( WINDOW_SIZE_X - 2 * BORDER_X, 40 ) ;
+ WordBreak = TRUE;
+
+ Text [ en-US ] = "That was all the information necessary to integrate your address data into %PRODUCTNAME.\n\nNow, just enter the name under which you want to register the data source in %PRODUCTNAME.";
+ };
+
+ FixedText FT_LOCATION
+ {
+ Pos = MAP_APPFONT ( BORDER_X, 53 ) ;
+ Size = MAP_APPFONT ( 50, 8 ) ;
+ Group = TRUE;
+
+ Text [ en-US ] = "Location";
+ };
+
+ ComboBox CBB_LOCATION
+ {
+ Pos = MAP_APPFONT ( BORDER_X , 64 ) ;
+ Size = MAP_APPFONT ( WINDOW_SIZE_X - 53 - BORDER_X - BORDER_X, 12) ;
+ SVLook = TRUE;
+ Border = TRUE;
+ DropDown = TRUE ;
+ AutoHScroll = TRUE ;
+ };
+
+ PushButton PB_BROWSE
+ {
+ Pos = MAP_APPFONT ( WINDOW_SIZE_X - 50 - BORDER_X , 63 ) ;
+ Size = MAP_APPFONT ( 50, 14) ;
+ SVLook = TRUE;
+ Group = FALSE;
+
+ Text [ en-US ] = "Browse...";
+ };
+
+ CheckBox CB_REGISTER_DS
+ {
+ Pos = MAP_APPFONT ( BORDER_X, 82 ) ;
+ Size = MAP_APPFONT ( WINDOW_SIZE_X - BORDER_X - BORDER_X, 8) ;
+ SVLook = TRUE;
+ Group = TRUE;
+
+ Text [ en-US ] = "Make this address book available to all modules in %PRODUCTNAME.";
+ };
+ FixedText FT_NAME_EXPL
+ {
+ Pos = MAP_APPFONT ( BORDER_X + 10, 93 ) ;
+ Size = MAP_APPFONT ( WINDOW_SIZE_X - BORDER_X - BORDER_X - 10, 8 ) ;
+
+ Text [ en-US ] = "Address book name";
+ };
+
+ Edit ET_DATASOURCENAME
+ {
+ Pos = MAP_APPFONT ( BORDER_X + 10, 104 ) ;
+ Size = MAP_APPFONT ( WINDOW_SIZE_X - 56 - BORDER_X - BORDER_X - 10, 12) ;
+ SVLook = TRUE;
+ Border = TRUE;
+ };
+
+ FixedText FT_DUPLICATENAME
+ {
+ Pos = MAP_APPFONT ( BORDER_X + 10, WINDOW_SIZE_Y - HEADER_SIZE_Y - 7 - 24 ) ;
+ Size = MAP_APPFONT ( WINDOW_SIZE_X - 2 * BORDER_X, 24) ;
+ WordBreak = TRUE;
+ Hide = TRUE;
+ Group = FALSE;
+
+ Text [ en-US ] = "Another data source already has this name. As data sources have to have globally unique names, you need to choose another one.";
+ };
+};
+
+//........................................................................
+ErrorBox RID_ERR_NEEDTYPESELECTION
+{
+ Buttons = WB_OK;
+
+ Message [ en-US ] = "Please select a type of address book.";
+};
+
+//........................................................................
+QueryBox RID_QRY_NOTABLES
+{
+ Buttons = WB_YES_NO;
+ DefButton = WB_DEF_NO;
+
+ Message [ en-US ] = "The data source does not contain any tables.\nDo you want to set it up as an address data source, anyway?";
+};
+
+//........................................................................
+String RID_STR_DEFAULT_NAME
+{
+ Text [ en-US ] = "Addresses";
+};
+
+String RID_STR_ADMINDIALOGTITLE
+{
+ Text [ en-US ] = "Create Address Data Source";
+};
+
+String RID_STR_NOCONNECTION
+{
+ Text [ en-US ] = "The connection could not be established.";
+};
+
+String RID_STR_PLEASECHECKSETTINGS
+{
+ Text [ en-US ] = "Please check the settings made for the data source.";
+};
+
+String RID_STR_FIELDDIALOGTITLE
+{
+ Text [ en-US ] = "Address Data - Field Assignment";
+};
+
+String RID_STR_NOFIELDSASSIGNED
+{
+ Text [ en-US ] = "There are no fields assigned at this time.\nYou can either assign fields now or do so later by first choosing:\n\"File - Template - Address Book Source...\"";
+};
+
+//........................................................................
+Bitmap BMP_HEADERIMAGE
+{
+ file = "addresspilot.bmp";
+};
diff --git a/extensions/source/abpilot/addresssettings.hxx b/extensions/source/abpilot/addresssettings.hxx
new file mode 100644
index 000000000000..9c05144befb6
--- /dev/null
+++ b/extensions/source/abpilot/addresssettings.hxx
@@ -0,0 +1,81 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef EXTENSIONS_ABP_ADDRESSSETTINGS_HXX
+#define EXTENSIONS_ABP_ADDRESSSETTINGS_HXX
+
+#include <rtl/ustring.hxx>
+#include "abptypes.hxx"
+
+//.........................................................................
+namespace abp
+{
+//.........................................................................
+
+ //=====================================================================
+ //= AddressSourceType
+ //=====================================================================
+ enum AddressSourceType
+ {
+ AST_MORK,
+ AST_THUNDERBIRD,
+ AST_EVOLUTION,
+ AST_EVOLUTION_GROUPWISE,
+ AST_EVOLUTION_LDAP,
+ AST_KAB,
+ AST_MACAB,
+ AST_LDAP,
+ AST_OUTLOOK,
+ AST_OE,
+
+ AST_OTHER,
+
+ AST_INVALID
+ };
+
+ //=====================================================================
+ //= AddressSettings
+ //=====================================================================
+ struct AddressSettings
+ {
+ AddressSourceType eType;
+ ::rtl::OUString sDataSourceName;
+ ::rtl::OUString sRegisteredDataSourceName;
+ ::rtl::OUString sSelectedTable;
+ bool bIgnoreNoTable;
+ MapString2String aFieldMapping;
+ bool bRegisterDataSource;
+ };
+
+//.........................................................................
+} // namespace abp
+//.........................................................................
+
+#endif // EXTENSIONS_ABP_ADDRESSSETTINGS_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/abpilot/admininvokationimpl.cxx b/extensions/source/abpilot/admininvokationimpl.cxx
new file mode 100644
index 000000000000..8f406ced1ce7
--- /dev/null
+++ b/extensions/source/abpilot/admininvokationimpl.cxx
@@ -0,0 +1,135 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+#include "admininvokationimpl.hxx"
+#include <tools/debug.hxx>
+#include <com/sun/star/beans/PropertyValue.hpp>
+#include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
+#include <com/sun/star/awt/XWindow.hpp>
+#include <vcl/stdtext.hxx>
+#include <toolkit/unohlp.hxx>
+#include "abpresid.hrc"
+#include "componentmodule.hxx"
+#include <vcl/waitobj.hxx>
+
+
+//.........................................................................
+namespace abp
+{
+//.........................................................................
+
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::lang;
+ using namespace ::com::sun::star::beans;
+ using namespace ::com::sun::star::awt;
+ using namespace ::com::sun::star::ui::dialogs;
+
+ //=====================================================================
+ //= OAdminDialogInvokation
+ //=====================================================================
+ //---------------------------------------------------------------------
+ OAdminDialogInvokation::OAdminDialogInvokation(const Reference< XMultiServiceFactory >& _rxORB
+ , const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > _xDataSource
+ , Window* _pMessageParent)
+ :m_xORB(_rxORB)
+ ,m_xDataSource(_xDataSource)
+ ,m_pMessageParent(_pMessageParent)
+ {
+ DBG_ASSERT(m_xORB.is(), "OAdminDialogInvokation::OAdminDialogInvokation: invalid service factory!");
+ DBG_ASSERT(m_xDataSource.is(), "OAdminDialogInvokation::OAdminDialogInvokation: invalid preferred name!");
+ DBG_ASSERT(m_pMessageParent, "OAdminDialogInvokation::OAdminDialogInvokation: invalid message parent!");
+ }
+
+ //---------------------------------------------------------------------
+ sal_Bool OAdminDialogInvokation::invokeAdministration( sal_Bool _bFixedType )
+ {
+ if (!m_xORB.is())
+ return sal_False;
+
+ try
+ {
+ // the service name of the administration dialog
+ const static ::rtl::OUString s_sAdministrationServiceName = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sdb.DatasourceAdministrationDialog"));
+ const static ::rtl::OUString s_sDataSourceTypeChangeDialog = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sdb.DataSourceTypeChangeDialog"));
+
+ // the parameters for the call
+ Sequence< Any > aArguments(3);
+ Any* pArguments = aArguments.getArray();
+
+ // the parent window
+ Reference< XWindow > xDialogParent = VCLUnoHelper::GetInterface(m_pMessageParent);
+ *pArguments++ <<= PropertyValue(::rtl::OUString::createFromAscii("ParentWindow"), -1, makeAny(xDialogParent), PropertyState_DIRECT_VALUE);
+
+ // the title of the dialog
+ String sAdminDialogTitle(ModuleRes(RID_STR_ADMINDIALOGTITLE));
+ *pArguments++ <<= PropertyValue(::rtl::OUString::createFromAscii("Title"), -1, makeAny(::rtl::OUString(sAdminDialogTitle)), PropertyState_DIRECT_VALUE);
+
+ // the name of the new data source
+ *pArguments++ <<= PropertyValue(::rtl::OUString::createFromAscii("InitialSelection"), -1, makeAny(m_xDataSource), PropertyState_DIRECT_VALUE);
+
+ // create the dialog
+ Reference< XExecutableDialog > xDialog;
+ {
+ // creating the dialog service is potentially expensive (if all the libraries invoked need to be loaded)
+ // so we display a wait cursor
+ WaitObject aWaitCursor(m_pMessageParent);
+ xDialog = Reference< XExecutableDialog >( m_xORB->createInstanceWithArguments( _bFixedType ? s_sAdministrationServiceName : s_sDataSourceTypeChangeDialog, aArguments ), UNO_QUERY );
+
+ // just for a smoother UI: What the dialog does upon execution, is (amongst other things) creating
+ // the DriverManager service
+ // If this context has never been accessed before, this may be expensive (it includes loading of
+ // at least one library).
+ // As this wizard is intended to run on the first office start, it is very likely that the
+ // context needs to be freshly created
+ // Thus, we access the context here (within the WaitCursor), which means the user sees a waitcursor
+ // while his/her office blocks a few seconds ....
+ m_xORB->createInstance( ::rtl::OUString::createFromAscii( "com.sun.star.sdbc.DriverManager" ) );
+ }
+
+ if (xDialog.is())
+ { // execute it
+ if (xDialog->execute())
+ return sal_True;
+ }
+ else
+ ShowServiceNotAvailableError(m_pMessageParent, s_sAdministrationServiceName, sal_True);
+ }
+ catch(const Exception&)
+ {
+ DBG_ERROR("OAdminDialogInvokation::invokeAdministration: caught an exception while executing the dialog!");
+ }
+ return sal_False;
+ }
+
+//.........................................................................
+} // namespace abp
+//.........................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/abpilot/admininvokationimpl.hxx b/extensions/source/abpilot/admininvokationimpl.hxx
new file mode 100644
index 000000000000..760d2270e0cd
--- /dev/null
+++ b/extensions/source/abpilot/admininvokationimpl.hxx
@@ -0,0 +1,72 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef EXTENSIONS_ABP_ADMININVOKATIONIMPL_HXX
+#define EXTENSIONS_ABP_ADMININVOKATIONIMPL_HXX
+
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+
+
+class Window;
+//.........................................................................
+namespace abp
+{
+//.........................................................................
+
+ //=====================================================================
+ //= OAdminDialogInvokation
+ //=====================================================================
+ /** outsourced from AdminDialogInvokationPage, 'cause this class here, in opposite to
+ the page, needs exception handlíng to be enabled.
+ */
+ class OAdminDialogInvokation
+ {
+ private:
+ ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >
+ m_xORB;
+ ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > m_xDataSource;
+ Window* m_pMessageParent;
+
+ public:
+ OAdminDialogInvokation(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > _xDataSource,
+ Window* _pMessageParent
+ );
+
+ sal_Bool invokeAdministration( sal_Bool _bFixedType );
+ };
+
+//.........................................................................
+} // namespace abp
+//.........................................................................
+
+#endif // EXTENSIONS_ABP_ADMININVOKATIONIMPL_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/abpilot/admininvokationpage.cxx b/extensions/source/abpilot/admininvokationpage.cxx
new file mode 100644
index 000000000000..872c050508a2
--- /dev/null
+++ b/extensions/source/abpilot/admininvokationpage.cxx
@@ -0,0 +1,116 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+#include "admininvokationpage.hxx"
+#include "abspilot.hxx"
+#include "admininvokationimpl.hxx"
+
+//.........................................................................
+namespace abp
+{
+//.........................................................................
+
+ //=====================================================================
+ //= AdminDialogInvokationPage
+ //=====================================================================
+ AdminDialogInvokationPage::AdminDialogInvokationPage( OAddessBookSourcePilot* _pParent )
+ :AddressBookSourcePage(_pParent, ModuleRes(RID_PAGE_ADMININVOKATION))
+ ,m_aExplanation (this, ModuleRes(FT_ADMINEXPLANATION))
+ ,m_aInvokeAdminDialog (this, ModuleRes(PB_INVOKE_ADMIN_DIALOG))
+ ,m_aErrorMessage (this, ModuleRes(FT_ERROR))
+ ,m_bSuccessfullyExecutedDialog(sal_False)
+ {
+ FreeResource();
+
+ m_aInvokeAdminDialog.SetClickHdl( LINK(this, AdminDialogInvokationPage, OnInvokeAdminDialog) );
+ }
+
+ //---------------------------------------------------------------------
+ void AdminDialogInvokationPage::ActivatePage()
+ {
+ AddressBookSourcePage::ActivatePage();
+ m_aInvokeAdminDialog.GrabFocus();
+ }
+
+ //---------------------------------------------------------------------
+ void AdminDialogInvokationPage::implUpdateErrorMessage()
+ {
+ const sal_Bool bIsConnected = getDialog()->getDataSource().isConnected();
+ m_aErrorMessage.Show( !bIsConnected );
+ }
+
+ //---------------------------------------------------------------------
+ void AdminDialogInvokationPage::initializePage()
+ {
+ AddressBookSourcePage::initializePage();
+ m_aErrorMessage.Hide();
+ // if we're entering this page, we assume we had no connection trial with this data source
+ }
+
+ //---------------------------------------------------------------------
+ void AdminDialogInvokationPage::implTryConnect()
+ {
+ getDialog()->connectToDataSource( sal_True );
+
+ // show our error message if and only if we could not connect
+ implUpdateErrorMessage();
+
+ // the status of the next button may have changed
+ updateDialogTravelUI();
+
+ // automatically go to the next page (if successfully connected)
+ if ( canAdvance() )
+ getDialog()->travelNext();
+ }
+
+ //---------------------------------------------------------------------
+ bool AdminDialogInvokationPage::canAdvance() const
+ {
+ return AddressBookSourcePage::canAdvance() && getDialog()->getDataSource().isConnected();
+ }
+
+ //---------------------------------------------------------------------
+ IMPL_LINK( AdminDialogInvokationPage, OnInvokeAdminDialog, void*, /*NOTINTERESTEDIN*/ )
+ {
+ OAdminDialogInvokation aInvokation( getORB(), getDialog()->getDataSource().getDataSource(), getDialog() );
+ if ( aInvokation.invokeAdministration( AST_LDAP == getSettings().eType ) )
+ {
+ // try to connect to this data source
+ implTryConnect();
+ }
+
+ return 0L;
+ }
+
+//.........................................................................
+} // namespace abp
+//.........................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/abpilot/admininvokationpage.hxx b/extensions/source/abpilot/admininvokationpage.hxx
new file mode 100644
index 000000000000..ac435be2cd07
--- /dev/null
+++ b/extensions/source/abpilot/admininvokationpage.hxx
@@ -0,0 +1,75 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef EXTENSIONS_ABP_ADMINDIALOG_INVOKATION_PAGE_HXX
+#define EXTENSIONS_ABP_ADMINDIALOG_INVOKATION_PAGE_HXX
+
+#include "abspage.hxx"
+
+//.........................................................................
+namespace abp
+{
+//.........................................................................
+
+ //=====================================================================
+ //= AdminDialogInvokationPage
+ //=====================================================================
+ class AdminDialogInvokationPage : public AddressBookSourcePage
+ {
+ protected:
+ FixedText m_aExplanation;
+ PushButton m_aInvokeAdminDialog;
+ FixedText m_aErrorMessage;
+
+ sal_Bool m_bSuccessfullyExecutedDialog;
+
+ public:
+ AdminDialogInvokationPage( OAddessBookSourcePilot* _pParent );
+
+ protected:
+ // TabDialog overridables
+ virtual void ActivatePage();
+ virtual void initializePage();
+
+ // OImportPage overridables
+ virtual bool canAdvance() const;
+
+ private:
+ DECL_LINK( OnInvokeAdminDialog, void* );
+
+ void implTryConnect();
+ void implUpdateErrorMessage();
+ };
+
+//.........................................................................
+} // namespace abp
+//.........................................................................
+
+#endif // EXTENSIONS_ABP_ADMINDIALOG_INVOKATION_PAGE_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/abpilot/datasourcehandling.cxx b/extensions/source/abpilot/datasourcehandling.cxx
new file mode 100644
index 000000000000..95e2be27bea8
--- /dev/null
+++ b/extensions/source/abpilot/datasourcehandling.cxx
@@ -0,0 +1,639 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+
+#include "abpresid.hrc"
+#include "abptypes.hxx"
+#include "componentmodule.hxx"
+#include "datasourcehandling.hxx"
+
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/container/XNameAccess.hpp>
+#include <com/sun/star/frame/XStorable.hpp>
+#include <com/sun/star/lang/XComponent.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/lang/XSingleServiceFactory.hpp>
+#include <com/sun/star/sdb/SQLContext.hpp>
+#include <com/sun/star/sdb/XCompletedConnection.hpp>
+#include <com/sun/star/sdb/XDatabaseRegistrations.hpp>
+#include <com/sun/star/sdb/XDocumentDataSource.hpp>
+#include <com/sun/star/sdbc/XConnection.hpp>
+#include <com/sun/star/sdbcx/XTablesSupplier.hpp>
+#include <com/sun/star/task/XInteractionHandler.hpp>
+#include <com/sun/star/uno/XNamingService.hpp>
+
+#include <comphelper/interaction.hxx>
+#include <comphelper/componentcontext.hxx>
+#include <tools/debug.hxx>
+#include <tools/diagnose_ex.h>
+#include <unotools/confignode.hxx>
+#include <unotools/sharedunocomponent.hxx>
+#include <vcl/stdtext.hxx>
+
+//.........................................................................
+namespace abp
+{
+//.........................................................................
+
+ using namespace ::utl;
+ using namespace ::comphelper;
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::lang;
+ using namespace ::com::sun::star::sdb;
+ using namespace ::com::sun::star::sdbc;
+ using namespace ::com::sun::star::task;
+ using namespace ::com::sun::star::beans;
+ using namespace ::com::sun::star::sdbcx;
+ using namespace ::com::sun::star::container;
+ using namespace ::com::sun::star::frame;
+
+ //=====================================================================
+ struct PackageAccessControl { };
+
+ //=====================================================================
+ //---------------------------------------------------------------------
+ static Reference< XNameAccess > lcl_getDataSourceContext( const Reference< XMultiServiceFactory >& _rxORB ) SAL_THROW (( Exception ))
+ {
+ Reference< XNameAccess > xContext( _rxORB->createInstance( ::rtl::OUString::createFromAscii( "com.sun.star.sdb.DatabaseContext" ) ), UNO_QUERY );
+ DBG_ASSERT(xContext.is(), "lcl_getDataSourceContext: could not access the data source context!");
+ return xContext;
+ }
+
+ //---------------------------------------------------------------------
+ /// creates a new data source and inserts it into the context
+ static void lcl_implCreateAndInsert(
+ const Reference< XMultiServiceFactory >& _rxORB, const ::rtl::OUString& _rName,
+ Reference< XPropertySet >& /* [out] */ _rxNewDataSource ) SAL_THROW (( ::com::sun::star::uno::Exception ))
+ {
+ //.............................................................
+ // get the data source context
+ Reference< XNameAccess > xContext = lcl_getDataSourceContext( _rxORB );
+
+ DBG_ASSERT( !xContext->hasByName( _rName ), "lcl_implCreateAndInsert: name already used!" );
+ (void)_rName;
+
+ //.............................................................
+ // create a new data source
+ Reference< XSingleServiceFactory > xFactory( xContext, UNO_QUERY );
+ Reference< XPropertySet > xNewDataSource;
+ if (xFactory.is())
+ xNewDataSource = Reference< XPropertySet >( xFactory->createInstance(), UNO_QUERY );
+ DBG_ASSERT( xNewDataSource.is(), "lcl_implCreateAndInsert: could not create a new data source!" );
+
+ //.............................................................
+ // insert the data source into the context
+ Reference< XNamingService > xDynamicContext( xContext, UNO_QUERY );
+ DBG_ASSERT( xDynamicContext.is(), "lcl_implCreateAndInsert: missing an interface on the context (XNamingService)!" );
+ if (xDynamicContext.is())
+ {
+ // xDynamicContext->registerObject( _rName, xNewDataSource );
+ _rxNewDataSource = xNewDataSource;
+ }
+ }
+
+ //---------------------------------------------------------------------
+ /// creates and inserts a data source, and sets it's URL property to the string given
+ static ODataSource lcl_implCreateAndSetURL(
+ const Reference< XMultiServiceFactory >& _rxORB, const ::rtl::OUString& _rName,
+ const sal_Char* _pInitialAsciiURL ) SAL_THROW (( ))
+ {
+ ODataSource aReturn( _rxORB );
+ try
+ {
+ // create the new data source
+ Reference< XPropertySet > xNewDataSource;
+ lcl_implCreateAndInsert( _rxORB, _rName, xNewDataSource );
+
+ //.............................................................
+ // set the URL property
+ if (xNewDataSource.is())
+ {
+ xNewDataSource->setPropertyValue(
+ ::rtl::OUString::createFromAscii( "URL" ),
+ makeAny( ::rtl::OUString::createFromAscii( _pInitialAsciiURL ) )
+ );
+ }
+
+ aReturn.setDataSource( xNewDataSource, _rName,PackageAccessControl() );
+ }
+ catch(const Exception&)
+ {
+ DBG_ERROR( "lcl_implCreateAndSetURL: caught an exception while creating the data source!" );
+ }
+
+ return aReturn;
+ }
+ //---------------------------------------------------------------------
+ void lcl_registerDataSource(
+ const Reference< XMultiServiceFactory >& _rxORB, const ::rtl::OUString& _sName,
+ const ::rtl::OUString& _sURL ) SAL_THROW (( ::com::sun::star::uno::Exception ))
+ {
+ OSL_ENSURE( _sName.getLength(), "lcl_registerDataSource: invalid name!" );
+ OSL_ENSURE( _sURL.getLength(), "lcl_registerDataSource: invalid URL!" );
+ try
+ {
+
+ ::comphelper::ComponentContext aContext( _rxORB );
+ Reference< XDatabaseRegistrations > xRegistrations(
+ aContext.createComponent( "com.sun.star.sdb.DatabaseContext" ), UNO_QUERY_THROW );
+
+ if ( xRegistrations->hasRegisteredDatabase( _sName ) )
+ xRegistrations->changeDatabaseLocation( _sName, _sURL );
+ else
+ xRegistrations->registerDatabaseLocation( _sName, _sURL );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+
+ //=====================================================================
+ //= ODataSourceContextImpl
+ //=====================================================================
+ struct ODataSourceContextImpl
+ {
+ Reference< XMultiServiceFactory > xORB;
+ Reference< XNameAccess > xContext; /// the UNO data source context
+ StringBag aDataSourceNames; /// for quicker name checks (without the UNO overhead)
+
+ ODataSourceContextImpl( const Reference< XMultiServiceFactory >& _rxORB ) : xORB( _rxORB ) { }
+ ODataSourceContextImpl( const ODataSourceContextImpl& _rSource )
+ :xORB ( _rSource.xORB )
+ ,xContext ( _rSource.xContext )
+ {
+ }
+ };
+
+ //=====================================================================
+ //= ODataSourceContext
+ //=====================================================================
+ //---------------------------------------------------------------------
+ ODataSourceContext::ODataSourceContext(const Reference< XMultiServiceFactory >& _rxORB)
+ :m_pImpl( new ODataSourceContextImpl( _rxORB ) )
+ {
+ try
+ {
+ // create the UNO context
+ m_pImpl->xContext = lcl_getDataSourceContext( _rxORB );
+
+ if (m_pImpl->xContext.is())
+ {
+ // collect the data source names
+ Sequence< ::rtl::OUString > aDSNames = m_pImpl->xContext->getElementNames();
+ const ::rtl::OUString* pDSNames = aDSNames.getConstArray();
+ const ::rtl::OUString* pDSNamesEnd = pDSNames + aDSNames.getLength();
+
+ for ( ;pDSNames != pDSNamesEnd; ++pDSNames )
+ m_pImpl->aDataSourceNames.insert( *pDSNames );
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_ERROR( "ODataSourceContext::ODataSourceContext: caught an exception!" );
+ }
+ }
+
+ //---------------------------------------------------------------------
+ ::rtl::OUString& ODataSourceContext::disambiguate(::rtl::OUString& _rDataSourceName)
+ {
+ ::rtl::OUString sCheck( _rDataSourceName );
+ ConstStringBagIterator aPos = m_pImpl->aDataSourceNames.find( sCheck );
+
+ sal_Int32 nPostFix = 1;
+ while ( ( m_pImpl->aDataSourceNames.end() != aPos ) && ( nPostFix < 65535 ) )
+ { // there already is a data source with this name
+ sCheck = _rDataSourceName;
+ sCheck += ::rtl::OUString::valueOf( nPostFix++ );
+
+ aPos = m_pImpl->aDataSourceNames.find( sCheck );
+ }
+
+ _rDataSourceName = sCheck;
+ return _rDataSourceName;
+ }
+
+ //---------------------------------------------------------------------
+ void ODataSourceContext::getDataSourceNames( StringBag& _rNames ) const SAL_THROW (( ))
+ {
+ _rNames = m_pImpl->aDataSourceNames;
+ }
+
+ //---------------------------------------------------------------------
+ ODataSource ODataSourceContext::createNewLDAP( const ::rtl::OUString& _rName) SAL_THROW (( ))
+ {
+ return lcl_implCreateAndSetURL( m_pImpl->xORB, _rName, "sdbc:address:ldap:" );
+ }
+
+ //---------------------------------------------------------------------
+ ODataSource ODataSourceContext::createNewMORK( const ::rtl::OUString& _rName) SAL_THROW (( ))
+ {
+ return lcl_implCreateAndSetURL( m_pImpl->xORB, _rName, "sdbc:address:mozilla" );
+ }
+
+ //---------------------------------------------------------------------
+ ODataSource ODataSourceContext::createNewThunderbird( const ::rtl::OUString& _rName ) SAL_THROW (( ))
+ {
+ return lcl_implCreateAndSetURL( m_pImpl->xORB, _rName, "sdbc:address:thunderbird" );
+ }
+
+ //---------------------------------------------------------------------
+ ODataSource ODataSourceContext::createNewEvolutionLdap( const ::rtl::OUString& _rName) SAL_THROW (( ))
+ {
+ return lcl_implCreateAndSetURL( m_pImpl->xORB, _rName, "sdbc:address:evolution:ldap" );
+ }
+ //---------------------------------------------------------------------
+ ODataSource ODataSourceContext::createNewEvolutionGroupwise( const ::rtl::OUString& _rName) SAL_THROW (( ))
+ {
+ return lcl_implCreateAndSetURL( m_pImpl->xORB, _rName, "sdbc:address:evolution:groupwise" );
+ }
+ //---------------------------------------------------------------------
+ ODataSource ODataSourceContext::createNewEvolution( const ::rtl::OUString& _rName) SAL_THROW (( ))
+ {
+ return lcl_implCreateAndSetURL( m_pImpl->xORB, _rName, "sdbc:address:evolution:local" );
+ }
+
+ //---------------------------------------------------------------------
+ ODataSource ODataSourceContext::createNewKab( const ::rtl::OUString& _rName) SAL_THROW (( ))
+ {
+ return lcl_implCreateAndSetURL( m_pImpl->xORB, _rName, "sdbc:address:kab" );
+ }
+
+ //---------------------------------------------------------------------
+ ODataSource ODataSourceContext::createNewMacab( const ::rtl::OUString& _rName) SAL_THROW (( ))
+ {
+ return lcl_implCreateAndSetURL( m_pImpl->xORB, _rName, "sdbc:address:macab" );
+ }
+
+ //---------------------------------------------------------------------
+ ODataSource ODataSourceContext::createNewOutlook( const ::rtl::OUString& _rName) SAL_THROW (( ))
+ {
+ return lcl_implCreateAndSetURL( m_pImpl->xORB, _rName, "sdbc:address:outlook" );
+ }
+
+ //---------------------------------------------------------------------
+ ODataSource ODataSourceContext::createNewOE( const ::rtl::OUString& _rName) SAL_THROW (( ))
+ {
+ return lcl_implCreateAndSetURL( m_pImpl->xORB, _rName, "sdbc:address:outlookexp" );
+ }
+
+ //---------------------------------------------------------------------
+ ODataSource ODataSourceContext::createNewDBase( const ::rtl::OUString& _rName) SAL_THROW (( ))
+ {
+ return lcl_implCreateAndSetURL( m_pImpl->xORB, _rName, "sdbc:dbase:" );
+ }
+
+ //=====================================================================
+ //= ODataSourceImpl
+ //=====================================================================
+ struct ODataSourceImpl
+ {
+ public:
+ Reference< XMultiServiceFactory > xORB; /// the service factory
+ Reference< XPropertySet > xDataSource; /// the UNO data source
+ ::utl::SharedUNOComponent< XConnection >
+ xConnection;
+ StringBag aTables; // the cached table names
+ ::rtl::OUString sName;
+ sal_Bool bTablesUpToDate; // table name cache up-to-date?
+
+ ODataSourceImpl( const Reference< XMultiServiceFactory >& _rxORB )
+ :xORB( _rxORB )
+ ,bTablesUpToDate( sal_False )
+ {
+ }
+
+ ODataSourceImpl( const ODataSourceImpl& _rSource );
+ };
+
+ //---------------------------------------------------------------------
+ ODataSourceImpl::ODataSourceImpl( const ODataSourceImpl& _rSource )
+ :xORB( _rSource.xORB )
+ ,xDataSource( _rSource.xDataSource )
+ ,xConnection( _rSource.xConnection )
+ ,aTables( _rSource.aTables )
+ ,sName( _rSource.sName )
+ ,bTablesUpToDate( _rSource.bTablesUpToDate )
+ {
+ }
+
+ //=====================================================================
+ //= ODataSource
+ //=====================================================================
+ //---------------------------------------------------------------------
+ ODataSource::ODataSource( const ODataSource& _rSource )
+ :m_pImpl( NULL )
+ {
+ *this = _rSource;
+ }
+
+ //---------------------------------------------------------------------
+ ODataSource& ODataSource::operator=( const ODataSource& _rSource )
+ {
+ delete m_pImpl;
+ m_pImpl = new ODataSourceImpl( *_rSource.m_pImpl );
+
+ return *this;
+ }
+
+ //---------------------------------------------------------------------
+ ODataSource::ODataSource( const Reference< XMultiServiceFactory >& _rxORB )
+ :m_pImpl(new ODataSourceImpl(_rxORB))
+ {
+ }
+
+ //---------------------------------------------------------------------
+ ODataSource::~ODataSource( )
+ {
+ delete m_pImpl;
+ }
+
+ //---------------------------------------------------------------------
+ void ODataSource::store() SAL_THROW (( ))
+ {
+ if (!isValid())
+ // nothing to do
+ return;
+ try
+ {
+ Reference< XDocumentDataSource > xDocAccess( m_pImpl->xDataSource, UNO_QUERY );
+ Reference< XStorable > xStorable;
+ if ( xDocAccess.is() )
+ xStorable = xStorable.query( xDocAccess->getDatabaseDocument() );
+ OSL_ENSURE( xStorable.is(),"DataSource is no XStorable!" );
+ if ( xStorable.is() )
+ xStorable->storeAsURL(m_pImpl->sName,Sequence<PropertyValue>());
+ }
+ catch(const Exception&)
+ {
+ DBG_ERROR( "ODataSource::registerDataSource: caught an exception while creating the data source!" );
+ }
+ }
+ //---------------------------------------------------------------------
+ void ODataSource::registerDataSource( const ::rtl::OUString& _sRegisteredDataSourceName) SAL_THROW (( ))
+ {
+ if (!isValid())
+ // nothing to do
+ return;
+
+ try
+ {
+ // invalidate ourself
+ lcl_registerDataSource(m_pImpl->xORB,_sRegisteredDataSourceName,m_pImpl->sName);
+ }
+ catch(const Exception&)
+ {
+ DBG_ERROR( "ODataSource::registerDataSource: caught an exception while creating the data source!" );
+ }
+ }
+
+ //---------------------------------------------------------------------
+ void ODataSource::setDataSource( const Reference< XPropertySet >& _rxDS,const ::rtl::OUString& _sName, PackageAccessControl )
+ {
+ if (m_pImpl->xDataSource.get() == _rxDS.get())
+ // nothing to do
+ return;
+
+ if ( isConnected() )
+ disconnect();
+
+ m_pImpl->sName = _sName;
+ m_pImpl->xDataSource = _rxDS;
+ }
+
+ //---------------------------------------------------------------------
+ void ODataSource::remove() SAL_THROW (( ))
+ {
+ if (!isValid())
+ // nothing to do
+ return;
+
+ try
+ {
+ // invalidate ourself
+ m_pImpl->xDataSource.clear();
+ }
+ catch(const Exception&)
+ {
+ DBG_ERROR( "ODataSource::remove: caught an exception while creating the data source!" );
+ }
+ }
+
+ //---------------------------------------------------------------------
+ sal_Bool ODataSource::rename( const ::rtl::OUString& _rName ) SAL_THROW (( ))
+ {
+ if (!isValid())
+ // nothing to do
+ return sal_False;
+
+ m_pImpl->sName = _rName;
+ return sal_True;
+ }
+
+ //---------------------------------------------------------------------
+ ::rtl::OUString ODataSource::getName() const SAL_THROW (( ))
+ {
+ if ( !isValid() )
+ return ::rtl::OUString();
+ return m_pImpl->sName;
+ }
+
+ //---------------------------------------------------------------------
+ bool ODataSource::hasTable( const ::rtl::OUString& _rTableName ) const
+ {
+ if ( !isConnected() )
+ return false;
+
+ const StringBag& aTables( getTableNames() );
+ return aTables.find( _rTableName ) != aTables.end();
+ }
+
+ //---------------------------------------------------------------------
+ const StringBag& ODataSource::getTableNames() const SAL_THROW (( ))
+ {
+ m_pImpl->aTables.clear();
+ if ( !isConnected() )
+ {
+ DBG_ERROR( "ODataSource::getTableNames: not connected!" );
+ }
+ else
+ {
+ try
+ {
+ // get the tables container from the connection
+ Reference< XTablesSupplier > xSuppTables( m_pImpl->xConnection.getTyped(), UNO_QUERY );
+ Reference< XNameAccess > xTables;
+ if ( xSuppTables.is( ) )
+ xTables = xSuppTables->getTables();
+ DBG_ASSERT( xTables.is(), "ODataSource::getTableNames: could not retrieve the tables container!" );
+
+ // get the names
+ Sequence< ::rtl::OUString > aTableNames;
+ if ( xTables.is( ) )
+ aTableNames = xTables->getElementNames( );
+
+ // copy the names
+ const ::rtl::OUString* pTableNames = aTableNames.getConstArray();
+ const ::rtl::OUString* pTableNamesEnd = pTableNames + aTableNames.getLength();
+ for (;pTableNames < pTableNamesEnd; ++pTableNames)
+ m_pImpl->aTables.insert( *pTableNames );
+ }
+ catch(const Exception&)
+ {
+ }
+ }
+
+ // now the table cache is up-to-date
+ m_pImpl->bTablesUpToDate = sal_True;
+ return m_pImpl->aTables;
+ }
+
+ //---------------------------------------------------------------------
+ sal_Bool ODataSource::connect( Window* _pMessageParent ) SAL_THROW (( ))
+ {
+ if ( isConnected( ) )
+ // nothing to do
+ return sal_True;
+
+ // ................................................................
+ // create the interaction handler (needed for authentication and error handling)
+ static ::rtl::OUString s_sInteractionHandlerServiceName = ::rtl::OUString::createFromAscii("com.sun.star.task.InteractionHandler");
+ Reference< XInteractionHandler > xInteractions;
+ try
+ {
+ xInteractions = Reference< XInteractionHandler >(
+ m_pImpl->xORB->createInstance( s_sInteractionHandlerServiceName ),
+ UNO_QUERY
+ );
+ }
+ catch(const Exception&)
+ {
+ }
+
+ // ................................................................
+ // failure to create the interaction handler is a serious issue ...
+ if (!xInteractions.is())
+ {
+ if ( _pMessageParent )
+ ShowServiceNotAvailableError( _pMessageParent, s_sInteractionHandlerServiceName, sal_True );
+ return sal_False;
+ }
+
+ // ................................................................
+ // open the connection
+ Any aError;
+ Reference< XConnection > xConnection;
+ try
+ {
+ Reference< XCompletedConnection > xComplConn( m_pImpl->xDataSource, UNO_QUERY );
+ DBG_ASSERT( xComplConn.is(), "ODataSource::connect: missing the XCompletedConnection interface on the data source!" );
+ if ( xComplConn.is() )
+ xConnection = xComplConn->connectWithCompletion( xInteractions );
+ }
+ catch( const SQLContext& e ) { aError <<= e; }
+ catch( const SQLWarning& e ) { aError <<= e; }
+ catch( const SQLException& e ) { aError <<= e; }
+ catch( const Exception& )
+ {
+ DBG_ERROR( "ODataSource::connect: caught a generic exception!" );
+ }
+
+ // ................................................................
+ // handle errors
+ if ( aError.hasValue() && _pMessageParent )
+ {
+ try
+ {
+ SQLException aException;
+ aError >>= aException;
+ if ( !aException.Message.getLength() )
+ {
+ // prepend some context info
+ SQLContext aDetailedError;
+ aDetailedError.Message = String( ModuleRes( RID_STR_NOCONNECTION ) );
+ aDetailedError.Details = String( ModuleRes( RID_STR_PLEASECHECKSETTINGS ) );
+ aDetailedError.NextException = aError;
+ // handle (aka display) the new context info
+ xInteractions->handle( new OInteractionRequest( makeAny( aDetailedError ) ) );
+ }
+ else
+ {
+ // handle (aka display) the original error
+ xInteractions->handle( new OInteractionRequest( makeAny( aException ) ) );
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_ERROR( "ODataSource::connect: caught an exception while trying to display the error!" );
+ }
+ }
+
+ if ( !xConnection.is() )
+ return sal_False;
+
+ // ................................................................
+ // success
+ m_pImpl->xConnection.reset( xConnection );
+ m_pImpl->aTables.clear();
+ m_pImpl->bTablesUpToDate = sal_False;
+
+ return sal_True;
+ }
+
+ //---------------------------------------------------------------------
+ void ODataSource::disconnect( ) SAL_THROW (( ))
+ {
+ m_pImpl->xConnection.clear();
+ m_pImpl->aTables.clear();
+ m_pImpl->bTablesUpToDate = sal_False;
+ }
+
+ //---------------------------------------------------------------------
+ sal_Bool ODataSource::isConnected( ) const SAL_THROW (( ))
+ {
+ return m_pImpl->xConnection.is();
+ }
+
+ //---------------------------------------------------------------------
+ sal_Bool ODataSource::isValid() const SAL_THROW (( ))
+ {
+ return m_pImpl && m_pImpl->xDataSource.is();
+ }
+ //---------------------------------------------------------------------
+ Reference< XPropertySet > ODataSource::getDataSource() const SAL_THROW (( ))
+ {
+ return m_pImpl ? m_pImpl->xDataSource : Reference< XPropertySet >();
+ }
+
+//.........................................................................
+} // namespace abp
+//.........................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/abpilot/datasourcehandling.hxx b/extensions/source/abpilot/datasourcehandling.hxx
new file mode 100644
index 000000000000..cce6253bb9bf
--- /dev/null
+++ b/extensions/source/abpilot/datasourcehandling.hxx
@@ -0,0 +1,217 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef EXTENSIONS_ABP_DATASOURCEHANDLING_HXX
+#define EXTENSIONS_ABP_DATASOURCEHANDLING_HXX
+
+#include <com/sun/star/uno/Reference.hxx>
+#include "abptypes.hxx"
+
+//========================================================================
+namespace com { namespace sun { namespace star {
+ namespace lang {
+ class XMultiServiceFactory;
+ }
+ namespace beans {
+ class XPropertySet;
+ }
+} } }
+
+class Window;
+
+
+//.........................................................................
+namespace abp
+{
+//.........................................................................
+
+ //=====================================================================
+ //= ODataSourceContext
+ //=====================================================================
+ struct ODataSourceContextImpl;
+ class ODataSource;
+ /// a non-UNO wrapper for the data source context
+ class ODataSourceContext
+ {
+ private:
+ ODataSourceContextImpl* m_pImpl;
+
+ public:
+ ODataSourceContext(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB
+ );
+
+ /// retrieves the names of all data sources
+ void getDataSourceNames( StringBag& _rNames ) const SAL_THROW (( ));
+
+ /// disambiguates the given name by appending auccessive numbers
+ ::rtl::OUString& disambiguate(::rtl::OUString& _rDataSourceName);
+
+ /// creates a new MORK data source
+ ODataSource createNewMORK( const ::rtl::OUString& _rName ) SAL_THROW (( ));
+
+ /// creates a new Thunderbird data source
+ ODataSource createNewThunderbird( const ::rtl::OUString& _rName ) SAL_THROW (( ));
+
+ /// creates a new Evolution local data source
+ ODataSource createNewEvolution( const ::rtl::OUString& _rName ) SAL_THROW (( ));
+
+ /// creates a new Evolution LDAP data source
+ ODataSource createNewEvolutionLdap( const ::rtl::OUString& _rName ) SAL_THROW (( ));
+
+ /// creates a new Evolution GROUPWISE data source
+ ODataSource createNewEvolutionGroupwise( const ::rtl::OUString& _rName ) SAL_THROW (( ));
+
+ /// creates a new KDE address book data source
+ ODataSource createNewKab( const ::rtl::OUString& _rName ) SAL_THROW (( ));
+
+ /// creates a new Mac OS X address book data source
+ ODataSource createNewMacab( const ::rtl::OUString& _rName ) SAL_THROW (( ));
+
+ /// creates a new LDAP data source
+ ODataSource createNewLDAP( const ::rtl::OUString& _rName ) SAL_THROW (( ));
+
+ /// creates a new Outlook data source
+ ODataSource createNewOutlook( const ::rtl::OUString& _rName ) SAL_THROW (( ));
+
+ /// creates a new Outlook express data source
+ ODataSource createNewOE( const ::rtl::OUString& _rName ) SAL_THROW (( ));
+
+ /// creates a new dBase data source
+ ODataSource createNewDBase( const ::rtl::OUString& _rName ) SAL_THROW (( ));
+ };
+
+ //=====================================================================
+ //= ODataSource
+ //=====================================================================
+ struct ODataSourceImpl;
+ struct PackageAccessControl;
+ /** a non-UNO wrapper for a data source
+ <p>This class allows to access data sources without the need to compile the respective file with
+ exception handling enabled (hopefully :).</p>
+ <p>In addition to wrapping an UNO data source, an instance of this class can handle at most
+ one valid connection, as obtained from the data source.</p>
+ */
+ class ODataSource
+ {
+ private:
+ ODataSourceImpl* m_pImpl;
+
+ public:
+ // ----------------------------------------------------------------
+ // - ctor/dtor/assignment
+ // ----------------------------------------------------------------
+ /// constructs an object which is initially invalid
+ ODataSource(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB
+ );
+
+ /// copy ctor
+ ODataSource( const ODataSource& _rSource );
+
+ /// dtor
+ ~ODataSource( );
+
+ /// assignment
+ ODataSource& operator=( const ODataSource& _rSource );
+
+ // ----------------------------------------------------------------
+ /// checks whether or not the object represents a valid data source
+ sal_Bool isValid() const SAL_THROW (( ));
+
+ // ----------------------------------------------------------------
+ /// removes the data source represented by the object from the data source context
+ void remove() SAL_THROW (( ));
+ // TODO: put this into the context class
+
+ /// returns the name of the data source
+ ::rtl::OUString
+ getName() const SAL_THROW (( ));
+
+ /// renames the data source
+ sal_Bool rename( const ::rtl::OUString& _rName ) SAL_THROW (( ));
+ // TODO: put this into the context class
+
+ // ----------------------------------------------------------------
+ // - connection handling
+ // ----------------------------------------------------------------
+ /** connects to the data source represented by this object
+ @param _pMessageParent
+ the window to use as parent for any error messages. If this is <NULL/>, no messages are displayed
+ at all.
+ @see isConnected
+ */
+ sal_Bool connect( Window* _pMessageParent ) SAL_THROW (( ));
+
+ /// returns <TRUE/> if the object has a valid connection, obtained from it's data source
+ sal_Bool isConnected( ) const SAL_THROW (( ));
+
+ /// disconnects from the data source (i.e. disposes the UNO connection hold internally)
+ void disconnect( ) SAL_THROW (( ));
+
+ /// stores the database file
+ void store() SAL_THROW (( ));
+
+ /// register the data source under the given name in the configuration
+ void registerDataSource( const ::rtl::OUString& _sRegisteredDataSourceName ) SAL_THROW (( ));
+
+ // ----------------------------------------------------------------
+ /** retrieves the tables names from the connection
+ <p>to be called when <method>isConnection</method> returns <TRUE/> only</p>
+ */
+ const StringBag& getTableNames() const SAL_THROW (( ));
+
+ /** determines whether a given table exists
+ */
+ bool hasTable( const ::rtl::OUString& _rTableName ) const;
+
+ /// return the intern data source object
+ ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > getDataSource() const SAL_THROW (( ));
+
+
+ // ----------------------------------------------------------------
+ /** set a new data source.
+ <p>Available to selected clients only</p>
+ */
+ void setDataSource(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxDS
+ ,const ::rtl::OUString& _sName
+ ,PackageAccessControl
+ );
+
+ private:
+ ODataSource( ); // never implemented
+ };
+
+//.........................................................................
+} // namespace abp
+//.........................................................................
+
+#endif // EXTENSIONS_ABP_DATASOURCEHANDLING_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/abpilot/exports.dxp b/extensions/source/abpilot/exports.dxp
new file mode 100644
index 000000000000..9630d7e06768
--- /dev/null
+++ b/extensions/source/abpilot/exports.dxp
@@ -0,0 +1,3 @@
+component_getImplementationEnvironment
+component_writeInfo
+component_getFactory
diff --git a/extensions/source/abpilot/fieldmappingimpl.cxx b/extensions/source/abpilot/fieldmappingimpl.cxx
new file mode 100644
index 000000000000..48e0073360f3
--- /dev/null
+++ b/extensions/source/abpilot/fieldmappingimpl.cxx
@@ -0,0 +1,374 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+#include "fieldmappingimpl.hxx"
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/beans/PropertyValue.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
+#include <com/sun/star/awt/XWindow.hpp>
+#include <com/sun/star/sdb/CommandType.hpp>
+#include <tools/debug.hxx>
+#include <toolkit/unohlp.hxx>
+#include <vcl/stdtext.hxx>
+#include <com/sun/star/util/AliasProgrammaticPair.hpp>
+#include "abpresid.hrc"
+#include "componentmodule.hxx"
+#include <unotools/confignode.hxx>
+#include "sal/macros.h"
+
+//.........................................................................
+namespace abp
+{
+//.........................................................................
+
+ using namespace ::utl;
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::awt;
+ using namespace ::com::sun::star::util;
+ using namespace ::com::sun::star::lang;
+ using namespace ::com::sun::star::beans;
+ using namespace ::com::sun::star::sdb;
+ using namespace ::com::sun::star::ui::dialogs;
+
+ //---------------------------------------------------------------------
+ static const ::rtl::OUString& lcl_getDriverSettingsNodeName()
+ {
+ static const ::rtl::OUString s_sDriverSettingsNodeName =
+ ::rtl::OUString::createFromAscii( "/org.openoffice.Office.DataAccess/DriverSettings/com.sun.star.comp.sdbc.MozabDriver" );
+ return s_sDriverSettingsNodeName;
+ }
+
+ //---------------------------------------------------------------------
+ static const ::rtl::OUString& lcl_getAddressBookNodeName()
+ {
+ static const ::rtl::OUString s_sAddressBookNodeName =
+ ::rtl::OUString::createFromAscii( "/org.openoffice.Office.DataAccess/AddressBook" );
+ return s_sAddressBookNodeName;
+ }
+
+ //.....................................................................
+ namespace fieldmapping
+ {
+ //.....................................................................
+
+ //-----------------------------------------------------------------
+ sal_Bool invokeDialog( const Reference< XMultiServiceFactory >& _rxORB, class Window* _pParent,
+ const Reference< XPropertySet >& _rxDataSource, AddressSettings& _rSettings ) SAL_THROW ( ( ) )
+ {
+ _rSettings.aFieldMapping.clear();
+
+ DBG_ASSERT( _rxORB.is(), "fieldmapping::invokeDialog: invalid service factory!" );
+ DBG_ASSERT( _rxDataSource.is(), "fieldmapping::invokeDialog: invalid data source!" );
+ if ( !_rxORB.is() || !_rxDataSource.is() )
+ return sal_False;
+
+ try
+ {
+ // ........................................................
+ // the parameters for creating the dialog
+ Sequence< Any > aArguments(5);
+ Any* pArguments = aArguments.getArray();
+
+ // the parent window
+ Reference< XWindow > xDialogParent = VCLUnoHelper::GetInterface( _pParent );
+ *pArguments++ <<= PropertyValue(::rtl::OUString::createFromAscii( "ParentWindow" ), -1, makeAny( xDialogParent ), PropertyState_DIRECT_VALUE);
+
+ // the data source to use
+ *pArguments++ <<= PropertyValue(::rtl::OUString::createFromAscii( "DataSource" ), -1, makeAny( _rxDataSource ), PropertyState_DIRECT_VALUE);
+ *pArguments++ <<= PropertyValue(::rtl::OUString::createFromAscii( "DataSourceName" ), -1, makeAny( (sal_Bool)_rSettings.bRegisterDataSource ? _rSettings.sRegisteredDataSourceName : _rSettings.sDataSourceName ), PropertyState_DIRECT_VALUE);
+
+ // the table to use
+ *pArguments++ <<= PropertyValue(::rtl::OUString::createFromAscii( "Command" ), -1, makeAny( _rSettings.sSelectedTable ), PropertyState_DIRECT_VALUE);
+
+ // the title
+ ::rtl::OUString sTitle = String( ModuleRes( RID_STR_FIELDDIALOGTITLE ) );
+ *pArguments++ <<= PropertyValue(::rtl::OUString::createFromAscii( "Title" ), -1, makeAny( sTitle ), PropertyState_DIRECT_VALUE);
+
+ // ........................................................
+ // create an instance of the dialog service
+ static ::rtl::OUString s_sAdressBookFieldAssignmentServiceName = ::rtl::OUString::createFromAscii( "com.sun.star.ui.AddressBookSourceDialog" );
+ Reference< XExecutableDialog > xDialog(
+ _rxORB->createInstanceWithArguments( s_sAdressBookFieldAssignmentServiceName, aArguments ),
+ UNO_QUERY
+ );
+ if ( !xDialog.is( ) )
+ {
+ ShowServiceNotAvailableError( _pParent, s_sAdressBookFieldAssignmentServiceName, sal_True );
+ return sal_False;
+ }
+
+ // execute the dialog
+ if ( xDialog->execute() )
+ {
+ // retrieve the field mapping as set by he user
+ Reference< XPropertySet > xDialogProps( xDialog, UNO_QUERY );
+
+ Sequence< AliasProgrammaticPair > aMapping;
+#ifdef DBG_UTIL
+ sal_Bool bSuccess =
+#endif
+ xDialogProps->getPropertyValue( ::rtl::OUString::createFromAscii( "FieldMapping" ) ) >>= aMapping;
+ DBG_ASSERT( bSuccess, "fieldmapping::invokeDialog: invalid property type for FieldMapping!" );
+
+ // and copy it into the map
+ const AliasProgrammaticPair* pMapping = aMapping.getConstArray();
+ const AliasProgrammaticPair* pMappingEnd = pMapping + aMapping.getLength();
+ for (;pMapping != pMappingEnd; ++pMapping)
+ _rSettings.aFieldMapping[ pMapping->ProgrammaticName ] = pMapping->Alias;
+
+ return sal_True;
+ }
+
+ }
+ catch(const Exception&)
+ {
+ DBG_ERROR("fieldmapping::invokeDialog: caught an exception while executing the dialog!");
+ }
+ return sal_False;
+ }
+
+ //-----------------------------------------------------------------
+ void defaultMapping( const Reference< XMultiServiceFactory >& _rxORB, MapString2String& _rFieldAssignment ) SAL_THROW ( ( ) )
+ {
+ _rFieldAssignment.clear();
+
+ try
+ {
+ // what we have:
+ // a) For the address data source, we need a mapping from programmatic names (1) to real column names
+ // b) The SDBC driver has a fixed set of columns, which, when returned, are named according to
+ // some configuration entries. E.g., the driver displays the field which it knows contains
+ // the first name as "First Name" - the latter string is stored in the config.
+ // For this, the driver uses programmatic names, too, but they differ from the programmatic names the
+ // template documents have.
+ // So what we need first is a mapping from programmatic names (1) to programmatic names (2)
+ const sal_Char* pMappingProgrammatics[] =
+ {
+ "FirstName", "FirstName",
+ "LastName", "LastName",
+ "Street", "HomeAddress",
+ "Zip", "HomeZipCode",
+ "City", "HomeCity",
+ "State", "HomeState",
+ "Country", "HomeCountry",
+ "PhonePriv", "HomePhone",
+ "PhoneComp", "WorkPhone",
+ "PhoneCell", "CellularNumber",
+ "Pager", "PagerNumber",
+ "Fax", "FaxNumber",
+ "EMail", "PrimaryEmail",
+ "URL", "WebPage1",
+ "Note", "Notes",
+ "Altfield1", "Custom1",
+ "Altfield2", "Custom2",
+ "Altfield3", "Custom3",
+ "Altfield4", "Custom4",
+ "Title", "JobTitle",
+ "Company", "Company",
+ "Department", "Department"
+ };
+ // (this list is not complete: both lists of programmatic names are larger in real,
+ // but this list above is the intersection)
+
+
+ // access the configuration information which the driver uses for determining it's column names
+ ::rtl::OUString sDriverAliasesNodeName = lcl_getDriverSettingsNodeName();
+ sDriverAliasesNodeName += ::rtl::OUString::createFromAscii( "/ColumnAliases" );
+
+ // create a config node for this
+ OConfigurationTreeRoot aDriverFieldAliasing = OConfigurationTreeRoot::createWithServiceFactory(
+ _rxORB, sDriverAliasesNodeName, -1, OConfigurationTreeRoot::CM_READONLY);
+
+ // loop through all programmatic pairs
+ DBG_ASSERT( 0 == SAL_N_ELEMENTS( pMappingProgrammatics ) % 2,
+ "fieldmapping::defaultMapping: invalid programmatic map!" );
+ // number of pairs
+ sal_Int32 nIntersectedProgrammatics = SAL_N_ELEMENTS( pMappingProgrammatics ) / 2;
+
+ const sal_Char** pProgrammatic = pMappingProgrammatics;
+ ::rtl::OUString sAddressProgrammatic;
+ ::rtl::OUString sDriverProgrammatic;
+ ::rtl::OUString sDriverUI;
+ for ( sal_Int32 i=0;
+ i < nIntersectedProgrammatics;
+ ++i
+ )
+ {
+ sAddressProgrammatic = ::rtl::OUString::createFromAscii( *pProgrammatic++ );
+ sDriverProgrammatic = ::rtl::OUString::createFromAscii( *pProgrammatic++ );
+
+ if ( aDriverFieldAliasing.hasByName( sDriverProgrammatic ) )
+ {
+ aDriverFieldAliasing.getNodeValue( sDriverProgrammatic ) >>= sDriverUI;
+ if ( 0 == sDriverUI.getLength() )
+ {
+ DBG_ERROR( "fieldmapping::defaultMapping: invalid driver UI column name!");
+ }
+ else
+ _rFieldAssignment[ sAddressProgrammatic ] = sDriverUI;
+ }
+ else
+ {
+ DBG_ERROR( "fieldmapping::defaultMapping: invalid driver programmatic name!" );
+ }
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_ERROR("fieldmapping::defaultMapping: code is assumed to throw no exceptions!");
+ // the config nodes we're using herein should not do this ....
+ }
+ }
+
+ //-----------------------------------------------------------------
+ void writeTemplateAddressFieldMapping( const Reference< XMultiServiceFactory >& _rxORB, const MapString2String& _rFieldAssignment ) SAL_THROW ( ( ) )
+ {
+ // want to have a non-const map for easier handling
+ MapString2String aFieldAssignment( _rFieldAssignment );
+
+ // access the configuration information which the driver uses for determining it's column names
+ const ::rtl::OUString& sAddressBookNodeName = lcl_getAddressBookNodeName();
+
+ // create a config node for this
+ OConfigurationTreeRoot aAddressBookSettings = OConfigurationTreeRoot::createWithServiceFactory(
+ _rxORB, sAddressBookNodeName, -1, OConfigurationTreeRoot::CM_UPDATABLE);
+
+ OConfigurationNode aFields = aAddressBookSettings.openNode( ::rtl::OUString::createFromAscii( "Fields" ) );
+
+ // loop through all existent fields
+ Sequence< ::rtl::OUString > aExistentFields = aFields.getNodeNames();
+ const ::rtl::OUString* pExistentFields = aExistentFields.getConstArray();
+ const ::rtl::OUString* pExistentFieldsEnd = pExistentFields + aExistentFields.getLength();
+
+ const ::rtl::OUString sProgrammaticNodeName = ::rtl::OUString::createFromAscii( "ProgrammaticFieldName" );
+ const ::rtl::OUString sAssignedNodeName = ::rtl::OUString::createFromAscii( "AssignedFieldName" );
+
+ for ( ; pExistentFields != pExistentFieldsEnd; ++pExistentFields )
+ {
+#ifdef DBG_UTIL
+ ::rtl::OUString sRedundantProgrammaticName;
+ aFields.openNode( *pExistentFields ).getNodeValue( sProgrammaticNodeName ) >>= sRedundantProgrammaticName;
+#endif
+ DBG_ASSERT( sRedundantProgrammaticName == *pExistentFields,
+ "fieldmapping::writeTemplateAddressFieldMapping: inconsistent config data!" );
+ // there should be a redundancy in the config data .... if this asserts, there isn't anymore!
+
+ // do we have a new alias for the programmatic?
+ MapString2StringIterator aPos = aFieldAssignment.find( *pExistentFields );
+ if ( aFieldAssignment.end() != aPos )
+ { // yes
+ // -> set a new value
+ OConfigurationNode aExistentField = aFields.openNode( *pExistentFields );
+ aExistentField.setNodeValue( sAssignedNodeName, makeAny( aPos->second ) );
+ // and remove the mapping entry
+ aFieldAssignment.erase( *pExistentFields );
+ }
+ else
+ { // no
+ // -> remove it
+ aFields.removeNode( *pExistentFields );
+ }
+ }
+
+ // now everything remaining in aFieldAssignment marks a mapping entry which was not present
+ // in the config before
+ for ( ConstMapString2StringIterator aNewMapping = aFieldAssignment.begin();
+ aNewMapping != aFieldAssignment.end();
+ ++aNewMapping
+ )
+ {
+ DBG_ASSERT( !aFields.hasByName( aNewMapping->first ),
+ "fieldmapping::writeTemplateAddressFieldMapping: inconsistence!" );
+ // in case the config node for the fields already has the node named <aNewMapping->first>,
+ // the entry should have been removed from aNewMapping (in the above loop)
+ OConfigurationNode aNewField = aFields.createNode( aNewMapping->first );
+ aNewField.setNodeValue( sProgrammaticNodeName, makeAny( aNewMapping->first ) );
+ aNewField.setNodeValue( sAssignedNodeName, makeAny( aNewMapping->second ) );
+ }
+
+ // commit the changes done
+ aAddressBookSettings.commit();
+ }
+
+ //.....................................................................
+ } // namespace fieldmapping
+ //.....................................................................
+
+ //.....................................................................
+ namespace addressconfig
+ {
+ //.....................................................................
+
+ //-----------------------------------------------------------------
+ void writeTemplateAddressSource( const Reference< XMultiServiceFactory >& _rxORB,
+ const ::rtl::OUString& _rDataSourceName, const ::rtl::OUString& _rTableName ) SAL_THROW ( ( ) )
+ {
+ // access the configuration information which the driver uses for determining it's column names
+ const ::rtl::OUString& sAddressBookNodeName = lcl_getAddressBookNodeName();
+
+ // create a config node for this
+ OConfigurationTreeRoot aAddressBookSettings = OConfigurationTreeRoot::createWithServiceFactory(
+ _rxORB, sAddressBookNodeName, -1, OConfigurationTreeRoot::CM_UPDATABLE);
+
+ aAddressBookSettings.setNodeValue( ::rtl::OUString::createFromAscii( "DataSourceName" ), makeAny( _rDataSourceName ) );
+ aAddressBookSettings.setNodeValue( ::rtl::OUString::createFromAscii( "Command" ), makeAny( _rTableName ) );
+ aAddressBookSettings.setNodeValue( ::rtl::OUString::createFromAscii( "CommandType" ), makeAny( (sal_Int32)CommandType::TABLE ) );
+
+ // commit the changes done
+ aAddressBookSettings.commit();
+ }
+
+ //-----------------------------------------------------------------
+ void markPilotSuccess( const Reference< XMultiServiceFactory >& _rxORB ) SAL_THROW ( ( ) )
+ {
+ // access the configuration information which the driver uses for determining it's column names
+ const ::rtl::OUString& sAddressBookNodeName = lcl_getAddressBookNodeName();
+
+ // create a config node for this
+ OConfigurationTreeRoot aAddressBookSettings = OConfigurationTreeRoot::createWithServiceFactory(
+ _rxORB, sAddressBookNodeName, -1, OConfigurationTreeRoot::CM_UPDATABLE);
+
+ // set the flag
+ aAddressBookSettings.setNodeValue( ::rtl::OUString::createFromAscii( "AutoPilotCompleted" ), makeAny( (sal_Bool)sal_True ) );
+
+ // commit the changes done
+ aAddressBookSettings.commit();
+ }
+
+ //.....................................................................
+ } // namespace addressconfig
+ //.....................................................................
+
+//.........................................................................
+} // namespace abp
+//.........................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/abpilot/fieldmappingimpl.hxx b/extensions/source/abpilot/fieldmappingimpl.hxx
new file mode 100644
index 000000000000..fe93fd01f2f9
--- /dev/null
+++ b/extensions/source/abpilot/fieldmappingimpl.hxx
@@ -0,0 +1,128 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef EXTENSIONS_ABP_FIELDMAPPINGIMPL_HXX
+#define EXTENSIONS_ABP_FIELDMAPPINGIMPL_HXX
+
+#include <rtl/ustring.hxx>
+#include "abptypes.hxx"
+#include <com/sun/star/uno/Reference.hxx>
+#include "addresssettings.hxx"
+
+namespace com { namespace sun { namespace star {
+ namespace lang {
+ class XMultiServiceFactory;
+ }
+ namespace beans {
+ class XPropertySet;
+ }
+} } }
+class Window;
+
+//.........................................................................
+namespace abp
+{
+//.........................................................................
+
+ //.....................................................................
+ namespace fieldmapping
+ {
+ //.....................................................................
+
+ //-----------------------------------------------------------------
+ /** invokes the field mapping dialog
+ @param _rxORB
+ service factory to use for creating UNO services
+ @param _pParent
+ window to use as parent for the dialog and error messages
+ @param _rSettings
+ current settings. Upon return, the field mapping member of this
+ structure will be filled with the settings the user did in the
+ field mapping dialog.
+ */
+ sal_Bool invokeDialog(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB,
+ class Window* _pParent,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxDataSource,
+ AddressSettings& _rSettings
+ ) SAL_THROW ( ( ) );
+
+ //-----------------------------------------------------------------
+ /** creates a default field mapping for usage with the address book SDBC driver
+ <p>The column names as used by the SDBC driver for address books is stored in the configuration,
+ and this function creates a mapping which uses this configuration information.</p>
+ */
+ void defaultMapping(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB,
+ MapString2String& /* [out] */ _rFieldAssignment
+ ) SAL_THROW ( ( ) );
+
+ //-----------------------------------------------------------------
+ /** writes a field mapping for the template document address source
+ */
+ void writeTemplateAddressFieldMapping(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB,
+ const MapString2String& _rFieldAssignment
+ ) SAL_THROW ( ( ) );
+
+ //.....................................................................
+ } // namespace fieldmapping
+ //.....................................................................
+
+ //.....................................................................
+ namespace addressconfig
+ {
+ //.....................................................................
+
+ //-----------------------------------------------------------------
+ /** writes the data source / table name given into the configuration, to where the template documents
+ expect it.
+ */
+ void writeTemplateAddressSource(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB,
+ const ::rtl::OUString& _rDataSourceName,
+ const ::rtl::OUString& _rTableName
+ ) SAL_THROW ( ( ) );
+
+ /** writes the configuration entry which states the the pilot has been completed successfully
+ */
+ void markPilotSuccess(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB
+ ) SAL_THROW ( ( ) );
+
+ //.....................................................................
+ } // namespace addressconfig
+ //.....................................................................
+
+//.........................................................................
+} // namespace abp
+//.........................................................................
+
+#endif // EXTENSIONS_ABP_FIELDMAPPINGIMPL_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/abpilot/fieldmappingpage.cxx b/extensions/source/abpilot/fieldmappingpage.cxx
new file mode 100644
index 000000000000..82f25f900d2d
--- /dev/null
+++ b/extensions/source/abpilot/fieldmappingpage.cxx
@@ -0,0 +1,121 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+#include "fieldmappingpage.hxx"
+#include "fieldmappingimpl.hxx"
+#include "addresssettings.hxx"
+#include "abspilot.hxx"
+
+//.........................................................................
+namespace abp
+{
+//.........................................................................
+
+ //=====================================================================
+ //= FieldMappingPage
+ //=====================================================================
+ //---------------------------------------------------------------------
+ FieldMappingPage::FieldMappingPage( OAddessBookSourcePilot* _pParent )
+ :AddressBookSourcePage( _pParent, ModuleRes( RID_PAGE_FIELDMAPPING ) )
+ ,m_aExplanation ( this, ModuleRes( FT_FIELDASSIGMENTEXPL ) )
+ ,m_aInvokeDialog ( this, ModuleRes( PB_INVOKE_FIELDS_DIALOG ) )
+ ,m_aHint ( this, ModuleRes( FT_ASSIGNEDFIELDS ) )
+ {
+ FreeResource();
+
+ m_aInvokeDialog.SetClickHdl( LINK( this, FieldMappingPage, OnInvokeDialog ) );
+
+ // check the size of the InvokeDialog button - some languages are very ... gossipy here ....
+ // 96349 - 09.01.2002 - fs@openoffice.org
+ sal_Int32 nTextWidth = m_aInvokeDialog.GetTextWidth( m_aInvokeDialog.GetText() );
+
+ sal_Int32 nBorderSpace = m_aInvokeDialog.LogicToPixel( Point( 4, 0 ), MAP_APPFONT ).X();
+ sal_Int32 nSpace = m_aInvokeDialog.GetOutputSizePixel().Width() - 2 * nBorderSpace;
+
+ if ( nSpace < nTextWidth )
+ {
+ Size aButtonSize = m_aInvokeDialog.GetSizePixel();
+ aButtonSize.Width() += nTextWidth - nSpace;
+ m_aInvokeDialog.SetSizePixel( aButtonSize );
+ }
+ }
+
+ //---------------------------------------------------------------------
+ void FieldMappingPage::ActivatePage()
+ {
+ AddressBookSourcePage::ActivatePage();
+ m_aInvokeDialog.GrabFocus();
+ }
+
+ //---------------------------------------------------------------------
+ void FieldMappingPage::DeactivatePage()
+ {
+ AddressBookSourcePage::DeactivatePage();
+ }
+
+ //---------------------------------------------------------------------
+ void FieldMappingPage::initializePage()
+ {
+ AddressBookSourcePage::initializePage();
+ implUpdateHint();
+ }
+
+ //---------------------------------------------------------------------
+ void FieldMappingPage::implUpdateHint()
+ {
+ const AddressSettings& rSettings = getSettings();
+ String sHint;
+ if ( 0 == rSettings.aFieldMapping.size() )
+ sHint = String( ModuleRes( RID_STR_NOFIELDSASSIGNED ) );
+ m_aHint.SetText( sHint );
+ }
+
+ //---------------------------------------------------------------------
+ IMPL_LINK( FieldMappingPage, OnInvokeDialog, void*, /*NOTINTERESTEDIN*/ )
+ {
+ AddressSettings& rSettings = getSettings();
+
+ // invoke the dialog doing the mapping
+ if ( fieldmapping::invokeDialog( getORB(), this, getDialog()->getDataSource().getDataSource(), rSettings ) )
+ {
+ if ( rSettings.aFieldMapping.size() )
+ getDialog()->travelNext();
+ else
+ implUpdateHint();
+ }
+
+ return 0L;
+ }
+
+//.........................................................................
+} // namespace abp
+//.........................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/abpilot/fieldmappingpage.hxx b/extensions/source/abpilot/fieldmappingpage.hxx
new file mode 100644
index 000000000000..3da50be83ad9
--- /dev/null
+++ b/extensions/source/abpilot/fieldmappingpage.hxx
@@ -0,0 +1,72 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef EXTENSIONS_ABP_FIELDMAPPINGPAGE_HXX
+#define EXTENSIONS_ABP_FIELDMAPPINGPAGE_HXX
+
+#include "abspage.hxx"
+
+//.........................................................................
+namespace abp
+{
+//.........................................................................
+
+ //=====================================================================
+ //= FieldMappingPage
+ //=====================================================================
+ class FieldMappingPage : public AddressBookSourcePage
+ {
+ protected:
+ FixedText m_aExplanation;
+ PushButton m_aInvokeDialog;
+ FixedText m_aHint;
+
+ public:
+ FieldMappingPage( OAddessBookSourcePilot* _pParent );
+
+ protected:
+ // OWizardPage overridables
+ virtual void initializePage();
+
+ // TabDialog overridables
+ virtual void ActivatePage();
+ virtual void DeactivatePage();
+
+ private:
+ DECL_LINK( OnInvokeDialog, void* );
+
+ void implUpdateHint();
+ };
+
+//.........................................................................
+} // namespace abp
+//.........................................................................
+
+#endif // EXTENSIONS_ABP_FIELDMAPPINGPAGE_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/abpilot/makefile.mk b/extensions/source/abpilot/makefile.mk
new file mode 100644
index 000000000000..19477e1b6b2b
--- /dev/null
+++ b/extensions/source/abpilot/makefile.mk
@@ -0,0 +1,106 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+PRJ=..$/..
+PRJINC=..$/inc
+
+PRJNAME=extensions
+TARGET=abp
+USE_DEFFILE=TRUE
+VISIBILITY_HIDDEN=TRUE
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : $(PRJ)$/util$/makefile.pmk
+
+# --- defines ------------------------------------------------------
+
+CDEFS+=-DCOMPMOD_NAMESPACE=abp
+CDEFS+=-DCOMPMOD_RESPREFIX=abp
+
+# --- Files --------------------------------------------------------
+
+EXCEPTIONSFILES= \
+ $(SLO)$/fieldmappingimpl.obj \
+ $(SLO)$/datasourcehandling.obj \
+ $(SLO)$/admininvokationimpl.obj \
+ $(SLO)$/unodialogabp.obj \
+ $(SLO)$/moduleabp.obj \
+ $(SLO)$/abpservices.obj \
+ $(SLO)$/typeselectionpage.obj \
+
+SLOFILES= \
+ $(SLO)$/fieldmappingpage.obj \
+ $(SLO)$/abpfinalpage.obj \
+ $(SLO)$/tableselectionpage.obj \
+ $(SLO)$/admininvokationpage.obj \
+ $(SLO)$/abspage.obj \
+ $(SLO)$/abspilot.obj \
+ $(EXCEPTIONSFILES)
+
+
+.IF "$(WITH_MOZILLA)" != "NO"
+.IF "$(SYSTEM_MOZILLA)" != "YES"
+CDEFS+=-DWITH_MOZILLA
+.ENDIF
+.ENDIF
+
+SRS1NAME=$(TARGET)
+SRC1FILES= abspilot.src
+
+RESLIB1NAME=abp
+RESLIB1IMAGES=$(PRJ)$/res
+RESLIB1SRSFILES= $(SRS)$/abp.srs
+
+SHL1TARGET= $(TARGET)$(DLLPOSTFIX)
+SHL1VERSIONMAP=$(SOLARENV)/src/component.map
+
+SHL1STDLIBS= \
+ $(VCLLIB) \
+ $(SALLIB) \
+ $(TOOLSLIB) \
+ $(CPPULIB) \
+ $(SVTOOLLIB) \
+ $(SVLLIB) \
+ $(SFXLIB) \
+ $(CPPUHELPERLIB) \
+ $(COMPHELPERLIB) \
+ $(TKLIB) \
+ $(UNOTOOLSLIB) \
+ $(SVXCORELIB) \
+ $(SVXLIB)
+
+SHL1LIBS= $(SLB)$/$(TARGET).lib
+SHL1IMPLIB= i$(TARGET)
+SHL1DEPN= $(SHL1LIBS)
+SHL1DEF= $(MISC)$/$(SHL1TARGET).def
+
+DEF1NAME= $(SHL1TARGET)
+DEF1EXPORTFILE= exports.dxp
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : target.mk
diff --git a/extensions/source/abpilot/moduleabp.cxx b/extensions/source/abpilot/moduleabp.cxx
new file mode 100644
index 000000000000..ead9753193f4
--- /dev/null
+++ b/extensions/source/abpilot/moduleabp.cxx
@@ -0,0 +1,34 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+
+#include "componentmodule.cxx"
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/abpilot/tableselectionpage.cxx b/extensions/source/abpilot/tableselectionpage.cxx
new file mode 100644
index 000000000000..5e6a2182d145
--- /dev/null
+++ b/extensions/source/abpilot/tableselectionpage.cxx
@@ -0,0 +1,135 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+#include "tableselectionpage.hxx"
+#include "abptypes.hxx"
+#include "addresssettings.hxx"
+#include "abspilot.hxx"
+#include <tools/debug.hxx>
+
+//.........................................................................
+namespace abp
+{
+//.........................................................................
+
+ //=====================================================================
+ //= TableSelectionPage
+ //=====================================================================
+ //---------------------------------------------------------------------
+ TableSelectionPage::TableSelectionPage( OAddessBookSourcePilot* _pParent )
+ :AddressBookSourcePage(_pParent, ModuleRes(RID_PAGE_TABLESELECTION_AB))
+ ,m_aLabel ( this, ModuleRes( FL_TOOMUCHTABLES ) )
+ ,m_aTableList ( this, ModuleRes( LB_TABLELIST ) )
+ {
+ FreeResource();
+
+ m_aTableList.SetSelectHdl( LINK( this, TableSelectionPage, OnTableSelected ) );
+ m_aTableList.SetDoubleClickHdl( LINK( this, TableSelectionPage, OnTableDoubleClicked ) );
+ }
+
+ //---------------------------------------------------------------------
+ void TableSelectionPage::ActivatePage()
+ {
+ AddressBookSourcePage::ActivatePage();
+
+ m_aTableList.GrabFocus();
+ }
+
+ //---------------------------------------------------------------------
+ void TableSelectionPage::DeactivatePage()
+ {
+ AddressBookSourcePage::DeactivatePage();
+ }
+
+ //---------------------------------------------------------------------
+ void TableSelectionPage::initializePage()
+ {
+ AddressBookSourcePage::initializePage();
+
+ const AddressSettings& rSettings = getSettings();
+
+ m_aTableList.Clear();
+
+ // get the table names
+ const StringBag& aTableNames = getDialog()->getDataSource().getTableNames();
+ DBG_ASSERT( aTableNames.size() > 1, "TableSelectionPage::initializePage: to be called for more than one table only!");
+ // this page should never bother the user if there is 1 or less tables.
+
+ // fill the list
+ for ( ConstStringBagIterator aTables = aTableNames.begin();
+ aTables != aTableNames.end();
+ ++aTables
+ )
+ m_aTableList.InsertEntry( *aTables );
+
+ // initially select the proper table
+ m_aTableList.SelectEntry( rSettings.sSelectedTable );
+ }
+
+ //---------------------------------------------------------------------
+ IMPL_LINK( TableSelectionPage, OnTableDoubleClicked, void*, /*NOTINTERESTEDIN*/ )
+ {
+ if ( 1 == m_aTableList.GetSelectEntryCount() )
+ getDialog()->travelNext();
+
+ return 0L;
+ }
+
+ //---------------------------------------------------------------------
+ IMPL_LINK( TableSelectionPage, OnTableSelected, void*, /*NOTINTERESTEDIN*/ )
+ {
+ updateDialogTravelUI();
+ return 0L;
+ }
+
+ //---------------------------------------------------------------------
+ sal_Bool TableSelectionPage::commitPage( ::svt::WizardTypes::CommitPageReason _eReason )
+ {
+ if (!AddressBookSourcePage::commitPage(_eReason))
+ return sal_False;
+
+ AddressSettings& rSettings = getSettings();
+ rSettings.sSelectedTable = m_aTableList.GetSelectEntry();
+
+ return sal_True;
+ }
+
+ //---------------------------------------------------------------------
+ bool TableSelectionPage::canAdvance() const
+ {
+ return AddressBookSourcePage::canAdvance()
+ && ( 0 < m_aTableList.GetSelectEntryCount() );
+ }
+
+//.........................................................................
+} // namespace abp
+//.........................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/abpilot/tableselectionpage.hxx b/extensions/source/abpilot/tableselectionpage.hxx
new file mode 100644
index 000000000000..82b2d5d57c03
--- /dev/null
+++ b/extensions/source/abpilot/tableselectionpage.hxx
@@ -0,0 +1,75 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef EXTENSIONS_ABP_TABLESELECTIONPAGE_HXX
+#define EXTENSIONS_ABP_TABLESELECTIONPAGE_HXX
+
+#include "abspage.hxx"
+#include <vcl/lstbox.hxx>
+
+//.........................................................................
+namespace abp
+{
+//.........................................................................
+
+ //=====================================================================
+ //= TableSelectionPage
+ //=====================================================================
+ class TableSelectionPage : public AddressBookSourcePage
+ {
+ protected:
+ FixedText m_aLabel;
+ ListBox m_aTableList;
+
+ public:
+ TableSelectionPage( OAddessBookSourcePilot* _pParent );
+
+ protected:
+ // OWizardPage overridables
+ virtual void initializePage();
+ virtual sal_Bool commitPage( ::svt::WizardTypes::CommitPageReason _eReason );
+
+ // TabDialog overridables
+ virtual void ActivatePage();
+ virtual void DeactivatePage();
+
+ // OImportPage overridables
+ virtual bool canAdvance() const;
+
+ private:
+ DECL_LINK( OnTableSelected, void* );
+ DECL_LINK( OnTableDoubleClicked, void* );
+ };
+
+//.........................................................................
+} // namespace abp
+//.........................................................................
+
+#endif // EXTENSIONS_ABP_TABLESELECTIONPAGE_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/abpilot/typeselectionpage.cxx b/extensions/source/abpilot/typeselectionpage.cxx
new file mode 100644
index 000000000000..f78878f0419c
--- /dev/null
+++ b/extensions/source/abpilot/typeselectionpage.cxx
@@ -0,0 +1,248 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+#include "typeselectionpage.hxx"
+#include "addresssettings.hxx"
+#include "abspilot.hxx"
+#include <vcl/msgbox.hxx>
+#include <com/sun/star/sdbc/XDriverAccess.hpp>
+
+//.........................................................................
+namespace abp
+{
+//.........................................................................
+
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::sdbc;
+
+ //=====================================================================
+ //= TypeSelectionPage
+ //=====================================================================
+ //---------------------------------------------------------------------
+ TypeSelectionPage::TypeSelectionPage( OAddessBookSourcePilot* _pParent )
+ :AddressBookSourcePage(_pParent, ModuleRes(RID_PAGE_SELECTABTYPE))
+ ,m_aHint (this, ModuleRes(FT_TYPE_HINTS))
+ ,m_aTypeSep (this, ModuleRes(FL_TYPE))
+ ,m_aEvolution (this, ModuleRes(RB_EVOLUTION))
+ ,m_aEvolutionGroupwise (this, ModuleRes(RB_EVOLUTION_GROUPWISE))
+ ,m_aEvolutionLdap (this, ModuleRes(RB_EVOLUTION_LDAP))
+ ,m_aMORK (this, ModuleRes(RB_MORK))
+ ,m_aThunderbird (this, ModuleRes(RB_THUNDERBIRD))
+ ,m_aKab (this, ModuleRes(RB_KAB))
+ ,m_aMacab (this, ModuleRes(RB_MACAB))
+ ,m_aLDAP (this, ModuleRes(RB_LDAP))
+ ,m_aOutlook (this, ModuleRes(RB_OUTLOOK))
+ ,m_aOE (this, ModuleRes(RB_OUTLOOKEXPRESS))
+ ,m_aOther (this, ModuleRes(RB_OTHER))
+ {
+ FreeResource();
+
+ Point aTopLeft( LogicToPixel( Point( 15, 68 ), MAP_APPFONT ) );
+ Size aItemSize( LogicToPixel( Size( 0, 8 ), MAP_APPFONT ) );
+ aItemSize.Width() = GetOutputSizePixel().Width() - 30;
+
+ bool bWithMozilla = true, bUnx = true;
+ bool bHaveEvolution = true, bHaveKab = true;
+ bool bHaveMacab = true;
+
+#if !defined WITH_MOZILLA || defined MACOSX
+ bWithMozilla = false;
+#endif
+#ifndef UNX
+ bUnx = false;
+ bHaveEvolution = false;
+ bHaveKab = false;
+ bHaveMacab = false;
+#else
+ Reference< XDriverAccess> xManager(_pParent->getORB()->createInstance(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sdbc.DriverManager"))), UNO_QUERY);
+
+ // check whether Evolution is available
+ Reference< XDriver > xDriver( xManager->getDriverByURL(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("sdbc:address:evolution:local"))) );
+ if ( !xDriver.is() )
+ bHaveEvolution = false;
+
+ // check whether KDE address book is available
+ xDriver = xManager->getDriverByURL(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("sdbc:address:kab")));
+ if ( !xDriver.is() )
+ bHaveKab = false;
+
+ // check whether Mac OS X address book is available
+ xDriver = xManager->getDriverByURL(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("sdbc:address:macab")));
+ if ( !xDriver.is() )
+ bHaveMacab = false;
+#endif
+
+ // Items are displayed in list order
+ m_aAllTypes.push_back( ButtonItem( &m_aEvolution, AST_EVOLUTION, bHaveEvolution ) );
+ m_aAllTypes.push_back( ButtonItem( &m_aEvolutionGroupwise, AST_EVOLUTION_GROUPWISE, bHaveEvolution ) );
+ m_aAllTypes.push_back( ButtonItem( &m_aEvolutionLdap, AST_EVOLUTION_LDAP, bHaveEvolution ) );
+ m_aAllTypes.push_back( ButtonItem( &m_aMORK, AST_MORK, bWithMozilla ) );
+ m_aAllTypes.push_back( ButtonItem( &m_aThunderbird, AST_THUNDERBIRD, bWithMozilla ) );
+ m_aAllTypes.push_back( ButtonItem( &m_aKab, AST_KAB, bHaveKab ) );
+ m_aAllTypes.push_back( ButtonItem( &m_aMacab, AST_MACAB, bHaveMacab ) );
+ m_aAllTypes.push_back( ButtonItem( &m_aLDAP, AST_LDAP, bWithMozilla ) );
+ m_aAllTypes.push_back( ButtonItem( &m_aOutlook, AST_OUTLOOK, bWithMozilla && !bUnx ) );
+ m_aAllTypes.push_back( ButtonItem( &m_aOE, AST_OE, bWithMozilla && !bUnx ) );
+ m_aAllTypes.push_back( ButtonItem( &m_aOther, AST_OTHER, true ) );
+
+ bool bFirstVisible = true;
+ Link aTypeSelectionHandler = LINK(this, TypeSelectionPage, OnTypeSelected );
+ const Size aSpacing( LogicToPixel( Size( 0, 3 ), MAP_APPFONT ) );
+ for ( ::std::vector< ButtonItem >::const_iterator loop = m_aAllTypes.begin();
+ loop != m_aAllTypes.end(); ++loop )
+ {
+ ButtonItem aItem = *loop;
+ if (!aItem.m_bVisible)
+ aItem.m_pItem->Hide();
+ else
+ {
+ aItem.m_pItem->SetPosPixel( aTopLeft );
+ aTopLeft.Y() += aItemSize.Height() + aSpacing.Height();
+ aItem.m_pItem->SetClickHdl( aTypeSelectionHandler );
+ aItem.m_pItem->Show();
+
+ if ( bFirstVisible )
+ {
+ aItem.m_pItem->SetStyle( aItem.m_pItem->GetStyle() | WB_GROUP );
+ bFirstVisible = false;
+ }
+ }
+ }
+ }
+
+ //---------------------------------------------------------------------
+ TypeSelectionPage::~TypeSelectionPage()
+ {
+ for ( ::std::vector< ButtonItem >::iterator loop = m_aAllTypes.begin();
+ loop != m_aAllTypes.end(); ++loop )
+ {
+ loop->m_bVisible = false;
+ }
+ }
+
+ //---------------------------------------------------------------------
+ void TypeSelectionPage::ActivatePage()
+ {
+ AddressBookSourcePage::ActivatePage();
+
+ for ( ::std::vector< ButtonItem >::const_iterator loop = m_aAllTypes.begin();
+ loop != m_aAllTypes.end(); ++loop )
+ {
+ const ButtonItem& rItem = (*loop);
+ if( rItem.m_pItem->IsChecked() && rItem.m_bVisible )
+ {
+ rItem.m_pItem->GrabFocus();
+ break;
+ }
+ }
+
+ getDialog()->enableButtons(WZB_PREVIOUS, sal_False);
+ }
+
+ //---------------------------------------------------------------------
+ void TypeSelectionPage::DeactivatePage()
+ {
+ AddressBookSourcePage::DeactivatePage();
+ getDialog()->enableButtons(WZB_PREVIOUS, sal_True);
+ }
+
+ //---------------------------------------------------------------------
+ void TypeSelectionPage::selectType( AddressSourceType _eType )
+ {
+ for ( ::std::vector< ButtonItem >::const_iterator loop = m_aAllTypes.begin();
+ loop != m_aAllTypes.end(); ++loop )
+ {
+ ButtonItem aItem = (*loop);
+ aItem.m_pItem->Check( _eType == aItem.m_eType );
+ }
+ }
+
+ //---------------------------------------------------------------------
+ AddressSourceType TypeSelectionPage::getSelectedType() const
+ {
+ for ( ::std::vector< ButtonItem >::const_iterator loop = m_aAllTypes.begin();
+ loop != m_aAllTypes.end(); ++loop )
+ {
+ ButtonItem aItem = (*loop);
+ if ( aItem.m_pItem->IsChecked() )
+ return aItem.m_eType;
+ }
+
+ return AST_INVALID;
+ }
+
+ //---------------------------------------------------------------------
+ void TypeSelectionPage::initializePage()
+ {
+ AddressBookSourcePage::initializePage();
+
+ const AddressSettings& rSettings = getSettings();
+ selectType(rSettings.eType);
+ }
+
+ //---------------------------------------------------------------------
+ sal_Bool TypeSelectionPage::commitPage( ::svt::WizardTypes::CommitPageReason _eReason )
+ {
+ if (!AddressBookSourcePage::commitPage(_eReason))
+ return sal_False;
+
+ if (AST_INVALID == getSelectedType( ))
+ {
+ ErrorBox aError(this, ModuleRes(RID_ERR_NEEDTYPESELECTION));
+ aError.Execute();
+ return sal_False;
+ }
+
+ AddressSettings& rSettings = getSettings();
+ rSettings.eType = getSelectedType();
+
+ return sal_True;
+ }
+
+ //---------------------------------------------------------------------
+ bool TypeSelectionPage::canAdvance() const
+ {
+ return AddressBookSourcePage::canAdvance()
+ && (AST_INVALID != getSelectedType());
+ }
+
+ //---------------------------------------------------------------------
+ IMPL_LINK( TypeSelectionPage, OnTypeSelected, void*, /*NOTINTERESTEDIN*/ )
+ {
+ getDialog()->typeSelectionChanged( getSelectedType() );
+ updateDialogTravelUI();
+ return 0L;
+ }
+
+//.........................................................................
+} // namespace abp
+//.........................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/abpilot/typeselectionpage.hxx b/extensions/source/abpilot/typeselectionpage.hxx
new file mode 100644
index 000000000000..37e0a8beb6da
--- /dev/null
+++ b/extensions/source/abpilot/typeselectionpage.hxx
@@ -0,0 +1,108 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef EXTENSIONS_ABP_TYPESELECTIONPAGE_HXX
+#define EXTENSIONS_ABP_TYPESELECTIONPAGE_HXX
+
+#include "abspage.hxx"
+#include "addresssettings.hxx"
+#include <vcl/edit.hxx>
+
+//.........................................................................
+namespace abp
+{
+//.........................................................................
+
+ //=====================================================================
+ //= TypeSelectionPage
+ //=====================================================================
+ class TypeSelectionPage : public AddressBookSourcePage
+ {
+ protected:
+ FixedText m_aHint;
+ FixedLine m_aTypeSep;
+ RadioButton m_aEvolution;
+ RadioButton m_aEvolutionGroupwise;
+ RadioButton m_aEvolutionLdap;
+ RadioButton m_aMORK;
+ RadioButton m_aThunderbird;
+ RadioButton m_aKab;
+ RadioButton m_aMacab;
+ RadioButton m_aLDAP;
+ RadioButton m_aOutlook;
+ RadioButton m_aOE;
+ RadioButton m_aOther;
+
+ struct ButtonItem {
+ RadioButton *m_pItem;
+ AddressSourceType m_eType;
+ bool m_bVisible;
+
+ ButtonItem( RadioButton *pItem,
+ AddressSourceType eType,
+ bool bVisible ) :
+ m_pItem( pItem ),
+ m_eType( eType ),
+ m_bVisible( bVisible )
+ {}
+ };
+
+ ::std::vector< ButtonItem > m_aAllTypes;
+
+ public:
+ TypeSelectionPage( OAddessBookSourcePilot* _pParent );
+ ~TypeSelectionPage();
+
+ // retrieves the currently selected type
+ AddressSourceType getSelectedType() const;
+
+ protected:
+ // OWizardPage overridables
+ virtual void initializePage();
+ virtual sal_Bool commitPage( ::svt::WizardTypes::CommitPageReason _eReason );
+
+ // TabDialog overridables
+ virtual void ActivatePage();
+ virtual void DeactivatePage();
+
+ // OImportPage overridables
+ virtual bool canAdvance() const;
+
+ private:
+ DECL_LINK( OnTypeSelected, void* );
+
+ void selectType( AddressSourceType _eType );
+ };
+
+//.........................................................................
+} // namespace abp
+//.........................................................................
+
+#endif // EXTENSIONS_ABP_TYPESELECTIONPAGE_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/abpilot/unodialogabp.cxx b/extensions/source/abpilot/unodialogabp.cxx
new file mode 100644
index 000000000000..0c58f088a665
--- /dev/null
+++ b/extensions/source/abpilot/unodialogabp.cxx
@@ -0,0 +1,198 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+#include "unodialogabp.hxx"
+#include <cppuhelper/typeprovider.hxx>
+#include "abspilot.hxx"
+#include <comphelper/sequence.hxx>
+#include <vcl/msgbox.hxx>
+
+extern "C" void SAL_CALL createRegistryInfo_OABSPilotUno()
+{
+ static ::abp::OMultiInstanceAutoRegistration< ::abp::OABSPilotUno > aAutoRegistration;
+}
+
+#define PROPERTY_ID_DATASOURCENAME 3
+//.........................................................................
+namespace abp
+{
+//.........................................................................
+
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::lang;
+ using namespace ::com::sun::star::beans;
+ using namespace ::com::sun::star::ui::dialogs;
+
+ //=====================================================================
+ //= OABSPilotUno
+ //=====================================================================
+ //---------------------------------------------------------------------
+ OABSPilotUno::OABSPilotUno(const Reference< XMultiServiceFactory >& _rxORB)
+ :OGenericUnoDialog(_rxORB)
+ {
+ registerProperty( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DataSourceName")), PROPERTY_ID_DATASOURCENAME, PropertyAttribute::READONLY ,
+ &m_sDataSourceName, ::getCppuType( &m_sDataSourceName ) );
+ }
+
+ //--------------------------------------------------------------------------
+ Any SAL_CALL OABSPilotUno::queryInterface( const Type& aType ) throw (RuntimeException)
+ {
+ Any aReturn = OABSPilotUno_DBase::queryInterface( aType );
+ return aReturn.hasValue() ? aReturn : OABSPilotUno_JBase::queryInterface( aType );
+ }
+
+ //--------------------------------------------------------------------------
+ void SAL_CALL OABSPilotUno::acquire( ) throw ()
+ {
+ OABSPilotUno_DBase::acquire();
+ }
+
+ //--------------------------------------------------------------------------
+ void SAL_CALL OABSPilotUno::release( ) throw ()
+ {
+ OABSPilotUno_DBase::release();
+ }
+
+ //---------------------------------------------------------------------
+ Sequence< Type > SAL_CALL OABSPilotUno::getTypes( ) throw (RuntimeException)
+ {
+ return ::comphelper::concatSequences(
+ OABSPilotUno_DBase::getTypes(),
+ OABSPilotUno_JBase::getTypes()
+ );
+ }
+
+ //---------------------------------------------------------------------
+ Sequence<sal_Int8> SAL_CALL OABSPilotUno::getImplementationId( ) throw(RuntimeException)
+ {
+ static ::cppu::OImplementationId* s_pId;
+ if ( !s_pId )
+ {
+ ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
+ if ( !s_pId )
+ {
+ static ::cppu::OImplementationId s_aId;
+ s_pId = &s_aId;
+ }
+ }
+ return s_pId->getImplementationId();
+ }
+
+ //---------------------------------------------------------------------
+ Reference< XInterface > SAL_CALL OABSPilotUno::Create(const Reference< XMultiServiceFactory >& _rxFactory)
+ {
+ return *(new OABSPilotUno(_rxFactory));
+ }
+
+ //---------------------------------------------------------------------
+ ::rtl::OUString SAL_CALL OABSPilotUno::getImplementationName() throw(RuntimeException)
+ {
+ return getImplementationName_Static();
+ }
+
+ //---------------------------------------------------------------------
+ ::rtl::OUString OABSPilotUno::getImplementationName_Static() throw(RuntimeException)
+ {
+ return ::rtl::OUString::createFromAscii("org.openoffice.comp.abp.OAddressBookSourcePilot");
+ }
+
+ //---------------------------------------------------------------------
+ ::comphelper::StringSequence SAL_CALL OABSPilotUno::getSupportedServiceNames() throw(RuntimeException)
+ {
+ return getSupportedServiceNames_Static();
+ }
+
+ //---------------------------------------------------------------------
+ ::comphelper::StringSequence OABSPilotUno::getSupportedServiceNames_Static() throw(RuntimeException)
+ {
+ ::comphelper::StringSequence aSupported(1);
+ aSupported.getArray()[0] = ::rtl::OUString::createFromAscii("com.sun.star.ui.dialogs.AddressBookSourcePilot");
+ return aSupported;
+ }
+
+ //---------------------------------------------------------------------
+ Reference<XPropertySetInfo> SAL_CALL OABSPilotUno::getPropertySetInfo() throw(RuntimeException)
+ {
+ Reference<XPropertySetInfo> xInfo( createPropertySetInfo( getInfoHelper() ) );
+ return xInfo;
+ }
+
+ //---------------------------------------------------------------------
+ ::cppu::IPropertyArrayHelper& OABSPilotUno::getInfoHelper()
+ {
+ return *const_cast<OABSPilotUno*>(this)->getArrayHelper();
+ }
+
+ //--------------------------------------------------------------------------
+ ::cppu::IPropertyArrayHelper* OABSPilotUno::createArrayHelper( ) const
+ {
+ Sequence< Property > aProps;
+ describeProperties(aProps);
+ return new ::cppu::OPropertyArrayHelper(aProps);
+ }
+
+ //--------------------------------------------------------------------------
+ Dialog* OABSPilotUno::createDialog(Window* _pParent)
+ {
+ return new OAddessBookSourcePilot(_pParent, m_aContext.getLegacyServiceFactory());
+ }
+
+ //--------------------------------------------------------------------------
+ Any SAL_CALL OABSPilotUno::execute( const Sequence< NamedValue >& /*lArgs*/ ) throw (IllegalArgumentException, Exception, RuntimeException)
+ {
+ // not interested in the context, not interested in the args
+ // -> call the execute method of the XExecutableDialog
+ static_cast< XExecutableDialog* >( this )->execute();
+
+ // result interest not really ...
+ // We show this dialog one times only!
+ // User has one chance to accept it or not.
+ // (or he can start it again by using wizard-menu!)
+ // So we should deregister it on our general job execution service by using right protocol parameters.
+ ::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue > lProtocol(1);
+ lProtocol[0].Name = ::rtl::OUString::createFromAscii("Deactivate");
+ lProtocol[0].Value <<= sal_True;
+ return makeAny( lProtocol );
+ }
+ // -----------------------------------------------------------------------------
+ void OABSPilotUno::executedDialog(sal_Int16 _nExecutionResult)
+ {
+ if ( _nExecutionResult == RET_OK )
+ {
+ const AddressSettings& aSettings = static_cast<OAddessBookSourcePilot*>(m_pDialog)->getSettings();
+ m_sDataSourceName = aSettings.bRegisterDataSource ? aSettings.sRegisteredDataSourceName : aSettings.sDataSourceName;
+ }
+ }
+
+//.........................................................................
+} // namespace abp
+//.........................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/abpilot/unodialogabp.hxx b/extensions/source/abpilot/unodialogabp.hxx
new file mode 100644
index 000000000000..ab56106b5746
--- /dev/null
+++ b/extensions/source/abpilot/unodialogabp.hxx
@@ -0,0 +1,103 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef EXTENSIONS_ABP_UNODIALOG_HXX
+#define EXTENSIONS_ABP_UNODIALOG_HXX
+
+#include <svtools/genericunodialog.hxx>
+#include <comphelper/proparrhlp.hxx>
+#include "componentmodule.hxx"
+#include <com/sun/star/task/XJob.hpp>
+#include <cppuhelper/implbase1.hxx>
+
+//.........................................................................
+namespace abp
+{
+//.........................................................................
+
+ //=====================================================================
+ //= OABSPilotUno
+ //=====================================================================
+ class OABSPilotUno;
+ typedef ::svt::OGenericUnoDialog OABSPilotUno_DBase;
+ typedef ::cppu::ImplHelper1< ::com::sun::star::task::XJob > OABSPilotUno_JBase;
+ typedef ::comphelper::OPropertyArrayUsageHelper< OABSPilotUno > OABSPilotUno_PBase;
+ /// the UNO wrapper for the address book source pilot
+ class OABSPilotUno
+ :public OABSPilotUno_DBase
+ ,public OABSPilotUno_JBase
+ ,public OABSPilotUno_PBase
+ ,public OModuleResourceClient
+ {
+ ::rtl::OUString m_sDataSourceName;
+ OABSPilotUno(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB);
+
+ public:
+ // XInterface (disambiguation)
+ virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type& aType ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL acquire( ) throw ();
+ virtual void SAL_CALL release( ) throw ();
+
+ // 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 ::rtl::OUString SAL_CALL getImplementationName() throw(::com::sun::star::uno::RuntimeException);
+ virtual ::comphelper::StringSequence SAL_CALL getSupportedServiceNames() throw(::com::sun::star::uno::RuntimeException);
+
+ // XServiceInfo - static methods
+ static ::com::sun::star::uno::Sequence< ::rtl::OUString > getSupportedServiceNames_Static(void) throw( ::com::sun::star::uno::RuntimeException );
+ static ::rtl::OUString getImplementationName_Static(void) throw( ::com::sun::star::uno::RuntimeException );
+ static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >
+ SAL_CALL Create(const ::com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory >&);
+
+ // XPropertySet
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo> SAL_CALL getPropertySetInfo() throw(::com::sun::star::uno::RuntimeException);
+ virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper();
+
+ // OPropertyArrayUsageHelper
+ virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const;
+
+ // XJob
+ virtual ::com::sun::star::uno::Any SAL_CALL execute( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue >& lArgs ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
+
+ using OABSPilotUno_DBase::execute;
+ protected:
+ // OGenericUnoDialog overridables
+ virtual Dialog* createDialog(Window* _pParent);
+ virtual void executedDialog(sal_Int16 _nExecutionResult);
+ };
+
+//.........................................................................
+} // namespace abp
+//.........................................................................
+
+#endif // EXTENSIONS_ABP_UNODIALOG_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/activex/main/README.txt b/extensions/source/activex/main/README.txt
new file mode 100644
index 000000000000..9d647987aaa7
--- /dev/null
+++ b/extensions/source/activex/main/README.txt
@@ -0,0 +1,33 @@
+ Description.
+
+The StarOffice ActiveX control shows an example of access to UNO through COM technology.
+It requires a properly installed StarOffice version 6.0/6.1 or OpenOffice 1.0.
+This is a Lite ActiveX control so it can be used only in containers that
+allows to use such controls.
+
+Pressing to any link to staroffice document should activate the control.
+So the document will be opened in ReadOnly mode.
+
+Also it can be activated with an <OBJECT> tag from a html-page.
+Without any parameters for an object tag a new writer document will be
+opened for editing. Possible parameters are
+ src - full URL to the file that should be edited/viewed;
+ it can contain "private:factory/..." URLs to open new documents
+ for edit, for example "private:factory/swriter"
+ readonly - the default value is "true", in case it is set to any other
+ value the document is opened for editing
+
+As any ActiveX control this one should be registered.
+To let MSIE register it itself the "CODEBASE" parameter
+for the "OBJECT" tag should be specified
+with an URL to the library "so_activex.dll".
+The example of registration with "OBJECT" tag is in example.html.
+
+Also it can be done using regsvr32 application.
+To do it please write
+<Path to Windows installation>\System32\regsvr32 so_activex.dll
+
+To unregister the control please use /u option:
+<Path to Windows installation>\system32\regsvr32 so_activex.dll /u
+
+
diff --git a/extensions/source/activex/main/SOActionsApproval.cpp b/extensions/source/activex/main/SOActionsApproval.cpp
new file mode 100644
index 000000000000..fd4abb170959
--- /dev/null
+++ b/extensions/source/activex/main/SOActionsApproval.cpp
@@ -0,0 +1,31 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+// SOActionsApproval.cpp : Implementation of CHelpApp and DLL registration.
+
+#include "stdafx2.h"
+
+#include "so_activex.h"
+#include "SOActionsApproval.h"
+
+/////////////////////////////////////////////////////////////////////////////
+//
+
+STDMETHODIMP SOActionsApproval::InterfaceSupportsErrorInfo(REFIID riid)
+{
+ static const IID* arr[] =
+ {
+ &IID_ISOActionsApproval,
+ };
+
+ for (int i=0;i<sizeof(arr)/sizeof(arr[0]);i++)
+ {
+#if defined(_MSC_VER) && (_MSC_VER >= 1300)
+ if (InlineIsEqualGUID(*arr[i],riid))
+#else
+ if (::ATL::InlineIsEqualGUID(*arr[i],riid))
+#endif
+ return S_OK;
+ }
+ return S_FALSE;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/activex/main/SOActionsApproval.h b/extensions/source/activex/main/SOActionsApproval.h
new file mode 100644
index 000000000000..097d7b97a29f
--- /dev/null
+++ b/extensions/source/activex/main/SOActionsApproval.h
@@ -0,0 +1,83 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+// SOActionsApproval.h: Definition of the SOActionsApproval class
+//
+//////////////////////////////////////////////////////////////////////
+
+#if !defined __SODOCUMENTEVENTLISTENER_H_
+#define __SODOCUMENTEVENTLISTENER_H_
+
+#if _MSC_VER > 1000
+#pragma once
+#endif // _MSC_VER > 1000
+
+#include "resource.h" // main symbols
+#include <ExDispID.h>
+#include <ExDisp.h>
+#include <shlguid.h>
+
+#if defined(_MSC_VER) && (_MSC_VER >= 1300)
+#undef _DEBUG
+#endif
+
+#include <atlctl.h>
+
+#include "so_activex.h"
+
+/////////////////////////////////////////////////////////////////////////////
+// SOActionsApproval
+
+class SOActionsApproval :
+ public IDispatchImpl<ISOActionsApproval, &IID_ISOActionsApproval, &LIBID_SO_ACTIVEXLib>,
+ public ISupportErrorInfo,
+ public CComObjectRoot,
+ public CComCoClass<SOActionsApproval,&CLSID_SOActionsApproval>
+{
+public:
+ SOActionsApproval() {}
+ virtual ~SOActionsApproval() {}
+
+BEGIN_COM_MAP(SOActionsApproval)
+ COM_INTERFACE_ENTRY(IDispatch)
+ COM_INTERFACE_ENTRY(ISOActionsApproval)
+ COM_INTERFACE_ENTRY(ISupportErrorInfo)
+END_COM_MAP()
+DECLARE_NOT_AGGREGATABLE(SOActionsApproval)
+// Remove the comment from the line above if you don't want your object to
+// support aggregation.
+
+DECLARE_REGISTRY_RESOURCEID(IDR_SODOCUMENTEVENTLISTENER)
+
+// ISupportsErrorInfo
+ STDMETHOD(InterfaceSupportsErrorInfo)(REFIID riid);
+
+// ISOActionsApproval
+ virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE approveAction(
+ /* [in] */ long nActionID,
+ /* [retval][out] */ boolean *pbApproval)
+ {
+ // only PreventClose is approved
+ USES_CONVERSION;
+ *pbApproval = ( nActionID == 1 );
+
+ return S_OK;
+ }
+
+ virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_Bridge_implementedInterfaces(
+ /* [retval][out] */ SAFEARRAY __RPC_FAR * __RPC_FAR *pVal)
+ {
+ *pVal = SafeArrayCreateVector( VT_BSTR, 0, 1 );
+
+ if( !*pVal )
+ return E_FAIL;
+
+ long ix = 0;
+ CComBSTR aInterface( OLESTR( "com.sun.star.embed.XActionsApproval" ) );
+ SafeArrayPutElement( *pVal, &ix, aInterface );
+
+ return S_OK;
+ }
+};
+
+#endif // __SODOCUMENTEVENTLISTENER_H_
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/activex/main/SOActionsApproval.rgs b/extensions/source/activex/main/SOActionsApproval.rgs
new file mode 100644
index 000000000000..543320813948
--- /dev/null
+++ b/extensions/source/activex/main/SOActionsApproval.rgs
@@ -0,0 +1,24 @@
+HKCR
+{
+9F3697AC-7A18-4335-AF0A-65FAC2C35CC1
+ so_activex.SOActionsApproval.1 = s 'SOActionsApproval Class'
+ {
+ CLSID = s '{9F3697AC-7A18-4335-AF0A-65FAC2C35CC1}'
+ }
+ so_activex.SOActionsApproval = s 'SOActionsApproval Class'
+ {
+ CLSID = s '{9F3697AC-7A18-4335-AF0A-65FAC2C35CC1}'
+ }
+ NoRemove CLSID
+ {
+ ForceRemove {9F3697AC-7A18-4335-AF0A-65FAC2C35CC1} = s 'SOActionsApproval Class'
+ {
+ ProgID = s 'so_activex.SOActionsApproval.1'
+ VersionIndependentProgID = s 'so_activex.SOActionsApproval'
+ InprocServer32 = s '%MODULE%'
+ {
+ val ThreadingModel = s 'both'
+ }
+ }
+ }
+}
diff --git a/extensions/source/activex/main/SOActiveX.cpp b/extensions/source/activex/main/SOActiveX.cpp
new file mode 100644
index 000000000000..3468337a0e80
--- /dev/null
+++ b/extensions/source/activex/main/SOActiveX.cpp
@@ -0,0 +1,1153 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+// SOActiveX.cpp : Implementation of CSOActiveX
+
+#pragma warning (disable:4505)
+ // permanently suppress "unreferenced local function has been removed" warning
+
+#pragma warning (push,1)
+#pragma warning (disable:4265)
+
+#include "stdafx2.h"
+#include "so_activex.h"
+#include "SOActiveX.h"
+#include "SOComWindowPeer.h"
+#include "SODispatchInterceptor.h"
+#include "SOActionsApproval.h"
+
+#pragma warning (pop)
+
+#define STAROFFICE_WINDOWCLASS "SOParentWindow"
+
+
+/////////////////////////////////////////////////////////////////////////////
+
+void OutputError_Impl( HWND hw, HRESULT ErrorCode )
+{
+ void* sMessage;
+ FormatMessageA(
+ FORMAT_MESSAGE_ALLOCATE_BUFFER |
+ FORMAT_MESSAGE_FROM_SYSTEM,
+ NULL,
+ ErrorCode,
+ MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
+ (LPTSTR) &sMessage,
+ 0,
+ NULL
+ );
+ ::MessageBoxA( hw, (LPCTSTR)sMessage, NULL, MB_OK | MB_ICONINFORMATION );
+ LocalFree( sMessage );
+}
+
+HRESULT ExecuteFunc( IDispatch* idispUnoObject,
+ OLECHAR* sFuncName,
+ CComVariant* params,
+ unsigned int count,
+ CComVariant* pResult )
+{
+ if( !idispUnoObject )
+ return E_FAIL;
+
+ DISPID id;
+ HRESULT hr = idispUnoObject->GetIDsOfNames( IID_NULL, &sFuncName, 1, LOCALE_USER_DEFAULT, &id);
+ if( !SUCCEEDED( hr ) ) return hr;
+
+ DISPPARAMS dispparams= { params, 0, count, 0};
+
+ // DEBUG
+ EXCEPINFO myInfo;
+ hr = idispUnoObject->Invoke( id, IID_NULL,LOCALE_USER_DEFAULT, DISPATCH_METHOD,
+ &dispparams, pResult, &myInfo, 0);
+
+ // for debugging purposes
+ // USES_CONVERSION;
+ // if ( !SUCCEEDED( hr ) )
+ // ::MessageBox( NULL, OLE2A( myInfo.bstrDescription ), OLE2A( myInfo.bstrSource ), MB_OK | MB_ICONINFORMATION );
+
+ return hr;
+}
+
+HRESULT GetIDispByFunc( IDispatch* idispUnoObject,
+ OLECHAR* sFuncName,
+ CComVariant* params,
+ unsigned int count,
+ CComPtr<IDispatch>& pdispResult )
+{
+ if( !idispUnoObject )
+ return E_FAIL;
+
+ CComVariant result;
+ HRESULT hr = ExecuteFunc( idispUnoObject, sFuncName, params, count, &result );
+ if( !SUCCEEDED( hr ) ) return hr;
+
+ if( result.vt != VT_DISPATCH || result.pdispVal == NULL )
+ return E_FAIL;
+
+ pdispResult = CComPtr<IDispatch>( result.pdispVal );
+
+ return S_OK;
+}
+
+HRESULT PutPropertiesToIDisp( IDispatch* pdispObject,
+ OLECHAR** sMemberNames,
+ CComVariant* pVariant,
+ unsigned int count )
+{
+ for( unsigned int ind = 0; ind < count; ind++ )
+ {
+ DISPID id;
+ HRESULT hr = pdispObject->GetIDsOfNames( IID_NULL, &sMemberNames[ind], 1, LOCALE_USER_DEFAULT, &id );
+ if( !SUCCEEDED( hr ) ) return hr;
+
+ hr = CComDispatchDriver::PutProperty( pdispObject, id, &pVariant[ind] );
+ if( !SUCCEEDED( hr ) ) return hr;
+ }
+
+ return S_OK;
+}
+
+HRESULT GetPropertiesFromIDisp( IDispatch* pdispObject,
+ OLECHAR** sMemberNames,
+ CComVariant* pVariant,
+ unsigned int count )
+{
+ for( unsigned int ind = 0; ind < count; ind++ )
+ {
+ DISPID id;
+ HRESULT hr = pdispObject->GetIDsOfNames( IID_NULL, &sMemberNames[ind], 1, LOCALE_USER_DEFAULT, &id );
+ if( !SUCCEEDED( hr ) ) return hr;
+
+ hr = CComDispatchDriver::GetProperty( pdispObject, id, &pVariant[ind] );
+ if( !SUCCEEDED( hr ) ) return hr;
+ }
+
+ return S_OK;
+}
+/////////////////////////////////////////////////////////////////////////////
+// CSOActiveX
+
+CSOActiveX::CSOActiveX()
+: mCookie(0)
+, mCurFileUrl( L"private:factory/swriter" )
+, mbLoad( FALSE )
+, mParentWin( NULL )
+, mOffWin( NULL )
+, mbViewOnly( TRUE )
+, mpDispatchInterceptor( NULL )
+, mnVersion( SO_NOT_DETECTED )
+, mbReadyForActivation( FALSE )
+, mbDrawLocked( FALSE )
+{
+ CLSID clsFactory = {0x82154420,0x0FBF,0x11d4,{0x83, 0x13,0x00,0x50,0x04,0x52,0x6A,0xB4}};
+ HRESULT hr = CoCreateInstance( clsFactory, NULL, CLSCTX_ALL, __uuidof(IDispatch), (void**)&mpDispFactory);
+ if( !SUCCEEDED( hr ) )
+ OutputError_Impl( NULL, hr );
+
+ mPWinClass.style = CS_HREDRAW|CS_VREDRAW;
+ mPWinClass.lpfnWndProc = ::DefWindowProc;
+ mPWinClass.cbClsExtra = 0;
+ mPWinClass.cbWndExtra = 0;
+ mPWinClass.hInstance = (HINSTANCE) GetModuleHandle(NULL); //myInstance;
+ mPWinClass.hIcon = NULL;
+ mPWinClass.hCursor = NULL;
+ mPWinClass.hbrBackground = (HBRUSH) COLOR_BACKGROUND;
+ mPWinClass.lpszMenuName = NULL;
+ mPWinClass.lpszClassName = STAROFFICE_WINDOWCLASS;
+
+ RegisterClass(&mPWinClass);
+}
+
+CSOActiveX::~CSOActiveX()
+{
+ Cleanup();
+
+}
+
+HRESULT CSOActiveX::Cleanup()
+{
+ CComVariant dummyResult;
+
+ if( mpDispatchInterceptor )
+ {
+ if( mpDispFrame )
+ {
+ // remove dispatch interceptor
+ CComQIPtr< IDispatch, &IID_IDispatch > pIDispDispInter( mpDispatchInterceptor );
+ CComVariant aVariant( pIDispDispInter );
+ ExecuteFunc( mpDispFrame,
+ L"releaseDispatchProviderInterceptor",
+ &aVariant,
+ 1,
+ &dummyResult );
+ }
+
+ mpDispatchInterceptor->ClearParent();
+ mpDispatchInterceptor->Release();
+ mpDispatchInterceptor = NULL;
+ }
+
+ mpDispTempFile = CComPtr< IDispatch >();
+ mbReadyForActivation = FALSE;
+
+ if( mpInstanceLocker )
+ {
+ ExecuteFunc( mpInstanceLocker, L"dispose", NULL, 0, &dummyResult );
+ mpInstanceLocker = CComPtr< IDispatch >();
+ }
+
+ if( mpDispFrame )
+ {
+ BOOL bCloserActivated = FALSE;
+
+ CComPtr<IDispatch> pDispDocumentCloser;
+ CComVariant aDocCloser( L"com.sun.star.embed.DocumentCloser" );
+ HRESULT hr = GetIDispByFunc( mpDispFactory,
+ L"createInstance",
+ &aDocCloser,
+ 1,
+ pDispDocumentCloser );
+ if ( SUCCEEDED( hr ) && pDispDocumentCloser )
+ {
+ SAFEARRAY FAR* pInitFrame = SafeArrayCreateVector( VT_VARIANT, 0, 1 );
+ long nInitInd = 0;
+ CComVariant pFrameVariant( mpDispFrame );
+ SafeArrayPutElement( pInitFrame, &nInitInd, &pFrameVariant );
+ CComVariant aVarInitFrame;
+ aVarInitFrame.vt = VT_ARRAY | VT_VARIANT; aVarInitFrame.parray = pInitFrame;
+ hr = ExecuteFunc( pDispDocumentCloser, L"initialize", &aVarInitFrame, 1, &dummyResult );
+ if( SUCCEEDED( hr ) )
+ {
+ // the following call will let the closing happen
+ hr = ExecuteFunc( pDispDocumentCloser, L"dispose", NULL, 0, &dummyResult );
+ bCloserActivated = SUCCEEDED( hr );
+ }
+ }
+
+ if ( !bCloserActivated )
+ {
+ CComVariant aPropVar;
+ aPropVar.vt = VT_BOOL; aPropVar.boolVal = VARIANT_TRUE;
+ if ( !SUCCEEDED( ExecuteFunc( mpDispFrame, L"close", &aPropVar, 1, &dummyResult ) ) )
+ ExecuteFunc( mpDispFrame, L"dispose", NULL, 0, &dummyResult );
+ }
+
+ mpDispFrame = CComPtr< IDispatch >();
+ }
+
+ if( ::IsWindow( mOffWin ) )
+ ::DestroyWindow( mOffWin );
+
+ TerminateOffice();
+
+ return S_OK;
+}
+
+HRESULT CSOActiveX::TerminateOffice()
+{
+ // create desktop
+ CComPtr<IDispatch> pdispDesktop;
+ CComVariant aDesktopServiceName( L"com.sun.star.frame.Desktop" );
+
+ HRESULT hr = GetIDispByFunc( mpDispFactory, L"createInstance", &aDesktopServiceName, 1, pdispDesktop );
+ if( !pdispDesktop || !SUCCEEDED( hr ) ) return hr;
+
+ // create tree of frames
+ CComPtr<IDispatch> pdispChildren;
+ hr = GetIDispByFunc( pdispDesktop, L"getFrames", NULL, 0, pdispChildren );
+ if( !pdispChildren || !SUCCEEDED( hr ) ) return hr;
+
+ CComVariant aFrames;
+ CComVariant nFlag( 4 );
+ hr = ExecuteFunc( pdispChildren, L"queryFrames", &nFlag, 1, &aFrames );
+ if ( SUCCEEDED( hr ) )
+ {
+ if ( ( aFrames.vt == ( VT_ARRAY | VT_DISPATCH ) || aFrames.vt == ( VT_ARRAY | VT_VARIANT ) )
+ && ( !aFrames.parray || aFrames.parray->cDims == 1 && aFrames.parray->rgsabound[0].cElements == 0 ) )
+ {
+ // there is no frames open
+ // TODO: check whether the frames are hidden if they are open?
+ CComVariant dummyResult;
+ hr = ExecuteFunc( pdispDesktop, L"terminate", NULL, 0, &dummyResult );
+ }
+ }
+
+ return hr;
+}
+
+STDMETHODIMP CSOActiveX::InitNew ()
+{
+ mnVersion = GetVersionConnected();
+ mbLoad = TRUE;
+ return S_OK;
+}
+
+STDMETHODIMP CSOActiveX::Load ( LPSTREAM /*pStm*/ )
+{
+ mnVersion = GetVersionConnected();
+ mbLoad = TRUE;
+
+ // may be later?
+ // for now just ignore
+
+ return S_OK;
+}
+
+STDMETHODIMP CSOActiveX::Load( LPPROPERTYBAG pPropBag, LPERRORLOG /*pErrorLog*/ )
+{
+ mnVersion = GetVersionConnected();
+
+ IPropertyBag2* pPropBag2;
+ HRESULT hr = pPropBag->QueryInterface( IID_IPropertyBag2, (void**)&pPropBag2 );
+ //ATLASSERT( hr >= 0 );
+
+ if( !SUCCEEDED( hr ) )
+ return hr;
+
+ unsigned long aNum;
+ hr = pPropBag2->CountProperties( &aNum );
+ //ATLASSERT( hr >= 0 );
+ if( !SUCCEEDED( hr ) )
+ return hr;
+
+ PROPBAG2* aPropNames = new PROPBAG2[aNum];
+ unsigned long aReaded;
+
+ hr = pPropBag2->GetPropertyInfo( 0,
+ aNum,
+ aPropNames,
+ &aReaded );
+ //ATLASSERT( hr >= 0 );
+ if( !SUCCEEDED( hr ) )
+ {
+ delete[] aPropNames;
+ return hr;
+ }
+
+ CComVariant* aVal = new CComVariant[aNum];
+ HRESULT* hvs = new HRESULT[aNum];
+ hr = pPropBag2->Read( aNum,
+ aPropNames,
+ NULL,
+ aVal,
+ hvs );
+ //ATLASSERT( hr >= 0 );
+ if( !SUCCEEDED( hr ) )
+ {
+ delete[] hvs;
+ delete[] aVal;
+ delete[] aPropNames;
+ return hr;
+ }
+
+ USES_CONVERSION;
+ for( unsigned long ind = 0; ind < aNum; ind++ )
+ {
+ // all information from the 'object' tag is in strings
+ if( aVal[ind].vt == VT_BSTR && !strcmp( OLE2T( aPropNames[ind].pstrName ), "src" ) )
+ {
+ mCurFileUrl = wcsdup( aVal[ind].bstrVal );
+ }
+ else if( aVal[ind].vt == VT_BSTR
+ && !strcmp( OLE2T( aPropNames[ind].pstrName ), "readonly" ) )
+ {
+ if( !strcmp( OLE2T( aVal[ind].bstrVal ), "true" ) )
+ {
+ // the default value
+ mbViewOnly = TRUE;
+ }
+ else
+ {
+ mbViewOnly = FALSE;
+ }
+ }
+ }
+
+ delete[] hvs;
+ delete[] aVal;
+ delete[] aPropNames;
+
+ if( !mpDispFactory )
+ return hr;
+
+ mbReadyForActivation = FALSE;
+ hr = CBindStatusCallback<CSOActiveX>::Download( this, &CSOActiveX::CallbackCreateXInputStream, mCurFileUrl, m_spClientSite, FALSE );
+ if ( hr == MK_S_ASYNCHRONOUS )
+ hr = S_OK;
+
+ if ( !SUCCEEDED( hr ) )
+ {
+ // trigger initialization without stream
+ mbLoad = TRUE;
+
+ Invalidate();
+ UpdateWindow();
+ }
+
+ return hr;
+}
+
+HRESULT CSOActiveX::GetUnoStruct( OLECHAR* sStructName, CComPtr<IDispatch>& pdispResult )
+{
+ CComVariant aComStruct( sStructName );
+ return GetIDispByFunc( mpDispFactory, L"Bridge_GetStruct", &aComStruct, 1, pdispResult );
+}
+
+HRESULT CSOActiveX::GetUrlStruct( OLECHAR* sUrl, CComPtr<IDispatch>& pdispUrl )
+{
+ HRESULT hr = GetUnoStruct( L"com.sun.star.util.URL", pdispUrl );
+ if( !SUCCEEDED( hr ) ) return hr;
+
+ OLECHAR* sURLMemberName = L"Complete";
+ DISPID nURLID;
+ hr = pdispUrl->GetIDsOfNames( IID_NULL, &sURLMemberName, 1, LOCALE_USER_DEFAULT, &nURLID );
+ if( !SUCCEEDED( hr ) ) return hr;
+ CComVariant aComUrl( sUrl );
+ hr = CComDispatchDriver::PutProperty( pdispUrl, nURLID, &aComUrl );
+ if( !SUCCEEDED( hr ) ) return hr;
+
+ CComPtr<IDispatch> pdispTransformer;
+ CComVariant aServiceName( L"com.sun.star.util.URLTransformer" );
+ hr = GetIDispByFunc( mpDispFactory,
+ L"createInstance",
+ &aServiceName,
+ 1,
+ pdispTransformer );
+ if( !SUCCEEDED( hr ) ) return hr;
+
+ CComVariant dummyResult;
+ CComVariant aParam[2];
+ aParam[1].ppdispVal = &pdispUrl;
+ aParam[1].vt = VT_DISPATCH | VT_BYREF;
+ aParam[0] = CComVariant( L"file:///" );
+
+ hr = ExecuteFunc( pdispTransformer, L"parseSmart", aParam, 2, &dummyResult );
+ if( !SUCCEEDED( hr ) || dummyResult.vt != VT_BOOL || !dummyResult.boolVal ) return hr;
+
+ return S_OK;
+}
+
+HRESULT CSOActiveX::SetLayoutManagerProps()
+{
+ if ( !mpDispFrame )
+ return E_FAIL;
+
+ CComVariant pVarLayoutMgr;
+ OLECHAR* sLMPropName = L"LayoutManager";
+ HRESULT hr = GetPropertiesFromIDisp( mpDispFrame, &sLMPropName, &pVarLayoutMgr, 1 );
+ if( pVarLayoutMgr.vt != VT_DISPATCH || pVarLayoutMgr.pdispVal == NULL )
+ return E_FAIL;
+
+ CComPtr<IDispatch> pdispLM( pVarLayoutMgr.pdispVal );
+
+
+ if( !SUCCEEDED( hr ) || !pdispLM )
+ return E_FAIL;
+
+ OLECHAR* sATName = L"AutomaticToolbars";
+ CComVariant pATProp;
+ pATProp.vt = VT_BOOL; pATProp.boolVal = VARIANT_FALSE ;
+ hr = PutPropertiesToIDisp( pdispLM, &sATName, &pATProp, 1 );
+
+ return hr;
+}
+
+HRESULT CSOActiveX::CreateFrameOldWay( HWND hwnd, int width, int height )
+{
+ if( !mpDispFactory )
+ return E_FAIL;
+
+ // create window handle holder
+ CComPtr< CComObject< SOComWindowPeer > > pPeerToSend = new CComObject<SOComWindowPeer>();
+ pPeerToSend->SetHWNDInternally( hwnd );
+ CComQIPtr< IDispatch, &IID_IDispatch > pIDispToSend( pPeerToSend );
+
+ // create rectangle structure
+ CComPtr<IDispatch> pdispRectangle;
+ HRESULT hr = GetUnoStruct( L"com.sun.star.awt.Rectangle", pdispRectangle );
+ if( !SUCCEEDED( hr ) ) return hr;
+
+ OLECHAR* sRectMemberNames[4] = { L"X",
+ L"Y",
+ L"Width",
+ L"Height" };
+ CComVariant pRectVariant[4];
+ pRectVariant[0] = pRectVariant[1] = pRectVariant[2] = pRectVariant[3] = CComVariant( 0 );
+
+ hr = PutPropertiesToIDisp( pdispRectangle, sRectMemberNames, pRectVariant, 4 );
+ if( !SUCCEEDED( hr ) ) return hr;
+
+ // create WindowDescriptor structure
+ CComPtr<IDispatch> pdispWinDescr;
+ hr = GetUnoStruct( L"com.sun.star.awt.WindowDescriptor", pdispWinDescr );
+ if( !SUCCEEDED( hr ) ) return hr;
+
+ // fill in descriptor with info
+ OLECHAR* sDescriptorMemberNames[6] = { L"Type",
+ L"WindowServiceName",
+ L"ParentIndex",
+ L"Parent",
+ L"Bounds",
+ L"WindowAttributes" };
+ CComVariant pDescriptorVar[6];
+ pDescriptorVar[0] = CComVariant( 0 );
+ pDescriptorVar[1] = CComVariant( L"workwindow" );
+ pDescriptorVar[2] = CComVariant( 1 );
+ pDescriptorVar[3] = CComVariant( pIDispToSend );
+ pDescriptorVar[4] = CComVariant( pdispRectangle );
+ pDescriptorVar[5] = CComVariant( 33 );
+ hr = PutPropertiesToIDisp( pdispWinDescr, sDescriptorMemberNames, pDescriptorVar, 6 );
+ if( !SUCCEEDED( hr ) ) return hr;
+
+ // create XToolkit instance
+ CComPtr<IDispatch> pdispToolkit;
+ CComVariant aServiceName( L"com.sun.star.awt.Toolkit" );
+ hr = GetIDispByFunc( mpDispFactory, L"createInstance", &aServiceName, 1, pdispToolkit );
+ if( !SUCCEEDED( hr ) ) return hr;
+
+ // create window with toolkit
+ CComVariant aWinDescr( pdispWinDescr );
+ hr = GetIDispByFunc( pdispToolkit, L"createWindow", &aWinDescr, 1, mpDispWin );
+ if( !SUCCEEDED( hr ) ) return hr;
+
+ // create frame
+ aServiceName = CComVariant( L"com.sun.star.frame.Task" );
+ hr = GetIDispByFunc( mpDispFactory, L"createInstance", &aServiceName, 1, mpDispFrame );
+ if( !SUCCEEDED( hr ) || !mpDispFrame )
+ {
+ // the interface com.sun.star.frame.Task is removed in 6.1
+ // but the interface com.sun.star.frame.Frame has some bugs in 6.0
+ aServiceName = CComVariant( L"com.sun.star.frame.Frame" );
+ hr = GetIDispByFunc( mpDispFactory, L"createInstance", &aServiceName, 1, mpDispFrame );
+ if( !SUCCEEDED( hr ) ) return hr;
+ }
+
+ // initialize frame
+ CComVariant dummyResult;
+ CComVariant aDispWin( mpDispWin );
+ hr = ExecuteFunc( mpDispFrame, L"initialize", &aDispWin, 1, &dummyResult );
+ if( !SUCCEEDED( hr ) ) return hr;
+
+ // set some properties to the layout manager, ignore errors for now
+ SetLayoutManagerProps();
+
+ // create desktop
+ CComPtr<IDispatch> pdispDesktop;
+ aServiceName = CComVariant( L"com.sun.star.frame.Desktop" );
+ hr = GetIDispByFunc( mpDispFactory, L"createInstance", &aServiceName, 1, pdispDesktop );
+ if( !SUCCEEDED( hr ) ) return hr;
+
+ // create tree of frames
+ CComPtr<IDispatch> pdispChildren;
+ hr = GetIDispByFunc( pdispDesktop, L"getFrames", NULL, 0, pdispChildren );
+ if( !SUCCEEDED( hr ) ) return hr;
+
+ // insert new frame into desctop hierarchy
+ CComVariant aDispFrame( mpDispFrame );
+ hr = ExecuteFunc( pdispChildren, L"append", &aDispFrame, 1, &dummyResult );
+ if( !SUCCEEDED( hr ) ) return hr;
+
+ // initialize window
+ CComVariant aTransparent( (long)0xFFFFFFFF );
+ hr = ExecuteFunc( mpDispWin, L"setBackground", &aTransparent, 1, &dummyResult );
+ if( !SUCCEEDED( hr ) ) return hr;
+
+ CComVariant aTrue( TRUE );
+ hr = ExecuteFunc( mpDispWin, L"setVisible", &aTrue, 1, &dummyResult );
+ if( !SUCCEEDED( hr ) ) return hr;
+
+ CComVariant aPosArgs[5];
+ aPosArgs[4] = CComVariant( 0 );
+ aPosArgs[3] = CComVariant( 0 );
+ aPosArgs[2] = CComVariant( width );
+ aPosArgs[1] = CComVariant( height );
+ aPosArgs[0] = CComVariant( 12 );
+ hr = ExecuteFunc( mpDispWin, L"setPosSize", aPosArgs, 5, &dummyResult );
+ if( !SUCCEEDED( hr ) ) return hr;
+
+ // create frame locker if there is such service
+ aServiceName = CComVariant( L"com.sun.star.embed.InstanceLocker" );
+ hr = GetIDispByFunc( mpDispFactory, L"createInstance", &aServiceName, 1, mpInstanceLocker );
+ if( SUCCEEDED( hr ) && mpInstanceLocker )
+ {
+ SAFEARRAY FAR* pInitVals = SafeArrayCreateVector( VT_VARIANT, 0, 3 );
+
+ // the first sequence element
+ long nInitInd = 0;
+ CComVariant pFrameVariant( mpDispFrame );
+ SafeArrayPutElement( pInitVals, &nInitInd, &pFrameVariant );
+
+ // the second sequence element
+ nInitInd = 1;
+ CComVariant pStrArr( 1L );
+ SafeArrayPutElement( pInitVals, &nInitInd, &pStrArr );
+
+ // the third sequence element
+ nInitInd = 2;
+ CComPtr<IDispatch> pdispValueObj;
+ hr = GetIDispByFunc( mpDispFactory, L"Bridge_GetValueObject", NULL, 0, pdispValueObj );
+ if( !SUCCEEDED( hr ) || !pdispValueObj ) return hr;
+
+ CComVariant aValueArgs[2];
+ aValueArgs[1] = CComVariant( L"com.sun.star.embed.XActionsApproval" );
+ CComPtr< CComObject< SOActionsApproval > > pApproval( new CComObject<SOActionsApproval>() );
+ aValueArgs[0] = CComVariant ( pApproval );
+
+ hr = ExecuteFunc( pdispValueObj, L"Set", aValueArgs, 2, &dummyResult );
+ if( !SUCCEEDED( hr ) ) return hr;
+
+ CComVariant aValueObj( pdispValueObj );
+ SafeArrayPutElement( pInitVals, &nInitInd, &aValueObj );
+
+ // execute initialize()
+ CComVariant aVarInitVals;
+ aVarInitVals.vt = VT_ARRAY | VT_VARIANT; aVarInitVals.parray = pInitVals;
+ hr = ExecuteFunc( mpInstanceLocker, L"initialize", &aVarInitVals, 1, &dummyResult );
+ if( !SUCCEEDED( hr ) ) return hr;
+ }
+
+ return S_OK;
+}
+
+HRESULT CSOActiveX::CallLoadComponentFromURL1PBool( OLECHAR* sUrl, OLECHAR* sArgName, BOOL sArgVal )
+{
+ SAFEARRAY FAR* pPropVals = SafeArrayCreateVector( VT_DISPATCH, 0, 1 );
+ long ix = 0;
+ CComPtr<IDispatch> pdispPropVal;
+ HRESULT hr = GetUnoStruct( L"com.sun.star.beans.PropertyValue", pdispPropVal );
+ if( !SUCCEEDED( hr ) ) return hr;
+
+ OLECHAR* sPropMemberNames[2] = { L"Name", L"Value" };
+ CComVariant pPropVar[2];
+ pPropVar[0] = CComVariant( sArgName );
+ pPropVar[1].vt = VT_BOOL; pPropVar[1].boolVal = sArgVal ? VARIANT_TRUE : VARIANT_FALSE ;
+ hr = PutPropertiesToIDisp( pdispPropVal, sPropMemberNames, pPropVar, 2 );
+ if( !SUCCEEDED( hr ) ) return hr;
+
+ SafeArrayPutElement( pPropVals, &ix, pdispPropVal );
+
+ CComVariant aDispArgs[4];
+ aDispArgs[3] = CComVariant( sUrl );
+ aDispArgs[2] = CComVariant( L"_self" );
+ aDispArgs[1] = CComVariant( 0 );
+ // aDispArgs[0] = CComVariant( pPropVals ); such constructor is not defined ??!
+ aDispArgs[0].vt = VT_ARRAY | VT_DISPATCH; aDispArgs[0].parray = pPropVals;
+
+ CComVariant dummyResult;
+ hr = ExecuteFunc( mpDispFrame, L"loadComponentFromURL", aDispArgs, 4, &dummyResult );
+ if( !SUCCEEDED( hr ) ) return hr;
+
+ return S_OK;
+}
+
+HRESULT CSOActiveX::CallDispatchMethod( OLECHAR* sUrl,
+ CComVariant* aArgNames,
+ CComVariant* aArgVals,
+ unsigned int count )
+{
+ CComPtr<IDispatch> pdispURL;
+ HRESULT hr = GetUrlStruct( sUrl, pdispURL );
+ if( !SUCCEEDED( hr ) ) return hr;
+
+ CComPtr<IDispatch> pdispXDispatch;
+ CComVariant aArgs[3];
+ aArgs[2] = CComVariant( pdispURL );
+ aArgs[1] = CComVariant( L"" );
+ aArgs[0] = CComVariant( (int)0 );
+ hr = GetIDispByFunc( mpDispFrame,
+ L"queryDispatch",
+ aArgs,
+ 3,
+ pdispXDispatch );
+ if( !SUCCEEDED( hr ) ) return hr;
+
+ SAFEARRAY FAR* pPropVals = SafeArrayCreateVector( VT_DISPATCH, 0, count );
+ for( long ix = 0; ix < (long)count; ix ++ )
+ {
+ CComPtr<IDispatch> pdispPropVal;
+ hr = GetUnoStruct( L"com.sun.star.beans.PropertyValue", pdispPropVal );
+ if( !SUCCEEDED( hr ) ) return hr;
+
+ OLECHAR* sPropMemberNames[2] = { L"Name", L"Value" };
+ CComVariant pPropVar[2];
+ pPropVar[0] = aArgNames[ix];
+ pPropVar[1] = aArgVals[ix];
+ hr = PutPropertiesToIDisp( pdispPropVal, sPropMemberNames, pPropVar, 2 );
+ if( !SUCCEEDED( hr ) ) return hr;
+
+ SafeArrayPutElement( pPropVals, &ix, pdispPropVal );
+ }
+
+ CComVariant aDispArgs[2];
+ aDispArgs[1] = CComVariant( pdispURL );
+ // aDispArgs[0] = CComVariant( pPropVals ); such constructor is not defined ??!
+ aDispArgs[0].vt = VT_ARRAY | VT_DISPATCH; aDispArgs[0].parray = pPropVals;
+
+ CComVariant dummyResult;
+ hr = ExecuteFunc( pdispXDispatch, L"dispatch", aDispArgs, 2, &dummyResult );
+ if( !SUCCEEDED( hr ) ) return hr;
+
+ return S_OK;
+}
+
+void CSOActiveX::CallbackCreateXInputStream( CBindStatusCallback<CSOActiveX>* /*pbsc*/, BYTE* pBytes, DWORD dwSize )
+{
+ if ( mbReadyForActivation )
+ return;
+
+ BOOL bSuccess = FALSE;
+ BOOL bFinishDownload = FALSE;
+ if ( !pBytes )
+ {
+ // means the download is finished, dwSize contains hresult
+ bFinishDownload = TRUE;
+ if ( SUCCEEDED( dwSize ) )
+ bSuccess = TRUE;
+ }
+ else
+ {
+ HRESULT hr = S_OK;
+
+ if ( !mpDispTempFile )
+ {
+ CComVariant aServiceName( L"com.sun.star.io.TempFile" );
+ hr = GetIDispByFunc( mpDispFactory,
+ L"createInstance",
+ &aServiceName,
+ 1,
+ mpDispTempFile );
+ }
+
+ if( SUCCEEDED( hr ) && mpDispTempFile )
+ {
+ SAFEARRAY FAR* pDataArray = SafeArrayCreateVector( VT_I1, 0, dwSize );
+
+ if ( pDataArray )
+ {
+ hr = SafeArrayLock( pDataArray );
+ if ( SUCCEEDED( hr ) )
+ {
+ for( DWORD ix = 0; ix < dwSize; ix++ )
+ ((BYTE*)(pDataArray->pvData))[ix] = pBytes[ix];
+ hr = SafeArrayUnlock( pDataArray );
+ if ( SUCCEEDED( hr ) )
+ {
+ CComVariant aArgs[1];
+ aArgs[0].vt = VT_ARRAY | VT_I1; aArgs[0].parray = pDataArray;
+ CComVariant dummyResult;
+ hr = ExecuteFunc( mpDispTempFile, L"writeBytes", aArgs, 1, &dummyResult );
+ if( SUCCEEDED( hr ) )
+ bSuccess = TRUE;
+ }
+ }
+ }
+ }
+ }
+
+ if ( !bSuccess )
+ {
+ // the download failed, let StarOffice download
+ bFinishDownload = TRUE;
+ mpDispTempFile = CComPtr< IDispatch >();
+ }
+
+ if ( bFinishDownload )
+ {
+ // trigger the loading now
+ mbLoad = TRUE;
+ mbReadyForActivation = TRUE;
+
+ Invalidate();
+ UpdateWindow();
+ }
+}
+
+HRESULT CSOActiveX::LoadURLToFrame( )
+{
+ CComVariant aArgNames[4] = { L"ReadOnly", L"ViewOnly", L"AsTemplate", L"InputStream" };
+ CComVariant aArgVals[4];
+ unsigned int nCount = 3; // the 4-th argument is used only if the stream can be retrieved
+
+ aArgVals[0].vt = VT_BOOL; aArgVals[0].boolVal = mbViewOnly ? VARIANT_TRUE : VARIANT_FALSE;
+ aArgVals[1].vt = VT_BOOL; aArgVals[1].boolVal = mbViewOnly ? VARIANT_TRUE : VARIANT_FALSE;
+ aArgVals[2].vt = VT_BOOL; aArgVals[2].boolVal = VARIANT_FALSE;
+
+ if ( mpDispTempFile )
+ {
+ aArgVals[3] = CComVariant( mpDispTempFile );
+ nCount = 4;
+ }
+
+ HRESULT hr = CallDispatchMethod( mCurFileUrl, aArgNames, aArgVals, nCount );
+ if( !SUCCEEDED( hr ) ) return hr;
+
+ CComVariant aBarName( L"MenuBarVisible" );
+ CComVariant aBarVis;
+ aBarVis.vt = VT_BOOL; aBarVis.boolVal = VARIANT_FALSE;
+ hr = CallDispatchMethod( L"slot:6661", &aBarName, &aBarVis, 1 );
+ // does not work for some documents, but it is no error
+ // if( !SUCCEEDED( hr ) ) return hr;
+
+ // try to get the model and set the presetation specific property, the setting will fail for other document formats
+ CComPtr<IDispatch> pdispController;
+ hr = GetIDispByFunc( mpDispFrame, L"getController", NULL, 0, pdispController );
+ if ( SUCCEEDED( hr ) && pdispController )
+ {
+ CComPtr<IDispatch> pdispModel;
+ hr = GetIDispByFunc( pdispController, L"getModel", NULL, 0, pdispModel );
+ if ( SUCCEEDED( hr ) && pdispModel )
+ {
+ CComPtr<IDispatch> pdispPres;
+ hr = GetIDispByFunc( pdispModel, L"getPresentation", NULL, 0, pdispPres );
+ if ( SUCCEEDED( hr ) && pdispPres )
+ {
+ // this is a presentation
+ // let the slide show be shown in the document window
+ OLECHAR* pPropName = L"IsFullScreen";
+ CComVariant pPresProp;
+ pPresProp.vt = VT_BOOL; pPresProp.boolVal = VARIANT_FALSE ;
+ hr = PutPropertiesToIDisp( pdispPres, &pPropName, &pPresProp, 1 );
+
+ // start the slide show
+ if ( SUCCEEDED( hr ) )
+ {
+ CComVariant dummyResult;
+ ExecuteFunc( pdispPres, L"Start", NULL, 0, &dummyResult );
+ }
+ }
+ }
+ }
+
+ // create dispatch interceptor
+ mpDispatchInterceptor = new CComObject< SODispatchInterceptor >();
+ mpDispatchInterceptor->AddRef();
+ mpDispatchInterceptor->SetParent( this );
+ CComQIPtr< IDispatch, &IID_IDispatch > pIDispDispInter( mpDispatchInterceptor );
+
+ // register dispatch interceptor in the frame
+ CComVariant aDispVariant( pIDispDispInter );
+ CComVariant dummyResult;
+ hr = ExecuteFunc( mpDispFrame,
+ L"registerDispatchProviderInterceptor",
+ &aDispVariant,
+ 1,
+ &dummyResult );
+
+ if( !SUCCEEDED( hr ) ) return hr;
+
+ return S_OK;
+}
+
+SOVersion CSOActiveX::GetVersionConnected()
+{
+ SOVersion bResult = SO_NOT_DETECTED;
+ if( mpDispFactory )
+ {
+ // create ConfigurationProvider instance
+ CComPtr<IDispatch> pdispConfProv;
+ CComVariant aServiceName( L"com.sun.star.configuration.ConfigurationProvider" );
+ HRESULT hr = GetIDispByFunc( mpDispFactory,
+ L"createInstance",
+ &aServiceName,
+ 1,
+ pdispConfProv );
+
+ if( SUCCEEDED( hr ) && pdispConfProv )
+ {
+ CComPtr<IDispatch> pdispConfAccess;
+
+ SAFEARRAY* pInitParams = SafeArrayCreateVector( VT_VARIANT, 0, 1 );
+
+ if( pInitParams )
+ {
+ long ix = 0;
+ CComVariant aConfPath( L"org.openoffice.Setup" );
+ SafeArrayPutElement( pInitParams, &ix, &aConfPath );
+
+ CComVariant aArgs[2];
+ aArgs[1] = CComVariant( L"com.sun.star.configuration.ConfigurationAccess" );
+ aArgs[0].vt = VT_ARRAY | VT_VARIANT; aArgs[0].parray = pInitParams;
+
+ hr = GetIDispByFunc( pdispConfProv,
+ L"createInstanceWithArguments",
+ aArgs,
+ 2,
+ pdispConfAccess );
+
+ if( SUCCEEDED( hr ) && pdispConfAccess )
+ {
+ CComVariant aOfficeName;
+
+ CComVariant aProductName( L"Product/ooName" );
+ hr = ExecuteFunc( pdispConfAccess,
+ L"getByHierarchicalName",
+ &aProductName,
+ 1,
+ &aOfficeName );
+
+ if( SUCCEEDED( hr ) && aOfficeName.vt == VT_BSTR )
+ {
+ CComVariant aOfficeVersion;
+
+ CComVariant aProductVersion( L"Product/ooSetupVersion" );
+ hr = ExecuteFunc( pdispConfAccess,
+ L"getByHierarchicalName",
+ &aProductVersion,
+ 1,
+ &aOfficeVersion );
+
+ if( SUCCEEDED( hr ) && aOfficeVersion.vt == VT_BSTR )
+ {
+ USES_CONVERSION;
+ if( !strcmp( OLE2T( aOfficeName.bstrVal ), "StarOffice" ) )
+ {
+ if( !strncmp( OLE2T( aOfficeVersion.bstrVal ), "6.1", 3 ) )
+ bResult = SO_61;
+ else if( !strncmp( OLE2T( aOfficeVersion.bstrVal ), "6.0", 3 ) )
+ bResult = SO_60;
+ else if( !strncmp( OLE2T( aOfficeVersion.bstrVal ), "5.2", 3 ) )
+ bResult = SO_52;
+ else
+ bResult = SO_UNKNOWN;
+ }
+ else // OpenOffice
+ {
+ if( !strncmp( OLE2T( aOfficeVersion.bstrVal ), "1.1", 3 ) )
+ bResult = OO_11;
+ else if( !strncmp( OLE2T( aOfficeVersion.bstrVal ), "1.0", 3 ) )
+ bResult = OO_10;
+ else
+ bResult = OO_UNKNOWN;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ return bResult;
+}
+
+class LockingGuard
+{
+ BOOL& mbLocked;
+public:
+ LockingGuard( BOOL& bLocked )
+ : mbLocked( bLocked )
+ {
+ mbLocked = TRUE;
+ }
+
+ ~LockingGuard()
+ {
+ mbLocked = FALSE;
+ }
+};
+
+HRESULT CSOActiveX::OnDrawAdvanced( ATL_DRAWINFO& di )
+{
+ // This method is called only in main thread, no need to lock it
+
+ // Get read of reentrance problems
+ if ( mbDrawLocked )
+ return S_OK;
+ LockingGuard aGuard( mbDrawLocked );
+
+ if( m_spInPlaceSite && mCurFileUrl && mbReadyForActivation )
+ {
+ HWND hwnd;
+ HRESULT hr = m_spInPlaceSite->GetWindow( &hwnd );
+ if( !SUCCEEDED( hr ) ) return hr;
+
+ if( mParentWin != hwnd || !mOffWin )
+ {
+ if( mpDispFrame )
+ {
+ CComVariant dummyResult;
+ CComVariant aPropVar;
+ aPropVar.vt = VT_BOOL; aPropVar.boolVal = VARIANT_FALSE;
+ HRESULT hr = ExecuteFunc( mpDispFrame, L"close", &aPropVar, 1, &dummyResult );
+ (void)hr;
+ mpDispFrame = CComPtr<IDispatch>();
+ }
+
+ mParentWin = hwnd;
+ mOffWin = CreateWindow(
+ STAROFFICE_WINDOWCLASS,
+ "OfficeContainer",
+ WS_CHILD | WS_CLIPCHILDREN | WS_BORDER,
+ di.prcBounds->left,
+ di.prcBounds->top,
+ di.prcBounds->right - di.prcBounds->left,
+ di.prcBounds->bottom - di.prcBounds->top,
+ mParentWin,
+ NULL,
+ NULL,
+ NULL );
+
+ ::ShowWindow( mOffWin, SW_SHOW );
+ }
+ else
+ {
+ RECT aRect;
+ ::GetWindowRect( mOffWin, &aRect );
+
+ if( aRect.left != di.prcBounds->left || aRect.top != di.prcBounds->top
+ || aRect.right != di.prcBounds->right || aRect.bottom != di.prcBounds->bottom )
+ {
+ // on this state the office window should exist already
+ ::SetWindowPos( mOffWin,
+ HWND_TOP,
+ di.prcBounds->left,
+ di.prcBounds->top,
+ di.prcBounds->right - di.prcBounds->left,
+ di.prcBounds->bottom - di.prcBounds->top,
+ SWP_NOZORDER );
+
+ CComVariant aPosArgs[5];
+ aPosArgs[4] = CComVariant( 0 );
+ aPosArgs[3] = CComVariant( 0 );
+ aPosArgs[2] = CComVariant( int(di.prcBounds->right - di.prcBounds->left) );
+ aPosArgs[1] = CComVariant( int(di.prcBounds->bottom - di.prcBounds->top) );
+ aPosArgs[0] = CComVariant( 12 );
+ CComVariant dummyResult;
+ hr = ExecuteFunc( mpDispWin, L"setPosSize", aPosArgs, 5, &dummyResult );
+ if( !SUCCEEDED( hr ) ) return hr;
+ }
+ }
+
+ if( !mnVersion )
+ {
+ OutputError_Impl( mOffWin, CS_E_INVALID_VERSION );
+ return E_FAIL;
+ }
+
+ if( ! mpDispFrame )
+ {
+ hr = CreateFrameOldWay( mOffWin,
+ di.prcBounds->right - di.prcBounds->left,
+ di.prcBounds->bottom - di.prcBounds->top );
+
+ if( !SUCCEEDED( hr ) )
+ {
+ // if the frame can not be opened do not try any more
+ mbReadyForActivation = FALSE;
+ OutputError_Impl( mOffWin, STG_E_ABNORMALAPIEXIT );
+ return hr;
+ }
+ }
+
+ if( mbLoad )
+ {
+ hr = LoadURLToFrame();
+ mbLoad = FALSE;
+
+ if( !SUCCEEDED( hr ) )
+ {
+ // if the document can not be opened do not try any more
+ mbReadyForActivation = FALSE;
+
+ OutputError_Impl( mOffWin, STG_E_ABNORMALAPIEXIT );
+
+ return hr;
+ }
+ }
+ }
+ else
+ {
+ // activate the fallback
+ CComControl<CSOActiveX>::OnDrawAdvanced( di );
+ }
+
+ return S_OK;
+}
+
+HRESULT CSOActiveX::OnDraw( ATL_DRAWINFO& di )
+{
+ // fallback that is activated by the parent class
+ if ( di.hdcDraw )
+ FillRect( di.hdcDraw, (RECT*)di.prcBounds, (HBRUSH)COLOR_BACKGROUND );
+
+ return S_OK;
+}
+
+STDMETHODIMP CSOActiveX::SetClientSite( IOleClientSite* aClientSite )
+{
+ HRESULT hr = IOleObjectImpl<CSOActiveX>::SetClientSite( aClientSite );
+
+ if( !aClientSite )
+ {
+ //ATLASSERT( mWebBrowser2 );
+ if( mWebBrowser2 )
+ AtlUnadvise( mWebBrowser2, DIID_DWebBrowserEvents2, mCookie );
+ return hr;
+ }
+
+ CComPtr<IOleContainer> aContainer;
+ m_spClientSite->GetContainer( &aContainer );
+// ATLASSERT( aContainer );
+
+ if( SUCCEEDED( hr ) && aContainer )
+ {
+ CComQIPtr<IServiceProvider, &IID_IServiceProvider> aServiceProvider( aContainer );
+ //ATLASSERT( aServiceProvider );
+
+ if( aServiceProvider )
+ {
+ aServiceProvider->QueryService( SID_SInternetExplorer,
+ IID_IWebBrowser,
+ (void**)&mWebBrowser2 );
+// ATLASSERT( mWebBrowser2 );
+ if( mWebBrowser2 )
+ AtlAdvise( mWebBrowser2, GetUnknown(), DIID_DWebBrowserEvents2, &mCookie );
+ }
+ }
+
+ return hr;
+}
+
+STDMETHODIMP CSOActiveX::Invoke(DISPID dispidMember,
+ REFIID riid,
+ LCID lcid,
+ WORD wFlags,
+ DISPPARAMS* pDispParams,
+ VARIANT* pvarResult,
+ EXCEPINFO* pExcepInfo,
+ UINT* puArgErr)
+{
+ if (riid != IID_NULL)
+ return DISP_E_UNKNOWNINTERFACE;
+
+ if (!pDispParams)
+ return DISP_E_PARAMNOTOPTIONAL;
+
+ if ( dispidMember == DISPID_ONQUIT )
+ Cleanup();
+
+ IDispatchImpl<ISOActiveX, &IID_ISOActiveX,
+ &LIBID_SO_ACTIVEXLib>::Invoke(
+ dispidMember, riid, lcid, wFlags, pDispParams,
+ pvarResult, pExcepInfo, puArgErr);
+
+ return S_OK;
+}
+
+HRESULT CSOActiveX::GetURL( const OLECHAR* url,
+ const OLECHAR* target )
+{
+ CComVariant aEmpty1, aEmpty2, aEmpty3;
+ CComVariant aUrl( url );
+ CComVariant aTarget;
+ if ( target )
+ aTarget = CComVariant( target );
+
+ return mWebBrowser2->Navigate2( &aUrl,
+ &aEmpty1,
+ &aTarget,
+ &aEmpty2,
+ &aEmpty3 );
+}
+
+
+// ---------------------------------------------------------------------------
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/activex/main/SOActiveX.h b/extensions/source/activex/main/SOActiveX.h
new file mode 100644
index 000000000000..4b589090b6aa
--- /dev/null
+++ b/extensions/source/activex/main/SOActiveX.h
@@ -0,0 +1,178 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+// SOActiveX.h : Declaration of the CSOActiveX
+
+#ifndef __SOACTIVEX_H_
+#define __SOACTIVEX_H_
+
+#include "resource.h" // main symbols
+
+#pragma warning (disable:4505)
+ // permanently suppress "unreferenced local function has been removed" warning
+
+#pragma warning (push,1)
+#pragma warning (disable:4265)
+
+#include <ExDispID.h>
+#include <ExDisp.h>
+#include <shlguid.h>
+
+#if defined(_MSC_VER) && (_MSC_VER >= 1300)
+#undef _DEBUG
+#endif
+#include <atlctl.h>
+
+#include "so_activex.h"
+
+#pragma warning (pop)
+
+class SODispatchInterceptor;
+
+enum SOVersion {
+ SO_NOT_DETECTED = 0,
+ SO_52,
+ SO_60,
+ SO_61,
+ SO_UNKNOWN,
+ OO_10,
+ OO_11,
+ OO_UNKNOWN
+};
+
+/////////////////////////////////////////////////////////////////////////////
+// CSOActiveX
+class ATL_NO_VTABLE CSOActiveX :
+ public CComObjectRootEx<CComSingleThreadModel>,
+ public IDispatchImpl<ISOActiveX, &IID_ISOActiveX, &LIBID_SO_ACTIVEXLib>,
+ public CComControl<CSOActiveX>,
+ public IPersistStreamInitImpl<CSOActiveX>,
+ public IOleControlImpl<CSOActiveX>,
+ public IOleObjectImpl<CSOActiveX>,
+ public IOleInPlaceActiveObjectImpl<CSOActiveX>,
+ public IViewObjectExImpl<CSOActiveX>,
+ public IOleInPlaceObjectWindowlessImpl<CSOActiveX>,
+// public IConnectionPointContainerImpl<CSOActiveX>,
+ public CComCoClass<CSOActiveX, &CLSID_SOActiveX>,
+// public CProxy_ItryPluginEvents< CSOActiveX >,
+ public IPersistPropertyBagImpl< CSOActiveX >,
+ public IProvideClassInfo2Impl< &CLSID_SOActiveX,
+ &DIID__ISOActiveXEvents,
+ &LIBID_SO_ACTIVEXLib >,
+ public IObjectSafetyImpl< CSOActiveX,
+ INTERFACESAFE_FOR_UNTRUSTED_DATA >
+{
+protected:
+ CComPtr<IWebBrowser2> mWebBrowser2;
+ DWORD mCookie;
+
+ CComPtr<IDispatch> mpDispFactory;
+ CComPtr<IDispatch> mpDispFrame;
+ CComPtr<IDispatch> mpInstanceLocker;
+ CComPtr<IDispatch> mpDispWin;
+ OLECHAR* mCurFileUrl;
+ BOOL mbLoad;
+ BOOL mbViewOnly;
+ WNDCLASS mPWinClass;
+ HWND mParentWin;
+ HWND mOffWin;
+
+ SODispatchInterceptor* mpDispatchInterceptor;
+ SOVersion mnVersion;
+
+ BOOL mbReadyForActivation;
+ CComPtr<IDispatch> mpDispTempFile;
+
+ BOOL mbDrawLocked;
+
+public:
+ CSOActiveX();
+ ~CSOActiveX();
+
+DECLARE_REGISTRY_RESOURCEID(IDR_SOACTIVEX)
+
+DECLARE_PROTECT_FINAL_CONSTRUCT()
+
+BEGIN_COM_MAP(CSOActiveX)
+ COM_INTERFACE_ENTRY(ISOActiveX)
+ COM_INTERFACE_ENTRY(IDispatch)
+ COM_INTERFACE_ENTRY(IViewObjectEx)
+ COM_INTERFACE_ENTRY(IViewObject2)
+ COM_INTERFACE_ENTRY(IViewObject)
+ COM_INTERFACE_ENTRY(IOleInPlaceObjectWindowless)
+ COM_INTERFACE_ENTRY(IOleInPlaceObject)
+ COM_INTERFACE_ENTRY2(IOleWindow, IOleInPlaceObjectWindowless)
+ COM_INTERFACE_ENTRY(IOleInPlaceActiveObject)
+ COM_INTERFACE_ENTRY(IOleControl)
+ COM_INTERFACE_ENTRY(IOleObject)
+ COM_INTERFACE_ENTRY(IPersistStreamInit)
+ COM_INTERFACE_ENTRY2(IPersist, IPersistStreamInit)
+// COM_INTERFACE_ENTRY(IConnectionPointContainer)
+ COM_INTERFACE_ENTRY(IProvideClassInfo)
+ COM_INTERFACE_ENTRY(IProvideClassInfo2)
+ COM_INTERFACE_ENTRY(IPersistPropertyBag)
+ COM_INTERFACE_ENTRY(IObjectSafety)
+END_COM_MAP()
+
+BEGIN_PROP_MAP(CSOActiveX)
+ PROP_DATA_ENTRY("_cx", m_sizeExtent.cx, VT_UI4)
+ PROP_DATA_ENTRY("_cy", m_sizeExtent.cy, VT_UI4)
+ // Example entries
+ // PROP_ENTRY("Property Description", dispid, clsid)
+ // PROP_PAGE(CLSID_StockColorPage)
+END_PROP_MAP()
+
+BEGIN_CONNECTION_POINT_MAP(CSOActiveX)
+END_CONNECTION_POINT_MAP()
+
+BEGIN_MSG_MAP(CSOActiveX)
+ CHAIN_MSG_MAP(CComControl<CSOActiveX>)
+ DEFAULT_REFLECTION_HANDLER()
+END_MSG_MAP()
+// Handler prototypes:
+// LRESULT MessageHandler(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
+// LRESULT CommandHandler(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
+// LRESULT NotifyHandler(int idCtrl, LPNMHDR pnmh, BOOL& bHandled);
+
+
+
+// IViewObjectEx
+ DECLARE_VIEW_STATUS(VIEWSTATUS_SOLIDBKGND | VIEWSTATUS_OPAQUE)
+
+// ISOActiveX
+public:
+
+ STDMETHOD(SetClientSite)( IOleClientSite* aClientSite );
+ STDMETHOD(Invoke)( DISPID dispidMember,
+ REFIID riid,
+ LCID lcid,
+ WORD wFlags,
+ DISPPARAMS* pDispParams,
+ VARIANT* pvarResult,
+ EXCEPINFO* pExcepInfo,
+ UINT* puArgErr);
+ STDMETHOD(Load) ( LPPROPERTYBAG pPropBag, LPERRORLOG pErrorLog );
+ STDMETHOD(Load) ( LPSTREAM pStm );
+ STDMETHOD(InitNew) ();
+ HRESULT OnDrawAdvanced(ATL_DRAWINFO& di);
+ HRESULT OnDraw(ATL_DRAWINFO& di);
+
+ HRESULT SetLayoutManagerProps();
+ HRESULT CreateFrameOldWay( HWND hwnd, int width, int height );
+ HRESULT GetUnoStruct( OLECHAR* sStructName, CComPtr<IDispatch>& pdispResult );
+ HRESULT LoadURLToFrame();
+ HRESULT CallDispatchMethod( OLECHAR* sUrl, CComVariant* sArgNames, CComVariant* sArgVal, unsigned int count );
+ HRESULT CallLoadComponentFromURL1PBool( OLECHAR* sUrl, OLECHAR* sArgName, BOOL sArgVal );
+ HRESULT GetUrlStruct( OLECHAR* sUrl, CComPtr<IDispatch>& pdispUrl );
+ HRESULT Cleanup();
+ HRESULT TerminateOffice();
+ HRESULT GetURL( const OLECHAR* url,
+ const OLECHAR* target );
+
+ void CallbackCreateXInputStream( CBindStatusCallback<CSOActiveX>* pbsc, BYTE* pBytes, DWORD dwSize );
+
+
+ SOVersion GetVersionConnected();
+};
+
+#endif //__SOACTIVEX_H_
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/activex/main/SOActiveX.rgs b/extensions/source/activex/main/SOActiveX.rgs
new file mode 100644
index 000000000000..d3814df3b241
--- /dev/null
+++ b/extensions/source/activex/main/SOActiveX.rgs
@@ -0,0 +1,33 @@
+HKCR
+{
+ so_activex.SOActiveX.1 = s 'SOActiveX Class'
+ {
+ CLSID = s '{67F2A879-82D5-4A6D-8CC5-FFB3C114B69D}'
+ }
+ so_activex.SOActiveX = s 'SOActiveX Class'
+ {
+ CLSID = s '{67F2A879-82D5-4A6D-8CC5-FFB3C114B69D}'
+ CurVer = s 'so_activex.SOActiveX.1'
+ }
+ NoRemove CLSID
+ {
+ ForceRemove {67F2A879-82D5-4A6D-8CC5-FFB3C114B69D} = s 'SOActiveX Class'
+ {
+ ProgID = s 'so_activex.SOActiveX.1'
+ VersionIndependentProgID = s 'so_activex.SOActiveX'
+ ForceRemove 'Programmable'
+ InprocServer32 = s '%MODULE%'
+ {
+ val ThreadingModel = s 'Apartment'
+ }
+ ForceRemove 'Control'
+ ForceRemove 'ToolboxBitmap32' = s '%MODULE%, 101'
+ 'MiscStatus' = s '0'
+ {
+ '1' = s '131473'
+ }
+ 'TypeLib' = s '{61FA3F13-8061-4796-B055-3697ED28CB38}'
+ 'Version' = s '1.0'
+ }
+ }
+}
diff --git a/extensions/source/activex/main/SOComWindowPeer.cpp b/extensions/source/activex/main/SOComWindowPeer.cpp
new file mode 100644
index 000000000000..b6c0986c0ab2
--- /dev/null
+++ b/extensions/source/activex/main/SOComWindowPeer.cpp
@@ -0,0 +1,30 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+// SOComWindowPeer.cpp : Implementation of CHelpApp and DLL registration.
+
+#include "stdafx2.h"
+#include "so_activex.h"
+#include "SOComWindowPeer.h"
+
+/////////////////////////////////////////////////////////////////////////////
+//
+
+STDMETHODIMP SOComWindowPeer::InterfaceSupportsErrorInfo(REFIID riid)
+{
+ static const IID* arr[] =
+ {
+ &IID_ISOComWindowPeer,
+ };
+
+ for (int i=0;i<sizeof(arr)/sizeof(arr[0]);i++)
+ {
+#if defined(_MSC_VER) && (_MSC_VER >= 1300)
+ if (InlineIsEqualGUID(*arr[i],riid))
+#else
+ if (::ATL::InlineIsEqualGUID(*arr[i],riid))
+#endif
+ return S_OK;
+ }
+ return S_FALSE;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/activex/main/SOComWindowPeer.h b/extensions/source/activex/main/SOComWindowPeer.h
new file mode 100644
index 000000000000..c819e17a81ea
--- /dev/null
+++ b/extensions/source/activex/main/SOComWindowPeer.h
@@ -0,0 +1,136 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+// SOComWindowPeer.h: Definition of the SOComWindowPeer class
+//
+//////////////////////////////////////////////////////////////////////
+
+#if !defined __SOCOMWINDOWPEER_H_
+#define __SOCOMWINDOWPEER_H_
+
+#if _MSC_VER > 1000
+#pragma once
+#endif // _MSC_VER > 1000
+
+#include "resource.h" // main symbols
+#include <ExDispID.h>
+#include <ExDisp.h>
+#include <shlguid.h>
+
+#if defined(_MSC_VER) && (_MSC_VER >= 1300)
+#undef _DEBUG
+#endif
+#include <atlctl.h>
+
+#include "so_activex.h"
+
+/////////////////////////////////////////////////////////////////////////////
+// SOComWindowPeer
+
+class SOComWindowPeer :
+ public IDispatchImpl<ISOComWindowPeer, &IID_ISOComWindowPeer, &LIBID_SO_ACTIVEXLib>,
+ public ISupportErrorInfo,
+ public CComObjectRoot,
+ public CComCoClass<SOComWindowPeer,&CLSID_SOComWindowPeer>
+{
+ HWND m_hwnd;
+public:
+ SOComWindowPeer() : m_hwnd( NULL ) {}
+ virtual ~SOComWindowPeer() { }
+
+BEGIN_COM_MAP(SOComWindowPeer)
+ COM_INTERFACE_ENTRY(IDispatch)
+ COM_INTERFACE_ENTRY(ISOComWindowPeer)
+ COM_INTERFACE_ENTRY(ISupportErrorInfo)
+END_COM_MAP()
+DECLARE_NOT_AGGREGATABLE(SOComWindowPeer)
+// Remove the comment from the line above if you don't want your object to
+// support aggregation.
+
+DECLARE_REGISTRY_RESOURCEID(IDR_SOCOMWINDOWPEER)
+
+// ISupportsErrorInfo
+ STDMETHOD(InterfaceSupportsErrorInfo)(REFIID riid);
+
+// ISOComWindowPeer
+ virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE getWindowHandle(
+ /* [in] */ SAFEARRAY __RPC_FAR * /*procId*/,
+ /* [in] */ short /*s*/,
+ /* [retval][out] */ long __RPC_FAR *ret)
+ {
+ *ret = HandleToLong( m_hwnd );
+ return S_OK;
+ }
+
+ virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE getToolkit(
+ /* [retval][out] */ IDispatch __RPC_FAR *__RPC_FAR *retVal)
+ {
+ *retVal = NULL;
+ return S_OK;
+ }
+
+ virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE setPointer(
+ /* [in] */ IDispatch __RPC_FAR* /*xPointer*/)
+ {
+ return S_OK;
+ }
+
+ virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE setBackground(
+ /* [in] */ int /*nColor*/)
+ {
+ return S_OK;
+ }
+
+ virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE invalidate(
+ /* [in] */ short /*__MIDL_0015*/)
+ {
+ return S_OK;
+ }
+
+ virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE invalidateRect(
+ /* [in] */ IDispatch __RPC_FAR* /*aRect*/,
+ /* [in] */ short /*nFlags*/)
+ {
+ return S_OK;
+ }
+
+ virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE dispose( void)
+ {
+ return S_OK;
+ }
+
+ virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE addEventListener(
+ /* [in] */ IDispatch __RPC_FAR* /*xListener*/)
+ {
+ return S_OK;
+ }
+
+ virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE removeEventListener(
+ /* [in] */ IDispatch __RPC_FAR* /*xListener*/)
+ {
+ return S_OK;
+ }
+
+ virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_Bridge_implementedInterfaces(
+ /* [retval][out] */ SAFEARRAY __RPC_FAR * __RPC_FAR *pVal)
+ {
+ *pVal = SafeArrayCreateVector( VT_BSTR, 0, 2 );
+
+ if( !*pVal )
+ return E_FAIL;
+
+ long ix = 0;
+ CComBSTR aInterface( OLESTR( "com.sun.star.awt.XSystemDependentWindowPeer" ) );
+ SafeArrayPutElement( *pVal, &ix, aInterface );
+
+ ix = 1;
+ aInterface = CComBSTR( OLESTR( "com.sun.star.awt.XWindowPeer" ) );
+ SafeArrayPutElement( *pVal, &ix, aInterface );
+
+ return S_OK;
+ }
+
+ void SetHWNDInternally( HWND hwnd ) { m_hwnd = hwnd; }
+};
+
+#endif // __SOCOMWINDOWPEER_H_
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/activex/main/SOComWindowPeer.rgs b/extensions/source/activex/main/SOComWindowPeer.rgs
new file mode 100644
index 000000000000..42e985a31a1b
--- /dev/null
+++ b/extensions/source/activex/main/SOComWindowPeer.rgs
@@ -0,0 +1,23 @@
+HKCR
+{
+ so_activex.SOComWindowPeer.1 = s 'SOComWindowPeer Class'
+ {
+ CLSID = s '{EE51BD3E-8BB6-4FB8-B319-F65B1BE3B21D}'
+ }
+ so_activex.SOComWindowPeer = s 'SOComWindowPeer Class'
+ {
+ CLSID = s '{EE51BD3E-8BB6-4FB8-B319-F65B1BE3B21D}'
+ }
+ NoRemove CLSID
+ {
+ ForceRemove {EE51BD3E-8BB6-4FB8-B319-F65B1BE3B21D} = s 'SOComWindowPeer Class'
+ {
+ ProgID = s 'so_activex.SOComWindowPeer.1'
+ VersionIndependentProgID = s 'so_activex.SOComWindowPeer'
+ InprocServer32 = s '%MODULE%'
+ {
+ val ThreadingModel = s 'both'
+ }
+ }
+ }
+}
diff --git a/extensions/source/activex/main/SODispatchInterceptor.cpp b/extensions/source/activex/main/SODispatchInterceptor.cpp
new file mode 100644
index 000000000000..eadce51085e8
--- /dev/null
+++ b/extensions/source/activex/main/SODispatchInterceptor.cpp
@@ -0,0 +1,224 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+// SODispatchInterceptor.cpp : Implementation of CHelpApp and DLL registration.
+
+#include "stdio.h"
+#include "stdafx2.h"
+#include "so_activex.h"
+#include "SOActiveX.h"
+#include "SODispatchInterceptor.h"
+#include "com_uno_helper.h"
+
+/////////////////////////////////////////////////////////////////////////////
+//
+
+STDMETHODIMP SODispatchInterceptor::InterfaceSupportsErrorInfo(REFIID riid)
+{
+ static const IID* arr[] =
+ {
+ &IID_ISODispatchInterceptor,
+ };
+
+ for (int i=0;i<sizeof(arr)/sizeof(arr[0]);i++)
+ {
+#if defined(_MSC_VER) && (_MSC_VER >= 1300)
+ if (InlineIsEqualGUID(*arr[i],riid))
+#else
+ if (::ATL::InlineIsEqualGUID(*arr[i],riid))
+#endif
+ return S_OK;
+ }
+ return S_FALSE;
+}
+
+STDMETHODIMP SODispatchInterceptor::queryDispatch( IDispatch FAR* aURL,
+ BSTR aTargetFrameName,
+ long nSearchFlags,
+ IDispatch FAR* FAR* retVal )
+{
+ if ( !aURL || !retVal ) return E_FAIL;
+
+ CComVariant aTargetUrl;
+ OLECHAR* sURLMemberName = L"Complete";
+ DISPID nURLID;
+ HRESULT hr = aURL->GetIDsOfNames( IID_NULL, &sURLMemberName, 1, LOCALE_USER_DEFAULT, &nURLID );
+ if( !SUCCEEDED( hr ) ) return hr;
+
+ hr = CComDispatchDriver::GetProperty( aURL, nURLID, &aTargetUrl );
+ if( !SUCCEEDED( hr ) ) return hr;
+
+ if( aTargetUrl.vt != VT_BSTR ) return E_FAIL;
+
+ USES_CONVERSION;
+ if( !strncmp( OLE2T( aTargetUrl.bstrVal ), ".uno:OpenHyperlink", 18 ) )
+ {
+ CComQIPtr< IDispatch, &IID_IDispatch > pIDisp( this );
+ if( pIDisp )
+ {
+ this->AddRef();
+ *retVal = pIDisp;
+ }
+ }
+ else
+ {
+ if( !m_xSlave )
+ {
+ *retVal = NULL;
+ return S_OK;
+ }
+
+ CComVariant aResult;
+ CComVariant aArgs[3];
+ aArgs[0] = CComVariant( nSearchFlags );
+ aArgs[1] = CComVariant( aTargetFrameName );
+ aArgs[2] = CComVariant( aURL );
+
+ hr = ExecuteFunc( m_xSlave, L"queryDispatch", aArgs, 3, &aResult );
+ if( !SUCCEEDED( hr ) || aResult.vt != VT_DISPATCH || aResult.pdispVal == NULL )
+ {
+ *retVal = NULL;
+ return S_OK;
+ }
+
+ *retVal = aResult.pdispVal;
+
+ CComQIPtr< IUnknown, &IID_IUnknown > pIUnk( *retVal );
+ if( pIUnk )
+ (*retVal)->AddRef();
+ }
+
+ return S_OK;
+}
+
+STDMETHODIMP SODispatchInterceptor::queryDispatches( SAFEARRAY FAR* aDescripts, SAFEARRAY FAR* FAR* retVal)
+{
+ if ( !aDescripts || !retVal || SafeArrayGetDim( aDescripts ) != 1 )
+ return E_FAIL;
+
+ long nLB, nUB;
+
+ HRESULT hr = SafeArrayGetLBound( aDescripts, 1, &nLB );
+ if( !SUCCEEDED( hr ) ) return hr;
+
+ hr = SafeArrayGetUBound( aDescripts, 1, &nUB );
+ if( !SUCCEEDED( hr ) ) return hr;
+ if( nUB < nLB ) return E_FAIL;
+
+ *retVal = SafeArrayCreateVector( VT_DISPATCH, 0, nUB - nLB );
+
+ for ( long ind = nLB; ind <= nUB; ind ++ )
+ {
+ CComPtr<IDispatch> pElem;
+ SafeArrayGetElement( aDescripts, &ind, pElem );
+ if( pElem )
+ {
+ OLECHAR* pMemberNames[3] = { L"FeatureURL", L"FrameName", L"SearchFlags" };
+ CComVariant pValues[3];
+ hr = GetPropertiesFromIDisp( pElem, pMemberNames, pValues, 3 );
+ if( !SUCCEEDED( hr ) ) return hr;
+ if( pValues[0].vt != VT_DISPATCH || pValues[0].pdispVal == NULL
+ || pValues[1].vt != VT_BSTR || pValues[2].vt != VT_I4 )
+ return E_FAIL;
+
+ CComPtr<IDispatch> aRes;
+ hr = queryDispatch( pValues[0].pdispVal, pValues[1].bstrVal, pValues[2].lVal, &aRes );
+ SafeArrayPutElement( *retVal, &ind, aRes );
+ }
+ }
+
+ return S_OK;
+}
+
+
+STDMETHODIMP SODispatchInterceptor::dispatch( IDispatch FAR* aURL, SAFEARRAY FAR* aArgs)
+{
+ // get url from aURL
+ OLECHAR* pUrlName = L"Complete";
+ CComVariant pValue;
+ HRESULT hr = GetPropertiesFromIDisp( aURL, &pUrlName, &pValue, 1 );
+ if( !SUCCEEDED( hr ) ) return hr;
+ if( pValue.vt != VT_BSTR || pValue.bstrVal == NULL )
+ return E_FAIL;
+
+ USES_CONVERSION;
+ if( !strncmp( OLE2T( pValue.bstrVal ), ".uno:OpenHyperlink", 18 ) )
+ {
+ long nLB = 0, nUB = 0;
+ // long nDim = SafeArrayGetDim( aArgs );
+
+ hr = SafeArrayGetLBound( aArgs, 1, &nLB );
+ if( !SUCCEEDED( hr ) ) return hr;
+
+ hr = SafeArrayGetUBound( aArgs, 1, &nUB );
+ if( !SUCCEEDED( hr ) ) return hr;
+ if( nUB < nLB ) return E_FAIL;
+
+ for ( long ind = nLB; ind <= nUB; ind ++ )
+ {
+ CComVariant pVarElem;
+ SafeArrayGetElement( aArgs, &ind, &pVarElem );
+ if( pVarElem.vt == VT_DISPATCH && pVarElem.pdispVal != NULL )
+ {
+ OLECHAR* pMemberNames[2] = { L"Name", L"Value" };
+ CComVariant pValues[2];
+ hr = GetPropertiesFromIDisp( pVarElem.pdispVal, pMemberNames, pValues, 2 );
+ if( !SUCCEEDED( hr ) ) return hr;
+
+ if( pValues[0].vt == VT_BSTR && pValues[1].vt == VT_BSTR )
+ {
+ USES_CONVERSION;
+ if( !strncmp( OLE2T( pValues[0].bstrVal ), "URL", 3 ) )
+ {
+ EnterCriticalSection( &mMutex );
+ if( m_xParentControl )
+ {
+ // call GetUrl to the browser instance
+ m_xParentControl->GetURL( pValues[1].bstrVal, L"_self" );
+ }
+ LeaveCriticalSection( &mMutex );
+
+ break;
+ }
+ }
+ }
+ }
+ }
+
+ return S_OK;
+}
+
+STDMETHODIMP SODispatchInterceptor::addStatusListener( IDispatch FAR* /*xControl*/, IDispatch FAR* /*aURL*/)
+{
+ // not implemented
+ return S_OK;
+}
+
+STDMETHODIMP SODispatchInterceptor::removeStatusListener( IDispatch FAR* /*xControl*/, IDispatch FAR* /*aURL*/)
+{
+ // not implemented
+ return S_OK;
+}
+
+STDMETHODIMP SODispatchInterceptor::getInterceptedURLs( SAFEARRAY FAR* FAR* pVal )
+{
+ *pVal = SafeArrayCreateVector( VT_BSTR, 0, 3 );
+
+ if( !*pVal )
+ return E_FAIL;
+
+ long ix = 0;
+ CComBSTR aPattern( OLESTR( "ftp://*" ) );
+ SafeArrayPutElement( *pVal, &ix, aPattern );
+
+ ix = 1;
+ aPattern = CComBSTR( OLESTR( "http://*" ) );
+ SafeArrayPutElement( *pVal, &ix, aPattern );
+
+ ix = 2;
+ aPattern = CComBSTR( OLESTR( "file://*" ) );
+ SafeArrayPutElement( *pVal, &ix, aPattern );
+
+ return S_OK;
+}
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/activex/main/SODispatchInterceptor.h b/extensions/source/activex/main/SODispatchInterceptor.h
new file mode 100644
index 000000000000..1a9b7e38cd6a
--- /dev/null
+++ b/extensions/source/activex/main/SODispatchInterceptor.h
@@ -0,0 +1,158 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+// SODispatchInterceptor.h: Definition of the SODispatchInterceptor class
+//
+//////////////////////////////////////////////////////////////////////
+
+#if !defined __SODISPATCHINTERCEPTOR_H_
+#define __SODISPATCHINTERCEPTOR_H_
+
+#if _MSC_VER > 1000
+#pragma once
+#endif // _MSC_VER > 1000
+
+#include "resource.h" // main symbols
+#include <ExDispID.h>
+#include <ExDisp.h>
+#include <shlguid.h>
+
+#if defined(_MSC_VER) && (_MSC_VER >= 1300)
+#undef _DEBUG
+#endif
+#include <atlctl.h>
+
+#include "so_activex.h"
+
+class CSOActiveX;
+
+/////////////////////////////////////////////////////////////////////////////
+// SODispatchInterceptor
+
+class SODispatchInterceptor :
+ public IDispatchImpl<ISODispatchInterceptor, &IID_ISODispatchInterceptor, &LIBID_SO_ACTIVEXLib>,
+ public ISupportErrorInfo,
+ public CComObjectRoot,
+ public CComCoClass<SODispatchInterceptor,&CLSID_SODispatchInterceptor>
+{
+ CComPtr<IDispatch> m_xMaster;
+ CComPtr<IDispatch> m_xSlave;
+ CSOActiveX* m_xParentControl;
+ CRITICAL_SECTION mMutex;
+public:
+ SODispatchInterceptor() : m_xParentControl( NULL ) { InitializeCriticalSection(&mMutex); }
+ virtual ~SODispatchInterceptor() { ATLASSERT( !m_xParentControl ); DeleteCriticalSection(&mMutex); }
+
+BEGIN_COM_MAP(SODispatchInterceptor)
+ COM_INTERFACE_ENTRY(IDispatch)
+ COM_INTERFACE_ENTRY(ISODispatchInterceptor)
+ COM_INTERFACE_ENTRY(ISupportErrorInfo)
+END_COM_MAP()
+DECLARE_NOT_AGGREGATABLE(SODispatchInterceptor)
+// Remove the comment from the line above if you don't want your object to
+// support aggregation.
+
+DECLARE_REGISTRY_RESOURCEID(IDR_SODISPATCHINTERCEPTOR)
+
+ void SetParent( CSOActiveX* pParent )
+ {
+ ATLASSERT( !m_xParentControl );
+ EnterCriticalSection( &mMutex );
+ m_xParentControl = pParent;
+ LeaveCriticalSection( &mMutex );
+ }
+
+ void ClearParent()
+ {
+ EnterCriticalSection( &mMutex );
+ m_xParentControl = NULL;
+ LeaveCriticalSection( &mMutex );
+ }
+
+// ISupportsErrorInfo
+ STDMETHOD(InterfaceSupportsErrorInfo)(REFIID riid);
+
+// ISODispatchInterceptor
+
+ virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE getSlaveDispatchProvider(
+ /* [retval][out] */ IDispatch __RPC_FAR *__RPC_FAR *retVal)
+ {
+ *retVal = m_xSlave;
+ return S_OK;
+ }
+
+ virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE setSlaveDispatchProvider(
+ /* [in] */ IDispatch __RPC_FAR *xNewDispatchProvider)
+ {
+ m_xSlave = xNewDispatchProvider;
+ return S_OK;
+ }
+
+ virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE getMasterDispatchProvider(
+ /* [retval][out] */ IDispatch __RPC_FAR *__RPC_FAR *retVal)
+ {
+ *retVal = m_xMaster;
+ return S_OK;
+ }
+
+ virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE setMasterDispatchProvider(
+ /* [in] */ IDispatch __RPC_FAR *xNewSupplier)
+ {
+ m_xMaster = xNewSupplier;
+ return S_OK;
+ }
+
+ virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE queryDispatch(
+ /* [in] */ IDispatch __RPC_FAR *aURL,
+ /* [in] */ BSTR aTargetFrameName,
+ /* [in] */ long nSearchFlags,
+ /* [retval][out] */ IDispatch __RPC_FAR *__RPC_FAR *retVal);
+
+ virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE queryDispatches(
+ /* [in] */ SAFEARRAY __RPC_FAR * aDescripts,
+ /* [retval][out] */ SAFEARRAY __RPC_FAR * __RPC_FAR *retVal);
+
+ virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE dispatch(
+ /* [in] */ IDispatch __RPC_FAR *aURL,
+ /* [in] */ SAFEARRAY __RPC_FAR * aArgs);
+
+ virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE addStatusListener(
+ /* [in] */ IDispatch __RPC_FAR *xControl,
+ /* [in] */ IDispatch __RPC_FAR *aURL);
+
+ virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE removeStatusListener(
+ /* [in] */ IDispatch __RPC_FAR *xControl,
+ /* [in] */ IDispatch __RPC_FAR *aURL);
+
+ virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE getInterceptedURLs(
+ /* [retval][out] */ SAFEARRAY __RPC_FAR * __RPC_FAR *pVal);
+
+ virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_Bridge_implementedInterfaces(
+ /* [retval][out] */ SAFEARRAY __RPC_FAR * __RPC_FAR *pVal)
+ {
+ *pVal = SafeArrayCreateVector( VT_BSTR, 0, 4 );
+
+ if( !*pVal )
+ return E_FAIL;
+
+ long ix = 0;
+ CComBSTR aInterface( OLESTR( "com.sun.star.frame.XDispatchProviderInterceptor" ) );
+ SafeArrayPutElement( *pVal, &ix, aInterface );
+
+ ix = 1;
+ aInterface = CComBSTR( OLESTR( "com.sun.star.frame.XDispatchProvider" ) );
+ SafeArrayPutElement( *pVal, &ix, aInterface );
+
+ ix = 2;
+ aInterface = CComBSTR( OLESTR( "com.sun.star.frame.XDispatch" ) );
+ SafeArrayPutElement( *pVal, &ix, aInterface );
+
+ ix = 3;
+ aInterface = CComBSTR( OLESTR( "com.sun.star.frame.XInterceptorInfo" ) );
+ SafeArrayPutElement( *pVal, &ix, aInterface );
+
+ return S_OK;
+ }
+};
+
+#endif // __SODISPATCHINTERCEPTOR_H_
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/activex/main/SODispatchInterceptor.rgs b/extensions/source/activex/main/SODispatchInterceptor.rgs
new file mode 100644
index 000000000000..19fe0b5f0e4c
--- /dev/null
+++ b/extensions/source/activex/main/SODispatchInterceptor.rgs
@@ -0,0 +1,23 @@
+HKCR
+{
+ so_activex.SODispatchInterceptor.1 = s 'SODispatchInterceptor Class'
+ {
+ CLSID = s '{C5D6D568-57DA-4D6C-819A-451CB565E682}'
+ }
+ so_activex.SODispatchInterceptor = s 'SODispatchInterceptor Class'
+ {
+ CLSID = s '{C5D6D568-57DA-4D6C-819A-451CB565E682}'
+ }
+ NoRemove CLSID
+ {
+ ForceRemove {C5D6D568-57DA-4D6C-819A-451CB565E682} = s 'SODispatchInterceptor Class'
+ {
+ ProgID = s 'so_activex.SODispatchInterceptor.1'
+ VersionIndependentProgID = s 'so_activex.SODispatchInterceptor'
+ InprocServer32 = s '%MODULE%'
+ {
+ val ThreadingModel = s 'both'
+ }
+ }
+ }
+}
diff --git a/extensions/source/activex/main/StdAfx2.cpp b/extensions/source/activex/main/StdAfx2.cpp
new file mode 100644
index 000000000000..f1cf88d10d14
--- /dev/null
+++ b/extensions/source/activex/main/StdAfx2.cpp
@@ -0,0 +1,21 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+// stdafx1.cpp : source file that includes just the standard includes
+// stdafx1.pch will be the pre-compiled header
+// stdafx1.obj will contain the pre-compiled type information
+
+#ifdef __MINGW32__
+#define _INIT_ATL_COMMON_VARS
+#endif
+#include "stdafx2.h"
+
+#ifdef _ATL_STATIC_REGISTRY
+#include <statreg.h>
+#include <statreg.cpp>
+#endif
+
+#if defined(_MSC_VER) && (_MSC_VER >= 1300)
+#undef _DEBUG
+#endif
+#include <atlimpl.cpp>
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/activex/main/StdAfx2.h b/extensions/source/activex/main/StdAfx2.h
new file mode 100644
index 000000000000..5c540b0ba329
--- /dev/null
+++ b/extensions/source/activex/main/StdAfx2.h
@@ -0,0 +1,45 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+// stdafx1.h : include file for standard system include files,
+// or project specific include files that are used frequently,
+// but are changed infrequently
+
+#if !defined(AFX_STDAFX_H__C1799EA0_62CC_44DE_A2DD_C9F0410FF7F1__INCLUDED_)
+#define AFX_STDAFX_H__C1799EA0_62CC_44DE_A2DD_C9F0410FF7F1__INCLUDED_
+
+#if _MSC_VER > 1000
+#pragma once
+#endif // _MSC_VER > 1000
+
+#define STRICT
+#ifndef _WIN32_WINNT
+#define _WIN32_WINNT 0x0400
+#endif
+#define _ATL_APARTMENT_THREADED
+#define _ATL_STATIC_REGISTRY
+
+#pragma warning (disable:4505)
+ // globally disable "unreferenced local function has been removed"
+
+#pragma warning (push,1)
+#pragma warning (disable:4548)
+ // expression before comma has no effect; expected expression with side-effect
+#pragma warning (disable:4555)
+ // expression has no effect; expected expression with side-effect
+
+#define min(a, b) (((a) < (b)) ? (a) : (b))
+#include <atlbase.h>
+
+//You may derive a class from CComModule and use it if you want to override
+//something, but do not change the name of _Module
+extern CComModule _Module;
+#include <atlcom.h>
+#include <atlctl.h>
+
+#pragma warning (pop)
+
+//{{AFX_INSERT_LOCATION}}
+// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
+
+#endif // !defined(AFX_STDAFX_H__C1799EA0_62CC_44DE_A2DD_C9F0410FF7F1__INCLUDED)
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/activex/main/com_uno_helper.h b/extensions/source/activex/main/com_uno_helper.h
new file mode 100644
index 000000000000..94573c645d16
--- /dev/null
+++ b/extensions/source/activex/main/com_uno_helper.h
@@ -0,0 +1,26 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+#include "stdafx2.h"
+
+HRESULT ExecuteFunc( IDispatch* idispUnoObject,
+ OLECHAR* sFuncName,
+ CComVariant* params,
+ unsigned int count,
+ CComVariant* pResult );
+
+HRESULT GetIDispByFunc( IDispatch* idispUnoObject,
+ OLECHAR* sFuncName,
+ CComVariant* params,
+ unsigned int count,
+ CComPtr<IDispatch>& pdispResult );
+
+HRESULT PutPropertiesToIDisp( IDispatch* pdispObject,
+ OLECHAR** sMemberNames,
+ CComVariant* pVariant,
+ unsigned int count );
+
+HRESULT GetPropertiesFromIDisp( IDispatch* pdispObject,
+ OLECHAR** sMemberNames,
+ CComVariant* pVariant,
+ unsigned int count );
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/activex/main/example.html b/extensions/source/activex/main/example.html
new file mode 100644
index 000000000000..3efee1f75a03
--- /dev/null
+++ b/extensions/source/activex/main/example.html
@@ -0,0 +1,26 @@
+<HTML>
+<HEAD>
+<TITLE>Document Title</TITLE>
+</HEAD>
+<BODY>
+
+<center>
+First you should edit the example.html file!!!
+</center>
+<center>
+<!-- Please edit CODEBASE parameter -->
+<!-- In case ActiveX control is already registered the parameter can be removed -->
+<OBJECT CLASSID="clsid:67F2A879-82D5-4A6D-8CC5-FFB3C114B69D" width="500" height="500"
+ CODEBASE="..\..\..\WINexample.out\bin\so_activex.dll">
+<!-- Full URL to a document
+ <PARAM NAME="src" VALUE="file:///d:/example.sxw">
+-->
+<!-- Just view the document, do not edit
+ <PARAM NAME="readonly" VALUE="true">
+-->
+</OBJECT>
+
+</center>
+
+</BODY>
+</HTML>
diff --git a/extensions/source/activex/main/makefile.mk b/extensions/source/activex/main/makefile.mk
new file mode 100644
index 000000000000..e4770180886c
--- /dev/null
+++ b/extensions/source/activex/main/makefile.mk
@@ -0,0 +1,155 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ=..$/..$/..
+PRJNAME=extensions
+TARGET=so_activex
+
+use_shl_versions=
+
+# --- Settings ----------------------------------
+.IF "$(GUI)" == "WNT" && "$(DISABLE_ACTIVEX)"==""
+PROF_EDITION=TRUE
+.ENDIF
+
+.INCLUDE : settings.mk
+
+.IF "$(GUI)" == "WNT" && "$(DISABLE_ACTIVEX)"==""
+
+VERSIONOBJ=
+LIBTARGET=NO
+USE_DEFFILE=YES
+UWINAPILIB=
+
+.IF "$(BUILD_X64)"!=""
+USE_DEFFILE_X64=TRUE
+.ENDIF
+
+INCPRE+=$(foreach,i,$(ATL_INCLUDE) -I$(i)) \
+ -I$(MISC) \
+
+# --- Files -------------------------------------
+
+
+.IF "$(PRODUCT)"!=""
+RC+=-DPRODUCT
+.ENDIF
+
+RCFILES=\
+ $(TARGET).rc
+RCDEPN=$(MISC)$/envsettings.h
+
+SLOFILES=\
+ $(SLO)$/so_activex.obj \
+ $(SLO)$/SOActiveX.obj \
+ $(SLO)$/SOComWindowPeer.obj \
+ $(SLO)$/SODispatchInterceptor.obj \
+ $(SLO)$/SOActionsApproval.obj \
+ $(SLO)$/StdAfx2.obj
+
+SHL1TARGET=$(TARGET)
+SHL1STDLIBS=\
+ $(UUIDLIB) \
+ $(ADVAPI32LIB) \
+ $(OLE32LIB) \
+ $(OLEAUT32LIB) \
+ $(GDI32LIB) \
+ $(URLMONLIB) \
+ $(SHLWAPILIB)
+
+.IF "$(COM)"!="GCC"
+.IF "$(CCNUMVER)" > "001300000000"
+ SHL1STDLIBS+= $(ATL_LIB)$/atls.lib
+.ENDIF
+.ENDIF
+
+
+# $(KERNEL32LIB) \
+# rpcndr.lib \
+# rpcns4.lib \
+# rpcrt4.lib
+
+#$(KERNEL32LIB) rpcndr.lib rpcns4.lib rpcrt4.lib
+
+SHL1OBJS=$(SLOFILES)
+
+SHL1LIBS=
+SHL1DEF=$(TARGET).def
+SHL1RES=$(RES)$/$(TARGET).res
+
+.ENDIF
+
+.IF "$(BUILD_X64)"!=""
+# -------------------- x64 -----------------------
+
+CDEFS_X64+:=$(foreach,i,$(CDEFS) $(subst,-D_X86_=1, $i))
+LIBTARGET_X64=NO
+USE_DEFFILE_X64=YES
+UWINAPILIB_X64=
+
+SLOFILES_X64= \
+ $(SLO_X64)$/so_activex.obj \
+ $(SLO_X64)$/SOActiveX.obj \
+ $(SLO_X64)$/SOComWindowPeer.obj \
+ $(SLO_X64)$/SODispatchInterceptor.obj \
+ $(SLO_X64)$/SOActionsApproval.obj \
+ $(SLO_X64)$/StdAfx2.obj
+
+SHL1TARGET_X64=$(TARGET)
+
+SHL1STDLIBS_X64+=\
+ $(UUIDLIB_X64) \
+ $(ADVAPI32LIB_X64) \
+ $(OLE32LIB_X64) \
+ $(OLEAUT32LIB_X64) \
+ $(GDI32LIB_X64) \
+ $(URLMONLIB_X64) \
+ $(SHLWAPILIB_X64) \
+ $(KERNEL32LIB_X64) \
+ $(USER32LIB_X64) \
+ $(MSVCRT_X64) \
+ $(MSVCPRT_X64) \
+ $(OLDNAMESLIB_X64)
+
+SHL1OBJS_X64=$(SLOFILES_X64)
+SHL1DEF_X64=$(TARGET).def
+
+SHL1STDLIBS_X64+= $(ATL_LIB)$/amd64$/atls.lib
+
+.ENDIF # "$(BUILD_X64)"!=""
+
+# --- Targets ----------------------------------
+
+.INCLUDE : set_wntx64.mk
+VERSIONOBJ_X64=
+.INCLUDE : target.mk
+.INCLUDE : tg_wntx64.mk
+
+$(MISC)$/envsettings.h : makefile.mk
+ -$(RM) $@
+# it looks wrong; but rc likes it that way...
+ echo "#define MISC .\..\$(INPATH)\misc" > $@
diff --git a/extensions/source/activex/main/resource.h b/extensions/source/activex/main/resource.h
new file mode 100644
index 000000000000..a80234031fb0
--- /dev/null
+++ b/extensions/source/activex/main/resource.h
@@ -0,0 +1,28 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+//{{NO_DEPENDENCIES}}
+// Microsoft Developer Studio generated include file.
+// Used by so_activex.rc
+//
+#define IDS_PROJNAME 100
+#define IDB_SOACTIVEX 101
+#define IDR_SOACTIVEX 102
+#define IDB_SOCOMWINDOWPEER 103
+#define IDR_SOCOMWINDOWPEER 104
+#define IDB_SODISPATCHINTERCEPTOR 105
+#define IDR_SODISPATCHINTERCEPTOR 106
+#define IDB_SODOCUMENTEVENTLISTENER 107
+#define IDR_SODOCUMENTEVENTLISTENER 108
+
+
+// Next default values for new objects
+//
+#ifdef APSTUDIO_INVOKED
+#ifndef APSTUDIO_READONLY_SYMBOLS
+#define _APS_NEXT_RESOURCE_VALUE 201
+#define _APS_NEXT_COMMAND_VALUE 32768
+#define _APS_NEXT_CONTROL_VALUE 201
+#define _APS_NEXT_SYMED_VALUE 107
+#endif
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/activex/main/so_activex.cpp b/extensions/source/activex/main/so_activex.cpp
new file mode 100644
index 000000000000..a681d18f6ffa
--- /dev/null
+++ b/extensions/source/activex/main/so_activex.cpp
@@ -0,0 +1,692 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+// so_activex.cpp : Implementation of DLL Exports.
+
+
+// Note: Proxy/Stub Information
+// To build a separate proxy/stub DLL,
+// run nmake -f so_activexps.mk in the project directory.
+
+#include "stdio.h"
+#include "stdafx2.h"
+#include "resource.h"
+#include <initguid.h>
+#include "so_activex.h"
+
+#include "so_activex_i.c"
+#include "SOActiveX.h"
+
+#include <comphelper\documentconstants.hxx>
+
+// #define MY_DEBUG 1
+
+CComModule _Module;
+
+BEGIN_OBJECT_MAP(ObjectMap)
+OBJECT_ENTRY(CLSID_SOActiveX, CSOActiveX)
+END_OBJECT_MAP()
+
+
+#define X64_LIB_NAME "so_activex_x64.dll"
+#define X32_LIB_NAME "so_activex.dll"
+
+// 06.11.2009 tkr: to provide windows xp as build systems for mingw we need to define KEY_WOW64_64KEY
+// in mingw 3.13 KEY_WOW64_64KEY isn't available < Win2003 systems.
+// Also defined in setup_native\source\win32\customactions\reg64\reg64.cxx,source\win32\customactions\shellextensions\shellextensions.cxx and
+// extensions\source\activex\main\so_activex.cpp
+#ifndef KEY_WOW64_64KEY
+ #define KEY_WOW64_64KEY (0x0100)
+#endif
+#ifndef KEY_WOW64_32KEY
+ #define KEY_WOW64_32KEY (0x0200)
+#endif
+
+const REGSAM n64KeyAccess = KEY_ALL_ACCESS | KEY_WOW64_64KEY;
+const REGSAM n32KeyAccess = KEY_ALL_ACCESS;
+
+#ifdef _AMD64_
+const BOOL bX64 = TRUE;
+#define REG_DELETE_KEY_A( key, aPath, nKeyAccess ) RegDeleteKeyExA( key, aPath, nKeyAccess, 0 )
+#else
+const BOOL bX64 = FALSE;
+#define REG_DELETE_KEY_A( key, aPath, nKeyAccess ) RegDeleteKeyA( key, aPath )
+#endif
+
+// 10.11.2009 tkr: MinGW doesn't know anything about RegDeleteKeyExA if WINVER < 0x0502.
+extern "C" {
+WINADVAPI LONG WINAPI RegDeleteKeyExA(HKEY,LPCSTR,REGSAM,DWORD);
+}
+
+/////////////////////////////////////////////////////////////////////////////
+// DLL Entry Point
+
+extern "C"
+BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/)
+{
+ if (dwReason == DLL_PROCESS_ATTACH)
+ {
+ _Module.Init(ObjectMap, hInstance, &LIBID_SO_ACTIVEXLib);
+ DisableThreadLibraryCalls(hInstance);
+ }
+ else if (dwReason == DLL_PROCESS_DETACH)
+ _Module.Term();
+ return TRUE; // ok
+}
+
+/////////////////////////////////////////////////////////////////////////////
+// Used to determine whether the DLL can be unloaded by OLE
+
+STDAPI DllCanUnloadNow(void)
+{
+ return (_Module.GetLockCount()==0) ? S_OK : S_FALSE;
+}
+
+/////////////////////////////////////////////////////////////////////////////
+// Returns a class factory to create an object of the requested type
+
+STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv)
+{
+ return _Module.GetClassObject(rclsid, riid, ppv);
+}
+
+/////////////////////////////////////////////////////////////////////////////
+// DllRegisterServer - Adds entries to the system registry
+
+// for now database component and chart are always installed
+#define SUPPORTED_EXT_NUM 30
+const char* aFileExt[] = { ".vor",
+ ".sds", ".sda", ".sdd", ".sdp", ".sdc", ".sdw", ".smf",
+ ".stw", ".stc", ".sti", ".std",
+ ".sxw", ".sxc", ".sxi", ".sxd", ".sxg", ".sxm",
+ ".ott", ".otg", ".otp", ".ots", ".otf",
+ ".odt", ".oth", ".odm", ".odg", ".odp", ".ods", ".odf"};
+const char* aMimeType[] = {
+ "application/vnd.stardivision.writer",
+
+ "application/vnd.stardivision.chart",
+ "application/vnd.stardivision.draw",
+ "application/vnd.stardivision.impress",
+ "application/vnd.stardivision.impress-packed",
+ "application/vnd.stardivision.calc",
+ "application/vnd.stardivision.writer",
+ "application/vnd.stardivision.math",
+
+ MIMETYPE_VND_SUN_XML_WRITER_TEMPLATE_ASCII,
+ MIMETYPE_VND_SUN_XML_CALC_TEMPLATE_ASCII,
+ MIMETYPE_VND_SUN_XML_IMPRESS_TEMPLATE_ASCII,
+ MIMETYPE_VND_SUN_XML_DRAW_TEMPLATE_ASCII,
+
+ MIMETYPE_VND_SUN_XML_WRITER_ASCII,
+ MIMETYPE_VND_SUN_XML_CALC_ASCII,
+ MIMETYPE_VND_SUN_XML_IMPRESS_ASCII,
+ MIMETYPE_VND_SUN_XML_DRAW_ASCII,
+ MIMETYPE_VND_SUN_XML_WRITER_GLOBAL_ASCII,
+ MIMETYPE_VND_SUN_XML_MATH_ASCII,
+
+ MIMETYPE_OASIS_OPENDOCUMENT_TEXT_TEMPLATE_ASCII,
+ MIMETYPE_OASIS_OPENDOCUMENT_DRAWING_TEMPLATE_ASCII,
+ MIMETYPE_OASIS_OPENDOCUMENT_PRESENTATION_TEMPLATE_ASCII,
+ MIMETYPE_OASIS_OPENDOCUMENT_SPREADSHEET_TEMPLATE_ASCII,
+ MIMETYPE_OASIS_OPENDOCUMENT_FORMULA_TEMPLATE_ASCII,
+
+ MIMETYPE_OASIS_OPENDOCUMENT_TEXT_ASCII,
+ MIMETYPE_OASIS_OPENDOCUMENT_TEXT_WEB_ASCII,
+ MIMETYPE_OASIS_OPENDOCUMENT_TEXT_GLOBAL_ASCII,
+ MIMETYPE_OASIS_OPENDOCUMENT_DRAWING_ASCII,
+ MIMETYPE_OASIS_OPENDOCUMENT_PRESENTATION_ASCII,
+ MIMETYPE_OASIS_OPENDOCUMENT_SPREADSHEET_ASCII,
+ MIMETYPE_OASIS_OPENDOCUMENT_FORMULA_ASCII };
+
+const int nForModes[] = { 16,
+ 1, 2, 4, 4, 8, 16, 32,
+ 16, 8, 4, 2,
+ 16, 8, 4, 2, 16, 32,
+ 16, 2, 4, 8, 32,
+ 16, 16, 16, 2, 4, 8, 32 };
+
+const char* aClassID = "{67F2A879-82D5-4A6D-8CC5-FFB3C114B69D}";
+const char* aTypeLib = "{61FA3F13-8061-4796-B055-3697ED28CB38}";
+
+// ISOComWindowPeer interface information
+const char* aInterIDWinPeer = "{BF5D10F3-8A10-4A0B-B150-2B6AA2D7E118}";
+const char* aProxyStubWinPeer = "{00020424-0000-0000-C000-000000000046}";
+
+// ISODispatchInterceptor interface information
+const char* aInterIDDispInt = "{9337694C-B27D-4384-95A4-9D8E0EABC9E5}";
+const char* aProxyStubDispInt = "{00020424-0000-0000-C000-000000000046}";
+
+// ISOActionsApproval interface information
+const char* aInterIDActApprove = "{029E9F1E-2B3F-4297-9160-8197DE7ED54F}";
+const char* aProxyStubActApprove = "{00020424-0000-0000-C000-000000000046}";
+
+// The following prefix is required for HKEY_LOCAL_MACHINE and HKEY_CURRENT_USER ( not for HKEY_CLASSES_ROOT )
+const char* aLocalPrefix = "Software\\Classes\\";
+
+BOOL createKey( HKEY hkey,
+ const char* aKeyToCreate,
+ REGSAM nKeyAccess,
+ const char* aValue = NULL,
+ const char* aChildName = NULL,
+ const char* aChildValue = NULL )
+{
+ HKEY hkey1;
+
+ return ( ERROR_SUCCESS == RegCreateKeyExA( hkey, aKeyToCreate, 0, NULL, REG_OPTION_NON_VOLATILE, nKeyAccess, NULL, &hkey1 , NULL )
+ && ( !aValue || ERROR_SUCCESS == RegSetValueExA( hkey1,
+ "",
+ 0,
+ REG_SZ,
+ (const BYTE*)aValue,
+ strlen( aValue ) ) )
+ && ( !aChildName || ERROR_SUCCESS == RegSetValueExA( hkey1,
+ aChildName,
+ 0,
+ REG_SZ,
+ (const BYTE*)aChildValue,
+ strlen( aChildValue ) ) )
+ && ERROR_SUCCESS == RegCloseKey( hkey1 ) );
+
+}
+
+STDAPI DllUnregisterServerNative( int nMode, BOOL bForAllUsers, BOOL bFor64Bit );
+STDAPI DllRegisterServerNative_Impl( int nMode, BOOL bForAllUsers, REGSAM nKeyAccess, const char* pProgramPath, const char* pLibName )
+{
+ BOOL aResult = FALSE;
+
+ HKEY hkey = NULL;
+ HKEY hkey1 = NULL;
+ HKEY hkey2 = NULL;
+ HKEY hkey3 = NULL;
+ HKEY hkey4 = NULL;
+ char aSubKey[513];
+ int ind;
+ const char* aPrefix = aLocalPrefix; // bForAllUsers ? "" : aLocalPrefix;
+
+ char pActiveXPath[1124];
+ char pActiveXPath101[1124];
+
+
+ // In case SO7 is installed for this user he can have local registry entries that will prevent him from
+ // using SO8 ActiveX control. The fix is just to clean up the local entries related to ActiveX control.
+ // Unfortunately it can be done only for the user who installs the office.
+ if ( bForAllUsers )
+ DllUnregisterServerNative( nMode, sal_False, sal_False );
+
+#ifdef MY_DEBUG
+ MessageBoxA(NULL, pProgramPath, "Library Path, ( from library )", MB_OK | MB_ICONINFORMATION);
+#endif
+
+ if ( pProgramPath && strlen( pProgramPath ) < 1024 )
+ {
+ sprintf( pActiveXPath, "%s\\%s", pProgramPath, pLibName );
+ sprintf( pActiveXPath101, "%s\\%s, 101", pProgramPath, pLibName );
+
+ {
+ wsprintfA( aSubKey, "%sCLSID\\%s", aPrefix, aClassID );
+ aResult =
+ ( ERROR_SUCCESS == RegCreateKeyExA( bForAllUsers ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER, aSubKey, 0, NULL, REG_OPTION_NON_VOLATILE, nKeyAccess, NULL, &hkey , NULL )
+ && ERROR_SUCCESS == RegSetValueExA( hkey, "", 0, REG_SZ, (const BYTE*)"SOActiveX Class", 17 )
+ && createKey( hkey, "Control", nKeyAccess )
+ && createKey( hkey, "EnableFullPage", nKeyAccess )
+ && createKey( hkey, "InprocServer32", nKeyAccess, pActiveXPath, "ThreadingModel", "Apartment" )
+ && createKey( hkey, "MiscStatus", nKeyAccess, "0" )
+ && createKey( hkey, "MiscStatus\\1", nKeyAccess, "131473" )
+ && createKey( hkey, "ProgID", nKeyAccess, "so_activex.SOActiveX.1" )
+ && createKey( hkey, "Programmable", nKeyAccess )
+ && createKey( hkey, "ToolboxBitmap32", nKeyAccess, pActiveXPath101 )
+ && createKey( hkey, "TypeLib", nKeyAccess, aTypeLib )
+ && createKey( hkey, "Version", nKeyAccess, "1.0" )
+ && createKey( hkey, "VersionIndependentProgID", nKeyAccess, "so_activex.SOActiveX" )
+ && ERROR_SUCCESS == RegCloseKey( hkey )
+ && ERROR_SUCCESS == RegCreateKeyExA( bForAllUsers ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER, aPrefix, 0, NULL, REG_OPTION_NON_VOLATILE, nKeyAccess, NULL, &hkey , NULL )
+ && createKey( hkey, "so_activex.SOActiveX", nKeyAccess, "SOActiveX Class" )
+ && ERROR_SUCCESS == RegCreateKeyExA( hkey, "so_activex.SOActiveX", 0, NULL, REG_OPTION_NON_VOLATILE, nKeyAccess, NULL, &hkey1 , NULL )
+ && createKey( hkey1, "CLSID", nKeyAccess, aClassID )
+ && createKey( hkey1, "CurVer", nKeyAccess, "so_activex.SOActiveX.1" )
+ && ERROR_SUCCESS == RegCloseKey( hkey1 )
+ && createKey( hkey, "so_activex.SOActiveX.1", nKeyAccess, "SOActiveX Class" )
+ && ERROR_SUCCESS == RegCreateKeyExA( hkey, "so_activex.SOActiveX.1", 0, NULL, REG_OPTION_NON_VOLATILE, nKeyAccess, NULL, &hkey1 , NULL )
+ && createKey( hkey1, "CLSID", nKeyAccess, aClassID )
+ && ERROR_SUCCESS == RegCloseKey( hkey1 )
+ && ERROR_SUCCESS == RegCreateKeyExA( hkey, "TypeLib", 0, NULL, REG_OPTION_NON_VOLATILE, nKeyAccess, NULL, &hkey1 , NULL )
+ && ERROR_SUCCESS == RegCreateKeyExA( hkey1, aTypeLib, 0, NULL, REG_OPTION_NON_VOLATILE, nKeyAccess, NULL, &hkey2 , NULL )
+ && createKey( hkey2, "1.0", nKeyAccess, "wrap_activex 1.0 Type Library" )
+ && ERROR_SUCCESS == RegCreateKeyExA( hkey2, "1.0", 0, NULL, REG_OPTION_NON_VOLATILE, nKeyAccess, NULL, &hkey3 , NULL )
+ && ERROR_SUCCESS == RegCreateKeyExA( hkey3, "0", 0, NULL, REG_OPTION_NON_VOLATILE, nKeyAccess, NULL, &hkey4 , NULL )
+ && createKey( hkey4, "win32", nKeyAccess, pActiveXPath )
+ && ERROR_SUCCESS == RegCloseKey( hkey4 )
+ && createKey( hkey3, "FLAGS", nKeyAccess, "0" )
+ && createKey( hkey3, "HELPDIR", nKeyAccess, pProgramPath )
+ && ERROR_SUCCESS == RegCloseKey( hkey3 )
+ && ERROR_SUCCESS == RegCloseKey( hkey2 )
+ && ERROR_SUCCESS == RegCloseKey( hkey1 )
+ && ERROR_SUCCESS == RegCreateKeyExA( hkey, "Interface", 0, NULL, REG_OPTION_NON_VOLATILE, nKeyAccess, NULL, &hkey1 , NULL )
+ && createKey( hkey1, aInterIDWinPeer, nKeyAccess, "ISOComWindowPeer" )
+ && ERROR_SUCCESS == RegCreateKeyExA( hkey1, aInterIDWinPeer, 0, NULL, REG_OPTION_NON_VOLATILE, nKeyAccess, NULL, &hkey2 , NULL )
+ && createKey( hkey2, "ProxyStubClsid", nKeyAccess, aProxyStubWinPeer )
+ && createKey( hkey2, "ProxyStubClsid32", nKeyAccess, aProxyStubWinPeer )
+ && createKey( hkey2, "TypeLib", nKeyAccess, aTypeLib, "Version", "1.0" )
+ && ERROR_SUCCESS == RegCloseKey( hkey2 )
+ && createKey( hkey1, aInterIDActApprove, nKeyAccess, "ISOActionsApproval" )
+ && ERROR_SUCCESS == RegCreateKeyExA( hkey1, aInterIDActApprove, 0, NULL, REG_OPTION_NON_VOLATILE, nKeyAccess, NULL, &hkey2 , NULL )
+ && createKey( hkey2, "ProxyStubClsid", nKeyAccess, aProxyStubActApprove )
+ && createKey( hkey2, "ProxyStubClsid32", nKeyAccess, aProxyStubActApprove )
+ && createKey( hkey2, "TypeLib", nKeyAccess, aTypeLib, "Version", "1.0" )
+ && ERROR_SUCCESS == RegCloseKey( hkey2 )
+ && createKey( hkey1, aInterIDDispInt, nKeyAccess, "ISODispatchInterceptor" )
+ && ERROR_SUCCESS == RegCreateKeyExA( hkey1, aInterIDDispInt, 0, NULL, REG_OPTION_NON_VOLATILE, nKeyAccess, NULL, &hkey2 , NULL )
+ && createKey( hkey2, "ProxyStubClsid", nKeyAccess, aProxyStubDispInt )
+ && createKey( hkey2, "ProxyStubClsid32", nKeyAccess, aProxyStubDispInt )
+ && createKey( hkey2, "TypeLib", nKeyAccess, aTypeLib, "Version", "1.0" )
+ && ERROR_SUCCESS == RegCloseKey( hkey2 )
+ && ERROR_SUCCESS == RegCloseKey( hkey1 )
+ && ERROR_SUCCESS == RegCloseKey( hkey ) );
+
+ hkey = hkey1 = hkey2 = hkey3 = hkey4 = NULL;
+ }
+ }
+
+ for( ind = 0; ind < SUPPORTED_EXT_NUM && aResult; ind++ )
+ {
+ if( nForModes[ind] & nMode )
+ {
+ wsprintfA( aSubKey, "%sMIME\\DataBase\\Content Type\\%s", aPrefix, aMimeType[ind] );
+ if ( ERROR_SUCCESS != RegCreateKeyExA( bForAllUsers ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER, aSubKey, 0, NULL, REG_OPTION_NON_VOLATILE, nKeyAccess, NULL, &hkey, NULL )
+// || ERROR_SUCCESS != RegSetValueExA(hkey, "Extension", 0, REG_SZ,
+// (const BYTE *)aFileExt[ind], strlen( aFileExt[ind] ) )
+ || ERROR_SUCCESS != RegSetValueExA(hkey, "CLSID", 0, REG_SZ,
+ (const BYTE *)aClassID, strlen(aClassID)) )
+ aResult = FALSE;
+
+ if( hkey )
+ RegCloseKey(hkey),hkey= NULL;
+
+/*
+ wsprintfA( aSubKey, "%s%s", aPrefix, aFileExt[ind] );
+ if ( ERROR_SUCCESS != RegCreateKeyExA( bForAllUsers ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER, aSubKey, 0, NULL, REG_OPTION_NON_VOLATILE, nKeyAccess, NULL, &hkey, NULL )
+ || ERROR_SUCCESS != RegSetValueExA(hkey, "Content Type", 0, REG_SZ,
+ (const BYTE *)aMimeType[ind], strlen( aMimeType[ind] ) ) )
+ aResult = FALSE;
+ if( hkey )
+ RegCloseKey(hkey),hkey= NULL;
+*/
+ }
+ }
+
+ wsprintfA( aSubKey, "%sCLSID\\%s", aPrefix, aClassID );
+ if ( aResult && ERROR_SUCCESS == RegOpenKeyExA(bForAllUsers ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER, aSubKey, 0, nKeyAccess, &hkey) )
+ {
+ for( ind = 0; ind < SUPPORTED_EXT_NUM; ind++ )
+ {
+ wsprintfA( aSubKey, "EnableFullPage\\%s", aFileExt[ind] );
+ if ( ERROR_SUCCESS != RegCreateKeyExA( hkey, aSubKey, 0, NULL, REG_OPTION_NON_VOLATILE, nKeyAccess, NULL, &hkey1 , NULL ) )
+ aResult = FALSE;
+
+ if ( hkey1 )
+ RegCloseKey(hkey1),hkey1= NULL;
+ }
+ }
+ else
+ aResult = FALSE;
+
+ if ( hkey )
+ RegCloseKey(hkey),hkey= NULL;
+
+ return aResult;
+}
+
+STDAPI DllRegisterServerNative( int nMode, BOOL bForAllUsers, BOOL bFor64Bit, const char* pProgramPath )
+{
+ HRESULT hr = S_OK;
+ if ( bFor64Bit )
+ hr = DllRegisterServerNative_Impl( nMode, bForAllUsers, n64KeyAccess, pProgramPath, X64_LIB_NAME );
+
+ if ( SUCCEEDED( hr ) )
+ hr = DllRegisterServerNative_Impl( nMode, bForAllUsers, n32KeyAccess, pProgramPath, X32_LIB_NAME );
+
+ return hr;
+}
+
+
+/////////////////////////////////////////////////////////////////////////////
+// DllUnregisterServer - Removes entries from the system registry
+HRESULT DeleteKeyTree( HKEY hkey, const char* pPath, REGSAM nKeyAccess )
+{
+ HKEY hkey1 = NULL;
+
+ char pSubKeyName[256];
+ // first delete the subkeys
+ while( ERROR_SUCCESS == RegOpenKeyExA( hkey, pPath, 0, nKeyAccess, &hkey1)
+ && ERROR_SUCCESS == RegEnumKeyA( hkey1, 0, pSubKeyName, 256 )
+ && ERROR_SUCCESS == DeleteKeyTree( hkey1, pSubKeyName, nKeyAccess ) )
+ {
+ RegCloseKey( hkey1 ),hkey1= NULL;
+ }
+
+ if ( hkey1 )
+ RegCloseKey( hkey1 ),hkey1= NULL;
+
+ // delete the key itself
+ return REG_DELETE_KEY_A( hkey, pPath, nKeyAccess & ( KEY_WOW64_64KEY | KEY_WOW64_32KEY ) );
+}
+
+STDAPI DllUnregisterServerNative_Impl( int nMode, BOOL bForAllUsers, REGSAM nKeyAccess )
+{
+ HKEY hkey = NULL;
+ BOOL fErr = FALSE;
+ char aSubKey[513];
+ const char* aPrefix = aLocalPrefix; // bForAllUsers ? "" : aLocalPrefix;
+
+ for( int ind = 0; ind < SUPPORTED_EXT_NUM; ind++ )
+ {
+ if( nForModes[ind] & nMode )
+ {
+ DWORD nSubKeys = 0, nValues = 0;
+ wsprintfA( aSubKey, "%sMIME\\DataBase\\Content Type\\%s", aPrefix, aMimeType[ind] );
+ if ( ERROR_SUCCESS != RegCreateKeyExA( bForAllUsers ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER, aSubKey, 0, NULL, REG_OPTION_NON_VOLATILE, nKeyAccess, NULL, &hkey, NULL ) )
+ fErr = TRUE;
+ else
+ {
+ if ( ERROR_SUCCESS != RegDeleteValue( hkey, "CLSID" ) )
+ fErr = TRUE;
+
+ if ( ERROR_SUCCESS != RegQueryInfoKey( hkey, NULL, NULL, NULL,
+ &nSubKeys, NULL, NULL,
+ &nValues, NULL, NULL, NULL, NULL ) )
+ {
+ RegCloseKey( hkey ), hkey = NULL;
+ fErr = TRUE;
+ }
+ else
+ {
+ RegCloseKey( hkey ), hkey = NULL;
+ if ( !nSubKeys && !nValues )
+ DeleteKeyTree( bForAllUsers ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER, aSubKey, nKeyAccess );
+ }
+ }
+
+ wsprintfA( aSubKey, "%s%s", aPrefix, aFileExt[ind] );
+ if ( ERROR_SUCCESS != RegCreateKeyExA( bForAllUsers ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER, aSubKey, 0, NULL, REG_OPTION_NON_VOLATILE, nKeyAccess, NULL, &hkey, NULL ) )
+ fErr = TRUE;
+ else
+ {
+ if ( ERROR_SUCCESS != RegQueryInfoKey( hkey, NULL, NULL, NULL,
+ &nSubKeys, NULL, NULL,
+ &nValues, NULL, NULL, NULL, NULL ) )
+ {
+ RegCloseKey( hkey ), hkey = NULL;
+ fErr = TRUE;
+ }
+ else
+ {
+ RegCloseKey( hkey ), hkey = NULL;
+ if ( !nSubKeys && !nValues )
+ DeleteKeyTree( bForAllUsers ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER, aSubKey, nKeyAccess );
+ }
+ }
+ }
+ }
+
+ wsprintfA( aSubKey, "%sCLSID\\%s", aPrefix, aClassID );
+ if( ERROR_SUCCESS != DeleteKeyTree( bForAllUsers ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER, aSubKey, nKeyAccess ) )
+ fErr = TRUE;
+
+ wsprintfA( aSubKey, "%sso_activex.SOActiveX", aPrefix );
+ if( ERROR_SUCCESS != DeleteKeyTree( bForAllUsers ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER, aSubKey, nKeyAccess ) )
+ fErr = TRUE;
+
+ wsprintfA( aSubKey, "%sso_activex.SOActiveX.1", aPrefix );
+ if( ERROR_SUCCESS != DeleteKeyTree( bForAllUsers ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER, aSubKey, nKeyAccess ) )
+ fErr = TRUE;
+
+ wsprintfA( aSubKey, "%s\\TypeLib\\%s", aPrefix, aTypeLib );
+ if( ERROR_SUCCESS != DeleteKeyTree( bForAllUsers ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER, aSubKey, nKeyAccess ) )
+ fErr = TRUE;
+
+ wsprintfA( aSubKey, "%s\\Interface\\%s", aPrefix, aInterIDWinPeer );
+ if( ERROR_SUCCESS != DeleteKeyTree( bForAllUsers ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER, aSubKey, nKeyAccess ) )
+ fErr = TRUE;
+
+ wsprintfA( aSubKey, "%s\\Interface\\%s", aPrefix, aInterIDDispInt );
+ if( ERROR_SUCCESS != DeleteKeyTree( bForAllUsers ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER, aSubKey, nKeyAccess ) )
+ fErr = TRUE;
+
+ wsprintfA( aSubKey, "%s\\Interface\\%s", aPrefix, aInterIDActApprove );
+ if( ERROR_SUCCESS != DeleteKeyTree( bForAllUsers ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER, aSubKey, nKeyAccess ) )
+ fErr = TRUE;
+
+ return !fErr;
+}
+
+STDAPI DllUnregisterServerNative( int nMode, BOOL bForAllUsers, BOOL bFor64Bit )
+{
+ HRESULT hr = DllUnregisterServerNative_Impl( nMode, bForAllUsers, n32KeyAccess );
+ if ( SUCCEEDED( hr ) && bFor64Bit )
+ hr = DllUnregisterServerNative_Impl( nMode, bForAllUsers, n64KeyAccess );
+
+ return hr;
+}
+
+
+/////////////////////////////////////////////////////////////////////////////
+// DllRegisterServerDoc - Adds entries to the system registry
+
+#define SUPPORTED_MSEXT_NUM 7
+const char* aMSFileExt[] = { ".dot", ".doc", ".xlt", ".xls", ".pot", ".ppt", ".pps" };
+const char* aMSMimeType[] = { "application/msword",
+ "application/msword",
+ "application/msexcell",
+ "application/msexcell",
+ "application/mspowerpoint",
+ "application/mspowerpoint",
+ "application/mspowerpoint" };
+const int nForMSModes[] = { 1, 1, 2, 2, 4, 4, 4 };
+
+STDAPI DllUnregisterServerDoc( int nMode, BOOL bForAllUsers, BOOL bFor64Bit );
+STDAPI DllRegisterServerDoc_Impl( int nMode, BOOL bForAllUsers, REGSAM nKeyAccess )
+{
+ BOOL aResult = TRUE;
+
+ HKEY hkey = NULL;
+ HKEY hkey1 = NULL;
+ char aSubKey[513];
+ int ind;
+ const char* aPrefix = aLocalPrefix; // bForAllUsers ? "" : aLocalPrefix;
+
+ // In case SO7 is installed for this user he can have local registry entries that will prevent him from
+ // using SO8 ActiveX control. The fix is just to clean up the local entries related to ActiveX control.
+ // Unfortunately it can be done only for the user who installs the office.
+ if ( bForAllUsers )
+ DllUnregisterServerDoc( nMode, sal_False, sal_False );
+
+ for( ind = 0; ind < SUPPORTED_MSEXT_NUM && aResult; ind++ )
+ {
+ if( nForMSModes[ind] & nMode )
+ {
+ wsprintfA( aSubKey, "%sMIME\\DataBase\\Content Type\\%s", aPrefix, aMSMimeType[ind] );
+ if ( ERROR_SUCCESS != RegCreateKeyExA( bForAllUsers ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER, aSubKey, 0, NULL, REG_OPTION_NON_VOLATILE, nKeyAccess, NULL, &hkey, NULL )
+ || ERROR_SUCCESS != RegSetValueExA(hkey, "Extension", 0, REG_SZ,
+ (const BYTE *)aMSFileExt[ind], strlen( aMSFileExt[ind] ) )
+ || ERROR_SUCCESS != RegSetValueExA(hkey, "CLSID", 0, REG_SZ,
+ (const BYTE *)aClassID, strlen(aClassID)) )
+ aResult = FALSE;
+
+ if( hkey )
+ RegCloseKey(hkey),hkey= NULL;
+
+ wsprintfA( aSubKey, "%s%s", aPrefix, aMSFileExt[ind] );
+ if ( ERROR_SUCCESS != RegCreateKeyExA( bForAllUsers ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER, aSubKey, 0, NULL, REG_OPTION_NON_VOLATILE, nKeyAccess, NULL, &hkey, NULL )
+ || ERROR_SUCCESS != RegSetValueExA(hkey, "Content Type", 0, REG_SZ,
+ (const BYTE *)aMSMimeType[ind], strlen( aMSMimeType[ind] ) ) )
+ aResult = FALSE;
+
+ if( hkey )
+ RegCloseKey(hkey),hkey= NULL;
+ }
+ }
+
+ wsprintfA( aSubKey, "%sCLSID\\%s", aPrefix, aClassID );
+ if ( aResult && ERROR_SUCCESS == RegCreateKeyExA( bForAllUsers ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER, aSubKey, 0, NULL, REG_OPTION_NON_VOLATILE, nKeyAccess, NULL, &hkey , NULL )
+ && createKey( hkey, "EnableFullPage", nKeyAccess ) )
+ {
+ for( ind = 0; ind < SUPPORTED_MSEXT_NUM; ind++ )
+ {
+ if( nForMSModes[ind] & nMode )
+ {
+ wsprintfA( aSubKey, "EnableFullPage\\%s", aMSFileExt[ind] );
+ if ( ERROR_SUCCESS != RegCreateKeyExA( hkey, aSubKey, 0, NULL, REG_OPTION_NON_VOLATILE, nKeyAccess, NULL, &hkey1 , NULL ) )
+ aResult = FALSE;
+
+ if ( hkey1 )
+ RegCloseKey(hkey1),hkey1= NULL;
+ }
+ }
+ }
+ else
+ aResult = FALSE;
+
+ if ( hkey )
+ RegCloseKey(hkey),hkey= NULL;
+
+ return aResult;
+}
+
+STDAPI DllRegisterServerDoc( int nMode, BOOL bForAllUsers, BOOL bFor64Bit )
+{
+ HRESULT hr = S_OK;
+ if ( bFor64Bit )
+ hr = DllRegisterServerDoc_Impl( nMode, bForAllUsers, n64KeyAccess );
+
+ if ( SUCCEEDED( hr ) )
+ hr = DllRegisterServerDoc_Impl( nMode, bForAllUsers, n32KeyAccess );
+
+ return hr;
+}
+
+
+/////////////////////////////////////////////////////////////////////////////
+// DllUnregisterServerDoc - Removes entries from the system registry
+
+STDAPI DllUnregisterServerDoc_Impl( int nMode, BOOL bForAllUsers, REGSAM nKeyAccess )
+{
+ HKEY hkey = NULL;
+ BOOL fErr = FALSE;
+ char aSubKey[513];
+ const char* aPrefix = aLocalPrefix; // bForAllUsers ? "" : aLocalPrefix;
+
+ for( int ind = 0; ind < SUPPORTED_MSEXT_NUM; ind++ )
+ {
+ if( nForMSModes[ind] & nMode )
+ {
+ DWORD nSubKeys = 0, nValues = 0;
+
+ wsprintfA( aSubKey, "%sMIME\\DataBase\\Content Type\\%s", aPrefix, aMSMimeType[ind] );
+ if ( ERROR_SUCCESS != RegCreateKeyExA( bForAllUsers ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER, aSubKey, 0, NULL, REG_OPTION_NON_VOLATILE, nKeyAccess, NULL, &hkey, NULL ) )
+ fErr = TRUE;
+ else
+ {
+ if ( ERROR_SUCCESS != RegDeleteValue( hkey, "Extension" ) )
+ fErr = TRUE;
+
+ if ( ERROR_SUCCESS != RegDeleteValue( hkey, "CLSID" ) )
+ fErr = TRUE;
+
+ if ( ERROR_SUCCESS != RegQueryInfoKey( hkey, NULL, NULL, NULL,
+ &nSubKeys, NULL, NULL,
+ &nValues, NULL, NULL, NULL, NULL ) )
+ {
+ RegCloseKey( hkey ), hkey = NULL;
+ fErr = TRUE;
+ }
+ else
+ {
+ RegCloseKey( hkey ), hkey = NULL;
+ if ( !nSubKeys && !nValues )
+ DeleteKeyTree( bForAllUsers ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER, aSubKey, nKeyAccess );
+ }
+ }
+
+ wsprintfA( aSubKey, "%s%s", aPrefix, aMSFileExt[ind] );
+ if ( ERROR_SUCCESS != RegCreateKeyExA( bForAllUsers ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER, aSubKey, 0, NULL, REG_OPTION_NON_VOLATILE, nKeyAccess, NULL, &hkey, NULL ) )
+ fErr = TRUE;
+ else
+ {
+ if ( ERROR_SUCCESS != RegDeleteValue( hkey, "Content Type" ) )
+ fErr = TRUE;
+
+ if ( ERROR_SUCCESS != RegQueryInfoKey( hkey, NULL, NULL, NULL,
+ &nSubKeys, NULL, NULL,
+ &nValues, NULL, NULL, NULL, NULL ) )
+ {
+ RegCloseKey( hkey ), hkey = NULL;
+ fErr = TRUE;
+ }
+ else
+ {
+ RegCloseKey( hkey ), hkey = NULL;
+ if ( !nSubKeys && !nValues )
+ DeleteKeyTree( bForAllUsers ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER, aSubKey, nKeyAccess );
+ }
+ }
+ }
+ }
+
+ return !fErr;
+}
+
+STDAPI DllUnregisterServerDoc( int nMode, BOOL bForAllUsers, BOOL bFor64Bit )
+{
+ HRESULT hr = S_OK;
+ if ( bFor64Bit )
+ hr = DllUnregisterServerDoc_Impl( nMode, bForAllUsers, n64KeyAccess );
+
+ if ( SUCCEEDED( hr ) )
+ hr = DllUnregisterServerDoc_Impl( nMode, bForAllUsers, n32KeyAccess );
+
+ return hr;
+}
+
+/////////////////////////////////////////////////////////////////////////////
+// DllRegisterServer - regsvr32 entry point
+
+STDAPI DllRegisterServer( void )
+{
+ char pProgramPath[1024];
+ HRESULT aResult = E_FAIL;
+
+ HMODULE aCurModule = GetModuleHandleA( bX64 ? X64_LIB_NAME : X32_LIB_NAME );
+ DWORD nLen = 0;
+ DWORD nLibNameLen = strlen( bX64 ? X64_LIB_NAME : X32_LIB_NAME );
+
+ if( aCurModule )
+ {
+ nLen = GetModuleFileNameA( aCurModule, pProgramPath, 1024 );
+ if ( nLen && nLen > nLibNameLen + 1 )
+ {
+ pProgramPath[ nLen - nLibNameLen - 1 ] = 0;
+ aResult = DllRegisterServerNative( 31, TRUE, bX64, pProgramPath );
+ if( SUCCEEDED( aResult ) )
+ aResult = DllRegisterServerDoc( 31, TRUE, bX64 );
+ else
+ {
+ aResult = DllRegisterServerNative( 31, FALSE, bX64, pProgramPath );
+ if( SUCCEEDED( aResult ) )
+ aResult = DllRegisterServerDoc( 31, FALSE, bX64 );
+ }
+ }
+ }
+
+ return aResult;
+}
+
+/////////////////////////////////////////////////////////////////////////////
+// DllUnregisterServer - regsvr32 entry point
+
+STDAPI DllUnregisterServer( void )
+{
+ DllUnregisterServerDoc( 63, FALSE, bX64 );
+ DllUnregisterServerNative( 63, FALSE, bX64 );
+ DllUnregisterServerDoc( 63, TRUE, bX64 );
+ return DllUnregisterServerNative( 63, TRUE, bX64 );
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/activex/main/so_activex.def b/extensions/source/activex/main/so_activex.def
new file mode 100644
index 000000000000..e3d56b070dad
--- /dev/null
+++ b/extensions/source/activex/main/so_activex.def
@@ -0,0 +1,13 @@
+; iervp.def : Declares the module parameters.
+
+LIBRARY "so_activex.dll"
+
+EXPORTS
+ DllCanUnloadNow @1 PRIVATE
+ DllGetClassObject @2 PRIVATE
+ DllRegisterServer @3 PRIVATE
+ DllUnregisterServer @4 PRIVATE
+ DllRegisterServerNative @5 PRIVATE
+ DllRegisterServerDoc @6 PRIVATE
+ DllUnregisterServerNative @7 PRIVATE
+ DllUnregisterServerDoc @8 PRIVATE
diff --git a/extensions/source/activex/main/so_activex.rc b/extensions/source/activex/main/so_activex.rc
new file mode 100644
index 000000000000..2370a5162187
--- /dev/null
+++ b/extensions/source/activex/main/so_activex.rc
@@ -0,0 +1,113 @@
+//Microsoft Developer Studio generated resource script.
+//
+#include "resource.h"
+
+#define APSTUDIO_READONLY_SYMBOLS
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 2 resource.
+//
+#if defined(_MSC_VER) && (_MSC_VER < 1500)
+#include "winres.h"
+#else
+#define WINVER 0x0500
+#include <winresrc.h>
+#define LB_ADDSTRING (WM_USER+1)
+#define CB_ADDSTRING (WM_USER+3)
+#define IDC_STATIC (-1)
+#endif
+
+/////////////////////////////////////////////////////////////////////////////
+#undef APSTUDIO_READONLY_SYMBOLS
+
+/////////////////////////////////////////////////////////////////////////////
+// Russian resources
+
+//#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_RUS)
+//#ifdef _WIN32
+//LANGUAGE LANG_RUSSIAN, SUBLANG_DEFAULT
+//#pragma code_page(1251)
+//#endif //_WIN32
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Bitmap
+//
+
+//IDB_SOACTIVEX BITMAP DISCARDABLE "soacti.bmp"
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// REGISTRY
+//
+
+IDR_SOACTIVEX REGISTRY DISCARDABLE "SOActiveX.rgs"
+IDR_SOCOMWINDOWPEER REGISTRY DISCARDABLE "SOComWindowPeer.rgs"
+IDR_SODISPATCHINTERCEPTOR REGISTRY DISCARDABLE "SODispatchInterceptor.rgs"
+//#endif // Russian resources
+/////////////////////////////////////////////////////////////////////////////
+
+
+/////////////////////////////////////////////////////////////////////////////
+// English (U.S.) resources
+
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
+#ifdef _WIN32
+LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
+#pragma code_page(1252)
+#endif //_WIN32
+
+#ifdef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// TEXTINCLUDE
+//
+
+1 TEXTINCLUDE DISCARDABLE
+BEGIN
+ "resource.h\0"
+END
+
+2 TEXTINCLUDE DISCARDABLE
+BEGIN
+ "#include ""winres.h""\r\n"
+ "\0"
+END
+
+3 TEXTINCLUDE DISCARDABLE
+BEGIN
+ "1 TYPELIB ""so_activex.tlb""\r\n"
+ "\0"
+END
+
+#endif // APSTUDIO_INVOKED
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// String Table
+//
+
+STRINGTABLE DISCARDABLE
+BEGIN
+ IDS_PROJNAME "so_activex"
+END
+
+#endif // English (U.S.) resources
+/////////////////////////////////////////////////////////////////////////////
+
+
+
+#ifndef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 3 resource.
+//
+
+#include "envsettings.h"
+
+1 TYPELIB MISC\so_activex.tlb
+
+/////////////////////////////////////////////////////////////////////////////
+#endif // not APSTUDIO_INVOKED
+
diff --git a/extensions/source/activex/msidl/makefile.mk b/extensions/source/activex/msidl/makefile.mk
new file mode 100644
index 000000000000..66c4a2a7cb3a
--- /dev/null
+++ b/extensions/source/activex/msidl/makefile.mk
@@ -0,0 +1,62 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ=..$/..$/..
+PRJNAME=extensions
+TARGET=msidl
+
+# --- Settings ----------------------------------
+
+.INCLUDE : settings.mk
+
+.IF "$(GUI)" == "WNT" && "$(DISABLE_ACTIVEX)"==""
+
+# --- Targets ----------------------------------
+
+ALL : $(MISC)$/activex_component
+
+MTL=midl.exe
+MTL_PROJ=
+
+SOURCE=so_activex.idl
+
+MTL_SWITCHES=-tlb $(MISC)$/so_activex.tlb -h $(MISC)$/so_activex.h -iid $(MISC)$/so_activex_i.c -dlldata $(MISC)$/so_activex_dll.c -proxy $(MISC)$/so_activex_p.c -Oicf
+
+.IF "$(COM)"=="GCC"
+MTL_SWITCHES+=-cpp_cmd gcc -cpp_opt "-x c -E -D__stdcall= -D_stdcall= -nostdinc -I $(shell @cygpath -w $(PSDK_HOME)/include)"
+
+$(MISC)$/activex_component : $(SOURCE)
+ $(MTL) $(MTL_SWITCHES) -I $(shell @cygpath -w $(PSDK_HOME)/include|sed 's#\\#\\\\#g') $(SOURCE)
+.ELSE
+$(MISC)$/activex_component : $(SOURCE)
+ $(WRAPCMD) $(MTL) $(MTL_SWITCHES) $(INCLUDE) $(SOURCE) && $(TOUCH) $@
+.ENDIF
+
+.ENDIF
+
+.INCLUDE : target.mk
+
diff --git a/extensions/source/activex/msidl/so_activex.idl b/extensions/source/activex/msidl/so_activex.idl
new file mode 100644
index 000000000000..ff396f5f9008
--- /dev/null
+++ b/extensions/source/activex/msidl/so_activex.idl
@@ -0,0 +1,210 @@
+// so_activex.idl : IDL source for so_activex.dll
+//
+
+// This file will be processed by the MIDL tool to
+// produce the type library (so_activex.tlb) and marshalling code.
+
+import "oaidl.idl";
+import "ocidl.idl";
+#include "olectl.h"
+
+
+ [
+ object,
+ uuid(DACF7E3F-626B-4BF9-964B-F4910C843711),
+ dual,
+ helpstring("ISOActiveX Interface"),
+ pointer_default(unique)
+ ]
+ interface ISOActiveX : IDispatch
+ {
+ };
+
+[
+ object,
+ uuid(BF5D10F3-8A10-4A0B-B150-2B6AA2D7E118),
+ dual,
+ helpstring("ISOComWindowPeer Interface"),
+ pointer_default(unique)
+]
+interface ISOComWindowPeer : IDispatch
+{
+ [id(1), helpstring("method getWindowHandle")]
+ HRESULT getWindowHandle( [in] SAFEARRAY(VARIANT) procId,
+ [in] short s,
+ [out,retval] long* ret);
+
+ [id(2), helpstring("method getToolkit")]
+ HRESULT getToolkit( [out,retval] IDispatch** retVal );
+
+ [id(3), helpstring("method setPointer")]
+ HRESULT setPointer( [in] IDispatch* xPointer );
+
+ [id(4), helpstring("method setBackground")]
+ HRESULT setBackground( [in] int nColor );
+
+ [id(5), helpstring("method invalidate")]
+ HRESULT invalidate( [in] short );
+
+ [id(6), helpstring("method invalidateRect")]
+ HRESULT invalidateRect( [in] IDispatch* aRect, [in] short nFlags );
+
+ [id(7), helpstring("method dispose")]
+ HRESULT dispose();
+
+ [id(8), helpstring("method addEventListener")]
+ HRESULT addEventListener( [in] IDispatch* xListener );
+
+ [id(9), helpstring("method removeEventListener")]
+ HRESULT removeEventListener( [in] IDispatch* xListener );
+
+ [propget, id(10), helpstring("property_implementedInterfaces")]
+ HRESULT Bridge_implementedInterfaces([out, retval] SAFEARRAY(BSTR) *pVal);
+};
+
+[
+ object,
+ uuid(9337694C-B27D-4384-95A4-9D8E0EABC9E5),
+ dual,
+ helpstring("ISODispatchInterceptor Interface"),
+ pointer_default(unique)
+]
+interface ISODispatchInterceptor : IDispatch
+{
+//com.sun.star.frame.XDispatchProviderInterceptor
+
+ [id(1), helpstring("method getSlaveDispatchProvider")]
+ HRESULT getSlaveDispatchProvider( [out,retval] IDispatch** retVal );
+
+ [id(2), helpstring("method setSlaveDispatchProvider")]
+ HRESULT setSlaveDispatchProvider( [in] IDispatch* xNewDispatchProvider );
+
+ [id(3), helpstring("method getMasterDispatchProvider")]
+ HRESULT getMasterDispatchProvider( [out,retval] IDispatch** retVal );
+
+ [id(4), helpstring("method setMasterDispatchProvider")]
+ HRESULT setMasterDispatchProvider( [in] IDispatch* xNewSupplier );
+
+// com.sun.star.frame.XDispatchProvider
+
+ [id(5), helpstring("method queryDispatch")]
+ HRESULT queryDispatch( [in] IDispatch* aURL,
+ [in] BSTR aTargetFrameName,
+ [in] long nSearchFlags,
+ [out,retval] IDispatch** retVal );
+
+ [id(6), helpstring("method queryDispatches")]
+ HRESULT queryDispatches( [in] SAFEARRAY(IDispatch*) aDescripts,
+ [out,retval] SAFEARRAY(VARIANT)* retVal );
+
+
+// com.sun.star.frame.XDispatch
+
+ [id(7), helpstring("method dispatch")]
+ HRESULT dispatch( [in] IDispatch* aURL,
+ [in] SAFEARRAY(VARIANT) aArgs );
+
+ [id(8), helpstring("method addStatusListener")]
+ HRESULT addStatusListener( [in] IDispatch* xControl,
+ [in] IDispatch* aURL );
+
+ [id(9), helpstring("method removeStatusListener")]
+ HRESULT removeStatusListener( [in] IDispatch* xControl,
+ [in] IDispatch* aURL );
+
+// com.sun.star.frame.XInterceptorInfo
+
+
+ [id(10), helpstring("method getInterceptedURLs")]
+ HRESULT getInterceptedURLs( [out,retval] SAFEARRAY(BSTR)* pVal );
+
+// the common UNO-COM staff
+ [propget, id(11), helpstring("property_implementedInterfaces")]
+ HRESULT Bridge_implementedInterfaces([out, retval] SAFEARRAY(BSTR) *pVal);
+
+};
+
+
+
+
+[
+ object,
+ uuid(029E9F1E-2B3F-4297-9160-8197DE7ED54F),
+ dual,
+ helpstring("ISOActionsApproval Interface"),
+ pointer_default(unique)
+]
+interface ISOActionsApproval : IDispatch
+{
+//com.sun.star.embed.XActionsApproval
+
+ [id(1), helpstring("method approveAction")]
+ HRESULT approveAction( [in] long aActionID,
+ [out,retval] boolean* pbApproval );
+
+// the common UNO-COM staff
+ [propget, id(2), helpstring("property_implementedInterfaces")]
+ HRESULT Bridge_implementedInterfaces([out, retval] SAFEARRAY(BSTR) *pVal);
+};
+
+
+
+[
+ uuid(61FA3F13-8061-4796-B055-3697ED28CB38),
+ version(1.0),
+ helpstring("so_activex 1.0 Type Library")
+]
+library SO_ACTIVEXLib
+{
+ importlib("stdole32.tlb");
+ importlib("stdole2.tlb");
+
+ [
+ uuid(7F760565-5719-4F04-BA86-112C474B10EA),
+ helpstring("_ISOActiveXEvents Interface")
+ ]
+ dispinterface _ISOActiveXEvents
+ {
+ properties:
+ methods:
+ };
+
+ [
+ uuid(67F2A879-82D5-4A6D-8CC5-FFB3C114B69D),
+ helpstring("SOActiveX Class")
+ ]
+ coclass SOActiveX
+ {
+ [default] interface ISOActiveX;
+ [default, source] dispinterface _ISOActiveXEvents;
+ };
+
+ [
+ uuid(EE51BD3E-8BB6-4FB8-B319-F65B1BE3B21D),
+ helpstring("SOComWindowPeer Class")
+ ]
+ coclass SOComWindowPeer
+ {
+ [default] interface ISOComWindowPeer;
+ };
+
+ [
+ uuid(C5D6D568-57DA-4D6C-819A-451CB565E682),
+ helpstring("SODispatchInterceptor Class")
+ ]
+ coclass SODispatchInterceptor
+ {
+ [default] interface ISODispatchInterceptor;
+ };
+
+ [
+ uuid(9F3697AC-7A18-4335-AF0A-65FAC2C35CC1),
+ helpstring("SOActionsApproval Class")
+ ]
+ coclass SOActionsApproval
+ {
+ [default] interface ISOActionsApproval;
+ };
+
+};
+
diff --git a/extensions/source/bibliography/bib.hrc b/extensions/source/bibliography/bib.hrc
new file mode 100644
index 000000000000..eb6afcb44135
--- /dev/null
+++ b/extensions/source/bibliography/bib.hrc
@@ -0,0 +1,111 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef BIB_HRC
+#define BIB_HRC
+
+#include "bibliography.hrc"
+
+#ifndef RID_BIB_START
+#define RID_BIB_START RID_EXTENSIONS_START
+#endif
+
+// ResIDs
+
+//Dialogs (100)
+#define RID_BIB_DIALOG (RID_BIB_START)
+#define RID_TP_GENERAL (RID_BIB_DIALOG)
+#define RID_DLG_MAPPING (RID_BIB_DIALOG + 1)
+#define RID_DLG_DBCHANGE (RID_BIB_DIALOG + 2)
+
+//Controls(100)
+#define RID_BIB_CONTROLS (RID_BIB_START + 100)
+#define RID_BIB_TOOLBAR (RID_BIB_CONTROLS+ 1)
+#define RID_TOOLBAR_IMGLIST (RID_BIB_CONTROLS+ 2)
+#define RID_TOOLBAR_IMGLIST_HC (RID_BIB_CONTROLS+ 3)
+#define RID_TOOLBAR_BIGIMGLIST (RID_BIB_CONTROLS+ 4)
+#define RID_TOOLBAR_BIGIMGLIST_HC (RID_BIB_CONTROLS+ 5)
+
+//Menu(100)
+#define RID_BIB_MENU (RID_BIB_CONTROLS + 100)
+#define RID_MAIN_MENU (RID_BIB_MENU +1)
+//#define RID_MAIN_ME_HIERARCHICAL (RID_BIB_MENU +2)
+#define RID_MAIN_ME_NEWENTRY (RID_BIB_MENU +3)
+#define RID_MAIN_ME_CHANGEENTRY (RID_BIB_MENU +4)
+#define RID_MAIN_ME_REMOVEENTRY (RID_BIB_MENU +5)
+#define RID_MAIN_ME_SEARCH (RID_BIB_MENU +6)
+#define RID_MAIN_ME_FIELDDLG (RID_BIB_MENU +7)
+//#define RID_MAIN_ME_LAYOUT (RID_BIB_MENU +8)
+#define RID_MAIN_ME_MAPPING (RID_BIB_MENU +9)
+#define RID_MAIN_ME_DBSOURCE (RID_BIB_MENU +10)
+#define RID_MAIN_DELETE_RECORD (RID_BIB_MENU +11)
+#define RID_MAIN_INSERT_RECORD (RID_BIB_MENU +12)
+#define MN_TEMPLATES (RID_BIB_MENU +13) // to make makro ITEM_FILE_DOCTEMPLATE happy...
+
+#define RID_POPUP_ME_VIEW (RID_BIB_MENU +50)
+
+// Strings (500)
+#define RID_BIB_STRING (RID_BIB_START + 200)
+ // FREE (RID_BIB_STRING + 1)
+#define RID_BIB_STR_FIELDSELECTION (RID_BIB_STRING + 2)
+#define RID_BIB_STR_TABWIN_PREFIX (RID_BIB_STRING + 3)
+#define RID_BIB_STR_FRAME_TITLE (RID_BIB_STRING + 4)
+#define RID_MAP_QUESTION (RID_BIB_STRING + 5)
+
+#define ST_IDENTIFIER (RID_BIB_STRING + 6)
+#define ST_AUTHTYPE (RID_BIB_STRING + 7)
+#define ST_AUTHOR (RID_BIB_STRING + 8)
+#define ST_YEAR (RID_BIB_STRING + 9)
+#define ST_ISBN (RID_BIB_STRING + 10)
+#define ST_MONTH (RID_BIB_STRING + 11)
+#define ST_PUBLISHER (RID_BIB_STRING + 12)
+#define ST_ADDRESS (RID_BIB_STRING + 13)
+#define ST_ANNOTE (RID_BIB_STRING + 14)
+#define ST_BOOKTITLE (RID_BIB_STRING + 15)
+#define ST_CHAPTER (RID_BIB_STRING + 16)
+#define ST_EDITION (RID_BIB_STRING + 17)
+#define ST_EDITOR (RID_BIB_STRING + 18)
+#define ST_HOWPUBLISHED (RID_BIB_STRING + 19)
+#define ST_INSTITUTION (RID_BIB_STRING + 20)
+#define ST_JOURNAL (RID_BIB_STRING + 21)
+#define ST_NOTE (RID_BIB_STRING + 22)
+#define ST_NUMBER (RID_BIB_STRING + 23)
+#define ST_ORGANIZATION (RID_BIB_STRING + 24)
+#define ST_PAGE (RID_BIB_STRING + 25)
+#define ST_SCHOOL (RID_BIB_STRING + 26)
+#define ST_SERIES (RID_BIB_STRING + 27)
+#define ST_TITLE (RID_BIB_STRING + 28)
+#define ST_REPORT (RID_BIB_STRING + 29)
+#define ST_VOLUME (RID_BIB_STRING + 30)
+#define ST_URL (RID_BIB_STRING + 31)
+#define ST_CUSTOM1 (RID_BIB_STRING + 32)
+#define ST_CUSTOM2 (RID_BIB_STRING + 33)
+#define ST_CUSTOM3 (RID_BIB_STRING + 34)
+#define ST_CUSTOM4 (RID_BIB_STRING + 35)
+#define ST_CUSTOM5 (RID_BIB_STRING + 36)
+
+
+#endif
diff --git a/extensions/source/bibliography/bib.src b/extensions/source/bibliography/bib.src
new file mode 100644
index 000000000000..1492de7b650a
--- /dev/null
+++ b/extensions/source/bibliography/bib.src
@@ -0,0 +1,74 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#include "bib.hrc"
+
+String RID_BIB_STR_FIELDSELECTION
+{
+ Text [ en-US ] = "Field selection:";
+};
+
+String RID_BIB_STR_TABWIN_PREFIX
+{
+ Text [ en-US ] = "Table;Query;Sql;Sql [Native]";
+};
+String RID_BIB_STR_FRAME_TITLE
+{
+ Text [ en-US ] = "Bibliography Database";
+};
+String RID_MAP_QUESTION
+{
+ Text [ en-US ] = "Do you want to edit the column arrangement?";
+};
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/extensions/source/bibliography/bibbeam.cxx b/extensions/source/bibliography/bibbeam.cxx
new file mode 100644
index 000000000000..f6f7c93f0470
--- /dev/null
+++ b/extensions/source/bibliography/bibbeam.cxx
@@ -0,0 +1,322 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+#include <osl/mutex.hxx>
+#include <tools/urlobj.hxx>
+#include <toolkit/helper/vclunohelper.hxx>
+#include <comphelper/processfactory.hxx>
+#include <com/sun/star/awt/PosSize.hpp>
+#include <com/sun/star/frame/XDispatch.hpp>
+#include <com/sun/star/util/XURLTransformer.hpp>
+
+#include "bibliography.hrc"
+#include <vcl/lstbox.hxx>
+#include <vcl/edit.hxx>
+#include <tools/debug.hxx>
+#include "bibbeam.hxx"
+#include "toolbar.hrc"
+#include "bibresid.hxx"
+#include "datman.hxx"
+#include "bibtools.hxx"
+
+using namespace rtl;
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::uno;
+
+#define C2U(cChar) OUString::createFromAscii(cChar)
+
+#define PROPERTY_FRAME 1
+#define ID_TOOLBAR 1
+#define ID_GRIDWIN 2
+
+//.........................................................................
+namespace bib
+{
+//.........................................................................
+
+ using namespace ::com::sun::star::uno;
+
+ void HandleTaskPaneList( Window* pWindow, BOOL bAddToList )
+ {
+ Window* pParent = pWindow->GetParent();
+
+ DBG_ASSERT( pParent, "-GetTaskPaneList(): everybody here should have a parent!" );
+
+ SystemWindow* pSysWin = pParent->GetSystemWindow();
+ if( pSysWin )
+ {
+ TaskPaneList* pTaskPaneList = pSysWin->GetTaskPaneList();
+ if( pTaskPaneList )
+ {
+ if( bAddToList )
+ pTaskPaneList->AddWindow( pWindow );
+ else
+ pTaskPaneList->RemoveWindow( pWindow );
+ }
+ }
+ }
+
+ //=====================================================================
+ //= BibGridwin
+ //=====================================================================
+ class BibGridwin
+ :public Window //DockingWindow
+ {
+ private:
+ Reference< awt::XWindow > m_xGridWin;
+ Reference< awt::XControlModel > m_xGridModel;
+ Reference< awt::XControl > m_xControl;
+ Reference< awt::XControlContainer > m_xControlContainer;
+ // #100312# ---------
+ Reference< frame::XDispatchProviderInterception> m_xDispatchProviderInterception;
+
+ protected:
+
+ virtual void Resize();
+
+ public:
+
+ BibGridwin(Window* pParent, WinBits nStyle = WB_3DLOOK );
+ ~BibGridwin();
+
+ void createGridWin(const Reference< awt::XControlModel > & xDbForm);
+ void disposeGridWin();
+
+ const Reference< awt::XControlContainer >& getControlContainer() const { return m_xControlContainer; }
+ // #100312# ---------
+ const Reference< frame::XDispatchProviderInterception>& getDispatchProviderInterception() const { return m_xDispatchProviderInterception; }
+
+ virtual void GetFocus();
+ };
+
+ //---------------------------------------------------------------------
+ BibGridwin::BibGridwin( Window* _pParent, WinBits _nStyle ) : Window( _pParent, _nStyle )
+ {
+ m_xControlContainer = VCLUnoHelper::CreateControlContainer(this);
+
+ AddToTaskPaneList( this );
+ }
+
+ //---------------------------------------------------------------------
+ BibGridwin::~BibGridwin()
+ {
+ RemoveFromTaskPaneList( this );
+
+ disposeGridWin();
+ }
+
+ //---------------------------------------------------------------------
+ void BibGridwin::Resize()
+ {
+ if(m_xGridWin.is())
+ {
+ ::Size aSize = GetOutputSizePixel();
+ m_xGridWin->setPosSize(0, 0, aSize.Width(),aSize.Height(), awt::PosSize::SIZE);
+ }
+ }
+
+ //---------------------------------------------------------------------
+ void BibGridwin::createGridWin(const uno::Reference< awt::XControlModel > & xGModel)
+ {
+ m_xGridModel = xGModel;
+
+ if( m_xControlContainer.is())
+ {
+ uno::Reference< lang::XMultiServiceFactory > xMgr = comphelper::getProcessServiceFactory();
+
+ if ( m_xGridModel.is() && xMgr.is())
+ {
+ uno::Reference< XPropertySet > xPropSet( m_xGridModel, UNO_QUERY );
+
+ if ( xPropSet.is() && m_xGridModel.is() )
+ {
+ uno::Any aAny = xPropSet->getPropertyValue( C2U("DefaultControl") );
+ rtl::OUString aControlName;
+ aAny >>= aControlName;
+
+ m_xControl = Reference< awt::XControl > (xMgr->createInstance( aControlName ), UNO_QUERY );
+ DBG_ASSERT( m_xControl.is(), "no GridControl created" );
+ if ( m_xControl.is() )
+ m_xControl->setModel( m_xGridModel );
+ }
+
+ if ( m_xControl.is() )
+ {
+ // Peer als Child zu dem FrameWindow
+ m_xControlContainer->addControl(C2U("GridControl"), m_xControl);
+ m_xGridWin=uno::Reference< awt::XWindow > (m_xControl, UNO_QUERY );
+ // #100312# -----
+ m_xDispatchProviderInterception=uno::Reference< frame::XDispatchProviderInterception > (m_xControl, UNO_QUERY );
+ m_xGridWin->setVisible( sal_True );
+ m_xControl->setDesignMode( sal_True );
+ // initially switch on the desing mode - switch it off _after_ loading the form
+ // 17.10.2001 - 93107 - frank.schoenheit@sun.com
+
+ ::Size aSize = GetOutputSizePixel();
+ m_xGridWin->setPosSize(0, 0, aSize.Width(),aSize.Height(), awt::PosSize::POSSIZE);
+ }
+ }
+ }
+ }
+
+ //---------------------------------------------------------------------
+ void BibGridwin::disposeGridWin()
+ {
+ if ( m_xControl.is() )
+ {
+ Reference< awt::XControl > xDel( m_xControl );
+ m_xControl = NULL;
+ m_xGridWin = NULL;
+
+ m_xControlContainer->removeControl( xDel );
+ xDel->dispose();
+ }
+ }
+
+ //---------------------------------------------------------------------
+ void BibGridwin::GetFocus()
+ {
+ if(m_xGridWin.is())
+ m_xGridWin->setFocus();
+ }
+
+ //---------------------------------------------------------------------
+ BibBeamer::BibBeamer( Window* _pParent, BibDataManager* _pDM, WinBits _nStyle )
+ :BibSplitWindow( _pParent, _nStyle | WB_NOSPLITDRAW )
+ ,pDatMan( _pDM )
+ ,pToolBar( NULL )
+ ,pGridWin( NULL )
+ {
+ createToolBar();
+ createGridWin();
+ if ( pDatMan )
+ pDatMan->SetToolbar(pToolBar);
+ pGridWin->Show();
+
+ if ( pDatMan )
+ connectForm( pDatMan );
+ }
+
+ //---------------------------------------------------------------------
+ BibBeamer::~BibBeamer()
+ {
+ if ( isFormConnected() )
+ disconnectForm();
+
+ if ( m_xToolBarRef.is() )
+ m_xToolBarRef->dispose();
+
+ if ( pToolBar )
+ {
+ if ( pDatMan )
+ pDatMan->SetToolbar(0);
+
+ DELETEZ( pToolBar );
+ }
+
+ if( pGridWin )
+ {
+ BibGridwin* pDel = pGridWin;
+ pGridWin = NULL;
+ pDel->disposeGridWin();
+ delete pDel;
+ }
+
+ }
+
+ //---------------------------------------------------------------------
+ void BibBeamer::createToolBar()
+ {
+ pToolBar= new BibToolBar(this, LINK( this, BibBeamer, RecalcLayout_Impl ));
+ ::Size aSize=pToolBar->GetSizePixel();
+ InsertItem(ID_TOOLBAR, pToolBar, aSize.Height(), 0, 0, SWIB_FIXED );
+ if ( m_xController.is() )
+ pToolBar->SetXController( m_xController );
+ }
+
+ //---------------------------------------------------------------------
+ void BibBeamer::createGridWin()
+ {
+ pGridWin = new BibGridwin(this,0);
+
+ InsertItem(ID_GRIDWIN, pGridWin, 40, 1, 0, SWIB_RELATIVESIZE );
+
+ pGridWin->createGridWin( pDatMan->updateGridModel() );
+ }
+
+ //---------------------------------------------------------------------
+ Reference< awt::XControlContainer > BibBeamer::getControlContainer()
+ {
+ Reference< awt::XControlContainer > xReturn;
+ if ( pGridWin )
+ xReturn = pGridWin->getControlContainer();
+ return xReturn;
+ }
+
+ // #100312# -----------------------------------------------------------
+ Reference< frame::XDispatchProviderInterception > BibBeamer::getDispatchProviderInterception()
+ {
+ Reference< frame::XDispatchProviderInterception > xReturn;
+ if ( pGridWin )
+ xReturn = pGridWin->getDispatchProviderInterception();
+ return xReturn;
+ }
+
+ //---------------------------------------------------------------------
+ void BibBeamer::SetXController(const uno::Reference< frame::XController > & xCtr)
+ {
+ m_xController = xCtr;
+
+ if ( pToolBar )
+ pToolBar->SetXController( m_xController );
+
+ }
+
+ //---------------------------------------------------------------------
+ void BibBeamer::GetFocus()
+ {
+ if( pGridWin )
+ pGridWin->GrabFocus();
+ }
+
+ //---------------------------------------------------------------------
+ IMPL_LINK( BibBeamer, RecalcLayout_Impl, void*, /*pVoid*/ )
+ {
+ long nHeight = pToolBar->GetSizePixel().Height();
+ SetItemSize( ID_TOOLBAR, nHeight );
+ return 0L;
+ }
+
+//.........................................................................
+} // namespace bib
+//.........................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/bibliography/bibbeam.hxx b/extensions/source/bibliography/bibbeam.hxx
new file mode 100644
index 000000000000..c9742b38baaa
--- /dev/null
+++ b/extensions/source/bibliography/bibbeam.hxx
@@ -0,0 +1,96 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef ADRBEAM_HXX
+#define ADRBEAM_HXX
+
+#include <com/sun/star/awt/XControlContainer.hpp>
+#include <com/sun/star/awt/XControl.hpp>
+#include <com/sun/star/awt/XControlModel.hpp>
+#include <com/sun/star/form/XForm.hpp>
+// #100312# -----------------
+#include <com/sun/star/frame/XDispatchProviderInterception.hpp>
+#include <cppuhelper/implbase1.hxx> // helper for implementations
+#include <vcl/splitwin.hxx>
+#include "toolbar.hxx"
+#include "formcontrolcontainer.hxx"
+#include "bibshortcuthandler.hxx"
+
+class BibDataManager;
+
+//.........................................................................
+namespace bib
+{
+//.........................................................................
+
+ class BibGridwin;
+ class BibBeamer
+ :public BibSplitWindow
+ ,public FormControlContainer
+ {
+ private:
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController > m_xController;
+ ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > m_xToolBarRef;
+ ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > m_xGridRef;
+ ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > m_xGridWin;
+
+ BibDataManager* pDatMan;
+ BibToolBar* pToolBar;
+ BibGridwin* pGridWin;
+
+ DECL_LINK( RecalcLayout_Impl, void* );
+
+ protected:
+
+ void createToolBar();
+ void createGridWin();
+
+ // FormControlContainer ----------
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlContainer >
+ getControlContainer();
+ public:
+ // #100312# -------------------
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProviderInterception >
+ getDispatchProviderInterception();
+
+ BibBeamer(Window* pParent,BibDataManager* pDatMan, WinBits nStyle = WB_3DLOOK );
+ ~BibBeamer();
+
+ void SetXController(const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController > &);
+
+ virtual void GetFocus();
+ };
+
+//.........................................................................
+} // namespace bib
+//.........................................................................
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/bibliography/bibconfig.cxx b/extensions/source/bibliography/bibconfig.cxx
new file mode 100644
index 000000000000..adf7ef75c276
--- /dev/null
+++ b/extensions/source/bibliography/bibconfig.cxx
@@ -0,0 +1,391 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+
+#include <bibconfig.hxx>
+#include <svl/svarray.hxx>
+#include <tools/debug.hxx>
+#include <com/sun/star/uno/Sequence.hxx>
+#include <com/sun/star/uno/Any.hxx>
+#include <com/sun/star/beans/PropertyValue.hpp>
+#include <com/sun/star/container/XNameAccess.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <comphelper/processfactory.hxx>
+
+using namespace rtl;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::lang;
+/* -----------------11.11.99 14:34-------------------
+
+ --------------------------------------------------*/
+typedef Mapping* MappingPtr;
+SV_DECL_PTRARR_DEL(MappingArray, MappingPtr, 2, 2)
+SV_IMPL_PTRARR(MappingArray, MappingPtr);
+
+#define C2U(cChar) OUString::createFromAscii(cChar)
+
+const char* cDataSourceHistory = "DataSourceHistory";
+/* -----------------------------13.11.00 12:21--------------------------------
+
+ ---------------------------------------------------------------------------*/
+Sequence<OUString> BibConfig::GetPropertyNames()
+{
+ static Sequence<OUString> aNames;
+ if(!aNames.getLength())
+ {
+ aNames.realloc(8);
+ OUString* pNames = aNames.getArray();
+ pNames[0] = C2U("CurrentDataSource/DataSourceName");
+ pNames[1] = C2U("CurrentDataSource/Command");
+ pNames[2] = C2U("CurrentDataSource/CommandType");
+ pNames[3] = C2U("BeamerHeight");
+ pNames[4] = C2U("ViewHeight");
+ pNames[5] = C2U("QueryText");
+ pNames[6] = C2U("QueryField");
+ pNames[7] = C2U("ShowColumnAssignmentWarning");
+ }
+ return aNames;
+}
+/* -----------------------------13.11.00 11:00--------------------------------
+
+ ---------------------------------------------------------------------------*/
+BibConfig::BibConfig() :
+ ConfigItem(C2U("Office.DataAccess/Bibliography"), CONFIG_MODE_DELAYED_UPDATE),
+ pMappingsArr(new MappingArray),
+ nBeamerSize(0),
+ nViewSize(0),
+ bShowColumnAssignmentWarning(sal_False)
+{
+ //Names of the default columns
+ aColumnDefaults[0] = C2U("Identifier");
+ aColumnDefaults[1] = C2U("BibliographyType");
+ aColumnDefaults[2] = C2U("Author");
+ aColumnDefaults[3] = C2U("Title");
+ aColumnDefaults[4] = C2U("Year");
+ aColumnDefaults[5] = C2U("ISBN");
+ aColumnDefaults[6] = C2U("Booktitle");
+ aColumnDefaults[7] = C2U("Chapter");
+ aColumnDefaults[8] = C2U("Edition");
+ aColumnDefaults[9] = C2U("Editor");
+ aColumnDefaults[10] = C2U("Howpublished");
+ aColumnDefaults[11] = C2U("Institution");
+ aColumnDefaults[12] = C2U("Journal");
+ aColumnDefaults[13] = C2U("Month");
+ aColumnDefaults[14] = C2U("Note");
+ aColumnDefaults[15] = C2U("Annote");
+ aColumnDefaults[16] = C2U("Number");
+ aColumnDefaults[17] = C2U("Organizations");
+ aColumnDefaults[18] = C2U("Pages");
+ aColumnDefaults[19] = C2U("Publisher");
+ aColumnDefaults[20] = C2U("Address");
+ aColumnDefaults[21] = C2U("School");
+ aColumnDefaults[22] = C2U("Series");
+ aColumnDefaults[23] = C2U("ReportType");
+ aColumnDefaults[24] = C2U("Volume");
+ aColumnDefaults[25] = C2U("URL");
+ aColumnDefaults[26] = C2U("Custom1");
+ aColumnDefaults[27] = C2U("Custom2");
+ aColumnDefaults[28] = C2U("Custom3");
+ aColumnDefaults[29] = C2U("Custom4");
+ aColumnDefaults[30] = C2U("Custom5");
+
+
+ const Sequence< OUString > aPropertyNames = GetPropertyNames();
+ const Sequence<Any> aPropertyValues = GetProperties( aPropertyNames );
+ const Any* pValues = aPropertyValues.getConstArray();
+ if(aPropertyValues.getLength() == aPropertyNames.getLength())
+ {
+ for(int nProp = 0; nProp < aPropertyNames.getLength(); nProp++)
+ {
+ if(pValues[nProp].hasValue())
+ {
+ switch(nProp)
+ {
+ case 0: pValues[nProp] >>= sDataSource; break;
+ case 1: pValues[nProp] >>= sTableOrQuery; break;
+ case 2: pValues[nProp] >>= nTblOrQuery; break;
+ case 3: pValues[nProp] >>= nBeamerSize; break;
+ case 4: pValues[nProp] >>= nViewSize ; break;
+ case 5: pValues[nProp] >>= sQueryText ; break;
+ case 6: pValues[nProp] >>= sQueryField; break;
+ case 7:
+ bShowColumnAssignmentWarning = *(sal_Bool*)pValues[nProp].getValue();
+ break;
+ }
+ }
+ }
+ }
+ OUString sName(C2U("DataSourceName"));
+ OUString sTable(C2U("Command"));
+ OUString sCommandType(C2U("CommandType"));
+ Sequence< OUString > aNodeNames = GetNodeNames(C2U(cDataSourceHistory));
+ const OUString* pNodeNames = aNodeNames.getConstArray();
+ for(sal_Int32 nNode = 0; nNode < aNodeNames.getLength(); nNode++)
+ {
+ Sequence<OUString> aHistoryNames(3);
+ OUString* pHistoryNames = aHistoryNames.getArray();
+
+ OUString sPrefix(C2U(cDataSourceHistory));
+ sPrefix += C2U("/");
+ sPrefix += pNodeNames[nNode];
+ sPrefix += C2U("/");
+ pHistoryNames[0] = sPrefix;
+ pHistoryNames[0] += sName;
+ pHistoryNames[1] = sPrefix;
+ pHistoryNames[1] += sTable;
+ pHistoryNames[2] = sPrefix;
+ pHistoryNames[2] += sCommandType;
+
+ Sequence<Any> aHistoryValues = GetProperties( aHistoryNames );
+ const Any* pHistoryValues = aHistoryValues.getConstArray();
+
+ if(aHistoryValues.getLength() == aHistoryNames.getLength())
+ {
+ Mapping* pMapping = new Mapping;
+ pHistoryValues[0] >>= pMapping->sURL;
+ pHistoryValues[1] >>= pMapping->sTableName;
+ pHistoryValues[2] >>= pMapping->nCommandType;
+ //field assignment is contained in another set
+ sPrefix += C2U("Fields");
+ Sequence< OUString > aAssignmentNodeNames = GetNodeNames(sPrefix);
+ const OUString* pAssignmentNodeNames = aAssignmentNodeNames.getConstArray();
+ Sequence<OUString> aAssignmentPropertyNames(aAssignmentNodeNames.getLength() * 2);
+ OUString* pAssignmentPropertyNames = aAssignmentPropertyNames.getArray();
+ sal_Int16 nFieldIdx = 0;
+ for(sal_Int16 nField = 0; nField < aAssignmentNodeNames.getLength(); nField++)
+ {
+ OUString sSubPrefix(sPrefix);
+ sSubPrefix += C2U("/");
+ sSubPrefix += pAssignmentNodeNames[nField];
+ pAssignmentPropertyNames[nFieldIdx] = sSubPrefix;
+ pAssignmentPropertyNames[nFieldIdx++] += C2U("/ProgrammaticFieldName");
+ pAssignmentPropertyNames[nFieldIdx] = sSubPrefix;
+ pAssignmentPropertyNames[nFieldIdx++] += C2U("/AssignedFieldName");
+ }
+ Sequence<Any> aAssignmentValues = GetProperties(aAssignmentPropertyNames);
+ const Any* pAssignmentValues = aAssignmentValues.getConstArray();
+ OUString sTempLogical;
+ OUString sTempReal;
+ sal_Int16 nSetMapping = 0;
+ nFieldIdx = 0;
+ for(sal_Int16 nFieldVal = 0; nFieldVal < aAssignmentValues.getLength() / 2; nFieldVal++)
+ {
+ pAssignmentValues[nFieldIdx++] >>= sTempLogical;
+ pAssignmentValues[nFieldIdx++] >>= sTempReal;
+ if(sTempLogical.getLength() && sTempReal.getLength())
+ {
+ pMapping->aColumnPairs[nSetMapping].sLogicalColumnName = sTempLogical;
+ pMapping->aColumnPairs[nSetMapping++].sRealColumnName = sTempReal;
+ }
+ }
+ pMappingsArr->Insert(pMapping, pMappingsArr->Count());
+ }
+ }
+}
+/* -----------------------------13.11.00 11:00--------------------------------
+
+ ---------------------------------------------------------------------------*/
+BibConfig::~BibConfig()
+{
+ if(IsModified())
+ Commit();
+ delete pMappingsArr;
+}
+/* -----------------------------13.11.00 12:08--------------------------------
+
+ ---------------------------------------------------------------------------*/
+BibDBDescriptor BibConfig::GetBibliographyURL()
+{
+ BibDBDescriptor aRet;
+ aRet.sDataSource = sDataSource;
+ aRet.sTableOrQuery = sTableOrQuery;
+ aRet.nCommandType = nTblOrQuery;
+ return aRet;
+};
+/* -----------------------------13.11.00 12:20--------------------------------
+
+ ---------------------------------------------------------------------------*/
+void BibConfig::SetBibliographyURL(const BibDBDescriptor& rDesc)
+{
+ sDataSource = rDesc.sDataSource;
+ sTableOrQuery = rDesc.sTableOrQuery;
+ nTblOrQuery = rDesc.nCommandType;
+ SetModified();
+};
+//---------------------------------------------------------------------------
+void BibConfig::Notify( const com::sun::star::uno::Sequence<rtl::OUString>& )
+{
+}
+
+void BibConfig::Commit()
+{
+ const Sequence<OUString> aPropertyNames = GetPropertyNames();
+ Sequence<Any> aValues(aPropertyNames.getLength());
+ Any* pValues = aValues.getArray();
+
+ for(int nProp = 0; nProp < aPropertyNames.getLength(); nProp++)
+ {
+ switch(nProp)
+ {
+ case 0: pValues[nProp] <<= sDataSource; break;
+ case 1: pValues[nProp] <<= sTableOrQuery; break;
+ case 2: pValues[nProp] <<= nTblOrQuery; break;
+ case 3: pValues[nProp] <<= nBeamerSize; break;
+ case 4: pValues[nProp] <<= nViewSize; break;
+ case 5: pValues[nProp] <<= sQueryText; break;
+ case 6: pValues[nProp] <<= sQueryField; break;
+ case 7:
+ pValues[nProp].setValue(&bShowColumnAssignmentWarning, ::getBooleanCppuType());
+ break;
+ }
+ }
+ PutProperties(aPropertyNames, aValues);
+ ClearNodeSet( C2U(cDataSourceHistory));
+ OUString sEmpty;
+ Sequence< PropertyValue > aNodeValues(pMappingsArr->Count() * 3);
+ PropertyValue* pNodeValues = aNodeValues.getArray();
+
+ sal_Int32 nIndex = 0;
+ OUString sName(C2U("DataSourceName"));
+ OUString sTable(C2U("Command"));
+ OUString sCommandType(C2U("CommandType"));
+ for(sal_Int32 i = 0; i < pMappingsArr->Count(); i++)
+ {
+ const Mapping* pMapping = pMappingsArr->GetObject((USHORT)i);
+ OUString sPrefix(C2U(cDataSourceHistory));
+ sPrefix += C2U("/_");
+ sPrefix += OUString::valueOf(i);
+ sPrefix += C2U("/");
+ pNodeValues[nIndex].Name = sPrefix;
+ pNodeValues[nIndex].Name += sName;
+ pNodeValues[nIndex++].Value <<= pMapping->sURL;
+ pNodeValues[nIndex].Name = sPrefix;
+ pNodeValues[nIndex].Name += sTable;
+ pNodeValues[nIndex++].Value <<= pMapping->sTableName;
+ pNodeValues[nIndex].Name = sPrefix;
+ pNodeValues[nIndex].Name += sCommandType;
+ pNodeValues[nIndex++].Value <<= pMapping->nCommandType;
+ SetSetProperties( C2U(cDataSourceHistory), aNodeValues);
+
+ sPrefix += C2U("Fields");
+ sal_Int32 nFieldAssignment = 0;
+ OUString sFieldName = C2U("/ProgrammaticFieldName");
+ OUString sDatabaseFieldName = C2U("/AssignedFieldName");
+ ClearNodeSet( sPrefix );
+
+ while(nFieldAssignment < COLUMN_COUNT &&
+ pMapping->aColumnPairs[nFieldAssignment].sLogicalColumnName.getLength())
+ {
+ OUString sSubPrefix(sPrefix);
+ sSubPrefix += C2U("/_");
+ sSubPrefix += OUString::valueOf(nFieldAssignment);
+ Sequence< PropertyValue > aAssignmentValues(2);
+ PropertyValue* pAssignmentValues = aAssignmentValues.getArray();
+ pAssignmentValues[0].Name = sSubPrefix;
+ pAssignmentValues[0].Name += sFieldName;
+ pAssignmentValues[0].Value <<= pMapping->aColumnPairs[nFieldAssignment].sLogicalColumnName;
+ pAssignmentValues[1].Name = sSubPrefix;
+ pAssignmentValues[1].Name += sDatabaseFieldName;
+ pAssignmentValues[1].Value <<= pMapping->aColumnPairs[nFieldAssignment].sRealColumnName;
+ SetSetProperties( sPrefix, aAssignmentValues );
+ nFieldAssignment++;
+ }
+ }
+}
+/* -----------------------------13.11.00 12:23--------------------------------
+
+ ---------------------------------------------------------------------------*/
+const Mapping* BibConfig::GetMapping(const BibDBDescriptor& rDesc) const
+{
+ for(sal_uInt16 i = 0; i < pMappingsArr->Count(); i++)
+ {
+ const Mapping* pMapping = pMappingsArr->GetObject(i);
+ sal_Bool bURLEqual = rDesc.sDataSource.equals(pMapping->sURL);
+ if(rDesc.sTableOrQuery == pMapping->sTableName && bURLEqual)
+ return pMapping;
+ }
+ return 0;
+}
+/* -----------------------------13.11.00 12:23--------------------------------
+
+ ---------------------------------------------------------------------------*/
+void BibConfig::SetMapping(const BibDBDescriptor& rDesc, const Mapping* pSetMapping)
+{
+ for(sal_uInt16 i = 0; i < pMappingsArr->Count(); i++)
+ {
+ const Mapping* pMapping = pMappingsArr->GetObject(i);
+ sal_Bool bURLEqual = rDesc.sDataSource.equals(pMapping->sURL);
+ if(rDesc.sTableOrQuery == pMapping->sTableName && bURLEqual)
+ {
+ pMappingsArr->DeleteAndDestroy(i, 1);
+ break;
+ }
+ }
+ Mapping* pNew = new Mapping(*pSetMapping);
+ pMappingsArr->Insert(pNew, pMappingsArr->Count());
+ SetModified();
+}
+/* -----------------------------20.11.00 11:56--------------------------------
+
+ ---------------------------------------------------------------------------*/
+DBChangeDialogConfig_Impl::DBChangeDialogConfig_Impl()
+{
+}
+/* -----------------------------20.11.00 11:57--------------------------------
+
+ ---------------------------------------------------------------------------*/
+DBChangeDialogConfig_Impl::~DBChangeDialogConfig_Impl()
+{
+}
+/* -----------------------------14.03.01 12:53--------------------------------
+
+ ---------------------------------------------------------------------------*/
+const Sequence<OUString>& DBChangeDialogConfig_Impl::GetDataSourceNames()
+{
+ if(!aSourceNames.getLength())
+ {
+ Reference<XNameAccess> xDBContext;
+ Reference< XMultiServiceFactory > xMgr( ::comphelper::getProcessServiceFactory() );
+ if( xMgr.is() )
+ {
+ Reference<XInterface> xInstance = xMgr->createInstance( C2U( "com.sun.star.sdb.DatabaseContext" ));
+ xDBContext = Reference<XNameAccess>(xInstance, UNO_QUERY) ;
+ }
+ if(xDBContext.is())
+ {
+ aSourceNames = xDBContext->getElementNames();
+ }
+ }
+ return aSourceNames;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/bibliography/bibconfig.hxx b/extensions/source/bibliography/bibconfig.hxx
new file mode 100644
index 000000000000..18af8fed5f46
--- /dev/null
+++ b/extensions/source/bibliography/bibconfig.hxx
@@ -0,0 +1,158 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _BIBCONFIG_HXX
+#define _BIBCONFIG_HXX
+
+#include <unotools/configitem.hxx>
+class MappingArray;
+
+//-----------------------------------------------------------------------------
+#define COLUMN_COUNT 31
+#define IDENTIFIER_POS 0
+#define AUTHORITYTYPE_POS 1
+#define AUTHOR_POS 2
+#define TITLE_POS 3
+#define YEAR_POS 4
+#define ISBN_POS 5
+#define BOOKTITLE_POS 6
+#define CHAPTER_POS 7
+#define EDITION_POS 8
+#define EDITOR_POS 9
+#define HOWPUBLISHED_POS 10
+#define INSTITUTION_POS 11
+#define JOURNAL_POS 12
+#define MONTH_POS 13
+#define NOTE_POS 14
+#define ANNOTE_POS 15
+#define NUMBER_POS 16
+#define ORGANIZATIONS_POS 17
+#define PAGES_POS 18
+#define PUBLISHER_POS 19
+#define ADDRESS_POS 20
+#define SCHOOL_POS 21
+#define SERIES_POS 22
+#define REPORTTYPE_POS 23
+#define VOLUME_POS 24
+#define URL_POS 25
+#define CUSTOM1_POS 26
+#define CUSTOM2_POS 27
+#define CUSTOM3_POS 28
+#define CUSTOM4_POS 29
+#define CUSTOM5_POS 30
+//-----------------------------------------------------------------------------
+struct StringPair
+{
+ rtl::OUString sRealColumnName;
+ rtl::OUString sLogicalColumnName;
+};
+//-----------------------------------------------------------------------------
+struct Mapping
+{
+ rtl::OUString sTableName;
+ rtl::OUString sURL;
+ sal_Int16 nCommandType;
+ StringPair aColumnPairs[COLUMN_COUNT];
+
+ Mapping() :
+ nCommandType(0){}
+};
+//-----------------------------------------------------------------------------
+struct BibDBDescriptor
+{
+ rtl::OUString sDataSource;
+ rtl::OUString sTableOrQuery;
+ sal_Int32 nCommandType;
+};
+//-----------------------------------------------------------------------------
+
+class BibConfig : public utl::ConfigItem
+{
+ rtl::OUString sDataSource;
+ rtl::OUString sTableOrQuery;
+ sal_Int32 nTblOrQuery;
+
+ rtl::OUString sQueryField;
+ rtl::OUString sQueryText;
+ MappingArray* pMappingsArr;
+ long nBeamerSize;
+ long nViewSize;
+ sal_Bool bShowColumnAssignmentWarning;
+
+ rtl::OUString aColumnDefaults[COLUMN_COUNT];
+
+ com::sun::star::uno::Sequence<rtl::OUString> GetPropertyNames();
+public:
+ BibConfig();
+ ~BibConfig();
+
+ virtual void Commit();
+ virtual void Notify( const com::sun::star::uno::Sequence<rtl::OUString>& aPropertyNames);
+
+ BibDBDescriptor GetBibliographyURL();
+ void SetBibliographyURL(const BibDBDescriptor& rDesc);
+
+ const Mapping* GetMapping(const BibDBDescriptor& rDesc) const;
+ void SetMapping(const BibDBDescriptor& rDesc, const Mapping* pMapping);
+
+ const rtl::OUString& GetDefColumnName(sal_uInt16 nIndex) const
+ {return aColumnDefaults[nIndex];}
+
+
+ void setBeamerSize(long nSize) {SetModified(); nBeamerSize = nSize;}
+ long getBeamerSize()const {return nBeamerSize;}
+ void setViewSize(long nSize) {SetModified(); nViewSize = nSize;}
+ long getViewSize() {return nViewSize;}
+
+ const rtl::OUString& getQueryField() const {return sQueryField;}
+ void setQueryField(const rtl::OUString& rSet) {SetModified(); sQueryField = rSet;}
+
+ const rtl::OUString& getQueryText() const {return sQueryText;}
+ void setQueryText(const rtl::OUString& rSet) {SetModified(); sQueryText = rSet;}
+
+ sal_Bool IsShowColumnAssignmentWarning() const
+ { return bShowColumnAssignmentWarning;}
+ void SetShowColumnAssignmentWarning(sal_Bool bSet)
+ { bShowColumnAssignmentWarning = bSet;}
+};
+/* -----------------------------20.11.00 11:47--------------------------------
+
+ ---------------------------------------------------------------------------*/
+class DBChangeDialogConfig_Impl
+{
+ com::sun::star::uno::Sequence<rtl::OUString> aSourceNames;
+public:
+ DBChangeDialogConfig_Impl();
+ ~DBChangeDialogConfig_Impl();
+
+ const com::sun::star::uno::Sequence<rtl::OUString>& GetDataSourceNames();
+
+};
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/bibliography/bibcont.cxx b/extensions/source/bibliography/bibcont.cxx
new file mode 100644
index 000000000000..2c3e0f4d1e37
--- /dev/null
+++ b/extensions/source/bibliography/bibcont.cxx
@@ -0,0 +1,278 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+
+#include <osl/mutex.hxx>
+#include <tools/urlobj.hxx>
+#include <cppuhelper/weak.hxx>
+#include <unotools/processfactory.hxx>
+#include <toolkit/helper/vclunohelper.hxx>
+#include <com/sun/star/awt/XWindow.hpp>
+#include <com/sun/star/awt/XWindowPeer.hpp>
+#include <com/sun/star/frame/XDispatchProvider.hpp>
+#include <com/sun/star/frame/FrameSearchFlag.hpp>
+#include <com/sun/star/util/XURLTransformer.hpp>
+#include "bibconfig.hxx"
+
+
+#include "datman.hxx"
+#include "bibcont.hxx"
+
+
+BibShortCutHandler::~BibShortCutHandler()
+{
+}
+
+sal_Bool BibShortCutHandler::HandleShortCutKey( const KeyEvent& )
+{
+ return sal_False;
+}
+
+
+BibWindow::BibWindow( Window* pParent, WinBits nStyle ) : Window( pParent, nStyle ), BibShortCutHandler( this )
+{
+}
+
+BibWindow::~BibWindow()
+{
+}
+
+
+BibSplitWindow::BibSplitWindow( Window* pParent, WinBits nStyle ) : SplitWindow( pParent, nStyle ), BibShortCutHandler( this )
+{
+}
+
+BibSplitWindow::~BibSplitWindow()
+{
+}
+
+
+BibTabPage::BibTabPage( Window* pParent, const ResId& rResId ) : TabPage( pParent, rResId ), BibShortCutHandler( this )
+{
+}
+
+BibTabPage::~BibTabPage()
+{
+}
+
+
+using namespace osl;
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::frame;
+using namespace ::rtl;
+
+#define C2U(cChar) OUString::createFromAscii(cChar)
+#define PROPERTY_FRAME 1
+//split window size is a percent value
+#define WIN_MIN_HEIGHT 10
+#define WIN_STEP_SIZE 5
+
+BibWindowContainer::BibWindowContainer( Window* pParent, BibShortCutHandler* pChildWin, WinBits nStyle ) :
+ BibWindow( pParent, nStyle ),
+ pChild( pChildWin )
+{
+ if(pChild!=NULL)
+ {
+ Window* pChildWindow = GetChild();
+ pChildWindow->SetParent(this);
+ pChildWindow->Show();
+ pChildWindow->SetPosPixel(Point(0,0));
+ }
+}
+
+BibWindowContainer::~BibWindowContainer()
+{
+ if( pChild )
+ {
+ Window* pDel = GetChild();
+ pChild = NULL; // prevents GetFocus for child while deleting!
+ delete pDel;
+ }
+}
+
+void BibWindowContainer::Resize()
+{
+ if( pChild )
+ GetChild()->SetSizePixel( GetOutputSizePixel() );
+}
+
+void BibWindowContainer::GetFocus()
+{
+ if( pChild )
+ GetChild()->GrabFocus();
+}
+
+sal_Bool BibWindowContainer::HandleShortCutKey( const KeyEvent& rKeyEvent )
+{
+ return pChild? pChild->HandleShortCutKey( rKeyEvent ) : sal_False;
+}
+
+
+BibBookContainer::BibBookContainer(Window* pParent,BibDataManager* pDtMn, WinBits nStyle):
+ BibSplitWindow(pParent,nStyle),
+ pDatMan(pDtMn),
+ pTopWin(NULL),
+ pBottomWin(NULL),
+ bFirstTime(sal_True)
+{
+ pBibMod = OpenBibModul();
+ aTimer.SetTimeoutHdl(LINK( this, BibBookContainer, SplitHdl));
+ aTimer.SetTimeout(400);
+}
+
+BibBookContainer::~BibBookContainer()
+{
+ if( xTopFrameRef.is() )
+ xTopFrameRef->dispose();
+ if( xBottomFrameRef.is() )
+ xBottomFrameRef->dispose();
+
+ if( pTopWin )
+ {
+ Window* pDel = pTopWin;
+ pTopWin = NULL; // prevents GetFocus for child while deleting!
+ delete pDel;
+ }
+
+ if( pBottomWin )
+ {
+ Window* pDel = pBottomWin;
+ pBottomWin = NULL; // prevents GetFocus for child while deleting!
+ delete pDel;
+ }
+
+ CloseBibModul( pBibMod );
+}
+
+void BibBookContainer::Split()
+{
+ aTimer.Start();
+}
+IMPL_LINK( BibBookContainer, SplitHdl, Timer*,/*pT*/)
+{
+ long nSize= GetItemSize( TOP_WINDOW);
+ BibConfig* pConfig = BibModul::GetConfig();
+ pConfig->setBeamerSize(nSize);
+ nSize = GetItemSize( BOTTOM_WINDOW);
+ pConfig->setViewSize(nSize);
+ return 0;
+}
+
+void BibBookContainer::createTopFrame( BibShortCutHandler* pWin )
+{
+ if ( xTopFrameRef.is() ) xTopFrameRef->dispose();
+
+ if(pTopWin)
+ {
+ RemoveItem(TOP_WINDOW);
+ delete pTopWin;
+ }
+ pTopWin=new BibWindowContainer(this,pWin);
+ pTopWin->Show();
+ BibConfig* pConfig = BibModul::GetConfig();
+ long nSize = pConfig->getBeamerSize();
+ InsertItem(TOP_WINDOW, pTopWin, nSize, 1, 0, SWIB_PERCENTSIZE );
+
+}
+
+void BibBookContainer::createBottomFrame( BibShortCutHandler* pWin )
+{
+ if ( xBottomFrameRef.is() ) xBottomFrameRef->dispose();
+
+ if(pBottomWin)
+ {
+ RemoveItem(BOTTOM_WINDOW);
+ delete pBottomWin;
+ }
+
+ pBottomWin=new BibWindowContainer(this,pWin);
+
+ BibConfig* pConfig = BibModul::GetConfig();
+ long nSize = pConfig->getViewSize();
+ InsertItem(BOTTOM_WINDOW, pBottomWin, nSize, 1, 0, SWIB_PERCENTSIZE );
+
+}
+
+void BibBookContainer::GetFocus()
+{
+ if( pBottomWin )
+ pBottomWin->GrabFocus();
+}
+
+long BibBookContainer::PreNotify( NotifyEvent& rNEvt )
+{
+ long nHandled = 0;
+ if( EVENT_KEYINPUT == rNEvt.GetType() )
+ {
+ const KeyEvent* pKEvt = rNEvt.GetKeyEvent();
+ const KeyCode aKeyCode = pKEvt->GetKeyCode();
+ USHORT nKey = aKeyCode.GetCode();
+ const USHORT nModifier = aKeyCode.GetModifier();
+
+ if( KEY_MOD2 == nModifier )
+ {
+ if( KEY_UP == nKey || KEY_DOWN == nKey )
+ {
+ if(pTopWin && pBottomWin)
+ {
+ USHORT nFirstWinId = KEY_UP == nKey ? TOP_WINDOW : BOTTOM_WINDOW;
+ USHORT nSecondWinId = KEY_UP == nKey ? BOTTOM_WINDOW : TOP_WINDOW;
+ long nHeight = GetItemSize( nFirstWinId );
+ nHeight -= WIN_STEP_SIZE;
+ if(nHeight < WIN_MIN_HEIGHT)
+ nHeight = WIN_MIN_HEIGHT;
+ SetItemSize( nFirstWinId, nHeight );
+ SetItemSize( nSecondWinId, 100 - nHeight );
+ }
+ nHandled = 1;
+ }
+ else if( pKEvt->GetCharCode() && HandleShortCutKey( *pKEvt ) )
+ nHandled = 1;
+ }
+ }
+
+ return nHandled;
+}
+
+sal_Bool BibBookContainer::HandleShortCutKey( const KeyEvent& rKeyEvent )
+{
+ sal_Bool bRet = sal_False;
+
+ if( pTopWin )
+ bRet = pTopWin->HandleShortCutKey( rKeyEvent );
+
+ if( !bRet && pBottomWin )
+ bRet = pBottomWin->HandleShortCutKey( rKeyEvent );
+
+ return bRet;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/bibliography/bibcont.hxx b/extensions/source/bibliography/bibcont.hxx
new file mode 100644
index 000000000000..54659be8ec08
--- /dev/null
+++ b/extensions/source/bibliography/bibcont.hxx
@@ -0,0 +1,117 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef ADDRCONT_HXX
+#define ADDRCONT_HXX
+
+#include <com/sun/star/frame/XFrame.hpp>
+#include <vcl/splitwin.hxx>
+#include <vcl/timer.hxx>
+#include "bibshortcuthandler.hxx"
+
+#include "bibmod.hxx"
+
+#define TOP_WINDOW 1
+#define BOTTOM_WINDOW 2
+
+class BibDataManager;
+
+class BibWindowContainer : public BibWindow //Window
+{
+ private:
+ // !BibShortCutHandler is also always a Window!
+ BibShortCutHandler* pChild;
+
+ protected:
+ virtual void Resize();
+
+ public:
+ BibWindowContainer( Window* pParent, BibShortCutHandler* pChild, WinBits nStyle = WB_3DLOOK);
+ ~BibWindowContainer();
+
+ inline Window* GetChild();
+
+ virtual void GetFocus();
+
+ virtual BOOL HandleShortCutKey( const KeyEvent& rKeyEvent ); // returns true, if key was handled
+
+ using Window::GetChild;
+};
+
+inline Window* BibWindowContainer::GetChild()
+{
+ return pChild? pChild->GetWindow() : NULL;
+}
+
+
+class BibBookContainer: public BibSplitWindow
+{
+ private:
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > xTopFrameRef;
+ ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > xBottomFrameRef;
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > xTopPeerRef;
+ ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > xBottomPeerRef;
+
+ BibDataManager* pDatMan;
+ BibWindowContainer* pTopWin;
+ BibWindowContainer* pBottomWin;
+ sal_Bool bFirstTime;
+ HdlBibModul pBibMod;
+ Timer aTimer;
+
+ DECL_LINK( SplitHdl, Timer*);
+
+ protected:
+
+ virtual void Split();
+
+ virtual long PreNotify( NotifyEvent& rNEvt );
+
+ public:
+
+ BibBookContainer(Window* pParent,BibDataManager*, WinBits nStyle = WB_3DLOOK );
+ ~BibBookContainer();
+
+ inline BibWindow* GetTopWin() {return pTopWin;}
+ inline BibWindow* GetBottomWin() {return pBottomWin;}
+
+ // !BibShortCutHandler is also always a Window!
+ void createTopFrame( BibShortCutHandler* pWin );
+
+ void createBottomFrame( BibShortCutHandler* pWin );
+
+ virtual void GetFocus();
+
+ virtual sal_Bool HandleShortCutKey( const KeyEvent& rKeyEvent ); // returns true, if key was handled
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/bibliography/bibload.cxx b/extensions/source/bibliography/bibload.cxx
new file mode 100644
index 000000000000..776f50a03067
--- /dev/null
+++ b/extensions/source/bibliography/bibload.cxx
@@ -0,0 +1,805 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+
+
+#include <osl/mutex.hxx>
+#include <tools/urlobj.hxx>
+#include <tools/diagnose_ex.h>
+#include <cppuhelper/weak.hxx>
+#include <svl/itemprop.hxx>
+#include <uno/environment.h>
+#include <svl/urihelper.hxx>
+#include <toolkit/helper/vclunohelper.hxx>
+#include <comphelper/processfactory.hxx>
+#include <cppuhelper/factory.hxx> // helper for factories
+#include <com/sun/star/sdbc/ResultSetType.hpp>
+#include <com/sun/star/sdbc/ResultSetConcurrency.hpp>
+#include <com/sun/star/sdb/XColumn.hpp>
+#include <com/sun/star/util/XURLTransformer.hpp>
+#include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
+#include <com/sun/star/sdbc/XRowSet.hpp>
+#include <com/sun/star/sdb/CommandType.hpp>
+#include <com/sun/star/frame/XFrameLoader.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/lang/XSingleServiceFactory.hpp>
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/container/XNameAccess.hpp>
+#include <com/sun/star/text/BibliographyDataField.hpp>
+#include <com/sun/star/form/XLoadListener.hpp>
+#include <com/sun/star/frame/XLayoutManager.hpp>
+#include <toolkit/awt/vclxwindow.hxx>
+#include <vcl/window.hxx>
+#include <vcl/edit.hxx>
+#include <vcl/svapp.hxx>
+#include <vcl/group.hxx>
+#include <svtools/svmedit.hxx>
+
+#include "bibresid.hxx"
+#include "bib.hrc"
+#include "bibcont.hxx"
+#include "bibbeam.hxx"
+#include "bibmod.hxx"
+#include "bibview.hxx"
+#include "framectr.hxx"
+#include "datman.hxx"
+#include <bibconfig.hxx>
+#include <cppuhelper/implbase4.hxx> // helper for implementations
+
+using namespace ::rtl;
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::sdb;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::form;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::frame;
+
+#define C2U(cChar) OUString::createFromAscii(cChar)
+
+
+//-----------------------------------------------------------------------------
+
+#define PROPERTY_FRAME 1
+
+class BibliographyLoader : public cppu::WeakImplHelper4
+ < XServiceInfo, XNameAccess, XPropertySet, XFrameLoader >
+{
+ HdlBibModul m_pBibMod;
+ Reference< XLoadable > m_xDatMan;
+ BibDataManager* m_pDatMan;
+ Reference< XNameAccess > m_xColumns;
+ Reference< XResultSet > m_xCursor;
+
+private:
+
+ void loadView(const Reference< XFrame > & aFrame, const rtl::OUString& aURL,
+ const Sequence< PropertyValue >& aArgs,
+ const Reference< XLoadEventListener > & aListener);
+
+ BibDataManager* GetDataManager()const;
+ Reference< XNameAccess > GetDataColumns() const;
+ Reference< XResultSet > GetDataCursor() const;
+ Reference< sdb::XColumn > GetIdentifierColumn() const;
+
+public:
+ BibliographyLoader();
+ ~BibliographyLoader();
+
+ // XServiceInfo
+ rtl::OUString SAL_CALL getImplementationName() throw( );
+ sal_Bool SAL_CALL supportsService(const rtl::OUString& ServiceName) throw( );
+ Sequence< rtl::OUString > SAL_CALL getSupportedServiceNames(void) throw( );
+ static rtl::OUString getImplementationName_Static() throw( )
+
+ {
+ //!
+ return C2U("com.sun.star.extensions.Bibliography");
+ //!
+ }
+
+ //XNameAccess
+ virtual Any SAL_CALL getByName(const rtl::OUString& aName) throw ( NoSuchElementException, WrappedTargetException, RuntimeException );
+ virtual Sequence< rtl::OUString > SAL_CALL getElementNames(void) throw ( RuntimeException );
+ virtual sal_Bool SAL_CALL hasByName(const rtl::OUString& aName) throw ( RuntimeException );
+
+ //XElementAccess
+ virtual Type SAL_CALL getElementType(void) throw ( RuntimeException );
+ virtual sal_Bool SAL_CALL hasElements(void) throw ( RuntimeException );
+
+ //XPropertySet
+ virtual Reference< XPropertySetInfo > SAL_CALL getPropertySetInfo(void) throw ( RuntimeException );
+ virtual void SAL_CALL setPropertyValue(const rtl::OUString& PropertyName, const Any& aValue) throw( UnknownPropertyException, PropertyVetoException, IllegalArgumentException, WrappedTargetException, RuntimeException );
+ virtual Any SAL_CALL getPropertyValue(const rtl::OUString& PropertyName) throw ( UnknownPropertyException, WrappedTargetException, RuntimeException );
+ virtual void SAL_CALL addPropertyChangeListener(const rtl::OUString& PropertyName, const Reference< XPropertyChangeListener > & aListener) throw( UnknownPropertyException, WrappedTargetException, RuntimeException );
+ virtual void SAL_CALL removePropertyChangeListener(const rtl::OUString& PropertyName, const Reference< XPropertyChangeListener > & aListener) throw( UnknownPropertyException, WrappedTargetException, RuntimeException );
+ virtual void SAL_CALL addVetoableChangeListener(const rtl::OUString& PropertyName, const Reference< XVetoableChangeListener > & aListener) throw( UnknownPropertyException, WrappedTargetException, RuntimeException );
+ virtual void SAL_CALL removeVetoableChangeListener(const rtl::OUString& PropertyName, const Reference< XVetoableChangeListener > & aListener) throw( UnknownPropertyException, WrappedTargetException, RuntimeException );
+
+ static Sequence<rtl::OUString> SAL_CALL getSupportedServiceNames_Static(void) throw( );
+
+ friend Reference< XInterface > SAL_CALL BibliographyLoader_CreateInstance( const Reference< XMultiServiceFactory > & rSMgr ) throw( Exception );
+
+ // XLoader
+ virtual void SAL_CALL load(const Reference< XFrame > & aFrame, const rtl::OUString& aURL,
+ const Sequence< PropertyValue >& aArgs,
+ const Reference< XLoadEventListener > & aListener) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL cancel(void) throw (::com::sun::star::uno::RuntimeException);
+};
+
+BibliographyLoader::BibliographyLoader() :
+ m_pBibMod(0),
+ m_pDatMan(0)
+{
+}
+
+BibliographyLoader::~BibliographyLoader()
+{
+ Reference< lang::XComponent > xComp(m_xCursor, UNO_QUERY);
+ if (xComp.is())
+ xComp->dispose();
+ if(m_pBibMod)
+ CloseBibModul(m_pBibMod);
+}
+
+
+Reference< XInterface > SAL_CALL BibliographyLoader_CreateInstance( const Reference< XMultiServiceFactory > & /*rSMgr*/ ) throw( Exception )
+{
+ return *(new BibliographyLoader);
+}
+
+
+// XServiceInfo
+rtl::OUString BibliographyLoader::getImplementationName() throw( )
+
+{
+ return getImplementationName_Static();
+}
+
+// XServiceInfo
+sal_Bool BibliographyLoader::supportsService(const rtl::OUString& ServiceName) throw( )
+{
+ Sequence< rtl::OUString > aSNL = getSupportedServiceNames();
+ const rtl::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< rtl::OUString > BibliographyLoader::getSupportedServiceNames(void) throw( )
+{
+ return getSupportedServiceNames_Static();
+}
+
+// ORegistryServiceManager_Static
+Sequence< rtl::OUString > BibliographyLoader::getSupportedServiceNames_Static(void) throw( )
+{
+ Sequence< rtl::OUString > aSNS( 2 );
+ aSNS.getArray()[0] = C2U("com.sun.star.frame.FrameLoader");
+ //!
+ aSNS.getArray()[1] = C2U("com.sun.star.frame.Bibliography");
+ //!
+ return aSNS;
+}
+
+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
+ , registry::XRegistryKey * pRegistryKey )
+ {
+ try
+ {
+ rtl::OUString sKey = rtl::OUString::createFromAscii("/");
+ sKey += BibliographyLoader::getImplementationName_Static();
+ //creates the impl key: /com.sun.star.extensions.Bibliography
+ Reference< registry::XRegistryKey > xImplKey = pRegistryKey->createKey(sKey);
+
+
+ //sKey += rtl::OUString::createFromAscii("/UNO/SERVICES");
+ Reference< registry::XRegistryKey > xNewKey = xImplKey->createKey( C2U("/UNO/SERVICES") );
+ Sequence< rtl::OUString > aServices = BibliographyLoader::getSupportedServiceNames_Static();
+ for( INT32 i = 0; i < aServices.getLength(); i++ )
+ xNewKey->createKey( aServices.getConstArray()[i]);
+ xNewKey = xImplKey->createKey( C2U("/UNO/Loader"));
+
+ Reference< registry::XRegistryKey > xPatternKey = xImplKey->createKey( C2U("/Loader/Pattern" ));
+ xPatternKey->setAsciiValue( C2U( ".component:Bibliography/*" ) );
+
+ return sal_True;
+ }
+ catch (Exception &)
+ {
+ return sal_False;
+ }
+ }
+
+
+ void * SAL_CALL component_getFactory(
+ const sal_Char * pImplName, XMultiServiceFactory * pServiceManager, void * /*pRegistryKey*/ )
+ {
+ void * pRet = 0;
+ if (!BibliographyLoader::getImplementationName_Static().compareToAscii( pImplName ) )
+ {
+ // create the factory
+ Reference< XSingleServiceFactory > xFactory =
+ cppu::createSingleFactory(
+ pServiceManager,
+ BibliographyLoader::getImplementationName_Static(),
+ BibliographyLoader_CreateInstance,
+ BibliographyLoader::getSupportedServiceNames_Static() );
+ // acquire, because we return an interface pointer instead of a reference
+ xFactory->acquire();
+ pRet = xFactory.get();
+ }
+ return pRet;
+ }
+
+}
+// -----------------------------------------------------------------------
+void BibliographyLoader::cancel(void) throw (::com::sun::star::uno::RuntimeException)
+{
+ //!
+ //!
+}
+
+// -----------------------------------------------------------------------
+void BibliographyLoader::load(const Reference< XFrame > & rFrame, const rtl::OUString& rURL,
+ const Sequence< PropertyValue >& rArgs,
+ const Reference< XLoadEventListener > & rListener) throw (::com::sun::star::uno::RuntimeException)
+{
+ //!
+
+ SolarMutexGuard aGuard;
+ m_pBibMod = OpenBibModul();
+
+ String aURLStr( rURL );
+ String aPartName = aURLStr.GetToken( 1, '/' );
+ Reference<XPropertySet> xPrSet(rFrame, UNO_QUERY);
+ if(xPrSet.is())
+ {
+ Any aTitle;
+ aTitle <<= OUString(String(BibResId(RID_BIB_STR_FRAME_TITLE)));
+ xPrSet->setPropertyValue(C2U("Title"), aTitle);
+ }
+ if(aPartName.EqualsAscii("View") || aPartName.EqualsAscii("View1"))
+ {
+ loadView(rFrame, rURL, rArgs, rListener);
+ }
+}
+
+// -----------------------------------------------------------------------
+void BibliographyLoader::loadView(const Reference< XFrame > & rFrame, const rtl::OUString& /*rURL*/,
+ const Sequence< PropertyValue >& /*rArgs*/,
+ const Reference< XLoadEventListener > & rListener)
+{
+ SolarMutexGuard aGuard;
+ //!
+ if(!m_pBibMod)
+ m_pBibMod = OpenBibModul();
+
+/*
+ //create the menu
+ ResMgr* pResMgr = (*m_pBibMod)->GetResMgr();
+ INetURLObject aEntry( URIHelper::SmartRelToAbs(pResMgr->GetFileName()) );
+ String aMenuRes( RTL_CONSTASCII_USTRINGPARAM( "private:resource/" ));
+ aMenuRes += ( aEntry.GetName() += '/' );
+ aMenuRes+=String::CreateFromInt32(RID_MAIN_MENU);
+
+ util::URL aURL;
+ aURL.Complete = aMenuRes;
+
+ Reference< XMultiServiceFactory > xMgr = comphelper::getProcessServiceFactory();
+ Reference< util::XURLTransformer > xTrans ( xMgr->createInstance( C2U("com.sun.star.util.URLTransformer") ), UNO_QUERY );
+ if( xTrans.is() )
+ {
+ // Datei laden
+ xTrans->parseStrict( aURL );
+
+ Reference< XDispatchProvider > xProv( rFrame, UNO_QUERY );
+ if ( xProv.is() )
+ {
+ Reference< XDispatch > aDisp = xProv->queryDispatch( aURL, C2U("_menubar"), 12 );
+ if ( aDisp.is() )
+ aDisp->dispatch( aURL, Sequence<PropertyValue>() );
+ }
+ }
+*/
+ m_pDatMan = (*m_pBibMod)->createDataManager();
+ m_xDatMan = m_pDatMan;
+ BibDBDescriptor aBibDesc = BibModul::GetConfig()->GetBibliographyURL();
+
+ if(!aBibDesc.sDataSource.getLength())
+ {
+ DBChangeDialogConfig_Impl aConfig;
+ const Sequence<OUString> aSources = aConfig.GetDataSourceNames();
+ if(aSources.getLength())
+ aBibDesc.sDataSource = aSources.getConstArray()[0];
+ }
+
+ Reference< XForm > xForm = m_pDatMan->createDatabaseForm( aBibDesc );
+
+ Reference< awt::XWindow > aWindow = rFrame->getContainerWindow();
+ VCLXWindow* pParentComponent = VCLXWindow::GetImplementation(aWindow);
+
+ Window* pParent = VCLUnoHelper::GetWindow( aWindow );
+
+ BibBookContainer *pMyWindow = new BibBookContainer( pParent, m_pDatMan );
+ pMyWindow->Show();
+
+ ::bib::BibView* pView = new ::bib::BibView( pMyWindow, m_pDatMan, WB_VSCROLL | WB_HSCROLL | WB_3DLOOK );
+ pView->Show();
+ m_pDatMan->SetView( pView );
+
+ ::bib::BibBeamer* pBeamer = new ::bib::BibBeamer( pMyWindow, m_pDatMan );
+ pBeamer->Show();
+ pMyWindow->createTopFrame(pBeamer);
+
+ pMyWindow->createBottomFrame(pView);
+
+ Reference< awt::XWindow > xWin ( pMyWindow->GetComponentInterface(), UNO_QUERY );
+
+ Reference< XController > xCtrRef( new BibFrameController_Impl( xWin, m_pDatMan ) );
+
+ xCtrRef->attachFrame(rFrame);
+ rFrame->setComponent( xWin, xCtrRef);
+ pBeamer->SetXController(xCtrRef);
+ //!
+
+ // not earlier because SetFocus() is triggered in setVisible()
+ pParentComponent->setVisible(sal_True);
+
+ m_xDatMan->load();
+ // #100312# ----------
+ m_pDatMan->RegisterInterceptor(pBeamer);
+
+ if ( rListener.is() )
+ rListener->loadFinished( this );
+
+ // attach menu bar
+ Reference< XPropertySet > xPropSet( rFrame, UNO_QUERY );
+ Reference< ::com::sun::star::frame::XLayoutManager > xLayoutManager;
+ if ( xPropSet.is() )
+ {
+ try
+ {
+ Any a = xPropSet->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "LayoutManager" )));
+ a >>= xLayoutManager;
+ }
+ catch ( uno::Exception& )
+ {
+ }
+ }
+
+ if ( xLayoutManager.is() )
+ xLayoutManager->createElement( OUString( RTL_CONSTASCII_USTRINGPARAM( "private:resource/menubar/menubar" )));
+}
+/* -----------------06.12.99 14:37-------------------
+
+ --------------------------------------------------*/
+BibDataManager* BibliographyLoader::GetDataManager()const
+{
+ if(!m_pDatMan)
+ {
+ if(!m_pBibMod)
+ const_cast< BibliographyLoader* >( this )->m_pBibMod = OpenBibModul();
+ const_cast< BibliographyLoader* >( this )->m_pDatMan = (*m_pBibMod)->createDataManager();
+ const_cast< BibliographyLoader* >( this )->m_xDatMan = m_pDatMan;
+ }
+ return m_pDatMan;
+}
+/* -----------------06.12.99 14:39-------------------
+
+ --------------------------------------------------*/
+Reference< XNameAccess > BibliographyLoader::GetDataColumns() const
+{
+ if (!m_xColumns.is())
+ {
+ Reference< XMultiServiceFactory > xMgr = comphelper::getProcessServiceFactory();
+ Reference< XRowSet > xRowSet(xMgr->createInstance(C2U("com.sun.star.sdb.RowSet")), UNO_QUERY);
+ Reference< XPropertySet > xResultSetProps(xRowSet, UNO_QUERY);
+ DBG_ASSERT(xResultSetProps.is() , "BibliographyLoader::GetDataCursor : invalid row set (no XResultSet or no XPropertySet) !");
+
+ BibDBDescriptor aBibDesc = BibModul::GetConfig()->GetBibliographyURL();
+
+ Any aBibUrlAny; aBibUrlAny <<= aBibDesc.sDataSource;
+ xResultSetProps->setPropertyValue(C2U("DataSourceName"), aBibUrlAny);
+ Any aCommandType; aCommandType <<= aBibDesc.nCommandType;
+ xResultSetProps->setPropertyValue(C2U("CommandType"), aCommandType);
+ Any aTableName; aTableName <<= aBibDesc.sTableOrQuery;
+ xResultSetProps->setPropertyValue(C2U("Command"), aTableName);
+ Any aResultSetType; aResultSetType <<= (sal_Int32)(ResultSetType::SCROLL_INSENSITIVE);
+ xResultSetProps->setPropertyValue(C2U("ResultSetType"), aResultSetType);
+ Any aResultSetCurrency; aResultSetCurrency <<= (sal_Int32)(ResultSetConcurrency::UPDATABLE);
+ xResultSetProps->setPropertyValue(C2U("ResultSetConcurrency"), aResultSetCurrency);
+
+ sal_Bool bSuccess = sal_False;
+ try
+ {
+ xRowSet->execute();
+ bSuccess = sal_True;
+ }
+ catch(const SQLException&)
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ catch(const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ bSuccess = sal_False;
+ }
+
+ if (!bSuccess)
+ {
+ Reference< XComponent > xSetComp(xRowSet, UNO_QUERY);
+ if (xSetComp.is())
+ xSetComp->dispose();
+ xRowSet = NULL;
+ }
+ else
+ ((BibliographyLoader*)this)->m_xCursor = xRowSet.get();
+
+ Reference< sdbcx::XColumnsSupplier > xSupplyCols(m_xCursor, UNO_QUERY);
+ if (xSupplyCols.is())
+ ((BibliographyLoader*)this)->m_xColumns = xSupplyCols->getColumns();
+ }
+
+ return m_xColumns;
+}
+/* -----------------17.12.99 12:29-------------------
+
+ --------------------------------------------------*/
+Reference< sdb::XColumn > BibliographyLoader::GetIdentifierColumn() const
+{
+ BibDataManager* pDatMan = GetDataManager();
+ Reference< XNameAccess > xColumns = GetDataColumns();
+ rtl::OUString sIdentifierColumnName = pDatMan->GetIdentifierMapping();
+
+ Reference< sdb::XColumn > xReturn;
+ if (xColumns.is() && xColumns->hasByName(sIdentifierColumnName))
+ {
+ xReturn = Reference< XColumn > (*(Reference< XInterface > *)
+ xColumns->getByName(sIdentifierColumnName).getValue(), UNO_QUERY);
+ }
+ return xReturn;
+}
+
+/* -----------------06.12.99 15:05-------------------
+
+ --------------------------------------------------*/
+Reference< XResultSet > BibliographyLoader::GetDataCursor() const
+{
+ if (!m_xCursor.is())
+ GetDataColumns();
+ if (m_xCursor.is())
+ m_xCursor->first();
+ return m_xCursor;
+}
+
+/*-- 17.11.99 12:51:38---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+rtl::OUString lcl_AddProperty(Reference< XNameAccess > xColumns,
+ const Mapping* pMapping, const String& rColumnName)
+{
+ String sColumnName(rColumnName);
+ if(pMapping)
+ {
+ for(sal_uInt16 nEntry = 0; nEntry < COLUMN_COUNT; nEntry++)
+ {
+ if(pMapping->aColumnPairs[nEntry].sLogicalColumnName == OUString(rColumnName))
+ {
+ sColumnName = pMapping->aColumnPairs[nEntry].sRealColumnName;
+ break;
+ }
+ }
+ }
+ rtl::OUString uColumnName(sColumnName);
+ rtl::OUString uRet;
+ Reference< sdb::XColumn > xCol;
+ if (xColumns->hasByName(uColumnName))
+ xCol = Reference< sdb::XColumn > (*(Reference< XInterface > *)xColumns->getByName(uColumnName).getValue(), UNO_QUERY);
+ if (xCol.is())
+ uRet = xCol->getString();
+ return uRet;
+}
+//-----------------------------------------------------------------------------
+Any BibliographyLoader::getByName(const rtl::OUString& rName) throw
+ ( NoSuchElementException, WrappedTargetException, RuntimeException )
+{
+ Any aRet;
+ try
+ {
+ BibDataManager* pDatMan = ((BibliographyLoader*)this)->GetDataManager();
+ Reference< XResultSet > xCursor = GetDataCursor();
+ Reference< sdbcx::XColumnsSupplier > xSupplyCols(xCursor, UNO_QUERY);
+ Reference< XNameAccess > xColumns;
+ if (!xSupplyCols.is())
+ return aRet;
+ xColumns = xSupplyCols->getColumns();
+ DBG_ASSERT(xSupplyCols.is(), "BibliographyLoader::getByName : invalid columns returned by the data cursor (may be the result set is not alive ?) !");
+ if (!xColumns.is())
+ return aRet;
+
+ String sIdentifierMapping = pDatMan->GetIdentifierMapping();
+ rtl::OUString sId = sIdentifierMapping;
+ Reference< sdb::XColumn > xColumn;
+ if (xColumns->hasByName(sId))
+ xColumn = Reference< sdb::XColumn > (*(Reference< XInterface > *)xColumns->getByName(sId).getValue(), UNO_QUERY);
+ if (xColumn.is())
+ {
+ do
+ {
+ if ((rName == xColumn->getString()) && !xColumn->wasNull())
+ {
+ Sequence<PropertyValue> aPropSequ(COLUMN_COUNT);
+ PropertyValue* pValues = aPropSequ.getArray();
+ BibConfig* pConfig = BibModul::GetConfig();
+ BibDBDescriptor aBibDesc = BibModul::GetConfig()->GetBibliographyURL();
+ const Mapping* pMapping = pConfig->GetMapping(aBibDesc);
+ for(sal_uInt16 nEntry = 0; nEntry < COLUMN_COUNT; nEntry++)
+ {
+ const String sColName = pConfig->GetDefColumnName(
+ nEntry);
+ pValues[nEntry].Name = sColName;
+ pValues[nEntry].Value <<= lcl_AddProperty(xColumns, pMapping, sColName);
+ }
+ aRet.setValue(&aPropSequ, ::getCppuType((Sequence<PropertyValue>*)0));
+
+ break;
+ }
+ }
+ while(xCursor->next());
+ }
+ }
+ catch(const Exception&)
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ return aRet;
+}
+/*-- 17.11.99 12:51:39---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+Sequence< rtl::OUString > BibliographyLoader::getElementNames(void) throw ( RuntimeException )
+{
+ Sequence< rtl::OUString > aRet(10);
+ int nRealNameCount = 0;
+ try
+ {
+ Reference< XResultSet > xCursor(GetDataCursor());
+ Reference< sdb::XColumn > xIdColumn(GetIdentifierColumn());
+ if (xIdColumn.is()) // implies xCursor.is()
+ {
+ do
+ {
+ rtl::OUString sTemp = xIdColumn->getString();
+ if (sTemp.getLength() && !xIdColumn->wasNull())
+ {
+ int nLen = aRet.getLength();
+ if(nLen == nRealNameCount)
+ aRet.realloc(nLen + 10);
+ rtl::OUString* pArray = aRet.getArray();
+ pArray[nRealNameCount] = sTemp;
+ nRealNameCount++;
+ }
+ }
+ while (xCursor->next());
+ }
+ }
+ catch(const Exception&)
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+ aRet.realloc(nRealNameCount);
+ return aRet;
+}
+/*-- 17.11.99 12:51:39---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+sal_Bool BibliographyLoader::hasByName(const rtl::OUString& rName) throw ( RuntimeException )
+{
+ sal_Bool bRet = sal_False;
+ try
+ {
+ Reference< XResultSet > xCursor = GetDataCursor();
+ Reference< sdb::XColumn > xIdColumn = GetIdentifierColumn();
+
+ if (xIdColumn.is()) // implies xCursor.is()
+ {
+ do
+ {
+ rtl::OUString sCurrentId = xIdColumn->getString();
+ if (!xIdColumn->wasNull() && (rName.compareTo(sCurrentId) == COMPARE_EQUAL))
+ {
+ bRet = sal_True;
+ break;
+ }
+ }
+ while(xCursor->next());
+ }
+ }
+ catch(const Exception&)
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ return bRet;
+}
+/*-- 17.11.99 12:51:39---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+Type BibliographyLoader::getElementType(void) throw ( RuntimeException )
+{
+ return ::getCppuType((Sequence<PropertyValue>*)0);
+}
+/*-- 17.11.99 12:51:40---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+sal_Bool BibliographyLoader::hasElements(void) throw ( RuntimeException )
+{
+ Reference< XResultSet > xCursor = GetDataCursor();
+ Reference< XNameAccess > xColumns = GetDataColumns();
+ return xColumns.is() && (xColumns->getElementNames().getLength() != 0);
+}
+
+/*-- 07.12.99 14:28:39---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+Reference< XPropertySetInfo > BibliographyLoader::getPropertySetInfo(void) throw
+ ( RuntimeException )
+{
+ static SfxItemPropertyMapEntry aBibProps_Impl[] =
+ {
+ { MAP_CHAR_LEN("BibliographyDataFieldNames"), 0, &::getCppuType((Sequence<PropertyValue>*)0), PropertyAttribute::READONLY, 0},
+ {0,0,0,0,0,0}
+ };
+ static Reference< XPropertySetInfo > xRet =
+ SfxItemPropertySet(aBibProps_Impl).getPropertySetInfo();
+ return xRet;
+}
+/*-- 07.12.99 14:28:39---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+void BibliographyLoader::setPropertyValue(const rtl::OUString& /*PropertyName*/,
+ const Any& /*aValue*/)
+ throw( UnknownPropertyException, PropertyVetoException,
+ IllegalArgumentException, WrappedTargetException, RuntimeException)
+{
+ throw UnknownPropertyException();
+ //no changeable properties
+}
+/*-- 07.12.99 14:28:39---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+Any BibliographyLoader::getPropertyValue(const rtl::OUString& rPropertyName)
+ throw( UnknownPropertyException, WrappedTargetException, RuntimeException )
+{
+ Any aRet;
+ static const sal_uInt16 aInternalMapping[] =
+ {
+ IDENTIFIER_POS , // BibliographyDataField_IDENTIFIER
+ AUTHORITYTYPE_POS , // BibliographyDataField_BIBILIOGRAPHIC_TYPE
+ ADDRESS_POS , // BibliographyDataField_ADDRESS
+ ANNOTE_POS , // BibliographyDataField_ANNOTE
+ AUTHOR_POS , // BibliographyDataField_AUTHOR
+ BOOKTITLE_POS , // BibliographyDataField_BOOKTITLE
+ CHAPTER_POS , // BibliographyDataField_CHAPTER
+ EDITION_POS , // BibliographyDataField_EDITION
+ EDITOR_POS , // BibliographyDataField_EDITOR
+ HOWPUBLISHED_POS , // BibliographyDataField_HOWPUBLISHED
+ INSTITUTION_POS , // BibliographyDataField_INSTITUTION
+ JOURNAL_POS , // BibliographyDataField_JOURNAL
+ MONTH_POS , // BibliographyDataField_MONTH
+ NOTE_POS , // BibliographyDataField_NOTE
+ NUMBER_POS , // BibliographyDataField_NUMBER
+ ORGANIZATIONS_POS , // BibliographyDataField_ORGANIZATIONS
+ PAGES_POS , // BibliographyDataField_PAGES
+ PUBLISHER_POS , // BibliographyDataField_PUBLISHER
+ SCHOOL_POS , // BibliographyDataField_SCHOOL
+ SERIES_POS , // BibliographyDataField_SERIES
+ TITLE_POS , // BibliographyDataField_TITLE
+ REPORTTYPE_POS , // BibliographyDataField_REPORT_TYPE
+ VOLUME_POS , // BibliographyDataField_VOLUME
+ YEAR_POS , // BibliographyDataField_YEAR
+ URL_POS , // BibliographyDataField_URL
+ CUSTOM1_POS , // BibliographyDataField_CUSTOM1
+ CUSTOM2_POS , // BibliographyDataField_CUSTOM2
+ CUSTOM3_POS , // BibliographyDataField_CUSTOM3
+ CUSTOM4_POS , // BibliographyDataField_CUSTOM4
+ CUSTOM5_POS , // BibliographyDataField_CUSTOM5
+ ISBN_POS //BibliographyDataField_ISBN
+ };
+ if(C2U("BibliographyDataFieldNames") == rPropertyName)
+ {
+ Sequence<PropertyValue> aSeq(COLUMN_COUNT);
+ PropertyValue* pArray = aSeq.getArray();
+ BibConfig* pConfig = BibModul::GetConfig();
+ for(sal_uInt16 i = 0; i <= text::BibliographyDataField::ISBN ; i++)
+ {
+ pArray[i].Name = pConfig->GetDefColumnName(aInternalMapping[i]);
+ pArray[i].Value <<= (sal_Int16) i;
+ }
+ aRet.setValue(&aSeq, ::getCppuType((Sequence<PropertyValue>*)0));
+ }
+ else
+ throw UnknownPropertyException();
+ return aRet;
+}
+/*-- 07.12.99 14:28:40---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+void BibliographyLoader::addPropertyChangeListener(
+ const rtl::OUString& /*PropertyName*/, const Reference< XPropertyChangeListener > & /*aListener*/)
+ throw( UnknownPropertyException, WrappedTargetException, RuntimeException )
+{
+ //no bound properties
+}
+/*-- 07.12.99 14:28:40---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+void BibliographyLoader::removePropertyChangeListener(
+ const rtl::OUString& /*PropertyName*/, const Reference< XPropertyChangeListener > & /*aListener*/)
+ throw( UnknownPropertyException, WrappedTargetException, RuntimeException )
+{
+ //no bound properties
+}
+/*-- 07.12.99 14:28:40---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+void BibliographyLoader::addVetoableChangeListener(
+ const rtl::OUString& /*PropertyName*/, const Reference< XVetoableChangeListener > & /*aListener*/)
+ throw( UnknownPropertyException, WrappedTargetException, RuntimeException )
+{
+ //no vetoable properties
+}
+/*-- 07.12.99 14:28:40---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+void BibliographyLoader::removeVetoableChangeListener(
+ const rtl::OUString& /*PropertyName*/, const Reference< XVetoableChangeListener > & /*aListener*/)
+ throw( UnknownPropertyException, WrappedTargetException, RuntimeException )
+{
+ //no vetoable properties
+}
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/bibliography/bibmod.cxx b/extensions/source/bibliography/bibmod.cxx
new file mode 100644
index 000000000000..a9809282d354
--- /dev/null
+++ b/extensions/source/bibliography/bibmod.cxx
@@ -0,0 +1,125 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+
+
+#include <tools/resmgr.hxx>
+#include <tools/urlobj.hxx>
+#include <svl/urihelper.hxx>
+#include <com/sun/star/container/XNameAccess.hpp>
+#include <com/sun/star/util/XLocalizedAliases.hpp>
+#include <com/sun/star/lang/XLocalizable.hpp>
+#include <tools/debug.hxx>
+
+#include "bibmod.hxx"
+#include "bibresid.hxx"
+#include "datman.hxx"
+#include "bibconfig.hxx"
+static PtrBibModul pBibModul=NULL;
+static sal_uInt32 nBibModulCount=0;
+#include <ucbhelper/content.hxx>
+
+using namespace ::rtl;
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::util;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::ucb;
+
+#define C2U(cChar) OUString::createFromAscii(cChar)
+#define C2S(cChar) String::CreateFromAscii(cChar)
+
+HdlBibModul OpenBibModul()
+{
+ if(pBibModul==NULL)
+ {
+ pBibModul=new BibModul();
+ }
+ nBibModulCount++;
+ return &pBibModul;
+}
+
+void CloseBibModul(HdlBibModul ppBibModul)
+{
+ nBibModulCount--;
+ if(nBibModulCount==0 && ppBibModul!=NULL)
+ {
+ delete pBibModul;
+ pBibModul=NULL;
+ }
+}
+
+BibResId::BibResId( sal_uInt16 nId ) :
+ ResId( nId, *pBibModul->GetResMgr() )
+{
+}
+BibConfig* BibModul::pBibConfig = 0;
+BibModul::BibModul()
+{
+ pResMgr = ResMgr::CreateResMgr( "bib" );
+}
+
+BibModul::~BibModul()
+{
+ delete pResMgr;
+ delete pBibConfig;
+ pBibConfig = 0;
+}
+
+BibDataManager* BibModul::createDataManager()
+{
+ return new BibDataManager();
+}
+//-----------------------------------------------------------------------------
+BibConfig* BibModul::GetConfig()
+{
+ if(! pBibConfig)
+ pBibConfig = new BibConfig;
+ return pBibConfig;
+}
+
+
+// PropertyNames
+#define STATIC_USTRING(a,b) rtl::OUString a(b)
+STATIC_USTRING(FM_PROP_LABEL,C2U("Label"));
+STATIC_USTRING(FM_PROP_CONTROLSOURCE,C2U("DataField"));
+STATIC_USTRING(FM_PROP_NAME,C2U("Name"));
+STATIC_USTRING(FM_PROP_FORMATKEY,C2U("FormatKey"));
+#ifdef TF_SDBAPI
+#else // !TF_SDBAPI
+STATIC_USTRING(FM_PROP_EDITMODE,C2U("RecordMode"));
+STATIC_USTRING(FM_PROP_CURSORSOURCETYPE,C2U("DataSelectionType"));
+STATIC_USTRING(FM_PROP_CURSORSOURCE,C2U("DataSelection"));
+STATIC_USTRING(FM_PROP_DATASOURCE, C2U("DataSource"));
+#endif // !TF_SDBAPI
+STATIC_USTRING(FM_PROP_VALUE,C2U("Value"));
+STATIC_USTRING(FM_PROP_TEXT,C2U("Text"));
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/bibliography/bibmod.hxx b/extensions/source/bibliography/bibmod.hxx
new file mode 100644
index 000000000000..0e2f04854e14
--- /dev/null
+++ b/extensions/source/bibliography/bibmod.hxx
@@ -0,0 +1,68 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef BIBMOD_HXX
+#define BIBMOD_HXX
+
+
+class ResMgr;
+class BibDataManager;
+class BibConfig;
+
+#define BIBLIOGRAPHY_INI_GROUP "Bibliography"
+#define BIBLIOGRAPHY_INI_CUR_NAME "BibliographyCurrent"
+#define BIBLIOGRAPHY_INI_DB_ENTRY "Bibliography"
+#define BIBLIOGRAPHY_INI_MAPPING "BibliographyFields"
+#define BIBLIOGRAPHY_TYPE_NAMES "BibliographyTypeNames"
+
+class BibModul
+{
+ private:
+ ResMgr* pResMgr;
+ static BibConfig* pBibConfig;
+
+ public:
+ BibModul();
+ ~BibModul();
+
+ ResMgr* GetResMgr(){return pResMgr;}
+ static BibConfig* GetConfig();
+
+ BibDataManager* createDataManager();
+
+};
+
+typedef BibModul* PtrBibModul;
+typedef PtrBibModul* HdlBibModul;
+
+HdlBibModul OpenBibModul();
+void CloseBibModul(HdlBibModul ppBibModul);
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/bibliography/bibprop.hrc b/extensions/source/bibliography/bibprop.hrc
new file mode 100644
index 000000000000..0f24597eee7a
--- /dev/null
+++ b/extensions/source/bibliography/bibprop.hrc
@@ -0,0 +1,45 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef _BIB_FMPROP_HRC
+#define _BIB_FMPROP_HRC
+
+extern rtl::OUString FM_PROP_LABEL;
+extern rtl::OUString FM_PROP_NAME;
+extern rtl::OUString FM_PROP_CONTROLSOURCE;
+extern rtl::OUString FM_PROP_FORMATKEY;
+extern rtl::OUString FM_PROP_VALUE;
+#ifdef TF_SDBAPI
+#else // !TF_SDBAPI
+extern rtl::OUString FM_PROP_EDITMODE;
+extern rtl::OUString FM_PROP_DATASOURCE;
+extern rtl::OUString FM_PROP_CURSORSOURCE;
+extern rtl::OUString FM_PROP_CURSORSOURCETYPE;
+#endif // !TF_SDBAPI
+extern rtl::OUString FM_PROP_TEXT;
+
+#endif // _SVX_FMPROP_HRC
+
diff --git a/extensions/source/bibliography/bibresid.hxx b/extensions/source/bibliography/bibresid.hxx
new file mode 100644
index 000000000000..724dec0c3673
--- /dev/null
+++ b/extensions/source/bibliography/bibresid.hxx
@@ -0,0 +1,46 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef ADRRESID_HXX
+#define ADRRESID_HXX
+
+#include <tools/resid.hxx>
+
+//===================================================================
+
+class BibResId : public ResId
+{
+ public:
+ BibResId( USHORT nId );
+};
+
+
+
+#endif // ADRRESID_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/bibliography/bibshortcuthandler.hxx b/extensions/source/bibliography/bibshortcuthandler.hxx
new file mode 100644
index 000000000000..88fe8b18a532
--- /dev/null
+++ b/extensions/source/bibliography/bibshortcuthandler.hxx
@@ -0,0 +1,90 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _BIBSHORTCUTHANDLER_HXX
+#define _BIBSHORTCUTHANDLER_HXX
+
+#include <vcl/window.hxx>
+#include <vcl/splitwin.hxx>
+#include <vcl/tabpage.hxx>
+
+// additional classes to handle shortcuts
+// code in bibcont.cxx
+
+
+class BibShortCutHandler
+{
+private:
+ Window* pBaseClass; // in cases, where BibShortCutHandler also has to be a window
+
+protected:
+ inline BibShortCutHandler( Window* pBaseClass );
+
+public:
+ virtual ~BibShortCutHandler();
+ virtual BOOL HandleShortCutKey( const KeyEvent& rKeyEvent ); // returns true, if key was handled
+
+ inline Window* GetWindow( void );
+};
+
+inline BibShortCutHandler::BibShortCutHandler( Window* _pBaseClass ) : pBaseClass( _pBaseClass )
+{
+}
+
+inline Window* BibShortCutHandler::GetWindow( void )
+{
+ return pBaseClass;
+}
+
+
+class BibWindow : public Window, public BibShortCutHandler
+{
+public:
+ BibWindow( Window* pParent,WinBits nStyle = WB_3DLOOK);
+ virtual ~BibWindow();
+};
+
+
+class BibSplitWindow : public SplitWindow, public BibShortCutHandler
+{
+public:
+ BibSplitWindow( Window* pParent,WinBits nStyle = WB_3DLOOK);
+ virtual ~BibSplitWindow();
+};
+
+
+class BibTabPage : public TabPage, public BibShortCutHandler
+{
+public:
+ BibTabPage( Window* pParent, const ResId& rResId );
+ virtual ~BibTabPage();
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/bibliography/bibtools.hxx b/extensions/source/bibliography/bibtools.hxx
new file mode 100644
index 000000000000..d62a5bce7528
--- /dev/null
+++ b/extensions/source/bibliography/bibtools.hxx
@@ -0,0 +1,53 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef BIBTOOLS_HXX
+
+#include <vcl/taskpanelist.hxx> // includes also vcl/window.hxx
+
+namespace bib
+{
+ // source in bibbeam.cxx
+
+ void HandleTaskPaneList( Window* pWindow, BOOL bAddToList );
+ // pWindow: just an system window or something wich is child of a system window
+
+ inline void AddToTaskPaneList( Window* pWindowToBeHandled )
+ {
+ HandleTaskPaneList( pWindowToBeHandled, TRUE );
+ }
+
+ inline void RemoveFromTaskPaneList( Window* pWindowToBeHandled )
+ {
+ HandleTaskPaneList( pWindowToBeHandled, FALSE );
+ }
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/bibliography/bibview.cxx b/extensions/source/bibliography/bibview.cxx
new file mode 100644
index 000000000000..44c94cb1a317
--- /dev/null
+++ b/extensions/source/bibliography/bibview.cxx
@@ -0,0 +1,233 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+
+#include "bib.hrc"
+#include "bibcont.hxx"
+#include "bibbeam.hxx"
+#include "bibmod.hxx"
+#include "general.hxx"
+#include "bibview.hxx"
+#include "datman.hxx"
+#include "bibresid.hxx"
+#include "bibmod.hxx"
+#include "sections.hrc"
+#include "bibconfig.hxx"
+
+
+#include <vcl/svapp.hxx>
+#include <com/sun/star/sdbc/XResultSetUpdate.hpp>
+#include <com/sun/star/form/XLoadable.hpp>
+#include <vcl/msgbox.hxx>
+#include <tools/debug.hxx>
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::form;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::uno;
+
+#define C2U( cChar ) ::rtl::OUString::createFromAscii( cChar )
+
+//.........................................................................
+namespace bib
+{
+//.........................................................................
+
+ // -----------------------------------------------------------------------
+ BibView::BibView( Window* _pParent, BibDataManager* _pManager, WinBits _nStyle )
+ :BibWindow( _pParent, _nStyle )
+ ,m_pDatMan( _pManager )
+ ,m_xDatMan( _pManager )
+ ,m_pGeneralPage( NULL )
+ {
+ if ( m_xDatMan.is() )
+ connectForm( m_xDatMan );
+ }
+
+ // -----------------------------------------------------------------------
+ BibView::~BibView()
+ {
+ BibGeneralPage* pGeneralPage = m_pGeneralPage;
+ m_pGeneralPage = NULL;
+
+ pGeneralPage->CommitActiveControl();
+ Reference< XForm > xForm = m_pDatMan->getForm();
+ Reference< XPropertySet > xProps( xForm, UNO_QUERY );
+ Reference< sdbc::XResultSetUpdate > xResUpd( xProps, UNO_QUERY );
+ DBG_ASSERT( xResUpd.is(), "BibView::~BibView: invalid form!" );
+
+ if ( xResUpd.is() )
+ {
+ Any aModified = xProps->getPropertyValue( C2U( "IsModified" ) );
+ sal_Bool bFlag = sal_False;
+ if ( ( aModified >>= bFlag ) && bFlag )
+ {
+
+ try
+ {
+ Any aNew = xProps->getPropertyValue( C2U( "IsNew" ) );
+ aNew >>= bFlag;
+ if ( bFlag )
+ xResUpd->insertRow();
+ else
+ xResUpd->updateRow();
+ }
+ catch( const uno::Exception& rEx)
+ {
+ (void) rEx;
+ }
+ }
+ }
+
+ if ( isFormConnected() )
+ disconnectForm();
+
+ pGeneralPage->RemoveListeners();
+ m_xGeneralPage = NULL;
+ }
+
+ /* -----------------16.11.99 13:13-------------------
+
+ --------------------------------------------------*/
+ void BibView::UpdatePages()
+ {
+ // TODO:
+ // this is _strange_: Why not updating the existent general page?
+ // I consider the current behaviour a HACK.
+ // frank.schoenheit@sun.com
+ if ( m_pGeneralPage )
+ {
+ m_pGeneralPage->Hide();
+ m_pGeneralPage->RemoveListeners();
+ m_xGeneralPage = 0;
+ }
+
+ m_xGeneralPage = m_pGeneralPage = new BibGeneralPage( this, m_pDatMan );
+
+ Resize();
+
+ if( HasFocus() )
+ // "delayed" GetFocus() because GetFocus() is initially called before GeneralPage is created
+ m_pGeneralPage->GrabFocus();
+
+ String sErrorString( m_pGeneralPage->GetErrorString() );
+ if ( sErrorString.Len() )
+ {
+ sal_Bool bExecute = BibModul::GetConfig()->IsShowColumnAssignmentWarning();
+ if(!m_pDatMan->HasActiveConnection())
+ {
+ //no connection is available -> the data base has to be assigned
+ m_pDatMan->DispatchDBChangeDialog();
+ bExecute = sal_False;
+ }
+ else if(bExecute)
+ {
+ sErrorString += '\n';
+ sErrorString += String( BibResId( RID_MAP_QUESTION ) );
+ QueryBox aQuery( this, WB_YES_NO, sErrorString );
+ aQuery.SetDefaultCheckBoxText();
+ short nResult = aQuery.Execute();
+ BibModul::GetConfig()->SetShowColumnAssignmentWarning(
+ !aQuery.GetCheckBoxState());
+ if( RET_YES != nResult )
+ {
+ bExecute = sal_False;
+ }
+ }
+ if(bExecute)
+ {
+ Application::PostUserEvent( STATIC_LINK( this, BibView, CallMappingHdl ) );
+ }
+ }
+ }
+ //---------------------------------------------------------------------
+ //--- 19.10.01 16:55:49 -----------------------------------------------
+
+ void BibView::_loaded( const EventObject& _rEvent )
+ {
+ UpdatePages();
+ FormControlContainer::_loaded( _rEvent );
+ }
+
+ void BibView::_reloaded( const EventObject& _rEvent )
+ {
+ UpdatePages();
+ FormControlContainer::_loaded( _rEvent );
+ }
+
+ /* -----------------------------02.02.00 16:49--------------------------------
+
+ ---------------------------------------------------------------------------*/
+ IMPL_STATIC_LINK( BibView, CallMappingHdl, BibView*, EMPTYARG )
+ {
+ pThis->m_pDatMan->CreateMappingDialog( pThis );
+ return 0;
+ }
+ /* -----------------------------13.04.00 16:12--------------------------------
+
+ ---------------------------------------------------------------------------*/
+ void BibView::Resize()
+ {
+ if ( m_pGeneralPage )
+ {
+ ::Size aSz( GetOutputSizePixel() );
+ m_pGeneralPage->SetSizePixel( aSz );
+ }
+ Window::Resize();
+ }
+
+ //---------------------------------------------------------------------
+ //--- 18.10.01 18:52:45 -----------------------------------------------
+
+ Reference< awt::XControlContainer > BibView::getControlContainer()
+ {
+ Reference< awt::XControlContainer > xReturn;
+ if ( m_pGeneralPage )
+ xReturn = m_pGeneralPage->GetControlContainer();
+ return xReturn;
+ }
+
+ void BibView::GetFocus()
+ {
+ if( m_pGeneralPage )
+ m_pGeneralPage->GrabFocus();
+ }
+
+ BOOL BibView::HandleShortCutKey( const KeyEvent& rKeyEvent )
+ {
+ return m_pGeneralPage? m_pGeneralPage->HandleShortCutKey( rKeyEvent ) : FALSE;
+ }
+
+//.........................................................................
+} // namespace bib
+//.........................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/bibliography/bibview.hxx b/extensions/source/bibliography/bibview.hxx
new file mode 100644
index 000000000000..0f86069a554a
--- /dev/null
+++ b/extensions/source/bibliography/bibview.hxx
@@ -0,0 +1,88 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef _BIB_VIEW_HXX
+#define _BIB_VIEW_HXX
+
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/awt/XControlContainer.hpp>
+#include "formcontrolcontainer.hxx"
+#include "bibshortcuthandler.hxx"
+
+class BibGeneralPage;
+class BibDataManager;
+
+namespace com{ namespace sun{ namespace star{ namespace awt{ class XFocusListener;}}}}
+
+//.........................................................................
+namespace bib
+{
+//.........................................................................
+
+ // -----------------------------------------------------------------------
+ class BibView : public BibWindow, public FormControlContainer
+ {
+ private:
+ BibDataManager* m_pDatMan;
+ ::com::sun::star::uno::Reference< ::com::sun::star::form::XLoadable> m_xDatMan;
+ ::com::sun::star::uno::Reference< ::com::sun::star::awt::XFocusListener> m_xGeneralPage;
+ BibGeneralPage* m_pGeneralPage;
+
+ private:
+ DECL_STATIC_LINK(BibView, CallMappingHdl, BibView*);
+
+ protected:
+ // Window overridables
+ virtual void Resize();
+
+ // FormControlContainer
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlContainer >
+ getControlContainer();
+
+ // XLoadListener equivalents
+ virtual void _loaded( const ::com::sun::star::lang::EventObject& _rEvent );
+ virtual void _reloaded( const ::com::sun::star::lang::EventObject& _rEvent );
+
+ public:
+ BibView( Window* _pParent, BibDataManager* _pDatMan, WinBits nStyle = WB_3DLOOK );
+ ~BibView();
+
+ void UpdatePages();
+
+ virtual void GetFocus();
+
+ virtual BOOL HandleShortCutKey( const KeyEvent& rKeyEvent ); // returns true, if key was handled
+ };
+
+//.........................................................................
+} // namespace bib
+//.........................................................................
+
+#endif
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/bibliography/datman.cxx b/extensions/source/bibliography/datman.cxx
new file mode 100644
index 000000000000..1290431f760c
--- /dev/null
+++ b/extensions/source/bibliography/datman.cxx
@@ -0,0 +1,1835 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+#include <osl/mutex.hxx>
+#include <tools/diagnose_ex.h>
+#include <tools/urlobj.hxx>
+#include <comphelper/processfactory.hxx>
+#include <com/sun/star/io/XPersistObject.hpp>
+#include <com/sun/star/sdbc/ResultSetType.hpp>
+#include <com/sun/star/sdbc/ResultSetConcurrency.hpp>
+#include <com/sun/star/sdbc/XResultSetUpdate.hpp>
+#include <com/sun/star/sdbcx/XRowLocate.hpp>
+#include <com/sun/star/sdbc/DataType.hpp>
+#include <com/sun/star/sdb/XSingleSelectQueryComposer.hpp>
+#include <com/sun/star/sdbc/XDatabaseMetaData.hpp>
+#include <com/sun/star/sdb/XDatabaseEnvironment.hpp>
+#include <com/sun/star/uno/XNamingService.hpp>
+#include <com/sun/star/sdbc/XDataSource.hpp>
+#include <com/sun/star/sdb/CommandType.hpp>
+#include <com/sun/star/sdbcx/XTablesSupplier.hpp>
+#include <com/sun/star/sdbc/XConnection.hpp>
+#include <com/sun/star/sdb/XCompletedConnection.hpp>
+#include <com/sun/star/task/XInteractionHandler.hpp>
+#include <com/sun/star/form/XLoadable.hpp>
+#include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
+#include <com/sun/star/form/XGridColumnFactory.hpp>
+#include <com/sun/star/io/XDataInputStream.hpp>
+#include <com/sun/star/container/XNameContainer.hpp>
+#include <com/sun/star/ucb/XContentProvider.hpp>
+#include <com/sun/star/ucb/XContentAccess.hpp>
+#include <ucbhelper/contentbroker.hxx>
+#include <ucbhelper/content.hxx>
+#include <ucbhelper/contentidentifier.hxx>
+#include <comphelper/container.hxx>
+#include <svl/urihelper.hxx>
+#include <svtools/svtabbx.hxx>
+#include <svtools/headbar.hxx>
+#include <vcl/dialog.hxx>
+#include <vcl/button.hxx>
+#include <vcl/lstbox.hxx>
+#include <vcl/fixed.hxx>
+#include <vcl/group.hxx>
+#include <vcl/lstbox.hxx>
+#include <vcl/edit.hxx>
+#include <vcl/msgbox.hxx>
+#include <tools/debug.hxx>
+#include "datman.hxx"
+#include "bibresid.hxx"
+#include "bibmod.hxx"
+#include "bibview.hxx"
+// #100312# ---------
+#include "bibbeam.hxx"
+#include "bibprop.hrc"
+#include "toolbar.hxx"
+#include "toolbar.hrc"
+#include "bibconfig.hxx"
+#include "bibbeam.hxx"
+#include "bib.hrc"
+#include "datman.hrc"
+#include "bibliography.hrc"
+#include <connectivity/dbtools.hxx>
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::sdb;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::form;
+using namespace ::com::sun::star::frame;
+using namespace ::com::sun::star::ucb;
+using namespace ::com::sun::star::lang;
+using namespace ::ucb;
+
+#define C2U(cChar) ::rtl::OUString::createFromAscii(cChar)
+#define C2S(cChar) String::CreateFromAscii(cChar)
+#define MAP_TOKEN ';'
+#define PAIR_TOKEN ':'
+
+
+/* -----------------17.01.00 14:38-------------------
+
+ --------------------------------------------------*/
+Reference< XConnection > getConnection(const ::rtl::OUString& _rURL)
+{
+ // first get the sdb::DataSource corresponding to the url
+ Reference< XDataSource > xDataSource;
+ // is it a favorite title ?
+ Reference< XMultiServiceFactory > xMgr = comphelper::getProcessServiceFactory();
+ Reference<XInterface> xNamingContextIfc = xMgr->createInstance(C2U("com.sun.star.sdb.DatabaseContext"));
+ Reference< XNameAccess > xNamingContext(xNamingContextIfc, UNO_QUERY);
+ if (xNamingContext.is() && xNamingContext->hasByName(_rURL))
+ {
+ DBG_ASSERT(Reference< XNamingService > (xNamingContext, UNO_QUERY).is(), "::getDataSource : no NamingService interface on the sdb::DatabaseAccessContext !");
+ try
+ {
+ xDataSource = Reference< XDataSource > (Reference< XNamingService > (xNamingContext, UNO_QUERY)->getRegisteredObject(_rURL), UNO_QUERY);
+ }
+ catch(Exception eEx)
+ {
+ (void) eEx; // make compiler happy
+ DBG_ERROR("Exception caught in ODatabaseContext::getRegisteredObject()");
+ }
+ }
+ // build the connection from the data source
+ Reference< XConnection > xConn;
+ if (xDataSource.is())
+ {
+ // need user/pwd for this
+ ::rtl::OUString sUser, sPwd;
+ Reference< XPropertySet > xDataSourceProps(xDataSource, UNO_QUERY);
+ Reference< XCompletedConnection > xComplConn(xDataSource, UNO_QUERY);
+/* Reference< XPropertySetInfo > xInfo = xDataSourceProps.is() ? xDataSourceProps->getPropertySetInfo() : Reference< XPropertySetInfo > ();
+ if (xInfo.is() && xInfo->hasPropertyByName(C2U("User")))
+ xDataSourceProps->getPropertyValue(C2U("User")) >>= sUser;
+ if (xInfo.is() && xInfo->hasPropertyByName(C2U("Password")))
+ xDataSourceProps->getPropertyValue(C2U("Password"))>>= sPwd;
+*/
+ try
+ {
+
+ Reference<XInterface> xHdl = xMgr->createInstance(C2U("com.sun.star.task.InteractionHandler"));
+ Reference<task::XInteractionHandler> xIHdl(xHdl, UNO_QUERY);
+ xConn = xComplConn->connectWithCompletion(xIHdl);
+// xConn = xDataSource->getConnection(sUser, sPwd);
+ }
+ catch(SQLException&)
+ {
+ // TODO : a real error handling
+ }
+ catch(Exception& e )
+ {
+ (void) e; // make compiler happy
+ }
+
+ }
+ return xConn;
+}
+
+/* -----------------17.01.00 14:46-------------------
+
+ --------------------------------------------------*/
+Reference< XConnection > getConnection(const Reference< XInterface > & xRowSet)
+{
+ Reference< XConnection > xConn;
+ try
+ {
+ Reference< XPropertySet > xFormProps(xRowSet, UNO_QUERY);
+ if (!xFormProps.is())
+ return xConn;
+
+ xConn = Reference< XConnection > (*(Reference< XInterface > *)xFormProps->getPropertyValue(C2U("ActiveConnection")).getValue(), UNO_QUERY);
+ if (!xConn.is())
+ {
+ DBG_WARNING("no active connection");
+ }
+ }
+ catch(Exception& e )
+ {
+ (void) e; // make compiler happy
+ DBG_ERROR("exception in getConnection");
+ }
+
+ return xConn;
+}
+/* -----------------17.01.00 16:07-------------------
+
+ --------------------------------------------------*/
+Reference< XNameAccess > getColumns(const Reference< XForm > & _rxForm)
+{
+ Reference< XNameAccess > xReturn;
+ // check if the form is alive
+ Reference< XColumnsSupplier > xSupplyCols( _rxForm, UNO_QUERY );
+ if (xSupplyCols.is())
+ xReturn = xSupplyCols->getColumns();
+
+ if (!xReturn.is() || (xReturn->getElementNames().getLength() == 0))
+ { // no ....
+ xReturn = NULL;
+ // -> get the table the form is bound to and ask it for their columns
+ Reference< XTablesSupplier > xSupplyTables( getConnection( _rxForm ), UNO_QUERY );
+ Reference< XPropertySet > xFormProps( _rxForm, UNO_QUERY );
+ if (xFormProps.is() && xSupplyTables.is())
+ {
+ try
+ {
+ DBG_ASSERT((*(sal_Int32*)xFormProps->getPropertyValue(C2U("CommandType")).getValue()) == CommandType::TABLE,
+ "::getColumns : invalid form (has no table as data source) !");
+ ::rtl::OUString sTable;
+ xFormProps->getPropertyValue(C2U("Command")) >>= sTable;
+ Reference< XNameAccess > xTables = xSupplyTables->getTables();
+ if (xTables.is() && xTables->hasByName(sTable))
+ xSupplyCols = Reference< XColumnsSupplier > (
+ *(Reference< XInterface > *)xTables->getByName(sTable).getValue(), UNO_QUERY);
+ if (xSupplyCols.is())
+ xReturn = xSupplyCols->getColumns();
+ }
+#ifdef DBG_UTIL
+ catch(Exception& e )
+#else
+ catch(Exception&)
+#endif
+ {
+#ifdef DBG_UTIL
+ String sMsg(String::CreateFromAscii("::getColumns : catched an exception ("));
+ sMsg += String(e.Message);
+ sMsg.AppendAscii(") ...");
+ DBG_ERROR( ByteString(sMsg, RTL_TEXTENCODING_ASCII_US ).GetBuffer());
+#endif
+ }
+
+ }
+ }
+ return xReturn;
+}
+
+/* -----------------11.11.99 15:54-------------------
+
+ --------------------------------------------------*/
+class MappingDialog_Impl : public ModalDialog
+{
+ BibDataManager* pDatMan;
+ OKButton aOKBT;
+ CancelButton aCancelBT;
+ HelpButton aHelpBT;
+ FixedLine aMapGB;
+ FixedText aIdentifierFT;
+ ListBox aIdentifierLB;
+ FixedText aAuthorityTypeFT;
+ ListBox aAuthorityTypeLB;
+ FixedText aAuthorFT;
+ ListBox aAuthorLB;
+ FixedText aTitleFT;
+ ListBox aTitleLB;
+ FixedText aMonthFT;
+ ListBox aMonthLB;
+ FixedText aYearFT;
+ ListBox aYearLB;
+ FixedText aISBNFT;
+ ListBox aISBNLB;
+ FixedText aBooktitleFT;
+ ListBox aBooktitleLB;
+ FixedText aChapterFT;
+ ListBox aChapterLB;
+ FixedText aEditionFT;
+ ListBox aEditionLB;
+ FixedText aEditorFT;
+ ListBox aEditorLB;
+ FixedText aHowpublishedFT;
+ ListBox aHowpublishedLB;
+ FixedText aInstitutionFT;
+ ListBox aInstitutionLB;
+ FixedText aJournalFT;
+ ListBox aJournalLB;
+ FixedText aNoteFT;
+ ListBox aNoteLB;
+ FixedText aAnnoteFT;
+ ListBox aAnnoteLB;
+ FixedText aNumberFT;
+ ListBox aNumberLB;
+ FixedText aOrganizationsFT;
+ ListBox aOrganizationsLB;
+ FixedText aPagesFT;
+ ListBox aPagesLB;
+ FixedText aPublisherFT;
+ ListBox aPublisherLB;
+ FixedText aAddressFT;
+ ListBox aAddressLB;
+ FixedText aSchoolFT;
+ ListBox aSchoolLB;
+ FixedText aSeriesFT;
+ ListBox aSeriesLB;
+ FixedText aReportTypeFT;
+ ListBox aReportTypeLB;
+ FixedText aVolumeFT;
+ ListBox aVolumeLB;
+ FixedText aURLFT;
+ ListBox aURLLB;
+ FixedText aCustom1FT;
+ ListBox aCustom1LB;
+ FixedText aCustom2FT;
+ ListBox aCustom2LB;
+ FixedText aCustom3FT;
+ ListBox aCustom3LB;
+ FixedText aCustom4FT;
+ ListBox aCustom4LB;
+ FixedText aCustom5FT;
+ ListBox aCustom5LB;
+ ListBox* aListBoxes[COLUMN_COUNT];
+ String sNone;
+
+ sal_Bool bModified;
+
+
+
+ DECL_LINK(OkHdl, OKButton*);
+ DECL_LINK(ListBoxSelectHdl, ListBox*);
+
+public:
+ MappingDialog_Impl(Window* pParent, BibDataManager* pDatMan);
+ ~MappingDialog_Impl();
+
+ void SetModified() {bModified = TRUE;}
+
+};
+/* -----------------11.11.99 16:42-------------------
+
+ --------------------------------------------------*/
+sal_uInt16 lcl_FindLogicalName(BibConfig* pConfig ,
+ const ::rtl::OUString& rLogicalColumnName)
+{
+ for(sal_uInt16 i = 0; i < COLUMN_COUNT; i++)
+ {
+ if(rLogicalColumnName == pConfig->GetDefColumnName(i))
+ return i;
+ }
+ return USHRT_MAX;
+}
+//-----------------------------------------------------------------------------
+MappingDialog_Impl::MappingDialog_Impl(Window* pParent, BibDataManager* pMan) :
+ ModalDialog(pParent, BibResId(RID_DLG_MAPPING) ),
+ pDatMan(pMan),
+ aOKBT(this, BibResId( BT_OK )),
+ aCancelBT(this, BibResId( BT_CANCEL )),
+ aHelpBT(this, BibResId( BT_HELP )),
+
+ aMapGB(this, BibResId( GB_MAPPING )),
+
+ aIdentifierFT(this, BibResId( FT_IDENTIFIER )),
+ aIdentifierLB(this, BibResId( LB_IDENTIFIER )),
+ aAuthorityTypeFT(this, BibResId( FT_AUTHORITYTYPE )),
+ aAuthorityTypeLB(this, BibResId( LB_AUTHORITYTYPE )),
+ aAuthorFT(this, BibResId( FT_AUTHOR )),
+ aAuthorLB(this, BibResId( LB_AUTHOR )),
+ aTitleFT(this, BibResId( FT_TITLE )),
+ aTitleLB(this, BibResId( LB_TITLE )),
+ aMonthFT(this, BibResId( FT_MONTH )),
+ aMonthLB(this, BibResId( LB_MONTH )),
+ aYearFT(this, BibResId( FT_YEAR )),
+ aYearLB(this, BibResId( LB_YEAR )),
+ aISBNFT(this, BibResId( FT_ISBN )),
+ aISBNLB(this, BibResId( LB_ISBN )),
+ aBooktitleFT(this, BibResId( FT_BOOKTITLE )),
+ aBooktitleLB(this, BibResId( LB_BOOKTITLE )),
+ aChapterFT(this, BibResId( FT_CHAPTER )),
+ aChapterLB(this, BibResId( LB_CHAPTER )),
+ aEditionFT(this, BibResId( FT_EDITION )),
+ aEditionLB(this, BibResId( LB_EDITION )),
+ aEditorFT(this, BibResId( FT_EDITOR )),
+ aEditorLB(this, BibResId( LB_EDITOR )),
+ aHowpublishedFT(this, BibResId( FT_HOWPUBLISHED )),
+ aHowpublishedLB(this, BibResId( LB_HOWPUBLISHED )),
+ aInstitutionFT(this, BibResId( FT_INSTITUTION )),
+ aInstitutionLB(this, BibResId( LB_INSTITUTION )),
+ aJournalFT(this, BibResId( FT_JOURNAL )),
+ aJournalLB(this, BibResId( LB_JOURNAL )),
+ aNoteFT(this, BibResId( FT_NOTE )),
+ aNoteLB(this, BibResId( LB_NOTE )),
+ aAnnoteFT(this, BibResId( FT_ANNOTE )),
+ aAnnoteLB(this, BibResId( LB_ANNOTE )),
+ aNumberFT(this, BibResId( FT_NUMBER )),
+ aNumberLB(this, BibResId( LB_NUMBER )),
+ aOrganizationsFT(this, BibResId( FT_ORGANIZATIONS )),
+ aOrganizationsLB(this, BibResId( LB_ORGANIZATIONS )),
+ aPagesFT(this, BibResId( FT_PAGES )),
+ aPagesLB(this, BibResId( LB_PAGES )),
+ aPublisherFT(this, BibResId( FT_PUBLISHER )),
+ aPublisherLB(this, BibResId( LB_PUBLISHER )),
+ aAddressFT(this, BibResId( FT_ADDRESS )),
+ aAddressLB(this, BibResId( LB_ADDRESS )),
+ aSchoolFT(this, BibResId( FT_SCHOOL )),
+ aSchoolLB(this, BibResId( LB_SCHOOL )),
+ aSeriesFT(this, BibResId( FT_SERIES )),
+ aSeriesLB(this, BibResId( LB_SERIES )),
+ aReportTypeFT(this, BibResId( FT_REPORTTYPE )),
+ aReportTypeLB(this, BibResId( LB_REPORTTYPE )),
+ aVolumeFT(this, BibResId( FT_VOLUME )),
+ aVolumeLB(this, BibResId( LB_VOLUME )),
+ aURLFT(this, BibResId( FT_URL )),
+ aURLLB(this, BibResId( LB_URL )),
+ aCustom1FT(this, BibResId( FT_CUSTOM1 )),
+ aCustom1LB(this, BibResId( LB_CUSTOM1 )),
+ aCustom2FT(this, BibResId( FT_CUSTOM2 )),
+ aCustom2LB(this, BibResId( LB_CUSTOM2 )),
+ aCustom3FT(this, BibResId( FT_CUSTOM3 )),
+ aCustom3LB(this, BibResId( LB_CUSTOM3 )),
+ aCustom4FT(this, BibResId( FT_CUSTOM4 )),
+ aCustom4LB(this, BibResId( LB_CUSTOM4 )),
+ aCustom5FT(this, BibResId( FT_CUSTOM5 )),
+ aCustom5LB(this, BibResId( LB_CUSTOM5 )),
+ sNone(BibResId(ST_NONE)),
+ bModified(sal_False)
+{
+ FreeResource();
+
+ aIdentifierFT.SetText(String( BibResId( ST_IDENTIFIER )));
+ aAuthorityTypeFT.SetText(String( BibResId( ST_AUTHTYPE )));
+ aAuthorFT.SetText(String( BibResId( ST_AUTHOR )));
+ aTitleFT.SetText(String( BibResId( ST_TITLE )));
+ aMonthFT.SetText(String( BibResId( ST_MONTH )));
+ aYearFT.SetText(String( BibResId( ST_YEAR )));
+ aISBNFT.SetText(String( BibResId( ST_ISBN )));
+ aBooktitleFT.SetText(String( BibResId( ST_BOOKTITLE )));
+ aChapterFT.SetText(String( BibResId( ST_CHAPTER )));
+ aEditionFT.SetText(String( BibResId( ST_EDITION )));
+ aEditorFT.SetText(String( BibResId( ST_EDITOR )));
+ aHowpublishedFT.SetText(String( BibResId( ST_HOWPUBLISHED )));
+ aInstitutionFT.SetText(String( BibResId( ST_INSTITUTION )));
+ aJournalFT.SetText(String( BibResId( ST_JOURNAL )));
+ aNoteFT.SetText(String( BibResId( ST_NOTE )));
+ aAnnoteFT.SetText(String( BibResId( ST_ANNOTE )));
+ aNumberFT.SetText(String( BibResId( ST_NUMBER )));
+ aOrganizationsFT.SetText(String( BibResId( ST_ORGANIZATION )));
+ aPagesFT.SetText(String( BibResId( ST_PAGE )));
+ aPublisherFT.SetText(String( BibResId( ST_PUBLISHER )));
+ aAddressFT.SetText(String( BibResId( ST_ADDRESS )));
+ aSchoolFT.SetText(String( BibResId( ST_SCHOOL )));
+ aSeriesFT.SetText(String( BibResId( ST_SERIES )));
+ aReportTypeFT.SetText(String( BibResId( ST_REPORT )));
+ aVolumeFT.SetText(String( BibResId( ST_VOLUME )));
+ aURLFT.SetText(String( BibResId( ST_URL )));
+ aCustom1FT.SetText(String( BibResId( ST_CUSTOM1 )));
+ aCustom2FT.SetText(String( BibResId( ST_CUSTOM2 )));
+ aCustom3FT.SetText(String( BibResId( ST_CUSTOM3 )));
+ aCustom4FT.SetText(String( BibResId( ST_CUSTOM4 )));
+ aCustom5FT.SetText(String( BibResId( ST_CUSTOM5 )));
+
+ aOKBT.SetClickHdl(LINK(this, MappingDialog_Impl, OkHdl));
+ String sTitle = GetText();
+ sTitle.SearchAndReplace(C2S("%1"), pDatMan->getActiveDataTable(), 0);
+ SetText(sTitle);
+
+ aListBoxes[0] = &aIdentifierLB;
+ aListBoxes[1] = &aAuthorityTypeLB;
+ aListBoxes[2] = &aAuthorLB;
+ aListBoxes[3] = &aTitleLB;
+ aListBoxes[4] = &aYearLB;
+ aListBoxes[5] = &aISBNLB;
+ aListBoxes[6] = &aBooktitleLB;
+ aListBoxes[7] = &aChapterLB;
+ aListBoxes[8] = &aEditionLB;
+ aListBoxes[9] = &aEditorLB;
+ aListBoxes[10] = &aHowpublishedLB;
+ aListBoxes[11] = &aInstitutionLB;
+ aListBoxes[12] = &aJournalLB;
+ aListBoxes[13] = &aMonthLB;
+ aListBoxes[14] = &aNoteLB;
+ aListBoxes[15] = &aAnnoteLB;
+ aListBoxes[16] = &aNumberLB;
+ aListBoxes[17] = &aOrganizationsLB;
+ aListBoxes[18] = &aPagesLB;
+ aListBoxes[19] = &aPublisherLB;
+ aListBoxes[20] = &aAddressLB;
+ aListBoxes[21] = &aSchoolLB;
+ aListBoxes[22] = &aSeriesLB;
+ aListBoxes[23] = &aReportTypeLB;
+ aListBoxes[24] = &aVolumeLB;
+ aListBoxes[25] = &aURLLB;
+ aListBoxes[26] = &aCustom1LB;
+ aListBoxes[27] = &aCustom2LB;
+ aListBoxes[28] = &aCustom3LB;
+ aListBoxes[29] = &aCustom4LB;
+ aListBoxes[30] = &aCustom5LB;
+
+ aListBoxes[0]->InsertEntry(sNone);
+ Reference< XNameAccess > xFields = getColumns( pDatMan->getForm() );
+ DBG_ASSERT(xFields.is(), "MappingDialog_Impl::MappingDialog_Impl : gave me an invalid form !");
+ if(xFields.is())
+ {
+ Sequence< ::rtl::OUString > aNames = xFields->getElementNames();
+ sal_Int32 nFieldsCount = aNames.getLength();
+ const ::rtl::OUString* pNames = aNames.getConstArray();
+
+ for(sal_Int32 nField = 0; nField < nFieldsCount; nField++)
+ aListBoxes[0]->InsertEntry(pNames[nField]);
+ }
+
+ Link aLnk = LINK(this, MappingDialog_Impl, ListBoxSelectHdl);
+
+ aListBoxes[0]->SelectEntryPos(0);
+ aListBoxes[0]->SetSelectHdl(aLnk);
+ for(sal_uInt16 i = 1; i < COLUMN_COUNT; i++)
+ {
+ for(sal_uInt16 j = 0; j < aListBoxes[0]->GetEntryCount();j++)
+ aListBoxes[i]->InsertEntry(aListBoxes[0]->GetEntry(j));
+ aListBoxes[i]->SelectEntryPos(0);
+ aListBoxes[i]->SetSelectHdl(aLnk);
+ }
+ BibConfig* pConfig = BibModul::GetConfig();
+ BibDBDescriptor aDesc;
+ aDesc.sDataSource = pDatMan->getActiveDataSource();
+ aDesc.sTableOrQuery = pDatMan->getActiveDataTable();
+ aDesc.nCommandType = CommandType::TABLE;
+ const Mapping* pMapping = pConfig->GetMapping(aDesc);
+ if(pMapping)
+ {
+ for(sal_uInt16 nEntry = 0; nEntry < COLUMN_COUNT; nEntry++)
+ {
+ sal_uInt16 nListBoxIndex = lcl_FindLogicalName( pConfig, pMapping->aColumnPairs[nEntry].sLogicalColumnName);
+ if(nListBoxIndex < COLUMN_COUNT)
+ {
+ aListBoxes[nListBoxIndex]->SelectEntry(pMapping->aColumnPairs[nEntry].sRealColumnName);
+ }
+ }
+ }
+}
+/* -----------------11.11.99 16:44-------------------
+
+ --------------------------------------------------*/
+MappingDialog_Impl::~MappingDialog_Impl()
+{}
+/* -----------------15.11.99 10:38-------------------
+
+ --------------------------------------------------*/
+IMPL_LINK(MappingDialog_Impl, ListBoxSelectHdl, ListBox*, pListBox)
+{
+ sal_uInt16 nEntryPos = pListBox->GetSelectEntryPos();
+ if(0 < nEntryPos)
+ {
+ for(sal_uInt16 i = 0; i < COLUMN_COUNT; i++)
+ {
+ if(pListBox != aListBoxes[i] && aListBoxes[i]->GetSelectEntryPos() == nEntryPos)
+ aListBoxes[i]->SelectEntryPos(0);
+ }
+ }
+ SetModified();
+ return 0;
+}
+/* -----------------12.11.99 14:50-------------------
+
+ --------------------------------------------------*/
+IMPL_LINK(MappingDialog_Impl, OkHdl, OKButton*, EMPTYARG)
+{
+ if(bModified)
+ {
+ Mapping aNew;
+ aNew.sTableName = String(pDatMan->getActiveDataTable());
+ aNew.sURL = String(pDatMan->getActiveDataSource());
+
+ sal_uInt16 nWriteIndex = 0;
+ BibConfig* pConfig = BibModul::GetConfig();
+ for(sal_uInt16 nEntry = 0; nEntry < COLUMN_COUNT; nEntry++)
+ {
+ String sSel = aListBoxes[nEntry]->GetSelectEntry();
+ if(sSel != sNone)
+ {
+ aNew.aColumnPairs[nWriteIndex].sRealColumnName = sSel;
+ aNew.aColumnPairs[nWriteIndex].sLogicalColumnName = pConfig->GetDefColumnName(nEntry);
+ nWriteIndex++;
+ }
+ }
+ BibDBDescriptor aDesc;
+ aDesc.sDataSource = pDatMan->getActiveDataSource();
+ aDesc.sTableOrQuery = pDatMan->getActiveDataTable();
+ aDesc.nCommandType = CommandType::TABLE;
+ pDatMan->ResetIdentifierMapping();
+ pConfig->SetMapping(aDesc, &aNew);
+ }
+ EndDialog(bModified ? RET_OK : RET_CANCEL);
+ return 0;
+}
+/* -----------------18.11.99 10:23-------------------
+
+ --------------------------------------------------*/
+class DBChangeDialog_Impl : public ModalDialog
+{
+ OKButton aOKBT;
+ CancelButton aCancelBT;
+ HelpButton aHelpBT;
+ FixedLine aSelectionGB;
+ SvTabListBox aSelectionLB;
+ HeaderBar aSelectionHB;
+ DBChangeDialogConfig_Impl aConfig;
+ String aEntryST;
+ String aURLST;
+
+ BibDataManager* pDatMan;
+
+// DECL_LINK(EndDragHdl, HeaderBar*);
+ DECL_LINK(DoubleClickHdl, SvTabListBox*);
+public:
+ DBChangeDialog_Impl(Window* pParent, BibDataManager* pMan );
+ ~DBChangeDialog_Impl();
+
+ String GetCurrentURL()const;
+};
+
+/*-- 18.11.99 10:35:20---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+DBChangeDialog_Impl::DBChangeDialog_Impl(Window* pParent, BibDataManager* pMan ) :
+ ModalDialog(pParent, BibResId(RID_DLG_DBCHANGE) ),
+ aOKBT(this, BibResId( BT_OK )),
+ aCancelBT(this, BibResId( BT_CANCEL )),
+ aHelpBT(this, BibResId( BT_HELP )),
+ aSelectionGB(this, BibResId( GB_SELECTION )),
+ aSelectionLB(this, BibResId( LB_SELECTION )),
+ aSelectionHB(this, BibResId( HB_SELECTION )),
+ aEntryST(BibResId(ST_ENTRY)),
+ aURLST( BibResId(ST_URL)),
+ pDatMan(pMan)
+{
+ FreeResource();
+ aSelectionLB.SetDoubleClickHdl( LINK(this, DBChangeDialog_Impl, DoubleClickHdl));
+ try
+ {
+ Reference< XMultiServiceFactory > xMgr = comphelper::getProcessServiceFactory();
+
+ ::Size aSize = aSelectionHB.GetSizePixel();
+ long nTabs[2];
+ nTabs[0] = 1;// Number of Tabs
+ nTabs[1] = aSize.Width() / 4;
+
+ aSelectionHB.SetStyle(aSelectionHB.GetStyle()|WB_STDHEADERBAR);
+ aSelectionHB.InsertItem( 1, aEntryST, aSize.Width());
+ aSelectionHB.SetSizePixel(aSelectionHB.CalcWindowSizePixel());
+ aSelectionHB.Show();
+
+ aSelectionLB.SetTabs( &nTabs[0], MAP_PIXEL );
+ aSelectionLB.SetWindowBits(WB_CLIPCHILDREN|WB_SORT);
+ aSelectionLB.GetModel()->SetSortMode(SortAscending);
+
+ ::rtl::OUString sActiveSource = pDatMan->getActiveDataSource();
+ const Sequence< ::rtl::OUString >& rSources = aConfig.GetDataSourceNames();
+ const ::rtl::OUString* pSourceNames = rSources.getConstArray();
+ for(int i = 0; i < rSources.getLength(); i++)
+ {
+ SvLBoxEntry* pEntry = aSelectionLB.InsertEntry(pSourceNames[i]);
+ if(pSourceNames[i] == sActiveSource)
+ {
+ aSelectionLB.Select(pEntry);
+ }
+ }
+ aSelectionLB.GetModel()->Resort();
+ }
+ catch(Exception& e )
+ {
+ (void) e; // make compiler happy
+ DBG_ERROR("Exception in BibDataManager::DBChangeDialog_Impl::DBChangeDialog_Impl");
+ }
+
+
+}
+/* -----------------06.12.99 12:09-------------------
+
+ --------------------------------------------------*/
+IMPL_LINK(DBChangeDialog_Impl, DoubleClickHdl, SvTabListBox*, /*pLB*/)
+{
+ EndDialog(RET_OK);
+ return 0;
+}
+/* -----------------18.11.99 11:17-------------------
+
+ --------------------------------------------------*/
+/*IMPL_LINK(DBChangeDialog_Impl, EndDragHdl, HeaderBar*, pHB)
+{
+ long nTabs[3];
+ nTabs[0] = 2;// Number of Tabs
+ nTabs[1] = 0;
+ nTabs[2] = pHB->GetItemSize( 1 );
+ aSelectionLB.SetTabs( &nTabs[0], MAP_PIXEL );
+ return 0;
+};*/
+
+/*-- 18.11.99 10:35:20---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+DBChangeDialog_Impl::~DBChangeDialog_Impl()
+{
+}
+/* -----------------18.11.99 12:36-------------------
+
+ --------------------------------------------------*/
+String DBChangeDialog_Impl::GetCurrentURL()const
+{
+ String sRet;
+ SvLBoxEntry* pEntry = aSelectionLB.FirstSelected();
+ if(pEntry)
+ {
+ sRet = aSelectionLB.GetEntryText(pEntry, 0);
+ }
+ return sRet;
+}
+
+// #100312# --------------------------------------------------------------------
+// XDispatchProvider
+BibInterceptorHelper::BibInterceptorHelper( ::bib::BibBeamer* pBibBeamer, ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch > xDispatch)
+{
+ if( pBibBeamer )
+ {
+ xInterception = pBibBeamer->getDispatchProviderInterception();
+ if( xInterception.is() )
+ xInterception->registerDispatchProviderInterceptor( this );
+ }
+ if( xDispatch.is() )
+ xFormDispatch = xDispatch;
+}
+
+BibInterceptorHelper::~BibInterceptorHelper( )
+{
+}
+
+void BibInterceptorHelper::ReleaseInterceptor()
+{
+ if ( xInterception.is() )
+ xInterception->releaseDispatchProviderInterceptor( this );
+ xInterception.clear();
+}
+
+::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch > SAL_CALL
+ BibInterceptorHelper::queryDispatch( const ::com::sun::star::util::URL& aURL, const ::rtl::OUString& aTargetFrameName, sal_Int32 nSearchFlags ) throw (::com::sun::star::uno::RuntimeException)
+{
+ Reference< XDispatch > xReturn;
+
+ String aCommand( aURL.Path );
+ if ( aCommand.EqualsAscii("FormSlots/ConfirmDeletion") )
+ xReturn = xFormDispatch;
+ else
+ if ( xSlaveDispatchProvider.is() )
+ xReturn = xSlaveDispatchProvider->queryDispatch( aURL, aTargetFrameName, nSearchFlags);
+
+ return xReturn;
+}
+
+::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch > > SAL_CALL
+ BibInterceptorHelper::queryDispatches( const ::com::sun::star::uno::Sequence< ::com::sun::star::frame::DispatchDescriptor >& aDescripts ) throw (::com::sun::star::uno::RuntimeException)
+{
+ Sequence< Reference< XDispatch> > aReturn( aDescripts.getLength() );
+ Reference< XDispatch >* pReturn = aReturn.getArray();
+ const DispatchDescriptor* pDescripts = aDescripts.getConstArray();
+ for ( sal_Int16 i=0; i<aDescripts.getLength(); ++i, ++pReturn, ++pDescripts )
+ {
+ *pReturn = queryDispatch( pDescripts->FeatureURL, pDescripts->FrameName, pDescripts->SearchFlags );
+ }
+ return aReturn;
+}
+
+// XDispatchProviderInterceptor
+::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider > SAL_CALL
+ BibInterceptorHelper::getSlaveDispatchProvider( ) throw (::com::sun::star::uno::RuntimeException)
+{
+ return xSlaveDispatchProvider;
+}
+
+void SAL_CALL BibInterceptorHelper::setSlaveDispatchProvider( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider >& xNewSlaveDispatchProvider ) throw (::com::sun::star::uno::RuntimeException)
+{
+ xSlaveDispatchProvider = xNewSlaveDispatchProvider;
+}
+
+::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider > SAL_CALL
+ BibInterceptorHelper::getMasterDispatchProvider( ) throw (::com::sun::star::uno::RuntimeException)
+{
+ return xMasterDispatchProvider;
+}
+
+void SAL_CALL BibInterceptorHelper::setMasterDispatchProvider( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider >& xNewMasterDispatchProvider ) throw (::com::sun::star::uno::RuntimeException)
+{
+ xMasterDispatchProvider = xNewMasterDispatchProvider;
+}
+
+//-----------------------------------------------------------------------------
+#define STR_UID "uid"
+::rtl::OUString gGridName(C2U("theGrid"));
+::rtl::OUString gViewName(C2U("theView"));
+::rtl::OUString gGlobalName(C2U("theGlobals"));
+::rtl::OUString gBeamerSize(C2U("theBeamerSize"));
+::rtl::OUString gViewSize(C2U("theViewSize"));
+
+BibDataManager::BibDataManager()
+ :BibDataManager_Base( GetMutex() )
+ // #100312# --------------
+ ,m_pInterceptorHelper( NULL )
+ ,m_aLoadListeners(m_aMutex)
+ ,pBibView( NULL )
+ ,pToolbar(0)
+{
+}
+
+/* --------------------------------------------------
+
+ --------------------------------------------------*/
+BibDataManager::~BibDataManager()
+{
+ Reference< XLoadable > xLoad( m_xForm, UNO_QUERY );
+ Reference< XPropertySet > xPrSet( m_xForm, UNO_QUERY );
+ Reference< XComponent > xComp( m_xForm, UNO_QUERY );
+ if ( m_xForm.is() )
+ {
+ Reference< XComponent > xConnection;
+ xPrSet->getPropertyValue(C2U("ActiveConnection")) >>= xConnection;
+ RemoveMeAsUidListener();
+ if (xLoad.is())
+ xLoad->unload();
+ if (xComp.is())
+ xComp->dispose();
+ if(xConnection.is())
+ xConnection->dispose();
+ m_xForm = NULL;
+ }
+ // #100312# ----------------
+ if( m_pInterceptorHelper )
+ {
+ m_pInterceptorHelper->ReleaseInterceptor();
+ m_pInterceptorHelper->release();
+ m_pInterceptorHelper = NULL;
+ }
+}
+//------------------------------------------------------------------------
+void BibDataManager::InsertFields(const Reference< XFormComponent > & _rxGrid)
+{
+ if ( !_rxGrid.is() )
+ return;
+
+ try
+ {
+ Reference< XNameContainer > xColContainer( _rxGrid, UNO_QUERY );
+ // remove the old fields
+ if ( xColContainer->hasElements() )
+ {
+ Sequence< ::rtl::OUString > aNames = xColContainer->getElementNames();
+ const ::rtl::OUString* pNames = aNames.getConstArray();
+ const ::rtl::OUString* pNamesEnd = pNames + aNames.getLength();
+ for ( ; pNames != pNamesEnd; ++pNames )
+ xColContainer->removeByName( *pNames );
+ }
+
+ Reference< XNameAccess > xFields = getColumns( m_xForm );
+ if (!xFields.is())
+ return;
+
+ Reference< XGridColumnFactory > xColFactory( _rxGrid, UNO_QUERY );
+
+ Reference< XPropertySet > xField;
+
+ Sequence< ::rtl::OUString > aFields( xFields->getElementNames() );
+ const ::rtl::OUString* pFields = aFields.getConstArray();
+ const ::rtl::OUString* pFieldsEnd = pFields + aFields.getLength();
+
+ for ( ; pFields != pFieldsEnd; ++pFields )
+ {
+ xFields->getByName( *pFields ) >>= xField;
+
+ ::rtl::OUString sCurrentModelType;
+ const ::rtl::OUString sType(C2U("Type"));
+ sal_Int32 nType = 0;
+ sal_Bool bIsFormatted = sal_False;
+ sal_Bool bFormattedIsNumeric = sal_True;
+ xField->getPropertyValue(sType) >>= nType;
+ switch(nType)
+ {
+ case DataType::BIT:
+ case DataType::BOOLEAN:
+ sCurrentModelType = C2U("CheckBox");
+ break;
+
+ case DataType::BINARY:
+ case DataType::VARBINARY:
+ case DataType::LONGVARBINARY:
+ case DataType::BLOB:
+ sCurrentModelType = C2U("TextField");
+ break;
+
+ case DataType::VARCHAR:
+ case DataType::LONGVARCHAR:
+ case DataType::CHAR:
+ case DataType::CLOB:
+ bFormattedIsNumeric = sal_False;
+ // _NO_ break !
+ default:
+ sCurrentModelType = C2U("FormattedField");
+ bIsFormatted = sal_True;
+ break;
+ }
+
+ Reference< XPropertySet > xCurrentCol = xColFactory->createColumn(sCurrentModelType);
+ if (bIsFormatted)
+ {
+ ::rtl::OUString sFormatKey(C2U("FormatKey"));
+ xCurrentCol->setPropertyValue(sFormatKey, xField->getPropertyValue(sFormatKey));
+ Any aFormatted(&bFormattedIsNumeric, ::getBooleanCppuType());
+ xCurrentCol->setPropertyValue(C2U("TreatAsNumber"), aFormatted);
+ }
+ Any aColName = makeAny( *pFields );
+ xCurrentCol->setPropertyValue(FM_PROP_CONTROLSOURCE, aColName);
+ xCurrentCol->setPropertyValue(FM_PROP_LABEL, aColName);
+
+ xColContainer->insertByName( *pFields, makeAny( xCurrentCol ) );
+ }
+ }
+ catch(Exception& e )
+ {
+ (void) e; // make compiler happy
+ DBG_ERROR("Exception in BibDataManager::InsertFields");
+ }
+}
+/* --------------------------------------------------
+
+ --------------------------------------------------*/
+Reference< awt::XControlModel > BibDataManager::updateGridModel()
+{
+ return updateGridModel( m_xForm );
+}
+/* --------------------------------------------------
+
+ --------------------------------------------------*/
+Reference< awt::XControlModel > BibDataManager::updateGridModel(const Reference< XForm > & xDbForm)
+{
+ try
+ {
+ Reference< XPropertySet > aFormPropSet( xDbForm, UNO_QUERY );
+ ::rtl::OUString sName;
+ aFormPropSet->getPropertyValue(C2U("Command")) >>= sName;
+
+ if ( !m_xGridModel.is() )
+ {
+ m_xGridModel = createGridModel( gGridName );
+
+ Reference< XNameContainer > xNameCont(xDbForm, UNO_QUERY);
+// if (xNameCont->hasByName(sName))
+// xNameCont->removeByName(sName);
+//
+ xNameCont->insertByName( sName, makeAny( m_xGridModel ) );
+ }
+
+ // insert the fields
+ Reference< XFormComponent > xFormComp( m_xGridModel, UNO_QUERY );
+ InsertFields( xFormComp );
+ }
+ catch(Exception& e )
+ {
+ (void) e; // make compiler happy
+ DBG_ERROR("::updateGridModel: something went wrong !");
+ }
+
+
+ return m_xGridModel;
+}
+/* --------------------------------------------------
+
+ --------------------------------------------------*/
+Reference< XForm > BibDataManager::createDatabaseForm(BibDBDescriptor& rDesc)
+{
+ Reference< XForm > xResult;
+ try
+ {
+ Reference< XMultiServiceFactory > xMgr = comphelper::getProcessServiceFactory();
+ m_xForm = Reference< XForm > ( xMgr->createInstance( C2U("com.sun.star.form.component.Form") ), UNO_QUERY );
+
+ Reference< XPropertySet > aPropertySet( m_xForm, UNO_QUERY );
+
+ aDataSourceURL = rDesc.sDataSource;
+ if(aPropertySet.is())
+ {
+ Any aVal;
+ aVal <<= (sal_Int32)ResultSetType::SCROLL_INSENSITIVE;
+ aPropertySet->setPropertyValue(C2U("ResultSetType"),aVal );
+ aVal <<= (sal_Int32)ResultSetConcurrency::READ_ONLY;
+ aPropertySet->setPropertyValue(C2U("ResultSetConcurrency"), aVal);
+
+ //Caching for Performance
+ aVal <<= (sal_Int32)50;
+ aPropertySet->setPropertyValue(C2U("FetchSize"), aVal);
+
+ Reference< XConnection > xConnection = getConnection(rDesc.sDataSource);
+ aVal <<= xConnection;
+ aPropertySet->setPropertyValue(C2U("ActiveConnection"), aVal);
+
+ Reference< XTablesSupplier > xSupplyTables(xConnection, UNO_QUERY);
+ Reference< XNameAccess > xTables = xSupplyTables.is() ?
+ xSupplyTables->getTables() : Reference< XNameAccess > ();
+
+ Sequence< ::rtl::OUString > aTableNameSeq;
+ if (xTables.is())
+ aTableNameSeq = xTables->getElementNames();
+
+ if(aTableNameSeq.getLength() > 0)
+ {
+ const ::rtl::OUString* pTableNames = aTableNameSeq.getConstArray();
+ if(rDesc.sTableOrQuery.getLength())
+ aActiveDataTable = rDesc.sTableOrQuery;
+ else
+ {
+ rDesc.sTableOrQuery = aActiveDataTable = pTableNames[0];
+ rDesc.nCommandType = CommandType::TABLE;
+ }
+
+ aVal <<= aActiveDataTable;
+ aPropertySet->setPropertyValue(C2U("Command"), aVal);
+ aVal <<= rDesc.nCommandType;
+ aPropertySet->setPropertyValue(C2U("CommandType"), aVal);
+
+
+ Reference< XDatabaseMetaData > xMetaData = xConnection->getMetaData();
+ aQuoteChar = xMetaData->getIdentifierQuoteString();
+
+ Reference< XMultiServiceFactory > xFactory(xConnection, UNO_QUERY);
+ if ( xFactory.is() )
+ m_xParser.set( xFactory->createInstance( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.sdb.SingleSelectQueryComposer" ) ) ), UNO_QUERY );
+
+ ::rtl::OUString aString(C2U("SELECT * FROM "));
+
+ ::rtl::OUString sCatalog, sSchema, sName;
+ ::dbtools::qualifiedNameComponents( xMetaData, aActiveDataTable, sCatalog, sSchema, sName, ::dbtools::eInDataManipulation );
+ aString += ::dbtools::composeTableNameForSelect( xConnection, sCatalog, sSchema, sName );
+
+ m_xParser->setElementaryQuery(aString);
+ BibConfig* pConfig = BibModul::GetConfig();
+ pConfig->setQueryField(getQueryField());
+ startQueryWith(pConfig->getQueryText());
+
+ xResult = m_xForm;
+ }
+ }
+ }
+ catch(Exception& e )
+ {
+ (void) e; // make compiler happy
+ DBG_ERROR("::createDatabaseForm: something went wrong !");
+ }
+
+
+ return xResult;
+}
+//------------------------------------------------------------------------
+Sequence< ::rtl::OUString > BibDataManager::getDataSources()
+{
+ Sequence< ::rtl::OUString > aTableNameSeq;
+
+ try
+ {
+ Reference< XTablesSupplier > xSupplyTables( getConnection( m_xForm ), UNO_QUERY );
+ Reference< XNameAccess > xTables;
+ if (xSupplyTables.is())
+ xTables = xSupplyTables->getTables();
+ if (xTables.is())
+ aTableNameSeq = xTables->getElementNames();
+ }
+ catch(Exception& e )
+ {
+ (void) e; // make compiler happy
+ DBG_ERROR("::getDataSources: something went wrong !");
+ }
+
+
+ return aTableNameSeq;
+}
+//------------------------------------------------------------------------
+::rtl::OUString BibDataManager::getActiveDataTable()
+{
+ return aActiveDataTable;
+}
+//------------------------------------------------------------------------
+void BibDataManager::setFilter(const ::rtl::OUString& rQuery)
+{
+ if(!m_xParser.is())
+ return;
+ try
+ {
+ m_xParser->setFilter( rQuery );
+ ::rtl::OUString aQuery = m_xParser->getFilter();
+ Reference< XPropertySet > xFormProps( m_xForm, UNO_QUERY_THROW );
+ xFormProps->setPropertyValue( C2U( "Filter" ), makeAny( aQuery ) );
+ xFormProps->setPropertyValue( C2U( "ApplyFilter" ), makeAny( sal_True ) );
+ reload();
+ }
+ catch(Exception& e )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+
+}
+//------------------------------------------------------------------------
+::rtl::OUString BibDataManager::getFilter()
+{
+
+ ::rtl::OUString aQueryString;
+ try
+ {
+ Reference< XPropertySet > xFormProps( m_xForm, UNO_QUERY_THROW );
+ OSL_VERIFY( xFormProps->getPropertyValue( C2U( "Filter" ) ) >>= aQueryString );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+
+ return aQueryString;
+
+}
+//------------------------------------------------------------------------
+Sequence< ::rtl::OUString > BibDataManager::getQueryFields()
+{
+ Sequence< ::rtl::OUString > aFieldSeq;
+ Reference< XNameAccess > xFields = getColumns( m_xForm );
+ if (xFields.is())
+ aFieldSeq = xFields->getElementNames();
+ return aFieldSeq;
+}
+//------------------------------------------------------------------------
+::rtl::OUString BibDataManager::getQueryField()
+{
+ BibConfig* pConfig = BibModul::GetConfig();
+ ::rtl::OUString aFieldString = pConfig->getQueryField();
+ if(!aFieldString.getLength())
+ {
+ Sequence< ::rtl::OUString > aSeq = getQueryFields();
+ const ::rtl::OUString* pFields = aSeq.getConstArray();
+ if(aSeq.getLength()>0)
+ {
+ aFieldString=pFields[0];
+ }
+ }
+ return aFieldString;
+}
+//------------------------------------------------------------------------
+void BibDataManager::startQueryWith(const ::rtl::OUString& rQuery)
+{
+ BibConfig* pConfig = BibModul::GetConfig();
+ pConfig->setQueryText( rQuery );
+
+ ::rtl::OUString aQueryString;
+ if(rQuery.getLength()>0)
+ {
+ aQueryString=aQuoteChar;
+ aQueryString+=getQueryField();
+ aQueryString+=aQuoteChar;
+ aQueryString+=C2U(" like '");
+ String sQuery(rQuery);
+ sQuery.SearchAndReplaceAll('?','_');
+ sQuery.SearchAndReplaceAll('*','%');
+ aQueryString += sQuery;
+ aQueryString+=C2U("%'");
+ }
+ setFilter(aQueryString);
+}
+/* -----------------03.12.99 15:05-------------------
+
+ --------------------------------------------------*/
+void BibDataManager::setActiveDataSource(const ::rtl::OUString& rURL)
+{
+ ::rtl::OUString uTable;
+ ::rtl::OUString sTmp(aDataSourceURL);
+ aDataSourceURL = rURL;
+
+ Reference< XPropertySet > aPropertySet( m_xForm, UNO_QUERY );
+ if(aPropertySet.is())
+ {
+ unload();
+
+ Reference< XComponent > xOldConnection;
+ aPropertySet->getPropertyValue(C2U("ActiveConnection")) >>= xOldConnection;
+
+ Reference< XConnection > xConnection = getConnection(rURL);
+ if(!xConnection.is())
+ {
+ aDataSourceURL = sTmp;
+ return;
+ }
+ Any aVal; aVal <<= xConnection;
+ aPropertySet->setPropertyValue(C2U("ActiveConnection"), aVal);
+ Reference< XMultiServiceFactory > xFactory(xConnection, UNO_QUERY);
+ if ( xFactory.is() )
+ m_xParser.set( xFactory->createInstance( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.sdb.SingleSelectQueryComposer" ) ) ), UNO_QUERY );
+
+ if(xOldConnection.is())
+ xOldConnection->dispose();
+
+ Sequence< ::rtl::OUString > aTableNameSeq;
+ Reference< XTablesSupplier > xSupplyTables(xConnection, UNO_QUERY);
+ if(xSupplyTables.is())
+ {
+ Reference< XNameAccess > xAccess = xSupplyTables->getTables();
+ aTableNameSeq = xAccess->getElementNames();
+ }
+ if(aTableNameSeq.getLength() > 0)
+ {
+ const ::rtl::OUString* pTableNames = aTableNameSeq.getConstArray();
+ aActiveDataTable = pTableNames[0];
+ aVal <<= aActiveDataTable;
+ aPropertySet->setPropertyValue(C2U("Command"), aVal);
+ aPropertySet->setPropertyValue(C2U("CommandType"), makeAny(CommandType::TABLE));
+ //Caching for Performance
+ aVal <<= (sal_Int32)50;
+ aPropertySet->setPropertyValue(C2U("FetchSize"), aVal);
+ ::rtl::OUString aString(C2U("SELECT * FROM "));
+ // quote the table name which may contain catalog.schema.table
+ Reference<XDatabaseMetaData> xMetaData(xConnection->getMetaData(),UNO_QUERY);
+ aQuoteChar = xMetaData->getIdentifierQuoteString();
+
+ ::rtl::OUString sCatalog, sSchema, sName;
+ ::dbtools::qualifiedNameComponents( xMetaData, aActiveDataTable, sCatalog, sSchema, sName, ::dbtools::eInDataManipulation );
+ aString += ::dbtools::composeTableNameForSelect( xConnection, sCatalog, sSchema, sName );
+
+ m_xParser->setElementaryQuery(aString);
+ BibConfig* pConfig = BibModul::GetConfig();
+ pConfig->setQueryField(getQueryField());
+ startQueryWith(pConfig->getQueryText());
+ setActiveDataTable(aActiveDataTable);
+ }
+ FeatureStateEvent aEvent;
+ util::URL aURL;
+ aEvent.IsEnabled = sal_True;
+ aEvent.Requery = sal_False;
+ aEvent.FeatureDescriptor = getActiveDataTable();
+
+ aEvent.State = makeAny( getDataSources() );
+
+ if(pToolbar)
+ {
+ aURL.Complete =C2U(".uno:Bib/source");
+ aEvent.FeatureURL = aURL;
+ pToolbar->statusChanged( aEvent );
+ }
+
+ updateGridModel();
+ load();
+ }
+}
+
+/* --------------------------------------------------
+
+ --------------------------------------------------*/
+void BibDataManager::setActiveDataTable(const ::rtl::OUString& rTable)
+{
+ ResetIdentifierMapping();
+ try
+ {
+ Reference< XPropertySet > aPropertySet( m_xForm, UNO_QUERY );
+
+ if(aPropertySet.is())
+ {
+ Reference< XConnection > xConnection = getConnection( m_xForm );
+ Reference< XTablesSupplier > xSupplyTables(xConnection, UNO_QUERY);
+ Reference< XNameAccess > xAccess = xSupplyTables->getTables();
+ Sequence< ::rtl::OUString > aTableNameSeq = xAccess->getElementNames();
+ sal_uInt32 nCount = aTableNameSeq.getLength();
+
+ const ::rtl::OUString* pTableNames = aTableNameSeq.getConstArray();
+ const ::rtl::OUString* pTableNamesEnd = pTableNames + nCount;
+
+ for ( ; pTableNames != pTableNamesEnd; ++pTableNames )
+ {
+ if ( rTable == *pTableNames )
+ {
+ aActiveDataTable = rTable;
+ Any aVal; aVal <<= rTable;
+ aPropertySet->setPropertyValue( C2U("Command"), aVal );
+ break;
+ }
+ }
+ if (pTableNames != pTableNamesEnd)
+ {
+ Reference< XDatabaseMetaData > xMetaData = xConnection->getMetaData();
+ aQuoteChar = xMetaData->getIdentifierQuoteString();
+
+ Reference< XMultiServiceFactory > xFactory(xConnection, UNO_QUERY);
+ if ( xFactory.is() )
+ m_xParser.set( xFactory->createInstance( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.sdb.SingleSelectQueryComposer" ) ) ), UNO_QUERY );
+
+ ::rtl::OUString aString(C2U("SELECT * FROM "));
+
+ ::rtl::OUString sCatalog, sSchema, sName;
+ ::dbtools::qualifiedNameComponents( xMetaData, aActiveDataTable, sCatalog, sSchema, sName, ::dbtools::eInDataManipulation );
+ aString += ::dbtools::composeTableNameForSelect( xConnection, sCatalog, sSchema, sName );
+
+ m_xParser->setElementaryQuery(aString);
+
+ BibConfig* pConfig = BibModul::GetConfig();
+ pConfig->setQueryField(getQueryField());
+ startQueryWith(pConfig->getQueryText());
+
+ BibDBDescriptor aDesc;
+ aDesc.sDataSource = aDataSourceURL;
+ aDesc.sTableOrQuery = aActiveDataTable;
+ aDesc.nCommandType = CommandType::TABLE;
+ BibModul::GetConfig()->SetBibliographyURL(aDesc);
+ }
+ }
+ }
+ catch(Exception& e )
+ {
+ (void) e; // make compiler happy
+ DBG_ERROR("::setActiveDataTable: something went wrong !");
+ }
+
+}
+
+//------------------------------------------------------------------------
+void SAL_CALL BibDataManager::load( ) throw (RuntimeException)
+{
+ if ( isLoaded() )
+ // nothing to do
+ return;
+
+ Reference< XLoadable > xFormAsLoadable( m_xForm, UNO_QUERY );
+ DBG_ASSERT( xFormAsLoadable.is() || !m_xForm.is(), "BibDataManager::load: invalid form!");
+ if ( xFormAsLoadable.is() )
+ {
+ xFormAsLoadable->load();
+ SetMeAsUidListener();
+
+ EventObject aEvt( static_cast< XWeak* >( this ) );
+ m_aLoadListeners.notifyEach( &XLoadListener::loaded, aEvt );
+ }
+}
+
+//------------------------------------------------------------------------
+void SAL_CALL BibDataManager::unload( ) throw (RuntimeException)
+{
+ if ( !isLoaded() )
+ // nothing to do
+ return;
+
+ Reference< XLoadable >xFormAsLoadable( m_xForm, UNO_QUERY );
+ DBG_ASSERT( xFormAsLoadable.is() || !m_xForm.is(), "BibDataManager::unload: invalid form!");
+ if ( xFormAsLoadable.is() )
+ {
+ EventObject aEvt( static_cast< XWeak* >( this ) );
+
+ {
+ m_aLoadListeners.notifyEach( &XLoadListener::unloading, aEvt );
+ }
+
+ RemoveMeAsUidListener();
+ xFormAsLoadable->unload();
+
+ {
+ m_aLoadListeners.notifyEach( &XLoadListener::unloaded, aEvt );
+ }
+ }
+}
+
+//------------------------------------------------------------------------
+void SAL_CALL BibDataManager::reload( ) throw (RuntimeException)
+{
+ if ( !isLoaded() )
+ // nothing to do
+ return;
+
+ Reference< XLoadable >xFormAsLoadable( m_xForm, UNO_QUERY );
+ DBG_ASSERT( xFormAsLoadable.is() || !m_xForm.is(), "BibDataManager::unload: invalid form!");
+ if ( xFormAsLoadable.is() )
+ {
+ EventObject aEvt( static_cast< XWeak* >( this ) );
+
+ {
+ m_aLoadListeners.notifyEach( &XLoadListener::reloading, aEvt );
+ }
+
+ xFormAsLoadable->reload();
+
+ {
+ m_aLoadListeners.notifyEach( &XLoadListener::reloaded, aEvt );
+ }
+ }
+}
+
+//------------------------------------------------------------------------
+sal_Bool SAL_CALL BibDataManager::isLoaded( ) throw (RuntimeException)
+{
+ Reference< XLoadable >xFormAsLoadable( m_xForm, UNO_QUERY );
+ DBG_ASSERT( xFormAsLoadable.is() || !m_xForm.is(), "BibDataManager::isLoaded: invalid form!");
+
+ sal_Bool bLoaded = sal_False;
+ if ( xFormAsLoadable.is() )
+ bLoaded = xFormAsLoadable->isLoaded();
+ return bLoaded;
+}
+
+//------------------------------------------------------------------------
+void SAL_CALL BibDataManager::addLoadListener( const Reference< XLoadListener >& aListener ) throw (RuntimeException)
+{
+ m_aLoadListeners.addInterface( aListener );
+}
+
+//------------------------------------------------------------------------
+void SAL_CALL BibDataManager::removeLoadListener( const Reference< XLoadListener >& aListener ) throw (RuntimeException)
+{
+ m_aLoadListeners.removeInterface( aListener );
+}
+
+//------------------------------------------------------------------------
+Reference< awt::XControlModel > BibDataManager::createGridModel(const ::rtl::OUString& rName)
+{
+ Reference< awt::XControlModel > xModel;
+
+ try
+ {
+ // create the control model
+ Reference< XMultiServiceFactory > xMgr = ::comphelper::getProcessServiceFactory();
+ Reference< XInterface > xObject = xMgr->createInstance(C2U("com.sun.star.form.component.GridControl"));
+ xModel=Reference< awt::XControlModel > ( xObject, UNO_QUERY );
+
+ // set the
+ Reference< XPropertySet > xPropSet( xModel, UNO_QUERY );
+ xPropSet->setPropertyValue( C2U("Name"), makeAny( rName ) );
+
+ // set the name of the to-be-created control
+ ::rtl::OUString aControlName(C2U("com.sun.star.form.control.InteractionGridControl"));
+ Any aAny; aAny <<= aControlName;
+ xPropSet->setPropertyValue( C2U("DefaultControl"),aAny );
+
+ // the the helpURL
+ ::rtl::OUString uProp(C2U("HelpURL"));
+ Reference< XPropertySetInfo > xPropInfo = xPropSet->getPropertySetInfo();
+ if (xPropInfo->hasPropertyByName(uProp))
+ {
+ ::rtl::OUString sId = ::rtl::OUString::createFromAscii( "HID:" );
+ sId += ::rtl::OUString::valueOf( (sal_Int32) HID_BIB_DB_GRIDCTRL );
+ xPropSet->setPropertyValue( uProp, makeAny( ::rtl::OUString( sId ) ) );
+ }
+ }
+ catch(Exception& e )
+ {
+ (void) e; // make compiler happy
+ DBG_ERROR("::createGridModel: something went wrong !");
+ }
+
+
+ return xModel;
+}
+//------------------------------------------------------------------------
+::rtl::OUString BibDataManager::getControlName(sal_Int32 nFormatKey )
+{
+ ::rtl::OUString aResStr;
+ switch (nFormatKey)
+ {
+ case DataType::BIT:
+ case DataType::BOOLEAN:
+ aResStr=C2U("CheckBox");
+ break;
+ case DataType::TINYINT:
+ case DataType::SMALLINT:
+ case DataType::INTEGER:
+ aResStr=C2U("NumericField"); ;
+ break;
+ case DataType::REAL:
+ case DataType::DOUBLE:
+ case DataType::NUMERIC:
+ case DataType::DECIMAL:
+ aResStr=C2U("FormattedField");
+ break;
+ case DataType::TIMESTAMP:
+ aResStr=C2U("FormattedField");
+ break;
+ case DataType::DATE:
+ aResStr=C2U("DateField");
+ break;
+ case DataType::TIME:
+ aResStr=C2U("TimeField");
+ break;
+ case DataType::CHAR:
+ case DataType::VARCHAR:
+ case DataType::LONGVARCHAR:
+ default:
+ aResStr=C2U("TextField");
+ break;
+ }
+ return aResStr;
+}
+//------------------------------------------------------------------------
+Reference< awt::XControlModel > BibDataManager::loadControlModel(
+ const ::rtl::OUString& rName, sal_Bool bForceListBox)
+{
+ Reference< awt::XControlModel > xModel;
+ ::rtl::OUString aName(C2U("View_"));
+ aName += rName;
+
+ try
+ {
+ Reference< XNameAccess > xFields = getColumns( m_xForm );
+ if (!xFields.is())
+ return xModel;
+ Reference< XPropertySet > xField;
+
+ Any aElement;
+
+ if(xFields->hasByName(rName))
+ {
+ aElement = xFields->getByName(rName);
+ aElement >>= xField;
+ Reference< XPropertySetInfo > xInfo = xField.is() ? xField->getPropertySetInfo() : Reference< XPropertySetInfo > ();
+
+ ::rtl::OUString sCurrentModelType;
+ const ::rtl::OUString sType(C2U("Type"));
+ sal_Int32 nFormatKey = 0;
+ xField->getPropertyValue(sType) >>= nFormatKey;
+
+ ::rtl::OUString aInstanceName(C2U("com.sun.star.form.component."));
+
+ if (bForceListBox)
+ aInstanceName += C2U("ListBox");
+ else
+ aInstanceName += getControlName(nFormatKey);
+
+ Reference< XMultiServiceFactory > xMgr = comphelper::getProcessServiceFactory();
+ Reference< XInterface > xObject = xMgr->createInstance(aInstanceName);
+ xModel=Reference< awt::XControlModel > ( xObject, UNO_QUERY );
+ Reference< XPropertySet > xPropSet( xModel, UNO_QUERY );
+ Any aFieldName; aFieldName <<= aName;
+
+ xPropSet->setPropertyValue( FM_PROP_NAME,aFieldName);
+ xPropSet->setPropertyValue( FM_PROP_CONTROLSOURCE, makeAny( rName ) );
+ xPropSet->setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "NativeWidgetLook" ) ), makeAny( (sal_Bool)sal_True ) );
+
+ Reference< XFormComponent > aFormComp(xModel,UNO_QUERY );
+
+ Reference< XNameContainer > xNameCont( m_xForm, UNO_QUERY );
+ xNameCont->insertByName(aName, makeAny( aFormComp ) );
+
+ // now if the form where we inserted the new model is already loaded, notify the model of this
+ // Note that this implementation below is a HACK as it relies on the fact that the model adds itself
+ // as load listener to it's parent, which is an implementation detail of the model.
+ //
+ // the better solution would be the following:
+ // in the current scenario, we insert a control model into a form. This results in the control model
+ // adding itself as load listener to the form. Now, the form should realize that it's already loaded
+ // and notify the model (which it knows as XLoadListener only) immediately. This seems to make sense.
+ // (as an anologon to the XStatusListener semantics).
+ //
+ // But this would be way too risky for this last-day fix here.
+ // 97140 - 30.01.2002 - fs@openoffice.org
+ Reference< XLoadable > xLoad( m_xForm, UNO_QUERY );
+ if ( xLoad.is() && xLoad->isLoaded() )
+ {
+ Reference< XLoadListener > xListener( aFormComp, UNO_QUERY );
+ if ( xListener.is() )
+ {
+ EventObject aLoadSource;
+ aLoadSource.Source = xLoad;
+ xListener->loaded( aLoadSource );
+ }
+ }
+ }
+ }
+ catch(Exception& e )
+ {
+ (void) e; // make compiler happy
+ DBG_ERROR("::loadControlModel: something went wrong !");
+ }
+ return xModel;
+}
+//------------------------------------------------------------------------
+void SAL_CALL BibDataManager::disposing()
+{
+ BibDataManager_Base::WeakComponentImplHelperBase::disposing();
+}
+
+//------------------------------------------------------------------------
+void BibDataManager::disposing( const EventObject& /*Source*/ ) throw( ::com::sun::star::uno::RuntimeException )
+{
+ // not interested in
+}
+
+//------------------------------------------------------------------------
+void BibDataManager::propertyChange(const beans::PropertyChangeEvent& evt) throw( RuntimeException )
+{
+ try
+ {
+ sal_Bool bFlag=sal_False;
+ if(evt.PropertyName == FM_PROP_VALUE)
+ {
+ if( evt.NewValue.getValueType() == ::getCppuType((Reference<io::XInputStream>*)0) )
+ {
+ Reference< io::XDataInputStream > xStream(
+ *(const Reference< io::XInputStream > *)evt.NewValue.getValue(), UNO_QUERY );
+ aUID <<= xStream->readUTF();
+ }
+ else
+ aUID = evt.NewValue;
+
+ Reference< XRowLocate > xLocate(xBibCursor, UNO_QUERY);
+ DBG_ASSERT(xLocate.is(), "BibDataManager::propertyChange : invalid cursor !");
+ bFlag = xLocate->moveToBookmark(aUID);
+ }
+ }
+ catch(Exception& e )
+ {
+ (void) e; // make compiler happy
+ DBG_ERROR("::propertyChange: something went wrong !");
+ }
+
+
+}
+//------------------------------------------------------------------------
+void BibDataManager::SetMeAsUidListener()
+{
+try
+{
+ Reference< XNameAccess > xFields = getColumns( m_xForm );
+ if (!xFields.is())
+ return;
+
+ Sequence< ::rtl::OUString > aFields(xFields->getElementNames());
+ const ::rtl::OUString* pFields = aFields.getConstArray();
+ sal_Int32 nCount=aFields.getLength();
+ String StrUID(C2S(STR_UID));
+ ::rtl::OUString theFieldName;
+ for( sal_Int32 i=0; i<nCount; i++ )
+ {
+ String aName= pFields[i];
+
+ if(aName.EqualsIgnoreCaseAscii(StrUID))
+ {
+ theFieldName=pFields[i];
+ break;
+ }
+ }
+
+ if(theFieldName.getLength()>0)
+ {
+ Reference< XPropertySet > xPropSet;
+ Any aElement;
+
+ aElement = xFields->getByName(theFieldName);
+ xPropSet = *(Reference< XPropertySet > *)aElement.getValue();
+
+ xPropSet->addPropertyChangeListener(FM_PROP_VALUE, this);
+ }
+
+}
+catch(Exception& e )
+{
+ (void) e; // make compiler happy
+ DBG_ERROR("Exception in BibDataManager::SetMeAsUidListener");
+}
+
+
+}
+//------------------------------------------------------------------------
+void BibDataManager::RemoveMeAsUidListener()
+{
+try
+{
+ Reference< XNameAccess > xFields = getColumns( m_xForm );
+ if (!xFields.is())
+ return;
+
+
+ Sequence< ::rtl::OUString > aFields(xFields->getElementNames());
+ const ::rtl::OUString* pFields = aFields.getConstArray();
+ sal_Int32 nCount=aFields.getLength();
+ String StrUID(C2S(STR_UID));
+ ::rtl::OUString theFieldName;
+ for( sal_Int32 i=0; i<nCount; i++ )
+ {
+ String aName= pFields[i];
+
+ if(aName.EqualsIgnoreCaseAscii(StrUID))
+ {
+ theFieldName=pFields[i];
+ break;
+ }
+ }
+
+ if(theFieldName.getLength()>0)
+ {
+ Reference< XPropertySet > xPropSet;
+ Any aElement;
+
+ aElement = xFields->getByName(theFieldName);
+ xPropSet = *(Reference< XPropertySet > *)aElement.getValue();
+
+ xPropSet->removePropertyChangeListener(FM_PROP_VALUE, this);
+ }
+
+}
+catch(Exception& e )
+{
+ (void) e; // make compiler happy
+ DBG_ERROR("Exception in BibDataManager::RemoveMeAsUidListener");
+}
+
+
+}
+/* -----------------11.11.99 15:51-------------------
+
+ --------------------------------------------------*/
+void BibDataManager::CreateMappingDialog(Window* pParent)
+{
+ MappingDialog_Impl* pDlg = new MappingDialog_Impl(pParent, this);
+ if(RET_OK == pDlg->Execute() && pBibView)
+ {
+ reload();
+// unload();
+// pBibView->UpdatePages();
+// load();
+ }
+ delete pDlg;
+}
+/* --------------------------------------------------
+
+ --------------------------------------------------*/
+::rtl::OUString BibDataManager::CreateDBChangeDialog(Window* pParent)
+{
+ ::rtl::OUString uRet;
+ DBChangeDialog_Impl * pDlg = new DBChangeDialog_Impl(pParent, this );
+ if(RET_OK == pDlg->Execute())
+ {
+ String sNewURL = pDlg->GetCurrentURL();
+ if(sNewURL != String(getActiveDataSource()))
+ {
+ uRet = sNewURL;
+ }
+ }
+ delete pDlg;
+ return uRet;
+}
+/*-- 18.05.2004 15:20:15---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+void BibDataManager::DispatchDBChangeDialog()
+{
+ if(pToolbar)
+ pToolbar->SendDispatch(TBC_BT_CHANGESOURCE, Sequence< PropertyValue >());
+}
+/* -----------------06.12.99 15:11-------------------
+
+ --------------------------------------------------*/
+const ::rtl::OUString& BibDataManager::GetIdentifierMapping()
+{
+ if(!sIdentifierMapping.getLength())
+ {
+ BibConfig* pConfig = BibModul::GetConfig();
+ BibDBDescriptor aDesc;
+ aDesc.sDataSource = getActiveDataSource();
+ aDesc.sTableOrQuery = getActiveDataTable();
+ aDesc.nCommandType = CommandType::TABLE;
+ const Mapping* pMapping = pConfig->GetMapping(aDesc);
+ sIdentifierMapping = pConfig->GetDefColumnName(IDENTIFIER_POS);
+ if(pMapping)
+ {
+ for(sal_uInt16 nEntry = 0; nEntry < COLUMN_COUNT; nEntry++)
+ {
+ if(pMapping->aColumnPairs[nEntry].sLogicalColumnName == sIdentifierMapping)
+ {
+ sIdentifierMapping = pMapping->aColumnPairs[nEntry].sRealColumnName;
+ break;
+ }
+ }
+ }
+ }
+ return sIdentifierMapping;
+}
+/* -----------------------------20.11.00 10:31--------------------------------
+
+ ---------------------------------------------------------------------------*/
+void BibDataManager::SetToolbar(BibToolBar* pSet)
+{
+ pToolbar = pSet;
+ if(pToolbar)
+ pToolbar->SetDatMan(*this);
+}
+/* -----------------------------08.05.2002 09:26------------------------------
+
+ ---------------------------------------------------------------------------*/
+uno::Reference< form::runtime::XFormController > BibDataManager::GetFormController()
+{
+ if(!m_xFormCtrl.is())
+ {
+ Reference< lang::XMultiServiceFactory > xMgr = comphelper::getProcessServiceFactory();
+ m_xFormCtrl = uno::Reference< form::runtime::XFormController > (
+ xMgr->createInstance(C2U("com.sun.star.form.runtime.FormController")), UNO_QUERY);
+ m_xFormCtrl->setModel(uno::Reference< awt::XTabControllerModel > (getForm(), UNO_QUERY));
+ // #100312# -------------
+ m_xFormDispatch = uno::Reference< frame::XDispatch > ( m_xFormCtrl, UNO_QUERY);
+ }
+ return m_xFormCtrl;
+}
+
+// #100312# ----------
+void BibDataManager::RegisterInterceptor( ::bib::BibBeamer* pBibBeamer)
+{
+ DBG_ASSERT( !m_pInterceptorHelper, "BibDataManager::RegisterInterceptor: called twice!" );
+
+ if( pBibBeamer )
+ m_pInterceptorHelper = new BibInterceptorHelper( pBibBeamer, m_xFormDispatch);
+ if( m_pInterceptorHelper )
+ m_pInterceptorHelper->acquire();
+}
+
+/*-- 18.05.2004 17:04:20---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+sal_Bool BibDataManager::HasActiveConnection()const
+{
+ sal_Bool bRet = sal_False;
+ Reference< XPropertySet > xPrSet( m_xForm, UNO_QUERY );
+ if( xPrSet.is() )
+ {
+ Reference< XComponent > xConnection;
+ xPrSet->getPropertyValue(C2U("ActiveConnection")) >>= xConnection;
+ bRet = xConnection.is();
+ }
+ return bRet;
+}
+/*-- 04.06.2004 14:37:29---------------------------------------------------
+
+ -----------------------------------------------------------------------*/
+sal_Bool BibDataManager::HasActiveConnection()
+{
+ return getConnection( m_xForm ).is();
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/bibliography/datman.hrc b/extensions/source/bibliography/datman.hrc
new file mode 100644
index 000000000000..5ea4749eef1c
--- /dev/null
+++ b/extensions/source/bibliography/datman.hrc
@@ -0,0 +1,102 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+
+#define BT_OK 1
+#define BT_CANCEL 2
+#define BT_HELP 3
+#define GB_MAPPING 4
+#define FT_IDENTIFIER 5
+#define LB_IDENTIFIER 6
+#define ST_NONE 7
+
+#define FT_AUTHORITYTYPE 8
+#define LB_AUTHORITYTYPE 9
+#define FT_ADDRESS 10
+#define LB_ADDRESS 11
+#define FT_ANNOTE 12
+#define LB_ANNOTE 13
+#define FT_AUTHOR 14
+#define LB_AUTHOR 15
+#define FT_TITLE 16
+#define LB_TITLE 17
+#define FT_MONTH 18
+#define LB_MONTH 19
+#define FT_YEAR 20
+#define LB_YEAR 21
+#define FT_ISBN 22
+#define LB_ISBN 23
+#define FT_BOOKTITLE 24
+#define LB_BOOKTITLE 25
+#define FT_CHAPTER 26
+#define LB_CHAPTER 27
+#define FT_EDITION 28
+#define LB_EDITION 29
+#define FT_EDITOR 30
+#define LB_EDITOR 31
+#define FT_HOWPUBLISHED 32
+#define LB_HOWPUBLISHED 33
+#define FT_INSTITUTION 34
+#define LB_INSTITUTION 35
+#define FT_JOURNAL 36
+#define LB_JOURNAL 37
+#define FT_NOTE 38
+#define LB_NOTE 39
+#define FT_NUMBER 40
+#define LB_NUMBER 41
+#define FT_ORGANIZATIONS 42
+#define LB_ORGANIZATIONS 43
+#define FT_PAGES 44
+#define LB_PAGES 45
+#define FT_PUBLISHER 46
+#define LB_PUBLISHER 47
+#define FT_SCHOOL 48
+#define LB_SCHOOL 49
+#define FT_SERIES 50
+#define LB_SERIES 51
+#define FT_REPORTTYPE 52
+#define LB_REPORTTYPE 53
+#define FT_VOLUME 54
+#define LB_VOLUME 55
+#define FT_URL 56
+#define LB_URL 57
+#define FT_CUSTOM1 58
+#define LB_CUSTOM1 59
+#define FT_CUSTOM2 60
+#define LB_CUSTOM2 61
+#define FT_CUSTOM3 62
+#define LB_CUSTOM3 63
+#define FT_CUSTOM4 64
+#define LB_CUSTOM4 65
+#define FT_CUSTOM5 66
+#define LB_CUSTOM5 67
+
+#define GB_SELECTION 68
+#define ST_ENTRY 69
+#define LB_SELECTION 71
+#define HB_SELECTION 72
+
diff --git a/extensions/source/bibliography/datman.hxx b/extensions/source/bibliography/datman.hxx
new file mode 100644
index 000000000000..4f485641e9e1
--- /dev/null
+++ b/extensions/source/bibliography/datman.hxx
@@ -0,0 +1,202 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _BIB_DATMAN_HXX
+#define _BIB_DATMAN_HXX
+
+#include <com/sun/star/awt/XControlModel.hpp>
+#include <com/sun/star/form/XForm.hpp>
+#include <com/sun/star/sdbc/XResultSet.hpp>
+#include <com/sun/star/sdb/XSingleSelectQueryComposer.hpp>
+#include <com/sun/star/form/runtime/XFormController.hpp>
+#include <cppuhelper/compbase2.hxx>
+#include <cppuhelper/interfacecontainer.h>
+#include <com/sun/star/form/XLoadable.hpp>
+#include <comphelper/broadcasthelper.hxx>
+// #100312# --------------------
+#include <com/sun/star/frame/XDispatchProviderInterceptor.hpp>
+#include <com/sun/star/frame/XDispatchProviderInterception.hpp>
+#include <cppuhelper/implbase1.hxx>
+
+class Window;
+
+//-----------------------------------------------------------------------------
+namespace bib
+{
+ class BibView;
+ // #100312# -----------
+ class BibBeamer;
+}
+
+class BibToolBar;
+struct BibDBDescriptor;
+
+// #100312# ---------------------
+class BibInterceptorHelper
+ :public cppu::WeakImplHelper1< ::com::sun::star::frame::XDispatchProviderInterceptor >
+{
+private:
+ ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider > xMasterDispatchProvider;
+ ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider > xSlaveDispatchProvider;
+ ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch > xFormDispatch;
+ ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProviderInterception > xInterception;
+
+protected:
+ ~BibInterceptorHelper( );
+
+public:
+ BibInterceptorHelper( ::bib::BibBeamer* pBibBeamer, ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch > xDispatch);
+
+ void ReleaseInterceptor();
+
+ // XDispatchProvider
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch > SAL_CALL queryDispatch( const ::com::sun::star::util::URL& aURL, const ::rtl::OUString& aTargetFrameName, sal_Int32 nSearchFlags ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch > > SAL_CALL queryDispatches( const ::com::sun::star::uno::Sequence< ::com::sun::star::frame::DispatchDescriptor >& aDescripts ) throw (::com::sun::star::uno::RuntimeException);
+ // XDispatchProviderInterceptor
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider > SAL_CALL getSlaveDispatchProvider( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setSlaveDispatchProvider( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider >& xNewSlaveDispatchProvider ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider > SAL_CALL getMasterDispatchProvider( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setMasterDispatchProvider( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider >& xNewMasterDispatchProvider ) throw (::com::sun::star::uno::RuntimeException);
+};
+
+typedef cppu::WeakComponentImplHelper2 < ::com::sun::star::beans::XPropertyChangeListener
+ , ::com::sun::star::form::XLoadable
+ > BibDataManager_Base;
+class BibDataManager
+ :public ::comphelper::OMutexAndBroadcastHelper
+ ,public BibDataManager_Base
+{
+private:
+ ::com::sun::star::uno::Reference< ::com::sun::star::form::XForm > m_xForm;
+ ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel > m_xGridModel;
+ ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > m_xSourceProps;
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XSingleSelectQueryComposer > m_xParser;
+ ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController > m_xFormCtrl;
+ // #100312# -------------------
+ ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch > m_xFormDispatch;
+ BibInterceptorHelper* m_pInterceptorHelper;
+
+ ::rtl::OUString aActiveDataTable;
+ ::rtl::OUString aDataSourceURL;
+ ::rtl::OUString aQuoteChar;
+ ::com::sun::star::uno::Any aUID;
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > xBibCursor;
+
+ ::cppu::OInterfaceContainerHelper m_aLoadListeners;
+
+ ::bib::BibView* pBibView;
+ BibToolBar* pToolbar;
+
+ rtl::OUString sIdentifierMapping;
+protected:
+
+ void InsertFields(const ::com::sun::star::uno::Reference< ::com::sun::star::form::XFormComponent > & xGrid);
+ void SetMeAsUidListener();
+ void RemoveMeAsUidListener();
+
+ void UpdateAddressbookCursor(::rtl::OUString aSourceName);
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel >
+ updateGridModel(const ::com::sun::star::uno::Reference< ::com::sun::star::form::XForm > & xDbForm);
+ ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel >
+ createGridModel( const ::rtl::OUString& rName );
+
+ // XLoadable
+ virtual void SAL_CALL load( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL unload( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL reload( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL isLoaded( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL addLoadListener( const ::com::sun::star::uno::Reference< ::com::sun::star::form::XLoadListener >& aListener ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL removeLoadListener( const ::com::sun::star::uno::Reference< ::com::sun::star::form::XLoadListener >& aListener ) throw (::com::sun::star::uno::RuntimeException);
+
+ virtual void SAL_CALL disposing();
+
+public:
+
+ BibDataManager();
+ ~BibDataManager();
+
+ virtual void SAL_CALL propertyChange(const ::com::sun::star::beans::PropertyChangeEvent& evt)
+ throw( ::com::sun::star::uno::RuntimeException );
+ virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source )
+ throw( ::com::sun::star::uno::RuntimeException );
+
+
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::form::XForm > createDatabaseForm( BibDBDescriptor& aDesc);
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel > updateGridModel();
+
+ ::com::sun::star::uno::Sequence< ::rtl::OUString> getDataSources();
+
+ ::rtl::OUString getActiveDataSource() {return aDataSourceURL;}
+ void setActiveDataSource(const ::rtl::OUString& rURL);
+
+ ::rtl::OUString getActiveDataTable();
+ void setActiveDataTable(const ::rtl::OUString& rTable);
+
+ void setFilter(const ::rtl::OUString& rQuery);
+ ::rtl::OUString getFilter();
+
+ ::com::sun::star::uno::Sequence< ::rtl::OUString> getQueryFields();
+ ::rtl::OUString getQueryField();
+ void startQueryWith(const ::rtl::OUString& rQuery);
+
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XSingleSelectQueryComposer >& getParser() { return m_xParser; }
+ const ::com::sun::star::uno::Reference< ::com::sun::star::form::XForm >& getForm() { return m_xForm; }
+
+
+ ::rtl::OUString getControlName(sal_Int32 nFormatKey );
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel > loadControlModel(const ::rtl::OUString& rName,
+ sal_Bool bForceListBox = sal_False);
+
+ void CreateMappingDialog(Window* pParent);
+ ::rtl::OUString CreateDBChangeDialog(Window* pParent);
+
+ void DispatchDBChangeDialog();
+ sal_Bool HasActiveConnection() const;
+
+ void SetView( ::bib::BibView* pView ) { pBibView = pView; }
+
+ void SetToolbar(BibToolBar* pSet);
+
+ const rtl::OUString& GetIdentifierMapping();
+ void ResetIdentifierMapping() {sIdentifierMapping = rtl::OUString();}
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController > GetFormController();
+ // #100312# ----------
+ void RegisterInterceptor( ::bib::BibBeamer* pBibBeamer);
+
+ sal_Bool HasActiveConnection();
+};
+
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/bibliography/datman.src b/extensions/source/bibliography/datman.src
new file mode 100644
index 000000000000..6b8c4b00ef41
--- /dev/null
+++ b/extensions/source/bibliography/datman.src
@@ -0,0 +1,469 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#include "bib.hrc"
+#include "datman.hrc"
+ModalDialog RID_DLG_MAPPING
+{
+ HelpID = HID_DLG_MAPPING;
+ OutputSize = TRUE ;
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( 391 , 195 ) ;
+ Moveable = TRUE ;
+
+ OKButton BT_OK
+ {
+ Pos = MAP_APPFONT ( 338 , 3 ) ;
+ Size = MAP_APPFONT ( 50 , 12 ) ;
+ };
+ CancelButton BT_CANCEL
+ {
+ Pos = MAP_APPFONT ( 338 , 18 ) ;
+ Size = MAP_APPFONT ( 50 , 12 ) ;
+ };
+ HelpButton BT_HELP
+ {
+ Pos = MAP_APPFONT ( 338 , 36 ) ;
+ Size = MAP_APPFONT ( 50 , 12 ) ;
+ };
+ FixedLine GB_MAPPING
+ {
+ Pos = MAP_APPFONT ( 6 , 3 ) ;
+ Size = MAP_APPFONT ( 329 , 8 ) ;
+ Text [ en-US ] = "Column names";
+ };
+ FixedText FT_IDENTIFIER
+ {
+ Pos = MAP_APPFONT ( 12 , 14 ) ;
+ Size = MAP_APPFONT ( 50 , 10 ) ;
+ };
+ ListBox LB_IDENTIFIER
+ {
+ Pos = MAP_APPFONT ( 65 , 13 ) ;
+ Size = MAP_APPFONT ( 50 , 60 ) ;
+ DropDown = TRUE;
+ };
+ FixedText FT_AUTHORITYTYPE
+ {
+ Pos = MAP_APPFONT ( 118 , 14 ) ;
+ Size = MAP_APPFONT ( 50 , 10 ) ;
+ };
+ ListBox LB_AUTHORITYTYPE
+ {
+ Pos = MAP_APPFONT ( 171 , 13 ) ;
+ Size = MAP_APPFONT ( 50 , 60 ) ;
+ DropDown = TRUE;
+ };
+ FixedText FT_YEAR
+ {
+ Pos = MAP_APPFONT ( 229 , 14 ) ;
+ Size = MAP_APPFONT ( 50 , 10 ) ;
+ };
+ ListBox LB_YEAR
+ {
+ Pos = MAP_APPFONT ( 282 , 13 ) ;
+ Size = MAP_APPFONT ( 50 , 60 ) ;
+ DropDown = TRUE;
+ };
+ FixedText FT_AUTHOR
+ {
+ Pos = MAP_APPFONT ( 12 , 29 ) ;
+ Size = MAP_APPFONT ( 50 , 10 ) ;
+ };
+ ListBox LB_AUTHOR
+ {
+ Pos = MAP_APPFONT ( 65 , 28 ) ;
+ Size = MAP_APPFONT ( 50 , 60 ) ;
+ DropDown = TRUE;
+ };
+ FixedText FT_TITLE
+ {
+ Pos = MAP_APPFONT ( 118 , 29 ) ;
+ Size = MAP_APPFONT ( 50 , 10 ) ;
+ };
+ ListBox LB_TITLE
+ {
+ Pos = MAP_APPFONT ( 171 , 28 ) ;
+ Size = MAP_APPFONT ( 50 , 60 ) ;
+ DropDown = TRUE;
+ };
+ FixedText FT_PUBLISHER
+ {
+ Pos = MAP_APPFONT ( 12 , 44 ) ;
+ Size = MAP_APPFONT ( 50 , 10 ) ;
+ };
+ ListBox LB_PUBLISHER
+ {
+ Pos = MAP_APPFONT ( 65 , 43 ) ;
+ Size = MAP_APPFONT ( 50 , 60 ) ;
+ DropDown = TRUE;
+ };
+ FixedText FT_ADDRESS
+ {
+ Pos = MAP_APPFONT ( 118 , 44 ) ;
+ Size = MAP_APPFONT ( 50 , 10 ) ;
+ };
+ ListBox LB_ADDRESS
+ {
+ Pos = MAP_APPFONT ( 171, 43 ) ;
+ Size = MAP_APPFONT ( 50 , 60 ) ;
+ DropDown = TRUE;
+ };
+ FixedText FT_ISBN
+ {
+ Pos = MAP_APPFONT ( 229 , 44 ) ;
+ Size = MAP_APPFONT ( 50 , 10 ) ;
+ };
+ ListBox LB_ISBN
+ {
+ Pos = MAP_APPFONT ( 282 , 43 ) ;
+ Size = MAP_APPFONT ( 50 , 60 ) ;
+ DropDown = TRUE;
+ };
+ FixedText FT_CHAPTER
+ {
+ Pos = MAP_APPFONT ( 12 , 59 ) ;
+ Size = MAP_APPFONT ( 50 , 10 ) ;
+ };
+ ListBox LB_CHAPTER
+ {
+ Pos = MAP_APPFONT ( 65 , 58 ) ;
+ Size = MAP_APPFONT ( 50 , 60 ) ;
+ DropDown = TRUE;
+ };
+ FixedText FT_PAGES
+ {
+ Pos = MAP_APPFONT ( 118 , 59 ) ;
+ Size = MAP_APPFONT ( 50 , 10 ) ;
+ };
+ ListBox LB_PAGES
+ {
+ Pos = MAP_APPFONT ( 171, 58) ;
+ Size = MAP_APPFONT ( 50 , 60 ) ;
+ DropDown = TRUE;
+ };
+ FixedText FT_EDITOR
+ {
+ Pos = MAP_APPFONT ( 12 , 74 ) ;
+ Size = MAP_APPFONT ( 50 , 10 ) ;
+ };
+ ListBox LB_EDITOR
+ {
+ Pos = MAP_APPFONT ( 65 , 73 ) ;
+ Size = MAP_APPFONT ( 50 , 60 ) ;
+ DropDown = TRUE;
+ };
+ FixedText FT_EDITION
+ {
+ Pos = MAP_APPFONT ( 118 , 74 ) ;
+ Size = MAP_APPFONT ( 50 , 10 ) ;
+ };
+ ListBox LB_EDITION
+ {
+ Pos = MAP_APPFONT ( 171 , 73 ) ;
+ Size = MAP_APPFONT ( 50 , 60 ) ;
+ DropDown = TRUE;
+ };
+ FixedText FT_BOOKTITLE
+ {
+ Pos = MAP_APPFONT ( 12, 89 ) ;
+ Size = MAP_APPFONT ( 50 , 10 ) ;
+ };
+ ListBox LB_BOOKTITLE
+ {
+ Pos = MAP_APPFONT ( 65, 88 ) ;
+ Size = MAP_APPFONT ( 50 , 60 ) ;
+ DropDown = TRUE;
+ };
+ FixedText FT_VOLUME
+ {
+ Pos = MAP_APPFONT ( 118 , 89 ) ;
+ Size = MAP_APPFONT ( 50 , 10 ) ;
+ };
+ ListBox LB_VOLUME
+ {
+ Pos = MAP_APPFONT ( 171 , 88 ) ;
+ Size = MAP_APPFONT ( 50 , 60 ) ;
+ DropDown = TRUE;
+ };
+ FixedText FT_HOWPUBLISHED
+ {
+ Pos = MAP_APPFONT ( 229 , 89 ) ;
+ Size = MAP_APPFONT ( 50 , 10 ) ;
+ };
+ ListBox LB_HOWPUBLISHED
+ {
+ Pos = MAP_APPFONT ( 282, 88 ) ;
+ Size = MAP_APPFONT ( 50 , 60 ) ;
+ DropDown = TRUE;
+ };
+ FixedText FT_ORGANIZATIONS
+ {
+ Pos = MAP_APPFONT ( 12 , 104 ) ;
+ Size = MAP_APPFONT ( 50 , 10 ) ;
+ };
+ ListBox LB_ORGANIZATIONS
+ {
+ Pos = MAP_APPFONT ( 65 , 103 ) ;
+ Size = MAP_APPFONT ( 50 , 60 ) ;
+ DropDown = TRUE;
+ };
+ FixedText FT_INSTITUTION
+ {
+ Pos = MAP_APPFONT ( 118 , 104 ) ;
+ Size = MAP_APPFONT ( 50 , 10 ) ;
+ };
+ ListBox LB_INSTITUTION
+ {
+ Pos = MAP_APPFONT ( 171 , 103) ;
+ Size = MAP_APPFONT ( 50 , 60 ) ;
+ DropDown = TRUE;
+ };
+ FixedText FT_SCHOOL
+ {
+ Pos = MAP_APPFONT ( 229 , 104 ) ;
+ Size = MAP_APPFONT ( 50 , 10 ) ;
+ };
+ ListBox LB_SCHOOL
+ {
+ Pos = MAP_APPFONT ( 282 , 103 ) ;
+ Size = MAP_APPFONT ( 50 , 60 ) ;
+ DropDown = TRUE;
+ };
+ FixedText FT_REPORTTYPE
+ {
+ Pos = MAP_APPFONT ( 12 , 119 ) ;
+ Size = MAP_APPFONT ( 50 , 10 ) ;
+ };
+ ListBox LB_REPORTTYPE
+ {
+ Pos = MAP_APPFONT ( 65 , 118 ) ;
+ Size = MAP_APPFONT ( 50 , 60 ) ;
+ DropDown = TRUE;
+ };
+ FixedText FT_MONTH
+ {
+ Pos = MAP_APPFONT ( 118 , 119 ) ;
+ Size = MAP_APPFONT ( 50 , 10 ) ;
+ };
+ ListBox LB_MONTH
+ {
+ Pos = MAP_APPFONT ( 171 , 118) ;
+ Size = MAP_APPFONT ( 50 , 60 ) ;
+ DropDown = TRUE;
+ };
+ FixedText FT_JOURNAL
+ {
+ Pos = MAP_APPFONT ( 12 , 134 ) ;
+ Size = MAP_APPFONT ( 50 , 10 ) ;
+ };
+ ListBox LB_JOURNAL
+ {
+ Pos = MAP_APPFONT ( 65 , 133) ;
+ Size = MAP_APPFONT ( 50 , 60 ) ;
+ DropDown = TRUE;
+ };
+ FixedText FT_NUMBER
+ {
+ Pos = MAP_APPFONT ( 118 , 134 ) ;
+ Size = MAP_APPFONT ( 50 , 10 ) ;
+ };
+ ListBox LB_NUMBER
+ {
+ Pos = MAP_APPFONT ( 171 , 133 ) ;
+ Size = MAP_APPFONT ( 50 , 60 ) ;
+ DropDown = TRUE;
+ };
+ FixedText FT_SERIES
+ {
+ Pos = MAP_APPFONT ( 229 , 134 ) ;
+ Size = MAP_APPFONT ( 50 , 10 ) ;
+ };
+ ListBox LB_SERIES
+ {
+ Pos = MAP_APPFONT ( 282 , 133 ) ;
+ Size = MAP_APPFONT ( 50 , 60 ) ;
+ DropDown = TRUE;
+ };
+ FixedText FT_ANNOTE
+ {
+ Pos = MAP_APPFONT ( 12 , 149 ) ;
+ Size = MAP_APPFONT ( 50 , 10 ) ;
+ };
+ ListBox LB_ANNOTE
+ {
+ Pos = MAP_APPFONT ( 65 , 148 ) ;
+ Size = MAP_APPFONT ( 50 , 60 ) ;
+ DropDown = TRUE;
+ };
+ FixedText FT_NOTE
+ {
+ Pos = MAP_APPFONT ( 118 , 149 ) ;
+ Size = MAP_APPFONT ( 50 , 10 ) ;
+ };
+ ListBox LB_NOTE
+ {
+ Pos = MAP_APPFONT ( 171 , 148 ) ;
+ Size = MAP_APPFONT ( 50 , 60 ) ;
+ DropDown = TRUE;
+ };
+ FixedText FT_URL
+ {
+ Pos = MAP_APPFONT ( 229 , 149 ) ;
+ Size = MAP_APPFONT ( 50 , 10 ) ;
+ };
+ ListBox LB_URL
+ {
+ Pos = MAP_APPFONT ( 282, 148 ) ;
+ Size = MAP_APPFONT ( 50 , 60 ) ;
+ DropDown = TRUE;
+ };
+ FixedText FT_CUSTOM1
+ {
+ Pos = MAP_APPFONT ( 12 , 164 ) ;
+ Size = MAP_APPFONT ( 50 , 10 ) ;
+ };
+ ListBox LB_CUSTOM1
+ {
+ Pos = MAP_APPFONT ( 65 , 163 ) ;
+ Size = MAP_APPFONT ( 50 , 60 ) ;
+ DropDown = TRUE;
+ };
+ FixedText FT_CUSTOM2
+ {
+ Pos = MAP_APPFONT ( 118 , 164 ) ;
+ Size = MAP_APPFONT ( 50 , 10 ) ;
+ };
+ ListBox LB_CUSTOM2
+ {
+ Pos = MAP_APPFONT ( 171 , 163 ) ;
+ Size = MAP_APPFONT ( 50 , 60 ) ;
+ DropDown = TRUE;
+ };
+ FixedText FT_CUSTOM3
+ {
+ Pos = MAP_APPFONT ( 229, 164 ) ;
+ Size = MAP_APPFONT ( 50 , 10 ) ;
+ };
+ ListBox LB_CUSTOM3
+ {
+ Pos = MAP_APPFONT ( 282 , 163 ) ;
+ Size = MAP_APPFONT ( 50 , 60 ) ;
+ DropDown = TRUE;
+ };
+ FixedText FT_CUSTOM4
+ {
+ Pos = MAP_APPFONT ( 12 , 178 ) ;
+ Size = MAP_APPFONT ( 50 , 10 ) ;
+ };
+ ListBox LB_CUSTOM4
+ {
+ Pos = MAP_APPFONT ( 65 , 177 ) ;
+ Size = MAP_APPFONT ( 50 , 60 ) ;
+ DropDown = TRUE;
+ };
+ FixedText FT_CUSTOM5
+ {
+ Pos = MAP_APPFONT ( 118 , 178 ) ;
+ Size = MAP_APPFONT ( 50 , 10 ) ;
+ };
+ ListBox LB_CUSTOM5
+ {
+ Pos = MAP_APPFONT ( 171 , 177 ) ;
+ Size = MAP_APPFONT ( 50 , 60 ) ;
+ DropDown = TRUE;
+ };
+ String ST_NONE
+ {
+ Text [ en-US ] = "<none>";
+ };
+ Text [ en-US ] = "Column Layout for Table %1";
+};
+ModalDialog RID_DLG_DBCHANGE
+{
+ HelpID = HID_DLG_DBCHANGE;
+ OutputSize = TRUE ;
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( 291 , 131 ) ;
+ Moveable = TRUE ;
+ Text [ en-US ] = "Choose Data Source";
+ OKButton BT_OK
+ {
+ Pos = MAP_APPFONT ( 238 , 3 ) ;
+ Size = MAP_APPFONT ( 50 , 12 ) ;
+ };
+ CancelButton BT_CANCEL
+ {
+ Pos = MAP_APPFONT ( 238 , 18 ) ;
+ Size = MAP_APPFONT ( 50 , 12 ) ;
+ };
+ HelpButton BT_HELP
+ {
+ Pos = MAP_APPFONT ( 238 , 36 ) ;
+ Size = MAP_APPFONT ( 50 , 12 ) ;
+ };
+ FixedLine GB_SELECTION
+ {
+ Pos = MAP_APPFONT ( 6 , 3 ) ;
+ Size = MAP_APPFONT ( 229 , 8 ) ;
+ };
+ String ST_ENTRY
+ {
+ Text [ en-US ] = "Entry";
+ };
+ Control LB_SELECTION
+ {
+ Pos = MAP_APPFONT ( 9 , 24 ) ;
+ Size = MAP_APPFONT ( 223 , 100 ) ;
+ Border = TRUE;
+ TabStop = TRUE;
+ HelpId = HID_SELECTION_TLB;
+ };
+ Window HB_SELECTION
+ {
+ Pos = MAP_APPFONT ( 9 , 12 ) ;
+ Size = MAP_APPFONT ( 223 , 12 ) ;
+ Border = TRUE;
+ };
+};
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/extensions/source/bibliography/formcontrolcontainer.cxx b/extensions/source/bibliography/formcontrolcontainer.cxx
new file mode 100644
index 000000000000..22ee46485b04
--- /dev/null
+++ b/extensions/source/bibliography/formcontrolcontainer.cxx
@@ -0,0 +1,182 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+#include "formcontrolcontainer.hxx"
+#include <tools/debug.hxx>
+
+#include <algorithm>
+#include <functional>
+
+//.........................................................................
+namespace bib
+{
+//.........................................................................
+
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::form;
+ using namespace ::com::sun::star::lang;
+ using namespace ::com::sun::star::awt;
+
+ //=====================================================================
+ //= FormControlContainer
+ //=====================================================================
+ //---------------------------------------------------------------------
+ FormControlContainer::FormControlContainer( )
+ :OLoadListener( m_aMutex )
+ ,m_pFormAdapter( NULL )
+ {
+ }
+
+ //---------------------------------------------------------------------
+ //--- 18.10.01 18:54:57 -----------------------------------------------
+ FormControlContainer::~FormControlContainer( )
+ {
+ DBG_ASSERT( !isFormConnected(), "FormControlContainer::~FormControlContainer: you should disconnect in your derived class!" );
+ if ( isFormConnected() )
+ disconnectForm();
+ }
+
+ //---------------------------------------------------------------------
+ //--- 18.10.01 17:03:14 -----------------------------------------------
+ void FormControlContainer::disconnectForm()
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ DBG_ASSERT( isFormConnected(), "FormControlContainer::connectForm: not connected!" );
+ if ( isFormConnected() )
+ {
+ m_pFormAdapter->dispose();
+ m_pFormAdapter->release();
+ m_pFormAdapter = NULL;
+ }
+ }
+
+ //---------------------------------------------------------------------
+ //--- 18.10.01 16:56:01 -----------------------------------------------
+ void FormControlContainer::connectForm( const Reference< XLoadable >& _rxForm )
+ {
+ DBG_ASSERT( !isFormConnected(), "FormControlContainer::connectForm: already connected!" );
+
+ DBG_ASSERT( _rxForm.is(), "FormControlContainer::connectForm: invalid form!" );
+ if ( !isFormConnected() && _rxForm.is() )
+ {
+ m_pFormAdapter = new OLoadListenerAdapter( _rxForm );
+ m_pFormAdapter->acquire();
+ m_pFormAdapter->Init( this );
+
+ ensureDesignMode();
+ }
+
+ m_xForm = _rxForm;
+ }
+
+ //---------------------------------------------------------------------
+ //--- 18.10.01 18:50:14 -----------------------------------------------
+ struct ControlModeSwitch : public ::std::unary_function< Reference< XControl >, void >
+ {
+ sal_Bool bDesign;
+ ControlModeSwitch( sal_Bool _bDesign ) : bDesign( _bDesign ) { }
+
+ void operator() ( const Reference< XControl >& _rxControl ) const
+ {
+ if ( _rxControl.is() )
+ _rxControl->setDesignMode( bDesign );
+ }
+ };
+
+ //---------------------------------------------------------------------
+ //--- 18.10.01 18:49:57 -----------------------------------------------
+ void FormControlContainer::implSetDesignMode( sal_Bool _bDesign )
+ {
+ try
+ {
+ Reference< XControlContainer > xControlCont = getControlContainer();
+ Sequence< Reference< XControl > > aControls;
+ if ( xControlCont.is() )
+ aControls = xControlCont->getControls();
+
+ ::std::for_each(
+ aControls.getConstArray(),
+ aControls.getConstArray() + aControls.getLength(),
+ ControlModeSwitch( _bDesign )
+ );
+ }
+ catch( const Exception& e)
+ {
+ (void) e; // make compiler happy
+ DBG_ERROR( "FormControlContainer::implSetDesignMode: caught an exception!" );
+ }
+ }
+
+ //---------------------------------------------------------------------
+ //--- 18.10.01 18:16:54 -----------------------------------------------
+ void FormControlContainer::ensureDesignMode()
+ {
+ implSetDesignMode( !m_xForm.is() || !m_xForm->isLoaded() );
+ }
+
+ //---------------------------------------------------------------------
+ //--- 18.10.01 16:45:33 -----------------------------------------------
+ void FormControlContainer::_loaded( const ::com::sun::star::lang::EventObject& /*_rEvent*/ )
+ {
+ implSetDesignMode( sal_False );
+ }
+
+ //---------------------------------------------------------------------
+ //--- 18.10.01 16:45:35 -----------------------------------------------
+ void FormControlContainer::_unloading( const ::com::sun::star::lang::EventObject& /*_rEvent*/ )
+ {
+ implSetDesignMode( sal_True );
+ }
+
+ //---------------------------------------------------------------------
+ //--- 18.10.01 16:45:36 -----------------------------------------------
+ void FormControlContainer::_unloaded( const ::com::sun::star::lang::EventObject& /*_rEvent*/ )
+ {
+ }
+
+ //---------------------------------------------------------------------
+ //--- 18.10.01 16:45:36 -----------------------------------------------
+ void FormControlContainer::_reloading( const ::com::sun::star::lang::EventObject& /*_rEvent*/ )
+ {
+ implSetDesignMode( sal_True );
+ }
+
+ //---------------------------------------------------------------------
+ //--- 18.10.01 16:45:37 -----------------------------------------------
+ void FormControlContainer::_reloaded( const ::com::sun::star::lang::EventObject& /*_rEvent*/ )
+ {
+ implSetDesignMode( sal_False );
+ }
+
+//.........................................................................
+} // namespace bib
+//.........................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/bibliography/formcontrolcontainer.hxx b/extensions/source/bibliography/formcontrolcontainer.hxx
new file mode 100644
index 000000000000..a1e72b11a222
--- /dev/null
+++ b/extensions/source/bibliography/formcontrolcontainer.hxx
@@ -0,0 +1,86 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef EXTENSIONS_BIB_FORMCONTROLCONTAINER_HXX
+#define EXTENSIONS_BIB_FORMCONTROLCONTAINER_HXX
+
+#include <comphelper/broadcasthelper.hxx>
+#include "loadlisteneradapter.hxx"
+#include <com/sun/star/awt/XControlContainer.hpp>
+
+class BibDataManager;
+
+//.........................................................................
+namespace bib
+{
+//.........................................................................
+
+ //=====================================================================
+ //= FormControlContainer
+ //=====================================================================
+ class FormControlContainer
+ :public ::comphelper::OBaseMutex
+ ,public ::bib::OLoadListener
+ {
+ private:
+ OLoadListenerAdapter* m_pFormAdapter;
+ ::com::sun::star::uno::Reference< ::com::sun::star::form::XLoadable >
+ m_xForm;
+ private:
+ void implSetDesignMode( sal_Bool _bDesign );
+
+ protected:
+ FormControlContainer( );
+ ~FormControlContainer( );
+
+ sal_Bool isFormConnected() const { return NULL != m_pFormAdapter; }
+ void connectForm( const ::com::sun::star::uno::Reference< ::com::sun::star::form::XLoadable >& _rxForm );
+ void disconnectForm();
+
+ void ensureDesignMode();
+
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlContainer >
+ getControlContainer() = 0;
+
+ protected:
+ // XLoadListener equivalents
+ virtual void _loaded( const ::com::sun::star::lang::EventObject& _rEvent );
+ virtual void _unloading( const ::com::sun::star::lang::EventObject& _rEvent );
+ virtual void _unloaded( const ::com::sun::star::lang::EventObject& _rEvent );
+ virtual void _reloading( const ::com::sun::star::lang::EventObject& _rEvent );
+ virtual void _reloaded( const ::com::sun::star::lang::EventObject& _rEvent );
+
+ };
+
+//.........................................................................
+} // namespace bib
+//.........................................................................
+
+#endif // EXTENSIONS_BIB_FORMCONTROLCONTAINER_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/bibliography/framectr.cxx b/extensions/source/bibliography/framectr.cxx
new file mode 100644
index 000000000000..495362294602
--- /dev/null
+++ b/extensions/source/bibliography/framectr.cxx
@@ -0,0 +1,979 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+#include <vcl/waitobj.hxx>
+#include <cppuhelper/interfacecontainer.hxx>
+#include <com/sun/star/util/URL.hpp>
+#include <osl/mutex.hxx>
+#include <vcl/msgbox.hxx>
+#include <tools/debug.hxx>
+#include <vcl/stdtext.hxx>
+#include <comphelper/types.hxx>
+#include <comphelper/sequence.hxx>
+#include "framectr.hxx"
+#include "datman.hxx"
+#include "bibresid.hxx"
+#include "bib.hrc"
+#include <toolkit/helper/vclunohelper.hxx>
+#include "bibconfig.hxx"
+#include <cppuhelper/implbase1.hxx> // helper for implementations
+#include <vcl/svapp.hxx>
+#include "bibliography.hrc"
+#include <comphelper/processfactory.hxx>
+#include <com/sun/star/form/XConfirmDeleteListener.hpp>
+#include <com/sun/star/form/runtime/XFormController.hpp>
+#include <com/sun/star/beans/PropertyState.hpp>
+#include <com/sun/star/beans/PropertyValue.hpp>
+#include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
+#include <com/sun/star/sdbcx/Privilege.hpp>
+#include <com/sun/star/sdbc/XResultSetUpdate.hpp>
+#include <com/sun/star/sdb/RowChangeAction.hpp>
+#include <com/sun/star/frame/CommandGroup.hpp>
+#include <com/sun/star/datatransfer/clipboard/XClipboard.hpp>
+#include <sot/exchange.hxx>
+#include <sot/formats.hxx>
+#include <vcl/edit.hxx>
+#include <osl/mutex.hxx>
+
+#include <hash_map>
+
+using namespace osl;
+using namespace cppu;
+using namespace rtl;
+using namespace com::sun::star::sdbc;
+using namespace com::sun::star::frame;
+using namespace com::sun::star::uno;
+using namespace com::sun::star;
+
+#define C2U(cChar) OUString::createFromAscii(cChar)
+
+struct DispatchInfo
+{
+ const char* pCommand;
+ sal_Int16 nGroupId;
+ sal_Bool bActiveConnection;
+};
+
+struct CacheDispatchInfo
+{
+ sal_Int16 nGroupId;
+ sal_Bool bActiveConnection;
+};
+
+// Attention: commands must be sorted by command groups. Implementation is dependent
+// on this!!
+static DispatchInfo SupportedCommandsArray[] =
+{
+ { ".uno:Undo" , frame::CommandGroup::EDIT , sal_False },
+ { ".uno:Cut" , frame::CommandGroup::EDIT , sal_False },
+ { ".uno:Copy" , frame::CommandGroup::EDIT , sal_False },
+ { ".uno:Paste" , frame::CommandGroup::EDIT , sal_False },
+ { ".uno:SelectAll" , frame::CommandGroup::EDIT , sal_False },
+ { ".uno:CloseDoc" , frame::CommandGroup::DOCUMENT , sal_False },
+ { ".uno:StatusBarVisible" , frame::CommandGroup::VIEW , sal_False },
+ { ".uno:AvailableToolbars" , frame::CommandGroup::VIEW , sal_False },
+ { ".uno:Bib/standardFilter" , frame::CommandGroup::DATA , sal_True },
+ { ".uno:Bib/DeleteRecord" , frame::CommandGroup::DATA , sal_True },
+ { ".uno:Bib/InsertRecord" , frame::CommandGroup::DATA , sal_True },
+ { ".uno:Bib/query" , frame::CommandGroup::DATA , sal_True },
+ { ".uno:Bib/autoFilter" , frame::CommandGroup::DATA , sal_True },
+ { ".uno:Bib/source" , frame::CommandGroup::DATA , sal_True },
+ { ".uno:Bib/removeFilter" , frame::CommandGroup::DATA , sal_True },
+ { ".uno:Bib/sdbsource" , frame::CommandGroup::DATA , sal_True },
+ { ".uno:Bib/Mapping" , frame::CommandGroup::DATA , sal_True },
+ { 0 , 0 , sal_False }
+};
+
+typedef ::std::hash_map< ::rtl::OUString, CacheDispatchInfo, rtl::OUStringHash, ::std::equal_to< ::rtl::OUString > > CmdToInfoCache;
+
+SV_IMPL_PTRARR( BibStatusDispatchArr, BibStatusDispatchPtr );
+
+const CmdToInfoCache& GetCommandToInfoCache()
+{
+ static sal_Bool bCacheInitialized = sal_False;
+ static CmdToInfoCache aCmdToInfoCache;
+
+ if ( !bCacheInitialized )
+ {
+ ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
+ if ( !bCacheInitialized )
+ {
+ sal_Int32 i( 0 );
+ while ( SupportedCommandsArray[i].pCommand != 0 )
+ {
+ rtl::OUString aCommand( rtl::OUString::createFromAscii( SupportedCommandsArray[i].pCommand ));
+
+ CacheDispatchInfo aDispatchInfo;
+ aDispatchInfo.nGroupId = SupportedCommandsArray[i].nGroupId;
+ aDispatchInfo.bActiveConnection = SupportedCommandsArray[i].bActiveConnection;
+ aCmdToInfoCache.insert( CmdToInfoCache::value_type( aCommand, aDispatchInfo ));
+ ++i;
+ }
+ bCacheInitialized = sal_True;
+ }
+ }
+
+ return aCmdToInfoCache;
+}
+
+
+class BibFrameCtrl_Impl : public cppu::WeakImplHelper1 < XFrameActionListener >
+{
+public:
+ Mutex aMutex;
+ OMultiTypeInterfaceContainerHelper aLC;
+
+ BibFrameController_Impl* pController;
+
+ BibFrameCtrl_Impl()
+ : aLC( aMutex )
+ , pController(0)
+ {}
+
+ ~BibFrameCtrl_Impl();
+
+ virtual void SAL_CALL frameAction(const FrameActionEvent& aEvent) throw( RuntimeException );
+ virtual void SAL_CALL disposing( const lang::EventObject& Source ) throw (::com::sun::star::uno::RuntimeException);
+};
+
+
+BibFrameCtrl_Impl::~BibFrameCtrl_Impl()
+{
+}
+
+void BibFrameCtrl_Impl::frameAction(const FrameActionEvent& aEvent) throw( uno::RuntimeException )
+{
+ if ( pController && aEvent.Frame == pController->getFrame())
+ {
+ if(aEvent.Action == FrameAction_FRAME_ACTIVATED)
+ {
+ pController->activate();
+ }
+ else if(aEvent.Action == FrameAction_FRAME_DEACTIVATING)
+ {
+ pController->deactivate();
+ }
+ }
+}
+
+void BibFrameCtrl_Impl::disposing( const lang::EventObject& /*Source*/ )
+ throw (::com::sun::star::uno::RuntimeException)
+{
+ ::SolarMutexGuard aGuard;
+ if ( pController )
+ pController->getFrame()->removeFrameActionListener( this );
+}
+
+BibFrameController_Impl::BibFrameController_Impl( const uno::Reference< awt::XWindow > & xComponent,
+ BibDataManager* pDataManager)
+ :xWindow( xComponent )
+ ,m_xDatMan( pDataManager )
+ ,pDatMan( pDataManager )
+ ,pBibMod(NULL)
+{
+ Window* pParent = VCLUnoHelper::GetWindow( xWindow );
+ pParent->SetUniqueId(UID_BIB_FRAME_WINDOW);
+ bDisposing=sal_False;
+ bHierarchical=sal_True;
+ pImp = new BibFrameCtrl_Impl;
+ pImp->pController = this;
+ pImp->acquire();
+}
+
+BibFrameController_Impl::~BibFrameController_Impl()
+{
+ pImp->pController = NULL;
+ pImp->release();
+ delete pDatMan;
+ if(pBibMod)
+ CloseBibModul(pBibMod);
+}
+
+::rtl::OUString SAL_CALL BibFrameController_Impl::getImplementationName() throw (::com::sun::star::uno::RuntimeException)
+{
+ return ::rtl::OUString::createFromAscii("com.sun.star.comp.extensions.Bibliography");
+}
+
+sal_Bool SAL_CALL BibFrameController_Impl::supportsService( const ::rtl::OUString& sServiceName ) throw (::com::sun::star::uno::RuntimeException)
+{
+ return (
+ sServiceName.equalsAscii("com.sun.star.frame.Bibliography") ||
+ sServiceName.equalsAscii("com.sun.star.frame.Controller")
+ );
+}
+
+::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL BibFrameController_Impl::getSupportedServiceNames() throw (::com::sun::star::uno::RuntimeException)
+{
+ // return only top level services ...
+ // base services are included there and should be asked by uno-rtti.
+ ::com::sun::star::uno::Sequence< ::rtl::OUString > lNames(1);
+ lNames[0] = ::rtl::OUString::createFromAscii("com.sun.star.frame.Bibliography");
+ return lNames;
+}
+
+void BibFrameController_Impl::attachFrame( const uno::Reference< XFrame > & xArg ) throw (::com::sun::star::uno::RuntimeException)
+{
+ xFrame = xArg;
+ xFrame->addFrameActionListener( pImp );
+}
+
+sal_Bool BibFrameController_Impl::attachModel( const uno::Reference< XModel > & /*xModel*/ ) throw (::com::sun::star::uno::RuntimeException)
+{
+ return sal_False;
+}
+
+sal_Bool BibFrameController_Impl::suspend( sal_Bool bSuspend ) throw (::com::sun::star::uno::RuntimeException)
+{
+ if ( bSuspend )
+ getFrame()->removeFrameActionListener( pImp );
+ else
+ getFrame()->addFrameActionListener( pImp );
+ return sal_True;
+}
+
+uno::Any BibFrameController_Impl::getViewData() throw (::com::sun::star::uno::RuntimeException)
+{
+ return uno::Any();
+}
+
+void BibFrameController_Impl::restoreViewData( const uno::Any& /*Value*/ ) throw (::com::sun::star::uno::RuntimeException)
+{
+}
+
+uno::Reference< XFrame > BibFrameController_Impl::getFrame() throw (::com::sun::star::uno::RuntimeException)
+{
+ return xFrame;
+}
+
+uno::Reference< XModel > BibFrameController_Impl::getModel() throw (::com::sun::star::uno::RuntimeException)
+{
+ return uno::Reference< XModel > ();
+}
+
+void BibFrameController_Impl::dispose() throw (::com::sun::star::uno::RuntimeException)
+{
+ bDisposing = sal_True;
+ lang::EventObject aObject;
+ aObject.Source = (XController*)this;
+ pImp->aLC.disposeAndClear(aObject);
+ m_xDatMan = 0;
+ pDatMan = 0;
+ aStatusListeners.DeleteAndDestroy( 0, aStatusListeners.Count() );
+ }
+
+void BibFrameController_Impl::addEventListener( const uno::Reference< lang::XEventListener > & aListener ) throw (::com::sun::star::uno::RuntimeException)
+{
+ pImp->aLC.addInterface( ::getCppuType((const Reference< lang::XEventListener >*)0), aListener );
+}
+
+void BibFrameController_Impl::removeEventListener( const uno::Reference< lang::XEventListener > & aListener ) throw (::com::sun::star::uno::RuntimeException)
+{
+ pImp->aLC.removeInterface( ::getCppuType((const Reference< lang::XEventListener >*)0), aListener );
+}
+
+uno::Reference< frame::XDispatch > BibFrameController_Impl::queryDispatch( const util::URL& aURL, const rtl::OUString& /*aTarget*/, sal_Int32 /*nSearchFlags*/ ) throw (::com::sun::star::uno::RuntimeException)
+{
+ if ( !bDisposing )
+ {
+ const CmdToInfoCache& rCmdCache = GetCommandToInfoCache();
+ CmdToInfoCache::const_iterator pIter = rCmdCache.find( aURL.Complete );
+ if ( pIter != rCmdCache.end() )
+ {
+ if (( pDatMan->HasActiveConnection() ) ||
+ ( !pIter->second.bActiveConnection ))
+ return (frame::XDispatch*) this;
+ }
+ }
+
+ return uno::Reference< frame::XDispatch > ();
+}
+
+uno::Sequence<uno::Reference< XDispatch > > BibFrameController_Impl::queryDispatches( const uno::Sequence<DispatchDescriptor>& aDescripts ) throw (::com::sun::star::uno::RuntimeException)
+{
+ uno::Sequence< uno::Reference< XDispatch > > aDispatches( aDescripts.getLength() );
+ for ( sal_Int32 i=0; i<aDescripts.getLength(); ++i )
+ aDispatches[i] = queryDispatch( aDescripts[i].FeatureURL, aDescripts[i].FrameName, aDescripts[i].SearchFlags );
+ return aDispatches;
+}
+
+uno::Sequence< ::sal_Int16 > SAL_CALL BibFrameController_Impl::getSupportedCommandGroups()
+throw (::com::sun::star::uno::RuntimeException)
+{
+ uno::Sequence< ::sal_Int16 > aDispatchInfo( 4 );
+
+ aDispatchInfo[0] = frame::CommandGroup::EDIT;
+ aDispatchInfo[1] = frame::CommandGroup::DOCUMENT;
+ aDispatchInfo[2] = frame::CommandGroup::DATA;
+ aDispatchInfo[3] = frame::CommandGroup::VIEW;
+
+ return aDispatchInfo;
+}
+
+uno::Sequence< frame::DispatchInformation > SAL_CALL BibFrameController_Impl::getConfigurableDispatchInformation( ::sal_Int16 nCommandGroup )
+throw (::com::sun::star::uno::RuntimeException)
+{
+ const CmdToInfoCache& rCmdCache = GetCommandToInfoCache();
+
+ sal_Bool bGroupFound( sal_False );
+ frame::DispatchInformation aDispatchInfo;
+ std::list< frame::DispatchInformation > aDispatchInfoList;
+
+ if (( nCommandGroup == frame::CommandGroup::EDIT ) ||
+ ( nCommandGroup == frame::CommandGroup::DOCUMENT ) ||
+ ( nCommandGroup == frame::CommandGroup::DATA ) ||
+ ( nCommandGroup == frame::CommandGroup::VIEW ))
+ {
+ CmdToInfoCache::const_iterator pIter = rCmdCache.begin();
+ while ( pIter != rCmdCache.end() )
+ {
+ if ( pIter->second.nGroupId == nCommandGroup )
+ {
+ bGroupFound = sal_True;
+ aDispatchInfo.Command = pIter->first;
+ aDispatchInfo.GroupId = pIter->second.nGroupId;
+ aDispatchInfoList.push_back( aDispatchInfo );
+ }
+ else if ( bGroupFound )
+ break;
+
+ ++pIter;
+ }
+ }
+
+ ::com::sun::star::uno::Sequence< ::com::sun::star::frame::DispatchInformation > aSeq =
+ comphelper::containerToSequence< ::com::sun::star::frame::DispatchInformation, std::list< ::com::sun::star::frame::DispatchInformation > >( aDispatchInfoList );
+
+ return aSeq;
+}
+
+sal_Bool canInsertRecords(const Reference< beans::XPropertySet>& _rxCursorSet)
+{
+ sal_Int32 nPriv = 0;
+ _rxCursorSet->getPropertyValue(C2U("Privileges")) >>= nPriv;
+ return ((_rxCursorSet.is() && (nPriv & sdbcx::Privilege::INSERT) != 0));
+}
+/* -----------------------------08.05.2002 08:58------------------------------
+
+ ---------------------------------------------------------------------------*/
+sal_Bool BibFrameController_Impl::SaveModified(const Reference< form::runtime::XFormController>& xController)
+{
+ if (!xController.is())
+ return sal_False;
+ sal_Bool bInserted = sal_False;
+
+ Reference< XResultSetUpdate> _xCursor = Reference< XResultSetUpdate>(xController->getModel(), UNO_QUERY);
+
+ if (!_xCursor.is())
+ return sal_False;
+
+ Reference< beans::XPropertySet> _xSet = Reference< beans::XPropertySet>(_xCursor, UNO_QUERY);
+ if (!_xSet.is())
+ return sal_False;
+
+ // muß gespeichert werden ?
+ sal_Bool bIsNew = ::comphelper::getBOOL(_xSet->getPropertyValue(C2U("IsNew")));
+ sal_Bool bIsModified = ::comphelper::getBOOL(_xSet->getPropertyValue(C2U("IsModified")));
+ sal_Bool bResult = !bIsModified;
+ if (bIsModified)
+ {
+ try
+ {
+ if (bIsNew)
+ _xCursor->insertRow();
+ else
+ _xCursor->updateRow();
+ bResult = sal_True;
+ }
+ catch(Exception&)
+ {
+ DBG_ERROR("SaveModified: Exception occured!");
+ }
+
+ bInserted = bIsNew && bResult;
+ }
+ return bResult;
+}
+
+Window* lcl_GetFocusChild( Window* pParent )
+{
+ USHORT nChildren = pParent->GetChildCount();
+ for( USHORT nChild = 0; nChild < nChildren; ++nChild)
+ {
+ Window* pChild = pParent->GetChild( nChild );
+ if(pChild->HasFocus())
+ return pChild;
+ Window* pSubChild = lcl_GetFocusChild( pChild );
+ if(pSubChild)
+ return pSubChild;
+ }
+ return 0;
+}
+
+//class XDispatch
+void BibFrameController_Impl::dispatch(const util::URL& _rURL, const uno::Sequence< beans::PropertyValue >& aArgs) throw (::com::sun::star::uno::RuntimeException)
+{
+ if ( !bDisposing )
+ {
+ ::SolarMutexGuard aGuard;
+ Window* pParent = VCLUnoHelper::GetWindow( xWindow );
+ WaitObject aWaitObject( pParent );
+
+ String aCommand( _rURL.Path);
+ if(aCommand.EqualsAscii("Bib/Mapping"))
+ {
+ pDatMan->CreateMappingDialog(pParent);
+ }
+ else if(aCommand.EqualsAscii("Bib/source"))
+ {
+ ChangeDataSource(aArgs);
+ }
+ else if(aCommand.EqualsAscii("Bib/sdbsource"))
+ {
+ rtl::OUString aURL = pDatMan->CreateDBChangeDialog(pParent);
+ if(aURL.getLength())
+ {
+ try
+ {
+ uno::Sequence< beans::PropertyValue > aNewDataSource(2);
+ beans::PropertyValue* pProps = aNewDataSource.getArray();
+ pProps[0].Value <<= rtl::OUString();
+ pProps[1].Value <<= aURL;
+ ChangeDataSource(aNewDataSource);
+ }
+ catch(const Exception&)
+ {
+ DBG_ERROR("Exception catched while changing the data source");
+ }
+ }
+ }
+ else if(aCommand.EqualsAscii("Bib/autoFilter"))
+ {
+ sal_uInt16 nCount = aStatusListeners.Count();
+ for ( sal_uInt16 n=0; n<nCount; n++ )
+ {
+ BibStatusDispatch *pObj = aStatusListeners[n];
+ if ( pObj->aURL.Path == C2U("Bib/removeFilter") )
+ {
+ FeatureStateEvent aEvent;
+ aEvent.FeatureURL = pObj->aURL;
+ aEvent.IsEnabled = sal_True;
+ aEvent.Requery = sal_False;
+ aEvent.Source = (XDispatch *) this;
+ pObj->xListener->statusChanged( aEvent );
+ //break; because there are more than one
+ }
+ }
+
+ const beans::PropertyValue* pPropertyValue = aArgs.getConstArray();
+ uno::Any aValue=pPropertyValue[0].Value;
+ rtl::OUString aQuery;
+ aValue >>= aQuery;
+
+ aValue=pPropertyValue[1].Value;
+ rtl::OUString aQueryField;
+ aValue >>= aQueryField;
+ BibConfig* pConfig = BibModul::GetConfig();
+ pConfig->setQueryField(aQueryField);
+ pDatMan->startQueryWith(aQuery);
+ }
+ else if(aCommand.EqualsAscii("Bib/standardFilter"))
+ {
+ try
+ {
+ uno::Reference< lang::XMultiServiceFactory > xORB = ::comphelper::getProcessServiceFactory();
+
+ // build the arguments for the filter dialog to be created
+ Sequence< Any > aDialogCreationArgs( 3 );
+ Any* pDialogCreationArgs = aDialogCreationArgs.getArray();
+ // the query composer
+ *pDialogCreationArgs++ <<= beans::PropertyValue( ::rtl::OUString::createFromAscii( "QueryComposer" ),
+ -1,
+ makeAny( pDatMan->getParser() ),
+ beans::PropertyState_DIRECT_VALUE
+ );
+
+ // the rowset
+ *pDialogCreationArgs++ <<= beans::PropertyValue( ::rtl::OUString::createFromAscii( "RowSet" ),
+ -1,
+ makeAny( pDatMan->getForm() ),
+ beans::PropertyState_DIRECT_VALUE
+ );
+ // the parent window for the dialog
+ *pDialogCreationArgs++ <<= beans::PropertyValue( ::rtl::OUString::createFromAscii( "ParentWindow" ),
+ -1,
+ makeAny( xWindow ),
+ beans::PropertyState_DIRECT_VALUE
+ );
+
+ // create the dialog object
+ const ::rtl::OUString sDialogServiceName = ::rtl::OUString::createFromAscii( "com.sun.star.sdb.FilterDialog" );
+ uno::Reference< uno::XInterface > xDialog = xORB->createInstanceWithArguments(
+ sDialogServiceName,
+ aDialogCreationArgs
+ );
+ if ( !xDialog.is() )
+ {
+ ShowServiceNotAvailableError( VCLUnoHelper::GetWindow( xWindow ), sDialogServiceName, sal_True );
+ }
+ else
+ {
+ // execute it
+ uno::Reference< ui::dialogs::XExecutableDialog > xExec( xDialog, UNO_QUERY );
+ DBG_ASSERT( xExec.is(), "BibFrameController_Impl::dispatch: missing an interface on the dialog!" );
+ if ( xExec.is() )
+ if ( xExec->execute( ) )
+ {
+ // the dialog has been executed successfully, and the filter on the query composer
+ // has been changed
+ ::rtl::OUString sNewFilter = pDatMan->getParser()->getFilter();
+ pDatMan->setFilter( sNewFilter );
+ }
+ }
+ }
+ catch( const uno::Exception& )
+ {
+ DBG_ERROR( "BibFrameController_Impl::dispatch: caught an exception!" );
+ }
+
+ sal_uInt16 nCount = aStatusListeners.Count();
+ for ( sal_uInt16 n=0; n<nCount; n++ )
+ {
+ BibStatusDispatch *pObj = aStatusListeners[n];
+ if ( pObj->aURL.Path == C2U("Bib/removeFilter") && pDatMan->getParser().is())
+ {
+ FeatureStateEvent aEvent;
+ aEvent.FeatureURL = pObj->aURL;
+ aEvent.IsEnabled = 0 != pDatMan->getParser()->getFilter().getLength();
+ aEvent.Requery = sal_False;
+ aEvent.Source = (XDispatch *) this;
+ pObj->xListener->statusChanged( aEvent );
+ }
+ }
+ }
+ else if(aCommand.EqualsAscii("Bib/removeFilter"))
+ {
+ RemoveFilter();
+ }
+ else if(_rURL.Complete.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("slot:5503")) ||
+ aCommand.EqualsAscii("CloseDoc"))
+ {
+ Application::PostUserEvent( STATIC_LINK( this, BibFrameController_Impl,
+ DisposeHdl ), 0 );
+
+ }
+ else if(aCommand.EqualsAscii("Bib/InsertRecord"))
+ {
+ Reference<form::runtime::XFormController > xFormCtrl = pDatMan->GetFormController();
+ if(SaveModified(xFormCtrl))
+ {
+ try
+ {
+ Reference< sdbc::XResultSet > xCursor( pDatMan->getForm(), UNO_QUERY );
+ xCursor->last();
+
+ Reference< XResultSetUpdate > xUpdateCursor( pDatMan->getForm(), UNO_QUERY );
+ xUpdateCursor->moveToInsertRow();
+ }
+ catch(Exception&)
+ {
+ DBG_ERROR("Exception in last() or moveToInsertRow()");
+ }
+ }
+ }
+ else if(aCommand.EqualsAscii("Bib/DeleteRecord"))
+ {
+ Reference< ::com::sun::star::sdbc::XResultSet > xCursor(pDatMan->getForm(), UNO_QUERY);
+ Reference< XResultSetUpdate > xUpdateCursor(xCursor, UNO_QUERY);
+ Reference< beans::XPropertySet > xSet(pDatMan->getForm(), UNO_QUERY);
+ sal_Bool bIsNew = ::comphelper::getBOOL(xSet->getPropertyValue(C2U("IsNew")));
+ if(!bIsNew)
+ {
+ sal_uInt32 nCount = 0;
+ xSet->getPropertyValue(C2U("RowCount")) >>= nCount;
+ // naechste position festellen
+ sal_Bool bSuccess = sal_False;
+ sal_Bool bLeft = sal_False;
+ sal_Bool bRight = sal_False;
+ try
+ {
+ bLeft = xCursor->isLast() && nCount > 1;
+ bRight= !xCursor->isLast();
+ // ask for confirmation
+ Reference< frame::XController > xCtrl = pImp->pController;
+ Reference< form::XConfirmDeleteListener > xConfirm(pDatMan->GetFormController(),UNO_QUERY);
+ if (xConfirm.is())
+ {
+ sdb::RowChangeEvent aEvent;
+ aEvent.Source = Reference< XInterface > (xCursor, UNO_QUERY);
+ aEvent.Action = sdb::RowChangeAction::DELETE;
+ aEvent.Rows = 1;
+ bSuccess = xConfirm->confirmDelete(aEvent);
+ }
+
+ // das Ding loeschen
+ if (bSuccess)
+ xUpdateCursor->deleteRow();
+ }
+ catch(Exception&)
+ {
+ bSuccess = sal_False;
+ }
+ if (bSuccess)
+ {
+ if (bLeft || bRight)
+ xCursor->relative(bRight ? 1 : -1);
+ else
+ {
+ sal_Bool bCanInsert = canInsertRecords(xSet);
+ // kann noch ein Datensatz eingefuegt weden
+ try
+ {
+ if (bCanInsert)
+ xUpdateCursor->moveToInsertRow();
+ else
+ // Datensatz bewegen um Stati neu zu setzen
+ xCursor->first();
+ }
+ catch(Exception&)
+ {
+ DBG_ERROR("DeleteRecord : exception caught !");
+ }
+ }
+ }
+ }
+ }
+ else if(aCommand.EqualsAscii("Cut"))
+ {
+ Window* pChild = lcl_GetFocusChild( VCLUnoHelper::GetWindow( xWindow ) );
+ if(pChild)
+ {
+ KeyEvent aEvent( 0, KEYFUNC_CUT );
+ pChild->KeyInput( aEvent );
+ }
+ }
+ else if(aCommand.EqualsAscii("Copy"))
+ {
+ Window* pChild = lcl_GetFocusChild( VCLUnoHelper::GetWindow( xWindow ) );
+ if(pChild)
+ {
+ KeyEvent aEvent( 0, KEYFUNC_COPY );
+ pChild->KeyInput( aEvent );
+ }
+ }
+ else if(aCommand.EqualsAscii("Paste"))
+ {
+ Window* pChild = lcl_GetFocusChild( VCLUnoHelper::GetWindow( xWindow ) );
+ if(pChild)
+ {
+ KeyEvent aEvent( 0, KEYFUNC_PASTE );
+ pChild->KeyInput( aEvent );
+ }
+ }
+ }
+}
+IMPL_STATIC_LINK( BibFrameController_Impl, DisposeHdl, void*, EMPTYARG )
+{
+ pThis->xFrame->dispose();
+ return 0;
+};
+
+//-----------------------------------------------------------------------------
+void BibFrameController_Impl::addStatusListener(
+ const uno::Reference< frame::XStatusListener > & aListener,
+ const util::URL& aURL)
+ throw (::com::sun::star::uno::RuntimeException)
+{
+ BibConfig* pConfig = BibModul::GetConfig();
+ // create a new Reference and insert into listener array
+ aStatusListeners.Insert( new BibStatusDispatch( aURL, aListener ), aStatusListeners.Count() );
+
+ // den ersten Status synchron zusenden
+ FeatureStateEvent aEvent;
+ aEvent.FeatureURL = aURL;
+ aEvent.Requery = sal_False;
+ aEvent.Source = (XDispatch *) this;
+ if ( aURL.Path == C2U("StatusBarVisible") )
+ {
+ aEvent.IsEnabled = sal_False;
+ aEvent.State <<= sal_Bool( sal_False );
+ }
+ else if ( aURL.Path == C2U("Bib/hierarchical") )
+ {
+ aEvent.IsEnabled = sal_True;
+ const char* pHier = bHierarchical? "" : "*" ;
+ aEvent.State <<= rtl::OUString::createFromAscii(pHier);
+ }
+ else if(aURL.Path == C2U("Bib/MenuFilter"))
+ {
+ aEvent.IsEnabled = sal_True;
+ aEvent.FeatureDescriptor=pDatMan->getQueryField();
+
+ uno::Sequence<rtl::OUString> aStringSeq=pDatMan->getQueryFields();
+ aEvent.State.setValue(&aStringSeq,::getCppuType((uno::Sequence<rtl::OUString>*)0));
+
+ }
+ else if ( aURL.Path == C2U("Bib/source"))
+ {
+ aEvent.IsEnabled = sal_True;
+ aEvent.FeatureDescriptor=pDatMan->getActiveDataTable();
+
+ uno::Sequence<rtl::OUString> aStringSeq=pDatMan->getDataSources();
+ aEvent.State.setValue(&aStringSeq,::getCppuType((uno::Sequence<rtl::OUString>*)0));
+ }
+ else if(aURL.Path == C2U("Bib/sdbsource") ||
+ aURL.Path == C2U("Bib/Mapping") ||
+ aURL.Path == C2U("Bib/autoFilter") ||
+ aURL.Path.equalsAscii("Bib/standardFilter"))
+ {
+ aEvent.IsEnabled = sal_True;
+ }
+ else if(aURL.Path == C2U("Bib/query"))
+ {
+ aEvent.IsEnabled = sal_True;
+ aEvent.State <<= pConfig->getQueryText();
+ }
+ else if (aURL.Path == C2U("Bib/removeFilter") )
+ {
+ rtl::OUString aFilterStr=pDatMan->getFilter();
+ aEvent.IsEnabled = (aFilterStr.getLength() > 0);
+ }
+ else if(aURL.Path == C2U("Cut"))
+ {
+ Window* pChild = lcl_GetFocusChild( VCLUnoHelper::GetWindow( xWindow ) );
+ Edit* pEdit = dynamic_cast<Edit*>( pChild );
+ if( pEdit )
+ aEvent.IsEnabled = !pEdit->IsReadOnly() && pEdit->GetSelection().Len();
+ }
+ if(aURL.Path == C2U("Copy"))
+ {
+ Window* pChild = lcl_GetFocusChild( VCLUnoHelper::GetWindow( xWindow ) );
+ Edit* pEdit = dynamic_cast<Edit*>( pChild );
+ if( pEdit )
+ aEvent.IsEnabled = pEdit->GetSelection().Len() > 0;
+ }
+ else if(aURL.Path == C2U("Paste") )
+ {
+ aEvent.IsEnabled = sal_False;
+ Window* pChild = lcl_GetFocusChild( VCLUnoHelper::GetWindow( xWindow ) );
+ if(pChild)
+ {
+ uno::Reference< datatransfer::clipboard::XClipboard > xClip = pChild->GetClipboard();
+ if(xClip.is())
+ {
+ uno::Reference< datatransfer::XTransferable > xDataObj;
+ const sal_uInt32 nRef = Application::ReleaseSolarMutex();
+ try
+ {
+ xDataObj = xClip->getContents();
+ }
+ catch( const uno::Exception& )
+ {
+ }
+ Application::AcquireSolarMutex( nRef );
+
+ if ( xDataObj.is() )
+ {
+ datatransfer::DataFlavor aFlavor;
+ SotExchange::GetFormatDataFlavor( SOT_FORMAT_STRING, aFlavor );
+ try
+ {
+ uno::Any aData = xDataObj->getTransferData( aFlavor );
+ ::rtl::OUString aText;
+ aData >>= aText;
+ aEvent.IsEnabled = aText.getLength() > 0;
+ }
+ catch( const uno::Exception& )
+ {
+ }
+ }
+ }
+ uno::Reference< datatransfer::XTransferable > xContents = xClip->getContents( );
+ }
+ }
+ else if(aURL.Path == C2U("Bib/DeleteRecord"))
+ {
+ Reference< ::com::sun::star::sdbc::XResultSet > xCursor(pDatMan->getForm(), UNO_QUERY);
+ Reference< XResultSetUpdate > xUpdateCursor(xCursor, UNO_QUERY);
+ Reference< beans::XPropertySet > xSet(pDatMan->getForm(), UNO_QUERY);
+ sal_Bool bIsNew = ::comphelper::getBOOL(xSet->getPropertyValue(C2U("IsNew")));
+ if(!bIsNew)
+ {
+ sal_uInt32 nCount = 0;
+ xSet->getPropertyValue(C2U("RowCount")) >>= nCount;
+ aEvent.IsEnabled = nCount > 0;
+ }
+ }
+ else if (aURL.Path == C2U("Bib/InsertRecord"))
+ {
+ Reference< beans::XPropertySet > xSet(pDatMan->getForm(), UNO_QUERY);
+ aEvent.IsEnabled = canInsertRecords(xSet);
+ }
+ aListener->statusChanged( aEvent );
+}
+//-----------------------------------------------------------------------------
+void BibFrameController_Impl::removeStatusListener(
+ const uno::Reference< frame::XStatusListener > & aObject, const util::URL& aURL)
+ throw (::com::sun::star::uno::RuntimeException)
+{
+ // search listener array for given listener
+ // for checking equality always "cast" to XInterface
+ if ( !bDisposing )
+ {
+ sal_uInt16 nCount = aStatusListeners.Count();
+ for ( sal_uInt16 n=0; n<nCount; n++ )
+ {
+ BibStatusDispatch *pObj = aStatusListeners[n];
+ sal_Bool bFlag=pObj->xListener.is();
+ if (!bFlag || (pObj->xListener == aObject &&
+ ( !aURL.Complete.getLength() || pObj->aURL.Path == aURL.Path )))
+ {
+ aStatusListeners.DeleteAndDestroy( n );
+ break;
+ }
+ }
+ }
+}
+//-----------------------------------------------------------------------------
+void BibFrameController_Impl::RemoveFilter()
+{
+ rtl::OUString aQuery;
+ pDatMan->startQueryWith(aQuery);
+
+ sal_uInt16 nCount = aStatusListeners.Count();
+
+ sal_Bool bRemoveFilter=sal_False;
+ sal_Bool bQueryText=sal_False;
+
+ for ( sal_uInt16 n=0; n<nCount; n++ )
+ {
+ BibStatusDispatch *pObj = aStatusListeners[n];
+ if ( pObj->aURL.Path == C2U("Bib/removeFilter") )
+ {
+ FeatureStateEvent aEvent;
+ aEvent.FeatureURL = pObj->aURL;
+ aEvent.IsEnabled = sal_False;
+ aEvent.Requery = sal_False;
+ aEvent.Source = (XDispatch *) this;
+ pObj->xListener->statusChanged( aEvent );
+ bRemoveFilter=sal_True;
+ }
+ else if(pObj->aURL.Path == C2U("Bib/query"))
+ {
+ FeatureStateEvent aEvent;
+ aEvent.FeatureURL = pObj->aURL;
+ aEvent.IsEnabled = sal_True;
+ aEvent.Requery = sal_False;
+ aEvent.Source = (XDispatch *) this;
+ aEvent.State <<= aQuery;
+ pObj->xListener->statusChanged( aEvent );
+ bQueryText=sal_True;
+ }
+
+ if(bRemoveFilter && bQueryText)
+ break;
+
+ }
+}
+//-----------------------------------------------------------------------------
+void BibFrameController_Impl::ChangeDataSource(const uno::Sequence< beans::PropertyValue >& aArgs)
+{
+ const beans::PropertyValue* pPropertyValue = aArgs.getConstArray();
+ uno::Any aValue=pPropertyValue[0].Value;
+ rtl::OUString aDBTableName;
+ aValue >>= aDBTableName;
+
+
+ if(aArgs.getLength() > 1)
+ {
+ uno::Any aDB = pPropertyValue[1].Value;
+ rtl::OUString aURL;
+ aDB >>= aURL;
+ pDatMan->setActiveDataSource(aURL);
+ aDBTableName = pDatMan->getActiveDataTable();
+ }
+ else
+ {
+ m_xDatMan->unload();
+ pDatMan->setActiveDataTable(aDBTableName);
+ pDatMan->updateGridModel();
+ m_xDatMan->load();
+ }
+
+
+ sal_uInt16 nCount = aStatusListeners.Count();
+
+ sal_Bool bMenuFilter=sal_False;
+ sal_Bool bQueryText=sal_False;
+ for ( sal_uInt16 n=0; n<nCount; n++ )
+ {
+ BibStatusDispatch *pObj = aStatusListeners[n];
+ if(COMPARE_EQUAL == pObj->aURL.Path.compareToAscii("Bib/MenuFilter"))
+ {
+ FeatureStateEvent aEvent;
+ aEvent.FeatureURL = pObj->aURL;
+ aEvent.IsEnabled = sal_True;
+ aEvent.Requery = sal_False;
+ aEvent.Source = (XDispatch *) this;
+ aEvent.FeatureDescriptor=pDatMan->getQueryField();
+
+ uno::Sequence<rtl::OUString> aStringSeq=pDatMan->getQueryFields();
+ aEvent.State = makeAny( aStringSeq );
+
+ pObj->xListener->statusChanged( aEvent );
+ bMenuFilter=sal_True;
+ }
+ else if(COMPARE_EQUAL == pObj->aURL.Path.compareToAscii("Bib/query"))
+ {
+ FeatureStateEvent aEvent;
+ aEvent.FeatureURL = pObj->aURL;
+ aEvent.IsEnabled = sal_True;
+ aEvent.Requery = sal_False;
+ aEvent.Source = (XDispatch *) this;
+ BibConfig* pConfig = BibModul::GetConfig();
+ aEvent.State <<= pConfig->getQueryText();
+ pObj->xListener->statusChanged( aEvent );
+ bQueryText=sal_True;
+ }
+
+ if (bMenuFilter && bQueryText)
+ break;
+
+ }
+}
+
+void BibFrameController_Impl::activate()
+{
+}
+void BibFrameController_Impl::deactivate()
+{
+}
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/bibliography/framectr.hxx b/extensions/source/bibliography/framectr.hxx
new file mode 100644
index 000000000000..4ef00f967fed
--- /dev/null
+++ b/extensions/source/bibliography/framectr.hxx
@@ -0,0 +1,132 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _BIB_FRAMECTR_HXX
+#define _BIB_FRAMECTR_HXX
+#include <com/sun/star/beans/XPropertyChangeListener.hpp>
+#include <com/sun/star/frame/XDispatchProvider.hpp>
+#include <com/sun/star/frame/XController.hpp>
+#include <com/sun/star/frame/XDispatch.hpp>
+#include <com/sun/star/form/XLoadable.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/frame/XDispatchInformationProvider.hpp>
+#include <cppuhelper/implbase5.hxx>
+#include <svl/svarray.hxx>
+
+#include "bibmod.hxx"
+class BibDataManager;
+class BibFrameCtrl_Impl;
+namespace com{namespace sun{namespace star{
+ namespace form { namespace runtime {
+ class XFormController;
+ } }
+}}}
+class BibStatusDispatch
+{
+public:
+ ::com::sun::star::util::URL aURL;
+ ::com::sun::star::uno::Reference< ::com::sun::star::frame::XStatusListener > xListener;
+ BibStatusDispatch( const ::com::sun::star::util::URL& rURL, const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XStatusListener > xRef )
+ : aURL( rURL )
+ , xListener( xRef )
+ {}
+};
+
+typedef BibStatusDispatch* BibStatusDispatchPtr;
+SV_DECL_PTRARR_DEL( BibStatusDispatchArr, BibStatusDispatchPtr, 4, 4 )
+
+class BibFrameController_Impl : public cppu::WeakImplHelper5 <
+ ::com::sun::star::lang::XServiceInfo,
+ ::com::sun::star::frame::XController,
+ ::com::sun::star::frame::XDispatch,
+ ::com::sun::star::frame::XDispatchProvider,
+ ::com::sun::star::frame::XDispatchInformationProvider
+>
+{
+friend class BibFrameCtrl_Impl;
+ BibFrameCtrl_Impl* pImp;
+ BibStatusDispatchArr aStatusListeners;
+ ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > xWindow;
+ ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > xFrame;
+ sal_Bool bDisposing;
+ sal_Bool bHierarchical;
+ ::com::sun::star::uno::Reference< ::com::sun::star::form::XLoadable > m_xDatMan;
+ BibDataManager* pDatMan;
+ HdlBibModul pBibMod;
+
+ DECL_STATIC_LINK( BibFrameController_Impl, DisposeHdl, void* );
+
+ sal_Bool SaveModified(const ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController>& xController);
+public:
+ BibFrameController_Impl( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > & xComponent,
+ BibDataManager* pDatMan);
+ ~BibFrameController_Impl();
+
+
+ void activate();
+ void deactivate();
+
+ void ChangeDataSource(const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& aArgs);
+ void RemoveFilter();
+
+ // ::com::sun::star::lang::XServiceInfo
+ virtual ::rtl::OUString SAL_CALL getImplementationName() throw (::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& sServiceName ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() throw (::com::sun::star::uno::RuntimeException);
+
+ // ::com::sun::star::frame::XController
+ virtual void SAL_CALL attachFrame( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > & xFrame ) throw (::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL attachModel( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > & xModel ) throw (::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL suspend( sal_Bool bSuspend ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Any SAL_CALL getViewData() throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL restoreViewData( const ::com::sun::star::uno::Any& Value ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > SAL_CALL getFrame() throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > SAL_CALL getModel() throw (::com::sun::star::uno::RuntimeException);
+
+ // ::com::sun::star::lang::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);
+
+ // ::com::sun::star::frame::XDispatchProvider
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch > SAL_CALL queryDispatch( const ::com::sun::star::util::URL& aURL, const rtl::OUString& aTargetFrameName, sal_Int32 nSearchFlags) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch > > SAL_CALL queryDispatches( const ::com::sun::star::uno::Sequence< ::com::sun::star::frame::DispatchDescriptor >& aDescripts) throw (::com::sun::star::uno::RuntimeException);
+
+ //class ::com::sun::star::frame::XDispatch
+ virtual void SAL_CALL dispatch(const ::com::sun::star::util::URL& aURL, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& aArgs) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL addStatusListener(const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XStatusListener > & xControl, const ::com::sun::star::util::URL& aURL) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL removeStatusListener(const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XStatusListener > & xControl, const ::com::sun::star::util::URL& aURL) throw (::com::sun::star::uno::RuntimeException);
+
+ // ::com::sun::star::frame::XDispatchInformationProvider
+ virtual ::com::sun::star::uno::Sequence< ::sal_Int16 > SAL_CALL getSupportedCommandGroups( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::frame::DispatchInformation > SAL_CALL getConfigurableDispatchInformation( ::sal_Int16 CommandGroup ) throw (::com::sun::star::uno::RuntimeException);
+ };
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/bibliography/general.cxx b/extensions/source/bibliography/general.cxx
new file mode 100644
index 000000000000..c699aff5d485
--- /dev/null
+++ b/extensions/source/bibliography/general.cxx
@@ -0,0 +1,895 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+
+
+#include <comphelper/processfactory.hxx>
+#include <com/sun/star/awt/PosSize.hpp>
+#include <com/sun/star/sdbc/XRowSet.hpp>
+#include <com/sun/star/sdb/XColumn.hpp>
+#include <com/sun/star/sdb/CommandType.hpp>
+#include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
+#include <com/sun/star/form/ListSourceType.hpp>
+#include <com/sun/star/awt/XWindow.hpp>
+#include <toolkit/helper/vclunohelper.hxx>
+#include <cppuhelper/implbase1.hxx> // helper for implementations
+#include "general.hxx"
+#include "sections.hrc"
+#include "bibresid.hxx"
+#include "datman.hxx"
+#include "bibconfig.hxx"
+#include "bibprop.hrc"
+#include "bib.hrc"
+#include "bibmod.hxx"
+#include "bibtools.hxx"
+#include "bibliography.hrc"
+#include <tools/debug.hxx>
+#include <vcl/mnemonic.hxx>
+#include <vcl/svapp.hxx>
+#include <vcl/i18nhelp.hxx>
+#include <vcl/mnemonic.hxx>
+#include <algorithm>
+#include <functional>
+#include <vector>
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::form;
+using namespace ::com::sun::star::sdb;
+using namespace ::rtl;
+
+#define C2U(cChar) OUString::createFromAscii(cChar)
+#define C2S(cChar) String::CreateFromAscii(cChar)
+#define DISTANCE_CONTROL_TO_FIXEDTEXT 5
+
+::Point lcl_MovePoint(const FixedText& rFixedText)
+{
+ ::Point aRet(rFixedText.GetPosPixel());
+ aRet.X() += rFixedText.GetSizePixel().Width();
+ aRet.X() += DISTANCE_CONTROL_TO_FIXEDTEXT;
+ return aRet;
+}
+
+//-----------------------------------------------------------------------------
+OUString lcl_GetColumnName( const Mapping* pMapping, sal_uInt16 nIndexPos )
+{
+ BibConfig* pBibConfig = BibModul::GetConfig();
+ OUString sRet = pBibConfig->GetDefColumnName(nIndexPos);
+ if(pMapping)
+ for(sal_uInt16 i = 0; i < COLUMN_COUNT; i++)
+ {
+ if(pMapping->aColumnPairs[i].sLogicalColumnName == sRet)
+ {
+ sRet = pMapping->aColumnPairs[i].sRealColumnName;
+ break;
+ }
+ }
+ return sRet;
+}
+/* -----------------------------04.01.00 10:54--------------------------------
+
+ ---------------------------------------------------------------------------*/
+class BibPosListener :public cppu::WeakImplHelper1 <sdbc::XRowSetListener>
+{
+ BibGeneralPage* pParentPage;
+public:
+ BibPosListener(BibGeneralPage* pParent);
+
+ //XPositioningListener
+ virtual void SAL_CALL cursorMoved(const lang::EventObject& event) throw( uno::RuntimeException );
+ virtual void SAL_CALL rowChanged(const lang::EventObject& /*event*/) throw( uno::RuntimeException ){ /* not interested in */ }
+ virtual void SAL_CALL rowSetChanged(const lang::EventObject& /*event*/) throw( uno::RuntimeException ){ /* not interested in */ }
+
+ //XEventListener
+ virtual void SAL_CALL disposing(const lang::EventObject& Source) throw( uno::RuntimeException );
+
+};
+/* -----------------------------04.01.00 10:57--------------------------------
+
+ ---------------------------------------------------------------------------*/
+BibPosListener::BibPosListener(BibGeneralPage* pParent) :
+ pParentPage(pParent)
+{
+}
+/* -----------------------------04.01.00 10:57--------------------------------
+
+ ---------------------------------------------------------------------------*/
+void BibPosListener::cursorMoved(const lang::EventObject& /*aEvent*/) throw( uno::RuntimeException )
+{
+ try
+ {
+ uno::Reference< form::XBoundComponent > xLstBox = pParentPage->GetTypeListBoxModel();
+ uno::Reference< beans::XPropertySet > xPropSet(xLstBox, UNO_QUERY);
+ if(xPropSet.is())
+ {
+ BibConfig* pBibConfig = BibModul::GetConfig();
+ BibDataManager* pDatMan = pParentPage->GetDataManager();
+ BibDBDescriptor aDesc;
+ aDesc.sDataSource = pDatMan->getActiveDataSource();
+ aDesc.sTableOrQuery = pDatMan->getActiveDataTable();
+ aDesc.nCommandType = CommandType::TABLE;
+
+ const Mapping* pMapping = pBibConfig->GetMapping(aDesc);
+ OUString sTypeMapping = pBibConfig->GetDefColumnName(AUTHORITYTYPE_POS);
+ if(pMapping)
+ {
+ for(sal_uInt16 nEntry = 0; nEntry < COLUMN_COUNT; nEntry++)
+ {
+ if(pMapping->aColumnPairs[nEntry].sLogicalColumnName == sTypeMapping)
+ {
+ sTypeMapping = pMapping->aColumnPairs[nEntry].sRealColumnName;
+ break;
+ }
+ }
+ }
+ rtl::OUString uTypeMapping = sTypeMapping;
+
+ uno::Reference< form::XForm > xForm = pDatMan->getForm();
+ uno::Reference< sdbcx::XColumnsSupplier > xSupplyCols(xForm, UNO_QUERY);
+ uno::Reference< container::XNameAccess > xValueAcc;
+ if (xSupplyCols.is())
+ xValueAcc = xSupplyCols->getColumns();
+
+ sal_Int16 nTempVal = -1;
+ if(xValueAcc.is() && xValueAcc->hasByName(uTypeMapping))
+ {
+ uno::Any aVal = xValueAcc->getByName(uTypeMapping);
+ uno::Reference< uno::XInterface > xInt = *(uno::Reference< uno::XInterface > *)aVal.getValue();
+ uno::Reference< sdb::XColumn > xCol(xInt, UNO_QUERY);
+ DBG_ASSERT(xCol.is(), "BibPosListener::positioned : invalid column (no sdb::XColumn) !");
+ if (xCol.is())
+ {
+ nTempVal = xCol->getShort();
+ // getShort returns zero if the value is not a number
+ if (!nTempVal || xCol->wasNull())
+ {
+ rtl::OUString sTempVal = xCol->getString();
+ if(sTempVal != rtl::OUString('0'))
+ nTempVal = -1;
+ }
+ }
+ }
+ if(nTempVal < 0 || nTempVal >= TYPE_COUNT)
+ {
+ uno::Any aSel;
+ uno::Sequence<sal_Int16> aSelSeq(1);
+ sal_Int16* pArr = aSelSeq.getArray();
+ pArr[0] = TYPE_COUNT;
+ aSel.setValue(&aSelSeq, ::getCppuType((Sequence<sal_Int16>*)0));
+ xPropSet->setPropertyValue(C2U("SelectedItems"), aSel);
+ }
+ }
+ }
+ catch(Exception& rEx)
+ {
+ (void) rEx; // make compiler happy
+ DBG_ERROR("BibPosListener::positioned: something went wrong !");
+ }
+}
+/* -----------------------------04.01.00 11:28--------------------------------
+
+ ---------------------------------------------------------------------------*/
+void BibPosListener::disposing(const lang::EventObject& /*Source*/) throw( uno::RuntimeException )
+{
+}
+
+/* -----------------16.11.99 13:06-------------------
+
+ --------------------------------------------------*/
+BibGeneralPage::BibGeneralPage(Window* pParent, BibDataManager* pMan):
+ BibTabPage(pParent,BibResId(RID_TP_GENERAL)),
+ aControlParentWin(this, WB_DIALOGCONTROL),
+ aIdentifierFT(&aControlParentWin, BibResId(FT_IDENTIFIER )),
+ aAuthTypeFT(&aControlParentWin, BibResId(FT_AUTHTYPE )),
+ aYearFT(&aControlParentWin, BibResId(FT_YEAR )),
+ aAuthorFT(&aControlParentWin, BibResId(FT_AUTHOR )),
+ aTitleFT(&aControlParentWin, BibResId(FT_TITLE )),
+ aPublisherFT(&aControlParentWin, BibResId(FT_PUBLISHER )),
+ aAddressFT(&aControlParentWin, BibResId(FT_ADDRESS )),
+ aISBNFT(&aControlParentWin, BibResId(FT_ISBN )),
+ aChapterFT(&aControlParentWin, BibResId(FT_CHAPTER )),
+ aPagesFT(&aControlParentWin, BibResId(FT_PAGE )),
+ aFirstFL(&aControlParentWin, BibResId(FL_1 )),
+ aEditorFT(&aControlParentWin, BibResId(FT_EDITOR )),
+ aEditionFT(&aControlParentWin, BibResId(FT_EDITION )),
+ aBooktitleFT(&aControlParentWin, BibResId(FT_BOOKTITLE )),
+ aVolumeFT(&aControlParentWin, BibResId(FT_VOLUME )),
+ aHowpublishedFT(&aControlParentWin, BibResId(FT_HOWPUBLISHED )),
+ aOrganizationsFT(&aControlParentWin,BibResId(FT_ORGANIZATION )),
+ aInstitutionFT(&aControlParentWin, BibResId(FT_INSTITUTION )),
+ aSchoolFT(&aControlParentWin, BibResId(FT_SCHOOL )),
+ aReportTypeFT(&aControlParentWin, BibResId(FT_REPORT )),
+ aMonthFT(&aControlParentWin, BibResId(FT_MONTH )),
+ aSecondFL(&aControlParentWin, BibResId(FL_2 )),
+ aJournalFT(&aControlParentWin, BibResId(FT_JOURNAL )),
+ aNumberFT(&aControlParentWin, BibResId(FT_NUMBER )),
+ aSeriesFT(&aControlParentWin, BibResId(FT_SERIES )),
+ aAnnoteFT(&aControlParentWin, BibResId(FT_ANNOTE )),
+ aNoteFT(&aControlParentWin, BibResId(FT_NOTE )),
+ aURLFT(&aControlParentWin, BibResId(FT_URL )),
+ aThirdFL(&aControlParentWin, BibResId(FL_3 )),
+ aCustom1FT(&aControlParentWin, BibResId(FT_CUSTOM1 )),
+ aCustom2FT(&aControlParentWin, BibResId(FT_CUSTOM2 )),
+ aCustom3FT(&aControlParentWin, BibResId(FT_CUSTOM3 )),
+ aCustom4FT(&aControlParentWin, BibResId(FT_CUSTOM4 )),
+ aCustom5FT(&aControlParentWin, BibResId(FT_CUSTOM5 )),
+ aHoriScroll(this, WB_HORZ),
+ aVertScroll(this, WB_VERT),
+ sErrorPrefix(BibResId(ST_ERROR_PREFIX)),
+ pDatMan(pMan)
+{
+ aControlParentWin.Show();
+ aControlParentWin.SetHelpId(HID_BIB_CONTROL_PARENT);
+ aStdSize = GetOutputSizePixel();
+
+ aBibTypeArr[0] = String(BibResId(ST_TYPE_ARTICLE));
+ aBibTypeArr[1] = String(BibResId(ST_TYPE_BOOK));
+ aBibTypeArr[2] = String(BibResId(ST_TYPE_BOOKLET));
+ aBibTypeArr[3] = String(BibResId(ST_TYPE_CONFERENCE));
+ aBibTypeArr[4] = String(BibResId(ST_TYPE_INBOOK ));
+ aBibTypeArr[5] = String(BibResId(ST_TYPE_INCOLLECTION));
+ aBibTypeArr[6] = String(BibResId(ST_TYPE_INPROCEEDINGS));
+ aBibTypeArr[7] = String(BibResId(ST_TYPE_JOURNAL ));
+ aBibTypeArr[8] = String(BibResId(ST_TYPE_MANUAL ));
+ aBibTypeArr[9] = String(BibResId(ST_TYPE_MASTERSTHESIS));
+ aBibTypeArr[10] = String(BibResId(ST_TYPE_MISC ));
+ aBibTypeArr[11] = String(BibResId(ST_TYPE_PHDTHESIS ));
+ aBibTypeArr[12] = String(BibResId(ST_TYPE_PROCEEDINGS ));
+ aBibTypeArr[13] = String(BibResId(ST_TYPE_TECHREPORT ));
+ aBibTypeArr[14] = String(BibResId(ST_TYPE_UNPUBLISHED ));
+ aBibTypeArr[15] = String(BibResId(ST_TYPE_EMAIL ));
+ aBibTypeArr[16] = String(BibResId(ST_TYPE_WWW ));
+ aBibTypeArr[17] = String(BibResId(ST_TYPE_CUSTOM1 ));
+ aBibTypeArr[18] = String(BibResId(ST_TYPE_CUSTOM2 ));
+ aBibTypeArr[19] = String(BibResId(ST_TYPE_CUSTOM3 ));
+ aBibTypeArr[20] = String(BibResId(ST_TYPE_CUSTOM4 ));
+ aBibTypeArr[21] = String(BibResId(ST_TYPE_CUSTOM5 ));
+
+ FreeResource();
+
+ InitFixedTexts();
+
+ aBasePos = aIdentifierFT.GetPosPixel();
+
+ INT16* pMap = nFT2CtrlMap;
+ for( USHORT i = 0 ; i < FIELD_COUNT ; ++i, ++pMap )
+ {
+ aControls[ i ] = 0;
+ *pMap = -1;
+ }
+
+ AdjustScrollbars();
+ Link aScrollLnk(LINK(this, BibGeneralPage, ScrollHdl));
+ aHoriScroll.SetScrollHdl( aScrollLnk );
+ aVertScroll.SetScrollHdl( aScrollLnk );
+ aHoriScroll.SetLineSize(10);
+ aVertScroll.SetLineSize(10);
+ aHoriScroll.SetPageSize( aIdentifierFT.GetSizePixel().Width());
+ aVertScroll.SetPageSize(
+ aPublisherFT.GetPosPixel().Y() - aIdentifierFT.GetPosPixel().Y());
+ aHoriScroll.Show();
+ aVertScroll.Show();
+
+ BibConfig* pBibConfig = BibModul::GetConfig();
+ BibDBDescriptor aDesc;
+ aDesc.sDataSource = pDatMan->getActiveDataSource();
+ aDesc.sTableOrQuery = pDatMan->getActiveDataTable();
+ aDesc.nCommandType = CommandType::TABLE;
+ const Mapping* pMapping = pBibConfig->GetMapping(aDesc);
+
+ xCtrlContnr = VCLUnoHelper::CreateControlContainer(&aControlParentWin);
+
+ xMgr = comphelper::getProcessServiceFactory();
+ // the control should be a bit smaller than the fixed text
+ Size aControlSize(aIdentifierFT.GetSizePixel());
+ aControlSize.Width() = aControlSize.Width() * 8 / 10;
+
+ AddControlWithError( lcl_GetColumnName( pMapping, IDENTIFIER_POS ), lcl_MovePoint( aIdentifierFT ),
+ aControlSize, sTableErrorString, aIdentifierFT.GetText(),
+ HID_BIB_IDENTIFIER_POS, 0 );
+
+ sTypeColumnName = lcl_GetColumnName(pMapping, AUTHORITYTYPE_POS);
+
+ AddControlWithError( sTypeColumnName, lcl_MovePoint(aAuthTypeFT ), aControlSize, sTableErrorString,
+ aAuthTypeFT.GetText(), HID_BIB_AUTHORITYTYPE_POS, 1 );
+
+ ::Point aYearPos = lcl_MovePoint(aYearFT);
+ AddControlWithError( lcl_GetColumnName( pMapping, YEAR_POS ), aYearPos,
+ aControlSize, sTableErrorString, aYearFT.GetText(), HID_BIB_YEAR_POS, 4 );
+
+ AddControlWithError( lcl_GetColumnName(pMapping, AUTHOR_POS), lcl_MovePoint(aAuthorFT),
+ aControlSize, sTableErrorString, aAuthorFT.GetText(), HID_BIB_AUTHOR_POS, 2 );
+
+ ::Point aTitlePos( lcl_MovePoint( aTitleFT ) );
+ ::Size aTitleSize = aTitleFT.GetSizePixel();
+ aTitleSize.Width() = aYearPos.X() + aControlSize.Width() - aTitlePos.X();
+ AddControlWithError( lcl_GetColumnName(pMapping, TITLE_POS), aTitlePos, aTitleSize, sTableErrorString,
+ aTitleFT.GetText(), HID_BIB_TITLE_POS, 22 );
+
+ AddControlWithError( lcl_GetColumnName( pMapping, PUBLISHER_POS ), lcl_MovePoint( aPublisherFT),
+ aControlSize, sTableErrorString, aPublisherFT.GetText(), HID_BIB_PUBLISHER_POS, 5 );
+
+ AddControlWithError( lcl_GetColumnName( pMapping, ADDRESS_POS ), lcl_MovePoint( aAddressFT ),
+ aControlSize, sTableErrorString, aAddressFT.GetText(), HID_BIB_ADDRESS_POS, 7 );
+
+ AddControlWithError( lcl_GetColumnName( pMapping, ISBN_POS ), lcl_MovePoint( aISBNFT ),
+ aControlSize, sTableErrorString, aISBNFT.GetText(), HID_BIB_ISBN_POS, 6 );
+
+ AddControlWithError( lcl_GetColumnName( pMapping, CHAPTER_POS ), lcl_MovePoint(aChapterFT),
+ aControlSize, sTableErrorString, aChapterFT.GetText(), HID_BIB_CHAPTER_POS, 10 );
+
+ AddControlWithError( lcl_GetColumnName( pMapping, PAGES_POS ), lcl_MovePoint( aPagesFT ),
+ aControlSize, sTableErrorString, aPagesFT.GetText(), HID_BIB_PAGES_POS, 19 );
+
+ AddControlWithError( lcl_GetColumnName( pMapping, EDITOR_POS ), lcl_MovePoint( aEditorFT ),
+ aControlSize, sTableErrorString, aEditorFT.GetText(), HID_BIB_EDITOR_POS, 12 );
+
+ AddControlWithError( lcl_GetColumnName( pMapping, EDITION_POS ), lcl_MovePoint(aEditionFT),
+ aControlSize, sTableErrorString, aEditionFT.GetText(), HID_BIB_EDITION_POS, 11 );
+
+ AddControlWithError( lcl_GetColumnName(pMapping, BOOKTITLE_POS), lcl_MovePoint(aBooktitleFT),
+ aControlSize, sTableErrorString, aBooktitleFT.GetText(), HID_BIB_BOOKTITLE_POS, 9 );
+
+ AddControlWithError( lcl_GetColumnName( pMapping, VOLUME_POS ), lcl_MovePoint( aVolumeFT ),
+ aControlSize, sTableErrorString, aVolumeFT.GetText(), HID_BIB_VOLUME_POS, 24 );
+
+ AddControlWithError( lcl_GetColumnName( pMapping, HOWPUBLISHED_POS ), lcl_MovePoint( aHowpublishedFT ),
+ aControlSize, sTableErrorString, aHowpublishedFT.GetText(), HID_BIB_HOWPUBLISHED_POS, 13 );
+
+ AddControlWithError( lcl_GetColumnName( pMapping, ORGANIZATIONS_POS ), lcl_MovePoint( aOrganizationsFT ),
+ aControlSize, sTableErrorString, aOrganizationsFT.GetText(), HID_BIB_ORGANIZATIONS_POS, 18 );
+
+ AddControlWithError( lcl_GetColumnName( pMapping, INSTITUTION_POS ), lcl_MovePoint( aInstitutionFT ),
+ aControlSize, sTableErrorString, aInstitutionFT.GetText(), HID_BIB_INSTITUTION_POS, 14 );
+
+ AddControlWithError( lcl_GetColumnName( pMapping, SCHOOL_POS ), lcl_MovePoint( aSchoolFT ),
+ aControlSize, sTableErrorString, aSchoolFT.GetText(), HID_BIB_SCHOOL_POS, 20 );
+
+ AddControlWithError( lcl_GetColumnName( pMapping, REPORTTYPE_POS ), lcl_MovePoint( aReportTypeFT ),
+ aControlSize, sTableErrorString, aReportTypeFT.GetText(), HID_BIB_REPORTTYPE_POS, 23 );
+
+ AddControlWithError( lcl_GetColumnName( pMapping, MONTH_POS ), lcl_MovePoint( aMonthFT ),
+ aControlSize, sTableErrorString, aMonthFT.GetText(), HID_BIB_MONTH_POS, 3 );
+
+ AddControlWithError( lcl_GetColumnName( pMapping, JOURNAL_POS ), lcl_MovePoint( aJournalFT ),
+ aControlSize, sTableErrorString, aJournalFT.GetText(), HID_BIB_JOURNAL_POS, 15 );
+
+ AddControlWithError( lcl_GetColumnName( pMapping, NUMBER_POS ), lcl_MovePoint( aNumberFT ),
+ aControlSize, sTableErrorString, aNumberFT.GetText(), HID_BIB_NUMBER_POS, 17 );
+
+ AddControlWithError( lcl_GetColumnName( pMapping, SERIES_POS ), lcl_MovePoint( aSeriesFT ),
+ aControlSize, sTableErrorString, aSeriesFT.GetText(), HID_BIB_SERIES_POS, 21 );
+
+ AddControlWithError( lcl_GetColumnName( pMapping, ANNOTE_POS ), lcl_MovePoint( aAnnoteFT ),
+ aControlSize, sTableErrorString, aAnnoteFT.GetText(), HID_BIB_ANNOTE_POS, 8 );
+
+ AddControlWithError( lcl_GetColumnName( pMapping, NOTE_POS ), lcl_MovePoint( aNoteFT ),
+ aControlSize, sTableErrorString, aNoteFT.GetText(), HID_BIB_NOTE_POS, 16 );
+
+ AddControlWithError( lcl_GetColumnName( pMapping, URL_POS ), lcl_MovePoint( aURLFT ),
+ aControlSize, sTableErrorString, aURLFT.GetText(), HID_BIB_URL_POS, 25 );
+
+ AddControlWithError( lcl_GetColumnName( pMapping, CUSTOM1_POS ), lcl_MovePoint( aCustom1FT ),
+ aControlSize, sTableErrorString, aCustom1FT.GetText(), HID_BIB_CUSTOM1_POS, 26 );
+
+ AddControlWithError( lcl_GetColumnName( pMapping, CUSTOM2_POS ), lcl_MovePoint( aCustom2FT ),
+ aControlSize, sTableErrorString, aCustom2FT.GetText(), HID_BIB_CUSTOM2_POS, 27 );
+
+ AddControlWithError( lcl_GetColumnName( pMapping, CUSTOM3_POS ), lcl_MovePoint( aCustom3FT ),
+ aControlSize, sTableErrorString, aCustom3FT.GetText(), HID_BIB_CUSTOM3_POS, 28 );
+
+ AddControlWithError( lcl_GetColumnName( pMapping, CUSTOM4_POS ), lcl_MovePoint( aCustom4FT ),
+ aControlSize, sTableErrorString, aCustom4FT.GetText(), HID_BIB_CUSTOM4_POS, 29 );
+
+ AddControlWithError( lcl_GetColumnName( pMapping, CUSTOM5_POS ), lcl_MovePoint( aCustom5FT ),
+ aControlSize, sTableErrorString, aCustom5FT.GetText(), HID_BIB_CUSTOM5_POS, 30 );
+
+ xPosListener = new BibPosListener(this);
+ uno::Reference< sdbc::XRowSet > xRowSet(pDatMan->getForm(), UNO_QUERY);
+ if(xRowSet.is())
+ xRowSet->addRowSetListener(xPosListener);
+ uno::Reference< form::runtime::XFormController > xFormCtrl = pDatMan->GetFormController();
+ xFormCtrl->setContainer(xCtrlContnr);
+ xFormCtrl->activateTabOrder();
+
+ if(sTableErrorString.Len())
+ sTableErrorString.Insert(sErrorPrefix, 0);
+}
+//-----------------------------------------------------------------------------
+BibGeneralPage::~BibGeneralPage()
+{
+ if (pDatMan && xPosListener.is())
+ {
+ uno::Reference< sdbc::XRowSet > xRowSet(pDatMan->getForm(), UNO_QUERY);
+ if(xRowSet.is())
+ xRowSet->removeRowSetListener(xPosListener);
+ }
+}
+ /* -----------------------------14.04.00 13:11--------------------------------
+
+ ---------------------------------------------------------------------------*/
+ void BibGeneralPage::RemoveListeners()
+ {
+ for(USHORT i = 0; i < FIELD_COUNT; i++)
+ {
+ if(aControls[i].is())
+ {
+ uno::Reference< awt::XWindow > xCtrWin(aControls[i], uno::UNO_QUERY );
+ xCtrWin->removeFocusListener( this );
+ aControls[i] = 0;
+ }
+ }
+ }
+/* -----------------------------21.01.00 17:05--------------------------------
+
+ ---------------------------------------------------------------------------*/
+void BibGeneralPage::CommitActiveControl()
+{
+ uno::Reference< form::runtime::XFormController > xFormCtrl = pDatMan->GetFormController();
+ uno::Reference< awt::XControl > xCurr = xFormCtrl->getCurrentControl();
+ if(xCurr.is())
+ {
+ uno::Reference< awt::XControlModel > xModel = xCurr->getModel();
+ uno::Reference< form::XBoundComponent > xBound(xModel, UNO_QUERY);
+ if(xBound.is())
+ xBound->commit();
+ }
+}
+//-----------------------------------------------------------------------------
+void BibGeneralPage::AddControlWithError( const OUString& rColumnName, const ::Point& rPos, const ::Size& rSize,
+ String& rErrorString, String aColumnUIName, sal_uInt16 nHelpId, sal_uInt16 nIndexInFTArray )
+{
+ // adds also the XControl and creates a map entry in nFT2CtrlMap[] for mapping between control and FT
+
+ INT16 nIndex = -1;
+ uno::Reference< awt::XControlModel > xTmp = AddXControl(rColumnName, rPos, rSize, nHelpId, nIndex );
+ if( xTmp.is() )
+ {
+ DBG_ASSERT( nIndexInFTArray < FIELD_COUNT, "*BibGeneralPage::AddControlWithError(): wrong array index!" );
+ DBG_ASSERT( nFT2CtrlMap[ nIndexInFTArray ] < 0, "+BibGeneralPage::AddControlWithError(): index already in use!" );
+
+ nFT2CtrlMap[ nIndexInFTArray ] = nIndex;
+ }
+ else
+ {
+ if( rErrorString.Len() )
+ rErrorString += '\n';
+
+ rErrorString += MnemonicGenerator::EraseAllMnemonicChars( aColumnUIName );
+ }
+}
+//-----------------------------------------------------------------------------
+uno::Reference< awt::XControlModel > BibGeneralPage::AddXControl(
+ const String& rName,
+ ::Point rPos, ::Size rSize, sal_uInt16 nHelpId, INT16& rIndex )
+{
+ uno::Reference< awt::XControlModel > xCtrModel;
+ try
+ {
+ sal_Bool bTypeListBox = sTypeColumnName == rName;
+ xCtrModel = pDatMan->loadControlModel(rName, bTypeListBox);
+ if ( xCtrModel.is() && xMgr.is())
+ {
+ uno::Reference< beans::XPropertySet > xPropSet( xCtrModel, UNO_QUERY );
+
+ if( xPropSet.is())
+ {
+ uno::Reference< beans::XPropertySetInfo > xPropInfo = xPropSet->getPropertySetInfo();
+
+ uno::Any aAny = xPropSet->getPropertyValue( C2U("DefaultControl") );
+ rtl::OUString aControlName;
+ aAny >>= aControlName;
+
+ rtl::OUString uProp(C2U("HelpURL"));
+ if(xPropInfo->hasPropertyByName(uProp))
+ {
+ String sId(C2S("HID:"));
+ sId += String::CreateFromInt32(nHelpId);
+ rtl::OUString uId(sId) ;
+ uno::Any aVal; aVal <<= uId;
+ xPropSet->setPropertyValue(uProp, aVal);
+ }
+
+ if(bTypeListBox)
+ {
+ //uno::Reference< beans::XPropertySet > xPropSet(xControl, UNO_QUERY);
+ aAny <<= (sal_Int16)1;
+ xPropSet->setPropertyValue(C2U("BoundColumn"), aAny);
+ ListSourceType eSet = ListSourceType_VALUELIST;
+ aAny.setValue( &eSet, ::getCppuType((const ListSourceType*)0) );
+ xPropSet->setPropertyValue(C2U("ListSourceType"), aAny);
+
+ uno::Sequence<rtl::OUString> aListSource(TYPE_COUNT);
+ rtl::OUString* pListSourceArr = aListSource.getArray();
+ //pListSourceArr[0] = C2U("select TypeName, TypeIndex from TypeNms");
+ for(sal_uInt16 i = 0; i < TYPE_COUNT; i++)
+ pListSourceArr[i] = String::CreateFromInt32(i);
+ aAny.setValue(&aListSource, ::getCppuType((uno::Sequence<rtl::OUString>*)0));
+
+ xPropSet->setPropertyValue(C2U("ListSource"), aAny);
+
+ uno::Sequence<rtl::OUString> aValues(TYPE_COUNT + 1);
+ rtl::OUString* pValuesArr = aValues.getArray();
+ for(sal_uInt16 j = 0; j < TYPE_COUNT; j++)
+ pValuesArr[j] = aBibTypeArr[j];
+ // empty string if an invalid value no values is set
+ pValuesArr[TYPE_COUNT] = rtl::OUString();
+
+ aAny.setValue(&aValues, ::getCppuType((uno::Sequence<rtl::OUString>*)0));
+
+ xPropSet->setPropertyValue(C2U("StringItemList"), aAny);
+
+ BOOL bTrue = sal_True;
+ aAny.setValue( &bTrue, ::getBooleanCppuType() );
+ xPropSet->setPropertyValue( C2U("Dropdown"), aAny );
+
+ aControlName = C2U("com.sun.star.form.control.ListBox");
+ xLBModel = Reference< form::XBoundComponent >(xCtrModel, UNO_QUERY);
+
+ }
+
+ uno::Reference< awt::XControl > xControl(xMgr->createInstance( aControlName ), UNO_QUERY );
+ if ( xControl.is() )
+ {
+ xControl->setModel( xCtrModel);
+
+ // Peer als Child zu dem FrameWindow
+ xCtrlContnr->addControl(rName, xControl);
+ uno::Reference< awt::XWindow > xCtrWin(xControl, UNO_QUERY );
+ xCtrWin->addFocusListener( this );
+ rIndex = -1; // -> implies, that not found
+ for(USHORT i = 0; i < FIELD_COUNT; i++)
+ if(!aControls[i].is())
+ {
+ aControls[i] = xCtrWin;
+ rIndex = INT16( i );
+ break;
+ }
+ xCtrWin->setVisible( sal_True );
+ xControl->setDesignMode( sal_True );
+ // initially switch on the desing mode - switch it off _after_ loading the form
+ // 17.10.2001 - 93107 - frank.schoenheit@sun.com
+
+ xCtrWin->setPosSize(rPos.X(), rPos.Y(), rSize.Width(),
+ rSize.Height(), awt::PosSize::POSSIZE);
+ }
+ }
+ }
+ }
+ catch(Exception& rEx)
+ {
+ (void) rEx; // make compiler happy
+ DBG_ERROR("BibGeneralPage::AddXControl: something went wrong !");
+ }
+ return xCtrModel;
+}
+
+void BibGeneralPage::AdjustScrollbars()
+{
+ long nVertScrollWidth = aVertScroll.GetSizePixel().Width();
+ long nHoriScrollHeight = aHoriScroll.GetSizePixel().Height();
+ ::Size aOutSize(GetOutputSizePixel());
+ BOOL bHoriVisible = aOutSize.Width() <= aStdSize.Width();
+ BOOL bVertVisible = (aOutSize.Height()-(bHoriVisible ? nHoriScrollHeight : 0)) <= (aStdSize.Height());
+ aHoriScroll.Show(bHoriVisible);
+ aVertScroll.Show(bVertVisible);
+
+ if(bHoriVisible)
+ {
+ ::Size aHoriSize(aOutSize.Width() - (bVertVisible ? nVertScrollWidth : 0),
+ nHoriScrollHeight);
+ aHoriScroll.SetSizePixel(aHoriSize);
+ aHoriScroll.SetRange( Range(0, aStdSize.Width()));
+ aHoriScroll.SetVisibleSize( aHoriSize.Width() - (bVertVisible ? nVertScrollWidth : 0));
+ }
+ if(bVertVisible)
+ {
+ ::Size aVertSize(nHoriScrollHeight, aOutSize.Height() -
+ (bHoriVisible ? nHoriScrollHeight : 0));
+ aVertScroll.SetSizePixel(aVertSize);
+ aVertScroll.SetRange( Range(0, aStdSize.Height()));
+ aVertScroll.SetVisibleSize( aVertSize.Height() );
+ }
+
+ ::Size aSize(8, 8);
+ aSize = LogicToPixel(aSize, MapMode(MAP_APPFONT));
+ ::Size aScrollSize(aOutSize.Width() - aSize.Height(), aSize.Height());
+ ::Point aScrollPos(0, aOutSize.Height() - aSize.Height());
+ aHoriScroll.SetPosSizePixel(aScrollPos, aScrollSize);
+
+ aScrollPos.X() = aOutSize.Width() - aSize.Width();
+ aScrollPos.Y() = 0;
+ aScrollSize.Width() = aSize.Width();
+ aScrollSize.Height() = aOutSize.Height() - aSize.Height();
+ aVertScroll.SetPosSizePixel(aScrollPos, aScrollSize);
+
+ ::Size aControlParentWinSz(aOutSize);
+ if(bHoriVisible)
+ aControlParentWinSz.Height() -= aSize.Height();
+ if(bVertVisible)
+ aControlParentWinSz.Width() -= aSize.Width();
+ aControlParentWin.SetSizePixel(aControlParentWinSz);
+}
+
+void BibGeneralPage::Resize()
+{
+ AdjustScrollbars();
+ ScrollHdl(&aVertScroll);
+ ScrollHdl(&aHoriScroll);
+ Window::Resize();
+}
+
+void BibGeneralPage::InitFixedTexts( void )
+{
+ String aFixedStrings[ FIELD_COUNT ] =
+ {
+ String( BibResId( ST_IDENTIFIER ) ),
+ String( BibResId( ST_AUTHTYPE ) ),
+ String( BibResId( ST_AUTHOR ) ),
+ String( BibResId( ST_TITLE ) ),
+ String( BibResId( ST_MONTH ) ),
+ String( BibResId( ST_YEAR ) ),
+ String( BibResId( ST_ISBN ) ),
+ String( BibResId( ST_BOOKTITLE ) ),
+ String( BibResId( ST_CHAPTER ) ),
+ String( BibResId( ST_EDITION ) ),
+ String( BibResId( ST_EDITOR ) ),
+ String( BibResId( ST_HOWPUBLISHED ) ),
+ String( BibResId( ST_INSTITUTION ) ),
+ String( BibResId( ST_JOURNAL ) ),
+ String( BibResId( ST_NOTE ) ),
+ String( BibResId( ST_ANNOTE ) ),
+ String( BibResId( ST_NUMBER ) ),
+ String( BibResId( ST_ORGANIZATION ) ),
+ String( BibResId( ST_PAGE ) ),
+ String( BibResId( ST_PUBLISHER ) ),
+ String( BibResId( ST_ADDRESS ) ),
+ String( BibResId( ST_SCHOOL ) ),
+ String( BibResId( ST_SERIES ) ),
+ String( BibResId( ST_REPORT ) ),
+ String( BibResId( ST_VOLUME ) ),
+ String( BibResId( ST_URL ) ),
+ String( BibResId( ST_CUSTOM1 ) ),
+ String( BibResId( ST_CUSTOM2 ) ),
+ String( BibResId( ST_CUSTOM3 ) ),
+ String( BibResId( ST_CUSTOM4 ) ),
+ String( BibResId( ST_CUSTOM5 ) )
+ };
+
+ aFixedTexts[0] = &aIdentifierFT;
+ aFixedTexts[1] = &aAuthTypeFT;
+ aFixedTexts[2] = &aAuthorFT;
+ aFixedTexts[3] = &aTitleFT;
+ aFixedTexts[4] = &aMonthFT;
+ aFixedTexts[5] = &aYearFT;
+ aFixedTexts[6] = &aISBNFT;
+ aFixedTexts[7] = &aBooktitleFT;
+ aFixedTexts[8] = &aChapterFT;
+ aFixedTexts[9] = &aEditionFT;
+ aFixedTexts[10] = &aEditorFT;
+ aFixedTexts[11] = &aHowpublishedFT;
+ aFixedTexts[12] = &aInstitutionFT;
+ aFixedTexts[13] = &aJournalFT;
+ aFixedTexts[14] = &aNoteFT;
+ aFixedTexts[15] = &aAnnoteFT;
+ aFixedTexts[16] = &aNumberFT;
+ aFixedTexts[17] = &aOrganizationsFT;
+ aFixedTexts[18] = &aPagesFT;
+ aFixedTexts[19] = &aPublisherFT;
+ aFixedTexts[20] = &aAddressFT;
+ aFixedTexts[21] = &aSchoolFT;
+ aFixedTexts[22] = &aSeriesFT;
+ aFixedTexts[23] = &aReportTypeFT;
+ aFixedTexts[24] = &aVolumeFT;
+ aFixedTexts[25] = &aURLFT;
+ aFixedTexts[26] = &aCustom1FT;
+ aFixedTexts[27] = &aCustom2FT;
+ aFixedTexts[28] = &aCustom3FT;
+ aFixedTexts[29] = &aCustom4FT;
+ aFixedTexts[30] = &aCustom5FT;
+
+ int i;
+
+ MnemonicGenerator aMnemonicGenerator;
+ // init mnemonics, first register all strings
+ for( i = 0 ; i < FIELD_COUNT ; ++i )
+ aMnemonicGenerator.RegisterMnemonic( aFixedStrings[ i ] );
+
+ // ... then get all strings
+ for( i = 0 ; i < FIELD_COUNT ; ++i )
+ aMnemonicGenerator.CreateMnemonic( aFixedStrings[ i ] );
+
+ // set texts
+ for( i = 0 ; i < FIELD_COUNT ; ++i )
+ aFixedTexts[ i ]->SetText( aFixedStrings[ i ] );
+}
+
+IMPL_LINK(BibGeneralPage, ScrollHdl, ScrollBar*, pScroll)
+{
+ BOOL bVertical = &aVertScroll == pScroll;
+ long nOffset = 0;
+ long nCurrentOffset = 0;
+ if(bVertical)
+ nCurrentOffset = aFixedTexts[0]->GetPosPixel().Y() - aBasePos.Y();
+ else
+ nCurrentOffset = aFixedTexts[0]->GetPosPixel().X() - aBasePos.X();
+ nOffset = pScroll->IsVisible() ? pScroll->GetThumbPos() + nCurrentOffset : nCurrentOffset;;
+
+ for(USHORT i = 0; i < FIELD_COUNT; i++)
+ {
+ ::Point aPos = aFixedTexts[i]->GetPosPixel();
+ if(bVertical)
+ aPos.Y() -= nOffset;
+ else
+ aPos.X() -= nOffset;
+ aFixedTexts[i]->SetPosPixel(aPos);
+ if(aControls[i].is())
+ {
+ awt::Rectangle aRect = aControls[i]->getPosSize();
+ long nX = aRect.X;
+ long nY = aRect.Y;
+ if(bVertical)
+ nY -= nOffset;
+ else
+ nX -= nOffset;
+ aControls[i]->setPosSize(nX, nY, 0, 0, awt::PosSize::POS);
+ }
+ }
+ return 0;
+}
+
+void BibGeneralPage::focusGained(const awt::FocusEvent& rEvent) throw( uno::RuntimeException )
+{
+ Reference<awt::XWindow> xCtrWin(rEvent.Source, UNO_QUERY );
+ if(xCtrWin.is())
+ {
+ ::Size aOutSize = aControlParentWin.GetOutputSizePixel();
+ awt::Rectangle aRect = xCtrWin->getPosSize();
+ long nX = aRect.X;
+ if(nX < 0)
+ {
+ // left of the visible area
+ aHoriScroll.SetThumbPos(aHoriScroll.GetThumbPos() + nX);
+ ScrollHdl(&aHoriScroll);
+ }
+ else if(nX > aOutSize.Width())
+ {
+ // right of the visible area
+ aHoriScroll.SetThumbPos(aHoriScroll.GetThumbPos() + nX - aOutSize.Width() + aFixedTexts[0]->GetSizePixel().Width());
+ ScrollHdl(&aHoriScroll);
+ }
+ long nY = aRect.Y;
+ if(nY < 0)
+ {
+ // below the visible area
+ aVertScroll.SetThumbPos(aVertScroll.GetThumbPos() + nY);
+ ScrollHdl(&aVertScroll);
+ }
+ else if(nY > aOutSize.Height())
+ {
+ // over the visible area
+ aVertScroll.SetThumbPos(aVertScroll.GetThumbPos() + nY - aOutSize.Height()+ aFixedTexts[0]->GetSizePixel().Height());
+ ScrollHdl(&aVertScroll);
+ }
+ }
+}
+
+void BibGeneralPage::focusLost(const awt::FocusEvent& ) throw( uno::RuntimeException )
+{
+ CommitActiveControl();
+}
+
+void BibGeneralPage::disposing(const lang::EventObject& /*Source*/) throw( uno::RuntimeException )
+{
+}
+
+void BibGeneralPage::GetFocus()
+{
+ Reference< awt::XWindow >* pxControl = aControls;
+
+ for( int i = FIELD_COUNT ; i ; --i, ++pxControl )
+ {
+ if( pxControl->is() )
+ {
+ ( *pxControl )->setFocus();
+ return;
+ }
+ }
+
+ // fallback
+ aControlParentWin.GrabFocus();
+}
+
+BOOL BibGeneralPage::HandleShortCutKey( const KeyEvent& rKeyEvent )
+{
+ DBG_ASSERT( KEY_MOD2 == rKeyEvent.GetKeyCode().GetModifier(), "+BibGeneralPage::HandleShortCutKey(): this is not for me!" );
+
+ const vcl::I18nHelper& rI18nHelper = Application::GetSettings().GetUILocaleI18nHelper();
+ const xub_Unicode c = rKeyEvent.GetCharCode();
+ BOOL bHandled = FALSE;
+
+ sal_Int16 i;
+
+ typedef std::vector< sal_Int16 > sal_Int16_vector;
+
+ sal_Int16_vector::size_type nFocused = 0xFFFF; // index of focused in vector, no one focused initial
+ DBG_ASSERT( nFocused > 0, "*BibGeneralPage::HandleShortCutKey(): size_type works not as expected!" );
+
+ sal_Int16_vector aMatchList;
+
+ for( i = 0 ; i < FIELD_COUNT ; ++i )
+ {
+ if( rI18nHelper.MatchMnemonic( aFixedTexts[ i ]->GetText(), c ) )
+ {
+ bHandled = TRUE;
+ sal_Int16 nCtrlIndex = nFT2CtrlMap[ i ];
+
+ if( nCtrlIndex >= 0 )
+ { // store index of control
+ DBG_ASSERT( aControls[ nCtrlIndex ].is(), "-BibGeneralPage::HandleShortCutKey(): valid index and no control?" );
+
+ uno::Reference< awt::XControl > xControl( aControls[ nCtrlIndex ], UNO_QUERY );
+ DBG_ASSERT( xControl.is(), "-BibGeneralPage::HandleShortCutKey(): a control wich is not a control!" );
+
+ Window* pWindow = VCLUnoHelper::GetWindow( xControl->getPeer() );
+
+ if( pWindow )
+ {
+ aMatchList.push_back( nCtrlIndex );
+ if( pWindow->HasChildPathFocus() )
+ { // save focused control
+ DBG_ASSERT( nFocused == 0xFFFF, "+BibGeneralPage::HandleShortCutKey(): more than one with focus?!" );
+ DBG_ASSERT( aMatchList.size() > 0, "+BibGeneralPage::HandleShortCutKey(): push_back and no content?!" );
+ nFocused = aMatchList.size() - 1;
+ }
+ }
+ }
+ }
+ }
+
+ if( bHandled )
+ {
+ DBG_ASSERT( aMatchList.size() > 0, "*BibGeneralPage::HandleShortCutKey(): be prepared to crash..." );
+
+ if( nFocused >= ( aMatchList.size() - 1 ) )
+ // >=... includes 0xFFFF
+ // no one or last focused, take first
+ nFocused = 0;
+ else
+ // take next one
+ nFocused++;
+
+ aControls[ aMatchList[ nFocused ] ]->setFocus();
+ }
+
+ return bHandled;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/bibliography/general.hxx b/extensions/source/bibliography/general.hxx
new file mode 100644
index 000000000000..5f2211cbdaba
--- /dev/null
+++ b/extensions/source/bibliography/general.hxx
@@ -0,0 +1,207 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _BIB_GENERAL_HXX
+#define _BIB_GENERAL_HXX
+
+#include <com/sun/star/awt/XFocusListener.hpp>
+#include <com/sun/star/awt/XControlContainer.hpp>
+#include <com/sun/star/form/XBoundComponent.hpp>
+#include <com/sun/star/sdbc/XRowSetListener.hpp>
+#include <svtools/stdctrl.hxx>
+
+#include <vcl/lstbox.hxx>
+#include <vcl/group.hxx>
+#include <svtools/svmedit.hxx>
+#include <vcl/tabpage.hxx>
+#include <vcl/combobox.hxx>
+#include <vcl/scrbar.hxx>
+#include <cppuhelper/implbase1.hxx> // helper for implementations
+#include "bibshortcuthandler.hxx"
+
+
+class BibDataManager;
+#define TYPE_COUNT 22
+#define FIELD_COUNT 31
+
+typedef cppu::WeakAggImplHelper1 < ::com::sun::star::awt::XFocusListener > BibGeneralPageBaseClass;
+
+class BibGeneralPage: public BibGeneralPageBaseClass, public BibTabPage
+{
+ Window aControlParentWin;
+ FixedText aIdentifierFT;
+ FixedText aAuthTypeFT;
+ FixedText aYearFT;
+
+ FixedText aAuthorFT;
+ FixedText aTitleFT;
+
+ FixedText aPublisherFT;
+ FixedText aAddressFT;
+ FixedText aISBNFT;
+
+ FixedText aChapterFT;
+ FixedText aPagesFT;
+ FixedLine aFirstFL;
+
+ FixedText aEditorFT;
+ FixedText aEditionFT;
+
+ FixedText aBooktitleFT;
+ FixedText aVolumeFT;
+ FixedText aHowpublishedFT;
+
+ FixedText aOrganizationsFT;
+ FixedText aInstitutionFT;
+ FixedText aSchoolFT;
+
+ FixedText aReportTypeFT;
+ FixedText aMonthFT;
+ FixedLine aSecondFL;
+
+ FixedText aJournalFT;
+ FixedText aNumberFT;
+ FixedText aSeriesFT;
+
+ FixedText aAnnoteFT;
+ FixedText aNoteFT;
+ FixedText aURLFT;
+ FixedLine aThirdFL;
+
+ FixedText aCustom1FT;
+ FixedText aCustom2FT;
+ FixedText aCustom3FT;
+ FixedText aCustom4FT;
+ FixedText aCustom5FT;
+
+ ScrollBar aHoriScroll;
+ ScrollBar aVertScroll;
+
+ FixedText* aFixedTexts[ FIELD_COUNT ];
+ sal_Int16 nFT2CtrlMap[ FIELD_COUNT ];
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow >
+ aControls[ FIELD_COUNT ];
+
+ Size aStdSize;
+ Point aBasePos;
+
+ String aBibTypeArr[ TYPE_COUNT ];
+ String sErrorPrefix;
+ String sTableErrorString;
+
+ String sTypeColumnName;
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlContainer >
+ xCtrlContnr;
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >
+ xMgr;
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::form::XBoundComponent >
+ xCurrentBoundComponent;
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::form::XBoundComponent >
+ xLBModel;
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRowSetListener >
+ xPosListener;
+
+
+ BibDataManager* pDatMan;
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel >
+ AddXControl( const String& rName, Point aPos, Size aSize, sal_uInt16 nHelpId,
+ sal_Int16& rIndex );
+
+ void AddControlWithError( const rtl::OUString& rColumnName, const Point& rPos,
+ const Size& rSize, String& rErrorString, String aColumnUIName,
+ sal_uInt16 nHelpId, sal_uInt16 nIndexInFTArray );
+
+ void AdjustScrollbars();
+
+ DECL_LINK( ScrollHdl, ScrollBar* );
+
+protected:
+ virtual void Resize();
+ void InitFixedTexts( void ); // create mnemonics and set text an all fixed texts
+
+public:
+ BibGeneralPage(Window* pParent, BibDataManager* pDatMan);
+ virtual ~BibGeneralPage();
+
+ inline const String& GetErrorString() const;
+
+ inline const ::com::sun::star::uno::Reference< ::com::sun::star::form::XBoundComponent >&
+ GetTypeListBoxModel() const;
+ inline const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlContainer >&
+ GetControlContainer() const;
+
+ inline BibDataManager* GetDataManager();
+
+ void CommitActiveControl();
+
+ virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw( com::sun::star::uno::RuntimeException );
+
+ void SAL_CALL focusGained( const ::com::sun::star::awt::FocusEvent& e ) throw( com::sun::star::uno::RuntimeException );
+ void SAL_CALL focusLost( const ::com::sun::star::awt::FocusEvent& e ) throw( com::sun::star::uno::RuntimeException );
+
+ void RemoveListeners();
+
+ virtual void GetFocus();
+
+ virtual BOOL HandleShortCutKey( const KeyEvent& rKeyEvent ); // returns true, if key was handled
+};
+
+
+inline const String& BibGeneralPage::GetErrorString() const
+{
+ return sTableErrorString;
+}
+
+inline const ::com::sun::star::uno::Reference< ::com::sun::star::form::XBoundComponent >&
+ BibGeneralPage::GetTypeListBoxModel() const
+{
+ return xLBModel;
+}
+
+inline const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlContainer >&
+ BibGeneralPage::GetControlContainer() const
+{
+ return xCtrlContnr;
+}
+
+inline BibDataManager* BibGeneralPage::GetDataManager()
+{
+ return pDatMan;
+}
+
+#endif
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/bibliography/hidother.src b/extensions/source/bibliography/hidother.src
new file mode 100644
index 000000000000..57028fb426e1
--- /dev/null
+++ b/extensions/source/bibliography/hidother.src
@@ -0,0 +1,61 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "bibliography.hrc"
+
+hidspecial HID_BIB_IDENTIFIER_POS { HelpID = HID_BIB_IDENTIFIER_POS ; };
+hidspecial HID_BIB_AUTHORITYTYPE_POS { HelpID = HID_BIB_AUTHORITYTYPE_POS ; };
+hidspecial HID_BIB_AUTHOR_POS { HelpID = HID_BIB_AUTHOR_POS ; };
+hidspecial HID_BIB_TITLE_POS { HelpID = HID_BIB_TITLE_POS ; };
+hidspecial HID_BIB_YEAR_POS { HelpID = HID_BIB_YEAR_POS ; };
+hidspecial HID_BIB_ISBN_POS { HelpID = HID_BIB_ISBN_POS ; };
+hidspecial HID_BIB_BOOKTITLE_POS { HelpID = HID_BIB_BOOKTITLE_POS ; };
+hidspecial HID_BIB_CHAPTER_POS { HelpID = HID_BIB_CHAPTER_POS ; };
+hidspecial HID_BIB_EDITION_POS { HelpID = HID_BIB_EDITION_POS ; };
+hidspecial HID_BIB_EDITOR_POS { HelpID = HID_BIB_EDITOR_POS ; };
+hidspecial HID_BIB_HOWPUBLISHED_POS { HelpID = HID_BIB_HOWPUBLISHED_POS ; };
+hidspecial HID_BIB_INSTITUTION_POS { HelpID = HID_BIB_INSTITUTION_POS ; };
+hidspecial HID_BIB_JOURNAL_POS { HelpID = HID_BIB_JOURNAL_POS ; };
+hidspecial HID_BIB_MONTH_POS { HelpID = HID_BIB_MONTH_POS ; };
+hidspecial HID_BIB_NOTE_POS { HelpID = HID_BIB_NOTE_POS ; };
+hidspecial HID_BIB_ANNOTE_POS { HelpID = HID_BIB_ANNOTE_POS ; };
+hidspecial HID_BIB_NUMBER_POS { HelpID = HID_BIB_NUMBER_POS ; };
+hidspecial HID_BIB_ORGANIZATIONS_POS { HelpID = HID_BIB_ORGANIZATIONS_POS ; };
+hidspecial HID_BIB_PAGES_POS { HelpID = HID_BIB_PAGES_POS ; };
+hidspecial HID_BIB_PUBLISHER_POS { HelpID = HID_BIB_PUBLISHER_POS ; };
+hidspecial HID_BIB_ADDRESS_POS { HelpID = HID_BIB_ADDRESS_POS ; };
+hidspecial HID_BIB_SCHOOL_POS { HelpID = HID_BIB_SCHOOL_POS ; };
+hidspecial HID_BIB_SERIES_POS { HelpID = HID_BIB_SERIES_POS ; };
+hidspecial HID_BIB_REPORTTYPE_POS { HelpID = HID_BIB_REPORTTYPE_POS ; };
+hidspecial HID_BIB_VOLUME_POS { HelpID = HID_BIB_VOLUME_POS ; };
+hidspecial HID_BIB_URL_POS { HelpID = HID_BIB_URL_POS ; };
+hidspecial HID_BIB_CUSTOM1_POS { HelpID = HID_BIB_CUSTOM1_POS ; };
+hidspecial HID_BIB_CUSTOM2_POS { HelpID = HID_BIB_CUSTOM2_POS ; };
+hidspecial HID_BIB_CUSTOM3_POS { HelpID = HID_BIB_CUSTOM3_POS ; };
+hidspecial HID_BIB_CUSTOM4_POS { HelpID = HID_BIB_CUSTOM4_POS ; };
+hidspecial HID_BIB_CUSTOM5_POS { HelpID = HID_BIB_CUSTOM5_POS ; };
+hidspecial HID_BIB_DB_GRIDCTRL { HelpID = HID_BIB_DB_GRIDCTRL ; };
diff --git a/extensions/source/bibliography/loadlisteneradapter.cxx b/extensions/source/bibliography/loadlisteneradapter.cxx
new file mode 100644
index 000000000000..928fb020ac4d
--- /dev/null
+++ b/extensions/source/bibliography/loadlisteneradapter.cxx
@@ -0,0 +1,241 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+#include "loadlisteneradapter.hxx"
+#include <osl/diagnose.h>
+#include <rtl/ref.hxx>
+
+//.........................................................................
+namespace bib
+{
+//.........................................................................
+
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::lang;
+ using namespace ::com::sun::star::form;
+
+ //=====================================================================
+ //= OComponentListener
+ //=====================================================================
+ //---------------------------------------------------------------------
+ OComponentListener::~OComponentListener()
+ {
+ {
+ ::osl::MutexGuard aGuard( m_rMutex );
+ if ( m_pAdapter )
+ m_pAdapter->dispose();
+ }
+ }
+
+ //---------------------------------------------------------------------
+ void OComponentListener::_disposing( const EventObject& /*_rSource*/ ) throw( RuntimeException)
+ {
+ // nothing to do here, overrride if you're interested in
+ }
+
+ //---------------------------------------------------------------------
+ void OComponentListener::setAdapter( OComponentAdapterBase* pAdapter )
+ {
+ {
+ ::osl::MutexGuard aGuard( m_rMutex );
+ if ( m_pAdapter )
+ {
+ m_pAdapter->release();
+ m_pAdapter = NULL;
+ }
+ }
+
+ if ( pAdapter )
+ {
+ ::osl::MutexGuard aGuard( m_rMutex );
+ m_pAdapter = pAdapter;
+ m_pAdapter->acquire();
+ }
+ }
+
+ //=====================================================================
+ //= OComponentAdapterBase
+ //=====================================================================
+ //---------------------------------------------------------------------
+ OComponentAdapterBase::OComponentAdapterBase( const Reference< XComponent >& _rxComp, sal_Bool _bAutoRelease )
+ :m_xComponent( _rxComp )
+ ,m_pListener( NULL )
+ ,m_nLockCount( 0 )
+ ,m_bListening( sal_False )
+ ,m_bAutoRelease( _bAutoRelease )
+ {
+ OSL_ENSURE( m_xComponent.is(), "OComponentAdapterBase::OComponentAdapterBase: invalid component!" );
+ }
+
+ //---------------------------------------------------------------------
+ void OComponentAdapterBase::Init( OComponentListener* _pListener )
+ {
+ OSL_ENSURE( !m_pListener, "OComponentAdapterBase::Init: already initialized!" );
+ OSL_ENSURE( _pListener, "OComponentAdapterBase::Init: invalid listener!" );
+
+ m_pListener = _pListener;
+ if ( m_pListener )
+ m_pListener->setAdapter( this );
+
+ startComponentListening( );
+ m_bListening = sal_True;
+ }
+
+ //---------------------------------------------------------------------
+ OComponentAdapterBase::~OComponentAdapterBase()
+ {
+ }
+
+ //---------------------------------------------------------------------
+ void OComponentAdapterBase::dispose()
+ {
+ if ( m_bListening )
+ {
+ ::rtl::Reference< OComponentAdapterBase > xPreventDelete(this);
+
+ disposing();
+
+ m_pListener->setAdapter(NULL);
+
+ m_pListener = NULL;
+ m_bListening = sal_False;
+
+ if (m_bAutoRelease)
+ m_xComponent = NULL;
+ }
+ }
+
+ // XEventListener
+
+ //---------------------------------------------------------------------
+ void SAL_CALL OComponentAdapterBase::disposing( const EventObject& _rSource ) throw( RuntimeException )
+ {
+ if ( m_pListener )
+ {
+ // tell the listener
+ if ( !locked() )
+ m_pListener->_disposing( _rSource );
+
+ // disconnect the listener
+ if ( m_pListener ) // may have been reset whilest calling into _disposing
+ m_pListener->setAdapter( NULL );
+ }
+
+ m_pListener = NULL;
+ m_bListening = sal_False;
+
+ if ( m_bAutoRelease )
+ m_xComponent = NULL;
+ }
+
+ //=====================================================================
+ //= OLoadListenerAdapter
+ //=====================================================================
+ //---------------------------------------------------------------------
+ OLoadListenerAdapter::OLoadListenerAdapter( const Reference< XLoadable >& _rxLoadable, sal_Bool _bAutoRelease )
+ :OComponentAdapterBase( Reference< XComponent >( _rxLoadable, UNO_QUERY ), _bAutoRelease )
+ {
+ }
+
+ //---------------------------------------------------------------------
+ void OLoadListenerAdapter::startComponentListening()
+ {
+ Reference< XLoadable > xLoadable( getComponent(), UNO_QUERY );
+ OSL_ENSURE( xLoadable.is(), "OLoadListenerAdapter::OLoadListenerAdapter: invalid object!" );
+ if ( xLoadable.is() )
+ xLoadable->addLoadListener( this );
+ }
+
+ //---------------------------------------------------------------------
+ void SAL_CALL OLoadListenerAdapter::acquire( ) throw ()
+ {
+ OLoadListenerAdapter_Base::acquire();
+ }
+
+ //---------------------------------------------------------------------
+ void SAL_CALL OLoadListenerAdapter::release( ) throw ()
+ {
+ OLoadListenerAdapter_Base::release();
+ }
+
+ //---------------------------------------------------------------------
+ void SAL_CALL OLoadListenerAdapter::disposing( const EventObject& _rSource ) throw( RuntimeException)
+ {
+ OComponentAdapterBase::disposing( _rSource );
+ }
+
+ //---------------------------------------------------------------------
+ void OLoadListenerAdapter::disposing()
+ {
+ Reference< XLoadable > xLoadable( getComponent(), UNO_QUERY );
+ if ( xLoadable.is() )
+ xLoadable->removeLoadListener( this );
+ }
+
+ //---------------------------------------------------------------------
+ void SAL_CALL OLoadListenerAdapter::loaded( const EventObject& _rEvent ) throw (RuntimeException)
+ {
+ if ( !locked() && getLoadListener( ) )
+ getLoadListener( )->_loaded( _rEvent );
+ }
+
+ //---------------------------------------------------------------------
+ void SAL_CALL OLoadListenerAdapter::unloading( const EventObject& _rEvent ) throw (RuntimeException)
+ {
+ if ( !locked() && getLoadListener( ) )
+ getLoadListener( )->_unloading( _rEvent );
+ }
+
+ //---------------------------------------------------------------------
+ void SAL_CALL OLoadListenerAdapter::unloaded( const EventObject& _rEvent ) throw (RuntimeException)
+ {
+ if ( !locked() && getLoadListener( ) )
+ getLoadListener( )->_unloaded( _rEvent );
+ }
+
+ //---------------------------------------------------------------------
+ void SAL_CALL OLoadListenerAdapter::reloading( const EventObject& _rEvent ) throw (RuntimeException)
+ {
+ if ( !locked() && getLoadListener( ) )
+ getLoadListener( )->_reloading( _rEvent );
+ }
+
+ //---------------------------------------------------------------------
+ void SAL_CALL OLoadListenerAdapter::reloaded( const EventObject& _rEvent ) throw (RuntimeException)
+ {
+ if ( !locked() && getLoadListener( ) )
+ getLoadListener( )->_reloaded( _rEvent );
+ }
+
+//.........................................................................
+} // namespace bib
+//.........................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/bibliography/loadlisteneradapter.hxx b/extensions/source/bibliography/loadlisteneradapter.hxx
new file mode 100644
index 000000000000..c35cb939b5b0
--- /dev/null
+++ b/extensions/source/bibliography/loadlisteneradapter.hxx
@@ -0,0 +1,187 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef EXTENSIONS_BIB_LOADLISTENERADAPTER_HXX
+#define EXTENSIONS_BIB_LOADLISTENERADAPTER_HXX
+
+#include <osl/mutex.hxx>
+#include <com/sun/star/lang/XComponent.hpp>
+#include <cppuhelper/implbase1.hxx>
+#include <com/sun/star/form/XLoadable.hpp>
+
+//.........................................................................
+namespace bib
+{
+//.........................................................................
+
+ class OComponentAdapterBase;
+
+ //=====================================================================
+ //= OComponentListener
+ //=====================================================================
+ class OComponentListener
+ {
+ friend class OComponentAdapterBase;
+
+ private:
+ OComponentAdapterBase* m_pAdapter;
+ ::osl::Mutex& m_rMutex;
+ protected:
+ OComponentListener( ::osl::Mutex& _rMutex )
+ :m_pAdapter( NULL )
+ ,m_rMutex( _rMutex )
+ {
+ }
+
+ virtual ~OComponentListener();
+
+ // XEventListener equivalents
+ virtual void _disposing( const ::com::sun::star::lang::EventObject& _rSource ) throw( ::com::sun::star::uno::RuntimeException );
+
+ protected:
+ void setAdapter( OComponentAdapterBase* _pAdapter );
+ };
+
+ //=====================================================================
+ //= OComponentAdapterBase
+ //=====================================================================
+ class OComponentAdapterBase
+ {
+ friend class OComponentListener;
+
+ private:
+ ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent >
+ m_xComponent;
+ OComponentListener* m_pListener;
+ sal_Int32 m_nLockCount;
+ sal_Bool m_bListening : 1;
+ sal_Bool m_bAutoRelease : 1;
+
+ // impl method for dispose - virtual, 'cause you at least need to remove the listener from the broadcaster
+ virtual void disposing() = 0;
+
+ protected:
+ // attribute access for derivees
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent >&
+ getComponent() const { return m_xComponent; }
+ OComponentListener* getListener() { return m_pListener; }
+
+ // to be called by derivees which started listening at the component
+ virtual void startComponentListening() = 0;
+
+ virtual ~OComponentAdapterBase();
+
+ public:
+ OComponentAdapterBase(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent >& _rxComp,
+ sal_Bool _bAutoRelease = sal_True
+ );
+
+ // late construction
+ // can be called from within you ctor, to have you're object fully initialized at the moment of
+ // the call (which would not be the case when calling this ctor)
+ void Init( OComponentListener* _pListener );
+
+ // base for ref-counting, implemented by OComponentAdapter
+ virtual void SAL_CALL acquire( ) throw () = 0;
+ virtual void SAL_CALL release( ) throw () = 0;
+
+ // helper
+ /// get the lock count
+ sal_Int32 locked() const { return m_nLockCount; }
+
+ /// dispose the object - stop listening and such
+ void dispose();
+
+ protected:
+ // XEventListener
+ virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw( ::com::sun::star::uno::RuntimeException);
+ };
+
+ //=====================================================================
+ //= OLoadListener
+ //=====================================================================
+ class OLoadListener : public OComponentListener
+ {
+ friend class OLoadListenerAdapter;
+
+ protected:
+ OLoadListener( ::osl::Mutex& _rMutex ) : OComponentListener( _rMutex ) { }
+
+ // XLoadListener equivalents
+ virtual void _loaded( const ::com::sun::star::lang::EventObject& aEvent ) = 0;
+ virtual void _unloading( const ::com::sun::star::lang::EventObject& aEvent ) = 0;
+ virtual void _unloaded( const ::com::sun::star::lang::EventObject& aEvent ) = 0;
+ virtual void _reloading( const ::com::sun::star::lang::EventObject& aEvent ) = 0;
+ virtual void _reloaded( const ::com::sun::star::lang::EventObject& aEvent ) = 0;
+ };
+
+ //=====================================================================
+ //= OLoadListenerAdapter
+ //=====================================================================
+ typedef ::cppu::WeakImplHelper1< ::com::sun::star::form::XLoadListener > OLoadListenerAdapter_Base;
+ class OLoadListenerAdapter
+ :public OLoadListenerAdapter_Base
+ ,public OComponentAdapterBase
+ {
+ protected:
+ OLoadListener* getLoadListener( ) { return static_cast< OLoadListener* >( getListener() ); }
+
+ protected:
+ virtual void disposing();
+ virtual void startComponentListening();
+
+ public:
+ OLoadListenerAdapter(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::form::XLoadable >& _rxLoadable,
+ sal_Bool _bAutoRelease = sal_True
+ );
+
+
+ virtual void SAL_CALL acquire( ) throw ();
+ virtual void SAL_CALL release( ) throw ();
+
+ protected:
+ // XEventListener
+ virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& _rSource ) throw( ::com::sun::star::uno::RuntimeException);
+
+ // XLoadListener
+ virtual void SAL_CALL loaded( const ::com::sun::star::lang::EventObject& aEvent ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL unloading( const ::com::sun::star::lang::EventObject& aEvent ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL unloaded( const ::com::sun::star::lang::EventObject& aEvent ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL reloading( const ::com::sun::star::lang::EventObject& aEvent ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL reloaded( const ::com::sun::star::lang::EventObject& aEvent ) throw (::com::sun::star::uno::RuntimeException);
+ };
+
+//.........................................................................
+} // namespace bib
+//.........................................................................
+
+#endif // EXTENSIONS_BIB_LOADLISTENERADAPTER_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/bibliography/makefile.mk b/extensions/source/bibliography/makefile.mk
new file mode 100644
index 000000000000..f25dce11045b
--- /dev/null
+++ b/extensions/source/bibliography/makefile.mk
@@ -0,0 +1,91 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+PRJ=..$/..
+
+PRJNAME=extensions
+TARGET=bib
+ENABLE_EXCEPTIONS=TRUE
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : $(PRJ)$/util$/makefile.pmk
+
+# --- Files --------------------------------------------------------
+
+SLOFILES= $(SLO)$/formcontrolcontainer.obj \
+ $(SLO)$/loadlisteneradapter.obj \
+ $(SLO)$/bibconfig.obj \
+ $(SLO)$/bibcont.obj \
+ $(SLO)$/bibload.obj \
+ $(SLO)$/bibmod.obj \
+ $(SLO)$/general.obj \
+ $(SLO)$/framectr.obj \
+ $(SLO)$/bibview.obj \
+ $(SLO)$/bibbeam.obj \
+ $(SLO)$/toolbar.obj \
+ $(SLO)$/datman.obj \
+
+
+SRS1NAME=$(TARGET)
+SRC1FILES= bib.src \
+ datman.src \
+ sections.src \
+ menu.src \
+ toolbar.src
+
+RESLIB1NAME=bib
+RESLIB1SRSFILES= $(SRS)$/bib.srs
+RESLIB1DEPN= bib.src bib.hrc
+
+
+SHL1STDLIBS= \
+ $(SOTLIB) \
+ $(SVTOOLLIB) \
+ $(TKLIB) \
+ $(VCLLIB) \
+ $(SVLLIB) \
+ $(UNOTOOLSLIB) \
+ $(TOOLSLIB) \
+ $(DBTOOLSLIB) \
+ $(COMPHELPERLIB) \
+ $(CPPUHELPERLIB) \
+ $(CPPULIB) \
+ $(SALLIB)
+
+
+SHL1TARGET= $(TARGET)$(DLLPOSTFIX)
+SHL1LIBS= $(SLB)$/$(TARGET).lib
+SHL1IMPLIB= i$(TARGET)
+SHL1DEPN= $(SHL1LIBS)
+SHL1DEF= $(MISC)$/$(SHL1TARGET).def
+SHL1VERSIONMAP=$(SOLARENV)/src/component.map
+DEF1NAME= $(SHL1TARGET)
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : target.mk
+
diff --git a/extensions/source/bibliography/menu.src b/extensions/source/bibliography/menu.src
new file mode 100644
index 000000000000..6b8adc355fb1
--- /dev/null
+++ b/extensions/source/bibliography/menu.src
@@ -0,0 +1,45 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include <svl/solar.hrc>
+#include <svx/svxids.hrc>
+#ifndef _GLOBLMN_HRC
+#include <svx/globlmn.hrc>
+#endif
+#ifndef _GLOBALACC_SRC
+#include <svx/globlac.hrc>
+#endif
+#include "bibliography.hrc"
+
+#include "bib.hrc"
+
+/*
+
+The menu bar resource has become obsolete. You find the menu bar definition
+now at: <project>/uiconfig/sbibliography/menubar/menubar.xml
+
+*/
diff --git a/extensions/source/bibliography/sections.hrc b/extensions/source/bibliography/sections.hrc
new file mode 100644
index 000000000000..2488f4ed62df
--- /dev/null
+++ b/extensions/source/bibliography/sections.hrc
@@ -0,0 +1,128 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "bib.hrc"
+
+//General
+/*#define FT_FIRST_MIDDLE 1
+#define ED_FIRST 2
+#define ED_MIDDLE 3
+#define FT_NAME_SUFFIX 4
+#define ED_NAME 5
+#define CB_SUFFIX 6
+#define ED_INITIALS 8
+#define FT_COMPANY 9
+#define ED_COMPANY 10
+#define FT_DEPARTMENT 11
+#define ED_DEPARTMENT 12
+#define FT_SALUTATION 13
+#define CB_SALUTATION 14
+#define FT_SHOWNNAME 15
+#define ED_SHOWNNAME 16*/
+#define FT_IDENTIFIER 1
+#define FT_AUTHTYPE 2
+#define FT_AUTHOR 3
+#define FT_YEAR 4
+#define FT_ISBN 5
+
+#define FT_MONTH 6
+
+#define FT_PUBLISHER 8
+
+#define FT_ADDRESS 9
+#define FT_ANNOTE 10
+#define FT_BOOKTITLE 11
+#define FT_CHAPTER 12
+#define FT_EDITION 13
+#define FT_EDITOR 14
+#define FT_HOWPUBLISHED 15
+#define FT_INSTITUTION 16
+#define FT_JOURNAL 17
+#define FT_NOTE 18
+#define FT_NUMBER 19
+#define FT_ORGANIZATION 20
+#define FT_PAGE 21
+#define FT_SCHOOL 22
+#define FT_SERIES 23
+#define FT_TITLE 24
+#define FT_REPORT 25
+#define FT_VOLUME 26
+#define FT_URL 27
+#define FT_CUSTOM1 28
+#define FT_CUSTOM2 29
+#define FT_CUSTOM3 30
+#define FT_CUSTOM4 31
+#define FT_CUSTOM5 32
+#define ST_ERROR_PREFIX 33
+#define FL_1 34
+#define FL_2 35
+#define FL_3 36
+
+//Business Address
+#define FT_OFFICE 1
+#define FT_STREET 2
+#define FT_CITY 3
+#define FT_STATE 4
+#define FT_COUNTRY 5
+#define FT_ZIP 6
+#define ED_OFFICE 7
+#define ED_STREET 8
+#define ED_CITY 9
+#define ED_STATE 10
+#define ED_COUNTRY 11
+#define ED_ZIP 12
+#define ED_POBOX 13
+
+
+//Popup SectionControl
+#define PU_INSERT 1
+#define PU_REMOVE 2
+#define PU_CHG_NAME 3
+
+#define ST_TYPE_ARTICLE 40
+#define ST_TYPE_BOOK 41
+#define ST_TYPE_BOOKLET 42
+#define ST_TYPE_CONFERENCE 43
+#define ST_TYPE_INBOOK 44
+#define ST_TYPE_INCOLLECTION 45
+#define ST_TYPE_INPROCEEDINGS 46
+#define ST_TYPE_JOURNAL 47
+#define ST_TYPE_MANUAL 48
+#define ST_TYPE_MASTERSTHESIS 49
+#define ST_TYPE_MISC 50
+#define ST_TYPE_PHDTHESIS 51
+#define ST_TYPE_PROCEEDINGS 52
+#define ST_TYPE_TECHREPORT 53
+#define ST_TYPE_UNPUBLISHED 54
+#define ST_TYPE_EMAIL 55
+#define ST_TYPE_WWW 56
+#define ST_TYPE_CUSTOM1 57
+#define ST_TYPE_CUSTOM2 58
+#define ST_TYPE_CUSTOM3 59
+#define ST_TYPE_CUSTOM4 60
+#define ST_TYPE_CUSTOM5 61
+
diff --git a/extensions/source/bibliography/sections.src b/extensions/source/bibliography/sections.src
new file mode 100644
index 000000000000..3f7fe83d5fba
--- /dev/null
+++ b/extensions/source/bibliography/sections.src
@@ -0,0 +1,584 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+//#pragma CHARSET_ANSI
+
+#include "sections.hrc"
+#include "bibliography.hrc"
+
+#define FT_POS 12
+#define FTSIZE_LEFT 88
+#define ED_POS_LEFT FT_POS+FTSIZE_LEFT+1
+#define ED_SIZE 70
+#define ED_POS_LEFT2 ED_POS_LEFT + ED_SIZE +1
+#define FT_POS_MIDDLE ED_POS_LEFT2 + 5
+#define FT_POS_RIGHT FT_POS_MIDDLE + FT_POS_MIDDLE - FT_POS
+
+#define FL_POS 6
+#define PAGE_WIDTH FT_POS_RIGHT + FTSIZE_LEFT + (FTSIZE_LEFT * 8 / 10) + FL_POS + 5
+#define FL_WIDTH PAGE_WIDTH - 2 * FL_POS
+
+TabPage RID_TP_GENERAL
+{
+ SVLook = TRUE ;
+ Size = MAP_APPFONT( PAGE_WIDTH, 209 );
+ HelpId = HID_BIB_CONTROL_PAGE;
+
+ FixedText FT_IDENTIFIER
+ {
+ Pos = MAP_APPFONT( FT_POS, 6 );
+ Size = MAP_APPFONT( FTSIZE_LEFT, 10 );
+ Right = TRUE;
+ };
+ FixedText FT_AUTHTYPE
+ {
+ Pos = MAP_APPFONT( FT_POS_MIDDLE, 6 );
+ Size = MAP_APPFONT( FTSIZE_LEFT, 10 );
+ Right = TRUE;
+ };
+ FixedText FT_YEAR
+ {
+ Pos = MAP_APPFONT( FT_POS_RIGHT, 6 );
+ Size = MAP_APPFONT( FTSIZE_LEFT, 10 );
+ Right = TRUE;
+ };
+ FixedText FT_AUTHOR
+ {
+ Pos = MAP_APPFONT( FT_POS, 20 );
+ Size = MAP_APPFONT( FTSIZE_LEFT, 10 );
+ Right = TRUE;
+ };
+ FixedText FT_TITLE
+ {
+ Pos = MAP_APPFONT( FT_POS_MIDDLE, 20 );
+ Size = MAP_APPFONT( FTSIZE_LEFT, 10 );
+ Right = TRUE;
+ };
+ FixedText FT_PUBLISHER
+ {
+ Pos = MAP_APPFONT( FT_POS, 34 );
+ Size = MAP_APPFONT( FTSIZE_LEFT, 10 );
+ Right = TRUE;
+ };
+ FixedText FT_ADDRESS
+ {
+ Pos = MAP_APPFONT( FT_POS_MIDDLE, 34 );
+ Size = MAP_APPFONT( FTSIZE_LEFT, 10 );
+ Right = TRUE;
+ };
+ FixedText FT_ISBN
+ {
+ Pos = MAP_APPFONT( FT_POS_RIGHT, 34 );
+ Size = MAP_APPFONT( FTSIZE_LEFT, 10 );
+ Right = TRUE;
+ };
+ FixedText FT_CHAPTER
+ {
+ Pos = MAP_APPFONT( FT_POS, 48 );
+ Size = MAP_APPFONT( FTSIZE_LEFT, 10 );
+ Right = TRUE;
+ };
+ FixedText FT_PAGE
+ {
+ Pos = MAP_APPFONT( FT_POS_MIDDLE, 48 );
+ Size = MAP_APPFONT( FTSIZE_LEFT, 10 );
+ Right = TRUE;
+ };
+ FixedLine FL_1
+ {
+ Pos = MAP_APPFONT( FL_POS, 62 );
+ Size = MAP_APPFONT( FL_WIDTH, 8 );
+ };
+ FixedText FT_EDITOR
+ {
+ Pos = MAP_APPFONT( FT_POS, 73 );
+ Size = MAP_APPFONT( FTSIZE_LEFT, 10 );
+ Right = TRUE;
+ };
+ FixedText FT_EDITION
+ {
+ Pos = MAP_APPFONT( FT_POS_MIDDLE, 73 );
+ Size = MAP_APPFONT( FTSIZE_LEFT, 10 );
+ Right = TRUE;
+ };
+ FixedText FT_BOOKTITLE
+ {
+ Pos = MAP_APPFONT( FT_POS, 87 );
+ Size = MAP_APPFONT( FTSIZE_LEFT, 10 );
+ Right = TRUE;
+ };
+ FixedText FT_VOLUME
+ {
+ Pos = MAP_APPFONT( FT_POS_MIDDLE, 87 );
+ Size = MAP_APPFONT( FTSIZE_LEFT, 10 );
+ Right = TRUE;
+ };
+ FixedText FT_HOWPUBLISHED
+ {
+ Pos = MAP_APPFONT( FT_POS_RIGHT, 87 );
+ Size = MAP_APPFONT( FTSIZE_LEFT, 10 );
+ Right = TRUE;
+ };
+ FixedText FT_ORGANIZATION
+ {
+ Pos = MAP_APPFONT( FT_POS, 101 );
+ Size = MAP_APPFONT( FTSIZE_LEFT, 10 );
+ Right = TRUE;
+ };
+ FixedText FT_INSTITUTION
+ {
+ Pos = MAP_APPFONT( FT_POS_MIDDLE, 101 );
+ Size = MAP_APPFONT( FTSIZE_LEFT, 10 );
+ Right = TRUE;
+ };
+ FixedText FT_SCHOOL
+ {
+ Pos = MAP_APPFONT( FT_POS_RIGHT, 101 );
+ Size = MAP_APPFONT( FTSIZE_LEFT, 10 );
+ Right = TRUE;
+ };
+ FixedText FT_REPORT
+ {
+ Pos = MAP_APPFONT( FT_POS, 115);
+ Size = MAP_APPFONT( FTSIZE_LEFT, 10 );
+ Right = TRUE;
+ };
+ FixedText FT_MONTH
+ {
+ Pos = MAP_APPFONT( FT_POS_MIDDLE, 115 );
+ Size = MAP_APPFONT( FTSIZE_LEFT, 10 );
+ Right = TRUE;
+ };
+ FixedLine FL_2
+ {
+ Pos = MAP_APPFONT( FL_POS, 129 );
+ Size = MAP_APPFONT( FL_WIDTH, 8 );
+ };
+ FixedText FT_JOURNAL
+ {
+ Pos = MAP_APPFONT( FT_POS, 140 );
+ Size = MAP_APPFONT( FTSIZE_LEFT, 10 );
+ Right = TRUE;
+ };
+
+ FixedText FT_NUMBER
+ {
+ Pos = MAP_APPFONT( FT_POS_MIDDLE, 140 );
+ Size = MAP_APPFONT( FTSIZE_LEFT, 10 );
+ Right = TRUE;
+ };
+ FixedText FT_SERIES
+ {
+ Pos = MAP_APPFONT( FT_POS_RIGHT, 140 );
+ Size = MAP_APPFONT( FTSIZE_LEFT, 10 );
+ Right = TRUE;
+ };
+ FixedText FT_ANNOTE
+ {
+ Pos = MAP_APPFONT( FT_POS, 154 );
+ Size = MAP_APPFONT( FTSIZE_LEFT, 10 );
+ Right = TRUE;
+ };
+ FixedText FT_NOTE
+ {
+ Pos = MAP_APPFONT( FT_POS_MIDDLE, 154 );
+ Size = MAP_APPFONT( FTSIZE_LEFT, 10 );
+ Right = TRUE;
+ };
+ FixedText FT_URL
+ {
+ Pos = MAP_APPFONT( FT_POS_RIGHT, 154 );
+ Size = MAP_APPFONT( FTSIZE_LEFT, 10 );
+ Right = TRUE;
+ };
+ FixedLine FL_3
+ {
+ Pos = MAP_APPFONT( FL_POS, 168 );
+ Size = MAP_APPFONT( FL_WIDTH, 8 );
+ };
+ FixedText FT_CUSTOM1
+ {
+ Pos = MAP_APPFONT( FT_POS, 179 );
+ Size = MAP_APPFONT( FTSIZE_LEFT, 10 );
+ Right = TRUE;
+ };
+ FixedText FT_CUSTOM2
+ {
+ Pos = MAP_APPFONT( FT_POS_MIDDLE, 179 );
+ Size = MAP_APPFONT( FTSIZE_LEFT, 10 );
+ Right = TRUE;
+ };
+ FixedText FT_CUSTOM3
+ {
+ Pos = MAP_APPFONT( FT_POS_RIGHT, 179 );
+ Size = MAP_APPFONT( FTSIZE_LEFT, 10 );
+ Right = TRUE;
+ };
+ FixedText FT_CUSTOM4
+ {
+ Pos = MAP_APPFONT( FT_POS, 193 );
+ Size = MAP_APPFONT( FTSIZE_LEFT, 10 );
+ Right = TRUE;
+ };
+ FixedText FT_CUSTOM5
+ {
+ Pos = MAP_APPFONT( FT_POS_MIDDLE, 193 );
+ Size = MAP_APPFONT( FTSIZE_LEFT, 10 );
+ Right = TRUE;
+ };
+ String ST_ERROR_PREFIX
+ {
+ Text [ en-US ] = "The following column names could not be assigned:\n";
+ };
+ String ST_TYPE_ARTICLE
+ {
+ Text [ en-US ] = "Article";
+ };
+ String ST_TYPE_BOOK
+ {
+ Text [ en-US ] = "Book";
+ };
+ String ST_TYPE_BOOKLET
+ {
+ Text [ en-US ] = "Brochures";
+ };
+ String ST_TYPE_CONFERENCE
+ {
+ Text [ en-US ] = "Conference proceedings";
+ };
+ String ST_TYPE_INBOOK
+ {
+ Text [ en-US ] = "Book excerpt";
+ };
+ String ST_TYPE_INCOLLECTION
+ {
+ Text [ en-US ] = "Book excerpt with title";
+ };
+ String ST_TYPE_INPROCEEDINGS
+ {
+ Text [ en-US ] = "Conference proceedings";
+ };
+ String ST_TYPE_JOURNAL
+ {
+ Text [ en-US ] = "Journal";
+ };
+ String ST_TYPE_MANUAL
+ {
+ Text [ en-US ] = "Techn. documentation";
+ };
+ String ST_TYPE_MASTERSTHESIS
+ {
+ Text [ en-US ] = "Thesis";
+ };
+ String ST_TYPE_MISC
+ {
+ Text [ en-US ] = "Miscellaneous";
+ };
+ String ST_TYPE_PHDTHESIS
+ {
+ Text [ en-US ] = "Dissertation";
+ };
+ String ST_TYPE_PROCEEDINGS
+ {
+ Text [ en-US ] = "Conference proceedings";
+ };
+ String ST_TYPE_TECHREPORT
+ {
+ Text [ en-US ] = "Research report";
+ };
+ String ST_TYPE_UNPUBLISHED
+ {
+ Text [ en-US ] = "Unpublished";
+ };
+ String ST_TYPE_EMAIL
+ {
+ Text [ en-US ] = "e-mail";
+ };
+ String ST_TYPE_WWW
+ {
+ Text [ en-US ] = "WWW document";
+ };
+ String ST_TYPE_CUSTOM1
+ {
+ Text [ en-US ] = "User-defined1";
+ };
+ String ST_TYPE_CUSTOM2
+ {
+ Text [ en-US ] = "User-defined2";
+ };
+ String ST_TYPE_CUSTOM3
+ {
+ Text [ en-US ] = "User-defined3";
+ };
+ String ST_TYPE_CUSTOM4
+ {
+ Text [ en-US ] = "User-defined4";
+ };
+ String ST_TYPE_CUSTOM5
+ {
+ Text [ en-US ] = "User-defined5";
+ };
+ Text [ en-US ] = "General";
+};
+Menu RID_POPUP_ME_VIEW
+{
+ ItemList =
+ {
+ MenuItem
+ {
+ Identifier = PU_INSERT;
+ Text [ en-US ] = "Insert Section...";
+ };
+ MenuItem
+ {
+ Identifier = PU_REMOVE;
+ Text [ en-US ] = "Delete Section...";
+ };
+ MenuItem
+ {
+ Identifier = PU_CHG_NAME;
+ Text [ en-US ] = "Modify Name...";
+ };
+ };
+};
+
+String ST_IDENTIFIER
+{
+ Text [ en-US ] = "~Short name";
+};
+String ST_AUTHTYPE
+{
+ Text [ en-US ] = "~Type";
+};
+String ST_YEAR
+{
+ Text [ en-US ] = "~Year";
+};
+String ST_AUTHOR
+{
+ Text [ en-US ] = "Author(s)";
+};
+String ST_TITLE
+{
+ Text [ en-US ] = "Tit~le";
+};
+String ST_PUBLISHER
+{
+ Text [ en-US ] = "~Publisher";
+};
+String ST_ADDRESS
+{
+ Text [ en-US ] = "A~ddress";
+};
+String ST_ISBN
+{
+ Text [ en-US ] = "~ISBN";
+};
+String ST_CHAPTER
+{
+ Text [ en-US ] = "~Chapter";
+};
+String ST_PAGE
+{
+ Text [ en-US ] = "Pa~ge(s)";
+};
+String ST_EDITOR
+{
+ Text [ en-US ] = "Editor";
+};
+String ST_EDITION
+{
+ Text [ en-US ] = "Ed~ition";
+};
+String ST_BOOKTITLE
+{
+ Text [ en-US ] = "~Book title";
+};
+String ST_VOLUME
+{
+ Text [ en-US ] = "Volume";
+};
+String ST_HOWPUBLISHED
+{
+ Text [ en-US ] = "Publication t~ype";
+};
+String ST_ORGANIZATION
+{
+ Text [ en-US ] = "Organi~zation";
+};
+String ST_INSTITUTION
+{
+ Text [ en-US ] = "Instit~ution";
+};
+String ST_SCHOOL
+{
+ Text [ en-US ] = "University";
+};
+String ST_REPORT
+{
+ Text [ en-US ] = "Type of re~port";
+};
+String ST_MONTH
+{
+ Text [ en-US ] = "~Month";
+};
+String ST_JOURNAL
+{
+ Text [ en-US ] = "~Journal";
+};
+
+String ST_NUMBER
+{
+ Text [ en-US ] = "Numb~er";
+};
+String ST_SERIES
+{
+ Text [ en-US ] = "Se~ries";
+};
+String ST_ANNOTE
+{
+ Text [ en-US ] = "Ann~otation";
+};
+String ST_NOTE
+{
+ Text [ en-US ] = "~Note";
+};
+String ST_URL
+{
+ Text [ en-US ] = "URL";
+};
+String ST_CUSTOM1
+{
+ Text [ en-US ] = "User-defined field ~1";
+};
+String ST_CUSTOM2
+{
+ Text [ en-US ] = "User-defined field ~2";
+};
+String ST_CUSTOM3
+{
+ Text [ en-US ] = "User-defined field ~3";
+};
+String ST_CUSTOM4
+{
+ Text [ en-US ] = "User-defined field ~4";
+};
+String ST_CUSTOM5
+{
+ Text [ en-US ] = "User-defined field ~5";
+};
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/extensions/source/bibliography/toolbar.cxx b/extensions/source/bibliography/toolbar.cxx
new file mode 100644
index 000000000000..dc801d27f808
--- /dev/null
+++ b/extensions/source/bibliography/toolbar.cxx
@@ -0,0 +1,646 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+#include <comphelper/processfactory.hxx>
+#include <osl/mutex.hxx>
+#include <tools/urlobj.hxx>
+#include <com/sun/star/frame/XDispatch.hpp>
+#include <com/sun/star/frame/XDispatchProvider.hpp>
+#include <com/sun/star/util/XURLTransformer.hpp>
+#include <com/sun/star/frame/FrameSearchFlag.hpp>
+#include <datman.hxx>
+#include <tools/debug.hxx>
+#include <svx/svxids.hrc>
+#include <svtools/miscopt.hxx>
+#include <svtools/imgdef.hxx>
+#include <vcl/svapp.hxx>
+#include <vcl/mnemonic.hxx>
+#include "bibbeam.hxx"
+#include "toolbar.hrc"
+#include "bibresid.hxx"
+
+#include "bibtools.hxx"
+#include <osl/mutex.hxx>
+
+using namespace ::rtl;
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+#define C2U(cChar) OUString::createFromAscii(cChar)
+
+
+// Konstanten -------------------------------------------------------------
+
+
+BibToolBarListener::BibToolBarListener(BibToolBar *pTB,rtl::OUString aStr,sal_uInt16 nId):
+ nIndex(nId),
+ aCommand(aStr),
+ pToolBar(pTB)
+{
+}
+
+BibToolBarListener::~BibToolBarListener()
+{
+}
+
+void BibToolBarListener::statusChanged(const ::com::sun::star::frame::FeatureStateEvent& rEvt)throw( ::com::sun::star::uno::RuntimeException )
+{
+ if(rEvt.FeatureURL.Complete == aCommand)
+ {
+ SolarMutexGuard aGuard;
+ pToolBar->EnableItem(nIndex,rEvt.IsEnabled);
+
+ ::com::sun::star::uno::Any aState=rEvt.State;
+ if(aState.getValueType()==::getBooleanCppuType())
+ {
+ sal_Bool bChecked= *(sal_Bool*)aState.getValue();
+ pToolBar->CheckItem(nIndex, bChecked);
+ }
+
+ /*
+ rtl::OUString FeatureDescriptor;
+ sal_Bool Requery;
+ ::com::sun::star::uno::Any State;*/
+ }
+};
+
+rtl::OUString BibToolBarListener::GetCommand()
+{
+ return aCommand;
+}
+
+BibTBListBoxListener::BibTBListBoxListener(BibToolBar *pTB,rtl::OUString aStr,sal_uInt16 nId):
+ BibToolBarListener(pTB,aStr,nId)
+{
+}
+
+BibTBListBoxListener::~BibTBListBoxListener()
+{
+}
+
+void BibTBListBoxListener::statusChanged(const ::com::sun::star::frame::FeatureStateEvent& rEvt)throw( ::com::sun::star::uno::RuntimeException )
+{
+ if(rEvt.FeatureURL.Complete == GetCommand())
+ {
+ SolarMutexGuard aGuard;
+ pToolBar->EnableSourceList(rEvt.IsEnabled);
+
+ Any aState = rEvt.State;
+ if(aState.getValueType() == ::getCppuType((Sequence<rtl::OUString>*)0))
+ {
+ pToolBar->UpdateSourceList(sal_False);
+ pToolBar->ClearSourceList();
+
+ Sequence<rtl::OUString>* pStringSeq = (Sequence<rtl::OUString>*)aState.getValue();
+ const rtl::OUString* pStringArray = (const rtl::OUString*)pStringSeq->getConstArray();
+
+ sal_uInt32 nCount = pStringSeq->getLength();
+ XubString aEntry;
+ for( sal_uInt32 i=0; i<nCount; i++ )
+ {
+ aEntry = String(pStringArray[i]);
+ pToolBar->InsertSourceEntry(aEntry);
+ }
+ pToolBar->UpdateSourceList(sal_True);
+ }
+
+ XubString aStr = String(rEvt.FeatureDescriptor);
+ pToolBar->SelectSourceEntry(aStr);
+ }
+};
+
+BibTBQueryMenuListener::BibTBQueryMenuListener(BibToolBar *pTB,rtl::OUString aStr,sal_uInt16 nId):
+ BibToolBarListener(pTB,aStr,nId)
+{
+}
+
+BibTBQueryMenuListener::~BibTBQueryMenuListener()
+{
+}
+
+void BibTBQueryMenuListener::statusChanged(const frame::FeatureStateEvent& rEvt)throw( uno::RuntimeException )
+{
+ if(rEvt.FeatureURL.Complete == GetCommand())
+ {
+ SolarMutexGuard aGuard;
+ pToolBar->EnableSourceList(rEvt.IsEnabled);
+
+ uno::Any aState=rEvt.State;
+ if(aState.getValueType()==::getCppuType((Sequence<rtl::OUString>*)0))
+ {
+ pToolBar->ClearFilterMenu();
+
+ Sequence<rtl::OUString>* pStringSeq = (Sequence<rtl::OUString>*) aState.getValue();
+ const rtl::OUString* pStringArray = (const rtl::OUString*)pStringSeq->getConstArray();
+
+ sal_uInt32 nCount = pStringSeq->getLength();
+ for( sal_uInt32 i=0; i<nCount; i++ )
+ {
+ sal_uInt16 nID=pToolBar->InsertFilterItem(String(pStringArray[i]));
+ if(pStringArray[i]==rEvt.FeatureDescriptor)
+ {
+// XubString aStr = rEvt.FeatureDescriptor;
+ pToolBar->SelectFilterItem(nID);
+ }
+ }
+ }
+ }
+};
+
+BibTBEditListener::BibTBEditListener(BibToolBar *pTB,rtl::OUString aStr,sal_uInt16 nId):
+ BibToolBarListener(pTB,aStr,nId)
+{
+}
+
+BibTBEditListener::~BibTBEditListener()
+{
+}
+
+void BibTBEditListener::statusChanged(const frame::FeatureStateEvent& rEvt)throw( uno::RuntimeException )
+{
+ if(rEvt.FeatureURL.Complete == GetCommand())
+ {
+ SolarMutexGuard aGuard;
+ pToolBar->EnableQuery(rEvt.IsEnabled);
+
+ uno::Any aState=rEvt.State;
+ if(aState.getValueType()==::getCppuType((const OUString*)0))
+ {
+ String aStr = String(*(OUString*) aState.getValue());
+ pToolBar->SetQueryString(aStr);
+ }
+ }
+}
+
+SV_IMPL_PTRARR( BibToolBarListenerArr, BibToolBarListenerPtr);
+
+BibToolBar::BibToolBar(Window* pParent, Link aLink, WinBits nStyle):
+ ToolBox(pParent,BibResId(RID_BIB_TOOLBAR)),
+ aImgLst(BibResId( RID_TOOLBAR_IMGLIST )),
+ aImgLstHC(BibResId(RID_TOOLBAR_IMGLIST_HC )),
+ aBigImgLst(BibResId( RID_TOOLBAR_BIGIMGLIST )),
+ aBigImgLstHC(BibResId( RID_TOOLBAR_BIGIMGLIST_HC )),
+ aFtSource(this,WB_VCENTER),
+ aLBSource(this,WB_DROPDOWN),
+ aFtQuery(this,WB_VCENTER),
+ aEdQuery(this),
+ nMenuId(0),
+ nSelMenuItem(0),
+ aLayoutManager( aLink ),
+ nSymbolsSize( SFX_SYMBOLS_SIZE_SMALL ),
+ nOutStyle( 0 )
+{
+ SvtMiscOptions aSvtMiscOptions;
+ nSymbolsSize = aSvtMiscOptions.GetCurrentSymbolsSize();
+ nOutStyle = aSvtMiscOptions.GetToolboxStyle();
+
+ ApplyImageList();
+ SetStyle(GetStyle()|nStyle);
+ SetOutStyle(TOOLBOX_STYLE_FLAT);
+ Size aSize=GetSizePixel();
+ Size a2Size(GetOutputSizePixel());
+ a2Size.Width()=100;
+ aLBSource.SetSizePixel(a2Size);
+ aLBSource.SetDropDownLineCount(9);
+ aLBSource.Show();
+ aLBSource.SetSelectHdl(LINK( this, BibToolBar, SelHdl));
+
+ SvtMiscOptions().AddListenerLink( LINK( this, BibToolBar, OptionsChanged_Impl ) );
+ Application::AddEventListener( LINK( this, BibToolBar, SettingsChanged_Impl ) );
+
+ aTimer.SetTimeoutHdl(LINK( this, BibToolBar, SendSelHdl));
+ aTimer.SetTimeout(400);
+
+ SetDropdownClickHdl( LINK( this, BibToolBar, MenuHdl));
+
+ aEdQuery.SetSizePixel(aLBSource.GetSizePixel());
+ aEdQuery.Show();
+
+ XubString aStr=GetItemText(TBC_FT_SOURCE);
+ Rectangle aRect=GetItemRect(TBC_FT_SOURCE);
+ aFtSource.SetText(aStr);
+ aFtSource.SetSizePixel(aRect.GetSize());
+ aFtSource.SetBackground(Wallpaper( COL_TRANSPARENT ));
+
+ aStr=GetItemText(TBC_FT_QUERY);
+ aRect=GetItemRect(TBC_FT_QUERY);
+ aFtQuery.SetText(aStr);
+ aFtQuery.SetSizePixel(aRect.GetSize());
+ aFtQuery.SetBackground(Wallpaper( COL_TRANSPARENT ));
+
+ SetItemWindow(TBC_FT_SOURCE,&aFtSource);
+ SetItemWindow(TBC_LB_SOURCE,&aLBSource);
+ SetItemWindow(TBC_FT_QUERY ,&aFtQuery);
+ SetItemWindow(TBC_ED_QUERY ,&aEdQuery);
+
+ ::bib::AddToTaskPaneList( this );
+}
+
+BibToolBar::~BibToolBar()
+{
+ SvtMiscOptions().RemoveListenerLink( LINK( this, BibToolBar, OptionsChanged_Impl ) );
+ Application::RemoveEventListener( LINK( this, BibToolBar, SettingsChanged_Impl ) );
+ ::bib::RemoveFromTaskPaneList( this );
+}
+
+void BibToolBar::InitListener()
+{
+ sal_uInt16 nCount=GetItemCount();
+
+ uno::Reference< lang::XMultiServiceFactory > xMgr = comphelper::getProcessServiceFactory();
+ uno::Reference< frame::XDispatch > xDisp(xController,UNO_QUERY);
+
+ uno::Reference< util::XURLTransformer > xTrans ( xMgr->createInstance( C2U("com.sun.star.util.URLTransformer") ), UNO_QUERY );
+ if( xTrans.is() )
+ {
+ util::URL aQueryURL;
+ aQueryURL.Complete = C2U(".uno:Bib/MenuFilter");
+ xTrans->parseStrict( aQueryURL);
+ BibToolBarListener* pQuery=new BibTBQueryMenuListener(this,aQueryURL.Complete,TBC_BT_AUTOFILTER);
+ xDisp->addStatusListener(uno::Reference< frame::XStatusListener > (pQuery),aQueryURL);
+
+ for(sal_uInt16 nPos=0;nPos<nCount;nPos++)
+ {
+ sal_uInt16 nId=GetItemId(nPos);
+ if(!nId || nId==TBC_FT_SOURCE || nId==TBC_FT_QUERY)
+ continue;
+
+ util::URL aURL;
+ aURL.Complete = GetItemCommand(nId);
+ if(!aURL.Complete.getLength())
+ continue;
+
+ xTrans->parseStrict( aURL );
+
+ BibToolBarListener* pListener=NULL;
+ if(nId==TBC_LB_SOURCE)
+ {
+ pListener=new BibTBListBoxListener(this,aURL.Complete,nId);
+ }
+ else if(nId==TBC_ED_QUERY)
+ {
+ pListener=new BibTBEditListener(this,aURL.Complete,nId);
+ }
+ else
+ {
+ pListener=new BibToolBarListener(this,aURL.Complete,nId);
+ }
+
+ BibToolBarListenerPtr pxInsert = new Reference<frame::XStatusListener>;
+ (*pxInsert) = pListener;
+ aListenerArr.Insert( pxInsert, aListenerArr.Count() );
+ xDisp->addStatusListener(uno::Reference< frame::XStatusListener > (pListener),aURL);
+ }
+ }
+}
+
+void BibToolBar::SetXController(const uno::Reference< frame::XController > & xCtr)
+{
+ xController=xCtr;
+ InitListener();
+
+}
+
+void BibToolBar::Select()
+{
+ sal_uInt16 nId=GetCurItemId();
+
+ if(nId!=TBC_BT_AUTOFILTER)
+ {
+ SendDispatch(nId,Sequence<PropertyValue>() );
+ }
+ else
+ {
+ Sequence<PropertyValue> aPropVal(2);
+ PropertyValue* pPropertyVal = (PropertyValue*)aPropVal.getConstArray();
+ pPropertyVal[0].Name=C2U("QueryText");
+ rtl::OUString aSelection = aEdQuery.GetText();
+ pPropertyVal[0].Value <<= aSelection;
+
+ pPropertyVal[1].Name=C2U("QueryField");
+ pPropertyVal[1].Value <<= aQueryField;
+ SendDispatch(nId,aPropVal);
+ }
+}
+
+void BibToolBar::SendDispatch(sal_uInt16 nId, const Sequence< PropertyValue >& rArgs)
+{
+ rtl::OUString aCommand = GetItemCommand(nId);
+
+ uno::Reference< frame::XDispatchProvider > xDSP( xController, UNO_QUERY );
+
+ if( xDSP.is() && aCommand.getLength())
+ {
+ uno::Reference< lang::XMultiServiceFactory > xMgr = comphelper::getProcessServiceFactory();
+
+ uno::Reference< util::XURLTransformer > xTrans ( xMgr->createInstance( C2U("com.sun.star.util.URLTransformer") ), UNO_QUERY );
+ if( xTrans.is() )
+ {
+ // Datei laden
+ util::URL aURL;
+ aURL.Complete = aCommand;
+
+ xTrans->parseStrict( aURL );
+
+ uno::Reference< frame::XDispatch > xDisp = xDSP->queryDispatch( aURL, rtl::OUString(), frame::FrameSearchFlag::SELF );
+
+ if ( xDisp.is() )
+ xDisp->dispatch( aURL, rArgs);
+ }
+ }
+
+}
+
+void BibToolBar::Click()
+{
+ sal_uInt16 nId=GetCurItemId();
+
+ if(nId == TBC_BT_COL_ASSIGN )
+ {
+ if(pDatMan)
+ pDatMan->CreateMappingDialog(GetParent());
+ CheckItem( nId, FALSE );
+ }
+ else if(nId == TBC_BT_CHANGESOURCE)
+ {
+ if(pDatMan)
+ {
+ OUString sNew = pDatMan->CreateDBChangeDialog(GetParent());
+ if(sNew.getLength())
+ pDatMan->setActiveDataSource(sNew);
+ }
+ CheckItem( nId, FALSE );
+ }
+}
+
+void BibToolBar::ClearFilterMenu()
+{
+ aPopupMenu.Clear();
+ nMenuId=0;
+}
+sal_uInt16 BibToolBar::InsertFilterItem(const XubString& aMenuEntry)
+{
+ nMenuId++;
+ aPopupMenu.InsertItem(nMenuId,aMenuEntry);
+
+ return nMenuId;
+}
+void BibToolBar::SelectFilterItem(sal_uInt16 nId)
+{
+ aPopupMenu.CheckItem(nId);
+ nSelMenuItem=nId;
+ aQueryField = MnemonicGenerator::EraseAllMnemonicChars( aPopupMenu.GetItemText(nId) );
+}
+
+void BibToolBar::EnableSourceList(sal_Bool bFlag)
+{
+ aFtSource.Enable(bFlag);
+ aLBSource.Enable(bFlag);
+}
+
+void BibToolBar::ClearSourceList()
+{
+ aLBSource.Clear();
+}
+
+void BibToolBar::UpdateSourceList(sal_Bool bFlag)
+{
+ aLBSource.SetUpdateMode(bFlag);
+}
+
+void BibToolBar::InsertSourceEntry(const XubString& aEntry, sal_uInt16 nPos)
+{
+ aLBSource.InsertEntry(aEntry, nPos);
+}
+
+void BibToolBar::SelectSourceEntry(const XubString& aStr)
+{
+ aLBSource.SelectEntry(aStr);
+}
+
+void BibToolBar::EnableQuery(sal_Bool bFlag)
+{
+ aFtQuery.Enable(bFlag);
+ aEdQuery.Enable(bFlag);
+}
+
+void BibToolBar::SetQueryString(const XubString& aStr)
+{
+ aEdQuery.SetText(aStr);
+}
+
+
+long BibToolBar::PreNotify( NotifyEvent& rNEvt )
+{
+ long nResult=sal_True;
+
+ sal_uInt16 nSwitch=rNEvt.GetType();
+ if(aEdQuery.HasFocus() && nSwitch==EVENT_KEYINPUT)// || nSwitch==EVENT_KEYUP)
+ {
+ const KeyCode& aKeyCode=rNEvt.GetKeyEvent()->GetKeyCode();
+ sal_uInt16 nKey = aKeyCode.GetCode();
+ if(nKey == KEY_RETURN)
+ {
+ Sequence<PropertyValue> aPropVal(2);
+ PropertyValue* pPropertyVal = (PropertyValue*)aPropVal.getConstArray();
+ pPropertyVal[0].Name = C2U("QueryText");
+ rtl::OUString aSelection = aEdQuery.GetText();
+ pPropertyVal[0].Value <<= aSelection;
+ pPropertyVal[1].Name=C2U("QueryField");
+ pPropertyVal[1].Value <<= aQueryField;
+ SendDispatch(TBC_BT_AUTOFILTER,aPropVal);
+ return nResult;
+ }
+
+ }
+
+ nResult=ToolBox::PreNotify(rNEvt);
+
+ return nResult;
+}
+
+IMPL_LINK( BibToolBar, SelHdl, ListBox*, /*pLb*/ )
+{
+ aTimer.Start();
+ return 0;
+}
+
+IMPL_LINK( BibToolBar, SendSelHdl, Timer*,/*pT*/)
+{
+ Sequence<PropertyValue> aPropVal(1);
+ PropertyValue* pPropertyVal = (PropertyValue*)aPropVal.getConstArray();
+ pPropertyVal[0].Name = C2U("DataSourceName");
+ String aEntry( MnemonicGenerator::EraseAllMnemonicChars( aLBSource.GetSelectEntry() ) );
+ rtl::OUString aSelection = aEntry;
+ pPropertyVal[0].Value <<= aSelection;
+ SendDispatch(TBC_LB_SOURCE,aPropVal);
+
+ return 0;
+}
+//-----------------------------------------------------------------------------
+IMPL_LINK( BibToolBar, MenuHdl, ToolBox*, /*pToolbox*/)
+{
+ sal_uInt16 nId=GetCurItemId();
+ if(nId==TBC_BT_AUTOFILTER)
+ {
+ EndSelection(); // vor SetDropMode (SetDropMode ruft SetItemImage)
+
+ SetItemDown(TBC_BT_AUTOFILTER,sal_True);
+ nId = aPopupMenu.Execute(this, GetItemRect(TBC_BT_AUTOFILTER));
+
+
+ if(nId>0)
+ {
+ aPopupMenu.CheckItem(nSelMenuItem,sal_False);
+ aPopupMenu.CheckItem(nId);
+ nSelMenuItem=nId;
+ aQueryField = MnemonicGenerator::EraseAllMnemonicChars( aPopupMenu.GetItemText(nId) );
+ Sequence<PropertyValue> aPropVal(2);
+ PropertyValue* pPropertyVal = (PropertyValue*)aPropVal.getConstArray();
+ pPropertyVal[0].Name = C2U("QueryText");
+ rtl::OUString aSelection = aEdQuery.GetText();
+ pPropertyVal[0].Value <<= aSelection;
+ pPropertyVal[1].Name=C2U("QueryField");
+ pPropertyVal[1].Value <<= aQueryField;
+ SendDispatch(TBC_BT_AUTOFILTER,aPropVal);
+ }
+
+ Point aPoint;
+ MouseEvent aLeave( aPoint, 0, MOUSE_LEAVEWINDOW | MOUSE_SYNTHETIC );
+ MouseMove( aLeave );
+ SetItemDown(TBC_BT_AUTOFILTER,sal_False);
+
+
+ }
+ return 0;
+}
+//-----------------------------------------------------------------------------
+void BibToolBar::statusChanged(const frame::FeatureStateEvent& rEvent)
+ throw( uno::RuntimeException )
+{
+ for(sal_uInt16 i = 0; i < aListenerArr.Count(); i++)
+ {
+ BibToolBarListenerPtr pListener = aListenerArr.GetObject(i);
+ (*pListener)->statusChanged(rEvent);
+ }
+}
+/* -----------------------------07.05.2002 15:08------------------------------
+
+ ---------------------------------------------------------------------------*/
+void BibToolBar::DataChanged( const DataChangedEvent& rDCEvt )
+{
+ if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) &&
+ (rDCEvt.GetFlags() & SETTINGS_STYLE) )
+ ApplyImageList();
+ ToolBox::DataChanged( rDCEvt );
+}
+/* -----------------------------07.05.2002 15:09------------------------------
+ ---------------------------------------------------------------------------*/
+
+IMPL_LINK( BibToolBar, OptionsChanged_Impl, void*, /*pVoid*/ )
+{
+ sal_Bool bRebuildToolBar = sal_False;
+ sal_Int16 eSymbolsSize = SvtMiscOptions().GetCurrentSymbolsSize();
+ if ( nSymbolsSize != eSymbolsSize )
+ {
+ nSymbolsSize = eSymbolsSize;
+ bRebuildToolBar = sal_True;
+ }
+ else if ( nOutStyle != SvtMiscOptions().GetToolboxStyle() )
+ {
+ nOutStyle = SvtMiscOptions().GetToolboxStyle();
+ SetOutStyle( nOutStyle );
+ bRebuildToolBar = sal_True;
+ }
+
+ if ( bRebuildToolBar )
+ RebuildToolbar();
+
+ return 0L;
+}
+
+//-----------------------------------------------------------------------------
+
+IMPL_LINK( BibToolBar, SettingsChanged_Impl, void*, /*pVoid*/ )
+{
+ // Check if toolbar button size have changed and we have to use system settings
+ sal_Int16 eSymbolsSize = SvtMiscOptions().GetCurrentSymbolsSize();
+ if ( eSymbolsSize != nSymbolsSize )
+ {
+ nSymbolsSize = eSymbolsSize;
+ RebuildToolbar();
+ }
+
+ return 0L;
+}
+
+//-----------------------------------------------------------------------------
+void BibToolBar::RebuildToolbar()
+{
+ ApplyImageList();
+ // We have to call parent asynchronously as SetSize works also asynchronously!
+ Application::PostUserEvent( aLayoutManager, 0 );
+}
+
+//-----------------------------------------------------------------------------
+
+void BibToolBar::ApplyImageList()
+{
+ ImageList& rList = ( nSymbolsSize == SFX_SYMBOLS_SIZE_SMALL ) ?
+ ( GetSettings().GetStyleSettings().GetHighContrastMode() ? aImgLstHC : aImgLst ) :
+ ( GetSettings().GetStyleSettings().GetHighContrastMode() ? aBigImgLstHC : aBigImgLst );
+
+ SetItemImage(TBC_BT_AUTOFILTER , rList.GetImage(SID_FM_AUTOFILTER));
+ SetItemImage(TBC_BT_FILTERCRIT , rList.GetImage(SID_FM_FILTERCRIT));
+ SetItemImage(TBC_BT_REMOVEFILTER, rList.GetImage(SID_FM_REMOVE_FILTER_SORT ));
+ AdjustToolBox();
+}
+
+void BibToolBar::AdjustToolBox()
+{
+ Size aOldSize = GetSizePixel();
+ Size aSize = CalcWindowSizePixel();
+ if ( !aSize.Width() )
+ aSize.Width() = aOldSize.Width();
+ else if ( !aSize.Height() )
+ aSize.Height() = aOldSize.Height();
+
+ Size aTbSize = GetSizePixel();
+ if (
+ (aSize.Width() && aSize.Width() != aTbSize.Width()) ||
+ (aSize.Height() && aSize.Height() != aTbSize.Height())
+ )
+ {
+ SetPosSizePixel( GetPosPixel(), aSize );
+ Invalidate();
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/bibliography/toolbar.hrc b/extensions/source/bibliography/toolbar.hrc
new file mode 100644
index 000000000000..7349bd2c2aae
--- /dev/null
+++ b/extensions/source/bibliography/toolbar.hrc
@@ -0,0 +1,46 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#include "bib.hrc"
+
+#define TBC_FT_SOURCE 1
+#define TBC_LB_SOURCE 2
+#define TBC_FT_QUERY 3
+#define TBC_ED_QUERY 4
+#define TBC_BT_AUTOFILTER 5
+#define TBC_BT_FILTERCRIT 6
+#define TBC_BT_REMOVEFILTER 7
+#define TBC_BT_NEWCARD 8
+#define TBC_BT_EDITCARD 9
+#define TBC_BT_REMOVECARD 10
+#define TBC_BT_INSERT 11
+#define TBC_BT_UPDATE 12
+#define TBC_BT_MAIL 13
+#define TBC_BT_URL 14
+#define TBC_BT_COL_ASSIGN 15
+#define TBC_BT_CHANGESOURCE 16
+#define IL_TOOLBOX 17
+#define ILH_TOOLBOX 18
diff --git a/extensions/source/bibliography/toolbar.hxx b/extensions/source/bibliography/toolbar.hxx
new file mode 100644
index 000000000000..07775e31f121
--- /dev/null
+++ b/extensions/source/bibliography/toolbar.hxx
@@ -0,0 +1,192 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _BIB_TOOLBAR_HXX
+#define _BIB_TOOLBAR_HXX
+
+#include <com/sun/star/frame/XController.hpp>
+#include <com/sun/star/frame/XStatusListener.hpp>
+
+
+#include <vcl/toolbox.hxx>
+#include <vcl/lstbox.hxx>
+#include <vcl/edit.hxx>
+#include <vcl/fixed.hxx>
+#include <svl/svarray.hxx>
+#include <vcl/timer.hxx>
+#include <cppuhelper/implbase1.hxx> // helper for implementations
+
+class BibDataManager;
+class BibToolBar;
+
+class BibToolBarListener: public cppu::WeakImplHelper1 < ::com::sun::star::frame::XStatusListener>
+{
+private:
+
+ sal_uInt16 nIndex;
+ rtl::OUString aCommand;
+
+protected:
+
+ BibToolBar *pToolBar;
+
+public:
+
+ BibToolBarListener(BibToolBar *pTB,rtl::OUString aStr,sal_uInt16 nId);
+ ~BibToolBarListener();
+
+ rtl::OUString GetCommand();
+
+ // ::com::sun::star::lang::XEventListener
+ // we do not hold References to dispatches, so there is nothing to do on disposal
+ virtual void SAL_CALL disposing(const ::com::sun::star::lang::EventObject& /*Source*/)
+ throw( ::com::sun::star::uno::RuntimeException ){};
+
+ // ::com::sun::star::frame::XStatusListener
+ virtual void SAL_CALL statusChanged(const ::com::sun::star::frame::FeatureStateEvent& Event)
+ throw( ::com::sun::star::uno::RuntimeException );
+
+};
+
+class BibTBListBoxListener: public BibToolBarListener
+{
+public:
+
+ BibTBListBoxListener(BibToolBar *pTB,rtl::OUString aStr,sal_uInt16 nId);
+ ~BibTBListBoxListener();
+
+ virtual void SAL_CALL statusChanged(const ::com::sun::star::frame::FeatureStateEvent& Event)
+ throw( ::com::sun::star::uno::RuntimeException );
+
+};
+
+class BibTBEditListener: public BibToolBarListener
+{
+public:
+
+ BibTBEditListener(BibToolBar *pTB,rtl::OUString aStr,sal_uInt16 nId);
+ ~BibTBEditListener();
+
+ virtual void SAL_CALL statusChanged(const ::com::sun::star::frame::FeatureStateEvent& Event)
+ throw( ::com::sun::star::uno::RuntimeException );
+
+};
+
+class BibTBQueryMenuListener: public BibToolBarListener
+{
+public:
+
+ BibTBQueryMenuListener(BibToolBar *pTB,rtl::OUString aStr,sal_uInt16 nId);
+ ~BibTBQueryMenuListener();
+
+ virtual void SAL_CALL statusChanged(const ::com::sun::star::frame::FeatureStateEvent& Event)
+ throw( ::com::sun::star::uno::RuntimeException );
+
+};
+
+
+typedef ::com::sun::star::uno::Reference< ::com::sun::star::frame::XStatusListener>* BibToolBarListenerPtr;
+SV_DECL_PTRARR_DEL( BibToolBarListenerArr, BibToolBarListenerPtr, 4, 4 )
+
+class BibToolBar: public ToolBox
+{
+ private:
+
+ BibToolBarListenerArr aListenerArr;
+ ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController > xController;
+ Timer aTimer;
+// Timer aMenuTimer;
+ ImageList aImgLst;
+ ImageList aImgLstHC;
+ ImageList aBigImgLst;
+ ImageList aBigImgLstHC;
+ FixedText aFtSource;
+ ListBox aLBSource;
+ FixedText aFtQuery;
+ Edit aEdQuery;
+ PopupMenu aPopupMenu;
+ sal_uInt16 nMenuId;
+ sal_uInt16 nSelMenuItem;
+ rtl::OUString aQueryField;
+ Link aLayoutManager;
+ sal_Int16 nSymbolsSize;
+ sal_Int16 nOutStyle;
+
+ BibDataManager* pDatMan;
+ DECL_LINK( SelHdl, ListBox* );
+ DECL_LINK( SendSelHdl, Timer* );
+ DECL_LINK( MenuHdl, ToolBox* );
+ DECL_LINK( OptionsChanged_Impl, void* );
+ DECL_LINK( SettingsChanged_Impl, void* );
+
+ void ApplyImageList();
+ void RebuildToolbar();
+
+ protected:
+
+ void DataChanged( const DataChangedEvent& rDCEvt );
+ void InitListener();
+ virtual void Select();
+ virtual void Click();
+ long PreNotify( NotifyEvent& rNEvt );
+
+
+ public:
+
+ BibToolBar(Window* pParent, Link aLink, WinBits nStyle = WB_3DLOOK );
+ ~BibToolBar();
+
+ void SetXController(const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController > &);
+
+ void ClearSourceList();
+ void UpdateSourceList(sal_Bool bFlag=sal_True);
+ void EnableSourceList(sal_Bool bFlag=sal_True);
+ void InsertSourceEntry(const XubString&,sal_uInt16 nPos=LISTBOX_APPEND );
+ void SelectSourceEntry(const XubString& );
+
+ void EnableQuery(sal_Bool bFlag=sal_True);
+ void SetQueryString(const XubString& );
+ void AdjustToolBox();
+
+ void ClearFilterMenu();
+ sal_uInt16 InsertFilterItem(const XubString& );
+ void SelectFilterItem(sal_uInt16 nId);
+
+ void statusChanged(const ::com::sun::star::frame::FeatureStateEvent& Event)
+ throw( ::com::sun::star::uno::RuntimeException );
+
+ void SetDatMan(BibDataManager& rDatMan) {pDatMan = &rDatMan;}
+ void SendDispatch(sal_uInt16 nId, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& rArgs);
+};
+
+
+
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/bibliography/toolbar.src b/extensions/source/bibliography/toolbar.src
new file mode 100644
index 000000000000..9016a4570b8b
--- /dev/null
+++ b/extensions/source/bibliography/toolbar.src
@@ -0,0 +1,241 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#include <svx/svxids.hrc>
+#include "bibliography.hrc"
+#include "toolbar.hrc"
+
+#define MASKCOLOR MaskColor = Color { Red = 0xFFFF; Green = 0x0000; Blue = 0xFFFF; };
+
+ToolBox RID_BIB_TOOLBAR
+{
+ HelpId = HID_BIB_DB_TBX;
+ Sizeable = TRUE ;
+ HideWhenDeactivate = TRUE ;
+ LineSpacing = TRUE ;
+ Border = TRUE ;
+ SVLook = TRUE ;
+ Pos = MAP_APPFONT ( 0 , 0 ) ;
+ Size = MAP_APPFONT ( 200 , 16 ) ;
+ ButtonType = BUTTON_SYMBOL ;
+ ItemList =
+ {
+ ToolBoxItem
+ {
+ Identifier = TBC_FT_SOURCE;
+ //HelpID = SID_SBA_BRW_INSERT ;
+ Text [ en-US ] = "Table";
+ };
+ ToolBoxItem
+ {
+ Identifier = TBC_LB_SOURCE;
+ HelpID = HID_BIB_TBX_TABLE;
+ Command = ".uno:Bib/source" ;
+ };
+ ToolBoxItem
+ {
+ Type = TOOLBOXITEM_SEPARATOR ;
+ };
+
+ ToolBoxItem
+ {
+ Identifier = TBC_FT_QUERY;
+ //HelpID = SID_SBA_BRW_INSERT ;
+ Text [ en-US ] = "Search Key";
+ };
+ ToolBoxItem
+ {
+ Identifier = TBC_ED_QUERY;
+ HelpID = HID_BIB_TBX_SEARCH;
+ Command = ".uno:Bib/query" ;
+ };
+ ToolBoxItem
+ {
+ Type = TOOLBOXITEM_SEPARATOR ;
+ };
+
+ ToolBoxItem
+ {
+ Identifier = TBC_BT_AUTOFILTER ;
+ HelpID = HID_BIB_TBX_AUTOFILTER;
+// ItemBitmap = Bitmap { File = "sc10716.bmp" ; };
+ DropDown = TRUE ;
+ Command = ".uno:Bib/autoFilter" ;
+ Text [ en-US ] = "AutoFilter";
+ };
+
+ ToolBoxItem
+ {
+ Identifier = TBC_BT_FILTERCRIT ;
+ HelpID = SID_FM_FILTERCRIT ;
+// ItemBitmap = Bitmap { File = "sc10715.bmp" ; };
+// Text [ de ] = "Standard Filter" ;
+ Command = ".uno:Bib/standardFilter" ;
+ Text [ en-US ] = "Standard Filter";
+ };
+
+ ToolBoxItem
+ {
+ Identifier = TBC_BT_REMOVEFILTER ;
+ HelpID = SID_FM_REMOVE_FILTER_SORT ;
+// ItemBitmap = Bitmap { File = "sc10711.bmp" ; };
+ Command = ".uno:Bib/removeFilter" ;
+ Text [ en-US ] = "Remove Filter";
+ };
+ ToolBoxItem
+ {
+ Identifier = TBC_BT_COL_ASSIGN ;
+ HelpId = HID_BIB_MAPPINGDLG;
+// Command = ".uno:Bib/Mapping" ;
+// ItemBitmap = Bitmap { File = "sc10711.bmp" ; };
+ Text [ en-US ] = "Column Arrangement";
+ };
+ ToolBoxItem
+ {
+ Identifier = TBC_BT_CHANGESOURCE ;
+ HelpId = HID_BIB_CHANGESOURCE;
+ Command = ".uno:Bib/sdbsource" ;
+// ItemBitmap = Bitmap { File = "sc10711.bmp" ; };
+ Checkable=TRUE;
+ Text [ en-US ] = "Data Source";
+ };
+/*
+ ToolBoxItem
+ {
+ Type = TOOLBOXITEM_SEPARATOR ;
+ };
+
+ ToolBoxItem
+ {
+ Identifier = TBC_BT_NEWCARD ;
+ //HelpID = SID_FM_REMOVE_FILTER_SORT ;
+ Command = ".uno:Bib/newEntry" ;
+ ItemBitmap = Bitmap { File = "newcard.bmp" ; };
+ Text [ en-US ] = "New Address";
+ };
+
+ ToolBoxItem
+ {
+ Identifier = TBC_BT_EDITCARD ;
+ //HelpID = SID_FM_REMOVE_FILTER_SORT ;
+ Command = ".uno:Bib/changeEntry" ;
+ ItemBitmap = Bitmap { File = "modcard.bmp" ; };
+ Text [ en-US ] = "Edit Address";
+ };
+
+ ToolBoxItem
+ {
+ Identifier = TBC_BT_REMOVECARD ;
+ //HelpID = SID_FM_REMOVE_FILTER_SORT ;
+ Command = ".uno:Bib/removeEntry" ;
+ ItemBitmap = Bitmap { File = "remcard.bmp" ; };
+ Text [ en-US ] = "Remove Address";
+ };
+
+ ToolBoxItem
+ {
+ Type = TOOLBOXITEM_SEPARATOR ;
+ };
+
+ ToolBoxItem
+ {
+ Identifier = TBC_BT_INSERT ;
+ HelpID = SID_SBA_BRW_INSERT ;
+ ItemBitmap = Bitmap { File = "sc12202.bmp" ; };
+ Text [ en-US ] = "Data into Text";
+ };
+ ToolBoxItem
+ {
+ Identifier = TBC_BT_UPDATE ;
+ HelpID = SID_SBA_BRW_UPDATE ;
+ ItemBitmap = Bitmap { File = "sc12201.bmp" ; };
+ Text = "Daten in Felder" ;
+ };
+
+ ToolBoxItem
+ {
+ Type = TOOLBOXITEM_SEPARATOR ;
+ };
+
+ ToolBoxItem
+ {
+ Identifier = TBC_BT_MAIL ;
+ //HelpID = HID_ADDRPI_AUTOMAIL ;
+ ItemBitmap = Bitmap { File = "sc06305.bmp" ; };
+ Text [ en-US ] = "AutoMail";
+ };
+ ToolBoxItem
+ {
+ Identifier = TBC_BT_URL ;
+ //HelpID = HID_ADDRPI_AUTOBROWSE ;
+ ItemBitmap = Bitmap { File = "sc06304.bmp" ; };
+ Text [ en-US ] = "AutoBrowse";
+ };*/
+ };
+ Scroll = TRUE ;
+};
+#define BIB_IMAGES \
+ IdList = \
+ { \
+ SID_FM_AUTOFILTER; /*10716*/ \
+ SID_FM_FILTERCRIT; /*10715*/ \
+ SID_FM_REMOVE_FILTER_SORT ; /*10711*/ \
+ }; \
+ IdCount = { 3; };
+
+ImageList RID_TOOLBAR_IMGLIST
+{
+ Prefix = "sc";
+ MASKCOLOR
+ BIB_IMAGES
+};
+ImageList RID_TOOLBAR_IMGLIST_HC
+{
+ Prefix = "sch";
+ MASKCOLOR
+ BIB_IMAGES
+};
+
+ImageList RID_TOOLBAR_BIGIMGLIST
+{
+ Prefix = "lc";
+ MASKCOLOR
+ BIB_IMAGES
+};
+ImageList RID_TOOLBAR_BIGIMGLIST_HC
+{
+ Prefix = "lch";
+ MASKCOLOR
+ BIB_IMAGES
+};
+
+
+
+
+
+
+
+
diff --git a/extensions/source/bibliography/uiconfig/sbibliography/menubar/menubar.xml b/extensions/source/bibliography/uiconfig/sbibliography/menubar/menubar.xml
new file mode 100644
index 000000000000..817473af0e73
--- /dev/null
+++ b/extensions/source/bibliography/uiconfig/sbibliography/menubar/menubar.xml
@@ -0,0 +1,92 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<menu:menubar xmlns:menu="http://openoffice.org/2001/menu" menu:id="menubar">
+ <menu:menu menu:id=".uno:PickList">
+ <menu:menupopup>
+ <menu:menuitem menu:id=".uno:AddDirect"/>
+ <menu:menuitem menu:id=".uno:Open"/>
+ <menu:menuitem menu:id=".uno:AutoPilotMenu"/>
+ <menu:menuseparator/>
+ <menu:menuitem menu:id=".uno:CloseWin"/>
+ <menu:menuitem menu:id=".uno:Save"/>
+ <menu:menuitem menu:id=".uno:SaveAs"/>
+ <menu:menuitem menu:id=".uno:SaveAll"/>
+ <menu:menuitem menu:id=".uno:Reload"/>
+ <menu:menuitem menu:id=".uno:VersionDialog"/>
+ <menu:menuseparator/>
+ <menu:menuitem menu:id=".uno:SendToMenu"/>
+ <menu:menuseparator/>
+ <menu:menuitem menu:id=".uno:SetDocumentProperties"/>
+ <menu:menu menu:id=".uno:TemplateMenu">
+ <menu:menupopup>
+ <menu:menuitem menu:id=".uno:Organizer"/>
+ <menu:menuitem menu:id=".uno:AddressBookSource"/>
+ <menu:menuitem menu:id=".uno:SaveAsTemplate"/>
+ <menu:menuitem menu:id=".uno:OpenTemplate"/>
+ </menu:menupopup>
+ </menu:menu>
+ <menu:menuseparator/>
+ <menu:menuitem menu:id=".uno:PrintPreview"/>
+ <menu:menuitem menu:id=".uno:Print"/>
+ <menu:menuitem menu:id=".uno:PrinterSetup"/>
+ <menu:menuseparator/>
+ <menu:menuitem menu:id=".uno:Quit"/>
+ </menu:menupopup>
+ </menu:menu>
+ <menu:menu menu:id=".uno:EditMenu">
+ <menu:menupopup>
+ <menu:menuitem menu:id=".uno:Cut"/>
+ <menu:menuitem menu:id=".uno:Copy"/>
+ <menu:menuitem menu:id=".uno:Paste"/>
+ <menu:menuseparator/>
+ <menu:menuitem menu:id=".uno:Bib/Mapping"/>
+ <menu:menuitem menu:id=".uno:Bib/sdbsource"/>
+ <menu:menuitem menu:id=".uno:Bib/DeleteRecord"/>
+ </menu:menupopup>
+ </menu:menu>
+ <menu:menu menu:id=".uno:ViewMenu">
+ <menu:menupopup>
+ <menu:menuitem menu:id=".uno:AvailableToolbars"/>
+ <menu:menuitem menu:id=".uno:StatusBarVisible"/>
+ </menu:menupopup>
+ </menu:menu>
+ <menu:menu menu:id=".uno:InsertMenu">
+ <menu:menupopup>
+ <menu:menuitem menu:id=".uno:Bib/InsertRecord"/>
+ </menu:menupopup>
+ </menu:menu>
+ <menu:menu menu:id=".uno:ToolsMenu">
+ <menu:menupopup>
+ <menu:menuitem menu:id=".uno:Bib/standardFilter"/>
+ <menu:menuseparator/>
+ <menu:menu menu:id=".uno:MacrosMenu">
+ <menu:menupopup>
+ <menu:menuitem menu:id=".uno:MacroRecorder"/>
+ <menu:menuitem menu:id=".uno:RunMacro"/>
+ <menu:menu menu:id=".uno:ScriptOrganizer"/>
+ <menu:menuseparator/>
+ <menu:menuitem menu:id=".uno:MacroOrganizer?TabId:short=1"/>
+ </menu:menupopup>
+ </menu:menu>
+ <menu:menuitem menu:id="service:com.sun.star.deployment.ui.PackageManagerDialog"/>
+ <menu:menuitem menu:id=".uno:ConfigureDialog"/>
+ <menu:menuitem menu:id=".uno:OptionsTreeDialog"/>
+ </menu:menupopup>
+ </menu:menu>
+ <menu:menu menu:id=".uno:WindowList">
+ <menu:menupopup>
+ <menu:menuitem menu:id=".uno:NewWindow"/>
+ <menu:menuitem menu:id=".uno:CloseWin"/>
+ <menu:menuseparator/>
+ </menu:menupopup>
+ </menu:menu>
+ <menu:menu menu:id=".uno:HelpMenu">
+ <menu:menupopup>
+ <menu:menuitem menu:id=".uno:HelpIndex"/>
+ <menu:menuitem menu:id=".uno:ExtendedHelp"/>
+ <menu:menuseparator/>
+ <menu:menuitem menu:id=".uno:ShowLicense"/>
+ <menu:menuseparator/>
+ <menu:menuitem menu:id=".uno:About"/>
+ </menu:menupopup>
+ </menu:menu>
+</menu:menubar>
diff --git a/extensions/source/config/ldap/componentdef.cxx b/extensions/source/config/ldap/componentdef.cxx
new file mode 100644
index 000000000000..87c535d7e0ad
--- /dev/null
+++ b/extensions/source/config/ldap/componentdef.cxx
@@ -0,0 +1,83 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+
+#include "ldapuserprofilebe.hxx"
+#include <cppuhelper/implementationentry.hxx>
+
+using namespace extensions::config::ldap ;
+
+//==============================================================================
+
+static uno::Reference<uno::XInterface> SAL_CALL createLdapUserProfileBe(
+ const uno::Reference<uno::XComponentContext>& aContext) {
+ return * new LdapUserProfileBe(aContext) ;
+}
+//------------------------------------------------------------------------------
+
+static const cppu::ImplementationEntry kImplementations_entries[] =
+{
+ {
+ createLdapUserProfileBe,
+ LdapUserProfileBe::getLdapUserProfileBeName,
+ LdapUserProfileBe::getLdapUserProfileBeServiceNames,
+ cppu::createSingleComponentFactory,
+ NULL,
+ 0
+ },
+ { NULL, NULL, NULL, NULL, NULL, 0 }
+} ;
+//------------------------------------------------------------------------------
+
+extern "C" void SAL_CALL component_getImplementationEnvironment(
+ const sal_Char **aEnvTypeName,
+ uno_Environment** /*aEnvironment*/) {
+ *aEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME ;
+}
+//------------------------------------------------------------------------------
+
+extern "C" sal_Bool SAL_CALL component_writeInfo(void *aServiceManager,
+ void *aRegistryKey) {
+ return cppu::component_writeInfoHelper(
+ aServiceManager, aRegistryKey, kImplementations_entries);
+}
+//------------------------------------------------------------------------------
+
+extern "C" void *component_getFactory(const sal_Char *aImplementationName,
+ void *aServiceManager,
+ void *aRegistryKey) {
+ return cppu::component_getFactoryHelper(aImplementationName,
+ aServiceManager,
+ aRegistryKey,
+ kImplementations_entries) ;
+}
+//------------------------------------------------------------------------------
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/config/ldap/exports.dxp b/extensions/source/config/ldap/exports.dxp
new file mode 100644
index 000000000000..9630d7e06768
--- /dev/null
+++ b/extensions/source/config/ldap/exports.dxp
@@ -0,0 +1,3 @@
+component_getImplementationEnvironment
+component_writeInfo
+component_getFactory
diff --git a/extensions/source/config/ldap/ldapaccess.cxx b/extensions/source/config/ldap/ldapaccess.cxx
new file mode 100644
index 000000000000..827baec0b928
--- /dev/null
+++ b/extensions/source/config/ldap/ldapaccess.cxx
@@ -0,0 +1,321 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+
+#include "ldapaccess.hxx"
+
+#include <rtl/ustrbuf.hxx>
+#include <rtl/strbuf.hxx>
+
+
+namespace extensions { namespace config { namespace ldap {
+
+oslModule LdapConnection::s_Ldap_Module = NULL;
+t_ldap_unbind_s LdapConnection::s_p_unbind_s = NULL;
+t_ldap_simple_bind_s LdapConnection::s_p_simple_bind_s = NULL;
+t_ldap_set_option LdapConnection::s_p_set_option = NULL;
+t_ldap_err2string LdapConnection::s_p_err2string = NULL;
+t_ldap_init LdapConnection::s_p_init = NULL;
+t_ldap_msgfree LdapConnection::s_p_msgfree = NULL;
+t_ldap_get_dn LdapConnection::s_p_get_dn = NULL;
+t_ldap_first_entry LdapConnection::s_p_first_entry = NULL;
+t_ldap_first_attribute LdapConnection::s_p_first_attribute = NULL;
+t_ldap_next_attribute LdapConnection::s_p_next_attribute = NULL;
+t_ldap_search_s LdapConnection::s_p_search_s = NULL;
+t_ldap_value_free LdapConnection::s_p_value_free = NULL;
+t_ldap_get_values LdapConnection::s_p_get_values = NULL;
+t_ldap_memfree LdapConnection::s_p_memfree = NULL;
+//------------------------------------------------------------------------------
+typedef int LdapErrCode;
+//------------------------------------------------------------------------------
+struct LdapMessageHolder
+{
+ LdapMessageHolder() : msg(0) {}
+ ~LdapMessageHolder()
+ {
+ if (msg)
+ (*LdapConnection::s_p_msgfree)(msg);
+ }
+
+ LDAPMessage * msg;
+
+private:
+ LdapMessageHolder(LdapMessageHolder const&);
+ void operator=(LdapMessageHolder const&);
+};
+//------------------------------------------------------------------------------
+LdapConnection::~LdapConnection()
+{
+ if (isValid()) disconnect();
+}
+//------------------------------------------------------------------------------
+
+void LdapConnection::disconnect()
+{
+ if (mConnection != NULL)
+ {
+ (*s_p_unbind_s)(mConnection) ;
+ mConnection = NULL;
+ }
+}
+//------------------------------------------------------------------------------
+
+static void checkLdapReturnCode(const sal_Char *aOperation,
+ LdapErrCode aRetCode,
+ LDAP * /*aConnection*/)
+{
+ if (aRetCode == LDAP_SUCCESS) { return ; }
+
+ static const sal_Char *kNoSpecificMessage = "No additional information" ;
+ rtl::OUStringBuffer message ;
+
+ if (aOperation != NULL)
+ {
+ message.appendAscii(aOperation).appendAscii(": ") ;
+ }
+ message.appendAscii((*LdapConnection::s_p_err2string)(aRetCode)).appendAscii(" (") ;
+ sal_Char *stub = NULL ;
+
+#ifndef LDAP_OPT_SIZELIMIT // for use with OpenLDAP
+ (*s_p_get_lderrno)(aConnection, NULL, &stub) ;
+#endif
+ if (stub != NULL)
+ {
+ message.appendAscii(stub) ;
+ // It would seem the message returned is actually
+ // not a copy of a string but rather some static
+ // string itself. At any rate freeing it seems to
+ // cause some undue problems at least on Windows.
+ // This call is thus disabled for the moment.
+ //(*s_p_memfree)(stub) ;
+ }
+ else { message.appendAscii(kNoSpecificMessage) ; }
+ message.appendAscii(")") ;
+ throw ldap::LdapGenericException(message.makeStringAndClear(),
+ NULL, aRetCode) ;
+}
+//------------------------------------------------------------------------------
+void LdapConnection::connectSimple(const LdapDefinition& aDefinition)
+ throw (ldap::LdapConnectionException, ldap::LdapGenericException)
+{
+ OSL_ENSURE(!isValid(), "Recoonecting an LDAP connection that is already established");
+ if (isValid()) disconnect();
+
+ mLdapDefinition = aDefinition;
+ connectSimple();
+}
+//------------------------------------------------------------------------------
+void LdapConnection::connectSimple()
+ throw (ldap::LdapConnectionException, ldap::LdapGenericException)
+{
+ if (!isValid())
+ {
+ // Connect to the server
+ initConnection() ;
+ // Set Protocol V3
+ int version = LDAP_VERSION3;
+ (*s_p_set_option)(mConnection,
+ LDAP_OPT_PROTOCOL_VERSION,
+ &version);
+
+#ifdef LDAP_X_OPT_CONNECT_TIMEOUT // OpenLDAP doesn't support this and the func
+ /* timeout is specified in milliseconds -> 4 seconds*/
+ int timeout = 4000;
+ (*s_p_set_option)( mConnection,
+ LDAP_X_OPT_CONNECT_TIMEOUT,
+ &timeout );
+#endif
+
+ // Do the bind
+ LdapErrCode retCode = (*s_p_simple_bind_s)(mConnection,
+ mLdapDefinition.mAnonUser ,
+ mLdapDefinition.mAnonCredentials) ;
+
+ checkLdapReturnCode("SimpleBind", retCode, mConnection) ;
+ }
+}
+//------------------------------------------------------------------------------
+void LdapConnection::initConnection()
+ throw (ldap::LdapConnectionException)
+{
+ if (mLdapDefinition.mServer.getLength() == 0)
+ {
+ rtl::OUStringBuffer message ;
+
+ message.appendAscii("Cannot initialise connection to LDAP: No server specified.") ;
+ throw ldap::LdapConnectionException(message.makeStringAndClear(), NULL) ;
+ }
+
+ if (mLdapDefinition.mPort == 0) mLdapDefinition.mPort = LDAP_PORT;
+
+ mConnection = (*s_p_init)(mLdapDefinition.mServer,
+ mLdapDefinition.mPort) ;
+ if (mConnection == NULL)
+ {
+ rtl::OUStringBuffer message ;
+
+ message.appendAscii("Cannot initialise connection to LDAP server ") ;
+ message.appendAscii(mLdapDefinition.mServer) ;
+ message.appendAscii(":") ;
+ message.append(mLdapDefinition.mPort) ;
+ throw ldap::LdapConnectionException(message.makeStringAndClear(),
+ NULL) ;
+ }
+}
+//------------------------------------------------------------------------------
+ void LdapConnection::getUserProfile(
+ const rtl::OUString& aUser, LdapData * data)
+ throw (lang::IllegalArgumentException,
+ ldap::LdapConnectionException, ldap::LdapGenericException)
+{
+ OSL_ASSERT(data != 0);
+ if (!isValid()) { connectSimple(); }
+
+ rtl::OString aUserDn =findUserDn( rtl::OUStringToOString(aUser, RTL_TEXTENCODING_ASCII_US));
+
+ LdapMessageHolder result;
+ LdapErrCode retCode = (*s_p_search_s)(mConnection,
+ aUserDn,
+ LDAP_SCOPE_BASE,
+ "(objectclass=*)",
+ 0,
+ 0, // Attributes + values
+ &result.msg) ;
+
+ checkLdapReturnCode("getUserProfile", retCode,mConnection) ;
+
+ void * ptr;
+ char * attr = (*s_p_first_attribute)(mConnection, result.msg, &ptr);
+ while (attr != 0) {
+ char ** values = (*s_p_get_values)(mConnection, result.msg, attr);
+ if (values != 0) {
+ data->insert(
+ LdapData::value_type(
+ rtl::OStringToOUString(attr, RTL_TEXTENCODING_ASCII_US),
+ rtl::OStringToOUString(*values, RTL_TEXTENCODING_UTF8)));
+ (*s_p_value_free)(values);
+ }
+ attr = (*s_p_next_attribute)(mConnection, result.msg, ptr);
+ }
+}
+//------------------------------------------------------------------------------
+ rtl::OString LdapConnection::findUserDn(const rtl::OString& aUser)
+ throw (lang::IllegalArgumentException,
+ ldap::LdapConnectionException, ldap::LdapGenericException)
+{
+ if (!isValid()) { connectSimple(); }
+
+ if (aUser.getLength() == 0)
+ {
+ throw lang::IllegalArgumentException(
+ rtl::OUString(RTL_CONSTASCII_USTRINGPARAM
+ ("LdapConnection::findUserDn -User id is empty")),
+ NULL, 0) ;
+ }
+
+
+
+ rtl::OStringBuffer filter( "(&(objectclass=" );
+
+ filter.append( mLdapDefinition.mUserObjectClass ).append(")(") ;
+ filter.append( mLdapDefinition.mUserUniqueAttr ).append("=").append(aUser).append("))") ;
+
+ LdapMessageHolder result;
+ sal_Char * attributes [2];
+ attributes[0]= const_cast<sal_Char *>(LDAP_NO_ATTRS);
+ attributes[1]= NULL;
+ LdapErrCode retCode = (*s_p_search_s)(mConnection,
+ mLdapDefinition.mBaseDN,
+ LDAP_SCOPE_SUBTREE,
+ filter.makeStringAndClear(), attributes, 0, &result.msg) ;
+
+ checkLdapReturnCode("FindUserDn", retCode,mConnection) ;
+ rtl::OString userDn ;
+ LDAPMessage *entry = (*s_p_first_entry)(mConnection, result.msg) ;
+
+ if (entry != NULL)
+ {
+ sal_Char *charsDn = (*s_p_get_dn)(mConnection, entry) ;
+
+ userDn = charsDn ;
+ (*s_p_memfree)(charsDn) ;
+ }
+ else
+ {
+ OSL_ENSURE( false, "LdapConnection::findUserDn-could not get DN for User ");
+ }
+
+ return userDn ;
+}
+
+extern "C" { static void SAL_CALL thisModule() {} }
+void LdapConnection::loadModule()
+{
+ if ( !s_Ldap_Module )
+ {
+#if defined(WIN) || defined(WNT)
+# define LIBLDAP "nsldap32v50.dll"
+#else
+# ifdef WITH_OPENLDAP
+# define xstr(s) str(s)
+# define str(s) #s
+# define LIBLDAP "libldap-" xstr(LDAP_VENDOR_VERSION_MAJOR) "." xstr(LDAP_VENDOR_VERSION_MINOR) ".so." xstr(LDAP_VENDOR_VERSION_MAJOR)
+# else
+# define LIBLDAP "libldap50.so"
+# endif
+#endif
+ const ::rtl::OUString sModuleName(RTL_CONSTASCII_USTRINGPARAM(LIBLDAP));
+
+ // load the dbtools library
+ s_Ldap_Module = osl_loadModuleRelative(&thisModule, sModuleName.pData, 0);
+ if ( s_Ldap_Module != NULL )
+ {
+ s_p_unbind_s = (t_ldap_unbind_s)(osl_getFunctionSymbol(s_Ldap_Module, ::rtl::OUString::createFromAscii("ldap_unbind_s").pData));
+ s_p_simple_bind_s = (t_ldap_simple_bind_s)(osl_getFunctionSymbol(s_Ldap_Module, ::rtl::OUString::createFromAscii("ldap_simple_bind_s").pData));
+ s_p_set_option = (t_ldap_set_option)(osl_getFunctionSymbol(s_Ldap_Module, ::rtl::OUString::createFromAscii("ldap_set_option").pData));
+ s_p_err2string = (t_ldap_err2string)(osl_getFunctionSymbol(s_Ldap_Module, ::rtl::OUString::createFromAscii("ldap_err2string").pData));
+ s_p_init = (t_ldap_init)(osl_getFunctionSymbol(s_Ldap_Module, ::rtl::OUString::createFromAscii("ldap_init").pData));
+ s_p_msgfree = (t_ldap_msgfree)(osl_getFunctionSymbol(s_Ldap_Module, ::rtl::OUString::createFromAscii("ldap_msgfree").pData));
+ s_p_get_dn = (t_ldap_get_dn)(osl_getFunctionSymbol(s_Ldap_Module, ::rtl::OUString::createFromAscii("ldap_get_dn").pData));
+ s_p_first_entry = (t_ldap_first_entry)(osl_getFunctionSymbol(s_Ldap_Module, ::rtl::OUString::createFromAscii("ldap_first_entry").pData));
+ s_p_first_attribute = (t_ldap_first_attribute)(osl_getFunctionSymbol(s_Ldap_Module, ::rtl::OUString::createFromAscii("ldap_first_attribute").pData));
+ s_p_next_attribute = (t_ldap_next_attribute)(osl_getFunctionSymbol(s_Ldap_Module, ::rtl::OUString::createFromAscii("ldap_next_attribute").pData));
+ s_p_search_s = (t_ldap_search_s)(osl_getFunctionSymbol(s_Ldap_Module, ::rtl::OUString::createFromAscii("ldap_search_s").pData));
+ s_p_value_free = (t_ldap_value_free)(osl_getFunctionSymbol(s_Ldap_Module, ::rtl::OUString::createFromAscii("ldap_value_free").pData));
+ s_p_get_values = (t_ldap_get_values)(osl_getFunctionSymbol(s_Ldap_Module, ::rtl::OUString::createFromAscii("ldap_get_values").pData));
+ s_p_memfree = (t_ldap_memfree)(osl_getFunctionSymbol(s_Ldap_Module, ::rtl::OUString::createFromAscii("ldap_memfree").pData));
+ }
+ }
+}
+
+//------------------------------------------------------------------------------
+} } } // extensions.config.ldap
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/config/ldap/ldapaccess.hxx b/extensions/source/config/ldap/ldapaccess.hxx
new file mode 100644
index 000000000000..a9bcbee5826a
--- /dev/null
+++ b/extensions/source/config/ldap/ldapaccess.hxx
@@ -0,0 +1,171 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef EXTENSIONS_CONFIG_LDAP_LDAPACCESS_HXX_
+#define EXTENSIONS_CONFIG_LDAP_LDAPACCESS_HXX_
+
+#include "sal/config.h"
+
+#include <map>
+
+#include "wrapldapinclude.hxx"
+#include <com/sun/star/ldap/LdapGenericException.hpp>
+
+#include <com/sun/star/ldap/LdapConnectionException.hpp>
+#include <com/sun/star/lang/IllegalArgumentException.hpp>
+#include <osl/module.h>
+
+namespace extensions { namespace config { namespace ldap {
+
+namespace css = com::sun::star ;
+namespace uno = css::uno ;
+namespace lang = css::lang ;
+namespace ldap = css::ldap ;
+//------------------------------------------------------------------------------
+// LdapUserProfile classes
+struct LdapUserProfile;
+class LdapUserProfileMap;
+
+typedef LDAP_API(int) (LDAP_CALL *t_ldap_unbind_s)( LDAP *ld );
+typedef LDAP_API(int) (LDAP_CALL *t_ldap_simple_bind_s)( LDAP *ld, const char *who, const char *passwd );
+typedef LDAP_API(int) (LDAP_CALL *t_ldap_set_option)( LDAP *ld, int option, const void *optdata );
+typedef LDAP_API(char *) (LDAP_CALL *t_ldap_err2string)( int err );
+typedef LDAP_API(LDAP *) (LDAP_CALL *t_ldap_init)( const char *defhost, int defport );
+typedef LDAP_API(int) (LDAP_CALL *t_ldap_msgfree)( LDAPMessage *lm );
+typedef LDAP_API(char *) (LDAP_CALL *t_ldap_get_dn)( LDAP *ld, LDAPMessage *entry );
+typedef LDAP_API(LDAPMessage *) (LDAP_CALL *t_ldap_first_entry)( LDAP *ld, LDAPMessage *chain );
+typedef LDAP_API(char *) (LDAP_CALL *t_ldap_first_attribute)( LDAP *ld, LDAPMessage *entry, void **ptr );
+typedef LDAP_API(char *) (LDAP_CALL *t_ldap_next_attribute)( LDAP *ld, LDAPMessage *entry, void *ptr );
+typedef LDAP_API(int) (LDAP_CALL *t_ldap_search_s)( LDAP *ld, const char *base, int scope, const char *filter, char **attrs, int attrsonly, LDAPMessage **res );
+typedef LDAP_API(void) (LDAP_CALL *t_ldap_value_free)( char **vals );
+typedef LDAP_API(char **) (LDAP_CALL *t_ldap_get_values)( LDAP *ld, LDAPMessage *entry, const char *target );
+typedef LDAP_API(void) (LDAP_CALL *t_ldap_memfree)( void *p );
+//------------------------------------------------------------------------------
+/** Struct containing the information on LDAP connection */
+struct LdapDefinition
+{
+ /** LDAP server name */
+ rtl::OString mServer ;
+ /** LDAP server port number */
+ sal_Int32 mPort ;
+ /** Repository base DN */
+ rtl::OString mBaseDN ;
+ /** DN to use for "anonymous" connection */
+ rtl::OString mAnonUser ;
+ /** Credentials to use for "anonymous" connection */
+ rtl::OString mAnonCredentials ;
+ /** User Entity Object Class */
+ rtl::OString mUserObjectClass;
+ /** User Entity Unique Attribute */
+ rtl::OString mUserUniqueAttr;
+ } ;
+
+typedef std::map< rtl::OUString, rtl::OUString > LdapData; // key/value pairs
+
+/** Class encapulating all LDAP functionality */
+class LdapConnection
+{
+ friend struct LdapMessageHolder;
+public:
+
+ /** Default constructor */
+ LdapConnection(void) : mConnection(NULL),mLdapDefinition() {}
+ /** Destructor, releases the connection */
+ ~LdapConnection(void) ;
+ /** Make connection to LDAP server */
+ void connectSimple(const LdapDefinition& aDefinition)
+ throw (ldap::LdapConnectionException,
+ ldap::LdapGenericException);
+
+ /**
+ Gets LdapUserProfile from LDAP repository for specified user
+ @param aUser name of logged on user
+ @param aUserProfileMap Map containing LDAP->00o mapping
+ @param aUserProfile struct for holding OOo values
+
+ @throws com::sun::star::ldap::LdapGenericException
+ if an LDAP error occurs.
+ */
+ void getUserProfile(const rtl::OUString& aUser, LdapData * data)
+ throw (lang::IllegalArgumentException,
+ ldap::LdapConnectionException,
+ ldap::LdapGenericException);
+
+ /** finds DN of user
+ @return DN of User
+ */
+ rtl::OString findUserDn(const rtl::OString& aUser)
+ throw (lang::IllegalArgumentException,
+ ldap::LdapConnectionException,
+ ldap::LdapGenericException);
+
+ void loadModule();
+
+ static t_ldap_err2string s_p_err2string;
+private:
+
+ void initConnection()
+ throw (ldap::LdapConnectionException);
+ void disconnect();
+ /**
+ Indicates whether the connection is in a valid state.
+ @return sal_True if connection is valid, sal_False otherwise
+ */
+ bool isValid(void) const { return mConnection != NULL ; }
+
+ void connectSimple()
+ throw (ldap::LdapConnectionException,
+ ldap::LdapGenericException);
+
+ /** LDAP connection object */
+ LDAP* mConnection ;
+ LdapDefinition mLdapDefinition;
+
+ static oslModule s_Ldap_Module;
+ static t_ldap_value_free s_p_value_free;
+ static t_ldap_get_values s_p_get_values;
+ static t_ldap_unbind_s s_p_unbind_s;
+ static t_ldap_simple_bind_s s_p_simple_bind_s;
+ static t_ldap_set_option s_p_set_option;
+ static t_ldap_init s_p_init;
+ static t_ldap_msgfree s_p_msgfree;
+ static t_ldap_get_dn s_p_get_dn;
+ static t_ldap_first_entry s_p_first_entry;
+ static t_ldap_first_attribute s_p_first_attribute;
+ static t_ldap_next_attribute s_p_next_attribute;
+ static t_ldap_search_s s_p_search_s;
+
+ static t_ldap_memfree s_p_memfree;
+
+} ;
+//------------------------------------------------------------------------------
+}} }
+
+#endif // EXTENSIONS_CONFIG_LDAP_LDAPUSERPROFILE_HXX_
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/config/ldap/ldapuserprofilebe.cxx b/extensions/source/config/ldap/ldapuserprofilebe.cxx
new file mode 100644
index 000000000000..6cc22c7190b1
--- /dev/null
+++ b/extensions/source/config/ldap/ldapuserprofilebe.cxx
@@ -0,0 +1,280 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+
+#include "ldapaccess.hxx"
+#include "ldapuserprofilebe.hxx"
+#include <osl/file.hxx>
+#include <osl/module.hxx>
+#include <osl/process.h>
+#include <rtl/ustrbuf.hxx>
+#include <rtl/byteseq.h>
+
+#include <rtl/instance.hxx>
+#include <com/sun/star/beans/NamedValue.hpp>
+#include <com/sun/star/beans/Optional.hpp>
+#include <osl/security.hxx>
+
+//==============================================================================
+namespace extensions { namespace config { namespace ldap {
+
+LdapUserProfileBe::LdapUserProfileBe( const uno::Reference<uno::XComponentContext>& xContext)
+: LdapProfileMutexHolder(),
+ BackendBase(mMutex)
+{
+ LdapDefinition aDefinition;
+ rtl::OUString loggedOnUser;
+
+ // This whole rigmarole is to prevent an infinite recursion where reading
+ // the configuration for the backend would create another instance of the
+ // backend, which would try and read the configuration which would...
+ {
+ osl::Mutex & aInitMutex = rtl::Static< osl::Mutex, LdapUserProfileBe >::get();
+ osl::MutexGuard aInitGuard(aInitMutex);
+
+ static bool bReentrantCall; // = false
+ OSL_ENSURE(!bReentrantCall, "configuration: Ldap Backend constructor called reentrantly - probably a registration error.");
+
+ if (!bReentrantCall)
+ {
+ try
+ {
+ bReentrantCall = true ;
+ if (!readLdapConfiguration(
+ css::uno::Reference< css::lang::XMultiServiceFactory >(
+ xContext->getServiceManager(),
+ css::uno::UNO_QUERY_THROW),
+ &aDefinition, &loggedOnUser))
+ {
+ throw css::uno::RuntimeException(
+ rtl::OUString::createFromAscii("LdapUserProfileBe- LDAP not configured"),
+ NULL);
+ }
+
+ bReentrantCall = false ;
+ }
+ catch (...)
+ {
+ bReentrantCall = false;
+ throw;
+ }
+ }
+ }
+
+ LdapConnection connection;
+ connection.loadModule();
+ connection.connectSimple(aDefinition);
+ connection.getUserProfile(loggedOnUser, &data_);
+}
+//------------------------------------------------------------------------------
+LdapUserProfileBe::~LdapUserProfileBe()
+{
+}
+//------------------------------------------------------------------------------
+
+bool LdapUserProfileBe::readLdapConfiguration(
+ css::uno::Reference< css::lang::XMultiServiceFactory > const & factory,
+ LdapDefinition * definition, rtl::OUString * loggedOnUser)
+{
+ OSL_ASSERT(factory.is() && definition != 0 && loggedOnUser != 0);
+ const rtl::OUString kConfigurationProviderService( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.configuration.ConfigurationProvider")) ;
+ const rtl::OUString kReadOnlyViewService( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.configuration.ConfigurationAccess")) ;
+ const rtl::OUString kComponent( RTL_CONSTASCII_USTRINGPARAM("org.openoffice.LDAP/UserDirectory"));
+ const rtl::OUString kServerDefiniton(RTL_CONSTASCII_USTRINGPARAM ("ServerDefinition"));
+ const rtl::OUString kServer(RTL_CONSTASCII_USTRINGPARAM ("Server"));
+ const rtl::OUString kPort(RTL_CONSTASCII_USTRINGPARAM("Port"));
+ const rtl::OUString kBaseDN(RTL_CONSTASCII_USTRINGPARAM("BaseDN"));
+ const rtl::OUString kUser(RTL_CONSTASCII_USTRINGPARAM("SearchUser"));
+ const rtl::OUString kPassword(RTL_CONSTASCII_USTRINGPARAM("SearchPassword"));
+ const rtl::OUString kUserObjectClass(RTL_CONSTASCII_USTRINGPARAM("UserObjectClass"));
+ const rtl::OUString kUserUniqueAttr(RTL_CONSTASCII_USTRINGPARAM("UserUniqueAttribute"));
+
+ uno::Reference< XInterface > xIface;
+ try
+ {
+ uno::Reference< lang::XMultiServiceFactory > xCfgProvider(
+ factory->createInstance(kConfigurationProviderService),
+ uno::UNO_QUERY);
+ OSL_ENSURE(xCfgProvider.is(),"LdapUserProfileBe: could not create the configuration provider");
+ if (!xCfgProvider.is())
+ return false;
+
+ css::beans::NamedValue aPath(rtl::OUString::createFromAscii("nodepath"), uno::makeAny(kComponent) );
+
+ uno::Sequence< uno::Any > aArgs(1);
+ aArgs[0] <<= aPath;
+
+ xIface = xCfgProvider->createInstanceWithArguments(kReadOnlyViewService, aArgs);
+
+ uno::Reference<container::XNameAccess > xAccess(xIface, uno::UNO_QUERY_THROW);
+ xAccess->getByName(kServerDefiniton) >>= xIface;
+
+ uno::Reference<container::XNameAccess > xChildAccess(xIface, uno::UNO_QUERY_THROW);
+
+ if (!getLdapStringParam(xChildAccess, kServer, definition->mServer))
+ return false;
+ if (!getLdapStringParam(xChildAccess, kBaseDN, definition->mBaseDN))
+ return false;
+
+ definition->mPort=0;
+ xChildAccess->getByName(kPort) >>= definition->mPort ;
+ if (definition->mPort == 0)
+ return false;
+
+ if (!getLdapStringParam(xAccess, kUserObjectClass, definition->mUserObjectClass))
+ return false;
+ if (!getLdapStringParam(xAccess, kUserUniqueAttr, definition->mUserUniqueAttr))
+ return false;
+
+ getLdapStringParam(xAccess, kUser, definition->mAnonUser);
+ getLdapStringParam(xAccess, kPassword, definition->mAnonCredentials);
+ }
+ catch (uno::Exception & e)
+ {
+ OSL_TRACE("LdapUserProfileBackend: access to configuration data failed: %s",
+ rtl::OUStringToOString( e.Message, RTL_TEXTENCODING_ASCII_US ).getStr() );
+ return false;
+ }
+
+ osl::Security aSecurityContext;
+ if (!aSecurityContext.getUserName(*loggedOnUser))
+ OSL_TRACE("LdapUserProfileBackend - could not get Logged on user from system");
+
+ sal_Int32 nIndex = loggedOnUser->indexOf('/');
+ if (nIndex > 0)
+ *loggedOnUser = loggedOnUser->copy(nIndex+1);
+
+ //Remember to remove
+ OSL_TRACE("Logged on user is %s", rtl::OUStringToOString(*loggedOnUser,RTL_TEXTENCODING_ASCII_US).getStr());
+
+ return true;
+}
+
+//------------------------------------------------------------------------------
+bool LdapUserProfileBe::getLdapStringParam(
+ uno::Reference<container::XNameAccess>& xAccess,
+ const rtl::OUString& aLdapSetting,
+ rtl::OString& aServerParameter)
+{
+ rtl::OUString sParam;
+ xAccess->getByName(aLdapSetting) >>= sParam;
+ aServerParameter = rtl::OUStringToOString(sParam, RTL_TEXTENCODING_ASCII_US);
+
+ return aServerParameter.getLength() != 0;
+}
+//------------------------------------------------------------------------------
+void LdapUserProfileBe::setPropertyValue(
+ rtl::OUString const &, css::uno::Any const &)
+ throw (
+ css::beans::UnknownPropertyException, css::beans::PropertyVetoException,
+ css::lang::IllegalArgumentException, css::lang::WrappedTargetException,
+ css::uno::RuntimeException)
+{
+ throw css::lang::IllegalArgumentException(
+ rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM("setPropertyValue not supported")),
+ static_cast< cppu::OWeakObject * >(this), -1);
+}
+
+css::uno::Any LdapUserProfileBe::getPropertyValue(
+ rtl::OUString const & PropertyName)
+ throw (
+ css::beans::UnknownPropertyException, css::lang::WrappedTargetException,
+ css::uno::RuntimeException)
+{
+ for (sal_Int32 i = 0;;) {
+ sal_Int32 j = PropertyName.indexOf(',', i);
+ if (j == -1) {
+ j = PropertyName.getLength();
+ }
+ if (j == i) {
+ throw css::beans::UnknownPropertyException(
+ PropertyName, static_cast< cppu::OWeakObject * >(this));
+ }
+ LdapData::iterator k(data_.find(PropertyName.copy(i, j - i)));
+ if (k != data_.end()) {
+ return css::uno::makeAny(
+ css::beans::Optional< css::uno::Any >(
+ true, css::uno::makeAny(k->second)));
+ }
+ if (j == PropertyName.getLength()) {
+ break;
+ }
+ i = j + 1;
+ }
+ return css::uno::makeAny(css::beans::Optional< css::uno::Any >());
+}
+
+//------------------------------------------------------------------------------
+rtl::OUString SAL_CALL LdapUserProfileBe::getLdapUserProfileBeName(void) {
+ return rtl::OUString::createFromAscii("com.sun.star.comp.configuration.backend.LdapUserProfileBe") ;
+}
+//------------------------------------------------------------------------------
+
+rtl::OUString SAL_CALL LdapUserProfileBe::getImplementationName(void)
+ throw (uno::RuntimeException)
+{
+ return getLdapUserProfileBeName() ;
+}
+//------------------------------------------------------------------------------
+
+uno::Sequence<rtl::OUString> SAL_CALL LdapUserProfileBe::getLdapUserProfileBeServiceNames(void)
+{
+ uno::Sequence<rtl::OUString> aServices(1) ;
+ aServices[0] = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.configuration.backend.LdapUserProfileBe")) ;
+ return aServices ;
+}
+//------------------------------------------------------------------------------
+
+sal_Bool SAL_CALL LdapUserProfileBe::supportsService(const rtl::OUString& aServiceName)
+ throw (uno::RuntimeException)
+{
+ uno::Sequence< rtl::OUString > const svc = getLdapUserProfileBeServiceNames();
+
+ for(sal_Int32 i = 0; i < svc.getLength(); ++i )
+ if(svc[i] == aServiceName)
+ return true;
+ return false;
+}
+
+//------------------------------------------------------------------------------
+
+uno::Sequence<rtl::OUString>
+SAL_CALL LdapUserProfileBe::getSupportedServiceNames(void)
+ throw (uno::RuntimeException)
+{
+ return getLdapUserProfileBeServiceNames() ;
+}
+// ---------------------------------------------------------------------------------------
+}}}
+// ---------------------------------------------------------------------------------------
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/config/ldap/ldapuserprofilebe.hxx b/extensions/source/config/ldap/ldapuserprofilebe.hxx
new file mode 100644
index 000000000000..6fced57bca1e
--- /dev/null
+++ b/extensions/source/config/ldap/ldapuserprofilebe.hxx
@@ -0,0 +1,161 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef EXTENSIONS_CONFIG_LDAP_LDAPUSERPROFILEBE_HXX_
+#define EXTENSIONS_CONFIG_LDAP_LDAPUSERPROFILEBE_HXX_
+
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/lang/XInitialization.hpp>
+#include <com/sun/star/uno/XComponentContext.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/container/XNameAccess.hpp>
+#include <com/sun/star/lang/IllegalArgumentException.hpp>
+#include <cppuhelper/compbase2.hxx>
+
+#include "ldapaccess.hxx"
+
+namespace extensions { namespace config { namespace ldap {
+
+namespace css = com::sun::star ;
+namespace uno = css::uno ;
+namespace lang = css::lang ;
+namespace container = css::container;
+
+struct LdapDefinition;
+
+typedef cppu::WeakComponentImplHelper2<css::beans::XPropertySet,
+ lang::XServiceInfo> BackendBase ;
+
+struct LdapProfileMutexHolder { osl::Mutex mMutex; };
+/**
+ Implements the PlatformBackend service, a specialization of the
+ XPropertySet service for retreiving LDAP user profile
+ configuration settings from a LDAP repsoitory.
+ */
+class LdapUserProfileBe : private LdapProfileMutexHolder, public BackendBase
+{
+ public :
+
+ LdapUserProfileBe(const uno::Reference<uno::XComponentContext>& xContext);
+ ~LdapUserProfileBe(void) ;
+
+ // XServiceInfo
+ virtual rtl::OUString SAL_CALL
+ getImplementationName( )
+ throw (uno::RuntimeException) ;
+
+ virtual sal_Bool SAL_CALL
+ supportsService( const rtl::OUString& aServiceName )
+ throw (uno::RuntimeException) ;
+
+ virtual uno::Sequence<rtl::OUString> SAL_CALL
+ getSupportedServiceNames( )
+ throw (uno::RuntimeException) ;
+
+ // XPropertySet
+ virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL
+ getPropertySetInfo() throw (css::uno::RuntimeException)
+ { return css::uno::Reference< css::beans::XPropertySetInfo >(); }
+
+ virtual void SAL_CALL setPropertyValue(
+ rtl::OUString const &, css::uno::Any const &)
+ throw (
+ css::beans::UnknownPropertyException,
+ css::beans::PropertyVetoException,
+ css::lang::IllegalArgumentException,
+ css::lang::WrappedTargetException, css::uno::RuntimeException);
+
+ virtual css::uno::Any SAL_CALL getPropertyValue(
+ rtl::OUString const & PropertyName)
+ throw (
+ css::beans::UnknownPropertyException,
+ css::lang::WrappedTargetException, css::uno::RuntimeException);
+
+ virtual void SAL_CALL addPropertyChangeListener(
+ rtl::OUString const &,
+ css::uno::Reference< css::beans::XPropertyChangeListener > const &)
+ throw (
+ css::beans::UnknownPropertyException,
+ css::lang::WrappedTargetException, css::uno::RuntimeException)
+ {}
+
+ virtual void SAL_CALL removePropertyChangeListener(
+ rtl::OUString const &,
+ css::uno::Reference< css::beans::XPropertyChangeListener > const &)
+ throw (
+ css::beans::UnknownPropertyException,
+ css::lang::WrappedTargetException, css::uno::RuntimeException)
+ {}
+
+ virtual void SAL_CALL addVetoableChangeListener(
+ rtl::OUString const &,
+ css::uno::Reference< css::beans::XVetoableChangeListener > const &)
+ throw (
+ css::beans::UnknownPropertyException,
+ css::lang::WrappedTargetException, css::uno::RuntimeException)
+ {}
+
+ virtual void SAL_CALL removeVetoableChangeListener(
+ rtl::OUString const &,
+ css::uno::Reference< css::beans::XVetoableChangeListener > const &)
+ throw (
+ css::beans::UnknownPropertyException,
+ css::lang::WrappedTargetException, css::uno::RuntimeException)
+ {}
+
+ /**
+ Provides the implementation name.
+ @return implementation name
+ */
+ static rtl::OUString SAL_CALL getLdapUserProfileBeName(void) ;
+ /**
+ Provides the supported services names
+ @return service names
+ */
+ static uno::Sequence<rtl::OUString> SAL_CALL
+ getLdapUserProfileBeServiceNames(void) ;
+
+ private:
+ /** Check if LDAP is configured */
+ bool readLdapConfiguration(
+ uno::Reference<lang::XMultiServiceFactory> const & factory,
+ LdapDefinition * definition, rtl::OUString * loggedOnUser);
+
+ bool getLdapStringParam(uno::Reference<container::XNameAccess>& xAccess,
+ const rtl::OUString& aLdapSetting,
+ rtl::OString& aServerParameter);
+
+ LdapData data_;
+} ;
+//------------------------------------------------------------------------------
+}}}
+
+#endif // EXTENSIONS_CONFIG_LDAP_LDAPUSERPROFILE_HXX_
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/config/ldap/makefile.mk b/extensions/source/config/ldap/makefile.mk
new file mode 100644
index 000000000000..a27cb39b6225
--- /dev/null
+++ b/extensions/source/config/ldap/makefile.mk
@@ -0,0 +1,97 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ=..$/..$/..
+
+PRJNAME=extensions
+TARGET=ldapbe
+ENABLE_EXCEPTIONS=TRUE
+
+# Version
+LDAP_MAJOR=2
+
+# --- Settings ---
+
+.INCLUDE : settings.mk
+DLLPRE =
+
+.IF "$(WITH_LDAP)" != "YES"
+@all:
+ @echo "LDAP disabled."
+.ENDIF
+
+.IF "$(LDAPSDKINCLUDES)" == ""
+
+.IF "$(SYSTEM_MOZILLA)" == "YES" && "$(WITH_OPENLDAP)" != "YES"
+LDAPSDKINCLUDES = $(MOZ_LDAP_CFLAGS)
+.ELSE
+LDAPSDKINCLUDES = -I$(SOLARINCDIR)$/mozilla
+.ENDIF
+.ENDIF
+
+.IF "$(WITH_OPENLDAP)" == "YES"
+CFLAGS += -DWITH_OPENLDAP -DLDAP_DEPRECATED
+.ENDIF
+
+SOLARINC+= $(LDAPSDKINCLUDES)
+# --- Files ---
+
+
+SLOFILES=\
+ $(SLO)$/ldapuserprofilebe.obj \
+ $(SLO)$/ldapaccess.obj \
+ $(SLO)$/componentdef.obj
+
+LIB1TARGET=$(SLB)$/_$(TARGET).lib
+LIB1OBJFILES=$(SLOFILES)
+
+SHL1TARGET=$(TARGET)$(LDAP_MAJOR).uno
+SHL1DEF=$(MISC)$/$(SHL1TARGET).def
+SHL1LIBS=$(LIB1TARGET)
+SHL1IMPLIB=i$(SHL1TARGET)
+SHL1STDLIBS= \
+ $(CPPUHELPERLIB) \
+ $(CPPULIB) \
+ $(SALHELPERLIB) \
+ $(SALLIB)
+.IF "$(OS)"=="FREEBSD"
+SHL1STDLIBS+=-lcompat
+# workaround for FreeBSD, which needs -llber50, too
+.IF "$(WITH_OPENLDAP)" != "YES"
+SHL1STDLIBS+=-Wl,-Bstatic -llber50
+.ENDIF
+.ENDIF
+
+DEF1NAME=$(SHL1TARGET)
+DEF1EXPORTFILE=exports.dxp
+DEF1DES=Configuration: LDAP User Profile Backend
+
+# --- Targets ---
+
+.INCLUDE : target.mk
+.INCLUDE : $(PRJ)$/util$/target.pmk
+
diff --git a/extensions/source/config/ldap/wrapldapinclude.hxx b/extensions/source/config/ldap/wrapldapinclude.hxx
new file mode 100644
index 000000000000..9e401944c1cc
--- /dev/null
+++ b/extensions/source/config/ldap/wrapldapinclude.hxx
@@ -0,0 +1,53 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifdef WNT
+#pragma warning (push,1)
+#pragma warning (disable:4668)
+#endif
+
+#ifdef WITH_OPENLDAP
+#include <ldap.h>
+#ifndef LDAP_API
+# define LDAP_API(rt) rt
+#endif
+#ifndef LDAP_CALL
+# define LDAP_CALL
+#endif
+#else
+#ifndef LDAP_INCLUDED
+#define LDAP_INCLUDED
+#include <ldap/ldap.h>
+#endif // LDAP_INCLUDED
+#endif
+
+#ifdef WNT
+#pragma warning (pop)
+#endif // WNT
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/dbpilots/commonpagesdbp.cxx b/extensions/source/dbpilots/commonpagesdbp.cxx
new file mode 100644
index 000000000000..4ec5568481db
--- /dev/null
+++ b/extensions/source/dbpilots/commonpagesdbp.cxx
@@ -0,0 +1,507 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+#include "commonpagesdbp.hxx"
+#include "dbpresid.hrc"
+#include "componentmodule.hxx"
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/sdb/XCompletedConnection.hpp>
+#include <com/sun/star/sdbcx/XTablesSupplier.hpp>
+#include <com/sun/star/sdb/XQueriesSupplier.hpp>
+#include <com/sun/star/sdbc/XConnection.hpp>
+#include <com/sun/star/sdb/SQLContext.hpp>
+#include <com/sun/star/sdbc/SQLWarning.hpp>
+#include <com/sun/star/sdb/CommandType.hpp>
+#include <tools/debug.hxx>
+#include <svtools/localresaccess.hxx>
+#include <comphelper/interaction.hxx>
+#include <connectivity/dbtools.hxx>
+#include <vcl/stdtext.hxx>
+#include <vcl/waitobj.hxx>
+#include <sfx2/docfilt.hxx>
+#include <unotools/pathoptions.hxx>
+#include <sfx2/filedlghelper.hxx>
+#include <svl/filenotation.hxx>
+//.........................................................................
+namespace dbp
+{
+//.........................................................................
+
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::lang;
+ using namespace ::com::sun::star::container;
+ using namespace ::com::sun::star::sdb;
+ using namespace ::com::sun::star::sdbc;
+ using namespace ::com::sun::star::sdbcx;
+ using namespace ::com::sun::star::task;
+ using namespace ::comphelper;
+
+ //=====================================================================
+ //= OTableSelectionPage
+ //=====================================================================
+ //---------------------------------------------------------------------
+ OTableSelectionPage::OTableSelectionPage(OControlWizard* _pParent)
+ :OControlWizardPage(_pParent, ModuleRes(RID_PAGE_TABLESELECTION))
+ ,m_aData (this, ModuleRes(FL_DATA))
+ ,m_aExplanation (this, ModuleRes(FT_EXPLANATION))
+ ,m_aDatasourceLabel (this, ModuleRes(FT_DATASOURCE))
+ ,m_aDatasource (this, ModuleRes(LB_DATASOURCE))
+ ,m_aSearchDatabase (this, ModuleRes(PB_FORMDATASOURCE))
+ ,m_aTableLabel (this, ModuleRes(FT_TABLE))
+ ,m_aTable (this, ModuleRes(LB_TABLE))
+ {
+ FreeResource();
+
+ implCollectDatasource();
+
+ m_aDatasource.SetSelectHdl(LINK(this, OTableSelectionPage, OnListboxSelection));
+ m_aTable.SetSelectHdl(LINK(this, OTableSelectionPage, OnListboxSelection));
+ m_aTable.SetDoubleClickHdl(LINK(this, OTableSelectionPage, OnListboxDoubleClicked));
+ m_aSearchDatabase.SetClickHdl(LINK(this, OTableSelectionPage, OnSearchClicked));
+
+ m_aDatasource.SetDropDownLineCount(10);
+ }
+
+ //---------------------------------------------------------------------
+ void OTableSelectionPage::ActivatePage()
+ {
+ OControlWizardPage::ActivatePage();
+ m_aDatasource.GrabFocus();
+ }
+
+ //---------------------------------------------------------------------
+ bool OTableSelectionPage::canAdvance() const
+ {
+ if (!OControlWizardPage::canAdvance())
+ return false;
+
+ if (0 == m_aDatasource.GetSelectEntryCount())
+ return false;
+
+ if (0 == m_aTable.GetSelectEntryCount())
+ return false;
+
+ return sal_True;
+ }
+
+ //---------------------------------------------------------------------
+ void OTableSelectionPage::initializePage()
+ {
+ OControlWizardPage::initializePage();
+
+ const OControlWizardContext& rContext = getContext();
+ try
+ {
+ ::rtl::OUString sDataSourceName;
+ rContext.xForm->getPropertyValue(::rtl::OUString::createFromAscii("DataSourceName")) >>= sDataSourceName;
+
+ Reference< XConnection > xConnection;
+ bool bEmbedded = ::dbtools::isEmbeddedInDatabase( rContext.xForm, xConnection );
+ if ( bEmbedded )
+ {
+ m_aDatasource.Hide();
+ m_aDatasourceLabel.Hide();
+ m_aSearchDatabase.Hide();
+ m_aTableLabel.SetPosPixel(m_aDatasourceLabel.GetPosPixel());
+ m_aTable.SetPosPixel(m_aDatasource.GetPosPixel());
+ m_aDatasource.InsertEntry(sDataSourceName);
+ }
+ m_aDatasource.SelectEntry(sDataSourceName);
+
+ implFillTables(xConnection);
+
+ ::rtl::OUString sCommand;
+ OSL_VERIFY( rContext.xForm->getPropertyValue( ::rtl::OUString::createFromAscii("Command") ) >>= sCommand );
+ sal_Int32 nCommandType = CommandType::TABLE;
+ OSL_VERIFY( rContext.xForm->getPropertyValue( ::rtl::OUString::createFromAscii("CommandType") ) >>= nCommandType );
+
+ // search the entry of the given type with the given name
+ XubString sLookup( sCommand );
+ for ( USHORT nLookup = 0; nLookup < m_aTable.GetEntryCount(); ++nLookup )
+ {
+ if ( m_aTable.GetEntry( nLookup ) == sLookup )
+ if ( reinterpret_cast< sal_IntPtr >( m_aTable.GetEntryData( nLookup ) ) == nCommandType )
+ {
+ m_aTable.SelectEntryPos( nLookup );
+ break;
+ }
+ }
+ }
+ catch(Exception&)
+ {
+ DBG_ERROR("OTableSelectionPage::initializePage: caught an exception!");
+ }
+ }
+
+ //---------------------------------------------------------------------
+ sal_Bool OTableSelectionPage::commitPage( ::svt::WizardTypes::CommitPageReason _eReason )
+ {
+ if (!OControlWizardPage::commitPage(_eReason))
+ return sal_False;
+
+ const OControlWizardContext& rContext = getContext();
+ try
+ {
+ Reference< XConnection > xOldConn;
+ if ( !rContext.bEmbedded )
+ {
+ xOldConn = getFormConnection();
+
+ ::rtl::OUString sDataSource = m_aDatasource.GetSelectEntry();
+ rContext.xForm->setPropertyValue( ::rtl::OUString::createFromAscii("DataSourceName"), makeAny( sDataSource ) );
+ }
+ ::rtl::OUString sCommand = m_aTable.GetSelectEntry();
+ sal_Int32 nCommandType = reinterpret_cast< sal_IntPtr >( m_aTable.GetEntryData( m_aTable.GetSelectEntryPos() ) );
+
+ rContext.xForm->setPropertyValue( ::rtl::OUString::createFromAscii("Command"), makeAny( sCommand ) );
+ rContext.xForm->setPropertyValue( ::rtl::OUString::createFromAscii("CommandType"), makeAny( nCommandType ) );
+
+ if ( !rContext.bEmbedded )
+ setFormConnection( xOldConn, sal_False );
+
+ if (!updateContext())
+ return sal_False;
+ }
+ catch(Exception&)
+ {
+ DBG_ERROR("OTableSelectionPage::commitPage: caught an exception!");
+ }
+
+ return sal_True;
+ }
+
+ //---------------------------------------------------------------------
+ IMPL_LINK( OTableSelectionPage, OnSearchClicked, PushButton*, /*_pButton*/ )
+ {
+ ::sfx2::FileDialogHelper aFileDlg(WB_3DLOOK);
+ aFileDlg.SetDisplayDirectory( SvtPathOptions().GetWorkPath() );
+
+ static const String s_sDatabaseType = String::CreateFromAscii("StarOffice XML (Base)");
+ const SfxFilter* pFilter = SfxFilter::GetFilterByName( s_sDatabaseType);
+ OSL_ENSURE(pFilter,"Filter: StarOffice XML (Base) could not be found!");
+ if ( pFilter )
+ {
+ aFileDlg.AddFilter(pFilter->GetUIName(),pFilter->GetDefaultExtension());
+ }
+
+ if (0 == aFileDlg.Execute())
+ {
+ String sDataSourceName = aFileDlg.GetPath();
+ ::svt::OFileNotation aFileNotation(sDataSourceName);
+ sDataSourceName = aFileNotation.get(::svt::OFileNotation::N_SYSTEM);
+ m_aDatasource.InsertEntry(sDataSourceName);
+ m_aDatasource.SelectEntry(sDataSourceName);
+ LINK(this, OTableSelectionPage, OnListboxSelection).Call(&m_aDatasource);
+ }
+ return 0L;
+ }
+ //---------------------------------------------------------------------
+ IMPL_LINK( OTableSelectionPage, OnListboxDoubleClicked, ListBox*, _pBox )
+ {
+ if (_pBox->GetSelectEntryCount())
+ getDialog()->travelNext();
+ return 0L;
+ }
+
+ //---------------------------------------------------------------------
+ IMPL_LINK( OTableSelectionPage, OnListboxSelection, ListBox*, _pBox )
+ {
+ if (&m_aDatasource == _pBox)
+ { // new data source selected
+ implFillTables();
+ }
+ else
+ {
+ }
+
+ updateDialogTravelUI();
+
+ return 0L;
+ }
+
+ //---------------------------------------------------------------------
+ namespace
+ {
+ void lcl_fillEntries( ListBox& _rListBox, const Sequence< ::rtl::OUString >& _rNames, const Image& _rImage, sal_Int32 _nCommandType )
+ {
+ const ::rtl::OUString* pNames = _rNames.getConstArray();
+ const ::rtl::OUString* pNamesEnd = _rNames.getConstArray() + _rNames.getLength();
+ sal_uInt16 nPos = 0;
+ while ( pNames != pNamesEnd )
+ {
+ nPos = _rListBox.InsertEntry( *pNames++, _rImage );
+ _rListBox.SetEntryData( nPos, reinterpret_cast< void* >( _nCommandType ) );
+ }
+ }
+ }
+
+ //---------------------------------------------------------------------
+ void OTableSelectionPage::implFillTables(const Reference< XConnection >& _rxConn)
+ {
+ m_aTable.Clear();
+
+ WaitObject aWaitCursor(this);
+
+ // will be the table tables of the selected data source
+ Sequence< ::rtl::OUString > aTableNames;
+ Sequence< ::rtl::OUString > aQueryNames;
+
+ // connect to the data source
+ Any aSQLException;
+ Reference< XConnection > xConn = _rxConn;
+ if ( !xConn.is() )
+ {
+ if (!m_xDSContext.is())
+ return;
+ // connect to the data source
+ try
+ {
+ ::rtl::OUString sCurrentDatasource = m_aDatasource.GetSelectEntry();
+ if (sCurrentDatasource.getLength())
+ {
+ // obtain the DS object
+ Reference< XCompletedConnection > xDatasource;
+ // check if I know this one otherwise transform it into a file URL
+ if ( !m_xDSContext->hasByName(sCurrentDatasource) )
+ {
+ ::svt::OFileNotation aFileNotation(sCurrentDatasource);
+ sCurrentDatasource = aFileNotation.get(::svt::OFileNotation::N_URL);
+ }
+
+ if (m_xDSContext->getByName(sCurrentDatasource) >>= xDatasource)
+ { // connect
+ // get the default SDB interaction handler
+ Reference< XInteractionHandler > xHandler = getDialog()->getInteractionHandler(this);
+ if (!xHandler.is() )
+ return;
+ xConn = xDatasource->connectWithCompletion(xHandler);
+ setFormConnection( xConn );
+ }
+ else
+ {
+ DBG_ERROR("OTableSelectionPage::implFillTables: invalid data source object returned by the context");
+ }
+ }
+ }
+ catch(SQLContext& e) { aSQLException <<= e; }
+ catch(SQLWarning& e) { aSQLException <<= e; }
+ catch(SQLException& e) { aSQLException <<= e; }
+ catch (Exception&)
+ {
+ DBG_ERROR("OTableSelectionPage::implFillTables: could not fill the table list!");
+ }
+ }
+
+ // will be the table tables of the selected data source
+ if ( xConn.is() )
+ {
+ try
+ {
+ // get the tables
+ Reference< XTablesSupplier > xSupplTables(xConn, UNO_QUERY);
+ if ( xSupplTables.is() )
+ {
+ Reference< XNameAccess > xTables(xSupplTables->getTables(), UNO_QUERY);
+ if (xTables.is())
+ aTableNames = xTables->getElementNames();
+ }
+
+ // and the queries
+ Reference< XQueriesSupplier > xSuppQueries( xConn, UNO_QUERY );
+ if ( xSuppQueries.is() )
+ {
+ Reference< XNameAccess > xQueries( xSuppQueries->getQueries(), UNO_QUERY );
+ if ( xQueries.is() )
+ aQueryNames = xQueries->getElementNames();
+ }
+ }
+ catch(SQLContext& e) { aSQLException <<= e; }
+ catch(SQLWarning& e) { aSQLException <<= e; }
+ catch(SQLException& e) { aSQLException <<= e; }
+ catch (Exception&)
+ {
+ DBG_ERROR("OTableSelectionPage::implFillTables: could not fill the table list!");
+ }
+ }
+
+
+ if ( aSQLException.hasValue() )
+ { // an SQLException (or derivee) was thrown ...
+ Reference< XInteractionRequest > xRequest = new OInteractionRequest(aSQLException);
+ try
+ {
+ // get the default SDB interaction handler
+ Reference< XInteractionHandler > xHandler = getDialog()->getInteractionHandler(this);
+ if ( xHandler.is() )
+ xHandler->handle(xRequest);
+ }
+ catch(Exception&) { }
+ return;
+ }
+
+ Image aTableImage, aQueryImage;
+ {
+ ::svt::OLocalResourceAccess aLocalResAccess( ModuleRes( RID_PAGE_TABLESELECTION ), RSC_TABPAGE );
+
+ bool bIsHiContrast = m_aTable.GetSettings().GetStyleSettings().GetHighContrastMode();
+ aTableImage = Image( ModuleRes( bIsHiContrast ? IMG_TABLE_HC : IMG_TABLE ) );
+ aQueryImage = Image( ModuleRes( bIsHiContrast ? IMG_QUERY_HC : IMG_QUERY ) );
+ }
+ lcl_fillEntries( m_aTable, aTableNames, aTableImage, CommandType::TABLE );
+ lcl_fillEntries( m_aTable, aQueryNames, aQueryImage, CommandType::QUERY );
+ }
+
+ //---------------------------------------------------------------------
+ void OTableSelectionPage::implCollectDatasource()
+ {
+ try
+ {
+ m_xDSContext = getContext().xDatasourceContext;
+ if (m_xDSContext.is())
+ fillListBox(m_aDatasource, m_xDSContext->getElementNames());
+ }
+ catch (Exception&)
+ {
+ DBG_ERROR("OTableSelectionPage::implCollectDatasource: could not collect the data source names!");
+ }
+ }
+
+ //=====================================================================
+ //= OMaybeListSelectionPage
+ //=====================================================================
+ //---------------------------------------------------------------------
+ OMaybeListSelectionPage::OMaybeListSelectionPage( OControlWizard* _pParent, const ResId& _rId )
+ :OControlWizardPage(_pParent, _rId)
+ ,m_pYes(NULL)
+ ,m_pNo(NULL)
+ ,m_pList(NULL)
+ {
+ }
+
+ //---------------------------------------------------------------------
+ void OMaybeListSelectionPage::announceControls(RadioButton& _rYesButton, RadioButton& _rNoButton, ListBox& _rSelection)
+ {
+ m_pYes = &_rYesButton;
+ m_pNo = &_rNoButton;
+ m_pList = &_rSelection;
+
+ m_pYes->SetClickHdl(LINK(this, OMaybeListSelectionPage, OnRadioSelected));
+ m_pNo->SetClickHdl(LINK(this, OMaybeListSelectionPage, OnRadioSelected));
+ implEnableWindows();
+ }
+
+ //---------------------------------------------------------------------
+ IMPL_LINK( OMaybeListSelectionPage, OnRadioSelected, RadioButton*, /*NOTINTERESTEDIN*/ )
+ {
+ implEnableWindows();
+ return 0L;
+ }
+
+ //---------------------------------------------------------------------
+ void OMaybeListSelectionPage::implInitialize(const String& _rSelection)
+ {
+ DBG_ASSERT(m_pYes, "OMaybeListSelectionPage::implInitialize: no controls announced!");
+ sal_Bool bIsSelection = (0 != _rSelection.Len());
+ m_pYes->Check(bIsSelection);
+ m_pNo->Check(!bIsSelection);
+ m_pList->Enable(bIsSelection);
+
+ m_pList->SelectEntry(bIsSelection ? _rSelection : String());
+ }
+
+ //---------------------------------------------------------------------
+ void OMaybeListSelectionPage::implCommit(String& _rSelection)
+ {
+ _rSelection = m_pYes->IsChecked() ? m_pList->GetSelectEntry() : String();
+ }
+
+ //---------------------------------------------------------------------
+ void OMaybeListSelectionPage::implEnableWindows()
+ {
+ m_pList->Enable(m_pYes->IsChecked());
+ }
+
+ //---------------------------------------------------------------------
+ void OMaybeListSelectionPage::ActivatePage()
+ {
+ OControlWizardPage::ActivatePage();
+
+ DBG_ASSERT(m_pYes, "OMaybeListSelectionPage::ActivatePage: no controls announced!");
+ if (m_pYes->IsChecked())
+ m_pList->GrabFocus();
+ else
+ m_pNo->GrabFocus();
+ }
+
+ //=====================================================================
+ //= ODBFieldPage
+ //=====================================================================
+ //---------------------------------------------------------------------
+ ODBFieldPage::ODBFieldPage( OControlWizard* _pParent )
+ :OMaybeListSelectionPage(_pParent, ModuleRes(RID_PAGE_OPTION_DBFIELD))
+ ,m_aFrame (this, ModuleRes(FL_DATABASEFIELD_EXPL))
+ ,m_aDescription (this, ModuleRes(FT_DATABASEFIELD_EXPL))
+ ,m_aQuestion (this, ModuleRes(FT_DATABASEFIELD_QUEST))
+ ,m_aStoreYes (this, ModuleRes(RB_STOREINFIELD_YES))
+ ,m_aStoreNo (this, ModuleRes(LB_STOREINFIELD))
+ ,m_aStoreWhere (this, ModuleRes(RB_STOREINFIELD_NO))
+ {
+ FreeResource();
+ announceControls(m_aStoreYes, m_aStoreNo, m_aStoreWhere);
+ m_aStoreWhere.SetDropDownLineCount(10);
+ }
+
+ //---------------------------------------------------------------------
+ void ODBFieldPage::initializePage()
+ {
+ OMaybeListSelectionPage::initializePage();
+
+ // fill the fields page
+ fillListBox(m_aStoreWhere, getContext().aFieldNames);
+
+ implInitialize(getDBFieldSetting());
+ }
+
+ //---------------------------------------------------------------------
+ sal_Bool ODBFieldPage::commitPage( ::svt::WizardTypes::CommitPageReason _eReason )
+ {
+ if (!OMaybeListSelectionPage::commitPage(_eReason))
+ return sal_False;
+
+ implCommit(getDBFieldSetting());
+
+ return sal_True;
+ }
+
+//.........................................................................
+} // namespace dbp
+//.........................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/dbpilots/commonpagesdbp.hxx b/extensions/source/dbpilots/commonpagesdbp.hxx
new file mode 100644
index 000000000000..bdeb59fff3ec
--- /dev/null
+++ b/extensions/source/dbpilots/commonpagesdbp.hxx
@@ -0,0 +1,148 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _EXTENSIONS_DBP_COMMONPAGESDBP_HXX_
+#define _EXTENSIONS_DBP_COMMONPAGESDBP_HXX_
+
+#include "controlwizard.hxx"
+#include <vcl/fixed.hxx>
+#include <vcl/lstbox.hxx>
+#include <com/sun/star/container/XNameAccess.hpp>
+
+//.........................................................................
+namespace dbp
+{
+//.........................................................................
+
+ //=====================================================================
+ //= OTableSelectionPage
+ //=====================================================================
+ class OTableSelectionPage : public OControlWizardPage
+ {
+ protected:
+ FixedLine m_aData;
+ FixedText m_aExplanation;
+ FixedText m_aDatasourceLabel;
+ ListBox m_aDatasource;
+ PushButton m_aSearchDatabase;
+ FixedText m_aTableLabel;
+ ListBox m_aTable;
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >
+ m_xDSContext;
+
+ public:
+ OTableSelectionPage(OControlWizard* _pParent);
+
+ protected:
+ // TabPage overridables
+ void ActivatePage();
+
+ // OWizardPage overridables
+ virtual void initializePage();
+ virtual sal_Bool commitPage( ::svt::WizardTypes::CommitPageReason _eReason );
+
+ protected:
+ DECL_LINK( OnListboxSelection, ListBox* );
+ DECL_LINK( OnListboxDoubleClicked, ListBox* );
+ DECL_LINK( OnSearchClicked, PushButton* );
+
+ void implCollectDatasource();
+ void implFillTables(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >&
+ _rxConn = ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >());
+
+ // OControlWizardPage overridables
+ virtual bool canAdvance() const;
+ };
+
+ //=====================================================================
+ //= OMaybeListSelectionPage
+ //=====================================================================
+ class OMaybeListSelectionPage : public OControlWizardPage
+ {
+ protected:
+ RadioButton* m_pYes;
+ RadioButton* m_pNo;
+ ListBox* m_pList;
+
+ public:
+ OMaybeListSelectionPage( OControlWizard* _pParent, const ResId& _rId );
+
+ protected:
+ DECL_LINK( OnRadioSelected, RadioButton* );
+
+ // TabPage overridables
+ void ActivatePage();
+
+ // own helper
+ void announceControls(
+ RadioButton& _rYesButton,
+ RadioButton& _rNoButton,
+ ListBox& _rSelection);
+
+ void implEnableWindows();
+
+ void implInitialize(const String& _rSelection);
+ void implCommit(String& _rSelection);
+ };
+
+ //=====================================================================
+ //= ODBFieldPage
+ //=====================================================================
+ class ODBFieldPage : public OMaybeListSelectionPage
+ {
+ protected:
+ FixedLine m_aFrame;
+ FixedText m_aDescription;
+ FixedText m_aQuestion;
+ RadioButton m_aStoreYes;
+ RadioButton m_aStoreNo;
+ ListBox m_aStoreWhere;
+
+ public:
+ ODBFieldPage( OControlWizard* _pParent );
+
+ protected:
+ void setDescriptionText(const String& _rDesc) { m_aDescription.SetText(_rDesc); }
+
+ // OWizardPage overridables
+ virtual void initializePage();
+ virtual sal_Bool commitPage( ::svt::WizardTypes::CommitPageReason _eReason );
+
+ // own overridables
+ virtual String& getDBFieldSetting() = 0;
+ };
+
+//.........................................................................
+} // namespace dbp
+//.........................................................................
+
+
+#endif // _EXTENSIONS_DBP_COMMONPAGESDBP_HXX_
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/dbpilots/commonpagesdbp.src b/extensions/source/dbpilots/commonpagesdbp.src
new file mode 100644
index 000000000000..783bdb48b65f
--- /dev/null
+++ b/extensions/source/dbpilots/commonpagesdbp.src
@@ -0,0 +1,230 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _EXTENSIONS_DBP_DBPRESID_HRC_
+#include "dbpresid.hrc"
+#endif
+
+TabPage RID_PAGE_TABLESELECTION
+{
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( WINDOW_SIZE_X , WINDOW_SIZE_Y ) ;
+ Text [ en-US ] = "Data";
+
+ FixedLine FL_DATA
+ {
+ Pos = MAP_APPFONT ( 4 , 3 ) ;
+ Size = MAP_APPFONT ( WINDOW_SIZE_X - 8 , 8 ) ;
+ Text [ en-US ] = "Data";
+ };
+ FixedText FT_EXPLANATION
+ {
+ Pos = MAP_APPFONT ( 7 , 15 ) ;
+ Size = MAP_APPFONT ( WINDOW_HALF_SIZE_X - 10 , WINDOW_SIZE_Y - 21 ) ;
+ WordBreak = TRUE;
+ Group = TRUE;
+ Text [ en-US ] = "Currently, the form the control belongs to is not (or not completely) bound to a data source.\n\nPlease choose a data source and a table.\n\n\nPlease note that the settings made on this page will take effect immediately upon leaving the page.";
+ };
+ FixedText FT_DATASOURCE
+ {
+ Pos = MAP_APPFONT ( WINDOW_HALF_SIZE_X + 3 , 15 ) ;
+ Size = MAP_APPFONT ( WINDOW_HALF_SIZE_X - 10 , 8) ;
+ Group = TRUE;
+ Text [ en-US ] = "~Data source:";
+ };
+ ListBox LB_DATASOURCE
+ {
+ Pos = MAP_APPFONT ( WINDOW_HALF_SIZE_X + 3 , 26 ) ;
+ Size = MAP_APPFONT ( WINDOW_HALF_SIZE_X - 27 , 14 ) ;
+ SVLook = TRUE ;
+ Border = TRUE ;
+ DropDown = TRUE ;
+ AutoHScroll = TRUE ;
+ };
+
+ PushButton PB_FORMDATASOURCE
+ {
+ Pos = MAP_APPFONT ( WINDOW_HALF_SIZE_X + 3 + WINDOW_HALF_SIZE_X - 24 , 25 ) ;
+ Size = MAP_APPFONT ( 14 , 14 ) ;
+ Text [ en-US ] = "~...";
+ };
+
+ FixedText FT_TABLE
+ {
+ Pos = MAP_APPFONT ( WINDOW_HALF_SIZE_X + 3, 46 ) ;
+ Size = MAP_APPFONT ( WINDOW_HALF_SIZE_X - 14 , 8) ;
+ Group = TRUE;
+ Text [ en-US ] = "~Table / Query:";
+ };
+ ListBox LB_TABLE
+ {
+ Pos = MAP_APPFONT ( WINDOW_HALF_SIZE_X + 3, 57 ) ;
+ Size = MAP_APPFONT ( WINDOW_HALF_SIZE_X - 10 , WINDOW_SIZE_Y - 6 - 57 ) ;
+ SVLook = TRUE ;
+ Border = TRUE ;
+ Sort = TRUE;
+ AutoHScroll = TRUE ;
+ };
+
+ Image IMG_TABLE
+ {
+ ImageBitmap = Bitmap { File = "sx03188.bmp"; };
+ MaskColor = Color { Red = 0xFFFF; Green = 0x0; Blue = 0xFFFF; };
+ };
+
+ Image IMG_TABLE_HC
+ {
+ ImageBitmap = Bitmap { File = "sxh03188.bmp"; };
+ MaskColor = Color { Red = 0xFFFF; Green = 0x0; Blue = 0xFFFF; };
+ };
+
+ Image IMG_QUERY
+ {
+ ImageBitmap = Bitmap { File = "sx03202.bmp"; };
+ MaskColor = Color { Red = 0xFFFF; Green = 0x0; Blue = 0xFFFF; };
+ };
+
+ Image IMG_QUERY_HC
+ {
+ ImageBitmap = Bitmap { File = "sxh03202.bmp"; };
+ MaskColor = Color { Red = 0xFFFF; Green = 0x0; Blue = 0xFFFF; };
+ };
+
+};
+
+TabPage RID_PAGE_OPTION_DBFIELD
+{
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( WINDOW_SIZE_X , WINDOW_SIZE_Y ) ;
+ Text [ en-US ] = "Database Field";
+
+ FixedLine FL_DATABASEFIELD_EXPL
+ {
+ Pos = MAP_APPFONT ( 4 , 3 ) ;
+ Size = MAP_APPFONT ( WINDOW_SIZE_X - 8 , 8 ) ;
+ };
+ FixedText FT_DATABASEFIELD_EXPL
+ {
+ Pos = MAP_APPFONT ( 7 , 15 ) ;
+ Size = MAP_APPFONT ( WINDOW_SIZE_X - 14, 16 ) ;
+ WordBreak = TRUE;
+ };
+ FixedText FT_DATABASEFIELD_QUEST
+ {
+ Pos = MAP_APPFONT ( 7 , 34 ) ;
+ Size = MAP_APPFONT ( WINDOW_SIZE_X - 14, 16 ) ;
+ WordBreak = TRUE;
+ Text [ en-US ] = "Do you want to save the value in a database field?";
+ };
+ RadioButton RB_STOREINFIELD_YES
+ {
+ Pos = MAP_APPFONT ( 7 , 53 ) ;
+ Size = MAP_APPFONT ( WINDOW_HALF_SIZE_X + 20, 10 ) ;
+ Group = TRUE;
+ TabStop = TRUE;
+ Text [ en-US ] = "~Yes, I want to save it in the following database field:";
+ };
+ ListBox LB_STOREINFIELD
+ {
+ Pos = MAP_APPFONT ( WINDOW_HALF_SIZE_X + 23, 51 ) ;
+ Size = MAP_APPFONT ( WINDOW_HALF_SIZE_X - 30, 14 ) ;
+ TabStop = TRUE;
+ SVLook = TRUE ;
+ Border = TRUE ;
+ DropDown = TRUE;
+ AutoHScroll = TRUE ;
+ };
+ RadioButton RB_STOREINFIELD_NO
+ {
+ Pos = MAP_APPFONT ( 7 , 68 ) ;
+ Size = MAP_APPFONT ( WINDOW_SIZE_X - 14, 10 ) ;
+ TabStop = FALSE;
+ Text [ en-US ] = "~No, I only want to save the value in the form.";
+ };
+};
+
+TabPage RID_PAGE_FORM_DATASOURCE_STATUS
+{
+ FixedLine FL_FORMSETINGS
+ {
+ Pos = MAP_APPFONT ( 4 , 3 ) ;
+ Size = MAP_APPFONT ( WINDOW_SIZE_X - 8 , 8 ) ;
+ Text [ en-US ] = "Form";
+ };
+ FixedText FT_FORMDATASOURCELABEL
+ {
+ Pos = MAP_APPFONT ( 7 , 15 ) ;
+ Size = MAP_APPFONT ( 60 , 8 ) ;
+ Text [ en-US ] = "Data source";
+ };
+ FixedText FT_FORMDATASOURCE
+ {
+ Pos = MAP_APPFONT ( 7 + 60 + 3 , 15 ) ;
+ Size = MAP_APPFONT ( WINDOW_SIZE_X / 2 - 80 - 3 , 19 ) ;
+ WordBreak = TRUE;
+ };
+
+ FixedText FT_FORMCONTENTTYPELABEL
+ {
+ Pos = MAP_APPFONT ( WINDOW_SIZE_X / 2 + 3, 15 ) ;
+ Size = MAP_APPFONT ( 60 , 8 ) ;
+ Text [ en-US ] = "Content type";
+ };
+ FixedText FT_FORMCONTENTTYPE
+ {
+ Pos = MAP_APPFONT ( WINDOW_SIZE_X / 2 + 3 + 60 , 15 ) ;
+ Size = MAP_APPFONT ( WINDOW_SIZE_X - ( WINDOW_SIZE_X / 2 + 3 + 60 ) - 7 , 8 ) ;
+ };
+
+ FixedText FT_FORMTABLELABEL
+ {
+ Pos = MAP_APPFONT ( WINDOW_SIZE_X / 2 + 3, 26 ) ;
+ Size = MAP_APPFONT ( 60 , 8 ) ;
+ Text [ en-US ] = "Content";
+ };
+ FixedText FT_FORMTABLE
+ {
+ Pos = MAP_APPFONT ( WINDOW_SIZE_X / 2 + 3 + 60 , 26 ) ;
+ Size = MAP_APPFONT ( WINDOW_SIZE_X - ( WINDOW_SIZE_X / 2 + 3 + 60 ) - 7 , 8 ) ;
+ };
+};
+
+String RID_STR_TYPE_TABLE
+{
+ Text [ en-US ] = "Table";
+};
+
+String RID_STR_TYPE_QUERY
+{
+ Text [ en-US ] = "Query";
+};
+
+String RID_STR_TYPE_COMMAND
+{
+ Text [ en-US ] = "SQL command";
+};
+
diff --git a/extensions/source/dbpilots/controlwizard.cxx b/extensions/source/dbpilots/controlwizard.cxx
new file mode 100644
index 000000000000..45e436d28fd0
--- /dev/null
+++ b/extensions/source/dbpilots/controlwizard.cxx
@@ -0,0 +1,779 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+#include "controlwizard.hxx"
+#include <tools/debug.hxx>
+#include <com/sun/star/container/XNameAccess.hpp>
+#include <com/sun/star/sdbcx/XTablesSupplier.hpp>
+#include <com/sun/star/sdb/XQueriesSupplier.hpp>
+#include <com/sun/star/sdbc/XPreparedStatement.hpp>
+#include <com/sun/star/container/XChild.hpp>
+#include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
+#include <com/sun/star/frame/XModel.hpp>
+#include <com/sun/star/sheet/XSpreadsheetView.hpp>
+#include <com/sun/star/drawing/XDrawView.hpp>
+#include <com/sun/star/drawing/XDrawPageSupplier.hpp>
+#include <com/sun/star/sdb/CommandType.hpp>
+#include <com/sun/star/sdbc/SQLWarning.hpp>
+#include <com/sun/star/sdb/SQLContext.hpp>
+#include <comphelper/types.hxx>
+#include <connectivity/dbtools.hxx>
+#include <vcl/msgbox.hxx>
+#include <comphelper/interaction.hxx>
+#include <vcl/stdtext.hxx>
+#include <svtools/localresaccess.hxx>
+#include <connectivity/conncleanup.hxx>
+#include <com/sun/star/sdbc/DataType.hpp>
+#include <tools/urlobj.hxx>
+
+//.........................................................................
+namespace dbp
+{
+//.........................................................................
+
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::awt;
+ using namespace ::com::sun::star::lang;
+ using namespace ::com::sun::star::sdb;
+ using namespace ::com::sun::star::sdbc;
+ using namespace ::com::sun::star::sdbcx;
+ using namespace ::com::sun::star::beans;
+ using namespace ::com::sun::star::container;
+ using namespace ::com::sun::star::drawing;
+ using namespace ::com::sun::star::frame;
+ using namespace ::com::sun::star::sheet;
+ using namespace ::com::sun::star::form;
+ using namespace ::com::sun::star::task;
+ using namespace ::svt;
+ using namespace ::comphelper;
+ using namespace ::dbtools;
+
+ //=====================================================================
+ //= OAccessRegulator
+ //=====================================================================
+ struct OAccessRegulator
+ {
+ friend class OControlWizardPage;
+
+ protected:
+ OAccessRegulator() { }
+ };
+
+ //=====================================================================
+ //= OControlWizardPage
+ //=====================================================================
+ //---------------------------------------------------------------------
+ OControlWizardPage::OControlWizardPage( OControlWizard* _pParent, const ResId& _rResId )
+ :OControlWizardPage_Base( _pParent, _rResId )
+ ,m_pFormSettingsSeparator(NULL)
+ ,m_pFormDatasourceLabel(NULL)
+ ,m_pFormDatasource(NULL)
+ ,m_pFormContentTypeLabel(NULL)
+ ,m_pFormContentType(NULL)
+ ,m_pFormTableLabel(NULL)
+ ,m_pFormTable(NULL)
+ {
+ }
+
+ //---------------------------------------------------------------------
+ OControlWizardPage::~OControlWizardPage()
+ {
+ delete m_pFormSettingsSeparator;
+ delete m_pFormDatasourceLabel;
+ delete m_pFormDatasource;
+ delete m_pFormContentTypeLabel;
+ delete m_pFormContentType;
+ delete m_pFormTableLabel;
+ delete m_pFormTable;
+ }
+
+ //---------------------------------------------------------------------
+ OControlWizard* OControlWizardPage::getDialog()
+ {
+ return static_cast< OControlWizard* >(GetParent());
+ }
+
+ //---------------------------------------------------------------------
+ const OControlWizard* OControlWizardPage::getDialog() const
+ {
+ return static_cast< OControlWizard* >(GetParent());
+ }
+
+ //---------------------------------------------------------------------
+ sal_Bool OControlWizardPage::updateContext()
+ {
+ return getDialog()->updateContext(OAccessRegulator());
+ }
+
+ //---------------------------------------------------------------------
+ Reference< XConnection > OControlWizardPage::getFormConnection() const
+ {
+ return getDialog()->getFormConnection(OAccessRegulator());
+ }
+
+ //---------------------------------------------------------------------
+ void OControlWizardPage::setFormConnection( const Reference< XConnection >& _rxConn, sal_Bool _bAutoDispose )
+ {
+ getDialog()->setFormConnection( OAccessRegulator(), _rxConn, _bAutoDispose );
+ }
+
+ //---------------------------------------------------------------------
+ const OControlWizardContext& OControlWizardPage::getContext()
+ {
+ return getDialog()->getContext();
+ }
+
+ //---------------------------------------------------------------------
+ void OControlWizardPage::fillListBox(ListBox& _rList, const Sequence< ::rtl::OUString >& _rItems, sal_Bool _bClear)
+ {
+ if (_bClear)
+ _rList.Clear();
+ const ::rtl::OUString* pItems = _rItems.getConstArray();
+ const ::rtl::OUString* pEnd = pItems + _rItems.getLength();
+ ::svt::WizardTypes::WizardState nPos;
+ sal_Int32 nIndex = 0;
+ for (;pItems < pEnd; ++pItems, ++nIndex)
+ {
+ nPos = _rList.InsertEntry(*pItems);
+ _rList.SetEntryData(nPos, reinterpret_cast<void*>(nIndex));
+ }
+ }
+
+ //---------------------------------------------------------------------
+ void OControlWizardPage::fillListBox(ComboBox& _rList, const Sequence< ::rtl::OUString >& _rItems, sal_Bool _bClear)
+ {
+ if (_bClear)
+ _rList.Clear();
+ const ::rtl::OUString* pItems = _rItems.getConstArray();
+ const ::rtl::OUString* pEnd = pItems + _rItems.getLength();
+ ::svt::WizardTypes::WizardState nPos;
+ sal_Int32 nIndex = 0;
+ for (;pItems < pEnd; ++pItems)
+ {
+ nPos = _rList.InsertEntry(*pItems);
+ _rList.SetEntryData(nPos, reinterpret_cast<void*>(nIndex));
+ }
+ }
+
+ //---------------------------------------------------------------------
+ void OControlWizardPage::enableFormDatasourceDisplay()
+ {
+ if (m_pFormSettingsSeparator)
+ // nothing to do
+ return;
+
+ ModuleRes aModuleRes(RID_PAGE_FORM_DATASOURCE_STATUS);
+ OLocalResourceAccess aLocalControls(aModuleRes, RSC_TABPAGE);
+
+ m_pFormSettingsSeparator = new FixedLine(this, ModuleRes(FL_FORMSETINGS));
+ m_pFormDatasourceLabel = new FixedText(this, ModuleRes(FT_FORMDATASOURCELABEL));
+ m_pFormDatasource = new FixedText(this, ModuleRes(FT_FORMDATASOURCE));
+ m_pFormContentTypeLabel = new FixedText(this, ModuleRes(FT_FORMCONTENTTYPELABEL));
+ m_pFormContentType = new FixedText(this, ModuleRes(FT_FORMCONTENTTYPE));
+ m_pFormTableLabel = new FixedText(this, ModuleRes(FT_FORMTABLELABEL));
+ m_pFormTable = new FixedText(this, ModuleRes(FT_FORMTABLE));
+
+ const OControlWizardContext& rContext = getContext();
+ if ( rContext.bEmbedded )
+ {
+ m_pFormDatasourceLabel->Hide();
+ m_pFormDatasource->Hide();
+ m_pFormContentTypeLabel->SetPosPixel(m_pFormDatasourceLabel->GetPosPixel());
+ m_pFormContentType->SetPosPixel(m_pFormDatasource->GetPosPixel());
+ m_pFormTableLabel->SetPosPixel(::Point(m_pFormDatasourceLabel->GetPosPixel().X(),m_pFormTableLabel->GetPosPixel().Y()));
+ m_pFormTable->SetPosPixel(::Point(m_pFormDatasource->GetPosPixel().X(),m_pFormTable->GetPosPixel().Y()));
+ }
+ }
+
+ //---------------------------------------------------------------------
+ void OControlWizardPage::adjustControlForNoDSDisplay(Control* _pControl, sal_Bool _bConstLowerDistance)
+ {
+ ::Size aDistanceToMove = LogicToPixel( ::Size( 0, 37 ), MAP_APPFONT );
+
+ ::Point aPos = _pControl->GetPosPixel();
+ aPos.Y() -= aDistanceToMove.Height();
+ _pControl->SetPosPixel(aPos);
+
+ if (_bConstLowerDistance)
+ {
+ ::Size aSize = _pControl->GetSizePixel();
+ aSize.Height() += aDistanceToMove.Height();
+ _pControl->SetSizePixel(aSize);
+ }
+ }
+
+ //---------------------------------------------------------------------
+ void OControlWizardPage::initializePage()
+ {
+ if (m_pFormDatasource && m_pFormContentTypeLabel && m_pFormTable)
+ {
+ const OControlWizardContext& rContext = getContext();
+ ::rtl::OUString sDataSource;
+ ::rtl::OUString sCommand;
+ sal_Int32 nCommandType = CommandType::COMMAND;
+ try
+ {
+ rContext.xForm->getPropertyValue(::rtl::OUString::createFromAscii("DataSourceName")) >>= sDataSource;
+ rContext.xForm->getPropertyValue(::rtl::OUString::createFromAscii("Command")) >>= sCommand;
+ rContext.xForm->getPropertyValue(::rtl::OUString::createFromAscii("CommandType")) >>= nCommandType;
+ }
+ catch(const Exception&)
+ {
+ DBG_ERROR("OControlWizardPage::initializePage: caught an exception!");
+ }
+
+ INetURLObject aURL( sDataSource );
+ if( aURL.GetProtocol() != INET_PROT_NOT_VALID )
+ sDataSource = aURL.GetName(INetURLObject::DECODE_WITH_CHARSET);
+ m_pFormDatasource->SetText(sDataSource);
+ m_pFormTable->SetText(sCommand);
+
+ ::svt::WizardTypes::WizardState nCommandTypeResourceId = 0;
+ switch (nCommandType)
+ {
+ case CommandType::TABLE:
+ nCommandTypeResourceId = RID_STR_TYPE_TABLE;
+ break;
+
+ case CommandType::QUERY:
+ nCommandTypeResourceId = RID_STR_TYPE_QUERY;
+ break;
+
+ default:
+ nCommandTypeResourceId = RID_STR_TYPE_COMMAND;
+ break;
+ }
+ m_pFormContentType->SetText(String(ModuleRes(nCommandTypeResourceId)));
+ }
+
+ OControlWizardPage_Base::initializePage();
+ }
+
+ //=====================================================================
+ //= OControlWizard
+ //=====================================================================
+ //---------------------------------------------------------------------
+ OControlWizard::OControlWizard( Window* _pParent, const ResId& _rId,
+ const Reference< XPropertySet >& _rxObjectModel, const Reference< XMultiServiceFactory >& _rxORB )
+ :OWizardMachine(_pParent, _rId, WZB_CANCEL | WZB_PREVIOUS | WZB_NEXT | WZB_FINISH)
+ ,m_xORB(_rxORB)
+ {
+ m_aContext.xObjectModel = _rxObjectModel;
+ initContext();
+
+ SetPageSizePixel(LogicToPixel(::Size(WINDOW_SIZE_X, WINDOW_SIZE_Y), MAP_APPFONT));
+ ShowButtonFixedLine(sal_True);
+ defaultButton(WZB_NEXT);
+ enableButtons(WZB_FINISH, sal_False);
+ }
+
+ //---------------------------------------------------------------------
+ OControlWizard::~OControlWizard()
+ {
+ }
+
+ //---------------------------------------------------------------------
+ short OControlWizard::Execute()
+ {
+ // get the class id of the control we're dealing with
+ sal_Int16 nClassId = FormComponentType::CONTROL;
+ try
+ {
+ getContext().xObjectModel->getPropertyValue(::rtl::OUString::createFromAscii("ClassId")) >>= nClassId;
+ }
+ catch(Exception&)
+ {
+ DBG_ERROR("OControlWizard::activate: could not obtain the class id!");
+ }
+ if (!approveControl(nClassId))
+ {
+ // TODO: MessageBox or exception
+ return RET_CANCEL;
+ }
+
+ ActivatePage();
+
+ return OControlWizard_Base::Execute();
+ }
+
+ //---------------------------------------------------------------------
+ void OControlWizard::ActivatePage()
+ {
+ OControlWizard_Base::ActivatePage();
+ }
+
+ //---------------------------------------------------------------------
+ void OControlWizard::implDetermineShape()
+ {
+ Reference< XIndexAccess > xPageObjects(m_aContext.xDrawPage, UNO_QUERY);
+ DBG_ASSERT(xPageObjects.is(), "OControlWizard::implDetermineShape: invalid page!");
+
+ // for comparing the model
+ Reference< XControlModel > xModelCompare(m_aContext.xObjectModel, UNO_QUERY);
+
+ if (xPageObjects.is())
+ {
+ // loop through all objects of the page
+ sal_Int32 nObjects = xPageObjects->getCount();
+ Reference< XControlShape > xControlShape;
+ Reference< XControlModel > xControlModel;
+ for (sal_Int32 i=0; i<nObjects; ++i)
+ {
+ if (xPageObjects->getByIndex(i) >>= xControlShape)
+ { // it _is_ a control shape
+ xControlModel = xControlShape->getControl();
+ DBG_ASSERT(xControlModel.is(), "OControlWizard::implDetermineShape: control shape without model!");
+ if (xModelCompare.get() == xControlModel.get())
+ {
+ m_aContext.xObjectShape = xControlShape;
+ break;
+ }
+ }
+ }
+ }
+ }
+
+ //---------------------------------------------------------------------
+ void OControlWizard::implDetermineForm()
+ {
+ Reference< XChild > xModelAsChild(m_aContext.xObjectModel, UNO_QUERY);
+ Reference< XInterface > xControlParent;
+ if (xModelAsChild.is())
+ xControlParent = xModelAsChild->getParent();
+
+ m_aContext.xForm = Reference< XPropertySet >(xControlParent, UNO_QUERY);
+ m_aContext.xRowSet = Reference< XRowSet >(xControlParent, UNO_QUERY);
+ DBG_ASSERT(m_aContext.xForm.is() && m_aContext.xRowSet.is(),
+ "OControlWizard::implDetermineForm: missing some interfaces of the control parent!");
+
+ }
+
+ //---------------------------------------------------------------------
+ void OControlWizard::implDeterminePage()
+ {
+ try
+ {
+ // get the document model
+ Reference< XChild > xControlAsChild(m_aContext.xObjectModel, UNO_QUERY);
+ Reference< XChild > xModelSearch(xControlAsChild->getParent(), UNO_QUERY);
+
+ Reference< XModel > xModel(xModelSearch, UNO_QUERY);
+ while (xModelSearch.is() && !xModel.is())
+ {
+ xModelSearch = Reference< XChild >(xModelSearch->getParent(), UNO_QUERY);
+ xModel = Reference< XModel >(xModelSearch, UNO_QUERY);
+ }
+
+ Reference< XDrawPage > xPage;
+ if (xModel.is())
+ {
+ m_aContext.xDocumentModel = xModel;
+
+ Reference< XDrawPageSupplier > xPageSupp(xModel, UNO_QUERY);
+ if (xPageSupp.is())
+ { // it's a document with only one page -> Writer
+ xPage = xPageSupp->getDrawPage();
+ }
+ else
+ {
+ // get the controller currently working on this model
+ Reference< XController > xController = xModel->getCurrentController();
+ DBG_ASSERT(xController.is(), "OControlWizard::implDeterminePage: no current controller!");
+
+ // maybe it's a spredsheet
+ Reference< XSpreadsheetView > xView(xController, UNO_QUERY);
+ if (xView.is())
+ { // okay, it is one
+ Reference< XSpreadsheet > xSheet = xView->getActiveSheet();
+ xPageSupp = Reference< XDrawPageSupplier >(xSheet, UNO_QUERY);
+ DBG_ASSERT(xPageSupp.is(), "OControlWizard::implDeterminePage: a spreadsheet which is no page supplier!");
+ if (xPageSupp.is())
+ xPage = xPageSupp->getDrawPage();
+ }
+ else
+ { // can be a draw/impress doc only
+ Reference< XDrawView > xDrawView(xController, UNO_QUERY);
+ DBG_ASSERT(xDrawView.is(), "OControlWizard::implDeterminePage: no alternatives left ... can't determine the page!");
+ if (xDrawView.is())
+ xPage = xDrawView->getCurrentPage();
+ }
+ }
+ }
+ else
+ {
+ DBG_ASSERT(xPage.is(), "OControlWizard::implDeterminePage: can't determine the page (no model)!");
+ }
+ m_aContext.xDrawPage = xPage;
+ }
+ catch(Exception&)
+ {
+ DBG_ERROR("OControlWizard::implDeterminePage: caught an exception!");
+ }
+ }
+
+ //---------------------------------------------------------------------
+ void OControlWizard::implGetDSContext()
+ {
+ Reference< XMultiServiceFactory > xORB = getServiceFactory();
+ try
+ {
+ DBG_ASSERT(xORB.is(), "OControlWizard::implGetDSContext: invalid service factory!");
+
+ Reference< XInterface > xContext;
+ if (xORB.is())
+ xContext = xORB->createInstance(::rtl::OUString::createFromAscii("com.sun.star.sdb.DatabaseContext"));
+ DBG_ASSERT(xContext.is(), "OControlWizard::implGetDSContext: invalid database context!");
+
+ m_aContext.xDatasourceContext = Reference< XNameAccess >(xContext, UNO_QUERY);
+ DBG_ASSERT(m_aContext.xDatasourceContext.is() || !xContext.is(), "OControlWizard::implGetDSContext: invalid database context (missing the XNameAccess)!");
+ }
+ catch(Exception&)
+ {
+ DBG_ERROR("OControlWizard::implGetDSContext: invalid database context!");
+ }
+ }
+
+ //---------------------------------------------------------------------
+ Reference< XConnection > OControlWizard::getFormConnection(const OAccessRegulator&) const
+ {
+ return getFormConnection();
+ }
+ //---------------------------------------------------------------------
+ Reference< XConnection > OControlWizard::getFormConnection() const
+ {
+ Reference< XConnection > xConn;
+ try
+ {
+ if ( !::dbtools::isEmbeddedInDatabase(m_aContext.xForm,xConn) )
+ m_aContext.xForm->getPropertyValue(::rtl::OUString::createFromAscii("ActiveConnection")) >>= xConn;
+ }
+ catch(const Exception&)
+ {
+ DBG_ERROR("OControlWizard::getFormConnection: caught an exception!");
+ }
+ return xConn;
+ }
+
+ //---------------------------------------------------------------------
+ void OControlWizard::setFormConnection( const OAccessRegulator& _rAccess, const Reference< XConnection >& _rxConn, sal_Bool _bAutoDispose )
+ {
+ try
+ {
+ Reference< XConnection > xOldConn = getFormConnection(_rAccess);
+ if (xOldConn.get() == _rxConn.get())
+ return;
+
+ disposeComponent(xOldConn);
+
+ // set the new connection
+ if ( _bAutoDispose )
+ {
+ // for this, use a AutoDisposer (so the conn is cleaned up when the form dies or get's another connection)
+ Reference< XRowSet > xFormRowSet( m_aContext.xForm, UNO_QUERY );
+ OAutoConnectionDisposer* pAutoDispose = new OAutoConnectionDisposer( xFormRowSet, _rxConn );
+ Reference< XPropertyChangeListener > xEnsureDelete( pAutoDispose );
+ }
+ else
+ {
+ m_aContext.xForm->setPropertyValue( ::rtl::OUString::createFromAscii("ActiveConnection"), makeAny( _rxConn ) );
+ }
+ }
+ catch(const Exception&)
+ {
+ DBG_ERROR("OControlWizard::setFormConnection: caught an exception!");
+ }
+ }
+
+ //---------------------------------------------------------------------
+ sal_Bool OControlWizard::updateContext(const OAccessRegulator&)
+ {
+ return initContext();
+ }
+ //---------------------------------------------------------------------
+ Reference< XInteractionHandler > OControlWizard::getInteractionHandler(Window* _pWindow) const
+ {
+ const ::rtl::OUString sInteractionHandlerServiceName = ::rtl::OUString::createFromAscii("com.sun.star.task.InteractionHandler");
+ Reference< XInteractionHandler > xHandler;
+ try
+ {
+ if (getServiceFactory().is())
+ xHandler = Reference< XInteractionHandler >(getServiceFactory()->createInstance(sInteractionHandlerServiceName), UNO_QUERY);
+ }
+ catch(Exception&) { }
+ if (!xHandler.is())
+ ShowServiceNotAvailableError(_pWindow, sInteractionHandlerServiceName, sal_True);
+ return xHandler;
+ }
+ //---------------------------------------------------------------------
+ sal_Bool OControlWizard::initContext()
+ {
+ DBG_ASSERT(m_aContext.xObjectModel.is(), "OGroupBoxWizard::initContext: have no control model to work with!");
+ if (!m_aContext.xObjectModel.is())
+ return sal_False;
+
+ // reset the context
+ m_aContext.xForm.clear();
+ m_aContext.xRowSet.clear();
+ m_aContext.xDocumentModel.clear();
+ m_aContext.xDrawPage.clear();
+ m_aContext.xObjectShape.clear();
+ m_aContext.aFieldNames.realloc(0);
+
+ m_aContext.xObjectContainer.clear();
+ m_aContext.aTypes.clear();
+ m_aContext.bEmbedded = sal_False;
+
+ Any aSQLException;
+ Reference< XPreparedStatement > xStatement;
+ try
+ {
+ // get the datasource context
+ implGetDSContext();
+
+ // first, determine the form the control belongs to
+ implDetermineForm();
+
+ // need the page, too
+ implDeterminePage();
+
+ // the shape of the control
+ implDetermineShape();
+
+ // get the columns of the object the settins refer to
+ Reference< XNameAccess > xColumns;
+
+ if (m_aContext.xForm.is())
+ {
+ // collect some properties of the form
+ ::rtl::OUString sObjectName = ::comphelper::getString(m_aContext.xForm->getPropertyValue(::rtl::OUString::createFromAscii("Command")));
+ sal_Int32 nObjectType = ::comphelper::getINT32(m_aContext.xForm->getPropertyValue(::rtl::OUString::createFromAscii("CommandType")));
+
+ // calculate the connection the rowset is working with
+ Reference< XConnection > xConnection;
+ m_aContext.bEmbedded = ::dbtools::isEmbeddedInDatabase( m_aContext.xForm, xConnection );
+ if ( !m_aContext.bEmbedded )
+ xConnection = ::dbtools::connectRowset( m_aContext.xRowSet, getServiceFactory(), sal_True );
+
+ // get the fields
+ if (xConnection.is())
+ {
+ switch (nObjectType)
+ {
+ case 0:
+ {
+ Reference< XTablesSupplier > xSupplyTables(xConnection, UNO_QUERY);
+ if (xSupplyTables.is() && xSupplyTables->getTables().is() && xSupplyTables->getTables()->hasByName(sObjectName))
+ {
+ Reference< XColumnsSupplier > xSupplyColumns;
+ m_aContext.xObjectContainer = xSupplyTables->getTables();
+ m_aContext.xObjectContainer->getByName(sObjectName) >>= xSupplyColumns;
+ DBG_ASSERT(xSupplyColumns.is(), "OControlWizard::initContext: invalid table columns!");
+ xColumns = xSupplyColumns->getColumns();
+ }
+ }
+ break;
+ case 1:
+ {
+ Reference< XQueriesSupplier > xSupplyQueries(xConnection, UNO_QUERY);
+ if (xSupplyQueries.is() && xSupplyQueries->getQueries().is() && xSupplyQueries->getQueries()->hasByName(sObjectName))
+ {
+ Reference< XColumnsSupplier > xSupplyColumns;
+ m_aContext.xObjectContainer = xSupplyQueries->getQueries();
+ m_aContext.xObjectContainer->getByName(sObjectName) >>= xSupplyColumns;
+ DBG_ASSERT(xSupplyColumns.is(), "OControlWizard::initContext: invalid query columns!");
+ xColumns = xSupplyColumns->getColumns();
+ }
+ }
+ break;
+ default:
+ {
+ xStatement = xConnection->prepareStatement(sObjectName);
+
+ // not interested in any results, only in the fields
+ Reference< XPropertySet > xStatementProps(xStatement, UNO_QUERY);
+ xStatementProps->setPropertyValue(::rtl::OUString::createFromAscii("MaxRows"), makeAny(sal_Int32(0)));
+
+ // TODO: think about handling local SQLExceptions here ...
+ Reference< XColumnsSupplier > xSupplyCols(xStatement->executeQuery(), UNO_QUERY);
+ if (xSupplyCols.is())
+ xColumns = xSupplyCols->getColumns();
+ }
+ }
+ }
+ }
+
+ if (xColumns.is())
+ {
+ m_aContext.aFieldNames = xColumns->getElementNames();
+ static const ::rtl::OUString s_sFieldTypeProperty = ::rtl::OUString::createFromAscii("Type");
+ const ::rtl::OUString* pBegin = m_aContext.aFieldNames.getConstArray();
+ const ::rtl::OUString* pEnd = pBegin + m_aContext.aFieldNames.getLength();
+ for(;pBegin != pEnd;++pBegin)
+ {
+ sal_Int32 nFieldType = DataType::OTHER;
+ try
+ {
+ Reference< XPropertySet > xColumn;
+ xColumns->getByName(*pBegin) >>= xColumn;
+ xColumn->getPropertyValue(s_sFieldTypeProperty) >>= nFieldType;
+ }
+ catch(Exception&)
+ {
+ DBG_ERROR("OControlWizard::initContext: unexpected exception while gathering column information!");
+ }
+ m_aContext.aTypes.insert(OControlWizardContext::TNameTypeMap::value_type(*pBegin,nFieldType));
+ }
+ }
+ }
+ catch(SQLContext& e) { aSQLException <<= e; }
+ catch(SQLWarning& e) { aSQLException <<= e; }
+ catch(SQLException& e) { aSQLException <<= e; }
+ catch(Exception&)
+ {
+ DBG_ERROR("OControlWizard::initContext: could not retrieve the control context (caught an exception)!");
+ }
+
+ ::comphelper::disposeComponent(xStatement);
+
+ if (aSQLException.hasValue())
+ { // an SQLException (or derivee) was thrown ...
+
+ // prepend an extra SQLContext explaining what we were doing
+ SQLContext aContext;
+ aContext.Message = String(ModuleRes(RID_STR_COULDNOTOPENTABLE));
+ aContext.NextException = aSQLException;
+
+ // create an interaction handler to display this exception
+ Reference< XInteractionHandler > xHandler = getInteractionHandler(this);
+ if ( !xHandler.is() )
+ return sal_False;
+
+ Reference< XInteractionRequest > xRequest = new OInteractionRequest(makeAny(aContext));
+ try
+ {
+ xHandler->handle(xRequest);
+ }
+ catch(Exception&) { }
+ return sal_False;
+ }
+
+ return 0 != m_aContext.aFieldNames.getLength();
+ }
+
+ //---------------------------------------------------------------------
+ void OControlWizard::commitControlSettings(OControlWizardSettings* _pSettings)
+ {
+ DBG_ASSERT(m_aContext.xObjectModel.is(), "OControlWizard::commitControlSettings: have no control model to work with!");
+ if (!m_aContext.xObjectModel.is())
+ return;
+
+ // the only thing we have at the moment is the label
+ try
+ {
+ ::rtl::OUString sLabelPropertyName = ::rtl::OUString::createFromAscii("Label");
+ Reference< XPropertySetInfo > xInfo = m_aContext.xObjectModel->getPropertySetInfo();
+ if (xInfo.is() && xInfo->hasPropertyByName(sLabelPropertyName))
+ {
+ ::rtl::OUString sControlLabel(_pSettings->sControlLabel);
+ m_aContext.xObjectModel->setPropertyValue(
+ ::rtl::OUString::createFromAscii("Label"),
+ makeAny(sControlLabel)
+ );
+ }
+ }
+ catch(Exception&)
+ {
+ DBG_ERROR("OControlWizard::commitControlSettings: could not commit the basic control settings!");
+ }
+ }
+
+ //---------------------------------------------------------------------
+ void OControlWizard::initControlSettings(OControlWizardSettings* _pSettings)
+ {
+ DBG_ASSERT(m_aContext.xObjectModel.is(), "OControlWizard::initControlSettings: have no control model to work with!");
+ if (!m_aContext.xObjectModel.is())
+ return;
+
+ // initialize some settings from the control model give
+ try
+ {
+ ::rtl::OUString sLabelPropertyName = ::rtl::OUString::createFromAscii("Label");
+ Reference< XPropertySetInfo > xInfo = m_aContext.xObjectModel->getPropertySetInfo();
+ if (xInfo.is() && xInfo->hasPropertyByName(sLabelPropertyName))
+ {
+ ::rtl::OUString sControlLabel;
+ m_aContext.xObjectModel->getPropertyValue(sLabelPropertyName) >>= sControlLabel;
+ _pSettings->sControlLabel = sControlLabel;
+ }
+ }
+ catch(Exception&)
+ {
+ DBG_ERROR("OControlWizard::initControlSettings: could not retrieve the basic control settings!");
+ }
+ }
+
+ //---------------------------------------------------------------------
+ sal_Bool OControlWizard::needDatasourceSelection()
+ {
+ // lemme see ...
+ return (0 == getContext().aFieldNames.getLength());
+ // if we got fields, the data source is valid ...
+// try
+// {
+// // first, we need a valid data source name
+// ::rtl::OUString sDataSourceName;
+// m_aContext.xForm->getPropertyValue(::rtl::OUString::createFromAscii("DataSourceName")) >>= sDataSourceName;
+// if (m_aContext.xDatasourceContext.is() && m_aContext.xDatasourceContext->hasByName(sDataSourceName))
+// { // at least the data source name is valid ...
+// // then, a CommandType "table" would be nice ...
+// sal_Int32 nCommandType = CommandType::COMMAND;
+// m_aContext.xForm->getPropertyValue(::rtl::OUString::createFromAscii("CommandType")) >>= nCommandType;
+// if (CommandType::TABLE == nCommandType)
+// { // okay ....
+// // now the table itself should be valid
+// ::rtl::OUString sTableName;
+// m_aContext.xForm->getPropertyValue(::rtl::OUString::createFromAscii("Command")) >>= sTableName;
+// if (m_aContext.xObjectContainer.is() && m_aContext.xObjectContainer->hasByName(sTableName))
+// return sal_False;
+// }
+// }
+// }
+// catch(Exception&)
+// {
+// DBG_ERROR("OControlWizard::needDatasourceSelection: caught an exception while checking the form settings!");
+// }
+// return sal_True;
+ }
+
+//.........................................................................
+} // namespace dbp
+//.........................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/dbpilots/controlwizard.hxx b/extensions/source/dbpilots/controlwizard.hxx
new file mode 100644
index 000000000000..0c5eb649d9dc
--- /dev/null
+++ b/extensions/source/dbpilots/controlwizard.hxx
@@ -0,0 +1,185 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _EXTENSIONS_DBP_CONTROLWIZARD_HXX
+#define _EXTENSIONS_DBP_CONTROLWIZARD_HXX
+
+#include <svtools/wizardmachine.hxx>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/form/FormComponentType.hpp>
+#include <com/sun/star/sdbc/XConnection.hpp>
+#include <com/sun/star/task/XInteractionHandler.hpp>
+#include <vcl/fixed.hxx>
+#include <vcl/edit.hxx>
+#include <vcl/button.hxx>
+#include <vcl/lstbox.hxx>
+#include <vcl/combobox.hxx>
+#include "dbptypes.hxx"
+#include "dbpresid.hrc"
+#include "componentmodule.hxx"
+#include "wizardcontext.hxx"
+
+class ResId;
+//.........................................................................
+namespace dbp
+{
+//.........................................................................
+
+ //=====================================================================
+ //= OControlWizardSettings
+ //=====================================================================
+ struct OControlWizardSettings
+ {
+ String sControlLabel;
+ };
+
+ //=====================================================================
+ //= OControlWizardPage
+ //=====================================================================
+ class OControlWizard;
+ typedef ::svt::OWizardPage OControlWizardPage_Base;
+ class OControlWizardPage : public OControlWizardPage_Base
+ {
+ protected:
+ FixedLine* m_pFormSettingsSeparator;
+ FixedText* m_pFormDatasourceLabel;
+ FixedText* m_pFormDatasource;
+ FixedText* m_pFormContentTypeLabel;
+ FixedText* m_pFormContentType;
+ FixedText* m_pFormTableLabel;
+ FixedText* m_pFormTable;
+
+ protected:
+ OControlWizard* getDialog();
+ const OControlWizard* getDialog() const;
+ const OControlWizardContext& getContext();
+ sal_Bool updateContext();
+ void setFormConnection(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConn, sal_Bool _bAutoDispose = sal_True );
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >
+ getFormConnection() const;
+
+ public:
+ OControlWizardPage( OControlWizard* _pParent, const ResId& _rResId );
+ ~OControlWizardPage();
+
+ protected:
+ void fillListBox(
+ ListBox& _rList,
+ const ::com::sun::star::uno::Sequence< ::rtl::OUString >& _rItems,
+ sal_Bool _bClear = sal_True);
+ void fillListBox(
+ ComboBox& _rList,
+ const ::com::sun::star::uno::Sequence< ::rtl::OUString >& _rItems,
+ sal_Bool _bClear = sal_True);
+
+ protected:
+ void enableFormDatasourceDisplay();
+ void adjustControlForNoDSDisplay(Control* _pControl, sal_Bool bConstLowerDistance = sal_False);
+
+ protected:
+ // OWizardPage overridables
+ virtual void initializePage();
+ };
+
+ struct OAccessRegulator;
+ //=====================================================================
+ //= OControlWizard
+ //=====================================================================
+ typedef ::svt::OWizardMachine OControlWizard_Base;
+ class OControlWizard : public OControlWizard_Base
+ {
+ private:
+ OControlWizardContext m_aContext;
+
+ protected:
+ ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >
+ m_xORB;
+
+ public:
+ OControlWizard(
+ Window* _pParent,
+ const ResId& _rId,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxObjectModel,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB
+ );
+ ~OControlWizard();
+
+ // make the some base class methods public
+ sal_Bool travelNext() { return OControlWizard_Base::travelNext(); }
+
+ public:
+ ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >
+ getServiceFactory() const { return m_xORB; }
+
+ const OControlWizardContext& getContext() const { return m_aContext; }
+ sal_Bool updateContext(const OAccessRegulator&);
+ void setFormConnection(const OAccessRegulator&, const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConn, sal_Bool _bAutoDispose = sal_True );
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >
+ getFormConnection(const OAccessRegulator&) const;
+
+ /** returns the com.sun.star.task.InteractionHandler
+ @param _pWindow The window will be used when an error message has to be shown.
+ */
+ ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler > getInteractionHandler(Window* _pWindow) const;
+
+ protected:
+ // initialize the derivees settings (which have to be derived from OControlWizardSettings)
+ // with some common data extracted from the control model
+ void initControlSettings(OControlWizardSettings* _pSettings);
+ // commit the control-relevant settings
+ void commitControlSettings(OControlWizardSettings* _pSettings);
+
+ sal_Bool needDatasourceSelection();
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >
+ getFormConnection() const;
+
+ virtual sal_Bool approveControl(sal_Int16 _nClassId) = 0;
+
+ // ModalDialog overridables
+ virtual short Execute();
+
+ private:
+ sal_Bool initContext();
+
+ void implGetDSContext();
+ void implDetermineForm();
+ void implDeterminePage();
+ void implDetermineShape();
+
+ // made private. Not to be used by derived (or external) classes
+ virtual void ActivatePage();
+ };
+
+//.........................................................................
+} // namespace dbp
+//.........................................................................
+
+#endif // _EXTENSIONS_DBP_CONTROLWIZARD_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/dbpilots/dbpilots.src b/extensions/source/dbpilots/dbpilots.src
new file mode 100644
index 000000000000..fcdda32e0747
--- /dev/null
+++ b/extensions/source/dbpilots/dbpilots.src
@@ -0,0 +1,78 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _EXTENSIONS_DBP_DBPRESID_HRC_
+#include "dbpresid.hrc"
+#endif
+
+ModalDialog RID_DLG_GROUPBOXWIZARD
+{
+ Text [ en-US ] = "Group Element Wizard";
+
+ OutputSize = TRUE ;
+ SVLook = TRUE ;
+ Moveable = TRUE ;
+ Closeable = TRUE ;
+ Hide = TRUE;
+};
+
+ModalDialog RID_DLG_LISTCOMBOWIZARD
+{
+ OutputSize = TRUE ;
+ SVLook = TRUE ;
+ Moveable = TRUE ;
+ Closeable = TRUE ;
+ Hide = TRUE;
+};
+
+ModalDialog RID_DLG_GRIDWIZARD
+{
+ OutputSize = TRUE ;
+ SVLook = TRUE ;
+ Moveable = TRUE ;
+ Closeable = TRUE ;
+ Hide = TRUE;
+
+ Text [ en-US ] = "Table Element Wizard";
+};
+
+String RID_STR_LISTWIZARD_TITLE
+{
+ Text [ en-US ] = "List Box Wizard";
+};
+
+String RID_STR_COMBOWIZARD_TITLE
+{
+ Text [ en-US ] = "Combo Box Wizard";
+};
+
+String RID_STR_COULDNOTOPENTABLE
+{
+ Text [ en-US ] = "The table connection to the data source could not be established.";
+};
+
+
diff --git a/extensions/source/dbpilots/dbpresid.hrc b/extensions/source/dbpilots/dbpresid.hrc
new file mode 100644
index 000000000000..81f61d49c96b
--- /dev/null
+++ b/extensions/source/dbpilots/dbpresid.hrc
@@ -0,0 +1,233 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _EXTENSIONS_DBP_DBPRESID_HRC_
+#define _EXTENSIONS_DBP_DBPRESID_HRC_
+
+#include "dbpilots.hrc"
+
+//========================================================================
+// basics
+
+#define RID_DIALOG_START RID_DBP_START
+#define RID_PAGE_START RID_DBP_START
+#define RID_STRING_START RID_DBP_START
+#define RID_ERRORBOX_START RID_DBP_START
+
+//========================================================================
+// strings
+
+#define RID_STR_GROUPWIZ_DBFIELD (RID_STRING_START + 1 )
+#define RID_STR_COMBOWIZ_DBFIELD (RID_STRING_START + 2 )
+#define RID_STR_LISTWIZARD_TITLE (RID_STRING_START + 3 )
+#define RID_STR_COMBOWIZARD_TITLE (RID_STRING_START + 4 )
+#define RID_STR_COULDNOTOPENTABLE (RID_STRING_START + 5 )
+#define RID_STR_DATEPOSTFIX (RID_STRING_START + 6 )
+#define RID_STR_TIMEPOSTFIX (RID_STRING_START + 7 )
+#define RID_STR_TYPE_QUERY (RID_STRING_START + 8 )
+#define RID_STR_TYPE_TABLE (RID_STRING_START + 9 )
+#define RID_STR_TYPE_COMMAND (RID_STRING_START + 10 )
+
+// please adjust RID_STRING_END (below) when adding new strings
+#define RID_STRING_END RID_STR_TIMEPOSTFIX
+
+//========================================================================
+// dialogs
+
+#define RID_DLG_GROUPBOXWIZARD ( RID_DIALOG_START + 1 )
+#define RID_DLG_LISTCOMBOWIZARD ( RID_DIALOG_START + 2 )
+#define RID_DLG_GRIDWIZARD ( RID_DIALOG_START + 3 )
+
+// please adjust RID_DIALOG_END (below) when adding new dialogs
+#define RID_DIALOG_END RID_DLG_GRIDWIZARD
+
+//========================================================================
+// tab pages
+
+#define RID_PAGE_TABLESELECTION ( RID_PAGE_START + 1 )
+#define RID_PAGE_GROUPRADIOSELECTION ( RID_PAGE_START + 2 )
+#define RID_PAGE_DEFAULTFIELDSELECTION ( RID_PAGE_START + 3 )
+#define RID_PAGE_OPTIONVALUES ( RID_PAGE_START + 4 )
+#define RID_PAGE_OPTION_DBFIELD ( RID_PAGE_START + 5 )
+#define RID_PAGE_OPTIONS_FINAL ( RID_PAGE_START + 6 )
+#define RID_PAGE_LCW_CONTENTSELECTION_TABLE ( RID_PAGE_START + 7 )
+#define RID_PAGE_LCW_CONTENTSELECTION_FIELD ( RID_PAGE_START + 8 )
+#define RID_PAGE_LCW_FIELDLINK ( RID_PAGE_START + 9 )
+#define RID_PAGE_GW_FIELDSELECTION ( RID_PAGE_START + 10 )
+#define RID_PAGE_FORM_DATASOURCE_STATUS ( RID_PAGE_START + 11 )
+
+// please adjust RID_PAGE_END (below) when adding new tab pages
+#define RID_PAGE_END RID_PAGE_GW_FIELDSELECTION
+
+//========================================================================
+// ErrorBox
+
+#define RID_ERR_INVALID_FORM_CONNECTION ( RID_ERRORBOX_START + 1 )
+
+// please adjust RID_ERRORBOX_END (below) when adding new error boxes
+#define RID_ERRORBOX_END RID_ERR_INVALID_FORM_CONNECTION
+
+
+//========================================================================
+//========================================================================
+//= range checks
+
+#if RID_STRING_END > RID_DBP_END
+ #error "please adjust the resource id ranges!!"
+#endif
+#if RID_DIALOG_END > RID_DBP_END
+ #error "please adjust the resource id ranges!!"
+#endif
+#if RID_PAGE_END > RID_DBP_END
+ #error "please adjust the resource id ranges!!"
+#endif
+#if RID_ERRORBOX_END > RID_DBP_END
+ #error "please adjust the resource id ranges!!"
+#endif
+
+//========================================================================
+// local ids
+
+//........................................................................
+// FixedLine
+
+#define FL_DATA 1
+#define FL_DEFAULTSELECTION 2
+#define FL_OPTIONVALUES 3
+#define FL_DATABASEFIELD_EXPL 4
+#define FL_NAMEIT 5
+#define FL_FRAME 6
+#define FL_FORMSETINGS 7
+
+//........................................................................
+// FixedText
+
+#define FT_DATASOURCE 1
+#define FT_TABLE 2
+#define FT_RADIOLABELS 3
+#define FT_RADIOBUTTONS 4
+#define FT_DEFAULTSELECTION 5
+#define FT_OPTIONVALUES_EXPL 6
+#define FT_OPTIONVALUES 7
+#define FT_DATABASEFIELD_EXPL 8
+#define FT_DATABASEFIELD_QUEST 9
+#define FT_NAMEIT 10
+#define FT_THATSALL 11
+#define FT_SELECTTABLE_LABEL 12
+#define FT_TABLEFIELDS 13
+#define FT_DISPLAYEDFIELD 14
+#define FT_CONTENTFIELD_INFO 15
+#define FT_VALUELISTFIELD 16
+#define FT_TABLEFIELD 17
+#define FT_EXPLANATION 18
+#define FT_EXISTING_FIELDS 19
+#define FT_SELECTED_FIELDS 20
+#define FT_FIELDLINK_DESC 21
+#define FT_FORMDATASOURCELABEL 22
+#define FT_FORMDATASOURCE 23
+#define FT_FORMTABLELABEL 24
+#define FT_FORMTABLE 25
+#define FT_FORMCONTENTTYPELABEL 26
+#define FT_FORMCONTENTTYPE 27
+
+//........................................................................
+// ListBox
+
+#define LB_DATASOURCE 1
+#define LB_TABLE 2
+#define LB_RADIOBUTTONS 3
+#define LB_DEFSELECTIONFIELD 3
+#define LB_STOREINFIELD 4
+#define LB_SELECTTABLE 5
+#define LB_SELECTFIELD 6
+#define LB_EXISTING_FIELDS 7
+#define LB_SELECTED_FIELDS 8
+
+//........................................................................
+// Edit
+
+#define ET_RADIOLABELS 1
+#define ET_OPTIONVALUE 2
+#define ET_NAMEIT 3
+#define ET_DISPLAYEDFIELD 4
+
+//........................................................................
+// PushButton
+
+#define PB_MOVETORIGHT 1
+#define PB_MOVETOLEFT 2
+#define PB_FIELDRIGHT 3
+#define PB_ALLFIELDSRIGHT 4
+#define PB_FIELDLEFT 5
+#define PB_ALLFIELDSLEFT 6
+#define PB_FORMDATASOURCE 7
+
+//........................................................................
+// RadioButton
+
+#define RB_DEFSELECTION_YES 1
+#define RB_DEFSELECTION_NO 2
+#define RB_STOREINFIELD_YES 3
+#define RB_STOREINFIELD_NO 4
+
+//........................................................................
+// ComboBox
+
+#define CMB_VALUELISTFIELD 1
+#define CMB_TABLEFIELD 2
+
+//........................................................................
+// String
+
+#define STR_FIELDINFO_LISTBOX 1
+#define STR_FIELDINFO_COMBOBOX 2
+
+//........................................................................
+// Image
+
+#define IMG_TABLE 1
+#define IMG_TABLE_HC 2
+#define IMG_QUERY 3
+#define IMG_QUERY_HC 4
+
+//========================================================================
+// defines
+
+#define WINDOW_SIZE_X 260
+#define WINDOW_SIZE_Y 185
+#define WINDOW_HALF_SIZE_X ( WINDOW_SIZE_X / 2 )
+
+#define BUTTON_SIZE_X 50
+#define BUTTON_SIZE_Y 14
+
+#define ITEM_BUTTON_SIZE_X 20
+#define ITEM_BUTTON_SIZE_Y 12
+
+
+
+#endif // _EXTENSIONS_DBP_DBPRESID_HRC_
+
diff --git a/extensions/source/dbpilots/dbpservices.cxx b/extensions/source/dbpilots/dbpservices.cxx
new file mode 100644
index 000000000000..e1e41725af25
--- /dev/null
+++ b/extensions/source/dbpilots/dbpservices.cxx
@@ -0,0 +1,114 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+#include "componentmodule.hxx"
+
+//---------------------------------------------------------------------------------------
+
+using namespace ::rtl;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::registry;
+
+//---------------------------------------------------------------------------------------
+
+extern "C" void SAL_CALL createRegistryInfo_OGroupBoxWizard();
+extern "C" void SAL_CALL createRegistryInfo_OListComboWizard();
+extern "C" void SAL_CALL createRegistryInfo_OGridWizard();
+
+//---------------------------------------------------------------------------------------
+
+extern "C" void SAL_CALL dbp_initializeModule()
+{
+ static sal_Bool s_bInit = sal_False;
+ if (!s_bInit)
+ {
+ createRegistryInfo_OGroupBoxWizard();
+ createRegistryInfo_OListComboWizard();
+ createRegistryInfo_OGridWizard();
+ ::dbp::OModule::setResourceFilePrefix("dbp");
+ s_bInit = sal_True;
+ }
+}
+
+//---------------------------------------------------------------------------------------
+
+extern "C" SAL_DLLPUBLIC_EXPORT void SAL_CALL
+component_getImplementationEnvironment(
+ const sal_Char **ppEnvTypeName,
+ uno_Environment ** /*ppEnv*/
+ )
+{
+ dbp_initializeModule();
+ *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
+}
+
+//---------------------------------------------------------------------------------------
+extern "C" SAL_DLLPUBLIC_EXPORT sal_Bool SAL_CALL component_writeInfo(
+ void* pServiceManager,
+ void* pRegistryKey
+ )
+{
+ if (pRegistryKey)
+ try
+ {
+ return ::dbp::OModule::writeComponentInfos(
+ static_cast<XMultiServiceFactory*>(pServiceManager),
+ static_cast<XRegistryKey*>(pRegistryKey));
+ }
+ catch (InvalidRegistryException& )
+ {
+ OSL_ASSERT("dbp::component_writeInfo: could not create a registry key (InvalidRegistryException) !");
+ }
+
+ return sal_False;
+}
+
+//---------------------------------------------------------------------------------------
+extern "C" SAL_DLLPUBLIC_EXPORT void* SAL_CALL component_getFactory(
+ const sal_Char* pImplementationName,
+ void* pServiceManager,
+ void* /*pRegistryKey*/)
+{
+ Reference< XInterface > xRet;
+ if (pServiceManager && pImplementationName)
+ {
+ xRet = ::dbp::OModule::getComponentFactory(
+ ::rtl::OUString::createFromAscii(pImplementationName),
+ static_cast< XMultiServiceFactory* >(pServiceManager));
+ }
+
+ if (xRet.is())
+ xRet->acquire();
+ return xRet.get();
+};
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/dbpilots/dbptools.cxx b/extensions/source/dbpilots/dbptools.cxx
new file mode 100644
index 000000000000..05d85f5c8790
--- /dev/null
+++ b/extensions/source/dbpilots/dbptools.cxx
@@ -0,0 +1,72 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+#include "dbptools.hxx"
+#include <tools/debug.hxx>
+
+//.........................................................................
+namespace dbp
+{
+//.........................................................................
+
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::container;
+
+ //---------------------------------------------------------------------
+ void disambiguateName(const Reference< XNameAccess >& _rxContainer, ::rtl::OUString& _rElementsName)
+ {
+ DBG_ASSERT(_rxContainer.is(), "::dbp::disambiguateName: invalid container!");
+ if (!_rxContainer.is())
+ return;
+
+ try
+ {
+ ::rtl::OUString sBase(_rElementsName);
+ for (sal_Int32 i=1; i<0x7FFFFFFF; ++i)
+ {
+ _rElementsName = sBase;
+ _rElementsName += ::rtl::OUString::valueOf((sal_Int32)i);
+ if (!_rxContainer->hasByName(_rElementsName))
+ return;
+ }
+ // can't do anything ... no free names
+ _rElementsName = sBase;
+ }
+ catch(Exception&)
+ {
+ DBG_ERROR("::dbp::disambiguateName: something went (strangely) wrong!");
+ }
+ }
+
+//.........................................................................
+} // namespace dbp
+//.........................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/dbpilots/dbptools.hxx b/extensions/source/dbpilots/dbptools.hxx
new file mode 100644
index 000000000000..7c37e7edd305
--- /dev/null
+++ b/extensions/source/dbpilots/dbptools.hxx
@@ -0,0 +1,50 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _EXTENSIONS_DBP_DBPTOOLS_HXX_
+#define _EXTENSIONS_DBP_DBPTOOLS_HXX_
+
+#include <com/sun/star/container/XNameAccess.hpp>
+
+//.........................................................................
+namespace dbp
+{
+//.........................................................................
+
+ void disambiguateName(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& _rxContainer,
+ ::rtl::OUString& _rElementsName);
+
+//.........................................................................
+} // namespace dbp
+//.........................................................................
+
+
+#endif // _EXTENSIONS_DBP_DBPTOOLS_HXX_
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/dbpilots/dbptypes.hxx b/extensions/source/dbpilots/dbptypes.hxx
new file mode 100644
index 000000000000..be188f63fdf0
--- /dev/null
+++ b/extensions/source/dbpilots/dbptypes.hxx
@@ -0,0 +1,49 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _EXTENSIONS_DBP_DBPTYPES_HXX_
+#define _EXTENSIONS_DBP_DBPTYPES_HXX_
+
+#include <comphelper/stl_types.hxx>
+#include <tools/string.hxx>
+
+//.........................................................................
+namespace dbp
+{
+//.........................................................................
+
+ DECLARE_STL_VECTOR( String, StringArray );
+ DECLARE_STL_STDKEY_SET( String, StringBag );
+ DECLARE_STL_STDKEY_MAP( sal_uInt32, String, MapInt2String );
+
+//.........................................................................
+} // namespace dbp
+//.........................................................................
+#endif // _EXTENSIONS_DBP_DBPTYPES_HXX_
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/dbpilots/gridpages.src b/extensions/source/dbpilots/gridpages.src
new file mode 100644
index 000000000000..5b5d557ca18a
--- /dev/null
+++ b/extensions/source/dbpilots/gridpages.src
@@ -0,0 +1,114 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _EXTENSIONS_DBP_DBPRESID_HRC_
+#include "dbpresid.hrc"
+#endif
+
+TabPage RID_PAGE_GW_FIELDSELECTION
+{
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( WINDOW_SIZE_X , WINDOW_SIZE_Y ) ;
+
+ Text [ en-US ] = "Field Selection";
+
+ FixedLine FL_FRAME
+ {
+ Pos = MAP_APPFONT ( 4 , 40 ) ;
+ Size = MAP_APPFONT ( WINDOW_SIZE_X - 8 , 8 ) ;
+ Text [ en-US ] = "Table element";
+ };
+
+ FixedText FT_EXISTING_FIELDS
+ {
+ Pos = MAP_APPFONT ( 7, 52 );
+ Size = MAP_APPFONT ( WINDOW_HALF_SIZE_X - ITEM_BUTTON_SIZE_X / 2 - 13, 8 );
+ Text [ en-US ] = "Existing fields";
+ };
+ ListBox LB_EXISTING_FIELDS
+ {
+ Pos = MAP_APPFONT ( 7 , 63 ) ;
+ Size = MAP_APPFONT ( WINDOW_HALF_SIZE_X - ITEM_BUTTON_SIZE_X / 2 - 13, WINDOW_SIZE_Y - 63 - 6 ) ;
+ SVLook = TRUE ;
+ Border = TRUE ;
+ AutoHScroll = TRUE ;
+ Sort = FALSE;
+ DropDown = FALSE;
+ };
+ PushButton PB_FIELDRIGHT
+ {
+ Pos = MAP_APPFONT ( WINDOW_HALF_SIZE_X - ITEM_BUTTON_SIZE_X / 2, 63 );
+ Size = MAP_APPFONT ( ITEM_BUTTON_SIZE_X, ITEM_BUTTON_SIZE_Y );
+ Text = "->";
+ };
+ PushButton PB_ALLFIELDSRIGHT
+ {
+ Pos = MAP_APPFONT ( WINDOW_HALF_SIZE_X - ITEM_BUTTON_SIZE_X / 2, 63 + ITEM_BUTTON_SIZE_Y + 3 );
+ Size = MAP_APPFONT ( ITEM_BUTTON_SIZE_X, ITEM_BUTTON_SIZE_Y );
+ Text = "=>>";
+ };
+ PushButton PB_FIELDLEFT
+ {
+ Pos = MAP_APPFONT ( WINDOW_HALF_SIZE_X - ITEM_BUTTON_SIZE_X / 2, 63 + ITEM_BUTTON_SIZE_Y + 3 + ITEM_BUTTON_SIZE_Y + 12 );
+ Size = MAP_APPFONT ( ITEM_BUTTON_SIZE_X, ITEM_BUTTON_SIZE_Y );
+ Text = "<-";
+ };
+ PushButton PB_ALLFIELDSLEFT
+ {
+ Pos = MAP_APPFONT ( WINDOW_HALF_SIZE_X - ITEM_BUTTON_SIZE_X / 2, 63 + ITEM_BUTTON_SIZE_Y + 3 + ITEM_BUTTON_SIZE_Y + 12 + ITEM_BUTTON_SIZE_Y + 3 );
+ Size = MAP_APPFONT ( ITEM_BUTTON_SIZE_X, ITEM_BUTTON_SIZE_Y );
+ Text = "<<=";
+ };
+ FixedText FT_SELECTED_FIELDS
+ {
+ Pos = MAP_APPFONT ( WINDOW_HALF_SIZE_X + ITEM_BUTTON_SIZE_X / 2 + 6, 52 );
+ Size = MAP_APPFONT ( WINDOW_HALF_SIZE_X - ITEM_BUTTON_SIZE_X / 2 - 13, 8 );
+ Text [ en-US ] = "Selected fields";
+ };
+ ListBox LB_SELECTED_FIELDS
+ {
+ Pos = MAP_APPFONT ( WINDOW_HALF_SIZE_X + ITEM_BUTTON_SIZE_X / 2 + 6 , 63 ) ;
+ Size = MAP_APPFONT ( WINDOW_HALF_SIZE_X - ITEM_BUTTON_SIZE_X / 2 - 13, WINDOW_SIZE_Y - 63 - 6 ) ;
+ SVLook = TRUE ;
+ Border = TRUE ;
+ AutoHScroll = TRUE ;
+ Sort = FALSE;
+ DropDown = FALSE;
+ };
+};
+
+String RID_STR_DATEPOSTFIX
+{
+ Text [ en-US ] = " (Date)";
+};
+
+String RID_STR_TIMEPOSTFIX
+{
+ Text [ en-US ] = " (Time)";
+};
+
+
diff --git a/extensions/source/dbpilots/gridwizard.cxx b/extensions/source/dbpilots/gridwizard.cxx
new file mode 100644
index 000000000000..6c39ac373524
--- /dev/null
+++ b/extensions/source/dbpilots/gridwizard.cxx
@@ -0,0 +1,487 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+#include "gridwizard.hxx"
+#include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
+#include <com/sun/star/sdbc/DataType.hpp>
+#include <comphelper/stl_types.hxx>
+#include <tools/string.hxx>
+#include <com/sun/star/form/XGridColumnFactory.hpp>
+#include <com/sun/star/awt/MouseWheelBehavior.hpp>
+#include <com/sun/star/container/XNameContainer.hpp>
+#include <tools/debug.hxx>
+#include "dbptools.hxx"
+#include "dbpilots.hrc"
+
+#define GW_STATE_DATASOURCE_SELECTION 0
+#define GW_STATE_FIELDSELECTION 1
+
+//.........................................................................
+namespace dbp
+{
+//.........................................................................
+
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::lang;
+ using namespace ::com::sun::star::beans;
+ using namespace ::com::sun::star::sdbc;
+ using namespace ::com::sun::star::container;
+ using namespace ::com::sun::star::form;
+ using namespace ::com::sun::star::awt;
+ using namespace ::svt;
+
+ //=====================================================================
+ //= OGridWizard
+ //=====================================================================
+ //---------------------------------------------------------------------
+ OGridWizard::OGridWizard( Window* _pParent,
+ const Reference< XPropertySet >& _rxObjectModel, const Reference< XMultiServiceFactory >& _rxORB )
+ :OControlWizard(_pParent, ModuleRes(RID_DLG_GRIDWIZARD), _rxObjectModel, _rxORB)
+ ,m_bHadDataSelection(sal_True)
+ {
+ initControlSettings(&m_aSettings);
+
+ m_pPrevPage->SetHelpId(HID_GRIDWIZARD_PREVIOUS);
+ m_pNextPage->SetHelpId(HID_GRIDWIZARD_NEXT);
+ m_pCancel->SetHelpId(HID_GRIDWIZARD_CANCEL);
+ m_pFinish->SetHelpId(HID_GRIDWIZARD_FINISH);
+
+ // if we do not need the data source selection page ...
+ if (!needDatasourceSelection())
+ { // ... skip it!
+ skip(1);
+ m_bHadDataSelection = sal_False;
+ }
+ }
+
+ //---------------------------------------------------------------------
+ sal_Bool OGridWizard::approveControl(sal_Int16 _nClassId)
+ {
+ if (FormComponentType::GRIDCONTROL != _nClassId)
+ return sal_False;
+
+ Reference< XGridColumnFactory > xColumnFactory(getContext().xObjectModel, UNO_QUERY);
+ if (!xColumnFactory.is())
+ return sal_False;
+
+ return sal_True;
+ }
+
+ //---------------------------------------------------------------------
+ void OGridWizard::implApplySettings()
+ {
+ const OControlWizardContext& rContext = getContext();
+
+ // the factory for the columns
+ Reference< XGridColumnFactory > xColumnFactory(rContext.xObjectModel, UNO_QUERY);
+ DBG_ASSERT(xColumnFactory.is(), "OGridWizard::implApplySettings: should never have made it 'til here!");
+ // (if we're here, what the hell happened in approveControl??)
+
+ // the container for the columns
+ Reference< XNameContainer > xColumnContainer(rContext.xObjectModel, UNO_QUERY);
+ DBG_ASSERT(xColumnContainer.is(), "OGridWizard::implApplySettings: no container!");
+
+ if (!xColumnFactory.is() || !xColumnContainer.is())
+ return;
+
+ static const ::rtl::OUString s_sDataFieldProperty = ::rtl::OUString::createFromAscii("DataField");
+ static const ::rtl::OUString s_sLabelProperty = ::rtl::OUString::createFromAscii("Label");
+ static const ::rtl::OUString s_sWidthProperty = ::rtl::OUString::createFromAscii("Width");
+ static const ::rtl::OUString s_sMouseWheelBehavior = ::rtl::OUString::createFromAscii("MouseWheelBehavior");
+ static const ::rtl::OUString s_sEmptyString;
+
+ // collect "descriptors" for the to-be-created (grid)columns
+ DECLARE_STL_VECTOR( ::rtl::OUString, StringArray );
+ StringArray aColumnServiceNames; // service names to be used with the XGridColumnFactory
+ StringArray aColumnLabelPostfixes; // postfixes to append to the column labels
+ StringArray aFormFieldNames; // data field names
+
+ aColumnServiceNames.reserve(getSettings().aSelectedFields.getLength());
+ aColumnLabelPostfixes.reserve(getSettings().aSelectedFields.getLength());
+ aFormFieldNames.reserve(getSettings().aSelectedFields.getLength());
+
+ // loop through the selected field names
+ const ::rtl::OUString* pSelectedFields = getSettings().aSelectedFields.getConstArray();
+ const ::rtl::OUString* pEnd = pSelectedFields + getSettings().aSelectedFields.getLength();
+ for (;pSelectedFields < pEnd; ++pSelectedFields)
+ {
+ // get the information for the selected column
+ sal_Int32 nFieldType = DataType::OTHER;
+ OControlWizardContext::TNameTypeMap::const_iterator aFind = rContext.aTypes.find(*pSelectedFields);
+ if ( aFind != rContext.aTypes.end() )
+ nFieldType = aFind->second;
+
+ aFormFieldNames.push_back(*pSelectedFields);
+ switch (nFieldType)
+ {
+ case DataType::BIT:
+ case DataType::BOOLEAN:
+ aColumnServiceNames.push_back(::rtl::OUString::createFromAscii("CheckBox"));
+ aColumnLabelPostfixes.push_back(s_sEmptyString);
+ break;
+
+ case DataType::TINYINT:
+ case DataType::SMALLINT:
+ case DataType::INTEGER:
+ aColumnServiceNames.push_back(::rtl::OUString::createFromAscii("NumericField"));
+ aColumnLabelPostfixes.push_back(s_sEmptyString);
+ break;
+
+ case DataType::FLOAT:
+ case DataType::REAL:
+ case DataType::DOUBLE:
+ case DataType::NUMERIC:
+ case DataType::DECIMAL:
+ aColumnServiceNames.push_back(::rtl::OUString::createFromAscii("FormattedField"));
+ aColumnLabelPostfixes.push_back(s_sEmptyString);
+ break;
+
+ case DataType::DATE:
+ aColumnServiceNames.push_back(::rtl::OUString::createFromAscii("DateField"));
+ aColumnLabelPostfixes.push_back(s_sEmptyString);
+ break;
+
+ case DataType::TIME:
+ aColumnServiceNames.push_back(::rtl::OUString::createFromAscii("TimeField"));
+ aColumnLabelPostfixes.push_back(s_sEmptyString);
+ break;
+
+ case DataType::TIMESTAMP:
+ aColumnServiceNames.push_back(::rtl::OUString::createFromAscii("DateField"));
+ aColumnLabelPostfixes.push_back(String(ModuleRes(RID_STR_DATEPOSTFIX)));
+
+ aFormFieldNames.push_back(*pSelectedFields);
+ aColumnServiceNames.push_back(::rtl::OUString::createFromAscii("TimeField"));
+ aColumnLabelPostfixes.push_back(String(ModuleRes(RID_STR_TIMEPOSTFIX)));
+ break;
+
+ default:
+ aColumnServiceNames.push_back(::rtl::OUString::createFromAscii("TextField"));
+ aColumnLabelPostfixes.push_back(s_sEmptyString);
+ }
+ }
+
+ DBG_ASSERT( aFormFieldNames.size() == aColumnServiceNames.size()
+ && aColumnServiceNames.size() == aColumnLabelPostfixes.size(),
+ "OGridWizard::implApplySettings: inconsistent descriptor sequences!");
+
+ // now loop through the descriptions and create the (grid)columns out of th descriptors
+ {
+ Reference< XNameAccess > xExistenceChecker(xColumnContainer.get());
+
+ ConstStringArrayIterator pColumnServiceName = aColumnServiceNames.begin();
+ ConstStringArrayIterator pColumnLabelPostfix = aColumnLabelPostfixes.begin();
+ ConstStringArrayIterator pFormFieldName = aFormFieldNames.begin();
+ ConstStringArrayIterator pColumnServiceNameEnd = aColumnServiceNames.end();
+
+ for (;pColumnServiceName < pColumnServiceNameEnd; ++pColumnServiceName, ++pColumnLabelPostfix, ++pFormFieldName)
+ {
+ // create a (grid)column for the (resultset)column
+ try
+ {
+ Reference< XPropertySet > xColumn( xColumnFactory->createColumn(*pColumnServiceName), UNO_SET_THROW );
+ Reference< XPropertySetInfo > xColumnPSI( xColumn->getPropertySetInfo(), UNO_SET_THROW );
+
+ ::rtl::OUString sColumnName(*pColumnServiceName);
+ disambiguateName(xExistenceChecker, sColumnName);
+
+ // the data field the column should be bound to
+ xColumn->setPropertyValue(s_sDataFieldProperty, makeAny(*pFormFieldName));
+ // the label
+ xColumn->setPropertyValue(s_sLabelProperty, makeAny(::rtl::OUString(*pFormFieldName) += *pColumnLabelPostfix));
+ // the width (<void/> => column will be auto-sized)
+ xColumn->setPropertyValue(s_sWidthProperty, Any());
+
+ if ( xColumnPSI->hasPropertyByName( s_sMouseWheelBehavior ) )
+ xColumn->setPropertyValue( s_sMouseWheelBehavior, makeAny( MouseWheelBehavior::SCROLL_DISABLED ) );
+
+ // insert the column
+ xColumnContainer->insertByName(sColumnName, makeAny(xColumn));
+ }
+ catch(Exception&)
+ {
+ DBG_ERROR( ::rtl::OString("OGridWizard::implApplySettings: unexpected exception while creating the grid column for field ")
+ += ::rtl::OString(pFormFieldName->getStr(), pFormFieldName->getLength(), gsl_getSystemTextEncoding())
+ += ::rtl::OString("!"));
+ }
+ }
+ }
+ }
+
+ //---------------------------------------------------------------------
+ OWizardPage* OGridWizard::createPage(WizardState _nState)
+ {
+ switch (_nState)
+ {
+ case GW_STATE_DATASOURCE_SELECTION:
+ return new OTableSelectionPage(this);
+ case GW_STATE_FIELDSELECTION:
+ return new OGridFieldsSelection(this);
+ }
+
+ return NULL;
+ }
+
+ //---------------------------------------------------------------------
+ WizardTypes::WizardState OGridWizard::determineNextState( WizardState _nCurrentState ) const
+ {
+ switch (_nCurrentState)
+ {
+ case GW_STATE_DATASOURCE_SELECTION:
+ return GW_STATE_FIELDSELECTION;
+ case GW_STATE_FIELDSELECTION:
+ return WZS_INVALID_STATE;
+ }
+
+ return WZS_INVALID_STATE;
+ }
+
+ //---------------------------------------------------------------------
+ void OGridWizard::enterState(WizardState _nState)
+ {
+ OControlWizard::enterState(_nState);
+
+ enableButtons(WZB_PREVIOUS, m_bHadDataSelection ? (GW_STATE_DATASOURCE_SELECTION < _nState) : GW_STATE_FIELDSELECTION < _nState);
+ enableButtons(WZB_NEXT, GW_STATE_FIELDSELECTION != _nState);
+ if (_nState < GW_STATE_FIELDSELECTION)
+ enableButtons(WZB_FINISH, sal_False);
+
+ if (GW_STATE_FIELDSELECTION == _nState)
+ defaultButton(WZB_FINISH);
+ }
+
+ //---------------------------------------------------------------------
+ sal_Bool OGridWizard::leaveState(WizardState _nState)
+ {
+ if (!OControlWizard::leaveState(_nState))
+ return sal_False;
+
+ if (GW_STATE_FIELDSELECTION == _nState)
+ defaultButton(WZB_NEXT);
+
+ return sal_True;
+ }
+
+ //---------------------------------------------------------------------
+ sal_Bool OGridWizard::onFinish()
+ {
+ if ( !OControlWizard::onFinish() )
+ return sal_False;
+
+ implApplySettings();
+
+ return sal_True;
+ }
+
+ //=====================================================================
+ //= OGridFieldsSelection
+ //=====================================================================
+ //---------------------------------------------------------------------
+ OGridFieldsSelection::OGridFieldsSelection( OGridWizard* _pParent )
+ :OGridPage(_pParent, ModuleRes(RID_PAGE_GW_FIELDSELECTION))
+ ,m_aFrame (this, ModuleRes(FL_FRAME))
+ ,m_aExistFieldsLabel (this, ModuleRes(FT_EXISTING_FIELDS))
+ ,m_aExistFields (this, ModuleRes(LB_EXISTING_FIELDS))
+ ,m_aSelectOne (this, ModuleRes(PB_FIELDRIGHT))
+ ,m_aSelectAll (this, ModuleRes(PB_ALLFIELDSRIGHT))
+ ,m_aDeselectOne (this, ModuleRes(PB_FIELDLEFT))
+ ,m_aDeselectAll (this, ModuleRes(PB_ALLFIELDSLEFT))
+ ,m_aSelFieldsLabel (this, ModuleRes(FT_SELECTED_FIELDS))
+ ,m_aSelFields (this, ModuleRes(LB_SELECTED_FIELDS))
+ {
+ FreeResource();
+
+ enableFormDatasourceDisplay();
+
+ m_aSelectOne.SetClickHdl(LINK(this, OGridFieldsSelection, OnMoveOneEntry));
+ m_aSelectAll.SetClickHdl(LINK(this, OGridFieldsSelection, OnMoveAllEntries));
+ m_aDeselectOne.SetClickHdl(LINK(this, OGridFieldsSelection, OnMoveOneEntry));
+ m_aDeselectAll.SetClickHdl(LINK(this, OGridFieldsSelection, OnMoveAllEntries));
+
+ m_aExistFields.SetSelectHdl(LINK(this, OGridFieldsSelection, OnEntrySelected));
+ m_aSelFields.SetSelectHdl(LINK(this, OGridFieldsSelection, OnEntrySelected));
+ m_aExistFields.SetDoubleClickHdl(LINK(this, OGridFieldsSelection, OnEntryDoubleClicked));
+ m_aSelFields.SetDoubleClickHdl(LINK(this, OGridFieldsSelection, OnEntryDoubleClicked));
+ }
+
+ //---------------------------------------------------------------------
+ void OGridFieldsSelection::ActivatePage()
+ {
+ OGridPage::ActivatePage();
+ m_aExistFields.GrabFocus();
+ }
+
+ //---------------------------------------------------------------------
+ bool OGridFieldsSelection::canAdvance() const
+ {
+ return false;
+ // we're the last page in our wizard
+ }
+
+ //---------------------------------------------------------------------
+ void OGridFieldsSelection::initializePage()
+ {
+ OGridPage::initializePage();
+
+ const OControlWizardContext& rContext = getContext();
+ fillListBox(m_aExistFields, rContext.aFieldNames);
+
+ m_aSelFields.Clear();
+ const OGridSettings& rSettings = getSettings();
+ const ::rtl::OUString* pSelected = rSettings.aSelectedFields.getConstArray();
+ const ::rtl::OUString* pEnd = pSelected + rSettings.aSelectedFields.getLength();
+ for (; pSelected < pEnd; ++pSelected)
+ {
+ m_aSelFields.InsertEntry(*pSelected);
+ m_aExistFields.RemoveEntry(*pSelected);
+ }
+
+ implCheckButtons();
+ }
+
+ //---------------------------------------------------------------------
+ sal_Bool OGridFieldsSelection::commitPage( ::svt::WizardTypes::CommitPageReason _eReason )
+ {
+ if (!OGridPage::commitPage(_eReason))
+ return sal_False;
+
+ OGridSettings& rSettings = getSettings();
+ USHORT nSelected = m_aSelFields.GetEntryCount();
+
+ rSettings.aSelectedFields.realloc(nSelected);
+ ::rtl::OUString* pSelected = rSettings.aSelectedFields.getArray();
+
+ for (USHORT i=0; i<nSelected; ++i, ++pSelected)
+ *pSelected = m_aSelFields.GetEntry(i);
+
+ return sal_True;
+ }
+
+ //---------------------------------------------------------------------
+ void OGridFieldsSelection::implCheckButtons()
+ {
+ m_aSelectOne.Enable(m_aExistFields.GetSelectEntryCount() != 0);
+ m_aSelectAll.Enable(m_aExistFields.GetEntryCount() != 0);
+
+ m_aDeselectOne.Enable(m_aSelFields.GetSelectEntryCount() != 0);
+ m_aDeselectAll.Enable(m_aSelFields.GetEntryCount() != 0);
+
+ getDialog()->enableButtons(WZB_FINISH, 0 != m_aSelFields.GetEntryCount());
+ }
+
+ //---------------------------------------------------------------------
+ IMPL_LINK(OGridFieldsSelection, OnEntryDoubleClicked, ListBox*, _pList)
+ {
+ PushButton* pSimulateButton = &m_aExistFields == _pList ? &m_aSelectOne : &m_aDeselectOne;
+ if (pSimulateButton->IsEnabled())
+ return OnMoveOneEntry( pSimulateButton );
+ else
+ return 1L;
+ }
+
+ //---------------------------------------------------------------------
+ IMPL_LINK(OGridFieldsSelection, OnEntrySelected, ListBox*, /*NOTINTERESTEDIN*/)
+ {
+ implCheckButtons();
+ return 0L;
+ }
+
+ //---------------------------------------------------------------------
+ IMPL_LINK(OGridFieldsSelection, OnMoveOneEntry, PushButton*, _pButton)
+ {
+ sal_Bool bMoveRight = (&m_aSelectOne == _pButton);
+ ListBox& rMoveTo = bMoveRight ? m_aSelFields : m_aExistFields;
+
+ // the index of the selected entry
+ USHORT nSelected = bMoveRight ? m_aExistFields.GetSelectEntryPos() : m_aSelFields.GetSelectEntryPos();
+ // the (original) relative position of the entry
+ sal_IntPtr nRelativeIndex = reinterpret_cast<sal_IntPtr>(bMoveRight ? m_aExistFields.GetEntryData(nSelected) : m_aSelFields.GetEntryData(nSelected));
+
+ USHORT nInsertPos = LISTBOX_APPEND;
+ if (!bMoveRight)
+ { // need to determine an insert pos which reflects the original
+ nInsertPos = 0;
+ while (nInsertPos < rMoveTo.GetEntryCount())
+ {
+ if (reinterpret_cast<sal_IntPtr>(rMoveTo.GetEntryData(nInsertPos)) > nRelativeIndex)
+ break;
+ ++nInsertPos;
+ }
+ }
+
+ // the text of the entry to move
+ String sMovingEntry = bMoveRight ? m_aExistFields.GetEntry(nSelected) : m_aSelFields.GetEntry(nSelected);
+
+ // insert the entry
+ nInsertPos = rMoveTo.InsertEntry(sMovingEntry, nInsertPos);
+ // preserve it's "relative position" entry data
+ rMoveTo.SetEntryData(nInsertPos, reinterpret_cast<void*>(nRelativeIndex));
+
+ // remove the entry from it's old list
+ if (bMoveRight)
+ {
+ USHORT nSelectPos = m_aExistFields.GetSelectEntryPos();
+ m_aExistFields.RemoveEntry(nSelected);
+ if ((LISTBOX_ENTRY_NOTFOUND != nSelectPos) && (nSelectPos < m_aExistFields.GetEntryCount()))
+ m_aExistFields.SelectEntryPos(nSelectPos);
+
+ m_aExistFields.GrabFocus();
+ }
+ else
+ {
+ USHORT nSelectPos = m_aSelFields.GetSelectEntryPos();
+ m_aSelFields.RemoveEntry(nSelected);
+ if ((LISTBOX_ENTRY_NOTFOUND != nSelectPos) && (nSelectPos < m_aSelFields.GetEntryCount()))
+ m_aSelFields.SelectEntryPos(nSelectPos);
+
+ m_aSelFields.GrabFocus();
+ }
+
+ implCheckButtons();
+ return 0;
+ }
+
+ //---------------------------------------------------------------------
+ IMPL_LINK(OGridFieldsSelection, OnMoveAllEntries, PushButton*, _pButton)
+ {
+ sal_Bool bMoveRight = (&m_aSelectAll == _pButton);
+ m_aExistFields.Clear();
+ m_aSelFields.Clear();
+ fillListBox(bMoveRight ? m_aSelFields : m_aExistFields, getContext().aFieldNames);
+
+ implCheckButtons();
+ return 0;
+ }
+
+//.........................................................................
+} // namespace dbp
+//.........................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/dbpilots/gridwizard.hxx b/extensions/source/dbpilots/gridwizard.hxx
new file mode 100644
index 000000000000..085762ce4f7c
--- /dev/null
+++ b/extensions/source/dbpilots/gridwizard.hxx
@@ -0,0 +1,138 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _EXTENSIONS_DBP_GRIDWIZARD_HXX_
+#define _EXTENSIONS_DBP_GRIDWIZARD_HXX_
+
+#include "controlwizard.hxx"
+#include "commonpagesdbp.hxx"
+
+//.........................................................................
+namespace dbp
+{
+//.........................................................................
+
+ //=====================================================================
+ //= OGridSettings
+ //=====================================================================
+ struct OGridSettings : public OControlWizardSettings
+ {
+ ::com::sun::star::uno::Sequence< ::rtl::OUString > aSelectedFields;
+ };
+
+ //=====================================================================
+ //= OGridWizard
+ //=====================================================================
+ class OGridWizard : public OControlWizard
+ {
+ protected:
+ OGridSettings m_aSettings;
+ sal_Bool m_bHadDataSelection : 1;
+
+ public:
+ OGridWizard(
+ Window* _pParent,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxObjectModel,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB
+ );
+
+ OGridSettings& getSettings() { return m_aSettings; }
+
+ protected:
+ // OWizardMachine overridables
+ virtual ::svt::OWizardPage* createPage( WizardState _nState );
+ virtual WizardState determineNextState( WizardState _nCurrentState ) const;
+ virtual void enterState( WizardState _nState );
+ virtual sal_Bool leaveState( WizardState _nState );
+ virtual sal_Bool onFinish();
+
+ virtual sal_Bool approveControl(sal_Int16 _nClassId);
+
+ protected:
+ void implApplySettings();
+ };
+
+ //=====================================================================
+ //= OGridPage
+ //=====================================================================
+ class OGridPage : public OControlWizardPage
+ {
+ public:
+ OGridPage( OGridWizard* _pParent, const ResId& _rId ) : OControlWizardPage(_pParent, _rId) { }
+
+ protected:
+ OGridSettings& getSettings() { return static_cast<OGridWizard*>(getDialog())->getSettings(); }
+ };
+
+ //=====================================================================
+ //= OGridFieldsSelection
+ //=====================================================================
+ class OGridFieldsSelection : public OGridPage
+ {
+ protected:
+ FixedLine m_aFrame;
+ FixedText m_aExistFieldsLabel;
+ ListBox m_aExistFields;
+ PushButton m_aSelectOne;
+ PushButton m_aSelectAll;
+ PushButton m_aDeselectOne;
+ PushButton m_aDeselectAll;
+ FixedText m_aSelFieldsLabel;
+ ListBox m_aSelFields;
+
+ public:
+ OGridFieldsSelection( OGridWizard* _pParent );
+
+ protected:
+ // TabPage overridables
+ virtual void ActivatePage();
+
+ // OWizardPage overridables
+ virtual void initializePage();
+ virtual sal_Bool commitPage( ::svt::WizardTypes::CommitPageReason _eReason );
+ virtual bool canAdvance() const;
+
+ protected:
+ DECL_LINK(OnMoveOneEntry, PushButton*);
+ DECL_LINK(OnMoveAllEntries, PushButton*);
+ DECL_LINK(OnEntrySelected, ListBox*);
+ DECL_LINK(OnEntryDoubleClicked, ListBox*);
+
+ void implCheckButtons();
+ void implApplySettings();
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > implGetColumns(sal_Bool _bShowError = sal_True);
+ };
+
+//.........................................................................
+} // namespace dbp
+//.........................................................................
+
+#endif // _EXTENSIONS_DBP_GRIDWIZARD_HXX_
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/dbpilots/groupboxpages.src b/extensions/source/dbpilots/groupboxpages.src
new file mode 100644
index 000000000000..f5538e2a14af
--- /dev/null
+++ b/extensions/source/dbpilots/groupboxpages.src
@@ -0,0 +1,226 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _EXTENSIONS_DBP_DBPRESID_HRC_
+#include "dbpresid.hrc"
+#endif
+
+TabPage RID_PAGE_GROUPRADIOSELECTION
+{
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( WINDOW_SIZE_X , WINDOW_SIZE_Y ) ;
+ Text [ en-US ] = "Data";
+
+ FixedLine FL_DATA
+ {
+ Pos = MAP_APPFONT ( 4 , 40 ) ;
+ Size = MAP_APPFONT ( WINDOW_SIZE_X - 8 , 8 ) ;
+ };
+ FixedText FT_RADIOLABELS
+ {
+ Pos = MAP_APPFONT ( 7 , 52 ) ;
+ Size = MAP_APPFONT ( WINDOW_HALF_SIZE_X - ITEM_BUTTON_SIZE_X / 2 - 13, 24 ) ;
+ WordBreak = TRUE;
+ Group = TRUE;
+ Text [ en-US ] = "Which ~names do you want to give the option fields?";
+ };
+ Edit ET_RADIOLABELS
+ {
+ Pos = MAP_APPFONT ( 7 , 79 ) ;
+ Size = MAP_APPFONT ( WINDOW_HALF_SIZE_X - ITEM_BUTTON_SIZE_X / 2 - 13, 12 ) ;
+ SVLook = TRUE ;
+ Border = TRUE ;
+ };
+ PushButton PB_MOVETORIGHT
+ {
+ Pos = MAP_APPFONT ( WINDOW_HALF_SIZE_X - ITEM_BUTTON_SIZE_X / 2 , 79 ) ;
+ Size = MAP_APPFONT ( ITEM_BUTTON_SIZE_X , ITEM_BUTTON_SIZE_Y ) ;
+ Text = "~>>";
+ };
+ PushButton PB_MOVETOLEFT
+ {
+ Pos = MAP_APPFONT ( WINDOW_HALF_SIZE_X - ITEM_BUTTON_SIZE_X / 2 , 79 + ITEM_BUTTON_SIZE_Y + 3 ) ;
+ Size = MAP_APPFONT ( ITEM_BUTTON_SIZE_X , ITEM_BUTTON_SIZE_Y ) ;
+ Text = "~<<";
+ };
+ FixedText FT_RADIOBUTTONS
+ {
+ Pos = MAP_APPFONT ( WINDOW_HALF_SIZE_X + ITEM_BUTTON_SIZE_X / 2 + 6 , 52 ) ;
+ Size = MAP_APPFONT ( WINDOW_SIZE_X - WINDOW_HALF_SIZE_X - ITEM_BUTTON_SIZE_X / 2 - 6 - 7, 8 ) ;
+ Group = TRUE;
+ Text [ en-US ] = "~Option fields";
+ };
+ ListBox LB_RADIOBUTTONS
+ {
+ Pos = MAP_APPFONT ( WINDOW_HALF_SIZE_X + ITEM_BUTTON_SIZE_X / 2 + 6 , 79 ) ;
+ Size = MAP_APPFONT ( WINDOW_SIZE_X - WINDOW_HALF_SIZE_X - ITEM_BUTTON_SIZE_X / 2 - 6 - 7, WINDOW_SIZE_Y - 79 - 6 ) ;
+ SVLook = TRUE ;
+ Border = TRUE ;
+ AutoHScroll = TRUE ;
+ Sort = FALSE;
+ };
+};
+
+TabPage RID_PAGE_DEFAULTFIELDSELECTION
+{
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( WINDOW_SIZE_X , WINDOW_SIZE_Y ) ;
+ Text [ en-US ] = "Default Field Selection";
+
+ FixedLine FL_DEFAULTSELECTION
+ {
+ Pos = MAP_APPFONT ( 4 , 3 ) ;
+ Size = MAP_APPFONT ( WINDOW_SIZE_X - 8 , 8 ) ;
+ };
+ FixedText FT_DEFAULTSELECTION
+ {
+ Pos = MAP_APPFONT ( 7 , 15 ) ;
+ Size = MAP_APPFONT ( WINDOW_SIZE_X - 14, 24 ) ;
+ WordBreak = TRUE;
+
+ Text [ en-US ] = "Should one option field be selected as a default?";
+ };
+ RadioButton RB_DEFSELECTION_YES
+ {
+ Pos = MAP_APPFONT ( 7 , 44 ) ;
+ Size = MAP_APPFONT ( WINDOW_HALF_SIZE_X - 10, 10 ) ;
+ Group = TRUE;
+ TabStop = TRUE;
+ Text [ en-US ] = "~Yes, the following:";
+ };
+ ListBox LB_DEFSELECTIONFIELD
+ {
+ Pos = MAP_APPFONT ( WINDOW_HALF_SIZE_X + 3 , 42 ) ;
+ Size = MAP_APPFONT ( WINDOW_HALF_SIZE_X - 10, 14 ) ;
+ TabStop = TRUE;
+ SVLook = TRUE ;
+ Border = TRUE ;
+ DropDown = TRUE;
+ AutoHScroll = TRUE ;
+ Sort = FALSE;
+ };
+ RadioButton RB_DEFSELECTION_NO
+ {
+ Pos = MAP_APPFONT ( 7 , 59 ) ;
+ Size = MAP_APPFONT ( WINDOW_SIZE_X - 14, 10 ) ;
+ TabStop = FALSE;
+ Text [ en-US ] = "No, one particular field is not going to be selected.";
+ };
+};
+
+TabPage RID_PAGE_OPTIONVALUES
+{
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( WINDOW_SIZE_X , WINDOW_SIZE_Y ) ;
+ Text [ en-US ] = "Field Values";
+
+ FixedLine FL_OPTIONVALUES
+ {
+ Pos = MAP_APPFONT ( 4 , 3 ) ;
+ Size = MAP_APPFONT ( WINDOW_SIZE_X - 8 , 8 ) ;
+ };
+ FixedText FT_OPTIONVALUES_EXPL
+ {
+ Pos = MAP_APPFONT ( 7 , 15 ) ;
+ Size = MAP_APPFONT ( WINDOW_HALF_SIZE_X - 10, 24 ) ;
+ WordBreak = TRUE;
+ Text [ en-US ] = "When you select an option, the option group is given a specific value.";
+ };
+ FixedText FT_OPTIONVALUES
+ {
+ Pos = MAP_APPFONT ( 7 , 42 ) ;
+ Size = MAP_APPFONT ( WINDOW_HALF_SIZE_X - 10, 16 ) ;
+ WordBreak = TRUE;
+ Group = TRUE;
+ Text [ en-US ] = "Which ~value do you want to assign to each option?";
+ };
+ Edit ET_OPTIONVALUE
+ {
+ Pos = MAP_APPFONT ( 7 , 61 ) ;
+ Size = MAP_APPFONT ( WINDOW_HALF_SIZE_X - 10, 12 ) ;
+ SVLook = TRUE ;
+ Border = TRUE ;
+ TabStop = TRUE;
+ };
+ FixedText FT_RADIOBUTTONS
+ {
+ Pos = MAP_APPFONT ( WINDOW_HALF_SIZE_X + 3 , 15 ) ;
+ Size = MAP_APPFONT ( WINDOW_SIZE_X - 14 , 8 ) ;
+ Text [ en-US ] = "~Option fields";
+ };
+ ListBox LB_RADIOBUTTONS
+ {
+ Pos = MAP_APPFONT ( WINDOW_HALF_SIZE_X + 3 , 26 ) ;
+ Size = MAP_APPFONT ( WINDOW_HALF_SIZE_X - 10 , WINDOW_SIZE_Y - 32 ) ;
+ SVLook = TRUE ;
+ Border = TRUE ;
+ AutoHScroll = TRUE ;
+ DropDown = FALSE;
+ };
+};
+
+TabPage RID_PAGE_OPTIONS_FINAL
+{
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( WINDOW_SIZE_X , WINDOW_SIZE_Y ) ;
+ Text [ en-US ] = "Create Option Group";
+
+ FixedLine FL_NAMEIT
+ {
+ Pos = MAP_APPFONT ( 4 , 3 ) ;
+ Size = MAP_APPFONT ( WINDOW_SIZE_X - 8 , 8 ) ;
+ };
+ FixedText FT_NAMEIT
+ {
+ Pos = MAP_APPFONT ( 7 , 15 ) ;
+ Size = MAP_APPFONT ( WINDOW_SIZE_X - 14, 16 ) ;
+ WordBreak = TRUE;
+ Text [ en-US ] = "Which ~caption is to be given to your option group?";
+ };
+ Edit ET_NAMEIT
+ {
+ Pos = MAP_APPFONT ( 7 , 34 ) ;
+ Size = MAP_APPFONT ( WINDOW_SIZE_X - 14, 12 ) ;
+ SVLook = TRUE ;
+ Border = TRUE ;
+ };
+ FixedText FT_THATSALL
+ {
+ Pos = MAP_APPFONT ( 7 , WINDOW_SIZE_Y - 22 ) ;
+ Size = MAP_APPFONT ( WINDOW_SIZE_X - 14, 16 ) ;
+ WordBreak = TRUE;
+ Center = TRUE;
+ Text [ en-US ] = "These were all details needed to create the option group.";
+ };
+};
+
+String RID_STR_GROUPWIZ_DBFIELD
+{
+ Text [ en-US ] = "You can either save the value of the option group in a database field or use it for a later action.";
+};
+
+
diff --git a/extensions/source/dbpilots/groupboxwiz.cxx b/extensions/source/dbpilots/groupboxwiz.cxx
new file mode 100644
index 000000000000..8bda68c04c72
--- /dev/null
+++ b/extensions/source/dbpilots/groupboxwiz.cxx
@@ -0,0 +1,563 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+#include "groupboxwiz.hxx"
+#include "commonpagesdbp.hxx"
+#include <tools/debug.hxx>
+#include <vcl/svapp.hxx>
+#include <vcl/msgbox.hxx>
+#include "optiongrouplayouter.hxx"
+#include "dbpilots.hrc"
+
+
+//#define GBW_STATE_DATASELECTION 0
+#define GBW_STATE_OPTIONLIST 0
+#define GBW_STATE_DEFAULTOPTION 1
+#define GBW_STATE_OPTIONVALUES 2
+#define GBW_STATE_DBFIELD 3
+#define GBW_STATE_FINALIZE 4
+
+//.........................................................................
+namespace dbp
+{
+//.........................................................................
+
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::lang;
+ using namespace ::com::sun::star::beans;
+ using namespace ::com::sun::star::form;
+ using namespace ::svt;
+
+ //=====================================================================
+ //= OGroupBoxWizard
+ //=====================================================================
+ //---------------------------------------------------------------------
+ OGroupBoxWizard::OGroupBoxWizard( Window* _pParent,
+ const Reference< XPropertySet >& _rxObjectModel, const Reference< XMultiServiceFactory >& _rxORB )
+ :OControlWizard(_pParent, ModuleRes(RID_DLG_GROUPBOXWIZARD), _rxObjectModel, _rxORB)
+ ,m_bVisitedDefault(sal_False)
+ ,m_bVisitedDB(sal_False)
+ {
+ initControlSettings(&m_aSettings);
+
+ m_pPrevPage->SetHelpId(HID_GROUPWIZARD_PREVIOUS);
+ m_pNextPage->SetHelpId(HID_GROUPWIZARD_NEXT);
+ m_pCancel->SetHelpId(HID_GROUPWIZARD_CANCEL);
+ m_pFinish->SetHelpId(HID_GROUPWIZARD_FINISH);
+ }
+
+ //---------------------------------------------------------------------
+ sal_Bool OGroupBoxWizard::approveControl(sal_Int16 _nClassId)
+ {
+ return FormComponentType::GROUPBOX == _nClassId;
+ }
+
+ //---------------------------------------------------------------------
+ OWizardPage* OGroupBoxWizard::createPage(::svt::WizardTypes::WizardState _nState)
+ {
+ switch (_nState)
+ {
+// case GBW_STATE_DATASELECTION:
+// return new OTableSelectionPage(this);
+//
+ case GBW_STATE_OPTIONLIST:
+ return new ORadioSelectionPage(this);
+
+ case GBW_STATE_DEFAULTOPTION:
+ return new ODefaultFieldSelectionPage(this);
+
+ case GBW_STATE_OPTIONVALUES:
+ return new OOptionValuesPage(this);
+
+ case GBW_STATE_DBFIELD:
+ return new OOptionDBFieldPage(this);
+
+ case GBW_STATE_FINALIZE:
+ return new OFinalizeGBWPage(this);
+ }
+
+ return NULL;
+ }
+
+ //---------------------------------------------------------------------
+ WizardTypes::WizardState OGroupBoxWizard::determineNextState( ::svt::WizardTypes::WizardState _nCurrentState ) const
+ {
+ switch (_nCurrentState)
+ {
+// case GBW_STATE_DATASELECTION:
+// return GBW_STATE_OPTIONLIST;
+//
+ case GBW_STATE_OPTIONLIST:
+ return GBW_STATE_DEFAULTOPTION;
+
+ case GBW_STATE_DEFAULTOPTION:
+ return GBW_STATE_OPTIONVALUES;
+
+ case GBW_STATE_OPTIONVALUES:
+ if (getContext().aFieldNames.getLength())
+ return GBW_STATE_DBFIELD;
+ else
+ return GBW_STATE_FINALIZE;
+
+ case GBW_STATE_DBFIELD:
+ return GBW_STATE_FINALIZE;
+ }
+
+ return WZS_INVALID_STATE;
+ }
+
+ //---------------------------------------------------------------------
+ void OGroupBoxWizard::enterState(::svt::WizardTypes::WizardState _nState)
+ {
+ // some stuff to do before calling the base class (modifying our settings)
+ switch (_nState)
+ {
+ case GBW_STATE_DEFAULTOPTION:
+ if (!m_bVisitedDefault)
+ { // assume that the first of the radio buttons should be selected
+ DBG_ASSERT(m_aSettings.aLabels.size(), "OGroupBoxWizard::enterState: should never have reached this state!");
+ m_aSettings.sDefaultField = m_aSettings.aLabels[0];
+ }
+ m_bVisitedDefault = sal_True;
+ break;
+
+ case GBW_STATE_DBFIELD:
+ if (!m_bVisitedDB)
+ { // try to generate a default for the DB field
+ // (simply use the first field in the DB names collection)
+ if (getContext().aFieldNames.getLength())
+ m_aSettings.sDBField = getContext().aFieldNames[0];
+ }
+ m_bVisitedDB = sal_True;
+ break;
+ }
+
+ // setting the def button .... to be done before the base class is called, too, 'cause the base class
+ // calls the pages, which are allowed to override our def button behaviour
+ defaultButton(GBW_STATE_FINALIZE == _nState ? WZB_FINISH : WZB_NEXT);
+
+ // allow "finish" on the last page only
+ enableButtons(WZB_FINISH, GBW_STATE_FINALIZE == _nState);
+ // allow previous on all pages but the first one
+ enableButtons(WZB_PREVIOUS, GBW_STATE_OPTIONLIST != _nState);
+ // allow next on all pages but the last one
+ enableButtons(WZB_NEXT, GBW_STATE_FINALIZE != _nState);
+
+ OControlWizard::enterState(_nState);
+ }
+
+ //---------------------------------------------------------------------
+ void OGroupBoxWizard::createRadios()
+ {
+ try
+ {
+ OOptionGroupLayouter aLayouter(getServiceFactory());
+ aLayouter.doLayout(getContext(), getSettings());
+ }
+ catch(Exception&)
+ {
+ DBG_ERROR("OGroupBoxWizard::createRadios: caught an exception while creating the radio shapes!");
+ }
+ }
+
+ //---------------------------------------------------------------------
+ sal_Bool OGroupBoxWizard::onFinish()
+ {
+ // commit the basic control setttings
+ commitControlSettings(&m_aSettings);
+
+ // create the radio buttons
+ createRadios();
+
+ return OControlWizard::onFinish();
+ }
+
+ //=====================================================================
+ //= ORadioSelectionPage
+ //=====================================================================
+ //---------------------------------------------------------------------
+ ORadioSelectionPage::ORadioSelectionPage( OControlWizard* _pParent )
+ :OGBWPage(_pParent, ModuleRes(RID_PAGE_GROUPRADIOSELECTION))
+ ,m_aFrame (this, ModuleRes(FL_DATA))
+ ,m_aRadioNameLabel (this, ModuleRes(FT_RADIOLABELS))
+ ,m_aRadioName (this, ModuleRes(ET_RADIOLABELS))
+ ,m_aMoveRight (this, ModuleRes(PB_MOVETORIGHT))
+ ,m_aMoveLeft (this, ModuleRes(PB_MOVETOLEFT))
+ ,m_aExistingRadiosLabel (this, ModuleRes(FT_RADIOBUTTONS))
+ ,m_aExistingRadios (this, ModuleRes(LB_RADIOBUTTONS))
+ {
+ FreeResource();
+
+ if (getContext().aFieldNames.getLength())
+ {
+ enableFormDatasourceDisplay();
+ }
+ else
+ {
+ adjustControlForNoDSDisplay(&m_aFrame);
+ adjustControlForNoDSDisplay(&m_aRadioNameLabel);
+ adjustControlForNoDSDisplay(&m_aRadioName);
+ adjustControlForNoDSDisplay(&m_aMoveRight);
+ adjustControlForNoDSDisplay(&m_aMoveLeft);
+ adjustControlForNoDSDisplay(&m_aExistingRadiosLabel);
+ adjustControlForNoDSDisplay(&m_aExistingRadios, sal_True);
+ }
+
+ m_aMoveLeft.SetClickHdl(LINK(this, ORadioSelectionPage, OnMoveEntry));
+ m_aMoveRight.SetClickHdl(LINK(this, ORadioSelectionPage, OnMoveEntry));
+ m_aRadioName.SetModifyHdl(LINK(this, ORadioSelectionPage, OnNameModified));
+ m_aExistingRadios.SetSelectHdl(LINK(this, ORadioSelectionPage, OnEntrySelected));
+
+ implCheckMoveButtons();
+ m_aExistingRadios.EnableMultiSelection(sal_True);
+
+ getDialog()->defaultButton(&m_aMoveRight);
+ }
+
+ //---------------------------------------------------------------------
+ void ORadioSelectionPage::ActivatePage()
+ {
+ OGBWPage::ActivatePage();
+ m_aRadioName.GrabFocus();
+ }
+
+ //---------------------------------------------------------------------
+ void ORadioSelectionPage::initializePage()
+ {
+ OGBWPage::initializePage();
+
+ m_aRadioName.SetText(String());
+
+ // no need to initialize the list of radios here
+ // (we're the only one affecting this special setting, so it will be in the same state as last time this
+ // page was commited)
+
+ implCheckMoveButtons();
+ }
+
+ //---------------------------------------------------------------------
+ sal_Bool ORadioSelectionPage::commitPage( ::svt::WizardTypes::CommitPageReason _eReason )
+ {
+ if (!OGBWPage::commitPage(_eReason))
+ return sal_False;
+
+ // copy the names of the radio buttons to be inserted
+ // and initialize the values
+ OOptionGroupSettings& rSettings = getSettings();
+ rSettings.aLabels.clear();
+ rSettings.aValues.clear();
+ rSettings.aLabels.reserve(m_aExistingRadios.GetEntryCount());
+ rSettings.aValues.reserve(m_aExistingRadios.GetEntryCount());
+ for (::svt::WizardTypes::WizardState i=0; i<m_aExistingRadios.GetEntryCount(); ++i)
+ {
+ rSettings.aLabels.push_back(m_aExistingRadios.GetEntry(i));
+ rSettings.aValues.push_back(String::CreateFromInt32((sal_Int32)(i + 1)));
+ }
+
+ return sal_True;
+ }
+
+ //---------------------------------------------------------------------
+ IMPL_LINK( ORadioSelectionPage, OnMoveEntry, PushButton*, _pButton )
+ {
+ sal_Bool bMoveLeft = (&m_aMoveLeft == _pButton);
+ if (bMoveLeft)
+ {
+ while (m_aExistingRadios.GetSelectEntryCount())
+ m_aExistingRadios.RemoveEntry(m_aExistingRadios.GetSelectEntryPos(0));
+ }
+ else
+ {
+ m_aExistingRadios.InsertEntry(m_aRadioName.GetText());
+ m_aRadioName.SetText(String());
+ }
+
+ implCheckMoveButtons();
+
+ //adjust the focus
+ if (bMoveLeft)
+ m_aExistingRadios.GrabFocus();
+ else
+ m_aRadioName.GrabFocus();
+ return 0L;
+ }
+
+ //---------------------------------------------------------------------
+ IMPL_LINK( ORadioSelectionPage, OnEntrySelected, ListBox*, /*_pList*/ )
+ {
+ implCheckMoveButtons();
+ return 0L;
+ }
+
+ //---------------------------------------------------------------------
+ IMPL_LINK( ORadioSelectionPage, OnNameModified, Edit*, /*_pList*/ )
+ {
+ implCheckMoveButtons();
+ return 0L;
+ }
+
+ //---------------------------------------------------------------------
+ bool ORadioSelectionPage::canAdvance() const
+ {
+ return 0 != m_aExistingRadios.GetEntryCount();
+ }
+
+ //---------------------------------------------------------------------
+ void ORadioSelectionPage::implCheckMoveButtons()
+ {
+ sal_Bool bHaveSome = (0 != m_aExistingRadios.GetEntryCount());
+ sal_Bool bSelectedSome = (0 != m_aExistingRadios.GetSelectEntryCount());
+ sal_Bool bUnfinishedInput = (0 != m_aRadioName.GetText().Len());
+
+ m_aMoveLeft.Enable(bSelectedSome);
+ m_aMoveRight.Enable(bUnfinishedInput);
+
+ getDialog()->enableButtons(WZB_NEXT, bHaveSome);
+
+ if (bUnfinishedInput)
+ {
+ if (0 == (m_aMoveRight.GetStyle() & WB_DEFBUTTON))
+ getDialog()->defaultButton(&m_aMoveRight);
+ }
+ else
+ {
+ if (WB_DEFBUTTON == (m_aMoveRight.GetStyle() & WB_DEFBUTTON))
+ getDialog()->defaultButton(WZB_NEXT);
+ }
+ }
+
+ //=====================================================================
+ //= ODefaultFieldSelectionPage
+ //=====================================================================
+ //---------------------------------------------------------------------
+ ODefaultFieldSelectionPage::ODefaultFieldSelectionPage( OControlWizard* _pParent )
+ :OMaybeListSelectionPage(_pParent, ModuleRes(RID_PAGE_DEFAULTFIELDSELECTION))
+ ,m_aFrame (this, ModuleRes(FL_DEFAULTSELECTION))
+ ,m_aDefaultSelectionLabel (this, ModuleRes(FT_DEFAULTSELECTION))
+ ,m_aDefSelYes (this, ModuleRes(RB_DEFSELECTION_YES))
+ ,m_aDefSelNo (this, ModuleRes(RB_DEFSELECTION_NO))
+ ,m_aDefSelection (this, ModuleRes(LB_DEFSELECTIONFIELD))
+ {
+ FreeResource();
+
+ announceControls(m_aDefSelYes, m_aDefSelNo, m_aDefSelection);
+ m_aDefSelection.SetDropDownLineCount(10);
+ }
+
+ //---------------------------------------------------------------------
+ void ODefaultFieldSelectionPage::initializePage()
+ {
+ OMaybeListSelectionPage::initializePage();
+
+ const OOptionGroupSettings& rSettings = getSettings();
+
+ // fill the listbox
+ m_aDefSelection.Clear();
+ for ( ConstStringArrayIterator aLoop = rSettings.aLabels.begin();
+ aLoop != rSettings.aLabels.end();
+ ++aLoop
+ )
+ m_aDefSelection.InsertEntry(*aLoop);
+
+
+ implInitialize(rSettings.sDefaultField);
+ }
+
+ //---------------------------------------------------------------------
+ sal_Bool ODefaultFieldSelectionPage::commitPage( ::svt::WizardTypes::CommitPageReason _eReason )
+ {
+ if (!OMaybeListSelectionPage::commitPage(_eReason))
+ return sal_False;
+
+ OOptionGroupSettings& rSettings = getSettings();
+ implCommit(rSettings.sDefaultField);
+
+ return sal_True;
+ }
+
+ //=====================================================================
+ //= OOptionValuesPage
+ //=====================================================================
+ //---------------------------------------------------------------------
+ OOptionValuesPage::OOptionValuesPage( OControlWizard* _pParent )
+ :OGBWPage(_pParent, ModuleRes(RID_PAGE_OPTIONVALUES))
+ ,m_aFrame (this, ModuleRes(FL_OPTIONVALUES))
+ ,m_aDescription (this, ModuleRes(FT_OPTIONVALUES_EXPL))
+ ,m_aValueLabel (this, ModuleRes(FT_OPTIONVALUES))
+ ,m_aValue (this, ModuleRes(ET_OPTIONVALUE))
+ ,m_aOptionsLabel (this, ModuleRes(FT_RADIOBUTTONS))
+ ,m_aOptions (this, ModuleRes(LB_RADIOBUTTONS))
+ ,m_nLastSelection((::svt::WizardTypes::WizardState)-1)
+ {
+ FreeResource();
+
+ m_aOptions.SetSelectHdl(LINK(this, OOptionValuesPage, OnOptionSelected));
+ }
+
+ //---------------------------------------------------------------------
+ IMPL_LINK( OOptionValuesPage, OnOptionSelected, ListBox*, /*NOTINTERESTEDIN*/ )
+ {
+ implTraveledOptions();
+ return 0L;
+ }
+
+ //---------------------------------------------------------------------
+ void OOptionValuesPage::ActivatePage()
+ {
+ OGBWPage::ActivatePage();
+ m_aValue.GrabFocus();
+ }
+
+ //---------------------------------------------------------------------
+ void OOptionValuesPage::implTraveledOptions()
+ {
+ if ((::svt::WizardTypes::WizardState)-1 != m_nLastSelection)
+ {
+ // save the value for the last option
+ DBG_ASSERT((size_t)m_nLastSelection < m_aUncommittedValues.size(), "OOptionValuesPage::implTraveledOptions: invalid previous selection index!");
+ m_aUncommittedValues[m_nLastSelection] = m_aValue.GetText();
+ }
+
+ m_nLastSelection = m_aOptions.GetSelectEntryPos();
+ DBG_ASSERT((size_t)m_nLastSelection < m_aUncommittedValues.size(), "OOptionValuesPage::implTraveledOptions: invalid new selection index!");
+ m_aValue.SetText(m_aUncommittedValues[m_nLastSelection]);
+ }
+
+ //---------------------------------------------------------------------
+ void OOptionValuesPage::initializePage()
+ {
+ OGBWPage::initializePage();
+
+ const OOptionGroupSettings& rSettings = getSettings();
+ DBG_ASSERT(rSettings.aLabels.size(), "OOptionValuesPage::initializePage: no options!!");
+ DBG_ASSERT(rSettings.aLabels.size() == rSettings.aValues.size(), "OOptionValuesPage::initializePage: inconsistent data!");
+
+ // fill the list with all available options
+ m_aOptions.Clear();
+ m_nLastSelection = -1;
+ for ( ConstStringArrayIterator aLoop = rSettings.aLabels.begin();
+ aLoop != rSettings.aLabels.end();
+ ++aLoop
+ )
+ m_aOptions.InsertEntry(*aLoop);
+
+ // remember the values ... can't set them directly in the settings without the explicit commit call
+ // so we need have a copy of the values
+ m_aUncommittedValues = rSettings.aValues;
+
+ // select the first entry
+ m_aOptions.SelectEntryPos(0);
+ implTraveledOptions();
+ }
+
+ //---------------------------------------------------------------------
+ sal_Bool OOptionValuesPage::commitPage( ::svt::WizardTypes::CommitPageReason _eReason )
+ {
+ if (!OGBWPage::commitPage(_eReason))
+ return sal_False;
+
+ OOptionGroupSettings& rSettings = getSettings();
+
+ // commit the current value
+ implTraveledOptions();
+ // copy the uncommitted values
+ rSettings.aValues = m_aUncommittedValues;
+
+ return sal_True;
+ }
+
+ //=====================================================================
+ //= OOptionDBFieldPage
+ //=====================================================================
+ //---------------------------------------------------------------------
+ OOptionDBFieldPage::OOptionDBFieldPage( OControlWizard* _pParent )
+ :ODBFieldPage(_pParent)
+ {
+ setDescriptionText(String(ModuleRes(RID_STR_GROUPWIZ_DBFIELD)));
+ }
+
+ //---------------------------------------------------------------------
+ String& OOptionDBFieldPage::getDBFieldSetting()
+ {
+ return getSettings().sDBField;
+ }
+
+ //=====================================================================
+ //= OFinalizeGBWPage
+ //=====================================================================
+ //---------------------------------------------------------------------
+ OFinalizeGBWPage::OFinalizeGBWPage( OControlWizard* _pParent )
+ :OGBWPage(_pParent, ModuleRes(RID_PAGE_OPTIONS_FINAL))
+ ,m_aFrame (this, ModuleRes(FL_NAMEIT))
+ ,m_aNameLabel (this, ModuleRes(FT_NAMEIT))
+ ,m_aName (this, ModuleRes(ET_NAMEIT))
+ ,m_aThatsAll (this, ModuleRes(FT_THATSALL))
+ {
+ FreeResource();
+ }
+
+ //---------------------------------------------------------------------
+ void OFinalizeGBWPage::ActivatePage()
+ {
+ OGBWPage::ActivatePage();
+ m_aName.GrabFocus();
+ }
+
+ //---------------------------------------------------------------------
+ bool OFinalizeGBWPage::canAdvance() const
+ {
+ return false;
+ }
+
+ //---------------------------------------------------------------------
+ void OFinalizeGBWPage::initializePage()
+ {
+ OGBWPage::initializePage();
+
+ const OOptionGroupSettings& rSettings = getSettings();
+ m_aName.SetText(rSettings.sControlLabel);
+ }
+
+ //---------------------------------------------------------------------
+ sal_Bool OFinalizeGBWPage::commitPage( ::svt::WizardTypes::CommitPageReason _eReason )
+ {
+ if (!OGBWPage::commitPage(_eReason))
+ return sal_False;
+
+ getSettings().sControlLabel = m_aName.GetText();
+
+ return sal_True;
+ }
+
+//.........................................................................
+} // namespace dbp
+//.........................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/dbpilots/groupboxwiz.hxx b/extensions/source/dbpilots/groupboxwiz.hxx
new file mode 100644
index 000000000000..2b762e1f96ce
--- /dev/null
+++ b/extensions/source/dbpilots/groupboxwiz.hxx
@@ -0,0 +1,231 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _EXTENSIONS_DBP_GROUPBOXWIZ_HXX_
+#define _EXTENSIONS_DBP_GROUPBOXWIZ_HXX_
+
+#include "controlwizard.hxx"
+#include "commonpagesdbp.hxx"
+
+//.........................................................................
+namespace dbp
+{
+//.........................................................................
+
+ //=====================================================================
+ //= OOptionGroupSettings
+ //=====================================================================
+ struct OOptionGroupSettings : public OControlWizardSettings
+ {
+ StringArray aLabels;
+ StringArray aValues;
+ String sDefaultField;
+ String sDBField;
+ String sName;
+ };
+
+ //=====================================================================
+ //= OGroupBoxWizard
+ //=====================================================================
+ class OGroupBoxWizard : public OControlWizard
+ {
+ protected:
+ OOptionGroupSettings m_aSettings;
+
+ sal_Bool m_bVisitedDefault : 1;
+ sal_Bool m_bVisitedDB : 1;
+
+ public:
+ OGroupBoxWizard(
+ Window* _pParent,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxObjectModel,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB
+ );
+
+ OOptionGroupSettings& getSettings() { return m_aSettings; }
+
+ protected:
+ // OWizardMachine overridables
+ virtual ::svt::OWizardPage* createPage( WizardState _nState );
+ virtual WizardState determineNextState( WizardState _nCurrentState ) const;
+ virtual void enterState( WizardState _nState );
+ virtual sal_Bool onFinish();
+
+ virtual sal_Bool approveControl(sal_Int16 _nClassId);
+
+ protected:
+ void createRadios();
+ };
+
+ //=====================================================================
+ //= OGBWPage
+ //=====================================================================
+ class OGBWPage : public OControlWizardPage
+ {
+ public:
+ OGBWPage( OControlWizard* _pParent, const ResId& _rId ) : OControlWizardPage(_pParent, _rId) { }
+
+ protected:
+ OOptionGroupSettings& getSettings() { return static_cast<OGroupBoxWizard*>(getDialog())->getSettings(); }
+ };
+
+ //=====================================================================
+ //= ORadioSelectionPage
+ //=====================================================================
+ class ORadioSelectionPage : public OGBWPage
+ {
+ protected:
+ FixedLine m_aFrame;
+ FixedText m_aRadioNameLabel;
+ Edit m_aRadioName;
+ PushButton m_aMoveRight;
+ PushButton m_aMoveLeft;
+ FixedText m_aExistingRadiosLabel;
+ ListBox m_aExistingRadios;
+
+ public:
+ ORadioSelectionPage( OControlWizard* _pParent );
+
+ protected:
+ // TabPage overridables
+ void ActivatePage();
+
+ // OWizardPage overridables
+ virtual void initializePage();
+ virtual sal_Bool commitPage( ::svt::WizardTypes::CommitPageReason _eReason );
+ virtual bool canAdvance() const;
+
+ DECL_LINK( OnMoveEntry, PushButton* );
+ DECL_LINK( OnEntrySelected, ListBox* );
+ DECL_LINK( OnNameModified, Edit* );
+
+ void implCheckMoveButtons();
+ };
+
+ //=====================================================================
+ //= ODefaultFieldSelectionPage
+ //=====================================================================
+ class ODefaultFieldSelectionPage : public OMaybeListSelectionPage
+ {
+ protected:
+ FixedLine m_aFrame;
+ FixedText m_aDefaultSelectionLabel;
+ RadioButton m_aDefSelYes;
+ RadioButton m_aDefSelNo;
+ ListBox m_aDefSelection;
+
+ public:
+ ODefaultFieldSelectionPage( OControlWizard* _pParent );
+
+ protected:
+ // OWizardPage overridables
+ virtual void initializePage();
+ virtual sal_Bool commitPage( ::svt::WizardTypes::CommitPageReason _eReason );
+
+ OOptionGroupSettings& getSettings() { return static_cast<OGroupBoxWizard*>(getDialog())->getSettings(); }
+ };
+
+ //=====================================================================
+ //= OOptionValuesPage
+ //=====================================================================
+ class OOptionValuesPage : public OGBWPage
+ {
+ protected:
+ FixedLine m_aFrame;
+ FixedText m_aDescription;
+ FixedText m_aValueLabel;
+ Edit m_aValue;
+ FixedText m_aOptionsLabel;
+ ListBox m_aOptions;
+
+ StringArray m_aUncommittedValues;
+ ::svt::WizardTypes::WizardState
+ m_nLastSelection;
+
+ public:
+ OOptionValuesPage( OControlWizard* _pParent );
+
+ protected:
+ // TabPage overridables
+ void ActivatePage();
+
+ // OWizardPage overridables
+ virtual void initializePage();
+ virtual sal_Bool commitPage( ::svt::WizardTypes::CommitPageReason _eReason );
+
+ void implTraveledOptions();
+
+ DECL_LINK( OnOptionSelected, ListBox* );
+ };
+
+ //=====================================================================
+ //= OOptionDBFieldPage
+ //=====================================================================
+ class OOptionDBFieldPage : public ODBFieldPage
+ {
+ public:
+ OOptionDBFieldPage( OControlWizard* _pParent );
+
+ protected:
+ OOptionGroupSettings& getSettings() { return static_cast<OGroupBoxWizard*>(getDialog())->getSettings(); }
+
+ // ODBFieldPage overridables
+ virtual String& getDBFieldSetting();
+ };
+
+ //=====================================================================
+ //= OFinalizeGBWPage
+ //=====================================================================
+ class OFinalizeGBWPage : public OGBWPage
+ {
+ protected:
+ FixedLine m_aFrame;
+ FixedText m_aNameLabel;
+ Edit m_aName;
+ FixedText m_aThatsAll;
+
+ public:
+ OFinalizeGBWPage( OControlWizard* _pParent );
+
+ protected:
+ // TabPage overridables
+ void ActivatePage();
+
+ // OWizardPage overridables
+ virtual void initializePage();
+ virtual sal_Bool commitPage( ::svt::WizardTypes::CommitPageReason _eReason );
+ virtual bool canAdvance() const;
+ };
+
+//.........................................................................
+} // namespace dbp
+//.........................................................................
+
+#endif // _EXTENSIONS_DBP_GROUPBOXWIZ_HXX_
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/dbpilots/listcombopages.src b/extensions/source/dbpilots/listcombopages.src
new file mode 100644
index 000000000000..7e48fef2cca9
--- /dev/null
+++ b/extensions/source/dbpilots/listcombopages.src
@@ -0,0 +1,203 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _EXTENSIONS_DBP_DBPRESID_HRC_
+#include "dbpresid.hrc"
+#endif
+
+TabPage RID_PAGE_LCW_CONTENTSELECTION_TABLE
+{
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( WINDOW_SIZE_X , WINDOW_SIZE_Y ) ;
+
+ Text [ en-US ] = "Table Selection";
+
+ FixedLine FL_FRAME
+ {
+ Pos = MAP_APPFONT ( 4 , 40 ) ;
+ Size = MAP_APPFONT ( WINDOW_SIZE_X - 8 , 8 ) ;
+ Text [ en-US ] = "Control";
+ };
+
+ FixedText FT_SELECTTABLE_LABEL
+ {
+ Pos = MAP_APPFONT ( 7 , 52 ) ;
+ Size = MAP_APPFONT ( 120, WINDOW_SIZE_Y - 21 ) ;
+ WordBreak = TRUE;
+ Group = TRUE;
+ Text [ en-US ] = "On the right side, you see all the tables from the data source of the form.\n\n\nChoose the table from which the data should be used as basis for the list content:";
+ };
+ ListBox LB_SELECTTABLE
+ {
+ Pos = MAP_APPFONT ( 130 , 52 ) ;
+ Size = MAP_APPFONT ( WINDOW_SIZE_X - 130 - 7, WINDOW_SIZE_Y - 52 - 6 ) ;
+ SVLook = TRUE ;
+ Border = TRUE ;
+ AutoHScroll = TRUE ;
+ Sort = FALSE;
+ DropDown = FALSE;
+ };
+};
+
+TabPage RID_PAGE_LCW_CONTENTSELECTION_FIELD
+{
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( WINDOW_SIZE_X , WINDOW_SIZE_Y ) ;
+
+ Text [ en-US ] = "Field Selection";
+
+ FixedLine FL_FRAME
+ {
+ Pos = MAP_APPFONT ( 4 , 3 ) ;
+ Size = MAP_APPFONT ( WINDOW_SIZE_X - 8 , 8 ) ;
+ };
+
+ FixedText FT_TABLEFIELDS
+ {
+ Pos = MAP_APPFONT ( 7 , 15 ) ;
+ Size = MAP_APPFONT ( WINDOW_HALF_SIZE_X - 3, 8 ) ;
+ WordBreak = TRUE;
+ Group = TRUE;
+ Text [ en-US ] = "Existing fields";
+ };
+ ListBox LB_SELECTFIELD
+ {
+ Pos = MAP_APPFONT ( 7 , 26 ) ;
+ Size = MAP_APPFONT ( WINDOW_HALF_SIZE_X - 10, WINDOW_SIZE_Y - 32 ) ;
+ SVLook = TRUE ;
+ Border = TRUE ;
+ AutoHScroll = TRUE ;
+ Sort = FALSE;
+ DropDown = FALSE;
+ };
+ FixedText FT_DISPLAYEDFIELD
+ {
+ Pos = MAP_APPFONT ( WINDOW_HALF_SIZE_X + 3 , 15 ) ;
+ Size = MAP_APPFONT ( WINDOW_HALF_SIZE_X - 10, 8 ) ;
+ Text [ en-US ] = "Display field";
+ };
+ Edit ET_DISPLAYEDFIELD
+ {
+ Pos = MAP_APPFONT ( WINDOW_HALF_SIZE_X + 3 , 26 ) ;
+ Size = MAP_APPFONT ( WINDOW_HALF_SIZE_X - 10, 12 ) ;
+ SVLook = TRUE ;
+ Border = TRUE ;
+ ReadOnly = TRUE;
+ };
+ FixedText FT_CONTENTFIELD_INFO
+ {
+ Pos = MAP_APPFONT ( WINDOW_HALF_SIZE_X + 3 , 45 ) ;
+ Size = MAP_APPFONT ( WINDOW_HALF_SIZE_X - 10, WINDOW_SIZE_Y - 51 ) ;
+ WordBreak = TRUE;
+ };
+ String STR_FIELDINFO_COMBOBOX
+ {
+ Text [ en-US ] = "The contents of the field selected will be shown in the combo box list.";
+ };
+
+ String STR_FIELDINFO_LISTBOX
+ {
+ Text [ en-US ] = "The contents of the selected field will be shown in the list box if the linked fields are identical.";
+ };
+};
+
+TabPage RID_PAGE_LCW_FIELDLINK
+{
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( WINDOW_SIZE_X , WINDOW_SIZE_Y ) ;
+
+ Text [ en-US ] = "Field Link";
+
+ FixedText FT_FIELDLINK_DESC
+ {
+ Pos = MAP_APPFONT ( 7 , 6 ) ;
+ Size = MAP_APPFONT ( WINDOW_SIZE_X - 14 , 16 ) ;
+ WordBreak = TRUE;
+ Text [ en-US ] = "This is where you select fields with matching contents so that the value from the display field will be shown.";
+ };
+ FixedLine FL_FRAME
+ {
+ Pos = MAP_APPFONT ( 4 , 25 ) ;
+ Size = MAP_APPFONT ( WINDOW_SIZE_X - 8 , 8 ) ;
+ };
+ FixedText FT_VALUELISTFIELD
+ {
+ Pos = MAP_APPFONT ( 7 , 37 ) ;
+ Size = MAP_APPFONT ( WINDOW_HALF_SIZE_X - 10, 8 ) ;
+ Group = TRUE;
+ Text [ en-US ] = "Field from the ~Value Table";
+ };
+ ComboBox CMB_VALUELISTFIELD
+ {
+ Pos = MAP_APPFONT ( 7 , 48 ) ;
+ Size = MAP_APPFONT ( WINDOW_HALF_SIZE_X - 10, WINDOW_SIZE_Y - 54 ) ;
+ SVLook = TRUE ;
+ Border = TRUE ;
+ DropDown = FALSE;
+ Sort = FALSE;
+ AutoHScroll = TRUE;
+ };
+ FixedText FT_TABLEFIELD
+ {
+ Pos = MAP_APPFONT ( WINDOW_HALF_SIZE_X + 3 , 37 ) ;
+ Size = MAP_APPFONT ( WINDOW_HALF_SIZE_X - 10, 8 ) ;
+ Group = TRUE;
+ Text [ en-US ] = "Field from the ~List Table";
+ };
+ ComboBox CMB_TABLEFIELD
+ {
+ Pos = MAP_APPFONT ( WINDOW_HALF_SIZE_X + 3 , 48 ) ;
+ Size = MAP_APPFONT ( WINDOW_HALF_SIZE_X - 10, WINDOW_SIZE_Y - 54 ) ;
+ SVLook = TRUE ;
+ Border = TRUE ;
+ DropDown = FALSE;
+ Sort = FALSE;
+ AutoHScroll = TRUE;
+ };
+};
+
+String RID_STR_COMBOWIZ_DBFIELD
+{
+ Text [ en-US ] = "You can either save the value of the combo box in a database field or use it for display purposes.";
+};
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/extensions/source/dbpilots/listcombowizard.cxx b/extensions/source/dbpilots/listcombowizard.cxx
new file mode 100644
index 000000000000..93c71ba16085
--- /dev/null
+++ b/extensions/source/dbpilots/listcombowizard.cxx
@@ -0,0 +1,564 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+#include "listcombowizard.hxx"
+#include "commonpagesdbp.hxx"
+#include <com/sun/star/sdbc/XConnection.hpp>
+#include <com/sun/star/sdbcx/XTablesSupplier.hpp>
+#include <com/sun/star/container/XNameAccess.hpp>
+#include <com/sun/star/form/ListSourceType.hpp>
+#include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
+#include <tools/debug.hxx>
+#include <vcl/msgbox.hxx>
+#include <connectivity/dbtools.hxx>
+#include "dbpilots.hrc"
+#include <comphelper/extract.hxx>
+
+//.........................................................................
+namespace dbp
+{
+//.........................................................................
+
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::lang;
+ using namespace ::com::sun::star::beans;
+ using namespace ::com::sun::star::sdbc;
+ using namespace ::com::sun::star::sdbcx;
+ using namespace ::com::sun::star::container;
+ using namespace ::com::sun::star::form;
+ using namespace ::svt;
+ using namespace ::dbtools;
+
+ //=====================================================================
+ //= OListComboWizard
+ //=====================================================================
+ //---------------------------------------------------------------------
+ OListComboWizard::OListComboWizard( Window* _pParent,
+ const Reference< XPropertySet >& _rxObjectModel, const Reference< XMultiServiceFactory >& _rxORB )
+ :OControlWizard(_pParent, ModuleRes(RID_DLG_LISTCOMBOWIZARD), _rxObjectModel, _rxORB)
+ ,m_bListBox(sal_False)
+ ,m_bHadDataSelection(sal_True)
+ {
+ initControlSettings(&m_aSettings);
+
+ m_pPrevPage->SetHelpId(HID_LISTWIZARD_PREVIOUS);
+ m_pNextPage->SetHelpId(HID_LISTWIZARD_NEXT);
+ m_pCancel->SetHelpId(HID_LISTWIZARD_CANCEL);
+ m_pFinish->SetHelpId(HID_LISTWIZARD_FINISH);
+
+ // if we do not need the data source selection page ...
+ if (!needDatasourceSelection())
+ { // ... skip it!
+ skip(1);
+ m_bHadDataSelection = sal_False;
+ }
+ }
+
+ //---------------------------------------------------------------------
+ sal_Bool OListComboWizard::approveControl(sal_Int16 _nClassId)
+ {
+ switch (_nClassId)
+ {
+ case FormComponentType::LISTBOX:
+ m_bListBox = sal_True;
+ setTitleBase(String(ModuleRes(RID_STR_LISTWIZARD_TITLE)));
+ return sal_True;
+ case FormComponentType::COMBOBOX:
+ m_bListBox = sal_False;
+ setTitleBase(String(ModuleRes(RID_STR_COMBOWIZARD_TITLE)));
+ return sal_True;
+ }
+ return sal_False;
+ }
+
+ //---------------------------------------------------------------------
+ OWizardPage* OListComboWizard::createPage(WizardState _nState)
+ {
+ switch (_nState)
+ {
+ case LCW_STATE_DATASOURCE_SELECTION:
+ return new OTableSelectionPage(this);
+ case LCW_STATE_TABLESELECTION:
+ return new OContentTableSelection(this);
+ case LCW_STATE_FIELDSELECTION:
+ return new OContentFieldSelection(this);
+ case LCW_STATE_FIELDLINK:
+ return new OLinkFieldsPage(this);
+ case LCW_STATE_COMBODBFIELD:
+ return new OComboDBFieldPage(this);
+ }
+
+ return NULL;
+ }
+
+ //---------------------------------------------------------------------
+ WizardTypes::WizardState OListComboWizard::determineNextState( WizardState _nCurrentState ) const
+ {
+ switch (_nCurrentState)
+ {
+ case LCW_STATE_DATASOURCE_SELECTION:
+ return LCW_STATE_TABLESELECTION;
+ case LCW_STATE_TABLESELECTION:
+ return LCW_STATE_FIELDSELECTION;
+ case LCW_STATE_FIELDSELECTION:
+ return getFinalState();
+ }
+
+ return WZS_INVALID_STATE;
+ }
+
+ //---------------------------------------------------------------------
+ void OListComboWizard::enterState(WizardState _nState)
+ {
+ OControlWizard::enterState(_nState);
+
+ enableButtons(WZB_PREVIOUS, m_bHadDataSelection ? (LCW_STATE_DATASOURCE_SELECTION < _nState) : LCW_STATE_TABLESELECTION < _nState);
+ enableButtons(WZB_NEXT, getFinalState() != _nState);
+ if (_nState < getFinalState())
+ enableButtons(WZB_FINISH, sal_False);
+
+ if (getFinalState() == _nState)
+ defaultButton(WZB_FINISH);
+ }
+
+ //---------------------------------------------------------------------
+ sal_Bool OListComboWizard::leaveState(WizardState _nState)
+ {
+ if (!OControlWizard::leaveState(_nState))
+ return sal_False;
+
+ if (getFinalState() == _nState)
+ defaultButton(WZB_NEXT);
+
+ return sal_True;
+ }
+
+ //---------------------------------------------------------------------
+ void OListComboWizard::implApplySettings()
+ {
+ try
+ {
+ // for quoting identifiers, we need the connection meta data
+ Reference< XConnection > xConn = getFormConnection();
+ DBG_ASSERT(xConn.is(), "OListComboWizard::implApplySettings: no connection, unable to quote!");
+ Reference< XDatabaseMetaData > xMetaData;
+ if (xConn.is())
+ xMetaData = xConn->getMetaData();
+
+ // do some quotings
+ if (xMetaData.is())
+ {
+ ::rtl::OUString sQuoteString = xMetaData->getIdentifierQuoteString();
+ if (isListBox()) // only when we have a listbox this should be not empty
+ getSettings().sLinkedListField = quoteName(sQuoteString, getSettings().sLinkedListField);
+
+ ::rtl::OUString sCatalog, sSchema, sName;
+ ::dbtools::qualifiedNameComponents( xMetaData, getSettings().sListContentTable, sCatalog, sSchema, sName, ::dbtools::eInDataManipulation );
+ getSettings().sListContentTable = ::dbtools::composeTableNameForSelect( xConn, sCatalog, sSchema, sName );
+
+ getSettings().sListContentField = quoteName(sQuoteString, getSettings().sListContentField);
+ }
+
+ // ListSourceType: SQL
+ getContext().xObjectModel->setPropertyValue(::rtl::OUString::createFromAscii("ListSourceType"), makeAny((sal_Int32)ListSourceType_SQL));
+
+ if (isListBox())
+ {
+ // BoundColumn: 1
+ getContext().xObjectModel->setPropertyValue(::rtl::OUString::createFromAscii("BoundColumn"), makeAny((sal_Int16)1));
+
+ // build the statement to set as list source
+ String sStatement;
+ sStatement.AppendAscii("SELECT ");
+ sStatement += getSettings().sListContentField;
+ sStatement.AppendAscii(", ");
+ sStatement += getSettings().sLinkedListField;
+ sStatement.AppendAscii(" FROM ");
+ sStatement += getSettings().sListContentTable;
+ Sequence< ::rtl::OUString > aListSource(1);
+ aListSource[0] = sStatement;
+ getContext().xObjectModel->setPropertyValue(::rtl::OUString::createFromAscii("ListSource"), makeAny(aListSource));
+ }
+ else
+ {
+ // build the statement to set as list source
+ String sStatement;
+ sStatement.AppendAscii("SELECT DISTINCT ");
+ sStatement += getSettings().sListContentField;
+ sStatement.AppendAscii(" FROM ");
+ sStatement += getSettings().sListContentTable;
+ getContext().xObjectModel->setPropertyValue(::rtl::OUString::createFromAscii("ListSource"), makeAny(::rtl::OUString(sStatement)));
+ }
+
+ // the bound field
+ getContext().xObjectModel->setPropertyValue(::rtl::OUString::createFromAscii("DataField"), makeAny(::rtl::OUString(getSettings().sLinkedFormField)));
+ }
+ catch(Exception&)
+ {
+ DBG_ERROR("OListComboWizard::implApplySettings: could not set the property values for the listbox!");
+ }
+ }
+
+ //---------------------------------------------------------------------
+ sal_Bool OListComboWizard::onFinish()
+ {
+ if ( !OControlWizard::onFinish() )
+ return sal_False;
+
+ implApplySettings();
+ return sal_True;
+ }
+
+ //=====================================================================
+ //= OLCPage
+ //=====================================================================
+ //---------------------------------------------------------------------
+ Reference< XNameAccess > OLCPage::getTables(sal_Bool _bNeedIt)
+ {
+ Reference< XConnection > xConn = getFormConnection();
+ DBG_ASSERT(!_bNeedIt || xConn.is(), "OLCPage::getTables: should have an active connection when reaching this page!");
+ (void)_bNeedIt;
+
+ Reference< XTablesSupplier > xSuppTables(xConn, UNO_QUERY);
+ Reference< XNameAccess > xTables;
+ if (xSuppTables.is())
+ xTables = xSuppTables->getTables();
+
+ DBG_ASSERT(!_bNeedIt || xTables.is() || !xConn.is(), "OLCPage::getTables: got no tables from the connection!");
+
+ return xTables;
+ }
+
+ //---------------------------------------------------------------------
+ Sequence< ::rtl::OUString > OLCPage::getTableFields(sal_Bool _bNeedIt)
+ {
+ Reference< XNameAccess > xTables = getTables(_bNeedIt);
+ Sequence< ::rtl::OUString > aColumnNames;
+ if (xTables.is())
+ {
+ try
+ {
+ // the list table as XColumnsSupplier
+ Reference< XColumnsSupplier > xSuppCols;
+ xTables->getByName(getSettings().sListContentTable) >>= xSuppCols;
+ DBG_ASSERT(!_bNeedIt || xSuppCols.is(), "OLCPage::getTableFields: no columns supplier!");
+
+ // the columns
+ Reference< XNameAccess > xColumns;
+ if (xSuppCols.is())
+ xColumns = xSuppCols->getColumns();
+
+ // the column names
+ if (xColumns.is())
+ aColumnNames = xColumns->getElementNames();
+ }
+ catch(Exception&)
+ {
+ DBG_ASSERT(!_bNeedIt, "OLinkFieldsPage::initializePage: caught an exception while retrieving the columns!");
+ }
+ }
+ return aColumnNames;
+ }
+
+ //=====================================================================
+ //= OContentTableSelection
+ //=====================================================================
+ //---------------------------------------------------------------------
+ OContentTableSelection::OContentTableSelection( OListComboWizard* _pParent )
+ :OLCPage(_pParent, ModuleRes(RID_PAGE_LCW_CONTENTSELECTION_TABLE))
+ ,m_aFrame (this, ModuleRes(FL_FRAME))
+ ,m_aSelectTableLabel (this, ModuleRes(FT_SELECTTABLE_LABEL))
+ ,m_aSelectTable (this, ModuleRes(LB_SELECTTABLE))
+ {
+ FreeResource();
+
+ enableFormDatasourceDisplay();
+
+ m_aSelectTable.SetDoubleClickHdl(LINK(this, OContentTableSelection, OnTableDoubleClicked));
+ m_aSelectTable.SetSelectHdl(LINK(this, OContentTableSelection, OnTableSelected));
+ }
+
+ //---------------------------------------------------------------------
+ void OContentTableSelection::ActivatePage()
+ {
+ OLCPage::ActivatePage();
+ m_aSelectTable.GrabFocus();
+ }
+
+ //---------------------------------------------------------------------
+ bool OContentTableSelection::canAdvance() const
+ {
+ if (!OLCPage::canAdvance())
+ return false;
+
+ return 0 != m_aSelectTable.GetSelectEntryCount();
+ }
+
+ //---------------------------------------------------------------------
+ IMPL_LINK( OContentTableSelection, OnTableSelected, ListBox*, /*_pListBox*/ )
+ {
+ updateDialogTravelUI();
+ return 0L;
+ }
+
+ //---------------------------------------------------------------------
+ IMPL_LINK( OContentTableSelection, OnTableDoubleClicked, ListBox*, _pListBox )
+ {
+ if (_pListBox->GetSelectEntryCount())
+ getDialog()->travelNext();
+ return 0L;
+ }
+
+ //---------------------------------------------------------------------
+ void OContentTableSelection::initializePage()
+ {
+ OLCPage::initializePage();
+
+ // fill the list with the table name
+ m_aSelectTable.Clear();
+ try
+ {
+ Reference< XNameAccess > xTables = getTables(sal_True);
+ Sequence< ::rtl::OUString > aTableNames;
+ if (xTables.is())
+ aTableNames = xTables->getElementNames();
+ fillListBox(m_aSelectTable, aTableNames);
+ }
+ catch(Exception&)
+ {
+ DBG_ERROR("OContentTableSelection::initializePage: could not retrieve the table names!");
+ }
+
+ m_aSelectTable.SelectEntry(getSettings().sListContentTable);
+ }
+
+ //---------------------------------------------------------------------
+ sal_Bool OContentTableSelection::commitPage( ::svt::WizardTypes::CommitPageReason _eReason )
+ {
+ if (!OLCPage::commitPage(_eReason))
+ return sal_False;
+
+ OListComboSettings& rSettings = getSettings();
+ rSettings.sListContentTable = m_aSelectTable.GetSelectEntry();
+ if (!rSettings.sListContentTable.Len() && (::svt::WizardTypes::eTravelBackward != _eReason))
+ // need to select a table
+ return sal_False;
+
+ return sal_True;
+ }
+
+ //=====================================================================
+ //= OContentFieldSelection
+ //=====================================================================
+ //---------------------------------------------------------------------
+ OContentFieldSelection::OContentFieldSelection( OListComboWizard* _pParent )
+ :OLCPage(_pParent, ModuleRes(RID_PAGE_LCW_CONTENTSELECTION_FIELD))
+ ,m_aFrame (this, ModuleRes(FL_FRAME))
+ ,m_aTableFields (this, ModuleRes(FT_TABLEFIELDS))
+ ,m_aSelectTableField (this, ModuleRes(LB_SELECTFIELD))
+ ,m_aDisplayedFieldLabel (this, ModuleRes(FT_DISPLAYEDFIELD))
+ ,m_aDisplayedField (this, ModuleRes(ET_DISPLAYEDFIELD))
+ ,m_aInfo (this, ModuleRes(FT_CONTENTFIELD_INFO))
+ {
+ m_aInfo.SetText(String(ModuleRes( isListBox() ? STR_FIELDINFO_LISTBOX : STR_FIELDINFO_COMBOBOX)));
+ FreeResource();
+ m_aSelectTableField.SetSelectHdl(LINK(this, OContentFieldSelection, OnFieldSelected));
+ m_aSelectTableField.SetDoubleClickHdl(LINK(this, OContentFieldSelection, OnTableDoubleClicked));
+ }
+
+ //---------------------------------------------------------------------
+ void OContentFieldSelection::ActivatePage()
+ {
+ OLCPage::ActivatePage();
+ m_aTableFields.GrabFocus();
+ }
+
+ //---------------------------------------------------------------------
+ void OContentFieldSelection::initializePage()
+ {
+ OLCPage::initializePage();
+
+ // fill the list of fields
+ fillListBox(m_aSelectTableField, getTableFields(sal_True));
+
+ m_aSelectTableField.SelectEntry(getSettings().sListContentField);
+ m_aDisplayedField.SetText(getSettings().sListContentField);
+ }
+
+ //---------------------------------------------------------------------
+ bool OContentFieldSelection::canAdvance() const
+ {
+ if (!OLCPage::canAdvance())
+ return false;
+
+ return 0 != m_aSelectTableField.GetSelectEntryCount();
+ }
+
+ //---------------------------------------------------------------------
+ IMPL_LINK( OContentFieldSelection, OnTableDoubleClicked, ListBox*, /*NOTINTERESTEDIN*/ )
+ {
+ if (m_aSelectTableField.GetSelectEntryCount())
+ getDialog()->travelNext();
+ return 0L;
+ }
+
+ //---------------------------------------------------------------------
+ IMPL_LINK( OContentFieldSelection, OnFieldSelected, ListBox*, /*NOTINTERESTEDIN*/ )
+ {
+ updateDialogTravelUI();
+ m_aDisplayedField.SetText(m_aSelectTableField.GetSelectEntry());
+ return 0L;
+ }
+
+ //---------------------------------------------------------------------
+ sal_Bool OContentFieldSelection::commitPage( ::svt::WizardTypes::CommitPageReason _eReason )
+ {
+ if (!OLCPage::commitPage(_eReason))
+ return sal_False;
+
+ getSettings().sListContentField = m_aSelectTableField.GetSelectEntry();
+
+ return sal_True;
+ }
+
+ //=====================================================================
+ //= OLinkFieldsPage
+ //=====================================================================
+ //---------------------------------------------------------------------
+ OLinkFieldsPage::OLinkFieldsPage( OListComboWizard* _pParent )
+ :OLCPage(_pParent, ModuleRes(RID_PAGE_LCW_FIELDLINK))
+ ,m_aDescription (this, ModuleRes(FT_FIELDLINK_DESC))
+ ,m_aFrame (this, ModuleRes(FL_FRAME))
+ ,m_aValueListFieldLabel (this, ModuleRes(FT_VALUELISTFIELD))
+ ,m_aValueListField (this, ModuleRes(CMB_VALUELISTFIELD))
+ ,m_aTableFieldLabel (this, ModuleRes(FT_TABLEFIELD))
+ ,m_aTableField (this, ModuleRes(CMB_TABLEFIELD))
+ {
+ FreeResource();
+
+ m_aValueListField.SetModifyHdl(LINK(this, OLinkFieldsPage, OnSelectionModified));
+ m_aTableField.SetModifyHdl(LINK(this, OLinkFieldsPage, OnSelectionModified));
+ m_aValueListField.SetSelectHdl(LINK(this, OLinkFieldsPage, OnSelectionModified));
+ m_aTableField.SetSelectHdl(LINK(this, OLinkFieldsPage, OnSelectionModified));
+ }
+
+ //---------------------------------------------------------------------
+ void OLinkFieldsPage::ActivatePage()
+ {
+ OLCPage::ActivatePage();
+ m_aValueListField.GrabFocus();
+ }
+
+ //---------------------------------------------------------------------
+ void OLinkFieldsPage::initializePage()
+ {
+ OLCPage::initializePage();
+
+ // fill the value list
+ fillListBox(m_aValueListField, getContext().aFieldNames);
+ // fill the table field list
+ fillListBox(m_aTableField, getTableFields(sal_True));
+
+ // the initial selections
+ m_aValueListField.SetText(getSettings().sLinkedFormField);
+ m_aTableField.SetText(getSettings().sLinkedListField);
+
+ implCheckFinish();
+ }
+
+ //---------------------------------------------------------------------
+ bool OLinkFieldsPage::canAdvance() const
+ {
+ // we're on the last page here, no travelNext allowed ...
+ return false;
+ }
+
+ //---------------------------------------------------------------------
+ void OLinkFieldsPage::implCheckFinish()
+ {
+ sal_Bool bInvalidSelection = (COMBOBOX_ENTRY_NOTFOUND == m_aValueListField.GetEntryPos(m_aValueListField.GetText()));
+ bInvalidSelection |= (COMBOBOX_ENTRY_NOTFOUND == m_aTableField.GetEntryPos(m_aTableField.GetText()));
+ getDialog()->enableButtons(WZB_FINISH, !bInvalidSelection);
+ }
+
+ //---------------------------------------------------------------------
+ IMPL_LINK(OLinkFieldsPage, OnSelectionModified, void*, EMPTYARG)
+ {
+ implCheckFinish();
+ return 0L;
+ }
+
+ //---------------------------------------------------------------------
+ sal_Bool OLinkFieldsPage::commitPage( ::svt::WizardTypes::CommitPageReason _eReason )
+ {
+ if (!OLCPage::commitPage(_eReason))
+ return sal_False;
+
+ getSettings().sLinkedFormField = m_aValueListField.GetText();
+ getSettings().sLinkedListField = m_aTableField.GetText();
+
+ return sal_True;
+ }
+
+ //=====================================================================
+ //= OComboDBFieldPage
+ //=====================================================================
+ //---------------------------------------------------------------------
+ OComboDBFieldPage::OComboDBFieldPage( OControlWizard* _pParent )
+ :ODBFieldPage(_pParent)
+ {
+ setDescriptionText(String(ModuleRes(RID_STR_COMBOWIZ_DBFIELD)));
+ }
+
+ //---------------------------------------------------------------------
+ String& OComboDBFieldPage::getDBFieldSetting()
+ {
+ return getSettings().sLinkedFormField;
+ }
+
+ //---------------------------------------------------------------------
+ void OComboDBFieldPage::ActivatePage()
+ {
+ ODBFieldPage::ActivatePage();
+ getDialog()->enableButtons(WZB_FINISH, sal_True);
+ }
+
+ //---------------------------------------------------------------------
+ bool OComboDBFieldPage::canAdvance() const
+ {
+ // we're on the last page here, no travelNext allowed ...
+ return false;
+ }
+
+//.........................................................................
+} // namespace dbp
+//.........................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/dbpilots/listcombowizard.hxx b/extensions/source/dbpilots/listcombowizard.hxx
new file mode 100644
index 000000000000..2f0ff8f85be1
--- /dev/null
+++ b/extensions/source/dbpilots/listcombowizard.hxx
@@ -0,0 +1,229 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _EXTENSIONS_DBP_LISTCOMBOWIZARD_HXX_
+#define _EXTENSIONS_DBP_LISTCOMBOWIZARD_HXX_
+
+#include "controlwizard.hxx"
+#include "commonpagesdbp.hxx"
+
+//.........................................................................
+namespace dbp
+{
+//.........................................................................
+
+#define LCW_STATE_DATASOURCE_SELECTION 0
+#define LCW_STATE_TABLESELECTION 1
+#define LCW_STATE_FIELDSELECTION 2
+#define LCW_STATE_FIELDLINK 3
+#define LCW_STATE_COMBODBFIELD 4
+
+ //=====================================================================
+ //= OListComboSettings
+ //=====================================================================
+ struct OListComboSettings : public OControlWizardSettings
+ {
+ String sListContentTable;
+ String sListContentField;
+ String sLinkedFormField;
+ String sLinkedListField;
+ };
+
+ //=====================================================================
+ //= OListComboWizard
+ //=====================================================================
+ class OListComboWizard : public OControlWizard
+ {
+ protected:
+ OListComboSettings m_aSettings;
+ sal_Bool m_bListBox : 1;
+ sal_Bool m_bHadDataSelection : 1;
+
+ public:
+ OListComboWizard(
+ Window* _pParent,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxObjectModel,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB
+ );
+
+ OListComboSettings& getSettings() { return m_aSettings; }
+
+ sal_Bool isListBox() const { return m_bListBox; }
+
+ protected:
+ // OWizardMachine overridables
+ virtual ::svt::OWizardPage* createPage( WizardState _nState );
+ virtual WizardState determineNextState( WizardState _nCurrentState ) const;
+ virtual void enterState( WizardState _nState );
+ virtual sal_Bool leaveState( WizardState _nState );
+ virtual sal_Bool onFinish();
+
+ virtual sal_Bool approveControl(sal_Int16 _nClassId);
+
+ WizardState getFinalState() const { return isListBox() ? LCW_STATE_FIELDLINK : LCW_STATE_COMBODBFIELD; }
+
+ private:
+ void implApplySettings();
+ };
+
+ //=====================================================================
+ //= OLCPage
+ //=====================================================================
+ class OLCPage : public OControlWizardPage
+ {
+ public:
+ OLCPage( OListComboWizard* _pParent, const ResId& _rId ) : OControlWizardPage(_pParent, _rId) { }
+
+ protected:
+ OListComboSettings& getSettings() { return static_cast<OListComboWizard*>(getDialog())->getSettings(); }
+ sal_Bool isListBox() { return static_cast<OListComboWizard*>(getDialog())->isListBox(); }
+
+ protected:
+ ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >
+ getTables(sal_Bool _bNeedIt);
+ ::com::sun::star::uno::Sequence< ::rtl::OUString >
+ getTableFields(sal_Bool _bNeedIt);
+ };
+
+ //=====================================================================
+ //= OContentTableSelection
+ //=====================================================================
+ class OContentTableSelection : public OLCPage
+ {
+ protected:
+ FixedLine m_aFrame;
+ FixedText m_aSelectTableLabel;
+ ListBox m_aSelectTable;
+
+ public:
+ OContentTableSelection( OListComboWizard* _pParent );
+
+ protected:
+ // TabPage overridables
+ virtual void ActivatePage();
+
+ // OWizardPage overridables
+ virtual void initializePage();
+ virtual sal_Bool commitPage( ::svt::WizardTypes::CommitPageReason _eReason );
+ virtual bool canAdvance() const;
+
+ protected:
+ DECL_LINK( OnTableDoubleClicked, ListBox* );
+ DECL_LINK( OnTableSelected, ListBox* );
+ };
+
+ //=====================================================================
+ //= OContentFieldSelection
+ //=====================================================================
+ class OContentFieldSelection : public OLCPage
+ {
+ protected:
+ FixedLine m_aFrame;
+ FixedText m_aTableFields;
+ ListBox m_aSelectTableField;
+ FixedText m_aDisplayedFieldLabel;
+ Edit m_aDisplayedField;
+ FixedText m_aInfo;
+
+
+ public:
+ OContentFieldSelection( OListComboWizard* _pParent );
+
+ protected:
+ DECL_LINK( OnFieldSelected, ListBox* );
+ DECL_LINK( OnTableDoubleClicked, ListBox* );
+
+ // TabPage overridables
+ virtual void ActivatePage();
+
+ // OWizardPage overridables
+ virtual void initializePage();
+ virtual sal_Bool commitPage( ::svt::WizardTypes::CommitPageReason _eReason );
+ virtual bool canAdvance() const;
+ };
+
+ //=====================================================================
+ //= OLinkFieldsPage
+ //=====================================================================
+ class OLinkFieldsPage : public OLCPage
+ {
+ protected:
+ FixedText m_aDescription;
+ FixedLine m_aFrame;
+ FixedText m_aValueListFieldLabel;
+ ComboBox m_aValueListField;
+ FixedText m_aTableFieldLabel;
+ ComboBox m_aTableField;
+
+
+ public:
+ OLinkFieldsPage( OListComboWizard* _pParent );
+
+ protected:
+ // TabPage overridables
+ virtual void ActivatePage();
+
+ // OWizardPage overridables
+ virtual void initializePage();
+ virtual sal_Bool commitPage( ::svt::WizardTypes::CommitPageReason _eReason );
+ virtual bool canAdvance() const;
+
+ private:
+ void implCheckFinish();
+
+ DECL_LINK(OnSelectionModified, void*);
+ };
+
+ //=====================================================================
+ //= OComboDBFieldPage
+ //=====================================================================
+ class OComboDBFieldPage : public ODBFieldPage
+ {
+ public:
+ OComboDBFieldPage( OControlWizard* _pParent );
+
+ protected:
+ OListComboSettings& getSettings() { return static_cast<OListComboWizard*>(getDialog())->getSettings(); }
+
+ // TabPage overridables
+ virtual void ActivatePage();
+
+ // OWizardPage overridables
+ virtual bool canAdvance() const;
+
+ // ODBFieldPage overridables
+ virtual String& getDBFieldSetting();
+ };
+
+//.........................................................................
+} // namespace dbp
+//.........................................................................
+
+#endif // _EXTENSIONS_DBP_LISTCOMBOWIZARD_HXX_
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/dbpilots/makefile.mk b/extensions/source/dbpilots/makefile.mk
new file mode 100644
index 000000000000..b5831e5fda0f
--- /dev/null
+++ b/extensions/source/dbpilots/makefile.mk
@@ -0,0 +1,103 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+PRJ=..$/..
+PRJINC=..$/inc
+
+PRJNAME=extensions
+TARGET=dbp
+ENABLE_EXCEPTIONS=TRUE
+VISIBILITY_HIDDEN=TRUE
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : $(PRJ)$/util$/makefile.pmk
+
+# --- defines ------------------------------------------------------
+
+CDEFS+=-DCOMPMOD_NAMESPACE=dbp
+
+# --- Files --------------------------------------------------------
+
+CXXFILES= dbptools.cxx \
+ gridwizard.cxx \
+ listcombowizard.cxx \
+ optiongrouplayouter.cxx \
+ commonpagesdbp.cxx \
+ groupboxwiz.cxx \
+ wizardservices.cxx \
+ controlwizard.cxx \
+ moduledbp.cxx \
+ dbpservices.cxx
+
+SLOFILES= $(SLO)$/dbptools.obj \
+ $(SLO)$/gridwizard.obj \
+ $(SLO)$/listcombowizard.obj \
+ $(SLO)$/optiongrouplayouter.obj \
+ $(SLO)$/commonpagesdbp.obj \
+ $(SLO)$/groupboxwiz.obj \
+ $(SLO)$/wizardservices.obj \
+ $(SLO)$/controlwizard.obj \
+ $(SLO)$/moduledbp.obj \
+ $(SLO)$/dbpservices.obj
+
+
+SRS1NAME=$(TARGET)
+SRC1FILES= gridpages.src \
+ commonpagesdbp.src \
+ dbpilots.src \
+ groupboxpages.src \
+ listcombopages.src
+
+RESLIB1NAME=dbp
+RESLIB1SRSFILES= $(SRS)$/dbp.srs
+
+SHL1TARGET= $(TARGET)$(DLLPOSTFIX)
+SHL1VERSIONMAP=$(SOLARENV)/src/component.map
+
+SHL1STDLIBS= \
+ $(SVTOOLLIB) \
+ $(VCLLIB) \
+ $(TOOLSLIB) \
+ $(SVLLIB) \
+ $(SFXLIB) \
+ $(DBTOOLSLIB) \
+ $(UNOTOOLSLIB) \
+ $(COMPHELPERLIB) \
+ $(CPPUHELPERLIB) \
+ $(CPPULIB) \
+ $(SALLIB)
+
+SHL1LIBS= $(SLB)$/$(TARGET).lib
+SHL1IMPLIB= i$(TARGET)
+SHL1DEPN= $(SHL1LIBS)
+SHL1DEF= $(MISC)$/$(SHL1TARGET).def
+
+DEF1NAME= $(SHL1TARGET)
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : target.mk
diff --git a/extensions/source/dbpilots/moduledbp.cxx b/extensions/source/dbpilots/moduledbp.cxx
new file mode 100644
index 000000000000..ead9753193f4
--- /dev/null
+++ b/extensions/source/dbpilots/moduledbp.cxx
@@ -0,0 +1,34 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+
+#include "componentmodule.cxx"
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/dbpilots/optiongrouplayouter.cxx b/extensions/source/dbpilots/optiongrouplayouter.cxx
new file mode 100644
index 000000000000..7bc1f84cf91d
--- /dev/null
+++ b/extensions/source/dbpilots/optiongrouplayouter.cxx
@@ -0,0 +1,218 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+#include "optiongrouplayouter.hxx"
+#include <tools/debug.hxx>
+#include <tools/string.hxx>
+#include <com/sun/star/awt/Size.hpp>
+#include <com/sun/star/awt/Point.hpp>
+#include <com/sun/star/container/XIndexAccess.hpp>
+#include <com/sun/star/container/XNameAccess.hpp>
+#include <com/sun/star/drawing/XShapes.hpp>
+#include <com/sun/star/drawing/XShapeGrouper.hpp>
+#include <com/sun/star/text/TextContentAnchorType.hpp>
+#include <com/sun/star/view/XSelectionSupplier.hpp>
+#include "controlwizard.hxx"
+#include "groupboxwiz.hxx"
+#include "dbptools.hxx"
+
+//.........................................................................
+namespace dbp
+{
+//.........................................................................
+
+#define BUTTON_HEIGHT 300
+#define TOP_HEIGHT 300
+#define HEIGHT 450
+#define OFFSET 300
+#define MIN_WIDTH 600
+
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::drawing;
+ using namespace ::com::sun::star::beans;
+ using namespace ::com::sun::star::awt;
+ using namespace ::com::sun::star::container;
+ using namespace ::com::sun::star::lang;
+ using namespace ::com::sun::star::text;
+ using namespace ::com::sun::star::view;
+
+ //=====================================================================
+ //= OOptionGroupLayouter
+ //=====================================================================
+ //---------------------------------------------------------------------
+ OOptionGroupLayouter::OOptionGroupLayouter(const Reference< XMultiServiceFactory >& _rxORB)
+ :m_xORB(_rxORB)
+ {
+ }
+
+ //---------------------------------------------------------------------
+ void OOptionGroupLayouter::doLayout(const OControlWizardContext& _rContext, const OOptionGroupSettings& _rSettings)
+ {
+ Reference< XShapes > xPageShapes(_rContext.xDrawPage, UNO_QUERY);
+ if (!xPageShapes.is())
+ {
+ DBG_ERROR("OOptionGroupLayouter::OOptionGroupLayouter: missing the XShapes interface for the page!");
+ return;
+ }
+
+ Reference< XMultiServiceFactory > xDocFactory(_rContext.xDocumentModel, UNO_QUERY);
+ if (!xDocFactory.is())
+ {
+ DBG_ERROR("OOptionGroupLayouter::OOptionGroupLayouter: no document service factory!");
+ return;
+ }
+
+ // no. of buttons to create
+ sal_Int32 nRadioButtons = _rSettings.aLabels.size();
+
+ sal_Int32 nTopSpace = 0;
+
+ // the shape of the groupbox
+ ::com::sun::star::awt::Size aControlShapeSize = _rContext.xObjectShape->getSize();
+ // maybe need to adjust the size if the control shapes
+ sal_Int32 nMinShapeHeight = BUTTON_HEIGHT*(nRadioButtons+1) + BUTTON_HEIGHT + BUTTON_HEIGHT/4;
+ if (aControlShapeSize.Height < nMinShapeHeight)
+ aControlShapeSize.Height = nMinShapeHeight;
+ if (aControlShapeSize.Width < MIN_WIDTH)
+ aControlShapeSize.Width = MIN_WIDTH;
+ _rContext.xObjectShape->setSize(aControlShapeSize);
+
+ // if we're working on a writer document, we need to anchor the shape
+ implAnchorShape(Reference< XPropertySet >(_rContext.xObjectShape, UNO_QUERY));
+
+ // shape collection (for grouping the shapes)
+ Reference< XShapes > xButtonCollection(m_xORB->createInstance(
+ ::rtl::OUString::createFromAscii("com.sun.star.drawing.ShapeCollection")),
+ UNO_QUERY);
+ // first member : the shape of the control
+ xButtonCollection->add(_rContext.xObjectShape.get());
+
+ sal_Int32 nTempHeight = (aControlShapeSize.Height - BUTTON_HEIGHT/4) / (nRadioButtons + 1);
+
+ ::com::sun::star::awt::Point aShapePosition = _rContext.xObjectShape->getPosition();
+
+ ::com::sun::star::awt::Size aButtonSize(aControlShapeSize);
+ aButtonSize.Width = aControlShapeSize.Width - OFFSET;
+ aButtonSize.Height = HEIGHT;
+ ::com::sun::star::awt::Point aButtonPosition;
+ aButtonPosition.X = aShapePosition.X + OFFSET;
+
+ ::rtl::OUString sElementsName = ::rtl::OUString::createFromAscii("RadioGroup");
+ disambiguateName(Reference< XNameAccess >(_rContext.xForm, UNO_QUERY), sElementsName);
+
+ StringArray::const_iterator aLabelIter = _rSettings.aLabels.begin();
+ StringArray::const_iterator aValueIter = _rSettings.aValues.begin();
+ for (sal_Int32 i=0; i<nRadioButtons; ++i, ++aLabelIter, ++aValueIter)
+ {
+ aButtonPosition.Y = aShapePosition.Y + (i+1) * nTempHeight + nTopSpace;
+
+ Reference< XPropertySet > xRadioModel(
+ xDocFactory->createInstance(::rtl::OUString::createFromAscii("com.sun.star.form.component.RadioButton")),
+ UNO_QUERY);
+
+ // the label
+ xRadioModel->setPropertyValue(::rtl::OUString::createFromAscii("Label"), makeAny(rtl::OUString(*aLabelIter)));
+ // the value
+ xRadioModel->setPropertyValue(::rtl::OUString::createFromAscii("RefValue"), makeAny(rtl::OUString(*aValueIter)));
+
+ // default selection
+ if (_rSettings.sDefaultField == *aLabelIter)
+ xRadioModel->setPropertyValue(::rtl::OUString::createFromAscii("DefaultState"), makeAny(sal_Int16(1)));
+
+ // the connection to the database field
+ if (0 != _rSettings.sDBField.Len())
+ xRadioModel->setPropertyValue(::rtl::OUString::createFromAscii("DataField"), makeAny(::rtl::OUString(_rSettings.sDBField)));
+
+ // the name for the model
+ xRadioModel->setPropertyValue(::rtl::OUString::createFromAscii("Name"), makeAny(sElementsName));
+
+ // create a shape for the radio button
+ Reference< XControlShape > xRadioShape(
+ xDocFactory->createInstance(::rtl::OUString::createFromAscii("com.sun.star.drawing.ControlShape")),
+ UNO_QUERY);
+ Reference< XPropertySet > xShapeProperties(xRadioShape, UNO_QUERY);
+
+ // if we're working on a writer document, we need to anchor the shape
+ implAnchorShape(xShapeProperties);
+
+ // position it
+ xRadioShape->setSize(aButtonSize);
+ xRadioShape->setPosition(aButtonPosition);
+ // knitting with the model
+ xRadioShape->setControl(Reference< XControlModel >(xRadioModel, UNO_QUERY));
+
+ // the name of the shape
+ if (xShapeProperties.is())
+ xShapeProperties->setPropertyValue(::rtl::OUString::createFromAscii("Name"), makeAny(sElementsName));
+
+ // add to the page
+ xPageShapes->add(xRadioShape.get());
+ // add to the collection (for the later grouping)
+ xButtonCollection->add(xRadioShape.get());
+
+ // set the GroupBox as "LabelControl" for the RadioButton
+ // (_after_ having inserted the model into the page!)
+ xRadioModel->setPropertyValue(::rtl::OUString::createFromAscii("LabelControl"), makeAny(_rContext.xObjectModel));
+ }
+
+ // group the shapes
+ try
+ {
+ Reference< XShapeGrouper > xGrouper(_rContext.xDrawPage, UNO_QUERY);
+ if (xGrouper.is())
+ {
+ Reference< XShapeGroup > xGroupedOptions = xGrouper->group(xButtonCollection);
+ Reference< XSelectionSupplier > xSelector(_rContext.xDocumentModel->getCurrentController(), UNO_QUERY);
+ if (xSelector.is())
+ xSelector->select(makeAny(xGroupedOptions));
+ }
+ }
+ catch(Exception&)
+ {
+ DBG_ERROR("OOptionGroupLayouter::doLayout: caught an exception while grouping the shapes!");
+ }
+ }
+
+ //---------------------------------------------------------------------
+ void OOptionGroupLayouter::implAnchorShape(const Reference< XPropertySet >& _rxShapeProps)
+ {
+ static const ::rtl::OUString s_sAnchorPropertyName = ::rtl::OUString::createFromAscii("AnchorType");
+ Reference< XPropertySetInfo > xPropertyInfo;
+ if (_rxShapeProps.is())
+ xPropertyInfo = _rxShapeProps->getPropertySetInfo();
+ if (xPropertyInfo.is() && xPropertyInfo->hasPropertyByName(s_sAnchorPropertyName))
+ _rxShapeProps->setPropertyValue(s_sAnchorPropertyName, makeAny(TextContentAnchorType_AT_PAGE));
+ }
+
+//.........................................................................
+} // namespace dbp
+//.........................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/dbpilots/optiongrouplayouter.hxx b/extensions/source/dbpilots/optiongrouplayouter.hxx
new file mode 100644
index 000000000000..52b6e7bfc315
--- /dev/null
+++ b/extensions/source/dbpilots/optiongrouplayouter.hxx
@@ -0,0 +1,77 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _EXTENSIONS_DBP_OPTIONGROUPLAYOUTER_HXX_
+#define _EXTENSIONS_DBP_OPTIONGROUPLAYOUTER_HXX_
+
+#include <com/sun/star/drawing/XDrawPage.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/drawing/XControlShape.hpp>
+#include <com/sun/star/frame/XModel.hpp>
+#include "dbptypes.hxx"
+
+//.........................................................................
+namespace dbp
+{
+//.........................................................................
+
+ struct OControlWizardContext;
+ struct OOptionGroupSettings;
+ //=====================================================================
+ //= OOptionGroupLayouter
+ //=====================================================================
+ class OOptionGroupLayouter
+ {
+ ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >
+ m_xORB;
+
+ public:
+ OOptionGroupLayouter(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB
+ );
+
+ public:
+ void doLayout(
+ const OControlWizardContext& _rContext,
+ const OOptionGroupSettings& _rSettings
+ );
+
+ protected:
+ void implAnchorShape(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxShapeProps
+ );
+ };
+
+//.........................................................................
+} // namespace dbp
+//.........................................................................
+
+#endif // _EXTENSIONS_DBP_OPTIONGROUPLAYOUTER_HXX_
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/dbpilots/unoautopilot.hxx b/extensions/source/dbpilots/unoautopilot.hxx
new file mode 100644
index 000000000000..bfa4e0cfed6d
--- /dev/null
+++ b/extensions/source/dbpilots/unoautopilot.hxx
@@ -0,0 +1,108 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _EXTENSIONS_DBP_UNOAUTOPILOT_HXX_
+#define _EXTENSIONS_DBP_UNOAUTOPILOT_HXX_
+
+#include <svtools/genericunodialog.hxx>
+#include <comphelper/proparrhlp.hxx>
+#include "componentmodule.hxx"
+#include <cppuhelper/typeprovider.hxx>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/beans/PropertyValue.hpp>
+
+//.........................................................................
+namespace dbp
+{
+//.........................................................................
+
+ //=====================================================================
+ //= IServiceInfo
+ //=====================================================================
+ /** interface for the SERVICEINFO template parameter of the OUnoAutoPilot class
+ */
+ struct IServiceInfo
+ {
+ public:
+ ::rtl::OUString getImplementationName() const;
+ ::com::sun::star::uno::Sequence< ::rtl::OUString >
+ getServiceNames() const;
+ };
+
+ //=====================================================================
+ //= OUnoAutoPilot
+ //=====================================================================
+ typedef ::svt::OGenericUnoDialog OUnoAutoPilot_Base;
+ template <class TYPE, class SERVICEINFO>
+ class OUnoAutoPilot
+ :public OUnoAutoPilot_Base
+ ,public ::comphelper::OPropertyArrayUsageHelper< OUnoAutoPilot< TYPE, SERVICEINFO > >
+ ,public OModuleResourceClient
+ {
+ OUnoAutoPilot(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB);
+
+ protected:
+ ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >
+ m_xObjectModel;
+
+ public:
+ // XTypeProvider
+ virtual ::com::sun::star::uno::Sequence<sal_Int8> SAL_CALL getImplementationId( ) throw(::com::sun::star::uno::RuntimeException);
+
+ // XServiceInfo
+ virtual ::rtl::OUString SAL_CALL getImplementationName() throw(::com::sun::star::uno::RuntimeException);
+ virtual ::comphelper::StringSequence SAL_CALL getSupportedServiceNames() throw(::com::sun::star::uno::RuntimeException);
+
+ // XServiceInfo - static methods
+ static ::com::sun::star::uno::Sequence< ::rtl::OUString > getSupportedServiceNames_Static(void) throw( ::com::sun::star::uno::RuntimeException );
+ static ::rtl::OUString getImplementationName_Static(void) throw( ::com::sun::star::uno::RuntimeException );
+ static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >
+ SAL_CALL Create(const ::com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory >&);
+
+ // XPropertySet
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo> SAL_CALL getPropertySetInfo() throw(::com::sun::star::uno::RuntimeException);
+ virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper();
+
+ // OPropertyArrayUsageHelper
+ virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const;
+
+ protected:
+ // OGenericUnoDialog overridables
+ virtual Dialog* createDialog(Window* _pParent);
+ virtual void implInitialize(const com::sun::star::uno::Any& _rValue);
+ };
+
+#include "unoautopilot.inl"
+
+//.........................................................................
+} // namespace dbp
+//.........................................................................
+
+#endif // _EXTENSIONS_DBP_UNOAUTOPILOT_HXX_
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/dbpilots/unoautopilot.inl b/extensions/source/dbpilots/unoautopilot.inl
new file mode 100644
index 000000000000..cc1fa0eba310
--- /dev/null
+++ b/extensions/source/dbpilots/unoautopilot.inl
@@ -0,0 +1,134 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// no include protecttion
+// this file is included from unoautopilot.hxx directly
+
+//using namespace ::com::sun::star::uno;
+//using namespace ::com::sun::star::lang;
+//using namespace ::com::sun::star::beans;
+//
+//=====================================================================
+//= OUnoAutoPilot
+//=====================================================================
+//---------------------------------------------------------------------
+template <class TYPE, class SERVICEINFO>
+OUnoAutoPilot<TYPE, SERVICEINFO>::OUnoAutoPilot(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB)
+ :OUnoAutoPilot_Base(_rxORB)
+{
+}
+
+//---------------------------------------------------------------------
+template <class TYPE, class SERVICEINFO>
+::com::sun::star::uno::Sequence<sal_Int8> SAL_CALL OUnoAutoPilot<TYPE, SERVICEINFO>::getImplementationId( ) throw(::com::sun::star::uno::RuntimeException)
+{
+ static ::cppu::OImplementationId aId;
+ return aId.getImplementationId();
+}
+
+//---------------------------------------------------------------------
+template <class TYPE, class SERVICEINFO>
+::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL OUnoAutoPilot<TYPE, SERVICEINFO>::Create(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory)
+{
+ return *(new OUnoAutoPilot<TYPE, SERVICEINFO>(_rxFactory));
+}
+
+//---------------------------------------------------------------------
+template <class TYPE, class SERVICEINFO>
+::rtl::OUString SAL_CALL OUnoAutoPilot<TYPE, SERVICEINFO>::getImplementationName() throw(::com::sun::star::uno::RuntimeException)
+{
+ return getImplementationName_Static();
+}
+
+//---------------------------------------------------------------------
+template <class TYPE, class SERVICEINFO>
+::rtl::OUString OUnoAutoPilot<TYPE, SERVICEINFO>::getImplementationName_Static() throw(::com::sun::star::uno::RuntimeException)
+{
+ return SERVICEINFO().getImplementationName();
+}
+
+//---------------------------------------------------------------------
+template <class TYPE, class SERVICEINFO>
+::comphelper::StringSequence SAL_CALL OUnoAutoPilot<TYPE, SERVICEINFO>::getSupportedServiceNames() throw(::com::sun::star::uno::RuntimeException)
+{
+ return getSupportedServiceNames_Static();
+}
+
+//---------------------------------------------------------------------
+template <class TYPE, class SERVICEINFO>
+::comphelper::StringSequence OUnoAutoPilot<TYPE, SERVICEINFO>::getSupportedServiceNames_Static() throw(::com::sun::star::uno::RuntimeException)
+{
+ return SERVICEINFO().getServiceNames();
+}
+
+//---------------------------------------------------------------------
+template <class TYPE, class SERVICEINFO>
+::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL OUnoAutoPilot<TYPE, SERVICEINFO>::getPropertySetInfo() throw(::com::sun::star::uno::RuntimeException)
+{
+ ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) );
+ return xInfo;
+}
+
+//---------------------------------------------------------------------
+template <class TYPE, class SERVICEINFO>
+::cppu::IPropertyArrayHelper& OUnoAutoPilot<TYPE, SERVICEINFO>::getInfoHelper()
+{
+ return *const_cast<OUnoAutoPilot*>(this)->getArrayHelper();
+}
+
+//--------------------------------------------------------------------------
+template <class TYPE, class SERVICEINFO>
+::cppu::IPropertyArrayHelper* OUnoAutoPilot<TYPE, SERVICEINFO>::createArrayHelper( ) const
+{
+ ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property > aProps;
+ describeProperties(aProps);
+ return new ::cppu::OPropertyArrayHelper(aProps);
+}
+
+//--------------------------------------------------------------------------
+template <class TYPE, class SERVICEINFO>
+Dialog* OUnoAutoPilot<TYPE, SERVICEINFO>::createDialog(Window* _pParent)
+{
+ return new TYPE(_pParent, m_xObjectModel, m_aContext.getLegacyServiceFactory());
+}
+
+//--------------------------------------------------------------------------
+template <class TYPE, class SERVICEINFO>
+void OUnoAutoPilot<TYPE, SERVICEINFO>::implInitialize(const com::sun::star::uno::Any& _rValue)
+{
+ ::com::sun::star::beans::PropertyValue aArgument;
+ if (_rValue >>= aArgument)
+ if (0 == aArgument.Name.compareToAscii("ObjectModel"))
+ {
+ aArgument.Value >>= m_xObjectModel;
+ return;
+ }
+
+ OUnoAutoPilot_Base::implInitialize(_rValue);
+}
+
+
diff --git a/extensions/source/dbpilots/wizardcontext.hxx b/extensions/source/dbpilots/wizardcontext.hxx
new file mode 100644
index 000000000000..93cc936bdd73
--- /dev/null
+++ b/extensions/source/dbpilots/wizardcontext.hxx
@@ -0,0 +1,94 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _EXTENSIONS_DBP_WIZARDCONTEXT_HXX_
+#define _EXTENSIONS_DBP_WIZARDCONTEXT_HXX_
+
+#include <com/sun/star/container/XNameAccess.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/sdbc/XRowSet.hpp>
+#include <com/sun/star/uno/Sequence.hxx>
+#include <com/sun/star/drawing/XDrawPage.hpp>
+#include <com/sun/star/drawing/XControlShape.hpp>
+#include <com/sun/star/frame/XModel.hpp>
+#include <comphelper/stl_types.hxx>
+
+//.........................................................................
+namespace dbp
+{
+//.........................................................................
+
+ //=====================================================================
+ //= OControlWizardContext
+ //=====================================================================
+ struct OControlWizardContext
+ {
+ // the global data source context
+ ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >
+ xDatasourceContext;
+
+ // the control mode
+ ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >
+ xObjectModel;
+ // the form the control model belongs to
+ ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >
+ xForm;
+ // the form as rowset
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRowSet >
+ xRowSet;
+
+ // the model of the document
+ ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >
+ xDocumentModel;
+ // the page where the control mode resides
+ ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawPage >
+ xDrawPage;
+ // the shape which carries the control
+ ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XControlShape >
+ xObjectShape;
+
+ // the tables or queries of the data source the form is bound to (if any)
+ ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >
+ xObjectContainer;
+ // the column types container of the object the form is bound to (table, query or SQL statement)
+ DECLARE_STL_USTRINGACCESS_MAP(sal_Int32,TNameTypeMap);
+ TNameTypeMap aTypes;
+ // the column names of the object the form is bound to (table, query or SQL statement)
+ ::com::sun::star::uno::Sequence< ::rtl::OUString >
+ aFieldNames;
+
+ sal_Bool bEmbedded;
+ };
+
+//.........................................................................
+} // namespace dbp
+//.........................................................................
+
+#endif // _EXTENSIONS_DBP_WIZARDCONTEXT_HXX_
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/dbpilots/wizardservices.cxx b/extensions/source/dbpilots/wizardservices.cxx
new file mode 100644
index 000000000000..b90e47478fc3
--- /dev/null
+++ b/extensions/source/dbpilots/wizardservices.cxx
@@ -0,0 +1,122 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+
+#include "wizardservices.hxx"
+#include "unoautopilot.hxx"
+#include "groupboxwiz.hxx"
+#include "listcombowizard.hxx"
+#include "gridwizard.hxx"
+
+// the registration methods
+extern "C" void SAL_CALL createRegistryInfo_OGroupBoxWizard()
+{
+ static ::dbp::OMultiInstanceAutoRegistration<
+ ::dbp::OUnoAutoPilot< ::dbp::OGroupBoxWizard, ::dbp::OGroupBoxSI >
+ > aAutoRegistration;
+}
+
+extern "C" void SAL_CALL createRegistryInfo_OListComboWizard()
+{
+ static ::dbp::OMultiInstanceAutoRegistration<
+ ::dbp::OUnoAutoPilot< ::dbp::OListComboWizard, ::dbp::OListComboSI >
+ > aAutoRegistration;
+}
+
+extern "C" void SAL_CALL createRegistryInfo_OGridWizard()
+{
+ static ::dbp::OMultiInstanceAutoRegistration<
+ ::dbp::OUnoAutoPilot< ::dbp::OGridWizard, ::dbp::OGridSI >
+ > aAutoRegistration;
+}
+
+//.........................................................................
+namespace dbp
+{
+//.........................................................................
+
+ using namespace ::com::sun::star::uno;
+
+ //=====================================================================
+ //= OGroupBoxSI
+ //=====================================================================
+ //---------------------------------------------------------------------
+ ::rtl::OUString OGroupBoxSI::getImplementationName() const
+ {
+ return ::rtl::OUString::createFromAscii("org.openoffice.comp.dbp.OGroupBoxWizard");
+ }
+
+ //---------------------------------------------------------------------
+ Sequence< ::rtl::OUString > OGroupBoxSI::getServiceNames() const
+ {
+ Sequence< ::rtl::OUString > aReturn(1);
+ aReturn[0] = ::rtl::OUString::createFromAscii("com.sun.star.sdb.GroupBoxAutoPilot");
+ return aReturn;
+ }
+
+ //=====================================================================
+ //= OListComboSI
+ //=====================================================================
+ //---------------------------------------------------------------------
+ ::rtl::OUString OListComboSI::getImplementationName() const
+ {
+ return ::rtl::OUString::createFromAscii("org.openoffice.comp.dbp.OListComboWizard");
+ }
+
+ //---------------------------------------------------------------------
+ Sequence< ::rtl::OUString > OListComboSI::getServiceNames() const
+ {
+ Sequence< ::rtl::OUString > aReturn(1);
+ aReturn[0] = ::rtl::OUString::createFromAscii("com.sun.star.sdb.ListComboBoxAutoPilot");
+ return aReturn;
+ }
+
+ //=====================================================================
+ //= OGridSI
+ //=====================================================================
+ //---------------------------------------------------------------------
+ ::rtl::OUString OGridSI::getImplementationName() const
+ {
+ return ::rtl::OUString::createFromAscii("org.openoffice.comp.dbp.OGridWizard");
+ }
+
+ //---------------------------------------------------------------------
+ Sequence< ::rtl::OUString > OGridSI::getServiceNames() const
+ {
+ Sequence< ::rtl::OUString > aReturn(1);
+ aReturn[0] = ::rtl::OUString::createFromAscii("com.sun.star.sdb.GridControlAutoPilot");
+ return aReturn;
+ }
+
+//.........................................................................
+} // namespace dbp
+//.........................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/dbpilots/wizardservices.hxx b/extensions/source/dbpilots/wizardservices.hxx
new file mode 100644
index 000000000000..48c57115b1c8
--- /dev/null
+++ b/extensions/source/dbpilots/wizardservices.hxx
@@ -0,0 +1,82 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _EXTENSIONS_DBW_WIZARDSERVICES_HXX_
+#define _EXTENSIONS_DBW_WIZARDSERVICES_HXX_
+
+#include <com/sun/star/uno/Sequence.hxx>
+#include <rtl/ustring.hxx>
+
+//.........................................................................
+namespace dbp
+{
+//.........................................................................
+
+ //=====================================================================
+ //= OGroupBoxSI
+ //=====================================================================
+ /// service info for the group box wizard
+ struct OGroupBoxSI
+ {
+ public:
+ ::rtl::OUString getImplementationName() const;
+ ::com::sun::star::uno::Sequence< ::rtl::OUString >
+ getServiceNames() const;
+ };
+
+ //=====================================================================
+ //= OListComboSI
+ //=====================================================================
+ /// service info for the list/combo box wizard
+ struct OListComboSI
+ {
+ public:
+ ::rtl::OUString getImplementationName() const;
+ ::com::sun::star::uno::Sequence< ::rtl::OUString >
+ getServiceNames() const;
+ };
+
+ //=====================================================================
+ //= OGridSI
+ //=====================================================================
+ /// service info for the grid wizard
+ struct OGridSI
+ {
+ public:
+ ::rtl::OUString getImplementationName() const;
+ ::com::sun::star::uno::Sequence< ::rtl::OUString >
+ getServiceNames() const;
+ };
+
+//.........................................................................
+} // namespace dbp
+//.........................................................................
+
+#endif // _EXTENSIONS_DBW_WIZARDSERVICES_HXX_
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/inc/componentmodule.cxx b/extensions/source/inc/componentmodule.cxx
new file mode 100644
index 000000000000..b5b80f89963a
--- /dev/null
+++ b/extensions/source/inc/componentmodule.cxx
@@ -0,0 +1,341 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "componentmodule.hxx"
+#include <tools/resmgr.hxx>
+#include <svl/solar.hrc>
+#include <comphelper/sequence.hxx>
+#include <tools/debug.hxx>
+
+#define ENTER_MOD_METHOD() \
+ ::osl::MutexGuard aGuard(s_aMutex); \
+ ensureImpl()
+
+//.........................................................................
+namespace COMPMOD_NAMESPACE
+{
+//.........................................................................
+
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::lang;
+ using namespace ::com::sun::star::registry;
+ using namespace ::comphelper;
+ using namespace ::cppu;
+
+ //=========================================================================
+ //= OModuleImpl
+ //=========================================================================
+ /** implementation for <type>OModule</type>. not threadsafe, has to be guarded by it's owner
+ */
+ class OModuleImpl
+ {
+ ResMgr* m_pRessources;
+ sal_Bool m_bInitialized;
+ ByteString m_sFilePrefix;
+
+ public:
+ /// ctor
+ OModuleImpl();
+ ~OModuleImpl();
+
+ /// get the manager for the ressources of the module
+ ResMgr* getResManager();
+ void setResourceFilePrefix(const ::rtl::OString& _rPrefix) { m_sFilePrefix = _rPrefix; }
+ };
+
+ //-------------------------------------------------------------------------
+ OModuleImpl::OModuleImpl()
+ :m_pRessources(NULL)
+ ,m_bInitialized(sal_False)
+ {
+ }
+
+ //-------------------------------------------------------------------------
+ OModuleImpl::~OModuleImpl()
+ {
+ if (m_pRessources)
+ delete m_pRessources;
+ }
+
+ //-------------------------------------------------------------------------
+ ResMgr* OModuleImpl::getResManager()
+ {
+ // note that this method is not threadsafe, which counts for the whole class !
+ if (!m_pRessources && !m_bInitialized)
+ {
+ DBG_ASSERT(m_sFilePrefix.Len(), "OModuleImpl::getResManager: no resource file prefix!");
+ // create a manager with a fixed prefix
+ ByteString aMgrName = m_sFilePrefix;
+
+ m_pRessources = ResMgr::CreateResMgr(aMgrName.GetBuffer());
+ DBG_ASSERT(m_pRessources,
+ (ByteString("OModuleImpl::getResManager: could not create the resource manager (file name: ")
+ += aMgrName
+ += ByteString(")!")).GetBuffer());
+
+ m_bInitialized = sal_True;
+ }
+ return m_pRessources;
+ }
+
+ //=========================================================================
+ //= OModule
+ //=========================================================================
+ ::osl::Mutex OModule::s_aMutex;
+ sal_Int32 OModule::s_nClients = 0;
+ OModuleImpl* OModule::s_pImpl = NULL;
+ ::rtl::OString OModule::s_sResPrefix;
+ //-------------------------------------------------------------------------
+ ResMgr* OModule::getResManager()
+ {
+ ENTER_MOD_METHOD();
+ return s_pImpl->getResManager();
+ }
+
+ //-------------------------------------------------------------------------
+ void OModule::setResourceFilePrefix(const ::rtl::OString& _rPrefix)
+ {
+ ::osl::MutexGuard aGuard(s_aMutex);
+ s_sResPrefix = _rPrefix;
+ if (s_pImpl)
+ s_pImpl->setResourceFilePrefix(_rPrefix);
+ }
+
+ //-------------------------------------------------------------------------
+ void OModule::registerClient()
+ {
+ ::osl::MutexGuard aGuard(s_aMutex);
+ ++s_nClients;
+ }
+
+ //-------------------------------------------------------------------------
+ void OModule::revokeClient()
+ {
+ ::osl::MutexGuard aGuard(s_aMutex);
+ if (!--s_nClients && s_pImpl)
+ {
+ delete s_pImpl;
+ s_pImpl = NULL;
+ }
+ }
+
+ //-------------------------------------------------------------------------
+ void OModule::ensureImpl()
+ {
+ if (s_pImpl)
+ return;
+ s_pImpl = new OModuleImpl();
+ s_pImpl->setResourceFilePrefix(s_sResPrefix);
+ }
+
+ //--------------------------------------------------------------------------
+ //- registration helper
+ //--------------------------------------------------------------------------
+
+ Sequence< ::rtl::OUString >* OModule::s_pImplementationNames = NULL;
+ Sequence< Sequence< ::rtl::OUString > >* OModule::s_pSupportedServices = NULL;
+ Sequence< sal_Int64 >* OModule::s_pCreationFunctionPointers = NULL;
+ Sequence< sal_Int64 >* OModule::s_pFactoryFunctionPointers = NULL;
+
+ //--------------------------------------------------------------------------
+ void OModule::registerComponent(
+ const ::rtl::OUString& _rImplementationName,
+ const Sequence< ::rtl::OUString >& _rServiceNames,
+ ComponentInstantiation _pCreateFunction,
+ FactoryInstantiation _pFactoryFunction)
+ {
+ if (!s_pImplementationNames)
+ {
+ OSL_ENSURE(!s_pSupportedServices && !s_pCreationFunctionPointers && !s_pFactoryFunctionPointers,
+ "OModule::registerComponent : inconsistent state (the pointers (1)) !");
+ s_pImplementationNames = new Sequence< ::rtl::OUString >;
+ s_pSupportedServices = new Sequence< Sequence< ::rtl::OUString > >;
+ s_pCreationFunctionPointers = new Sequence< sal_Int64 >;
+ s_pFactoryFunctionPointers = new Sequence< sal_Int64 >;
+ }
+ OSL_ENSURE(s_pImplementationNames && s_pSupportedServices && s_pCreationFunctionPointers && s_pFactoryFunctionPointers,
+ "OModule::registerComponent : inconsistent state (the pointers (2)) !");
+
+ OSL_ENSURE( (s_pImplementationNames->getLength() == s_pSupportedServices->getLength())
+ && (s_pImplementationNames->getLength() == s_pCreationFunctionPointers->getLength())
+ && (s_pImplementationNames->getLength() == s_pFactoryFunctionPointers->getLength()),
+ "OModule::registerComponent : inconsistent state !");
+
+ sal_Int32 nOldLen = s_pImplementationNames->getLength();
+ s_pImplementationNames->realloc(nOldLen + 1);
+ s_pSupportedServices->realloc(nOldLen + 1);
+ s_pCreationFunctionPointers->realloc(nOldLen + 1);
+ s_pFactoryFunctionPointers->realloc(nOldLen + 1);
+
+ s_pImplementationNames->getArray()[nOldLen] = _rImplementationName;
+ s_pSupportedServices->getArray()[nOldLen] = _rServiceNames;
+ s_pCreationFunctionPointers->getArray()[nOldLen] = reinterpret_cast<sal_Int64>(_pCreateFunction);
+ s_pFactoryFunctionPointers->getArray()[nOldLen] = reinterpret_cast<sal_Int64>(_pFactoryFunction);
+ }
+
+ //--------------------------------------------------------------------------
+ void OModule::revokeComponent(const ::rtl::OUString& _rImplementationName)
+ {
+ if (!s_pImplementationNames)
+ {
+ OSL_ASSERT("OModule::revokeComponent : have no class infos ! Are you sure called this method at the right time ?");
+ return;
+ }
+ OSL_ENSURE(s_pImplementationNames && s_pSupportedServices && s_pCreationFunctionPointers && s_pFactoryFunctionPointers,
+ "OModule::revokeComponent : inconsistent state (the pointers) !");
+ OSL_ENSURE( (s_pImplementationNames->getLength() == s_pSupportedServices->getLength())
+ && (s_pImplementationNames->getLength() == s_pCreationFunctionPointers->getLength())
+ && (s_pImplementationNames->getLength() == s_pFactoryFunctionPointers->getLength()),
+ "OModule::revokeComponent : inconsistent state !");
+
+ sal_Int32 nLen = s_pImplementationNames->getLength();
+ const ::rtl::OUString* pImplNames = s_pImplementationNames->getConstArray();
+ for (sal_Int32 i=0; i<nLen; ++i, ++pImplNames)
+ {
+ if (pImplNames->equals(_rImplementationName))
+ {
+ removeElementAt(*s_pImplementationNames, i);
+ removeElementAt(*s_pSupportedServices, i);
+ removeElementAt(*s_pCreationFunctionPointers, i);
+ removeElementAt(*s_pFactoryFunctionPointers, i);
+ break;
+ }
+ }
+
+ if (s_pImplementationNames->getLength() == 0)
+ {
+ delete s_pImplementationNames; s_pImplementationNames = NULL;
+ delete s_pSupportedServices; s_pSupportedServices = NULL;
+ delete s_pCreationFunctionPointers; s_pCreationFunctionPointers = NULL;
+ delete s_pFactoryFunctionPointers; s_pFactoryFunctionPointers = NULL;
+ }
+ }
+
+ //--------------------------------------------------------------------------
+ sal_Bool OModule::writeComponentInfos(
+ const Reference< XMultiServiceFactory >& /*_rxServiceManager*/,
+ const Reference< XRegistryKey >& _rxRootKey)
+ {
+ OSL_ENSURE(_rxRootKey.is(), "OModule::writeComponentInfos : invalid argument !");
+
+ if (!s_pImplementationNames)
+ {
+ OSL_ASSERT("OModule::writeComponentInfos : have no class infos ! Are you sure called this method at the right time ?");
+ return sal_True;
+ }
+ OSL_ENSURE(s_pImplementationNames && s_pSupportedServices && s_pCreationFunctionPointers && s_pFactoryFunctionPointers,
+ "OModule::writeComponentInfos : inconsistent state (the pointers) !");
+ OSL_ENSURE( (s_pImplementationNames->getLength() == s_pSupportedServices->getLength())
+ && (s_pImplementationNames->getLength() == s_pCreationFunctionPointers->getLength())
+ && (s_pImplementationNames->getLength() == s_pFactoryFunctionPointers->getLength()),
+ "OModule::writeComponentInfos : inconsistent state !");
+
+ sal_Int32 nLen = s_pImplementationNames->getLength();
+ const ::rtl::OUString* pImplName = s_pImplementationNames->getConstArray();
+ const Sequence< ::rtl::OUString >* pServices = s_pSupportedServices->getConstArray();
+
+ ::rtl::OUString sRootKey("/", 1, RTL_TEXTENCODING_ASCII_US);
+ for (sal_Int32 i=0; i<nLen; ++i, ++pImplName, ++pServices)
+ {
+ ::rtl::OUString aMainKeyName(sRootKey);
+ aMainKeyName += *pImplName;
+ aMainKeyName += ::rtl::OUString::createFromAscii("/UNO/SERVICES");
+
+ try
+ {
+ Reference< XRegistryKey > xNewKey( _rxRootKey->createKey(aMainKeyName) );
+
+ const ::rtl::OUString* pService = pServices->getConstArray();
+ for (sal_Int32 j=0; j<pServices->getLength(); ++j, ++pService)
+ xNewKey->createKey(*pService);
+ }
+ catch(Exception&)
+ {
+ OSL_ASSERT("OModule::writeComponentInfos : something went wrong while creating the keys !");
+ return sal_False;
+ }
+ }
+
+ return sal_True;
+ }
+
+ //--------------------------------------------------------------------------
+ Reference< XInterface > OModule::getComponentFactory(
+ const ::rtl::OUString& _rImplementationName,
+ const Reference< XMultiServiceFactory >& _rxServiceManager)
+ {
+ OSL_ENSURE(_rxServiceManager.is(), "OModule::getComponentFactory : invalid argument (service manager) !");
+ OSL_ENSURE(_rImplementationName.getLength(), "OModule::getComponentFactory : invalid argument (implementation name) !");
+
+ if (!s_pImplementationNames)
+ {
+ OSL_ASSERT("OModule::getComponentFactory : have no class infos ! Are you sure called this method at the right time ?");
+ return NULL;
+ }
+ OSL_ENSURE(s_pImplementationNames && s_pSupportedServices && s_pCreationFunctionPointers && s_pFactoryFunctionPointers,
+ "OModule::getComponentFactory : inconsistent state (the pointers) !");
+ OSL_ENSURE( (s_pImplementationNames->getLength() == s_pSupportedServices->getLength())
+ && (s_pImplementationNames->getLength() == s_pCreationFunctionPointers->getLength())
+ && (s_pImplementationNames->getLength() == s_pFactoryFunctionPointers->getLength()),
+ "OModule::getComponentFactory : inconsistent state !");
+
+
+ Reference< XInterface > xReturn;
+
+
+ sal_Int32 nLen = s_pImplementationNames->getLength();
+ const ::rtl::OUString* pImplName = s_pImplementationNames->getConstArray();
+ const Sequence< ::rtl::OUString >* pServices = s_pSupportedServices->getConstArray();
+ const sal_Int64* pComponentFunction = s_pCreationFunctionPointers->getConstArray();
+ const sal_Int64* pFactoryFunction = s_pFactoryFunctionPointers->getConstArray();
+
+ for (sal_Int32 i=0; i<nLen; ++i, ++pImplName, ++pServices, ++pComponentFunction, ++pFactoryFunction)
+ {
+ if (pImplName->equals(_rImplementationName))
+ {
+ const FactoryInstantiation FactoryInstantiationFunction = reinterpret_cast<const FactoryInstantiation>(*pFactoryFunction);
+ const ComponentInstantiation ComponentInstantiationFunction = reinterpret_cast<const ComponentInstantiation>(*pComponentFunction);
+
+ xReturn = FactoryInstantiationFunction( _rxServiceManager, *pImplName, ComponentInstantiationFunction, *pServices, NULL);
+ if (xReturn.is())
+ {
+ xReturn->acquire();
+ return xReturn.get();
+ }
+ }
+ }
+
+ return NULL;
+ }
+
+
+//.........................................................................
+} // namespace COMPMOD_NAMESPACE
+//.........................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/inc/componentmodule.hxx b/extensions/source/inc/componentmodule.hxx
new file mode 100644
index 000000000000..d0c93c5b0663
--- /dev/null
+++ b/extensions/source/inc/componentmodule.hxx
@@ -0,0 +1,280 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _EXTENSIONS_COMPONENT_MODULE_HXX_
+#define _EXTENSIONS_COMPONENT_MODULE_HXX_
+
+/** you may find this file helpfull if you implement a component (in it's own library) which can't use
+ the usual infrastructure.<br/>
+ More precise, you find helper classes to ease the use of resources and the registration of services.
+ <p>
+ You need to define a preprocessor variable COMPMOD_NAMESPACE in order to use this file. Set it to a string
+ which should be used as namespace for the classes defined herein.</p>
+*/
+
+#include <osl/mutex.hxx>
+#include <tools/resid.hxx>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/lang/XSingleServiceFactory.hpp>
+#include <com/sun/star/uno/Sequence.hxx>
+#include <com/sun/star/registry/XRegistryKey.hpp>
+#include <cppuhelper/factory.hxx>
+#include <rtl/string.hxx>
+
+class ResMgr;
+
+//.........................................................................
+namespace COMPMOD_NAMESPACE
+{
+//.........................................................................
+
+typedef ::com::sun::star::uno::Reference< ::com::sun::star::lang::XSingleServiceFactory > (SAL_CALL *FactoryInstantiation)
+ (
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rServiceManager,
+ const ::rtl::OUString & _rComponentName,
+ ::cppu::ComponentInstantiation _pCreateFunction,
+ const ::com::sun::star::uno::Sequence< ::rtl::OUString > & _rServiceNames,
+ rtl_ModuleCount* _pModuleCounter
+ );
+
+ //=========================================================================
+ //= OModule
+ //=========================================================================
+ class OModuleImpl;
+ class OModule
+ {
+ friend class OModuleResourceClient;
+
+ private:
+ OModule();
+ // not implemented. OModule is a static class
+
+ protected:
+ // resource administration
+ static ::osl::Mutex s_aMutex; /// access safety
+ static sal_Int32 s_nClients; /// number of registered clients
+ static OModuleImpl* s_pImpl; /// impl class. lives as long as at least one client for the module is registered
+ static ::rtl::OString s_sResPrefix;
+
+ // auto registration administration
+ static ::com::sun::star::uno::Sequence< ::rtl::OUString >*
+ s_pImplementationNames;
+ static ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::rtl::OUString > >*
+ s_pSupportedServices;
+ static ::com::sun::star::uno::Sequence< sal_Int64 >*
+ s_pCreationFunctionPointers;
+ static ::com::sun::star::uno::Sequence< sal_Int64 >*
+ s_pFactoryFunctionPointers;
+
+ public:
+ // cna be set as long as no resource has been accessed ...
+ static void setResourceFilePrefix(const ::rtl::OString& _rPrefix);
+
+ /// get the vcl res manager of the module
+ static ResMgr* getResManager();
+
+ /** register a component implementing a service with the given data.
+ @param _rImplementationName
+ the implementation name of the component
+ @param _rServiceNames
+ the services the component supports
+ @param _pCreateFunction
+ a function for creating an instance of the component
+ @param _pFactoryFunction
+ a function for creating a factory for that component
+ @see revokeComponent
+ */
+ static void registerComponent(
+ const ::rtl::OUString& _rImplementationName,
+ const ::com::sun::star::uno::Sequence< ::rtl::OUString >& _rServiceNames,
+ ::cppu::ComponentInstantiation _pCreateFunction,
+ FactoryInstantiation _pFactoryFunction);
+
+ /** revoke the registration for the specified component
+ @param _rImplementationName
+ the implementation name of the component
+ */
+ static void revokeComponent(
+ const ::rtl::OUString& _rImplementationName);
+
+ /** write the registration information of all known components
+ <p>writes the registration information of all components which are currently registered into the
+ specified registry.<p/>
+ <p>Usually used from within component_writeInfo.<p/>
+ @param _rxServiceManager
+ the service manager
+ @param _rRootKey
+ the registry key under which the information will be stored
+ @return
+ sal_True if the registration of all implementations was successfull, sal_False otherwise
+ */
+ static sal_Bool writeComponentInfos(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxServiceManager,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::registry::XRegistryKey >& _rRootKey);
+
+ /** creates a Factory for the component with the given implementation name.
+ <p>Usually used from within component_getFactory.<p/>
+ @param _rxServiceManager
+ a pointer to an XMultiServiceFactory interface as got in component_getFactory
+ @param _pImplementationName
+ the implementation name of the component
+ @return
+ the XInterface access to a factory for the component
+ */
+ static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > getComponentFactory(
+ const ::rtl::OUString& _rImplementationName,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxServiceManager
+ );
+
+ protected:
+ /// register a client for the module
+ static void registerClient();
+ /// revoke a client for the module
+ static void revokeClient();
+
+ private:
+ /** ensure that the impl class exists
+ @precond m_aMutex is guarded when this method gets called
+ */
+ static void ensureImpl();
+ };
+
+ //=========================================================================
+ //= OModuleResourceClient
+ //=========================================================================
+ /** base class for objects which uses any global module-specific ressources
+ */
+ class OModuleResourceClient
+ {
+ public:
+ OModuleResourceClient() { OModule::registerClient(); }
+ ~OModuleResourceClient() { OModule::revokeClient(); }
+ };
+
+ //=========================================================================
+ //= ModuleRes
+ //=========================================================================
+ /** specialized ResId, using the ressource manager provided by the global module
+ */
+ class ModuleRes : public ::ResId
+ {
+ public:
+ ModuleRes(USHORT _nId) : ResId(_nId, *OModule::getResManager()) { }
+ };
+
+ //==========================================================================
+ //= OMultiInstanceAutoRegistration
+ //==========================================================================
+ template <class TYPE>
+ class OMultiInstanceAutoRegistration
+ {
+ public:
+ /** automatically registeres a multi instance component
+ <p>Assumed that the template argument has the three methods
+ <ul>
+ <li><code>static ::rtl::OUString getImplementationName_Static()</code><li/>
+ <li><code>static ::com::sun::star::uno::Sequence< ::rtl::OUString > getSupportedServiceNames_Static()</code><li/>
+ <li><code>static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >
+ Create(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >&)</code>
+ </li>
+ <ul/>
+ the instantiation of this object will automatically register the class via <method>OModule::registerComponent</method>.
+ <p/>
+ The factory creation function used is <code>::cppu::createSingleFactory</code>.
+ @see OOneInstanceAutoRegistration
+ */
+ OMultiInstanceAutoRegistration();
+ ~OMultiInstanceAutoRegistration();
+ };
+
+ template <class TYPE>
+ OMultiInstanceAutoRegistration<TYPE>::OMultiInstanceAutoRegistration()
+ {
+ OModule::registerComponent(
+ TYPE::getImplementationName_Static(),
+ TYPE::getSupportedServiceNames_Static(),
+ TYPE::Create,
+ ::cppu::createSingleFactory
+ );
+ }
+
+ template <class TYPE>
+ OMultiInstanceAutoRegistration<TYPE>::~OMultiInstanceAutoRegistration()
+ {
+ OModule::revokeComponent(TYPE::getImplementationName_Static());
+ }
+
+ //==========================================================================
+ //= OOneInstanceAutoRegistration
+ //==========================================================================
+ template <class TYPE>
+ class OOneInstanceAutoRegistration
+ {
+ public:
+ /** automatically registeres a single instance component
+ <p>Assumed that the template argument has the three methods
+ <ul>
+ <li><code>static ::rtl::OUString getImplementationName_Static()</code><li/>
+ <li><code>static ::com::sun::star::uno::Sequence< ::rtl::OUString > getSupportedServiceNames_Static()</code><li/>
+ <li><code>static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >
+ Create(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >&)</code>
+ </li>
+ <ul/>
+ the instantiation of this object will automatically register the class via <method>OModule::registerComponent</method>.
+ <p/>
+ The factory creation function used is <code>::cppu::createOneInstanceFactory</code>.
+ @see OOneInstanceAutoRegistration
+ */
+ OOneInstanceAutoRegistration();
+ ~OOneInstanceAutoRegistration();
+ };
+
+ template <class TYPE>
+ OOneInstanceAutoRegistration<TYPE>::OOneInstanceAutoRegistration()
+ {
+ OModule::registerComponent(
+ TYPE::getImplementationName_Static(),
+ TYPE::getSupportedServiceNames_Static(),
+ TYPE::Create,
+ ::cppu::createOneInstanceFactory
+ );
+ }
+
+ template <class TYPE>
+ OOneInstanceAutoRegistration<TYPE>::~OOneInstanceAutoRegistration()
+ {
+ OModule::revokeComponent(TYPE::getImplementationName_Static());
+ }
+
+//.........................................................................
+} // namespace COMPMOD_NAMESPACE
+//.........................................................................
+
+#endif // _EXTENSIONS_COMPONENT_MODULE_HXX_
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/logging/consolehandler.cxx b/extensions/source/logging/consolehandler.cxx
new file mode 100644
index 000000000000..9e51ca370a7b
--- /dev/null
+++ b/extensions/source/logging/consolehandler.cxx
@@ -0,0 +1,345 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+
+#include "log_module.hxx"
+#include "methodguard.hxx"
+#include "loghandler.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/logging/XConsoleHandler.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/logging/LogLevel.hpp>
+#include <com/sun/star/lang/XInitialization.hpp>
+#include <com/sun/star/ucb/AlreadyInitializedException.hpp>
+#include <com/sun/star/lang/IllegalArgumentException.hpp>
+#include <com/sun/star/beans/NamedValue.hpp>
+/** === end UNO includes === **/
+
+#include <tools/diagnose_ex.h>
+
+#include <comphelper/componentcontext.hxx>
+
+#include <cppuhelper/compbase3.hxx>
+#include <cppuhelper/basemutex.hxx>
+
+#include <stdio.h>
+
+//........................................................................
+namespace logging
+{
+//........................................................................
+
+ /** === begin UNO using === **/
+ using ::com::sun::star::logging::XConsoleHandler;
+ using ::com::sun::star::lang::XServiceInfo;
+ using ::com::sun::star::uno::Reference;
+ using ::com::sun::star::uno::XComponentContext;
+ using ::com::sun::star::uno::RuntimeException;
+ using ::com::sun::star::logging::XLogFormatter;
+ using ::com::sun::star::uno::Sequence;
+ using ::com::sun::star::logging::LogRecord;
+ using ::com::sun::star::uno::UNO_QUERY_THROW;
+ using ::com::sun::star::uno::Exception;
+ using ::com::sun::star::uno::Any;
+ using ::com::sun::star::uno::XInterface;
+ using ::com::sun::star::lang::XInitialization;
+ using ::com::sun::star::ucb::AlreadyInitializedException;
+ using ::com::sun::star::lang::IllegalArgumentException;
+ using ::com::sun::star::beans::NamedValue;
+ /** === end UNO using === **/
+ namespace LogLevel = ::com::sun::star::logging::LogLevel;
+
+ //====================================================================
+ //= ConsoleHandler - declaration
+ //====================================================================
+ //--------------------------------------------------------------------
+ typedef ::cppu::WeakComponentImplHelper3 < XConsoleHandler
+ , XServiceInfo
+ , XInitialization
+ > ConsoleHandler_Base;
+ class ConsoleHandler :public ::cppu::BaseMutex
+ ,public ConsoleHandler_Base
+ {
+ private:
+ ::comphelper::ComponentContext m_aContext;
+ LogHandlerHelper m_aHandlerHelper;
+ sal_Int32 m_nThreshold;
+
+ protected:
+ ConsoleHandler( const Reference< XComponentContext >& _rxContext );
+ virtual ~ConsoleHandler();
+
+ // XConsoleHandler
+ virtual ::sal_Int32 SAL_CALL getThreshold() throw (RuntimeException);
+ virtual void SAL_CALL setThreshold( ::sal_Int32 _threshold ) throw (RuntimeException);
+
+ // XLogHandler
+ virtual ::rtl::OUString SAL_CALL getEncoding() throw (RuntimeException);
+ virtual void SAL_CALL setEncoding( const ::rtl::OUString& _encoding ) throw (RuntimeException);
+ virtual Reference< XLogFormatter > SAL_CALL getFormatter() throw (RuntimeException);
+ virtual void SAL_CALL setFormatter( const Reference< XLogFormatter >& _formatter ) throw (RuntimeException);
+ virtual ::sal_Int32 SAL_CALL getLevel() throw (RuntimeException);
+ virtual void SAL_CALL setLevel( ::sal_Int32 _level ) throw (RuntimeException);
+ virtual void SAL_CALL flush( ) throw (RuntimeException);
+ virtual ::sal_Bool SAL_CALL publish( const LogRecord& Record ) throw (RuntimeException);
+
+ // 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);
+
+ // XServiceInfo
+ virtual ::rtl::OUString SAL_CALL getImplementationName() throw(RuntimeException);
+ virtual ::sal_Bool SAL_CALL supportsService( const ::rtl::OUString& _rServiceName ) throw(RuntimeException);
+ virtual Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() throw(RuntimeException);
+
+ // OComponentHelper
+ virtual void SAL_CALL disposing();
+
+ public:
+ // XServiceInfo - static version
+ static ::rtl::OUString SAL_CALL getImplementationName_static();
+ static Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames_static();
+ static Reference< XInterface > Create( const Reference< XComponentContext >& _rxContext );
+
+ public:
+ typedef ComponentMethodGuard< ConsoleHandler > MethodGuard;
+ void enterMethod( MethodGuard::Access );
+ void leaveMethod( MethodGuard::Access );
+ };
+
+ //====================================================================
+ //= ConsoleHandler - implementation
+ //====================================================================
+ //--------------------------------------------------------------------
+ ConsoleHandler::ConsoleHandler( const Reference< XComponentContext >& _rxContext )
+ :ConsoleHandler_Base( m_aMutex )
+ ,m_aContext( _rxContext )
+ ,m_aHandlerHelper( _rxContext, m_aMutex, rBHelper )
+ ,m_nThreshold( LogLevel::SEVERE )
+ {
+ }
+
+ //--------------------------------------------------------------------
+ ConsoleHandler::~ConsoleHandler()
+ {
+ if ( !rBHelper.bDisposed )
+ {
+ acquire();
+ dispose();
+ }
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL ConsoleHandler::disposing()
+ {
+ m_aHandlerHelper.setFormatter( NULL );
+ }
+
+ //--------------------------------------------------------------------
+ void ConsoleHandler::enterMethod( MethodGuard::Access )
+ {
+ m_aHandlerHelper.enterMethod();
+ }
+
+ //--------------------------------------------------------------------
+ void ConsoleHandler::leaveMethod( MethodGuard::Access )
+ {
+ m_aMutex.release();
+ }
+
+ //--------------------------------------------------------------------
+ ::sal_Int32 SAL_CALL ConsoleHandler::getThreshold() throw (RuntimeException)
+ {
+ MethodGuard aGuard( *this );
+ return m_nThreshold;
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL ConsoleHandler::setThreshold( ::sal_Int32 _threshold ) throw (RuntimeException)
+ {
+ MethodGuard aGuard( *this );
+ m_nThreshold = _threshold;
+ }
+
+ //--------------------------------------------------------------------
+ ::rtl::OUString SAL_CALL ConsoleHandler::getEncoding() throw (RuntimeException)
+ {
+ MethodGuard aGuard( *this );
+ ::rtl::OUString sEncoding;
+ OSL_VERIFY( m_aHandlerHelper.getEncoding( sEncoding ) );
+ return sEncoding;
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL ConsoleHandler::setEncoding( const ::rtl::OUString& _rEncoding ) throw (RuntimeException)
+ {
+ MethodGuard aGuard( *this );
+ OSL_VERIFY( m_aHandlerHelper.setEncoding( _rEncoding ) );
+ }
+
+ //--------------------------------------------------------------------
+ Reference< XLogFormatter > SAL_CALL ConsoleHandler::getFormatter() throw (RuntimeException)
+ {
+ MethodGuard aGuard( *this );
+ return m_aHandlerHelper.getFormatter();
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL ConsoleHandler::setFormatter( const Reference< XLogFormatter >& _rxFormatter ) throw (RuntimeException)
+ {
+ MethodGuard aGuard( *this );
+ m_aHandlerHelper.setFormatter( _rxFormatter );
+ }
+
+ //--------------------------------------------------------------------
+ ::sal_Int32 SAL_CALL ConsoleHandler::getLevel() throw (RuntimeException)
+ {
+ MethodGuard aGuard( *this );
+ return m_aHandlerHelper.getLevel();
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL ConsoleHandler::setLevel( ::sal_Int32 _nLevel ) throw (RuntimeException)
+ {
+ MethodGuard aGuard( *this );
+ m_aHandlerHelper.setLevel( _nLevel );
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL ConsoleHandler::flush( ) throw (RuntimeException)
+ {
+ MethodGuard aGuard( *this );
+ fflush( stdout );
+ fflush( stderr );
+ }
+
+ //--------------------------------------------------------------------
+ ::sal_Bool SAL_CALL ConsoleHandler::publish( const LogRecord& _rRecord ) throw (RuntimeException)
+ {
+ MethodGuard aGuard( *this );
+
+ ::rtl::OString sEntry;
+ if ( !m_aHandlerHelper.formatForPublishing( _rRecord, sEntry ) )
+ return sal_False;
+
+ if ( _rRecord.Level >= m_nThreshold )
+ fprintf( stderr, sEntry.getStr() );
+ else
+ fprintf( stdout, sEntry.getStr() );
+
+ return sal_True;
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL ConsoleHandler::initialize( const Sequence< Any >& _rArguments ) throw (Exception, RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ if ( m_aHandlerHelper.getIsInitialized() )
+ throw AlreadyInitializedException();
+
+ if ( _rArguments.getLength() == 0 )
+ { // create() - nothing to init
+ m_aHandlerHelper.setIsInitialized();
+ return;
+ }
+
+ if ( _rArguments.getLength() != 1 )
+ throw IllegalArgumentException( ::rtl::OUString(), *this, 1 );
+
+ Sequence< NamedValue > aSettings;
+ if ( !( _rArguments[0] >>= aSettings ) )
+ throw IllegalArgumentException( ::rtl::OUString(), *this, 1 );
+
+ // createWithSettings( [in] sequence< ::com::sun::star::beans::NamedValue > Settings )
+ ::comphelper::NamedValueCollection aTypedSettings( aSettings );
+ m_aHandlerHelper.initFromSettings( aTypedSettings );
+
+ aTypedSettings.get_ensureType( "Threshold", m_nThreshold );
+
+ m_aHandlerHelper.setIsInitialized();
+ }
+
+ //--------------------------------------------------------------------
+ ::rtl::OUString SAL_CALL ConsoleHandler::getImplementationName() throw(RuntimeException)
+ {
+ return getImplementationName_static();
+ }
+
+ //--------------------------------------------------------------------
+ ::sal_Bool SAL_CALL ConsoleHandler::supportsService( const ::rtl::OUString& _rServiceName ) throw(RuntimeException)
+ {
+ const Sequence< ::rtl::OUString > aServiceNames( getSupportedServiceNames() );
+ for ( const ::rtl::OUString* pServiceNames = aServiceNames.getConstArray();
+ pServiceNames != aServiceNames.getConstArray() + aServiceNames.getLength();
+ ++pServiceNames
+ )
+ if ( _rServiceName == *pServiceNames )
+ return sal_True;
+ return sal_False;
+ }
+
+ //--------------------------------------------------------------------
+ Sequence< ::rtl::OUString > SAL_CALL ConsoleHandler::getSupportedServiceNames() throw(RuntimeException)
+ {
+ return getSupportedServiceNames_static();
+ }
+
+ //--------------------------------------------------------------------
+ ::rtl::OUString SAL_CALL ConsoleHandler::getImplementationName_static()
+ {
+ return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.extensions.ConsoleHandler" ) );
+ }
+
+ //--------------------------------------------------------------------
+ Sequence< ::rtl::OUString > SAL_CALL ConsoleHandler::getSupportedServiceNames_static()
+ {
+ Sequence< ::rtl::OUString > aServiceNames(1);
+ aServiceNames[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.logging.ConsoleHandler" ) );
+ return aServiceNames;
+ }
+
+ //--------------------------------------------------------------------
+ Reference< XInterface > ConsoleHandler::Create( const Reference< XComponentContext >& _rxContext )
+ {
+ return *( new ConsoleHandler( _rxContext ) );
+ }
+
+ //--------------------------------------------------------------------
+ void createRegistryInfo_ConsoleHandler()
+ {
+ static OAutoRegistration< ConsoleHandler > aAutoRegistration;
+ }
+
+//........................................................................
+} // namespace logging
+//........................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/logging/csvformatter.cxx b/extensions/source/logging/csvformatter.cxx
new file mode 100644
index 000000000000..244b0b3407ba
--- /dev/null
+++ b/extensions/source/logging/csvformatter.cxx
@@ -0,0 +1,377 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+
+#include "log_module.hxx"
+
+#include <stdio.h>
+#include <string>
+
+/** === begin UNO includes === **/
+#include <com/sun/star/logging/XCsvLogFormatter.hpp>
+#include <com/sun/star/logging/XLogFormatter.hpp>
+#include <com/sun/star/uno/XComponentContext.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+/** === end UNO includes === **/
+
+#include <comphelper/componentcontext.hxx>
+
+#include <cppuhelper/implbase2.hxx>
+
+#include <rtl/ustrbuf.hxx>
+
+#include <osl/thread.h>
+
+namespace logging
+{
+
+ /** === begin UNO using === **/
+ using ::com::sun::star::logging::XCsvLogFormatter;
+ using ::com::sun::star::logging::XLogFormatter;
+ using ::com::sun::star::uno::XComponentContext;
+ using ::com::sun::star::uno::Reference;
+ using ::com::sun::star::uno::Sequence;
+ using ::com::sun::star::lang::XServiceInfo;
+ using ::com::sun::star::uno::RuntimeException;
+ using ::com::sun::star::logging::LogRecord;
+ using ::com::sun::star::uno::XInterface;
+ /** === end UNO using === **/
+
+ //= CsvFormatter - declaration
+ //= formats for csv files as defined by RFC4180
+ typedef ::cppu::WeakImplHelper2 < XCsvLogFormatter
+ , XServiceInfo
+ > CsvFormatter_Base;
+ class CsvFormatter : public CsvFormatter_Base
+ {
+ public:
+ virtual ::rtl::OUString SAL_CALL formatMultiColumn(const Sequence< ::rtl::OUString>& column_data) throw (RuntimeException);
+
+ // XServiceInfo - static version
+ static ::rtl::OUString SAL_CALL getImplementationName_static();
+ static Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames_static();
+ static Reference< XInterface > Create( const Reference< XComponentContext >& context );
+
+ protected:
+ CsvFormatter( const Reference< XComponentContext >& context );
+ virtual ~CsvFormatter();
+
+ // XCsvLogFormatter
+ virtual ::sal_Bool SAL_CALL getLogEventNo() throw (RuntimeException);
+ virtual ::sal_Bool SAL_CALL getLogThread() throw (RuntimeException);
+ virtual ::sal_Bool SAL_CALL getLogTimestamp() throw (RuntimeException);
+ virtual ::sal_Bool SAL_CALL getLogSource() throw (RuntimeException);
+ virtual Sequence< ::rtl::OUString > SAL_CALL getColumnnames() throw (RuntimeException);
+
+ virtual void SAL_CALL setLogEventNo( ::sal_Bool log_event_no ) throw (RuntimeException);
+ virtual void SAL_CALL setLogThread( ::sal_Bool log_thread ) throw (RuntimeException);
+ virtual void SAL_CALL setLogTimestamp( ::sal_Bool log_timestamp ) throw (RuntimeException);
+ virtual void SAL_CALL setLogSource( ::sal_Bool log_source ) throw (RuntimeException);
+ virtual void SAL_CALL setColumnnames( const Sequence< ::rtl::OUString>& column_names) throw (RuntimeException);
+
+ // XLogFormatter
+ virtual ::rtl::OUString SAL_CALL getHead( ) throw (RuntimeException);
+ virtual ::rtl::OUString SAL_CALL format( const LogRecord& Record ) throw (RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getTail( ) throw (RuntimeException);
+
+ // XServiceInfo
+ virtual ::rtl::OUString SAL_CALL getImplementationName() throw(RuntimeException);
+ virtual ::sal_Bool SAL_CALL supportsService( const ::rtl::OUString& service_name ) throw(RuntimeException);
+ virtual Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() throw(RuntimeException);
+
+ private:
+ ::comphelper::ComponentContext m_aContext;
+ ::sal_Bool m_LogEventNo;
+ ::sal_Bool m_LogThread;
+ ::sal_Bool m_LogTimestamp;
+ ::sal_Bool m_LogSource;
+ ::sal_Bool m_MultiColumn;
+ ::com::sun::star::uno::Sequence< ::rtl::OUString > m_Columnnames;
+ };
+} // namespace logging
+
+//= private helpers
+namespace
+{
+ const sal_Unicode quote_char = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("\"")).toChar();
+ const sal_Unicode comma_char = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(",")).toChar();
+ const ::rtl::OUString dos_newline = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("\r\n"));
+
+ inline bool needsQuoting(const ::rtl::OUString& str)
+ {
+ static const ::rtl::OUString quote_trigger_chars = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("\",\n\r"));
+ sal_Int32 len = str.getLength();
+ for(sal_Int32 i=0; i<len; i++)
+ if(quote_trigger_chars.indexOf(str[i])!=-1)
+ return true;
+ return false;
+ };
+
+ inline void appendEncodedString(::rtl::OUStringBuffer& buf, const ::rtl::OUString& str)
+ {
+ if(needsQuoting(str))
+ {
+ // each double-quote will get replaced by two double-quotes
+ buf.append(quote_char);
+ const sal_Int32 buf_offset = buf.getLength();
+ const sal_Int32 str_length = str.getLength();
+ buf.append(str);
+ // special treatment for the last character
+ if(quote_char==str[str_length-1])
+ buf.append(quote_char);
+ // iterating backwards because the index at which we insert wont be shifted
+ // when moving that way.
+ for(sal_Int32 i = str_length; i>=0; )
+ {
+ i=str.lastIndexOf(quote_char, --i);
+ if(i!=-1)
+ buf.insert(buf_offset + i, quote_char);
+ }
+ buf.append(quote_char);
+ }
+ else
+ buf.append(str);
+ };
+
+ ::com::sun::star::uno::Sequence< ::rtl::OUString> initialColumns()
+ {
+ com::sun::star::uno::Sequence< ::rtl::OUString> result = ::com::sun::star::uno::Sequence< ::rtl::OUString>(1);
+ result[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("message"));
+ return result;
+ };
+}
+
+//= CsvFormatter - implementation
+namespace logging
+{
+ CsvFormatter::CsvFormatter( const Reference< XComponentContext >& context )
+ :m_aContext( context ),
+ m_LogEventNo(true),
+ m_LogThread(true),
+ m_LogTimestamp(true),
+ m_LogSource(false),
+ m_MultiColumn(false),
+ m_Columnnames(initialColumns())
+ { }
+
+ CsvFormatter::~CsvFormatter()
+ { }
+
+ ::sal_Bool CsvFormatter::getLogEventNo() throw (RuntimeException)
+ {
+ return m_LogEventNo;
+ }
+
+ ::sal_Bool CsvFormatter::getLogThread() throw (RuntimeException)
+ {
+ return m_LogThread;
+ }
+
+ ::sal_Bool CsvFormatter::getLogTimestamp() throw (RuntimeException)
+ {
+ return m_LogTimestamp;
+ }
+
+ ::sal_Bool CsvFormatter::getLogSource() throw (RuntimeException)
+ {
+ return m_LogSource;
+ }
+
+ Sequence< ::rtl::OUString > CsvFormatter::getColumnnames() throw (RuntimeException)
+ {
+ return m_Columnnames;
+ }
+
+ void CsvFormatter::setLogEventNo(::sal_Bool log_event_no) throw (RuntimeException)
+ {
+ m_LogEventNo = log_event_no;
+ }
+
+ void CsvFormatter::setLogThread(::sal_Bool log_thread) throw (RuntimeException)
+ {
+ m_LogThread = log_thread;
+ }
+
+ void CsvFormatter::setLogTimestamp(::sal_Bool log_timestamp) throw (RuntimeException)
+ {
+ m_LogTimestamp = log_timestamp;
+ }
+
+ void CsvFormatter::setLogSource(::sal_Bool log_source) throw (RuntimeException)
+ {
+ m_LogSource = log_source;
+ }
+
+ void CsvFormatter::setColumnnames(const Sequence< ::rtl::OUString >& columnnames) throw (RuntimeException)
+ {
+ m_Columnnames = Sequence< ::rtl::OUString>(columnnames);
+ m_MultiColumn = (m_Columnnames.getLength()>1);
+ }
+
+ ::rtl::OUString SAL_CALL CsvFormatter::getHead( ) throw (RuntimeException)
+ {
+ ::rtl::OUStringBuffer buf;
+ if(m_LogEventNo)
+ buf.appendAscii("event no,");
+ if(m_LogThread)
+ buf.appendAscii("thread,");
+ if(m_LogTimestamp)
+ buf.appendAscii("timestamp,");
+ if(m_LogSource)
+ buf.appendAscii("class,method,");
+ sal_Int32 columns = m_Columnnames.getLength();
+ for(sal_Int32 i=0; i<columns; i++)
+ {
+ buf.append(m_Columnnames[i]);
+ buf.append(comma_char);
+ }
+ buf.setLength(buf.getLength()-1);
+ buf.append(dos_newline);
+ return buf.makeStringAndClear();
+ }
+
+ ::rtl::OUString SAL_CALL CsvFormatter::format( const LogRecord& record ) throw (RuntimeException)
+ {
+ ::rtl::OUStringBuffer aLogEntry;
+
+ if(m_LogEventNo)
+ {
+ aLogEntry.append( record.SequenceNumber );
+ aLogEntry.append(comma_char);
+ }
+
+ if(m_LogThread)
+ {
+ aLogEntry.append( record.ThreadID );
+ aLogEntry.append(comma_char);
+ }
+
+ if(m_LogTimestamp)
+ {
+ // ISO 8601
+ char buffer[ 30 ];
+ const size_t buffer_size = sizeof( buffer );
+ snprintf( buffer, buffer_size, "%04i-%02i-%02iT%02i:%02i:%02i.%02i",
+ (int)record.LogTime.Year,
+ (int)record.LogTime.Month,
+ (int)record.LogTime.Day,
+ (int)record.LogTime.Hours,
+ (int)record.LogTime.Minutes,
+ (int)record.LogTime.Seconds,
+ (int)record.LogTime.HundredthSeconds );
+ aLogEntry.appendAscii( buffer );
+ aLogEntry.append(comma_char);
+ }
+
+ if(m_LogSource)
+ {
+ appendEncodedString(aLogEntry, record.SourceClassName);
+ aLogEntry.append(comma_char);
+
+ appendEncodedString(aLogEntry, record.SourceMethodName);
+ aLogEntry.append(comma_char);
+ }
+
+ // if the CsvFormatter has multiple columns set via setColumnnames(), the
+ // message of the record is expected to be encoded with formatMultiColumn
+ // if the CsvFormatter has only one column set, the message is expected not
+ // to be encoded
+ if(m_MultiColumn)
+ aLogEntry.append(record.Message);
+ else
+ appendEncodedString(aLogEntry, record.Message);
+
+ aLogEntry.append( dos_newline );
+ return aLogEntry.makeStringAndClear();
+ }
+
+ ::rtl::OUString SAL_CALL CsvFormatter::getTail( ) throw (RuntimeException)
+ {
+ return ::rtl::OUString();
+ }
+
+ ::rtl::OUString SAL_CALL CsvFormatter::formatMultiColumn(const Sequence< ::rtl::OUString>& column_data) throw (RuntimeException)
+ {
+ sal_Int32 columns = column_data.getLength();
+ ::rtl::OUStringBuffer buf;
+ for(int i=0; i<columns; i++)
+ {
+ appendEncodedString(buf, column_data[i]);
+ buf.append(comma_char);
+ }
+ buf.setLength(buf.getLength()-1);
+ return buf.makeStringAndClear();
+ }
+
+ ::sal_Bool SAL_CALL CsvFormatter::supportsService( const ::rtl::OUString& service_name ) throw(RuntimeException)
+ {
+ const Sequence< ::rtl::OUString > aServiceNames( getSupportedServiceNames() );
+ for ( const ::rtl::OUString* pServiceNames = aServiceNames.getConstArray();
+ pServiceNames != aServiceNames.getConstArray() + aServiceNames.getLength();
+ ++pServiceNames
+ )
+ if ( service_name == *pServiceNames )
+ return sal_True;
+ return sal_False;
+ }
+
+ ::rtl::OUString SAL_CALL CsvFormatter::getImplementationName() throw(RuntimeException)
+ {
+ return getImplementationName_static();
+ }
+
+ Sequence< ::rtl::OUString > SAL_CALL CsvFormatter::getSupportedServiceNames() throw(RuntimeException)
+ {
+ return getSupportedServiceNames_static();
+ }
+
+ ::rtl::OUString SAL_CALL CsvFormatter::getImplementationName_static()
+ {
+ return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.extensions.CsvFormatter" ) );
+ }
+
+ Sequence< ::rtl::OUString > SAL_CALL CsvFormatter::getSupportedServiceNames_static()
+ {
+ Sequence< ::rtl::OUString > aServiceNames(1);
+ aServiceNames[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.logging.CsvFormatter" ) );
+ return aServiceNames;
+ }
+
+ Reference< XInterface > CsvFormatter::Create( const Reference< XComponentContext >& context )
+ {
+ return *( new CsvFormatter( context ) );
+ }
+
+ void createRegistryInfo_CsvFormatter()
+ {
+ static OAutoRegistration< CsvFormatter > aAutoRegistration;
+ }
+} // namespace logging
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/logging/filehandler.cxx b/extensions/source/logging/filehandler.cxx
new file mode 100644
index 000000000000..beeccbb7453b
--- /dev/null
+++ b/extensions/source/logging/filehandler.cxx
@@ -0,0 +1,444 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+
+#include "log_module.hxx"
+#include "methodguard.hxx"
+#include "loghandler.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/logging/XLogHandler.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/ucb/AlreadyInitializedException.hpp>
+#include <com/sun/star/lang/XInitialization.hpp>
+#include <com/sun/star/lang/IllegalArgumentException.hpp>
+#include <com/sun/star/util/XStringSubstitution.hpp>
+/** === end UNO includes === **/
+
+#include <tools/diagnose_ex.h>
+
+#include <comphelper/componentcontext.hxx>
+
+#include <cppuhelper/compbase3.hxx>
+#include <cppuhelper/basemutex.hxx>
+
+#include <osl/thread.h>
+#include <osl/file.hxx>
+
+#include <rtl/strbuf.hxx>
+
+#include <memory>
+
+//........................................................................
+namespace logging
+{
+//........................................................................
+
+ /** === begin UNO using === **/
+ using ::com::sun::star::uno::Reference;
+ using ::com::sun::star::logging::LogRecord;
+ using ::com::sun::star::uno::RuntimeException;
+ using ::com::sun::star::logging::XLogFormatter;
+ using ::com::sun::star::uno::Sequence;
+ using ::com::sun::star::uno::XInterface;
+ using ::com::sun::star::uno::XComponentContext;
+ using ::com::sun::star::logging::XLogHandler;
+ using ::com::sun::star::lang::XServiceInfo;
+ using ::com::sun::star::ucb::AlreadyInitializedException;
+ using ::com::sun::star::lang::XInitialization;
+ using ::com::sun::star::uno::Any;
+ using ::com::sun::star::uno::Exception;
+ using ::com::sun::star::lang::IllegalArgumentException;
+ using ::com::sun::star::uno::UNO_QUERY_THROW;
+ using ::com::sun::star::util::XStringSubstitution;
+ using ::com::sun::star::beans::NamedValue;
+ /** === end UNO using === **/
+
+ //====================================================================
+ //= FileHandler - declaration
+ //====================================================================
+ typedef ::cppu::WeakComponentImplHelper3 < XLogHandler
+ , XServiceInfo
+ , XInitialization
+ > FileHandler_Base;
+ class FileHandler :public ::cppu::BaseMutex
+ ,public FileHandler_Base
+ {
+ private:
+ enum FileValidity
+ {
+ /// never attempted to open the file
+ eUnknown,
+ /// file is valid
+ eValid,
+ /// file is invalid
+ eInvalid
+ };
+
+ private:
+ ::comphelper::ComponentContext m_aContext;
+ LogHandlerHelper m_aHandlerHelper;
+ ::rtl::OUString m_sFileURL;
+ ::std::auto_ptr< ::osl::File > m_pFile;
+ FileValidity m_eFileValidity;
+
+ protected:
+ FileHandler( const Reference< XComponentContext >& _rxContext );
+ virtual ~FileHandler();
+
+ // XLogHandler
+ virtual ::rtl::OUString SAL_CALL getEncoding() throw (RuntimeException);
+ virtual void SAL_CALL setEncoding( const ::rtl::OUString& _encoding ) throw (RuntimeException);
+ virtual Reference< XLogFormatter > SAL_CALL getFormatter() throw (RuntimeException);
+ virtual void SAL_CALL setFormatter( const Reference< XLogFormatter >& _formatter ) throw (RuntimeException);
+ virtual ::sal_Int32 SAL_CALL getLevel() throw (RuntimeException);
+ virtual void SAL_CALL setLevel( ::sal_Int32 _level ) throw (RuntimeException);
+ virtual void SAL_CALL flush( ) throw (RuntimeException);
+ virtual ::sal_Bool SAL_CALL publish( const LogRecord& Record ) throw (RuntimeException);
+
+ // 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);
+
+ // XServiceInfo
+ virtual ::rtl::OUString SAL_CALL getImplementationName() throw(RuntimeException);
+ virtual ::sal_Bool SAL_CALL supportsService( const ::rtl::OUString& _rServiceName ) throw(RuntimeException);
+ virtual Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() throw(RuntimeException);
+
+ // OComponentHelper
+ virtual void SAL_CALL disposing();
+
+ public:
+ // XServiceInfo - static version
+ static ::rtl::OUString SAL_CALL getImplementationName_static();
+ static Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames_static();
+ static Reference< XInterface > Create( const Reference< XComponentContext >& _rxContext );
+
+ public:
+ typedef ComponentMethodGuard< FileHandler > MethodGuard;
+ void enterMethod( MethodGuard::Access );
+ void leaveMethod( MethodGuard::Access );
+
+ private:
+ /** prepares our output file for writing
+ */
+ bool impl_prepareFile_nothrow();
+
+ /// writes the given string to our file
+ void impl_writeString_nothrow( const ::rtl::OString& _rEntry );
+
+ /** does string substitution on a (usually externally provided) file url
+ */
+ void impl_doStringsubstitution_nothrow( ::rtl::OUString& _inout_rURL );
+ };
+
+ //====================================================================
+ //= FileHandler - implementation
+ //====================================================================
+ //--------------------------------------------------------------------
+ FileHandler::FileHandler( const Reference< XComponentContext >& _rxContext )
+ :FileHandler_Base( m_aMutex )
+ ,m_aContext( _rxContext )
+ ,m_aHandlerHelper( _rxContext, m_aMutex, rBHelper )
+ ,m_sFileURL( )
+ ,m_pFile( )
+ ,m_eFileValidity( eUnknown )
+ {
+ }
+
+ //--------------------------------------------------------------------
+ FileHandler::~FileHandler()
+ {
+ if ( !rBHelper.bDisposed )
+ {
+ acquire();
+ dispose();
+ }
+ }
+
+ //--------------------------------------------------------------------
+ bool FileHandler::impl_prepareFile_nothrow()
+ {
+ if ( m_eFileValidity == eUnknown )
+ {
+ m_pFile.reset( new ::osl::File( m_sFileURL ) );
+ // check whether the log file already exists
+ ::osl::DirectoryItem aFileItem;
+ ::osl::DirectoryItem::get( m_sFileURL, aFileItem );
+ ::osl::FileStatus aStatus( FileStatusMask_Validate );
+ if ( ::osl::FileBase::E_None == aFileItem.getFileStatus( aStatus ) )
+ ::osl::File::remove( m_sFileURL );
+
+ ::osl::FileBase::RC res = m_pFile->open( osl_File_OpenFlag_Write | osl_File_OpenFlag_Create );
+ m_eFileValidity = res == ::osl::FileBase::E_None
+ ? eValid
+ : eInvalid;
+ #if OSL_DEBUG_LEVEL > 0
+ if ( m_eFileValidity == eInvalid )
+ {
+ ::rtl::OStringBuffer sMessage;
+ sMessage.append( "FileHandler::impl_prepareFile_nothrow: could not open the designated log file:" );
+ sMessage.append( "\nURL: " );
+ sMessage.append( ::rtl::OString( m_sFileURL.getStr(), m_sFileURL.getLength(), osl_getThreadTextEncoding() ) );
+ sMessage.append( "\nerror code: " );
+ sMessage.append( (sal_Int32)res );
+ OSL_ENSURE( false, sMessage.makeStringAndClear() );
+ }
+ #endif
+ if ( m_eFileValidity == eValid )
+ {
+ ::rtl::OString sHead;
+ if ( m_aHandlerHelper.getEncodedHead( sHead ) )
+ impl_writeString_nothrow( sHead );
+ }
+ }
+
+ return m_eFileValidity == eValid;
+ }
+
+ //--------------------------------------------------------------------
+ void FileHandler::impl_writeString_nothrow( const ::rtl::OString& _rEntry )
+ {
+ OSL_PRECOND( m_pFile.get(), "FileHandler::impl_writeString_nothrow: no file!" );
+
+ sal_uInt64 nBytesToWrite( _rEntry.getLength() );
+ sal_uInt64 nBytesWritten( 0 );
+ #if OSL_DEBUG_LEVEL > 0
+ ::osl::FileBase::RC res =
+ #endif
+ m_pFile->write( _rEntry.getStr(), nBytesToWrite, nBytesWritten );
+ OSL_ENSURE( ( res == ::osl::FileBase::E_None ) && ( nBytesWritten == nBytesToWrite ),
+ "FileHandler::impl_writeString_nothrow: could not write the log entry!" );
+ }
+
+ //--------------------------------------------------------------------
+ void FileHandler::impl_doStringsubstitution_nothrow( ::rtl::OUString& _inout_rURL )
+ {
+ try
+ {
+ Reference< XStringSubstitution > xStringSubst;
+ if ( m_aContext.createComponent( "com.sun.star.util.PathSubstitution", xStringSubst ) )
+ _inout_rURL = xStringSubst->substituteVariables( _inout_rURL, true );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL FileHandler::disposing()
+ {
+ if ( m_eFileValidity == eValid )
+ {
+ ::rtl::OString sTail;
+ if ( m_aHandlerHelper.getEncodedTail( sTail ) )
+ impl_writeString_nothrow( sTail );
+ }
+
+ m_pFile.reset( NULL );
+ m_aHandlerHelper.setFormatter( NULL );
+ }
+
+ //--------------------------------------------------------------------
+ void FileHandler::enterMethod( MethodGuard::Access )
+ {
+ m_aHandlerHelper.enterMethod();
+ }
+
+ //--------------------------------------------------------------------
+ void FileHandler::leaveMethod( MethodGuard::Access )
+ {
+ m_aMutex.release();
+ }
+
+ //--------------------------------------------------------------------
+ ::rtl::OUString SAL_CALL FileHandler::getEncoding() throw (RuntimeException)
+ {
+ MethodGuard aGuard( *this );
+ ::rtl::OUString sEncoding;
+ OSL_VERIFY( m_aHandlerHelper.getEncoding( sEncoding ) );
+ return sEncoding;
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL FileHandler::setEncoding( const ::rtl::OUString& _rEncoding ) throw (RuntimeException)
+ {
+ MethodGuard aGuard( *this );
+ OSL_VERIFY( m_aHandlerHelper.setEncoding( _rEncoding ) );
+ }
+
+ //--------------------------------------------------------------------
+ Reference< XLogFormatter > SAL_CALL FileHandler::getFormatter() throw (RuntimeException)
+ {
+ MethodGuard aGuard( *this );
+ return m_aHandlerHelper.getFormatter();
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL FileHandler::setFormatter( const Reference< XLogFormatter >& _rxFormatter ) throw (RuntimeException)
+ {
+ MethodGuard aGuard( *this );
+ m_aHandlerHelper.setFormatter( _rxFormatter );
+ }
+
+ //--------------------------------------------------------------------
+ ::sal_Int32 SAL_CALL FileHandler::getLevel() throw (RuntimeException)
+ {
+ MethodGuard aGuard( *this );
+ return m_aHandlerHelper.getLevel();
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL FileHandler::setLevel( ::sal_Int32 _nLevel ) throw (RuntimeException)
+ {
+ MethodGuard aGuard( *this );
+ m_aHandlerHelper.setLevel( _nLevel );
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL FileHandler::flush( ) throw (RuntimeException)
+ {
+ MethodGuard aGuard( *this );
+ if(!m_pFile.get())
+ {
+ OSL_PRECOND(false, "FileHandler::flush: no file!");
+ return;
+ }
+ #if OSL_DEBUG_LEVEL > 0
+ ::osl::FileBase::RC res =
+ #endif
+ m_pFile->sync();
+ OSL_ENSURE(res == ::osl::FileBase::E_None, "FileHandler::flush: Could not sync logfile to filesystem.");
+ }
+
+ //--------------------------------------------------------------------
+ ::sal_Bool SAL_CALL FileHandler::publish( const LogRecord& _rRecord ) throw (RuntimeException)
+ {
+ MethodGuard aGuard( *this );
+
+ if ( !impl_prepareFile_nothrow() )
+ return sal_False;
+
+ ::rtl::OString sEntry;
+ if ( !m_aHandlerHelper.formatForPublishing( _rRecord, sEntry ) )
+ return sal_False;
+
+ impl_writeString_nothrow( sEntry );
+ return sal_True;
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL FileHandler::initialize( const Sequence< Any >& _rArguments ) throw (Exception, RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ if ( m_aHandlerHelper.getIsInitialized() )
+ throw AlreadyInitializedException();
+
+ if ( _rArguments.getLength() != 1 )
+ throw IllegalArgumentException( ::rtl::OUString(), *this, 1 );
+
+ Sequence< NamedValue > aSettings;
+ if ( _rArguments[0] >>= m_sFileURL )
+ {
+ // create( [in] string URL );
+ impl_doStringsubstitution_nothrow( m_sFileURL );
+ }
+ else if ( _rArguments[0] >>= aSettings )
+ {
+ // createWithSettings( [in] sequence< ::com::sun::star::beans::NamedValue > Settings )
+ ::comphelper::NamedValueCollection aTypedSettings( aSettings );
+ m_aHandlerHelper.initFromSettings( aTypedSettings );
+
+ if ( aTypedSettings.get_ensureType( "FileURL", m_sFileURL ) )
+ impl_doStringsubstitution_nothrow( m_sFileURL );
+ }
+ else
+ throw IllegalArgumentException( ::rtl::OUString(), *this, 1 );
+
+ m_aHandlerHelper.setIsInitialized();
+ }
+
+ //--------------------------------------------------------------------
+ ::rtl::OUString SAL_CALL FileHandler::getImplementationName() throw(RuntimeException)
+ {
+ return getImplementationName_static();
+ }
+
+ //--------------------------------------------------------------------
+ ::sal_Bool SAL_CALL FileHandler::supportsService( const ::rtl::OUString& _rServiceName ) throw(RuntimeException)
+ {
+ const Sequence< ::rtl::OUString > aServiceNames( getSupportedServiceNames() );
+ for ( const ::rtl::OUString* pServiceNames = aServiceNames.getConstArray();
+ pServiceNames != aServiceNames.getConstArray() + aServiceNames.getLength();
+ ++pServiceNames
+ )
+ if ( _rServiceName == *pServiceNames )
+ return sal_True;
+ return sal_False;
+ }
+
+ //--------------------------------------------------------------------
+ Sequence< ::rtl::OUString > SAL_CALL FileHandler::getSupportedServiceNames() throw(RuntimeException)
+ {
+ return getSupportedServiceNames_static();
+ }
+
+ //--------------------------------------------------------------------
+ ::rtl::OUString SAL_CALL FileHandler::getImplementationName_static()
+ {
+ return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.extensions.FileHandler" ) );
+ }
+
+ //--------------------------------------------------------------------
+ Sequence< ::rtl::OUString > SAL_CALL FileHandler::getSupportedServiceNames_static()
+ {
+ Sequence< ::rtl::OUString > aServiceNames(1);
+ aServiceNames[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.logging.FileHandler" ) );
+ return aServiceNames;
+ }
+
+ //--------------------------------------------------------------------
+ Reference< XInterface > FileHandler::Create( const Reference< XComponentContext >& _rxContext )
+ {
+ return *( new FileHandler( _rxContext ) );
+ }
+
+ //--------------------------------------------------------------------
+ void createRegistryInfo_FileHandler()
+ {
+ static OAutoRegistration< FileHandler > aAutoRegistration;
+ }
+
+//........................................................................
+} // namespace logging
+//........................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/logging/log_module.cxx b/extensions/source/logging/log_module.cxx
new file mode 100644
index 000000000000..5cdf5e73723a
--- /dev/null
+++ b/extensions/source/logging/log_module.cxx
@@ -0,0 +1,45 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+#include "log_module.hxx"
+#include <rtl/instance.hxx>
+
+//........................................................................
+namespace logging
+{
+//........................................................................
+
+ IMPLEMENT_COMPONENT_MODULE( LogModule );
+
+//........................................................................
+} // namespace logging
+//........................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/logging/log_module.hxx b/extensions/source/logging/log_module.hxx
new file mode 100644
index 000000000000..dbc06816ccab
--- /dev/null
+++ b/extensions/source/logging/log_module.hxx
@@ -0,0 +1,47 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef EXTENSIONS_LOG_MODULE_HXX
+#define EXTENSIONS_LOG_MODULE_HXX
+
+#include <comphelper/componentmodule.hxx>
+
+//........................................................................
+namespace logging
+{
+//........................................................................
+
+ DECLARE_COMPONENT_MODULE( LogModule, LogModuleClient )
+
+//........................................................................
+} // namespace logging
+//........................................................................
+
+#endif // EXTENSIONS_LOG_MODULE_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/logging/log_services.cxx b/extensions/source/logging/log_services.cxx
new file mode 100644
index 000000000000..4cf0d54e13c0
--- /dev/null
+++ b/extensions/source/logging/log_services.cxx
@@ -0,0 +1,71 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+
+/** === begin UNO includes === **/
+/** === end UNO includes === **/
+#include "log_module.hxx"
+
+//........................................................................
+namespace logging
+{
+//........................................................................
+
+ //--------------------------------------------------------------------
+ extern void createRegistryInfo_LoggerPool();
+ extern void createRegistryInfo_FileHandler();
+ extern void createRegistryInfo_ConsoleHandler();
+ extern void createRegistryInfo_PlainTextFormatter();
+ extern void createRegistryInfo_CsvFormatter();
+
+ static void initializeModule()
+ {
+ static bool bInitialized( false );
+ if ( !bInitialized )
+ {
+ ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
+ if ( !bInitialized )
+ {
+ createRegistryInfo_LoggerPool();
+ createRegistryInfo_FileHandler();
+ createRegistryInfo_ConsoleHandler();
+ createRegistryInfo_PlainTextFormatter();
+ createRegistryInfo_CsvFormatter();
+ }
+ }
+ }
+
+//........................................................................
+} // namespace logging
+//........................................................................
+
+IMPLEMENT_COMPONENT_LIBRARY_API( ::logging::LogModule, ::logging::initializeModule )
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/logging/logger.cxx b/extensions/source/logging/logger.cxx
new file mode 100644
index 000000000000..64de34fc78b5
--- /dev/null
+++ b/extensions/source/logging/logger.cxx
@@ -0,0 +1,406 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+
+#include "log_module.hxx"
+#include "logrecord.hxx"
+#include "loggerconfig.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/logging/XLogger.hpp>
+#include <com/sun/star/logging/LogLevel.hpp>
+#include <com/sun/star/uno/XComponentContext.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/logging/XLoggerPool.hpp>
+/** === end UNO includes === **/
+
+#include <tools/diagnose_ex.h>
+
+#include <comphelper/componentcontext.hxx>
+
+#include <cppuhelper/basemutex.hxx>
+#include <cppuhelper/interfacecontainer.hxx>
+#include <cppuhelper/implbase2.hxx>
+#include <cppuhelper/weakref.hxx>
+
+#include <boost/bind.hpp>
+
+#include <map>
+
+//........................................................................
+namespace logging
+{
+//........................................................................
+
+ /** === begin UNO using === **/
+ using ::com::sun::star::logging::XLogger;
+ using ::com::sun::star::uno::Reference;
+ using ::com::sun::star::uno::XComponentContext;
+ using ::com::sun::star::lang::XServiceInfo;
+ using ::com::sun::star::uno::RuntimeException;
+ using ::com::sun::star::uno::Sequence;
+ using ::com::sun::star::uno::XInterface;
+ using ::com::sun::star::uno::UNO_QUERY_THROW;
+ using ::com::sun::star::uno::Any;
+ using ::com::sun::star::uno::Exception;
+ using ::com::sun::star::uno::WeakReference;
+ using ::com::sun::star::logging::XLogHandler;
+ using ::com::sun::star::logging::XLoggerPool;
+ using ::com::sun::star::logging::LogRecord;
+ /** === end UNO using === **/
+ namespace LogLevel = ::com::sun::star::logging::LogLevel;
+
+ //====================================================================
+ //= helper
+ //====================================================================
+ namespace
+ {
+ sal_Bool lcl_supportsService_nothrow( XServiceInfo& _rSI, const ::rtl::OUString& _rServiceName )
+ {
+ const Sequence< ::rtl::OUString > aServiceNames( _rSI.getSupportedServiceNames() );
+ for ( const ::rtl::OUString* pServiceNames = aServiceNames.getConstArray();
+ pServiceNames != aServiceNames.getConstArray() + aServiceNames.getLength();
+ ++pServiceNames
+ )
+ if ( _rServiceName == *pServiceNames )
+ return sal_True;
+ return sal_False;
+ }
+ }
+
+ //====================================================================
+ //= EventLogger - declaration
+ //====================================================================
+ typedef ::cppu::WeakImplHelper2 < XLogger
+ , XServiceInfo
+ > EventLogger_Base;
+ class EventLogger :public ::cppu::BaseMutex
+ ,public EventLogger_Base
+ {
+ private:
+ ::comphelper::ComponentContext m_aContext;
+ ::cppu::OInterfaceContainerHelper m_aHandlers;
+ oslInterlockedCount m_nEventNumber;
+
+ // <attributes>
+ sal_Int32 m_nLogLevel;
+ ::rtl::OUString m_sName;
+ // </attributes>
+
+ public:
+ EventLogger( const Reference< XComponentContext >& _rxContext, const ::rtl::OUString& _rName );
+
+ // XServiceInfo
+ virtual ::rtl::OUString SAL_CALL getImplementationName() throw(RuntimeException);
+ virtual ::sal_Bool SAL_CALL supportsService( const ::rtl::OUString& _rServiceName ) throw(RuntimeException);
+ virtual Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() throw(RuntimeException);
+
+ // XLogger
+ virtual ::rtl::OUString SAL_CALL getName() throw (RuntimeException);
+ virtual ::sal_Int32 SAL_CALL getLevel() throw (RuntimeException);
+ virtual void SAL_CALL setLevel( ::sal_Int32 _level ) throw (RuntimeException);
+ virtual void SAL_CALL addLogHandler( const Reference< XLogHandler >& LogHandler ) throw (RuntimeException);
+ virtual void SAL_CALL removeLogHandler( const Reference< XLogHandler >& LogHandler ) throw (RuntimeException);
+ virtual ::sal_Bool SAL_CALL isLoggable( ::sal_Int32 _nLevel ) throw (RuntimeException);
+ virtual void SAL_CALL log( ::sal_Int32 Level, const ::rtl::OUString& Message ) throw (RuntimeException);
+ virtual void SAL_CALL logp( ::sal_Int32 Level, const ::rtl::OUString& SourceClass, const ::rtl::OUString& SourceMethod, const ::rtl::OUString& Message ) throw (RuntimeException);
+
+ protected:
+ ~EventLogger();
+
+ private:
+ /** logs the given log record
+ */
+ void impl_ts_logEvent_nothrow( const LogRecord& _rRecord );
+
+ /** non-threadsafe impl-version of isLoggable
+ */
+ bool impl_nts_isLoggable_nothrow( ::sal_Int32 _nLevel );
+ };
+
+ //====================================================================
+ //= LoggerPool - declaration
+ //====================================================================
+ typedef ::cppu::WeakImplHelper2 < XLoggerPool
+ , XServiceInfo
+ > LoggerPool_Base;
+ /** administrates a pool of XLogger instances, where a logger is keyed by its name,
+ and subsequent requests for a logger with the same name return the same instance.
+ */
+ class LoggerPool : public LoggerPool_Base
+ {
+ private:
+ typedef ::std::map< ::rtl::OUString, WeakReference< XLogger > > ImplPool;
+
+ private:
+ ::osl::Mutex m_aMutex;
+ ::comphelper::ComponentContext m_aContext;
+ ImplPool m_aImpl;
+
+ public:
+ LoggerPool( const Reference< XComponentContext >& _rxContext );
+
+ // XServiceInfo
+ virtual ::rtl::OUString SAL_CALL getImplementationName() throw(RuntimeException);
+ virtual ::sal_Bool SAL_CALL supportsService( const ::rtl::OUString& _rServiceName ) throw(RuntimeException);
+ virtual Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() throw(RuntimeException);
+
+ // helper for factories
+ static Sequence< ::rtl::OUString > getSupportedServiceNames_static();
+ static ::rtl::OUString getImplementationName_static();
+ static ::rtl::OUString getSingletonName_static();
+ static Reference< XInterface > Create( const Reference< XComponentContext >& _rxContext );
+
+ // XLoggerPool
+ virtual Reference< XLogger > SAL_CALL getNamedLogger( const ::rtl::OUString& Name ) throw (RuntimeException);
+ virtual Reference< XLogger > SAL_CALL getDefaultLogger( ) throw (RuntimeException);
+ };
+
+ //====================================================================
+ //= EventLogger - implementation
+ //====================================================================
+ //--------------------------------------------------------------------
+ EventLogger::EventLogger( const Reference< XComponentContext >& _rxContext, const ::rtl::OUString& _rName )
+ :m_aContext( _rxContext )
+ ,m_aHandlers( m_aMutex )
+ ,m_nEventNumber( 0 )
+ ,m_nLogLevel( LogLevel::OFF )
+ ,m_sName( _rName )
+ {
+ osl_incrementInterlockedCount( &m_refCount );
+ {
+ initializeLoggerFromConfiguration( m_aContext, this );
+ }
+ osl_decrementInterlockedCount( &m_refCount );
+ }
+
+ //--------------------------------------------------------------------
+ EventLogger::~EventLogger()
+ {
+ }
+
+ //--------------------------------------------------------------------
+ bool EventLogger::impl_nts_isLoggable_nothrow( ::sal_Int32 _nLevel )
+ {
+ if ( _nLevel < m_nLogLevel )
+ return false;
+
+ if ( !m_aHandlers.getLength() )
+ return false;
+
+ return true;
+ }
+
+ //--------------------------------------------------------------------
+ void EventLogger::impl_ts_logEvent_nothrow( const LogRecord& _rRecord )
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ if ( !impl_nts_isLoggable_nothrow( _rRecord.Level ) )
+ return;
+
+ m_aHandlers.forEach< XLogHandler >(
+ ::boost::bind( &XLogHandler::publish, _1, ::boost::cref( _rRecord ) ) );
+ m_aHandlers.forEach< XLogHandler >(
+ ::boost::bind( &XLogHandler::flush, _1 ) );
+ }
+
+ //--------------------------------------------------------------------
+ ::rtl::OUString SAL_CALL EventLogger::getName() throw (RuntimeException)
+ {
+ return m_sName;
+ }
+
+ //--------------------------------------------------------------------
+ ::sal_Int32 SAL_CALL EventLogger::getLevel() throw (RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ return m_nLogLevel;
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL EventLogger::setLevel( ::sal_Int32 _level ) throw (RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ m_nLogLevel = _level;
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL EventLogger::addLogHandler( const Reference< XLogHandler >& _rxLogHandler ) throw (RuntimeException)
+ {
+ if ( _rxLogHandler.is() )
+ m_aHandlers.addInterface( _rxLogHandler );
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL EventLogger::removeLogHandler( const Reference< XLogHandler >& _rxLogHandler ) throw (RuntimeException)
+ {
+ if ( _rxLogHandler.is() )
+ m_aHandlers.removeInterface( _rxLogHandler );
+ }
+
+ //--------------------------------------------------------------------
+ ::sal_Bool SAL_CALL EventLogger::isLoggable( ::sal_Int32 _nLevel ) throw (RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ return impl_nts_isLoggable_nothrow( _nLevel );
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL EventLogger::log( ::sal_Int32 _nLevel, const ::rtl::OUString& _rMessage ) throw (RuntimeException)
+ {
+ impl_ts_logEvent_nothrow( createLogRecord(
+ m_sName,
+ _rMessage,
+ _nLevel,
+ osl_incrementInterlockedCount( &m_nEventNumber )
+ ) );
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL EventLogger::logp( ::sal_Int32 _nLevel, const ::rtl::OUString& _rSourceClass, const ::rtl::OUString& _rSourceMethod, const ::rtl::OUString& _rMessage ) throw (RuntimeException)
+ {
+ impl_ts_logEvent_nothrow( createLogRecord(
+ m_sName,
+ _rSourceClass,
+ _rSourceMethod,
+ _rMessage,
+ _nLevel,
+ osl_incrementInterlockedCount( &m_nEventNumber )
+ ) );
+ }
+
+ //--------------------------------------------------------------------
+ ::rtl::OUString SAL_CALL EventLogger::getImplementationName() throw(RuntimeException)
+ {
+ return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.extensions.EventLogger" ) );
+ }
+
+ //--------------------------------------------------------------------
+ ::sal_Bool EventLogger::supportsService( const ::rtl::OUString& _rServiceName ) throw(RuntimeException)
+ {
+ return lcl_supportsService_nothrow( *this, _rServiceName );
+ }
+
+ //--------------------------------------------------------------------
+ Sequence< ::rtl::OUString > SAL_CALL EventLogger::getSupportedServiceNames() throw(RuntimeException)
+ {
+ Sequence< ::rtl::OUString > aServiceNames(1);
+ aServiceNames[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.logging.Logger" ) );
+ return aServiceNames;
+ }
+
+ //====================================================================
+ //= LoggerPool - implementation
+ //====================================================================
+ //--------------------------------------------------------------------
+ LoggerPool::LoggerPool( const Reference< XComponentContext >& _rxContext )
+ :m_aContext( _rxContext )
+ {
+ }
+
+ //--------------------------------------------------------------------
+ ::rtl::OUString SAL_CALL LoggerPool::getImplementationName() throw(RuntimeException)
+ {
+ return getImplementationName_static();
+ }
+
+ //--------------------------------------------------------------------
+ ::sal_Bool SAL_CALL LoggerPool::supportsService( const ::rtl::OUString& _rServiceName ) throw(RuntimeException)
+ {
+ return lcl_supportsService_nothrow( *this, _rServiceName );
+ }
+
+ //--------------------------------------------------------------------
+ Sequence< ::rtl::OUString > SAL_CALL LoggerPool::getSupportedServiceNames() throw(RuntimeException)
+ {
+ return getSupportedServiceNames_static();
+ }
+
+ //--------------------------------------------------------------------
+ ::rtl::OUString SAL_CALL LoggerPool::getImplementationName_static()
+ {
+ return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.extensions.LoggerPool" ) );
+ }
+
+ //--------------------------------------------------------------------
+ Sequence< ::rtl::OUString > SAL_CALL LoggerPool::getSupportedServiceNames_static()
+ {
+ Sequence< ::rtl::OUString > aServiceNames(1);
+ aServiceNames[0] = getSingletonName_static();
+ return aServiceNames;
+ }
+
+ //--------------------------------------------------------------------
+ ::rtl::OUString LoggerPool::getSingletonName_static()
+ {
+ return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.logging.LoggerPool" ) );
+ }
+
+ //--------------------------------------------------------------------
+ Reference< XInterface > SAL_CALL LoggerPool::Create( const Reference< XComponentContext >& _rxContext )
+ {
+ return *( new LoggerPool( _rxContext ) );
+ }
+
+ //--------------------------------------------------------------------
+ Reference< XLogger > SAL_CALL LoggerPool::getNamedLogger( const ::rtl::OUString& _rName ) throw (RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ WeakReference< XLogger >& rLogger( m_aImpl[ _rName ] );
+ Reference< XLogger > xLogger( (Reference< XLogger >)rLogger );
+ if ( !xLogger.is() )
+ {
+ // never requested before, or already dead
+ xLogger = new EventLogger( m_aContext.getUNOContext(), _rName );
+ rLogger = xLogger;
+ }
+
+ return xLogger;
+ }
+
+ //--------------------------------------------------------------------
+ Reference< XLogger > SAL_CALL LoggerPool::getDefaultLogger( ) throw (RuntimeException)
+ {
+ return getNamedLogger( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "org.openoffice.logging.DefaultLogger" ) ) );
+ }
+
+ //--------------------------------------------------------------------
+ void createRegistryInfo_LoggerPool()
+ {
+ static OSingletonRegistration< LoggerPool > aAutoRegistration;
+ }
+
+//........................................................................
+} // namespace logging
+//........................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/logging/loggerconfig.cxx b/extensions/source/logging/loggerconfig.cxx
new file mode 100644
index 000000000000..e05c93e1ebf9
--- /dev/null
+++ b/extensions/source/logging/loggerconfig.cxx
@@ -0,0 +1,287 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+
+#include "loggerconfig.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/container/XNameContainer.hpp>
+#include <com/sun/star/lang/XSingleServiceFactory.hpp>
+#include <com/sun/star/util/XChangesBatch.hpp>
+#include <com/sun/star/logging/LogLevel.hpp>
+#include <com/sun/star/lang/NullPointerException.hpp>
+#include <com/sun/star/lang/ServiceNotRegisteredException.hpp>
+#include <com/sun/star/beans/NamedValue.hpp>
+#include <com/sun/star/logging/XLogHandler.hpp>
+#include <com/sun/star/logging/XLogFormatter.hpp>
+/** === end UNO includes === **/
+
+#include <tools/diagnose_ex.h>
+
+#include <comphelper/componentcontext.hxx>
+
+#include <cppuhelper/component_context.hxx>
+
+#include <vector>
+#include <sal/macros.h>
+
+//........................................................................
+namespace logging
+{
+//........................................................................
+
+ /** === begin UNO using === **/
+ using ::com::sun::star::uno::Reference;
+ using ::com::sun::star::logging::XLogger;
+ using ::com::sun::star::lang::XMultiServiceFactory;
+ using ::com::sun::star::uno::Sequence;
+ using ::com::sun::star::uno::Any;
+ using ::com::sun::star::container::XNameContainer;
+ using ::com::sun::star::uno::UNO_QUERY_THROW;
+ using ::com::sun::star::lang::XSingleServiceFactory;
+ using ::com::sun::star::uno::XInterface;
+ using ::com::sun::star::util::XChangesBatch;
+ using ::com::sun::star::uno::makeAny;
+ using ::com::sun::star::lang::NullPointerException;
+ using ::com::sun::star::uno::Exception;
+ using ::com::sun::star::lang::ServiceNotRegisteredException;
+ using ::com::sun::star::beans::NamedValue;
+ using ::com::sun::star::logging::XLogHandler;
+ using ::com::sun::star::logging::XLogFormatter;
+ using ::com::sun::star::container::XNameAccess;
+ using ::com::sun::star::uno::XComponentContext;
+ /** === end UNO using === **/
+ namespace LogLevel = ::com::sun::star::logging::LogLevel;
+
+ namespace
+ {
+ //----------------------------------------------------------------
+ typedef void (*SettingTranslation)( const Reference< XLogger >&, const ::rtl::OUString&, Any& );
+
+ //----------------------------------------------------------------
+ void lcl_substituteFileHandlerURLVariables_nothrow( const Reference< XLogger >& _rxLogger, ::rtl::OUString& _inout_rFileURL )
+ {
+ struct Variable
+ {
+ const sal_Char* pVariablePattern;
+ const sal_Int32 nPatternLength;
+ rtl_TextEncoding eEncoding;
+ const ::rtl::OUString sVariableValue;
+
+ Variable( const sal_Char* _pVariablePattern, const sal_Int32 _nPatternLength, rtl_TextEncoding _eEncoding,
+ const ::rtl::OUString& _rVariableValue )
+ :pVariablePattern( _pVariablePattern )
+ ,nPatternLength( _nPatternLength )
+ ,eEncoding( _eEncoding )
+ ,sVariableValue( _rVariableValue )
+ {
+ }
+ };
+
+ ::rtl::OUString sLoggerName;
+ try { sLoggerName = _rxLogger->getName(); }
+ catch( const Exception& ) { DBG_UNHANDLED_EXCEPTION(); }
+
+ Variable aVariables[] =
+ {
+ Variable( RTL_CONSTASCII_USTRINGPARAM( "$(loggername)" ), sLoggerName )
+ };
+
+ for ( size_t i = 0; i < SAL_N_ELEMENTS( aVariables ); ++i )
+ {
+ ::rtl::OUString sPattern( aVariables[i].pVariablePattern, aVariables[i].nPatternLength, aVariables[i].eEncoding );
+ sal_Int32 nVariableIndex = _inout_rFileURL.indexOf( sPattern );
+ if ( ( nVariableIndex == 0 )
+ || ( ( nVariableIndex > 0 )
+ && ( sPattern[ nVariableIndex - 1 ] != '$' )
+ )
+ )
+ {
+ // found an (unescaped) variable
+ _inout_rFileURL = _inout_rFileURL.replaceAt( nVariableIndex, sPattern.getLength(), aVariables[i].sVariableValue );
+ }
+ }
+ }
+
+ //----------------------------------------------------------------
+ void lcl_transformFileHandlerSettings_nothrow( const Reference< XLogger >& _rxLogger, const ::rtl::OUString& _rSettingName, Any& _inout_rSettingValue )
+ {
+ if ( !_rSettingName.equalsAscii( "FileURL" ) )
+ // not interested in this setting
+ return;
+
+ ::rtl::OUString sURL;
+ OSL_VERIFY( _inout_rSettingValue >>= sURL );
+ lcl_substituteFileHandlerURLVariables_nothrow( _rxLogger, sURL );
+ _inout_rSettingValue <<= sURL;
+ }
+
+ //----------------------------------------------------------------
+ Reference< XInterface > lcl_createInstanceFromSetting_throw(
+ const ::comphelper::ComponentContext& _rContext,
+ const Reference< XLogger >& _rxLogger,
+ const Reference< XNameAccess >& _rxLoggerSettings,
+ const sal_Char* _pServiceNameAsciiNodeName,
+ const sal_Char* _pServiceSettingsAsciiNodeName,
+ SettingTranslation _pSettingTranslation = NULL
+ )
+ {
+ Reference< XInterface > xInstance;
+
+ // read the settings for the to-be-created service
+ Reference< XNameAccess > xServiceSettingsNode( _rxLoggerSettings->getByName(
+ ::rtl::OUString::createFromAscii( _pServiceSettingsAsciiNodeName ) ), UNO_QUERY_THROW );
+
+ Sequence< ::rtl::OUString > aSettingNames( xServiceSettingsNode->getElementNames() );
+ size_t nServiceSettingCount( aSettingNames.getLength() );
+ Sequence< NamedValue > aSettings( nServiceSettingCount );
+ if ( nServiceSettingCount )
+ {
+ const ::rtl::OUString* pSettingNames = aSettingNames.getConstArray();
+ const ::rtl::OUString* pSettingNamesEnd = aSettingNames.getConstArray() + aSettingNames.getLength();
+ NamedValue* pSetting = aSettings.getArray();
+
+ for ( ;
+ pSettingNames != pSettingNamesEnd;
+ ++pSettingNames, ++pSetting
+ )
+ {
+ pSetting->Name = *pSettingNames;
+ pSetting->Value = xServiceSettingsNode->getByName( *pSettingNames );
+
+ if ( _pSettingTranslation )
+ (_pSettingTranslation)( _rxLogger, pSetting->Name, pSetting->Value );
+ }
+ }
+
+ ::rtl::OUString sServiceName;
+ _rxLoggerSettings->getByName( ::rtl::OUString::createFromAscii( _pServiceNameAsciiNodeName ) ) >>= sServiceName;
+ if ( sServiceName.getLength() )
+ {
+ bool bSuccess = false;
+ if ( aSettings.getLength() )
+ {
+ Sequence< Any > aConstructionArgs(1);
+ aConstructionArgs[0] <<= aSettings;
+ bSuccess = _rContext.createComponentWithArguments( sServiceName, aConstructionArgs, xInstance );
+ }
+ else
+ {
+ bSuccess = _rContext.createComponent( sServiceName, xInstance );
+ }
+
+ if ( !bSuccess )
+ throw ServiceNotRegisteredException( sServiceName, NULL );
+ }
+
+ return xInstance;
+ }
+ }
+
+ //--------------------------------------------------------------------
+ void initializeLoggerFromConfiguration( const ::comphelper::ComponentContext& _rContext, const Reference< XLogger >& _rxLogger )
+ {
+ try
+ {
+ if ( !_rxLogger.is() )
+ throw NullPointerException();
+
+ // the configuration provider
+ Reference< XMultiServiceFactory > xConfigProvider;
+ ::rtl::OUString sConfigProvServiceName( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.configuration.ConfigurationProvider" ) );
+ if ( !_rContext.createComponent( sConfigProvServiceName, xConfigProvider ) )
+ throw ServiceNotRegisteredException( sConfigProvServiceName, _rxLogger );
+
+ // write access to the "Settings" node (which includes settings for all loggers)
+ Sequence< Any > aArguments(1);
+ aArguments[0] <<= NamedValue(
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "nodepath" ) ),
+ makeAny( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "/org.openoffice.Office.Logging/Settings" ) ) )
+ );
+ Reference< XNameContainer > xAllSettings( xConfigProvider->createInstanceWithArguments(
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.configuration.ConfigurationUpdateAccess" ) ),
+ aArguments
+ ), UNO_QUERY_THROW );
+
+ ::rtl::OUString sLoggerName( _rxLogger->getName() );
+ if ( !xAllSettings->hasByName( sLoggerName ) )
+ {
+ // no node yet for this logger. Create default settings.
+ Reference< XSingleServiceFactory > xNodeFactory( xAllSettings, UNO_QUERY_THROW );
+ Reference< XInterface > xLoggerSettings( xNodeFactory->createInstance(), UNO_QUERY_THROW );
+ xAllSettings->insertByName( sLoggerName, makeAny( xLoggerSettings ) );
+ Reference< XChangesBatch > xChanges( xAllSettings, UNO_QUERY_THROW );
+ xChanges->commitChanges();
+ }
+
+ // actually read and forward the settings
+ Reference< XNameAccess > xLoggerSettings( xAllSettings->getByName( sLoggerName ), UNO_QUERY_THROW );
+
+ // the log level
+ sal_Int32 nLogLevel( LogLevel::OFF );
+ OSL_VERIFY( xLoggerSettings->getByName( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "LogLevel" ) ) ) >>= nLogLevel );
+ _rxLogger->setLevel( nLogLevel );
+
+ // the default handler, if any
+ Reference< XInterface > xUntyped( lcl_createInstanceFromSetting_throw( _rContext, _rxLogger, xLoggerSettings, "DefaultHandler", "HandlerSettings", &lcl_transformFileHandlerSettings_nothrow ) );
+ if ( !xUntyped.is() )
+ // no handler -> we're done
+ return;
+ Reference< XLogHandler > xHandler( xUntyped, UNO_QUERY_THROW );
+ _rxLogger->addLogHandler( xHandler );
+
+ // The newly created handler might have an own (default) level. Ensure that it uses
+ // the same level as the logger.
+ xHandler->setLevel( nLogLevel );
+
+ // the default formatter for the handler
+ xUntyped = lcl_createInstanceFromSetting_throw( _rContext, _rxLogger, xLoggerSettings, "DefaultFormatter", "FormatterSettings" );
+ if ( !xUntyped.is() )
+ // no formatter -> we're done
+ return;
+ Reference< XLogFormatter > xFormatter( xUntyped, UNO_QUERY_THROW );
+ xHandler->setFormatter( xFormatter );
+
+ // TODO: we could first create the formatter, then the handler. This would allow
+ // passing the formatter as value in the component context, so the handler would
+ // not create an own default formatter
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+
+//........................................................................
+} // namespace logging
+//........................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/logging/loggerconfig.hxx b/extensions/source/logging/loggerconfig.hxx
new file mode 100644
index 000000000000..78157d8ad73a
--- /dev/null
+++ b/extensions/source/logging/loggerconfig.hxx
@@ -0,0 +1,68 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef EXTENSIONS_LOGGERCONFIG_HXX
+#define EXTENSIONS_LOGGERCONFIG_HXX
+
+/** === begin UNO includes === **/
+#include <com/sun/star/logging/XLogger.hpp>
+/** === end UNO includes === **/
+
+namespace comphelper
+{
+ class ComponentContext;
+}
+
+//........................................................................
+namespace logging
+{
+//........................................................................
+
+ /** initializes the given logger from the configuration
+
+ The configuration node /org.openoffice.Office.Logging/Settings/<logger_name>
+ is examined for this. If it does not yet exist, it will be created.
+
+ The function creates a default handler and a default formatter, as specified in the
+ configuration.
+
+ This function is currently external to the logger instance. Perhaps it can, on the long
+ run, be moved to the logger implementation - not sure if it's the best place.
+ */
+ void initializeLoggerFromConfiguration(
+ const ::comphelper::ComponentContext& _rContext,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::logging::XLogger >& _rxLogger
+ );
+
+//........................................................................
+} // namespace logging
+//........................................................................
+
+#endif // EXTENSIONS_LOGGERCONFIG_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/logging/loghandler.cxx b/extensions/source/logging/loghandler.cxx
new file mode 100644
index 000000000000..a2c7411b390b
--- /dev/null
+++ b/extensions/source/logging/loghandler.cxx
@@ -0,0 +1,204 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+
+#include "loghandler.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/logging/LogLevel.hpp>
+#include <com/sun/star/lang/IllegalArgumentException.hpp>
+#include <com/sun/star/lang/DisposedException.hpp>
+#include <com/sun/star/logging/PlainTextFormatter.hpp>
+/** === end UNO includes === **/
+
+#include <tools/diagnose_ex.h>
+#include <comphelper/componentcontext.hxx>
+#include <rtl/tencinfo.h>
+
+//........................................................................
+namespace logging
+{
+//........................................................................
+
+ /** === begin UNO using === **/
+ using ::com::sun::star::uno::Reference;
+ using ::com::sun::star::uno::XComponentContext;
+ using ::com::sun::star::uno::Any;
+ using ::com::sun::star::logging::LogRecord;
+ using ::com::sun::star::uno::UNO_QUERY_THROW;
+ using ::com::sun::star::logging::XLogFormatter;
+ using ::com::sun::star::uno::Exception;
+ using ::com::sun::star::lang::IllegalArgumentException;
+ using ::com::sun::star::lang::DisposedException;
+ using ::com::sun::star::logging::PlainTextFormatter;
+ /** === end UNO using === **/
+ namespace LogLevel = ::com::sun::star::logging::LogLevel;
+
+ //====================================================================
+ //= LogHandlerHelper
+ //====================================================================
+ //--------------------------------------------------------------------
+ LogHandlerHelper::LogHandlerHelper( const Reference< XComponentContext >& _rxContext, ::osl::Mutex& _rMutex, ::cppu::OBroadcastHelper& _rBHelper )
+ :m_eEncoding( RTL_TEXTENCODING_UTF8 )
+ ,m_nLevel( LogLevel::SEVERE )
+ ,m_xFormatter( NULL )
+ ,m_xContext( _rxContext )
+ ,m_rMutex( _rMutex )
+ ,m_rBHelper( _rBHelper )
+ ,m_bInitialized( false )
+ {
+ }
+
+ //--------------------------------------------------------------------
+ void LogHandlerHelper::initFromSettings( const ::comphelper::NamedValueCollection& _rSettings )
+ {
+ ::rtl::OUString sEncoding;
+ if ( _rSettings.get_ensureType( "Encoding", sEncoding ) )
+ {
+ if ( !setEncoding( sEncoding ) )
+ throw IllegalArgumentException();
+ }
+
+ _rSettings.get_ensureType( "Formatter", m_xFormatter );
+ _rSettings.get_ensureType( "Level", m_nLevel );
+ }
+
+ //--------------------------------------------------------------------
+ void LogHandlerHelper::enterMethod()
+ {
+ m_rMutex.acquire();
+
+ if ( !getIsInitialized() )
+ throw DisposedException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "component not initialized" ) ), NULL );
+
+ if ( m_rBHelper.bDisposed )
+ throw DisposedException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "component already disposed" ) ), NULL );
+
+ // fallback settings, in case they weren't passed at construction time
+ if ( !getFormatter().is() )
+ {
+ try
+ {
+ Reference< XLogFormatter > xFormatter( PlainTextFormatter::create( m_xContext ), UNO_QUERY_THROW );
+ setFormatter( xFormatter );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+ }
+
+ //--------------------------------------------------------------------
+ bool LogHandlerHelper::getEncoding( ::rtl::OUString& _out_rEncoding ) const
+ {
+ const char* pMimeCharset = rtl_getMimeCharsetFromTextEncoding( m_eEncoding );
+ if ( pMimeCharset )
+ {
+ _out_rEncoding = ::rtl::OUString::createFromAscii( pMimeCharset );
+ return true;
+ }
+ _out_rEncoding = ::rtl::OUString();
+ return false;
+ }
+
+ //--------------------------------------------------------------------
+ bool LogHandlerHelper::setEncoding( const ::rtl::OUString& _rEncoding )
+ {
+ ::rtl::OString sAsciiEncoding( ::rtl::OUStringToOString( _rEncoding, RTL_TEXTENCODING_ASCII_US ) );
+ rtl_TextEncoding eEncoding = rtl_getTextEncodingFromMimeCharset( sAsciiEncoding.getStr() );
+ if ( eEncoding != RTL_TEXTENCODING_DONTKNOW )
+ {
+ m_eEncoding = eEncoding;
+ return true;
+ }
+ return false;
+ }
+
+ //--------------------------------------------------------------------
+ bool LogHandlerHelper::formatForPublishing( const LogRecord& _rRecord, ::rtl::OString& _out_rEntry ) const
+ {
+ if ( _rRecord.Level < getLevel() )
+ // not to be published due to low level
+ return false;
+
+ try
+ {
+ Reference< XLogFormatter > xFormatter( getFormatter(), UNO_QUERY_THROW );
+ ::rtl::OUString sEntry( xFormatter->format( _rRecord ) );
+ _out_rEntry = ::rtl::OUStringToOString( sEntry, getTextEncoding() );
+ return true;
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ return false;
+ }
+
+ //--------------------------------------------------------------------
+ bool LogHandlerHelper::getEncodedHead( ::rtl::OString& _out_rHead ) const
+ {
+ try
+ {
+ Reference< XLogFormatter > xFormatter( getFormatter(), UNO_QUERY_THROW );
+ ::rtl::OUString sHead( xFormatter->getHead() );
+ _out_rHead = ::rtl::OUStringToOString( sHead, getTextEncoding() );
+ return true;
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ return false;
+ }
+
+ //--------------------------------------------------------------------
+ bool LogHandlerHelper::getEncodedTail( ::rtl::OString& _out_rTail ) const
+ {
+ try
+ {
+ Reference< XLogFormatter > xFormatter( getFormatter(), UNO_QUERY_THROW );
+ ::rtl::OUString sTail( xFormatter->getTail() );
+ _out_rTail = ::rtl::OUStringToOString( sTail, getTextEncoding() );
+ return true;
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ return false;
+ }
+
+//........................................................................
+} // namespace logging
+//........................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/logging/loghandler.hxx b/extensions/source/logging/loghandler.hxx
new file mode 100644
index 000000000000..34f93d4c2824
--- /dev/null
+++ b/extensions/source/logging/loghandler.hxx
@@ -0,0 +1,157 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef LOGHANDLER_HXX
+#define LOGHANDLER_HXX
+
+/** === begin UNO includes === **/
+#include <com/sun/star/logging/XLogFormatter.hpp>
+#include <com/sun/star/uno/XComponentContext.hpp>
+#include <com/sun/star/logging/LogRecord.hpp>
+/** === end UNO includes === **/
+
+#include <comphelper/namedvaluecollection.hxx>
+#include <cppuhelper/interfacecontainer.hxx>
+#include <rtl/string.hxx>
+
+//........................................................................
+namespace logging
+{
+//........................................................................
+
+ //====================================================================
+ //=
+ //====================================================================
+ class LogHandlerHelper
+ {
+ private:
+ // <attributes>
+ rtl_TextEncoding m_eEncoding;
+ sal_Int32 m_nLevel;
+ ::com::sun::star::uno::Reference< ::com::sun::star::logging::XLogFormatter >
+ m_xFormatter;
+ // <//attributes>
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >
+ m_xContext;
+ ::osl::Mutex& m_rMutex;
+ ::cppu::OBroadcastHelper& m_rBHelper;
+ bool m_bInitialized;
+
+ public:
+ LogHandlerHelper(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _rxContext,
+ ::osl::Mutex& _rMutex,
+ ::cppu::OBroadcastHelper& _rBHelper
+ );
+
+ public:
+ bool getIsInitialized() const { return m_bInitialized; }
+ void setIsInitialized() { m_bInitialized = true; }
+
+ bool getEncoding( ::rtl::OUString& _out_rEncoding ) const;
+ bool setEncoding( const ::rtl::OUString& _rEncoding );
+
+ inline rtl_TextEncoding
+ getTextEncoding() const { return m_eEncoding; }
+
+ inline ::com::sun::star::uno::Reference< ::com::sun::star::logging::XLogFormatter >
+ getFormatter() const { return m_xFormatter; }
+ inline void
+ setFormatter( const ::com::sun::star::uno::Reference< ::com::sun::star::logging::XLogFormatter >& _rxFormatter )
+ {
+ m_xFormatter = _rxFormatter;
+ }
+
+ inline sal_Int32
+ getLevel() const { return m_nLevel; }
+ inline void
+ setLevel( const sal_Int32 _nLevel )
+ {
+ m_nLevel = _nLevel;
+ }
+
+ /** prepares implementation of an public accessible method of a log handler
+
+ <code>enterMethod</code> does the following things:
+ <ul><li>It acquires the mutex given in the constructor.</li>
+ <li>It checks whether the component is already initialized, and throws an exception if not os.</li>
+ <li>It checks whether the component is already disposed, and throws an exception if not os.</li>
+ <li>It creates a default formatter (PlainTextFormatter), if no formatter exists at this time.</li>
+ </ul>
+ */
+ void enterMethod();
+
+ /** formats a record for publishing it
+
+ The method first checks whether the records log level is greater or equal our own
+ log level. If not, <FALSE/> is returned.
+
+ Second, our formatter is used to create a unicode string from the log record. If an error occurs
+ during this, e.g. if the formatter is <NULL/> or throws an exception during formatting,
+ <FALSE/> is returned.
+
+ Finally, the unicode string is encoded into a byte string, using our encoding setting. Then,
+ <TRUE/> is returned.
+ */
+ bool formatForPublishing( const ::com::sun::star::logging::LogRecord& _rRecord, ::rtl::OString& _out_rEntry ) const;
+
+ /** retrieves our formatter's heading, encoded with our encoding
+
+ @return <TRUE/> in case of success, <FALSE/> if any error occured
+ */
+ bool getEncodedHead( ::rtl::OString& _out_rHead ) const;
+
+ /** retrieves our formatter's tail, encoded with our encoding
+
+ @return <TRUE/> in case of success, <FALSE/> if any error occured
+ */
+ bool getEncodedTail( ::rtl::OString& _out_rTail ) const;
+
+ /** initializes the instance from a collection of named settings
+
+ The recognized named settings are <code>Encoding</code>, <code>Formatter</code>, and <code>Level</code>,
+ which initialize the respective attributes.
+
+ Settings which are recognized are remove from the given collection. This allows
+ the caller to determine whether or not the collection contained any unsupported
+ items, and react appropriately.
+
+ @throws IllegalArgumentException
+ if one of the values in the collection is of wrong type.
+ */
+ void initFromSettings( const ::comphelper::NamedValueCollection& _rSettings );
+ };
+
+//........................................................................
+} // namespace logging
+//........................................................................
+
+#endif // LOGHANDLER_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/logging/logrecord.cxx b/extensions/source/logging/logrecord.cxx
new file mode 100644
index 000000000000..8ff2f94b1af1
--- /dev/null
+++ b/extensions/source/logging/logrecord.cxx
@@ -0,0 +1,105 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+#include "logrecord.hxx"
+
+/** === begin UNO includes === **/
+/** === end UNO includes === **/
+
+#include <osl/time.h>
+#include <osl/thread.h>
+#include <osl/diagnose.h>
+
+//........................................................................
+namespace logging
+{
+//........................................................................
+
+ /** === begin UNO using === **/
+ using ::com::sun::star::logging::LogRecord;
+ using ::com::sun::star::util::DateTime;
+ /** === end UNO using === **/
+
+ //====================================================================
+ //= helper
+ //====================================================================
+ //--------------------------------------------------------------------
+ namespace
+ {
+ /** returns a string representation of the current thread
+
+ @todo
+ We need a way to retrieve the current UNO thread ID as string,
+ which is issue #i77342#
+ */
+ ::rtl::OUString getCurrentThreadID()
+ {
+ oslThreadIdentifier nThreadID( osl_getThreadIdentifier( NULL ) );
+ return ::rtl::OUString::valueOf( (sal_Int64)nThreadID );
+ }
+ }
+
+ //--------------------------------------------------------------------
+ LogRecord createLogRecord( const ::rtl::OUString& _rLoggerName, const ::rtl::OUString& _rClassName,
+ const ::rtl::OUString& _rMethodName, const ::rtl::OUString& _rMessage,
+ sal_Int32 _nLogLevel, oslInterlockedCount _nEventNumber )
+ {
+ TimeValue aTimeValue;
+ osl_getSystemTime( &aTimeValue );
+
+ oslDateTime aDateTime;
+ OSL_VERIFY( osl_getDateTimeFromTimeValue( &aTimeValue, &aDateTime ) );
+
+ DateTime aTimeStamp;
+ aTimeStamp.Year = aDateTime.Year;
+ aTimeStamp.Month = aDateTime.Month;
+ aTimeStamp.Day = aDateTime.Day;
+ aTimeStamp.Hours = aDateTime.Hours;
+ aTimeStamp.Minutes = aDateTime.Minutes;
+ aTimeStamp.Seconds = aDateTime.Seconds;
+ aTimeStamp.HundredthSeconds = ::sal::static_int_cast< sal_Int16 >( aDateTime.NanoSeconds / 10000000 );
+
+ return LogRecord(
+ _rLoggerName,
+ _rClassName,
+ _rMethodName,
+ _rMessage,
+ aTimeStamp,
+ _nEventNumber,
+ getCurrentThreadID(),
+ _nLogLevel
+ );
+ }
+
+//........................................................................
+} // namespace logging
+//........................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/logging/logrecord.hxx b/extensions/source/logging/logrecord.hxx
new file mode 100644
index 000000000000..53c8f49f7d07
--- /dev/null
+++ b/extensions/source/logging/logrecord.hxx
@@ -0,0 +1,71 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef LOGRECORD_HXX
+#define LOGRECORD_HXX
+
+/** === begin UNO includes === **/
+#include <com/sun/star/logging/LogRecord.hpp>
+/** === end UNO includes === **/
+
+#include <osl/interlck.h>
+
+//........................................................................
+namespace logging
+{
+//........................................................................
+
+ //====================================================================
+ //= helper
+ //====================================================================
+ ::com::sun::star::logging::LogRecord createLogRecord(
+ const ::rtl::OUString& _rLoggerName,
+ const ::rtl::OUString& _rClassName,
+ const ::rtl::OUString& _rMethodName,
+ const ::rtl::OUString& _rMessage,
+ sal_Int32 _nLogLevel,
+ oslInterlockedCount _nEventNumber
+ );
+
+ inline ::com::sun::star::logging::LogRecord createLogRecord(
+ const ::rtl::OUString& _rLoggerName,
+ const ::rtl::OUString& _rMessage,
+ sal_Int32 _nLogLevel,
+ oslInterlockedCount _nEventNumber
+ )
+ {
+ return createLogRecord( _rLoggerName, ::rtl::OUString(), ::rtl::OUString(), _rMessage, _nLogLevel, _nEventNumber );
+ }
+
+//........................................................................
+} // namespace logging
+//........................................................................
+
+#endif // LOGRECORD_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/logging/makefile.mk b/extensions/source/logging/makefile.mk
new file mode 100644
index 000000000000..4a1fa9813cb0
--- /dev/null
+++ b/extensions/source/logging/makefile.mk
@@ -0,0 +1,76 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ=..$/..
+PRJNAME=extensions
+TARGET=log
+
+# --- Settings ----------------------------------
+
+.INCLUDE : settings.mk
+
+# --- Files -------------------------------------
+
+# ... object files ............................
+EXCEPTIONSFILES= \
+ $(SLO)$/consolehandler.obj \
+ $(SLO)$/csvformatter.obj \
+ $(SLO)$/filehandler.obj \
+ $(SLO)$/log_services.obj \
+ $(SLO)$/logger.obj \
+ $(SLO)$/loggerconfig.obj \
+ $(SLO)$/loghandler.obj \
+ $(SLO)$/plaintextformatter.obj \
+
+SLOFILES= \
+ $(EXCEPTIONSFILES) \
+ $(SLO)$/log_module.obj \
+ $(SLO)$/logrecord.obj \
+
+# --- library -----------------------------------
+
+LIB1TARGET=$(SLB)$/$(TARGET)_t.lib
+LIB1FILES=\
+ $(SLB)$/$(TARGET).lib
+
+SHL1TARGET=$(TARGET)$(DLLPOSTFIX)
+
+SHL1STDLIBS= \
+ $(COMPHELPERLIB) \
+ $(CPPUHELPERLIB) \
+ $(CPPULIB) \
+ $(SALLIB)
+
+SHL1LIBS=$(LIB1TARGET)
+SHL1DEF=$(MISC)$/$(SHL1TARGET).def
+DEF1NAME=$(SHL1TARGET)
+SHL1VERSIONMAP=$(SOLARENV)/src/component.map
+
+# --- Targets ----------------------------------
+
+.INCLUDE : target.mk
+
diff --git a/extensions/source/logging/methodguard.hxx b/extensions/source/logging/methodguard.hxx
new file mode 100644
index 000000000000..62b37f6706fc
--- /dev/null
+++ b/extensions/source/logging/methodguard.hxx
@@ -0,0 +1,75 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef EXTENSIONS_METHODGUARD_HXX
+#define EXTENSIONS_METHODGUARD_HXX
+
+/** === begin UNO includes === **/
+/** === end UNO includes === **/
+
+//........................................................................
+namespace logging
+{
+//........................................................................
+
+ //====================================================================
+ //= ComponentMethodGuard
+ //====================================================================
+ template < class COMPONENT >
+ class ComponentMethodGuard
+ {
+ private:
+ COMPONENT& m_rHandler;
+
+ public:
+ class Access
+ {
+ private:
+ friend class ComponentMethodGuard;
+ Access() { }
+ };
+
+ public:
+ ComponentMethodGuard( COMPONENT& _rHandler )
+ :m_rHandler( _rHandler )
+ {
+ m_rHandler.enterMethod( Access() );
+ }
+ ~ComponentMethodGuard()
+ {
+ m_rHandler.leaveMethod( Access() );
+ }
+ };
+
+//........................................................................
+} // namespace logging
+//........................................................................
+
+#endif // EXTENSIONS_METHODGUARD_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/logging/plaintextformatter.cxx b/extensions/source/logging/plaintextformatter.cxx
new file mode 100644
index 000000000000..6d5591467960
--- /dev/null
+++ b/extensions/source/logging/plaintextformatter.cxx
@@ -0,0 +1,229 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+
+#include "log_module.hxx"
+
+#include <stdio.h>
+
+/** === begin UNO includes === **/
+#include <com/sun/star/logging/XLogFormatter.hpp>
+#include <com/sun/star/uno/XComponentContext.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+/** === end UNO includes === **/
+
+#include <comphelper/componentcontext.hxx>
+
+#include <cppuhelper/implbase2.hxx>
+
+#include <rtl/ustrbuf.hxx>
+
+#include <osl/thread.h>
+
+//........................................................................
+namespace logging
+{
+//........................................................................
+
+ /** === begin UNO using === **/
+ using ::com::sun::star::logging::XLogFormatter;
+ using ::com::sun::star::uno::XComponentContext;
+ using ::com::sun::star::uno::Reference;
+ using ::com::sun::star::uno::Sequence;
+ using ::com::sun::star::lang::XServiceInfo;
+ using ::com::sun::star::uno::RuntimeException;
+ using ::com::sun::star::logging::LogRecord;
+ using ::com::sun::star::uno::XInterface;
+ /** === end UNO using === **/
+
+ //====================================================================
+ //= PlainTextFormatter - declaration
+ //====================================================================
+ typedef ::cppu::WeakImplHelper2 < XLogFormatter
+ , XServiceInfo
+ > PlainTextFormatter_Base;
+ class PlainTextFormatter : public PlainTextFormatter_Base
+ {
+ private:
+ ::comphelper::ComponentContext m_aContext;
+
+ protected:
+ PlainTextFormatter( const Reference< XComponentContext >& _rxContext );
+ virtual ~PlainTextFormatter();
+
+ // XLogFormatter
+ virtual ::rtl::OUString SAL_CALL getHead( ) throw (RuntimeException);
+ virtual ::rtl::OUString SAL_CALL format( const LogRecord& Record ) throw (RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getTail( ) throw (RuntimeException);
+
+ // XServiceInfo
+ virtual ::rtl::OUString SAL_CALL getImplementationName() throw(RuntimeException);
+ virtual ::sal_Bool SAL_CALL supportsService( const ::rtl::OUString& _rServiceName ) throw(RuntimeException);
+ virtual Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() throw(RuntimeException);
+
+ public:
+ // XServiceInfo - static version
+ static ::rtl::OUString SAL_CALL getImplementationName_static();
+ static Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames_static();
+ static Reference< XInterface > Create( const Reference< XComponentContext >& _rxContext );
+ };
+
+ //====================================================================
+ //= PlainTextFormatter - implementation
+ //====================================================================
+ //--------------------------------------------------------------------
+ PlainTextFormatter::PlainTextFormatter( const Reference< XComponentContext >& _rxContext )
+ :m_aContext( _rxContext )
+ {
+ }
+
+ //--------------------------------------------------------------------
+ PlainTextFormatter::~PlainTextFormatter()
+ {
+ }
+
+ //--------------------------------------------------------------------
+ ::rtl::OUString SAL_CALL PlainTextFormatter::getHead( ) throw (RuntimeException)
+ {
+ ::rtl::OUStringBuffer aHeader;
+ aHeader.appendAscii( " event no" ); // column 1: the event number
+ aHeader.appendAscii( " " );
+ aHeader.appendAscii( "thread " ); // column 2: the thread ID
+ aHeader.appendAscii( " " );
+ aHeader.appendAscii( "date " ); // column 3: date
+ aHeader.appendAscii( " " );
+ aHeader.appendAscii( "time " ); // column 4: time
+ aHeader.appendAscii( " " );
+ aHeader.appendAscii( "(class/method:) message" ); // column 5: class/method/message
+ aHeader.appendAscii( "\n" );
+ return aHeader.makeStringAndClear();
+ }
+
+ //--------------------------------------------------------------------
+ ::rtl::OUString SAL_CALL PlainTextFormatter::format( const LogRecord& _rRecord ) throw (RuntimeException)
+ {
+ char buffer[ 30 ];
+ const int buffer_size = sizeof( buffer );
+ int used = snprintf( buffer, buffer_size, "%10i", (int)_rRecord.SequenceNumber );
+ if ( used >= buffer_size || used < 0 )
+ buffer[ buffer_size - 1 ] = 0;
+
+ ::rtl::OUStringBuffer aLogEntry;
+ aLogEntry.appendAscii( buffer );
+ aLogEntry.appendAscii( " " );
+
+ ::rtl::OString sThreadID( ::rtl::OUStringToOString( _rRecord.ThreadID, osl_getThreadTextEncoding() ) );
+ snprintf( buffer, buffer_size, "%8s", sThreadID.getStr() );
+ aLogEntry.appendAscii( buffer );
+ aLogEntry.appendAscii( " " );
+
+ snprintf( buffer, buffer_size, "%04i-%02i-%02i %02i:%02i:%02i.%02i",
+ (int)_rRecord.LogTime.Year, (int)_rRecord.LogTime.Month, (int)_rRecord.LogTime.Day,
+ (int)_rRecord.LogTime.Hours, (int)_rRecord.LogTime.Minutes, (int)_rRecord.LogTime.Seconds, (int)_rRecord.LogTime.HundredthSeconds );
+ aLogEntry.appendAscii( buffer );
+ aLogEntry.appendAscii( " " );
+
+ if ( _rRecord.SourceClassName.getLength() && _rRecord.SourceMethodName.getLength() )
+ {
+ aLogEntry.append( _rRecord.SourceClassName );
+ aLogEntry.appendAscii( "::" );
+ aLogEntry.append( _rRecord.SourceMethodName );
+ aLogEntry.appendAscii( ": " );
+ }
+
+ aLogEntry.append( _rRecord.Message );
+ aLogEntry.appendAscii( "\n" );
+
+ return aLogEntry.makeStringAndClear();
+ }
+
+ //--------------------------------------------------------------------
+ ::rtl::OUString SAL_CALL PlainTextFormatter::getTail( ) throw (RuntimeException)
+ {
+ // no tail
+ return ::rtl::OUString();
+ }
+
+ //--------------------------------------------------------------------
+ ::sal_Bool SAL_CALL PlainTextFormatter::supportsService( const ::rtl::OUString& _rServiceName ) throw(RuntimeException)
+ {
+ const Sequence< ::rtl::OUString > aServiceNames( getSupportedServiceNames() );
+ for ( const ::rtl::OUString* pServiceNames = aServiceNames.getConstArray();
+ pServiceNames != aServiceNames.getConstArray() + aServiceNames.getLength();
+ ++pServiceNames
+ )
+ if ( _rServiceName == *pServiceNames )
+ return sal_True;
+ return sal_False;
+ }
+
+ //--------------------------------------------------------------------
+ ::rtl::OUString SAL_CALL PlainTextFormatter::getImplementationName() throw(RuntimeException)
+ {
+ return getImplementationName_static();
+ }
+
+ //--------------------------------------------------------------------
+ Sequence< ::rtl::OUString > SAL_CALL PlainTextFormatter::getSupportedServiceNames() throw(RuntimeException)
+ {
+ return getSupportedServiceNames_static();
+ }
+
+ //--------------------------------------------------------------------
+ ::rtl::OUString SAL_CALL PlainTextFormatter::getImplementationName_static()
+ {
+ return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.extensions.PlainTextFormatter" ) );
+ }
+
+ //--------------------------------------------------------------------
+ Sequence< ::rtl::OUString > SAL_CALL PlainTextFormatter::getSupportedServiceNames_static()
+ {
+ Sequence< ::rtl::OUString > aServiceNames(1);
+ aServiceNames[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.logging.PlainTextFormatter" ) );
+ return aServiceNames;
+ }
+
+ //--------------------------------------------------------------------
+ Reference< XInterface > PlainTextFormatter::Create( const Reference< XComponentContext >& _rxContext )
+ {
+ return *( new PlainTextFormatter( _rxContext ) );
+ }
+
+ //--------------------------------------------------------------------
+ void createRegistryInfo_PlainTextFormatter()
+ {
+ static OAutoRegistration< PlainTextFormatter > aAutoRegistration;
+ }
+
+//........................................................................
+} // namespace logging
+//........................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/macosx/spotlight/GetMetadataForFile.m b/extensions/source/macosx/spotlight/GetMetadataForFile.m
new file mode 100644
index 000000000000..40d7850970cc
--- /dev/null
+++ b/extensions/source/macosx/spotlight/GetMetadataForFile.m
@@ -0,0 +1,70 @@
+/*************************************************************************
+*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+*************************************************************************/
+
+#include <CoreFoundation/CoreFoundation.h>
+#include <CoreServices/CoreServices.h>
+#include <Foundation/Foundation.h>
+
+
+#import "OOoSpotlightImporter.h"
+
+
+/* -----------------------------------------------------------------------------
+ Get metadata attributes from file
+
+ This function's job is to extract useful information your file format supports
+ and return it as a dictionary
+ ----------------------------------------------------------------------------- */
+
+Boolean GetMetadataForFile(void* thisInterface,
+ CFMutableDictionaryRef attributes,
+ CFStringRef contentTypeUTI,
+ CFStringRef pathToFile)
+{
+ /* Pull any available metadata from the file at the specified path */
+ /* Return the attribute keys and attribute values in the dict */
+ /* Return TRUE if successful, FALSE if there was no data provided */
+ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+
+ OOoSpotlightImporter *importer = [OOoSpotlightImporter new];
+
+ Boolean importOK = NO;
+ @try {
+ importOK = [importer importDocument:(NSString*)pathToFile
+ contentType:(NSString*)contentTypeUTI
+ attributes:(NSMutableDictionary*)attributes];
+ }
+ @catch (NSException *exception) {
+ NSLog(@"main: Caught %@: %@", [exception name], [exception reason]);
+ }
+
+ [importer release];
+
+ [pool release];
+
+ return importOK;
+}
diff --git a/extensions/source/macosx/spotlight/OOoContentDataParser.h b/extensions/source/macosx/spotlight/OOoContentDataParser.h
new file mode 100644
index 000000000000..b307bb3756cd
--- /dev/null
+++ b/extensions/source/macosx/spotlight/OOoContentDataParser.h
@@ -0,0 +1,61 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+*************************************************************************/
+
+#import <Cocoa/Cocoa.h>
+
+
+@interface OOoContentDataParser : NSObject {
+ // indicates if we are interested in an element's content
+ BOOL shouldReadCharacters;
+
+ // the MD importer's values
+ NSMutableDictionary *mdiValues;
+
+ // all of the text inside a document
+ NSMutableString *textContent;
+
+ // the current element's content
+ NSMutableString *runningTextContent;
+}
+
+- (void)parseXML:(NSData*)data intoDictionary:(NSMutableDictionary*)dict;
+
+// delegates
+- (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qualifiedName attributes:(NSDictionary *)attributeDict;
+
+- (void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName;
+
+- (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string;
+
+- (void)parser:(NSXMLParser *)parser parseErrorOccurred:(NSError *)parseError;
+
+- (void)parserDidEndDocument:(NSXMLParser *)parser;
+
+@end
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/macosx/spotlight/OOoContentDataParser.m b/extensions/source/macosx/spotlight/OOoContentDataParser.m
new file mode 100644
index 000000000000..11c3ec06cfc5
--- /dev/null
+++ b/extensions/source/macosx/spotlight/OOoContentDataParser.m
@@ -0,0 +1,133 @@
+/*************************************************************************
+*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+*************************************************************************/
+
+#import "OOoContentDataParser.h"
+
+@implementation OOoContentDataParser
+
+- (id)init
+{
+ if ((self = [super init]) != nil) {
+ shouldReadCharacters = NO;
+ textContent = nil;
+ runningTextContent = nil;
+
+ return self;
+ }
+
+ return nil;
+}
+
+- (void)parseXML:(NSData*)data intoDictionary:(NSMutableDictionary*)dict
+{
+ mdiValues = dict;
+
+ //NSLog(@"data: %@ %d", data, [data length]);
+
+ //init parser settings
+ shouldReadCharacters = NO;
+
+ NSXMLParser *parser = [[NSXMLParser alloc] initWithData:data];
+
+ [parser setDelegate:self];
+ [parser setShouldResolveExternalEntities:NO];
+ [parser parse];
+
+ [parser release];
+
+ //NSLog(@"finished");
+}
+
+- (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qualifiedName attributes:(NSDictionary *)attributeDict
+{
+ // all text content is stored inside <text:p> elements
+ if ([elementName isEqualToString:@"text:p"] == YES) {
+ runningTextContent = [NSMutableString new];
+ shouldReadCharacters = YES;
+ //NSLog(@"start");
+ } else {
+ return;
+ }
+
+ //NSLog(@"start element %@", elementName);
+}
+
+- (void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName
+{
+ if (shouldReadCharacters == TRUE) {
+ if (textContent == nil) {
+ textContent = [NSMutableString new];
+ } else if ([runningTextContent isEqualToString:@""] == NO) {
+ // separate by whitespace
+ [textContent appendString:@" "];
+ }
+ //NSLog(@"end");
+
+ [textContent appendString:[NSString stringWithString:runningTextContent]];
+ [runningTextContent release];
+ }
+ shouldReadCharacters = NO;
+}
+
+- (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string
+{
+ if (shouldReadCharacters == NO) {
+ return;
+ }
+ //NSLog(string);
+
+ [runningTextContent appendString:string];
+
+ //NSLog(@"currentElement: %@", currentElement);
+ //NSLog(@"read: %@", string);
+
+}
+
+- (void)parser:(NSXMLParser *)parser parseErrorOccurred:(NSError *)parseError
+{
+ //NSLog(@"parsing finished with error");
+ NSLog([NSString stringWithFormat:@"An error occured parsing the document. (Error %i, Description: %@, Line: %i, Column: %i)", [parseError code],
+ [[parser parserError] localizedDescription], [parser lineNumber],
+ [parser columnNumber]]);
+
+ if (runningTextContent != nil) {
+ [runningTextContent release];
+ }
+ if (textContent != nil) {
+ [textContent release];
+ }
+}
+
+- (void)parserDidEndDocument:(NSXMLParser *)parser
+{
+ if (textContent != nil && [textContent length] > 0) {
+ [mdiValues setObject:[NSString stringWithString:textContent] forKey:(NSString*)kMDItemTextContent];
+ [textContent release];
+ }
+}
+
+@end
diff --git a/extensions/source/macosx/spotlight/OOoMetaDataParser.h b/extensions/source/macosx/spotlight/OOoMetaDataParser.h
new file mode 100644
index 000000000000..fdeb61d15c67
--- /dev/null
+++ b/extensions/source/macosx/spotlight/OOoMetaDataParser.h
@@ -0,0 +1,55 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+*************************************************************************/
+
+#import <Cocoa/Cocoa.h>
+
+
+@interface OOoMetaDataParser : NSObject {
+ //indicates if content should be read
+ BOOL shouldReadCharacters;
+ //indicates if the current element is a custom metadata tag
+ BOOL isCustom;
+
+ NSMutableDictionary *metaValues;
+ NSMutableString *textCurrentElement;
+ NSString *customAttribute;
+}
+
+- (void)parseXML:(NSData*)data intoDictionary:(NSMutableDictionary*)dict;
+
+//delegates
+- (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qualifiedName attributes:(NSDictionary *)attributeDict;
+
+- (void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName;
+
+- (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string;
+
+- (void)parser:(NSXMLParser *)parser parseErrorOccurred:(NSError *)parseError;
+@end
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/macosx/spotlight/OOoMetaDataParser.m b/extensions/source/macosx/spotlight/OOoMetaDataParser.m
new file mode 100644
index 000000000000..cddbbd1309e1
--- /dev/null
+++ b/extensions/source/macosx/spotlight/OOoMetaDataParser.m
@@ -0,0 +1,200 @@
+/*************************************************************************
+*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+*************************************************************************/
+
+#import "OOoMetaDataParser.h"
+
+static NSSet *singleValueXMLElements;
+static NSSet *multiValueXMLElements;
+static NSDictionary *metaXML2MDIKeys;
+
+@implementation OOoMetaDataParser
+
++ (void)initialize
+{
+ static BOOL isInitialized = NO;
+
+ if (isInitialized == NO) {
+ //set up the meta elements with only one value
+ NSMutableSet *temp = [NSMutableSet new];
+ [temp addObject:@"dc:title"];
+ [temp addObject:@"dc:description"];
+ [temp addObject:@"meta:user-defined"];
+ singleValueXMLElements = [[NSSet setWithSet:temp] retain];
+
+ //set up the meta elements that can have more than one value
+ [temp removeAllObjects];
+ [temp addObject:@"dc:subject"];
+ [temp addObject:@"meta:keyword"];
+ [temp addObject:@"meta:initial-creator"];
+ [temp addObject:@"dc:creator"];
+ multiValueXMLElements = [[NSSet setWithSet:temp] retain];
+ [temp release];
+
+ //set up the map to store the values with the correct MDI keys
+ NSMutableDictionary *tempDict = [NSMutableDictionary new];
+ [tempDict setObject:(NSString*)kMDItemTitle forKey:@"dc:title"];
+ [tempDict setObject:(NSString*)kMDItemDescription forKey:@"dc:description"];
+ [tempDict setObject:(NSString*)kMDItemKeywords forKey:@"dc:subject"];
+ [tempDict setObject:(NSString*)kMDItemAuthors forKey:@"meta:initial-creator"];
+ [tempDict setObject:(NSString*)kMDItemAuthors forKey:@"dc:creator"];
+ [tempDict setObject:(NSString*)kMDItemKeywords forKey:@"meta:keyword"];
+ [tempDict setObject:@"org_openoffice_opendocument_custominfo1" forKey:@"Info 1"];
+ [tempDict setObject:@"org_openoffice_opendocument_custominfo2" forKey:@"Info 2"];
+ [tempDict setObject:@"org_openoffice_opendocument_custominfo3" forKey:@"Info 3"];
+ [tempDict setObject:@"org_openoffice_opendocument_custominfo4" forKey:@"Info 4"];
+ metaXML2MDIKeys = [[NSDictionary dictionaryWithDictionary:tempDict] retain];
+ [tempDict release];
+
+ isInitialized = YES;
+ }
+}
+
+- (id)init
+{
+ if ((self = [super init]) != nil) {
+ shouldReadCharacters = NO;
+// currentElement = nil;
+ textCurrentElement = nil;
+
+ return self;
+ }
+
+ return nil;
+}
+
+- (void)parseXML:(NSData*)data intoDictionary:(NSMutableDictionary*)dict
+{
+ metaValues = dict;
+
+ //NSLog(@"data: %@ %d", data, [data length]);
+
+ //init parser settings
+ shouldReadCharacters = NO;
+
+ NSXMLParser *parser = [[NSXMLParser alloc] initWithData:data];
+
+ [parser setDelegate:self];
+ [parser setShouldResolveExternalEntities:NO];
+ [parser parse];
+
+ [parser release];
+
+ //NSLog(@"finished parsing meta");
+}
+
+- (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qualifiedName attributes:(NSDictionary *)attributeDict
+{
+// NSLog(@"<%@>", elementName);
+ if ([singleValueXMLElements containsObject:elementName] == YES) {
+ shouldReadCharacters = YES;
+ } else if ([multiValueXMLElements containsObject:elementName] == YES) {
+ shouldReadCharacters = YES;
+ } else {
+ //we are not interested in this element
+ shouldReadCharacters = NO;
+ return;
+ }
+
+ if (shouldReadCharacters == YES) {
+ textCurrentElement = [NSMutableString new];
+ isCustom = [elementName isEqualToString:@"meta:user-defined"];
+ if (isCustom == YES) {
+ customAttribute = [[attributeDict objectForKey:@"meta:name"] retain];
+ //NSLog(customAttribute);
+ }
+ }
+
+ //NSLog(@"start element %@", elementName);
+}
+
+- (void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName
+{
+// NSLog(@"</%@>", elementName);
+ if (shouldReadCharacters == YES) {
+ NSString *mdiName = nil;
+ if (isCustom == YES) {
+ mdiName = (NSString*)[metaXML2MDIKeys objectForKey:customAttribute];
+ } else {
+ mdiName = (NSString*)[metaXML2MDIKeys objectForKey:elementName];
+ }
+ //NSLog(@"mdiName: %@", mdiName);
+
+ if (mdiName == nil) {
+ return;
+ }
+
+ if ([singleValueXMLElements containsObject:elementName] == YES) {
+ [metaValues setObject:textCurrentElement forKey:mdiName];
+ } else {
+ // must be multi-value
+ NSMutableArray *arr = [metaValues objectForKey:mdiName];
+ if (arr == nil) {
+ // we have no array yet, create it
+ arr = [[NSMutableArray new] autorelease];
+ // and store it
+ [metaValues setObject:arr forKey:mdiName];
+ }
+ // only store an element once, no need for duplicates
+ if ([arr containsObject:textCurrentElement] == NO) {
+ [arr addObject:textCurrentElement];
+ }
+ }
+ // cleanup part 1
+ [textCurrentElement release];
+ if (customAttribute != nil) {
+ [customAttribute release];
+ }
+ }
+
+ //cleanup part 2
+ shouldReadCharacters = NO;
+ isCustom = NO;
+}
+
+- (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string
+{
+// NSLog(@"%@", string);
+ if (shouldReadCharacters == NO) {
+ return;
+ }
+
+ // this delegate method might be called several times for a single element,
+ // so we have to collect the received data
+ [textCurrentElement appendString:string];
+
+ //NSLog(@"chars read: %@", string);
+}
+
+- (void)parser:(NSXMLParser *)parser parseErrorOccurred:(NSError *)parseError
+{
+ //NSLog(@"parsing finished with error");
+ NSLog([NSString stringWithFormat:@"Error %i, Description: %@, Line: %i, Column: %i", [parseError code],
+ [[parser parserError] localizedDescription], [parser lineNumber],
+ [parser columnNumber]]);
+}
+
+@end
diff --git a/extensions/source/macosx/spotlight/OOoSpotlightImporter.h b/extensions/source/macosx/spotlight/OOoSpotlightImporter.h
new file mode 100644
index 000000000000..6fec52fae722
--- /dev/null
+++ b/extensions/source/macosx/spotlight/OOoSpotlightImporter.h
@@ -0,0 +1,45 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+*************************************************************************/
+
+#import <Cocoa/Cocoa.h>
+
+#include "unzip.h" //for unzFile
+
+@interface OOoSpotlightImporter : NSObject {
+}
+
+- (BOOL)importDocument:(NSString*)pathToFile contentType:(NSString*)contentTypeUTI attributes:(NSMutableDictionary*)attributes;
+
+- (unzFile)openZipFileAtPath:(NSString*)pathToFile;
+
+- (NSData*)metaDataFileFromZip:(unzFile)unzipFile;
+
+- (NSData*)contentDataFileFromZip:(unzFile)unzipFile;
+@end
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/macosx/spotlight/OOoSpotlightImporter.m b/extensions/source/macosx/spotlight/OOoSpotlightImporter.m
new file mode 100644
index 000000000000..c5918e242bc7
--- /dev/null
+++ b/extensions/source/macosx/spotlight/OOoSpotlightImporter.m
@@ -0,0 +1,235 @@
+/*************************************************************************
+*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+*************************************************************************/
+
+#import "OOoSpotlightImporter.h"
+#import "OOoMetaDataParser.h"
+#import "OOoContentDataParser.h"
+
+#define CASESENSITIVITY (0)
+#define BUFFER_SIZE (4096)
+
+/* a dictionary to hold the UTIs */
+static NSDictionary *uti2kind;
+
+@implementation OOoSpotlightImporter
+
+/* initialize is only called once the first time this class is loaded */
++ (void)initialize
+{
+ static BOOL isInitialized = NO;
+ if (isInitialized == NO) {
+ NSMutableDictionary *temp = [NSMutableDictionary new];
+ [temp setObject:@"OpenOffice.org 1.0 Text" forKey:@"org.openoffice.text"];
+ [temp setObject:@"OpenDocument Text" forKey:@"org.oasis.opendocument.text"];
+ [temp setObject:@"OpenOffice.org 1.0 Spreadsheet" forKey:@"org.openoffice.spreadsheet"];
+ [temp setObject:@"OpenDocument Spreadsheet" forKey:@"org.oasis.opendocument.spreadsheet"];
+ [temp setObject:@"OpenOffice.org 1.0 Presentation" forKey:@"org.openoffice.presentation"];
+ [temp setObject:@"OpenDocument Presentation" forKey:@"org.oasis.opendocument.presentation"];
+ [temp setObject:@"OpenOffice.org 1.0 Drawing" forKey:@"org.openoffice.graphics"];
+ [temp setObject:@"OpenDocument Drawing" forKey:@"org.oasis.opendocument.graphics"];
+ [temp setObject:@"OpenOffice.org 1.0 Master" forKey:@"org.openoffice.text-master"];
+ [temp setObject:@"OpenDocument Master" forKey:@"org.oasis.opendocument.text-master"];
+ [temp setObject:@"OpenOffice.org 1.0 Formula" forKey:@"org.openoffice.formula"];
+ [temp setObject:@"OpenDocument Formula" forKey:@"org.oasis.opendocument.formula"];
+ [temp setObject:@"OpenOffice.org 1.0 Text Template" forKey:@"org.openoffice.text-template"];
+ [temp setObject:@"OpenDocument Text Template" forKey:@"org.oasis.opendocument.text-template"];
+ [temp setObject:@"OpenOffice.org 1.0 Spreadsheet Template" forKey:@"org.openoffice.spreadsheet-template"];
+ [temp setObject:@"OpenDocument Spreadsheet Template" forKey:@"org.oasis.opendocument.spreadsheet-template"];
+ [temp setObject:@"OpenOffice.org 1.0 Presentation Template" forKey:@"org.openoffice.presentation-template"];
+ [temp setObject:@"OpenDocument Presentation Template" forKey:@"org.oasis.opendocument.presentation-template"];
+ [temp setObject:@"OpenOffice.org 1.0 Drawing Template" forKey:@"org.openoffice.graphics-template"];
+ [temp setObject:@"OpenDocument Drawing Template" forKey:@"org.oasis.opendocument.graphics-template"];
+ [temp setObject:@"OpenOffice.org 1.0 Database" forKey:@"org.openoffice.database"];
+ [temp setObject:@"OpenDocument Chart" forKey:@"org.oasis.opendocument.chart"];
+
+ uti2kind = [[NSDictionary dictionaryWithDictionary:temp] retain];
+ [temp release];
+
+ isInitialized = YES;
+ }
+}
+
+/* importDocument is the real starting point for our plugin */
+- (BOOL)importDocument:(NSString*)pathToFile contentType:(NSString*)contentTypeUTI attributes:(NSMutableDictionary*)attributes
+{
+ //NSLog(contentTypeUTI);
+ //NSLog(pathToFile);
+
+ NSString *itemKind = [uti2kind objectForKey:contentTypeUTI];
+ if (itemKind != nil) {
+ [attributes setObject:itemKind forKey:(NSString*)kMDItemKind];
+ }
+
+ //first check to see if this is a valid zipped file that contains a file "meta.xml"
+ unzFile unzipFile = [self openZipFileAtPath:pathToFile];
+
+ //
+ if (unzipFile == nil) {
+ //NSLog(@"zip file not open");
+ return YES;
+ }
+
+ //first get the metadata
+ NSData *metaData = [self metaDataFileFromZip:unzipFile];
+ if (metaData == nil) {
+ unzClose(unzipFile);
+ return YES;
+ }
+
+ [metaData retain];
+
+ OOoMetaDataParser *parser = [OOoMetaDataParser new];
+ if (parser != nil) {
+ //parse and extract the data
+ [parser parseXML:metaData intoDictionary:attributes];
+ }
+
+ [metaData release];
+ [parser release];
+
+ //and now get the content
+ NSData *contentData = [self contentDataFileFromZip:unzipFile];
+ if (contentData == nil) {
+ unzClose(unzipFile);
+ return YES;
+ }
+
+ [contentData retain];
+
+ OOoContentDataParser *parser2 = [OOoContentDataParser new];
+ if (parser2 != nil) {
+ //parse and extract the data
+ [parser2 parseXML:contentData intoDictionary:attributes];
+ }
+
+ [contentData release];
+ [parser2 release];
+
+ unzClose(unzipFile);
+
+ return YES;
+}
+
+/* openZipFileAtPath returns the file as a valid data structure or nil otherwise*/
+- (unzFile)openZipFileAtPath:(NSString*)pathToFile
+{
+ unzFile unzipFile = nil;
+
+ const char *zipfilename = [pathToFile UTF8String];
+
+ if (zipfilename != nil)
+ {
+ unzipFile = unzOpen(zipfilename);
+ }
+
+ if (unzipFile == nil)
+ {
+ //NSLog(@"Cannot open %s",zipfilename);
+ return nil;
+ }
+
+ //NSLog(@"%s opened",zipfilename);
+
+ return unzipFile;
+}
+
+/* metaDataFileFromZip extracts the file meta.xml from the zip file and returns it as an NSData* structure
+ or nil if the metadata is not present */
+- (NSData*) metaDataFileFromZip:(unzFile)unzipFile
+{
+ //search and set the cursor to meta.xml
+ if (unzLocateFile(unzipFile, "meta.xml", CASESENSITIVITY) != UNZ_OK) {
+ //we hit an error, do cleanup
+ unzCloseCurrentFile(unzipFile);
+ return nil;
+ }
+
+ //open the current file
+ if (unzOpenCurrentFile(unzipFile) != UNZ_OK) {
+ //we hit an error, do cleanup
+ unzCloseCurrentFile(unzipFile);
+ unzClose(unzipFile);
+ return nil;
+ }
+
+ NSMutableData *data = [NSMutableData new];
+
+ unsigned buffer[BUFFER_SIZE];
+ int bytesRead = 0;
+ while ((bytesRead = unzReadCurrentFile(unzipFile, buffer, sizeof(buffer))) > 0) {
+ //append the data until we are finished
+ [data appendData:[NSData dataWithBytes:(const void *)buffer length:bytesRead]];
+ }
+
+ //we no longer need the file, so close it
+ unzCloseCurrentFile(unzipFile);
+
+ NSData *returnValue = [NSData dataWithData:data];
+ [data release];
+
+ return returnValue;
+}
+
+/* contentDataFileFromZip extracts the file content.xml from the zip file and returns it as an NSData* structure
+ or nil if the metadata is not present */
+- (NSData*) contentDataFileFromZip:(unzFile)unzipFile
+{
+ //search and set the cursor to content.xml
+ if (unzLocateFile(unzipFile, "content.xml", CASESENSITIVITY) != UNZ_OK) {
+ //we hit an error, do cleanup
+ unzCloseCurrentFile(unzipFile);
+ return nil;
+ }
+
+ //open the current file
+ if (unzOpenCurrentFile(unzipFile) != UNZ_OK) {
+ //we hit an error, do cleanup
+ unzCloseCurrentFile(unzipFile);
+ unzClose(unzipFile);
+ return nil;
+ }
+
+ NSMutableData *data = [NSMutableData new];
+
+ unsigned buffer[BUFFER_SIZE];
+ int bytesRead = 0;
+ while ((bytesRead = unzReadCurrentFile(unzipFile, buffer, sizeof(buffer))) > 0) {
+ //append the data
+ [data appendData:[NSData dataWithBytes:(const void *)buffer length:bytesRead]];
+ }
+
+ //we no longer need the file, so close it
+ unzCloseCurrentFile(unzipFile);
+
+ NSData *returnValue = [NSData dataWithData:data];
+ [data release];
+
+ return returnValue;
+}
+
+
+@end
diff --git a/extensions/source/macosx/spotlight/delzip b/extensions/source/macosx/spotlight/delzip
new file mode 100644
index 000000000000..e69de29bb2d1
--- /dev/null
+++ b/extensions/source/macosx/spotlight/delzip
diff --git a/extensions/source/macosx/spotlight/ioapi.h b/extensions/source/macosx/spotlight/ioapi.h
new file mode 100644
index 000000000000..4b10726a7dad
--- /dev/null
+++ b/extensions/source/macosx/spotlight/ioapi.h
@@ -0,0 +1,100 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+*************************************************************************/
+
+/* ioapi.h -- IO base function header for compress/uncompress .zip
+ files using zlib + zip or unzip API
+
+ Version 1.01e, February 12th, 2005
+
+ Copyright (C) 1998-2005 Gilles Vollant
+*/
+
+#ifndef _ZLIBIOAPI_H
+#define _ZLIBIOAPI_H
+
+#include <zlib.h>
+
+#define ZLIB_FILEFUNC_SEEK_CUR (1)
+#define ZLIB_FILEFUNC_SEEK_END (2)
+#define ZLIB_FILEFUNC_SEEK_SET (0)
+
+#define ZLIB_FILEFUNC_MODE_READ (1)
+#define ZLIB_FILEFUNC_MODE_WRITE (2)
+#define ZLIB_FILEFUNC_MODE_READWRITEFILTER (3)
+
+#define ZLIB_FILEFUNC_MODE_EXISTING (4)
+#define ZLIB_FILEFUNC_MODE_CREATE (8)
+
+
+#ifndef ZCALLBACK
+#define ZCALLBACK
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef voidpf (ZCALLBACK *open_file_func) OF((voidpf opaque, const char* filename, int mode));
+typedef uLong (ZCALLBACK *read_file_func) OF((voidpf opaque, voidpf stream, void* buf, uLong size));
+typedef uLong (ZCALLBACK *write_file_func) OF((voidpf opaque, voidpf stream, const void* buf, uLong size));
+typedef long (ZCALLBACK *tell_file_func) OF((voidpf opaque, voidpf stream));
+typedef long (ZCALLBACK *seek_file_func) OF((voidpf opaque, voidpf stream, uLong offset, int origin));
+typedef int (ZCALLBACK *close_file_func) OF((voidpf opaque, voidpf stream));
+typedef int (ZCALLBACK *testerror_file_func) OF((voidpf opaque, voidpf stream));
+
+typedef struct zlib_filefunc_def_s
+{
+ open_file_func zopen_file;
+ read_file_func zread_file;
+ write_file_func zwrite_file;
+ tell_file_func ztell_file;
+ seek_file_func zseek_file;
+ close_file_func zclose_file;
+ testerror_file_func zerror_file;
+ voidpf opaque;
+} zlib_filefunc_def;
+
+
+
+void fill_fopen_filefunc OF((zlib_filefunc_def* pzlib_filefunc_def));
+
+#define ZREAD(filefunc,filestream,buf,size) ((*((filefunc).zread_file))((filefunc).opaque,filestream,buf,size))
+#define ZWRITE(filefunc,filestream,buf,size) ((*((filefunc).zwrite_file))((filefunc).opaque,filestream,buf,size))
+#define ZTELL(filefunc,filestream) ((*((filefunc).ztell_file))((filefunc).opaque,filestream))
+#define ZSEEK(filefunc,filestream,pos,mode) ((*((filefunc).zseek_file))((filefunc).opaque,filestream,pos,mode))
+#define ZCLOSE(filefunc,filestream) ((*((filefunc).zclose_file))((filefunc).opaque,filestream))
+#define ZERROR(filefunc,filestream) ((*((filefunc).zerror_file))((filefunc).opaque,filestream))
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/macosx/spotlight/ioapi.m b/extensions/source/macosx/spotlight/ioapi.m
new file mode 100644
index 000000000000..c1508d7fa0d5
--- /dev/null
+++ b/extensions/source/macosx/spotlight/ioapi.m
@@ -0,0 +1,204 @@
+/*************************************************************************
+*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+*************************************************************************/
+
+/* ioapi.c -- IO base function header for compress/uncompress .zip
+ files using zlib + zip or unzip API
+
+ Version 1.01e, February 12th, 2005
+
+ Copyright (C) 1998-2005 Gilles Vollant
+*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <zlib.h>
+#include "ioapi.h"
+
+
+
+/* I've found an old Unix (a SunOS 4.1.3_U1) without all SEEK_* defined.... */
+
+#ifndef SEEK_CUR
+#define SEEK_CUR 1
+#endif
+
+#ifndef SEEK_END
+#define SEEK_END 2
+#endif
+
+#ifndef SEEK_SET
+#define SEEK_SET 0
+#endif
+
+voidpf ZCALLBACK fopen_file_func OF((
+ voidpf opaque,
+ const char* filename,
+ int mode));
+
+uLong ZCALLBACK fread_file_func OF((
+ voidpf opaque,
+ voidpf stream,
+ void* buf,
+ uLong size));
+
+uLong ZCALLBACK fwrite_file_func OF((
+ voidpf opaque,
+ voidpf stream,
+ const void* buf,
+ uLong size));
+
+long ZCALLBACK ftell_file_func OF((
+ voidpf opaque,
+ voidpf stream));
+
+long ZCALLBACK fseek_file_func OF((
+ voidpf opaque,
+ voidpf stream,
+ uLong offset,
+ int origin));
+
+int ZCALLBACK fclose_file_func OF((
+ voidpf opaque,
+ voidpf stream));
+
+int ZCALLBACK ferror_file_func OF((
+ voidpf opaque,
+ voidpf stream));
+
+
+voidpf ZCALLBACK fopen_file_func (opaque, filename, mode)
+ voidpf opaque;
+ const char* filename;
+ int mode;
+{
+ FILE* file = NULL;
+ const char* mode_fopen = NULL;
+ if ((mode & ZLIB_FILEFUNC_MODE_READWRITEFILTER)==ZLIB_FILEFUNC_MODE_READ)
+ mode_fopen = "rb";
+ else
+ if (mode & ZLIB_FILEFUNC_MODE_EXISTING)
+ mode_fopen = "r+b";
+ else
+ if (mode & ZLIB_FILEFUNC_MODE_CREATE)
+ mode_fopen = "wb";
+
+ if ((filename!=NULL) && (mode_fopen != NULL))
+ file = fopen(filename, mode_fopen);
+ return file;
+}
+
+
+uLong ZCALLBACK fread_file_func (opaque, stream, buf, size)
+ voidpf opaque;
+ voidpf stream;
+ void* buf;
+ uLong size;
+{
+ uLong ret;
+ ret = (uLong)fread(buf, 1, (size_t)size, (FILE *)stream);
+ return ret;
+}
+
+
+uLong ZCALLBACK fwrite_file_func (opaque, stream, buf, size)
+ voidpf opaque;
+ voidpf stream;
+ const void* buf;
+ uLong size;
+{
+ uLong ret;
+ ret = (uLong)fwrite(buf, 1, (size_t)size, (FILE *)stream);
+ return ret;
+}
+
+long ZCALLBACK ftell_file_func (opaque, stream)
+ voidpf opaque;
+ voidpf stream;
+{
+ long ret;
+ ret = ftell((FILE *)stream);
+ return ret;
+}
+
+long ZCALLBACK fseek_file_func (opaque, stream, offset, origin)
+ voidpf opaque;
+ voidpf stream;
+ uLong offset;
+ int origin;
+{
+ int fseek_origin=0;
+ long ret;
+ switch (origin)
+ {
+ case ZLIB_FILEFUNC_SEEK_CUR :
+ fseek_origin = SEEK_CUR;
+ break;
+ case ZLIB_FILEFUNC_SEEK_END :
+ fseek_origin = SEEK_END;
+ break;
+ case ZLIB_FILEFUNC_SEEK_SET :
+ fseek_origin = SEEK_SET;
+ break;
+ default: return -1;
+ }
+ ret = 0;
+ fseek((FILE *)stream, offset, fseek_origin);
+ return ret;
+}
+
+int ZCALLBACK fclose_file_func (opaque, stream)
+ voidpf opaque;
+ voidpf stream;
+{
+ int ret;
+ ret = fclose((FILE *)stream);
+ return ret;
+}
+
+int ZCALLBACK ferror_file_func (opaque, stream)
+ voidpf opaque;
+ voidpf stream;
+{
+ int ret;
+ ret = ferror((FILE *)stream);
+ return ret;
+}
+
+void fill_fopen_filefunc (pzlib_filefunc_def)
+ zlib_filefunc_def* pzlib_filefunc_def;
+{
+ pzlib_filefunc_def->zopen_file = fopen_file_func;
+ pzlib_filefunc_def->zread_file = fread_file_func;
+ pzlib_filefunc_def->zwrite_file = fwrite_file_func;
+ pzlib_filefunc_def->ztell_file = ftell_file_func;
+ pzlib_filefunc_def->zseek_file = fseek_file_func;
+ pzlib_filefunc_def->zclose_file = fclose_file_func;
+ pzlib_filefunc_def->zerror_file = ferror_file_func;
+ pzlib_filefunc_def->opaque = NULL;
+}
diff --git a/extensions/source/macosx/spotlight/main.m b/extensions/source/macosx/spotlight/main.m
new file mode 100644
index 000000000000..b9afc65e0f27
--- /dev/null
+++ b/extensions/source/macosx/spotlight/main.m
@@ -0,0 +1,225 @@
+//
+// main.c
+// SpotlightTester
+//
+// Created by Florian Heckl on 10.07.07.
+// Copyright (c) 2007 __MyCompanyName__. All rights reserved.
+//
+
+
+
+
+
+//==============================================================================
+//
+// DO NO MODIFY THE CONTENT OF THIS FILE
+//
+// This file contains the generic CFPlug-in code necessary for your importer
+// To complete your importer implement the function in GetMetadataForFile.c
+//
+//==============================================================================
+
+
+
+
+
+
+#include <CoreFoundation/CoreFoundation.h>
+#include <CoreFoundation/CFPlugInCOM.h>
+#include <CoreServices/CoreServices.h>
+
+// -----------------------------------------------------------------------------
+// constants
+// -----------------------------------------------------------------------------
+
+
+#define PLUGIN_ID "A3FCC88D-B9A6-4364-8B93-92123C8A2D18"
+
+//
+// Below is the generic glue code for all plug-ins.
+//
+// You should not have to modify this code aside from changing
+// names if you decide to change the names defined in the Info.plist
+//
+
+
+// -----------------------------------------------------------------------------
+// typedefs
+// -----------------------------------------------------------------------------
+
+// The import function to be implemented in GetMetadataForFile.c
+Boolean GetMetadataForFile(void *thisInterface,
+ CFMutableDictionaryRef attributes,
+ CFStringRef contentTypeUTI,
+ CFStringRef pathToFile);
+
+// The layout for an instance of MetaDataImporterPlugIn
+typedef struct __MetadataImporterPluginType
+{
+ MDImporterInterfaceStruct *conduitInterface;
+ CFUUIDRef factoryID;
+ UInt32 refCount;
+} MetadataImporterPluginType;
+
+// -----------------------------------------------------------------------------
+// prototypes
+// -----------------------------------------------------------------------------
+// Forward declaration for the IUnknown implementation.
+//
+
+MetadataImporterPluginType *AllocMetadataImporterPluginType(CFUUIDRef inFactoryID);
+void DeallocMetadataImporterPluginType(MetadataImporterPluginType *thisInstance);
+HRESULT MetadataImporterQueryInterface(void *thisInstance,REFIID iid,LPVOID *ppv);
+void *MetadataImporterPluginFactory(CFAllocatorRef allocator,CFUUIDRef typeID);
+ULONG MetadataImporterPluginAddRef(void *thisInstance);
+ULONG MetadataImporterPluginRelease(void *thisInstance);
+// -----------------------------------------------------------------------------
+// testInterfaceFtbl definition
+// -----------------------------------------------------------------------------
+// The TestInterface function table.
+//
+
+static MDImporterInterfaceStruct testInterfaceFtbl = {
+ NULL,
+ MetadataImporterQueryInterface,
+ MetadataImporterPluginAddRef,
+ MetadataImporterPluginRelease,
+ GetMetadataForFile
+};
+
+
+// -----------------------------------------------------------------------------
+// AllocMetadataImporterPluginType
+// -----------------------------------------------------------------------------
+// Utility function that allocates a new instance.
+// You can do some initial setup for the importer here if you wish
+// like allocating globals etc...
+//
+MetadataImporterPluginType *AllocMetadataImporterPluginType(CFUUIDRef inFactoryID)
+{
+ MetadataImporterPluginType *theNewInstance;
+
+ theNewInstance = (MetadataImporterPluginType *)malloc(sizeof(MetadataImporterPluginType));
+ memset(theNewInstance,0,sizeof(MetadataImporterPluginType));
+
+ /* Point to the function table */
+ theNewInstance->conduitInterface = &testInterfaceFtbl;
+
+ /* Retain and keep an open instance refcount for each factory. */
+ theNewInstance->factoryID = CFRetain(inFactoryID);
+ CFPlugInAddInstanceForFactory(inFactoryID);
+
+ /* This function returns the IUnknown interface so set the refCount to one. */
+ theNewInstance->refCount = 1;
+ return theNewInstance;
+}
+
+// -----------------------------------------------------------------------------
+// DeallocSpotlightTesterMDImporterPluginType
+// -----------------------------------------------------------------------------
+// Utility function that deallocates the instance when
+// the refCount goes to zero.
+// In the current implementation importer interfaces are never deallocated
+// but implement this as this might change in the future
+//
+void DeallocMetadataImporterPluginType(MetadataImporterPluginType *thisInstance)
+{
+ CFUUIDRef theFactoryID;
+
+ theFactoryID = thisInstance->factoryID;
+ free(thisInstance);
+ if (theFactoryID){
+ CFPlugInRemoveInstanceForFactory(theFactoryID);
+ CFRelease(theFactoryID);
+ }
+}
+
+// -----------------------------------------------------------------------------
+// MetadataImporterQueryInterface
+// -----------------------------------------------------------------------------
+// Implementation of the IUnknown QueryInterface function.
+//
+HRESULT MetadataImporterQueryInterface(void *thisInstance,REFIID iid,LPVOID *ppv)
+{
+ CFUUIDRef interfaceID;
+
+ interfaceID = CFUUIDCreateFromUUIDBytes(kCFAllocatorDefault,iid);
+
+ if (CFEqual(interfaceID,kMDImporterInterfaceID)){
+ /* If the Right interface was requested, bump the ref count,
+ * set the ppv parameter equal to the instance, and
+ * return good status.
+ */
+ ((MetadataImporterPluginType*)thisInstance)->conduitInterface->AddRef(thisInstance);
+ *ppv = thisInstance;
+ CFRelease(interfaceID);
+ return S_OK;
+ }else{
+ if (CFEqual(interfaceID,IUnknownUUID)){
+ /* If the IUnknown interface was requested, same as above. */
+ ((MetadataImporterPluginType*)thisInstance )->conduitInterface->AddRef(thisInstance);
+ *ppv = thisInstance;
+ CFRelease(interfaceID);
+ return S_OK;
+ }else{
+ /* Requested interface unknown, bail with error. */
+ *ppv = NULL;
+ CFRelease(interfaceID);
+ return E_NOINTERFACE;
+ }
+ }
+}
+
+// -----------------------------------------------------------------------------
+// MetadataImporterPluginAddRef
+// -----------------------------------------------------------------------------
+// Implementation of reference counting for this type. Whenever an interface
+// is requested, bump the refCount for the instance. NOTE: returning the
+// refcount is a convention but is not required so don't rely on it.
+//
+ULONG MetadataImporterPluginAddRef(void *thisInstance)
+{
+ ((MetadataImporterPluginType *)thisInstance )->refCount += 1;
+ return ((MetadataImporterPluginType*) thisInstance)->refCount;
+}
+
+// -----------------------------------------------------------------------------
+// SampleCMPluginRelease
+// -----------------------------------------------------------------------------
+// When an interface is released, decrement the refCount.
+// If the refCount goes to zero, deallocate the instance.
+//
+ULONG MetadataImporterPluginRelease(void *thisInstance)
+{
+ ((MetadataImporterPluginType*)thisInstance)->refCount -= 1;
+ if (((MetadataImporterPluginType*)thisInstance)->refCount == 0){
+ DeallocMetadataImporterPluginType((MetadataImporterPluginType*)thisInstance );
+ return 0;
+ }else{
+ return ((MetadataImporterPluginType*) thisInstance )->refCount;
+ }
+}
+
+// -----------------------------------------------------------------------------
+// SpotlightTesterMDImporterPluginFactory
+// -----------------------------------------------------------------------------
+// Implementation of the factory function for this type.
+//
+void *MetadataImporterPluginFactory(CFAllocatorRef allocator,CFUUIDRef typeID)
+{
+ MetadataImporterPluginType *result;
+ CFUUIDRef uuid;
+
+ /* If correct type is being requested, allocate an
+ * instance of TestType and return the IUnknown interface.
+ */
+ if (CFEqual(typeID,kMDImporterTypeID)){
+ uuid = CFUUIDCreateFromString(kCFAllocatorDefault,CFSTR(PLUGIN_ID));
+ result = AllocMetadataImporterPluginType(uuid);
+ CFRelease(uuid);
+ return result;
+ }
+ /* If the requested type is incorrect, return NULL. */
+ return NULL;
+}
+
diff --git a/extensions/source/macosx/spotlight/makefile.mk b/extensions/source/macosx/spotlight/makefile.mk
new file mode 100644
index 000000000000..3d1cb12d1dab
--- /dev/null
+++ b/extensions/source/macosx/spotlight/makefile.mk
@@ -0,0 +1,96 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ=../../..
+PRJNAME=extensions
+TARGET=spotlightplugin
+
+# --- Settings ----------------------------------
+.INCLUDE : settings.mk
+
+.IF "$(OS)"!="MACOSX"
+dummy:
+ @echo Not using Mac OS X - nothing to build
+.ENDIF
+
+# --- Files -------------------------------------
+
+# ... object files ............................
+SLOFILES= \
+ $(SLO)$/ioapi.obj \
+ $(SLO)$/unzip.obj \
+ $(SLO)$/main.obj \
+ $(SLO)$/GetMetadataForFile.obj \
+ $(SLO)$/OOoContentDataParser.obj \
+ $(SLO)$/OOoMetaDataParser.obj \
+ $(SLO)$/OOoSpotlightImporter.obj \
+
+BUNDLE = $(MISC)$/OOoSpotlightImporter.mdimporter
+CONTENTS = $(BUNDLE)$/Contents
+RESOURCES = $(CONTENTS)$/Resources
+MACOS = $(CONTENTS)$/MacOS
+
+BUNDLELIBS= -framework CoreFoundation \
+ -framework Foundation \
+ -framework CoreServices \
+ $(ZLIB3RDLIB)
+
+plistfiles = $(CONTENTS)$/Info.plist
+binaries = $(MACOS)$/OOoSpotlightImporter
+resources = $(RESOURCES)/en.lproj/schema.strings \
+ $(RESOURCES)/schema.xml
+
+ZIPFLAGS = -r
+ZIP1TARGET = mdibundle
+ZIP1DIR = $(CONTENTS)
+ZIP1LIST = *
+
+
+# --- Targets ----------------------------------
+
+.INCLUDE : target.mk
+
+$(ZIP1TARGETN) : $(plistfiles) $(binaries) $(resources)
+
+# Info.plist is just versioned and copied into the bundle
+$(CONTENTS)$/%.plist : mdimporter/%.plist
+ $(MKDIRHIER) $(@:d)
+ $(COPY) "$<" "$@"
+
+$(MACOS)$/OOoSpotlightImporter: $(SLOFILES)
+ $(MKDIRHIER) $(@:d)
+ $(CC) -o $(MACOS)$/OOoSpotlightImporter $(SLOFILES:s/.obj/.o/) $(EXTRA_LINKFLAGS) $(BUNDLELIBS) -bundle
+# we have to change the zlib install name, otherwise the plugin will not work
+ .IF "$(SYSTEM_ZLIB)"=="NO"
+ install_name_tool -change @executable_path/libz.1.dylib @executable_path/../../../../MacOS/libz.1.dylib $(MACOS)$/OOoSpotlightImporter
+ .ENDIF
+
+#the resources are just copied
+$(RESOURCES)$/% : mdimporter/%
+ $(MKDIRHIER) $(@:d)
+ $(COPY) "$<" "$@"
+
diff --git a/extensions/source/macosx/spotlight/mdimporter/Info.plist b/extensions/source/macosx/spotlight/mdimporter/Info.plist
new file mode 100644
index 000000000000..f2de1fb0ecd0
--- /dev/null
+++ b/extensions/source/macosx/spotlight/mdimporter/Info.plist
@@ -0,0 +1,70 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>CFBundleDevelopmentRegion</key>
+ <string>English</string>
+ <key>CFBundleDocumentTypes</key>
+ <array>
+ <dict>
+ <key>CFBundleTypeRole</key>
+ <string>MDImporter</string>
+ <key>LSItemContentTypes</key>
+ <array>
+ <string>org.openoffice.text</string>
+ <string>org.oasis-open.opendocument.text</string>
+ <string>org.openoffice.spreadsheet</string>
+ <string>org.oasis-open.opendocument.spreadsheet</string>
+ <string>org.openoffice.presentation</string>
+ <string>org.oasis-open.opendocument.presentation</string>
+ <string>org.openoffice.graphics</string>
+ <string>org.oasis-open.opendocument.graphics</string>
+ <string>org.openoffice.text-master</string>
+ <string>org.oasis-open.opendocument.text-master</string>
+ <string>org.openoffice.formula</string>
+ <string>org.oasis-open.opendocument.formula</string>
+ <string>org.openoffice.text-template</string>
+ <string>org.oasis-open.opendocument.text-template</string>
+ <string>org.openoffice.spreadsheet-template</string>
+ <string>org.oasis-open.opendocument.spreadsheet-template</string>
+ <string>org.openoffice.presentation-template</string>
+ <string>org.oasis-open.opendocument.presentation-template</string>
+ <string>org.openoffice.graphics-template</string>
+ <string>org.oasis-open.opendocument.graphics-template</string>
+ <string>org.oasis-open.opendocument.database</string>
+ </array>
+ </dict>
+ </array>
+ <key>CFBundleExecutable</key>
+ <string>OOoSpotlightImporter</string>
+ <key>CFBundleName</key>
+ <string>OOoSpotlightImporter</string>
+ <key>CFBundleIconFile</key>
+ <string></string>
+ <key>CFBundleIdentifier</key>
+ <string>org.openoffice.mdimporter</string>
+ <key>CFBundleInfoDictionaryVersion</key>
+ <string>6.0</string>
+ <key>CFBundleVersion</key>
+ <string>1.0</string>
+ <key>CFPlugInDynamicRegisterFunction</key>
+ <string></string>
+ <key>CFPlugInDynamicRegistration</key>
+ <string>NO</string>
+ <key>CFPlugInFactories</key>
+ <dict>
+ <key>A3FCC88D-B9A6-4364-8B93-92123C8A2D18</key>
+ <string>MetadataImporterPluginFactory</string>
+ </dict>
+ <key>CFPlugInTypes</key>
+ <dict>
+ <key>8B08C4BF-415B-11D8-B3F9-0003936726FC</key>
+ <array>
+ <string>A3FCC88D-B9A6-4364-8B93-92123C8A2D18</string>
+ </array>
+ </dict>
+ <key>CFPlugInUnloadFunction</key>
+ <string></string>
+
+</dict>
+</plist>
diff --git a/extensions/source/macosx/spotlight/mdimporter/en.lproj/schema.strings b/extensions/source/macosx/spotlight/mdimporter/en.lproj/schema.strings
new file mode 100644
index 000000000000..3559987837fc
--- /dev/null
+++ b/extensions/source/macosx/spotlight/mdimporter/en.lproj/schema.strings
@@ -0,0 +1 @@
+ÿþ \ No newline at end of file
diff --git a/extensions/source/macosx/spotlight/mdimporter/schema.xml b/extensions/source/macosx/spotlight/mdimporter/schema.xml
new file mode 100644
index 000000000000..06457c86fca2
--- /dev/null
+++ b/extensions/source/macosx/spotlight/mdimporter/schema.xml
@@ -0,0 +1,397 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<schema version="1.0" xmlns="http://www.apple.com/metadata"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.apple.com/metadata file:///System/Library/Frameworks/CoreServices.framework/Frameworks/Metadata.framework/Resources/MetadataSchema.xsd">
+ <note>
+ OpenOffice.org allows the user to enter 4 pieces of custom information in the document's metadata.
+ These metadata fields are described here for Spotlight's use.
+ </note>
+ <attributes>
+ <attribute name="org_openoffice_opendocument_custominfo1" type="CFString"/>
+ <attribute name="org_openoffice_opendocument_custominfo2" type="CFString"/>
+ <attribute name="org_openoffice_opendocument_custominfo3" type="CFString"/>
+ <attribute name="org_openoffice_opendocument_custominfo4" type="CFString"/>
+ </attributes>
+
+ <types>
+ <type name="org.openoffice.text">
+ <note>
+ The custom metadata info.
+ </note>
+ <allattrs id="attrs">
+ org_openoffice_opendocument_custominfo1
+ org_openoffice_opendocument_custominfo2
+ org_openoffice_opendocument_custominfo3
+ org_openoffice_opendocument_custominfo4
+ </allattrs>
+ <displayattrs id="dattrs">
+ org_openoffice_opendocument_custominfo1
+ org_openoffice_opendocument_custominfo2
+ org_openoffice_opendocument_custominfo3
+ org_openoffice_opendocument_custominfo4
+ </displayattrs>
+ </type>
+
+ <type name="org.oasis.opendocument.text">
+ <note>
+ The custom metadata info.
+ </note>
+ <allattrs id="attrs">
+ org_openoffice_opendocument_custominfo1
+ org_openoffice_opendocument_custominfo2
+ org_openoffice_opendocument_custominfo3
+ org_openoffice_opendocument_custominfo4
+ </allattrs>
+ <displayattrs id="dattrs">
+ org_openoffice_opendocument_custominfo1
+ org_openoffice_opendocument_custominfo2
+ org_openoffice_opendocument_custominfo3
+ org_openoffice_opendocument_custominfo4
+ </displayattrs>
+ </type>
+
+ <type name="org.openoffice.spreadsheet">
+ <note>
+ The custom metadata info.
+ </note>
+ <allattrs id="attrs">
+ org_openoffice_opendocument_custominfo1
+ org_openoffice_opendocument_custominfo2
+ org_openoffice_opendocument_custominfo3
+ org_openoffice_opendocument_custominfo4
+ </allattrs>
+ <displayattrs id="dattrs">
+ org_openoffice_opendocument_custominfo1
+ org_openoffice_opendocument_custominfo2
+ org_openoffice_opendocument_custominfo3
+ org_openoffice_opendocument_custominfo4
+ </displayattrs>
+ </type>
+
+ <type name="org.oasis.opendocument.spreadsheet">
+ <note>
+ The custom metadata info.
+ </note>
+ <allattrs id="attrs">
+ org_openoffice_opendocument_custominfo1
+ org_openoffice_opendocument_custominfo2
+ org_openoffice_opendocument_custominfo3
+ org_openoffice_opendocument_custominfo4
+ </allattrs>
+ <displayattrs id="dattrs">
+ org_openoffice_opendocument_custominfo1
+ org_openoffice_opendocument_custominfo2
+ org_openoffice_opendocument_custominfo3
+ org_openoffice_opendocument_custominfo4
+ </displayattrs>
+ </type>
+
+ <type name="org.openoffice.presentation">
+ <note>
+ The custom metadata info.
+ </note>
+ <allattrs id="attrs">
+ org_openoffice_opendocument_custominfo1
+ org_openoffice_opendocument_custominfo2
+ org_openoffice_opendocument_custominfo3
+ org_openoffice_opendocument_custominfo4
+ </allattrs>
+ <displayattrs id="dattrs">
+ org_openoffice_opendocument_custominfo1
+ org_openoffice_opendocument_custominfo2
+ org_openoffice_opendocument_custominfo3
+ org_openoffice_opendocument_custominfo4
+ </displayattrs>
+ </type>
+
+ <type name="org.oasis.opendocument.presentation">
+ <note>
+ The custom metadata info.
+ </note>
+ <allattrs id="attrs">
+ org_openoffice_opendocument_custominfo1
+ org_openoffice_opendocument_custominfo2
+ org_openoffice_opendocument_custominfo3
+ org_openoffice_opendocument_custominfo4
+ </allattrs>
+ <displayattrs id="dattrs">
+ org_openoffice_opendocument_custominfo1
+ org_openoffice_opendocument_custominfo2
+ org_openoffice_opendocument_custominfo3
+ org_openoffice_opendocument_custominfo4
+ </displayattrs>
+ </type>
+
+ <type name="org.openoffice.graphics">
+ <note>
+ The custom metadata info.
+ </note>
+ <allattrs id="attrs">
+ org_openoffice_opendocument_custominfo1
+ org_openoffice_opendocument_custominfo2
+ org_openoffice_opendocument_custominfo3
+ org_openoffice_opendocument_custominfo4
+ </allattrs>
+ <displayattrs id="dattrs">
+ org_openoffice_opendocument_custominfo1
+ org_openoffice_opendocument_custominfo2
+ org_openoffice_opendocument_custominfo3
+ org_openoffice_opendocument_custominfo4
+ </displayattrs>
+ </type>
+
+ <type name="org.oasis.opendocument.graphics">
+ <note>
+ The custom metadata info.
+ </note>
+ <allattrs id="attrs">
+ org_openoffice_opendocument_custominfo1
+ org_openoffice_opendocument_custominfo2
+ org_openoffice_opendocument_custominfo3
+ org_openoffice_opendocument_custominfo4
+ </allattrs>
+ <displayattrs id="dattrs">
+ org_openoffice_opendocument_custominfo1
+ org_openoffice_opendocument_custominfo2
+ org_openoffice_opendocument_custominfo3
+ org_openoffice_opendocument_custominfo4
+ </displayattrs>
+ </type>
+
+ <type name="org.openoffice.text-master">
+ <note>
+ The custom metadata info.
+ </note>
+ <allattrs id="attrs">
+ org_openoffice_opendocument_custominfo1
+ org_openoffice_opendocument_custominfo2
+ org_openoffice_opendocument_custominfo3
+ org_openoffice_opendocument_custominfo4
+ </allattrs>
+ <displayattrs id="dattrs">
+ org_openoffice_opendocument_custominfo1
+ org_openoffice_opendocument_custominfo2
+ org_openoffice_opendocument_custominfo3
+ org_openoffice_opendocument_custominfo4
+ </displayattrs>
+ </type>
+
+ <type name="org.oasis.opendocument.text-master">
+ <note>
+ The custom metadata info.
+ </note>
+ <allattrs id="attrs">
+ org_openoffice_opendocument_custominfo1
+ org_openoffice_opendocument_custominfo2
+ org_openoffice_opendocument_custominfo3
+ org_openoffice_opendocument_custominfo4
+ </allattrs>
+ <displayattrs id="dattrs">
+ org_openoffice_opendocument_custominfo1
+ org_openoffice_opendocument_custominfo2
+ org_openoffice_opendocument_custominfo3
+ org_openoffice_opendocument_custominfo4
+ </displayattrs>
+ </type>
+
+ <type name="org.openoffice.formula">
+ <note>
+ The custom metadata info.
+ </note>
+ <allattrs id="attrs">
+ org_openoffice_opendocument_custominfo1
+ org_openoffice_opendocument_custominfo2
+ org_openoffice_opendocument_custominfo3
+ org_openoffice_opendocument_custominfo4
+ </allattrs>
+ <displayattrs id="dattrs">
+ org_openoffice_opendocument_custominfo1
+ org_openoffice_opendocument_custominfo2
+ org_openoffice_opendocument_custominfo3
+ org_openoffice_opendocument_custominfo4
+ </displayattrs>
+ </type>
+
+ <type name="org.oasis.opendocument.formula">
+ <note>
+ The custom metadata info.
+ </note>
+ <allattrs id="attrs">
+ org_openoffice_opendocument_custominfo1
+ org_openoffice_opendocument_custominfo2
+ org_openoffice_opendocument_custominfo3
+ org_openoffice_opendocument_custominfo4
+ </allattrs>
+ <displayattrs id="dattrs">
+ org_openoffice_opendocument_custominfo1
+ org_openoffice_opendocument_custominfo2
+ org_openoffice_opendocument_custominfo3
+ org_openoffice_opendocument_custominfo4
+ </displayattrs>
+ </type>
+
+ <type name="org.openoffice.text-template">
+ <note>
+ The custom metadata info.
+ </note>
+ <allattrs id="attrs">
+ org_openoffice_opendocument_custominfo1
+ org_openoffice_opendocument_custominfo2
+ org_openoffice_opendocument_custominfo3
+ org_openoffice_opendocument_custominfo4
+ </allattrs>
+ <displayattrs id="dattrs">
+ org_openoffice_opendocument_custominfo1
+ org_openoffice_opendocument_custominfo2
+ org_openoffice_opendocument_custominfo3
+ org_openoffice_opendocument_custominfo4
+ </displayattrs>
+ </type>
+
+ <type name="org.oasis.opendocument.text-template">
+ <note>
+ The custom metadata info.
+ </note>
+ <allattrs id="attrs">
+ org_openoffice_opendocument_custominfo1
+ org_openoffice_opendocument_custominfo2
+ org_openoffice_opendocument_custominfo3
+ org_openoffice_opendocument_custominfo4
+ </allattrs>
+ <displayattrs id="dattrs">
+ org_openoffice_opendocument_custominfo1
+ org_openoffice_opendocument_custominfo2
+ org_openoffice_opendocument_custominfo3
+ org_openoffice_opendocument_custominfo4
+ </displayattrs>
+ </type>
+
+ <type name="org.openoffice.spreadsheet-template">
+ <note>
+ The custom metadata info.
+ </note>
+ <allattrs id="attrs">
+ org_openoffice_opendocument_custominfo1
+ org_openoffice_opendocument_custominfo2
+ org_openoffice_opendocument_custominfo3
+ org_openoffice_opendocument_custominfo4
+ </allattrs>
+ <displayattrs id="dattrs">
+ org_openoffice_opendocument_custominfo1
+ org_openoffice_opendocument_custominfo2
+ org_openoffice_opendocument_custominfo3
+ org_openoffice_opendocument_custominfo4
+ </displayattrs>
+ </type>
+
+ <type name="org.oasis.opendocument.spreadsheet-template">
+ <note>
+ The custom metadata info.
+ </note>
+ <allattrs id="attrs">
+ org_openoffice_opendocument_custominfo1
+ org_openoffice_opendocument_custominfo2
+ org_openoffice_opendocument_custominfo3
+ org_openoffice_opendocument_custominfo4
+ </allattrs>
+ <displayattrs id="dattrs">
+ org_openoffice_opendocument_custominfo1
+ org_openoffice_opendocument_custominfo2
+ org_openoffice_opendocument_custominfo3
+ org_openoffice_opendocument_custominfo4
+ </displayattrs>
+ </type>
+
+ <type name="org.openoffice.presentation-template">
+ <note>
+ The custom metadata info.
+ </note>
+ <allattrs id="attrs">
+ org_openoffice_opendocument_custominfo1
+ org_openoffice_opendocument_custominfo2
+ org_openoffice_opendocument_custominfo3
+ org_openoffice_opendocument_custominfo4
+ </allattrs>
+ <displayattrs id="dattrs">
+ org_openoffice_opendocument_custominfo1
+ org_openoffice_opendocument_custominfo2
+ org_openoffice_opendocument_custominfo3
+ org_openoffice_opendocument_custominfo4
+ </displayattrs>
+ </type>
+
+ <type name="org.oasis.opendocument.presentation-template">
+ <note>
+ The custom metadata info.
+ </note>
+ <allattrs id="attrs">
+ org_openoffice_opendocument_custominfo1
+ org_openoffice_opendocument_custominfo2
+ org_openoffice_opendocument_custominfo3
+ org_openoffice_opendocument_custominfo4
+ </allattrs>
+ <displayattrs id="dattrs">
+ org_openoffice_opendocument_custominfo1
+ org_openoffice_opendocument_custominfo2
+ org_openoffice_opendocument_custominfo3
+ org_openoffice_opendocument_custominfo4
+ </displayattrs>
+ </type>
+
+ <type name="org.openoffice.graphics-template">
+ <note>
+ The custom metadata info.
+ </note>
+ <allattrs id="attrs">
+ org_openoffice_opendocument_custominfo1
+ org_openoffice_opendocument_custominfo2
+ org_openoffice_opendocument_custominfo3
+ org_openoffice_opendocument_custominfo4
+ </allattrs>
+ <displayattrs id="dattrs">
+ org_openoffice_opendocument_custominfo1
+ org_openoffice_opendocument_custominfo2
+ org_openoffice_opendocument_custominfo3
+ org_openoffice_opendocument_custominfo4
+ </displayattrs>
+ </type>
+
+ <type name="org.oasis.opendocument.graphics-template">
+ <note>
+ The custom metadata info.
+ </note>
+ <allattrs id="attrs">
+ org_openoffice_opendocument_custominfo1
+ org_openoffice_opendocument_custominfo2
+ org_openoffice_opendocument_custominfo3
+ org_openoffice_opendocument_custominfo4
+ </allattrs>
+ <displayattrs id="dattrs">
+ org_openoffice_opendocument_custominfo1
+ org_openoffice_opendocument_custominfo2
+ org_openoffice_opendocument_custominfo3
+ org_openoffice_opendocument_custominfo4
+ </displayattrs>
+ </type>
+
+ <type name="org.oasis.opendocument.chart">
+ <note>
+ The custom metadata info.
+ </note>
+ <allattrs id="attrs">
+ org_openoffice_opendocument_custominfo1
+ org_openoffice_opendocument_custominfo2
+ org_openoffice_opendocument_custominfo3
+ org_openoffice_opendocument_custominfo4
+ </allattrs>
+ <displayattrs id="dattrs">
+ org_openoffice_opendocument_custominfo1
+ org_openoffice_opendocument_custominfo2
+ org_openoffice_opendocument_custominfo3
+ org_openoffice_opendocument_custominfo4
+ </displayattrs>
+ </type>
+ </types>
+</schema>
+
diff --git a/extensions/source/macosx/spotlight/unzip.h b/extensions/source/macosx/spotlight/unzip.h
new file mode 100644
index 000000000000..e710cd84a0d6
--- /dev/null
+++ b/extensions/source/macosx/spotlight/unzip.h
@@ -0,0 +1,380 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+*************************************************************************/
+
+/* unzip.h -- IO for uncompress .zip files using zlib
+ Version 1.01e, February 12th, 2005
+
+ Copyright (C) 1998-2005 Gilles Vollant
+
+ This unzip package allow extract file from .ZIP file, compatible with PKZip 2.04g
+ WinZip, InfoZip tools and compatible.
+
+ Multi volume ZipFile (span) are not supported.
+ Encryption compatible with pkzip 2.04g only supported
+ Old compressions used by old PKZip 1.x are not supported
+
+
+ I WAIT FEEDBACK at mail info@winimage.com
+ Visit also http://www.winimage.com/zLibDll/unzip.htm for evolution
+
+ Condition of use and distribution are the same than zlib :
+
+ This software is provided 'as-is', without any express or implied
+ warranty. In no event will the authors be held liable for any damages
+ arising from the use of this software.
+
+ Permission is granted to anyone to use this software for any purpose,
+ including commercial applications, and to alter it and redistribute it
+ freely, subject to the following restrictions:
+
+ 1. The origin of this software must not be misrepresented; you must not
+ claim that you wrote the original software. If you use this software
+ in a product, an acknowledgment in the product documentation would be
+ appreciated but is not required.
+ 2. Altered source versions must be plainly marked as such, and must not be
+ misrepresented as being the original software.
+ 3. This notice may not be removed or altered from any source distribution.
+
+
+*/
+
+/* for more info about .ZIP format, see
+ http://www.info-zip.org/pub/infozip/doc/appnote-981119-iz.zip
+ http://www.info-zip.org/pub/infozip/doc/
+ PkWare has also a specification at :
+ ftp://ftp.pkware.com/probdesc.zip
+*/
+
+#ifndef _unz_H
+#define _unz_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <zlib.h>
+
+#include "ioapi.h"
+
+#if defined(STRICTUNZIP) || defined(STRICTZIPUNZIP)
+/* like the STRICT of WIN32, we define a pointer that cannot be converted
+ from (void*) without cast */
+typedef struct TagunzFile__ { int unused; } unzFile__;
+typedef unzFile__ *unzFile;
+#else
+typedef voidp unzFile;
+#endif
+
+
+#define UNZ_OK (0)
+#define UNZ_END_OF_LIST_OF_FILE (-100)
+#define UNZ_ERRNO (Z_ERRNO)
+#define UNZ_EOF (0)
+#define UNZ_PARAMERROR (-102)
+#define UNZ_BADZIPFILE (-103)
+#define UNZ_INTERNALERROR (-104)
+#define UNZ_CRCERROR (-105)
+
+/* tm_unz contain date/time info */
+typedef struct tm_unz_s
+{
+ uInt tm_sec; /* seconds after the minute - [0,59] */
+ uInt tm_min; /* minutes after the hour - [0,59] */
+ uInt tm_hour; /* hours since midnight - [0,23] */
+ uInt tm_mday; /* day of the month - [1,31] */
+ uInt tm_mon; /* months since January - [0,11] */
+ uInt tm_year; /* years - [1980..2044] */
+} tm_unz;
+
+/* unz_global_info structure contain global data about the ZIPfile
+ These data comes from the end of central dir */
+typedef struct unz_global_info_s
+{
+ uLong number_entry; /* total number of entries in
+ the central dir on this disk */
+ uLong size_comment; /* size of the global comment of the zipfile */
+} unz_global_info;
+
+
+/* unz_file_info contain information about a file in the zipfile */
+typedef struct unz_file_info_s
+{
+ uLong version; /* version made by 2 bytes */
+ uLong version_needed; /* version needed to extract 2 bytes */
+ uLong flag; /* general purpose bit flag 2 bytes */
+ uLong compression_method; /* compression method 2 bytes */
+ uLong dosDate; /* last mod file date in Dos fmt 4 bytes */
+ uLong crc; /* crc-32 4 bytes */
+ uLong compressed_size; /* compressed size 4 bytes */
+ uLong uncompressed_size; /* uncompressed size 4 bytes */
+ uLong size_filename; /* filename length 2 bytes */
+ uLong size_file_extra; /* extra field length 2 bytes */
+ uLong size_file_comment; /* file comment length 2 bytes */
+
+ uLong disk_num_start; /* disk number start 2 bytes */
+ uLong internal_fa; /* internal file attributes 2 bytes */
+ uLong external_fa; /* external file attributes 4 bytes */
+
+ tm_unz tmu_date;
+} unz_file_info;
+
+extern int ZEXPORT unzStringFileNameCompare OF ((const char* fileName1,
+ const char* fileName2,
+ int iCaseSensitivity));
+/*
+ Compare two filename (fileName1,fileName2).
+ If iCaseSenisivity = 1, comparision is case sensitivity (like strcmp)
+ If iCaseSenisivity = 2, comparision is not case sensitivity (like strcmpi
+ or strcasecmp)
+ If iCaseSenisivity = 0, case sensitivity is defaut of your operating system
+ (like 1 on Unix, 2 on Windows)
+*/
+
+
+extern unzFile ZEXPORT unzOpen OF((const char *path));
+/*
+ Open a Zip file. path contain the full pathname (by example,
+ on a Windows XP computer "c:\\zlib\\zlib113.zip" or on an Unix computer
+ "zlib/zlib113.zip".
+ If the zipfile cannot be opened (file don't exist or in not valid), the
+ return value is NULL.
+ Else, the return value is a unzFile Handle, usable with other function
+ of this unzip package.
+*/
+
+extern unzFile ZEXPORT unzOpen2 OF((const char *path,
+ zlib_filefunc_def* pzlib_filefunc_def));
+/*
+ Open a Zip file, like unzOpen, but provide a set of file low level API
+ for read/write the zip file (see ioapi.h)
+*/
+
+extern int ZEXPORT unzClose OF((unzFile file));
+/*
+ Close a ZipFile opened with unzipOpen.
+ If there is files inside the .Zip opened with unzOpenCurrentFile (see later),
+ these files MUST be closed with unzipCloseCurrentFile before call unzipClose.
+ return UNZ_OK if there is no problem. */
+
+extern int ZEXPORT unzGetGlobalInfo OF((unzFile file,
+ unz_global_info *pglobal_info));
+/*
+ Write info about the ZipFile in the *pglobal_info structure.
+ No preparation of the structure is needed
+ return UNZ_OK if there is no problem. */
+
+
+extern int ZEXPORT unzGetGlobalComment OF((unzFile file,
+ char *szComment,
+ uLong uSizeBuf));
+/*
+ Get the global comment string of the ZipFile, in the szComment buffer.
+ uSizeBuf is the size of the szComment buffer.
+ return the number of byte copied or an error code <0
+*/
+
+
+/***************************************************************************/
+/* Unzip package allow you browse the directory of the zipfile */
+
+extern int ZEXPORT unzGoToFirstFile OF((unzFile file));
+/*
+ Set the current file of the zipfile to the first file.
+ return UNZ_OK if there is no problem
+*/
+
+extern int ZEXPORT unzGoToNextFile OF((unzFile file));
+/*
+ Set the current file of the zipfile to the next file.
+ return UNZ_OK if there is no problem
+ return UNZ_END_OF_LIST_OF_FILE if the actual file was the latest.
+*/
+
+extern int ZEXPORT unzLocateFile OF((unzFile file,
+ const char *szFileName,
+ int iCaseSensitivity));
+/*
+ Try locate the file szFileName in the zipfile.
+ For the iCaseSensitivity signification, see unzStringFileNameCompare
+
+ return value :
+ UNZ_OK if the file is found. It becomes the current file.
+ UNZ_END_OF_LIST_OF_FILE if the file is not found
+*/
+
+
+/* ****************************************** */
+/* Ryan supplied functions */
+/* unz_file_info contain information about a file in the zipfile */
+typedef struct unz_file_pos_s
+{
+ uLong pos_in_zip_directory; /* offset in zip file directory */
+ uLong num_of_file; /* # of file */
+} unz_file_pos;
+
+extern int ZEXPORT unzGetFilePos(
+ unzFile file,
+ unz_file_pos* file_pos);
+
+extern int ZEXPORT unzGoToFilePos(
+ unzFile file,
+ unz_file_pos* file_pos);
+
+/* ****************************************** */
+
+extern int ZEXPORT unzGetCurrentFileInfo OF((unzFile file,
+ unz_file_info *pfile_info,
+ char *szFileName,
+ uLong fileNameBufferSize,
+ void *extraField,
+ uLong extraFieldBufferSize,
+ char *szComment,
+ uLong commentBufferSize));
+/*
+ Get Info about the current file
+ if pfile_info!=NULL, the *pfile_info structure will contain somes info about
+ the current file
+ if szFileName!=NULL, the filemane string will be copied in szFileName
+ (fileNameBufferSize is the size of the buffer)
+ if extraField!=NULL, the extra field information will be copied in extraField
+ (extraFieldBufferSize is the size of the buffer).
+ This is the Central-header version of the extra field
+ if szComment!=NULL, the comment string of the file will be copied in szComment
+ (commentBufferSize is the size of the buffer)
+*/
+
+/***************************************************************************/
+/* for reading the content of the current zipfile, you can open it, read data
+ from it, and close it (you can close it before reading all the file)
+ */
+
+extern int ZEXPORT unzOpenCurrentFile OF((unzFile file));
+/*
+ Open for reading data the current file in the zipfile.
+ If there is no error, the return value is UNZ_OK.
+*/
+
+extern int ZEXPORT unzOpenCurrentFilePassword OF((unzFile file,
+ const char* password));
+/*
+ Open for reading data the current file in the zipfile.
+ password is a crypting password
+ If there is no error, the return value is UNZ_OK.
+*/
+
+extern int ZEXPORT unzOpenCurrentFile2 OF((unzFile file,
+ int* method,
+ int* level,
+ int raw));
+/*
+ Same than unzOpenCurrentFile, but open for read raw the file (not uncompress)
+ if raw==1
+ *method will receive method of compression, *level will receive level of
+ compression
+ note : you can set level parameter as NULL (if you did not want known level,
+ but you CANNOT set method parameter as NULL
+*/
+
+extern int ZEXPORT unzOpenCurrentFile3 OF((unzFile file,
+ int* method,
+ int* level,
+ int raw,
+ const char* password));
+/*
+ Same than unzOpenCurrentFile, but open for read raw the file (not uncompress)
+ if raw==1
+ *method will receive method of compression, *level will receive level of
+ compression
+ note : you can set level parameter as NULL (if you did not want known level,
+ but you CANNOT set method parameter as NULL
+*/
+
+
+extern int ZEXPORT unzCloseCurrentFile OF((unzFile file));
+/*
+ Close the file in zip opened with unzOpenCurrentFile
+ Return UNZ_CRCERROR if all the file was read but the CRC is not good
+*/
+
+extern int ZEXPORT unzReadCurrentFile OF((unzFile file,
+ voidp buf,
+ unsigned len));
+/*
+ Read bytes from the current file (opened by unzOpenCurrentFile)
+ buf contain buffer where data must be copied
+ len the size of buf.
+
+ return the number of byte copied if somes bytes are copied
+ return 0 if the end of file was reached
+ return <0 with error code if there is an error
+ (UNZ_ERRNO for IO error, or zLib error for uncompress error)
+*/
+
+extern z_off_t ZEXPORT unztell OF((unzFile file));
+/*
+ Give the current position in uncompressed data
+*/
+
+extern int ZEXPORT unzeof OF((unzFile file));
+/*
+ return 1 if the end of file was reached, 0 elsewhere
+*/
+
+extern int ZEXPORT unzGetLocalExtrafield OF((unzFile file,
+ voidp buf,
+ unsigned len));
+/*
+ Read extra field from the current file (opened by unzOpenCurrentFile)
+ This is the local-header version of the extra field (sometimes, there is
+ more info in the local-header version than in the central-header)
+
+ if buf==NULL, it return the size of the local extra field
+
+ if buf!=NULL, len is the size of the buffer, the extra header is copied in
+ buf.
+ the return value is the number of bytes copied in buf, or (if <0)
+ the error code
+*/
+
+/***************************************************************************/
+
+/* Get the current file offset */
+extern uLong ZEXPORT unzGetOffset (unzFile file);
+
+/* Set the current file offset */
+extern int ZEXPORT unzSetOffset (unzFile file, uLong pos);
+
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _unz_H */
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/macosx/spotlight/unzip.m b/extensions/source/macosx/spotlight/unzip.m
new file mode 100644
index 000000000000..fe8fad538a86
--- /dev/null
+++ b/extensions/source/macosx/spotlight/unzip.m
@@ -0,0 +1,1586 @@
+/*************************************************************************
+*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+*************************************************************************/
+
+/* unzip.c -- IO for uncompress .zip files using zlib
+ Version 1.01e, February 12th, 2005
+
+ Copyright (C) 1998-2005 Gilles Vollant
+
+ Read unzip.h for more info
+*/
+
+/* Decryption code comes from crypt.c by Info-ZIP but has been greatly reduced in terms of
+compatibility with older software. The following is from the original crypt.c. Code
+woven in by Terry Thorsen 1/2003.
+*/
+/*
+ Copyright (c) 1990-2000 Info-ZIP. All rights reserved.
+
+ See the accompanying file LICENSE, version 2000-Apr-09 or later
+ (the contents of which are also included in zip.h) for terms of use.
+ If, for some reason, all these files are missing, the Info-ZIP license
+ also may be found at: ftp://ftp.info-zip.org/pub/infozip/license.html
+*/
+/*
+ crypt.c (full version) by Info-ZIP. Last revised: [see crypt.h]
+
+ The encryption/decryption parts of this source code (as opposed to the
+ non-echoing password parts) were originally written in Europe. The
+ whole source package can be freely distributed, including from the USA.
+ (Prior to January 2000, re-export from the US was a violation of US law.)
+ */
+
+/*
+ This encryption code is a direct transcription of the algorithm from
+ Roger Schlafly, described by Phil Katz in the file appnote.txt. This
+ file (appnote.txt) is distributed with the PKZIP program (even in the
+ version without encryption capabilities).
+ */
+
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <zlib.h>
+#include "ioapi.h"
+#include "unzip.h"
+
+#ifdef STDC
+# include <stddef.h>
+# include <string.h>
+# include <stdlib.h>
+#endif
+#ifdef NO_ERRNO_H
+ extern int errno;
+#else
+# include <errno.h>
+#endif
+
+
+#ifndef local
+# define local static
+#endif
+/* compile with -Dlocal if your debugger can't find static symbols */
+
+
+#ifndef CASESENSITIVITYDEFAULT_NO
+# if !defined(unix) && !defined(CASESENSITIVITYDEFAULT_YES)
+# define CASESENSITIVITYDEFAULT_NO
+# endif
+#endif
+
+
+#ifndef UNZ_BUFSIZE
+#define UNZ_BUFSIZE (16384)
+#endif
+
+#ifndef UNZ_MAXFILENAMEINZIP
+#define UNZ_MAXFILENAMEINZIP (256)
+#endif
+
+#ifndef ALLOC
+# define ALLOC(size) (malloc(size))
+#endif
+#ifndef TRYFREE
+# define TRYFREE(p) {if (p) free(p);}
+#endif
+
+#define SIZECENTRALDIRITEM (0x2e)
+#define SIZEZIPLOCALHEADER (0x1e)
+
+
+
+
+const char unz_copyright[] =
+ " unzip 1.01 Copyright 1998-2004 Gilles Vollant - http://www.winimage.com/zLibDll";
+
+/* unz_file_info_interntal contain internal info about a file in zipfile*/
+typedef struct unz_file_info_internal_s
+{
+ uLong offset_curfile;/* relative offset of local header 4 bytes */
+} unz_file_info_internal;
+
+
+/* file_in_zip_read_info_s contain internal information about a file in zipfile,
+ when reading and decompress it */
+typedef struct
+{
+ char *read_buffer; /* internal buffer for compressed data */
+ z_stream stream; /* zLib stream structure for inflate */
+
+ uLong pos_in_zipfile; /* position in byte on the zipfile, for fseek*/
+ uLong stream_initialised; /* flag set if stream structure is initialised*/
+
+ uLong offset_local_extrafield;/* offset of the local extra field */
+ uInt size_local_extrafield;/* size of the local extra field */
+ uLong pos_local_extrafield; /* position in the local extra field in read*/
+
+ uLong crc32; /* crc32 of all data uncompressed */
+ uLong crc32_wait; /* crc32 we must obtain after decompress all */
+ uLong rest_read_compressed; /* number of byte to be decompressed */
+ uLong rest_read_uncompressed;/*number of byte to be obtained after decomp*/
+ zlib_filefunc_def z_filefunc;
+ voidpf filestream; /* io structore of the zipfile */
+ uLong compression_method; /* compression method (0==store) */
+ uLong byte_before_the_zipfile;/* byte before the zipfile, (>0 for sfx)*/
+ int raw;
+} file_in_zip_read_info_s;
+
+
+/* unz_s contain internal information about the zipfile
+*/
+typedef struct
+{
+ zlib_filefunc_def z_filefunc;
+ voidpf filestream; /* io structore of the zipfile */
+ unz_global_info gi; /* public global information */
+ uLong byte_before_the_zipfile;/* byte before the zipfile, (>0 for sfx)*/
+ uLong num_file; /* number of the current file in the zipfile*/
+ uLong pos_in_central_dir; /* pos of the current file in the central dir*/
+ uLong current_file_ok; /* flag about the usability of the current file*/
+ uLong central_pos; /* position of the beginning of the central dir*/
+
+ uLong size_central_dir; /* size of the central directory */
+ uLong offset_central_dir; /* offset of start of central directory with
+ respect to the starting disk number */
+
+ unz_file_info cur_file_info; /* public info about the current file in zip*/
+ unz_file_info_internal cur_file_info_internal; /* private info about it*/
+ file_in_zip_read_info_s* pfile_in_zip_read; /* structure about the current
+ file if we are decompressing it */
+ int encrypted;
+} unz_s;
+
+
+
+/* ===========================================================================
+ Read a byte from a gz_stream; update next_in and avail_in. Return EOF
+ for end of file.
+ IN assertion: the stream s has been sucessfully opened for reading.
+*/
+
+
+local int unzlocal_getByte OF((
+ const zlib_filefunc_def* pzlib_filefunc_def,
+ voidpf filestream,
+ int *pi));
+
+local int unzlocal_getByte(pzlib_filefunc_def,filestream,pi)
+ const zlib_filefunc_def* pzlib_filefunc_def;
+ voidpf filestream;
+ int *pi;
+{
+ unsigned char c;
+ int err = (int)ZREAD(*pzlib_filefunc_def,filestream,&c,1);
+ if (err==1)
+ {
+ *pi = (int)c;
+ return UNZ_OK;
+ }
+ else
+ {
+ if (ZERROR(*pzlib_filefunc_def,filestream))
+ return UNZ_ERRNO;
+ else
+ return UNZ_EOF;
+ }
+}
+
+
+/* ===========================================================================
+ Reads a long in LSB order from the given gz_stream. Sets
+*/
+local int unzlocal_getShort OF((
+ const zlib_filefunc_def* pzlib_filefunc_def,
+ voidpf filestream,
+ uLong *pX));
+
+local int unzlocal_getShort (pzlib_filefunc_def,filestream,pX)
+ const zlib_filefunc_def* pzlib_filefunc_def;
+ voidpf filestream;
+ uLong *pX;
+{
+ uLong x ;
+ int i;
+ int err;
+
+ err = unzlocal_getByte(pzlib_filefunc_def,filestream,&i);
+ x = (uLong)i;
+
+ if (err==UNZ_OK)
+ err = unzlocal_getByte(pzlib_filefunc_def,filestream,&i);
+ x += ((uLong)i)<<8;
+
+ if (err==UNZ_OK)
+ *pX = x;
+ else
+ *pX = 0;
+ return err;
+}
+
+local int unzlocal_getLong OF((
+ const zlib_filefunc_def* pzlib_filefunc_def,
+ voidpf filestream,
+ uLong *pX));
+
+local int unzlocal_getLong (pzlib_filefunc_def,filestream,pX)
+ const zlib_filefunc_def* pzlib_filefunc_def;
+ voidpf filestream;
+ uLong *pX;
+{
+ uLong x ;
+ int i;
+ int err;
+
+ err = unzlocal_getByte(pzlib_filefunc_def,filestream,&i);
+ x = (uLong)i;
+
+ if (err==UNZ_OK)
+ err = unzlocal_getByte(pzlib_filefunc_def,filestream,&i);
+ x += ((uLong)i)<<8;
+
+ if (err==UNZ_OK)
+ err = unzlocal_getByte(pzlib_filefunc_def,filestream,&i);
+ x += ((uLong)i)<<16;
+
+ if (err==UNZ_OK)
+ err = unzlocal_getByte(pzlib_filefunc_def,filestream,&i);
+ x += ((uLong)i)<<24;
+
+ if (err==UNZ_OK)
+ *pX = x;
+ else
+ *pX = 0;
+ return err;
+}
+
+
+/* My own strcmpi / strcasecmp */
+local int strcmpcasenosensitive_internal (fileName1,fileName2)
+ const char* fileName1;
+ const char* fileName2;
+{
+ for (;;)
+ {
+ char c1=*(fileName1++);
+ char c2=*(fileName2++);
+ if ((c1>='a') && (c1<='z'))
+ c1 -= 0x20;
+ if ((c2>='a') && (c2<='z'))
+ c2 -= 0x20;
+ if (c1=='\0')
+ return ((c2=='\0') ? 0 : -1);
+ if (c2=='\0')
+ return 1;
+ if (c1<c2)
+ return -1;
+ if (c1>c2)
+ return 1;
+ }
+}
+
+
+#ifdef CASESENSITIVITYDEFAULT_NO
+#define CASESENSITIVITYDEFAULTVALUE 2
+#else
+#define CASESENSITIVITYDEFAULTVALUE 1
+#endif
+
+#ifndef STRCMPCASENOSENTIVEFUNCTION
+#define STRCMPCASENOSENTIVEFUNCTION strcmpcasenosensitive_internal
+#endif
+
+/*
+ Compare two filename (fileName1,fileName2).
+ If iCaseSenisivity = 1, comparision is case sensitivity (like strcmp)
+ If iCaseSenisivity = 2, comparision is not case sensitivity (like strcmpi
+ or strcasecmp)
+ If iCaseSenisivity = 0, case sensitivity is defaut of your operating system
+ (like 1 on Unix, 2 on Windows)
+
+*/
+extern int ZEXPORT unzStringFileNameCompare (fileName1,fileName2,iCaseSensitivity)
+ const char* fileName1;
+ const char* fileName2;
+ int iCaseSensitivity;
+{
+ if (iCaseSensitivity==0)
+ iCaseSensitivity=CASESENSITIVITYDEFAULTVALUE;
+
+ if (iCaseSensitivity==1)
+ return strcmp(fileName1,fileName2);
+
+ return STRCMPCASENOSENTIVEFUNCTION(fileName1,fileName2);
+}
+
+#ifndef BUFREADCOMMENT
+#define BUFREADCOMMENT (0x400)
+#endif
+
+/*
+ Locate the Central directory of a zipfile (at the end, just before
+ the global comment)
+*/
+local uLong unzlocal_SearchCentralDir OF((
+ const zlib_filefunc_def* pzlib_filefunc_def,
+ voidpf filestream));
+
+local uLong unzlocal_SearchCentralDir(pzlib_filefunc_def,filestream)
+ const zlib_filefunc_def* pzlib_filefunc_def;
+ voidpf filestream;
+{
+ unsigned char* buf;
+ uLong uSizeFile;
+ uLong uBackRead;
+ uLong uMaxBack=0xffff; /* maximum size of global comment */
+ uLong uPosFound=0;
+
+ if (ZSEEK(*pzlib_filefunc_def,filestream,0,ZLIB_FILEFUNC_SEEK_END) != 0)
+ return 0;
+
+
+ uSizeFile = ZTELL(*pzlib_filefunc_def,filestream);
+
+ if (uMaxBack>uSizeFile)
+ uMaxBack = uSizeFile;
+
+ buf = (unsigned char*)ALLOC(BUFREADCOMMENT+4);
+ if (buf==NULL)
+ return 0;
+
+ uBackRead = 4;
+ while (uBackRead<uMaxBack)
+ {
+ uLong uReadSize,uReadPos ;
+ int i;
+ if (uBackRead+BUFREADCOMMENT>uMaxBack)
+ uBackRead = uMaxBack;
+ else
+ uBackRead+=BUFREADCOMMENT;
+ uReadPos = uSizeFile-uBackRead ;
+
+ uReadSize = ((BUFREADCOMMENT+4) < (uSizeFile-uReadPos)) ?
+ (BUFREADCOMMENT+4) : (uSizeFile-uReadPos);
+ if (ZSEEK(*pzlib_filefunc_def,filestream,uReadPos,ZLIB_FILEFUNC_SEEK_SET)!=0)
+ break;
+
+ if (ZREAD(*pzlib_filefunc_def,filestream,buf,uReadSize)!=uReadSize)
+ break;
+
+ for (i=(int)uReadSize-3; (i--)>0;)
+ if (((*(buf+i))==0x50) && ((*(buf+i+1))==0x4b) &&
+ ((*(buf+i+2))==0x05) && ((*(buf+i+3))==0x06))
+ {
+ uPosFound = uReadPos+i;
+ break;
+ }
+
+ if (uPosFound!=0)
+ break;
+ }
+ TRYFREE(buf);
+ return uPosFound;
+}
+
+/*
+ Open a Zip file. path contain the full pathname (by example,
+ on a Windows NT computer "c:\\test\\zlib114.zip" or on an Unix computer
+ "zlib/zlib114.zip".
+ If the zipfile cannot be opened (file doesn't exist or in not valid), the
+ return value is NULL.
+ Else, the return value is a unzFile Handle, usable with other function
+ of this unzip package.
+*/
+extern unzFile ZEXPORT unzOpen2 (path, pzlib_filefunc_def)
+ const char *path;
+ zlib_filefunc_def* pzlib_filefunc_def;
+{
+ unz_s us;
+ unz_s *s;
+ uLong central_pos,uL;
+
+ uLong number_disk; /* number of the current dist, used for
+ spaning ZIP, unsupported, always 0*/
+ uLong number_disk_with_CD; /* number the the disk with central dir, used
+ for spaning ZIP, unsupported, always 0*/
+ uLong number_entry_CD; /* total number of entries in
+ the central dir
+ (same than number_entry on nospan) */
+
+ int err=UNZ_OK;
+
+ if (unz_copyright[0]!=' ')
+ return NULL;
+
+ if (pzlib_filefunc_def==NULL)
+ fill_fopen_filefunc(&us.z_filefunc);
+ else
+ us.z_filefunc = *pzlib_filefunc_def;
+
+ us.filestream= (*(us.z_filefunc.zopen_file))(us.z_filefunc.opaque,
+ path,
+ ZLIB_FILEFUNC_MODE_READ |
+ ZLIB_FILEFUNC_MODE_EXISTING);
+ if (us.filestream==NULL)
+ return NULL;
+
+ central_pos = unzlocal_SearchCentralDir(&us.z_filefunc,us.filestream);
+ if (central_pos==0)
+ err=UNZ_ERRNO;
+
+ if (ZSEEK(us.z_filefunc, us.filestream,
+ central_pos,ZLIB_FILEFUNC_SEEK_SET)!=0)
+ err=UNZ_ERRNO;
+
+ /* the signature, already checked */
+ if (unzlocal_getLong(&us.z_filefunc, us.filestream,&uL)!=UNZ_OK)
+ err=UNZ_ERRNO;
+
+ /* number of this disk */
+ if (unzlocal_getShort(&us.z_filefunc, us.filestream,&number_disk)!=UNZ_OK)
+ err=UNZ_ERRNO;
+
+ /* number of the disk with the start of the central directory */
+ if (unzlocal_getShort(&us.z_filefunc, us.filestream,&number_disk_with_CD)!=UNZ_OK)
+ err=UNZ_ERRNO;
+
+ /* total number of entries in the central dir on this disk */
+ if (unzlocal_getShort(&us.z_filefunc, us.filestream,&us.gi.number_entry)!=UNZ_OK)
+ err=UNZ_ERRNO;
+
+ /* total number of entries in the central dir */
+ if (unzlocal_getShort(&us.z_filefunc, us.filestream,&number_entry_CD)!=UNZ_OK)
+ err=UNZ_ERRNO;
+
+ if ((number_entry_CD!=us.gi.number_entry) ||
+ (number_disk_with_CD!=0) ||
+ (number_disk!=0))
+ err=UNZ_BADZIPFILE;
+
+ /* size of the central directory */
+ if (unzlocal_getLong(&us.z_filefunc, us.filestream,&us.size_central_dir)!=UNZ_OK)
+ err=UNZ_ERRNO;
+
+ /* offset of start of central directory with respect to the
+ starting disk number */
+ if (unzlocal_getLong(&us.z_filefunc, us.filestream,&us.offset_central_dir)!=UNZ_OK)
+ err=UNZ_ERRNO;
+
+ /* zipfile comment length */
+ if (unzlocal_getShort(&us.z_filefunc, us.filestream,&us.gi.size_comment)!=UNZ_OK)
+ err=UNZ_ERRNO;
+
+ if ((central_pos<us.offset_central_dir+us.size_central_dir) &&
+ (err==UNZ_OK))
+ err=UNZ_BADZIPFILE;
+
+ if (err!=UNZ_OK)
+ {
+ ZCLOSE(us.z_filefunc, us.filestream);
+ return NULL;
+ }
+
+ us.byte_before_the_zipfile = central_pos -
+ (us.offset_central_dir+us.size_central_dir);
+ us.central_pos = central_pos;
+ us.pfile_in_zip_read = NULL;
+ us.encrypted = 0;
+
+
+ s=(unz_s*)ALLOC(sizeof(unz_s));
+ *s=us;
+ unzGoToFirstFile((unzFile)s);
+ return (unzFile)s;
+}
+
+
+extern unzFile ZEXPORT unzOpen (path)
+ const char *path;
+{
+ return unzOpen2(path, NULL);
+}
+
+/*
+ Close a ZipFile opened with unzipOpen.
+ If there is files inside the .Zip opened with unzipOpenCurrentFile (see later),
+ these files MUST be closed with unzipCloseCurrentFile before call unzipClose.
+ return UNZ_OK if there is no problem. */
+extern int ZEXPORT unzClose (file)
+ unzFile file;
+{
+ unz_s* s;
+ if (file==NULL)
+ return UNZ_PARAMERROR;
+ s=(unz_s*)file;
+
+ if (s->pfile_in_zip_read!=NULL)
+ unzCloseCurrentFile(file);
+
+ ZCLOSE(s->z_filefunc, s->filestream);
+ TRYFREE(s);
+ return UNZ_OK;
+}
+
+
+/*
+ Write info about the ZipFile in the *pglobal_info structure.
+ No preparation of the structure is needed
+ return UNZ_OK if there is no problem. */
+extern int ZEXPORT unzGetGlobalInfo (file,pglobal_info)
+ unzFile file;
+ unz_global_info *pglobal_info;
+{
+ unz_s* s;
+ if (file==NULL)
+ return UNZ_PARAMERROR;
+ s=(unz_s*)file;
+ *pglobal_info=s->gi;
+ return UNZ_OK;
+}
+
+
+/*
+ Translate date/time from Dos format to tm_unz (readable more easilty)
+*/
+local void unzlocal_DosDateToTmuDate (ulDosDate, ptm)
+ uLong ulDosDate;
+ tm_unz* ptm;
+{
+ uLong uDate;
+ uDate = (uLong)(ulDosDate>>16);
+ ptm->tm_mday = (uInt)(uDate&0x1f) ;
+ ptm->tm_mon = (uInt)((((uDate)&0x1E0)/0x20)-1) ;
+ ptm->tm_year = (uInt)(((uDate&0x0FE00)/0x0200)+1980) ;
+
+ ptm->tm_hour = (uInt) ((ulDosDate &0xF800)/0x800);
+ ptm->tm_min = (uInt) ((ulDosDate&0x7E0)/0x20) ;
+ ptm->tm_sec = (uInt) (2*(ulDosDate&0x1f)) ;
+}
+
+/*
+ Get Info about the current file in the zipfile, with internal only info
+*/
+local int unzlocal_GetCurrentFileInfoInternal OF((unzFile file,
+ unz_file_info *pfile_info,
+ unz_file_info_internal
+ *pfile_info_internal,
+ char *szFileName,
+ uLong fileNameBufferSize,
+ void *extraField,
+ uLong extraFieldBufferSize,
+ char *szComment,
+ uLong commentBufferSize));
+
+local int unzlocal_GetCurrentFileInfoInternal (file,
+ pfile_info,
+ pfile_info_internal,
+ szFileName, fileNameBufferSize,
+ extraField, extraFieldBufferSize,
+ szComment, commentBufferSize)
+ unzFile file;
+ unz_file_info *pfile_info;
+ unz_file_info_internal *pfile_info_internal;
+ char *szFileName;
+ uLong fileNameBufferSize;
+ void *extraField;
+ uLong extraFieldBufferSize;
+ char *szComment;
+ uLong commentBufferSize;
+{
+ unz_s* s;
+ unz_file_info file_info;
+ unz_file_info_internal file_info_internal;
+ int err=UNZ_OK;
+ uLong uMagic;
+ long lSeek=0;
+
+ if (file==NULL)
+ return UNZ_PARAMERROR;
+ s=(unz_s*)file;
+ if (ZSEEK(s->z_filefunc, s->filestream,
+ s->pos_in_central_dir+s->byte_before_the_zipfile,
+ ZLIB_FILEFUNC_SEEK_SET)!=0)
+ err=UNZ_ERRNO;
+
+
+ /* we check the magic */
+ if (err==UNZ_OK) {
+ if (unzlocal_getLong(&s->z_filefunc, s->filestream,&uMagic) != UNZ_OK)
+ err=UNZ_ERRNO;
+ else if (uMagic!=0x02014b50)
+ err=UNZ_BADZIPFILE;
+ }
+
+ if (unzlocal_getShort(&s->z_filefunc, s->filestream,&file_info.version) != UNZ_OK)
+ err=UNZ_ERRNO;
+
+ if (unzlocal_getShort(&s->z_filefunc, s->filestream,&file_info.version_needed) != UNZ_OK)
+ err=UNZ_ERRNO;
+
+ if (unzlocal_getShort(&s->z_filefunc, s->filestream,&file_info.flag) != UNZ_OK)
+ err=UNZ_ERRNO;
+
+ if (unzlocal_getShort(&s->z_filefunc, s->filestream,&file_info.compression_method) != UNZ_OK)
+ err=UNZ_ERRNO;
+
+ if (unzlocal_getLong(&s->z_filefunc, s->filestream,&file_info.dosDate) != UNZ_OK)
+ err=UNZ_ERRNO;
+
+ unzlocal_DosDateToTmuDate(file_info.dosDate,&file_info.tmu_date);
+
+ if (unzlocal_getLong(&s->z_filefunc, s->filestream,&file_info.crc) != UNZ_OK)
+ err=UNZ_ERRNO;
+
+ if (unzlocal_getLong(&s->z_filefunc, s->filestream,&file_info.compressed_size) != UNZ_OK)
+ err=UNZ_ERRNO;
+
+ if (unzlocal_getLong(&s->z_filefunc, s->filestream,&file_info.uncompressed_size) != UNZ_OK)
+ err=UNZ_ERRNO;
+
+ if (unzlocal_getShort(&s->z_filefunc, s->filestream,&file_info.size_filename) != UNZ_OK)
+ err=UNZ_ERRNO;
+
+ if (unzlocal_getShort(&s->z_filefunc, s->filestream,&file_info.size_file_extra) != UNZ_OK)
+ err=UNZ_ERRNO;
+
+ if (unzlocal_getShort(&s->z_filefunc, s->filestream,&file_info.size_file_comment) != UNZ_OK)
+ err=UNZ_ERRNO;
+
+ if (unzlocal_getShort(&s->z_filefunc, s->filestream,&file_info.disk_num_start) != UNZ_OK)
+ err=UNZ_ERRNO;
+
+ if (unzlocal_getShort(&s->z_filefunc, s->filestream,&file_info.internal_fa) != UNZ_OK)
+ err=UNZ_ERRNO;
+
+ if (unzlocal_getLong(&s->z_filefunc, s->filestream,&file_info.external_fa) != UNZ_OK)
+ err=UNZ_ERRNO;
+
+ if (unzlocal_getLong(&s->z_filefunc, s->filestream,&file_info_internal.offset_curfile) != UNZ_OK)
+ err=UNZ_ERRNO;
+
+ lSeek+=file_info.size_filename;
+ if ((err==UNZ_OK) && (szFileName!=NULL))
+ {
+ uLong uSizeRead ;
+ if (file_info.size_filename<fileNameBufferSize)
+ {
+ *(szFileName+file_info.size_filename)='\0';
+ uSizeRead = file_info.size_filename;
+ }
+ else
+ uSizeRead = fileNameBufferSize;
+
+ if ((file_info.size_filename>0) && (fileNameBufferSize>0))
+ if (ZREAD(s->z_filefunc, s->filestream,szFileName,uSizeRead)!=uSizeRead)
+ err=UNZ_ERRNO;
+ lSeek -= uSizeRead;
+ }
+
+
+ if ((err==UNZ_OK) && (extraField!=NULL))
+ {
+ uLong uSizeRead ;
+ if (file_info.size_file_extra<extraFieldBufferSize)
+ uSizeRead = file_info.size_file_extra;
+ else
+ uSizeRead = extraFieldBufferSize;
+
+ if (lSeek!=0) {
+ if (ZSEEK(s->z_filefunc, s->filestream,lSeek,ZLIB_FILEFUNC_SEEK_CUR)==0)
+ lSeek=0;
+ else
+ err=UNZ_ERRNO;
+ }
+ if ((file_info.size_file_extra>0) && (extraFieldBufferSize>0))
+ if (ZREAD(s->z_filefunc, s->filestream,extraField,uSizeRead)!=uSizeRead)
+ err=UNZ_ERRNO;
+ lSeek += file_info.size_file_extra - uSizeRead;
+ }
+ else
+ lSeek+=file_info.size_file_extra;
+
+
+ if ((err==UNZ_OK) && (szComment!=NULL))
+ {
+ uLong uSizeRead ;
+ if (file_info.size_file_comment<commentBufferSize)
+ {
+ *(szComment+file_info.size_file_comment)='\0';
+ uSizeRead = file_info.size_file_comment;
+ }
+ else
+ uSizeRead = commentBufferSize;
+
+ if (lSeek!=0) {
+ if (ZSEEK(s->z_filefunc, s->filestream,lSeek,ZLIB_FILEFUNC_SEEK_CUR)==0)
+ lSeek=0;
+ else
+ err=UNZ_ERRNO;
+ }
+ if ((file_info.size_file_comment>0) && (commentBufferSize>0))
+ if (ZREAD(s->z_filefunc, s->filestream,szComment,uSizeRead)!=uSizeRead)
+ err=UNZ_ERRNO;
+ lSeek+=file_info.size_file_comment - uSizeRead;
+ }
+ else
+ lSeek+=file_info.size_file_comment;
+
+ if ((err==UNZ_OK) && (pfile_info!=NULL))
+ *pfile_info=file_info;
+
+ if ((err==UNZ_OK) && (pfile_info_internal!=NULL))
+ *pfile_info_internal=file_info_internal;
+
+ return err;
+}
+
+
+
+/*
+ Write info about the ZipFile in the *pglobal_info structure.
+ No preparation of the structure is needed
+ return UNZ_OK if there is no problem.
+*/
+extern int ZEXPORT unzGetCurrentFileInfo (file,
+ pfile_info,
+ szFileName, fileNameBufferSize,
+ extraField, extraFieldBufferSize,
+ szComment, commentBufferSize)
+ unzFile file;
+ unz_file_info *pfile_info;
+ char *szFileName;
+ uLong fileNameBufferSize;
+ void *extraField;
+ uLong extraFieldBufferSize;
+ char *szComment;
+ uLong commentBufferSize;
+{
+ return unzlocal_GetCurrentFileInfoInternal(file,pfile_info,NULL,
+ szFileName,fileNameBufferSize,
+ extraField,extraFieldBufferSize,
+ szComment,commentBufferSize);
+}
+
+/*
+ Set the current file of the zipfile to the first file.
+ return UNZ_OK if there is no problem
+*/
+extern int ZEXPORT unzGoToFirstFile (file)
+ unzFile file;
+{
+ int err=UNZ_OK;
+ unz_s* s;
+ if (file==NULL)
+ return UNZ_PARAMERROR;
+ s=(unz_s*)file;
+ s->pos_in_central_dir=s->offset_central_dir;
+ s->num_file=0;
+ err=unzlocal_GetCurrentFileInfoInternal(file,&s->cur_file_info,
+ &s->cur_file_info_internal,
+ NULL,0,NULL,0,NULL,0);
+ s->current_file_ok = (err == UNZ_OK);
+ return err;
+}
+
+/*
+ Set the current file of the zipfile to the next file.
+ return UNZ_OK if there is no problem
+ return UNZ_END_OF_LIST_OF_FILE if the actual file was the latest.
+*/
+extern int ZEXPORT unzGoToNextFile (file)
+ unzFile file;
+{
+ unz_s* s;
+ int err;
+
+ if (file==NULL)
+ return UNZ_PARAMERROR;
+ s=(unz_s*)file;
+ if (!s->current_file_ok)
+ return UNZ_END_OF_LIST_OF_FILE;
+ if (s->gi.number_entry != 0xffff) /* 2^16 files overflow hack */
+ if (s->num_file+1==s->gi.number_entry)
+ return UNZ_END_OF_LIST_OF_FILE;
+
+ s->pos_in_central_dir += SIZECENTRALDIRITEM + s->cur_file_info.size_filename +
+ s->cur_file_info.size_file_extra + s->cur_file_info.size_file_comment ;
+ s->num_file++;
+ err = unzlocal_GetCurrentFileInfoInternal(file,&s->cur_file_info,
+ &s->cur_file_info_internal,
+ NULL,0,NULL,0,NULL,0);
+ s->current_file_ok = (err == UNZ_OK);
+ return err;
+}
+
+
+/*
+ Try locate the file szFileName in the zipfile.
+ For the iCaseSensitivity signification, see unzipStringFileNameCompare
+
+ return value :
+ UNZ_OK if the file is found. It becomes the current file.
+ UNZ_END_OF_LIST_OF_FILE if the file is not found
+*/
+extern int ZEXPORT unzLocateFile (file, szFileName, iCaseSensitivity)
+ unzFile file;
+ const char *szFileName;
+ int iCaseSensitivity;
+{
+ unz_s* s;
+ int err;
+
+ /* We remember the 'current' position in the file so that we can jump
+ * back there if we fail.
+ */
+ unz_file_info cur_file_infoSaved;
+ unz_file_info_internal cur_file_info_internalSaved;
+ uLong num_fileSaved;
+ uLong pos_in_central_dirSaved;
+
+
+ if (file==NULL)
+ return UNZ_PARAMERROR;
+
+ if (strlen(szFileName)>=UNZ_MAXFILENAMEINZIP)
+ return UNZ_PARAMERROR;
+
+ s=(unz_s*)file;
+ if (!s->current_file_ok)
+ return UNZ_END_OF_LIST_OF_FILE;
+
+ /* Save the current state */
+ num_fileSaved = s->num_file;
+ pos_in_central_dirSaved = s->pos_in_central_dir;
+ cur_file_infoSaved = s->cur_file_info;
+ cur_file_info_internalSaved = s->cur_file_info_internal;
+
+ err = unzGoToFirstFile(file);
+
+ while (err == UNZ_OK)
+ {
+ char szCurrentFileName[UNZ_MAXFILENAMEINZIP+1];
+ err = unzGetCurrentFileInfo(file,NULL,
+ szCurrentFileName,sizeof(szCurrentFileName)-1,
+ NULL,0,NULL,0);
+ if (err == UNZ_OK)
+ {
+ if (unzStringFileNameCompare(szCurrentFileName,
+ szFileName,iCaseSensitivity)==0)
+ return UNZ_OK;
+ err = unzGoToNextFile(file);
+ }
+ }
+
+ /* We failed, so restore the state of the 'current file' to where we
+ * were.
+ */
+ s->num_file = num_fileSaved ;
+ s->pos_in_central_dir = pos_in_central_dirSaved ;
+ s->cur_file_info = cur_file_infoSaved;
+ s->cur_file_info_internal = cur_file_info_internalSaved;
+ return err;
+}
+
+
+/*
+///////////////////////////////////////////
+// Contributed by Ryan Haksi (mailto://cryogen@infoserve.net)
+// I need random access
+//
+// Further optimization could be realized by adding an ability
+// to cache the directory in memory. The goal being a single
+// comprehensive file read to put the file I need in a memory.
+*/
+
+/*
+typedef struct unz_file_pos_s
+{
+ uLong pos_in_zip_directory; // offset in file
+ uLong num_of_file; // # of file
+} unz_file_pos;
+*/
+
+extern int ZEXPORT unzGetFilePos(file, file_pos)
+ unzFile file;
+ unz_file_pos* file_pos;
+{
+ unz_s* s;
+
+ if (file==NULL || file_pos==NULL)
+ return UNZ_PARAMERROR;
+ s=(unz_s*)file;
+ if (!s->current_file_ok)
+ return UNZ_END_OF_LIST_OF_FILE;
+
+ file_pos->pos_in_zip_directory = s->pos_in_central_dir;
+ file_pos->num_of_file = s->num_file;
+
+ return UNZ_OK;
+}
+
+extern int ZEXPORT unzGoToFilePos(file, file_pos)
+ unzFile file;
+ unz_file_pos* file_pos;
+{
+ unz_s* s;
+ int err;
+
+ if (file==NULL || file_pos==NULL)
+ return UNZ_PARAMERROR;
+ s=(unz_s*)file;
+
+ /* jump to the right spot */
+ s->pos_in_central_dir = file_pos->pos_in_zip_directory;
+ s->num_file = file_pos->num_of_file;
+
+ /* set the current file */
+ err = unzlocal_GetCurrentFileInfoInternal(file,&s->cur_file_info,
+ &s->cur_file_info_internal,
+ NULL,0,NULL,0,NULL,0);
+ /* return results */
+ s->current_file_ok = (err == UNZ_OK);
+ return err;
+}
+
+/*
+// Unzip Helper Functions - should be here?
+///////////////////////////////////////////
+*/
+
+/*
+ Read the local header of the current zipfile
+ Check the coherency of the local header and info in the end of central
+ directory about this file
+ store in *piSizeVar the size of extra info in local header
+ (filename and size of extra field data)
+*/
+local int unzlocal_CheckCurrentFileCoherencyHeader (s,piSizeVar,
+ poffset_local_extrafield,
+ psize_local_extrafield)
+ unz_s* s;
+ uInt* piSizeVar;
+ uLong *poffset_local_extrafield;
+ uInt *psize_local_extrafield;
+{
+ uLong uMagic,uData,uFlags;
+ uLong size_filename;
+ uLong size_extra_field;
+ int err=UNZ_OK;
+
+ *piSizeVar = 0;
+ *poffset_local_extrafield = 0;
+ *psize_local_extrafield = 0;
+
+ if (ZSEEK(s->z_filefunc, s->filestream,s->cur_file_info_internal.offset_curfile +
+ s->byte_before_the_zipfile,ZLIB_FILEFUNC_SEEK_SET)!=0)
+ return UNZ_ERRNO;
+
+
+ if (err==UNZ_OK) {
+ if (unzlocal_getLong(&s->z_filefunc, s->filestream,&uMagic) != UNZ_OK)
+ err=UNZ_ERRNO;
+ else if (uMagic!=0x04034b50)
+ err=UNZ_BADZIPFILE;
+ }
+
+ if (unzlocal_getShort(&s->z_filefunc, s->filestream,&uData) != UNZ_OK)
+ err=UNZ_ERRNO;
+/*
+ else if ((err==UNZ_OK) && (uData!=s->cur_file_info.wVersion))
+ err=UNZ_BADZIPFILE;
+*/
+ if (unzlocal_getShort(&s->z_filefunc, s->filestream,&uFlags) != UNZ_OK)
+ err=UNZ_ERRNO;
+
+ if (unzlocal_getShort(&s->z_filefunc, s->filestream,&uData) != UNZ_OK)
+ err=UNZ_ERRNO;
+ else if ((err==UNZ_OK) && (uData!=s->cur_file_info.compression_method))
+ err=UNZ_BADZIPFILE;
+
+ if ((err==UNZ_OK) && (s->cur_file_info.compression_method!=0) &&
+ (s->cur_file_info.compression_method!=Z_DEFLATED))
+ err=UNZ_BADZIPFILE;
+
+ if (unzlocal_getLong(&s->z_filefunc, s->filestream,&uData) != UNZ_OK) /* date/time */
+ err=UNZ_ERRNO;
+
+ if (unzlocal_getLong(&s->z_filefunc, s->filestream,&uData) != UNZ_OK) /* crc */
+ err=UNZ_ERRNO;
+ else if ((err==UNZ_OK) && (uData!=s->cur_file_info.crc) &&
+ ((uFlags & 8)==0))
+ err=UNZ_BADZIPFILE;
+
+ if (unzlocal_getLong(&s->z_filefunc, s->filestream,&uData) != UNZ_OK) /* size compr */
+ err=UNZ_ERRNO;
+ else if ((err==UNZ_OK) && (uData!=s->cur_file_info.compressed_size) &&
+ ((uFlags & 8)==0))
+ err=UNZ_BADZIPFILE;
+
+ if (unzlocal_getLong(&s->z_filefunc, s->filestream,&uData) != UNZ_OK) /* size uncompr */
+ err=UNZ_ERRNO;
+ else if ((err==UNZ_OK) && (uData!=s->cur_file_info.uncompressed_size) &&
+ ((uFlags & 8)==0))
+ err=UNZ_BADZIPFILE;
+
+
+ if (unzlocal_getShort(&s->z_filefunc, s->filestream,&size_filename) != UNZ_OK)
+ err=UNZ_ERRNO;
+ else if ((err==UNZ_OK) && (size_filename!=s->cur_file_info.size_filename))
+ err=UNZ_BADZIPFILE;
+
+ *piSizeVar += (uInt)size_filename;
+
+ if (unzlocal_getShort(&s->z_filefunc, s->filestream,&size_extra_field) != UNZ_OK)
+ err=UNZ_ERRNO;
+ *poffset_local_extrafield= s->cur_file_info_internal.offset_curfile +
+ SIZEZIPLOCALHEADER + size_filename;
+ *psize_local_extrafield = (uInt)size_extra_field;
+
+ *piSizeVar += (uInt)size_extra_field;
+
+ return err;
+}
+
+/*
+ Open for reading data the current file in the zipfile.
+ If there is no error and the file is opened, the return value is UNZ_OK.
+*/
+extern int ZEXPORT unzOpenCurrentFile3 (file, method, level, raw, password)
+ unzFile file;
+ int* method;
+ int* level;
+ int raw;
+ const char* password;
+{
+ int err=UNZ_OK;
+ uInt iSizeVar;
+ unz_s* s;
+ file_in_zip_read_info_s* pfile_in_zip_read_info;
+ uLong offset_local_extrafield; /* offset of the local extra field */
+ uInt size_local_extrafield; /* size of the local extra field */
+ if (password != NULL)
+ return UNZ_PARAMERROR;
+
+ if (file==NULL)
+ return UNZ_PARAMERROR;
+ s=(unz_s*)file;
+ if (!s->current_file_ok)
+ return UNZ_PARAMERROR;
+
+ if (s->pfile_in_zip_read != NULL)
+ unzCloseCurrentFile(file);
+
+ if (unzlocal_CheckCurrentFileCoherencyHeader(s,&iSizeVar,
+ &offset_local_extrafield,&size_local_extrafield)!=UNZ_OK)
+ return UNZ_BADZIPFILE;
+
+ pfile_in_zip_read_info = (file_in_zip_read_info_s*)
+ ALLOC(sizeof(file_in_zip_read_info_s));
+ if (pfile_in_zip_read_info==NULL)
+ return UNZ_INTERNALERROR;
+
+ pfile_in_zip_read_info->read_buffer=(char*)ALLOC(UNZ_BUFSIZE);
+ pfile_in_zip_read_info->offset_local_extrafield = offset_local_extrafield;
+ pfile_in_zip_read_info->size_local_extrafield = size_local_extrafield;
+ pfile_in_zip_read_info->pos_local_extrafield=0;
+ pfile_in_zip_read_info->raw=raw;
+
+ if (pfile_in_zip_read_info->read_buffer==NULL)
+ {
+ TRYFREE(pfile_in_zip_read_info);
+ return UNZ_INTERNALERROR;
+ }
+
+ pfile_in_zip_read_info->stream_initialised=0;
+
+ if (method!=NULL)
+ *method = (int)s->cur_file_info.compression_method;
+
+ if (level!=NULL)
+ {
+ *level = 6;
+ switch (s->cur_file_info.flag & 0x06)
+ {
+ case 6 : *level = 1; break;
+ case 4 : *level = 2; break;
+ case 2 : *level = 9; break;
+ }
+ }
+
+ if ((s->cur_file_info.compression_method!=0) &&
+ (s->cur_file_info.compression_method!=Z_DEFLATED))
+ err=UNZ_BADZIPFILE;
+
+ pfile_in_zip_read_info->crc32_wait=s->cur_file_info.crc;
+ pfile_in_zip_read_info->crc32=0;
+ pfile_in_zip_read_info->compression_method =
+ s->cur_file_info.compression_method;
+ pfile_in_zip_read_info->filestream=s->filestream;
+ pfile_in_zip_read_info->z_filefunc=s->z_filefunc;
+ pfile_in_zip_read_info->byte_before_the_zipfile=s->byte_before_the_zipfile;
+
+ pfile_in_zip_read_info->stream.total_out = 0;
+
+ if ((s->cur_file_info.compression_method==Z_DEFLATED) &&
+ (!raw))
+ {
+ pfile_in_zip_read_info->stream.zalloc = (alloc_func)0;
+ pfile_in_zip_read_info->stream.zfree = (free_func)0;
+ pfile_in_zip_read_info->stream.opaque = (voidpf)0;
+ pfile_in_zip_read_info->stream.next_in = (voidpf)0;
+ pfile_in_zip_read_info->stream.avail_in = 0;
+
+ err=inflateInit2(&pfile_in_zip_read_info->stream, -MAX_WBITS);
+ if (err == Z_OK)
+ pfile_in_zip_read_info->stream_initialised=1;
+ else
+ {
+ TRYFREE(pfile_in_zip_read_info);
+ return err;
+ }
+ /* windowBits is passed < 0 to tell that there is no zlib header.
+ * Note that in this case inflate *requires* an extra "dummy" byte
+ * after the compressed stream in order to complete decompression and
+ * return Z_STREAM_END.
+ * In unzip, i don't wait absolutely Z_STREAM_END because I known the
+ * size of both compressed and uncompressed data
+ */
+ }
+ pfile_in_zip_read_info->rest_read_compressed =
+ s->cur_file_info.compressed_size ;
+ pfile_in_zip_read_info->rest_read_uncompressed =
+ s->cur_file_info.uncompressed_size ;
+
+
+ pfile_in_zip_read_info->pos_in_zipfile =
+ s->cur_file_info_internal.offset_curfile + SIZEZIPLOCALHEADER +
+ iSizeVar;
+
+ pfile_in_zip_read_info->stream.avail_in = (uInt)0;
+
+ s->pfile_in_zip_read = pfile_in_zip_read_info;
+
+ return UNZ_OK;
+}
+
+extern int ZEXPORT unzOpenCurrentFile (file)
+ unzFile file;
+{
+ return unzOpenCurrentFile3(file, NULL, NULL, 0, NULL);
+}
+
+extern int ZEXPORT unzOpenCurrentFilePassword (file, password)
+ unzFile file;
+ const char* password;
+{
+ return unzOpenCurrentFile3(file, NULL, NULL, 0, password);
+}
+
+extern int ZEXPORT unzOpenCurrentFile2 (file,method,level,raw)
+ unzFile file;
+ int* method;
+ int* level;
+ int raw;
+{
+ return unzOpenCurrentFile3(file, method, level, raw, NULL);
+}
+
+/*
+ Read bytes from the current file.
+ buf contain buffer where data must be copied
+ len the size of buf.
+
+ return the number of byte copied if somes bytes are copied
+ return 0 if the end of file was reached
+ return <0 with error code if there is an error
+ (UNZ_ERRNO for IO error, or zLib error for uncompress error)
+*/
+extern int ZEXPORT unzReadCurrentFile (file, buf, len)
+ unzFile file;
+ voidp buf;
+ unsigned len;
+{
+ int err=UNZ_OK;
+ uInt iRead = 0;
+ unz_s* s;
+ file_in_zip_read_info_s* pfile_in_zip_read_info;
+ if (file==NULL)
+ return UNZ_PARAMERROR;
+ s=(unz_s*)file;
+ pfile_in_zip_read_info=s->pfile_in_zip_read;
+
+ if (pfile_in_zip_read_info==NULL)
+ return UNZ_PARAMERROR;
+
+
+ if ((pfile_in_zip_read_info->read_buffer == NULL))
+ return UNZ_END_OF_LIST_OF_FILE;
+ if (len==0)
+ return 0;
+
+ pfile_in_zip_read_info->stream.next_out = (Bytef*)buf;
+
+ pfile_in_zip_read_info->stream.avail_out = (uInt)len;
+
+ if ((len>pfile_in_zip_read_info->rest_read_uncompressed) &&
+ (!(pfile_in_zip_read_info->raw)))
+ pfile_in_zip_read_info->stream.avail_out =
+ (uInt)pfile_in_zip_read_info->rest_read_uncompressed;
+
+ if ((len>pfile_in_zip_read_info->rest_read_compressed+
+ pfile_in_zip_read_info->stream.avail_in) &&
+ (pfile_in_zip_read_info->raw))
+ pfile_in_zip_read_info->stream.avail_out =
+ (uInt)pfile_in_zip_read_info->rest_read_compressed+
+ pfile_in_zip_read_info->stream.avail_in;
+
+ while (pfile_in_zip_read_info->stream.avail_out>0)
+ {
+ if ((pfile_in_zip_read_info->stream.avail_in==0) &&
+ (pfile_in_zip_read_info->rest_read_compressed>0))
+ {
+ uInt uReadThis = UNZ_BUFSIZE;
+ if (pfile_in_zip_read_info->rest_read_compressed<uReadThis)
+ uReadThis = (uInt)pfile_in_zip_read_info->rest_read_compressed;
+ if (uReadThis == 0)
+ return UNZ_EOF;
+ if (ZSEEK(pfile_in_zip_read_info->z_filefunc,
+ pfile_in_zip_read_info->filestream,
+ pfile_in_zip_read_info->pos_in_zipfile +
+ pfile_in_zip_read_info->byte_before_the_zipfile,
+ ZLIB_FILEFUNC_SEEK_SET)!=0)
+ return UNZ_ERRNO;
+ if (ZREAD(pfile_in_zip_read_info->z_filefunc,
+ pfile_in_zip_read_info->filestream,
+ pfile_in_zip_read_info->read_buffer,
+ uReadThis)!=uReadThis)
+ return UNZ_ERRNO;
+
+
+
+
+ pfile_in_zip_read_info->pos_in_zipfile += uReadThis;
+
+ pfile_in_zip_read_info->rest_read_compressed-=uReadThis;
+
+ pfile_in_zip_read_info->stream.next_in =
+ (Bytef*)pfile_in_zip_read_info->read_buffer;
+ pfile_in_zip_read_info->stream.avail_in = (uInt)uReadThis;
+ }
+
+ if ((pfile_in_zip_read_info->compression_method==0) || (pfile_in_zip_read_info->raw))
+ {
+ uInt uDoCopy,i ;
+
+ if ((pfile_in_zip_read_info->stream.avail_in == 0) &&
+ (pfile_in_zip_read_info->rest_read_compressed == 0))
+ return (iRead==0) ? UNZ_EOF : iRead;
+
+ if (pfile_in_zip_read_info->stream.avail_out <
+ pfile_in_zip_read_info->stream.avail_in)
+ uDoCopy = pfile_in_zip_read_info->stream.avail_out ;
+ else
+ uDoCopy = pfile_in_zip_read_info->stream.avail_in ;
+
+ for (i=0;i<uDoCopy;i++)
+ *(pfile_in_zip_read_info->stream.next_out+i) =
+ *(pfile_in_zip_read_info->stream.next_in+i);
+
+ pfile_in_zip_read_info->crc32 = crc32(pfile_in_zip_read_info->crc32,
+ pfile_in_zip_read_info->stream.next_out,
+ uDoCopy);
+ pfile_in_zip_read_info->rest_read_uncompressed-=uDoCopy;
+ pfile_in_zip_read_info->stream.avail_in -= uDoCopy;
+ pfile_in_zip_read_info->stream.avail_out -= uDoCopy;
+ pfile_in_zip_read_info->stream.next_out += uDoCopy;
+ pfile_in_zip_read_info->stream.next_in += uDoCopy;
+ pfile_in_zip_read_info->stream.total_out += uDoCopy;
+ iRead += uDoCopy;
+ }
+ else
+ {
+ uLong uTotalOutBefore,uTotalOutAfter;
+ const Bytef *bufBefore;
+ uLong uOutThis;
+ int flush=Z_SYNC_FLUSH;
+
+ uTotalOutBefore = pfile_in_zip_read_info->stream.total_out;
+ bufBefore = pfile_in_zip_read_info->stream.next_out;
+
+ /*
+ if ((pfile_in_zip_read_info->rest_read_uncompressed ==
+ pfile_in_zip_read_info->stream.avail_out) &&
+ (pfile_in_zip_read_info->rest_read_compressed == 0))
+ flush = Z_FINISH;
+ */
+ err=inflate(&pfile_in_zip_read_info->stream,flush);
+
+ if ((err>=0) && (pfile_in_zip_read_info->stream.msg!=NULL))
+ err = Z_DATA_ERROR;
+
+ uTotalOutAfter = pfile_in_zip_read_info->stream.total_out;
+ uOutThis = uTotalOutAfter-uTotalOutBefore;
+
+ pfile_in_zip_read_info->crc32 =
+ crc32(pfile_in_zip_read_info->crc32,bufBefore,
+ (uInt)(uOutThis));
+
+ pfile_in_zip_read_info->rest_read_uncompressed -=
+ uOutThis;
+
+ iRead += (uInt)(uTotalOutAfter - uTotalOutBefore);
+
+ if (err==Z_STREAM_END)
+ return (iRead==0) ? UNZ_EOF : iRead;
+ if (err!=Z_OK)
+ break;
+ }
+ }
+
+ if (err==Z_OK)
+ return iRead;
+ return err;
+}
+
+
+/*
+ Give the current position in uncompressed data
+*/
+extern z_off_t ZEXPORT unztell (file)
+ unzFile file;
+{
+ unz_s* s;
+ file_in_zip_read_info_s* pfile_in_zip_read_info;
+ if (file==NULL)
+ return UNZ_PARAMERROR;
+ s=(unz_s*)file;
+ pfile_in_zip_read_info=s->pfile_in_zip_read;
+
+ if (pfile_in_zip_read_info==NULL)
+ return UNZ_PARAMERROR;
+
+ return (z_off_t)pfile_in_zip_read_info->stream.total_out;
+}
+
+
+/*
+ return 1 if the end of file was reached, 0 elsewhere
+*/
+extern int ZEXPORT unzeof (file)
+ unzFile file;
+{
+ unz_s* s;
+ file_in_zip_read_info_s* pfile_in_zip_read_info;
+ if (file==NULL)
+ return UNZ_PARAMERROR;
+ s=(unz_s*)file;
+ pfile_in_zip_read_info=s->pfile_in_zip_read;
+
+ if (pfile_in_zip_read_info==NULL)
+ return UNZ_PARAMERROR;
+
+ if (pfile_in_zip_read_info->rest_read_uncompressed == 0)
+ return 1;
+ else
+ return 0;
+}
+
+
+
+/*
+ Read extra field from the current file (opened by unzOpenCurrentFile)
+ This is the local-header version of the extra field (sometimes, there is
+ more info in the local-header version than in the central-header)
+
+ if buf==NULL, it return the size of the local extra field that can be read
+
+ if buf!=NULL, len is the size of the buffer, the extra header is copied in
+ buf.
+ the return value is the number of bytes copied in buf, or (if <0)
+ the error code
+*/
+extern int ZEXPORT unzGetLocalExtrafield (file,buf,len)
+ unzFile file;
+ voidp buf;
+ unsigned len;
+{
+ unz_s* s;
+ file_in_zip_read_info_s* pfile_in_zip_read_info;
+ uInt read_now;
+ uLong size_to_read;
+
+ if (file==NULL)
+ return UNZ_PARAMERROR;
+ s=(unz_s*)file;
+ pfile_in_zip_read_info=s->pfile_in_zip_read;
+
+ if (pfile_in_zip_read_info==NULL)
+ return UNZ_PARAMERROR;
+
+ size_to_read = (pfile_in_zip_read_info->size_local_extrafield -
+ pfile_in_zip_read_info->pos_local_extrafield);
+
+ if (buf==NULL)
+ return (int)size_to_read;
+
+ if (len>size_to_read)
+ read_now = (uInt)size_to_read;
+ else
+ read_now = (uInt)len ;
+
+ if (read_now==0)
+ return 0;
+
+ if (ZSEEK(pfile_in_zip_read_info->z_filefunc,
+ pfile_in_zip_read_info->filestream,
+ pfile_in_zip_read_info->offset_local_extrafield +
+ pfile_in_zip_read_info->pos_local_extrafield,
+ ZLIB_FILEFUNC_SEEK_SET)!=0)
+ return UNZ_ERRNO;
+
+ if (ZREAD(pfile_in_zip_read_info->z_filefunc,
+ pfile_in_zip_read_info->filestream,
+ buf,read_now)!=read_now)
+ return UNZ_ERRNO;
+
+ return (int)read_now;
+}
+
+/*
+ Close the file in zip opened with unzipOpenCurrentFile
+ Return UNZ_CRCERROR if all the file was read but the CRC is not good
+*/
+extern int ZEXPORT unzCloseCurrentFile (file)
+ unzFile file;
+{
+ int err=UNZ_OK;
+
+ unz_s* s;
+ file_in_zip_read_info_s* pfile_in_zip_read_info;
+ if (file==NULL)
+ return UNZ_PARAMERROR;
+ s=(unz_s*)file;
+ pfile_in_zip_read_info=s->pfile_in_zip_read;
+
+ if (pfile_in_zip_read_info==NULL)
+ return UNZ_PARAMERROR;
+
+
+ if ((pfile_in_zip_read_info->rest_read_uncompressed == 0) &&
+ (!pfile_in_zip_read_info->raw))
+ {
+ if (pfile_in_zip_read_info->crc32 != pfile_in_zip_read_info->crc32_wait)
+ err=UNZ_CRCERROR;
+ }
+
+
+ TRYFREE(pfile_in_zip_read_info->read_buffer);
+ pfile_in_zip_read_info->read_buffer = NULL;
+ if (pfile_in_zip_read_info->stream_initialised)
+ inflateEnd(&pfile_in_zip_read_info->stream);
+
+ pfile_in_zip_read_info->stream_initialised = 0;
+ TRYFREE(pfile_in_zip_read_info);
+
+ s->pfile_in_zip_read=NULL;
+
+ return err;
+}
+
+
+/*
+ Get the global comment string of the ZipFile, in the szComment buffer.
+ uSizeBuf is the size of the szComment buffer.
+ return the number of byte copied or an error code <0
+*/
+extern int ZEXPORT unzGetGlobalComment (file, szComment, uSizeBuf)
+ unzFile file;
+ char *szComment;
+ uLong uSizeBuf;
+{
+// int err=UNZ_OK;
+ unz_s* s;
+ uLong uReadThis ;
+ if (file==NULL)
+ return UNZ_PARAMERROR;
+ s=(unz_s*)file;
+
+ uReadThis = uSizeBuf;
+ if (uReadThis>s->gi.size_comment)
+ uReadThis = s->gi.size_comment;
+
+ if (ZSEEK(s->z_filefunc,s->filestream,s->central_pos+22,ZLIB_FILEFUNC_SEEK_SET)!=0)
+ return UNZ_ERRNO;
+
+ if (uReadThis>0)
+ {
+ *szComment='\0';
+ if (ZREAD(s->z_filefunc,s->filestream,szComment,uReadThis)!=uReadThis)
+ return UNZ_ERRNO;
+ }
+
+ if ((szComment != NULL) && (uSizeBuf > s->gi.size_comment))
+ *(szComment+s->gi.size_comment)='\0';
+ return (int)uReadThis;
+}
+
+/* Additions by RX '2004 */
+extern uLong ZEXPORT unzGetOffset (file)
+ unzFile file;
+{
+ unz_s* s;
+
+ if (file==NULL)
+ return UNZ_PARAMERROR;
+ s=(unz_s*)file;
+ if (!s->current_file_ok)
+ return 0;
+ if (s->gi.number_entry != 0 && s->gi.number_entry != 0xffff)
+ if (s->num_file==s->gi.number_entry)
+ return 0;
+ return s->pos_in_central_dir;
+}
+
+extern int ZEXPORT unzSetOffset (file, pos)
+ unzFile file;
+ uLong pos;
+{
+ unz_s* s;
+ int err;
+
+ if (file==NULL)
+ return UNZ_PARAMERROR;
+ s=(unz_s*)file;
+
+ s->pos_in_central_dir = pos;
+ s->num_file = s->gi.number_entry; /* hack */
+ err = unzlocal_GetCurrentFileInfoInternal(file,&s->cur_file_info,
+ &s->cur_file_info_internal,
+ NULL,0,NULL,0,NULL,0);
+ s->current_file_ok = (err == UNZ_OK);
+ return err;
+}
diff --git a/extensions/source/macosx/spotlight/version.plist b/extensions/source/macosx/spotlight/version.plist
new file mode 100644
index 000000000000..79fc99b2c2ad
--- /dev/null
+++ b/extensions/source/macosx/spotlight/version.plist
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>BuildVersion</key>
+ <string>266</string>
+ <key>CFBundleShortVersionString</key>
+ <string>1.0</string>
+ <key>CFBundleVersion</key>
+ <string>1.0</string>
+ <key>ProjectName</key>
+ <string>DevToolsWizardTemplates</string>
+ <key>SourceVersion</key>
+ <string>3070000</string>
+</dict>
+</plist>
diff --git a/extensions/source/nsplugin/source/exports.dxp b/extensions/source/nsplugin/source/exports.dxp
new file mode 100644
index 000000000000..e8b697289c20
--- /dev/null
+++ b/extensions/source/nsplugin/source/exports.dxp
@@ -0,0 +1,16 @@
+NPP_GetMIMEDescription
+NPP_GetValue
+NPP_Initialize
+NPP_GetJavaClass
+NPP_Shutdown
+NPP_New
+NPP_Destroy
+NPP_SetWindow
+NPP_NewStream
+NPP_WriteReady
+NPP_Write
+NPP_DestroyStream
+NPP_StreamAsFile
+NPP_URLNotify
+NPP_Print
+NPP_Shutdown
diff --git a/extensions/source/nsplugin/source/exports_wnt.dxp b/extensions/source/nsplugin/source/exports_wnt.dxp
new file mode 100644
index 000000000000..a27be8c38300
--- /dev/null
+++ b/extensions/source/nsplugin/source/exports_wnt.dxp
@@ -0,0 +1,18 @@
+NPP_GetMIMEDescription
+NPP_Initialize
+NPP_Shutdown
+NPP_New
+NPP_Destroy
+NPP_SetWindow
+NPP_NewStream
+NPP_WriteReady
+NPP_Write
+NPP_DestroyStream
+NPP_StreamAsFile
+NPP_URLNotify
+NPP_Print
+NPP_Shutdown
+NP_GetEntryPoints
+NP_Initialize
+NP_Shutdown
+NP_GetMIMEDescription
diff --git a/extensions/source/nsplugin/source/makefile.mk b/extensions/source/nsplugin/source/makefile.mk
new file mode 100644
index 000000000000..1790851bd3d0
--- /dev/null
+++ b/extensions/source/nsplugin/source/makefile.mk
@@ -0,0 +1,162 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ=..$/..$/..
+PRJNAME=extensions
+TARGET=npsoplugin
+
+ENABLE_EXCEPTIONS=TRUE
+USE_DEFFILE=TRUE
+
+# --- Settings ----------------------------------
+
+.INCLUDE : settings.mk
+
+INCPRE=$(SOLARINCDIR)$/npsdk
+
+.IF "$(GUI)"=="UNX"
+
+# not sure about -DMOZ_X11 but otheriwse some struct member don't exist...
+CFLAGS+=-DMOZ_X11
+
+.IF "$(ENABLE_GTK)"==""
+
+dummy:
+ @echo GTK disabled - nothing to build
+
+.ELSE # "$(ENABLE_GTK)"==""
+.IF "$(OS)"=="LINUX" || "$(OS)"=="FREEBSD" || "$(OS)"=="OPENBSD"
+INC+= -DNP_LINUX
+.ENDIF
+PKGCONFIG_MODULES=gtk+-2.0
+.INCLUDE: pkg_config.mk
+.ENDIF # "$(ENABLE_GTK)"==""
+.ENDIF # "$(GUI)"=="UNX"
+.IF "$(GUI)"=="WNT"
+INC+= -DENGLISH
+.ENDIF
+
+
+# --- Files -------------------------------------
+
+SLOFILES= $(SLO)$/npshell.obj \
+ $(SLO)$/so_env.obj
+
+SHL1OBJS= $(SLO)$/npshell.obj \
+ $(SLO)$/so_env.obj
+
+.IF "$(GUI)"=="UNX"
+STDLIBS+=$(SOLARLIBDIR)$/npunix.o
+SHL1STDLIBS+=$(SOLARLIBDIR)$/npunix.o
+#.IF "$(OS)"!="FREEBSD"
+#SHL1STDLIBS+= -ldl -lnsl
+#.ENDIF #FREEBSD
+.ENDIF #UNX
+.IF "$(GUI)"=="WNT"
+SHL1OBJS+=$(SOLARLIBDIR)$/pathutils-slo.obj
+STDLIBS+=$(SOLARLIBDIR)$/npwin.obj
+SHL1STDLIBS+= $(SHELL32LIB) $(SOLARLIBDIR)$/npwin.obj
+
+.ENDIF
+
+OBJFILES=\
+ $(OBJ)$/so_closelistener.obj\
+ $(OBJ)$/so_instance.obj\
+ $(OBJ)$/so_env.obj\
+ $(OBJ)$/so_main.obj
+
+# --- Plugin executable -------------------------
+APP1TARGET=nsplugin$(EXEPOSTFIX)
+APP1OBJS=$(OBJFILES)
+
+APP1STDLIBS=\
+ $(CPPULIB) \
+ $(CPPUHELPERLIB) \
+ $(SALLIB)
+
+.IF "$(OS)"=="SOLARIS"
+APP1STDLIBS+= -lsocket -lnsl
+.ENDIF
+
+.IF "$(GUI)"=="WNT"
+DEPOBJFILES=$(OBJ)$/nsp_windows.obj
+APP1OBJS+=$(OBJ)$/nsp_windows.obj $(SOLARLIBDIR)$/pathutils-obj.obj
+APP1STDLIBS+= $(WS2_32LIB) $(SHELL32LIB) $(OLE32LIB) $(KERNEL32LIB) $(USER32LIB) $(GDI32LIB) $(WINSPOOLLIB) $(COMDLG32LIB) $(ADVAPI32LIB) $(OLEAAUT32LIB) $(UUIDLIB)
+.ENDIF
+
+# --- Library -----------------------------------
+
+SHL1TARGET=$(TARGET)_so
+.IF "$(GUI)"=="WNT"
+SHL1STDLIBS+= $(WS2_32LIB) $(SHELL32LIB) $(OLE32LIB) $(KERNEL32LIB) $(USER32LIB) $(GDI32LIB) $(WINSPOOLLIB) $(COMDLG32LIB) $(ADVAPI32LIB) $(OLE32LIB) $(OLEAAUT32LIB) $(UUIDLIB) $(KERNEL32LIB) $(USER32LIB) $(GDI32LIB) $(WINSPOOLLIB) $(COMDLG32LIB) $(ADVAPI32LIB)
+.ENDIF
+
+SHL1DEPN=
+SHL1IMPLIB= i$(SHL1TARGET)
+SHL1DEF= $(MISC)$/$(SHL1TARGET).def
+SHL1RPATH=BRAND
+
+# ----- get some additional keys in versioninfo ------------
+SHL1ADD_VERINFO=nsplugin.rc
+SHL1DEPN+=$(SHL1ADD_VERINFO)
+
+DEF1NAME=$(SHL1TARGET)
+.IF "$(GUI)"=="UNX"
+DEF1EXPORTFILE=exports.dxp
+.ENDIF
+.IF "$(GUI)"=="WNT"
+DEF1EXPORTFILE=exports_wnt.dxp
+.ENDIF
+
+SHL2OBJS=$(SHL1OBJS)
+SHL2STDLIBS=$(SHL1STDLIBS)
+SHL2TARGET=$(TARGET)
+.IF "$(GUI)"=="WNT"
+SHL2STDLIBS+= $(WS2_32LIB) $(SHELL32LIB) $(OLE32LIB) $(KERNEL32LIB) $(USER32LIB) $(GDI32LIB) $(WINSPOOLLIB) $(COMDLG32LIB) $(ADVAPI32LIB) $(OLE32LIB) $(OLEAAUT32LIB) $(UUIDLIB) $(KERNEL32LIB) $(USER32LIB) $(GDI32LIB) $(WINSPOOLLIB) $(COMDLG32LIB) $(ADVAPI32LIB)
+.ENDIF
+
+SHL2DEPN=
+SHL2IMPLIB= i$(SHL2TARGET)
+SHL2DEF= $(MISC)$/$(SHL2TARGET).def
+SHL2RPATH=BRAND
+
+# ----- get some additional keys in versioninfo ------------
+SHL2ADD_VERINFO=nsplugin_oo.rc
+SHL2DEPN+=$(SHL2ADD_VERINFO)
+
+DEF2NAME=$(SHL2TARGET)
+.IF "$(GUI)"=="UNX"
+DEF2EXPORTFILE=exports.dxp
+.ENDIF
+.IF "$(GUI)"=="WNT"
+DEF2EXPORTFILE=exports_wnt.dxp
+.ENDIF
+
+# --- Targets ----------------------------------
+
+.INCLUDE : target.mk
+
diff --git a/extensions/source/nsplugin/source/npshell.cxx b/extensions/source/nsplugin/source/npshell.cxx
new file mode 100644
index 000000000000..d19b7b6d2482
--- /dev/null
+++ b/extensions/source/nsplugin/source/npshell.cxx
@@ -0,0 +1,933 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+
+#ifdef OS2
+#define UNIX
+#endif
+
+#ifdef UNIX
+
+#define XP_UNIX 1
+
+#include <strings.h>
+#include <arpa/inet.h>
+#include <netinet/in.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <sys/stat.h>
+#include <sys/wait.h>
+#include <unistd.h>
+#include <fcntl.h>
+
+#endif //end of UNIX
+
+#ifdef WNT
+
+#define _WINDOWS
+
+#pragma warning (push,1)
+#pragma warning (disable:4668)
+
+#include <windows.h>
+#include <direct.h>
+#include <stdlib.h>
+#include <io.h>
+#include <sys/types.h>
+#include <fcntl.h>
+
+#pragma warning (pop)
+
+#endif //end of WNT
+
+
+#include <stdio.h>
+
+#include <string.h>
+#include <errno.h>
+#include "boost/scoped_array.hpp"
+#include "tools/pathutils.hxx"
+
+//http://qa.openoffice.org/issues/show_bug.cgi?id=82545
+//https://bugzilla.mozilla.org/show_bug.cgi?id=241262
+#ifdef UNIX
+# ifndef _UINT32
+# if defined(__alpha) || defined(__LP64__) || defined(AIX)
+ typedef unsigned int uint32;
+# else /* __alpha */
+ typedef unsigned long uint32;
+# endif
+# define _UINT32
+# endif
+# ifndef _INT32
+# if defined(__alpha) || defined(__LP64__) || defined(AIX)
+ typedef int int32;
+# else /* __alpha */
+ typedef long int32;
+# endif
+# define _INT32
+# endif
+#endif
+
+#include "npapi.h"
+#include "npshell.hxx"
+#include "so_env.hxx"
+#include "so_msg.hxx"
+#include "ns_debug.hxx"
+
+
+#include "nsp_func.hxx"
+
+#include <comphelper/documentconstants.hxx>
+
+/***********************************************************************
+ *
+ * Implementations of plugin API functions
+ *
+ ***********************************************************************/
+
+static NSP_Mute_Obj send_lock = NSP_New_Mute_Obj();
+static NSP_PIPE_FD write_fd = 0;
+
+
+long int NSP_WriteToPipe(NSP_PIPE_FD fp, void* buf, unsigned long int len)
+{
+ unsigned long int len_unix = 0, len_wnt = 0;
+
+ len_unix = NSP_Write_Pipe(fp, buf, len, &len_wnt);
+#ifdef UNIX
+ (void)len_wnt;
+ return len_unix;
+#endif //end of UNIX
+#ifdef WNT
+ return len_wnt;
+#endif //end of WNT
+
+}
+
+#ifdef UNIX
+static pid_t nChildPID = 0;
+#endif
+
+#define MY_LENGTH(s) (sizeof (s) / sizeof *(s) - 1)
+#define MY_STRING(s) (s), MY_LENGTH(s)
+
+#if defined WNT
+namespace {
+
+bool extendEnvironment(
+ boost::scoped_array< WCHAR > * environment, WCHAR const * pathBegin,
+ WCHAR const * pathEnd)
+{
+ WCHAR ure[MAX_PATH];
+ if (tools::buildPath(ure, pathBegin, pathEnd, MY_STRING(L"\\ure-link")) ==
+ NULL)
+ {
+ return false;
+ }
+ WCHAR * ureEnd = tools::resolveLink(ure);
+ if (ureEnd == NULL) {
+ return false;
+ }
+ ureEnd = tools::buildPath(ure, ure, ureEnd, MY_STRING(L"\\bin"));
+ if (ureEnd == NULL) {
+ return false;
+ }
+ WCHAR const * env = GetEnvironmentStringsW();
+ if (env == NULL) {
+ return false;
+ }
+ WCHAR const * p = env;
+ WCHAR const * p1 = NULL;
+ while (*p != L'\0') {
+ size_t n = wcslen(p);
+ if (p1 == NULL && n >= MY_LENGTH(L"PATH=") &&
+ (p[0] == L'P' || p[0] == L'p') &&
+ (p[1] == L'A' || p[1] == L'a') &&
+ (p[2] == L'T' || p[2] == L't') &&
+ (p[3] == L'H' || p[3] == L'h') && p[4] == L'=')
+ {
+ p1 = p + MY_LENGTH(L"PATH=");
+ //TODO: check whether the ure path is already present in PATH (at
+ // the beginning of PATH?)
+ }
+ p += n + 1;
+ }
+ ++p;
+ if (p1 == NULL) {
+ environment->reset(
+ new WCHAR[MY_LENGTH(L"PATH=") + (ureEnd - ure) + 1 + (p - env)]);
+ //TODO: overflow
+ memcpy(environment->get(), MY_STRING(L"PATH=") * sizeof (WCHAR));
+ memcpy(
+ environment->get() + MY_LENGTH(L"PATH="), ure,
+ ((ureEnd - ure) + 1) * sizeof (WCHAR));
+ memcpy(
+ environment->get() + MY_LENGTH(L"PATH=") + (ureEnd - ure) + 1, env,
+ (p - env) * sizeof (WCHAR));
+ } else {
+ environment->reset(
+ new WCHAR[(p - env) + (ureEnd - ure) + MY_LENGTH(L";")]);
+ //TODO: overflow
+ memcpy(environment->get(), env, (p1 - env) * sizeof (WCHAR));
+ memcpy(
+ environment->get() + (p1 - env), ure,
+ (ureEnd - ure) * sizeof (WCHAR));
+ environment->get()[(p1 - env) + (ureEnd - ure)] = L';';
+ memcpy(
+ environment->get() + (p1 - env) + (ureEnd - ure) + 1, p1,
+ (p - p1) * sizeof (WCHAR));
+ }
+ return true;
+}
+
+}
+#endif
+
+// start nspluin executable in child process, and use pipe to talk with it
+int do_init_pipe()
+{
+ debug_fprintf(NSP_LOG_APPEND, "enter do_init_pipe 1\n");
+ NSP_PIPE_FD fd[2];
+
+ if( 0 != NSP_Inherited_Pipe(fd) )
+ return NPERR_GENERIC_ERROR;
+
+ write_fd = fd[1]; // write fd
+#ifdef UNIX
+ // the parent process will wait for the child process in NPP_Shutdown code
+ nChildPID = fork();
+
+ if( ! nChildPID ) // child process
+#endif //end of UNIX
+ {
+#ifdef UNIX
+ char s_read_fd[16] = {0};
+ char s_write_fd[16] = {0};
+ sprintf(s_read_fd, "%d", fd[0]);
+ sprintf(s_write_fd, "%d", fd[1]);
+ char const * instdir = findInstallDir();
+ boost::scoped_array< char > exepath(
+ new char[strlen(instdir) +
+ RTL_CONSTASCII_LENGTH("/basis-link/program/nsplugin") +
+ 1]);
+ sprintf(exepath.get(), "%s/basis-link/program/nsplugin", instdir);
+ char const * progdir = findProgramDir();
+ boost::scoped_array< char > inifilepath(
+ new char[
+ RTL_CONSTASCII_LENGTH(
+ "-env:INIFILENAME=vnd.sun.star.pathname:") +
+ strlen(progdir) + RTL_CONSTASCII_LENGTH("/redirectrc") + 1]);
+ //TODO: overflow
+ sprintf(
+ inifilepath.get(),
+ "-env:INIFILENAME=vnd.sun.star.pathname:%s/redirectrc", progdir);
+ execl(
+ exepath.get(), exepath.get(), s_read_fd, s_write_fd,
+ inifilepath.get(), progdir, NULL);
+ _exit(255);
+#endif //end of UNIX
+#ifdef WNT
+ WCHAR s_read_fd[16] = {0};
+ WCHAR s_write_fd[16] = {0};
+ wsprintfW(s_read_fd, L"%d", fd[0]);
+ wsprintfW(s_write_fd, L"%d", fd[1]);
+ WCHAR brand[MAX_PATH];
+ int brandLen = MultiByteToWideChar(
+ CP_ACP, MB_PRECOMPOSED, findInstallDir(), -1, brand, MAX_PATH);
+ //TODO: conversion errors
+ if (brandLen == 0) {
+ return NPERR_GENERIC_ERROR;
+ }
+ WCHAR path[MAX_PATH];
+ if (tools::buildPath(
+ path, brand, brand + brandLen - 1, MY_STRING(L"\\basis-link"))
+ == NULL)
+ {
+ return NPERR_GENERIC_ERROR;
+ }
+ WCHAR * pathEnd = tools::resolveLink(path);
+ if (pathEnd == NULL) {
+ return NPERR_GENERIC_ERROR;
+ }
+ boost::scoped_array< WCHAR > env;
+ if (!extendEnvironment(&env, path, pathEnd)) {
+ return NPERR_GENERIC_ERROR;
+ }
+ pathEnd = tools::buildPath(
+ path, path, pathEnd, MY_STRING(L"\\program"));
+ if (pathEnd == NULL) {
+ return NPERR_GENERIC_ERROR;
+ }
+ WCHAR exe[MAX_PATH];
+ WCHAR * exeEnd = tools::buildPath(
+ exe, path, pathEnd, MY_STRING(L"\\nsplugin.exe"));
+ if (exeEnd == NULL) {
+ return NPERR_GENERIC_ERROR;
+ }
+ WCHAR * brandEnd = tools::buildPath(
+ brand, brand, brand + brandLen - 1,
+ MY_STRING(L"\\program\\redirect.ini"));
+ if (brandEnd == NULL) {
+ return NPERR_GENERIC_ERROR;
+ }
+ boost::scoped_array< WCHAR > args(
+ new WCHAR[
+ MY_LENGTH(L"\"") + (exeEnd - exe) + MY_LENGTH(L"\" ") +
+ wcslen(s_read_fd) + MY_LENGTH(L" ") + wcslen(s_write_fd) +
+ MY_LENGTH(L" \"-env:INIFILENAME=vnd.sun.star.pathname:") +
+ (brandEnd - brand) + MY_LENGTH(L"\"") + 1]); //TODO: overflow
+ wsprintfW(
+ args.get(),
+ L"\"%s\" %s %s \"-env:INIFILENAME=vnd.sun.star.pathname:%s\"", exe,
+ s_read_fd, s_write_fd, brand);
+ STARTUPINFOW NSP_StarInfo;
+ memset((void*) &NSP_StarInfo, 0, sizeof(STARTUPINFOW));
+ NSP_StarInfo.cb = sizeof(STARTUPINFOW);
+ PROCESS_INFORMATION NSP_ProcessInfo;
+ memset((void*)&NSP_ProcessInfo, 0, sizeof(PROCESS_INFORMATION));
+ if(!CreateProcessW(
+ exe, args.get(), NULL, NULL, TRUE,
+ CREATE_NO_WINDOW | CREATE_UNICODE_ENVIRONMENT, env.get(), path,
+ &NSP_StarInfo, &NSP_ProcessInfo))
+ {
+ DWORD Err = GetLastError();
+ (void)Err;
+ }
+#endif //end of WNT
+ }
+ NSP_Close_Pipe(fd[0]);
+ return NPERR_NO_ERROR;
+}
+
+bool sendMsg( PLUGIN_MSG* pMsg, size_t len, int iEnsure)
+{
+ NSP_Lock_Mute_Obj(send_lock);
+ size_t len_w = 0;
+
+ debug_fprintf(NSP_LOG_APPEND, "try to send message type:%d; len: %d\n", pMsg->msg_id, len);
+ /*
+ debug_fprintf(NSP_LOG_APPEND, "NSPlugin Message: msg_id:%d; instance_id:%d;
+ wnd_id:%d;wnd_x:%d;wnd_y:%d;wnd_w:%d;wnd_h:%d; url:%s\n",
+ pMsg->msg_id, pMsg->instance_id, pMsg->wnd_id,
+ pMsg->wnd_x, pMsg->wnd_y, pMsg->wnd_w, pMsg->wnd_h, pMsg->url);*/
+ len_w = NSP_WriteToPipe(write_fd, (void*) pMsg, len);
+ if (len_w != len){
+ if(errno == EPIPE) // If pipe breaks, then init pipe again and resend the msg
+ {
+ if(iEnsure){
+ debug_fprintf(NSP_LOG_APPEND, "send message error, plugin exec need to be restart\n");
+ NSP_Close_Pipe(write_fd);
+ do_init_pipe();
+ len_w = NSP_WriteToPipe(write_fd, (void*) pMsg, len);
+ }
+ }
+ else if(errno == EINTR) // If interrupted by signal, then continue to send
+ {
+ long new_len;
+ debug_fprintf(NSP_LOG_APPEND, "send message error, send intrrupted by singal, resend again\n");
+ new_len = NSP_WriteToPipe(write_fd, (char*)pMsg+len_w, len-len_w);
+ len_w = len_w + new_len;
+ }
+ else // else return error
+ {
+ debug_fprintf(NSP_LOG_APPEND, "send message error :%s.\n", strerror(errno));
+ len_w = 0;
+ }
+ }
+ NSP_Unlock_Mute_Obj(send_lock);
+ debug_fprintf(NSP_LOG_APPEND, "send message success!\n");
+ return len_w == len;
+}
+
+extern "C"
+{
+char* pMimeTypes = const_cast< char* >( "application/vnd.stardivision.calc:sdc:StarCalc 3.0 - 5.0;"
+"application/vnd.stardivision.chart:sds:StarChart 3.0 - 5.0;"
+"application/vnd.stardivision.draw:sda:StarDraw 3.0 - 5.0;"
+"application/vnd.stardivision.impress:sdd:StarImpress 3.0 - 5.0;"
+"application/vnd.stardivision.impress-packed:sdp:StarImpress-packed 3.0 - 5.0;"
+"application/vnd.stardivision.math:smf:StarMath 3.0 - 5.0;"
+"application/vnd.stardivision.writer:vor:StarWriter Template 3.0 - 5.0;"
+"application/vnd.stardivision.writer-global:sgl:StarWriter Global 3.0 - 5.0;"
+"application/vnd.staroffice.writer:sdw:StarWriter 3.0 - 5.0;"
+MIMETYPE_VND_SUN_XML_CALC_ASCII ":sxc:StarOffice 6.0/7 Spreadsheet;"
+MIMETYPE_VND_SUN_XML_CALC_TEMPLATE_ASCII":stc:StarOffice 6.0/7 Spreadsheet Template;"
+MIMETYPE_VND_SUN_XML_DRAW_ASCII ":sxd:StarOffice 6.0/7 Drawing;"
+MIMETYPE_VND_SUN_XML_DRAW_TEMPLATE_ASCII ":std:StarOffice 6.0/7 Drawing Template;"
+MIMETYPE_VND_SUN_XML_IMPRESS_ASCII ":sxi:StarOffice 6.0/7 Presentation;"
+MIMETYPE_VND_SUN_XML_IMPRESS_TEMPLATE_ASCII ":sti:StarOffice 6.0/7 Presentation Template;"
+MIMETYPE_VND_SUN_XML_MATH_ASCII ":sxm:StarOffice 6.0/7 Formula;"
+MIMETYPE_VND_SUN_XML_WRITER_ASCII ":sxw:StarOffice 6.0/7 Text Document;"
+MIMETYPE_VND_SUN_XML_WRITER_GLOBAL_ASCII ":sxg:StarOffice 6.0/7 Master Document;"
+MIMETYPE_VND_SUN_XML_WRITER_TEMPLATE_ASCII ":stw:StarOffice 6.0/7 Text Document Template;"
+MIMETYPE_OASIS_OPENDOCUMENT_TEXT_ASCII ":odt:OpenDocument Text;"
+MIMETYPE_OASIS_OPENDOCUMENT_TEXT_TEMPLATE_ASCII ":ott:OpenDocument Text Template;"
+MIMETYPE_OASIS_OPENDOCUMENT_TEXT_GLOBAL_ASCII ":odm:OpenDocument Master Document;"
+MIMETYPE_OASIS_OPENDOCUMENT_TEXT_WEB_ASCII ":oth:HTML Document Template;"
+MIMETYPE_OASIS_OPENDOCUMENT_SPREADSHEET_ASCII ":ods:OpenDocument Spreadsheet;"
+MIMETYPE_OASIS_OPENDOCUMENT_SPREADSHEET_TEMPLATE_ASCII ":ots:OpenDocument Spreadsheet Template;"
+MIMETYPE_OASIS_OPENDOCUMENT_DRAWING_ASCII ":odg:OpenDocument Drawing;"
+MIMETYPE_OASIS_OPENDOCUMENT_DRAWING_TEMPLATE_ASCII ":otg:OpenDocument Drawing Template;"
+MIMETYPE_OASIS_OPENDOCUMENT_PRESENTATION_ASCII ":odp:OpenDocument Presentation;"
+MIMETYPE_OASIS_OPENDOCUMENT_PRESENTATION_TEMPLATE_ASCII ":otp:OpenDocument Presentation Template;"
+MIMETYPE_OASIS_OPENDOCUMENT_FORMULA_ASCII ":odf:OpenDocument Formula;" );
+
+char*
+NPP_GetMIMEDescription(void)
+{
+ debug_fprintf(NSP_LOG_APPEND, "print by Netscape Plugin, NPP_GetMIMEDescription:%s.\n", pMimeTypes);
+ return(pMimeTypes);
+}
+
+#ifdef UNIX
+NPError
+// I am not actually sure wrt this, it ast least compiles with external
+// npapi.h now...
+NPP_GetValue(NPP /*instance*/, NPPVariable variable, void *value)
+{
+ NPError err = NPERR_NO_ERROR;
+
+ switch (variable) {
+ case NPPVpluginNameString:
+ // add here, for dynamic productname
+ *((char **)value) = NSP_getPluginName();
+ break;
+ case NPPVpluginDescriptionString:
+ // add here, for dynamic product description
+ *((char **)value) = NSP_getPluginDesc();
+ break;
+ default:
+ err = NPERR_GENERIC_ERROR;
+ }
+ debug_fprintf(NSP_LOG_APPEND, "print by Netscape Plugin, NPP_GetValue return %d.\n", err);
+ return err;
+}
+
+
+NPMIMEType
+dupMimeType(NPMIMEType type)
+{
+ NPMIMEType mimetype = (NPMIMEType) NPN_MemAlloc(strlen(type)+1);
+ mimetype[strlen(type)] = 0;
+ if (mimetype)
+ strcpy(mimetype, type);
+ return(mimetype);
+}
+#endif // end of UNIX
+
+NPError
+NPP_Initialize(void)
+{
+ debug_fprintf(NSP_LOG_NEW, "NS Plugin begin initialize.\n");
+ return (NPError)do_init_pipe();
+}
+
+#ifdef OJI
+jref
+NPP_GetJavaClass()
+{
+ return NULL;
+}
+#endif
+
+void
+NPP_Shutdown(void)
+{
+ PLUGIN_MSG msg;
+ memset((char*)&msg, 0, sizeof(PLUGIN_MSG));
+ msg.msg_id = SO_SHUTDOWN;
+ sendMsg(&msg, sizeof(PLUGIN_MSG), 0);
+ NSP_Close_Pipe(write_fd);
+
+#ifdef UNIX
+ // on Unix we should wait till the child process is dead
+ int nStatus;
+ waitpid( nChildPID, &nStatus, 0 );
+#endif
+}
+
+NPError
+NPP_New(NPMIMEType pluginType,
+ NPP instance,
+ uint16 mode,
+ int16 /*argc*/,
+ char* /*argn*/[],
+ char* /*argv*/[],
+ NPSavedData* /*saved*/)
+{
+ PluginInstance* This;
+
+ debug_fprintf(NSP_LOG_APPEND, "print by Netscape Plugin, enter NPP_New.\n");
+ if (instance == NULL)
+ return NPERR_INVALID_INSTANCE_ERROR;
+
+ instance->pdata = (PluginInstance*)NPN_MemAlloc(sizeof(PluginInstance));
+
+ memset(instance->pdata, 0 , sizeof(PluginInstance));
+ This = (PluginInstance*) instance->pdata;
+
+ if (This == NULL)
+ {
+ return NPERR_OUT_OF_MEMORY_ERROR;
+ }
+
+ memset(This, 0, sizeof(PluginInstance));
+
+ /* mode is NP_EMBED, NP_FULL, or NP_BACKGROUND (see npapi.h) */
+#ifdef UNIX
+ This->mode = mode;
+ This->type = dupMimeType(pluginType);
+ This->instance = instance;
+ This->pluginsPageUrl = NULL;
+ This->exists = FALSE;
+#endif //end of UNIX
+#ifdef WNT
+ (void)pluginType;
+ This->fWindow = (NPWindow*)NPN_MemAlloc(sizeof(NPWindow));
+ memset(This->fWindow, 0, sizeof (NPWindow));
+ This->fMode = mode;
+ #endif //end of WNT
+ PLUGIN_MSG msg;
+ memset((char*)&msg, 0, sizeof(PLUGIN_MSG));
+ msg.msg_id = SO_NEW_INSTANCE;
+ msg.instance_id = (plugin_Int32)instance;
+ if (!sendMsg(&msg, sizeof(PLUGIN_MSG), 1))
+ return NPERR_GENERIC_ERROR;
+
+ NPN_Status(instance, "......");
+ return NPERR_NO_ERROR;
+}
+
+NPError
+NPP_Destroy(NPP instance, NPSavedData** /*save*/)
+{
+ debug_fprintf(NSP_LOG_APPEND, "print by Nsplugin, enter NPP_Destroy.\n");
+ PluginInstance* This;
+
+ if (instance == NULL)
+ return NPERR_INVALID_INSTANCE_ERROR;
+
+ // Send destroy message
+ PLUGIN_MSG msg;
+ memset((char*)&msg, 0, sizeof(PLUGIN_MSG));
+ msg.msg_id = SO_DESTROY;
+ msg.instance_id = (plugin_Int32)instance;
+#ifdef UNIX
+ msg.wnd_id =(plugin_Int32)((PluginInstance*) instance->pdata)->window;
+#endif //end of UNIX
+#ifdef WNT
+ msg.wnd_id =(plugin_Int32)((PluginInstance*) instance->pdata)->fhWnd;
+#endif //end of WNT
+ sendMsg(&msg, sizeof(PLUGIN_MSG), 0);
+
+ // Free the instance space
+ This = (PluginInstance*) instance->pdata;
+ if (This != NULL) {
+#ifdef UNIX
+ if (This->type)
+ NPN_MemFree(This->type);
+ if (This->pluginsPageUrl)
+ NPN_MemFree(This->pluginsPageUrl);
+ if (This->pluginsFileUrl)
+ NPN_MemFree(This->pluginsFileUrl);
+#endif //end of UNIX
+#ifdef WNT
+ if(This->fWindow)
+ NPN_MemFree(This->fWindow);
+#endif //end of WNT
+ NPN_MemFree(instance->pdata);
+ instance->pdata = NULL;
+ }
+
+ return NPERR_NO_ERROR;
+}
+
+
+NPError
+NPP_SetWindow(NPP instance, NPWindow* window)
+{
+ PluginInstance* This;
+#ifdef UNIX
+ NPSetWindowCallbackStruct *ws_info;
+#endif //end of UNIX
+
+ debug_fprintf(NSP_LOG_APPEND, "print by Netscape Plugin, received window resize.\n");
+ if (instance == NULL)
+ return NPERR_INVALID_INSTANCE_ERROR;
+
+ This = (PluginInstance*) instance->pdata;
+ if (This == NULL)
+ return NPERR_INVALID_INSTANCE_ERROR;
+
+ // Prepare the general part of the SET_WINDOW message
+ PLUGIN_MSG msg;
+ memset((char*)&msg, 0, sizeof(msg));
+ msg.msg_id = SO_SET_WINDOW;
+ msg.instance_id = (plugin_Int32)instance;
+
+ if ( window )
+ {
+ // Set window info for instance
+#ifdef UNIX
+ ws_info = (NPSetWindowCallbackStruct *)window->ws_info;
+ This->window = (Window) window->window;
+ This->x = window->x;
+ This->y = window->y;
+ This->width = window->width;
+ This->height = window->height;
+ This->display = ws_info->display;
+ This->visual = ws_info->visual;
+ This->depth = ws_info->depth;
+ This->colormap = ws_info->colormap;
+#endif //end of UNIX
+#ifdef WNT
+ This->fhWnd = (HWND) window->window;
+ This->fWindow->x = window->x;
+ This->fWindow->y = window->y;
+ This->fWindow->width = window->width;
+ This->fWindow->height = window->height;
+#endif //end of WNT
+ debug_fprintf(NSP_LOG_APPEND, "begin Set window of Office\n");
+ debug_fprintf(NSP_LOG_APPEND, "W=(%d) H=(%d)\n", window->width, window->height);
+
+ // fill the window dependent part of the message
+ msg.wnd_id = (plugin_Int32) window->window;
+ msg.wnd_x = window->x;
+ msg.wnd_y = window->y;
+ msg.wnd_w = window->width;
+ msg.wnd_h = window->height;
+ }
+ else
+ {
+ // empty window pointer usually means closing of the parent window
+#ifdef UNIX
+ ws_info = NULL;
+ This->window = (Window) NULL;
+ This->x = 0;
+ This->y = 0;
+ This->width = 0;
+ This->height = 0;
+ This->display = NULL;
+ This->visual = NULL;
+#endif //end of UNIX
+#ifdef WNT
+ This->fhWnd = (HWND) NULL;
+ This->fWindow->x = 0;
+ This->fWindow->y = 0;
+ This->fWindow->width = 0;
+ This->fWindow->height = 0;
+#endif //end of WNT
+ debug_fprintf(NSP_LOG_APPEND, "Empty window pointer is provided\n");
+
+ // fill the window dependent part of the message
+ msg.wnd_id = (plugin_Int32) NULL;
+ msg.wnd_x = 0;
+ msg.wnd_y = 0;
+ msg.wnd_w = 0;
+ msg.wnd_h = 0;
+ }
+
+ if(!sendMsg(&msg, sizeof(PLUGIN_MSG), 1))
+ {
+ debug_fprintf(NSP_LOG_APPEND, "NPP_SetWindow return failure \n");
+ return NPERR_GENERIC_ERROR;
+ }
+
+ return NPERR_NO_ERROR;
+}
+
+
+NPError
+NPP_NewStream(NPP instance,
+ NPMIMEType /*type*/,
+ NPStream* /*stream*/,
+ NPBool /*seekable*/,
+ uint16 *stype)
+{
+ if (instance == NULL)
+ return NPERR_INVALID_INSTANCE_ERROR;
+
+ // Notify Mozilla to fetch the remote file into local cache directory
+ *stype=NP_ASFILEONLY;
+
+ return NPERR_NO_ERROR;
+}
+
+
+int32 STREAMBUFSIZE = 0X0FFFFFFF;
+/* If we are reading from a file in NPAsFile
+ * mode so we can take any size stream in our
+ * write call (since we ignore it) */
+
+int32
+NPP_WriteReady(NPP /*instance*/, NPStream* /*stream*/)
+{
+ return STREAMBUFSIZE;
+}
+
+
+int32
+NPP_Write(NPP /*instance*/, NPStream* /*stream*/, int32 /*offset*/, int32 len, void* /*buffer*/)
+{
+ return len; /* The number of bytes accepted */
+}
+
+
+NPError
+NPP_DestroyStream(NPP instance, NPStream* /*stream*/, NPError /*reason*/)
+{
+ if (instance == NULL)
+ return NPERR_INVALID_INSTANCE_ERROR;
+ return NPERR_NO_ERROR;
+}
+
+// save fname to another file with the original file name
+void
+NPP_StreamAsFile(NPP instance, NPStream *stream, const char* fname)
+{
+ debug_fprintf(NSP_LOG_APPEND, "Into Stream\n");
+ char* url = (char*)stream->url;
+ char filename[1024] = {0};
+ char* pfilename = NULL;
+ if (NULL != (pfilename = strrchr(url, '/')))
+ {
+ strcpy(filename, pfilename+1);
+ } else {
+ return;
+ }
+
+ int length = strlen(url);
+ debug_fprintf(NSP_LOG_APPEND, "url: %s; length: %d\n", url, length);
+ PluginInstance* This;
+ This = (PluginInstance*) instance->pdata;
+
+ debug_fprintf(NSP_LOG_APPEND, "NPP_StreamAsFile\n");
+
+ // copy cached file to another file with original name
+ char localPathNew[NPP_PATH_MAX] = {0};
+ char localFileNew[NPP_PATH_MAX] = {0};
+ // if the file is from local
+ if (0 == STRNICMP(url, "file:///", strlen("file:///")))
+ {
+ sprintf(localPathNew, "%s", fname);
+ char* pAskSymbol = NULL;
+ if(NULL != (pAskSymbol = strrchr(localPathNew, '?')))
+ *pAskSymbol = 0;
+ }
+ else // from network, on windows, fname is c:\abc123
+ {
+ strncpy(localPathNew, fname, sizeof(localPathNew));
+ char* pRandomFilename = NULL;
+
+#ifdef UNIX
+ if(NULL != (pRandomFilename = strrchr(localPathNew, '/')))
+#endif //end of UNIX
+#ifdef WNT
+ if(NULL != (pRandomFilename = strrchr(localPathNew, '\\')))
+#endif //end of WNT
+ {
+ pRandomFilename[1] = 0;
+ } else {
+ return;
+ }
+ strcat(localPathNew, filename);
+ char* pAskSymbol = NULL;
+ if(NULL != (pAskSymbol = strrchr(localPathNew, '?')))
+ *pAskSymbol = 0;
+
+ sprintf(localFileNew, "file://%s", localPathNew);
+ UnixToDosPath(localFileNew);
+ debug_fprintf(NSP_LOG_APPEND, "fname: %s\n localPathNew: %s\nlocalFileNew: %s\n",
+ fname, localPathNew, localFileNew);
+
+ restoreUTF8(localPathNew);
+ restoreUTF8(localFileNew);
+ if(0 != strcmp(fname, localPathNew)) {
+
+#ifdef WNT
+ if(NULL == CopyFile(fname, localPathNew, FALSE))
+ return;
+#endif //end of WNT
+
+#ifdef UNIX
+ int fdSrc, fdDst;
+ if((0 > (fdSrc = open(fname, O_RDONLY)))){
+ return;
+ }
+ remove(localPathNew);
+ umask(0);
+ if (0 > (fdDst = open(localPathNew, O_WRONLY|O_CREAT,
+ S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH))){
+ close( fdSrc);
+ debug_fprintf(NSP_LOG_APPEND, "NPP_StreamAsFile:can not create cache file %s. error: %s \n",
+ localPathNew, strerror(errno));
+ return;
+ }
+ char buffer[NPP_BUFFER_SIZE] = {0};
+ int ret;
+ while(0 <= (ret = read(fdSrc, buffer, NPP_BUFFER_SIZE)))
+ {
+ if (0 == ret)
+ {
+ if(EINTR == errno)
+ continue;
+ else
+
+ break;
+ }
+ write(fdDst, buffer, ret);
+ }
+ close(fdSrc);
+ close(fdDst);
+#endif //end of UNIX
+
+ debug_fprintf(NSP_LOG_APPEND, "NPP_StreamAsFile:before SetURL\n");
+ }
+ }
+
+ // send SO_SET_URl message to inform the new URL
+ PLUGIN_MSG msg;
+ memset((char*)&msg, 0, sizeof(PLUGIN_MSG));
+ msg.msg_id = SO_SET_URL;
+ msg.instance_id = (plugin_Int32)instance;
+#ifdef UNIX
+ msg.wnd_id =(plugin_Int32)(This->window);
+ sprintf(msg.url, "file://%s", localPathNew);
+#endif //end of UNIX
+#ifdef WNT
+ msg.wnd_id =(int)(This->fhWnd);
+ sprintf(msg.url, "file:///%s", localPathNew);
+ DosToUnixPath(msg.url);
+#endif //endof WNT
+ if(!sendMsg(&msg, sizeof(PLUGIN_MSG), 1))
+ debug_fprintf(NSP_LOG_APPEND, "NPP_StreamAsFile send SO_SET_URL return failure \n");
+
+ // send SO_SET_WINDOW message
+// memset((char*)&msg, 0, sizeof(PLUGIN_MSG));
+ msg.msg_id = SO_SET_WINDOW;
+ msg.instance_id = (plugin_Int32)instance;
+// msg.wnd_id =(plugin_Int32)((PluginInstance*) instance->pdata)->window;
+#ifdef UNIX
+ msg.wnd_x = This->x;
+ msg.wnd_y = This->y;
+ msg.wnd_w = This->width;
+ msg.wnd_h = This->height;
+#endif //end of UNIX
+#ifdef WNT
+ msg.wnd_x = This->fWindow->x;
+ msg.wnd_y = This->fWindow->y;
+ msg.wnd_w = This->fWindow->width;
+ msg.wnd_h = This->fWindow->height;
+#endif //endof WNT
+ if(!sendMsg(&msg, sizeof(PLUGIN_MSG), 1))
+ debug_fprintf(NSP_LOG_APPEND, "NPP_StreamAsFile send SO_SET_WINDOW return failure \n");
+}
+
+void
+NPP_URLNotify(NPP /*instance*/, const char* /*url*/,
+ NPReason /*reason*/, void* /*notifyData*/)
+{
+}
+
+
+void
+NPP_Print(NPP instance, NPPrint* printInfo)
+{
+ if(printInfo == NULL)
+ return;
+
+ if (instance != NULL) {
+ /***** Insert NPP_Print code here *****/
+ PluginInstance* This = (PluginInstance*) instance->pdata;
+ (void)This;
+ PLUGIN_MSG msg;
+ memset((char*)&msg, 0, sizeof(PLUGIN_MSG));
+ msg.msg_id = SO_PRINT;
+ msg.instance_id = (plugin_Int32)instance;
+ if(!sendMsg(&msg, sizeof(PLUGIN_MSG), 1))
+ debug_fprintf(NSP_LOG_APPEND, "NPP_StreamAsFile send SO_SET_WINDOW return failure \n");
+ printInfo->mode = TRUE;
+ /**************************************/
+
+ if (printInfo->mode == NP_FULL) {
+ /*
+ * PLUGIN DEVELOPERS:
+ * If your plugin would like to take over
+ * printing completely when it is in full-screen mode,
+ * set printInfo->pluginPrinted to TRUE and print your
+ * plugin as you see fit. If your plugin wants Netscape
+ * to handle printing in this case, set
+ * printInfo->pluginPrinted to FALSE (the default) and
+ * do nothing. If you do want to handle printing
+ * yourself, printOne is true if the print button
+ * (as opposed to the print menu) was clicked.
+ * On the Macintosh, platformPrint is a THPrint; on
+ * Windows, platformPrint is a structure
+ * (defined in npapi.h) containing the printer name, port,
+ * etc.
+ */
+
+ /***** Insert NPP_Print code here *****\
+ void* platformPrint =
+ printInfo->print.fullPrint.platformPrint;
+ NPBool printOne =
+ printInfo->print.fullPrint.printOne;
+ \**************************************/
+
+ /* Do the default*/
+ printInfo->print.fullPrint.pluginPrinted = FALSE;
+ }
+ else { /* If not fullscreen, we must be embedded */
+ /*
+ * PLUGIN DEVELOPERS:
+ * If your plugin is embedded, or is full-screen
+ * but you returned false in pluginPrinted above, NPP_Print
+ * will be called with mode == NP_EMBED. The NPWindow
+ * in the printInfo gives the location and dimensions of
+ * the embedded plugin on the printed page. On the
+ * Macintosh, platformPrint is the printer port; on
+ * Windows, platformPrint is the handle to the printing
+ * device context.
+ */
+
+ /***** Insert NPP_Print code here *****\
+ NPWindow* printWindow =
+ &(printInfo->print.embedPrint.window);
+ void* platformPrint =
+ printInfo->print.embedPrint.platformPrint;
+ \**************************************/
+ }
+ }
+}
+
+}// end of extern "C"
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/nsplugin/source/npshell.hxx b/extensions/source/nsplugin/source/npshell.hxx
new file mode 100644
index 000000000000..e3e44c93ac09
--- /dev/null
+++ b/extensions/source/nsplugin/source/npshell.hxx
@@ -0,0 +1,94 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifdef UNIX
+
+#ifndef MOZ_X11
+# define MOZ_X11
+#endif
+
+#include <gtk/gtk.h>
+#include <X11/Xlib.h>
+
+typedef struct _PluginInstance
+{
+ uint16 mode;
+#ifdef MOZ_X11
+ Window window;
+ Display *display;
+#endif
+ uint32 x, y;
+ uint32 width, height;
+ NPMIMEType type;
+ char *message;
+
+ NPP instance;
+ char *pluginsPageUrl;
+ char *pluginsFileUrl;
+ NPBool pluginsHidden;
+#ifdef MOZ_X11
+ Visual* visual;
+ Colormap colormap;
+#endif
+ unsigned int depth;
+ GtkWidget* dialogBox;
+
+ NPBool exists; /* Does the widget already exist? */
+ int action; /* What action should we take? (GET or REFRESH) */
+
+} PluginInstance;
+
+typedef struct _MimeTypeElement
+{
+ PluginInstance *pinst;
+ struct _MimeTypeElement *next;
+} MimeTypeElement;
+
+#endif //end of UNIX
+
+
+#ifdef WNT
+
+#include <windows.h>
+
+typedef struct _PluginInstance
+{
+ NPWindow* fWindow;
+ uint16 fMode;
+
+ HWND fhWnd;
+ WNDPROC fDefaultWindowProc;
+} PluginInstance;
+
+#endif //end of WNT
+
+
+/* Extern functions */
+extern "C" NPMIMEType dupMimeType(NPMIMEType type);
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/nsplugin/source/ns_debug.hxx b/extensions/source/nsplugin/source/ns_debug.hxx
new file mode 100644
index 000000000000..d2ee5b0bd2cd
--- /dev/null
+++ b/extensions/source/nsplugin/source/ns_debug.hxx
@@ -0,0 +1,42 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef __NSDEBUG_HXX_
+#define __NSDEBUG_HXX_
+
+#define NPP_PATH_MAX 1024
+#define NPP_BUFFER_SIZE 1024
+
+#define NSP_LOG_APPEND 2
+#define NSP_LOG_NEW 0
+
+#define debug_fprintf NSP_WriteLog
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/nsplugin/source/nsp_func.hxx b/extensions/source/nsplugin/source/nsp_func.hxx
new file mode 100644
index 000000000000..c9ebbc7d747c
--- /dev/null
+++ b/extensions/source/nsplugin/source/nsp_func.hxx
@@ -0,0 +1,106 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef __NSP_FUNC_HXX
+#define __NSP_FUNC_HXX
+
+
+// Some function diffrent from UNIX and Window.
+
+/************************ In UNIX ************************/
+
+
+#ifdef UNIX
+// for chdir()
+#define NSP_CHDIR chdir
+//for vsnprintf()
+#define NSP_vsnprintf vsnprintf
+
+
+//for pipe()
+typedef int NSP_PIPE_FD;
+#define NSP_Inherited_Pipe(fp) pipe(fd)
+#define NSP_Close_Pipe(fp) close(fp)
+//for write(), read()
+#define NSP_Write_Pipe(a, b, c, d) write(a, b, c)
+#define NSP_Read_Pipe(a, b, c, d) read(a, b, c)
+
+//for socket
+#define NSP_CloseSocket close
+
+//for sleep
+#define NSP_Sleep(a) sleep(a)
+
+//for mutex
+#define NSP_Mute_Obj pthread_mutex_t
+#define NSP_New_Mute_Obj() PTHREAD_MUTEX_INITIALIZER
+#define NSP_Lock_Mute_Obj(a) pthread_mutex_lock(&a)
+#define NSP_Unlock_Mute_Obj(a) pthread_mutex_unlock(&a)
+
+#define STRNICMP(a, b ,c) strncasecmp(a, b ,c)
+#endif //end of UNIX
+
+/************************ In WINWS ************************/
+
+#ifdef WNT
+
+#include <windows.h>
+//for chdir()
+#define NSP_CHDIR(a) _chdir(a)
+//for vsnprintf()
+#define NSP_vsnprintf _vsnprintf
+
+//for pipe()
+typedef HANDLE NSP_PIPE_FD;
+SECURITY_ATTRIBUTES NSP_pipe_access = { sizeof(SECURITY_ATTRIBUTES), NULL, TRUE};
+#define NSP_Inherited_Pipe(fd) (!CreatePipe(&fd[0], &fd[1], &NSP_pipe_access, 1024*10))
+#define NSP_Close_Pipe(fp) CloseHandle(fp)
+//for write(), read()
+#define NSP_Write_Pipe(a, b, c, d) WriteFile(a, b, c, d, NULL)
+#define NSP_Read_Pipe(a, b, c, d) ReadFile(a, b, c, d, NULL)
+
+//for execl()
+#define NSP_CreateProcess(a, b ) CreateProcess(a, b, NULL, NULL, TRUE, 0, NULL, NULL, NULL, NULL)
+
+//for socket
+#define NSP_CloseSocket closesocket
+//for sleep
+#define NSP_Sleep(a) Sleep(a*1000)
+
+//for mutex
+#define NSP_Mute_Obj HANDLE
+#define NSP_New_Mute_Obj() CreateMutex (NULL, FALSE, NULL)
+#define NSP_Lock_Mute_Obj(a) WaitForSingleObject(a, INFINITE)
+#define NSP_Unlock_Mute_Obj(a) ReleaseMutex(a)
+#define STRNICMP(a, b ,c) strnicmp(a, b ,c)
+
+#endif //end of WNT
+
+
+#endif //end of __NSP_FUNC_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/nsplugin/source/nsp_windows.cxx b/extensions/source/nsplugin/source/nsp_windows.cxx
new file mode 100644
index 000000000000..85cabfbb278c
--- /dev/null
+++ b/extensions/source/nsplugin/source/nsp_windows.cxx
@@ -0,0 +1,66 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+
+#ifdef WNT
+ #pragma warning (push,1)
+ #pragma warning (disable:4668)
+ #include <windows.h>
+ #pragma warning (pop)
+#endif
+
+int NSP_ResetWinStyl(long hParent)
+{
+ int ret = 0;
+#ifdef WNT
+ LONG dOldStyl = GetWindowLong( (HWND)hParent, GWL_STYLE);
+ ret = dOldStyl;
+
+ if(ret != 0)
+ {
+ LONG dNewStyl = dOldStyl|WS_CLIPCHILDREN;
+ if(0 == SetWindowLong((HWND)hParent, GWL_STYLE, dNewStyl))
+ ret = 0;
+ }
+#endif
+ return ret;
+
+}
+
+int NSP_RestoreWinStyl(long hParent, long dOldStyle)
+{
+ int ret = 0;
+#ifdef WNT
+ ret = SetWindowLong((HWND)hParent, GWL_STYLE, dOldStyle);
+#endif
+ return ret;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/nsplugin/source/nsp_windows.hxx b/extensions/source/nsplugin/source/nsp_windows.hxx
new file mode 100644
index 000000000000..4ed2f89c3906
--- /dev/null
+++ b/extensions/source/nsplugin/source/nsp_windows.hxx
@@ -0,0 +1,38 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef __NSP_WINDOWS_HXX__
+#define __NSP_WINDOWS_HXX__
+
+
+int NSP_ResetWinStyl(long hParent);
+int NSP_RestoreWinStyl(long hParent, long dOldStyle);
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/nsplugin/source/nsplugin.rc b/extensions/source/nsplugin/source/nsplugin.rc
new file mode 100644
index 000000000000..7d4b60b5bdad
--- /dev/null
+++ b/extensions/source/nsplugin/source/nsplugin.rc
@@ -0,0 +1,30 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#define ADDITIONAL_VERINFO1 value "FileExtents", "sdc|sds|sda|sdd|sdp|smf|vor|sgl|sdw|sxc|stc|sxd|std|sxi|sti|sxm|sxw|sxg|stw|odt|ott|odm|oth|ods|ots|odg|otg|odp|otp|odf\0"\
+ value "FileOpenName", "StarCalc 3.0 - 5.0|StarChart 3.0 - 5.0|StarDraw 3.0 - 5.0|StarImpress 3.0 - 5.0|StarImpress-packed 3.0 - 5.0|StarMath 3.0 - 5.0|StarWriter Template 3.0 - 5.0|StarWriter Global 3.0 - 5.0|StarWriter 3.0 - 5.0|StarOffice 6.0/7 Spreadsheet|StarOffice 6.0/7 Spreadsheet Template|StarOffice 6.0/7 Drawing|StarOffice 6.0/7 Drawing Template|StarOffice 6.0/7 Presentation|StarOffice 6.0/7 Presentation Template|StarOffice 6.0/7 Formula|StarOffice 6.0/7 Text Document|StarOffice 6.0/7 Master Document|StarOffice 6.0/7 Text Document Template|OpenDocument Text|OpenDocument Text Template|OpenDocument Master Document|HTML Document Template|OpenDocument Spreadsheet|OpenDocument Spreadsheet Template|OpenDocument Drawing|OpenDocument Drawing Template|OpenDocument Presentation|OpenDocument Presentation Template|OpenDocument Formula\0"
+#define ADDITIONAL_VERINFO2 value "FileDescription", "Oracle Open Office Plug-in handles all its documents" value "ProductName", "Oracle Open Office Plug-in" value "MIMEType", "application/vnd.stardivision.calc|application/vnd.stardivision.chart|application/vnd.stardivision.draw|application/vnd.stardivision.impress|application/vnd.stardivision.impress-packed|application/vnd.stardivision.math|application/vnd.stardivision.writer|application/vnd.stardivision.writer-global|application/vnd.staroffice.writer|application/vnd.sun.xml.calc|application/vnd.sun.xml.calc.template|application/vnd.sun.xml.draw|application/vnd.sun.xml.draw.template|"
+#define ADDITIONAL_VERINFO3 "application/vnd.sun.xml.impress|application/vnd.sun.xml.impress.template|application/vnd.sun.xml.math|application/vnd.sun.xml.writer|application/vnd.sun.xml.writer.global|application/vnd.sun.xml.writer.template|application/vnd.oasis.opendocument.text|application/vnd.oasis.opendocument.text-template|application/vnd.oasis.opendocument.text-master|application/vnd.oasis.opendocument.text-web|application/vnd.oasis.opendocument.spreadsheet|application/vnd.oasis.opendocument.spreadsheet-template|application/vnd.oasis.opendocument.graphics|application/vnd.oasis.opendocument.graphics-template|application/vnd.oasis.opendocument.presentation|application/vnd.oasis.opendocument.presentation-template|application/vnd.oasis.opendocument.formula\0"
diff --git a/extensions/source/nsplugin/source/nsplugin_oo.rc b/extensions/source/nsplugin/source/nsplugin_oo.rc
new file mode 100644
index 000000000000..42a2a642e023
--- /dev/null
+++ b/extensions/source/nsplugin/source/nsplugin_oo.rc
@@ -0,0 +1,30 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#define ADDITIONAL_VERINFO1 value "FileExtents", "sdc|sds|sda|sdd|sdp|smf|vor|sgl|sdw|sxc|stc|sxd|std|sxi|sti|sxm|sxw|sxg|stw|odt|ott|odm|oth|ods|ots|odg|otg|odp|otp|odf\0"\
+ value "FileOpenName", "StarCalc 3.0 - 5.0|StarChart 3.0 - 5.0|StarDraw 3.0 - 5.0|StarImpress 3.0 - 5.0|StarImpress-packed 3.0 - 5.0|StarMath 3.0 - 5.0|StarWriter Template 3.0 - 5.0|StarWriter Global 3.0 - 5.0|StarWriter 3.0 - 5.0|StarOffice 6.0/7 Spreadsheet|StarOffice 6.0/7 Spreadsheet Template|StarOffice 6.0/7 Drawing|StarOffice 6.0/7 Drawing Template|StarOffice 6.0/7 Presentation|StarOffice 6.0/7 Presentation Template|StarOffice 6.0/7 Formula|StarOffice 6.0/7 Text Document|StarOffice 6.0/7 Master Document|StarOffice 6.0/7 Text Document Template|OpenDocument Text|OpenDocument Text Template|OpenDocument Master Document|HTML Document Template|OpenDocument Spreadsheet|OpenDocument Spreadsheet Template|OpenDocument Drawing|OpenDocument Drawing Template|OpenDocument Presentation|OpenDocument Presentation Template|OpenDocument Formula\0"
+#define ADDITIONAL_VERINFO2 value "FileDescription", "OpenOffice.org Plug-in handles all its documents" value "ProductName", "OpenOffice.org Plug-in" value "MIMEType", "application/vnd.stardivision.calc|application/vnd.stardivision.chart|application/vnd.stardivision.draw|application/vnd.stardivision.impress|application/vnd.stardivision.impress-packed|application/vnd.stardivision.math|application/vnd.stardivision.writer|application/vnd.stardivision.writer-global|application/vnd.staroffice.writer|application/vnd.sun.xml.calc|application/vnd.sun.xml.calc.template|application/vnd.sun.xml.draw|application/vnd.sun.xml.draw.template|"
+#define ADDITIONAL_VERINFO3 "application/vnd.sun.xml.impress|application/vnd.sun.xml.impress.template|application/vnd.sun.xml.math|application/vnd.sun.xml.writer|application/vnd.sun.xml.writer.global|application/vnd.sun.xml.writer.template|application/vnd.oasis.opendocument.text|application/vnd.oasis.opendocument.text-template|application/vnd.oasis.opendocument.text-master|application/vnd.oasis.opendocument.text-web|application/vnd.oasis.opendocument.spreadsheet|application/vnd.oasis.opendocument.spreadsheet-template|application/vnd.oasis.opendocument.graphics|application/vnd.oasis.opendocument.graphics-template|application/vnd.oasis.opendocument.presentation|application/vnd.oasis.opendocument.presentation-template|application/vnd.oasis.opendocument.formula\0"
diff --git a/extensions/source/nsplugin/source/so_closelistener.cxx b/extensions/source/nsplugin/source/so_closelistener.cxx
new file mode 100644
index 000000000000..4fb26e593669
--- /dev/null
+++ b/extensions/source/nsplugin/source/so_closelistener.cxx
@@ -0,0 +1,50 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+
+#include "so_closelistener.hxx"
+
+using namespace ::com::sun::star;
+
+void SAL_CALL PluginDocumentClosePreventer::queryClosing( const lang::EventObject& /*aEvent*/, sal_Bool /*bDeliverOwnership*/ )
+ throw ( uno::RuntimeException, util::CloseVetoException )
+{
+ if ( m_bPreventClose )
+ throw util::CloseVetoException();
+}
+
+void SAL_CALL PluginDocumentClosePreventer::notifyClosing( const lang::EventObject& /*aEvent*/ ) throw ( uno::RuntimeException )
+{}
+
+void SAL_CALL PluginDocumentClosePreventer::disposing( const lang::EventObject& /*aEvent*/ ) throw ( uno::RuntimeException )
+{}
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/nsplugin/source/so_closelistener.hxx b/extensions/source/nsplugin/source/so_closelistener.hxx
new file mode 100644
index 000000000000..7451c44b8203
--- /dev/null
+++ b/extensions/source/nsplugin/source/so_closelistener.hxx
@@ -0,0 +1,56 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef __SO_CLOSELISTENER_HXX_
+#define __SO_CLOSELISTENER_HXX_
+
+#include <com/sun/star/util/XCloseListener.hpp>
+#include <cppuhelper/implbase1.hxx>
+
+class PluginDocumentClosePreventer : public ::cppu::WeakImplHelper1< ::com::sun::star::util::XCloseListener >
+{
+ sal_Bool m_bPreventClose;
+
+public:
+ PluginDocumentClosePreventer()
+ : m_bPreventClose( sal_True )
+ {}
+
+ void StopPreventClose() { m_bPreventClose = sal_False; }
+
+ virtual void SAL_CALL queryClosing( const ::com::sun::star::lang::EventObject& aEvent, sal_Bool bDeliverOwnership )
+ throw ( ::com::sun::star::uno::RuntimeException, ::com::sun::star::util::CloseVetoException );
+
+ virtual void SAL_CALL notifyClosing( const ::com::sun::star::lang::EventObject& aEvent ) throw ( ::com::sun::star::uno::RuntimeException ) ;
+
+ virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& aEvent ) throw ( ::com::sun::star::uno::RuntimeException ) ;
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/nsplugin/source/so_env.cxx b/extensions/source/nsplugin/source/so_env.cxx
new file mode 100644
index 000000000000..8f8e436f0d7d
--- /dev/null
+++ b/extensions/source/nsplugin/source/so_env.cxx
@@ -0,0 +1,509 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+
+#ifdef UNIX
+#include <sys/types.h>
+#include <strings.h>
+#ifdef LINUX
+#include <dlfcn.h>
+#endif
+#include <stdarg.h>
+// For vsnprintf()
+#define NSP_vsnprintf vsnprintf
+#include "nsp_func.hxx"
+#endif // End UNIX
+
+#ifdef WNT
+#define _WINDOWS
+
+#pragma warning (push,1)
+#pragma warning (disable:4668)
+#pragma warning (disable:4917)
+
+#include <windows.h>
+#include <direct.h>
+#include <stdlib.h>
+#include <shlobj.h>
+#include <objidl.h>
+// For vsnprintf()
+#define NSP_vsnprintf _vsnprintf
+
+#pragma warning (pop)
+#endif // End WNT
+
+#include <sys/stat.h>
+#include <errno.h>
+#include "so_env.hxx"
+#include "ns_debug.hxx"
+#include <sal/config.h>
+
+#define PLUGIN_NAME "OpenOffice.org"
+
+// Tranform all strings like %20 in pPath to one char like space
+/*int retoreUTF8(char* pPath)
+{
+ // Prepare buf
+ int len = strlen(pPath) + 1;
+ char* pBuf = (char*)malloc(len);
+ memset(pBuf, 0, len);
+
+ // Store the original pBuf and pPath
+ char* pBufCur = pBuf;
+ char* pPathCur = pPath;
+ // ie, for %20, UTF8Numbers[0][0] = 2, UTF8Numbers[1][0] = 0
+ char UTF8Numbers[2][2] = {{0, 0}, {0,0}};
+ int temp;
+
+ while (*pPathCur) {
+ if (('%' == *pPathCur) && (0 != *(pPathCur + 1))
+ && (0 != *(pPathCur + 2)))
+ {
+ UTF8Numbers[0][0] = *(pPathCur + 1);
+ UTF8Numbers[1][0] = *(pPathCur + 2);
+ temp = 0;
+ temp = atoi(UTF8Numbers[0])*16 + atoi(UTF8Numbers[1]);
+ *pBufCur = (char)temp;
+ pBufCur++;
+ pPathCur += 3;
+ } else {
+ *pBufCur++ = *pPathCur++;
+ }
+ }
+
+ *pBufCur = 0;
+ strcpy(pPath, pBuf);
+ free(pBuf);
+ return 0;
+}*/
+
+int
+restoreUTF8(char *pPath)
+{
+ unsigned char *s, *d;
+
+#define XDIGIT(c) ((c) <= '9' ? (c) - '0' : ((c) & 0x4F) - 'A' + 10)
+
+ s = d = (unsigned char *)pPath;
+ do {
+ if (*s == '%' && s[1] && s[2]) {
+ *d++ = (XDIGIT (s[1]) << 4) + XDIGIT (s[2]);
+ s += 2;
+ } else
+ *d++ = *s;
+ } while (*s++);
+ debug_fprintf(NSP_LOG_APPEND, "after restoreUTF8, pPath is %s\n", pPath);
+ return 0;
+}
+
+#ifdef LINUX
+extern int nspluginOOoModuleHook (void** aResult);
+int nspluginOOoModuleHook (void** aResult)
+{
+ void *dl_handle;
+
+ dl_handle = dlopen(NULL, RTLD_NOW);
+ if (!dl_handle)
+ {
+ fprintf (stderr, "Can't open myself '%s'\n", dlerror());
+ return 1;
+ }
+
+ Dl_info dl_info = { 0,0,0,0 };
+ if(!dladdr((void *)nspluginOOoModuleHook, &dl_info))
+ {
+ fprintf (stderr, "Can't find my own address '%s'\n", dlerror());
+ return 1;
+ }
+
+ if (!dl_info.dli_fname)
+ {
+ fprintf (stderr, "Can't find my own file name\n");
+ return 1;
+ }
+
+ char cwdstr[NPP_PATH_MAX];
+ if (!getcwd (cwdstr, sizeof(cwdstr)))
+ {
+ fprintf (stderr, "Can't get cwd\n");
+ return 1;
+ }
+
+ char libFileName[NPP_PATH_MAX];
+
+ if (dl_info.dli_fname[0] != '/')
+ {
+ if ((strlen(cwdstr) + 1 + strlen(dl_info.dli_fname)) >= NPP_PATH_MAX)
+ {
+ fprintf (stderr, "Plugin path too long\n");
+ return 1;
+ }
+ strcpy (libFileName, cwdstr);
+ strcat (libFileName, "/");
+ strcat (libFileName, dl_info.dli_fname);
+ }
+ else
+ {
+ if (strlen(dl_info.dli_fname) >= NPP_PATH_MAX)
+ {
+ fprintf (stderr, "Plugin path too long\n");
+ return 1;
+ }
+ strcpy (libFileName, dl_info.dli_fname);
+ }
+
+ char *clobber;
+ static char realFileName[NPP_PATH_MAX] = {0};
+# define SEARCH_SUFFIX "/program/libnpsoplug"
+
+ if (!(clobber = strstr (libFileName, SEARCH_SUFFIX)))
+ {
+ ssize_t len = readlink(libFileName, realFileName, NPP_PATH_MAX-1);
+ if (len == -1)
+ {
+ fprintf (stderr, "Couldn't read link '%s'\n", libFileName);
+ return 1;
+ }
+ realFileName[len] = '\0';
+ if (!(clobber = strstr (realFileName, SEARCH_SUFFIX)))
+ {
+ fprintf (stderr, "Couldn't find suffix in '%s'\n", realFileName);
+ return 1;
+ }
+ *clobber = '\0';
+ }
+ else
+ {
+ *clobber = '\0';
+ strcpy (realFileName, libFileName);
+ }
+
+#if OSL_DEBUG_LEVEL > 0
+ fprintf (stderr, "LibreOffice path before fixup is '%s'\n", realFileName);
+#endif
+
+ if (realFileName[0] != '/') {
+ /* a relative sym-link and we need to get an absolute path */
+ char scratch[NPP_PATH_MAX] = {0};
+ if (strlen (realFileName) + strlen (libFileName) + 2 >= NPP_PATH_MAX - 1)
+ {
+ fprintf (stderr, "Paths too long to fix up.\n");
+ return 1;
+ }
+ strcpy (scratch, libFileName);
+ if (strrchr (scratch, '/')) /* remove the last element */
+ *(strrchr (scratch, '/') + 1) = '\0';
+ strcat (scratch, realFileName);
+ strcpy (realFileName, scratch);
+ }
+
+ *aResult = realFileName;
+
+#if OSL_DEBUG_LEVEL > 0
+ fprintf (stderr, "LibreOffice path is '%s'\n", realFileName);
+#endif
+
+ return 0;
+}
+#endif
+
+// *aResult points the static string holding "/opt/staroffice8"
+int findReadSversion(void** aResult, int /*bWnt*/, const char* /*tag*/, const char* /*entry*/)
+{
+#ifdef UNIX
+ // The real space to hold "/opt/staroffice8"
+ static char realFileName[NPP_PATH_MAX] = {0};
+ memset(realFileName, 0, NPP_PATH_MAX);
+ *aResult = realFileName;
+
+ // Filename of lnk file, eg. "soffice"
+ char lnkFileName[NPP_PATH_MAX] = {0};
+ char* pTempZero = NULL;
+
+#ifdef LINUX
+ /* try to fetch a 'self' pointer */
+ if (!nspluginOOoModuleHook (aResult))
+ return 0;
+
+ /* .. now in $HOME */
+#endif
+ sprintf(lnkFileName, "%s/.mozilla/plugins/libnpsoplugin%s", getenv("HOME"), SAL_DLLEXTENSION);
+#ifdef LINUX
+ ssize_t len = readlink(lnkFileName, realFileName, NPP_PATH_MAX-1);
+ if (-1 == len)
+ {
+ *realFileName = 0;
+ return -1;
+ }
+ realFileName[len] = '\0';
+
+ if (NULL == (pTempZero = strstr(realFileName, "/program/libnpsoplugin" SAL_DLLEXTENSION)))
+#else
+ if ((0 > readlink(lnkFileName, realFileName, NPP_PATH_MAX)) ||
+ (NULL == (pTempZero = strstr(realFileName, "/program/libnpsoplugin" SAL_DLLEXTENSION))))
+#endif
+ {
+ *realFileName = 0;
+ return -1;
+ }
+ *pTempZero = 0;
+ return 0;
+#endif
+#ifdef WNT
+ static char realFileName[NPP_PATH_MAX] = {0};
+ *aResult = realFileName;
+ HKEY hKey;
+ DWORD dwBufLen = NPP_PATH_MAX;
+ LONG lRet;
+
+ debug_fprintf(NSP_LOG_APPEND, "1 before before strstr realFileName is %s\n", realFileName);
+ lRet = RegOpenKeyEx( HKEY_LOCAL_MACHINE,
+ "SOFTWARE\\MozillaPlugins\\@sun.com/npsopluginmi;version=1.0",
+ 0, KEY_QUERY_VALUE, &hKey );
+ if (lRet == ERROR_FILE_NOT_FOUND) {
+ lRet = RegOpenKeyEx(
+ HKEY_CURRENT_USER,
+ "SOFTWARE\\MozillaPlugins\\@sun.com/npsopluginmi;version=1.0", 0,
+ KEY_QUERY_VALUE, &hKey);
+ }
+ debug_fprintf(NSP_LOG_APPEND, "2 before before strstr realFileName is %s\n", realFileName);
+ if( lRet != ERROR_SUCCESS )
+ return FALSE;
+
+ lRet = RegQueryValueEx( hKey, "Path", NULL, NULL,
+ (LPBYTE) realFileName, &dwBufLen);
+ debug_fprintf(NSP_LOG_APPEND, "3 before before strstr realFileName is %s\n", realFileName);
+ if( (lRet != ERROR_SUCCESS) || (dwBufLen > NPP_PATH_MAX) )
+ return FALSE;
+
+ RegCloseKey( hKey );
+ char* pTempZero = NULL;
+ debug_fprintf(NSP_LOG_APPEND, "before strstr realFileName is %s\n", realFileName);
+ if (NULL == (pTempZero = strstr(realFileName, "\\program")))
+ {
+ *realFileName = 0;
+ return -1;
+ }
+ *pTempZero = 0;
+ debug_fprintf(NSP_LOG_APPEND, "realFileName is %s\n", realFileName);
+ return 0;
+#endif
+}
+
+// Return the install dir path of staroffice, return value like "/home/build/staroffice"
+const char* findInstallDir()
+{
+ static char* pInstall = NULL;
+ debug_fprintf(NSP_LOG_APPEND, "start of findInstallDir()\n");
+ if (!pInstall)
+ {
+ findReadSversion((void**)&pInstall, 0, "["SECTION_NAME"]", SOFFICE_VERSION"=");
+ if (!pInstall)
+ pInstall = const_cast< char* >( "" );
+ }
+ return pInstall;
+}
+
+// Return the program dir path of staroffice, return value like "/home/build/staroffice/program"
+const char* findProgramDir()
+{
+ static char sProgram[NPP_BUFFER_SIZE] = {0};
+ if (!sProgram[0])
+ {
+ sprintf(sProgram, "%s/program", findInstallDir());
+#ifdef WNT
+ UnixToDosPath(sProgram);
+#endif
+ }
+ return sProgram;
+}
+
+#ifdef WNT
+// Return SO executable absolute path, like "/home/build/staroffice/program/soffice"
+const char* findSofficeExecutable()
+{
+ static char pSofficeExeccutable[NPP_PATH_MAX] = {0};
+ if (!pSofficeExeccutable[0])
+ {
+ sprintf(pSofficeExeccutable, "%s/%s", findProgramDir(), STAROFFICE_EXE_FILE_NAME);
+#ifdef WNT
+ UnixToDosPath(pSofficeExeccutable);
+#endif
+ }
+
+ return pSofficeExeccutable;
+}
+
+// Change Dos path such as c:\program\soffice to c:/program/soffice
+int DosToUnixPath(char* sPath)
+{
+ if (!sPath)
+ return -1;
+ char* p = sPath;
+ while (*p)
+ {
+ if(*p == '\\')
+ *p = '/';
+ p++;
+ }
+ return 0;
+
+}
+#endif
+// Change Unix path such as program/soffice to program\soffice
+int UnixToDosPath(char* sPath)
+{
+ if (!sPath)
+ return -1;
+ char* p = sPath;
+ while (*p)
+ {
+ if(*p == '/')
+ *p = '\\';
+ p++;
+ }
+ return 0;
+
+}
+
+#ifdef UNIX
+char productName[128] = {0};
+char* NSP_getProductName()
+{
+ if(productName[0])
+ return productName;
+ char fullBootstrapIniPath[1024] = {0};
+ const char* pFullFilePath = findProgramDir();
+ if(0 == *pFullFilePath)
+ {
+ strcpy(productName, PLUGIN_NAME);
+ return productName;
+ }
+ sprintf(fullBootstrapIniPath, "%s/%s", pFullFilePath,
+ "bootstraprc");
+
+ FILE* fp = fopen(fullBootstrapIniPath, "r");
+
+ if (NULL == fp)
+ {
+ strcpy(productName, PLUGIN_NAME);
+ return productName;
+ }
+ char line[4096] = {0};
+ char *pStart = 0;
+ char *pEnd = 0;
+ while(!feof(fp))
+ {
+ if (fgets( line, sizeof(line), fp ) == NULL)
+ continue;
+ if (NULL == (pStart = strstr( line, "ProductKey=" )))
+ continue;
+ pStart += strlen("ProductKey=");
+ if (NULL == (pEnd = strchr( pStart, ' ' )) &&
+ (NULL == (pEnd = strchr( pStart, '\r' ))))
+ continue;
+ *pEnd = 0;
+ strcpy(productName, pStart);
+ }
+ fclose(fp);
+ if ((*productName == 0) ||
+ (0 != STRNICMP(productName, "StarOffice", sizeof("StarOffice"))))
+ {
+ strcpy(productName, PLUGIN_NAME);
+ return productName;
+ }
+ memset(productName, 0, sizeof(productName));
+ strcat(productName, "StarOffice/StarSuite");
+ return productName;
+}
+
+char PluginName[1024] = {0};
+char* NSP_getPluginName()
+{
+ if(*PluginName)
+ return PluginName;
+ sprintf(PluginName, "%s Plug-in", NSP_getProductName());
+ return PluginName;
+}
+
+char PluginDesc[1024] = {0};
+char* NSP_getPluginDesc()
+{
+ if(*PluginDesc)
+ return PluginDesc;
+
+ sprintf(PluginDesc, "%s Plug-in handles all its documents",
+ productName);
+ return PluginDesc;
+}
+#endif //end of UNIX
+
+void NSP_WriteLog(int level, const char* pFormat, ...)
+{
+ (void)level;
+#ifndef DEBUG
+ (void)pFormat;
+#else
+ va_list ap;
+ char msgBuf[NPP_BUFFER_SIZE];
+ static char logName[NPP_PATH_MAX] = {0};
+ FILE * fp = NULL;
+
+ va_start(ap,pFormat);
+ NSP_vsnprintf(msgBuf, NPP_BUFFER_SIZE, pFormat, ap);
+ va_end(ap);
+
+ if (!logName[0])
+ {
+#ifdef UNIX
+ const char* homeDir = getenv("HOME");
+ sprintf(logName,"%s/%s",homeDir,"nsplugin.log");
+#endif // End UNIX
+#ifdef WNT
+ char szPath[MAX_PATH];
+ if (!SHGetSpecialFolderPath(NULL, szPath, CSIDL_APPDATA, 0))
+ {
+ return;
+ }
+ char* homeDir = szPath;
+ sprintf(logName,"%s\\%s", szPath, "nsplugin.log");
+#endif // End WNT
+ }
+ else
+ fp = fopen(logName, "a+");
+
+ if (!fp)
+ return;
+ fputs(msgBuf, fp);
+ fclose(fp);
+#endif
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/nsplugin/source/so_env.hxx b/extensions/source/nsplugin/source/so_env.hxx
new file mode 100644
index 000000000000..9737425f428e
--- /dev/null
+++ b/extensions/source/nsplugin/source/so_env.hxx
@@ -0,0 +1,97 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef __SO_ENVIRON_HXX__
+#define __SO_ENVIRON_HXX__
+
+
+
+#ifdef UNIX
+
+
+#include <pthread.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+
+#endif //end of UNIX
+
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <ctype.h>
+#include <unistd.h>
+#include <string.h>
+
+#define SO_SERVER_PORT 8100
+
+
+#ifdef UNIX
+#define STAROFFICE_VERSION_FILE "/.sversionrc"
+#define STAROFFICE_EXE_FILE_NAME "soffice"
+#endif
+#ifdef WNT
+#define STAROFFICE_VERSION_FILE "\\sversion.ini"
+#define STAROFFICE_EXE_FILE_NAME "soffice.exe"
+#endif
+
+#define SECTION_NAME "Versions"
+#define SOFFICE_VERSION "StarOffice 8"
+//#define SOFFICE_VERSION "SunShine Office 1.0"
+
+#define APP_ERROR 1
+#define APP_CHAR 2
+#define APP_WCHAR 3
+
+// return the install path of staroffice, return value like "/home/build/staroffice"
+const char* findInstallDir();
+
+// return SO program dir absolute path, like "/home/build/staroffice/program"
+const char* findProgramDir();
+
+#ifdef WNT
+// return SO executable absolute path, like "/home/build/staroffice/program/soffice"
+const char* findSofficeExecutable();
+
+// change Dos path such as c:\program\soffice to c:/program/soffice
+int DosToUnixPath(char*);
+#endif
+
+//change Unix path such as program\soffice to program/soffice
+int UnixToDosPath(char*);
+
+void NSP_WriteLog(int level, const char* pFormat, ...);
+
+int restoreUTF8(char* pPath);
+
+char* NSP_getPluginName();
+
+char* NSP_getPluginDesc();
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/nsplugin/source/so_instance.cxx b/extensions/source/nsplugin/source/so_instance.cxx
new file mode 100644
index 000000000000..b94d2958a815
--- /dev/null
+++ b/extensions/source/nsplugin/source/so_instance.cxx
@@ -0,0 +1,498 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/frame/XDispatchProviderInterception.hpp>
+#include <com/sun/star/lang/SystemDependent.hpp>
+#include <com/sun/star/awt/XSystemChildFactory.hpp>
+#include <com/sun/star/awt/XVclWindowPeer.hpp>
+#include <com/sun/star/util/XCloseable.hpp>
+#include <com/sun/star/lang/DisposedException.hpp>
+#include <com/sun/star/ucb/XSimpleFileAccess.hpp>
+#include <com/sun/star/presentation/XPresentation.hpp>
+#include <com/sun/star/presentation/XPresentationSupplier.hpp>
+#include <tools/debug.hxx>
+#include <tools/color.hxx>
+#include <vcl/window.hxx>
+#include <rtl/textenc.h>
+#include <rtl/locale.h>
+#include <osl/nlsupport.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <errno.h>
+
+#include "so_instance.hxx"
+#include "ns_debug.hxx"
+#include "so_env.hxx"
+#include "nsp_windows.hxx"
+#include "so_closelistener.hxx"
+#include <osl/process.h>
+
+namespace css=com::sun::star;
+using namespace com::sun::star::uno;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::connection;
+using namespace cppu;
+using namespace rtl;
+using namespace com::sun::star;
+
+char SoPluginInstance::sSO_Dir[] = {0};
+Reference< XMultiServiceFactory > SoPluginInstance::mxRemoteMSF = Reference< XMultiServiceFactory >(NULL);
+
+
+SoPluginInstance::SoPluginInstance(long pParent, Reference< XMultiServiceFactory > xMSF):
+ m_xUnoWin(NULL),
+ m_xComponent(NULL),
+ m_xFrame(NULL),
+ m_xFrames(NULL),
+ m_xDispatcher(NULL),
+ m_xDispatchProvider(NULL),
+ m_pCloseListener(NULL)
+{
+ m_nWidth = 0;
+ m_nHeight = 0;
+ m_nX = 0;
+ m_nY = 0;
+ m_nFlag = 15;
+ m_bInit = sal_False;
+ m_sURL = rtl::OUString::createFromAscii("");
+ m_hParent = 0;
+ m_pParent = pParent;
+ m_dParentStyl = 0;
+ mxRemoteMSF = xMSF;
+}
+
+SoPluginInstance::~SoPluginInstance()
+{
+}
+
+sal_Bool SoPluginInstance::SetURL(char* aURL)
+{
+ debug_fprintf(NSP_LOG_APPEND, "SoPluginInstance::SetURL %s\n", aURL);
+ sal_uInt16 encoding = 11;
+
+ rtl_Locale* pLocale = NULL;
+ osl_getProcessLocale(&pLocale);
+ encoding = osl_getTextEncodingFromLocale(pLocale);
+
+ m_sURL = ::rtl::OUString(aURL, strlen(aURL), encoding);
+ debug_fprintf(NSP_LOG_APPEND, "SetURL %s\nencoding is: %d\n", ::rtl::OUStringToOString(m_sURL,
+ RTL_TEXTENCODING_GB_18030).getStr(), m_sURL.getLength(), encoding);
+ return sal_True;
+}
+
+// plugin window UI part: create window, load document
+sal_Bool SoPluginInstance::LoadDocument(NSP_HWND hParent)
+{
+ // If doc has been loaded, we just resize the window and return
+ if(m_bInit)
+ {
+ debug_fprintf(NSP_LOG_APPEND, "only reset windows size\n");
+ m_xUnoWin->setPosSize( m_nX, m_nY, m_nWidth, m_nHeight, m_nFlag );
+ debug_fprintf(NSP_LOG_APPEND, "set windows to x:%d y:%d w:%d h%d falg:%d\n",
+ m_nX, m_nY, m_nWidth, m_nHeight, m_nFlag);
+ return sal_True;
+ }
+
+ // If mxRemoteMSF is not initialized, we assert and return sal_False
+ if(!mxRemoteMSF.is())
+ {
+ debug_fprintf(NSP_LOG_APPEND, "Remote StarOfiice ServiceManager is not initilzed correctly!\n");
+ return sal_False;
+ }
+
+ try
+ {
+ // try to create netscape plugin window
+ Reference< awt::XToolkit > xToolkit(
+ mxRemoteMSF->createInstance( ::rtl::OUString::createFromAscii("com.sun.star.awt.Toolkit") ),
+ uno::UNO_QUERY );
+ if( !xToolkit.is() )
+ {
+ debug_fprintf(NSP_LOG_APPEND, "Can not create Toolkit!\n");
+ return sal_False;
+ }
+
+ // prepare parameters for plugin window
+ css::uno::Any hwndParent = css::uno::makeAny((sal_Int32)hParent);
+#ifdef UNIX
+ sal_Int16 nWindowType = css::lang::SystemDependent::SYSTEM_XWINDOW;
+#endif //end of UNIX
+#ifdef WNT
+ sal_Int16 nWindowType = css::lang::SystemDependent::SYSTEM_WIN32;
+#endif //end of WNT
+
+ Reference< awt::XSystemChildFactory > xToolkitSystemChildFactory(xToolkit, uno::UNO_QUERY);
+ if (!xToolkitSystemChildFactory.is())
+ {
+ debug_fprintf(NSP_LOG_APPEND, "print by Nsplugin, get xToolkitSystemChildFactory failure.\n");
+ return sal_False;
+ }
+
+ debug_fprintf(NSP_LOG_APPEND, "print by Nsplugin, try to create plugin container window HWIN:%ld.\n", hParent);
+
+ // create the plugin window
+ Reference< awt::XWindowPeer > xNewWinPeer =
+ xToolkitSystemChildFactory->createSystemChild( hwndParent,
+ css::uno::Sequence<sal_Int8>(), nWindowType );
+ if ( !xNewWinPeer.is() )
+ {
+ debug_fprintf(NSP_LOG_APPEND, "can not create first window\n", hParent);
+ return sal_False;
+ }
+
+ // get interface of first window
+ m_xUnoWin = Reference< awt::XWindow >( xNewWinPeer, uno::UNO_QUERY );
+ if( !m_xUnoWin.is() )
+ {
+ debug_fprintf(NSP_LOG_APPEND, "can not get interface of first window\n", hParent);
+ return sal_False;
+ }
+
+ // initialize window
+ xNewWinPeer->setBackground( COL_GRAY );
+ m_xUnoWin->setVisible( sal_True );
+ m_xUnoWin->setPosSize( m_nX, m_nY, m_nWidth, m_nHeight, m_nFlag );
+ debug_fprintf(NSP_LOG_APPEND, "set windows to x:%d y:%d w:%d h%d falg:%d\n",
+ m_nX, m_nY, m_nWidth, m_nHeight, m_nFlag);
+
+ // create frame
+ m_xFrame = Reference< frame::XFrame >(
+ mxRemoteMSF->createInstance( ::rtl::OUString::createFromAscii("com.sun.star.frame.Frame") ),
+ uno::UNO_QUERY );
+ if (!m_xFrame.is())
+ {
+ debug_fprintf(NSP_LOG_APPEND, "can not create frame\n");
+ return sal_False;
+ }
+
+ // initialize frame
+ m_xFrame->initialize( m_xUnoWin );
+
+ try
+ {
+ // currently ignore errors in this code
+ uno::Reference< beans::XPropertySet > xFrameProps( m_xFrame, uno::UNO_QUERY_THROW );
+ uno::Reference< beans::XPropertySet > xLMProps;
+ xFrameProps->getPropertyValue( ::rtl::OUString::createFromAscii("LayoutManager") ) >>= xLMProps;
+ if ( xLMProps.is() )
+ xLMProps->setPropertyValue( ::rtl::OUString::createFromAscii("AutomaticToolbars"), uno::makeAny( (sal_Bool)sal_False ) );
+ }
+ catch( uno::Exception& )
+ {}
+
+ // get frames supplier
+ Reference< frame::XFramesSupplier > m_xFramesSupplier(
+ mxRemoteMSF->createInstance( ::rtl::OUString::createFromAscii("com.sun.star.frame.Desktop") ),
+ uno::UNO_QUERY );
+ if ( !m_xFramesSupplier.is() )
+ {
+ debug_fprintf(NSP_LOG_APPEND, "can not get desktop\n");
+ return sal_False;
+ }
+
+ // get frames
+ m_xFrames = m_xFramesSupplier->getFrames();
+ if ( !m_xFrames.is() )
+ {
+ debug_fprintf(NSP_LOG_APPEND, "can not get frames from FramesSupplier\n");
+ return sal_False;
+ }
+
+ // append m_xFrame to m_xFrames
+ m_xFrames->append( m_xFrame );
+
+ // create XComponentLoader
+ Reference< frame::XComponentLoader > xLoader( m_xFrame, uno::UNO_QUERY );
+ if ( !xLoader.is() )
+ {
+ debug_fprintf(NSP_LOG_APPEND, "can not get ComponentLoader to load URL\n");
+ return sal_False;
+ }
+
+ //create stream for the document
+ Reference< ::com::sun::star::ucb::XSimpleFileAccess > xSimpleFileAccess(
+ mxRemoteMSF->createInstance( ::rtl::OUString::createFromAscii("com.sun.star.ucb.SimpleFileAccess") ),
+ uno::UNO_QUERY );
+ if(!xSimpleFileAccess.is())
+ {
+ debug_fprintf(NSP_LOG_APPEND, "can not create SimpleFileAccess to load URL\n");
+ return sal_False;
+ }
+ Reference<io::XInputStream> xInputStream = xSimpleFileAccess->openFileRead( m_sURL );
+
+ if(!xInputStream.is())
+ {
+ debug_fprintf(NSP_LOG_APPEND, "can not create XInputStream for URL\n");
+ return sal_False;
+ }
+
+ // prepare to load document
+ debug_fprintf(NSP_LOG_APPEND, "try to load document\n");
+ Sequence< ::com::sun::star::beans::PropertyValue > setPropValues(3);
+ setPropValues[0].Name = OUString( RTL_CONSTASCII_USTRINGPARAM("ViewOnly") );
+ setPropValues[0].Value <<= sal_True;
+ setPropValues[1].Name = OUString( RTL_CONSTASCII_USTRINGPARAM("ReadOnly") );
+ setPropValues[1].Value <<= sal_True;
+ setPropValues[2].Name = OUString(RTL_CONSTASCII_USTRINGPARAM("InputStream"));
+ setPropValues[2].Value <<= xInputStream;
+ /*
+ setPropValues[ 3 ].Name = "FilterName";
+ setPropValues[ 3 ].Value = "Flat XML File";*/
+
+ debug_fprintf(NSP_LOG_APPEND, "try to load copy of URL from local file %s:%d\n",
+ ::rtl::OUStringToOString( m_sURL, RTL_TEXTENCODING_ASCII_US ).getStr( ),
+ m_sURL.getLength() );
+
+
+ // load document
+/*
+ m_xComponent = xLoader->loadComponentFromURL(
+ OUString(RTL_CONSTASCII_USTRINGPARAM("private:stream")), //m_sURL,
+ m_xFrame->getName(), 0, setPropValues );
+ */
+
+ Sequence< ::com::sun::star::beans::PropertyValue > setPropValues2(3);
+ setPropValues2[0].Name = OUString( RTL_CONSTASCII_USTRINGPARAM("ViewOnly") );
+ setPropValues2[0].Value <<= sal_True;
+ setPropValues2[1].Name = OUString( RTL_CONSTASCII_USTRINGPARAM("ReadOnly") );
+ setPropValues2[1].Value <<= sal_True;
+ setPropValues2[2].Name = OUString( RTL_CONSTASCII_USTRINGPARAM("AsTemplate") );
+ setPropValues2[2].Value <<= sal_False;
+ m_xComponent = xLoader->loadComponentFromURL(
+ m_sURL,
+ m_xFrame->getName(), 0, setPropValues2 );
+
+ if ( !m_xComponent.is() )
+ {
+ debug_fprintf(NSP_LOG_APPEND, "print by Nsplugin, Load Componment error\n");
+ return sal_False;
+ }
+
+ // register the closelistener that will prevent closing of the component
+ Reference< util::XCloseable > xCloseable( m_xFrame, uno::UNO_QUERY );
+ if ( xCloseable.is() )
+ {
+ m_pCloseListener = new PluginDocumentClosePreventer();
+ m_xCloseListener = Reference< util::XCloseListener >( m_pCloseListener );
+ xCloseable->addCloseListener( m_xCloseListener );
+ }
+
+ //free the input stream, it is hold by the m_xComponent
+ xInputStream = Reference<io::XInputStream>();
+
+ debug_fprintf(NSP_LOG_APPEND, "load document success\n");
+
+ // create frame::XDispatchHelper and frame::XDispatchProvider
+ m_xDispatcher = Reference< frame::XDispatchHelper > (
+ mxRemoteMSF->createInstance(::rtl::OUString::createFromAscii("com.sun.star.frame.DispatchHelper")),
+ uno::UNO_QUERY );
+ if(!m_xDispatcher.is())
+ {
+ debug_fprintf(NSP_LOG_APPEND, "m_xDispatcher can not be getten\n");
+ return sal_False;
+ }
+ m_xDispatchProvider = Reference< frame::XDispatchProvider >(m_xFrame, uno::UNO_QUERY);
+ if(!m_xDispatchProvider.is())
+ {
+ debug_fprintf(NSP_LOG_APPEND, "m_xDispatchProvider can not be getten\n");
+ return sal_False;
+ }
+
+ //try to enable toolbar and tool windows
+ Sequence< ::com::sun::star::beans::PropertyValue > propertyValue(1);
+ propertyValue[0].Name = OUString( RTL_CONSTASCII_USTRINGPARAM("FunctionBarVisible") );
+ propertyValue[0].Value <<= sal_True;
+ m_xDispatcher->executeDispatch(m_xDispatchProvider,
+ ::rtl::OUString::createFromAscii(".uno:FunctionBarVisible"),
+ m_xFrame->getName(), 0,
+ propertyValue );
+
+ // reset window style of parent window
+#ifdef WNT
+ m_dParentStyl = ::NSP_ResetWinStyl (m_hParent);
+#endif
+ m_bInit = sal_True;
+
+ try
+ {
+ // in case of presentation try to set the mode of slide-show, and start it
+ uno::Reference< presentation::XPresentationSupplier > xPresSuppl( m_xComponent, uno::UNO_QUERY_THROW );
+ uno::Reference< presentation::XPresentation > xPres( xPresSuppl->getPresentation(), uno::UNO_SET_THROW );
+ uno::Reference< beans::XPropertySet > xProps( xPresSuppl->getPresentation(), uno::UNO_QUERY_THROW );
+ xProps->setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IsFullScreen" ) ), uno::makeAny( sal_False ) );
+ xPres->start();
+ }
+ catch( uno::Exception& )
+ {}
+ }
+ catch( uno::Exception& e )
+ {
+ debug_fprintf(NSP_LOG_APPEND, "Unknown exception while loading document in netscape plugin windows\n");
+ OString o = OUStringToOString( e.Message, RTL_TEXTENCODING_ASCII_US );
+ debug_fprintf(NSP_LOG_APPEND, "error: %s \n", o.pData->buffer );
+ return sal_False;
+ }
+ return sal_True;
+}
+
+sal_Bool SoPluginInstance::SetWindow(NSP_HWND hParent, int x, int y, int w, int h)
+{
+ sal_Bool bRetval(sal_True);
+
+ if ( m_hParent && !hParent )
+ {
+ // the plugin instance has the parent window set already and now it becomes NULL as parent window
+ // that means that the instance should be closed
+ Destroy();
+ m_hParent = hParent;
+ }
+ else
+ {
+ m_hParent = hParent;
+
+ debug_fprintf(NSP_LOG_APPEND, "SoPluginInstance::SetWindow %s : %d\n",
+ ::rtl::OUStringToOString(m_sURL, RTL_TEXTENCODING_ASCII_US).getStr(),
+ m_sURL.getLength() );
+ m_nWidth = w;
+ m_nHeight =h;
+ m_nX = x;
+ m_nY = y;
+
+ if (0 == m_sURL.getLength())
+ return sal_True;
+
+ if(!mxRemoteMSF.is())
+ {
+ debug_fprintf(NSP_LOG_APPEND, "Remote StarOfiice ServiceManager is not initilzed correctly!\n");
+ return sal_False;
+ }
+ debug_fprintf(NSP_LOG_APPEND, "in SoPluginInstance::SetWindow, begin LoadDocument(hParent)\n");
+ bRetval = LoadDocument(hParent); // Load document into current window
+ if(!bRetval){
+ // try to reload document again
+ debug_fprintf(NSP_LOG_APPEND, "load document error, try to reload it once again\n");
+ mxRemoteMSF = Reference< XMultiServiceFactory >();
+ m_bInit = sal_False;
+ bRetval = LoadDocument(hParent);
+ debug_fprintf(NSP_LOG_APPEND, "load document again, return %d\n", bRetval);
+ }
+ }
+
+ return bRetval;
+}
+
+sal_Bool SoPluginInstance::Destroy(void)
+{
+#ifdef WNT
+ if(m_dParentStyl != 0)
+ NSP_RestoreWinStyl(m_hParent, m_dParentStyl);
+#endif
+// if(m_xDispatcher.is()){
+// m_xDispatcher->executeDispatch(m_xDispatchProvider,
+// ::rtl::OUString::createFromAscii(".uno:CloseFrame"),
+// ::rtl::OUString::createFromAscii("_top"), 0,
+// Sequence< ::com::sun::star::beans::PropertyValue >() );
+// }
+
+ uno::Reference< util::XCloseable > xCloseable( m_xFrame, uno::UNO_QUERY );
+
+ try
+ {
+ if ( m_xCloseListener.is() )
+ {
+ if ( m_pCloseListener )
+ m_pCloseListener->StopPreventClose();
+
+ if ( xCloseable.is() )
+ xCloseable->removeCloseListener( m_xCloseListener );
+ }
+ }
+ catch( uno::Exception& )
+ {}
+
+ try
+ {
+ uno::Sequence< uno::Any > aArgs( 1 );
+ aArgs[0] <<= m_xFrame;
+ uno::Reference< lang::XComponent > xDocumentCloser(
+ mxRemoteMSF->createInstanceWithArguments(
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.embed.DocumentCloser" ) ),
+ aArgs ),
+ uno::UNO_QUERY_THROW );
+
+ xDocumentCloser->dispose(); // this call should close the document
+ }
+ catch( uno::Exception& )
+ {
+ debug_fprintf(NSP_LOG_APPEND, "print by Nsplugin.exe, could not close the document correctly!\n");
+ try
+ {
+ if ( xCloseable.is() )
+ xCloseable->close( sal_True );
+ else
+ {
+ uno::Reference< lang::XComponent > xDisposable( m_xFrame, uno::UNO_QUERY );
+ if ( xDisposable.is() )
+ xDisposable->dispose();
+ }
+ }
+ catch (const uno::Exception&)
+ {
+ }
+ }
+
+ m_xUnoWin = Reference< awt::XWindow >();
+ m_xComponent = Reference< XComponent >();
+ m_xFrame = Reference< frame::XFrame >();
+ m_xFrames = Reference< frame::XFrames >();
+ m_xDispatcher = Reference< frame::XDispatchHelper >();
+ m_xDispatchProvider = Reference< frame::XDispatchProvider >();
+ return sal_True;
+}
+
+sal_Bool SoPluginInstance::Print(void)
+{
+ if(!m_xDispatcher.is())
+ return sal_False;
+
+ Sequence< ::com::sun::star::beans::PropertyValue > propertyValue(1);
+ m_xDispatcher->executeDispatch(m_xDispatchProvider,
+ ::rtl::OUString::createFromAscii(".uno:PrintDefault"),
+ m_xFrame->getName(), 0,
+ propertyValue );
+ return sal_True;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/nsplugin/source/so_instance.hxx b/extensions/source/nsplugin/source/so_instance.hxx
new file mode 100644
index 000000000000..07b73ba8c1d6
--- /dev/null
+++ b/extensions/source/nsplugin/source/so_instance.hxx
@@ -0,0 +1,113 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef __SO_INSTANCE_HXX__
+#define __SO_INSTANCE_HXX__
+
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <osl/diagnose.h>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/io/XActiveDataSource.hpp>
+#include <com/sun/star/bridge/XUnoUrlResolver.hpp>
+#include <com/sun/star/uno/XNamingService.hpp>
+#include <com/sun/star/connection/ConnectionSetupException.hpp>
+#include <com/sun/star/frame/XComponentLoader.hpp>
+#include <com/sun/star/util/URL.hpp>
+#include <com/sun/star/frame/XStorable.hpp>
+#include <com/sun/star/io/XSeekable.hpp>
+
+#include <com/sun/star/uno/XComponentContext.hpp>
+#include <com/sun/star/util/XCloseListener.hpp>
+#include <cppuhelper/bootstrap.hxx>
+#include <com/sun/star/awt/WindowDescriptor.hpp>
+#include <rtl/ustring.hxx>
+#include <com/sun/star/awt/XWindow.hpp>
+#include <com/sun/star/frame/XFrame.hpp>
+#include <com/sun/star/frame/XDispatchHelper.hpp>
+
+#include "ns_debug.hxx"
+
+typedef sal_Int32 NSP_HWND;
+
+class PluginDocumentClosePreventer;
+class SoPluginInstance
+{
+
+private:
+ // Service manager of remote Soffice
+ static ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > mxRemoteMSF;
+ // Dir where Soffice is in, ie. /Soffice7/program
+ static char sSO_Dir[NPP_PATH_MAX];
+ int m_nWidth;
+ int m_nHeight;
+ int m_nX;
+ int m_nY;
+ sal_Int16 m_nFlag; // Set to 12 during initialization
+ ::rtl::OUString m_sURL; // URL of the document to be loaded
+ sal_Bool m_bInit; // If the Plugin instance is initilaized.
+ NSP_HWND m_hParent; // Windows handle of parent window
+ long m_pParent; // ID of this instance - get from NPP
+ // StarOffice window
+ ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > m_xUnoWin;
+ // StarOffice component window
+ ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent > m_xComponent;
+ // StarOffice frame for this Plugin
+ ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > m_xFrame;
+ // Frames of StarOffice
+ ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrames > m_xFrames;
+ // Dispatcher of frame
+ ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchHelper > m_xDispatcher;
+ // DispatchProvider of frame
+ ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider > m_xDispatchProvider;
+
+ // the closelistener that will prevent document closing
+ PluginDocumentClosePreventer* m_pCloseListener;
+ ::com::sun::star::uno::Reference< ::com::sun::star::util::XCloseListener > m_xCloseListener;
+
+ sal_Bool LoadDocument(NSP_HWND hParent);
+
+ long m_dParentStyl; // Old Windows style of parent window
+
+
+public:
+ SoPluginInstance(long iInstance, ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xMSF);
+ virtual ~SoPluginInstance(void);
+ virtual sal_Bool SetURL(char* aURL);
+ virtual sal_Bool IsInit(void){return m_bInit;};
+ virtual sal_Bool SetWindow(NSP_HWND hParent, int x, int y, int w, int h) ;
+ virtual sal_Bool Destroy(void) ;
+ virtual sal_Bool Print(void) ;
+
+ static sal_Bool ShutDown(void);
+ static char* GetSODir(void) {return sSO_Dir;};
+ long GetParent(void) {return m_pParent;};
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/nsplugin/source/so_main.cxx b/extensions/source/nsplugin/source/so_main.cxx
new file mode 100644
index 000000000000..eaead5ff5303
--- /dev/null
+++ b/extensions/source/nsplugin/source/so_main.cxx
@@ -0,0 +1,500 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+#ifdef UNIX
+#include <sys/stat.h>
+#include <sys/socket.h>
+#include <sys/types.h>
+#include <arpa/inet.h>
+#include <netinet/in.h>
+#endif //end of UNIX
+
+#ifdef WNT
+#ifdef _MSC_VER
+#pragma once
+#endif
+#pragma warning (push,1)
+#pragma warning (disable:4668)
+#define WIN32_LEAN_AND_MEAN
+#include <windows.h>
+#include <winsock2.h>
+#include <stdlib.h>
+#include <malloc.h>
+#include <memory.h>
+#include <tchar.h>
+#pragma warning (pop)
+#endif //end of WNT
+
+#include <unistd.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <errno.h>
+#include "boost/scoped_array.hpp"
+
+#include "ns_debug.hxx"
+#include "so_msg.hxx"
+#include "so_instance.hxx"
+#include "so_env.hxx"
+
+#include "nsp_func.hxx"
+
+#include "sal/main.h"
+
+#include "rtl/process.h"
+#include "rtl/bootstrap.hxx"
+#include "rtl/string.hxx"
+#include "rtl/ustrbuf.hxx"
+
+#include "osl/security.hxx"
+#include "osl/thread.hxx"
+
+#include "cppuhelper/bootstrap.hxx"
+
+
+
+#include "com/sun/star/uno/XComponentContext.hpp"
+#include "com/sun/star/lang/XMultiServiceFactory.hpp"
+#include "com/sun/star/bridge/UnoUrlResolver.hpp"
+#include "com/sun/star/bridge/XUnoUrlResolver.hpp"
+
+#define OUSTR(x) ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(x) )
+#define ARLEN(x) sizeof (x) / sizeof *(x)
+
+using namespace ::rtl;
+using namespace ::osl;
+using namespace ::cppu;
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+
+
+#define MAX_NODE_NUM 1024
+
+SoPluginInstance* lpInstance[MAX_NODE_NUM];
+
+static NSP_PIPE_FD la_read_fd = 0;
+static char const * progdir = NULL;
+
+
+long int NSP_ReadFromPipe(NSP_PIPE_FD fp, void* buf, unsigned long int len)
+{
+ unsigned long int len_unix = 0, len_wnt = 0;
+
+ len_unix = NSP_Read_Pipe(fp, buf, len, &len_wnt);
+#ifdef UNIX
+ (void)len_wnt;
+ return len_unix;
+#endif //end of UNIX
+#ifdef WNT
+ return len_wnt;
+#endif //end of WNT
+
+}
+
+int find_free_node()
+{
+ for(int i=0; i<MAX_NODE_NUM; i++)
+ {
+ if(NULL == lpInstance[i])
+ return i;
+ }
+ return -1;
+}
+
+int find_cur_node(long cur_id)
+{
+ for(int i=0; i<MAX_NODE_NUM; i++)
+ {
+ if(lpInstance[i] == NULL)
+ continue;
+ if(cur_id == lpInstance[i]->GetParent())
+ return i;
+ }
+ return -1;
+}
+
+sal_Bool dump_plugin_message(PLUGIN_MSG* pMsg)
+{
+ if (!pMsg)
+ return sal_False;
+ debug_fprintf(NSP_LOG_APPEND, "NSPlugin Message: msg_id:%d; instance_id:%d;wnd_id:%d;wnd_x:%d;wnd_y:%d;wnd_w:%d;wnd_h:%d; url:%s\n",
+ pMsg->msg_id, pMsg->instance_id, pMsg->wnd_id,
+ pMsg->wnd_x, pMsg->wnd_y, pMsg->wnd_w, pMsg->wnd_h, pMsg->url);
+ return sal_True;
+}
+
+int Set_Window(PLUGIN_MSG* pMsg)
+{
+ dump_plugin_message(pMsg);
+ int cur_no;
+ if( -1 == (cur_no = find_cur_node(pMsg->instance_id)))
+ return -1;
+ if(lpInstance[cur_no]->SetWindow(pMsg->wnd_id,
+ pMsg->wnd_x, pMsg->wnd_y, pMsg->wnd_w, pMsg->wnd_h))
+ return 0;
+ else
+ return -1;
+}
+
+int Set_URL(PLUGIN_MSG* pMsg)
+{
+ dump_plugin_message(pMsg);
+ int cur_no;
+ if( -1 == (cur_no = find_cur_node(pMsg->instance_id)))
+ return -1;
+ if(lpInstance[cur_no]->SetURL(pMsg->url))
+ return 0;
+ else
+ return -1;
+}
+
+int New_Instance(PLUGIN_MSG* pMsg, Reference< lang::XMultiServiceFactory > xMSF)
+{
+ dump_plugin_message(pMsg);
+ int free_no;
+ if( -1 == (free_no = find_free_node()))
+ return -1;
+ lpInstance[free_no] = new SoPluginInstance(pMsg->instance_id, xMSF);
+ return 0;
+}
+
+int Destroy(PLUGIN_MSG* pMsg)
+{
+ dump_plugin_message(pMsg);
+ int cur_no;
+ if( -1 == (cur_no = find_cur_node(pMsg->instance_id)))
+ return -1;
+ if(lpInstance[cur_no] != NULL)
+ {
+ lpInstance[cur_no]->Destroy();
+ debug_fprintf(NSP_LOG_APPEND, "print by Nsplugin, begin delete.\n");
+ delete(lpInstance[cur_no]);
+ lpInstance[cur_no] = NULL;
+ }
+ return 0;
+}
+
+int Print(PLUGIN_MSG* pMsg)
+{
+ dump_plugin_message(pMsg);
+ int cur_no;
+ if( -1 == (cur_no = find_cur_node(pMsg->instance_id)))
+ return -1;
+ if(lpInstance[cur_no] != NULL)
+ {
+ lpInstance[cur_no]->Print();
+ }
+ return 0;
+}
+
+int Shutdown()
+{
+ for(int cur_no=0; cur_no<MAX_NODE_NUM; cur_no++)
+ {
+ if(lpInstance[cur_no] == NULL)
+ continue;
+ lpInstance[cur_no]->Destroy();
+ debug_fprintf(NSP_LOG_APPEND, "print by Nsplugin, begin delete.\n");
+ delete(lpInstance[cur_no]);
+ lpInstance[cur_no] = NULL;
+ }
+ return -1;
+}
+
+int dispatchMsg(PLUGIN_MSG* pMsg, Reference< lang::XMultiServiceFactory > xMSF)
+{
+ switch(pMsg->msg_id)
+ {
+ case SO_SET_WINDOW:
+ return Set_Window(pMsg);
+ case SO_NEW_INSTANCE:
+ if(xMSF.is())
+ return New_Instance(pMsg, xMSF);
+ case SO_SET_URL:
+ return Set_URL(pMsg);
+ case SO_DESTROY:
+ return Destroy(pMsg);
+ case SO_SHUTDOWN:
+ Shutdown();
+ return -1;
+ case SO_PRINT:
+ Print(pMsg);
+ return 0;
+ default:
+ return -1;
+ }
+}
+
+Reference< lang::XMultiServiceFactory > SAL_CALL start_office(NSP_PIPE_FD read_fd)
+{
+ Reference< XComponentContext > xRemoteContext;
+
+ try
+ {
+ OUString aOfficePath;
+
+#ifdef UNIX
+ boost::scoped_array< char > exepath(
+ new char[( progdir ? strlen( progdir ) : 0 ) + RTL_CONSTASCII_LENGTH( "/soffice" ) + 1] );
+ if ( progdir )
+ sprintf( exepath.get(), "%s/soffice", progdir );
+ else
+ sprintf( exepath.get(), "soffice" );
+ if (!rtl_convertStringToUString(
+ &aOfficePath.pData, exepath.get(), strlen(exepath.get()), osl_getThreadTextEncoding(),
+ (RTL_TEXTTOUNICODE_FLAGS_UNDEFINED_ERROR |
+ RTL_TEXTTOUNICODE_FLAGS_MBUNDEFINED_ERROR |
+ RTL_TEXTTOUNICODE_FLAGS_INVALID_ERROR)))
+ {
+ debug_fprintf(NSP_LOG_APPEND,"bad characters in soffice installation path!\n");
+ return Reference< lang::XMultiServiceFactory >(NULL);
+ }
+#endif //end of UNIX
+#ifdef WNT
+ char sPath[NPP_PATH_MAX];
+ sPath[0] = 0;
+
+ // The quotes will be added in osl_executeProcess
+ sprintf(sPath, "%s", findSofficeExecutable() );
+ if (!rtl_convertStringToUString(
+ &aOfficePath.pData, sPath, strlen(sPath), osl_getThreadTextEncoding(),
+ (RTL_TEXTTOUNICODE_FLAGS_UNDEFINED_ERROR |
+ RTL_TEXTTOUNICODE_FLAGS_MBUNDEFINED_ERROR |
+ RTL_TEXTTOUNICODE_FLAGS_INVALID_ERROR)))
+ {
+ debug_fprintf(NSP_LOG_APPEND,"bad characters in soffice installation path!\n");
+ return Reference< lang::XMultiServiceFactory >(NULL);
+ }
+#endif //end of WNT
+
+ // create default local component context
+ Reference< XComponentContext > xLocalContext(
+ defaultBootstrap_InitialComponentContext() );
+ if ( !xLocalContext.is() )
+ {
+ debug_fprintf(NSP_LOG_APPEND,"no local component context!\n");
+ return Reference< lang::XMultiServiceFactory >(NULL);
+ }
+
+ // env string
+ ::rtl::OUStringBuffer buf;
+ OUString aIniPath, aPluginPipeName;
+
+ if(!Bootstrap::get(OUSTR("BRAND_BASE_DIR"), aIniPath))
+ {
+ debug_fprintf(NSP_LOG_APPEND,"failed to get BRAND_BASE_DIR!\n");
+ return Reference< lang::XMultiServiceFactory >(NULL);
+ }
+ aIniPath += OUSTR("/program/");
+ aIniPath += OUSTR(SAL_CONFIGFILE("bootstrap"));
+ Bootstrap aVersionFile(aIniPath);
+ aVersionFile.getFrom(OUSTR("BaseInstallation"), aPluginPipeName, OUString());
+
+ aPluginPipeName = ::rtl::OUString::valueOf( aPluginPipeName.hashCode() );
+
+ // accept string
+ OSL_ASSERT( buf.getLength() == 0 );
+ buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( "-accept=pipe,name=" ) );
+ buf.append( aPluginPipeName ); //user installation path as pipe name
+ buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( ";urp;" ) );
+ OUString sConnectStartString( buf.makeStringAndClear() );
+
+ // arguments
+ OUString args [] = {
+ OUSTR( "-nologo" ),
+ OUSTR( "-nodefault" ),
+ OUSTR( "-nolockcheck" ),
+ sConnectStartString,
+ };
+
+ // create a URL resolver
+ Reference< bridge::XUnoUrlResolver > xUrlResolver(
+ bridge::UnoUrlResolver::create( xLocalContext ) );
+
+ // connection string
+ OSL_ASSERT( buf.getLength() == 0 );
+ buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( "uno:pipe,name=" ) );
+ buf.append( aPluginPipeName );
+ buf.appendAscii( RTL_CONSTASCII_STRINGPARAM(
+ ";urp;StarOffice.ComponentContext" ) );
+ OUString sConnectString( buf.makeStringAndClear() );
+
+ try
+ {
+ // try to connect to office, no need to start instance again if office already started
+ xRemoteContext.set(
+ xUrlResolver->resolve( sConnectString ), UNO_QUERY_THROW );
+ debug_fprintf(NSP_LOG_APPEND, "Staroffice already start\n");
+ return Reference< lang::XMultiServiceFactory >(xRemoteContext->getServiceManager(), UNO_QUERY);
+ }
+ catch ( connection::NoConnectException & )
+ {
+ }
+
+ // start office process
+#ifdef UNIX
+ // a temporary solution
+ // in future the process should be started using the osl_executeProcess call
+ int nChildPID = fork();
+ if( ! nChildPID ) // child process
+ {
+ NSP_Close_Pipe(read_fd);
+ execl( "/bin/sh",
+ "/bin/sh",
+ ::rtl::OUStringToOString( aOfficePath, osl_getThreadTextEncoding() ).getStr(),
+ ::rtl::OUStringToOString( args[0], osl_getThreadTextEncoding() ).getStr(),
+ ::rtl::OUStringToOString( args[1], osl_getThreadTextEncoding() ).getStr(),
+ ::rtl::OUStringToOString( args[2], osl_getThreadTextEncoding() ).getStr(),
+ ::rtl::OUStringToOString( args[3], osl_getThreadTextEncoding() ).getStr(),
+ NULL);
+ _exit(255);
+ }
+#else
+ (void) read_fd; /* avoid warning about unused parameter */
+ Security sec;
+ oslProcess hProcess = 0;
+ rtl_uString * ar_args [] = {
+ args[ 0 ].pData,
+ args[ 1 ].pData,
+ args[ 2 ].pData,
+ args[ 3 ].pData,
+ };
+
+ oslProcessError rc = osl_executeProcess(
+ aOfficePath.pData,
+ ar_args,
+ ARLEN( ar_args ),
+ osl_Process_DETACHED,
+ sec.getHandle(),
+ 0, // => current working dir
+ 0,
+ 0, // => no env vars
+ &hProcess );
+ switch ( rc )
+ {
+ case osl_Process_E_None:
+ osl_freeProcessHandle( hProcess );
+ break;
+ default:
+ debug_fprintf(NSP_LOG_APPEND, "unmapped error!\n");
+ return Reference< lang::XMultiServiceFactory >(NULL);
+ }
+#endif
+
+ // wait until office is started
+ for ( int i = 0; i < 240 /* stop the connection after 240 * 500ms */; ++i )
+ {
+ try
+ {
+ // try to connect to office
+ xRemoteContext.set(
+ xUrlResolver->resolve( sConnectString ), UNO_QUERY_THROW );
+ return Reference< lang::XMultiServiceFactory >(xRemoteContext->getServiceManager(), UNO_QUERY);
+ }
+ catch ( connection::NoConnectException & )
+ {
+ // wait 500 ms, then try to connect again
+ TimeValue tv = { 0 /* secs */, 500000000 /* nanosecs */ };
+ ::osl::Thread::wait( tv );
+ }
+ }
+ debug_fprintf(NSP_LOG_APPEND, "Failed to connect to Staroffice in 2 minutes\n");
+ return Reference< lang::XMultiServiceFactory >(NULL);
+ }
+ catch ( Exception & e)
+ {
+ debug_fprintf(NSP_LOG_APPEND, "unexpected UNO exception caught: ");
+ debug_fprintf(NSP_LOG_APPEND, (sal_Char *)e.Message.getStr());
+ return Reference< lang::XMultiServiceFactory >(NULL);
+ }
+
+}
+
+
+SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv)
+{
+ // Sleep(20*1000);
+ debug_fprintf(NSP_LOG_APPEND, "start of main\n");
+ memset(lpInstance, 0, sizeof(lpInstance));
+
+ // MessageBox( NULL, "nsplugin has been started", "Info", MB_OK );
+
+ NSP_PIPE_FD fd_pipe[2];
+ int iPipe[2];
+ if(argc < 3)
+ {
+ debug_fprintf(NSP_LOG_APPEND, "print by nsplugin, command error; too little argument to start plugin exec\n");
+ return EXIT_FAILURE;
+ }
+ iPipe[0] = atoi(argv[1]);
+ iPipe[1] = atoi(argv[2]);
+
+ // fd_pipe[0]: read, fd_pipe[0]: write
+ fd_pipe[0] = (NSP_PIPE_FD) iPipe[0] ;
+ fd_pipe[1] = (NSP_PIPE_FD) iPipe[1] ;
+ NSP_Close_Pipe(fd_pipe[1]);
+
+ la_read_fd = fd_pipe[0];
+ if(la_read_fd < 0)
+ {
+ debug_fprintf(NSP_LOG_APPEND, "print by nsplugin, command error: bad read file id:%s \n", la_read_fd);
+ return 0;
+ }
+
+ // the program path is provided only on unix, on windows the registry entry is used
+ if ( argc > 4 )
+ progdir = argv[4];
+
+ Reference< lang::XMultiServiceFactory > xFactory = start_office(la_read_fd);
+ if(!xFactory.is())
+ {
+ NSP_Close_Pipe(la_read_fd);
+ return -1;
+ }
+ PLUGIN_MSG nMsg;
+ int len;
+ while(1)
+ {
+ memset(&nMsg, 0, sizeof(PLUGIN_MSG));
+ len = NSP_ReadFromPipe(la_read_fd, (char*)&nMsg, sizeof(PLUGIN_MSG));
+ if(len != sizeof(PLUGIN_MSG))
+ break;
+ debug_fprintf(NSP_LOG_APPEND, "Read message from pipe type %d \n", nMsg.msg_id);
+ if(-1 == dispatchMsg(&nMsg, xFactory))
+ {
+ debug_fprintf(NSP_LOG_APPEND, "plugin will shutdown\n");
+ break;
+ }
+ }
+ NSP_Close_Pipe(la_read_fd);
+ _exit(0);
+ return EXIT_SUCCESS; // avoid warnings
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/nsplugin/source/so_msg.hxx b/extensions/source/nsplugin/source/so_msg.hxx
new file mode 100644
index 000000000000..162bb40f04ec
--- /dev/null
+++ b/extensions/source/nsplugin/source/so_msg.hxx
@@ -0,0 +1,57 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef __PLUGIN_MSG_HXX
+#define __PLUGIN_MSG_HXX
+enum msg_type
+{
+ SO_EMPTY, // 0
+ SO_SET_WINDOW, // 1
+ SO_SET_URL, // 2
+ SO_NEW_INSTANCE, // 3
+ SO_DESTROY, // 4
+ SO_SHUTDOWN, // 5
+ SO_PRINT // 6
+};
+
+#define plugin_Int32 unsigned long int
+
+typedef struct _PLUGIN_MSG {
+ plugin_Int32 msg_id;
+ plugin_Int32 instance_id;
+ plugin_Int32 wnd_id;
+ plugin_Int32 wnd_x;
+ plugin_Int32 wnd_y;
+ plugin_Int32 wnd_w;
+ plugin_Int32 wnd_h;
+ char url[484];
+} PLUGIN_MSG;
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/ole/comifaces.hxx b/extensions/source/ole/comifaces.hxx
new file mode 100644
index 000000000000..d33f350b8f70
--- /dev/null
+++ b/extensions/source/ole/comifaces.hxx
@@ -0,0 +1,72 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef __COMIFACES_HXX
+#define __COMIFACES_HXX
+
+#include <com/sun/star/uno/XInterface.hpp>
+
+using namespace com::sun::star::uno;
+
+#ifdef __MINGW32__
+DEFINE_GUID(IID_IJScriptValueObject, 0xe40a2331, 0x3bc1, 0x11d4, 0x83, 0x21, 0x00, 0x50, 0x04, 0x52, 0x6a, 0xb4);
+DEFINE_GUID(IID_IUnoObjectWrapper, 0x7B5C3410, 0x66FA, 0x11d4, 0x83, 0x2A, 0x00, 0x50, 0x04, 0x52, 0x6A, 0xB4);
+DEFINE_GUID(IID_IUnoTypeWrapper, 0x8BB66591, 0xA544, 0x4de9, 0x82, 0x2C, 0x57, 0xAB, 0x57, 0xBC, 0xED, 0x1C);
+#endif
+MIDL_INTERFACE("e40a2331-3bc1-11d4-8321-005004526ab4")
+IJScriptValueObject: public IUnknown
+{
+ STDMETHOD( Set)( VARIANT type, VARIANT value)= 0;
+ STDMETHOD( Get)( VARIANT *val)= 0;
+ STDMETHOD( InitOutParam)()= 0;
+ STDMETHOD( InitInOutParam)( VARIANT type, VARIANT value)= 0;
+ STDMETHOD( IsOutParam)( VARIANT_BOOL * flag)= 0;
+ STDMETHOD( IsInOutParam)( VARIANT_BOOL * flag)= 0;
+ STDMETHOD( GetValue)( BSTR* type, VARIANT *value)= 0;
+
+};
+
+MIDL_INTERFACE("7B5C3410-66FA-11d4-832A-005004526AB4")
+IUnoObjectWrapper: public IUnknown
+{
+ STDMETHOD( getWrapperXInterface)( Reference<XInterface>* pInt)=0;
+ STDMETHOD( getOriginalUnoObject)( Reference<XInterface>* pInt)=0;
+ STDMETHOD( getOriginalUnoStruct)( Any * pStruct)=0;
+
+};
+
+MIDL_INTERFACE("8BB66591-A544-4de9-822C-57AB57BCED1C")
+IUnoTypeWrapper: public IUnknown
+{
+ STDMETHOD(put_Name)(BSTR val) = 0;
+ STDMETHOD(get_Name)(BSTR* pVal) = 0;
+};
+
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/ole/jscriptclasses.cxx b/extensions/source/ole/jscriptclasses.cxx
new file mode 100644
index 000000000000..5b5083a0c848
--- /dev/null
+++ b/extensions/source/ole/jscriptclasses.cxx
@@ -0,0 +1,324 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+#include "jscriptclasses.hxx"
+
+//========================================================================
+// JScriptValue
+//========================================================================
+JScriptValue::JScriptValue(): m_bOutParam(0), m_bInOutParam(0)
+{
+}
+
+JScriptValue::~JScriptValue()
+{
+}
+
+
+// JScriptValue, IDispatch --------------------------------------------
+STDMETHODIMP JScriptValue::GetTypeInfoCount(UINT* /*pctinfo*/)
+{
+ return E_NOTIMPL;
+}
+
+// JScriptValue, IDispatch --------------------------------------------
+STDMETHODIMP JScriptValue::GetTypeInfo( UINT /*iTInfo*/,
+ LCID /*lcid*/,
+ ITypeInfo** /*ppTInfo*/)
+{
+ return E_NOTIMPL;
+}
+
+// JScriptValue, IDispatch --------------------------------------------
+STDMETHODIMP JScriptValue::GetIDsOfNames( REFIID /*riid*/,
+ LPOLESTR *rgszNames,
+ UINT /*cNames*/,
+ LCID /*lcid*/,
+ DISPID *rgDispId)
+{
+ if( !rgDispId)
+ return E_POINTER;
+
+
+ HRESULT ret= S_OK;
+ CComBSTR name(*rgszNames);
+ name.ToLower();
+
+ if( name == CComBSTR( L"set") )
+ *rgDispId= 1;
+ else if( name == CComBSTR( L"get") )
+ *rgDispId= 2;
+ else if( name == CComBSTR( L"initoutparam") )
+ *rgDispId= 3;
+ else if( name == CComBSTR( L"initinoutparam") )
+ *rgDispId= 4;
+ else
+ ret= DISP_E_UNKNOWNNAME;
+
+ return ret;
+}
+
+// JScriptValue, IDispatch --------------------------------------------
+STDMETHODIMP JScriptValue::Invoke( DISPID dispIdMember,
+ REFIID /*riid*/,
+ LCID /*lcid*/,
+ WORD wFlags,
+ DISPPARAMS *pDispParams,
+ VARIANT *pVarResult,
+ EXCEPINFO* /*pExcepInfo*/,
+ UINT* /*puArgErr*/)
+{
+ if( pDispParams->cNamedArgs)
+ return DISP_E_NONAMEDARGS;
+
+
+ HRESULT ret= S_OK;
+ switch( dispIdMember)
+ {
+ case 0: // DISPID_VALUE
+ if( wFlags & DISPATCH_PROPERTYGET && pVarResult)
+ {
+ if( FAILED( VariantCopy( pVarResult, &m_varValue)))
+ ret= E_FAIL;
+ }
+ else
+ ret= E_POINTER;
+ break;
+ case 1:
+ if( wFlags & DISPATCH_METHOD)
+ ret= Set( pDispParams->rgvarg[1], pDispParams->rgvarg[0]);
+ if( FAILED( ret))
+ ret= DISP_E_EXCEPTION;
+ break;
+ case 2:
+ if( wFlags & DISPATCH_METHOD)
+ ret= Get( pVarResult);
+ if( FAILED( ret))
+ ret= DISP_E_EXCEPTION;
+ break;
+ case 3:
+ if( wFlags & DISPATCH_METHOD)
+ ret= InitOutParam();
+ if( FAILED( ret))
+ ret= DISP_E_EXCEPTION;
+ break;
+ case 4:
+ if( wFlags & DISPATCH_METHOD)
+ ret= InitInOutParam( pDispParams->rgvarg[1], pDispParams->rgvarg[0]);
+ if( FAILED( ret))
+ ret= DISP_E_EXCEPTION;
+ break;
+ default:
+ ret= DISP_E_MEMBERNOTFOUND;
+ break;
+ }
+
+ return ret;
+}
+
+// JScriptValue, IScriptOutParam-----------------------
+STDMETHODIMP JScriptValue::Set( VARIANT type, VARIANT value)
+{
+ Lock();
+ HRESULT hr= S_OK;
+ m_varValue.Clear();
+ hr= VariantCopyInd( &m_varValue, &value);
+ VARIANT var;
+ VariantInit( &var);
+ if( SUCCEEDED( hr= VariantChangeType( &var, &type, 0, VT_BSTR)))
+ m_bstrType= var.bstrVal;
+ Unlock();
+ return hr;
+}
+// JScriptValue, IScriptOutParam-----------------------
+STDMETHODIMP JScriptValue::Get( VARIANT *val)
+{
+ Lock();
+ if( !val)
+ return E_POINTER;
+ HRESULT hr= VariantCopy( val, &m_varValue);
+ Unlock();
+ return hr;
+}
+
+STDMETHODIMP JScriptValue::InitOutParam()
+{
+ Lock();
+ m_varValue.Clear();
+ m_bOutParam= true;
+ m_bInOutParam= false;
+ Unlock();
+ return S_OK;
+}
+
+STDMETHODIMP JScriptValue::InitInOutParam( VARIANT type, VARIANT value)
+{
+ Lock();
+ m_bInOutParam= true;
+ m_bOutParam= false;
+ Unlock();
+ return Set( type, value);
+}
+
+STDMETHODIMP JScriptValue::IsOutParam( VARIANT_BOOL * flag)
+{
+ Lock();
+ if( !flag)
+ return E_POINTER;
+ *flag= m_bOutParam ? VARIANT_TRUE : VARIANT_FALSE;
+ Unlock();
+ return S_OK;
+}
+
+STDMETHODIMP JScriptValue::IsInOutParam( VARIANT_BOOL * flag)
+{
+ Lock();
+ if( !flag)
+ return E_POINTER;
+ *flag= m_bInOutParam ? VARIANT_TRUE : VARIANT_FALSE;
+ Unlock();
+ return S_OK;
+}
+
+STDMETHODIMP JScriptValue::GetValue( BSTR* type, VARIANT *value)
+{
+ Lock();
+ if( !type || !value)
+ return E_POINTER;
+ HRESULT hr;
+ if( SUCCEEDED( hr= m_bstrType.CopyTo( type)))
+ hr= VariantCopy( value, &m_varValue);
+ Unlock();
+ return hr;
+}
+
+//##########################################################################################
+// JScriptOutValue
+//##########################################################################################
+
+JScriptOutParam::JScriptOutParam()
+{
+}
+
+JScriptOutParam::~JScriptOutParam()
+{
+}
+
+
+// JScriptOutParam, IDispatch --------------------------------------------
+STDMETHODIMP JScriptOutParam::GetTypeInfoCount(UINT* /*pctinfo*/)
+{
+ return E_NOTIMPL;
+}
+
+// JScriptOutParam, IDispatch --------------------------------------------
+STDMETHODIMP JScriptOutParam::GetTypeInfo( UINT /*iTInfo*/,
+ LCID /*lcid*/,
+ ITypeInfo** /*ppTInfo*/)
+{
+ return E_NOTIMPL;
+}
+
+// JScriptOutParam, IDispatch --------------------------------------------
+STDMETHODIMP JScriptOutParam::GetIDsOfNames( REFIID /*riid*/,
+ LPOLESTR *rgszNames,
+ UINT /*cNames*/,
+ LCID /*lcid*/,
+ DISPID *rgDispId)
+{
+ if( !rgDispId)
+ return E_POINTER;
+
+
+ HRESULT ret= S_OK;
+ CComBSTR name(*rgszNames);
+ name.ToLower();
+
+ if( name == CComBSTR( L"0") )
+ *rgDispId= 1;
+ else
+ ret= DISP_E_UNKNOWNNAME;
+
+ return ret;
+}
+
+// JScriptOutParam, IDispatch --------------------------------------------
+STDMETHODIMP JScriptOutParam::Invoke( DISPID dispIdMember,
+ REFIID /*riid*/,
+ LCID /*lcid*/,
+ WORD wFlags,
+ DISPPARAMS *pDispParams,
+ VARIANT *pVarResult,
+ EXCEPINFO* /*pExcepInfo*/,
+ UINT* /*puArgErr*/)
+{
+ HRESULT ret= S_OK;
+ switch( dispIdMember)
+ {
+ case 0: // DISPID_VALUE
+ if( wFlags & DISPATCH_PROPERTYGET && pVarResult)
+ {
+ if( FAILED( VariantCopy( pVarResult, &m_varValue)))
+ ret= E_FAIL;
+ }
+ else if( wFlags & DISPATCH_PROPERTYPUT || wFlags & DISPATCH_PROPERTYPUTREF)
+ {
+ m_varValue.Clear();
+ if( FAILED( VariantCopyInd( &m_varValue, &pDispParams->rgvarg[0])))
+ ret= E_FAIL;
+ }
+ else
+ ret= E_POINTER;
+ break;
+ case 1: //
+ if( wFlags & DISPATCH_PROPERTYGET && pVarResult)
+ {
+ if( FAILED( VariantCopy( pVarResult, &m_varValue)))
+ ret= E_FAIL;
+ }
+ else if( wFlags & DISPATCH_PROPERTYPUT || wFlags & DISPATCH_PROPERTYPUTREF)
+ {
+ m_varValue.Clear();
+ if( FAILED( VariantCopyInd( &m_varValue, &pDispParams->rgvarg[0])))
+ ret= E_FAIL;
+ }
+ else
+ ret= E_POINTER;
+ break;
+
+ default:
+ ret= DISP_E_MEMBERNOTFOUND;
+ break;
+ }
+
+ return ret;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/ole/jscriptclasses.hxx b/extensions/source/ole/jscriptclasses.hxx
new file mode 100644
index 000000000000..7eab4bd8c8aa
--- /dev/null
+++ b/extensions/source/ole/jscriptclasses.hxx
@@ -0,0 +1,163 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef __JSCRIPTCLASSES_HXX
+#define __JSCRIPTCLASSES_HXX
+
+
+#pragma warning (push,1)
+#pragma warning (disable:4548)
+
+#include <tools/presys.h>
+#define STRICT
+#define _WIN32_WINNT 0x0403
+#define _WIN32_DCOM
+#if OSL_DEBUG_LEVEL > 0
+//#define _ATL_DEBUG_INTERFACES
+#endif
+#include <atlbase.h>
+extern CComModule _Module;
+#include <atlcom.h>
+#include <tools/postsys.h>
+
+#pragma warning (pop)
+#pragma warning (disable:4505)
+ // disable "unreferenced local function has been removed" globally
+
+#include "comifaces.hxx"
+
+
+
+// Sequences are represented by prepending "[]", e.g. []char, [][]byte, [][][]object, etc.
+
+// To make a JScriptValue object to an out parameter, call
+// "InitOutParam" and to make it a in/out parameter call
+// "InitInOutParam"
+
+// If the object represents an out parameter then the value can after the call
+// be retrived by "Get".
+
+// From JavaScript the functions Get, Set, InitOutParam and InitInOutParam are
+// used, that is they are accessible through IDispatch. The functions are used
+// by the bridge.
+
+class JScriptValue:
+ public CComObjectRootEx<CComMultiThreadModel>,
+ public IJScriptValueObject,
+ public IDispatch
+{
+public:
+ JScriptValue();
+ virtual ~JScriptValue();
+
+ BEGIN_COM_MAP(JScriptValue)
+ COM_INTERFACE_ENTRY(IDispatch)
+ COM_INTERFACE_ENTRY(IJScriptValueObject)
+ END_COM_MAP()
+
+ // IDispatch -------------------------------------------
+ STDMETHOD( GetTypeInfoCount)(UINT *pctinfo);
+
+ STDMETHOD( GetTypeInfo)( UINT iTInfo,
+ LCID lcid,
+ ITypeInfo **ppTInfo);
+
+ STDMETHOD( GetIDsOfNames)( REFIID riid,
+ LPOLESTR *rgszNames,
+ UINT cNames,
+ LCID lcid,
+ DISPID *rgDispId);
+
+ STDMETHOD( Invoke)( DISPID dispIdMember,
+ REFIID riid,
+ LCID lcid,
+ WORD wFlags,
+ DISPPARAMS *pDispParams,
+ VARIANT *pVarResult,
+ EXCEPINFO *pExcepInfo,
+ UINT *puArgErr);
+ // IJScriptOutParam --------------------------------------
+
+ STDMETHOD( Set)( VARIANT type, VARIANT value);
+ STDMETHOD( Get)( VARIANT *val);
+ STDMETHOD( InitOutParam)();
+ STDMETHOD( InitInOutParam)( VARIANT type, VARIANT value);
+ STDMETHOD( IsOutParam)( VARIANT_BOOL * flag);
+ STDMETHOD( IsInOutParam)( VARIANT_BOOL * flag);
+ STDMETHOD( GetValue)( BSTR* type, VARIANT *value);
+
+
+ CComVariant m_varValue;
+ CComBSTR m_bstrType;
+ unsigned m_bOutParam: 1;
+ unsigned m_bInOutParam: 1;
+
+};
+
+// If a class is implemented in JScript, then its method
+class JScriptOutParam:
+ public CComObjectRootEx<CComMultiThreadModel>,
+ public IDispatch
+{
+public:
+ JScriptOutParam();
+ virtual ~JScriptOutParam();
+
+ BEGIN_COM_MAP(JScriptOutParam)
+ COM_INTERFACE_ENTRY(IDispatch)
+ END_COM_MAP()
+
+ // IDispatch -------------------------------------------
+ STDMETHOD( GetTypeInfoCount)(UINT *pctinfo);
+
+ STDMETHOD( GetTypeInfo)( UINT iTInfo,
+ LCID lcid,
+ ITypeInfo **ppTInfo);
+
+ STDMETHOD( GetIDsOfNames)( REFIID riid,
+ LPOLESTR *rgszNames,
+ UINT cNames,
+ LCID lcid,
+ DISPID *rgDispId);
+
+ STDMETHOD( Invoke)( DISPID dispIdMember,
+ REFIID riid,
+ LCID lcid,
+ WORD wFlags,
+ DISPPARAMS *pDispParams,
+ VARIANT *pVarResult,
+ EXCEPINFO *pExcepInfo,
+ UINT *puArgErr);
+
+
+private:
+ CComVariant m_varValue;
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/ole/makefile.mk b/extensions/source/ole/makefile.mk
new file mode 100644
index 000000000000..e20e83e0f1e7
--- /dev/null
+++ b/extensions/source/ole/makefile.mk
@@ -0,0 +1,129 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+PRJ=..$/..
+
+# -----------------------------------------------------------------
+
+PRJNAME=extensions
+TARGET=oleautobridge.uno
+TARGET2=oleautobridge2.uno
+
+ENABLE_EXCEPTIONS=TRUE
+
+.INCLUDE : $(PRJ)$/util$/makefile.pmk
+
+LIBTARGET=NO
+USE_DEFFILE=YES
+
+USE_DEFFILE=TRUE
+
+INCPRE+= $(foreach,i,$(ATL_INCLUDE) -I$(i))
+
+# --- Settings -----------------------------------------------------
+
+.IF "$(GUI)" == "WNT" && "$(DISABLE_ATL)"==""
+
+.IF "$(USE_STLP_DEBUG)"!=""
+CDEFS+=-D_DEBUG
+.ENDIF # "$(USE_STLP_DEBUG)"!=""
+
+SLOFILES= \
+ $(SLO)$/servreg.obj \
+ $(SLO)$/servprov.obj \
+ $(SLO)$/unoobjw.obj \
+ $(SLO)$/oleobjw.obj \
+ $(SLO)$/olethread.obj \
+ $(SLO)$/oledll.obj \
+ $(SLO)$/jscriptclasses.obj \
+ $(SLO)$/ole2uno.obj \
+ $(SLO)$/windata.obj \
+ $(SLO)$/unotypewrapper.obj
+
+SECOND_BUILD=OWNGUID
+OWNGUID_SLOFILES=$(SLOFILES)
+OWNGUIDCDEFS+= -DOWNGUID
+
+# the original library
+SHL1TARGET=$(TARGET)
+SHL1STDLIBS=\
+ $(SALLIB) \
+ $(CPPULIB) \
+ $(CPPUHELPERLIB) \
+ $(OLE32LIB) \
+ $(UUIDLIB) \
+ $(ADVAPI32LIB) \
+ $(OLEAUT32LIB)
+
+.IF "$(COM)"=="MSC"
+.IF "$(WINDOWS_VISTA_PSDK)"!="" || "$(CCNUMVER)"<="001399999999"
+.IF "$(USE_STLP_DEBUG)" != ""
+ SHL1STDLIBS+= $(ATL_LIB)$/atlsd.lib
+.ELSE
+ SHL1STDLIBS+= $(ATL_LIB)$/atls.lib
+.ENDIF
+.ENDIF # "$(WINDOWS_VISTA_PSDK)"!="" || "$(CCNUMVER)"<="001399999999"
+.ENDIF # "$(COM)"=="MSC"
+
+SHL1LIBS=
+SHL1OBJS=$(SLOFILES)
+
+DEF1NAME=$(SHL1TARGET)
+DEF1EXPORTFILE=$(SHL1TARGET).dxp
+
+# the second library
+SHL2TARGET=$(TARGET2)
+SHL2STDLIBS=\
+ $(SALLIB) \
+ $(CPPULIB) \
+ $(CPPUHELPERLIB) \
+ $(OLE32LIB) \
+ $(UUIDLIB) \
+ $(ADVAPI32LIB) \
+ $(OLEAUT32LIB)
+
+.IF "$(COM)"=="MSC"
+.IF "$(WINDOWS_VISTA_PSDK)"!="" || "$(CCNUMVER)"<="001399999999"
+.IF "$(USE_STLP_DEBUG)" != ""
+ SHL2STDLIBS+= $(ATL_LIB)$/atlsd.lib
+.ELSE
+ SHL2STDLIBS+= $(ATL_LIB)$/atls.lib
+.ENDIF
+.ENDIF # "$(WINDOWS_VISTA_PSDK)"!="" || "$(CCNUMVER)"<="001399999999"
+.ENDIF # "$(COM)"=="MSC"
+
+SHL2LIBS=
+SHL2OBJS=$(REAL_OWNGUID_SLOFILES)
+
+DEF2NAME=$(SHL2TARGET)
+DEF2EXPORTFILE=$(TARGET).dxp
+
+.ENDIF
+
+#----------------------------------------------------------------
+
+.INCLUDE : target.mk
+
diff --git a/extensions/source/ole/ole2uno.cxx b/extensions/source/ole/ole2uno.cxx
new file mode 100644
index 000000000000..16060432ac75
--- /dev/null
+++ b/extensions/source/ole/ole2uno.cxx
@@ -0,0 +1,76 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+#include "osl/getglobalmutex.hxx"
+#include "rtl/instance.hxx"
+#include "ole2uno.hxx"
+
+using namespace osl;
+namespace ole_adapter
+{
+
+struct MutexInit
+{
+ Mutex * operator () ()
+ {
+ static Mutex aInstance;
+ return &aInstance;
+ }
+};
+
+
+Mutex * getBridgeMutex()
+{
+ return rtl_Instance< Mutex, MutexInit, ::osl::MutexGuard,
+ ::osl::GetGlobalMutex >::create(
+ MutexInit(), ::osl::GetGlobalMutex());
+}
+
+
+// Mutex* getBridgeMutex()
+// {
+// static Mutex* pMutex= NULL;
+
+// if( ! pMutex)
+// {
+// MutexGuard guard( Mutex::getGlobalMutex() );
+// if( !pMutex)
+// {
+// static Mutex aMutex;
+// pMutex= &aMutex;
+// }
+// }
+// return pMutex;
+// }
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/ole/ole2uno.hxx b/extensions/source/ole/ole2uno.hxx
new file mode 100644
index 000000000000..fc3ad87ce0b5
--- /dev/null
+++ b/extensions/source/ole/ole2uno.hxx
@@ -0,0 +1,147 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _OLE2UNO_HXX
+#define _OLE2UNO_HXX
+
+
+#if _MSC_VER > 1000
+#pragma once
+#endif // _MSC_VER > 1000
+
+#define STRICT
+#ifndef _WIN32_WINNT
+#define _WIN32_WINNT 0x0400
+#endif
+
+#define _WIN32_DCOM
+#if OSL_DEBUG_LEVEL > 0
+//#define _ATL_DEBUG_INTERFACES
+#endif
+
+#pragma warning (push,1)
+#pragma warning (disable:4917)
+#pragma warning (disable:4005)
+#pragma warning (disable:4548)
+
+#include <tools/prewin.h>
+#include <tchar.h>
+#if (_MSC_VER >= 1200) || defined(__MINGW32__)
+#include <dispex.h>
+#endif
+#include <tools/postwin.h>
+
+#include <tools/presys.h>
+#include <list>
+#include <tools/postsys.h>
+
+#pragma warning (pop)
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/lang/XSingleServiceFactory.hpp>
+#include <com/sun/star/script/XInvocation.hpp>
+#include <com/sun/star/registry/XRegistryKey.hpp>
+#include <com/sun/star/bridge/XBridgeSupplier2.hpp>
+#include <com/sun/star/bridge/ModelDependent.hpp>
+#include <com/sun/star/reflection/InvocationTargetException.hpp>
+#include <com/sun/star/uno/Exception.hpp>
+#include <com/sun/star/beans/UnknownPropertyException.hpp>
+#include <cppuhelper/implbase2.hxx>
+#include <cppuhelper/implbase1.hxx>
+#include <cppuhelper/typeprovider.hxx>
+#include <cppuhelper/factory.hxx>
+#include <sal/types.h>
+#include <typelib/typeclass.h>
+#include <osl/diagnose.h>
+#include <osl/mutex.hxx>
+#include <com/sun/star/uno/Reference.h>
+#include <rtl/process.h>
+#include <rtl/uuid.h>
+
+#define UNO_2_OLE_EXCEPTIONCODE 1001
+#define OUSTR(x) ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(x) )
+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 com::sun::star::reflection;
+using namespace com::sun::star::beans;
+using namespace osl;
+using namespace rtl;
+using namespace std;
+
+
+
+namespace ole_adapter
+{
+
+const VARTYPE getVarType( const Any& val);
+/* creates a Type object for a given type name.
+
+ The function returns false if the name does not represent
+ a valid type.
+*/
+bool getType( BSTR name, Type & type);
+void o2u_attachCurrentThread();
+
+struct equalOUString_Impl
+{
+ 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();
+ }
+};
+
+
+class BridgeRuntimeError
+{
+public:
+ BridgeRuntimeError(const OUString& sMessage)
+ {
+ message = sMessage;
+ }
+ OUString message;
+};
+
+
+Mutex* getBridgeMutex();
+
+} // end namespace
+
+
+
+#endif // _OLE2UNO_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/ole/oleautobridge.uno.dxp b/extensions/source/ole/oleautobridge.uno.dxp
new file mode 100644
index 000000000000..e7947188aa92
--- /dev/null
+++ b/extensions/source/ole/oleautobridge.uno.dxp
@@ -0,0 +1,4 @@
+component_writeInfo @100
+component_getFactory @101
+component_getImplementationEnvironment @102
+component_canUnload @103
diff --git a/extensions/source/ole/oledll.cxx b/extensions/source/ole/oledll.cxx
new file mode 100644
index 000000000000..5346aa940cf7
--- /dev/null
+++ b/extensions/source/ole/oledll.cxx
@@ -0,0 +1,72 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+
+#define STRICT
+#define _WIN32_WINNT 0x0403
+#define _WIN32_DCOM
+
+#pragma warning (push,1)
+#pragma warning (disable:4548)
+
+#if defined(_MSC_VER) && (_MSC_VER >= 1300) && !defined(_STLP_DEBUG)
+#undef _DEBUG
+#endif
+#ifdef __MINGW32__
+#define _INIT_ATL_COMMON_VARS
+#endif
+#include <atlbase.h>
+CComModule _Module;
+#include <atlcom.h>
+
+#pragma warning (pop)
+
+BEGIN_OBJECT_MAP(ObjectMap)
+END_OBJECT_MAP()
+
+/////////////////////////////////////////////////////////////////////////////
+// DLL Entry Point
+
+extern "C"
+BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/)
+{
+ if (dwReason == DLL_PROCESS_ATTACH)
+ {
+ _Module.Init(ObjectMap, hInstance, NULL);
+ DisableThreadLibraryCalls(hInstance);
+ }
+ else if (dwReason == DLL_PROCESS_DETACH)
+ {
+ _Module.Term();
+ }
+ return TRUE; // ok
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/ole/oleobjw.cxx b/extensions/source/ole/oleobjw.cxx
new file mode 100644
index 000000000000..20359a21901b
--- /dev/null
+++ b/extensions/source/ole/oleobjw.cxx
@@ -0,0 +1,2391 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+#include "ole2uno.hxx"
+#include "rtl/ustrbuf.hxx"
+
+
+#include "osl/diagnose.h"
+#include "osl/doublecheckedlocking.h"
+#include "osl/thread.h"
+
+#include "boost/scoped_array.hpp"
+#include <com/sun/star/script/FailReason.hpp>
+#include <com/sun/star/beans/XMaterialHolder.hpp>
+#include <com/sun/star/script/XTypeConverter.hpp>
+#include <com/sun/star/script/FinishEngineEvent.hpp>
+#include <com/sun/star/script/InterruptReason.hpp>
+#include <com/sun/star/script/XEngineListener.hpp>
+#include <com/sun/star/script/XDebugging.hpp>
+#include <com/sun/star/script/XInvocation.hpp>
+#include <com/sun/star/script/ContextInformation.hpp>
+#include <com/sun/star/script/FinishReason.hpp>
+#include <com/sun/star/script/XEngine.hpp>
+#include <com/sun/star/script/InterruptEngineEvent.hpp>
+#include <com/sun/star/script/XLibraryAccess.hpp>
+#include <com/sun/star/script/BasicErrorException.hpp>
+#include <com/sun/star/bridge/ModelDependent.hpp>
+
+#include "com/sun/star/bridge/oleautomation/NamedArgument.hpp"
+#include "com/sun/star/bridge/oleautomation/PropertyPutArgument.hpp"
+
+#include <typelib/typedescription.hxx>
+#include <rtl/uuid.h>
+#include <rtl/memory.h>
+#include <rtl/ustring.hxx>
+
+#include "jscriptclasses.hxx"
+
+#include "oleobjw.hxx"
+#include "unoobjw.hxx"
+#include <stdio.h>
+using namespace std;
+using namespace boost;
+using namespace osl;
+using namespace rtl;
+using namespace cppu;
+using namespace com::sun::star::script;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::bridge;
+using namespace com::sun::star::bridge::oleautomation;
+using namespace com::sun::star::bridge::ModelDependent;
+
+#define JSCRIPT_ID_PROPERTY L"_environment"
+#define JSCRIPT_ID L"jscript"
+namespace ole_adapter
+{
+
+
+// key: XInterface pointer created by Invocation Adapter Factory
+// value: XInterface pointer to the wrapper class.
+// Entries to the map are made within
+// Any createOleObjectWrapper(IUnknown* pUnknown, const Type& aType);
+// Entries are being deleted if the wrapper class's destructor has been
+// called.
+// Before UNO object is wrapped to COM object this map is checked
+// to see if the UNO object is already a wrapper.
+hash_map<sal_uInt32, sal_uInt32> AdapterToWrapperMap;
+// key: XInterface of the wrapper object.
+// value: XInterface of the Interface created by the Invocation Adapter Factory.
+// A COM wrapper is responsible for removing the corresponding entry
+// in AdapterToWrappperMap if it is being destroyed. Because the wrapper does not
+// know about its adapted interface it uses WrapperToAdapterMap to get the
+// adapted interface which is then used to locate the entry in AdapterToWrapperMap.
+hash_map<sal_uInt32,sal_uInt32> WrapperToAdapterMap;
+
+hash_map<sal_uInt32, WeakReference<XInterface> > ComPtrToWrapperMap;
+/*****************************************************************************
+
+ class implementation IUnknownWrapper_Impl
+
+*****************************************************************************/
+
+IUnknownWrapper_Impl::IUnknownWrapper_Impl( Reference<XMultiServiceFactory>& xFactory,
+ sal_uInt8 unoWrapperClass, sal_uInt8 comWrapperClass):
+ UnoConversionUtilities<IUnknownWrapper_Impl>( xFactory, unoWrapperClass, comWrapperClass),
+ m_pxIdlClass( NULL), m_eJScript( JScriptUndefined),
+ m_bComTlbIndexInit(false), m_bHasDfltMethod(false), m_bHasDfltProperty(false)
+{
+}
+
+
+IUnknownWrapper_Impl::~IUnknownWrapper_Impl()
+{
+ o2u_attachCurrentThread();
+ MutexGuard guard(getBridgeMutex());
+ XInterface * xIntRoot = (OWeakObject *)this;
+#if OSL_DEBUG_LEVEL > 0
+ acquire(); // make sure we don't delete us twice because of Reference
+ OSL_ASSERT( Reference<XInterface>( static_cast<XWeak*>(this), UNO_QUERY).get() == xIntRoot );
+#endif
+
+ // remove entries in global maps
+ typedef hash_map<sal_uInt32, sal_uInt32>::iterator _IT;
+ _IT it= WrapperToAdapterMap.find( (sal_uInt32) xIntRoot);
+ if( it != WrapperToAdapterMap.end())
+ {
+ sal_uInt32 adapter= it->second;
+
+ AdapterToWrapperMap.erase( adapter);
+ WrapperToAdapterMap.erase( it);
+ }
+
+ IT_Com it_c= ComPtrToWrapperMap.find( (sal_uInt32) m_spUnknown.p);
+ if(it_c != ComPtrToWrapperMap.end())
+ ComPtrToWrapperMap.erase(it_c);
+
+#if OSL_DEBUG_LEVEL > 0
+ fprintf(stderr,"[automation bridge] ComPtrToWrapperMap contains: %i \n",
+ ComPtrToWrapperMap.size());
+#endif
+}
+
+Any IUnknownWrapper_Impl::queryInterface(const Type& t)
+ throw (RuntimeException)
+{
+ if (t == getCppuType(static_cast<Reference<XDefaultMethod>*>( 0)) && !m_bHasDfltMethod )
+ return Any();
+ if (t == getCppuType(static_cast<Reference<XDefaultProperty>*>( 0)) && !m_bHasDfltProperty )
+ return Any();
+ if ( ( t == getCppuType(static_cast<Reference<XInvocation>*>( 0)) || t == getCppuType(static_cast<Reference<XAutomationInvocation>*>( 0)) ) && !m_spDispatch)
+ return Any();
+
+ return WeakImplHelper6<XAutomationInvocation, XBridgeSupplier2,
+ XInitialization, XAutomationObject, XDefaultProperty, XDefaultMethod>::queryInterface(t);
+}
+
+Reference<XIntrospectionAccess> SAL_CALL IUnknownWrapper_Impl::getIntrospection(void)
+ throw (RuntimeException )
+{
+ Reference<XIntrospectionAccess> ret;
+
+ return ret;
+}
+
+Any SAL_CALL IUnknownWrapper_Impl::invokeGetProperty( const OUString& aPropertyName, const Sequence< Any >& aParams, Sequence< sal_Int16 >& aOutParamIndex, Sequence< Any >& aOutParam )
+{
+ Any aResult;
+ try
+ {
+ o2u_attachCurrentThread();
+ ITypeInfo * pInfo = getTypeInfo();
+ FuncDesc aDescGet(pInfo);
+ FuncDesc aDescPut(pInfo);
+ VarDesc aVarDesc(pInfo);
+ getPropDesc(aPropertyName, & aDescGet, & aDescPut, & aVarDesc);
+ if ( !aDescGet )
+ {
+ OUString msg(OUSTR("[automation bridge]Property \"") + aPropertyName +
+ OUSTR("\" is not supported"));
+ throw UnknownPropertyException(msg, Reference<XInterface>());
+ }
+ aResult = invokeWithDispIdComTlb( aDescGet, aPropertyName, aParams, aOutParamIndex, aOutParam );
+ }
+ catch ( Exception& e )
+ {
+ throw RuntimeException(OUSTR("[automation bridge] unexpected exception in "
+ "IUnknownWrapper_Impl::invokeGetProperty ! Message : \n") +
+ e.Message, Reference<XInterface>());
+ }
+ return aResult;
+}
+
+Any SAL_CALL IUnknownWrapper_Impl::invokePutProperty( const OUString& aPropertyName, const Sequence< Any >& aParams, Sequence< sal_Int16 >& aOutParamIndex, Sequence< Any >& aOutParam )
+{
+ Any aResult;
+ try
+ {
+ o2u_attachCurrentThread();
+ ITypeInfo * pInfo = getTypeInfo();
+ FuncDesc aDescGet(pInfo);
+ FuncDesc aDescPut(pInfo);
+ VarDesc aVarDesc(pInfo);
+ getPropDesc(aPropertyName, & aDescGet, & aDescPut, & aVarDesc);
+ if ( !aDescPut )
+ {
+ OUString msg(OUSTR("[automation bridge]Property \"") + aPropertyName +
+ OUSTR("\" is not supported"));
+ throw UnknownPropertyException(msg, Reference<XInterface>());
+ }
+ aResult = invokeWithDispIdComTlb( aDescPut, aPropertyName, aParams, aOutParamIndex, aOutParam );
+ }
+ catch ( Exception& e )
+ {
+ throw RuntimeException(OUSTR("[automation bridge] unexpected exception in "
+ "IUnknownWrapper_Impl::invokePutProperty ! Message : \n") +
+ e.Message, Reference<XInterface>());
+ }
+ return aResult;
+}
+
+
+Any SAL_CALL IUnknownWrapper_Impl::invoke( const OUString& aFunctionName,
+ const Sequence< Any >& aParams, Sequence< sal_Int16 >& aOutParamIndex,
+ Sequence< Any >& aOutParam )
+ throw(IllegalArgumentException, CannotConvertException, InvocationTargetException,
+ RuntimeException)
+{
+ if ( ! m_spDispatch )
+ {
+ throw RuntimeException(
+ OUSTR("[automation bridge] The object does not have an IDispatch interface"),
+ Reference<XInterface>());
+ }
+
+ Any ret;
+
+ try
+ {
+ o2u_attachCurrentThread();
+
+ TypeDescription methodDesc;
+ getMethodInfo(aFunctionName, methodDesc);
+ if( methodDesc.is())
+ {
+ ret = invokeWithDispIdUnoTlb(aFunctionName,
+ aParams,
+ aOutParamIndex,
+ aOutParam);
+ }
+ else
+ {
+ ret= invokeWithDispIdComTlb( aFunctionName,
+ aParams,
+ aOutParamIndex,
+ aOutParam);
+ }
+ }
+ catch (IllegalArgumentException &)
+ {
+ throw;
+ }
+ catch (CannotConvertException &)
+ {
+ throw;
+ }
+ catch (InvocationTargetException &)
+ {
+ throw;
+ }
+ catch (BridgeRuntimeError & e)
+ {
+ throw RuntimeException(e.message, Reference<XInterface>());
+ }
+ catch (Exception & e)
+ {
+ throw RuntimeException(OUSTR("[automation bridge] unexpected exception in "
+ "IUnknownWrapper_Impl::invoke ! Message : \n") +
+ e.Message, Reference<XInterface>());
+
+ }
+ catch(...)
+ {
+ throw RuntimeException(
+ OUSTR("[automation bridge] unexpected exception in "
+ "IUnknownWrapper_Impl::Invoke !"), Reference<XInterface>());
+ }
+ return ret;
+}
+
+void SAL_CALL IUnknownWrapper_Impl::setValue( const OUString& aPropertyName,
+ const Any& aValue )
+ throw(UnknownPropertyException, CannotConvertException, InvocationTargetException,
+ RuntimeException)
+{
+ if ( ! m_spDispatch )
+ {
+ throw RuntimeException(
+ OUSTR("[automation bridge] The object does not have an IDispatch interface"),
+ Reference<XInterface>());
+ }
+ try
+ {
+ o2u_attachCurrentThread();
+
+ ITypeInfo * pInfo = getTypeInfo();
+ FuncDesc aDescGet(pInfo);
+ FuncDesc aDescPut(pInfo);
+ VarDesc aVarDesc(pInfo);
+ getPropDesc(aPropertyName, & aDescGet, & aDescPut, & aVarDesc);
+ //check if there is such a property at all or if it is read only
+ if ( ! aDescPut && ! aDescGet && ! aVarDesc)
+ {
+ OUString msg(OUSTR("[automation bridge]Property \"") + aPropertyName +
+ OUSTR("\" is not supported"));
+ throw UnknownPropertyException(msg, Reference<XInterface>());
+ }
+
+ if ( (! aDescPut && aDescGet) || aVarDesc
+ && aVarDesc->wVarFlags == VARFLAG_FREADONLY )
+ {
+ //read-only
+ OUString msg(OUSTR("[automation bridge] Property ") + aPropertyName +
+ OUSTR(" is read-only"));
+ OString sMsg = OUStringToOString(msg, osl_getThreadTextEncoding());
+ OSL_ENSURE(0, sMsg.getStr());
+ // ignore silently
+ return;
+ }
+
+ HRESULT hr= S_OK;
+ DISPPARAMS dispparams;
+ CComVariant varArg;
+ CComVariant varRefArg;
+ CComVariant varResult;
+ ExcepInfo excepinfo;
+ unsigned int uArgErr;
+
+ // converting UNO value to OLE variant
+ DISPID dispidPut= DISPID_PROPERTYPUT;
+ dispparams.rgdispidNamedArgs = &dispidPut;
+ dispparams.cArgs = 1;
+ dispparams.cNamedArgs = 1;
+ dispparams.rgvarg = & varArg;
+
+ OSL_ASSERT(aDescPut || aVarDesc);
+
+ VARTYPE vt = 0;
+ DISPID dispid = 0;
+ INVOKEKIND invkind = INVOKE_PROPERTYPUT;
+ //determine the expected type, dispid, invoke kind (DISPATCH_PROPERTYPUT,
+ //DISPATCH_PROPERTYPUTREF)
+ if (aDescPut)
+ {
+ vt = getElementTypeDesc(& aDescPut->lprgelemdescParam[0].tdesc);
+ dispid = aDescPut->memid;
+ invkind = aDescPut->invkind;
+ }
+ else
+ {
+ vt = getElementTypeDesc( & aVarDesc->elemdescVar.tdesc);
+ dispid = aVarDesc->memid;
+ if (vt == VT_UNKNOWN || vt == VT_DISPATCH ||
+ (vt & VT_ARRAY) || (vt & VT_BYREF))
+ {
+ invkind = INVOKE_PROPERTYPUTREF;
+ }
+ }
+
+ // convert the uno argument
+ if (vt & VT_BYREF)
+ {
+ anyToVariant( & varRefArg, aValue, ::sal::static_int_cast< VARTYPE, int >( vt ^ VT_BYREF ) );
+ varArg.vt = vt;
+ if( (vt & VT_TYPEMASK) == VT_VARIANT)
+ varArg.byref = & varRefArg;
+ else if ((vt & VT_TYPEMASK) == VT_DECIMAL)
+ varArg.byref = & varRefArg.decVal;
+ else
+ varArg.byref = & varRefArg.byref;
+ }
+ else
+ {
+ anyToVariant(& varArg, aValue, vt);
+ }
+ // call to IDispatch
+ hr = m_spDispatch->Invoke(dispid, IID_NULL, LOCALE_USER_DEFAULT, ::sal::static_int_cast< WORD, INVOKEKIND >( invkind ),
+ &dispparams, & varResult, & excepinfo, &uArgErr);
+
+ // lookup error code
+ switch (hr)
+ {
+ case S_OK:
+ break;
+ case DISP_E_BADPARAMCOUNT:
+ throw RuntimeException();
+ break;
+ case DISP_E_BADVARTYPE:
+ throw RuntimeException();
+ break;
+ case DISP_E_EXCEPTION:
+ throw InvocationTargetException();
+ break;
+ case DISP_E_MEMBERNOTFOUND:
+ throw UnknownPropertyException();
+ break;
+ case DISP_E_NONAMEDARGS:
+ throw RuntimeException();
+ break;
+ case DISP_E_OVERFLOW:
+ throw CannotConvertException(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("call to OLE object failed")), static_cast<XInterface*>(
+ static_cast<XWeak*>(this)), TypeClass_UNKNOWN, FailReason::OUT_OF_RANGE, uArgErr);
+ break;
+ case DISP_E_PARAMNOTFOUND:
+ throw IllegalArgumentException(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("call to OLE object failed")), static_cast<XInterface*>(
+ static_cast<XWeak*>(this)), ::sal::static_int_cast< sal_Int16, unsigned int >( uArgErr )) ;
+ break;
+ case DISP_E_TYPEMISMATCH:
+ throw CannotConvertException(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("call to OLE object failed")), static_cast<XInterface*>(
+ static_cast<XWeak*>(this)), TypeClass_UNKNOWN, FailReason::UNKNOWN, ::sal::static_int_cast< sal_Int16, unsigned int >( uArgErr ));
+ break;
+ case DISP_E_UNKNOWNINTERFACE:
+ throw RuntimeException();
+ break;
+ case DISP_E_UNKNOWNLCID:
+ throw RuntimeException();
+ break;
+ case DISP_E_PARAMNOTOPTIONAL:
+ throw CannotConvertException(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("call to OLE object failed")),static_cast<XInterface*>(
+ static_cast<XWeak*>(this)) , TypeClass_UNKNOWN, FailReason::NO_DEFAULT_AVAILABLE, uArgErr);
+ break;
+ default:
+ throw RuntimeException();
+ break;
+ }
+ }
+ catch (CannotConvertException &)
+ {
+ throw;
+ }
+ catch (UnknownPropertyException &)
+ {
+ throw;
+ }
+ catch (BridgeRuntimeError& e)
+ {
+ throw RuntimeException(
+ e.message, Reference<XInterface>());
+ }
+ catch (Exception & e)
+ {
+ throw RuntimeException(OUSTR("[automation bridge] unexpected exception in "
+ "IUnknownWrapper_Impl::setValue ! Message : \n") +
+ e.Message, Reference<XInterface>());
+
+ }
+ catch (...)
+ {
+ throw RuntimeException(
+ OUSTR("[automation bridge] unexpected exception in "
+ "IUnknownWrapper_Impl::setValue !"), Reference<XInterface>());
+ }
+}
+
+Any SAL_CALL IUnknownWrapper_Impl::getValue( const OUString& aPropertyName )
+ throw(UnknownPropertyException, RuntimeException)
+{
+ if ( ! m_spDispatch )
+ {
+ throw RuntimeException(
+ OUSTR("[automation bridge] The object does not have an IDispatch interface"),
+ Reference<XInterface>());
+ }
+ Any ret;
+ try
+ {
+ o2u_attachCurrentThread();
+ ITypeInfo * pInfo = getTypeInfo();
+ // I was going to implement an XServiceInfo interface to allow the type
+ // of the automation object to be exposed.. but it seems
+ // from looking at comments in the code that it is possible for
+ // this object to actually wrap an UNO object ( I guess if automation is
+ // used from MSO to create Openoffice objects ) Therefore, those objects
+ // will more than likely already have their own XServiceInfo interface.
+ // Instead here I chose a name that should be illegal both in COM and
+ // UNO ( from an IDL point of view ) therefore I think this is a safe
+ // hack
+ if ( aPropertyName.equals( rtl::OUString::createFromAscii("$GetTypeName") ))
+ {
+ if ( pInfo && m_sTypeName.getLength() == 0 )
+ {
+ m_sTypeName = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("IDispatch") );
+ CComBSTR sName;
+
+ if ( SUCCEEDED( pInfo->GetDocumentation( -1, &sName, NULL, NULL, NULL ) ) )
+ {
+ rtl::OUString sTmp( reinterpret_cast<const sal_Unicode*>(LPCOLESTR(sName)));
+ if ( sTmp.indexOf('_') == 0 )
+ sTmp = sTmp.copy(1);
+ // do we own the memory for pTypeLib, msdn doco is vague
+ // I'll assume we do
+ CComPtr< ITypeLib > pTypeLib;
+ unsigned int index;
+ if ( SUCCEEDED( pInfo->GetContainingTypeLib( &pTypeLib.p, &index )) )
+ {
+ if ( SUCCEEDED( pTypeLib->GetDocumentation( -1, &sName, NULL, NULL, NULL ) ) )
+ {
+ rtl::OUString sLibName( reinterpret_cast<const sal_Unicode*>(LPCOLESTR(sName)));
+ m_sTypeName = sLibName.concat( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(".") ) ).concat( sTmp );
+
+ }
+ }
+ }
+
+ }
+ ret <<= m_sTypeName;
+ return ret;
+ }
+ FuncDesc aDescGet(pInfo);
+ FuncDesc aDescPut(pInfo);
+ VarDesc aVarDesc(pInfo);
+ getPropDesc(aPropertyName, & aDescGet, & aDescPut, & aVarDesc);
+ if ( ! aDescGet && ! aDescPut && ! aVarDesc)
+ {
+ //property not found
+ OUString msg(OUSTR("[automation bridge]Property \"") + aPropertyName +
+ OUSTR("\" is not supported"));
+ throw UnknownPropertyException(msg, Reference<XInterface>());
+ }
+ // write-only should not be possible
+ OSL_ASSERT( aDescGet || ! aDescPut);
+
+ HRESULT hr;
+ DISPPARAMS dispparams = {0, 0, 0, 0};
+ CComVariant varResult;
+ ExcepInfo excepinfo;
+ unsigned int uArgErr;
+ DISPID dispid;
+ if (aDescGet)
+ dispid = aDescGet->memid;
+ else if (aVarDesc)
+ dispid = aVarDesc->memid;
+ else
+ dispid = aDescPut->memid;
+
+ hr = m_spDispatch->Invoke(dispid,
+ IID_NULL,
+ LOCALE_USER_DEFAULT,
+ DISPATCH_PROPERTYGET,
+ &dispparams,
+ &varResult,
+ &excepinfo,
+ &uArgErr);
+
+ // converting return value and out parameter back to UNO
+ if (hr == S_OK)
+ {
+ // If the com object implements uno interfaces then we have
+ // to convert the attribute into the expected type.
+ TypeDescription attrInfo;
+ getAttributeInfo(aPropertyName, attrInfo);
+ if( attrInfo.is() )
+ variantToAny( &varResult, ret, Type( attrInfo.get()->pWeakRef));
+ else
+ variantToAny(&varResult, ret);
+ }
+
+ // lookup error code
+ switch (hr)
+ {
+ case S_OK:
+ break;
+ case DISP_E_BADPARAMCOUNT:
+ throw RuntimeException(OUString(reinterpret_cast<const sal_Unicode*>(excepinfo.bstrDescription)),
+ Reference<XInterface>());
+ break;
+ case DISP_E_BADVARTYPE:
+ throw RuntimeException(OUString(reinterpret_cast<const sal_Unicode*>(excepinfo.bstrDescription)),
+ Reference<XInterface>());
+ break;
+ case DISP_E_EXCEPTION:
+ throw RuntimeException(OUString(reinterpret_cast<const sal_Unicode*>(excepinfo.bstrDescription)),
+ Reference<XInterface>());
+ break;
+ case DISP_E_MEMBERNOTFOUND:
+ throw UnknownPropertyException(OUString(reinterpret_cast<const sal_Unicode*>(excepinfo.bstrDescription)),
+ Reference<XInterface>());
+ break;
+ case DISP_E_NONAMEDARGS:
+ throw RuntimeException(OUString(reinterpret_cast<const sal_Unicode*>(excepinfo.bstrDescription)),
+ Reference<XInterface>());
+ break;
+ case DISP_E_OVERFLOW:
+ throw RuntimeException(OUString(reinterpret_cast<const sal_Unicode*>(excepinfo.bstrDescription)),
+ Reference<XInterface>());
+ break;
+ case DISP_E_PARAMNOTFOUND:
+ throw RuntimeException(OUString(reinterpret_cast<const sal_Unicode*>(excepinfo.bstrDescription)),
+ Reference<XInterface>());
+ break;
+ case DISP_E_TYPEMISMATCH:
+ throw RuntimeException(OUString(reinterpret_cast<const sal_Unicode*>(excepinfo.bstrDescription)),
+ Reference<XInterface>());
+ break;
+ case DISP_E_UNKNOWNINTERFACE:
+ throw RuntimeException(OUString(reinterpret_cast<const sal_Unicode*>(excepinfo.bstrDescription)),
+ Reference<XInterface>());
+ break;
+ case DISP_E_UNKNOWNLCID:
+ throw RuntimeException(OUString(reinterpret_cast<const sal_Unicode*>(excepinfo.bstrDescription)),
+ Reference<XInterface>());
+ break;
+ case DISP_E_PARAMNOTOPTIONAL:
+ throw RuntimeException(OUString(reinterpret_cast<const sal_Unicode*>(excepinfo.bstrDescription)),
+ Reference<XInterface>());
+ break;
+ default:
+ throw RuntimeException(OUString(reinterpret_cast<const sal_Unicode*>(excepinfo.bstrDescription)),
+ Reference<XInterface>());
+ break;
+ }
+ }
+ catch (UnknownPropertyException& )
+ {
+ throw;
+ }
+ catch (BridgeRuntimeError& e)
+ {
+ throw RuntimeException(
+ e.message, Reference<XInterface>());
+ }
+ catch (Exception & e)
+ {
+ throw RuntimeException(OUSTR("[automation bridge] unexpected exception in "
+ "IUnknownWrapper_Impl::getValue ! Message : \n") +
+ e.Message, Reference<XInterface>());
+ }
+ catch (...)
+ {
+ throw RuntimeException(
+ OUSTR("[automation bridge] unexpected exception in "
+ "IUnknownWrapper_Impl::getValue !"), Reference<XInterface>());
+ }
+ return ret;
+}
+
+sal_Bool SAL_CALL IUnknownWrapper_Impl::hasMethod( const OUString& aName )
+ throw(RuntimeException)
+{
+ if ( ! m_spDispatch )
+ {
+ throw RuntimeException(
+ OUSTR("[automation bridge] The object does not have an IDispatch interface"),
+ Reference<XInterface>());
+ }
+ sal_Bool ret = sal_False;
+
+ try
+ {
+ o2u_attachCurrentThread();
+ ITypeInfo* pInfo = getTypeInfo();
+ FuncDesc aDesc(pInfo);
+ getFuncDesc(aName, & aDesc);
+ // Automation properties can have arguments. Those are treated as methods and
+ //are called through XInvocation::invoke.
+ if ( ! aDesc)
+ {
+ FuncDesc aDescGet(pInfo);
+ FuncDesc aDescPut(pInfo);
+ VarDesc aVarDesc(pInfo);
+ getPropDesc( aName, & aDescGet, & aDescPut, & aVarDesc);
+ if (aDescGet && aDescGet->cParams > 0
+ || aDescPut && aDescPut->cParams > 0)
+ ret = sal_True;
+ }
+ else
+ ret = sal_True;
+ }
+ catch (BridgeRuntimeError& e)
+ {
+ throw RuntimeException(e.message, Reference<XInterface>());
+ }
+ catch (Exception & e)
+ {
+ throw RuntimeException(OUSTR("[automation bridge] unexpected exception in "
+ "IUnknownWrapper_Impl::hasMethod ! Message : \n") +
+ e.Message, Reference<XInterface>());
+ }
+ catch (...)
+ {
+ throw RuntimeException(OUSTR("[automation bridge] unexpected exception in "
+ "IUnknownWrapper_Impl::hasMethod !"), Reference<XInterface>());;
+ }
+ return ret;
+}
+
+sal_Bool SAL_CALL IUnknownWrapper_Impl::hasProperty( const OUString& aName )
+ throw(RuntimeException)
+{
+ if ( ! m_spDispatch )
+ {
+ throw RuntimeException(OUSTR("[automation bridge] The object does not have an "
+ "IDispatch interface"), Reference<XInterface>());
+ return sal_False;
+ }
+ sal_Bool ret = sal_False;
+ try
+ {
+ o2u_attachCurrentThread();
+
+ ITypeInfo * pInfo = getTypeInfo();
+ FuncDesc aDescGet(pInfo);
+ FuncDesc aDescPut(pInfo);
+ VarDesc aVarDesc(pInfo);
+ getPropDesc(aName, & aDescGet, & aDescPut, & aVarDesc);
+
+ // we should probably just check the funckind
+ // basic has been modified to handle properties ( 'get' ) props at
+ // least with paramaters
+ // additionally you can call invoke(Get|Set)Property on the bridge
+ // you can determine if a property has parameter is hasMethod
+ // returns true for the name
+ if (aVarDesc
+ || aDescPut
+ || aDescGet )
+ {
+ ret = sal_True;
+ }
+ }
+ catch (BridgeRuntimeError& e)
+ {
+ throw RuntimeException(e.message, Reference<XInterface>());
+ }
+ catch (Exception & e)
+ {
+ throw RuntimeException(OUSTR("[automation bridge] unexpected exception in "
+ "IUnknownWrapper_Impl::hasProperty ! Message : \n") +
+ e.Message, Reference<XInterface>());
+
+ }
+ catch (...)
+ {
+ throw RuntimeException(OUSTR("[automation bridge] unexpected exception in "
+ "IUnknownWrapper_Impl::hasProperty !"), Reference<XInterface>());
+ }
+ return ret;
+}
+
+Any SAL_CALL IUnknownWrapper_Impl::createBridge( const Any& modelDepObject,
+ const Sequence< sal_Int8 >& /*aProcessId*/, sal_Int16 sourceModelType,
+ sal_Int16 destModelType )
+ throw( IllegalArgumentException, RuntimeException)
+{
+ Any ret;
+ o2u_attachCurrentThread();
+
+ if (
+ (sourceModelType == UNO) &&
+ (destModelType == OLE) &&
+ (modelDepObject.getValueTypeClass() == TypeClass_INTERFACE)
+ )
+ {
+ Reference<XInterface> xInt( *(XInterface**) modelDepObject.getValue());
+ Reference<XInterface> xSelf( (OWeakObject*)this);
+
+ if (xInt == xSelf)
+ {
+ VARIANT* pVariant = (VARIANT*) CoTaskMemAlloc(sizeof(VARIANT));
+
+ VariantInit(pVariant);
+ if (m_bOriginalDispatch == sal_True)
+ {
+ pVariant->vt = VT_DISPATCH;
+ pVariant->pdispVal = m_spDispatch;
+ pVariant->pdispVal->AddRef();
+ }
+ else
+ {
+ pVariant->vt = VT_UNKNOWN;
+ pVariant->punkVal = m_spUnknown;
+ pVariant->punkVal->AddRef();
+ }
+
+ ret.setValue((void*)&pVariant, getCppuType( (sal_uInt32*) 0));
+ }
+ }
+
+ return ret;
+}
+/** @internal
+ @exception IllegalArgumentException
+ @exception CannotConvertException
+ @exception InvocationTargetException
+ @RuntimeException
+*/
+Any IUnknownWrapper_Impl::invokeWithDispIdUnoTlb(const OUString& sFunctionName,
+ const Sequence< Any >& Params,
+ Sequence< sal_Int16 >& OutParamIndex,
+ Sequence< Any >& OutParam)
+{
+ Any ret;
+ HRESULT hr= S_OK;
+
+ sal_Int32 parameterCount= Params.getLength();
+ sal_Int32 outParameterCount= 0;
+ typelib_InterfaceMethodTypeDescription* pMethod= NULL;
+ TypeDescription methodDesc;
+ getMethodInfo(sFunctionName, methodDesc);
+
+ // We need to know whether the IDispatch is from a JScript object.
+ // Then out and in/out parameters have to be treated differently than
+ // with common COM objects.
+ sal_Bool bJScriptObject= isJScriptObject();
+ scoped_array<CComVariant> sarParams;
+ scoped_array<CComVariant> sarParamsRef;
+ CComVariant *pVarParams= NULL;
+ CComVariant *pVarParamsRef= NULL;
+ sal_Bool bConvRet= sal_True;
+
+ if( methodDesc.is())
+ {
+ pMethod = (typelib_InterfaceMethodTypeDescription* )methodDesc.get();
+ parameterCount = pMethod->nParams;
+ // Create the Array for the array being passed in DISPPARAMS
+ // the array also contains the outparameter (but not the values)
+ if( pMethod->nParams > 0)
+ {
+ sarParams.reset(new CComVariant[ parameterCount]);
+ pVarParams = sarParams.get();
+ }
+
+ // Create the Array for the out an in/out parameter. These values
+ // are referenced by the VT_BYREF VARIANTs in DISPPARAMS.
+ // We need to find out the number of out and in/out parameter.
+ for( sal_Int32 i=0; i < parameterCount; i++)
+ {
+ if( pMethod->pParams[i].bOut)
+ outParameterCount++;
+ }
+
+ if( !bJScriptObject)
+ {
+ sarParamsRef.reset(new CComVariant[outParameterCount]);
+ pVarParamsRef = sarParamsRef.get();
+ // build up the parameters for IDispatch::Invoke
+ sal_Int32 outParamIndex=0;
+ int i = 0;
+ try
+ {
+ for( i= 0; i < parameterCount; i++)
+ {
+ // In parameter
+ if( pMethod->pParams[i].bIn == sal_True && ! pMethod->pParams[i].bOut)
+ {
+ anyToVariant( &pVarParams[parameterCount - i -1], Params.getConstArray()[i]);
+ }
+ // Out parameter + in/out parameter
+ else if( pMethod->pParams[i].bOut == sal_True)
+ {
+ CComVariant var;
+ if(pMethod->pParams[i].bIn)
+ {
+ anyToVariant( & var,Params[i]);
+ pVarParamsRef[outParamIndex] = var;
+ }
+
+ switch( pMethod->pParams[i].pTypeRef->eTypeClass)
+ {
+ case TypeClass_INTERFACE:
+ case TypeClass_STRUCT:
+ if( ! pMethod->pParams[i].bIn)
+ {
+ pVarParamsRef[ outParamIndex].vt= VT_DISPATCH;
+ pVarParamsRef[ outParamIndex].pdispVal= 0;
+ }
+ pVarParams[parameterCount - i -1].vt = VT_DISPATCH | VT_BYREF;
+ pVarParams[parameterCount - i -1].ppdispVal= &pVarParamsRef[outParamIndex].pdispVal;
+ break;
+ case TypeClass_ENUM:
+ case TypeClass_LONG:
+ case TypeClass_UNSIGNED_LONG:
+ if( ! pMethod->pParams[i].bIn)
+ {
+ pVarParamsRef[ outParamIndex].vt = VT_I4;
+ pVarParamsRef[ outParamIndex].lVal = 0;
+ }
+ pVarParams[parameterCount - i -1].vt = VT_I4 | VT_BYREF;
+ pVarParams[parameterCount - i -1].plVal= &pVarParamsRef[outParamIndex].lVal;
+ break;
+ case TypeClass_SEQUENCE:
+ if( ! pMethod->pParams[i].bIn)
+ {
+ pVarParamsRef[ outParamIndex].vt = VT_ARRAY| VT_VARIANT;
+ pVarParamsRef[ outParamIndex].parray= NULL;
+ }
+ pVarParams[parameterCount - i -1].vt = VT_ARRAY| VT_BYREF | VT_VARIANT;
+ pVarParams[parameterCount - i -1].pparray= &pVarParamsRef[outParamIndex].parray;
+ break;
+ case TypeClass_ANY:
+ if( ! pMethod->pParams[i].bIn)
+ {
+ pVarParamsRef[ outParamIndex].vt = VT_EMPTY;
+ pVarParamsRef[ outParamIndex].lVal = 0;
+ }
+ pVarParams[parameterCount - i -1].vt = VT_VARIANT | VT_BYREF;
+ pVarParams[parameterCount - i -1].pvarVal = &pVarParamsRef[outParamIndex];
+ break;
+ case TypeClass_BOOLEAN:
+ if( ! pMethod->pParams[i].bIn)
+ {
+ pVarParamsRef[ outParamIndex].vt = VT_BOOL;
+ pVarParamsRef[ outParamIndex].boolVal = 0;
+ }
+ pVarParams[parameterCount - i -1].vt = VT_BOOL| VT_BYREF;
+ pVarParams[parameterCount - i -1].pboolVal =
+ & pVarParamsRef[outParamIndex].boolVal;
+ break;
+
+ case TypeClass_STRING:
+ if( ! pMethod->pParams[i].bIn)
+ {
+ pVarParamsRef[ outParamIndex].vt = VT_BSTR;
+ pVarParamsRef[ outParamIndex].bstrVal= 0;
+ }
+ pVarParams[parameterCount - i -1].vt = VT_BSTR| VT_BYREF;
+ pVarParams[parameterCount - i -1].pbstrVal=
+ & pVarParamsRef[outParamIndex].bstrVal;
+ break;
+
+ case TypeClass_FLOAT:
+ if( ! pMethod->pParams[i].bIn)
+ {
+ pVarParamsRef[ outParamIndex].vt = VT_R4;
+ pVarParamsRef[ outParamIndex].fltVal= 0;
+ }
+ pVarParams[parameterCount - i -1].vt = VT_R4| VT_BYREF;
+ pVarParams[parameterCount - i -1].pfltVal =
+ & pVarParamsRef[outParamIndex].fltVal;
+ break;
+ case TypeClass_DOUBLE:
+ if( ! pMethod->pParams[i].bIn)
+ {
+ pVarParamsRef[ outParamIndex].vt = VT_R8;
+ pVarParamsRef[ outParamIndex].dblVal= 0;
+ }
+ pVarParams[parameterCount - i -1].vt = VT_R8| VT_BYREF;
+ pVarParams[parameterCount - i -1].pdblVal=
+ & pVarParamsRef[outParamIndex].dblVal;
+ break;
+ case TypeClass_BYTE:
+ if( ! pMethod->pParams[i].bIn)
+ {
+ pVarParamsRef[ outParamIndex].vt = VT_UI1;
+ pVarParamsRef[ outParamIndex].bVal= 0;
+ }
+ pVarParams[parameterCount - i -1].vt = VT_UI1| VT_BYREF;
+ pVarParams[parameterCount - i -1].pbVal=
+ & pVarParamsRef[outParamIndex].bVal;
+ break;
+ case TypeClass_CHAR:
+ case TypeClass_SHORT:
+ case TypeClass_UNSIGNED_SHORT:
+ if( ! pMethod->pParams[i].bIn)
+ {
+ pVarParamsRef[ outParamIndex].vt = VT_I2;
+ pVarParamsRef[ outParamIndex].iVal = 0;
+ }
+ pVarParams[parameterCount - i -1].vt = VT_I2| VT_BYREF;
+ pVarParams[parameterCount - i -1].piVal=
+ & pVarParamsRef[outParamIndex].iVal;
+ break;
+
+ default:
+ if( ! pMethod->pParams[i].bIn)
+ {
+ pVarParamsRef[ outParamIndex].vt = VT_EMPTY;
+ pVarParamsRef[ outParamIndex].lVal = 0;
+ }
+ pVarParams[parameterCount - i -1].vt = VT_VARIANT | VT_BYREF;
+ pVarParams[parameterCount - i -1].pvarVal =
+ & pVarParamsRef[outParamIndex];
+ }
+ outParamIndex++;
+ } // end else if
+ } // end for
+ }
+ catch (IllegalArgumentException & e)
+ {
+ e.ArgumentPosition = ::sal::static_int_cast< sal_Int16, int >( i );
+ throw;
+ }
+ catch (CannotConvertException & e)
+ {
+ e.ArgumentIndex = i;
+ throw;
+ }
+ }
+ else // it is an JScriptObject
+ {
+ int i = 0;
+ try
+ {
+ for( ; i< parameterCount; i++)
+ {
+ // In parameter
+ if( pMethod->pParams[i].bIn == sal_True && ! pMethod->pParams[i].bOut)
+ {
+ anyToVariant( &pVarParams[parameterCount - i -1], Params.getConstArray()[i]);
+ }
+ // Out parameter + in/out parameter
+ else if( pMethod->pParams[i].bOut == sal_True)
+ {
+ CComObject<JScriptOutParam>* pParamObject;
+ if( SUCCEEDED( CComObject<JScriptOutParam>::CreateInstance( &pParamObject)))
+ {
+ CComPtr<IUnknown> pUnk(pParamObject->GetUnknown());
+#ifdef __MINGW32__
+ CComQIPtr<IDispatch, &__uuidof(IDispatch)> pDisp( pUnk);
+#else
+ CComQIPtr<IDispatch> pDisp( pUnk);
+#endif
+
+ pVarParams[ parameterCount - i -1].vt= VT_DISPATCH;
+ pVarParams[ parameterCount - i -1].pdispVal= pDisp;
+ pVarParams[ parameterCount - i -1].pdispVal->AddRef();
+ // if the param is in/out then put the parameter on index 0
+ if( pMethod->pParams[i].bIn == sal_True ) // in / out
+ {
+ CComVariant varParam;
+ anyToVariant( &varParam, Params.getConstArray()[i]);
+ CComDispatchDriver dispDriver( pDisp);
+ if(FAILED( dispDriver.PutPropertyByName( L"0", &varParam)))
+ throw BridgeRuntimeError(
+ OUSTR("[automation bridge]IUnknownWrapper_Impl::"
+ "invokeWithDispIdUnoTlb\n"
+ "Could not set property \"0\" for the in/out "
+ "param!"));
+
+ }
+ }
+ else
+ {
+ throw BridgeRuntimeError(
+ OUSTR("[automation bridge]IUnknownWrapper_Impl::"
+ "invokeWithDispIdUnoTlb\n"
+ "Could not create out parameter at index: ") +
+ OUString::valueOf((sal_Int32) i));
+ }
+
+ }
+ }
+ }
+ catch (IllegalArgumentException & e)
+ {
+ e.ArgumentPosition = ::sal::static_int_cast< sal_Int16, int >( i );
+ throw;
+ }
+ catch (CannotConvertException & e)
+ {
+ e.ArgumentIndex = i;
+ throw;
+ }
+ }
+ }
+ // No type description Available, that is we have to deal with a COM component,
+ // that does not implements UNO interfaces ( IDispatch based)
+ else
+ {
+ //We should not run into this block, because invokeWithDispIdComTlb should
+ //have been called instead.
+ OSL_ASSERT(0);
+ }
+
+
+ CComVariant varResult;
+ ExcepInfo excepinfo;
+ unsigned int uArgErr;
+ DISPPARAMS dispparams= { pVarParams, NULL, parameterCount, 0};
+ // Get the DISPID
+ FuncDesc aDesc(getTypeInfo());
+ getFuncDesc(sFunctionName, & aDesc);
+ // invoking OLE method
+ hr = m_spDispatch->Invoke(aDesc->memid,
+ IID_NULL,
+ LOCALE_USER_DEFAULT,
+ DISPATCH_METHOD,
+ &dispparams,
+ &varResult,
+ &excepinfo,
+ &uArgErr);
+
+ // converting return value and out parameter back to UNO
+ if (hr == S_OK)
+ {
+ if( outParameterCount && pMethod)
+ {
+ OutParamIndex.realloc( outParameterCount);
+ OutParam.realloc( outParameterCount);
+ sal_Int32 outIndex=0;
+ int i = 0;
+ try
+ {
+ for( ; i < parameterCount; i++)
+ {
+ if( pMethod->pParams[i].bOut )
+ {
+ OutParamIndex[outIndex]= (sal_Int16) i;
+ Any outAny;
+ if( !bJScriptObject)
+ {
+ variantToAny( &pVarParamsRef[outIndex], outAny,
+ Type(pMethod->pParams[i].pTypeRef), sal_False);
+ OutParam[outIndex++]= outAny;
+ }
+ else //JScriptObject
+ {
+ if( pVarParams[i].vt == VT_DISPATCH)
+ {
+ CComDispatchDriver pDisp( pVarParams[i].pdispVal);
+ if( pDisp)
+ {
+ CComVariant varOut;
+ if( SUCCEEDED( pDisp.GetPropertyByName( L"0", &varOut)))
+ {
+ variantToAny( &varOut, outAny,
+ Type(pMethod->pParams[parameterCount - 1 - i].pTypeRef), sal_False);
+ OutParam[outParameterCount - 1 - outIndex++]= outAny;
+ }
+ else
+ bConvRet= sal_False;
+ }
+ else
+ bConvRet= sal_False;
+ }
+ else
+ bConvRet= sal_False;
+ }
+ }
+ if( !bConvRet) break;
+ }
+ }
+ catch(IllegalArgumentException & e)
+ {
+ e.ArgumentPosition = ::sal::static_int_cast< sal_Int16, int >( i );
+ throw;
+ }
+ catch(CannotConvertException & e)
+ {
+ e.ArgumentIndex = i;
+ throw;
+ }
+ }
+ // return value, no type information available
+ if ( bConvRet)
+ {
+ try
+ {
+ if( pMethod )
+ variantToAny(&varResult, ret, Type( pMethod->pReturnTypeRef), sal_False);
+ else
+ variantToAny(&varResult, ret, sal_False);
+ }
+ catch (IllegalArgumentException & e)
+ {
+ e.Message =
+ OUSTR("[automation bridge]IUnknownWrapper_Impl::invokeWithDispIdUnoTlb\n"
+ "Could not convert return value! \n Message: \n") + e.Message;
+ throw;
+ }
+ catch (CannotConvertException & e)
+ {
+ e.Message =
+ OUSTR("[automation bridge]IUnknownWrapper_Impl::invokeWithDispIdUnoTlb\n"
+ "Could not convert return value! \n Message: \n") + e.Message;
+ throw;
+ }
+ }
+ }
+
+ if( !bConvRet) // conversion of return or out parameter failed
+ throw CannotConvertException( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Call to COM object failed. Conversion of return or out value failed")),
+ Reference<XInterface>( static_cast<XWeak*>(this), UNO_QUERY ), TypeClass_UNKNOWN,
+ FailReason::UNKNOWN, 0);// lookup error code
+ // conversion of return or out parameter failed
+ switch (hr)
+ {
+ case S_OK:
+ break;
+ case DISP_E_BADPARAMCOUNT:
+ throw IllegalArgumentException();
+ break;
+ case DISP_E_BADVARTYPE:
+ throw RuntimeException();
+ break;
+ case DISP_E_EXCEPTION:
+ throw InvocationTargetException();
+ break;
+ case DISP_E_MEMBERNOTFOUND:
+ throw IllegalArgumentException();
+ break;
+ case DISP_E_NONAMEDARGS:
+ throw IllegalArgumentException();
+ break;
+ case DISP_E_OVERFLOW:
+ throw CannotConvertException(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("call to OLE object failed")), static_cast<XInterface*>(
+ static_cast<XWeak*>(this)), TypeClass_UNKNOWN, FailReason::OUT_OF_RANGE, uArgErr);
+ break;
+ case DISP_E_PARAMNOTFOUND:
+ throw IllegalArgumentException(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("call to OLE object failed")), static_cast<XInterface*>(
+ static_cast<XWeak*>(this)), ::sal::static_int_cast< sal_Int16, unsigned int >( uArgErr ));
+ break;
+ case DISP_E_TYPEMISMATCH:
+ throw CannotConvertException(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("call to OLE object failed")),static_cast<XInterface*>(
+ static_cast<XWeak*>(this)) , TypeClass_UNKNOWN, FailReason::UNKNOWN, uArgErr);
+ break;
+ case DISP_E_UNKNOWNINTERFACE:
+ throw RuntimeException() ;
+ break;
+ case DISP_E_UNKNOWNLCID:
+ throw RuntimeException() ;
+ break;
+ case DISP_E_PARAMNOTOPTIONAL:
+ throw CannotConvertException(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("call to OLE object failed")), static_cast<XInterface*>(
+ static_cast<XWeak*>(this)), TypeClass_UNKNOWN, FailReason::NO_DEFAULT_AVAILABLE, uArgErr);
+ break;
+ default:
+ throw RuntimeException();
+ break;
+ }
+
+ return ret;
+}
+
+
+
+ // --------------------------
+// XInitialization
+void SAL_CALL IUnknownWrapper_Impl::initialize( const Sequence< Any >& aArguments ) throw(Exception, RuntimeException)
+{
+ // 1.parameter is IUnknown
+ // 2.parameter is a boolean which indicates if the the COM pointer was a IUnknown or IDispatch
+ // 3.parameter is a Sequence<Type>
+ o2u_attachCurrentThread();
+ OSL_ASSERT(aArguments.getLength() == 3);
+
+ m_spUnknown= *(IUnknown**) aArguments[0].getValue();
+#ifdef __MINGW32__
+ m_spUnknown->QueryInterface(IID_IDispatch, reinterpret_cast<LPVOID*>( & m_spDispatch.p));
+#else
+ m_spUnknown.QueryInterface( & m_spDispatch.p);
+#endif
+
+ aArguments[1] >>= m_bOriginalDispatch;
+ aArguments[2] >>= m_seqTypes;
+
+ ITypeInfo* pType = NULL;
+ try
+ {
+ // a COM object implementation that has no TypeInfo is still a legal COM object;
+ // such objects can at least be transported through UNO using the bridge
+ // so we should allow to create wrappers for them as well
+ pType = getTypeInfo();
+ }
+ catch( BridgeRuntimeError& )
+ {}
+ catch( Exception& )
+ {}
+
+ if ( pType )
+ {
+ try
+ {
+ // Get Default member
+ CComBSTR defaultMemberName;
+ if ( SUCCEEDED( pType->GetDocumentation(0, &defaultMemberName, 0, 0, 0 ) ) )
+ {
+ OUString usName(reinterpret_cast<const sal_Unicode*>(LPCOLESTR(defaultMemberName)));
+ FuncDesc aDescGet(pType);
+ FuncDesc aDescPut(pType);
+ VarDesc aVarDesc(pType);
+ // see if this is a property first ( more likely to be a property then a method )
+ getPropDesc( usName, & aDescGet, & aDescPut, & aVarDesc);
+
+ if ( !aDescGet && !aDescPut )
+ {
+ getFuncDesc( usName, &aDescGet );
+ if ( !aDescGet )
+ throw BridgeRuntimeError( OUSTR("[automation bridge]IUnknownWrapper_Impl::initialize() Failed to get Function or Property desc. for " ) + usName );
+ }
+ // now for some funny heuristics to make basic understand what to do
+ // a single aDescGet ( that doesn't take any params ) would be
+ // a read only ( defaultmember ) property e.g. this object
+ // should implement XDefaultProperty
+ // a single aDescGet ( that *does* ) take params is basically a
+ // default method e.g. implement XDefaultMethod
+
+ // a DescPut ( I guess we only really support a default param with '1' param ) as a setValue ( but I guess we can leave it through, the object will fail if we don't get it right anyway )
+ if ( aDescPut || ( aDescGet && aDescGet->cParams == 0 ) )
+ m_bHasDfltProperty = true;
+ if ( aDescGet->cParams > 0 )
+ m_bHasDfltMethod = true;
+ if ( m_bHasDfltProperty || m_bHasDfltMethod )
+ m_sDefaultMember = usName;
+ }
+ }
+ catch ( BridgeRuntimeError & e )
+ {
+ throw RuntimeException( e.message, Reference<XInterface>() );
+ }
+ catch( Exception& e )
+ {
+ throw RuntimeException(
+ OUSTR("[automation bridge] unexpected exception in IUnknownWrapper_Impl::initialiase() error message: \n") + e.Message,
+ Reference<XInterface>() );
+ }
+ }
+}
+
+// UnoConversionUtilities --------------------------------------------------------------------------------
+Reference< XInterface > IUnknownWrapper_Impl::createUnoWrapperInstance()
+{
+ if( m_nUnoWrapperClass == INTERFACE_OLE_WRAPPER_IMPL)
+ {
+ Reference<XWeak> xWeak= static_cast<XWeak*>( new InterfaceOleWrapper_Impl(
+ m_smgr, m_nUnoWrapperClass, m_nComWrapperClass));
+ return Reference<XInterface>( xWeak, UNO_QUERY);
+ }
+ else if( m_nUnoWrapperClass == UNO_OBJECT_WRAPPER_REMOTE_OPT)
+ {
+ Reference<XWeak> xWeak= static_cast<XWeak*>( new UnoObjectWrapperRemoteOpt(
+ m_smgr, m_nUnoWrapperClass, m_nComWrapperClass));
+ return Reference<XInterface>( xWeak, UNO_QUERY);
+ }
+ else
+ return Reference<XInterface>();
+}
+Reference<XInterface> IUnknownWrapper_Impl::createComWrapperInstance()
+{
+ Reference<XWeak> xWeak= static_cast<XWeak*>( new IUnknownWrapper_Impl(
+ m_smgr, m_nUnoWrapperClass, m_nComWrapperClass));
+ return Reference<XInterface>( xWeak, UNO_QUERY);
+}
+
+
+
+void IUnknownWrapper_Impl::getMethodInfo(const OUString& sName, TypeDescription& methodInfo)
+{
+ TypeDescription desc= getInterfaceMemberDescOfCurrentCall(sName);
+ if( desc.is())
+ {
+ typelib_TypeDescription* pMember= desc.get();
+ if( pMember->eTypeClass == TypeClass_INTERFACE_METHOD )
+ methodInfo= pMember;
+ }
+}
+
+void IUnknownWrapper_Impl::getAttributeInfo(const OUString& sName, TypeDescription& attributeInfo)
+{
+ TypeDescription desc= getInterfaceMemberDescOfCurrentCall(sName);
+ if( desc.is())
+ {
+ typelib_TypeDescription* pMember= desc.get();
+ if( pMember->eTypeClass == TypeClass_INTERFACE_ATTRIBUTE )
+ {
+ attributeInfo= ((typelib_InterfaceAttributeTypeDescription*)pMember)->pAttributeTypeRef;
+ }
+ }
+}
+TypeDescription IUnknownWrapper_Impl::getInterfaceMemberDescOfCurrentCall(const OUString& sName)
+{
+ TypeDescription ret;
+
+ for( sal_Int32 i=0; i < m_seqTypes.getLength(); i++)
+ {
+ TypeDescription _curDesc( m_seqTypes[i]);
+ _curDesc.makeComplete();
+ typelib_InterfaceTypeDescription * pInterface= (typelib_InterfaceTypeDescription*) _curDesc.get();
+ if( pInterface)
+ {
+ typelib_InterfaceMemberTypeDescription* pMember= NULL;
+ //find the member description of the current call
+ for( int i=0; i < pInterface->nAllMembers; i++)
+ {
+ typelib_TypeDescriptionReference* pTypeRefMember = pInterface->ppAllMembers[i];
+ typelib_TypeDescription* pDescMember= NULL;
+ TYPELIB_DANGER_GET( &pDescMember, pTypeRefMember)
+
+ typelib_InterfaceMemberTypeDescription* pInterfaceMember=
+ (typelib_InterfaceMemberTypeDescription*) pDescMember;
+ if( OUString( pInterfaceMember->pMemberName) == sName)
+ {
+ pMember= pInterfaceMember;
+ break;
+ }
+ TYPELIB_DANGER_RELEASE( pDescMember)
+ }
+
+ if( pMember)
+ {
+ ret= (typelib_TypeDescription*)pMember;
+ TYPELIB_DANGER_RELEASE( (typelib_TypeDescription*)pMember);
+ }
+ }
+ if( ret.is())
+ break;
+ }
+ return ret;
+}
+
+sal_Bool IUnknownWrapper_Impl::isJScriptObject()
+{
+ if( m_eJScript == JScriptUndefined)
+ {
+ CComDispatchDriver disp( m_spDispatch);
+ if( disp)
+ {
+ CComVariant result;
+ if( SUCCEEDED( disp.GetPropertyByName( JSCRIPT_ID_PROPERTY, &result)))
+ {
+ if(result.vt == VT_BSTR)
+ {
+ CComBSTR name( result.bstrVal);
+ name.ToLower();
+ if( name == CComBSTR(JSCRIPT_ID))
+ m_eJScript= IsJScript;
+ }
+ }
+ }
+ if( m_eJScript == JScriptUndefined)
+ m_eJScript= NoJScript;
+ }
+
+ return m_eJScript == NoJScript ? sal_False : sal_True;
+}
+
+
+
+/** @internal
+ The function ultimately calls IDispatch::Invoke on the wrapped COM object.
+ The COM object does not implement UNO Interfaces ( via IDispatch). This
+ is the case when the OleObjectFactory service has been used to create a
+ component.
+ @exception IllegalArgumentException
+ @exception CannotConvertException
+ @InvocationTargetException
+ @RuntimeException
+ @BridgeRuntimeError
+*/
+Any IUnknownWrapper_Impl::invokeWithDispIdComTlb(const OUString& sFuncName,
+ const Sequence< Any >& Params,
+ Sequence< sal_Int16 >& OutParamIndex,
+ Sequence< Any >& OutParam)
+{
+ // Get type info for the call. It can be a method call or property put or
+ // property get operation.
+ FuncDesc aFuncDesc(getTypeInfo());
+ getFuncDescForInvoke(sFuncName, Params, & aFuncDesc);
+ return invokeWithDispIdComTlb( aFuncDesc, sFuncName, Params, OutParamIndex, OutParam );
+}
+
+Any IUnknownWrapper_Impl::invokeWithDispIdComTlb(FuncDesc& aFuncDesc,
+ const OUString& sFuncName,
+ const Sequence< Any >& Params,
+ Sequence< sal_Int16 >& OutParamIndex,
+ Sequence< Any >& OutParam)
+{
+ Any ret;
+ HRESULT result;
+
+ DISPPARAMS dispparams = {NULL, NULL, 0, 0};
+ CComVariant varResult;
+ ExcepInfo excepinfo;
+ unsigned int uArgErr;
+ sal_Int32 i = 0;
+ sal_Int32 nUnoArgs = Params.getLength();
+ DISPID idPropertyPut = DISPID_PROPERTYPUT;
+ scoped_array<DISPID> arDispidNamedArgs;
+ scoped_array<CComVariant> ptrArgs;
+ scoped_array<CComVariant> ptrRefArgs; // referenced arguments
+ CComVariant * arArgs = NULL;
+ CComVariant * arRefArgs = NULL;
+ sal_Int32 revIndex = 0;
+ bool bVarargParam = false;
+
+
+ //Set the array of DISPIDs for named args if it is a property put operation.
+ //If there are other named arguments another array is set later on.
+ if (aFuncDesc->invkind == INVOKE_PROPERTYPUT
+ || aFuncDesc->invkind == INVOKE_PROPERTYPUTREF)
+ dispparams.rgdispidNamedArgs = & idPropertyPut;
+
+ //Determine the number of named arguments
+ for (int iParam = 0; iParam < nUnoArgs; iParam ++)
+ {
+ const Any & curArg = Params[iParam];
+ if (curArg.getValueType() == getCppuType((NamedArgument*) 0))
+ dispparams.cNamedArgs ++;
+ }
+ //In a property put operation a property value is a named argument (DISPID_PROPERTYPUT).
+ //Therefore the number of named arguments is increased by one.
+ //Although named, the argument is not named in a actual language, such as Basic,
+ //therefore it is never a com.sun.star.bridge.oleautomation.NamedArgument
+ if (aFuncDesc->invkind == DISPATCH_PROPERTYPUT
+ || aFuncDesc->invkind == DISPATCH_PROPERTYPUTREF)
+ dispparams.cNamedArgs ++;
+
+ //Determine the number of all arguments and named arguments
+ if (aFuncDesc->cParamsOpt == -1)
+ {
+ //Attribute vararg is set on this method. "Unlimited" number of args
+ //supported. There can be no optional or defaultvalue on any of the arguments.
+ dispparams.cArgs = nUnoArgs;
+ }
+ else
+ {
+ //If there are namesd arguments, then the dispparams.cArgs
+ //is the number of supplied args, otherwise it is the expected number.
+ if (dispparams.cNamedArgs)
+ dispparams.cArgs = nUnoArgs;
+ else
+ dispparams.cArgs = aFuncDesc->cParams;
+ }
+
+ //check if there are not to many arguments supplied
+ if (::sal::static_int_cast< sal_uInt32, int >( nUnoArgs ) > dispparams.cArgs)
+ {
+ OUStringBuffer buf(256);
+ buf.appendAscii("[automation bridge] There are too many arguments for this method");
+ throw IllegalArgumentException( buf.makeStringAndClear(),
+ Reference<XInterface>(), (sal_Int16) dispparams.cArgs);
+ }
+
+ //Set up the array of DISPIDs (DISPPARAMS::rgdispidNamedArgs)
+ //for the named arguments.
+ //If there is only one named arg and if it is because of a property put
+ //operation, then we need not set up the DISPID array.
+ if (dispparams.cNamedArgs > 0 &&
+ ! (dispparams.cNamedArgs == 1 &&
+ (aFuncDesc->invkind == INVOKE_PROPERTYPUT ||
+ aFuncDesc->invkind == INVOKE_PROPERTYPUT)))
+ {
+ //set up an array containing the member and parameter names
+ //which is then used in ITypeInfo::GetIDsOfNames
+ //First determine the size of the array of names which is passed to
+ //ITypeInfo::GetIDsOfNames. It must hold the method names + the named
+ //args.
+ int nSizeAr = dispparams.cNamedArgs + 1;
+ if (aFuncDesc->invkind == INVOKE_PROPERTYPUT
+ || aFuncDesc->invkind == INVOKE_PROPERTYPUTREF)
+ {
+ nSizeAr = dispparams.cNamedArgs; //counts the DISID_PROPERTYPUT
+ }
+
+ scoped_array<OLECHAR*> saNames(new OLECHAR*[nSizeAr]);
+ OLECHAR ** arNames = saNames.get();
+ arNames[0] = const_cast<OLECHAR*>(reinterpret_cast<LPCOLESTR>(sFuncName.getStr()));
+
+ int cNamedArg = 0;
+ for (size_t iParams = 0; iParams < dispparams.cArgs; iParams ++)
+ {
+ const Any & curArg = Params[iParams];
+ if (curArg.getValueType() == getCppuType((NamedArgument*) 0))
+ {
+ const NamedArgument& arg = *(NamedArgument const*) curArg.getValue();
+ //We put the parameter names in reverse order into the array,
+ //so we can use the DISPID array for DISPPARAMS::rgdispidNamedArgs
+ //The first name in the array is the method name
+ arNames[nSizeAr - 1 - cNamedArg++] = const_cast<OLECHAR*>(reinterpret_cast<LPCOLESTR>(arg.Name.getStr()));
+ }
+ }
+
+ //Prepare the array of DISPIDs for ITypeInfo::GetIDsOfNames
+ //it must be big enough to contain the DISPIDs of the member + parameters
+ arDispidNamedArgs.reset(new DISPID[nSizeAr]);
+ HRESULT hr = getTypeInfo()->GetIDsOfNames(arNames, nSizeAr,
+ arDispidNamedArgs.get());
+ if ( hr == E_NOTIMPL )
+ hr = m_spDispatch->GetIDsOfNames(IID_NULL, arNames, nSizeAr, LOCALE_USER_DEFAULT, arDispidNamedArgs.get() );
+
+ if (hr == S_OK)
+ {
+ // In a "property put" operation, the property value is a named param with the
+ //special DISPID DISPID_PROPERTYPUT
+ if (aFuncDesc->invkind == DISPATCH_PROPERTYPUT
+ || aFuncDesc->invkind == DISPATCH_PROPERTYPUTREF)
+ {
+ //Element at index 0 in the DISPID array must be DISPID_PROPERTYPUT
+ //The first item in the array arDispidNamedArgs is the DISPID for
+ //the method. We replace it with DISPID_PROPERTYPUT.
+ DISPID* arIDs = arDispidNamedArgs.get();
+ arIDs[0] = DISPID_PROPERTYPUT;
+ dispparams.rgdispidNamedArgs = arIDs;
+ }
+ else
+ {
+ //The first item in the array arDispidNamedArgs is the DISPID for
+ //the method. It must be removed
+ DISPID* arIDs = arDispidNamedArgs.get();
+ dispparams.rgdispidNamedArgs = & arIDs[1];
+ }
+ }
+ else if (hr == DISP_E_UNKNOWNNAME)
+ {
+ throw IllegalArgumentException(
+ OUSTR("[automation bridge]One of the named arguments is wrong!"),
+ Reference<XInterface>(), 0);
+ }
+ else
+ {
+ throw InvocationTargetException(
+ OUSTR("[automation bridge] ITypeInfo::GetIDsOfNames returned error ")
+ + OUString::valueOf((sal_Int32) hr, 16), Reference<XInterface>(), Any());
+ }
+ }
+
+ //Convert arguments
+ ptrArgs.reset(new CComVariant[dispparams.cArgs]);
+ ptrRefArgs.reset(new CComVariant[dispparams.cArgs]);
+ arArgs = ptrArgs.get();
+ arRefArgs = ptrRefArgs.get();
+ try
+ {
+ for (i = 0; i < (sal_Int32) dispparams.cArgs; i++)
+ {
+ revIndex= dispparams.cArgs - i -1;
+ arRefArgs[revIndex].byref=0;
+ Any anyArg;
+ if ( i < nUnoArgs)
+ anyArg= Params.getConstArray()[i];
+
+ //Test if the current parameter is a "vararg" parameter.
+ if (bVarargParam || (aFuncDesc->cParamsOpt == -1 &&
+ aFuncDesc->cParams == (i + 1)))
+ { //This parameter is from the variable argument list. There is no
+ //type info available, except that it must be a VARIANT
+ bVarargParam = true;
+ }
+
+ unsigned short paramFlags = PARAMFLAG_FOPT | PARAMFLAG_FIN;
+ VARTYPE varType = VT_VARIANT;
+ if ( ! bVarargParam)
+ {
+ paramFlags =
+ aFuncDesc->lprgelemdescParam[i].paramdesc.wParamFlags;
+ varType = getElementTypeDesc(
+ & aFuncDesc->lprgelemdescParam[i].tdesc);
+ }
+ //Make sure that there is a UNO parameter for every
+ // expected parameter. If there is no UNO parameter where the
+ // called function expects one, then it must be optional. Otherwise
+ // its a UNO programming error.
+ if (i >= nUnoArgs && !(paramFlags & PARAMFLAG_FOPT))
+ {
+ OUStringBuffer buf(256);
+ buf.appendAscii("ole automation bridge: The called function expects an argument at"
+ "position: "); //a different number of arguments")),
+ buf.append(OUString::valueOf((sal_Int32) i));
+ buf.appendAscii(" (index starting at 0).");
+ throw IllegalArgumentException( buf.makeStringAndClear(),
+ Reference<XInterface>(), (sal_Int16) i);
+ }
+ //make sure we get no void any for an in parameter. In StarBasic
+ //this may be caused by
+ // Dim arg
+ // obj.func(arg)
+ //A void any is allowed if the parameter is optional
+ if ( ! (aFuncDesc->lprgelemdescParam[i].paramdesc.wParamFlags & PARAMFLAG_FOPT)
+ && (i < nUnoArgs) && (paramFlags & PARAMFLAG_FIN) &&
+ Params.getConstArray()[i].getValueTypeClass() == TypeClass_VOID)
+ {
+ OUStringBuffer buf(256);
+ buf.appendAscii("ole automation bridge: The argument at position: ");
+ buf.append(OUString::valueOf((sal_Int32) i));
+ buf.appendAscii(" (index starts with 0) is uninitialized.");
+ throw IllegalArgumentException( buf.makeStringAndClear(),
+ Reference<XInterface>(), (sal_Int16) i);
+ }
+
+ // Property Put arguments
+ if (anyArg.getValueType() == getCppuType((PropertyPutArgument*)0))
+ {
+ PropertyPutArgument arg;
+ anyArg >>= arg;
+ anyArg <<= arg.Value;
+ }
+ // named argument
+ if (anyArg.getValueType() == getCppuType((NamedArgument*) 0))
+ {
+ NamedArgument aNamedArgument;
+ anyArg >>= aNamedArgument;
+ anyArg <<= aNamedArgument.Value;
+ }
+ // out param
+ if (paramFlags & PARAMFLAG_FOUT &&
+ ! (paramFlags & PARAMFLAG_FIN) )
+ {
+ VARTYPE type = ::sal::static_int_cast< VARTYPE, int >( varType ^ VT_BYREF );
+ if (i < nUnoArgs)
+ {
+ arRefArgs[revIndex].vt= type;
+ }
+ else
+ {
+ //optional arg
+ arRefArgs[revIndex].vt = VT_ERROR;
+ arRefArgs[revIndex].scode = DISP_E_PARAMNOTFOUND;
+ }
+ if( type == VT_VARIANT )
+ {
+ arArgs[revIndex].vt= VT_VARIANT | VT_BYREF;
+ arArgs[revIndex].byref= &arRefArgs[revIndex];
+ }
+ else
+ {
+ arArgs[revIndex].vt= varType;
+ if (type == VT_DECIMAL)
+ arArgs[revIndex].byref= & arRefArgs[revIndex].decVal;
+ else
+ arArgs[revIndex].byref= & arRefArgs[revIndex].byref;
+ }
+ }
+ // in/out + in byref params
+ else if (varType & VT_BYREF)
+ {
+ VARTYPE type = ::sal::static_int_cast< VARTYPE, int >( varType ^ VT_BYREF );
+ CComVariant var;
+
+ if (i < nUnoArgs && anyArg.getValueTypeClass() != TypeClass_VOID)
+ {
+ anyToVariant( & arRefArgs[revIndex], anyArg, type);
+ }
+ else if (paramFlags & PARAMFLAG_FHASDEFAULT)
+ {
+ //optional arg with default
+ VariantCopy( & arRefArgs[revIndex],
+ & aFuncDesc->lprgelemdescParam[i].paramdesc.
+ pparamdescex->varDefaultValue);
+ }
+ else
+ {
+ //optional arg
+ //e.g: call func(x) in basic : func() ' no arg supplied
+ OSL_ASSERT(paramFlags & PARAMFLAG_FOPT);
+ arRefArgs[revIndex].vt = VT_ERROR;
+ arRefArgs[revIndex].scode = DISP_E_PARAMNOTFOUND;
+ }
+
+ // Set the converted arguments in the array which will be
+ // DISPPARAMS::rgvarg
+ // byref arg VT_XXX |VT_BYREF
+ arArgs[revIndex].vt = varType;
+ if (revIndex == 0 && aFuncDesc->invkind == INVOKE_PROPERTYPUT)
+ {
+ arArgs[revIndex] = arRefArgs[revIndex];
+ }
+ else if (type == VT_DECIMAL)
+ {
+ arArgs[revIndex].byref= & arRefArgs[revIndex].decVal;
+ }
+ else if (type == VT_VARIANT)
+ {
+ if ( ! (paramFlags & PARAMFLAG_FOUT))
+ arArgs[revIndex] = arRefArgs[revIndex];
+ else
+ arArgs[revIndex].byref = & arRefArgs[revIndex];
+ }
+ else
+ {
+ arArgs[revIndex].byref = & arRefArgs[revIndex].byref;
+ arArgs[revIndex].vt = ::sal::static_int_cast< VARTYPE, int >( arRefArgs[revIndex].vt | VT_BYREF );
+ }
+
+ }
+ // in parameter no VT_BYREF except for array, interfaces
+ else
+ { // void any stands for optional param
+ if (i < nUnoArgs && anyArg.getValueTypeClass() != TypeClass_VOID)
+ {
+ anyToVariant( & arArgs[revIndex], anyArg, varType);
+ }
+ //optional arg but no void any supplied
+ //Basic: obj.func() ' first parameter left out because it is optional
+ else if (paramFlags & PARAMFLAG_FHASDEFAULT)
+ {
+ //optional arg with defaulteithter as direct arg : VT_XXX or
+ VariantCopy( & arArgs[revIndex],
+ & aFuncDesc->lprgelemdescParam[i].paramdesc.
+ pparamdescex->varDefaultValue);
+ }
+ else
+ {
+ OSL_ASSERT(paramFlags & PARAMFLAG_FOPT);
+ arArgs[revIndex].vt = VT_ERROR;
+ arArgs[revIndex].scode = DISP_E_PARAMNOTFOUND;
+ }
+ }
+ }
+ }
+ catch (IllegalArgumentException & e)
+ {
+ e.ArgumentPosition = ::sal::static_int_cast< sal_Int16, sal_Int32 >( i );
+ throw;
+ }
+ catch (CannotConvertException & e)
+ {
+ e.ArgumentIndex = i;
+ throw;
+ }
+ dispparams.rgvarg= arArgs;
+ // invoking OLE method
+ DWORD localeId = LOCALE_USER_DEFAULT;
+ result = m_spDispatch->Invoke(aFuncDesc->memid,
+ IID_NULL,
+ localeId,
+ ::sal::static_int_cast< WORD, INVOKEKIND >( aFuncDesc->invkind ),
+ &dispparams,
+ &varResult,
+ &excepinfo,
+ &uArgErr);
+
+ // converting return value and out parameter back to UNO
+ if (result == S_OK)
+ {
+
+ // allocate space for the out param Sequence and indices Sequence
+ int outParamsCount= 0; // includes in/out parameter
+ for (int i = 0; i < aFuncDesc->cParams; i++)
+ {
+ if (aFuncDesc->lprgelemdescParam[i].paramdesc.wParamFlags &
+ PARAMFLAG_FOUT)
+ outParamsCount++;
+ }
+
+ OutParamIndex.realloc(outParamsCount);
+ OutParam.realloc(outParamsCount);
+ // Convert out params
+ if (outParamsCount)
+ {
+ int outParamIndex=0;
+ for (int paramIndex = 0; paramIndex < nUnoArgs; paramIndex ++)
+ {
+ //Determine the index within the method sinature
+ int realParamIndex = paramIndex;
+ int revParamIndex = dispparams.cArgs - paramIndex - 1;
+ if (Params[paramIndex].getValueType()
+ == getCppuType((NamedArgument*) 0))
+ {
+ //dispparams.rgdispidNamedArgs contains the mapping from index
+ //of named args list to index of parameter list
+ realParamIndex = dispparams.rgdispidNamedArgs[revParamIndex];
+ }
+
+ // no named arg, always come before named args
+ if (! (aFuncDesc->lprgelemdescParam[realParamIndex].paramdesc.wParamFlags
+ & PARAMFLAG_FOUT))
+ continue;
+ Any outAny;
+ // variantToAny is called with the "reduce range" parameter set to sal_False.
+ // That causes VT_I4 values not to be converted down to a "lower" type. That
+ // feature exist for JScript only because it only uses VT_I4 for integer types.
+ try
+ {
+ variantToAny( & arRefArgs[revParamIndex], outAny, sal_False );
+ }
+ catch (IllegalArgumentException & e)
+ {
+ e.ArgumentPosition = (sal_Int16)paramIndex;
+ throw;
+ }
+ catch (CannotConvertException & e)
+ {
+ e.ArgumentIndex = paramIndex;
+ throw;
+ }
+ OutParam[outParamIndex] = outAny;
+ OutParamIndex[outParamIndex] = ::sal::static_int_cast< sal_Int16, int >( paramIndex );
+ outParamIndex++;
+ }
+ OutParam.realloc(outParamIndex);
+ OutParamIndex.realloc(outParamIndex);
+ }
+ // Return value
+ variantToAny(&varResult, ret, sal_False);
+ }
+
+ // map error codes to exceptions
+ OUString message;
+ switch (result)
+ {
+ case S_OK:
+ break;
+ case DISP_E_BADPARAMCOUNT:
+ throw IllegalArgumentException(OUSTR("[automation bridge] Wrong "
+ "number of arguments. Object returned DISP_E_BADPARAMCOUNT."),
+ 0, 0);
+ break;
+ case DISP_E_BADVARTYPE:
+ throw RuntimeException(OUSTR("[automation bridge] One or more "
+ "arguments have the wrong type. Object returned "
+ "DISP_E_BADVARTYPE."), 0);
+ break;
+ case DISP_E_EXCEPTION:
+ {
+ message = OUSTR("[automation bridge]: ");
+ message += OUString(reinterpret_cast<const sal_Unicode*>(excepinfo.bstrDescription),
+ ::SysStringLen(excepinfo.bstrDescription));
+
+ // Add for VBA, to throw an exception with the correct error code and message.
+ sal_Int32 nErrorCode = excepinfo.wCode;
+ if ( nErrorCode == 0 )
+ {
+ // The low 16-bit of scode describing the error or warning.
+ nErrorCode = ( excepinfo.scode & 0xFFFF );
+ }
+ BasicErrorException aBasicErrExp(message, Reference<XInterface>(), nErrorCode, message);
+ throw InvocationTargetException(message, Reference<XInterface>(), makeAny(aBasicErrExp));
+ // End add
+
+ break;
+ }
+ case DISP_E_MEMBERNOTFOUND:
+ message = OUSTR("[automation bridge]: A function with the name \"")
+ + sFuncName + OUSTR("\" is not supported. Object returned "
+ "DISP_E_MEMBERNOTFOUND.");
+ throw IllegalArgumentException(message, 0, 0);
+ break;
+ case DISP_E_NONAMEDARGS:
+ throw IllegalArgumentException(OUSTR("[automation bridge] Object "
+ "returned DISP_E_NONAMEDARGS"),0, ::sal::static_int_cast< sal_Int16, unsigned int >( uArgErr ));
+ break;
+ case DISP_E_OVERFLOW:
+ throw CannotConvertException(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("[automation bridge] Call failed.")),
+ static_cast<XInterface*>(
+ static_cast<XWeak*>(this)), TypeClass_UNKNOWN, FailReason::OUT_OF_RANGE, uArgErr);
+ break;
+ case DISP_E_PARAMNOTFOUND:
+ throw IllegalArgumentException(OUSTR("[automation bridge]Call failed."
+ "Object returned DISP_E_PARAMNOTFOUND."),
+ 0, ::sal::static_int_cast< sal_Int16, unsigned int >( uArgErr ));
+ break;
+ case DISP_E_TYPEMISMATCH:
+ throw CannotConvertException(OUSTR("[automation bridge] Call failed. "
+ "Object returned DISP_E_TYPEMISMATCH"),
+ static_cast<XInterface*>(
+ static_cast<XWeak*>(this)) , TypeClass_UNKNOWN, FailReason::UNKNOWN, uArgErr);
+ break;
+ case DISP_E_UNKNOWNINTERFACE:
+ throw RuntimeException(OUSTR("[automation bridge] Call failed. "
+ "Object returned DISP_E_UNKNOWNINTERFACE."),0);
+ break;
+ case DISP_E_UNKNOWNLCID:
+ throw RuntimeException(OUSTR("[automation bridge] Call failed. "
+ "Object returned DISP_E_UNKNOWNLCID."),0);
+ break;
+ case DISP_E_PARAMNOTOPTIONAL:
+ throw CannotConvertException(OUSTR("[automation bridge] Call failed."
+ "Object returned DISP_E_PARAMNOTOPTIONAL"),
+ static_cast<XInterface*>(static_cast<XWeak*>(this)),
+ TypeClass_UNKNOWN, FailReason::NO_DEFAULT_AVAILABLE, uArgErr);
+ break;
+ default:
+ throw RuntimeException();
+ break;
+ }
+
+ return ret;
+}
+
+void IUnknownWrapper_Impl::getFuncDescForInvoke(const OUString & sFuncName,
+ const Sequence<Any> & seqArgs,
+ FUNCDESC** pFuncDesc)
+{
+ int nUnoArgs = seqArgs.getLength();
+ const Any * arArgs = seqArgs.getConstArray();
+ ITypeInfo* pInfo = getTypeInfo();
+
+ //If the last of the positional arguments is a PropertyPutArgument
+ //then obtain the type info for the property put operation.
+
+ //The property value is always the last argument, in a positional argument list
+ //or in a list of named arguments. A PropertyPutArgument is actually a named argument
+ //hence it must not be put in an extra NamedArgument structure
+ if (nUnoArgs > 0 &&
+ arArgs[nUnoArgs - 1].getValueType() == getCppuType((PropertyPutArgument*) 0))
+ {
+ // DISPATCH_PROPERTYPUT
+ FuncDesc aDescGet(pInfo);
+ FuncDesc aDescPut(pInfo);
+ VarDesc aVarDesc(pInfo);
+ getPropDesc(sFuncName, & aDescGet, & aDescPut, & aVarDesc);
+ if ( ! aDescPut)
+ {
+ throw IllegalArgumentException(
+ OUSTR("[automation bridge] The object does not have a writeable property: ")
+ + sFuncName, Reference<XInterface>(), 0);
+ }
+ *pFuncDesc = aDescPut.Detach();
+ }
+ else
+ { // DISPATCH_METHOD
+ FuncDesc aFuncDesc(pInfo);
+ getFuncDesc(sFuncName, & aFuncDesc);
+ if ( ! aFuncDesc)
+ {
+ // Fallback: DISPATCH_PROPERTYGET can mostly be called as
+ // DISPATCH_METHOD
+ ITypeInfo * pInfo = getTypeInfo();
+ FuncDesc aDescPut(pInfo);
+ VarDesc aVarDesc(pInfo);
+ getPropDesc(sFuncName, & aFuncDesc, & aDescPut, & aVarDesc);
+ if ( ! aFuncDesc )
+ {
+ throw IllegalArgumentException(
+ OUSTR("[automation bridge] The object does not have a function"
+ "or readable property \"")
+ + sFuncName, Reference<XInterface>(), 0);
+ }
+ }
+ *pFuncDesc = aFuncDesc.Detach();
+ }
+}
+bool IUnknownWrapper_Impl::getDispid(const OUString& sFuncName, DISPID * id)
+{
+ OSL_ASSERT(m_spDispatch);
+ LPOLESTR lpsz = const_cast<LPOLESTR> (reinterpret_cast<LPCOLESTR>(sFuncName.getStr()));
+ HRESULT hr = m_spDispatch->GetIDsOfNames(IID_NULL, &lpsz, 1, LOCALE_USER_DEFAULT, id);
+ return hr == S_OK ? true : false;
+}
+void IUnknownWrapper_Impl::getFuncDesc(const OUString & sFuncName, FUNCDESC ** pFuncDesc)
+
+{
+ OSL_ASSERT( * pFuncDesc == 0);
+ buildComTlbIndex();
+ typedef TLBFuncIndexMap::const_iterator cit;
+ typedef TLBFuncIndexMap::iterator it;
+ //We assume there is only one entry with the function name. A property
+ //would have two entries.
+ cit itIndex= m_mapComFunc.find(sFuncName);
+ if (itIndex == m_mapComFunc.end())
+ {
+ //try case insensive with IDispatch::GetIDsOfNames
+ DISPID id;
+ if (getDispid(sFuncName, &id))
+ {
+ CComBSTR memberName;
+ unsigned int pcNames=0;
+ // get the case sensitive name
+ if( SUCCEEDED(getTypeInfo()->GetNames( id, & memberName, 1, &pcNames)))
+ {
+ //get the associated index and add an entry to the map
+ //with the name sFuncName which differs in the casing of the letters to
+ //the actual name as obtained from ITypeInfo
+ OUString sRealName(reinterpret_cast<const sal_Unicode*>(LPCOLESTR(memberName)));
+ cit itOrg = m_mapComFunc.find(sRealName);
+ OSL_ASSERT(itOrg != m_mapComFunc.end());
+ // maybe this is a property, if so we need
+ // to store either both id's ( put/get ) or
+ // just the get. Storing both is more consistent
+ pair<cit, cit> pItems = m_mapComFunc.equal_range( sRealName );
+ for ( ;pItems.first != pItems.second; ++pItems.first )
+ m_mapComFunc.insert( TLBFuncIndexMap::value_type ( make_pair(sFuncName, pItems.first->second ) ));
+ itIndex =
+ m_mapComFunc.find( sFuncName );
+ }
+ }
+ }
+
+#if OSL_DEBUG_LEVEL >= 1
+ // There must only be one entry if sFuncName represents a function or two
+ // if it is a property
+ pair<cit, cit> p = m_mapComFunc.equal_range(sFuncName.toAsciiLowerCase());
+ int numEntries = 0;
+ for ( ;p.first != p.second; p.first ++, numEntries ++);
+ OSL_ASSERT( ! (numEntries > 3) );
+#endif
+ if( itIndex != m_mapComFunc.end())
+ {
+ ITypeInfo* pType= getTypeInfo();
+ FUNCDESC * pDesc = NULL;
+ if (SUCCEEDED(pType->GetFuncDesc(itIndex->second, & pDesc)))
+ {
+ if (pDesc->invkind == INVOKE_FUNC)
+ {
+ (*pFuncDesc) = pDesc;
+ }
+ else
+ {
+ pType->ReleaseFuncDesc(pDesc);
+ }
+ }
+ else
+ {
+ throw BridgeRuntimeError(OUSTR("[automation bridge] Could not get "
+ "FUNCDESC for ") + sFuncName);
+ }
+ }
+ //else no entry found for sFuncName, pFuncDesc will not be filled in
+}
+
+void IUnknownWrapper_Impl::getPropDesc(const OUString & sFuncName, FUNCDESC ** pFuncDescGet,
+ FUNCDESC** pFuncDescPut, VARDESC** pVarDesc)
+{
+ OSL_ASSERT( * pFuncDescGet == 0 && * pFuncDescPut == 0);
+ buildComTlbIndex();
+ typedef TLBFuncIndexMap::const_iterator cit;
+ pair<cit, cit> p = m_mapComFunc.equal_range(sFuncName);
+ if (p.first == m_mapComFunc.end())
+ {
+ //try case insensive with IDispatch::GetIDsOfNames
+ DISPID id;
+ if (getDispid(sFuncName, &id))
+ {
+ CComBSTR memberName;
+ unsigned int pcNames=0;
+ // get the case sensitive name
+ if( SUCCEEDED(getTypeInfo()->GetNames( id, & memberName, 1, &pcNames)))
+ {
+ //As opposed to getFuncDesc, we do not add the value because we would
+ // need to find the get and set description for the property. This would
+ //mean to iterate over all FUNCDESCs again.
+ p = m_mapComFunc.equal_range(OUString(reinterpret_cast<const sal_Unicode*>(LPCOLESTR(memberName))));
+ }
+ }
+ }
+
+ for ( int i = 0 ;p.first != p.second; p.first ++, i ++)
+ {
+ // There are a maximum of two entries, property put and property get
+ OSL_ASSERT( ! (i > 2) );
+ ITypeInfo* pType= getTypeInfo();
+ FUNCDESC * pFuncDesc = NULL;
+ if (SUCCEEDED( pType->GetFuncDesc(p.first->second, & pFuncDesc)))
+ {
+ if (pFuncDesc->invkind == INVOKE_PROPERTYGET)
+ {
+ (*pFuncDescGet) = pFuncDesc;
+ }
+ else if (pFuncDesc->invkind == INVOKE_PROPERTYPUT ||
+ pFuncDesc->invkind == INVOKE_PROPERTYPUTREF)
+ {
+ //a property can have 3 entries, put, put ref, get
+ // If INVOKE_PROPERTYPUTREF or INVOKE_PROPERTYPUT is used
+ //depends on what is found first.
+ if ( * pFuncDescPut)
+ {
+ //we already have found one
+ pType->ReleaseFuncDesc(pFuncDesc);
+ }
+ else
+ {
+ (*pFuncDescPut) = pFuncDesc;
+ }
+ }
+ else
+ {
+ pType->ReleaseFuncDesc(pFuncDesc);
+ }
+ }
+ //ITypeInfo::GetFuncDesc may even provide a funcdesc for a VARDESC
+ // with invkind = INVOKE_FUNC. Since this function should only return
+ //a value for a real property (XInvokation::hasMethod, ..::hasProperty
+ //we need to make sure that sFuncName represents a real property.
+ VARDESC * pVD = NULL;
+ if (SUCCEEDED(pType->GetVarDesc(p.first->second, & pVD)))
+ (*pVarDesc) = pVD;
+ }
+ //else no entry for sFuncName, pFuncDesc will not be filled in
+}
+
+VARTYPE IUnknownWrapper_Impl::getUserDefinedElementType( ITypeInfo* pTypeInfo, const DWORD nHrefType )
+{
+ VARTYPE _type( VT_NULL );
+ if ( pTypeInfo )
+ {
+ CComPtr<ITypeInfo> spRefInfo;
+ pTypeInfo->GetRefTypeInfo( nHrefType, &spRefInfo.p );
+ if ( spRefInfo )
+ {
+ TypeAttr attr( spRefInfo );
+ spRefInfo->GetTypeAttr( &attr );
+ if ( attr->typekind == TKIND_ENUM )
+ {
+ // We use the type of the first enum value.
+ if ( attr->cVars == 0 )
+ {
+ throw BridgeRuntimeError(OUSTR("[automation bridge] Could not obtain type description"));
+ }
+ VarDesc var( spRefInfo );
+ spRefInfo->GetVarDesc( 0, &var );
+ _type = var->lpvarValue->vt;
+ }
+ else if ( attr->typekind == TKIND_INTERFACE )
+ {
+ _type = VT_UNKNOWN;
+ }
+ else if ( attr->typekind == TKIND_DISPATCH )
+ {
+ _type = VT_DISPATCH;
+ }
+ else if ( attr->typekind == TKIND_ALIAS )
+ {
+ // TKIND_ALIAS is a type that is an alias for another type. So get that alias type.
+ _type = getUserDefinedElementType( pTypeInfo, attr->tdescAlias.hreftype );
+ }
+ else
+ {
+ throw BridgeRuntimeError( OUSTR("[automation bridge] Unhandled user defined type.") );
+ }
+ }
+ }
+ return _type;
+}
+
+VARTYPE IUnknownWrapper_Impl::getElementTypeDesc(const TYPEDESC *desc)
+{
+ VARTYPE _type( VT_NULL );
+
+ if (desc->vt == VT_PTR)
+ {
+ _type = getElementTypeDesc(desc->lptdesc);
+ _type |= VT_BYREF;
+ }
+ else if (desc->vt == VT_SAFEARRAY)
+ {
+ _type = getElementTypeDesc(desc->lptdesc);
+ _type |= VT_ARRAY;
+ }
+ else if (desc->vt == VT_USERDEFINED)
+ {
+ ITypeInfo* thisInfo = getTypeInfo(); //kept by this instance
+ _type = getUserDefinedElementType( thisInfo, desc->hreftype );
+ }
+ else
+ {
+ _type = desc->vt;
+ }
+ return _type;
+}
+
+void IUnknownWrapper_Impl::buildComTlbIndex()
+{
+ if ( ! m_bComTlbIndexInit)
+ {
+ MutexGuard guard(getBridgeMutex());
+ {
+ if ( ! m_bComTlbIndexInit)
+ {
+ OUString sError;
+ ITypeInfo* pType= getTypeInfo();
+ TypeAttr typeAttr(pType);
+ if( SUCCEEDED( pType->GetTypeAttr( &typeAttr)))
+ {
+ for( long i= 0; i < typeAttr->cFuncs; i++)
+ {
+ FuncDesc funcDesc(pType);
+ if( SUCCEEDED( pType->GetFuncDesc( i, &funcDesc)))
+ {
+ CComBSTR memberName;
+ unsigned int pcNames=0;
+ if( SUCCEEDED(pType->GetNames( funcDesc->memid, & memberName, 1, &pcNames)))
+ {
+ OUString usName(reinterpret_cast<const sal_Unicode*>(LPCOLESTR(memberName)));
+ m_mapComFunc.insert( TLBFuncIndexMap::value_type( usName, i));
+ }
+ else
+ {
+ sError = OUSTR("[automation bridge] IUnknownWrapper_Impl::buildComTlbIndex, " \
+ "ITypeInfo::GetNames failed.");
+ }
+ }
+ else
+ sError = OUSTR("[automation bridge] IUnknownWrapper_Impl::buildComTlbIndex, " \
+ "ITypeInfo::GetFuncDesc failed.");
+ }
+
+ //If we create an Object in JScript and a a property then it
+ //has VARDESC instead of FUNCDESC
+ for (long i = 0; i < typeAttr->cVars; i++)
+ {
+ VarDesc varDesc(pType);
+ if (SUCCEEDED(pType->GetVarDesc(i, & varDesc)))
+ {
+ CComBSTR memberName;
+ unsigned int pcNames = 0;
+ if (SUCCEEDED(pType->GetNames(varDesc->memid, & memberName, 1, &pcNames)))
+ {
+ if (varDesc->varkind == VAR_DISPATCH)
+ {
+ OUString usName(reinterpret_cast<const sal_Unicode*>(LPCOLESTR(memberName)));
+ m_mapComFunc.insert(TLBFuncIndexMap::value_type(
+ usName, i));
+ }
+ }
+ else
+ {
+ sError = OUSTR("[automation bridge] IUnknownWrapper_Impl::buildComTlbIndex, " \
+ "ITypeInfo::GetNames failed.");
+ }
+ }
+ else
+ sError = OUSTR("[automation bridge] IUnknownWrapper_Impl::buildComTlbIndex, " \
+ "ITypeInfo::GetVarDesc failed.");
+
+ }
+ }
+ else
+ sError = OUSTR("[automation bridge] IUnknownWrapper_Impl::buildComTlbIndex, " \
+ "ITypeInfo::GetTypeAttr failed.");
+
+ if (sError.getLength())
+ {
+ throw BridgeRuntimeError(sError);
+ }
+
+ m_bComTlbIndexInit = true;
+ }
+ }
+ }
+}
+
+ITypeInfo* IUnknownWrapper_Impl::getTypeInfo()
+{
+ if( !m_spDispatch)
+ {
+ throw BridgeRuntimeError(OUSTR("The object has no IDispatch interface!"));
+ }
+
+ if( !m_spTypeInfo )
+ {
+ MutexGuard guard(getBridgeMutex());
+ if( ! m_spTypeInfo)
+ {
+ CComPtr< ITypeInfo > spType;
+ if( SUCCEEDED( m_spDispatch->GetTypeInfo( 0, LOCALE_USER_DEFAULT, &spType.p)))
+
+ {
+ OSL_DOUBLE_CHECKED_LOCKING_MEMORY_BARRIER();
+
+ //If this is a dual interface then TYPEATTR::typekind is usually TKIND_INTERFACE
+ //We need to get the type description for TKIND_DISPATCH
+ TypeAttr typeAttr(spType.p);
+ if( SUCCEEDED(spType->GetTypeAttr( &typeAttr)))
+ {
+ if (typeAttr->typekind == TKIND_INTERFACE &&
+ typeAttr->wTypeFlags & TYPEFLAG_FDUAL)
+ {
+ HREFTYPE refDispatch;
+ if (SUCCEEDED(spType->GetRefTypeOfImplType(::sal::static_int_cast< UINT, int >( -1 ), &refDispatch)))
+ {
+ CComPtr<ITypeInfo> spTypeDisp;
+ if (SUCCEEDED(spType->GetRefTypeInfo(refDispatch, & spTypeDisp)))
+ m_spTypeInfo= spTypeDisp;
+ }
+ else
+ {
+ throw BridgeRuntimeError(
+ OUSTR("[automation bridge] Could not obtain type information "
+ "for dispatch interface." ));
+ }
+ }
+ else if (typeAttr->typekind == TKIND_DISPATCH)
+ {
+ m_spTypeInfo= spType;
+ }
+ else
+ {
+ throw BridgeRuntimeError(
+ OUSTR("[automation bridge] Automation object does not "
+ "provide type information."));
+ }
+ }
+ }
+ else
+ {
+ throw BridgeRuntimeError(OUSTR("[automation bridge]The dispatch object does not "
+ "support ITypeInfo!"));
+ }
+ }
+ }
+ return m_spTypeInfo;
+}
+
+} // end namespace
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/ole/oleobjw.hxx b/extensions/source/ole/oleobjw.hxx
new file mode 100644
index 000000000000..0f926695eaab
--- /dev/null
+++ b/extensions/source/ole/oleobjw.hxx
@@ -0,0 +1,284 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef __OLEOBJW_HXX
+#define __OLEOBJW_HXX
+#include "ole2uno.hxx"
+
+#ifdef _MSC_VER
+#pragma warning (push,1)
+#pragma warning (disable:4548)
+#endif
+
+#include <tools/presys.h>
+#define _WIN32_WINNT 0x0403
+
+#if defined(_MSC_VER) && (_MSC_VER >= 1300)
+#undef _DEBUG
+#endif
+#include <atlbase.h>
+#include <vector>
+#include <hash_map>
+#include <tools/postsys.h>
+
+#ifdef _MSC_VER
+#pragma warning (pop)
+#endif
+#include <cppuhelper/implbase3.hxx>
+#include <cppuhelper/implbase4.hxx>
+#include <cppuhelper/implbase6.hxx>
+
+#include <com/sun/star/lang/XInitialization.hpp>
+#include <com/sun/star/bridge/oleautomation/XAutomationObject.hpp>
+#include <com/sun/star/script//XAutomationInvocation.hpp>
+#include <rtl/ustring.hxx>
+
+#include <com/sun/star/script/XDefaultProperty.hpp>
+#include <com/sun/star/script/XDefaultMethod.hpp>
+
+#include <typelib/typedescription.hxx>
+#include "unoconversionutilities.hxx"
+#include "windata.hxx"
+using namespace cppu;
+using namespace rtl;
+using namespace std;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::bridge;
+using namespace com::sun::star::bridge::oleautomation;
+
+namespace ole_adapter
+{
+
+
+
+typedef hash_map<OUString, pair<DISPID, unsigned short>, hashOUString_Impl, equalOUString_Impl> DispIdMap;
+
+typedef hash_multimap<OUString, unsigned int, hashOUString_Impl, equalOUString_Impl> TLBFuncIndexMap;
+
+// This class wraps an IDispatch and maps XInvocation calls to IDispatch calls on the wrapped object.
+// If m_TypeDescription is set then this class represents an UNO interface implemented in a COM component.
+// The interface is not a real interface in terms of an abstract class but is realized through IDispatch.
+class IUnknownWrapper_Impl : public WeakImplHelper6<XAutomationInvocation, XBridgeSupplier2, XInitialization, XAutomationObject, XDefaultProperty, XDefaultMethod>,
+
+ public UnoConversionUtilities<IUnknownWrapper_Impl>
+
+{
+public:
+ IUnknownWrapper_Impl(Reference<XMultiServiceFactory> &xFactory,
+ sal_uInt8 unoWrapperClass, sal_uInt8 comWrapperClass);
+
+ ~IUnknownWrapper_Impl();
+
+ //XInterface
+ Any SAL_CALL queryInterface(const Type& t)
+ throw (RuntimeException);
+
+ // XInvokation
+ virtual Reference< XIntrospectionAccess > SAL_CALL getIntrospection( )
+ throw(RuntimeException);
+ virtual Any SAL_CALL invoke( const OUString& aFunctionName,
+ const Sequence< Any >& aParams,
+ Sequence< sal_Int16 >& aOutParamIndex,
+ Sequence< Any >& aOutParam )
+ throw(IllegalArgumentException, CannotConvertException,
+ InvocationTargetException, RuntimeException);
+ virtual void SAL_CALL setValue( const OUString& aPropertyName,
+ const Any& aValue )
+ throw(UnknownPropertyException, CannotConvertException,
+ InvocationTargetException, RuntimeException);
+ virtual Any SAL_CALL getValue( const OUString& aPropertyName )
+ throw(UnknownPropertyException, RuntimeException);
+ virtual sal_Bool SAL_CALL hasMethod( const OUString& aName )
+ throw(RuntimeException);
+ virtual sal_Bool SAL_CALL hasProperty( const OUString& aName )
+ throw(RuntimeException);
+
+ // XBridgeSupplier2
+ // This interface is implemented to provide a safe way to obtain the original
+ // IUnknown or IDispatch within the function anyToVariant. The function asks
+ // every UNO object for its XBridgeSupplier2 and if it is available uses it to convert
+ // the object with its own supplier.
+ virtual Any SAL_CALL createBridge( const Any& modelDepObject,
+ const Sequence< sal_Int8 >& aProcessId,
+ sal_Int16 sourceModelType,
+ sal_Int16 destModelType )
+ throw(IllegalArgumentException, RuntimeException);
+
+ // XInitialization
+ virtual void SAL_CALL initialize( const Sequence< Any >& aArguments )
+ throw(Exception, RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getDefaultPropertyName( ) throw (::com::sun::star::uno::RuntimeException) { return m_sDefaultMember; }
+protected:
+ virtual ::rtl::OUString SAL_CALL getDefaultMethodName( ) throw (::com::sun::star::uno::RuntimeException) { return m_sDefaultMember; }
+
+ virtual ::com::sun::star::uno::Any SAL_CALL invokeGetProperty( const ::rtl::OUString& aFunctionName, const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aParams, ::com::sun::star::uno::Sequence< ::sal_Int16 >& aOutParamIndex, ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aOutParam ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::script::CannotConvertException, ::com::sun::star::reflection::InvocationTargetException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Any SAL_CALL invokePutProperty( const ::rtl::OUString& aFunctionName, const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aParams, ::com::sun::star::uno::Sequence< ::sal_Int16 >& aOutParamIndex, ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aOutParam ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::script::CannotConvertException, ::com::sun::star::reflection::InvocationTargetException, ::com::sun::star::uno::RuntimeException);
+
+ // ----------------------------------------------------------------------------
+ virtual Any invokeWithDispIdUnoTlb(const OUString& sFunctionName,
+ const Sequence< Any >& Params,
+ Sequence<sal_Int16 >& OutParamIndex,
+ Sequence< Any >& OutParam);
+ // Is used for OleObjectFactory service
+ virtual Any invokeWithDispIdComTlb(const OUString& sFuncName,
+ const Sequence< Any >& Params,
+ Sequence< sal_Int16 >& OutParamIndex,
+ Sequence< Any >& OutParam);
+
+ Any IUnknownWrapper_Impl::invokeWithDispIdComTlb(FuncDesc& aFuncDesc,
+ const OUString& sFuncName,
+ const Sequence< Any >& Params,
+ Sequence< sal_Int16 >& OutParamIndex,
+ Sequence< Any >& OutParam);
+
+// virtual void setValueWithDispId(DISPID dispID, const Any& Value);
+
+// virtual Any getValueWithDispId(const OUString& sName, DISPID dispID);
+
+
+ // UnoConversionUtilities -------------------------------------------------------------------------------
+ virtual Reference<XInterface> createUnoWrapperInstance();
+ virtual Reference<XInterface> createComWrapperInstance();
+
+ /**Obtains a FUNCDESC structure for a function.
+ Fills the FUNCDESC structure if ITypeInfo provides information for
+ the function of name sFuncName or pFuncDesc will not be filled in.
+ May throw a BridgeRuntimeError.
+ */
+ void getFuncDesc(const OUString & sFuncName, FUNCDESC ** pFuncDesc);
+ /**Obtains a FUNCDESC structures or a VARDESC structure
+ for a property. pFuncDescPut may also contain
+ a structure for a "propertyputref" operation. If pFuncDesc contains a
+ "put ref" or "put" FUNCDESC depends on what was found first in the type
+ description.
+ Fills the FUNCDESC structure if ITypeInfo provides information for
+ the respective property functions or the structures will not be filled in.
+ May throw a BridgeRuntimeError.
+ */
+ void getPropDesc(const OUString & sFuncName, FUNCDESC ** pFuncDescGet,
+ FUNCDESC** pFuncDescPut, VARDESC ** pVarDesc);
+ // These functions are for the case if an object of this class wraps an IDispatch
+ // object that implements UNO interfaces. In that case the member m_seqTypes
+ // is set through XInitialization::initialize.
+ void getMethodInfo(const OUString& sName, TypeDescription& methodDescription);
+ // After return attributInfo contains typelib_InterfaceAttributeTypeDescription::pAttributeTypeRef
+ void getAttributeInfo(const OUString& sName, TypeDescription& attributeInfo);
+ // used by get MethodInfo
+ TypeDescription getInterfaceMemberDescOfCurrentCall(const OUString& sName);
+ /** Returns alway a valid ITypeInfo interface or throws a BridgeRuntimeError.
+ The returned interface does not need to be AddRef'ed as long as it is locally
+ used. The interface is kept in the instance of this class.
+ */
+ ITypeInfo* getTypeInfo();
+
+ /** Returns the DISPID for a function or property name. If true is returned then
+ id contains a valid DISPID.
+ */
+
+ bool getDispid(const OUString& sFuncName, DISPID * id);
+
+ VARTYPE getUserDefinedElementType( ITypeInfo* pTypeInfo, const DWORD nHrefType );
+
+ /** Gets the element type in a VARIANT like style. E.g. if desc->lptdesc contains
+ a VT_PTR than it is replaced by VT_BYREF and VT_SAFEARRAY is replaced by VT_ARRAY
+ If the TYPEDESC describes an SAFEARRAY then varType is a combination of VT_ARRAY
+ and the element type.
+ The argument desc must be obtained from FUNCDESC::lprgelemdescParam[i].tdesc where
+ FUNCDESC was obtained from the ITypeInfo belonging to wrapped IDispatch.
+ */
+ VARTYPE getElementTypeDesc( const TYPEDESC *desc);
+ /** Iterates over all functions and put the names and indices into the map
+ m_mapComFunc of type TLBFuncIndexMap.
+ Call the function every time before accessing the map.
+ Throws a BridgeRuntimeError on failure.
+ */
+ void buildComTlbIndex();
+
+ /** Returns a FUNCDESC structure which contains type information about the
+ current XInvocation::invoke call. The FUNCDESC either describes a method,
+ a property put or a property get operation.
+ It uses the types com.sun.star.bridge.oleautomation.PropertyPutArgument
+ which can be
+ contained in the sequence of in-arguments of invoke to determine if the call is
+ a property put or property get operation.
+ If no adequate FUNCDESC was found, an IllegalArgumentException is thrown.
+ Therefore it is safe to assume that the returned FUNCDESC* is not NULL.
+
+ @exception IllegalArgumentException
+ Thrown if no adequate FUNCDESC could be found.
+ */
+ void getFuncDescForInvoke(const OUString & sFuncName,
+ const Sequence<Any> & seqArgs, FUNCDESC** pFuncDesc);
+
+ // Finds out wheter the wrapped IDispatch is an JScript Object. This is is
+ // done by
+ // asking for the property "_environment". If it has the value "JScript"
+ // (case insensitive) then the IDispatch is considered a JScript object.
+ sal_Bool isJScriptObject();
+ // -------------------------------------------------------------------------------
+
+ // If UNO interfaces are implemented in JScript objects, VB or C++ COM objects
+ // and those are passed as parameter to a UNO interface function, then
+ // the IDispatch* are wrapped by objects of this class. Assuming that the functions
+ // implemented by the IDispatch object returns another UNO interface then
+ // it has to be wrapped to this type. But this is only possible if an object of this
+ // wrapper class knows what type it is represting. The member m_TypeDescription holds this
+ // information.
+ // m_TypeDescription is only useful when an object wraps an IDispatch object that implements
+ // an UNO interface. The value is set during a call to XInitialization::initialize.
+ Sequence<Type> m_seqTypes;
+ CComPtr<IUnknown> m_spUnknown;
+ CComPtr<IDispatch> m_spDispatch;
+ rtl::OUString m_sTypeName; // is "" ( not initialised ), "IDispatch" ( we have no idea ) or "SomeLibrary.SomeTypeName" if we managed to get a type
+ /** This value is set dureing XInitialization::initialize. It indicates that the COM interface
+ was transported as VT_DISPATCH in a VARIANT rather then a VT_UNKNOWN
+ */
+ sal_Bool m_bOriginalDispatch;
+ DispIdMap m_dispIdMap;
+ Reference<XIdlClass>* m_pxIdlClass;
+
+
+ // used by isJScriptObject
+ enum JScriptDetermination{ JScriptUndefined=0, NoJScript, IsJScript};
+ JScriptDetermination m_eJScript;
+ // The map is filled by buildComTlbIndex
+ // It maps Uno Function names to an index which is used in ITypeInfo::GetFuncDesc
+ TLBFuncIndexMap m_mapComFunc;
+ // used for synchroizing the computation of the content for m_mapComFunc
+ bool m_bComTlbIndexInit;
+ // Keeps the ITypeInfo obtained from IDispatch::GetTypeInfo
+ CComPtr< ITypeInfo > m_spTypeInfo;
+ rtl::OUString m_sDefaultMember;
+ bool m_bHasDfltMethod;
+ bool m_bHasDfltProperty;
+};
+
+} // end namespace
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/ole/olethread.cxx b/extensions/source/ole/olethread.cxx
new file mode 100644
index 000000000000..bd6f5fbceeec
--- /dev/null
+++ b/extensions/source/ole/olethread.cxx
@@ -0,0 +1,79 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+#if defined _MSC_VER && ( _MSC_VER >= 1200 )
+#define _WIN32_WINNT 0x0400
+#endif
+
+#include "ole2uno.hxx"
+
+#include <tools/presys.h>
+#include <tools/postsys.h>
+
+#include <osl/thread.hxx>
+
+using namespace std;
+
+namespace ole_adapter
+{
+// CoInitializeEx *
+typedef DECLSPEC_IMPORT HRESULT (STDAPICALLTYPE *ptrCoInitEx)( LPVOID, DWORD);
+// CoInitialize *
+typedef DECLSPEC_IMPORT HRESULT (STDAPICALLTYPE *ptrCoInit)( LPVOID);
+
+void o2u_attachCurrentThread()
+{
+ static osl::ThreadData oleThreadData;
+
+ if ((sal_Bool)(sal_IntPtr)oleThreadData.getData() != sal_True)
+ {
+ HINSTANCE inst= LoadLibrary( _T("ole32.dll"));
+ if( inst )
+ {
+ HRESULT hr;
+ // Try DCOM
+ ptrCoInitEx initFuncEx= (ptrCoInitEx)GetProcAddress( inst, _T("CoInitializeEx"));
+ if( initFuncEx)
+ hr= initFuncEx( NULL, COINIT_MULTITHREADED);
+ // No DCOM, try COM
+ else
+ {
+ ptrCoInit initFunc= (ptrCoInit)GetProcAddress( inst,_T("CoInitialize"));
+ if( initFunc)
+ hr= initFunc( NULL);
+ }
+ }
+ oleThreadData.setData((void*)sal_True);
+ }
+}
+
+} // end namespace
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/ole/servprov.cxx b/extensions/source/ole/servprov.cxx
new file mode 100644
index 000000000000..ecf45a4ce074
--- /dev/null
+++ b/extensions/source/ole/servprov.cxx
@@ -0,0 +1,757 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+
+#ifdef __MINGW32__
+#define INITGUID
+#include <initguid.h>
+#else
+#include "ole2uno.hxx"
+#include "unoconversionutilities.hxx"
+#endif
+#include "servprov.hxx"
+#include "unoobjw.hxx"
+#include "oleobjw.hxx"
+#include <rtl/unload.h>
+
+#include <tools/presys.h>
+#define _WIN32_WINNT 0x0403
+
+#if defined(_MSC_VER) && (_MSC_VER >= 1300)
+#undef _DEBUG
+#endif
+#include <atlbase.h>
+extern CComModule _Module;
+#include <atlcom.h>
+#include <tools/postsys.h>
+
+
+using namespace std;
+using namespace cppu;
+using namespace rtl;
+using namespace osl;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::uno;
+using namespace com::sun::star::bridge;
+using namespace com::sun::star::bridge::ModelDependent;
+
+
+
+namespace ole_adapter
+{
+
+#include <initguid.h>
+// prior 5.2 ( src569 ver m)
+// {3ECF78F0-B149-11D2-8EBE-00105AD848AF}
+//DEFINE_GUID(OID_ServiceManager, 0x3ECF78F0, 0xB149, 0x11d2, 0x8E, 0xBE, 0x00, 0x10, 0x5A, 0xD8, 0x48, 0xAF);
+
+#ifndef OWNGUID
+// GUID used since 5.2 ( src569 m)
+// {82154420-0FBF-11d4-8313-005004526AB4}
+DEFINE_GUID(OID_ServiceManager, 0x82154420, 0xfbf, 0x11d4, 0x83, 0x13, 0x0, 0x50, 0x4, 0x52, 0x6a, 0xb4);
+#else
+// Alternative GUID
+// {D9BB9D1D-BFA9-4357-9F11-9A2E9061F06E}
+DEFINE_GUID(OID_ServiceManager, 0xd9bb9d1d, 0xbfa9, 0x4357, 0x9f, 0x11, 0x9a, 0x2e, 0x90, 0x61, 0xf0, 0x6e);
+#endif
+
+extern rtl_StandardModuleCount globalModuleCount;
+
+/*****************************************************************************
+
+ class implementation ProviderOleWrapper_Impl
+
+*****************************************************************************/
+
+ProviderOleWrapper_Impl::ProviderOleWrapper_Impl(const Reference<XMultiServiceFactory>& smgr,
+ const Reference<XSingleServiceFactory>& xSFact, GUID* pGuid)
+ : m_xSingleServiceFactory(xSFact),
+ m_smgr( smgr)
+{
+ m_guid = *pGuid;
+
+ Reference<XInterface> xInt = smgr->createInstance(reinterpret_cast<const sal_Unicode*>(L"com.sun.star.bridge.oleautomation.BridgeSupplier"));
+
+ if (xInt.is())
+ {
+ Any a= xInt->queryInterface( ::getCppuType( reinterpret_cast<
+ Reference< XBridgeSupplier2>* >(0)));
+ a >>= m_bridgeSupplier;
+
+ }
+}
+
+ProviderOleWrapper_Impl::~ProviderOleWrapper_Impl()
+{
+}
+
+sal_Bool ProviderOleWrapper_Impl::registerClass()
+{
+ HRESULT hresult;
+
+ o2u_attachCurrentThread();
+
+ hresult = CoRegisterClassObject(
+ m_guid,
+ this,
+ CLSCTX_INPROC_SERVER | CLSCTX_LOCAL_SERVER,
+ REGCLS_MULTIPLEUSE,
+ &m_factoryHandle);
+
+ return (hresult == NOERROR);
+}
+
+sal_Bool ProviderOleWrapper_Impl::deregisterClass()
+{
+ HRESULT hresult = CoRevokeClassObject(m_factoryHandle);
+
+ return (hresult == NOERROR);
+}
+
+STDMETHODIMP ProviderOleWrapper_Impl::QueryInterface(REFIID riid, void FAR* FAR* ppv)
+{
+ if(IsEqualIID(riid, IID_IUnknown))
+ {
+ AddRef();
+ *ppv = (IUnknown*) (IClassFactory*) this;
+ return NOERROR;
+ }
+ else if (IsEqualIID(riid, IID_IClassFactory))
+ {
+ AddRef();
+ *ppv = (IClassFactory*) this;
+ return NOERROR;
+ }
+
+ *ppv = NULL;
+ return ResultFromScode(E_NOINTERFACE);
+}
+
+STDMETHODIMP_(ULONG) ProviderOleWrapper_Impl::AddRef()
+{
+ return osl_incrementInterlockedCount( &m_refCount);
+}
+
+STDMETHODIMP_(ULONG) ProviderOleWrapper_Impl::Release()
+{
+ MutexGuard aGuard( Mutex::getGlobalMutex());
+ ULONG refCount = --m_refCount;
+ if (m_refCount == 0)
+ {
+ delete this;
+ }
+
+ return refCount;
+}
+
+STDMETHODIMP ProviderOleWrapper_Impl::CreateInstance(IUnknown FAR* punkOuter,
+ REFIID riid,
+ void FAR* FAR* ppv)
+{
+ HRESULT ret = ResultFromScode(E_UNEXPECTED);
+ punkOuter = NULL;
+
+ Reference<XInterface> xInstance;
+
+ if (m_xSingleServiceFactory.is())
+ {
+ xInstance = m_xSingleServiceFactory->createInstance();
+
+ if (xInstance.is())
+ {
+ Any usrAny(&xInstance, getCppuType( & xInstance));
+
+ sal_uInt8 arId[16];
+ rtl_getGlobalProcessId( arId );
+ Any oleAny = m_bridgeSupplier->createBridge(usrAny,
+ Sequence<sal_Int8>((sal_Int8*)arId, 16),
+ UNO,
+ OLE);
+
+
+ if (oleAny.getValueTypeClass() == getCppuType( (sal_uInt32 *)0).getTypeClass())
+ {
+ VARIANT* pVariant = *(VARIANT**)oleAny.getValue();
+
+ if (pVariant->vt == VT_DISPATCH)
+ {
+ ret = pVariant->pdispVal->QueryInterface(riid, ppv);
+ }
+
+ VariantClear(pVariant);
+ CoTaskMemFree(pVariant);
+ }
+ }
+ }
+
+ return ret;
+}
+
+STDMETHODIMP ProviderOleWrapper_Impl::LockServer(int /*fLock*/)
+{
+ return NOERROR;
+}
+
+/*****************************************************************************
+
+ class implementation OneInstanceOleWrapper_Impl
+
+*****************************************************************************/
+
+OneInstanceOleWrapper_Impl::OneInstanceOleWrapper_Impl( const Reference<XMultiServiceFactory>& smgr,
+ const Reference<XInterface>& xInst,
+ GUID* pGuid,
+ sal_Bool bAsApplication )
+ : m_xInst(xInst), m_refCount(0),
+ m_smgr( smgr),
+ m_factoryHandle( 0 ),
+ m_bAsApplication( bAsApplication ),
+ m_nApplRegHandle( 0 )
+{
+ m_guid = *pGuid;
+
+ Reference<XInterface> xInt = m_smgr->createInstance(reinterpret_cast<const sal_Unicode*>(L"com.sun.star.bridge.oleautomation.BridgeSupplier"));
+
+ if (xInt.is())
+ {
+ Any a= xInt->queryInterface( getCppuType(
+ reinterpret_cast< Reference<XBridgeSupplier2>*>(0)));
+ a >>= m_bridgeSupplier;
+ }
+}
+
+OneInstanceOleWrapper_Impl::~OneInstanceOleWrapper_Impl()
+{
+}
+
+sal_Bool OneInstanceOleWrapper_Impl::registerClass()
+{
+ HRESULT hresult;
+
+ o2u_attachCurrentThread();
+
+ hresult = CoRegisterClassObject(
+ m_guid,
+ this,
+ CLSCTX_INPROC_SERVER | CLSCTX_LOCAL_SERVER,
+ REGCLS_MULTIPLEUSE,
+ &m_factoryHandle);
+
+ if ( hresult == NOERROR && m_bAsApplication )
+ hresult = RegisterActiveObject( this, m_guid, ACTIVEOBJECT_WEAK, &m_nApplRegHandle );
+
+ return (hresult == NOERROR);
+}
+
+sal_Bool OneInstanceOleWrapper_Impl::deregisterClass()
+{
+ HRESULT hresult1 = NOERROR;
+ if ( m_bAsApplication )
+ hresult1 = RevokeActiveObject( m_nApplRegHandle, NULL );
+
+ HRESULT hresult2 = CoRevokeClassObject(m_factoryHandle);
+
+ return (hresult1 == NOERROR && hresult2 == NOERROR);
+}
+
+STDMETHODIMP OneInstanceOleWrapper_Impl::QueryInterface(REFIID riid, void FAR* FAR* ppv)
+{
+ if(IsEqualIID(riid, IID_IUnknown))
+ {
+ AddRef();
+ *ppv = (IUnknown*) (IClassFactory*) this;
+ return NOERROR;
+ }
+ else if (IsEqualIID(riid, IID_IClassFactory))
+ {
+ AddRef();
+ *ppv = (IClassFactory*) this;
+ return NOERROR;
+ }
+
+ *ppv = NULL;
+ return ResultFromScode(E_NOINTERFACE);
+}
+
+STDMETHODIMP_(ULONG) OneInstanceOleWrapper_Impl::AddRef()
+{
+ return osl_incrementInterlockedCount( &m_refCount);
+}
+
+STDMETHODIMP_(ULONG) OneInstanceOleWrapper_Impl::Release()
+{
+ MutexGuard oGuard( Mutex::getGlobalMutex());
+ ULONG refCount = --m_refCount;
+ if ( m_refCount == 0)
+ {
+ delete this;
+ }
+
+ return refCount;
+}
+
+STDMETHODIMP OneInstanceOleWrapper_Impl::CreateInstance(IUnknown FAR* punkOuter,
+ REFIID riid,
+ void FAR* FAR* ppv)
+{
+ HRESULT ret = ResultFromScode(E_UNEXPECTED);
+ punkOuter = NULL;
+
+ if (m_xInst.is())
+ {
+ Any usrAny(&m_xInst, getCppuType( &m_xInst));
+ sal_uInt8 arId[16];
+ rtl_getGlobalProcessId( arId);
+ Any oleAny = m_bridgeSupplier->createBridge(usrAny,
+ Sequence<sal_Int8>( (sal_Int8*)arId, 16),
+ UNO,
+ OLE);
+
+
+ if (oleAny.getValueTypeClass() == TypeClass_UNSIGNED_LONG)
+ {
+ VARIANT* pVariant = *(VARIANT**)oleAny.getValue();
+
+ if ((pVariant->vt == VT_UNKNOWN) || (pVariant->vt == VT_DISPATCH))
+ {
+ ret = pVariant->punkVal->QueryInterface(riid, ppv);
+ }
+
+ VariantClear(pVariant);
+ CoTaskMemFree(pVariant);
+ }
+ }
+
+ return ret;
+}
+
+STDMETHODIMP OneInstanceOleWrapper_Impl::LockServer(int /*fLock*/)
+{
+ return NOERROR;
+}
+
+
+/*****************************************************************************
+
+ class implementation OleConverter_Impl2
+
+*****************************************************************************/
+
+OleConverter_Impl2::OleConverter_Impl2( const Reference<XMultiServiceFactory> &smgr):
+ UnoConversionUtilities<OleConverter_Impl2>( smgr)
+
+{
+ // library unloading support
+ globalModuleCount.modCnt.acquire( &globalModuleCount.modCnt);
+}
+
+// The XMultiServiceFactory is later set by XInitialization
+OleConverter_Impl2::OleConverter_Impl2( const Reference<XMultiServiceFactory>& smgr, sal_uInt8 unoWrapperClass, sal_uInt8 comWrapperClass ):
+ UnoConversionUtilities<OleConverter_Impl2>( smgr, unoWrapperClass, comWrapperClass )
+
+{
+ //library unloading support
+ globalModuleCount.modCnt.acquire( &globalModuleCount.modCnt);
+}
+
+OleConverter_Impl2::~OleConverter_Impl2()
+{
+ globalModuleCount.modCnt.release( &globalModuleCount.modCnt);
+}
+
+// XBridgeSupplier --------------------------------------------------------------
+Any SAL_CALL OleConverter_Impl2::createBridge(const Any& modelDepObject,
+ const Sequence< sal_Int8 >& ProcessId,
+ sal_Int16 sourceModelType,
+ sal_Int16 destModelType)
+ throw (IllegalArgumentException,
+ RuntimeException )
+{
+ Any ret;
+ sal_uInt8 arId[16];
+ rtl_getGlobalProcessId( arId );
+
+ Sequence< sal_Int8 > seqProcessId( (sal_Int8*)arId, 16);
+
+ if ( seqProcessId == ProcessId)
+ {
+ if (sourceModelType == UNO)
+ {
+ if (destModelType == UNO)
+ {
+ // same model -> copy value only
+ ret = modelDepObject;
+ }
+ else if (destModelType == OLE)
+ {
+ // convert UNO any into variant
+ VARIANT* pVariant = (VARIANT*) CoTaskMemAlloc(sizeof(VARIANT));
+ VariantInit( pVariant);
+ try
+ {
+ anyToVariant( pVariant, modelDepObject);
+ }
+ catch(...)
+ {
+ CoTaskMemFree(pVariant);
+ throw IllegalArgumentException();
+ }
+ ret.setValue((void*) &pVariant, getCppuType((sal_uInt32*)0));
+ }
+ else
+ throw IllegalArgumentException();
+ }
+ else if (sourceModelType == OLE)
+ {
+ if (modelDepObject.getValueType() != getCppuType((sal_uInt32*)0))
+ {
+ throw IllegalArgumentException();
+ }
+ else if (destModelType == OLE)
+ {
+ // same model -> copy value only
+ VARIANT* pVariant = (VARIANT*) CoTaskMemAlloc(sizeof(VARIANT));
+
+ if (NOERROR != VariantCopy(pVariant, *(VARIANT**)modelDepObject.getValue()))
+ {
+ CoTaskMemFree(pVariant);
+ throw(IllegalArgumentException());
+ }
+ else
+ {
+ ret.setValue((void*) &pVariant, getCppuType((sal_uInt32*)0));
+ }
+ }
+ else if (destModelType == UNO)
+ {
+ // convert variant into UNO any
+ VARIANT* pVariant = *(VARIANT**)modelDepObject.getValue();
+ try
+ {
+ variantToAny(pVariant, ret);
+ }
+ catch (CannotConvertException & e)
+ {
+ throw IllegalArgumentException(
+ e.Message, 0, -1);
+ }
+ }
+ else
+ throw IllegalArgumentException();
+
+ }
+ else
+ throw IllegalArgumentException();
+ }
+
+ return ret;
+}
+
+
+// XInitialize ------------------------------------------------------------------------------
+// the first argument is an XMultiServiceFactory if at all
+void SAL_CALL OleConverter_Impl2::initialize( const Sequence< Any >& aArguments )
+ throw(Exception, RuntimeException)
+{
+ if( aArguments.getLength() == 1 && aArguments[0].getValueTypeClass() == TypeClass_INTERFACE)
+ {
+ Reference < XInterface > xInt;
+ aArguments[0] >>= xInt;
+ Reference <XMultiServiceFactory> xMulti( xInt, UNO_QUERY);
+ m_smgrRemote= xMulti;
+ }
+}
+
+// UnoConversionUtilities -------------------------------------------------------------------
+Reference< XInterface > OleConverter_Impl2::createUnoWrapperInstance()
+{
+ if( m_nUnoWrapperClass == INTERFACE_OLE_WRAPPER_IMPL)
+ {
+ Reference<XWeak> xWeak= static_cast<XWeak*>( new InterfaceOleWrapper_Impl(
+ m_smgr, m_nUnoWrapperClass, m_nComWrapperClass));
+ return Reference<XInterface>( xWeak, UNO_QUERY);
+ }
+ else if( m_nUnoWrapperClass == UNO_OBJECT_WRAPPER_REMOTE_OPT)
+ {
+ Reference<XWeak> xWeak= static_cast<XWeak*>( new UnoObjectWrapperRemoteOpt(
+ m_smgr, m_nUnoWrapperClass, m_nComWrapperClass));
+ return Reference<XInterface>( xWeak, UNO_QUERY);
+ }
+ else
+ return Reference<XInterface>();
+}
+
+Reference< XInterface > OleConverter_Impl2::createComWrapperInstance()
+{
+ Reference<XWeak> xWeak= static_cast<XWeak*>( new IUnknownWrapper_Impl(
+ m_smgr, m_nUnoWrapperClass, m_nComWrapperClass));
+ return Reference<XInterface>( xWeak, UNO_QUERY);
+}
+
+
+
+/*****************************************************************************
+
+ class implementation OleClient_Impl
+
+*****************************************************************************/
+
+OleClient_Impl::OleClient_Impl( const Reference<XMultiServiceFactory>& smgr):
+ UnoConversionUtilities<OleClient_Impl>( smgr)
+{
+ // library unloading support
+ globalModuleCount.modCnt.acquire( &globalModuleCount.modCnt);
+ Reference<XInterface> xInt;// = m_smgr->createInstance(L"com.sun.star.bridge.OleBridgeSupplier2");
+
+ if (xInt.is())
+ {
+ Any a= xInt->queryInterface(getCppuType(
+ reinterpret_cast<Reference<XBridgeSupplier2>*>(0)));
+ a >>= m_bridgeSupplier;
+ }
+}
+
+OleClient_Impl::~OleClient_Impl()
+{
+ // library unloading support
+ globalModuleCount.modCnt.release( &globalModuleCount.modCnt);
+}
+
+Sequence< OUString > SAL_CALL OleClient_Impl::getAvailableServiceNames() throw( RuntimeException )
+{
+ Sequence< OUString > ret;
+
+ return ret;
+}
+
+
+OUString OleClient_Impl::getImplementationName()
+{
+ return OUString(reinterpret_cast<const sal_Unicode*>(L"com.sun.star.comp.ole.OleClient"));
+}
+
+Reference<XInterface> SAL_CALL OleClient_Impl::createInstance(const OUString& ServiceSpecifier) throw (Exception, RuntimeException )
+{
+ Reference<XInterface> ret;
+ HRESULT result;
+ IUnknown* pUnknown = NULL;
+ CLSID classId;
+
+ o2u_attachCurrentThread();
+
+ result = CLSIDFromProgID(
+ reinterpret_cast<LPCWSTR>(ServiceSpecifier.getStr()), //Pointer to the ProgID
+ &classId); //Pointer to the CLSID
+
+
+ if (result == NOERROR)
+ {
+ result = CoCreateInstance(
+ classId, //Class identifier (CLSID) of the object
+ NULL, //Pointer to whether object is or isn't part of an aggregate
+ CLSCTX_SERVER, //Context for running executable code
+ IID_IUnknown, //Reference to the identifier of the interface
+ (void**)&pUnknown); //Address of output variable that receives
+ // the interface pointer requested in riid
+ }
+
+ if (pUnknown != NULL)
+ {
+ Any any;
+ CComVariant variant;
+
+ V_VT(&variant) = VT_UNKNOWN;
+ V_UNKNOWN(&variant) = pUnknown;
+ // AddRef for Variant
+ pUnknown->AddRef();
+
+ // When the object is wrapped, then its refcount is increased
+ variantToAny(&variant, any);
+ if (any.getValueTypeClass() == TypeClass_INTERFACE)
+ {
+ any >>= ret;
+ }
+ pUnknown->Release(); // CoCreateInstance
+ }
+
+ return ret;
+}
+
+Reference<XInterface> SAL_CALL OleClient_Impl::createInstanceWithArguments(const OUString& ServiceSpecifier, const Sequence< Any >& /*Arguments*/) throw (Exception, RuntimeException)
+{
+ return createInstance( ServiceSpecifier);
+}
+
+// UnoConversionUtilities -----------------------------------------------------------------------------
+Reference< XInterface > OleClient_Impl::createUnoWrapperInstance()
+{
+ if( m_nUnoWrapperClass == INTERFACE_OLE_WRAPPER_IMPL)
+ {
+ Reference<XWeak> xWeak= static_cast<XWeak*>( new InterfaceOleWrapper_Impl(
+ m_smgr, m_nUnoWrapperClass, m_nComWrapperClass));
+ return Reference<XInterface>( xWeak, UNO_QUERY);
+ }
+ else if( m_nUnoWrapperClass == UNO_OBJECT_WRAPPER_REMOTE_OPT)
+ {
+ Reference<XWeak> xWeak= static_cast<XWeak*>( new UnoObjectWrapperRemoteOpt(
+ m_smgr, m_nUnoWrapperClass, m_nComWrapperClass));
+ return Reference<XInterface>( xWeak, UNO_QUERY);
+ }
+ else
+ return Reference< XInterface>();
+}
+// UnoConversionUtilities -----------------------------------------------------------------------------
+Reference< XInterface > OleClient_Impl::createComWrapperInstance( )
+{
+ Reference<XWeak> xWeak= static_cast<XWeak*>( new IUnknownWrapper_Impl(
+ m_smgr, m_nUnoWrapperClass, m_nComWrapperClass));
+ return Reference<XInterface>( xWeak, UNO_QUERY);
+}
+
+
+
+/*****************************************************************************
+
+ class implementation OleServer_Impl
+
+*****************************************************************************/
+
+OleServer_Impl::OleServer_Impl( const Reference<XMultiServiceFactory>& smgr):
+ m_smgr( smgr)
+{
+ //library unloading support
+ globalModuleCount.modCnt.acquire( &globalModuleCount.modCnt);
+ Reference<XInterface> xInt = m_smgr->createInstance(reinterpret_cast<const sal_Unicode*>(L"com.sun.star.bridge.oleautomation.BridgeSupplier"));
+
+ if (xInt.is())
+ {
+ Any a= xInt->queryInterface( getCppuType(
+ reinterpret_cast< Reference<XBridgeSupplier2>*>(0)));
+ a >>= m_bridgeSupplier;
+ }
+
+#ifndef OWNGUID
+ sal_Bool bOLERegister = sal_False;
+#else
+ sal_Bool bOLERegister = sal_True;
+#endif
+ sal_Bool ret = provideInstance( m_smgr, (GUID*)&OID_ServiceManager, bOLERegister );
+ (void)ret;
+}
+
+OleServer_Impl::~OleServer_Impl()
+{
+ while (!m_wrapperList.empty())
+ {
+ (*m_wrapperList.begin())->deregisterClass();
+ (*m_wrapperList.begin())->Release();
+ m_wrapperList.pop_front();
+ }
+ //library unloading support
+ globalModuleCount.modCnt.release( &globalModuleCount.modCnt);
+}
+// XInterface --------------------------------------------------
+Any SAL_CALL OleServer_Impl::queryInterface( const Type& aType ) throw(RuntimeException)
+{
+ Any a= ::cppu::queryInterface( aType, static_cast<XTypeProvider*>(this));
+ if( a == Any())
+ return OWeakObject::queryInterface( aType);
+ else
+ return a;
+}
+void SAL_CALL OleServer_Impl::acquire( ) throw()
+{
+ OWeakObject::acquire();
+}
+void SAL_CALL OleServer_Impl::release( ) throw ()
+{
+ OWeakObject::release();
+}
+
+
+// XTypeProvider --------------------------------------------------
+Sequence< Type > SAL_CALL OleServer_Impl::getTypes( ) throw(RuntimeException)
+{
+ static OTypeCollection *pCollection = 0;
+ if( ! pCollection )
+ {
+ MutexGuard guard( Mutex::getGlobalMutex() );
+ if( ! pCollection )
+ {
+ static OTypeCollection collection(
+ getCppuType(reinterpret_cast< Reference< XWeak>*>(0)),
+ getCppuType(reinterpret_cast< Reference< XTypeProvider>*>(0)) );
+ pCollection = &collection;
+ }
+ }
+ return (*pCollection).getTypes();
+}
+Sequence< sal_Int8 > SAL_CALL OleServer_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();
+}
+
+
+sal_Bool OleServer_Impl::provideService(const Reference<XSingleServiceFactory>& xSFact, GUID* guid)
+{
+ IClassFactoryWrapper* pFac = new ProviderOleWrapper_Impl( m_smgr, xSFact, guid);
+
+ pFac->AddRef();
+
+ m_wrapperList.push_back(pFac);
+
+ return pFac->registerClass();
+}
+
+sal_Bool OleServer_Impl::provideInstance(const Reference<XInterface>& xInst, GUID* guid, sal_Bool bAsApplication )
+{
+ IClassFactoryWrapper* pFac = new OneInstanceOleWrapper_Impl( m_smgr, xInst, guid, bAsApplication );
+
+ pFac->AddRef();
+ m_wrapperList.push_back(pFac);
+
+ return pFac->registerClass();
+}
+
+
+
+} // end namespace
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/ole/servprov.hxx b/extensions/source/ole/servprov.hxx
new file mode 100644
index 000000000000..49091b1fcd38
--- /dev/null
+++ b/extensions/source/ole/servprov.hxx
@@ -0,0 +1,279 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _SERVPROV_HXX
+#define _SERVPROV_HXX
+
+#include <com/sun/star/lang/XInitialization.hpp>
+#include <cppuhelper/implbase2.hxx>
+
+#include "ole2uno.hxx"
+#include "unoconversionutilities.hxx"
+
+
+using namespace com::sun::star::bridge;
+using namespace cppu;
+using namespace std;
+
+namespace ole_adapter
+{
+Reference< XInterface> SAL_CALL ConverterProvider_CreateInstance( const Reference<XMultiServiceFactory> & xSMgr)
+ throw( Exception);
+Reference< XInterface> SAL_CALL ConverterProvider_CreateInstance2( const Reference<XMultiServiceFactory> & xSMgr)
+ throw( Exception);
+Reference< XInterface> SAL_CALL ConverterProvider_CreateInstanceVar1( const Reference<XMultiServiceFactory> & xSMgr)
+ throw( Exception);
+Reference<XInterface> SAL_CALL OleClient_CreateInstance( const Reference<XMultiServiceFactory> & xSMgr)
+ throw( Exception);
+Reference<XInterface> SAL_CALL OleServer_CreateInstance( const Reference<XMultiServiceFactory> & xSMgr)
+ throw( Exception);
+/*****************************************************************************
+
+ class declaration IClassFactoryWrapper
+
+ Specify abstract helper methods on class factories, which provide
+ UNO objects. These methods are used by objects of class OleServer_Impl,
+ to handle the OLE registration of different class factories.
+
+*****************************************************************************/
+
+class IClassFactoryWrapper : public IClassFactory
+{
+public:
+
+ virtual sal_Bool registerClass() = 0;
+ virtual sal_Bool deregisterClass() = 0;
+};
+
+/*****************************************************************************
+
+ class declaration ProviderOleWrapper_Impl
+
+ Provides an UNO service provider as OLE class factory. Handle the
+ OLE registration by overloading the abstract methods from
+ IClassFactoryWrapper.
+
+ Acts as a COM class factory. When IClassFactory::CreateInstance is being called
+ then it creates an service by help of the XSingleServiceFactory member and maps
+ maps it to a COM object.
+
+*****************************************************************************/
+
+class ProviderOleWrapper_Impl : public IClassFactoryWrapper
+{
+public:
+
+ ProviderOleWrapper_Impl( const Reference<XMultiServiceFactory>& smgr,
+ const Reference<XSingleServiceFactory>& xSFactory, GUID* pGuid);
+ virtual ~ProviderOleWrapper_Impl();
+
+ sal_Bool registerClass();
+ sal_Bool deregisterClass();
+
+ /* IUnknown methods */
+ STDMETHOD(QueryInterface)(REFIID riid, LPVOID FAR * ppvObj);
+ STDMETHOD_(ULONG, AddRef)();
+ STDMETHOD_(ULONG, Release)();
+
+ /* IClassFactory methods */
+ STDMETHOD(CreateInstance)(IUnknown FAR* punkOuter, REFIID riid, void FAR* FAR* ppv);
+ STDMETHOD(LockServer)(int fLock);
+
+protected:
+
+ oslInterlockedCount m_refCount;
+ Reference<XSingleServiceFactory> m_xSingleServiceFactory;
+ GUID m_guid;
+ DWORD m_factoryHandle;
+ Reference<XBridgeSupplier2> m_bridgeSupplier;
+ Reference<XMultiServiceFactory> m_smgr;
+};
+
+/*****************************************************************************
+
+ class declaration OneInstanceOleWrapper_Impl
+
+ Provides an single UNO object as OLE object. Handle the
+ OLE registration by overloading the abstract methods from
+ IClassFactoryWrapper.
+
+ Acts as a COM class factory. When IClassFactory::CreateInstance is being called
+ then it maps the XInstance member it to a COM object.
+
+*****************************************************************************/
+
+class OneInstanceOleWrapper_Impl : public IClassFactoryWrapper
+{
+public:
+
+ OneInstanceOleWrapper_Impl( const Reference<XMultiServiceFactory>& smgr, const Reference<XInterface>& xInst, GUID* pGuid, sal_Bool bAsApplication );
+ virtual ~OneInstanceOleWrapper_Impl();
+
+ sal_Bool registerClass();
+ sal_Bool deregisterClass();
+
+ /* IUnknown methods */
+ STDMETHOD(QueryInterface)(REFIID riid, LPVOID FAR * ppvObj);
+ STDMETHOD_(ULONG, AddRef)();
+ STDMETHOD_(ULONG, Release)();
+
+ /* IClassFactory methods */
+ STDMETHOD(CreateInstance)(IUnknown FAR* punkOuter, REFIID riid, void FAR* FAR* ppv);
+ STDMETHOD(LockServer)(int fLock);
+
+protected:
+
+ oslInterlockedCount m_refCount;
+ Reference<XInterface> m_xInst;
+ GUID m_guid;
+ DWORD m_factoryHandle;
+ Reference<XBridgeSupplier2> m_bridgeSupplier;
+ Reference<XMultiServiceFactory> m_smgr;
+ unsigned long m_nApplRegHandle;
+ sal_Bool m_bAsApplication;
+};
+
+/*****************************************************************************
+
+ class declaration OleConverter_Impl2
+
+ Implementation of the UNO service com.sun.star.bridge.OleBridgeSupplier2.
+
+*****************************************************************************/
+
+// This class realizes the service com.sun.star.bridge.OleBridgeSupplier2 and
+// com.sun.star.bridge.OleBridgeSupplierVar1. The class implements XBridgeSupplier2
+// instead of XBridgeSuppplier as done by class OleConverter_Impl. The XBridgeSupplier2
+// interface does not need a Maschine Id in its createBridge function anymore,
+// If an UNO interface is to be converted then the member m_nUnoWrapperClass determines
+// what wrapper class is to be used. There are currently InterfaceOleWrapper_Impl and
+// UnoObjectWrapperRemoteOpt. The first is used for the OleBridgeSupplier2 and the
+// latter for OleBridgeSupplierVar1.
+// The m_nComWrapperClass specifies the class which is used as wrapper for COM interfaces.
+// Currently there is only one class available ( IUnknownWrapper_Impl).
+class OleConverter_Impl2 : public WeakImplHelper2<XBridgeSupplier2, XInitialization>,
+ public UnoConversionUtilities<OleConverter_Impl2>
+{
+public:
+ OleConverter_Impl2( const Reference<XMultiServiceFactory>& smgr);
+ OleConverter_Impl2( const Reference<XMultiServiceFactory>& smgr, sal_uInt8 unoWrapperClass, sal_uInt8 comWrapperClass );
+ virtual ~OleConverter_Impl2();
+
+ // XBridgeSupplier2 ---------------------------------------------------
+
+ virtual Any SAL_CALL createBridge(const Any& modelDepObject,
+ const Sequence<sal_Int8>& ProcessId,
+ sal_Int16 sourceModelType,
+ sal_Int16 destModelType)
+ throw (IllegalArgumentException, RuntimeException);
+
+ // XInitialization
+ virtual void SAL_CALL initialize( const Sequence< Any >& aArguments ) throw(Exception, RuntimeException);
+
+ // Abstract struct UnoConversionUtilities
+ virtual Reference< XInterface > createUnoWrapperInstance();
+ virtual Reference< XInterface > createComWrapperInstance();
+protected:
+
+};
+
+
+/*****************************************************************************
+
+ class declaration OleClient_Impl
+
+ Implementation of the UNO service com.sun.star.bridge.OleObjectFactory.
+
+*****************************************************************************/
+
+
+class OleClient_Impl : public WeakImplHelper1<XMultiServiceFactory>,
+ public UnoConversionUtilities<OleClient_Impl>
+{
+public:
+ OleClient_Impl( const Reference<XMultiServiceFactory>& smgr);
+ ~OleClient_Impl();
+
+ // XMultiServiceFactory
+ virtual Reference<XInterface> SAL_CALL createInstance(const OUString& ServiceSpecifier) throw( Exception, RuntimeException);
+ virtual Reference<XInterface> SAL_CALL createInstanceWithArguments(const OUString& ServiceSpecifier, const Sequence< Any >& Arguments) throw (Exception, RuntimeException);
+ Sequence< OUString > SAL_CALL getAvailableServiceNames() throw (RuntimeException);
+
+ // Abstract struct UnoConversionUtilities
+ virtual Reference< XInterface > createUnoWrapperInstance();
+ virtual Reference< XInterface > createComWrapperInstance();
+
+
+ OUString getImplementationName();
+protected:
+ Reference<XBridgeSupplier2> m_bridgeSupplier;
+};
+
+/*****************************************************************************
+
+ class declaration OleServer_Impl
+
+ Implementation of the UNO service com.sun.star.bridge.OleApplicationRegistration.
+ Register the calling application as OLE automation server for
+ standard OLE object. The objects will be registered while instanciating
+ this implementation and deregistrated, if this implementation is destroyed.
+
+*****************************************************************************/
+
+class OleServer_Impl : public OWeakObject, XTypeProvider
+{
+public:
+ OleServer_Impl( const Reference<XMultiServiceFactory> &smgr);
+ ~OleServer_Impl();
+
+ // XInterface
+ virtual Any SAL_CALL queryInterface( const Type& aType ) throw(RuntimeException);
+ virtual void SAL_CALL acquire( ) throw ();
+ virtual void SAL_CALL release( ) throw ();
+
+ // XTypeProvider
+ virtual Sequence< Type > SAL_CALL getTypes( ) throw(RuntimeException);
+ virtual Sequence< sal_Int8 > SAL_CALL getImplementationId() throw(RuntimeException);
+
+protected:
+
+ sal_Bool provideService(const Reference<XSingleServiceFactory>& xMulFact, GUID* guid);
+ sal_Bool provideInstance(const Reference<XInterface>& xInst, GUID* guid, sal_Bool bAsApplication );
+
+ list< IClassFactoryWrapper* > m_wrapperList;
+ Reference< XBridgeSupplier2 > m_bridgeSupplier;
+
+ Reference<XMultiServiceFactory> m_smgr;
+};
+
+} // end namespace
+#endif
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/ole/servreg.cxx b/extensions/source/ole/servreg.cxx
new file mode 100644
index 000000000000..16a99df48fa4
--- /dev/null
+++ b/extensions/source/ole/servreg.cxx
@@ -0,0 +1,176 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+#include <rtl/unload.h>
+#include <osl/time.h>
+#include "ole2uno.hxx"
+#include "servprov.hxx"
+#include <rtl/ustring.hxx>
+#include <cppuhelper/factory.hxx>
+using namespace rtl;
+using namespace ole_adapter;
+using namespace cppu;
+
+namespace ole_adapter
+{
+rtl_StandardModuleCount globalModuleCount= MODULE_COUNT_INIT;
+
+
+
+Reference<XInterface> SAL_CALL ConverterProvider_CreateInstance2( const Reference<XMultiServiceFactory> & xSMgr)
+ throw(Exception)
+{
+ Reference<XInterface> xService = *new OleConverter_Impl2( xSMgr);
+ return xService;
+}
+
+Reference<XInterface> SAL_CALL ConverterProvider_CreateInstanceVar1( const Reference<XMultiServiceFactory> & xSMgr)
+ throw(Exception)
+{
+ Reference<XInterface> xService = *new OleConverter_Impl2( xSMgr, UNO_OBJECT_WRAPPER_REMOTE_OPT, IUNKNOWN_WRAPPER_IMPL);
+ return xService;
+}
+
+Reference<XInterface> SAL_CALL OleClient_CreateInstance( const Reference<XMultiServiceFactory> & xSMgr)
+ throw(Exception)
+{
+ Reference<XInterface> xService = *new OleClient_Impl( xSMgr);
+ return xService;
+}
+
+Reference<XInterface> SAL_CALL OleServer_CreateInstance( const Reference<XMultiServiceFactory> & xSMgr)
+ throw (Exception)
+{
+ Reference<XInterface > xService = *new OleServer_Impl(xSMgr);
+ return xService;
+}
+} // end namespace
+
+extern "C" void * SAL_CALL component_getFactory(
+ const sal_Char * pImplName, void * pServiceManager, void * /*pRegistryKey*/ )
+{
+ void * pRet = 0;
+
+ OUString aImplName( OUString::createFromAscii( pImplName ) );
+ Reference< XSingleServiceFactory > xFactory;
+ Sequence<OUString> seqServiceNames;
+ if (pServiceManager && aImplName.equals( reinterpret_cast<const sal_Unicode*>(L"com.sun.star.comp.ole.OleConverter2") ))
+ {
+ xFactory= createSingleFactory( reinterpret_cast< XMultiServiceFactory*>(pServiceManager),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.ole.OleConverter2")),
+ ConverterProvider_CreateInstance2, seqServiceNames,
+ &globalModuleCount.modCnt );
+ }
+ else if (pServiceManager && aImplName.equals( reinterpret_cast<const sal_Unicode*>(L"com.sun.star.comp.ole.OleConverterVar1") ))
+ {
+ xFactory= createSingleFactory( reinterpret_cast<XMultiServiceFactory*>(pServiceManager),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.ole.OleConverterVar1")),
+ ConverterProvider_CreateInstanceVar1, seqServiceNames,
+ &globalModuleCount.modCnt );
+ }
+ else if(pServiceManager && aImplName.equals(reinterpret_cast<const sal_Unicode*>(L"com.sun.star.comp.ole.OleClient")))
+ {
+ xFactory= createSingleFactory( reinterpret_cast< XMultiServiceFactory*>(pServiceManager),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.ole.OleClient")),
+ OleClient_CreateInstance, seqServiceNames,
+ &globalModuleCount.modCnt);
+ }
+ else if(pServiceManager && aImplName.equals(reinterpret_cast<const sal_Unicode*>(L"com.sun.star.comp.ole.OleServer")))
+ {
+ xFactory= createOneInstanceFactory( reinterpret_cast< XMultiServiceFactory*>(pServiceManager),
+ OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.ole.OleServer")),
+ OleServer_CreateInstance, seqServiceNames,
+ &globalModuleCount.modCnt);
+ }
+
+ if (xFactory.is())
+ {
+ xFactory->acquire();
+ pRet = xFactory.get();
+ }
+
+ return pRet;
+}
+
+
+extern "C" sal_Bool SAL_CALL component_writeInfo( void * /*pServiceManager*/, void * pRegistryKey )
+{
+ if (pRegistryKey)
+ {
+ try
+ {
+ //deprecated
+ Reference<XRegistryKey> xNewKey =
+ reinterpret_cast<XRegistryKey*>( pRegistryKey)->createKey(reinterpret_cast<const sal_Unicode*>(L"/com.sun.star.comp.ole.OleConverter2/UNO/SERVICES"));
+ xNewKey->createKey(reinterpret_cast<const sal_Unicode*>(L"com.sun.star.bridge.OleBridgeSupplier2"));
+
+ xNewKey->createKey(reinterpret_cast<const sal_Unicode*>(L"com.sun.star.bridge.oleautomation.BridgeSupplier"));
+
+ //deprecated
+ xNewKey =
+ reinterpret_cast<XRegistryKey*>( pRegistryKey)->createKey(reinterpret_cast<const sal_Unicode*>(L"/com.sun.star.comp.ole.OleConverterVar1/UNO/SERVICES"));
+ xNewKey->createKey(reinterpret_cast<const sal_Unicode*>(L"com.sun.star.bridge.OleBridgeSupplierVar1"));
+
+ //deprecated
+ xNewKey =
+ reinterpret_cast<XRegistryKey*>( pRegistryKey)->createKey(reinterpret_cast<const sal_Unicode*>(L"/com.sun.star.comp.ole.OleClient/UNO/SERVICES"));
+ xNewKey->createKey(reinterpret_cast<const sal_Unicode*>(L"com.sun.star.bridge.OleObjectFactory"));
+
+ xNewKey->createKey(reinterpret_cast<const sal_Unicode*>(L"com.sun.star.bridge.oleautomation.Factory"));
+ //deprecated
+ xNewKey =
+ reinterpret_cast<XRegistryKey*>( pRegistryKey)->createKey(reinterpret_cast<const sal_Unicode*>(L"/com.sun.star.comp.ole.OleServer/UNO/SERVICES"));
+ xNewKey->createKey(reinterpret_cast<const sal_Unicode*>(L"com.sun.star.bridge.OleApplicationRegistration"));
+
+ xNewKey->createKey(reinterpret_cast<const sal_Unicode*>(L"com.sun.star.bridge.oleautomation.ApplicationRegistration"));
+
+ return sal_True;
+ }
+ catch (InvalidRegistryException &)
+ {
+ OSL_ENSURE( sal_False, "### InvalidRegistryException!" );
+ }
+ }
+ return sal_False;
+}
+
+extern "C" void SAL_CALL component_getImplementationEnvironment(
+ const sal_Char ** ppEnvTypeName, uno_Environment ** /*ppEnv*/ )
+{
+ *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
+}
+
+
+extern "C" sal_Bool component_canUnload( TimeValue* libUnused)
+{
+ return globalModuleCount.canUnload( &globalModuleCount, libUnused);
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/ole/unoconversionutilities.hxx b/extensions/source/ole/unoconversionutilities.hxx
new file mode 100644
index 000000000000..1970b08fd843
--- /dev/null
+++ b/extensions/source/ole/unoconversionutilities.hxx
@@ -0,0 +1,2452 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef _UNO_CONVERSION_UTILITIES
+#define _UNO_CONVERSION_UTILITIES
+
+#include "boost/scoped_array.hpp"
+#include "com/sun/star/script/XInvocationAdapterFactory.hpp"
+#include "com/sun/star/script/XInvocationAdapterFactory2.hpp"
+#include "com/sun/star/script/XTypeConverter.hpp"
+#include "com/sun/star/script/FailReason.hpp"
+#include "com/sun/star/bridge/oleautomation/Date.hpp"
+#include "com/sun/star/bridge/oleautomation/Currency.hpp"
+#include "com/sun/star/bridge/oleautomation/SCode.hpp"
+#include "com/sun/star/bridge/oleautomation/Decimal.hpp"
+#include "typelib/typedescription.hxx"
+#include "ole2uno.hxx"
+
+#include "unotypewrapper.hxx"
+#include <hash_map>
+
+// for some reason DECIMAL_NEG (wtypes.h) which contains BYTE is not resolved.
+typedef unsigned char BYTE;
+// classes for wrapping uno objects
+#define INTERFACE_OLE_WRAPPER_IMPL 1
+#define UNO_OBJECT_WRAPPER_REMOTE_OPT 2
+
+#define INVOCATION_SERVICE reinterpret_cast<const sal_Unicode*>(L"com.sun.star.script.Invocation")
+
+
+// classes for wrapping ole objects
+#define IUNKNOWN_WRAPPER_IMPL 1
+
+#define INTERFACE_ADAPTER_FACTORY reinterpret_cast<const sal_Unicode*>(L"com.sun.star.script.InvocationAdapterFactory")
+// COM or JScript objects implementing UNO interfaces have to implement this property
+#define SUPPORTED_INTERFACES_PROP L"_implementedInterfaces"
+// Second property without leading underscore for use in VB
+#define SUPPORTED_INTERFACES_PROP2 L"Bridge_ImplementedInterfaces"
+
+using namespace com::sun::star::script;
+using namespace com::sun::star::beans;
+using namespace com::sun::star::uno;
+#ifdef __MINGW32__
+using namespace com::sun::star::bridge;
+using namespace com::sun::star::bridge::ModelDependent;
+#endif
+using namespace com::sun::star::bridge::oleautomation;
+using namespace boost;
+namespace ole_adapter
+{
+extern hash_map<sal_uInt32, sal_uInt32> AdapterToWrapperMap;
+extern hash_map<sal_uInt32, sal_uInt32> WrapperToAdapterMap;
+typedef hash_map<sal_uInt32, sal_uInt32>::iterator IT_Wrap;
+typedef hash_map<sal_uInt32, sal_uInt32>::iterator CIT_Wrap;
+//Maps IUnknown pointers to a weak reference of the respective wrapper class (e.g.
+// IUnknownWrapperImpl. It is the responsibility of the wrapper to remove the entry when
+// it is being destroyed.
+// Used to ensure that an Automation object is always mapped to the same UNO objects.
+extern hash_map<sal_uInt32, WeakReference<XInterface> > ComPtrToWrapperMap;
+typedef hash_map<sal_uInt32, WeakReference<XInterface> >::iterator IT_Com;
+typedef hash_map<sal_uInt32, WeakReference<XInterface> >::const_iterator CIT_Com;
+
+// Maps XInterface pointers to a weak reference of its wrapper class (i.e.
+// InterfaceOleWrapper_Impl). It is the responsibility of the wrapper to remove the entry when
+// it is being destroyed. It is used to ensure the identity of objects. That is, an UNO interface
+// is mapped to IDispatch which is kept alive in the COM environment. If the same
+// UNO interface is mapped again to COM then the IDispach of the first mapped instance
+// must be returned.
+extern hash_map<sal_uInt32, WeakReference<XInterface> > UnoObjToWrapperMap;
+typedef hash_map<sal_uInt32, WeakReference<XInterface> >::iterator IT_Uno;
+typedef hash_map<sal_uInt32, WeakReference<XInterface> >::const_iterator CIT_Uno;
+#ifdef __MINGW32__
+inline void reduceRange( Any& any);
+#endif
+
+
+
+
+// createUnoObjectWrapper gets a wrapper instance by calling createUnoWrapperInstance
+ // and initializes it via XInitialization. The wrapper object is required to implement
+ // XBridgeSupplier so that it can convert itself to IDispatch.
+ // class T: Deriving class ( must implement XInterface )
+/** All methods are allowed to throw at least a BridgeRuntimeError.
+ */
+template< class >
+class UnoConversionUtilities
+{
+public:
+ UnoConversionUtilities( const Reference<XMultiServiceFactory> & smgr):
+ m_nUnoWrapperClass( INTERFACE_OLE_WRAPPER_IMPL),
+ m_nComWrapperClass( IUNKNOWN_WRAPPER_IMPL),
+ m_smgr( smgr)
+ {}
+
+ UnoConversionUtilities( const Reference<XMultiServiceFactory> & xFactory, sal_uInt8 unoWrapperClass, sal_uInt8 comWrapperClass )
+ : m_smgr( xFactory), m_nComWrapperClass( comWrapperClass), m_nUnoWrapperClass( unoWrapperClass)
+ {}
+
+ virtual ~UnoConversionUtilities() {}
+ /** converts only into oleautomation types, that is there is no VT_I1, VT_UI2, VT_UI4
+ a sal_Unicode character is converted into a BSTR.
+ @exception com.sun.star.lang.IllegalArgumentException
+ If the any was inappropriate for conversion.
+ @exception com.sun.star.script.CannotConvertException
+ The any contains a type class for which no conversion is provided.
+ */
+ void anyToVariant(VARIANT* pVariant, const Any& rAny);
+ void anyToVariant(VARIANT* pVariant, const Any& rAny, VARTYPE type);
+
+ /** @exception com.sun.star.lang.IllegalArgumentException
+ If rSeq does not contain a sequence then the exception is thrown.
+ */
+ SAFEARRAY* createUnoSequenceWrapper(const Any& rSeq);
+ /** @exception com.sun.star.lang.IllegalArgumentException
+ If rSeq does not contain a sequence or elemtype has no proper value
+ then the exception is thrown.
+ */
+ SAFEARRAY* createUnoSequenceWrapper(const Any& rSeq, VARTYPE elemtype);
+ /**
+ @exception com.sun.star.lang.IllegalArgumentException
+ If rObj does not contain a struct or interface
+ */
+ void createUnoObjectWrapper(const Any & rObj, VARIANT * pVar);
+ /** @exception CannotConvertException
+ Thrown if the VARIANT contains a type that cannot be coerced in the expected Any.
+ ArgumentIndex is 0.
+ @IllegalArgumentException
+ Thrown if the VARIANT is inappropriate for conversion. ArgumentPosition is -1,
+ */
+ void variantToAny(const VARIANT* pVariant, Any& rAny, sal_Bool bReduceValueRange = sal_True);
+ /** This method converts variants arguments in calls from COM -> UNO. Only then
+ the expected UNO type is known.
+ @exception CannotConvertException
+ Thrown if the VARIANT contains a type that cannot be coerced in the expected Any.
+ ArgumentIndex is 0.
+ @IllegalArgumentException
+ Thrown if the VARIANT is inappropriate for conversion. ArgumentPosition is -1,
+ */
+ void variantToAny( const VARIANTARG* pArg, Any& rAny, const Type& ptype, sal_Bool bReduceValueRange = sal_True);
+
+ /**
+ @exception IllegalArgumentException
+ -if pVar does not contain VT_UNKNOWN or VT_DISPATCH or
+ pVar is used for a particular UNO type which is not supported by pVar
+ */
+ Any createOleObjectWrapper(VARIANT* pVar, const Type& aType= Type());
+
+ /*
+ Return true means var contained a ValueObject, and it was successfully converted.
+ The result is in any. It an error occurred a BridgeRuntimeError will be thrown.
+ */
+ bool convertValueObject( const VARIANTARG *var, Any& any);
+ void dispatchExObject2Sequence( const VARIANTARG* pvar, Any& anySeq, const Type& type);
+
+ Sequence<Any> createOleArrayWrapperOfDim(SAFEARRAY* pArray, unsigned int dimCount, unsigned int actDim, long* index,
+ VARTYPE type, const Type& unotype);
+ Sequence<Any> createOleArrayWrapper(SAFEARRAY* pArray, VARTYPE type, const Type& unotype= Type());
+
+
+ VARTYPE mapTypeClassToVartype( TypeClass type);
+ Reference< XSingleServiceFactory > getInvocationFactory(const Any& anyObject);
+
+
+ virtual Reference< XInterface > createUnoWrapperInstance()=0;
+ virtual Reference< XInterface > createComWrapperInstance()=0;
+
+ static sal_Bool isJScriptArray(const VARIANT* pvar);
+
+ Sequence<Type> getImplementedInterfaces(IUnknown* pUnk);
+
+protected:
+ Reference<XInterface> createAdapter(const Sequence<Type>& types, const Reference<XInterface>& receiver);
+
+ // helper function for Sequence conversion
+ void getElementCountAndTypeOfSequence( const Any& rSeq, sal_Int32 dim, Sequence< sal_Int32 >& seqElementCounts, TypeDescription& typeDesc);
+ // helper function for Sequence conversion
+ sal_Bool incrementMultidimensionalIndex(sal_Int32 dimensions, const sal_Int32 * parDimensionLength,
+ sal_Int32 * parMultidimensionalIndex);
+ // helper function for Sequence conversion
+ size_t getOleElementSize( VARTYPE type);
+
+ Type getElementTypeOfSequence( const Type& seqType);
+
+ //Provides a typeconverter
+ Reference<XTypeConverter> getTypeConverter();
+
+ // This member determines what class is used to convert a UNO object
+ // or struct to a COM object. It is passed along to the o2u_anyToVariant
+ // function in the createBridge function implementation
+ sal_uInt8 m_nUnoWrapperClass;
+ sal_uInt8 m_nComWrapperClass;
+
+ // The servicemanager is either a local smgr or remote when the service
+ // com.sun.star.bridge.OleBridgeSupplierVar1 is used. This service can be
+ // created by createInstanceWithArguments where one can supply a service
+ // manager that is to be used.
+ // Local service manager as supplied by the loader when the creator function
+ // of the service is being called.
+ Reference<XMultiServiceFactory> m_smgr;
+ // An explicitly supplied service manager when the service
+ // com.sun.star.bridge.OleBridgeSupplierVar1 is used. That can be a remote
+ // manager.
+ Reference<XMultiServiceFactory> m_smgrRemote;
+ Reference<XSingleServiceFactory> m_xInvocationFactoryLocal;
+ Reference<XSingleServiceFactory> m_xInvocationFactoryRemote;
+
+private:
+ // Holds the type converter which is used for sequence conversion etc.
+ // Use the getTypeConverter function to obtain the interface.
+ Reference<XTypeConverter> m_typeConverter;
+
+
+};
+
+// ask the object for XBridgeSupplier2 and on success bridges
+// the uno object to IUnknown or IDispatch.
+// return true the UNO object supports
+template < class T >
+bool convertSelfToCom( T& unoInterface, VARIANT * pVar)
+{
+ bool ret = false;
+ Reference< XInterface > xInt( unoInterface, UNO_QUERY);
+ if( xInt.is())
+ {
+ Reference< XBridgeSupplier2 > xSupplier( xInt, UNO_QUERY);
+ if( xSupplier.is())
+ {
+ sal_Int8 arId[16];
+ rtl_getGlobalProcessId( (sal_uInt8*)arId);
+ Sequence<sal_Int8> seqId( arId, 16);
+ Any anySource;
+ anySource <<= xInt;
+ Any anyDisp= xSupplier->createBridge( anySource, seqId, UNO, OLE);
+ if( anyDisp.getValueTypeClass() == TypeClass_UNSIGNED_LONG)
+ {
+ VARIANT* pvariant= *(VARIANT**)anyDisp.getValue();
+ HRESULT hr;
+ if (FAILED(hr = VariantCopy(pVar, pvariant)))
+ throw BridgeRuntimeError(
+ OUSTR("[automation bridge] convertSelfToCom\n"
+ "VariantCopy failed! Error: ") +
+ OUString::valueOf(hr));
+ VariantClear( pvariant);
+ CoTaskMemFree( pvariant);
+ ret = true;
+ }
+ }
+ }
+ return ret;
+}
+
+
+
+// Gets the invocation factory depending on the Type in the Any.
+// The factory can be created by a local or remote multi service factory.
+// In case there is a remote multi service factory available there are
+// some services or types for which the local factory is used. The exceptions
+// are: all structs.
+// Param anyObject - contains the object ( interface, struct) for what we need an invocation object.
+//
+template<class T>
+Reference< XSingleServiceFactory > UnoConversionUtilities<T>::getInvocationFactory(const Any& anyObject)
+{
+ Reference< XSingleServiceFactory > retVal;
+ MutexGuard guard( getBridgeMutex());
+ if( anyObject.getValueTypeClass() != TypeClass_STRUCT &&
+ m_smgrRemote.is() )
+ {
+ if( ! m_xInvocationFactoryRemote.is() )
+ m_xInvocationFactoryRemote= Reference<XSingleServiceFactory>(
+ m_smgrRemote->createInstance( INVOCATION_SERVICE), UNO_QUERY);
+ retVal= m_xInvocationFactoryRemote;
+ }
+ else
+ {
+ if( ! m_xInvocationFactoryLocal.is() )
+ m_xInvocationFactoryLocal= Reference<XSingleServiceFactory>(
+ m_smgr->createInstance(INVOCATION_SERVICE ), UNO_QUERY);
+ retVal= m_xInvocationFactoryLocal;
+ }
+ return retVal;
+}
+
+template<class T>
+void UnoConversionUtilities<T>::variantToAny( const VARIANTARG* pArg, Any& rAny, const Type& ptype, sal_Bool bReduceValueRange /* = sal_True */)
+{
+ try
+ {
+ HRESULT hr;
+ bool bFail = false;
+ bool bCannotConvert = false;
+ CComVariant var;
+
+ // There is no need to support indirect values, since they're not supported by UNO
+ if( FAILED(hr= VariantCopyInd( &var, const_cast<VARIANTARG*>(pArg)))) // remove VT_BYREF
+ throw BridgeRuntimeError(
+ OUSTR("[automation bridge] UnoConversionUtilities<T>::variantToAny \n"
+ "VariantCopyInd failed for reason : ") + OUString::valueOf(hr));
+ bool bHandled = convertValueObject( & var, rAny);
+ if( bHandled)
+ OSL_ENSURE( rAny.getValueType() == ptype, "type in Value Object must match the type parameter");
+
+ if( ! bHandled)
+ {
+ // convert into a variant type that is the equivalent to the type
+ // the sequence expects. Thus variantToAny produces the correct type
+ // E.g. An Array object contains VT_I4 and the sequence expects shorts
+ // than the vartype must be changed. The reason is, you can't specify the
+ // type in JavaScript and the script engine determines the type beeing used.
+ switch( ptype.getTypeClass())
+ {
+ case TypeClass_CHAR: // could be: new Array( 12, 'w', "w")
+ if( var.vt == VT_BSTR)
+ {
+ if(SUCCEEDED( hr= VariantChangeType( &var, &var, 0, VT_BSTR)))
+ rAny.setValue( (void*)V_BSTR( &var), ptype);
+ else if (hr == DISP_E_TYPEMISMATCH)
+ bCannotConvert = true;
+ else
+ bFail = true;
+ }
+ else
+ {
+ if(SUCCEEDED(hr = VariantChangeType( & var, &var, 0, VT_I2)))
+ rAny.setValue((void*) & var.iVal, ptype);
+ else if (hr == DISP_E_TYPEMISMATCH)
+ bCannotConvert = true;
+ else
+ bFail = true;
+ }
+ break;
+ case TypeClass_INTERFACE: // could also be an IUnknown
+ case TypeClass_STRUCT:
+ {
+ rAny = createOleObjectWrapper( & var, ptype);
+ break;
+ }
+ case TypeClass_ENUM:
+ if(SUCCEEDED(hr = VariantChangeType( & var, &var, 0, VT_I4)))
+ rAny.setValue((void*) & var.lVal, ptype);
+ else if (hr == DISP_E_TYPEMISMATCH)
+ bCannotConvert = true;
+ else
+ bFail = true;
+ break;
+ case TypeClass_SEQUENCE:
+ // There are different ways of receiving a sequence:
+ // 1: JScript, VARTYPE: VT_DISPATCH
+ // 2. VBScript simple arraysVT_VARIANT|VT_BYREF the referenced VARIANT contains
+ // a VT_ARRAY| <type>
+ // 3. VBSrcript multi dimensional arrays: VT_ARRAY|VT_BYREF
+ if( pArg->vt == VT_DISPATCH)
+ {
+ dispatchExObject2Sequence( pArg, rAny, ptype);
+ }
+ else
+ {
+ if ((var.vt & VT_ARRAY) != 0)
+ {
+ VARTYPE oleType = ::sal::static_int_cast< VARTYPE, int >( var.vt ^ VT_ARRAY );
+ Sequence<Any> unoSeq = createOleArrayWrapper( var.parray, oleType, ptype);
+ Reference<XTypeConverter> conv = getTypeConverter();
+ if (conv.is())
+ {
+ try
+ {
+ Any anySeq = makeAny(unoSeq);
+ Any convAny = conv->convertTo(anySeq, ptype);
+ rAny = convAny;
+ }
+ catch (IllegalArgumentException& e)
+ {
+ throw BridgeRuntimeError(
+ OUSTR("[automation bridge]com.sun.star.lang.IllegalArgumentException "
+ "in UnoConversionUtilities<T>::variantToAny! Message: ") +
+ e.Message);
+ }
+ catch (CannotConvertException& e)
+ {
+ throw BridgeRuntimeError(
+ OUSTR("[automation bridge]com.sun.star.script.CannotConvertException "
+ "in UnoConversionUtilities<T>::variantToAny! Message: ") +
+ e.Message);
+ }
+ }
+ }
+ }
+ break;
+ case TypeClass_VOID:
+ rAny.setValue(NULL,Type());
+ break;
+ case TypeClass_ANY: // Any
+ // There could be a JScript Array that needs special handling
+ // If an Any is expected and this Any must contain a Sequence
+ // then we cannot figure out what element type is required.
+ // Therefore we convert to Sequence< Any >
+ if( pArg->vt == VT_DISPATCH && isJScriptArray( pArg))
+ {
+ dispatchExObject2Sequence( pArg, rAny,
+ getCppuType((Sequence<Any>*) 0));
+ }
+ else if (pArg->vt == VT_DECIMAL)
+ {
+ //Decimal maps to hyper in calls from COM -> UNO
+ // It does not matter if we create a sal_uInt64 or sal_Int64,
+ // because the UNO object is called through invocation which
+ //will do a type conversion if necessary
+ if (var.decVal.sign == 0)
+ {
+ // positive value
+ variantToAny( & var, rAny, getCppuType( (sal_uInt64*) 0),
+ bReduceValueRange);
+ }
+ else
+ {
+ //negative value
+ variantToAny( & var, rAny, getCppuType( (sal_Int64*) 0),
+ bReduceValueRange);
+ }
+ }
+ else
+ {
+ variantToAny( & var, rAny);
+ }
+ break;
+ case TypeClass_BOOLEAN: // VARIANT could be VARIANT_BOOL or other
+ if(SUCCEEDED(hr = VariantChangeType( & var, &var, 0, VT_BOOL)))
+ variantToAny( & var, rAny);
+ else if (hr == DISP_E_TYPEMISMATCH)
+ bCannotConvert = true;
+ else
+ bFail = true;
+ break;
+ case TypeClass_STRING: // UString
+ if(SUCCEEDED(hr = VariantChangeType( & var, &var, 0, VT_BSTR)))
+ variantToAny( & var, rAny);
+ else if (hr == DISP_E_TYPEMISMATCH)
+ bCannotConvert = true;
+ else
+ bFail = true;
+ break;
+ case TypeClass_FLOAT: // float
+ if(SUCCEEDED(hr = VariantChangeType( & var, &var, 0, VT_R4)))
+ variantToAny( & var, rAny);
+ else if (hr == DISP_E_TYPEMISMATCH)
+ bCannotConvert = true;
+ else
+ bFail = true;
+ break;
+ case TypeClass_DOUBLE: // double
+ if(SUCCEEDED(hr = VariantChangeType( & var, &var, 0, VT_R8)))
+ variantToAny(& var, rAny);
+ else if (hr == DISP_E_TYPEMISMATCH)
+ bCannotConvert = true;
+ else
+ bFail = true;
+ break;
+ case TypeClass_BYTE: // BYTE
+ if(SUCCEEDED(hr = VariantChangeType( & var, &var, 0, VT_I1)))
+ variantToAny( & var, rAny);
+ else if (hr == DISP_E_TYPEMISMATCH)
+ bCannotConvert = true;
+ else
+ bFail = true;
+ break;
+ case TypeClass_SHORT: // INT16
+ if(SUCCEEDED(hr = VariantChangeType( & var, &var, 0, VT_I2)))
+ variantToAny( & var, rAny);
+ else if (hr == DISP_E_TYPEMISMATCH)
+ bCannotConvert = true;
+ else
+ bFail = true;
+ break;
+ case TypeClass_LONG:
+ if(SUCCEEDED(hr = VariantChangeType(& var, &var, 0, VT_I4)))
+ variantToAny( & var, rAny, bReduceValueRange);
+ else if (hr == DISP_E_TYPEMISMATCH)
+ bCannotConvert = true;
+ else
+ bFail = true;
+ break;
+ case TypeClass_HYPER:
+ if(SUCCEEDED(hr = VariantChangeType(& var, &var, 0, VT_DECIMAL)))
+ {
+ if (var.decVal.Lo64 > SAL_CONST_UINT64(0x8000000000000000)
+ || var.decVal.Hi32 > 0
+ || var.decVal.scale > 0)
+ {
+ bFail = true;
+ break;
+ }
+ sal_Int64 value = var.decVal.Lo64;
+ if (var.decVal.sign == DECIMAL_NEG)
+ value |= SAL_CONST_UINT64(0x8000000000000000);
+ rAny <<= value;
+ }
+ else if (hr == DISP_E_TYPEMISMATCH)
+ bCannotConvert = true;
+ else
+ bFail = true;
+ break;
+ case TypeClass_UNSIGNED_SHORT: // UINT16
+ if(SUCCEEDED(hr = VariantChangeType( & var, &var, 0, VT_UI2)))
+ variantToAny( & var, rAny);
+ else if (hr == DISP_E_TYPEMISMATCH)
+ bCannotConvert = true;
+ else
+ bFail = true;
+ break;
+ case TypeClass_UNSIGNED_LONG:
+ if(SUCCEEDED(hr = VariantChangeType( & var, &var, 0, VT_UI4)))
+ variantToAny( & var, rAny, bReduceValueRange);
+ else if (hr == DISP_E_TYPEMISMATCH)
+ bCannotConvert = true;
+ else
+ bFail = true;
+ break;
+ case TypeClass_UNSIGNED_HYPER:
+ if(SUCCEEDED(hr = VariantChangeType(& var, &var, 0, VT_DECIMAL)))
+ {
+ if (var.decVal.Hi32 > 0 || var.decVal.scale > 0)
+ {
+ bFail = true;
+ break;
+ }
+ rAny <<= var.decVal.Lo64;
+ }
+ else if (hr == DISP_E_TYPEMISMATCH)
+ bCannotConvert = true;
+ else
+ bFail = true;
+ break;
+ case TypeClass_TYPE:
+ if(SUCCEEDED(hr = VariantChangeType(& var, &var, 0, VT_UNKNOWN)))
+ variantToAny( & var, rAny);
+ else if (hr == DISP_E_TYPEMISMATCH)
+ bCannotConvert = true;
+ else
+ bFail = true;
+ break;
+ default:
+// case TypeClass_SERVICE: break; // meta construct
+// case TypeClass_TYPEDEF: break;
+// case TypeClass_UNION: break;
+// case TypeClass_MODULE: break; // module
+// case TypeClass_EXCEPTION: break;
+// case TypeClass_ARRAY: break; // there's no Array at the moment
+// case TypeClass_UNKNOWN: break;
+ bCannotConvert = true;
+ break;
+ }
+ }
+ if (bCannotConvert)
+ throw CannotConvertException(
+ OUSTR("[automation bridge]UnoConversionUtilities<T>::variantToAny \n"
+ "Cannot convert the value of vartype :\"") +
+ OUString::valueOf((sal_Int32) var.vt) +
+ OUSTR("\" to the expected UNO type of type class: ") +
+ OUString::valueOf((sal_Int32) ptype.getTypeClass()),
+ 0, TypeClass_UNKNOWN, FailReason::TYPE_NOT_SUPPORTED,0);
+
+ if (bFail)
+ throw IllegalArgumentException(
+ OUSTR("[automation bridge]UnoConversionUtilities<T>:variantToAny\n"
+ "The provided VARIANT of type\" ") + OUString::valueOf((sal_Int32) var.vt) +
+ OUSTR("\" is unappropriate for conversion!"), Reference<XInterface>(), -1);
+ }
+ catch (CannotConvertException &)
+ {
+ throw;
+ }
+ catch (IllegalArgumentException &)
+ {
+ throw;
+ }
+ catch (BridgeRuntimeError &)
+ {
+ throw;
+ }
+ catch (Exception & e)
+ {
+ throw BridgeRuntimeError(OUSTR("[automation bridge] unexpected exception in "
+ "UnoConversionUtilities<T>::variantToAny ! Message : \n") +
+ e.Message);
+ }
+ catch(...)
+ {
+ throw BridgeRuntimeError(
+ OUSTR("[automation bridge] unexpected exception in "
+ "UnoConversionUtilities<T>::variantToAny !"));
+ }
+}
+
+// The function only converts Sequences to SAFEARRAYS with elements of the type
+// specified by the parameter type. Everything else is forwarded to
+// anyToVariant(VARIANT* pVariant, const Any& rAny)
+// Param type must not be VT_BYREF
+template<class T>
+void UnoConversionUtilities<T>::anyToVariant(VARIANT* pVariant, const Any& rAny, VARTYPE type)
+{
+ try
+ {
+ HRESULT hr= S_OK;
+
+ OSL_ASSERT( (type & VT_BYREF) == 0);
+ if (type & VT_ARRAY)
+ {
+ type ^= VT_ARRAY;
+ SAFEARRAY* ar= createUnoSequenceWrapper( rAny, type);
+ if( ar)
+ {
+ VariantClear( pVariant);
+ pVariant->vt= ::sal::static_int_cast< VARTYPE, int >( VT_ARRAY | type );
+ pVariant->byref= ar;
+ }
+ }
+ else if(type == VT_VARIANT)
+ {
+ anyToVariant(pVariant, rAny);
+ }
+ else
+ {
+ CComVariant var;
+ anyToVariant( &var, rAny);
+ if(FAILED(hr = VariantChangeType(&var, &var, 0, type)))
+ {
+ if (hr == DISP_E_TYPEMISMATCH)
+ throw CannotConvertException(
+ OUSTR("[automation bridge]UnoConversionUtilities<T>::anyToVariant \n"
+ "Cannot convert the value of type :\"") +
+ rAny.getValueTypeName() +
+ OUSTR("\" to the expected Automation type of VARTYPE: ") +
+ OUString::valueOf((sal_Int32)type),
+ 0, TypeClass_UNKNOWN, FailReason::TYPE_NOT_SUPPORTED,0);
+
+ throw BridgeRuntimeError(
+ OUSTR("[automation bridge]UnoConversionUtilities<T>::anyToVariant \n"
+ "Conversion of any with ") +
+ rAny.getValueType().getTypeName() +
+ OUSTR(" to VARIANT with type: ") + OUString::valueOf((sal_Int32) type) +
+ OUSTR(" failed! Error code: ") + OUString::valueOf(hr));
+
+ }
+ if(FAILED(hr = VariantCopy(pVariant, &var)))
+ {
+ throw BridgeRuntimeError(
+ OUSTR("[automation bridge]UnoConversionUtilities<T>::anyToVariant \n"
+ "VariantCopy failed for reason: ") + OUString::valueOf(hr));
+ }
+ }
+ }
+ catch (IllegalArgumentException &)
+ {
+ throw;
+ }
+ catch (CannotConvertException & )
+ {
+ throw;
+ }
+ catch (BridgeRuntimeError&)
+ {
+ throw;
+ }
+ catch(Exception & e)
+ {
+ throw BridgeRuntimeError(
+ OUSTR("[automation bridge]UnoConversionUtilities<T>::anyToVariant \n"
+ "Unexpected exception occurred. Message: ") + e.Message);
+ }
+ catch(...)
+ {
+ throw BridgeRuntimeError(
+ OUSTR("[automation bridge]UnoConversionUtilities<T>::anyToVariant \n"
+ "Unexpected exception occurred."));
+ }
+}
+
+template<class T>
+void UnoConversionUtilities<T>::anyToVariant(VARIANT* pVariant, const Any& rAny)
+{
+ bool bIllegal = false;
+ try
+ {
+ switch (rAny.getValueTypeClass())
+ {
+ case TypeClass_INTERFACE:
+ {
+ Reference<XInterface> xInt;
+ if (rAny >>= xInt)
+ {
+ createUnoObjectWrapper(rAny, pVariant);
+ }
+ else
+ {
+ bIllegal = true;
+ }
+ break;
+ }
+ case TypeClass_STRUCT:
+ {
+ if (rAny.getValueType() == getCppuType((Date*)0))
+ {
+ Date d;
+ if (rAny >>= d)
+ {
+ pVariant->vt = VT_DATE;
+ pVariant->date = d.Value;
+ }
+ else
+ {
+ bIllegal = true;
+ }
+ }
+ else if(rAny.getValueType() == getCppuType((Decimal*)0))
+ {
+ Decimal d;
+ if (rAny >>= d)
+ {
+ pVariant->vt = VT_DECIMAL;
+ pVariant->decVal.scale = d.Scale;
+ pVariant->decVal.sign = d.Sign;
+ pVariant->decVal.Lo32 = d.LowValue;
+ pVariant->decVal.Mid32 = d.MiddleValue;
+ pVariant->decVal.Hi32 = d.HighValue;
+ }
+ else
+ {
+ bIllegal = true;
+ }
+ }
+ else if (rAny.getValueType() == getCppuType((Currency*)0))
+ {
+ Currency c;
+ if (rAny >>= c)
+ {
+ pVariant->vt = VT_CY;
+ pVariant->cyVal.int64 = c.Value;
+ }
+ else
+ {
+ bIllegal = true;
+ }
+ }
+ else if(rAny.getValueType() == getCppuType((SCode*)0))
+ {
+ SCode s;
+ if (rAny >>= s)
+ {
+ pVariant->vt = VT_ERROR;
+ pVariant->scode = s.Value;
+ }
+ else
+ {
+ bIllegal = true;
+ }
+ }
+ else
+ {
+ createUnoObjectWrapper(rAny, pVariant);
+ }
+ break;
+ }
+ case TypeClass_SEQUENCE: // sequence ??? SafeArray descriptor
+ {
+ SAFEARRAY* pArray = createUnoSequenceWrapper(rAny);
+ if (pArray)
+ {
+ V_VT(pVariant) = VT_ARRAY | VT_VARIANT;
+ V_ARRAY(pVariant) = pArray;
+ }
+ else
+ {
+ bIllegal = true;
+ }
+ break;
+ }
+ case TypeClass_VOID:
+ {
+ HRESULT hr = S_OK;
+ if (FAILED(hr = VariantClear(pVariant)))
+ {
+ throw BridgeRuntimeError(
+ OUSTR("[automation bridge]UnoConversionUtilities<T>::anyToVariant\n"
+ "VariantClear failed with error:") + OUString::valueOf(hr));
+ }
+ break;
+ }
+ case TypeClass_BOOLEAN:
+ {
+ sal_Bool value;
+ if (rAny >>= value)
+ {
+ pVariant->vt = VT_BOOL;
+ pVariant->boolVal = value == sal_True? VARIANT_TRUE: VARIANT_FALSE;
+ }
+ else
+ {
+ bIllegal = true;
+ }
+ break;
+ }
+ case TypeClass_CHAR:
+ {
+ // Because VT_UI2 does not conform to oleautomation we convert into VT_I2 instead
+ sal_uInt16 value = *(sal_Unicode*) rAny.getValue();
+ pVariant->vt = VT_I2;
+ pVariant->iVal = value;
+ break;
+ }
+ case TypeClass_STRING:
+ {
+ OUString value;
+ if (rAny >>= value)
+ {
+ pVariant->vt = VT_BSTR;
+ pVariant->bstrVal = SysAllocString(reinterpret_cast<LPCOLESTR>(value.getStr()));
+ }
+ else
+ {
+ bIllegal = true;
+ }
+ break;
+ }
+ case TypeClass_FLOAT:
+ {
+ float value;
+ if (rAny >>= value)
+ {
+ pVariant->vt = VT_R4;
+ pVariant->fltVal = value;
+ }
+ else
+ {
+ bIllegal = true;
+ }
+ break;
+ }
+ case TypeClass_DOUBLE:
+ {
+ double value;
+ if (rAny >>= value)
+ {
+ pVariant->vt = VT_R8;
+ pVariant->dblVal = value;
+ }
+ else
+ {
+ bIllegal = true;
+ }
+ break;
+ }
+ case TypeClass_BYTE:
+ {
+ // ole automation does not know a signed char but only unsigned char
+ sal_Int8 value;
+ if (rAny >>= value)
+ {
+ pVariant->vt = VT_UI1;
+ pVariant->bVal = value;
+ }
+ else
+ {
+ bIllegal = true;
+ }
+ break;
+ }
+ case TypeClass_SHORT: // INT16
+ case TypeClass_UNSIGNED_SHORT: // UINT16
+ {
+ sal_Int16 value;
+ if (rAny >>= value)
+ {
+ pVariant->vt = VT_I2;
+ pVariant->iVal = value;
+ }
+ else
+ {
+ bIllegal = true;
+ }
+ break;
+ }
+ case TypeClass_ENUM:
+ {
+ sal_Int32 value = *(sal_Int32*) rAny.getValue();
+ pVariant->vt = VT_I4;
+ pVariant->lVal= value;
+ break;
+ }
+ case TypeClass_LONG:
+ case TypeClass_UNSIGNED_LONG:
+ {
+ sal_Int32 value;
+ if (rAny >>= value)
+ {
+ pVariant->vt = VT_I4;
+ pVariant->lVal= value;
+ }
+ else
+ {
+ bIllegal = true;
+ }
+ break;
+ }
+ case TypeClass_HYPER:
+ {
+
+ pVariant->vt = VT_DECIMAL;
+ pVariant->decVal.scale = 0;
+ pVariant->decVal.sign = 0;
+ pVariant->decVal.Hi32 = 0;
+
+ sal_Int64 value;
+ rAny >>= value;
+
+ if (value & SAL_CONST_UINT64(0x8000000000000000))
+ pVariant->decVal.sign = DECIMAL_NEG;
+
+ pVariant->decVal.Lo64 = value;
+ break;
+ }
+ case TypeClass_UNSIGNED_HYPER:
+ {
+ pVariant->vt = VT_DECIMAL;
+ pVariant->decVal.scale = 0;
+ pVariant->decVal.sign = 0;
+ pVariant->decVal.Hi32 = 0;
+
+ sal_uInt64 value;
+ rAny >>= value;
+ pVariant->decVal.Lo64 = value;
+ break;
+ }
+ case TypeClass_TYPE:
+ {
+ Type type;
+ rAny >>= type;
+ CComVariant var;
+ if (createUnoTypeWrapper(type.getTypeName(), & var) == false)
+ throw BridgeRuntimeError(
+ OUSTR("[automation bridge] UnoConversionUtilities<T>::anyToVariant \n"
+ "Error during conversion of UNO type to Automation object!"));
+
+ if (FAILED(VariantCopy(pVariant, &var)))
+ throw BridgeRuntimeError(
+ OUSTR("[automation bridge] UnoConversionUtilities<T>::anyToVariant \n"
+ "Unexpected error!"));
+ break;
+ }
+ default:
+ //TypeClass_SERVICE:
+ //TypeClass_EXCEPTION:
+ //When a InvocationTargetException is thrown when calling XInvocation::invoke
+ //on a UNO object, then the target exception is directly used to create a
+ //EXEPINFO structure
+ //TypeClass_TYPEDEF
+ //TypeClass_ANY:
+ //TypeClass_UNKNOWN:
+ //TypeClass_UNSIGNED_OCTET:
+ // TypeClass_UNION:
+ // TypeClass_ARRAY:
+ // TypeClass_UNSIGNED_INT:
+ // TypeClass_UNSIGNED_BYTE:
+ // TypeClass_MODULE:
+ throw CannotConvertException(
+ OUSTR("[automation bridge]UnoConversionUtilities<T>::anyToVariant\n"
+ "There is no conversion for this UNO type to a Automation type."
+ "The destination type class is the type class of the UNO "
+ "argument which was to be converted."),
+ Reference<XInterface>(), rAny.getValueTypeClass(),
+ FailReason::TYPE_NOT_SUPPORTED, 0);
+
+ break;
+ }
+ if (bIllegal)
+ {
+ throw IllegalArgumentException(
+ OUSTR("[automation bridge]UnoConversionUtilities<T>::anyToVariant\n"
+ "The provided any of type\" ") + rAny.getValueType().getTypeName() +
+ OUSTR("\" is unappropriate for conversion!"), Reference<XInterface>(), -1);
+
+ }
+ }
+ catch (CannotConvertException & )
+ {
+ throw;
+ }
+ catch (IllegalArgumentException & )
+ {
+ throw;
+ }
+ catch(BridgeRuntimeError&)
+ {
+ throw;
+ }
+ catch(Exception & e)
+ {
+ throw BridgeRuntimeError(
+ OUSTR("[automation bridge]UnoConversionUtilities<T>::anyToVariant \n"
+ "Unexpected exception occurred. Message: ") + e.Message);
+ }
+ catch(...)
+ {
+ throw BridgeRuntimeError(
+ OUSTR("[automation bridge]UnoConversionUtilities<T>::anyToVariant \n"
+ "Unexpected exception occurred. ") );
+ }
+}
+
+// Creates an SAFEARRAY of the specified element and if necessary
+// creates a SAFEARRAY whith multiple dimensions.
+// Used by sal_Bool anyToVariant(VARIANT* pVariant, const Any& rAny, VARTYPE type);
+template<class T>
+SAFEARRAY* UnoConversionUtilities<T>::createUnoSequenceWrapper(const Any& rSeq, VARTYPE elemtype)
+{
+ if (rSeq.getValueTypeClass() != TypeClass_SEQUENCE)
+ throw IllegalArgumentException(
+ OUSTR("[automation bridge]UnoConversionUtilities<T>::createUnoSequenceWrapper \n"
+ "The any does not contain a sequence!"), 0, 0);
+ if (elemtype == VT_NULL || elemtype == VT_EMPTY)
+ throw IllegalArgumentException(
+ OUSTR("[automation bridge]UnoConversionUtilities<T>::createUnoSequenceWrapper \n"
+ "No element type supplied!"),0, -1);
+ SAFEARRAY* pArray= NULL;
+ // Get the dimensions. This is done by examining the type name string
+ // The count of brackets determines the dimensions.
+ OUString sTypeName= rSeq.getValueType().getTypeName();
+ sal_Int32 dims=0;
+ for(sal_Int32 lastIndex=0;(lastIndex= sTypeName.indexOf( L'[', lastIndex)) != -1; lastIndex++,dims++);
+
+ //get the maximum number of elements per dimensions and the typedescription of the elements
+ Sequence<sal_Int32> seqElementCounts( dims);
+ TypeDescription elementTypeDesc;
+ getElementCountAndTypeOfSequence( rSeq, 1, seqElementCounts, elementTypeDesc );
+
+ if( elementTypeDesc.is() )
+ {
+ // set up the SAFEARRAY
+ scoped_array<SAFEARRAYBOUND> sarSafeArrayBound(new SAFEARRAYBOUND[dims]);
+ SAFEARRAYBOUND* prgsabound= sarSafeArrayBound.get();
+ for( sal_Int32 i=0; i < dims; i++)
+ {
+ //prgsabound[0] is the right most dimension
+ prgsabound[dims - i - 1].lLbound = 0;
+ prgsabound[dims - i - 1].cElements = seqElementCounts[i];
+ }
+
+ typelib_TypeDescription* rawTypeDesc= elementTypeDesc.get();
+ sal_Int32 elementSize= rawTypeDesc->nSize;
+ size_t oleElementSize= getOleElementSize( elemtype);
+ // SafeArrayCreate clears the memory for the data itself.
+ pArray = SafeArrayCreate(elemtype, dims, prgsabound);
+
+ // convert the Sequence's elements and populate the SAFEARRAY
+ if( pArray)
+ {
+ // Iterate over every Sequence that contains the actual elements
+ void* pSAData;
+ if( SUCCEEDED( SafeArrayAccessData( pArray, &pSAData)))
+ {
+ const sal_Int32* parElementCount= seqElementCounts.getConstArray();
+ uno_Sequence * pMultiSeq= *(uno_Sequence* const*) rSeq.getValue();
+ sal_Int32 dimsSeq= dims - 1;
+
+ // arDimSeqIndizes contains the current index of a block of data.
+ // E.g. Sequence<Sequence<sal_Int32>> , the index would refer to Sequence<sal_Int32>
+ // In this case arDimSeqIndices would have the size 1. That is the elements are not counted
+ // but the Sequences that contain those elements.
+ // The indices ar 0 based
+ scoped_array<sal_Int32> sarDimsSeqIndices;
+ sal_Int32* arDimsSeqIndices= NULL;
+ if( dimsSeq > 0)
+ {
+ sarDimsSeqIndices.reset(new sal_Int32[dimsSeq]);
+ arDimsSeqIndices = sarDimsSeqIndices.get();
+ memset( arDimsSeqIndices, 0, sizeof( sal_Int32 ) * dimsSeq);
+ }
+
+ char* psaCurrentData= (char*)pSAData;
+
+ do
+ {
+ // Get the Sequence at the current index , see arDimsSeqIndices
+ uno_Sequence * pCurrentSeq= pMultiSeq;
+ sal_Int32 curDim=1; // 1 based
+ sal_Bool skipSeq= sal_False;
+ while( curDim <= dimsSeq )
+ {
+ // get the Sequence at the index if valid
+ if( pCurrentSeq->nElements > arDimsSeqIndices[ curDim - 1] ) // don't point to Nirvana
+ {
+ // size of Sequence is 4
+ sal_Int32 offset= arDimsSeqIndices[ curDim - 1] * 4;
+ pCurrentSeq= *(uno_Sequence**) &pCurrentSeq->elements[ offset];
+ curDim++;
+ }
+ else
+ {
+ // There is no Sequence at this index, so skip this index
+ skipSeq= sal_True;
+ break;
+ }
+ }
+
+ if( skipSeq)
+ continue;
+
+ // Calculate the current position within the datablock of the SAFEARRAY
+ // for the next Sequence.
+ sal_Int32 memOffset= 0;
+ sal_Int32 dimWeight= parElementCount[ dims - 1]; // size of the rightmost dimension
+ for(sal_Int16 idims=0; idims < dimsSeq; idims++ )
+ {
+ memOffset+= arDimsSeqIndices[dimsSeq - 1 - idims] * dimWeight;
+ // now determine the weight of the dimension to the left of the current.
+ if( dims - 2 - idims >=0)
+ dimWeight*= parElementCount[dims - 2 - idims];
+ }
+ psaCurrentData= (char*)pSAData + memOffset * oleElementSize;
+ // convert the Sequence and put the elements into the Safearray
+ for( sal_Int32 i= 0; i < pCurrentSeq->nElements; i++)
+ {
+ Any unoElement( pCurrentSeq->elements + i * elementSize, rawTypeDesc );
+ // The any is being converted into an VARIANT which value is then copied
+ // to the SAFEARRAY's data block. When copying one has to follow the rules for
+ // copying certain types, as are VT_DISPATCH, VT_UNKNOWN, VT_VARIANT, VT_BSTR.
+ // To increase performance, we just do a memcpy of VARIANT::byref. This is possible
+ // because anyToVariant has already followed the copying rules. To make this
+ // work there must not be a VariantClear.
+ // One Exception is VARIANT because I don't know how VariantCopy works.
+
+ VARIANT var;
+ VariantInit( &var);
+ anyToVariant( &var, unoElement);
+ if( elemtype == VT_VARIANT )
+ {
+ VariantCopy( ( VARIANT*)psaCurrentData, &var);
+ VariantClear( &var);
+ }
+ else
+ memcpy( psaCurrentData, &var.byref, oleElementSize);
+
+ psaCurrentData+= oleElementSize;
+ }
+ }
+ while( incrementMultidimensionalIndex( dimsSeq, parElementCount, arDimsSeqIndices));
+
+ SafeArrayUnaccessData( pArray);
+ }
+ }
+ }
+ return pArray;
+}
+
+// Increments a multi dimensional index.
+// Returns true as long as the index has been successfully incremented, false otherwise.
+// False is also returned if an overflow of the most significant dimension occurs. E.g.
+// assume an array with the dimensions (2,2), then the lowest index is (0,0) and the highest
+// index is (1,1). If the function is being called with the index (1,1) then the overflow would
+// occur, with the result (0,0) and a sal_False as return value.
+// Param dimensions - number of dimensions
+// Param parDimensionsLength - The array contains the size of each dimension, that is the
+// size of the array equals the parameter dimensions.
+// The rightmost dimensions is the least significant one
+// ( parDimensionsLengths[ dimensions -1 ] ).
+// Param parMultiDimensionalIndex - The array contains the index. Each dimension index is
+// 0 based.
+template<class T>
+sal_Bool UnoConversionUtilities<T>::incrementMultidimensionalIndex(sal_Int32 dimensions,
+ const sal_Int32 * parDimensionLengths,
+ sal_Int32 * parMultidimensionalIndex)
+{
+ if( dimensions < 1)
+ return sal_False;
+
+ sal_Bool ret= sal_True;
+ sal_Bool carry= sal_True; // to get into the while loop
+
+ sal_Int32 currentDimension= dimensions; //most significant is 1
+ while( carry)
+ {
+ parMultidimensionalIndex[ currentDimension - 1]++;
+ // if carryover, set index to 0 and handle carry on a level above
+ if( parMultidimensionalIndex[ currentDimension - 1] > (parDimensionLengths[ currentDimension - 1] - 1))
+ parMultidimensionalIndex[ currentDimension - 1]= 0;
+ else
+ carry= sal_False;
+
+ currentDimension --;
+ // if dimensions drops below 1 and carry is set than then all indices are 0 again
+ // this is signalled by returning sal_False
+ if( currentDimension < 1 && carry)
+ {
+ carry= sal_False;
+ ret= sal_False;
+ }
+ }
+ return ret;
+}
+
+// Determines the size of a certain OLE type. The function takes
+// only those types into account which are oleautomation types and
+// can have a value ( unless VT_NULL, VT_EMPTY, VT_ARRAY, VT_BYREF).
+// Currently used in createUnoSequenceWrapper to calculate addresses
+// for data within a SAFEARRAY.
+template<class T>
+size_t UnoConversionUtilities<T>::getOleElementSize( VARTYPE type)
+{
+ size_t size;
+ switch( type)
+ {
+ case VT_BOOL: size= sizeof( VARIANT_BOOL);break;
+ case VT_UI1: size= sizeof( unsigned char);break;
+ case VT_R8: size= sizeof( double);break;
+ case VT_R4: size= sizeof( float);break;
+ case VT_I2: size= sizeof( short);break;
+ case VT_I4: size= sizeof( long);break;
+ case VT_BSTR: size= sizeof( BSTR); break;
+ case VT_ERROR: size= sizeof( SCODE); break;
+ case VT_DISPATCH:
+ case VT_UNKNOWN: size= sizeof( IUnknown*); break;
+ case VT_VARIANT: size= sizeof( VARIANT);break;
+ default: size= 0;
+ }
+ return size;
+}
+
+//If a Sequence is being converted into a SAFEARRAY then we possibly have
+// to create a SAFEARRAY with multiple dimensions. This is the case when a
+// Sequence contains Sequences ( Sequence< Sequence < XXX > > ). The leftmost
+// Sequence in the declaration is assumed to represent dimension 1. Because
+// all Sequence elements of a Sequence can have different length, we have to
+// determine the maximum length which is then the length of the respective
+// dimension.
+// getElementCountAndTypeOfSequence determines the length of each dimension and calls itself recursively
+// in the process.
+// param rSeq - an Any that has to contain a Sequence
+// param dim - the dimension for which the number of elements is being determined,
+// must be one.
+// param seqElementCounts - countains the maximum number of elements for each
+// dimension. Index 0 contains the number of dimension one.
+// After return the Sequence contains the maximum number of
+// elements for each dimension.
+// The length of the Sequence must equal the number of dimensions.
+// param typeClass - TypeClass of the element type that is no Sequence, e.g.
+// Sequence< Sequence <Sequence <sal_Int32> > > - type is sal_Int32)
+template<class T>
+void UnoConversionUtilities<T>::getElementCountAndTypeOfSequence( const Any& rSeq, sal_Int32 dim,
+ Sequence< sal_Int32 >& seqElementCounts, TypeDescription& typeDesc)
+{
+ sal_Int32 dimCount= (*(uno_Sequence* const *) rSeq.getValue())->nElements;
+ if( dimCount > seqElementCounts[ dim-1])
+ seqElementCounts[ dim-1]= dimCount;
+
+ // we need the element type to construct the any that is
+ // passed into getElementCountAndTypeOfSequence again
+ typelib_TypeDescription* pSeqDesc= NULL;
+ rSeq.getValueTypeDescription( &pSeqDesc);
+ typelib_TypeDescriptionReference* pElementDescRef= ((typelib_IndirectTypeDescription*)pSeqDesc)->pType;
+
+ // if the elements are Sequences than do recursion
+ if( dim < seqElementCounts.getLength() )
+ {
+ uno_Sequence* pSeq = *(uno_Sequence* const*) rSeq.getValue();
+ uno_Sequence** arSequences= (uno_Sequence**)pSeq->elements;
+ for( sal_Int32 i=0; i < dimCount; i++)
+ {
+ uno_Sequence* arElement= arSequences[ i];
+ getElementCountAndTypeOfSequence( Any( &arElement, pElementDescRef), dim + 1 , seqElementCounts, typeDesc);
+ }
+ }
+ else
+ {
+ // determine the element type ( e.g. Sequence< Sequence <Sequence <sal_Int32> > > - type is sal_Int32)
+ typeDesc= pElementDescRef;
+ }
+ typelib_typedescription_release( pSeqDesc);
+}
+
+
+template<class T>
+SAFEARRAY* UnoConversionUtilities<T>::createUnoSequenceWrapper(const Any& rSeq)
+{
+ SAFEARRAY* pArray = NULL;
+ sal_uInt32 n = 0;
+
+ if( rSeq.getValueTypeClass() != TypeClass_SEQUENCE )
+ throw IllegalArgumentException(
+ OUSTR("[automation bridge]UnoConversionUtilities<T>::createUnoSequenceWrapper\n"
+ "The UNO argument is not a sequence"), 0, -1);
+
+ uno_Sequence * punoSeq= *(uno_Sequence**) rSeq.getValue();
+
+ typelib_TypeDescriptionReference* pSeqTypeRef= rSeq.getValueTypeRef();
+ typelib_TypeDescription* pSeqType= NULL;
+ TYPELIB_DANGER_GET( &pSeqType, pSeqTypeRef);
+ typelib_IndirectTypeDescription * pSeqIndDec= (typelib_IndirectTypeDescription*) pSeqType;
+
+
+ typelib_TypeDescriptionReference * pSeqElementTypeRef= pSeqIndDec->pType;
+ TYPELIB_DANGER_RELEASE( pSeqType);
+
+ typelib_TypeDescription* pSeqElementDesc= NULL;
+ TYPELIB_DANGER_GET( &pSeqElementDesc, pSeqElementTypeRef);
+
+ // try to find VARIANT type that is related to the UNO type of the sequence elements
+ // the sequence as a sequence element should be handled in a special way
+ VARTYPE eTargetElementType = VT_EMPTY;
+ if ( pSeqElementDesc->eTypeClass != TypeClass_SEQUENCE )
+ eTargetElementType = mapTypeClassToVartype( static_cast< TypeClass >( pSeqElementDesc->eTypeClass ) );
+
+ if ( eTargetElementType != VT_EMPTY )
+ pArray = createUnoSequenceWrapper( rSeq, eTargetElementType );
+
+ if ( !pArray )
+ {
+ sal_Int32 nElementSize= pSeqElementDesc->nSize;
+ n= punoSeq->nElements;
+
+ SAFEARRAYBOUND rgsabound[1];
+ rgsabound[0].lLbound = 0;
+ rgsabound[0].cElements = n;
+ VARIANT oleElement;
+ long safeI[1];
+
+ pArray = SafeArrayCreate(VT_VARIANT, 1, rgsabound);
+
+ Any unoElement;
+ // sal_uInt8 * pSeqData= (sal_uInt8*) punoSeq->pElements;
+ sal_uInt8 * pSeqData= (sal_uInt8*) punoSeq->elements;
+
+ for (sal_uInt32 i = 0; i < n; i++)
+ {
+ unoElement.setValue( pSeqData + i * nElementSize, pSeqElementDesc);
+ VariantInit(&oleElement);
+
+ anyToVariant(&oleElement, unoElement);
+
+ safeI[0] = i;
+ SafeArrayPutElement(pArray, safeI, &oleElement);
+
+ VariantClear(&oleElement);
+ }
+ }
+
+ TYPELIB_DANGER_RELEASE( pSeqElementDesc);
+
+ return pArray;
+}
+
+/* The argument rObj can contain
+- UNO struct
+- UNO interface
+- UNO interface created by this bridge (adapter factory)
+- UNO interface created by this bridge ( COM Wrapper)
+
+pVar must be initialized.
+*/
+template<class T>
+void UnoConversionUtilities<T>::createUnoObjectWrapper(const Any & rObj, VARIANT * pVar)
+{
+ MutexGuard guard(getBridgeMutex());
+
+ Reference<XInterface> xInt;
+
+ TypeClass tc = rObj.getValueTypeClass();
+ if (tc != TypeClass_INTERFACE && tc != TypeClass_STRUCT)
+ throw IllegalArgumentException(
+ OUSTR("[automation bridge]UnoConversionUtilities<T>::createUnoObjectWrapper \n"
+ "Cannot create an Automation interface for a UNO type which is not "
+ "a struct or interface!"), 0, -1);
+
+ if (rObj.getValueTypeClass() == TypeClass_INTERFACE)
+ {
+ if (! (rObj >>= xInt))
+ throw IllegalArgumentException(
+ OUSTR("[automation bridge] UnoConversionUtilities<T>::createUnoObjectWrapper\n "
+ "Could not create wrapper object for UNO object!"), 0, -1);
+ //If XInterface is NULL, which is a valid value, then simply return NULL.
+ if ( ! xInt.is())
+ {
+ pVar->vt = VT_UNKNOWN;
+ pVar->punkVal = NULL;
+ return;
+ }
+ //make sure we have the main XInterface which is used with a map
+ xInt = Reference<XInterface>(xInt, UNO_QUERY);
+ //If there is already a wrapper for the UNO object then use it
+
+ Reference<XInterface> xIntWrapper;
+ // Does a UNO wrapper exist already ?
+ IT_Uno it_uno = UnoObjToWrapperMap.find( (sal_uInt32) xInt.get());
+ if(it_uno != UnoObjToWrapperMap.end())
+ {
+ xIntWrapper = it_uno->second;
+ if (xIntWrapper.is())
+ {
+ convertSelfToCom(xIntWrapper, pVar);
+ return;
+ }
+ }
+ // Is the object a COM wrapper ( either XInvocation, or Adapter object)
+ // or does it suppy an IDispatch by its own ?
+ else
+ {
+ Reference<XInterface> xIntComWrapper = xInt;
+ typedef hash_map<sal_uInt32,sal_uInt32>::iterator _IT;
+ // Adapter? then get the COM wrapper to which the adapter delegates its calls
+ _IT it= AdapterToWrapperMap.find( (sal_uInt32) xInt.get());
+ if( it != AdapterToWrapperMap.end() )
+ xIntComWrapper= reinterpret_cast<XInterface*>(it->second);
+
+ if (convertSelfToCom(xIntComWrapper, pVar))
+ return;
+ }
+ }
+ // If we have no UNO wrapper nor the IDispatch yet then we have to create
+ // a wrapper. For that we need an XInvocation from the UNO object.
+
+ // get an XInvocation or create one using the invocation service
+ Reference<XInvocation> xInv(xInt, UNO_QUERY);
+ if ( ! xInv.is())
+ {
+ Reference<XSingleServiceFactory> xInvFactory= getInvocationFactory(rObj);
+ if (xInvFactory.is())
+ {
+ Sequence<Any> params(1);
+ params.getArray()[0] = rObj;
+ Reference<XInterface> xInt = xInvFactory->createInstanceWithArguments(params);
+ xInv= Reference<XInvocation>(xInt, UNO_QUERY);
+ }
+ }
+
+ if (xInv.is())
+ {
+ Reference<XInterface> xNewWrapper = createUnoWrapperInstance();
+ Reference<XInitialization> xInitWrapper(xNewWrapper, UNO_QUERY);
+ if (xInitWrapper.is())
+ {
+ VARTYPE vartype= getVarType( rObj);
+
+ if (xInt.is())
+ {
+ Any params[3];
+ params[0] <<= xInv;
+ params[1] <<= xInt;
+ params[2] <<= vartype;
+ xInitWrapper->initialize( Sequence<Any>(params, 3));
+ }
+ else
+ {
+ Any params[2];
+ params[0] <<= xInv;
+ params[1] <<= vartype;
+ xInitWrapper->initialize( Sequence<Any>(params, 2));
+ }
+
+ // put the newly created object into a map. If the same object will
+ // be mapped again and there is already a wrapper then the old wrapper
+ // will be used.
+ if(xInt.is()) // only interfaces
+ UnoObjToWrapperMap[(sal_uInt32) xInt.get()]= xNewWrapper;
+ convertSelfToCom(xNewWrapper, pVar);
+ return;
+ }
+ }
+}
+
+template<class T>
+void UnoConversionUtilities<T>::variantToAny( const VARIANT* pVariant, Any& rAny,
+ sal_Bool bReduceValueRange /* = sal_True */)
+{
+ HRESULT hr = S_OK;
+ try
+ {
+ CComVariant var;
+
+ // There is no need to support indirect values, since they're not supported by UNO
+ if( FAILED(hr= VariantCopyInd( &var, const_cast<VARIANTARG*>(pVariant)))) // remove VT_BYREF
+ throw BridgeRuntimeError(
+ OUSTR("[automation bridge] UnoConversionUtilities<T>::variantToAny \n"
+ "VariantCopyInd failed for reason : ") + OUString::valueOf(hr));
+
+ if ( ! convertValueObject( & var, rAny))
+ {
+ if ((var.vt & VT_ARRAY) > 0)
+ {
+ VARTYPE oleTypeFlags = ::sal::static_int_cast< VARTYPE, int >( var.vt ^ VT_ARRAY );
+
+ Sequence<Any> unoSeq = createOleArrayWrapper(var.parray, oleTypeFlags);
+ rAny.setValue( &unoSeq, getCppuType( &unoSeq));
+ }
+ else
+ {
+ switch (var.vt)
+ {
+ case VT_EMPTY:
+ rAny.setValue(NULL, Type());
+ break;
+ case VT_NULL:
+ rAny.setValue(NULL, Type());
+ break;
+ case VT_I2:
+ rAny.setValue( & var.iVal, getCppuType( (sal_Int16*)0));
+ break;
+ case VT_I4:
+ rAny.setValue( & var.lVal, getCppuType( (sal_Int32*)0));
+ // necessary for use in JavaScript ( see "reduceRange")
+ if( bReduceValueRange)
+ reduceRange(rAny);
+ break;
+ case VT_R4:
+ rAny.setValue( & var.fltVal, getCppuType( (float*)0));
+ break;
+ case VT_R8:
+ rAny.setValue(& var.dblVal, getCppuType( (double*)0));
+ break;
+ case VT_CY:
+ {
+ Currency cy(var.cyVal.int64);
+ rAny <<= cy;
+ break;
+ }
+ case VT_DATE:
+ {
+ Date d(var.date);
+ rAny <<= d;
+ break;
+ }
+ case VT_BSTR:
+ {
+ OUString b(reinterpret_cast<const sal_Unicode*>(var.bstrVal));
+ rAny.setValue( &b, getCppuType( &b));
+ break;
+ }
+ case VT_UNKNOWN:
+ case VT_DISPATCH:
+ {
+ //check if it is a UNO type
+#ifdef __MINGW32__
+ CComQIPtr<IUnoTypeWrapper, &__uuidof(IUnoTypeWrapper)> spType((IUnknown*) var.byref);
+#else
+ CComQIPtr<IUnoTypeWrapper> spType((IUnknown*) var.byref);
+#endif
+ if (spType)
+ {
+ CComBSTR sName;
+ if (FAILED(spType->get_Name(&sName)))
+ throw BridgeRuntimeError(
+ OUSTR("[automation bridge]UnoConversionUtilities<T>::variantToAny \n"
+ "Failed to get the type name from a UnoTypeWrapper!"));
+ Type type;
+ if (getType(sName, type) == false)
+ {
+ throw CannotConvertException(
+ OUSTR("[automation bridge]UnoConversionUtilities<T>::variantToAny \n"
+ "A UNO type with the name: ") + OUString(reinterpret_cast<const sal_Unicode*>(LPCOLESTR(sName))) +
+ OUSTR("does not exist!"),
+ 0, TypeClass_UNKNOWN, FailReason::TYPE_NOT_SUPPORTED,0);
+ }
+ rAny <<= type;
+ }
+ else
+ {
+ rAny = createOleObjectWrapper( & var);
+ }
+ break;
+ }
+ case VT_ERROR:
+ {
+ SCode scode(var.scode);
+ rAny <<= scode;
+ break;
+ }
+ case VT_BOOL:
+ {
+ sal_Bool b= var.boolVal == VARIANT_TRUE;
+ rAny.setValue( &b, getCppuType( &b));
+ break;
+ }
+ case VT_I1:
+ rAny.setValue( & var.cVal, getCppuType((sal_Int8*)0));
+ break;
+ case VT_UI1: // there is no unsigned char in UNO
+ rAny.setValue( & var.bVal, getCppuType( (sal_Int8*)0));
+ break;
+ case VT_UI2:
+ rAny.setValue( & var.uiVal, getCppuType( (sal_uInt16*)0));
+ break;
+ case VT_UI4:
+ rAny.setValue( & var.ulVal, getCppuType( (sal_uInt32*)0));
+ break;
+ case VT_INT:
+ rAny.setValue( & var.intVal, getCppuType( (sal_Int32*)0));
+ break;
+ case VT_UINT:
+ rAny.setValue( & var.uintVal, getCppuType( (sal_uInt32*)0));
+ break;
+ case VT_VOID:
+ rAny.setValue( NULL, Type());
+ break;
+ case VT_DECIMAL:
+ {
+ Decimal dec;
+ dec.Scale = var.decVal.scale;
+ dec.Sign = var.decVal.sign;
+ dec.LowValue = var.decVal.Lo32;
+ dec.MiddleValue = var.decVal.Mid32;
+ dec.HighValue = var.decVal.Hi32;
+ rAny <<= dec;
+ break;
+ }
+
+ default:
+ break;
+ }
+ }
+ }
+ }
+ catch (IllegalArgumentException & )
+ {
+ throw;
+ }
+ catch (CannotConvertException &)
+ {
+ throw;
+ }
+ catch (BridgeRuntimeError & )
+ {
+ throw;
+ }
+ catch (Exception & e)
+ {
+ throw BridgeRuntimeError(OUSTR("[automation bridge] unexpected exception in "
+ "UnoConversionUtilities<T>::variantToAny ! Message : \n") +
+ e.Message);
+ }
+ catch(...)
+ {
+ throw BridgeRuntimeError(
+ OUSTR("[automation bridge] unexpected exception in "
+ "UnoConversionUtilities<T>::variantToAny !"));
+ }
+
+}
+// The function converts an IUnknown* into an UNO interface or struct. The
+// IUnknown pointer can constitute different kind of objects:
+// 1. a wrapper of an UNO struct (the wrapper was created by this bridge)
+// 2. a wrapper of an UNO interface (created by this bridge)
+// 3. a dispatch object that implements UNO interfaces
+// 4. a dispatch object.
+
+// If the parameter "aType" has a value then the COM object ( pUnknown) is supposed to
+// implement the interface described by "aType". Moreover it ( pUnknown) can implement
+// several other
+// UNO interfaces in which case it has to support the SUPPORTED_INTERFACES_PROP (see
+// #define) property. That property contains all names of interfaces.
+// "pUnknown" is wrapped by a COM wrapper object that implements XInvocation, e.g.
+// IUnknownWrapper_Impl. Additionally an object of type "aType" is created by help
+// of the INTERFACE_ADAPTER_FACTORY (see #define) service. The implementation of
+// "aType" calls on the COM wrapper's XInvocation::invoke. If the COM object supports
+// more then one UNO interfaces, as can be determined by the property
+// SUPPORTED_INTERFACES_PROP, then the INTERFACE_ADAPTER_FACTORY creates an object that
+// implements all these interfaces.
+// This is only done if "pUnknown" is not already a UNO wrapper,
+// that is it is actually NOT an UNO object that was converted to a COM object. If it is an
+// UNO wrapper than the original UNO object is being extracted, queried for "aType" (if
+// it is no struct) and returned.
+template<class T>
+#ifdef __MINGW32__
+Any UnoConversionUtilities<T>::createOleObjectWrapper(VARIANT* pVar, const Type& aType)
+#else
+Any UnoConversionUtilities<T>::createOleObjectWrapper(VARIANT* pVar, const Type& aType= Type())
+#endif
+{
+ //To allow passing "Nothing" in VS 2008 we need to accept VT_EMPTY
+ if (pVar->vt != VT_UNKNOWN && pVar->vt != VT_DISPATCH && pVar->vt != VT_EMPTY)
+ throw IllegalArgumentException(
+ OUSTR("[automation bridge]UnoConversionUtilities<T>::createOleObjectWrapper \n"
+ "The VARIANT does not contain an object type! "), 0, -1);
+
+ MutexGuard guard( getBridgeMutex());
+
+ CComPtr<IUnknown> spUnknown;
+ CComPtr<IDispatch> spDispatch;
+
+ if (pVar->vt == VT_UNKNOWN)
+ {
+ spUnknown = pVar->punkVal;
+ if (spUnknown)
+#ifdef __MINGW32__
+ spUnknown->QueryInterface( IID_IDispatch, reinterpret_cast<LPVOID*>( & spDispatch.p));
+#else
+ spUnknown.QueryInterface( & spDispatch.p);
+#endif
+ }
+ else if (pVar->vt == VT_DISPATCH && pVar->pdispVal != NULL)
+ {
+ CComPtr<IDispatch> spDispatch(pVar->pdispVal);
+ if (spDispatch)
+#ifdef __MINGW32__
+ spDispatch->QueryInterface( IID_IUnknown, reinterpret_cast<LPVOID*>( & spUnknown.p));
+#else
+ spDispatch.QueryInterface( & spUnknown.p);
+#endif
+ }
+
+ static Type VOID_TYPE= Type();
+ Any ret;
+ //If no Type is provided and pVar contains IUnknown then we return a XInterface.
+ //If pVar contains an IDispatch then we return a XInvocation.
+ Type desiredType = aType;
+
+ if (aType == VOID_TYPE)
+ {
+ switch (pVar->vt)
+ {
+ case VT_EMPTY:
+ case VT_UNKNOWN:
+ desiredType = getCppuType((Reference<XInterface>*) 0);
+ break;
+ case VT_DISPATCH:
+ desiredType = getCppuType((Reference<XInvocation>*) 0);
+ break;
+ default:
+ desiredType = aType;
+ }
+ }
+
+ // COM pointer are NULL, no wrapper required
+ if (spUnknown == NULL)
+ {
+ Reference<XInterface> xInt;
+ if( aType.getTypeClass() == TypeClass_INTERFACE)
+ ret.setValue( &xInt, aType);
+ else if( aType.getTypeClass() == TypeClass_STRUCT)
+ ret.setValue( NULL, aType);
+ else
+ ret <<= xInt;
+ return ret;
+ }
+
+
+ // Check if "spUnknown" is a UNO wrapper, that is an UNO object that has been
+ // passed to COM. Then it supports IUnoObjectWrapper
+ // and we extract the original UNO object.
+#ifdef __MINGW32__
+ CComQIPtr<IUnoObjectWrapper, &__uuidof(IUnoObjectWrapper)> spUno( spUnknown);
+#else
+ CComQIPtr<IUnoObjectWrapper> spUno( spUnknown);
+#endif
+ if( spUno)
+ { // it is a wrapper
+ Reference<XInterface> xInt;
+ if( SUCCEEDED( spUno->getOriginalUnoObject( &xInt)))
+ {
+ ret <<= xInt;
+ }
+ else
+ {
+ Any any;
+ if( SUCCEEDED( spUno->getOriginalUnoStruct(&any)))
+ ret= any;
+ }
+ return ret;
+ }
+
+ // "spUnknown" is a real COM object.
+ // Before we create a new wrapper object we check if there is an existing wrapper
+ // There can be two kinds of wrappers, those who wrap dispatch - UNO objects, and those who
+ // wrap ordinary dispatch objects. The dispatch-UNO objects usually are adapted to represent
+ // particular UNO interfaces.
+ Reference<XInterface> xIntWrapper;
+ CIT_Com cit_currWrapper= ComPtrToWrapperMap.find( reinterpret_cast<sal_uInt32>(spUnknown.p));
+ if(cit_currWrapper != ComPtrToWrapperMap.end())
+ xIntWrapper = cit_currWrapper->second;
+ if (xIntWrapper.is())
+ {
+ //Try to find an adapter for the wrapper
+ //find the proper Adapter. The pointer in the WrapperToAdapterMap are valid as long as
+ //we get a pointer to the wrapper from ComPtrToWrapperMap, because the Adapter hold references
+ //to the wrapper.
+ CIT_Wrap it = WrapperToAdapterMap.find((sal_uInt32) xIntWrapper.get());
+ if (it == WrapperToAdapterMap.end())
+ {
+ // No adapter available.
+ //The COM component could be a UNO object. Then we need to provide
+ // a proxy that implements all interfaces
+ Sequence<Type> seqTypes= getImplementedInterfaces(spUnknown);
+ Reference<XInterface> xIntAdapter;
+ if (seqTypes.getLength() > 0)
+ {
+ //It is a COM UNO object
+ xIntAdapter = createAdapter(seqTypes, xIntWrapper);
+ }
+ else
+ {
+ // Some ordinary COM object
+ xIntAdapter = xIntWrapper;
+ }
+ // return the wrapper directly, return XInterface or XInvocation
+ ret = xIntWrapper->queryInterface(desiredType);
+ if ( ! ret.hasValue())
+ throw IllegalArgumentException(
+ OUSTR("[automation bridge]UnoConversionUtilities<T>::createOleObjectWrapper \n"
+ "The COM object is not suitable for the UNO type: ") +
+ desiredType.getTypeName(), 0, -1);
+ }
+ else
+ {
+ //There is an adapter available
+ Reference<XInterface> xIntAdapter((XInterface*) it->second);
+ ret = xIntAdapter->queryInterface( desiredType);
+ if ( ! ret.hasValue())
+ throw IllegalArgumentException(
+ OUSTR("[automation bridge]UnoConversionUtilities<T>::createOleObjectWrapper \n"
+ "The COM object is not suitable for the UNO type: ") +
+ desiredType.getTypeName(), 0, -1);
+ }
+
+ return ret;
+ }
+ // No existing wrapper. Therefore create a new proxy.
+ // If the object implements UNO interfaces then get the types.
+ Sequence<Type> seqTypes = getImplementedInterfaces(spUnknown);
+ if (seqTypes.getLength() == 0 &&
+ aType != VOID_TYPE && aType != getCppuType((Reference<XInvocation>*)0))
+ {
+ seqTypes = Sequence<Type>( & aType, 1);
+ }
+
+ //There is no existing wrapper, therefore we create one for the real COM object
+ Reference<XInterface> xIntNewProxy= createComWrapperInstance();
+ if ( ! xIntNewProxy.is())
+ throw BridgeRuntimeError(
+ OUSTR("[automation bridge]UnoConversionUtilities<T>::createOleObjectWrapper \n"
+ "Could not create proxy object for COM object!"));
+
+ // initialize the COM wrapper
+ Reference<XInitialization> xInit( xIntNewProxy, UNO_QUERY);
+ OSL_ASSERT( xInit.is());
+
+ Any params[3];
+#ifdef __MINGW32__
+ params[0] <<= reinterpret_cast<sal_uInt32>( spUnknown.p );
+#else
+ params[0] <<= (sal_uInt32) spUnknown.p;
+#endif
+ sal_Bool bDisp = pVar->vt == VT_DISPATCH ? sal_True : sal_False;
+ params[1].setValue( & bDisp, getBooleanCppuType());
+ params[2] <<= seqTypes;
+
+ xInit->initialize( Sequence<Any>( params, 3));
+#ifdef __MINGW32__
+ ComPtrToWrapperMap[reinterpret_cast<sal_uInt32>( spUnknown.p )]= xIntNewProxy;
+#else
+ ComPtrToWrapperMap[reinterpret_cast<sal_uInt32>(spUnknown.p)]= xIntNewProxy;
+#endif
+
+ // we have a wrapper object
+ //The wrapper implements already XInvocation and XInterface. If
+ //param aType is void then the object is supposed to have XInvocation.
+ if (aType == getCppuType((Reference<XInvocation>*)0) ||
+ (aType == VOID_TYPE && seqTypes.getLength() == 0 ))
+ {
+ ret = xIntNewProxy->queryInterface(desiredType);
+ }
+ else
+ {
+ Reference<XInterface> xIntAdapter =
+ createAdapter(seqTypes, xIntNewProxy);
+ ret = xIntAdapter->queryInterface(desiredType);
+ }
+ return ret;
+}
+template<class T>
+Reference<XInterface> UnoConversionUtilities<T>::createAdapter(const Sequence<Type>& seqTypes,
+ const Reference<XInterface>& receiver)
+{
+ Reference< XInterface> xIntAdapterFac;
+ xIntAdapterFac= m_smgr->createInstance(INTERFACE_ADAPTER_FACTORY);
+ // We create an adapter object that does not only implement the required type but also
+ // all types that the COM object pretends to implement. An COM object must therefore
+ // support the property "_implementedInterfaces".
+ Reference<XInterface> xIntAdapted;
+ Reference<XInvocation> xInv(receiver, UNO_QUERY);
+ Reference<XInvocationAdapterFactory2> xAdapterFac( xIntAdapterFac, UNO_QUERY);
+ if( xAdapterFac.is())
+ xIntAdapted= xAdapterFac->createAdapter( xInv, seqTypes);
+
+ if( xIntAdapted.is())
+ {
+ // Put the pointer to the wrapper object and the interface pointer of the adapted interface
+ // in a global map. Thus we can determine in a call to createUnoObjectWrapper whether the UNO
+ // object is a wrapped COM object. In that case we extract the original COM object rather than
+ // creating a wrapper around the UNO object.
+ typedef hash_map<sal_uInt32,sal_uInt32>::value_type VALUE;
+ AdapterToWrapperMap.insert( VALUE( (sal_uInt32) xIntAdapted.get(), (sal_uInt32) receiver.get()));
+ WrapperToAdapterMap.insert( VALUE( (sal_uInt32) receiver.get(), (sal_uInt32) xIntAdapted.get()));
+ }
+ else
+ {
+ throw BridgeRuntimeError(
+ OUSTR("[automation bridge]UnoConversionUtilities<T>::createOleObjectWrapper \n"
+ "Could not create a proxy for COM object! Creation of adapter failed."));
+ }
+ return xIntAdapted;
+}
+// "convertValueObject" converts a JScriptValue object contained in "var" into
+// an any. The type contained in the any is stipulated by a "type value" thas
+// was set within the JScript script on the value object ( see JScriptValue).
+template<class T>
+bool UnoConversionUtilities<T>::convertValueObject( const VARIANTARG *var, Any& any)
+{
+ bool ret = false;
+ try
+ {
+ bool bFail = false;
+ HRESULT hr= S_OK;
+ CComVariant varDisp;
+
+ if(SUCCEEDED(hr = varDisp.ChangeType( VT_DISPATCH, var)))
+ {
+ CComPtr <IJScriptValueObject> spValue;
+ VARIANT_BOOL varBool;
+ CComBSTR bstrType;
+ CComVariant varValue;
+ CComPtr<IDispatch> spDisp( varDisp.pdispVal);
+ if(spDisp)
+ {
+ if(SUCCEEDED( spDisp->QueryInterface( __uuidof( IJScriptValueObject),
+ reinterpret_cast<void**> (&spValue))))
+ {
+ ret = true; // is is a ValueObject
+ //If it is an out - param then it does not need to be converted. In/out and
+ // in params does so.
+ if (SUCCEEDED(hr= spValue->IsOutParam( &varBool)))
+ {
+ // if varBool == true then no conversion needed because out param
+ if (varBool == VARIANT_FALSE)
+ {
+ if(SUCCEEDED(hr = spValue->GetValue( & bstrType, & varValue)))
+ {
+ Type type;
+ if (getType(bstrType, type))
+ variantToAny( & varValue, any, type);
+ else
+ bFail = true;
+ }
+ else
+ bFail = true;
+ }
+ }
+ else
+ bFail = true;;
+ }
+ }
+ }
+ else if( hr != DISP_E_TYPEMISMATCH && hr != E_NOINTERFACE)
+ bFail = true;
+
+ if (bFail)
+ throw BridgeRuntimeError(
+ OUSTR("[automation bridge] Conversion of ValueObject failed "));
+ }
+ catch (BridgeRuntimeError &)
+ {
+ throw;
+ }
+ catch (Exception & e)
+ {
+ throw BridgeRuntimeError(OUSTR("[automation bridge] unexpected exception in "
+ "UnoConversionUtilities<T>::convertValueObject ! Message : \n") +
+ e.Message);
+ }
+ catch(...)
+ {
+ throw BridgeRuntimeError(
+ OUSTR("[automation bridge] unexpected exception in "
+ "UnoConversionUtilities<T>::convertValueObject !"));
+ }
+ return ret;
+}
+
+template<class T>
+void UnoConversionUtilities<T>::dispatchExObject2Sequence( const VARIANTARG* pvar, Any& anySeq, const Type& type)
+{
+ try
+ {
+ bool bFail = false;
+ if( pvar->vt != VT_DISPATCH)
+ throw BridgeRuntimeError(OUSTR("[automation bridge] UnoConversionUtilities<T>::dispatchExObject2Sequence \n"
+ "Conversion of dispatch object to Sequence failed!"));
+ IDispatchEx* pdispEx;
+ HRESULT hr;
+ if( FAILED( hr= pvar->pdispVal->QueryInterface( IID_IDispatchEx,
+ reinterpret_cast<void**>( &pdispEx))))
+ throw BridgeRuntimeError(OUSTR("[automation bridge] UnoConversionUtilities<T>::dispatchExObject2Sequence \n"
+ "Conversion of dispatch object to Sequence failed!"));
+
+ DISPID dispid;
+ OUString sindex;
+ DISPPARAMS param= {0,0,0,0};
+ CComVariant result;
+
+ OLECHAR* sLength= L"length";
+
+ // Get the length of the array. Can also be obtained throu GetNextDispID. The
+ // method only returns DISPIDs of the array data. Their names are like "0", "1" etc.
+ if( FAILED( hr= pdispEx->GetIDsOfNames(IID_NULL, &sLength , 1, LOCALE_USER_DEFAULT, &dispid)))
+ throw BridgeRuntimeError(OUSTR("[automation bridge] UnoConversionUtilities<T>::dispatchExObject2Sequence \n"
+ "Conversion of dispatch object to Sequence failed!"));
+ if( FAILED( hr= pdispEx->InvokeEx(dispid, LOCALE_USER_DEFAULT, DISPATCH_PROPERTYGET,
+ &param, &result, NULL, NULL)))
+ throw BridgeRuntimeError(OUSTR("[automation bridge] UnoConversionUtilities<T>::dispatchExObject2Sequence \n"
+ "Conversion of dispatch object to Sequence failed!"));
+ if( FAILED( VariantChangeType( &result, &result, 0, VT_I4)))
+ throw BridgeRuntimeError(OUSTR("[automation bridge] UnoConversionUtilities<T>::dispatchExObject2Sequence \n"
+ "Conversion of dispatch object to Sequence failed!"));
+ long length= result.lVal;
+
+ result.Clear();
+
+ // get a few basic facts about the sequence, and reallocate:
+ // create the Sequences
+ // get the size of the elements
+ typelib_TypeDescription *pDesc= NULL;
+ type.getDescription( &pDesc);
+
+ typelib_IndirectTypeDescription *pSeqDesc= reinterpret_cast<typelib_IndirectTypeDescription*>(pDesc);
+ typelib_TypeDescriptionReference *pSeqElemDescRef= pSeqDesc->pType; // type of the Sequence' elements
+ Type elemType( pSeqElemDescRef);
+ _typelib_TypeDescription* pSeqElemDesc=NULL;
+ TYPELIB_DANGER_GET( &pSeqElemDesc, pSeqElemDescRef)
+ sal_uInt32 nelementSize= pSeqElemDesc->nSize;
+ TYPELIB_DANGER_RELEASE( pSeqElemDesc)
+
+ uno_Sequence *p_uno_Seq;
+ uno_sequence_construct( &p_uno_Seq, pDesc, NULL, length, cpp_acquire);
+
+ typelib_TypeClass typeElement= pSeqDesc->pType->eTypeClass;
+ char *pArray= p_uno_Seq->elements;
+
+ // Get All properties in the object, convert their values to the expected type and
+ // put them into the passed in sequence
+ for( sal_Int32 i= 0; i< length; i++)
+ {
+ OUString ousIndex=OUString::valueOf( i);
+ OLECHAR* sindex = (OLECHAR*)ousIndex.getStr();
+
+ if( FAILED( hr= pdispEx->GetIDsOfNames(IID_NULL, &sindex , 1, LOCALE_USER_DEFAULT, &dispid)))
+ {
+ throw BridgeRuntimeError(OUSTR("[automation bridge] UnoConversionUtilities<T>::dispatchExObject2Sequence \n"
+ "Conversion of dispatch object to Sequence failed!"));
+ }
+ if( FAILED( hr= pdispEx->InvokeEx(dispid, LOCALE_USER_DEFAULT, DISPATCH_PROPERTYGET,
+ &param, &result, NULL, NULL)))
+ {
+ throw BridgeRuntimeError(OUSTR("[automation bridge] UnoConversionUtilities<T>::dispatchExObject2Sequence \n"
+ "Conversion of dispatch object to Sequence failed!"));
+ }
+
+ // If the result is VT_DISPATCH than the Sequence's element type could be Sequence
+ // Look that up in the CoreReflection to make clear.
+ // That requires a recursiv conversion
+ Any any;
+ // Destination address within the out-Sequence "anySeq" where to copy the next converted element
+ void* pDest= (void*)(pArray + (i * nelementSize));
+
+ if( result.vt & VT_DISPATCH && typeElement == typelib_TypeClass_SEQUENCE)
+ {
+ variantToAny( &result, any, elemType, sal_False);
+ // copy the converted VARIANT, that is a Sequence to the Sequence
+ uno_Sequence * p_unoSeq= *(uno_Sequence**)any.getValue();
+ // just copy the pointer of the uno_Sequence
+ // nelementSize should be 4 !!!!
+ memcpy( pDest, &p_unoSeq, nelementSize);
+ osl_incrementInterlockedCount( &p_unoSeq->nRefCount);
+ }
+ else // Element type is no Sequence -> do one conversion
+ {
+ variantToAny( &result, any, elemType, sal_False);
+ if( typeElement == typelib_TypeClass_ANY)
+ {
+ // copy the converted VARIANT to the Sequence
+ uno_type_assignData( pDest, pSeqElemDescRef , &any, pSeqElemDescRef,cpp_queryInterface,
+ cpp_acquire, cpp_release);
+ }
+ else
+ {
+ // type after conversion must be the element type of the sequence
+ OSL_ENSURE( (any.getValueTypeClass() == typeElement), "wrong conversion");
+ uno_type_assignData( pDest, pSeqElemDescRef,const_cast<void*>( any.getValue()), any.getValueTypeRef(),
+ cpp_queryInterface, cpp_acquire, cpp_release);
+ }
+ }
+ } // else
+ result.Clear();
+ anySeq.setValue( &p_uno_Seq, pDesc);
+ uno_destructData( &p_uno_Seq, pDesc, cpp_release);
+ typelib_typedescription_release( pDesc);
+
+ if (bFail)
+ throw BridgeRuntimeError(
+ OUSTR("[automation bridge] Conversion of ValueObject failed "));
+ }
+ catch (BridgeRuntimeError & )
+ {
+ throw;
+ }
+ catch (Exception & e)
+ {
+ throw BridgeRuntimeError(OUSTR("[automation bridge] unexpected exception in "
+ "UnoConversionUtilities<T>::convertValueObject ! Message : \n") +
+ e.Message);
+ }
+ catch(...)
+ {
+ throw BridgeRuntimeError(
+ OUSTR("[automation bridge] unexpected exception in "
+ "UnoConversionUtilities<T>::convertValueObject !"));
+ }
+}
+
+/* The argument unotype is the type that is expected by the currently called UNO function.
+ For example: []long, [][]long. If the function calls itself recursively then the element type
+ is passed on. For example a two dimensional SAFEARRAY of type VT_I4 is to be converted. Then
+ unotype has to be either void or [][]long. When the function calls itself recursivly then
+ it passes the element type which is []long.
+*/
+template<class T>
+Sequence<Any> UnoConversionUtilities<T>::createOleArrayWrapperOfDim(SAFEARRAY* pArray,
+ unsigned int dimCount, unsigned int actDim, long* index, VARTYPE type, const Type& unotype)
+{
+ HRESULT hr= S_OK;
+ long lBound;
+ long uBound;
+ long nCountElements;
+
+ SafeArrayGetLBound(pArray, actDim, &lBound);
+ SafeArrayGetUBound(pArray, actDim, &uBound);
+ nCountElements= uBound - lBound +1;
+
+ Sequence<Any> anySeq(nCountElements);
+ Any* pUnoArray = anySeq.getArray();
+
+ for (index[actDim - 1] = lBound; index[actDim - 1] <= uBound; index[actDim - 1]++)
+ {
+ if (actDim > 1 )
+ {
+ Sequence<Any> element = createOleArrayWrapperOfDim(pArray, dimCount,
+ actDim - 1, index, type, getElementTypeOfSequence(unotype));
+
+ pUnoArray[index[actDim - 1] - lBound].setValue(&element, getCppuType(&element));
+ }
+ else
+ {
+ VARIANT variant;
+
+ VariantInit(&variant);
+
+ V_VT(&variant) = type;
+
+ switch (type)
+ {
+ case VT_I2:
+ SafeArrayGetElement(pArray, index, &V_I2(&variant));
+ break;
+ case VT_I4:
+ SafeArrayGetElement(pArray, index, &V_I4(&variant));
+ break;
+ case VT_R4:
+ SafeArrayGetElement(pArray, index, &V_R4(&variant));
+ break;
+ case VT_R8:
+ SafeArrayGetElement(pArray, index, &V_R8(&variant));
+ break;
+ case VT_CY:
+ SafeArrayGetElement(pArray, index, &V_CY(&variant));
+ break;
+ case VT_DATE:
+ SafeArrayGetElement(pArray, index, &V_DATE(&variant));
+ break;
+ case VT_BSTR:
+ hr= SafeArrayGetElement(pArray, index, &V_BSTR(&variant));
+ break;
+ case VT_DISPATCH:
+ SafeArrayGetElement(pArray, index, &V_DISPATCH(&variant));
+ break;
+ case VT_ERROR:
+ SafeArrayGetElement(pArray, index, &V_ERROR(&variant));
+ break;
+ case VT_BOOL:
+ SafeArrayGetElement(pArray, index, &V_BOOL(&variant));
+ break;
+ case VT_VARIANT:
+ SafeArrayGetElement(pArray, index, &variant);
+ break;
+ case VT_UNKNOWN:
+ SafeArrayGetElement(pArray, index, &V_UNKNOWN(&variant));
+ break;
+ case VT_I1:
+ SafeArrayGetElement(pArray, index, &V_I1(&variant));
+ break;
+ case VT_UI1:
+ SafeArrayGetElement(pArray, index, &V_UI1(&variant));
+ break;
+ case VT_UI2:
+ SafeArrayGetElement(pArray, index, &V_UI2(&variant));
+ break;
+ case VT_UI4:
+ SafeArrayGetElement(pArray, index, &V_UI4(&variant));
+ break;
+ default:
+ break;
+ }
+
+ if( unotype.getTypeClass() == TypeClass_VOID)
+ // the function was called without specifying the destination type
+ variantToAny(&variant, pUnoArray[index[actDim - 1] - lBound], sal_False);
+ else
+ variantToAny(&variant, pUnoArray[index[actDim - 1] - lBound],
+ getElementTypeOfSequence(unotype), sal_False);
+
+ VariantClear(&variant);
+ }
+ }
+ return anySeq;
+}
+
+template<class T>
+Type UnoConversionUtilities<T>::getElementTypeOfSequence( const Type& seqType)
+{
+ Type retValue;
+ if( seqType.getTypeClass() != TypeClass_VOID)
+ {
+ OSL_ASSERT( seqType.getTypeClass() == TypeClass_SEQUENCE);
+ typelib_IndirectTypeDescription* pDescSeq= NULL;
+ seqType.getDescription((typelib_TypeDescription** ) & pDescSeq);
+ retValue = Type(pDescSeq->pType);
+ typelib_typedescription_release( (typelib_TypeDescription*) pDescSeq);
+ }
+ return retValue;
+}
+template<class T>
+Sequence<Any> UnoConversionUtilities<T>::createOleArrayWrapper(SAFEARRAY* pArray, VARTYPE type, const Type& unoType)
+{
+ sal_uInt32 dim = SafeArrayGetDim(pArray);
+
+ Sequence<Any> ret;
+
+ if (dim > 0)
+ {
+ scoped_array<long> sarIndex(new long[dim]);
+ long * index = sarIndex.get();
+
+ for (unsigned int i = 0; i < dim; i++)
+ {
+ index[i] = 0;
+ }
+
+ ret = createOleArrayWrapperOfDim(pArray, dim, dim, index, type, unoType);
+ }
+
+ return ret;
+}
+
+// If an VARIANT has the type VT_DISPATCH it can either be an JScript Array
+// or some other object. This function finds out if it is such an array or
+// not. Currently there's no way to make sure it's an array
+// so we assume that when the object has a property "0" then it is an Array.
+// An JScript has property like "0", "1", "2" etc. which represent the
+// value at the corresponding index of the array
+template<class T>
+sal_Bool UnoConversionUtilities<T>::isJScriptArray(const VARIANT* rvar)
+{
+ OSL_ENSURE( rvar->vt == VT_DISPATCH, "param is not a VT_DISPATCH");
+ HRESULT hr;
+ OLECHAR* sindex= L"0";
+ DISPID id;
+ if ( rvar->vt == VT_DISPATCH && rvar->pdispVal )
+ {
+ hr= rvar->pdispVal->GetIDsOfNames( IID_NULL, &sindex, 1,
+ LOCALE_USER_DEFAULT, &id);
+
+ if( SUCCEEDED ( hr) )
+ return sal_True;
+ }
+
+ return sal_False;
+}
+
+template<class T>
+VARTYPE UnoConversionUtilities<T>::mapTypeClassToVartype( TypeClass type)
+{
+ VARTYPE ret;
+ switch( type)
+ {
+ case TypeClass_INTERFACE: ret= VT_DISPATCH;
+ break;
+ case TypeClass_STRUCT: ret= VT_DISPATCH;
+ break;
+ case TypeClass_ENUM: ret= VT_I4;
+ break;
+ case TypeClass_SEQUENCE: ret= VT_ARRAY;
+ break;
+ case TypeClass_ANY: ret= VT_VARIANT;
+ break;
+ case TypeClass_BOOLEAN: ret= VT_BOOL;
+ break;
+ case TypeClass_CHAR: ret= VT_I2;
+ break;
+ case TypeClass_STRING: ret= VT_BSTR;
+ break;
+ case TypeClass_FLOAT: ret= VT_R4;
+ break;
+ case TypeClass_DOUBLE: ret= VT_R8;
+ break;
+ case TypeClass_BYTE: ret= VT_UI1;
+ break;
+ case TypeClass_SHORT: ret= VT_I2;
+ break;
+ case TypeClass_LONG: ret= VT_I4;
+ break;
+ case TypeClass_UNSIGNED_SHORT: ret= VT_UI2;
+ break;
+ case TypeClass_UNSIGNED_LONG: ret= VT_UI4;
+ break;
+ default:
+ ret= VT_EMPTY;
+ }
+ return ret;
+}
+
+template<class T>
+Sequence<Type> UnoConversionUtilities<T>::getImplementedInterfaces(IUnknown* pUnk)
+{
+ Sequence<Type> seqTypes;
+ CComDispatchDriver disp( pUnk);
+ if( disp)
+ {
+ CComVariant var;
+ HRESULT hr= S_OK;
+ // There are two different property names possible.
+ if( FAILED( hr= disp.GetPropertyByName( SUPPORTED_INTERFACES_PROP, &var)))
+ {
+ hr= disp.GetPropertyByName( SUPPORTED_INTERFACES_PROP2, &var);
+ }
+ if (SUCCEEDED( hr))
+ {
+ // we exspect an array( SafeArray or IDispatch) of Strings.
+ Any anyNames;
+ variantToAny( &var, anyNames, getCppuType( (Sequence<Any>*) 0));
+ Sequence<Any> seqAny;
+ if( anyNames >>= seqAny)
+ {
+ seqTypes.realloc( seqAny.getLength());
+ for( sal_Int32 i=0; i < seqAny.getLength(); i++)
+ {
+ OUString typeName;
+ seqAny[i] >>= typeName;
+ seqTypes[i]= Type( TypeClass_INTERFACE, typeName);
+ }
+ }
+ }
+ }
+ return seqTypes;
+}
+template<class T>
+Reference<XTypeConverter> UnoConversionUtilities<T>::getTypeConverter()
+{
+ if ( ! m_typeConverter.is())
+ {
+ MutexGuard guard(getBridgeMutex());
+ if ( ! m_typeConverter.is())
+ {
+ Reference<XInterface> xIntConverter =
+ m_smgr->createInstance(OUSTR("com.sun.star.script.Converter"));
+ if (xIntConverter.is())
+ m_typeConverter = Reference<XTypeConverter>(xIntConverter, UNO_QUERY);
+ }
+ }
+ return m_typeConverter;
+}
+
+// This function tries to the change the type of a value (contained in the Any)
+// to the smallest possible that can hold the value. This is actually done only
+// for types of VT_I4 (see o2u_variantToAny). The reason is the following:
+// JavaScript passes integer values always as VT_I4. If there is a parameter or
+// property of type any then the bridge converts the any's content according
+// to "o2u_variantToAny". Because the VARTYPE is VT_I4 the value would be converted
+// to TypeClass_LONG. Say the method XPropertySet::setPropertyValue( string name, any value)
+// would be called on an object and the property actually is of TypeClass_SHORT.
+// After conversion of the VARIANT parameter the Any would contain type
+// TypeClass_LONG. Because the corereflection does not cast from long to short
+// the "setPropertValue" would fail as the value has not the right type.
+
+// The corereflection does convert small integer types to bigger types.
+// Therefore we can reduce the type if possible and avoid the above mentioned
+// problem.
+
+// The function is not used when elements are to be converted for Sequences.
+
+#ifndef _REDUCE_RANGE
+#define _REDUCE_RANGE
+inline void reduceRange( Any& any)
+{
+ OSL_ASSERT( any.getValueTypeClass() == TypeClass_LONG);
+
+ sal_Int32 value= *(sal_Int32*)any.getValue();
+ if( value <= 0x7f && value >= -0x80)
+ {// -128 bis 127
+ sal_Int8 charVal= static_cast<sal_Int8>( value);
+ any.setValue( &charVal, getCppuType( (sal_Int8*)0));
+ }
+ else if( value <= 0x7fff && value >= -0x8000)
+ {// -32768 bis 32767
+ sal_Int16 shortVal= static_cast<sal_Int16>( value);
+ any.setValue( &shortVal, getCppuType( (sal_Int16*)0));
+ }
+}
+#endif
+
+
+
+} // end namespace
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/ole/unoobjw.cxx b/extensions/source/ole/unoobjw.cxx
new file mode 100644
index 000000000000..9cd131487dc4
--- /dev/null
+++ b/extensions/source/ole/unoobjw.cxx
@@ -0,0 +1,1690 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+
+#include "ole2uno.hxx"
+#include <stdio.h>
+#include <tools/presys.h>
+#include <olectl.h>
+#include <vector>
+#include <list>
+#include <hash_map>
+#include "comifaces.hxx"
+#include <tools/postsys.h>
+
+
+#include <osl/diagnose.h>
+#include <salhelper/simplereferenceobject.hxx>
+#include <tools/debug.hxx>
+#include <rtl/ustring.hxx>
+#include <com/sun/star/beans/MethodConcept.hpp>
+#include <com/sun/star/beans/PropertyConcept.hpp>
+#include <com/sun/star/script/FailReason.hpp>
+#include <com/sun/star/reflection/ParamInfo.hpp>
+#include <com/sun/star/beans/XExactName.hpp>
+#include <com/sun/star/container/NoSuchElementException.hpp>
+
+#include <com/sun/star/beans/XMaterialHolder.hpp>
+#include <com/sun/star/script/XInvocation2.hpp>
+#include <com/sun/star/script/MemberType.hpp>
+#include <com/sun/star/reflection/XIdlReflection.hpp>
+#include <osl/interlck.h>
+#include <com/sun/star/uno/genfunc.h>
+#include <cppuhelper/implbase1.hxx>
+
+#include "comifaces.hxx"
+#include "jscriptclasses.hxx"
+#include "unotypewrapper.hxx"
+#include "oleobjw.hxx"
+#include "unoobjw.hxx"
+#include "servprov.hxx"
+
+using namespace std;
+using namespace rtl;
+using namespace osl;
+using namespace cppu;
+using namespace com::sun::star::uno;
+using namespace com::sun::star::beans;
+using namespace com::sun::star::container;
+using namespace com::sun::star::script;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::bridge::ModelDependent;
+using namespace com::sun::star::reflection;
+
+
+
+#if _MSC_VER < 1200
+extern "C" const GUID IID_IDispatchEx;
+#endif
+
+namespace ole_adapter
+{
+hash_map<sal_uInt32, WeakReference<XInterface> > UnoObjToWrapperMap;
+static sal_Bool writeBackOutParameter(VARIANTARG* pDest, VARIANT* pSource);
+static sal_Bool writeBackOutParameter2( VARIANTARG* pDest, VARIANT* pSource);
+static HRESULT mapCannotConvertException( CannotConvertException e, unsigned int * puArgErr);
+
+
+/* Does not throw any exceptions.
+ Param pInfo can be NULL.
+ */
+static void writeExcepinfo(EXCEPINFO * pInfo, const OUString& message)
+{
+ if (pInfo != NULL)
+ {
+ pInfo->wCode = UNO_2_OLE_EXCEPTIONCODE;
+ pInfo->bstrSource = SysAllocString(L"[automation bridge] ");
+ pInfo->bstrDescription = SysAllocString(reinterpret_cast<LPCOLESTR>(message.getStr()));
+ }
+}
+
+/*****************************************************************************
+
+ class implementation: InterfaceOleWrapper_Impl
+
+*****************************************************************************/
+InterfaceOleWrapper_Impl::InterfaceOleWrapper_Impl( Reference<XMultiServiceFactory>& xFactory,
+ sal_uInt8 unoWrapperClass, sal_uInt8 comWrapperClass):
+ m_defaultValueType( 0),
+ UnoConversionUtilities<InterfaceOleWrapper_Impl>( xFactory, unoWrapperClass, comWrapperClass)
+{
+}
+
+InterfaceOleWrapper_Impl::~InterfaceOleWrapper_Impl()
+{
+ MutexGuard guard(getBridgeMutex());
+ // remove entries in global map
+ IT_Uno it= UnoObjToWrapperMap.find( (sal_uInt32) m_xOrigin.get());
+ if(it != UnoObjToWrapperMap.end())
+ UnoObjToWrapperMap.erase(it);
+#if OSL_DEBUG_LEVEL > 0
+ fprintf(stderr,"[automation bridge] UnoObjToWrapperMap contains: %i \n",
+ UnoObjToWrapperMap.size());
+#endif
+
+}
+
+STDMETHODIMP InterfaceOleWrapper_Impl::QueryInterface(REFIID riid, LPVOID FAR * ppv)
+{
+ HRESULT ret= S_OK;
+
+ if( !ppv)
+ return E_POINTER;
+
+ if(IsEqualIID(riid, IID_IUnknown))
+ {
+ AddRef();
+ *ppv = (IUnknown*) (IDispatch*) this;
+ }
+ else if (IsEqualIID(riid, IID_IDispatch))
+ {
+ AddRef();
+ *ppv = (IDispatch*) this;
+ }
+ else if( IsEqualIID( riid, __uuidof( IUnoObjectWrapper)))
+ {
+ AddRef();
+ *ppv= (IUnoObjectWrapper*) this;
+ }
+ else
+ ret= E_NOINTERFACE;
+ return ret;
+}
+
+STDMETHODIMP_(ULONG) InterfaceOleWrapper_Impl::AddRef()
+{
+ acquire();
+ // does not need to guard because one should not rely on the return value of
+ // AddRef anyway
+ return m_refCount;
+}
+
+STDMETHODIMP_(ULONG) InterfaceOleWrapper_Impl::Release()
+{
+ ULONG n= m_refCount;
+ release();
+ return n - 1;
+}
+
+// IUnoObjectWrapper --------------------------------------------------------
+STDMETHODIMP InterfaceOleWrapper_Impl::getWrapperXInterface( Reference<XInterface>* pXInt)
+{
+ *pXInt= Reference<XInterface>( static_cast<XWeak*>( this), UNO_QUERY);
+ return pXInt->is() ? S_OK : E_FAIL;
+}
+STDMETHODIMP InterfaceOleWrapper_Impl::getOriginalUnoObject( Reference<XInterface>* pXInt)
+{
+ *pXInt= m_xOrigin;
+ return m_xOrigin.is() ? S_OK : E_FAIL;
+}
+STDMETHODIMP InterfaceOleWrapper_Impl::getOriginalUnoStruct( Any * pStruct)
+{
+ HRESULT ret= E_FAIL;
+ if( !m_xOrigin.is())
+ {
+ Reference<XMaterialHolder> xMatHolder( m_xInvocation, UNO_QUERY);
+ if( xMatHolder.is())
+ {
+ Any any = xMatHolder->getMaterial();
+ if( any.getValueTypeClass() == TypeClass_STRUCT)
+ {
+ *pStruct= any;
+ ret= S_OK;
+ }
+ }
+ }
+ return ret;
+}
+
+STDMETHODIMP InterfaceOleWrapper_Impl::GetTypeInfoCount( unsigned int * /*pctinfo*/ )
+{
+ return E_NOTIMPL ;
+}
+
+STDMETHODIMP InterfaceOleWrapper_Impl::GetTypeInfo(unsigned int /*itinfo*/, LCID /*lcid*/, ITypeInfo ** /*pptinfo*/)
+{
+ return E_NOTIMPL;
+}
+
+STDMETHODIMP InterfaceOleWrapper_Impl::GetIDsOfNames(REFIID /*riid*/,
+ OLECHAR ** rgszNames,
+ unsigned int cNames,
+ LCID /*lcid*/,
+ DISPID * rgdispid )
+{
+ HRESULT ret = DISP_E_UNKNOWNNAME;
+ try
+ {
+ MutexGuard guard( getBridgeMutex());
+ if( ! rgdispid)
+ return E_POINTER;
+
+ // ----------------------------------------
+ if( ! _wcsicmp( *rgszNames, JSCRIPT_VALUE_FUNC) ||
+ ! _wcsicmp( *rgszNames, BRIDGE_VALUE_FUNC))
+ {
+ *rgdispid= DISPID_JSCRIPT_VALUE_FUNC;
+ return S_OK;
+ }
+ else if( ! _wcsicmp( *rgszNames, GET_STRUCT_FUNC) ||
+ ! _wcsicmp( *rgszNames, BRIDGE_GET_STRUCT_FUNC))
+ {
+ *rgdispid= DISPID_GET_STRUCT_FUNC;
+ return S_OK;
+ }
+ else if( ! _wcsicmp( *rgszNames, BRIDGE_CREATE_TYPE_FUNC))
+ {
+ *rgdispid= DISPID_CREATE_TYPE_FUNC;
+ return S_OK;
+ }
+
+ // ----------------------------------------
+ if (m_xInvocation.is() && (cNames > 0))
+ {
+ OUString name(reinterpret_cast<const sal_Unicode*>(rgszNames[0]));
+ NameToIdMap::iterator iter = m_nameToDispIdMap.find(name);
+
+ if (iter == m_nameToDispIdMap.end())
+ {
+ OUString exactName;
+
+ if (m_xExactName.is())
+ {
+ exactName = m_xExactName->getExactName(name);
+ }
+ else
+ {
+ exactName = name;
+ }
+
+ MemberInfo d(0, exactName);
+
+ if (m_xInvocation->hasProperty(exactName))
+ {
+ d.flags |= DISPATCH_PROPERTYGET;
+ d.flags |= DISPATCH_PROPERTYPUT;
+ d.flags |= DISPATCH_PROPERTYPUTREF;
+ }
+
+ if (m_xInvocation->hasMethod(exactName))
+ {
+ d.flags |= DISPATCH_METHOD;
+ }
+
+ if (d.flags != 0)
+ {
+ m_MemberInfos.push_back(d);
+ iter = m_nameToDispIdMap.insert(NameToIdMap::value_type(exactName, (DISPID)m_MemberInfos.size())).first;
+
+ if (exactName != name)
+ {
+ iter = m_nameToDispIdMap.insert(NameToIdMap::value_type(name, (DISPID)m_MemberInfos.size())).first;
+ }
+ }
+ }
+
+ if (iter == m_nameToDispIdMap.end())
+ {
+ ret = DISP_E_UNKNOWNNAME;
+ }
+ else
+ {
+ *rgdispid = (*iter).second;
+ ret = S_OK;
+ }
+ }
+ }
+ catch(BridgeRuntimeError& )
+ {
+ OSL_ASSERT(0);
+ }
+ catch(Exception& )
+ {
+ OSL_ASSERT(0);
+ }
+ catch(...)
+ {
+ OSL_ASSERT(0);
+ }
+
+ return ret;
+}
+
+// "convertDispparamsArgs" converts VARIANTS to their respecting Any counterparts
+// The parameters "id", "wFlags" and "pdispparams" equal those as used in
+// IDispatch::Invoke. The function handles special JavaScript
+// cases where a VARIANT of type VT_DISPATCH is ambiguous and could represent
+// an object, array ( JavaScript Array object), out parameter and in/out ( JavaScript Array object)
+// parameter (JavaScript Array object)
+// Because all those VT_DISPATCH objects need a different conversion
+// we have to find out what the object is supposed to be. The function does this
+// by either using type information or by help of a specialized ValueObject object.
+
+// A. Type Information
+// -----------------------------------------------------------------------------
+// With the help of type information the kind of parameter can be exactly determined
+// and an appropriate conversion can be choosen. A problem arises if a method expects
+// an Any. Then the type info does not tell what the type of the value, that is kept
+// by the any, should be. In this situation the decision wheter the param is a
+// sequence or an object is made upon the fact if the object has a property "0"
+// ( see function "isJScriptArray"). Since this is unsafe it is recommended to use
+// the JScript value objects within a JScript script on such an occasion.
+
+// B. JavaScript Value Object ( class JScriptValue )
+// -----------------------------------------------------------------------------
+// A JScriptValue (ValueObject) object is a COM object in that it implements IDispatch and the
+// IJScriptValue object interface. Such objects are provided by all UNO wrapper
+// objects used within a JScript script. To obtain an instance one has to call
+// "_GetValueObject() or Bridge_GetValueObject()" on an UNO wrapper object (class InterfaceOleWrapper_Impl).
+// A value object is appropriately initialized within the script and passed as
+// parameter to an UNO object method or property. The convertDispparamsArgs function
+// can easily find out that a param is such an object by queriing for the
+// IJScriptValue interface. By this interface one the type and kind ( out, in/out)
+// can be determined and the right conversion can be applied.
+// Using ValueObjects we spare us the effort of aquiring and examining type information
+// in order to figure out what the an IDispatch parameter is meant for.
+
+// Normal JScript object parameter can be mixed with JScriptValue object. If an
+// VARIANT contains an VT_DISPATCH that is no JScriptValue than the type information
+// is used to find out about the reqired type.
+void InterfaceOleWrapper_Impl::convertDispparamsArgs(DISPID id,
+ unsigned short /*wFlags*/, DISPPARAMS* pdispparams, Sequence<Any>& rSeq)
+{
+ HRESULT hr= S_OK;
+ sal_Int32 countArgs= pdispparams->cArgs;
+ if( countArgs == 0)
+ return;
+
+ rSeq.realloc( countArgs);
+ Any* pParams = rSeq.getArray();
+
+ Any anyParam;
+
+ //Get type information for the current call
+ InvocationInfo info;
+ if( ! getInvocationInfoForCall( id, info))
+ throw BridgeRuntimeError(
+ OUSTR("[automation bridge]InterfaceOleWrapper_Impl::convertDispparamsArgs \n"
+ "Could not obtain type information for current call."));
+
+ for (int i = 0; i < countArgs; i++)
+ {
+ if (info.eMemberType == MemberType_METHOD &&
+ info.aParamModes[ countArgs - i -1 ] == ParamMode_OUT)
+ continue;
+
+ if(convertValueObject( & pdispparams->rgvarg[i], anyParam))
+ { //a param is a ValueObject and could be converted
+ pParams[countArgs - (i + 1)] = anyParam;
+ continue;
+ }
+
+ // If the param is an out, in/out parameter in
+ // JScript (Array object, with value at index 0) then we
+ // extract Array[0] and put the value into varParam. At the end of the loop varParam
+ // is converted if it contains a value otherwise the VARIANT from
+ // DISPPARAMS is converted.
+ CComVariant varParam;
+
+ // Check for JScript out and in/out paramsobjects (VT_DISPATCH).
+ // To find them out we use typeinformation of the function being called.
+ if( pdispparams->rgvarg[i].vt == VT_DISPATCH )
+ {
+ if( info.eMemberType == MemberType_METHOD && info.aParamModes[ countArgs - i -1 ] == ParamMode_INOUT)
+ {
+ // INOUT-param
+ // Index ( property) "0" contains the actual IN-param. The object is a JScript
+ // Array object.
+ // Get the IN-param at index "0"
+ IDispatch* pdisp= pdispparams->rgvarg[i].pdispVal;
+
+ OLECHAR* sindex= L"0";
+ DISPID id;
+ DISPPARAMS noParams= {0,0,0,0};
+ if(SUCCEEDED( hr= pdisp->GetIDsOfNames( IID_NULL, &sindex, 1, LOCALE_USER_DEFAULT, &id)))
+ hr= pdisp->Invoke( id, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_PROPERTYGET,
+ & noParams, & varParam, NULL, NULL);
+ if( FAILED( hr))
+ {
+ throw BridgeRuntimeError(
+ OUSTR("[automation bridge] Could not determine "
+ "if the object has a member \"0\". Error: ") +
+ OUString::valueOf(hr));
+ }
+ }
+ }
+
+ if( varParam.vt == VT_EMPTY) // then it was no in/out parameter
+ varParam= pdispparams->rgvarg[i];
+
+ if(info.eMemberType == MemberType_METHOD)
+ variantToAny( & varParam, anyParam,
+ info.aParamTypes[ countArgs - i - 1]);
+ else if(info.eMemberType == MemberType_PROPERTY)
+ variantToAny( & varParam, anyParam, info.aType);
+ else
+ OSL_ASSERT(0);
+
+ pParams[countArgs - (i + 1)]= anyParam;
+ }// end for / iterating over all parameters
+}
+
+sal_Bool InterfaceOleWrapper_Impl::getInvocationInfoForCall( DISPID id, InvocationInfo& info)
+{
+ sal_Bool bTypesAvailable= sal_False;
+
+ if( !m_xInvocation.is() )return false;
+ Reference<XInvocation2> inv2( m_xInvocation, UNO_QUERY);
+ if( inv2.is())
+ {
+ // We need the name of the property or method to get its type information.
+ // The name can be identified through the param "id"
+ // that is kept as value in the map m_nameToDispIdMap.
+ // Proplem: the Windows JScript engine sometimes changes small letters to capital
+ // letters as happens in xidlclass_obj.createObject( var) // in JScript.
+ // IDispatch::GetIdsOfNames is then called with "CreateObject" !!!
+ // m_nameToDispIdMap can contain several names for one DISPID but only one is
+ // the exact one. If there's no m_xExactName and therefore no exact name then
+ // there's only one entry in the map.
+ typedef NameToIdMap::const_iterator cit;
+ OUString sMemberName;
+
+ for(cit ci1= m_nameToDispIdMap.begin(); ci1 != m_nameToDispIdMap.end(); ci1++)
+ {
+ if( (*ci1).second == id) // iterator is a pair< OUString, DISPID>
+ {
+ sMemberName= (*ci1).first;
+ break;
+ }
+ }
+ // Get information for the current call ( property or method).
+ // There could be similar names which only differ in the cases
+ // of letters. First we assume that the name which was passed into
+ // GetIDsOfNames is correct. If we won't get information with that
+ // name then we have the invocation service use the XExactName interface.
+ sal_Bool validInfo= sal_True;
+ InvocationInfo invInfo;
+ try{
+ invInfo= inv2->getInfoForName( sMemberName, sal_False);
+ }
+ catch( IllegalArgumentException )
+ {
+ validInfo= sal_False;
+ }
+
+ if( ! validInfo)
+ {
+ invInfo= inv2->getInfoForName( sMemberName, sal_True);
+ }
+ if( invInfo.aName.pData)
+ {
+ bTypesAvailable= sal_True;
+ info= invInfo;
+ }
+ }
+ return bTypesAvailable;
+}
+// XBridgeSupplier2 ---------------------------------------------------
+// only bridges itself ( this instance of InterfaceOleWrapper_Impl)from UNO to IDispatch
+// If sourceModelType is UNO than any UNO interface implemented by InterfaceOleWrapper_Impl
+// can bridged to IDispatch ( if destModelType == OLE). The IDispatch is
+// implemented by this class.
+Any SAL_CALL InterfaceOleWrapper_Impl::createBridge(const Any& modelDepObject,
+ const Sequence<sal_Int8>& /*ProcessId*/,
+ sal_Int16 sourceModelType,
+ sal_Int16 destModelType)
+ throw (IllegalArgumentException, RuntimeException)
+{
+
+ Any retAny;
+ if( sourceModelType == UNO && destModelType == OLE &&
+ modelDepObject.getValueTypeClass() == TypeClass_INTERFACE )
+ {
+ Reference<XInterface> xInt;
+ if( modelDepObject >>= xInt )
+ {
+ if( xInt == Reference<XInterface>( static_cast<XWeak*>( this), UNO_QUERY))
+ {
+ VARIANT *pVar= (VARIANT*)CoTaskMemAlloc( sizeof( VARIANT));
+ if( pVar)
+ {
+ pVar->vt= VT_DISPATCH;
+ pVar->pdispVal= static_cast<IDispatch*>( this);
+ AddRef();
+
+ retAny<<= reinterpret_cast< sal_uInt32 >( pVar);
+ }
+ }
+ }
+ }
+
+ return retAny;
+}
+
+
+// XInitialization --------------------------------------------------
+void SAL_CALL InterfaceOleWrapper_Impl::initialize( const Sequence< Any >& aArguments )
+ throw(Exception, RuntimeException)
+{
+ switch( aArguments.getLength() )
+ {
+ case 2: // the object wraps an UNO struct
+ aArguments[0] >>= m_xInvocation;
+ aArguments[1] >>= m_defaultValueType;
+ break;
+ case 3: // the object wraps an UNO interface
+ aArguments[0] >>= m_xInvocation;
+ aArguments[1] >>= m_xOrigin;
+ aArguments[2] >>= m_defaultValueType;
+ break;
+ }
+
+ m_xExactName= Reference<XExactName>( m_xInvocation, UNO_QUERY);
+}
+
+Reference< XInterface > InterfaceOleWrapper_Impl::createUnoWrapperInstance()
+{
+ Reference<XWeak> xWeak= static_cast<XWeak*>( new InterfaceOleWrapper_Impl(
+ m_smgr, m_nUnoWrapperClass, m_nComWrapperClass));
+ return Reference<XInterface>( xWeak, UNO_QUERY);
+}
+
+Reference<XInterface> InterfaceOleWrapper_Impl::createComWrapperInstance()
+{
+ Reference<XWeak> xWeak= static_cast<XWeak*>( new IUnknownWrapper_Impl(
+ m_smgr, m_nUnoWrapperClass, m_nComWrapperClass));
+ return Reference<XInterface>( xWeak, UNO_QUERY);
+}
+
+
+
+// "getType" is used in convertValueObject to map the string denoting the type
+// to an actual Type object.
+bool getType( const BSTR name, Type & type)
+{
+ Type retType;
+ bool ret = false;
+ typelib_TypeDescription * pDesc= NULL;
+ OUString str( reinterpret_cast<const sal_Unicode*>(name));
+ typelib_typedescription_getByName( &pDesc, str.pData );
+ if( pDesc)
+ {
+ type = Type( pDesc->pWeakRef );
+ typelib_typedescription_release( pDesc);
+ ret = true;
+ }
+ return ret;
+}
+
+static sal_Bool writeBackOutParameter2( VARIANTARG* pDest, VARIANT* pSource)
+{
+ sal_Bool ret = sal_False;
+ HRESULT hr;
+
+ // Handle JScriptValue objects and JScript out params ( Array object )
+ CComVariant varDest( *pDest);
+
+ if( SUCCEEDED( varDest.ChangeType(VT_DISPATCH)))
+ {
+ CComPtr<IDispatch> spDispDest(varDest.pdispVal);
+
+ // special Handling for a JScriptValue object
+#ifdef __MINGW32__
+ CComQIPtr<IJScriptValueObject, &__uuidof(IJScriptValueObject)> spValueDest(spDispDest);
+#else
+ CComQIPtr<IJScriptValueObject> spValueDest(spDispDest);
+#endif
+ if (spValueDest)
+ {
+ VARIANT_BOOL varBool= VARIANT_FALSE;
+ if( SUCCEEDED( hr= spValueDest->IsOutParam( &varBool) )
+ && varBool == VARIANT_TRUE ||
+ SUCCEEDED(hr= spValueDest->IsInOutParam( &varBool) )
+ && varBool == VARIANT_TRUE )
+ {
+ if( SUCCEEDED( spValueDest->Set( CComVariant(), *pSource)))
+ ret= sal_True;
+ }
+ }
+ else if (pDest->vt == VT_DISPATCH)// VT_DISPATCH -> JScript out param
+ {
+ // We use IDispatchEx because its GetDispID function causes the creation
+ // of a property if it does not exist already. This is convenient for
+ // out parameters in JScript. Then the user must not specify propery "0"
+ // explicitly
+#ifdef __MINGW32__
+ CComQIPtr<IDispatchEx, &__uuidof(IDispatchEx)> spDispEx( spDispDest);
+#else
+ CComQIPtr<IDispatchEx> spDispEx( spDispDest);
+#endif
+ if( spDispEx)
+ {
+ CComBSTR nullProp(L"0");
+ DISPID dwDispID;
+ if( SUCCEEDED( spDispEx->GetDispID( nullProp, fdexNameEnsure, &dwDispID)))
+ {
+ DISPPARAMS dispparams = {NULL, NULL, 1, 1};
+ dispparams.rgvarg = pSource;
+ DISPID dispidPut = DISPID_PROPERTYPUT;
+ dispparams.rgdispidNamedArgs = &dispidPut;
+
+ if (pSource->vt == VT_UNKNOWN || pSource->vt == VT_DISPATCH ||
+ (pSource->vt & VT_ARRAY) || (pSource->vt & VT_BYREF))
+ hr = spDispEx->InvokeEx(dwDispID, LOCALE_USER_DEFAULT, DISPATCH_PROPERTYPUTREF,
+ &dispparams, NULL, NULL, NULL);
+ else
+ hr= spDispEx->InvokeEx(dwDispID, LOCALE_USER_DEFAULT, DISPATCH_PROPERTYPUT,
+ &dispparams, NULL, NULL, NULL);
+ if( SUCCEEDED(hr))
+ ret= sal_True;
+ }
+ }
+ }
+ else
+ ret= writeBackOutParameter( pDest, pSource);
+ }
+ else // The param can't be a JScript out-parameter ( an Array object), it could be a VBScript
+ { // param. The function checks itself for correct VBScript params
+ ret= writeBackOutParameter( pDest, pSource);
+ }
+ return ret;
+}
+// VisualBasic Script passes arguments as VT_VARIANT | VT_BYREF be it in or out parameter.
+// Thus we are in charge of freeing an eventual value contained by the inner VARIANT
+// Please note: VariantCopy doesn't free a VT_BYREF value
+// The out parameters are expected to have always a valid type
+static sal_Bool writeBackOutParameter(VARIANTARG* pDest, VARIANT* pSource)
+{
+ HRESULT hr;
+ sal_Bool ret = FALSE;
+ // Out parameter must be VT_BYREF
+ if ((V_VT(pDest) & VT_BYREF) != 0 )
+ {
+ VARTYPE oleTypeFlags = V_VT(pSource);
+
+ // if caller accept VARIANT as out parameter, any value must be converted
+ if (V_VT(pDest) == (VT_VARIANT | VT_BYREF))
+ {
+ // When the user provides a VARIANT rather then a concrete type
+ // we just copy the source to the out, in/out parameter
+ // VT_DISPATCH, VT_UNKNOWN, VT_ARRAY, VT_BSTR in the VARIANT that
+ // is contained in pDest are released by VariantCopy
+ VariantCopy(V_VARIANTREF(pDest), pSource);
+ ret = sal_True;
+ }
+ else
+ {
+ // variantarg and variant must have same type
+ if ((V_VT(pDest) & oleTypeFlags) == oleTypeFlags)
+ {
+ if ((oleTypeFlags & VT_ARRAY) != 0)
+ {
+ // In / Out Param
+ if( *V_ARRAYREF(pDest) != NULL)
+ hr= SafeArrayCopyData( V_ARRAY(pSource), *V_ARRAYREF(pDest));
+ else
+ // Out Param
+ hr= SafeArrayCopy(V_ARRAY(pSource), V_ARRAYREF(pDest)) == NOERROR;
+ if( SUCCEEDED( hr))
+ ret = sal_True;
+ }
+ else
+ {
+ // copy base type
+ switch (V_VT(pSource))
+ {
+ case VT_I2:
+ {
+ *V_I2REF(pDest) = V_I2(pSource);
+ ret = sal_True;
+ break;
+ }
+ case VT_I4:
+ *V_I4REF(pDest) = V_I4(pSource);
+ ret = sal_True;
+ break;
+ case VT_R4:
+ *V_R4REF(pDest) = V_R4(pSource);
+ ret = sal_True;
+ break;
+ case VT_R8:
+ *V_R8REF(pDest) = V_R8(pSource);
+ ret = sal_True;
+ break;
+ case VT_CY:
+ *V_CYREF(pDest) = V_CY(pSource);
+ ret = sal_True;
+ break;
+ case VT_DATE:
+ *V_DATEREF(pDest) = V_DATE(pSource);
+ ret = sal_True;
+ break;
+ case VT_BSTR:
+ SysFreeString( *pDest->pbstrVal);
+
+ *V_BSTRREF(pDest) = SysAllocString(V_BSTR(pSource));
+ ret = sal_True;
+ break;
+ case VT_DISPATCH:
+ if (*V_DISPATCHREF(pDest) != NULL)
+ (*V_DISPATCHREF(pDest))->Release();
+
+ *V_DISPATCHREF(pDest) = V_DISPATCH(pSource);
+
+ if (*V_DISPATCHREF(pDest) != NULL)
+ (*V_DISPATCHREF(pDest))->AddRef();
+
+ ret = sal_True;
+ break;
+ case VT_ERROR:
+ *V_ERRORREF(pDest) = V_ERROR(pSource);
+ ret = sal_True;
+ break;
+ case VT_BOOL:
+ *V_BOOLREF(pDest) = V_BOOL(pSource);
+ ret = sal_True;
+ break;
+ case VT_UNKNOWN:
+ if (*V_UNKNOWNREF(pDest) != NULL)
+ (*V_UNKNOWNREF(pDest))->Release();
+
+ *V_UNKNOWNREF(pDest) = V_UNKNOWN(pSource);
+
+ if (*V_UNKNOWNREF(pDest) != NULL)
+ (*V_UNKNOWNREF(pDest))->AddRef();
+
+ ret = sal_True;
+ break;
+ case VT_I1:
+ *V_I1REF(pDest) = V_I1(pSource);
+ ret = sal_True;
+ break;
+ case VT_UI1:
+ *V_UI1REF(pDest) = V_UI1(pSource);
+ ret = sal_True;
+ break;
+ case VT_UI2:
+ *V_UI2REF(pDest) = V_UI2(pSource);
+ ret = sal_True;
+ break;
+ case VT_UI4:
+ *V_UI4REF(pDest) = V_UI4(pSource);
+ ret = sal_True;
+ break;
+ case VT_INT:
+ *V_INTREF(pDest) = V_INT(pSource);
+ ret = sal_True;
+ break;
+ case VT_UINT:
+ *V_UINTREF(pDest) = V_UINT(pSource);
+ ret = sal_True;
+ break;
+ case VT_DECIMAL:
+ memcpy(pDest->pdecVal, pSource, sizeof(DECIMAL));
+ ret = sal_True;
+ break;
+ default:
+ break;
+ }
+ }
+ }
+ else
+ {
+ // Handling of special cases
+ // Destination and source types are different
+ if( pDest->vt == (VT_BSTR | VT_BYREF)
+ && pSource->vt == VT_I2)
+ {
+ // When the user provides a String as out our in/out parameter
+ // and the type is char (TypeClass_CHAR) then we convert to a BSTR
+ // instead of VT_I2 as is done otherwise
+ OLECHAR buff[]= {0,0};
+ buff[0]= pSource->iVal;
+
+ SysFreeString( *pDest->pbstrVal);
+ *pDest->pbstrVal= SysAllocString( buff);
+ ret = sal_True;
+ }
+ }
+ }
+ }
+ return ret;
+}
+
+STDMETHODIMP InterfaceOleWrapper_Impl::Invoke(DISPID dispidMember,
+ REFIID /*riid*/,
+ LCID /*lcid*/,
+ unsigned short wFlags,
+ DISPPARAMS * pdispparams,
+ VARIANT * pvarResult,
+ EXCEPINFO * pexcepinfo,
+ unsigned int * puArgErr )
+{
+ HRESULT ret = S_OK;
+
+ try
+ {
+ sal_Bool bHandled= sal_False;
+ ret= InvokeGeneral( dispidMember, wFlags, pdispparams, pvarResult, pexcepinfo,
+ puArgErr, bHandled);
+ if( bHandled)
+ return ret;
+
+ if ((dispidMember > 0) && ((size_t)dispidMember <= m_MemberInfos.size()) && m_xInvocation.is())
+ {
+ MemberInfo d = m_MemberInfos[dispidMember - 1];
+ DWORD flags = wFlags & d.flags;
+
+ if (flags != 0)
+ {
+ if ((flags & DISPATCH_METHOD) != 0)
+ {
+ if (pdispparams->cNamedArgs > 0)
+ ret = DISP_E_NONAMEDARGS;
+ else
+ {
+ Sequence<Any> params;
+
+ convertDispparamsArgs(dispidMember, wFlags, pdispparams , params );
+
+ ret= doInvoke(pdispparams, pvarResult,
+ pexcepinfo, puArgErr, d.name, params);
+ }
+ }
+ else if ((flags & DISPATCH_PROPERTYGET) != 0)
+ {
+ ret= doGetProperty( pdispparams, pvarResult,
+ pexcepinfo, d.name);
+ }
+ else if ((flags & DISPATCH_PROPERTYPUT || flags & DISPATCH_PROPERTYPUTREF) != 0)
+ {
+ if (pdispparams->cArgs != 1)
+ ret = DISP_E_BADPARAMCOUNT;
+ else
+ {
+ Sequence<Any> params;
+ convertDispparamsArgs(dispidMember, wFlags, pdispparams, params );
+ if(params.getLength() > 0)
+ ret= doSetProperty( pdispparams, pvarResult, pexcepinfo, puArgErr, d.name, params);
+ else
+ ret = DISP_E_BADVARTYPE;
+ }
+ }
+ }
+ else
+ ret= DISP_E_MEMBERNOTFOUND;
+ }
+ else
+ ret = DISP_E_MEMBERNOTFOUND;
+ }
+ catch(BridgeRuntimeError& e)
+ {
+ writeExcepinfo(pexcepinfo, e.message);
+ ret = DISP_E_EXCEPTION;
+ }
+ catch(Exception& e)
+ {
+ OUString message= OUSTR("InterfaceOleWrapper_Impl::Invoke : \n") +
+ e.Message;
+ writeExcepinfo(pexcepinfo, message);
+ ret = DISP_E_EXCEPTION;
+ }
+ catch(...)
+ {
+ OUString message= OUSTR("InterfaceOleWrapper_Impl::Invoke : \n"
+ "Unexpected exception");
+ writeExcepinfo(pexcepinfo, message);
+ ret = DISP_E_EXCEPTION;
+ }
+
+ return ret;
+}
+
+HRESULT InterfaceOleWrapper_Impl::doInvoke( DISPPARAMS * pdispparams, VARIANT * pvarResult,
+ EXCEPINFO * pexcepinfo, unsigned int * puArgErr, OUString& name, Sequence<Any>& params)
+{
+
+
+ HRESULT ret= S_OK;
+ try
+ {
+ Sequence<INT16> outIndex;
+ Sequence<Any> outParams;
+ Any returnValue;
+
+ if (pdispparams->cNamedArgs > 0)
+ return DISP_E_NONAMEDARGS;
+
+ // invoke method and take care of exceptions
+ returnValue = m_xInvocation->invoke(name,
+ params,
+ outIndex,
+ outParams);
+
+ // try to write back out parameter
+ if (outIndex.getLength() > 0)
+ {
+ const INT16* pOutIndex = outIndex.getConstArray();
+ const Any* pOutParams = outParams.getConstArray();
+
+ for (sal_Int32 i = 0; i < outIndex.getLength(); i++)
+ {
+ CComVariant variant;
+ // Currently a Sequence is converted to an SafeArray of VARIANTs.
+ anyToVariant( &variant, pOutParams[i]);
+
+ // out parameter need special handling if they are VT_DISPATCH
+ // and used in JScript
+ int outindex= pOutIndex[i];
+ writeBackOutParameter2(&(pdispparams->rgvarg[pdispparams->cArgs - 1 - outindex]),
+ &variant );
+ }
+ }
+
+ // write back return value
+ if (pvarResult != NULL)
+ anyToVariant(pvarResult, returnValue);
+ }
+ catch(IllegalArgumentException & e) //XInvocation::invoke
+ {
+ writeExcepinfo(pexcepinfo, e.Message);
+ ret = DISP_E_TYPEMISMATCH;
+ }
+ catch(CannotConvertException & e) //XInvocation::invoke
+ {
+ writeExcepinfo(pexcepinfo, e.Message);
+ ret = mapCannotConvertException( e, puArgErr);
+ }
+ catch(InvocationTargetException & e) //XInvocation::invoke
+ {
+ const Any& org = e.TargetException;
+ Exception excTarget;
+ org >>= excTarget;
+ OUString message=
+ org.getValueType().getTypeName() + OUSTR(": ") + excTarget.Message;
+ writeExcepinfo(pexcepinfo, message);
+ ret = DISP_E_EXCEPTION;
+ }
+ catch(NoSuchMethodException & e) //XInvocation::invoke
+ {
+ writeExcepinfo(pexcepinfo, e.Message);
+ ret = DISP_E_MEMBERNOTFOUND;
+ }
+ catch(BridgeRuntimeError & e)
+ {
+ writeExcepinfo(pexcepinfo, e.message);
+ ret = DISP_E_EXCEPTION;
+ }
+ catch(Exception & e)
+ {
+ OUString message= OUSTR("InterfaceOleWrapper_Impl::doInvoke : \n") +
+ e.Message;
+ writeExcepinfo(pexcepinfo, message);
+ ret = DISP_E_EXCEPTION;
+ }
+ catch( ... )
+ {
+ OUString message= OUSTR("InterfaceOleWrapper_Impl::doInvoke : \n"
+ "Unexpected exception");
+ writeExcepinfo(pexcepinfo, message);
+ ret = DISP_E_EXCEPTION;
+ }
+ return ret;
+}
+
+HRESULT InterfaceOleWrapper_Impl::doGetProperty( DISPPARAMS * /*pdispparams*/, VARIANT * pvarResult,
+ EXCEPINFO * pexcepinfo, OUString& name)
+{
+ HRESULT ret= S_OK;
+
+ Any value;
+ try
+ {
+ Any returnValue = m_xInvocation->getValue( name);
+ // write back return value
+ if (pvarResult)
+ anyToVariant(pvarResult, returnValue);
+ }
+ catch(UnknownPropertyException e) //XInvocation::getValue
+ {
+ writeExcepinfo(pexcepinfo, e.Message);
+ ret = DISP_E_MEMBERNOTFOUND;
+ }
+ catch(BridgeRuntimeError& e)
+ {
+ writeExcepinfo(pexcepinfo, e.message);
+ ret = DISP_E_EXCEPTION;
+ }
+ catch(Exception& e)
+ {
+ OUString message= OUSTR("InterfaceOleWrapper_Impl::doGetProperty : \n") +
+ e.Message;
+ writeExcepinfo(pexcepinfo, message);
+ }
+ catch( ... )
+ {
+ OUString message= OUSTR("InterfaceOleWrapper_Impl::doInvoke : \n"
+ "Unexpected exception");
+ writeExcepinfo(pexcepinfo, message);
+ ret = DISP_E_EXCEPTION;
+ }
+ return ret;
+}
+
+HRESULT InterfaceOleWrapper_Impl::doSetProperty( DISPPARAMS * /*pdispparams*/, VARIANT * /*pvarResult*/,
+ EXCEPINFO * pexcepinfo, unsigned int * puArgErr, OUString& name, Sequence<Any> params)
+{
+ HRESULT ret= S_OK;
+
+ try
+ {
+ m_xInvocation->setValue( name, params.getConstArray()[0]);
+ }
+ catch(UnknownPropertyException )
+ {
+ ret = DISP_E_MEMBERNOTFOUND;
+ }
+ catch(CannotConvertException e)
+ {
+ ret= mapCannotConvertException( e, puArgErr);
+ }
+ catch(InvocationTargetException e)
+ {
+ if (pexcepinfo != NULL)
+ {
+ Any org = e.TargetException;
+
+ pexcepinfo->wCode = UNO_2_OLE_EXCEPTIONCODE;
+ pexcepinfo->bstrSource = SysAllocString(L"any ONE component");
+ pexcepinfo->bstrDescription = SysAllocString(
+ reinterpret_cast<LPCOLESTR>(org.getValueType().getTypeName().getStr()));
+ }
+ ret = DISP_E_EXCEPTION;
+ }
+ catch( ... )
+ {
+ ret= DISP_E_EXCEPTION;
+ }
+ return ret;
+}
+
+HRESULT InterfaceOleWrapper_Impl::InvokeGeneral( DISPID dispidMember, unsigned short wFlags,
+ DISPPARAMS * pdispparams, VARIANT * pvarResult, EXCEPINFO * pexcepinfo,
+ unsigned int * /*puArgErr*/, sal_Bool& bHandled)
+{
+ HRESULT ret= S_OK;
+ try
+ {
+// DISPID_VALUE | The DEFAULT Value is required in JScript when the situation
+// is that we put an object into an Array object ( out parameter). We have to return
+// IDispatch otherwise the object cannot be accessed from the Script.
+ if( dispidMember == DISPID_VALUE && wFlags == DISPATCH_PROPERTYGET
+ && m_defaultValueType != VT_EMPTY && pvarResult != NULL)
+ {
+ bHandled= sal_True;
+ if( m_defaultValueType == VT_DISPATCH)
+ {
+ pvarResult->vt= VT_DISPATCH;
+ pvarResult->pdispVal= static_cast<IDispatch*>( this);
+ AddRef();
+ ret= S_OK;
+ }
+ }
+// ---------
+ // function: _GetValueObject
+ else if( dispidMember == DISPID_JSCRIPT_VALUE_FUNC)
+ {
+ bHandled= sal_True;
+ if( !pvarResult)
+ ret= E_POINTER;
+ CComObject< JScriptValue>* pValue;
+ if( SUCCEEDED( CComObject<JScriptValue>::CreateInstance( &pValue)))
+ {
+ pValue->AddRef();
+ pvarResult->vt= VT_DISPATCH;
+#ifdef __MINGW32__
+ pvarResult->pdispVal= CComQIPtr<IDispatch, &__uuidof(IDispatch)>(pValue->GetUnknown());
+#else
+ pvarResult->pdispVal= CComQIPtr<IDispatch>(pValue->GetUnknown());
+#endif
+ ret= S_OK;
+ }
+ else
+ ret= DISP_E_EXCEPTION;
+ }
+ else if( dispidMember == DISPID_GET_STRUCT_FUNC)
+ {
+ bHandled= sal_True;
+ sal_Bool bStruct= sal_False;
+
+
+ Reference<XInterface> xIntCore= m_smgr->createInstance( OUString::createFromAscii("com.sun.star.reflection.CoreReflection"));
+ Reference<XIdlReflection> xRefl( xIntCore, UNO_QUERY);
+ if( xRefl.is() )
+ {
+ // the first parameter is in DISPPARAMS rgvargs contains the name of the struct.
+ CComVariant arg;
+ if( pdispparams->cArgs == 1 && SUCCEEDED( arg.ChangeType( VT_BSTR, &pdispparams->rgvarg[0])) )
+ {
+ Reference<XIdlClass> classStruct= xRefl->forName( reinterpret_cast<const sal_Unicode*>(arg.bstrVal));
+ if( classStruct.is())
+ {
+ Any anyStruct;
+ classStruct->createObject( anyStruct);
+ CComVariant var;
+ anyToVariant( &var, anyStruct );
+
+ if( var.vt == VT_DISPATCH)
+ {
+ VariantCopy( pvarResult, & var);
+ bStruct= sal_True;
+ }
+ }
+ }
+ }
+ ret= bStruct == sal_True ? S_OK : DISP_E_EXCEPTION;
+ }
+ else if (dispidMember == DISPID_CREATE_TYPE_FUNC)
+ {
+ bHandled= sal_True;
+ if( !pvarResult)
+ ret= E_POINTER;
+ // the first parameter is in DISPPARAMS rgvargs contains the name of the struct.
+ CComVariant arg;
+ if( pdispparams->cArgs != 1)
+ return DISP_E_BADPARAMCOUNT;
+ if (FAILED( arg.ChangeType( VT_BSTR, &pdispparams->rgvarg[0])))
+ return DISP_E_BADVARTYPE;
+
+ //check if the provided name represents a valid type
+ Type type;
+ if (getType(arg.bstrVal, type) == false)
+ {
+ writeExcepinfo(pexcepinfo,OUString(
+ OUSTR("[automation bridge] A UNO type with the name ") +
+ OUString(reinterpret_cast<const sal_Unicode*>(arg.bstrVal)) + OUSTR(" does not exist!")));
+ return DISP_E_EXCEPTION;
+ }
+
+ if (createUnoTypeWrapper(arg.bstrVal, pvarResult) == false)
+ {
+ writeExcepinfo(pexcepinfo,OUSTR("[automation bridge] InterfaceOleWrapper_Impl::InvokeGeneral\n"
+ "Could not initialize UnoTypeWrapper object!"));
+ return DISP_E_EXCEPTION;
+ }
+ }
+ }
+ catch(BridgeRuntimeError & e)
+ {
+ writeExcepinfo(pexcepinfo, e.message);
+ ret = DISP_E_EXCEPTION;
+ }
+ catch(Exception & e)
+ {
+ OUString message= OUSTR("InterfaceOleWrapper_Impl::InvokeGeneral : \n") +
+ e.Message;
+ writeExcepinfo(pexcepinfo, message);
+ ret = DISP_E_EXCEPTION;
+ }
+ catch( ... )
+ {
+ OUString message= OUSTR("InterfaceOleWrapper_Impl::InvokeGeneral : \n"
+ "Unexpected exception");
+ writeExcepinfo(pexcepinfo, message);
+ ret = DISP_E_EXCEPTION;
+ }
+ return ret;
+}
+
+
+
+
+STDMETHODIMP InterfaceOleWrapper_Impl::GetDispID(BSTR /*bstrName*/, DWORD /*grfdex*/, DISPID __RPC_FAR* /*pid*/)
+{
+ HRESULT ret = ResultFromScode(E_NOTIMPL);
+
+ return ret;
+}
+
+STDMETHODIMP InterfaceOleWrapper_Impl::InvokeEx(
+ /* [in] */ DISPID /*id*/,
+ /* [in] */ LCID /*lcid*/,
+ /* [in] */ WORD /*wFlags*/,
+ /* [in] */ DISPPARAMS __RPC_FAR* /*pdp*/,
+ /* [out] */ VARIANT __RPC_FAR* /*pvarRes*/,
+ /* [out] */ EXCEPINFO __RPC_FAR* /*pei*/,
+ /* [unique][in] */ IServiceProvider __RPC_FAR* /*pspCaller*/)
+{
+ HRESULT ret = ResultFromScode(E_NOTIMPL);
+
+ return ret;
+}
+
+
+STDMETHODIMP InterfaceOleWrapper_Impl::DeleteMemberByName(
+ /* [in] */ BSTR /*bstr*/,
+ /* [in] */ DWORD /*grfdex*/)
+{
+ HRESULT ret = ResultFromScode(E_NOTIMPL);
+
+ return ret;
+}
+
+STDMETHODIMP InterfaceOleWrapper_Impl::DeleteMemberByDispID(DISPID /*id*/)
+{
+ HRESULT ret = ResultFromScode(E_NOTIMPL);
+
+ return ret;
+}
+
+STDMETHODIMP InterfaceOleWrapper_Impl::GetMemberProperties(
+ /* [in] */ DISPID /*id*/,
+ /* [in] */ DWORD /*grfdexFetch*/,
+ /* [out] */ DWORD __RPC_FAR* /*pgrfdex*/)
+{
+ HRESULT ret = ResultFromScode(E_NOTIMPL);
+
+ return ret;
+}
+
+STDMETHODIMP InterfaceOleWrapper_Impl::GetMemberName(
+ /* [in] */ DISPID /*id*/,
+ /* [out] */ BSTR __RPC_FAR* /*pbstrName*/)
+{
+ HRESULT ret = ResultFromScode(E_NOTIMPL);
+
+ return ret;
+}
+
+STDMETHODIMP InterfaceOleWrapper_Impl::GetNextDispID(
+ /* [in] */ DWORD /*grfdex*/,
+ /* [in] */ DISPID /*id*/,
+ /* [out] */ DISPID __RPC_FAR* /*pid*/)
+{
+ HRESULT ret = ResultFromScode(E_NOTIMPL);
+
+ return ret;
+}
+
+STDMETHODIMP InterfaceOleWrapper_Impl::GetNameSpaceParent(
+ /* [out] */ IUnknown __RPC_FAR *__RPC_FAR* /*ppunk*/)
+{
+ HRESULT ret = ResultFromScode(E_NOTIMPL);
+
+ return ret;
+}
+
+
+/*************************************************************************
+
+ UnoObjectWrapperRemoteOpt
+
+*************************************************************************/
+UnoObjectWrapperRemoteOpt::UnoObjectWrapperRemoteOpt( Reference<XMultiServiceFactory>& aFactory,
+ sal_uInt8 unoWrapperClass, sal_uInt8 comWrapperClass):
+InterfaceOleWrapper_Impl( aFactory, unoWrapperClass, comWrapperClass),
+m_currentId(1)
+
+{
+}
+UnoObjectWrapperRemoteOpt::~UnoObjectWrapperRemoteOpt()
+{
+}
+
+// UnoConversionUtilities
+Reference< XInterface > UnoObjectWrapperRemoteOpt::createUnoWrapperInstance()
+{
+ Reference<XWeak> xWeak= static_cast<XWeak*>( new UnoObjectWrapperRemoteOpt(
+ m_smgr, m_nUnoWrapperClass, m_nComWrapperClass));
+ return Reference<XInterface>( xWeak, UNO_QUERY);
+}
+
+STDMETHODIMP UnoObjectWrapperRemoteOpt::GetIDsOfNames ( REFIID /*riid*/, OLECHAR ** rgszNames, unsigned int cNames,
+ LCID /*lcid*/, DISPID * rgdispid )
+{
+ MutexGuard guard( getBridgeMutex());
+
+ if( ! rgdispid)
+ return E_POINTER;
+ HRESULT ret = E_UNEXPECTED;
+ // ----------------------------------------
+ // _GetValueObject
+ if( ! wcscmp( *rgszNames, JSCRIPT_VALUE_FUNC))
+ {
+ *rgdispid= DISPID_JSCRIPT_VALUE_FUNC;
+ return S_OK;
+ }
+ else if( ! wcscmp( *rgszNames, GET_STRUCT_FUNC))
+ {
+ *rgdispid= DISPID_GET_STRUCT_FUNC;
+ return S_OK;
+ }
+
+ // ----------------------------------------
+ if (m_xInvocation.is() && (cNames > 0))
+ {
+ OUString name(reinterpret_cast<const sal_Unicode*>(rgszNames[0]));
+ // has this name been determined as "bad"
+ BadNameMap::iterator badIter= m_badNameMap.find( name);
+ if( badIter == m_badNameMap.end() )
+ {
+ // name has not been bad before( member exists
+ typedef NameToIdMap::iterator ITnames;
+ pair< ITnames, bool > pair_id= m_nameToDispIdMap.insert( NameToIdMap::value_type(name, m_currentId++));
+ // new ID inserted ?
+ if( pair_id.second )
+ {// yes, now create MemberInfo and ad to IdToMemberInfoMap
+ MemberInfo d(0, name);
+ m_idToMemberInfoMap.insert( IdToMemberInfoMap::value_type( m_currentId - 1, d));
+ }
+
+ *rgdispid = pair_id.first->second;
+ ret = S_OK;
+ }
+ else
+ ret= DISP_E_UNKNOWNNAME;
+ }
+ return ret;
+}
+
+STDMETHODIMP UnoObjectWrapperRemoteOpt::Invoke ( DISPID dispidMember, REFIID /*riid*/, LCID /*lcid*/, unsigned short wFlags,
+ DISPPARAMS * pdispparams, VARIANT * pvarResult, EXCEPINFO * pexcepinfo,
+ unsigned int * puArgErr )
+{
+ HRESULT ret = S_OK;
+ try
+ {
+ sal_Bool bHandled= sal_False;
+ ret= InvokeGeneral( dispidMember, wFlags, pdispparams, pvarResult, pexcepinfo,
+ puArgErr, bHandled);
+ if( bHandled)
+ return ret;
+
+ if ( dispidMember > 0 && m_xInvocation.is())
+ {
+
+ IdToMemberInfoMap::iterator it_MemberInfo= m_idToMemberInfoMap.find( dispidMember);
+ if( it_MemberInfo != m_idToMemberInfoMap.end() )
+ {
+ MemberInfo& info= it_MemberInfo->second;
+
+ Sequence<Any> params; // holds converted any s
+ if( ! info.flags )
+ { // DISPID called for the first time
+ if( wFlags == DISPATCH_METHOD )
+ {
+ convertDispparamsArgs(dispidMember, wFlags, pdispparams, params );
+
+ if( FAILED( ret= doInvoke( pdispparams, pvarResult,
+ pexcepinfo, puArgErr, info.name, params))
+ && ret == DISP_E_MEMBERNOTFOUND)
+ {
+ // try to get the exact name
+ OUString exactName;
+ if (m_xExactName.is())
+ {
+ exactName = m_xExactName->getExactName( info.name);
+ // invoke again
+ if( exactName.getLength() != 0)
+ {
+ if( SUCCEEDED( ret= doInvoke( pdispparams, pvarResult,
+ pexcepinfo, puArgErr, exactName, params)))
+ info.name= exactName;
+ }
+ }
+ }
+ if( SUCCEEDED( ret ) )
+ info.flags= DISPATCH_METHOD;
+ } //if( wFlags == DISPATCH_METHOD )
+
+ else if( wFlags == DISPATCH_PROPERTYPUT || wFlags == DISPATCH_PROPERTYPUTREF)
+ {
+ convertDispparamsArgs(dispidMember, wFlags, pdispparams, params );
+ if( FAILED( ret= doSetProperty( pdispparams, pvarResult,
+ pexcepinfo, puArgErr, info.name, params))
+ && ret == DISP_E_MEMBERNOTFOUND)
+ {
+ // try to get the exact name
+ OUString exactName;
+ if (m_xExactName.is())
+ {
+ exactName = m_xExactName->getExactName( info.name);
+ // invoke again
+ if( exactName.getLength() != 0)
+ {
+ if( SUCCEEDED( ret= doSetProperty( pdispparams, pvarResult,
+ pexcepinfo, puArgErr, exactName, params)))
+ info.name= exactName;
+ }
+ }
+ }
+ if( SUCCEEDED( ret ) )
+ info.flags= DISPATCH_PROPERTYPUT | DISPATCH_PROPERTYGET;
+ }
+
+ else if( wFlags == DISPATCH_PROPERTYGET)
+ {
+ if( FAILED( ret= doGetProperty( pdispparams, pvarResult,
+ pexcepinfo, info.name))
+ && ret == DISP_E_MEMBERNOTFOUND)
+ {
+ // try to get the exact name
+ OUString exactName;
+ if (m_xExactName.is())
+ {
+ exactName = m_xExactName->getExactName( info.name);
+ // invoke again
+ if( exactName.getLength() != 0)
+ {
+ if( SUCCEEDED( ret= doGetProperty( pdispparams, pvarResult,
+ pexcepinfo, exactName)))
+ info.name= exactName;
+ }
+ }
+ }
+ if( SUCCEEDED( ret ) )
+ info.flags= DISPATCH_PROPERTYGET | DISPATCH_PROPERTYPUT;
+ }
+ else if( wFlags & DISPATCH_METHOD &&
+ (wFlags & DISPATCH_PROPERTYPUT || wFlags & DISPATCH_PROPERTYPUTREF))
+ {
+
+ OUString exactName;
+ // convert params for DISPATCH_METHOD or DISPATCH_PROPERTYPUT
+ convertDispparamsArgs(dispidMember, wFlags, pdispparams, params );
+ // try first as method
+ if( FAILED( ret= doInvoke( pdispparams, pvarResult,
+ pexcepinfo, puArgErr, info.name, params))
+ && ret == DISP_E_MEMBERNOTFOUND)
+ {
+ // try to get the exact name
+ if (m_xExactName.is())
+ {
+ exactName = m_xExactName->getExactName( info.name);
+ // invoke again
+ if( exactName.getLength() != 0)
+ {
+ if( SUCCEEDED( ret= doInvoke( pdispparams, pvarResult,
+ pexcepinfo, puArgErr, exactName, params)))
+ info.name= exactName;
+ }
+ }
+ }
+ if( SUCCEEDED( ret ) )
+ info.flags= DISPATCH_METHOD;
+
+ // try as property
+ if( FAILED( ret) && pdispparams->cArgs == 1)
+ {
+ if( FAILED( ret= doSetProperty( pdispparams, pvarResult,
+ pexcepinfo, puArgErr, info.name, params))
+ && ret == DISP_E_MEMBERNOTFOUND)
+ {
+ // try to get the exact name
+ if( exactName.getLength() != 0)
+ {
+ if( SUCCEEDED( ret= doSetProperty( pdispparams, pvarResult,
+ pexcepinfo, puArgErr, exactName, params)))
+ info.name= exactName;
+ }
+ }
+ if( SUCCEEDED( ret ) )
+ info.flags= DISPATCH_PROPERTYPUT | DISPATCH_PROPERTYGET;
+ }
+ }
+ else if( wFlags & DISPATCH_METHOD && wFlags & DISPATCH_PROPERTYGET)
+ {
+ OUString exactName;
+ convertDispparamsArgs(dispidMember, wFlags, pdispparams, params );
+
+ if( FAILED( ret= doInvoke( pdispparams, pvarResult,
+ pexcepinfo, puArgErr, info.name, params))
+ && ret == DISP_E_MEMBERNOTFOUND)
+ {
+ // try to get the exact name
+ if (m_xExactName.is())
+ {
+ exactName = m_xExactName->getExactName( info.name);
+ // invoke again
+ if( exactName.getLength() != 0)
+ {
+ if( SUCCEEDED( ret= doInvoke( pdispparams, pvarResult,
+ pexcepinfo, puArgErr, exactName, params)))
+ info.name= exactName;
+ }
+ }
+ }
+ if( SUCCEEDED( ret ) )
+ info.flags= DISPATCH_METHOD;
+
+ // try as property
+ if( FAILED( ret) && pdispparams->cArgs == 1)
+ {
+ if( FAILED( ret= doGetProperty( pdispparams, pvarResult,
+ pexcepinfo, info.name))
+ && ret == DISP_E_MEMBERNOTFOUND)
+ {
+ if( exactName.getLength() != 0)
+ {
+ if( SUCCEEDED( ret= doSetProperty( pdispparams, pvarResult,
+ pexcepinfo, puArgErr, exactName, params)))
+ info.name= exactName;
+ }
+ }
+ if( SUCCEEDED( ret ) )
+ info.flags= DISPATCH_PROPERTYGET;
+ }
+ }
+
+ // update ínformation about this member
+ if( ret == DISP_E_MEMBERNOTFOUND)
+ {
+ // Remember the name as not existing
+ // and remove the MemberInfo
+ m_badNameMap[info.name]= sal_False;
+ m_idToMemberInfoMap.erase( it_MemberInfo);
+ }
+ } // if( ! info.flags )
+ else // IdToMemberInfoMap contains a MemberInfo
+ {
+ if( wFlags & DISPATCH_METHOD && info.flags == DISPATCH_METHOD)
+ {
+ convertDispparamsArgs(dispidMember, wFlags, pdispparams, params );
+ ret= doInvoke( pdispparams, pvarResult,
+ pexcepinfo, puArgErr, info.name, params);
+ }
+ else if( (wFlags & DISPATCH_PROPERTYPUT || wFlags & DISPATCH_PROPERTYPUTREF ) &&
+ info.flags & DISPATCH_PROPERTYPUT)
+ {
+ convertDispparamsArgs(dispidMember, wFlags, pdispparams, params );
+ ret= doSetProperty( pdispparams, pvarResult,
+ pexcepinfo, puArgErr, info.name, params);
+ }
+ else if( (wFlags & DISPATCH_PROPERTYGET) && ( info.flags & DISPATCH_PROPERTYGET))
+ {
+ ret= doGetProperty( pdispparams, pvarResult,
+ pexcepinfo, info.name);
+ }
+ else
+ {
+ ret= DISP_E_MEMBERNOTFOUND;
+ }
+ }
+ }// if( it_MemberInfo != m_idToMemberInfoMap.end() )
+ else
+ ret= DISP_E_MEMBERNOTFOUND;
+ }
+ }
+ catch(BridgeRuntimeError& e)
+ {
+ writeExcepinfo(pexcepinfo, e.message);
+ ret = DISP_E_EXCEPTION;
+ }
+ catch(Exception& e)
+ {
+ OUString message= OUSTR("UnoObjectWrapperRemoteOpt::Invoke : \n") +
+ e.Message;
+ writeExcepinfo(pexcepinfo, message);
+ ret = DISP_E_EXCEPTION;
+ }
+ catch(...)
+ {
+ OUString message= OUSTR("UnoObjectWrapperRemoteOpt::Invoke : \n"
+ "Unexpected exception");
+ writeExcepinfo(pexcepinfo, message);
+ ret = DISP_E_EXCEPTION;
+ }
+
+ return ret;
+}
+
+HRESULT UnoObjectWrapperRemoteOpt::methodInvoke( DISPID /*dispidMember*/, DISPPARAMS * /*pdispparams*/, VARIANT * /*pvarResult*/,
+ EXCEPINFO * /*pexcepinfo*/, unsigned int * /*puArgErr*/, Sequence<Any> params)
+{
+ return S_OK;
+}
+
+
+// The returned HRESULT is only appropriate for IDispatch::Invoke
+static HRESULT mapCannotConvertException( CannotConvertException e, unsigned int * puArgErr)
+{
+ HRESULT ret;
+ sal_Bool bWriteIndex= sal_True;
+
+ switch ( e.Reason)
+ {
+ case FailReason::OUT_OF_RANGE:
+ ret = DISP_E_OVERFLOW;
+ break;
+ case FailReason::IS_NOT_NUMBER:
+ ret = DISP_E_TYPEMISMATCH;
+ break;
+ case FailReason::IS_NOT_ENUM:
+ ret = DISP_E_TYPEMISMATCH;
+ break;
+ case FailReason::IS_NOT_BOOL:
+ ret = DISP_E_TYPEMISMATCH;
+ break;
+ case FailReason::NO_SUCH_INTERFACE:
+ ret = DISP_E_TYPEMISMATCH;
+ break;
+ case FailReason::SOURCE_IS_NO_DERIVED_TYPE:
+ ret = DISP_E_TYPEMISMATCH;
+ break;
+ case FailReason::TYPE_NOT_SUPPORTED:
+ ret = DISP_E_TYPEMISMATCH;
+ break;
+ case FailReason::INVALID:
+ ret = DISP_E_TYPEMISMATCH;
+ break;
+ case FailReason::NO_DEFAULT_AVAILABLE:
+ ret = DISP_E_BADPARAMCOUNT;
+ break;
+ case FailReason::UNKNOWN:
+ ret = E_UNEXPECTED;
+ break;
+ default:
+ ret = E_UNEXPECTED;
+ bWriteIndex= sal_False;
+ break;
+ }
+
+ if( bWriteIndex && puArgErr != NULL)
+ *puArgErr = e.ArgumentIndex;
+ return ret;
+}
+
+// The function maps the TypeClass of the any to VARTYPE: If
+// the Any contains STRUCT or INTERFACE then the return value
+// is VT_DISPATCH. The function is used from o2u_createUnoObjectWrapper
+// and the result is put into the constructor of the uno - wrapper
+// object. If a client asks the object for DISPID_VALUE and this
+// funtion returned VT_DISPATCH then the IDispatch of the same
+// object is being returned.
+// See InterfaceOleWrapper_Impl::Invoke, InterfaceOleWrapper_Impl::m_defaultValueType
+const VARTYPE getVarType( const Any& value)
+{
+ VARTYPE ret= VT_EMPTY;
+
+ switch ( value.getValueTypeClass())
+ {
+ case TypeClass_STRUCT: ret= VT_DISPATCH; break;
+ case TypeClass_INTERFACE: ret= VT_DISPATCH; break;
+ default: break;
+ }
+ return ret;
+}
+
+
+
+
+} // end namespace
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/ole/unoobjw.hxx b/extensions/source/ole/unoobjw.hxx
new file mode 100644
index 000000000000..e007dd662883
--- /dev/null
+++ b/extensions/source/ole/unoobjw.hxx
@@ -0,0 +1,302 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _UNOOBJW_HXX
+#define _UNOOBJW_HXX
+
+#include <com/sun/star/bridge/XBridgeSupplier2.hpp>
+#include <com/sun/star/beans/XExactName.hpp>
+#include <com/sun/star/lang/XInitialization.hpp>
+#include <com/sun/star/script/InvocationInfo.hpp>
+#include <salhelper/simplereferenceobject.hxx>
+
+#include <tools/presys.h>
+#include "comifaces.hxx"
+#include <tools/postsys.h>
+
+#include "ole2uno.hxx"
+#include "unoconversionutilities.hxx"
+
+//#define INVOCATION_SERVICE L"com.sun.star.script.Invocation"
+#define JSCRIPT_VALUE_FUNC L"_GetValueObject"
+#define GET_STRUCT_FUNC L"_GetStruct"
+#define BRIDGE_VALUE_FUNC L"Bridge_GetValueObject"
+#define BRIDGE_GET_STRUCT_FUNC L"Bridge_GetStruct"
+#define BRIDGE_CREATE_TYPE_FUNC L"Bridge_CreateType"
+
+#define DISPID_JSCRIPT_VALUE_FUNC -10l
+#define DISPID_GET_STRUCT_FUNC -102
+#define DISPID_CREATE_TYPE_FUNC -103
+
+using namespace std;
+using namespace cppu;
+using namespace com::sun::star::bridge;
+using namespace com::sun::star::script;
+namespace ole_adapter
+{
+
+
+
+struct hash_IUnknown_Impl
+{
+ size_t operator()(const IUnknown* p) const
+ {
+ return (size_t)p;
+ }
+};
+
+struct equal_to_IUnknown_Impl
+{
+ bool operator()(const IUnknown* s1, const IUnknown* s2) const
+ {
+ return s1 == s2;
+ }
+};
+
+
+
+struct MemberInfo
+{
+ MemberInfo() : flags(0), name() {}
+ MemberInfo(WORD f, const OUString& n) : flags(f), name(n) {}
+
+ WORD flags;
+ OUString name;
+};
+
+typedef hash_map
+<
+ OUString,
+ DISPID,
+ hashOUString_Impl,
+ equalOUString_Impl
+> NameToIdMap;
+
+typedef hash_map
+<
+ OUString,
+ sal_Bool,
+ hashOUString_Impl,
+ equalOUString_Impl
+> BadNameMap;
+
+typedef hash_map
+<
+ DISPID,
+ MemberInfo
+> IdToMemberInfoMap;
+
+/*****************************************************************************
+
+ class declaration: InterfaceOleWrapper_Impl
+
+*****************************************************************************/
+
+class InterfaceOleWrapper_Impl : public WeakImplHelper2<XBridgeSupplier2, XInitialization>,
+ public IDispatchEx,
+ public UnoConversionUtilities<InterfaceOleWrapper_Impl>,
+ public IUnoObjectWrapper
+{
+public:
+
+
+ InterfaceOleWrapper_Impl(Reference<XMultiServiceFactory>& xFactory, sal_uInt8 unoWrapperClass, sal_uInt8 comWrapperClass);
+ ~InterfaceOleWrapper_Impl();
+
+ /* IUnknown methods */
+ STDMETHOD(QueryInterface)(REFIID riid, LPVOID FAR * ppvObj);
+ STDMETHOD_(ULONG, AddRef)();
+ STDMETHOD_(ULONG, Release)();
+
+ /* IDispatch methods */
+ STDMETHOD( GetTypeInfoCount )( unsigned int * pctinfo );
+ STDMETHOD( GetTypeInfo )( unsigned int itinfo, LCID lcid, ITypeInfo ** pptinfo );
+ STDMETHOD( GetIDsOfNames )( REFIID riid, OLECHAR ** rgszNames, unsigned int cNames,
+ LCID lcid, DISPID * rgdispid );
+ STDMETHOD( Invoke )( DISPID dispidMember, REFIID riid, LCID lcid, unsigned short wFlags,
+ DISPPARAMS * pdispparams, VARIANT * pvarResult, EXCEPINFO * pexcepinfo,
+ unsigned int * puArgErr );
+
+ /* IDispatchEx methods */
+
+ virtual HRESULT STDMETHODCALLTYPE GetDispID(
+ /* [in] */ BSTR bstrName,
+ /* [in] */ DWORD grfdex,
+ /* [out] */ DISPID __RPC_FAR *pid);
+
+ virtual /* [local] */ HRESULT STDMETHODCALLTYPE InvokeEx(
+ /* [in] */ DISPID id,
+ /* [in] */ LCID lcid,
+ /* [in] */ WORD wFlags,
+ /* [in] */ DISPPARAMS __RPC_FAR *pdp,
+ /* [out] */ VARIANT __RPC_FAR *pvarRes,
+ /* [out] */ EXCEPINFO __RPC_FAR *pei,
+ /* [unique][in] */ IServiceProvider __RPC_FAR *pspCaller);
+
+ virtual HRESULT STDMETHODCALLTYPE DeleteMemberByName(
+ /* [in] */ BSTR bstr,
+ /* [in] */ DWORD grfdex);
+
+ virtual HRESULT STDMETHODCALLTYPE DeleteMemberByDispID(
+ /* [in] */ DISPID id);
+
+ virtual HRESULT STDMETHODCALLTYPE GetMemberProperties(
+ /* [in] */ DISPID id,
+ /* [in] */ DWORD grfdexFetch,
+ /* [out] */ DWORD __RPC_FAR *pgrfdex);
+
+ virtual HRESULT STDMETHODCALLTYPE GetMemberName(
+ /* [in] */ DISPID id,
+ /* [out] */ BSTR __RPC_FAR *pbstrName);
+
+ virtual HRESULT STDMETHODCALLTYPE GetNextDispID(
+ /* [in] */ DWORD grfdex,
+ /* [in] */ DISPID id,
+ /* [out] */ DISPID __RPC_FAR *pid);
+
+ virtual HRESULT STDMETHODCALLTYPE GetNameSpaceParent(
+ /* [out] */ IUnknown __RPC_FAR *__RPC_FAR *ppunk);
+
+ // XBridgeSupplier2 ---------------------------------------------------
+ virtual Any SAL_CALL createBridge(const Any& modelDepObject,
+ const Sequence<sal_Int8>& ProcessId,
+ sal_Int16 sourceModelType,
+ sal_Int16 destModelType)
+ throw (IllegalArgumentException, RuntimeException);
+
+ //XInitialization -----------------------------------------------------
+ virtual void SAL_CALL initialize( const Sequence< Any >& aArguments ) throw(Exception, RuntimeException);
+
+ // IUnoObjectWrapper
+ STDMETHOD( getWrapperXInterface)( Reference<XInterface>* pXInt);
+ STDMETHOD( getOriginalUnoObject)( Reference<XInterface>* pXInt);
+ STDMETHOD( getOriginalUnoStruct)( Any * pStruct);
+
+ // UnoConversionUtility
+ virtual Reference< XInterface > createUnoWrapperInstance();
+ virtual Reference< XInterface > createComWrapperInstance();
+
+
+protected:
+ virtual HRESULT doInvoke( DISPPARAMS * pdispparams, VARIANT * pvarResult,
+ EXCEPINFO * pexcepinfo, unsigned int * puArgErr, OUString & name, Sequence<Any>& params);
+
+ virtual HRESULT doGetProperty( DISPPARAMS * pdispparams, VARIANT * pvarResult,
+ EXCEPINFO * pexcepinfo, OUString & name );
+
+ virtual HRESULT doSetProperty( DISPPARAMS * pdispparams, VARIANT * pvarResult,
+ EXCEPINFO * pexcepinfo, unsigned int * puArgErr, OUString & name, Sequence<Any> params);
+
+ virtual HRESULT InvokeGeneral( DISPID dispidMember, unsigned short wFlags,
+ DISPPARAMS * pdispparams, VARIANT * pvarResult, EXCEPINFO * pexcepinfo,
+ unsigned int * puArgErr, sal_Bool& bHandled);
+
+ void convertDispparamsArgs( DISPID id, unsigned short wFlags, DISPPARAMS* pdispparams,
+ Sequence<Any>& rSeq);
+
+ sal_Bool getInvocationInfoForCall(DISPID id, InvocationInfo& info);
+
+ Reference<XInvocation> m_xInvocation;
+ Reference<XExactName> m_xExactName;
+ Reference<XInterface> m_xOrigin;
+ NameToIdMap m_nameToDispIdMap;
+ vector<MemberInfo> m_MemberInfos;
+ // This member is used to determine the default value
+ // denoted by DISPID_VALUE (0). For proper results in JavaScript
+ // we have to return the default value when we write an object
+ // as out parameter. That is, we get an JScript Array as parameter
+ // and put a wrapped object on index null. The array object tries
+ // to detect the default value. The wrapped object must then return
+ // its own IDispatch* otherwise we cannot access it within the script.
+ // see InterfaceOleWrapper_Impl::Invoke
+ VARTYPE m_defaultValueType;
+
+};
+
+/*****************************************************************************
+
+ class declaration: UnoObjectWrapperRemoteOpt
+ ( Uno Object Wrapper Remote Optimized)
+ This is the UNO wrapper used in the service com.sun.star.bridge.OleBridgeSupplierVar1.
+ Key features:
+ DISPIDs are passed out blindly. That is in GetIDsOfNames is no name checking carried out.
+ Only if Invoke fails the name is being checked. Moreover Invoke tries to figure out
+ if a call is made to a property or method if the flags are DISPATCH_METHOD | DISPATCH_PROPERTYPUT.
+ If something has been found out about a property or member than it is saved
+ in a MemberInfo structure hold by a IdToMemberInfoMap stl map.
+
+*****************************************************************************/
+class UnoObjectWrapperRemoteOpt: public InterfaceOleWrapper_Impl
+{
+public:
+ UnoObjectWrapperRemoteOpt( Reference<XMultiServiceFactory>& aFactory, sal_uInt8 unoWrapperClass, sal_uInt8 comWrapperClass);
+ ~UnoObjectWrapperRemoteOpt();
+
+ STDMETHOD( GetIDsOfNames )( REFIID riid, OLECHAR ** rgszNames, unsigned int cNames,
+ LCID lcid, DISPID * rgdispid );
+ STDMETHOD( Invoke )( DISPID dispidMember, REFIID riid, LCID lcid, unsigned short wFlags,
+ DISPPARAMS * pdispparams, VARIANT * pvarResult, EXCEPINFO * pexcepinfo,
+ unsigned int * puArgErr );
+
+ // UnoConversionUtility
+ // If UNO interfaces are converted in methods of this class then
+ // they are always wrapped with instances of this class
+ virtual Reference< XInterface > createUnoWrapperInstance();
+
+protected:
+
+ HRESULT methodInvoke( DISPID dispidMember, DISPPARAMS * pdispparams, VARIANT * pvarResult,
+ EXCEPINFO * pexcepinfo, unsigned int * puArgErr, Sequence<Any> params);
+ // In GetIDsOfNames are blindly passed out, that is without verifying
+ // the name. If two names are passed in during different calls to
+ // GetIDsOfNames and the names differ only in their cases then different
+ // id's are passed out ( e.g. "doSomethingMethod" or "dosomethingmethod").
+ // In Invoke the DISPID is remapped to the name passed to GetIDsOfNames
+ // and the name is used as parameter for XInvocation::invoke. If invoke
+ // fails because of a wrong name, then m_xExactName ( XExactName) is used
+ // to verify the name. The correct name is then inserted to m_MemberInfos
+ // ( vector<MemberInfo> ). During the next call to Invoke the right name
+ // is used. .
+
+
+ BadNameMap m_badNameMap;
+
+ IdToMemberInfoMap m_idToMemberInfoMap;
+
+ DISPID m_currentId;
+
+
+};
+
+
+
+} // end namespace
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/ole/unotypewrapper.cxx b/extensions/source/ole/unotypewrapper.cxx
new file mode 100644
index 000000000000..7461d7d0e62f
--- /dev/null
+++ b/extensions/source/ole/unotypewrapper.cxx
@@ -0,0 +1,181 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+#include "unotypewrapper.hxx"
+#include "rtl/ustring.hxx"
+
+
+bool createUnoTypeWrapper(BSTR sTypeName, VARIANT * pVar)
+{
+ bool ret = false;
+ OSL_ASSERT(sTypeName && pVar);
+ CComObject< UnoTypeWrapper>* pObj;
+ VariantClear(pVar);
+ if( SUCCEEDED( CComObject<UnoTypeWrapper>::CreateInstance( &pObj)))
+ {
+ pObj->AddRef();
+ pVar->vt= VT_DISPATCH;
+#ifdef __MINGW32__
+ pVar->pdispVal= CComQIPtr<IDispatch, &__uuidof(IDispatch)>(pObj->GetUnknown());
+#else
+ pVar->pdispVal= CComQIPtr<IDispatch>(pObj->GetUnknown());
+#endif
+ //now set the value, e.i. the name of the type
+#ifdef __MINGW32__
+ CComQIPtr<IUnoTypeWrapper, &__uuidof(IUnoTypeWrapper)> spType(pVar->pdispVal);
+#else
+ CComQIPtr<IUnoTypeWrapper> spType(pVar->pdispVal);
+#endif
+ OSL_ASSERT(spType);
+ if (SUCCEEDED(spType->put_Name(sTypeName)))
+ {
+ ret = true;
+ }
+ }
+ return ret;
+}
+
+
+bool createUnoTypeWrapper(const rtl::OUString& sTypeName, VARIANT * pVar)
+{
+ CComBSTR bstr(reinterpret_cast<LPCOLESTR>(sTypeName.getStr()));
+ return createUnoTypeWrapper(bstr, pVar);
+}
+
+UnoTypeWrapper::UnoTypeWrapper()
+{
+}
+
+UnoTypeWrapper::~UnoTypeWrapper()
+{
+}
+
+
+// UnoTypeWrapper, IDispatch --------------------------------------------
+STDMETHODIMP UnoTypeWrapper::GetTypeInfoCount(UINT* /*pctinfo*/)
+{
+ return E_NOTIMPL;
+}
+
+// UnoTypeWrapper, IDispatch --------------------------------------------
+STDMETHODIMP UnoTypeWrapper::GetTypeInfo( UINT /*iTInfo*/,
+ LCID /*lcid*/,
+ ITypeInfo** /*ppTInfo*/)
+{
+ return E_NOTIMPL;
+}
+
+// UnoTypeWrapper, IDispatch --------------------------------------------
+STDMETHODIMP UnoTypeWrapper::GetIDsOfNames( REFIID /*riid*/,
+ LPOLESTR *rgszNames,
+ UINT /*cNames*/,
+ LCID /*lcid*/,
+ DISPID *rgDispId)
+{
+ if( !rgDispId)
+ return E_POINTER;
+
+ HRESULT ret= S_OK;
+ CComBSTR name(*rgszNames);
+ name.ToLower();
+
+ if( name == CComBSTR( L"name") )
+ *rgDispId= DISPID_VALUE;
+ else
+ ret= DISP_E_UNKNOWNNAME;
+
+ return ret;
+}
+
+// UnoTypeWrapper, IDispatch --------------------------------------------
+STDMETHODIMP UnoTypeWrapper::Invoke( DISPID dispIdMember,
+ REFIID /*riid*/,
+ LCID /*lcid*/,
+ WORD wFlags,
+ DISPPARAMS *pDispParams,
+ VARIANT *pVarResult,
+ EXCEPINFO* /*pExcepInfo*/,
+ UINT* /*puArgErr*/)
+{
+ if (pDispParams == NULL)
+ return DISP_E_EXCEPTION;
+
+ if( pDispParams->cNamedArgs)
+ return DISP_E_NONAMEDARGS;
+
+
+ HRESULT ret= S_OK;
+ switch( dispIdMember)
+ {
+ case DISPID_VALUE: // DISPID_VALUE
+ if (wFlags & DISPATCH_PROPERTYGET)
+ {
+ if (pVarResult == NULL)
+ {
+ ret = E_POINTER;
+ break;
+ }
+ get_Name( & pVarResult->bstrVal);
+ pVarResult->vt = VT_BSTR;
+ }
+ break;
+ default:
+ ret= DISP_E_MEMBERNOTFOUND;
+ break;
+ }
+
+ return ret;
+}
+
+// IUnoTypeWrapper-----------------------
+STDMETHODIMP UnoTypeWrapper::put_Name(BSTR val)
+{
+ Lock();
+ HRESULT hr = S_OK;
+ m_sName = val;
+ Unlock();
+ return hr;
+}
+
+// (UnoTypeWrapper-----------------------
+STDMETHODIMP UnoTypeWrapper::get_Name(BSTR *pVal)
+{
+ Lock();
+ HRESULT hr = S_OK;
+ if( !pVal)
+ return E_POINTER;
+ *pVal = m_sName.Copy();
+ Unlock();
+ return hr;
+}
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/ole/unotypewrapper.hxx b/extensions/source/ole/unotypewrapper.hxx
new file mode 100644
index 000000000000..f09fd9bfbbb2
--- /dev/null
+++ b/extensions/source/ole/unotypewrapper.hxx
@@ -0,0 +1,103 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef UNO_TYPE_WRAPPER_HXX
+#define UNO_TYPE_WRAPPER_HXX
+
+#pragma warning (push,1)
+#pragma warning (disable:4548)
+
+#include <tools/presys.h>
+#define STRICT
+#define _WIN32_WINNT 0x0403
+#define _WIN32_DCOM
+#if OSL_DEBUG_LEVEL > 0
+//#define _ATL_DEBUG_INTERFACES
+#endif
+#include <atlbase.h>
+extern CComModule _Module;
+#include <atlcom.h>
+#include <tools/postsys.h>
+
+#pragma warning (pop)
+#pragma warning (disable:4505)
+ // disable "unreferenced local function has been removed" globally
+
+#include "comifaces.hxx"
+
+/* creates an UnoTypWrapper and sets the Name property to the value
+ specified by sTypeName.
+ Returns true if the object could be created and initialized.
+ */
+bool createUnoTypeWrapper(BSTR sTypeName, VARIANT * pVariant);
+bool createUnoTypeWrapper(const rtl::OUString& sTypeName, VARIANT * pVar);
+
+class UnoTypeWrapper:
+ public CComObjectRootEx<CComMultiThreadModel>,
+ public IUnoTypeWrapper,
+ public IDispatch
+{
+public:
+ UnoTypeWrapper();
+ virtual ~UnoTypeWrapper();
+
+ BEGIN_COM_MAP(UnoTypeWrapper)
+ COM_INTERFACE_ENTRY(IDispatch)
+ COM_INTERFACE_ENTRY(IUnoTypeWrapper)
+ END_COM_MAP()
+
+ // IDispatch -------------------------------------------
+ STDMETHOD( GetTypeInfoCount)(UINT *pctinfo);
+
+ STDMETHOD( GetTypeInfo)( UINT iTInfo,
+ LCID lcid,
+ ITypeInfo **ppTInfo);
+
+ STDMETHOD( GetIDsOfNames)( REFIID riid,
+ LPOLESTR *rgszNames,
+ UINT cNames,
+ LCID lcid,
+ DISPID *rgDispId);
+
+ STDMETHOD( Invoke)( DISPID dispIdMember,
+ REFIID riid,
+ LCID lcid,
+ WORD wFlags,
+ DISPPARAMS *pDispParams,
+ VARIANT *pVarResult,
+ EXCEPINFO *pExcepInfo,
+ UINT *puArgErr);
+ // IUnoTypeWrapper --------------------------------------
+ STDMETHOD(put_Name)(BSTR val);
+ STDMETHOD(get_Name)(BSTR* pVal);
+
+ CComBSTR m_sName;
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/ole/windata.cxx b/extensions/source/ole/windata.cxx
new file mode 100644
index 000000000000..e4047e3b184c
--- /dev/null
+++ b/extensions/source/ole/windata.cxx
@@ -0,0 +1,42 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+#include "windata.hxx"
+
+
+namespace ole_adapter
+{
+
+
+
+}
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/ole/windata.hxx b/extensions/source/ole/windata.hxx
new file mode 100644
index 000000000000..fce3d4af5e9c
--- /dev/null
+++ b/extensions/source/ole/windata.hxx
@@ -0,0 +1,201 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef AUTOMATION_BRIDGE_WINDATA_HXX
+#define AUTOMATION_BRIDGE_WINDATA_HXX
+
+#pragma warning (push,1)
+#pragma warning (disable:4668)
+#pragma warning (disable:4548)
+#include "oleidl.h"
+
+#include <atlbase.h>
+#pragma warning (pop)
+#include "osl/diagnose.h"
+
+namespace ole_adapter
+{
+//Wrapper for VARDESC
+class VarDesc
+{
+ VARDESC* operator = (const VarDesc*);
+ VarDesc(const VarDesc&);
+// Construction
+public:
+ CComPtr< ITypeInfo > m_pTypeInfo;
+ VARDESC* m_pVarDesc;
+
+ VarDesc(ITypeInfo* pTypeInfo) :
+ m_pVarDesc(NULL),
+ m_pTypeInfo(pTypeInfo)
+ {
+ OSL_ASSERT(pTypeInfo);
+ }
+ ~VarDesc()
+ {
+ if (m_pVarDesc != NULL)
+ {
+ m_pTypeInfo->ReleaseVarDesc(m_pVarDesc);
+ }
+ }
+
+ VARDESC* operator->()
+ {
+ return m_pVarDesc;
+ }
+
+ VARDESC** operator&()
+ {
+ return &m_pVarDesc;
+ }
+
+ operator VARDESC* ()
+ {
+ return m_pVarDesc;
+ }
+};
+
+//Wrapper for FUNCDESC structure
+class FuncDesc
+{
+ FUNCDESC* operator = (const FuncDesc &);
+ FuncDesc(const FuncDesc&);
+ CComPtr<ITypeInfo> m_pTypeInfo;
+ FUNCDESC * m_pFuncDesc;
+
+public:
+
+ FuncDesc(ITypeInfo * pTypeInfo) :
+ m_pFuncDesc(NULL),
+ m_pTypeInfo(pTypeInfo)
+ {
+ OSL_ASSERT(pTypeInfo);
+ }
+ ~FuncDesc()
+ {
+ ReleaseFUNCDESC();
+ }
+
+ FUNCDESC* operator -> ()
+ {
+ return m_pFuncDesc;
+ }
+
+ FUNCDESC** operator & ()
+ {
+ return & m_pFuncDesc;
+ }
+
+ operator FUNCDESC* ()
+ {
+ return m_pFuncDesc;
+ }
+
+ FUNCDESC* operator = (FUNCDESC* pDesc)
+ {
+ ReleaseFUNCDESC();
+ m_pFuncDesc = pDesc;
+ return m_pFuncDesc;
+ }
+ FUNCDESC* Detach()
+ {
+ FUNCDESC* pDesc = m_pFuncDesc;
+ m_pFuncDesc = NULL;
+ return pDesc;
+ }
+
+ void ReleaseFUNCDESC()
+ {
+ if (m_pFuncDesc != NULL)
+ {
+ m_pTypeInfo->ReleaseFuncDesc(m_pFuncDesc);
+ }
+ m_pFuncDesc = NULL;
+ }
+};
+//Wrapper for EXCEPINFO structure
+class ExcepInfo : public EXCEPINFO
+{
+ EXCEPINFO* operator = (const ExcepInfo& );
+ ExcepInfo(const ExcepInfo &);
+public:
+ ExcepInfo()
+ {
+ memset(this, 0, sizeof(ExcepInfo));
+ }
+ ~ExcepInfo()
+ {
+ if (bstrSource != NULL)
+ ::SysFreeString(bstrSource);
+ if (bstrDescription != NULL)
+ ::SysFreeString(bstrDescription);
+ if (bstrHelpFile != NULL)
+ ::SysFreeString(bstrHelpFile);
+ }
+};
+
+//Wrapper for TYPEATTR
+class TypeAttr
+{
+ TYPEATTR* operator = (const TypeAttr &);
+ TypeAttr(const TypeAttr &);
+public:
+ CComPtr< ITypeInfo > m_pTypeInfo;
+ TYPEATTR* m_pTypeAttr;
+
+ TypeAttr(ITypeInfo* pTypeInfo) :
+ m_pTypeAttr( NULL ),
+ m_pTypeInfo( pTypeInfo )
+ {
+ OSL_ASSERT(pTypeInfo);
+ }
+ ~TypeAttr() throw()
+ {
+ if (m_pTypeAttr != NULL)
+ {
+ m_pTypeInfo->ReleaseTypeAttr(m_pTypeAttr);
+ }
+ }
+
+ TYPEATTR** operator&() throw()
+ {
+ return &m_pTypeAttr;
+ }
+
+ TYPEATTR* operator->() throw()
+ {
+ return m_pTypeAttr;
+ }
+};
+
+
+
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/oooimprovecore/core.cxx b/extensions/source/oooimprovecore/core.cxx
new file mode 100644
index 000000000000..4c13d5b5e2b3
--- /dev/null
+++ b/extensions/source/oooimprovecore/core.cxx
@@ -0,0 +1,193 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+
+#include <com/sun/star/oooimprovement/XCore.hpp>
+
+#include "oooimprovecore_module.hxx"
+#include <com/sun/star/frame/XTerminateListener.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/oooimprovement/XCoreController.hpp>
+#include <com/sun/star/uno/XComponentContext.hpp>
+#include <comphelper/componentmodule.hxx>
+#include <comphelper/configurationhelper.hxx>
+#include <comphelper/processfactory.hxx>
+#include <comphelper/uieventslogger.hxx>
+#include <cppuhelper/implbase3.hxx>
+#include <svx/svxdlg.hxx>
+#include <vcl/svapp.hxx>
+#include <osl/mutex.hxx>
+#include <svl/itemset.hxx>
+#include <svl/stritem.hxx>
+#include <sfx2/app.hxx>
+#include <svx/dialogs.hrc>
+#include <sfx2/sfxsids.hrc>
+
+using namespace ::com::sun::star::oooimprovement;
+using ::com::sun::star::frame::XTerminateListener;
+using ::com::sun::star::lang::EventObject;
+using ::com::sun::star::lang::XMultiServiceFactory;
+using ::com::sun::star::lang::XServiceInfo;
+using ::com::sun::star::uno::Reference;
+using ::com::sun::star::uno::RuntimeException;
+using ::com::sun::star::uno::Sequence;
+using ::com::sun::star::uno::UNO_QUERY;
+using ::com::sun::star::uno::XComponentContext;
+using ::com::sun::star::uno::XInterface;
+using ::comphelper::UiEventsLogger;
+using ::rtl::OUString;
+
+// declaration
+namespace oooimprovecore
+{
+ class Core : public ::cppu::WeakImplHelper3<XCore,XServiceInfo,XTerminateListener>
+ {
+ public:
+ // XServiceInfo - static version
+ static OUString SAL_CALL getImplementationName_static();
+ static Sequence<OUString> SAL_CALL getSupportedServiceNames_static();
+ static Reference<XInterface> Create(const Reference<XComponentContext>& context );
+
+ protected:
+ Core(const Reference<XComponentContext>&);
+ virtual ~Core();
+
+ // XCore
+ virtual sal_Int32 SAL_CALL getSessionLogEventCount() throw(RuntimeException);
+ virtual sal_Bool SAL_CALL getUiEventsLoggerEnabled() throw(RuntimeException);
+ virtual void SAL_CALL inviteUser() throw(RuntimeException);
+
+ // XServiceInfo
+ virtual OUString SAL_CALL getImplementationName() throw(RuntimeException);
+ virtual sal_Bool SAL_CALL supportsService(const OUString& service_name) throw(RuntimeException);
+ virtual Sequence<OUString> SAL_CALL getSupportedServiceNames() throw(RuntimeException);
+
+ // XTerminateListener
+ virtual void SAL_CALL queryTermination(const EventObject&) throw(RuntimeException);
+ virtual void SAL_CALL notifyTermination(const EventObject&) throw(RuntimeException);
+
+ // XEventListener
+ virtual void SAL_CALL disposing(const EventObject&) throw(RuntimeException);
+ };
+}
+
+
+// implementation
+namespace oooimprovecore
+{
+
+ Core::Core(const Reference<XComponentContext>&)
+ { }
+
+ Core::~Core()
+ { }
+
+ sal_Int32 SAL_CALL Core::getSessionLogEventCount() throw(RuntimeException)
+ { return UiEventsLogger::getSessionLogEventCount(); }
+
+ sal_Bool SAL_CALL Core::getUiEventsLoggerEnabled() throw(RuntimeException)
+ { return UiEventsLogger::isEnabled(); }
+
+ void SAL_CALL Core::inviteUser() throw(RuntimeException)
+ {
+ Reference<XMultiServiceFactory> xServiceFactory = ::comphelper::getProcessServiceFactory();
+
+ OUString help_url;
+ Reference<XCoreController> core_c(
+ xServiceFactory->createInstance(OUString::createFromAscii("com.sun.star.oooimprovement.CoreController")),
+ UNO_QUERY);
+ if(core_c.is())
+ ::comphelper::ConfigurationHelper::readDirectKey(
+ xServiceFactory,
+ OUString::createFromAscii("/org.openoffice.Office.OOoImprovement.Settings"),
+ OUString::createFromAscii("Participation"),
+ OUString::createFromAscii("HelpUrl"),
+ ::comphelper::ConfigurationHelper::E_READONLY) >>= help_url;
+ else
+ help_url = OUString::createFromAscii("http://www.libreoffice.org");
+ {
+ SolarMutexGuard aGuard;
+ SfxAllItemSet aSet( SFX_APP()->GetPool() );
+ aSet.Put( SfxStringItem( SID_CURRENT_URL, help_url ) );
+ SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
+ if ( pFact )
+ {
+ SfxAbstractDialog *pDlg = pFact->CreateSfxDialog( NULL, aSet, 0, RID_SVXPAGE_IMPROVEMENT );
+ pDlg->Execute();
+ delete pDlg;
+ }
+ }
+ }
+
+ sal_Bool SAL_CALL Core::supportsService(const OUString& service_name) throw(RuntimeException)
+ {
+ const Sequence<OUString> service_names(getSupportedServiceNames());
+ for (sal_Int32 idx = service_names.getLength()-1; idx>=0; --idx)
+ if(service_name == service_names[idx]) return sal_True;
+ return sal_False;
+ }
+
+ OUString SAL_CALL Core::getImplementationName() throw(RuntimeException)
+ { return getImplementationName_static(); }
+
+ Sequence<OUString> SAL_CALL Core::getSupportedServiceNames() throw(RuntimeException)
+ { return getSupportedServiceNames_static(); }
+
+ OUString SAL_CALL Core::getImplementationName_static()
+ { return OUString::createFromAscii("com.sun.star.comp.extensions.oooimprovecore.Core"); }
+
+ Sequence<OUString> SAL_CALL Core::getSupportedServiceNames_static()
+ {
+ Sequence<OUString> aServiceNames(1);
+ aServiceNames[0] = OUString::createFromAscii("com.sun.star.oooimprovement.Core");
+ return aServiceNames;
+ }
+
+ void Core::queryTermination(const EventObject&) throw(RuntimeException)
+ { }
+
+ void Core::notifyTermination(const EventObject&) throw(RuntimeException)
+ {
+ UiEventsLogger::disposing();
+ }
+
+ void Core::disposing(const EventObject&) throw(RuntimeException)
+ { }
+
+ Reference<XInterface> Core::Create(const Reference<XComponentContext>& context)
+ { return *(new Core(context)); }
+
+ void createRegistryInfo_Core()
+ {
+ static OAutoRegistration<Core> auto_reg;
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/oooimprovecore/makefile.mk b/extensions/source/oooimprovecore/makefile.mk
new file mode 100644
index 000000000000..97e130c3a644
--- /dev/null
+++ b/extensions/source/oooimprovecore/makefile.mk
@@ -0,0 +1,77 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ=..$/..
+PRJNAME=extensions
+TARGET=oooimprovecore
+
+# --- Settings ----------------------------------
+
+.INCLUDE : settings.mk
+
+# --- Files -------------------------------------
+
+EXCEPTIONSFILES= \
+ $(SLO)$/core.obj \
+ $(SLO)$/oooimprovecore_services.obj \
+
+SLOFILES= \
+ $(EXCEPTIONSFILES) \
+ $(SLO)$/oooimprovecore_module.obj \
+
+LIB1TARGET=$(SLB)$/$(TARGET)_t.lib
+LIB1FILES= \
+ $(SLB)$/$(TARGET).lib \
+
+SHL1TARGET=$(TARGET)$(DLLPOSTFIX)
+.IF "$(GUI)"=="OS2"
+SHL1TARGET=oooimpc$(DLLPOSTFIX)
+.ENDIF
+
+SHL1STDLIBS= \
+ $(COMPHELPERLIB) \
+ $(CPPUHELPERLIB) \
+ $(CPPULIB) \
+ $(SALLIB) \
+ $(VCLLIB) \
+ $(SVLLIB) \
+ $(SVTOOLLIB) \
+ $(SFXLIB) \
+ $(SVXCORELIB) \
+ $(SVXLIB) \
+ $(TOOLSLIB)
+
+
+SHL1LIBS=$(LIB1TARGET)
+SHL1DEF=$(MISC)$/$(SHL1TARGET).def
+DEF1NAME=$(SHL1TARGET)
+SHL1VERSIONMAP=$(SOLARENV)/src/component.map
+
+# --- Targets ----------------------------------
+
+.INCLUDE : target.mk
+
diff --git a/extensions/source/oooimprovecore/oooimprovecore_module.cxx b/extensions/source/oooimprovecore/oooimprovecore_module.cxx
new file mode 100644
index 000000000000..c686bee9455a
--- /dev/null
+++ b/extensions/source/oooimprovecore/oooimprovecore_module.cxx
@@ -0,0 +1,39 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+#include "oooimprovecore_module.hxx"
+#include <rtl/instance.hxx>
+
+namespace oooimprovecore
+{
+ IMPLEMENT_COMPONENT_MODULE( OooimprovecoreModule );
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/oooimprovecore/oooimprovecore_module.hxx b/extensions/source/oooimprovecore/oooimprovecore_module.hxx
new file mode 100644
index 000000000000..3cf4d715588f
--- /dev/null
+++ b/extensions/source/oooimprovecore/oooimprovecore_module.hxx
@@ -0,0 +1,40 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef EXTENSIONS_OOOIMPROVECORE_MODULE_HXX
+#define EXTENSIONS_OOOIMPROVECORE_MODULE_HXX
+
+#include <comphelper/componentmodule.hxx>
+
+namespace oooimprovecore
+{
+ DECLARE_COMPONENT_MODULE( OooimprovecoreModule, OooimprovecoreModuleClient )
+}
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/oooimprovecore/oooimprovecore_services.cxx b/extensions/source/oooimprovecore/oooimprovecore_services.cxx
new file mode 100644
index 000000000000..532e9a2d14d1
--- /dev/null
+++ b/extensions/source/oooimprovecore/oooimprovecore_services.cxx
@@ -0,0 +1,55 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+
+#include "oooimprovecore_module.hxx"
+
+namespace oooimprovecore
+{
+ extern void createRegistryInfo_Core();
+
+ static void initializeModule()
+ {
+ static bool bInitialized(false);
+ if (!bInitialized)
+ {
+ ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
+ if (!bInitialized)
+ {
+ createRegistryInfo_Core();
+ }
+ }
+ }
+
+}
+
+IMPLEMENT_COMPONENT_LIBRARY_API( ::oooimprovecore::OooimprovecoreModule, ::oooimprovecore::initializeModule)
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/oooimprovement/Jobs.xcu b/extensions/source/oooimprovement/Jobs.xcu
new file mode 100644
index 000000000000..206d83dd7eb2
--- /dev/null
+++ b/extensions/source/oooimprovement/Jobs.xcu
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<oor:component-data oor:name="Jobs" oor:package="org.openoffice.Office" xmlns:oor="http://openoffice.org/2001/registry" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <node oor:name="Jobs">
+ <node oor:name="OOoImprovement.OnLogRotateJob" oor:op="replace">
+ <prop oor:name="Service">
+ <value>com.sun.star.comp.extensions.oooimprovement.OnLogRotateJob</value>
+ </prop>
+ <node oor:name="Arguments"/>
+ </node>
+ <node oor:name="OOoImprovement.InviteJob" oor:op="replace">
+ <prop oor:name="Service">
+ <value>com.sun.star.comp.extensions.oooimprovement.InviteJob</value>
+ </prop>
+ <node oor:name="Arguments"/>
+ </node>
+ </node>
+ <node oor:name="Events">
+ <node oor:name="onFirstVisibleTask" oor:op="fuse">
+ <node oor:name="JobList">
+ <node oor:name="OOoImprovement.OnLogRotateJob" oor:op="replace"/>
+ <node oor:name="OOoImprovement.InviteJob" oor:op="replace"/>
+ </node>
+ </node>
+ </node>
+</oor:component-data>
diff --git a/extensions/source/oooimprovement/Logging.xcu b/extensions/source/oooimprovement/Logging.xcu
new file mode 100644
index 000000000000..4ea492d67737
--- /dev/null
+++ b/extensions/source/oooimprovement/Logging.xcu
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<oor:component-data oor:name="Logging" oor:package="org.openoffice.Office" xmlns:oor="http://openoffice.org/2001/registry" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <node oor:name="OOoImprovement">
+ <prop oor:name="EnablingAllowed">
+ <value>true</value>
+ </prop>
+ </node>
+</oor:component-data>
diff --git a/extensions/source/oooimprovement/config.cxx b/extensions/source/oooimprovement/config.cxx
new file mode 100644
index 000000000000..52347ac47c2d
--- /dev/null
+++ b/extensions/source/oooimprovement/config.cxx
@@ -0,0 +1,299 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+
+#include "config.hxx"
+#include "myconfigurationhelper.hxx"
+#include <rtl/ustrbuf.hxx>
+
+
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::uno;
+using ::rtl::OUString;
+using ::rtl::OUStringBuffer;
+
+
+namespace
+{
+ using namespace oooimprovement;
+
+ static const OUString CFG_COUNTERS = OUString::createFromAscii("Counters");
+ static const OUString CFG_ENABLINGALLOWED = OUString::createFromAscii("EnablingAllowed");
+ static const OUString CFG_EVENTSCOUNT = OUString::createFromAscii("LoggedEvents");
+ static const OUString CFG_EXTENSION = OUString::createFromAscii("ooSetupExtension");
+ static const OUString CFG_FAILEDATTEMPTS = OUString::createFromAscii("FailedAttempts");
+ static const OUString CFG_INVACCEPT = OUString::createFromAscii("InvitationAccepted");
+ static const OUString CFG_L10N = OUString::createFromAscii("L10N");
+ static const OUString CFG_LOCALE = OUString::createFromAscii("ooLocale");
+ static const OUString CFG_LOGGING = OUString::createFromAscii("/org.openoffice.Office.Logging");
+ static const OUString CFG_LOGPATH = OUString::createFromAscii("LogPath");
+ static const OUString CFG_NAME = OUString::createFromAscii("ooName");
+ static const OUString CFG_OFFICESTARTCOUNTDOWN = OUString::createFromAscii("OfficeStartCounterdown");
+ static const OUString CFG_OOOIMPROVEMENT = OUString::createFromAscii("OOoImprovement");
+ static const OUString CFG_OOOIMPROVEMENTPACK = OUString::createFromAscii("/org.openoffice.Office.OOoImprovement.Settings");
+ static const OUString CFG_PARTICIPATION = OUString::createFromAscii("Participation");
+ static const OUString CFG_PRODUCT = OUString::createFromAscii("Product");
+ static const OUString CFG_REPORTCOUNT = OUString::createFromAscii("UploadedReports");
+ static const OUString CFG_REPORTEREMAIL = OUString::createFromAscii("ReporterEmail");
+ static const OUString CFG_SETUP = OUString::createFromAscii("/org.openoffice.Setup");
+ static const OUString CFG_SHOWEDINV = OUString::createFromAscii("ShowedInvitation");
+ static const OUString CFG_SOAPIDADD = OUString::createFromAscii("SoapIdAdditions");
+ static const OUString CFG_SOAPURL = OUString::createFromAscii("SoapUrl");
+ static const OUString CFG_UPLOAD = OUString::createFromAscii("Upload");
+ static const OUString CFG_VERSION = OUString::createFromAscii("ooSetupVersion");
+
+ static const OUString SOAPID = OUString::createFromAscii("OpenOffice.org Improvement Report - Version 1\n");
+
+ static sal_Int32 incrementCfgValue(
+ const Reference<XMultiServiceFactory> sm,
+ const OUString& package,
+ const OUString& rel_path,
+ const OUString& key,
+ sal_Int32 increment_by)
+ {
+ sal_Int32 value;
+ Reference<XInterface> cfg =
+ MyConfigurationHelper::openConfig(
+ sm,
+ package, MyConfigurationHelper::E_STANDARD);
+ MyConfigurationHelper::readRelativeKey(
+ cfg,
+ rel_path, key) >>= value;
+ value += increment_by;
+ MyConfigurationHelper::writeRelativeKey(
+ cfg,
+ rel_path, key,
+ Any(value));
+ MyConfigurationHelper::flush(cfg);
+ return value;
+ };
+}
+
+namespace oooimprovement
+{
+ Config::Config(const Reference<XMultiServiceFactory>& sf)
+ : m_ServiceFactory(sf)
+ {}
+
+ OUString Config::getSoapUrl() const
+ {
+ OUString result;
+ MyConfigurationHelper::readDirectKey(
+ m_ServiceFactory,
+ CFG_OOOIMPROVEMENTPACK, CFG_UPLOAD, CFG_SOAPURL,
+ MyConfigurationHelper::E_READONLY) >>= result;
+ return result;
+ }
+
+ OUString Config::getSoapId() const
+ {
+ OUString value;
+ OUStringBuffer result = SOAPID;
+ MyConfigurationHelper::readDirectKey(
+ m_ServiceFactory,
+ CFG_OOOIMPROVEMENTPACK, CFG_UPLOAD, CFG_SOAPIDADD,
+ MyConfigurationHelper::E_READONLY) >>= value;
+ result.append(value);
+ return result.makeStringAndClear();
+ }
+
+ OUString Config::getReporterEmail() const
+ {
+ OUString result;
+ MyConfigurationHelper::readDirectKey(
+ m_ServiceFactory,
+ CFG_OOOIMPROVEMENTPACK, CFG_UPLOAD, CFG_REPORTEREMAIL,
+ MyConfigurationHelper::E_READONLY) >>= result;
+ return result;
+ }
+
+ OUString Config::getLogPath() const
+ {
+ OUString result;
+ MyConfigurationHelper::readDirectKey(
+ m_ServiceFactory,
+ CFG_LOGGING, CFG_OOOIMPROVEMENT, CFG_LOGPATH,
+ MyConfigurationHelper::E_READONLY) >>= result;
+ return result;
+ }
+
+ bool Config::getEnablingAllowed() const
+ {
+ bool result = false;
+ MyConfigurationHelper::readDirectKey(
+ m_ServiceFactory,
+ CFG_LOGGING, CFG_OOOIMPROVEMENT, CFG_ENABLINGALLOWED,
+ MyConfigurationHelper::E_READONLY) >>= result;
+ return result;
+ }
+
+ bool Config::getInvitationAccepted() const
+ {
+ bool result = false;
+ MyConfigurationHelper::readDirectKey(
+ m_ServiceFactory,
+ CFG_OOOIMPROVEMENTPACK, CFG_PARTICIPATION, CFG_INVACCEPT,
+ MyConfigurationHelper::E_READONLY) >>= result;
+ return result;
+ };
+
+ bool Config::getShowedInvitation() const
+ {
+ bool result = false;
+ MyConfigurationHelper::readDirectKey(
+ m_ServiceFactory,
+ CFG_OOOIMPROVEMENTPACK, CFG_PARTICIPATION, CFG_SHOWEDINV,
+ MyConfigurationHelper::E_READONLY) >>= result;
+ return result;
+ };
+
+ OUString Config::getCompleteProductname() const
+ {
+ OUStringBuffer result;
+ OUString value;
+ MyConfigurationHelper::readDirectKey(
+ m_ServiceFactory,
+ CFG_SETUP, CFG_PRODUCT, CFG_NAME,
+ MyConfigurationHelper::E_READONLY) >>= value;
+ result.append(value);
+
+ value = OUString::createFromAscii("");
+ MyConfigurationHelper::readDirectKey(
+ m_ServiceFactory,
+ CFG_SETUP, CFG_PRODUCT, CFG_VERSION,
+ MyConfigurationHelper::E_READONLY) >>= value;
+ if(value.getLength()) result.appendAscii(" ").append(value);
+
+ value = OUString::createFromAscii("");
+ MyConfigurationHelper::readDirectKey(
+ m_ServiceFactory,
+ CFG_SETUP, CFG_PRODUCT, CFG_EXTENSION,
+ MyConfigurationHelper::E_READONLY) >>= value;
+ if(value.getLength()) result.appendAscii(" ").append(value);
+
+ return result.makeStringAndClear();
+ }
+
+ OUString Config::getSetupLocale() const
+ {
+ OUString result;
+ MyConfigurationHelper::readDirectKey(
+ m_ServiceFactory,
+ CFG_SETUP, CFG_L10N, CFG_LOCALE,
+ MyConfigurationHelper::E_READONLY) >>= result;
+ return result;
+ }
+
+ sal_Int32 Config::getReportCount() const
+ {
+ sal_Int32 result = 0;
+ MyConfigurationHelper::readDirectKey(
+ m_ServiceFactory,
+ CFG_OOOIMPROVEMENTPACK, CFG_COUNTERS, CFG_REPORTCOUNT,
+ MyConfigurationHelper::E_READONLY) >>= result;
+ return result;
+ }
+
+#ifdef FUTURE
+ sal_Int32 Config::getFailedAttempts() const
+ {
+ sal_Int32 result = 0;
+ MyConfigurationHelper::readDirectKey(
+ m_ServiceFactory,
+ CFG_OOOIMPROVEMENTPACK, CFG_COUNTERS, CFG_FAILEDATTEMPTS,
+ MyConfigurationHelper::E_READONLY) >>= result;
+ return result;
+ }
+#endif
+
+ sal_Int32 Config::getOfficeStartCounterdown() const
+ {
+ sal_Int32 result = 0;
+ MyConfigurationHelper::readDirectKey(
+ m_ServiceFactory,
+ CFG_OOOIMPROVEMENTPACK, CFG_PARTICIPATION, CFG_OFFICESTARTCOUNTDOWN,
+ MyConfigurationHelper::E_READONLY) >>= result;
+ return result;
+ }
+
+ sal_Int32 Config::incrementReportCount(sal_Int32 by)
+ {
+ return incrementCfgValue(
+ m_ServiceFactory,
+ CFG_OOOIMPROVEMENTPACK, CFG_COUNTERS, CFG_REPORTCOUNT,
+ by);
+ }
+
+ sal_Int32 Config::incrementEventCount(sal_Int32 by)
+ {
+ return incrementCfgValue(
+ m_ServiceFactory,
+ CFG_OOOIMPROVEMENTPACK, CFG_COUNTERS, CFG_EVENTSCOUNT,
+ by);
+ }
+
+ sal_Int32 Config::incrementFailedAttempts(sal_Int32 by)
+ {
+ return incrementCfgValue(
+ m_ServiceFactory,
+ CFG_OOOIMPROVEMENTPACK, CFG_COUNTERS, CFG_FAILEDATTEMPTS,
+ by);
+ }
+
+ sal_Int32 Config::decrementOfficeStartCounterdown(sal_Int32 by)
+ {
+ return incrementCfgValue(
+ m_ServiceFactory,
+ CFG_OOOIMPROVEMENTPACK, CFG_PARTICIPATION, CFG_OFFICESTARTCOUNTDOWN,
+ -by);
+ }
+
+ void Config::resetFailedAttempts()
+ {
+ sal_Int32 zero = 0;
+ MyConfigurationHelper::writeDirectKey(
+ m_ServiceFactory,
+ CFG_OOOIMPROVEMENTPACK, CFG_COUNTERS, CFG_FAILEDATTEMPTS,
+ Any(zero),
+ MyConfigurationHelper::E_STANDARD);
+ }
+
+ void Config::giveupUploading()
+ {
+ sal_Bool f = false;
+ MyConfigurationHelper::writeDirectKey(
+ m_ServiceFactory,
+ CFG_OOOIMPROVEMENTPACK, CFG_PARTICIPATION, CFG_INVACCEPT,
+ Any(f),
+ MyConfigurationHelper::E_STANDARD);
+ resetFailedAttempts();
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/oooimprovement/config.hxx b/extensions/source/oooimprovement/config.hxx
new file mode 100644
index 000000000000..9aebafe15894
--- /dev/null
+++ b/extensions/source/oooimprovement/config.hxx
@@ -0,0 +1,71 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+
+
+#ifndef EXTENSIONS_OOOIMPROVEMENT_CONFIG_HXX
+#define EXTENSIONS_OOOIMPROVEMENT_CONFIG_HXX
+
+#include <rtl/ustring.hxx>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+
+
+namespace oooimprovement
+{
+ class Config
+ {
+ public:
+ Config(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory>& sf);
+ bool getEnablingAllowed() const;
+ bool getInvitationAccepted() const;
+ bool getShowedInvitation() const;
+ ::rtl::OUString getCompleteProductname() const;
+ ::rtl::OUString getLogPath() const;
+ ::rtl::OUString getReporterEmail() const;
+ ::rtl::OUString getSetupLocale() const;
+ ::rtl::OUString getSoapId() const;
+ ::rtl::OUString getSoapUrl() const;
+ sal_Int32 getReportCount() const;
+#ifdef FUTURE
+ sal_Int32 getFailedAttempts() const;
+#endif
+ sal_Int32 getOfficeStartCounterdown() const;
+ sal_Int32 incrementEventCount(sal_Int32 by);
+ sal_Int32 incrementReportCount(sal_Int32 by);
+ sal_Int32 incrementFailedAttempts(sal_Int32 by);
+ sal_Int32 decrementOfficeStartCounterdown(sal_Int32 by);
+ void resetFailedAttempts();
+ void giveupUploading();
+
+ private:
+ ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory> m_ServiceFactory;
+ };
+}
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/oooimprovement/corecontroller.cxx b/extensions/source/oooimprovement/corecontroller.cxx
new file mode 100644
index 000000000000..0d3cc368169b
--- /dev/null
+++ b/extensions/source/oooimprovement/corecontroller.cxx
@@ -0,0 +1,92 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+
+#include "corecontroller.hxx"
+#include "config.hxx"
+
+using ::rtl::OUString;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::uno;
+
+
+namespace oooimprovement
+{
+ CoreController::CoreController(const Reference<XMultiServiceFactory>& sf)
+ : m_ServiceFactory(sf)
+ { }
+
+ CoreController::~CoreController()
+ { }
+
+ sal_Bool SAL_CALL CoreController::enablingUiEventsLoggerAllowed(sal_Int16 version) throw(RuntimeException)
+ {
+ Config config(m_ServiceFactory);
+ if(version==1 && config.getEnablingAllowed() && config.getShowedInvitation() && config.getInvitationAccepted())
+ return true;
+ return false;
+ }
+
+ sal_Bool SAL_CALL CoreController::showBuiltinOptionsPage(sal_Int16 version) throw(RuntimeException)
+ {
+ Config config(m_ServiceFactory);
+ if(version==1 && config.getEnablingAllowed())
+ return true;
+ return false;
+ }
+
+ sal_Bool SAL_CALL CoreController::supportsService(const OUString& service_name) throw(RuntimeException)
+ {
+ const Sequence<OUString> service_names(getSupportedServiceNames());
+ for (sal_Int32 idx = service_names.getLength()-1; idx>=0; --idx)
+ if(service_name == service_names[idx]) return sal_True;
+ return sal_False;
+ }
+
+ OUString SAL_CALL CoreController::getImplementationName() throw(RuntimeException)
+ { return getImplementationName_static(); }
+
+ Sequence<OUString> SAL_CALL CoreController::getSupportedServiceNames() throw(RuntimeException)
+ { return getSupportedServiceNames_static(); }
+
+ OUString SAL_CALL CoreController::getImplementationName_static()
+ { return OUString::createFromAscii("com.sun.star.comp.extensions.oooimprovement.CoreController"); }
+
+ Sequence<OUString> SAL_CALL CoreController::getSupportedServiceNames_static()
+ {
+ Sequence<OUString> aServiceNames(1);
+ aServiceNames[0] = OUString::createFromAscii("com.sun.star.oooimprovement.CoreController");
+ return aServiceNames;
+ }
+
+ Reference<XInterface> SAL_CALL CoreController::Create(const Reference<XMultiServiceFactory>& sm)
+ { return *(new CoreController(sm)); }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/oooimprovement/corecontroller.hxx b/extensions/source/oooimprovement/corecontroller.hxx
new file mode 100644
index 000000000000..5d68cc0395df
--- /dev/null
+++ b/extensions/source/oooimprovement/corecontroller.hxx
@@ -0,0 +1,87 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+
+
+#ifndef EXTENSIONS_OOOIMPROVEMENT_CORECONTROLLER_HXX
+#define EXTENSIONS_OOOIMPROVEMENT_CORECONTROLLER_HXX
+
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/oooimprovement/XCoreController.hpp>
+#include <com/sun/star/uno/XComponentContext.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <cppuhelper/implbase2.hxx>
+
+
+namespace oooimprovement
+{
+ #ifdef css
+ #error css defined globally
+ #endif
+ #define css ::com::sun::star
+ class CoreController : public ::cppu::WeakImplHelper2<
+ css::oooimprovement::XCoreController,
+ css::lang::XServiceInfo>
+ {
+ public:
+ // css::lang::XServiceInfo - static version
+ static ::rtl::OUString SAL_CALL getImplementationName_static();
+ static css::uno::Sequence< ::rtl::OUString> SAL_CALL getSupportedServiceNames_static();
+ //static css::uno::Reference< css::uno::XInterface> SAL_CALL Create(
+ // const css::uno::Reference<css::uno::XComponentContext>& context);
+
+ static css::uno::Reference< css::uno::XInterface> SAL_CALL Create(
+ const css::uno::Reference< css::lang::XMultiServiceFactory>& sm);
+
+ protected:
+ CoreController(const css::uno::Reference< css::uno::XComponentContext>& context);
+ CoreController(const css::uno::Reference< css::lang::XMultiServiceFactory>& sm);
+ virtual ~CoreController();
+
+ // css::oooimprovement::XCoreController
+ virtual sal_Bool SAL_CALL enablingUiEventsLoggerAllowed(sal_Int16 version)
+ throw(css::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL showBuiltinOptionsPage(sal_Int16 version)
+ throw(css::uno::RuntimeException);
+
+ // css::lang::XServiceInfo
+ virtual ::rtl::OUString SAL_CALL getImplementationName()
+ throw(css::uno::RuntimeException);
+ virtual ::sal_Bool SAL_CALL supportsService(const ::rtl::OUString& service_name)
+ throw(css::uno::RuntimeException);
+ virtual css::uno::Sequence< ::rtl::OUString> SAL_CALL getSupportedServiceNames()
+ throw(css::uno::RuntimeException);
+
+ private:
+ css::uno::Reference< css::lang::XMultiServiceFactory> m_ServiceFactory;
+ };
+ #undef css
+}
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/oooimprovement/errormail.cxx b/extensions/source/oooimprovement/errormail.cxx
new file mode 100644
index 000000000000..81bf38ba2868
--- /dev/null
+++ b/extensions/source/oooimprovement/errormail.cxx
@@ -0,0 +1,210 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+
+#include "errormail.hxx"
+#include "config.hxx"
+#include <unotools/bootstrap.hxx>
+#include <rtl/ustring.hxx>
+#include <rtl/string.hxx>
+#include <rtl/strbuf.hxx>
+
+#if defined(UNIX) || defined(OS2)
+ #include <sys/utsname.h>
+#endif
+#ifdef WIN32
+ #include <windows.h>
+#endif
+
+
+using namespace com::sun::star::lang;
+using namespace com::sun::star::uno;
+using namespace oooimprovement;
+using ::rtl::OUString;
+using ::rtl::OString;
+using ::rtl::OStringBuffer;
+
+
+namespace {
+ static OString replaceAll(const OString& str, sal_Char old, const OString& replacement)
+ {
+ OStringBuffer result;
+ sal_Int32 idx = 0;
+ do {
+ result.append(str.getToken(0, old, idx));
+ if(idx>=0) result.append(replacement);
+ } while(idx >= 0);
+ return result.makeStringAndClear();
+ };
+
+ static OString xmlAttrEncode(const OString& input)
+ {
+ OString result = replaceAll(input, '&', OString("&amp;"));
+ result = replaceAll(result, '<', OString("&lt;"));
+ result = replaceAll(result, '"', OString("&quot;"));
+ return replaceAll(result, '>', OString("&gt;"));
+ }
+
+ static OString getPlatform()
+ {
+ #ifdef SOLARIS
+ return "Solaris";
+ #elif defined LINUX
+ return "Linux";
+ #elif defined WIN32
+ return "Win32";
+ #elif defined UNIX
+ return "Unix";
+ #elif defined OS2
+ return "OS/2";
+ #else
+ return "Unknown";
+ #endif
+ };
+
+#if defined(UNIX) || defined(OS2)
+ static const OString getLocale()
+ {
+ const char * locale = getenv( "LC_ALL" );
+ if( NULL == locale )
+ locale = getenv( "LC_CTYPE" );
+
+ if( NULL == locale )
+ locale = getenv( "LANG" );
+
+ if( NULL == locale )
+ locale = "C";
+ return locale;
+ };
+
+ static OString getSystemInfoXml(const Reference<XMultiServiceFactory>&)
+ {
+ struct utsname info;
+ //memset(&info, 0, sizeof(info));
+ uname(&info);
+ OStringBuffer result =
+ "<systeminfo:systeminfo xmlns:systeminfo=\"http://openoffice.org/2002/systeminfo\">\n"
+ "<systeminfo:System name=\""
+ + xmlAttrEncode(OString(info.sysname)) + "\" version=\""
+ + xmlAttrEncode(OString(info.version)) + "\" build=\""
+ + xmlAttrEncode(OString(info.release)) + "\" locale=\""
+ + xmlAttrEncode(OString(getLocale())) + "\"/>\n"
+ "<systeminfo:CPU type=\""
+ + xmlAttrEncode(OString(info.machine)) + "\"/>\n"
+ "</systeminfo:systeminfo>\n";
+ return result.makeStringAndClear();
+ };
+#else
+ static OString getSystemInfoXml(const Reference<XMultiServiceFactory>&)
+ {
+ OSVERSIONINFO info;
+ ZeroMemory(&info, sizeof(OSVERSIONINFO));
+ info.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
+ GetVersionEx(&info);
+ OStringBuffer result = OString(
+ "<systeminfo:systeminfo xmlns:systeminfo=\"http://openoffice.org/2002/systeminfo\">\n"
+ "<systeminfo:System name=\"");
+ if(VER_PLATFORM_WIN32_NT == info.dwPlatformId)
+ result.append(OString("Windows NT"));
+ else
+ result.append(OString("Windows"));
+ result.append("\" version=\"").append(static_cast<long>(info.dwMajorVersion));
+ result.append(".").append(static_cast<long>(info.dwMinorVersion));
+ result.append("\" build=\"").append(static_cast<long>(info.dwBuildNumber));
+ result.append("\" locale=\"").append(static_cast<long>(GetUserDefaultLangID()));
+ result.append("\"/>\n");
+ result.append("<systeminfo:CPU type=\""
+ /* x86 or AMD64 */ "\"/>\n"
+ "</systeminfo:systeminfo>\n");
+ return result.makeStringAndClear();
+ };
+#endif
+
+ static OString getOfficeInfoXml(const Reference<XMultiServiceFactory>& sf)
+ {
+ Config config(sf);
+ const OString product = OUStringToOString(config.getCompleteProductname(), RTL_TEXTENCODING_ASCII_US);
+ const OString platform = getPlatform();
+ const OString language = OUStringToOString(config.getSetupLocale(), RTL_TEXTENCODING_ASCII_US);
+ // If the oooimprovement lib is packaged in an extension, this needs to
+ // be done in another way: The build version string needs to be made
+ // available in an UNO service (if no better place is found for this,
+ // com.sun.star.comp.extensions.oooimprovecore.Core in oooimprovecore
+ // is likely the best fit)
+ const OString build = OUStringToOString(::utl::Bootstrap::getBuildIdData(OUString()), RTL_TEXTENCODING_ASCII_US);
+ const OString exceptiontype = "";
+ OStringBuffer result =
+ "<officeinfo:officeinfo xmlns:officeinfo=\"http://openoffice.org/2002/officeinfo\" platform=\""
+ + xmlAttrEncode(platform) + "\" language=\""
+ + xmlAttrEncode(language) + "\" build=\""
+ + xmlAttrEncode(build) + "\" exceptiontype=\""
+ + xmlAttrEncode(exceptiontype) + "\" product=\""
+ + xmlAttrEncode(product) + " \" />\n";
+ return result.makeStringAndClear();
+ };
+}
+
+namespace oooimprovement
+{
+ Errormail::Errormail(const Reference<XMultiServiceFactory>& sf)
+ : m_ServiceFactory(sf)
+ {}
+
+ OString Errormail::getXml()
+ {
+ Config config(m_ServiceFactory);
+ const OString usertype;
+ const OString email = OUStringToOString(config.getReporterEmail(), RTL_TEXTENCODING_ASCII_US);
+ OString feedback;
+ {
+ OStringBuffer temp;
+ temp.append(config.getReportCount());
+ feedback = temp.makeStringAndClear();
+ }
+ const OString title;
+ OStringBuffer result =
+ "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
+ "<!DOCTYPE errormail:errormail PUBLIC \"-//OpenOffice.org//DTD ErrorMail 1.0//EN\" \"errormail.dtd\">\n"
+ "<errormail:errormail xmlns:errormail=\"http://openoffice.org/2002/errormail\" usertype=\""
+ + xmlAttrEncode(usertype) + "\">\n"
+ "<reportmail:mail xmlns:reportmail=\"http://openoffice.org/2002/reportmail\" version=\"1.1\" feedback=\""
+ + xmlAttrEncode(feedback) + "\" email=\""
+ + xmlAttrEncode(email) + "\">\n"
+ "<reportmail:title>"
+ + xmlAttrEncode(title) + "</reportmail:title>\n"
+ "<reportmail:attachment name=\"data.zip\" media-type=\"application/zip\" class=\"OOoImprovementLog\"/>\n"
+ "</reportmail:mail>\n"
+ + getOfficeInfoXml(m_ServiceFactory)
+ + getSystemInfoXml(m_ServiceFactory) +
+ "</errormail:errormail>\n";
+ return result.makeStringAndClear();
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/oooimprovement/errormail.hxx b/extensions/source/oooimprovement/errormail.hxx
new file mode 100644
index 000000000000..8a9f3a4db7a4
--- /dev/null
+++ b/extensions/source/oooimprovement/errormail.hxx
@@ -0,0 +1,57 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+
+#ifndef EXTENSIONS_OOOIMPROVEMENT_ERRORMAIL_HXX
+#define EXTENSIONS_OOOIMPROVEMENT_ERRORMAIL_HXX
+
+#include <rtl/string.hxx>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+
+
+namespace oooimprovement
+{
+ #ifdef css
+ #error css defined globally
+ #endif
+ #define css ::com::sun::star
+ class Errormail
+ {
+ public:
+ Errormail(const css::uno::Reference<css::lang::XMultiServiceFactory>& sf);
+ // Errormail does NOT use CDATA so it can be included
+ // in a CDATA of another XML document without further
+ // quoting
+ ::rtl::OString getXml();
+ private:
+ css::uno::Reference<css::lang::XMultiServiceFactory> m_ServiceFactory;
+ };
+ #undef css
+}
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/oooimprovement/invite_job.cxx b/extensions/source/oooimprovement/invite_job.cxx
new file mode 100644
index 000000000000..59c84acde617
--- /dev/null
+++ b/extensions/source/oooimprovement/invite_job.cxx
@@ -0,0 +1,136 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+
+
+#include "invite_job.hxx"
+#include "config.hxx"
+#include "logstorage.hxx"
+#include <com/sun/star/oooimprovement/XCore.hpp>
+#include <rtl/process.h>
+
+
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::task;
+using namespace ::com::sun::star::uno;
+using ::com::sun::star::oooimprovement::XCore;
+using ::rtl::OUString;
+
+namespace
+{
+ // dont show Invitation, when:
+ // -nofirststartwizard commandline switch is present
+ // [add additional conditions here]
+ static bool lcl_IsInvitationAllowed()
+ {
+ static OUString sNoFirstStartWizard = OUString::createFromAscii("-nofirststartwizard");
+ sal_Int32 nCount = rtl_getAppCommandArgCount();
+ for(sal_Int32 nCurrent=0; nCurrent<nCount; nCurrent++)
+ {
+ OUString sArg;
+ rtl_getAppCommandArg(nCurrent, &sArg.pData);
+ if(sNoFirstStartWizard == sArg)
+ return false;
+ }
+ return true;
+ }
+}
+
+namespace oooimprovement
+{
+// InviteJob::InviteJob(const Reference<XComponentContext>& context)
+// : m_ServiceFactory(Reference<XMultiServiceFactory>(
+// context->getServiceManager()->createInstanceWithContext(
+// OUString::createFromAscii("com.sun.star.lang.XMultiServiceFactory"), context),
+// UNO_QUERY))
+// { }
+
+ InviteJob::InviteJob(const Reference<XMultiServiceFactory>& sf)
+ : m_ServiceFactory(sf)
+ { }
+
+ InviteJob::~InviteJob()
+ { }
+
+ void SAL_CALL InviteJob::executeAsync(const Sequence<NamedValue>&, const Reference<XJobListener>& listener) throw(RuntimeException)
+ {
+ Config config(m_ServiceFactory);
+ {
+ LogStorage log_storage(m_ServiceFactory);
+ log_storage.assureExists();
+ }
+ if(config.getOfficeStartCounterdown() > 0)
+ config.decrementOfficeStartCounterdown(1);
+ else
+ {
+ if(lcl_IsInvitationAllowed() && !config.getShowedInvitation())
+ {
+ Reference<XCore> core(
+ m_ServiceFactory->createInstance(OUString::createFromAscii("com.sun.star.oooimprovement.Core")),
+ UNO_QUERY);
+ if(core.is()) core->inviteUser();
+ }
+ }
+ Any result;
+ listener->jobFinished(Reference<XAsyncJob>(this), result);
+ }
+
+ sal_Bool SAL_CALL InviteJob::supportsService(const OUString& service_name) throw(RuntimeException)
+ {
+ const Sequence<OUString> service_names(getSupportedServiceNames());
+ for (sal_Int32 idx = service_names.getLength()-1; idx>=0; --idx)
+ if(service_name == service_names[idx]) return sal_True;
+ return sal_False;
+ }
+
+ OUString SAL_CALL InviteJob::getImplementationName() throw(RuntimeException)
+ { return getImplementationName_static(); }
+
+ Sequence<OUString> SAL_CALL InviteJob::getSupportedServiceNames() throw(RuntimeException)
+ { return getSupportedServiceNames_static(); }
+
+ OUString SAL_CALL InviteJob::getImplementationName_static()
+ { return OUString::createFromAscii("com.sun.star.comp.extensions.oooimprovement.InviteJob"); }
+
+ Sequence<OUString> SAL_CALL InviteJob::getSupportedServiceNames_static()
+ {
+ Sequence<OUString> aServiceNames(1);
+ aServiceNames[0] = OUString::createFromAscii("com.sun.star.task.XAsyncJob");
+ return aServiceNames;
+ }
+
+// Reference<XInterface> InviteJob::Create(const Reference<XComponentContext>& context)
+// { return *(new InviteJob(context)); }
+
+ Reference<XInterface> InviteJob::Create(const Reference<XMultiServiceFactory>& sm)
+ { return *(new InviteJob(sm)); }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/oooimprovement/invite_job.hxx b/extensions/source/oooimprovement/invite_job.hxx
new file mode 100644
index 000000000000..fc2feb515a85
--- /dev/null
+++ b/extensions/source/oooimprovement/invite_job.hxx
@@ -0,0 +1,85 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+
+
+#ifndef EXTENSIONS_OOOIMPROVEMENT_INVITEJOB_HXX
+#define EXTENSIONS_OOOIMPROVEMENT_INVITEJOB_HXX
+
+#include <com/sun/star/task/XAsyncJob.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/uno/XComponentContext.hpp>
+#include <cppuhelper/implbase2.hxx>
+
+
+namespace oooimprovement
+{
+ #ifdef css
+ #error css defined globally
+ #endif
+ #define css ::com::sun::star
+ class InviteJob : public ::cppu::WeakImplHelper2<
+ css::task::XAsyncJob,
+ css::lang::XServiceInfo>
+ {
+ public:
+ // XServiceInfo - static version
+ static ::rtl::OUString SAL_CALL getImplementationName_static();
+ static css::uno::Sequence< ::rtl::OUString> SAL_CALL getSupportedServiceNames_static();
+ //static css::uno::Reference< css::uno::XInterface> SAL_CALL Create(
+ // const css::uno::Reference< css::uno::XComponentContext>& context);
+
+ static css::uno::Reference< css::uno::XInterface> SAL_CALL Create(const css::uno::Reference< css::lang::XMultiServiceFactory>& sm);
+
+ protected:
+ InviteJob(const css::uno::Reference< css::uno::XComponentContext>& context);
+ InviteJob(const css::uno::Reference< css::lang::XMultiServiceFactory>& sf);
+ virtual ~InviteJob();
+
+ // XAsyncJob
+ virtual void SAL_CALL executeAsync(
+ const css::uno::Sequence< css::beans::NamedValue>& args,
+ const css::uno::Reference< css::task::XJobListener>& listener)
+ throw(css::uno::RuntimeException);
+
+ // XServiceInfo
+ virtual ::rtl::OUString SAL_CALL getImplementationName()
+ throw(css::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsService(const ::rtl::OUString& service_name)
+ throw(css::uno::RuntimeException);
+ virtual css::uno::Sequence< ::rtl::OUString> SAL_CALL getSupportedServiceNames()
+ throw(css::uno::RuntimeException);
+
+ private:
+ css::uno::Reference< css::lang::XMultiServiceFactory> m_ServiceFactory;
+ };
+ #undef css
+}
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/oooimprovement/logpacker.cxx b/extensions/source/oooimprovement/logpacker.cxx
new file mode 100644
index 000000000000..59dadca7a3bb
--- /dev/null
+++ b/extensions/source/oooimprovement/logpacker.cxx
@@ -0,0 +1,117 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+
+#include "logpacker.hxx"
+#include <com/sun/star/ucb/XSimpleFileAccess.hpp>
+#include <com/sun/star/lang/XSingleServiceFactory.hpp>
+#include <com/sun/star/embed/XStorage.hpp>
+#include <com/sun/star/embed/XTransactedObject.hpp>
+#include <com/sun/star/embed/ElementModes.hpp>
+#include <rtl/ustrbuf.hxx>
+
+
+using namespace com::sun::star::embed;
+using namespace com::sun::star::io;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::uno;
+using ::com::sun::star::ucb::XSimpleFileAccess;
+using ::rtl::OUString;
+using ::rtl::OUStringBuffer;
+
+
+namespace
+{
+ static const OUString getZipfileurl(const OUString& csvfileurl)
+ {
+ OUStringBuffer buf(csvfileurl);
+ buf.setLength(csvfileurl.getLength()-3);
+ buf.appendAscii("zip");
+ return buf.makeStringAndClear();
+ };
+
+ static sal_Int32 countLines(const Sequence<sal_Int8>& data)
+ {
+ sal_Int32 result = 0;
+ for(sal_Int32 idx = data.getLength()-1; idx>=0; --idx)
+ if(data[idx]==0x0a) result++;
+ return result;
+ };
+}
+
+namespace oooimprovement
+{
+ LogPacker::LogPacker(const Reference<XMultiServiceFactory>& sf)
+ : m_ServiceFactory(sf)
+ {}
+
+ sal_Int32 LogPacker::pack(const OUString& fileurl)
+ {
+ Reference<XSimpleFileAccess> file_access(
+ m_ServiceFactory->createInstance(OUString::createFromAscii("com.sun.star.ucb.SimpleFileAccess")),
+ UNO_QUERY_THROW);
+
+ Reference<XStorage> storage;
+ {
+ Reference<XSingleServiceFactory> storage_factory(
+ m_ServiceFactory->createInstance(OUString::createFromAscii("com.sun.star.embed.StorageFactory")),
+ UNO_QUERY_THROW);
+ Sequence<Any> storage_init_args(2);
+ storage_init_args[0] = Any(getZipfileurl(fileurl));
+ storage_init_args[1] = Any(ElementModes::WRITE);
+ storage = Reference<XStorage>(
+ storage_factory->createInstanceWithArguments(storage_init_args),
+ UNO_QUERY_THROW);
+ }
+
+ Reference<XOutputStream> zipped_stream = storage->openStreamElement(
+ OUString::createFromAscii("logdata.csv"),
+ ElementModes::WRITE)->getOutputStream();
+ Reference<XInputStream> unzipped_stream = file_access->openFileRead(fileurl);
+ const sal_Int32 bufsize = 1024;
+ sal_Int32 read_bytes;
+ sal_Int32 logged_events = -1; // ignore header row
+ Sequence<sal_Int8> buf(bufsize);
+ do
+ {
+ read_bytes = unzipped_stream->readBytes(buf, bufsize);
+ buf.realloc(read_bytes);
+ logged_events += countLines(buf);
+ zipped_stream->writeBytes(buf);
+ } while(read_bytes == bufsize);
+ unzipped_stream->closeInput();
+ zipped_stream->flush();
+ zipped_stream->closeOutput();
+ Reference<XTransactedObject>(storage, UNO_QUERY_THROW)->commit();
+ file_access->kill(fileurl);
+ return logged_events;
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/oooimprovement/logpacker.hxx b/extensions/source/oooimprovement/logpacker.hxx
new file mode 100644
index 000000000000..52e86fd8e065
--- /dev/null
+++ b/extensions/source/oooimprovement/logpacker.hxx
@@ -0,0 +1,54 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+
+#ifndef EXTENSIONS_OOOIMPROVEMENT_LOGPACKER_HXX
+#define EXTENSIONS_OOOIMPROVEMENT_LOGPACKER_HXX
+
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <rtl/ustring.hxx>
+
+
+namespace oooimprovement
+{
+ #ifdef css
+ #error css defined globally
+ #endif
+ #define css ::com::sun::star
+ class LogPacker
+ {
+ public:
+ LogPacker(const css::uno::Reference< css::lang::XMultiServiceFactory>& sf);
+ sal_Int32 pack(const ::rtl::OUString& fileurl);
+ private:
+ const css::uno::Reference< css::lang::XMultiServiceFactory> m_ServiceFactory;
+ };
+ #undef css
+}
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/oooimprovement/logstorage.cxx b/extensions/source/oooimprovement/logstorage.cxx
new file mode 100644
index 000000000000..27313a5fb4d9
--- /dev/null
+++ b/extensions/source/oooimprovement/logstorage.cxx
@@ -0,0 +1,149 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+
+#include "logstorage.hxx"
+#include "config.hxx"
+#include <com/sun/star/ucb/XSimpleFileAccess.hpp>
+#include <com/sun/star/util/XStringSubstitution.hpp>
+
+
+using namespace com::sun::star::io;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::uno;
+using namespace com::sun::star::util;
+using ::com::sun::star::ucb::XSimpleFileAccess;
+using ::rtl::OUString;
+using ::std::vector;
+
+
+namespace
+{
+ using namespace oooimprovement;
+
+ static const OUString CSSU_PATHSUB = OUString::createFromAscii("com.sun.star.util.PathSubstitution");
+
+ static OUString getLogPathFromCfg(const Reference<XMultiServiceFactory>& sf)
+ {
+ Config config(sf);
+ OUString result=config.getLogPath();
+ Reference<XStringSubstitution> path_sub(
+ sf->createInstance(CSSU_PATHSUB),
+ UNO_QUERY);
+ if(path_sub.is())
+ result = path_sub->substituteVariables(result, sal_False);
+ return result;
+ }
+
+ static bool isZipfile(const OUString& fileurl)
+ {
+ static const OUString file_extension = OUString::createFromAscii(".zip");
+ return fileurl.match(file_extension, fileurl.getLength()-file_extension.getLength());
+ };
+
+ static bool isLogfile(const OUString& fileurl)
+ {
+ static const OUString file_extension = OUString::createFromAscii(".csv");
+ static const OUString current = OUString::createFromAscii("Current.csv");
+ return
+ fileurl.match(file_extension, fileurl.getLength()-file_extension.getLength())
+ && !fileurl.match(current, fileurl.getLength()-current.getLength());
+ };
+
+ static bool isZipOrLogFile(const OUString& fileurl)
+ {
+ return isZipfile(fileurl) || isLogfile(fileurl);
+ }
+
+ static Sequence<OUString> getAllLogStoragefiles(const Reference<XMultiServiceFactory>& sf)
+ {
+ Reference<XSimpleFileAccess> file_access(
+ sf->createInstance(OUString::createFromAscii("com.sun.star.ucb.SimpleFileAccess")),
+ UNO_QUERY_THROW);
+ return file_access->getFolderContents(
+ getLogPathFromCfg(sf),
+ false);
+ };
+
+ static vector<OUString> getLogStoragefiles(
+ const Reference<XMultiServiceFactory>& sf,
+ bool (*condition)(const OUString& path))
+ {
+ Sequence<OUString> candidates = getAllLogStoragefiles(sf);
+ vector<OUString> result;
+ result.reserve(candidates.getLength());
+ for(sal_Int32 idx=0; idx<candidates.getLength(); ++idx)
+ if(condition(candidates[idx]))
+ result.push_back(candidates[idx]);
+ return result;
+ };
+
+ static void assureLogStorageExists(const Reference<XMultiServiceFactory>& sf)
+ {
+ Reference<XSimpleFileAccess> file_access(
+ sf->createInstance(OUString::createFromAscii("com.sun.star.ucb.SimpleFileAccess")),
+ UNO_QUERY_THROW);
+ OUString log_path(getLogPathFromCfg(sf));
+ if(!file_access->isFolder(log_path))
+ file_access->createFolder(log_path);
+ };
+}
+
+namespace oooimprovement
+{
+
+ LogStorage::LogStorage(const Reference<XMultiServiceFactory>& sf)
+ : m_ServiceFactory(sf)
+ {}
+
+ void LogStorage::assureExists()
+ {
+ assureLogStorageExists(m_ServiceFactory);
+ }
+
+ void LogStorage::clear()
+ {
+ Reference<XSimpleFileAccess> file_access(
+ m_ServiceFactory->createInstance(OUString::createFromAscii("com.sun.star.ucb.SimpleFileAccess")),
+ UNO_QUERY_THROW);
+ vector<OUString> files_to_kill = getLogStoragefiles(m_ServiceFactory, &isZipOrLogFile);
+ for(vector<OUString>::iterator item = files_to_kill.begin();
+ item != files_to_kill.end();
+ item++)
+ file_access->kill(*item);
+ }
+
+ const vector<OUString> LogStorage::getUnzippedLogFiles() const
+ { return getLogStoragefiles(m_ServiceFactory, &isLogfile); }
+
+ const vector<OUString> LogStorage::getZippedLogFiles() const
+ { return getLogStoragefiles(m_ServiceFactory, &isZipfile); }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/oooimprovement/logstorage.hxx b/extensions/source/oooimprovement/logstorage.hxx
new file mode 100644
index 000000000000..f97c99a51085
--- /dev/null
+++ b/extensions/source/oooimprovement/logstorage.hxx
@@ -0,0 +1,58 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+
+#ifndef EXTENSIONS_OOOIMPROVEMENT_LOGSTORAGE_HXX
+#define EXTENSIONS_OOOIMPROVEMENT_LOGSTORAGE_HXX
+
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <rtl/ustring.hxx>
+#include <vector>
+
+
+namespace oooimprovement
+{
+ #ifdef css
+ #error css defined globally
+ #endif
+ #define css ::com::sun::star
+ class LogStorage
+ {
+ public:
+ LogStorage(const css::uno::Reference< css::lang::XMultiServiceFactory>& sf);
+ void assureExists();
+ void clear();
+ const std::vector< ::rtl::OUString> getUnzippedLogFiles() const;
+ const std::vector< ::rtl::OUString> getZippedLogFiles() const;
+ private:
+ const css::uno::Reference< css::lang::XMultiServiceFactory> m_ServiceFactory;
+ };
+ #undef css
+}
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/oooimprovement/makefile.mk b/extensions/source/oooimprovement/makefile.mk
new file mode 100644
index 000000000000..6e5d7ab0d6a2
--- /dev/null
+++ b/extensions/source/oooimprovement/makefile.mk
@@ -0,0 +1,104 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+
+PRJ=..$/..
+
+PRJNAME=extensions
+TARGET=oooimprovement
+ENABLE_EXCEPTIONS=TRUE
+
+PACKAGE=org.openoffice.Office
+ABSXCSROOT=$(SOLARXMLDIR)
+XCSROOT=..
+DTDDIR=$(ABSXCSROOT)
+XSLDIR=$(ABSXCSROOT)$/processing
+PROCESSOUT=$(MISC)$/$(TARGET)
+PROCESSORDIR=$(SOLARBINDIR)
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+
+# --- Files --------------------------------------------------------
+
+SLOFILES= \
+ $(SLO)$/myconfigurationhelper.obj \
+ $(SLO)$/config.obj \
+ $(SLO)$/corecontroller.obj \
+ $(SLO)$/errormail.obj \
+ $(SLO)$/invite_job.obj \
+ $(SLO)$/logpacker.obj \
+ $(SLO)$/logstorage.obj \
+ $(SLO)$/onlogrotate_job.obj \
+ $(SLO)$/oooimprovement_exports.obj \
+ $(SLO)$/soaprequest.obj \
+ $(SLO)$/soapsender.obj \
+
+SHL1STDLIBS= \
+ $(CPPUHELPERLIB) \
+ $(CPPULIB) \
+ $(SALLIB) \
+ $(UNOTOOLSLIB) \
+
+SHL1TARGET= $(TARGET)$(DLLPOSTFIX)
+.IF "$(GUI)"=="OS2"
+SHL1TARGET= oooimp$(DLLPOSTFIX)
+.ENDIF
+
+SHL1LIBS= $(SLB)$/$(TARGET).lib
+SHL1DEF= $(MISC)$/$(SHL1TARGET).def
+DEF1NAME= $(SHL1TARGET)
+SHL1VERSIONMAP=$(SOLARENV)/src/component.map
+
+PACKAGEDIR=$(subst,.,$/ $(PACKAGE))
+SPOOLDIR=$(MISC)$/registry$/spool
+
+XCUFILES= \
+ Jobs.xcu \
+ Logging.xcu
+
+MYXCUFILES= \
+ $(SPOOLDIR)$/$(PACKAGEDIR)$/Jobs$/Jobs-oooimprovement.xcu \
+ $(SPOOLDIR)$/$(PACKAGEDIR)$/Logging$/Logging-oooimprovement.xcu
+
+
+# --- Targets ---
+
+.INCLUDE : target.mk
+
+ALLTAR : $(MYXCUFILES)
+
+XCU_SOURCEDIR:=.
+
+$(SPOOLDIR)$/$(PACKAGEDIR)$/Jobs$/Jobs-oooimprovement.xcu : $(XCU_SOURCEDIR)$/Jobs.xcu
+ @-$(MKDIRHIER) $(@:d)
+ @$(COPY) $< $@
+
+$(SPOOLDIR)$/$(PACKAGEDIR)$/Logging$/Logging-oooimprovement.xcu : $(XCU_SOURCEDIR)$/Logging.xcu
+ @-$(MKDIRHIER) $(@:d)
+ @$(COPY) $< $@
diff --git a/extensions/source/oooimprovement/makefile.pmk b/extensions/source/oooimprovement/makefile.pmk
new file mode 100644
index 000000000000..f5c8da25b54a
--- /dev/null
+++ b/extensions/source/oooimprovement/makefile.pmk
@@ -0,0 +1,29 @@
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+XSLDIR=$(SOLARXMLDIR)$/processing
+XCSROOT=$(SOLARXMLDIR)
+ABSXCSROOT=$(SOLARXMLDIR)
+DTDDIR=$(SOLARXMLDIR)
+PROCESSOUT=$(MISC)$/$(CUSTID)
+PROCESSORDIR=$(SOLARBINDIR)
+
+# no validation by inspector class
+NO_INSPECTION=TRUE
+
diff --git a/extensions/source/oooimprovement/myconfigurationhelper.cxx b/extensions/source/oooimprovement/myconfigurationhelper.cxx
new file mode 100644
index 000000000000..88e11dfcc88d
--- /dev/null
+++ b/extensions/source/oooimprovement/myconfigurationhelper.cxx
@@ -0,0 +1,181 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+
+#include "myconfigurationhelper.hxx"
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/container/XNameAccess.hpp>
+#include <com/sun/star/container/XNameContainer.hpp>
+#include <com/sun/star/lang/XSingleServiceFactory.hpp>
+#include <rtl/ustrbuf.hxx>
+#include <vector>
+
+
+namespace css = ::com::sun::star;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::uno;
+using ::rtl::OUString;
+using ::rtl::OUStringBuffer;
+using ::std::vector;
+
+
+namespace
+{
+ static const Sequence<Any> sequenceFromVector(const vector<Any>& vec)
+ {
+ Sequence<Any> result(vec.size());
+ for(size_t idx = 0; idx < vec.size(); ++idx)
+ result[idx] = vec[idx];
+ return result;
+ };
+
+ static const OUString noSuchElement(const OUString& path)
+ {
+ OUStringBuffer buf(256);
+ buf.appendAscii("The requested path \"");
+ buf.append(path);
+ buf.appendAscii("\" does not exists.");
+ return buf.makeStringAndClear();
+ };
+}
+
+namespace oooimprovement
+{
+ Reference<XInterface> MyConfigurationHelper::openConfig(
+ const Reference<XMultiServiceFactory> xSMGR,
+ const OUString& sPackage,
+ sal_Int32 eMode)
+ {
+ Reference<XMultiServiceFactory> xConfigProvider(
+ xSMGR->createInstance(OUString::createFromAscii("com.sun.star.configuration.ConfigurationProvider")),
+ UNO_QUERY_THROW);
+
+ vector<Any> lParams;
+ css::beans::PropertyValue aParam;
+
+ // set root path
+ aParam.Name = OUString::createFromAscii("nodepath");
+ aParam.Value <<= sPackage;
+ lParams.push_back(makeAny(aParam));
+
+ // enable all locales mode
+ if ((eMode & MyConfigurationHelper::E_ALL_LOCALES)==MyConfigurationHelper::E_ALL_LOCALES)
+ {
+ aParam.Name = OUString::createFromAscii("locale");
+ aParam.Value <<= OUString::createFromAscii("*");
+ lParams.push_back(makeAny(aParam));
+ }
+
+ // enable lazy writing
+ sal_Bool bLazy = ((eMode & MyConfigurationHelper::E_LAZY_WRITE)==MyConfigurationHelper::E_LAZY_WRITE);
+ aParam.Name = OUString::createFromAscii("lazywrite");
+ aParam.Value = makeAny(bLazy);
+ lParams.push_back(makeAny(aParam));
+
+ // open it
+ Reference<XInterface> xCFG;
+
+ sal_Bool bReadOnly = ((eMode & MyConfigurationHelper::E_READONLY)==MyConfigurationHelper::E_READONLY);
+ if (bReadOnly)
+ xCFG = xConfigProvider->createInstanceWithArguments(
+ OUString::createFromAscii("com.sun.star.configuration.ConfigurationAccess"),
+ sequenceFromVector(lParams));
+ else
+ xCFG = xConfigProvider->createInstanceWithArguments(
+ OUString::createFromAscii("com.sun.star.configuration.ConfigurationUpdateAccess"),
+ sequenceFromVector(lParams));
+ return xCFG;
+ }
+
+ Any MyConfigurationHelper::readRelativeKey(
+ const Reference<XInterface> xCFG,
+ const OUString& sRelPath,
+ const OUString& sKey)
+ {
+ Reference<css::container::XHierarchicalNameAccess> xAccess(xCFG, UNO_QUERY_THROW);
+
+ Reference<css::beans::XPropertySet> xProps;
+ xAccess->getByHierarchicalName(sRelPath) >>= xProps;
+ if (!xProps.is())
+ throw css::container::NoSuchElementException(
+ noSuchElement(sRelPath),
+ Reference<XInterface>());
+ return xProps->getPropertyValue(sKey);
+ }
+
+ void MyConfigurationHelper::writeRelativeKey(
+ const Reference<XInterface> xCFG,
+ const OUString& sRelPath,
+ const OUString& sKey,
+ const Any& aValue)
+ {
+ Reference<css::container::XHierarchicalNameAccess> xAccess(xCFG, UNO_QUERY_THROW);
+
+ Reference<css::beans::XPropertySet> xProps;
+ xAccess->getByHierarchicalName(sRelPath) >>= xProps;
+ if (!xProps.is())
+ throw css::container::NoSuchElementException(
+ noSuchElement(sRelPath),
+ Reference<XInterface>());
+ xProps->setPropertyValue(sKey, aValue);
+ }
+
+ Any MyConfigurationHelper::readDirectKey(
+ const Reference<XMultiServiceFactory> xSMGR,
+ const OUString& sPackage,
+ const OUString& sRelPath,
+ const OUString& sKey,
+ sal_Int32 eMode)
+ {
+ Reference<XInterface> xCFG = MyConfigurationHelper::openConfig(xSMGR, sPackage, eMode);
+ return MyConfigurationHelper::readRelativeKey(xCFG, sRelPath, sKey);
+ }
+
+ void MyConfigurationHelper::writeDirectKey(
+ const Reference<XMultiServiceFactory> xSMGR,
+ const OUString& sPackage,
+ const OUString& sRelPath,
+ const OUString& sKey,
+ const Any& aValue,
+ sal_Int32 eMode)
+ {
+ Reference<XInterface> xCFG = MyConfigurationHelper::openConfig(xSMGR, sPackage, eMode);
+ MyConfigurationHelper::writeRelativeKey(xCFG, sRelPath, sKey, aValue);
+ MyConfigurationHelper::flush(xCFG);
+ }
+
+ void MyConfigurationHelper::flush(const Reference<XInterface>& xCFG)
+ {
+ Reference<css::util::XChangesBatch> xBatch(xCFG, UNO_QUERY_THROW);
+ xBatch->commitChanges();
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/oooimprovement/myconfigurationhelper.hxx b/extensions/source/oooimprovement/myconfigurationhelper.hxx
new file mode 100644
index 000000000000..96936bcb9656
--- /dev/null
+++ b/extensions/source/oooimprovement/myconfigurationhelper.hxx
@@ -0,0 +1,217 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+
+#ifndef EXTENSIONS_OOOIMPROVEMENT_CONFIGURATIONHELPER_HXX
+#define EXTENSIONS_OOOIMPROVEMENT_CONFIGURATIONHELPER_HXX
+
+#include <com/sun/star/uno/XInterface.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/beans/PropertyValue.hpp>
+#include <com/sun/star/container/XHierarchicalNameAccess.hpp>
+#include <com/sun/star/util/XChangesBatch.hpp>
+#include <rtl/ustring.hxx>
+
+
+namespace oooimprovement
+{
+ #ifdef css
+ #error css defined globally
+ #endif
+ #define css ::com::sun::star
+ // Copy from comphelper module, we cant use that directly from an extension
+ class MyConfigurationHelper
+ {
+ public:
+ //-----------------------------------------------
+ /** specify all possible modes, which can be used to open a configuration access.
+ *
+ * @see openConfig()
+ * @see readDirectKey()
+ * @see writeDirectKey()
+ */
+ enum EConfigurationModes
+ {
+ /// opens configuration in read/write mode (without LAZY writing!)
+ E_STANDARD = 0,
+ /// configuration will be opened readonly
+ E_READONLY = 1,
+ /// all localized nodes will be interpreted as css::uno::XInterface instead of interpreting it as atomic value nodes
+ E_ALL_LOCALES = 2,
+ /// enable lazy writing
+ E_LAZY_WRITE = 4
+ };
+
+ //-----------------------------------------------
+ /** returns access to the specified configuration package.
+ *
+ * This method should be used, if e.g. more then one request to the same
+ * configuration package is needed. The configuration access can be cached
+ * outside and used inbetween.
+ *
+ * @param xSMGR
+ * the uno service manager, which should be used to create the
+ * configuration access.
+ *
+ * @param sPackage
+ * the name of the configuration package.
+ * e.g. <ul>
+ * <li>org.openoffice.Office.Common</li>
+ * <li>org.openoffice.Office.Common/Menu</li>
+ * </ul>
+ *
+ * @param eMode
+ * specify the open mode for the returned configuration access.
+ * It's interpreted as a flag field and can be any usefull combination
+ * of values of EConfigurationModes.
+ *
+ * @throw css::uno::Any exceptions the underlying configuration can throw.
+ * E.g. css::uno::Exception if the configuration could not be opened.
+ */
+ static css::uno::Reference< css::uno::XInterface> openConfig(
+ const css::uno::Reference< css::lang::XMultiServiceFactory> xSMGR,
+ const ::rtl::OUString& sPackage,
+ sal_Int32 eMode);
+
+ //-----------------------------------------------
+ /** reads the value of an existing(!) configuration key,
+ * which is searched relative to the specified configuration access.
+ *
+ * This method must be used in combination with openConfig().
+ * The cached configuration access must be provided here ... and
+ * all operations are made relativ to this access point.
+ *
+ * @param xCFG
+ * the configuration root, where sRelPath should be interpreted.
+ * as relativ path
+ *
+ * @param sRelPath
+ * path relative to xCFG parameter.
+ *
+ * @param sKey
+ * the configuration node, where we should read the value.
+ *
+ * @return [css.uno.css::uno::Any]
+ * the value of sKey.
+ *
+ * @throw css::uno::Any exceptions the underlying configuration can throw.
+ * E.g. css::container::NoSuchElementException if the specified
+ * key does not exists.
+ */
+ static css::uno::Any readRelativeKey(
+ const css::uno::Reference< css::uno::XInterface> xCFG,
+ const ::rtl::OUString& sRelPath,
+ const ::rtl::OUString& sKey);
+
+ //-----------------------------------------------
+ /** writes a new value for an existing(!) configuration key,
+ * which is searched relative to the specified configuration access.
+ *
+ * This method must be used in combination with openConfig().
+ * The cached configuration access must be provided here ... and
+ * all operations are made relativ to this access point.
+ *
+ * @param xCFG
+ * the configuration root, where sRelPath should be interpreted.
+ * as relativ path
+ *
+ * @param sRelPath
+ * path relative to xCFG parameter.
+ *
+ * @param sKey
+ * the configuration node, where we should write the new value.
+ *
+ * @param aValue
+ * the new value for sKey.
+ *
+ * @throw css::uno::Any exceptions the underlying configuration can throw.
+ * E.g. css::container::NoSuchElementException if the specified
+ * key does not exists or css::uno::Exception if the provided configuration
+ * access does not allow writing for this key.
+ */
+ static void writeRelativeKey(
+ const css::uno::Reference< css::uno::XInterface> xCFG,
+ const ::rtl::OUString& sRelPath,
+ const ::rtl::OUString& sKey,
+ const css::uno::Any& aValue);
+
+ //-----------------------------------------------
+ /** commit all changes made on the specified configuration access.
+ *
+ * This method must be used in combination with openConfig().
+ * The cached configuration access must be provided here.
+ *
+ * @param xCFG
+ * the configuration root, where changes should be commited.
+ *
+ * @throw css::uno::Any exceptions the underlying configuration can throw.
+ * E.g. uno::Exception if the provided configuration
+ * access does not allow writing for this set.
+ */
+ static void flush(const css::uno::Reference< css::uno::XInterface>& xCFG);
+
+ //-----------------------------------------------
+ /** does the same then openConfig() & readRelativeKey() together.
+ *
+ * This method should be used for reading one key at one code place only.
+ * Because it opens the specified configuration package, reads the key and
+ * closes the configuration again.
+ *
+ * So its not very usefull to use this method for reading multiple keys at the same time.
+ * (Excepting these keys exists inside different configuration packages ...))
+ */
+ static css::uno::Any readDirectKey(
+ const css::uno::Reference< css::lang::XMultiServiceFactory> xSMGR,
+ const ::rtl::OUString& sPackage,
+ const ::rtl::OUString& sRelPath,
+ const ::rtl::OUString& sKey,
+ sal_Int32 eMode);
+
+ //-----------------------------------------------
+ /** does the same then openConfig() / writeRelativeKey() & flush() together.
+ *
+ * This method should be used for writing one key at one code place only.
+ * Because it opens the specified configuration package, writes the key, flush
+ * all changes and closes the configuration again.
+ *
+ * So its not very usefull to use this method for writing multiple keys at the same time.
+ * (Excepting these keys exists inside different configuration packages ...))
+ */
+ static void writeDirectKey(
+ const css::uno::Reference< css::lang::XMultiServiceFactory> xSMGR,
+ const ::rtl::OUString& sPackage,
+ const ::rtl::OUString& sRelPath,
+ const ::rtl::OUString& sKey,
+ const css::uno::Any& aValue,
+ sal_Int32 eMode);
+ };
+ #undef css
+}
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/oooimprovement/onlogrotate_job.cxx b/extensions/source/oooimprovement/onlogrotate_job.cxx
new file mode 100644
index 000000000000..da78298b6145
--- /dev/null
+++ b/extensions/source/oooimprovement/onlogrotate_job.cxx
@@ -0,0 +1,205 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+
+#include "onlogrotate_job.hxx"
+#include "config.hxx"
+#include "logpacker.hxx"
+#include "logstorage.hxx"
+#include "soaprequest.hxx"
+#include "soapsender.hxx"
+
+#include <com/sun/star/ucb/XSimpleFileAccess.hpp>
+#include <osl/mutex.hxx>
+#include <osl/thread.hxx>
+#include <osl/time.h>
+
+
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::task;
+using namespace ::com::sun::star::uno;
+using ::com::sun::star::ucb::XSimpleFileAccess;
+using ::rtl::OUString;
+using ::std::vector;
+
+namespace
+{
+ using namespace oooimprovement;
+
+ static void packLogs(const Reference<XMultiServiceFactory>& sf)
+ {
+ try
+ {
+ Config config(sf);
+ LogPacker log_packer(sf);
+ vector<OUString> csvfiles = LogStorage(sf).getUnzippedLogFiles();
+ for(
+ vector<OUString>::iterator item = csvfiles.begin();
+ item!=csvfiles.end();
+ item++)
+ config.incrementEventCount(log_packer.pack(*item));
+ } catch(...) {};
+ };
+
+ static void uploadLogs(const Reference<XMultiServiceFactory>& sf)
+ {
+ try
+ {
+ Config config(sf);
+ Reference<XSimpleFileAccess> file_access(
+ sf->createInstance(OUString::createFromAscii("com.sun.star.ucb.SimpleFileAccess")),
+ UNO_QUERY_THROW);
+ SoapSender sender(sf, config.getSoapUrl());
+ OUString soap_id = config.getSoapId();
+ vector<OUString> zipfiles = LogStorage(sf).getZippedLogFiles();
+ for(
+ vector<OUString>::iterator item = zipfiles.begin();
+ item!=zipfiles.end();
+ item++)
+ {
+ if(config.incrementFailedAttempts(1) > 25)
+ {
+ config.giveupUploading();
+ LogStorage(sf).clear();
+ return;
+ }
+ sender.send(SoapRequest(sf, soap_id, *item));
+ config.incrementReportCount(1);
+ file_access->kill(*item);
+ config.resetFailedAttempts();
+ }
+ } catch(...) {};
+ }
+
+ class OnLogRotateThread : public ::osl::Thread
+ {
+ public:
+ OnLogRotateThread(Reference<XMultiServiceFactory> sf);
+ virtual void SAL_CALL run();
+ void disposing();
+ private:
+ Reference<XMultiServiceFactory> m_ServiceFactory;
+ ::osl::Mutex m_ServiceFactoryMutex;
+ };
+
+ OnLogRotateThread::OnLogRotateThread(Reference<XMultiServiceFactory> sf)
+ : m_ServiceFactory(sf)
+ { }
+
+ void SAL_CALL OnLogRotateThread::run()
+ {
+ {
+ ::osl::Thread::yield();
+ TimeValue wait_intervall = {30,0};
+ osl_waitThread(&wait_intervall);
+ }
+ {
+ ::osl::Guard< ::osl::Mutex> service_factory_guard(m_ServiceFactoryMutex);
+ if(m_ServiceFactory.is())
+ {
+ if(Config(m_ServiceFactory).getInvitationAccepted())
+ {
+ packLogs(m_ServiceFactory);
+ uploadLogs(m_ServiceFactory);
+ }
+ else
+ LogStorage(m_ServiceFactory).clear();
+ }
+ m_ServiceFactory.clear();
+ }
+ }
+
+ void OnLogRotateThread::disposing()
+ {
+ ::osl::Guard< ::osl::Mutex> service_factory_guard(m_ServiceFactoryMutex);
+ m_ServiceFactory.clear();
+ }
+}
+
+namespace oooimprovement
+{
+ OnLogRotateJob::OnLogRotateJob(const Reference<XComponentContext>& context)
+ : m_ServiceFactory(Reference<XMultiServiceFactory>(
+ context->getServiceManager()->createInstanceWithContext(
+ OUString::createFromAscii("com.sun.star.lang.XMultiServiceFactory"), context),
+ UNO_QUERY))
+ { }
+
+ OnLogRotateJob::OnLogRotateJob(const Reference<XMultiServiceFactory>& sf)
+ : m_ServiceFactory(sf)
+ { }
+
+ OnLogRotateJob::~OnLogRotateJob()
+ { }
+
+ void SAL_CALL OnLogRotateJob::executeAsync(
+ const Sequence<NamedValue>&,
+ const Reference<XJobListener>& listener)
+ throw(RuntimeException)
+ {
+ OnLogRotateThread* thread = new OnLogRotateThread(m_ServiceFactory);
+ thread->create();
+
+ Any result;
+ listener->jobFinished(Reference<XAsyncJob>(this), result);
+ }
+
+ sal_Bool SAL_CALL OnLogRotateJob::supportsService(const OUString& service_name) throw(RuntimeException)
+ {
+ const Sequence<OUString> service_names(getSupportedServiceNames());
+ for (sal_Int32 idx = service_names.getLength()-1; idx>=0; --idx)
+ if(service_name == service_names[idx]) return sal_True;
+ return sal_False;
+ }
+
+ OUString SAL_CALL OnLogRotateJob::getImplementationName() throw(RuntimeException)
+ { return getImplementationName_static(); }
+
+ Sequence<OUString> SAL_CALL OnLogRotateJob::getSupportedServiceNames() throw(RuntimeException)
+ { return getSupportedServiceNames_static(); }
+
+ OUString SAL_CALL OnLogRotateJob::getImplementationName_static()
+ { return OUString::createFromAscii("com.sun.star.comp.extensions.oooimprovement.OnLogRotateJob"); }
+
+ Sequence<OUString> SAL_CALL OnLogRotateJob::getSupportedServiceNames_static()
+ {
+ Sequence<OUString> aServiceNames(1);
+ aServiceNames[0] = OUString::createFromAscii("com.sun.star.task.XAsyncJob");
+ return aServiceNames;
+ }
+
+ Reference<XInterface> OnLogRotateJob::Create(const Reference<XComponentContext>& context)
+ { return *(new OnLogRotateJob(context)); }
+
+ Reference<XInterface> OnLogRotateJob::Create(const Reference<XMultiServiceFactory>& sf)
+ { return *(new OnLogRotateJob(sf)); }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/oooimprovement/onlogrotate_job.hxx b/extensions/source/oooimprovement/onlogrotate_job.hxx
new file mode 100644
index 000000000000..5832c44d658d
--- /dev/null
+++ b/extensions/source/oooimprovement/onlogrotate_job.hxx
@@ -0,0 +1,86 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+
+
+#ifndef EXTENSIONS_OOOIMPROVEMENT_ONLOGROTATEJOB_HXX
+#define EXTENSIONS_OOOIMPROVEMENT_ONLOGROTATEJOB_HXX
+
+#include <com/sun/star/task/XAsyncJob.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/uno/XComponentContext.hpp>
+#include <cppuhelper/implbase2.hxx>
+
+
+namespace oooimprovement
+{
+ #ifdef css
+ #error css defined globally
+ #endif
+ #define css ::com::sun::star
+ class OnLogRotateJob : public ::cppu::WeakImplHelper2<
+ ::com::sun::star::task::XAsyncJob,
+ ::com::sun::star::lang::XServiceInfo>
+ {
+ public:
+ // XServiceInfo - static version
+ static ::rtl::OUString SAL_CALL getImplementationName_static();
+ static ::com::sun::star::uno::Sequence< ::rtl::OUString> SAL_CALL getSupportedServiceNames_static();
+ static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface> SAL_CALL Create(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext>& context);
+
+ static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface> SAL_CALL Create(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory>& sf);
+
+ protected:
+ OnLogRotateJob(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext>& context);
+ OnLogRotateJob(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory>& sm);
+ virtual ~OnLogRotateJob();
+
+ // XAsyncJob
+ virtual void SAL_CALL executeAsync(
+ const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue>& args,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::task::XJobListener>& listener)
+ throw(::com::sun::star::uno::RuntimeException);
+
+ // XServiceInfo
+ virtual ::rtl::OUString SAL_CALL getImplementationName()
+ throw(::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsService(const ::rtl::OUString& service_name)
+ throw(::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString> SAL_CALL getSupportedServiceNames()
+ throw(::com::sun::star::uno::RuntimeException);
+
+ private:
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory> m_ServiceFactory;
+ };
+ #undef css
+}
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/oooimprovement/oooimprovement_exports.cxx b/extensions/source/oooimprovement/oooimprovement_exports.cxx
new file mode 100644
index 000000000000..eed57333d3de
--- /dev/null
+++ b/extensions/source/oooimprovement/oooimprovement_exports.cxx
@@ -0,0 +1,113 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+
+#include "corecontroller.hxx"
+#include "invite_job.hxx"
+#include "onlogrotate_job.hxx"
+#include <com/sun/star/lang/XSingleServiceFactory.hpp>
+#include <cppuhelper/factory.hxx>
+#include <osl/mutex.hxx>
+#include <osl/thread.h>
+#include <rtl/ustrbuf.hxx>
+#include <rtl/ustring.hxx>
+
+
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::registry;
+using namespace ::com::sun::star::uno;
+using namespace ::oooimprovement;
+using ::rtl::OUString;
+using ::rtl::OUStringBuffer;
+
+
+namespace
+{
+ void writeInfo(const Reference<XRegistryKey>& reg_key,
+ const OUString& implementation_name,
+ const OUString& service_name)
+ {
+ OUStringBuffer buf(256);
+ buf.append(implementation_name);
+ buf.appendAscii("/UNO/SERVICES/");
+ buf.append(service_name);
+ reg_key->createKey(buf.makeStringAndClear());
+ }
+}
+
+extern "C"
+{
+ void SAL_CALL component_getImplementationEnvironment(const sal_Char** env_type_name, uno_Environment**)
+ { *env_type_name = CPPU_CURRENT_LANGUAGE_BINDING_NAME; }
+
+ sal_Bool SAL_CALL component_writeInfo(void*, void* p_reg_key)
+ {
+ if (!p_reg_key) return sal_False;
+ try
+ {
+ Reference<XRegistryKey> reg_key(reinterpret_cast<XRegistryKey*>(p_reg_key), UNO_QUERY);
+ writeInfo(reg_key,
+ CoreController::getImplementationName_static(),
+ CoreController::getSupportedServiceNames_static()[0]);
+ writeInfo(reg_key,
+ OnLogRotateJob::getImplementationName_static(),
+ OnLogRotateJob::getSupportedServiceNames_static()[0]);
+ writeInfo(reg_key,
+ InviteJob::getImplementationName_static(),
+ InviteJob::getSupportedServiceNames_static()[0]);
+ return sal_True;
+ }
+ catch(const InvalidRegistryException&)
+ { OSL_ENSURE( sal_False, "### InvalidRegistryException!" ); }
+ return sal_False;
+ }
+
+ void* SAL_CALL component_getFactory(const sal_Char* pImplName, void* pServiceManager, void*)
+ {
+ if ( !pServiceManager || !pImplName ) return 0;
+
+ Reference<XSingleServiceFactory> factory;
+ Reference<XMultiServiceFactory> sm(reinterpret_cast<XMultiServiceFactory*>(pServiceManager), UNO_QUERY);
+ OUString impl_name = OUString::createFromAscii(pImplName);
+ Sequence<OUString> names(1);
+ names[0] = impl_name;
+
+ if (impl_name.equals(CoreController::getImplementationName_static()))
+ factory = ::cppu::createSingleFactory(sm, impl_name, CoreController::Create, names);
+ if (impl_name.equals(OnLogRotateJob::getImplementationName_static()))
+ factory = ::cppu::createSingleFactory(sm, impl_name, OnLogRotateJob::Create, names);
+ if (impl_name.equals(InviteJob::getImplementationName_static()))
+ factory = ::cppu::createSingleFactory(sm, impl_name, InviteJob::Create, names);
+ if (!factory.is()) return 0;
+ factory->acquire();
+ return factory.get();
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/oooimprovement/soaprequest.cxx b/extensions/source/oooimprovement/soaprequest.cxx
new file mode 100644
index 000000000000..c2dc4b348ef4
--- /dev/null
+++ b/extensions/source/oooimprovement/soaprequest.cxx
@@ -0,0 +1,203 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+
+#include "soaprequest.hxx"
+#include "errormail.hxx"
+#include "config.hxx"
+#include <boost/shared_ptr.hpp>
+#include <com/sun/star/lang/XMultiComponentFactory.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/ucb/XSimpleFileAccess.hpp>
+#include <rtl/strbuf.hxx>
+#include <rtl/ustring.hxx>
+
+
+using namespace com::sun::star::uno;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::io;
+using boost::shared_ptr;
+using com::sun::star::io::XOutputStream;
+using com::sun::star::ucb::XSimpleFileAccess;
+using rtl::OUString;
+using rtl::OString;
+using rtl::OStringBuffer;
+
+
+namespace
+{
+ static unsigned long asUlong(sal_Int8 input)
+ {
+ return *reinterpret_cast<unsigned char *>(&input);
+ };
+
+ static Sequence<sal_Int8> base64_encode(const Sequence<sal_Int8>& input)
+ {
+ static const char base64_tab[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
+ Sequence<sal_Int8> result(4);
+ unsigned long value = asUlong(input[0]) << 16;
+ if(input.getLength() > 1) value |= asUlong(input[1]) << 8;
+ if(input.getLength() > 2) value |= asUlong(input[2]);
+
+ result[0] = static_cast<sal_Int8>(base64_tab[(value >> 18) & 0x3F]);
+ result[1] = static_cast<sal_Int8>(base64_tab[(value >> 12) & 0x3F]);
+ result[2] = static_cast<sal_Int8>('=');
+ result[3] = static_cast<sal_Int8>('=');
+
+ if (input.getLength() > 1)
+ {
+ result[2] = base64_tab[(value >> 6) & 0x3F];
+ if (input.getLength() > 2)
+ result[3] = base64_tab[(value >> 0) & 0x3F];
+ }
+ return result;
+ };
+
+ static OString replaceAll(const OString& str, sal_Char old, const OString& replacement)
+ {
+ OStringBuffer result;
+ sal_Int32 idx = 0;
+ do {
+ result.append(str.getToken(0, old, idx));
+ if(idx>=0) result.append(replacement);
+ } while(idx >= 0);
+ return result.makeStringAndClear();
+ };
+
+ static OString xmlEncode(const OString& input)
+ {
+ OString result = replaceAll(input, '&', OString("&amp;"));
+ result = replaceAll(result, '<', OString("&lt;"));
+ return replaceAll(result, '>', OString("&gt;"));
+ }
+
+ static shared_ptr<Sequence<sal_Int8> > createSequenceFromString(const OString& str)
+ {
+ const sal_Int32 size = str.getLength();
+ shared_ptr<Sequence<sal_Int8> > result(new Sequence<sal_Int8>(size));
+ for(sal_Int32 idx=0; idx < size; idx++)
+ (*result)[idx] = str[idx];
+ return result;
+ };
+
+ static void writeString(const Reference<XOutputStream>& target, const OString& str)
+ {
+ shared_ptr<Sequence<sal_Int8> > seq = createSequenceFromString(str);
+ target->writeBytes(*seq);
+ };
+
+ static void writeFile(const Reference<XMultiServiceFactory>& sf, const Reference<XOutputStream>& target, const OUString& fileurl)
+ {
+ Reference<XSimpleFileAccess> file_access(
+ sf->createInstance(OUString::createFromAscii("com.sun.star.ucb.SimpleFileAccess")),
+ UNO_QUERY);
+ Reference<XInputStream> file = file_access->openFileRead(fileurl);
+ const sal_Int32 bufsize = 3;
+ sal_Int32 bytes_read;
+ Sequence<sal_Int8> buf(bufsize);
+ do
+ {
+ bytes_read = file->readBytes(buf, bufsize);
+ if(bytes_read < buf.getLength()) buf.realloc(bytes_read);
+ if(bytes_read) target->writeBytes(base64_encode(buf));
+ } while(bytes_read == bufsize);
+ };
+
+ static const OString SOAP_START(
+ "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
+ "<SOAP-ENV:Envelope xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\"\n"
+ "xmlns:SOAP-ENC=\"http://schemas.xmlsoap.org/soap/encoding/\"\n"
+ "xmlns:xsi=\"http://www.w3.org/1999/XMLSchema-instance\"\n"
+ "xmlns:xsd=\"http://www.w3.org/1999/XMLSchema\"\n"
+ "xmlns:rds=\"urn:ReportDataService\"\n"
+ "xmlns:apache=\"http://xml.apache.org/xml-soap\"\n"
+ "SOAP-ENV:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\">\n"
+ "<SOAP-ENV:Body>\n"
+ "<rds:submitReport>\n");
+ static const OString SOAP_ITEMS_START("<hash xsi:type=\"apache:Map\">\n");
+ static const OString SOAP_ITEMS_END("</hash>\n");
+ static const OString SOAP_END(
+ "</rds:submitReport>\n"
+ "</SOAP-ENV:Body>\n"
+ "</SOAP-ENV:Envelope>\n");
+ static const OString SOAP_ITEM_END("]]></value></item>\n");
+
+ static const OString getSoapOfficeversion(const Reference<XMultiServiceFactory>& sf)
+ {
+ return ::rtl::OUStringToOString(oooimprovement::Config(sf).getCompleteProductname(), RTL_TEXTENCODING_ASCII_US);
+ };
+
+ static const OString getSoapSoapId(const Reference<XMultiServiceFactory>& sf, const OString& soap_id)
+ {
+ OStringBuffer buf;
+ buf.append("<body xsi:type=\"xsd:string\">");
+ buf.append(xmlEncode(soap_id)).append("\n");
+ buf.append(xmlEncode(getSoapOfficeversion(sf))).append("\n");
+ buf.append("</body>\n");
+ return buf.makeStringAndClear();
+ };
+
+ static const OString getSoapItemStart(const OString& key)
+ {
+ OStringBuffer buf =
+ "<item>\n"
+ "<key xsi:type=\"xsd:string\">" + key + "</key>\n"
+ "<value xsi:type=\"xsd:string\"><![CDATA[";
+ return buf.makeStringAndClear();
+ };
+}
+
+namespace oooimprovement
+{
+ SoapRequest::SoapRequest(const Reference<XMultiServiceFactory>& sf, const OUString& soap_id, const OUString& logfile)
+ : m_ServiceFactory(sf)
+ , m_SoapId(soap_id)
+ , m_Logfile(logfile)
+ {}
+
+ void SoapRequest::writeTo(const Reference<XOutputStream>& target) const
+ {
+ writeString(target, SOAP_START);
+ writeString(
+ target,
+ getSoapSoapId(m_ServiceFactory, rtl::OUStringToOString(m_SoapId, RTL_TEXTENCODING_ASCII_US)));
+ writeString(target, SOAP_ITEMS_START);
+ writeString(target, getSoapItemStart("reportmail.xml"));
+ writeString(target, Errormail(m_ServiceFactory).getXml());
+ writeString(target, SOAP_ITEM_END);
+ writeString(target, getSoapItemStart("data.zip"));
+ writeFile(m_ServiceFactory, target, m_Logfile);
+ writeString(target, SOAP_ITEM_END);
+ writeString(target, SOAP_ITEMS_END);
+ writeString(target, SOAP_END);
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/oooimprovement/soaprequest.hxx b/extensions/source/oooimprovement/soaprequest.hxx
new file mode 100644
index 000000000000..126bc0948343
--- /dev/null
+++ b/extensions/source/oooimprovement/soaprequest.hxx
@@ -0,0 +1,63 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+
+#ifndef EXTENSIONS_OOOIMPROVEMENT_SOAPREQUEST_HXX
+#define EXTENSIONS_OOOIMPROVEMENT_SOAPREQUEST_HXX
+
+#include <com/sun/star/io/XOutputStream.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <rtl/ustring.hxx>
+
+
+namespace oooimprovement
+{
+ #ifdef css
+ #error css defined globally
+ #endif
+ #define css ::com::sun::star
+ class SoapRequest
+ {
+ public:
+ SoapRequest(
+ const css::uno::Reference< css::lang::XMultiServiceFactory>& sf,
+ const ::rtl::OUString& soap_id,
+ const ::rtl::OUString& logfile);
+ void writeTo(const css::uno::Reference< css::io::XOutputStream>& target) const;
+ private:
+ const css::uno::Reference< css::lang::XMultiServiceFactory> m_ServiceFactory;
+ // soap_id has to be a plain 7-Bit ASCII String for identification of
+ // automated test logs etc.
+ const ::rtl::OUString m_SoapId;
+ // logfile is the file-url to the file to include
+ const ::rtl::OUString m_Logfile;
+ };
+ #undef css
+}
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/oooimprovement/soapsender.cxx b/extensions/source/oooimprovement/soapsender.cxx
new file mode 100644
index 000000000000..32a50f30e3cb
--- /dev/null
+++ b/extensions/source/oooimprovement/soapsender.cxx
@@ -0,0 +1,163 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+
+#include "soapsender.hxx"
+#include <com/sun/star/ucb/XSimpleFileAccess.hpp>
+#include <com/sun/star/uno/RuntimeException.hpp>
+#include <com/sun/star/util/XURLTransformer.hpp>
+#include <com/sun/star/io/XTempFile.hpp>
+#include <com/sun/star/io/XOutputStream.hpp>
+#include <com/sun/star/io/XInputStream.hpp>
+#include <osl/socket.hxx>
+#include <rtl/strbuf.hxx>
+#include <boost/shared_ptr.hpp>
+
+
+using namespace com::sun::star::uno;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::io;
+using boost::shared_ptr;
+using com::sun::star::io::XTempFile;
+using com::sun::star::ucb::XSimpleFileAccess;
+using com::sun::star::util::URL;
+using com::sun::star::util::XURLTransformer;
+using osl::ConnectorSocket;
+using rtl::OString;
+using rtl::OUString;
+using rtl::OStringBuffer;
+
+
+namespace
+{
+ static OString getHttpPostHeader(OString path, sal_Int32 length)
+ {
+ OStringBuffer result =
+ "POST " + path + " HTTP/1.0\r\n"
+ "Content-Type: text/xml; charset=\"utf-8\"\r\n"
+ "Content-Length: ";
+ result.append(length);
+ result.append("\r\nSOAPAction: \"\"\r\n\r\n");
+ return result.makeStringAndClear();
+ };
+}
+
+namespace oooimprovement
+{
+ SoapSender::SoapSender(const Reference<XMultiServiceFactory> sf, const OUString& url)
+ : m_ServiceFactory(sf)
+ , m_Url(url)
+ { }
+
+ void SoapSender::send(const SoapRequest& request) const
+ {
+ Reference<XTempFile> temp_file(
+ m_ServiceFactory->createInstance(OUString::createFromAscii("com.sun.star.io.TempFile")),
+ UNO_QUERY_THROW);
+ Reference<XSimpleFileAccess> file_access(
+ m_ServiceFactory->createInstance(OUString::createFromAscii("com.sun.star.ucb.SimpleFileAccess")),
+ UNO_QUERY_THROW);
+ Reference<XURLTransformer> url_trans(
+ m_ServiceFactory->createInstance(OUString::createFromAscii("com.sun.star.util.URLTransformer")),
+ UNO_QUERY_THROW);
+
+ // writing request to tempfile
+ {
+ Reference<XOutputStream> temp_stream = temp_file->getOutputStream();
+ request.writeTo(temp_stream);
+ temp_stream->flush();
+ temp_stream->closeOutput();
+ }
+
+ // parse Url
+ URL url;
+ {
+ url.Complete = m_Url;
+ url_trans->parseStrict(url);
+ }
+
+ // connect socket
+ shared_ptr<ConnectorSocket> socket(new ConnectorSocket(osl_Socket_FamilyInet, osl_Socket_ProtocolIp, osl_Socket_TypeStream));
+ {
+ ::osl::SocketAddr addr(url.Server, url.Port);
+ oslSocketResult result = socket->connect(addr);
+ if(result != osl_Socket_Ok)
+ throw RuntimeException(
+ OUString::createFromAscii("unable to connect to SOAP server"),
+ Reference<XInterface>());
+ }
+
+ // send header
+ {
+ OStringBuffer path_on_server =
+ OUStringToOString(url.Path, RTL_TEXTENCODING_ASCII_US) +
+ OUStringToOString(url.Name, RTL_TEXTENCODING_ASCII_US);
+ const OString header = getHttpPostHeader(path_on_server.makeStringAndClear(), file_access->getSize(temp_file->getUri()));
+ if(socket->write(header.getStr(), header.getLength()) != static_cast<sal_Int32>(header.getLength()))
+ throw RuntimeException(
+ OUString::createFromAscii("error while sending HTTP header"),
+ Reference<XInterface>());
+ }
+
+ // send soap request
+ {
+ Reference<XInputStream> temp_stream = file_access->openFileRead(temp_file->getUri());
+ const sal_Int32 bufsize = 1024;
+ sal_Int32 bytes_read;
+ Sequence<sal_Int8> buf(bufsize);
+ char buf2[bufsize];
+ do
+ {
+ bytes_read = temp_stream->readBytes(buf, bufsize);
+ buf.realloc(bytes_read);
+ for(sal_Int32 idx = 0; idx < bytes_read; idx++)
+ buf2[idx] = buf[idx];
+ if(socket->write(buf2, bytes_read) != bytes_read)
+ throw RuntimeException(
+ OUString::createFromAscii("error while sending SOAP request"),
+ Reference<XInterface>());
+ } while(bytes_read == bufsize);
+ }
+
+ // receive answer
+ {
+ const sal_Int32 bufsize = 1024;
+ char buf[bufsize];
+ sal_Int32 bytes_read = socket->read(buf, bufsize);
+ OString answer(buf, bytes_read);
+ const sal_Int32 returncode_start = answer.indexOf(' ');
+ if(returncode_start==-1 || !answer.copy(returncode_start, 4).equals(OString(" 200")))
+ throw RuntimeException(
+ OUString::createFromAscii("SOAP server returns a error"),
+ Reference<XInterface>());
+ }
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/oooimprovement/soapsender.hxx b/extensions/source/oooimprovement/soapsender.hxx
new file mode 100644
index 000000000000..6a3e3d6f1d51
--- /dev/null
+++ b/extensions/source/oooimprovement/soapsender.hxx
@@ -0,0 +1,59 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+
+#ifndef EXTENSIONS_OOOIMPROVEMENT_SOAPSENDER_HXX
+#define EXTENSIONS_OOOIMPROVEMENT_SOAPSENDER_HXX
+
+#include "soaprequest.hxx"
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/util/URL.hpp>
+#include <rtl/ustring.hxx>
+
+
+namespace oooimprovement
+{
+ #ifdef css
+ #error css defined globally
+ #endif
+ #define css ::com::sun::star
+ class SoapSender
+ {
+ public:
+ SoapSender(
+ const css::uno::Reference< css::lang::XMultiServiceFactory> sf,
+ const ::rtl::OUString& url);
+ void send(const SoapRequest& request) const;
+ private:
+ const css::uno::Reference< css::lang::XMultiServiceFactory> m_ServiceFactory;
+ const ::rtl::OUString m_Url;
+ };
+ #undef css
+}
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/plugin/aqua/macmgr.cxx b/extensions/source/plugin/aqua/macmgr.cxx
new file mode 100644
index 000000000000..e17b3bde2058
--- /dev/null
+++ b/extensions/source/plugin/aqua/macmgr.cxx
@@ -0,0 +1,648 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "rtl/ustrbuf.hxx"
+#include "rtl/strbuf.hxx"
+
+#include "plugin/impl.hxx"
+#include "osl/file.h"
+#include "osl/module.hxx"
+
+using namespace rtl;
+using namespace std;
+using namespace com::sun::star::uno;
+using namespace com::sun::star::plugin;
+
+namespace plugstringhelper
+{
+
+rtl::OUString getString( CFStringRef i_xString )
+{
+ rtl::OUStringBuffer aBuf;
+ if( i_xString )
+ {
+ CFIndex nChars = CFStringGetLength( i_xString );
+ CFRange aRange = { 0, nChars };
+ aBuf.setLength( nChars );
+ CFStringGetCharacters( i_xString, aRange, static_cast< UniChar* >(const_cast<sal_Unicode*>(aBuf.getStr())) );
+ }
+ return aBuf.makeStringAndClear();
+}
+
+rtl::OUString getString( CFURLRef i_xURL )
+{
+ CFStringRef xString = CFURLGetString( i_xURL );
+ return getString( xString );
+}
+
+CFMutableStringRef createString( const rtl::OUString& i_rString )
+{
+ CFMutableStringRef xString = CFStringCreateMutable( NULL, 0 );
+ if( xString )
+ CFStringAppendCharacters( xString, i_rString.getStr(), i_rString.getLength() );
+ return xString;
+}
+
+CFURLRef createURL( const rtl::OUString& i_rString )
+{
+
+ CFMutableStringRef xMutableString = createString( i_rString );
+ CFURLRef xURL = CFURLCreateWithString( NULL, xMutableString, NULL );
+ CFRelease( xMutableString );
+ return xURL;
+}
+
+rtl::OUString getURLFromPath( const rtl::OUString& i_rPath )
+{
+ CFMutableStringRef xMutableString = createString( i_rPath );
+ CFURLRef xURL = CFURLCreateWithFileSystemPath( NULL, xMutableString, kCFURLPOSIXPathStyle, true );
+ CFRelease( xMutableString );
+ CFStringRef xString = CFURLGetString( xURL );
+ rtl::OUString aRet = getString( xString );
+ CFRelease( xURL );
+ return aRet;
+}
+
+CFURLRef createURLFromPath( const rtl::OUString& i_rPath )
+{
+ CFMutableStringRef xMutableString = createString( i_rPath );
+ CFURLRef xURL = CFURLCreateWithFileSystemPath( NULL, xMutableString, kCFURLPOSIXPathStyle, true );
+ return xURL;
+}
+
+rtl::OUString CFURLtoOSLURL( CFURLRef i_xURL )
+{
+ // make URL absolute
+ CFURLRef xAbsURL = CFURLCopyAbsoluteURL( i_xURL );
+ // copy system path
+ CFStringRef xSysPath = CFURLCopyFileSystemPath( xAbsURL ? xAbsURL : i_xURL, kCFURLPOSIXPathStyle );
+ if( xAbsURL )
+ CFRelease( xAbsURL );
+ rtl::OUString aSysPath( getString( xSysPath ) );
+ CFRelease( xSysPath );
+ rtl::OUString aFileURL;
+ osl_getFileURLFromSystemPath( aSysPath.pData, &aFileURL.pData );
+ return aFileURL;
+}
+
+}
+
+using namespace plugstringhelper;
+
+static int parsePlist( CFBundleRef i_xBundle, const rtl::OUString& i_rBundleURL , list< PluginDescription* >& io_rDescriptions )
+{
+ CFTypeRef xMimeDict = CFBundleGetValueForInfoDictionaryKey( i_xBundle, CFSTR("WebPluginMIMETypes"));
+ int nMimetypes = 0;
+ if( xMimeDict == 0 ||
+ CFGetTypeID(xMimeDict) != CFDictionaryGetTypeID() ||
+ (nMimetypes = CFDictionaryGetCount( static_cast<CFDictionaryRef>(xMimeDict))) <= 0 )
+ {
+ return 0;
+ }
+
+ // prepare an array of key and value refs
+ std::vector< CFTypeRef > aKeys( nMimetypes, CFTypeRef(NULL) );
+ std::vector< CFTypeRef > aValues( nMimetypes, CFTypeRef(NULL) );
+ CFDictionaryGetKeysAndValues(static_cast<CFDictionaryRef>(xMimeDict), &aKeys[0], &aValues[0] );
+
+ int nAdded = 0;
+ for( int i = 0; i < nMimetypes; i++ )
+ {
+ // get the mimetype
+ CFTypeRef xKey = aKeys[i];
+ if( ! xKey || CFGetTypeID(xKey) != CFStringGetTypeID() )
+ continue;
+ rtl::OUString aMimetype = getString( (CFStringRef)xKey );
+
+ // the correspoding value should be a dictionary
+ CFTypeRef xDict = aValues[i];
+ if( ! xDict || CFGetTypeID( xDict ) != CFDictionaryGetTypeID() )
+ continue;
+
+ // get the extension list
+ CFTypeRef xExtArray = CFDictionaryGetValue( (CFDictionaryRef)xDict, CFSTR("WebPluginExtensions" ) );
+ if( !xExtArray || CFGetTypeID( xExtArray ) != CFArrayGetTypeID() )
+ continue;
+
+ OUStringBuffer aExtBuf;
+ int nExtensions = CFArrayGetCount( (CFArrayRef)xExtArray );
+ for( int n = 0; n < nExtensions; n++ )
+ {
+ CFTypeRef xExt = CFArrayGetValueAtIndex( (CFArrayRef)xExtArray, n );
+ if( xExt && CFGetTypeID( xExt ) == CFStringGetTypeID() )
+ {
+ if( aExtBuf.getLength() > 0 )
+ aExtBuf.append( sal_Unicode(';') );
+ OUString aExt( getString( (CFStringRef)xExt ) );
+ if( aExt.indexOfAsciiL( "*.", 2 ) != 0 )
+ aExtBuf.appendAscii( "*." );
+ aExtBuf.append( aExt );
+ }
+ }
+
+ // get the description string
+ CFTypeRef xDescString = CFDictionaryGetValue( (CFDictionaryRef)xDict, CFSTR("WebPluginTypeDescription" ) );
+ if( !xDescString || CFGetTypeID( xDescString ) != CFStringGetTypeID() )
+ continue;
+ rtl::OUString aDescription = getString( (CFStringRef)xDescString );
+
+ PluginDescription* pNew = new PluginDescription;
+ // set plugin name (path to library)
+ pNew->PluginName = i_rBundleURL;
+ // set mimetype
+ pNew->Mimetype = aMimetype;
+ // set extension line
+ pNew->Extension = aExtBuf.makeStringAndClear();
+ // set description
+ pNew->Description= aDescription;
+
+ io_rDescriptions.push_back( pNew );
+ nAdded++;
+
+#if OSL_DEBUG_LEVEL > 1
+ fprintf( stderr,
+ "Inserting from PList:\n"
+ " Mimetype: %s\n"
+ " Extension: %s\n"
+ " Description: %s\n",
+ OUStringToOString( pNew->Mimetype, RTL_TEXTENCODING_UTF8 ).getStr(),
+ OUStringToOString( pNew->Extension, RTL_TEXTENCODING_UTF8 ).getStr(),
+ OUStringToOString( pNew->Description, RTL_TEXTENCODING_UTF8 ).getStr()
+ );
+#endif
+
+ }
+
+ return nAdded;
+}
+
+static int parseMimeString( const rtl::OUString& i_rBundleURL , list< PluginDescription* >& io_rDescriptions, const char* i_pMime )
+{
+ if( ! i_pMime )
+ return 0;
+
+ rtl_TextEncoding aEncoding = osl_getThreadTextEncoding();
+
+ OStringBuffer aMIME;
+ aMIME.append( i_pMime );
+
+ if( aMIME.getLength() < 1 )
+ return 0;
+
+ OString aLine = aMIME.makeStringAndClear();
+
+ int nAdded = 0;
+ sal_Int32 nIndex = 0;
+ while( nIndex != -1 )
+ {
+ OString aType = aLine.getToken( 0, ';', nIndex );
+
+ sal_Int32 nTypeIndex = 0;
+ OString aMimetype = aType.getToken( 0, ':', nTypeIndex );
+ OString aExtLine = aType.getToken( 0, ':', nTypeIndex );
+ if( nTypeIndex < 0 ) // ensure at least three tokens
+ continue;
+ OString aDesc = aType.getToken( 0, ':', nTypeIndex );
+
+ // create extension list string
+ sal_Int32 nExtIndex = 0;
+ OStringBuffer aExtension;
+ while( nExtIndex != -1 )
+ {
+ OString aExt = aExtLine.getToken( 0, ',', nExtIndex);
+ if( aExt.indexOf( "*." ) != 0 )
+ aExtension.append( "*." );
+ aExtension.append( aExt );
+ if( nExtIndex != -1 )
+ aExtension.append( ';' );
+ }
+
+ PluginDescription* pNew = new PluginDescription;
+ // set plugin name (path to library)
+ pNew->PluginName = i_rBundleURL;
+ // set mimetype
+ pNew->Mimetype = OStringToOUString( aMimetype, aEncoding );
+ // set extension line
+ pNew->Extension = OStringToOUString( aExtension.makeStringAndClear(), aEncoding );
+ // set description
+ pNew->Description= OStringToOUString( aDesc, aEncoding );
+ io_rDescriptions.push_back( pNew );
+ nAdded++;
+
+#if OSL_DEBUG_LEVEL > 1
+ fprintf( stderr,
+ "Inserting from mime string:\n"
+ " Mimetype: %s\n"
+ " Extension: %s\n"
+ " Description: %s\n",
+ OUStringToOString( pNew->Mimetype, aEncoding ).getStr(),
+ OUStringToOString( pNew->Extension, aEncoding ).getStr(),
+ OUStringToOString( pNew->Description, aEncoding ).getStr()
+ );
+#endif
+ }
+ return nAdded;
+}
+
+// this is so ugly it you want to tear your eyes out
+static rtl::OUString GetNextPluginStringFromHandle(Handle h, short *index)
+{
+ char* pPascalBytes = (*h + *index);
+ sal_uInt32 nLen = (unsigned char)pPascalBytes[0];
+ rtl::OStringBuffer aBuf( nLen );
+ aBuf.append( pPascalBytes+1, nLen );
+ *index += nLen + 1;
+ return rtl::OStringToOUString( aBuf.makeStringAndClear(), RTL_TEXTENCODING_UTF8 );
+}
+
+static int parseMimeResource( CFBundleRef i_xBundle,
+ oslModule& i_rMod,
+ const rtl::OUString& i_rBundleURL,
+ list< PluginDescription* >& io_rDescriptions )
+{
+ int nAdded = 0;
+ // just to hurt our eyes more there is an alternative mimetype function plus the possibility
+ // of a resource fork. Must be a case of think different.
+ #if __LP64__
+ int
+ #else
+ SInt16
+ #endif
+ xRes = 0;
+ BPSupportedMIMETypes aMIMETypesStrangeStruct = {kBPSupportedMIMETypesStructVers_1, NULL, NULL};
+
+ BP_GetSupportedMIMETypesUPP pBPGetSupp = (BP_GetSupportedMIMETypesUPP)osl_getAsciiFunctionSymbol( i_rMod, "BP_GetSupportedMIMETypes" );
+ if( pBPGetSupp &&
+ noErr == pBPGetSupp( &aMIMETypesStrangeStruct, 0 ) &&
+ aMIMETypesStrangeStruct.typeStrings )
+ {
+ HLock( aMIMETypesStrangeStruct.typeStrings );
+ if( aMIMETypesStrangeStruct.infoStrings ) // it's possible some plugins have infoStrings missing
+ HLock( aMIMETypesStrangeStruct.infoStrings );
+ }
+ else // Try to get data from the resource fork
+ {
+ xRes = CFBundleOpenBundleResourceMap( i_xBundle );
+ if( xRes > 0 )
+ {
+ aMIMETypesStrangeStruct.typeStrings = Get1Resource('STR#', 128);
+ if( aMIMETypesStrangeStruct.typeStrings )
+ {
+ DetachResource( aMIMETypesStrangeStruct.typeStrings );
+ HLock( aMIMETypesStrangeStruct.typeStrings );
+ aMIMETypesStrangeStruct.infoStrings = Get1Resource('STR#', 127);
+ if( aMIMETypesStrangeStruct.infoStrings )
+ {
+ DetachResource( aMIMETypesStrangeStruct.infoStrings );
+ HLock( aMIMETypesStrangeStruct.infoStrings );
+ }
+ }
+ }
+ }
+
+ if( aMIMETypesStrangeStruct.typeStrings && aMIMETypesStrangeStruct.infoStrings )
+ {
+ short nVariantCount = (**(short**)aMIMETypesStrangeStruct.typeStrings) / 2;
+ // Fill in the info struct based on the data in the BPSupportedMIMETypes struct
+ // this is an array of pascal string of unknown (!) encoding
+ // whoever thought of this deserves a fair beating
+ short mimeIndex = 2;
+ short descriptionIndex = 2;
+ for( int i = 0; i < nVariantCount; i++ )
+ {
+ rtl::OUString aMimetype = GetNextPluginStringFromHandle( aMIMETypesStrangeStruct.typeStrings, &mimeIndex );
+ rtl::OUString aExtLine = GetNextPluginStringFromHandle( aMIMETypesStrangeStruct.typeStrings, &mimeIndex );
+ rtl::OUString aDescription;
+ if( aMIMETypesStrangeStruct.infoStrings )
+ aDescription = GetNextPluginStringFromHandle( aMIMETypesStrangeStruct.infoStrings, &descriptionIndex );
+
+ // create extension list string
+ sal_Int32 nExtIndex = 0;
+ OUStringBuffer aExtension;
+ while( nExtIndex != -1 )
+ {
+ OUString aExt = aExtLine.getToken( 0, ',', nExtIndex);
+ if( aExt.indexOfAsciiL( "*.", 2 ) != 0 )
+ aExtension.appendAscii( "*." );
+ aExtension.append( aExt );
+ if( nExtIndex != -1 )
+ aExtension.append( sal_Unicode(';') );
+ }
+
+ PluginDescription* pNew = new PluginDescription;
+ // set plugin name (path to library)
+ pNew->PluginName = i_rBundleURL;
+ // set mimetype
+ pNew->Mimetype = aMimetype;
+ // set extension line
+ pNew->Extension = aExtension.makeStringAndClear();
+ // set description
+ pNew->Description= aDescription;
+ io_rDescriptions.push_back( pNew );
+ nAdded++;
+
+ #if OSL_DEBUG_LEVEL > 1
+ fprintf( stderr,
+ "Inserting from resource:\n"
+ " Mimetype: %s\n"
+ " Extension: %s\n"
+ " Description: %s\n",
+ OUStringToOString( pNew->Mimetype, RTL_TEXTENCODING_UTF8 ).getStr(),
+ OUStringToOString( pNew->Extension, RTL_TEXTENCODING_UTF8 ).getStr(),
+ OUStringToOString( pNew->Description, RTL_TEXTENCODING_UTF8 ).getStr()
+ );
+ #endif
+ }
+ }
+
+
+ // clean up
+ if( aMIMETypesStrangeStruct.typeStrings )
+ {
+ HUnlock( aMIMETypesStrangeStruct.typeStrings );
+ DisposeHandle( aMIMETypesStrangeStruct.typeStrings );
+ }
+ if( aMIMETypesStrangeStruct.infoStrings )
+ {
+ HUnlock( aMIMETypesStrangeStruct.infoStrings );
+ DisposeHandle( aMIMETypesStrangeStruct.infoStrings );
+ }
+ if( xRes )
+ CFBundleCloseBundleResourceMap( i_xBundle, xRes );
+
+ return nAdded;
+}
+
+// check some known bad plugins to avoid crashes
+static bool checkBlackList( CFBundleRef i_xBundle )
+{
+ rtl::OUString aBundleName;
+ CFTypeRef bundlename = CFBundleGetValueForInfoDictionaryKey( i_xBundle, CFSTR("CFBundleName"));
+ if( bundlename && CFGetTypeID(bundlename) == CFStringGetTypeID() )
+ aBundleName = getString( static_cast<CFStringRef>(bundlename) );
+
+ rtl::OUString aBundleVersion;
+ CFTypeRef bundleversion = CFBundleGetValueForInfoDictionaryKey( i_xBundle, CFSTR("CFBundleVersion"));
+ if( bundleversion && CFGetTypeID(bundleversion) == CFStringGetTypeID() )
+ aBundleVersion = getString( static_cast<CFStringRef>(bundleversion) );
+
+ bool bReject = false;
+ // #i102735# VLC plugin prior to 1.0 tends to crash
+ if( aBundleName.equalsAscii( "VLC Plug-in" ) )
+ {
+ sal_Int32 nIndex = 0;
+ rtl::OUString aMajor( aBundleVersion.getToken( 0, '.', nIndex ) );
+ if( aMajor.toInt32() < 1 )
+ {
+ bReject = true;
+ }
+ }
+ // #i103674# Garmin Communicator Plugin crashes
+ else if( aBundleName.equalsAscii( "Garmin Communicator Plugin" ) )
+ {
+ bReject = true;
+ }
+
+ #if OSL_DEBUG_LEVEL > 1
+ if( bReject )
+ fprintf( stderr, "rejecting plugin \"%s\" version %s\n",
+ rtl::OUStringToOString( aBundleName, RTL_TEXTENCODING_UTF8 ).getStr(),
+ rtl::OUStringToOString( aBundleVersion, RTL_TEXTENCODING_UTF8 ).getStr()
+ );
+ #endif
+
+ return bReject;
+}
+
+static int getPluginDescriptions( CFBundleRef i_xBundle , list< PluginDescription* >& io_rDescriptions )
+{
+ int nDescriptions = 0;
+ if( ! i_xBundle )
+ return nDescriptions;
+
+ if( checkBlackList( i_xBundle ) )
+ return 0;
+
+ rtl::OUString aPlugURL;
+ CFURLRef xURL = CFBundleCopyBundleURL( i_xBundle );
+ aPlugURL = getString( xURL );
+ CFRelease( xURL );
+
+ #if OSL_DEBUG_LEVEL > 1
+ rtl::OUString aPlugName, aPlugDescription;
+ CFTypeRef name = CFBundleGetValueForInfoDictionaryKey( i_xBundle, CFSTR("WebPluginName"));
+ if( name && CFGetTypeID(name) == CFStringGetTypeID() )
+ aPlugName = getString( static_cast<CFStringRef>(name) );
+
+ CFTypeRef description = CFBundleGetValueForInfoDictionaryKey( i_xBundle, CFSTR("WebPluginDescription"));
+ if( description && CFGetTypeID(description) == CFStringGetTypeID() )
+ aPlugDescription = getString( static_cast<CFStringRef>(description) );
+
+ fprintf( stderr, "URL: %s\nname: %s\ndescription: %s\n",
+ rtl::OUStringToOString( aPlugURL, RTL_TEXTENCODING_UTF8 ).getStr(),
+ rtl::OUStringToOString( aPlugName, RTL_TEXTENCODING_UTF8 ).getStr(),
+ rtl::OUStringToOString( aPlugDescription, RTL_TEXTENCODING_UTF8 ).getStr()
+ );
+ #endif
+
+
+ // get location of plugin library
+ CFURLRef xLibURL = CFBundleCopyExecutableURL( i_xBundle );
+ if( ! xLibURL )
+ return 0;
+ // get the file system path
+ rtl::OUString aModuleURL( CFURLtoOSLURL( xLibURL ) );
+ CFRelease( xLibURL );
+
+ #if OSL_DEBUG_LEVEL > 1
+ fprintf( stderr, "exec URL = %s\n", rtl::OUStringToOString( aModuleURL, RTL_TEXTENCODING_UTF8 ).getStr() );
+ #endif
+
+ /* TODO: originally the C++ wrapper for oslModule was used here, but that led to
+ mysterious crashes in the event loop (pointing to heap corruption). Why using
+ the C style oslModule should fix this is completely unknown. It may be that
+ we have just hidden the heap corruption a little more.
+ */
+ oslModule aMod = osl_loadModule( aModuleURL.pData, SAL_LOADMODULE_DEFAULT );
+ if( ! aMod )
+ return 0;
+
+ // check for at least the init function of a plugin
+ if( ! osl_getAsciiFunctionSymbol( aMod, "NP_Initialize") &&
+ ! osl_getAsciiFunctionSymbol( aMod, "NP_GetEntryPoints" ) )
+ {
+ return 0;
+ }
+
+ // ask the plist of the bundle for mimetypes
+ nDescriptions = parsePlist( i_xBundle, aPlugURL, io_rDescriptions );
+ if( nDescriptions )
+ {
+ osl_unloadModule( aMod );
+ return nDescriptions;
+ }
+
+ // resolve the symbol that might get us the mimetypes
+ const char* (*pGetMimeDescription)() = (const char*(*)())osl_getAsciiFunctionSymbol( aMod, "_NP_GetMIMEDescription" );
+ if( pGetMimeDescription )
+ {
+ const char* pMime = pGetMimeDescription();
+ if( pMime )
+ {
+ nDescriptions = parseMimeString( aPlugURL, io_rDescriptions, pMime );
+ if( nDescriptions )
+ {
+ osl_unloadModule( aMod );
+ return nDescriptions;
+ }
+ }
+ }
+
+ // and as last resort check the resource of the bundle
+ nDescriptions = parseMimeResource( i_xBundle, aMod, aPlugURL, io_rDescriptions );
+ osl_unloadModule( aMod );
+
+ return nDescriptions;
+}
+
+// Unix specific implementation
+static bool CheckPlugin( const rtl::OUString& rPath, list< PluginDescription* >& rDescriptions )
+{
+#if OSL_DEBUG_LEVEL > 1
+ fprintf( stderr, "Trying path %s ... ", rtl::OUStringToOString( rPath, RTL_TEXTENCODING_UTF8 ).getStr() );
+#endif
+ CFURLRef xURL = createURL( rPath );
+
+ CFArrayRef xBundles = CFBundleCreateBundlesFromDirectory( NULL, xURL, CFSTR("plugin") );
+ if( ! xBundles )
+ return false;
+
+ CFIndex nBundles = CFArrayGetCount( xBundles );
+
+#if OSL_DEBUG_LEVEL > 1
+ fprintf( stderr, "got %d bundles\n", (int)nBundles );
+#endif
+
+ int nDescriptions = 0;
+ for( CFIndex i = 0; i < nBundles; i++ )
+ {
+ CFBundleRef xBundle = (CFBundleRef)CFArrayGetValueAtIndex( xBundles, i );
+ nDescriptions += getPluginDescriptions( xBundle, rDescriptions );
+
+ CFRelease( xBundle );
+ }
+ CFRelease( xBundles );
+
+
+ return nDescriptions > 0;
+}
+
+static rtl::OUString FindFolderURL( FSVolumeRefNum vRefNum, OSType folderType )
+{
+ rtl::OUString aRet;
+
+ FSRef aFSRef;
+ OSErr err = FSFindFolder( vRefNum, folderType, kDontCreateFolder, &aFSRef );
+ if( err == noErr )
+ {
+ CFURLRef xURL = CFURLCreateFromFSRef( NULL, &aFSRef );
+ aRet = getString( xURL );
+ CFRelease( xURL );
+ }
+
+ return aRet;
+}
+
+Sequence<PluginDescription> XPluginManager_Impl::impl_getPluginDescriptions() throw()
+{
+ static Sequence<PluginDescription> aDescriptions;
+ static BOOL bHavePlugins = FALSE;
+ if( ! bHavePlugins )
+ {
+ std::list<PluginDescription*> aPlugins;
+
+ static const char* pNPXPluginPath = getenv( "MOZ_PLUGIN_PATH" );
+
+ // get directories
+ std::list< rtl::OUString > aPaths;
+ if( pNPXPluginPath )
+ {
+ CFMutableStringRef xMutableString = CFStringCreateMutable( NULL, 0 );
+ CFStringAppendCString( xMutableString, pNPXPluginPath, kCFStringEncodingUTF8 );
+ CFURLRef xURL = CFURLCreateWithFileSystemPath( NULL, xMutableString, kCFURLPOSIXPathStyle, true );
+ CFRelease( xMutableString );
+ aPaths.push_back( getString( xURL ) );
+ CFRelease( xURL );
+ }
+
+ rtl::OUString aPath = FindFolderURL( kUserDomain, kInternetPlugInFolderType );
+ if( aPath.getLength() )
+ aPaths.push_back( aPath );
+ aPath = FindFolderURL( kLocalDomain, kInternetPlugInFolderType );
+ if( aPath.getLength() )
+ aPaths.push_back( aPath );
+ aPath = FindFolderURL( kOnAppropriateDisk, kInternetPlugInFolderType );
+ if( aPath.getLength() )
+ aPaths.push_back( aPath );
+
+
+ const Sequence< ::rtl::OUString >& rPaths( PluginManager::getAdditionalSearchPaths() );
+ for( sal_Int32 i = 0; i < rPaths.getLength(); i++ )
+ {
+ aPaths.push_back( getURLFromPath( rPaths.getConstArray()[i] ) );
+ }
+
+ for( std::list< rtl::OUString >::const_iterator it = aPaths.begin(); it != aPaths.end(); ++it )
+ {
+ rtl::OUString aPath( *it );
+#if OSL_DEBUG_LEVEL > 1
+ fprintf( stderr, "check path %s\n", rtl::OUStringToOString( *it, RTL_TEXTENCODING_UTF8 ).getStr() );
+#endif
+ CheckPlugin( aPath, aPlugins );
+ }
+
+
+ // create return value
+ aDescriptions = Sequence<PluginDescription>( aPlugins.size() );
+#if OSL_DEBUG_LEVEL > 1
+ fprintf( stderr, "found %d plugins\n", (int)aPlugins.size() );
+#endif
+ list<PluginDescription*>::iterator iter;
+ sal_Int32 nPlug = 0;
+ for( iter = aPlugins.begin(); iter != aPlugins.end(); ++iter )
+ {
+ aDescriptions.getArray()[ nPlug++ ] = **iter;
+ delete *iter;
+ }
+ aPlugins.clear();
+ bHavePlugins = TRUE;
+ }
+ return aDescriptions;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/plugin/aqua/makefile.mk b/extensions/source/plugin/aqua/makefile.mk
new file mode 100644
index 000000000000..c0d3a2eed949
--- /dev/null
+++ b/extensions/source/plugin/aqua/makefile.mk
@@ -0,0 +1,74 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+PRJ=..$/..$/..
+
+PRJNAME=extensions
+TARGET=plaqua
+#ENABLE_EXCEPTIONS=TRUE
+#TARGETTYPE=CUI
+
+.INCLUDE : ..$/util$/makefile.pmk
+
+.IF "$(GUIBASE)"!="aqua" || "$(WITH_MOZILLA)"=="NO"
+
+dummy:
+ @echo "Nothing to build for GUIBASE $(GUIBASE)."
+
+.ELSE
+
+# --- Files --------------------------------------------------------
+
+INCPRE+=-I$(SOLARINCDIR)$/mozilla$/plugin
+.IF "$(SOLAR_JAVA)" != ""
+INCPRE+=-I$(SOLARINCDIR)$/mozilla$/java
+INCPRE+=-I$(SOLARINCDIR)$/mozilla$/nspr
+INCPRE+=-I$(SOLARINCDIR)$/npsdk
+CDEFS+=-DOJI
+.ENDIF
+
+.IF "$(GUIBASE)"=="aqua"
+CFLAGSCXX+=$(OBJCXXFLAGS)
+.ENDIF # "$(GUIBASE)"=="aqua"
+
+SLOFILES=\
+ $(SLO)$/macmgr.obj \
+ $(SLO)$/sysplug.obj
+
+#APP1TARGET=pluginapp.bin
+#APP1OBJS=$(OBJFILES)
+#APP1STDLIBS=\
+# $(TOOLSLIB) \
+# $(SALLIB)
+
+#APP1DEF= $(MISC)$/$(TARGET).def
+
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : target.mk
+
+.ENDIF # $(GUIBASE)==aqua
diff --git a/extensions/source/plugin/aqua/sysplug.cxx b/extensions/source/plugin/aqua/sysplug.cxx
new file mode 100644
index 000000000000..3139b5cdfe45
--- /dev/null
+++ b/extensions/source/plugin/aqua/sysplug.cxx
@@ -0,0 +1,810 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#include <cstdarg>
+
+#include <sys/types.h>
+#include <signal.h>
+#include <sys/wait.h>
+#include <osl/thread.h>
+
+#include <plugin/impl.hxx>
+
+extern NPNetscapeFuncs aNPNFuncs;
+
+#include <tools/debug.hxx>
+
+using namespace rtl;
+using namespace plugstringhelper;
+
+#if OSL_DEBUG_LEVEL > 1
+void TRACE( char const * s );
+void TRACEN( char const * s, long n );
+#else
+#define TRACE(x)
+#define TRACEN(x,n)
+#endif
+
+struct FakeEventRecord : public EventRecord
+{
+ FakeEventRecord()
+ {
+ memset( this, 0, sizeof(EventRecord) );
+ ::GetGlobalMouse( &where );
+ when = ::TickCount();
+ modifiers = ::GetCurrentEventKeyModifiers();
+ }
+};
+
+
+@interface OOoPluginView : NSView
+{
+ XPlugin_Impl* m_pImpl;
+ MacPluginComm* m_pCom;
+}
+-(id)initWithInstance: (XPlugin_Impl*)i_pImpl pluginComm: (MacPluginComm*)i_pCom frame: (NSRect)i_aRect;
+-(void)drawRect: (NSRect)i_aRect;
+-(MacOSBOOL)isOpaque;
+-(MacOSBOOL)isFlipped;
+
+// NSResponder
+-(void)mouseMoved: (NSEvent*)i_pEvent;
+-(void)mouseDown: (NSEvent*)i_pEvent;
+-(void)mouseDragged: (NSEvent*)i_pEvent;
+-(void)mouseUp: (NSEvent*)i_pEvent;
+-(void)rightMouseDown: (NSEvent*)i_pEvent;
+-(void)rightMouseDragged: (NSEvent*)i_pEvent;
+-(void)rightMouseUp: (NSEvent*)i_pEvent;
+-(void)otherMouseDown: (NSEvent*)i_pEvent;
+-(void)otherMouseDragged: (NSEvent*)i_pEvent;
+-(void)otherMouseUp: (NSEvent*)i_pEvent;
+-(void)mouseEntered: (NSEvent*)i_pEvent;
+-(void)mouseExited: (NSEvent*)i_pEvent;
+@end
+
+@implementation OOoPluginView
+-(id)initWithInstance: (XPlugin_Impl*)i_pImpl pluginComm: (MacPluginComm*)i_pCom frame: (NSRect) i_aRect
+{
+ if( (self = [super initWithFrame: i_aRect]) )
+ {
+ m_pImpl = i_pImpl;
+ m_pCom = i_pCom;
+ }
+ return self;
+}
+
+-(void)drawRect: (NSRect) i_aRect
+{
+ m_pCom->drawView( m_pImpl );
+}
+
+-(MacOSBOOL)isOpaque
+{
+ return NO;
+}
+
+-(MacOSBOOL)isFlipped
+{
+ return YES;
+}
+
+// NSResponder
+-(void)mouseMoved: (NSEvent*)i_pEvent
+{
+ FakeEventRecord aRec;
+ aRec.what = osEvt + 18; // NPEventType_AdjustCursorEvent
+ m_pCom->NPP_HandleEvent( m_pImpl->getNPPInstance(), &aRec );
+}
+
+-(void)mouseDown: (NSEvent*)i_pEvent;
+{
+ FakeEventRecord aRec;
+ aRec.what = mouseDown;
+ m_pCom->NPP_HandleEvent( m_pImpl->getNPPInstance(), &aRec );
+}
+
+-(void)mouseDragged: (NSEvent*)i_pEvent;
+{
+ FakeEventRecord aRec;
+ aRec.what = aRec.what = osEvt + 18; // NPEventType_AdjustCursorEvent
+ m_pCom->NPP_HandleEvent( m_pImpl->getNPPInstance(), &aRec );
+}
+
+-(void)mouseUp: (NSEvent*)i_pEvent;
+{
+ FakeEventRecord aRec;
+ aRec.what = mouseUp;
+ m_pCom->NPP_HandleEvent( m_pImpl->getNPPInstance(), &aRec );
+}
+
+-(void)rightMouseDown: (NSEvent*)i_pEvent;
+{
+ FakeEventRecord aRec;
+ aRec.what = mouseDown;
+ m_pCom->NPP_HandleEvent( m_pImpl->getNPPInstance(), &aRec );
+}
+
+-(void)rightMouseDragged: (NSEvent*)i_pEvent;
+{
+ FakeEventRecord aRec;
+ aRec.what = aRec.what = osEvt + 18; // NPEventType_AdjustCursorEvent
+ m_pCom->NPP_HandleEvent( m_pImpl->getNPPInstance(), &aRec );
+}
+
+-(void)rightMouseUp: (NSEvent*)i_pEvent;
+{
+ FakeEventRecord aRec;
+ aRec.what = mouseUp;
+ m_pCom->NPP_HandleEvent( m_pImpl->getNPPInstance(), &aRec );
+}
+
+-(void)otherMouseDown: (NSEvent*)i_pEvent;
+{
+ FakeEventRecord aRec;
+ aRec.what = mouseDown;
+ m_pCom->NPP_HandleEvent( m_pImpl->getNPPInstance(), &aRec );
+}
+
+-(void)otherMouseDragged: (NSEvent*)i_pEvent;
+{
+ FakeEventRecord aRec;
+ aRec.what = aRec.what = osEvt + 18; // NPEventType_AdjustCursorEvent
+ m_pCom->NPP_HandleEvent( m_pImpl->getNPPInstance(), &aRec );
+}
+
+-(void)otherMouseUp: (NSEvent*)i_pEvent;
+{
+ FakeEventRecord aRec;
+ aRec.what = mouseUp;
+ m_pCom->NPP_HandleEvent( m_pImpl->getNPPInstance(), &aRec );
+}
+
+-(void)mouseEntered: (NSEvent*)i_pEvent;
+{
+ FakeEventRecord aRec;
+ aRec.what = aRec.what = osEvt + 18; // NPEventType_AdjustCursorEvent
+ m_pCom->NPP_HandleEvent( m_pImpl->getNPPInstance(), &aRec );
+}
+
+-(void)mouseExited: (NSEvent*)i_pEvent;
+{
+ FakeEventRecord aRec;
+ aRec.what = aRec.what = osEvt + 18; // NPEventType_AdjustCursorEvent
+ m_pCom->NPP_HandleEvent( m_pImpl->getNPPInstance(), &aRec );
+}
+
+@end
+
+//--------------------------------------------------------------------------------------------------
+MacPluginComm::MacPluginComm( const rtl::OUString& i_rMimetype, const rtl::OUString& i_rBundle, NSView* i_pParent )
+ : PluginComm( OUStringToOString( i_rBundle, RTL_TEXTENCODING_UTF8 ) ),
+ m_xBundle( NULL ),
+ m_hPlugLib( NULL ),
+ m_pNullTimer( NULL )
+{
+ // initialize plugin function table
+ memset( &m_aNPPfuncs, 0, sizeof( m_aNPPfuncs ) );
+
+ // load the bundle
+ CFURLRef xURL = createURL( i_rBundle );
+ m_xBundle = CFBundleCreate( NULL, xURL );
+ CFRelease( xURL );
+ if( m_xBundle )
+ {
+ // ask the plugin library
+ // first get its location
+ CFURLRef xLibURL = CFBundleCopyExecutableURL( m_xBundle );
+ if( xLibURL )
+ {
+ // get the file system path
+ rtl::OUString aModuleURL( CFURLtoOSLURL( xLibURL ) );
+ CFRelease( xLibURL );
+ m_hPlugLib = osl_loadModule( aModuleURL.pData, SAL_LOADMODULE_DEFAULT );
+ #if OSL_DEBUG_LEVEL > 1
+ if( ! m_hPlugLib )
+ fprintf( stderr, "module %s could not be loaded\n", OUStringToOString( aModuleURL, RTL_TEXTENCODING_UTF8 ).getStr() );
+ #endif
+ }
+ #if OSL_DEBUG_LEVEL > 1
+ else
+ fprintf( stderr, "bundle %s has no exectutable URL\n", OUStringToOString( i_rBundle, RTL_TEXTENCODING_UTF8 ).getStr() );
+ #endif
+ }
+ else
+ {
+ #if OSL_DEBUG_LEVEL > 1
+ fprintf( stderr, "bundle %s could not be loaded\n", OUStringToOString( i_rBundle, RTL_TEXTENCODING_UTF8 ).getStr() );
+ #endif
+ }
+
+ DBG_ASSERT( m_xBundle && m_hPlugLib, "loading plugin bundle failed!" );
+
+
+ m_aNPPfuncs.size = sizeof( m_aNPPfuncs );
+ m_aNPPfuncs.version = 0;
+
+
+ m_eCall = eNP_Initialize;
+ execute();
+}
+
+//--------------------------------------------------------------------------------------------------
+MacPluginComm::~MacPluginComm()
+{
+ if( m_hPlugLib )
+ {
+ // NPP_Shutdown();
+ NPError (*pShutdown)();
+ if( retrieveFunction( "NP_Shutdown", (void**)&pShutdown ) )
+ {
+ NPError nErr = (*pShutdown)(); (void)nErr;
+ DBG_ASSERT( nErr == NPERR_NO_ERROR, "NP_Shutdown() failed!" );
+ }
+ osl_unloadModule( m_hPlugLib );
+ }
+ if( m_xBundle )
+ CFRelease( m_xBundle );
+}
+
+//--------------------------------------------------------------------------------------------------
+BOOL MacPluginComm::retrieveFunction( const char* i_pName, void** o_ppFunc ) const
+{
+ if( ! m_hPlugLib || ! o_ppFunc )
+ return FALSE;
+
+ *o_ppFunc = (void*)osl_getAsciiFunctionSymbol( m_hPlugLib, i_pName );
+
+ if( ! *o_ppFunc && m_xBundle )
+ {
+ rtl::OUString aName( OUString::createFromAscii( *i_pName == '_' ? i_pName+1 : i_pName ) );
+ CFStringRef xName = createString( aName );
+ if( xName )
+ {
+ *o_ppFunc = CFBundleGetFunctionPointerForName( m_xBundle, xName );
+ CFRelease( xName );
+ }
+ }
+
+ return (*o_ppFunc != NULL);
+}
+
+IMPL_LINK( MacPluginComm, NullTimerHdl, void*, EMPTYARG )
+{
+ // note: this is a Timer handler, we are already protected by the SolarMutex
+
+ FakeEventRecord aRec;
+ aRec.what = nullEvent;
+ aRec.where.h = aRec.where.v = 20000;
+
+ for( std::list< XPlugin_Impl* >::iterator it = m_aNullEventClients.begin();
+ it != m_aNullEventClients.end(); ++it )
+ {
+ SysPlugData& rPlugData( (*it)->getSysPlugData() );
+ if( rPlugData.m_pPlugView ) // for safety do not dispatch null events before first NPP_SetWindow
+ (*m_aNPPfuncs.event)( (*it)->getNPPInstance(), &aRec );
+ }
+
+ return 0;
+}
+
+//--------------------------------------------------------------------------------------------------
+
+long MacPluginComm::doIt()
+{
+ long nRet = 0;
+ switch( m_eCall )
+ {
+ case eNP_Initialize:
+ {
+ TRACE( "eNP_Initialize" );
+ NPError (*pInit)( NPNetscapeFuncs* );
+ if( retrieveFunction( "NP_Initialize", (void**)&pInit ) )
+ {
+ nRet = (*pInit)( &aNPNFuncs );
+
+ NPError nErr = NPERR_NO_ERROR;
+ NPError (*pEntry)( NPPluginFuncs* );
+ retrieveFunction( "NP_GetEntryPoints", (void**)&pEntry );
+ nErr = (*pEntry)( &m_aNPPfuncs );
+
+ DBG_ASSERT( nErr == NPERR_NO_ERROR, "NP_GetEntryPoints() failed!" );
+ }
+ else
+ {
+ nRet = NPERR_GENERIC_ERROR;
+ }
+ DBG_ASSERT( nRet == NPERR_NO_ERROR, "### NP_Initialize() failed!" );
+ }
+ break;
+ case eNPP_Destroy:
+ if( m_aNullEventClients.empty() )
+ delete m_pNullTimer, m_pNullTimer = NULL;
+
+ TRACE( "eNPP_Destroy" );
+ nRet = (m_aNPPfuncs.destroy
+ ? (*m_aNPPfuncs.destroy)(
+ (NPP)m_aArgs[0],
+ (NPSavedData**)m_aArgs[1] )
+ : NPERR_GENERIC_ERROR);
+ break;
+ case eNPP_DestroyStream:
+ TRACE( "eNPP_DestroyStream" );
+ nRet = (m_aNPPfuncs.destroystream
+ ? (*m_aNPPfuncs.destroystream)(
+ (NPP)m_aArgs[0],
+ (NPStream*)m_aArgs[1],
+ (NPError)(sal_IntPtr)m_aArgs[2] )
+ : NPERR_GENERIC_ERROR);
+ break;
+ case eNPP_New:
+ TRACE( "eNPP_New" );
+ nRet = (m_aNPPfuncs.newp
+ ? (*m_aNPPfuncs.newp)(
+ (NPMIMEType)m_aArgs[0],
+ (NPP)m_aArgs[1],
+ (uint16)(sal_IntPtr)m_aArgs[2],
+ (int16)(sal_IntPtr)m_aArgs[3],
+ (char**)m_aArgs[4],
+ (char**)m_aArgs[5],
+ (NPSavedData*)m_aArgs[6] )
+ : NPERR_GENERIC_ERROR);
+
+ if( ! m_pNullTimer && m_aNPPfuncs.event )
+ {
+ m_pNullTimer = new AutoTimer();
+ m_pNullTimer->SetTimeout( 50 );
+ m_pNullTimer->SetTimeoutHdl( LINK( this, MacPluginComm, NullTimerHdl ) );
+ m_pNullTimer->Start();
+ }
+
+ break;
+ case eNPP_NewStream:
+ TRACE( "eNPP_NewStream" );
+ nRet = (m_aNPPfuncs.newstream
+ ? (*m_aNPPfuncs.newstream)(
+ (NPP)m_aArgs[0],
+ (NPMIMEType)m_aArgs[1],
+ (NPStream*)m_aArgs[2],
+ (NPBool)(sal_IntPtr)m_aArgs[3],
+ (uint16*)m_aArgs[4] )
+ : NPERR_GENERIC_ERROR);
+ break;
+ case eNPP_Print:
+ TRACE( "eNPP_Print" );
+ if (m_aNPPfuncs.print)
+ (*m_aNPPfuncs.print)(
+ (NPP)m_aArgs[0],
+ (NPPrint*)m_aArgs[1] );
+ break;
+ case eNPP_SetWindow:
+ {
+ TRACE( "eNPP_SetWindow" );
+ nRet = (m_aNPPfuncs.setwindow
+ ? (*m_aNPPfuncs.setwindow)(
+ (NPP)m_aArgs[0],
+ (NPWindow*)m_aArgs[1] )
+ : NPERR_GENERIC_ERROR);
+
+ break;
+ }
+ case eNPP_HandleEvent:
+ {
+ TRACE( "eNPP_HandleEvent" );
+ nRet = (m_aNPPfuncs.event
+ ? (*m_aNPPfuncs.event)(
+ (NPP)m_aArgs[0],
+ m_aArgs[1] )
+ : NPERR_GENERIC_ERROR);
+
+ break;
+ }
+ case eNPP_StreamAsFile:
+ TRACE( "eNPP_StreamAsFile" );
+ if (m_aNPPfuncs.asfile)
+ (*m_aNPPfuncs.asfile)(
+ (NPP)m_aArgs[0],
+ (NPStream*)m_aArgs[1],
+ (char*)m_aArgs[2] );
+ break;
+ case eNPP_URLNotify:
+ TRACE( "eNPP_URLNotify" );
+ if (m_aNPPfuncs.urlnotify)
+ (*m_aNPPfuncs.urlnotify)(
+ (NPP)m_aArgs[0],
+ (char*)m_aArgs[1],
+ (NPReason)(sal_IntPtr)m_aArgs[2],
+ m_aArgs[3] );
+ break;
+ case eNPP_Write:
+ TRACEN( "eNPP_Write n=", (int32)m_aArgs[3] );
+ nRet = (m_aNPPfuncs.write
+ ? (*m_aNPPfuncs.write)(
+ (NPP)m_aArgs[0],
+ (NPStream*)m_aArgs[1],
+ (int32)m_aArgs[2],
+ (int32)m_aArgs[3],
+ m_aArgs[4] )
+ : 0);
+ break;
+ case eNPP_WriteReady:
+ TRACE( "eNPP_WriteReady" );
+ nRet = (m_aNPPfuncs.writeready
+ ? (*m_aNPPfuncs.writeready)(
+ (NPP)m_aArgs[0],
+ (NPStream*)m_aArgs[1] )
+ : 0);
+ break;
+ case eNPP_GetValue:
+ TRACE( "eNPP_GetValue" );
+ nRet = (m_aNPPfuncs.getvalue
+ ? (*m_aNPPfuncs.getvalue)(
+ (NPP)m_aArgs[0],
+ (NPPVariable)(int)m_aArgs[1],
+ m_aArgs[2] )
+ : NPERR_GENERIC_ERROR);
+ break;
+ case eNPP_SetValue:
+ TRACE( "eNPP_SetValue" );
+ nRet = (m_aNPPfuncs.setvalue
+ ? (*m_aNPPfuncs.setvalue)(
+ (NPP)m_aArgs[0],
+ (NPNVariable)(int)m_aArgs[1],
+ m_aArgs[2] )
+ : NPERR_GENERIC_ERROR);
+ break;
+ case eNPP_Shutdown:
+ {
+ TRACE( "eNPP_Shutdown" );
+ NPP_ShutdownUPP pFunc;
+ if (retrieveFunction( "NPP_Shutdown", (void**)&pFunc ))
+ (*pFunc)();
+ }
+ break;
+ case eNPP_Initialize:
+ TRACE( "eNPP_Initialize" );
+ OSL_ENSURE( false, "NPP_Initialize: not implemented!" );
+ break;
+ case eNPP_GetJavaClass:
+ TRACE( "eNPP_GetJavaClass" );
+ OSL_ENSURE( false, "NPP_GetJavaClass: not implemented!" );
+ break;
+ }
+ return nRet;
+}
+
+//--------------------------------------------------------------------------------------------------
+NPError MacPluginComm::NPP_Destroy( XPlugin_Impl* i_pImpl, NPSavedData** save )
+{
+ // remove from NullEvent timer
+ m_aNullEventClients.remove( i_pImpl );
+
+ NPError nErr = NPP_Destroy( i_pImpl->getNPPInstance(), save );
+
+ // release plugin view
+ SysPlugData& rPlugData( i_pImpl->getSysPlugData() );
+ if( rPlugData.m_pPlugView )
+ {
+ [rPlugData.m_pPlugView removeFromSuperview];
+ [rPlugData.m_pPlugView release];
+ rPlugData.m_pPlugView = nil;
+ }
+
+ return nErr;
+}
+
+
+NPError MacPluginComm::NPP_Destroy( NPP instance, NPSavedData** save )
+{
+ DBG_ASSERT( m_aNPPfuncs.destroy, "### NPP_Destroy(): null pointer in NPP functions table!" );
+ m_eCall = eNPP_Destroy;
+ m_aArgs[0] = (void*)instance;
+ m_aArgs[1] = (void*)save;
+ return (NPError)execute();
+}
+
+//--------------------------------------------------------------------------------------------------
+NPError MacPluginComm::NPP_DestroyStream( NPP instance, NPStream* stream, NPError reason )
+{
+ DBG_ASSERT( m_aNPPfuncs.destroystream, "### NPP_DestroyStream(): null pointer in NPP functions table!" );
+ m_eCall = eNPP_DestroyStream;
+ m_aArgs[0] = (void*)instance;
+ m_aArgs[1] = (void*)stream;
+ m_aArgs[2] = (void*)reason;
+ return (NPError)execute();
+}
+
+//--------------------------------------------------------------------------------------------------
+NPError MacPluginComm::NPP_New( NPMIMEType pluginType, NPP instance, uint16 mode, int16 argc,
+ char* argn[], char* argv[], NPSavedData *saved )
+{
+ XPlugin_Impl* pImpl = XPluginManager_Impl::getXPluginFromNPP( instance );
+ DBG_ASSERT( pImpl, "no instance found" );
+
+ if( pImpl ) // sanity check
+ m_aNullEventClients.push_back( pImpl );
+
+ DBG_ASSERT( m_aNPPfuncs.newp, "### NPP_New(): null pointer in NPP functions table!" );
+ #if OSL_DEBUG_LEVEL > 1
+ fprintf( stderr, "NPP_New( %s. %p, %d, %d",
+ pluginType, instance, (int)mode, (int)argc );
+ for( int16 i = 0; i < argc; i++ )
+ fprintf( stderr, "\n%s = %s", argn[i], argv[i] );
+ fprintf( stderr, ", %p )\n", saved );
+ #endif
+ m_eCall = eNPP_New;
+ m_aArgs[0] = (void*)pluginType;
+ m_aArgs[1] = (void*)instance;
+ m_aArgs[2] = (void*)mode;
+ m_aArgs[3] = (void*)argc;
+ m_aArgs[4] = (void*)argn;
+ m_aArgs[5] = (void*)argv;
+ m_aArgs[6] = (void*)saved;
+
+ return (NPError)execute();
+}
+
+//--------------------------------------------------------------------------------------------------
+NPError MacPluginComm::NPP_NewStream( NPP instance, NPMIMEType type, NPStream* stream,
+ NPBool seekable, uint16* stype )
+{
+ DBG_ASSERT( m_aNPPfuncs.newstream, "### NPP_NewStream(): null pointer in NPP functions table!" );
+ m_eCall = eNPP_NewStream;
+ m_aArgs[0] = (void*)instance;
+ m_aArgs[1] = (void*)type;
+ m_aArgs[2] = (void*)stream;
+ m_aArgs[3] = (void*)seekable;
+ m_aArgs[4] = (void*)stype;
+ return (NPError)execute();
+}
+
+//--------------------------------------------------------------------------------------------------
+void MacPluginComm::NPP_Print( NPP instance, NPPrint* platformPrint )
+{
+ DBG_ASSERT( m_aNPPfuncs.print, "### NPP_Print(): null pointer in NPP functions table!" );
+ m_eCall = eNPP_Print;
+ m_aArgs[0] = (void*)instance;
+ m_aArgs[1] = (void*)platformPrint;
+ execute();
+}
+
+//--------------------------------------------------------------------------------------------------
+NPError MacPluginComm::NPP_SetWindow( NPP instance, NPWindow* window )
+{
+ DBG_ASSERT( m_aNPPfuncs.setwindow, "### NPP_SetWindow(): null pointer in NPP functions table!" );
+ m_eCall = eNPP_SetWindow;
+ m_aArgs[0] = (void*)instance;
+ m_aArgs[1] = (void*)window;
+ return (NPError)execute();
+}
+
+//--------------------------------------------------------------------------------------------------
+NPError MacPluginComm::NPP_HandleEvent( NPP instance, void* event )
+{
+ DBG_ASSERT( m_aNPPfuncs.event, "### NPP_HandleEvent(): null pointer in NPP functions table!" );
+ m_eCall = eNPP_HandleEvent;
+ m_aArgs[0] = (void*)instance;
+ m_aArgs[1] = event;
+ return (NPError)execute();
+}
+
+//--------------------------------------------------------------------------------------------------
+void MacPluginComm::NPP_StreamAsFile( NPP instance, NPStream* stream, const char* fname )
+{
+ DBG_ASSERT( m_aNPPfuncs.asfile, "### NPP_StreamAsFile(): null pointer in NPP functions table!" );
+ m_eCall = eNPP_StreamAsFile;
+ m_aArgs[0] = (void*)instance;
+ m_aArgs[1] = (void*)stream;
+ m_aArgs[2] = (void*)fname;
+ execute();
+}
+
+//--------------------------------------------------------------------------------------------------
+void MacPluginComm::NPP_URLNotify( NPP instance, const char* url, NPReason reason, void* notifyData )
+{
+ DBG_ASSERT( m_aNPPfuncs.urlnotify, "### NPP_URLNotify(): null pointer in NPP functions table!" );
+ m_eCall = eNPP_URLNotify;
+ m_aArgs[0] = (void*)instance;
+ m_aArgs[1] = (void*)url;
+ m_aArgs[2] = (void*)reason;
+ m_aArgs[3] = notifyData;
+ execute();
+}
+
+//--------------------------------------------------------------------------------------------------
+int32 MacPluginComm::NPP_Write( NPP instance, NPStream* stream, int32 offset, int32 len, void* buffer )
+{
+ DBG_ASSERT( m_aNPPfuncs.write, "### NPP_Write(): null pointer in NPP functions table!" );
+ m_eCall = eNPP_Write;
+ m_aArgs[0] = (void*)instance;
+ m_aArgs[1] = (void*)stream;
+ m_aArgs[2] = (void*)offset;
+ m_aArgs[3] = (void*)len;
+ m_aArgs[4] = buffer;
+ return (NPError)execute();
+}
+
+//--------------------------------------------------------------------------------------------------
+int32 MacPluginComm::NPP_WriteReady( NPP instance, NPStream* stream )
+{
+ DBG_ASSERT( m_aNPPfuncs.writeready, "### NPP_WriteReady(): null pointer in NPP functions table!" );
+ m_eCall = eNPP_WriteReady;
+ m_aArgs[0] = (void*)instance;
+ m_aArgs[1] = (void*)stream;
+ return execute();
+}
+
+//--------------------------------------------------------------------------------------------------
+NPError MacPluginComm::NPP_GetValue( NPP instance, NPPVariable variable, void *ret_value )
+{
+ DBG_ASSERT( m_aNPPfuncs.getvalue, "### NPP_GetValue(): null pointer in NPP functions table!" );
+ m_eCall = eNPP_GetValue;
+ m_aArgs[0] = (void*)instance;
+ m_aArgs[1] = (void*)variable;
+ m_aArgs[2] = ret_value;
+ return (NPError)execute();
+}
+
+//--------------------------------------------------------------------------------------------------
+NPError MacPluginComm::NPP_SetValue( NPP instance, NPNVariable variable, void *set_value )
+{
+ DBG_ASSERT( m_aNPPfuncs.setvalue, "### NPP_SetValue(): null pointer in NPP functions table!" );
+ m_eCall = eNPP_SetValue;
+ m_aArgs[0] = (void*)instance;
+ m_aArgs[1] = (void*)variable;
+ m_aArgs[2] = set_value;
+ return (NPError)execute();
+}
+
+//--------------------------------------------------------------------------------------------------
+void * MacPluginComm::NPP_GetJavaClass()
+{
+ DBG_ERROR( "no java class available!" );
+ return 0;
+}
+
+//--------------------------------------------------------------------------------------------------
+NPError MacPluginComm::NPP_Initialize()
+{
+ return NPERR_NO_ERROR;
+}
+
+//--------------------------------------------------------------------------------------------------
+void MacPluginComm::NPP_Shutdown()
+{
+ m_eCall = eNPP_Shutdown;
+ execute();
+}
+
+//--------------------------------------------------------------------------------------------------
+NPError MacPluginComm::NPP_SetWindow( XPlugin_Impl* i_pImpl )
+{
+ // update window NPWindow from view
+ SysPlugData& rPlugData( i_pImpl->getSysPlugData() );
+
+ // update plug view
+ NSRect aPlugRect = [rPlugData.m_pParentView frame];
+ aPlugRect.origin.x = aPlugRect.origin.y = 0;
+ if( ! rPlugData.m_pPlugView )
+ {
+ rPlugData.m_pPlugView = [[OOoPluginView alloc] initWithInstance: i_pImpl pluginComm: this frame: aPlugRect];
+ [rPlugData.m_pParentView addSubview: rPlugData.m_pPlugView];
+ }
+ else
+ [rPlugData.m_pPlugView setFrame: aPlugRect];
+
+ NPWindow* pNPWin = i_pImpl->getNPWindow();
+ NSWindow* pWin = [rPlugData.m_pPlugView window];
+ NSRect aWinRect = [pWin frame];
+ NSRect aBounds = [rPlugData.m_pPlugView frame];
+ NSRect aVisibleBounds = [rPlugData.m_pPlugView visibleRect];
+
+ #if OSL_DEBUG_LEVEL > 1
+ fprintf( stderr, "visible bounds = %d+%d+%dx%d\n",
+ (int)aVisibleBounds.origin.x, (int)aVisibleBounds.origin.y,
+ (int)aVisibleBounds.size.width, (int)aVisibleBounds.size.height );
+ #endif
+
+ NSPoint aViewOrigin = [rPlugData.m_pPlugView convertPoint: NSZeroPoint toView: nil];
+ // save view origin so we can notice movement of the view in drawView
+ // in case of a moved view we need to reset the port/context
+ rPlugData.m_aLastPlugViewOrigin = aViewOrigin;
+
+ // convert view origin to topdown coordinates
+ aViewOrigin.y = aWinRect.size.height - aViewOrigin.y;
+
+ // same for clipping
+ NSPoint aClipOrigin = [rPlugData.m_pPlugView convertPoint: aVisibleBounds.origin toView: nil];
+ aClipOrigin.y = aWinRect.size.height - aClipOrigin.y;
+
+ #if OSL_DEBUG_LEVEL > 1
+ fprintf( stderr, "view origin: %d+%d, clip origin = %d+%d\n",
+ (int)aViewOrigin.x, (int)aViewOrigin.y,
+ (int)aClipOrigin.x, (int)aClipOrigin.y );
+ #endif
+
+ pNPWin->x = aViewOrigin.x;
+ pNPWin->y = aViewOrigin.y;
+ pNPWin->width = aBounds.size.width;
+ pNPWin->height = aBounds.size.height;
+ pNPWin->clipRect.left = aClipOrigin.x;
+ pNPWin->clipRect.top = aClipOrigin.y;
+ pNPWin->clipRect.right = aClipOrigin.x + aVisibleBounds.size.width;
+ pNPWin->clipRect.bottom = aClipOrigin.y + aVisibleBounds.size.height;
+
+ if( rPlugData.m_nDrawingModel == 1 )
+ {
+ rPlugData.m_aCGContext.window = reinterpret_cast<WindowRef>([pWin windowRef]);
+ pNPWin->window = &rPlugData.m_aCGContext;
+ rPlugData.m_aCGContext.context = reinterpret_cast<CGContextRef>([[pWin graphicsContext] graphicsPort]);
+ #if OSL_DEBUG_LEVEL > 1
+ fprintf( stderr, "window is %p, context is %p\n",
+ rPlugData.m_aCGContext.window, rPlugData.m_aCGContext.context );
+ #endif
+ }
+ else
+ {
+ rPlugData.m_aNPPort.port = GetWindowPort( reinterpret_cast<WindowRef>([pWin windowRef]) );
+ rPlugData.m_aNPPort.portx = aClipOrigin.x;
+ rPlugData.m_aNPPort.porty = aClipOrigin.y;
+ pNPWin->window = &rPlugData.m_aNPPort;
+ #if OSL_DEBUG_LEVEL > 1
+ fprintf( stderr, "port is %p at (%d,%d)\n",
+ rPlugData.m_aNPPort.port, (int)rPlugData.m_aNPPort.portx, (int)rPlugData.m_aNPPort.porty );
+ #endif
+ }
+
+ if( pNPWin->width == 0 || pNPWin->height == 0 || [rPlugData.m_pPlugView isHiddenOrHasHiddenAncestor] )
+ rPlugData.m_bSetWindowOnDraw = true;
+
+ NPError nErr = NPP_SetWindow( i_pImpl->getNPPInstance(), i_pImpl->getNPWindow() );
+
+ return nErr;
+}
+
+void MacPluginComm::drawView( XPlugin_Impl* i_pImpl )
+{
+ SysPlugData& rPlugData( i_pImpl->getSysPlugData() );
+
+ // check if the view was moved since the last SetWindow
+ NSPoint aViewOrigin = [rPlugData.m_pPlugView convertPoint: NSZeroPoint toView: nil];
+ if( rPlugData.m_bSetWindowOnDraw ||
+ aViewOrigin.x != rPlugData.m_aLastPlugViewOrigin.x ||
+ aViewOrigin.y != rPlugData.m_aLastPlugViewOrigin.y )
+ {
+ NPP_SetWindow( i_pImpl );
+ rPlugData.m_bSetWindowOnDraw = false;
+ }
+
+ // send a paint event
+ NSWindow* pWin = [rPlugData.m_pPlugView window];
+ FakeEventRecord aRec;
+ aRec.what = updateEvt;
+ aRec.message = (UInt32)[pWin windowRef];
+ this->NPP_HandleEvent( i_pImpl->getNPPInstance(), &aRec );
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/plugin/base/context.cxx b/extensions/source/plugin/base/context.cxx
new file mode 100644
index 000000000000..bf23f9c19113
--- /dev/null
+++ b/extensions/source/plugin/base/context.cxx
@@ -0,0 +1,350 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+
+#ifdef AIX
+#define _LINUX_SOURCE_COMPAT
+#include <sys/timer.h>
+#undef _LINUX_SOURCE_COMPAT
+#endif
+
+#if STLPORT_VERSION>=321
+#include <cstdarg>
+#include <cstdio>
+#endif
+
+#include <plugin/impl.hxx>
+
+#include <com/sun/star/frame/FrameSearchFlag.hpp>
+#include <com/sun/star/frame/XComponentLoader.hpp>
+#include <tools/fsys.hxx>
+#include <tools/urlobj.hxx>
+
+#include <cppuhelper/implbase1.hxx>
+
+using namespace com::sun::star::io;
+
+namespace ext_plug {
+
+class FileSink : public ::cppu::WeakAggImplHelper1< ::com::sun::star::io::XOutputStream >
+{
+private:
+ Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xSMgr;
+ FILE* fp;
+ Reference< ::com::sun::star::plugin::XPlugin > m_xPlugin;
+ ::rtl::OUString m_aMIMEType;
+ ::rtl::OUString m_aTarget;
+ ::rtl::OUString m_aFileName;
+
+public:
+ FileSink( const Reference< ::com::sun::star::lang::XMultiServiceFactory > &,
+ const Reference< ::com::sun::star::plugin::XPlugin > & plugin,
+ const ::rtl::OUString& mimetype,
+ const ::rtl::OUString& target,
+ const Reference< ::com::sun::star::io::XActiveDataSource > & source );
+ virtual ~FileSink();
+
+ // ::com::sun::star::io::XOutputStream
+ virtual void SAL_CALL writeBytes( const Sequence<sal_Int8>& ) throw();
+ virtual void SAL_CALL flush() throw();
+ virtual void SAL_CALL closeOutput() throw();
+};
+
+}
+using namespace ext_plug;
+
+class XPluginContext_Impl : public ::cppu::WeakAggImplHelper1< ::com::sun::star::plugin::XPluginContext >
+{
+ Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xSMgr;
+ rtl_TextEncoding m_aEncoding;
+public:
+
+ XPluginContext_Impl( const Reference< ::com::sun::star::lang::XMultiServiceFactory > & );
+ virtual ~XPluginContext_Impl();
+
+
+ virtual ::rtl::OUString SAL_CALL getValue(const Reference< ::com::sun::star::plugin::XPlugin > & plugin, ::com::sun::star::plugin::PluginVariable variable) throw( ::com::sun::star::plugin::PluginException, RuntimeException );
+ virtual void SAL_CALL getURLNotify(const Reference< ::com::sun::star::plugin::XPlugin > & plugin, const ::rtl::OUString& url, const ::rtl::OUString& target, const Reference< ::com::sun::star::lang::XEventListener > & listener) throw( ::com::sun::star::plugin::PluginException, RuntimeException );
+ virtual void SAL_CALL getURL(const Reference< ::com::sun::star::plugin::XPlugin > & plugin, const ::rtl::OUString& url, const ::rtl::OUString& target) throw( ::com::sun::star::plugin::PluginException, RuntimeException );
+ virtual void SAL_CALL postURLNotify(const Reference< ::com::sun::star::plugin::XPlugin > & plugin, const ::rtl::OUString& url, const ::rtl::OUString& target, const Sequence< sal_Int8 >& buf, sal_Bool file, const Reference< ::com::sun::star::lang::XEventListener > & listener) throw( ::com::sun::star::plugin::PluginException, RuntimeException );
+ virtual void SAL_CALL postURL(const Reference< ::com::sun::star::plugin::XPlugin > & plugin, const ::rtl::OUString& url, const ::rtl::OUString& target, const Sequence< sal_Int8 >& buf, sal_Bool file) throw( ::com::sun::star::plugin::PluginException, RuntimeException );
+ virtual void SAL_CALL newStream(const Reference< ::com::sun::star::plugin::XPlugin > & plugin, const ::rtl::OUString& mimetype, const ::rtl::OUString& target, const Reference< ::com::sun::star::io::XActiveDataSource > & source) throw( ::com::sun::star::plugin::PluginException, RuntimeException );
+ virtual void SAL_CALL displayStatusText(const Reference< ::com::sun::star::plugin::XPlugin > & plugin, const ::rtl::OUString& message) throw( ::com::sun::star::plugin::PluginException, RuntimeException );
+ virtual ::rtl::OUString SAL_CALL getUserAgent(const Reference< ::com::sun::star::plugin::XPlugin > & plugin) throw( ::com::sun::star::plugin::PluginException, RuntimeException );
+};
+
+Reference< ::com::sun::star::plugin::XPluginContext > XPluginManager_Impl::createPluginContext() throw()
+{
+ return new XPluginContext_Impl( m_xSMgr );
+}
+
+XPluginContext_Impl::XPluginContext_Impl( const Reference< ::com::sun::star::lang::XMultiServiceFactory > & rSMgr )
+ : m_xSMgr( rSMgr ),
+ m_aEncoding( gsl_getSystemTextEncoding() )
+{
+}
+
+XPluginContext_Impl::~XPluginContext_Impl()
+{
+}
+
+::rtl::OUString XPluginContext_Impl::getValue( const Reference< ::com::sun::star::plugin::XPlugin > & /*plugin*/, ::com::sun::star::plugin::PluginVariable /*variable*/ )
+ throw( ::com::sun::star::plugin::PluginException, RuntimeException )
+{
+ return ::rtl::OUString();
+}
+
+
+void XPluginContext_Impl::getURL(const Reference< ::com::sun::star::plugin::XPlugin > & plugin, const ::rtl::OUString& url, const ::rtl::OUString& target) throw( ::com::sun::star::plugin::PluginException, RuntimeException )
+{
+ Reference< XInterface > xInst = m_xSMgr->createInstance( ::rtl::OUString::createFromAscii( "com.sun.star.frame.Desktop" ) );
+ if( ! xInst.is() )
+ return;
+
+ if( ! target.getLength() )
+ {
+ INetURLObject aURL;
+ aURL.SetSmartProtocol( INET_PROT_FILE );
+ aURL.SetSmartURL( ::rtl::OUStringToOString( url, m_aEncoding ) );
+
+ rtl::OUString aUrl = aURL.GetMainURL(INetURLObject::DECODE_TO_IURI);
+ // the mimetype cannot be specified
+ plugin->provideNewStream( ::rtl::OUString(),
+ Reference< XActiveDataSource >(),
+ aUrl,
+ 0, 0, (sal_Bool)(aUrl.compareToAscii( "file:", 5 ) == 0) );
+ return;
+ }
+
+ Reference< ::com::sun::star::frame::XComponentLoader > xLoader( xInst, UNO_QUERY );
+ XPlugin_Impl* pPlugin = XPluginManager_Impl::getPluginImplementation( plugin );
+
+ if( xLoader.is() && pPlugin )
+ {
+ try
+ {
+ ::com::sun::star::beans::PropertyValue aValue;
+ aValue.Name = ::rtl::OUString::createFromAscii( "Referer" );
+ aValue.Value <<= pPlugin->getRefererURL();
+
+ Sequence< ::com::sun::star::beans::PropertyValue > aArgs( &aValue, 1 );
+ Reference< ::com::sun::star::lang::XComponent > xComp =
+ xLoader->loadComponentFromURL(
+ url,
+ target,
+ ::com::sun::star::frame::FrameSearchFlag::PARENT |
+ ::com::sun::star::frame::FrameSearchFlag::SELF |
+ ::com::sun::star::frame::FrameSearchFlag::CHILDREN |
+ ::com::sun::star::frame::FrameSearchFlag::SIBLINGS |
+ ::com::sun::star::frame::FrameSearchFlag::TASKS |
+ ::com::sun::star::frame::FrameSearchFlag::CREATE,
+ aArgs
+ );
+ }
+ catch(...)
+ {
+ throw ::com::sun::star::plugin::PluginException();
+ }
+ }
+}
+
+void XPluginContext_Impl::getURLNotify(const Reference< ::com::sun::star::plugin::XPlugin > & plugin, const ::rtl::OUString& url, const ::rtl::OUString& target, const Reference< ::com::sun::star::lang::XEventListener > & listener )
+ throw( ::com::sun::star::plugin::PluginException, RuntimeException )
+{
+ getURL( plugin, url, target );
+ if( listener.is() )
+ listener->disposing( ::com::sun::star::lang::EventObject() );
+}
+
+::rtl::OUString XPluginContext_Impl::getUserAgent(const Reference< ::com::sun::star::plugin::XPlugin > & /*plugin*/)
+ throw( ::com::sun::star::plugin::PluginException, RuntimeException )
+{
+ return ::rtl::OUString::createFromAscii( "Mozilla 3.0" );
+}
+
+void XPluginContext_Impl::displayStatusText(const Reference< ::com::sun::star::plugin::XPlugin > & /*plugin*/, const ::rtl::OUString& /*message*/)
+ throw( ::com::sun::star::plugin::PluginException, RuntimeException )
+{
+}
+
+void XPluginContext_Impl::postURL(const Reference< ::com::sun::star::plugin::XPlugin > & plugin, const ::rtl::OUString& url, const ::rtl::OUString& target, const Sequence< sal_Int8 >& buf, sal_Bool file)
+ throw( ::com::sun::star::plugin::PluginException, RuntimeException )
+{
+ Sequence< sal_Int8 > aBuf;
+
+ if( file )
+ {
+ String aFileName( (char*)buf.getConstArray(), m_aEncoding );
+ INetURLObject aFilePath( aFileName );
+ aFileName = aFilePath.PathToFileName();
+ SvFileStream aStream( aFileName, STREAM_READ );
+ if( aStream.IsOpen() )
+ {
+ int nBytes = 0;
+ aStream.Seek( STREAM_SEEK_TO_END );
+ aBuf = Sequence<sal_Int8>( nBytes = aStream.Tell() );
+ aStream.Seek( STREAM_SEEK_TO_BEGIN );
+ aStream.Read( aBuf.getArray(), nBytes );
+ aStream.Close();
+ DirEntry( aFileName ).Kill();
+ }
+ }
+
+ Reference< XInterface > xInst = m_xSMgr->createInstance( ::rtl::OUString::createFromAscii( "com.sun.star.frame.Desktop" ) );
+ if( ! xInst.is() )
+ return ;
+
+ Reference< ::com::sun::star::frame::XComponentLoader > xLoader( xInst, UNO_QUERY );
+ XPlugin_Impl* pPlugin = XPluginManager_Impl::getPluginImplementation( plugin );
+ if( xLoader.is() && pPlugin )
+ {
+ try
+ {
+ ::com::sun::star::beans::PropertyValue aValues[2];
+ aValues[0].Name = ::rtl::OUString::createFromAscii( "Referer" );
+ aValues[0].Value <<= pPlugin->getRefererURL();
+
+ aValues[1].Name = ::rtl::OUString::createFromAscii( "PostString" );
+ aValues[1].Value <<= ::rtl::OStringToOUString( (char*)( file ? aBuf : buf ).getConstArray(), m_aEncoding );
+ Sequence< ::com::sun::star::beans::PropertyValue > aArgs( aValues, 2 );
+ Reference< ::com::sun::star::lang::XComponent > xComp =
+ xLoader->loadComponentFromURL(
+ url,
+ target,
+ ::com::sun::star::frame::FrameSearchFlag::PARENT |
+ ::com::sun::star::frame::FrameSearchFlag::SELF |
+ ::com::sun::star::frame::FrameSearchFlag::CHILDREN |
+ ::com::sun::star::frame::FrameSearchFlag::SIBLINGS |
+ ::com::sun::star::frame::FrameSearchFlag::TASKS |
+ ::com::sun::star::frame::FrameSearchFlag::CREATE,
+ aArgs
+ );
+ }
+ catch( ... )
+ {
+ throw ::com::sun::star::plugin::PluginException();
+ }
+ }
+}
+
+void XPluginContext_Impl::postURLNotify(const Reference< ::com::sun::star::plugin::XPlugin > & plugin, const ::rtl::OUString& url, const ::rtl::OUString& target, const Sequence< sal_Int8 >& buf, sal_Bool file, const Reference< ::com::sun::star::lang::XEventListener > & listener )
+ throw( ::com::sun::star::plugin::PluginException, RuntimeException )
+{
+ postURL( plugin, url, target, buf, file );
+ if( listener.is() )
+ listener->disposing( ::com::sun::star::lang::EventObject() );
+}
+
+void XPluginContext_Impl::newStream( const Reference< ::com::sun::star::plugin::XPlugin > & plugin, const ::rtl::OUString& mimetype, const ::rtl::OUString& target, const Reference< ::com::sun::star::io::XActiveDataSource > & source )
+ throw( ::com::sun::star::plugin::PluginException, RuntimeException )
+{
+ FileSink* pNewSink = new FileSink( m_xSMgr, plugin, mimetype, target, source );
+ pNewSink->acquire();
+}
+
+
+
+FileSink::FileSink( const Reference< ::com::sun::star::lang::XMultiServiceFactory > & rSMgr, const Reference< ::com::sun::star::plugin::XPlugin > & plugin,
+ const ::rtl::OUString& mimetype,
+ const ::rtl::OUString& target, const Reference< ::com::sun::star::io::XActiveDataSource > & source ) :
+ m_xSMgr( rSMgr ),
+ m_xPlugin( plugin ),
+ m_aMIMEType( mimetype ),
+ m_aTarget( target )
+{
+ DirEntry aEntry;
+ m_aFileName = aEntry.TempName().GetFull();
+ ::rtl::OString aFile = ::rtl::OUStringToOString( m_aFileName, gsl_getSystemTextEncoding() );
+ fp = fopen( aFile.getStr() , "wb" );
+
+ Reference< ::com::sun::star::io::XActiveDataControl > xControl( source, UNO_QUERY );
+
+ source->setOutputStream( Reference< ::com::sun::star::io::XOutputStream > ( this ) );
+ if( xControl.is() )
+ xControl->start();
+}
+
+FileSink::~FileSink()
+{
+ DirEntry aEntry( m_aFileName );
+ aEntry.Kill();
+}
+
+void FileSink::closeOutput() throw()
+{
+ if( fp )
+ fclose( fp );
+
+ Reference< XInterface > xInst = m_xSMgr->createInstance( ::rtl::OUString::createFromAscii( "com.sun.star.frame.Desktop" ) );
+ Reference< ::com::sun::star::frame::XComponentLoader > xLoader( xInst, UNO_QUERY );
+ XPlugin_Impl* pPlugin = XPluginManager_Impl::getPluginImplementation( m_xPlugin );
+
+ if( xLoader.is() && pPlugin )
+ {
+ try
+ {
+ ::com::sun::star::beans::PropertyValue aValue;
+ aValue.Name = ::rtl::OUString::createFromAscii( "Referer" );
+ aValue.Value <<= pPlugin->getRefererURL();
+
+ Sequence< ::com::sun::star::beans::PropertyValue > aArgs( &aValue, 1 );
+ Reference< ::com::sun::star::lang::XComponent > xComp =
+ xLoader->loadComponentFromURL(
+ m_aFileName,
+ m_aTarget,
+ ::com::sun::star::frame::FrameSearchFlag::PARENT |
+ ::com::sun::star::frame::FrameSearchFlag::SELF |
+ ::com::sun::star::frame::FrameSearchFlag::CHILDREN |
+ ::com::sun::star::frame::FrameSearchFlag::SIBLINGS |
+ ::com::sun::star::frame::FrameSearchFlag::TASKS |
+ ::com::sun::star::frame::FrameSearchFlag::CREATE,
+ aArgs
+ );
+ }
+ catch( ... )
+ {
+ }
+ }
+ release();
+}
+
+void FileSink::writeBytes( const Sequence<sal_Int8>& Buffer ) throw()
+{
+ if( fp )
+ fwrite( Buffer.getConstArray(), 1, Buffer.getLength(), fp );
+}
+
+void FileSink::flush() throw()
+{
+ if( fp )
+ fflush( fp );
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/plugin/base/evtlstnr.cxx b/extensions/source/plugin/base/evtlstnr.cxx
new file mode 100644
index 000000000000..ffbf3c208031
--- /dev/null
+++ b/extensions/source/plugin/base/evtlstnr.cxx
@@ -0,0 +1,73 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+
+#ifdef AIX
+#define _LINUX_SOURCE_COMPAT
+#include <sys/timer.h>
+#undef _LINUX_SOURCE_COMPAT
+#endif
+
+#if STLPORT_VERSION>=321
+#include <cstdarg>
+#endif
+
+#include <plugin/impl.hxx>
+
+PluginEventListener::PluginEventListener( XPlugin_Impl* pPlugin,
+ const char* url,
+ const char* normurl,
+ void* notifyData ) :
+ m_pPlugin( pPlugin ),
+ m_xPlugin( pPlugin ),
+ m_pUrl( strdup( url ) ),
+ m_pNormalizedUrl( strdup( normurl ) ),
+ m_pNotifyData( notifyData )
+{
+}
+
+PluginEventListener::~PluginEventListener()
+{
+ if( m_pUrl )
+ free( m_pUrl );
+ if( m_pNormalizedUrl )
+ free( m_pNormalizedUrl );
+}
+
+void PluginEventListener::disposing( const ::com::sun::star::lang::EventObject& /*rEvt*/ ) throw()
+{
+ m_pPlugin->getPluginComm()->
+ NPP_URLNotify( m_pPlugin->getNPPInstance(),
+ m_pUrl,
+ NPRES_DONE,
+ m_pNotifyData );
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/plugin/base/makefile.mk b/extensions/source/plugin/base/makefile.mk
new file mode 100644
index 000000000000..35390c6e6322
--- /dev/null
+++ b/extensions/source/plugin/base/makefile.mk
@@ -0,0 +1,70 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+PRJ=..$/..$/..
+
+PRJNAME=extensions
+TARGET=plbase
+TARGETTYPE=GUI
+ENABLE_EXCEPTIONS=TRUE
+
+.INCLUDE : ..$/util$/makefile.pmk
+
+INCPRE+=-I$(SOLARINCDIR)$/mozilla$/plugin
+.IF "$(SOLAR_JAVA)" != ""
+INCPRE+=-I$(SOLARINCDIR)$/mozilla$/java
+INCPRE+=-I$(SOLARINCDIR)$/mozilla$/nspr
+CDEFS+=-DOJI
+.ENDIF
+
+.IF "$(DISABLE_XAW)" != ""
+CDEFS+=-DDISABLE_XAW
+.ENDIF
+
+.IF "$(WITH_MOZILLA)" != "NO"
+
+.IF "$(GUIBASE)"=="aqua"
+CFLAGSCXX+=$(OBJCXXFLAGS)
+.ENDIF # "$(GUIBASE)"=="aqua"
+
+SLOFILES= \
+ $(SLO)$/plctrl.obj \
+ $(SLO)$/service.obj \
+ $(SLO)$/xplugin.obj \
+ $(SLO)$/nfuncs.obj \
+ $(SLO)$/manager.obj \
+ $(SLO)$/context.obj \
+ $(SLO)$/evtlstnr.obj \
+ $(SLO)$/plcom.obj \
+ $(SLO)$/multiplx.obj \
+ $(SLO)$/plmodel.obj
+
+.ENDIF # $(WITH_MOZILLA) != "NO"
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : target.mk
+
diff --git a/extensions/source/plugin/base/manager.cxx b/extensions/source/plugin/base/manager.cxx
new file mode 100644
index 000000000000..4e193244d0eb
--- /dev/null
+++ b/extensions/source/plugin/base/manager.cxx
@@ -0,0 +1,233 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+
+#ifdef AIX
+#define _LINUX_SOURCE_COMPAT
+#include <sys/timer.h>
+#undef _LINUX_SOURCE_COMPAT
+#endif
+
+#if STLPORT_VERSION>=321
+#include <cstdarg>
+#endif
+
+#include "plugin/impl.hxx"
+
+#include "osl/mutex.hxx"
+#include "unotools/pathoptions.hxx"
+#include "vcl/configsettings.hxx"
+
+#include "com/sun/star/container/XEnumerationAccess.hpp"
+#include "com/sun/star/container/XNameAccess.hpp"
+#include "com/sun/star/container/XEnumeration.hpp"
+#include "com/sun/star/container/XElementAccess.hpp"
+#include "com/sun/star/container/XIndexAccess.hpp"
+#include "com/sun/star/loader/XImplementationLoader.hpp"
+#include "com/sun/star/loader/CannotActivateFactoryException.hpp"
+
+PluginManager* PluginManager::pManager = NULL;
+
+PluginManager& PluginManager::get()
+{
+ if( ! pManager )
+ pManager = new PluginManager();
+ return *pManager;
+}
+
+void PluginManager::setServiceFactory( const Reference< ::com::sun::star::lang::XMultiServiceFactory >& xFactory )
+{
+ PluginManager& rManager = get();
+ if( ! rManager.m_xSMgr.is() )
+ rManager.m_xSMgr = xFactory;
+}
+
+PluginManager::PluginManager()
+{
+}
+
+const Sequence< ::rtl::OUString >& PluginManager::getAdditionalSearchPaths()
+{
+ static Sequence< ::rtl::OUString > aPaths;
+
+ if( ! aPaths.getLength() )
+ {
+ SvtPathOptions aOptions;
+ String aPluginPath( aOptions.GetPluginPath() );
+ if( aPluginPath.Len() )
+ {
+ USHORT nPaths = aPluginPath.GetTokenCount( ';' );
+ aPaths.realloc( nPaths );
+ for( USHORT i = 0; i < nPaths; i++ )
+ aPaths.getArray()[i] = aPluginPath.GetToken( i, ';' );
+ }
+ }
+
+ return aPaths;
+}
+
+//==================================================================================================
+Reference< XInterface > SAL_CALL PluginManager_CreateInstance( const Reference< ::com::sun::star::lang::XMultiServiceFactory > & rSMgr ) throw( Exception )
+{
+ Reference< XInterface > xService = *new XPluginManager_Impl( rSMgr );
+ return xService;
+}
+
+// ::com::sun::star::lang::XServiceInfo
+::rtl::OUString XPluginManager_Impl::getImplementationName() throw( )
+
+{
+ return getImplementationName_Static();
+
+}
+
+// ::com::sun::star::lang::XServiceInfo
+sal_Bool XPluginManager_Impl::supportsService(const ::rtl::OUString& ServiceName) throw( )
+{
+ Sequence< ::rtl::OUString > aSNL = getSupportedServiceNames();
+ const ::rtl::OUString * pArray = aSNL.getConstArray();
+ for( sal_Int32 i = 0; i < aSNL.getLength(); i++ )
+ if( pArray[i] == ServiceName )
+ return sal_True;
+ return sal_False;
+}
+
+// ::com::sun::star::lang::XServiceInfo
+Sequence< ::rtl::OUString > XPluginManager_Impl::getSupportedServiceNames(void) throw( )
+{
+ return getSupportedServiceNames_Static();
+}
+
+// XPluginManager_Impl
+Sequence< ::rtl::OUString > XPluginManager_Impl::getSupportedServiceNames_Static(void) throw( )
+{
+ Sequence< ::rtl::OUString > aSNS( 1 );
+ aSNS.getArray()[0] = ::rtl::OUString::createFromAscii( "com.sun.star.plugin.PluginManager" );
+ return aSNS;
+}
+
+XPluginManager_Impl::XPluginManager_Impl( const Reference< ::com::sun::star::lang::XMultiServiceFactory > & rSMgr )
+: m_xSMgr( rSMgr )
+{
+ PluginManager::setServiceFactory( rSMgr );
+}
+
+XPluginManager_Impl::~XPluginManager_Impl()
+{
+}
+
+XPlugin_Impl* XPluginManager_Impl::getXPluginFromNPP( NPP instance )
+{
+ ::std::list<XPlugin_Impl*>::iterator iter;
+ for( iter = PluginManager::get().getPlugins().begin();
+ iter != PluginManager::get().getPlugins().end(); ++iter )
+ {
+ if( (*iter)->getNPPInstance() == instance )
+ return *iter;
+ }
+
+ return NULL;
+}
+
+XPlugin_Impl* XPluginManager_Impl::getPluginImplementation( const Reference< ::com::sun::star::plugin::XPlugin >& plugin )
+{
+ ::std::list<XPlugin_Impl*>::iterator iter;
+ for( iter = PluginManager::get().getPlugins().begin();
+ iter != PluginManager::get().getPlugins().end(); ++iter )
+ {
+ if( plugin == Reference< ::com::sun::star::plugin::XPlugin >((*iter)) )
+ return *iter;
+ }
+
+ return NULL;
+}
+
+Sequence<com::sun::star::plugin::PluginDescription> XPluginManager_Impl::getPluginDescriptions() throw()
+{
+ Sequence<com::sun::star::plugin::PluginDescription> aRet;
+
+ vcl::SettingsConfigItem* pCfg = vcl::SettingsConfigItem::get();
+ rtl::OUString aVal( pCfg->getValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "BrowserPlugins" ) ),
+ rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Disabled" ) ) ) );
+ if( ! aVal.toBoolean() )
+ {
+ aRet = impl_getPluginDescriptions();
+ }
+ return aRet;
+}
+
+Reference< ::com::sun::star::plugin::XPlugin > XPluginManager_Impl::createPlugin( const Reference< ::com::sun::star::plugin::XPluginContext >& acontext, INT16 mode, const Sequence< ::rtl::OUString >& argn, const Sequence< ::rtl::OUString >& argv, const ::com::sun::star::plugin::PluginDescription& plugintype)
+ throw( RuntimeException,::com::sun::star::plugin::PluginException )
+{
+ XPlugin_Impl* pImpl = new XPlugin_Impl( m_xSMgr );
+ pImpl->setPluginContext( acontext );
+
+ PluginManager::get().getPlugins().push_back( pImpl );
+
+ pImpl->initInstance( plugintype,
+ argn,
+ argv,
+ mode );
+
+ return pImpl;
+}
+
+Reference< ::com::sun::star::plugin::XPlugin > XPluginManager_Impl::createPluginFromURL( const Reference< ::com::sun::star::plugin::XPluginContext > & acontext, sal_Int16 mode, const Sequence< ::rtl::OUString >& argn, const Sequence< ::rtl::OUString >& argv, const Reference< ::com::sun::star::awt::XToolkit > & toolkit, const Reference< ::com::sun::star::awt::XWindowPeer > & parent, const ::rtl::OUString& url ) throw()
+{
+ XPlugin_Impl* pImpl = new XPlugin_Impl( m_xSMgr );
+ Reference< ::com::sun::star::plugin::XPlugin > xRef = pImpl;
+
+ pImpl->setPluginContext( acontext );
+
+ PluginManager::get().getPlugins().push_back( pImpl );
+
+
+ pImpl->initInstance( url,
+ argn,
+ argv,
+ mode );
+
+ pImpl->createPeer( toolkit, parent );
+
+ pImpl->provideNewStream( pImpl->getDescription().Mimetype,
+ Reference< com::sun::star::io::XActiveDataSource >(),
+ url,
+ 0, 0, (sal_Bool)(url.compareToAscii( "file:", 5 ) == 0) );
+
+ if( ! pImpl->getPluginComm() )
+ {
+ pImpl->dispose();
+ xRef = NULL;
+ }
+
+ return xRef;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/plugin/base/multiplx.cxx b/extensions/source/plugin/base/multiplx.cxx
new file mode 100644
index 000000000000..bd25b51db184
--- /dev/null
+++ b/extensions/source/plugin/base/multiplx.cxx
@@ -0,0 +1,335 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+#include <osl/diagnose.h>
+#include <plugin/multiplx.hxx>
+
+// ---------------------------------------------------------------------
+// class MRCListenerMultiplexerHelper
+// ---------------------------------------------------------------------
+MRCListenerMultiplexerHelper::MRCListenerMultiplexerHelper
+(
+ const Reference< ::com::sun::star::awt::XWindow > & rControl
+ , const Reference< ::com::sun::star::awt::XWindow > & rPeer
+)
+ : xPeer( rPeer )
+ , xControl( Reference< ::com::sun::star::awt::XControl >( rControl, UNO_QUERY ) )
+ , aListenerHolder( aMutex )
+{
+}
+
+
+void MRCListenerMultiplexerHelper::setPeer( const Reference< ::com::sun::star::awt::XWindow > & rPeer )
+{
+ ::osl::Guard< ::osl::Mutex > aGuard( aMutex );
+ if( xPeer != rPeer )
+ {
+ if( xPeer.is() )
+ {
+ // get all uiks from the listener added to the peer
+ Sequence<Type> aContainedTypes = aListenerHolder.getContainedTypes();
+ const Type* pArray = aContainedTypes.getConstArray();
+ sal_Int32 nCount = aContainedTypes.getLength();
+ // loop over all listener types and remove the listeners from the peer
+ for( sal_Int32 i = 0; i < nCount; i++ )
+ unadviseFromPeer( xPeer, pArray[i] );
+ }
+ xPeer = rPeer;
+ if( xPeer.is() )
+ {
+ // get all uiks from the listener added to the peer
+ Sequence<Type> aContainedTypes = aListenerHolder.getContainedTypes();
+ const Type * pArray = aContainedTypes.getConstArray();
+ sal_Int32 nCount = aContainedTypes.getLength();
+ // loop over all listener types and add the listeners to the peer
+ for( sal_Int32 i = 0; i < nCount; i++ )
+ adviseToPeer( xPeer, pArray[i] );
+ }
+ }
+}
+
+// MRCListenerMultiplexerHelper
+void MRCListenerMultiplexerHelper::disposeAndClear()
+{
+ ::com::sun::star::lang::EventObject aEvt;
+ aEvt.Source = xControl;
+ aListenerHolder.disposeAndClear( aEvt );
+}
+
+// MRCListenerMultiplexerHelper
+void MRCListenerMultiplexerHelper::adviseToPeer( const Reference< ::com::sun::star::awt::XWindow > & rPeer, const Type & type )
+{
+ // add a listener to the source (peer)
+ if( type == ::getCppuType((const Reference< ::com::sun::star::awt::XWindowListener >*)0) )
+ rPeer->addWindowListener( this );
+ else if( type == ::getCppuType((const Reference< ::com::sun::star::awt::XKeyListener >*)0) )
+ rPeer->addKeyListener( this );
+ else if( type == ::getCppuType((const Reference< ::com::sun::star::awt::XFocusListener >*)0) )
+ rPeer->addFocusListener( this );
+ else if( type == ::getCppuType((const Reference< ::com::sun::star::awt::XMouseListener >*)0) )
+ rPeer->addMouseListener( this );
+ else if( type == ::getCppuType((const Reference< ::com::sun::star::awt::XMouseMotionListener >*)0) )
+ rPeer->addMouseMotionListener( this );
+ else if( type == ::getCppuType((const Reference< ::com::sun::star::awt::XPaintListener >*)0) )
+ rPeer->addPaintListener( this );
+ else if( type == ::getCppuType((const Reference< ::com::sun::star::awt::XTopWindowListener >*)0) )
+ {
+ Reference< ::com::sun::star::awt::XTopWindow > xTop( rPeer, UNO_QUERY );
+ if( xTop.is() )
+ xTop->addTopWindowListener( this );
+ }
+ else
+ {
+ OSL_ENSURE( sal_False, "unknown listener" );
+ }
+}
+
+// MRCListenerMultiplexerHelper
+void MRCListenerMultiplexerHelper::unadviseFromPeer( const Reference< ::com::sun::star::awt::XWindow > & rPeer, const Type & type )
+{
+ // the last listener is removed, remove the listener from the source (peer)
+ if( type == ::getCppuType((const Reference< ::com::sun::star::awt::XWindowListener >*)0) )
+ rPeer->removeWindowListener( this );
+ else if( type == ::getCppuType((const Reference< ::com::sun::star::awt::XKeyListener >*)0) )
+ rPeer->removeKeyListener( this );
+ else if( type == ::getCppuType((const Reference< ::com::sun::star::awt::XFocusListener >*)0) )
+ rPeer->removeFocusListener( this );
+ else if( type == ::getCppuType((const Reference< ::com::sun::star::awt::XMouseListener >*)0) )
+ rPeer->removeMouseListener( this );
+ else if( type == ::getCppuType((const Reference< ::com::sun::star::awt::XMouseMotionListener >*)0) )
+ rPeer->removeMouseMotionListener( this );
+ else if( type == ::getCppuType((const Reference< ::com::sun::star::awt::XPaintListener >*)0) )
+ rPeer->removePaintListener( this );
+ else if( type == ::getCppuType((const Reference< ::com::sun::star::awt::XTopWindowListener >*)0) )
+ {
+ Reference< ::com::sun::star::awt::XTopWindow > xTop( rPeer, UNO_QUERY );
+ if( xTop.is() )
+ xTop->removeTopWindowListener( this );
+ }
+ else
+ {
+ OSL_ENSURE( sal_False, "unknown listener" );
+ }
+}
+
+// MRCListenerMultiplexerHelper
+void MRCListenerMultiplexerHelper::advise( const Type & type, const Reference< XInterface > & listener)
+{
+ ::osl::Guard< ::osl::Mutex > aGuard( aMutex );
+ if( 1 == aListenerHolder.addInterface( type, listener ) )
+ {
+ // the first listener is added
+ if( xPeer.is() )
+ adviseToPeer( xPeer, type );
+ }
+}
+
+// MRCListenerMultiplexerHelper
+void MRCListenerMultiplexerHelper::unadvise(const Type & type, const Reference< XInterface > & listener)
+{
+ ::osl::Guard< ::osl::Mutex > aGuard( aMutex );
+ ::cppu::OInterfaceContainerHelper * pCont = aListenerHolder.getContainer( type );
+ if( pCont )
+ {
+ if( 0 == pCont->removeInterface( listener ) && xPeer.is() )
+ // the last listener is removed
+ unadviseFromPeer( xPeer, type );
+ }
+}
+
+// ::com::sun::star::lang::XEventListener
+void MRCListenerMultiplexerHelper::disposing(const ::com::sun::star::lang::EventObject& ) throw()
+{
+ ::osl::Guard< ::osl::Mutex > aGuard( aMutex );
+ // peer is disposed, clear the reference
+ xPeer = Reference< ::com::sun::star::awt::XWindow > ();
+}
+
+#define MULTIPLEX( InterfaceName, MethodName, EventName ) \
+::cppu::OInterfaceContainerHelper * pCont; \
+pCont = aListenerHolder.getContainer( ::getCppuType((const Reference< InterfaceName >*)0) ); \
+if( pCont ) \
+{ \
+ ::cppu::OInterfaceIteratorHelper aIt( *pCont ); \
+ EventName aEvt = e; \
+ /* Remark: The control is the event source not the peer. We must change */ \
+ /* the source of the event */ \
+ aEvt.Source = xControl;\
+ /*.is the control not destroyed */ \
+ if( aEvt.Source.is() ) \
+ { \
+ if( aIt.hasMoreElements() ) \
+ { \
+ InterfaceName * pListener = (InterfaceName *)aIt.next(); \
+ try \
+ { \
+ pListener->MethodName( aEvt ); \
+ } \
+ catch( RuntimeException& ) \
+ { \
+ /* ignore all usr system exceptions from the listener */ \
+ } \
+ } \
+ } \
+}
+
+// ::com::sun::star::awt::XFocusListener
+void MRCListenerMultiplexerHelper::focusGained(const ::com::sun::star::awt::FocusEvent& e) throw()
+{
+ MULTIPLEX( ::com::sun::star::awt::XFocusListener, focusGained, ::com::sun::star::awt::FocusEvent )
+}
+
+// ::com::sun::star::awt::XFocusListener
+void MRCListenerMultiplexerHelper::focusLost(const ::com::sun::star::awt::FocusEvent& e) throw()
+{
+ MULTIPLEX( ::com::sun::star::awt::XFocusListener, focusLost, ::com::sun::star::awt::FocusEvent )
+}
+
+// ::com::sun::star::awt::XWindowListener
+void MRCListenerMultiplexerHelper::windowResized(const ::com::sun::star::awt::WindowEvent& e) throw()
+{
+ MULTIPLEX( ::com::sun::star::awt::XWindowListener, windowResized, ::com::sun::star::awt::WindowEvent )
+}
+
+// ::com::sun::star::awt::XWindowListener
+void MRCListenerMultiplexerHelper::windowMoved(const ::com::sun::star::awt::WindowEvent& e) throw()
+{
+ MULTIPLEX( ::com::sun::star::awt::XWindowListener, windowMoved, ::com::sun::star::awt::WindowEvent )
+}
+
+// ::com::sun::star::awt::XWindowListener
+void MRCListenerMultiplexerHelper::windowShown(const ::com::sun::star::lang::EventObject& e) throw()
+{
+ MULTIPLEX( ::com::sun::star::awt::XWindowListener, windowShown, ::com::sun::star::lang::EventObject )
+}
+
+// ::com::sun::star::awt::XWindowListener
+void MRCListenerMultiplexerHelper::windowHidden(const ::com::sun::star::lang::EventObject& e) throw()
+{
+ MULTIPLEX( ::com::sun::star::awt::XWindowListener, windowHidden, ::com::sun::star::lang::EventObject )
+}
+
+// ::com::sun::star::awt::XKeyListener
+void MRCListenerMultiplexerHelper::keyPressed(const ::com::sun::star::awt::KeyEvent& e) throw()
+{
+ MULTIPLEX( ::com::sun::star::awt::XKeyListener, keyPressed, ::com::sun::star::awt::KeyEvent )
+}
+
+// ::com::sun::star::awt::XKeyListener
+void MRCListenerMultiplexerHelper::keyReleased(const ::com::sun::star::awt::KeyEvent& e) throw()
+{
+ MULTIPLEX( ::com::sun::star::awt::XKeyListener, keyReleased, ::com::sun::star::awt::KeyEvent )
+}
+
+// ::com::sun::star::awt::XMouseListener
+void MRCListenerMultiplexerHelper::mousePressed(const ::com::sun::star::awt::MouseEvent& e) throw()
+{
+ MULTIPLEX( ::com::sun::star::awt::XMouseListener, mousePressed, ::com::sun::star::awt::MouseEvent )
+}
+
+// ::com::sun::star::awt::XMouseListener
+void MRCListenerMultiplexerHelper::mouseReleased(const ::com::sun::star::awt::MouseEvent& e) throw()
+{
+ MULTIPLEX( ::com::sun::star::awt::XMouseListener, mouseReleased, ::com::sun::star::awt::MouseEvent )
+}
+
+// ::com::sun::star::awt::XMouseListener
+void MRCListenerMultiplexerHelper::mouseEntered(const ::com::sun::star::awt::MouseEvent& e) throw()
+{
+ MULTIPLEX( ::com::sun::star::awt::XMouseListener, mouseEntered, ::com::sun::star::awt::MouseEvent )
+}
+
+// ::com::sun::star::awt::XMouseListener
+void MRCListenerMultiplexerHelper::mouseExited(const ::com::sun::star::awt::MouseEvent& e) throw()
+{
+ MULTIPLEX( ::com::sun::star::awt::XMouseListener, mouseExited, ::com::sun::star::awt::MouseEvent )
+}
+
+// ::com::sun::star::awt::XMouseMotionListener
+void MRCListenerMultiplexerHelper::mouseDragged(const ::com::sun::star::awt::MouseEvent& e) throw()
+{
+ MULTIPLEX( ::com::sun::star::awt::XMouseMotionListener, mouseDragged, ::com::sun::star::awt::MouseEvent )
+}
+
+// ::com::sun::star::awt::XMouseMotionListener
+void MRCListenerMultiplexerHelper::mouseMoved(const ::com::sun::star::awt::MouseEvent& e) throw()
+{
+ MULTIPLEX( ::com::sun::star::awt::XMouseMotionListener, mouseMoved, ::com::sun::star::awt::MouseEvent )
+}
+
+// ::com::sun::star::awt::XPaintListener
+void MRCListenerMultiplexerHelper::windowPaint(const ::com::sun::star::awt::PaintEvent& e) throw()
+{
+ MULTIPLEX( ::com::sun::star::awt::XPaintListener, windowPaint, ::com::sun::star::awt::PaintEvent )
+}
+
+// ::com::sun::star::awt::XTopWindowListener
+void MRCListenerMultiplexerHelper::windowOpened(const ::com::sun::star::lang::EventObject& e) throw()
+{
+ MULTIPLEX( ::com::sun::star::awt::XTopWindowListener, windowOpened, ::com::sun::star::lang::EventObject )
+}
+
+// ::com::sun::star::awt::XTopWindowListener
+void MRCListenerMultiplexerHelper::windowClosing( const ::com::sun::star::lang::EventObject& e ) throw()
+{
+ MULTIPLEX( ::com::sun::star::awt::XTopWindowListener, windowClosing, ::com::sun::star::lang::EventObject )
+}
+
+// ::com::sun::star::awt::XTopWindowListener
+void MRCListenerMultiplexerHelper::windowClosed( const ::com::sun::star::lang::EventObject& e ) throw()
+{
+ MULTIPLEX( ::com::sun::star::awt::XTopWindowListener, windowClosed, ::com::sun::star::lang::EventObject )
+}
+
+// ::com::sun::star::awt::XTopWindowListener
+void MRCListenerMultiplexerHelper::windowMinimized( const ::com::sun::star::lang::EventObject& e ) throw()
+{
+ MULTIPLEX( ::com::sun::star::awt::XTopWindowListener, windowMinimized, ::com::sun::star::lang::EventObject )
+}
+
+// ::com::sun::star::awt::XTopWindowListener
+void MRCListenerMultiplexerHelper::windowNormalized( const ::com::sun::star::lang::EventObject& e ) throw()
+{
+ MULTIPLEX( ::com::sun::star::awt::XTopWindowListener, windowNormalized, ::com::sun::star::lang::EventObject )
+}
+
+// ::com::sun::star::awt::XTopWindowListener
+void MRCListenerMultiplexerHelper::windowActivated( const ::com::sun::star::lang::EventObject& e ) throw()
+{
+ MULTIPLEX( ::com::sun::star::awt::XTopWindowListener, windowActivated, ::com::sun::star::lang::EventObject )
+}
+
+// ::com::sun::star::awt::XTopWindowListener
+void MRCListenerMultiplexerHelper::windowDeactivated( const ::com::sun::star::lang::EventObject& e ) throw()
+{
+ MULTIPLEX( ::com::sun::star::awt::XTopWindowListener, windowDeactivated, ::com::sun::star::lang::EventObject )
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/plugin/base/nfuncs.cxx b/extensions/source/plugin/base/nfuncs.cxx
new file mode 100644
index 000000000000..cbfc05e423e8
--- /dev/null
+++ b/extensions/source/plugin/base/nfuncs.cxx
@@ -0,0 +1,686 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+
+#ifdef AIX
+#define _LINUX_SOURCE_COMPAT
+#include <sys/timer.h>
+#undef _LINUX_SOURCE_COMPAT
+#endif
+
+#if STLPORT_VERSION>=321
+#include <cstdarg>
+#endif
+
+#include <list>
+
+#include <plugin/impl.hxx>
+#include <vcl/svapp.hxx>
+
+#if OSL_DEBUG_LEVEL > 1
+#include <osl/thread.h>
+#include <stdio.h>
+static FILE * s_file = 0;
+void TRACE( char const * s )
+{
+ if (! s_file)
+ s_file = stderr;
+ if (s_file)
+ {
+ oslThreadIdentifier t = osl_getThreadIdentifier(0);
+ fprintf( s_file, "log [t_id=%"SAL_PRIuUINT32"]: %s\n", t, s );
+ fflush( s_file );
+ }
+}
+void TRACEN( char const * s, long n )
+{
+ if (! s_file)
+ s_file = stderr;
+ if (s_file)
+ {
+ oslThreadIdentifier t = osl_getThreadIdentifier(0);
+ fprintf( s_file, "log [t_id=%"SAL_PRIuUINT32"]: %s%ld\n", t, s, n );
+ fflush( s_file );
+ }
+}
+void TRACES( char const* s, char const* s2 )
+{
+ if (! s_file)
+ s_file = stderr;
+ if (s_file)
+ {
+ oslThreadIdentifier t = osl_getThreadIdentifier(0);
+ fprintf( s_file, "log [t_id=%"SAL_PRIuUINT32"]: %s %s\n", t, s, s2 );
+ fflush( s_file );
+ }
+}
+#else
+#define TRACE(x)
+#define TRACEN(x,n)
+#define TRACES(x,s)
+#endif
+
+using namespace rtl;
+using namespace com::sun::star::lang;
+
+NPNetscapeFuncs aNPNFuncs =
+{
+ sizeof( NPNetscapeFuncs ),
+ (NP_VERSION_MAJOR << 8) | NP_VERSION_MINOR,
+ NPN_GetURL,
+ NPN_PostURL,
+ NPN_RequestRead,
+ NPN_NewStream,
+ NPN_Write,
+ NPN_DestroyStream,
+ NPN_Status,
+ NPN_UserAgent,
+ NPN_MemAlloc,
+ NPN_MemFree,
+ NPN_MemFlush,
+ NPN_ReloadPlugins,
+#ifdef OJI
+ NPN_GetJavaEnv,
+ NPN_GetJavaPeer,
+#else
+ 0,
+ 0,
+#endif
+ NPN_GetURLNotify,
+ NPN_PostURLNotify,
+ NPN_GetValue,
+ NPN_SetValue,
+ NPN_InvalidateRect,
+ NPN_InvalidateRegion,
+ NPN_ForceRedraw
+};
+
+static ::rtl::OString normalizeURL( XPlugin_Impl* plugin, const ::rtl::OString& url )
+{
+ ::rtl::OString aLoadURL;
+ if( url.indexOf( ":" ) == -1 )
+ {
+ aLoadURL = ::rtl::OUStringToOString( plugin->getCreationURL(), plugin->getTextEncoding() );
+ int nPos;
+ if( ( nPos = aLoadURL.indexOf( "://" ) ) != -1 )
+ {
+ if( url.getLength() && (url.getStr()[ 0 ] == '/' || url.indexOf( '/' ) != -1) )
+ {
+ // this means same server but new path
+ nPos = aLoadURL.indexOf( '/', nPos+3 );
+
+ if( nPos != -1 )
+ aLoadURL = aLoadURL.copy( 0, url.getStr()[0] == '/' ? nPos : nPos+1 );
+ }
+ else
+ {
+ // same server but new file
+ nPos = aLoadURL.lastIndexOf( '/' );
+ aLoadURL = aLoadURL.copy( 0, nPos+1 );
+ }
+ aLoadURL += url;
+ }
+ else
+ aLoadURL = url;
+ }
+ else if( url.indexOf( ":/" ) != -1 )
+ aLoadURL = url;
+
+ return aLoadURL;
+}
+
+struct AsynchronousGetURL
+{
+ OUString aUrl;
+ OUString aTarget;
+ Reference< XEventListener > xListener;
+
+ DECL_LINK( getURL, XPlugin_Impl* );
+};
+
+IMPL_LINK( AsynchronousGetURL, getURL, XPlugin_Impl*, pImpl )
+{
+ try
+ {
+ pImpl->enterPluginCallback();
+ if( xListener.is() )
+ pImpl->getPluginContext()->
+ getURLNotify( pImpl,
+ aUrl,
+ aTarget,
+ xListener );
+ else
+ pImpl->getPluginContext()->
+ getURL( pImpl,
+ aUrl,
+ aTarget );
+ }
+ catch( ::com::sun::star::plugin::PluginException& e )
+ {
+ (void)e;
+ }
+ pImpl->leavePluginCallback();
+ delete this;
+ return 0;
+}
+
+
+extern "C" {
+
+ void* SAL_CALL NP_LOADDS NPN_MemAlloc( uint32 nBytes )
+ {
+ TRACE( "NPN_MemAlloc" );
+ void* pMem = malloc( nBytes );
+ return pMem;
+ }
+
+ void SAL_CALL NP_LOADDS NPN_MemFree( void* pMem )
+ {
+ TRACE( "NPN_MemFree" );
+ free( pMem );
+ }
+
+ uint32 SAL_CALL NP_LOADDS NPN_MemFlush( uint32 /*nSize*/ )
+ {
+ TRACE( "NPN_MemFlush" );
+ return 0;
+ }
+
+ NPError SAL_CALL NP_LOADDS NPN_DestroyStream( NPP instance, NPStream* stream, NPError /*reason*/ )
+ {
+ TRACE( "NPN_DestroyStream" );
+ XPlugin_Impl* pImpl = XPluginManager_Impl::getXPluginFromNPP( instance );
+ if( ! pImpl )
+ return NPERR_INVALID_INSTANCE_ERROR;
+
+ PluginStream* pStream = pImpl->getStreamFromNPStream( stream );
+ if( pStream )
+ {
+ if( pStream->getStreamType() == InputStream )
+ static_cast<PluginInputStream*>(pStream)->releaseSelf();
+ else
+ delete pStream;
+ }
+
+ return NPERR_NO_ERROR;
+ }
+
+ #ifdef OJI
+ const JRIEnvInterface** SAL_CALL NP_LOADDS NPN_GetJavaEnv()
+ {
+ TRACE( "NPN_GetJavaEnv" );
+ // no java in this program
+ return NULL;
+ }
+
+ jref SAL_CALL NP_LOADDS NPN_GetJavaPeer( NPP /*instance*/ )
+ {
+ TRACE( "NPN_GetJavaPeer" );
+ return NULL;
+ }
+ #endif
+
+ NPError SAL_CALL NP_LOADDS NPN_GetURL( NPP instance, const char* url, const char* window )
+ {
+ TRACES( "NPN_GetURL", url );
+ XPlugin_Impl* pImpl = XPluginManager_Impl::getXPluginFromNPP( instance );
+ if( ! pImpl )
+ return NPERR_INVALID_INSTANCE_ERROR;
+
+ AsynchronousGetURL* pAsync = new AsynchronousGetURL();
+
+ OString aLoadURL = normalizeURL( pImpl, url );
+ TRACES( "NPN_GetURL", aLoadURL.getStr() );
+ pAsync->aUrl = OStringToOUString( aLoadURL, pImpl->getTextEncoding() );
+ pAsync->aTarget = OStringToOUString( window, pImpl->getTextEncoding() );
+ pImpl->setLastGetUrl( aLoadURL );
+ Application::PostUserEvent( LINK( pAsync, AsynchronousGetURL, getURL ), pImpl );
+ return NPERR_NO_ERROR;
+ }
+
+ NPError SAL_CALL NP_LOADDS NPN_GetURLNotify( NPP instance, const char* url, const char* target,
+ void* notifyData )
+ {
+ TRACES( "NPN_GetURLNotify", url );
+ XPlugin_Impl* pImpl = XPluginManager_Impl::getXPluginFromNPP( instance );
+ if( ! pImpl )
+ return NPERR_INVALID_INSTANCE_ERROR;
+
+ OString aLoadURL = normalizeURL( pImpl, url );
+ if( !aLoadURL.getLength() )
+ return NPERR_INVALID_URL;
+
+ AsynchronousGetURL* pAsync = new AsynchronousGetURL();
+ PluginEventListener* pListener =
+ new PluginEventListener( pImpl, url, aLoadURL.getStr(), notifyData );
+ if( ! target || ! *target )
+ {
+ // stream will be fed back to plugin,
+ // notify immediately after destruction of stream
+ pImpl->addPluginEventListener( pListener );
+ pListener = NULL;
+ }
+ pAsync->aUrl = OStringToOUString( aLoadURL, pImpl->getTextEncoding() );
+ pAsync->aTarget = OStringToOUString( target, pImpl->getTextEncoding() );
+ pAsync->xListener = pListener;
+ pImpl->setLastGetUrl( aLoadURL );
+ Application::PostUserEvent( LINK( pAsync, AsynchronousGetURL, getURL ), pImpl );
+
+ return NPERR_NO_ERROR;
+ }
+
+ NPError SAL_CALL NP_LOADDS NPN_NewStream( NPP instance, NPMIMEType type, const char* target,
+ NPStream** stream )
+ // stream is a return value
+ {
+ TRACE( "NPN_NewStream" );
+ XPlugin_Impl* pImpl = XPluginManager_Impl::getXPluginFromNPP( instance );
+ if( ! pImpl )
+ return NPERR_INVALID_INSTANCE_ERROR;
+
+ PluginOutputStream* pStream = new PluginOutputStream( pImpl,
+ "", 0, 0 );
+ *stream = pStream->getStream();
+
+ try
+ {
+ pImpl->enterPluginCallback();
+ pImpl->getPluginContext()->
+ newStream(
+ pImpl,
+ ::rtl::OStringToOUString( type, pImpl->getTextEncoding () ),
+ ::rtl::OStringToOUString( target, pImpl->getTextEncoding() ),
+ ::com::sun::star::uno::Reference< ::com::sun::star::io::XActiveDataSource > ( pStream->getOutputStream(), UNO_QUERY )
+ );
+ pImpl->leavePluginCallback();
+ }
+ catch( ::com::sun::star::plugin::PluginException& e )
+ {
+ pImpl->leavePluginCallback();
+ return e.ErrorCode;
+ }
+
+ return NPERR_NO_ERROR;
+ }
+
+ NPError SAL_CALL NP_LOADDS NPN_PostURLNotify( NPP instance, const char* url, const char* target, uint32 len, const char* buf, NPBool file, void* notifyData )
+ {
+ TRACE( "NPN_PostURLNotify" );
+ XPlugin_Impl* pImpl = XPluginManager_Impl::getXPluginFromNPP( instance );
+ if( ! pImpl )
+ return NPERR_INVALID_INSTANCE_ERROR;
+
+ ::com::sun::star::uno::Sequence<sal_Int8> Bytes( (sal_Int8*)buf, len );
+
+ ::rtl::OString aPostURL = normalizeURL( pImpl, url );
+ PluginEventListener* pListener =
+ new PluginEventListener( pImpl, url, aPostURL.getStr(), notifyData );
+
+ if( ! target || ! *target )
+ {
+ // stream will be fed back to plugin,
+ // notify immediately after destruction of stream
+ pImpl->addPluginEventListener( pListener );
+ pListener = NULL;
+ }
+
+ try
+ {
+ pImpl->enterPluginCallback();
+ pImpl->getPluginContext()->
+ postURLNotify( pImpl,
+ ::rtl::OStringToOUString( aPostURL, pImpl->getTextEncoding() ),
+ ::rtl::OStringToOUString( target, pImpl->getTextEncoding() ),
+ Bytes,
+ file,
+ ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > ( pListener ) );
+ pImpl->leavePluginCallback();
+ }
+ catch( ::com::sun::star::plugin::PluginException& e )
+ {
+ pImpl->leavePluginCallback();
+ return e.ErrorCode;
+ }
+
+ return NPERR_NO_ERROR;
+ }
+
+ NPError SAL_CALL NP_LOADDS NPN_PostURL( NPP instance, const char* url, const char* window, uint32 len, const char* buf, NPBool file )
+ {
+ TRACE( "NPN_PostURL" );
+ XPlugin_Impl* pImpl = XPluginManager_Impl::getXPluginFromNPP( instance );
+ if( ! pImpl )
+ return NPERR_INVALID_INSTANCE_ERROR;
+
+ ::com::sun::star::uno::Sequence<sal_Int8> Bytes( (sal_Int8*)buf, len );
+ ::rtl::OString aPostURL = normalizeURL( pImpl, url );
+ try
+ {
+ pImpl->enterPluginCallback();
+ pImpl->getPluginContext()->
+ postURL( pImpl,
+ ::rtl::OStringToOUString( aPostURL, pImpl->getTextEncoding() ),
+ ::rtl::OStringToOUString( window, pImpl->getTextEncoding () ),
+ Bytes,
+ file );
+ pImpl->leavePluginCallback();
+ }
+ catch( ::com::sun::star::plugin::PluginException& e )
+ {
+ pImpl->leavePluginCallback();
+ return e.ErrorCode;
+ }
+
+ return NPERR_NO_ERROR;
+ }
+
+ NPError SAL_CALL NP_LOADDS NPN_RequestRead( NPStream* stream, NPByteRange* rangeList )
+ {
+ TRACE( "NPN_RequestRead" );
+ if( ! rangeList )
+ return NPERR_NO_ERROR;
+
+ ::std::list<XPlugin_Impl*>& rList = PluginManager::get().getPlugins();
+ ::std::list<XPlugin_Impl*>::iterator iter;
+ XPlugin_Impl* pPlugin = NULL;
+ PluginStream* pStream = NULL;
+ for( iter = rList.begin(); iter!= rList.end(); ++iter )
+ {
+ pStream = (*iter)->getStreamFromNPStream( stream );
+ if( pStream )
+ {
+ pPlugin = *iter;
+ break;
+ }
+ }
+ if( ! pPlugin )
+ return NPERR_INVALID_INSTANCE_ERROR;
+ if( ! pStream || pStream->getStreamType() != InputStream )
+ return NPERR_FILE_NOT_FOUND;
+
+ PluginInputStream* pInputStream = (PluginInputStream*)pStream;
+ sal_Int8* pBytes = NULL;
+ int nBytes = 0;
+ pPlugin->enterPluginCallback();
+ while( rangeList )
+ {
+ if( pBytes && nBytes < (int)rangeList->length )
+ {
+ delete [] pBytes;
+ pBytes = NULL;
+ }
+ if( ! pBytes )
+ pBytes = new sal_Int8[ nBytes = rangeList->length ];
+ int nRead =
+ pInputStream->read( rangeList->offset, pBytes, rangeList->length );
+ int nPos = 0;
+ int nNow;
+ do
+ {
+ nNow = pPlugin->getPluginComm()->
+ NPP_WriteReady( pPlugin->getNPPInstance(),
+ stream );
+ nNow = pPlugin->getPluginComm()->
+ NPP_Write( pPlugin->getNPPInstance(),
+ stream,
+ rangeList->offset + nPos,
+ nNow,
+ pBytes+nPos );
+ nPos += nNow;
+ nRead -= nNow;
+ } while( nRead > 0 && nNow );
+ rangeList = rangeList->next;
+ }
+ pPlugin->leavePluginCallback();
+
+ return NPERR_NO_ERROR;
+ }
+
+ void SAL_CALL NP_LOADDS NPN_Status( NPP instance, const char* message )
+ {
+ TRACE( "NPN_Status" );
+ XPlugin_Impl* pImpl = XPluginManager_Impl::getXPluginFromNPP( instance );
+ if( ! pImpl )
+ return;
+
+ try
+ {
+ pImpl->enterPluginCallback();
+ pImpl->getPluginContext()->
+ displayStatusText( pImpl, ::rtl::OStringToOUString( message, pImpl->getTextEncoding() ) );
+ pImpl->leavePluginCallback();
+ }
+ catch( ::com::sun::star::plugin::PluginException& )
+ {
+ pImpl->leavePluginCallback();
+ return;
+ }
+ }
+
+ const char* SAL_CALL NP_LOADDS NPN_UserAgent( NPP instance )
+ {
+ static char* pAgent = strdup( "Mozilla 3.0" );
+
+ XPlugin_Impl* pImpl = XPluginManager_Impl::getXPluginFromNPP( instance );
+ if( pImpl )
+ {
+ rtl::OUString UserAgent;
+ try
+ {
+ pImpl->enterPluginCallback();
+ UserAgent = pImpl->getPluginContext()->
+ getUserAgent( pImpl );
+ pImpl->leavePluginCallback();
+ if( pAgent )
+ free( pAgent );
+ pAgent = strdup( ::rtl::OUStringToOString( UserAgent, pImpl->getTextEncoding() ).getStr() );
+ }
+ catch( ::com::sun::star::plugin::PluginException& )
+ {
+ pImpl->leavePluginCallback();
+ }
+ }
+
+ TRACES( "NPN_UserAgent: returning", pAgent );
+
+ return pAgent;
+ }
+
+void SAL_CALL NP_LOADDS NPN_Version( int* major, int* minor, int* net_major, int* net_minor )
+{
+ TRACE( "NPN_Version" );
+ *major = 4;
+ *minor = 0;
+ *net_major = 4;
+ *net_minor = 5;
+}
+
+int32 SAL_CALL NP_LOADDS NPN_Write( NPP instance, NPStream* stream, int32 len,
+ void* buffer )
+{
+ TRACE( "NPN_Write" );
+ XPlugin_Impl* pImpl = XPluginManager_Impl::getXPluginFromNPP( instance );
+ if( ! pImpl )
+ return 0;
+
+ PluginStream* pStream = pImpl->getStreamFromNPStream( stream );
+ if( ! pStream || pStream->getStreamType() != OutputStream )
+ return 0;
+
+ pImpl->enterPluginCallback();
+ ::com::sun::star::uno::Sequence<sal_Int8> Bytes( (sal_Int8*)buffer, len );
+ ((PluginOutputStream*)pStream)->getOutputStream()->writeBytes( Bytes );
+ pImpl->leavePluginCallback();
+
+ return len;
+}
+
+
+NPError SAL_CALL NP_LOADDS NPN_GetValue( NPP instance, NPNVariable variable, void* value )
+{
+ TRACEN( "NPN_GetValue: ", variable );
+ XPlugin_Impl* pImpl = XPluginManager_Impl::getXPluginFromNPP( instance );
+
+ if( ! pImpl )
+ return 0;
+
+ NPError aResult( NPERR_NO_ERROR );
+
+ switch( variable )
+ {
+ case NPNVxDisplay:
+ // Unix only, handled in sysdep part
+ case NPNVxtAppContext:
+ // Unix only, handled in sysdep part
+ default:
+ aResult = NPERR_INVALID_PARAM;
+ break;
+ #ifdef QUARTZ
+ case 2000: // NPNVsupportsQuickDrawBool
+ *(NPBool*)value = false;
+ break;
+ case 2001: // NPNVsupportsCoreGraphicsBool
+ *(NPBool*)value = true;
+ break;
+ #endif
+ case NPNVjavascriptEnabledBool:
+ // no javascript
+ *(NPBool*)value = false;
+ break;
+ case NPNVasdEnabledBool:
+ // no SmartUpdate
+ *(NPBool*)value = false;
+ break;
+ case NPNVisOfflineBool:
+ // no offline browsing
+ *(NPBool*)value = false;
+ break;
+ }
+ /*
+ provisional code should there ever be NPNVariables that we actually
+ want to query from the PluginContext
+ ::rtl::OUString aValue;
+ try
+ {
+ pImpl->enterPluginCallback();
+ aValue = pImpl->getPluginContext()->
+ getValue( pImpl, (::com::sun::star::plugin::PluginVariable)variable );
+ pImpl->leavePluginCallback();
+ }
+ catch( ::com::sun::star::plugin::PluginException& e )
+ {
+ pImpl->leavePluginCallback();
+ return e.ErrorCode;
+ }
+ */
+
+ return aResult;
+}
+
+void SAL_CALL NP_LOADDS NPN_ReloadPlugins(NPBool /*reloadPages*/)
+{
+ TRACE( "NPN_ReloadPlugins" );
+}
+
+
+NPError SAL_CALL NP_LOADDS NPN_SetValue( NPP instance,
+ NPPVariable variable,
+ void* value )
+{
+ NPError nError = NPERR_NO_ERROR;
+ TRACEN( "NPN_SetValue ", variable );
+ switch( variable )
+ {
+ #ifdef QUARTZ
+ case (NPPVariable)1000: // NPNVpluginDrawingModel
+ {
+ int nDrawingModel = (int)value; // ugly, but that's the way we need to do it
+
+ TRACEN( "drawing model: ", nDrawingModel );
+
+ XPlugin_Impl* pImpl = XPluginManager_Impl::getXPluginFromNPP( instance );
+ if( pImpl )
+ pImpl->getSysPlugData().m_nDrawingModel = nDrawingModel;
+ }
+ break;
+ #endif
+ case NPPVpluginNameString: // make the windows compiler happy, it needs at least one case statement
+ break;
+ default:
+ break;
+ }
+ #ifndef QUARTZ
+ (void)instance;
+ (void)value;
+ #endif
+ return nError;
+}
+
+void SAL_CALL NP_LOADDS NPN_InvalidateRect(NPP instance, NPRect* /*invalidRect*/)
+{
+ TRACE( "NPN_InvalidateRect" );
+
+ #ifdef QUARTZ
+ NPN_ForceRedraw( instance );
+ #else
+ (void)instance;
+ #endif
+}
+
+void SAL_CALL NP_LOADDS NPN_InvalidateRegion(NPP instance, NPRegion /*invalidRegion*/)
+{
+ TRACE( "NPN_InvalidateRegion" );
+
+ #ifdef QUARTZ
+ NPN_ForceRedraw( instance );
+ #else
+ (void)instance;
+ #endif
+}
+
+void SAL_CALL NP_LOADDS NPN_ForceRedraw(NPP instance)
+{
+ TRACE( "NPN_ForceRedraw" );
+ #ifdef QUARTZ
+ XPlugin_Impl* pImpl = XPluginManager_Impl::getXPluginFromNPP( instance );
+ if( pImpl )
+ {
+ SysPlugData& rPlugData( pImpl->getSysPlugData() );
+ if( rPlugData.m_pPlugView )
+ [rPlugData.m_pPlugView setNeedsDisplay: YES];
+ }
+ #else
+ (void)instance;
+ #endif
+}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/plugin/base/plcom.cxx b/extensions/source/plugin/base/plcom.cxx
new file mode 100644
index 000000000000..a77145cdf573
--- /dev/null
+++ b/extensions/source/plugin/base/plcom.cxx
@@ -0,0 +1,79 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+
+#ifdef AIX
+#define _LINUX_SOURCE_COMPAT
+#include <sys/timer.h>
+#undef _LINUX_SOURCE_COMPAT
+#endif
+
+#ifdef SOLARIS
+#include <limits>
+#endif
+
+#if STLPORT_VERSION>=321
+#include <cstdarg>
+#endif
+
+#include <tools/fsys.hxx>
+#include <plugin/impl.hxx>
+
+PluginComm::PluginComm( const ::rtl::OString& rLibName, bool bReusable ) :
+ m_nRefCount( 0 ),
+ m_aLibName( rLibName )
+{
+ if( bReusable )
+ PluginManager::get().getPluginComms().push_back( this );
+}
+
+PluginComm::~PluginComm()
+{
+ PluginManager::get().getPluginComms().remove( this );
+ while( m_aFilesToDelete.size() )
+ {
+ String aFile = m_aFilesToDelete.front();
+ m_aFilesToDelete.pop_front();
+ DirEntry aEntry( aFile );
+ aEntry.Kill();
+ }
+}
+
+NPError PluginComm::NPP_SetWindow( XPlugin_Impl* i_pImpl )
+{
+ return NPP_SetWindow( i_pImpl->getNPPInstance(), i_pImpl->getNPWindow() );
+}
+
+NPError PluginComm::NPP_Destroy( XPlugin_Impl* i_pImpl, NPSavedData** save )
+{
+ return NPP_Destroy( i_pImpl->getNPPInstance(), save );
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/plugin/base/plctrl.cxx b/extensions/source/plugin/base/plctrl.cxx
new file mode 100644
index 000000000000..cf86074806f9
--- /dev/null
+++ b/extensions/source/plugin/base/plctrl.cxx
@@ -0,0 +1,325 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+#include <com/sun/star/awt/XAdjustmentListener.hpp>
+#include <com/sun/star/awt/XActionListener.hpp>
+#include <com/sun/star/awt/XTextListener.hpp>
+#include <com/sun/star/awt/XSpinListener.hpp>
+#include <com/sun/star/awt/XItemListener.hpp>
+#include <com/sun/star/awt/XVclContainerListener.hpp>
+
+#include <plugin/plctrl.hxx>
+#include <vcl/syschild.hxx>
+#include <toolkit/helper/vclunohelper.hxx>
+
+
+//--------------------------------------------------------------------------------------------------
+PluginControl_Impl::PluginControl_Impl() :
+ _pMultiplexer( NULL )
+ , _nX( 0 )
+ , _nY( 0 )
+ , _nWidth( 100 )
+ , _nHeight( 100 )
+ , _nFlags( WINDOW_POSSIZE_ALL )
+ , _bVisible( sal_False )
+ , _bInDesignMode( sal_False )
+ , _bEnable( sal_True )
+{
+}
+
+//--------------------------------------------------------------------------------------------------
+PluginControl_Impl::~PluginControl_Impl()
+{
+}
+
+MRCListenerMultiplexerHelper* PluginControl_Impl::getMultiplexer()
+{
+ if( ! _pMultiplexer )
+ _pMultiplexer = new MRCListenerMultiplexerHelper( this, _xPeerWindow );
+ return _pMultiplexer;
+}
+//==================================================================================================
+
+void PluginControl_Impl::addEventListener( const Reference< ::com::sun::star::lang::XEventListener > & l )
+ throw( RuntimeException )
+{
+ _aDisposeListeners.push_back( l );
+}
+
+//---- ::com::sun::star::lang::XComponent ----------------------------------------------------------------------------------
+void PluginControl_Impl::removeEventListener( const Reference< ::com::sun::star::lang::XEventListener > & l )
+ throw( RuntimeException )
+{
+ _aDisposeListeners.remove( l );
+}
+
+//---- ::com::sun::star::lang::XComponent ----------------------------------------------------------------------------------
+void PluginControl_Impl::dispose(void)
+ throw( RuntimeException )
+{
+ // send disposing events
+ ::com::sun::star::lang::EventObject aEvt;
+ if( getMultiplexer() )
+ getMultiplexer()->disposeAndClear();
+
+ // release context
+ _xContext = Reference< XInterface > ();
+ releasePeer();
+}
+
+
+//---- ::com::sun::star::awt::XWindow -------------------------------------------------------------------------------------
+void PluginControl_Impl::setPosSize( sal_Int32 nX_, sal_Int32 nY_, sal_Int32 nWidth_, sal_Int32 nHeight_, sal_Int16 nFlags )
+ throw( RuntimeException )
+{
+ _nX = nX_ >=0 ? nX_ : 0;
+ _nY = nY_ >=0 ? nY_ : 0;
+ _nWidth = nWidth_ >=0 ? nWidth_ : 0;
+ _nHeight = nHeight_ >=0 ? nHeight_ : 0;
+ _nFlags = nFlags;
+
+ if (_xPeerWindow.is())
+ _xPeerWindow->setPosSize( _nX, _nY, _nWidth, _nHeight, nFlags );
+}
+
+//---- ::com::sun::star::awt::XWindow -------------------------------------------------------------------------------------
+::com::sun::star::awt::Rectangle PluginControl_Impl::getPosSize(void)
+ throw( RuntimeException )
+{
+ return _xPeerWindow->getPosSize();
+}
+
+//---- ::com::sun::star::awt::XWindow -------------------------------------------------------------------------------------
+void PluginControl_Impl::setVisible( sal_Bool bVisible )
+ throw( RuntimeException )
+{
+ _bVisible = bVisible;
+ if (_xPeerWindow.is())
+ _xPeerWindow->setVisible( _bVisible && !_bInDesignMode );
+}
+
+//---- ::com::sun::star::awt::XWindow -------------------------------------------------------------------------------------
+void PluginControl_Impl::setEnable( sal_Bool bEnable )
+ throw( RuntimeException )
+{
+ _bEnable = bEnable;
+ if (_xPeerWindow.is())
+ _xPeerWindow->setEnable( _bEnable );
+}
+
+//---- ::com::sun::star::awt::XWindow -------------------------------------------------------------------------------------
+void PluginControl_Impl::setFocus(void) throw( RuntimeException )
+{
+ if (_xPeerWindow.is())
+ _xPeerWindow->setFocus();
+}
+
+
+//--------------------------------------------------------------------------------------------------
+void PluginControl_Impl::releasePeer()
+{
+ if (_xPeer.is())
+ {
+ _xParentWindow->removeFocusListener( this );
+ _xPeerWindow->dispose();
+ _pSysChild = NULL;
+ _xPeerWindow = Reference< ::com::sun::star::awt::XWindow > ();
+ _xPeer = Reference< ::com::sun::star::awt::XWindowPeer > ();
+ getMultiplexer()->setPeer( Reference< ::com::sun::star::awt::XWindow > () );
+ }
+}
+
+//---- ::com::sun::star::awt::XControl ------------------------------------------------------------------------------------
+void PluginControl_Impl::createPeer( const Reference< ::com::sun::star::awt::XToolkit > & /*xToolkit*/, const Reference< ::com::sun::star::awt::XWindowPeer > & xParentPeer )
+ throw( RuntimeException )
+{
+ if (_xPeer.is())
+ {
+ DBG_ERROR( "### Peer is already set!" );
+ return;
+ }
+
+ _xParentPeer = xParentPeer;
+ _xParentWindow = Reference< ::com::sun::star::awt::XWindow > ( xParentPeer, UNO_QUERY );
+ DBG_ASSERT( _xParentWindow.is(), "### no parent peer window!" );
+
+ Window* pImpl = VCLUnoHelper::GetWindow( xParentPeer );
+ if (pImpl)
+ {
+ _pSysChild = new SystemChildWindow( pImpl, WB_CLIPCHILDREN );
+ if (pImpl->HasFocus())
+ _pSysChild->GrabFocus();
+
+ // get peer
+ _xPeer = Reference< ::com::sun::star::awt::XWindowPeer > ( _pSysChild->GetComponentInterface() );
+ _xPeerWindow = Reference< ::com::sun::star::awt::XWindow > ( _xPeer, UNO_QUERY );
+ // !_BOTH_ MUST BE VALID!
+ DBG_ASSERT( (_xPeer.is() && _xPeerWindow.is()), "### no peer!" );
+
+ _xParentWindow->addFocusListener( this );
+ _xPeerWindow->setPosSize( _nX, _nY, _nWidth, _nHeight, _nFlags );
+ _xPeerWindow->setEnable( _bEnable );
+ _xPeerWindow->setVisible( _bVisible && !_bInDesignMode );
+ }
+ else
+ {
+ DBG_ERROR( "### cannot get implementation of parent peer!" );
+ }
+
+ getMultiplexer()->setPeer( _xPeerWindow );
+}
+
+//---- ::com::sun::star::awt::XControl ------------------------------------------------------------------------------------
+void PluginControl_Impl::setDesignMode( sal_Bool bOn )
+ throw( RuntimeException )
+{
+ _bInDesignMode = bOn;
+ if (_xPeerWindow.is())
+ _xPeerWindow->setVisible( _bVisible && !_bInDesignMode );
+}
+
+//---- ::com::sun::star::awt::XWindow -------------------------------------------------------------------------------------
+void PluginControl_Impl::addPaintListener( const Reference< ::com::sun::star::awt::XPaintListener > & l )
+ throw( RuntimeException )
+{
+ getMultiplexer()->advise( ::getCppuType((const Reference< ::com::sun::star::awt::XPaintListener >*)0), l );
+}
+
+//---- ::com::sun::star::awt::XWindow -------------------------------------------------------------------------------------
+void PluginControl_Impl::removePaintListener( const Reference< ::com::sun::star::awt::XPaintListener > & l )
+ throw( RuntimeException )
+{
+ getMultiplexer()->unadvise( ::getCppuType((const Reference< ::com::sun::star::awt::XPaintListener >*)0), l );
+}
+
+//---- ::com::sun::star::awt::XWindow -------------------------------------------------------------------------------------
+void PluginControl_Impl::addWindowListener( const Reference< ::com::sun::star::awt::XWindowListener > & l )
+ throw( RuntimeException )
+{
+ getMultiplexer()->advise( ::getCppuType((const Reference< ::com::sun::star::awt::XWindowListener >*)0), l );
+}
+
+//---- ::com::sun::star::awt::XWindow -------------------------------------------------------------------------------------
+void PluginControl_Impl::removeWindowListener( const Reference< ::com::sun::star::awt::XWindowListener > & l )
+ throw( RuntimeException )
+{
+ getMultiplexer()->unadvise( ::getCppuType((const Reference< ::com::sun::star::awt::XWindowListener >*)0), l );
+}
+
+//---- ::com::sun::star::awt::XWindow -------------------------------------------------------------------------------------
+void PluginControl_Impl::addFocusListener( const Reference< ::com::sun::star::awt::XFocusListener > & l )
+ throw( RuntimeException )
+{
+ getMultiplexer()->advise( ::getCppuType((const Reference< ::com::sun::star::awt::XFocusListener >*)0), l );
+}
+
+//---- ::com::sun::star::awt::XWindow -------------------------------------------------------------------------------------
+void PluginControl_Impl::removeFocusListener( const Reference< ::com::sun::star::awt::XFocusListener > & l )
+ throw( RuntimeException )
+{
+ getMultiplexer()->unadvise( ::getCppuType((const Reference< ::com::sun::star::awt::XFocusListener >*)0), l );
+}
+
+//---- ::com::sun::star::awt::XWindow -------------------------------------------------------------------------------------
+void PluginControl_Impl::addKeyListener( const Reference< ::com::sun::star::awt::XKeyListener > & l )
+ throw( RuntimeException )
+{
+ getMultiplexer()->advise( ::getCppuType((const Reference< ::com::sun::star::awt::XKeyListener >*)0), l );
+}
+
+//---- ::com::sun::star::awt::XWindow -------------------------------------------------------------------------------------
+void PluginControl_Impl::removeKeyListener( const Reference< ::com::sun::star::awt::XKeyListener > & l )
+ throw( RuntimeException )
+{
+ getMultiplexer()->unadvise( ::getCppuType((const Reference< ::com::sun::star::awt::XKeyListener >*)0), l );
+}
+
+//---- ::com::sun::star::awt::XWindow -------------------------------------------------------------------------------------
+void PluginControl_Impl::addMouseListener( const Reference< ::com::sun::star::awt::XMouseListener > & l )
+ throw( RuntimeException )
+{
+ getMultiplexer()->advise( ::getCppuType((const Reference< ::com::sun::star::awt::XMouseListener >*)0), l );
+}
+
+//---- ::com::sun::star::awt::XWindow -------------------------------------------------------------------------------------
+void PluginControl_Impl::removeMouseListener( const Reference< ::com::sun::star::awt::XMouseListener > & l )
+ throw( RuntimeException )
+{
+ getMultiplexer()->unadvise( ::getCppuType((const Reference< ::com::sun::star::awt::XMouseListener >*)0), l );
+}
+
+//---- ::com::sun::star::awt::XWindow -------------------------------------------------------------------------------------
+void PluginControl_Impl::addMouseMotionListener( const Reference< ::com::sun::star::awt::XMouseMotionListener > & l )
+ throw( RuntimeException )
+{
+ getMultiplexer()->advise( ::getCppuType((const Reference< ::com::sun::star::awt::XMouseMotionListener >*)0), l );
+}
+
+//---- ::com::sun::star::awt::XWindow -------------------------------------------------------------------------------------
+void PluginControl_Impl::removeMouseMotionListener( const Reference< ::com::sun::star::awt::XMouseMotionListener > & l )
+ throw( RuntimeException )
+{
+ getMultiplexer()->unadvise( ::getCppuType((const Reference< ::com::sun::star::awt::XMouseMotionListener >*)0), l );
+}
+
+
+//---- ::com::sun::star::awt::XView ---------------------------------------------------------------------------------------
+void PluginControl_Impl::draw( sal_Int32 /*x*/, sal_Int32 /*y*/ )
+ throw( RuntimeException )
+{
+ // has to be done by further implementation of control
+}
+
+//---- ::com::sun::star::awt::XView ---------------------------------------------------------------------------------------
+void PluginControl_Impl::setZoom( float /*ZoomX*/, float /*ZoomY*/ )
+ throw( RuntimeException )
+{
+ // has to be done by further implementation of control
+}
+
+//---- ::com::sun::star::lang::XEventListener ------------------------------------------------------------------------------
+void PluginControl_Impl::disposing( const ::com::sun::star::lang::EventObject & /*rSource*/ )
+ throw( RuntimeException )
+{
+}
+//---- ::com::sun::star::awt::XFocusListener ------------------------------------------------------------------------------
+void PluginControl_Impl::focusGained( const ::com::sun::star::awt::FocusEvent & /*rEvt*/ )
+ throw( RuntimeException )
+{
+ if (_xPeerWindow.is())
+ _xPeerWindow->setFocus();
+}
+//---- ::com::sun::star::awt::XFocusListener ------------------------------------------------------------------------------
+void PluginControl_Impl::focusLost( const ::com::sun::star::awt::FocusEvent & /*rEvt*/ )
+ throw( RuntimeException )
+{
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/plugin/base/plmodel.cxx b/extensions/source/plugin/base/plmodel.cxx
new file mode 100644
index 000000000000..5a7164720900
--- /dev/null
+++ b/extensions/source/plugin/base/plmodel.cxx
@@ -0,0 +1,206 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+#include <plugin/model.hxx>
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+
+using namespace com::sun::star::uno;
+
+//==================================================================================================
+Reference< XInterface > SAL_CALL PluginModel_CreateInstance( const Reference< ::com::sun::star::lang::XMultiServiceFactory > & ) throw( Exception )
+{
+ Reference< XInterface > xService = *new PluginModel();
+ return xService;
+}
+
+Any PluginModel::queryAggregation( const Type& type ) throw( RuntimeException )
+{
+ Any aRet( ::cppu::queryInterface( type,
+ static_cast< ::com::sun::star::lang::XComponent* >(this),
+ static_cast< ::com::sun::star::io::XPersistObject* >(this ),
+ static_cast< ::com::sun::star::awt::XControlModel* >(this),
+ static_cast< ::com::sun::star::beans::XPropertySet* >(this),
+ static_cast< ::com::sun::star::beans::XMultiPropertySet* >(this),
+ static_cast< ::com::sun::star::beans::XFastPropertySet* >(this)
+ ) );
+ return aRet.hasValue() ? aRet : OWeakAggObject::queryAggregation( type );
+}
+
+
+// XPluginManager_Impl
+Sequence< ::rtl::OUString > PluginModel::getSupportedServiceNames_Static(void) throw()
+{
+ Sequence< ::rtl::OUString > aSNS( 1 );
+ aSNS.getArray()[0] = ::rtl::OUString::createFromAscii( "com.sun.star.plugin.PluginModel" );
+ return aSNS;
+}
+
+
+static const char* aCreationURL = "URL";
+static const char* aMime = "TYPE";
+
+static ::osl::Mutex aPropertyMutex;
+
+static ::com::sun::star::beans::Property aProps[] =
+{
+ ::com::sun::star::beans::Property(
+ ::rtl::OUString::createFromAscii( aMime ),
+ 1,
+ ::getCppuType((const ::rtl::OUString*)0),
+ ::com::sun::star::beans::PropertyAttribute::BOUND ),
+ ::com::sun::star::beans::Property(
+ ::rtl::OUString::createFromAscii( aCreationURL ),
+ 2,
+ ::getCppuType((const ::rtl::OUString*)0),
+ ::com::sun::star::beans::PropertyAttribute::BOUND )
+};
+
+PluginModel::PluginModel() :
+ BroadcasterHelperHolder( aPropertyMutex ),
+ OPropertySetHelper( m_aHelper ),
+ OPropertyArrayHelper( aProps, 2 )
+{
+}
+
+PluginModel::PluginModel(const ::rtl::OUString& rURL, const rtl::OUString& rMimeType ) :
+ BroadcasterHelperHolder( aPropertyMutex ),
+ OPropertySetHelper( m_aHelper ),
+ OPropertyArrayHelper( aProps, 2 ),
+ m_aCreationURL( rURL ),
+ m_aMimeType( rMimeType )
+{
+}
+
+PluginModel::~PluginModel()
+{
+}
+
+Reference< ::com::sun::star::beans::XPropertySetInfo > PluginModel::getPropertySetInfo() throw()
+{
+ static Reference< ::com::sun::star::beans::XPropertySetInfo > aInfo =
+ createPropertySetInfo( *this );
+ return aInfo;
+}
+
+::cppu::IPropertyArrayHelper& PluginModel::getInfoHelper()
+{
+ return *this;
+}
+
+sal_Bool PluginModel::convertFastPropertyValue( Any & rConvertedValue,
+ Any & rOldValue,
+ sal_Int32 nHandle,
+ const Any& rValue ) throw()
+{
+ if( nHandle == 1 || nHandle == 2 )
+ {
+ if( rValue.getValueTypeClass() == TypeClass_STRING )
+ {
+ rConvertedValue = rValue;
+ if( nHandle == 2 )
+ rOldValue <<= m_aCreationURL;
+ else if( nHandle == 1 )
+ rOldValue <<= m_aMimeType;
+ return sal_True;
+ }
+ }
+ return sal_False;
+}
+
+void PluginModel::setFastPropertyValue_NoBroadcast( sal_Int32 nHandle,
+ const Any& rValue )
+ throw(::com::sun::star::uno::Exception)
+{
+ if( rValue.getValueTypeClass() == TypeClass_STRING ) // FIXME wrong type!
+
+ {
+ if( nHandle == 2 )
+ rValue >>= m_aCreationURL;
+ else if( nHandle == 1 )
+ rValue >>= m_aMimeType;
+ }
+ else
+ throw ::com::sun::star::lang::IllegalArgumentException();
+}
+
+void PluginModel::getFastPropertyValue( Any& rValue, sal_Int32 nHandle ) const throw()
+{
+ if( nHandle == 2 )
+ rValue <<= m_aCreationURL;
+ else if( nHandle == 1 )
+ rValue <<= m_aMimeType;
+}
+
+//---- ::com::sun::star::lang::XComponent ----------------------------------------------------------------------------------
+void PluginModel::addEventListener( const Reference< ::com::sun::star::lang::XEventListener > & l ) throw()
+{
+ m_aDisposeListeners.push_back( l );
+}
+
+//---- ::com::sun::star::lang::XComponent ----------------------------------------------------------------------------------
+void PluginModel::removeEventListener( const Reference< ::com::sun::star::lang::XEventListener > & l ) throw()
+{
+ m_aDisposeListeners.remove( l );
+}
+
+//---- ::com::sun::star::lang::XComponent ----------------------------------------------------------------------------------
+void PluginModel::dispose(void) throw()
+{
+ // send disposing events
+ ::com::sun::star::lang::EventObject aEvt;
+ aEvt.Source = (::cppu::OWeakObject*)this;
+ ::std::list< Reference< ::com::sun::star::lang::XEventListener > > aLocalListeners = m_aDisposeListeners;
+ for( ::std::list< Reference< ::com::sun::star::lang::XEventListener > >::iterator it = aLocalListeners.begin();
+ it != aLocalListeners.end(); ++it )
+ (*it)->disposing( aEvt );
+
+ m_aDisposeListeners.clear();
+
+ disposing();
+}
+
+
+// ::com::sun::star::io::XPersistObject
+::rtl::OUString PluginModel::getServiceName() throw()
+{
+ return ::rtl::OUString::createFromAscii( "com.sun.star.plugin.PluginModel" );
+}
+
+void PluginModel::write(const Reference< ::com::sun::star::io::XObjectOutputStream > & OutStream) throw()
+{
+ OutStream->writeUTF( m_aCreationURL );
+}
+
+void PluginModel::read(const Reference< ::com::sun::star::io::XObjectInputStream > & InStream) throw()
+{
+ m_aCreationURL = InStream->readUTF();
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/plugin/base/service.cxx b/extensions/source/plugin/base/service.cxx
new file mode 100644
index 000000000000..0b5d8321bf22
--- /dev/null
+++ b/extensions/source/plugin/base/service.cxx
@@ -0,0 +1,129 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+
+#ifdef AIX
+#define _LINUX_SOURCE_COMPAT
+#include <sys/timer.h>
+#undef _LINUX_SOURCE_COMPAT
+#endif
+
+#if STLPORT_VERSION>=321
+#include <cstdarg>
+#endif
+
+#include <plugin/impl.hxx>
+#include <tools/debug.hxx>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/lang/XSingleServiceFactory.hpp>
+#include <com/sun/star/container/XSet.hpp>
+#include <com/sun/star/registry/XRegistryKey.hpp>
+
+#include <uno/dispatcher.h> // declaration of generic uno interface
+#include <uno/mapping.hxx> // mapping stuff
+
+#include <cppuhelper/factory.hxx>
+
+using namespace cppu;
+
+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* pXUnoKey )
+ {
+ if( pXUnoKey )
+ {
+ try
+ {
+ Reference< ::com::sun::star::registry::XRegistryKey > xKey( reinterpret_cast< ::com::sun::star::registry::XRegistryKey* >( pXUnoKey ) );
+
+ ::rtl::OUString aImplName = ::rtl::OUString::createFromAscii( "/" );
+ aImplName += XPluginManager_Impl::getImplementationName_Static();
+ aImplName += ::rtl::OUString::createFromAscii( "/UNO/SERVICES/com.sun.star.plugin.PluginManager" );
+ xKey->createKey( aImplName );
+
+ aImplName = ::rtl::OUString::createFromAscii( "/" );
+ aImplName += PluginModel::getImplementationName_Static();
+ aImplName += ::rtl::OUString::createFromAscii( "/UNO/SERVICES/com.sun.star.plugin.PluginModel" );
+ xKey->createKey( aImplName );
+
+ return sal_True;
+ }
+ catch( ::com::sun::star::registry::InvalidRegistryException& )
+ {
+ }
+ }
+ return sal_False;
+ }
+
+ void* SAL_CALL component_getFactory(
+ const sal_Char* pImplementationName,
+ void* pXUnoSMgr,
+ void* /*pXUnoKey*/
+ )
+ {
+ void* pRet = 0;
+
+ ::rtl::OUString aImplName( ::rtl::OUString::createFromAscii( pImplementationName ) );
+
+ if( pXUnoSMgr )
+ {
+ Reference< ::com::sun::star::lang::XMultiServiceFactory > xMgr(
+ reinterpret_cast< ::com::sun::star::lang::XMultiServiceFactory* >( pXUnoSMgr )
+ );
+ Reference< ::com::sun::star::lang::XSingleServiceFactory > xFactory;
+ if( aImplName.equals( XPluginManager_Impl::getImplementationName_Static() ) )
+ {
+ xFactory = ::cppu::createSingleFactory(
+ xMgr, aImplName, PluginManager_CreateInstance,
+ XPluginManager_Impl::getSupportedServiceNames_Static() );
+ }
+ else if( aImplName.equals( PluginModel::getImplementationName_Static() ) )
+ {
+ xFactory = ::cppu::createSingleFactory(
+ xMgr, aImplName, PluginModel_CreateInstance,
+ PluginModel::getSupportedServiceNames_Static() );
+ }
+ if( xFactory.is() )
+ {
+ xFactory->acquire();
+ pRet = xFactory.get();
+ }
+ }
+ return pRet;
+ }
+} /* extern "C" */
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/plugin/base/xplugin.cxx b/extensions/source/plugin/base/xplugin.cxx
new file mode 100644
index 000000000000..610cc8dd1d91
--- /dev/null
+++ b/extensions/source/plugin/base/xplugin.cxx
@@ -0,0 +1,1162 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+#ifdef AIX
+#define _LINUX_SOURCE_COMPAT
+#include <sys/timer.h>
+#undef _LINUX_SOURCE_COMPAT
+#endif
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/lang/XSingleServiceFactory.hpp>
+#include <com/sun/star/loader/XImplementationLoader.hpp>
+#include <com/sun/star/loader/CannotActivateFactoryException.hpp>
+
+#include <plugin/impl.hxx>
+#include <tools/fsys.hxx>
+#include <ucbhelper/content.hxx>
+#include <tools/urlobj.hxx>
+#include <tools/string.hxx>
+#include <vcl/svapp.hxx>
+#include <salhelper/timer.hxx>
+#include <osl/file.hxx>
+
+#ifdef UNX
+#include <sys/types.h>
+#include <sys/socket.h>
+#endif
+
+#if OSL_DEBUG_LEVEL > 1
+#include <stdio.h>
+#endif
+
+using namespace com::sun::star;
+using namespace com::sun::star::io;
+using namespace com::sun::star::beans;
+using namespace com::sun::star::plugin;
+using namespace rtl;
+using namespace osl;
+
+class PluginDisposer : public salhelper::Timer
+{
+private:
+ XPlugin_Impl* m_pPlugin;
+
+ virtual void SAL_CALL onShot();
+public:
+ PluginDisposer( XPlugin_Impl* pPlugin ) :
+ salhelper::Timer( salhelper::TTimeValue( 2, 0 ),
+ salhelper::TTimeValue( 2, 0 ) ),
+ m_pPlugin( pPlugin )
+ { start(); }
+ ~PluginDisposer() {}
+};
+
+void PluginDisposer::onShot()
+{
+ if( m_pPlugin )
+ {
+ if( m_pPlugin->isDisposable() )
+ {
+ ULONG nEvent;
+ Application::PostUserEvent( nEvent, LINK( m_pPlugin, XPlugin_Impl, secondLevelDispose ), (void*)m_pPlugin );
+ }
+ }
+ else
+ release();
+}
+
+//==================================================================================================
+
+Any XPlugin_Impl::queryInterface( const Type& type ) throw( RuntimeException )
+{
+ return OWeakAggObject::queryInterface( type );
+}
+
+Any XPlugin_Impl::queryAggregation( const Type& type ) throw( RuntimeException )
+{
+ Any aRet( cppu::queryInterface( type, static_cast< XPlugin* >(this) ) );
+ if( ! aRet.hasValue() )
+ aRet = PluginControl_Impl::queryAggregation( type );
+ return aRet;
+}
+
+
+XPlugin_Impl::XPlugin_Impl( const uno::Reference< com::sun::star::lang::XMultiServiceFactory > & rSMgr) :
+ PluginControl_Impl(),
+ m_xSMgr( rSMgr ),
+ m_pPluginComm( NULL ),
+ m_aEncoding( gsl_getSystemTextEncoding() ),
+ m_pArgv( NULL ),
+ m_pArgn( NULL ),
+ m_nArgs( 0 ),
+ m_aPluginMode( NP_FULL ),
+ m_nProvidingState( PROVIDING_NONE ),
+ m_nCalledFromPlugin( 0 ),
+ m_pDisposer( NULL ),
+ m_bIsDisposed( sal_False )
+{
+ memset( &m_aInstance, 0, sizeof( m_aInstance ) );
+ memset( &m_aNPWindow, 0, sizeof( m_aNPWindow ) );
+ memset( &m_aSysPlugData, 0, sizeof( m_aSysPlugData ) );
+
+ m_xModel = new PluginModel();
+ uno::Reference< com::sun::star::beans::XPropertySet > xPS( m_xModel, UNO_QUERY );
+ xPS->addPropertyChangeListener( OUString(), this );
+
+ Guard< Mutex > aGuard( PluginManager::get().getPluginMutex() );
+ PluginManager::get().getPlugins().push_back( this );
+}
+
+void XPlugin_Impl::destroyInstance()
+{
+ Guard< Mutex > aGuard( m_aMutex );
+
+ NPSavedData* pSavedData = NULL;
+
+ destroyStreams();
+ if( getPluginComm() )
+ {
+ getPluginComm()->NPP_Destroy( this, &pSavedData );
+ getPluginComm()->decRef();
+ m_pPluginComm = NULL;
+ }
+
+ freeArgs();
+
+ while( m_aPEventListeners.size() )
+ {
+ delete *m_aPEventListeners.begin();
+ m_aPEventListeners.pop_front();
+ }
+}
+
+XPlugin_Impl::~XPlugin_Impl()
+{
+ destroyInstance();
+}
+
+void XPlugin_Impl::checkListeners( const char* normalizedURL )
+{
+ if( ! normalizedURL )
+ return;
+
+ Guard< Mutex > aGuard( m_aMutex );
+
+ std::list<PluginEventListener*>::iterator iter;
+ for( iter = m_aPEventListeners.begin();
+ iter != m_aPEventListeners.end();
+ ++iter )
+ {
+ if( ! strcmp( normalizedURL, (*iter)->getURL() ) ||
+ ! strcmp( normalizedURL, (*iter)->getNormalizedURL() ) )
+ {
+ (*iter)->disposing( com::sun::star::lang::EventObject() );
+ delete *iter;
+ m_aPEventListeners.remove( *iter );
+ return;
+ }
+ }
+}
+
+IMPL_LINK( XPlugin_Impl, secondLevelDispose, XPlugin_Impl*, /*pThis*/ )
+{
+ Guard< Mutex > aGuard( m_aMutex );
+
+ // may have become undisposable between PostUserEvent and here
+ // or may have disposed and receive a second UserEvent
+ std::list<XPlugin_Impl*>& rList = PluginManager::get().getPlugins();
+ std::list<XPlugin_Impl*>::iterator iter;
+
+ {
+ Guard< Mutex > aPluginGuard( PluginManager::get().getPluginMutex() );
+ for( iter = rList.begin(); iter != rList.end(); ++iter )
+ {
+ if( *iter == this )
+ break;
+ }
+ if( iter == rList.end() || ! isDisposable() )
+ return 0;
+ }
+
+ if (m_pDisposer)
+ {
+ m_pDisposer->release();
+ m_pDisposer = NULL;
+ }
+
+ uno::Reference< XPlugin > xProtection( this );
+ uno::Reference< com::sun::star::beans::XPropertySet > xPS( m_xModel, UNO_QUERY );
+ xPS->removePropertyChangeListener( OUString(), this );
+ {
+ Guard< Mutex > aPluginGuard( PluginManager::get().getPluginMutex() );
+ rList.remove( this );
+ }
+ m_aNPWindow.window = NULL;
+#ifndef UNX
+ // acrobat does an unconditional XtParent on the windows widget
+ getPluginComm()->NPP_SetWindow( this );
+#endif
+ destroyInstance();
+ PluginControl_Impl::dispose();
+ return 0;
+}
+
+void XPlugin_Impl::dispose() throw()
+{
+ Guard< Mutex > aGuard( m_aMutex );
+
+ if (m_bIsDisposed || !getPluginComm())
+ return;
+ m_bIsDisposed = sal_True;
+
+ if( isDisposable() )
+ secondLevelDispose( this );
+ else
+ {
+ m_pDisposer = new PluginDisposer( this );
+ m_pDisposer->acquire();
+ }
+}
+
+void XPlugin_Impl::initArgs( const Sequence< OUString >& argn,
+ const Sequence< OUString >& argv,
+ sal_Int16 mode )
+{
+ m_aPluginMode = mode;
+
+ m_nArgs = argn.getLength();
+ m_pArgn = new const char*[m_nArgs];
+ m_pArgv = new const char*[m_nArgs];
+ const OUString* pUArgn = argn.getConstArray();
+ const OUString* pUArgv = argv.getConstArray();
+ for( int i = 0; i < m_nArgs; i++ )
+ {
+ m_pArgn[i] = strdup(
+ OUStringToOString( pUArgn[i], m_aEncoding ).getStr()
+ );
+ m_pArgv[i] = strdup(
+ OUStringToOString( pUArgv[i], m_aEncoding ).getStr()
+ );
+ }
+}
+
+void XPlugin_Impl::freeArgs()
+{
+ if( m_nArgs > 0 )
+ {
+ for( ; m_nArgs--; )
+ {
+ free( (void*)m_pArgn[m_nArgs] );
+ free( (void*)m_pArgv[m_nArgs] );
+ }
+ delete [] m_pArgn;
+ delete [] m_pArgv;
+ }
+}
+
+void XPlugin_Impl::prependArg( const char* pName, const char* pValue )
+{
+ const char** pNewNames = new const char*[m_nArgs+1];
+ const char** pNewValues = new const char*[m_nArgs+1];
+
+ pNewNames[0] = strdup( pName );
+ pNewValues[0] = strdup( pValue );
+ for( int nIndex = 0; nIndex < m_nArgs; ++nIndex )
+ {
+ pNewNames[nIndex+1] = m_pArgn[nIndex];
+ pNewValues[nIndex+1]= m_pArgv[nIndex];
+ }
+ // free old arrays
+ delete [] m_pArgn;
+ delete [] m_pArgv;
+ // set new arrays
+ m_pArgn = pNewNames;
+ m_pArgv = pNewValues;
+ // set new number of arguments
+ m_nArgs++;
+#if OSL_DEBUG_LEVEL > 1
+ fprintf( stderr, "inserted %s=%s\n", pNewNames[0], pNewValues[0] );
+#endif
+}
+
+void XPlugin_Impl::handleSpecialArgs()
+{
+ // special handling for real audio which needs a lot of parameters
+ // or won't function at all
+ if( ! m_aDescription.Mimetype.compareToAscii( "audio/x-pn-realaudio-plugin" ) && m_nArgs < 1 )
+ {
+ OUString aURL;
+ if( m_xModel.is() )
+ {
+ try
+ {
+ uno::Reference< XPropertySet > xProp( m_xModel, UNO_QUERY );
+ Any aProp = xProp->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "URL" ) ) );
+ aProp >>= aURL;
+ }
+ catch( UnknownPropertyException )
+ {
+ }
+ }
+
+ if( aURL.getLength() )
+ {
+ // set new args, old args need not be freed as there were none set
+ m_nArgs = 6;
+ m_pArgn = new const char*[m_nArgs];
+ m_pArgv = new const char*[m_nArgs];
+
+ // SRC
+ m_pArgn[0] = strdup( "SRC" );
+ m_pArgv[0] = strdup( OUStringToOString( aURL, m_aEncoding ).getStr() );
+ // WIDTH
+ m_pArgn[1] = strdup( "WIDTH" );
+ m_pArgv[1] = strdup( "200" );
+ // HEIGHT
+ m_pArgn[2] = strdup( "HEIGHT" );
+ m_pArgv[2] = strdup( "200" );
+ // CONTROLS
+ m_pArgn[3] = strdup( "CONTROLS" );
+ m_pArgv[3] = strdup( "PlayButton,StopButton,ImageWindow" );
+ // AUTOSTART
+ m_pArgn[4] = strdup( "AUTOSTART" );
+ m_pArgv[4] = strdup( "TRUE" );
+ // NOJAVA
+ m_pArgn[5] = strdup( "NOJAVA" );
+ m_pArgv[5] = strdup( "TRUE" );
+ }
+ }
+ // #69333# special for pdf
+ else if( ! m_aDescription.Mimetype.compareToAscii( "application/pdf" ) )
+ m_aPluginMode = PluginMode::FULL;
+
+ // see if we have a TYPE tag
+ int nIndex;
+ for( nIndex = 0; nIndex < m_nArgs; ++nIndex )
+ if( m_pArgn[nIndex][0] == 'T' &&
+ m_pArgn[nIndex][1] == 'Y' &&
+ m_pArgn[nIndex][2] == 'P' &&
+ m_pArgn[nIndex][3] == 'E' &&
+ m_pArgn[nIndex][4] == 0 )
+ break;
+ if( nIndex >= m_nArgs )
+ {
+ // TYPE
+ prependArg( "TYPE", OUStringToOString( m_aDescription.Mimetype, m_aEncoding ).getStr() );
+ }
+
+ // see if we have a SRC tag
+ for( nIndex = 0; nIndex < m_nArgs; ++nIndex )
+ if( m_pArgn[nIndex][0] == 'S' &&
+ m_pArgn[nIndex][1] == 'R' &&
+ m_pArgn[nIndex][2] == 'C' &&
+ m_pArgn[nIndex][3] == 0 )
+ break;
+ if( nIndex >= m_nArgs )
+ {
+ // need a SRC parameter (as all browser set one on the plugin
+ OUString aURL;
+ if( m_xModel.is() )
+ {
+ try
+ {
+ uno::Reference< XPropertySet > xProp( m_xModel, UNO_QUERY );
+ Any aProp = xProp->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM( "URL" ) ) );
+ aProp >>= aURL;
+ }
+ catch( UnknownPropertyException )
+ {
+ }
+ }
+
+ if( aURL.getLength() )
+ {
+ // SRC
+ prependArg( "SRC", OUStringToOString( aURL, m_aEncoding ).getStr() );
+ }
+ }
+}
+
+void XPlugin_Impl::initInstance( const PluginDescription& rDescription,
+ const Sequence< OUString >& argn,
+ const Sequence< OUString >& argv,
+ sal_Int16 mode )
+{
+ Guard< Mutex > aGuard( m_aMutex );
+
+ m_aDescription = rDescription;
+ initArgs( argn, argv, mode );
+ handleSpecialArgs();
+}
+
+void XPlugin_Impl::initInstance( const OUString& rURL,
+ const Sequence< OUString >& argn,
+ const Sequence< OUString >& argv,
+ sal_Int16 mode )
+{
+ Guard< Mutex > aGuard( m_aMutex );
+
+ initArgs( argn, argv, mode );
+ m_aDescription = fitDescription( rURL );
+
+ m_xModel = new PluginModel( rURL, m_aDescription.Mimetype );
+ handleSpecialArgs();
+}
+
+void XPlugin_Impl::modelChanged()
+{
+ Guard< Mutex > aGuard( m_aMutex );
+
+ m_nProvidingState = PROVIDING_MODEL_UPDATE;
+
+ destroyInstance();
+
+ m_aDescription = fitDescription( getCreationURL() );
+ if( !m_aDescription.Mimetype.getLength() )
+ {
+ m_nProvidingState = PROVIDING_NONE;
+ return;
+ }
+
+ OUString aURL = getCreationURL();
+ provideNewStream( m_aDescription.Mimetype,
+ uno::Reference< XActiveDataSource >(),
+ aURL,
+ 0, 0, (sal_Bool)(aURL.compareToAscii( "file:", 5 ) == 0) );
+ m_nProvidingState = PROVIDING_NONE;
+}
+
+OUString XPlugin_Impl::getCreationURL()
+{
+ Guard< Mutex > aGuard( m_aMutex );
+
+ OUString aRet;
+ uno::Reference< com::sun::star::beans::XPropertySet > xPS( m_xModel, UNO_QUERY );
+ if( xPS.is() )
+ {
+ Any aValue = xPS->getPropertyValue( OUString::createFromAscii( "URL" ) );
+ aValue >>= aRet;
+ }
+ return aRet;
+}
+
+
+sal_Bool XPlugin_Impl::setModel( const uno::Reference< com::sun::star::awt::XControlModel > & Model )
+ throw( RuntimeException )
+{
+ Guard< Mutex > aGuard( m_aMutex );
+
+ uno::Reference< com::sun::star::beans::XPropertySet > xPS( Model, UNO_QUERY );
+ if( ! xPS.is() )
+ return sal_False;
+
+ if( getCreationURL().getLength() )
+ {
+ m_xModel = Model;
+ modelChanged();
+ xPS->addPropertyChangeListener( OUString(), this );
+ return sal_True;
+ }
+ return sal_False;
+}
+
+void XPlugin_Impl::createPeer( const uno::Reference< com::sun::star::awt::XToolkit > & xToolkit, const uno::Reference< com::sun::star::awt::XWindowPeer > & Parent )
+ throw( RuntimeException )
+{
+ Guard< Mutex > aGuard( m_aMutex );
+
+ if( ! _xPeer.is() )
+ {
+ if( ! Parent.is() )
+ throw RuntimeException();
+ PluginControl_Impl::createPeer( xToolkit, Parent );
+ }
+}
+
+void XPlugin_Impl::loadPlugin()
+{
+ Guard< Mutex > aGuard( m_aMutex );
+
+ std::list<PluginComm*>::iterator iter;
+ for( iter = PluginManager::get().getPluginComms().begin();
+ iter != PluginManager::get().getPluginComms().end(); ++iter )
+ {
+ if( OStringToOUString( (*iter)->getLibName(), m_aEncoding ) == m_aDescription.PluginName )
+ {
+ setPluginComm( *iter );
+ break;
+ }
+ }
+ const SystemEnvData* pEnvData = getSysChildSysData();
+#if defined( UNX ) && !(defined(QUARTZ))
+ XSync( (Display*)pEnvData->pDisplay, False );
+#endif
+ if( ! getPluginComm() )
+ {
+ if( m_aDescription.PluginName.getLength() )
+ {
+#if defined QUARTZ
+ PluginComm* pComm = new MacPluginComm( m_aDescription.Mimetype,
+ m_aDescription.PluginName,
+ pEnvData->pView );
+#elif defined UNX
+ // need a new PluginComm
+ PluginComm* pComm = NULL;
+ int sv[2];
+ if( !socketpair( AF_UNIX, SOCK_STREAM, 0, sv ) )
+ pComm = new UnxPluginComm( m_aDescription.Mimetype,
+ m_aDescription.PluginName,
+ (XLIB_Window)pEnvData->aWindow,
+ sv[0],
+ sv[1]
+ );
+#elif (defined WNT || defined OS2)
+ PluginComm* pComm = new PluginComm_Impl( m_aDescription.Mimetype,
+ m_aDescription.PluginName,
+ (HWND)pEnvData->hWnd );
+#endif
+ setPluginComm( pComm );
+ }
+ else
+ return;
+ }
+
+ NPError aError = getPluginComm()->
+ NPP_New( (char*)OUStringToOString( m_aDescription.Mimetype,
+ m_aEncoding).getStr(),
+ getNPPInstance(),
+ m_aPluginMode == PluginMode::FULL ? NP_FULL : NP_EMBED,
+ ::sal::static_int_cast< int16, int >( m_nArgs ),
+ (char**)(m_nArgs ? m_pArgn : NULL),
+ (char**)(m_nArgs ? m_pArgv : NULL),
+ NULL );
+#ifdef QUARTZ
+ // m_aNPWindow is set up in the MacPluginComm from the view
+ m_aSysPlugData.m_pParentView = pEnvData->pView;
+#elif defined( UNX )
+ XSync( (Display*)pEnvData->pDisplay, False );
+ m_aNPWindow.window = (void*)pEnvData->aWindow;
+ m_aNPWindow.ws_info = NULL;
+#else
+ m_aNPWindow.window = (void*)pEnvData->hWnd;
+#endif
+ com::sun::star::awt::Rectangle aPosSize = getPosSize();
+
+ for( int i = 0; i < m_nArgs; i++ )
+ {
+ OString aName( m_pArgn[i] );
+ if( aName.equalsIgnoreAsciiCase( "width" ) )
+ {
+ OString aValue( m_pArgv[i] );
+ aPosSize.Width = aValue.toInt32();
+ }
+ else if( aName.equalsIgnoreAsciiCase( "height" ) )
+ {
+ OString aValue( m_pArgv[i] );
+ aPosSize.Height = aValue.toInt32();
+ }
+ }
+
+ m_aNPWindow.clipRect.top = 0;
+ m_aNPWindow.clipRect.left = 0;
+ m_aNPWindow.clipRect.bottom = ::sal::static_int_cast< uint16, sal_Int32 >( aPosSize.Height );
+ m_aNPWindow.clipRect.right = ::sal::static_int_cast< uint16, sal_Int32 >( aPosSize.Width );
+ m_aNPWindow.type = NPWindowTypeWindow;
+
+ m_aNPWindow.x = 0;
+ m_aNPWindow.y = 0;
+ m_aNPWindow.width = aPosSize.Width ? aPosSize.Width : 600;
+ m_aNPWindow.height = aPosSize.Height ? aPosSize.Height : 600;
+
+ aError = getPluginComm()->NPP_SetWindow( this );
+}
+
+void XPlugin_Impl::destroyStreams()
+{
+ Guard< Mutex > aGuard( m_aMutex );
+
+ // streams remove themselves from this list when deleted
+ while( m_aOutputStreams.size() )
+ delete *m_aOutputStreams.begin();
+
+ // input streams are XOutputStreams, they cannot be simply deleted
+ std::list<PluginInputStream*> aLocalList( m_aInputStreams );
+ for( std::list<PluginInputStream*>::iterator it = aLocalList.begin();
+ it != aLocalList.end(); ++it )
+ (*it)->setMode( -1 );
+}
+
+PluginStream* XPlugin_Impl::getStreamFromNPStream( NPStream* stream )
+{
+ Guard< Mutex > aGuard( m_aMutex );
+
+ std::list<PluginInputStream*>::iterator iter;
+ for( iter = m_aInputStreams.begin(); iter != m_aInputStreams.end(); ++iter )
+ if( (*iter)->getStream() == stream )
+ return *iter;
+
+ std::list<PluginOutputStream*>::iterator iter2;
+ for( iter2 = m_aOutputStreams.begin(); iter2 != m_aOutputStreams.end(); ++iter2 )
+ if( (*iter2)->getStream() == stream )
+ return *iter2;
+
+ return NULL;
+}
+
+sal_Bool XPlugin_Impl::provideNewStream(const OUString& mimetype,
+ const uno::Reference< com::sun::star::io::XActiveDataSource > & stream,
+ const OUString& url, sal_Int32 length,
+ sal_Int32 lastmodified, sal_Bool isfile) throw()
+
+{
+ Guard< Mutex > aGuard( m_aMutex );
+ sal_Bool bRet = sal_False;
+
+ if( m_nProvidingState != PROVIDING_NONE )
+ {
+ m_nProvidingState = PROVIDING_NOW;
+ Any aAny;
+ aAny <<= url;
+ uno::Reference< com::sun::star::beans::XPropertySet > xPS( m_xModel, UNO_QUERY );
+ if( xPS.is() )
+ {
+ try
+ {
+ xPS->setPropertyValue( OUString::createFromAscii( "URL" ), aAny );
+ aAny <<= mimetype;
+ xPS->setPropertyValue( OUString::createFromAscii( "TYPE" ), aAny );
+ }
+ catch(...)
+ {
+ }
+ }
+ }
+ m_nProvidingState = PROVIDING_NOW;
+
+ OString aMIME;
+ if( mimetype.getLength() )
+ aMIME = OUStringToOString( mimetype, m_aEncoding );
+ else
+ aMIME = OUStringToOString( m_aDescription.Mimetype, m_aEncoding );
+
+ OString aURL = OUStringToOString( url, m_aEncoding );
+
+ // check wether there is a notifylistener for this stream
+ // this means that the strema is created from the plugin
+ // via NPN_GetURLNotify or NPN_PostURLNotify
+ std::list<PluginEventListener*>::iterator iter;
+ for( iter = m_aPEventListeners.begin();
+ iter != m_aPEventListeners.end();
+ ++iter )
+ {
+ if( (*iter)->getNormalizedURL() == aURL )
+ {
+ aURL = (*iter)->getURL();
+ break;
+ }
+ }
+
+ if( ! m_pPluginComm )
+ {
+ loadPlugin();
+ if( m_aLastGetUrl.getLength() && m_aLastGetUrl == aURL )
+ {
+ // plugin is pulling data, don't push the same stream;
+ // this complicated method could have been avoided if
+ // all plugins respected the SRC parameter; but e.g.
+ // acrobat reader plugin does not
+ m_nProvidingState = PROVIDING_NONE;
+ return sal_True;
+ }
+ }
+ if( ! m_pPluginComm )
+ return sal_False;
+
+ if( ! url.getLength() )
+ // this is valid if the plugin is supposed to
+ // pull data (via e.g. NPN_GetURL)
+ return sal_True;
+
+ // set mimetype on model
+ {
+ uno::Reference< com::sun::star::beans::XPropertySet > xPS( m_xModel, UNO_QUERY );
+ if( xPS.is() )
+ {
+ try
+ {
+ Any aAny;
+ aAny <<= m_aDescription.Mimetype;
+ xPS->setPropertyValue( OUString::createFromAscii( "TYPE" ), aAny );
+ }
+ catch(...)
+ {
+ }
+ }
+ }
+
+ // there may be plugins that can use the file length information,
+ // but currently none are known. Since this file opening/seeking/closing
+ // is rather costly, it is #if'ed out. If there are plugins known to
+ // make use of the file length, simply put it in
+#if 0
+ if( isfile && ! length )
+ {
+ osl::File aFile( url );
+ if( aFile.open( OpenFlag_Read ) == FileBase::E_None )
+ {
+ aFile.setPos( Pos_End, 0 );
+ sal_uInt64 nPos = 0;
+ if( aFile.getPos( nPos ) == FileBase::E_None )
+ length = nPos;
+ aFile.close();
+ }
+ }
+#endif
+
+ PluginInputStream* pStream = new PluginInputStream( this, aURL.getStr(),
+ length, lastmodified );
+ uno::Reference< com::sun::star::io::XOutputStream > xNewStream( pStream );
+
+ if( iter != m_aPEventListeners.end() )
+ pStream->getStream()->notifyData = (*iter)->getNotifyData();
+
+ uint16 stype = 0;
+
+ // special handling acrobat reader
+ // presenting a seekable stream to it does not seem to work correctly
+ if( aMIME.equals( "application/pdf" ) )
+ isfile = sal_False;
+
+#if OSL_DEBUG_LEVEL > 1
+ fprintf( stderr,
+ "new stream \"%s\" of MIMEType \"%s\"\n"
+ "for plugin \"%s\"\n"
+ "seekable = %s, length = %"SAL_PRIdINT32"\n",
+ aURL.getStr(), aMIME.getStr(), getPluginComm()->getLibName().getStr(),
+ isfile ? "true" : "false", length );
+
+#endif
+ if( ! m_pPluginComm->NPP_NewStream( &m_aInstance,
+ (char*)aMIME.getStr(),
+ pStream->getStream(), isfile,
+ &stype ) )
+ {
+#if OSL_DEBUG_LEVEL > 1
+ const char* pType;
+ switch( stype )
+ {
+ case NP_NORMAL: pType = "NP_NORMAL";break;
+ case NP_SEEK: pType = "NP_SEEK";break;
+ case NP_ASFILE: pType = "NP_ASFILE";break;
+ case NP_ASFILEONLY: pType = "NP_ASFILEONLY";break;
+ default: pType = "unknown!!!";
+ }
+ fprintf( stderr, "Plugin wants it in Mode %s\n", pType );
+#endif
+ if( isfile && stype == NP_ASFILEONLY )
+ {
+ OString aFileName;
+ if( url.compareToAscii( "file:", 5 ) == 0 )
+ {
+ OUString aSysName;
+ osl_getSystemPathFromFileURL( url.pData, &aSysName.pData );
+ aFileName = OUStringToOString( aSysName, m_aEncoding );
+ }
+ else
+ aFileName = OUStringToOString( url, m_aEncoding );
+ m_pPluginComm->
+ NPP_StreamAsFile( &m_aInstance,
+ pStream->getStream(),
+ aFileName.getStr() );
+ }
+ else
+ {
+ pStream->setMode( stype );
+
+ if( ! stream.is() )
+ {
+ // stream has to be loaded by PluginStream itself via UCB
+ pStream->load();
+ }
+ else
+ {
+ uno::Reference< com::sun::star::io::XConnectable > xConnectable( stream, UNO_QUERY );
+ pStream->setPredecessor( xConnectable );
+ if( xConnectable.is() )
+ {
+ xConnectable->setSuccessor( static_cast< com::sun::star::io::XConnectable* >(pStream) );
+ while( xConnectable->getPredecessor().is() )
+ xConnectable = xConnectable->getPredecessor();
+ }
+ stream->setOutputStream( xNewStream );
+ pStream->setSource( stream );
+ uno::Reference< com::sun::star::io::XActiveDataControl > xController;
+ if( xConnectable.is() )
+ xController = uno::Reference< com::sun::star::io::XActiveDataControl >( xConnectable, UNO_QUERY );
+ else
+ xController = uno::Reference< com::sun::star::io::XActiveDataControl >( stream, UNO_QUERY );
+
+ if( xController.is() )
+ xController->start();
+ }
+ }
+ bRet = sal_True;
+ }
+
+ m_nProvidingState = PROVIDING_NONE;
+
+ return bRet;
+}
+
+void XPlugin_Impl::disposing( const com::sun::star::lang::EventObject& /*rSource*/ ) throw()
+{
+}
+
+void XPlugin_Impl::propertyChange( const com::sun::star::beans::PropertyChangeEvent& rEvent ) throw()
+{
+ Guard< Mutex > aGuard( m_aMutex );
+
+ if( ! rEvent.PropertyName.compareToAscii( "URL" ) )
+ {
+ OUString aStr;
+ rEvent.NewValue >>= aStr;
+ if( m_nProvidingState == PROVIDING_NONE )
+ {
+ if( aStr != m_aURL )
+ {
+ m_aURL = aStr;
+ modelChanged();
+ }
+ }
+ }
+}
+
+void XPlugin_Impl::setPluginContext( const uno::Reference< XPluginContext > & rContext )
+{
+ m_rBrowserContext = rContext;
+}
+
+void XPlugin_Impl::setPosSize( sal_Int32 nX_, sal_Int32 nY_, sal_Int32 nWidth_, sal_Int32 nHeight_, sal_Int16 nFlags )
+ throw( RuntimeException )
+{
+ Guard< Mutex > aGuard( m_aMutex );
+
+#if OSL_DEBUG_LEVEL > 1
+ fprintf( stderr, "XPlugin_Impl::setPosSize( %"SAL_PRIdINT32", %"SAL_PRIdINT32", %"SAL_PRIdINT32", %"SAL_PRIdINT32", %d )\n",
+ nX_, nY_, nWidth_, nHeight_, nFlags );
+#endif
+
+ PluginControl_Impl::setPosSize(nX_, nY_, nWidth_, nHeight_, nFlags);
+
+ m_aNPWindow.x = 0;
+ m_aNPWindow.y = 0;
+ m_aNPWindow.width = nWidth_;
+ m_aNPWindow.height = nHeight_;
+ m_aNPWindow.clipRect.top = 0;
+ m_aNPWindow.clipRect.left = 0;
+ m_aNPWindow.clipRect.right = ::sal::static_int_cast< uint16, sal_Int32 >( nWidth_ );
+ m_aNPWindow.clipRect.bottom = ::sal::static_int_cast< uint16, sal_Int32 >( nHeight_ );
+
+ if( getPluginComm() )
+ getPluginComm()->NPP_SetWindow( this );
+}
+
+PluginDescription XPlugin_Impl::fitDescription( const OUString& rURL )
+{
+ uno::Reference< XPluginManager > xPMgr( m_xSMgr->createInstance( OUString::createFromAscii( "com.sun.star.plugin.PluginManager" ) ), UNO_QUERY );
+ if( !xPMgr.is() )
+ {
+ m_nProvidingState = PROVIDING_NONE;
+ return PluginDescription();
+ }
+
+ Sequence< PluginDescription > aDescrs = xPMgr->getPluginDescriptions();
+ const PluginDescription* pDescrs = aDescrs.getConstArray();
+
+ for( int nArg = 0; nArg < m_nArgs; nArg++ )
+ {
+ if( strncmp( m_pArgn[nArg], "TYPE", 4 ) == 0 &&
+ m_pArgn[nArg][4] == 0 )
+ {
+ for( int i = 0; i < aDescrs.getLength(); i++ )
+ {
+ if( pDescrs[i].Mimetype.compareToAscii( m_pArgv[nArg] ) == 0 )
+ return pDescrs[i];
+ }
+ }
+ }
+
+ int nPos = rURL.lastIndexOf( (sal_Unicode)'.' );
+ OUString aExt = rURL.copy( nPos ).toAsciiLowerCase();
+ if( nPos != -1 )
+ {
+ for( int i = 0; i < aDescrs.getLength(); i++ )
+ {
+ OUString aThisExt = pDescrs[ i ].Extension.toAsciiLowerCase();
+ if( aThisExt.indexOf( aExt ) != -1 )
+ {
+ return pDescrs[i];
+ }
+ }
+ }
+ return PluginDescription();
+}
+
+
+PluginStream::PluginStream( XPlugin_Impl* pPlugin,
+ const char* url, sal_uInt32 len, sal_uInt32 lastmod ) :
+ m_pPlugin( pPlugin )
+{
+ memset( &m_aNPStream, 0, sizeof( m_aNPStream ) );
+ m_aNPStream.url = strdup( url );
+ m_aNPStream.end = len;
+ m_aNPStream.lastmodified = lastmod;
+}
+
+PluginStream::~PluginStream()
+{
+ Guard< Mutex > aGuard( m_pPlugin->getMutex() );
+
+ if( m_pPlugin && m_pPlugin->getPluginComm() )
+ {
+ m_pPlugin->getPluginComm()->NPP_DestroyStream( m_pPlugin->getNPPInstance(),
+ &m_aNPStream, NPRES_DONE );
+ m_pPlugin->checkListeners( m_aNPStream.url );
+ m_pPlugin->getPluginComm()->NPP_SetWindow( m_pPlugin );
+ }
+ ::free( (void*)m_aNPStream.url );
+}
+
+PluginInputStream::PluginInputStream( XPlugin_Impl* pPlugin,
+ const char* url,
+ sal_uInt32 len,
+ sal_uInt32 lastmod ) :
+ PluginStream( pPlugin, url, len, lastmod ),
+ m_pContent( NULL ),
+ m_nMode( NP_NORMAL ),
+ m_nWritePos( 0 )
+{
+ Guard< Mutex > aGuard( m_pPlugin->getMutex() );
+
+ m_pPlugin->getInputStreams().push_back( this );
+ DirEntry aEntry;
+ aEntry = aEntry.TempName();
+
+ // set correct extension, some plugins need that
+ DirEntry aName( String( m_aNPStream.url, m_pPlugin->getTextEncoding() ) );
+ String aExtension = aName.GetExtension();
+ if( aExtension.Len() )
+ aEntry.SetExtension( aExtension );
+ m_aFileStream.Open( aEntry.GetFull(), STREAM_READ | STREAM_WRITE );
+ if( ! m_aFileStream.IsOpen() )
+ {
+ // #74808# might be that the extension scrambled the whole filename
+ aEntry = aEntry.TempName();
+ m_aFileStream.Open( aEntry.GetFull(), STREAM_READ | STREAM_WRITE );
+ }
+}
+
+PluginInputStream::~PluginInputStream()
+{
+ Guard< Mutex > aGuard( m_pPlugin->getMutex() );
+
+ m_pPlugin->getInputStreams().remove( this );
+
+ String aFile( m_aFileStream.GetFileName() );
+
+ m_aFileStream.Close();
+ if( m_pPlugin )
+ {
+ ByteString aFileName( aFile, m_pPlugin->getTextEncoding() );
+ if( m_pPlugin->getPluginComm() && m_nMode != -1 )
+ // mode -1 means either an error occured,
+ // or the plugin is already disposing
+ {
+ m_pPlugin->getPluginComm()->addFileToDelete( aFile );
+ if( m_nMode == NP_ASFILE )
+ {
+ m_pPlugin->getPluginComm()->
+ NPP_StreamAsFile( m_pPlugin->getNPPInstance(),
+ &m_aNPStream,
+ aFileName.GetBuffer() );
+ }
+ m_pPlugin->getPluginComm()->NPP_SetWindow( m_pPlugin );
+ m_pPlugin->getInputStreams().remove( this );
+ }
+ else
+ DirEntry( m_aFileStream.GetFileName() ).Kill();
+ }
+ else
+ DirEntry( m_aFileStream.GetFileName() ).Kill();
+ if( m_pContent )
+ delete m_pContent;
+}
+
+PluginStreamType PluginInputStream::getStreamType()
+{
+ return InputStream;
+}
+
+void PluginInputStream::load()
+{
+ Guard< Mutex > aGuard( m_pPlugin->getMutex() );
+
+ INetURLObject aUrl;
+ aUrl.SetSmartProtocol( INET_PROT_FILE );
+ aUrl.SetSmartURL(
+ String( getStream()->url,
+ ::sal::static_int_cast< USHORT, size_t >( strlen( getStream()->url ) ),
+ RTL_TEXTENCODING_MS_1252
+ ) );
+ try
+ {
+ m_pContent =
+ new ::ucbhelper::Content(
+ aUrl.GetMainURL(INetURLObject::DECODE_TO_IURI),
+ uno::Reference< com::sun::star::ucb::XCommandEnvironment >()
+ );
+ m_pContent->openStream( static_cast< XOutputStream* >( this ) );
+ }
+ catch( com::sun::star::uno::Exception )
+ {
+ }
+}
+
+void PluginInputStream::setMode( sal_Int32 nMode )
+{
+ Guard< Mutex > aGuard( m_pPlugin->getMutex() );
+
+ m_nMode = nMode;
+
+ // invalidation by plugin
+ if( m_nMode == -1 && m_pPlugin )
+ {
+ m_pPlugin->getInputStreams().remove( this );
+ m_pPlugin = NULL;
+ }
+}
+
+void PluginInputStream::writeBytes( const Sequence<sal_Int8>& Buffer ) throw()
+{
+ Guard< Mutex > aGuard( m_pPlugin->getMutex() );
+
+ m_aFileStream.Seek( STREAM_SEEK_TO_END );
+ m_aFileStream.Write( Buffer.getConstArray(), Buffer.getLength() );
+
+ if( m_nMode == NP_SEEK )
+ // hold reference, streem gets destroyed in NPN_DestroyStream
+ m_xSelf = this;
+
+ if( m_nMode == -1 || !m_pPlugin->getPluginComm() )
+ return;
+
+ UINT32 nPos = m_aFileStream.Tell();
+ UINT32 nBytes = 0;
+ while( m_nMode != NP_ASFILEONLY &&
+ m_nWritePos < nPos &&
+ (nBytes = m_pPlugin->getPluginComm()-> NPP_WriteReady(
+ m_pPlugin->getNPPInstance(), &m_aNPStream )) > 0 )
+ {
+ nBytes = (nBytes > nPos - m_nWritePos) ? nPos - m_nWritePos : nBytes;
+
+ char* pBuffer = new char[ nBytes ];
+ m_aFileStream.Seek( m_nWritePos );
+ nBytes = m_aFileStream.Read( pBuffer, nBytes );
+
+ int32 nBytesRead = 0;
+ try
+ {
+ nBytesRead = m_pPlugin->getPluginComm()->NPP_Write(
+ m_pPlugin->getNPPInstance(), &m_aNPStream, m_nWritePos, nBytes, pBuffer );
+ }
+ catch( ... )
+ {
+ nBytesRead = 0;
+ }
+ delete [] pBuffer;
+
+ if( nBytesRead < 0 )
+ {
+ m_nMode = -1;
+ return;
+ }
+
+ m_nWritePos += nBytesRead;
+ }
+}
+
+void PluginInputStream::closeOutput() throw()
+{
+ Guard< Mutex > aGuard( m_pPlugin->getMutex() );
+
+ flush();
+ m_xSource = uno::Reference< com::sun::star::io::XActiveDataSource >();
+}
+
+sal_uInt32 PluginInputStream::read( sal_uInt32 offset, sal_Int8* buffer, sal_uInt32 size )
+{
+ Guard< Mutex > aGuard( m_pPlugin->getMutex() );
+
+ if( m_nMode != NP_SEEK )
+ return 0;
+
+ m_aFileStream.Seek( offset );
+ return m_aFileStream.Read( buffer, size );
+}
+
+void PluginInputStream::flush(void) throw()
+{
+}
+
+PluginOutputStream::PluginOutputStream( XPlugin_Impl* pPlugin,
+ const char* url,
+ sal_uInt32 len,
+ sal_uInt32 lastmod ) :
+ PluginStream( pPlugin, url, len, lastmod ),
+ m_xStream( pPlugin->getServiceManager()->createInstance( OUString::createFromAscii( "com.sun.star.io.DataOutputStream" ) ), UNO_QUERY )
+{
+ Guard< Mutex > aGuard( m_pPlugin->getMutex() );
+
+ m_pPlugin->getOutputStreams().push_back( this );
+}
+
+PluginOutputStream::~PluginOutputStream()
+{
+ Guard< Mutex > aGuard( m_pPlugin->getMutex() );
+
+ m_pPlugin->getOutputStreams().remove( this );
+}
+
+PluginStreamType PluginOutputStream::getStreamType()
+{
+ return OutputStream;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/plugin/inc/plugin/aqua/sysplug.hxx b/extensions/source/plugin/inc/plugin/aqua/sysplug.hxx
new file mode 100644
index 000000000000..acabff40f123
--- /dev/null
+++ b/extensions/source/plugin/inc/plugin/aqua/sysplug.hxx
@@ -0,0 +1,169 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef __PLUGIN_INC_MACPLUG_HXX
+#define __PLUGIN_INC_MACPLUG_HXX
+
+#include <unistd.h>
+
+#include <list>
+#include <map>
+#include <algorithm>
+#include "premac.h"
+#include <Carbon/Carbon.h>
+#include <Security/cssmconfig.h>
+#include "postmac.h"
+#undef uint32
+
+#define XP_MAC
+#include "npsdk/npapi.h"
+#include "npsdk/npupp.h"
+
+#include "plugin/plcom.hxx"
+#include "premac.h"
+#include <Cocoa/Cocoa.h>
+#include "postmac.h"
+
+#include "vcl/sysdata.hxx"
+#include "vcl/threadex.hxx"
+#include "vcl/timer.hxx"
+#include "osl/module.h"
+
+class XPlugin_Impl;
+
+namespace plugstringhelper
+{
+rtl::OUString getString( CFStringRef i_xString );
+rtl::OUString getString( CFURLRef i_xURL );
+CFMutableStringRef createString( const rtl::OUString& i_rString );
+CFURLRef createURL( const rtl::OUString& i_rString );
+rtl::OUString getURLFromPath( const rtl::OUString& i_rPath );
+CFURLRef createURLFromPath( const rtl::OUString& i_rPath );
+rtl::OUString CFURLtoOSLURL( CFURLRef i_xURL );
+}
+
+//==================================================================================================
+class MacPluginComm :
+ public PluginComm,
+ public ::vcl::SolarThreadExecutor
+
+{
+ enum CallType {
+ eNPP_Destroy,
+ eNPP_DestroyStream,
+ eNPP_GetJavaClass,
+ eNPP_Initialize,
+ eNPP_New,
+ eNPP_NewStream,
+ eNPP_Print,
+ eNPP_SetWindow,
+ eNPP_Shutdown,
+ eNPP_StreamAsFile,
+ eNPP_URLNotify,
+ eNPP_Write,
+ eNPP_WriteReady,
+ eNPP_GetValue,
+ eNPP_SetValue,
+ eNPP_HandleEvent,
+ eNP_Initialize
+ };
+
+ void* m_aArgs[ 8 ];
+ CallType m_eCall;
+
+ virtual long doIt();
+public:
+ MacPluginComm( const rtl::OUString& rMIME, const rtl::OUString& rName, NSView* pView );
+ virtual ~MacPluginComm();
+
+ // FIXME:
+ // this actually should be from the NP headers
+ // but currently we have too old a version
+ // changes this when we have updated our headers
+ typedef struct NP_CGContext
+ {
+ CGContextRef context;
+ WindowRef window;
+ } NP_CGContext;
+
+public:
+ virtual NPError NPP_Destroy( NPP instance, NPSavedData** save );
+ virtual NPError NPP_DestroyStream( NPP instance, NPStream* stream, NPError reason );
+ virtual void * NPP_GetJavaClass();
+ virtual NPError NPP_Initialize();
+ virtual NPError NPP_New( NPMIMEType pluginType, NPP instance, uint16 mode, int16 argc,
+ char* argn[], char* argv[], NPSavedData *saved );
+ virtual NPError NPP_NewStream( NPP instance, NPMIMEType type, NPStream* stream,
+ NPBool seekable, uint16* stype );
+ virtual void NPP_Print( NPP instance, NPPrint* platformPrint );
+ virtual NPError NPP_SetWindow( NPP instance, NPWindow* window );
+ virtual void NPP_Shutdown();
+ virtual void NPP_StreamAsFile( NPP instance, NPStream* stream, const char* fname );
+ virtual void NPP_URLNotify( NPP instance, const char* url,
+ NPReason reason, void* notifyData );
+ virtual int32 NPP_Write( NPP instance, NPStream* stream, int32 offset,
+ int32 len, void* buffer );
+ virtual int32 NPP_WriteReady( NPP instance, NPStream* stream );
+ virtual NPError NPP_GetValue( NPP instance, NPPVariable variable, void *ret_value );
+ virtual NPError NPP_SetValue( NPP instance, NPNVariable variable, void *ret_value );
+ virtual int16 NPP_HandleEvent( NPP instance, void* event );
+
+ virtual NPError NPP_SetWindow( XPlugin_Impl* );
+ virtual NPError NPP_Destroy( XPlugin_Impl*, NPSavedData** save );
+
+ void drawView( XPlugin_Impl* );
+private:
+ BOOL retrieveFunction( const char* i_pName, void** i_ppFunc ) const;
+ DECL_LINK( NullTimerHdl, void* );
+
+private:
+ CFBundleRef m_xBundle;
+ oslModule m_hPlugLib;
+ NPPluginFuncs m_aNPPfuncs;
+
+ // timer for sending nullEvents
+ AutoTimer* m_pNullTimer;
+ std::list< XPlugin_Impl* > m_aNullEventClients;
+};
+
+struct SysPlugData
+{
+ MacPluginComm::NP_CGContext m_aCGContext;
+ NP_Port m_aNPPort;
+ NSView* m_pParentView;
+ NSView* m_pPlugView;
+ int m_nDrawingModel;
+ NSPoint m_aLastPlugViewOrigin;
+ bool m_bSetWindowOnDraw;
+};
+
+
+
+#endif
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/plugin/inc/plugin/impl.hxx b/extensions/source/plugin/inc/plugin/impl.hxx
new file mode 100644
index 000000000000..99bedc5da5ce
--- /dev/null
+++ b/extensions/source/plugin/inc/plugin/impl.hxx
@@ -0,0 +1,433 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef __PLUGIN_SOURCE_MGR_IMPL_HXX
+#define __PLUGIN_SOURCE_MGR_IMPL_HXX
+
+#ifdef SOLARIS
+#include <limits>
+#endif
+
+#include "cppuhelper/weak.hxx"
+
+#include "com/sun/star/awt/Key.hpp"
+#include "com/sun/star/awt/KeyFunction.hpp"
+#include "com/sun/star/beans/PropertyAttribute.hpp"
+#include "com/sun/star/plugin/PluginMode.hpp"
+#include "com/sun/star/plugin/PluginDescription.hpp"
+#include "com/sun/star/plugin/PluginException.hpp"
+#include "com/sun/star/plugin/PluginVariable.hpp"
+#include "com/sun/star/plugin/XPlugin.hpp"
+#include "com/sun/star/plugin/XPluginManager.hpp"
+#include "com/sun/star/plugin/XPluginContext.hpp"
+#include "com/sun/star/io/XConnectable.hpp"
+#include "com/sun/star/io/XOutputStream.hpp"
+#include "com/sun/star/io/XDataOutputStream.hpp"
+#include "com/sun/star/io/XActiveDataControl.hpp"
+#include "com/sun/star/io/XDataInputStream.hpp"
+#include "com/sun/star/io/XMarkableStream.hpp"
+#include "com/sun/star/io/XInputStream.hpp"
+#include "com/sun/star/io/XStreamListener.hpp"
+#include "com/sun/star/io/XActiveDataSink.hpp"
+#include "com/sun/star/io/XActiveDataSource.hpp"
+#include "com/sun/star/lang/XServiceName.hpp"
+#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/awt/GradientStyle.hpp"
+#include "com/sun/star/awt/RasterOperation.hpp"
+#include "com/sun/star/awt/Gradient.hpp"
+#include "com/sun/star/awt/XGraphics.hpp"
+
+#include "cppuhelper/implbase3.hxx"
+#include "cppuhelper/implbase2.hxx"
+#include "cppuhelper/implbase1.hxx"
+
+#include <list>
+
+#ifdef WNT
+#include "plugin/win/sysplug.hxx"
+#endif
+
+#ifdef WNT
+#include <plugin/win/sysplug.hxx>
+#elif defined(OS2)
+#include "plugin/os2/sysplug.hxx"
+#elif defined(QUARTZ)
+#include "plugin/aqua/sysplug.hxx"
+#elif defined(UNX)
+#include "plugin/unx/sysplug.hxx"
+#endif
+
+#if ! defined (QUARTZ)
+// the QUARTZ implementation needs special instance data
+typedef int SysPlugData;
+#endif
+
+#include "plugin/plctrl.hxx"
+#include "plugin/model.hxx"
+
+#include "vcl/sysdata.hxx"
+#include "vcl/syschild.hxx"
+
+#include "tools/link.hxx"
+#include "tools/stream.hxx"
+
+
+using namespace com::sun::star::uno;
+
+#define PROVIDING_NONE 0
+#define PROVIDING_NOW 1
+#define PROVIDING_MODEL_UPDATE 2
+
+// forwards
+namespace ucbhelper { class Content; }
+class PluginStream;
+class PluginInputStream;
+class PluginOutputStream;
+class XPlugin_Impl;
+class PluginDisposer;
+class PluginEventListener;
+
+class XPlugin_Impl : public com::sun::star::plugin::XPlugin,
+ public PluginControl_Impl,
+ public com::sun::star::beans::XPropertyChangeListener
+{
+private:
+ ::osl::Mutex m_aMutex;
+ Reference< com::sun::star::lang::XMultiServiceFactory > m_xSMgr;
+ Reference< com::sun::star::plugin::XPluginContext > m_rBrowserContext;
+
+ PluginComm* m_pPluginComm;
+ NPP_t m_aInstance;
+ NPWindow m_aNPWindow;
+ SysPlugData m_aSysPlugData;
+ rtl_TextEncoding m_aEncoding;
+
+ const char** m_pArgv;
+ const char** m_pArgn;
+ int m_nArgs;
+ rtl::OString m_aLastGetUrl;
+
+ Reference< com::sun::star::awt::XControlModel > m_xModel;
+
+ ::com::sun::star::plugin::PluginDescription m_aDescription;
+ sal_Int16 m_aPluginMode;
+
+ int m_nProvidingState;
+ int m_nCalledFromPlugin;
+ PluginDisposer* m_pDisposer;
+
+ ::std::list<PluginInputStream*> m_aInputStreams;
+ ::std::list<PluginOutputStream*> m_aOutputStreams;
+ ::std::list<PluginEventListener*> m_aPEventListeners;
+ ::rtl::OUString m_aURL;
+
+ sal_Bool m_bIsDisposed;
+
+ void prependArg( const char* pName, const char* pValue ); // arguments will be strdup'ed
+ void initArgs( const Sequence< rtl::OUString >& argn,
+ const Sequence< rtl::OUString >& argv,
+ sal_Int16 mode );
+ void freeArgs();
+ void handleSpecialArgs();
+
+ void loadPlugin();
+ void destroyInstance();
+ void modelChanged();
+
+public:
+ XPlugin_Impl( const Reference< com::sun::star::lang::XMultiServiceFactory > & rSMgr );
+ virtual ~XPlugin_Impl();
+
+ ::osl::Mutex& getMutex() { return m_aMutex; }
+
+ void destroyStreams();
+
+ void setLastGetUrl( const rtl::OString& rUrl ) { m_aLastGetUrl = rUrl; }
+
+ com::sun::star::plugin::PluginDescription fitDescription( const rtl::OUString& rURL );
+
+ ::std::list<PluginInputStream*>& getInputStreams() { return m_aInputStreams; }
+ ::std::list<PluginOutputStream*>& getOutputStreams() { return m_aOutputStreams; }
+ PluginComm* getPluginComm() { return m_pPluginComm; }
+ void setPluginComm( PluginComm* comm )
+ {
+ if( ! m_pPluginComm )
+ {
+ m_pPluginComm = comm;
+ m_pPluginComm->addRef();
+ }
+ }
+ Reference< com::sun::star::lang::XMultiServiceFactory > getServiceManager() { return m_xSMgr; }
+ const com::sun::star::plugin::PluginDescription& getDescription() const { return m_aDescription; }
+ rtl_TextEncoding getTextEncoding() { return m_aEncoding; }
+ NPP getNPPInstance() { return &m_aInstance; }
+ NPWindow* getNPWindow() { return &m_aNPWindow; }
+ SysPlugData& getSysPlugData() { return m_aSysPlugData; }
+
+ void enterPluginCallback() { m_nCalledFromPlugin++; }
+ void leavePluginCallback() { m_nCalledFromPlugin--; }
+ sal_Bool isDisposable() { return m_nCalledFromPlugin < 1 ? sal_True : sal_False; }
+ DECL_LINK( secondLevelDispose, XPlugin_Impl* );
+
+ void addPluginEventListener( PluginEventListener* pListener )
+ { m_aPEventListeners.push_back( pListener ); }
+ void checkListeners( const char* normalizedURL );
+
+ void initInstance(
+ const com::sun::star::plugin::PluginDescription& rDescription,
+ const Sequence< rtl::OUString >& argn,
+ const Sequence< rtl::OUString >& argv,
+ sal_Int16 mode );
+ void initInstance(
+ const rtl::OUString& rURL,
+ const Sequence< rtl::OUString >& argn,
+ const Sequence< rtl::OUString >& argv,
+ sal_Int16 mode );
+
+ const rtl::OUString& getRefererURL() { return m_aURL; }
+ ::rtl::OUString getCreationURL();
+
+ PluginStream* getStreamFromNPStream( NPStream* );
+
+ const SystemEnvData* getSysChildSysData()
+ { return _pSysChild->GetSystemData(); }
+
+ const Reference< com::sun::star::plugin::XPluginContext > & getPluginContext() const
+ { return m_rBrowserContext; }
+ void setPluginContext( const Reference< com::sun::star::plugin::XPluginContext > & );
+
+ void secondLevelDispose();
+
+// static const Reference< com::sun::star::reflection::XIdlClass > & staticGetIdlClass();
+
+ // XInterface
+ virtual Any SAL_CALL queryInterface( const Type& ) throw( com::sun::star::uno::RuntimeException );
+ virtual void SAL_CALL acquire() throw()
+ { OWeakAggObject::acquire(); }
+ virtual void SAL_CALL release() throw()
+ { OWeakAggObject::release(); }
+
+ // OWeakAggObject
+ virtual Any SAL_CALL queryAggregation( const Type& )
+ throw( com::sun::star::uno::RuntimeException );
+
+ // PluginContol_Impl
+ virtual void SAL_CALL dispose() throw();
+ virtual void SAL_CALL createPeer( const Reference< com::sun::star::awt::XToolkit > & xToolkit, const Reference< com::sun::star::awt::XWindowPeer > & Parent) throw( RuntimeException );
+
+ virtual sal_Bool SAL_CALL setModel( const Reference< com::sun::star::awt::XControlModel > & Model ) throw( RuntimeException );
+ virtual Reference< com::sun::star::awt::XControlModel > SAL_CALL getModel()throw( RuntimeException )
+ { return m_xModel; }
+
+ virtual void SAL_CALL setPosSize( sal_Int32 nX_, sal_Int32 nY_, sal_Int32 nWidth_, sal_Int32 nHeight_, sal_Int16 nFlags ) throw( RuntimeException );
+
+ // com::sun::star::plugin::XPlugin
+ virtual sal_Bool SAL_CALL provideNewStream(const rtl::OUString& mimetype, const Reference< com::sun::star::io::XActiveDataSource > & stream, const rtl::OUString& url, sal_Int32 length, sal_Int32 lastmodified, sal_Bool isfile) throw();
+
+ // com::sun::star::beans::XPropertyChangeListener
+ virtual void SAL_CALL disposing( const com::sun::star::lang::EventObject& rSource ) throw();
+ virtual void SAL_CALL propertyChange( const com::sun::star::beans::PropertyChangeEvent& rEvent ) throw();
+};
+
+class PluginManager
+{
+private:
+ Reference< com::sun::star::lang::XMultiServiceFactory > m_xSMgr;
+ ::std::list<PluginComm*> m_aPluginComms;
+ ::std::list<XPlugin_Impl*> m_aAllPlugins;
+ ::osl::Mutex m_aPluginMutex;
+
+ static PluginManager* pManager;
+
+ PluginManager();
+public:
+
+ static PluginManager& get();
+ static void setServiceFactory( const Reference< com::sun::star::lang::XMultiServiceFactory >& xFactory );
+ static const Sequence< rtl::OUString >& getAdditionalSearchPaths();
+
+ ::std::list<PluginComm*>& getPluginComms() { return m_aPluginComms; }
+ ::std::list<XPlugin_Impl*>& getPlugins() { return m_aAllPlugins; }
+ ::osl::Mutex& getPluginMutex() { return m_aPluginMutex; }
+};
+
+class XPluginManager_Impl :
+ public cppu::WeakAggImplHelper1< com::sun::star::plugin::XPluginManager >
+{
+ Reference< com::sun::star::lang::XMultiServiceFactory > m_xSMgr;
+public:
+ XPluginManager_Impl( const Reference< com::sun::star::lang::XMultiServiceFactory > & );
+ virtual ~XPluginManager_Impl();
+
+ static XPlugin_Impl* getXPluginFromNPP( NPP );
+ static XPlugin_Impl* getPluginImplementation( const Reference< com::sun::star::plugin::XPlugin >& plugin );
+
+ virtual Reference< com::sun::star::plugin::XPluginContext > SAL_CALL createPluginContext() throw();
+
+ // has to be implemented per system
+ virtual Sequence< com::sun::star::plugin::PluginDescription > SAL_CALL impl_getPluginDescriptions(void) throw();
+ // calls system specific impl_getPluginDescriptions
+ // checks whether plugins are disabled
+ virtual Sequence< com::sun::star::plugin::PluginDescription > SAL_CALL getPluginDescriptions(void) throw();
+
+ virtual Reference< com::sun::star::plugin::XPlugin > SAL_CALL createPlugin( const Reference< com::sun::star::plugin::XPluginContext > & acontext, sal_Int16 mode, const Sequence< rtl::OUString >& argn, const Sequence< rtl::OUString >& argv, const com::sun::star::plugin::PluginDescription& plugintype) throw( RuntimeException,::com::sun::star::plugin::PluginException );
+
+ virtual Reference< com::sun::star::plugin::XPlugin > SAL_CALL createPluginFromURL( const Reference< com::sun::star::plugin::XPluginContext > & acontext, sal_Int16 mode, const Sequence< rtl::OUString >& argn, const Sequence< rtl::OUString >& argv, const Reference< com::sun::star::awt::XToolkit > & toolkit, const Reference< com::sun::star::awt::XWindowPeer > & parent, const rtl::OUString& url ) throw();
+
+ virtual sal_Bool SAL_CALL supportsService(const rtl::OUString& ServiceName) throw();
+ virtual rtl::OUString SAL_CALL getImplementationName() throw();
+
+ Sequence< rtl::OUString > SAL_CALL getSupportedServiceNames(void) throw( );
+ static Sequence< rtl::OUString > getSupportedServiceNames_Static(void) throw( );
+ static rtl::OUString getImplementationName_Static() throw( )
+ {
+ /** the soplayer uses this name in its source! maybe not after 5.2 */
+ return rtl::OUString::createFromAscii( "com.sun.star.extensions.PluginManager" );
+ }
+};
+Reference< XInterface > SAL_CALL PluginManager_CreateInstance( const Reference< com::sun::star::lang::XMultiServiceFactory > & ) throw( Exception );
+
+enum PluginStreamType { InputStream, OutputStream };
+
+class PluginStream
+{
+protected:
+ XPlugin_Impl* m_pPlugin;
+ NPStream m_aNPStream;
+public:
+ PluginStream( XPlugin_Impl* pPlugin,
+ const char* url, sal_uInt32 len, sal_uInt32 lastmod );
+ virtual ~PluginStream();
+
+ NPStream* getStream() { return &m_aNPStream; }
+ XPlugin_Impl* getPlugin() { return m_pPlugin; }
+
+ virtual PluginStreamType getStreamType() = 0;
+};
+
+class PluginInputStream :
+ public PluginStream,
+ public cppu::WeakAggImplHelper2<
+ ::com::sun::star::io::XOutputStream,
+ ::com::sun::star::io::XConnectable
+ >
+{
+private:
+ ::ucbhelper::Content* m_pContent;
+ sal_Int32 m_nMode;
+ UINT32 m_nWritePos;
+
+ Reference< com::sun::star::io::XActiveDataSource > m_xSource;
+ // hold a reference on input until closeOutput is called
+
+ Reference< com::sun::star::io::XConnectable > m_xPredecessor;
+ Reference< com::sun::star::io::XConnectable > m_xSuccessor;
+
+ // needed to hold a reference to self in NP_SEEK mode
+ Reference< com::sun::star::io::XOutputStream > m_xSelf;
+
+ SvFileStream m_aFileStream;
+public:
+ PluginInputStream( XPlugin_Impl* pPlugin,
+ const char* url, UINT32 len, UINT32 lastmod );
+
+ PluginInputStream() : PluginStream( NULL, NULL, 0, 0 ) {}
+
+ virtual ~PluginInputStream();
+
+ virtual PluginStreamType getStreamType();
+
+ void setMode( sal_Int32 nMode );
+ UINT32 read( UINT32 offset, sal_Int8* buffer, UINT32 size );
+ void setSource( const Reference< com::sun::star::io::XActiveDataSource >& xSource ) { m_xSource = xSource; }
+ // get contents ot url via ucbhelper::Content
+ void load();
+
+ // clear reference
+ bool releaseSelf()
+ { bool bRet = m_xSelf.is(); m_xSelf.clear(); return bRet; }
+
+ // XOutputStream
+ virtual void SAL_CALL writeBytes( const Sequence<sal_Int8>& ) throw();
+ virtual void SAL_CALL flush() throw();
+ virtual void SAL_CALL closeOutput() throw();
+
+ // XConnectable
+ virtual void SAL_CALL setPredecessor( const Reference< com::sun::star::io::XConnectable >& xPredecessor ) throw()
+ { m_xPredecessor = xPredecessor; }
+ virtual Reference< com::sun::star::io::XConnectable > SAL_CALL getPredecessor() throw()
+ { return m_xPredecessor; }
+
+ virtual void SAL_CALL setSuccessor( const Reference< com::sun::star::io::XConnectable >& xSuccessor ) throw()
+ { m_xSuccessor = xSuccessor; }
+ virtual Reference< com::sun::star::io::XConnectable > SAL_CALL getSuccessor() throw()
+ { return m_xSuccessor; }
+};
+
+class PluginOutputStream : public PluginStream
+{
+private:
+ Reference< com::sun::star::io::XOutputStream > m_xStream;
+public:
+ PluginOutputStream( XPlugin_Impl* pPlugin, const char* url,
+ sal_uInt32 len, sal_uInt32 lastmod );
+ virtual ~PluginOutputStream();
+
+ virtual PluginStreamType getStreamType();
+
+ Reference< com::sun::star::io::XOutputStream > & getOutputStream() { return m_xStream; }
+};
+
+class PluginEventListener :
+ public cppu::WeakAggImplHelper1< com::sun::star::lang::XEventListener >
+{
+private:
+ XPlugin_Impl* m_pPlugin;
+ Reference< com::sun::star::plugin::XPlugin > m_xPlugin; // just to hold the plugin
+ char* m_pUrl;
+ char* m_pNormalizedUrl;
+ void* m_pNotifyData;
+public:
+ PluginEventListener( XPlugin_Impl*,
+ const char* url,
+ const char* normurl,
+ void* notifyData );
+ virtual ~PluginEventListener();
+
+ const char* getURL() { return m_pUrl; }
+ const char* getNormalizedURL() { return m_pNormalizedUrl; }
+ void* getNotifyData() { return m_pNotifyData; }
+
+ // com::sun::star::lang::XEventListener
+ virtual void SAL_CALL disposing( const com::sun::star::lang::EventObject& Source ) throw();
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/plugin/inc/plugin/model.hxx b/extensions/source/plugin/inc/plugin/model.hxx
new file mode 100644
index 000000000000..91dfea02e32f
--- /dev/null
+++ b/extensions/source/plugin/inc/plugin/model.hxx
@@ -0,0 +1,139 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef __PLUGIN_MODEL_HXX
+#define __PLUGIN_MODEL_HXX
+
+#include <com/sun/star/io/XObjectInputStream.hpp>
+#include <com/sun/star/io/XPersistObject.hpp>
+#include <com/sun/star/io/XObjectOutputStream.hpp>
+#include <com/sun/star/lang/XServiceName.hpp>
+#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/awt/XControlModel.hpp>
+#include <com/sun/star/awt/XControl.hpp>
+
+#include <cppuhelper/propshlp.hxx>
+#include <cppuhelper/weakagg.hxx>
+#include <rtl/alloc.h>
+
+#include <list>
+
+using namespace com::sun::star::uno;
+
+class BroadcasterHelperHolder
+{
+protected:
+ ::cppu::OBroadcastHelper m_aHelper;
+public:
+ BroadcasterHelperHolder( osl::Mutex& rMutex ) :
+ m_aHelper( rMutex ) {}
+ ~BroadcasterHelperHolder() {}
+
+ ::cppu::OBroadcastHelper& getHelper() { return m_aHelper; }
+
+};
+
+class PluginModel : public BroadcasterHelperHolder,
+ public cppu::OPropertySetHelper,
+ public cppu::OPropertyArrayHelper,
+ public cppu::OWeakAggObject,
+ public com::sun::star::lang::XComponent,
+ public com::sun::star::io::XPersistObject,
+ public com::sun::star::awt::XControlModel
+{
+ private:
+ rtl::OUString m_aCreationURL;
+ rtl::OUString m_aMimeType;
+
+ std::list< Reference< com::sun::star::lang::XEventListener > >
+ m_aDisposeListeners;
+ 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 ); }
+
+ PluginModel();
+ PluginModel( const rtl::OUString& rURL, const rtl::OUString& rMimeType );
+ virtual ~PluginModel();
+
+
+ const rtl::OUString& getCreationURL() { return m_aCreationURL; }
+ void setMimeType( const rtl::OUString& rMime ) { m_aMimeType = rMime; }
+
+ // XInterface
+ virtual Any SAL_CALL queryInterface( const Type& rType ) throw( com::sun::star::uno::RuntimeException )
+ { return OWeakAggObject::queryInterface( rType ); }
+ virtual void SAL_CALL acquire() throw()
+ { OWeakAggObject::acquire(); }
+ virtual void SAL_CALL release() throw()
+ { OWeakAggObject::release(); }
+
+ virtual Any SAL_CALL queryAggregation( const Type& ) throw( com::sun::star::uno::RuntimeException );
+
+
+ // com::sun::star::lang::XTypeProvider
+
+ static Sequence< rtl::OUString > SAL_CALL getSupportedServiceNames_Static(void) throw( );
+ static rtl::OUString SAL_CALL getImplementationName_Static() throw( )
+ {
+ /** the soplayer uses this name in its source! maybe not after 5.2 */
+ return rtl::OUString::createFromAscii( "com.sun.star.extensions.PluginModel" );
+ }
+
+ // OPropertySetHelper
+ virtual cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper();
+ virtual sal_Bool SAL_CALL convertFastPropertyValue( Any & rConvertedValue,
+ Any & rOldValue,
+ sal_Int32 nHandle,
+ const Any& rValue ) throw();
+ virtual void SAL_CALL setFastPropertyValue_NoBroadcast( sal_Int32 nHandle,
+ const Any& rValue )
+ throw(::com::sun::star::uno::Exception);
+ virtual void SAL_CALL getFastPropertyValue( Any& rValue, sal_Int32 nHandle ) const throw();
+ virtual Reference< com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() throw();
+
+ // com::sun::star::io::XPersistObject
+ virtual rtl::OUString SAL_CALL getServiceName() throw();
+ virtual void SAL_CALL write(const Reference< com::sun::star::io::XObjectOutputStream > & OutStream) throw();
+ virtual void SAL_CALL read(const Reference< com::sun::star::io::XObjectInputStream > & InStream) throw();
+
+ // com::sun::star::lang::XComponent
+ virtual void SAL_CALL addEventListener( const Reference< com::sun::star::lang::XEventListener > & l ) throw();
+ virtual void SAL_CALL removeEventListener( const Reference< com::sun::star::lang::XEventListener > & l ) throw();
+ virtual void SAL_CALL dispose() throw();
+ private:
+ using cppu::OPropertySetHelper::getFastPropertyValue;
+};
+Reference< XInterface > SAL_CALL PluginModel_CreateInstance( const Reference< com::sun::star::lang::XMultiServiceFactory > & ) throw( Exception );
+
+#endif // __PLUGIN_MODEL_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/plugin/inc/plugin/multiplx.hxx b/extensions/source/plugin/inc/plugin/multiplx.hxx
new file mode 100644
index 000000000000..4544304b785e
--- /dev/null
+++ b/extensions/source/plugin/inc/plugin/multiplx.hxx
@@ -0,0 +1,169 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef _MRC_MULTIPLX_HXX
+#define _MRC_MULTIPLX_HXX
+
+#include <com/sun/star/awt/XControl.hpp>
+#include <com/sun/star/awt/XKeyListener.hpp>
+#include <com/sun/star/awt/XPaintListener.hpp>
+#include <com/sun/star/awt/KeyEvent.hpp>
+#include <com/sun/star/awt/KeyModifier.hpp>
+#include <com/sun/star/awt/XMouseMotionListener.hpp>
+#include <com/sun/star/awt/FocusEvent.hpp>
+#include <com/sun/star/awt/XWindowListener.hpp>
+#include <com/sun/star/awt/XActivateListener.hpp>
+#include <com/sun/star/awt/MouseEvent.hpp>
+#include <com/sun/star/awt/XTopWindowListener.hpp>
+#include <com/sun/star/awt/PaintEvent.hpp>
+#include <com/sun/star/awt/InputEvent.hpp>
+#include <com/sun/star/awt/KeyGroup.hpp>
+#include <com/sun/star/awt/Key.hpp>
+#include <com/sun/star/awt/WindowEvent.hpp>
+#include <com/sun/star/awt/XMouseListener.hpp>
+#include <com/sun/star/awt/KeyFunction.hpp>
+#include <com/sun/star/awt/FocusChangeReason.hpp>
+#include <com/sun/star/awt/MouseButton.hpp>
+#include <com/sun/star/awt/XFocusListener.hpp>
+#include <com/sun/star/awt/XTopWindow.hpp>
+#include <com/sun/star/awt/XWindow.hpp>
+#include <com/sun/star/awt/PosSize.hpp>
+
+#include <cppuhelper/implbase7.hxx>
+#include <cppuhelper/interfacecontainer.hxx>
+
+using namespace com::sun::star::uno;
+
+struct MRCListenerMultiplexerHelper_Mutex
+{
+ ::osl::Mutex aMutex;
+};
+
+class MRCListenerMultiplexerHelper :
+ public MRCListenerMultiplexerHelper_Mutex,
+
+ public ::cppu::WeakAggImplHelper7<
+ ::com::sun::star::awt::XFocusListener,
+ ::com::sun::star::awt::XWindowListener,
+ ::com::sun::star::awt::XKeyListener,
+ ::com::sun::star::awt::XMouseListener,
+ ::com::sun::star::awt::XMouseMotionListener,
+ ::com::sun::star::awt::XPaintListener,
+ ::com::sun::star::awt::XTopWindowListener >
+{
+public:
+ /**
+ * Create a Multiplexer of XWindowEvents.
+ *
+ * @param rControl The control. All listeners think that this is the original
+ * broadcaster.
+ * @param rPeer The peer from which the original events are dispatched. Null is
+ * allowed.
+ */
+ MRCListenerMultiplexerHelper( const Reference< ::com::sun::star::awt::XWindow > & rControl, const Reference< ::com::sun::star::awt::XWindow > & rPeer );
+
+ /**
+ * Remove all listeners from the previous set peer and add the needed listeners to rPeer.
+ * @param rPeer The peer from which the original events are dispatched. Null is
+ * allowed.
+ */
+ void setPeer( const Reference< ::com::sun::star::awt::XWindow > & rPeer );
+
+ /**
+ * Remove all listeners and send a disposing message.
+ */
+ void disposeAndClear();
+
+ /**
+ * Add the specified listener to the source.
+ */
+ void advise( const Type& type, const Reference< XInterface > & listener);
+ /**
+ * Remove the specified listener from the source.
+ */
+ void unadvise(const Type& type, const Reference< XInterface > & listener);
+
+ // ::com::sun::star::lang::XEventListener
+ void SAL_CALL disposing(const ::com::sun::star::lang::EventObject& Source) throw();
+ // ::com::sun::star::awt::XFocusListener
+ void SAL_CALL focusGained(const ::com::sun::star::awt::FocusEvent& e) throw();
+ void SAL_CALL focusLost(const ::com::sun::star::awt::FocusEvent& e) throw();
+ // ::com::sun::star::awt::XWindowListener
+ void SAL_CALL windowResized(const ::com::sun::star::awt::WindowEvent& e) throw();
+ void SAL_CALL windowMoved(const ::com::sun::star::awt::WindowEvent& e) throw();
+ void SAL_CALL windowShown(const ::com::sun::star::lang::EventObject& e) throw();
+ void SAL_CALL windowHidden(const ::com::sun::star::lang::EventObject& e) throw();
+ // ::com::sun::star::awt::XKeyListener
+ void SAL_CALL keyPressed( const ::com::sun::star::awt::KeyEvent& e ) throw();
+ void SAL_CALL keyReleased( const ::com::sun::star::awt::KeyEvent& e ) throw();
+ // ::com::sun::star::awt::XMouseListener
+ void SAL_CALL mousePressed(const ::com::sun::star::awt::MouseEvent& e) throw();
+ void SAL_CALL mouseReleased(const ::com::sun::star::awt::MouseEvent& e) throw();
+ void SAL_CALL mouseEntered(const ::com::sun::star::awt::MouseEvent& e) throw();
+ void SAL_CALL mouseExited(const ::com::sun::star::awt::MouseEvent& e) throw();
+ // ::com::sun::star::awt::XMouseMotionListener
+ void SAL_CALL mouseDragged(const ::com::sun::star::awt::MouseEvent& e) throw();
+ void SAL_CALL mouseMoved(const ::com::sun::star::awt::MouseEvent& e) throw();
+ // ::com::sun::star::awt::XPaintListener
+ void SAL_CALL windowPaint(const ::com::sun::star::awt::PaintEvent& e) throw();
+ // ::com::sun::star::awt::XTopWindowListener
+ void SAL_CALL windowOpened( const ::com::sun::star::lang::EventObject& e ) throw();
+ void SAL_CALL windowClosing( const ::com::sun::star::lang::EventObject& e ) throw();
+ void SAL_CALL windowClosed( const ::com::sun::star::lang::EventObject& e ) throw();
+ void SAL_CALL windowMinimized( const ::com::sun::star::lang::EventObject& e ) throw();
+ void SAL_CALL windowNormalized( const ::com::sun::star::lang::EventObject& e ) throw();
+ void SAL_CALL windowActivated( const ::com::sun::star::lang::EventObject& e ) throw();
+ void SAL_CALL windowDeactivated( const ::com::sun::star::lang::EventObject& e ) throw();
+protected:
+ /**
+ * Remove the listener with the uik rUik from the peer rPeer.
+ * @param rPeer the peer from which the listener is removed.
+ * @param rUik the listener uik, which specify the type of the listener.
+ */
+ void adviseToPeer( const Reference< ::com::sun::star::awt::XWindow > & rPeer, const Type & type );
+ /**
+ * Add the listener with the uik rUik to the peer rPeer.
+ * @param rPeer the peer to which the listener is added.
+ * @param rUik the listener uik, which specify the type of the listener.
+ */
+ void unadviseFromPeer( const Reference< ::com::sun::star::awt::XWindow > & rPeer, const Type & type );
+private:
+ /** The source of the events. Normally this is the peer object.*/
+ Reference< ::com::sun::star::awt::XWindow > xPeer;
+ WeakReference< ::com::sun::star::awt::XControl > xControl;
+ ::cppu::OMultiTypeInterfaceContainerHelper aListenerHolder;
+
+
+ MRCListenerMultiplexerHelper( const MRCListenerMultiplexerHelper & );
+ MRCListenerMultiplexerHelper & operator = ( const MRCListenerMultiplexerHelper & );
+};
+
+#endif // _MRC_MULTIPLX_HXX
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/plugin/inc/plugin/plcom.hxx b/extensions/source/plugin/inc/plugin/plcom.hxx
new file mode 100644
index 000000000000..8775a8450e16
--- /dev/null
+++ b/extensions/source/plugin/inc/plugin/plcom.hxx
@@ -0,0 +1,88 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef __PLUGIN_INC_PLCOM_HXX
+#define __PLUGIN_INC_PLCOM_HXX
+
+#include <tools/string.hxx>
+#include <list>
+
+class XPlugin_Impl;
+
+class PluginComm
+{
+protected:
+ int m_nRefCount;
+ ::rtl::OString m_aLibName;
+ std::list< String > m_aFilesToDelete;
+public:
+ PluginComm( const ::rtl::OString& rLibName, bool bReusable = true );
+ virtual ~PluginComm();
+
+ int getRefCount() { return m_nRefCount; }
+ void addRef() { m_nRefCount++; }
+ void decRef() { m_nRefCount--; if( ! m_nRefCount ) delete this; }
+
+ const ::rtl::OString& getLibName() { return m_aLibName; }
+ void setLibName( const ::rtl::OString& rName ) { m_aLibName = rName; }
+
+ void addFileToDelete( const String& filename )
+ { m_aFilesToDelete.push_back( filename ); }
+
+ virtual NPError NPP_Destroy( NPP instance, NPSavedData** save ) = 0;
+ virtual NPError NPP_DestroyStream( NPP instance, NPStream* stream,
+ NPError reason ) = 0;
+ virtual void* NPP_GetJavaClass() = 0;
+ virtual NPError NPP_Initialize() = 0;
+ virtual NPError NPP_New( NPMIMEType pluginType, NPP instance,
+ uint16 mode, int16 argc,
+ char* argn[], char* argv[],
+ NPSavedData *saved ) = 0;
+ virtual NPError NPP_NewStream( NPP instance, NPMIMEType type,
+ NPStream* stream,
+ NPBool seekable, uint16* stype ) = 0;
+ virtual void NPP_Print( NPP instance, NPPrint* platformPrint ) = 0;
+ virtual NPError NPP_SetWindow( NPP instance, NPWindow* window ) = 0;
+ virtual void NPP_Shutdown() = 0;
+ virtual void NPP_StreamAsFile( NPP instance, NPStream* stream,
+ const char* fname ) = 0;
+ virtual void NPP_URLNotify( NPP instance, const char* url,
+ NPReason reason, void* notifyData ) = 0;
+ virtual int32 NPP_Write( NPP instance, NPStream* stream, int32 offset,
+ int32 len, void* buffer ) = 0;
+ virtual int32 NPP_WriteReady( NPP instance, NPStream* stream ) = 0;
+ virtual NPError NPP_GetValue( NPP instance, NPPVariable variable, void* value ) = 0;
+ virtual NPError NPP_SetValue( NPP instance, NPNVariable variable,
+ void *value) = 0;
+
+ virtual NPError NPP_SetWindow( XPlugin_Impl* );
+ virtual NPError NPP_Destroy( XPlugin_Impl*, NPSavedData** save );
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/plugin/inc/plugin/plctrl.hxx b/extensions/source/plugin/inc/plugin/plctrl.hxx
new file mode 100644
index 000000000000..c98199213512
--- /dev/null
+++ b/extensions/source/plugin/inc/plugin/plctrl.hxx
@@ -0,0 +1,183 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef __PLCTRL_HXX
+#define __PLCTRL_HXX
+
+#include <tools/debug.hxx>
+
+#include <cppuhelper/weak.hxx>
+#include <plugin/multiplx.hxx>
+#include <com/sun/star/beans/PropertyValues.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/beans/PropertyValue.hpp>
+#include <com/sun/star/beans/PropertyState.hpp>
+#include <com/sun/star/beans/XPropertySetInfo.hpp>
+#include <com/sun/star/beans/XMultiPropertySet.hpp>
+#include <com/sun/star/beans/XFastPropertySet.hpp>
+#include <com/sun/star/beans/XVetoableChangeListener.hpp>
+#include <com/sun/star/beans/XPropertyState.hpp>
+#include <com/sun/star/beans/XPropertyStateChangeListener.hpp>
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+#include <com/sun/star/beans/XPropertiesChangeListener.hpp>
+#include <com/sun/star/beans/XPropertyChangeListener.hpp>
+#include <com/sun/star/beans/XPropertyAccess.hpp>
+#include <com/sun/star/beans/XPropertyContainer.hpp>
+#include <com/sun/star/beans/PropertyStateChangeEvent.hpp>
+#include <com/sun/star/beans/PropertyChangeEvent.hpp>
+#include <com/sun/star/awt/XVclContainerPeer.hpp>
+#include <com/sun/star/awt/XVclWindowPeer.hpp>
+#include <com/sun/star/awt/XControlModel.hpp>
+#include <com/sun/star/awt/XUnoControlContainer.hpp>
+#include <com/sun/star/awt/XControlContainer.hpp>
+#include <com/sun/star/awt/VclWindowPeerAttribute.hpp>
+#include <com/sun/star/awt/XVclContainer.hpp>
+#include <com/sun/star/awt/XControl.hpp>
+#include <com/sun/star/awt/XTopWindow.hpp>
+#include <com/sun/star/awt/XWindow.hpp>
+#include <com/sun/star/awt/PosSize.hpp>
+
+#include <cppuhelper/implbase4.hxx>
+
+#include <list>
+
+class SystemChildWindow;
+
+//==================================================================================================
+class PluginControl_Impl : public ::cppu::WeakAggImplHelper4<
+ ::com::sun::star::awt::XControl,
+ ::com::sun::star::awt::XWindow,
+ ::com::sun::star::awt::XFocusListener,
+ ::com::sun::star::awt::XView >
+{
+public:
+ // ::com::sun::star::awt::XControl
+ virtual void SAL_CALL setContext( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > & xContext ) throw( ::com::sun::star::uno::RuntimeException )
+ { _xContext = xContext; }
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL getContext() throw( ::com::sun::star::uno::RuntimeException )
+ { return _xContext; }
+
+ virtual sal_Bool SAL_CALL setModel( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel > & Model ) throw( ::com::sun::star::uno::RuntimeException ) = 0;
+// { DBG_ERROR( "### setModel() illegal on plugincontrol!" ); return sal_False; }
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel > SAL_CALL getModel() throw( ::com::sun::star::uno::RuntimeException ) = 0;
+
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::XView > SAL_CALL getView() throw( ::com::sun::star::uno::RuntimeException )
+ { return (::com::sun::star::awt::XView*)this; }
+
+ virtual sal_Bool SAL_CALL isTransparent() throw( ::com::sun::star::uno::RuntimeException )
+ { return sal_False; }
+
+ virtual void SAL_CALL setDesignMode( sal_Bool bOn ) throw( ::com::sun::star::uno::RuntimeException );
+ virtual sal_Bool SAL_CALL isDesignMode() throw( ::com::sun::star::uno::RuntimeException )
+ { return _bInDesignMode; }
+
+ virtual void SAL_CALL createPeer( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XToolkit > & xToolkit, const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer > & Parent) throw( ::com::sun::star::uno::RuntimeException );
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer > SAL_CALL getPeer() throw( ::com::sun::star::uno::RuntimeException )
+ { return _xPeer; }
+
+ // ::com::sun::star::awt::XWindow
+ virtual void SAL_CALL setVisible( sal_Bool bVisible ) throw( ::com::sun::star::uno::RuntimeException );
+ virtual void SAL_CALL setEnable( sal_Bool bEnable ) throw( ::com::sun::star::uno::RuntimeException );
+ virtual void SAL_CALL setFocus(void) throw( ::com::sun::star::uno::RuntimeException );
+
+ virtual void SAL_CALL setPosSize( sal_Int32 nX_, sal_Int32 nY_, sal_Int32 nWidth_, sal_Int32 nHeight_, sal_Int16 nFlags ) throw( ::com::sun::star::uno::RuntimeException );
+ virtual ::com::sun::star::awt::Rectangle SAL_CALL getPosSize(void) throw( ::com::sun::star::uno::RuntimeException );
+
+ virtual void SAL_CALL addWindowListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowListener > & l ) throw( ::com::sun::star::uno::RuntimeException );
+ virtual void SAL_CALL removeWindowListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowListener > & l ) throw( ::com::sun::star::uno::RuntimeException );
+ virtual void SAL_CALL addFocusListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XFocusListener > & l ) throw( ::com::sun::star::uno::RuntimeException );
+ virtual void SAL_CALL removeFocusListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XFocusListener > & l ) throw( ::com::sun::star::uno::RuntimeException );
+ virtual void SAL_CALL addKeyListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XKeyListener > & l ) throw( ::com::sun::star::uno::RuntimeException );
+ virtual void SAL_CALL removeKeyListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XKeyListener > & l ) throw( ::com::sun::star::uno::RuntimeException );
+ virtual void SAL_CALL addMouseListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XMouseListener > & l ) throw( ::com::sun::star::uno::RuntimeException );
+ virtual void SAL_CALL removeMouseListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XMouseListener > & l ) throw( ::com::sun::star::uno::RuntimeException );
+ virtual void SAL_CALL addMouseMotionListener( const Reference< ::com::sun::star::awt::XMouseMotionListener > & l ) throw( RuntimeException );
+ virtual void SAL_CALL removeMouseMotionListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XMouseMotionListener > & l ) throw( ::com::sun::star::uno::RuntimeException );
+ virtual void SAL_CALL addPaintListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XPaintListener > & l ) throw( ::com::sun::star::uno::RuntimeException );
+ virtual void SAL_CALL removePaintListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XPaintListener > & l ) throw( ::com::sun::star::uno::RuntimeException );
+
+ // ::com::sun::star::lang::XEventListener
+ virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject & rSource ) throw( ::com::sun::star::uno::RuntimeException );
+ // ::com::sun::star::awt::XFocusListener
+ virtual void SAL_CALL focusGained( const ::com::sun::star::awt::FocusEvent & rEvt ) throw( ::com::sun::star::uno::RuntimeException );
+ virtual void SAL_CALL focusLost( const ::com::sun::star::awt::FocusEvent & rEvt ) throw( ::com::sun::star::uno::RuntimeException );
+
+ // ::com::sun::star::lang::XComponent
+ virtual void SAL_CALL addEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > & l ) throw( ::com::sun::star::uno::RuntimeException );
+ virtual void SAL_CALL removeEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > & l ) throw( ::com::sun::star::uno::RuntimeException );
+
+ virtual void SAL_CALL dispose() throw( ::com::sun::star::uno::RuntimeException );
+
+ // ::com::sun::star::awt::XView
+ virtual sal_Bool SAL_CALL setGraphics( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XGraphics > & /*aDevice*/ ) throw( ::com::sun::star::uno::RuntimeException )
+ { return sal_False; }
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::XGraphics > SAL_CALL getGraphics(void) throw( ::com::sun::star::uno::RuntimeException )
+ { return ::com::sun::star::uno::Reference< ::com::sun::star::awt::XGraphics > (); }
+
+ virtual ::com::sun::star::awt::Size SAL_CALL getSize(void) throw( ::com::sun::star::uno::RuntimeException )
+ { return ::com::sun::star::awt::Size(_nWidth, _nHeight); }
+
+ virtual void SAL_CALL draw( sal_Int32 x, sal_Int32 y ) throw( ::com::sun::star::uno::RuntimeException );
+ virtual void SAL_CALL setZoom( float ZoomX, float ZoomY ) throw( ::com::sun::star::uno::RuntimeException );
+
+public:
+ PluginControl_Impl();
+ virtual ~PluginControl_Impl();
+
+ MRCListenerMultiplexerHelper* getMultiplexer();
+
+protected:
+ void releasePeer();
+
+protected:
+ ::std::list< Reference< ::com::sun::star::lang::XEventListener > > _aDisposeListeners;
+ MRCListenerMultiplexerHelper* _pMultiplexer;
+
+ Reference< XInterface > _xContext;
+
+ sal_Int32 _nX;
+ sal_Int32 _nY;
+ sal_Int32 _nWidth;
+ sal_Int32 _nHeight;
+ sal_Int16 _nFlags;
+
+ sal_Bool _bVisible;
+ sal_Bool _bInDesignMode;
+ sal_Bool _bEnable;
+
+ SystemChildWindow* _pSysChild;
+ ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer > _xPeer;
+ ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > _xPeerWindow;
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > _xParentWindow;
+ ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer > _xParentPeer;
+};
+
+#endif
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/plugin/inc/plugin/unx/mediator.hxx b/extensions/source/plugin/inc/plugin/unx/mediator.hxx
new file mode 100644
index 000000000000..1c847bb88e08
--- /dev/null
+++ b/extensions/source/plugin/inc/plugin/unx/mediator.hxx
@@ -0,0 +1,186 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef _MEDIATOR_HXX
+#define _MEDIATOR_HXX
+
+#include <string.h>
+#include <stdarg.h>
+#include <tools/string.hxx>
+#include <tools/link.hxx>
+#include <osl/pipe.hxx>
+#include <osl/mutex.hxx>
+#include <osl/conditn.hxx>
+#include <osl/thread.hxx>
+#if OSL_DEBUG_LEVEL > 1
+#include <stdio.h>
+#endif
+
+#include <vector>
+
+struct MediatorMessage
+{
+ ULONG m_nID;
+ ULONG m_nBytes;
+ char* m_pBytes;
+ char* m_pRun;
+
+ MediatorMessage() : m_nID( 0 ), m_nBytes( 0 ),
+ m_pBytes( NULL ), m_pRun( NULL ) {}
+ MediatorMessage( ULONG nID, ULONG nBytes, char* pBytes ) :
+ m_nID( nID ),m_nBytes( nBytes ), m_pRun( NULL )
+ {
+ m_pBytes = new char[ m_nBytes ];
+ memcpy( m_pBytes, pBytes, (size_t)m_nBytes );
+ }
+
+ ~MediatorMessage()
+ {
+ if( m_pBytes )
+ delete [] m_pBytes;
+ }
+
+ void Set( ULONG nBytes, char* pBytes )
+ {
+ if( m_pBytes )
+ delete [] m_pBytes;
+ m_nBytes = nBytes;
+ m_pBytes = new char[ m_nBytes ];
+ memcpy( m_pBytes, pBytes, (size_t)m_nBytes );
+ }
+
+ ULONG ExtractULONG();
+ char* GetString();
+ UINT32 GetUINT32();
+ void* GetBytes( ULONG& );
+ void* GetBytes() { ULONG nBytes; return GetBytes( nBytes ); }
+
+ void Rewind() { m_pRun = NULL; }
+};
+
+class MediatorListener;
+
+class Mediator
+{
+ friend class MediatorListener;
+protected:
+ int m_nSocket;
+
+ std::vector<MediatorMessage*> m_aMessageQueue;
+ osl::Mutex m_aQueueMutex;
+ osl::Mutex m_aSendMutex;
+ // only one thread can send a message at any given time
+ osl::Condition m_aNewMessageCdtn;
+ MediatorListener* m_pListener;
+ // thread to fill the queue
+
+ ULONG m_nCurrentID;
+ // will be constantly increased with each message sent
+ bool m_bValid;
+
+ Link m_aConnectionLostHdl;
+ Link m_aNewMessageHdl;
+public:
+ Mediator( int nSocket );
+ ~Mediator();
+
+ // mark mediator as invalid. No more messages will be processed,
+ // SendMessage, WaitForMessage, TransactMessage will return immediatly
+ // with error
+ void invalidate() { m_bValid = false; }
+
+ ULONG SendMessage( ULONG nBytes, const char* pBytes, ULONG nMessageID = 0 );
+ ULONG SendMessage( const ByteString& rMessage, ULONG nMessageID = 0 )
+ {
+ return SendMessage( rMessage.Len(), rMessage.GetBuffer(), nMessageID );
+ }
+
+ BOOL WaitForMessage( ULONG nTimeOut = 5000 );
+ // timeout in ms
+ // TRUE: Message came in
+ // FALSE: timed out
+ // if timeout is set, WaitForMessage will wait even if there are messages
+ // in the queue
+
+ virtual MediatorMessage* WaitForAnswer( ULONG nMessageID );
+ // wait for an answer message ( ID >= 1 << 24 )
+ // the message will be removed from the queue and returned
+
+ MediatorMessage* TransactMessage( ULONG nBytes, char* pBytes );
+ // sends a message and waits for an answer
+
+ MediatorMessage* GetNextMessage( BOOL bWait = FALSE );
+
+
+ Link SetConnectionLostHdl( const Link& rLink )
+ {
+ Link aRet = m_aConnectionLostHdl;
+ m_aConnectionLostHdl = rLink;
+ return aRet;
+ }
+
+ Link SetNewMessageHdl( const Link& rLink )
+ {
+ Link aRet = m_aNewMessageHdl;
+ m_aNewMessageHdl = rLink;
+ return aRet;
+ }
+};
+
+class MediatorListener : public osl::Thread
+{
+ friend class Mediator;
+ private:
+ Mediator* m_pMediator;
+ ::osl::Mutex m_aMutex;
+
+ MediatorListener( Mediator* );
+ ~MediatorListener();
+
+ virtual void run();
+ virtual void onTerminated();
+};
+
+inline void medDebug( int condition, const char* pFormat, ... )
+{
+#if OSL_DEBUG_LEVEL > 1
+ if( condition )
+ {
+ va_list ap;
+ va_start( ap, pFormat );
+ vfprintf( stderr, pFormat, ap );
+ va_end( ap );
+ }
+#else
+ (void)condition;
+ (void)pFormat;
+#endif
+}
+
+#endif // _MEDIATOR_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/plugin/inc/plugin/unx/plugcon.hxx b/extensions/source/plugin/inc/plugin/unx/plugcon.hxx
new file mode 100644
index 000000000000..491fdf4475a5
--- /dev/null
+++ b/extensions/source/plugin/inc/plugin/unx/plugcon.hxx
@@ -0,0 +1,254 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef _PLUGCON_HXX
+#define _PLUGCON_HXX
+
+#include <stdarg.h>
+#include <string.h>
+
+#include <list>
+#include <vector>
+#include <plugin/unx/mediator.hxx>
+
+#if defined SOLARIS
+# define USE_MOTIF
+#endif
+
+#define Window XLIB_Window
+#define Font XLIB_Font
+#define KeyCode XLIB_KeyCode
+#define Time XLIB_Time
+#define Cursor XLIB_Cursor
+#define Region XLIB_Region
+#define String XLIB_String
+#define Boolean XLIB_Boolean
+#define XPointer XLIB_XPointer
+#include <X11/Xlib.h>
+extern "C" {
+#include <X11/Intrinsic.h>
+}
+#include <X11/Shell.h>
+#include <X11/IntrinsicP.h> /* Intrinsics Definitions*/
+#include <X11/StringDefs.h> /* Standard Name-String definitions*/
+#if defined USE_MOTIF
+#include <Xm/DrawingA.h>
+#else
+# if defined DISABLE_XAW
+# include <X11/Composite.h>
+# else
+# include <X11/Xaw/Label.h>
+# endif
+#endif
+#include <X11/Xatom.h>
+#ifndef XP_UNIX
+# define XP_UNIX
+#endif
+#define MOZ_X11
+#include <stdio.h>
+#ifdef SYSTEM_MOZILLA
+#ifndef OJI
+# define OJI
+#endif
+#define MOZ_X11
+#endif
+
+//http://qa.openoffice.org/issues/show_bug.cgi?id=82545
+//https://bugzilla.mozilla.org/show_bug.cgi?id=241262
+#ifdef UNIX
+# ifndef _UINT32
+# if defined(__alpha) || defined(__LP64__) || defined(AIX)
+ typedef unsigned int uint32;
+# else /* __alpha */
+ typedef unsigned long uint32;
+# endif
+# define _UINT32
+# endif
+# ifndef _INT32
+# if defined(__alpha) || defined(__LP64__) || defined(AIX)
+ typedef int int32;
+# else /* __alpha */
+ typedef long int32;
+# endif
+# define _INT32
+# endif
+#endif
+
+#ifndef _NPAPI_H_
+extern "C" {
+#include <npsdk/npupp.h>
+}
+#include <npsdk/npapi.h>
+
+#if NP_VERSION_MINOR < 17
+// compatibility hack: compile with older NPN api header, but define
+// some later introduced constants
+// for gcc 3
+#define NP_ABI_MASK 0x10000000
+#define NPNVSupportsXEmbedBool ((NPNVariable)14)
+#define NPPVpluginNeedsXEmbed ((NPPVariable)14)
+#define NPNVToolkit ((int)(13 | NP_ABI_MASK))
+#define NPNVGtk12 1
+#define NPNVGtk2 2
+#endif
+#endif
+
+#ifdef ENABLE_GTK
+#include <gtk/gtk.h>
+#include <gdk/gdkx.h>
+#else
+#define GtkWidget void
+#endif
+
+#undef Window
+#undef Font
+#undef KeyCode
+#undef Time
+#undef Cursor
+#undef String
+#undef Region
+#undef Boolean
+#undef XPointer
+
+class ConnectorInstance
+{
+public:
+ NPP instance;
+ NPWindow window;
+ NPSetWindowCallbackStruct ws_info;
+ char* pMimeType;
+ void* pShell;
+ void* pWidget;
+ void* pForm;
+
+ GtkWidget* pGtkWindow;
+ GtkWidget* pGtkWidget;
+
+ bool bShouldUseXEmbed;
+
+ int nArg;
+ char** argn;
+ char** argv;
+ char* pArgnBuf;
+ char* pArgvBuf;
+ NPSavedData aData;
+
+ ConnectorInstance( NPP inst, char* type,
+ int args, char* pargnbuf, ULONG nargnbytes,
+ char* pargvbuf, ULONG nargvbytes,
+ char* savedata, ULONG savebytes );
+ ~ConnectorInstance();
+};
+
+class PluginConnector : public Mediator
+{
+protected:
+ osl::Mutex m_aUserEventMutex;
+
+ static std::vector<PluginConnector*> allConnectors;
+
+ DECL_LINK( NewMessageHdl, Mediator* );
+ DECL_LINK( WorkOnNewMessageHdl, Mediator* );
+
+ std::vector<NPStream*> m_aNPWrapStreams;
+ std::vector<ConnectorInstance*> m_aInstances;
+
+ ULONG FillBuffer( char*&, const char*, ULONG, va_list );
+public:
+ PluginConnector( int nSocket );
+ ~PluginConnector();
+
+ virtual MediatorMessage* WaitForAnswer( ULONG nMessageID );
+ MediatorMessage* Transact( const char*, ULONG, ... );
+ MediatorMessage* Transact( UINT32, ... );
+ void Respond( ULONG nID, char*, ULONG, ... );
+ ULONG Send( UINT32, ... );
+
+ static const UINT32 UnknownStreamID = 0xffffffff;
+ static const UINT32 UnknownNPPID = 0xffffffff;
+
+ UINT32 GetStreamID( NPStream* pStream );
+ UINT32 GetNPPID( NPP );
+
+ std::vector<NPStream*>& getStreamList() { return m_aNPWrapStreams; }
+
+ NPError GetNPError( MediatorMessage* pMes )
+ {
+ NPError* pErr = (NPError*)pMes->GetBytes();
+ NPError aErr = *pErr;
+ delete [] pErr;
+ return aErr;
+ }
+
+ void CallWorkHandler()
+ {
+ LINK( this, PluginConnector, WorkOnNewMessageHdl ).
+ Call( (Mediator*)this );
+ }
+
+ ConnectorInstance* getInstance( NPP );
+ ConnectorInstance* getInstanceById( UINT32 );
+};
+
+enum CommandAtoms
+{
+ eNPN_GetURL,
+ eNPN_GetURLNotify,
+ eNPN_DestroyStream,
+ eNPN_NewStream,
+ eNPN_PostURLNotify,
+ eNPN_PostURL,
+ eNPN_RequestRead,
+ eNPN_Status,
+ eNPN_Version,
+ eNPN_Write,
+ eNPN_UserAgent,
+
+ eNPP_DestroyStream,
+ eNPP_Destroy,
+ eNPP_DestroyPhase2,
+ eNPP_NewStream,
+ eNPP_New,
+ eNPP_SetWindow,
+ eNPP_StreamAsFile,
+ eNPP_URLNotify,
+ eNPP_WriteReady,
+ eNPP_Write,
+ eNPP_GetMIMEDescription,
+ eNPP_Initialize,
+ eNPP_Shutdown,
+
+ eMaxCommand
+};
+
+const char* GetCommandName( CommandAtoms );
+
+#define POST_STRING( x ) x ? x : const_cast<char*>(""), x ? strlen(x) : 1
+
+#endif // _PLUGCON_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/plugin/inc/plugin/unx/sysplug.hxx b/extensions/source/plugin/inc/plugin/unx/sysplug.hxx
new file mode 100644
index 000000000000..69d64f7ac514
--- /dev/null
+++ b/extensions/source/plugin/inc/plugin/unx/sysplug.hxx
@@ -0,0 +1,86 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef __PLUGIN_INC_UNXPLUG_HXX
+#define __PLUGIN_INC_UNXPLUG_HXX
+
+#include <unistd.h>
+
+#include <plugin/unx/plugcon.hxx>
+#include <plugin/plcom.hxx>
+#include <vcl/sysdata.hxx>
+
+class UnxPluginComm : public PluginComm, public PluginConnector
+{
+private:
+ static int nConnCounter;
+
+ pid_t m_nCommPID;
+public:
+ UnxPluginComm( const String& mimetype,
+ const String& library,
+ XLIB_Window aParent,
+ int nDescriptor1,
+ int nDescriptor2
+ );
+ virtual ~UnxPluginComm();
+
+ using PluginComm::NPP_Destroy;
+ virtual NPError NPP_Destroy( NPP instance, NPSavedData** save );
+ virtual NPError NPP_DestroyStream( NPP instance, NPStream* stream,
+ NPError reason );
+ virtual void* NPP_GetJavaClass();
+ virtual NPError NPP_Initialize();
+ virtual NPError NPP_New( NPMIMEType pluginType, NPP instance,
+ uint16 mode, int16 argc,
+ char* argn[], char* argv[], NPSavedData *saved );
+ virtual NPError NPP_NewStream( NPP instance, NPMIMEType type,
+ NPStream* stream,
+ NPBool seekable, uint16* stype );
+ virtual void NPP_Print( NPP instance, NPPrint* platformPrint );
+
+ using PluginComm::NPP_SetWindow;
+ virtual NPError NPP_SetWindow( NPP instance, NPWindow* window );
+ virtual void NPP_Shutdown();
+ virtual void NPP_StreamAsFile( NPP instance, NPStream* stream,
+ const char* fname );
+ virtual void NPP_URLNotify( NPP instance, const char* url, NPReason reason,
+ void* notifyData );
+ virtual int32 NPP_Write( NPP instance, NPStream* stream, int32 offset,
+ int32 len, void* buffer );
+ virtual int32 NPP_WriteReady( NPP instance, NPStream* stream );
+ virtual char* NPP_GetMIMEDescription();
+ virtual NPError NPP_GetValue( NPP instance, NPPVariable variable, void* value );
+ virtual NPError NPP_SetValue( NPP instance, NPNVariable variable,
+ void *value);
+
+ static bool getPluginappPath(rtl::OString * path);
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/plugin/inc/plugin/win/sysplug.hxx b/extensions/source/plugin/inc/plugin/win/sysplug.hxx
new file mode 100644
index 000000000000..4161312b4988
--- /dev/null
+++ b/extensions/source/plugin/inc/plugin/win/sysplug.hxx
@@ -0,0 +1,127 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef __PLUGIN_INC_WINPLUG_HXX
+#define __PLUGIN_INC_WINPLUG_HXX
+
+#pragma warning (push,1)
+#pragma warning (disable:4005)
+
+#include <tools/prewin.h>
+
+#include <windows.h>
+#include <tchar.h>
+#include <winbase.h>
+
+#include <tools/postwin.h>
+
+#pragma pack( push, 8 )
+#include <npsdk/npapi.h>
+#include <npsdk/npupp.h>
+#pragma pack( pop )
+
+#pragma warning (pop)
+
+#include <list>
+#include <map>
+#include <algorithm>
+
+#include <plugin/plcom.hxx>
+#include <vcl/threadex.hxx>
+
+//==================================================================================================
+class PluginComm_Impl :
+ public PluginComm,
+ public ::vcl::SolarThreadExecutor
+
+{
+ enum CallType {
+ eNPP_Destroy,
+ eNPP_DestroyStream,
+ eNPP_GetJavaClass,
+ eNPP_Initialize,
+ eNPP_New,
+ eNPP_NewStream,
+ eNPP_Print,
+ eNPP_SetWindow,
+ eNPP_Shutdown,
+ eNPP_StreamAsFile,
+ eNPP_URLNotify,
+ eNPP_Write,
+ eNPP_WriteReady,
+ eNPP_GetValue,
+ eNPP_SetValue,
+ eNP_Initialize
+ };
+
+ void* m_aArgs[ 8 ];
+ CallType m_eCall;
+
+ virtual long doIt();
+public:
+ PluginComm_Impl( const rtl::OUString& rMIME, const rtl::OUString& rName, HWND hWnd );
+ virtual ~PluginComm_Impl();
+
+public:
+ using PluginComm::NPP_Destroy;
+ virtual NPError NPP_Destroy( NPP instance, NPSavedData** save );
+ virtual NPError NPP_DestroyStream( NPP instance, NPStream* stream, NPError reason );
+ virtual void * NPP_GetJavaClass();
+ virtual NPError NPP_Initialize();
+ virtual NPError NPP_New( NPMIMEType pluginType, NPP instance, uint16 mode, int16 argc,
+ char* argn[], char* argv[], NPSavedData *saved );
+ virtual NPError NPP_NewStream( NPP instance, NPMIMEType type, NPStream* stream,
+ NPBool seekable, uint16* stype );
+ virtual void NPP_Print( NPP instance, NPPrint* platformPrint );
+
+ using PluginComm::NPP_SetWindow;
+ virtual NPError NPP_SetWindow( NPP instance, NPWindow* window );
+ virtual void NPP_Shutdown();
+ virtual void NPP_StreamAsFile( NPP instance, NPStream* stream, const char* fname );
+ virtual void NPP_URLNotify( NPP instance, const char* url,
+ NPReason reason, void* notifyData );
+ virtual int32 NPP_Write( NPP instance, NPStream* stream, int32 offset,
+ int32 len, void* buffer );
+ virtual int32 NPP_WriteReady( NPP instance, NPStream* stream );
+ virtual NPError NPP_GetValue( NPP instance, NPPVariable variable, void *ret_alue );
+ virtual NPError NPP_SetValue( NPP instance, NPNVariable variable, void *ret_alue );
+
+private:
+ BOOL retrieveFunction( TCHAR* pName, void** ppFunc ) const;
+
+private:
+ HINSTANCE _plDLL;
+
+ NPPluginFuncs _NPPfuncs;
+};
+
+
+#endif
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/plugin/unx/makefile.mk b/extensions/source/plugin/unx/makefile.mk
new file mode 100644
index 000000000000..0e9b5d454596
--- /dev/null
+++ b/extensions/source/plugin/unx/makefile.mk
@@ -0,0 +1,111 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+PRJ=..$/..$/..
+
+PRJNAME=extensions
+TARGET=plunx
+TARGETTYPE=CUI
+ENABLE_EXCEPTIONS=TRUE
+
+.INCLUDE : ..$/util$/makefile.pmk
+
+.IF "$(GUIBASE)"=="aqua"
+dummy:
+ @echo "Nothing to build for GUIBASE aqua."
+
+.ELSE
+
+# --- Files --------------------------------------------------------
+
+INCPRE+=-I$(SOLARINCDIR)$/mozilla$/plugin
+.IF "$(SOLAR_JAVA)" != ""
+INCPRE+=-I$(SOLARINCDIR)$/mozilla$/java
+INCPRE+=-I$(SOLARINCDIR)$/mozilla$/nspr
+CDEFS+=-DOJI
+.ENDIF
+
+.IF "$(WITH_MOZILLA)" != "NO"
+
+.IF "$(DISABLE_XAW)" == "TRUE"
+CDEFS+=-DDISABLE_XAW
+.ENDIF
+
+SLOFILES=\
+ $(SLO)$/nppapi.obj \
+ $(SLO)$/sysplug.obj \
+ $(SLO)$/mediator.obj \
+ $(SLO)$/plugcon.obj \
+ $(SLO)$/unxmgr.obj
+
+OBJFILES=\
+ $(OBJ)$/npwrap.obj \
+ $(OBJ)$/npnapi.obj \
+ $(OBJ)$/mediator.obj \
+ $(OBJ)$/plugcon.obj
+
+APP1TARGET=pluginapp.bin
+APP1OBJS=$(OBJFILES)
+APP1STDLIBS= $(SALLIB)
+
+.IF "$(OS)"=="SOLARIS" || "$(OS)"=="SCO" || "$(OS)"=="HPUX"
+APP1STDLIBS+=-lXm -lXt $(X11LINK_DYNAMIC) -ldl
+.ELSE
+.IF "$(DISABLE_XAW)" != "TRUE"
+APP1STDLIBS+=-lXaw
+.ENDIF
+.IF "$(OS)"=="FREEBSD" || "$(OS)"=="NETBSD" || "$(OS)"=="OPENBSD"
+APP1STDLIBS+= -lXt -lXext -lX11
+.ELIF "$(OS)"=="AIX"
+APP1STDLIBS+= -lXpm -lXmu -lXt $(X11LINK_DYNAMIC) -ldl
+.ELSE
+APP1STDLIBS+= -lXt $(X11LINK_DYNAMIC) -ldl
+.ENDIF
+.ENDIF
+
+.IF "$(ENABLE_GTK)" == "TRUE"
+# libs for gtk plugin
+APP1STDLIBS+=$(PKGCONFIG_LIBS:s/ -lpangoxft-1.0//)
+# hack for faked SO environment
+.IF "$(PKGCONFIG_ROOT)"!=""
+.IF "$(OS)" == "SOLARIS"
+# don't ask, it's ugly
+DIRECT :=-z nodefs $(DIRECT)
+.ENDIF
+.ENDIF # "$(PKGCONFIG_ROOT)"!=""
+.ENDIF
+
+
+APP1DEF= $(MISC)$/$(TARGET).def
+
+.ENDIF # $(WITH_MOZILLA) != "NO"
+
+.ENDIF # $(GUIBASE)==aqua
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : target.mk
+
diff --git a/extensions/source/plugin/unx/mediator.cxx b/extensions/source/plugin/unx/mediator.cxx
new file mode 100644
index 000000000000..afd42fa308bf
--- /dev/null
+++ b/extensions/source/plugin/unx/mediator.cxx
@@ -0,0 +1,312 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+#include <errno.h>
+#include <unistd.h>
+
+#include <plugin/unx/mediator.hxx>
+#include <vcl/svapp.hxx>
+
+#define MEDIATOR_MAGIC 0xf7a8d2f4
+
+Mediator::Mediator( int nSocket ) :
+ m_nSocket( nSocket ),
+ m_pListener( NULL ),
+ m_nCurrentID( 1 ),
+ m_bValid( true )
+{
+ m_pListener = new MediatorListener( this );
+ m_pListener->create();
+}
+
+Mediator::~Mediator()
+{
+ if( m_pListener )
+ {
+ {
+ ::osl::MutexGuard aGuard( m_pListener->m_aMutex );
+ m_pListener->m_pMediator = NULL;
+ }
+ m_pListener = NULL;
+ if( m_bValid )
+ {
+ ULONG aHeader[3];
+ aHeader[0] = 0;
+ aHeader[1] = 0;
+ aHeader[2] = MEDIATOR_MAGIC;
+ write( m_nSocket, aHeader, sizeof( aHeader ) );
+ }
+ // kick the thread out of its run method; it deletes itself
+ close( m_nSocket );
+ }
+ else
+ close( m_nSocket );
+ for( std::vector< MediatorMessage* >::iterator it = m_aMessageQueue.begin();
+ it != m_aMessageQueue.end(); ++it )
+ {
+ delete *it;
+ }
+}
+
+
+ULONG Mediator::SendMessage( ULONG nBytes, const char* pBytes, ULONG nMessageID )
+{
+ if( ! m_pListener )
+ return 0;
+
+ osl::MutexGuard aGuard( m_aSendMutex );
+ if( ! nMessageID )
+ nMessageID = m_nCurrentID;
+
+ m_nCurrentID++;
+ if( m_nCurrentID >= 1 << 24 ) // protection against overflow
+ m_nCurrentID = 1;
+
+ if( ! m_bValid )
+ return nMessageID;
+
+ ULONG* pBuffer = new ULONG[ (nBytes/sizeof(ULONG)) + 4 ];
+ pBuffer[ 0 ] = nMessageID;
+ pBuffer[ 1 ] = nBytes;
+ pBuffer[ 2 ] = MEDIATOR_MAGIC;
+ memcpy( &pBuffer[3], pBytes, (size_t)nBytes );
+ write( m_nSocket, pBuffer, nBytes + 3*sizeof( ULONG ) );
+ delete [] pBuffer;
+
+ return nMessageID;
+}
+
+BOOL Mediator::WaitForMessage( ULONG nTimeOut )
+{
+ if( ! m_pListener )
+ return FALSE;
+
+ size_t nItems = m_aMessageQueue.size();
+
+ if( ! nTimeOut && nItems > 0 )
+ return TRUE;
+
+ TimeValue aValue;
+ aValue.Seconds = nTimeOut/1000;
+ aValue.Nanosec = ( nTimeOut % 1000 ) * 1000;
+
+ while( m_aMessageQueue.size() == nItems )
+ {
+ m_aNewMessageCdtn.wait( & aValue );
+ m_aNewMessageCdtn.reset();
+ if( nTimeOut && m_aMessageQueue.size() == nItems )
+ return FALSE;
+ }
+ return TRUE;
+}
+
+MediatorMessage* Mediator::WaitForAnswer( ULONG nMessageID )
+{
+ nMessageID &= 0x00ffffff;
+ while( m_pListener )
+ {
+ {
+ osl::MutexGuard aGuard( m_aQueueMutex );
+ for( size_t i = 0; i < m_aMessageQueue.size(); i++ )
+ {
+ MediatorMessage* pMessage = m_aMessageQueue[ i ];
+ ULONG nID = pMessage->m_nID;
+ if( ( nID & 0xff000000 ) &&
+ ( ( nID & 0x00ffffff ) == nMessageID ) )
+ {
+ m_aMessageQueue.erase( m_aMessageQueue.begin() + i );
+ return pMessage;
+ }
+ }
+ }
+ WaitForMessage( 10 );
+ }
+ return NULL;
+}
+
+MediatorMessage* Mediator::GetNextMessage( BOOL bWait )
+{
+ while( m_pListener )
+ {
+ {
+ // guard must be after WaitForMessage, else the listener
+ // cannot insert a new one -> deadlock
+ osl::MutexGuard aGuard( m_aQueueMutex );
+ for( size_t i = 0; i < m_aMessageQueue.size(); i++ )
+ {
+ MediatorMessage* pMessage = m_aMessageQueue[ i ];
+ if( ! ( pMessage->m_nID & 0xff000000 ) )
+ {
+ m_aMessageQueue.erase( m_aMessageQueue.begin() + i );
+ return pMessage;
+ }
+ }
+ if( ! bWait )
+ return NULL;
+ }
+ WaitForMessage();
+ }
+ return NULL;
+}
+
+MediatorMessage* Mediator::TransactMessage( ULONG nBytes, char* pBytes )
+{
+ ULONG nID = SendMessage( nBytes, pBytes );
+ return WaitForAnswer( nID );
+}
+
+MediatorListener::MediatorListener( Mediator* pMediator ) :
+ m_pMediator( pMediator )
+{
+}
+
+MediatorListener::~MediatorListener()
+{
+}
+
+void MediatorListener::run()
+{
+ bool bRun = true;
+ while( schedule() && m_pMediator && bRun )
+ {
+ ULONG nHeader[ 3 ];
+ int nBytes;
+
+ if( m_pMediator && ( nBytes = read( m_pMediator->m_nSocket, nHeader, sizeof( nHeader ) ) ) == sizeof( nHeader ) && nHeader[2] == MEDIATOR_MAGIC)
+ {
+ if( nHeader[ 0 ] == 0 && nHeader[ 1 ] == 0 )
+ return;
+ char* pBuffer = new char[ nHeader[ 1 ] ];
+ if( m_pMediator && (ULONG)read( m_pMediator->m_nSocket, pBuffer, nHeader[ 1 ] ) == nHeader[ 1 ] )
+ {
+ ::osl::MutexGuard aMyGuard( m_aMutex );
+ {
+ osl::MutexGuard
+ aGuard( m_pMediator->m_aQueueMutex );
+ MediatorMessage* pMessage =
+ new MediatorMessage( nHeader[ 0 ], nHeader[ 1 ], pBuffer );
+ m_pMediator->m_aMessageQueue.push_back( pMessage );
+ }
+ m_pMediator->m_aNewMessageCdtn.set();
+ m_pMediator->m_aNewMessageHdl.Call( m_pMediator );
+ }
+ else
+ {
+ medDebug( 1, "got incomplete MediatorMessage: { %d, %d, %*s }\n",
+ nHeader[0], nHeader[1], nHeader[1], pBuffer );
+ bRun = false;
+ }
+ delete [] pBuffer;
+ }
+ else
+ {
+ medDebug( 1, "got incomplete message header of %d bytes ( nHeader = [ %u, %u ] ), errno is %d\n",
+ nBytes, nHeader[ 0 ], nHeader[ 1 ], (int)errno );
+ bRun = false;
+ }
+ }
+}
+
+void MediatorListener::onTerminated()
+{
+ if( m_pMediator )
+ {
+ m_pMediator->m_aConnectionLostHdl.Call( m_pMediator );
+ m_pMediator->m_pListener = NULL;
+ }
+ delete this;
+}
+
+ULONG MediatorMessage::ExtractULONG()
+{
+ if( ! m_pRun )
+ m_pRun = m_pBytes;
+
+ medDebug( (ULONG)(m_pRun - m_pBytes) >= m_nBytes, "Overflow in MediatorMessage::ExtractULONG\n" );
+ ULONG nCount;
+ memcpy( &nCount, m_pRun, sizeof( ULONG ) );
+ m_pRun += sizeof( ULONG );
+ return nCount;
+}
+
+void* MediatorMessage::GetBytes( ULONG& rBytes )
+{
+ if( ! m_pRun )
+ m_pRun = m_pBytes;
+
+ medDebug( (ULONG)(m_pRun - m_pBytes) >= m_nBytes, "Overflow in MediatorMessage::GetBytes\n" );
+ ULONG nBytes = ExtractULONG();
+
+ if( nBytes == 0 )
+ return NULL;
+
+ medDebug( (ULONG)(m_pRun - m_pBytes) >= m_nBytes, "Overflow in MediatorMessage::GetBytes\n" );
+ char* pBuffer = new char[ nBytes ];
+ memcpy( pBuffer, m_pRun, nBytes );
+ m_pRun += nBytes;
+ rBytes = nBytes;
+ return pBuffer;
+}
+
+char* MediatorMessage::GetString()
+{
+ if( ! m_pRun )
+ m_pRun = m_pBytes;
+
+ medDebug( (ULONG)(m_pRun - m_pBytes) >= m_nBytes, "Overflow in MediatorMessage::GetString\n" );
+ ULONG nBytes = ExtractULONG();
+
+ if( nBytes == 0 )
+ return NULL;
+
+ medDebug( (ULONG)(m_pRun - m_pBytes) >= m_nBytes, "Overflow in MediatorMessage::GetString\n" );
+ char* pBuffer = new char[ nBytes+1 ];
+ memcpy( pBuffer, m_pRun, nBytes );
+ pBuffer[ nBytes ] = 0;
+ m_pRun += nBytes;
+ return pBuffer;
+}
+
+UINT32 MediatorMessage::GetUINT32()
+{
+ if( ! m_pRun )
+ m_pRun = m_pBytes;
+
+ medDebug( (ULONG)(m_pRun - m_pBytes) >= m_nBytes, "Overflow in MediatorMessage::GetUINT32\n" );
+ ULONG nBytes = ExtractULONG();
+ medDebug( nBytes != sizeof( UINT32 ), "No UINT32 in MediatorMessage::GetUINT32\n" );
+ medDebug( (ULONG)(m_pRun - m_pBytes) >= m_nBytes, "Overflow in MediatorMessage::GetUINT32\n" );
+ UINT32 nRet;
+ memcpy( &nRet, m_pRun, sizeof( nRet ) );
+ m_pRun += sizeof( UINT32 );
+ return nRet;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/plugin/unx/npnapi.cxx b/extensions/source/plugin/unx/npnapi.cxx
new file mode 100644
index 000000000000..f1f58fcc08bf
--- /dev/null
+++ b/extensions/source/plugin/unx/npnapi.cxx
@@ -0,0 +1,926 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+
+#ifdef AIX
+#define _LINUX_SOURCE_COMPAT
+#include <sys/timer.h>
+#undef _LINUX_SOURCE_COMPAT
+#endif
+
+#include <plugin/unx/plugcon.hxx>
+
+#include <unistd.h>
+#include <dlfcn.h>
+
+#include <osl/module.h>
+
+extern PluginConnector* pConnector;
+extern XtAppContext app_context;
+extern int wakeup_fd[];
+extern Widget topLevel, topBox;
+extern Display* pAppDisplay;
+extern Display* pXtAppDisplay;
+extern int nAppArguments;
+extern char** pAppArguments;
+
+void* CreateNewShell( void**, XLIB_Window );
+
+// begin Netscape plugin api calls
+extern "C" {
+
+static void* l_NPN_MemAlloc( uint32 nBytes )
+{
+ void* pMem = new char[nBytes];
+ return pMem;
+}
+
+static void l_NPN_MemFree( void* pMem )
+{
+ delete [] (char*)pMem;
+}
+
+static uint32 l_NPN_MemFlush( uint32 /*nSize*/ )
+{
+ return 0;
+}
+
+static NPError l_NPN_DestroyStream( NPP instance, NPStream* stream, NPError reason )
+{
+ UINT32 nInstance = pConnector->GetNPPID( instance );
+ if( nInstance == PluginConnector::UnknownNPPID )
+ return NPERR_GENERIC_ERROR;
+
+ UINT32 nFileID = pConnector->GetStreamID( stream );
+ MediatorMessage* pMes=
+ pConnector->
+ Transact( eNPN_DestroyStream,
+ &nInstance, sizeof( nInstance ),
+ &nFileID, sizeof( nFileID ),
+ POST_STRING( stream->url ),
+ &reason, sizeof( reason ),
+ NULL );
+
+ if( ! pMes )
+ return NPERR_GENERIC_ERROR;
+
+ for( std::vector< NPStream* >::iterator it = pConnector->getStreamList().begin();
+ it != pConnector->getStreamList().end(); ++it )
+ {
+ if( *it == stream )
+ {
+ pConnector->getStreamList().erase( it );
+ break;
+ }
+ }
+ delete [] stream->url;
+ delete stream;
+ // returns NPError
+ NPError aRet = pConnector->GetNPError( pMes );
+ delete pMes;
+ return aRet;
+}
+
+#ifdef OJI
+static JRIEnv* l_NPN_GetJavaEnv()
+{
+ // no java in this program
+ medDebug( 1, "SNI: NPN_GetJavaEnv\n" );
+ return NULL;
+}
+
+static jref l_NPN_GetJavaPeer( NPP /*instance*/ )
+{
+ medDebug( 1, "SNI: NPN_GetJavaPeer\n" );
+ return NULL;
+}
+#endif
+
+static NPError l_NPN_GetURL( NPP instance, const char* url, const char* window )
+{
+ UINT32 nInstance = pConnector->GetNPPID( instance );
+ if( nInstance == PluginConnector::UnknownNPPID )
+ return NPERR_GENERIC_ERROR;
+
+ MediatorMessage* pMes=
+ pConnector->
+ Transact( eNPN_GetURL,
+ &nInstance, sizeof( nInstance ),
+ POST_STRING(url),
+ POST_STRING(window),
+ NULL );
+ medDebug( !pMes, "geturl: message unaswered\n" );
+ if( ! pMes )
+ return NPERR_GENERIC_ERROR;
+
+ // returns NPError
+ NPError aRet = pConnector->GetNPError( pMes );
+ medDebug( aRet, "geturl returns %d\n", (int)aRet );
+ delete pMes;
+ return aRet;
+}
+
+static NPError l_NPN_GetURLNotify( NPP instance, const char* url, const char* target,
+ void* notifyData )
+{
+ UINT32 nInstance = pConnector->GetNPPID( instance );
+ if( nInstance == PluginConnector::UnknownNPPID )
+ return NPERR_GENERIC_ERROR;
+
+ MediatorMessage* pMes=
+ pConnector->
+ Transact( eNPN_GetURLNotify,
+ &nInstance, sizeof( nInstance ),
+ POST_STRING(url),
+ POST_STRING(target),
+ &notifyData, sizeof( void* ), // transmit the actual pointer
+ // since it is a pointer to private data fed back
+ // by NPP_URLNotify; this can be thought of as an ID
+ NULL );
+ if( ! pMes )
+ return NPERR_GENERIC_ERROR;
+
+ // returns NPError
+ NPError aRet = pConnector->GetNPError( pMes );
+ delete pMes;
+ return aRet;
+}
+
+static NPError l_NPN_NewStream( NPP instance, NPMIMEType type, const char* target,
+ NPStream** stream )
+ // stream is a return value
+{
+ UINT32 nInstance = pConnector->GetNPPID( instance );
+ if( nInstance == PluginConnector::UnknownNPPID )
+ return NPERR_GENERIC_ERROR;
+
+ MediatorMessage* pMes=
+ pConnector->
+ Transact( eNPN_NewStream,
+ &nInstance, sizeof( nInstance ),
+ POST_STRING(type),
+ POST_STRING(target),
+ NULL );
+ if( ! pMes )
+ return NPERR_GENERIC_ERROR;
+
+ // returns a new NPStream and an error
+ NPError aRet = pConnector->GetNPError( pMes );
+ if( ! aRet )
+ {
+ NPStream* pStream = new NPStream;
+ pStream->url = pMes->GetString();
+ pStream->end = pMes->GetUINT32();
+ pStream->lastmodified = pMes->GetUINT32();
+ pStream->ndata = pStream->pdata = pStream->notifyData = NULL;
+
+ pConnector->getStreamList().push_back( pStream );
+ *stream = pStream;
+ }
+
+ delete pMes;
+ return aRet;
+}
+
+static NPError l_NPN_PostURLNotify( NPP instance, const char* url, const char* target, uint32 len, const char* buf, NPBool file, void* notifyData )
+{
+ UINT32 nInstance = pConnector->GetNPPID( instance );
+ if( nInstance == PluginConnector::UnknownNPPID )
+ return NPERR_GENERIC_ERROR;
+
+ MediatorMessage* pMes = pConnector->
+ Transact( eNPN_PostURLNotify,
+ &nInstance, sizeof( nInstance ),
+ POST_STRING( url ),
+ POST_STRING( target ),
+ &len, sizeof( len ),
+ buf, len,
+ &file, sizeof( NPBool ),
+ &notifyData, sizeof( void* ), // send the real pointer
+ NULL );
+
+ if( ! pMes )
+ return NPERR_GENERIC_ERROR;
+
+ NPError aRet = pConnector->GetNPError( pMes );
+ delete pMes;
+ return aRet;
+}
+
+static NPError l_NPN_PostURL( NPP instance, const char* url, const char* window, uint32 len, const char* buf, NPBool file )
+{
+ UINT32 nInstance = pConnector->GetNPPID( instance );
+ if( nInstance == PluginConnector::UnknownNPPID )
+ return NPERR_GENERIC_ERROR;
+
+ MediatorMessage* pMes = pConnector->
+ Transact( eNPN_PostURL,
+ &nInstance, sizeof( nInstance ),
+ POST_STRING( url ),
+ POST_STRING( window ),
+ &len, sizeof( len ),
+ buf, len,
+ &file, sizeof( NPBool ),
+ NULL );
+ if( ! pMes )
+ return NPERR_GENERIC_ERROR;
+
+ NPError aRet = pConnector->GetNPError( pMes );
+ delete pMes;
+ return aRet;
+}
+
+static NPError l_NPN_RequestRead( NPStream* stream, NPByteRange* rangeList )
+{
+ medDebug( 1, "pluginapp: NPN_RequestRead\n" );
+
+ NPByteRange* pRange = rangeList;
+ UINT32 nRanges = 0;
+ while( pRange )
+ {
+ nRanges++;
+ pRange = pRange->next;
+ }
+
+ UINT32* pArray = new UINT32[ 2 * nRanges ];
+ pRange = rangeList;
+ UINT32 n = 0;
+ while( pRange )
+ {
+ pArray[ 2*n ] = (UINT32)pRange->offset;
+ pArray[ 2*n + 1] = (UINT32)pRange->length;
+ n++;
+ pRange = pRange->next;
+ }
+ UINT32 nFileID = pConnector->GetStreamID( stream );
+ MediatorMessage* pMes = pConnector->
+ Transact( eNPN_RequestRead,
+ &nFileID, sizeof( nFileID ),
+ &nRanges, sizeof( nRanges ),
+ pArray, sizeof( UINT32 ) * 2 * nRanges,
+ NULL );
+
+ if( ! pMes )
+ return NPERR_GENERIC_ERROR;
+
+ NPError aRet = pConnector->GetNPError( pMes );
+ delete [] pArray;
+ delete pMes;
+ return aRet;
+}
+
+static void l_NPN_Status( NPP instance, const char* message )
+{
+ UINT32 nInstance = pConnector->GetNPPID( instance );
+ if( nInstance == PluginConnector::UnknownNPPID )
+ return;
+
+ pConnector->Send( eNPN_Status,
+ &nInstance, sizeof( nInstance ),
+ POST_STRING( message ),
+ NULL );
+}
+
+static const char* l_NPN_UserAgent( NPP instance )
+{
+ static char* pAgent = NULL;
+
+ UINT32 nInstance = pConnector->GetNPPID( instance );
+ if( nInstance == PluginConnector::UnknownNPPID )
+ {
+ if( instance )
+ return "Mozilla 3.0";
+ else // e.g. flashplayer calls NPN_UserAgent with NULL
+ nInstance = 0;
+ }
+
+ MediatorMessage* pMes = pConnector->
+ Transact( eNPN_UserAgent,
+ &nInstance, sizeof( nInstance ),
+ NULL );
+
+ if( ! pMes )
+ return pAgent;
+
+ if( pAgent )
+ delete [] pAgent;
+ pAgent = pMes->GetString();
+
+ delete pMes;
+
+ medDebug( 1, "NPN_UserAgent returns %s\n", pAgent );
+
+ return pAgent;
+}
+
+#if 0
+static void l_NPN_Version( int* major, int* minor, int* net_major, int* net_minor )
+{
+ MediatorMessage* pMes = pConnector->
+ Transact( eNPN_Version,
+ NULL );
+
+ if( ! pMes )
+ return;
+
+ *major = pMes->GetUINT32();
+ *minor = pMes->GetUINT32();
+ *net_major = pMes->GetUINT32();
+ *net_minor = pMes->GetUINT32();
+
+ medDebug( 1, "pluginapp: NPN_Version: results %d %d, %d %d\n", *major, *minor, *net_major, *net_minor );
+
+ delete pMes;
+}
+#endif
+
+static int32 l_NPN_Write( NPP instance, NPStream* stream, int32 len, void* buffer )
+{
+ UINT32 nFileID = pConnector->GetStreamID( stream );
+ if( nFileID == PluginConnector::UnknownStreamID )
+ return NPERR_GENERIC_ERROR;
+ UINT32 nInstance = pConnector->GetNPPID( instance );
+ if( nInstance == PluginConnector::UnknownNPPID )
+ return NPERR_GENERIC_ERROR;
+
+ MediatorMessage* pMes = pConnector->
+ Transact( eNPN_Write,
+ &nInstance, sizeof( nInstance ),
+ &nFileID, sizeof( nFileID ),
+ &len, sizeof( len ),
+ buffer, len,
+ NULL );
+
+ if( ! pMes )
+ return 0;
+
+ INT32 nRet = pMes->GetUINT32();
+ return nRet;
+}
+
+static void l_NPN_ReloadPlugins( NPBool /*reloadPages*/ )
+{
+ medDebug( 1, "NPN_ReloadPlugins: SNI\n" );
+}
+
+static NPError l_NPN_GetValue( NPP, NPNVariable variable, void* value )
+{
+ /*
+ * We want to handle values injected into a NPNVariable which aren't in
+ * the old enum we build against, but that we know are in the new enum
+ * we want to support
+ */
+ switch( (int)variable )
+ {
+ case NPNVxDisplay:
+ *((Display**)value) = pXtAppDisplay;
+ medDebug( 1, "Display requested\n" );
+ break;
+ case NPNVxtAppContext:
+ *((XtAppContext*)value) = app_context;
+ medDebug( 1, "AppContext requested\n" );
+ break;
+ case NPNVjavascriptEnabledBool:
+ // no javascript
+ *(NPBool*)value = false;
+ medDebug( 1, "javascript enabled requested\n" );
+ break;
+ case NPNVasdEnabledBool:
+ // no SmartUpdate
+ *(NPBool*)value = false;
+ medDebug( 1, "smart update enabled requested\n" );
+ break;
+ case NPNVisOfflineBool:
+ // no offline browsing
+ *(NPBool*)value = false;
+ medDebug( 1, "offline browsing requested\n" );
+ break;
+ case NPNVSupportsXEmbedBool:
+ // asking xembed
+ *(int*)value = true;
+ medDebug( 1, "xembed requested\n" );
+ break;
+ case NPNVToolkit:
+# ifdef ENABLE_GTK
+ *(int*)value = NPNVGtk2;
+# else
+ *(int*)value = 0;
+# endif
+ medDebug( 1, "toolkit requested\n" );
+ break;
+ default:
+ medDebug( 1, "unknown NPNVariable %x requested\n", variable );
+ return NPERR_INVALID_PARAM;
+ }
+ return NPERR_NO_ERROR;
+}
+
+static NPError l_NPN_SetValue(NPP /*instance*/, NPPVariable variable, void *value)
+{
+ medDebug( 1, "NPN_SetValue %d=%p\n", variable, value );
+ return 0;
+}
+
+static void l_NPN_InvalidateRect(NPP /*instance*/, NPRect* /*invalidRect*/)
+{
+ medDebug( 1, "NPN_InvalidateRect\n" );
+}
+
+static void l_NPN_InvalidateRegion(NPP /*instance*/, NPRegion /*invalidRegion*/)
+{
+ medDebug( 1, "NPN_InvalidateRegion\n" );
+}
+
+static void l_NPN_ForceRedraw(NPP /*instance*/)
+{
+ medDebug( 1, "NPN_ForceRedraw\n" );
+}
+
+}
+
+static NPNetscapeFuncs aNetscapeFuncs =
+{
+ sizeof(aNetscapeFuncs),
+ (NP_VERSION_MAJOR << 8) | NP_VERSION_MINOR,
+ l_NPN_GetURL,
+ l_NPN_PostURL,
+ l_NPN_RequestRead,
+ l_NPN_NewStream,
+ l_NPN_Write,
+ l_NPN_DestroyStream,
+ l_NPN_Status,
+ l_NPN_UserAgent,
+ l_NPN_MemAlloc,
+ l_NPN_MemFree,
+ l_NPN_MemFlush,
+ l_NPN_ReloadPlugins,
+# ifdef OJI
+ l_NPN_GetJavaEnv,
+ l_NPN_GetJavaPeer,
+# else
+ NULL,
+ NULL,
+# endif
+ l_NPN_GetURLNotify,
+ l_NPN_PostURLNotify,
+ l_NPN_GetValue,
+ l_NPN_SetValue,
+ l_NPN_InvalidateRect,
+ l_NPN_InvalidateRegion,
+ l_NPN_ForceRedraw
+};
+
+static NPPluginFuncs aPluginFuncs =
+{
+ sizeof(aPluginFuncs),
+ (NP_VERSION_MAJOR << 8) | NP_VERSION_MINOR,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL
+};
+
+
+oslModule pPluginLib = NULL;
+char*(*pNPP_GetMIMEDescription)() = NULL;
+NPError (*pNP_Initialize)(NPNetscapeFuncs*,NPPluginFuncs*) = NULL;
+NPError (*pNP_Shutdown)() = NULL;
+
+std::vector< PluginConnector* > PluginConnector::allConnectors;
+
+PluginConnector::PluginConnector( int nSocket ) :
+ Mediator( nSocket )
+{
+ SetNewMessageHdl( LINK( this, PluginConnector, NewMessageHdl ) );
+}
+
+PluginConnector::~PluginConnector()
+{
+}
+
+IMPL_LINK( PluginConnector, WorkOnNewMessageHdl, Mediator*, /*pMediator*/ )
+{
+ MediatorMessage* pMessage;
+ CommandAtoms nCommand;
+ while( (pMessage = GetNextMessage( FALSE )) )
+ {
+ nCommand = (CommandAtoms)pMessage->GetUINT32();
+ medDebug( 1, "pluginapp: %s\n", GetCommandName( nCommand ) );
+ switch( nCommand )
+ {
+ case eNPP_DestroyStream:
+ {
+ UINT32 nInstance = pMessage->GetUINT32();
+ NPP instance = m_aInstances[ nInstance ]->instance;
+ UINT32 nFileID = pMessage->GetUINT32();
+ NPStream* pStream = m_aNPWrapStreams[ nFileID ];
+ NPError aReason = GetNPError( pMessage );
+ m_aNPWrapStreams.erase( m_aNPWrapStreams.begin() + nFileID );
+
+ aReason = aPluginFuncs.destroystream( instance, pStream, aReason );
+ Respond( pMessage->m_nID,
+ (char*)&aReason, sizeof( aReason ),
+ NULL );
+
+ delete [] pStream->url;
+ delete pStream;
+ }
+ break;
+ case eNPP_Destroy:
+ {
+ UINT32 nInstance = pMessage->GetUINT32();
+ ConnectorInstance* pInst= m_aInstances[ nInstance ];
+
+ // some plugin rely on old netscapes behaviour
+ // to first destroy the widget and then destroy
+ // the instance, so mimic that behaviour here
+ if( pInst->pShell )
+ XtDestroyWidget( (Widget)pInst->pShell );
+
+ pInst->pWidget = pInst->pShell = NULL;
+
+ // the other side will call eNPP_DestroyPhase2 after this
+ NPError aReason = NPERR_NO_ERROR;
+ Respond( pMessage->m_nID, (char*)&aReason, sizeof( aReason ), NULL );
+ }
+ break;
+ case eNPP_DestroyPhase2:
+ {
+ // now really destroy the instance
+ UINT32 nInstance = pMessage->GetUINT32();
+ ConnectorInstance* pInst= m_aInstances[ nInstance ];
+ NPP instance = pInst->instance;
+ NPSavedData* pSave = NULL;
+
+ NPError aRet = aPluginFuncs.destroy( instance, &pSave );
+ if( pSave )
+ {
+ Respond( pMessage->m_nID,
+ (char*)&aRet, sizeof( aRet ),
+ pSave->buf, pSave->len,
+ NULL );
+ delete [] (char*)pSave->buf;
+ }
+ else
+ Respond( pMessage->m_nID,
+ (char*)&aRet, sizeof( aRet ),
+ "0000", 4,
+ NULL );
+
+ #ifdef ENABLE_GTK
+ if( pInst->pGtkWindow )
+ g_object_unref( G_OBJECT(pInst->pGtkWindow) );
+ if( pInst->pGtkWidget )
+ g_object_unref( G_OBJECT(pInst->pGtkWidget) );
+ #endif
+
+ m_aInstances.erase( m_aInstances.begin() + nInstance );
+ delete pInst;
+ delete instance;
+ medDebug( 1, "destroyed instance (returning %d)\n", aRet );
+ }
+ break;
+ case eNPP_NewStream:
+ {
+ UINT32 nInstance = pMessage->GetUINT32();
+ NPP instance = m_aInstances[ nInstance ]->instance;
+ char* pType = pMessage->GetString();
+ NPStream* pStream = new NPStream;
+ pStream->url = pMessage->GetString();
+ pStream->end = pMessage->GetUINT32();
+ pStream->lastmodified = pMessage->GetUINT32();
+ pStream->pdata = pStream->ndata = pStream->notifyData = NULL;
+ NPBool* pSeekable = (NPBool*)pMessage->GetBytes();
+ m_aNPWrapStreams.push_back( pStream );
+ uint16 nStype = NP_ASFILE;
+ NPError aRet = aPluginFuncs.newstream( instance, pType, pStream,
+ *pSeekable, &nStype );
+ medDebug( 1, "pluginapp: NPP_NewStream( %p, %s, %p, %s, %p ) returns %d\n"
+ "stream = { pdata = %p, ndata = %p, url = %s, end = %d, lastmodified = %d, notifyData = %p }\n",
+ instance, pType, pStream, *pSeekable ? "seekable" : "not seekable", &nStype, (int)aRet,
+ pStream->pdata, pStream->ndata, pStream->url, pStream->end, pStream->lastmodified, pStream->notifyData );
+ Respond( pMessage->m_nID,
+ (char*)&aRet, sizeof( aRet ),
+ &nStype, sizeof( nStype ),
+ NULL );
+ delete [] pType;
+ delete [] pSeekable;
+ }
+ break;
+ case eNPP_New:
+ {
+ char* pType = pMessage->GetString();
+ uint16* pMode = (uint16*)pMessage->GetBytes();
+ int16* pArgc = (int16*)pMessage->GetBytes();
+ NPP instance = new NPP_t;
+ instance->pdata = instance->ndata = NULL;
+ ULONG nArgnBytes, nArgvBytes;
+ char* pArgn = (char*)pMessage->GetBytes( nArgnBytes );
+ char* pArgv = (char*)pMessage->GetBytes( nArgvBytes );
+ ULONG nSaveBytes;
+ char* pSavedData = (char*)pMessage->GetBytes( nSaveBytes );
+ ConnectorInstance* pInst =
+ new ConnectorInstance( instance, pType,
+ *pArgc,
+ pArgn, nArgnBytes,
+ pArgv, nArgvBytes,
+ pSavedData, nSaveBytes );
+ m_aInstances.push_back( pInst );
+ NPError aRet;
+ aRet = aPluginFuncs.newp( pInst->pMimeType, instance, *pMode, *pArgc,
+ pInst->nArg ? pInst->argn : NULL,
+ pInst->nArg ? pInst->argv : NULL,
+ ( nSaveBytes == 4 && *(UINT32*)pSavedData == 0 ) ?
+ &(pInst->aData) : NULL );
+ medDebug( 1, "pluginapp: NPP_New( %s, %p, %d, %d, %p, %p, %p ) returns %d\n",
+ pInst->pMimeType,
+ instance, *pMode, pInst->nArg, pInst->argn, pInst->argv, &pInst->aData,
+ (int) aRet );
+#if OSL_DEBUG_LEVEL > 1
+ for( int i = 0; i < pInst->nArg; i++ )
+ medDebug( 1, " \"%s\"=\"%s\"\n", pInst->argn[i], pInst->argv[i] );
+#endif
+
+ #ifdef ENABLE_GTK
+ // check if XEMBED is to be used
+ // ask for Bool. there seems to be no clear definition whether the
+ // return value should be an int or unsigned char
+ // int can hold both and will be nonzero in case of "true"
+ if( aPluginFuncs.getvalue )
+ {
+ int bNeedsXEmbed = 0;
+ NPError error = aPluginFuncs.getvalue( instance, NPPVpluginNeedsXEmbed, (void *)&bNeedsXEmbed );
+ if( error == NPERR_NO_ERROR )
+ pInst->bShouldUseXEmbed = (bNeedsXEmbed != 0);
+ medDebug( 1, "should use xembed = %s\n", pInst->bShouldUseXEmbed ? "true" : "false" );
+ }
+ #endif
+
+ Respond( pMessage->m_nID,
+ (char*)&aRet, sizeof( aRet ),
+ NULL );
+ delete [] pMode;
+ delete [] pArgc;
+ delete [] pType;
+ }
+ break;
+ case eNPP_SetWindow:
+ {
+ UINT32 nInstance = pMessage->GetUINT32();
+ ConnectorInstance* pInst= m_aInstances[ nInstance ];
+ NPWindow* pWindow = (NPWindow*)pMessage->GetBytes();
+
+ if( pWindow->width < 1 )
+ pWindow->width = 1;
+ if( pWindow->height < 1 )
+ pWindow->height = 1;
+
+ #ifdef ENABLE_GTK
+ if( pInst->bShouldUseXEmbed )
+ {
+ if( ! pInst->pGtkWidget )
+ {
+ medDebug( 1, "creating gtk plug and socket\n" );
+
+ pInst->pGtkWindow = gtk_plug_new((GdkNativeWindow)reinterpret_cast<sal_uIntPtr>(pWindow->window));
+ gtk_widget_show( pInst->pGtkWindow );
+ pInst->pGtkWidget = gtk_socket_new();
+ gtk_widget_show( pInst->pGtkWidget );
+ gtk_container_add( GTK_CONTAINER(pInst->pGtkWindow), pInst->pGtkWidget );
+ gtk_widget_show_all( pInst->pGtkWindow );
+ pInst->window.window = (void *)gtk_socket_get_id( GTK_SOCKET(pInst->pGtkWidget ) );
+
+ XSync( pAppDisplay, False );
+
+ XMapWindow( pAppDisplay, GDK_WINDOW_XWINDOW(pInst->pGtkWindow->window) );
+
+ XSync( pAppDisplay, False );
+ }
+
+ // update widget size; alas out parent is not yet really XEMBED conformant
+ gtk_widget_set_size_request( pInst->pGtkWidget, pWindow->width, pWindow->height );
+ gtk_window_resize( GTK_WINDOW(pInst->pGtkWindow), pWindow->width, pWindow->height );
+
+ GdkScreen* pGdkScreen = gtk_widget_get_screen( pInst->pGtkWidget );
+ Screen* pScreen = ScreenOfDisplay( pAppDisplay, gdk_screen_get_number( pGdkScreen ) );
+
+ pInst->window.x = 0;
+ pInst->window.y = 0;
+ pInst->window.width = pWindow->width;
+ pInst->window.height = pWindow->height;
+ pInst->window.clipRect.left = 0;
+ pInst->window.clipRect.top = 0;
+ pInst->window.clipRect.right = pWindow->width;
+ pInst->window.clipRect.bottom = pWindow->height;
+ pInst->window.ws_info = &pInst->ws_info;
+ pInst->window.type = NPWindowTypeWindow;
+ pInst->ws_info.type = NP_SETWINDOW;
+ pInst->ws_info.display = pAppDisplay;
+ pInst->ws_info.visual = DefaultVisualOfScreen( pScreen );
+ pInst->ws_info.colormap = DefaultColormapOfScreen( pScreen );
+ pInst->ws_info.depth = DefaultDepthOfScreen( pScreen );
+ }
+ else
+ #endif
+ {
+ if( ! pInst->pWidget )
+ {
+ pInst->pWidget = CreateNewShell( &(pInst->pShell), (XLIB_Window)pWindow->window );
+ }
+
+ // fill in NPWindow and NPCallbackStruct
+ pInst->window.window = (void*)XtWindow( (Widget)pInst->pWidget );
+ pInst->window.x = 0;
+ pInst->window.y = 0;
+ pInst->window.width = pWindow->width;
+ pInst->window.height = pWindow->height;
+ pInst->window.clipRect.left = 0;
+ pInst->window.clipRect.top = 0;
+ pInst->window.clipRect.right = pWindow->width;
+ pInst->window.clipRect.bottom = pWindow->height;
+ pInst->window.ws_info = &pInst->ws_info;
+ pInst->window.type = NPWindowTypeWindow;
+ pInst->ws_info.type = NP_SETWINDOW;
+ pInst->ws_info.display = XtDisplay( (Widget)pInst->pWidget );
+ pInst->ws_info.visual = DefaultVisualOfScreen( XtScreen( (Widget)pInst->pWidget ) );
+ pInst->ws_info.colormap = DefaultColormapOfScreen( XtScreen( (Widget)pInst->pWidget ) );
+ pInst->ws_info.depth = DefaultDepthOfScreen( XtScreen( (Widget)pInst->pWidget ) );
+
+ XtResizeWidget( (Widget)pInst->pShell,
+ pInst->window.width,
+ pInst->window.height,
+ 0 );
+ XtResizeWidget( (Widget)pInst->pWidget,
+ pInst->window.width,
+ pInst->window.height,
+ 0 );
+ }
+
+ NPError aRet = aPluginFuncs.setwindow( pInst->instance, &pInst->window );
+ medDebug( 1, "pluginapp: NPP_SetWindow returns %d\n", (int) aRet );
+ Respond( pMessage->m_nID,
+ (char*)&aRet, sizeof( aRet ),
+ NULL );
+ delete [] (char*)pWindow;
+ }
+ break;
+ case eNPP_StreamAsFile:
+ {
+ UINT32 nInstance = pMessage->GetUINT32();
+ NPP instance = m_aInstances[ nInstance ]->instance;
+ UINT32 nFileID = pMessage->GetUINT32();
+ NPStream* pStream = m_aNPWrapStreams[ nFileID ];
+ char* fname = pMessage->GetString();
+ medDebug( 1, "pluginapp: NPP_StreamAsFile %s\n", fname );
+ aPluginFuncs.asfile( instance, pStream, fname );
+ delete [] fname;
+ }
+ break;
+ case eNPP_URLNotify:
+ {
+ UINT32 nInstance = pMessage->GetUINT32();
+ NPP instance = m_aInstances[ nInstance ]->instance;
+ char* url = pMessage->GetString();
+ NPReason* pReason = (NPReason*)pMessage->GetBytes();
+ void** notifyData = (void**)pMessage->GetBytes();
+ aPluginFuncs.urlnotify( instance, url, *pReason, *notifyData );
+ delete [] url;
+ delete [] pReason;
+ delete [] notifyData;
+ }
+ break;
+ case eNPP_WriteReady:
+ {
+ UINT32 nInstance = pMessage->GetUINT32();
+ NPP instance = m_aInstances[ nInstance ]->instance;
+ UINT32 nFileID = pMessage->GetUINT32();
+ NPStream* pStream = m_aNPWrapStreams[ nFileID ];
+ int32 nRet = aPluginFuncs.writeready( instance, pStream );
+
+ medDebug( 1, "pluginapp: NPP_WriteReady( %p, %p ) (stream id = %d) returns %d\n",
+ instance, pStream, nFileID, nRet );
+
+ Respond( pMessage->m_nID,
+ (char*)&nRet, sizeof( nRet ),
+ NULL );
+ }
+ break;
+ case eNPP_Write:
+ {
+ UINT32 nInstance = pMessage->GetUINT32();
+ NPP instance = m_aInstances[ nInstance ]->instance;
+ UINT32 nFileID = pMessage->GetUINT32();
+ NPStream* pStream = m_aNPWrapStreams[ nFileID ];
+ int32 offset = pMessage->GetUINT32();
+ ULONG len;
+ char* buffer = (char*)pMessage->GetBytes( len );
+ int32 nRet = aPluginFuncs.write( instance, pStream, offset, len, buffer );
+
+ medDebug( 1,"pluginapp: NPP_Write( %p, %p, %d, %d, %p ) returns %d\n"
+ "stream = { pdata = %p, ndata = %p, url = %s, end = %d, lastmodified = %d, notifyData = %p }\n",
+ instance, pStream, offset, len, buffer, nRet,
+ pStream->pdata, pStream->ndata, pStream->url, pStream->end, pStream->lastmodified, pStream->notifyData );
+
+ Respond( pMessage->m_nID,
+ (char*)&nRet, sizeof( nRet ),
+ NULL );
+ delete [] buffer;
+ }
+ break;
+ case eNPP_GetMIMEDescription:
+ {
+ if( ! pNPP_GetMIMEDescription )
+ pNPP_GetMIMEDescription = (char*(*)())
+ osl_getAsciiFunctionSymbol( pPluginLib, "NPP_GetMIMEDescription" );
+ char* pMIME = pNPP_GetMIMEDescription();
+ Respond( pMessage->m_nID,
+ POST_STRING( pMIME ),
+ NULL );
+ }
+ break;
+ case eNPP_Initialize:
+ {
+
+ pNP_Initialize =
+ (NPError(*)(NPNetscapeFuncs*, NPPluginFuncs*))
+ osl_getAsciiFunctionSymbol( pPluginLib, "NP_Initialize" );
+ medDebug( !pNP_Initialize, "no NP_Initialize, %s\n", dlerror() );
+ pNP_Shutdown = (NPError(*)())
+ osl_getAsciiFunctionSymbol( pPluginLib, "NP_Shutdown" );
+ medDebug( !pNP_Initialize, "no NP_Shutdown, %s\n", dlerror() );
+
+ medDebug( 1, "entering NP_Initialize\n" );
+ NPError aRet = pNP_Initialize( &aNetscapeFuncs, &aPluginFuncs );
+ medDebug( 1, "pluginapp: NP_Initialize returns %d\n", (int) aRet );
+ Respond( pMessage->m_nID, (char*)&aRet, sizeof( aRet ), NULL );
+ }
+ break;
+ case eNPP_Shutdown:
+ {
+ write( wakeup_fd[1], "xxxx", 4 );
+ }
+ break;
+ default:
+ medDebug( 1, "caught unknown NPP request %d\n", nCommand );
+ break;
+ }
+ delete pMessage;
+ }
+ return 0;
+}
+
+void LoadAdditionalLibs( const char* _pPluginLib )
+{
+ medDebug( 1, "LoadAdditionalLibs %s\n", _pPluginLib );
+
+ if( ! strncmp( _pPluginLib, "libflashplayer.so", 17 ) )
+ {
+ /* #b4951312# flash 7 implicitly assumes a gtk application
+ * if the API version is greater or equal to 12 (probably
+ * because they think they run in mozilla then). In that
+ * case they try to find gtk within the process and crash
+ * when they don't find it.
+ */
+ aNetscapeFuncs.version = 11;
+ aPluginFuncs.version = 11;
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/plugin/unx/nppapi.cxx b/extensions/source/plugin/unx/nppapi.cxx
new file mode 100644
index 000000000000..c6dd6a59895d
--- /dev/null
+++ b/extensions/source/plugin/unx/nppapi.cxx
@@ -0,0 +1,630 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+
+#ifdef AIX
+#define _LINUX_SOURCE_COMPAT
+#include <sys/timer.h>
+#undef _LINUX_SOURCE_COMPAT
+#endif
+
+#if STLPORT_VERSION>=321
+#include <cstdarg>
+#endif
+
+#include <plugin/impl.hxx>
+#include <vcl/svapp.hxx>
+
+std::vector<PluginConnector*> PluginConnector::allConnectors;
+
+PluginConnector::PluginConnector( int nSocket ) :
+ Mediator( nSocket )
+{
+ allConnectors.push_back( this );
+ SetNewMessageHdl( LINK( this, PluginConnector, NewMessageHdl ) );
+}
+
+PluginConnector::~PluginConnector()
+{
+ osl::MutexGuard aGuard( m_aUserEventMutex );
+ for( std::vector< PluginConnector* >::iterator it = allConnectors.begin();
+ it != allConnectors.end(); ++it )
+ {
+ if( *it == this )
+ {
+ allConnectors.erase( it );
+ break;
+ }
+ }
+}
+
+IMPL_LINK( PluginConnector, NewMessageHdl, Mediator*, /*pMediator*/ )
+{
+ osl::MutexGuard aGuard( m_aUserEventMutex );
+ bool bFound = false;
+ for( std::vector< PluginConnector* >::iterator it = allConnectors.begin();
+ it != allConnectors.end() && bFound == false; ++it )
+ {
+ if( *it == this )
+ bFound = true;
+ }
+ if( ! bFound )
+ return 0;
+ Application::PostUserEvent( LINK( this, PluginConnector, WorkOnNewMessageHdl ) );
+ return 0;
+}
+
+IMPL_LINK( PluginConnector, WorkOnNewMessageHdl, Mediator*, /*pMediator*/ )
+{
+ bool bFound = false;
+ for( std::vector< PluginConnector* >::iterator it = allConnectors.begin();
+ it != allConnectors.end() && bFound == false; ++it )
+ {
+ if( *it == this )
+ bFound = true;
+ }
+ if( ! bFound )
+ return 0;
+/*
+ {
+ osl::MutexGuard aGuard( m_aUserEventMutex );
+ m_aUserEventIDs.pop_front();
+ }
+*/
+
+ MediatorMessage* pMessage;
+ CommandAtoms nCommand;
+ while( (pMessage = GetNextMessage( FALSE )) )
+ {
+ nCommand = (CommandAtoms)pMessage->GetUINT32();
+ medDebug( 1, "%s\n", GetCommandName( nCommand ) );
+ switch( nCommand )
+ {
+ case eNPN_GetURL:
+ {
+ UINT32 nInstance = pMessage->GetUINT32();
+ NPP instance = m_aInstances[ nInstance ]->instance;
+ char* pUrl = pMessage->GetString();
+ char* pWindow = pMessage->GetString();
+ NPError aRet = NPN_GetURL( instance, pUrl, pWindow );
+ Respond( pMessage->m_nID,
+ (char*)(&aRet), sizeof( NPError ), NULL );
+ delete [] pUrl;
+ delete [] pWindow;
+ }
+ break;
+ case eNPN_GetURLNotify:
+ {
+ UINT32 nInstance = pMessage->GetUINT32();
+ NPP instance = m_aInstances[ nInstance ]->instance;
+ char* pUrl = pMessage->GetString();
+ char* pWindow = pMessage->GetString();
+ void** pNotifyData = (void**)pMessage->GetBytes();
+ NPError aRet = NPN_GetURLNotify( instance, pUrl, pWindow,
+ *pNotifyData );
+ Respond( pMessage->m_nID,
+ (char*)(&aRet), sizeof( NPError ), NULL );
+ delete [] pUrl;
+ delete [] pWindow;
+ delete [] pNotifyData;
+ }
+ break;
+ case eNPN_DestroyStream:
+ {
+ UINT32 nInstance = pMessage->GetUINT32();
+ NPP instance = m_aInstances[ nInstance ]->instance;
+ UINT32 nFileID = pMessage->GetUINT32();
+ char* pUrl = pMessage->GetString();
+ NPError* pReason = (NPError*)pMessage->GetBytes();
+ NPError aRet = NPERR_FILE_NOT_FOUND;
+ if( nFileID < static_cast<UINT32>(m_aNPWrapStreams.size()) )
+ {
+ if( ! strcmp( m_aNPWrapStreams[ nFileID ]->url, pUrl ) )
+ {
+ aRet =
+ NPN_DestroyStream( instance, m_aNPWrapStreams[ nFileID ],
+ *pReason );
+ m_aNPWrapStreams.erase( m_aNPWrapStreams.begin() + nFileID );
+ }
+ else
+ medDebug( 1, "StreamID %d has incoherent urls %s and %s\n",
+ nFileID, pUrl, m_aNPWrapStreams[ nFileID ]->url );
+ }
+ else
+ medDebug( 1, "Nonexistent StreamID %d\n", nFileID );
+
+ Respond( pMessage->m_nID,
+ (char*)(&aRet), sizeof( NPError ), NULL );
+
+ delete [] pUrl;
+ delete [] pReason;
+ }
+ break;
+ case eNPN_NewStream:
+ {
+ UINT32 nInstance = pMessage->GetUINT32();
+ NPP instance = m_aInstances[ nInstance ]->instance;
+ NPMIMEType pType = pMessage->GetString();
+ char* pTarget = pMessage->GetString();
+
+ NPStream* pStream = NULL;
+
+ NPError aRet = NPN_NewStream( instance, pType, pTarget, &pStream );
+
+ if( aRet != NPERR_NO_ERROR )
+ {
+ UINT32 nDummy = 0;
+ Respond( pMessage->m_nID,
+ (char*)&aRet, sizeof( aRet ),
+ "", 0,
+ &nDummy, sizeof(UINT32),
+ &nDummy, sizeof(UINT32),
+ NULL );
+ }
+ else
+ {
+ m_aNPWrapStreams.push_back( pStream );
+
+ ULONG nLen = strlen( pStream->url );
+ Respond( pMessage->m_nID,
+ (char*)&aRet, sizeof( aRet ),
+ pStream->url, nLen,
+ &pStream->end, sizeof(UINT32),
+ &pStream->lastmodified, sizeof(UINT32),
+ NULL );
+ }
+
+ delete [] pTarget;
+ delete [] pType;
+ }
+ break;
+ case eNPN_PostURLNotify:
+ {
+ UINT32 nInstance = pMessage->GetUINT32();
+ NPP instance = m_aInstances[ nInstance ]->instance;
+ char* pUrl = pMessage->GetString();
+ char* pTarget = pMessage->GetString();
+ UINT32 nLen = pMessage->GetUINT32();
+ char* pBuf = (char*)pMessage->GetBytes();
+ NPBool* pFile = (NPBool*)pMessage->GetBytes();
+ void** pNData = (void**)pMessage->GetBytes();
+ NPError aRet =
+ NPN_PostURLNotify( instance, pUrl, pTarget, nLen, pBuf, *pFile, *pNData );
+ Respond( pMessage->m_nID, (char*)&aRet, sizeof( aRet ), NULL );
+ delete [] pUrl;
+ delete [] pTarget;
+ delete [] pBuf;
+ delete [] pFile;
+ delete [] pNData;
+ }
+ break;
+ case eNPN_PostURL:
+ {
+ UINT32 nInstance = pMessage->GetUINT32();
+ NPP instance = m_aInstances[ nInstance ]->instance;
+ char* pUrl = pMessage->GetString();
+ char* pWindow = pMessage->GetString();
+ UINT32 nLen = pMessage->GetUINT32();
+ char* pBuf = (char*)pMessage->GetBytes();
+ NPBool* pFile = (NPBool*)pMessage->GetBytes();
+ NPError aRet =
+ NPN_PostURL( instance, pUrl, pWindow, nLen, pBuf, *pFile );
+ Respond( pMessage->m_nID, (char*)&aRet, sizeof( aRet ), NULL );
+ delete [] pUrl;
+ delete [] pWindow;
+ delete [] pBuf;
+ delete [] pFile;
+ }
+ break;
+ case eNPN_RequestRead:
+ {
+ UINT32 nFileID = pMessage->GetUINT32();
+ NPStream* pStream = m_aNPWrapStreams[ nFileID ];
+ UINT32 nRanges = pMessage->GetUINT32();
+ UINT32* pArray = (UINT32*)pMessage->GetBytes();
+ // build ranges table
+ NPByteRange* pFirst = new NPByteRange;
+ NPByteRange* pRun = pFirst;
+ for( UINT32 n = 0; n < nRanges; n++ )
+ {
+ pRun->offset = pArray[ 2*n ];
+ pRun->length = pArray[ 2*n+1 ];
+ pRun->next = n < nRanges-1 ? new NPByteRange : NULL;
+ pRun = pRun->next;
+ }
+ NPError aRet = NPN_RequestRead( pStream, pFirst );
+ Respond( pMessage->m_nID, (char*)&aRet, sizeof( aRet ), NULL );
+ while( pFirst )
+ {
+ pRun = pFirst->next;
+ delete pFirst;
+ pFirst = pRun;
+ }
+ delete [] pArray;
+ }
+ break;
+ case eNPN_Status:
+ {
+ UINT32 nInstance = pMessage->GetUINT32();
+ NPP instance = m_aInstances[ nInstance ]->instance;
+ char* pString = pMessage->GetString();
+ NPN_Status( instance, pString );
+ delete [] pString;
+ }
+ break;
+ case eNPN_Version:
+ {
+ int major, minor, net_major, net_minor;
+ NPN_Version( &major, &minor, &net_major, &net_minor );
+ Respond( pMessage->m_nID,
+ (char*)&major, sizeof( int ),
+ &minor, sizeof( int ),
+ &net_major, sizeof( int ),
+ &net_minor, sizeof( int ),
+ NULL );
+ }
+ break;
+ case eNPN_Write:
+ {
+ UINT32 nInstance = pMessage->GetUINT32();
+ NPP instance = m_aInstances[ nInstance ]->instance;
+ UINT32 nFileID = pMessage->GetUINT32();
+ NPStream* pStream = m_aNPWrapStreams[ nFileID ];
+ INT32 nLen = pMessage->GetUINT32();
+ void* pBuffer = pMessage->GetBytes();
+ INT32 nRet = NPN_Write( instance, pStream, nLen, pBuffer );
+ Respond( pMessage->m_nID,
+ (char*)&nRet, sizeof( nRet ),
+ NULL );
+ delete [] (char*)pBuffer;
+ delete instance;
+ }
+ break;
+ case eNPN_UserAgent:
+ {
+ UINT32 nInstance = pMessage->GetUINT32();
+ NPP instance = m_aInstances[ nInstance ]->instance;
+ const char* pAnswer = NPN_UserAgent( instance );
+ Respond( pMessage->m_nID,
+ (char*)pAnswer, strlen( pAnswer ),
+ NULL );
+ }
+ break;
+ default:
+ medDebug( 1, "caught unknown NPN request %d\n", nCommand );
+ }
+
+ delete pMessage;
+ }
+ return 0;
+}
+
+#define GET_INSTANCE() \
+ UINT32 nInstance; \
+ nInstance = GetNPPID( instance );
+
+#define GET_INSTANCE_RET( err ) \
+ GET_INSTANCE() \
+ if( nInstance == PluginConnector::UnknownNPPID ) \
+ return err
+
+
+#define POST_INSTANCE() (char*)&nInstance, sizeof( nInstance )
+
+NPError UnxPluginComm::NPP_Destroy( NPP instance, NPSavedData** save )
+{
+ NPError aRet = NPERR_GENERIC_ERROR;
+ GET_INSTANCE_RET( aRet );
+ MediatorMessage* pMes =
+ Transact( eNPP_Destroy,
+ POST_INSTANCE(),
+ NULL );
+ if( ! pMes )
+ return NPERR_GENERIC_ERROR;
+ delete pMes;
+
+ pMes = Transact( eNPP_DestroyPhase2,
+ POST_INSTANCE(),
+ NULL );
+ if( ! pMes )
+ return NPERR_GENERIC_ERROR;
+
+ aRet = GetNPError( pMes );
+ ULONG nSaveBytes;
+ void* pSaveData = pMes->GetBytes( nSaveBytes );
+ if( nSaveBytes == 4 && *(UINT32*)pSaveData == 0 )
+ *save = NULL;
+ else
+ {
+ *save = new NPSavedData;
+ (*save)->len = nSaveBytes;
+ (*save)->buf = pSaveData;
+ }
+ delete pMes;
+
+ return aRet;
+}
+
+NPError UnxPluginComm::NPP_DestroyStream( NPP instance, NPStream* stream, NPError reason )
+{
+ NPError aRet = NPERR_GENERIC_ERROR;
+ GET_INSTANCE_RET( aRet );
+ UINT32 nFileID = GetStreamID( stream );
+ if( nFileID == PluginConnector::UnknownStreamID )
+ return NPERR_GENERIC_ERROR;
+
+ MediatorMessage* pMes =
+ Transact( eNPP_DestroyStream,
+ POST_INSTANCE(),
+ &nFileID, sizeof( nFileID ),
+ &reason, sizeof( reason ),
+ NULL );
+ m_aNPWrapStreams.erase( m_aNPWrapStreams.begin() + nFileID );
+ if( ! pMes )
+ return NPERR_GENERIC_ERROR;
+
+ aRet = GetNPError( pMes );
+ delete pMes;
+ return aRet;
+}
+
+void* UnxPluginComm::NPP_GetJavaClass()
+{
+ return NULL;
+}
+
+NPError UnxPluginComm::NPP_Initialize()
+{
+ MediatorMessage* pMes =
+ Transact( eNPP_Initialize,
+ NULL );
+ if( ! pMes )
+ return NPERR_GENERIC_ERROR;
+
+ NPError aRet = GetNPError( pMes );
+ delete pMes;
+ return aRet;
+}
+
+NPError UnxPluginComm::NPP_New( NPMIMEType pluginType, NPP instance, uint16 mode, int16 argc,
+ char* argn[], char* argv[], NPSavedData *saved )
+{
+ m_aInstances.push_back(
+ new ConnectorInstance( instance, pluginType, 0,
+ NULL, 0, NULL, 0,
+ saved ? (char*)saved->buf : NULL,
+ saved ? saved->len : 0 ) );
+
+ char *pArgnBuf, *pArgvBuf;
+ size_t nArgnLen = 0, nArgvLen = 0;
+ int i;
+ for( i = 0; i < argc; i++ )
+ {
+ nArgnLen += strlen( argn[i] ) +1;
+ nArgvLen += strlen( argv[i] ) +1;
+ }
+ pArgnBuf = new char[ nArgnLen ];
+ pArgvBuf = new char[ nArgvLen ];
+ char* pRunArgn = pArgnBuf;
+ char* pRunArgv = pArgvBuf;
+ for( i = 0; i < argc; i++ )
+ {
+ strcpy( pRunArgn, argn[i] );
+ strcpy( pRunArgv, argv[i] );
+ pRunArgn += strlen( argn[i] ) +1;
+ pRunArgv += strlen( argv[i] ) +1;
+ }
+
+ MediatorMessage* pMes;
+ if( saved )
+ pMes =
+ Transact( eNPP_New,
+ pluginType, strlen( pluginType ),
+ &mode, sizeof( mode ),
+ &argc, sizeof( argc ),
+ pArgnBuf, nArgnLen,
+ pArgvBuf, nArgvLen,
+ saved->buf, static_cast<size_t>(saved->len),
+ NULL );
+ else
+ pMes =
+ Transact( eNPP_New,
+ pluginType, strlen( pluginType ),
+ &mode, sizeof( mode ),
+ &argc, sizeof( argc ),
+ pArgnBuf, nArgnLen,
+ pArgvBuf, nArgvLen,
+ "0000", size_t(4),
+ NULL );
+ delete [] pArgnBuf;
+ delete [] pArgvBuf;
+ if( ! pMes )
+ return NPERR_GENERIC_ERROR;
+
+ NPError aRet = GetNPError( pMes );
+ delete pMes;
+
+ return aRet;
+}
+
+NPError UnxPluginComm::NPP_NewStream( NPP instance, NPMIMEType type, NPStream* stream,
+ NPBool seekable, uint16* stype )
+{
+ NPError aRet = NPERR_GENERIC_ERROR;
+ GET_INSTANCE_RET( aRet );
+
+ m_aNPWrapStreams.push_back( stream );
+ MediatorMessage* pMes =
+ Transact( eNPP_NewStream,
+ POST_INSTANCE(),
+ type, strlen( type ),
+ stream->url, strlen( stream->url ),
+ &stream->end, sizeof( stream->end ),
+ &stream->lastmodified, sizeof( stream->lastmodified ),
+ &seekable, sizeof( seekable ),
+ NULL );
+
+ if( ! pMes )
+ return NPERR_GENERIC_ERROR;
+
+ aRet = GetNPError( pMes );
+ uint16* pSType = (uint16*)pMes->GetBytes();
+ *stype = *pSType;
+
+ delete [] pSType;
+ delete pMes;
+ return aRet;
+}
+
+void UnxPluginComm::NPP_Print( NPP /*instance*/, NPPrint* /*platformPrint*/ )
+{
+}
+
+NPError UnxPluginComm::NPP_SetWindow( NPP instance, NPWindow* window )
+{
+ NPError aRet = NPERR_GENERIC_ERROR;
+ GET_INSTANCE_RET( aRet );
+
+ MediatorMessage* pMes =
+ Transact( eNPP_SetWindow,
+ POST_INSTANCE(),
+ window, sizeof( NPWindow ),
+ NULL );
+ if( ! pMes )
+ return NPERR_GENERIC_ERROR;
+
+ aRet = GetNPError( pMes );
+ delete pMes;
+ return aRet;
+}
+
+void UnxPluginComm::NPP_Shutdown()
+{
+ Send( eNPP_Shutdown, NULL );
+}
+
+void UnxPluginComm::NPP_StreamAsFile( NPP instance, NPStream* stream, const char* fname )
+{
+ GET_INSTANCE();
+ UINT32 nFileID = GetStreamID( stream );
+ if( nFileID == PluginConnector::UnknownStreamID )
+ return;
+
+ Send( eNPP_StreamAsFile,
+ POST_INSTANCE(),
+ &nFileID, sizeof( nFileID ),
+ fname, strlen( fname ),
+ NULL );
+}
+
+void UnxPluginComm::NPP_URLNotify( NPP instance, const char* url, NPReason reason, void* notifyData )
+{
+ GET_INSTANCE();
+
+ Send( eNPP_URLNotify,
+ POST_INSTANCE(),
+ url, strlen( url ),
+ &reason, sizeof( reason ),
+ &notifyData, sizeof( void* ),
+ NULL );
+}
+
+int32 UnxPluginComm::NPP_Write( NPP instance, NPStream* stream, int32 offset, int32 len, void* buffer )
+{
+ GET_INSTANCE_RET( -1 );
+ UINT32 nFileID = GetStreamID( stream );
+ if( nFileID == PluginConnector::UnknownStreamID )
+ return -1;
+
+ MediatorMessage* pMes =
+ Transact( eNPP_Write,
+ POST_INSTANCE(),
+ &nFileID, sizeof( nFileID ),
+ &offset, sizeof( offset ),
+ buffer, static_cast<size_t>(len),
+ NULL );
+ if( ! pMes )
+ return 0;
+
+ int32 aRet = pMes->GetUINT32();
+ delete pMes;
+
+ return aRet;
+}
+
+int32 UnxPluginComm::NPP_WriteReady( NPP instance, NPStream* stream )
+{
+ GET_INSTANCE_RET( -1 );
+ UINT32 nFileID = GetStreamID( stream );
+ if( nFileID == PluginConnector::UnknownStreamID )
+ return -1;
+
+ MediatorMessage* pMes =
+ Transact( eNPP_WriteReady,
+ POST_INSTANCE(),
+ &nFileID, sizeof( nFileID ),
+ NULL );
+
+ if( ! pMes )
+ return 0;
+
+ int32 aRet = pMes->GetUINT32();
+ delete pMes;
+
+ return aRet;
+}
+
+char* UnxPluginComm::NPP_GetMIMEDescription()
+{
+ static char* pDesc = NULL;
+ MediatorMessage* pMes =
+ Transact( eNPP_GetMIMEDescription,
+ NULL );
+ if( ! pMes )
+ return (char*)"";
+
+ if( pDesc )
+ delete [] pDesc;
+ pDesc = pMes->GetString();
+ delete pMes;
+ return pDesc;
+}
+
+NPError UnxPluginComm::NPP_GetValue( NPP /*instance*/, NPPVariable /*variable*/, void* /*value*/ )
+{
+ return 0;
+}
+
+NPError UnxPluginComm::NPP_SetValue( NPP /*instance*/, NPNVariable /*variable*/, void* /*value*/ )
+{
+ return 0;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/plugin/unx/npwrap.cxx b/extensions/source/plugin/unx/npwrap.cxx
new file mode 100644
index 000000000000..04f4bbbacf5a
--- /dev/null
+++ b/extensions/source/plugin/unx/npwrap.cxx
@@ -0,0 +1,522 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+#ifdef AIX
+#define _LINUX_SOURCE_COMPAT
+#include <sys/timer.h>
+#undef _LINUX_SOURCE_COMPAT
+#endif
+#include <errno.h>
+#include <dlfcn.h>
+#include <unistd.h>
+#include <sys/poll.h>
+#include <fcntl.h>
+#include <signal.h>
+
+#include <plugin/unx/plugcon.hxx>
+
+#include <osl/file.h>
+#include <osl/module.h>
+
+PluginConnector* pConnector = NULL;
+
+int nAppArguments = 0;
+char** pAppArguments = NULL;
+Display* pAppDisplay = NULL;
+Display* pXtAppDisplay = NULL;
+
+extern oslModule pPluginLib;
+extern NPError (*pNP_Shutdown)();
+
+void LoadAdditionalLibs(const char*);
+
+XtAppContext app_context;
+Widget topLevel = NULL, topBox = NULL;
+int wakeup_fd[2] = { 0, 0 };
+static bool bPluginAppQuit = false;
+
+static long GlobalConnectionLostHdl( void* /*pInst*/, void* /*pArg*/ )
+{
+ medDebug( 1, "pluginapp exiting due to connection lost\n" );
+
+ write( wakeup_fd[1], "xxxx", 4 );
+ return 0;
+}
+
+extern "C"
+{
+ static int plugin_x_error_handler( Display*, XErrorEvent* )
+ {
+ return 0;
+ }
+
+ #ifndef ENABLE_GTK
+ static void ThreadEventHandler( XtPointer /*client_data*/, int* /*source*/, XtInputId* id )
+ {
+ char buf[256];
+ // clear pipe
+ int len, nLast = -1;
+
+ while( (len = read( wakeup_fd[0], buf, sizeof( buf ) ) ) > 0 )
+ nLast = len-1;
+ if( ! bPluginAppQuit )
+ {
+ if( ( nLast == -1 || buf[nLast] != 'x' ) && pConnector )
+ pConnector->CallWorkHandler();
+ else
+ {
+ // it seems you can use XtRemoveInput only
+ // safely from within the callback
+ // why is that ?
+ medDebug( 1, "removing wakeup pipe\n" );
+ XtRemoveInput( *id );
+ XtAppSetExitFlag( app_context );
+ bPluginAppQuit = true;
+
+ delete pConnector;
+ pConnector = NULL;
+ }
+ }
+ }
+ #endif
+}
+
+
+IMPL_LINK( PluginConnector, NewMessageHdl, Mediator*, /*pMediator*/ )
+{
+ medDebug( 1, "new message handler\n" );
+ write( wakeup_fd[1], "cccc", 4 );
+ return 0;
+
+}
+
+Widget createSubWidget( char* /*pPluginText*/, Widget shell, XLIB_Window aParentWindow )
+{
+ Widget newWidget = XtVaCreateManagedWidget(
+#if defined USE_MOTIF
+ "drawingArea",
+ xmDrawingAreaWidgetClass,
+#else
+ "",
+# if defined DISABLE_XAW
+ compositeWidgetClass,
+# else
+ labelWidgetClass,
+# endif
+#endif
+ shell,
+ XtNwidth, 200,
+ XtNheight, 200,
+ (char *)NULL );
+ XtRealizeWidget( shell );
+ XtRealizeWidget( newWidget );
+
+ medDebug( 1, "Reparenting new widget %x to %x\n", XtWindow( newWidget ), aParentWindow );
+ XReparentWindow( pXtAppDisplay,
+ XtWindow( shell ),
+ aParentWindow,
+ 0, 0 );
+ XtMapWidget( shell );
+ XtMapWidget( newWidget );
+ XRaiseWindow( pXtAppDisplay, XtWindow( shell ) );
+ XSync( pXtAppDisplay, False );
+
+ return newWidget;
+}
+
+void* CreateNewShell( void** pShellReturn, XLIB_Window aParentWindow )
+{
+ XLIB_String n, c;
+ XtGetApplicationNameAndClass(pXtAppDisplay, &n, &c);
+
+ Widget newShell =
+ XtVaAppCreateShell( "pane", c,
+ topLevelShellWidgetClass,
+ pXtAppDisplay,
+ XtNwidth, 200,
+ XtNheight, 200,
+ XtNoverrideRedirect, True,
+ (char *)NULL );
+ *pShellReturn = newShell;
+
+ char pText[1024];
+ sprintf( pText, "starting plugin %s ...", pAppArguments[2] );
+
+ Widget newWidget = createSubWidget( pText, newShell, aParentWindow );
+
+ return newWidget;
+}
+
+static oslModule LoadModule( const char* pPath )
+{
+ ::rtl::OUString sSystemPath( ::rtl::OUString::createFromAscii( pPath ) );
+ ::rtl::OUString sFileURL;
+ osl_getFileURLFromSystemPath( sSystemPath.pData, &sFileURL.pData );
+
+ oslModule pLib = osl_loadModule( sFileURL.pData, SAL_LOADMODULE_LAZY );
+ if( ! pLib )
+ {
+ medDebug( 1, "could not open %s: %s\n", pPath, dlerror() );
+ }
+ return pLib;
+}
+
+// Unix specific implementation
+static void CheckPlugin( const char* pPath )
+{
+ oslModule pLib = LoadModule( pPath );
+
+ char*(*pNP_GetMIMEDescription)() = (char*(*)())
+ osl_getAsciiFunctionSymbol( pLib, "NP_GetMIMEDescription" );
+ if( pNP_GetMIMEDescription )
+ printf( "%s\n", pNP_GetMIMEDescription() );
+ else
+ medDebug( 1, "could not get symbol NP_GetMIMEDescription %s\n", dlerror() );
+
+ osl_unloadModule( pLib );
+}
+
+#if OSL_DEBUG_LEVEL > 1 && defined LINUX
+#include <execinfo.h>
+#endif
+
+extern "C" {
+
+static void signal_handler( int nSig )
+{
+#if OSL_DEBUG_LEVEL > 1
+ fprintf( stderr, "caught signal %d, exiting\n", nSig );
+#ifdef LINUX
+ void* pStack[64];
+ int nStackLevels = backtrace( pStack, SAL_N_ELEMENTS(pStack) );
+ backtrace_symbols_fd( pStack, nStackLevels, STDERR_FILENO );
+#endif
+#endif
+ if( pConnector )
+ {
+ // ensure that a read on the other side will wakeup
+ delete pConnector;
+ pConnector = NULL;
+ }
+
+ _exit(nSig);
+}
+
+#ifdef ENABLE_GTK
+
+static gboolean noClosure( gpointer )
+{
+ return TRUE;
+}
+
+// Xt events
+static gboolean prepareXtEvent( GSource*, gint* )
+{
+ int nMask = XtAppPending( app_context );
+ return (nMask & XtIMAll) != 0;
+}
+
+static gboolean checkXtEvent( GSource* )
+{
+ int nMask = XtAppPending( app_context );
+ return (nMask & XtIMAll) != 0;
+}
+
+static gboolean dispatchXtEvent( GSource*, GSourceFunc, gpointer )
+{
+ XtAppProcessEvent( app_context, XtIMAll );
+ return TRUE;
+}
+
+static GSourceFuncs aXtEventFuncs =
+{
+ prepareXtEvent,
+ checkXtEvent,
+ dispatchXtEvent,
+ NULL,
+ noClosure,
+ NULL
+};
+
+static gboolean pollXtTimerCallback(gpointer)
+{
+ for(int i = 0; i < 5; i++)
+ {
+ if( (XtAppPending(app_context) & (XtIMAll & ~XtIMXEvent)) == 0 )
+ break;
+ XtAppProcessEvent(app_context, XtIMAll & ~XtIMXEvent);
+ }
+ return TRUE;
+}
+
+static gboolean prepareWakeupEvent( GSource*, gint* )
+{
+ struct pollfd aPoll = { wakeup_fd[0], POLLIN, 0 };
+ poll( &aPoll, 1, 0 );
+ return (aPoll.revents & POLLIN ) != 0;
+}
+
+static gboolean checkWakeupEvent( GSource* pSource )
+{
+ gint nDum = 0;
+ return prepareWakeupEvent( pSource, &nDum );
+}
+
+static gboolean dispatchWakeupEvent( GSource*, GSourceFunc, gpointer )
+{
+ char buf[256];
+ // clear pipe
+ int len, nLast = -1;
+
+ while( (len = read( wakeup_fd[0], buf, sizeof( buf ) ) ) > 0 )
+ nLast = len-1;
+ if( ( nLast == -1 || buf[nLast] != 'x' ) && pConnector )
+ pConnector->CallWorkHandler();
+ else
+ {
+ XtAppSetExitFlag( app_context );
+ bPluginAppQuit = true;
+
+ delete pConnector;
+ pConnector = NULL;
+ }
+
+ return TRUE;
+}
+
+static GSourceFuncs aWakeupEventFuncs = {
+ prepareWakeupEvent,
+ checkWakeupEvent,
+ dispatchWakeupEvent,
+ NULL,
+ noClosure,
+ NULL
+};
+
+#endif // GTK
+
+}
+
+int main( int argc, char **argv)
+{
+ struct sigaction aSigAction;
+ aSigAction.sa_handler = signal_handler;
+ sigemptyset( &aSigAction.sa_mask );
+ aSigAction.sa_flags = SA_NOCLDSTOP;
+ sigaction( SIGSEGV, &aSigAction, NULL );
+ sigaction( SIGBUS, &aSigAction, NULL );
+ sigaction( SIGABRT, &aSigAction, NULL );
+ sigaction( SIGTERM, &aSigAction, NULL );
+ sigaction( SIGILL, &aSigAction, NULL );
+
+ int nArg = (argc < 3) ? 1 : 2;
+ char* pBaseName = argv[nArg] + strlen(argv[nArg]);
+ while( pBaseName > argv[nArg] && pBaseName[-1] != '/' )
+ pBaseName--;
+ LoadAdditionalLibs( pBaseName );
+
+ if( argc == 2 )
+ {
+ CheckPlugin(argv[1]);
+ exit(0);
+ }
+ nAppArguments = argc;
+ pAppArguments = argv;
+
+ XSetErrorHandler( plugin_x_error_handler );
+
+ if( pipe( wakeup_fd ) )
+ {
+ medDebug( 1, "could not pipe()\n" );
+ return 1;
+ }
+ // initialize 'wakeup' pipe.
+ int flags;
+
+ // set close-on-exec descriptor flag.
+ if ((flags = fcntl (wakeup_fd[0], F_GETFD)) != -1)
+ {
+ flags |= FD_CLOEXEC;
+ fcntl (wakeup_fd[0], F_SETFD, flags);
+ }
+ if ((flags = fcntl (wakeup_fd[1], F_GETFD)) != -1)
+ {
+ flags |= FD_CLOEXEC;
+ fcntl (wakeup_fd[1], F_SETFD, flags);
+ }
+
+ // set non-blocking I/O flag.
+ if ((flags = fcntl (wakeup_fd[0], F_GETFL)) != -1)
+ {
+ flags |= O_NONBLOCK;
+ fcntl (wakeup_fd[0], F_SETFL, flags);
+ }
+ if ((flags = fcntl (wakeup_fd[1], F_GETFL)) != -1)
+ {
+ flags |= O_NONBLOCK;
+ fcntl (wakeup_fd[1], F_SETFL, flags);
+ }
+
+ pPluginLib = LoadModule( argv[2] );
+ if( ! pPluginLib )
+ {
+ exit(255);
+ }
+ int nSocket = atol( argv[1] );
+
+ #ifdef ENABLE_GTK
+ g_thread_init(NULL);
+ gtk_init(&argc, &argv);
+ #endif
+
+ pConnector = new PluginConnector( nSocket );
+ pConnector->SetConnectionLostHdl( Link( NULL, GlobalConnectionLostHdl ) );
+
+ XtSetLanguageProc( NULL, NULL, NULL );
+
+ XtToolkitInitialize();
+ app_context = XtCreateApplicationContext();
+ pXtAppDisplay = XtOpenDisplay( app_context, NULL, "SOPlugin", "SOPlugin", NULL, 0, &argc, argv );
+
+
+ #ifdef ENABLE_GTK
+ // integrate Xt events into GTK event loop
+ GPollFD aXtPollDesc, aWakeupPollDesc;
+
+ GSource* pXTSource = g_source_new( &aXtEventFuncs, sizeof(GSource) );
+ if( !pXTSource )
+ {
+ medDebug( 1, "could not get Xt GSource" );
+ return 1;
+ }
+
+ g_source_set_priority( pXTSource, GDK_PRIORITY_EVENTS );
+ g_source_set_can_recurse( pXTSource, TRUE );
+ g_source_attach( pXTSource, NULL );
+ aXtPollDesc.fd = ConnectionNumber( pXtAppDisplay );
+ aXtPollDesc.events = G_IO_IN;
+ aXtPollDesc.revents = 0;
+ g_source_add_poll( pXTSource, &aXtPollDesc );
+
+ gint xt_polling_timer_id = g_timeout_add( 25, pollXtTimerCallback, NULL);
+ // Initialize wakeup events listener
+ GSource *pWakeupSource = g_source_new( &aWakeupEventFuncs, sizeof(GSource) );
+ if ( pWakeupSource == NULL )
+ {
+ medDebug( 1, "could not get wakeup source" );
+ return 1;
+ }
+ g_source_set_priority( pWakeupSource, GDK_PRIORITY_EVENTS);
+ g_source_attach( pWakeupSource, NULL );
+ aWakeupPollDesc.fd = wakeup_fd[0];
+ aWakeupPollDesc.events = G_IO_IN;
+ aWakeupPollDesc.revents = 0;
+ g_source_add_poll( pWakeupSource, &aWakeupPollDesc );
+
+ pAppDisplay = gdk_x11_display_get_xdisplay( gdk_display_get_default() );
+ #else
+ pAppDisplay = pXtAppDisplay;
+ XtAppAddInput( app_context,
+ wakeup_fd[0],
+ (XtPointer)XtInputReadMask,
+ ThreadEventHandler, NULL );
+ #endif
+
+ // send that we are ready to go
+ MediatorMessage* pMessage =
+ pConnector->Transact( "init req", 8,
+ NULL );
+ delete pMessage;
+
+#if OSL_DEBUG_LEVEL > 3
+ int nPID = getpid();
+ int nChild = fork();
+ if( nChild == 0 )
+ {
+ char pidbuf[16];
+ char* pArgs[] = { "xterm", "-sl", "2000", "-sb", "-e", "gdb", "pluginapp.bin", pidbuf, NULL };
+ sprintf( pidbuf, "%d", nPID );
+ execvp( pArgs[0], pArgs );
+ _exit(255);
+ }
+ else
+ sleep( 10 );
+#endif
+
+ /*
+ * Loop for events.
+ */
+ // for some reason XtAppSetExitFlag won't quit the application
+ // in ThreadEventHandler most of times; Xt will hang in select
+ // (hat is in XtAppNextEvent). Have our own mainloop instead
+ // of XtAppMainLoop
+ do
+ {
+ #ifdef ENABLE_GTK
+ g_main_context_iteration( NULL, TRUE );
+ #else
+ XtAppProcessEvent( app_context, XtIMAll );
+ #endif
+ } while( ! XtAppGetExitFlag( app_context ) && ! bPluginAppQuit );
+
+ medDebug( 1, "left plugin app main loop\n" );
+
+ #ifdef ENABLE_GTK
+ g_source_remove(xt_polling_timer_id);
+ #endif
+
+ pNP_Shutdown();
+ medDebug( 1, "NP_Shutdown done\n" );
+ osl_unloadModule( pPluginLib );
+ medDebug( 1, "plugin close\n" );
+
+ close( wakeup_fd[0] );
+ close( wakeup_fd[1] );
+
+ return 0;
+}
+
+#ifdef GCC
+extern "C" {
+ void __pure_virtual()
+ {}
+
+ void* __builtin_new( int nBytes )
+ { return malloc(nBytes); }
+ void* __builtin_vec_new( int nBytes )
+ { return malloc(nBytes); }
+ void __builtin_delete( char* pMem )
+ { free(pMem); }
+ void __builtin_vec_delete( char* pMem )
+ { free(pMem); }
+}
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/plugin/unx/plugcon.cxx b/extensions/source/plugin/unx/plugcon.cxx
new file mode 100644
index 000000000000..52be98fdae87
--- /dev/null
+++ b/extensions/source/plugin/unx/plugcon.cxx
@@ -0,0 +1,292 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+
+#ifdef AIX
+#define _LINUX_SOURCE_COMPAT
+#include <sys/timer.h>
+#undef _LINUX_SOURCE_COMPAT
+#endif
+
+#include <plugin/unx/plugcon.hxx>
+
+#include <cstdarg>
+#include <vector>
+
+UINT32 PluginConnector::GetStreamID( NPStream* pStream )
+{
+ size_t nLen = m_aNPWrapStreams.size();
+ for( size_t i = 0; i < nLen; i++ )
+ if( m_aNPWrapStreams[ i ] == pStream )
+ return static_cast<UINT32>(i);
+ medDebug( 1, "Error: NPStream has no ID\n" );
+ return UnknownStreamID;
+}
+
+UINT32 PluginConnector::GetNPPID( NPP instance )
+{
+ size_t nLen = m_aInstances.size();
+ for( size_t i=0; i <nLen; i++ )
+ if( m_aInstances[ i ]->instance == instance )
+ return static_cast<UINT32>(i);
+ medDebug( 1, "Error: NPP has no ID\n" );
+
+ return UnknownNPPID;
+}
+
+ConnectorInstance* PluginConnector::getInstance( NPP instance )
+{
+ size_t nLen = m_aInstances.size();
+ for( size_t i=0; i <nLen; i++ )
+ {
+ ConnectorInstance* pInst = m_aInstances[i];
+ if( pInst->instance == instance )
+ return pInst;
+ }
+ return NULL;
+}
+
+ConnectorInstance* PluginConnector::getInstanceById( UINT32 nInstanceID )
+{
+ return nInstanceID < static_cast<UINT32>(m_aInstances.size()) ? m_aInstances[ nInstanceID ] : NULL;
+}
+
+struct PtrStruct
+{
+ char* pData;
+ ULONG nBytes;
+
+ PtrStruct( char* i_pData, ULONG i_nBytes )
+ : pData( i_pData ), nBytes( i_nBytes ) {}
+};
+
+ULONG PluginConnector::FillBuffer( char*& rpBuffer,
+ const char* pFunction,
+ ULONG nFunctionLen,
+ va_list ap )
+{
+ std::vector< PtrStruct > aList;
+ aList.reserve( 5 );
+
+ ULONG nDataSize = nFunctionLen + sizeof( ULONG );
+ char* pNext;
+
+ do {
+ pNext = va_arg( ap, char* );
+ if( pNext )
+ {
+ aList.push_back( PtrStruct( pNext, va_arg( ap, ULONG ) ) );
+ nDataSize += aList.back().nBytes + sizeof(ULONG);
+ }
+ } while( pNext );
+
+ rpBuffer = new char[ nDataSize ];
+ char* pRun = rpBuffer;
+ memcpy( pRun, &nFunctionLen, sizeof( nFunctionLen ) );
+ pRun += sizeof( nFunctionLen );
+ memcpy( pRun, pFunction, nFunctionLen );
+ pRun += nFunctionLen;
+
+ for( std::vector<PtrStruct>::const_iterator it = aList.begin(); it != aList.end(); ++it )
+ {
+ memcpy( pRun, &it->nBytes, sizeof( ULONG ) );
+ pRun += sizeof( ULONG );
+ memcpy( pRun, it->pData, it->nBytes );
+ pRun += it->nBytes;
+ }
+ return nDataSize;
+}
+
+MediatorMessage* PluginConnector::Transact( const char* pFunction,
+ ULONG nFunctionLen, ... )
+{
+ va_list ap;
+ char* pBuffer;
+
+ va_start( ap, nFunctionLen );
+ ULONG nSize = FillBuffer( pBuffer, pFunction, nFunctionLen, ap );
+ va_end( ap );
+ return TransactMessage( nSize, pBuffer );
+}
+
+MediatorMessage* PluginConnector::Transact( UINT32 nFunction, ... )
+{
+ va_list ap;
+ char* pBuffer;
+
+ va_start( ap, nFunction );
+ ULONG nSize = FillBuffer( pBuffer, (char*)&nFunction, sizeof( nFunction ), ap );
+ va_end( ap );
+ return TransactMessage( nSize, pBuffer );
+}
+
+ULONG PluginConnector::Send( UINT32 nFunction, ... )
+{
+ va_list ap;
+ char* pBuffer;
+
+ va_start( ap, nFunction );
+ ULONG nSize = FillBuffer( pBuffer, (char*)&nFunction, sizeof( nFunction ), ap );
+ va_end( ap );
+ return SendMessage( nSize, pBuffer );
+}
+
+void PluginConnector::Respond( ULONG nID,
+ char* pFunction,
+ ULONG nFunctionLen, ... )
+{
+ va_list ap;
+ char* pBuffer;
+
+ va_start( ap, nFunctionLen );
+ ULONG nSize = FillBuffer( pBuffer, pFunction, nFunctionLen, ap );
+ va_end( ap );
+ SendMessage( nSize, pBuffer, nID | ( 1 << 24 ) );
+}
+
+MediatorMessage* PluginConnector::WaitForAnswer( ULONG nMessageID )
+{
+ if( ! m_bValid )
+ return NULL;
+
+ nMessageID &= 0x00ffffff;
+ while( m_pListener )
+ {
+ {
+ osl::MutexGuard aGuard( m_aQueueMutex );
+ for( size_t i = 0; i < m_aMessageQueue.size(); i++ )
+ {
+ MediatorMessage* pMessage = m_aMessageQueue[ i ];
+ ULONG nID = pMessage->m_nID;
+ if( ( nID & 0xff000000 ) &&
+ ( ( nID & 0x00ffffff ) == nMessageID ) )
+ {
+ m_aMessageQueue.erase( m_aMessageQueue.begin() + i );
+ return pMessage;
+ }
+ }
+ }
+ if( ! m_aMessageQueue.empty() )
+ CallWorkHandler();
+ WaitForMessage( 2000 );
+ }
+ return NULL;
+}
+
+ConnectorInstance::ConnectorInstance( NPP inst, char* type,
+ int args, char* pargnbuf, ULONG nargnbytes,
+ char* pargvbuf, ULONG nargvbytes,
+ char* savedata, ULONG savebytes ) :
+ instance( inst ),
+ pShell( NULL ),
+ pWidget( NULL ),
+ pForm( NULL ),
+ pGtkWindow( NULL ),
+ pGtkWidget( NULL ),
+ bShouldUseXEmbed( false ),
+ nArg( args ),
+ pArgnBuf( pargnbuf ),
+ pArgvBuf( pargvbuf )
+{
+ memset( &window, 0, sizeof(window) );
+ pMimeType = new char[ strlen( type ) + 1 ];
+ strcpy( pMimeType, type );
+ aData.len = savebytes;
+ aData.buf = savedata;
+ argn = new char*[ nArg ];
+ argv = new char*[ nArg ];
+ int i;
+ char* pRun = pArgnBuf;
+ for( i = 0; i < nArg; i++ )
+ {
+ argn[i] = pRun;
+ while( *pRun != 0 && (ULONG)(pRun - pArgnBuf) < nargnbytes )
+ pRun++;
+ if( (ULONG)(pRun - pArgnBuf) < nargnbytes )
+ pRun++;
+ }
+ pRun = pArgvBuf;
+ for( i = 0; i < nArg; i++ )
+ {
+ argv[i] = pRun;
+ while( *pRun != 0 && (ULONG)(pRun - pArgvBuf) < nargvbytes )
+ pRun++;
+ if( (ULONG)(pRun - pArgvBuf) < nargvbytes )
+ pRun++;
+ }
+}
+
+ConnectorInstance::~ConnectorInstance()
+{
+ delete [] pMimeType;
+ delete [] argn;
+ delete [] argv;
+ delete [] pArgnBuf;
+ delete [] pArgvBuf;
+ delete [] (char*)aData.buf;
+}
+
+const char* GetCommandName( CommandAtoms eCommand )
+{
+ switch( eCommand )
+ {
+ case eNPN_GetURL: return "NPN_GetURL";
+ case eNPN_GetURLNotify: return "NPN_GetURLNotify";
+ case eNPN_DestroyStream: return "NPN_DestroyStream";
+ case eNPN_NewStream: return "NPN_NewStream";
+ case eNPN_PostURLNotify: return "NPN_PostURLNotify";
+ case eNPN_PostURL: return "NPN_PostURL";
+ case eNPN_RequestRead: return "NPN_RequestRead";
+ case eNPN_Status: return "NPN_Status";
+ case eNPN_Version: return "NPN_Version";
+ case eNPN_Write: return "NPN_Write";
+ case eNPN_UserAgent: return "NPN_UserAgent";
+
+ case eNPP_DestroyStream: return "NPP_DestroyStream";
+ case eNPP_Destroy: return "NPP_Destroy";
+ case eNPP_DestroyPhase2: return "NPP_DestroyPhase2";
+ case eNPP_NewStream: return "NPP_NewStream";
+ case eNPP_New: return "NPP_New";
+ case eNPP_SetWindow: return "NPP_SetWindow";
+ case eNPP_StreamAsFile: return "NPP_StreamAsFile";
+ case eNPP_URLNotify: return "NPP_URLNotify";
+ case eNPP_WriteReady: return "NPP_WriteReady";
+ case eNPP_Write: return "NPP_Write";
+ case eNPP_GetMIMEDescription: return "NPP_GetMIMEDescription";
+ case eNPP_Initialize: return "NPP_Initialize";
+ case eNPP_Shutdown: return "NPP_Shutdown";
+
+ case eMaxCommand: return "eMaxCommand";
+ default: return "unknown command";
+ }
+ return NULL;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/plugin/unx/sysplug.cxx b/extensions/source/plugin/unx/sysplug.cxx
new file mode 100644
index 000000000000..f5221aa027c8
--- /dev/null
+++ b/extensions/source/plugin/unx/sysplug.cxx
@@ -0,0 +1,141 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+
+#ifdef AIX
+#define _LINUX_SOURCE_COMPAT
+#include <sys/timer.h>
+#undef _LINUX_SOURCE_COMPAT
+#endif
+
+#include <cstdarg>
+
+#include <sys/types.h>
+#include <signal.h>
+#include <sys/wait.h>
+#include <osl/file.hxx>
+#include <osl/thread.h>
+#include <rtl/bootstrap.hxx>
+
+#include <plugin/impl.hxx>
+
+int UnxPluginComm::nConnCounter = 0;
+
+UnxPluginComm::UnxPluginComm(
+ const String& /*mimetype*/,
+ const String& library,
+ XLIB_Window aParent,
+ int nDescriptor1,
+ int nDescriptor2
+ ) :
+ PluginComm( ::rtl::OUStringToOString( library, osl_getThreadTextEncoding() ), false ),
+ PluginConnector( nDescriptor2 )
+{
+ char pDesc[32];
+ char pWindow[32];
+ sprintf( pWindow, "%d", (int)aParent );
+ sprintf( pDesc, "%d", nDescriptor1 );
+ ByteString aLib( library, osl_getThreadTextEncoding() );
+ rtl::OString path;
+ if (!getPluginappPath(&path)) {
+ fprintf( stderr, "cannot construct path to pluginapp.bin\n" );
+ m_nCommPID = -1;
+ return;
+ }
+
+ char const* pArgs[5];
+ pArgs[0] = path.getStr();
+ pArgs[1] = pDesc;
+ pArgs[2] = aLib.GetBuffer();
+ pArgs[3] = pWindow;
+ pArgs[4] = NULL;
+
+#if OSL_DEBUG_LEVEL > 1
+ m_nCommPID = 10;
+ fprintf( stderr, "Try to launch: %s %s %s %s, descriptors are %d, %d\n", pArgs[0], pArgs[1], pArgs[2], pArgs[3], nDescriptor1, nDescriptor2 );
+#endif
+
+ if( ! ( m_nCommPID = fork() ) )
+ {
+ execvp( pArgs[0], const_cast< char ** >(pArgs) );
+ fprintf( stderr, "Error: could not exec %s\n", pArgs[0] );
+ _exit(255);
+ }
+
+ if( m_nCommPID != -1 )
+ {
+ // wait for pluginapp.bin to start up
+ if( ! WaitForMessage( 5000 ) )
+ {
+ fprintf( stderr, "Timeout on command: %s %s %s %s\n", pArgs[0], pArgs[1], pArgs[2], pArgs[3] );
+ invalidate();
+ }
+ else
+ {
+ MediatorMessage* pMessage = GetNextMessage( TRUE );
+ Respond( pMessage->m_nID,
+ const_cast<char*>("init ack"),8,
+ NULL );
+ delete pMessage;
+ NPP_Initialize();
+ }
+ }
+}
+
+UnxPluginComm::~UnxPluginComm()
+{
+ NPP_Shutdown();
+ if( m_nCommPID != -1 && m_nCommPID != 0 )
+ {
+ int status = 16777216;
+ pid_t nExit = waitpid( m_nCommPID, &status, WUNTRACED );
+#if OSL_DEBUG_LEVEL > 1
+ fprintf( stderr, "child %d (plugin app child %d) exited with status %d\n", nExit, m_nCommPID, WEXITSTATUS(status) );
+#else
+ (void)nExit;
+#endif
+ }
+}
+
+bool UnxPluginComm::getPluginappPath(rtl::OString * path) {
+ OSL_ASSERT(path != NULL);
+ rtl::OUString p(
+ RTL_CONSTASCII_USTRINGPARAM("$OOO_BASE_DIR/program/pluginapp.bin"));
+ rtl::Bootstrap::expandMacros(p);
+ return
+ (osl::FileBase::getSystemPathFromFileURL(p, p) ==
+ osl::FileBase::E_None) &&
+ p.convertToString(
+ path, osl_getThreadTextEncoding(),
+ (RTL_UNICODETOTEXT_FLAGS_UNDEFINED_ERROR |
+ RTL_UNICODETOTEXT_FLAGS_INVALID_ERROR));
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/plugin/unx/unxmgr.cxx b/extensions/source/plugin/unx/unxmgr.cxx
new file mode 100644
index 000000000000..b042815f8343
--- /dev/null
+++ b/extensions/source/plugin/unx/unxmgr.cxx
@@ -0,0 +1,325 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+
+#ifdef AIX
+#define _LINUX_SOURCE_COMPAT
+#include <sys/timer.h>
+#undef _LINUX_SOURCE_COMPAT
+#endif
+
+#include <cstdarg>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <dirent.h>
+#include <osl/thread.h>
+#include <rtl/strbuf.hxx>
+#include <tools/appendunixshellword.hxx>
+
+#include <vcl/svapp.hxx>
+#include <plugin/impl.hxx>
+
+using namespace rtl;
+using namespace std;
+using namespace com::sun::star::uno;
+using namespace com::sun::star::plugin;
+
+// Unix specific implementation
+static bool CheckPlugin( const ByteString& rPath, list< PluginDescription* >& rDescriptions )
+{
+#if OSL_DEBUG_LEVEL > 1
+ fprintf( stderr, "Trying plugin %s ... ", rPath.GetBuffer() );
+#endif
+
+ xub_StrLen nPos = rPath.SearchBackward( '/' );
+ if( nPos == STRING_NOTFOUND )
+ {
+#if OSL_DEBUG_LEVEL > 1
+ fprintf( stderr, "no absolute path to plugin\n" );
+#endif
+ return false;
+ }
+
+ ByteString aBaseName = rPath.Copy( nPos+1 );
+ if( aBaseName.Equals( "libnullplugin.so" ) )
+ {
+#if OSL_DEBUG_LEVEL > 1
+ fprintf( stderr, "don't like %s\n", aBaseName.GetBuffer() );
+#endif
+ return false;
+ }
+
+ struct stat aStat;
+ if( stat( rPath.GetBuffer(), &aStat ) || ! S_ISREG( aStat.st_mode ) )
+ {
+#if OSL_DEBUG_LEVEL > 1
+ fprintf( stderr, "%s is not a regular file\n", rPath.GetBuffer() );
+#endif
+ return false;
+ }
+
+
+ rtl_TextEncoding aEncoding = osl_getThreadTextEncoding();
+
+ rtl::OString path;
+ if (!UnxPluginComm::getPluginappPath(&path)) {
+#if OSL_DEBUG_LEVEL > 1
+ fprintf( stderr, "cannot construct path to pluginapp.bin\n" );
+#endif
+ return false;
+ }
+ rtl::OStringBuffer cmd;
+ tools::appendUnixShellWord(&cmd, path);
+ cmd.append(' ');
+ tools::appendUnixShellWord(&cmd, rPath);
+ rtl::OString aCommand(cmd.makeStringAndClear());
+
+ FILE* pResult = popen( aCommand.getStr(), "r" );
+ int nDescriptions = 0;
+ if( pResult )
+ {
+ OStringBuffer aMIME;
+ char buf[256];
+ while( fgets( buf, sizeof( buf ), pResult ) )
+ {
+ for( size_t i = 0; i < sizeof(buf) && buf[i]; ++i )
+ {
+ if( buf[i] == '\n' )
+ buf[i] = ';';
+ }
+ aMIME.append( buf );
+ }
+ pclose( pResult );
+
+ if( aMIME.getLength() > 0 )
+ {
+ OString aLine = aMIME.makeStringAndClear();
+
+ sal_Int32 nIndex = 0;
+ while( nIndex != -1 )
+ {
+ OString aType = aLine.getToken( 0, ';', nIndex );
+
+ sal_Int32 nTypeIndex = 0;
+ OString aMimetype = aType.getToken( 0, ':', nTypeIndex );
+ OString aExtLine = aType.getToken( 0, ':', nTypeIndex );
+ if( nTypeIndex < 0 ) // ensure at least three tokens
+ continue;
+ OString aDesc = aType.getToken( 0, ':', nTypeIndex );
+
+ // create extension list string
+ sal_Int32 nExtIndex = 0;
+ OStringBuffer aExtension;
+ while( nExtIndex != -1 )
+ {
+ OString aExt = aExtLine.getToken( 0, ',', nExtIndex);
+ if( aExt.indexOf( "*." ) != 0 )
+ aExtension.append( "*." );
+ aExtension.append( aExt );
+ if( nExtIndex != -1 )
+ aExtension.append( ';' );
+ }
+
+ PluginDescription* pNew = new PluginDescription;
+ // set plugin name (path to library)
+ pNew->PluginName = OStringToOUString( rPath, aEncoding );
+ // set mimetype
+ pNew->Mimetype = OStringToOUString( aMimetype, aEncoding );
+ // set extension line
+ pNew->Extension = OStringToOUString( aExtension.makeStringAndClear(), aEncoding );
+ // set description
+ pNew->Description= OStringToOUString( aDesc, aEncoding );
+ rDescriptions.push_back( pNew );
+#if OSL_DEBUG_LEVEL > 1
+ fprintf( stderr, "Mimetype: %s\nExtension: %s\n"
+ "Description: %s\n",
+ OUStringToOString( pNew->Mimetype, aEncoding ).getStr(),
+ OUStringToOString( pNew->Extension, aEncoding ).getStr(),
+ OUStringToOString( pNew->Description, aEncoding ).getStr()
+ );
+#endif
+ }
+ }
+#if OSL_DEBUG_LEVEL > 1
+ else
+ fprintf( stderr, "result of \"%s\" contains no mimtype\n",
+ aCommand.getStr() );
+#endif
+ }
+#if OSL_DEBUG_LEVEL > 1
+ else
+ fprintf( stderr, "command \"%s\" failed\n", aCommand.getStr() );
+#endif
+ return nDescriptions > 0;
+}
+
+union maxDirent
+{
+ char aBuffer[ sizeof( struct dirent ) + _PC_NAME_MAX +1 ];
+ struct dirent asDirent;
+};
+
+static void CheckPluginRegistryFiles( const rtl::OString& rPath, list< PluginDescription* >& rDescriptions )
+{
+ rtl::OStringBuffer aPath( 1024 );
+ aPath.append( rPath );
+ aPath.append( "/pluginreg.dat" );
+ FILE* fp = fopen( aPath.getStr(), "r" );
+ if( fp )
+ {
+#if OSL_DEBUG_LEVEL > 1
+ fprintf( stderr, "parsing %s\n", aPath.getStr() );
+#endif
+ char aLine[1024];
+ while( fgets( aLine, sizeof( aLine ), fp ) )
+ {
+ int nLineLen = strlen( aLine );
+ int nDotPos;
+ for( nDotPos = nLineLen-1; nDotPos > 0 && aLine[nDotPos] != ':'; nDotPos-- )
+ ;
+ if( aLine[0] == '/' && aLine[nDotPos] == ':' && aLine[nDotPos+1] == '$' )
+ CheckPlugin( ByteString( aLine, nDotPos ), rDescriptions );
+ }
+ fclose( fp );
+ }
+
+ // check subdirectories
+ DIR* pDIR = opendir( rPath.getStr() );
+ struct dirent* pDirEnt = NULL;
+ struct stat aStat;
+ maxDirent u;
+ while( pDIR && ! readdir_r( pDIR, &u.asDirent, &pDirEnt ) && pDirEnt )
+ {
+ char* pBaseName = u.asDirent.d_name;
+ if( rtl_str_compare( ".", pBaseName ) && rtl_str_compare( "..", pBaseName ) )
+ {
+ rtl::OStringBuffer aBuf( 1024 );
+ aBuf.append( rPath );
+ aBuf.append( '/' );
+ aBuf.append( pBaseName );
+
+ if( ! stat( aBuf.getStr(), &aStat ) )
+ {
+ if( S_ISDIR( aStat.st_mode ) )
+ CheckPluginRegistryFiles( aBuf.makeStringAndClear(), rDescriptions );
+ }
+ }
+ }
+ if( pDIR )
+ closedir( pDIR );
+}
+
+Sequence<PluginDescription> XPluginManager_Impl::impl_getPluginDescriptions() throw()
+{
+ static Sequence<PluginDescription> aDescriptions;
+ static BOOL bHavePlugins = FALSE;
+ if( ! bHavePlugins )
+ {
+ rtl_TextEncoding aEncoding = osl_getThreadTextEncoding();
+ list<PluginDescription*> aPlugins;
+ int i;
+
+ // unix: search for plugins in /usr/lib/netscape/plugins,
+ // ~/.netscape/plugins und NPX_PLUGIN_PATH
+ // additionally: search in PluginsPath
+ static const char* pHome = getenv( "HOME" );
+ static const char* pNPXPluginPath = getenv( "NPX_PLUGIN_PATH" );
+
+ ByteString aSearchPath( "/usr/lib/netscape/plugins" );
+ if( pHome )
+ {
+ aSearchPath.Append( ':' );
+ aSearchPath.Append( pHome );
+ aSearchPath += "/.netscape/plugins";
+ }
+ if( pNPXPluginPath )
+ {
+ aSearchPath.Append( ':' );
+ aSearchPath += pNPXPluginPath;
+ }
+
+ const Sequence< ::rtl::OUString >& rPaths( PluginManager::getAdditionalSearchPaths() );
+ for( i = 0; i < rPaths.getLength(); i++ )
+ {
+ aSearchPath += ":";
+ aSearchPath += ByteString( String( rPaths.getConstArray()[i] ), aEncoding );
+ }
+
+ int nPaths = aSearchPath.GetTokenCount( ':' );
+ maxDirent u;
+ for( i = 0; i < nPaths; i++ )
+ {
+ ByteString aPath( aSearchPath.GetToken( i, ':' ) );
+ if( aPath.Len() )
+ {
+ DIR* pDIR = opendir( aPath.GetBuffer() );
+ struct dirent* pDirEnt = NULL;
+ while( pDIR && ! readdir_r( pDIR, &u.asDirent, &pDirEnt ) && pDirEnt )
+ {
+ char* pBaseName = u.asDirent.d_name;
+ if( pBaseName[0] != '.' ||
+ pBaseName[1] != '.' ||
+ pBaseName[2] != 0 )
+ {
+ ByteString aFileName( aPath );
+ aFileName += "/";
+ aFileName += pBaseName;
+ CheckPlugin( aFileName, aPlugins );
+ }
+ }
+ if( pDIR )
+ closedir( pDIR );
+ }
+ }
+
+ // try ~/.mozilla/pluginreg.dat
+ rtl::OStringBuffer aBuf(256);
+ aBuf.append( pHome );
+ aBuf.append( "/.mozilla" );
+ CheckPluginRegistryFiles( aBuf.makeStringAndClear(), aPlugins );
+
+ // create return value
+ aDescriptions = Sequence<PluginDescription>( aPlugins.size() );
+#if OSL_DEBUG_LEVEL > 1
+ fprintf( stderr, "found %d plugins\n", aPlugins.size() );
+#endif
+ list<PluginDescription*>::iterator iter;
+ for( iter = aPlugins.begin(), i=0; iter != aPlugins.end(); ++iter ,i++ )
+ {
+ aDescriptions.getArray()[ i ] = **iter;
+ delete *iter;
+ }
+ aPlugins.clear();
+ bHavePlugins = TRUE;
+ }
+ return aDescriptions;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/plugin/util/makefile.mk b/extensions/source/plugin/util/makefile.mk
new file mode 100644
index 000000000000..75baea867c21
--- /dev/null
+++ b/extensions/source/plugin/util/makefile.mk
@@ -0,0 +1,109 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+PRJ=..$/..$/..
+
+PRJNAME=extensions
+TARGET=pl
+TARGETTYPE=GUI
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+
+# --- Files --------------------------------------------------------
+
+.IF "$(WITH_MOZILLA)" != "NO"
+
+LIB1TARGET = $(SLB)$/plall.lib
+LIB1FILES = \
+ $(SLB)$/plbase.lib \
+ $(SHL1LINKLIB)
+
+.IF "$(GUI)" == "UNX"
+.IF "$(GUIBASE)"=="aqua"
+.IF "$(WITH_MOZILLA)"=="YES"
+SHL1LINKLIB = $(SLB)$/plaqua.lib
+.ENDIF
+.ELSE
+SHL1LINKLIB = $(SLB)$/plunx.lib
+.ENDIF # $(GUIBASE)==aqua
+.IF "$(OS)" == "SOLARIS"
+SHL1OWNLIBS = -lsocket
+.ENDIF # SOLARIS
+.ENDIF # UNX
+
+.IF "$(GUI)" == "WNT"
+SHL1LINKLIB = $(SLB)$/plwin.lib
+SHL1OWNLIBS = \
+ $(VERSIONLIB) \
+ $(OLE32LIB) \
+ $(ADVAPI32LIB)
+.ENDIF # WNT
+
+SHL1TARGET= $(TARGET)$(DLLPOSTFIX)
+SHL1IMPLIB= i$(TARGET)
+
+SHL1VERSIONMAP=$(SOLARENV)/src/component.map
+SHL1DEF=$(MISC)$/$(SHL1TARGET).def
+DEF1NAME=$(SHL1TARGET)
+
+SHL1LIBS=$(LIB1TARGET)
+
+.IF "$(OS)"=="MACOSX"
+SHL1STDLIBS= \
+ $(LIBSTLPORT) \
+ $(TKLIB)
+.ELSE
+SHL1STDLIBS= \
+ $(TKLIB)
+.ENDIF
+
+SHL1STDLIBS+= \
+ $(VCLLIB) \
+ $(SVLLIB) \
+ $(UNOTOOLSLIB) \
+ $(TOOLSLIB) \
+ $(UCBHELPERLIB) \
+ $(CPPUHELPERLIB) \
+ $(CPPULIB) \
+ $(SALLIB) \
+ $(SALHELPERLIB)
+
+.IF "$(GUIBASE)"=="unx"
+SHL1STDLIBS+=$(X11LINK_DYNAMIC)
+.ENDIF
+
+SHL1STDLIBS+=$(SHL1OWNLIBS)
+
+.ENDIF # $(WITH_MOZILLA) != "NO"
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : target.mk
+
+
+
diff --git a/extensions/source/plugin/util/makefile.pmk b/extensions/source/plugin/util/makefile.pmk
new file mode 100644
index 000000000000..0f06ea2a50ce
--- /dev/null
+++ b/extensions/source/plugin/util/makefile.pmk
@@ -0,0 +1,48 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+NOUNODOC=true
+
+.INCLUDE : settings.mk
+
+.IF "$(SYSTEM_MOZILLA)" == "YES"
+CFLAGS+=-DSYSTEM_MOZILLA
+PKGCONFIG_MODULES+=$(MOZ_FLAVOUR)-plugin
+.ENDIF
+
+.IF "$(GUIBASE)" == "unx" && "$(ENABLE_GTK)" == "TRUE"
+CDEFS+=-DENABLE_GTK
+PKGCONFIG_MODULES+=gtk+-2.0 gthread-2.0
+.ENDIF
+
+.IF "$(GUIBASE)" == "aqua"
+CFLAGS += -I$(FRAMEWORKSHOME)/ApplicationServices.framework/Versions/Current/Frameworks/QD.framework/Headers\
+ -I$(FRAMEWORKSHOME)/Carbon.framework/Versions/Current/Frameworks/HIToolbox.framework/Versions/Current/Headers
+.ENDIF
+
+.IF "$(PKGCONFIG_MODULES)" != ""
+.INCLUDE : pkg_config.mk
+.ENDIF
diff --git a/extensions/source/plugin/win/makefile.mk b/extensions/source/plugin/win/makefile.mk
new file mode 100644
index 000000000000..3167c22d135d
--- /dev/null
+++ b/extensions/source/plugin/win/makefile.mk
@@ -0,0 +1,65 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ=..$/..$/..
+
+PRJNAME=extensions
+TARGET=plwin
+ENABLE_EXCEPTIONS=TRUE
+
+# --- Settings -----------------------------------------------------
+.IF "$(GUI)" == "WNT"
+
+.INCLUDE : ..$/util$/makefile.pmk
+
+INCPRE+=-I$(SOLARINCDIR)$/mozilla$/plugin
+.IF "$(SOLAR_JAVA)" != ""
+INCPRE+=-I$(SOLARINCDIR)$/mozilla$/java
+INCPRE+=-I$(SOLARINCDIR)$/mozilla$/nspr
+CDEFS+=-DOJI
+.ENDIF
+
+# --- Types -------------------------------------
+
+.IF "$(WITH_MOZILLA)" != "NO"
+
+#UNOUCROUT=$(OUT)$/inc$/$(PRJNAME)
+#INCPRE+=$(UNOUCROUT)
+
+# --- Types -------------------------------------
+
+SLOFILES = $(SLO)$/winmgr.obj \
+ $(SLO)$/sysplug.obj
+
+.ENDIF # $(WITH_MOZILLA) != "NO"
+.ENDIF
+
+# ------------------------------------------------------------------
+
+
+.INCLUDE : target.mk
+
diff --git a/extensions/source/plugin/win/sysplug.cxx b/extensions/source/plugin/win/sysplug.cxx
new file mode 100644
index 000000000000..607aa4b87f88
--- /dev/null
+++ b/extensions/source/plugin/win/sysplug.cxx
@@ -0,0 +1,446 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+
+#include <plugin/impl.hxx>
+
+#pragma warning (push,1)
+#pragma warning (disable:4005)
+
+ #include <tools/prewin.h>
+
+ #include <windows.h>
+ #include <string.h>
+ #include <tchar.h>
+ #include <winreg.h>
+ #include <winbase.h>
+ #include <objbase.h>
+
+ #include <tools/postwin.h>
+
+#pragma warning (pop)
+
+#include <list>
+#include <map>
+#include <algorithm>
+
+
+extern NPNetscapeFuncs aNPNFuncs;
+
+#include <tools/debug.hxx>
+
+using namespace rtl;
+
+#if OSL_DEBUG_LEVEL > 1
+void TRACE( char const * s );
+void TRACEN( char const * s, long n );
+#else
+#define TRACE(x)
+#define TRACEN(x,n)
+#endif
+
+
+//--------------------------------------------------------------------------------------------------
+PluginComm_Impl::PluginComm_Impl( const OUString& /*rMIME*/, const OUString& rName, HWND /*hWnd*/ )
+ : PluginComm( OUStringToOString( rName, RTL_TEXTENCODING_MS_1252 ) )
+{
+ // initialize plugin function table
+ memset( &_NPPfuncs, 0, sizeof( _NPPfuncs ) );
+#ifdef UNICODE
+ _plDLL = ::LoadLibrary( rName.getStr() );
+#else
+ OString aStr( OUStringToOString( rName, RTL_TEXTENCODING_MS_1252 ) );
+ _plDLL = ::LoadLibrary( aStr.getStr() );
+#endif
+ DBG_ASSERT( _plDLL, "### loading plugin dll failed!" );
+
+ NPError nErr = NPERR_NO_ERROR;
+ NPError (WINAPI * pEntry)( NPPluginFuncs* );
+ retrieveFunction( _T("NP_GetEntryPoints"), (void**)&pEntry );
+
+ _NPPfuncs.size = sizeof( _NPPfuncs );
+ _NPPfuncs.version = 0;
+ nErr = (*pEntry)( &_NPPfuncs );
+
+ DBG_ASSERT( nErr == NPERR_NO_ERROR, "### NP_GetEntryPoints() failed!" );
+ DBG_ASSERT( (_NPPfuncs.version >> 8) >= NP_VERSION_MAJOR,
+ "### version failure!" );
+
+ m_eCall = eNP_Initialize;
+ execute();
+}
+
+//--------------------------------------------------------------------------------------------------
+PluginComm_Impl::~PluginComm_Impl()
+{
+ if (_plDLL)
+ {
+// NPP_Shutdown();
+
+ NPError (WINAPI * pShutdown)();
+ if (retrieveFunction( _T("NP_Shutdown"), (void**)&pShutdown ))
+ {
+ NPError nErr = (*pShutdown)(); (void)nErr;
+ DBG_ASSERT( nErr == NPERR_NO_ERROR, "### NP_Shutdown() failed!" );
+ }
+
+ BOOL bRet = (BOOL)::FreeLibrary( _plDLL ); (void)bRet;
+ DBG_ASSERT( bRet, "### unloading plugin dll failed!" );
+ _plDLL = NULL;
+ }
+}
+
+//--------------------------------------------------------------------------------------------------
+BOOL PluginComm_Impl::retrieveFunction( TCHAR* pName, void** ppFunc ) const
+{
+ if( ! _plDLL )
+ return FALSE;
+
+ *ppFunc = (void*)::GetProcAddress( _plDLL, pName );
+
+ return (*ppFunc != NULL);
+}
+
+//--------------------------------------------------------------------------------------------------
+
+long PluginComm_Impl::doIt()
+{
+ long nRet = 0;
+ switch( m_eCall )
+ {
+ case eNP_Initialize:
+ {
+ TRACE( "eNP_Initialize" );
+ NPError (WINAPI * pInit)( NPNetscapeFuncs* );
+ if ((_NPPfuncs.version >> 8) >= NP_VERSION_MAJOR &&
+ (retrieveFunction( _T("NP_Initialize"), (void**)&pInit ) ||
+ retrieveFunction( _T("NP_PluginInit"), (void**)&pInit )))
+ {
+ nRet = (*pInit)( &aNPNFuncs );
+ }
+ else
+ {
+ nRet = NPERR_GENERIC_ERROR;
+ }
+ DBG_ASSERT( nRet == NPERR_NO_ERROR, "### NP_Initialize() failed!" );
+ }
+ break;
+ case eNPP_Destroy:
+ TRACE( "eNPP_Destroy" );
+ nRet = (_NPPfuncs.destroy
+ ? (*_NPPfuncs.destroy)(
+ (NPP)m_aArgs[0],
+ (NPSavedData**)m_aArgs[1] )
+ : NPERR_GENERIC_ERROR);
+ break;
+ case eNPP_DestroyStream:
+ TRACE( "eNPP_DestroyStream" );
+ nRet = (_NPPfuncs.destroystream
+ ? (*_NPPfuncs.destroystream)(
+ (NPP)m_aArgs[0],
+ (NPStream*)m_aArgs[1],
+ (NPError)(sal_IntPtr)m_aArgs[2] )
+ : NPERR_GENERIC_ERROR);
+ break;
+ case eNPP_New:
+ TRACE( "eNPP_New" );
+ nRet = (_NPPfuncs.newp
+ ? (*_NPPfuncs.newp)(
+ (NPMIMEType)m_aArgs[0],
+ (NPP)m_aArgs[1],
+ (uint16)(sal_IntPtr)m_aArgs[2],
+ (int16)(sal_IntPtr)m_aArgs[3],
+ (char**)m_aArgs[4],
+ (char**)m_aArgs[5],
+ (NPSavedData*)m_aArgs[6] )
+ : NPERR_GENERIC_ERROR);
+ break;
+ case eNPP_NewStream:
+ TRACE( "eNPP_NewStream" );
+ nRet = (_NPPfuncs.newstream
+ ? (*_NPPfuncs.newstream)(
+ (NPP)m_aArgs[0],
+ (NPMIMEType)m_aArgs[1],
+ (NPStream*)m_aArgs[2],
+ (NPBool)(sal_IntPtr)m_aArgs[3],
+ (uint16*)m_aArgs[4] )
+ : NPERR_GENERIC_ERROR);
+ break;
+ case eNPP_Print:
+ TRACE( "eNPP_Print" );
+ if (_NPPfuncs.print)
+ (*_NPPfuncs.print)(
+ (NPP)m_aArgs[0],
+ (NPPrint*)m_aArgs[1] );
+ break;
+ case eNPP_SetWindow:
+ {
+ TRACE( "eNPP_SetWindow" );
+ nRet = (_NPPfuncs.setwindow
+ ? (*_NPPfuncs.setwindow)(
+ (NPP)m_aArgs[0],
+ (NPWindow*)m_aArgs[1] )
+ : NPERR_GENERIC_ERROR);
+ break;
+ }
+ case eNPP_StreamAsFile:
+ TRACE( "eNPP_StreamAsFile" );
+ if (_NPPfuncs.asfile)
+ (*_NPPfuncs.asfile)(
+ (NPP)m_aArgs[0],
+ (NPStream*)m_aArgs[1],
+ (char*)m_aArgs[2] );
+ break;
+ case eNPP_URLNotify:
+ TRACE( "eNPP_URLNotify" );
+ if (_NPPfuncs.urlnotify)
+ (*_NPPfuncs.urlnotify)(
+ (NPP)m_aArgs[0],
+ (char*)m_aArgs[1],
+ (NPReason)(sal_IntPtr)m_aArgs[2],
+ m_aArgs[3] );
+ break;
+ case eNPP_Write:
+ TRACEN( "eNPP_Write n=", (int32)m_aArgs[3] );
+ nRet = (_NPPfuncs.write
+ ? (*_NPPfuncs.write)(
+ (NPP)m_aArgs[0],
+ (NPStream*)m_aArgs[1],
+ (int32)m_aArgs[2],
+ (int32)m_aArgs[3],
+ m_aArgs[4] )
+ : 0);
+ break;
+ case eNPP_WriteReady:
+ TRACE( "eNPP_WriteReady" );
+ nRet = (_NPPfuncs.writeready
+ ? (*_NPPfuncs.writeready)(
+ (NPP)m_aArgs[0],
+ (NPStream*)m_aArgs[1] )
+ : 0);
+ break;
+ case eNPP_GetValue:
+ TRACE( "eNPP_GetValue" );
+ nRet = (_NPPfuncs.getvalue
+ ? (*_NPPfuncs.getvalue)(
+ (NPP)m_aArgs[0],
+ (NPPVariable)(int)m_aArgs[1],
+ m_aArgs[2] )
+ : NPERR_GENERIC_ERROR);
+ break;
+ case eNPP_SetValue:
+ TRACE( "eNPP_SetValue" );
+ nRet = (_NPPfuncs.setvalue
+ ? (*_NPPfuncs.setvalue)(
+ (NPP)m_aArgs[0],
+ (NPNVariable)(int)m_aArgs[1],
+ m_aArgs[2] )
+ : NPERR_GENERIC_ERROR);
+ break;
+ case eNPP_Shutdown:
+ {
+ TRACE( "eNPP_Shutdown" );
+ NPP_ShutdownUPP pFunc;
+ if (retrieveFunction( _T("NPP_Shutdown"), (void**)&pFunc ))
+ (*pFunc)();
+ }
+ break;
+ case eNPP_Initialize:
+ TRACE( "eNPP_Initialize" );
+ OSL_ENSURE( false, "NPP_Initialize: not implemented!" );
+ break;
+ case eNPP_GetJavaClass:
+ TRACE( "eNPP_GetJavaClass" );
+ OSL_ENSURE( false, "NPP_GetJavaClass: not implemented!" );
+ break;
+ }
+ return nRet;
+}
+
+//--------------------------------------------------------------------------------------------------
+NPError PluginComm_Impl::NPP_Destroy( NPP instance, NPSavedData** save )
+{
+ DBG_ASSERT( _NPPfuncs.destroy, "### NPP_Destroy(): null pointer in NPP functions table!" );
+ m_eCall = eNPP_Destroy;
+ m_aArgs[0] = (void*)instance;
+ m_aArgs[1] = (void*)save;
+ return (NPError)execute();
+}
+
+//--------------------------------------------------------------------------------------------------
+NPError PluginComm_Impl::NPP_DestroyStream( NPP instance, NPStream* stream, NPError reason )
+{
+ DBG_ASSERT( _NPPfuncs.destroystream, "### NPP_DestroyStream(): null pointer in NPP functions table!" );
+ m_eCall = eNPP_DestroyStream;
+ m_aArgs[0] = (void*)instance;
+ m_aArgs[1] = (void*)stream;
+ m_aArgs[2] = (void*)reason;
+ return (NPError)execute();
+}
+
+//--------------------------------------------------------------------------------------------------
+NPError PluginComm_Impl::NPP_New( NPMIMEType pluginType, NPP instance, uint16 mode, int16 argc,
+ char* argn[], char* argv[], NPSavedData *saved )
+{
+ DBG_ASSERT( _NPPfuncs.newp, "### NPP_New(): null pointer in NPP functions table!" );
+ m_eCall = eNPP_New;
+ m_aArgs[0] = (void*)pluginType;
+ m_aArgs[1] = (void*)instance;
+ m_aArgs[2] = (void*)mode;
+ m_aArgs[3] = (void*)argc;
+ m_aArgs[4] = (void*)argn;
+ m_aArgs[5] = (void*)argv;
+ m_aArgs[6] = (void*)saved;
+ return (NPError)execute();
+}
+
+//--------------------------------------------------------------------------------------------------
+NPError PluginComm_Impl::NPP_NewStream( NPP instance, NPMIMEType type, NPStream* stream,
+ NPBool seekable, uint16* stype )
+{
+ DBG_ASSERT( _NPPfuncs.newstream, "### NPP_NewStream(): null pointer in NPP functions table!" );
+ m_eCall = eNPP_NewStream;
+ m_aArgs[0] = (void*)instance;
+ m_aArgs[1] = (void*)type;
+ m_aArgs[2] = (void*)stream;
+ m_aArgs[3] = (void*)seekable;
+ m_aArgs[4] = (void*)stype;
+ return (NPError)execute();
+}
+
+//--------------------------------------------------------------------------------------------------
+void PluginComm_Impl::NPP_Print( NPP instance, NPPrint* platformPrint )
+{
+ DBG_ASSERT( _NPPfuncs.print, "### NPP_Print(): null pointer in NPP functions table!" );
+ m_eCall = eNPP_Print;
+ m_aArgs[0] = (void*)instance;
+ m_aArgs[1] = (void*)platformPrint;
+ execute();
+}
+
+//--------------------------------------------------------------------------------------------------
+NPError PluginComm_Impl::NPP_SetWindow( NPP instance, NPWindow* window )
+{
+ DBG_ASSERT( _NPPfuncs.setwindow, "### NPP_SetWindow(): null pointer in NPP functions table!" );
+ m_eCall = eNPP_SetWindow;
+ m_aArgs[0] = (void*)instance;
+ m_aArgs[1] = (void*)window;
+ return (NPError)execute();
+}
+
+//--------------------------------------------------------------------------------------------------
+void PluginComm_Impl::NPP_StreamAsFile( NPP instance, NPStream* stream, const char* fname )
+{
+ DBG_ASSERT( _NPPfuncs.asfile, "### NPP_StreamAsFile(): null pointer in NPP functions table!" );
+ m_eCall = eNPP_StreamAsFile;
+ m_aArgs[0] = (void*)instance;
+ m_aArgs[1] = (void*)stream;
+ m_aArgs[2] = (void*)fname;
+ execute();
+}
+
+//--------------------------------------------------------------------------------------------------
+void PluginComm_Impl::NPP_URLNotify( NPP instance, const char* url, NPReason reason, void* notifyData )
+{
+ DBG_ASSERT( _NPPfuncs.urlnotify, "### NPP_URLNotify(): null pointer in NPP functions table!" );
+ m_eCall = eNPP_URLNotify;
+ m_aArgs[0] = (void*)instance;
+ m_aArgs[1] = (void*)url;
+ m_aArgs[2] = (void*)reason;
+ m_aArgs[3] = notifyData;
+ execute();
+}
+
+//--------------------------------------------------------------------------------------------------
+int32 PluginComm_Impl::NPP_Write( NPP instance, NPStream* stream, int32 offset, int32 len, void* buffer )
+{
+ DBG_ASSERT( _NPPfuncs.write, "### NPP_Write(): null pointer in NPP functions table!" );
+ m_eCall = eNPP_Write;
+ m_aArgs[0] = (void*)instance;
+ m_aArgs[1] = (void*)stream;
+ m_aArgs[2] = (void*)offset;
+ m_aArgs[3] = (void*)len;
+ m_aArgs[4] = buffer;
+ return (NPError)execute();
+}
+
+//--------------------------------------------------------------------------------------------------
+int32 PluginComm_Impl::NPP_WriteReady( NPP instance, NPStream* stream )
+{
+ DBG_ASSERT( _NPPfuncs.writeready, "### NPP_WriteReady(): null pointer in NPP functions table!" );
+ m_eCall = eNPP_WriteReady;
+ m_aArgs[0] = (void*)instance;
+ m_aArgs[1] = (void*)stream;
+ return execute();
+}
+
+//--------------------------------------------------------------------------------------------------
+NPError PluginComm_Impl::NPP_GetValue( NPP instance, NPPVariable variable, void *ret_value )
+{
+ DBG_ASSERT( _NPPfuncs.getvalue, "### NPP_GetValue(): null pointer in NPP functions table!" );
+ m_eCall = eNPP_GetValue;
+ m_aArgs[0] = (void*)instance;
+ m_aArgs[1] = (void*)variable;
+ m_aArgs[2] = ret_value;
+ return (NPError)execute();
+}
+
+//--------------------------------------------------------------------------------------------------
+NPError PluginComm_Impl::NPP_SetValue( NPP instance, NPNVariable variable, void *set_value )
+{
+ DBG_ASSERT( _NPPfuncs.setvalue, "### NPP_SetValue(): null pointer in NPP functions table!" );
+ m_eCall = eNPP_SetValue;
+ m_aArgs[0] = (void*)instance;
+ m_aArgs[1] = (void*)variable;
+ m_aArgs[2] = set_value;
+ return (NPError)execute();
+}
+
+//--------------------------------------------------------------------------------------------------
+void * PluginComm_Impl::NPP_GetJavaClass()
+{
+ DBG_ERROR( "no java class available!" );
+ return 0;
+}
+
+//--------------------------------------------------------------------------------------------------
+NPError PluginComm_Impl::NPP_Initialize()
+{
+ return NPERR_NO_ERROR;
+}
+
+//--------------------------------------------------------------------------------------------------
+void PluginComm_Impl::NPP_Shutdown()
+{
+ m_eCall = eNPP_Shutdown;
+ execute();
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/plugin/win/winmgr.cxx b/extensions/source/plugin/win/winmgr.cxx
new file mode 100644
index 000000000000..ff9b713c6085
--- /dev/null
+++ b/extensions/source/plugin/win/winmgr.cxx
@@ -0,0 +1,472 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+
+#include "vcl/svapp.hxx"
+#include "tools/fsys.hxx"
+#include "tools/urlobj.hxx"
+#include "osl/mutex.hxx"
+
+#include "rtl/string.hxx"
+#include "rtl/ustring.hxx"
+#include "rtl/ustrbuf.hxx"
+
+#include "plugin/impl.hxx"
+
+#pragma warning (push,1)
+#pragma warning (disable:4005)
+
+ #include "tools/prewin.h"
+
+ #include <windows.h>
+ #include <string.h>
+ #include <tchar.h>
+ #include <winreg.h>
+ #include <winbase.h>
+ #include <objbase.h>
+
+ #include "tools/postwin.h"
+
+#pragma warning (pop)
+
+#include <list>
+#include <map>
+#include <algorithm>
+
+
+using namespace rtl;
+using namespace std;
+using namespace osl;
+using namespace com::sun::star::uno;
+using namespace com::sun::star::plugin;
+
+typedef map< OString, OUString, less< OString > > PluginLocationMap;
+
+
+#if OSL_DEBUG_LEVEL > 1
+#include <stdio.h>
+
+static void logPlugin( OUString const & path_ )
+{
+ static FILE * s_file = 0;
+ if (! s_file)
+ s_file = fopen( "d:\\plugins.log", "a+" );
+ OString path( OUStringToOString( path_, RTL_TEXTENCODING_ASCII_US ) );
+ fprintf( s_file, "%s\n", path.getStr() );
+}
+#endif
+
+//__________________________________________________________________________________________________
+static void addPluginsFromPath( const TCHAR * pPluginsPath, PluginLocationMap & rPlugins )
+{
+ // append dll name pattern we are looking for
+ TCHAR arPluginsPath[MAX_PATH];
+ arPluginsPath[0] = 0;
+
+ if (::rtl_str_indexOfStr( pPluginsPath, "%programfiles%" ) == 0)
+ {
+ const char * p = ::getenv( "ProgramFiles" );
+ if (p)
+ {
+ ::lstrcpy( arPluginsPath, p );
+ pPluginsPath += 14;
+ }
+ }
+ ::lstrcat( arPluginsPath, pPluginsPath );
+ ::lstrcat( arPluginsPath, _T("\\") );
+
+ TCHAR arPluginsPattern[MAX_PATH];
+ ::lstrcpy( arPluginsPattern, arPluginsPath );
+ ::lstrcat( arPluginsPattern, _T("NP*.DLL") );
+
+ WIN32_FIND_DATA aFindData;
+ HANDLE hFind = ::FindFirstFile( arPluginsPattern, &aFindData );
+
+ while (hFind != INVALID_HANDLE_VALUE)
+ {
+ OString aName( aFindData.cFileName );
+ aName.toAsciiLowerCase();
+
+ // no netscape default plugin anymore...
+ // and no double plugin dlls
+ if ( !aName.equals( "npnul32.dll" ) &&
+ ! aName.equals( "npnrvp.dll" ) &&
+ rPlugins.find( aName ) == rPlugins.end())
+ {
+ TCHAR arComplete[MAX_PATH];
+ ::lstrcpy( arComplete, arPluginsPath );
+ ::lstrcat( arComplete, aFindData.cFileName );
+
+ OUString path( OStringToOUString( arComplete, RTL_TEXTENCODING_MS_1252 ) );
+ rPlugins[ aName ] = path;
+#if OSL_DEBUG_LEVEL > 1
+ logPlugin( path );
+#endif
+ }
+
+ if (! ::FindNextFile( hFind, &aFindData ))
+ break;
+ }
+
+ if (hFind != INVALID_HANDLE_VALUE)
+ ::FindClose( hFind );
+}
+//__________________________________________________________________________________________________
+static void addPluginsFromPath( const OUString & rPath, PluginLocationMap & rPlugins )
+{
+ TCHAR arPluginsPath[MAX_PATH];
+ DWORD dwPluginsPathSize = sizeof(arPluginsPath);
+ arPluginsPath[dwPluginsPathSize-1] = 0;
+
+ OString aStr( OUStringToOString( rPath, RTL_TEXTENCODING_MS_1252 ) );
+ ::strncpy( arPluginsPath, aStr.getStr(), dwPluginsPathSize );
+
+ addPluginsFromPath( arPluginsPath, rPlugins );
+}
+
+
+//__________________________________________________________________________________________________
+static void add_IE_Plugins( PluginLocationMap & rPlugins )
+{
+ HKEY hKey;
+ TCHAR arCurrent[MAX_PATH];
+ DWORD dwType, dwCurrentSize = sizeof(arCurrent);
+
+ if (::RegOpenKeyEx( HKEY_LOCAL_MACHINE, _T("Software\\Microsoft\\IE4\\SETUP"),
+ 0, KEY_READ, &hKey ) == ERROR_SUCCESS)
+ {
+ if (::RegQueryValueEx( hKey, _T("Path"), NULL, &dwType,
+ (LPBYTE)arCurrent, &dwCurrentSize ) == ERROR_SUCCESS &&
+ (dwType == REG_SZ || dwType == REG_EXPAND_SZ))
+ {
+ // add \\Plugins
+ ::lstrcat( arCurrent, _T("\\Plugins") );
+
+ addPluginsFromPath( arCurrent, rPlugins );
+ }
+ ::RegCloseKey( hKey );
+ }
+}
+
+//--------------------------------------------------------------------------------------------------
+static void add_NS_keys( HKEY hKey, PluginLocationMap & rPlugins )
+{
+ TCHAR value[MAX_PATH];
+ DWORD dwType, size = sizeof(value);
+
+ // 4.7
+ size = sizeof(value);
+ if (::RegQueryValueEx(
+ hKey, _T("Plugins Directory"), NULL, &dwType,
+ (LPBYTE)value, &size ) == ERROR_SUCCESS &&
+ (dwType == REG_SZ || dwType == REG_EXPAND_SZ))
+ {
+ addPluginsFromPath( value, rPlugins );
+ }
+ // 6
+ size = sizeof(value);
+ if (::RegQueryValueEx(
+ hKey, _T("Install Directory"), NULL, &dwType,
+ (LPBYTE)value, &size ) == ERROR_SUCCESS &&
+ (dwType == REG_SZ || dwType == REG_EXPAND_SZ))
+ {
+ int n = size / sizeof (TCHAR);
+ if ('\\' != value[ n -2 ])
+ {
+ value[ n -1 ] = '\\';
+ value[ n ] = 0;
+ }
+ addPluginsFromPath( ::lstrcat( value, _T("Plugins") ), rPlugins );
+ }
+ size = sizeof(value);
+ if (::RegQueryValueEx(
+ hKey, _T("Plugins"), NULL, &dwType,
+ (LPBYTE)value, &size ) == ERROR_SUCCESS &&
+ (dwType == REG_SZ || dwType == REG_EXPAND_SZ))
+ {
+ addPluginsFromPath( value, rPlugins );
+ }
+}
+//--------------------------------------------------------------------------------------------------
+static void add_NS_lookupRecursive( HKEY hKey, PluginLocationMap & rPlugins )
+{
+ add_NS_keys( hKey, rPlugins );
+
+ TCHAR keyName[MAX_PATH];
+ DWORD dwIndex = 0, size = sizeof (keyName);
+
+ while (::RegEnumKeyEx( hKey, dwIndex, keyName, &size, NULL, NULL, NULL, NULL ) == ERROR_SUCCESS)
+ {
+ size = sizeof (keyName);
+ HKEY hSubKey;
+ if (::RegOpenKeyEx( hKey, keyName, 0, KEY_READ, &hSubKey ) == ERROR_SUCCESS)
+ {
+ add_NS_lookupRecursive( hSubKey, rPlugins );
+ ::RegCloseKey( hSubKey );
+ }
+ ++dwIndex;
+ }
+}
+//__________________________________________________________________________________________________
+static void add_MozPlugin( HKEY hKey, PluginLocationMap & rPlugins )
+{
+ TCHAR value[MAX_PATH];
+ DWORD dwType, size = sizeof(value);
+
+ size = sizeof(value);
+ if (::RegQueryValueEx(
+ hKey, _T("Path"), NULL, &dwType,
+ (LPBYTE)value, &size ) == ERROR_SUCCESS &&
+ (dwType == REG_SZ || dwType == REG_EXPAND_SZ))
+ {
+ OUString aUPath( OStringToOUString( value, RTL_TEXTENCODING_MS_1252 ) );
+ INetURLObject aURL( aUPath );
+ OString aName( OUStringToOString( aURL.GetName().toAsciiLowerCase(), RTL_TEXTENCODING_MS_1252 ) );
+
+ // no netscape default plugin anymore...
+ // and no double plugin dlls
+ if ( !aName.equals( "npnul32.dll" ) &&
+ ! aName.equals( "npnrvp.dll" ) &&
+ rPlugins.find( aName ) == rPlugins.end())
+ {
+ rPlugins[ aName ] = aUPath;
+#if OSL_DEBUG_LEVEL > 1
+ logPlugin( aUPath );
+#endif
+ }
+ }
+}
+static void add_MozillaPlugin( HKEY hKey, PluginLocationMap & rPlugins )
+{
+ TCHAR keyName[MAX_PATH];
+ DWORD dwIndex = 0, size = sizeof (keyName);
+
+ while (::RegEnumKeyEx( hKey, dwIndex, keyName, &size, NULL, NULL, NULL, NULL ) == ERROR_SUCCESS)
+ {
+ size = sizeof (keyName);
+ HKEY hSubKey;
+ if (::RegOpenKeyEx( hKey, keyName, 0, KEY_READ, &hSubKey ) == ERROR_SUCCESS)
+ {
+ add_MozPlugin( hSubKey, rPlugins );
+ ::RegCloseKey( hSubKey );
+ }
+ ++dwIndex;
+ }
+}
+//__________________________________________________________________________________________________
+static void add_NS_Plugins( PluginLocationMap & rPlugins )
+{
+ HKEY hKey;
+ // Netscape
+ if (::RegOpenKeyEx(
+ HKEY_LOCAL_MACHINE, _T("Software\\Netscape"),
+ 0, KEY_READ, &hKey ) == ERROR_SUCCESS)
+ {
+ add_NS_lookupRecursive( hKey, rPlugins );
+ ::RegCloseKey( hKey );
+ }
+ // Mozilla
+ if (::RegOpenKeyEx(
+ HKEY_LOCAL_MACHINE, _T("Software\\Mozilla"),
+ 0, KEY_READ, &hKey ) == ERROR_SUCCESS)
+ {
+ add_NS_lookupRecursive( hKey, rPlugins );
+ ::RegCloseKey( hKey );
+ }
+ // Mozilla - plugins
+ if (::RegOpenKeyEx(
+ HKEY_LOCAL_MACHINE, _T("Software\\MozillaPlugins"),
+ 0, KEY_READ, &hKey ) == ERROR_SUCCESS)
+ {
+ add_MozillaPlugin( hKey, rPlugins );
+ ::RegCloseKey( hKey );
+ }
+}
+
+//__________________________________________________________________________________________________
+static void add_SO_Plugins( PluginLocationMap & rPlugins )
+{
+ const Sequence< OUString > & rPaths = PluginManager::getAdditionalSearchPaths();
+
+ const OUString * pPaths = rPaths.getConstArray();
+ for ( UINT32 nPos = rPaths.getLength(); nPos--; )
+ {
+ addPluginsFromPath( pPaths[nPos], rPlugins );
+ }
+}
+
+//__________________________________________________________________________________________________
+Sequence< PluginDescription > XPluginManager_Impl::impl_getPluginDescriptions(void) throw()
+{
+ Guard< Mutex > aGuard( Mutex::getGlobalMutex() );
+ static Sequence<PluginDescription > s_aDescriptions( 0 );
+ static bool s_bInit = FALSE;
+
+ if (! s_bInit)
+ {
+ // collect all distinct plugin dlls
+ PluginLocationMap aPlugins;
+ add_SO_Plugins( aPlugins );
+ add_NS_Plugins( aPlugins );
+ add_IE_Plugins( aPlugins );
+
+ // collect mime types of plugin dlls
+ for ( PluginLocationMap::iterator iPos( aPlugins.begin() );
+ iPos != aPlugins.end();
+ ++iPos )
+ {
+ TCHAR arFileName[MAX_PATH];
+ DWORD dwDummy, dwSize;
+
+ // DLL name
+ OUString aName( (*iPos).second.getStr() );
+
+ OString aStr( OUStringToOString( aName, RTL_TEXTENCODING_MS_1252 ) );
+ ::strcpy( arFileName, aStr.getStr() );
+ dwSize = ::GetFileVersionInfoSize( arFileName, &dwDummy );
+
+ if ( !dwSize )
+ continue;
+
+ char * pVersionData = new char[dwSize];
+ if (pVersionData && ::GetFileVersionInfo( arFileName, 0, dwSize, pVersionData ))
+ {
+ // optional comment
+ OUString aComment;
+
+ TCHAR * pInfo = NULL, * pInfo2 = NULL;
+ UINT nSize = 0;
+ if (::VerQueryValue( pVersionData, _T("\\StringFileInfo\\040904E4\\ProductName"),
+ (void**)&pInfo, &nSize ) && pInfo)
+ {
+ aComment.operator=( OStringToOUString( OString(pInfo), RTL_TEXTENCODING_MS_1252 ) );
+ }
+
+ // mandatory mime type and file extensions
+ if (::VerQueryValue( pVersionData, _T("\\StringFileInfo\\040904E4\\MIMEType"),
+ (void**)&pInfo, &nSize ) && pInfo &&
+ ::VerQueryValue( pVersionData, _T("\\StringFileInfo\\040904E4\\FileExtents"),
+ (void**)&pInfo2, &nSize ) && pInfo2)
+ {
+ OString aStr2( pInfo2 );
+ OString aExt( aStr2 );
+ OString aStr( pInfo );
+ OString aMIME( aStr );
+ aMIME.trim();
+
+ // count mime tokens
+ USHORT nToken = 0;
+ if (aMIME.getLength())
+ {
+ ++nToken;
+ for ( sal_Int32 n = aMIME.getLength(); n--; )
+ {
+ if (aMIME[ n ] == '|')
+ {
+ ++nToken;
+ }
+ }
+ }
+ sal_Int32 nIndex = 0, nIndex2 = 0;
+
+ UINT32 nStart = s_aDescriptions.getLength();
+ s_aDescriptions.realloc( nStart + nToken );
+ PluginDescription* pDescriptions = s_aDescriptions.getArray();
+ // for every MIME Type
+ sal_Int32 nTok = 0;
+ while (true)
+ {
+ if (nIndex < 0 || nIndex2 < 0)
+ break;
+
+ PluginDescription & rDescr = pDescriptions[nStart+nTok];
+ OString aMIMEToken( aMIME.getToken( 0, '|', nIndex ) );
+ OString aExtToken2( aExt.getToken( 0, '|', nIndex2 ) );
+ if( aMIMEToken.getLength() == 0 || aExtToken2.getLength() == 0 )
+ continue;
+
+ rDescr.Mimetype = OUString(
+ aMIMEToken.getStr(), aMIMEToken.getLength(), RTL_TEXTENCODING_MS_1252 );
+ if (! rDescr.Mimetype.getLength())
+ break;
+
+ OUString aExtToken( aExtToken2.getStr(), aExtToken2.getLength(), RTL_TEXTENCODING_MS_1252 );
+ rDescr.PluginName = aName;
+ rDescr.Description = aComment;
+
+ sal_Int32 nPos = 0, nLen = aExtToken.getLength();
+ OUString aExtensions( OUString::createFromAscii( nLen ? "*." : "*.*" ) );
+
+ for ( ; nPos < nLen; ++nPos )
+ {
+ sal_Unicode c = aExtToken[nPos];
+ switch (c)
+ {
+ case ',':
+ case ';':
+ aExtensions += OUString::createFromAscii( ";*." );
+ case ' ':
+ break;
+ case '*':
+ if (nPos < (nLen-1) && aExtToken[ nPos+1 ] == '.')
+ {
+ ++nPos;
+ break;
+ }
+ default:
+ aExtensions += OUString( &c, 1 );
+ }
+ }
+ rDescr.Extension = aExtensions;
+
+ ++nTok;
+ }
+
+ if (nToken != nTok)
+ {
+ s_aDescriptions.realloc( nTok );
+ }
+ }
+#if OSL_DEBUG_LEVEL > 1
+ else
+ DBG_ERROR( "### cannot get MIME type or extensions!" );
+#endif
+ }
+ if (pVersionData)
+ delete[] pVersionData;
+ }
+
+ s_bInit = TRUE;
+ }
+ return s_aDescriptions;
+}
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/preload/makefile.mk b/extensions/source/preload/makefile.mk
new file mode 100644
index 000000000000..fb11a2bfd32c
--- /dev/null
+++ b/extensions/source/preload/makefile.mk
@@ -0,0 +1,85 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+PRJ=..$/..
+PRJINC=..$/inc
+
+PRJNAME=extensions
+TARGET=preload
+ENABLE_EXCEPTIONS=TRUE
+VISIBILITY_HIDDEN=TRUE
+USE_DEFFILE=TRUE
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : $(PRJ)$/util$/makefile.pmk
+
+# --- defines ------------------------------------------------------
+
+CDEFS+=-DCOMPMOD_NAMESPACE=preload
+CDEFS+=-DCOMPMOD_RESPREFIX=preload
+
+# --- Files --------------------------------------------------------
+
+SLOFILES= $(SLO)$/services.obj\
+ $(SLO)$/modulepreload.obj\
+ $(SLO)$/preloadservices.obj\
+ $(SLO)$/oemwiz.obj
+
+SRS1NAME=$(TARGET)
+SRC1FILES= preload.src
+
+RESLIB1NAME=preload
+RESLIB1IMAGES=$(PRJ)$/res
+RESLIB1SRSFILES= $(SRS)$/preload.srs
+
+SHL1TARGET= $(TARGET)$(DLLPOSTFIX)
+SHL1VERSIONMAP=$(SOLARENV)/src/component.map
+
+SHL1STDLIBS= \
+ $(SFXLIB) \
+ $(SVTOOLLIB)\
+ $(VCLLIB) \
+ $(SVLLIB) \
+ $(TOOLSLIB) \
+ $(UNOTOOLSLIB) \
+ $(COMPHELPERLIB) \
+ $(CPPUHELPERLIB) \
+ $(CPPULIB) \
+ $(SALLIB)
+
+
+SHL1LIBS= $(SLB)$/$(TARGET).lib
+SHL1IMPLIB= i$(TARGET)
+SHL1DEPN= $(SHL1LIBS)
+SHL1DEF= $(MISC)$/$(SHL1TARGET).def
+
+DEF1NAME= $(SHL1TARGET)
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : target.mk
+
diff --git a/extensions/source/preload/modulepreload.cxx b/extensions/source/preload/modulepreload.cxx
new file mode 100644
index 000000000000..ead9753193f4
--- /dev/null
+++ b/extensions/source/preload/modulepreload.cxx
@@ -0,0 +1,34 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+
+#include "componentmodule.cxx"
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/preload/oemwiz.cxx b/extensions/source/preload/oemwiz.cxx
new file mode 100644
index 000000000000..f02d20a0a824
--- /dev/null
+++ b/extensions/source/preload/oemwiz.cxx
@@ -0,0 +1,469 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+#include "oemwiz.hxx"
+#include "componentmodule.hxx"
+#include <tools/debug.hxx>
+#include <sfx2/docfile.hxx>
+#include <svl/itemset.hxx>
+#include <svl/itempool.hxx>
+#include <vcl/msgbox.hxx>
+#include <unotools/pathoptions.hxx>
+#include "preload.hrc"
+#include <svx/svxids.hrc>
+#include <sfx2/app.hxx>
+#include <svtools/xtextedt.hxx>
+#include "osl/diagnose.h"
+#include "tools/urlobj.hxx"
+
+#include <sfx2/sfxdlg.hxx>
+#include <sfx2/tabdlg.hxx>
+#include <svx/dialogs.hrc>
+
+//.........................................................................
+namespace preload
+{
+//.........................................................................
+
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::lang;
+ using namespace ::com::sun::star::beans;
+//.........................................................................
+
+ struct OEMPreloadDialog_Impl
+ {
+ SfxItemSet* pSet;
+ TabPage* pWelcomePage;
+ TabPage* pLicensePage;
+ TabPage* pUserDataPage;
+
+ OEMPreloadDialog_Impl(OEMPreloadDialog* pDialog);
+ ~OEMPreloadDialog_Impl()
+ {
+ delete pWelcomePage;
+ delete pLicensePage;
+ delete pUserDataPage;
+ delete pSet;
+ }
+ void WriteUserData();
+ };
+/* -----------------------------14.11.2001 11:33------------------------------
+
+ ---------------------------------------------------------------------------*/
+ OEMPreloadDialog_Impl::OEMPreloadDialog_Impl(OEMPreloadDialog* pDialog)
+ {
+ SfxItemPool& rPool = SFX_APP()->GetPool();
+ pSet = new SfxItemSet(rPool, SID_FIELD_GRABFOCUS, SID_FIELD_GRABFOCUS);
+ SfxAbstractDialogFactory* pFact = SfxAbstractDialogFactory::Create();
+ if ( pFact )
+ {
+ CreateTabPage pFunc = pFact->GetTabPageCreatorFunc(RID_SFXPAGE_GENERAL);
+ pUserDataPage = (*pFunc)(pDialog, *pSet);
+ ((SfxTabPage*)pUserDataPage)->Reset(*pSet);
+ }
+ else
+ pUserDataPage = NULL;
+ pWelcomePage = new OEMWelcomeTabPage(pDialog);
+ pLicensePage = new OEMLicenseTabPage(pDialog);
+ }
+/* -----------------------------14.11.2001 11:33------------------------------
+
+ ---------------------------------------------------------------------------*/
+ void OEMPreloadDialog_Impl::WriteUserData()
+ {
+ if ( pUserDataPage )
+ ((SfxTabPage*)pUserDataPage)->FillItemSet(*pSet);
+ }
+
+/* -----------------------------14.11.2001 11:33------------------------------
+
+ ---------------------------------------------------------------------------*/
+ //=====================================================================
+ //= OEMPreloadDialog
+ //=====================================================================
+ //---------------------------------------------------------------------
+ OEMPreloadDialog::OEMPreloadDialog( Window* _pParent,
+ const Reference< XPropertySet >& /*_rxObjectModel*/, const Reference< XMultiServiceFactory >& /*_rxORB*/ )
+ :WizardDialog(_pParent, ModuleRes(RID_DLG_OEMWIZARD)/*, _rxObjectModel, _rxORB*/)
+ ,aPrevPB(this, ModuleRes(PB_PREV ))
+ ,aNextPB(this, ModuleRes(PB_NEXT ))
+ ,aCancelPB(this, ModuleRes(PB_CANCEL ))
+ ,aAcceptST(ModuleRes(ST_ACCEPT))
+ ,aFinishST(ModuleRes(ST_FINISH))
+ ,aLicense(ModuleRes(ST_LICENSE_AGREEMENT))
+ ,aUserData(ModuleRes(ST_INSERT_USER_DATA))
+ ,pImpl(new OEMPreloadDialog_Impl(this))
+ {
+ FreeResource();
+ aDlgTitle = GetText();
+ aPrevPB.Enable(FALSE);
+ aNextST = aNextPB.GetText();
+ aPrevPB.SetClickHdl(LINK(this, OEMPreloadDialog, NextPrevPageHdl));
+ aNextPB.SetClickHdl(LINK(this, OEMPreloadDialog, NextPrevPageHdl));
+ AddButton( &aPrevPB, WIZARDDIALOG_BUTTON_STDOFFSET_X );
+ AddButton( &aNextPB, WIZARDDIALOG_BUTTON_STDOFFSET_X );
+ AddButton( &aCancelPB, WIZARDDIALOG_BUTTON_STDOFFSET_X );
+
+ SetPrevButton(&aPrevPB);
+ SetNextButton(&aNextPB);
+
+ AddPage( pImpl->pWelcomePage );
+ AddPage( pImpl->pLicensePage );
+ if ( pImpl->pUserDataPage )
+ AddPage( pImpl->pUserDataPage );
+ SetPage( OEM_WELCOME, pImpl->pWelcomePage );
+ SetPage( OEM_LICENSE, pImpl->pLicensePage );
+ if ( pImpl->pUserDataPage )
+ SetPage( OEM_USERDATA, pImpl->pUserDataPage );
+ ShowPage( OEM_WELCOME );
+ }
+/* -----------------------------14.11.2001 11:33------------------------------
+
+ ---------------------------------------------------------------------------*/
+ OEMPreloadDialog::~OEMPreloadDialog( )
+ {
+ delete pImpl;
+ }
+/* -----------------------------14.11.2001 11:33------------------------------
+
+ ---------------------------------------------------------------------------*/
+ IMPL_LINK(OEMPreloadDialog, NextPrevPageHdl, PushButton*, pButton)
+ {
+ if(pButton == &aPrevPB)
+ {
+ if(GetCurLevel())
+ ShowPage(GetCurLevel() - 1);
+ }
+ else if(OEM_USERDATA > GetCurLevel())
+ ShowPage(GetCurLevel() + 1);
+ else
+ {
+ pImpl->WriteUserData();
+ Finnish(RET_OK);
+ }
+
+ String sTitle(aDlgTitle);
+
+ switch(GetCurLevel())
+ {
+ case OEM_WELCOME:
+ aNextPB.SetText(aNextST);
+ aNextPB.Enable(TRUE);
+ break;
+ case OEM_LICENSE:
+ sTitle += aLicense;
+ aNextPB.SetText(aNextST);
+ aCancelPB.GrabFocus();
+ break;
+ case OEM_USERDATA:
+ sTitle += aUserData;
+ aNextPB.SetText(aFinishST);
+ break;
+ }
+ SetText(sTitle);
+ aPrevPB.Enable(GetCurLevel() != OEM_WELCOME);
+ return 0;
+ }
+/* -----------------------------14.11.2001 11:33------------------------------
+
+ ---------------------------------------------------------------------------*/
+ sal_Bool OEMPreloadDialog::LoadFromLocalFile(const String& rFileName, String& rContent)
+ {
+ SvtPathOptions aPathOpt;
+ String sFileName = aPathOpt.GetUserConfigPath();//GetModulePath();
+ INetURLObject aURLObject(sFileName);
+ OSL_ASSERT(aURLObject.getSegmentCount() >= 2);
+ aURLObject.removeSegment(); //remove '/config'
+ aURLObject.removeSegment(); //remove '/user'
+ sFileName = aURLObject.GetMainURL(INetURLObject::DECODE_TO_IURI);
+ sFileName += rFileName;
+
+ SfxMedium aMedium( sFileName,STREAM_READ, TRUE );
+ SvStream* pInStream = aMedium.GetInStream();
+ if( !pInStream )
+ return sal_False;
+
+ pInStream->ReadCString( rContent, RTL_TEXTENCODING_UTF8 );
+
+ xub_StrLen nPos;
+ while ( ( nPos = rContent.Search( 12 )) != STRING_NOTFOUND )
+ rContent.Erase( nPos, 1 );
+ return sal_True;
+ }
+
+
+ void OEMPreloadDialog::SetCancelString( const String& rText )
+ {
+ aCancelPB.SetText(rText);
+ }
+
+/* -----------------------------13.11.2001 12:29------------------------------
+
+ ---------------------------------------------------------------------------*/
+ OEMWelcomeTabPage::OEMWelcomeTabPage(Window* pParent) :
+ TabPage(pParent, ModuleRes(RID_TP_WELCOME)),
+ aInfoFT(this, ModuleRes(FT_INFO))
+ {
+ FreeResource();
+ }
+/* -----------------------------13.11.2001 12:30------------------------------
+
+ ---------------------------------------------------------------------------*/
+ OEMWelcomeTabPage::~OEMWelcomeTabPage()
+ {
+ }
+/* -----------------------------13.11.2001 12:29------------------------------
+
+ ---------------------------------------------------------------------------*/
+ OEMLicenseTabPage::OEMLicenseTabPage(OEMPreloadDialog* pParent) :
+ TabPage(pParent, ModuleRes(RID_TP_LICENSE)),
+ aLicenseML(this, ModuleRes(ML_LICENSE)),
+ aInfo1FT(this, ModuleRes(FT_INFO1)),
+ aInfo2FT(this, ModuleRes(FT_INFO2)),
+ aInfo3FT(this, ModuleRes(FT_INFO3)),
+ aInfo2_1FT(this, ModuleRes(FT_INFO2_1)),
+ aInfo3_1FT(this, ModuleRes(FT_INFO3_1)),
+ aCBAccept(this, ModuleRes(CB_ACCEPT)),
+ aPBPageDown(this, ModuleRes(PB_PAGEDOWN)),
+ aArrow(this, ModuleRes(IMG_ARROW)),
+ aStrAccept( ModuleRes(LICENCE_ACCEPT) ),
+ aStrNotAccept( ModuleRes(LICENCE_NOTACCEPT) ),
+ bEndReached(FALSE),
+ pPreloadDialog(pParent)
+ {
+ FreeResource();
+
+ aLicenseML.SetEndReachedHdl( LINK(this, OEMLicenseTabPage, EndReachedHdl) );
+ aLicenseML.SetScrolledHdl( LINK(this, OEMLicenseTabPage, ScrolledHdl) );
+
+ aPBPageDown.SetClickHdl( LINK(this, OEMLicenseTabPage, PageDownHdl) );
+ aCBAccept.SetClickHdl( LINK(this, OEMLicenseTabPage, AcceptHdl) );
+
+ // We want a automatic repeating page down button
+ WinBits aStyle = aPBPageDown.GetStyle();
+ aStyle |= WB_REPEAT;
+ aPBPageDown.SetStyle( aStyle );
+
+ aOldCancelText = pPreloadDialog->GetCancelString();
+ pPreloadDialog->SetCancelString( aStrNotAccept );
+
+ String aText = aInfo2FT.GetText();
+ aText.SearchAndReplaceAll( UniString::CreateFromAscii("%PAGEDOWN"), aPBPageDown.GetText() );
+ aInfo2FT.SetText( aText );
+ }
+/* -----------------------------13.11.2001 12:30------------------------------
+
+ ---------------------------------------------------------------------------*/
+ OEMLicenseTabPage::~OEMLicenseTabPage()
+ {
+ }
+/* ---------------------------14.11.2001 11:24----------------------------
+
+ -----------------------------------------------------------------------*/
+ void OEMLicenseTabPage::ActivatePage()
+ {
+ if(!aLicenseML.GetText().Len())
+ {
+ aLicenseML.SetLeftMargin( 5 );
+ String sLicense;
+#ifdef UNX
+ OEMPreloadDialog::LoadFromLocalFile(String::CreateFromAscii("LICENSE"), sLicense);
+#else
+ OEMPreloadDialog::LoadFromLocalFile(String::CreateFromAscii("license.txt"), sLicense);
+#endif
+ aLicenseML.SetText( sLicense );
+ }
+
+ EnableControls();
+ }
+
+ //------------------------------------------------------------------------
+ IMPL_LINK( OEMLicenseTabPage, AcceptHdl, CheckBox *, EMPTYARG )
+ {
+ EnableControls();
+ return 0;
+ }
+
+ //------------------------------------------------------------------------
+ IMPL_LINK( OEMLicenseTabPage, PageDownHdl, PushButton *, EMPTYARG )
+ {
+ aLicenseML.ScrollDown( SCROLL_PAGEDOWN );
+ return 0;
+ }
+
+ //------------------------------------------------------------------------
+ IMPL_LINK( OEMLicenseTabPage, EndReachedHdl, LicenceView *, EMPTYARG )
+ {
+ bEndReached = TRUE;
+
+ EnableControls();
+ aCBAccept.GrabFocus();
+
+ return 0;
+ }
+
+ //------------------------------------------------------------------------
+ IMPL_LINK( OEMLicenseTabPage, ScrolledHdl, LicenceView *, EMPTYARG )
+ {
+ EnableControls();
+
+ return 0;
+ }
+
+ //------------------------------------------------------------------------
+ void OEMLicenseTabPage::EnableControls()
+ {
+ if( !bEndReached &&
+ ( aLicenseML.IsEndReached() || !aLicenseML.GetText().Len() ) )
+ bEndReached = TRUE;
+
+ if ( bEndReached )
+ {
+ Point aPos( 0, aInfo3_1FT.GetPosPixel().Y() );
+ aArrow.SetPosPixel( aPos );
+ aCBAccept.Enable();
+ }
+ else
+ {
+ Point aPos( 0, aInfo2_1FT.GetPosPixel().Y() );
+ aArrow.SetPosPixel( aPos );
+ aCBAccept.Disable();
+ }
+
+ if ( aLicenseML.IsEndReached() )
+ aPBPageDown.Disable();
+ else
+ aPBPageDown.Enable();
+
+ if ( aCBAccept.IsChecked() )
+ {
+ PushButton *pNext = pPreloadDialog->GetNextButton();
+ if ( ! pNext->IsEnabled() )
+ {
+ pPreloadDialog->SetCancelString( aOldCancelText );
+ pNext->Enable(TRUE);
+ }
+ }
+ else
+ {
+ PushButton *pNext = pPreloadDialog->GetNextButton();
+ if ( pNext->IsEnabled() )
+ {
+ pPreloadDialog->SetCancelString( aStrNotAccept );
+ pNext->Enable(FALSE);
+ }
+ }
+ }
+
+ //------------------------------------------------------------------------
+ //------------------------------------------------------------------------
+ //------------------------------------------------------------------------
+ LicenceView::LicenceView( Window* pParent, const ResId& rResId )
+ : MultiLineEdit( pParent, rResId )
+ {
+ SetLeftMargin( 5 );
+
+ mbEndReached = IsEndReached();
+
+ StartListening( *GetTextEngine() );
+ }
+
+ //------------------------------------------------------------------------
+ LicenceView::~LicenceView()
+ {
+ maEndReachedHdl = Link();
+ maScrolledHdl = Link();
+
+ EndListeningAll();
+ }
+
+ //------------------------------------------------------------------------
+ void LicenceView::ScrollDown( ScrollType eScroll )
+ {
+ ScrollBar* pScroll = GetVScrollBar();
+
+ if ( pScroll )
+ pScroll->DoScrollAction( eScroll );
+ }
+
+ //------------------------------------------------------------------------
+ BOOL LicenceView::IsEndReached() const
+ {
+ BOOL bEndReached;
+
+ ExtTextView* pView = GetTextView();
+ ExtTextEngine* pEdit = GetTextEngine();
+ ULONG nHeight = pEdit->GetTextHeight();
+ Size aOutSize = pView->GetWindow()->GetOutputSizePixel();
+ Point aBottom( 0, aOutSize.Height() );
+
+ if ( (ULONG) pView->GetDocPos( aBottom ).Y() >= nHeight - 1 )
+ bEndReached = TRUE;
+ else
+ bEndReached = FALSE;
+
+ return bEndReached;
+ }
+
+ //------------------------------------------------------------------------
+ void LicenceView::Notify( SfxBroadcaster& /*rBC*/, const SfxHint& rHint )
+ {
+ if ( rHint.IsA( TYPE(TextHint) ) )
+ {
+ BOOL bLastVal = EndReached();
+ ULONG nId = ((const TextHint&)rHint).GetId();
+
+ if ( nId == TEXT_HINT_PARAINSERTED )
+ {
+ if ( bLastVal )
+ mbEndReached = IsEndReached();
+ }
+ else if ( nId == TEXT_HINT_VIEWSCROLLED )
+ {
+ if ( ! mbEndReached )
+ mbEndReached = IsEndReached();
+ maScrolledHdl.Call( this );
+ }
+
+ if ( EndReached() && !bLastVal )
+ {
+ maEndReachedHdl.Call( this );
+ }
+ }
+ }
+
+ //------------------------------------------------------------------------
+
+//.........................................................................
+} // namespace preload
+//.........................................................................
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/preload/oemwiz.hxx b/extensions/source/preload/oemwiz.hxx
new file mode 100644
index 000000000000..5874994b5192
--- /dev/null
+++ b/extensions/source/preload/oemwiz.hxx
@@ -0,0 +1,156 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _EXTENSIONS_PRELOAD_OEMWIZ_HXX_
+#define _EXTENSIONS_PRELOAD_OEMWIZ_HXX_
+
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <svtools/wizdlg.hxx>
+#include <vcl/button.hxx>
+#include <vcl/tabpage.hxx>
+#include <vcl/fixed.hxx>
+#include <svtools/svmedit.hxx>
+#include <svl/lstner.hxx>
+#include <vcl/scrbar.hxx>
+
+//.........................................................................
+namespace preload
+{
+ #define OEM_WELCOME 0
+ #define OEM_LICENSE 1
+ #define OEM_USERDATA 2
+
+//.........................................................................
+ //=====================================================================
+ //= OEMPreloadDialog
+ //=====================================================================
+ struct OEMPreloadDialog_Impl;
+ class OEMPreloadDialog : public WizardDialog
+ {
+ PushButton aPrevPB;
+ PushButton aNextPB;
+ CancelButton aCancelPB;
+
+ String aNextST;
+ String aAcceptST;
+ String aFinishST;
+ String aDlgTitle;
+ String aLicense;
+ String aUserData;
+ OEMPreloadDialog_Impl* pImpl;
+
+ DECL_LINK(NextPrevPageHdl, PushButton*);
+ protected:
+
+ public:
+ OEMPreloadDialog(
+ Window* _pParent,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxObjectModel,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB
+ );
+ ~OEMPreloadDialog();
+
+ const String& GetAcceptString()const {return aAcceptST;}
+ const String GetCancelString() const {return aCancelPB.GetText();}
+ void SetCancelString( const String& rText );
+
+ static sal_Bool LoadFromLocalFile(const String& rFileName, String& rContent);
+ };
+ class OEMWelcomeTabPage : public TabPage
+ {
+ FixedText aInfoFT;
+ public:
+ OEMWelcomeTabPage(Window* pParent);
+ ~OEMWelcomeTabPage();
+ };
+ class LicenceView : public MultiLineEdit, public SfxListener
+ {
+ BOOL mbEndReached;
+ Link maEndReachedHdl;
+ Link maScrolledHdl;
+
+ public:
+ LicenceView( Window* pParent, const ResId& rResId );
+ ~LicenceView();
+
+ void ScrollDown( ScrollType eScroll );
+
+ BOOL IsEndReached() const;
+ BOOL EndReached() const { return mbEndReached; }
+ void SetEndReached( BOOL bEnd ) { mbEndReached = bEnd; }
+
+ void SetEndReachedHdl( const Link& rHdl ) { maEndReachedHdl = rHdl; }
+ const Link& GetAutocompleteHdl() const { return maEndReachedHdl; }
+
+ void SetScrolledHdl( const Link& rHdl ) { maScrolledHdl = rHdl; }
+ const Link& GetScrolledHdl() const { return maScrolledHdl; }
+
+ virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
+ private:
+ using MultiLineEdit::Notify;
+ };
+ class OEMLicenseTabPage : public TabPage
+ {
+ LicenceView aLicenseML;
+ FixedText aInfo1FT;
+ FixedText aInfo2FT;
+ FixedText aInfo3FT;
+ FixedText aInfo2_1FT;
+ FixedText aInfo3_1FT;
+ CheckBox aCBAccept;
+ PushButton aPBPageDown;
+ FixedImage aArrow;
+ String aStrAccept;
+ String aStrNotAccept;
+ String aOldCancelText;
+ BOOL bEndReached;
+
+ OEMPreloadDialog* pPreloadDialog;
+
+ void EnableControls();
+
+ DECL_LINK( AcceptHdl, CheckBox * );
+ DECL_LINK( PageDownHdl, PushButton * );
+ DECL_LINK( EndReachedHdl, LicenceView * );
+ DECL_LINK( ScrolledHdl, LicenceView * );
+
+ public:
+ OEMLicenseTabPage(OEMPreloadDialog* pParent);
+ ~OEMLicenseTabPage();
+
+ virtual void ActivatePage();
+ };
+
+//.........................................................................
+} // namespace preload
+//.........................................................................
+
+#endif // _EXTENSIONS_PRELOAD_OEMWIZ_HXX_
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/preload/preload.hrc b/extensions/source/preload/preload.hrc
new file mode 100644
index 000000000000..a7d9725bd110
--- /dev/null
+++ b/extensions/source/preload/preload.hrc
@@ -0,0 +1,58 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _EXTENSIONS_PRELOAD_PRELOAD_HRC_
+#define _EXTENSIONS_PRELOAD_PRELOAD_HRC_
+
+#define RID_DLG_OEMWIZARD 1024
+#define RID_TP_LICENSE 1025
+#define RID_TP_WELCOME 1027
+
+
+#define PB_PREV 1
+#define PB_NEXT 2
+#define PB_CANCEL 3
+
+#define ST_ACCEPT 5
+#define ST_FINISH 6
+#define FT_INFO 7
+#define ML_README 8
+#define FT_INFO1 9
+#define FT_INFO2 10
+#define ML_LICENSE 11
+#define ST_LICENSE_AGREEMENT 12
+#define ST_INSERT_USER_DATA 13
+#define IMG_ARROW 14
+#define FT_INFO2_1 15
+#define FT_INFO3_1 16
+#define FT_INFO3 17
+#define PB_PAGEDOWN 18
+#define CB_ACCEPT 19
+#define LICENCE_ACCEPT 20
+#define LICENCE_NOTACCEPT 21
+
+#endif
diff --git a/extensions/source/preload/preload.src b/extensions/source/preload/preload.src
new file mode 100644
index 000000000000..301e489cddbf
--- /dev/null
+++ b/extensions/source/preload/preload.src
@@ -0,0 +1,282 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _EXTENSIONS_PRELOAD_PRELOAD_HRC_
+#include "preload.hrc"
+#endif
+
+ModalDialog RID_DLG_OEMWIZARD
+{
+ Text = "%PRODUCTNAME %PRODUCTVERSION";
+
+ OutputSize = TRUE ;
+ SVLook = TRUE ;
+ Moveable = TRUE ;
+ Closeable = TRUE ;
+ Hide = TRUE;
+ PushButton PB_PREV
+ {
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ Text [ en-US ] = "<< Back" ;
+ };
+ PushButton PB_NEXT
+ {
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ Text [ en-US ] = "Next >>" ;
+ };
+ CancelButton PB_CANCEL
+ {
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ };
+ String ST_ACCEPT
+ {
+ Text [ en-US ] = "Accept";
+ };
+ String ST_FINISH
+ {
+ Text [ en-US ] = "Finish";
+ };
+ String ST_LICENSE_AGREEMENT
+ {
+ Text [ en-US ] = " - Software License Agreement";
+ };
+
+ String ST_INSERT_USER_DATA
+ {
+ Text [ en-US ] = "- User Data";
+ };
+};
+TabPage RID_TP_WELCOME
+{
+// HelpId = ;
+ OutputSize = TRUE ;
+ SVLook = TRUE ;
+ Hide = TRUE ;
+ Size = MAP_APPFONT ( 260 , 185 ) ;
+ Text [ en-US ] = "Welcome";
+ FixedText FT_INFO
+ {
+ Pos = MAP_APPFONT ( 6 , 3 ) ;
+ Size = MAP_APPFONT ( 248 , 174 ) ;
+ WordBreak = TRUE ;
+ Text [ en-US ] = "Welcome to %PRODUCTNAME %PRODUCTVERSION OEM\n\nTo start the %PRODUCTNAME %PRODUCTVERSION OEM, "
+ "please enter your personal data in the dialog following the license text. Important information is contained "
+ "in the readme files which are located in the %PRODUCTNAME product directory. Please read these files carefully. "
+ "You can also find detailed information at the Oracle website \n\n"
+ "http://www.oracle.com/us/products/applications/open-office.";
+ };
+};
+
+#define LICENSE_DIALOG_WIDTH 260
+#define LICENSE_DIALOG_HEIGTH 185
+#define LICENSE_RIGHT_BORDER 7
+#define LICENSE_BOTTOM_BORDER 0
+#define LICENSE_ROW_1 (7)
+#define LICENSE_COL_1 (7)
+
+#define OFFSET 2
+#define COL2_WIDTH 10
+#define OFFSET_IMG 10
+#define FT_HEIGHT 8
+#define PB_HEIGHT 14
+#define PD_WIDTH 40
+
+#define LICENCE_HEIGHT 102
+#define LICENSE_ROW_2 (LICENSE_ROW_1 + OFFSET + LICENCE_HEIGHT)
+#define LICENSE_ROW_3 (LICENSE_ROW_2 + OFFSET + FT_HEIGHT)
+#define LICENSE_ROW_4 (LICENSE_ROW_3 + OFFSET + 3*FT_HEIGHT )
+#define LICENSE_ROW_5 (LICENSE_ROW_4 + OFFSET + FT_HEIGHT)
+
+/*
+#define LICENSE_ROW_5 (LICENSE_DIALOG_HEIGTH - LICENSE_BOTTOM_BORDER - OFFSET - FT_HEIGHT)
+#define LICENSE_ROW_4 (LICENSE_ROW_5 - OFFSET - FT_HEIGHT)
+#define LICENSE_ROW_3 (LICENSE_ROW_4 - OFFSET - 3*FT_HEIGHT)
+#define LICENSE_ROW_2 (LICENSE_ROW_3 - OFFSET - FT_HEIGHT)
+#define LICENCE_HEIGHT (LICENSE_ROW_2-LICENSE_ROW_1-OFFSET)
+*/
+
+
+#define LICENSE_COL_2 (LICENSE_COL_1 + OFFSET_IMG)
+#define LICENSE_COL_3 (LICENSE_COL_2 + COL2_WIDTH +1)
+#define LICENSE_COL_4 (LICENSE_DIALOG_WIDTH - LICENSE_RIGHT_BORDER - PD_WIDTH)
+
+#define LICENSE_WIDTH (LICENSE_DIALOG_WIDTH - LICENSE_RIGHT_BORDER - LICENSE_ROW_1)
+#define COL3_WIDTH (LICENSE_COL_4 - LICENSE_COL_3)
+
+
+TabPage RID_TP_LICENSE
+{
+ OutputSize = TRUE ;
+ SVLook = TRUE ;
+ Hide = TRUE ;
+ Size = MAP_APPFONT ( LICENSE_DIALOG_WIDTH , LICENSE_DIALOG_HEIGTH ) ;
+ Text [ en-US ] = "License Agreement";
+
+ MultiLineEdit ML_LICENSE
+ {
+ PosSize = MAP_APPFONT ( LICENSE_COL_1 , LICENSE_ROW_1 , LICENSE_WIDTH , LICENCE_HEIGHT ) ;
+ Border = TRUE ;
+ VScroll = TRUE ;
+ ReadOnly = TRUE ;
+ };
+
+ FixedText FT_INFO1
+ {
+ WordBreak = TRUE ;
+ Pos = MAP_APPFONT ( LICENSE_COL_1 , LICENSE_ROW_2 ) ;
+ Size = MAP_APPFONT ( LICENSE_WIDTH , FT_HEIGHT ) ;
+ Text [ en-US ] = "Please follow these steps to proceed with the installation:" ;
+ };
+
+ FixedImage IMG_ARROW
+ {
+ Pos = MAP_APPFONT ( LICENSE_COL_1 , LICENSE_ROW_3 ) ;
+ Size = MAP_PIXEL ( 16 , 16 ) ;
+ Fixed = Image
+ {
+ ImageBitmap = Bitmap
+ {
+ File = "arrow.bmp" ;
+ File[ ar ] = "m_arrow.bmp" ;
+ };
+ MaskColor = Color { Red = 0xFFFF ; Green = 0x0000 ; Blue = 0xFFFF ; };
+ };
+ };
+
+ FixedText FT_INFO2_1
+ {
+ WordBreak = TRUE ;
+ Pos = MAP_APPFONT ( LICENSE_COL_2 , LICENSE_ROW_3 ) ;
+ Size = MAP_APPFONT ( COL2_WIDTH , FT_HEIGHT ) ;
+ Text [ en-US ] = "1." ;
+ };
+
+ FixedText FT_INFO2
+ {
+ WordBreak = TRUE ;
+ Pos = MAP_APPFONT ( LICENSE_COL_3 , LICENSE_ROW_3 ) ;
+ Size = MAP_APPFONT ( COL3_WIDTH, 3*FT_HEIGHT ) ;
+ Text [ en-US ] = "View the complete License Agreement. Please use the scroll bar or the '%PAGEDOWN' button in this dialog to view the entire license text." ;
+ };
+
+ PushButton PB_PAGEDOWN
+ {
+ TabStop = TRUE ;
+ Pos = MAP_APPFONT ( LICENSE_COL_4 , LICENSE_ROW_3 ) ;
+ Size = MAP_APPFONT ( PD_WIDTH , PB_HEIGHT ) ;
+ Text [ en-US ] = "Page Down" ;
+ };
+
+ FixedText FT_INFO3_1
+ {
+ WordBreak = TRUE ;
+ Pos = MAP_APPFONT ( LICENSE_COL_2 , LICENSE_ROW_4 ) ;
+ Size = MAP_APPFONT ( COL2_WIDTH, FT_HEIGHT ) ;
+ Text [ en-US ] = "2." ;
+ };
+
+ FixedText FT_INFO3
+ {
+ WordBreak = TRUE ;
+ Pos = MAP_APPFONT ( LICENSE_COL_3, LICENSE_ROW_4 ) ;
+ Size = MAP_APPFONT ( COL3_WIDTH, FT_HEIGHT ) ;
+ Text [ en-US ] = "Accept the License Agreement." ;
+ };
+
+ CheckBox CB_ACCEPT
+ {
+ TabStop = TRUE ;
+ Pos = MAP_APPFONT ( LICENSE_COL_3, LICENSE_ROW_5 ) ;
+ Size = MAP_APPFONT ( COL3_WIDTH, FT_HEIGHT ) ;
+ Text [ en-US ] = "I accept the terms of the Agreement." ;
+ };
+
+ String LICENCE_ACCEPT
+ {
+ Text [ en-US ] = "~Accept" ;
+ };
+
+ String LICENCE_NOTACCEPT
+ {
+ Text [ en-US ] = "Decline" ;
+ };
+
+};
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/extensions/source/preload/preloadservices.cxx b/extensions/source/preload/preloadservices.cxx
new file mode 100644
index 000000000000..f23d65310479
--- /dev/null
+++ b/extensions/source/preload/preloadservices.cxx
@@ -0,0 +1,73 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+#include "preloadservices.hxx"
+#include "componentmodule.hxx"
+#include "unoautopilot.hxx"
+#include "oemwiz.hxx"
+
+// the registration methods
+extern "C" void SAL_CALL createRegistryInfo_OEMPreloadDialog()
+{
+ static ::preload::OMultiInstanceAutoRegistration<
+ ::preload::OUnoAutoPilot< ::preload::OEMPreloadDialog, ::preload::OEMPreloadSI >
+ > aAutoRegistration;
+}
+static const char cServiceName[] = "org.openoffice.comp.preload.OEMPreloadWizard";
+//.........................................................................
+namespace preload
+{
+//.........................................................................
+
+ using namespace ::com::sun::star::uno;
+
+ //=====================================================================
+ //= OEMPreloadSI
+ //=====================================================================
+ //---------------------------------------------------------------------
+ ::rtl::OUString OEMPreloadSI::getImplementationName() const
+ {
+ return ::rtl::OUString::createFromAscii(cServiceName);
+ }
+
+ //---------------------------------------------------------------------
+ Sequence< ::rtl::OUString > OEMPreloadSI::getServiceNames() const
+ {
+ Sequence< ::rtl::OUString > aReturn(1);
+ aReturn[0] = ::rtl::OUString::createFromAscii(cServiceName);
+ return aReturn;
+ }
+
+
+//.........................................................................
+} // namespace preload
+//.........................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/preload/preloadservices.hxx b/extensions/source/preload/preloadservices.hxx
new file mode 100644
index 000000000000..ba51e0547bab
--- /dev/null
+++ b/extensions/source/preload/preloadservices.hxx
@@ -0,0 +1,57 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _EXTENSIONS_PRELOAD_PRELOADSERVICES_HXX_
+#define _EXTENSIONS_PRELOAD_PRELOADSERVICES_HXX_
+
+#include <com/sun/star/uno/Sequence.hxx>
+#include <rtl/ustring.hxx>
+
+//.........................................................................
+namespace preload
+{
+//.........................................................................
+
+ //=====================================================================
+ //= OGroupBoxSI
+ //=====================================================================
+ /// service info for the OEM preload wizard
+ struct OEMPreloadSI
+ {
+ public:
+ ::rtl::OUString getImplementationName() const;
+ ::com::sun::star::uno::Sequence< ::rtl::OUString >
+ getServiceNames() const;
+ };
+//.........................................................................
+} // namespace preload
+//.........................................................................
+
+#endif // _EXTENSIONS_PRELOAD_PRELOADSERVICES_HXX_
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/preload/services.cxx b/extensions/source/preload/services.cxx
new file mode 100644
index 000000000000..04dcc48657ef
--- /dev/null
+++ b/extensions/source/preload/services.cxx
@@ -0,0 +1,109 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+#include "componentmodule.hxx"
+
+//---------------------------------------------------------------------------------------
+
+using namespace ::rtl;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::registry;
+
+//---------------------------------------------------------------------------------------
+
+extern "C" void SAL_CALL createRegistryInfo_OEMPreloadDialog();
+
+//---------------------------------------------------------------------------------------
+
+extern "C" void SAL_CALL preload_initializeModule()
+{
+ static sal_Bool s_bInit = sal_False;
+ if (!s_bInit)
+ {
+ createRegistryInfo_OEMPreloadDialog();
+ ::preload::OModule::setResourceFilePrefix("preload");
+ s_bInit = sal_True;
+ }
+}
+
+//---------------------------------------------------------------------------------------
+
+extern "C" SAL_DLLPUBLIC_EXPORT void SAL_CALL
+component_getImplementationEnvironment(
+ const sal_Char **ppEnvTypeName,
+ uno_Environment ** /*ppEnv*/
+ )
+{
+ preload_initializeModule();
+ *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
+}
+
+//---------------------------------------------------------------------------------------
+extern "C" SAL_DLLPUBLIC_EXPORT sal_Bool SAL_CALL component_writeInfo(
+ void* pServiceManager,
+ void* pRegistryKey
+ )
+{
+ if (pRegistryKey)
+ try
+ {
+ return ::preload::OModule::writeComponentInfos(
+ static_cast<XMultiServiceFactory*>(pServiceManager),
+ static_cast<XRegistryKey*>(pRegistryKey));
+ }
+ catch (InvalidRegistryException& )
+ {
+ OSL_ASSERT("preload::component_writeInfo: could not create a registry key (InvalidRegistryException) !");
+ }
+
+ return sal_False;
+}
+
+//---------------------------------------------------------------------------------------
+extern "C" SAL_DLLPUBLIC_EXPORT void* SAL_CALL component_getFactory(
+ const sal_Char* pImplementationName,
+ void* pServiceManager,
+ void* /*pRegistryKey*/)
+{
+ Reference< XInterface > xRet;
+ if (pServiceManager && pImplementationName)
+ {
+ xRet = ::preload::OModule::getComponentFactory(
+ ::rtl::OUString::createFromAscii(pImplementationName),
+ static_cast< XMultiServiceFactory* >(pServiceManager));
+ }
+
+ if (xRet.is())
+ xRet->acquire();
+ return xRet.get();
+};
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/preload/unoautopilot.hxx b/extensions/source/preload/unoautopilot.hxx
new file mode 100644
index 000000000000..dd485d887876
--- /dev/null
+++ b/extensions/source/preload/unoautopilot.hxx
@@ -0,0 +1,109 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _EXTENSIONS_PRELOAD_UNOAUTOPILOT_HXX_
+#define _EXTENSIONS_PRELOAD_UNOAUTOPILOT_HXX_
+
+#include <svtools/genericunodialog.hxx>
+#include <comphelper/proparrhlp.hxx>
+#include "componentmodule.hxx"
+#include <cppuhelper/typeprovider.hxx>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/beans/PropertyValue.hpp>
+
+//.........................................................................
+namespace preload
+{
+//.........................................................................
+
+ //=====================================================================
+ //= IServiceInfo
+ //=====================================================================
+ /** interface for the SERVICEINFO template parameter of the OUnoAutoPilot class
+ */
+ struct IServiceInfo
+ {
+ public:
+ ::rtl::OUString getImplementationName() const;
+ ::com::sun::star::uno::Sequence< ::rtl::OUString >
+ getServiceNames() const;
+ };
+
+ //=====================================================================
+ //= OUnoAutoPilot
+ //=====================================================================
+ typedef ::svt::OGenericUnoDialog OUnoAutoPilot_Base;
+ template <class TYPE, class SERVICEINFO>
+ class OUnoAutoPilot
+ :public OUnoAutoPilot_Base
+ ,public ::comphelper::OPropertyArrayUsageHelper< OUnoAutoPilot< TYPE, SERVICEINFO > >
+ ,public OModuleResourceClient
+ {
+ OUnoAutoPilot(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB);
+
+ protected:
+ ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >
+ m_xObjectModel;
+
+ public:
+ // XTypeProvider
+ virtual ::com::sun::star::uno::Sequence<sal_Int8> SAL_CALL getImplementationId( ) throw(::com::sun::star::uno::RuntimeException);
+
+ // XServiceInfo
+ virtual ::rtl::OUString SAL_CALL getImplementationName() throw(::com::sun::star::uno::RuntimeException);
+ virtual ::comphelper::StringSequence SAL_CALL getSupportedServiceNames() throw(::com::sun::star::uno::RuntimeException);
+
+ // XServiceInfo - static methods
+ static ::com::sun::star::uno::Sequence< ::rtl::OUString > getSupportedServiceNames_Static(void) throw( ::com::sun::star::uno::RuntimeException );
+ static ::rtl::OUString getImplementationName_Static(void) throw( ::com::sun::star::uno::RuntimeException );
+ static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >
+ SAL_CALL Create(const ::com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory >&);
+
+ // XPropertySet
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo> SAL_CALL getPropertySetInfo() throw(::com::sun::star::uno::RuntimeException);
+ virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper();
+
+ // OPropertyArrayUsageHelper
+ virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const;
+
+ protected:
+ // OGenericUnoDialog overridables
+ virtual Dialog* createDialog(Window* _pParent);
+ virtual void implInitialize(const com::sun::star::uno::Any& _rValue);
+ };
+
+#include "unoautopilot.inl"
+
+//.........................................................................
+} // namespace dbp
+//.........................................................................
+
+#endif // _EXTENSIONS_PRELOAD_UNOAUTOPILOT_HXX_
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/preload/unoautopilot.inl b/extensions/source/preload/unoautopilot.inl
new file mode 100644
index 000000000000..77c3f7b589ab
--- /dev/null
+++ b/extensions/source/preload/unoautopilot.inl
@@ -0,0 +1,133 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// no include protecttion
+// this file is included from unoautopilot.hxx directly
+
+//using namespace ::com::sun::star::uno;
+//using namespace ::com::sun::star::lang;
+//using namespace ::com::sun::star::beans;
+//
+//=====================================================================
+//= OUnoAutoPilot
+//=====================================================================
+//---------------------------------------------------------------------
+template <class TYPE, class SERVICEINFO>
+OUnoAutoPilot<TYPE, SERVICEINFO>::OUnoAutoPilot(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB)
+ :OUnoAutoPilot_Base(_rxORB)
+{
+}
+
+//---------------------------------------------------------------------
+template <class TYPE, class SERVICEINFO>
+::com::sun::star::uno::Sequence<sal_Int8> SAL_CALL OUnoAutoPilot<TYPE, SERVICEINFO>::getImplementationId( ) throw(::com::sun::star::uno::RuntimeException)
+{
+ static ::cppu::OImplementationId aId;
+ return aId.getImplementationId();
+}
+
+//---------------------------------------------------------------------
+template <class TYPE, class SERVICEINFO>
+::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL OUnoAutoPilot<TYPE, SERVICEINFO>::Create(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory)
+{
+ return *(new OUnoAutoPilot<TYPE, SERVICEINFO>(_rxFactory));
+}
+
+//---------------------------------------------------------------------
+template <class TYPE, class SERVICEINFO>
+::rtl::OUString SAL_CALL OUnoAutoPilot<TYPE, SERVICEINFO>::getImplementationName() throw(::com::sun::star::uno::RuntimeException)
+{
+ return getImplementationName_Static();
+}
+
+//---------------------------------------------------------------------
+template <class TYPE, class SERVICEINFO>
+::rtl::OUString OUnoAutoPilot<TYPE, SERVICEINFO>::getImplementationName_Static() throw(::com::sun::star::uno::RuntimeException)
+{
+ return SERVICEINFO().getImplementationName();
+}
+
+//---------------------------------------------------------------------
+template <class TYPE, class SERVICEINFO>
+::comphelper::StringSequence SAL_CALL OUnoAutoPilot<TYPE, SERVICEINFO>::getSupportedServiceNames() throw(::com::sun::star::uno::RuntimeException)
+{
+ return getSupportedServiceNames_Static();
+}
+
+//---------------------------------------------------------------------
+template <class TYPE, class SERVICEINFO>
+::comphelper::StringSequence OUnoAutoPilot<TYPE, SERVICEINFO>::getSupportedServiceNames_Static() throw(::com::sun::star::uno::RuntimeException)
+{
+ return SERVICEINFO().getServiceNames();
+}
+
+//---------------------------------------------------------------------
+template <class TYPE, class SERVICEINFO>
+::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL OUnoAutoPilot<TYPE, SERVICEINFO>::getPropertySetInfo() throw(::com::sun::star::uno::RuntimeException)
+{
+ ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) );
+ return xInfo;
+}
+
+//---------------------------------------------------------------------
+template <class TYPE, class SERVICEINFO>
+::cppu::IPropertyArrayHelper& OUnoAutoPilot<TYPE, SERVICEINFO>::getInfoHelper()
+{
+ return *const_cast<OUnoAutoPilot*>(this)->getArrayHelper();
+}
+
+//--------------------------------------------------------------------------
+template <class TYPE, class SERVICEINFO>
+::cppu::IPropertyArrayHelper* OUnoAutoPilot<TYPE, SERVICEINFO>::createArrayHelper( ) const
+{
+ ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property > aProps;
+ describeProperties(aProps);
+ return new ::cppu::OPropertyArrayHelper(aProps);
+}
+
+//--------------------------------------------------------------------------
+template <class TYPE, class SERVICEINFO>
+Dialog* OUnoAutoPilot<TYPE, SERVICEINFO>::createDialog(Window* _pParent)
+{
+ return new TYPE(_pParent, m_xObjectModel, m_aContext.getLegacyServiceFactory());
+}
+
+//--------------------------------------------------------------------------
+template <class TYPE, class SERVICEINFO>
+void OUnoAutoPilot<TYPE, SERVICEINFO>::implInitialize(const com::sun::star::uno::Any& _rValue)
+{
+ ::com::sun::star::beans::PropertyValue aArgument;
+ if (_rValue >>= aArgument)
+ if (0 == aArgument.Name.compareToAscii("ObjectModel"))
+ {
+ aArgument.Value >>= m_xObjectModel;
+ return;
+ }
+
+ OUnoAutoPilot_Base::implInitialize(_rValue);
+}
+
diff --git a/extensions/source/propctrlr/MasterDetailLinkDialog.cxx b/extensions/source/propctrlr/MasterDetailLinkDialog.cxx
new file mode 100644
index 000000000000..ed69baf7a8c1
--- /dev/null
+++ b/extensions/source/propctrlr/MasterDetailLinkDialog.cxx
@@ -0,0 +1,160 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+ #include "precompiled_extensions.hxx"
+ #include "MasterDetailLinkDialog.hxx"
+ #include "formlinkdialog.hxx"
+
+ extern "C" void SAL_CALL createRegistryInfo_MasterDetailLinkDialog()
+{
+ ::pcr::OAutoRegistration< ::pcr::MasterDetailLinkDialog > aAutoRegistration;
+}
+
+//............................................................................
+namespace pcr
+{
+//............................................................................
+
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::lang;
+ using namespace ::com::sun::star::beans;
+
+ //====================================================================
+ //= MasterDetailLinkDialog
+ //====================================================================
+ //---------------------------------------------------------------------
+ MasterDetailLinkDialog::MasterDetailLinkDialog(const Reference< XComponentContext >& _rxContext )
+ :OGenericUnoDialog( _rxContext )
+ {
+ }
+//---------------------------------------------------------------------
+ Sequence<sal_Int8> SAL_CALL MasterDetailLinkDialog::getImplementationId( ) throw(RuntimeException)
+ {
+ static ::cppu::OImplementationId aId;
+ return aId.getImplementationId();
+ }
+
+ //---------------------------------------------------------------------
+ Reference< XInterface > SAL_CALL MasterDetailLinkDialog::Create( const Reference< XComponentContext >& _rxContext )
+ {
+ return *( new MasterDetailLinkDialog( _rxContext ) );
+ }
+
+ //---------------------------------------------------------------------
+ ::rtl::OUString SAL_CALL MasterDetailLinkDialog::getImplementationName() throw(RuntimeException)
+ {
+ return getImplementationName_static();
+ }
+
+ //---------------------------------------------------------------------
+ ::rtl::OUString MasterDetailLinkDialog::getImplementationName_static() throw(RuntimeException)
+ {
+ return ::rtl::OUString::createFromAscii("org.openoffice.comp.form.ui.MasterDetailLinkDialog");
+ }
+
+ //---------------------------------------------------------------------
+ ::comphelper::StringSequence SAL_CALL MasterDetailLinkDialog::getSupportedServiceNames() throw(RuntimeException)
+ {
+ return getSupportedServiceNames_static();
+ }
+
+ //---------------------------------------------------------------------
+ ::comphelper::StringSequence MasterDetailLinkDialog::getSupportedServiceNames_static() throw(RuntimeException)
+ {
+ ::comphelper::StringSequence aSupported(1);
+ aSupported.getArray()[0] = ::rtl::OUString::createFromAscii("com.sun.star.form.MasterDetailLinkDialog");
+ return aSupported;
+ }
+
+ //---------------------------------------------------------------------
+ Reference<XPropertySetInfo> SAL_CALL MasterDetailLinkDialog::getPropertySetInfo() throw(RuntimeException)
+ {
+ Reference<XPropertySetInfo> xInfo( createPropertySetInfo( getInfoHelper() ) );
+ return xInfo;
+ }
+
+ //---------------------------------------------------------------------
+ ::cppu::IPropertyArrayHelper& MasterDetailLinkDialog::getInfoHelper()
+ {
+ return *const_cast<MasterDetailLinkDialog*>(this)->getArrayHelper();
+ }
+
+ //--------------------------------------------------------------------------
+ ::cppu::IPropertyArrayHelper* MasterDetailLinkDialog::createArrayHelper( ) const
+ {
+ Sequence< Property > aProps;
+ describeProperties(aProps);
+ return new ::cppu::OPropertyArrayHelper(aProps);
+ }
+
+ //--------------------------------------------------------------------------
+ Dialog* MasterDetailLinkDialog::createDialog(Window* _pParent)
+ {
+ return new FormLinkDialog(_pParent,m_xDetail,m_xMaster,m_aContext.getLegacyServiceFactory()
+ ,m_sExplanation,m_sDetailLabel,m_sMasterLabel);
+ }
+ //---------------------------------------------------------------------
+ void MasterDetailLinkDialog::implInitialize(const Any& _rValue)
+ {
+ PropertyValue aProperty;
+ if (_rValue >>= aProperty)
+ {
+ if (0 == aProperty.Name.compareToAscii("Detail"))
+ {
+ OSL_VERIFY( aProperty.Value >>= m_xDetail );
+ return;
+ }
+ else if (0 == aProperty.Name.compareToAscii("Master"))
+ {
+ OSL_VERIFY( aProperty.Value >>= m_xMaster );
+ return;
+ }
+ else if (0 == aProperty.Name.compareToAscii("Explanation"))
+ {
+ OSL_VERIFY( aProperty.Value >>= m_sExplanation );
+ return;
+ }
+ else if (0 == aProperty.Name.compareToAscii("DetailLabel"))
+ {
+ OSL_VERIFY( aProperty.Value >>= m_sDetailLabel );
+ return;
+ }
+ else if (0 == aProperty.Name.compareToAscii("MasterLabel"))
+ {
+ OSL_VERIFY( aProperty.Value >>= m_sMasterLabel );
+ return;
+ }
+ }
+ MasterDetailLinkDialog_DBase::implInitialize(_rValue);
+ }
+
+//............................................................................
+} // namespace pcr
+//............................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/propctrlr/MasterDetailLinkDialog.hxx b/extensions/source/propctrlr/MasterDetailLinkDialog.hxx
new file mode 100644
index 000000000000..dcfd8e76e9fd
--- /dev/null
+++ b/extensions/source/propctrlr/MasterDetailLinkDialog.hxx
@@ -0,0 +1,87 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef PROPCTRLR_MASTERDETAILLINKDIALOG_HXX
+#define PROPCTRLR_MASTERDETAILLINKDIALOG_HXX
+#include <svtools/genericunodialog.hxx>
+#include "modulepcr.hxx"
+//........................................................................
+namespace pcr
+{
+//........................................................................
+
+ class MasterDetailLinkDialog;
+ typedef ::svt::OGenericUnoDialog MasterDetailLinkDialog_DBase;
+ typedef ::comphelper::OPropertyArrayUsageHelper< MasterDetailLinkDialog > MasterDetailLinkDialog_PBase;
+
+ //========================================================================
+ //= MasterDetailLinkDialog
+ //========================================================================
+ class MasterDetailLinkDialog : public MasterDetailLinkDialog_DBase
+ ,public MasterDetailLinkDialog_PBase
+ ,public PcrClient
+ {
+ public:
+ MasterDetailLinkDialog(const com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext >& _rxContext);
+
+ // XServiceInfo - static methods
+ static ::com::sun::star::uno::Sequence< ::rtl::OUString > getSupportedServiceNames_static(void) throw( ::com::sun::star::uno::RuntimeException );
+ static ::rtl::OUString getImplementationName_static(void) throw( ::com::sun::star::uno::RuntimeException );
+ static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >
+ SAL_CALL Create(const ::com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext >&);
+ private:
+ // XTypeProvider
+ virtual ::com::sun::star::uno::Sequence<sal_Int8> SAL_CALL getImplementationId( ) throw(::com::sun::star::uno::RuntimeException);
+
+ // XServiceInfo
+ virtual ::rtl::OUString SAL_CALL getImplementationName() throw(::com::sun::star::uno::RuntimeException);
+ virtual ::comphelper::StringSequence SAL_CALL getSupportedServiceNames() throw(::com::sun::star::uno::RuntimeException);
+
+ // XPropertySet
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo> SAL_CALL getPropertySetInfo() throw(::com::sun::star::uno::RuntimeException);
+ virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper();
+
+ // OPropertyArrayUsageHelper
+ virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const;
+
+ // OGenericUnoDialog overridables
+ virtual Dialog* createDialog(Window* _pParent);
+ virtual void implInitialize(const com::sun::star::uno::Any& _rValue);
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet> m_xDetail;
+ ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet> m_xMaster;
+ ::rtl::OUString m_sExplanation;
+ ::rtl::OUString m_sDetailLabel;
+ ::rtl::OUString m_sMasterLabel;
+ };
+
+//........................................................................
+} // namespace pcr
+//........................................................................
+#endif // PROPCTRLR_MASTERDETAILLINKDIALOG_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/propctrlr/browserline.cxx b/extensions/source/propctrlr/browserline.cxx
new file mode 100644
index 000000000000..74a2765166a0
--- /dev/null
+++ b/extensions/source/propctrlr/browserline.cxx
@@ -0,0 +1,550 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+#include "browserline.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/inspection/PropertyLineElement.hpp>
+#include <com/sun/star/graphic/XGraphicProvider.hpp>
+/** === end UNO includes === **/
+
+#include <vcl/svapp.hxx>
+#include <tools/debug.hxx>
+#include <tools/diagnose_ex.h>
+#include <tools/urlobj.hxx>
+#include <toolkit/helper/vclunohelper.hxx>
+
+#include <comphelper/processfactory.hxx>
+#include <comphelper/componentcontext.hxx>
+
+//............................................................................
+namespace pcr
+{
+//............................................................................
+
+ /** === begin UNO using === **/
+ using ::com::sun::star::uno::Reference;
+ using ::com::sun::star::inspection::XPropertyControl;
+ using ::com::sun::star::inspection::XPropertyControlContext;
+ using ::com::sun::star::uno::UNO_QUERY_THROW;
+ using ::com::sun::star::uno::Exception;
+ using ::com::sun::star::graphic::XGraphicProvider;
+ using ::com::sun::star::uno::Sequence;
+ using ::com::sun::star::beans::PropertyValue;
+ using ::com::sun::star::graphic::XGraphic;
+ /** === end UNO using === **/
+
+ namespace PropertyLineElement = ::com::sun::star::inspection::PropertyLineElement;
+
+ //==================================================================
+ //= OBrowserLine
+ //==================================================================
+ DBG_NAME(OBrowserLine)
+ //------------------------------------------------------------------
+
+ OBrowserLine::OBrowserLine( const ::rtl::OUString& _rEntryName, Window* pParent )
+ :m_sEntryName( _rEntryName )
+ ,m_aFtTitle(pParent)
+ ,m_pControlWindow( NULL )
+ ,m_pBrowseButton(NULL)
+ ,m_pAdditionalBrowseButton( NULL )
+ ,m_pClickListener( NULL )
+ ,m_pTheParent(pParent)
+ ,m_nNameWidth(0)
+ ,m_nEnableFlags( 0xFFFF )
+ ,m_bIndentTitle( false )
+ ,m_bReadOnly( false )
+ {
+ DBG_CTOR(OBrowserLine,NULL);
+ m_aFtTitle.Show();
+ }
+
+ //------------------------------------------------------------------
+ OBrowserLine::~OBrowserLine()
+ {
+ implHideBrowseButton( true, false );
+ implHideBrowseButton( false, false );
+
+ DBG_DTOR(OBrowserLine,NULL);
+ }
+
+ //------------------------------------------------------------------
+ void OBrowserLine::IndentTitle( bool _bIndent )
+ {
+ if ( m_bIndentTitle != _bIndent )
+ {
+ m_bIndentTitle = _bIndent;
+ impl_layoutComponents();
+ }
+ }
+
+ //------------------------------------------------------------------
+ void OBrowserLine::SetComponentHelpIds( const SmartId& _rHelpId, sal_uInt32 _bPrimaryButtonId, sal_uInt32 _nSecondaryButtonId )
+ {
+ if ( m_pControlWindow )
+ m_pControlWindow->SetSmartHelpId( _rHelpId );
+
+ if ( m_pBrowseButton )
+ {
+ m_pBrowseButton->SetSmartHelpId( _rHelpId );
+ m_pBrowseButton->SetUniqueId( _bPrimaryButtonId );
+
+ if ( m_pAdditionalBrowseButton )
+ {
+ m_pAdditionalBrowseButton->SetSmartHelpId( _rHelpId );
+ m_pAdditionalBrowseButton->SetUniqueId( _nSecondaryButtonId );
+ }
+ }
+ }
+
+ //------------------------------------------------------------------
+ void OBrowserLine::setControl( const Reference< XPropertyControl >& _rxControl )
+ {
+ m_xControl = _rxControl;
+ m_pControlWindow = m_xControl.is() ? VCLUnoHelper::GetWindow( _rxControl->getControlWindow() ) : NULL;
+ DBG_ASSERT( m_pControlWindow, "OBrowserLine::setControl: setting NULL controls/windows is not allowed!" );
+
+ if ( m_pControlWindow )
+ {
+ m_pControlWindow->SetParent( m_pTheParent );
+ m_pControlWindow->Show();
+ }
+ impl_layoutComponents();
+ }
+
+ //------------------------------------------------------------------
+ Window* OBrowserLine::GetRefWindow()
+ {
+ Window* pRefWindow=&m_aFtTitle;
+
+ if(m_pBrowseButton)
+ {
+ pRefWindow=(Window*)m_pBrowseButton;
+ }
+ else if ( m_pControlWindow )
+ {
+ pRefWindow = m_pControlWindow;
+ }
+ return pRefWindow;
+ }
+
+ //------------------------------------------------------------------
+ void OBrowserLine::SetTabOrder(Window* pRefWindow, sal_uInt16 nFlags )
+ {
+ m_aFtTitle.SetZOrder(pRefWindow,nFlags);
+ if ( m_pControlWindow )
+ m_pControlWindow->SetZOrder( (Window*)&m_aFtTitle, WINDOW_ZORDER_BEHIND );
+
+ if ( m_pBrowseButton )
+ m_pBrowseButton->SetZOrder( m_pControlWindow, WINDOW_ZORDER_BEHIND );
+
+ if ( m_pAdditionalBrowseButton )
+ m_pAdditionalBrowseButton->SetZOrder( m_pBrowseButton, WINDOW_ZORDER_BEHIND );
+ }
+
+ //------------------------------------------------------------------
+ sal_Bool OBrowserLine::GrabFocus()
+ {
+ sal_Bool bRes=sal_False;
+
+ if ( m_pControlWindow && m_pControlWindow->IsEnabled() )
+ {
+ m_pControlWindow->GrabFocus();
+ bRes = sal_True;
+ }
+ else if ( m_pAdditionalBrowseButton && m_pAdditionalBrowseButton->IsEnabled() )
+ {
+ m_pAdditionalBrowseButton->GrabFocus();
+ bRes = sal_True;
+ }
+ else if ( m_pBrowseButton && m_pBrowseButton->IsEnabled() )
+ {
+ m_pBrowseButton->GrabFocus();
+ bRes = sal_True;
+ }
+ return bRes;
+ }
+
+ //------------------------------------------------------------------
+ void OBrowserLine::SetPosSizePixel( Point _rPos, Size _rSize )
+ {
+ m_aLinePos = _rPos;
+ m_aOutputSize = _rSize;
+
+ impl_layoutComponents();
+ }
+
+ //------------------------------------------------------------------
+ void OBrowserLine::Show(sal_Bool bFlag)
+ {
+ m_aFtTitle.Show(bFlag);
+ if ( m_pControlWindow )
+ m_pControlWindow->Show( bFlag );
+ if ( m_pBrowseButton )
+ m_pBrowseButton->Show( bFlag );
+ if ( m_pAdditionalBrowseButton )
+ m_pAdditionalBrowseButton->Show( bFlag );
+ }
+
+ //------------------------------------------------------------------
+ void OBrowserLine::Hide()
+ {
+ Show(sal_False);
+ }
+
+ //------------------------------------------------------------------
+ sal_Bool OBrowserLine::IsVisible()
+ {
+ return m_aFtTitle.IsVisible();
+ }
+
+ //------------------------------------------------------------------
+ void OBrowserLine::impl_layoutComponents()
+ {
+ {
+ Point aTitlePos( m_aLinePos.X(), m_aLinePos.Y() + 8 );
+ Size aTitleSize( m_nNameWidth - 3, m_aOutputSize.Height() );
+
+ if ( m_bIndentTitle )
+ {
+ Size aIndent( m_pTheParent->LogicToPixel( Size( 8, 0 ), MAP_APPFONT ) );
+ aTitlePos.X() += aIndent.Width();
+ aTitleSize.Width() -= aIndent.Width();
+ }
+ m_aFtTitle.SetPosSizePixel( aTitlePos, aTitleSize );
+ }
+
+ sal_Int32 nBrowseButtonSize = m_aOutputSize.Height() - 4;
+
+ if ( m_pControlWindow )
+ {
+ Point aControlPos( m_aLinePos.X() + m_nNameWidth, m_aLinePos.Y() + 2 );
+ m_pControlWindow->SetPosPixel( aControlPos );
+
+ Size aControlSize( m_aOutputSize.Width() - 4 - m_nNameWidth - nBrowseButtonSize - 4, m_pControlWindow->GetSizePixel().Height() );
+ if ( m_pAdditionalBrowseButton )
+ aControlSize.Width() -= nBrowseButtonSize + 4;
+ m_pControlWindow->SetSizePixel( aControlSize );
+ }
+
+ if ( m_pBrowseButton )
+ {
+ Point aButtonPos( m_aOutputSize.Width() - 4 - nBrowseButtonSize, m_aLinePos.Y() + 2 );
+ Size aButtonSize( nBrowseButtonSize, nBrowseButtonSize );
+ m_pBrowseButton->SetPosSizePixel( aButtonPos, aButtonSize );
+
+ if ( m_pAdditionalBrowseButton )
+ {
+ aButtonPos.X() -= nBrowseButtonSize + 4;
+ m_pAdditionalBrowseButton->SetPosSizePixel( aButtonPos, aButtonSize );
+ }
+ }
+ }
+
+ //------------------------------------------------------------------
+ void OBrowserLine::SetTitle(const XubString& _rNewTtile )
+ {
+ if ( GetTitle() == _rNewTtile )
+ return;
+ // #99102# --------------
+ m_aFtTitle.SetText( _rNewTtile );
+ if ( m_pControlWindow )
+ m_pControlWindow->SetAccessibleName( _rNewTtile );
+ if ( m_pBrowseButton )
+ m_pBrowseButton->SetAccessibleName( _rNewTtile );
+ FullFillTitleString();
+ }
+
+ // #99102# ---------------------------------------------------------
+ void OBrowserLine::FullFillTitleString()
+ {
+ if( m_pTheParent )
+ {
+ String aText = m_aFtTitle.GetText();
+
+ while( m_pTheParent->GetTextWidth( aText ) < m_nNameWidth )
+ aText.AppendAscii("...........");
+
+ // for Issue 69452
+ if (Application::GetSettings().GetLayoutRTL())
+ {
+ sal_Unicode cRTL_mark = 0x200F;
+ aText.Append(cRTL_mark);
+ }
+
+ m_aFtTitle.SetText(aText);
+ }
+ }
+
+ //------------------------------------------------------------------
+ XubString OBrowserLine::GetTitle() const
+ {
+ String sDisplayName = m_aFtTitle.GetText();
+
+ // for Issue 69452
+ if (Application::GetSettings().GetLayoutRTL())
+ {
+ sal_Unicode cRTL_mark = 0x200F;
+ sDisplayName.EraseTrailingChars(cRTL_mark);
+ }
+
+ sDisplayName.EraseTrailingChars( '.' );
+
+ return sDisplayName;
+ }
+
+ //------------------------------------------------------------------
+ void OBrowserLine::SetReadOnly( bool _bReadOnly )
+ {
+ if ( m_bReadOnly != _bReadOnly )
+ {
+ m_bReadOnly = _bReadOnly;
+ implUpdateEnabledDisabled();
+ }
+ }
+
+ //------------------------------------------------------------------
+ namespace
+ {
+ void implSetBitIfAffected( sal_uInt16& _nEnabledBits, sal_Int16 _nAffectedMask, sal_Int16 _nTestBit, bool _bSet )
+ {
+ if ( _nAffectedMask & _nTestBit )
+ {
+ if ( _bSet )
+ _nEnabledBits |= _nTestBit;
+ else
+ _nEnabledBits &= ~_nTestBit;
+ }
+ }
+
+ void implEnable( Window* _pWindow, sal_uInt16 _nEnabledBits, sal_uInt16 _nMatchBits )
+ {
+ if ( _pWindow )
+ _pWindow->Enable( ( _nEnabledBits & _nMatchBits ) == _nMatchBits );
+ }
+
+ void implEnable( Window* _pWindow, bool _bEnable )
+ {
+ if ( _pWindow )
+ _pWindow->Enable( _bEnable );
+ }
+ }
+
+ //------------------------------------------------------------------
+ void OBrowserLine::implUpdateEnabledDisabled()
+ {
+ implEnable( &m_aFtTitle, m_nEnableFlags, PropertyLineElement::CompleteLine );
+ if ( m_pControlWindow )
+ implEnable( m_pControlWindow, m_nEnableFlags, PropertyLineElement::CompleteLine | PropertyLineElement::InputControl );
+
+ if ( m_bReadOnly )
+ {
+ implEnable( m_pBrowseButton, false );
+ implEnable( m_pAdditionalBrowseButton, false );
+ }
+ else
+ {
+ implEnable( m_pBrowseButton, m_nEnableFlags, PropertyLineElement::CompleteLine | PropertyLineElement::PrimaryButton );
+ implEnable( m_pAdditionalBrowseButton, m_nEnableFlags, PropertyLineElement::CompleteLine | PropertyLineElement::SecondaryButton );
+ }
+ }
+
+ //------------------------------------------------------------------
+ void OBrowserLine::EnablePropertyLine( bool _bEnable )
+ {
+ implSetBitIfAffected( m_nEnableFlags, PropertyLineElement::CompleteLine, PropertyLineElement::CompleteLine, _bEnable );
+ implUpdateEnabledDisabled();
+ }
+
+ //------------------------------------------------------------------
+ void OBrowserLine::EnablePropertyControls( sal_Int16 _nControls, bool _bEnable )
+ {
+ implSetBitIfAffected( m_nEnableFlags, _nControls, PropertyLineElement::InputControl, _bEnable );
+ implSetBitIfAffected( m_nEnableFlags, _nControls, PropertyLineElement::PrimaryButton, _bEnable );
+ implSetBitIfAffected( m_nEnableFlags, _nControls, PropertyLineElement::SecondaryButton, _bEnable );
+ implUpdateEnabledDisabled();
+ }
+
+ //------------------------------------------------------------------
+ PushButton& OBrowserLine::impl_ensureButton( bool _bPrimary )
+ {
+ PushButton*& rpButton = _bPrimary ? m_pBrowseButton : m_pAdditionalBrowseButton;
+
+ if ( !rpButton )
+ {
+ rpButton = new PushButton( m_pTheParent, WB_NOPOINTERFOCUS );
+ rpButton->SetGetFocusHdl( LINK( this, OBrowserLine, OnButtonFocus ) );
+ rpButton->SetClickHdl( LINK( this, OBrowserLine, OnButtonClicked ) );
+ rpButton->SetText( String::CreateFromAscii( "..." ) );
+ }
+
+ rpButton->Show();
+
+ impl_layoutComponents();
+
+ return *rpButton;
+ }
+
+ //------------------------------------------------------------------
+ void OBrowserLine::impl_getImagesFromURL_nothrow( const ::rtl::OUString& _rImageURL, Image& _out_rImage, Image& _out_rHCImage )
+ {
+ try
+ {
+ ::comphelper::ComponentContext aContext( ::comphelper::getProcessServiceFactory() );
+ Reference< XGraphicProvider > xGraphicProvider( aContext.createComponent( "com.sun.star.graphic.GraphicProvider" ), UNO_QUERY_THROW );
+
+ Sequence< PropertyValue > aMediaProperties(1);
+ aMediaProperties[0].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "URL" ) );
+ aMediaProperties[0].Value <<= _rImageURL;
+
+ Reference< XGraphic > xGraphic( xGraphicProvider->queryGraphic( aMediaProperties ), UNO_QUERY_THROW );
+ _out_rImage = _out_rHCImage = Image( xGraphic );
+
+ // see if we find an HC version beside the normal graphic
+ INetURLObject aURL( _rImageURL );
+ ::rtl::OUString sBaseName( aURL.getBase() );
+ aURL.setBase( sBaseName + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "_hc" ) ) );
+ ::rtl::OUString sHCImageURL( aURL.GetMainURL( INetURLObject::NO_DECODE ) );
+
+ Reference< XGraphic > xHCGraphic;
+ try
+ {
+ aMediaProperties[0].Value <<= sHCImageURL;
+ xHCGraphic = xGraphicProvider->queryGraphic( aMediaProperties );
+ }
+ catch( const Exception& ) { }
+
+ if ( xHCGraphic.is() )
+ _out_rHCImage = Image( xHCGraphic );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+
+ //------------------------------------------------------------------
+ void OBrowserLine::ShowBrowseButton( const ::rtl::OUString& _rImageURL, sal_Bool _bPrimary )
+ {
+ PushButton& rButton( impl_ensureButton( _bPrimary ) );
+
+ OSL_PRECOND( _rImageURL.getLength(), "OBrowserLine::ShowBrowseButton: use the other version if you don't have an image!" );
+ Image aImage, aHCImage;
+ impl_getImagesFromURL_nothrow( _rImageURL, aImage, aHCImage );
+
+ rButton.SetModeImage( aImage, BMP_COLOR_NORMAL );
+ rButton.SetModeImage( aHCImage, BMP_COLOR_HIGHCONTRAST );
+ }
+
+ //------------------------------------------------------------------
+ void OBrowserLine::ShowBrowseButton( const Image& _rImage, sal_Bool _bPrimary )
+ {
+ PushButton& rButton( impl_ensureButton( _bPrimary ) );
+ if ( !!_rImage )
+ rButton.SetModeImage( _rImage );
+ }
+
+ //------------------------------------------------------------------
+ void OBrowserLine::ShowBrowseButton( sal_Bool _bPrimary )
+ {
+ impl_ensureButton( _bPrimary );
+ }
+
+ //------------------------------------------------------------------
+ void OBrowserLine::implHideBrowseButton( sal_Bool _bPrimary, bool _bReLayout )
+ {
+ PushButton*& rpButton = _bPrimary ? m_pBrowseButton : m_pAdditionalBrowseButton;
+
+ if ( rpButton )
+ {
+ rpButton->Hide();
+ delete rpButton;
+ rpButton = NULL;
+ }
+
+ if ( _bReLayout )
+ impl_layoutComponents();
+ }
+
+ //------------------------------------------------------------------
+ void OBrowserLine::HideBrowseButton( sal_Bool _bPrimary )
+ {
+ implHideBrowseButton( _bPrimary, true );
+ }
+
+ //------------------------------------------------------------------
+ void OBrowserLine::SetTitleWidth(sal_uInt16 nWidth)
+ {
+ if (m_nNameWidth != nWidth+10)
+ {
+ m_nNameWidth = nWidth+10;
+ impl_layoutComponents();
+ }
+ // #99102# ---------
+ FullFillTitleString();
+ }
+
+ //------------------------------------------------------------------
+ void OBrowserLine::SetClickListener( IButtonClickListener* _pListener )
+ {
+ m_pClickListener = _pListener;
+ }
+
+ //------------------------------------------------------------------
+ IMPL_LINK( OBrowserLine, OnButtonClicked, PushButton*, _pButton )
+ {
+ if ( m_pClickListener )
+ m_pClickListener->buttonClicked( this, _pButton == m_pBrowseButton );
+
+ return 0L;
+ }
+
+ //------------------------------------------------------------------
+ IMPL_LINK( OBrowserLine, OnButtonFocus, PushButton*, /*pPB*/ )
+ {
+ if ( m_xControl.is() )
+ {
+ try
+ {
+ Reference< XPropertyControlContext > xContext( m_xControl->getControlContext(), UNO_QUERY_THROW );
+ xContext->focusGained( m_xControl );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+ return 0;
+ }
+//............................................................................
+} // namespace pcr
+//............................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/propctrlr/browserline.hxx b/extensions/source/propctrlr/browserline.hxx
new file mode 100644
index 000000000000..323b457cd590
--- /dev/null
+++ b/extensions/source/propctrlr/browserline.hxx
@@ -0,0 +1,143 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _EXTENSIONS_PROPCTRLR_BROWSERLINE_HXX_
+#define _EXTENSIONS_PROPCTRLR_BROWSERLINE_HXX_
+
+/** === begin UNO includes === **/
+#include <com/sun/star/inspection/XPropertyControl.hpp>
+/** === end UNO includes === **/
+#include <vcl/fixed.hxx>
+#include <vcl/button.hxx>
+
+namespace com { namespace sun { namespace star { namespace inspection { namespace PropertyLineElement
+{
+ const sal_Int16 CompleteLine = 0x4000;
+} } } } }
+
+//............................................................................
+namespace pcr
+{
+//............................................................................
+
+ class OBrowserLine;
+
+ //========================================================================
+ class IButtonClickListener
+ {
+ public:
+ virtual void buttonClicked( OBrowserLine* _pLine, sal_Bool _bPrimary ) = 0;
+ };
+
+ //========================================================================
+ class OBrowserLine
+ {
+ private:
+ ::rtl::OUString m_sEntryName;
+ FixedText m_aFtTitle;
+ Size m_aOutputSize;
+ Point m_aLinePos;
+ ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyControl >
+ m_xControl;
+ Window* m_pControlWindow;
+ PushButton* m_pBrowseButton;
+ PushButton* m_pAdditionalBrowseButton;
+ IButtonClickListener* m_pClickListener;
+ Window* m_pTheParent;
+ sal_uInt16 m_nNameWidth;
+ sal_uInt16 m_nEnableFlags;
+ bool m_bIndentTitle;
+ bool m_bReadOnly;
+
+ public:
+ OBrowserLine( const ::rtl::OUString& _rEntryName, Window* pParent);
+ ~OBrowserLine();
+
+ void setControl( const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyControl >& _rxControl );
+ const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyControl >& getControl()
+ {
+ return m_xControl;
+ }
+ inline Window* getControlWindow() const
+ {
+ return m_pControlWindow;
+ }
+
+ const ::rtl::OUString&
+ GetEntryName() const { return m_sEntryName; }
+
+ void SetComponentHelpIds( const SmartId& _rHelpId, sal_uInt32 _bPrimaryButtonId, sal_uInt32 _nSecondaryButtonId );
+
+ void SetTitle(const String& rString );
+ void FullFillTitleString();
+ String GetTitle() const;
+ void SetTitleWidth(sal_uInt16);
+
+ void SetPosSizePixel(Point aPos,Size aSize);
+ void Show(sal_Bool bFlag=sal_True);
+ void Hide();
+ sal_Bool IsVisible();
+
+ Window* GetRefWindow();
+ void SetTabOrder(Window* pRefWindow, sal_uInt16 nFlags );
+
+ sal_Bool GrabFocus();
+ void ShowBrowseButton( const ::rtl::OUString& _rImageURL, sal_Bool _bPrimary );
+ void ShowBrowseButton( const Image& _rImage, sal_Bool _bPrimary );
+ void ShowBrowseButton( sal_Bool _bPrimary );
+ void HideBrowseButton( sal_Bool _bPrimary );
+
+ void EnablePropertyControls( sal_Int16 _nControls, bool _bEnable );
+ void EnablePropertyLine( bool _bEnable );
+
+ void SetReadOnly( bool _bReadOnly );
+
+ void SetClickListener( IButtonClickListener* _pListener );
+
+ void IndentTitle( bool _bIndent );
+
+ private:
+ DECL_LINK( OnButtonClicked, PushButton* );
+ DECL_LINK( OnButtonFocus, PushButton* );
+
+ void implHideBrowseButton( sal_Bool _bPrimary, bool _bReLayout );
+ void implUpdateEnabledDisabled();
+
+ void impl_layoutComponents();
+
+ PushButton& impl_ensureButton( bool _bPrimary );
+ void impl_getImagesFromURL_nothrow( const ::rtl::OUString& _rImageURL, Image& _out_rImage, Image& _out_rHCImage );
+ };
+
+//............................................................................
+} // namespace pcr
+//............................................................................
+
+#endif // _EXTENSIONS_PROPCTRLR_BROWSERLINE_HXX_
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/propctrlr/browserlistbox.cxx b/extensions/source/propctrlr/browserlistbox.cxx
new file mode 100644
index 000000000000..a70d7cc50d67
--- /dev/null
+++ b/extensions/source/propctrlr/browserlistbox.cxx
@@ -0,0 +1,1312 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+#include "browserlistbox.hxx"
+#include "propresid.hrc"
+#include "proplinelistener.hxx"
+#include "propcontrolobserver.hxx"
+#include "linedescriptor.hxx"
+#include "inspectorhelpwindow.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/lang/DisposedException.hpp>
+#include <com/sun/star/lang/XComponent.hpp>
+#include <com/sun/star/inspection/PropertyControlType.hpp>
+/** === end UNO includes === **/
+#include <tools/debug.hxx>
+#include <tools/diagnose_ex.h>
+#include <comphelper/asyncnotification.hxx>
+#include <cppuhelper/implbase1.hxx>
+#include <vcl/svapp.hxx>
+#include <osl/mutex.hxx>
+
+//............................................................................
+namespace pcr
+{
+//............................................................................
+
+ #define FRAME_OFFSET 4
+ // TODO: find out what this is really for ... and check if it does make sense in the new
+ // browser environment
+ #define LAYOUT_HELP_WINDOW_DISTANCE_APPFONT 3
+
+ /** === begin UNO using === **/
+ using ::com::sun::star::uno::Any;
+ using ::com::sun::star::uno::Exception;
+ using ::com::sun::star::inspection::XPropertyControlContext;
+ using ::com::sun::star::uno::Reference;
+ using ::com::sun::star::inspection::XPropertyControl;
+ using ::com::sun::star::uno::RuntimeException;
+ using ::com::sun::star::lang::DisposedException;
+ using ::com::sun::star::lang::XComponent;
+ using ::com::sun::star::uno::UNO_QUERY;
+ using ::com::sun::star::graphic::XGraphic;
+ /** === end UNO using === **/
+ namespace PropertyControlType = ::com::sun::star::inspection::PropertyControlType;
+
+ //==================================================================
+ //= ControlEvent
+ //==================================================================
+ enum ControlEventType
+ {
+ FOCUS_GAINED,
+ VALUE_CHANGED,
+ ACTIVATE_NEXT
+ };
+
+ struct ControlEvent : public ::comphelper::AnyEvent
+ {
+ Reference< XPropertyControl > xControl;
+ ControlEventType eType;
+
+ ControlEvent( const Reference< XPropertyControl >& _rxControl, ControlEventType _eType )
+ :xControl( _rxControl )
+ ,eType( _eType )
+ {
+ }
+ };
+
+ //==================================================================
+ //= SharedNotifier
+ //==================================================================
+ class SharedNotifier
+ {
+ private:
+ static ::osl::Mutex& getMutex();
+ static ::rtl::Reference< ::comphelper::AsyncEventNotifier > s_pNotifier;
+
+ public:
+ static const ::rtl::Reference< ::comphelper::AsyncEventNotifier >&
+ getNotifier();
+
+ private:
+ SharedNotifier(); // never implemented
+ SharedNotifier( const SharedNotifier& ); // never implemented
+ SharedNotifier& operator=( const SharedNotifier& ); // never implemented
+ };
+
+ //------------------------------------------------------------------
+ ::rtl::Reference< ::comphelper::AsyncEventNotifier > SharedNotifier::s_pNotifier;
+
+ //------------------------------------------------------------------
+ ::osl::Mutex& SharedNotifier::getMutex()
+ {
+ static ::osl::Mutex s_aMutex;
+ return s_aMutex;
+ }
+
+ //------------------------------------------------------------------
+ const ::rtl::Reference< ::comphelper::AsyncEventNotifier >& SharedNotifier::getNotifier()
+ {
+ ::osl::MutexGuard aGuard( getMutex() );
+ if ( !s_pNotifier.is() )
+ {
+ s_pNotifier.set( new ::comphelper::AsyncEventNotifier );
+ s_pNotifier->create();
+ }
+ return s_pNotifier;
+ }
+
+ //==================================================================
+ //= PropertyControlContext_Impl
+ //==================================================================
+ /** implementation for of <type scope="com::sun::star::inspection">XPropertyControlContext</type>
+ which forwards all events to a non-UNO version of this interface
+ */
+ typedef ::cppu::WeakImplHelper1< XPropertyControlContext > PropertyControlContext_Impl_Base;
+ class PropertyControlContext_Impl :public PropertyControlContext_Impl_Base
+ ,public ::comphelper::IEventProcessor
+ {
+ public:
+ enum NotifcationMode
+ {
+ eSynchronously,
+ eAsynchronously
+ };
+
+ private:
+ IControlContext* m_pContext;
+ NotifcationMode m_eMode;
+
+ public:
+ /** creates an instance
+ @param _rContextImpl
+ the instance to delegate events to
+ */
+ PropertyControlContext_Impl( IControlContext& _rContextImpl );
+
+ /** disposes the context.
+
+ When you call this method, all subsequent callbacks to the
+ <type scope="com::sun::star::inspection">XPropertyControlContext</type> methods
+ will throw a <type scope="com::sun::star::lang">DisposedException</type>.
+ */
+ void SAL_CALL dispose();
+
+ /** sets the notification mode, so that notifications recieved from the controls are
+ forwarded to our IControlContext either synchronously or asynchronously
+ @param _eMode
+ the new notification mode
+ */
+ void setNotificationMode( NotifcationMode _eMode );
+
+ virtual void SAL_CALL acquire() throw();
+ virtual void SAL_CALL release() throw();
+
+ protected:
+ ~PropertyControlContext_Impl();
+
+ // XPropertyControlObserver
+ virtual void SAL_CALL focusGained( const Reference< XPropertyControl >& Control ) throw (RuntimeException);
+ virtual void SAL_CALL valueChanged( const Reference< XPropertyControl >& Control ) throw (RuntimeException);
+ // XPropertyControlContext
+ virtual void SAL_CALL activateNextControl( const Reference< XPropertyControl >& CurrentControl ) throw (RuntimeException);
+
+ // IEventProcessor
+ virtual void processEvent( const ::comphelper::AnyEvent& _rEvent );
+
+ private:
+ /** processes the given event, i.e. notifies it to our IControlContext
+ @param _rEvent
+ the event no notify
+ @precond
+ our mutex (well, the SolarMutex) is locked
+ */
+ void impl_processEvent_throw( const ::comphelper::AnyEvent& _rEvent );
+
+ /** checks whether we're alive
+
+ @throws DisposedException
+ if the instance is already disposed
+ */
+ void impl_checkAlive_throw() const;
+
+ /** checks whether the instance is already disposed
+ */
+ bool impl_isDisposed_nothrow() const { return m_pContext == NULL; }
+
+ /** notifies the given event originating from the given control
+ @throws DisposedException
+ @param _rxControl
+ @param _eType
+ */
+ void impl_notify_throw( const Reference< XPropertyControl >& _rxControl, ControlEventType _eType );
+ };
+
+ //--------------------------------------------------------------------
+ PropertyControlContext_Impl::PropertyControlContext_Impl( IControlContext& _rContextImpl )
+ :m_pContext( &_rContextImpl )
+ ,m_eMode( eAsynchronously )
+ {
+ }
+
+ //--------------------------------------------------------------------
+ PropertyControlContext_Impl::~PropertyControlContext_Impl()
+ {
+ if ( !impl_isDisposed_nothrow() )
+ dispose();
+ }
+
+ //--------------------------------------------------------------------
+ void PropertyControlContext_Impl::impl_checkAlive_throw() const
+ {
+ if ( impl_isDisposed_nothrow() )
+ throw DisposedException( ::rtl::OUString(), *const_cast< PropertyControlContext_Impl* >( this ) );
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL PropertyControlContext_Impl::dispose()
+ {
+ SolarMutexGuard aGuard;
+ if ( impl_isDisposed_nothrow() )
+ return;
+
+ SharedNotifier::getNotifier()->removeEventsForProcessor( this );
+ m_pContext = NULL;
+ }
+
+ //--------------------------------------------------------------------
+ void PropertyControlContext_Impl::setNotificationMode( NotifcationMode _eMode )
+ {
+ SolarMutexGuard aGuard;
+ m_eMode = _eMode;
+ }
+
+ //--------------------------------------------------------------------
+ void PropertyControlContext_Impl::impl_notify_throw( const Reference< XPropertyControl >& _rxControl, ControlEventType _eType )
+ {
+ ::comphelper::AnyEventRef pEvent;
+
+ {
+ SolarMutexGuard aGuard;
+ impl_checkAlive_throw();
+ pEvent = new ControlEvent( _rxControl, _eType );
+
+ if ( m_eMode == eSynchronously )
+ {
+ impl_processEvent_throw( *pEvent );
+ return;
+ }
+ }
+
+ SharedNotifier::getNotifier()->addEvent( pEvent, this );
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL PropertyControlContext_Impl::focusGained( const Reference< XPropertyControl >& Control ) throw (RuntimeException)
+ {
+ DBG_TRACE( "PropertyControlContext_Impl: FOCUS_GAINED" );
+ impl_notify_throw( Control, FOCUS_GAINED );
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL PropertyControlContext_Impl::valueChanged( const Reference< XPropertyControl >& Control ) throw (RuntimeException)
+ {
+ DBG_TRACE( "PropertyControlContext_Impl: VALUE_CHANGED" );
+ impl_notify_throw( Control, VALUE_CHANGED );
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL PropertyControlContext_Impl::activateNextControl( const Reference< XPropertyControl >& CurrentControl ) throw (RuntimeException)
+ {
+ DBG_TRACE( "PropertyControlContext_Impl: ACTIVATE_NEXT" );
+ impl_notify_throw( CurrentControl, ACTIVATE_NEXT );
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL PropertyControlContext_Impl::acquire() throw()
+ {
+ PropertyControlContext_Impl_Base::acquire();
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL PropertyControlContext_Impl::release() throw()
+ {
+ PropertyControlContext_Impl_Base::release();
+ }
+
+ //--------------------------------------------------------------------
+ void PropertyControlContext_Impl::processEvent( const ::comphelper::AnyEvent& _rEvent )
+ {
+ SolarMutexGuard aGuard;
+ if ( impl_isDisposed_nothrow() )
+ return;
+
+ try
+ {
+ impl_processEvent_throw( _rEvent );
+ }
+ catch( const Exception& )
+ {
+ // can't handle otherwise, since our caller (the notification thread) does not allow
+ // for exceptions (it could itself abort only)
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+
+ //--------------------------------------------------------------------
+ void PropertyControlContext_Impl::impl_processEvent_throw( const ::comphelper::AnyEvent& _rEvent )
+ {
+ const ControlEvent& rControlEvent = static_cast< const ControlEvent& >( _rEvent );
+ switch ( rControlEvent.eType )
+ {
+ case FOCUS_GAINED:
+ DBG_TRACE( "PropertyControlContext_Impl::processEvent: FOCUS_GAINED" );
+ m_pContext->focusGained( rControlEvent.xControl );
+ break;
+ case VALUE_CHANGED:
+ DBG_TRACE( "PropertyControlContext_Impl::processEvent: VALUE_CHANGED" );
+ m_pContext->valueChanged( rControlEvent.xControl );
+ break;
+ case ACTIVATE_NEXT:
+ DBG_TRACE( "PropertyControlContext_Impl::processEvent: ACTIVATE_NEXT" );
+ m_pContext->activateNextControl( rControlEvent.xControl );
+ break;
+ }
+ }
+
+ //==================================================================
+ //= OBrowserListBox
+ //==================================================================
+ DBG_NAME(OBrowserListBox)
+ //------------------------------------------------------------------
+ OBrowserListBox::OBrowserListBox( Window* pParent, WinBits nWinStyle)
+ :Control(pParent, nWinStyle| WB_CLIPCHILDREN)
+ ,m_aLinesPlayground(this,WB_DIALOGCONTROL | WB_CLIPCHILDREN)
+ ,m_aVScroll(this,WB_VSCROLL|WB_REPEAT|WB_DRAG)
+ ,m_pHelpWindow( new InspectorHelpWindow( this ) )
+ ,m_pLineListener(NULL)
+ ,m_pControlObserver( NULL )
+ ,m_nYOffset(0)
+ ,m_nCurrentPreferredHelpHeight(0)
+ ,m_nTheNameSize(0)
+ ,m_bIsActive(sal_False)
+ ,m_bUpdate(sal_True)
+ ,m_pControlContextImpl( new PropertyControlContext_Impl( *this ) )
+ {
+ DBG_CTOR(OBrowserListBox,NULL);
+
+ ListBox aListBox(this,WB_DROPDOWN);
+ aListBox.SetPosSizePixel(Point(0,0),Size(100,100));
+ m_nRowHeight = (sal_uInt16)aListBox.GetSizePixel().Height()+2;
+ SetBackground( pParent->GetBackground() );
+ m_aLinesPlayground.SetBackground( GetBackground() );
+
+ m_aLinesPlayground.SetPosPixel(Point(0,0));
+ m_aLinesPlayground.SetPaintTransparent(sal_True);
+ m_aLinesPlayground.Show();
+ m_aVScroll.Hide();
+ m_aVScroll.SetScrollHdl(LINK(this, OBrowserListBox, ScrollHdl));
+ }
+
+ //------------------------------------------------------------------
+ OBrowserListBox::~OBrowserListBox()
+ {
+ OSL_ENSURE( !IsModified(), "OBrowserListBox::~OBrowserListBox: still modified - should have been committed before!" );
+ // doing the commit here, while we, as well as our owner, as well as some other components,
+ // are already "half dead" (means within their dtor) is potentially dangerous.
+ // By definition, CommitModified has to be called (if necessary) before destruction
+ // #105868# - 2002-12-13 - fs@openoffice.org
+
+ m_pControlContextImpl->dispose();
+ m_pControlContextImpl.clear();
+
+ Hide();
+ Clear();
+
+ DBG_DTOR(OBrowserListBox,NULL);
+ }
+
+ //------------------------------------------------------------------
+ sal_Bool OBrowserListBox::IsModified( ) const
+ {
+ sal_Bool bModified = sal_False;
+
+ if ( m_bIsActive && m_xActiveControl.is() )
+ bModified = m_xActiveControl->isModified();
+
+ return bModified;
+ }
+
+ //------------------------------------------------------------------
+ void OBrowserListBox::CommitModified( )
+ {
+ if ( IsModified() && m_xActiveControl.is() )
+ {
+ // for the time of this commit, notify all events synchronously
+ // #i63814# / 2006-03-31 / frank.schoenheit@sun.com
+ m_pControlContextImpl->setNotificationMode( PropertyControlContext_Impl::eSynchronously );
+ try
+ {
+ m_xActiveControl->notifyModifiedValue();
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ m_pControlContextImpl->setNotificationMode( PropertyControlContext_Impl::eAsynchronously );
+ }
+ }
+
+ //------------------------------------------------------------------
+ void OBrowserListBox::ActivateListBox(sal_Bool _bActive)
+ {
+ m_bIsActive = _bActive;
+ if (m_bIsActive)
+ {
+ // TODO: what's the sense of this?
+ m_aVScroll.SetThumbPos(100);
+ MoveThumbTo(0);
+ Resize();
+ }
+ }
+
+ //------------------------------------------------------------------
+ long OBrowserListBox::impl_getPrefererredHelpHeight()
+ {
+ return HasHelpSection() ? m_pHelpWindow->GetOptimalHeightPixel() : 0;
+ }
+
+ //------------------------------------------------------------------
+ void OBrowserListBox::Resize()
+ {
+ Rectangle aPlayground( Point( 0, 0 ), GetOutputSizePixel() );
+ Size aHelpWindowDistance( LogicToPixel( Size( 0, LAYOUT_HELP_WINDOW_DISTANCE_APPFONT ), MAP_APPFONT ) );
+
+ long nHelpWindowHeight = m_nCurrentPreferredHelpHeight = impl_getPrefererredHelpHeight();
+ bool bPositionHelpWindow = ( nHelpWindowHeight != 0 );
+
+ Rectangle aLinesArea( aPlayground );
+ if ( bPositionHelpWindow )
+ {
+ aLinesArea.Bottom() -= nHelpWindowHeight;
+ aLinesArea.Bottom() -= aHelpWindowDistance.Height();
+ }
+ m_aLinesPlayground.SetPosSizePixel( aLinesArea.TopLeft(), aLinesArea.GetSize() );
+
+ UpdateVScroll();
+
+ sal_Bool bNeedScrollbar = m_aOrderedLines.size() > (sal_uInt32)CalcVisibleLines();
+ if ( !bNeedScrollbar )
+ {
+ if ( m_aVScroll.IsVisible() )
+ m_aVScroll.Hide();
+ // scroll to top
+ m_nYOffset = 0;
+ m_aVScroll.SetThumbPos( 0 );
+ }
+ else
+ {
+ Size aVScrollSize( m_aVScroll.GetSizePixel() );
+
+ // adjust the playground's width
+ aLinesArea.Right() -= aVScrollSize.Width();
+ m_aLinesPlayground.SetPosSizePixel( aLinesArea.TopLeft(), aLinesArea.GetSize() );
+
+ // position the scrollbar
+ aVScrollSize.Height() = aLinesArea.GetHeight();
+ Point aVScrollPos( aLinesArea.GetWidth(), 0 );
+ m_aVScroll.SetPosSizePixel( aVScrollPos, aVScrollSize );
+ }
+
+ for ( sal_uInt16 i = 0; i < m_aOrderedLines.size(); ++i )
+ m_aOutOfDateLines.insert( i );
+
+ // repaint
+ EnablePaint(sal_False);
+ UpdatePlayGround();
+ EnablePaint(sal_True);
+
+ // show the scrollbar
+ if ( bNeedScrollbar )
+ m_aVScroll.Show();
+
+ // position the help window
+ if ( bPositionHelpWindow )
+ {
+ Rectangle aHelpArea( aPlayground );
+ aHelpArea.Top() = aLinesArea.Bottom() + aHelpWindowDistance.Height();
+ m_pHelpWindow->SetPosSizePixel( aHelpArea.TopLeft(), aHelpArea.GetSize() );
+ }
+ }
+
+ //------------------------------------------------------------------
+ void OBrowserListBox::SetListener( IPropertyLineListener* _pListener )
+ {
+ m_pLineListener = _pListener;
+ }
+
+ //------------------------------------------------------------------
+ void OBrowserListBox::SetObserver( IPropertyControlObserver* _pObserver )
+ {
+ m_pControlObserver = _pObserver;
+ }
+
+ //------------------------------------------------------------------
+ void OBrowserListBox::EnableHelpSection( bool _bEnable )
+ {
+ m_pHelpWindow->Show( _bEnable );
+ Resize();
+ }
+
+ //------------------------------------------------------------------
+ bool OBrowserListBox::HasHelpSection() const
+ {
+ return m_pHelpWindow->IsVisible();
+ }
+
+ //------------------------------------------------------------------
+ void OBrowserListBox::SetHelpText( const ::rtl::OUString& _rHelpText )
+ {
+ OSL_ENSURE( HasHelpSection(), "OBrowserListBox::SetHelpText: help section not visible!" );
+ m_pHelpWindow->SetText( _rHelpText );
+ if ( m_nCurrentPreferredHelpHeight != impl_getPrefererredHelpHeight() )
+ Resize();
+ }
+
+ //------------------------------------------------------------------
+ void OBrowserListBox::SetHelpLineLimites( sal_Int32 _nMinLines, sal_Int32 _nMaxLines )
+ {
+ m_pHelpWindow->SetLimits( _nMinLines, _nMaxLines );
+ }
+
+ //------------------------------------------------------------------
+ sal_uInt16 OBrowserListBox::CalcVisibleLines()
+ {
+ Size aSize(m_aLinesPlayground.GetOutputSizePixel());
+ sal_uInt16 nResult = 0;
+ if (0 != m_nRowHeight)
+ nResult = (sal_uInt16) aSize.Height()/m_nRowHeight;
+
+ return nResult;
+ }
+
+ //------------------------------------------------------------------
+ void OBrowserListBox::UpdateVScroll()
+ {
+ sal_uInt16 nLines = CalcVisibleLines();
+ m_aVScroll.SetPageSize(nLines-1);
+ m_aVScroll.SetVisibleSize(nLines-1);
+
+ size_t nCount = m_aLines.size();
+ if (nCount>0)
+ {
+ m_aVScroll.SetRange(Range(0,nCount-1));
+ m_nYOffset = -m_aVScroll.GetThumbPos()*m_nRowHeight;
+ }
+ else
+ {
+ m_aVScroll.SetRange(Range(0,0));
+ m_nYOffset = 0;
+ }
+ }
+
+ //------------------------------------------------------------------
+ void OBrowserListBox::PositionLine( sal_uInt16 _nIndex )
+ {
+ Size aSize(m_aLinesPlayground.GetOutputSizePixel());
+ Point aPos(0, m_nYOffset);
+
+ aSize.Height() = m_nRowHeight;
+
+ aPos.Y() += _nIndex * m_nRowHeight;
+
+ if ( _nIndex < m_aOrderedLines.size() )
+ {
+ m_aOrderedLines[ _nIndex ]->second.pLine->SetPosSizePixel( aPos, aSize );
+
+ m_aOrderedLines[ _nIndex ]->second.pLine->SetTitleWidth( m_nTheNameSize + 2 * FRAME_OFFSET );
+
+ // show the line if necessary
+ if ( !m_aOrderedLines[ _nIndex ]->second.pLine->IsVisible() )
+ m_aOrderedLines[ _nIndex ]->second.pLine->Show();
+ }
+ }
+
+ //------------------------------------------------------------------
+ void OBrowserListBox::UpdatePosNSize()
+ {
+ for ( ::std::set< sal_uInt16 >::const_iterator aLoop = m_aOutOfDateLines.begin();
+ aLoop != m_aOutOfDateLines.end();
+ ++aLoop
+ )
+ {
+ DBG_ASSERT( *aLoop < m_aOrderedLines.size(), "OBrowserListBox::UpdatePosNSize: invalid line index!" );
+ if ( *aLoop < m_aOrderedLines.size() )
+ PositionLine( *aLoop );
+ }
+ m_aOutOfDateLines.clear();
+ }
+
+ //------------------------------------------------------------------
+ void OBrowserListBox::UpdatePlayGround()
+ {
+ sal_Int32 nThumbPos = m_aVScroll.GetThumbPos();
+ sal_Int32 nLines = CalcVisibleLines();
+
+ sal_uInt16 nEnd = (sal_uInt16)(nThumbPos + nLines);
+ if (nEnd >= m_aOrderedLines.size())
+ nEnd = (sal_uInt16)m_aOrderedLines.size()-1;
+
+ if ( !m_aOrderedLines.empty() )
+ {
+ for ( sal_uInt16 i = (sal_uInt16)nThumbPos; i <= nEnd; ++i )
+ m_aOutOfDateLines.insert( i );
+ UpdatePosNSize();
+ }
+ }
+
+ //------------------------------------------------------------------
+ void OBrowserListBox::UpdateAll()
+ {
+ Resize();
+ }
+
+ //------------------------------------------------------------------
+ void OBrowserListBox::DisableUpdate()
+ {
+ m_bUpdate = sal_False;
+ }
+
+ //------------------------------------------------------------------
+ void OBrowserListBox::EnableUpdate()
+ {
+ m_bUpdate = sal_True;
+ UpdateAll();
+ }
+
+ //------------------------------------------------------------------
+ void OBrowserListBox::SetPropertyValue(const ::rtl::OUString& _rEntryName, const Any& _rValue, bool _bUnknownValue )
+ {
+ ListBoxLines::iterator line = m_aLines.find( _rEntryName );
+ if ( line != m_aLines.end() )
+ {
+ if ( _bUnknownValue )
+ {
+ Reference< XPropertyControl > xControl( line->second.pLine->getControl() );
+ OSL_ENSURE( xControl.is(), "OBrowserListBox::SetPropertyValue: illegal control!" );
+ if ( xControl.is() )
+ xControl->setValue( Any() );
+ }
+ else
+ impl_setControlAsPropertyValue( line->second, _rValue );
+ }
+ }
+
+ //------------------------------------------------------------------------
+ sal_uInt16 OBrowserListBox::GetPropertyPos( const ::rtl::OUString& _rEntryName ) const
+ {
+ sal_uInt16 nRet = LISTBOX_ENTRY_NOTFOUND;
+ for ( OrderedListBoxLines::const_iterator linePos = m_aOrderedLines.begin();
+ linePos != m_aOrderedLines.end();
+ ++linePos
+ )
+ {
+ if ( (*linePos)->first == _rEntryName )
+ {
+ nRet = (sal_uInt16)( linePos - m_aOrderedLines.begin() );
+ break;
+ }
+ }
+
+ return nRet;
+ }
+
+ //------------------------------------------------------------------------
+ bool OBrowserListBox::impl_getBrowserLineForName( const ::rtl::OUString& _rEntryName, BrowserLinePointer& _out_rpLine ) const
+ {
+ ListBoxLines::const_iterator line = m_aLines.find( _rEntryName );
+ if ( line != m_aLines.end() )
+ _out_rpLine = line->second.pLine;
+ else
+ _out_rpLine.reset();
+ return ( NULL != _out_rpLine.get() );
+ }
+
+ //------------------------------------------------------------------------
+ void OBrowserListBox::EnablePropertyControls( const ::rtl::OUString& _rEntryName, sal_Int16 _nControls, bool _bEnable )
+ {
+ BrowserLinePointer pLine;
+ if ( impl_getBrowserLineForName( _rEntryName, pLine ) )
+ pLine->EnablePropertyControls( _nControls, _bEnable );
+ }
+
+ //------------------------------------------------------------------------
+ void OBrowserListBox::EnablePropertyLine( const ::rtl::OUString& _rEntryName, bool _bEnable )
+ {
+ BrowserLinePointer pLine;
+ if ( impl_getBrowserLineForName( _rEntryName, pLine ) )
+ pLine->EnablePropertyLine( _bEnable );
+ }
+
+ //------------------------------------------------------------------------
+ Reference< XPropertyControl > OBrowserListBox::GetPropertyControl( const ::rtl::OUString& _rEntryName )
+ {
+ BrowserLinePointer pLine;
+ if ( impl_getBrowserLineForName( _rEntryName, pLine ) )
+ return pLine->getControl();
+ return NULL;
+ }
+
+ //------------------------------------------------------------------
+ sal_uInt16 OBrowserListBox::InsertEntry(const OLineDescriptor& _rPropertyData, sal_uInt16 _nPos)
+ {
+ // create a new line
+ BrowserLinePointer pBrowserLine( new OBrowserLine( _rPropertyData.sName, &m_aLinesPlayground ) );
+
+ ListBoxLine aNewLine( pBrowserLine, _rPropertyData.xPropertyHandler );
+ ::std::pair< ListBoxLines::iterator, bool > insertPoint =
+ m_aLines.insert( ListBoxLines::value_type( _rPropertyData.sName, aNewLine ) );
+ OSL_ENSURE( insertPoint.second, "OBrowserListBox::InsertEntry: already have another line for this name!" );
+
+ sal_uInt16 nInsertPos = _nPos;
+ if ( nInsertPos > m_aOrderedLines.size() )
+ nInsertPos = EDITOR_LIST_APPEND;
+ if ( EDITOR_LIST_APPEND == nInsertPos )
+ {
+ nInsertPos = (sal_uInt16)m_aOrderedLines.size();
+ m_aOrderedLines.push_back( insertPoint.first );
+ }
+ else
+ m_aOrderedLines.insert( m_aOrderedLines.begin() + nInsertPos, insertPoint.first );
+
+ pBrowserLine->SetTitleWidth(m_nTheNameSize);
+ if (m_bUpdate)
+ {
+ UpdateVScroll();
+ Invalidate();
+ }
+
+ // initialize the entry
+ ChangeEntry(_rPropertyData, nInsertPos);
+
+ // update the positions of possibly affected lines
+ sal_uInt16 nUpdatePos = nInsertPos;
+ while ( nUpdatePos < m_aOrderedLines.size() )
+ m_aOutOfDateLines.insert( nUpdatePos++ );
+ UpdatePosNSize( );
+
+ return nInsertPos;
+ }
+
+ //------------------------------------------------------------------
+ sal_Int32 OBrowserListBox::GetMinimumWidth()
+ {
+ return m_nTheNameSize + 2 * FRAME_OFFSET + (m_nRowHeight - 4) * 8;
+ }
+
+ //------------------------------------------------------------------
+ sal_Int32 OBrowserListBox::GetMinimumHeight()
+ {
+ // assume that we want to display 5 rows, at least
+ sal_Int32 nMinHeight = m_nRowHeight * 5;
+
+ if ( HasHelpSection() )
+ {
+ Size aHelpWindowDistance( LogicToPixel( Size( 0, LAYOUT_HELP_WINDOW_DISTANCE_APPFONT ), MAP_APPFONT ) );
+ nMinHeight += aHelpWindowDistance.Height();
+
+ nMinHeight += m_pHelpWindow->GetMinimalHeightPixel();
+ }
+
+ return nMinHeight;
+ }
+
+ //------------------------------------------------------------------
+ void OBrowserListBox::ShowEntry(sal_uInt16 _nPos)
+ {
+ if ( _nPos < m_aOrderedLines.size() )
+ {
+ sal_Int32 nThumbPos = m_aVScroll.GetThumbPos();
+
+ if (_nPos < nThumbPos)
+ MoveThumbTo(_nPos);
+ else
+ {
+ sal_Int32 nLines = CalcVisibleLines();
+ if (_nPos >= nThumbPos + nLines)
+ MoveThumbTo(_nPos - nLines + 1);
+ }
+ }
+
+ }
+
+ //------------------------------------------------------------------
+ void OBrowserListBox::MoveThumbTo(sal_Int32 _nNewThumbPos)
+ {
+ // disable painting to prevent flicker
+ m_aLinesPlayground.EnablePaint(sal_False);
+
+ sal_Int32 nDelta = _nNewThumbPos - m_aVScroll.GetThumbPos();
+ // adjust the scrollbar
+ m_aVScroll.SetThumbPos(_nNewThumbPos);
+ sal_Int32 nThumbPos = _nNewThumbPos;
+
+ m_nYOffset = -m_aVScroll.GetThumbPos() * m_nRowHeight;
+
+ sal_Int32 nLines = CalcVisibleLines();
+ sal_uInt16 nEnd = (sal_uInt16)(nThumbPos + nLines);
+
+ m_aLinesPlayground.Scroll(0, -nDelta * m_nRowHeight, SCROLL_CHILDREN);
+
+ if (1 == nDelta)
+ {
+ // TODO: what's the sense of this two PositionLines? Why not just one call?
+ PositionLine(nEnd-1);
+ PositionLine(nEnd);
+ }
+ else if (-1 == nDelta)
+ {
+ PositionLine((sal_uInt16)nThumbPos);
+ }
+ else if (0 != nDelta)
+ {
+ UpdatePlayGround();
+ }
+
+ m_aLinesPlayground.EnablePaint(sal_True);
+ m_aLinesPlayground.Invalidate(INVALIDATE_CHILDREN);
+ }
+
+ //------------------------------------------------------------------
+ IMPL_LINK(OBrowserListBox, ScrollHdl, ScrollBar*, _pScrollBar )
+ {
+ DBG_ASSERT(_pScrollBar == &m_aVScroll, "OBrowserListBox::ScrollHdl: where does this come from?");
+ (void)_pScrollBar;
+
+ // disable painting to prevent flicker
+ m_aLinesPlayground.EnablePaint(sal_False);
+
+ sal_Int32 nThumbPos = m_aVScroll.GetThumbPos();
+
+ sal_Int32 nDelta = m_aVScroll.GetDelta();
+ m_nYOffset = -nThumbPos * m_nRowHeight;
+
+ sal_uInt16 nEnd = (sal_uInt16)(nThumbPos + CalcVisibleLines());
+
+ m_aLinesPlayground.Scroll(0, -nDelta * m_nRowHeight, SCROLL_CHILDREN);
+
+ if (1 == nDelta)
+ {
+ PositionLine(nEnd-1);
+ PositionLine(nEnd);
+ }
+ else if (nDelta==-1)
+ {
+ PositionLine((sal_uInt16)nThumbPos);
+ }
+ else if (nDelta!=0 || m_aVScroll.GetType() == SCROLL_DONTKNOW)
+ {
+ UpdatePlayGround();
+ }
+
+ m_aLinesPlayground.EnablePaint(sal_True);
+ return 0;
+ }
+
+ //------------------------------------------------------------------
+ void OBrowserListBox::buttonClicked( OBrowserLine* _pLine, sal_Bool _bPrimary )
+ {
+ DBG_ASSERT( _pLine, "OBrowserListBox::buttonClicked: invalid browser line!" );
+ if ( _pLine && m_pLineListener )
+ {
+ m_pLineListener->Clicked( _pLine->GetEntryName(), _bPrimary );
+ }
+ }
+
+ //------------------------------------------------------------------
+ void OBrowserListBox::impl_setControlAsPropertyValue( const ListBoxLine& _rLine, const Any& _rPropertyValue )
+ {
+ Reference< XPropertyControl > xControl( _rLine.pLine->getControl() );
+ try
+ {
+ if ( _rPropertyValue.getValueType().equals( _rLine.pLine->getControl()->getValueType() ) )
+ {
+ xControl->setValue( _rPropertyValue );
+ }
+ else
+ {
+ #ifdef DBG_UTIL
+ if ( !_rLine.xHandler.is() )
+ {
+ ::rtl::OString sMessage( "OBrowserListBox::impl_setControlAsPropertyValue: no handler -> no conversion (property: '" );
+ ::rtl::OUString sPropertyName( _rLine.pLine->GetEntryName() );
+ sMessage += ::rtl::OString( sPropertyName.getStr(), sPropertyName.getLength(), RTL_TEXTENCODING_ASCII_US );
+ sMessage += ::rtl::OString( "')!" );
+ DBG_ERROR( sMessage );
+ }
+ #endif
+ if ( _rLine.xHandler.is() )
+ {
+ Any aControlValue = _rLine.xHandler->convertToControlValue(
+ _rLine.pLine->GetEntryName(), _rPropertyValue, xControl->getValueType() );
+ xControl->setValue( aControlValue );
+ }
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+
+ //------------------------------------------------------------------
+ Any OBrowserListBox::impl_getControlAsPropertyValue( const ListBoxLine& _rLine ) const
+ {
+ Reference< XPropertyControl > xControl( _rLine.pLine->getControl() );
+ Any aPropertyValue;
+ try
+ {
+ #ifdef DBG_UTIL
+ if ( !_rLine.xHandler.is() )
+ {
+ ::rtl::OString sMessage( "OBrowserListBox::impl_getControlAsPropertyValue: no handler -> no conversion (property: '" );
+ ::rtl::OUString sPropertyName( _rLine.pLine->GetEntryName() );
+ sMessage += ::rtl::OString( sPropertyName.getStr(), sPropertyName.getLength(), RTL_TEXTENCODING_ASCII_US );
+ sMessage += ::rtl::OString( "')!" );
+ DBG_ERROR( sMessage );
+ }
+ #endif
+ if ( _rLine.xHandler.is() )
+ aPropertyValue = _rLine.xHandler->convertToPropertyValue( _rLine.pLine->GetEntryName(), xControl->getValue() );
+ else
+ aPropertyValue = xControl->getValue();
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ return aPropertyValue;
+ }
+
+ //------------------------------------------------------------------
+ sal_uInt16 OBrowserListBox::impl_getControlPos( const Reference< XPropertyControl >& _rxControl ) const
+ {
+ for ( OrderedListBoxLines::const_iterator search = m_aOrderedLines.begin();
+ search != m_aOrderedLines.end();
+ ++search
+ )
+ if ( (*search)->second.pLine->getControl().get() == _rxControl.get() )
+ return sal_uInt16( search - m_aOrderedLines.begin() );
+ DBG_ERROR( "OBrowserListBox::impl_getControlPos: invalid control - not part of any of our lines!" );
+ return (sal_uInt16)-1;
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL OBrowserListBox::focusGained( const Reference< XPropertyControl >& _rxControl ) throw (RuntimeException)
+ {
+ DBG_TESTSOLARMUTEX();
+
+ DBG_ASSERT( _rxControl.is(), "OBrowserListBox::focusGained: invalid event source!" );
+ if ( !_rxControl.is() )
+ return;
+
+ if ( m_pControlObserver )
+ m_pControlObserver->focusGained( _rxControl );
+
+ m_xActiveControl = _rxControl;
+ ShowEntry( impl_getControlPos( m_xActiveControl ) );
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL OBrowserListBox::valueChanged( const Reference< XPropertyControl >& _rxControl ) throw (RuntimeException)
+ {
+ DBG_TESTSOLARMUTEX();
+
+ DBG_ASSERT( _rxControl.is(), "OBrowserListBox::valueChanged: invalid event source!" );
+ if ( !_rxControl.is() )
+ return;
+
+ if ( m_pControlObserver )
+ m_pControlObserver->valueChanged( _rxControl );
+
+ if ( m_pLineListener )
+ {
+ const ListBoxLine& rLine = impl_getControlLine( _rxControl );
+ m_pLineListener->Commit(
+ rLine.pLine->GetEntryName(),
+ impl_getControlAsPropertyValue( rLine )
+ );
+ }
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL OBrowserListBox::activateNextControl( const Reference< XPropertyControl >& _rxCurrentControl ) throw (RuntimeException)
+ {
+ DBG_TESTSOLARMUTEX();
+
+ sal_uInt16 nLine = impl_getControlPos( _rxCurrentControl );
+
+ // cycle forwards, 'til we've the next control which can grab the focus
+ ++nLine;
+ while ( (size_t)nLine < m_aOrderedLines.size() )
+ {
+ if ( m_aOrderedLines[nLine]->second.pLine->GrabFocus() )
+ break;
+ ++nLine;
+ }
+
+ if ( ( (size_t)nLine >= m_aOrderedLines.size() )
+ && ( m_aOrderedLines.size() > 0 )
+ )
+ // wrap around
+ m_aOrderedLines[0]->second.pLine->GrabFocus();
+ }
+
+ //------------------------------------------------------------------
+ namespace
+ {
+ //..............................................................
+ void lcl_implDisposeControl_nothrow( const Reference< XPropertyControl >& _rxControl )
+ {
+ if ( !_rxControl.is() )
+ return;
+ try
+ {
+ _rxControl->setControlContext( NULL );
+ Reference< XComponent > xControlComponent( _rxControl, UNO_QUERY );
+ if ( xControlComponent.is() )
+ xControlComponent->dispose();
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+ }
+
+ //------------------------------------------------------------------
+ void OBrowserListBox::Clear()
+ {
+ for ( ListBoxLines::iterator loop = m_aLines.begin();
+ loop != m_aLines.end();
+ ++loop
+ )
+ {
+ // hide the line
+ loop->second.pLine->Hide();
+ // reset the listener
+ lcl_implDisposeControl_nothrow( loop->second.pLine->getControl() );
+ }
+
+ clearContainer( m_aLines );
+ clearContainer( m_aOrderedLines );
+ }
+
+ //------------------------------------------------------------------
+ sal_Bool OBrowserListBox::RemoveEntry( const ::rtl::OUString& _rName )
+ {
+ sal_uInt16 nPos = GetPropertyPos( _rName );
+ if ( nPos == LISTBOX_ENTRY_NOTFOUND )
+ return sal_False;
+
+ OrderedListBoxLines::iterator orderedPos = m_aOrderedLines.begin() + nPos;
+ BrowserLinePointer pLine = (*orderedPos)->second.pLine;
+ pLine->Hide();
+ lcl_implDisposeControl_nothrow( pLine->getControl() );
+
+ m_aLines.erase( *orderedPos );
+ m_aOrderedLines.erase( orderedPos );
+ m_aOutOfDateLines.erase( (sal_uInt16)m_aOrderedLines.size() );
+ // this index *may* have been out of date, which is obsoleted now by m_aOrderedLines shrinking
+
+ // update the positions of possibly affected lines
+ while ( nPos < m_aOrderedLines.size() )
+ m_aOutOfDateLines.insert( nPos++ );
+ UpdatePosNSize( );
+
+ return sal_True;
+ }
+
+ //------------------------------------------------------------------
+ void OBrowserListBox::ChangeEntry( const OLineDescriptor& _rPropertyData, sal_uInt16 nPos )
+ {
+ OSL_PRECOND( _rPropertyData.Control.is(), "OBrowserListBox::ChangeEntry: invalid control!" );
+ if ( !_rPropertyData.Control.is() )
+ return;
+
+ if ( nPos == EDITOR_LIST_REPLACE_EXISTING )
+ nPos = GetPropertyPos( _rPropertyData.sName );
+
+ if ( nPos < m_aOrderedLines.size() )
+ {
+ Window* pRefWindow = NULL;
+ if ( nPos > 0 )
+ pRefWindow = m_aOrderedLines[nPos-1]->second.pLine->GetRefWindow();
+
+ // the current line and control
+ ListBoxLine& rLine = m_aOrderedLines[nPos]->second;
+
+ // the old control and some data about it
+ Reference< XPropertyControl > xControl = rLine.pLine->getControl();
+ Window* pControlWindow = rLine.pLine->getControlWindow();
+ Point aControlPos;
+ if ( pControlWindow )
+ aControlPos = pControlWindow->GetPosPixel();
+
+ // clean up the old control
+ lcl_implDisposeControl_nothrow( xControl );
+
+ // set the new control at the line
+ rLine.pLine->setControl( _rPropertyData.Control );
+ xControl = rLine.pLine->getControl();
+
+ if ( xControl.is() )
+ xControl->setControlContext( m_pControlContextImpl.get() );
+
+ // the initial property value
+ if ( _rPropertyData.bUnknownValue )
+ xControl->setValue( Any() );
+ else
+ impl_setControlAsPropertyValue( rLine, _rPropertyData.aValue );
+
+ rLine.pLine->SetTitle(_rPropertyData.DisplayName);
+ rLine.xHandler = _rPropertyData.xPropertyHandler;
+
+ sal_uInt16 nTextWidth = (sal_uInt16)m_aLinesPlayground.GetTextWidth(_rPropertyData.DisplayName);
+ if (m_nTheNameSize< nTextWidth)
+ m_nTheNameSize = nTextWidth;
+
+ if ( _rPropertyData.HasPrimaryButton )
+ {
+ if ( _rPropertyData.PrimaryButtonImageURL.getLength() )
+ rLine.pLine->ShowBrowseButton( _rPropertyData.PrimaryButtonImageURL, true );
+ else if ( _rPropertyData.PrimaryButtonImage.is() )
+ rLine.pLine->ShowBrowseButton( Image( _rPropertyData.PrimaryButtonImage ), true );
+ else
+ rLine.pLine->ShowBrowseButton( true );
+
+ if ( _rPropertyData.HasSecondaryButton )
+ {
+ if ( _rPropertyData.SecondaryButtonImageURL.getLength() )
+ rLine.pLine->ShowBrowseButton( _rPropertyData.SecondaryButtonImageURL, false );
+ else if ( _rPropertyData.SecondaryButtonImage.is() )
+ rLine.pLine->ShowBrowseButton( Image( _rPropertyData.SecondaryButtonImage ), false );
+ else
+ rLine.pLine->ShowBrowseButton( false );
+ }
+ else
+ rLine.pLine->HideBrowseButton( false );
+
+ rLine.pLine->SetClickListener( this );
+ }
+ else
+ {
+ rLine.pLine->HideBrowseButton( true );
+ rLine.pLine->HideBrowseButton( false );
+ }
+
+ DBG_ASSERT( ( _rPropertyData.IndentLevel == 0 ) || ( _rPropertyData.IndentLevel == 1 ),
+ "OBrowserListBox::ChangeEntry: unsupported indent level!" );
+ rLine.pLine->IndentTitle( _rPropertyData.IndentLevel > 0 );
+
+ if ( nPos > 0 )
+ rLine.pLine->SetTabOrder( pRefWindow, WINDOW_ZORDER_BEHIND );
+ else
+ rLine.pLine->SetTabOrder( pRefWindow, WINDOW_ZORDER_FIRST );
+
+ m_aOutOfDateLines.insert( nPos );
+ rLine.pLine->SetComponentHelpIds(
+ HelpIdUrl::getHelpId( _rPropertyData.HelpURL ),
+ _rPropertyData.PrimaryButtonId,
+ _rPropertyData.SecondaryButtonId
+ );
+
+ if ( _rPropertyData.bReadOnly )
+ {
+ rLine.pLine->SetReadOnly( true );
+
+ // user controls (i.e. the ones not provided by the usual
+ // XPropertyControlFactory) have no chance to know that they should be read-only,
+ // since XPropertyHandler::describePropertyLine does not transport this
+ // information.
+ // So, we manually switch this to read-only.
+ if ( xControl.is() && ( xControl->getControlType() == PropertyControlType::Unknown ) )
+ {
+ Edit* pControlWindowAsEdit = dynamic_cast< Edit* >( rLine.pLine->getControlWindow() );
+ if ( pControlWindowAsEdit )
+ pControlWindowAsEdit->SetReadOnly( TRUE );
+ else
+ pControlWindowAsEdit->Enable( FALSE );
+ }
+ }
+ }
+ }
+
+ //------------------------------------------------------------------
+ long OBrowserListBox::PreNotify( NotifyEvent& _rNEvt )
+ {
+ switch ( _rNEvt.GetType() )
+ {
+ case EVENT_KEYINPUT:
+ {
+ const KeyEvent* pKeyEvent = _rNEvt.GetKeyEvent();
+ if ( ( pKeyEvent->GetKeyCode().GetModifier() != 0 )
+ || ( ( pKeyEvent->GetKeyCode().GetCode() != KEY_PAGEUP )
+ && ( pKeyEvent->GetKeyCode().GetCode() != KEY_PAGEDOWN )
+ )
+ )
+ break;
+
+ long nScrollOffset = 0;
+ if ( m_aVScroll.IsVisible() )
+ {
+ if ( pKeyEvent->GetKeyCode().GetCode() == KEY_PAGEUP )
+ nScrollOffset = -m_aVScroll.GetPageSize();
+ else if ( pKeyEvent->GetKeyCode().GetCode() == KEY_PAGEDOWN )
+ nScrollOffset = m_aVScroll.GetPageSize();
+ }
+
+ if ( nScrollOffset )
+ {
+ long nNewThumbPos = m_aVScroll.GetThumbPos() + nScrollOffset;
+ nNewThumbPos = ::std::max( nNewThumbPos, m_aVScroll.GetRangeMin() );
+ nNewThumbPos = ::std::min( nNewThumbPos, m_aVScroll.GetRangeMax() );
+ m_aVScroll.DoScroll( nNewThumbPos );
+ nNewThumbPos = m_aVScroll.GetThumbPos();
+
+ sal_uInt16 nFocusControlPos = 0;
+ sal_uInt16 nActiveControlPos = impl_getControlPos( m_xActiveControl );
+ if ( nActiveControlPos < nNewThumbPos )
+ nFocusControlPos = (sal_uInt16)nNewThumbPos;
+ else if ( nActiveControlPos >= nNewThumbPos + CalcVisibleLines() )
+ nFocusControlPos = (sal_uInt16)nNewThumbPos + CalcVisibleLines() - 1;
+ if ( nFocusControlPos )
+ {
+ if ( nFocusControlPos < m_aOrderedLines.size() )
+ {
+ m_aOrderedLines[ nFocusControlPos ]->second.pLine->GrabFocus();
+ }
+ else
+ OSL_ENSURE( false, "OBrowserListBox::PreNotify: internal error, invalid focus control position!" );
+ }
+ }
+
+ return 1L;
+ // handled this. In particular, we also consume PageUp/Down events if we do not use them for scrolling,
+ // otherwise they would be used to scroll the document view, which does not sound like it is desired by
+ // the user.
+ }
+ }
+ return Control::PreNotify( _rNEvt );
+ }
+
+ //------------------------------------------------------------------
+ long OBrowserListBox::Notify( NotifyEvent& _rNEvt )
+ {
+ switch ( _rNEvt.GetType() )
+ {
+ case EVENT_COMMAND:
+ {
+ const CommandEvent* pCommand = _rNEvt.GetCommandEvent();
+ if ( ( COMMAND_WHEEL == pCommand->GetCommand() )
+ || ( COMMAND_STARTAUTOSCROLL == pCommand->GetCommand() )
+ || ( COMMAND_AUTOSCROLL == pCommand->GetCommand() )
+ )
+ {
+ // interested in scroll events if we have a scrollbar
+ if ( m_aVScroll.IsVisible() )
+ {
+ HandleScrollCommand( *pCommand, NULL, &m_aVScroll );
+ }
+ }
+ }
+ break;
+ }
+
+ return Control::Notify( _rNEvt );
+ }
+
+//............................................................................
+} // namespace pcr
+//............................................................................
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/propctrlr/browserlistbox.hxx b/extensions/source/propctrlr/browserlistbox.hxx
new file mode 100644
index 000000000000..6ae8b6427283
--- /dev/null
+++ b/extensions/source/propctrlr/browserlistbox.hxx
@@ -0,0 +1,248 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _EXTENSIONS_PROPCTRLR_BROWSERLISTBOX_HXX_
+#define _EXTENSIONS_PROPCTRLR_BROWSERLISTBOX_HXX_
+
+#include "browserline.hxx"
+#include "modulepcr.hxx"
+#include "pcrcommon.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/inspection/XPropertyControl.hpp>
+#include <com/sun/star/inspection/XPropertyHandler.hpp>
+/** === end UNO includes === **/
+#include <vcl/scrbar.hxx>
+#include <vcl/lstbox.hxx>
+#include <vcl/button.hxx>
+#include <tools/link.hxx>
+#include <rtl/ref.hxx>
+
+#include <set>
+#include <vector>
+#include <hash_map>
+#include <boost/shared_ptr.hpp>
+
+//............................................................................
+namespace pcr
+{
+//............................................................................
+
+ class IPropertyLineListener;
+ class IPropertyControlObserver;
+ struct OLineDescriptor;
+ class InspectorHelpWindow;
+ class PropertyControlContext_Impl;
+
+ //========================================================================
+ //= administrative structures for OBrowserListBox
+ //========================================================================
+ typedef ::boost::shared_ptr< OBrowserLine > BrowserLinePointer;
+ struct ListBoxLine
+ {
+ BrowserLinePointer pLine;
+ ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyHandler >
+ xHandler;
+
+ ListBoxLine() { }
+ ListBoxLine( BrowserLinePointer _pLine, const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyHandler >& _rxHandler )
+ :pLine( _pLine )
+ ,xHandler( _rxHandler )
+ {
+ }
+ };
+ typedef ::std::hash_map< ::rtl::OUString, ListBoxLine, ::rtl::OUStringHash > ListBoxLines;
+ typedef ::std::vector< ListBoxLines::iterator > OrderedListBoxLines;
+
+ //========================================================================
+ //= IControlContext
+ //========================================================================
+ /** non-UNO version of XPropertyControlContext
+ */
+ class SAL_NO_VTABLE IControlContext
+ {
+ public:
+ virtual void SAL_CALL focusGained( const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyControl >& Control ) throw (::com::sun::star::uno::RuntimeException) = 0;
+ virtual void SAL_CALL valueChanged( const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyControl >& Control ) throw (::com::sun::star::uno::RuntimeException) = 0;
+ virtual void SAL_CALL activateNextControl( const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyControl >& CurrentControl ) throw (::com::sun::star::uno::RuntimeException) = 0;
+ };
+
+ //========================================================================
+ //= OBrowserListBox
+ //========================================================================
+ class OBrowserListBox :public Control
+ ,public IButtonClickListener
+ ,public IControlContext
+ ,public PcrClient
+ {
+ protected:
+ Window m_aLinesPlayground;
+ ScrollBar m_aVScroll;
+ ::std::auto_ptr< InspectorHelpWindow >
+ m_pHelpWindow;
+ ListBoxLines m_aLines;
+ OrderedListBoxLines m_aOrderedLines;
+ IPropertyLineListener* m_pLineListener;
+ IPropertyControlObserver* m_pControlObserver;
+ long m_nYOffset;
+ long m_nCurrentPreferredHelpHeight;
+ ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyControl >
+ m_xActiveControl;
+ sal_uInt16 m_nTheNameSize;
+ sal_uInt16 m_nRowHeight;
+ ::std::set< sal_uInt16 > m_aOutOfDateLines;
+ sal_Bool m_bIsActive : 1;
+ sal_Bool m_bUpdate : 1;
+ ::rtl::Reference< PropertyControlContext_Impl >
+ m_pControlContextImpl;
+
+ protected:
+ void PositionLine( sal_uInt16 _nIndex );
+ void UpdatePosNSize();
+ void UpdatePlayGround();
+ void UpdateVScroll();
+ void ShowEntry(sal_uInt16 nPos);
+ void MoveThumbTo(sal_Int32 nNewThumbPos);
+ void Resize();
+
+ public:
+ OBrowserListBox( Window* pParent, WinBits nWinStyle = WB_DIALOGCONTROL );
+
+ ~OBrowserListBox();
+
+ void UpdateAll();
+
+ void ActivateListBox( sal_Bool _bActive );
+
+ sal_uInt16 CalcVisibleLines();
+ void EnableUpdate();
+ void DisableUpdate();
+ long Notify( NotifyEvent& _rNEvt );
+ long PreNotify( NotifyEvent& _rNEvt );
+
+ void SetListener( IPropertyLineListener* _pListener );
+ void SetObserver( IPropertyControlObserver* _pObserver );
+
+ void EnableHelpSection( bool _bEnable );
+ bool HasHelpSection() const;
+ void SetHelpText( const ::rtl::OUString& _rHelpText );
+ void SetHelpLineLimites( sal_Int32 _nMinLines, sal_Int32 _nMaxLines );
+
+ void Clear();
+
+ sal_uInt16 InsertEntry( const OLineDescriptor&, sal_uInt16 nPos = EDITOR_LIST_APPEND );
+ sal_Bool RemoveEntry( const ::rtl::OUString& _rName );
+ void ChangeEntry( const OLineDescriptor&, sal_uInt16 nPos );
+
+ void SetPropertyValue( const ::rtl::OUString& rEntryName, const ::com::sun::star::uno::Any& rValue, bool _bUnknownValue );
+ sal_uInt16 GetPropertyPos( const ::rtl::OUString& rEntryName ) const;
+ ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyControl >
+ GetPropertyControl( const ::rtl::OUString& rEntryName );
+ void EnablePropertyControls( const ::rtl::OUString& _rEntryName, sal_Int16 _nControls, bool _bEnable );
+ void EnablePropertyLine( const ::rtl::OUString& _rEntryName, bool _bEnable );
+
+ sal_Int32 GetMinimumWidth();
+ sal_Int32 GetMinimumHeight();
+
+
+ sal_Bool IsModified( ) const;
+ void CommitModified( );
+
+ protected:
+ // IControlContext
+ virtual void SAL_CALL focusGained( const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyControl >& Control ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL valueChanged( const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyControl >& Control ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL activateNextControl( const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyControl >& CurrentControl ) throw (::com::sun::star::uno::RuntimeException);
+
+ // IButtonClickListener
+ void buttonClicked( OBrowserLine* _pLine, sal_Bool _bPrimary );
+
+ using Window::SetHelpText;
+ private:
+ DECL_LINK( ScrollHdl, ScrollBar* );
+
+ /** retrieves the index of a given control in our line list
+ @param _rxControl
+ The control to lookup. Must denote a control of one of the lines in ->m_aLines
+ */
+ sal_uInt16 impl_getControlPos( const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyControl >& _rxControl ) const;
+
+ /** retrieves (a reference to) the ->ListBoxLine for a given control
+ @param _rxControl
+ The control to lookup. Must denote a control of one of the lines in ->m_aLines
+ */
+ inline const ListBoxLine&
+ impl_getControlLine( const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyControl >& _rxControl ) const
+ {
+ return m_aOrderedLines[ impl_getControlPos( _rxControl ) ]->second;
+ }
+
+ /** sets the given property value at the given control, after converting it as necessary
+ @param _rLine
+ The line whose at which the value is to be set.
+ @param _rPropertyValue
+ the property value to set. If it's not compatible with the control value,
+ it will be converted, using <member>XPropertyHandler::convertToControlValue</member>
+ */
+ void impl_setControlAsPropertyValue( const ListBoxLine& _rLine, const ::com::sun::star::uno::Any& _rPropertyValue );
+
+ /** retrieves the value for the given control, as a property value, after converting it as necessary
+ @param _rLine
+ The line whose at which the value is to be set.
+ */
+ ::com::sun::star::uno::Any
+ impl_getControlAsPropertyValue( const ListBoxLine& _rLine ) const;
+
+ /** retrieves the ->BrowserLinePointer for a given entry name
+ @param _rEntryName
+ the name whose line is to be looked up
+ @param _out_rpLine
+ contains, upon return, the found browser line, if any
+ @return
+ <TRUE/> if and only if a non-<NULL/> line for the given entry name could be
+ found.
+ */
+ bool impl_getBrowserLineForName( const ::rtl::OUString& _rEntryName, BrowserLinePointer& _out_rpLine ) const;
+
+ /** returns the preferred height (in pixels) of the help section, or 0 if we
+ currently don't have a help section
+ */
+ long impl_getPrefererredHelpHeight();
+
+ private:
+ using Window::Activate;
+ };
+
+//............................................................................
+} // namespace pcr
+//............................................................................
+
+#endif // _EXTENSIONS_PROPCTRLR_BROWSERLISTBOX_HXX_
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/propctrlr/browserpage.cxx b/extensions/source/propctrlr/browserpage.cxx
new file mode 100644
index 000000000000..30f1516190f4
--- /dev/null
+++ b/extensions/source/propctrlr/browserpage.cxx
@@ -0,0 +1,107 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+#include "browserpage.hxx"
+
+//............................................................................
+namespace pcr
+{
+//............................................................................
+
+ #define LAYOUT_BORDER_LEFT 3
+ #define LAYOUT_BORDER_TOP 3
+ #define LAYOUT_BORDER_RIGHT 3
+ #define LAYOUT_BORDER_BOTTOM 3
+
+ //==================================================================
+ // class OBrowserPage
+ //==================================================================
+ //------------------------------------------------------------------
+ OBrowserPage::OBrowserPage(Window* pParent,WinBits nWinStyle)
+ :TabPage(pParent,nWinStyle)
+ ,m_aListBox(this)
+ {
+ m_aListBox.SetBackground(GetBackground());
+ m_aListBox.SetPaintTransparent( TRUE );
+ m_aListBox.Show();
+ }
+
+ //------------------------------------------------------------------
+ OBrowserPage::~OBrowserPage()
+ {
+ }
+
+ //------------------------------------------------------------------
+ void OBrowserPage::Resize()
+ {
+ Size aSize( GetOutputSizePixel() );
+ aSize.Width() -= LAYOUT_BORDER_LEFT + LAYOUT_BORDER_RIGHT;
+ aSize.Height() -= LAYOUT_BORDER_TOP + LAYOUT_BORDER_BOTTOM;
+ m_aListBox.SetPosSizePixel( Point( LAYOUT_BORDER_LEFT, LAYOUT_BORDER_TOP ), aSize );
+ }
+
+ //------------------------------------------------------------------
+ OBrowserListBox& OBrowserPage::getListBox()
+ {
+ return m_aListBox;
+ }
+
+ //------------------------------------------------------------------
+ const OBrowserListBox& OBrowserPage::getListBox() const
+ {
+ return m_aListBox;
+ }
+
+ //------------------------------------------------------------------
+ void OBrowserPage::StateChanged(StateChangedType nType)
+ {
+ Window::StateChanged( nType);
+ if (STATE_CHANGE_VISIBLE == nType)
+ m_aListBox.ActivateListBox(IsVisible());
+ }
+
+ //------------------------------------------------------------------
+ sal_Int32 OBrowserPage::getMinimumWidth()
+ {
+ return m_aListBox.GetMinimumWidth() + LAYOUT_BORDER_LEFT + LAYOUT_BORDER_RIGHT;
+ }
+
+ //------------------------------------------------------------------
+ sal_Int32 OBrowserPage::getMinimumHeight()
+ {
+ return m_aListBox.GetMinimumHeight() + LAYOUT_BORDER_TOP + LAYOUT_BORDER_BOTTOM;
+ }
+
+//............................................................................
+} // namespace pcr
+//............................................................................
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/propctrlr/browserpage.hxx b/extensions/source/propctrlr/browserpage.hxx
new file mode 100644
index 000000000000..348e56bbc5a7
--- /dev/null
+++ b/extensions/source/propctrlr/browserpage.hxx
@@ -0,0 +1,70 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _EXTENSIONS_PROPCTRLR_BROWSERPAGE_HXX_
+#define _EXTENSIONS_PROPCTRLR_BROWSERPAGE_HXX_
+
+#include <vcl/tabpage.hxx>
+#include "browserlistbox.hxx"
+
+//............................................................................
+namespace pcr
+{
+//............................................................................
+
+ //========================================================================
+ //= OBrowserPage
+ //========================================================================
+ class OBrowserPage : public TabPage
+ {
+ private:
+ OBrowserListBox m_aListBox;
+
+ protected:
+ virtual void Resize();
+ virtual void StateChanged(StateChangedType nType);
+
+ public:
+ OBrowserPage(Window* pParent, WinBits nWinStyle = 0);
+ ~OBrowserPage();
+
+ sal_Int32 getMinimumWidth();
+ sal_Int32 getMinimumHeight();
+
+ OBrowserListBox& getListBox();
+ const OBrowserListBox& getListBox() const;
+ };
+
+//............................................................................
+} // namespace pcr
+//............................................................................
+
+#endif // _EXTENSIONS_PROPCTRLR_BROWSERPAGE_HXX_
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/propctrlr/browserview.cxx b/extensions/source/propctrlr/browserview.cxx
new file mode 100644
index 000000000000..1c9e29f89f8e
--- /dev/null
+++ b/extensions/source/propctrlr/browserview.cxx
@@ -0,0 +1,146 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+#include "browserview.hxx"
+#include "propertyeditor.hxx"
+#include "propctrlr.hrc"
+#include <tools/debug.hxx>
+#include <memory>
+
+//............................................................................
+namespace pcr
+{
+//............................................................................
+
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::lang;
+
+
+ //========================================================================
+ //= class OPropertyBrowserView
+ //========================================================================
+ DBG_NAME(OPropertyBrowserView)
+ //------------------------------------------------------------------------
+ OPropertyBrowserView::OPropertyBrowserView( const Reference< XMultiServiceFactory >& _rxORB,
+ Window* _pParent, WinBits nBits)
+ :Window(_pParent, nBits | WB_3DLOOK)
+ ,m_xORB(_rxORB)
+ ,m_nActivePage(0)
+ {
+ DBG_CTOR(OPropertyBrowserView,NULL);
+
+ m_pPropBox = new OPropertyEditor( this );
+ m_pPropBox->SetHelpId(HID_FM_PROPDLG_TABCTR);
+ m_pPropBox->setPageActivationHandler(LINK(this, OPropertyBrowserView, OnPageActivation));
+
+ m_pPropBox->Show();
+ }
+
+ //------------------------------------------------------------------------
+ IMPL_LINK(OPropertyBrowserView, OnPageActivation, void*, EMPTYARG)
+ {
+ m_nActivePage = m_pPropBox->GetCurPage();
+ if (m_aPageActivationHandler.IsSet())
+ m_aPageActivationHandler.Call(NULL);
+ return 0L;
+ }
+
+ //------------------------------------------------------------------------
+ OPropertyBrowserView::~OPropertyBrowserView()
+ {
+ if(m_pPropBox)
+ {
+ sal_uInt16 nTmpPage = m_pPropBox->GetCurPage();
+ if (nTmpPage)
+ m_nActivePage = nTmpPage;
+ ::std::auto_ptr<Window> aTemp(m_pPropBox);
+ m_pPropBox = NULL;
+ }
+ m_xORB = NULL;
+
+ DBG_DTOR(OPropertyBrowserView, NULL);
+ }
+
+ //------------------------------------------------------------------------
+ void OPropertyBrowserView::activatePage(sal_uInt16 _nPage)
+ {
+ m_nActivePage = _nPage;
+ getPropertyBox().SetPage(m_nActivePage);
+ }
+
+ //------------------------------------------------------------------------
+ void OPropertyBrowserView::GetFocus()
+ {
+ if (m_pPropBox)
+ m_pPropBox->GrabFocus();
+ else
+ Window::GetFocus();
+ }
+
+ //------------------------------------------------------------------------
+ long OPropertyBrowserView::Notify( NotifyEvent& _rNEvt )
+ {
+ if ( EVENT_KEYINPUT == _rNEvt.GetType() )
+ {
+ sal_uInt16 nKey = _rNEvt.GetKeyEvent()->GetKeyCode().GetCode();
+
+ if ( ( KEY_DELETE == nKey ) || ( KEY_BACKSPACE == nKey ) )
+ // silence this, we don't want to propagate this outside the property
+ // browser, as it will probably do harm there
+ // #i63285# / 2006-12-06 / frank.schoenheit@sun.com
+ return 1;
+ }
+ return Window::Notify( _rNEvt );
+ }
+
+ //------------------------------------------------------------------------
+ void OPropertyBrowserView::Resize()
+ {
+ Size aSize = GetOutputSizePixel();
+ m_pPropBox->SetSizePixel(aSize);
+ }
+
+ // #95343# ---------------------------------------------------------------
+ ::com::sun::star::awt::Size OPropertyBrowserView::getMinimumSize()
+ {
+ Size aSize = GetOutputSizePixel();
+ if( m_pPropBox )
+ {
+ aSize.setHeight( m_pPropBox->getMinimumHeight() );
+ aSize.setWidth( m_pPropBox->getMinimumWidth() );
+ }
+ return ::com::sun::star::awt::Size( aSize.Width(), aSize.Height() );
+ }
+
+//............................................................................
+} // namespace pcr
+//............................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/propctrlr/browserview.hxx b/extensions/source/propctrlr/browserview.hxx
new file mode 100644
index 000000000000..5e7801f927ca
--- /dev/null
+++ b/extensions/source/propctrlr/browserview.hxx
@@ -0,0 +1,91 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _EXTENSIONS_PROPCTRLR_BROWSERVIEW_HXX_
+#define _EXTENSIONS_PROPCTRLR_BROWSERVIEW_HXX_
+
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <vcl/window.hxx>
+#include <tools/resid.hxx>
+// #95343# --------------------
+#include <com/sun/star/awt/Size.hpp>
+
+//............................................................................
+namespace pcr
+{
+//............................................................................
+
+ class OPropertyEditor;
+
+ //========================================================================
+ //=
+ //========================================================================
+ class OPropertyBrowserView : public Window
+ {
+ ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xORB;
+
+ OPropertyEditor* m_pPropBox;
+ sal_uInt16 m_nActivePage;
+ Link m_aPageActivationHandler;
+
+ protected:
+ virtual void Resize();
+ virtual void GetFocus();
+ virtual long Notify( NotifyEvent& _rNEvt );
+
+ public:
+ OPropertyBrowserView(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _xORB,
+ Window* pParent, WinBits nBits = 0);
+
+ virtual ~OPropertyBrowserView();
+
+ OPropertyEditor& getPropertyBox() { return *m_pPropBox; }
+
+ // page handling
+ sal_uInt16 getActivaPage() const { return m_nActivePage; }
+ void activatePage(sal_uInt16 _nPage);
+
+ void setPageActivationHandler(const Link& _rHdl) { m_aPageActivationHandler = _rHdl; }
+ Link getPageActivationHandler() const { return m_aPageActivationHandler; }
+
+ // #95343# ------------------
+ ::com::sun::star::awt::Size getMinimumSize();
+
+ protected:
+ DECL_LINK(OnPageActivation, void*);
+ };
+
+
+//............................................................................
+} // namespace pcr
+//............................................................................
+
+#endif // _EXTENSIONS_PROPCTRLR_BROWSERVIEW_HXX_
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/propctrlr/buttonnavigationhandler.cxx b/extensions/source/propctrlr/buttonnavigationhandler.cxx
new file mode 100644
index 000000000000..5f9f8e941ecf
--- /dev/null
+++ b/extensions/source/propctrlr/buttonnavigationhandler.cxx
@@ -0,0 +1,297 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+#include "buttonnavigationhandler.hxx"
+#include "formstrings.hxx"
+#include "formmetadata.hxx"
+#include "pushbuttonnavigation.hxx"
+
+/** === begin UNO includes === **/
+/** === end UNO includes === **/
+#include <tools/debug.hxx>
+
+//------------------------------------------------------------------------
+extern "C" void SAL_CALL createRegistryInfo_ButtonNavigationHandler()
+{
+ ::pcr::ButtonNavigationHandler::registerImplementation();
+}
+
+//........................................................................
+namespace pcr
+{
+//........................................................................
+
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::lang;
+ using namespace ::com::sun::star::beans;
+ using namespace ::com::sun::star::script;
+ using namespace ::com::sun::star::frame;
+ using namespace ::com::sun::star::inspection;
+
+ //====================================================================
+ //= ButtonNavigationHandler
+ //====================================================================
+ DBG_NAME( ButtonNavigationHandler )
+ //--------------------------------------------------------------------
+ ButtonNavigationHandler::ButtonNavigationHandler( const Reference< XComponentContext >& _rxContext )
+ :ButtonNavigationHandler_Base( _rxContext )
+ {
+ DBG_CTOR( ButtonNavigationHandler, NULL );
+
+ m_aContext.createComponent(
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.form.inspection.FormComponentPropertyHandler" ) ),
+ m_xSlaveHandler );
+ if ( !m_xSlaveHandler.is() )
+ throw RuntimeException();
+ }
+
+ //--------------------------------------------------------------------
+ ButtonNavigationHandler::~ButtonNavigationHandler( )
+ {
+ DBG_DTOR( ButtonNavigationHandler, NULL );
+ }
+
+ //--------------------------------------------------------------------
+ ::rtl::OUString SAL_CALL ButtonNavigationHandler::getImplementationName_static( ) throw (RuntimeException)
+ {
+ return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.extensions.ButtonNavigationHandler" ) );
+ }
+
+ //--------------------------------------------------------------------
+ Sequence< ::rtl::OUString > SAL_CALL ButtonNavigationHandler::getSupportedServiceNames_static( ) throw (RuntimeException)
+ {
+ Sequence< ::rtl::OUString > aSupported( 1 );
+ aSupported[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.form.inspection.ButtonNavigationHandler" ) );
+ return aSupported;
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL ButtonNavigationHandler::inspect( const Reference< XInterface >& _rxIntrospectee ) throw (RuntimeException, NullPointerException)
+ {
+ ButtonNavigationHandler_Base::inspect( _rxIntrospectee );
+ m_xSlaveHandler->inspect( _rxIntrospectee );
+ }
+
+ //--------------------------------------------------------------------
+ PropertyState SAL_CALL ButtonNavigationHandler::getPropertyState( const ::rtl::OUString& _rPropertyName ) throw (UnknownPropertyException, RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ PropertyId nPropId( impl_getPropertyId_throw( _rPropertyName ) );
+ PropertyState eState = PropertyState_DIRECT_VALUE;
+ switch ( nPropId )
+ {
+ case PROPERTY_ID_BUTTONTYPE:
+ {
+ PushButtonNavigation aHelper( m_xComponent );
+ eState = aHelper.getCurrentButtonTypeState();
+ }
+ break;
+ case PROPERTY_ID_TARGET_URL:
+ {
+ PushButtonNavigation aHelper( m_xComponent );
+ eState = aHelper.getCurrentTargetURLState();
+ }
+ break;
+
+ default:
+ DBG_ERROR( "ButtonNavigationHandler::getPropertyState: cannot handle this property!" );
+ break;
+ }
+
+ return eState;
+ }
+
+ //--------------------------------------------------------------------
+ Any SAL_CALL ButtonNavigationHandler::getPropertyValue( const ::rtl::OUString& _rPropertyName ) throw (UnknownPropertyException, RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ PropertyId nPropId( impl_getPropertyId_throw( _rPropertyName ) );
+
+ Any aReturn;
+ switch ( nPropId )
+ {
+ case PROPERTY_ID_BUTTONTYPE:
+ {
+ PushButtonNavigation aHelper( m_xComponent );
+ aReturn = aHelper.getCurrentButtonType();
+ }
+ break;
+
+ case PROPERTY_ID_TARGET_URL:
+ {
+ PushButtonNavigation aHelper( m_xComponent );
+ aReturn = aHelper.getCurrentTargetURL();
+ }
+ break;
+
+ default:
+ DBG_ERROR( "ButtonNavigationHandler::getPropertyValue: cannot handle this property!" );
+ break;
+ }
+
+ return aReturn;
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL ButtonNavigationHandler::setPropertyValue( const ::rtl::OUString& _rPropertyName, const Any& _rValue ) throw (UnknownPropertyException, RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ PropertyId nPropId( impl_getPropertyId_throw( _rPropertyName ) );
+ switch ( nPropId )
+ {
+ case PROPERTY_ID_BUTTONTYPE:
+ {
+ PushButtonNavigation aHelper( m_xComponent );
+ aHelper.setCurrentButtonType( _rValue );
+ }
+ break;
+
+ case PROPERTY_ID_TARGET_URL:
+ {
+ PushButtonNavigation aHelper( m_xComponent );
+ aHelper.setCurrentTargetURL( _rValue );
+ }
+ break;
+
+ default:
+ OSL_ENSURE( sal_False, "ButtonNavigationHandler::setPropertyValue: cannot handle this id!" );
+ }
+ }
+
+ //--------------------------------------------------------------------
+ bool ButtonNavigationHandler::isNavigationCapableButton( const Reference< XPropertySet >& _rxComponent )
+ {
+ Reference< XPropertySetInfo > xPSI;
+ if ( _rxComponent.is() )
+ xPSI = _rxComponent->getPropertySetInfo();
+
+ return xPSI.is()
+ && xPSI->hasPropertyByName( PROPERTY_TARGET_URL )
+ && xPSI->hasPropertyByName( PROPERTY_BUTTONTYPE );
+ }
+
+ //--------------------------------------------------------------------
+ Sequence< Property > SAL_CALL ButtonNavigationHandler::doDescribeSupportedProperties() const
+ {
+ ::std::vector< Property > aProperties;
+
+ if ( isNavigationCapableButton( m_xComponent ) )
+ {
+ addStringPropertyDescription( aProperties, PROPERTY_TARGET_URL );
+ implAddPropertyDescription( aProperties, PROPERTY_BUTTONTYPE, ::getCppuType( static_cast< sal_Int32* >( NULL ) ) );
+ }
+
+ if ( aProperties.empty() )
+ return Sequence< Property >();
+ return Sequence< Property >( &(*aProperties.begin()), aProperties.size() );
+ }
+
+ //--------------------------------------------------------------------
+ Sequence< ::rtl::OUString > SAL_CALL ButtonNavigationHandler::getActuatingProperties( ) throw (RuntimeException)
+ {
+ Sequence< ::rtl::OUString > aActuating( 2 );
+ aActuating[0] = PROPERTY_BUTTONTYPE;
+ aActuating[1] = PROPERTY_TARGET_URL;
+ return aActuating;
+ }
+
+ //--------------------------------------------------------------------
+ InteractiveSelectionResult SAL_CALL ButtonNavigationHandler::onInteractivePropertySelection( const ::rtl::OUString& _rPropertyName, sal_Bool _bPrimary, Any& _rData, const Reference< XObjectInspectorUI >& _rxInspectorUI ) throw (UnknownPropertyException, NullPointerException, RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ PropertyId nPropId( impl_getPropertyId_throw( _rPropertyName ) );
+
+ InteractiveSelectionResult eReturn( InteractiveSelectionResult_Cancelled );
+
+ switch ( nPropId )
+ {
+ case PROPERTY_ID_TARGET_URL:
+ eReturn = m_xSlaveHandler->onInteractivePropertySelection( _rPropertyName, _bPrimary, _rData, _rxInspectorUI );
+ break;
+ default:
+ eReturn = ButtonNavigationHandler_Base::onInteractivePropertySelection( _rPropertyName, _bPrimary, _rData, _rxInspectorUI );
+ break;
+ }
+
+ return eReturn;
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL ButtonNavigationHandler::actuatingPropertyChanged( const ::rtl::OUString& _rActuatingPropertyName, const Any& /*_rNewValue*/, const Any& /*_rOldValue*/, const Reference< XObjectInspectorUI >& _rxInspectorUI, sal_Bool /*_bFirstTimeInit*/ ) throw (NullPointerException, RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ PropertyId nPropId( impl_getPropertyId_throw( _rActuatingPropertyName ) );
+ switch ( nPropId )
+ {
+ case PROPERTY_ID_BUTTONTYPE:
+ {
+ PushButtonNavigation aHelper( m_xComponent );
+ _rxInspectorUI->enablePropertyUI( PROPERTY_TARGET_URL, aHelper.currentButtonTypeIsOpenURL() );
+ }
+ break;
+
+ case PROPERTY_ID_TARGET_URL:
+ {
+ PushButtonNavigation aHelper( m_xComponent );
+ _rxInspectorUI->enablePropertyUI( PROPERTY_TARGET_FRAME, aHelper.hasNonEmptyCurrentTargetURL() );
+ }
+ break;
+
+ default:
+ OSL_ENSURE( sal_False, "ButtonNavigationHandler::actuatingPropertyChanged: cannot handle this id!" );
+ }
+ }
+
+ //--------------------------------------------------------------------
+ LineDescriptor SAL_CALL ButtonNavigationHandler::describePropertyLine( const ::rtl::OUString& _rPropertyName, const Reference< XPropertyControlFactory >& _rxControlFactory ) throw (UnknownPropertyException, NullPointerException, RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ PropertyId nPropId( impl_getPropertyId_throw( _rPropertyName ) );
+
+ LineDescriptor aReturn;
+
+ switch ( nPropId )
+ {
+ case PROPERTY_ID_TARGET_URL:
+ aReturn = m_xSlaveHandler->describePropertyLine( _rPropertyName, _rxControlFactory );
+ break;
+ default:
+ aReturn = ButtonNavigationHandler_Base::describePropertyLine( _rPropertyName, _rxControlFactory );
+ break;
+ }
+
+ return aReturn;
+ }
+
+//........................................................................
+} // namespace pcr
+//........................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/propctrlr/buttonnavigationhandler.hxx b/extensions/source/propctrlr/buttonnavigationhandler.hxx
new file mode 100644
index 000000000000..d3be8b131e29
--- /dev/null
+++ b/extensions/source/propctrlr/buttonnavigationhandler.hxx
@@ -0,0 +1,92 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef EXTENSIONS_SOURCE_PROPCTRLR_BUTTONNAVIGATIONHANDLER_HXX
+#define EXTENSIONS_SOURCE_PROPCTRLR_BUTTONNAVIGATIONHANDLER_HXX
+
+#include "propertyhandler.hxx"
+
+/** === begin UNO includes === **/
+/** === end UNO includes === **/
+
+//........................................................................
+namespace pcr
+{
+//........................................................................
+
+ //====================================================================
+ //= ButtonNavigationHandler
+ //====================================================================
+ class ButtonNavigationHandler;
+ typedef HandlerComponentBase< ButtonNavigationHandler > ButtonNavigationHandler_Base;
+ /** a property handler for any virtual string properties
+ */
+ class ButtonNavigationHandler : public ButtonNavigationHandler_Base
+ {
+ private:
+ ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyHandler >
+ m_xSlaveHandler;
+
+ public:
+ ButtonNavigationHandler(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _rxContext
+ );
+ static ::rtl::OUString SAL_CALL getImplementationName_static( ) throw (::com::sun::star::uno::RuntimeException);
+ static ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames_static( ) throw (::com::sun::star::uno::RuntimeException);
+
+ protected:
+ ~ButtonNavigationHandler();
+
+ static bool isNavigationCapableButton( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxComponent );
+
+ protected:
+ // XPropertyHandler overriables
+ virtual void SAL_CALL inspect( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxIntrospectee ) throw (::com::sun::star::uno::RuntimeException, ::com::sun::star::lang::NullPointerException);
+ virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue( const ::rtl::OUString& _rPropertyName ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setPropertyValue( const ::rtl::OUString& _rPropertyName, const ::com::sun::star::uno::Any& _rValue ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::beans::PropertyState SAL_CALL getPropertyState( const ::rtl::OUString& _rPropertyName ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString >
+ SAL_CALL getActuatingProperties( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::inspection::InteractiveSelectionResult
+ SAL_CALL onInteractivePropertySelection( const ::rtl::OUString& _rPropertyName, sal_Bool _bPrimary, ::com::sun::star::uno::Any& _rData, const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XObjectInspectorUI >& _rxInspectorUI ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::NullPointerException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL actuatingPropertyChanged( const ::rtl::OUString& _rActuatingPropertyName, const ::com::sun::star::uno::Any& _rNewValue, const ::com::sun::star::uno::Any& _rOldValue, const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XObjectInspectorUI >& _rxInspectorUI, sal_Bool _bFirstTimeInit ) throw (::com::sun::star::lang::NullPointerException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::inspection::LineDescriptor
+ SAL_CALL describePropertyLine( const ::rtl::OUString& _rPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyControlFactory >& _rxControlFactory ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::NullPointerException, ::com::sun::star::uno::RuntimeException);
+
+ // PropertyHandler overridables
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property >
+ SAL_CALL doDescribeSupportedProperties() const;
+ };
+
+//........................................................................
+} // namespace pcr
+//........................................................................
+
+#endif // EXTENSIONS_SOURCE_PROPCTRLR_BUTTONNAVIGATIONHANDLER_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/propctrlr/cellbindinghandler.cxx b/extensions/source/propctrlr/cellbindinghandler.cxx
new file mode 100644
index 000000000000..41bc249994b1
--- /dev/null
+++ b/extensions/source/propctrlr/cellbindinghandler.cxx
@@ -0,0 +1,507 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+#include "cellbindinghandler.hxx"
+#include "formstrings.hxx"
+#include "formmetadata.hxx"
+#include "cellbindinghelper.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/form/binding/XValueBinding.hpp>
+#include <com/sun/star/table/CellAddress.hpp>
+#include <com/sun/star/inspection/XObjectInspectorUI.hpp>
+/** === end UNO includes === **/
+#include <tools/debug.hxx>
+
+//------------------------------------------------------------------------
+extern "C" void SAL_CALL createRegistryInfo_CellBindingPropertyHandler()
+{
+ ::pcr::CellBindingPropertyHandler::registerImplementation();
+}
+
+//........................................................................
+namespace pcr
+{
+//........................................................................
+
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::table;
+ using namespace ::com::sun::star::lang;
+ using namespace ::com::sun::star::beans;
+ using namespace ::com::sun::star::script;
+ using namespace ::com::sun::star::frame;
+ using namespace ::com::sun::star::inspection;
+ using namespace ::com::sun::star::form::binding;
+ using namespace ::comphelper;
+
+ //====================================================================
+ //= CellBindingPropertyHandler
+ //====================================================================
+ DBG_NAME( CellBindingPropertyHandler )
+ //--------------------------------------------------------------------
+ CellBindingPropertyHandler::CellBindingPropertyHandler( const Reference< XComponentContext >& _rxContext )
+ :CellBindingPropertyHandler_Base( _rxContext )
+ ,m_pCellExchangeConverter( new DefaultEnumRepresentation( *m_pInfoService, ::getCppuType( static_cast< sal_Int16* >( NULL ) ), PROPERTY_ID_CELL_EXCHANGE_TYPE ) )
+ {
+ DBG_CTOR( CellBindingPropertyHandler, NULL );
+ }
+
+ //--------------------------------------------------------------------
+ ::rtl::OUString SAL_CALL CellBindingPropertyHandler::getImplementationName_static( ) throw (RuntimeException)
+ {
+ return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.extensions.CellBindingPropertyHandler" ) );
+ }
+
+ //--------------------------------------------------------------------
+ Sequence< ::rtl::OUString > SAL_CALL CellBindingPropertyHandler::getSupportedServiceNames_static( ) throw (RuntimeException)
+ {
+ Sequence< ::rtl::OUString > aSupported( 1 );
+ aSupported[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.form.inspection.CellBindingPropertyHandler" ) );
+ return aSupported;
+ }
+
+ //--------------------------------------------------------------------
+ void CellBindingPropertyHandler::onNewComponent()
+ {
+ PropertyHandlerComponent::onNewComponent();
+
+ Reference< XModel > xDocument( impl_getContextDocument_nothrow() );
+ DBG_ASSERT( xDocument.is(), "CellBindingPropertyHandler::onNewComponent: no document!" );
+ if ( CellBindingHelper::isSpreadsheetDocument( xDocument ) )
+ m_pHelper.reset( new CellBindingHelper( m_xComponent, xDocument ) );
+ }
+
+ //--------------------------------------------------------------------
+ CellBindingPropertyHandler::~CellBindingPropertyHandler( )
+ {
+ DBG_DTOR( CellBindingPropertyHandler, NULL );
+ }
+
+ //--------------------------------------------------------------------
+ Sequence< ::rtl::OUString > SAL_CALL CellBindingPropertyHandler::getActuatingProperties( ) throw (RuntimeException)
+ {
+ Sequence< ::rtl::OUString > aInterestingProperties( 3 );
+ aInterestingProperties[0] = PROPERTY_LIST_CELL_RANGE;
+ aInterestingProperties[1] = PROPERTY_BOUND_CELL;
+ aInterestingProperties[2] = PROPERTY_CONTROLSOURCE;
+ return aInterestingProperties;
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL CellBindingPropertyHandler::actuatingPropertyChanged( const ::rtl::OUString& _rActuatingPropertyName, const Any& _rNewValue, const Any& /*_rOldValue*/, const Reference< XObjectInspectorUI >& _rxInspectorUI, sal_Bool _bFirstTimeInit ) throw (NullPointerException, RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ PropertyId nActuatingPropId( impl_getPropertyId_throw( _rActuatingPropertyName ) );
+ OSL_PRECOND( m_pHelper.get(), "CellBindingPropertyHandler::actuatingPropertyChanged: inconsistentcy!" );
+ // if we survived impl_getPropertyId_throw, we should have a helper, since no helper implies no properties
+
+ OSL_PRECOND( _rxInspectorUI.is(), "FormComponentPropertyHandler::actuatingPropertyChanged: no access to the UI!" );
+ if ( !_rxInspectorUI.is() )
+ throw NullPointerException();
+
+ ::std::vector< PropertyId > aDependentProperties;
+
+ switch ( nActuatingPropId )
+ {
+ // ----- BoundCell -----
+ case PROPERTY_ID_BOUND_CELL:
+ {
+ // the SQL-data-binding related properties need to be enabled if and only if
+ // there is *no* valid cell binding
+ Reference< XValueBinding > xBinding;
+ _rNewValue >>= xBinding;
+
+ if ( impl_isSupportedProperty_nothrow( PROPERTY_ID_CELL_EXCHANGE_TYPE ) )
+ _rxInspectorUI->enablePropertyUI( PROPERTY_CELL_EXCHANGE_TYPE, xBinding.is() );
+ if ( impl_componentHasProperty_throw( PROPERTY_CONTROLSOURCE ) )
+ _rxInspectorUI->enablePropertyUI( PROPERTY_CONTROLSOURCE, !xBinding.is() );
+
+ if ( impl_isSupportedProperty_nothrow( PROPERTY_ID_FILTERPROPOSAL ) )
+ _rxInspectorUI->enablePropertyUI( PROPERTY_FILTERPROPOSAL, !xBinding.is() );
+ if ( impl_isSupportedProperty_nothrow( PROPERTY_ID_EMPTY_IS_NULL ) )
+ _rxInspectorUI->enablePropertyUI( PROPERTY_EMPTY_IS_NULL, !xBinding.is() );
+
+ aDependentProperties.push_back( PROPERTY_ID_BOUNDCOLUMN );
+
+ if ( !xBinding.is() && m_pHelper->getCurrentBinding().is() )
+ {
+ // ensure that the "transfer selection as" property is reset. Since we can't remember
+ // it at the object itself, but derive it from the binding only, we have to normalize
+ // it now that there *is* no binding anymore.
+ setPropertyValue( PROPERTY_CELL_EXCHANGE_TYPE, makeAny( (sal_Int16) 0 ) );
+ }
+ }
+ break;
+
+ // ----- CellRange -----
+ case PROPERTY_ID_LIST_CELL_RANGE:
+ {
+ // the list source related properties need to be enabled if and only if
+ // there is *no* valid external list source for the control
+ Reference< XListEntrySource > xSource;
+ _rNewValue >>= xSource;
+
+ _rxInspectorUI->enablePropertyUI( PROPERTY_STRINGITEMLIST, !xSource.is() );
+ _rxInspectorUI->enablePropertyUI( PROPERTY_LISTSOURCE, !xSource.is() );
+ _rxInspectorUI->enablePropertyUI( PROPERTY_LISTSOURCETYPE, !xSource.is() );
+
+ aDependentProperties.push_back( PROPERTY_ID_BOUNDCOLUMN );
+
+ // also reset the list entries if the cell range is reset
+ // #i28319# - 2004-04-27 - fs@openoffice.org
+ if ( !_bFirstTimeInit )
+ {
+ try
+ {
+ if ( !xSource.is() )
+ setPropertyValue( PROPERTY_STRINGITEMLIST, makeAny( Sequence< ::rtl::OUString >() ) );
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "OPropertyBrowserController::actuatingPropertyChanged( ListCellRange ): caught an exception while resetting the string items!" );
+ }
+ }
+ }
+ break; // case PROPERTY_ID_LIST_CELL_RANGE
+
+ // ----- DataField -----
+ case PROPERTY_ID_CONTROLSOURCE:
+ {
+ ::rtl::OUString sControlSource;
+ _rNewValue >>= sControlSource;
+ if ( impl_isSupportedProperty_nothrow( PROPERTY_ID_BOUND_CELL ) )
+ _rxInspectorUI->enablePropertyUI( PROPERTY_BOUND_CELL, sControlSource.getLength() == 0 );
+ }
+ break; // case PROPERTY_ID_CONTROLSOURCE
+
+ default:
+ DBG_ERROR( "CellBindingPropertyHandler::actuatingPropertyChanged: did not register for this property!" );
+ }
+
+ for ( ::std::vector< PropertyId >::const_iterator loopAffected = aDependentProperties.begin();
+ loopAffected != aDependentProperties.end();
+ ++loopAffected
+ )
+ {
+ impl_updateDependentProperty_nothrow( *loopAffected, _rxInspectorUI );
+ }
+ }
+
+ //--------------------------------------------------------------------
+ void CellBindingPropertyHandler::impl_updateDependentProperty_nothrow( PropertyId _nPropId, const Reference< XObjectInspectorUI >& _rxInspectorUI ) const
+ {
+ try
+ {
+ switch ( _nPropId )
+ {
+ // ----- BoundColumn -----
+ case PROPERTY_ID_BOUNDCOLUMN:
+ {
+ CellBindingPropertyHandler* pNonConstThis = const_cast< CellBindingPropertyHandler* >( this );
+ Reference< XValueBinding > xBinding( pNonConstThis->getPropertyValue( PROPERTY_BOUND_CELL ), UNO_QUERY );
+ Reference< XListEntrySource > xListSource( pNonConstThis->getPropertyValue( PROPERTY_LIST_CELL_RANGE ), UNO_QUERY );
+
+ if ( impl_isSupportedProperty_nothrow( PROPERTY_ID_BOUNDCOLUMN ) )
+ _rxInspectorUI->enablePropertyUI( PROPERTY_BOUNDCOLUMN, !xBinding.is() && !xListSource.is() );
+ }
+ break; // case PROPERTY_ID_BOUNDCOLUMN
+
+ } // switch
+
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "CellBindingPropertyHandler::impl_updateDependentProperty_nothrow: caught an exception!" );
+ }
+ }
+
+ //--------------------------------------------------------------------
+ Any SAL_CALL CellBindingPropertyHandler::getPropertyValue( const ::rtl::OUString& _rPropertyName ) throw (UnknownPropertyException, RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ PropertyId nPropId( impl_getPropertyId_throw( _rPropertyName ) );
+
+ OSL_ENSURE( m_pHelper.get(), "CellBindingPropertyHandler::getPropertyValue: inconsistency!" );
+ // if we survived impl_getPropertyId_throw, we should have a helper, since no helper implies no properties
+
+ Any aReturn;
+ switch ( nPropId )
+ {
+ case PROPERTY_ID_BOUND_CELL:
+ {
+ Reference< XValueBinding > xBinding( m_pHelper->getCurrentBinding() );
+ if ( !m_pHelper->isCellBinding( xBinding ) )
+ xBinding.clear();
+
+ aReturn <<= xBinding;
+ }
+ break;
+
+ case PROPERTY_ID_LIST_CELL_RANGE:
+ {
+ Reference< XListEntrySource > xSource( m_pHelper->getCurrentListSource() );
+ if ( !m_pHelper->isCellRangeListSource( xSource ) )
+ xSource.clear();
+
+ aReturn <<= xSource;
+ }
+ break;
+
+ case PROPERTY_ID_CELL_EXCHANGE_TYPE:
+ {
+ Reference< XValueBinding > xBinding( m_pHelper->getCurrentBinding() );
+ aReturn <<= (sal_Int16)( m_pHelper->isCellIntegerBinding( xBinding ) ? 1 : 0 );
+ }
+ break;
+
+ default:
+ DBG_ERROR( "CellBindingPropertyHandler::getPropertyValue: cannot handle this!" );
+ break;
+ }
+ return aReturn;
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL CellBindingPropertyHandler::setPropertyValue( const ::rtl::OUString& _rPropertyName, const Any& _rValue ) throw (UnknownPropertyException, RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ PropertyId nPropId( impl_getPropertyId_throw( _rPropertyName ) );
+
+ OSL_ENSURE( m_pHelper.get(), "CellBindingPropertyHandler::setPropertyValue: inconsistency!" );
+ // if we survived impl_getPropertyId_throw, we should have a helper, since no helper implies no properties
+
+ try
+ {
+ Any aOldValue = getPropertyValue( _rPropertyName );
+
+ switch ( nPropId )
+ {
+ case PROPERTY_ID_BOUND_CELL:
+ {
+ Reference< XValueBinding > xBinding;
+ _rValue >>= xBinding;
+ m_pHelper->setBinding( xBinding );
+ }
+ break;
+
+ case PROPERTY_ID_LIST_CELL_RANGE:
+ {
+ Reference< XListEntrySource > xSource;
+ _rValue >>= xSource;
+ m_pHelper->setListSource( xSource );
+ }
+ break;
+
+ case PROPERTY_ID_CELL_EXCHANGE_TYPE:
+ {
+ sal_Int16 nExchangeType = 0;
+ OSL_VERIFY( _rValue >>= nExchangeType );
+
+ Reference< XValueBinding > xBinding = m_pHelper->getCurrentBinding( );
+ if ( xBinding.is() )
+ {
+ sal_Bool bNeedIntegerBinding = ( nExchangeType == 1 );
+ if ( (bool)bNeedIntegerBinding != m_pHelper->isCellIntegerBinding( xBinding ) )
+ {
+ CellAddress aAddress;
+ if ( m_pHelper->getAddressFromCellBinding( xBinding, aAddress ) )
+ {
+ xBinding = m_pHelper->createCellBindingFromAddress( aAddress, bNeedIntegerBinding );
+ m_pHelper->setBinding( xBinding );
+ }
+ }
+ }
+ }
+ break;
+
+ default:
+ DBG_ERROR( "CellBindingPropertyHandler::setPropertyValue: cannot handle this!" );
+ break;
+ }
+
+ impl_setContextDocumentModified_nothrow();
+
+ Any aNewValue( getPropertyValue( _rPropertyName ) );
+ firePropertyChange( _rPropertyName, nPropId, aOldValue, aNewValue );
+ // TODO/UNOize: can't we make this a part of the base class, for all those "virtual"
+ // properties? Base class'es |setPropertyValue| could call some |doSetPropertyValue|,
+ // and handle the listener notification itself
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "CellBindingPropertyHandler::setPropertyValue: caught an exception!" );
+ }
+ }
+
+ //--------------------------------------------------------------------
+ Any SAL_CALL CellBindingPropertyHandler::convertToPropertyValue( const ::rtl::OUString& _rPropertyName, const Any& _rControlValue ) throw (UnknownPropertyException, RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ Any aPropertyValue;
+
+ OSL_ENSURE( m_pHelper.get(), "CellBindingPropertyHandler::convertToPropertyValue: we have no SupportedProperties!" );
+ if ( !m_pHelper.get() )
+ return aPropertyValue;
+
+ PropertyId nPropId( m_pInfoService->getPropertyId( _rPropertyName ) );
+
+ ::rtl::OUString sControlValue;
+ OSL_VERIFY( _rControlValue >>= sControlValue );
+ switch( nPropId )
+ {
+ case PROPERTY_ID_LIST_CELL_RANGE:
+ aPropertyValue <<= m_pHelper->createCellListSourceFromStringAddress( sControlValue );
+ break;
+
+ case PROPERTY_ID_BOUND_CELL:
+ {
+ // if we have the possibility of an integer binding, then we must preserve
+ // this property's value (e.g. if the current binding is an integer binding, then
+ // the newly created one must be, too)
+ bool bIntegerBinding = false;
+ if ( m_pHelper->isCellIntegerBindingAllowed() )
+ {
+ sal_Int16 nCurrentBindingType = 0;
+ getPropertyValue( PROPERTY_CELL_EXCHANGE_TYPE ) >>= nCurrentBindingType;
+ bIntegerBinding = ( nCurrentBindingType != 0 );
+ }
+ aPropertyValue <<= m_pHelper->createCellBindingFromStringAddress( sControlValue, bIntegerBinding );
+ }
+ break;
+
+ case PROPERTY_ID_CELL_EXCHANGE_TYPE:
+ m_pCellExchangeConverter->getValueFromDescription( sControlValue, aPropertyValue );
+ break;
+
+ default:
+ DBG_ERROR( "CellBindingPropertyHandler::convertToPropertyValue: cannot handle this!" );
+ break;
+ }
+
+ return aPropertyValue;
+ }
+
+ //--------------------------------------------------------------------
+ Any SAL_CALL CellBindingPropertyHandler::convertToControlValue( const ::rtl::OUString& _rPropertyName,
+ const Any& _rPropertyValue, const Type& /*_rControlValueType*/ ) throw (UnknownPropertyException, RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ Any aControlValue;
+
+ OSL_ENSURE( m_pHelper.get(), "CellBindingPropertyHandler::convertToControlValue: we have no SupportedProperties!" );
+ if ( !m_pHelper.get() )
+ return aControlValue;
+
+ PropertyId nPropId( m_pInfoService->getPropertyId( _rPropertyName ) );
+
+ switch ( nPropId )
+ {
+ case PROPERTY_ID_BOUND_CELL:
+ {
+ Reference< XValueBinding > xBinding;
+#if OSL_DEBUG_LEVEL > 0
+ sal_Bool bSuccess =
+#endif
+ _rPropertyValue >>= xBinding;
+ OSL_ENSURE( bSuccess, "CellBindingPropertyHandler::convertToControlValue: invalid value (1)!" );
+
+ // the only value binding we support so far is linking to spreadsheet cells
+ aControlValue <<= m_pHelper->getStringAddressFromCellBinding( xBinding );
+ }
+ break;
+
+ case PROPERTY_ID_LIST_CELL_RANGE:
+ {
+ Reference< XListEntrySource > xSource;
+#if OSL_DEBUG_LEVEL > 0
+ sal_Bool bSuccess =
+#endif
+ _rPropertyValue >>= xSource;
+ OSL_ENSURE( bSuccess, "CellBindingPropertyHandler::convertToControlValue: invalid value (2)!" );
+
+ // the only value binding we support so far is linking to spreadsheet cells
+ aControlValue <<= m_pHelper->getStringAddressFromCellListSource( xSource );
+ }
+ break;
+
+ case PROPERTY_ID_CELL_EXCHANGE_TYPE:
+ aControlValue <<= m_pCellExchangeConverter->getDescriptionForValue( _rPropertyValue );
+ break;
+
+ default:
+ DBG_ERROR( "CellBindingPropertyHandler::convertToControlValue: cannot handle this!" );
+ break;
+ }
+
+ return aControlValue;
+ }
+
+ //--------------------------------------------------------------------
+ Sequence< Property > SAL_CALL CellBindingPropertyHandler::doDescribeSupportedProperties() const
+ {
+ ::std::vector< Property > aProperties;
+
+ bool bAllowCellLinking = m_pHelper.get() && m_pHelper->isCellBindingAllowed();
+ bool bAllowCellIntLinking = m_pHelper.get() && m_pHelper->isCellIntegerBindingAllowed();
+ bool bAllowListCellRange = m_pHelper.get() && m_pHelper->isListCellRangeAllowed();
+ if ( bAllowCellLinking || bAllowListCellRange || bAllowCellIntLinking )
+ {
+ sal_Int32 nPos = ( bAllowCellLinking ? 1 : 0 )
+ + ( bAllowListCellRange ? 1 : 0 )
+ + ( bAllowCellIntLinking ? 1 : 0 );
+ aProperties.resize( nPos );
+
+ if ( bAllowCellLinking )
+ {
+ aProperties[ --nPos ] = Property( PROPERTY_BOUND_CELL, PROPERTY_ID_BOUND_CELL,
+ ::getCppuType( static_cast< ::rtl::OUString* >( NULL ) ), 0 );
+ }
+ if ( bAllowCellIntLinking )
+ {
+ aProperties[ --nPos ] = Property( PROPERTY_CELL_EXCHANGE_TYPE, PROPERTY_ID_CELL_EXCHANGE_TYPE,
+ ::getCppuType( static_cast< sal_Int16* >( NULL ) ), 0 );
+ }
+ if ( bAllowListCellRange )
+ {
+ aProperties[ --nPos ] = Property( PROPERTY_LIST_CELL_RANGE, PROPERTY_ID_LIST_CELL_RANGE,
+ ::getCppuType( static_cast< ::rtl::OUString* >( NULL ) ), 0 );
+ }
+ }
+
+ if ( aProperties.empty() )
+ return Sequence< Property >();
+ return Sequence< Property >( &(*aProperties.begin()), aProperties.size() );
+ }
+
+//........................................................................
+} // namespace pcr
+//........................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/propctrlr/cellbindinghandler.hxx b/extensions/source/propctrlr/cellbindinghandler.hxx
new file mode 100644
index 000000000000..e5e27f609879
--- /dev/null
+++ b/extensions/source/propctrlr/cellbindinghandler.hxx
@@ -0,0 +1,111 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef EXTENSIONS_SOURCE_PROPCTRLR_CELLBINDINGHANDLER_HXX
+#define EXTENSIONS_SOURCE_PROPCTRLR_CELLBINDINGHANDLER_HXX
+
+#include "propertyhandler.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+/** === end UNO includes === **/
+#include <rtl/ref.hxx>
+
+#include <memory>
+
+//........................................................................
+namespace pcr
+{
+//........................................................................
+
+ class CellBindingHelper;
+ class IPropertyEnumRepresentation;
+ //====================================================================
+ //= CellBindingPropertyHandler
+ //====================================================================
+ class CellBindingPropertyHandler;
+ typedef HandlerComponentBase< CellBindingPropertyHandler > CellBindingPropertyHandler_Base;
+ class CellBindingPropertyHandler : public CellBindingPropertyHandler_Base
+ {
+ private:
+ ::std::auto_ptr< CellBindingHelper > m_pHelper;
+ ::rtl::Reference< IPropertyEnumRepresentation > m_pCellExchangeConverter;
+
+ public:
+ CellBindingPropertyHandler(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _rxContext
+ );
+
+ static ::rtl::OUString SAL_CALL getImplementationName_static( ) throw (::com::sun::star::uno::RuntimeException);
+ static ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames_static( ) throw (::com::sun::star::uno::RuntimeException);
+
+ protected:
+ ~CellBindingPropertyHandler();
+
+ protected:
+ // XPropertyHandler overriables
+ virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue( const ::rtl::OUString& _rPropertyName ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setPropertyValue( const ::rtl::OUString& _rPropertyName, const ::com::sun::star::uno::Any& _rValue ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Any SAL_CALL convertToPropertyValue( const ::rtl::OUString& _rPropertyName, const ::com::sun::star::uno::Any& _rControlValue ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Any SAL_CALL convertToControlValue( const ::rtl::OUString& _rPropertyName, const ::com::sun::star::uno::Any& _rPropertyValue, const ::com::sun::star::uno::Type& _rControlValueType ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString >
+ SAL_CALL getActuatingProperties( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL actuatingPropertyChanged( const ::rtl::OUString& _rActuatingPropertyName, const ::com::sun::star::uno::Any& _rNewValue, const ::com::sun::star::uno::Any& _rOldValue, const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XObjectInspectorUI >& _rxInspectorUI, sal_Bool _bFirstTimeInit ) throw (::com::sun::star::lang::NullPointerException, ::com::sun::star::uno::RuntimeException);
+
+ // PropertyHandler overridables
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property >
+ SAL_CALL doDescribeSupportedProperties() const;
+ virtual void onNewComponent();
+
+ private:
+ /** updates a property (UI) whose state depends on more than one other property
+
+ ->actuatingPropertyChanged is called for certain properties in whose changes
+ we expressed interes (->getActuatingProperty). Now such a property change can
+ result in simple UI updates, for instance another property being enabled or disabled.
+
+ However, it can also result in a more complex change: The current (UI) state might
+ depend on the value of more than one other property. Those dependent properties (their
+ UI, more precisly) are updated in this method.
+
+ @param _nPropid
+ the ->PropertyId of the dependent property whose UI state is to be updated
+
+ @param _rxInspectorUI
+ provides access to the property browser UI. Must not be <NULL/>.
+ */
+ void impl_updateDependentProperty_nothrow( PropertyId _nPropId, const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XObjectInspectorUI >& _rxInspectorUI ) const;
+ };
+
+//........................................................................
+} // namespace pcr
+//........................................................................
+
+#endif // EXTENSIONS_SOURCE_PROPCTRLR_CELLBINDINGHANDLER_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/propctrlr/cellbindinghelper.cxx b/extensions/source/propctrlr/cellbindinghelper.cxx
new file mode 100644
index 000000000000..dc9abea4b5cb
--- /dev/null
+++ b/extensions/source/propctrlr/cellbindinghelper.cxx
@@ -0,0 +1,568 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+#include "cellbindinghelper.hxx"
+#include <com/sun/star/form/binding/XBindableValue.hpp>
+#include <com/sun/star/form/binding/XListEntrySink.hpp>
+#include <com/sun/star/form/FormComponentType.hpp>
+#include <com/sun/star/form/XGridColumnFactory.hpp>
+#include <com/sun/star/container/XChild.hpp>
+#include <com/sun/star/container/XNamed.hpp>
+#include <com/sun/star/drawing/XDrawPageSupplier.hpp>
+#include <com/sun/star/table/XCellRange.hpp>
+#include <com/sun/star/form/XFormsSupplier.hpp>
+#include <com/sun/star/form/XForm.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/beans/NamedValue.hpp>
+#include <com/sun/star/sheet/XSpreadsheet.hpp>
+#include <unotools/transliterationwrapper.hxx>
+#include <osl/diagnose.h>
+#include <tools/diagnose_ex.h>
+#include "formstrings.hxx"
+
+#include <functional>
+#include <algorithm>
+
+//............................................................................
+namespace pcr
+{
+//............................................................................
+
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::beans;
+ using namespace ::com::sun::star::frame;
+ using namespace ::com::sun::star::sheet;
+ using namespace ::com::sun::star::container;
+ using namespace ::com::sun::star::drawing;
+ using namespace ::com::sun::star::table;
+ using namespace ::com::sun::star::form;
+ using namespace ::com::sun::star::lang;
+ using namespace ::com::sun::star::i18n;
+ using namespace ::com::sun::star::form::binding;
+
+ namespace
+ {
+ //....................................................................
+ struct StringCompare : public ::std::unary_function< ::rtl::OUString, bool >
+ {
+ private:
+ ::rtl::OUString m_sReference;
+
+ public:
+ StringCompare( const ::rtl::OUString& _rReference ) : m_sReference( _rReference ) { }
+
+ inline bool operator()( const ::rtl::OUString& _rCompare )
+ {
+ return ( _rCompare == m_sReference ) ? true : false;
+ }
+ };
+ }
+
+ //========================================================================
+ //= CellBindingHelper
+ //========================================================================
+ //------------------------------------------------------------------------
+ CellBindingHelper::CellBindingHelper( const Reference< XPropertySet >& _rxControlModel, const Reference< XModel >& _rxContextDocument )
+ :m_xControlModel( _rxControlModel )
+ {
+ OSL_ENSURE( m_xControlModel.is(), "CellBindingHelper::CellBindingHelper: invalid control model!" );
+
+ m_xDocument = m_xDocument.query( _rxContextDocument );
+ OSL_ENSURE( m_xDocument.is(), "CellBindingHelper::CellBindingHelper: This is no spreadsheet document!" );
+
+ OSL_ENSURE( isSpreadsheetDocumentWhichSupplies( SERVICE_ADDRESS_CONVERSION ),
+ "CellBindingHelper::CellBindingHelper: the document cannot convert address representations!" );
+ }
+
+ //------------------------------------------------------------------------
+ sal_Bool CellBindingHelper::isSpreadsheetDocument( const Reference< XModel >& _rxContextDocument )
+ {
+ return Reference< XSpreadsheetDocument >::query( _rxContextDocument ).is();
+ }
+
+ //------------------------------------------------------------------------
+ sal_Int16 CellBindingHelper::getControlSheetIndex( Reference< XSpreadsheet >& _out_rxSheet ) const
+ {
+ sal_Int16 nSheetIndex = -1;
+ // every sheet has a draw page, and every draw page has a forms collection.
+ // Our control, OTOH, belongs to a forms collection. Match these ...
+ try
+ {
+ // for determining the draw page, we need the forms collection which
+ // the object belongs to. This is the first object up the hierarchy which is
+ // *no* XForm (and, well, no XGridColumnFactory)
+ Reference< XChild > xCheck( m_xControlModel, UNO_QUERY );
+ Reference< XForm > xParentAsForm; if ( xCheck.is() ) xParentAsForm = xParentAsForm.query( xCheck->getParent() );
+ Reference< XGridColumnFactory > xParentAsGrid; if ( xCheck.is() ) xParentAsGrid = xParentAsGrid.query( xCheck->getParent() );
+
+ while ( ( xParentAsForm.is() || xParentAsGrid.is() ) && xCheck.is() )
+ {
+ xCheck = xCheck.query( xCheck->getParent() );
+ xParentAsForm = xParentAsForm.query( xCheck.is() ? xCheck->getParent() : (Reference< XInterface >) Reference< XForm >() );
+ xParentAsGrid = xParentAsGrid.query( xCheck.is() ? xCheck->getParent() : (Reference< XInterface >) Reference< XGridColumnFactory >() );
+ }
+ Reference< XInterface > xFormsCollection( xCheck.is() ? xCheck->getParent() : Reference< XInterface >() );
+
+ // now iterate through the sheets
+ Reference< XIndexAccess > xSheets( m_xDocument->getSheets(), UNO_QUERY );
+ if ( xSheets.is() && xFormsCollection.is() )
+ {
+ for ( sal_Int32 i = 0; i < xSheets->getCount(); ++i )
+ {
+ Reference< XDrawPageSupplier > xSuppPage( xSheets->getByIndex( i ), UNO_QUERY_THROW );
+ Reference< XFormsSupplier > xSuppForms( xSuppPage->getDrawPage(), UNO_QUERY_THROW );
+
+ if ( xSuppForms->getForms() == xFormsCollection )
+ { // found it
+ nSheetIndex = (sal_Int16)i;
+ _out_rxSheet.set( xSuppPage, UNO_QUERY_THROW );
+ break;
+ }
+ }
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+ return nSheetIndex;
+ }
+
+ //------------------------------------------------------------------------
+ bool CellBindingHelper::convertStringAddress( const ::rtl::OUString& _rAddressDescription, CellAddress& /* [out] */ _rAddress ) const
+ {
+ Any aAddress;
+ return doConvertAddressRepresentations(
+ PROPERTY_UI_REPRESENTATION,
+ makeAny( _rAddressDescription ),
+ PROPERTY_ADDRESS,
+ aAddress,
+ false
+ )
+ && ( aAddress >>= _rAddress );
+ }
+
+ //------------------------------------------------------------------------
+ bool CellBindingHelper::doConvertAddressRepresentations( const ::rtl::OUString& _rInputProperty, const Any& _rInputValue,
+ const ::rtl::OUString& _rOutputProperty, Any& _rOutputValue, bool _bIsRange ) const SAL_THROW(())
+ {
+ bool bSuccess = false;
+
+ Reference< XPropertySet > xConverter(
+ createDocumentDependentInstance(
+ _bIsRange ? SERVICE_RANGEADDRESS_CONVERSION : SERVICE_ADDRESS_CONVERSION,
+ ::rtl::OUString(),
+ Any()
+ ),
+ UNO_QUERY
+ );
+ OSL_ENSURE( xConverter.is(), "CellBindingHelper::doConvertAddressRepresentations: could not get a converter service!" );
+ if ( xConverter.is() )
+ {
+ try
+ {
+ Reference< XSpreadsheet > xSheet;
+ xConverter->setPropertyValue( PROPERTY_REFERENCE_SHEET, makeAny( (sal_Int32)getControlSheetIndex( xSheet ) ) );
+ xConverter->setPropertyValue( _rInputProperty, _rInputValue );
+ _rOutputValue = xConverter->getPropertyValue( _rOutputProperty );
+ bSuccess = true;
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "CellBindingHelper::doConvertAddressRepresentations: caught an exception!" );
+ }
+ }
+
+ return bSuccess;
+ }
+
+ //------------------------------------------------------------------------
+ bool CellBindingHelper::convertStringAddress( const ::rtl::OUString& _rAddressDescription,
+ CellRangeAddress& /* [out] */ _rAddress ) const
+ {
+ Any aAddress;
+ return doConvertAddressRepresentations(
+ PROPERTY_UI_REPRESENTATION,
+ makeAny( _rAddressDescription ),
+ PROPERTY_ADDRESS,
+ aAddress,
+ true
+ )
+ && ( aAddress >>= _rAddress );
+ }
+
+ //------------------------------------------------------------------------
+ Reference< XValueBinding > CellBindingHelper::createCellBindingFromAddress( const CellAddress& _rAddress, bool _bSupportIntegerExchange ) const
+ {
+ Reference< XValueBinding > xBinding( createDocumentDependentInstance(
+ _bSupportIntegerExchange ? SERVICE_SHEET_CELL_INT_BINDING : SERVICE_SHEET_CELL_BINDING,
+ PROPERTY_BOUND_CELL,
+ makeAny( _rAddress )
+ ), UNO_QUERY );
+
+ return xBinding;
+ }
+
+ //------------------------------------------------------------------------
+ Reference< XValueBinding > CellBindingHelper::createCellBindingFromStringAddress( const ::rtl::OUString& _rAddress, bool _bSupportIntegerExchange ) const
+ {
+ Reference< XValueBinding > xBinding;
+ if ( !m_xDocument.is() )
+ // very bad ...
+ return xBinding;
+
+ // get the UNO representation of the address
+ CellAddress aAddress;
+ if ( !_rAddress.getLength() || !convertStringAddress( _rAddress, aAddress ) )
+ return xBinding;
+
+ return createCellBindingFromAddress( aAddress, _bSupportIntegerExchange );
+ }
+
+ //------------------------------------------------------------------------
+ Reference< XListEntrySource > CellBindingHelper::createCellListSourceFromStringAddress( const ::rtl::OUString& _rAddress ) const
+ {
+ Reference< XListEntrySource > xSource;
+
+ CellRangeAddress aRangeAddress;
+ if ( !_rAddress.getLength() || !convertStringAddress( _rAddress, aRangeAddress ) )
+ return xSource;
+
+ // create a range object for this address
+ xSource = xSource.query( createDocumentDependentInstance(
+ SERVICE_SHEET_CELLRANGE_LISTSOURCE,
+ PROPERTY_LIST_CELL_RANGE,
+ makeAny( aRangeAddress )
+ ) );
+
+ return xSource;
+ }
+
+ //------------------------------------------------------------------------
+ Reference< XInterface > CellBindingHelper::createDocumentDependentInstance( const ::rtl::OUString& _rService, const ::rtl::OUString& _rArgumentName,
+ const Any& _rArgumentValue ) const
+ {
+ Reference< XInterface > xReturn;
+
+ Reference< XMultiServiceFactory > xDocumentFactory( m_xDocument, UNO_QUERY );
+ OSL_ENSURE( xDocumentFactory.is(), "CellBindingHelper::createDocumentDependentInstance: no document service factory!" );
+ if ( xDocumentFactory.is() )
+ {
+ try
+ {
+ if ( _rArgumentName.getLength() )
+ {
+ NamedValue aArg;
+ aArg.Name = _rArgumentName;
+ aArg.Value = _rArgumentValue;
+
+ Sequence< Any > aArgs( 1 );
+ aArgs[ 0 ] <<= aArg;
+
+ xReturn = xDocumentFactory->createInstanceWithArguments( _rService, aArgs );
+ }
+ else
+ {
+ xReturn = xDocumentFactory->createInstance( _rService );
+ }
+ }
+ catch ( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "CellBindingHelper::createDocumentDependentInstance: could not create the binding at the document!" );
+ }
+ }
+ return xReturn;
+ }
+
+ //------------------------------------------------------------------------
+ bool CellBindingHelper::getAddressFromCellBinding(
+ const Reference< XValueBinding >& _rxBinding, CellAddress& _rAddress ) const
+ {
+ OSL_PRECOND( !_rxBinding.is() || isCellBinding( _rxBinding ), "CellBindingHelper::getAddressFromCellBinding: this is no cell binding!" );
+
+ bool bReturn = false;
+ if ( !m_xDocument.is() )
+ // very bad ...
+ return bReturn;
+
+ try
+ {
+ Reference< XPropertySet > xBindingProps( _rxBinding, UNO_QUERY );
+ OSL_ENSURE( xBindingProps.is() || !_rxBinding.is(), "CellBindingHelper::getAddressFromCellBinding: no property set for the binding!" );
+ if ( xBindingProps.is() )
+ {
+ CellAddress aAddress;
+ bReturn = (bool)( xBindingProps->getPropertyValue( PROPERTY_BOUND_CELL ) >>= _rAddress );
+ }
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "CellBindingHelper::getAddressFromCellBinding: caught an exception!" );
+ }
+
+ return bReturn;
+ }
+
+ //------------------------------------------------------------------------
+ ::rtl::OUString CellBindingHelper::getStringAddressFromCellBinding( const Reference< XValueBinding >& _rxBinding ) const
+ {
+ CellAddress aAddress;
+ ::rtl::OUString sAddress;
+ if ( getAddressFromCellBinding( _rxBinding, aAddress ) )
+ {
+ Any aStringAddress;
+ doConvertAddressRepresentations( PROPERTY_ADDRESS, makeAny( aAddress ),
+ PROPERTY_UI_REPRESENTATION, aStringAddress, false );
+
+ aStringAddress >>= sAddress;
+ }
+
+ return sAddress;
+ }
+
+ //------------------------------------------------------------------------
+ ::rtl::OUString CellBindingHelper::getStringAddressFromCellListSource( const Reference< XListEntrySource >& _rxSource ) const
+ {
+ OSL_PRECOND( !_rxSource.is() || isCellRangeListSource( _rxSource ), "CellBindingHelper::getStringAddressFromCellListSource: this is no cell list source!" );
+
+ ::rtl::OUString sAddress;
+ if ( !m_xDocument.is() )
+ // very bad ...
+ return sAddress;
+
+ try
+ {
+ Reference< XPropertySet > xSourceProps( _rxSource, UNO_QUERY );
+ OSL_ENSURE( xSourceProps.is() || !_rxSource.is(), "CellBindingHelper::getStringAddressFromCellListSource: no property set for the list source!" );
+ if ( xSourceProps.is() )
+ {
+ CellRangeAddress aRangeAddress;
+ xSourceProps->getPropertyValue( PROPERTY_LIST_CELL_RANGE ) >>= aRangeAddress;
+
+ Any aStringAddress;
+ doConvertAddressRepresentations( PROPERTY_ADDRESS, makeAny( aRangeAddress ),
+ PROPERTY_UI_REPRESENTATION, aStringAddress, true );
+ aStringAddress >>= sAddress;
+ }
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "CellBindingHelper::getStringAddressFromCellListSource: caught an exception!" );
+ }
+
+ return sAddress;
+ }
+
+ //------------------------------------------------------------------------
+ bool CellBindingHelper::isSpreadsheetDocumentWhichSupplies( const ::rtl::OUString& _rService ) const
+ {
+ bool bYesItIs = false;
+
+ Reference< XServiceInfo > xSI( m_xDocument, UNO_QUERY );
+ if ( xSI.is() && xSI->supportsService( SERVICE_SPREADSHEET_DOCUMENT ) )
+ {
+ Reference< XMultiServiceFactory > xDocumentFactory( m_xDocument, UNO_QUERY );
+ OSL_ENSURE( xDocumentFactory.is(), "CellBindingHelper::isSpreadsheetDocumentWhichSupplies: spreadsheet document, but no factory?" );
+
+ Sequence< ::rtl::OUString > aAvailableServices;
+ if ( xDocumentFactory.is() )
+ aAvailableServices = xDocumentFactory->getAvailableServiceNames( );
+
+ const ::rtl::OUString* pFound = ::std::find_if(
+ aAvailableServices.getConstArray(),
+ aAvailableServices.getConstArray() + aAvailableServices.getLength(),
+ StringCompare( _rService )
+ );
+ if ( pFound - aAvailableServices.getConstArray() < aAvailableServices.getLength() )
+ {
+ bYesItIs = true;
+ }
+ }
+
+ return bYesItIs;
+ }
+
+ //------------------------------------------------------------------------
+ bool CellBindingHelper::isListCellRangeAllowed( ) const
+ {
+ bool bAllow( false );
+
+ Reference< XListEntrySink > xSink( m_xControlModel, UNO_QUERY );
+ if ( xSink.is() )
+ {
+ bAllow = isSpreadsheetDocumentWhichSupplies( SERVICE_SHEET_CELLRANGE_LISTSOURCE );
+ }
+
+ return bAllow;
+ }
+
+ //------------------------------------------------------------------------
+ bool CellBindingHelper::isCellIntegerBindingAllowed( ) const
+ {
+ bool bAllow( true );
+
+ // first, we only offer this for controls which allow bindings in general
+ Reference< XBindableValue > xBindable( m_xControlModel, UNO_QUERY );
+ if ( !xBindable.is() )
+ bAllow = false;
+
+ // then, we must live in a spreadsheet document which can provide the special
+ // service needed for exchanging integer values
+ if ( bAllow )
+ bAllow = isSpreadsheetDocumentWhichSupplies( SERVICE_SHEET_CELL_INT_BINDING );
+
+ // then, we only offer this for list boxes
+ if ( bAllow )
+ {
+ try
+ {
+ sal_Int16 nClassId = FormComponentType::CONTROL;
+ m_xControlModel->getPropertyValue( PROPERTY_CLASSID ) >>= nClassId;
+ if ( FormComponentType::LISTBOX != nClassId )
+ bAllow = false;
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "CellBindingHelper::isCellIntegerBindingAllowed: caught an exception!" );
+ // are there really control models which survive isCellBindingAllowed, but don't have a ClassId
+ // property?
+ bAllow = false;
+ }
+ }
+
+ return bAllow;
+ }
+
+ //------------------------------------------------------------------------
+ bool CellBindingHelper::isCellBindingAllowed( ) const
+ {
+ bool bAllow( false );
+
+ Reference< XBindableValue > xBindable( m_xControlModel, UNO_QUERY );
+ if ( xBindable.is() )
+ {
+ // the control can potentially be bound to an external value
+ // Does it live within a Calc document, and is able to supply CellBindings?
+ bAllow = isSpreadsheetDocumentWhichSupplies( SERVICE_SHEET_CELL_BINDING );
+ }
+
+ // disallow for some types
+ // TODO: shouldn't the XBindableValue supply a list of supported types, and we can distingusih
+ // using this list? The current behavior below is somewhat hackish ...
+ if ( bAllow )
+ {
+ try
+ {
+ sal_Int16 nClassId = FormComponentType::CONTROL;
+ m_xControlModel->getPropertyValue( PROPERTY_CLASSID ) >>= nClassId;
+ if ( ( FormComponentType::DATEFIELD == nClassId ) || ( FormComponentType::TIMEFIELD == nClassId ) )
+ bAllow = false;
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "CellBindingHelper::isCellBindingAllowed: caught an exception!" );
+ bAllow = false;
+ }
+ }
+ return bAllow;
+ }
+
+ //------------------------------------------------------------------------
+ bool CellBindingHelper::isCellBinding( const Reference< XValueBinding >& _rxBinding ) const
+ {
+ return doesComponentSupport( _rxBinding.get(), SERVICE_SHEET_CELL_BINDING );
+ }
+
+ //------------------------------------------------------------------------
+ bool CellBindingHelper::isCellIntegerBinding( const Reference< XValueBinding >& _rxBinding ) const
+ {
+ return doesComponentSupport( _rxBinding.get(), SERVICE_SHEET_CELL_INT_BINDING );
+ }
+
+ //------------------------------------------------------------------------
+ bool CellBindingHelper::isCellRangeListSource( const Reference< XListEntrySource >& _rxSource ) const
+ {
+ return doesComponentSupport( _rxSource.get(), SERVICE_SHEET_CELLRANGE_LISTSOURCE );
+ }
+
+ //------------------------------------------------------------------------
+ bool CellBindingHelper::doesComponentSupport( const Reference< XInterface >& _rxComponent, const ::rtl::OUString& _rService ) const
+ {
+ bool bDoes = false;
+ Reference< XServiceInfo > xSI( _rxComponent, UNO_QUERY );
+ bDoes = xSI.is() && xSI->supportsService( _rService );
+ return bDoes;
+ }
+
+ //------------------------------------------------------------------------
+ Reference< XValueBinding > CellBindingHelper::getCurrentBinding( ) const
+ {
+ Reference< XValueBinding > xBinding;
+ Reference< XBindableValue > xBindable( m_xControlModel, UNO_QUERY );
+ if ( xBindable.is() )
+ xBinding = xBindable->getValueBinding();
+ return xBinding;
+ }
+
+ //------------------------------------------------------------------------
+ Reference< XListEntrySource > CellBindingHelper::getCurrentListSource( ) const
+ {
+ Reference< XListEntrySource > xSource;
+ Reference< XListEntrySink > xSink( m_xControlModel, UNO_QUERY );
+ if ( xSink.is() )
+ xSource = xSink->getListEntrySource();
+ return xSource;
+ }
+
+ //------------------------------------------------------------------------
+ void CellBindingHelper::setBinding( const Reference< XValueBinding >& _rxBinding )
+ {
+ Reference< XBindableValue > xBindable( m_xControlModel, UNO_QUERY );
+ OSL_PRECOND( xBindable.is(), "CellBindingHelper::setBinding: the object is not bindable!" );
+ if ( xBindable.is() )
+ xBindable->setValueBinding( _rxBinding );
+ }
+
+ //------------------------------------------------------------------------
+ void CellBindingHelper::setListSource( const Reference< XListEntrySource >& _rxSource )
+ {
+ Reference< XListEntrySink > xSink( m_xControlModel, UNO_QUERY );
+ OSL_PRECOND( xSink.is(), "CellBindingHelper::setListSource: the object is no list entry sink!" );
+ if ( xSink.is() )
+ xSink->setListEntrySource( _rxSource );
+ }
+
+//............................................................................
+} // namespace pcr
+//............................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/propctrlr/cellbindinghelper.hxx b/extensions/source/propctrlr/cellbindinghelper.hxx
new file mode 100644
index 000000000000..8fe262b165fc
--- /dev/null
+++ b/extensions/source/propctrlr/cellbindinghelper.hxx
@@ -0,0 +1,293 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef EXTENSIONS_PROPCTRLR_CELLBINDINGHELPER_HXX
+#define EXTENSIONS_PROPCTRLR_CELLBINDINGHELPER_HXX
+
+/** === begin UNO includes === **/
+#include <com/sun/star/frame/XModel.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
+#include <com/sun/star/table/CellAddress.hpp>
+#include <com/sun/star/table/CellRangeAddress.hpp>
+#include <com/sun/star/form/binding/XValueBinding.hpp>
+#include <com/sun/star/form/binding/XListEntrySource.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/sheet/XSpreadsheet.hpp>
+/** === end UNO includes === **/
+
+//............................................................................
+namespace pcr
+{
+//............................................................................
+
+ //========================================================================
+ //= CellBindingHelper
+ //========================================================================
+ /** encapsulates functionality related to binding a form control to a spreadsheet cell
+ */
+ class CellBindingHelper
+ {
+ protected:
+ ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >
+ m_xControlModel; // the model we work for
+ ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XSpreadsheetDocument >
+ m_xDocument; // the document where the model lives
+
+ public:
+ /** ctor
+ @param _rxControlModel
+ the control model which is or will be bound
+ */
+ CellBindingHelper(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxControlModel,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& _rxContextDocument
+ );
+
+ public:
+ /** determines whether the given model is a spreadsheet document model
+
+ <p>If this method returns <FALSE/>, you cannot instantiate a CellBindingHelper with
+ the document, since then no of it's functionality will be available.</p>
+ */
+ static sal_Bool isSpreadsheetDocument(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& _rxContextDocument
+ );
+
+ /** gets a cell binding for the given address
+ @precond
+ isCellBindingAllowed returns <TRUE/>
+ */
+ ::com::sun::star::uno::Reference< ::com::sun::star::form::binding::XValueBinding >
+ createCellBindingFromStringAddress(
+ const ::rtl::OUString& _rAddress,
+ bool _bSupportIntegerExchange = false
+ ) const;
+
+ /** creates a cell binding (supporting integer exchange, if requested) for
+ the given address object
+ */
+ ::com::sun::star::uno::Reference< ::com::sun::star::form::binding::XValueBinding >
+ createCellBindingFromAddress(
+ const ::com::sun::star::table::CellAddress& _rAddress,
+ bool _bSupportIntegerExchange = false
+ ) const;
+
+ /** gets a cell range list source binding for the given address
+ */
+ ::com::sun::star::uno::Reference< ::com::sun::star::form::binding::XListEntrySource >
+ createCellListSourceFromStringAddress( const ::rtl::OUString& _rAddress ) const;
+
+ /** creates a string representation for the given value binding's address
+
+ <p>If the sheet of the bound cell is the same as the sheet which our control belongs
+ to, then the sheet name is omitted in the resulting string representation.</p>
+
+ @precond
+ The binding is a valid cell binding, or <NULL/>
+ @see isCellBinding
+ */
+ ::rtl::OUString getStringAddressFromCellBinding(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::form::binding::XValueBinding >& _rxBinding
+ ) const;
+
+ /** creates an address object for the given value binding's address
+
+ @precond
+ The binding is a valid cell binding, or <NULL/>
+ @return
+ <FALSE/> if and only if an error occured and no valid address could be obtained
+ @see isCellBinding
+ */
+ bool getAddressFromCellBinding(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::form::binding::XValueBinding >& _rxBinding,
+ ::com::sun::star::table::CellAddress& _rAddress
+ ) const;
+
+ /** creates a string representation for the given list source's range address
+
+ <p>If the sheet of the cell range which acts as list source is the same as the
+ sheet which our control belongs to, then the sheet name is omitted in the
+ resulting string representation.</p>
+
+ @precond
+ The object is a valid cell range list source, or <NULL/>
+ @see isCellRangeListSource
+ */
+ ::rtl::OUString getStringAddressFromCellListSource(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::form::binding::XListEntrySource >& _rxSource
+ ) const;
+
+ /** returns the current binding of our control model, if any.
+ */
+ ::com::sun::star::uno::Reference< ::com::sun::star::form::binding::XValueBinding >
+ getCurrentBinding( ) const;
+
+ /** returns the current external list source of the control model, if any
+ */
+ ::com::sun::star::uno::Reference< ::com::sun::star::form::binding::XListEntrySource >
+ getCurrentListSource( ) const;
+
+ /** sets a new binding for our control model
+ @precond
+ the control model is bindable (which is implied by <member>isCellBindingAllowed</member>
+ returning <TRUE/>)
+ */
+ void setBinding(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::form::binding::XValueBinding >& _rxBinding
+ );
+
+ /** sets a list source for our control model
+ @precond
+ the control model is a list sink (which is implied by <member>isListCellRangeAllowed</member>
+ returning <TRUE/>)
+ */
+ void setListSource(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::form::binding::XListEntrySource >& _rxSource
+ );
+
+ /** checks whether it's possible to bind the control model to a spreadsheet cell
+ */
+ bool isCellBindingAllowed( ) const;
+
+ /** checks whether it's possible to bind the control model to a spreadsheet cell,
+ with exchanging integer values
+ */
+ bool isCellIntegerBindingAllowed( ) const;
+
+ /** checks whether it's possible to bind the control model to range of spreadsheet cells
+ supplying the list entries
+ */
+ bool isListCellRangeAllowed( ) const;
+
+ /** checks whether a given binding is a spreadsheet cell binding
+ */
+ bool isCellBinding(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::form::binding::XValueBinding >& _rxBinding
+ ) const;
+
+ /** checks whether a given binding is a spreadsheet cell binding, exchanging
+ integer values
+ */
+ bool isCellIntegerBinding(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::form::binding::XValueBinding >& _rxBinding
+ ) const;
+
+ /** checks whether a given list source is a spreadsheet cell list source
+ */
+ bool isCellRangeListSource(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::form::binding::XListEntrySource >& _rxSource
+ ) const;
+
+ /** retrieves the index of the sheet which our control belongs to
+ @return the index of the sheet which our control belongs to or -1, if an error occured
+ */
+ sal_Int16 getControlSheetIndex(
+ ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XSpreadsheet >& _out_rxSheet
+ ) const;
+
+ protected:
+ /** creates an address object from a string representation of a cell address
+ */
+ bool convertStringAddress(
+ const ::rtl::OUString& _rAddressDescription,
+ ::com::sun::star::table::CellAddress& /* [out] */ _rAddress
+ ) const;
+
+ /** creates an address range object from a string representation of a cell range address
+ */
+ bool convertStringAddress(
+ const ::rtl::OUString& _rAddressDescription,
+ ::com::sun::star::table::CellRangeAddress& /* [out] */ _rAddress
+ ) const;
+
+ /** determines if our document is a spreadsheet document, *and* can supply
+ the given service
+ */
+ bool isSpreadsheetDocumentWhichSupplies( const ::rtl::OUString& _rService ) const;
+
+ /** checkes whether a given component supports a given servive
+ */
+ bool doesComponentSupport(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxComponent,
+ const ::rtl::OUString& _rService
+ ) const;
+
+ /** uses the document (it's factory interface, respectively) to create a component instance
+ @param _rService
+ the service name
+ @param _rArgumentName
+ the name of the single argument to pass during creation. May be empty, in this case
+ no arguments are passed
+ @param _rArgumentValue
+ the value of the instantiation argument. Not evaluated if <arg>_rArgumentName</arg>
+ is empty.
+ */
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >
+ createDocumentDependentInstance(
+ const ::rtl::OUString& _rService,
+ const ::rtl::OUString& _rArgumentName,
+ const ::com::sun::star::uno::Any& _rArgumentValue
+ ) const;
+
+ /** converts an address representation into another one
+
+ @param _rInputProperty
+ the input property name for the conversion service
+ @param _rInputValue
+ the input property value for the conversion service
+ @param _rOutputProperty
+ the output property name for the conversion service
+ @param _rOutputValue
+ the output property value for the conversion service
+ @param _bIsRange
+ if <TRUE/>, the RangeAddressConversion service will be used, else
+ the AddressConversion service
+
+ @return
+ <TRUE/> if any only if the conversion was successfull
+
+ @see com::sun::star::table::CellAddressConversion
+ @see com::sun::star::table::CellRangeAddressConversion
+ */
+ bool doConvertAddressRepresentations(
+ const ::rtl::OUString& _rInputProperty,
+ const ::com::sun::star::uno::Any& _rInputValue,
+ const ::rtl::OUString& _rOutputProperty,
+ ::com::sun::star::uno::Any& _rOutputValue,
+ bool _bIsRange
+ ) const SAL_THROW(());
+ };
+
+//............................................................................
+} // namespace pcr
+//............................................................................
+
+#endif // EXTENSIONS_PROPCTRLR_CELLBINDINGHELPER_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/propctrlr/commoncontrol.cxx b/extensions/source/propctrlr/commoncontrol.cxx
new file mode 100644
index 000000000000..f532fe25c88b
--- /dev/null
+++ b/extensions/source/propctrlr/commoncontrol.cxx
@@ -0,0 +1,208 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+#include "commoncontrol.hxx"
+#include "pcrcommon.hxx"
+#include <tools/debug.hxx>
+#include <tools/diagnose_ex.h>
+#include <vcl/combobox.hxx>
+#include <toolkit/helper/vclunohelper.hxx>
+
+//............................................................................
+namespace pcr
+{
+//............................................................................
+
+ /** === begin UNO using === **/
+ using ::com::sun::star::uno::RuntimeException;
+ using ::com::sun::star::uno::Reference;
+ using ::com::sun::star::inspection::XPropertyControlContext;
+ using ::com::sun::star::awt::XWindow;
+ using ::com::sun::star::uno::Exception;
+ using ::com::sun::star::inspection::XPropertyControl;
+ /** === end UNO using === **/
+
+ //==================================================================
+ //= ControlHelper
+ //==================================================================
+ //------------------------------------------------------------------
+ ControlHelper::ControlHelper( Window* _pControlWindow, sal_Int16 _nControlType, XPropertyControl& _rAntiImpl, IModifyListener* _pModifyListener )
+ :m_pControlWindow( _pControlWindow )
+ ,m_nControlType( _nControlType )
+ ,m_rAntiImpl( _rAntiImpl )
+ ,m_pModifyListener( _pModifyListener )
+ ,m_bModified( sal_False )
+ {
+ DBG_ASSERT( m_pControlWindow != NULL, "ControlHelper::ControlHelper: invalid window!" );
+ }
+
+ //------------------------------------------------------------------
+ ControlHelper::~ControlHelper()
+ {
+ }
+
+ //--------------------------------------------------------------------
+ ::sal_Int16 SAL_CALL ControlHelper::getControlType() throw (RuntimeException)
+ {
+ return m_nControlType;
+ }
+
+ //--------------------------------------------------------------------
+ Reference< XPropertyControlContext > SAL_CALL ControlHelper::getControlContext() throw (RuntimeException)
+ {
+ return m_xContext;
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL ControlHelper::setControlContext( const Reference< XPropertyControlContext >& _controlcontext ) throw (RuntimeException)
+ {
+ m_xContext = _controlcontext;
+ }
+
+ //--------------------------------------------------------------------
+ Reference< XWindow > SAL_CALL ControlHelper::getControlWindow() throw (RuntimeException)
+ {
+ return VCLUnoHelper::GetInterface( m_pControlWindow );
+ }
+
+ //--------------------------------------------------------------------
+ ::sal_Bool SAL_CALL ControlHelper::isModified( ) throw (RuntimeException)
+ {
+ return m_bModified;
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL ControlHelper::notifyModifiedValue( ) throw (RuntimeException)
+ {
+ if ( isModified() && m_xContext.is() )
+ {
+ try
+ {
+ m_xContext->valueChanged( &m_rAntiImpl );
+ m_bModified = sal_False;
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+ }
+
+ //------------------------------------------------------------------
+ void SAL_CALL ControlHelper::dispose()
+ {
+ DELETEZ( m_pControlWindow );
+ }
+
+ //------------------------------------------------------------------
+ void ControlHelper::autoSizeWindow()
+ {
+ OSL_PRECOND( m_pControlWindow, "ControlHelper::autoSizeWindow: no window!" );
+ if ( !m_pControlWindow )
+ return;
+
+ ComboBox aComboBox(m_pControlWindow, WB_DROPDOWN);
+ aComboBox.SetPosSizePixel(Point(0,0), Size(100,100));
+ m_pControlWindow->SetSizePixel(aComboBox.GetSizePixel());
+
+ // TODO/UNOize: why do the controls this themselves? Shouldn't this be the task
+ // of the the browser listbox/line?
+ }
+
+ //------------------------------------------------------------------
+ void ControlHelper::impl_activateNextControl_nothrow() const
+ {
+ try
+ {
+ if ( m_xContext.is() )
+ m_xContext->activateNextControl( const_cast< XPropertyControl* >( &m_rAntiImpl ) );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+
+ //------------------------------------------------------------------
+ bool ControlHelper::handlePreNotify(NotifyEvent& rNEvt)
+ {
+ if (EVENT_KEYINPUT == rNEvt.GetType())
+ {
+ const KeyCode& aKeyCode = rNEvt.GetKeyEvent()->GetKeyCode();
+ sal_uInt16 nKey = aKeyCode.GetCode();
+
+ if (nKey == KEY_RETURN && !aKeyCode.IsShift())
+ {
+ LoseFocusHdl(m_pControlWindow);
+ impl_activateNextControl_nothrow();
+ return true;
+ }
+ }
+ return false;
+ }
+
+ //------------------------------------------------------------------
+ IMPL_LINK( ControlHelper, ModifiedHdl, Window*, /*_pWin*/ )
+ {
+ if ( m_pModifyListener )
+ m_pModifyListener->modified();
+ return 0;
+ }
+
+ //------------------------------------------------------------------
+ IMPL_LINK( ControlHelper, GetFocusHdl, Window*, /*_pWin*/ )
+ {
+ try
+ {
+ if ( m_xContext.is() )
+ m_xContext->focusGained( &m_rAntiImpl );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ return 0;
+ }
+
+ //------------------------------------------------------------------
+ IMPL_LINK( ControlHelper, LoseFocusHdl, Window*, /*_pWin*/ )
+ {
+ // TODO/UNOize: should this be outside the default control's implementations? If somebody
+ // has an own control implementation, which does *not* do this - would this be allowed?
+ // If not, then we must move this logic out of here.
+ notifyModifiedValue();
+ return 0;
+ }
+
+//............................................................................
+} // namespace pcr
+//............................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/propctrlr/commoncontrol.hxx b/extensions/source/propctrlr/commoncontrol.hxx
new file mode 100644
index 000000000000..6c834e9773ad
--- /dev/null
+++ b/extensions/source/propctrlr/commoncontrol.hxx
@@ -0,0 +1,339 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _EXTENSIONS_PROPCTRLR_COMMONCONTROL_HXX_
+#define _EXTENSIONS_PROPCTRLR_COMMONCONTROL_HXX_
+
+/** === begin UNO includes === **/
+#include <com/sun/star/inspection/XPropertyControl.hpp>
+#include <com/sun/star/lang/DisposedException.hpp>
+/** === end UNO includes === **/
+#include <cppuhelper/compbase1.hxx>
+#include <comphelper/broadcasthelper.hxx>
+#include <tools/link.hxx>
+#include <vcl/window.hxx>
+
+class NotifyEvent;
+//............................................................................
+namespace pcr
+{
+//............................................................................
+
+ class ControlHelper;
+ //========================================================================
+ //= ControlWindow
+ //========================================================================
+ template< class WINDOW >
+ class ControlWindow : public WINDOW
+ {
+ protected:
+ typedef WINDOW WindowType;
+
+ protected:
+ ControlHelper* m_pHelper;
+
+ public:
+ ControlWindow( Window* _pParent, WinBits _nStyle )
+ :WindowType( _pParent, _nStyle )
+ ,m_pHelper( NULL )
+ {
+ }
+
+ /// sets a ControlHelper instance which some functionality is delegated to
+ inline virtual void setControlHelper( ControlHelper& _rControlHelper );
+
+ protected:
+ // Window overridables
+ inline virtual long PreNotify( NotifyEvent& rNEvt );
+ };
+
+ //========================================================================
+ //= IModifyListener
+ //========================================================================
+ class SAL_NO_VTABLE IModifyListener
+ {
+ public:
+ virtual void modified() = 0;
+ };
+
+ //========================================================================
+ //= ControlHelper
+ //========================================================================
+ /** A helper class for implementing the <type scope="com::sun::star::inspection">XPropertyControl</type>
+ or one of its derived interfaces.
+
+ This class is intended to be held as member of another class which implements the
+ <type scope="com::sun::star::inspection">XPropertyControl</type> interface. The pointer
+ to this interface is to be passed to the ctor.
+ */
+ class ControlHelper
+ {
+ private:
+ Window* m_pControlWindow;
+ sal_Int16 m_nControlType;
+ ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyControlContext >
+ m_xContext;
+ ::com::sun::star::inspection::XPropertyControl&
+ m_rAntiImpl;
+ IModifyListener* m_pModifyListener;
+ sal_Bool m_bModified;
+
+ public:
+ /** creates the instance
+ @param _rControlWindow
+ the window which is associated with the <type scope="com::sun::star::inspection">XPropertyControl</type>.
+ Must not be <NULL/>.<br/>
+ Ownership for this window is taken by the ControlHelper - it will be deleted in <member>disposing</member>.
+ @param _nControlType
+ the type of the control - one of the <type scope="com::sun::star::inspection">PropertyControlType</type>
+ constants
+ @param _pAntiImpl
+ Reference to the instance as whose "impl-class" we act. This reference is held during lifetime
+ of the <type>ControlHelper</type> class, within acquiring it. Thus, the owner of the
+ <type>ControlHelper</type> is responsible for assuring the lifetime of the instance
+ pointed to by <arg>_pAntiImpl</arg>.
+ @param _pModifyListener
+ a listener to be modfied when the user modified the control's value. the
+ <member>IModifyListener::modified</member> of this listener is called from within our
+ ModifiedHdl. A default implementation of <member>IModifyListener::modified</member>
+ would just call our <member>setModified</member>.
+ */
+ ControlHelper(
+ Window* _pControlWindow,
+ sal_Int16 _nControlType,
+ ::com::sun::star::inspection::XPropertyControl& _rAntiImpl,
+ IModifyListener* _pModifyListener );
+
+ virtual ~ControlHelper();
+
+ /** sets our "modified" flag to <TRUE/>
+ */
+ inline void setModified() { m_bModified = sal_True; }
+ inline Window* getVclControlWindow() { return m_pControlWindow; }
+ inline const Window* getVclControlWindow() const { return m_pControlWindow; }
+
+ public:
+ // XPropertyControl
+ ::sal_Int16 SAL_CALL getControlType() throw (::com::sun::star::uno::RuntimeException);
+ ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyControlContext > SAL_CALL getControlContext() throw (::com::sun::star::uno::RuntimeException);
+ void SAL_CALL setControlContext( const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyControlContext >& _controlcontext ) throw (::com::sun::star::uno::RuntimeException);
+ ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > SAL_CALL getControlWindow() throw (::com::sun::star::uno::RuntimeException);
+ ::sal_Bool SAL_CALL isModified( ) throw (::com::sun::star::uno::RuntimeException);
+ void SAL_CALL notifyModifiedValue( ) throw (::com::sun::star::uno::RuntimeException);
+
+ // XComponent
+ virtual void SAL_CALL dispose();
+
+ /** (fail-safe) wrapper around calling our context's activateNextControl
+ */
+ inline void activateNextControl() const { impl_activateNextControl_nothrow(); }
+
+ public:
+ /// may be used to implement the default handling in PreNotify; returns sal_True if handled
+ bool handlePreNotify(NotifyEvent& _rNEvt);
+
+ /// automatically size the window given in the ctor
+ void autoSizeWindow();
+
+ /// may be used by derived classes, they forward the event to the PropCtrListener
+ DECL_LINK( ModifiedHdl, Window* );
+ DECL_LINK( GetFocusHdl, Window* );
+ DECL_LINK( LoseFocusHdl, Window* );
+
+ private:
+ /** fail-safe wrapper around calling our context's activateNextControl
+ */
+ void impl_activateNextControl_nothrow() const;
+ };
+
+ //========================================================================
+ //= CommonBehaviourControl
+ //========================================================================
+ /** implements a base class for <type scope="com::sun::star::inspection">XPropertyControl</type>
+ implementations, which delegates the generic functionality of this interface to a
+ <type>ControlHelper</type> member.
+
+ @param CONTROL_INTERFACE
+ an interface class which is derived from (or identical to) <type scope="com::sun::star::inspection">XPropertyControl</type>
+ @param CONTROL_WINDOW
+ a class which is derived from ControlWindow
+ */
+ template < class CONTROL_INTERFACE, class CONTROL_WINDOW >
+ class CommonBehaviourControl :public ::comphelper::OBaseMutex
+ ,public ::cppu::WeakComponentImplHelper1< CONTROL_INTERFACE >
+ ,public IModifyListener
+ {
+ protected:
+ typedef CONTROL_INTERFACE InterfaceType;
+ typedef CONTROL_WINDOW WindowType;
+
+ typedef ::comphelper::OBaseMutex MutexBaseClass;
+ typedef ::cppu::WeakComponentImplHelper1< CONTROL_INTERFACE > ComponentBaseClass;
+
+ protected:
+ ControlHelper m_aImplControl;
+
+ protected:
+ inline CommonBehaviourControl( sal_Int16 _nControlType, Window* _pParentWindow, WinBits _nWindowStyle, bool _bDoSetHandlers = true );
+
+ // XPropertyControl - delegated to ->m_aImplControl
+ inline ::sal_Int16 SAL_CALL getControlType() throw (::com::sun::star::uno::RuntimeException);
+ inline ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyControlContext > SAL_CALL getControlContext() throw (::com::sun::star::uno::RuntimeException);
+ inline void SAL_CALL setControlContext( const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyControlContext >& _controlcontext ) throw (::com::sun::star::uno::RuntimeException);
+ inline ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > SAL_CALL getControlWindow() throw (::com::sun::star::uno::RuntimeException);
+ inline ::sal_Bool SAL_CALL isModified( ) throw (::com::sun::star::uno::RuntimeException);
+ inline void SAL_CALL notifyModifiedValue( ) throw (::com::sun::star::uno::RuntimeException);
+
+ // XComponent
+ inline virtual void SAL_CALL disposing();
+
+ // IModifyListener
+ inline virtual void modified();
+
+ /// returns a typed pointer to our control window
+ WindowType* getTypedControlWindow() { return static_cast< WindowType* > ( m_aImplControl.getVclControlWindow() ); }
+ const WindowType* getTypedControlWindow() const { return static_cast< const WindowType* >( m_aImplControl.getVclControlWindow() ); }
+
+ protected:
+ /** checks whether the instance is already disposed
+ @throws DisposedException
+ if the instance is already disposed
+ */
+ inline void impl_checkDisposed_throw();
+ };
+
+ //========================================================================
+ //= ControlWindow - implementation
+ //========================================================================
+ //------------------------------------------------------------------------
+ template< class WINDOW >
+ inline void ControlWindow< WINDOW >::setControlHelper( ControlHelper& _rControlHelper )
+ {
+ m_pHelper = &_rControlHelper;
+ }
+
+ //------------------------------------------------------------------------
+ template< class WINDOW >
+ inline long ControlWindow< WINDOW >::PreNotify( NotifyEvent& rNEvt )
+ {
+ if ( m_pHelper && m_pHelper->handlePreNotify( rNEvt ) )
+ return 1;
+ return WindowType::PreNotify( rNEvt );
+ }
+
+ //========================================================================
+ //= CommonBehaviourControl - implementation
+ //========================================================================
+ //------------------------------------------------------------------------
+ template< class CONTROL_INTERFACE, class CONTROL_WINDOW >
+ inline CommonBehaviourControl< CONTROL_INTERFACE, CONTROL_WINDOW >::CommonBehaviourControl ( sal_Int16 _nControlType, Window* _pParentWindow, WinBits _nWindowStyle, bool _bDoSetHandlers )
+ :ComponentBaseClass( m_aMutex )
+ ,m_aImplControl( new WindowType( _pParentWindow, _nWindowStyle ), _nControlType, *this, this )
+ {
+ WindowType* pControlWindow( getTypedControlWindow() );
+ pControlWindow->setControlHelper( m_aImplControl );
+ if ( _bDoSetHandlers )
+ {
+ pControlWindow->SetModifyHdl( LINK( &m_aImplControl, ControlHelper, ModifiedHdl ) );
+ pControlWindow->SetGetFocusHdl( LINK( &m_aImplControl, ControlHelper, GetFocusHdl ) );
+ pControlWindow->SetLoseFocusHdl( LINK( &m_aImplControl, ControlHelper, LoseFocusHdl ) );
+ }
+ m_aImplControl.autoSizeWindow();
+ }
+
+ //--------------------------------------------------------------------
+ template< class CONTROL_INTERFACE, class CONTROL_WINDOW >
+ inline ::sal_Int16 SAL_CALL CommonBehaviourControl< CONTROL_INTERFACE, CONTROL_WINDOW >::getControlType() throw (::com::sun::star::uno::RuntimeException)
+ {
+ return m_aImplControl.getControlType();
+ }
+
+ //--------------------------------------------------------------------
+ template< class CONTROL_INTERFACE, class CONTROL_WINDOW >
+ inline ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyControlContext > SAL_CALL CommonBehaviourControl< CONTROL_INTERFACE, CONTROL_WINDOW >::getControlContext() throw (::com::sun::star::uno::RuntimeException)
+ {
+ return m_aImplControl.getControlContext();
+ }
+
+ //--------------------------------------------------------------------
+ template< class CONTROL_INTERFACE, class CONTROL_WINDOW >
+ inline void SAL_CALL CommonBehaviourControl< CONTROL_INTERFACE, CONTROL_WINDOW >::setControlContext( const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyControlContext >& _controlcontext ) throw (::com::sun::star::uno::RuntimeException)
+ {
+ m_aImplControl.setControlContext( _controlcontext );
+ }
+
+ //--------------------------------------------------------------------
+ template< class CONTROL_INTERFACE, class CONTROL_WINDOW >
+ inline ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > SAL_CALL CommonBehaviourControl< CONTROL_INTERFACE, CONTROL_WINDOW >::getControlWindow() throw (::com::sun::star::uno::RuntimeException)
+ {
+ return m_aImplControl.getControlWindow();
+ }
+
+ //--------------------------------------------------------------------
+ template< class CONTROL_INTERFACE, class CONTROL_WINDOW >
+ inline ::sal_Bool SAL_CALL CommonBehaviourControl< CONTROL_INTERFACE, CONTROL_WINDOW >::isModified( ) throw (::com::sun::star::uno::RuntimeException)
+ {
+ return m_aImplControl.isModified();
+ }
+
+ //--------------------------------------------------------------------
+ template< class CONTROL_INTERFACE, class CONTROL_WINDOW >
+ inline void SAL_CALL CommonBehaviourControl< CONTROL_INTERFACE, CONTROL_WINDOW >::notifyModifiedValue( ) throw (::com::sun::star::uno::RuntimeException)
+ {
+ m_aImplControl.notifyModifiedValue();
+ }
+
+ //--------------------------------------------------------------------
+ template< class CONTROL_INTERFACE, class CONTROL_WINDOW >
+ inline void SAL_CALL CommonBehaviourControl< CONTROL_INTERFACE, CONTROL_WINDOW >::disposing()
+ {
+ m_aImplControl.dispose();
+ }
+
+ //--------------------------------------------------------------------
+ template< class CONTROL_INTERFACE, class CONTROL_WINDOW >
+ inline void CommonBehaviourControl< CONTROL_INTERFACE, CONTROL_WINDOW >::modified()
+ {
+ m_aImplControl.setModified();
+ }
+
+ //--------------------------------------------------------------------
+ template< class CONTROL_INTERFACE, class CONTROL_WINDOW >
+ inline void CommonBehaviourControl< CONTROL_INTERFACE, CONTROL_WINDOW >::impl_checkDisposed_throw()
+ {
+ if ( ComponentBaseClass::rBHelper.bDisposed )
+ throw ::com::sun::star::lang::DisposedException( ::rtl::OUString(), *this );
+ }
+
+//............................................................................
+} // namespace pcr
+//............................................................................
+
+#endif // _EXTENSIONS_PROPCTRLR_COMMONCONTROL_HXX_
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/propctrlr/composeduiupdate.cxx b/extensions/source/propctrlr/composeduiupdate.cxx
new file mode 100644
index 000000000000..f40d92e0a259
--- /dev/null
+++ b/extensions/source/propctrlr/composeduiupdate.cxx
@@ -0,0 +1,861 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+#include "composeduiupdate.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/inspection/XObjectInspectorUI.hpp>
+#include <com/sun/star/lang/DisposedException.hpp>
+#include <com/sun/star/inspection/PropertyLineElement.hpp>
+/** === end UNO includes === **/
+#include <osl/mutex.hxx>
+#include <rtl/ref.hxx>
+
+#include <algorithm>
+
+//........................................................................
+namespace pcr
+{
+//........................................................................
+
+ /** === begin UNO using === **/
+ using ::com::sun::star::uno::Exception;
+ using ::com::sun::star::lang::DisposedException;
+ using ::com::sun::star::lang::NullPointerException;
+ using ::com::sun::star::inspection::XPropertyHandler;
+ using ::com::sun::star::uno::Reference;
+ using ::com::sun::star::inspection::XObjectInspectorUI;
+ using ::com::sun::star::inspection::XPropertyControl;
+ using ::com::sun::star::uno::RuntimeException;
+ using ::com::sun::star::lang::NoSupportException;
+ using ::com::sun::star::inspection::XPropertyControlObserver;
+ /** === end UNO using === **/
+
+ namespace PropertyLineElement = ::com::sun::star::inspection::PropertyLineElement;
+
+ //====================================================================
+ //= helper
+ //====================================================================
+ namespace
+ {
+ struct HandlerLess : public ::std::binary_function < Reference< XPropertyHandler >
+ , Reference< XPropertyHandler >
+ , bool
+ >
+ {
+ bool operator()( const Reference< XPropertyHandler >& lhs, const Reference< XPropertyHandler >& rhs) const
+ {
+ return lhs.get() < rhs.get();
+ }
+ };
+
+ //================================================================
+ typedef ::std::set< ::rtl::OUString > StringBag;
+ typedef ::std::map< sal_Int16, StringBag > MapIntToStringBag;
+ }
+
+ //====================================================================
+ //= callbacks for CachedInspectorUI
+ //====================================================================
+ typedef void (ComposedPropertyUIUpdate::*FNotifySingleUIChange)();
+
+ //====================================================================
+ //= CachedInspectorUI
+ //====================================================================
+ typedef ::cppu::WeakImplHelper1 < ::com::sun::star::inspection::XObjectInspectorUI
+ > CachedInspectorUI_Base;
+ struct CachedInspectorUI : public CachedInspectorUI_Base
+ {
+ private:
+ ::osl::Mutex m_aMutex;
+ oslInterlockedCount m_refCount;
+ bool m_bDisposed;
+ ComposedPropertyUIUpdate&
+ m_rMaster;
+ FNotifySingleUIChange m_pUIChangeNotification;
+
+ // enablePropertyUI cache
+ StringBag aEnabledProperties;
+ StringBag aDisabledProperties;
+
+ // show/hidePropertyUI cache
+ StringBag aShownProperties;
+ StringBag aHiddenProperties;
+
+ // rebuildPropertyUI cache
+ StringBag aRebuiltProperties;
+
+ // showCategory cache
+ StringBag aShownCategories;
+ StringBag aHiddenCategories;
+
+ // enablePropertyUIElements cache
+ MapIntToStringBag aEnabledElements;
+ MapIntToStringBag aDisabledElements;
+
+ public:
+ typedef StringBag& (CachedInspectorUI::*FGetStringBag)();
+
+ // enablePropertyUI cache
+ StringBag& getEnabledProperties() { return aEnabledProperties; }
+ StringBag& getDisabledProperties() { return aDisabledProperties; }
+
+ // show/hidePropertyUI cache
+ StringBag& getShownProperties() { return aShownProperties; }
+ StringBag& getHiddenProperties() { return aHiddenProperties; }
+
+ // rebuildPropertyUI cache
+ StringBag& getRebuiltProperties() { return aRebuiltProperties; }
+
+ // showCategory cache
+ StringBag& getShownCategories() { return aShownCategories; }
+ StringBag& getHiddenCategories() { return aHiddenCategories; }
+
+ // enablePropertyUIElements
+ StringBag& getEnabledInputControls() { return aEnabledElements[ PropertyLineElement::InputControl ]; }
+ StringBag& getDisabledInputControls() { return aDisabledElements[ PropertyLineElement::InputControl ]; }
+ StringBag& getEnabledPrimaryButtons() { return aEnabledElements[ PropertyLineElement::PrimaryButton ]; }
+ StringBag& getDisabledPrimaryButtons() { return aDisabledElements[ PropertyLineElement::PrimaryButton ]; }
+ StringBag& getEnabledSecondaryButtons() { return aEnabledElements[ PropertyLineElement::SecondaryButton ]; }
+ StringBag& getDisabledSecondaryButtons() { return aDisabledElements[ PropertyLineElement::SecondaryButton ]; }
+
+ public:
+ CachedInspectorUI( ComposedPropertyUIUpdate& _rMaster, FNotifySingleUIChange _pUIChangeNotification );
+
+ /// disposes the instance
+ void dispose();
+
+ // XObjectInspectorUI overridables
+ virtual void SAL_CALL enablePropertyUI( const ::rtl::OUString& _rPropertyName, ::sal_Bool _bEnable ) throw (RuntimeException);
+ virtual void SAL_CALL enablePropertyUIElements( const ::rtl::OUString& _rPropertyName, ::sal_Int16 _nElements, ::sal_Bool _bEnable ) throw (RuntimeException);
+ virtual void SAL_CALL rebuildPropertyUI( const ::rtl::OUString& _rPropertyName ) throw (RuntimeException);
+ virtual void SAL_CALL showPropertyUI( const ::rtl::OUString& _rPropertyName ) throw (RuntimeException);
+ virtual void SAL_CALL hidePropertyUI( const ::rtl::OUString& _rPropertyName ) throw (RuntimeException);
+ virtual void SAL_CALL showCategory( const ::rtl::OUString& _rCategory, ::sal_Bool _bShow ) throw (RuntimeException);
+ virtual Reference< XPropertyControl > SAL_CALL getPropertyControl( const ::rtl::OUString& _rPropertyName ) throw (RuntimeException);
+ virtual void SAL_CALL registerControlObserver( const Reference< XPropertyControlObserver >& Observer ) throw (RuntimeException);
+ virtual void SAL_CALL revokeControlObserver( const Reference< XPropertyControlObserver >& Observer ) throw (RuntimeException);
+ virtual void SAL_CALL setHelpSectionText( const ::rtl::OUString& _HelpText ) throw (NoSupportException, RuntimeException);
+
+ // UNOCompatibleNonUNOReference overridables
+ virtual void SAL_CALL acquire() throw();
+ virtual void SAL_CALL release() throw();
+
+ protected:
+ ~CachedInspectorUI();
+
+ /// determines whether the instance is already disposed
+ inline bool isDisposed() const { return m_bDisposed; }
+
+ /// throws an exception if the component is already disposed
+ void checkDisposed() const;
+
+ private:
+ void impl_markElementEnabledOrDisabled( const ::rtl::OUString& _rPropertyName, sal_Int16 _nElementIdOrZero, sal_Bool _bEnable );
+
+ /** calls <member>m_pUIChangeNotification</member> at <member>m_rMaster</member>
+ */
+ void impl_notifySingleUIChange() const;
+
+ private:
+ CachedInspectorUI( const CachedInspectorUI& ); // never implemented
+ CachedInspectorUI& operator=( const CachedInspectorUI& ); // never implemented
+
+ private:
+ class MethodGuard;
+ friend class MethodGuard;
+ class MethodGuard : public ::osl::MutexGuard
+ {
+ public:
+ MethodGuard( CachedInspectorUI& rInstance )
+ : ::osl::MutexGuard( rInstance.m_aMutex )
+ {
+ rInstance.checkDisposed();
+ }
+ };
+ };
+
+ //----------------------------------------------------------------
+ CachedInspectorUI::CachedInspectorUI( ComposedPropertyUIUpdate& _rMaster, FNotifySingleUIChange _pUIChangeNotification )
+ :m_refCount( 0 )
+ ,m_bDisposed( false )
+ ,m_rMaster( _rMaster )
+ ,m_pUIChangeNotification( _pUIChangeNotification )
+ {
+ }
+
+ //----------------------------------------------------------------
+ CachedInspectorUI::~CachedInspectorUI()
+ {
+ }
+
+ //----------------------------------------------------------------
+ void CachedInspectorUI::dispose()
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ m_bDisposed = true;
+
+ clearContainer( aEnabledProperties );
+ clearContainer( aDisabledProperties );
+ clearContainer( aRebuiltProperties );
+ clearContainer( aShownProperties );
+ clearContainer( aHiddenProperties );
+ clearContainer( aShownCategories );
+ clearContainer( aHiddenCategories );
+ clearContainer( aEnabledElements );
+ clearContainer( aDisabledElements );
+ }
+
+ //----------------------------------------------------------------
+ void SAL_CALL CachedInspectorUI::acquire() throw()
+ {
+ osl_incrementInterlockedCount( &m_refCount );
+ }
+
+ //----------------------------------------------------------------
+ void SAL_CALL CachedInspectorUI::release() throw()
+ {
+ if ( 0 == osl_decrementInterlockedCount( &m_refCount ) )
+ delete this;
+ }
+
+
+ //----------------------------------------------------------------
+ void CachedInspectorUI::checkDisposed() const
+ {
+ if ( isDisposed() )
+ throw DisposedException();
+ }
+
+ //----------------------------------------------------------------
+ namespace
+ {
+ void lcl_markStringKeyPositiveOrNegative( const ::rtl::OUString& _rKeyName, StringBag& _rPositives, StringBag& _rNegatives, sal_Bool _bMarkPositive )
+ {
+ if ( _bMarkPositive )
+ {
+ _rPositives.insert( _rKeyName );
+ // if the same key has been remember as in the "negative" list before, clear this information, since it's overruled
+ _rNegatives.erase( _rKeyName );
+ }
+ else
+ _rNegatives.insert( _rKeyName );
+ }
+ }
+
+ //----------------------------------------------------------------
+ void CachedInspectorUI::enablePropertyUI( const ::rtl::OUString& _rPropertyName, sal_Bool _bEnable ) throw (RuntimeException)
+ {
+ MethodGuard aGuard( *this );
+ if ( !m_rMaster.shouldContinuePropertyHandling( _rPropertyName ) )
+ return;
+
+ lcl_markStringKeyPositiveOrNegative( _rPropertyName, aEnabledProperties, aDisabledProperties, _bEnable );
+ impl_notifySingleUIChange();
+ }
+
+ //----------------------------------------------------------------
+ void CachedInspectorUI::impl_markElementEnabledOrDisabled( const ::rtl::OUString& _rPropertyName, sal_Int16 _nElementIdOrZero, sal_Bool _bEnable )
+ {
+ if ( _nElementIdOrZero == 0 )
+ return;
+
+ lcl_markStringKeyPositiveOrNegative(
+ _rPropertyName,
+ aEnabledElements[ _nElementIdOrZero ],
+ aDisabledElements[ _nElementIdOrZero ],
+ _bEnable
+ );
+ }
+
+ //----------------------------------------------------------------
+ void CachedInspectorUI::impl_notifySingleUIChange() const
+ {
+ (m_rMaster.*m_pUIChangeNotification)();
+ }
+
+ //----------------------------------------------------------------
+ void CachedInspectorUI::enablePropertyUIElements( const ::rtl::OUString& _rPropertyName, sal_Int16 _nElements, sal_Bool _bEnable ) throw (RuntimeException)
+ {
+ MethodGuard aGuard( *this );
+ if ( !m_rMaster.shouldContinuePropertyHandling( _rPropertyName ) )
+ return;
+
+ impl_markElementEnabledOrDisabled( _rPropertyName, _nElements & PropertyLineElement::InputControl, _bEnable );
+ impl_markElementEnabledOrDisabled( _rPropertyName, _nElements & PropertyLineElement::PrimaryButton, _bEnable );
+ impl_markElementEnabledOrDisabled( _rPropertyName, _nElements & PropertyLineElement::SecondaryButton, _bEnable );
+
+ impl_notifySingleUIChange();
+ }
+
+ //----------------------------------------------------------------
+ void CachedInspectorUI::rebuildPropertyUI( const ::rtl::OUString& _rPropertyName ) throw (RuntimeException)
+ {
+ MethodGuard aGuard( *this );
+ if ( !m_rMaster.shouldContinuePropertyHandling( _rPropertyName ) )
+ return;
+
+ aRebuiltProperties.insert( _rPropertyName );
+
+ impl_notifySingleUIChange();
+ }
+
+ //----------------------------------------------------------------
+ void CachedInspectorUI::showPropertyUI( const ::rtl::OUString& _rPropertyName ) throw (RuntimeException)
+ {
+ MethodGuard aGuard( *this );
+ if ( !m_rMaster.shouldContinuePropertyHandling( _rPropertyName ) )
+ return;
+
+ aShownProperties.insert( _rPropertyName );
+ // if the same category has been hidden before, clear this information, since it's overruled
+ aHiddenProperties.erase( _rPropertyName );
+
+ impl_notifySingleUIChange();
+ }
+
+ //----------------------------------------------------------------
+ void CachedInspectorUI::hidePropertyUI( const ::rtl::OUString& _rPropertyName ) throw (RuntimeException)
+ {
+ MethodGuard aGuard( *this );
+ if ( !m_rMaster.shouldContinuePropertyHandling( _rPropertyName ) )
+ return;
+
+ aHiddenProperties.insert( _rPropertyName );
+ impl_notifySingleUIChange();
+ }
+
+ //----------------------------------------------------------------
+ void CachedInspectorUI::showCategory( const ::rtl::OUString& _rCategory, sal_Bool _bShow ) throw (RuntimeException)
+ {
+ MethodGuard aGuard( *this );
+
+ lcl_markStringKeyPositiveOrNegative( _rCategory, aShownCategories, aHiddenCategories, _bShow );
+ impl_notifySingleUIChange();
+ }
+
+ //----------------------------------------------------------------
+ Reference< XPropertyControl > SAL_CALL CachedInspectorUI::getPropertyControl( const ::rtl::OUString& _rPropertyName ) throw (RuntimeException)
+ {
+ MethodGuard aGuard( *this );
+ if ( !m_rMaster.shouldContinuePropertyHandling( _rPropertyName ) )
+ return Reference< XPropertyControl >();
+
+ return m_rMaster.getDelegatorUI()->getPropertyControl( _rPropertyName );
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL CachedInspectorUI::registerControlObserver( const Reference< XPropertyControlObserver >& _Observer ) throw (RuntimeException)
+ {
+ OSL_ENSURE( false, "CachedInspectorUI::registerControlObserver: not expected to be called!" );
+ // CachedInspectorUI is used as context for the controls, and we don't expect them to
+ // register listeners themself
+ m_rMaster.getDelegatorUI()->registerControlObserver( _Observer );
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL CachedInspectorUI::revokeControlObserver( const Reference< XPropertyControlObserver >& _Observer ) throw (RuntimeException)
+ {
+ OSL_ENSURE( false, "CachedInspectorUI::revokeControlObserver: not expected to be called!" );
+ // CachedInspectorUI is used as context for the controls, and we don't expect them to
+ // register listeners themself
+ m_rMaster.getDelegatorUI()->revokeControlObserver( _Observer );
+ }
+
+ //----------------------------------------------------------------
+ void SAL_CALL CachedInspectorUI::setHelpSectionText( const ::rtl::OUString& _HelpText ) throw (NoSupportException, RuntimeException)
+ {
+ m_rMaster.getDelegatorUI()->setHelpSectionText( _HelpText );
+ }
+
+ //====================================================================
+ //= HandlerMap
+ //====================================================================
+ typedef ::std::map < Reference< XPropertyHandler >
+ , ::rtl::Reference< CachedInspectorUI >
+ , HandlerLess
+ > ImplMapHandlerToUI;
+ struct MapHandlerToUI
+ {
+ ImplMapHandlerToUI aHandlers;
+ };
+
+ //====================================================================
+ //= ComposedPropertyUIUpdate
+ //====================================================================
+ //----------------------------------------------------------------
+ ComposedPropertyUIUpdate::ComposedPropertyUIUpdate( const Reference< XObjectInspectorUI >& _rxDelegatorUI,
+ IPropertyExistenceCheck* _pPropertyCheck )
+ :m_pCollectedUIs( new MapHandlerToUI )
+ ,m_xDelegatorUI( _rxDelegatorUI )
+ ,m_nSuspendCounter( 0 )
+ ,m_pPropertyCheck( _pPropertyCheck )
+ {
+ if ( !m_xDelegatorUI.is() )
+ throw NullPointerException();
+ }
+
+ //----------------------------------------------------------------
+ ComposedPropertyUIUpdate::~ComposedPropertyUIUpdate( )
+ {
+ }
+
+ //----------------------------------------------------------------
+ Reference< XObjectInspectorUI > ComposedPropertyUIUpdate::getUIForPropertyHandler( const Reference< XPropertyHandler >& _rxHandler )
+ {
+ impl_checkDisposed();
+
+ ::rtl::Reference< CachedInspectorUI >& rUI = m_pCollectedUIs->aHandlers[ _rxHandler ];
+ if ( !rUI.is() )
+ rUI = new CachedInspectorUI( *this, &ComposedPropertyUIUpdate::callback_inspectorUIChanged_throw );
+ return rUI.get();
+ }
+
+ //----------------------------------------------------------------
+ namespace
+ {
+ //============================================================
+ //= StringBagCollector
+ //============================================================
+ /** an STL-compatible structure which collects strings from a CachedInspectorUI instances
+ */
+ struct StringBagCollector : public ::std::unary_function< ImplMapHandlerToUI::value_type, void >
+ {
+ private:
+ StringBag& m_rBag;
+ CachedInspectorUI::FGetStringBag m_pGetter;
+
+ public:
+ StringBagCollector( StringBag& _rBag, CachedInspectorUI::FGetStringBag _pGetter ) :m_rBag( _rBag ), m_pGetter( _pGetter ) { }
+
+ void operator()( const ImplMapHandlerToUI::value_type& _rUI )
+ {
+ StringBag& rBag( ((_rUI.second.get())->*m_pGetter)() );
+ m_rBag.insert( rBag.begin(), rBag.end() );
+ }
+
+ static void collectAll( StringBag& _rAll, const ImplMapHandlerToUI& _rMap, CachedInspectorUI::FGetStringBag _pGetter )
+ {
+ ::std::for_each( _rMap.begin(), _rMap.end(), StringBagCollector( _rAll, _pGetter ) );
+ }
+ };
+
+ //============================================================
+ //= StringBagClearer
+ //============================================================
+ /** an STL-compatible structure which cleans a certain string bag in a CachedInspectorUI instances
+ */
+ struct StringBagClearer : public ::std::unary_function< ImplMapHandlerToUI::value_type, void >
+ {
+ private:
+ CachedInspectorUI::FGetStringBag m_pGetter;
+
+ public:
+ StringBagClearer( CachedInspectorUI::FGetStringBag _pGetter ) :m_pGetter( _pGetter ) { }
+
+ void operator()( const ImplMapHandlerToUI::value_type& _rUI )
+ {
+ clearContainer( ((_rUI.second.get())->*m_pGetter)() );
+ }
+
+ static void clearAll( const ImplMapHandlerToUI& _rMap, CachedInspectorUI::FGetStringBag _pGetter )
+ {
+ ::std::for_each( _rMap.begin(), _rMap.end(), StringBagClearer( _pGetter ) );
+ }
+ };
+
+ //============================================================
+ //= FPropertyUISetter
+ //============================================================
+ /** a typedef for a ->XObjectInspectorUI member function taking a string
+ */
+ typedef void ( SAL_CALL XObjectInspectorUI::*FPropertyUISetter )( const ::rtl::OUString& );
+
+ //============================================================
+ //= PropertyUIOperator
+ //============================================================
+ /** an STL-compatible struct which calls a certain member method (taking a string) at a
+ given ->XObjectInspectorUI instance
+ */
+ struct PropertyUIOperator : public ::std::unary_function< ::rtl::OUString, void >
+ {
+ private:
+ Reference< XObjectInspectorUI > m_xUpdater;
+ FPropertyUISetter m_pSetter;
+
+ public:
+ PropertyUIOperator( const Reference< XObjectInspectorUI >& _rxInspectorUI, FPropertyUISetter _pSetter )
+ :m_xUpdater( _rxInspectorUI )
+ ,m_pSetter( _pSetter )
+ {
+ }
+
+ void operator()( const ::rtl::OUString& _rPropertyName )
+ {
+ ((m_xUpdater.get())->*m_pSetter)( _rPropertyName );
+ }
+
+ static void forEach( const StringBag& _rProperties, const Reference< XObjectInspectorUI >& _rxDelegatorUI, FPropertyUISetter _pSetter )
+ {
+ ::std::for_each( _rProperties.begin(), _rProperties.end(), PropertyUIOperator( _rxDelegatorUI, _pSetter ) );
+ }
+ };
+
+ //============================================================
+ //= IStringKeyBooleanUIUpdate
+ //============================================================
+ /** an interface which encapsulates access to a single aspect of the ->XObjectInspectorUI,
+ where this aspect is given by a string key, and has a boolean value.
+ */
+ class IStringKeyBooleanUIUpdate
+ {
+ public:
+ virtual void updateUIForKey( const ::rtl::OUString& _rKey, sal_Bool _bFlag ) const = 0;
+
+ virtual ~IStringKeyBooleanUIUpdate() { }
+ };
+
+ //============================================================
+ //= FPropertyUIFlagSetter
+ //============================================================
+ /** an implementation of the ->IStringKeyBooleanUIUpdate interface which,
+ for a fixed ->XObjectInspectorUI instance and a fixed UI element (->PropertyLineElement),
+ updates this element for a given property with a given boolean flag
+ (->XObjectInspectorUI::enablePropertyUIElements)
+ */
+ class EnablePropertyUIElement : public IStringKeyBooleanUIUpdate
+ {
+ private:
+ Reference< XObjectInspectorUI > m_xUIUpdate;
+ sal_Int16 m_nElement;
+
+ public:
+ EnablePropertyUIElement( const Reference< XObjectInspectorUI >& _rxUIUpdate, sal_Int16 _nElement )
+ :m_xUIUpdate( _rxUIUpdate )
+ ,m_nElement( _nElement )
+ {
+ }
+ // IStringKeyBooleanUIUpdate
+ virtual void updateUIForKey( const ::rtl::OUString& _rKey, sal_Bool _bFlag ) const;
+ };
+
+ //............................................................
+ void EnablePropertyUIElement::updateUIForKey( const ::rtl::OUString& _rKey, sal_Bool _bFlag ) const
+ {
+ m_xUIUpdate->enablePropertyUIElements( _rKey, m_nElement, _bFlag );
+ }
+
+ //============================================================
+ //= FPropertyUIFlagSetter
+ //============================================================
+ /** a ->XObjectInspectorUI method taking a string and a boolean
+ */
+ typedef void ( SAL_CALL XObjectInspectorUI::*FPropertyUIFlagSetter )( const ::rtl::OUString&, sal_Bool );
+
+ //============================================================
+ //= DefaultStringKeyBooleanUIUpdate
+ //============================================================
+ /** an implementaiton of the ->IStringKeyBooleanUIUpdate interface which calls
+ am arbitrary ->XObjectInspectorUI method taking a string and a boolean flag
+ */
+ class DefaultStringKeyBooleanUIUpdate : public IStringKeyBooleanUIUpdate
+ {
+ private:
+ Reference< XObjectInspectorUI > m_xUIUpdate;
+ FPropertyUIFlagSetter m_pSetter;
+
+ public:
+ DefaultStringKeyBooleanUIUpdate( const Reference< XObjectInspectorUI >& _rxUIUpdate, FPropertyUIFlagSetter _pSetter );
+ // IStringKeyBooleanUIUpdate
+ virtual void updateUIForKey( const ::rtl::OUString& _rKey, sal_Bool _bFlag ) const;
+ };
+
+ //............................................................
+ DefaultStringKeyBooleanUIUpdate::DefaultStringKeyBooleanUIUpdate( const Reference< XObjectInspectorUI >& _rxUIUpdate, FPropertyUIFlagSetter _pSetter )
+ :m_xUIUpdate( _rxUIUpdate )
+ ,m_pSetter( _pSetter )
+ {
+ }
+
+ //............................................................
+ void DefaultStringKeyBooleanUIUpdate::updateUIForKey( const ::rtl::OUString& _rKey, sal_Bool _bFlag ) const
+ {
+ ((m_xUIUpdate.get())->*m_pSetter)( _rKey, _bFlag );
+ }
+
+ //============================================================
+ //= BooleanUIAspectUpdate
+ //============================================================
+ /** an STL-compatible structure which applies a ->IStringKeyBooleanUIUpdate::updateUIForKey
+ operation with a fixed boolean value, for a given string value
+ */
+ struct BooleanUIAspectUpdate : public ::std::unary_function< ::rtl::OUString, void >
+ {
+ private:
+ const IStringKeyBooleanUIUpdate& m_rUpdater;
+ sal_Bool m_bFlag;
+
+ public:
+ BooleanUIAspectUpdate( const IStringKeyBooleanUIUpdate& _rUpdater, sal_Bool _bFlag )
+ :m_rUpdater( _rUpdater )
+ ,m_bFlag( _bFlag )
+ {
+ }
+
+ void operator()( const ::rtl::OUString& _rPropertyName )
+ {
+ m_rUpdater.updateUIForKey( _rPropertyName, m_bFlag );
+ }
+
+ static void forEach( const StringBag& _rProperties, const IStringKeyBooleanUIUpdate& _rUpdater, sal_Bool _bFlag )
+ {
+ ::std::for_each( _rProperties.begin(), _rProperties.end(), BooleanUIAspectUpdate( _rUpdater, _bFlag ) );
+ }
+ };
+
+ //============================================================
+ //= BooleanUIAspectUpdate
+ //============================================================
+ /** an STL-compatible structure subtracting a given string from a fixed ->StringBag
+ */
+ struct StringBagComplement : public ::std::unary_function< ::rtl::OUString, void >
+ {
+ private:
+ StringBag& m_rMinuend;
+
+ public:
+ StringBagComplement( StringBag& _rMinuend ) :m_rMinuend( _rMinuend ) { }
+
+ void operator()( const ::rtl::OUString& _rPropertyToSubtract )
+ {
+ m_rMinuend.erase( _rPropertyToSubtract );
+ }
+
+ static void subtract( StringBag& _rMinuend, const StringBag& _rSubtrahend )
+ {
+ ::std::for_each( _rSubtrahend.begin(), _rSubtrahend.end(), StringBagComplement( _rMinuend ) );
+ }
+ };
+
+ //============================================================
+ //= BooleanUIAspectUpdate
+ //============================================================
+ void lcl_fireUIStateFlag(
+ const IStringKeyBooleanUIUpdate& _rUIUpdate,
+ const ImplMapHandlerToUI& _rHandlerUIs,
+ CachedInspectorUI::FGetStringBag _pGetPositives,
+ CachedInspectorUI::FGetStringBag _pGetNegatives
+ )
+ {
+ // all strings which are in the "positive" list of one handler
+ StringBag aAllPositives;
+ StringBagCollector::collectAll( aAllPositives, _rHandlerUIs, _pGetPositives );
+
+ // all strings which are in the "negative" list of one handler
+ StringBag aAllNegatives;
+ StringBagCollector::collectAll( aAllNegatives, _rHandlerUIs, _pGetNegatives );
+
+ // propagate the "negative" flags to the delegator UI
+ BooleanUIAspectUpdate::forEach( aAllNegatives, _rUIUpdate, sal_False );
+
+ // propagate the "positive" flags to the delegator UI, for all elements where _no_
+ // "negative" flag exists
+ StringBagComplement::subtract( aAllPositives, aAllNegatives );
+ BooleanUIAspectUpdate::forEach( aAllPositives, _rUIUpdate, sal_True );
+
+ // the "positive" request can be cleared no, only negative requests
+ // (such as "disable a property" or "hide a category") need to be preserved for the next round
+ StringBagClearer::clearAll( _rHandlerUIs, _pGetPositives );
+ }
+ }
+
+ //----------------------------------------------------------------
+ void ComposedPropertyUIUpdate::impl_fireEnablePropertyUI_throw()
+ {
+ lcl_fireUIStateFlag(
+ DefaultStringKeyBooleanUIUpdate( m_xDelegatorUI, &XObjectInspectorUI::enablePropertyUI ),
+ m_pCollectedUIs->aHandlers,
+ &CachedInspectorUI::getEnabledProperties,
+ &CachedInspectorUI::getDisabledProperties
+ );
+ }
+
+ //----------------------------------------------------------------
+ void ComposedPropertyUIUpdate::impl_fireRebuildPropertyUI_throw()
+ {
+ // collect all properties for which a rebuild request has been made
+ StringBag aAllRebuilt;
+ StringBagCollector::collectAll( aAllRebuilt, m_pCollectedUIs->aHandlers, &CachedInspectorUI::getRebuiltProperties );
+
+ // rebuild all those properties
+ PropertyUIOperator::forEach( aAllRebuilt, m_xDelegatorUI, &XObjectInspectorUI::rebuildPropertyUI );
+
+ // clear the "properties to rebuild" at all handlers, since the request has been fulfilled now.
+ StringBagClearer::clearAll( m_pCollectedUIs->aHandlers, &CachedInspectorUI::getRebuiltProperties );
+ }
+
+ //----------------------------------------------------------------
+ void ComposedPropertyUIUpdate::impl_fireShowHidePropertyUI_throw()
+ {
+ // all properties which have been shown by at least one handler
+ StringBag aAllShown;
+ StringBagCollector::collectAll( aAllShown, m_pCollectedUIs->aHandlers, &CachedInspectorUI::getShownProperties );
+ // all properties which have been hidden by at least one handler
+ StringBag aAllHidden;
+ StringBagCollector::collectAll( aAllHidden, m_pCollectedUIs->aHandlers, &CachedInspectorUI::getHiddenProperties );
+
+ // hide properties as necessary
+ PropertyUIOperator::forEach( aAllHidden, m_xDelegatorUI, &XObjectInspectorUI::hidePropertyUI );
+
+ // for those properties which are hidden, ignore all "show" requests which other handlers might have had
+ StringBagComplement::subtract( aAllShown, aAllHidden );
+
+ // show properties
+ PropertyUIOperator::forEach( aAllShown, m_xDelegatorUI, &XObjectInspectorUI::showPropertyUI );
+ }
+
+ //----------------------------------------------------------------
+ void ComposedPropertyUIUpdate::impl_fireShowCategory_throw()
+ {
+ lcl_fireUIStateFlag(
+ DefaultStringKeyBooleanUIUpdate( m_xDelegatorUI, &XObjectInspectorUI::showCategory ),
+ m_pCollectedUIs->aHandlers,
+ &CachedInspectorUI::getShownCategories,
+ &CachedInspectorUI::getHiddenCategories
+ );
+ }
+
+ //----------------------------------------------------------------
+ void ComposedPropertyUIUpdate::impl_fireEnablePropertyUIElements_throw()
+ {
+ lcl_fireUIStateFlag(
+ EnablePropertyUIElement( m_xDelegatorUI, PropertyLineElement::InputControl ),
+ m_pCollectedUIs->aHandlers,
+ &CachedInspectorUI::getEnabledInputControls,
+ &CachedInspectorUI::getDisabledInputControls
+ );
+
+ lcl_fireUIStateFlag(
+ EnablePropertyUIElement( m_xDelegatorUI, PropertyLineElement::PrimaryButton ),
+ m_pCollectedUIs->aHandlers,
+ &CachedInspectorUI::getEnabledPrimaryButtons,
+ &CachedInspectorUI::getDisabledPrimaryButtons
+ );
+
+ lcl_fireUIStateFlag(
+ EnablePropertyUIElement( m_xDelegatorUI, PropertyLineElement::SecondaryButton ),
+ m_pCollectedUIs->aHandlers,
+ &CachedInspectorUI::getEnabledSecondaryButtons,
+ &CachedInspectorUI::getDisabledSecondaryButtons
+ );
+ }
+
+ //--------------------------------------------------------------------
+ void ComposedPropertyUIUpdate::impl_fireAll_throw()
+ {
+ OSL_PRECOND( !impl_isDisposed(), "ComposedPropertyUIUpdate::impl_fireAll_throw: already disposed, this will crash!" );
+
+ impl_fireEnablePropertyUI_throw();
+ impl_fireShowHidePropertyUI_throw();
+ impl_fireRebuildPropertyUI_throw();
+ impl_fireShowCategory_throw();
+ impl_fireEnablePropertyUIElements_throw();
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL ComposedPropertyUIUpdate::suspendAutoFire()
+ {
+ impl_checkDisposed();
+ osl_incrementInterlockedCount( &m_nSuspendCounter );
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL ComposedPropertyUIUpdate::resumeAutoFire()
+ {
+ impl_checkDisposed();
+ if ( 0 == osl_decrementInterlockedCount( &m_nSuspendCounter ) )
+ impl_fireAll_throw();
+ }
+
+ //----------------------------------------------------------------
+ void ComposedPropertyUIUpdate::impl_checkDisposed() const
+ {
+ if ( impl_isDisposed() )
+ throw DisposedException();
+ }
+
+ //----------------------------------------------------------------
+ void ComposedPropertyUIUpdate::callback_inspectorUIChanged_throw()
+ {
+ if ( 0 == m_nSuspendCounter )
+ impl_fireAll_throw();
+ }
+
+ //----------------------------------------------------------------
+ Reference< XObjectInspectorUI > ComposedPropertyUIUpdate::getDelegatorUI() const
+ {
+ impl_checkDisposed();
+ return m_xDelegatorUI;
+ }
+
+ //----------------------------------------------------------------
+ void SAL_CALL ComposedPropertyUIUpdate::dispose()
+ {
+ if ( impl_isDisposed() )
+ return;
+
+ OSL_ENSURE( m_nSuspendCounter == 0, "ComposedPropertyUIUpdate::dispose: still suspended, the changes will be lost!" );
+
+ for ( ImplMapHandlerToUI::const_iterator singleUI = m_pCollectedUIs->aHandlers.begin();
+ singleUI != m_pCollectedUIs->aHandlers.end();
+ ++singleUI
+ )
+ {
+ singleUI->second->dispose();
+ }
+ m_pCollectedUIs.reset( NULL );
+ m_xDelegatorUI.set( NULL );
+ }
+
+ //----------------------------------------------------------------
+ bool ComposedPropertyUIUpdate::shouldContinuePropertyHandling( const ::rtl::OUString& _rName ) const
+ {
+ if ( !m_pPropertyCheck )
+ return true;
+ if ( m_pPropertyCheck->hasPropertyByName( _rName ) )
+ return true;
+ return false;
+ }
+
+//........................................................................
+} // namespace pcr
+//........................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/propctrlr/composeduiupdate.hxx b/extensions/source/propctrlr/composeduiupdate.hxx
new file mode 100644
index 000000000000..3660246d3838
--- /dev/null
+++ b/extensions/source/propctrlr/composeduiupdate.hxx
@@ -0,0 +1,233 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef EXTENSIONS_SOURCE_PROPCTRLR_COMPOSEDUIUPDATE_HXX
+#define EXTENSIONS_SOURCE_PROPCTRLR_COMPOSEDUIUPDATE_HXX
+
+#include "propertyhandler.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/inspection/XObjectInspectorUI.hpp>
+/** === end UNO includes === **/
+
+#include <map>
+#include <set>
+#include <memory>
+
+//........................................................................
+namespace pcr
+{
+//........................................................................
+
+ //====================================================================
+ //= some helper types
+ //====================================================================
+
+ struct MapHandlerToUI;
+
+ /** callback for an ComposedPropertyUIUpdate checking a given property for existence
+ */
+ class SAL_NO_VTABLE IPropertyExistenceCheck
+ {
+ public:
+ virtual ::sal_Bool SAL_CALL hasPropertyByName( const ::rtl::OUString& _rName ) throw (::com::sun::star::uno::RuntimeException) = 0;
+ };
+
+ //====================================================================
+ //= ComposedPropertyUIUpdate
+ //====================================================================
+ /** helper class composing requests to a ->XObjectInspectorUI interface, coming
+ from multiple sources
+
+ Usually, a handler tells the browser UI to enable to disable, or show or hide, certain
+ elements. Now when multiple handlers do this, their instructions must be combined:
+ If one handler disables a certain element, but others enable it, it must in the
+ result still be disabled. Similar for showing/hiding elements.
+
+ ->ComposedPropertyUIUpdate implements this combination. It does so by providing a dedicated
+ ->XObjectInspectorUI instance for every participating handler, and remembering the UI
+ state on a per-handler basis. Upon request (->fire), the combined UI state is
+ forwarded to another ->XObjectInspectorUI instance, the so-called delegator UI.
+ */
+ class ComposedPropertyUIUpdate
+ {
+ private:
+ ::std::auto_ptr< MapHandlerToUI > m_pCollectedUIs;
+ ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XObjectInspectorUI >
+ m_xDelegatorUI;
+ oslInterlockedCount m_nSuspendCounter;
+ IPropertyExistenceCheck* m_pPropertyCheck;
+
+ public:
+ /** constructs a ->ComposedPropertyUIUpdate instance
+ @param _rxDelegatorUI
+ a ->XObjectInspectorUI instance to which composed UI requests should be forwarded. Must
+ not be <NULL/>.
+ @param _pPropertyCheck
+ an instance checking properties for existence. If this is not <NULL/>, it will be invoked
+ whenever one of the ->XObjectInspectorUI methods is called, to check the passed property
+ name.<br/>
+ Beware of lifetime issues. The instance pointed to by <arg>_pPropertyCheck</arg> must
+ live at least as long as the ->ComposedPropertyUIUpdate instance you're going to create.
+ @throws ::com::sun::star::lang::NullPointerException
+ if ->_rxDelegatorUI is <NULL/>
+ */
+ ComposedPropertyUIUpdate(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XObjectInspectorUI >& _rxDelegatorUI,
+ IPropertyExistenceCheck* _pPropertyCheck );
+ ~ComposedPropertyUIUpdate();
+
+ /** returns the delegator UI
+ @throw ::com::sun::star::lang::DisposedException
+ */
+ ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XObjectInspectorUI > getDelegatorUI() const;
+
+ /** returns a ->XObjectInspectorUI instance belonging to a given property handler
+
+ In every call to an ->XPropertyHandler method which requires a ->XObjectInspectorUI,
+ the same UI instance should be used. The instance here will cache all requests passed
+ to it, and ->ComposedPropertyUIUpdate::fire will use the combination of all
+ cached UI states of all handlers to update the delegator UI.
+ */
+ ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XObjectInspectorUI >
+ getUIForPropertyHandler( const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyHandler >& _rxHandler );
+
+ /** Suspends automatic firing of UI changes
+
+ normally, as soon as any of the property handlers does a request for an
+ arbitrary UI change, the set of collected UI changes is evaluated, and the combined
+ UI state is fired to the delegator UI.
+
+ You can disable this automatic firing by calling ->suspendAutoFire. As longs as auto
+ firing is suspended, only explicit ->fire calls trigger the notification to the
+ delegator UI.
+
+ Note that calls to ->suspendAutoFire are culmulative, that is, if you make multiple calls
+ they must be accompanied by an equal number of calls to ->resumeAutoFire, to enable
+ auto-firing again.
+
+ @seealso resumeAutoFire
+ */
+ void SAL_CALL suspendAutoFire();
+
+ /** Suspends automatic firing of UI changes
+
+ @seealso suspendAutoFire
+ */
+ void SAL_CALL resumeAutoFire();
+
+ /** disposes the instance, so it becomes non-functional.
+
+ All cached handlers and cached ->XObjectInspectorUI instances will be released,
+ the latter will also be disposed, so that if anybody still holds a reference to them
+ and tries to operate them will get a DisposedException.
+ */
+ void SAL_CALL dispose();
+
+ /** invokes m_pPropertyCheck to check whether a given property should be handled
+ */
+ bool shouldContinuePropertyHandling( const ::rtl::OUString& _rName ) const;
+
+ private:
+ /// determines whether the instance is already disposed
+ inline bool impl_isDisposed() const { return m_pCollectedUIs.get() == NULL; }
+
+ /// throws an exception if the component is already disposed
+ void impl_checkDisposed() const;
+
+ /** fires the collected UI changes to our delegator UI
+
+ All operations for any elements are forwarded:
+ <ul><li>If an element has been hidden at least once, it's also hidden at the delegator UI.</li>
+ <li>If an element has been shown at least once, and never been hidden, it's also
+ shown at the delegator UI.</li>
+ <li>If an element has never been shown or hidden, it's also not touched at the delegator UI.</li>
+ <li>The same holds if you replace "hidden" in the last three items with "disabled",
+ and "shown" with "enabled".</li>
+ <li>If an element should have been rebuilt (->XObjectInspectorUI::rebuiltPropertyUI)
+ at least once, it's rebuilt at the delegator UI, too.<br/>
+ After that, the request to rebuild the UI for this property is cleared, so subsequent
+ calls to ->fire will not trigger an new rebuilt request.
+ </ul>
+
+ @precond
+ instance is not disposed
+ */
+ void impl_fireAll_throw();
+
+ /// fires the combination of ->XObjectInspectorUI::enablePropertyUI calls
+ void impl_fireEnablePropertyUI_throw();
+
+ /// fires the combination of ->XObjectInspectorUI::enablePropertyUIElements calls
+ void impl_fireEnablePropertyUIElements_throw();
+
+ /// fires the combination of ->XObjectInspectorUI::rebuildPropertyUI calls
+ void impl_fireRebuildPropertyUI_throw();
+
+ /// fires the combination of ->XObjectInspectorUI::showPropertyUI and ->XObjectInspectorUI::hidePropertyUI calls
+ void impl_fireShowHidePropertyUI_throw();
+
+ /// fires the combination of ->XObjectInspectorUI::showCategory calls
+ void impl_fireShowCategory_throw();
+
+ /** callback for when a single property handler requested any change in the inspector UI
+ */
+ void callback_inspectorUIChanged_throw();
+
+ private:
+ ComposedPropertyUIUpdate(); // never implemented
+ ComposedPropertyUIUpdate( const ComposedPropertyUIUpdate& ); // never implemented
+ ComposedPropertyUIUpdate& operator=( const ComposedPropertyUIUpdate& ); // never implemented
+ };
+
+ //====================================================================
+ //= ComposedUIAutoFireGuard
+ //====================================================================
+ class ComposedUIAutoFireGuard
+ {
+ private:
+ ComposedPropertyUIUpdate& m_rUIUpdate;
+ public:
+ ComposedUIAutoFireGuard( ComposedPropertyUIUpdate& _rUIUpdate )
+ :m_rUIUpdate( _rUIUpdate )
+ {
+ m_rUIUpdate.suspendAutoFire();
+ }
+ ~ComposedUIAutoFireGuard()
+ {
+ m_rUIUpdate.resumeAutoFire();
+ }
+ };
+
+//........................................................................
+} // namespace pcr
+//........................................................................
+
+#endif // EXTENSIONS_SOURCE_PROPCTRLR_COMPOSEDUIUPDATE_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/propctrlr/controlfontdialog.cxx b/extensions/source/propctrlr/controlfontdialog.cxx
new file mode 100644
index 000000000000..d922d853ea66
--- /dev/null
+++ b/extensions/source/propctrlr/controlfontdialog.cxx
@@ -0,0 +1,177 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+
+#include "controlfontdialog.hxx"
+#include <cppuhelper/typeprovider.hxx>
+#include "fontdialog.hxx"
+#include "formstrings.hxx"
+#include "pcrcommon.hxx"
+
+extern "C" void SAL_CALL createRegistryInfo_OControlFontDialog()
+{
+ ::pcr::OAutoRegistration< ::pcr::OControlFontDialog > aAutoRegistration;
+}
+
+//........................................................................
+namespace pcr
+{
+//........................................................................
+
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::lang;
+ using namespace ::com::sun::star::beans;
+
+ //====================================================================
+ //= OControlFontDialog
+ //====================================================================
+ //---------------------------------------------------------------------
+ OControlFontDialog::OControlFontDialog(const Reference< XComponentContext >& _rxContext )
+ :OGenericUnoDialog( _rxContext )
+ ,m_pFontItems(NULL)
+ ,m_pItemPool(NULL)
+ ,m_pItemPoolDefaults(NULL)
+ {
+ registerProperty(PROPERTY_INTROSPECTEDOBJECT, OWN_PROPERTY_ID_INTROSPECTEDOBJECT,
+ PropertyAttribute::BOUND | PropertyAttribute::TRANSIENT,
+ &m_xControlModel, ::getCppuType(&m_xControlModel));
+ }
+
+ //---------------------------------------------------------------------
+ OControlFontDialog::~OControlFontDialog()
+ {
+ if (m_pDialog)
+ {
+ ::osl::MutexGuard aGuard(m_aMutex);
+ if (m_pDialog)
+ destroyDialog();
+ }
+ }
+
+ //---------------------------------------------------------------------
+ Sequence<sal_Int8> SAL_CALL OControlFontDialog::getImplementationId( ) throw(RuntimeException)
+ {
+ static ::cppu::OImplementationId aId;
+ return aId.getImplementationId();
+ }
+
+ //---------------------------------------------------------------------
+ Reference< XInterface > SAL_CALL OControlFontDialog::Create( const Reference< XComponentContext >& _rxContext )
+ {
+ return *( new OControlFontDialog( _rxContext ) );
+ }
+
+ //---------------------------------------------------------------------
+ ::rtl::OUString SAL_CALL OControlFontDialog::getImplementationName() throw(RuntimeException)
+ {
+ return getImplementationName_static();
+ }
+
+ //---------------------------------------------------------------------
+ ::rtl::OUString OControlFontDialog::getImplementationName_static() throw(RuntimeException)
+ {
+ return ::rtl::OUString::createFromAscii("org.openoffice.comp.form.ui.OControlFontDialog");
+ }
+
+ //---------------------------------------------------------------------
+ ::comphelper::StringSequence SAL_CALL OControlFontDialog::getSupportedServiceNames() throw(RuntimeException)
+ {
+ return getSupportedServiceNames_static();
+ }
+
+ //---------------------------------------------------------------------
+ ::comphelper::StringSequence OControlFontDialog::getSupportedServiceNames_static() throw(RuntimeException)
+ {
+ ::comphelper::StringSequence aSupported(1);
+ aSupported.getArray()[0] = ::rtl::OUString::createFromAscii("com.sun.star.form.ControlFontDialog");
+ return aSupported;
+ }
+
+ //---------------------------------------------------------------------
+ Reference<XPropertySetInfo> SAL_CALL OControlFontDialog::getPropertySetInfo() throw(RuntimeException)
+ {
+ Reference<XPropertySetInfo> xInfo( createPropertySetInfo( getInfoHelper() ) );
+ return xInfo;
+ }
+
+ //---------------------------------------------------------------------
+ ::cppu::IPropertyArrayHelper& OControlFontDialog::getInfoHelper()
+ {
+ return *const_cast<OControlFontDialog*>(this)->getArrayHelper();
+ }
+
+ //--------------------------------------------------------------------------
+ ::cppu::IPropertyArrayHelper* OControlFontDialog::createArrayHelper( ) const
+ {
+ Sequence< Property > aProps;
+ describeProperties(aProps);
+ return new ::cppu::OPropertyArrayHelper(aProps);
+ }
+
+ //--------------------------------------------------------------------------
+ Dialog* OControlFontDialog::createDialog(Window* _pParent)
+ {
+ ControlCharacterDialog::createItemSet(m_pFontItems, m_pItemPool, m_pItemPoolDefaults);
+
+ OSL_ENSURE(m_xControlModel.is(), "OControlFontDialog::createDialog: no introspectee set!");
+ if (m_xControlModel.is())
+ ControlCharacterDialog::translatePropertiesToItems(m_xControlModel, m_pFontItems);
+ // TODO: we need a mechanism to prevent that somebody creates us, sets an introspectee, executes us,
+ // sets a new introspectee and re-executes us. In this case, the dialog returned here (upon the first
+ // execute) will be re-used upon the second execute, and thus it won't be initialized correctly.
+
+ ControlCharacterDialog* pDialog = new ControlCharacterDialog(_pParent, *m_pFontItems);
+ return pDialog;
+ }
+
+ //-------------------------------------------------------------------------
+ void OControlFontDialog::destroyDialog()
+ {
+ OGenericUnoDialog::destroyDialog();
+ ControlCharacterDialog::destroyItemSet(m_pFontItems, m_pItemPool, m_pItemPoolDefaults);
+ }
+
+ //-------------------------------------------------------------------------
+ void OControlFontDialog::executedDialog(sal_Int16 _nExecutionResult)
+ {
+ OSL_ENSURE(m_pDialog, "OControlFontDialog::executedDialog: no dialog anymore?!!");
+ if (m_pDialog && (sal_True == _nExecutionResult) && m_xControlModel.is())
+ {
+ const SfxItemSet* pOutput = static_cast<ControlCharacterDialog*>(m_pDialog)->GetOutputItemSet();
+ if (pOutput)
+ ControlCharacterDialog::translateItemsToProperties( *pOutput, m_xControlModel );
+ }
+ }
+
+//........................................................................
+} // namespace pcr
+//........................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/propctrlr/controlfontdialog.hxx b/extensions/source/propctrlr/controlfontdialog.hxx
new file mode 100644
index 000000000000..555370d37623
--- /dev/null
+++ b/extensions/source/propctrlr/controlfontdialog.hxx
@@ -0,0 +1,102 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _EXTENSIONS_PROPCTRLR_CONTROLFONTDIALOG_HXX_
+#define _EXTENSIONS_PROPCTRLR_CONTROLFONTDIALOG_HXX_
+
+#include <svtools/genericunodialog.hxx>
+#include "modulepcr.hxx"
+
+class SfxItemSet;
+class SfxItemPool;
+class SfxPoolItem;
+//........................................................................
+namespace pcr
+{
+//........................................................................
+
+ //====================================================================
+ //= OControlFontDialog
+ //====================================================================
+ class OControlFontDialog;
+ typedef ::svt::OGenericUnoDialog OControlFontDialog_DBase;
+ typedef ::comphelper::OPropertyArrayUsageHelper< OControlFontDialog > OControlFontDialog_PBase;
+
+ class OControlFontDialog
+ :public OControlFontDialog_DBase
+ ,public OControlFontDialog_PBase
+ ,public PcrClient
+ {
+ protected:
+ // <properties>
+ ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >
+ m_xControlModel;
+ // </properties>
+
+ SfxItemSet* m_pFontItems; // item set for the dialog
+ SfxItemPool* m_pItemPool; // item pool for the item set for the dialog
+ SfxPoolItem** m_pItemPoolDefaults; // pool defaults
+
+ public:
+ OControlFontDialog(const com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext >& _rxContext);
+ ~OControlFontDialog();
+
+ // XTypeProvider
+ virtual ::com::sun::star::uno::Sequence<sal_Int8> SAL_CALL getImplementationId( ) throw(::com::sun::star::uno::RuntimeException);
+
+ // XServiceInfo
+ virtual ::rtl::OUString SAL_CALL getImplementationName() throw(::com::sun::star::uno::RuntimeException);
+ virtual ::comphelper::StringSequence SAL_CALL getSupportedServiceNames() throw(::com::sun::star::uno::RuntimeException);
+
+ // XServiceInfo - static methods
+ static ::com::sun::star::uno::Sequence< ::rtl::OUString > getSupportedServiceNames_static(void) throw( ::com::sun::star::uno::RuntimeException );
+ static ::rtl::OUString getImplementationName_static(void) throw( ::com::sun::star::uno::RuntimeException );
+ static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >
+ SAL_CALL Create(const ::com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext >&);
+
+ // XPropertySet
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo> SAL_CALL getPropertySetInfo() throw(::com::sun::star::uno::RuntimeException);
+ virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper();
+
+ // OPropertyArrayUsageHelper
+ virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const;
+
+ protected:
+ // OGenericUnoDialog overridables
+ virtual Dialog* createDialog(Window* _pParent);
+ virtual void destroyDialog();
+ virtual void executedDialog(sal_Int16 _nExecutionResult);
+ };
+
+//........................................................................
+} // namespace pcr
+//........................................................................
+
+#endif // _EXTENSIONS_PROPCTRLR_CONTROLFONTDIALOG_HXX_
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/propctrlr/controltype.hxx b/extensions/source/propctrlr/controltype.hxx
new file mode 100644
index 000000000000..c2c502449838
--- /dev/null
+++ b/extensions/source/propctrlr/controltype.hxx
@@ -0,0 +1,56 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef EXTENSIONS_SOURCE_PROPCTRLR_CONTROLTYPE_HXX
+#define EXTENSIONS_SOURCE_PROPCTRLR_CONTROLTYPE_HXX
+
+#include <sal/types.h>
+
+//........................................................................
+namespace pcr
+{
+//........................................................................
+
+ //====================================================================
+ //= control types, analogous to FormComponentType
+ //====================================================================
+ namespace ControlType
+ {
+ static const sal_Int16 FIXEDLINE = (sal_Int16)100;
+ static const sal_Int16 FORMATTEDFIELD = (sal_Int16)101;
+ static const sal_Int16 PROGRESSBAR = (sal_Int16)102;
+
+ // need only those which are not already covered as FormComponentType
+ }
+
+//........................................................................
+} // namespacepcr
+//........................................................................
+
+#endif // EXTENSIONS_SOURCE_PROPCTRLR_CONTROLTYPE_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/propctrlr/defaultforminspection.cxx b/extensions/source/propctrlr/defaultforminspection.cxx
new file mode 100644
index 000000000000..124941034d4c
--- /dev/null
+++ b/extensions/source/propctrlr/defaultforminspection.cxx
@@ -0,0 +1,267 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+#include "defaultforminspection.hxx"
+#include "pcrcommon.hxx"
+#include "propresid.hrc"
+#include "formresid.hrc"
+#include "modulepcr.hxx"
+#include "propctrlr.hrc"
+#include "formmetadata.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/ucb/AlreadyInitializedException.hpp>
+#include <com/sun/star/lang/IllegalArgumentException.hpp>
+/** === end UNO includes === **/
+#include <cppuhelper/implbase1.hxx>
+#include <osl/diagnose.h>
+#include <sal/macros.h>
+
+//------------------------------------------------------------------------
+extern "C" void SAL_CALL createRegistryInfo_DefaultFormComponentInspectorModel()
+{
+ ::pcr::OAutoRegistration< ::pcr::DefaultFormComponentInspectorModel > aAutoRegistration;
+}
+
+//........................................................................
+namespace pcr
+{
+//........................................................................
+
+ /** === begin UNO using === **/
+ using ::com::sun::star::uno::Reference;
+ using ::com::sun::star::uno::Sequence;
+ using ::com::sun::star::uno::Any;
+ using ::com::sun::star::uno::RuntimeException;
+ using ::com::sun::star::uno::XInterface;
+ using ::com::sun::star::uno::XComponentContext;
+ using ::com::sun::star::uno::Exception;
+ using ::com::sun::star::lang::EventObject;
+ using ::com::sun::star::inspection::PropertyCategoryDescriptor;
+ using ::com::sun::star::beans::UnknownPropertyException;
+ using ::com::sun::star::ucb::AlreadyInitializedException;
+ using ::com::sun::star::lang::IllegalArgumentException;
+ /** === end UNO using === **/
+
+ //====================================================================
+ //= DefaultFormComponentInspectorModel
+ //====================================================================
+ //--------------------------------------------------------------------
+ DefaultFormComponentInspectorModel::DefaultFormComponentInspectorModel( const Reference< XComponentContext >& _rxContext, bool _bUseFormFormComponentHandlers )
+ :ImplInspectorModel( _rxContext )
+ ,m_bUseFormComponentHandlers( _bUseFormFormComponentHandlers )
+ ,m_bConstructed( false )
+ ,m_pInfoService( new OPropertyInfoService )
+ {
+ }
+
+ //------------------------------------------------------------------------
+ DefaultFormComponentInspectorModel::~DefaultFormComponentInspectorModel()
+ {
+ }
+
+ //------------------------------------------------------------------------
+ ::rtl::OUString SAL_CALL DefaultFormComponentInspectorModel::getImplementationName( ) throw(RuntimeException)
+ {
+ return getImplementationName_static();
+ }
+
+ //------------------------------------------------------------------------
+ Sequence< ::rtl::OUString > SAL_CALL DefaultFormComponentInspectorModel::getSupportedServiceNames( ) throw(RuntimeException)
+ {
+ return getSupportedServiceNames_static();
+ }
+
+ //------------------------------------------------------------------------
+ ::rtl::OUString DefaultFormComponentInspectorModel::getImplementationName_static( ) throw(RuntimeException)
+ {
+ return ::rtl::OUString::createFromAscii( "org.openoffice.comp.extensions.DefaultFormComponentInspectorModel");
+ }
+
+ //------------------------------------------------------------------------
+ Sequence< ::rtl::OUString > DefaultFormComponentInspectorModel::getSupportedServiceNames_static( ) throw(RuntimeException)
+ {
+ Sequence< ::rtl::OUString > aSupported(1);
+ aSupported[0] = ::rtl::OUString::createFromAscii( "com.sun.star.form.inspection.DefaultFormComponentInspectorModel" );
+ return aSupported;
+ }
+
+ //------------------------------------------------------------------------
+ Reference< XInterface > SAL_CALL DefaultFormComponentInspectorModel::Create( const Reference< XComponentContext >& _rxContext )
+ {
+ return *new DefaultFormComponentInspectorModel( _rxContext );
+ }
+
+ //--------------------------------------------------------------------
+ Sequence< Any > SAL_CALL DefaultFormComponentInspectorModel::getHandlerFactories() throw (RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ // service names for all our handlers
+ struct
+ {
+ const sal_Char* serviceName;
+ bool isFormOnly;
+ } aFactories[] = {
+
+ // a generic handler for form component properties (must precede the ButtonNavigationHandler)
+ { "com.sun.star.form.inspection.FormComponentPropertyHandler", false },
+
+ // generic virtual edit properties
+ { "com.sun.star.form.inspection.EditPropertyHandler", false },
+
+ // a handler which virtualizes the ButtonType property, to provide additional types like
+ // "move to next record"
+ { "com.sun.star.form.inspection.ButtonNavigationHandler", false },
+
+ // a handler for script events bound to form components or dialog elements
+ { "com.sun.star.form.inspection.EventHandler", false },
+
+ // a handler which introduces virtual properties for binding controls to spreadsheet cells
+ { "com.sun.star.form.inspection.CellBindingPropertyHandler", false },
+
+ // properties related to binding to an XForms DOM node
+ { "com.sun.star.form.inspection.XMLFormsPropertyHandler", true },
+
+ // properties related to the XSD data against which a control content is validated
+ { "com.sun.star.form.inspection.XSDValidationPropertyHandler", true },
+
+ // a handler which cares for XForms submissions
+ { "com.sun.star.form.inspection.SubmissionPropertyHandler", true },
+
+ // a handler which cares for geometry properties of form controls
+ { "com.sun.star.form.inspection.FormGeometryHandler", true }
+ };
+
+ sal_Int32 nFactories = SAL_N_ELEMENTS( aFactories );
+ Sequence< Any > aReturn( nFactories );
+ Any* pReturn = aReturn.getArray();
+ for ( sal_Int32 i = 0; i < nFactories; ++i )
+ {
+ if ( aFactories[i].isFormOnly && !m_bUseFormComponentHandlers )
+ continue;
+ *pReturn++ <<= ::rtl::OUString::createFromAscii( aFactories[i].serviceName );
+ }
+ aReturn.realloc( pReturn - aReturn.getArray() );
+
+ return aReturn;
+ }
+
+ //--------------------------------------------------------------------
+ Sequence< PropertyCategoryDescriptor > SAL_CALL DefaultFormComponentInspectorModel::describeCategories( ) throw (RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ struct
+ {
+ const sal_Char* programmaticName;
+ USHORT uiNameResId;
+ sal_uInt32 helpId;
+ } aCategories[] = {
+ { "General", RID_STR_PROPPAGE_DEFAULT, HID_FM_PROPDLG_TAB_GENERAL },
+ { "Data", RID_STR_PROPPAGE_DATA, HID_FM_PROPDLG_TAB_DATA },
+ { "Events", RID_STR_EVENTS, HID_FM_PROPDLG_TAB_EVT }
+ };
+
+ sal_Int32 nCategories = SAL_N_ELEMENTS( aCategories );
+ Sequence< PropertyCategoryDescriptor > aReturn( nCategories );
+ PropertyCategoryDescriptor* pReturn = aReturn.getArray();
+ for ( sal_Int32 i=0; i<nCategories; ++i, ++pReturn )
+ {
+ pReturn->ProgrammaticName = ::rtl::OUString::createFromAscii( aCategories[i].programmaticName );
+ pReturn->UIName = String( PcrRes( aCategories[i].uiNameResId ) );
+ pReturn->HelpURL = HelpIdUrl::getHelpURL( aCategories[i].helpId );
+ }
+
+ return aReturn;
+ }
+
+ //--------------------------------------------------------------------
+ ::sal_Int32 SAL_CALL DefaultFormComponentInspectorModel::getPropertyOrderIndex( const ::rtl::OUString& _rPropertyName ) throw (RuntimeException)
+ {
+ sal_Int32 nPropertyId( m_pInfoService->getPropertyId( _rPropertyName ) );
+ if ( nPropertyId == -1 )
+ {
+ if ( _rPropertyName.indexOf( ';' ) != -1 )
+ // it's an event. Just give it an arbitrary number - events will be on a separate
+ // page, and by definition, if two properties have the same OrderIndex, then
+ // they will be ordered as they appear in the handler's getSupportedProperties.
+ return 1000;
+ return 0;
+ }
+ return m_pInfoService->getPropertyPos( nPropertyId );
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL DefaultFormComponentInspectorModel::initialize( const Sequence< Any >& _arguments ) throw (Exception, RuntimeException)
+ {
+ if ( m_bConstructed )
+ throw AlreadyInitializedException();
+
+ StlSyntaxSequence< Any > arguments( _arguments );
+ if ( arguments.empty() )
+ { // constructor: "createDefault()"
+ createDefault();
+ return;
+ }
+
+ sal_Int32 nMinHelpTextLines( 0 ), nMaxHelpTextLines( 0 );
+ if ( arguments.size() == 2 )
+ { // constructor: "createWithHelpSection( long, long )"
+ if ( !( arguments[0] >>= nMinHelpTextLines ) || !( arguments[1] >>= nMaxHelpTextLines ) )
+ throw IllegalArgumentException( ::rtl::OUString(), *this, 0 );
+ createWithHelpSection( nMinHelpTextLines, nMaxHelpTextLines );
+ return;
+ }
+
+ throw IllegalArgumentException( ::rtl::OUString(), *this, 0 );
+ }
+
+ //--------------------------------------------------------------------
+ void DefaultFormComponentInspectorModel::createDefault()
+ {
+ m_bConstructed = true;
+ }
+
+ //--------------------------------------------------------------------
+ void DefaultFormComponentInspectorModel::createWithHelpSection( sal_Int32 _nMinHelpTextLines, sal_Int32 _nMaxHelpTextLines )
+ {
+ if ( ( _nMinHelpTextLines <= 0 ) || ( _nMaxHelpTextLines <= 0 ) || ( _nMinHelpTextLines > _nMaxHelpTextLines ) )
+ throw IllegalArgumentException( ::rtl::OUString(), *this, 0 );
+
+ enableHelpSectionProperties( _nMinHelpTextLines, _nMaxHelpTextLines );
+ m_bConstructed = true;
+ }
+
+//........................................................................
+} // namespace pcr
+//........................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/propctrlr/defaultforminspection.hxx b/extensions/source/propctrlr/defaultforminspection.hxx
new file mode 100644
index 000000000000..9fe1cd3972b2
--- /dev/null
+++ b/extensions/source/propctrlr/defaultforminspection.hxx
@@ -0,0 +1,93 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef EXTENSIONS_SOURCE_PROPCTRLR_DEFAULTFORMINSPECTION_HXX
+#define EXTENSIONS_SOURCE_PROPCTRLR_DEFAULTFORMINSPECTION_HXX
+
+#include "inspectormodelbase.hxx"
+
+/** === begin UNO includes === **/
+/** === end UNO includes === **/
+
+#include <memory>
+
+//........................................................................
+namespace pcr
+{
+//........................................................................
+
+ class OPropertyInfoService;
+ //====================================================================
+ //= DefaultFormComponentInspectorModel
+ //====================================================================
+ class DefaultFormComponentInspectorModel : public ImplInspectorModel
+ {
+ private:
+ bool m_bUseFormComponentHandlers;
+ bool m_bConstructed;
+
+ /// access to property meta data
+ ::std::auto_ptr< OPropertyInfoService > m_pInfoService;
+
+ protected:
+ ~DefaultFormComponentInspectorModel();
+
+ // XServiceInfo
+ virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw(::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw(::com::sun::star::uno::RuntimeException);
+
+ // XObjectInspectorModel
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > SAL_CALL getHandlerFactories() throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::inspection::PropertyCategoryDescriptor > SAL_CALL describeCategories( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::sal_Int32 SAL_CALL getPropertyOrderIndex( const ::rtl::OUString& PropertyName ) throw (::com::sun::star::uno::RuntimeException);
+
+ // 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);
+
+ public:
+ // XServiceInfo - static versions
+ static ::rtl::OUString getImplementationName_static( ) throw(::com::sun::star::uno::RuntimeException);
+ static ::com::sun::star::uno::Sequence< ::rtl::OUString > getSupportedServiceNames_static( ) throw(::com::sun::star::uno::RuntimeException);
+ static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL
+ Create(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >&);
+
+ public:
+ DefaultFormComponentInspectorModel( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _rxContext, bool _bUseFormFormComponentHandlers = true );
+
+ protected:
+ // Service constructors
+ void createDefault();
+ void createWithHelpSection( sal_Int32 _nMinHelpTextLines, sal_Int32 _nMaxHelpTextLines );
+ };
+
+//........................................................................
+} // namespace pcr
+//........................................................................
+
+#endif // EXTENSIONS_SOURCE_PROPCTRLR_DEFAULTFORMINSPECTION_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/propctrlr/defaulthelpprovider.cxx b/extensions/source/propctrlr/defaulthelpprovider.cxx
new file mode 100644
index 000000000000..290450050ec3
--- /dev/null
+++ b/extensions/source/propctrlr/defaulthelpprovider.cxx
@@ -0,0 +1,209 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+
+#include "defaulthelpprovider.hxx"
+#include "pcrcommon.hxx"
+#include "modulepcr.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/ucb/AlreadyInitializedException.hpp>
+#include <com/sun/star/lang/IllegalArgumentException.hpp>
+#include <com/sun/star/awt/XVclWindowPeer.hpp>
+/** === end UNO includes === **/
+
+#include <toolkit/helper/vclunohelper.hxx>
+#include <vcl/window.hxx>
+#include <tools/diagnose_ex.h>
+
+//------------------------------------------------------------------------
+extern "C" void SAL_CALL createRegistryInfo_DefaultHelpProvider()
+{
+ ::pcr::OAutoRegistration< ::pcr::DefaultHelpProvider > aAutoRegistration;
+}
+
+//........................................................................
+namespace pcr
+{
+//........................................................................
+
+ /** === begin UNO using === **/
+ using ::com::sun::star::uno::Reference;
+ using ::com::sun::star::uno::XComponentContext;
+ using ::com::sun::star::inspection::XPropertyControl;
+ using ::com::sun::star::uno::RuntimeException;
+ using ::com::sun::star::uno::Sequence;
+ using ::com::sun::star::uno::Any;
+ using ::com::sun::star::uno::Exception;
+ using ::com::sun::star::inspection::XObjectInspectorUI;
+ using ::com::sun::star::uno::XInterface;
+ using ::com::sun::star::ucb::AlreadyInitializedException;
+ using ::com::sun::star::lang::IllegalArgumentException;
+ using ::com::sun::star::uno::UNO_QUERY;
+ using ::com::sun::star::uno::UNO_QUERY_THROW;
+ using ::com::sun::star::awt::XWindow;
+ using ::com::sun::star::awt::XVclWindowPeer;
+ /** === end UNO using === **/
+
+ //====================================================================
+ //= DefaultHelpProvider
+ //====================================================================
+ //--------------------------------------------------------------------
+ DefaultHelpProvider::DefaultHelpProvider( const Reference< XComponentContext >& _rxContext )
+ :m_aContext( _rxContext )
+ ,m_bConstructed( false )
+ {
+ }
+
+ //--------------------------------------------------------------------
+ DefaultHelpProvider::~DefaultHelpProvider()
+ {
+ }
+
+ //------------------------------------------------------------------------
+ ::rtl::OUString DefaultHelpProvider::getImplementationName_static( ) throw(RuntimeException)
+ {
+ return ::rtl::OUString::createFromAscii( "org.openoffice.comp.extensions.DefaultHelpProvider");
+ }
+
+ //------------------------------------------------------------------------
+ Sequence< ::rtl::OUString > DefaultHelpProvider::getSupportedServiceNames_static( ) throw(RuntimeException)
+ {
+ Sequence< ::rtl::OUString > aSupported(1);
+ aSupported[0] = ::rtl::OUString::createFromAscii( "com.sun.star.inspection.DefaultHelpProvider" );
+ return aSupported;
+ }
+
+ //------------------------------------------------------------------------
+ Reference< XInterface > SAL_CALL DefaultHelpProvider::Create( const Reference< XComponentContext >& _rxContext )
+ {
+ return *new DefaultHelpProvider( _rxContext );
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL DefaultHelpProvider::focusGained( const Reference< XPropertyControl >& _Control ) throw (RuntimeException)
+ {
+ if ( !m_xInspectorUI.is() )
+ throw RuntimeException( ::rtl::OUString(), *this );
+
+ try
+ {
+ m_xInspectorUI->setHelpSectionText( impl_getHelpText_nothrow( _Control ) );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL DefaultHelpProvider::valueChanged( const Reference< XPropertyControl >& /*_Control*/ ) throw (RuntimeException)
+ {
+ // not interested in
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL DefaultHelpProvider::initialize( const Sequence< Any >& _arguments ) throw (Exception, RuntimeException)
+ {
+ if ( m_bConstructed )
+ throw AlreadyInitializedException();
+
+ StlSyntaxSequence< Any > arguments( _arguments );
+ if ( arguments.size() == 1 )
+ { // constructor: "create( XObjectInspectorUI )"
+ Reference< XObjectInspectorUI > xUI( arguments[0], UNO_QUERY );
+ create( xUI );
+ return;
+ }
+
+ throw IllegalArgumentException( ::rtl::OUString(), *this, 0 );
+ }
+
+ //--------------------------------------------------------------------
+ void DefaultHelpProvider::create( const Reference< XObjectInspectorUI >& _rxUI )
+ {
+ if ( !_rxUI.is() )
+ throw IllegalArgumentException( ::rtl::OUString(), *this, 1 );
+
+ try
+ {
+ m_xInspectorUI = _rxUI;
+ m_xInspectorUI->registerControlObserver( this );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+ m_bConstructed = true;
+ }
+
+ //--------------------------------------------------------------------
+ Window* DefaultHelpProvider::impl_getVclControlWindow_nothrow( const Reference< XPropertyControl >& _rxControl )
+ {
+ Window* pControlWindow = NULL;
+ OSL_PRECOND( _rxControl.is(), "DefaultHelpProvider::impl_getVclControlWindow_nothrow: illegal control!" );
+ if ( !_rxControl.is() )
+ return pControlWindow;
+
+ try
+ {
+ Reference< XWindow > xControlWindow( _rxControl->getControlWindow(), UNO_QUERY_THROW );
+ pControlWindow = VCLUnoHelper::GetWindow( xControlWindow );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+ return pControlWindow;
+ }
+
+ //--------------------------------------------------------------------
+ ::rtl::OUString DefaultHelpProvider::impl_getHelpText_nothrow( const Reference< XPropertyControl >& _rxControl )
+ {
+ ::rtl::OUString sHelpText;
+ OSL_PRECOND( _rxControl.is(), "DefaultHelpProvider::impl_getHelpText_nothrow: illegal control!" );
+ if ( !_rxControl.is() )
+ return sHelpText;
+
+ Window* pControlWindow( impl_getVclControlWindow_nothrow( _rxControl ) );
+ OSL_ENSURE( pControlWindow, "DefaultHelpProvider::impl_getHelpText_nothrow: could not determine the VCL window!" );
+ if ( !pControlWindow )
+ return sHelpText;
+
+ sHelpText = pControlWindow->GetHelpText();
+ return sHelpText;
+ }
+//........................................................................
+} // namespace pcr
+//........................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/propctrlr/defaulthelpprovider.hxx b/extensions/source/propctrlr/defaulthelpprovider.hxx
new file mode 100644
index 000000000000..625521660240
--- /dev/null
+++ b/extensions/source/propctrlr/defaulthelpprovider.hxx
@@ -0,0 +1,96 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef EXTENSIONS_DEFAULTHELPPROVIDER_HXX
+#define EXTENSIONS_DEFAULTHELPPROVIDER_HXX
+
+/** === begin UNO includes === **/
+#include <com/sun/star/inspection/XPropertyControlObserver.hpp>
+#include <com/sun/star/lang/XInitialization.hpp>
+#include <com/sun/star/inspection/XObjectInspectorUI.hpp>
+/** === end UNO includes === **/
+
+#include <cppuhelper/implbase2.hxx>
+#include <comphelper/componentcontext.hxx>
+
+class Window;
+
+//........................................................................
+namespace pcr
+{
+//........................................................................
+
+ //====================================================================
+ //= DefaultHelpProvider
+ //====================================================================
+ typedef ::cppu::WeakImplHelper2 < ::com::sun::star::inspection::XPropertyControlObserver
+ , ::com::sun::star::lang::XInitialization
+ > DefaultHelpProvider_Base;
+ class DefaultHelpProvider : public DefaultHelpProvider_Base
+ {
+ private:
+ ::comphelper::ComponentContext m_aContext;
+ bool m_bConstructed;
+ ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XObjectInspectorUI >
+ m_xInspectorUI;
+
+ public:
+ DefaultHelpProvider( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _rxContext );
+
+ // XServiceInfo - static versions
+ static ::rtl::OUString getImplementationName_static( ) throw(::com::sun::star::uno::RuntimeException);
+ static ::com::sun::star::uno::Sequence< ::rtl::OUString > getSupportedServiceNames_static( ) throw(::com::sun::star::uno::RuntimeException);
+ static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL
+ Create(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >&);
+
+ protected:
+ ~DefaultHelpProvider();
+
+ // XPropertyControlObserver
+ virtual void SAL_CALL focusGained( const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyControl >& Control ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL valueChanged( const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyControl >& Control ) throw (::com::sun::star::uno::RuntimeException);
+
+ // 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);
+
+ protected:
+ // Service constructors
+ void create( const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XObjectInspectorUI >& _rxUI );
+
+ private:
+ Window* impl_getVclControlWindow_nothrow( const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyControl >& _rxControl );
+ ::rtl::OUString impl_getHelpText_nothrow( const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyControl >& _rxControl );
+ };
+
+//........................................................................
+} // namespace pcr
+//........................................................................
+
+#endif // EXTENSIONS_DEFAULTHELPPROVIDER_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/propctrlr/editpropertyhandler.cxx b/extensions/source/propctrlr/editpropertyhandler.cxx
new file mode 100644
index 000000000000..f57b62039da5
--- /dev/null
+++ b/extensions/source/propctrlr/editpropertyhandler.cxx
@@ -0,0 +1,325 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+#include "editpropertyhandler.hxx"
+#include "formstrings.hxx"
+#include "formmetadata.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/inspection/XObjectInspectorUI.hpp>
+/** === end UNO includes === **/
+#include <tools/debug.hxx>
+
+#define TEXTTYPE_SINGLELINE 0
+#define TEXTTYPE_MULTILINE 1
+#define TEXTTYPE_RICHTEXT 2
+
+//------------------------------------------------------------------------
+extern "C" void SAL_CALL createRegistryInfo_EditPropertyHandler()
+{
+ ::pcr::EditPropertyHandler::registerImplementation();
+}
+
+//........................................................................
+namespace pcr
+{
+//........................................................................
+
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::lang;
+ using namespace ::com::sun::star::beans;
+ using namespace ::com::sun::star::script;
+ using namespace ::com::sun::star::frame;
+ using namespace ::com::sun::star::inspection;
+
+ //====================================================================
+ //= EditPropertyHandler
+ //====================================================================
+ DBG_NAME( EditPropertyHandler )
+ //--------------------------------------------------------------------
+ EditPropertyHandler::EditPropertyHandler( const Reference< XComponentContext >& _rxContext )
+ :EditPropertyHandler_Base( _rxContext )
+ {
+ DBG_CTOR( EditPropertyHandler, NULL );
+ }
+
+ //--------------------------------------------------------------------
+ EditPropertyHandler::~EditPropertyHandler( )
+ {
+ DBG_DTOR( EditPropertyHandler, NULL );
+ }
+
+ //--------------------------------------------------------------------
+ ::rtl::OUString SAL_CALL EditPropertyHandler::getImplementationName_static( ) throw (RuntimeException)
+ {
+ return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.extensions.EditPropertyHandler" ) );
+ }
+
+ //--------------------------------------------------------------------
+ Sequence< ::rtl::OUString > SAL_CALL EditPropertyHandler::getSupportedServiceNames_static( ) throw (RuntimeException)
+ {
+ Sequence< ::rtl::OUString > aSupported( 1 );
+ aSupported[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.form.inspection.EditPropertyHandler" ) );
+ return aSupported;
+ }
+
+ //--------------------------------------------------------------------
+ Any SAL_CALL EditPropertyHandler::getPropertyValue( const ::rtl::OUString& _rPropertyName ) throw (UnknownPropertyException, RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ PropertyId nPropId( impl_getPropertyId_throw( _rPropertyName ) );
+
+ Any aReturn;
+ try
+ {
+ switch ( nPropId )
+ {
+ case PROPERTY_ID_SHOW_SCROLLBARS:
+ {
+ sal_Bool bHasVScroll = sal_False;
+ m_xComponent->getPropertyValue( PROPERTY_VSCROLL ) >>= bHasVScroll;
+ sal_Bool bHasHScroll = sal_False;
+ m_xComponent->getPropertyValue( PROPERTY_HSCROLL ) >>= bHasHScroll;
+
+ aReturn <<= (sal_Int32)( ( bHasVScroll ? 2 : 0 ) + ( bHasHScroll ? 1 : 0 ) );
+ }
+ break;
+
+ case PROPERTY_ID_TEXTTYPE:
+ {
+ sal_Int32 nTextType = TEXTTYPE_SINGLELINE;
+ sal_Bool bRichText = sal_False;
+ OSL_VERIFY( m_xComponent->getPropertyValue( PROPERTY_RICHTEXT ) >>= bRichText );
+ if ( bRichText )
+ nTextType = TEXTTYPE_RICHTEXT;
+ else
+ {
+ sal_Bool bMultiLine = sal_False;
+ OSL_VERIFY( m_xComponent->getPropertyValue( PROPERTY_MULTILINE ) >>= bMultiLine );
+ if ( bMultiLine )
+ nTextType = TEXTTYPE_MULTILINE;
+ else
+ nTextType = TEXTTYPE_SINGLELINE;
+ }
+ aReturn <<= nTextType;
+ }
+ break;
+
+
+ default:
+ DBG_ERROR( "EditPropertyHandler::getPropertyValue: cannot handle this property!" );
+ break;
+ }
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "EditPropertyHandler::getPropertyValue: caught an exception!" );
+ }
+
+ return aReturn;
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL EditPropertyHandler::setPropertyValue( const ::rtl::OUString& _rPropertyName, const Any& _rValue ) throw (UnknownPropertyException, RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ PropertyId nPropId( impl_getPropertyId_throw( _rPropertyName ) );
+
+ try
+ {
+ switch ( nPropId )
+ {
+ case PROPERTY_ID_SHOW_SCROLLBARS:
+ {
+ sal_Int32 nScrollbars = 0;
+ _rValue >>= nScrollbars;
+
+ sal_Bool bHasVScroll = 0 != ( nScrollbars & 2 );
+ sal_Bool bHasHScroll = 0 != ( nScrollbars & 1 );
+
+ m_xComponent->setPropertyValue( PROPERTY_VSCROLL, makeAny( (sal_Bool)bHasVScroll ) );
+ m_xComponent->setPropertyValue( PROPERTY_HSCROLL, makeAny( (sal_Bool)bHasHScroll ) );
+ }
+ break;
+
+ case PROPERTY_ID_TEXTTYPE:
+ {
+ sal_Bool bMultiLine = sal_False;
+ sal_Bool bRichText = sal_False;
+ sal_Int32 nTextType = TEXTTYPE_SINGLELINE;
+ OSL_VERIFY( _rValue >>= nTextType );
+ switch ( nTextType )
+ {
+ case TEXTTYPE_SINGLELINE: bMultiLine = bRichText = sal_False; break;
+ case TEXTTYPE_MULTILINE: bMultiLine = sal_True; bRichText = sal_False; break;
+ case TEXTTYPE_RICHTEXT: bMultiLine = sal_True; bRichText = sal_True; break;
+ default:
+ OSL_ENSURE( sal_False, "EditPropertyHandler::setPropertyValue: invalid text type!" );
+ }
+
+ m_xComponent->setPropertyValue( PROPERTY_MULTILINE, makeAny( bMultiLine ) );
+ m_xComponent->setPropertyValue( PROPERTY_RICHTEXT, makeAny( bRichText ) );
+ }
+ break;
+
+ default:
+ OSL_ENSURE( sal_False, "EditPropertyHandler::setPropertyValue: cannot handle this id!" );
+ }
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "EditPropertyHandler::setPropertyValue: caught an exception!" );
+ }
+ }
+
+ //--------------------------------------------------------------------
+ bool EditPropertyHandler::implHaveBothScrollBarProperties() const
+ {
+ // have a "Scrollbars" property if the object supports both "HScroll" and "VScroll"
+ Reference< XPropertySetInfo > xPSI;
+ if ( m_xComponent.is() )
+ xPSI = m_xComponent->getPropertySetInfo();
+
+ return xPSI.is()
+ && xPSI->hasPropertyByName( PROPERTY_HSCROLL )
+ && xPSI->hasPropertyByName( PROPERTY_VSCROLL );
+ }
+
+ //--------------------------------------------------------------------
+ bool EditPropertyHandler::implHaveTextTypeProperty() const
+ {
+ // have a "Scrollbars" property if the object supports both "HScroll" and "VScroll"
+ Reference< XPropertySetInfo > xPSI;
+ if ( m_xComponent.is() )
+ xPSI = m_xComponent->getPropertySetInfo();
+
+ return xPSI.is()
+ && xPSI->hasPropertyByName( PROPERTY_RICHTEXT )
+ && xPSI->hasPropertyByName( PROPERTY_MULTILINE );
+ }
+
+ //--------------------------------------------------------------------
+ Sequence< Property > SAL_CALL EditPropertyHandler::doDescribeSupportedProperties() const
+ {
+ ::std::vector< Property > aProperties;
+
+ if ( implHaveBothScrollBarProperties() )
+ addInt32PropertyDescription( aProperties, PROPERTY_SHOW_SCROLLBARS );
+
+ if ( implHaveTextTypeProperty() )
+ addInt32PropertyDescription( aProperties, PROPERTY_TEXTTYPE );
+
+ if ( aProperties.empty() )
+ return Sequence< Property >();
+ return Sequence< Property >( &(*aProperties.begin()), aProperties.size() );
+ }
+
+ //--------------------------------------------------------------------
+ Sequence< ::rtl::OUString > SAL_CALL EditPropertyHandler::getSupersededProperties( ) throw (RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ ::std::vector< ::rtl::OUString > aSuperseded;
+ if ( implHaveBothScrollBarProperties() )
+ {
+ aSuperseded.push_back( PROPERTY_HSCROLL );
+ aSuperseded.push_back( PROPERTY_VSCROLL );
+ }
+ if ( implHaveTextTypeProperty() )
+ {
+ aSuperseded.push_back( PROPERTY_RICHTEXT );
+ aSuperseded.push_back( PROPERTY_MULTILINE );
+ }
+ if ( aSuperseded.empty() )
+ return Sequence< ::rtl::OUString >();
+ return Sequence< ::rtl::OUString >( &(*aSuperseded.begin()), aSuperseded.size() );
+ }
+
+ //--------------------------------------------------------------------
+ Sequence< ::rtl::OUString > SAL_CALL EditPropertyHandler::getActuatingProperties( ) throw (RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ ::std::vector< ::rtl::OUString > aInterestingActuatingProps;
+ if ( implHaveTextTypeProperty() )
+ aInterestingActuatingProps.push_back( PROPERTY_TEXTTYPE );
+ aInterestingActuatingProps.push_back( PROPERTY_MULTILINE );
+ return Sequence< ::rtl::OUString >( &(*aInterestingActuatingProps.begin()), aInterestingActuatingProps.size() );;
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL EditPropertyHandler::actuatingPropertyChanged( const ::rtl::OUString& _rActuatingPropertyName, const Any& _rNewValue, const Any& /*_rOldValue*/, const Reference< XObjectInspectorUI >& _rxInspectorUI, sal_Bool ) throw (NullPointerException, RuntimeException)
+ {
+ if ( !_rxInspectorUI.is() )
+ throw NullPointerException();
+
+ ::osl::MutexGuard aGuard( m_aMutex );
+ PropertyId nActuatingPropId( impl_getPropertyId_throw( _rActuatingPropertyName ) );
+ switch ( nActuatingPropId )
+ {
+ case PROPERTY_ID_TEXTTYPE:
+ {
+ sal_Int32 nTextType = TEXTTYPE_SINGLELINE;
+ getPropertyValue( PROPERTY_TEXTTYPE ) >>= nTextType;
+
+ if ( impl_isSupportedProperty_nothrow( PROPERTY_ID_WORDBREAK ) )
+ _rxInspectorUI->enablePropertyUI( PROPERTY_WORDBREAK, nTextType == TEXTTYPE_RICHTEXT );
+ _rxInspectorUI->enablePropertyUI( PROPERTY_MAXTEXTLEN, nTextType != TEXTTYPE_RICHTEXT );
+ _rxInspectorUI->enablePropertyUI( PROPERTY_ECHO_CHAR, nTextType == TEXTTYPE_SINGLELINE );
+ _rxInspectorUI->enablePropertyUI( PROPERTY_FONT, nTextType != TEXTTYPE_RICHTEXT );
+ _rxInspectorUI->enablePropertyUI( PROPERTY_ALIGN, nTextType != TEXTTYPE_RICHTEXT );
+ _rxInspectorUI->enablePropertyUI( PROPERTY_DEFAULT_TEXT, nTextType != TEXTTYPE_RICHTEXT );
+ _rxInspectorUI->enablePropertyUI( PROPERTY_SHOW_SCROLLBARS, nTextType != TEXTTYPE_SINGLELINE );
+ _rxInspectorUI->enablePropertyUI( PROPERTY_LINEEND_FORMAT, nTextType != TEXTTYPE_SINGLELINE );
+ _rxInspectorUI->enablePropertyUI( PROPERTY_VERTICAL_ALIGN, nTextType == TEXTTYPE_SINGLELINE );
+
+ _rxInspectorUI->showCategory( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Data" ) ), nTextType != TEXTTYPE_RICHTEXT );
+ }
+ break;
+
+ case PROPERTY_ID_MULTILINE:
+ {
+ sal_Bool bIsMultiline = sal_False;
+ _rNewValue >>= bIsMultiline;
+
+ _rxInspectorUI->enablePropertyUI( PROPERTY_SHOW_SCROLLBARS, bIsMultiline );
+ _rxInspectorUI->enablePropertyUI( PROPERTY_ECHO_CHAR, !bIsMultiline );
+ _rxInspectorUI->enablePropertyUI( PROPERTY_LINEEND_FORMAT, bIsMultiline );
+ }
+ break;
+
+ default:
+ OSL_ENSURE( sal_False, "EditPropertyHandler::actuatingPropertyChanged: cannot handle this id!" );
+ }
+ }
+
+//........................................................................
+} // namespace pcr
+//........................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/propctrlr/editpropertyhandler.hxx b/extensions/source/propctrlr/editpropertyhandler.hxx
new file mode 100644
index 000000000000..8035cc8938db
--- /dev/null
+++ b/extensions/source/propctrlr/editpropertyhandler.hxx
@@ -0,0 +1,84 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef EXTENSIONS_SOURCE_PROPCTRLR_EDITPROPERTYHANDLER_HXX
+#define EXTENSIONS_SOURCE_PROPCTRLR_EDITPROPERTYHANDLER_HXX
+
+#include "propertyhandler.hxx"
+
+/** === begin UNO includes === **/
+/** === end UNO includes === **/
+
+//........................................................................
+namespace pcr
+{
+//........................................................................
+
+ //====================================================================
+ //= EditPropertyHandler
+ //====================================================================
+ class EditPropertyHandler;
+ typedef HandlerComponentBase< EditPropertyHandler > EditPropertyHandler_Base;
+ /** a property handler for any virtual string properties
+ */
+ class EditPropertyHandler : public EditPropertyHandler_Base
+ {
+ public:
+ EditPropertyHandler(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _rxContext
+ );
+
+ static ::rtl::OUString SAL_CALL getImplementationName_static( ) throw (::com::sun::star::uno::RuntimeException);
+ static ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames_static( ) throw (::com::sun::star::uno::RuntimeException);
+
+ protected:
+ ~EditPropertyHandler();
+
+ protected:
+ // XPropertyHandler overriables
+ virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue( const ::rtl::OUString& _rPropertyName ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setPropertyValue( const ::rtl::OUString& _rPropertyName, const ::com::sun::star::uno::Any& _rValue ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupersededProperties( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getActuatingProperties( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL actuatingPropertyChanged( const ::rtl::OUString& _rActuatingPropertyName, const ::com::sun::star::uno::Any& _rNewValue, const ::com::sun::star::uno::Any& _rOldValue, const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XObjectInspectorUI >& _rxInspectorUI, sal_Bool ) throw (::com::sun::star::lang::NullPointerException, ::com::sun::star::uno::RuntimeException);
+
+ // PropertyHandler overridables
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property >
+ SAL_CALL doDescribeSupportedProperties() const;
+ private:
+ bool implHaveBothScrollBarProperties() const;
+ bool implHaveTextTypeProperty() const;
+ };
+
+//........................................................................
+} // namespace pcr
+//........................................................................
+
+#endif // EXTENSIONS_SOURCE_PROPCTRLR_EDITPROPERTYHANDLER_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/propctrlr/eformshelper.cxx b/extensions/source/propctrlr/eformshelper.cxx
new file mode 100644
index 000000000000..9a356d452c1b
--- /dev/null
+++ b/extensions/source/propctrlr/eformshelper.cxx
@@ -0,0 +1,788 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+#include "eformshelper.hxx"
+#include "formstrings.hxx"
+#include "formresid.hrc"
+#include "modulepcr.hxx"
+#include "propeventtranslation.hxx"
+#include "formbrowsertools.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/form/FormComponentType.hpp>
+#include <com/sun/star/xforms/XFormsUIHelper1.hpp>
+#include <com/sun/star/xsd/DataTypeClass.hpp>
+#include <com/sun/star/form/binding/XListEntrySink.hpp>
+/** === end UNO includes === **/
+#include <tools/diagnose_ex.h>
+#include <rtl/ustrbuf.hxx>
+
+#include <functional>
+#include <algorithm>
+
+//........................................................................
+namespace pcr
+{
+//........................................................................
+
+ using namespace ::com::sun::star;
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::beans;
+ using namespace ::com::sun::star::container;
+ using namespace ::com::sun::star::form::binding;
+ using namespace ::com::sun::star::xsd;
+ using namespace ::com::sun::star::lang;
+ using namespace ::com::sun::star::form;
+
+ //====================================================================
+ //= file-local helpers
+ //====================================================================
+ namespace
+ {
+ //--------------------------------------------------------------------
+ ::rtl::OUString composeModelElementUIName( const ::rtl::OUString& _rModelName, const ::rtl::OUString& _rElementName )
+ {
+ ::rtl::OUStringBuffer aBuffer;
+ aBuffer.appendAscii( "[" );
+ aBuffer.append( _rModelName );
+ aBuffer.appendAscii( "] " );
+ aBuffer.append( _rElementName );
+ return aBuffer.makeStringAndClear();
+ }
+ }
+
+ //====================================================================
+ //= EFormsHelper
+ //====================================================================
+ //--------------------------------------------------------------------
+ EFormsHelper::EFormsHelper( ::osl::Mutex& _rMutex, const Reference< XPropertySet >& _rxControlModel, const Reference< frame::XModel >& _rxContextDocument )
+ :m_xControlModel( _rxControlModel )
+ ,m_aPropertyListeners( _rMutex )
+ {
+ OSL_ENSURE( _rxControlModel.is(), "EFormsHelper::EFormsHelper: invalid control model!" );
+ m_xBindableControl = m_xBindableControl.query( _rxControlModel );
+
+ m_xDocument = m_xDocument.query( _rxContextDocument );
+ OSL_ENSURE( m_xDocument.is(), "EFormsHelper::EFormsHelper: invalid document!" );
+
+ }
+
+ //--------------------------------------------------------------------
+ bool EFormsHelper::isEForm( const Reference< frame::XModel >& _rxContextDocument )
+ {
+ try
+ {
+ Reference< xforms::XFormsSupplier > xDocument( _rxContextDocument, UNO_QUERY );
+ if ( !xDocument.is() )
+ return false;
+
+ return xDocument->getXForms().is();
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "EFormsHelper::isEForm: caught an exception!" );
+ }
+ return false;
+ }
+
+ //--------------------------------------------------------------------
+ bool EFormsHelper::canBindToDataType( sal_Int32 _nDataType ) const SAL_THROW(())
+ {
+ if ( !m_xBindableControl.is() )
+ // cannot bind at all
+ return false;
+
+ // some types cannot be bound, independent from the control type
+ if ( ( DataTypeClass::hexBinary == _nDataType )
+ || ( DataTypeClass::base64Binary == _nDataType )
+ || ( DataTypeClass::QName == _nDataType )
+ || ( DataTypeClass::NOTATION == _nDataType )
+ )
+ return false;
+
+ bool bCan = false;
+ try
+ {
+ // classify the control model
+ sal_Int16 nControlType = FormComponentType::CONTROL;
+ OSL_VERIFY( m_xControlModel->getPropertyValue( PROPERTY_CLASSID ) >>= nControlType );
+
+ // some lists
+ sal_Int16 nNumericCompatibleTypes[] = { DataTypeClass::DECIMAL, DataTypeClass::FLOAT, DataTypeClass::DOUBLE, 0 };
+ sal_Int16 nDateCompatibleTypes[] = { DataTypeClass::DATE, 0 };
+ sal_Int16 nTimeCompatibleTypes[] = { DataTypeClass::TIME, 0 };
+ sal_Int16 nCheckboxCompatibleTypes[] = { DataTypeClass::BOOLEAN, DataTypeClass::STRING, DataTypeClass::anyURI, 0 };
+ sal_Int16 nRadiobuttonCompatibleTypes[] = { DataTypeClass::STRING, DataTypeClass::anyURI, 0 };
+ sal_Int16 nFormattedCompatibleTypes[] = { DataTypeClass::DECIMAL, DataTypeClass::FLOAT, DataTypeClass::DOUBLE, DataTypeClass::DATETIME, DataTypeClass::DATE, DataTypeClass::TIME, 0 };
+
+ sal_Int16* pCompatibleTypes = NULL;
+ switch ( nControlType )
+ {
+ case FormComponentType::SPINBUTTON:
+ case FormComponentType::NUMERICFIELD:
+ pCompatibleTypes = nNumericCompatibleTypes;
+ break;
+ case FormComponentType::DATEFIELD:
+ pCompatibleTypes = nDateCompatibleTypes;
+ break;
+ case FormComponentType::TIMEFIELD:
+ pCompatibleTypes = nTimeCompatibleTypes;
+ break;
+ case FormComponentType::CHECKBOX:
+ pCompatibleTypes = nCheckboxCompatibleTypes;
+ break;
+ case FormComponentType::RADIOBUTTON:
+ pCompatibleTypes = nRadiobuttonCompatibleTypes;
+ break;
+
+ case FormComponentType::TEXTFIELD:
+ {
+ // both the normal text field, and the formatted field, claim to be a TEXTFIELD
+ // need to distinguish by service name
+ Reference< XServiceInfo > xSI( m_xControlModel, UNO_QUERY );
+ OSL_ENSURE( xSI.is(), "EFormsHelper::canBindToDataType: a control model which has no service info?" );
+ if ( xSI.is() )
+ {
+ if ( xSI->supportsService( SERVICE_COMPONENT_FORMATTEDFIELD ) )
+ {
+ pCompatibleTypes = nFormattedCompatibleTypes;
+ break;
+ }
+ }
+ // NO break here!
+ }
+ case FormComponentType::LISTBOX:
+ case FormComponentType::COMBOBOX:
+ // edit fields and list/combo boxes can be bound to anything
+ bCan = true;
+ }
+
+ if ( !bCan && pCompatibleTypes )
+ {
+ if ( _nDataType == -1 )
+ {
+ // the control can be bound to at least one type, and exactly this is being asked for
+ bCan = true;
+ }
+ else
+ {
+ while ( *pCompatibleTypes && !bCan )
+ bCan = ( *pCompatibleTypes++ == _nDataType );
+ }
+ }
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "EFormsHelper::canBindToDataType: caught an exception!" );
+ }
+
+ return bCan;
+ }
+
+ //--------------------------------------------------------------------
+ bool EFormsHelper::isListEntrySink() const SAL_THROW(())
+ {
+ bool bIs = false;
+ try
+ {
+ Reference< XListEntrySink > xAsSink( m_xControlModel, UNO_QUERY );
+ bIs = xAsSink.is();
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "EFormsHelper::isListEntrySink: caught an exception!" );
+ }
+ return bIs;
+ }
+
+ //--------------------------------------------------------------------
+ void EFormsHelper::impl_switchBindingListening_throw( bool _bDoListening, const Reference< XPropertyChangeListener >& _rxListener )
+ {
+ Reference< XPropertySet > xBindingProps;
+ if ( m_xBindableControl.is() )
+ xBindingProps = xBindingProps.query( m_xBindableControl->getValueBinding() );
+ if ( !xBindingProps.is() )
+ return;
+
+ if ( _bDoListening )
+ {
+ xBindingProps->addPropertyChangeListener( ::rtl::OUString(), _rxListener );
+ }
+ else
+ {
+ xBindingProps->removePropertyChangeListener( ::rtl::OUString(), _rxListener );
+ }
+ }
+
+ //--------------------------------------------------------------------
+ void EFormsHelper::registerBindingListener( const Reference< XPropertyChangeListener >& _rxBindingListener )
+ {
+ if ( !_rxBindingListener.is() )
+ return;
+ impl_toggleBindingPropertyListening_throw( true, _rxBindingListener );
+ }
+
+ //--------------------------------------------------------------------
+ void EFormsHelper::impl_toggleBindingPropertyListening_throw( bool _bDoListen, const Reference< XPropertyChangeListener >& _rxConcreteListenerOrNull )
+ {
+ if ( !_bDoListen )
+ {
+ ::std::auto_ptr< ::cppu::OInterfaceIteratorHelper > pListenerIterator = m_aPropertyListeners.createIterator();
+ while ( pListenerIterator->hasMoreElements() )
+ {
+ PropertyEventTranslation* pTranslator = dynamic_cast< PropertyEventTranslation* >( pListenerIterator->next() );
+ OSL_ENSURE( pTranslator, "EFormsHelper::impl_toggleBindingPropertyListening_throw: invalid listener element in my container!" );
+ if ( !pTranslator )
+ continue;
+
+ Reference< XPropertyChangeListener > xEventSourceTranslator( pTranslator );
+ if ( _rxConcreteListenerOrNull.is() )
+ {
+ if ( pTranslator->getDelegator() == _rxConcreteListenerOrNull )
+ {
+ impl_switchBindingListening_throw( false, xEventSourceTranslator );
+ m_aPropertyListeners.removeListener( xEventSourceTranslator );
+ break;
+ }
+ }
+ else
+ {
+ impl_switchBindingListening_throw( false, xEventSourceTranslator );
+ }
+ }
+ }
+ else
+ {
+ if ( _rxConcreteListenerOrNull.is() )
+ {
+ Reference< XPropertyChangeListener > xEventSourceTranslator( new PropertyEventTranslation( _rxConcreteListenerOrNull, m_xBindableControl ) );
+ m_aPropertyListeners.addListener( xEventSourceTranslator );
+ impl_switchBindingListening_throw( true, xEventSourceTranslator );
+ }
+ else
+ {
+ ::std::auto_ptr< ::cppu::OInterfaceIteratorHelper > pListenerIterator = m_aPropertyListeners.createIterator();
+ while ( pListenerIterator->hasMoreElements() )
+ {
+ Reference< XPropertyChangeListener > xListener( pListenerIterator->next(), UNO_QUERY );
+ impl_switchBindingListening_throw( true, xListener );
+ }
+ }
+ }
+ }
+
+ //--------------------------------------------------------------------
+ void EFormsHelper::revokeBindingListener( const Reference< XPropertyChangeListener >& _rxBindingListener )
+ {
+ impl_toggleBindingPropertyListening_throw( false, _rxBindingListener );
+ }
+
+ //--------------------------------------------------------------------
+ void EFormsHelper::getFormModelNames( ::std::vector< ::rtl::OUString >& /* [out] */ _rModelNames ) const SAL_THROW(())
+ {
+ if ( m_xDocument.is() )
+ {
+ try
+ {
+ _rModelNames.resize( 0 );
+
+ Reference< XNameContainer > xForms( m_xDocument->getXForms() );
+ OSL_ENSURE( xForms.is(), "EFormsHelper::getFormModelNames: invalid forms container!" );
+ if ( xForms.is() )
+ {
+ Sequence< ::rtl::OUString > aModelNames = xForms->getElementNames();
+ _rModelNames.resize( aModelNames.getLength() );
+ ::std::copy( aModelNames.getConstArray(), aModelNames.getConstArray() + aModelNames.getLength(),
+ _rModelNames.begin()
+ );
+ }
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "EFormsHelper::getFormModelNames: caught an exception!" );
+ }
+ }
+ }
+
+ //--------------------------------------------------------------------
+ void EFormsHelper::getBindingNames( const ::rtl::OUString& _rModelName, ::std::vector< ::rtl::OUString >& /* [out] */ _rBindingNames ) const SAL_THROW(())
+ {
+ _rBindingNames.resize( 0 );
+ try
+ {
+ Reference< xforms::XModel > xModel( getFormModelByName( _rModelName ) );
+ if ( xModel.is() )
+ {
+ Reference< XNameAccess > xBindings( xModel->getBindings(), UNO_QUERY );
+ OSL_ENSURE( xBindings.is(), "EFormsHelper::getBindingNames: invalid bindings container obtained from the model!" );
+ if ( xBindings.is() )
+ {
+ Sequence< ::rtl::OUString > aNames = xBindings->getElementNames();
+ _rBindingNames.resize( aNames.getLength() );
+ ::std::copy( aNames.getConstArray(), aNames.getConstArray() + aNames.getLength(), _rBindingNames.begin() );
+ }
+ }
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "EFormsHelper::getBindingNames: caught an exception!" );
+ }
+ }
+
+ //--------------------------------------------------------------------
+ Reference< xforms::XModel > EFormsHelper::getFormModelByName( const ::rtl::OUString& _rModelName ) const SAL_THROW(())
+ {
+ Reference< xforms::XModel > xReturn;
+ try
+ {
+ Reference< XNameContainer > xForms( m_xDocument->getXForms() );
+ OSL_ENSURE( xForms.is(), "EFormsHelper::getFormModelByName: invalid forms container!" );
+ if ( xForms.is() )
+ OSL_VERIFY( xForms->getByName( _rModelName ) >>= xReturn );
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "EFormsHelper::getFormModelByName: caught an exception!" );
+ }
+ return xReturn;
+ }
+
+ //--------------------------------------------------------------------
+ Reference< xforms::XModel > EFormsHelper::getCurrentFormModel() const SAL_THROW(())
+ {
+ Reference< xforms::XModel > xModel;
+ try
+ {
+ Reference< XPropertySet > xBinding( getCurrentBinding() );
+ if ( xBinding.is() )
+ {
+ OSL_VERIFY( xBinding->getPropertyValue( PROPERTY_MODEL ) >>= xModel );
+ }
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "EFormsHelper::getCurrentFormModel: caught an exception!" );
+ }
+ return xModel;
+ }
+
+ //--------------------------------------------------------------------
+ ::rtl::OUString EFormsHelper::getCurrentFormModelName() const SAL_THROW(())
+ {
+ ::rtl::OUString sModelName;
+ try
+ {
+ Reference< xforms::XModel > xFormsModel( getCurrentFormModel() );
+ if ( xFormsModel.is() )
+ sModelName = xFormsModel->getID();
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "EFormsHelper::getCurrentFormModel: caught an exception!" );
+ }
+ return sModelName;
+ }
+
+ //--------------------------------------------------------------------
+ Reference< XPropertySet > EFormsHelper::getCurrentBinding() const SAL_THROW(())
+ {
+ Reference< XPropertySet > xBinding;
+
+ try
+ {
+ if ( m_xBindableControl.is() )
+ xBinding = xBinding.query( m_xBindableControl->getValueBinding() );
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "EFormsHelper::getCurrentBinding: caught an exception!" );
+ }
+
+ return xBinding;
+ }
+
+ //--------------------------------------------------------------------
+ ::rtl::OUString EFormsHelper::getCurrentBindingName() const SAL_THROW(())
+ {
+ ::rtl::OUString sBindingName;
+ try
+ {
+ Reference< XPropertySet > xBinding( getCurrentBinding() );
+ if ( xBinding.is() )
+ xBinding->getPropertyValue( PROPERTY_BINDING_ID ) >>= sBindingName;
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "EFormsHelper::getCurrentBindingName: caught an exception!" );
+ }
+ return sBindingName;
+ }
+
+ //--------------------------------------------------------------------
+ Reference< XListEntrySource > EFormsHelper::getCurrentListSourceBinding() const SAL_THROW(())
+ {
+ Reference< XListEntrySource > xReturn;
+ try
+ {
+ Reference< XListEntrySink > xAsSink( m_xControlModel, UNO_QUERY );
+ OSL_ENSURE( xAsSink.is(), "EFormsHelper::getCurrentListSourceBinding: you should have used isListEntrySink before!" );
+ if ( xAsSink.is() )
+ xReturn = xAsSink->getListEntrySource();
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "EFormsHelper::getCurrentListSourceBinding: caught an exception!" );
+ }
+ return xReturn;
+ }
+
+ //--------------------------------------------------------------------
+ void EFormsHelper::setListSourceBinding( const Reference< XListEntrySource >& _rxListSource ) SAL_THROW(())
+ {
+ try
+ {
+ Reference< XListEntrySink > xAsSink( m_xControlModel, UNO_QUERY );
+ OSL_ENSURE( xAsSink.is(), "EFormsHelper::setListSourceBinding: you should have used isListEntrySink before!" );
+ if ( xAsSink.is() )
+ xAsSink->setListEntrySource( _rxListSource );
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "EFormsHelper::setListSourceBinding: caught an exception!" );
+ }
+ }
+
+ //--------------------------------------------------------------------
+ void EFormsHelper::setBinding( const Reference< ::com::sun::star::beans::XPropertySet >& _rxBinding ) SAL_THROW(())
+ {
+ if ( !m_xBindableControl.is() )
+ return;
+
+ try
+ {
+ Reference< XPropertySet > xOldBinding( m_xBindableControl->getValueBinding(), UNO_QUERY );
+
+ Reference< XValueBinding > xBinding( _rxBinding, UNO_QUERY );
+ OSL_ENSURE( xBinding.is() || !_rxBinding.is(), "EFormsHelper::setBinding: invalid binding!" );
+
+ impl_toggleBindingPropertyListening_throw( false, NULL );
+ m_xBindableControl->setValueBinding( xBinding );
+ impl_toggleBindingPropertyListening_throw( true, NULL );
+
+ ::std::set< ::rtl::OUString > aSet;
+ firePropertyChanges( xOldBinding, _rxBinding, aSet );
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "EFormsHelper::setBinding: caught an exception!" );
+ }
+ }
+
+ //--------------------------------------------------------------------
+ Reference< XPropertySet > EFormsHelper::getOrCreateBindingForModel( const ::rtl::OUString& _rTargetModel, const ::rtl::OUString& _rBindingName ) const SAL_THROW(())
+ {
+ OSL_ENSURE( _rBindingName.getLength(), "EFormsHelper::getOrCreateBindingForModel: invalid binding name!" );
+ return implGetOrCreateBinding( _rTargetModel, _rBindingName );
+ }
+
+ //--------------------------------------------------------------------
+ Reference< XPropertySet > EFormsHelper::implGetOrCreateBinding( const ::rtl::OUString& _rTargetModel, const ::rtl::OUString& _rBindingName ) const SAL_THROW(())
+ {
+ OSL_ENSURE( !( !_rTargetModel.getLength() && _rBindingName .getLength() ), "EFormsHelper::implGetOrCreateBinding: no model, but a binding name?" );
+
+ Reference< XPropertySet > xBinding;
+ try
+ {
+ ::rtl::OUString sTargetModel( _rTargetModel );
+ // determine the model which the binding should belong to
+ if ( !sTargetModel.getLength() )
+ {
+ ::std::vector< ::rtl::OUString > aModelNames;
+ getFormModelNames( aModelNames );
+ if ( !aModelNames.empty() )
+ sTargetModel = *aModelNames.begin();
+ OSL_ENSURE( sTargetModel.getLength(), "EFormsHelper::implGetOrCreateBinding: unable to obtain a default model!" );
+ }
+ Reference< xforms::XModel > xModel( getFormModelByName( sTargetModel ) );
+ Reference< XNameAccess > xBindingNames( xModel.is() ? xModel->getBindings() : Reference< XSet >(), UNO_QUERY );
+ if ( xBindingNames.is() )
+ {
+ // get or create the binding instance
+ if ( _rBindingName.getLength() )
+ {
+ if ( xBindingNames->hasByName( _rBindingName ) )
+ OSL_VERIFY( xBindingNames->getByName( _rBindingName ) >>= xBinding );
+ else
+ {
+ xBinding = xModel->createBinding( );
+ if ( xBinding.is() )
+ {
+ xBinding->setPropertyValue( PROPERTY_BINDING_ID, makeAny( _rBindingName ) );
+ xModel->getBindings()->insert( makeAny( xBinding ) );
+ }
+ }
+ }
+ else
+ {
+ xBinding = xModel->createBinding( );
+ if ( xBinding.is() )
+ {
+ // find a nice name for it
+ String sBaseName( PcrRes( RID_STR_BINDING_UI_NAME ) );
+ sBaseName += String::CreateFromAscii( " " );
+ String sNewName;
+ sal_Int32 nNumber = 1;
+ do
+ {
+ sNewName = sBaseName + ::rtl::OUString::valueOf( nNumber++ );
+ }
+ while ( xBindingNames->hasByName( sNewName ) );
+ Reference< XNamed > xName( xBinding, UNO_QUERY_THROW );
+ xName->setName( sNewName );
+ // and insert into the model
+ xModel->getBindings()->insert( makeAny( xBinding ) );
+ }
+ }
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+ return xBinding;
+ }
+
+ //--------------------------------------------------------------------
+ namespace
+ {
+ //................................................................
+ struct PropertyBagInserter : public ::std::unary_function< Property, void >
+ {
+ private:
+ PropertyBag& m_rProperties;
+
+ public:
+ PropertyBagInserter( PropertyBag& rProperties ) : m_rProperties( rProperties ) { }
+
+ void operator()( const Property& _rProp )
+ {
+ m_rProperties.insert( _rProp );
+ }
+ };
+
+ //................................................................
+ Reference< XPropertySetInfo > collectPropertiesGetInfo( const Reference< XPropertySet >& _rxProps, PropertyBag& _rBag )
+ {
+ Reference< XPropertySetInfo > xInfo;
+ if ( _rxProps.is() )
+ xInfo = _rxProps->getPropertySetInfo();
+ if ( xInfo.is() )
+ {
+ Sequence< Property > aProperties = xInfo->getProperties();
+ ::std::for_each( aProperties.getConstArray(), aProperties.getConstArray() + aProperties.getLength(),
+ PropertyBagInserter( _rBag )
+ );
+ }
+ return xInfo;
+ }
+ }
+
+ //--------------------------------------------------------------------
+ ::rtl::OUString EFormsHelper::getModelElementUIName( const EFormsHelper::ModelElementType _eType, const Reference< XPropertySet >& _rxElement ) const SAL_THROW(())
+ {
+ ::rtl::OUString sUIName;
+ try
+ {
+ // determine the model which the element belongs to
+ Reference< xforms::XFormsUIHelper1 > xHelper;
+ if ( _rxElement.is() )
+ _rxElement->getPropertyValue( PROPERTY_MODEL ) >>= xHelper;
+ OSL_ENSURE( xHelper.is(), "EFormsHelper::getModelElementUIName: invalid element or model!" );
+ if ( xHelper.is() )
+ {
+ ::rtl::OUString sElementName = ( _eType == Submission ) ? xHelper->getSubmissionName( _rxElement, sal_True ) : xHelper->getBindingName( _rxElement, sal_True );
+ Reference< xforms::XModel > xModel( xHelper, UNO_QUERY_THROW );
+ sUIName = composeModelElementUIName( xModel->getID(), sElementName );
+ }
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "EFormsHelper::getModelElementUIName: caught an exception!" );
+ }
+
+ return sUIName;
+ }
+
+ //--------------------------------------------------------------------
+ Reference< XPropertySet > EFormsHelper::getModelElementFromUIName( const EFormsHelper::ModelElementType _eType, const ::rtl::OUString& _rUIName ) const SAL_THROW(())
+ {
+ const MapStringToPropertySet& rMapUINameToElement( ( _eType == Submission ) ? m_aSubmissionUINames : m_aBindingUINames );
+ MapStringToPropertySet::const_iterator pos = rMapUINameToElement.find( _rUIName );
+ OSL_ENSURE( pos != rMapUINameToElement.end(), "EFormsHelper::getModelElementFromUIName: didn't find it!" );
+
+ return ( pos != rMapUINameToElement.end() ) ? pos->second : Reference< XPropertySet >();
+ }
+
+ //--------------------------------------------------------------------
+ void EFormsHelper::getAllElementUINames( const ModelElementType _eType, ::std::vector< ::rtl::OUString >& /* [out] */ _rElementNames, bool _bPrepentEmptyEntry )
+ {
+ MapStringToPropertySet& rMapUINameToElement( ( _eType == Submission ) ? m_aSubmissionUINames : m_aBindingUINames );
+ rMapUINameToElement.clear();
+ _rElementNames.resize( 0 );
+
+ if ( _bPrepentEmptyEntry )
+ rMapUINameToElement[ ::rtl::OUString() ] = Reference< XPropertySet >();
+
+ try
+ {
+ // obtain the model names
+ ::std::vector< ::rtl::OUString > aModels;
+ getFormModelNames( aModels );
+ _rElementNames.reserve( aModels.size() * 2 ); // heuristics
+
+ // for every model, obtain the element
+ for ( ::std::vector< ::rtl::OUString >::const_iterator pModelName = aModels.begin();
+ pModelName != aModels.end();
+ ++pModelName
+ )
+ {
+ Reference< xforms::XModel > xModel = getFormModelByName( *pModelName );
+ OSL_ENSURE( xModel.is(), "EFormsHelper::getAllElementUINames: inconsistency in the models!" );
+ Reference< xforms::XFormsUIHelper1 > xHelper( xModel, UNO_QUERY );
+
+ Reference< XIndexAccess > xElements;
+ if ( xModel.is() )
+ xElements = xElements.query( ( _eType == Submission ) ? xModel->getSubmissions() : xModel->getBindings() );
+ if ( !xElements.is() )
+ break;
+
+ sal_Int32 nElementCount = xElements->getCount();
+ for ( sal_Int32 i = 0; i < nElementCount; ++i )
+ {
+ Reference< XPropertySet > xElement( xElements->getByIndex( i ), UNO_QUERY );
+ OSL_ENSURE( xElement.is(), "EFormsHelper::getAllElementUINames: empty element!" );
+ if ( !xElement.is() )
+ continue;
+#if OSL_DEBUG_LEVEL > 0
+ {
+ Reference< xforms::XModel > xElementsModel;
+ xElement->getPropertyValue( PROPERTY_MODEL ) >>= xElementsModel;
+ OSL_ENSURE( xElementsModel == xModel, "EFormsHelper::getAllElementUINames: inconsistency in the model-element relationship!" );
+ if ( !( xElementsModel == xModel ) )
+ xElement->setPropertyValue( PROPERTY_MODEL, makeAny( xModel ) );
+ }
+#endif
+ ::rtl::OUString sElementName = ( _eType == Submission ) ? xHelper->getSubmissionName( xElement, sal_True ) : xHelper->getBindingName( xElement, sal_True );
+ ::rtl::OUString sUIName = composeModelElementUIName( *pModelName, sElementName );
+
+ OSL_ENSURE( rMapUINameToElement.find( sUIName ) == rMapUINameToElement.end(), "EFormsHelper::getAllElementUINames: duplicate name!" );
+ rMapUINameToElement.insert( MapStringToPropertySet::value_type( sUIName, xElement ) );
+ }
+ }
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "EFormsHelper::getAllElementUINames: caught an exception!" );
+ }
+
+ _rElementNames.resize( rMapUINameToElement.size() );
+ ::std::transform( rMapUINameToElement.begin(), rMapUINameToElement.end(), _rElementNames.begin(), ::std::select1st< MapStringToPropertySet::value_type >() );
+ }
+
+ //--------------------------------------------------------------------
+ void EFormsHelper::firePropertyChange( const ::rtl::OUString& _rName, const Any& _rOldValue, const Any& _rNewValue ) const
+ {
+ if ( m_aPropertyListeners.empty() )
+ return;
+
+ if ( _rOldValue == _rNewValue )
+ return;
+
+ try
+ {
+ PropertyChangeEvent aEvent;
+
+ aEvent.Source = m_xBindableControl.get();
+ aEvent.PropertyName = _rName;
+ aEvent.OldValue = _rOldValue;
+ aEvent.NewValue = _rNewValue;
+
+ const_cast< EFormsHelper* >( this )->m_aPropertyListeners.notify( aEvent, &XPropertyChangeListener::propertyChange );
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "EFormsHelper::firePropertyChange: caught an exception!" );
+ }
+ }
+
+ //--------------------------------------------------------------------
+ void EFormsHelper::firePropertyChanges( const Reference< XPropertySet >& _rxOldProps, const Reference< XPropertySet >& _rxNewProps, ::std::set< ::rtl::OUString >& _rFilter ) const
+ {
+ if ( m_aPropertyListeners.empty() )
+ return;
+
+ try
+ {
+ PropertyBag aProperties;
+ Reference< XPropertySetInfo > xOldInfo = collectPropertiesGetInfo( _rxOldProps, aProperties );
+ Reference< XPropertySetInfo > xNewInfo = collectPropertiesGetInfo( _rxNewProps, aProperties );
+
+ for ( PropertyBag::const_iterator aProp = aProperties.begin();
+ aProp != aProperties.end();
+ ++aProp
+ )
+ {
+ if ( _rFilter.find( aProp->Name ) != _rFilter.end() )
+ continue;
+
+ Any aOldValue( NULL, aProp->Type );
+ if ( xOldInfo.is() && xOldInfo->hasPropertyByName( aProp->Name ) )
+ aOldValue = _rxOldProps->getPropertyValue( aProp->Name );
+
+ Any aNewValue( NULL, aProp->Type );
+ if ( xNewInfo.is() && xNewInfo->hasPropertyByName( aProp->Name ) )
+ aNewValue = _rxNewProps->getPropertyValue( aProp->Name );
+
+ firePropertyChange( aProp->Name, aOldValue, aNewValue );
+ }
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "EFormsHelper::firePropertyChanges: caught an exception!" );
+ }
+ }
+
+//........................................................................
+} // namespace pcr
+//........................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/propctrlr/eformshelper.hxx b/extensions/source/propctrlr/eformshelper.hxx
new file mode 100644
index 000000000000..53883b348d13
--- /dev/null
+++ b/extensions/source/propctrlr/eformshelper.hxx
@@ -0,0 +1,271 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef EXTENSIONS_SOURCE_PROPCTRLR_EFORMSHELPER_HXX
+#define EXTENSIONS_SOURCE_PROPCTRLR_EFORMSHELPER_HXX
+
+#include "pcrcommon.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/frame/XModel.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/xforms/XModel.hpp>
+#include <com/sun/star/xforms/XFormsSupplier.hpp>
+#include <com/sun/star/form/binding/XBindableValue.hpp>
+#include <com/sun/star/form/binding/XListEntrySource.hpp>
+/** === end UNO includes === **/
+#include <osl/mutex.hxx>
+#include <tools/string.hxx>
+#include <comphelper/listenernotification.hxx>
+
+#include <vector>
+#include <set>
+#include <map>
+
+//........................................................................
+namespace pcr
+{
+//........................................................................
+
+ typedef ::std::map< ::rtl::OUString, ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >, ::std::less< ::rtl::OUString > >
+ MapStringToPropertySet;
+
+ //====================================================================
+ //= EFormsHelper
+ //====================================================================
+ class EFormsHelper
+ {
+ protected:
+ ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >
+ m_xControlModel;
+ ::com::sun::star::uno::Reference< ::com::sun::star::form::binding::XBindableValue >
+ m_xBindableControl;
+ ::com::sun::star::uno::Reference< ::com::sun::star::xforms::XFormsSupplier >
+ m_xDocument;
+ PropertyChangeListeners
+ m_aPropertyListeners;
+ MapStringToPropertySet
+ m_aSubmissionUINames; // only filled upon request
+ MapStringToPropertySet
+ m_aBindingUINames; // only filled upon request
+
+ public:
+ EFormsHelper(
+ ::osl::Mutex& _rMutex,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxControlModel,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& _rxContextDocument
+ );
+
+ /** determines whether the given document is an eForm
+
+ If this method returns <FALSE/>, you cannot instantiate a EFormsHelper with
+ this document, since then no of it's functionality will be available.
+ */
+ static bool
+ isEForm(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& _rxContextDocument
+ ) SAL_THROW(());
+
+ /** registers a listener to be notified when any aspect of the binding changes.
+
+ The listener will be registered at the current binding of the control model. If the binding
+ changes (see <method>setBinding</method>), the listener will be revoked from the old binding,
+ registered at the new binding, and for all properties which differ between both bindings,
+ the listener will be notified.
+ @see revokeBindingListener
+ */
+ void registerBindingListener(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& _rxBindingListener
+ );
+
+ /** revokes the binding listener which has previously been registered
+ @see registerBindingListener
+ */
+ void revokeBindingListener(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& _rxBindingListener
+ );
+
+ /** checks whether it's possible to bind the control model to a given XSD data type
+
+ @param _nDataType
+ the data type which should be bound. If this is -1, <TRUE/> is returned if the control model
+ can be bound to <em>any</em> data type.
+ */
+ bool canBindToDataType( sal_Int32 _nDataType = -1 ) const SAL_THROW(());
+
+ /** checks whether the control model cna be bound to any XSD data type
+ */
+ bool canBindToAnyDataType() const SAL_THROW(()) { return canBindToDataType( -1 ); }
+
+ /** checks whether the control model is a source for list entries, as supplied by XML data bindings
+ */
+ bool isListEntrySink() const SAL_THROW(());
+
+ /** retrieves the names of all XForms models in the document the control lives in
+ */
+ void getFormModelNames( ::std::vector< ::rtl::OUString >& /* [out] */ _rModelNames ) const SAL_THROW(());
+
+ /** retrieves the names of all bindings for a given model
+ @see getFormModelNames
+ */
+ void getBindingNames( const ::rtl::OUString& _rModelName, ::std::vector< ::rtl::OUString >& /* [out] */ _rBindingNames ) const SAL_THROW(());
+
+ /// retrieves the XForms model (within the control model's document) with the given name
+ ::com::sun::star::uno::Reference< ::com::sun::star::xforms::XModel >
+ getFormModelByName( const ::rtl::OUString& _rModelName ) const SAL_THROW(());
+
+ /** retrieves the model which the active binding of the control model belongs to
+ */
+ ::com::sun::star::uno::Reference< ::com::sun::star::xforms::XModel >
+ getCurrentFormModel() const SAL_THROW(());
+
+ /** retrieves the name of the model which the active binding of the control model belongs to
+ */
+ ::rtl::OUString
+ getCurrentFormModelName() const SAL_THROW(());
+
+ /** retrieves the binding instance which is currently attached to the control model
+ */
+ ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >
+ getCurrentBinding() const SAL_THROW(());
+
+ /** retrieves the name of the binding instance which is currently attached to the control model
+ */
+ ::rtl::OUString
+ getCurrentBindingName() const SAL_THROW(());
+
+ /** sets a new binding at the control model
+ */
+ void setBinding( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxBinding ) SAL_THROW(());
+
+ /** retrieves the binding instance which is currently used as list source for the control model
+ @see isListEntrySink
+ */
+ ::com::sun::star::uno::Reference< ::com::sun::star::form::binding::XListEntrySource >
+ getCurrentListSourceBinding() const SAL_THROW(());
+
+ /** sets a new list source at the control model
+ @see isListEntrySink
+ */
+ void setListSourceBinding( const ::com::sun::star::uno::Reference< ::com::sun::star::form::binding::XListEntrySource >& _rxListSource ) SAL_THROW(());
+
+ /** retrieves a given binding for a given model, or creates a new one
+
+ @param _rTargetModel
+ the name of the model to create a binding for. Must not be empty
+ @param _rBindingName
+ the name of the binding to retrieve. If the model denoted by <arg>_rTargetModel</arg> does not
+ have a binding with this name, a new binding is created and returned.
+ */
+ ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >
+ getOrCreateBindingForModel( const ::rtl::OUString& _rTargetModel, const ::rtl::OUString& _rBindingName ) const SAL_THROW(());
+
+ /** types of sub-elements of a model
+ */
+ enum ModelElementType
+ {
+ Submission,
+ Binding
+ };
+
+ /** retrieves the name of a model's sub-element, as to be shown in the UI
+ @see getModelElementFromUIName
+ @see getAllElementUINames
+ */
+ ::rtl::OUString
+ getModelElementUIName(
+ const ModelElementType _eType,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxElement
+ ) const SAL_THROW(());
+
+ /** retrieves the submission object for an UI name
+
+ Note that <member>getAllElementUINames</member> must have been called before, for the given element type
+
+ @see getModelElementUIName
+ @see getAllElementUINames
+ */
+ ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >
+ getModelElementFromUIName(
+ const ModelElementType _eType,
+ const ::rtl::OUString& _rUIName
+ ) const SAL_THROW(());
+
+ /** retrieves the UI names of all elements of all models in our document
+ @param _eType
+ the type of elements for which the names should be retrieved
+ @param _rElementNames
+ the array of element names
+ @see getModelElementUIName
+ @see getModelElementFromUIName
+ */
+ void getAllElementUINames(
+ const ModelElementType _eType,
+ ::std::vector< ::rtl::OUString >& /* [out] */ _rElementNames,
+ bool _bPrepentEmptyEntry
+ );
+
+ protected:
+ void firePropertyChanges(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxOldProps,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxNewProps,
+ ::std::set< ::rtl::OUString >& _rFilter
+ ) const;
+
+ /** fires a change in a single property, if the property value changed, and if we have a listener
+ interested in property changes
+ */
+ void firePropertyChange(
+ const ::rtl::OUString& _rName,
+ const ::com::sun::star::uno::Any& _rOldValue,
+ const ::com::sun::star::uno::Any& _rNewValue
+ ) const;
+
+ private:
+ void impl_switchBindingListening_throw( bool _bDoListening, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& _rxListener );
+
+ /// implementation for both <member>getOrCreateBindingForModel</member>
+ ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >
+ implGetOrCreateBinding( const ::rtl::OUString& _rTargetModel, const ::rtl::OUString& _rBindingName ) const SAL_THROW(());
+
+ void
+ impl_toggleBindingPropertyListening_throw( bool _bDoListen, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& _rxConcreteListenerOrNull );
+
+ private:
+ EFormsHelper(); // never implemented
+ EFormsHelper( const EFormsHelper& ); // never implemented
+ EFormsHelper& operator=( const EFormsHelper& ); // never implemented
+ };
+
+//........................................................................
+} // namespace pcr
+//........................................................................
+
+#endif // EXTENSIONS_SOURCE_PROPCTRLR_EFORMSHELPER_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/propctrlr/eformspropertyhandler.cxx b/extensions/source/propctrlr/eformspropertyhandler.cxx
new file mode 100644
index 000000000000..5002606ecc76
--- /dev/null
+++ b/extensions/source/propctrlr/eformspropertyhandler.cxx
@@ -0,0 +1,618 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+#include "eformspropertyhandler.hxx"
+#include "formstrings.hxx"
+#include "formmetadata.hxx"
+#include "propctrlr.hrc"
+#include "formbrowsertools.hxx"
+#include "eformshelper.hxx"
+#include "handlerhelper.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
+#include <com/sun/star/inspection/PropertyControlType.hpp>
+#include <com/sun/star/inspection/XObjectInspectorUI.hpp>
+/** === end UNO includes === **/
+#include <tools/debug.hxx>
+
+#include <functional>
+
+//------------------------------------------------------------------------
+extern "C" void SAL_CALL createRegistryInfo_EFormsPropertyHandler()
+{
+ ::pcr::EFormsPropertyHandler::registerImplementation();
+}
+
+//........................................................................
+namespace pcr
+{
+//........................................................................
+
+ using namespace ::com::sun::star;
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::lang;
+ using namespace ::com::sun::star::beans;
+ using namespace ::com::sun::star::xforms;
+ using namespace ::com::sun::star::script;
+ using namespace ::com::sun::star::ui::dialogs;
+ using namespace ::com::sun::star::form::binding;
+ using namespace ::com::sun::star::inspection;
+
+ //====================================================================
+ //= EFormsPropertyHandler
+ //====================================================================
+ DBG_NAME( EFormsPropertyHandler )
+ //--------------------------------------------------------------------
+ EFormsPropertyHandler::EFormsPropertyHandler( const Reference< XComponentContext >& _rxContext )
+ :EFormsPropertyHandler_Base( _rxContext )
+ ,m_bSimulatingModelChange( false )
+ {
+ DBG_CTOR( EFormsPropertyHandler, NULL );
+ }
+
+ //--------------------------------------------------------------------
+ EFormsPropertyHandler::~EFormsPropertyHandler( )
+ {
+ DBG_DTOR( EFormsPropertyHandler, NULL );
+ }
+
+ //--------------------------------------------------------------------
+ ::rtl::OUString SAL_CALL EFormsPropertyHandler::getImplementationName_static( ) throw (RuntimeException)
+ {
+ return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.extensions.EFormsPropertyHandler" ) );
+ }
+
+ //--------------------------------------------------------------------
+ Sequence< ::rtl::OUString > SAL_CALL EFormsPropertyHandler::getSupportedServiceNames_static( ) throw (RuntimeException)
+ {
+ Sequence< ::rtl::OUString > aSupported( 1 );
+ aSupported[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.form.inspection.XMLFormsPropertyHandler" ) );
+ return aSupported;
+ }
+
+ //--------------------------------------------------------------------
+ ::rtl::OUString EFormsPropertyHandler::getModelNamePropertyValue() const
+ {
+ ::rtl::OUString sModelName = m_pHelper->getCurrentFormModelName();
+ if ( !sModelName.getLength() )
+ sModelName = m_sBindingLessModelName;
+ return sModelName;
+ }
+
+ //--------------------------------------------------------------------
+ Any SAL_CALL EFormsPropertyHandler::getPropertyValue( const ::rtl::OUString& _rPropertyName ) throw (UnknownPropertyException, RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ PropertyId nPropId( impl_getPropertyId_throw( _rPropertyName ) );
+
+ OSL_ENSURE( m_pHelper.get(), "EFormsPropertyHandler::getPropertyValue: we don't have any SupportedProperties!" );
+ // if we survived impl_getPropertyId_throw, we should have a helper, since no helper implies no properties
+
+ Any aReturn;
+ try
+ {
+ switch ( nPropId )
+ {
+ case PROPERTY_ID_LIST_BINDING:
+ aReturn <<= m_pHelper->getCurrentListSourceBinding();
+ break;
+
+ case PROPERTY_ID_XML_DATA_MODEL:
+ aReturn <<= getModelNamePropertyValue();
+ break;
+
+ case PROPERTY_ID_BINDING_NAME:
+ aReturn <<= m_pHelper->getCurrentBindingName();
+ break;
+
+ case PROPERTY_ID_BIND_EXPRESSION:
+ case PROPERTY_ID_XSD_CONSTRAINT:
+ case PROPERTY_ID_XSD_CALCULATION:
+ case PROPERTY_ID_XSD_REQUIRED:
+ case PROPERTY_ID_XSD_RELEVANT:
+ case PROPERTY_ID_XSD_READONLY:
+ {
+ Reference< XPropertySet > xBindingProps( m_pHelper->getCurrentBinding() );
+ if ( xBindingProps.is() )
+ {
+ aReturn = xBindingProps->getPropertyValue( _rPropertyName );
+ DBG_ASSERT( aReturn.getValueType().equals( ::getCppuType( static_cast< ::rtl::OUString* >( NULL ) ) ),
+ "EFormsPropertyHandler::getPropertyValue: invalid BindingExpression value type!" );
+ }
+ else
+ aReturn <<= ::rtl::OUString();
+ }
+ break;
+
+ default:
+ DBG_ERROR( "EFormsPropertyHandler::getPropertyValue: cannot handle this property!" );
+ break;
+ }
+ }
+ catch( const Exception& )
+ {
+#if OSL_DEBUG_LEVEL > 0
+ ::rtl::OString sMessage( "EFormsPropertyHandler::getPropertyValue: caught an exception!" );
+ sMessage += "\n(have been asked for the \"";
+ sMessage += ::rtl::OString( _rPropertyName.getStr(), _rPropertyName.getLength(), RTL_TEXTENCODING_ASCII_US );
+ sMessage += "\" property.)";
+ OSL_ENSURE( sal_False, sMessage.getStr() );
+#endif
+ }
+ return aReturn;
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL EFormsPropertyHandler::setPropertyValue( const ::rtl::OUString& _rPropertyName, const Any& _rValue ) throw (UnknownPropertyException, RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ PropertyId nPropId( impl_getPropertyId_throw( _rPropertyName ) );
+
+ OSL_ENSURE( m_pHelper.get(), "EFormsPropertyHandler::setPropertyValue: we don't have any SupportedProperties!" );
+ // if we survived impl_getPropertyId_throw, we should have a helper, since no helper implies no properties
+
+ try
+ {
+ Any aOldValue = getPropertyValue( _rPropertyName );
+
+ switch ( nPropId )
+ {
+ case PROPERTY_ID_LIST_BINDING:
+ {
+ Reference< XListEntrySource > xSource;
+ OSL_VERIFY( _rValue >>= xSource );
+ m_pHelper->setListSourceBinding( xSource );
+ }
+ break;
+
+ case PROPERTY_ID_XML_DATA_MODEL:
+ {
+ OSL_VERIFY( _rValue >>= m_sBindingLessModelName );
+
+ // if the model changed, reset the binding to NULL
+ if ( m_pHelper->getCurrentFormModelName() != m_sBindingLessModelName )
+ {
+ ::rtl::OUString sOldBindingName = m_pHelper->getCurrentBindingName();
+ m_pHelper->setBinding( NULL );
+ firePropertyChange( PROPERTY_BINDING_NAME, PROPERTY_ID_BINDING_NAME,
+ makeAny( sOldBindingName ), makeAny( ::rtl::OUString() ) );
+ }
+ }
+ break;
+
+ case PROPERTY_ID_BINDING_NAME:
+ {
+ ::rtl::OUString sNewBindingName;
+ OSL_VERIFY( _rValue >>= sNewBindingName );
+
+ bool bPreviouslyEmptyModel = !m_pHelper->getCurrentFormModel().is();
+
+ Reference< XPropertySet > xNewBinding;
+ if ( sNewBindingName.getLength() )
+ // obtain the binding with this name, for the current model
+ xNewBinding = m_pHelper->getOrCreateBindingForModel( getModelNamePropertyValue(), sNewBindingName );
+
+ m_pHelper->setBinding( xNewBinding );
+
+ if ( bPreviouslyEmptyModel )
+ { // simulate a property change for the model property
+ // This is because we "simulate" the Model property by remembering the
+ // value ourself. Other instances might, however, not know this value,
+ // but prefer to retrieve it somewhere else - e.g. from the EFormsHelper
+ //
+ // The really correct solution would be if *all* property handlers
+ // obtain a "current property value" for *all* properties from a central
+ // instance. Then, handler A could ask it for the value of property
+ // X, and this request would be re-routed to handler B, which ultimately
+ // knows the current value.
+ // However, there's no such mechanism in place currently.
+ m_bSimulatingModelChange = true;
+ firePropertyChange( PROPERTY_XML_DATA_MODEL, PROPERTY_ID_XML_DATA_MODEL,
+ makeAny( ::rtl::OUString() ), makeAny( getModelNamePropertyValue() ) );
+ m_bSimulatingModelChange = false;
+ }
+ }
+ break;
+
+ case PROPERTY_ID_BIND_EXPRESSION:
+ {
+ Reference< XPropertySet > xBinding( m_pHelper->getCurrentBinding() );
+ OSL_ENSURE( xBinding.is(), "You should not reach this without an active binding!" );
+ if ( xBinding.is() )
+ xBinding->setPropertyValue( PROPERTY_BIND_EXPRESSION, _rValue );
+ }
+ break;
+
+ case PROPERTY_ID_XSD_REQUIRED:
+ case PROPERTY_ID_XSD_RELEVANT:
+ case PROPERTY_ID_XSD_READONLY:
+ case PROPERTY_ID_XSD_CONSTRAINT:
+ case PROPERTY_ID_XSD_CALCULATION:
+ {
+ Reference< XPropertySet > xBindingProps( m_pHelper->getCurrentBinding() );
+ DBG_ASSERT( xBindingProps.is(), "EFormsPropertyHandler::setPropertyValue: how can I set a property if there's no binding?" );
+ if ( xBindingProps.is() )
+ {
+ DBG_ASSERT( _rValue.getValueType().equals( ::getCppuType( static_cast< ::rtl::OUString* >( NULL ) ) ),
+ "EFormsPropertyHandler::setPropertyValue: invalid value type!" );
+ xBindingProps->setPropertyValue( _rPropertyName, _rValue );
+ }
+ }
+ break;
+
+ default:
+ DBG_ERROR( "EFormsPropertyHandler::setPropertyValue: cannot handle this property!" );
+ break;
+ }
+
+ impl_setContextDocumentModified_nothrow();
+
+ Any aNewValue( getPropertyValue( _rPropertyName ) );
+ firePropertyChange( _rPropertyName, nPropId, aOldValue, aNewValue );
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "EFormsPropertyHandler::setPropertyValue: caught an exception!" );
+ }
+ }
+
+ //--------------------------------------------------------------------
+ void EFormsPropertyHandler::onNewComponent()
+ {
+ EFormsPropertyHandler_Base::onNewComponent();
+
+ Reference< frame::XModel > xDocument( impl_getContextDocument_nothrow() );
+ DBG_ASSERT( xDocument.is(), "EFormsPropertyHandler::onNewComponent: no document!" );
+ if ( EFormsHelper::isEForm( xDocument ) )
+ m_pHelper.reset( new EFormsHelper( m_aMutex, m_xComponent, xDocument ) );
+ else
+ m_pHelper.reset( NULL );
+ }
+
+ //--------------------------------------------------------------------
+ Sequence< Property > SAL_CALL EFormsPropertyHandler::doDescribeSupportedProperties() const
+ {
+ ::std::vector< Property > aProperties;
+
+ if ( m_pHelper.get() )
+ {
+ if ( m_pHelper->canBindToAnyDataType() )
+ {
+ aProperties.reserve( 7 );
+ addStringPropertyDescription( aProperties, PROPERTY_XML_DATA_MODEL );
+ addStringPropertyDescription( aProperties, PROPERTY_BINDING_NAME );
+ addStringPropertyDescription( aProperties, PROPERTY_BIND_EXPRESSION );
+ addStringPropertyDescription( aProperties, PROPERTY_XSD_REQUIRED );
+ addStringPropertyDescription( aProperties, PROPERTY_XSD_RELEVANT );
+ addStringPropertyDescription( aProperties, PROPERTY_XSD_READONLY );
+ addStringPropertyDescription( aProperties, PROPERTY_XSD_CONSTRAINT );
+ addStringPropertyDescription( aProperties, PROPERTY_XSD_CALCULATION );
+ }
+ if ( m_pHelper->isListEntrySink() )
+ {
+ implAddPropertyDescription( aProperties, PROPERTY_LIST_BINDING,
+ ::getCppuType( static_cast< Reference< XListEntrySource > * >( NULL ) ) );
+ }
+ }
+
+ if ( aProperties.empty() )
+ return Sequence< Property >();
+ return Sequence< Property >( &(*aProperties.begin()), aProperties.size() );
+ }
+
+ //--------------------------------------------------------------------
+ Any SAL_CALL EFormsPropertyHandler::convertToPropertyValue( const ::rtl::OUString& _rPropertyName, const Any& _rControlValue ) throw (UnknownPropertyException, RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ Any aReturn;
+
+ OSL_ENSURE( m_pHelper.get(), "EFormsPropertyHandler::convertToPropertyValue: we have no SupportedProperties!" );
+ if ( !m_pHelper.get() )
+ return aReturn;
+
+ PropertyId nPropId( m_pInfoService->getPropertyId( _rPropertyName ) );
+
+ ::rtl::OUString sControlValue;
+ switch ( nPropId )
+ {
+ case PROPERTY_ID_LIST_BINDING:
+ {
+ OSL_VERIFY( _rControlValue >>= sControlValue );
+ Reference< XListEntrySource > xListSource( m_pHelper->getModelElementFromUIName( EFormsHelper::Binding, sControlValue ), UNO_QUERY );
+ OSL_ENSURE( xListSource.is() || !m_pHelper->getModelElementFromUIName( EFormsHelper::Binding, sControlValue ).is(),
+ "EFormsPropertyHandler::convertToPropertyValue: there's a binding which is no ListEntrySource!" );
+ aReturn <<= xListSource;
+ }
+ break;
+
+ default:
+ aReturn = EFormsPropertyHandler_Base::convertToPropertyValue( _rPropertyName, _rControlValue );
+ break;
+ }
+
+ return aReturn;
+ }
+
+ //--------------------------------------------------------------------
+ Any SAL_CALL EFormsPropertyHandler::convertToControlValue( const ::rtl::OUString& _rPropertyName, const Any& _rPropertyValue, const Type& _rControlValueType ) throw (UnknownPropertyException, RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ Any aReturn;
+
+ OSL_ENSURE( m_pHelper.get(), "EFormsPropertyHandler::convertToControlValue: we have no SupportedProperties!" );
+ if ( !m_pHelper.get() )
+ return aReturn;
+
+ PropertyId nPropId( m_pInfoService->getPropertyId( _rPropertyName ) );
+
+ OSL_ENSURE( _rControlValueType.getTypeClass() == TypeClass_STRING,
+ "EFormsPropertyHandler::convertToControlValue: all our controls should use strings for value exchange!" );
+
+ switch ( nPropId )
+ {
+ case PROPERTY_ID_LIST_BINDING:
+ {
+ Reference< XPropertySet > xListSourceBinding( _rPropertyValue, UNO_QUERY );
+ if ( xListSourceBinding.is() )
+ aReturn <<= m_pHelper->getModelElementUIName( EFormsHelper::Binding, xListSourceBinding );
+ }
+ break;
+
+ default:
+ aReturn = EFormsPropertyHandler_Base::convertToControlValue( _rPropertyName, _rPropertyValue, _rControlValueType );
+ break;
+ }
+
+ return aReturn;
+ }
+
+ //--------------------------------------------------------------------
+ Sequence< ::rtl::OUString > SAL_CALL EFormsPropertyHandler::getActuatingProperties( ) throw (RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ if ( !m_pHelper.get() )
+ return Sequence< ::rtl::OUString >();
+
+ ::std::vector< ::rtl::OUString > aInterestedInActuations( 2 );
+ aInterestedInActuations[ 0 ] = PROPERTY_XML_DATA_MODEL;
+ aInterestedInActuations[ 1 ] = PROPERTY_BINDING_NAME;
+ return Sequence< ::rtl::OUString >( &(*aInterestedInActuations.begin()), aInterestedInActuations.size() );
+ }
+
+ //--------------------------------------------------------------------
+ Sequence< ::rtl::OUString > SAL_CALL EFormsPropertyHandler::getSupersededProperties( ) throw (RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ if ( !m_pHelper.get() )
+ return Sequence< ::rtl::OUString >();
+
+ Sequence< ::rtl::OUString > aReturn( 1 );
+ aReturn[ 0 ] = PROPERTY_INPUT_REQUIRED;
+ return aReturn;
+ }
+
+ //--------------------------------------------------------------------
+ LineDescriptor SAL_CALL EFormsPropertyHandler::describePropertyLine( const ::rtl::OUString& _rPropertyName,
+ const Reference< XPropertyControlFactory >& _rxControlFactory )
+ throw (UnknownPropertyException, NullPointerException, RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ if ( !_rxControlFactory.is() )
+ throw NullPointerException();
+ if ( !m_pHelper.get() )
+ throw RuntimeException();
+
+ LineDescriptor aDescriptor;
+ sal_Int16 nControlType = PropertyControlType::TextField;
+ ::std::vector< ::rtl::OUString > aListEntries;
+ PropertyId nPropId( impl_getPropertyId_throw( _rPropertyName ) );
+ switch ( nPropId )
+ {
+ case PROPERTY_ID_LIST_BINDING:
+ nControlType = PropertyControlType::ListBox;
+ const_cast< EFormsHelper* >( m_pHelper.get() )->getAllElementUINames( EFormsHelper::Binding, aListEntries, true );
+ break;
+
+ case PROPERTY_ID_XML_DATA_MODEL:
+ nControlType = PropertyControlType::ListBox;
+ m_pHelper->getFormModelNames( aListEntries );
+ break;
+
+ case PROPERTY_ID_BINDING_NAME:
+ {
+ nControlType = PropertyControlType::ComboBox;
+ ::rtl::OUString sCurrentModel( getModelNamePropertyValue() );
+ if ( sCurrentModel.getLength() )
+ m_pHelper->getBindingNames( sCurrentModel, aListEntries );
+ }
+ break;
+
+ case PROPERTY_ID_BIND_EXPRESSION: aDescriptor.PrimaryButtonId = UID_PROP_DLG_BIND_EXPRESSION; break;
+ case PROPERTY_ID_XSD_REQUIRED: aDescriptor.PrimaryButtonId = UID_PROP_DLG_XSD_REQUIRED; break;
+ case PROPERTY_ID_XSD_RELEVANT: aDescriptor.PrimaryButtonId = UID_PROP_DLG_XSD_RELEVANT; break;
+ case PROPERTY_ID_XSD_READONLY: aDescriptor.PrimaryButtonId = UID_PROP_DLG_XSD_READONLY; break;
+ case PROPERTY_ID_XSD_CONSTRAINT: aDescriptor.PrimaryButtonId = UID_PROP_DLG_XSD_CONSTRAINT; break;
+ case PROPERTY_ID_XSD_CALCULATION: aDescriptor.PrimaryButtonId = UID_PROP_DLG_XSD_CALCULATION; break;
+
+ default:
+ DBG_ERROR( "EFormsPropertyHandler::describePropertyLine: cannot handle this property!" );
+ break;
+ }
+
+ switch ( nControlType )
+ {
+ case PropertyControlType::ListBox:
+ aDescriptor.Control = PropertyHandlerHelper::createListBoxControl( _rxControlFactory, aListEntries, sal_False, sal_True );
+ break;
+ case PropertyControlType::ComboBox:
+ aDescriptor.Control = PropertyHandlerHelper::createComboBoxControl( _rxControlFactory, aListEntries, sal_False, sal_True );
+ break;
+ default:
+ aDescriptor.Control = _rxControlFactory->createPropertyControl( nControlType, sal_False );
+ break;
+ }
+
+ aDescriptor.DisplayName = m_pInfoService->getPropertyTranslation( nPropId );
+ aDescriptor.Category = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Data" ) );
+ aDescriptor.HelpURL = HelpIdUrl::getHelpURL( m_pInfoService->getPropertyHelpId( nPropId ) );
+ return aDescriptor;
+ }
+
+ //--------------------------------------------------------------------
+ InteractiveSelectionResult SAL_CALL EFormsPropertyHandler::onInteractivePropertySelection( const ::rtl::OUString& _rPropertyName, sal_Bool /*_bPrimary*/, Any& _rData, const Reference< XObjectInspectorUI >& _rxInspectorUI ) throw (UnknownPropertyException, NullPointerException, RuntimeException)
+ {
+ if ( !_rxInspectorUI.is() )
+ throw NullPointerException();
+
+ ::osl::MutexGuard aGuard( m_aMutex );
+ OSL_ENSURE( m_pHelper.get(), "EFormsPropertyHandler::onInteractivePropertySelection: we do not have any SupportedProperties!" );
+ if ( !m_pHelper.get() )
+ return InteractiveSelectionResult_Cancelled;
+
+ PropertyId nPropId( impl_getPropertyId_throw( _rPropertyName ) );
+ (void)nPropId;
+ OSL_ENSURE( ( PROPERTY_ID_BINDING_NAME == nPropId )
+ || ( PROPERTY_ID_BIND_EXPRESSION == nPropId )
+ || ( PROPERTY_ID_XSD_REQUIRED == nPropId )
+ || ( PROPERTY_ID_XSD_RELEVANT == nPropId )
+ || ( PROPERTY_ID_XSD_READONLY == nPropId )
+ || ( PROPERTY_ID_XSD_CONSTRAINT == nPropId )
+ || ( PROPERTY_ID_XSD_CALCULATION == nPropId ), "EFormsPropertyHandler::onInteractivePropertySelection: unexpected!" );
+
+ try
+ {
+ Reference< XExecutableDialog > xDialog;
+ m_aContext.createComponent( "com.sun.star.xforms.ui.dialogs.AddCondition", xDialog );
+ Reference< XPropertySet > xDialogProps( xDialog, UNO_QUERY_THROW );
+
+ // the model for the dialog to work with
+ Reference< xforms::XModel > xModel( m_pHelper->getCurrentFormModel() );
+ // the binding for the dialog to work with
+ Reference< XPropertySet > xBinding( m_pHelper->getCurrentBinding() );
+ // the aspect of the binding which the dialog should modify
+ ::rtl::OUString sFacetName( _rPropertyName );
+
+ OSL_ENSURE( xModel.is() && xBinding.is() && sFacetName.getLength(),
+ "EFormsPropertyHandler::onInteractivePropertySelection: something is missing for the dialog initialization!" );
+ if ( !( xModel.is() && xBinding.is() && sFacetName.getLength() ) )
+ return InteractiveSelectionResult_Cancelled;
+
+ xDialogProps->setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FormModel" ) ), makeAny( xModel ) );
+ xDialogProps->setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Binding" ) ), makeAny( xBinding ) );
+ xDialogProps->setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FacetName" ) ), makeAny( sFacetName ) );
+
+ if ( !xDialog->execute() )
+ // cancelled
+ return InteractiveSelectionResult_Cancelled;
+
+ _rData = xDialogProps->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ConditionValue" ) ) );
+ return InteractiveSelectionResult_ObtainedValue;
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "EFormsPropertyHandler::onInteractivePropertySelection: caught an exception!" );
+ }
+
+ // something went wrong here ...(but has been asserted already)
+ return InteractiveSelectionResult_Cancelled;
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL EFormsPropertyHandler::addPropertyChangeListener( const Reference< XPropertyChangeListener >& _rxListener ) throw (RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ EFormsPropertyHandler_Base::addPropertyChangeListener( _rxListener );
+ if ( m_pHelper.get() )
+ m_pHelper->registerBindingListener( _rxListener );
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL EFormsPropertyHandler::removePropertyChangeListener( const Reference< XPropertyChangeListener >& _rxListener ) throw (RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ if ( m_pHelper.get() )
+ m_pHelper->revokeBindingListener( _rxListener );
+ EFormsPropertyHandler_Base::removePropertyChangeListener( _rxListener );
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL EFormsPropertyHandler::actuatingPropertyChanged( const ::rtl::OUString& _rActuatingPropertyName, const Any& _rNewValue, const Any& /*_rOldValue*/, const Reference< XObjectInspectorUI >& _rxInspectorUI, sal_Bool ) throw (NullPointerException, RuntimeException)
+ {
+ if ( !_rxInspectorUI.is() )
+ throw NullPointerException();
+
+ ::osl::MutexGuard aGuard( m_aMutex );
+ PropertyId nActuatingPropId( impl_getPropertyId_throw( _rActuatingPropertyName ) );
+ OSL_PRECOND( m_pHelper.get(), "EFormsPropertyHandler::actuatingPropertyChanged: inconsistentcy!" );
+ // if we survived impl_getPropertyId_throw, we should have a helper, since no helper implies no properties
+
+ DBG_ASSERT( _rxInspectorUI.is(), "EFormsPropertyHandler::actuatingPropertyChanged: invalid callback!" );
+ if ( !_rxInspectorUI.is() )
+ return;
+
+ switch ( nActuatingPropId )
+ {
+ case PROPERTY_ID_XML_DATA_MODEL:
+ {
+ if ( m_bSimulatingModelChange )
+ break;
+ ::rtl::OUString sDataModelName;
+ OSL_VERIFY( _rNewValue >>= sDataModelName );
+ sal_Bool bBoundToSomeModel = 0 != sDataModelName.getLength();
+ _rxInspectorUI->rebuildPropertyUI( PROPERTY_BINDING_NAME );
+ _rxInspectorUI->enablePropertyUI( PROPERTY_BINDING_NAME, bBoundToSomeModel );
+ }
+ // NO break
+
+ case PROPERTY_ID_BINDING_NAME:
+ {
+ sal_Bool bHaveABinding = ( m_pHelper->getCurrentBindingName().getLength() > 0 );
+ _rxInspectorUI->enablePropertyUI( PROPERTY_BIND_EXPRESSION, bHaveABinding );
+ _rxInspectorUI->enablePropertyUI( PROPERTY_XSD_REQUIRED, bHaveABinding );
+ _rxInspectorUI->enablePropertyUI( PROPERTY_XSD_RELEVANT, bHaveABinding );
+ _rxInspectorUI->enablePropertyUI( PROPERTY_XSD_READONLY, bHaveABinding );
+ _rxInspectorUI->enablePropertyUI( PROPERTY_XSD_CONSTRAINT, bHaveABinding );
+ _rxInspectorUI->enablePropertyUI( PROPERTY_XSD_CALCULATION, bHaveABinding );
+ _rxInspectorUI->enablePropertyUI( PROPERTY_XSD_DATA_TYPE, bHaveABinding );
+ }
+ break;
+
+ default:
+ DBG_ERROR( "EFormsPropertyHandler::actuatingPropertyChanged: cannot handle this property!" );
+ break;
+ }
+ }
+
+//........................................................................
+} // namespace pcr
+//........................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/propctrlr/eformspropertyhandler.hxx b/extensions/source/propctrlr/eformspropertyhandler.hxx
new file mode 100644
index 000000000000..f1613a661583
--- /dev/null
+++ b/extensions/source/propctrlr/eformspropertyhandler.hxx
@@ -0,0 +1,110 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef EXTENSIONS_SOURCE_PROPCTRLR_EFORMSPROPERTYHANDLER_HXX
+#define EXTENSIONS_SOURCE_PROPCTRLR_EFORMSPROPERTYHANDLER_HXX
+
+#include "propertyhandler.hxx"
+
+/** === begin UNO includes === **/
+/** === end UNO includes === **/
+
+#include <memory>
+
+//........................................................................
+namespace pcr
+{
+//........................................................................
+
+ class EFormsHelper;
+ //====================================================================
+ //= EFormsPropertyHandler
+ //====================================================================
+ class EFormsPropertyHandler;
+ typedef HandlerComponentBase< EFormsPropertyHandler > EFormsPropertyHandler_Base;
+ class EFormsPropertyHandler : public EFormsPropertyHandler_Base
+ {
+ private:
+ ::std::auto_ptr< EFormsHelper > m_pHelper;
+ /** current value of the Model property, if there is no binding, yet
+ */
+ ::rtl::OUString m_sBindingLessModelName;
+ /** are we currently simulating a propertyChange event of the Model property?
+ */
+ bool m_bSimulatingModelChange;
+
+ public:
+ EFormsPropertyHandler(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _rxContext
+ );
+
+ static ::rtl::OUString SAL_CALL getImplementationName_static( ) throw (::com::sun::star::uno::RuntimeException);
+ static ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames_static( ) throw (::com::sun::star::uno::RuntimeException);
+
+ protected:
+ ~EFormsPropertyHandler();
+
+ protected:
+ // XPropertyHandler overriables
+ virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue( const ::rtl::OUString& _rPropertyName ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setPropertyValue( const ::rtl::OUString& _rPropertyName, const ::com::sun::star::uno::Any& _rValue ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString >
+ SAL_CALL getActuatingProperties( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString >
+ SAL_CALL getSupersededProperties( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::inspection::LineDescriptor
+ SAL_CALL describePropertyLine( const ::rtl::OUString& _rPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyControlFactory >& _rxControlFactory ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::NullPointerException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::inspection::InteractiveSelectionResult
+ SAL_CALL onInteractivePropertySelection( const ::rtl::OUString& _rPropertyName, sal_Bool _bPrimary, ::com::sun::star::uno::Any& _rData, const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XObjectInspectorUI >& _rxInspectorUI ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::NullPointerException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL actuatingPropertyChanged( const ::rtl::OUString& _rActuatingPropertyName, const ::com::sun::star::uno::Any& _rNewValue, const ::com::sun::star::uno::Any& _rOldValue, const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XObjectInspectorUI >& _rxInspectorUI, sal_Bool ) throw (::com::sun::star::lang::NullPointerException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Any SAL_CALL convertToPropertyValue( const ::rtl::OUString& _rPropertyName, const ::com::sun::star::uno::Any& _rControlValue ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Any SAL_CALL convertToControlValue( const ::rtl::OUString& _rPropertyName, const ::com::sun::star::uno::Any& _rPropertyValue, const ::com::sun::star::uno::Type& _rControlValueType ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL addPropertyChangeListener( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& _rxListener ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL removePropertyChangeListener( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& _rxListener ) throw (::com::sun::star::uno::RuntimeException);
+
+ // PropertyHandler overridables
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property >
+ SAL_CALL doDescribeSupportedProperties() const;
+ virtual void onNewComponent();
+
+ protected:
+ /** returns the value of the PROPERTY_XML_DATA_MODEL property.
+
+ An extra method is necessary here, which respects both the value set at our helper,
+ and <member>m_sBindingLessModelName</member>
+ */
+ ::rtl::OUString getModelNamePropertyValue() const;
+ };
+
+//........................................................................
+} // namespace pcr
+//........................................................................
+
+#endif // EXTENSIONS_SOURCE_PROPCTRLR_EFORMSPROPERTYHANDLER_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/propctrlr/enumrepresentation.hxx b/extensions/source/propctrlr/enumrepresentation.hxx
new file mode 100644
index 000000000000..058dd1096f4a
--- /dev/null
+++ b/extensions/source/propctrlr/enumrepresentation.hxx
@@ -0,0 +1,78 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef EXTENSIONS_SOURCE_PROPCTRLR_ENUMREPRESENTATION_HXX
+#define EXTENSIONS_SOURCE_PROPCTRLR_ENUMREPRESENTATION_HXX
+
+/** === begin UNO includes === **/
+#include <com/sun/star/uno/Any.hxx>
+/** === end UNO includes === **/
+#include <rtl/ref.hxx>
+#include <rtl/ustring.hxx>
+
+#include <vector>
+
+//........................................................................
+namespace pcr
+{
+//........................................................................
+
+ //====================================================================
+ //= IPropertyEnumRepresentation
+ //====================================================================
+ class SAL_NO_VTABLE IPropertyEnumRepresentation : public ::rtl::IReference
+ {
+ public:
+ /** retrieves all descriptions of all possible values of the enumeration property
+ */
+ virtual ::std::vector< ::rtl::OUString > SAL_CALL getDescriptions(
+ ) const = 0;
+
+ /** converts a given description into a property value
+ */
+ virtual void SAL_CALL getValueFromDescription(
+ const ::rtl::OUString& _rDescription,
+ ::com::sun::star::uno::Any& _out_rValue
+ ) const = 0;
+
+ /** converts a given property value into a description
+ */
+ virtual ::rtl::OUString SAL_CALL getDescriptionForValue(
+ const ::com::sun::star::uno::Any& _rEnumValue
+ ) const = 0;
+
+ virtual ~IPropertyEnumRepresentation() { };
+ };
+
+//........................................................................
+} // namespace pcr
+//........................................................................
+
+#endif // EXTENSIONS_SOURCE_PROPCTRLR_ENUMREPRESENTATION_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/propctrlr/eventhandler.cxx b/extensions/source/propctrlr/eventhandler.cxx
new file mode 100644
index 000000000000..ac148ed648cd
--- /dev/null
+++ b/extensions/source/propctrlr/eventhandler.cxx
@@ -0,0 +1,1287 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+
+#include "eventhandler.hxx"
+#include "propctrlr.hrc"
+#include "formbrowsertools.hxx"
+#include "formresid.hrc"
+#include "formstrings.hxx"
+#include "handlerhelper.hxx"
+#include "modulepcr.hxx"
+#include "pcrcommon.hxx"
+#include "pcrstrings.hxx"
+#include "propertycontrolextender.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/awt/XTabControllerModel.hpp>
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+#include <com/sun/star/beans/UnknownPropertyException.hpp>
+#include <com/sun/star/beans/XIntrospection.hpp>
+#include <com/sun/star/beans/XIntrospectionAccess.hpp>
+#include <com/sun/star/container/NoSuchElementException.hpp>
+#include <com/sun/star/container/XChild.hpp>
+#include <com/sun/star/container/XIndexAccess.hpp>
+#include <com/sun/star/container/XNameContainer.hpp>
+#include <com/sun/star/container/XNameReplace.hpp>
+#include <com/sun/star/form/FormComponentType.hpp>
+#include <com/sun/star/form/XForm.hpp>
+#include <com/sun/star/form/runtime/XFormController.hpp>
+#include <com/sun/star/inspection/PropertyControlType.hpp>
+#include <com/sun/star/lang/NullPointerException.hpp>
+#include <com/sun/star/script/XEventAttacherManager.hpp>
+#include <com/sun/star/script/XScriptEventsSupplier.hpp>
+#include <com/sun/star/util/XModifiable.hpp>
+#include <com/sun/star/uri/UriReferenceFactory.hpp>
+#include <com/sun/star/uri/XVndSunStarScriptUrlReference.hpp>
+/** === end UNO includes === **/
+
+#include <comphelper/namedvaluecollection.hxx>
+#include <comphelper/evtmethodhelper.hxx>
+#include <comphelper/types.hxx>
+#include <cppuhelper/implbase1.hxx>
+#include <rtl/ref.hxx>
+#include <rtl/ustrbuf.hxx>
+#include <sfx2/app.hxx>
+#include <svl/eitem.hxx>
+#include <svl/itemset.hxx>
+#include <svx/svxdlg.hxx>
+#include <svx/svxids.hrc>
+#include <tools/diagnose_ex.h>
+
+#include <map>
+#include <algorithm>
+
+//------------------------------------------------------------------------
+extern "C" void SAL_CALL createRegistryInfo_EventHandler()
+{
+ ::pcr::OAutoRegistration< ::pcr::EventHandler > aAutoRegistration;
+}
+
+//........................................................................
+namespace pcr
+{
+//........................................................................
+
+ /** === begin UNO using === **/
+ using ::com::sun::star::uno::Reference;
+ using ::com::sun::star::uno::XComponentContext;
+ using ::com::sun::star::beans::XPropertySet;
+ using ::com::sun::star::uno::Any;
+ using ::com::sun::star::uno::TypeClass_STRING;
+ using ::com::sun::star::uno::Type;
+ using ::com::sun::star::beans::XPropertyChangeListener;
+ using ::com::sun::star::beans::Property;
+ using ::com::sun::star::beans::PropertyState;
+ using ::com::sun::star::beans::PropertyState_DIRECT_VALUE;
+ using ::com::sun::star::uno::Sequence;
+ using ::com::sun::star::script::ScriptEventDescriptor;
+ using ::com::sun::star::script::XScriptEventsSupplier;
+ using ::com::sun::star::lang::NullPointerException;
+ using ::com::sun::star::uno::Exception;
+ using ::com::sun::star::container::XChild;
+ using ::com::sun::star::container::XIndexAccess;
+ using ::com::sun::star::script::XEventAttacherManager;
+ using ::com::sun::star::uno::UNO_QUERY;
+ using ::com::sun::star::uno::UNO_QUERY_THROW;
+ using ::com::sun::star::uno::XInterface;
+ using ::com::sun::star::beans::XIntrospection;
+ using ::com::sun::star::beans::XIntrospectionAccess;
+ using ::com::sun::star::container::XNameContainer;
+ using ::com::sun::star::awt::XTabControllerModel;
+ using ::com::sun::star::form::XForm;
+ using ::com::sun::star::form::runtime::XFormController;
+ using ::com::sun::star::beans::UnknownPropertyException;
+ using ::com::sun::star::uno::makeAny;
+ using ::com::sun::star::container::NoSuchElementException;
+ using ::com::sun::star::beans::XPropertySetInfo;
+ using ::com::sun::star::container::XNameReplace;
+ using ::com::sun::star::lang::IllegalArgumentException;
+ using ::com::sun::star::lang::WrappedTargetException;
+ using ::com::sun::star::uno::RuntimeException;
+ using ::com::sun::star::beans::PropertyValue;
+ using ::com::sun::star::inspection::LineDescriptor;
+ using ::com::sun::star::inspection::XPropertyControlFactory;
+ using ::com::sun::star::inspection::InteractiveSelectionResult;
+ using ::com::sun::star::inspection::InteractiveSelectionResult_Cancelled;
+ using ::com::sun::star::inspection::InteractiveSelectionResult_Success;
+ using ::com::sun::star::inspection::XObjectInspectorUI;
+ using ::com::sun::star::util::XModifiable;
+ using ::com::sun::star::beans::PropertyChangeEvent;
+ using ::com::sun::star::frame::XFrame;
+ using ::com::sun::star::frame::XModel;
+ using ::com::sun::star::frame::XController;
+ using ::com::sun::star::uno::UNO_SET_THROW;
+ using com::sun::star::uri::UriReferenceFactory;
+ using com::sun::star::uri::XUriReferenceFactory;
+ using com::sun::star::uri::XVndSunStarScriptUrlReference;
+ using ::com::sun::star::lang::XEventListener;
+ /** === end UNO using === **/
+ namespace PropertyControlType = ::com::sun::star::inspection::PropertyControlType;
+ namespace PropertyAttribute = ::com::sun::star::beans::PropertyAttribute;
+ namespace FormComponentType = ::com::sun::star::form::FormComponentType;
+
+ //====================================================================
+ //= EventDescription
+ //====================================================================
+ EventDescription::EventDescription( EventId _nId, const sal_Char* _pListenerNamespaceAscii, const sal_Char* _pListenerClassAsciiName,
+ const sal_Char* _pListenerMethodAsciiName, sal_uInt16 _nDisplayNameResId, sal_Int32 _nHelpId, sal_Int32 _nUniqueBrowseId )
+ :sDisplayName( String( PcrRes( _nDisplayNameResId ) ) )
+ ,sListenerMethodName( ::rtl::OUString::createFromAscii( _pListenerMethodAsciiName ) )
+ ,nHelpId( _nHelpId )
+ ,nUniqueBrowseId( _nUniqueBrowseId )
+ ,nId( _nId )
+ {
+ ::rtl::OUStringBuffer aQualifiedListenerClass;
+ aQualifiedListenerClass.appendAscii( "com.sun.star." );
+ aQualifiedListenerClass.appendAscii( _pListenerNamespaceAscii );
+ aQualifiedListenerClass.appendAscii( "." );
+ aQualifiedListenerClass.appendAscii( _pListenerClassAsciiName );
+ sListenerClassName = aQualifiedListenerClass.makeStringAndClear();
+ }
+
+ //========================================================================
+ //= helper
+ //========================================================================
+ namespace
+ {
+ //....................................................................
+ #define DESCRIBE_EVENT( asciinamespace, asciilistener, asciimethod, id_postfix ) \
+ s_aKnownEvents.insert( EventMap::value_type( \
+ ::rtl::OUString::createFromAscii( asciimethod ), \
+ EventDescription( ++nEventId, asciinamespace, asciilistener, asciimethod, RID_STR_EVT_##id_postfix, HID_EVT_##id_postfix, UID_BRWEVT_##id_postfix ) ) )
+
+ //....................................................................
+ bool lcl_getEventDescriptionForMethod( const ::rtl::OUString& _rMethodName, EventDescription& _out_rDescription )
+ {
+ static EventMap s_aKnownEvents;
+ if ( s_aKnownEvents.empty() )
+ {
+ ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
+ if ( s_aKnownEvents.empty() )
+ {
+ static sal_Int32 nEventId = 0;
+
+ DESCRIBE_EVENT( "form", "XApproveActionListener", "approveAction", APPROVEACTIONPERFORMED );
+ DESCRIBE_EVENT( "awt", "XActionListener", "actionPerformed", ACTIONPERFORMED );
+ DESCRIBE_EVENT( "form", "XChangeListener", "changed", CHANGED );
+ DESCRIBE_EVENT( "awt", "XTextListener", "textChanged", TEXTCHANGED );
+ DESCRIBE_EVENT( "awt", "XItemListener", "itemStateChanged", ITEMSTATECHANGED );
+ DESCRIBE_EVENT( "awt", "XFocusListener", "focusGained", FOCUSGAINED );
+ DESCRIBE_EVENT( "awt", "XFocusListener", "focusLost", FOCUSLOST );
+ DESCRIBE_EVENT( "awt", "XKeyListener", "keyPressed", KEYTYPED );
+ DESCRIBE_EVENT( "awt", "XKeyListener", "keyReleased", KEYUP );
+ DESCRIBE_EVENT( "awt", "XMouseListener", "mouseEntered", MOUSEENTERED );
+ DESCRIBE_EVENT( "awt", "XMouseMotionListener", "mouseDragged", MOUSEDRAGGED );
+ DESCRIBE_EVENT( "awt", "XMouseMotionListener", "mouseMoved", MOUSEMOVED );
+ DESCRIBE_EVENT( "awt", "XMouseListener", "mousePressed", MOUSEPRESSED );
+ DESCRIBE_EVENT( "awt", "XMouseListener", "mouseReleased", MOUSERELEASED );
+ DESCRIBE_EVENT( "awt", "XMouseListener", "mouseExited", MOUSEEXITED );
+ DESCRIBE_EVENT( "form", "XResetListener", "approveReset", APPROVERESETTED );
+ DESCRIBE_EVENT( "form", "XResetListener", "resetted", RESETTED );
+ DESCRIBE_EVENT( "form", "XSubmitListener", "approveSubmit", SUBMITTED );
+ DESCRIBE_EVENT( "form", "XUpdateListener", "approveUpdate", BEFOREUPDATE );
+ DESCRIBE_EVENT( "form", "XUpdateListener", "updated", AFTERUPDATE );
+ DESCRIBE_EVENT( "form", "XLoadListener", "loaded", LOADED );
+ DESCRIBE_EVENT( "form", "XLoadListener", "reloading", RELOADING );
+ DESCRIBE_EVENT( "form", "XLoadListener", "reloaded", RELOADED );
+ DESCRIBE_EVENT( "form", "XLoadListener", "unloading", UNLOADING );
+ DESCRIBE_EVENT( "form", "XLoadListener", "unloaded", UNLOADED );
+ DESCRIBE_EVENT( "form", "XConfirmDeleteListener", "confirmDelete", CONFIRMDELETE );
+ DESCRIBE_EVENT( "sdb", "XRowSetApproveListener", "approveRowChange", APPROVEROWCHANGE );
+ DESCRIBE_EVENT( "sdbc", "XRowSetListener", "rowChanged", ROWCHANGE );
+ DESCRIBE_EVENT( "sdb", "XRowSetApproveListener", "approveCursorMove", POSITIONING );
+ DESCRIBE_EVENT( "sdbc", "XRowSetListener", "cursorMoved", POSITIONED );
+ DESCRIBE_EVENT( "form", "XDatabaseParameterListener", "approveParameter", APPROVEPARAMETER );
+ DESCRIBE_EVENT( "sdb", "XSQLErrorListener", "errorOccured", ERROROCCURED );
+ DESCRIBE_EVENT( "awt", "XAdjustmentListener", "adjustmentValueChanged", ADJUSTMENTVALUECHANGED );
+ }
+ }
+
+ EventMap::const_iterator pos = s_aKnownEvents.find( _rMethodName );
+ if ( pos == s_aKnownEvents.end() )
+ return false;
+
+ _out_rDescription = pos->second;
+ return true;
+ }
+
+ //....................................................................
+ ::rtl::OUString lcl_getEventPropertyName( const ::rtl::OUString& _rListenerClassName, const ::rtl::OUString& _rMethodName )
+ {
+ ::rtl::OUStringBuffer aPropertyName;
+ aPropertyName.append( _rListenerClassName );
+ aPropertyName.append( (sal_Unicode)';' );
+ aPropertyName.append( _rMethodName.getStr() );
+ return aPropertyName.makeStringAndClear();
+ }
+
+ //................................................................
+ ScriptEventDescriptor lcl_getAssignedScriptEvent( const EventDescription& _rEvent, const Sequence< ScriptEventDescriptor >& _rAllAssignedMacros )
+ {
+ ScriptEventDescriptor aScriptEvent;
+ // for the case there is actually no event assigned, initialize at least ListenerType and MethodName,
+ // so this ScriptEventDescriptor properly describes the given event
+ aScriptEvent.ListenerType = _rEvent.sListenerClassName;
+ aScriptEvent.EventMethod = _rEvent.sListenerMethodName;
+
+ const ScriptEventDescriptor* pAssignedEvent = _rAllAssignedMacros.getConstArray();
+ sal_Int32 assignedEventCount( _rAllAssignedMacros.getLength() );
+ for ( sal_Int32 assignedEvent = 0; assignedEvent < assignedEventCount; ++assignedEvent, ++pAssignedEvent )
+ {
+ if ( ( pAssignedEvent->ListenerType != _rEvent.sListenerClassName )
+ || ( pAssignedEvent->EventMethod != _rEvent.sListenerMethodName )
+ )
+ continue;
+
+ if ( ( pAssignedEvent->ScriptCode.getLength() == 0 )
+ || ( pAssignedEvent->ScriptType.getLength() == 0 )
+ )
+ {
+ DBG_ERROR( "lcl_getAssignedScriptEvent: me thinks this should not happen!" );
+ continue;
+ }
+
+ aScriptEvent = *pAssignedEvent;
+
+ if ( !aScriptEvent.ScriptType.equalsAscii( "StarBasic" ) )
+ continue;
+
+ // this is an old-style macro specification:
+ // [document|application]:Library.Module.Function
+ // we need to translate this to the new-style macro specification
+ // vnd.sun.star.script:Library.Module.Function?language=Basic&location=[document|application]
+
+ sal_Int32 nPrefixLen = aScriptEvent.ScriptCode.indexOf( ':' );
+ OSL_ENSURE( nPrefixLen > 0, "lcl_getAssignedScriptEvent: illegal location!" );
+ ::rtl::OUString sLocation = aScriptEvent.ScriptCode.copy( 0, nPrefixLen );
+ ::rtl::OUString sMacroPath = aScriptEvent.ScriptCode.copy( nPrefixLen + 1 );
+
+ ::rtl::OUStringBuffer aNewStyleSpec;
+ aNewStyleSpec.appendAscii( "vnd.sun.star.script:" );
+ aNewStyleSpec.append ( sMacroPath );
+ aNewStyleSpec.appendAscii( "?language=Basic&location=" );
+ aNewStyleSpec.append ( sLocation );
+
+ aScriptEvent.ScriptCode = aNewStyleSpec.makeStringAndClear();
+
+ // also, this new-style spec requires the script code to be "Script" instead of "StarBasic"
+ aScriptEvent.ScriptType = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Script" ) );
+ }
+ return aScriptEvent;
+ }
+
+ //................................................................
+ ::rtl::OUString lcl_getQualifiedKnownListenerName( const ScriptEventDescriptor& _rFormComponentEventDescriptor )
+ {
+ EventDescription aKnownEvent;
+ if ( lcl_getEventDescriptionForMethod( _rFormComponentEventDescriptor.EventMethod, aKnownEvent ) )
+ return aKnownEvent.sListenerClassName;
+ DBG_ERROR( "lcl_getQualifiedKnownListenerName: unknown method name!" );
+ // somebody assigned an script to a form component event which we don't know
+ // Speaking strictly, this is not really an error - it is possible to do
+ // this programmatically -, but it should rarely happen, since it's not possible
+ // via UI
+ return _rFormComponentEventDescriptor.ListenerType;
+ }
+
+ //................................................................
+ typedef ::std::set< Type, TypeLessByName > TypeBag;
+
+ //................................................................
+ void lcl_addListenerTypesFor_throw( const Reference< XInterface >& _rxComponent,
+ const Reference< XIntrospection >& _rxIntrospection, TypeBag& _out_rTypes )
+ {
+ if ( !_rxComponent.is() )
+ return;
+ OSL_PRECOND( _rxIntrospection.is(), "lcl_addListenerTypesFor_throw: this will crash!" );
+
+ Reference< XIntrospectionAccess > xIntrospectionAccess(
+ _rxIntrospection->inspect( makeAny( _rxComponent ) ), UNO_QUERY_THROW );
+
+ Sequence< Type > aListeners( xIntrospectionAccess->getSupportedListeners() );
+
+ ::std::copy( aListeners.getConstArray(), aListeners.getConstArray() + aListeners.getLength(),
+ ::std::insert_iterator< TypeBag >( _out_rTypes, _out_rTypes.begin() ) );
+ }
+
+ //................................................................
+ bool operator ==( const ScriptEventDescriptor _lhs, const ScriptEventDescriptor _rhs )
+ {
+ return ( ( _lhs.ListenerType == _rhs.ListenerType )
+ && ( _lhs.EventMethod == _rhs.EventMethod )
+ && ( _lhs.AddListenerParam == _rhs.AddListenerParam )
+ && ( _lhs.ScriptType == _rhs.ScriptType )
+ && ( _lhs.ScriptCode == _rhs.ScriptCode )
+ );
+ }
+ }
+
+ //====================================================================
+ //= EventHandler
+ //====================================================================
+ typedef ::cppu::WeakImplHelper1 < ::com::sun::star::container::XNameReplace
+ > EventHolder_Base;
+ /** a UNO component holding assigned event descriptions, for use with a SvxMacroAssignDlg
+ */
+ class EventHolder : public EventHolder_Base
+ {
+ private:
+ typedef ::std::hash_map< ::rtl::OUString, ScriptEventDescriptor, ::rtl::OUStringHash > EventMap;
+ typedef ::std::map< EventId, EventMap::iterator > EventMapIndexAccess;
+
+ EventMap m_aEventNameAccess;
+ EventMapIndexAccess m_aEventIndexAccess;
+
+ public:
+ EventHolder( );
+
+ void addEvent( EventId _nId, const ::rtl::OUString& _rEventName, const ScriptEventDescriptor& _rScriptEvent );
+
+ /** effectively the same as getByName, but instead of converting the ScriptEventDescriptor to the weird
+ format used by the macro assignment dialog, it is returned directly
+ */
+ ScriptEventDescriptor getNormalizedDescriptorByName( const ::rtl::OUString& _rEventName ) const;
+
+ // XNameReplace
+ virtual void SAL_CALL replaceByName( const ::rtl::OUString& _rName, const Any& aElement ) throw (IllegalArgumentException, NoSuchElementException, WrappedTargetException, RuntimeException);
+ virtual Any SAL_CALL getByName( const ::rtl::OUString& _rName ) throw (NoSuchElementException, WrappedTargetException, RuntimeException);
+ virtual Sequence< ::rtl::OUString > SAL_CALL getElementNames( ) throw (RuntimeException);
+ virtual ::sal_Bool SAL_CALL hasByName( const ::rtl::OUString& _rName ) throw (RuntimeException);
+ virtual Type SAL_CALL getElementType( ) throw (RuntimeException);
+ virtual ::sal_Bool SAL_CALL hasElements( ) throw (RuntimeException);
+
+ protected:
+ ~EventHolder( );
+
+ private:
+ ScriptEventDescriptor impl_getDescriptor_throw( const ::rtl::OUString& _rEventName ) const;
+ };
+
+ DBG_NAME( EventHolder )
+ //------------------------------------------------------------------------
+ EventHolder::EventHolder()
+ {
+ DBG_CTOR( EventHolder, NULL );
+ }
+
+ //------------------------------------------------------------------------
+ EventHolder::~EventHolder()
+ {
+ m_aEventNameAccess.clear();
+ m_aEventIndexAccess.clear();
+ DBG_DTOR( EventHolder, NULL );
+ }
+
+ //------------------------------------------------------------------------
+ void EventHolder::addEvent( EventId _nId, const ::rtl::OUString& _rEventName, const ScriptEventDescriptor& _rScriptEvent )
+ {
+ ::std::pair< EventMap::iterator, bool > insertionResult =
+ m_aEventNameAccess.insert( EventMap::value_type( _rEventName, _rScriptEvent ) );
+ OSL_ENSURE( insertionResult.second, "EventHolder::addEvent: there already was a MacroURL for this event!" );
+ m_aEventIndexAccess[ _nId ] = insertionResult.first;
+ }
+
+ //------------------------------------------------------------------------
+ ScriptEventDescriptor EventHolder::getNormalizedDescriptorByName( const ::rtl::OUString& _rEventName ) const
+ {
+ return impl_getDescriptor_throw( _rEventName );
+ }
+
+ //------------------------------------------------------------------------
+ ScriptEventDescriptor EventHolder::impl_getDescriptor_throw( const ::rtl::OUString& _rEventName ) const
+ {
+ EventMap::const_iterator pos = m_aEventNameAccess.find( _rEventName );
+ if ( pos == m_aEventNameAccess.end() )
+ throw NoSuchElementException( ::rtl::OUString(), *const_cast< EventHolder* >( this ) );
+ return pos->second;
+ }
+
+ //------------------------------------------------------------------------
+ void SAL_CALL EventHolder::replaceByName( const ::rtl::OUString& _rName, const Any& _rElement ) throw (IllegalArgumentException, NoSuchElementException, WrappedTargetException, RuntimeException)
+ {
+ EventMap::iterator pos = m_aEventNameAccess.find( _rName );
+ if ( pos == m_aEventNameAccess.end() )
+ throw NoSuchElementException( ::rtl::OUString(), *this );
+
+ Sequence< PropertyValue > aScriptDescriptor;
+ OSL_VERIFY( _rElement >>= aScriptDescriptor );
+
+ ::comphelper::NamedValueCollection aExtractor( aScriptDescriptor );
+
+ pos->second.ScriptType = aExtractor.getOrDefault( "EventType", ::rtl::OUString() );
+ pos->second.ScriptCode = aExtractor.getOrDefault( "Script", ::rtl::OUString() );
+ }
+
+ //------------------------------------------------------------------------
+ Any SAL_CALL EventHolder::getByName( const ::rtl::OUString& _rName ) throw (NoSuchElementException, WrappedTargetException, RuntimeException)
+ {
+ ScriptEventDescriptor aDescriptor( impl_getDescriptor_throw( _rName ) );
+
+ Any aRet;
+ Sequence< PropertyValue > aScriptDescriptor( 2 );
+ aScriptDescriptor[0].Name = ::rtl::OUString::createFromAscii( "EventType" );
+ aScriptDescriptor[0].Value <<= aDescriptor.ScriptType;
+ aScriptDescriptor[1].Name = ::rtl::OUString::createFromAscii( "Script" );
+ aScriptDescriptor[1].Value <<= aDescriptor.ScriptCode;
+
+ return makeAny( aScriptDescriptor );
+ }
+
+ //------------------------------------------------------------------------
+ Sequence< ::rtl::OUString > SAL_CALL EventHolder::getElementNames( ) throw (RuntimeException)
+ {
+ Sequence< ::rtl::OUString > aReturn( m_aEventIndexAccess.size() );
+ ::rtl::OUString* pReturn = aReturn.getArray();
+
+ // SvxMacroAssignDlg has a weird API: It expects a XNameReplace, means a container whose
+ // main access method is by name. In it's UI, it shows the possible events in exactly the
+ // order in which XNameAccess::getElementNames returns them.
+ // However, SvxMacroAssignDlg *also* takes an index for the initial selection, which is
+ // relative to the sequence returned by XNameAccess::getElementNames.
+ // This is IMO weird, since it mixes index access with name access, which decreases efficiency
+ // of the implementation.
+ // Well, it means we're forced to return the events in getElementNames in exactly the same as they
+ // appear in the property browser UI.
+ for ( EventMapIndexAccess::const_iterator loop = m_aEventIndexAccess.begin();
+ loop != m_aEventIndexAccess.end();
+ ++loop, ++pReturn
+ )
+ *pReturn = loop->second->first;
+ return aReturn;
+ }
+
+ //------------------------------------------------------------------------
+ sal_Bool SAL_CALL EventHolder::hasByName( const ::rtl::OUString& _rName ) throw (RuntimeException)
+ {
+ EventMap::const_iterator pos = m_aEventNameAccess.find( _rName );
+ return pos != m_aEventNameAccess.end();
+ }
+
+ //------------------------------------------------------------------------
+ Type SAL_CALL EventHolder::getElementType( ) throw (RuntimeException)
+ {
+ return ::getCppuType( static_cast< Sequence< PropertyValue >* >( NULL ) );
+ }
+
+ //------------------------------------------------------------------------
+ sal_Bool SAL_CALL EventHolder::hasElements( ) throw (RuntimeException)
+ {
+ return !m_aEventNameAccess.empty();
+ }
+
+
+ //====================================================================
+ //= EventHandler
+ //====================================================================
+ DBG_NAME( EventHandler )
+ //--------------------------------------------------------------------
+ EventHandler::EventHandler( const Reference< XComponentContext >& _rxContext )
+ :EventHandler_Base( m_aMutex )
+ ,m_aContext( _rxContext )
+ ,m_aPropertyListeners( m_aMutex )
+ ,m_bEventsMapInitialized( false )
+ ,m_bIsDialogElement( false )
+ ,m_nGridColumnType( -1 )
+ {
+ DBG_CTOR( EventHandler, NULL );
+ }
+
+ //--------------------------------------------------------------------
+ EventHandler::~EventHandler()
+ {
+ DBG_DTOR( EventHandler, NULL );
+ }
+
+ //--------------------------------------------------------------------
+ ::rtl::OUString SAL_CALL EventHandler::getImplementationName( ) throw (RuntimeException)
+ {
+ return getImplementationName_static();
+ }
+
+ //--------------------------------------------------------------------
+ ::sal_Bool SAL_CALL EventHandler::supportsService( const ::rtl::OUString& ServiceName ) throw (RuntimeException)
+ {
+ StlSyntaxSequence< ::rtl::OUString > aAllServices( getSupportedServiceNames() );
+ return ::std::find( aAllServices.begin(), aAllServices.end(), ServiceName ) != aAllServices.end();
+ }
+
+ //--------------------------------------------------------------------
+ Sequence< ::rtl::OUString > SAL_CALL EventHandler::getSupportedServiceNames( ) throw (RuntimeException)
+ {
+ return getSupportedServiceNames_static();
+ }
+
+ //--------------------------------------------------------------------
+ ::rtl::OUString SAL_CALL EventHandler::getImplementationName_static( ) throw (RuntimeException)
+ {
+ return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.extensions.EventHandler" ) );
+ }
+
+ //--------------------------------------------------------------------
+ Sequence< ::rtl::OUString > SAL_CALL EventHandler::getSupportedServiceNames_static( ) throw (RuntimeException)
+ {
+ Sequence< ::rtl::OUString > aSupported( 1 );
+ aSupported[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.form.inspection.EventHandler" ) );
+ return aSupported;
+ }
+
+ //--------------------------------------------------------------------
+ Reference< XInterface > SAL_CALL EventHandler::Create( const Reference< XComponentContext >& _rxContext )
+ {
+ return *( new EventHandler( _rxContext ) );
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL EventHandler::inspect( const Reference< XInterface >& _rxIntrospectee ) throw (RuntimeException, NullPointerException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ if ( !_rxIntrospectee.is() )
+ throw NullPointerException();
+
+ m_xComponent = Reference< XPropertySet >( _rxIntrospectee, UNO_QUERY_THROW );
+
+ m_bEventsMapInitialized = false;
+ EventMap aEmpty;
+ m_aEvents.swap( aEmpty );
+
+ m_bIsDialogElement = false;
+ m_nGridColumnType = -1;
+ try
+ {
+ Reference< XPropertySetInfo > xPSI( m_xComponent->getPropertySetInfo() );
+ m_bIsDialogElement = xPSI.is()
+ && xPSI->hasPropertyByName( PROPERTY_WIDTH )
+ && xPSI->hasPropertyByName( PROPERTY_HEIGHT )
+ && xPSI->hasPropertyByName( PROPERTY_POSITIONX )
+ && xPSI->hasPropertyByName( PROPERTY_POSITIONY );
+
+ Reference< XChild > xAsChild( _rxIntrospectee, UNO_QUERY );
+ if ( xAsChild.is() && !Reference< XForm >( _rxIntrospectee, UNO_QUERY ).is() )
+ {
+ if ( FormComponentType::GRIDCONTROL == classifyComponent( xAsChild->getParent() ) )
+ {
+ m_nGridColumnType = classifyComponent( _rxIntrospectee );
+ }
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+
+ //--------------------------------------------------------------------
+ Any SAL_CALL EventHandler::getPropertyValue( const ::rtl::OUString& _rPropertyName ) throw (UnknownPropertyException, RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ const EventDescription& rEvent = impl_getEventForName_throw( _rPropertyName );
+
+ Sequence< ScriptEventDescriptor > aEvents;
+ impl_getComponentScriptEvents_nothrow( aEvents );
+
+ sal_Int32 nEventCount = aEvents.getLength();
+ const ScriptEventDescriptor* pEvents = aEvents.getConstArray();
+
+ ScriptEventDescriptor aPropertyValue;
+ for ( sal_Int32 event = 0; event < nEventCount; ++event, ++pEvents )
+ {
+ if ( rEvent.sListenerClassName == pEvents->ListenerType
+ && rEvent.sListenerMethodName == pEvents->EventMethod
+ )
+ {
+ aPropertyValue = *pEvents;
+ break;
+ }
+ }
+
+ return makeAny( aPropertyValue );
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL EventHandler::setPropertyValue( const ::rtl::OUString& _rPropertyName, const Any& _rValue ) throw (UnknownPropertyException, RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ const EventDescription& rEvent = impl_getEventForName_throw( _rPropertyName );
+
+ ScriptEventDescriptor aNewScriptEvent;
+ OSL_VERIFY( _rValue >>= aNewScriptEvent );
+
+ ScriptEventDescriptor aOldScriptEvent;
+ OSL_VERIFY( getPropertyValue( _rPropertyName ) >>= aOldScriptEvent );
+ if ( aOldScriptEvent == aNewScriptEvent )
+ return;
+
+ if ( m_bIsDialogElement )
+ impl_setDialogElementScriptEvent_nothrow( aNewScriptEvent );
+ else
+ impl_setFormComponentScriptEvent_nothrow( aNewScriptEvent );
+
+ Reference< XModifiable > xDoc( m_aContext.getContextValueByAsciiName( "ContextDocument" ), UNO_QUERY );
+ if ( xDoc.is() )
+ xDoc->setModified( sal_True );
+
+ PropertyChangeEvent aEvent;
+ aEvent.Source = m_xComponent;
+ aEvent.PropertyHandle = rEvent.nId;
+ aEvent.PropertyName = _rPropertyName;
+ aEvent.OldValue <<= aOldScriptEvent;
+ aEvent.NewValue <<= aNewScriptEvent;
+ m_aPropertyListeners.notify( aEvent, &XPropertyChangeListener::propertyChange );
+ }
+
+ //--------------------------------------------------------------------
+ Any SAL_CALL EventHandler::convertToPropertyValue( const ::rtl::OUString& _rPropertyName, const Any& _rControlValue ) throw (UnknownPropertyException, RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ ::rtl::OUString sNewScriptCode;
+ OSL_VERIFY( _rControlValue >>= sNewScriptCode );
+
+ Sequence< ScriptEventDescriptor > aAllAssignedEvents;
+ impl_getComponentScriptEvents_nothrow( aAllAssignedEvents );
+
+ const EventDescription& rEvent = impl_getEventForName_throw( _rPropertyName );
+ ScriptEventDescriptor aAssignedScript = lcl_getAssignedScriptEvent( rEvent, aAllAssignedEvents );
+
+ OSL_ENSURE( !sNewScriptCode.getLength(), "EventHandler::convertToPropertyValue: cannot convert a non-empty display name!" );
+ // Usually, there is no possibility for the user to change the content of an event binding directly in the
+ // input field, this instead is done with the macro assignment dialog.
+ // The only exception is the user pressing "DEL" while the control has the focus, in this case, we reset the
+ // control content to an empty string. So this is the only scenario where this method is allowed to be called.
+
+ // Striclty, we would be able to convert the display value to a property value,
+ // using the "name (location, language)" format we used in convertToControlValue. However,
+ // there is no need for this code ...
+
+ aAssignedScript.ScriptCode = sNewScriptCode;
+ return makeAny( aAssignedScript );
+ }
+
+ //--------------------------------------------------------------------
+ Any SAL_CALL EventHandler::convertToControlValue( const ::rtl::OUString& /*_rPropertyName*/, const Any& _rPropertyValue, const Type& _rControlValueType ) throw (UnknownPropertyException, RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ ScriptEventDescriptor aScriptEvent;
+ OSL_VERIFY( _rPropertyValue >>= aScriptEvent );
+
+ OSL_ENSURE( _rControlValueType.getTypeClass() == TypeClass_STRING,
+ "EventHandler::convertToControlValue: unexpected ControlValue type class!" );
+ (void)_rControlValueType;
+
+ ::rtl::OUString sScript( aScriptEvent.ScriptCode );
+ if ( sScript.getLength() )
+ {
+ // format is: "name (location, language)"
+ try
+ {
+ // parse
+ Reference< XUriReferenceFactory > xUriRefFac = UriReferenceFactory::create( m_aContext.getUNOContext() );
+ Reference< XVndSunStarScriptUrlReference > xScriptUri( xUriRefFac->parse( sScript ), UNO_QUERY_THROW );
+
+ ::rtl::OUStringBuffer aComposeBuffer;
+
+ // name
+ aComposeBuffer.append( xScriptUri->getName() );
+
+ // location
+ const ::rtl::OUString sLocationParamName( RTL_CONSTASCII_USTRINGPARAM( "location" ) );
+ const ::rtl::OUString sLocation = xScriptUri->getParameter( sLocationParamName );
+ const ::rtl::OUString sLangParamName( RTL_CONSTASCII_USTRINGPARAM( "language" ) );
+ const ::rtl::OUString sLanguage = xScriptUri->getParameter( sLangParamName );
+
+ if ( sLocation.getLength() || sLanguage.getLength() )
+ {
+ aComposeBuffer.appendAscii( " (" );
+
+ // location
+ OSL_ENSURE( sLocation.getLength(), "EventHandler::convertToControlValue: unexpected: no location!" );
+ if ( sLocation.getLength() )
+ {
+ aComposeBuffer.append( sLocation );
+ aComposeBuffer.appendAscii( ", " );
+ }
+
+ // language
+ if ( sLanguage.getLength() )
+ {
+ aComposeBuffer.append( sLanguage );
+ }
+
+ aComposeBuffer.append( sal_Unicode( ')' ) );
+ }
+
+ sScript = aComposeBuffer.makeStringAndClear();
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+
+ return makeAny( sScript );
+ }
+
+ //--------------------------------------------------------------------
+ PropertyState SAL_CALL EventHandler::getPropertyState( const ::rtl::OUString& /*_rPropertyName*/ ) throw (UnknownPropertyException, RuntimeException)
+ {
+ return PropertyState_DIRECT_VALUE;
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL EventHandler::addPropertyChangeListener( const Reference< XPropertyChangeListener >& _rxListener ) throw (RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ if ( !_rxListener.is() )
+ throw NullPointerException();
+ m_aPropertyListeners.addListener( _rxListener );
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL EventHandler::removePropertyChangeListener( const Reference< XPropertyChangeListener >& _rxListener ) throw (RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ m_aPropertyListeners.removeListener( _rxListener );
+ }
+
+ //--------------------------------------------------------------------
+ Sequence< Property > SAL_CALL EventHandler::getSupportedProperties() throw (RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ if ( !m_bEventsMapInitialized )
+ {
+ const_cast< EventHandler* >( this )->m_bEventsMapInitialized = true;
+ try
+ {
+ Sequence< Type > aListeners;
+ impl_getCopmonentListenerTypes_nothrow( aListeners );
+ sal_Int32 listenerCount = aListeners.getLength();
+
+ Property aCurrentProperty;
+ ::rtl::OUString sListenerClassName;
+
+ // loop through all listeners and all methods, and see which we can present at the UI
+ const Type* pListeners = aListeners.getConstArray();
+ for ( sal_Int32 listener = 0; listener < listenerCount; ++listener, ++pListeners )
+ {
+ aCurrentProperty = Property();
+
+ // the programmatic name of the listener, to be used as "property" name
+ sListenerClassName = pListeners->getTypeName();
+ OSL_ENSURE( sListenerClassName.getLength(), "EventHandler::getSupportedProperties: strange - no listener name ..." );
+ if ( !sListenerClassName.getLength() )
+ continue;
+
+ // loop through all methods
+ Sequence< ::rtl::OUString > aMethods( comphelper::getEventMethodsForType( *pListeners ) );
+
+ const ::rtl::OUString* pMethods = aMethods.getConstArray();
+ sal_uInt32 methodCount = aMethods.getLength();
+
+ for (sal_uInt32 method = 0 ; method < methodCount ; ++method, ++pMethods )
+ {
+ EventDescription aEvent;
+ if ( !lcl_getEventDescriptionForMethod( *pMethods, aEvent ) )
+ continue;
+
+ if ( !impl_filterMethod_nothrow( aEvent ) )
+ continue;
+
+ const_cast< EventHandler* >( this )->m_aEvents.insert( EventMap::value_type(
+ lcl_getEventPropertyName( sListenerClassName, *pMethods ), aEvent ) );
+ }
+ }
+
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+
+ // sort them by ID - this is the relative ordering in the UI
+ ::std::map< EventId, Property > aOrderedProperties;
+ for ( EventMap::const_iterator loop = m_aEvents.begin();
+ loop != m_aEvents.end();
+ ++loop
+ )
+ {
+ aOrderedProperties[ loop->second.nId ] = Property(
+ loop->first, loop->second.nId,
+ ::getCppuType( static_cast< const ::rtl::OUString* >( NULL ) ),
+ PropertyAttribute::BOUND );
+ }
+
+ StlSyntaxSequence< Property > aReturn( aOrderedProperties.size() );
+ ::std::transform( aOrderedProperties.begin(), aOrderedProperties.end(), aReturn.begin(),
+ ::std::select2nd< ::std::map< EventId, Property >::value_type >() );
+ return aReturn;
+ }
+
+ //--------------------------------------------------------------------
+ Sequence< ::rtl::OUString > SAL_CALL EventHandler::getSupersededProperties( ) throw (RuntimeException)
+ {
+ // none
+ return Sequence< ::rtl::OUString >( );
+ }
+
+ //--------------------------------------------------------------------
+ Sequence< ::rtl::OUString > SAL_CALL EventHandler::getActuatingProperties( ) throw (RuntimeException)
+ {
+ // none
+ return Sequence< ::rtl::OUString >( );
+ }
+
+ //--------------------------------------------------------------------
+ LineDescriptor SAL_CALL EventHandler::describePropertyLine( const ::rtl::OUString& _rPropertyName,
+ const Reference< XPropertyControlFactory >& _rxControlFactory )
+ throw (UnknownPropertyException, NullPointerException, RuntimeException)
+ {
+ if ( !_rxControlFactory.is() )
+ throw NullPointerException();
+
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ LineDescriptor aDescriptor;
+
+ aDescriptor.Control = _rxControlFactory->createPropertyControl( PropertyControlType::TextField, sal_True );
+ Reference< XEventListener > xControlExtender = new PropertyControlExtender( aDescriptor.Control );
+
+ const EventDescription& rEvent = impl_getEventForName_throw( _rPropertyName );
+ aDescriptor.DisplayName = rEvent.sDisplayName;
+ aDescriptor.HelpURL = HelpIdUrl::getHelpURL( rEvent.nHelpId );
+ aDescriptor.PrimaryButtonId = rEvent.nUniqueBrowseId;
+ aDescriptor.HasPrimaryButton = sal_True;
+ aDescriptor.Category = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Events" ) );
+ return aDescriptor;
+ }
+
+ //--------------------------------------------------------------------
+ ::sal_Bool SAL_CALL EventHandler::isComposable( const ::rtl::OUString& /*_rPropertyName*/ ) throw (UnknownPropertyException, RuntimeException)
+ {
+ return sal_False;
+ }
+
+ //--------------------------------------------------------------------
+ InteractiveSelectionResult SAL_CALL EventHandler::onInteractivePropertySelection( const ::rtl::OUString& _rPropertyName, sal_Bool /*_bPrimary*/, Any& /*_rData*/, const Reference< XObjectInspectorUI >& _rxInspectorUI ) throw (UnknownPropertyException, NullPointerException, RuntimeException)
+ {
+ if ( !_rxInspectorUI.is() )
+ throw NullPointerException();
+
+ ::osl::MutexGuard aGuard( m_aMutex );
+ const EventDescription& rForEvent = impl_getEventForName_throw( _rPropertyName );
+
+ Sequence< ScriptEventDescriptor > aAllAssignedEvents;
+ impl_getComponentScriptEvents_nothrow( aAllAssignedEvents );
+
+ // SvxMacroAssignDlg-compatible structure holding all event/assignments
+ ::rtl::Reference< EventHolder > pEventHolder( new EventHolder );
+
+ for ( EventMap::const_iterator event = m_aEvents.begin();
+ event != m_aEvents.end();
+ ++event
+ )
+ {
+ // the script which is assigned to the current event (if any)
+ ScriptEventDescriptor aAssignedScript = lcl_getAssignedScriptEvent( event->second, aAllAssignedEvents );
+ pEventHolder->addEvent( event->second.nId, event->second.sListenerMethodName, aAssignedScript );
+ }
+
+ // the inital selection in the dialog
+ Sequence< ::rtl::OUString > aNames( pEventHolder->getElementNames() );
+ const ::rtl::OUString* pChosenEvent = ::std::find( aNames.getConstArray(), aNames.getConstArray() + aNames.getLength(), rForEvent.sListenerMethodName );
+ sal_uInt16 nInitialSelection = (sal_uInt16)( pChosenEvent - aNames.getConstArray() );
+
+ // the dialog
+ SvxAbstractDialogFactory* pFactory = SvxAbstractDialogFactory::Create();
+ if ( !pFactory )
+ return InteractiveSelectionResult_Cancelled;
+
+ ::std::auto_ptr< VclAbstractDialog > pDialog( pFactory->CreateSvxMacroAssignDlg(
+ PropertyHandlerHelper::getDialogParentWindow( m_aContext ),
+ impl_getContextFrame_nothrow(),
+ m_bIsDialogElement,
+ pEventHolder.get(),
+ nInitialSelection
+ ) );
+
+ if ( !pDialog.get() )
+ return InteractiveSelectionResult_Cancelled;
+
+ // DF definite problem here
+ // OK & Cancel seem to be both returning 0
+ if ( pDialog->Execute() != 0 )
+ return InteractiveSelectionResult_Cancelled;
+
+ try
+ {
+ for ( EventMap::const_iterator event = m_aEvents.begin();
+ event != m_aEvents.end();
+ ++event
+ )
+ {
+ ScriptEventDescriptor aScriptDescriptor( pEventHolder->getNormalizedDescriptorByName( event->second.sListenerMethodName ) );
+
+ // set the new "property value"
+ setPropertyValue(
+ lcl_getEventPropertyName( event->second.sListenerClassName, event->second.sListenerMethodName ),
+ makeAny( aScriptDescriptor )
+ );
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+ return InteractiveSelectionResult_Success;
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL EventHandler::actuatingPropertyChanged( const ::rtl::OUString& /*_rActuatingPropertyName*/, const Any& /*_rNewValue*/, const Any& /*_rOldValue*/, const Reference< XObjectInspectorUI >& /*_rxInspectorUI*/, sal_Bool /*_bFirstTimeInit*/ ) throw (NullPointerException, RuntimeException)
+ {
+ DBG_ERROR( "EventHandler::actuatingPropertyChanged: no actuating properties -> no callback (well, this is how it *should* be!)" );
+ }
+
+ //--------------------------------------------------------------------
+ IMPLEMENT_FORWARD_XCOMPONENT( EventHandler, EventHandler_Base )
+
+ //--------------------------------------------------------------------
+ void SAL_CALL EventHandler::disposing()
+ {
+ EventMap aEmpty;
+ m_aEvents.swap( aEmpty );
+ m_xComponent.clear();
+ }
+
+ //--------------------------------------------------------------------
+ sal_Bool SAL_CALL EventHandler::suspend( sal_Bool /*_bSuspend*/ ) throw (RuntimeException)
+ {
+ return sal_True;
+ }
+
+ //------------------------------------------------------------------------
+ Reference< XFrame > EventHandler::impl_getContextFrame_nothrow() const
+ {
+ Reference< XFrame > xContextFrame;
+
+ try
+ {
+ Reference< XModel > xContextDocument( m_aContext.getContextValueByAsciiName( "ContextDocument" ), UNO_QUERY_THROW );
+ Reference< XController > xController( xContextDocument->getCurrentController(), UNO_SET_THROW );
+ xContextFrame.set( xController->getFrame(), UNO_SET_THROW );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+ return xContextFrame;
+ }
+
+ //--------------------------------------------------------------------
+ sal_Int32 EventHandler::impl_getComponentIndexInParent_throw() const
+ {
+ Reference< XChild > xChild( m_xComponent, UNO_QUERY_THROW );
+ Reference< XIndexAccess > xParentAsIndexAccess( xChild->getParent(), UNO_QUERY_THROW );
+
+ // get the index of the inspected object within it's parent container
+ sal_Int32 nElements = xParentAsIndexAccess->getCount();
+ for ( sal_Int32 i=0; i<nElements; ++i )
+ {
+ Reference< XInterface > xElement( xParentAsIndexAccess->getByIndex( i ), UNO_QUERY_THROW );
+ if ( xElement == m_xComponent )
+ return i;
+ }
+ throw NoSuchElementException();
+ }
+
+ //--------------------------------------------------------------------
+ void EventHandler::impl_getFormComponentScriptEvents_nothrow( Sequence < ScriptEventDescriptor >& _out_rEvents ) const
+ {
+ _out_rEvents = Sequence < ScriptEventDescriptor >();
+ try
+ {
+ Reference< XChild > xChild( m_xComponent, UNO_QUERY_THROW );
+ Reference< XEventAttacherManager > xEventManager( xChild->getParent(), UNO_QUERY_THROW );
+ _out_rEvents = xEventManager->getScriptEvents( impl_getComponentIndexInParent_throw() );
+
+ // the form component script API has unqualified listener names, but for normalization
+ // purpose, we want fully qualified ones
+ ScriptEventDescriptor* pEvents = _out_rEvents.getArray();
+ ScriptEventDescriptor* pEventsEnd = _out_rEvents.getArray() + _out_rEvents.getLength();
+ while ( pEvents != pEventsEnd )
+ {
+ pEvents->ListenerType = lcl_getQualifiedKnownListenerName( *pEvents );
+ ++pEvents;
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+
+ //--------------------------------------------------------------------
+ void EventHandler::impl_getCopmonentListenerTypes_nothrow( Sequence< Type >& _out_rTypes ) const
+ {
+ _out_rTypes.realloc( 0 );
+ try
+ {
+ // we use a set to avoid duplicates
+ TypeBag aListeners;
+
+ Reference< XIntrospection > xIntrospection( m_aContext.createComponent( "com.sun.star.beans.Introspection" ), UNO_QUERY_THROW );
+
+ // --- model listeners
+ lcl_addListenerTypesFor_throw(
+ m_xComponent, xIntrospection, aListeners );
+
+ // --- "secondary component" (usually: "control" listeners)
+ {
+ Reference< XInterface > xSecondaryComponent( impl_getSecondaryComponentForEventInspection_throw() );
+ lcl_addListenerTypesFor_throw( xSecondaryComponent, xIntrospection, aListeners );
+ ::comphelper::disposeComponent( xSecondaryComponent );
+ }
+
+ // now that they're disambiguated, copy these types into our member
+ _out_rTypes.realloc( aListeners.size() );
+ ::std::copy( aListeners.begin(), aListeners.end(), _out_rTypes.getArray() );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+
+ //--------------------------------------------------------------------
+ void EventHandler::impl_getDialogElementScriptEvents_nothrow( Sequence < ScriptEventDescriptor >& _out_rEvents ) const
+ {
+ _out_rEvents = Sequence < ScriptEventDescriptor >();
+ try
+ {
+ Reference< XScriptEventsSupplier > xEventsSupplier( m_xComponent, UNO_QUERY_THROW );
+ Reference< XNameContainer > xEvents( xEventsSupplier->getEvents(), UNO_QUERY_THROW );
+ Sequence< ::rtl::OUString > aEventNames( xEvents->getElementNames() );
+
+ sal_Int32 nEventCount = aEventNames.getLength();
+ _out_rEvents.realloc( nEventCount );
+
+ const ::rtl::OUString* pNames = aEventNames.getConstArray();
+ ScriptEventDescriptor* pDescs = _out_rEvents.getArray();
+
+ for( sal_Int32 i = 0 ; i < nEventCount ; ++i, ++pNames, ++pDescs )
+ OSL_VERIFY( xEvents->getByName( *pNames ) >>= *pDescs );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+
+ //--------------------------------------------------------------------
+ Reference< XInterface > EventHandler::impl_getSecondaryComponentForEventInspection_throw( ) const
+ {
+ Reference< XInterface > xReturn;
+
+ // if it's a form, create a form controller for the additional events
+ Reference< XForm > xComponentAsForm( m_xComponent, UNO_QUERY );
+ if ( xComponentAsForm.is() )
+ {
+ Reference< XTabControllerModel > xComponentAsTCModel( m_xComponent, UNO_QUERY_THROW );
+ Reference< XFormController > xController(
+ m_aContext.createComponent( "com.sun.star.form.runtime.FormController" ), UNO_QUERY_THROW );
+ xController->setModel( xComponentAsTCModel );
+
+ xReturn = xController;
+ }
+ else
+ {
+ ::rtl::OUString sControlService;
+ OSL_VERIFY( m_xComponent->getPropertyValue( PROPERTY_DEFAULTCONTROL ) >>= sControlService );
+
+ xReturn = m_aContext.createComponent( sControlService );
+ }
+ return xReturn;
+ }
+
+ //--------------------------------------------------------------------
+ const EventDescription& EventHandler::impl_getEventForName_throw( const ::rtl::OUString& _rPropertyName ) const
+ {
+ EventMap::const_iterator pos = m_aEvents.find( _rPropertyName );
+ if ( pos == m_aEvents.end() )
+ throw UnknownPropertyException();
+ return pos->second;
+ }
+
+ //--------------------------------------------------------------------
+ namespace
+ {
+ static bool lcl_endsWith( const ::rtl::OUString& _rText, const ::rtl::OUString& _rCheck )
+ {
+ sal_Int32 nTextLen = _rText.getLength();
+ sal_Int32 nCheckLen = _rCheck.getLength();
+ if ( nCheckLen > nTextLen )
+ return false;
+
+ return _rText.indexOf( _rCheck ) == ( nTextLen - nCheckLen );
+ }
+ }
+ //--------------------------------------------------------------------
+ void EventHandler::impl_setFormComponentScriptEvent_nothrow( const ScriptEventDescriptor& _rScriptEvent )
+ {
+ try
+ {
+ ::rtl::OUString sScriptCode( _rScriptEvent.ScriptCode );
+ ::rtl::OUString sScriptType( _rScriptEvent.ScriptType );
+ bool bResetScript = ( sScriptCode.getLength() == 0 );
+
+ sal_Int32 nObjectIndex = impl_getComponentIndexInParent_throw();
+ Reference< XChild > xChild( m_xComponent, UNO_QUERY_THROW );
+ Reference< XEventAttacherManager > xEventManager( xChild->getParent(), UNO_QUERY_THROW );
+ Sequence< ScriptEventDescriptor > aEvents( xEventManager->getScriptEvents( nObjectIndex ) );
+
+ // is there already a registered script for this event?
+ ScriptEventDescriptor* pEvent = aEvents.getArray();
+ sal_Int32 eventCount = aEvents.getLength(), event = 0;
+ for ( event = 0; event < eventCount; ++event, ++pEvent )
+ {
+ if ( ( pEvent->EventMethod == _rScriptEvent.EventMethod )
+ && ( lcl_endsWith( _rScriptEvent.ListenerType, pEvent->ListenerType ) )
+ // (strange enough, the events we get from getScriptEvents are not fully qualified)
+ )
+ {
+ // yes
+ if ( !bResetScript )
+ {
+ // set to something non-empty -> overwrite
+ pEvent->ScriptCode = sScriptCode;
+ pEvent->ScriptType = sScriptType;
+ }
+ else
+ {
+ // set to empty -> remove from sequence
+ ::std::copy( pEvent + 1, aEvents.getArray() + eventCount, pEvent );
+ aEvents.realloc( eventCount - 1 );
+ --eventCount;
+ }
+ break;
+ }
+ }
+ if ( ( event >= eventCount ) && !bResetScript )
+ {
+ // no, did not find it -> append
+ aEvents.realloc( eventCount + 1 );
+ aEvents[ eventCount ] = _rScriptEvent;
+ }
+
+ xEventManager->revokeScriptEvents( nObjectIndex );
+ xEventManager->registerScriptEvents( nObjectIndex, aEvents );
+
+ PropertyHandlerHelper::setContextDocumentModified( m_aContext );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+
+ //--------------------------------------------------------------------
+ void EventHandler::impl_setDialogElementScriptEvent_nothrow( const ScriptEventDescriptor& _rScriptEvent )
+ {
+ try
+ {
+ ::rtl::OUString sScriptCode( _rScriptEvent.ScriptCode );
+ bool bResetScript = ( sScriptCode.getLength() == 0 );
+
+ Reference< XScriptEventsSupplier > xEventsSupplier( m_xComponent, UNO_QUERY_THROW );
+ Reference< XNameContainer > xEvents( xEventsSupplier->getEvents(), UNO_QUERY_THROW );
+
+ ::rtl::OUStringBuffer aCompleteName;
+ aCompleteName.append( _rScriptEvent.ListenerType );
+ aCompleteName.appendAscii( "::" );
+ aCompleteName.append( _rScriptEvent.EventMethod );
+ ::rtl::OUString sCompleteName( aCompleteName.makeStringAndClear() );
+
+ bool bExists = xEvents->hasByName( sCompleteName );
+
+ if ( bResetScript )
+ {
+ if ( bExists )
+ xEvents->removeByName( sCompleteName );
+ }
+ else
+ {
+ Any aNewValue; aNewValue <<= _rScriptEvent;
+
+ if ( bExists )
+ xEvents->replaceByName( sCompleteName, aNewValue );
+ else
+ xEvents->insertByName( sCompleteName, aNewValue );
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+
+ //--------------------------------------------------------------------
+ bool EventHandler::impl_filterMethod_nothrow( const EventDescription& _rEvent ) const
+ {
+ // some (control-triggered) events do not make sense for certain grid control columns. However,
+ // our mechnism to retrieve control-triggered events does not know about this, so we do some
+ // late filtering here.
+ switch ( m_nGridColumnType )
+ {
+ case FormComponentType::COMBOBOX:
+ if ( UID_BRWEVT_ACTIONPERFORMED == _rEvent.nUniqueBrowseId )
+ return false;
+ break;
+ case FormComponentType::LISTBOX:
+ if ( ( UID_BRWEVT_CHANGED == _rEvent.nUniqueBrowseId )
+ || ( UID_BRWEVT_ACTIONPERFORMED == _rEvent.nUniqueBrowseId )
+ )
+ return false;
+ break;
+ }
+
+ return true;
+ }
+
+//........................................................................
+} // namespace pcr
+//........................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/propctrlr/eventhandler.hxx b/extensions/source/propctrlr/eventhandler.hxx
new file mode 100644
index 000000000000..7e113ec741bb
--- /dev/null
+++ b/extensions/source/propctrlr/eventhandler.hxx
@@ -0,0 +1,269 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef EXTENSIONS_SOURCE_PROPCTRLR_EVENTHANDLER_HXX
+#define EXTENSIONS_SOURCE_PROPCTRLR_EVENTHANDLER_HXX
+
+#include "pcrcomponentcontext.hxx"
+#include "pcrcommontypes.hxx"
+#include "pcrcommon.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/script/ScriptEventDescriptor.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/inspection/XPropertyHandler.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/frame/XFrame.hpp>
+/** === end UNO includes === **/
+#include <cppuhelper/compbase2.hxx>
+#include <comphelper/listenernotification.hxx>
+
+//........................................................................
+namespace pcr
+{
+//........................................................................
+
+ //====================================================================
+ //= EventDescription
+ //====================================================================
+ typedef sal_Int32 EventId;
+ struct EventDescription
+ {
+ public:
+ ::rtl::OUString sDisplayName;
+ ::rtl::OUString sListenerClassName;
+ ::rtl::OUString sListenerMethodName;
+ sal_Int32 nHelpId;
+ sal_Int32 nUniqueBrowseId;
+ EventId nId;
+
+ EventDescription()
+ :nHelpId( 0 )
+ ,nUniqueBrowseId( 0 )
+ ,nId( 0 )
+ {
+ }
+
+ EventDescription(
+ EventId _nId,
+ const sal_Char* _pListenerNamespaceAscii,
+ const sal_Char* _pListenerClassAsciiName,
+ const sal_Char* _pListenerMethodAsciiName,
+ sal_uInt16 _nDisplayNameResId,
+ sal_Int32 _nHelpId,
+ sal_Int32 _nUniqueBrowseId );
+ };
+
+ typedef ::std::hash_map< ::rtl::OUString, EventDescription, ::rtl::OUStringHash > EventMap;
+
+ //====================================================================
+ //= EventHandler
+ //====================================================================
+ typedef ::cppu::WeakComponentImplHelper2 < ::com::sun::star::inspection::XPropertyHandler
+ , ::com::sun::star::lang::XServiceInfo
+ > EventHandler_Base;
+ class EventHandler : public EventHandler_Base
+ {
+ private:
+ mutable ::osl::Mutex m_aMutex;
+
+ /// the context in which the instance was created
+ ComponentContext m_aContext;
+ /// the properties of the object we're handling
+ ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > m_xComponent;
+ /// our XPropertyChangeListener(s)
+ PropertyChangeListeners m_aPropertyListeners;
+ /// cache of the events we found at our introspectee
+ EventMap m_aEvents;
+ /// has m_aEvents been initialized?
+ bool m_bEventsMapInitialized;
+ /// is our introspectee a dialog element?
+ bool m_bIsDialogElement;
+ // TODO: move different handling into different derived classes?
+ /// (FormComponent) type of the grid column being inspected, or -1 if we're not inspecting a grid column
+ sal_Int16 m_nGridColumnType;
+
+ public:
+ // XServiceInfo - static versions
+ static ::rtl::OUString SAL_CALL getImplementationName_static( ) throw (::com::sun::star::uno::RuntimeException);
+ static ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames_static( ) throw (::com::sun::star::uno::RuntimeException);
+ static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > Create( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _rxContext );
+
+ protected:
+ EventHandler(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _rxContext
+ );
+
+ ~EventHandler();
+
+ protected:
+ // XPropertyHandler overridables
+ virtual void SAL_CALL inspect( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxIntrospectee ) throw (::com::sun::star::lang::NullPointerException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue( const ::rtl::OUString& _rPropertyName ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setPropertyValue( const ::rtl::OUString& _rPropertyName, const ::com::sun::star::uno::Any& _rValue ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Any SAL_CALL convertToPropertyValue( const ::rtl::OUString& _rPropertyName, const ::com::sun::star::uno::Any& _rControlValue ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Any SAL_CALL convertToControlValue( const ::rtl::OUString& _rPropertyName, const ::com::sun::star::uno::Any& _rPropertyValue, const ::com::sun::star::uno::Type& _rControlValueType ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::beans::PropertyState SAL_CALL getPropertyState( const ::rtl::OUString& _rPropertyName ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL addPropertyChangeListener( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& _rxListener ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL removePropertyChangeListener( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& _rxListener ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property >
+ SAL_CALL getSupportedProperties() throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupersededProperties( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getActuatingProperties( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::inspection::LineDescriptor SAL_CALL describePropertyLine( const ::rtl::OUString& _rPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyControlFactory >& _rxControlFactory ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::NullPointerException, ::com::sun::star::uno::RuntimeException);
+ virtual ::sal_Bool SAL_CALL isComposable( const ::rtl::OUString& _rPropertyName ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::inspection::InteractiveSelectionResult
+ SAL_CALL onInteractivePropertySelection( const ::rtl::OUString& _rPropertyName, sal_Bool _bPrimary, ::com::sun::star::uno::Any& _rData, const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XObjectInspectorUI >& _rxInspectorUI ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::NullPointerException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL actuatingPropertyChanged( const ::rtl::OUString& _rActuatingPropertyName, const ::com::sun::star::uno::Any& _rNewValue, const ::com::sun::star::uno::Any& _rOldValue, const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XObjectInspectorUI >& _rxInspectorUI, sal_Bool _bFirstTimeInit ) throw (::com::sun::star::lang::NullPointerException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL suspend( sal_Bool _bSuspend ) throw (::com::sun::star::uno::RuntimeException);
+
+ // XComponent
+ DECLARE_XCOMPONENT()
+ virtual void SAL_CALL disposing();
+
+ // XServiceInfo
+ virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw (::com::sun::star::uno::RuntimeException);
+
+ private:
+ /** returns the script events associated with our introspectee
+ @param _out_rEvents
+ Takes, upon successfull return, the events currently associated with the introspectee
+ @precond
+ Our introspectee is a form component
+ */
+ void impl_getFormComponentScriptEvents_nothrow(
+ ::com::sun::star::uno::Sequence< ::com::sun::star::script::ScriptEventDescriptor >& _out_rEvents
+ ) const;
+
+ /** returns the script events associated with our introspectee
+ @param _out_rEvents
+ Takes, upon successfull return, the events currently associated with the introspectee
+ @precond
+ Our introspectee is a dialog element
+ */
+ void impl_getDialogElementScriptEvents_nothrow(
+ ::com::sun::star::uno::Sequence< ::com::sun::star::script::ScriptEventDescriptor >& _out_rEvents
+ ) const;
+
+ /** returns the script events associated with our introspectee
+ @param _out_rEvents
+ Takes, the events currently associated with the introspectee
+ */
+ inline void impl_getComponentScriptEvents_nothrow(
+ ::com::sun::star::uno::Sequence< ::com::sun::star::script::ScriptEventDescriptor >& _out_rEvents
+ ) const
+ {
+ if ( m_bIsDialogElement )
+ impl_getDialogElementScriptEvents_nothrow( _out_rEvents );
+ else
+ impl_getFormComponentScriptEvents_nothrow( _out_rEvents );
+ }
+
+ /** returns the types of the listeners which can be registered at our introspectee
+ @param _out_rTypes
+ Takes, upon successfull return, the types of possible listeners at the introspectee
+ */
+ void impl_getCopmonentListenerTypes_nothrow(
+ ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type >& _out_rTypes
+ ) const;
+
+ /** returns a secondary component to be used for event inspection
+
+ In the UI, we want to mix events for the control model with events for the control.
+ Since our introspectee is a model, this method creates a control for it (if possible).
+
+ @return
+ the secondary component whose events should be mixed with the introspectee's events
+ The caller takes the ownership of the component (if not <NULL/>).
+
+ @throws
+ if an unexpected error occurs during creation of the secondary component.
+ A <NULL/> component to be returned is not unexpected, but allowed
+
+ @precond
+ ->m_xComponent is not <NULL/>
+ */
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >
+ impl_getSecondaryComponentForEventInspection_throw( ) const;
+
+ /** returns the event description for the given (programmatic) property name
+ @param _rPropertyName
+ the name whose event description should be looked up
+ @return
+ the event description for the property name
+ @throws ::com::sun::star::beans::UnknownPropertyException
+ if our introspectee does not have an event with the given logical name (see ->getSupportedProperties)
+ */
+ const EventDescription&
+ impl_getEventForName_throw( const ::rtl::OUString& _rPropertyName ) const;
+
+ /** returns the index of our component within its parent, if this parent can be
+ obtained (XChild::getParent) and supports an ->XIndexAccess interface
+ */
+ sal_Int32 impl_getComponentIndexInParent_throw() const;
+
+ /** sets a given script event as event handler at a form component
+
+ @param _rScriptEvent
+ the script event to set
+ */
+ void impl_setFormComponentScriptEvent_nothrow( const ::com::sun::star::script::ScriptEventDescriptor& _rScriptEvent );
+
+ /** sets a given script event as event handler at a dialog component
+
+ @param _rScriptEvent
+ the script event to set
+ */
+ void impl_setDialogElementScriptEvent_nothrow( const ::com::sun::star::script::ScriptEventDescriptor& _rScriptEvent );
+
+ /** returns the frame associated with our context document
+ */
+ ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >
+ impl_getContextFrame_nothrow() const;
+
+ /** approves or denies a certain method to be included in the UI
+ @return
+ <TRUE/> if and only if the given method is allowed.
+ */
+ bool impl_filterMethod_nothrow( const EventDescription& _rEvent ) const;
+
+ private:
+ EventHandler(); // never implemented
+ EventHandler( const EventHandler& ); // never implemented
+ EventHandler& operator=( const EventHandler& ); // never implemented
+ };
+
+//........................................................................
+} // namespace pcr
+//........................................................................
+
+#endif // EXTENSIONS_SOURCE_PROPCTRLR_EVENTHANDLER_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/propctrlr/fontdialog.cxx b/extensions/source/propctrlr/fontdialog.cxx
new file mode 100644
index 000000000000..c18d5735d60d
--- /dev/null
+++ b/extensions/source/propctrlr/fontdialog.cxx
@@ -0,0 +1,609 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+#include <sfx2/sfxsids.hrc>
+#include "fontdialog.hxx"
+#include "formresid.hrc"
+#include "modulepcr.hxx"
+#include "formlocalid.hrc"
+#include <vcl/svapp.hxx>
+#include <toolkit/unohlp.hxx>
+#include <comphelper/types.hxx>
+#include <comphelper/extract.hxx>
+#include <com/sun/star/awt/FontDescriptor.hpp>
+#include <com/sun/star/awt/FontWeight.hpp>
+#include <com/sun/star/awt/FontSlant.hpp>
+#include <com/sun/star/awt/FontUnderline.hpp>
+#include <com/sun/star/awt/FontStrikeout.hpp>
+#include "formstrings.hxx"
+#include "fontitemids.hxx"
+#include <editeng/charreliefitem.hxx>
+#include <editeng/emphitem.hxx>
+#include <editeng/fontitem.hxx>
+#include <editeng/fhgtitem.hxx>
+#include <editeng/postitem.hxx>
+#include <editeng/wghtitem.hxx>
+#include <editeng/udlnitem.hxx>
+#include <editeng/crsditem.hxx>
+#include <editeng/colritem.hxx>
+#include <editeng/flstitem.hxx>
+#include <editeng/langitem.hxx>
+#include <editeng/wrlmitem.hxx>
+#include <editeng/cmapitem.hxx>
+#include <editeng/cntritem.hxx>
+#include <editeng/shdditem.hxx>
+#include <editeng/flstitem.hxx>
+#include <svtools/ctrltool.hxx>
+#include <tools/diagnose_ex.h>
+#include <com/sun/star/beans/XPropertyState.hpp>
+#include <svx/svxids.hrc>
+#include <svx/svxdlg.hxx>
+#include <svx/dialogs.hrc>
+#include <svx/flagsdef.hxx>
+//............................................................................
+namespace pcr
+{
+//............................................................................
+
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::beans;
+
+ //========================================================================
+ //= OFontPropertyExtractor
+ //========================================================================
+ class OFontPropertyExtractor
+ {
+ protected:
+ ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >
+ m_xPropValueAccess;
+ ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyState >
+ m_xPropStateAccess;
+
+ public:
+ OFontPropertyExtractor( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >&
+ _rxProps );
+
+ public:
+ sal_Bool getCheckFontProperty(const ::rtl::OUString& _rPropName, ::com::sun::star::uno::Any& _rValue);
+ ::rtl::OUString getStringFontProperty(const ::rtl::OUString& _rPropName, const ::rtl::OUString& _rDefault);
+ sal_Int16 getInt16FontProperty(const ::rtl::OUString& _rPropName, const sal_Int16 _nDefault);
+ sal_Int32 getInt32FontProperty(const ::rtl::OUString& _rPropName, const sal_Int32 _nDefault);
+ float getFloatFontProperty(const ::rtl::OUString& _rPropName, const float _nDefault);
+
+ void invalidateItem(
+ const ::rtl::OUString& _rPropName,
+ sal_uInt16 _nItemId,
+ SfxItemSet& _rSet,
+ sal_Bool _bForceInvalidation = sal_False);
+ };
+
+ //------------------------------------------------------------------------
+ OFontPropertyExtractor::OFontPropertyExtractor(const Reference< XPropertySet >& _rxProps)
+ :m_xPropValueAccess(_rxProps)
+ ,m_xPropStateAccess(_rxProps, UNO_QUERY)
+ {
+ OSL_ENSURE(m_xPropValueAccess.is(), "OFontPropertyExtractor::OFontPropertyExtractor: invalid property set!");
+ }
+
+ //------------------------------------------------------------------------
+ sal_Bool OFontPropertyExtractor::getCheckFontProperty(const ::rtl::OUString& _rPropName, Any& _rValue)
+ {
+ _rValue = m_xPropValueAccess->getPropertyValue(_rPropName);
+ if (m_xPropStateAccess.is())
+ return PropertyState_DEFAULT_VALUE == m_xPropStateAccess->getPropertyState(_rPropName);
+
+ return sal_False;
+ }
+
+ //------------------------------------------------------------------------
+ ::rtl::OUString OFontPropertyExtractor::getStringFontProperty(const ::rtl::OUString& _rPropName, const ::rtl::OUString& _rDefault)
+ {
+ Any aValue;
+ if (getCheckFontProperty(_rPropName, aValue))
+ return _rDefault;
+
+ return ::comphelper::getString(aValue);
+ }
+
+ //------------------------------------------------------------------------
+ sal_Int16 OFontPropertyExtractor::getInt16FontProperty(const ::rtl::OUString& _rPropName, const sal_Int16 _nDefault)
+ {
+ Any aValue;
+ if (getCheckFontProperty(_rPropName, aValue))
+ return _nDefault;
+
+ sal_Int32 nValue(_nDefault);
+ ::cppu::enum2int(nValue, aValue);
+ return (sal_Int16)nValue;
+ }
+
+ //------------------------------------------------------------------------
+ sal_Int32 OFontPropertyExtractor::getInt32FontProperty(const ::rtl::OUString& _rPropName, const sal_Int32 _nDefault)
+ {
+ Any aValue;
+ if (getCheckFontProperty(_rPropName, aValue))
+ return _nDefault;
+
+ sal_Int32 nValue(_nDefault);
+ ::cppu::enum2int(nValue, aValue);
+ return nValue;
+ }
+
+ //------------------------------------------------------------------------
+ float OFontPropertyExtractor::getFloatFontProperty(const ::rtl::OUString& _rPropName, const float _nDefault)
+ {
+ Any aValue;
+ if (getCheckFontProperty(_rPropName, aValue))
+ return _nDefault;
+
+ return ::comphelper::getFloat(aValue);
+ }
+
+ //------------------------------------------------------------------------
+ void OFontPropertyExtractor::invalidateItem(const ::rtl::OUString& _rPropName, sal_uInt16 _nItemId, SfxItemSet& _rSet, sal_Bool _bForceInvalidation)
+ {
+ if ( _bForceInvalidation
+ || ( m_xPropStateAccess.is()
+ && (PropertyState_AMBIGUOUS_VALUE == m_xPropStateAccess->getPropertyState(_rPropName))
+ )
+ )
+ _rSet.InvalidateItem(_nItemId);
+ }
+
+ //========================================================================
+ //= ControlCharacterDialog
+ //========================================================================
+ //------------------------------------------------------------------------
+ ControlCharacterDialog::ControlCharacterDialog(Window* _pParent, const SfxItemSet& _rCoreSet)
+ :SfxTabDialog(_pParent, PcrRes(RID_TABDLG_FONTDIALOG), &_rCoreSet)
+ {
+ FreeResource();
+ SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
+ DBG_ASSERT(pFact, "CreateFactory fail!");
+ AddTabPage(TABPAGE_CHARACTERS, pFact->GetTabPageCreatorFunc(RID_SVXPAGE_CHAR_NAME), 0 );
+ AddTabPage(TABPAGE_CHARACTERS_EXT, pFact->GetTabPageCreatorFunc(RID_SVXPAGE_CHAR_EFFECTS), 0 );
+ }
+
+ //------------------------------------------------------------------------
+ ControlCharacterDialog::~ControlCharacterDialog()
+ {
+ }
+
+ //------------------------------------------------------------------------
+ void ControlCharacterDialog::translatePropertiesToItems(const Reference< XPropertySet >& _rxModel, SfxItemSet* _pSet)
+ {
+ OSL_ENSURE(_pSet && _rxModel.is(), "ControlCharacterDialog::translatePropertiesToItems: invalid arguments!");
+ if (!_pSet || !_rxModel.is())
+ return;
+
+ try
+ {
+ OFontPropertyExtractor aPropExtractor(_rxModel);
+
+ // some items, which may be in default state, have to be filled with non-void information
+ Font aDefaultVCLFont = Application::GetDefaultDevice()->GetSettings().GetStyleSettings().GetAppFont();
+ ::com::sun::star::awt::FontDescriptor aDefaultFont = VCLUnoHelper::CreateFontDescriptor(aDefaultVCLFont);
+
+ // get the current properties
+ ::rtl::OUString aFontName = aPropExtractor.getStringFontProperty(PROPERTY_FONT_NAME, aDefaultFont.Name);
+ ::rtl::OUString aFontStyleName = aPropExtractor.getStringFontProperty(PROPERTY_FONT_STYLENAME, aDefaultFont.StyleName);
+ sal_Int16 nFontFamily = aPropExtractor.getInt16FontProperty(PROPERTY_FONT_FAMILY, aDefaultFont.Family);
+ sal_Int16 nFontCharset = aPropExtractor.getInt16FontProperty(PROPERTY_FONT_CHARSET, aDefaultFont.CharSet);
+ float nFontHeight = aPropExtractor.getFloatFontProperty(PROPERTY_FONT_HEIGHT, (float)aDefaultFont.Height);
+ float nFontWeight = aPropExtractor.getFloatFontProperty(PROPERTY_FONT_WEIGHT, aDefaultFont.Weight);
+ sal_Int16 nFontSlant = aPropExtractor.getInt16FontProperty(PROPERTY_FONT_SLANT, (sal_Int16)aDefaultFont.Slant);
+ sal_Int16 nFontUnderline = aPropExtractor.getInt16FontProperty(PROPERTY_FONT_UNDERLINE, aDefaultFont.Underline);
+ sal_Int16 nFontStrikeout = aPropExtractor.getInt16FontProperty(PROPERTY_FONT_STRIKEOUT, aDefaultFont.Strikeout);
+
+ sal_Int32 nTextLineColor = aPropExtractor.getInt32FontProperty(PROPERTY_TEXTLINECOLOR, COL_AUTO);
+ sal_Int16 nFontRelief = aPropExtractor.getInt16FontProperty(PROPERTY_FONT_RELIEF, (sal_Int16)aDefaultVCLFont.GetRelief());
+ sal_Int16 nFontEmphasisMark = aPropExtractor.getInt16FontProperty(PROPERTY_FONT_EMPHASIS_MARK, aDefaultVCLFont.GetEmphasisMark());
+
+ Any aValue;
+ sal_Bool bWordLineMode = aPropExtractor.getCheckFontProperty(PROPERTY_WORDLINEMODE, aValue) ? aDefaultFont.WordLineMode : ::cppu::any2bool(aValue);
+ sal_Int32 nColor32 = aPropExtractor.getInt32FontProperty(PROPERTY_TEXTCOLOR, 0);
+
+ // build SfxItems with the values
+ SvxFontItem aFontItem((FontFamily)nFontFamily, aFontName, aFontStyleName, PITCH_DONTKNOW, nFontCharset, CFID_FONT);
+
+ nFontHeight = (float)OutputDevice::LogicToLogic(Size(0, (sal_Int32)nFontHeight), MAP_POINT, MAP_TWIP).Height();
+ SvxFontHeightItem aSvxFontHeightItem((sal_uInt32)nFontHeight,100,CFID_HEIGHT);
+
+ FontWeight eWeight=VCLUnoHelper::ConvertFontWeight(nFontWeight);
+ FontItalic eItalic=(FontItalic)nFontSlant;
+ FontUnderline eUnderline=(FontUnderline)nFontUnderline;
+ FontStrikeout eStrikeout=(FontStrikeout)nFontStrikeout;
+
+ SvxWeightItem aWeightItem(eWeight,CFID_WEIGHT);
+ SvxPostureItem aPostureItem(eItalic,CFID_POSTURE);
+
+ SvxCrossedOutItem aCrossedOutItem(eStrikeout,CFID_STRIKEOUT);
+ SvxWordLineModeItem aWordLineModeItem(bWordLineMode, CFID_WORDLINEMODE);
+
+ SvxUnderlineItem aUnderlineItem(eUnderline,CFID_UNDERLINE);
+ aUnderlineItem.SetColor(Color(nTextLineColor));
+
+ SvxColorItem aSvxColorItem(nColor32,CFID_CHARCOLOR);
+ SvxLanguageItem aLanguageItem(Application::GetSettings().GetUILanguage(), CFID_LANGUAGE);
+
+ // the 2 CJK props
+ SvxCharReliefItem aFontReliefItem((FontRelief)nFontRelief, CFID_RELIEF);
+ SvxEmphasisMarkItem aEmphasisMarkitem((FontEmphasisMark)nFontEmphasisMark, CFID_EMPHASIS);
+
+ _pSet->Put(aFontItem, CFID_FONT);
+ _pSet->Put(aSvxFontHeightItem,CFID_HEIGHT);
+ _pSet->Put(aWeightItem, CFID_WEIGHT);
+ _pSet->Put(aPostureItem, CFID_POSTURE);
+ _pSet->Put(aLanguageItem, CFID_LANGUAGE);
+ _pSet->Put(aUnderlineItem,CFID_UNDERLINE);
+ _pSet->Put(aCrossedOutItem,CFID_STRIKEOUT);
+ _pSet->Put(aWordLineModeItem, CFID_WORDLINEMODE);
+ _pSet->Put(aSvxColorItem, CFID_CHARCOLOR);
+ _pSet->Put(aFontReliefItem, CFID_RELIEF);
+ _pSet->Put(aEmphasisMarkitem, CFID_EMPHASIS);
+
+ aPropExtractor.invalidateItem(PROPERTY_FONT_NAME, CFID_FONT, *_pSet);
+ aPropExtractor.invalidateItem(PROPERTY_FONT_HEIGHT, CFID_HEIGHT, *_pSet);
+ aPropExtractor.invalidateItem(PROPERTY_FONT_WEIGHT, CFID_WEIGHT, *_pSet, ::com::sun::star::awt::FontWeight::DONTKNOW == nFontWeight);
+ aPropExtractor.invalidateItem(PROPERTY_FONT_SLANT, CFID_POSTURE, *_pSet, ::com::sun::star::awt::FontSlant_DONTKNOW == nFontSlant);
+ aPropExtractor.invalidateItem(PROPERTY_FONT_UNDERLINE, CFID_UNDERLINE, *_pSet, ::com::sun::star::awt::FontUnderline::DONTKNOW == nFontUnderline);
+ aPropExtractor.invalidateItem(PROPERTY_FONT_STRIKEOUT, CFID_STRIKEOUT, *_pSet, ::com::sun::star::awt::FontStrikeout::DONTKNOW == nFontStrikeout);
+ aPropExtractor.invalidateItem(PROPERTY_WORDLINEMODE, CFID_WORDLINEMODE, *_pSet);
+ aPropExtractor.invalidateItem(PROPERTY_TEXTCOLOR, CFID_CHARCOLOR, *_pSet);
+ aPropExtractor.invalidateItem(PROPERTY_FONT_RELIEF, CFID_RELIEF, *_pSet);
+ aPropExtractor.invalidateItem(PROPERTY_FONT_EMPHASIS_MARK, CFID_EMPHASIS, *_pSet);
+ }
+ catch (Exception&)
+ {
+ DBG_ERROR("ControlCharacterDialog::translatePropertiesToItems: caught an exception!");
+ }
+
+ _pSet->DisableItem(SID_ATTR_CHAR_CJK_FONT);
+ _pSet->DisableItem(SID_ATTR_CHAR_CJK_FONTHEIGHT);
+ _pSet->DisableItem(SID_ATTR_CHAR_CJK_LANGUAGE);
+ _pSet->DisableItem(SID_ATTR_CHAR_CJK_POSTURE);
+ _pSet->DisableItem(SID_ATTR_CHAR_CJK_WEIGHT);
+
+ _pSet->DisableItem(SID_ATTR_CHAR_CASEMAP);
+ _pSet->DisableItem(SID_ATTR_CHAR_CONTOUR);
+ _pSet->DisableItem(SID_ATTR_CHAR_SHADOWED);
+
+ }
+
+ //------------------------------------------------------------------------
+ namespace
+ {
+ void lcl_pushBackPropertyValue( Sequence< NamedValue >& _out_properties, const ::rtl::OUString& _name, const Any& _value )
+ {
+ _out_properties.realloc( _out_properties.getLength() + 1 );
+ _out_properties[ _out_properties.getLength() - 1 ] = NamedValue( _name, _value );
+ }
+ }
+
+ //------------------------------------------------------------------------
+ void ControlCharacterDialog::translateItemsToProperties( const SfxItemSet& _rSet, Sequence< NamedValue >& _out_properties )
+ {
+ _out_properties.realloc( 0 );
+
+ try
+ {
+ // --------------------------
+ // font name
+ SfxItemState eState = _rSet.GetItemState(CFID_FONT);
+
+ if ( eState == SFX_ITEM_SET )
+ {
+ const SvxFontItem& rFontItem =
+ static_cast<const SvxFontItem&>(_rSet.Get(CFID_FONT));
+
+ lcl_pushBackPropertyValue( _out_properties, PROPERTY_FONT_NAME , makeAny(::rtl::OUString(rFontItem.GetFamilyName())));
+ lcl_pushBackPropertyValue( _out_properties, PROPERTY_FONT_STYLENAME, makeAny(::rtl::OUString(rFontItem.GetStyleName())));
+ lcl_pushBackPropertyValue( _out_properties, PROPERTY_FONT_FAMILY , makeAny((sal_Int16)rFontItem.GetFamily()));
+ lcl_pushBackPropertyValue( _out_properties, PROPERTY_FONT_CHARSET , makeAny((sal_Int16)rFontItem.GetCharSet()));
+ }
+
+ // --------------------------
+ // font height
+ eState = _rSet.GetItemState(CFID_HEIGHT);
+
+ if ( eState == SFX_ITEM_SET )
+ {
+ const SvxFontHeightItem& rSvxFontHeightItem =
+ static_cast<const SvxFontHeightItem&>(_rSet.Get(CFID_HEIGHT));
+
+ float nHeight = (float)OutputDevice::LogicToLogic(Size(0, rSvxFontHeightItem.GetHeight()), MAP_TWIP, MAP_POINT).Height();
+ lcl_pushBackPropertyValue( _out_properties, PROPERTY_FONT_HEIGHT,makeAny(nHeight));
+
+ }
+
+ // --------------------------
+ // font weight
+ eState = _rSet.GetItemState(CFID_WEIGHT);
+
+ if ( eState == SFX_ITEM_SET )
+ {
+ const SvxWeightItem& rWeightItem =
+ static_cast<const SvxWeightItem&>(_rSet.Get(CFID_WEIGHT));
+
+ float nWeight = VCLUnoHelper::ConvertFontWeight( rWeightItem.GetWeight());
+ lcl_pushBackPropertyValue( _out_properties, PROPERTY_FONT_WEIGHT,makeAny(nWeight));
+ }
+
+ // --------------------------
+ // font slant
+ eState = _rSet.GetItemState(CFID_POSTURE);
+
+ if ( eState == SFX_ITEM_SET )
+ {
+ const SvxPostureItem& rPostureItem =
+ static_cast<const SvxPostureItem&>(_rSet.Get(CFID_POSTURE));
+
+ ::com::sun::star::awt::FontSlant eSlant = (::com::sun::star::awt::FontSlant)rPostureItem.GetPosture();
+ lcl_pushBackPropertyValue( _out_properties, PROPERTY_FONT_SLANT, makeAny((sal_Int16)eSlant));
+ }
+
+ // --------------------------
+ // font underline
+ eState = _rSet.GetItemState(CFID_UNDERLINE);
+
+ if ( eState == SFX_ITEM_SET )
+ {
+ const SvxUnderlineItem& rUnderlineItem =
+ static_cast<const SvxUnderlineItem&>(_rSet.Get(CFID_UNDERLINE));
+
+ sal_Int16 nUnderline = (sal_Int16)rUnderlineItem.GetLineStyle();
+ lcl_pushBackPropertyValue( _out_properties, PROPERTY_FONT_UNDERLINE,makeAny(nUnderline));
+
+ // the text line color is transported in this item, too
+ sal_Int32 nColor = rUnderlineItem.GetColor().GetColor();
+
+ Any aUnoColor;
+ if (COL_AUTO != (UINT32)nColor)
+ aUnoColor <<= nColor;
+
+ lcl_pushBackPropertyValue( _out_properties, PROPERTY_TEXTLINECOLOR, aUnoColor );
+ }
+
+ // --------------------------
+ // font strikeout
+ eState = _rSet.GetItemState(CFID_STRIKEOUT);
+
+ if ( eState == SFX_ITEM_SET )
+ {
+ const SvxCrossedOutItem& rCrossedOutItem =
+ static_cast<const SvxCrossedOutItem&>(_rSet.Get(CFID_STRIKEOUT));
+
+ sal_Int16 nStrikeout = (sal_Int16)rCrossedOutItem.GetStrikeout();
+ lcl_pushBackPropertyValue( _out_properties, PROPERTY_FONT_STRIKEOUT,makeAny(nStrikeout));
+ }
+
+
+ // --------------------------
+ // font wordline mode
+ eState = _rSet.GetItemState(CFID_WORDLINEMODE);
+
+ if ( eState == SFX_ITEM_SET )
+ {
+ const SvxWordLineModeItem& rWordLineModeItem =
+ static_cast<const SvxWordLineModeItem&>(_rSet.Get(CFID_WORDLINEMODE));
+
+ lcl_pushBackPropertyValue( _out_properties, PROPERTY_WORDLINEMODE, ::cppu::bool2any(rWordLineModeItem.GetValue()));
+ }
+
+
+ // --------------------------
+ // text color
+ eState = _rSet.GetItemState(CFID_CHARCOLOR);
+
+ if ( eState == SFX_ITEM_SET )
+ {
+ const SvxColorItem& rColorItem =
+ static_cast<const SvxColorItem&>(_rSet.Get(CFID_CHARCOLOR));
+
+ sal_Int32 nColor = rColorItem.GetValue().GetColor();
+
+ Any aUnoColor;
+ if (COL_AUTO != (UINT32)nColor)
+ aUnoColor <<= nColor;
+
+ lcl_pushBackPropertyValue( _out_properties, PROPERTY_TEXTCOLOR, aUnoColor );
+ }
+
+ // --------------------------
+ // font relief
+ eState = _rSet.GetItemState(CFID_RELIEF);
+
+ if ( eState == SFX_ITEM_SET )
+ {
+ const SvxCharReliefItem& rReliefItem =
+ static_cast<const SvxCharReliefItem&>(_rSet.Get(CFID_RELIEF));
+
+ lcl_pushBackPropertyValue( _out_properties, PROPERTY_FONT_RELIEF, makeAny((sal_Int16)rReliefItem.GetValue()) );
+ }
+
+ // --------------------------
+ // font emphasis mark
+ eState = _rSet.GetItemState(CFID_EMPHASIS);
+
+ if ( eState == SFX_ITEM_SET )
+ {
+ const SvxEmphasisMarkItem& rEmphMarkItem =
+ static_cast<const SvxEmphasisMarkItem&>(_rSet.Get(CFID_EMPHASIS));
+
+ lcl_pushBackPropertyValue( _out_properties, PROPERTY_FONT_EMPHASIS_MARK, makeAny((sal_Int16)rEmphMarkItem.GetEmphasisMark()) );
+ }
+ }
+ catch (const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+
+ //------------------------------------------------------------------------
+ void ControlCharacterDialog::translateItemsToProperties( const SfxItemSet& _rSet, const Reference< XPropertySet >& _rxModel)
+ {
+ OSL_ENSURE( _rxModel.is(), "ControlCharacterDialog::translateItemsToProperties: invalid arguments!" );
+ if ( !_rxModel.is())
+ return;
+
+ Sequence< NamedValue > aPropertyValues;
+ translateItemsToProperties( _rSet, aPropertyValues );
+ try
+ {
+ const NamedValue* propertyValue = aPropertyValues.getConstArray();
+ const NamedValue* propertyValueEnd = propertyValue + aPropertyValues.getLength();
+ for ( ; propertyValue != propertyValueEnd; ++propertyValue )
+ _rxModel->setPropertyValue( propertyValue->Name, propertyValue->Value );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+
+ //------------------------------------------------------------------------
+ SfxItemSet* ControlCharacterDialog::createItemSet(SfxItemSet*& _rpSet, SfxItemPool*& _rpPool, SfxPoolItem**& _rppDefaults)
+ {
+ // just to be sure ....
+ _rpSet = NULL;
+ _rpPool = NULL;
+ _rppDefaults = NULL;
+
+ // create and initialize the defaults
+ _rppDefaults = new SfxPoolItem*[CFID_LAST_ITEM_ID - CFID_FIRST_ITEM_ID + 1];
+
+ Font aDefaultVCLFont = Application::GetDefaultDevice()->GetSettings().GetStyleSettings().GetAppFont();
+
+ SfxPoolItem** pCounter = _rppDefaults; // want to modify this without affecting the out param _rppDefaults
+ *pCounter++ = new SvxFontItem(aDefaultVCLFont.GetFamily(), aDefaultVCLFont.GetName(), aDefaultVCLFont.GetStyleName(), aDefaultVCLFont.GetPitch(), aDefaultVCLFont.GetCharSet(), CFID_FONT);
+ *pCounter++ = new SvxFontHeightItem(aDefaultVCLFont.GetHeight(), 100, CFID_HEIGHT);
+ *pCounter++ = new SvxWeightItem(aDefaultVCLFont.GetWeight(), CFID_WEIGHT);
+ *pCounter++ = new SvxPostureItem(aDefaultVCLFont.GetItalic(), CFID_POSTURE);
+ *pCounter++ = new SvxLanguageItem(Application::GetSettings().GetUILanguage(), CFID_LANGUAGE);
+ *pCounter++ = new SvxUnderlineItem(aDefaultVCLFont.GetUnderline(), CFID_UNDERLINE);
+ *pCounter++ = new SvxCrossedOutItem(aDefaultVCLFont.GetStrikeout(), CFID_STRIKEOUT);
+ *pCounter++ = new SvxWordLineModeItem(aDefaultVCLFont.IsWordLineMode(), CFID_WORDLINEMODE);
+ *pCounter++ = new SvxColorItem(aDefaultVCLFont.GetColor(), CFID_CHARCOLOR);
+ *pCounter++ = new SvxCharReliefItem(aDefaultVCLFont.GetRelief(), CFID_RELIEF);
+ *pCounter++ = new SvxEmphasisMarkItem(aDefaultVCLFont.GetEmphasisMark(), CFID_EMPHASIS);
+
+ *pCounter++ = new SvxFontItem(aDefaultVCLFont.GetFamily(), aDefaultVCLFont.GetName(), aDefaultVCLFont.GetStyleName(), aDefaultVCLFont.GetPitch(), aDefaultVCLFont.GetCharSet(), CFID_CJK_FONT);
+ *pCounter++ = new SvxFontHeightItem(aDefaultVCLFont.GetHeight(), 100, CFID_CJK_HEIGHT);
+ *pCounter++ = new SvxWeightItem(aDefaultVCLFont.GetWeight(), CFID_CJK_WEIGHT);
+ *pCounter++ = new SvxPostureItem(aDefaultVCLFont.GetItalic(), CFID_CJK_POSTURE);
+ *pCounter++ = new SvxLanguageItem(Application::GetSettings().GetUILanguage(), CFID_CJK_LANGUAGE);
+
+ *pCounter++ = new SvxCaseMapItem(SVX_CASEMAP_NOT_MAPPED, CFID_CASEMAP);
+ *pCounter++ = new SvxContourItem(sal_False, CFID_CONTOUR);
+ *pCounter++ = new SvxShadowedItem(sal_False, CFID_SHADOWED);
+
+ *pCounter++ = new SvxFontListItem (new FontList(Application::GetDefaultDevice()), CFID_FONTLIST);
+
+ // create the pool
+ static SfxItemInfo __READONLY_DATA aItemInfos[CFID_LAST_ITEM_ID - CFID_FIRST_ITEM_ID + 1] =
+ {
+ { SID_ATTR_CHAR_FONT, 0 },
+ { SID_ATTR_CHAR_FONTHEIGHT, 0 },
+ { SID_ATTR_CHAR_WEIGHT, 0 },
+ { SID_ATTR_CHAR_POSTURE, 0 },
+ { SID_ATTR_CHAR_LANGUAGE, 0 },
+ { SID_ATTR_CHAR_UNDERLINE, 0 },
+ { SID_ATTR_CHAR_STRIKEOUT, 0 },
+ { SID_ATTR_CHAR_WORDLINEMODE, 0 },
+ { SID_ATTR_CHAR_COLOR, 0 },
+ { SID_ATTR_CHAR_RELIEF, 0 },
+ { SID_ATTR_CHAR_EMPHASISMARK, 0 },
+ { 0, 0 },
+ { 0, 0 },
+ { 0, 0 },
+ { 0, 0 },
+ { 0, 0 },
+ { 0, 0 },
+ { 0, 0 },
+ { 0, 0 },
+ { SID_ATTR_CHAR_FONTLIST, 0 }
+ };
+
+ _rpPool = new SfxItemPool(String::CreateFromAscii("PCRControlFontItemPool"), CFID_FIRST_ITEM_ID, CFID_LAST_ITEM_ID,
+ aItemInfos, _rppDefaults);
+ _rpPool->FreezeIdRanges();
+
+ // and, finally, the set
+ _rpSet = new SfxItemSet(*_rpPool, sal_True);
+
+ return _rpSet;
+ }
+
+ //-------------------------------------------------------------------------
+ void ControlCharacterDialog::destroyItemSet(SfxItemSet*& _rpSet, SfxItemPool*& _rpPool, SfxPoolItem**& _rppDefaults)
+ {
+ // from the pool, get and remember the font list (needs to be deleted)
+ const SvxFontListItem& rFontListItem = static_cast<const SvxFontListItem&>(_rpPool->GetDefaultItem(CFID_FONTLIST));
+ const FontList* pFontList = rFontListItem.GetFontList();
+
+ // _first_ delete the set (refering the pool)
+ if (_rpSet)
+ {
+ delete _rpSet;
+ _rpSet = NULL;
+ }
+
+ // delete the pool
+ if (_rpPool)
+ {
+ _rpPool->ReleaseDefaults(sal_True);
+ // the "true" means delete the items, too
+ SfxItemPool::Free(_rpPool);
+ _rpPool = NULL;
+ }
+
+ // reset the defaults ptr
+ _rppDefaults = NULL;
+ // no need to explicitly delete the defaults, this has been done by the ReleaseDefaults
+
+ delete pFontList;
+ }
+
+ //------------------------------------------------------------------------
+ void ControlCharacterDialog::PageCreated( sal_uInt16 _nId, SfxTabPage& _rPage )
+ {
+ SfxAllItemSet aSet(*(GetInputSetImpl()->GetPool()));
+ if ( _nId == TABPAGE_CHARACTERS ) {
+ aSet.Put (SvxFontListItem(static_cast<const SvxFontListItem&>(GetInputSetImpl()->Get(CFID_FONTLIST))));
+ aSet.Put (SfxUInt16Item(SID_DISABLE_CTL,DISABLE_HIDE_LANGUAGE));
+ _rPage.PageCreated(aSet);
+ }
+ }
+
+//............................................................................
+} // namespace pcr
+//............................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/propctrlr/fontdialog.hxx b/extensions/source/propctrlr/fontdialog.hxx
new file mode 100644
index 000000000000..b7d812c4af90
--- /dev/null
+++ b/extensions/source/propctrlr/fontdialog.hxx
@@ -0,0 +1,85 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _EXTENSIONS_PROPCTRLR_FONTDIALOG_HXX_
+#define _EXTENSIONS_PROPCTRLR_FONTDIALOG_HXX_
+
+#include <sfx2/tabdlg.hxx>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/beans/NamedValue.hpp>
+
+class SvxFontListItem;
+class FontList;
+
+//............................................................................
+namespace pcr
+{
+//............................................................................
+
+ //========================================================================
+ //= ControlCharacterDialog
+ //========================================================================
+ class ControlCharacterDialog : public SfxTabDialog
+ {
+ public:
+ ControlCharacterDialog(Window* _pParent, const SfxItemSet& _rCoreSet);
+ ~ControlCharacterDialog();
+
+ /// creates an item set to be used with this dialog
+ static SfxItemSet* createItemSet(SfxItemSet*& _rpSet, SfxItemPool*& _rpPool, SfxPoolItem**& _rppDefaults);
+
+ /// destroys an item previously created with <method>createItemSet</method>
+ static void destroyItemSet(SfxItemSet*& _rpSet, SfxItemPool*& _rpPool, SfxPoolItem**& _rppDefaults);
+
+ /// fills the given item set with values obtained from the given property set
+ static void translatePropertiesToItems(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxModel,
+ SfxItemSet* _pSet);
+
+ /** fills the given property set with values obtained from the given item set
+ */
+ static void translateItemsToProperties(
+ const SfxItemSet& _rSet,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxModel);
+
+ /** fills the given property set with values obtained from the given item set
+ */
+ static void translateItemsToProperties(
+ const SfxItemSet& _rSet,
+ ::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue >& _out_properties );
+
+ protected:
+ virtual void PageCreated(sal_uInt16 _nId, SfxTabPage& _rPage);
+ };
+//............................................................................
+} // namespace pcr
+//............................................................................
+
+#endif // _EXTENSIONS_PROPCTRLR_FONTDIALOG_HXX_
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/propctrlr/fontdialog.src b/extensions/source/propctrlr/fontdialog.src
new file mode 100644
index 000000000000..7d628e9efbae
--- /dev/null
+++ b/extensions/source/propctrlr/fontdialog.src
@@ -0,0 +1,60 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef EXTENSIONS_PROPRESID_HRC
+#include "formresid.hrc"
+#endif
+#ifndef _EXTENSIONS_PROPCTRLR_FORMLOCALID_HRC_
+#include "formlocalid.hrc"
+#endif
+
+TabDialog RID_TABDLG_FONTDIALOG
+{
+ OutputSize = TRUE ;
+ SVLook = TRUE ;
+ Text [ en-US ] = "Character" ;
+ Moveable = TRUE ;
+ TabControl 1
+ {
+ OutputSize = TRUE ;
+ PageList =
+ {
+ PageItem
+ {
+ Identifier = TABPAGE_CHARACTERS ;
+ PageResID = TABPAGE_CHARACTERS ;
+ Text [ en-US ] = "Font" ;
+ };
+ PageItem
+ {
+ Identifier = TABPAGE_CHARACTERS_EXT ;
+ PageResID = TABPAGE_CHARACTERS_EXT ;
+ Text [ en-US ] = "Font Effects" ;
+ };
+ };
+ };
+};
diff --git a/extensions/source/propctrlr/fontitemids.hxx b/extensions/source/propctrlr/fontitemids.hxx
new file mode 100644
index 000000000000..2089f93ccbeb
--- /dev/null
+++ b/extensions/source/propctrlr/fontitemids.hxx
@@ -0,0 +1,68 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _EXTENSIONS_PROPCTRLR_FONTITEMIDS_HXX_
+#define _EXTENSIONS_PROPCTRLR_FONTITEMIDS_HXX_
+
+#define CFID_FONT 1
+#define CFID_HEIGHT 2
+#define CFID_WEIGHT 3
+#define CFID_POSTURE 4
+#define CFID_LANGUAGE 5
+#define CFID_UNDERLINE 6
+#define CFID_STRIKEOUT 7
+#define CFID_WORDLINEMODE 8
+#define CFID_CHARCOLOR 9
+#define CFID_RELIEF 10
+#define CFID_EMPHASIS 11
+
+#define CFID_CJK_FONT 12
+#define CFID_CJK_HEIGHT 13
+#define CFID_CJK_WEIGHT 14
+#define CFID_CJK_POSTURE 15
+#define CFID_CJK_LANGUAGE 16
+#define CFID_CASEMAP 17
+#define CFID_CONTOUR 18
+#define CFID_SHADOWED 19
+
+#define CFID_FONTLIST 20
+
+#define CFID_FIRST_ITEM_ID CFID_FONT
+#define CFID_LAST_ITEM_ID CFID_FONTLIST
+
+//........................................................................
+namespace pcr
+{
+//........................................................................
+//........................................................................
+} // namespace pcr
+//........................................................................
+
+#endif // _EXTENSIONS_PROPCTRLR_FONTITEMIDS_HXX_
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/propctrlr/formbrowsertools.cxx b/extensions/source/propctrlr/formbrowsertools.cxx
new file mode 100644
index 000000000000..d39e6c1ee170
--- /dev/null
+++ b/extensions/source/propctrlr/formbrowsertools.cxx
@@ -0,0 +1,146 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+#include "formbrowsertools.hxx"
+#include <com/sun/star/form/FormComponentType.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include "formresid.hrc"
+#include "modulepcr.hxx"
+#include <tools/string.hxx>
+#include "formstrings.hxx"
+
+//............................................................................
+namespace pcr
+{
+//............................................................................
+
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::form;
+ using namespace ::com::sun::star::lang;
+ using namespace ::com::sun::star::beans;
+
+ //------------------------------------------------------------------------
+ ::rtl::OUString GetUIHeadlineName(sal_Int16 nClassId, const Any& aUnoObj)
+ {
+ PcrClient aResourceAccess;
+ // this ensures that we have our resource file loaded
+
+ ::rtl::OUString sClassName;
+ switch (nClassId)
+ {
+ case FormComponentType::TEXTFIELD:
+ {
+ Reference< XInterface > xIFace;
+ aUnoObj >>= xIFace;
+ sClassName = String(PcrRes(RID_STR_PROPTITLE_EDIT));
+ if (xIFace.is())
+ { // we have a chance to check if it's a formatted field model
+ Reference< XServiceInfo > xInfo(xIFace, UNO_QUERY);
+ if (xInfo.is() && (xInfo->supportsService(SERVICE_COMPONENT_FORMATTEDFIELD)))
+ sClassName = String(PcrRes(RID_STR_PROPTITLE_FORMATTED));
+ else if (!xInfo.is())
+ {
+ // couldn't distinguish between formatted and edit with the service name, so try with the properties
+ Reference< XPropertySet > xProps(xIFace, UNO_QUERY);
+ if (xProps.is())
+ {
+ Reference< XPropertySetInfo > xPropsInfo = xProps->getPropertySetInfo();
+ if (xPropsInfo.is() && xPropsInfo->hasPropertyByName(PROPERTY_FORMATSSUPPLIER))
+ sClassName = String(PcrRes(RID_STR_PROPTITLE_FORMATTED));
+ }
+ }
+ }
+ }
+ break;
+
+ case FormComponentType::COMMANDBUTTON:
+ sClassName = String(PcrRes(RID_STR_PROPTITLE_PUSHBUTTON)); break;
+ case FormComponentType::RADIOBUTTON:
+ sClassName = String(PcrRes(RID_STR_PROPTITLE_RADIOBUTTON)); break;
+ case FormComponentType::CHECKBOX:
+ sClassName = String(PcrRes(RID_STR_PROPTITLE_CHECKBOX)); break;
+ case FormComponentType::LISTBOX:
+ sClassName = String(PcrRes(RID_STR_PROPTITLE_LISTBOX)); break;
+ case FormComponentType::COMBOBOX:
+ sClassName = String(PcrRes(RID_STR_PROPTITLE_COMBOBOX)); break;
+ case FormComponentType::GROUPBOX:
+ sClassName = String(PcrRes(RID_STR_PROPTITLE_GROUPBOX)); break;
+ case FormComponentType::IMAGEBUTTON:
+ sClassName = String(PcrRes(RID_STR_PROPTITLE_IMAGEBUTTON)); break;
+ case FormComponentType::FIXEDTEXT:
+ sClassName = String(PcrRes(RID_STR_PROPTITLE_FIXEDTEXT)); break;
+ case FormComponentType::GRIDCONTROL:
+ sClassName = String(PcrRes(RID_STR_PROPTITLE_DBGRID)); break;
+ case FormComponentType::FILECONTROL:
+ sClassName = String(PcrRes(RID_STR_PROPTITLE_FILECONTROL)); break;
+
+ case FormComponentType::DATEFIELD:
+ sClassName = String(PcrRes(RID_STR_PROPTITLE_DATEFIELD)); break;
+ case FormComponentType::TIMEFIELD:
+ sClassName = String(PcrRes(RID_STR_PROPTITLE_TIMEFIELD)); break;
+ case FormComponentType::NUMERICFIELD:
+ sClassName = String(PcrRes(RID_STR_PROPTITLE_NUMERICFIELD)); break;
+ case FormComponentType::CURRENCYFIELD:
+ sClassName = String(PcrRes(RID_STR_PROPTITLE_CURRENCYFIELD)); break;
+ case FormComponentType::PATTERNFIELD:
+ sClassName = String(PcrRes(RID_STR_PROPTITLE_PATTERNFIELD)); break;
+ case FormComponentType::IMAGECONTROL:
+ sClassName = String(PcrRes(RID_STR_PROPTITLE_IMAGECONTROL)); break;
+ case FormComponentType::HIDDENCONTROL:
+ sClassName = String(PcrRes(RID_STR_PROPTITLE_HIDDENCONTROL)); break;
+
+ case FormComponentType::CONTROL:
+ default:
+ sClassName = String(PcrRes(RID_STR_PROPTITLE_UNKNOWNCONTROL)); break;
+ }
+
+ return sClassName;
+ }
+
+ //------------------------------------------------------------------------
+ sal_Int16 classifyComponent( const Reference< XInterface >& _rxComponent )
+ {
+ Reference< XPropertySet > xComponentProps( _rxComponent, UNO_QUERY_THROW );
+ Reference< XPropertySetInfo > xPSI( xComponentProps->getPropertySetInfo(), UNO_SET_THROW );
+
+ sal_Int16 nControlType( FormComponentType::CONTROL );
+ if ( xPSI->hasPropertyByName( PROPERTY_CLASSID ) )
+ {
+ OSL_VERIFY( xComponentProps->getPropertyValue( PROPERTY_CLASSID ) >>= nControlType );
+ }
+ return nControlType;
+ }
+
+//............................................................................
+} // namespace pcr
+//............................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/propctrlr/formbrowsertools.hxx b/extensions/source/propctrlr/formbrowsertools.hxx
new file mode 100644
index 000000000000..ec6d329e50da
--- /dev/null
+++ b/extensions/source/propctrlr/formbrowsertools.hxx
@@ -0,0 +1,110 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _EXTENSIONS_FORMSCTRLR_FORMBROWSERTOOLS_HXX_
+#define _EXTENSIONS_FORMSCTRLR_FORMBROWSERTOOLS_HXX_
+
+#include <com/sun/star/uno/Any.hxx>
+#include <com/sun/star/beans/Property.hpp>
+#include <rtl/ustring.hxx>
+
+#include <functional>
+#include <set>
+
+//............................................................................
+namespace pcr
+{
+//............................................................................
+
+ ::rtl::OUString GetUIHeadlineName(sal_Int16 _nClassId, const ::com::sun::star::uno::Any& _rUnoObject);
+ sal_Int16 classifyComponent( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxComponent );
+
+ //========================================================================
+ struct FindPropertyByHandle : public ::std::unary_function< ::com::sun::star::beans::Property, bool >
+ {
+ private:
+ sal_Int32 m_nId;
+
+ public:
+ FindPropertyByHandle( sal_Int32 _nId ) : m_nId ( _nId ) { }
+ bool operator()( const ::com::sun::star::beans::Property& _rProp ) const
+ {
+ return m_nId == _rProp.Handle;
+ }
+ };
+
+ //========================================================================
+ struct FindPropertyByName : public ::std::unary_function< ::com::sun::star::beans::Property, bool >
+ {
+ private:
+ ::rtl::OUString m_sName;
+
+ public:
+ FindPropertyByName( const ::rtl::OUString& _rName ) : m_sName( _rName ) { }
+ bool operator()( const ::com::sun::star::beans::Property& _rProp ) const
+ {
+ return m_sName == _rProp.Name;
+ }
+ };
+
+ //========================================================================
+ struct PropertyLessByName
+ :public ::std::binary_function < ::com::sun::star::beans::Property,
+ ::com::sun::star::beans::Property,
+ bool
+ >
+ {
+ bool operator() (::com::sun::star::beans::Property _rLhs, ::com::sun::star::beans::Property _rRhs) const
+ {
+ return _rLhs.Name < _rRhs.Name ? true : false;
+ }
+ };
+
+ //========================================================================
+ struct TypeLessByName
+ :public ::std::binary_function < ::com::sun::star::uno::Type,
+ ::com::sun::star::uno::Type,
+ bool
+ >
+ {
+ bool operator() (::com::sun::star::uno::Type _rLhs, ::com::sun::star::uno::Type _rRhs) const
+ {
+ return _rLhs.getTypeName() < _rRhs.getTypeName() ? true : false;
+ }
+ };
+
+ //========================================================================
+ typedef ::std::set< ::com::sun::star::beans::Property, PropertyLessByName > PropertyBag;
+
+//............................................................................
+} // namespace pcr
+//............................................................................
+
+#endif // _EXTENSIONS_FORMSCTRLR_FORMBROWSERTOOLS_HXX_
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/propctrlr/formcomponenthandler.cxx b/extensions/source/propctrlr/formcomponenthandler.cxx
new file mode 100644
index 000000000000..5ffafad89fe4
--- /dev/null
+++ b/extensions/source/propctrlr/formcomponenthandler.cxx
@@ -0,0 +1,3344 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+
+#include "controltype.hxx"
+#include "propctrlr.hrc"
+#include "extensio.hrc"
+#include "fontdialog.hxx"
+#include "formcomponenthandler.hxx"
+#include "formlinkdialog.hxx"
+#include "formmetadata.hxx"
+#include "formresid.hrc"
+#include "formstrings.hxx"
+#include "handlerhelper.hxx"
+#include "listselectiondlg.hxx"
+#include "pcrcommon.hxx"
+#include "selectlabeldialog.hxx"
+#include "taborder.hxx"
+#include "usercontrol.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/lang/NullPointerException.hpp>
+#include <com/sun/star/awt/XControlModel.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/form/FormComponentType.hpp>
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+#include <com/sun/star/util/XNumberFormatsSupplier.hpp>
+#include <com/sun/star/container/XNameAccess.hpp>
+#include <com/sun/star/form/XForm.hpp>
+#include <com/sun/star/container/XChild.hpp>
+#include <com/sun/star/sdbc/XConnection.hpp>
+#include <com/sun/star/sdb/CommandType.hpp>
+#include <com/sun/star/form/XGridColumnFactory.hpp>
+#include <com/sun/star/sdb/SQLContext.hpp>
+#include <com/sun/star/sdbcx/XTablesSupplier.hpp>
+#include <com/sun/star/sdb/XQueriesSupplier.hpp>
+#include <com/sun/star/form/ListSourceType.hpp>
+#include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
+#include <com/sun/star/sdb/XSingleSelectQueryComposer.hpp>
+#include <com/sun/star/ui/dialogs/XFilePickerControlAccess.hpp>
+#include <com/sun/star/ui/dialogs/ExtendedFilePickerElementIds.hpp>
+#include <com/sun/star/awt/XTabControllerModel.hpp>
+#include <com/sun/star/form/FormSubmitEncoding.hpp>
+#include <com/sun/star/awt/VisualEffect.hpp>
+#include <com/sun/star/form/FormButtonType.hpp>
+#include <com/sun/star/inspection/PropertyControlType.hpp>
+#include <com/sun/star/util/MeasureUnit.hpp>
+#include <com/sun/star/inspection/XObjectInspectorUI.hpp>
+#include <com/sun/star/inspection/PropertyLineElement.hpp>
+#include <com/sun/star/resource/XStringResourceManager.hpp>
+#include <com/sun/star/resource/MissingResourceException.hpp>
+#include <com/sun/star/graphic/GraphicObject.hpp>
+#include <com/sun/star/text/WritingMode2.hpp>
+/** === end UNO includes === **/
+
+#include <comphelper/extract.hxx>
+#include <connectivity/dbconversion.hxx>
+#include <connectivity/dbexception.hxx>
+#include <cppuhelper/exc_hlp.hxx>
+#include <sfx2/app.hxx>
+#include <sfx2/basedlgs.hxx>
+#include <sfx2/docfilt.hxx>
+#include <sfx2/filedlghelper.hxx>
+#include <svl/ctloptions.hxx>
+#include <svtools/colrdlg.hxx>
+#include <svl/filenotation.hxx>
+#include <svl/intitem.hxx>
+#include <svl/itemset.hxx>
+#include <unotools/moduleoptions.hxx>
+#include <svl/numuno.hxx>
+#include <svl/urihelper.hxx>
+#include <svx/dialogs.hrc>
+#include <svx/numinf.hxx>
+#include <svx/svxdlg.hxx>
+#include <svx/svxids.hrc>
+#include <toolkit/helper/vclunohelper.hxx>
+#include <tools/diagnose_ex.h>
+#include <vcl/msgbox.hxx>
+#include <vcl/stdtext.hxx>
+#include <vcl/wrkwin.hxx>
+#include <tools/StringListResource.hxx>
+#include <sal/macros.h>
+
+#include <limits>
+
+#define GRAPHOBJ_URLPREFIX "vnd.sun.star.GraphicObject:"
+//------------------------------------------------------------------------
+extern "C" void SAL_CALL createRegistryInfo_FormComponentPropertyHandler()
+{
+ ::pcr::FormComponentPropertyHandler::registerImplementation();
+}
+
+//........................................................................
+namespace pcr
+{
+//........................................................................
+
+ using namespace ::com::sun::star;
+ using namespace uno;
+ using namespace lang;
+ using namespace beans;
+ using namespace frame;
+ using namespace script;
+ using namespace form;
+ using namespace util;
+ using namespace awt;
+ using namespace sdb;
+ using namespace sdbc;
+ using namespace sdbcx;
+ using namespace form;
+ using namespace container;
+ using namespace ui::dialogs;
+ using namespace inspection;
+ using namespace ::dbtools;
+
+ namespace WritingMode2 = ::com::sun::star::text::WritingMode2;
+
+ //====================================================================
+ //= FormComponentPropertyHandler
+ //====================================================================
+ DBG_NAME( FormComponentPropertyHandler )
+#define PROPERTY_ID_ROWSET 1
+ //--------------------------------------------------------------------
+ FormComponentPropertyHandler::FormComponentPropertyHandler( const Reference< XComponentContext >& _rxContext )
+ :FormComponentPropertyHandler_Base( _rxContext )
+ ,::comphelper::OPropertyContainer(FormComponentPropertyHandler_Base::rBHelper)
+ ,m_sDefaultValueString( String( PcrRes( RID_STR_STANDARD ) ) )
+ ,m_eComponentClass( eUnknown )
+ ,m_bComponentIsSubForm( false )
+ ,m_bHaveListSource( false )
+ ,m_bHaveCommand( false )
+ ,m_nClassId( 0 )
+ {
+ DBG_CTOR( FormComponentPropertyHandler, NULL );
+ registerProperty(PROPERTY_ROWSET,PROPERTY_ID_ROWSET,0,&m_xRowSet,::getCppuType(&m_xRowSet));
+ }
+
+ //--------------------------------------------------------------------
+ FormComponentPropertyHandler::~FormComponentPropertyHandler()
+ {
+ DBG_DTOR( FormComponentPropertyHandler, NULL );
+ }
+ //--------------------------------------------------------------------
+ IMPLEMENT_FORWARD_XINTERFACE2(FormComponentPropertyHandler,FormComponentPropertyHandler_Base,::comphelper::OPropertyContainer)
+ //--------------------------------------------------------------------
+ ::rtl::OUString SAL_CALL FormComponentPropertyHandler::getImplementationName_static( ) throw (RuntimeException)
+ {
+ return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.extensions.FormComponentPropertyHandler" ) );
+ }
+
+ //--------------------------------------------------------------------
+ Sequence< ::rtl::OUString > SAL_CALL FormComponentPropertyHandler::getSupportedServiceNames_static( ) throw (RuntimeException)
+ {
+ Sequence< ::rtl::OUString > aSupported( 1 );
+ aSupported[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.form.inspection.FormComponentPropertyHandler" ) );
+ return aSupported;
+ }
+
+ //============================================
+ // TODO: -> export from toolkit
+ struct LanguageDependentProp
+ {
+ const char* pPropName;
+ sal_Int32 nPropNameLength;
+ };
+
+ static LanguageDependentProp aLanguageDependentProp[] =
+ {
+ { "Text", 4 },
+ { "Label", 5 },
+ { "Title", 5 },
+ { "HelpText", 8 },
+ { "CurrencySymbol", 14 },
+ { "StringItemList", 14 },
+ { 0, 0 }
+ };
+
+ namespace
+ {
+ bool lcl_isLanguageDependentProperty( ::rtl::OUString aName )
+ {
+ bool bRet = false;
+
+ LanguageDependentProp* pLangDepProp = aLanguageDependentProp;
+ while( pLangDepProp->pPropName != 0 )
+ {
+ if( aName.equalsAsciiL( pLangDepProp->pPropName, pLangDepProp->nPropNameLength ))
+ {
+ bRet = true;
+ break;
+ }
+ pLangDepProp++;
+ }
+ return bRet;
+ }
+
+ Reference< resource::XStringResourceResolver > lcl_getStringResourceResolverForProperty
+ ( Reference< XPropertySet > _xComponent, const ::rtl::OUString& _rPropertyName,
+ const Any& _rPropertyValue )
+ {
+ Reference< resource::XStringResourceResolver > xRet;
+ const TypeClass eType = _rPropertyValue.getValueType().getTypeClass();
+ if ( (eType == TypeClass_STRING || eType == TypeClass_SEQUENCE) &&
+ lcl_isLanguageDependentProperty( _rPropertyName ) )
+ {
+ static const ::rtl::OUString s_sResourceResolverPropName(RTL_CONSTASCII_USTRINGPARAM("ResourceResolver"));
+
+ Reference< resource::XStringResourceResolver > xStringResourceResolver;
+ try
+ {
+ xStringResourceResolver.set( _xComponent->getPropertyValue( s_sResourceResolverPropName ),UNO_QUERY);
+ if( xStringResourceResolver.is() &&
+ xStringResourceResolver->getLocales().getLength() > 0 )
+ {
+ xRet = xStringResourceResolver;
+ }
+ }
+ catch(UnknownPropertyException&)
+ {
+ // nii
+ }
+ }
+
+ return xRet;
+ }
+ }
+
+ //--------------------------------------------------------------------
+ Any FormComponentPropertyHandler::impl_getPropertyValue_throw( const ::rtl::OUString& _rPropertyName ) const
+ {
+ const PropertyId nPropId( impl_getPropertyId_throw( _rPropertyName ) );
+
+ Any aPropertyValue( m_xComponent->getPropertyValue( _rPropertyName ) );
+
+ Reference< resource::XStringResourceResolver > xStringResourceResolver
+ = lcl_getStringResourceResolverForProperty( m_xComponent, _rPropertyName, aPropertyValue );
+ if( xStringResourceResolver.is() )
+ {
+ TypeClass eType = aPropertyValue.getValueType().getTypeClass();
+ if( eType == TypeClass_STRING )
+ {
+ ::rtl::OUString aPropStr;
+ aPropertyValue >>= aPropStr;
+ if( aPropStr.getLength() > 1 )
+ {
+ ::rtl::OUString aPureIdStr = aPropStr.copy( 1 );
+ if( xStringResourceResolver->hasEntryForId( aPureIdStr ) )
+ {
+ ::rtl::OUString aResourceStr = xStringResourceResolver->resolveString( aPureIdStr );
+ aPropertyValue <<= aResourceStr;
+ }
+ }
+ }
+ // StringItemList?
+ else if( eType == TypeClass_SEQUENCE )
+ {
+ Sequence< ::rtl::OUString > aStrings;
+ aPropertyValue >>= aStrings;
+
+ const ::rtl::OUString* pStrings = aStrings.getConstArray();
+ sal_Int32 nCount = aStrings.getLength();
+
+ Sequence< ::rtl::OUString > aResolvedStrings;
+ aResolvedStrings.realloc( nCount );
+ ::rtl::OUString* pResolvedStrings = aResolvedStrings.getArray();
+ try
+ {
+ for ( sal_Int32 i = 0; i < nCount; ++i )
+ {
+ ::rtl::OUString aIdStr = pStrings[i];
+ ::rtl::OUString aPureIdStr = aIdStr.copy( 1 );
+ if( xStringResourceResolver->hasEntryForId( aPureIdStr ) )
+ pResolvedStrings[i] = xStringResourceResolver->resolveString( aPureIdStr );
+ else
+ pResolvedStrings[i] = aIdStr;
+ }
+ }
+ catch( resource::MissingResourceException & )
+ {}
+ aPropertyValue <<= aResolvedStrings;
+ }
+ }
+ else
+ impl_normalizePropertyValue_nothrow( aPropertyValue, nPropId );
+
+ return aPropertyValue;
+ }
+
+ //--------------------------------------------------------------------
+ Any SAL_CALL FormComponentPropertyHandler::getPropertyValue( const ::rtl::OUString& _rPropertyName ) throw (UnknownPropertyException, RuntimeException)
+ {
+ if( _rPropertyName == PROPERTY_ROWSET )
+ return ::comphelper::OPropertyContainer::getPropertyValue( _rPropertyName );
+
+ ::osl::MutexGuard aGuard( m_aMutex );
+ return impl_getPropertyValue_throw( _rPropertyName );
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL FormComponentPropertyHandler::setPropertyValue( const ::rtl::OUString& _rPropertyName, const Any& _rValue ) throw (UnknownPropertyException, RuntimeException)
+ {
+ if( _rPropertyName == PROPERTY_ROWSET )
+ {
+ ::comphelper::OPropertyContainer::setPropertyValue( _rPropertyName, _rValue );
+ return;
+ }
+
+ ::osl::MutexGuard aGuard( m_aMutex );
+ PropertyId nPropId( impl_getPropertyId_throw( _rPropertyName ) ); // check if property is known by the handler
+
+ Reference< graphic::XGraphicObject > xGrfObj;
+ if ( PROPERTY_ID_IMAGE_URL == nPropId && ( _rValue >>= xGrfObj ) )
+ {
+ DBG_ASSERT( xGrfObj.is(), "FormComponentPropertyHandler::setPropertyValue() xGrfObj is invalid");
+ rtl::OUString sObjectID( RTL_CONSTASCII_USTRINGPARAM( GRAPHOBJ_URLPREFIX ) );
+ sObjectID = sObjectID + xGrfObj->getUniqueID();
+ m_xComponent->setPropertyValue( _rPropertyName, uno::makeAny( sObjectID ) );
+ }
+ else if ( PROPERTY_ID_FONT == nPropId )
+ {
+ // special handling, the value is a faked value we generated ourself in impl_executeFontDialog_nothrow
+ Sequence< NamedValue > aFontPropertyValues;
+ OSL_VERIFY( _rValue >>= aFontPropertyValues );
+ const NamedValue* fontPropertyValue = aFontPropertyValues.getConstArray();
+ const NamedValue* fontPropertyValueEnd = fontPropertyValue + aFontPropertyValues.getLength();
+ for ( ; fontPropertyValue != fontPropertyValueEnd; ++fontPropertyValue )
+ m_xComponent->setPropertyValue( fontPropertyValue->Name, fontPropertyValue->Value );
+ }
+ else
+ {
+ Any aValue = _rValue;
+
+ Reference< resource::XStringResourceResolver > xStringResourceResolver
+ = lcl_getStringResourceResolverForProperty( m_xComponent, _rPropertyName, _rValue );
+ if( xStringResourceResolver.is() )
+ {
+ Reference< resource::XStringResourceManager >
+ xStringResourceManager( xStringResourceResolver, UNO_QUERY );
+ if( xStringResourceManager.is() )
+ {
+ Any aPropertyValue( m_xComponent->getPropertyValue( _rPropertyName ) );
+ TypeClass eType = aPropertyValue.getValueType().getTypeClass();
+ if( eType == TypeClass_STRING )
+ {
+ ::rtl::OUString aPropStr;
+ aPropertyValue >>= aPropStr;
+ if( aPropStr.getLength() > 1 )
+ {
+ ::rtl::OUString aPureIdStr = aPropStr.copy( 1 );
+ ::rtl::OUString aValueStr;
+ _rValue >>= aValueStr;
+ xStringResourceManager->setString( aPureIdStr, aValueStr );
+ aValue = aPropertyValue; // set value to force modified
+ }
+ }
+ // StringItemList?
+ else if( eType == TypeClass_SEQUENCE )
+ {
+ static ::rtl::OUString aDot = ::rtl::OUString::createFromAscii( "." );
+ static ::rtl::OUString aEsc = ::rtl::OUString::createFromAscii( "&" );
+
+ // Put strings into resource using new ids
+ Sequence< ::rtl::OUString > aNewStrings;
+ _rValue >>= aNewStrings;
+
+ const ::rtl::OUString* pNewStrings = aNewStrings.getConstArray();
+ sal_Int32 nNewCount = aNewStrings.getLength();
+
+ // Create new Ids
+ ::rtl::OUString* pNewPureIds = new ::rtl::OUString[nNewCount];
+ ::rtl::OUString aIdStrBase = aDot;
+ Any aNameAny = m_xComponent->getPropertyValue(PROPERTY_NAME);
+ ::rtl::OUString sControlName;
+ aNameAny >>= sControlName;
+ aIdStrBase += sControlName;
+ aIdStrBase += aDot;
+ aIdStrBase += _rPropertyName;
+ sal_Int32 i;
+ ::rtl::OUString aDummyStr;
+ for ( i = 0; i < nNewCount; ++i )
+ {
+ sal_Int32 nUniqueId = xStringResourceManager->getUniqueNumericId();
+ ::rtl::OUString aPureIdStr = ::rtl::OUString::valueOf( nUniqueId );
+ aPureIdStr += aIdStrBase;
+ pNewPureIds[i] = aPureIdStr;
+ // Force usage of next Unique Id
+ xStringResourceManager->setString( aPureIdStr, aDummyStr );
+ }
+
+ // Move strings to new Ids for all locales
+ Sequence< Locale > aLocaleSeq = xStringResourceManager->getLocales();
+ const Locale* pLocale = aLocaleSeq.getConstArray();
+ sal_Int32 nLocaleCount = aLocaleSeq.getLength();
+ Sequence< ::rtl::OUString > aOldIdStrings;
+ aPropertyValue >>= aOldIdStrings;
+ try
+ {
+ const ::rtl::OUString* pOldIdStrings = aOldIdStrings.getConstArray();
+ sal_Int32 nOldIdCount = aOldIdStrings.getLength();
+ for ( i = 0; i < nNewCount; ++i )
+ {
+ ::rtl::OUString aOldIdStr;
+ ::rtl::OUString aOldPureIdStr;
+ if( i < nOldIdCount )
+ {
+ aOldIdStr = pOldIdStrings[i];
+ aOldPureIdStr = aOldIdStr.copy( 1 );
+ }
+ ::rtl::OUString aNewPureIdStr = pNewPureIds[i];
+
+ for ( sal_Int32 iLocale = 0; iLocale < nLocaleCount; ++iLocale )
+ {
+ Locale aLocale = pLocale[iLocale];
+
+ ::rtl::OUString aResourceStr;
+ if( aOldPureIdStr.getLength() != 0 )
+ {
+ if( xStringResourceManager->hasEntryForIdAndLocale( aOldPureIdStr, aLocale ) )
+ {
+ aResourceStr = xStringResourceManager->
+ resolveStringForLocale( aOldPureIdStr, aLocale );
+ }
+ }
+ xStringResourceManager->setStringForLocale( aNewPureIdStr, aResourceStr, aLocale );
+ }
+ }
+ }
+ catch( resource::MissingResourceException & )
+ {}
+
+
+ // Set new strings for current locale and create
+ // new Id sequence as new property value
+ Sequence< ::rtl::OUString > aNewIdStrings;
+ aNewIdStrings.realloc( nNewCount );
+ ::rtl::OUString* pNewIdStrings = aNewIdStrings.getArray();
+ for ( i = 0; i < nNewCount; ++i )
+ {
+ ::rtl::OUString aPureIdStr = pNewPureIds[i];
+ ::rtl::OUString aStr = pNewStrings[i];
+ xStringResourceManager->setString( aPureIdStr, aStr );
+
+ ::rtl::OUString aIdStr = aEsc;
+ aIdStr += aPureIdStr;
+ pNewIdStrings[i] = aIdStr;
+ }
+ aValue <<= aNewIdStrings;
+
+ // Remove old ids from resource for all locales
+ const ::rtl::OUString* pOldIdStrings = aOldIdStrings.getConstArray();
+ sal_Int32 nOldIdCount = aOldIdStrings.getLength();
+ for( i = 0 ; i < nOldIdCount ; ++i )
+ {
+ ::rtl::OUString aIdStr = pOldIdStrings[i];
+ ::rtl::OUString aPureIdStr = aIdStr.copy( 1 );
+ for ( sal_Int32 iLocale = 0; iLocale < nLocaleCount; ++iLocale )
+ {
+ Locale aLocale = pLocale[iLocale];
+ try
+ {
+ xStringResourceManager->removeIdForLocale( aPureIdStr, aLocale );
+ }
+ catch( resource::MissingResourceException & )
+ {}
+ }
+ }
+ delete[] pNewPureIds;
+ }
+ }
+ }
+
+ m_xComponent->setPropertyValue( _rPropertyName, aValue );
+ }
+ }
+
+ //--------------------------------------------------------------------
+ Any SAL_CALL FormComponentPropertyHandler::convertToPropertyValue( const ::rtl::OUString& _rPropertyName, const Any& _rControlValue ) throw (UnknownPropertyException, RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ PropertyId nPropId( impl_getPropertyId_throw( _rPropertyName ) );
+ Property aProperty( impl_getPropertyFromId_throw( nPropId ) );
+
+ Any aPropertyValue( _rControlValue );
+ if ( !aPropertyValue.hasValue() )
+ {
+ if ( ( aProperty.Attributes & PropertyAttribute::MAYBEVOID ) == 0 )
+ // default construct an instance of the proper type
+ aPropertyValue = Any( NULL, aProperty.Type );
+ // nothing to do
+ return aPropertyValue;
+ }
+
+ /// care for the special "default" string, translate it to VOID
+ if ( m_aPropertiesWithDefListEntry.find( _rPropertyName ) != m_aPropertiesWithDefListEntry.end() )
+ {
+ // it's a control with a string list
+ ::rtl::OUString sStringValue;
+ if ( _rControlValue >>= sStringValue )
+ { // note that ColorListBoxes might transfer values either as string or as css.util.Color,
+ // so this check here is important
+ if ( sStringValue == m_sDefaultValueString )
+ return Any();
+ }
+ }
+
+ switch ( nPropId )
+ {
+ case PROPERTY_ID_DATASOURCE:
+ {
+ ::rtl::OUString sControlValue;
+ OSL_VERIFY( _rControlValue >>= sControlValue );
+
+ if ( sControlValue.getLength() )
+ {
+ Reference< XNameAccess > xDatabaseContext;
+ m_aContext.createComponent( (::rtl::OUString)SERVICE_DATABASE_CONTEXT, xDatabaseContext );
+ if ( !xDatabaseContext.is() || !xDatabaseContext->hasByName( sControlValue ) )
+ {
+ ::svt::OFileNotation aTransformer(sControlValue);
+ aPropertyValue <<= ::rtl::OUString( aTransformer.get( ::svt::OFileNotation::N_URL ) );
+ }
+ }
+ }
+ break; // case PROPERTY_ID_DATASOURCE
+
+ case PROPERTY_ID_SHOW_POSITION:
+ case PROPERTY_ID_SHOW_NAVIGATION:
+ case PROPERTY_ID_SHOW_RECORDACTIONS:
+ case PROPERTY_ID_SHOW_FILTERSORT:
+ {
+ ::rtl::OUString sControlValue;
+ OSL_VERIFY( _rControlValue >>= sControlValue );
+
+ ::std::vector< ::rtl::OUString > aListEntries;
+ tools::StringListResource aRes( PcrRes( RID_RSC_ENUM_SHOWHIDE ), aListEntries );
+ OSL_ENSURE( aListEntries.size() == 2, "FormComponentPropertyHandler::convertToPropertyValue: broken resource for Show/Hide!" );
+ sal_Bool bShow = ( aListEntries.size() < 2 ) || ( sControlValue == aListEntries[1] );
+
+ aPropertyValue <<= bShow;
+ }
+ break;
+
+ case PROPERTY_ID_TARGET_URL:
+ case PROPERTY_ID_IMAGE_URL:
+ {
+ ::rtl::OUString sControlValue;
+ OSL_VERIFY( _rControlValue >>= sControlValue );
+ // Don't convert a placeholder
+ if ( nPropId == PROPERTY_ID_IMAGE_URL && sControlValue.equals( String( PcrRes( RID_EMBED_IMAGE_PLACEHOLDER ) ) ) )
+ aPropertyValue <<= sControlValue;
+ else
+ {
+ INetURLObject aDocURL( impl_getDocumentURL_nothrow() );
+ aPropertyValue <<= (::rtl::OUString)URIHelper::SmartRel2Abs( aDocURL, sControlValue, Link(), false, true, INetURLObject::WAS_ENCODED, INetURLObject::DECODE_TO_IURI );
+ }
+ }
+ break;
+
+ case PROPERTY_ID_DATEMIN:
+ case PROPERTY_ID_DATEMAX:
+ case PROPERTY_ID_DEFAULT_DATE:
+ case PROPERTY_ID_DATE:
+ {
+ util::Date aDate;
+ OSL_VERIFY( _rControlValue >>= aDate );
+ aPropertyValue <<= (sal_Int32)DBTypeConversion::toINT32( aDate );
+ }
+ break;
+
+ case PROPERTY_ID_TIMEMIN:
+ case PROPERTY_ID_TIMEMAX:
+ case PROPERTY_ID_DEFAULT_TIME:
+ case PROPERTY_ID_TIME:
+ {
+ util::Time aTime;
+ OSL_VERIFY( _rControlValue >>= aTime );
+ aPropertyValue <<= (sal_Int32)DBTypeConversion::toINT32( aTime );
+ }
+ break;
+
+ case PROPERTY_ID_WRITING_MODE:
+ {
+ aPropertyValue = FormComponentPropertyHandler_Base::convertToPropertyValue( _rPropertyName, _rControlValue );
+
+ sal_Int16 nNormalizedValue( 2 );
+ OSL_VERIFY( aPropertyValue >>= nNormalizedValue );
+ sal_Int16 nWritingMode = WritingMode2::CONTEXT;
+ switch ( nNormalizedValue )
+ {
+ case 0: nWritingMode = WritingMode2::LR_TB; break;
+ case 1: nWritingMode = WritingMode2::RL_TB; break;
+ case 2: nWritingMode = WritingMode2::CONTEXT; break;
+ default:
+ OSL_ENSURE( false, "FormComponentPropertyHandler::convertToPropertyValue: unexpected 'normalized value' for WritingMode!" );
+ nWritingMode = WritingMode2::CONTEXT;
+ break;
+ }
+
+ aPropertyValue <<= nWritingMode;
+ }
+ break;
+
+ default:
+ aPropertyValue = FormComponentPropertyHandler_Base::convertToPropertyValue( _rPropertyName, _rControlValue );
+ break; // default
+
+ } // switch ( nPropId )
+
+ return aPropertyValue;
+ }
+
+ //--------------------------------------------------------------------
+ Any SAL_CALL FormComponentPropertyHandler::convertToControlValue( const ::rtl::OUString& _rPropertyName, const Any& _rPropertyValue, const Type& _rControlValueType ) throw (UnknownPropertyException, RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ sal_Int32 nPropId = m_pInfoService->getPropertyId( _rPropertyName );
+ DBG_ASSERT( nPropId != -1, "FormComponentPropertyHandler::convertToPropertyValue: not one of my properties!!" );
+
+ Property aProperty( impl_getPropertyFromId_throw( nPropId ) );
+
+ Any aControlValue( _rPropertyValue );
+ if ( !aControlValue.hasValue() )
+ {
+ // if the property is represented with a list box or color list box, we need to
+ // translate this into the string "Default"
+ if ( m_aPropertiesWithDefListEntry.find( _rPropertyName ) != m_aPropertiesWithDefListEntry.end() )
+ aControlValue <<= m_sDefaultValueString;
+
+ return aControlValue;
+ }
+
+ switch ( nPropId )
+ {
+ //////////////////////////////////////////////////////////////
+ case PROPERTY_ID_SHOW_POSITION:
+ case PROPERTY_ID_SHOW_NAVIGATION:
+ case PROPERTY_ID_SHOW_RECORDACTIONS:
+ case PROPERTY_ID_SHOW_FILTERSORT:
+ {
+ ::std::vector< ::rtl::OUString > aListEntries;
+ tools::StringListResource aRes( PcrRes( RID_RSC_ENUM_SHOWHIDE ), aListEntries );
+ OSL_ENSURE( aListEntries.size() == 2, "FormComponentPropertyHandler::convertToControlValue: broken resource for Show/Hide!" );
+
+ if ( aListEntries.size() == 2 )
+ {
+ ::rtl::OUString sControlValue = ::comphelper::getBOOL( _rPropertyValue )
+ ? aListEntries[1]
+ : aListEntries[0];
+ aControlValue <<= sControlValue;
+ }
+ }
+ break;
+
+ //////////////////////////////////////////////////////////////
+ case PROPERTY_ID_DATASOURCE:
+ {
+ OSL_ENSURE( _rControlValueType.getTypeClass() == TypeClass_STRING,
+ "FormComponentPropertyHandler::convertToControlValue: wrong ControlValueType!" );
+
+ ::rtl::OUString sDataSource;
+ _rPropertyValue >>= sDataSource;
+ if ( sDataSource.getLength() )
+ {
+ ::svt::OFileNotation aTransformer( sDataSource );
+ sDataSource = aTransformer.get( ::svt::OFileNotation::N_SYSTEM );
+ }
+ aControlValue <<= sDataSource;
+ }
+ break;
+
+ //////////////////////////////////////////////////////////////
+ case PROPERTY_ID_CONTROLLABEL:
+ {
+ ::rtl::OUString sControlValue;
+
+ Reference< XPropertySet > xSet;
+ _rPropertyValue >>= xSet;
+ Reference< XPropertySetInfo > xPSI;
+ if ( xSet.is() )
+ xPSI = xSet->getPropertySetInfo();
+ if ( xPSI.is() && xPSI->hasPropertyByName( PROPERTY_LABEL ) )
+ {
+ ::rtl::OUStringBuffer aValue;
+ aValue.append( (sal_Unicode)'<' );
+ ::rtl::OUString sLabel;
+ OSL_VERIFY( xSet->getPropertyValue( PROPERTY_LABEL ) >>= sLabel );
+ aValue.append( sLabel );
+ aValue.append( (sal_Unicode)'>' );
+ sControlValue = aValue.makeStringAndClear();
+ }
+
+ aControlValue <<= sControlValue;
+ }
+ break;
+
+ //////////////////////////////////////////////////////////////
+ case PROPERTY_ID_DATEMIN:
+ case PROPERTY_ID_DATEMAX:
+ case PROPERTY_ID_DEFAULT_DATE:
+ case PROPERTY_ID_DATE:
+ {
+ sal_Int32 nDate = 0;
+ OSL_VERIFY( _rPropertyValue >>= nDate );
+ aControlValue <<= DBTypeConversion::toDate( nDate );
+ }
+ break;
+
+ case PROPERTY_ID_TIMEMIN:
+ case PROPERTY_ID_TIMEMAX:
+ case PROPERTY_ID_DEFAULT_TIME:
+ case PROPERTY_ID_TIME:
+ {
+ sal_Int32 nTime = 0;
+ OSL_VERIFY( _rPropertyValue >>= nTime );
+ aControlValue <<= DBTypeConversion::toTime( nTime );
+ }
+ break;
+
+ case PROPERTY_ID_WRITING_MODE:
+ {
+ sal_Int16 nWritingMode( WritingMode2::CONTEXT );
+ OSL_VERIFY( _rPropertyValue >>= nWritingMode );
+ sal_Int16 nNormalized = 2;
+ switch ( nWritingMode )
+ {
+ case WritingMode2::LR_TB: nNormalized = 0; break;
+ case WritingMode2::RL_TB: nNormalized = 1; break;
+ case WritingMode2::CONTEXT: nNormalized = 2; break;
+ default:
+ OSL_ENSURE( false, "FormComponentPropertyHandler::convertToControlValue: unsupported API value for WritingMode!" );
+ nNormalized = 2;
+ break;
+ }
+
+ aControlValue = FormComponentPropertyHandler_Base::convertToControlValue( _rPropertyName, makeAny( nNormalized ), _rControlValueType );
+ }
+ break;
+
+ case PROPERTY_ID_FONT:
+ {
+ FontDescriptor aFont;
+ OSL_VERIFY( _rPropertyValue >>= aFont );
+
+ ::rtl::OUStringBuffer displayName;
+ if ( !aFont.Name.getLength() )
+ {
+ displayName.append( String( PcrRes( RID_STR_FONT_DEFAULT ) ) );
+ }
+ else
+ {
+ // font name
+ displayName.append( aFont.Name );
+ displayName.appendAscii( ", " );
+
+ // font style
+ ::FontWeight eWeight = VCLUnoHelper::ConvertFontWeight( aFont.Weight );
+ USHORT nStyleResID = RID_STR_FONTSTYLE_REGULAR;
+ if ( aFont.Slant == FontSlant_ITALIC )
+ {
+ if ( eWeight > WEIGHT_NORMAL )
+ nStyleResID = RID_STR_FONTSTYLE_BOLD_ITALIC;
+ else
+ nStyleResID = RID_STR_FONTSTYLE_ITALIC;
+ }
+ else
+ {
+ if ( eWeight > WEIGHT_NORMAL )
+ nStyleResID = RID_STR_FONTSTYLE_BOLD;
+ }
+ displayName.append( String( PcrRes( nStyleResID ) ) );
+
+ // font size
+ if ( aFont.Height )
+ {
+ displayName.appendAscii( ", " );
+ displayName.append( sal_Int32( aFont.Height ) );
+ }
+ }
+
+ aControlValue <<= displayName.makeStringAndClear();
+ }
+ break;
+
+ default:
+ aControlValue = FormComponentPropertyHandler_Base::convertToControlValue( _rPropertyName, _rPropertyValue, _rControlValueType );
+ break;
+
+ } // switch ( nPropId )
+
+ return aControlValue;
+ }
+
+ //--------------------------------------------------------------------
+ PropertyState SAL_CALL FormComponentPropertyHandler::getPropertyState( const ::rtl::OUString& _rPropertyName ) throw (UnknownPropertyException, RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ if ( m_xPropertyState.is() )
+ return m_xPropertyState->getPropertyState( _rPropertyName );
+ return PropertyState_DIRECT_VALUE;
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL FormComponentPropertyHandler::addPropertyChangeListener( const Reference< XPropertyChangeListener >& _rxListener ) throw (RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ FormComponentPropertyHandler_Base::addPropertyChangeListener( _rxListener );
+ if ( m_xComponent.is() )
+ m_xComponent->addPropertyChangeListener( ::rtl::OUString(), _rxListener );
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL FormComponentPropertyHandler::removePropertyChangeListener( const Reference< XPropertyChangeListener >& _rxListener ) throw (RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ if ( m_xComponent.is() )
+ m_xComponent->removePropertyChangeListener( ::rtl::OUString(), _rxListener );
+ FormComponentPropertyHandler_Base::removePropertyChangeListener( _rxListener );
+ }
+
+ //--------------------------------------------------------------------
+ void FormComponentPropertyHandler::onNewComponent()
+ {
+ FormComponentPropertyHandler_Base::onNewComponent();
+ if ( !m_xComponentPropertyInfo.is() && m_xComponent.is() )
+ throw NullPointerException();
+
+ m_xPropertyState.set( m_xComponent, UNO_QUERY );
+ m_eComponentClass = eUnknown;
+ m_bComponentIsSubForm = m_bHaveListSource = m_bHaveCommand = false;
+ m_nClassId = 0;
+
+ impl_initComponentMetaData_throw();
+ }
+
+ //--------------------------------------------------------------------
+ Sequence< Property > SAL_CALL FormComponentPropertyHandler::doDescribeSupportedProperties() const
+ {
+ if ( !m_xComponentPropertyInfo.is() )
+ return Sequence< Property >();
+
+ ::std::vector< Property > aProperties;
+
+ Sequence< Property > aAllProperties( m_xComponentPropertyInfo->getProperties() );
+ aProperties.reserve( aAllProperties.getLength() );
+
+ // filter the properties
+ PropertyId nPropId( 0 );
+ ::rtl::OUString sDisplayName;
+
+ Property* pProperty = aAllProperties.getArray();
+ Property* pPropertiesEnd = pProperty + aAllProperties.getLength();
+ for ( ; pProperty != pPropertiesEnd; ++pProperty )
+ {
+ nPropId = m_pInfoService->getPropertyId( pProperty->Name );
+ if ( nPropId == -1 )
+ continue;
+ pProperty->Handle = nPropId;
+
+ sDisplayName = m_pInfoService->getPropertyTranslation( nPropId );
+ if ( !sDisplayName.getLength() )
+ continue;
+
+ sal_uInt32 nPropertyUIFlags = m_pInfoService->getPropertyUIFlags( nPropId );
+ bool bIsVisibleForForms = ( nPropertyUIFlags & PROP_FLAG_FORM_VISIBLE ) != 0;
+ bool bIsVisibleForDialogs = ( nPropertyUIFlags & PROP_FLAG_DIALOG_VISIBLE ) != 0;
+
+ // depending on whether we're working for a form or a UNO dialog, some
+ // properties are not displayed
+ if ( ( m_eComponentClass == eFormControl && !bIsVisibleForForms )
+ || ( m_eComponentClass == eDialogControl && !bIsVisibleForDialogs )
+ )
+ continue;
+
+ // some generic sanity checks
+ if ( impl_shouldExcludeProperty_nothrow( *pProperty ) )
+ continue;
+
+ switch ( nPropId )
+ {
+ case PROPERTY_ID_BORDER:
+ case PROPERTY_ID_TABSTOP:
+ // BORDER and TABSTOP are normalized (see impl_normalizePropertyValue_nothrow)
+ // to not allow VOID values
+ pProperty->Attributes &= ~( PropertyAttribute::MAYBEVOID );
+ break;
+
+ case PROPERTY_ID_LISTSOURCE:
+ // no cursor source if no Base is installed. #124939#
+ // This fix is not intendend to appear on the main trunk. If you find it there,
+ // please tell me! frank.schoenheit@sun.com
+ if ( SvtModuleOptions().IsModuleInstalled( SvtModuleOptions::E_SDATABASE ) )
+ const_cast< FormComponentPropertyHandler* >( this )->m_bHaveListSource = true;
+ break;
+
+ case PROPERTY_ID_COMMAND:
+ // no cursor source if no Base is installed. #124939#
+ // This fix is not intendend to appear on the main trunk. If you find it there,
+ // please tell me! frank.schoenheit@sun.com
+ if ( SvtModuleOptions().IsModuleInstalled( SvtModuleOptions::E_SDATABASE ) )
+ const_cast< FormComponentPropertyHandler* >( this )->m_bHaveCommand = true;
+ break;
+ } // switch ( nPropId )
+
+ aProperties.push_back( *pProperty );
+ }
+
+ if ( aProperties.empty() )
+ return Sequence< Property >();
+ return Sequence< Property >( &(*aProperties.begin()), aProperties.size() );
+ }
+
+ //--------------------------------------------------------------------
+ Sequence< ::rtl::OUString > SAL_CALL FormComponentPropertyHandler::getSupersededProperties( ) throw (RuntimeException)
+ {
+ return Sequence< ::rtl::OUString >( );
+ }
+
+ //--------------------------------------------------------------------
+ Sequence< ::rtl::OUString > SAL_CALL FormComponentPropertyHandler::getActuatingProperties( ) throw (RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ ::std::vector< ::rtl::OUString > aInterestingProperties;
+ aInterestingProperties.push_back( PROPERTY_DATASOURCE );
+ aInterestingProperties.push_back( PROPERTY_COMMAND );
+ aInterestingProperties.push_back( PROPERTY_COMMANDTYPE );
+ aInterestingProperties.push_back( PROPERTY_LISTSOURCE );
+ aInterestingProperties.push_back( PROPERTY_LISTSOURCETYPE );
+ aInterestingProperties.push_back( PROPERTY_SUBMIT_ENCODING );
+ aInterestingProperties.push_back( PROPERTY_REPEAT );
+ aInterestingProperties.push_back( PROPERTY_TABSTOP );
+ aInterestingProperties.push_back( PROPERTY_BORDER );
+ aInterestingProperties.push_back( PROPERTY_CONTROLSOURCE );
+ aInterestingProperties.push_back( PROPERTY_DROPDOWN );
+ aInterestingProperties.push_back( PROPERTY_IMAGE_URL );
+ aInterestingProperties.push_back( PROPERTY_TARGET_URL );
+ aInterestingProperties.push_back( PROPERTY_STRINGITEMLIST );
+ aInterestingProperties.push_back( PROPERTY_BUTTONTYPE );
+ aInterestingProperties.push_back( PROPERTY_ESCAPE_PROCESSING );
+ aInterestingProperties.push_back( PROPERTY_TRISTATE );
+ aInterestingProperties.push_back( PROPERTY_DECIMAL_ACCURACY );
+ aInterestingProperties.push_back( PROPERTY_SHOWTHOUSANDSEP );
+ aInterestingProperties.push_back( PROPERTY_FORMATKEY );
+ aInterestingProperties.push_back( PROPERTY_EMPTY_IS_NULL );
+ aInterestingProperties.push_back( PROPERTY_TOGGLE );
+ return Sequence< ::rtl::OUString >( &(*aInterestingProperties.begin()), aInterestingProperties.size() );
+ }
+
+ //--------------------------------------------------------------------
+ LineDescriptor SAL_CALL FormComponentPropertyHandler::describePropertyLine( const ::rtl::OUString& _rPropertyName,
+ const Reference< XPropertyControlFactory >& _rxControlFactory )
+ throw (UnknownPropertyException, NullPointerException, RuntimeException)
+ {
+ if ( !_rxControlFactory.is() )
+ throw NullPointerException();
+
+ ::osl::MutexGuard aGuard( m_aMutex );
+ PropertyId nPropId( impl_getPropertyId_throw( _rPropertyName ) );
+ Property aProperty( impl_getPropertyFromId_throw( nPropId ) );
+
+ //////////////////////////////////////////////////////////////////////
+ // for the MultiLine property, we have different UI translations depending on the control
+ // type
+ if ( nPropId == PROPERTY_ID_MULTILINE )
+ {
+ if ( ( m_nClassId == FormComponentType::FIXEDTEXT )
+ || ( m_nClassId == FormComponentType::COMMANDBUTTON )
+ || ( m_nClassId == FormComponentType::RADIOBUTTON )
+ || ( m_nClassId == FormComponentType::CHECKBOX )
+ )
+ nPropId = PROPERTY_ID_WORDBREAK;
+ }
+
+ String sDisplayName = m_pInfoService->getPropertyTranslation( nPropId );
+ if ( !sDisplayName.Len() )
+ {
+ DBG_ERROR( "FormComponentPropertyHandler::describePropertyLine: did getSupportedProperties not work properly?" );
+ throw UnknownPropertyException();
+ }
+
+ //////////////////////////////////////////////////////////////////////
+
+ LineDescriptor aDescriptor;
+ aDescriptor.HelpURL = HelpIdUrl::getHelpURL( m_pInfoService->getPropertyHelpId( nPropId ) );
+ aDescriptor.DisplayName = sDisplayName;
+
+ // for the moment, assume a text field
+ sal_Int16 nControlType = PropertyControlType::TextField;
+ sal_Bool bReadOnly = sal_False;
+ aDescriptor.Control.clear();
+
+ //////////////////////////////////////////////////////////////////////
+
+ bool bNeedDefaultStringIfVoidAllowed = false;
+
+ TypeClass eType = aProperty.Type.getTypeClass();
+
+ switch ( nPropId )
+ {
+ case PROPERTY_ID_DEFAULT_SELECT_SEQ:
+ case PROPERTY_ID_SELECTEDITEMS:
+ aDescriptor.PrimaryButtonId = UID_PROP_DLG_SELECTION;
+ break;
+
+ case PROPERTY_ID_FILTER:
+ aDescriptor.PrimaryButtonId = UID_PROP_DLG_FILTER;
+ break;
+
+ case PROPERTY_ID_SORT:
+ aDescriptor.PrimaryButtonId = UID_PROP_DLG_ORDER;
+ break;
+
+ case PROPERTY_ID_MASTERFIELDS:
+ case PROPERTY_ID_DETAILFIELDS:
+ nControlType = PropertyControlType::StringListField;
+ aDescriptor.PrimaryButtonId = UID_PROP_DLG_FORMLINKFIELDS;
+ break;
+
+ case PROPERTY_ID_COMMAND:
+ aDescriptor.PrimaryButtonId = UID_PROP_DLG_SQLCOMMAND;
+ break;
+
+ case PROPERTY_ID_TABINDEX:
+ {
+ Reference< XControlContainer > xControlContext( impl_getContextControlContainer_nothrow() );
+ if ( xControlContext.is() )
+ aDescriptor.PrimaryButtonId = UID_PROP_DLG_TABINDEX;
+ nControlType = PropertyControlType::NumericField;
+ };
+ break;
+
+ case PROPERTY_ID_FONT:
+ bReadOnly = sal_True;
+ aDescriptor.PrimaryButtonId = UID_PROP_DLG_FONT_TYPE;
+ break;
+
+ case PROPERTY_ID_TARGET_URL:
+ case PROPERTY_ID_IMAGE_URL:
+ {
+ aDescriptor.Control = new OFileUrlControl( impl_getDefaultDialogParent_nothrow(), WB_TABSTOP | WB_BORDER );
+
+ aDescriptor.PrimaryButtonId = ( PROPERTY_ID_TARGET_URL == nPropId )
+ ? UID_PROP_DLG_ATTR_TARGET_URL : UID_PROP_DLG_IMAGE_URL;
+ }
+ break;
+
+ case PROPERTY_ID_ECHO_CHAR:
+ nControlType = PropertyControlType::CharacterField;
+ break;
+
+ case PROPERTY_ID_BACKGROUNDCOLOR:
+ case PROPERTY_ID_FILLCOLOR:
+ case PROPERTY_ID_SYMBOLCOLOR:
+ case PROPERTY_ID_BORDERCOLOR:
+ nControlType = PropertyControlType::ColorListBox;
+
+ switch( nPropId )
+ {
+ case PROPERTY_ID_BACKGROUNDCOLOR:
+ aDescriptor.PrimaryButtonId = UID_PROP_DLG_BACKGROUNDCOLOR; break;
+ case PROPERTY_ID_FILLCOLOR:
+ aDescriptor.PrimaryButtonId = UID_PROP_DLG_FILLCOLOR; break;
+ case PROPERTY_ID_SYMBOLCOLOR:
+ aDescriptor.PrimaryButtonId = UID_PROP_DLG_SYMBOLCOLOR; break;
+ case PROPERTY_ID_BORDERCOLOR:
+ aDescriptor.PrimaryButtonId = UID_PROP_DLG_BORDERCOLOR; break;
+ }
+ break;
+
+ case PROPERTY_ID_LABEL:
+ nControlType = PropertyControlType::MultiLineTextField;
+ break;
+
+ case PROPERTY_ID_DEFAULT_TEXT:
+ {
+ if (FormComponentType::FILECONTROL == m_nClassId)
+ nControlType = PropertyControlType::TextField;
+ else
+ nControlType = PropertyControlType::MultiLineTextField;
+ }
+ break;
+
+ case PROPERTY_ID_TEXT:
+ if ( impl_componentHasProperty_throw( PROPERTY_MULTILINE ) )
+ nControlType = PropertyControlType::MultiLineTextField;
+ break;
+
+ case PROPERTY_ID_CONTROLLABEL:
+ bReadOnly = sal_True;
+ aDescriptor.PrimaryButtonId = UID_PROP_DLG_CONTROLLABEL;
+ break;
+
+ case PROPERTY_ID_FORMATKEY:
+ case PROPERTY_ID_EFFECTIVE_MIN:
+ case PROPERTY_ID_EFFECTIVE_MAX:
+ case PROPERTY_ID_EFFECTIVE_DEFAULT:
+ case PROPERTY_ID_EFFECTIVE_VALUE:
+ {
+ // and the supplier is really available
+ Reference< XNumberFormatsSupplier > xSupplier;
+ m_xComponent->getPropertyValue( PROPERTY_FORMATSSUPPLIER ) >>= xSupplier;
+ if (xSupplier.is())
+ {
+ Reference< XUnoTunnel > xTunnel(xSupplier,UNO_QUERY);
+ DBG_ASSERT(xTunnel.is(), "FormComponentPropertyHandler::describePropertyLine : xTunnel is invalid!");
+ SvNumberFormatsSupplierObj* pSupplier = reinterpret_cast<SvNumberFormatsSupplierObj*>(xTunnel->getSomething(SvNumberFormatsSupplierObj::getUnoTunnelId()));
+
+ if (pSupplier != NULL)
+ {
+ sal_Bool bIsFormatKey = (PROPERTY_ID_FORMATKEY == nPropId);
+
+ bReadOnly = bIsFormatKey;
+
+ if ( bIsFormatKey )
+ {
+ OFormatSampleControl* pControl = new OFormatSampleControl( impl_getDefaultDialogParent_nothrow(), WB_READONLY | WB_TABSTOP | WB_BORDER );
+ aDescriptor.Control = pControl;
+ pControl->SetFormatSupplier( pSupplier );
+
+ aDescriptor.PrimaryButtonId = UID_PROP_DLG_NUMBER_FORMAT;
+ }
+ else
+ {
+ OFormattedNumericControl* pControl = new OFormattedNumericControl( impl_getDefaultDialogParent_nothrow(), WB_TABSTOP | WB_BORDER );
+ aDescriptor.Control = pControl;
+
+ FormatDescription aDesc;
+ aDesc.pSupplier = pSupplier;
+ Any aFormatKeyValue = m_xComponent->getPropertyValue(PROPERTY_FORMATKEY);
+ if ( !( aFormatKeyValue >>= aDesc.nKey ) )
+ aDesc.nKey = 0;
+
+ pControl->SetFormatDescription( aDesc );
+ }
+ }
+ }
+ }
+ break;
+
+ case PROPERTY_ID_DATEMIN:
+ case PROPERTY_ID_DATEMAX:
+ case PROPERTY_ID_DEFAULT_DATE:
+ case PROPERTY_ID_DATE:
+ nControlType = PropertyControlType::DateField;
+ break;
+
+ case PROPERTY_ID_TIMEMIN:
+ case PROPERTY_ID_TIMEMAX:
+ case PROPERTY_ID_DEFAULT_TIME:
+ case PROPERTY_ID_TIME:
+ nControlType = PropertyControlType::TimeField;
+ break;
+
+ case PROPERTY_ID_VALUEMIN:
+ case PROPERTY_ID_VALUEMAX:
+ case PROPERTY_ID_DEFAULT_VALUE:
+ case PROPERTY_ID_VALUE:
+ {
+ OFormattedNumericControl* pControl = new OFormattedNumericControl( impl_getDefaultDialogParent_nothrow(), WB_TABSTOP | WB_BORDER | WB_SPIN | WB_REPEAT );
+ aDescriptor.Control = pControl;
+
+ // we don't set a formatter so the control uses a default (which uses the application
+ // language and a default numeric format)
+ // but we set the decimal digits
+ pControl->SetDecimalDigits(
+ ::comphelper::getINT16( m_xComponent->getPropertyValue( PROPERTY_DECIMAL_ACCURACY ) )
+ );
+
+ // and the thousands separator
+ pControl->SetThousandsSep(
+ ::comphelper::getBOOL( m_xComponent->getPropertyValue(PROPERTY_SHOWTHOUSANDSEP) )
+ );
+
+ // and the default value for the property
+ try
+ {
+ if (m_xPropertyState.is() && ((PROPERTY_ID_VALUEMIN == nPropId) || (PROPERTY_ID_VALUEMAX == nPropId)))
+ {
+ double nDefault = 0;
+ if ( m_xPropertyState->getPropertyDefault( aProperty.Name ) >>= nDefault )
+ pControl->SetDefaultValue( nDefault );
+ }
+ }
+ catch (Exception&)
+ {
+ // just ignore it
+ }
+
+ // and allow empty values only for the default value and the value
+ pControl->EnableEmptyField( ( PROPERTY_ID_DEFAULT_VALUE == nPropId )
+ || ( PROPERTY_ID_VALUE == nPropId ) );
+ }
+ break;
+
+ default:
+ if ( TypeClass_BYTE <= eType && eType <= TypeClass_DOUBLE )
+ {
+ sal_Int16 nDigits = 0;
+ sal_Int16 nValueUnit = -1;
+ sal_Int16 nDisplayUnit = -1;
+ if ( m_eComponentClass == eFormControl )
+ {
+ if ( ( nPropId == PROPERTY_ID_WIDTH )
+ || ( nPropId == PROPERTY_ID_ROWHEIGHT )
+ || ( nPropId == PROPERTY_ID_HEIGHT )
+ )
+ {
+ nValueUnit = MeasureUnit::MM_10TH;
+ nDisplayUnit = impl_getDocumentMeasurementUnit_throw();
+ nDigits = 2;
+ }
+ }
+
+ Optional< double > aValueNotPresent( sal_False, 0 );
+ aDescriptor.Control = PropertyHandlerHelper::createNumericControl(
+ _rxControlFactory, nDigits, aValueNotPresent, aValueNotPresent, sal_False );
+
+ Reference< XNumericControl > xNumericControl( aDescriptor.Control, UNO_QUERY_THROW );
+ if ( nValueUnit != -1 )
+ xNumericControl->setValueUnit( nValueUnit );
+ if ( nDisplayUnit != -1 )
+ xNumericControl->setDisplayUnit( nDisplayUnit );
+ }
+ break;
+ }
+
+ //////////////////////////////////////////////////////////////////////
+ if ( eType == TypeClass_SEQUENCE )
+ nControlType = PropertyControlType::StringListField;
+
+ //////////////////////////////////////////////////////////////////////
+ // boolean values
+ if ( eType == TypeClass_BOOLEAN )
+ {
+ USHORT nResId = RID_RSC_ENUM_YESNO;
+ if ( ( nPropId == PROPERTY_ID_SHOW_POSITION )
+ || ( nPropId == PROPERTY_ID_SHOW_NAVIGATION )
+ || ( nPropId == PROPERTY_ID_SHOW_RECORDACTIONS )
+ || ( nPropId == PROPERTY_ID_SHOW_FILTERSORT )
+ )
+ nResId = RID_RSC_ENUM_SHOWHIDE;
+
+ ::std::vector< ::rtl::OUString > aListEntries;
+ tools::StringListResource aRes(PcrRes(nResId),aListEntries);
+ aDescriptor.Control = PropertyHandlerHelper::createListBoxControl( _rxControlFactory, aListEntries, sal_False, sal_False );
+ bNeedDefaultStringIfVoidAllowed = true;
+ }
+
+ //////////////////////////////////////////////////////////////////////
+ // enum properties
+ sal_uInt32 nPropertyUIFlags = m_pInfoService->getPropertyUIFlags( nPropId );
+ bool bIsEnumProperty = ( nPropertyUIFlags & PROP_FLAG_ENUM ) != 0;
+ if ( bIsEnumProperty || ( PROPERTY_ID_TARGET_FRAME == nPropId ) )
+ {
+ ::std::vector< ::rtl::OUString > aEnumValues = m_pInfoService->getPropertyEnumRepresentations( nPropId );
+ ::std::vector< ::rtl::OUString >::const_iterator pStart = aEnumValues.begin();
+ ::std::vector< ::rtl::OUString >::const_iterator pEnd = aEnumValues.end();
+
+ // for a checkbox: if "ambiguous" is not allowed, remove this from the sequence
+ if ( ( PROPERTY_ID_DEFAULT_STATE == nPropId )
+ || ( PROPERTY_ID_STATE == nPropId )
+ )
+ {
+ if ( impl_componentHasProperty_throw( PROPERTY_TRISTATE ) )
+ {
+ if ( !::comphelper::getBOOL( m_xComponent->getPropertyValue( PROPERTY_TRISTATE ) ) )
+ { // remove the last sequence element
+ if ( pEnd > pStart )
+ --pEnd;
+ }
+ }
+ else
+ --pEnd;
+ }
+
+ if ( PROPERTY_ID_LISTSOURCETYPE == nPropId )
+ if ( FormComponentType::COMBOBOX == m_nClassId )
+ // remove the first sequence element -> value list not possible for combo boxes
+ ++pStart;
+
+ // copy the sequence
+ ::std::vector< ::rtl::OUString > aListEntries( pEnd - pStart );
+ ::std::copy( pStart, pEnd, aListEntries.begin() );
+
+ // create the control
+ if ( PROPERTY_ID_TARGET_FRAME == nPropId )
+ aDescriptor.Control = PropertyHandlerHelper::createComboBoxControl( _rxControlFactory, aListEntries, sal_False, sal_False );
+ else
+ {
+ aDescriptor.Control = PropertyHandlerHelper::createListBoxControl( _rxControlFactory, aListEntries, sal_False, sal_False );
+ bNeedDefaultStringIfVoidAllowed = true;
+ }
+ }
+
+ //////////////////////////////////////////////////////////////////////
+ switch( nPropId )
+ {
+ case PROPERTY_ID_REPEAT_DELAY:
+ {
+ OTimeDurationControl* pControl = new OTimeDurationControl( impl_getDefaultDialogParent_nothrow(), WB_BORDER | WB_TABSTOP );
+ aDescriptor.Control = pControl;
+
+ pControl->setMinValue( Optional< double >( sal_True, 0 ) );
+ pControl->setMaxValue( Optional< double >( sal_True, ::std::numeric_limits< double >::max() ) );
+ }
+ break;
+
+ case PROPERTY_ID_TABINDEX:
+ case PROPERTY_ID_BOUNDCOLUMN:
+ case PROPERTY_ID_VISIBLESIZE:
+ case PROPERTY_ID_MAXTEXTLEN:
+ case PROPERTY_ID_LINEINCREMENT:
+ case PROPERTY_ID_BLOCKINCREMENT:
+ case PROPERTY_ID_SPININCREMENT:
+ {
+ Optional< double > aMinValue( sal_True, 0 );
+ Optional< double > aMaxValue( sal_True, 0x7FFFFFFF );
+
+ if ( nPropId == PROPERTY_ID_MAXTEXTLEN )
+ aMinValue.Value = -1;
+ else if ( ( nPropId == PROPERTY_ID_BOUNDCOLUMN ) || ( nPropId == PROPERTY_ID_VISIBLESIZE ) )
+ aMinValue.Value = 1;
+ else
+ aMinValue.Value = 0;
+
+ aDescriptor.Control = PropertyHandlerHelper::createNumericControl(
+ _rxControlFactory, 0, aMinValue, aMaxValue, sal_False );
+ }
+ break;
+
+ case PROPERTY_ID_DECIMAL_ACCURACY:
+ {
+ Optional< double > aMinValue( sal_True, 0 );
+ Optional< double > aMaxValue( sal_True, 20 );
+
+ aDescriptor.Control = PropertyHandlerHelper::createNumericControl(
+ _rxControlFactory, 0, aMinValue, aMaxValue, sal_False );
+ }
+ break;
+
+ //////////////////////////////////////////////////////////////////////
+ // DataSource
+ case PROPERTY_ID_DATASOURCE:
+ {
+ aDescriptor.PrimaryButtonId = UID_PROP_DLG_ATTR_DATASOURCE;
+
+ ::std::vector< ::rtl::OUString > aListEntries;
+
+ Reference< XNameAccess > xDatabaseContext;
+ m_aContext.createComponent( (rtl::OUString)SERVICE_DATABASE_CONTEXT, xDatabaseContext );
+ if (xDatabaseContext.is())
+ {
+ Sequence< ::rtl::OUString > aDatasources = xDatabaseContext->getElementNames();
+ aListEntries.resize( aDatasources.getLength() );
+ ::std::copy( aDatasources.getConstArray(), aDatasources.getConstArray() + aDatasources.getLength(),
+ aListEntries.begin() );
+ }
+ aDescriptor.Control = PropertyHandlerHelper::createComboBoxControl(
+ _rxControlFactory, aListEntries, sal_False, sal_True );
+ }
+ break;
+
+ case PROPERTY_ID_CONTROLSOURCE:
+ {
+ ::std::vector< ::rtl::OUString > aFieldNames;
+ impl_initFieldList_nothrow( aFieldNames );
+ aDescriptor.Control = PropertyHandlerHelper::createComboBoxControl(
+ _rxControlFactory, aFieldNames, sal_False, sal_False );
+ }
+ break;
+
+ case PROPERTY_ID_COMMAND:
+ impl_describeCursorSource_nothrow( aDescriptor, _rxControlFactory );
+ break;
+
+ case PROPERTY_ID_LISTSOURCE:
+ impl_describeListSourceUI_throw( aDescriptor, _rxControlFactory );
+ break;
+ }
+
+ if ( !aDescriptor.Control.is() )
+ aDescriptor.Control = _rxControlFactory->createPropertyControl( nControlType, bReadOnly );
+
+ if ( ( aProperty.Attributes & PropertyAttribute::MAYBEVOID ) != 0 )
+ {
+ // insert the string "Default" string, if necessary
+ if ( bNeedDefaultStringIfVoidAllowed || ( nControlType == PropertyControlType::ColorListBox ) )
+ {
+ Reference< XStringListControl > xStringList( aDescriptor.Control, UNO_QUERY_THROW );
+ xStringList->prependListEntry( m_sDefaultValueString );
+ m_aPropertiesWithDefListEntry.insert( _rPropertyName );
+ }
+ }
+
+ if ( aDescriptor.PrimaryButtonId )
+ aDescriptor.HasPrimaryButton = sal_True;
+ if ( aDescriptor.SecondaryButtonId )
+ aDescriptor.HasSecondaryButton = sal_True;
+
+ bool bIsDataProperty = ( nPropertyUIFlags & PROP_FLAG_DATA_PROPERTY ) != 0;
+ aDescriptor.Category = ::rtl::OUString::createFromAscii( bIsDataProperty ? "Data" : "General" );
+ return aDescriptor;
+ }
+
+ //--------------------------------------------------------------------
+ InteractiveSelectionResult SAL_CALL FormComponentPropertyHandler::onInteractivePropertySelection( const ::rtl::OUString& _rPropertyName, sal_Bool /*_bPrimary*/, Any& _rData, const Reference< XObjectInspectorUI >& _rxInspectorUI ) throw (UnknownPropertyException, NullPointerException, RuntimeException)
+ {
+ if ( !_rxInspectorUI.is() )
+ throw NullPointerException();
+
+ ::osl::ClearableMutexGuard aGuard( m_aMutex );
+ PropertyId nPropId( impl_getPropertyId_throw( _rPropertyName ) );
+
+ InteractiveSelectionResult eResult = InteractiveSelectionResult_Cancelled;
+ switch ( nPropId )
+ {
+ case PROPERTY_ID_DEFAULT_SELECT_SEQ:
+ case PROPERTY_ID_SELECTEDITEMS:
+ if ( impl_dialogListSelection_nothrow( _rPropertyName, aGuard ) )
+ eResult = InteractiveSelectionResult_Success;
+ break;
+
+ case PROPERTY_ID_FILTER:
+ case PROPERTY_ID_SORT:
+ {
+ ::rtl::OUString sClause;
+ if ( impl_dialogFilterOrSort_nothrow( PROPERTY_ID_FILTER == nPropId, sClause, aGuard ) )
+ {
+ _rData <<= sClause;
+ eResult = InteractiveSelectionResult_ObtainedValue;
+ }
+ }
+ break;
+
+ case PROPERTY_ID_MASTERFIELDS:
+ case PROPERTY_ID_DETAILFIELDS:
+ if ( impl_dialogLinkedFormFields_nothrow( aGuard ) )
+ eResult = InteractiveSelectionResult_Success;
+ break;
+
+ case PROPERTY_ID_FORMATKEY:
+ if ( impl_dialogFormatting_nothrow( _rData, aGuard ) )
+ eResult = InteractiveSelectionResult_ObtainedValue;
+ break;
+
+ case PROPERTY_ID_IMAGE_URL:
+ if ( impl_browseForImage_nothrow( _rData, aGuard ) )
+ eResult = InteractiveSelectionResult_ObtainedValue;
+ break;
+
+ case PROPERTY_ID_TARGET_URL:
+ if ( impl_browseForTargetURL_nothrow( _rData, aGuard ) )
+ eResult = InteractiveSelectionResult_ObtainedValue;
+ break;
+
+ case PROPERTY_ID_FONT:
+ if ( impl_executeFontDialog_nothrow( _rData, aGuard ) )
+ eResult = InteractiveSelectionResult_ObtainedValue;
+ break;
+
+ case PROPERTY_ID_DATASOURCE:
+ if ( impl_browseForDatabaseDocument_throw( _rData, aGuard ) )
+ eResult = InteractiveSelectionResult_ObtainedValue;
+ break;
+
+ case PROPERTY_ID_BACKGROUNDCOLOR:
+ case PROPERTY_ID_FILLCOLOR:
+ case PROPERTY_ID_SYMBOLCOLOR:
+ case PROPERTY_ID_BORDERCOLOR:
+ if ( impl_dialogColorChooser_throw( nPropId, _rData, aGuard ) )
+ eResult = InteractiveSelectionResult_ObtainedValue;
+ break;
+
+ case PROPERTY_ID_CONTROLLABEL:
+ if ( impl_dialogChooseLabelControl_nothrow( _rData, aGuard ) )
+ eResult = InteractiveSelectionResult_ObtainedValue;
+ break;
+
+ case PROPERTY_ID_TABINDEX:
+ if ( impl_dialogChangeTabOrder_nothrow( aGuard ) )
+ eResult = InteractiveSelectionResult_Success;
+ break;
+
+ case PROPERTY_ID_COMMAND:
+ case PROPERTY_ID_LISTSOURCE:
+ if ( impl_doDesignSQLCommand_nothrow( _rxInspectorUI, nPropId ) )
+ eResult = InteractiveSelectionResult_Pending;
+ break;
+ default:
+ DBG_ERROR( "FormComponentPropertyHandler::onInteractivePropertySelection: request for a property which does not have dedicated UI!" );
+ break;
+ }
+ return eResult;
+ }
+
+ //--------------------------------------------------------------------
+ namespace
+ {
+ void lcl_rebuildAndResetCommand( const Reference< XObjectInspectorUI >& _rxInspectorUI, const Reference< XPropertyHandler >& _rxHandler )
+ {
+ OSL_PRECOND( _rxInspectorUI.is(), "lcl_rebuildAndResetCommand: invalid BrowserUI!" );
+ OSL_PRECOND( _rxHandler.is(), "lcl_rebuildAndResetCommand: invalid handler!" );
+ _rxInspectorUI->rebuildPropertyUI( PROPERTY_COMMAND );
+ _rxHandler->setPropertyValue( PROPERTY_COMMAND, makeAny( ::rtl::OUString() ) );
+ }
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL FormComponentPropertyHandler::actuatingPropertyChanged( const ::rtl::OUString& _rActuatingPropertyName, const Any& _rNewValue, const Any& /*_rOldValue*/, const Reference< XObjectInspectorUI >& _rxInspectorUI, sal_Bool _bFirstTimeInit ) throw (NullPointerException, RuntimeException)
+ {
+ if ( !_rxInspectorUI.is() )
+ throw NullPointerException();
+
+ ::osl::MutexGuard aGuard( m_aMutex );
+ PropertyId nActuatingPropId( impl_getPropertyId_throw( _rActuatingPropertyName ) );
+
+ ::std::vector< PropertyId > aDependentProperties;
+
+ switch ( nActuatingPropId )
+ {
+ // ----- EscapeProcessing -----
+ case PROPERTY_ID_ESCAPE_PROCESSING:
+ aDependentProperties.push_back( PROPERTY_ID_FILTER );
+ aDependentProperties.push_back( PROPERTY_ID_SORT );
+ break; // case PROPERTY_ID_ESCAPE_PROCESSING
+
+ // ----- CommandType -----
+ case PROPERTY_ID_COMMANDTYPE:
+ // available commands (tables or queries) might have changed
+ if ( !_bFirstTimeInit && m_bHaveCommand )
+ lcl_rebuildAndResetCommand( _rxInspectorUI, this );
+ aDependentProperties.push_back( PROPERTY_ID_COMMAND );
+ break; // case PROPERTY_ID_COMMANDTYPE
+
+ // ----- DataSourceName -----
+ case PROPERTY_ID_DATASOURCE:
+ // reset the connection, now that we have a new data source
+ impl_clearRowsetConnection_nothrow();
+
+ // available list source values (tables or queries) might have changed
+ if ( !_bFirstTimeInit && m_bHaveListSource )
+ _rxInspectorUI->rebuildPropertyUI( PROPERTY_LISTSOURCE );
+
+ // available commands (tables or queries) might have changed
+ if ( !_bFirstTimeInit && m_bHaveCommand )
+ lcl_rebuildAndResetCommand( _rxInspectorUI, this );
+
+ // Command also depends on DataSource
+ aDependentProperties.push_back( PROPERTY_ID_COMMAND );
+ // NO break!
+
+ // ----- Command -----
+ case PROPERTY_ID_COMMAND:
+ aDependentProperties.push_back( PROPERTY_ID_FILTER );
+ aDependentProperties.push_back( PROPERTY_ID_SORT );
+ if ( m_bComponentIsSubForm )
+ aDependentProperties.push_back( PROPERTY_ID_DETAILFIELDS );
+ break;
+
+ // ----- ListSourceType -----
+ case PROPERTY_ID_LISTSOURCETYPE:
+ if ( !_bFirstTimeInit && m_bHaveListSource )
+ // available list source values (tables or queries) might have changed
+ _rxInspectorUI->rebuildPropertyUI( PROPERTY_LISTSOURCE );
+ aDependentProperties.push_back( PROPERTY_ID_BOUNDCOLUMN );
+ aDependentProperties.push_back( PROPERTY_ID_STRINGITEMLIST );
+ // NO break!
+
+ // ----- StringItemList -----
+ case PROPERTY_ID_STRINGITEMLIST:
+ aDependentProperties.push_back( PROPERTY_ID_SELECTEDITEMS );
+ aDependentProperties.push_back( PROPERTY_ID_DEFAULT_SELECT_SEQ );
+ break;
+
+ // ----- ListSource -----
+ case PROPERTY_ID_LISTSOURCE:
+ aDependentProperties.push_back( PROPERTY_ID_STRINGITEMLIST );
+ break;
+
+ // ----- DataField -----
+ case PROPERTY_ID_CONTROLSOURCE:
+ {
+ ::rtl::OUString sControlSource;
+ _rNewValue >>= sControlSource;
+ if ( impl_componentHasProperty_throw( PROPERTY_FILTERPROPOSAL ) )
+ _rxInspectorUI->enablePropertyUI( PROPERTY_FILTERPROPOSAL, sControlSource.getLength() > 0 );
+ if ( impl_componentHasProperty_throw( PROPERTY_EMPTY_IS_NULL ) )
+ _rxInspectorUI->enablePropertyUI( PROPERTY_EMPTY_IS_NULL, sControlSource.getLength() > 0 );
+
+ aDependentProperties.push_back( PROPERTY_ID_BOUNDCOLUMN );
+ aDependentProperties.push_back( PROPERTY_ID_SCALEIMAGE );
+ aDependentProperties.push_back( PROPERTY_ID_SCALE_MODE );
+ aDependentProperties.push_back( PROPERTY_ID_INPUT_REQUIRED );
+ }
+ break;
+
+ case PROPERTY_ID_EMPTY_IS_NULL:
+ aDependentProperties.push_back( PROPERTY_ID_INPUT_REQUIRED );
+ break;
+
+ // ----- SubmitEncoding -----
+ case PROPERTY_ID_SUBMIT_ENCODING:
+ {
+ FormSubmitEncoding eEncoding = FormSubmitEncoding_URL;
+ OSL_VERIFY( _rNewValue >>= eEncoding );
+ _rxInspectorUI->enablePropertyUI( PROPERTY_SUBMIT_METHOD, eEncoding == FormSubmitEncoding_URL );
+ }
+ break;
+
+ // ----- Repeat -----
+ case PROPERTY_ID_REPEAT:
+ {
+ sal_Bool bIsRepeating = sal_False;
+ OSL_VERIFY( _rNewValue >>= bIsRepeating );
+ _rxInspectorUI->enablePropertyUI( PROPERTY_REPEAT_DELAY, bIsRepeating );
+ }
+ break;
+
+ // ----- TabStop -----
+ case PROPERTY_ID_TABSTOP:
+ {
+ if ( !impl_componentHasProperty_throw( PROPERTY_TABINDEX ) )
+ break;
+ sal_Bool bHasTabStop = sal_False;
+ _rNewValue >>= bHasTabStop;
+ _rxInspectorUI->enablePropertyUI( PROPERTY_TABINDEX, bHasTabStop );
+ }
+ break;
+
+ // ----- Border -----
+ case PROPERTY_ID_BORDER:
+ {
+ sal_Int16 nBordeType = VisualEffect::NONE;
+ OSL_VERIFY( _rNewValue >>= nBordeType );
+ _rxInspectorUI->enablePropertyUI( PROPERTY_BORDERCOLOR, nBordeType == VisualEffect::FLAT );
+ }
+ break;
+
+ // ----- DropDown -----
+ case PROPERTY_ID_DROPDOWN:
+ {
+ if ( impl_isSupportedProperty_nothrow( PROPERTY_ID_LINECOUNT ) )
+ {
+ sal_Bool bDropDown = sal_True;
+ _rNewValue >>= bDropDown;
+ _rxInspectorUI->enablePropertyUI( PROPERTY_LINECOUNT, bDropDown );
+ }
+ }
+ break;
+
+ // ----- ImageURL -----
+ case PROPERTY_ID_IMAGE_URL:
+ {
+ if ( impl_isSupportedProperty_nothrow( PROPERTY_ID_IMAGEPOSITION ) )
+ {
+ ::rtl::OUString sImageURL;
+ OSL_VERIFY( _rNewValue >>= sImageURL );
+ _rxInspectorUI->enablePropertyUI( PROPERTY_IMAGEPOSITION, sImageURL.getLength() != 0 );
+ }
+
+ aDependentProperties.push_back( PROPERTY_ID_SCALEIMAGE );
+ aDependentProperties.push_back( PROPERTY_ID_SCALE_MODE );
+ }
+ break;
+
+ // ----- ButtonType -----
+ case PROPERTY_ID_BUTTONTYPE:
+ {
+ FormButtonType eButtonType( FormButtonType_PUSH );
+ OSL_VERIFY( _rNewValue >>= eButtonType );
+ _rxInspectorUI->enablePropertyUI( PROPERTY_TARGET_URL, FormButtonType_URL == eButtonType );
+ }
+ // NO break!
+
+ // ----- TargetURL -----
+ case PROPERTY_ID_TARGET_URL:
+ aDependentProperties.push_back( PROPERTY_ID_TARGET_FRAME );
+ break; // case PROPERTY_ID_TARGET_URL
+
+ // ----- TriState -----
+ case PROPERTY_ID_TRISTATE:
+ if ( !_bFirstTimeInit )
+ _rxInspectorUI->rebuildPropertyUI( m_eComponentClass == eFormControl ? PROPERTY_DEFAULT_STATE : PROPERTY_STATE );
+ break; // case PROPERTY_ID_TRISTATE
+
+ // ----- DecimalAccuracy -----
+ case PROPERTY_ID_DECIMAL_ACCURACY:
+ // ----- ShowThousandsSeparator -----
+ case PROPERTY_ID_SHOWTHOUSANDSEP:
+ {
+ sal_Bool bAccuracy = (PROPERTY_ID_DECIMAL_ACCURACY == nActuatingPropId);
+ sal_uInt16 nNewDigits = 0;
+ sal_Bool bUseSep = sal_False;
+ if ( bAccuracy )
+ OSL_VERIFY( _rNewValue >>= nNewDigits );
+ else
+ OSL_VERIFY( _rNewValue >>= bUseSep );
+
+ // propagate the changes to the min/max/default fields
+ Any aCurrentProp;
+ ::rtl::OUString aAffectedProps[] = { PROPERTY_VALUE, PROPERTY_DEFAULT_VALUE, PROPERTY_VALUEMIN, PROPERTY_VALUEMAX };
+ for (sal_uInt16 i=0; i<SAL_N_ELEMENTS(aAffectedProps); ++i)
+ {
+ Reference< XPropertyControl > xControl;
+ try
+ {
+ xControl = _rxInspectorUI->getPropertyControl( aAffectedProps[i] );
+ }
+ catch( const UnknownPropertyException& e ) { (void)e; }
+ if ( xControl.is() )
+ {
+ OFormattedNumericControl* pControl = dynamic_cast< OFormattedNumericControl* >( xControl.get() );
+ DBG_ASSERT( pControl, "FormComponentPropertyHandler::actuatingPropertyChanged: invalid control!" );
+ if ( pControl )
+ {
+ if ( bAccuracy )
+ pControl->SetDecimalDigits( nNewDigits );
+ else
+ pControl->SetThousandsSep( bUseSep );
+ }
+ }
+ }
+ }
+ break;
+
+ // ----- FormatKey -----
+ case PROPERTY_ID_FORMATKEY:
+ {
+ FormatDescription aNewDesc;
+
+ Reference< XNumberFormatsSupplier > xSupplier;
+ OSL_VERIFY( m_xComponent->getPropertyValue( PROPERTY_FORMATSSUPPLIER ) >>= xSupplier );
+
+ Reference< XUnoTunnel > xTunnel( xSupplier, UNO_QUERY );
+ DBG_ASSERT(xTunnel.is(), "FormComponentPropertyHandler::actuatingPropertyChanged: xTunnel is invalid!");
+ if ( xTunnel.is() )
+ {
+ SvNumberFormatsSupplierObj* pSupplier = reinterpret_cast<SvNumberFormatsSupplierObj*>(xTunnel->getSomething(SvNumberFormatsSupplierObj::getUnoTunnelId()));
+ // the same again
+
+ aNewDesc.pSupplier = pSupplier;
+ if ( !( _rNewValue >>= aNewDesc.nKey ) )
+ aNewDesc.nKey = 0;
+
+ // give each control which has to know this an own copy of the description
+ ::rtl::OUString aFormattedPropertyControls[] = {
+ PROPERTY_EFFECTIVE_MIN, PROPERTY_EFFECTIVE_MAX, PROPERTY_EFFECTIVE_DEFAULT, PROPERTY_EFFECTIVE_VALUE
+ };
+ for ( sal_uInt16 i=0; i<SAL_N_ELEMENTS(aFormattedPropertyControls); ++i )
+ {
+ Reference< XPropertyControl > xControl;
+ try
+ {
+ xControl = _rxInspectorUI->getPropertyControl( aFormattedPropertyControls[i] );
+ }
+ catch( const UnknownPropertyException& e ) { (void)e; }
+ if ( xControl.is() )
+ {
+ OFormattedNumericControl* pControl = dynamic_cast< OFormattedNumericControl* >( xControl.get() );
+ DBG_ASSERT( pControl, "FormComponentPropertyHandler::actuatingPropertyChanged: invalid control!" );
+ if ( pControl )
+ pControl->SetFormatDescription( aNewDesc );
+ }
+ }
+ }
+ }
+ break;
+
+ case PROPERTY_ID_TOGGLE:
+ {
+ sal_Bool bIsToggleButton = sal_False;
+ OSL_VERIFY( _rNewValue >>= bIsToggleButton );
+ _rxInspectorUI->enablePropertyUI( PROPERTY_DEFAULT_STATE, bIsToggleButton );
+ }
+ break;
+
+ default:
+ DBG_ERROR( "FormComponentPropertyHandler::actuatingPropertyChanged: did not register for this property!" );
+ break;
+
+ } // switch ( nActuatingPropId )
+
+ for ( ::std::vector< PropertyId >::const_iterator loopAffected = aDependentProperties.begin();
+ loopAffected != aDependentProperties.end();
+ ++loopAffected
+ )
+ {
+ if ( impl_isSupportedProperty_nothrow( *loopAffected ) )
+ impl_updateDependentProperty_nothrow( *loopAffected, _rxInspectorUI );
+ }
+ }
+
+ //------------------------------------------------------------------------
+ void FormComponentPropertyHandler::impl_updateDependentProperty_nothrow( PropertyId _nPropId, const Reference< XObjectInspectorUI >& _rxInspectorUI ) const
+ {
+ try
+ {
+ switch ( _nPropId )
+ {
+ // ----- StringItemList -----
+ case PROPERTY_ID_STRINGITEMLIST:
+ {
+ ListSourceType eLSType = ListSourceType_VALUELIST;
+ OSL_VERIFY( impl_getPropertyValue_throw( PROPERTY_LISTSOURCETYPE ) >>= eLSType );
+
+ ::rtl::OUString sListSource;
+ {
+ Sequence< ::rtl::OUString > aListSource;
+ Any aListSourceValue( impl_getPropertyValue_throw( PROPERTY_LISTSOURCE ) );
+ if ( aListSourceValue >>= aListSource )
+ {
+ if ( aListSource.getLength() )
+ sListSource = aListSource[0];
+ }
+ else
+ OSL_VERIFY( aListSourceValue >>= sListSource );
+ }
+
+ sal_Bool bIsEnabled = ( ( eLSType == ListSourceType_VALUELIST )
+ || ( sListSource.getLength() == 0 )
+ );
+ _rxInspectorUI->enablePropertyUI( PROPERTY_STRINGITEMLIST, bIsEnabled );
+ }
+ break; // case PROPERTY_ID_STRINGITEMLIST
+
+ // ----- BoundColumn -----
+ case PROPERTY_ID_BOUNDCOLUMN:
+ {
+ ::rtl::OUString sControlSource;
+ OSL_VERIFY( impl_getPropertyValue_throw( PROPERTY_CONTROLSOURCE ) >>= sControlSource );
+
+ ListSourceType eLSType = ListSourceType_VALUELIST;
+ OSL_VERIFY( impl_getPropertyValue_throw( PROPERTY_LISTSOURCETYPE ) >>= eLSType );
+
+ _rxInspectorUI->enablePropertyUI( PROPERTY_BOUNDCOLUMN,
+ ( sControlSource.getLength() > 0 )
+ && ( eLSType != ListSourceType_TABLEFIELDS )
+ && ( eLSType != ListSourceType_VALUELIST )
+ );
+ }
+ break; // case PROPERTY_ID_BOUNDCOLUMN
+
+ // ----- ScaleImage, ScaleMode -----
+ case PROPERTY_ID_SCALEIMAGE:
+ case PROPERTY_ID_SCALE_MODE:
+ {
+ ::rtl::OUString sControlSource;
+ if ( impl_isSupportedProperty_nothrow( PROPERTY_ID_CONTROLSOURCE ) )
+ impl_getPropertyValue_throw( PROPERTY_CONTROLSOURCE ) >>= sControlSource;
+
+ ::rtl::OUString sImageURL;
+ impl_getPropertyValue_throw( PROPERTY_IMAGE_URL ) >>= sImageURL;
+
+ _rxInspectorUI->enablePropertyUI( impl_getPropertyNameFromId_nothrow( _nPropId ),
+ ( sControlSource.getLength() != 0 ) || ( sImageURL.getLength() != 0 )
+ );
+ }
+ break; // case PROPERTY_ID_SCALEIMAGE, PROPERTY_ID_SCALE_MODE
+
+ // ----- InputRequired -----
+ case PROPERTY_ID_INPUT_REQUIRED:
+ {
+ ::rtl::OUString sControlSource;
+ OSL_VERIFY( impl_getPropertyValue_throw( PROPERTY_CONTROLSOURCE ) >>= sControlSource );
+
+ sal_Bool bEmptyIsNULL = sal_False;
+ sal_Bool bHasEmptyIsNULL = impl_componentHasProperty_throw( PROPERTY_EMPTY_IS_NULL );
+ if ( bHasEmptyIsNULL )
+ OSL_VERIFY( impl_getPropertyValue_throw( PROPERTY_EMPTY_IS_NULL ) >>= bEmptyIsNULL );
+
+ // if the control is not bound to a DB field, there is no sense in having the "Input required"
+ // property
+ // Also, if an empty input of this control are *not* written as NULL, but as empty strings,
+ // then "Input required" does not make sense, too (since there's always an input, even if the control
+ // is empty).
+ _rxInspectorUI->enablePropertyUI( PROPERTY_INPUT_REQUIRED,
+ ( sControlSource.getLength() != 0 ) && ( !bHasEmptyIsNULL || bEmptyIsNULL )
+ );
+ }
+ break;
+
+ // ----- SelectedItems, DefaultSelection -----
+ case PROPERTY_ID_SELECTEDITEMS:
+ case PROPERTY_ID_DEFAULT_SELECT_SEQ:
+ {
+ Sequence< ::rtl::OUString > aEntries;
+ impl_getPropertyValue_throw( PROPERTY_STRINGITEMLIST ) >>= aEntries;
+ bool isEnabled = aEntries.getLength() != 0;
+
+ if ( ( m_nClassId == FormComponentType::LISTBOX ) && ( m_eComponentClass == eFormControl ) )
+ {
+ ListSourceType eLSType = ListSourceType_VALUELIST;
+ impl_getPropertyValue_throw( PROPERTY_LISTSOURCETYPE ) >>= eLSType;
+ isEnabled &= ( eLSType == ListSourceType_VALUELIST );
+ }
+ _rxInspectorUI->enablePropertyUIElements( impl_getPropertyNameFromId_nothrow( _nPropId ),
+ PropertyLineElement::PrimaryButton, isEnabled );
+ }
+ break; // case PROPERTY_ID_DEFAULT_SELECT_SEQ
+
+ // ----- TargetFrame ------
+ case PROPERTY_ID_TARGET_FRAME:
+ {
+ ::rtl::OUString sTargetURL;
+ impl_getPropertyValue_throw( PROPERTY_TARGET_URL ) >>= sTargetURL;
+ FormButtonType eButtonType( FormButtonType_URL );
+ if ( 0 != m_nClassId )
+ {
+ OSL_VERIFY( impl_getPropertyValue_throw( PROPERTY_BUTTONTYPE ) >>= eButtonType );
+ }
+ // if m_nClassId is 0, then we're inspecting a form. In this case, eButtonType is always
+ // FormButtonType_URL here
+ _rxInspectorUI->enablePropertyUI( PROPERTY_TARGET_FRAME,
+ ( eButtonType == FormButtonType_URL ) && ( sTargetURL.getLength() > 0 )
+ );
+ }
+ break;
+
+ // ----- Order ------
+ case PROPERTY_ID_SORT:
+ // ----- Filter ------
+ case PROPERTY_ID_FILTER:
+ {
+ Reference< XConnection > xConnection;
+ bool bAllowEmptyDS = ::dbtools::isEmbeddedInDatabase( m_xComponent, xConnection );
+
+ // if there's no escape processing, we cannot enter any values for this property
+ sal_Bool bDoEscapeProcessing( sal_False );
+ impl_getPropertyValue_throw( PROPERTY_ESCAPE_PROCESSING ) >>= bDoEscapeProcessing;
+ _rxInspectorUI->enablePropertyUI(
+ impl_getPropertyNameFromId_nothrow( _nPropId ),
+ bDoEscapeProcessing
+ );
+
+ // also care for the browse button - enabled if we have escape processing, and a valid
+ // data source signature
+ _rxInspectorUI->enablePropertyUIElements(
+ impl_getPropertyNameFromId_nothrow( _nPropId ),
+ PropertyLineElement::PrimaryButton,
+ impl_hasValidDataSourceSignature_nothrow( m_xComponent, bAllowEmptyDS )
+ && bDoEscapeProcessing
+ );
+ }
+ break; // case PROPERTY_ID_FILTER:
+
+ // ----- Command -----
+ case PROPERTY_ID_COMMAND:
+ {
+ sal_Int32 nCommandType( CommandType::COMMAND );
+ OSL_VERIFY( impl_getPropertyValue_throw( PROPERTY_COMMANDTYPE ) >>= nCommandType );
+
+ impl_ensureRowsetConnection_nothrow();
+ Reference< XConnection > xConnection = m_xRowSetConnection.getTyped();
+ bool bAllowEmptyDS = false;
+ if ( !xConnection.is() )
+ bAllowEmptyDS = ::dbtools::isEmbeddedInDatabase( m_xComponent, xConnection );
+
+ bool doEnable = ( nCommandType == CommandType::COMMAND )
+ && ( m_xRowSetConnection.is()
+ || xConnection.is()
+ || impl_hasValidDataSourceSignature_nothrow( m_xComponent, bAllowEmptyDS)
+ );
+
+ _rxInspectorUI->enablePropertyUIElements(
+ PROPERTY_COMMAND,
+ PropertyLineElement::PrimaryButton,
+ doEnable
+ );
+ }
+ break; // case PROPERTY_ID_COMMAND
+
+ // ----- DetailFields -----
+ case PROPERTY_ID_DETAILFIELDS:
+ {
+ Reference< XConnection > xConnection;
+ bool bAllowEmptyDS = ::dbtools::isEmbeddedInDatabase( m_xComponent, xConnection );
+
+ // both our current form, and it's parent form, need to have a valid
+ // data source signature
+ bool bDoEnableMasterDetailFields =
+ impl_hasValidDataSourceSignature_nothrow( m_xComponent, bAllowEmptyDS )
+ && impl_hasValidDataSourceSignature_nothrow( Reference< XPropertySet >( m_xObjectParent, UNO_QUERY ), bAllowEmptyDS );
+
+ // in opposite to the other properties, here in real *two* properties are
+ // affected
+ _rxInspectorUI->enablePropertyUIElements( PROPERTY_DETAILFIELDS, PropertyLineElement::PrimaryButton, bDoEnableMasterDetailFields );
+ _rxInspectorUI->enablePropertyUIElements( PROPERTY_MASTERFIELDS, PropertyLineElement::PrimaryButton, bDoEnableMasterDetailFields );
+ }
+ break;
+
+ default:
+ OSL_ENSURE( false, "FormComponentPropertyHandler::impl_updateDependentProperty_nothrow: unexpected property to update!" );
+ break;
+
+ } // switch
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "FormComponentPropertyHandler::impl_updateDependentProperty_nothrow: caught an exception!" );
+ }
+ }
+
+ //------------------------------------------------------------------------
+ void SAL_CALL FormComponentPropertyHandler::disposing()
+ {
+ FormComponentPropertyHandler_Base::disposing();
+ if ( m_xCommandDesigner.is() && m_xCommandDesigner->isActive() )
+ m_xCommandDesigner->dispose();
+ }
+
+ //------------------------------------------------------------------------
+ sal_Bool SAL_CALL FormComponentPropertyHandler::suspend( sal_Bool _bSuspend ) throw (RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ if ( _bSuspend )
+ if ( m_xCommandDesigner.is() && m_xCommandDesigner->isActive() )
+ return m_xCommandDesigner->suspend();
+ return sal_True;
+ }
+
+ //------------------------------------------------------------------------
+ void FormComponentPropertyHandler::impl_initComponentMetaData_throw()
+ {
+ try
+ {
+ //////////////////////////////////////////////////////////////////
+ // component class
+ m_eComponentClass = eUnknown;
+
+ if ( impl_componentHasProperty_throw( PROPERTY_WIDTH )
+ && impl_componentHasProperty_throw( PROPERTY_HEIGHT )
+ && impl_componentHasProperty_throw( PROPERTY_POSITIONX )
+ && impl_componentHasProperty_throw( PROPERTY_POSITIONY )
+ && impl_componentHasProperty_throw( PROPERTY_STEP )
+ && impl_componentHasProperty_throw( PROPERTY_TABINDEX )
+ )
+ {
+ m_eComponentClass = eDialogControl;
+ }
+ else
+ {
+ m_eComponentClass = eFormControl;
+ }
+
+ //////////////////////////////////////////////////////////////////
+ // (database) sub form?
+ Reference< XForm > xAsForm( m_xComponent, UNO_QUERY );
+ if ( xAsForm.is() )
+ {
+ Reference< XChild > xFormAsChild( xAsForm, UNO_QUERY );
+ Reference< XForm > xFormsParent;
+ if ( xFormAsChild.is() )
+ xFormsParent = xFormsParent.query( xFormAsChild->getParent() );
+ m_bComponentIsSubForm = xFormsParent.is();
+ }
+
+ //////////////////////////////////////////////////////////////////
+ // ClassId
+ Reference< XChild > xCompAsChild( m_xComponent, UNO_QUERY );
+ if ( xCompAsChild.is() )
+ m_xObjectParent = xCompAsChild->getParent();
+
+ //////////////////////////////////////////////////////////////////
+ // ClassId
+ impl_classifyControlModel_throw();
+ }
+ catch( const RuntimeException& )
+ {
+ throw;
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "FormComponentPropertyHandler::impl_initComponentMetaData_throw: caught an exception!" );
+ }
+ }
+
+ //------------------------------------------------------------------------
+ void FormComponentPropertyHandler::impl_classifyControlModel_throw( )
+ {
+ if ( impl_componentHasProperty_throw( PROPERTY_CLASSID ) )
+ {
+ OSL_VERIFY( m_xComponent->getPropertyValue( PROPERTY_CLASSID ) >>= m_nClassId );
+ }
+ else if ( eDialogControl == m_eComponentClass )
+ {
+ Reference< XControlModel > xControlModel( m_xComponent, UNO_QUERY );
+ Reference< XServiceInfo > xServiceInfo( m_xComponent, UNO_QUERY );
+ if ( xServiceInfo.is() )
+ {
+ // it's a control model, and can tell about it's supported services
+ m_nClassId = FormComponentType::CONTROL;
+
+ const sal_Char* aControlModelServiceNames[] =
+ {
+ "UnoControlButtonModel",
+ "UnoControlCheckBoxModel",
+ "UnoControlComboBoxModel",
+ "UnoControlCurrencyFieldModel",
+ "UnoControlDateFieldModel",
+ "UnoControlEditModel",
+ "UnoControlFileControlModel",
+ "UnoControlFixedTextModel",
+ "UnoControlGroupBoxModel",
+ "UnoControlImageControlModel",
+ "UnoControlListBoxModel",
+ "UnoControlNumericFieldModel",
+ "UnoControlPatternFieldModel",
+ "UnoControlRadioButtonModel",
+ "UnoControlScrollBarModel",
+ "UnoControlSpinButtonModel",
+ "UnoControlTimeFieldModel",
+
+ "UnoControlFixedLineModel",
+ "UnoControlFormattedFieldModel",
+ "UnoControlProgressBarModel"
+ };
+ const sal_Int16 nClassIDs[] =
+ {
+ FormComponentType::COMMANDBUTTON,
+ FormComponentType::CHECKBOX,
+ FormComponentType::COMBOBOX,
+ FormComponentType::CURRENCYFIELD,
+ FormComponentType::DATEFIELD,
+ FormComponentType::TEXTFIELD,
+ FormComponentType::FILECONTROL,
+ FormComponentType::FIXEDTEXT,
+ FormComponentType::GROUPBOX,
+ FormComponentType::IMAGECONTROL,
+ FormComponentType::LISTBOX,
+ FormComponentType::NUMERICFIELD,
+ FormComponentType::PATTERNFIELD,
+ FormComponentType::RADIOBUTTON,
+ FormComponentType::SCROLLBAR,
+ FormComponentType::SPINBUTTON,
+ FormComponentType::TIMEFIELD,
+
+ ControlType::FIXEDLINE,
+ ControlType::FORMATTEDFIELD,
+ ControlType::PROGRESSBAR
+ };
+
+ sal_Int32 nKnownControlTypes = SAL_N_ELEMENTS( aControlModelServiceNames );
+ OSL_ENSURE( nKnownControlTypes == SAL_N_ELEMENTS( nClassIDs ),
+ "FormComponentPropertyHandler::impl_classifyControlModel_throw: inconsistence" );
+
+ for ( sal_Int32 i = 0; i < nKnownControlTypes; ++i )
+ {
+ ::rtl::OUString sServiceName( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt." ) );
+ sServiceName += ::rtl::OUString::createFromAscii( aControlModelServiceNames[ i ] );
+
+ if ( xServiceInfo->supportsService( sServiceName ) )
+ {
+ m_nClassId = nClassIDs[ i ];
+ break;
+ }
+ }
+ }
+ }
+ }
+
+ //------------------------------------------------------------------------
+ void FormComponentPropertyHandler::impl_normalizePropertyValue_nothrow( Any& _rValue, PropertyId _nPropId ) const
+ {
+ switch ( _nPropId )
+ {
+ case PROPERTY_ID_TABSTOP:
+ if ( !_rValue.hasValue() )
+ {
+ switch ( m_nClassId )
+ {
+ case FormComponentType::COMMANDBUTTON:
+ case FormComponentType::RADIOBUTTON:
+ case FormComponentType::CHECKBOX:
+ case FormComponentType::TEXTFIELD:
+ case FormComponentType::LISTBOX:
+ case FormComponentType::COMBOBOX:
+ case FormComponentType::FILECONTROL:
+ case FormComponentType::DATEFIELD:
+ case FormComponentType::TIMEFIELD:
+ case FormComponentType::NUMERICFIELD:
+ case ControlType::FORMATTEDFIELD:
+ case FormComponentType::CURRENCYFIELD:
+ case FormComponentType::PATTERNFIELD:
+ _rValue = makeAny( (sal_Bool)sal_True );
+ break;
+ default:
+ _rValue = makeAny( (sal_Bool)sal_False );
+ break;
+ }
+ }
+ break;
+ }
+ }
+
+ //------------------------------------------------------------------------
+ bool FormComponentPropertyHandler::impl_shouldExcludeProperty_nothrow( const Property& _rProperty ) const
+ {
+ OSL_ENSURE( _rProperty.Handle == m_pInfoService->getPropertyId( _rProperty.Name ),
+ "FormComponentPropertyHandler::impl_shouldExcludeProperty_nothrow: insonsistency in the property!" );
+
+ if ( _rProperty.Handle == PROPERTY_ID_CONTROLLABEL )
+ // prevent that this is caught below
+ return false;
+
+ if ( ( _rProperty.Type.getTypeClass() == TypeClass_INTERFACE )
+ || ( _rProperty.Type.getTypeClass() == TypeClass_ARRAY )
+ || ( _rProperty.Type.getTypeClass() == TypeClass_UNKNOWN )
+ )
+ return true;
+
+ if ( ( _rProperty.Attributes & PropertyAttribute::TRANSIENT ) && ( m_eComponentClass != eDialogControl ) )
+ // strange enough, dialog controls declare a lot of their properties as transient
+ return true;
+
+ if ( _rProperty.Attributes & PropertyAttribute::READONLY )
+ return true;
+
+ switch ( _rProperty.Handle )
+ {
+ case PROPERTY_ID_MASTERFIELDS:
+ case PROPERTY_ID_DETAILFIELDS:
+ if ( !m_bComponentIsSubForm )
+ // no master and detail fields for forms which are no sub forms
+ return true;
+ break;
+
+ case PROPERTY_ID_DATASOURCE:
+ {
+ // don't show DataSource if the component is part of an embedded form document
+ Reference< XConnection > xConn;
+ if ( isEmbeddedInDatabase( m_xComponent, xConn ) )
+ return true;
+ }
+ break;
+
+ case PROPERTY_ID_TEXT:
+ // don't show the "Text" property of formatted fields
+ if ( ControlType::FORMATTEDFIELD == m_nClassId )
+ return true;
+ break;
+
+ case PROPERTY_ID_FORMATKEY:
+ case PROPERTY_ID_EFFECTIVE_MIN:
+ case PROPERTY_ID_EFFECTIVE_MAX:
+ case PROPERTY_ID_EFFECTIVE_DEFAULT:
+ case PROPERTY_ID_EFFECTIVE_VALUE:
+ // only if the set has a formats supplier, too
+ if ( !impl_componentHasProperty_throw( PROPERTY_FORMATSSUPPLIER ) )
+ return true;
+ // (form) date and time fields also have a formats supplier, but the format itself
+ // is reflected in another property
+ if ( ( FormComponentType::DATEFIELD == m_nClassId )
+ || ( FormComponentType::TIMEFIELD == m_nClassId )
+ )
+ return true;
+ break;
+
+ case PROPERTY_ID_SCALEIMAGE:
+ if ( impl_componentHasProperty_throw( PROPERTY_SCALE_MODE ) )
+ // ScaleImage is superseded by ScaleMode
+ return true;
+ break;
+
+ case PROPERTY_ID_WRITING_MODE:
+ if ( !SvtCTLOptions().IsCTLFontEnabled() )
+ return true;
+ break;
+ }
+
+ sal_uInt32 nPropertyUIFlags = m_pInfoService->getPropertyUIFlags( _rProperty.Handle );
+
+ // don't show experimental properties unless allowed to do so
+ if ( ( nPropertyUIFlags & PROP_FLAG_EXPERIMENTAL ) != 0 )
+ {
+ if ( true ) // TODO
+ return true;
+ }
+
+ // no data properties if no Base is installed. #124939#
+ // This fix is not intendend to appear on the main trunk. If you find it there,
+ // please tell me! frank.schoenheit@sun.com
+ if ( ( nPropertyUIFlags & PROP_FLAG_DATA_PROPERTY ) != 0 )
+ if ( !SvtModuleOptions().IsModuleInstalled( SvtModuleOptions::E_SDATABASE ) )
+ return true;
+
+ return false;
+ }
+
+ //------------------------------------------------------------------------
+ Reference< XRowSet > FormComponentPropertyHandler::impl_getRowSet_throw( ) const
+ {
+ Reference< XRowSet > xRowSet = m_xRowSet;
+ if ( !xRowSet.is() )
+ {
+ xRowSet.set( m_xComponent, UNO_QUERY );
+ if ( !xRowSet.is() )
+ {
+ xRowSet = Reference< XRowSet >( m_xObjectParent, UNO_QUERY );
+ if ( !xRowSet.is() )
+ {
+ // are we inspecting a grid column?
+ if (Reference< XGridColumnFactory >( m_xObjectParent, UNO_QUERY) .is())
+ { // yes
+ Reference< XChild > xParentAsChild( m_xObjectParent, UNO_QUERY );
+ if ( xParentAsChild.is() )
+ xRowSet = Reference< XRowSet >( xParentAsChild->getParent(), UNO_QUERY );
+ }
+ }
+ if ( !xRowSet.is() )
+ xRowSet = m_xRowSet;
+ }
+ DBG_ASSERT( xRowSet.is(), "FormComponentPropertyHandler::impl_getRowSet_throw: could not obtain the rowset for the introspectee!" );
+ }
+ return xRowSet;
+ }
+
+ //------------------------------------------------------------------------
+ Reference< XRowSet > FormComponentPropertyHandler::impl_getRowSet_nothrow( ) const
+ {
+ Reference< XRowSet > xReturn;
+ try
+ {
+ xReturn = impl_getRowSet_throw();
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "FormComponentPropertyHandler::impl_getRowSet_nothrow: caught an exception!" );
+ }
+ return xReturn;
+ }
+
+ //------------------------------------------------------------------------
+ void FormComponentPropertyHandler::impl_initFieldList_nothrow( ::std::vector< ::rtl::OUString >& _rFieldNames ) const
+ {
+ clearContainer( _rFieldNames );
+ try
+ {
+ WaitCursor aWaitCursor( impl_getDefaultDialogParent_nothrow() );
+
+ Reference< XPreparedStatement > xStatement;
+
+ // get the form of the control we're inspecting
+ Reference< XPropertySet > xFormSet( impl_getRowSet_throw(), UNO_QUERY );
+ if ( !xFormSet.is() )
+ return;
+
+ ::rtl::OUString sObjectName;
+ OSL_VERIFY( xFormSet->getPropertyValue( PROPERTY_COMMAND ) >>= sObjectName );
+ // when there is no command we don't need to ask for columns
+ if ( sObjectName.getLength() && impl_ensureRowsetConnection_nothrow() )
+ {
+ ::rtl::OUString aDatabaseName;
+ OSL_VERIFY( xFormSet->getPropertyValue( PROPERTY_DATASOURCE ) >>= aDatabaseName );
+ sal_Int32 nObjectType = CommandType::COMMAND;
+ OSL_VERIFY( xFormSet->getPropertyValue( PROPERTY_COMMANDTYPE ) >>= nObjectType );
+
+ Sequence< ::rtl::OUString > aFields( ::dbtools::getFieldNamesByCommandDescriptor( m_xRowSetConnection, nObjectType, sObjectName ) );
+
+ const ::rtl::OUString* pFields = aFields.getConstArray();
+ for ( sal_Int32 i = 0; i < aFields.getLength(); ++i, ++pFields )
+ _rFieldNames.push_back( *pFields );
+ }
+ }
+ catch (Exception&)
+ {
+ DBG_ERROR( "FormComponentPropertyHandler::impl_initFieldList_nothrow: caught an exception!" );
+ }
+ }
+
+ //------------------------------------------------------------------------
+ void FormComponentPropertyHandler::impl_clearRowsetConnection_nothrow()
+ {
+ m_xRowSetConnection.clear();
+ }
+
+ //------------------------------------------------------------------------
+ void FormComponentPropertyHandler::impl_displaySQLError_nothrow( const ::dbtools::SQLExceptionInfo& _rErrorDescriptor ) const
+ {
+ ::dbtools::showError( _rErrorDescriptor, VCLUnoHelper::GetInterface( impl_getDefaultDialogParent_nothrow() ), m_aContext.getLegacyServiceFactory() );
+ }
+
+ //------------------------------------------------------------------------
+ bool FormComponentPropertyHandler::impl_ensureRowsetConnection_nothrow() const
+ {
+ if ( !m_xRowSetConnection.is() )
+ {
+ uno::Reference<sdbc::XConnection> xConnection(m_aContext.getContextValueByAsciiName( "ActiveConnection" ),uno::UNO_QUERY);
+ m_xRowSetConnection.reset(xConnection,::dbtools::SharedConnection::NoTakeOwnership);
+ }
+ if ( m_xRowSetConnection.is() )
+ return true;
+
+ Reference< XRowSet > xRowSet( impl_getRowSet_throw() );
+ Reference< XPropertySet > xRowSetProps( xRowSet, UNO_QUERY );
+
+ // connect the row set - this is delegated to elsewhere - while observing errors
+ SQLExceptionInfo aError;
+ try
+ {
+ if ( xRowSetProps.is() )
+ {
+ WaitCursor aWaitCursor( impl_getDefaultDialogParent_nothrow() );
+ m_xRowSetConnection = ::dbtools::ensureRowSetConnection( xRowSet, m_aContext.getLegacyServiceFactory(), false );
+ }
+ }
+ catch ( const SQLException& ) { aError = SQLExceptionInfo( ::cppu::getCaughtException() ); }
+ catch ( const WrappedTargetException& e ) { aError = SQLExceptionInfo( e.TargetException ); }
+ catch ( const Exception& ) { DBG_UNHANDLED_EXCEPTION(); }
+
+ // report errors, if necessary
+ if ( aError.isValid() )
+ {
+ ::rtl::OUString sDataSourceName;
+ try
+ {
+ xRowSetProps->getPropertyValue( PROPERTY_DATASOURCE ) >>= sDataSourceName;
+ }
+ catch( const Exception& )
+ {
+ DBG_ERROR( "FormComponentPropertyHandler::impl_ensureRowsetConnection_nothrow: caught an exception during error handling!" );
+ }
+ // additional info about what happended
+ String sInfo( PcrRes( RID_STR_UNABLETOCONNECT ) );
+ INetURLObject aParser( sDataSourceName );
+ if ( aParser.GetProtocol() != INET_PROT_NOT_VALID )
+ sDataSourceName = aParser.getBase( INetURLObject::LAST_SEGMENT, true, INetURLObject::DECODE_WITH_CHARSET );
+ sInfo.SearchAndReplaceAllAscii( "$name$", sDataSourceName );
+
+ SQLContext aContext;
+ aContext.Message = sInfo;
+ aContext.NextException = aError.get();
+ impl_displaySQLError_nothrow( aContext );
+ }
+
+ return m_xRowSetConnection.is();
+ }
+
+ //------------------------------------------------------------------------
+ void FormComponentPropertyHandler::impl_describeCursorSource_nothrow( LineDescriptor& _out_rProperty, const Reference< XPropertyControlFactory >& _rxControlFactory ) const
+ {
+ try
+ {
+ WaitCursor aWaitCursor( impl_getDefaultDialogParent_nothrow() );
+
+ ////////////////////////////////////////////////////////////
+ // Setzen der UI-Daten
+ _out_rProperty.DisplayName = m_pInfoService->getPropertyTranslation( PROPERTY_ID_COMMAND );
+
+ _out_rProperty.HelpURL = HelpIdUrl::getHelpURL( m_pInfoService->getPropertyHelpId( PROPERTY_ID_COMMAND ) );
+ _out_rProperty.PrimaryButtonId = UID_PROP_DLG_SQLCOMMAND;
+
+ ////////////////////////////////////////////////////////////
+ sal_Int32 nCommandType = CommandType::COMMAND;
+ impl_getPropertyValue_throw( PROPERTY_COMMANDTYPE ) >>= nCommandType;
+
+ switch ( nCommandType )
+ {
+ case CommandType::TABLE:
+ case CommandType::QUERY:
+ {
+ ::std::vector< ::rtl::OUString > aNames;
+ if ( impl_ensureRowsetConnection_nothrow() )
+ {
+ if ( nCommandType == CommandType::TABLE )
+ impl_fillTableNames_throw( aNames );
+ else
+ impl_fillQueryNames_throw( aNames );
+ }
+ _out_rProperty.Control = PropertyHandlerHelper::createComboBoxControl( _rxControlFactory, aNames, sal_False, sal_True );
+ }
+ break;
+
+ default:
+ _out_rProperty.Control = _rxControlFactory->createPropertyControl( PropertyControlType::MultiLineTextField, sal_False );
+ break;
+ }
+ }
+ catch (Exception&)
+ {
+ DBG_ERROR("FormComponentPropertyHandler::impl_describeCursorSource_nothrow: caught an exception !");
+ }
+ }
+
+ //------------------------------------------------------------------------
+ void FormComponentPropertyHandler::impl_fillTableNames_throw( ::std::vector< ::rtl::OUString >& _out_rNames ) const
+ {
+ OSL_PRECOND( m_xRowSetConnection.is(), "FormComponentPropertyHandler::impl_fillTableNames_throw: need a connection!" );
+ _out_rNames.resize( 0 );
+
+ Reference< XTablesSupplier > xSupplyTables( m_xRowSetConnection, UNO_QUERY );
+ Reference< XNameAccess > xTableNames;
+ if ( xSupplyTables.is() )
+ xTableNames = xSupplyTables->getTables();
+ DBG_ASSERT( xTableNames.is(), "FormComponentPropertyHandler::impl_fillTableNames_throw: no way to obtain the tables of the connection!" );
+ if ( !xTableNames.is() )
+ return;
+
+ Sequence< ::rtl::OUString> aTableNames = xTableNames->getElementNames();
+ sal_uInt32 nCount = aTableNames.getLength();
+ const ::rtl::OUString* pTableNames = aTableNames.getConstArray();
+
+ for ( sal_uInt32 i=0; i<nCount; ++i ,++pTableNames )
+ _out_rNames.push_back( *pTableNames );
+ }
+
+ //------------------------------------------------------------------------
+ void FormComponentPropertyHandler::impl_fillQueryNames_throw( ::std::vector< ::rtl::OUString >& _out_rNames ) const
+ {
+ OSL_PRECOND( m_xRowSetConnection.is(), "FormComponentPropertyHandler::impl_fillQueryNames_throw: need a connection!" );
+ _out_rNames.resize( 0 );
+
+ Reference< XQueriesSupplier > xSupplyQueries( m_xRowSetConnection, UNO_QUERY );
+ Reference< XNameAccess > xQueryNames;
+ if ( xSupplyQueries.is() )
+ {
+ xQueryNames = xSupplyQueries->getQueries();
+ impl_fillQueryNames_throw(xQueryNames,_out_rNames);
+ }
+ }
+ //------------------------------------------------------------------------
+ void FormComponentPropertyHandler::impl_fillQueryNames_throw( const Reference< XNameAccess >& _xQueryNames,::std::vector< ::rtl::OUString >& _out_rNames,const ::rtl::OUString& _sName ) const
+ {
+ DBG_ASSERT( _xQueryNames.is(), "FormComponentPropertyHandler::impl_fillQueryNames_throw: no way to obtain the queries of the connection!" );
+ if ( !_xQueryNames.is() )
+ return;
+
+ Sequence< ::rtl::OUString> aQueryNames = _xQueryNames->getElementNames();
+ sal_uInt32 nCount = aQueryNames.getLength();
+ const ::rtl::OUString* pQueryNames = aQueryNames.getConstArray();
+ sal_Bool bAdd = _sName.getLength();
+
+ for ( sal_uInt32 i=0; i<nCount; i++, ++pQueryNames )
+ {
+ ::rtl::OUStringBuffer sTemp;
+ if ( bAdd )
+ {
+ sTemp.append(_sName);
+ sTemp.appendAscii("/");
+ }
+ sTemp.append(*pQueryNames);
+ Reference< XNameAccess > xSubQueries(_xQueryNames->getByName(*pQueryNames),UNO_QUERY);
+ if ( xSubQueries.is() )
+ impl_fillQueryNames_throw(xSubQueries,_out_rNames,sTemp.makeStringAndClear());
+ else
+ _out_rNames.push_back( sTemp.makeStringAndClear() );
+ }
+ }
+
+ //------------------------------------------------------------------------
+ void FormComponentPropertyHandler::impl_describeListSourceUI_throw( LineDescriptor& _out_rDescriptor, const Reference< XPropertyControlFactory >& _rxControlFactory ) const
+ {
+ OSL_PRECOND( m_xComponent.is(), "FormComponentPropertyHandler::impl_describeListSourceUI_throw: no component!" );
+
+ ////////////////////////////////////////////////////////////
+ // Auslesen des ListSourceTypes
+ Any aListSourceType( m_xComponent->getPropertyValue( PROPERTY_LISTSOURCETYPE ) );
+
+ sal_Int32 nListSourceType = ListSourceType_VALUELIST;
+ ::cppu::enum2int( nListSourceType, aListSourceType );
+
+ _out_rDescriptor.DisplayName = m_pInfoService->getPropertyTranslation( PROPERTY_ID_LISTSOURCE );
+ _out_rDescriptor.HelpURL = HelpIdUrl::getHelpURL( m_pInfoService->getPropertyHelpId( PROPERTY_ID_LISTSOURCE ) );
+
+ ////////////////////////////////////////////////////////////
+ // Enums setzen
+ switch( nListSourceType )
+ {
+ case ListSourceType_VALUELIST:
+ _out_rDescriptor.Control = _rxControlFactory->createPropertyControl( PropertyControlType::StringListField, sal_False );
+ break;
+
+ case ListSourceType_TABLEFIELDS:
+ case ListSourceType_TABLE:
+ case ListSourceType_QUERY:
+ {
+ ::std::vector< ::rtl::OUString > aListEntries;
+ if ( impl_ensureRowsetConnection_nothrow() )
+ {
+ if ( nListSourceType == ListSourceType_QUERY )
+ impl_fillQueryNames_throw( aListEntries );
+ else
+ impl_fillTableNames_throw( aListEntries );
+ }
+ _out_rDescriptor.Control = PropertyHandlerHelper::createComboBoxControl( _rxControlFactory, aListEntries, sal_False, sal_False );
+ }
+ break;
+ case ListSourceType_SQL:
+ case ListSourceType_SQLPASSTHROUGH:
+ impl_ensureRowsetConnection_nothrow();
+ _out_rDescriptor.HasPrimaryButton = m_xRowSetConnection.is();
+ break;
+ }
+ }
+
+ //------------------------------------------------------------------------
+ bool FormComponentPropertyHandler::impl_dialogListSelection_nothrow( const ::rtl::OUString& _rProperty, ::osl::ClearableMutexGuard& _rClearBeforeDialog ) const
+ {
+ OSL_PRECOND( m_pInfoService.get(), "FormComponentPropertyHandler::impl_dialogListSelection_nothrow: no property meta data!" );
+
+ String sPropertyUIName( m_pInfoService->getPropertyTranslation( m_pInfoService->getPropertyId( _rProperty ) ) );
+ ListSelectionDialog aDialog( impl_getDefaultDialogParent_nothrow(), m_xComponent, _rProperty, sPropertyUIName );
+ _rClearBeforeDialog.clear();
+ return ( RET_OK == aDialog.Execute() );
+ }
+
+ //------------------------------------------------------------------------
+ bool FormComponentPropertyHandler::impl_dialogFilterOrSort_nothrow( bool _bFilter, ::rtl::OUString& _out_rSelectedClause, ::osl::ClearableMutexGuard& _rClearBeforeDialog ) const
+ {
+ OSL_PRECOND( Reference< XRowSet >( m_xComponent, UNO_QUERY ).is(),
+ "FormComponentPropertyHandler::impl_dialogFilterOrSort_nothrow: to be called for forms only!" );
+
+ _out_rSelectedClause = ::rtl::OUString();
+ bool bSuccess = false;
+ SQLExceptionInfo aErrorInfo;
+ try
+ {
+ if ( !impl_ensureRowsetConnection_nothrow() )
+ return false;
+
+ // get a composer for the statement which the form is currently based on
+ Reference< XSingleSelectQueryComposer > xComposer( ::dbtools::getCurrentSettingsComposer( m_xComponent, m_aContext.getLegacyServiceFactory() ) );
+ OSL_ENSURE( xComposer.is(), "FormComponentPropertyHandler::impl_dialogFilterOrSort_nothrow: could not obtain a composer!" );
+ if ( !xComposer.is() )
+ return false;
+
+ ::rtl::OUString sPropertyUIName( m_pInfoService->getPropertyTranslation( _bFilter ? PROPERTY_ID_FILTER : PROPERTY_ID_SORT ) );
+
+ const sal_Char* pAsciiServiceName = _bFilter ? "com.sun.star.sdb.FilterDialog" : "com.sun.star.sdb.OrderDialog";
+
+ // create the dialog
+ Reference< XExecutableDialog > xDialog;
+ if ( !m_aContext.createComponent( pAsciiServiceName, xDialog ) )
+ {
+ ShowServiceNotAvailableError( impl_getDefaultDialogParent_nothrow(), ::rtl::OUString::createFromAscii( pAsciiServiceName ), sal_True );
+ return false;
+ }
+
+ // initialize the dialog
+ Reference< XPropertySet > xDialogProps( xDialog, UNO_QUERY_THROW );
+ xDialogProps->setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "QueryComposer" ) ), makeAny( xComposer ) );
+ xDialogProps->setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "RowSet" ) ), makeAny( m_xComponent ) );
+ xDialogProps->setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ParentWindow" ) ), makeAny( VCLUnoHelper::GetInterface( impl_getDefaultDialogParent_nothrow() ) ) );
+ xDialogProps->setPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Title" ) ), makeAny( sPropertyUIName ) );
+
+ _rClearBeforeDialog.clear();
+ bSuccess = ( xDialog->execute() != 0 );
+ if ( bSuccess )
+ _out_rSelectedClause = _bFilter ? xComposer->getFilter() : xComposer->getOrder();
+ }
+ catch (SQLContext& e) { aErrorInfo = e; }
+ catch (SQLWarning& e) { aErrorInfo = e; }
+ catch (SQLException& e) { aErrorInfo = e; }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "FormComponentPropertyHandler::impl_dialogFilterOrSort_nothrow: caught an exception!" );
+ }
+
+ if ( aErrorInfo.isValid() )
+ impl_displaySQLError_nothrow( aErrorInfo );
+
+ return bSuccess;
+ }
+
+ //------------------------------------------------------------------------
+ bool FormComponentPropertyHandler::impl_dialogLinkedFormFields_nothrow( ::osl::ClearableMutexGuard& _rClearBeforeDialog ) const
+ {
+ Reference< XForm > xDetailForm( m_xComponent, UNO_QUERY );
+ Reference< XForm > xMasterForm( m_xObjectParent, UNO_QUERY );
+ uno::Reference<beans::XPropertySet> xMasterProp(m_xObjectParent,uno::UNO_QUERY);
+ OSL_PRECOND( xDetailForm.is() && xMasterForm.is(), "FormComponentPropertyHandler::impl_dialogLinkedFormFields_nothrow: no forms!" );
+ if ( !xDetailForm.is() || !xMasterForm.is() )
+ return false;
+
+
+ FormLinkDialog aDialog( impl_getDefaultDialogParent_nothrow(), m_xComponent, xMasterProp, m_aContext.getLegacyServiceFactory() );
+ _rClearBeforeDialog.clear();
+ return ( RET_OK == aDialog.Execute() );
+ }
+
+ //------------------------------------------------------------------------
+ bool FormComponentPropertyHandler::impl_dialogFormatting_nothrow( Any& _out_rNewValue, ::osl::ClearableMutexGuard& _rClearBeforeDialog ) const
+ {
+ bool bChanged = false;
+ try
+ {
+ // create the itemset for the dialog
+ SfxItemSet aCoreSet(SFX_APP()->GetPool(),
+ SID_ATTR_NUMBERFORMAT_VALUE, SID_ATTR_NUMBERFORMAT_VALUE,
+ SID_ATTR_NUMBERFORMAT_INFO, SID_ATTR_NUMBERFORMAT_INFO,
+ 0); // ripped this somewhere ... don't understand it :(
+
+ // get the number formats supplier
+ Reference< XNumberFormatsSupplier > xSupplier;
+ m_xComponent->getPropertyValue( PROPERTY_FORMATSSUPPLIER ) >>= xSupplier;
+
+ DBG_ASSERT(xSupplier.is(), "FormComponentPropertyHandler::impl_dialogFormatting_nothrow: invalid call !" );
+ Reference< XUnoTunnel > xTunnel( xSupplier, UNO_QUERY_THROW );
+ SvNumberFormatsSupplierObj* pSupplier =
+ reinterpret_cast< SvNumberFormatsSupplierObj* >( xTunnel->getSomething( SvNumberFormatsSupplierObj::getUnoTunnelId() ) );
+ DBG_ASSERT( pSupplier != NULL, "FormComponentPropertyHandler::impl_dialogFormatting_nothrow: invalid call !" );
+
+ sal_Int32 nFormatKey = 0;
+ impl_getPropertyValue_throw( PROPERTY_FORMATKEY ) >>= nFormatKey;
+ aCoreSet.Put( SfxUInt32Item( SID_ATTR_NUMBERFORMAT_VALUE, nFormatKey ) );
+
+ SvNumberFormatter* pFormatter = pSupplier->GetNumberFormatter();
+ double dPreviewVal = OFormatSampleControl::getPreviewValue(pFormatter,nFormatKey);
+ SvxNumberInfoItem aFormatter( pFormatter, dPreviewVal, String( PcrRes( RID_STR_TEXT_FORMAT ) ), SID_ATTR_NUMBERFORMAT_INFO );
+ aCoreSet.Put( aFormatter );
+
+ // a tab dialog with a single page
+ ::std::auto_ptr< SfxSingleTabDialog > pDialog( new SfxSingleTabDialog( impl_getDefaultDialogParent_nothrow(), aCoreSet, 0 ) );
+ SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
+ DBG_ASSERT( pFact, "CreateFactory fail!" );
+ ::CreateTabPage fnCreatePage = pFact->GetTabPageCreatorFunc( RID_SVXPAGE_NUMBERFORMAT );
+ if ( !fnCreatePage )
+ throw RuntimeException(); // caught below
+
+ SfxTabPage* pPage = (*fnCreatePage)( pDialog.get(), aCoreSet );
+ pDialog->SetTabPage( pPage );
+
+ _rClearBeforeDialog.clear();
+ if ( RET_OK == pDialog->Execute() )
+ {
+ const SfxItemSet* pResult = pDialog->GetOutputItemSet();
+
+ const SfxPoolItem* pItem = pResult->GetItem( SID_ATTR_NUMBERFORMAT_INFO );
+ const SvxNumberInfoItem* pInfoItem = dynamic_cast< const SvxNumberInfoItem* >( pItem );
+ if (pInfoItem && pInfoItem->GetDelCount())
+ {
+ const sal_uInt32* pDeletedKeys = pInfoItem->GetDelArray();
+
+ for (sal_uInt16 i=0; i< pInfoItem->GetDelCount(); ++i, ++pDeletedKeys)
+ pFormatter->DeleteEntry(*pDeletedKeys);
+ }
+
+ pItem = NULL;
+ if ( SFX_ITEM_SET == pResult->GetItemState( SID_ATTR_NUMBERFORMAT_VALUE, sal_False, &pItem ) )
+ {
+ _out_rNewValue <<= (sal_Int32)( static_cast< const SfxUInt32Item* >( pItem )->GetValue() );
+ bChanged = true;
+ }
+ }
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "FormComponentPropertyHandler::impl_dialogFormatting_nothrow: : caught an exception!" );
+ }
+ return bChanged;
+ }
+
+ //------------------------------------------------------------------------
+ bool FormComponentPropertyHandler::impl_browseForImage_nothrow( Any& _out_rNewValue, ::osl::ClearableMutexGuard& _rClearBeforeDialog ) const
+ {
+ bool bIsLink = true;// reflect the legacy behavior
+ ::rtl::OUString aStrTrans = m_pInfoService->getPropertyTranslation( PROPERTY_ID_IMAGE_URL );
+
+ ::sfx2::FileDialogHelper aFileDlg(SFXWB_GRAPHIC);
+
+ aFileDlg.SetTitle(aStrTrans);
+ // non-linked images ( e.g. those located in the document
+ // stream ) cannot *currently* be handled by openoffice basic dialogs.
+ bool bHandleNonLink = ( m_eComponentClass == eFormControl );
+
+ Reference< XFilePickerControlAccess > xController(aFileDlg.GetFilePicker(), UNO_QUERY);
+ DBG_ASSERT(xController.is(), "FormComponentPropertyHandler::impl_browseForImage_nothrow: missing the controller interface on the file picker!");
+ if (xController.is())
+ {
+ // do a preview by default
+ xController->setValue(ExtendedFilePickerElementIds::CHECKBOX_PREVIEW, 0, ::cppu::bool2any(sal_True));
+
+ xController->setValue(ExtendedFilePickerElementIds::CHECKBOX_LINK, 0, ::cppu::bool2any(bIsLink));
+ xController->enableControl(ExtendedFilePickerElementIds::CHECKBOX_LINK, bHandleNonLink );
+
+ }
+
+ ::rtl::OUString sCurValue;
+ OSL_VERIFY( impl_getPropertyValue_throw( PROPERTY_IMAGE_URL ) >>= sCurValue );
+ if ( sCurValue.getLength() != 0 && sCurValue.compareToAscii(GRAPHOBJ_URLPREFIX, RTL_CONSTASCII_LENGTH(GRAPHOBJ_URLPREFIX) ) != 0 )
+ {
+ aFileDlg.SetDisplayDirectory( sCurValue );
+ // TODO: need to set the display directory _and_ the default name
+ }
+
+ _rClearBeforeDialog.clear();
+ bool bSuccess = ( 0 == aFileDlg.Execute() );
+ if ( bSuccess )
+ {
+ if ( bHandleNonLink && xController.is() )
+ {
+ xController->getValue(ExtendedFilePickerElementIds::CHECKBOX_LINK, 0) >>= bIsLink;
+ }
+ if ( !bIsLink )
+ {
+ Graphic aGraphic;
+ aFileDlg.GetGraphic( aGraphic );
+
+ Reference< graphic::XGraphicObject > xGrfObj = graphic::GraphicObject::create( m_aContext.getUNOContext() );
+ xGrfObj->setGraphic( aGraphic.GetXGraphic() );
+
+
+ _out_rNewValue <<= xGrfObj;
+
+ }
+ else
+ _out_rNewValue <<= (::rtl::OUString)aFileDlg.GetPath();
+ }
+ return bSuccess;
+ }
+
+ //------------------------------------------------------------------------
+ bool FormComponentPropertyHandler::impl_browseForTargetURL_nothrow( Any& _out_rNewValue, ::osl::ClearableMutexGuard& _rClearBeforeDialog ) const
+ {
+ ::sfx2::FileDialogHelper aFileDlg( WB_3DLOOK );
+
+ ::rtl::OUString sURL;
+ OSL_VERIFY( impl_getPropertyValue_throw( PROPERTY_TARGET_URL ) >>= sURL );
+ INetURLObject aParser( sURL );
+ if ( INET_PROT_FILE == aParser.GetProtocol() )
+ // set the initial directory only for file-URLs. Everything else
+ // is considered to be potentially expensive
+ // 106126 - 2002/12/10 - fs@openoffice.org
+ aFileDlg.SetDisplayDirectory( sURL );
+
+ _rClearBeforeDialog.clear();
+ bool bSuccess = ( 0 == aFileDlg.Execute() );
+ if ( bSuccess )
+ _out_rNewValue <<= (::rtl::OUString)aFileDlg.GetPath();
+ return bSuccess;
+ }
+
+ //------------------------------------------------------------------------
+ bool FormComponentPropertyHandler::impl_executeFontDialog_nothrow( Any& _out_rNewValue, ::osl::ClearableMutexGuard& _rClearBeforeDialog ) const
+ {
+ bool bSuccess = false;
+
+ // create an item set for use with the dialog
+ SfxItemSet* pSet = NULL;
+ SfxItemPool* pPool = NULL;
+ SfxPoolItem** pDefaults = NULL;
+ ControlCharacterDialog::createItemSet(pSet, pPool, pDefaults);
+ ControlCharacterDialog::translatePropertiesToItems(m_xComponent, pSet);
+
+ { // do this in an own block. The dialog needs to be destroyed before we call
+ // destroyItemSet
+ ControlCharacterDialog aDlg( impl_getDefaultDialogParent_nothrow(), *pSet );
+ _rClearBeforeDialog.clear();
+ if ( RET_OK == aDlg.Execute() )
+ {
+ const SfxItemSet* pOut = aDlg.GetOutputItemSet();
+ if ( pOut )
+ {
+ Sequence< NamedValue > aFontPropertyValues;
+ ControlCharacterDialog::translateItemsToProperties( *pOut, aFontPropertyValues );
+ _out_rNewValue <<= aFontPropertyValues;
+ bSuccess = true;
+ }
+ }
+ }
+
+ ControlCharacterDialog::destroyItemSet(pSet, pPool, pDefaults);
+ return bSuccess;
+ }
+
+ //------------------------------------------------------------------------
+ bool FormComponentPropertyHandler::impl_browseForDatabaseDocument_throw( Any& _out_rNewValue, ::osl::ClearableMutexGuard& _rClearBeforeDialog ) const
+ {
+ ::sfx2::FileDialogHelper aFileDlg(WB_3DLOOK|WB_OPEN,::String::CreateFromAscii("sdatabase"));
+
+ ::rtl::OUString sDataSource;
+ OSL_VERIFY( impl_getPropertyValue_throw( PROPERTY_DATASOURCE ) >>= sDataSource );
+ INetURLObject aParser( sDataSource );
+ if ( INET_PROT_FILE == aParser.GetProtocol() )
+ // set the initial directory only for file-URLs. Everything else
+ // is considered to be potentially expensive
+ // 106126 - 2002/12/10 - fs@openoffice.org
+ aFileDlg.SetDisplayDirectory( sDataSource );
+
+ const String s_sDatabaseType = String::CreateFromAscii("StarOffice XML (Base)");
+ const SfxFilter* pFilter = SfxFilter::GetFilterByName( s_sDatabaseType);
+ OSL_ENSURE(pFilter,"Filter: StarOffice XML (Base) could not be found!");
+ if ( pFilter )
+ {
+ aFileDlg.SetCurrentFilter(pFilter->GetUIName());
+ //aFileDlg.AddFilter(pFilter->GetFilterName(),pFilter->GetDefaultExtension());
+ }
+
+ _rClearBeforeDialog.clear();
+ bool bSuccess = ( 0 == aFileDlg.Execute() );
+ if ( bSuccess )
+ _out_rNewValue <<= (::rtl::OUString)aFileDlg.GetPath();
+ return bSuccess;
+ }
+
+ //------------------------------------------------------------------------
+ bool FormComponentPropertyHandler::impl_dialogColorChooser_throw( sal_Int32 _nColorPropertyId, Any& _out_rNewValue, ::osl::ClearableMutexGuard& _rClearBeforeDialog ) const
+ {
+ sal_Int32 nColor = 0;
+ OSL_VERIFY( impl_getPropertyValue_throw( impl_getPropertyNameFromId_nothrow( _nColorPropertyId ) ) >>= nColor );
+ ::Color aColor( nColor );
+ SvColorDialog aColorDlg( impl_getDefaultDialogParent_nothrow() );
+ aColorDlg.SetColor( aColor );
+
+ _rClearBeforeDialog.clear();
+ if ( !aColorDlg.Execute() )
+ return false;
+
+ aColor = aColorDlg.GetColor();
+ nColor = aColor.GetColor();
+ _out_rNewValue <<= (sal_Int32)nColor;
+ return true;
+ }
+
+ //------------------------------------------------------------------------
+ bool FormComponentPropertyHandler::impl_dialogChooseLabelControl_nothrow( Any& _out_rNewValue, ::osl::ClearableMutexGuard& _rClearBeforeDialog ) const
+ {
+ OSelectLabelDialog dlgSelectLabel( impl_getDefaultDialogParent_nothrow(), m_xComponent );
+ _rClearBeforeDialog.clear();
+ bool bSuccess = ( RET_OK == dlgSelectLabel.Execute() );
+ if ( bSuccess )
+ _out_rNewValue <<= dlgSelectLabel.GetSelected();
+ return bSuccess;
+ }
+
+ //------------------------------------------------------------------------
+ Reference< XControlContainer > FormComponentPropertyHandler::impl_getContextControlContainer_nothrow() const
+ {
+ Reference< XControlContainer > xControlContext(
+ m_aContext.getContextValueByAsciiName( "ControlContext" ),
+ UNO_QUERY );
+ return xControlContext;
+ }
+
+ //------------------------------------------------------------------------
+ bool FormComponentPropertyHandler::impl_dialogChangeTabOrder_nothrow( ::osl::ClearableMutexGuard& _rClearBeforeDialog ) const
+ {
+ OSL_PRECOND( impl_getContextControlContainer_nothrow().is(), "FormComponentPropertyHandler::impl_dialogChangeTabOrder_nothrow: invalid control context!" );
+
+ Reference< XTabControllerModel > xTabControllerModel( impl_getRowSet_nothrow(), UNO_QUERY );
+ TabOrderDialog aDialog(
+ impl_getDefaultDialogParent_nothrow(),
+ xTabControllerModel,
+ impl_getContextControlContainer_nothrow(),
+ m_aContext.getLegacyServiceFactory()
+ );
+ _rClearBeforeDialog.clear();
+ return ( RET_OK == aDialog.Execute() );
+ }
+
+ //------------------------------------------------------------------------
+ namespace
+ {
+ //--------------------------------------------------------------------
+ //- ISQLCommandPropertyUI
+ //--------------------------------------------------------------------
+ class ISQLCommandPropertyUI : public ISQLCommandAdapter
+ {
+ public:
+ /** returns the empty-string-terminated list of names of properties
+ whose UI is to be disabled while the SQL command property is
+ being edited.
+ */
+ virtual ::rtl::OUString* getPropertiesToDisable() = 0;
+ };
+
+ //--------------------------------------------------------------------
+ //- SQLCommandPropertyUI
+ //--------------------------------------------------------------------
+ class SQLCommandPropertyUI : public ISQLCommandPropertyUI
+ {
+ protected:
+ SQLCommandPropertyUI( const Reference< XPropertySet >& _rxObject )
+ :m_xObject( _rxObject )
+ {
+ if ( !m_xObject.is() )
+ throw NullPointerException();
+ }
+
+ virtual oslInterlockedCount SAL_CALL acquire()
+ {
+ return osl_incrementInterlockedCount( &m_refCount );
+ }
+
+ virtual oslInterlockedCount SAL_CALL release()
+ {
+ if ( 0 == osl_decrementInterlockedCount( &m_refCount ) )
+ {
+ delete this;
+ return 0;
+ }
+ return m_refCount;
+ }
+
+ protected:
+ Reference< XPropertySet > m_xObject;
+
+ private:
+ oslInterlockedCount m_refCount;
+ };
+
+ //--------------------------------------------------------------------
+ //- FormSQLCommandUI - declaration
+ //--------------------------------------------------------------------
+ class FormSQLCommandUI : public SQLCommandPropertyUI
+ {
+ public:
+ FormSQLCommandUI( const Reference< XPropertySet >& _rxForm );
+
+ // ISQLCommandAdapter
+ virtual ::rtl::OUString getSQLCommand() const;
+ virtual sal_Bool getEscapeProcessing() const;
+ virtual void setSQLCommand( const ::rtl::OUString& _rCommand ) const;
+ virtual void setEscapeProcessing( const sal_Bool _bEscapeProcessing ) const;
+
+ // ISQLCommandPropertyUI
+ virtual ::rtl::OUString* getPropertiesToDisable();
+ };
+
+ //--------------------------------------------------------------------
+ //- FormSQLCommandUI - implementation
+ //--------------------------------------------------------------------
+ //....................................................................
+ FormSQLCommandUI::FormSQLCommandUI( const Reference< XPropertySet >& _rxForm )
+ :SQLCommandPropertyUI( _rxForm )
+ {
+ }
+
+ //....................................................................
+ ::rtl::OUString FormSQLCommandUI::getSQLCommand() const
+ {
+ ::rtl::OUString sCommand;
+ OSL_VERIFY( m_xObject->getPropertyValue( PROPERTY_COMMAND ) >>= sCommand );
+ return sCommand;
+ }
+
+ //....................................................................
+ sal_Bool FormSQLCommandUI::getEscapeProcessing() const
+ {
+ sal_Bool bEscapeProcessing( sal_False );
+ OSL_VERIFY( m_xObject->getPropertyValue( PROPERTY_ESCAPE_PROCESSING ) >>= bEscapeProcessing );
+ return bEscapeProcessing;
+ }
+
+ //....................................................................
+ void FormSQLCommandUI::setSQLCommand( const ::rtl::OUString& _rCommand ) const
+ {
+ m_xObject->setPropertyValue( PROPERTY_COMMAND, makeAny( _rCommand ) );
+ }
+
+ //....................................................................
+ void FormSQLCommandUI::setEscapeProcessing( const sal_Bool _bEscapeProcessing ) const
+ {
+ m_xObject->setPropertyValue( PROPERTY_ESCAPE_PROCESSING, makeAny( _bEscapeProcessing ) );
+ }
+
+ //....................................................................
+ ::rtl::OUString* FormSQLCommandUI::getPropertiesToDisable()
+ {
+ static ::rtl::OUString s_aCommandProps[] = {
+ PROPERTY_DATASOURCE,
+ PROPERTY_COMMAND,
+ PROPERTY_COMMANDTYPE,
+ PROPERTY_ESCAPE_PROCESSING,
+ ::rtl::OUString()
+ };
+ return s_aCommandProps;
+ }
+ //--------------------------------------------------------------------
+ //- ValueListCommandUI - declaration
+ //--------------------------------------------------------------------
+ class ValueListCommandUI : public SQLCommandPropertyUI
+ {
+ public:
+ ValueListCommandUI( const Reference< XPropertySet >& _rxListOrCombo );
+
+ // ISQLCommandAdapter
+ virtual ::rtl::OUString getSQLCommand() const;
+ virtual sal_Bool getEscapeProcessing() const;
+ virtual void setSQLCommand( const ::rtl::OUString& _rCommand ) const;
+ virtual void setEscapeProcessing( const sal_Bool _bEscapeProcessing ) const;
+
+ // ISQLCommandPropertyUI
+ virtual ::rtl::OUString* getPropertiesToDisable();
+ private:
+ mutable bool m_bPropertyValueIsList;
+ };
+
+ //--------------------------------------------------------------------
+ //- ValueListCommandUI - implementation
+ //--------------------------------------------------------------------
+ //....................................................................
+ ValueListCommandUI::ValueListCommandUI( const Reference< XPropertySet >& _rxListOrCombo )
+ :SQLCommandPropertyUI( _rxListOrCombo )
+ ,m_bPropertyValueIsList( false )
+ {
+ }
+
+ //....................................................................
+ ::rtl::OUString ValueListCommandUI::getSQLCommand() const
+ {
+ ::rtl::OUString sValue;
+ m_bPropertyValueIsList = false;
+
+ // for combo boxes, the property is a mere string
+ Any aValue( m_xObject->getPropertyValue( PROPERTY_LISTSOURCE ) );
+ if ( aValue >>= sValue )
+ return sValue;
+
+ Sequence< ::rtl::OUString > aValueList;
+ if ( aValue >>= aValueList )
+ {
+ m_bPropertyValueIsList = true;
+ if ( aValueList.getLength() )
+ sValue = aValueList[0];
+ return sValue;
+ }
+
+ OSL_ENSURE( false, "ValueListCommandUI::getSQLCommand: unexpected property type!" );
+ return sValue;
+ }
+
+ //....................................................................
+ sal_Bool ValueListCommandUI::getEscapeProcessing() const
+ {
+ enum ListSourceType eType( ListSourceType_SQL );
+ OSL_VERIFY( m_xObject->getPropertyValue( PROPERTY_LISTSOURCETYPE ) >>= eType );
+ OSL_ENSURE( ( eType == ListSourceType_SQL ) || ( eType == ListSourceType_SQLPASSTHROUGH ),
+ "ValueListCommandUI::getEscapeProcessing: unexpected list source type!" );
+ return ( eType == ListSourceType_SQL );
+ }
+
+ //....................................................................
+ void ValueListCommandUI::setSQLCommand( const ::rtl::OUString& _rCommand ) const
+ {
+ Any aValue;
+ if ( m_bPropertyValueIsList )
+ aValue <<= Sequence< ::rtl::OUString >( &_rCommand, 1 );
+ else
+ aValue <<= _rCommand;
+ m_xObject->setPropertyValue( PROPERTY_LISTSOURCE, aValue );
+ }
+
+ //....................................................................
+ void ValueListCommandUI::setEscapeProcessing( const sal_Bool _bEscapeProcessing ) const
+ {
+ m_xObject->setPropertyValue( PROPERTY_LISTSOURCETYPE, makeAny(
+ _bEscapeProcessing ? ListSourceType_SQL : ListSourceType_SQLPASSTHROUGH ) );
+ }
+
+ //....................................................................
+ ::rtl::OUString* ValueListCommandUI::getPropertiesToDisable()
+ {
+ static ::rtl::OUString s_aListSourceProps[] = {
+ PROPERTY_LISTSOURCETYPE,
+ PROPERTY_LISTSOURCE,
+ ::rtl::OUString()
+ };
+ return s_aListSourceProps;
+ }
+ }
+
+ //------------------------------------------------------------------------
+ bool FormComponentPropertyHandler::impl_doDesignSQLCommand_nothrow( const Reference< XObjectInspectorUI >& _rxInspectorUI, PropertyId _nDesignForProperty )
+ {
+ try
+ {
+ if ( m_xCommandDesigner.is() )
+ {
+ if ( m_xCommandDesigner->isActive() )
+ {
+ m_xCommandDesigner->raise();
+ return true;
+ }
+ m_xCommandDesigner->dispose();
+ m_xCommandDesigner.set( NULL );
+ }
+
+ if ( !impl_ensureRowsetConnection_nothrow() )
+ return false;
+
+ Reference< XPropertySet > xComponentProperties( m_xComponent, UNO_QUERY_THROW );
+
+ ::rtl::Reference< ISQLCommandPropertyUI > xCommandUI;
+ switch ( _nDesignForProperty )
+ {
+ case PROPERTY_ID_COMMAND:
+ xCommandUI = new FormSQLCommandUI( xComponentProperties );
+ break;
+ case PROPERTY_ID_LISTSOURCE:
+ xCommandUI = new ValueListCommandUI( xComponentProperties );
+ break;
+ default:
+ OSL_ENSURE( false, "FormComponentPropertyHandler::OnDesignerClosed: invalid property id!" );
+ return false;
+ }
+
+ m_xCommandDesigner.set( new SQLCommandDesigner( m_aContext.getUNOContext(), xCommandUI.get(), m_xRowSetConnection, LINK( this, FormComponentPropertyHandler, OnDesignerClosed ) ) );
+
+ DBG_ASSERT( _rxInspectorUI.is(), "FormComponentPropertyHandler::OnDesignerClosed: no access to the property browser ui!" );
+ if ( m_xCommandDesigner->isActive() && _rxInspectorUI.is() )
+ {
+ m_xBrowserUI = _rxInspectorUI;
+ // disable everything which would affect this property
+ const ::rtl::OUString* pToDisable = xCommandUI->getPropertiesToDisable();
+ while ( pToDisable->getLength() )
+ {
+ m_xBrowserUI->enablePropertyUIElements( *pToDisable++, PropertyLineElement::All, sal_False );
+ }
+
+ // but enable the browse button for the property itself - so it can be used to raise the query designer
+ ::rtl::OUString sPropertyName( impl_getPropertyNameFromId_nothrow( _nDesignForProperty ) );
+ m_xBrowserUI->enablePropertyUIElements( sPropertyName, PropertyLineElement::PrimaryButton, sal_True );
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ return m_xCommandDesigner.is();
+ }
+
+ //------------------------------------------------------------------------
+ IMPL_LINK( FormComponentPropertyHandler, OnDesignerClosed, void*, /*NOTINTERESTEDIN*/ )
+ {
+ OSL_ENSURE( m_xBrowserUI.is() && m_xCommandDesigner.is(), "FormComponentPropertyHandler::OnDesignerClosed: too many NULLs!" );
+ if ( m_xBrowserUI.is() && m_xCommandDesigner.is() )
+ {
+ try
+ {
+ ::rtl::Reference< ISQLCommandPropertyUI > xCommandUI(
+ dynamic_cast< ISQLCommandPropertyUI* >( m_xCommandDesigner->getPropertyAdapter().get() ) );
+ if ( !xCommandUI.is() )
+ throw NullPointerException();
+
+ const ::rtl::OUString* pToEnable = xCommandUI->getPropertiesToDisable();
+ while ( pToEnable->getLength() )
+ {
+ m_xBrowserUI->enablePropertyUIElements( *pToEnable++, PropertyLineElement::All, sal_True );
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+
+ return 0L;
+ }
+
+ //------------------------------------------------------------------------
+ bool FormComponentPropertyHandler::impl_hasValidDataSourceSignature_nothrow( const Reference< XPropertySet >& _xFormProperties, bool _bAllowEmptyDataSourceName ) SAL_THROW(())
+ {
+ bool bHas = false;
+ if ( _xFormProperties.is() )
+ {
+ try
+ {
+ ::rtl::OUString sPropertyValue;
+ // first, we need the name of an existent data source
+ if ( _xFormProperties->getPropertySetInfo()->hasPropertyByName(PROPERTY_DATASOURCE) )
+ _xFormProperties->getPropertyValue( PROPERTY_DATASOURCE ) >>= sPropertyValue;
+ bHas = ( sPropertyValue.getLength() != 0 ) || _bAllowEmptyDataSourceName;
+
+ // then, the command should not be empty
+ if ( bHas )
+ {
+ if ( _xFormProperties->getPropertySetInfo()->hasPropertyByName(PROPERTY_COMMAND) )
+ _xFormProperties->getPropertyValue( PROPERTY_COMMAND ) >>= sPropertyValue;
+ bHas = ( sPropertyValue.getLength() != 0 );
+ }
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( false, "FormComponentPropertyHandler::impl_hasValidDataSourceSignature_nothrow: caught an exception!" );
+ }
+ }
+ return bHas;
+ }
+ //------------------------------------------------------------------------
+ ::rtl::OUString FormComponentPropertyHandler::impl_getDocumentURL_nothrow() const
+ {
+ ::rtl::OUString sURL;
+ try
+ {
+ Reference< XModel > xDocument( impl_getContextDocument_nothrow() );
+ if ( xDocument.is() )
+ sURL = xDocument->getURL();
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ return sURL;
+ }
+ // -------------------------------------------------------------------------
+ ::cppu::IPropertyArrayHelper* FormComponentPropertyHandler::createArrayHelper( ) const
+ {
+ uno::Sequence< beans::Property > aProps;
+ describeProperties(aProps);
+ return new ::cppu::OPropertyArrayHelper(aProps);
+
+ }
+ // -------------------------------------------------------------------------
+ ::cppu::IPropertyArrayHelper & FormComponentPropertyHandler::getInfoHelper()
+ {
+ return *const_cast<FormComponentPropertyHandler*>(this)->getArrayHelper();
+ }
+ // -----------------------------------------------------------------------------
+ uno::Reference< beans::XPropertySetInfo > SAL_CALL FormComponentPropertyHandler::getPropertySetInfo( ) throw(uno::RuntimeException)
+ {
+ return ::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper());
+ }
+
+//........................................................................
+} // namespace pcr
+//........................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/propctrlr/formcomponenthandler.hxx b/extensions/source/propctrlr/formcomponenthandler.hxx
new file mode 100644
index 000000000000..81f72606f1cc
--- /dev/null
+++ b/extensions/source/propctrlr/formcomponenthandler.hxx
@@ -0,0 +1,481 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef EXTENSIONS_SOURCE_PROPCTRLR_FORMCOMPONENTHANDLER_HXX
+#define EXTENSIONS_SOURCE_PROPCTRLR_FORMCOMPONENTHANDLER_HXX
+
+#include "propertyhandler.hxx"
+#include "sqlcommanddesign.hxx"
+#include "pcrcommon.hxx"
+#include <comphelper/uno3.hxx>
+#include <comphelper/proparrhlp.hxx>
+#include <comphelper/propertycontainer.hxx>
+/** === begin UNO includes === **/
+#include <com/sun/star/frame/XModel.hpp>
+#include <com/sun/star/beans/XPropertyState.hpp>
+#include <com/sun/star/sdbc/XRowSet.hpp>
+#include <com/sun/star/awt/XControlContainer.hpp>
+#include <com/sun/star/form/XForm.hpp>
+/** === end UNO includes === **/
+#include <vcl/fldunit.hxx>
+#include <vcl/waitobj.hxx>
+#include <connectivity/dbtools.hxx>
+
+#include <set>
+
+//........................................................................
+namespace pcr
+{
+//........................................................................
+
+ //====================================================================
+ //= ComponentClassification
+ //====================================================================
+ enum ComponentClassification
+ {
+ eFormControl,
+ eDialogControl,
+ eUnknown
+ };
+
+ //====================================================================
+ //= FormComponentPropertyHandler
+ //====================================================================
+ class FormComponentPropertyHandler;
+ typedef HandlerComponentBase< FormComponentPropertyHandler > FormComponentPropertyHandler_Base;
+ typedef ::comphelper::OPropertyArrayUsageHelper<FormComponentPropertyHandler> FormComponentPropertyHandler_PROP;
+ /** default ->XPropertyHandler for all form components.
+ */
+ class FormComponentPropertyHandler : public FormComponentPropertyHandler_Base,
+ public ::comphelper::OPropertyContainer,
+ public FormComponentPropertyHandler_PROP
+ {
+ private:
+ /// access to property states
+ ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyState > m_xPropertyState;
+ /// the parent of our component
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > m_xObjectParent;
+
+ /// the database connection. Owned by us if and only if we created it ourself.
+ mutable ::dbtools::SharedConnection m_xRowSetConnection;
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRowSet > m_xRowSet;
+ /** helper component encapsulating the handling for the QueryDesign component for
+ interactively designing an SQL command
+ */
+ ::rtl::Reference< SQLCommandDesigner > m_xCommandDesigner;
+ ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XObjectInspectorUI > m_xBrowserUI;
+
+ /// the string indicating a "default" (VOID) value in list-like controls
+ ::rtl::OUString m_sDefaultValueString;
+ /// all properties to whose control's we added ->m_sDefaultValueString
+ ::std::set< ::rtl::OUString > m_aPropertiesWithDefListEntry;
+ /// type of our component
+ ComponentClassification m_eComponentClass;
+ /// is our component a (database) sub form?
+ bool m_bComponentIsSubForm : 1;
+ /// our component has a "ListSource" property
+ bool m_bHaveListSource : 1;
+ /// our component has a "Command" property
+ bool m_bHaveCommand : 1;
+ /// the class id of the component - if appliable
+ sal_Int16 m_nClassId;
+
+ public:
+ FormComponentPropertyHandler(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _rxContext
+ );
+
+ DECLARE_XINTERFACE( )
+
+ // XPropertySet
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException);
+
+ static ::rtl::OUString SAL_CALL getImplementationName_static( ) throw (::com::sun::star::uno::RuntimeException);
+ static ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames_static( ) throw (::com::sun::star::uno::RuntimeException);
+
+ protected:
+ ~FormComponentPropertyHandler();
+
+ protected:
+ virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const;
+ virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper();
+ // XPropertyHandler overridables
+ virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue( const ::rtl::OUString& _rPropertyName ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setPropertyValue( const ::rtl::OUString& _rPropertyName, const ::com::sun::star::uno::Any& _rValue ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Any SAL_CALL convertToPropertyValue( const ::rtl::OUString& _rPropertyName, const ::com::sun::star::uno::Any& _rControlValue ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Any SAL_CALL convertToControlValue( const ::rtl::OUString& _rPropertyName, const ::com::sun::star::uno::Any& _rPropertyValue, const ::com::sun::star::uno::Type& _rControlValueType ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::beans::PropertyState SAL_CALL getPropertyState( const ::rtl::OUString& _rPropertyName ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL addPropertyChangeListener( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& _rxListener ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL removePropertyChangeListener( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& _rxListener ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupersededProperties() throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getActuatingProperties() throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::inspection::LineDescriptor SAL_CALL describePropertyLine( const ::rtl::OUString& _rPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyControlFactory >& _rxControlFactory ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::NullPointerException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::inspection::InteractiveSelectionResult
+ SAL_CALL onInteractivePropertySelection( const ::rtl::OUString& _rPropertyName, sal_Bool _bPrimary, ::com::sun::star::uno::Any& _rData, const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XObjectInspectorUI >& _rxInspectorUI ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::NullPointerException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL actuatingPropertyChanged( const ::rtl::OUString& _rActuatingPropertyName, const ::com::sun::star::uno::Any& _rNewValue, const ::com::sun::star::uno::Any& _rOldValue, const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XObjectInspectorUI >& _rxInspectorUI, sal_Bool _bFirstTimeInit ) throw (::com::sun::star::lang::NullPointerException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL suspend( sal_Bool _bSuspend ) throw (::com::sun::star::uno::RuntimeException);
+
+ // XComponent
+ virtual void SAL_CALL disposing();
+
+ // PropertyHandler
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property >
+ SAL_CALL doDescribeSupportedProperties() const;
+ virtual void onNewComponent();
+
+ private:
+ /** initializes some (cached) meta data about the component
+ @throws RuntimeException
+ if a serious error occurs, for instance if the component does not provide an XPropertySetInfo instance
+ */
+ void impl_initComponentMetaData_throw();
+
+ /** classifies our component, in case it's a control model, by ClassId
+
+ Note that UNO dialog controls are also classified, though they don't have the ClassId property
+ */
+ void impl_classifyControlModel_throw();
+
+ /** const-version of ->getPropertyValue
+ */
+ ::com::sun::star::uno::Any impl_getPropertyValue_throw( const ::rtl::OUString& _rPropertyName ) const;
+
+ // some property values are faked, and not used in the way they're provided by our component
+ void impl_normalizePropertyValue_nothrow( ::com::sun::star::uno::Any& _rValue, PropertyId _nPropId ) const;
+
+ /** determines whether we should exclude a given property from our "supported properties"
+ */
+ bool impl_shouldExcludeProperty_nothrow( const ::com::sun::star::beans::Property& _rProperty ) const;
+
+ /** initializes the list of field names, if we're handling a control which supports the
+ DataField property
+ */
+ void impl_initFieldList_nothrow( ::std::vector< ::rtl::OUString >& rFieldNames ) const;
+
+ /** obtaines the RowSet to which our component belongs
+
+ If the component is a RowSet itself, it's returned directly. Else, the parent
+ is examined for the XRowSet interface. If the parent is no XRowSet, then
+ a check is made whether our component is a grid control column, and if so,
+ the parent of the grid control is examied for the XRowSet interace.
+
+ Normally, at least one of those methods should succeed.
+ */
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRowSet > impl_getRowSet_throw( ) const;
+
+ /** nothrow-version of ->impl_getRowSet_throw
+ */
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRowSet > impl_getRowSet_nothrow( ) const;
+
+ /** connects the row set belonging to our introspected data aware form component,
+ and remembers the connection in ->m_xRowSetConnection.
+
+ If the row set already is connected, ->m_xRowSetConnection will be set, too, but
+ not take the ownership of the connection.
+
+ If ->m_xRowSetConnection is already set, nothing happens, so if you want to
+ force creation of a connection, you need to clear ->m_xRowSetConnection.
+ */
+ bool impl_ensureRowsetConnection_nothrow() const;
+
+ /** clears ->m_xRowSetConnection
+ */
+ void impl_clearRowsetConnection_nothrow();
+
+ /** fills an ->LineDescriptor with information to represent a cursor source
+ of our form - that is, a table, a query, or an SQL statement.
+
+ As an example, if our form has currently a CommandType of TABLE, then the
+ value list in the LineDescriptor will contain a list of all tables
+ of the data source which the form is bound to.
+
+ @seealso impl_fillTableNames_throw
+ @seealso impl_fillQueryNames_throw
+ */
+ void impl_describeCursorSource_nothrow(
+ ::com::sun::star::inspection::LineDescriptor& _out_rProperty,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyControlFactory >& _rxControlFactory
+ ) const;
+
+ /** describes the UI for selecting a table name
+
+ @precond
+ m_xRowSetConnection is not <NULL/>
+ */
+ void impl_fillTableNames_throw( ::std::vector< ::rtl::OUString >& _out_rNames ) const;
+
+ /** describes the UI for selecting a query name
+
+ @precond
+ m_xRowSetConnection is not <NULL/>
+ */
+ void impl_fillQueryNames_throw( ::std::vector< ::rtl::OUString >& _out_rNames ) const;
+
+ /** describes the UI for selecting a query name
+
+ @precond
+ m_xRowSetConnection is not <NULL/>
+ */
+ void impl_fillQueryNames_throw( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& _xQueryNames
+ ,::std::vector< ::rtl::OUString >& _out_rNames
+ ,const ::rtl::OUString& _sName = ::rtl::OUString() ) const;
+
+ /** describes the UI for selecting a ListSource (for list-like form controls)
+ @precond
+ ->m_xRowSetConnection is not <NULL/>
+ @precond
+ ->m_xComponent is not <NULL/>
+ */
+ void impl_describeListSourceUI_throw(
+ ::com::sun::star::inspection::LineDescriptor& _out_rDescriptor,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyControlFactory >& _rxControlFactory
+ ) const;
+
+ /** displays a datbase-related error to the user
+ */
+ void impl_displaySQLError_nothrow( const ::dbtools::SQLExceptionInfo& _rErrorDescriptor ) const;
+
+ /** let's the user chose a selection of entries from a string list, and stores this
+ selection in the given property
+ @return
+ <TRUE/> if and only if the user successfully changed the property
+ */
+ bool impl_dialogListSelection_nothrow( const ::rtl::OUString& _rProperty, ::osl::ClearableMutexGuard& _rClearBeforeDialog ) const;
+
+ /** executes a dialog for chosing a filter or sort criterion for a database form
+ @param _bFilter
+ <TRUE/> if the Filter property should be used, <FALSE/> if it's the Order
+ property
+ @param _out_rSelectedClause
+ the filter or order clause as chosen by the user
+ @precond
+ we're really inspecting a database form (well, a RowSet at least)
+ @return
+ <TRUE/> if and only if the user successfully chose a clause
+ */
+ bool impl_dialogFilterOrSort_nothrow( bool _bFilter, ::rtl::OUString& _out_rSelectedClause, ::osl::ClearableMutexGuard& _rClearBeforeDialog ) const;
+
+ /** executes a dialog which allows the user to chose the columns linking
+ a sub to a master form, and sets the respective MasterFields / SlaveFields
+ properties at the form.
+ @precond
+ we're inspecting (sub) database form
+ @return
+ <TRUE/> if and only if the user successfully eneter master and slave fields
+ */
+ bool impl_dialogLinkedFormFields_nothrow( ::osl::ClearableMutexGuard& _rClearBeforeDialog ) const;
+
+ /** executes a dialog which allows the user to modify the FormatKey
+ property of our component, by chosing a (number) format.
+ @precond
+ Our component actually has a FormatKey property.
+ @param _out_rNewValue
+ the new property value, if the user chose a new formatting
+ @return
+ <TRUE/> if and only if a new formatting has been chosen by the user.
+ In this case, ->_out_rNewValue is filled with the new property value
+ */
+ bool impl_dialogFormatting_nothrow( ::com::sun::star::uno::Any& _out_rNewValue, ::osl::ClearableMutexGuard& _rClearBeforeDialog ) const;
+
+ /** executes a dialog which allows to the user to change the ImageURL property
+ of our component by browsing for an image file.
+ @precond
+ our component actually has a ImageURL property
+ @param _out_rNewValue
+ the new property value, if the user chose a new image url
+ @return
+ <TRUE/> if and only if a new image URL has been chosen by the user.
+ In this case, ->_out_rNewValue is filled with the new property value
+ */
+ bool impl_browseForImage_nothrow( ::com::sun::star::uno::Any& _out_rNewValue, ::osl::ClearableMutexGuard& _rClearBeforeDialog ) const;
+
+ /** executes a dialog which allows the user to change the TargetURL property of
+ our component
+ @precond
+ our component actually has a TargetURL property
+ @param _out_rNewValue
+ the new property value, if the user chose a new TargetURL
+ @return
+ <TRUE/> if and only if a new TargetURL has been chosen by the user.
+ In this case, ->_out_rNewValue is filled with the new property value
+ */
+ bool impl_browseForTargetURL_nothrow( ::com::sun::star::uno::Any& _out_rNewValue, ::osl::ClearableMutexGuard& _rClearBeforeDialog ) const;
+
+ /** executes a dialog which allows the user to change the font, plus related properties,
+ of our component
+ @precond
+ our component actually has a Font property
+ @param _out_rNewValue
+ a value desribing the new font, as <code>Sequence&lt; NamedValue &gt;</code>
+ @return
+ <TRUE/> if and only if the user successfully changed the font of our component
+ */
+ bool impl_executeFontDialog_nothrow( ::com::sun::star::uno::Any& _out_rNewValue, ::osl::ClearableMutexGuard& _rClearBeforeDialog ) const;
+
+ /** allows the user browsing for a database document
+ @precond
+ our component actually has a DataSource property
+ @param _out_rNewValue
+ the new property value, if the user chose a new DataSource
+ @return
+ <TRUE/> if and only if a new DataSource has been chosen by the user.
+ In this case, ->_out_rNewValue is filled with the new property value
+ */
+ bool impl_browseForDatabaseDocument_throw( ::com::sun::star::uno::Any& _out_rNewValue, ::osl::ClearableMutexGuard& _rClearBeforeDialog ) const;
+
+ /** raises a dialog which allows the user to choose a color
+ @param _nColorPropertyId
+ the ID of the color property
+ @param _out_rNewValue
+ the chosen color value
+ @return
+ <TRUE/> if and only if a color was chosen by the user
+ */
+ bool impl_dialogColorChooser_throw( sal_Int32 _nColorPropertyId, ::com::sun::star::uno::Any& _out_rNewValue, ::osl::ClearableMutexGuard& _rClearBeforeDialog ) const;
+
+ /** raises a dialog which allows the user to choose a label control for our component
+ @param _out_rNewValue
+ the chosen label control, if any
+ @return
+ <TRUE/> if and only if a label control was chosen by the user
+ */
+ bool impl_dialogChooseLabelControl_nothrow( ::com::sun::star::uno::Any& _out_rNewValue, ::osl::ClearableMutexGuard& _rClearBeforeDialog ) const;
+
+ /** raises a dialog which lets the user chose the tab order of controls of a form
+ @precond
+ we have a view control container in which our controls live
+ @return
+ <TRUE/> if and only if the user successfully changed the tab order
+ @seealso impl_getContextControlContainer_nothrow
+ */
+ bool impl_dialogChangeTabOrder_nothrow( ::osl::ClearableMutexGuard& _rClearBeforeDialog ) const;
+
+ /** retrieves the context for controls, whose model(s) we're inspecting
+
+ If we're inspecting a control model, this is usually part of a set of controls
+ and control models, where the controls live in a certain context (a ->XControlContainer).
+ If we know this context, we can enable additional special functionality.
+
+ The ->XComponentContext in which we were created is examined for a value
+ named "ControlContext", and this value is returned.
+ */
+ ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlContainer >
+ impl_getContextControlContainer_nothrow() const;
+
+ /** opens a query design window for interactively designing the SQL command of a
+ database form
+ @param _rxUIUpdate
+ access to the property browser UI
+ @param _nDesignForProperty
+ the ID for the property for which the designer is opened
+ @return
+ <TRUE/> if the window was successfully opened, or was previously open,
+ <FALSE/> otherwise
+ */
+ bool impl_doDesignSQLCommand_nothrow(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XObjectInspectorUI >& _rxInspectorUI,
+ PropertyId _nDesignForProperty
+ );
+
+ /** updates a property (UI) whose state depends on more than one other property
+
+ ->actuatingPropertyChanged is called for certain properties in whose changes
+ we expressed interes (->getActuatingProperty). Now such a property change can
+ result in simple UI updates, for instance another property being enabled or disabled.
+
+ However, it can also result in a more complex change: The current (UI) state might
+ depend on the value of more than one other property. Those dependent properties (their
+ UI, more precisly) are updated in this method.
+
+ @param _nPropid
+ the ->PropertyId of the dependent property whose UI state is to be updated
+
+ @param _rxInspectorUI
+ provides access to the property browser UI. Must not be <NULL/>.
+ */
+ void impl_updateDependentProperty_nothrow( PropertyId _nPropId, const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XObjectInspectorUI >& _rxInspectorUI ) const;
+
+ /** determines whether the given form has a valid data source signature.
+
+ Valid here means that the DataSource property denotes an existing data source, and the
+ Command property is not empty. No check is made whether the value of the Command property
+ denotes an existent object, since this would be way too expensive.
+
+ @param _xFormProperties
+ the form to check. Must not be <NULL/>.
+ @param _bAllowEmptyDataSourceName
+ determine whether an empty data source name is allowed (<TRUE/>), and should not
+ lead to rejection
+ */
+ static bool impl_hasValidDataSourceSignature_nothrow(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _xFormProperties,
+ bool _bAllowEmptyDataSourceName );
+
+ /** returns the URL of our context document
+ @return
+ */
+ ::rtl::OUString impl_getDocumentURL_nothrow() const;
+
+ private:
+ DECL_LINK( OnDesignerClosed, void* );
+
+ private:
+ FormComponentPropertyHandler(); // never implemented
+ FormComponentPropertyHandler( const FormComponentPropertyHandler& ); // never implemented
+ FormComponentPropertyHandler& operator=( const FormComponentPropertyHandler& ); // never implemented
+
+ private:
+ using ::comphelper::OPropertyContainer::addPropertyChangeListener;
+ using ::comphelper::OPropertyContainer::removePropertyChangeListener;
+ };
+
+ //====================================================================
+ //= WaitCursor
+ //====================================================================
+ /** wrapper around a ->WaitObject which can cope with a NULL window
+ */
+ class WaitCursor
+ {
+ private:
+ ::std::auto_ptr< WaitObject > m_aWaitObject;
+
+ public:
+ WaitCursor( Window* _pWindow )
+ {
+ if ( _pWindow )
+ m_aWaitObject.reset( new WaitObject( _pWindow ) );
+ }
+ };
+
+//........................................................................
+} // namespace pcr
+//........................................................................
+
+#endif // EXTENSIONS_SOURCE_PROPCTRLR_FORMCOMPONENTHANDLER_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/propctrlr/formcontroller.cxx b/extensions/source/propctrlr/formcontroller.cxx
new file mode 100644
index 000000000000..e2c5b7cdc7b6
--- /dev/null
+++ b/extensions/source/propctrlr/formcontroller.cxx
@@ -0,0 +1,300 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+#include "formcontroller.hxx"
+#include "pcrcommon.hxx"
+#include "formstrings.hxx"
+#include "defaultforminspection.hxx"
+#include "propctrlr.hrc"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+#include <com/sun/star/form/XGridColumnFactory.hpp>
+#include <com/sun/star/form/XForm.hpp>
+#include <com/sun/star/container/XChild.hpp>
+/** === end UNO includes === **/
+#include <cppuhelper/typeprovider.hxx>
+#include <toolkit/helper/vclunohelper.hxx>
+
+//------------------------------------------------------------------------
+extern "C" void SAL_CALL createRegistryInfo_FormController()
+{
+ ::pcr::OAutoRegistration< ::pcr::FormController > aFormControllerRegistration;
+ ::pcr::OAutoRegistration< ::pcr::DialogController > aDialogControllerRegistration;
+}
+
+//........................................................................
+namespace pcr
+{
+//........................................................................
+
+ /** === begin UNO using === **/
+ using ::com::sun::star::uno::Reference;
+ using ::com::sun::star::uno::TypeClass_INTERFACE;
+ using ::com::sun::star::uno::TypeClass_STRING;
+ using ::com::sun::star::uno::XComponentContext;
+ using ::com::sun::star::inspection::XObjectInspectorModel;
+ using ::com::sun::star::uno::RuntimeException;
+ using ::com::sun::star::uno::UNO_QUERY_THROW;
+ using ::com::sun::star::uno::Sequence;
+ using ::com::sun::star::uno::XInterface;
+ using ::com::sun::star::beans::XPropertySetInfo;
+ using ::com::sun::star::beans::XPropertySet;
+ using ::com::sun::star::beans::Property;
+ using ::com::sun::star::uno::Any;
+ using ::com::sun::star::lang::IllegalArgumentException;
+ using ::com::sun::star::uno::Exception;
+ using ::com::sun::star::uno::Type;
+ using ::com::sun::star::util::VetoException;
+ using ::com::sun::star::beans::PropertyVetoException;
+ using ::com::sun::star::uno::UNO_QUERY;
+ using ::com::sun::star::form::XGridColumnFactory;
+ using ::com::sun::star::form::XForm;
+ using ::com::sun::star::container::XChild;
+ using ::com::sun::star::frame::XFrame;
+ using ::com::sun::star::awt::XWindow;
+ /** === end UNO using === **/
+
+ namespace PropertyAttribute = ::com::sun::star::beans::PropertyAttribute;
+
+ //====================================================================
+ //= FormController
+ //====================================================================
+ //--------------------------------------------------------------------
+ FormController::FormController( const Reference< XComponentContext >& _rxContext, ServiceDescriptor _aServiceDescriptor,
+ bool _bUseFormFormComponentHandlers )
+ :OPropertyBrowserController( _rxContext )
+ ,FormController_PropertyBase1( m_aBHelper )
+ ,m_aServiceDescriptor( _aServiceDescriptor )
+ {
+ osl_incrementInterlockedCount( &m_refCount );
+ {
+ Reference< XObjectInspectorModel > xModel(
+ *(new DefaultFormComponentInspectorModel( _rxContext, _bUseFormFormComponentHandlers )),
+ UNO_QUERY_THROW
+ );
+ setInspectorModel( xModel );
+ }
+ osl_decrementInterlockedCount( &m_refCount );
+ }
+
+ //------------------------------------------------------------------------
+ FormController::~FormController()
+ {
+ }
+
+ //------------------------------------------------------------------------
+ IMPLEMENT_FORWARD_XINTERFACE2( FormController, OPropertyBrowserController, FormController_PropertyBase1 )
+
+ //------------------------------------------------------------------------
+ Sequence< Type > SAL_CALL FormController::getTypes( ) throw(RuntimeException)
+ {
+ ::cppu::OTypeCollection aTypes(
+ ::getCppuType( static_cast< Reference< XPropertySet >* >(NULL) ),
+ ::getCppuType( static_cast< Reference< XMultiPropertySet >* >(NULL) ),
+ ::getCppuType( static_cast< Reference< XFastPropertySet >* >(NULL) ),
+ OPropertyBrowserController::getTypes());
+ return aTypes.getTypes();
+ }
+
+ //------------------------------------------------------------------------
+ IMPLEMENT_GET_IMPLEMENTATION_ID( FormController )
+
+ //------------------------------------------------------------------------
+ ::rtl::OUString SAL_CALL FormController::getImplementationName( ) throw(RuntimeException)
+ {
+ return m_aServiceDescriptor.GetImplementationName();
+ }
+
+ //------------------------------------------------------------------------
+ Sequence< ::rtl::OUString > SAL_CALL FormController::getSupportedServiceNames( ) throw(RuntimeException)
+ {
+ Sequence< ::rtl::OUString > aSupported( m_aServiceDescriptor.GetSupportedServiceNames() );
+ aSupported.realloc( aSupported.getLength() + 1 );
+ aSupported[ aSupported.getLength() - 1 ] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.inspection.ObjectInspector" ) );
+ return aSupported;
+ }
+
+ //------------------------------------------------------------------------
+ ::rtl::OUString FormController::getImplementationName_static( ) throw(RuntimeException)
+ {
+ return ::rtl::OUString::createFromAscii("org.openoffice.comp.extensions.FormController");
+ }
+
+ //------------------------------------------------------------------------
+ Sequence< ::rtl::OUString > FormController::getSupportedServiceNames_static( ) throw(RuntimeException)
+ {
+ Sequence< ::rtl::OUString > aSupported(1);
+ aSupported[0] = ::rtl::OUString::createFromAscii( "com.sun.star.form.PropertyBrowserController" );
+ return aSupported;
+ }
+
+ //------------------------------------------------------------------------
+ Reference< XInterface > SAL_CALL FormController::Create(const Reference< XComponentContext >& _rxContext )
+ {
+ ServiceDescriptor aService;
+ aService.GetImplementationName = &FormController::getImplementationName_static;
+ aService.GetSupportedServiceNames = &FormController::getSupportedServiceNames_static;
+ return *(new FormController( _rxContext, aService, true ) );
+ }
+
+ //------------------------------------------------------------------------
+ Reference< XPropertySetInfo > SAL_CALL FormController::getPropertySetInfo( ) throw(RuntimeException)
+ {
+ return ::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper());
+ }
+
+ //------------------------------------------------------------------------
+ ::cppu::IPropertyArrayHelper& SAL_CALL FormController::getInfoHelper()
+ {
+ return *getArrayHelper();
+ }
+
+ //------------------------------------------------------------------------
+ ::cppu::IPropertyArrayHelper* FormController::createArrayHelper( ) const
+ {
+ Sequence< Property > aProps( 2 );
+ aProps[0] = Property(
+ PROPERTY_CURRENTPAGE,
+ OWN_PROPERTY_ID_CURRENTPAGE,
+ ::getCppuType( static_cast< ::rtl::OUString* >( NULL ) ),
+ PropertyAttribute::TRANSIENT
+ );
+ aProps[1] = Property(
+ PROPERTY_INTROSPECTEDOBJECT,
+ OWN_PROPERTY_ID_INTROSPECTEDOBJECT,
+ XPropertySet::static_type(),
+ PropertyAttribute::TRANSIENT | PropertyAttribute::CONSTRAINED
+ );
+ return new ::cppu::OPropertyArrayHelper( aProps );
+ }
+
+ //------------------------------------------------------------------------
+ sal_Bool SAL_CALL FormController::convertFastPropertyValue( Any & rConvertedValue, Any & rOldValue, sal_Int32 nHandle, const Any& rValue ) throw (IllegalArgumentException)
+ {
+ switch ( nHandle )
+ {
+ case OWN_PROPERTY_ID_INTROSPECTEDOBJECT:
+ if ( rValue.getValueTypeClass() != TypeClass_INTERFACE )
+ throw IllegalArgumentException();
+ break;
+ case OWN_PROPERTY_ID_CURRENTPAGE:
+ if ( rValue.getValueTypeClass() != TypeClass_STRING )
+ throw IllegalArgumentException();
+ break;
+ }
+
+ getFastPropertyValue( rOldValue, nHandle );
+ rConvertedValue = rValue;
+ return sal_True;
+ }
+
+ //------------------------------------------------------------------------
+ void SAL_CALL FormController::setFastPropertyValue_NoBroadcast(sal_Int32 _nHandle, const Any& _rValue) throw (Exception)
+ {
+ switch ( _nHandle )
+ {
+ case OWN_PROPERTY_ID_INTROSPECTEDOBJECT:
+ {
+ Reference< XObjectInspectorModel > xModel( getInspectorModel() );
+ if ( xModel.is() )
+ {
+ try
+ {
+ m_xCurrentInspectee.set( _rValue, UNO_QUERY );
+ Sequence< Reference< XInterface > > aObjects;
+ if ( m_xCurrentInspectee.is() )
+ {
+ aObjects.realloc( 1 );
+ aObjects[0] = m_xCurrentInspectee;
+ }
+
+ Reference< XObjectInspector > xInspector( *this, UNO_QUERY_THROW );
+ xInspector->inspect( aObjects );
+ }
+ catch( const VetoException& e )
+ {
+ throw PropertyVetoException( e.Message, e.Context );
+ }
+ }
+ }
+ break;
+ case OWN_PROPERTY_ID_CURRENTPAGE:
+ restoreViewData( _rValue );
+ break;
+ }
+ }
+
+ //------------------------------------------------------------------------
+ void SAL_CALL FormController::getFastPropertyValue( ::com::sun::star::uno::Any& rValue, sal_Int32 nHandle ) const
+ {
+ switch ( nHandle )
+ {
+ case OWN_PROPERTY_ID_INTROSPECTEDOBJECT:
+ rValue <<= m_xCurrentInspectee;
+ break;
+
+ case OWN_PROPERTY_ID_CURRENTPAGE:
+ rValue = const_cast< FormController* >( this )->getViewData();
+ break;
+ }
+ }
+
+ //====================================================================
+ //= DialogController
+ //====================================================================
+ //------------------------------------------------------------------------
+ ::rtl::OUString DialogController::getImplementationName_static( ) throw(RuntimeException)
+ {
+ return ::rtl::OUString::createFromAscii("org.openoffice.comp.extensions.DialogController");
+ }
+
+ //------------------------------------------------------------------------
+ Sequence< ::rtl::OUString > DialogController::getSupportedServiceNames_static( ) throw(RuntimeException)
+ {
+ Sequence< ::rtl::OUString > aSupported(1);
+ aSupported[0] = ::rtl::OUString::createFromAscii( "com.sun.star.awt.PropertyBrowserController" );
+ return aSupported;
+ }
+
+ //------------------------------------------------------------------------
+ Reference< XInterface > SAL_CALL DialogController::Create(const Reference< XComponentContext >& _rxContext)
+ {
+ ServiceDescriptor aService;
+ aService.GetImplementationName = &DialogController::getImplementationName_static;
+ aService.GetSupportedServiceNames = &DialogController::getSupportedServiceNames_static;
+ return *(new FormController( _rxContext, aService, false ) );
+ }
+
+//........................................................................
+} // namespace pcr
+//........................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/propctrlr/formcontroller.hxx b/extensions/source/propctrlr/formcontroller.hxx
new file mode 100644
index 000000000000..fc398beb42d5
--- /dev/null
+++ b/extensions/source/propctrlr/formcontroller.hxx
@@ -0,0 +1,142 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef EXTENSIONS_SOURCE_PROPCTRLR_FORMCONTROLLER_HXX
+#define EXTENSIONS_SOURCE_PROPCTRLR_FORMCONTROLLER_HXX
+
+#include "propcontroller.hxx"
+
+/** === begin UNO includes === **/
+/** === end UNO includes === **/
+#include <cppuhelper/propshlp.hxx>
+#include <comphelper/proparrhlp.hxx>
+#include <comphelper/uno3.hxx>
+
+//........................................................................
+namespace pcr
+{
+//........................................................................
+
+ //====================================================================
+ //= ServiceDescriptor
+ //====================================================================
+ struct ServiceDescriptor
+ {
+ ::rtl::OUString
+ ( *GetImplementationName )( void );
+ ::com::sun::star::uno::Sequence< ::rtl::OUString >
+ ( *GetSupportedServiceNames )( void );
+ };
+
+ //====================================================================
+ //= FormController
+ //====================================================================
+ class FormController;
+ typedef ::cppu::OPropertySetHelper FormController_PropertyBase1;
+ typedef ::comphelper::OPropertyArrayUsageHelper< FormController > FormController_PropertyBase2;
+
+ /** Legacy implementation of com.sun.star.form.PropertyBrowserController
+
+ Nowadays only a wrapper around an ObjectInspector using a
+ DefaultFormComponentInspectorModel.
+ */
+ class FormController :public OPropertyBrowserController
+ ,public FormController_PropertyBase1
+ ,public FormController_PropertyBase2
+ {
+ private:
+ ServiceDescriptor m_aServiceDescriptor;
+ ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >
+ m_xCurrentInspectee;
+ bool m_bUseFormComponentHandlers;
+ public:
+ FormController(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _rxContext,
+ ServiceDescriptor _aServiceDescriptor,
+ bool _bUseFormFormComponentHandlers
+ );
+
+ // XServiceInfo - static versions
+ static ::rtl::OUString getImplementationName_static( ) throw(::com::sun::star::uno::RuntimeException);
+ static ::com::sun::star::uno::Sequence< ::rtl::OUString > getSupportedServiceNames_static( ) throw(::com::sun::star::uno::RuntimeException);
+ static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL
+ Create(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >&);
+
+ protected:
+ ~FormController();
+
+ DECLARE_XINTERFACE()
+ DECLARE_XTYPEPROVIDER()
+
+ // XServiceInfo
+ virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw(::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw(::com::sun::star::uno::RuntimeException);
+
+ // XPropertySet and friends
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException);
+ virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper();
+ virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const;
+
+ 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);
+ virtual void SAL_CALL setFastPropertyValue_NoBroadcast(
+ sal_Int32 nHandle, const ::com::sun::star::uno::Any& rValue
+ ) throw (::com::sun::star::uno::Exception);
+ virtual void SAL_CALL getFastPropertyValue(
+ ::com::sun::star::uno::Any& rValue, sal_Int32 nHandle
+ ) const;
+ private:
+ using FormController_PropertyBase1::getFastPropertyValue;
+ };
+
+ //====================================================================
+ //= DialogController
+ //====================================================================
+ /** Legacy implementation of com.sun.star.awt.PropertyBrowserController
+ */
+ class DialogController
+ {
+ public:
+ // XServiceInfo - static versions
+ static ::rtl::OUString getImplementationName_static( ) throw(::com::sun::star::uno::RuntimeException);
+ static ::com::sun::star::uno::Sequence< ::rtl::OUString > getSupportedServiceNames_static( ) throw(::com::sun::star::uno::RuntimeException);
+ static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL
+ Create(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >&);
+
+ private:
+ DialogController(); // never implemented
+ DialogController( const DialogController& ); // never implemented
+ DialogController& operator=( const DialogController& ); // never implemented
+ };
+//........................................................................
+} // namespace pcr
+//........................................................................
+
+#endif // EXTENSIONS_SOURCE_PROPCTRLR_FORMCONTROLLER_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/propctrlr/formgeometryhandler.cxx b/extensions/source/propctrlr/formgeometryhandler.cxx
new file mode 100644
index 000000000000..5c0875e7870c
--- /dev/null
+++ b/extensions/source/propctrlr/formgeometryhandler.cxx
@@ -0,0 +1,829 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+
+#include "propertyhandler.hxx"
+#include "formmetadata.hxx"
+#include "formstrings.hxx"
+#include "handlerhelper.hxx"
+#include "cellbindinghelper.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/inspection/XObjectInspectorUI.hpp>
+#include <com/sun/star/awt/XControlModel.hpp>
+#include <com/sun/star/drawing/XControlShape.hpp>
+#include <com/sun/star/container/XMap.hpp>
+#include <com/sun/star/inspection/XNumericControl.hpp>
+#include <com/sun/star/util/MeasureUnit.hpp>
+#include <com/sun/star/text/TextContentAnchorType.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/sheet/XSpreadsheet.hpp>
+#include <com/sun/star/table/XColumnRowRange.hpp>
+#include <com/sun/star/table/XCellRange.hpp>
+#include <com/sun/star/container/XChild.hpp>
+#include <com/sun/star/form/XGridColumnFactory.hpp>
+/** === end UNO includes === **/
+
+#include <cppuhelper/interfacecontainer.hxx>
+#include <comphelper/componentbase.hxx>
+#include <tools/debug.hxx>
+#include <tools/diagnose_ex.h>
+
+//........................................................................
+namespace pcr
+{
+//........................................................................
+
+ /** === begin UNO using === **/
+ using ::com::sun::star::uno::Reference;
+ using ::com::sun::star::uno::XInterface;
+ using ::com::sun::star::uno::UNO_QUERY;
+ using ::com::sun::star::uno::UNO_QUERY_THROW;
+ using ::com::sun::star::uno::UNO_SET_THROW;
+ using ::com::sun::star::uno::Exception;
+ using ::com::sun::star::uno::RuntimeException;
+ using ::com::sun::star::uno::Any;
+ using ::com::sun::star::uno::makeAny;
+ using ::com::sun::star::uno::Sequence;
+ using ::com::sun::star::uno::Type;
+ using ::com::sun::star::uno::XComponentContext;
+ using ::com::sun::star::beans::UnknownPropertyException;
+ using ::com::sun::star::beans::Property;
+ using ::com::sun::star::awt::XControlModel;
+ using ::com::sun::star::drawing::XControlShape;
+ using ::com::sun::star::container::XMap;
+ using ::com::sun::star::inspection::LineDescriptor;
+ using ::com::sun::star::inspection::XPropertyControlFactory;
+ using ::com::sun::star::lang::NullPointerException;
+ using ::com::sun::star::beans::Optional;
+ using ::com::sun::star::inspection::XNumericControl;
+ using ::com::sun::star::drawing::XShape;
+ using ::com::sun::star::beans::PropertyChangeEvent;
+ using ::com::sun::star::lang::EventObject;
+ using ::com::sun::star::beans::XPropertySet;
+ using ::com::sun::star::beans::XPropertyChangeListener;
+ using ::com::sun::star::text::TextContentAnchorType;
+ using ::com::sun::star::text::TextContentAnchorType_AT_PARAGRAPH;
+ using ::com::sun::star::text::TextContentAnchorType_AS_CHARACTER;
+ using ::com::sun::star::beans::XPropertySetInfo;
+ using ::com::sun::star::inspection::XObjectInspectorUI;
+ using ::com::sun::star::lang::XServiceInfo;
+ using ::com::sun::star::sheet::XSpreadsheet;
+ using ::com::sun::star::table::XColumnRowRange;
+ using ::com::sun::star::table::XTableColumns;
+ using ::com::sun::star::table::XTableRows;
+ using ::com::sun::star::table::XCellRange;
+ using ::com::sun::star::container::XIndexAccess;
+ using ::com::sun::star::container::XChild;
+ using ::com::sun::star::form::XGridColumnFactory;
+ /** === end UNO using === **/
+ namespace MeasureUnit = ::com::sun::star::util::MeasureUnit;
+
+ typedef ::com::sun::star::awt::Point AwtPoint;
+ typedef ::com::sun::star::awt::Size AwtSize;
+
+ #define ANCHOR_TO_SHEET 0
+ #define ANCHOR_TO_CELL 1
+
+ //====================================================================
+ //= BroadcastHelperBase
+ //====================================================================
+ class BroadcastHelperBase
+ {
+ protected:
+ BroadcastHelperBase( ::osl::Mutex& _rMutex )
+ :maBHelper( _rMutex )
+ {
+ }
+
+ protected:
+ ::cppu::OBroadcastHelper& getBroadcastHelper() { return maBHelper; }
+
+ private:
+ ::cppu::OBroadcastHelper maBHelper;
+ };
+
+ //====================================================================
+ //= ShapeGeometryChangeNotifier - declaration
+ //====================================================================
+ /** helper class to work around the ...unfortunate implementation of property change broadcasts
+ in the XShape implementation, which broadcasts way too generous and unspecified
+ */
+ typedef ::comphelper::ComponentBase ShapeGeometryChangeNotifier_CBase;
+ typedef ::cppu::WeakImplHelper1 < ::com::sun::star::beans::XPropertyChangeListener
+ > ShapeGeometryChangeNotifier_IBase;
+
+ class ShapeGeometryChangeNotifier :public BroadcastHelperBase
+ ,public ShapeGeometryChangeNotifier_CBase
+ ,public ShapeGeometryChangeNotifier_IBase
+ {
+ public:
+ ShapeGeometryChangeNotifier( ::cppu::OWeakObject& _rParent, ::osl::Mutex& _rParentMutex, const Reference< XShape >& _shape )
+ :BroadcastHelperBase( _rParentMutex )
+ ,ShapeGeometryChangeNotifier_CBase( BroadcastHelperBase::getBroadcastHelper(), ::comphelper::ComponentBase::NoInitializationNeeded() )
+ ,ShapeGeometryChangeNotifier_IBase()
+ ,m_rParent( _rParent )
+ ,m_aPropertyChangeListeners( _rParentMutex )
+ ,m_xShape( _shape )
+ {
+ ENSURE_OR_THROW( m_xShape.is(), "illegal shape!" );
+ impl_init_nothrow();
+ }
+
+ // property change broadcasting
+ void addPropertyChangeListener( const Reference< XPropertyChangeListener >& _listener )
+ {
+ m_aPropertyChangeListeners.addInterface( _listener );
+ }
+ void removePropertyChangeListener( const Reference< XPropertyChangeListener >& _listener )
+ {
+ m_aPropertyChangeListeners.removeInterface( _listener );
+ }
+
+ // XComponent equivalent
+ void dispose()
+ {
+ ::osl::MutexGuard aGuard( getMutex() );
+ impl_dispose_nothrow();
+ }
+
+ // XInterface
+ virtual void SAL_CALL acquire( ) throw ()
+ {
+ m_rParent.acquire();
+ }
+
+ virtual void SAL_CALL release( ) throw ()
+ {
+ m_rParent.release();
+ }
+
+ // XPropertyChangeListener
+ virtual void SAL_CALL propertyChange( const PropertyChangeEvent& _event ) throw (RuntimeException);
+
+ // XEventListener
+ virtual void SAL_CALL disposing( const EventObject& _event ) throw (RuntimeException);
+
+ protected:
+ virtual ~ShapeGeometryChangeNotifier()
+ {
+ if ( !getBroadcastHelper().bDisposed )
+ {
+ acquire();
+ dispose();
+ }
+ }
+
+ protected:
+ ::cppu::OBroadcastHelper& getBroadcastHelper() { return BroadcastHelperBase::getBroadcastHelper(); }
+
+ private:
+ void impl_init_nothrow();
+ void impl_dispose_nothrow();
+
+ private:
+ ::cppu::OWeakObject& m_rParent;
+ ::cppu::OInterfaceContainerHelper m_aPropertyChangeListeners;
+ Reference< XShape > m_xShape;
+ };
+
+ //====================================================================
+ //= FormGeometryHandler - declaration
+ //====================================================================
+ class FormGeometryHandler;
+ typedef HandlerComponentBase< FormGeometryHandler > FormGeometryHandler_Base;
+ /** a property handler for any virtual string properties
+ */
+ class FormGeometryHandler : public FormGeometryHandler_Base
+ {
+ public:
+ FormGeometryHandler(
+ const Reference< XComponentContext >& _rxContext
+ );
+
+ static ::rtl::OUString SAL_CALL getImplementationName_static( ) throw (RuntimeException);
+ static Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames_static( ) throw (RuntimeException);
+
+ protected:
+ ~FormGeometryHandler();
+
+ protected:
+ // XPropertyHandler overriables
+ virtual Any SAL_CALL getPropertyValue( const ::rtl::OUString& _rPropertyName ) throw (UnknownPropertyException, RuntimeException);
+ virtual void SAL_CALL setPropertyValue( const ::rtl::OUString& _rPropertyName, const Any& _rValue ) throw (UnknownPropertyException, RuntimeException);
+ virtual LineDescriptor SAL_CALL describePropertyLine( const ::rtl::OUString& _rPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyControlFactory >& _rxControlFactory ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::NullPointerException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL addPropertyChangeListener( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& _rxListener ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL removePropertyChangeListener( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& _rxListener ) throw (::com::sun::star::uno::RuntimeException);
+ virtual Sequence< ::rtl::OUString > SAL_CALL getActuatingProperties( ) throw (RuntimeException);
+ virtual void SAL_CALL actuatingPropertyChanged( const ::rtl::OUString& _rActuatingPropertyName, const Any& _rNewValue, const Any& _rOldValue, const Reference< XObjectInspectorUI >& _rxInspectorUI, sal_Bool _bFirstTimeInit ) throw (NullPointerException, RuntimeException);
+
+ // OComponentHandler overridables
+ virtual void SAL_CALL disposing();
+
+ // PropertyHandler overridables
+ virtual Sequence< Property > SAL_CALL doDescribeSupportedProperties() const;
+
+ protected:
+ virtual void onNewComponent();
+
+ private:
+ bool impl_haveTextAnchorType_nothrow() const;
+ bool impl_haveSheetAnchorType_nothrow() const;
+ void impl_setSheetAnchorType_nothrow( const sal_Int32 _nAnchorType ) const;
+
+ private:
+ Reference< XControlShape > m_xAssociatedShape;
+ Reference< XPropertySet > m_xShapeProperties;
+ ::rtl::Reference< ShapeGeometryChangeNotifier > m_xChangeNotifier;
+ };
+
+ //====================================================================
+ //= FormGeometryHandler - implementation
+ //====================================================================
+ DBG_NAME( FormGeometryHandler )
+ //--------------------------------------------------------------------
+ FormGeometryHandler::FormGeometryHandler( const Reference< XComponentContext >& _rxContext )
+ :FormGeometryHandler_Base( _rxContext )
+ {
+ DBG_CTOR( FormGeometryHandler, NULL );
+ }
+
+ //--------------------------------------------------------------------
+ FormGeometryHandler::~FormGeometryHandler( )
+ {
+ if ( !rBHelper.bDisposed )
+ {
+ acquire();
+ dispose();
+ }
+
+ DBG_DTOR( FormGeometryHandler, NULL );
+ }
+
+ //--------------------------------------------------------------------
+ void FormGeometryHandler::onNewComponent()
+ {
+ if ( m_xChangeNotifier.is() )
+ {
+ m_xChangeNotifier->dispose();
+ m_xChangeNotifier.clear();
+ }
+ m_xAssociatedShape.clear();
+ m_xShapeProperties.clear();
+
+ FormGeometryHandler_Base::onNewComponent();
+
+ try
+ {
+ Reference< XControlModel > xControlModel( m_xComponent, UNO_QUERY );
+ if ( xControlModel.is() )
+ {
+ // do not ask the map for shapes for grid control columns ....
+ Reference< XChild > xCompChild( m_xComponent, UNO_QUERY_THROW );
+ Reference< XGridColumnFactory > xCheckGrid( xCompChild->getParent(), UNO_QUERY );
+ if ( !xCheckGrid.is() )
+ {
+ Reference< XMap > xControlMap( m_aContext.getContextValueByAsciiName( "ControlShapeAccess" ), UNO_QUERY_THROW );
+ m_xAssociatedShape.set( xControlMap->get( makeAny( xControlModel ) ), UNO_QUERY_THROW );
+ m_xShapeProperties.set( m_xAssociatedShape, UNO_QUERY_THROW );
+ }
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+ if ( m_xAssociatedShape.is() )
+ m_xChangeNotifier = new ShapeGeometryChangeNotifier( *this, m_aMutex, m_xAssociatedShape.get() );
+ }
+
+ //--------------------------------------------------------------------
+ ::rtl::OUString SAL_CALL FormGeometryHandler::getImplementationName_static( ) throw (RuntimeException)
+ {
+ return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.extensions.FormGeometryHandler" ) );
+ }
+
+ //--------------------------------------------------------------------
+ Sequence< ::rtl::OUString > SAL_CALL FormGeometryHandler::getSupportedServiceNames_static( ) throw (RuntimeException)
+ {
+ Sequence< ::rtl::OUString > aSupported( 1 );
+ aSupported[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.form.inspection.FormGeometryHandler" ) );
+ return aSupported;
+ }
+
+ //--------------------------------------------------------------------
+ Any SAL_CALL FormGeometryHandler::getPropertyValue( const ::rtl::OUString& _rPropertyName ) throw (UnknownPropertyException, RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ PropertyId nPropId( impl_getPropertyId_throw( _rPropertyName ) );
+
+ ENSURE_OR_THROW2( m_xAssociatedShape.is(), "internal error: properties, but no shape!", *this );
+ ENSURE_OR_THROW2( m_xShapeProperties.is(), "internal error: no shape properties!", *this );
+
+ Any aReturn;
+ try
+ {
+ switch ( nPropId )
+ {
+ case PROPERTY_ID_POSITIONX:
+ aReturn <<= m_xAssociatedShape->getPosition().X;
+ break;
+ case PROPERTY_ID_POSITIONY:
+ aReturn <<= m_xAssociatedShape->getPosition().Y;
+ break;
+ case PROPERTY_ID_WIDTH:
+ aReturn <<= m_xAssociatedShape->getSize().Width;
+ break;
+ case PROPERTY_ID_HEIGHT:
+ aReturn <<= m_xAssociatedShape->getSize().Height;
+ break;
+ case PROPERTY_ID_TEXT_ANCHOR_TYPE:
+ aReturn = m_xShapeProperties->getPropertyValue( PROPERTY_ANCHOR_TYPE );
+ OSL_ENSURE( aReturn.hasValue(), "FormGeometryHandler::getPropertyValue: illegal anchor type!" );
+ break;
+ case PROPERTY_ID_SHEET_ANCHOR_TYPE:
+ {
+ Reference< XSpreadsheet > xAnchorSheet( m_xShapeProperties->getPropertyValue( PROPERTY_ANCHOR ), UNO_QUERY );
+ aReturn <<= sal_Int32( xAnchorSheet.is() ? ANCHOR_TO_SHEET : ANCHOR_TO_CELL );
+ }
+ break;
+
+ default:
+ OSL_ENSURE( false, "FormGeometryHandler::getPropertyValue: huh?" );
+ break;
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ return aReturn;
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL FormGeometryHandler::setPropertyValue( const ::rtl::OUString& _rPropertyName, const Any& _rValue ) throw (UnknownPropertyException, RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ PropertyId nPropId( impl_getPropertyId_throw( _rPropertyName ) );
+
+ ENSURE_OR_THROW2( m_xAssociatedShape.is(), "internal error: properties, but no shape!", *this );
+ ENSURE_OR_THROW2( m_xShapeProperties.is(), "internal error: properties, but no shape!", *this );
+
+ try
+ {
+ switch ( nPropId )
+ {
+ case PROPERTY_ID_POSITIONX:
+ case PROPERTY_ID_POSITIONY:
+ {
+ sal_Int32 nPosition(0);
+ OSL_VERIFY( _rValue >>= nPosition );
+
+ AwtPoint aPos( m_xAssociatedShape->getPosition() );
+ if ( nPropId == PROPERTY_ID_POSITIONX )
+ aPos.X = nPosition;
+ else
+ aPos.Y = nPosition;
+ m_xAssociatedShape->setPosition( aPos );
+ }
+ break;
+
+ case PROPERTY_ID_WIDTH:
+ case PROPERTY_ID_HEIGHT:
+ {
+ sal_Int32 nSize(0);
+ OSL_VERIFY( _rValue >>= nSize );
+
+ AwtSize aSize( m_xAssociatedShape->getSize() );
+ if ( nPropId == PROPERTY_ID_WIDTH )
+ aSize.Width = nSize;
+ else
+ aSize.Height = nSize;
+ m_xAssociatedShape->setSize( aSize );
+ }
+ break;
+
+ case PROPERTY_ID_TEXT_ANCHOR_TYPE:
+ m_xShapeProperties->setPropertyValue( PROPERTY_ANCHOR_TYPE, _rValue );
+ break;
+
+ case PROPERTY_ID_SHEET_ANCHOR_TYPE:
+ {
+ sal_Int32 nSheetAnchorType = 0;
+ OSL_VERIFY( _rValue >>= nSheetAnchorType );
+ impl_setSheetAnchorType_nothrow( nSheetAnchorType );
+ }
+ break;
+
+ default:
+ OSL_ENSURE( false, "FormGeometryHandler::getPropertyValue: huh?" );
+ break;
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+
+ //--------------------------------------------------------------------
+ LineDescriptor SAL_CALL FormGeometryHandler::describePropertyLine( const ::rtl::OUString& _rPropertyName,
+ const Reference< XPropertyControlFactory >& _rxControlFactory )
+ throw (UnknownPropertyException, NullPointerException, RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ PropertyId nPropId( impl_getPropertyId_throw( _rPropertyName ) );
+
+ LineDescriptor aLineDesc( PropertyHandler::describePropertyLine( _rPropertyName, _rxControlFactory ) );
+ try
+ {
+ bool bIsSize = false;
+ switch ( nPropId )
+ {
+ case PROPERTY_ID_WIDTH:
+ case PROPERTY_ID_HEIGHT:
+ bIsSize = true;
+ // NO break!
+ case PROPERTY_ID_POSITIONX:
+ case PROPERTY_ID_POSITIONY:
+ {
+ Optional< double > aZero( sal_True, 0 );
+ Optional< double > aValueNotPresent( sal_False, 0 );
+ aLineDesc.Control = PropertyHandlerHelper::createNumericControl(
+ _rxControlFactory, 2, bIsSize ? aZero : aValueNotPresent, aValueNotPresent, sal_False );
+
+ Reference< XNumericControl > xNumericControl( aLineDesc.Control, UNO_QUERY_THROW );
+ xNumericControl->setValueUnit( MeasureUnit::MM_100TH );
+ xNumericControl->setDisplayUnit( impl_getDocumentMeasurementUnit_throw() );
+ }
+ break;
+
+ case PROPERTY_ID_TEXT_ANCHOR_TYPE:
+ case PROPERTY_ID_SHEET_ANCHOR_TYPE:
+ // default handling from PropertyHandler is sufficient
+ break;
+
+ default:
+ OSL_ENSURE( false, "FormGeometryHandler::describePropertyLine: huh?" );
+ break;
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ return aLineDesc;
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL FormGeometryHandler::addPropertyChangeListener( const Reference< XPropertyChangeListener >& _listener ) throw (RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ OSL_PRECOND( m_xChangeNotifier.is(), "FormGeometryHandler::addPropertyChangeListener: no notified, implies no shape!?" );
+ if ( m_xChangeNotifier.is() )
+ m_xChangeNotifier->addPropertyChangeListener( _listener );
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL FormGeometryHandler::removePropertyChangeListener( const Reference< XPropertyChangeListener >& _listener ) throw (RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ OSL_PRECOND( m_xChangeNotifier.is(), "FormGeometryHandler::removePropertyChangeListener: no notified, implies no shape!?" );
+ if ( m_xChangeNotifier.is() )
+ m_xChangeNotifier->removePropertyChangeListener( _listener );
+ }
+
+ //--------------------------------------------------------------------
+ Sequence< ::rtl::OUString > SAL_CALL FormGeometryHandler::getActuatingProperties( ) throw (RuntimeException)
+ {
+ Sequence< ::rtl::OUString > aInterestedIn(1);
+ aInterestedIn[0] = PROPERTY_TEXT_ANCHOR_TYPE;
+ return aInterestedIn;
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL FormGeometryHandler::actuatingPropertyChanged( const ::rtl::OUString& _rActuatingPropertyName, const Any& _rNewValue, const Any& /*_rOldValue*/, const Reference< XObjectInspectorUI >& _rxInspectorUI, sal_Bool /*_bFirstTimeInit*/ ) throw (NullPointerException, RuntimeException)
+ {
+ if ( !_rxInspectorUI.is() )
+ throw NullPointerException();
+
+ ::osl::MutexGuard aGuard( m_aMutex );
+ PropertyId nActuatingPropId( impl_getPropertyId_throw( _rActuatingPropertyName ) );
+
+ switch ( nActuatingPropId )
+ {
+ case PROPERTY_ID_TEXT_ANCHOR_TYPE:
+ {
+ TextContentAnchorType eAnchorType( TextContentAnchorType_AT_PARAGRAPH );
+ OSL_VERIFY( _rNewValue >>= eAnchorType );
+ _rxInspectorUI->enablePropertyUI( PROPERTY_POSITIONX, eAnchorType != TextContentAnchorType_AS_CHARACTER );
+ }
+ break;
+ default:
+ OSL_ENSURE( false, "FormGeometryHandler::actuatingPropertyChanged: not registered for this property!" );
+ break;
+ }
+ }
+
+ //--------------------------------------------------------------------
+ Sequence< Property > SAL_CALL FormGeometryHandler::doDescribeSupportedProperties() const
+ {
+ if ( !m_xAssociatedShape.is() )
+ return Sequence< Property >();
+
+ ::std::vector< Property > aProperties;
+
+ addInt32PropertyDescription( aProperties, PROPERTY_POSITIONX );
+ addInt32PropertyDescription( aProperties, PROPERTY_POSITIONY );
+ addInt32PropertyDescription( aProperties, PROPERTY_WIDTH );
+ addInt32PropertyDescription( aProperties, PROPERTY_HEIGHT );
+
+ if ( impl_haveTextAnchorType_nothrow() )
+ implAddPropertyDescription( aProperties, PROPERTY_TEXT_ANCHOR_TYPE, ::cppu::UnoType< TextContentAnchorType >::get() );
+
+ if ( impl_haveSheetAnchorType_nothrow() )
+ addInt32PropertyDescription( aProperties, PROPERTY_SHEET_ANCHOR_TYPE );
+
+ return Sequence< Property >( &(*aProperties.begin()), aProperties.size() );
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL FormGeometryHandler::disposing()
+ {
+ FormGeometryHandler_Base::disposing();
+
+ if ( m_xChangeNotifier.is() )
+ {
+ m_xChangeNotifier->dispose();
+ m_xChangeNotifier.clear();
+ }
+ }
+
+ //--------------------------------------------------------------------
+ bool FormGeometryHandler::impl_haveTextAnchorType_nothrow() const
+ {
+ ENSURE_OR_THROW( m_xShapeProperties.is(), "not to be called without shape properties" );
+ try
+ {
+ Reference< XPropertySetInfo > xPSI( m_xShapeProperties->getPropertySetInfo(), UNO_SET_THROW );
+ if ( xPSI->hasPropertyByName( PROPERTY_ANCHOR_TYPE ) )
+ return true;
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ return false;
+ }
+
+ //--------------------------------------------------------------------
+ bool FormGeometryHandler::impl_haveSheetAnchorType_nothrow() const
+ {
+ ENSURE_OR_THROW( m_xShapeProperties.is(), "not to be called without shape properties" );
+ try
+ {
+ Reference< XPropertySetInfo > xPSI( m_xShapeProperties->getPropertySetInfo(), UNO_SET_THROW );
+ if ( !xPSI->hasPropertyByName( PROPERTY_ANCHOR ) )
+ return false;
+ Reference< XServiceInfo > xSI( m_xAssociatedShape, UNO_QUERY_THROW );
+ if ( xSI->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.sheet.Shape" ) ) ) )
+ return true;
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ return false;
+ }
+
+ //--------------------------------------------------------------------
+ namespace
+ {
+ static sal_Int32 lcl_getLowerBoundRowOrColumn( const Reference< XIndexAccess >& _rxRowsOrColumns, const bool _bRows,
+ const AwtPoint& _rRelativePosition )
+ {
+ sal_Int32 nAccumulated = 0;
+
+ const sal_Int32& rRelativePos = _bRows ? _rRelativePosition.Y : _rRelativePosition.X;
+
+ sal_Int32 nElements = _rxRowsOrColumns->getCount();
+ sal_Int32 currentPos = 0;
+ for ( currentPos=0; currentPos<nElements; ++currentPos )
+ {
+ Reference< XPropertySet > xRowOrColumn( _rxRowsOrColumns->getByIndex( currentPos ), UNO_QUERY_THROW );
+
+ sal_Bool bIsVisible = sal_True;
+ OSL_VERIFY( xRowOrColumn->getPropertyValue( PROPERTY_IS_VISIBLE ) >>= bIsVisible );
+ if ( !bIsVisible )
+ continue;
+
+ sal_Int32 nHeightOrWidth( 0 );
+ OSL_VERIFY( xRowOrColumn->getPropertyValue( _bRows ? PROPERTY_HEIGHT : PROPERTY_WIDTH ) >>= nHeightOrWidth );
+
+ if ( nAccumulated + nHeightOrWidth > rRelativePos )
+ break;
+
+ nAccumulated += nHeightOrWidth;
+ }
+
+ return currentPos;
+ }
+ }
+
+ //--------------------------------------------------------------------
+ void FormGeometryHandler::impl_setSheetAnchorType_nothrow( const sal_Int32 _nAnchorType ) const
+ {
+ ENSURE_OR_THROW( m_xShapeProperties.is(), "illegal to be called without shape properties." );
+ try
+ {
+ CellBindingHelper aHelper( m_xComponent, impl_getContextDocument_nothrow() );
+ // find the sheet which the control belongs to
+ Reference< XSpreadsheet > xSheet;
+ aHelper.getControlSheetIndex( xSheet );
+
+ switch ( _nAnchorType )
+ {
+ case ANCHOR_TO_SHEET:
+ OSL_ENSURE( xSheet.is(),
+ "FormGeometryHandler::impl_setSheetAnchorType_nothrow: sheet not found!" );
+ if ( xSheet.is() )
+ {
+ AwtPoint aPreservePosition( m_xAssociatedShape->getPosition() );
+ m_xShapeProperties->setPropertyValue( PROPERTY_ANCHOR, makeAny( xSheet ) );
+ m_xAssociatedShape->setPosition( aPreservePosition );
+ }
+ break;
+
+ case ANCHOR_TO_CELL:
+ {
+ Reference< XColumnRowRange > xColsRows( xSheet, UNO_QUERY_THROW );
+
+ // get the current anchor
+ Reference< XSpreadsheet > xCurrentAnchor;
+ OSL_VERIFY( m_xShapeProperties->getPropertyValue( PROPERTY_ANCHOR ) >>= xCurrentAnchor );
+ OSL_ENSURE( xCurrentAnchor.is(), "FormGeometryHandler::impl_setSheetAnchorType_nothrow: only to be called when currently anchored to a sheet!" );
+
+ // get the current position
+ AwtPoint aRelativePosition( m_xAssociatedShape->getPosition() );
+
+ Reference< XTableColumns > xCols( xColsRows->getColumns(), UNO_SET_THROW );
+ sal_Int32 nNewAnchorCol = lcl_getLowerBoundRowOrColumn( xCols.get(), false, aRelativePosition );
+
+ Reference< XTableRows > xRows( xColsRows->getRows(), UNO_SET_THROW );
+ sal_Int32 nNewAnchorRow = lcl_getLowerBoundRowOrColumn( xRows.get(), true, aRelativePosition );
+
+ Reference< XCellRange > xSheetCellRange( xSheet, UNO_QUERY_THROW );
+ Any aNewAnchorCell( xSheetCellRange->getCellByPosition( nNewAnchorCol, nNewAnchorRow ) );
+ m_xShapeProperties->setPropertyValue( PROPERTY_ANCHOR, aNewAnchorCell );
+ }
+ break;
+
+ default:
+ OSL_ENSURE( false, "FormGeometryHandler::impl_setSheetAnchorType_nothrow: illegal anchor type!" );
+ break;
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+
+ //====================================================================
+ //= ShapeGeometryChangeNotifier - implementation
+ //====================================================================
+ namespace
+ {
+ struct EventTranslation
+ {
+ ::rtl::OUString sPropertyName;
+ Any aNewPropertyValue;
+
+ EventTranslation( const ::rtl::OUString& _propertyName, const Any& _newPropertyValue )
+ :sPropertyName( _propertyName )
+ ,aNewPropertyValue( _newPropertyValue )
+ {
+ }
+ };
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL ShapeGeometryChangeNotifier::propertyChange( const PropertyChangeEvent& _event ) throw (RuntimeException)
+ {
+ ::comphelper::ComponentMethodGuard aGuard( *this );
+
+ ::std::vector< EventTranslation > aEventTranslations;
+ aEventTranslations.reserve(2);
+
+ if ( _event.PropertyName.equalsAscii( "Position" ) )
+ {
+ AwtPoint aPos = m_xShape->getPosition();
+ aEventTranslations.push_back( EventTranslation( PROPERTY_POSITIONX, makeAny( aPos.X ) ) );
+ aEventTranslations.push_back( EventTranslation( PROPERTY_POSITIONY, makeAny( aPos.Y ) ) );
+ }
+ else if ( _event.PropertyName.equalsAscii( "Size" ) )
+ {
+ AwtSize aSize = m_xShape->getSize();
+ aEventTranslations.push_back( EventTranslation( PROPERTY_WIDTH, makeAny( aSize.Width ) ) );
+ aEventTranslations.push_back( EventTranslation( PROPERTY_HEIGHT, makeAny( aSize.Height ) ) );
+ }
+ else if ( _event.PropertyName == PROPERTY_ANCHOR_TYPE )
+ {
+ aEventTranslations.push_back( EventTranslation( PROPERTY_TEXT_ANCHOR_TYPE, makeAny( _event.NewValue ) ) );
+ }
+ else if ( _event.PropertyName == PROPERTY_ANCHOR )
+ {
+ aEventTranslations.push_back( EventTranslation( PROPERTY_SHEET_ANCHOR_TYPE, makeAny( _event.NewValue ) ) );
+ }
+
+ PropertyChangeEvent aTranslatedEvent( _event );
+ aTranslatedEvent.Source = m_rParent;
+
+ aGuard.clear();
+ for ( ::std::vector< EventTranslation >::const_iterator t = aEventTranslations.begin();
+ t != aEventTranslations.end();
+ ++t
+ )
+ {
+ aTranslatedEvent.PropertyName = t->sPropertyName;
+ aTranslatedEvent.NewValue = t->aNewPropertyValue;
+ m_aPropertyChangeListeners.notifyEach( &XPropertyChangeListener::propertyChange, aTranslatedEvent );
+ }
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL ShapeGeometryChangeNotifier::disposing( const EventObject& /*_event*/ ) throw (RuntimeException)
+ {
+ ::comphelper::ComponentMethodGuard aGuard( *this );
+ impl_dispose_nothrow();
+ }
+
+ //--------------------------------------------------------------------
+ void ShapeGeometryChangeNotifier::impl_init_nothrow()
+ {
+ osl_incrementInterlockedCount( &m_refCount );
+ try
+ {
+ Reference< XPropertySet > xShapeProperties( m_xShape, UNO_QUERY_THROW );
+ xShapeProperties->addPropertyChangeListener( ::rtl::OUString(), this );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ osl_decrementInterlockedCount( &m_refCount );
+ }
+
+ //--------------------------------------------------------------------
+ void ShapeGeometryChangeNotifier::impl_dispose_nothrow()
+ {
+ try
+ {
+ Reference< XPropertySet > xShapeProperties( m_xShape, UNO_QUERY_THROW );
+ xShapeProperties->removePropertyChangeListener( ::rtl::OUString(), this );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+ getBroadcastHelper().bDisposed = true;
+ }
+
+//........................................................................
+} // namespace pcr
+//........................................................................
+
+extern "C" void SAL_CALL createRegistryInfo_FormGeometryHandler()
+{
+ ::pcr::FormGeometryHandler::registerImplementation();
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/propctrlr/formlinkdialog.cxx b/extensions/source/propctrlr/formlinkdialog.cxx
new file mode 100644
index 000000000000..21e965ede7b7
--- /dev/null
+++ b/extensions/source/propctrlr/formlinkdialog.cxx
@@ -0,0 +1,675 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+
+#include "formlinkdialog.hxx"
+#include "formlinkdialog.hrc"
+
+#include "modulepcr.hxx"
+#include "formresid.hrc"
+#include "formstrings.hxx"
+#include <vcl/combobox.hxx>
+#include <vcl/msgbox.hxx>
+#include <vcl/waitobj.hxx>
+#include <svtools/localresaccess.hxx>
+#include <connectivity/dbtools.hxx>
+#include <connectivity/dbexception.hxx>
+#include <toolkit/helper/vclunohelper.hxx>
+
+/** === begin UNO includes === **/
+#include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
+#include <com/sun/star/sdbcx/XKeysSupplier.hpp>
+#include <com/sun/star/sdbcx/KeyType.hpp>
+#include <com/sun/star/container/XNameAccess.hpp>
+#include <com/sun/star/sdbcx/XTablesSupplier.hpp>
+#include <com/sun/star/sdbc/XRowSet.hpp>
+#include <com/sun/star/sdb/CommandType.hpp>
+#include <com/sun/star/sdb/SQLContext.hpp>
+/** === end UNO includes === **/
+
+
+//............................................................................
+namespace pcr
+{
+//............................................................................
+
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::lang;
+ using namespace ::com::sun::star::form;
+ using namespace ::com::sun::star::sdb;
+ using namespace ::com::sun::star::sdbc;
+ using namespace ::com::sun::star::sdbcx;
+ using namespace ::com::sun::star::beans;
+ using namespace ::com::sun::star::container;
+
+ //========================================================================
+ //= FieldLinkRow
+ //========================================================================
+ class FieldLinkRow : public Window
+ {
+ private:
+ ComboBox m_aDetailColumn;
+ FixedText m_aEqualSign;
+ ComboBox m_aMasterColumn;
+
+ Link m_aLinkChangeHandler;
+
+ public:
+ FieldLinkRow( Window* _pParent, const ResId& _rId );
+
+ inline void SetLinkChangeHandler( const Link& _rHdl ) { m_aLinkChangeHandler = _rHdl; }
+ inline const Link& GetLinkChangeHandler( ) const { return m_aLinkChangeHandler; }
+
+ enum LinkParticipant
+ {
+ eDetailField,
+ eMasterField
+ };
+ /** retrieves the selected field name for either the master or the detail field
+ @return <TRUE/> if and only a valid field is selected
+ */
+ bool GetFieldName( LinkParticipant _eWhich, String& /* [out] */ _rName ) const;
+ void SetFieldName( LinkParticipant _eWhich, const String& _rName );
+
+ void fillList( LinkParticipant _eWhich, const Sequence< ::rtl::OUString >& _rFieldNames );
+
+ private:
+ DECL_LINK( OnFieldNameChanged, ComboBox* );
+ };
+
+ //------------------------------------------------------------------------
+ FieldLinkRow::FieldLinkRow( Window* _pParent, const ResId& _rId )
+ :Window( _pParent, _rId )
+ ,m_aDetailColumn( this, ResId( 1, *_rId.GetResMgr() ) )
+ ,m_aEqualSign ( this, ResId( 1, *_rId.GetResMgr() ) )
+ ,m_aMasterColumn( this, ResId( 2, *_rId.GetResMgr() ) )
+ {
+ FreeResource();
+
+ m_aDetailColumn.SetDropDownLineCount( 10 );
+ m_aMasterColumn.SetDropDownLineCount( 10 );
+
+ m_aDetailColumn.SetModifyHdl( LINK( this, FieldLinkRow, OnFieldNameChanged ) );
+ m_aMasterColumn.SetModifyHdl( LINK( this, FieldLinkRow, OnFieldNameChanged ) );
+ }
+
+ //------------------------------------------------------------------------
+ void FieldLinkRow::fillList( LinkParticipant _eWhich, const Sequence< ::rtl::OUString >& _rFieldNames )
+ {
+ ComboBox* pBox = ( _eWhich == eDetailField ) ? &m_aDetailColumn : &m_aMasterColumn;
+
+ const ::rtl::OUString* pFieldName = _rFieldNames.getConstArray();
+ const ::rtl::OUString* pFieldNameEnd = pFieldName + _rFieldNames.getLength();
+ for ( ; pFieldName != pFieldNameEnd; ++pFieldName )
+ pBox->InsertEntry( *pFieldName );
+ }
+
+ //------------------------------------------------------------------------
+ bool FieldLinkRow::GetFieldName( LinkParticipant _eWhich, String& /* [out] */ _rName ) const
+ {
+ const ComboBox* pBox = ( _eWhich == eDetailField ) ? &m_aDetailColumn : &m_aMasterColumn;
+ _rName = pBox->GetText();
+ return _rName.Len() != 0;
+ }
+
+ //------------------------------------------------------------------------
+ void FieldLinkRow::SetFieldName( LinkParticipant _eWhich, const String& _rName )
+ {
+ ComboBox* pBox = ( _eWhich == eDetailField ) ? &m_aDetailColumn : &m_aMasterColumn;
+ pBox->SetText( _rName );
+ }
+
+ //------------------------------------------------------------------------
+ IMPL_LINK( FieldLinkRow, OnFieldNameChanged, ComboBox*, /*_pBox*/ )
+ {
+ if ( m_aLinkChangeHandler.IsSet() )
+ return m_aLinkChangeHandler.Call( this );
+
+ return 0L;
+ }
+
+ //========================================================================
+ //= FormLinkDialog
+ //========================================================================
+ //------------------------------------------------------------------------
+ FormLinkDialog::FormLinkDialog( Window* _pParent, const Reference< XPropertySet >& _rxDetailForm,
+ const Reference< XPropertySet >& _rxMasterForm, const Reference< XMultiServiceFactory >& _rxORB,
+ const ::rtl::OUString& _sExplanation,
+ const ::rtl::OUString& _sDetailLabel,
+ const ::rtl::OUString& _sMasterLabel)
+ :ModalDialog( _pParent, PcrRes( RID_DLG_FORMLINKS ) )
+ ,m_aExplanation( this, PcrRes( FT_EXPLANATION ) )
+ ,m_aDetailLabel( this, PcrRes( FT_DETAIL_LABEL ) )
+ ,m_aMasterLabel( this, PcrRes( FT_MASTER_LABEL ) )
+ ,m_aRow1 ( new FieldLinkRow( this, PcrRes( 1 ) ) )
+ ,m_aRow2 ( new FieldLinkRow( this, PcrRes( 2 ) ) )
+ ,m_aRow3 ( new FieldLinkRow( this, PcrRes( 3 ) ) )
+ ,m_aRow4 ( new FieldLinkRow( this, PcrRes( 4 ) ) )
+ ,m_aOK ( this, PcrRes( PB_OK ) )
+ ,m_aCancel ( this, PcrRes( PB_CANCEL ) )
+ ,m_aHelp ( this, PcrRes( PB_HELP ) )
+ ,m_aSuggest ( this, PcrRes( PB_SUGGEST ) )
+ ,m_xORB ( _rxORB )
+ ,m_xDetailForm( _rxDetailForm )
+ ,m_xMasterForm( _rxMasterForm )
+ ,m_sDetailLabel(_sDetailLabel)
+ ,m_sMasterLabel(_sMasterLabel)
+ {
+ FreeResource();
+ if ( _sExplanation.getLength() )
+ m_aExplanation.SetText(_sExplanation);
+
+ m_aSuggest.SetClickHdl ( LINK( this, FormLinkDialog, OnSuggest ) );
+ m_aRow1->SetLinkChangeHandler( LINK( this, FormLinkDialog, OnFieldChanged ) );
+ m_aRow2->SetLinkChangeHandler( LINK( this, FormLinkDialog, OnFieldChanged ) );
+ m_aRow3->SetLinkChangeHandler( LINK( this, FormLinkDialog, OnFieldChanged ) );
+ m_aRow4->SetLinkChangeHandler( LINK( this, FormLinkDialog, OnFieldChanged ) );
+
+ PostUserEvent( LINK( this, FormLinkDialog, OnInitialize ) );
+
+ updateOkButton();
+ }
+
+ //------------------------------------------------------------------------
+ FormLinkDialog::~FormLinkDialog( )
+ {
+ }
+
+ //------------------------------------------------------------------------
+ void FormLinkDialog::commitLinkPairs()
+ {
+ // collect the field lists from the rows
+ ::std::vector< ::rtl::OUString > aDetailFields; aDetailFields.reserve( 4 );
+ ::std::vector< ::rtl::OUString > aMasterFields; aMasterFields.reserve( 4 );
+
+ const FieldLinkRow* aRows[] = {
+ m_aRow1.get(), m_aRow2.get(), m_aRow3.get(), m_aRow4.get()
+ };
+
+ for ( sal_Int32 i = 0; i < 4; ++i )
+ {
+ String sDetailField, sMasterField;
+ aRows[ i ]->GetFieldName( FieldLinkRow::eDetailField, sDetailField );
+ aRows[ i ]->GetFieldName( FieldLinkRow::eMasterField, sMasterField );
+ if ( !sDetailField.Len() && !sMasterField.Len() )
+ continue;
+
+ aDetailFields.push_back( sDetailField );
+ aMasterFields.push_back( sMasterField );
+ }
+
+ // and set as property values
+ try
+ {
+ Reference< XPropertySet > xDetailFormProps( m_xDetailForm, UNO_QUERY );
+ if ( xDetailFormProps.is() )
+ {
+ ::rtl::OUString *pFields = aDetailFields.empty() ? 0 : &aDetailFields[0];
+ xDetailFormProps->setPropertyValue( PROPERTY_DETAILFIELDS, makeAny( Sequence< ::rtl::OUString >( pFields, aDetailFields.size() ) ) );
+ pFields = aMasterFields.empty() ? 0 : &aMasterFields[0];
+ xDetailFormProps->setPropertyValue( PROPERTY_MASTERFIELDS, makeAny( Sequence< ::rtl::OUString >( pFields, aMasterFields.size() ) ) );
+ }
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "FormLinkDialog::commitLinkPairs: caught an exception while setting the properties!" );
+ }
+ }
+
+ //------------------------------------------------------------------------
+ short FormLinkDialog::Execute()
+ {
+ short nResult = ModalDialog::Execute();
+
+ if ( RET_OK == nResult )
+ commitLinkPairs();
+
+ return nResult;
+ }
+
+ //------------------------------------------------------------------------
+ void FormLinkDialog::initializeFieldLists()
+ {
+ Sequence< ::rtl::OUString > sDetailFields;
+ getFormFields( m_xDetailForm, sDetailFields );
+
+ Sequence< ::rtl::OUString > sMasterFields;
+ getFormFields( m_xMasterForm, sMasterFields );
+
+ FieldLinkRow* aRows[] = {
+ m_aRow1.get(), m_aRow2.get(), m_aRow3.get(), m_aRow4.get()
+ };
+ for ( sal_Int32 i = 0; i < 4 ; ++i )
+ {
+ aRows[i]->fillList( FieldLinkRow::eDetailField, sDetailFields );
+ aRows[i]->fillList( FieldLinkRow::eMasterField, sMasterFields );
+ }
+
+ }
+
+ //------------------------------------------------------------------------
+ void FormLinkDialog::initializeColumnLabels()
+ {
+ // label for the detail form
+ String sDetailType = getFormDataSourceType( m_xDetailForm );
+ if ( !sDetailType.Len() )
+ {
+ if ( !m_sDetailLabel.getLength() )
+ {
+ ::svt::OLocalResourceAccess aStringAccess( PcrRes( RID_DLG_FORMLINKS ), RSC_MODALDIALOG );
+ m_sDetailLabel = String( PcrRes( STR_DETAIL_FORM ) );
+ }
+ sDetailType = m_sDetailLabel;
+ }
+ m_aDetailLabel.SetText( sDetailType );
+
+ // label for the master form
+ String sMasterType = getFormDataSourceType( m_xMasterForm );
+ if ( !sMasterType.Len() )
+ {
+ if ( !m_sMasterLabel.getLength() )
+ {
+ ::svt::OLocalResourceAccess aStringAccess( PcrRes( RID_DLG_FORMLINKS ), RSC_MODALDIALOG );
+ m_sMasterLabel = String( PcrRes( STR_MASTER_FORM ) );
+ }
+ sMasterType = m_sMasterLabel;
+ }
+ m_aMasterLabel.SetText( sMasterType );
+ }
+
+ //------------------------------------------------------------------------
+ void FormLinkDialog::initializeFieldRowsFrom( Sequence< ::rtl::OUString >& _rDetailFields, Sequence< ::rtl::OUString >& _rMasterFields )
+ {
+ // our UI does allow 4 fields max
+ _rDetailFields.realloc( 4 );
+ _rMasterFields.realloc( 4 );
+
+ const ::rtl::OUString* pDetailFields = _rDetailFields.getConstArray();
+ const ::rtl::OUString* pMasterFields = _rMasterFields.getConstArray();
+
+ FieldLinkRow* aRows[] = {
+ m_aRow1.get(), m_aRow2.get(), m_aRow3.get(), m_aRow4.get()
+ };
+ for ( sal_Int32 i = 0; i < 4; ++i, ++pDetailFields, ++pMasterFields )
+ {
+ aRows[ i ]->SetFieldName( FieldLinkRow::eDetailField, *pDetailFields );
+ aRows[ i ]->SetFieldName( FieldLinkRow::eMasterField, *pMasterFields );
+ }
+ }
+
+ //------------------------------------------------------------------------
+ void FormLinkDialog::initializeLinks()
+ {
+ try
+ {
+ Sequence< ::rtl::OUString > aDetailFields;
+ Sequence< ::rtl::OUString > aMasterFields;
+
+ Reference< XPropertySet > xDetailFormProps( m_xDetailForm, UNO_QUERY );
+ if ( xDetailFormProps.is() )
+ {
+ xDetailFormProps->getPropertyValue( PROPERTY_DETAILFIELDS ) >>= aDetailFields;
+ xDetailFormProps->getPropertyValue( PROPERTY_MASTERFIELDS ) >>= aMasterFields;
+ }
+
+ initializeFieldRowsFrom( aDetailFields, aMasterFields );
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "FormLinkDialog::initializeLinks: caught an exception!" );
+ }
+ }
+
+ //------------------------------------------------------------------------
+ void FormLinkDialog::updateOkButton()
+ {
+ // in all rows, there must be either two valid selections, or none at all
+ // If there is at least one row with exactly one valid selection, then the
+ // OKButton needs to be disabled
+ BOOL bEnable = TRUE;
+
+ const FieldLinkRow* aRows[] = {
+ m_aRow1.get(), m_aRow2.get(), m_aRow3.get(), m_aRow4.get()
+ };
+
+ for ( sal_Int32 i = 0; ( i < 4 ) && bEnable; ++i )
+ {
+ String sNotInterestedInRightNow;
+ if ( aRows[ i ]->GetFieldName( FieldLinkRow::eDetailField, sNotInterestedInRightNow )
+ != aRows[ i ]->GetFieldName( FieldLinkRow::eMasterField, sNotInterestedInRightNow )
+ )
+ bEnable = FALSE;
+ }
+
+ m_aOK.Enable( bEnable );
+ }
+
+ //------------------------------------------------------------------------
+ String FormLinkDialog::getFormDataSourceType( const Reference< XPropertySet >& _rxForm ) const SAL_THROW(())
+ {
+ String sReturn;
+ Reference< XPropertySet > xFormProps( _rxForm, UNO_QUERY );
+ if ( !xFormProps.is() )
+ return sReturn;
+
+ try
+ {
+ sal_Int32 nCommandType = CommandType::COMMAND;
+ ::rtl::OUString sCommand;
+
+ xFormProps->getPropertyValue( PROPERTY_COMMANDTYPE ) >>= nCommandType;
+ xFormProps->getPropertyValue( PROPERTY_COMMAND ) >>= sCommand;
+
+ if ( ( nCommandType == CommandType::TABLE )
+ || ( nCommandType == CommandType::QUERY )
+ )
+ sReturn = sCommand;
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "FormLinkDialog::getFormDataSourceType: caught an exception!" );
+ }
+ return sReturn;
+ }
+
+ //------------------------------------------------------------------------
+ void FormLinkDialog::getFormFields( const Reference< XPropertySet >& _rxForm, Sequence< ::rtl::OUString >& /* [out] */ _rNames ) const SAL_THROW(( ))
+ {
+ _rNames.realloc( 0 );
+
+ ::dbtools::SQLExceptionInfo aErrorInfo;
+ ::rtl::OUString sCommand;
+ try
+ {
+ WaitObject aWaitCursor( const_cast< FormLinkDialog* >( this ) );
+
+ Reference< XPropertySet > xFormProps( _rxForm, UNO_QUERY );
+ OSL_ENSURE( xFormProps.is(), "FormLinkDialog::getFormFields: invalid form!" );
+
+ sal_Int32 nCommandType = CommandType::COMMAND;
+
+ xFormProps->getPropertyValue( PROPERTY_COMMANDTYPE ) >>= nCommandType;
+ xFormProps->getPropertyValue( PROPERTY_COMMAND ) >>= sCommand;
+
+ Reference< XConnection > xConnection;
+ ensureFormConnection( xFormProps, xConnection );
+
+ _rNames = ::dbtools::getFieldNamesByCommandDescriptor(
+ xConnection,
+ nCommandType,
+ sCommand,
+ &aErrorInfo
+ );
+ }
+ catch (const SQLContext& e) { aErrorInfo = e; }
+ catch (const SQLWarning& e) { aErrorInfo = e; }
+ catch (const SQLException& e ) { aErrorInfo = e; }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "FormLinkDialog::getFormFields: caught a non-SQL exception!" );
+ }
+
+ if ( aErrorInfo.isValid() )
+ {
+ String sErrorMessage;
+ {
+ ::svt::OLocalResourceAccess aStringAccess( PcrRes( RID_DLG_FORMLINKS ), RSC_MODALDIALOG );
+ sErrorMessage = String( PcrRes( STR_ERROR_RETRIEVING_COLUMNS) );
+ sErrorMessage.SearchAndReplace('#',sCommand);
+ }
+
+ SQLContext aContext;
+ aContext.Message = sErrorMessage;
+ aContext.NextException = aErrorInfo.get();
+ ::dbtools::showError( aContext, VCLUnoHelper::GetInterface( const_cast< FormLinkDialog* >( this ) ), m_xORB );
+ }
+ }
+
+ //------------------------------------------------------------------------
+ void FormLinkDialog::ensureFormConnection( const Reference< XPropertySet >& _rxFormProps, Reference< XConnection >& /* [out] */ _rxConnection ) const SAL_THROW(( Exception ))
+ {
+ OSL_PRECOND( _rxFormProps.is(), "FormLinkDialog::ensureFormConnection: invalid form!" );
+ if ( !_rxFormProps.is() )
+ return;
+ if ( _rxFormProps->getPropertySetInfo()->hasPropertyByName(PROPERTY_ACTIVE_CONNECTION) )
+ _rxConnection.set(_rxFormProps->getPropertyValue(PROPERTY_ACTIVE_CONNECTION),UNO_QUERY);
+
+ if ( !_rxConnection.is() )
+ _rxConnection = ::dbtools::connectRowset( Reference< XRowSet >( _rxFormProps, UNO_QUERY ), m_xORB, sal_True );
+ }
+
+ //------------------------------------------------------------------------
+ void FormLinkDialog::getConnectionMetaData( const Reference< XPropertySet >& _rxFormProps, Reference< XDatabaseMetaData >& /* [out] */ _rxMeta ) const SAL_THROW(( Exception ))
+ {
+ if ( _rxFormProps.is() )
+ {
+ Reference< XConnection > xConnection;
+ if ( !::dbtools::isEmbeddedInDatabase( _rxFormProps, xConnection ) )
+ _rxFormProps->getPropertyValue( PROPERTY_ACTIVE_CONNECTION ) >>= xConnection;
+ if ( xConnection.is() )
+ _rxMeta = xConnection->getMetaData();
+ }
+ }
+
+ //------------------------------------------------------------------------
+ Reference< XPropertySet > FormLinkDialog::getCanonicUnderlyingTable( const Reference< XPropertySet >& _rxFormProps ) const
+ {
+ Reference< XPropertySet > xTable;
+ try
+ {
+ Reference< XTablesSupplier > xTablesInForm( ::dbtools::getCurrentSettingsComposer( _rxFormProps, m_xORB ), UNO_QUERY );
+ Reference< XNameAccess > xTables;
+ if ( xTablesInForm.is() )
+ xTables = xTablesInForm->getTables();
+ Sequence< ::rtl::OUString > aTableNames;
+ if ( xTables.is() )
+ aTableNames = xTables->getElementNames();
+
+ if ( aTableNames.getLength() == 1 )
+ {
+ xTables->getByName( aTableNames[ 0 ] ) >>= xTable;
+ OSL_ENSURE( xTable.is(), "FormLinkDialog::getCanonicUnderlyingTable: invalid table!" );
+ }
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "FormLinkDialog::getCanonicUnderlyingTable: caught an exception!" );
+ }
+ return xTable;
+ }
+
+ //------------------------------------------------------------------------
+ sal_Bool FormLinkDialog::getExistingRelation( const Reference< XPropertySet >& _rxLHS, const Reference< XPropertySet >& /*_rxRHS*/,
+ // TODO: fix the usage of _rxRHS. This is issue #i81956#.
+ Sequence< ::rtl::OUString >& _rLeftFields, Sequence< ::rtl::OUString >& _rRightFields ) const
+ {
+ try
+ {
+ Reference< XKeysSupplier > xSuppKeys( _rxLHS, UNO_QUERY );
+ Reference< XIndexAccess > xKeys;
+ if ( xSuppKeys.is() )
+ xKeys = xSuppKeys->getKeys();
+
+ if ( xKeys.is() )
+ {
+ Reference< XPropertySet > xKey;
+ Reference< XColumnsSupplier > xKeyColSupp( xKey, UNO_QUERY );
+ Reference< XIndexAccess > xKeyColumns;
+ Reference< XPropertySet > xKeyColumn;
+ ::rtl::OUString sColumnName, sRelatedColumnName;
+
+ const sal_Int32 keyCount = xKeys->getCount();
+ for ( sal_Int32 key = 0; key < keyCount; ++key )
+ {
+ xKeys->getByIndex( key ) >>= xKey;
+ sal_Int32 nKeyType = 0;
+ xKey->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Type" ) ) ) >>= nKeyType;
+ if ( nKeyType != KeyType::FOREIGN )
+ continue;
+
+ xKeyColumns.clear();
+ xKeyColSupp = xKeyColSupp.query( xKey );
+ if ( xKeyColSupp.is() )
+ xKeyColumns = xKeyColumns.query( xKeyColSupp->getColumns() );
+ OSL_ENSURE( xKeyColumns.is(), "FormLinkDialog::getExistingRelation: could not obtain the columns for the key!" );
+
+ if ( !xKeyColumns.is() )
+ continue;
+
+ const sal_Int32 columnCount = xKeyColumns->getCount();
+ _rLeftFields.realloc( columnCount );
+ _rRightFields.realloc( columnCount );
+ for ( sal_Int32 column = 0; column < columnCount; ++column )
+ {
+ xKeyColumn.clear();
+ xKeyColumns->getByIndex( column ) >>= xKeyColumn;
+ OSL_ENSURE( xKeyColumn.is(), "FormLinkDialog::getExistingRelation: invalid key column!" );
+ if ( xKeyColumn.is() )
+ {
+ xKeyColumn->getPropertyValue( PROPERTY_NAME ) >>= sColumnName;
+ xKeyColumn->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "RelatedColumn" ) ) ) >>= sRelatedColumnName;
+
+ _rLeftFields[ column ] = sColumnName;
+ _rRightFields[ column ] = sRelatedColumnName;
+ }
+ }
+ }
+ }
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "FormLinkDialog::getExistingRelation: caught an exception!" );
+ }
+
+ return ( _rLeftFields.getLength() > 0 ) && ( _rLeftFields[ 0 ].getLength() > 0 );
+ }
+
+ //------------------------------------------------------------------------
+ void FormLinkDialog::initializeSuggest()
+ {
+ Reference< XPropertySet > xDetailFormProps( m_xDetailForm, UNO_QUERY );
+ Reference< XPropertySet > xMasterFormProps( m_xMasterForm, UNO_QUERY );
+ if ( !xDetailFormProps.is() || !xMasterFormProps.is() )
+ return;
+
+ try
+ {
+ sal_Bool bEnable = sal_True;
+
+ // only show the button when both forms are based on the same data source
+ if ( bEnable )
+ {
+ ::rtl::OUString sMasterDS, sDetailDS;
+ xMasterFormProps->getPropertyValue( PROPERTY_DATASOURCE ) >>= sMasterDS;
+ xDetailFormProps->getPropertyValue( PROPERTY_DATASOURCE ) >>= sDetailDS;
+ bEnable = ( sMasterDS == sDetailDS );
+ }
+
+ // only show the button when the connection supports relations
+ if ( bEnable )
+ {
+ Reference< XDatabaseMetaData > xMeta;
+ getConnectionMetaData( xDetailFormProps, xMeta );
+ OSL_ENSURE( xMeta.is(), "FormLinkDialog::initializeSuggest: unable to retrieve the meta data for the connection!" );
+ try
+ {
+ bEnable = xMeta.is() && xMeta->supportsIntegrityEnhancementFacility();
+ }
+ catch(const Exception&)
+ {
+ bEnable = sal_False;
+ }
+ }
+
+ // only enable the button if there is a "canonic" table underlying both forms
+ Reference< XPropertySet > xDetailTable, xMasterTable;
+ if ( bEnable )
+ {
+ xDetailTable = getCanonicUnderlyingTable( xDetailFormProps );
+ xMasterTable = getCanonicUnderlyingTable( xMasterFormProps );
+ bEnable = xDetailTable.is() && xMasterTable.is();
+ }
+
+ // only enable the button if there is a relation between both tables
+ m_aRelationDetailColumns.realloc( 0 );
+ m_aRelationMasterColumns.realloc( 0 );
+ if ( bEnable )
+ {
+ bEnable = getExistingRelation( xDetailTable, xMasterTable, m_aRelationDetailColumns, m_aRelationMasterColumns );
+ OSL_POSTCOND( m_aRelationMasterColumns.getLength() == m_aRelationDetailColumns.getLength(), "FormLinkDialog::initializeSuggest: nonsense!" );
+ if ( m_aRelationMasterColumns.getLength() == 0 )
+ { // okay, there is no relation "pointing" (via a foreign key) from the detail table to the master table
+ // but perhaps the other way round (would make less sense, but who knows ...)
+ bEnable = getExistingRelation( xMasterTable, xDetailTable, m_aRelationMasterColumns, m_aRelationDetailColumns );
+ }
+ }
+
+ // only enable the button if the relation contains at most 4 field pairs
+ if ( bEnable )
+ {
+ bEnable = ( m_aRelationMasterColumns.getLength() <= 4 );
+ }
+
+ m_aSuggest.Enable( bEnable );
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "FormLinkDialog::initializeSuggest: caught an exception!" );
+ }
+ }
+
+ //------------------------------------------------------------------------
+ IMPL_LINK( FormLinkDialog, OnSuggest, void*, /*_pNotInterestedIn*/ )
+ {
+ initializeFieldRowsFrom( m_aRelationDetailColumns, m_aRelationMasterColumns );
+ return 0L;
+ }
+
+ //------------------------------------------------------------------------
+ IMPL_LINK( FormLinkDialog, OnFieldChanged, FieldLinkRow*, /*_pRow*/ )
+ {
+ updateOkButton();
+ return 0L;
+ }
+
+ //------------------------------------------------------------------------
+ IMPL_LINK( FormLinkDialog, OnInitialize, void*, /*_pNotInterestedIn*/ )
+ {
+ initializeColumnLabels();
+ initializeFieldLists();
+ initializeLinks();
+ initializeSuggest();
+ return 0L;
+ }
+//............................................................................
+} // namespace pcr
+//............................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/propctrlr/formlinkdialog.hrc b/extensions/source/propctrlr/formlinkdialog.hrc
new file mode 100644
index 000000000000..25a179352d66
--- /dev/null
+++ b/extensions/source/propctrlr/formlinkdialog.hrc
@@ -0,0 +1,44 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef EXTENSIONS_SOURCE_PROPCTRLR_FORMLINKDIALOG_HRC
+#define EXTENSIONS_SOURCE_PROPCTRLR_FORMLINKDIALOG_HRC
+
+#define FT_EXPLANATION 1
+#define FT_DETAIL_LABEL 2
+#define FT_MASTER_LABEL 3
+
+#define PB_OK 1
+#define PB_CANCEL 2
+#define PB_HELP 3
+#define PB_SUGGEST 4
+
+#define STR_DETAIL_FORM 1
+#define STR_MASTER_FORM 2
+#define STR_ERROR_RETRIEVING_COLUMNS 3
+
+#endif // EXTENSIONS_SOURCE_PROPCTRLR_FORMLINKDIALOG_HRC
diff --git a/extensions/source/propctrlr/formlinkdialog.hxx b/extensions/source/propctrlr/formlinkdialog.hxx
new file mode 100644
index 000000000000..04d35cc9fc6e
--- /dev/null
+++ b/extensions/source/propctrlr/formlinkdialog.hxx
@@ -0,0 +1,151 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef EXTENSIONS_SOURCE_PROPCTRLR_FORMLINKDIALOG_HXX
+#define EXTENSIONS_SOURCE_PROPCTRLR_FORMLINKDIALOG_HXX
+
+#include <vcl/dialog.hxx>
+#include <vcl/fixed.hxx>
+#include <vcl/button.hxx>
+
+/** === begin UNO includes === **/
+#include <com/sun/star/form/XForm.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/sdbc/XConnection.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+/** === end UNO includes === **/
+
+#include <memory>
+
+//............................................................................
+namespace pcr
+{
+//............................................................................
+
+ class FieldLinkRow;
+ //========================================================================
+ //= FormLinkDialog
+ //========================================================================
+ class FormLinkDialog : public ModalDialog
+ {
+ private:
+ FixedText m_aExplanation;
+ FixedText m_aDetailLabel;
+ FixedText m_aMasterLabel;
+ ::std::auto_ptr< FieldLinkRow > m_aRow1;
+ ::std::auto_ptr< FieldLinkRow > m_aRow2;
+ ::std::auto_ptr< FieldLinkRow > m_aRow3;
+ ::std::auto_ptr< FieldLinkRow > m_aRow4;
+ OKButton m_aOK;
+ CancelButton m_aCancel;
+ HelpButton m_aHelp;
+ PushButton m_aSuggest;
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >
+ m_xORB;
+ ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >
+ m_xDetailForm;
+ ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >
+ m_xMasterForm;
+
+ ::com::sun::star::uno::Sequence< ::rtl::OUString >
+ m_aRelationDetailColumns;
+ ::com::sun::star::uno::Sequence< ::rtl::OUString >
+ m_aRelationMasterColumns;
+
+ ::rtl::OUString m_sDetailLabel;
+ ::rtl::OUString m_sMasterLabel;
+
+ public:
+ FormLinkDialog(
+ Window* _pParent,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxDetailForm,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxMasterForm,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB,
+ const ::rtl::OUString& _sExplanation = ::rtl::OUString(),
+ const ::rtl::OUString& _sDetailLabel = ::rtl::OUString(),
+ const ::rtl::OUString& _sMasterLabel = ::rtl::OUString()
+ );
+ ~FormLinkDialog( );
+
+ // Dialog overridables
+ virtual short Execute();
+
+ private:
+ DECL_LINK( OnSuggest, void* );
+ DECL_LINK( OnFieldChanged, FieldLinkRow* );
+ DECL_LINK( OnInitialize, void* );
+
+ void updateOkButton();
+ void initializeFieldLists();
+ void initializeColumnLabels();
+ void initializeLinks();
+ void initializeSuggest();
+ void commitLinkPairs();
+
+ void initializeFieldRowsFrom(
+ ::com::sun::star::uno::Sequence< ::rtl::OUString >& _rDetailFields,
+ ::com::sun::star::uno::Sequence< ::rtl::OUString >& _rMasterFields
+ );
+
+ String getFormDataSourceType(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxForm
+ ) const SAL_THROW(());
+
+ void getFormFields(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxForm,
+ ::com::sun::star::uno::Sequence< ::rtl::OUString >& /* [out] */ _rNames
+ ) const SAL_THROW(());
+
+ void ensureFormConnection(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxFormProps,
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& /* [out] */ _rxConnection
+ ) const SAL_THROW(( ::com::sun::star::uno::Exception ));
+
+ void getConnectionMetaData(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxFormProps,
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData >& /* [out] */ _rxMeta
+ ) const SAL_THROW(( ::com::sun::star::uno::Exception ));
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >
+ getCanonicUnderlyingTable( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxFormProps ) const;
+ sal_Bool getExistingRelation(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxLHS,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxRHS,
+ ::com::sun::star::uno::Sequence< ::rtl::OUString >& /* [out] */ _rLeftFields,
+ ::com::sun::star::uno::Sequence< ::rtl::OUString >& /* [out] */ _rRightFields
+ ) const;
+ };
+
+//............................................................................
+} // namespace pcr
+//............................................................................
+
+#endif // EXTENSIONS_SOURCE_PROPCTRLR_FORMLINKDIALOG_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/propctrlr/formlinkdialog.src b/extensions/source/propctrlr/formlinkdialog.src
new file mode 100644
index 000000000000..ca936a58d4d4
--- /dev/null
+++ b/extensions/source/propctrlr/formlinkdialog.src
@@ -0,0 +1,160 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _EXTENSIONS_FORMCTRLR_PROPRESID_HRC_
+#include "formresid.hrc"
+#endif
+#include "propctrlr.hrc"
+#ifndef EXTENSIONS_SOURCE_PROPCTRLR_FORMLINKDIALOG_HRC
+#include "formlinkdialog.hrc"
+#endif
+
+ModalDialog RID_DLG_FORMLINKS
+{
+ OutputSize = TRUE ;
+ Moveable = TRUE ;
+ Closeable = TRUE ;
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( 252, 110 ) ;
+
+ Text [ en-US ] = "Link fields";
+
+ FixedText FT_EXPLANATION
+ {
+ Pos = MAP_APPFONT( 6, 6 );
+ Size = MAP_APPFONT( 187, 24 );
+
+ WordBreak = TRUE;
+
+ Text [ en-US ] = "Sub forms can be used to display detailed data about the current record of the master form. To do this, you can specify which columns in the sub form match which columns in the master form.";
+ };
+
+ FixedText FT_DETAIL_LABEL
+ {
+ Pos = MAP_APPFONT( 6, 36 );
+ Size = MAP_APPFONT( 85, 8 );
+ };
+
+ FixedText FT_MASTER_LABEL
+ {
+ Pos = MAP_APPFONT( 102, 36 );
+ Size = MAP_APPFONT( 85, 8 );
+ };
+
+#define ROW( n ) \
+ Window n \
+ { \
+ Pos = MAP_APPFONT( 6, 47 + 15 * ( n - 1 ) ); \
+ Size = MAP_APPFONT( 181, 13 ); \
+ \
+ Hide = FALSE; \
+ DialogControl = TRUE; \
+ \
+ ComboBox 1 \
+ { \
+ Pos = MAP_APPFONT( 0, 0 ); \
+ Size = MAP_APPFONT( 85, 12 ); \
+ \
+ DropDown = TRUE; \
+ TabStop = TRUE; \
+ \
+ HelpId = HID_FIELDLINK_DETAIL_COLUMN; \
+ UniqueId = UID_FIELDLINK_DETAIL#n; \
+ }; \
+ FixedText 1 \
+ { \
+ Pos = MAP_APPFONT( 85, 0 ); \
+ Size = MAP_APPFONT( 10, 12 ); \
+ Center = TRUE; \
+ }; \
+ ComboBox 2 \
+ { \
+ Pos = MAP_APPFONT( 95, 0 ); \
+ Size = MAP_APPFONT( 85, 12 ); \
+ \
+ DropDown = TRUE; \
+ TabStop = TRUE; \
+ \
+ HelpId = HID_FIELDLINK_MASTER_COLUMN; \
+ UniqueId = UID_FIELDLINK_MASTER#n; \
+ }; \
+ }
+
+ ROW( 1 );
+ ROW( 2 );
+ ROW( 3 );
+ ROW( 4 );
+
+ OKButton PB_OK
+ {
+ Pos = MAP_APPFONT( 199, 6 );
+ Size = MAP_APPFONT( 50, 14 );
+ TabStop = TRUE;
+ DefButton = TRUE;
+ };
+
+ CancelButton PB_CANCEL
+ {
+ Pos = MAP_APPFONT( 199, 23 );
+ Size = MAP_APPFONT( 50, 14 );
+ TabStop = TRUE;
+ };
+
+ HelpButton PB_HELP
+ {
+ Pos = MAP_APPFONT( 199, 43 );
+ Size = MAP_APPFONT( 50, 14 );
+ TabStop = TRUE;
+ };
+
+ PushButton PB_SUGGEST
+ {
+ Pos = MAP_APPFONT( 199, 90 );
+ Size = MAP_APPFONT( 50, 14 );
+ TabStop = TRUE;
+ Hide = FALSE;
+ Disable = TRUE;
+
+ Text [ en-US ] = "Suggest";
+ };
+
+ String STR_DETAIL_FORM
+ {
+ Text [ en-US ] = "Sub Form";
+ };
+
+ String STR_MASTER_FORM
+ {
+ Text [ en-US ] = "Master Form";
+ };
+
+ String STR_ERROR_RETRIEVING_COLUMNS
+ {
+ Text [ en-US ] = "The columns of '#' could not be retrieved.";
+ Text [ x-comment ] ="# will be replace with a name.";
+ };
+};
diff --git a/extensions/source/propctrlr/formlocalid.hrc b/extensions/source/propctrlr/formlocalid.hrc
new file mode 100644
index 000000000000..387a1418a000
--- /dev/null
+++ b/extensions/source/propctrlr/formlocalid.hrc
@@ -0,0 +1,39 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _EXTENSIONS_PROPCTRLR_FORMLOCALID_HRC_
+#define _EXTENSIONS_PROPCTRLR_FORMLOCALID_HRC_
+
+#define TABPAGE_CHARACTERS 1
+#define TABPAGE_CHARACTERS_EXT 2
+
+#define IMG_PLUS 1
+#define IMG_MINUS 2
+#define IMG_PLUS_HC 3
+#define IMG_MINUS_HC 4
+
+#endif // _EXTENSIONS_PROPCTRLR_FORMLOCALID_HRC_
diff --git a/extensions/source/propctrlr/formmetadata.cxx b/extensions/source/propctrlr/formmetadata.cxx
new file mode 100644
index 000000000000..ae14c90c2b44
--- /dev/null
+++ b/extensions/source/propctrlr/formmetadata.cxx
@@ -0,0 +1,705 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+#include "formmetadata.hxx"
+#include "propctrlr.hrc"
+#include "formstrings.hxx"
+#include "formresid.hrc"
+#include "propctrlr.hrc"
+#include <svtools/localresaccess.hxx>
+#include <tools/debug.hxx>
+#include <cppuhelper/extract.hxx>
+
+#include <algorithm>
+#include <functional>
+
+//............................................................................
+namespace pcr
+{
+//............................................................................
+
+ using namespace ::com::sun::star::uno;
+
+ //========================================================================
+ //= OPropertyInfoImpl
+ //========================================================================
+ struct OPropertyInfoImpl
+ {
+ String sName;
+ String sTranslation;
+ sal_uInt32 nHelpId;
+ sal_Int32 nId;
+ sal_uInt16 nPos;
+ sal_uInt32 nUIFlags;
+
+ OPropertyInfoImpl(
+ const ::rtl::OUString& rName,
+ sal_Int32 _nId,
+ const String& aTranslation,
+ sal_uInt16 nPosId,
+ sal_uInt32 nHelpId,
+ sal_uInt32 _nUIFlags);
+ };
+
+ //------------------------------------------------------------------------
+ OPropertyInfoImpl::OPropertyInfoImpl(const ::rtl::OUString& _rName, sal_Int32 _nId,
+ const String& aString, sal_uInt16 nP, sal_uInt32 nHid, sal_uInt32 _nUIFlags)
+ :sName(_rName)
+ ,sTranslation(aString)
+ ,nHelpId(nHid)
+ ,nId(_nId)
+ ,nPos(nP)
+ ,nUIFlags(_nUIFlags)
+ {
+ }
+
+ //------------------------------------------------------------------------
+ // Vergleichen von PropertyInfo
+ struct PropertyInfoLessByName : public ::std::binary_function< OPropertyInfoImpl, OPropertyInfoImpl, bool >
+ {
+ bool operator()( const OPropertyInfoImpl& _rLHS, const OPropertyInfoImpl& _rRHS )
+ {
+ return _rLHS.sName.CompareTo( _rRHS.sName ) == COMPARE_LESS;
+ }
+ };
+
+ //========================================================================
+ //= OPropertyInfoService
+ //========================================================================
+#define DEF_INFO( ident, uinameres, helpid, flags ) \
+ OPropertyInfoImpl( PROPERTY_##ident, PROPERTY_ID_##ident, \
+ String( PcrRes( RID_STR_##uinameres ) ), nPos++, HID_PROP_##helpid, flags )
+
+#define DEF_INFO_1( ident, uinameres, helpid, flag1 ) \
+ DEF_INFO( ident, uinameres, helpid, PROP_FLAG_##flag1 )
+
+#define DEF_INFO_2( ident, uinameres, helpid, flag1, flag2 ) \
+ DEF_INFO( ident, uinameres, helpid, PROP_FLAG_##flag1 | PROP_FLAG_##flag2 )
+
+#define DEF_INFO_3( ident, uinameres, helpid, flag1, flag2, flag3 ) \
+ DEF_INFO( ident, uinameres, helpid, PROP_FLAG_##flag1 | PROP_FLAG_##flag2 | PROP_FLAG_##flag3 )
+
+#define DEF_INFO_4( ident, uinameres, helpid, flag1, flag2, flag3, flag4 ) \
+ DEF_INFO( ident, uinameres, helpid, PROP_FLAG_##flag1 | PROP_FLAG_##flag2 | PROP_FLAG_##flag3 | PROP_FLAG_##flag4 )
+
+#define DEF_INFO_5( ident, uinameres, helpid, flag1, flag2, flag3, flag4, flag5 ) \
+ DEF_INFO( ident, uinameres, helpid, PROP_FLAG_##flag1 | PROP_FLAG_##flag2 | PROP_FLAG_##flag3 | PROP_FLAG_##flag4 | PROP_FLAG_##flag5 )
+
+ sal_uInt16 OPropertyInfoService::s_nCount = 0;
+ OPropertyInfoImpl* OPropertyInfoService::s_pPropertyInfos = NULL;
+ //------------------------------------------------------------------------
+ const OPropertyInfoImpl* OPropertyInfoService::getPropertyInfo()
+ {
+ if ( s_pPropertyInfos )
+ return s_pPropertyInfos;
+
+ PcrClient aResourceAccess;
+ // this ensures that we have our resource file loaded
+
+ sal_uInt16 nPos = 1;
+
+ static OPropertyInfoImpl aPropertyInfos[] =
+ {
+ /*
+ DEF_INFO_?( propname and id, resoure id, help id, flags ),
+ */
+ DEF_INFO_3( NAME, NAME, NAME, FORM_VISIBLE, DIALOG_VISIBLE, COMPOSEABLE ),
+ DEF_INFO_2( TITLE, TITLE, TITLE, FORM_VISIBLE, DIALOG_VISIBLE ),
+ DEF_INFO_3( LABEL, LABEL, LABEL, FORM_VISIBLE, DIALOG_VISIBLE, COMPOSEABLE ),
+ DEF_INFO_2( CONTROLLABEL, LABELCONTROL, CONTROLLABEL, FORM_VISIBLE, COMPOSEABLE ),
+ DEF_INFO_3( WRITING_MODE, WRITING_MODE, WRITING_MODE, FORM_VISIBLE, ENUM, COMPOSEABLE ),
+ DEF_INFO_3( GROUP_NAME, GROUP_NAME, GROUP_NAME, FORM_VISIBLE, DIALOG_VISIBLE, COMPOSEABLE ),
+ DEF_INFO_2( TEXT, TEXT, TEXT, DIALOG_VISIBLE, COMPOSEABLE ),
+ DEF_INFO_3( MAXTEXTLEN, MAXTEXTLEN, MAXTEXTLEN, FORM_VISIBLE, DIALOG_VISIBLE, COMPOSEABLE ),
+ DEF_INFO_3( EDITMASK, EDITMASK, EDITMASK, FORM_VISIBLE, DIALOG_VISIBLE, COMPOSEABLE ),
+ DEF_INFO_3( LITERALMASK, LITERALMASK, LITERALMASK, FORM_VISIBLE, DIALOG_VISIBLE, COMPOSEABLE ),
+ DEF_INFO_3( STRICTFORMAT, STRICTFORMAT, STRICTFORMAT, FORM_VISIBLE, DIALOG_VISIBLE, COMPOSEABLE ),
+ DEF_INFO_3( ENABLED, ENABLED, ENABLED, FORM_VISIBLE, DIALOG_VISIBLE, COMPOSEABLE ),
+ DEF_INFO_3( ENABLE_VISIBLE, ENABLE_VISIBLE, ENABLE_VISIBLE, FORM_VISIBLE, DIALOG_VISIBLE, COMPOSEABLE ),
+ DEF_INFO_3( READONLY, READONLY, READONLY, FORM_VISIBLE, DIALOG_VISIBLE, COMPOSEABLE ),
+ DEF_INFO_3( PRINTABLE, PRINTABLE, PRINTABLE, FORM_VISIBLE, DIALOG_VISIBLE, COMPOSEABLE ),
+ DEF_INFO_3( STEP, STEP, STEP, FORM_VISIBLE, DIALOG_VISIBLE, COMPOSEABLE ),
+ DEF_INFO_3( TABSTOP, TABSTOP, TABSTOP, FORM_VISIBLE, DIALOG_VISIBLE, COMPOSEABLE ),
+ DEF_INFO_2( TABINDEX, TABINDEX, TABINDEX, FORM_VISIBLE, DIALOG_VISIBLE ),
+ DEF_INFO_3( WHEEL_BEHAVIOR, WHEEL_BEHAVIOR, WHEEL_BEHAVIOR, FORM_VISIBLE, ENUM, COMPOSEABLE ),
+
+ DEF_INFO_2( BOUND_CELL, BOUND_CELL, BOUND_CELL, FORM_VISIBLE, DATA_PROPERTY ),
+ DEF_INFO_3( CELL_EXCHANGE_TYPE,CELL_EXCHANGE_TYPE, CELL_EXCHANGE_TYPE,FORM_VISIBLE, DATA_PROPERTY, ENUM ),
+ DEF_INFO_2( LIST_CELL_RANGE, LIST_CELL_RANGE, LIST_CELL_RANGE, FORM_VISIBLE, DATA_PROPERTY ),
+ DEF_INFO_3( CONTROLSOURCE, CONTROLSOURCE, CONTROLSOURCE, FORM_VISIBLE, DATA_PROPERTY, COMPOSEABLE ),
+ DEF_INFO_3( EMPTY_IS_NULL, EMPTY_IS_NULL, EMPTY_IS_NULL, FORM_VISIBLE, DATA_PROPERTY, COMPOSEABLE ),
+ DEF_INFO_3( INPUT_REQUIRED, INPUT_REQUIRED, INPUT_REQUIRED, FORM_VISIBLE, DATA_PROPERTY, COMPOSEABLE ),
+ DEF_INFO_3( REFVALUE, REFVALUE, REFVALUE, FORM_VISIBLE, DATA_PROPERTY, COMPOSEABLE ),
+ DEF_INFO_3( UNCHECKEDREFVALUE, UNCHECKEDREFVALUE, UNCHECKEDREFVALUE, FORM_VISIBLE, DATA_PROPERTY, COMPOSEABLE ),
+ DEF_INFO_3( DATASOURCE, DATASOURCE, DATASOURCE, FORM_VISIBLE, DATA_PROPERTY, COMPOSEABLE ),
+ DEF_INFO_4( COMMANDTYPE, CURSORSOURCETYPE, CURSORSOURCETYPE, FORM_VISIBLE, DATA_PROPERTY, ENUM, COMPOSEABLE ),
+ DEF_INFO_3( COMMAND, CURSORSOURCE, CURSORSOURCE, FORM_VISIBLE, DATA_PROPERTY, COMPOSEABLE ),
+ DEF_INFO_3( ESCAPE_PROCESSING, ESCAPE_PROCESSING, ESCAPE_PROCESSING, FORM_VISIBLE, DATA_PROPERTY, COMPOSEABLE ),
+ DEF_INFO_3( FILTER, FILTER, FILTER, FORM_VISIBLE, DATA_PROPERTY, COMPOSEABLE ),
+ DEF_INFO_3( SORT, SORT_CRITERIA, SORT_CRITERIA, FORM_VISIBLE, DATA_PROPERTY, COMPOSEABLE ),
+ DEF_INFO_2( MASTERFIELDS, MASTERFIELDS, MASTERFIELDS, FORM_VISIBLE, DATA_PROPERTY ),
+ DEF_INFO_2( DETAILFIELDS, SLAVEFIELDS, SLAVEFIELDS, FORM_VISIBLE, DATA_PROPERTY ),
+ DEF_INFO_3( ALLOWADDITIONS, ALLOW_ADDITIONS, ALLOW_ADDITIONS, FORM_VISIBLE, DATA_PROPERTY, COMPOSEABLE ),
+ DEF_INFO_3( ALLOWEDITS, ALLOW_EDITS, ALLOW_EDITS, FORM_VISIBLE, DATA_PROPERTY, COMPOSEABLE ),
+ DEF_INFO_3( ALLOWDELETIONS, ALLOW_DELETIONS, ALLOW_DELETIONS, FORM_VISIBLE, DATA_PROPERTY, COMPOSEABLE ),
+ DEF_INFO_4( INSERTONLY, DATAENTRY, DATAENTRY, FORM_VISIBLE, DATA_PROPERTY, COMPOSEABLE, COMPOSEABLE ),
+ DEF_INFO_4( NAVIGATION, NAVIGATION, NAVIGATION, FORM_VISIBLE, DATA_PROPERTY, ENUM, COMPOSEABLE ),
+ DEF_INFO_4( CYCLE, CYCLE, CYCLE, FORM_VISIBLE, DATA_PROPERTY, ENUM, COMPOSEABLE ),
+ DEF_INFO_3( FILTERPROPOSAL, FILTERPROPOSAL, FILTERPROPOSAL, FORM_VISIBLE, DATA_PROPERTY, COMPOSEABLE ),
+ DEF_INFO_4( LISTSOURCETYPE, LISTSOURCETYPE, LISTSOURCETYPE, FORM_VISIBLE, DATA_PROPERTY, ENUM, COMPOSEABLE ),
+ DEF_INFO_3( LISTSOURCE, LISTSOURCE, LISTSOURCE, FORM_VISIBLE, DATA_PROPERTY, COMPOSEABLE ),
+ DEF_INFO_3( BOUNDCOLUMN, BOUNDCOLUMN, BOUNDCOLUMN, FORM_VISIBLE, DATA_PROPERTY, COMPOSEABLE ),
+
+ // <!----------------->
+ // XML node binding
+ DEF_INFO_2( LIST_BINDING, LIST_BINDING, LIST_BINDING, FORM_VISIBLE, DATA_PROPERTY ),
+ DEF_INFO_2( XML_DATA_MODEL, XML_DATA_MODEL, XML_DATA_MODEL, FORM_VISIBLE, DATA_PROPERTY ),
+ DEF_INFO_2( BINDING_NAME, BINDING_NAME, BINDING_NAME, FORM_VISIBLE, DATA_PROPERTY ),
+ DEF_INFO_2( BIND_EXPRESSION, BIND_EXPRESSION, BIND_EXPRESSION, FORM_VISIBLE, DATA_PROPERTY ),
+ DEF_INFO_2( XSD_REQUIRED, XSD_REQUIRED, XSD_REQUIRED, FORM_VISIBLE, DATA_PROPERTY ),
+ DEF_INFO_2( XSD_RELEVANT, XSD_RELEVANT, XSD_RELEVANT, FORM_VISIBLE, DATA_PROPERTY ),
+ DEF_INFO_2( XSD_READONLY, XSD_READONLY, XSD_READONLY, FORM_VISIBLE, DATA_PROPERTY ),
+ DEF_INFO_2( XSD_CONSTRAINT, XSD_CONSTRAINT, XSD_CONSTRAINT, FORM_VISIBLE, DATA_PROPERTY ),
+ DEF_INFO_2( XSD_CALCULATION, XSD_CALCULATION, XSD_CALCULATION, FORM_VISIBLE, DATA_PROPERTY ),
+
+ // data type
+ DEF_INFO_2( XSD_DATA_TYPE, XSD_DATA_TYPE, XSD_DATA_TYPE, FORM_VISIBLE, DATA_PROPERTY ),
+ // data types facets
+ // common
+ DEF_INFO_3( XSD_WHITESPACES, XSD_WHITESPACES, XSD_WHITESPACES, FORM_VISIBLE, DATA_PROPERTY, ENUM ),
+ DEF_INFO_2( XSD_PATTERN, XSD_PATTERN, XSD_PATTERN, FORM_VISIBLE, DATA_PROPERTY ),
+ // string
+ DEF_INFO_2( XSD_LENGTH, XSD_LENGTH, XSD_LENGTH, FORM_VISIBLE, DATA_PROPERTY ),
+ DEF_INFO_2( XSD_MIN_LENGTH, XSD_MIN_LENGTH, XSD_MIN_LENGTH, FORM_VISIBLE, DATA_PROPERTY ),
+ DEF_INFO_2( XSD_MAX_LENGTH, XSD_MAX_LENGTH, XSD_MAX_LENGTH, FORM_VISIBLE, DATA_PROPERTY ),
+ // decimal
+ DEF_INFO_2( XSD_TOTAL_DIGITS, XSD_TOTAL_DIGITS, XSD_TOTAL_DIGITS, FORM_VISIBLE, DATA_PROPERTY ),
+ DEF_INFO_2( XSD_FRACTION_DIGITS,XSD_FRACTION_DIGITS,XSD_FRACTION_DIGITS,FORM_VISIBLE, DATA_PROPERTY ),
+ // int value types (year, month, day)
+ DEF_INFO_2( XSD_MAX_INCLUSIVE_INT, XSD_MAX_INCLUSIVE, XSD_MAX_INCLUSIVE, FORM_VISIBLE, DATA_PROPERTY ),
+ DEF_INFO_2( XSD_MAX_EXCLUSIVE_INT, XSD_MAX_EXCLUSIVE, XSD_MAX_EXCLUSIVE, FORM_VISIBLE, DATA_PROPERTY ),
+ DEF_INFO_2( XSD_MIN_INCLUSIVE_INT, XSD_MIN_INCLUSIVE, XSD_MIN_INCLUSIVE, FORM_VISIBLE, DATA_PROPERTY ),
+ DEF_INFO_2( XSD_MIN_EXCLUSIVE_INT, XSD_MIN_EXCLUSIVE, XSD_MIN_EXCLUSIVE, FORM_VISIBLE, DATA_PROPERTY ),
+ // double value types (double, float, decimal)
+ DEF_INFO_2( XSD_MAX_INCLUSIVE_DOUBLE, XSD_MAX_INCLUSIVE, XSD_MAX_INCLUSIVE, FORM_VISIBLE, DATA_PROPERTY ),
+ DEF_INFO_2( XSD_MAX_EXCLUSIVE_DOUBLE, XSD_MAX_EXCLUSIVE, XSD_MAX_EXCLUSIVE, FORM_VISIBLE, DATA_PROPERTY ),
+ DEF_INFO_2( XSD_MIN_INCLUSIVE_DOUBLE, XSD_MIN_INCLUSIVE, XSD_MIN_INCLUSIVE, FORM_VISIBLE, DATA_PROPERTY ),
+ DEF_INFO_2( XSD_MIN_EXCLUSIVE_DOUBLE, XSD_MIN_EXCLUSIVE, XSD_MIN_EXCLUSIVE, FORM_VISIBLE, DATA_PROPERTY ),
+ // date value type
+ DEF_INFO_2( XSD_MAX_INCLUSIVE_DATE, XSD_MAX_INCLUSIVE, XSD_MAX_INCLUSIVE, FORM_VISIBLE, DATA_PROPERTY ),
+ DEF_INFO_2( XSD_MAX_EXCLUSIVE_DATE, XSD_MAX_EXCLUSIVE, XSD_MAX_EXCLUSIVE, FORM_VISIBLE, DATA_PROPERTY ),
+ DEF_INFO_2( XSD_MIN_INCLUSIVE_DATE, XSD_MIN_INCLUSIVE, XSD_MIN_INCLUSIVE, FORM_VISIBLE, DATA_PROPERTY ),
+ DEF_INFO_2( XSD_MIN_EXCLUSIVE_DATE, XSD_MIN_EXCLUSIVE, XSD_MIN_EXCLUSIVE, FORM_VISIBLE, DATA_PROPERTY ),
+ // time value type
+ DEF_INFO_2( XSD_MAX_INCLUSIVE_TIME, XSD_MAX_INCLUSIVE, XSD_MAX_INCLUSIVE, FORM_VISIBLE, DATA_PROPERTY ),
+ DEF_INFO_2( XSD_MAX_EXCLUSIVE_TIME, XSD_MAX_EXCLUSIVE, XSD_MAX_EXCLUSIVE, FORM_VISIBLE, DATA_PROPERTY ),
+ DEF_INFO_2( XSD_MIN_INCLUSIVE_TIME, XSD_MIN_INCLUSIVE, XSD_MIN_INCLUSIVE, FORM_VISIBLE, DATA_PROPERTY ),
+ DEF_INFO_2( XSD_MIN_EXCLUSIVE_TIME, XSD_MIN_EXCLUSIVE, XSD_MIN_EXCLUSIVE, FORM_VISIBLE, DATA_PROPERTY ),
+ // dateTime value type
+ DEF_INFO_2( XSD_MAX_INCLUSIVE_DATE_TIME, XSD_MAX_INCLUSIVE, XSD_MAX_INCLUSIVE, FORM_VISIBLE, DATA_PROPERTY ),
+ DEF_INFO_2( XSD_MAX_EXCLUSIVE_DATE_TIME, XSD_MAX_EXCLUSIVE, XSD_MAX_EXCLUSIVE, FORM_VISIBLE, DATA_PROPERTY ),
+ DEF_INFO_2( XSD_MIN_INCLUSIVE_DATE_TIME, XSD_MIN_INCLUSIVE, XSD_MIN_INCLUSIVE, FORM_VISIBLE, DATA_PROPERTY ),
+ DEF_INFO_2( XSD_MIN_EXCLUSIVE_DATE_TIME, XSD_MIN_EXCLUSIVE, XSD_MIN_EXCLUSIVE, FORM_VISIBLE, DATA_PROPERTY ),
+ // <!----------------->
+
+ DEF_INFO_2( HIDDEN_VALUE, VALUE, HIDDEN_VALUE, FORM_VISIBLE, COMPOSEABLE ),
+ DEF_INFO_2( VALUE, VALUE, VALUE, DIALOG_VISIBLE, COMPOSEABLE ),
+ DEF_INFO_3( VALUEMIN, VALUEMIN, VALUEMIN, FORM_VISIBLE, DIALOG_VISIBLE, COMPOSEABLE ),
+ DEF_INFO_3( VALUEMAX, VALUEMAX, VALUEMAX, FORM_VISIBLE, DIALOG_VISIBLE, COMPOSEABLE ),
+ DEF_INFO_3( VALUESTEP, VALUESTEP, VALUESTEP, FORM_VISIBLE, DIALOG_VISIBLE, COMPOSEABLE ),
+ DEF_INFO_2( DEFAULT_VALUE, DEFAULTVALUE, DEFAULT_LONG_VALUE,FORM_VISIBLE, COMPOSEABLE ),
+ DEF_INFO_3( DECIMAL_ACCURACY, DECIMAL_ACCURACY, DECIMAL_ACCURACY, FORM_VISIBLE, DIALOG_VISIBLE, COMPOSEABLE ),
+ DEF_INFO_3( SHOWTHOUSANDSEP, SHOWTHOUSANDSEP, SHOWTHOUSANDSEP, FORM_VISIBLE, DIALOG_VISIBLE, COMPOSEABLE ),
+
+ DEF_INFO_3( CURRENCYSYMBOL, CURRENCYSYMBOL, CURRENCYSYMBOL, FORM_VISIBLE, DIALOG_VISIBLE, COMPOSEABLE ),
+ DEF_INFO_3( CURRSYM_POSITION, CURRSYM_POSITION, CURRSYM_POSITION, FORM_VISIBLE, DIALOG_VISIBLE, COMPOSEABLE ),
+
+ DEF_INFO_2( DATE, DATE, DATE, DIALOG_VISIBLE, COMPOSEABLE ),
+ DEF_INFO_3( DATEMIN, DATEMIN, DATEMIN, FORM_VISIBLE, DIALOG_VISIBLE, COMPOSEABLE ),
+ DEF_INFO_3( DATEMAX, DATEMAX, DATEMAX, FORM_VISIBLE, DIALOG_VISIBLE, COMPOSEABLE ),
+ DEF_INFO_4( DATEFORMAT, DATEFORMAT, DATEFORMAT, FORM_VISIBLE, DIALOG_VISIBLE, ENUM, COMPOSEABLE ),
+ DEF_INFO_2( DEFAULT_DATE, DEFAULTDATE, DEFAULT_DATE, FORM_VISIBLE, COMPOSEABLE ),
+
+ DEF_INFO_2( TIME, TIME, TIME, DIALOG_VISIBLE, COMPOSEABLE ),
+ DEF_INFO_3( TIMEMIN, TIMEMIN, TIMEMIN, FORM_VISIBLE, DIALOG_VISIBLE, COMPOSEABLE ),
+ DEF_INFO_3( TIMEMAX, TIMEMAX, TIMEMAX, FORM_VISIBLE, DIALOG_VISIBLE, COMPOSEABLE ),
+ DEF_INFO_4( TIMEFORMAT, TIMEFORMAT, TIMEFORMAT, FORM_VISIBLE, DIALOG_VISIBLE, ENUM, COMPOSEABLE ),
+ DEF_INFO_2( DEFAULT_TIME, DEFAULTTIME, DEFAULT_TIME, FORM_VISIBLE, COMPOSEABLE ),
+
+ DEF_INFO_1( EFFECTIVE_VALUE, VALUE, VALUE, DIALOG_VISIBLE ),
+ DEF_INFO_3( EFFECTIVE_MIN, VALUEMIN, EFFECTIVEMIN, FORM_VISIBLE, DIALOG_VISIBLE, COMPOSEABLE ),
+ DEF_INFO_3( EFFECTIVE_MAX, VALUEMAX, EFFECTIVEMAX, FORM_VISIBLE, DIALOG_VISIBLE, COMPOSEABLE ),
+ DEF_INFO_2( EFFECTIVE_DEFAULT, DEFAULTVALUE, EFFECTIVEDEFAULT, FORM_VISIBLE, COMPOSEABLE ),
+ DEF_INFO_3( FORMATKEY, FORMATKEY, FORMATKEY, FORM_VISIBLE, DIALOG_VISIBLE, COMPOSEABLE ),
+
+ DEF_INFO_3( PROGRESSVALUE, PROGRESSVALUE, PROGRESSVALUE, FORM_VISIBLE, DIALOG_VISIBLE, COMPOSEABLE ),
+ DEF_INFO_3( PROGRESSVALUE_MIN, PROGRESSVALUE_MIN, PROGRESSVALUE_MIN, FORM_VISIBLE, DIALOG_VISIBLE, COMPOSEABLE ),
+ DEF_INFO_3( PROGRESSVALUE_MAX, PROGRESSVALUE_MAX, PROGRESSVALUE_MAX, FORM_VISIBLE, DIALOG_VISIBLE, COMPOSEABLE ),
+
+ DEF_INFO_2( SCROLLVALUE, SCROLLVALUE, SCROLLVALUE, DIALOG_VISIBLE, COMPOSEABLE ),
+ DEF_INFO_3( SCROLLVALUE_MIN, SCROLLVALUE_MIN, SCROLLVALUE_MIN, FORM_VISIBLE, DIALOG_VISIBLE, COMPOSEABLE ),
+ DEF_INFO_3( SCROLLVALUE_MAX, SCROLLVALUE_MAX, SCROLLVALUE_MAX, FORM_VISIBLE, DIALOG_VISIBLE, COMPOSEABLE ),
+ DEF_INFO_2( DEFAULT_SCROLLVALUE,DEFAULT_SCROLLVALUE,DEFAULT_SCROLLVALUE,FORM_VISIBLE, COMPOSEABLE ),
+ DEF_INFO_3( LINEINCREMENT, LINEINCREMENT, LINEINCREMENT, FORM_VISIBLE, DIALOG_VISIBLE, COMPOSEABLE ),
+ DEF_INFO_3( BLOCKINCREMENT, BLOCKINCREMENT, BLOCKINCREMENT, FORM_VISIBLE, DIALOG_VISIBLE, COMPOSEABLE ),
+
+ DEF_INFO_2( SPINVALUE, VALUE, SPINVALUE, DIALOG_VISIBLE, COMPOSEABLE ),
+ DEF_INFO_3( SPINVALUE_MIN, VALUEMIN, SPINVALUE_MIN, FORM_VISIBLE, DIALOG_VISIBLE, COMPOSEABLE ),
+ DEF_INFO_3( SPINVALUE_MAX, VALUEMAX, SPINVALUE_MAX, FORM_VISIBLE, DIALOG_VISIBLE, COMPOSEABLE ),
+ DEF_INFO_2( DEFAULT_SPINVALUE,DEFAULTVALUE, DEFAULT_SPINVALUE, FORM_VISIBLE, COMPOSEABLE ),
+ DEF_INFO_3( SPININCREMENT, VALUESTEP, SPININCREMENT, FORM_VISIBLE, DIALOG_VISIBLE, COMPOSEABLE ),
+
+ DEF_INFO_3( SPIN, SPIN, SPIN, FORM_VISIBLE, DIALOG_VISIBLE, COMPOSEABLE ),
+ DEF_INFO_3( REPEAT, REPEAT, REPEAT, FORM_VISIBLE, DIALOG_VISIBLE, COMPOSEABLE ),
+ DEF_INFO_3( REPEAT_DELAY, REPEAT_DELAY, REPEAT_DELAY, FORM_VISIBLE, DIALOG_VISIBLE, COMPOSEABLE ),
+ DEF_INFO_3( VISIBLESIZE, VISIBLESIZE, VISIBLESIZE, FORM_VISIBLE, DIALOG_VISIBLE, COMPOSEABLE ),
+ DEF_INFO_4( ORIENTATION, ORIENTATION, ORIENTATION, FORM_VISIBLE, DIALOG_VISIBLE, ENUM, COMPOSEABLE ),
+ DEF_INFO_3( FOCUSONCLICK, FOCUSONCLICK, FOCUSONCLICK, FORM_VISIBLE, DIALOG_VISIBLE, COMPOSEABLE ),
+ DEF_INFO_3( TOGGLE, TOGGLE, TOGGLE, FORM_VISIBLE, DIALOG_VISIBLE, COMPOSEABLE ),
+ DEF_INFO_3( DEFAULT_STATE, DEFAULT_STATE, DEFAULT_STATE, FORM_VISIBLE, ENUM, COMPOSEABLE ),
+
+ DEF_INFO_3( TEXT_ANCHOR_TYPE, ANCHOR_TYPE, ANCHOR_TYPE, FORM_VISIBLE, ENUM, COMPOSEABLE ),
+ DEF_INFO_3( SHEET_ANCHOR_TYPE, ANCHOR_TYPE, ANCHOR_TYPE, FORM_VISIBLE, ENUM, COMPOSEABLE ),
+ DEF_INFO_3( POSITIONX, POSITIONX, POSITIONX, FORM_VISIBLE, DIALOG_VISIBLE, COMPOSEABLE ),
+ DEF_INFO_3( POSITIONY, POSITIONY, POSITIONY, FORM_VISIBLE, DIALOG_VISIBLE, COMPOSEABLE ),
+ DEF_INFO_3( WIDTH, WIDTH, WIDTH, FORM_VISIBLE, DIALOG_VISIBLE, COMPOSEABLE ),
+ DEF_INFO_3( HEIGHT, HEIGHT, HEIGHT, FORM_VISIBLE, DIALOG_VISIBLE, COMPOSEABLE ),
+
+ DEF_INFO_1( LISTINDEX, LISTINDEX, LISTINDEX, FORM_VISIBLE ),
+ DEF_INFO_3( STRINGITEMLIST, STRINGITEMLIST, STRINGITEMLIST, FORM_VISIBLE, DIALOG_VISIBLE, COMPOSEABLE ),
+ DEF_INFO_2( DEFAULT_TEXT, DEFAULTTEXT, DEFAULTVALUE, FORM_VISIBLE, COMPOSEABLE ),
+ DEF_INFO_3( FONT, FONT, FONT, FORM_VISIBLE, DIALOG_VISIBLE, COMPOSEABLE ),
+ DEF_INFO_4( VISUALEFFECT, VISUALEFFECT, VISUALEFFECT, FORM_VISIBLE, DIALOG_VISIBLE, ENUM_ONE, COMPOSEABLE ),
+ DEF_INFO_4( ALIGN, ALIGN, ALIGN, FORM_VISIBLE, DIALOG_VISIBLE, ENUM, COMPOSEABLE ),
+ DEF_INFO_3( VERTICAL_ALIGN, VERTICAL_ALIGN, VERTICAL_ALIGN, FORM_VISIBLE, ENUM, COMPOSEABLE ),
+ DEF_INFO_3( ROWHEIGHT, ROWHEIGHT, ROWHEIGHT, FORM_VISIBLE, DIALOG_VISIBLE, COMPOSEABLE ),
+ DEF_INFO_3( BACKGROUNDCOLOR, BACKGROUNDCOLOR, BACKGROUNDCOLOR, FORM_VISIBLE, DIALOG_VISIBLE, COMPOSEABLE ),
+ DEF_INFO_3( SYMBOLCOLOR, SYMBOLCOLOR, SYMBOLCOLOR, FORM_VISIBLE, DIALOG_VISIBLE, COMPOSEABLE ),
+ DEF_INFO_3( FILLCOLOR, FILLCOLOR, FILLCOLOR, FORM_VISIBLE, DIALOG_VISIBLE, COMPOSEABLE ),
+ DEF_INFO_3( LINECOLOR, LINECOLOR, LINECOLOR, FORM_VISIBLE, DIALOG_VISIBLE, COMPOSEABLE ),
+ DEF_INFO_4( BORDER, BORDER, BORDER, FORM_VISIBLE, DIALOG_VISIBLE, ENUM, COMPOSEABLE ),
+ DEF_INFO_3( BORDERCOLOR, BORDERCOLOR, BORDERCOLOR, FORM_VISIBLE, DIALOG_VISIBLE, COMPOSEABLE ),
+ DEF_INFO_3( ICONSIZE, ICONSIZE, ICONSIZE, FORM_VISIBLE, ENUM, COMPOSEABLE ),
+ DEF_INFO_2( SHOW_POSITION, SHOW_POSITION, SHOW_POSITION, FORM_VISIBLE, COMPOSEABLE ),
+ DEF_INFO_2( SHOW_NAVIGATION, SHOW_NAVIGATION, SHOW_NAVIGATION, FORM_VISIBLE, COMPOSEABLE ),
+ DEF_INFO_2( SHOW_RECORDACTIONS,SHOW_RECORDACTIONS, SHOW_RECORDACTIONS,FORM_VISIBLE, COMPOSEABLE ),
+ DEF_INFO_2( SHOW_FILTERSORT, SHOW_FILTERSORT, SHOW_FILTERSORT, FORM_VISIBLE, COMPOSEABLE ),
+
+ DEF_INFO_3( DROPDOWN, DROPDOWN, DROPDOWN, FORM_VISIBLE, DIALOG_VISIBLE, COMPOSEABLE ),
+ DEF_INFO_3( LINECOUNT, LINECOUNT, LINECOUNT, FORM_VISIBLE, DIALOG_VISIBLE, COMPOSEABLE ),
+ DEF_INFO_3( AUTOCOMPLETE, AUTOCOMPLETE, AUTOCOMPLETE, FORM_VISIBLE, DIALOG_VISIBLE, COMPOSEABLE ),
+ DEF_INFO_3( MULTILINE, MULTILINE, MULTILINE, FORM_VISIBLE, DIALOG_VISIBLE, COMPOSEABLE ),
+ DEF_INFO_3( WORDBREAK, WORDBREAK, WORDBREAK, FORM_VISIBLE, DIALOG_VISIBLE, COMPOSEABLE ),
+ DEF_INFO_3( TEXTTYPE, TEXTTYPE, TEXTTYPE, FORM_VISIBLE, ENUM, COMPOSEABLE ),
+ DEF_INFO_3( LINEEND_FORMAT, LINEEND_FORMAT, LINEEND_FORMAT, FORM_VISIBLE, ENUM_ONE, COMPOSEABLE ),
+ DEF_INFO_3( MULTISELECTION, MULTISELECTION, MULTISELECTION, FORM_VISIBLE, DIALOG_VISIBLE, COMPOSEABLE ),
+ DEF_INFO_4( SHOW_SCROLLBARS, SHOW_SCROLLBARS, SHOW_SCROLLBARS, FORM_VISIBLE, DIALOG_VISIBLE, ENUM, COMPOSEABLE ),
+ DEF_INFO_3( HSCROLL, HSCROLL, HSCROLL, FORM_VISIBLE, DIALOG_VISIBLE, COMPOSEABLE ),
+ DEF_INFO_3( VSCROLL, VSCROLL, VSCROLL, FORM_VISIBLE, DIALOG_VISIBLE, COMPOSEABLE ),
+ DEF_INFO_3( BUTTONTYPE, BUTTONTYPE, BUTTONTYPE, FORM_VISIBLE, ENUM, COMPOSEABLE ),
+ DEF_INFO_2( XFORMS_BUTTONTYPE, BUTTONTYPE, BUTTONTYPE, FORM_VISIBLE, ENUM ),
+ DEF_INFO_1( SUBMISSION_ID, SUBMISSION_ID, SUBMISSION_ID, FORM_VISIBLE ),
+ DEF_INFO_2( PUSHBUTTONTYPE, PUSHBUTTONTYPE, PUSHBUTTONTYPE, DIALOG_VISIBLE, ENUM ),
+ DEF_INFO_2( TARGET_URL, TARGET_URL, TARGET_URL, FORM_VISIBLE, COMPOSEABLE ),
+ DEF_INFO_1( TARGET_FRAME, TARGET_FRAME, TARGET_FRAME, FORM_VISIBLE ),
+ DEF_INFO_2( SUBMIT_ACTION, SUBMIT_ACTION, SUBMIT_ACTION, FORM_VISIBLE, COMPOSEABLE ),
+ DEF_INFO_2( SUBMIT_TARGET, SUBMIT_TARGET, SUBMIT_TARGET, FORM_VISIBLE, COMPOSEABLE ),
+ DEF_INFO_3( SUBMIT_ENCODING, SUBMIT_ENCODING, SUBMIT_ENCODING, FORM_VISIBLE, ENUM, COMPOSEABLE ),
+ DEF_INFO_3( SUBMIT_METHOD, SUBMIT_METHOD, SUBMIT_METHOD, FORM_VISIBLE, ENUM, COMPOSEABLE ),
+ DEF_INFO_3( STATE, STATE, STATE, DIALOG_VISIBLE, ENUM, COMPOSEABLE ),
+ DEF_INFO_3( DEFAULTBUTTON, DEFAULT_BUTTON, DEFAULT_BUTTON, FORM_VISIBLE, DIALOG_VISIBLE, COMPOSEABLE ),
+ DEF_INFO_3( IMAGE_URL, IMAGE_URL, IMAGE_URL, FORM_VISIBLE, DIALOG_VISIBLE, COMPOSEABLE ),
+ DEF_INFO_4( IMAGEPOSITION, IMAGEPOSITION, IMAGEPOSITION, FORM_VISIBLE, DIALOG_VISIBLE, ENUM, COMPOSEABLE ),
+ DEF_INFO_3( SCALEIMAGE, SCALEIMAGE, SCALEIMAGE, FORM_VISIBLE, DIALOG_VISIBLE, COMPOSEABLE ),
+ DEF_INFO_4( SCALE_MODE, SCALEIMAGE, SCALEIMAGE, FORM_VISIBLE, DIALOG_VISIBLE, COMPOSEABLE, ENUM ),
+ DEF_INFO_2( DEFAULT_SELECT_SEQ,DEFAULT_SELECT_SEQ, DEFAULT_SELECT_SEQ,FORM_VISIBLE, COMPOSEABLE ),
+ DEF_INFO_2( SELECTEDITEMS, SELECTEDITEMS, SELECTEDITEMS, DIALOG_VISIBLE, COMPOSEABLE ),
+ DEF_INFO_3( ECHO_CHAR, ECHO_CHAR, ECHO_CHAR, FORM_VISIBLE, DIALOG_VISIBLE, COMPOSEABLE ),
+ DEF_INFO_3( HIDEINACTIVESELECTION, HIDEINACTIVESELECTION, HIDEINACTIVESELECTION, FORM_VISIBLE, DIALOG_VISIBLE, COMPOSEABLE ),
+ DEF_INFO_3( TRISTATE, TRISTATE, TRISTATE, FORM_VISIBLE, DIALOG_VISIBLE, COMPOSEABLE ),
+ DEF_INFO_2( HASNAVIGATION, NAVIGATION, NAVIGATIONBAR, FORM_VISIBLE, COMPOSEABLE ),
+ DEF_INFO_2( RECORDMARKER, RECORDMARKER, RECORDMARKER, FORM_VISIBLE, COMPOSEABLE ),
+ DEF_INFO_3( TAG, TAG, TAG, FORM_VISIBLE, DIALOG_VISIBLE, COMPOSEABLE ),
+ DEF_INFO_3( HELPTEXT, HELPTEXT, HELPTEXT, FORM_VISIBLE, DIALOG_VISIBLE, COMPOSEABLE ),
+ DEF_INFO_3( HELPURL, HELPURL, HELPURL, FORM_VISIBLE, DIALOG_VISIBLE, COMPOSEABLE ),
+ DEF_INFO_3( SELECTION_TYPE, SELECTION_TYPE, SELECTION_TYPE, DIALOG_VISIBLE, ENUM, COMPOSEABLE ),
+ DEF_INFO_2( ROOT_DISPLAYED, ROOT_DISPLAYED, ROOT_DISPLAYED, DIALOG_VISIBLE, COMPOSEABLE ),
+ DEF_INFO_2( SHOWS_HANDLES, SHOWS_HANDLES, SHOWS_HANDLES, DIALOG_VISIBLE, COMPOSEABLE ),
+ DEF_INFO_2( SHOWS_ROOT_HANDLES, SHOWS_ROOT_HANDLES, SHOWS_ROOT_HANDLES, DIALOG_VISIBLE, COMPOSEABLE ),
+ DEF_INFO_2( EDITABLE, EDITABLE, EDITABLE, DIALOG_VISIBLE, COMPOSEABLE ),
+ DEF_INFO_2( INVOKES_STOP_NOT_EDITING, INVOKES_STOP_NOT_EDITING, INVOKES_STOP_NOT_EDITING, DIALOG_VISIBLE, COMPOSEABLE ),
+ DEF_INFO_2( DECORATION, DECORATION, DECORATION, DIALOG_VISIBLE, COMPOSEABLE ),
+ DEF_INFO_2( NOLABEL, NOLABEL, NOLABEL, DIALOG_VISIBLE, COMPOSEABLE )
+ };
+
+ s_pPropertyInfos = aPropertyInfos;
+ s_nCount = sizeof(aPropertyInfos) / sizeof(OPropertyInfoImpl);
+
+ // sort
+ ::std::sort( s_pPropertyInfos, s_pPropertyInfos + s_nCount, PropertyInfoLessByName() );
+
+#if OSL_DEBUG_LEVEL > 0
+ for ( const OPropertyInfoImpl* pCheck = s_pPropertyInfos; pCheck != s_pPropertyInfos + s_nCount - 1; ++pCheck )
+ {
+ OSL_ENSURE( pCheck->sName != ( pCheck + 1 )->sName, "OPropertyInfoService::getPropertyInfo: duplicate entry in the table!" );
+ }
+#endif
+
+ return s_pPropertyInfos;
+ }
+
+ //------------------------------------------------------------------------
+ sal_Int32 OPropertyInfoService::getPropertyId(const String& _rName) const
+ {
+ const OPropertyInfoImpl* pInfo = getPropertyInfo(_rName);
+ return pInfo ? pInfo->nId : -1;
+ }
+
+ //------------------------------------------------------------------------
+ String OPropertyInfoService::getPropertyName( sal_Int32 _nPropId )
+ {
+ const OPropertyInfoImpl* pInfo = getPropertyInfo(_nPropId);
+ return pInfo ? pInfo->sName : String();
+ }
+
+ //------------------------------------------------------------------------
+ String OPropertyInfoService::getPropertyTranslation(sal_Int32 _nId) const
+ {
+ const OPropertyInfoImpl* pInfo = getPropertyInfo(_nId);
+ return (pInfo) ? pInfo->sTranslation : String();
+ }
+
+ //------------------------------------------------------------------------
+ sal_Int32 OPropertyInfoService::getPropertyHelpId(sal_Int32 _nId) const
+ {
+ const OPropertyInfoImpl* pInfo = getPropertyInfo(_nId);
+ return (pInfo) ? pInfo->nHelpId : 0;
+ }
+
+ //------------------------------------------------------------------------
+ sal_Int16 OPropertyInfoService::getPropertyPos(sal_Int32 _nId) const
+ {
+ const OPropertyInfoImpl* pInfo = getPropertyInfo(_nId);
+ return (pInfo) ? pInfo->nPos : 0xFFFF;
+ }
+
+ //------------------------------------------------------------------------
+ sal_uInt32 OPropertyInfoService::getPropertyUIFlags(sal_Int32 _nId) const
+ {
+ const OPropertyInfoImpl* pInfo = getPropertyInfo(_nId);
+ return (pInfo) ? pInfo->nUIFlags : 0;
+ }
+
+ //------------------------------------------------------------------------
+ ::std::vector< ::rtl::OUString > OPropertyInfoService::getPropertyEnumRepresentations(sal_Int32 _nId) const
+ {
+ OSL_ENSURE( ( ( getPropertyUIFlags( _nId ) & PROP_FLAG_ENUM ) != 0 ) || ( _nId == PROPERTY_ID_TARGET_FRAME ),
+ "OPropertyInfoService::getPropertyEnumRepresentations: this is no enum property!" );
+
+ sal_Int16 nStringItemsResId = 0;
+ switch ( _nId )
+ {
+ case PROPERTY_ID_IMAGEPOSITION:
+ nStringItemsResId = RID_RSC_ENUM_IMAGE_POSITION;
+ break;
+ case PROPERTY_ID_BORDER:
+ nStringItemsResId = RID_RSC_ENUM_BORDER_TYPE;
+ break;
+ case PROPERTY_ID_ICONSIZE:
+ nStringItemsResId = RID_RSC_ENUM_ICONSIZE_TYPE;
+ break;
+ case PROPERTY_ID_COMMANDTYPE:
+ nStringItemsResId = RID_RSC_ENUM_COMMAND_TYPE;
+ break;
+ case PROPERTY_ID_LISTSOURCETYPE:
+ nStringItemsResId = RID_RSC_ENUM_LISTSOURCE_TYPE;
+ break;
+ case PROPERTY_ID_ALIGN:
+ nStringItemsResId = RID_RSC_ENUM_ALIGNMENT;
+ break;
+ case PROPERTY_ID_VERTICAL_ALIGN:
+ nStringItemsResId = RID_RSC_ENUM_VERTICAL_ALIGN;
+ break;
+ case PROPERTY_ID_BUTTONTYPE:
+ nStringItemsResId = RID_RSC_ENUM_BUTTONTYPE;
+ break;
+ case PROPERTY_ID_PUSHBUTTONTYPE:
+ nStringItemsResId = RID_RSC_ENUM_PUSHBUTTONTYPE;
+ break;
+ case PROPERTY_ID_SUBMIT_METHOD:
+ nStringItemsResId = RID_RSC_ENUM_SUBMIT_METHOD;
+ break;
+ case PROPERTY_ID_SUBMIT_ENCODING:
+ nStringItemsResId = RID_RSC_ENUM_SUBMIT_ENCODING;
+ break;
+ case PROPERTY_ID_DATEFORMAT:
+ nStringItemsResId = RID_RSC_ENUM_DATEFORMAT_LIST;
+ break;
+ case PROPERTY_ID_TIMEFORMAT:
+ nStringItemsResId = RID_RSC_ENUM_TIMEFORMAT_LIST;
+ break;
+ case PROPERTY_ID_DEFAULT_STATE:
+ case PROPERTY_ID_STATE:
+ nStringItemsResId = RID_RSC_ENUM_CHECKED;
+ break;
+ case PROPERTY_ID_CYCLE:
+ nStringItemsResId = RID_RSC_ENUM_CYCLE;
+ break;
+ case PROPERTY_ID_NAVIGATION:
+ nStringItemsResId = RID_RSC_ENUM_NAVIGATION;
+ break;
+ case PROPERTY_ID_TARGET_FRAME:
+ nStringItemsResId = RID_RSC_ENUM_SUBMIT_TARGET;
+ break;
+ case PROPERTY_ID_ORIENTATION:
+ nStringItemsResId = RID_RSC_ENUM_ORIENTATION;
+ break;
+ case PROPERTY_ID_CELL_EXCHANGE_TYPE:
+ nStringItemsResId = RID_RSC_ENUM_CELL_EXCHANGE_TYPE;
+ break;
+ case PROPERTY_ID_SHOW_SCROLLBARS:
+ nStringItemsResId = RID_RSC_ENUM_SCROLLBARS;
+ break;
+ case PROPERTY_ID_VISUALEFFECT:
+ nStringItemsResId = RID_RSC_ENUM_VISUALEFFECT;
+ break;
+ case PROPERTY_ID_TEXTTYPE:
+ nStringItemsResId = RID_RSC_ENUM_TEXTTYPE;
+ break;
+ case PROPERTY_ID_LINEEND_FORMAT:
+ nStringItemsResId = RID_RSC_ENUM_LINEEND_FORMAT;
+ break;
+ case PROPERTY_ID_XSD_WHITESPACES:
+ nStringItemsResId = RID_RSC_ENUM_WHITESPACE_HANDLING;
+ break;
+ case PROPERTY_ID_SELECTION_TYPE:
+ nStringItemsResId = RID_RSC_ENUM_SELECTION_TYPE;
+ break;
+ case PROPERTY_ID_SCALE_MODE:
+ nStringItemsResId = RID_RSC_ENUM_SCALE_MODE;
+ break;
+ case PROPERTY_ID_WRITING_MODE:
+ nStringItemsResId = RID_RSC_ENUM_WRITING_MODE;
+ break;
+ case PROPERTY_ID_WHEEL_BEHAVIOR:
+ nStringItemsResId = RID_RSC_ENUM_WHEEL_BEHAVIOR;
+ break;
+ case PROPERTY_ID_TEXT_ANCHOR_TYPE:
+ nStringItemsResId = RID_RSC_ENUM_TEXT_ANCHOR_TYPE;
+ break;
+ case PROPERTY_ID_SHEET_ANCHOR_TYPE:
+ nStringItemsResId = RID_RSC_ENUM_SHEET_ANCHOR_TYPE;
+ break;
+ default:
+ OSL_ENSURE( sal_False, "OPropertyInfoService::getPropertyEnumRepresentations: unknown enum property!" );
+ break;
+ }
+
+ ::std::vector< ::rtl::OUString > aReturn;
+
+ if ( nStringItemsResId )
+ {
+ PcrRes aResId( nStringItemsResId );
+ ::svt::OLocalResourceAccess aEnumStrings( aResId, RSC_RESOURCE );
+
+ sal_Int16 i = 1;
+ PcrRes aLocalId( i );
+ while ( aEnumStrings.IsAvailableRes( aLocalId.SetRT( RSC_STRING ) ) )
+ {
+ aReturn.push_back( String( aLocalId ) );
+ aLocalId = PcrRes( ++i );
+ }
+ }
+
+ return aReturn;
+ }
+
+ //------------------------------------------------------------------------
+ sal_Bool OPropertyInfoService::isComposeable( const ::rtl::OUString& _rPropertyName ) const
+ {
+ sal_Int32 nId = getPropertyId( _rPropertyName );
+ if ( nId == -1 )
+ return sal_False;
+
+ sal_uInt32 nFlags = getPropertyUIFlags( nId );
+ return ( nFlags & PROP_FLAG_COMPOSEABLE ) != 0;
+ }
+
+ //------------------------------------------------------------------------
+ const OPropertyInfoImpl* OPropertyInfoService::getPropertyInfo(const String& _rName)
+ {
+ // intialisierung
+ if(!s_pPropertyInfos)
+ getPropertyInfo();
+ OPropertyInfoImpl aSearch(_rName, 0L, String(), 0, 0, 0);
+
+ const OPropertyInfoImpl* pInfo = ::std::lower_bound(
+ s_pPropertyInfos, s_pPropertyInfos + s_nCount, aSearch, PropertyInfoLessByName() );
+
+ if ( pInfo == s_pPropertyInfos + s_nCount )
+ return NULL;
+
+ if ( pInfo->sName != _rName )
+ return NULL;
+
+ return pInfo;
+ }
+
+
+ //------------------------------------------------------------------------
+ const OPropertyInfoImpl* OPropertyInfoService::getPropertyInfo(sal_Int32 _nId)
+ {
+ // intialisierung
+ if(!s_pPropertyInfos)
+ getPropertyInfo();
+
+ // TODO: a real structure which allows quick access by name as well as by id
+ for (sal_uInt16 i = 0; i < s_nCount; i++)
+ if (s_pPropertyInfos[i].nId == _nId)
+ return &s_pPropertyInfos[i];
+
+ return NULL;
+ }
+
+ //====================================================================
+ //= DefaultEnumRepresentation
+ //====================================================================
+ DBG_NAME( DefaultEnumRepresentation )
+ //--------------------------------------------------------------------
+ DefaultEnumRepresentation::DefaultEnumRepresentation( const IPropertyInfoService& _rInfo, const Type& _rType, sal_Int32 _nPropertyId )
+ :m_refCount( 0 )
+ ,m_rMetaData( _rInfo )
+ ,m_aType( _rType )
+ ,m_nPropertyId( _nPropertyId )
+ {
+ DBG_CTOR( DefaultEnumRepresentation, NULL );
+ }
+
+ //--------------------------------------------------------------------
+ DefaultEnumRepresentation::~DefaultEnumRepresentation()
+ {
+ DBG_DTOR( DefaultEnumRepresentation, NULL );
+ }
+
+ //--------------------------------------------------------------------
+ ::std::vector< ::rtl::OUString > SAL_CALL DefaultEnumRepresentation::getDescriptions() const
+ {
+ return m_rMetaData.getPropertyEnumRepresentations( m_nPropertyId );
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL DefaultEnumRepresentation::getValueFromDescription( const ::rtl::OUString& _rDescription, Any& _out_rValue ) const
+ {
+ sal_uInt32 nPropertyUIFlags = m_rMetaData.getPropertyUIFlags( m_nPropertyId );
+ ::std::vector< ::rtl::OUString > aEnumStrings = m_rMetaData.getPropertyEnumRepresentations( m_nPropertyId );
+ ::std::vector< ::rtl::OUString >::const_iterator pos = ::std::find( aEnumStrings.begin(), aEnumStrings.end(), _rDescription );
+ if ( pos != aEnumStrings.end() )
+ {
+ sal_Int32 nPos = pos - aEnumStrings.begin();
+ if ( ( nPropertyUIFlags & PROP_FLAG_ENUM_ONE ) == PROP_FLAG_ENUM_ONE )
+ // enum value starting with 1
+ ++nPos;
+
+ switch ( m_aType.getTypeClass() )
+ {
+ case TypeClass_ENUM:
+ _out_rValue = ::cppu::int2enum( nPos, m_aType );
+ break;
+
+ case TypeClass_SHORT:
+ _out_rValue <<= (sal_Int16)nPos;
+ break;
+
+ case TypeClass_UNSIGNED_SHORT:
+ _out_rValue <<= (sal_uInt16)nPos;
+ break;
+
+ case TypeClass_UNSIGNED_LONG:
+ _out_rValue <<= (sal_uInt32)nPos;
+ break;
+
+ default:
+ _out_rValue <<= (sal_Int32)nPos;
+ break;
+ }
+ }
+ else
+ {
+ DBG_ERROR( "DefaultEnumRepresentation::getValueFromDescription: could not translate the enum string!" );
+ _out_rValue.clear();
+ }
+ }
+
+ //--------------------------------------------------------------------
+ ::rtl::OUString SAL_CALL DefaultEnumRepresentation::getDescriptionForValue( const Any& _rEnumValue ) const
+ {
+ ::rtl::OUString sReturn;
+ sal_Int32 nIntValue = -1;
+ OSL_VERIFY( ::cppu::enum2int( nIntValue, _rEnumValue ) );
+
+ sal_uInt32 nUIFlags = m_rMetaData.getPropertyUIFlags( m_nPropertyId );
+ if ( ( nUIFlags & PROP_FLAG_ENUM_ONE ) == PROP_FLAG_ENUM_ONE )
+ // enum value starting with 1
+ --nIntValue;
+
+ ::std::vector< ::rtl::OUString > aEnumStrings = m_rMetaData.getPropertyEnumRepresentations( m_nPropertyId );
+ if ( ( nIntValue >= 0 ) && ( nIntValue < (sal_Int32)aEnumStrings.size() ) )
+ {
+ sReturn = aEnumStrings[ nIntValue ];
+ }
+ else
+ {
+ DBG_ERROR( "DefaultEnumRepresentation::getDescriptionForValue: could not translate an enum value" );
+ }
+ return sReturn;
+ }
+
+ //--------------------------------------------------------------------
+ oslInterlockedCount SAL_CALL DefaultEnumRepresentation::acquire()
+ {
+ return osl_incrementInterlockedCount( &m_refCount );
+ }
+
+ //--------------------------------------------------------------------
+ oslInterlockedCount SAL_CALL DefaultEnumRepresentation::release()
+ {
+ if ( 0 == osl_decrementInterlockedCount( &m_refCount ) )
+ {
+ delete this;
+ return 0;
+ }
+ return m_refCount;
+ }
+
+//............................................................................
+} // namespace pcr
+//............................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/propctrlr/formmetadata.hxx b/extensions/source/propctrlr/formmetadata.hxx
new file mode 100644
index 000000000000..66aaf8ab2e70
--- /dev/null
+++ b/extensions/source/propctrlr/formmetadata.hxx
@@ -0,0 +1,351 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _EXTENSIONS_PROPCTRLR_FORMMETADATA_HXX_
+#define _EXTENSIONS_PROPCTRLR_FORMMETADATA_HXX_
+
+#include "propertyinfo.hxx"
+#include "modulepcr.hxx"
+#include "enumrepresentation.hxx"
+#include <comphelper/composedprops.hxx>
+
+//............................................................................
+namespace pcr
+{
+//............................................................................
+
+ struct OPropertyInfoImpl;
+
+ //========================================================================
+ //= OPropertyInfoService
+ //========================================================================
+ class OPropertyInfoService
+ :public IPropertyInfoService
+ ,public ::comphelper::IPropertySetComposerCallback
+ ,public PcrClient
+ {
+ protected:
+ static sal_uInt16 s_nCount;
+ static OPropertyInfoImpl* s_pPropertyInfos;
+ // TODO: a real structure which allows quick access by name as well as by id
+
+ public:
+ // IPropertyInfoService
+ virtual sal_Int32 getPropertyId(const String& _rName) const;
+ virtual String getPropertyTranslation(sal_Int32 _nId) const;
+ virtual sal_Int32 getPropertyHelpId(sal_Int32 _nId) const;
+ virtual sal_Int16 getPropertyPos(sal_Int32 _nId) const;
+ virtual sal_uInt32 getPropertyUIFlags(sal_Int32 _nId) const;
+ virtual ::std::vector< ::rtl::OUString > getPropertyEnumRepresentations(sal_Int32 _nId) const;
+ virtual String getPropertyName( sal_Int32 _nPropId );
+
+ // IPropertySetComposerCallback
+ virtual sal_Bool isComposeable( const ::rtl::OUString& _rPropertyName ) const;
+
+ protected:
+ static const OPropertyInfoImpl* getPropertyInfo();
+
+ static const OPropertyInfoImpl* getPropertyInfo(const String& _rName);
+ static const OPropertyInfoImpl* getPropertyInfo(sal_Int32 _nId);
+ };
+
+ //========================================================================
+ //= DefaultEnumRepresentation
+ //========================================================================
+ /** an implementation of the IPropertyEnumRepresentation
+
+ To be used with properties which, in formmetadata.cxx, are declared as ENUM.
+ */
+ class DefaultEnumRepresentation : public IPropertyEnumRepresentation
+ {
+ private:
+ oslInterlockedCount m_refCount;
+ const IPropertyInfoService& m_rMetaData;
+ ::com::sun::star::uno::Type m_aType;
+ const sal_Int32 m_nPropertyId;
+
+ public:
+ /** constructs an instance
+
+ @param _rInfo
+ An instance implementing IPropertyInfoService. Must live at least as
+ long as the DefaultEnumRepresentation should live.
+ */
+ DefaultEnumRepresentation( const IPropertyInfoService& _rInfo, const ::com::sun::star::uno::Type& _rType, sal_Int32 _nPropertyId );
+
+ protected:
+ ~DefaultEnumRepresentation();
+
+ protected:
+ // IPropertyEnumRepresentation implementqation
+ virtual ::std::vector< ::rtl::OUString >
+ SAL_CALL getDescriptions() const;
+ virtual void SAL_CALL getValueFromDescription( const ::rtl::OUString& _rDescription, ::com::sun::star::uno::Any& _out_rValue ) const;
+ virtual ::rtl::OUString SAL_CALL getDescriptionForValue( const ::com::sun::star::uno::Any& _rEnumValue ) const;
+
+ // IReference implementqation
+ virtual oslInterlockedCount SAL_CALL acquire();
+ virtual oslInterlockedCount SAL_CALL release();
+
+ private:
+ DefaultEnumRepresentation(); // never implemented
+ DefaultEnumRepresentation( const DefaultEnumRepresentation& ); // never implemented
+ DefaultEnumRepresentation& operator=( const DefaultEnumRepresentation& ); // never implemented
+ };
+
+ //========================================================================
+ //= UI flags (for all browseable properties)
+ //========================================================================
+
+#define PROP_FLAG_NONE 0x00000000 // no special flag
+#define PROP_FLAG_FORM_VISIBLE 0x00000001 // the property is visible when inspecting a form object
+#define PROP_FLAG_DIALOG_VISIBLE 0x00000002 // the property is visible when inspecting a dialog object
+#define PROP_FLAG_DATA_PROPERTY 0x00000004 // the property is to appear on the "Data" page
+#define PROP_FLAG_ENUM 0x00000020 // the property is some kind of enum property, i.e. its
+ // value is chosen from a fixed list of possible values
+#define PROP_FLAG_ENUM_ONE 0x00000060 // the property is an enum property starting with 1
+ // (note that this includes PROP_FLAG_ENUM)
+#define PROP_FLAG_COMPOSEABLE 0x00000080 // the property is "composeable", i.e. an intersection of property
+ // sets should expose it, if all elements do
+#define PROP_FLAG_EXPERIMENTAL 0x00000100 // the property is experimental, i.e. should not appear in the
+ // UI, unless experimental properties are enabled by a configuraiton
+ // option
+
+ //========================================================================
+ //= property ids (for all browseable properties)
+ //========================================================================
+
+ #define PROPERTY_ID_NAME 1
+ #define PROPERTY_ID_LABEL 2
+ #define PROPERTY_ID_CONTROLLABEL 3
+ #define PROPERTY_ID_MAXTEXTLEN 4
+ #define PROPERTY_ID_EDITMASK 5
+ #define PROPERTY_ID_LITERALMASK 6
+ #define PROPERTY_ID_STRICTFORMAT 7
+ #define PROPERTY_ID_ENABLED 8
+ #define PROPERTY_ID_READONLY 9
+ #define PROPERTY_ID_PRINTABLE 10
+ #define PROPERTY_ID_CONTROLSOURCE 11
+ #define PROPERTY_ID_TABSTOP 12
+ #define PROPERTY_ID_TABINDEX 13
+ #define PROPERTY_ID_DATASOURCE 14
+ #define PROPERTY_ID_COMMAND 15
+ #define PROPERTY_ID_COMMANDTYPE 16
+ #define PROPERTY_ID_FILTER 17
+ #define PROPERTY_ID_SORT 18
+ #define PROPERTY_ID_INSERTONLY 19
+ #define PROPERTY_ID_ALLOWADDITIONS 20
+ #define PROPERTY_ID_ALLOWEDITS 21
+ #define PROPERTY_ID_ALLOWDELETIONS 22
+ #define PROPERTY_ID_GROUP_NAME 23
+ #define PROPERTY_ID_NAVIGATION 24
+ #define PROPERTY_ID_CYCLE 25
+ #define PROPERTY_ID_HIDDEN_VALUE 26
+ #define PROPERTY_ID_VALUEMIN 27
+ #define PROPERTY_ID_VALUEMAX 28
+ #define PROPERTY_ID_VALUESTEP 29
+ #define PROPERTY_ID_DEFAULT_VALUE 30
+ #define PROPERTY_ID_DECIMAL_ACCURACY 31
+ #define PROPERTY_ID_SHOWTHOUSANDSEP 32
+ #define PROPERTY_ID_REFVALUE 33
+ #define PROPERTY_ID_CURRENCYSYMBOL 34
+ #define PROPERTY_ID_CURRSYM_POSITION 35
+ #define PROPERTY_ID_DATEMIN 36
+ #define PROPERTY_ID_DATEMAX 37
+ #define PROPERTY_ID_DATEFORMAT 38
+ #define PROPERTY_ID_SELECTEDITEMS 39
+ #define PROPERTY_ID_DEFAULT_DATE 40
+ #define PROPERTY_ID_TIMEMIN 41
+ #define PROPERTY_ID_TIMEMAX 42
+ #define PROPERTY_ID_TIMEFORMAT 43
+ #define PROPERTY_ID_DEFAULT_TIME 44
+ #define PROPERTY_ID_EFFECTIVE_MIN 45
+ #define PROPERTY_ID_EFFECTIVE_MAX 46
+ #define PROPERTY_ID_EFFECTIVE_DEFAULT 47
+ #define PROPERTY_ID_FORMATKEY 48
+ #define PROPERTY_ID_CLASSID 50
+ #define PROPERTY_ID_HEIGHT 51
+ #define PROPERTY_ID_WIDTH 52
+ #define PROPERTY_ID_BOUNDCOLUMN 53
+ #define PROPERTY_ID_LISTSOURCETYPE 54
+ #define PROPERTY_ID_LISTSOURCE 55
+ #define PROPERTY_ID_LISTINDEX 56
+ #define PROPERTY_ID_STRINGITEMLIST 57
+ #define PROPERTY_ID_DEFAULT_TEXT 58
+ #define PROPERTY_ID_FONT 59
+ #define PROPERTY_ID_ALIGN 60
+ #define PROPERTY_ID_ROWHEIGHT 61
+ #define PROPERTY_ID_BACKGROUNDCOLOR 62
+ #define PROPERTY_ID_FILLCOLOR 63
+ #define PROPERTY_ID_ESCAPE_PROCESSING 64
+ #define PROPERTY_ID_LINECOLOR 65
+ #define PROPERTY_ID_BORDER 66
+ #define PROPERTY_ID_DROPDOWN 67
+ #define PROPERTY_ID_AUTOCOMPLETE 68
+ #define PROPERTY_ID_LINECOUNT 69
+ #define PROPERTY_ID_WORDBREAK 70
+ #define PROPERTY_ID_MULTILINE 71
+ #define PROPERTY_ID_MULTISELECTION 72
+ #define PROPERTY_ID_AUTOLINEBREAK 73
+ #define PROPERTY_ID_HSCROLL 74
+ #define PROPERTY_ID_VSCROLL 75
+ #define PROPERTY_ID_SPIN 76
+ #define PROPERTY_ID_BUTTONTYPE 77
+ #define PROPERTY_ID_TARGET_URL 78
+ #define PROPERTY_ID_TARGET_FRAME 79
+ #define PROPERTY_ID_SUBMIT_ACTION 80
+ #define PROPERTY_ID_SUBMIT_TARGET 81
+ #define PROPERTY_ID_SUBMIT_METHOD 82
+ #define PROPERTY_ID_SUBMIT_ENCODING 83
+ #define PROPERTY_ID_DEFAULT_STATE 84
+ #define PROPERTY_ID_DEFAULTBUTTON 85
+ #define PROPERTY_ID_IMAGE_URL 86
+ #define PROPERTY_ID_DEFAULT_SELECT_SEQ 87
+ #define PROPERTY_ID_ECHO_CHAR 88
+ #define PROPERTY_ID_EMPTY_IS_NULL 89
+ #define PROPERTY_ID_TRISTATE 90
+ #define PROPERTY_ID_MASTERFIELDS 91
+ #define PROPERTY_ID_DETAILFIELDS 92
+ #define PROPERTY_ID_RECORDMARKER 93
+ #define PROPERTY_ID_FILTERPROPOSAL 94
+ #define PROPERTY_ID_TAG 95
+ #define PROPERTY_ID_HELPTEXT 96
+ #define PROPERTY_ID_HELPURL 97
+ #define PROPERTY_ID_HASNAVIGATION 98
+ #define PROPERTY_ID_POSITIONX 99
+ #define PROPERTY_ID_POSITIONY 100
+ #define PROPERTY_ID_TITLE 101
+ #define PROPERTY_ID_STEP 102
+ #define PROPERTY_ID_PROGRESSVALUE 103
+ #define PROPERTY_ID_PROGRESSVALUE_MIN 104
+ #define PROPERTY_ID_PROGRESSVALUE_MAX 105
+ #define PROPERTY_ID_SCROLLVALUE 106
+ #define PROPERTY_ID_SCROLLVALUE_MAX 107
+ #define PROPERTY_ID_LINEINCREMENT 108
+ #define PROPERTY_ID_BLOCKINCREMENT 109
+ #define PROPERTY_ID_VISIBLESIZE 110
+ #define PROPERTY_ID_ORIENTATION 111
+ #define PROPERTY_ID_IMAGEPOSITION 112
+ #define PROPERTY_ID_DATE 113
+ #define PROPERTY_ID_STATE 114
+ #define PROPERTY_ID_TIME 115
+ #define PROPERTY_ID_VALUE 116
+ #define PROPERTY_ID_SCALEIMAGE 117
+ #define PROPERTY_ID_PUSHBUTTONTYPE 118
+ #define PROPERTY_ID_EFFECTIVE_VALUE 119
+ #define PROPERTY_ID_TEXT 120
+ #define PROPERTY_ID_BOUND_CELL 121
+ #define PROPERTY_ID_LIST_CELL_RANGE 122
+ #define PROPERTY_ID_CELL_EXCHANGE_TYPE 123
+ #define PROPERTY_ID_SCROLLVALUE_MIN 124
+ #define PROPERTY_ID_DEFAULT_SCROLLVALUE 125
+ #define PROPERTY_ID_REPEAT_DELAY 126
+ #define PROPERTY_ID_SYMBOLCOLOR 127
+ #define PROPERTY_ID_SPINVALUE 128
+ #define PROPERTY_ID_SPINVALUE_MIN 129
+ #define PROPERTY_ID_SPINVALUE_MAX 130
+ #define PROPERTY_ID_DEFAULT_SPINVALUE 131
+ #define PROPERTY_ID_SPININCREMENT 132
+ #define PROPERTY_ID_REPEAT 133
+ #define PROPERTY_ID_SHOW_SCROLLBARS 134
+ #define PROPERTY_ID_ICONSIZE 135
+ #define PROPERTY_ID_SHOW_POSITION 136
+ #define PROPERTY_ID_SHOW_NAVIGATION 137
+ #define PROPERTY_ID_SHOW_RECORDACTIONS 138
+ #define PROPERTY_ID_SHOW_FILTERSORT 139
+ #define PROPERTY_ID_TEXTTYPE 140
+ #define PROPERTY_ID_LINEEND_FORMAT 141
+ #define PROPERTY_ID_TOGGLE 142
+ #define PROPERTY_ID_FOCUSONCLICK 143
+ #define PROPERTY_ID_HIDEINACTIVESELECTION 144
+ #define PROPERTY_ID_VISUALEFFECT 145
+ #define PROPERTY_ID_BORDERCOLOR 146
+ #define PROPERTY_ID_XML_DATA_MODEL 147
+ #define PROPERTY_ID_BIND_EXPRESSION 148
+ #define PROPERTY_ID_XSD_REQUIRED 149
+ #define PROPERTY_ID_XSD_RELEVANT 150
+ #define PROPERTY_ID_XSD_READONLY 151
+ #define PROPERTY_ID_XSD_CONSTRAINT 152
+ #define PROPERTY_ID_XSD_CALCULATION 153
+ #define PROPERTY_ID_XSD_DATA_TYPE 154
+ #define PROPERTY_ID_XSD_WHITESPACES 155
+ #define PROPERTY_ID_XSD_PATTERN 156
+ #define PROPERTY_ID_XSD_LENGTH 157
+ #define PROPERTY_ID_XSD_MIN_LENGTH 158
+ #define PROPERTY_ID_XSD_MAX_LENGTH 159
+ #define PROPERTY_ID_XSD_TOTAL_DIGITS 160
+ #define PROPERTY_ID_XSD_FRACTION_DIGITS 161
+ #define PROPERTY_ID_XSD_MAX_INCLUSIVE_INT 162
+ #define PROPERTY_ID_XSD_MAX_EXCLUSIVE_INT 163
+ #define PROPERTY_ID_XSD_MIN_INCLUSIVE_INT 164
+ #define PROPERTY_ID_XSD_MIN_EXCLUSIVE_INT 165
+ #define PROPERTY_ID_XSD_MAX_INCLUSIVE_DOUBLE 166
+ #define PROPERTY_ID_XSD_MAX_EXCLUSIVE_DOUBLE 167
+ #define PROPERTY_ID_XSD_MIN_INCLUSIVE_DOUBLE 168
+ #define PROPERTY_ID_XSD_MIN_EXCLUSIVE_DOUBLE 169
+ #define PROPERTY_ID_XSD_MAX_INCLUSIVE_DATE 170
+ #define PROPERTY_ID_XSD_MAX_EXCLUSIVE_DATE 171
+ #define PROPERTY_ID_XSD_MIN_INCLUSIVE_DATE 172
+ #define PROPERTY_ID_XSD_MIN_EXCLUSIVE_DATE 173
+ #define PROPERTY_ID_XSD_MAX_INCLUSIVE_TIME 174
+ #define PROPERTY_ID_XSD_MAX_EXCLUSIVE_TIME 175
+ #define PROPERTY_ID_XSD_MIN_INCLUSIVE_TIME 176
+ #define PROPERTY_ID_XSD_MIN_EXCLUSIVE_TIME 177
+ #define PROPERTY_ID_XSD_MAX_INCLUSIVE_DATE_TIME 178
+ #define PROPERTY_ID_XSD_MAX_EXCLUSIVE_DATE_TIME 179
+ #define PROPERTY_ID_XSD_MIN_INCLUSIVE_DATE_TIME 180
+ #define PROPERTY_ID_XSD_MIN_EXCLUSIVE_DATE_TIME 181
+ #define PROPERTY_ID_UNCHECKEDREFVALUE 182
+ #define PROPERTY_ID_SUBMISSION_ID 183
+ #define PROPERTY_ID_XFORMS_BUTTONTYPE 184
+ #define PROPERTY_ID_LIST_BINDING 185
+ #define PROPERTY_ID_VERTICAL_ALIGN 186
+ #define PROPERTY_ID_BINDING_NAME 187
+ #define PROPERTY_ID_DECORATION 188
+ #define PROPERTY_ID_SELECTION_TYPE 189
+ #define PROPERTY_ID_ROOT_DISPLAYED 190
+ #define PROPERTY_ID_SHOWS_HANDLES 191
+ #define PROPERTY_ID_SHOWS_ROOT_HANDLES 192
+ #define PROPERTY_ID_EDITABLE 193
+ #define PROPERTY_ID_INVOKES_STOP_NOT_EDITING 194
+ #define PROPERTY_ID_NOLABEL 195
+ #define PROPERTY_ID_SCALE_MODE 196
+ #define PROPERTY_ID_INPUT_REQUIRED 197
+ #define PROPERTY_ID_WRITING_MODE 198
+ #define PROPERTY_ID_ENABLE_VISIBLE 199
+ #define PROPERTY_ID_WHEEL_BEHAVIOR 200
+ #define PROPERTY_ID_TEXT_ANCHOR_TYPE 201
+ #define PROPERTY_ID_SHEET_ANCHOR_TYPE 202
+
+//............................................................................
+} // namespace pcr
+//............................................................................
+
+#endif // _EXTENSIONS_PROPCTRLR_FORMMETADATA_HXX_
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/propctrlr/formres.src b/extensions/source/propctrlr/formres.src
new file mode 100644
index 000000000000..1170c89cccf8
--- /dev/null
+++ b/extensions/source/propctrlr/formres.src
@@ -0,0 +1,1527 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef EXTENSIONS_PROPRESID_HRC
+#include "formresid.hrc"
+#endif
+#ifndef _EXTENSIONS_PROPCTRLR_FORMLOCALID_HRC_
+#include "formlocalid.hrc"
+#endif
+
+String RID_STR_EDITMASK
+{
+ Text [ en-US ] = "Edit mask" ;
+};
+String RID_STR_LITERALMASK
+{
+ Text [ en-US ] = "Literal mask" ;
+};
+String RID_STR_READONLY
+{
+ Text [ en-US ] = "Read-only" ;
+};
+String RID_STR_ENABLED
+{
+ Text [ en-US ] = "Enabled" ;
+};
+String RID_STR_ENABLE_VISIBLE
+{
+ Text [ en-US ] = "Visible" ;
+};
+String RID_STR_AUTOCOMPLETE
+{
+ Text [ en-US ] = "AutoFill" ;
+};
+String RID_STR_LINECOUNT
+{
+ Text [ en-US ] = "Line count" ;
+};
+String RID_STR_MAXTEXTLEN
+{
+ Text [ en-US ] = "Max. text length" ;
+};
+String RID_STR_SPIN
+{
+ Text [ en-US ] = "Spin Button" ;
+};
+String RID_STR_STRICTFORMAT
+{
+ Text [ en-US ] = "Strict format" ;
+};
+String RID_STR_SHOWTHOUSANDSEP
+{
+ Text [ en-US ] = "Thousands separator" ;
+};
+String RID_STR_PRINTABLE
+{
+ Text [ en-US ] = "Printable" ;
+};
+String RID_STR_TARGET_URL
+{
+ Text [ en-US ] = "URL" ;
+};
+String RID_STR_TARGET_FRAME
+{
+ Text [ en-US ] = "Frame" ;
+};
+String RID_STR_HELPTEXT
+{
+ Text [ en-US ] = "Help text" ;
+};
+String RID_STR_HELPURL
+{
+ Text [ en-US ] = "Help URL";
+};
+String RID_STR_TAG
+{
+ Text [ en-US ] = "Additional information" ;
+};
+String RID_STR_ECHO_CHAR
+{
+ Text [ en-US ] = "Password character" ;
+};
+
+String RID_STR_TRISTATE
+{
+ Text [ en-US ] = "Tristate" ;
+};
+String RID_STR_EMPTY_IS_NULL
+{
+ Text [ en-US ] = "Empty string is NULL" ;
+};
+String RID_STR_DECIMAL_ACCURACY
+{
+ Text [ en-US ] = "Decimal accuracy" ;
+};
+String RID_STR_IMAGE_URL
+{
+ Text [ en-US ] = "Graphics" ;
+};
+String RID_STR_DEFAULT_SELECT_SEQ
+{
+ Text [ en-US ] = "Default selection" ;
+};
+String RID_STR_DEFAULT_BUTTON
+{
+ Text [ en-US ] = "Default button" ;
+};
+String RID_STR_LABELCONTROL
+{
+ Text [ en-US ] = "Label Field";
+};
+String RID_STR_LABEL
+{
+ Text [ en-US ] = "Label" ;
+};
+String RID_STR_ALIGN
+{
+ Text [ en-US ] = "Alignment" ;
+};
+String RID_STR_VERTICAL_ALIGN
+{
+ Text [ en-US ] = "Vert. Alignment" ;
+};
+Resource RID_RSC_ENUM_VERTICAL_ALIGN
+{
+ String 1
+ {
+ Text [ en-US ] = "Top";
+ };
+ String 2
+ {
+ Text [ en-US ] = "Middle";
+ };
+ String 3
+ {
+ Text [ en-US ] = "Bottom";
+ };
+};
+String RID_STR_IMAGEPOSITION
+{
+ Text [ en-US ] = "Graphics alignment";
+};
+String RID_STR_FONT
+{
+ Text [ en-US ] = "Font" ;
+};
+String RID_STR_BACKGROUNDCOLOR
+{
+ Text [ en-US ] = "Background color" ;
+};
+String RID_STR_BORDER
+{
+ Text [ en-US ] = "Border" ;
+};
+String RID_STR_ICONSIZE
+{
+ Text [ en-US ] = "Icon size" ;
+};
+Resource RID_RSC_ENUM_ICONSIZE_TYPE
+{
+ String 1
+ {
+ Text [ en-US ] = "Small" ;
+ };
+ String 2
+ {
+ Text [ en-US ] = "Large" ;
+ };
+};
+String RID_STR_SHOW_POSITION
+{
+ Text [ en-US ] = "Positioning";
+};
+String RID_STR_SHOW_NAVIGATION
+{
+ Text [ en-US ] = "Navigation";
+};
+String RID_STR_SHOW_RECORDACTIONS
+{
+ Text [ en-US ] = "Acting on a record";
+};
+String RID_STR_SHOW_FILTERSORT
+{
+ Text [ en-US ] = "Filtering / Sorting";
+};
+String RID_STR_HSCROLL
+{
+ Text [ en-US ] = "Horizontal scroll bar" ;
+};
+String RID_STR_VSCROLL
+{
+ Text [ en-US ] = "Vertical scroll bar" ;
+};
+String RID_STR_WORDBREAK
+{
+ Text [ en-US ] = "Word break";
+};
+String RID_STR_MULTILINE
+{
+ Text [ en-US ] = "Multiline input" ;
+};
+String RID_STR_MULTISELECTION
+{
+ Text [ en-US ] = "Multiselection" ;
+};
+String RID_STR_NAME
+{
+ Text [ en-US ] = "Name" ;
+};
+String RID_STR_GROUP_NAME
+{
+ Text [ en-US ] = "Group name" ;
+};
+String RID_STR_TABINDEX
+{
+ Text [ en-US ] = "Tab order" ;
+};
+String RID_STR_WHEEL_BEHAVIOR
+{
+ Text [ en-US ] = "Mouse wheel scroll" ;
+};
+String RID_STR_FILTER
+{
+ Text [ en-US ] = "Filter" ;
+};
+String RID_STR_SORT_CRITERIA
+{
+ Text [ en-US ] = "Sort" ;
+};
+String RID_STR_RECORDMARKER
+{
+ Text [ en-US ] = "Record marker";
+};
+String RID_STR_FILTERPROPOSAL
+{
+ Text [ en-US ] = "Filter proposal";
+};
+String RID_STR_NAVIGATION
+{
+ Text [ en-US ] = "Navigation bar" ;
+};
+String RID_STR_CYCLE
+{
+ Text [ en-US ] = "Cycle" ;
+};
+String RID_STR_TABSTOP
+{
+ Text [ en-US ] = "Tabstop" ;
+};
+String RID_STR_CONTROLSOURCE
+{
+ Text [ en-US ] = "Data field" ;
+};
+String RID_STR_DROPDOWN
+{
+ Text [ en-US ] = "Dropdown" ;
+};
+String RID_STR_BOUNDCOLUMN
+{
+ Text [ en-US ] = "Bound field" ;
+};
+String RID_STR_LISTSOURCE
+{
+ Text [ en-US ] = "List content" ;
+};
+String RID_STR_LISTSOURCETYPE
+{
+ Text [ en-US ] = "Type of list contents" ;
+};
+String RID_STR_CURSORSOURCE
+{
+ Text [ en-US ] = "Content" ;
+};
+String RID_STR_CURSORSOURCETYPE
+{
+ Text [ en-US ] = "Content type";
+};
+String RID_STR_ALLOW_ADDITIONS
+{
+ Text [ en-US ] = "Allow additions" ;
+};
+String RID_STR_ALLOW_DELETIONS
+{
+ Text [ en-US ] = "Allow deletions" ;
+};
+String RID_STR_ALLOW_EDITS
+{
+ Text [ en-US ] = "Allow modifications" ;
+};
+String RID_STR_DATAENTRY
+{
+ Text [ en-US ] = "Add data only" ;
+};
+String RID_STR_DATASOURCE
+{
+ Text [ en-US ] = "Data source";
+};
+String RID_STR_MASTERFIELDS
+{
+ Text [ en-US ] = "Link master fields" ;
+};
+String RID_STR_SLAVEFIELDS
+{
+ Text [ en-US ] = "Link slave fields" ;
+};
+String RID_STR_VALUEMIN
+{
+ Text [ en-US ] = "Value min." ;
+};
+String RID_STR_VALUEMAX
+{
+ Text [ en-US ] = "Value max." ;
+};
+String RID_STR_VALUESTEP
+{
+ Text [ en-US ] = "Incr./decrement value" ;
+};
+String RID_STR_CURRENCYSYMBOL
+{
+ Text [ en-US ] = "Currency symbol" ;
+};
+String RID_STR_DATEMIN
+{
+ Text [ en-US ] = "Date min." ;
+};
+String RID_STR_DATEMAX
+{
+ Text [ en-US ] = "Date max." ;
+};
+String RID_STR_DATEFORMAT
+{
+ Text [ en-US ] = "Date format" ;
+};
+String RID_STR_SELECTEDITEMS
+{
+ Text [ en-US ] = "Selection" ;
+};
+String RID_STR_TIMEMIN
+{
+ Text [ en-US ] = "Time min." ;
+};
+String RID_STR_TIMEMAX
+{
+ Text [ en-US ] = "Time max." ;
+};
+String RID_STR_TIMEFORMAT
+{
+ Text [ en-US ] = "Time format" ;
+};
+String RID_STR_CURRSYM_POSITION
+{
+ Text [ en-US ] = "Prefix symbol";
+};
+String RID_STR_VALUE
+{
+ Text [ en-US ] = "Value" ;
+};
+String RID_STR_FORMATKEY
+{
+ Text [ en-US ] = "Formatting" ;
+};
+String RID_STR_CLASSID
+{
+ Text [ en-US ] = "Class ID" ;
+};
+String RID_STR_HEIGHT
+{
+ Text [ en-US ] = "Height" ;
+};
+String RID_STR_WIDTH
+{
+ Text [ en-US ] = "Width" ;
+};
+String RID_STR_LISTINDEX
+{
+ Text [ en-US ] = "List index" ;
+};
+String RID_STR_ROWHEIGHT
+{
+ Text [ en-US ] = "Row height" ;
+};
+String RID_STR_FILLCOLOR
+{
+ Text [ en-US ] = "Fill color" ;
+};
+String RID_STR_LINECOLOR
+{
+ Text [ en-US ] = "Line color" ;
+};
+String RID_STR_REFVALUE
+{
+ Text [ en-US ] = "Reference value (on)" ;
+};
+String RID_STR_UNCHECKEDREFVALUE
+{
+ Text [ en-US ] = "Reference value (off)";
+};
+String RID_STR_STRINGITEMLIST
+{
+ Text [ en-US ] = "List entries" ;
+};
+String RID_STR_BUTTONTYPE
+{
+ Text [ en-US ] = "Action";
+};
+String RID_STR_SUBMIT_ACTION
+{
+ Text [ en-US ] = "URL" ;
+};
+String RID_STR_SUBMIT_METHOD
+{
+ Text [ en-US ] = "Type of submission" ;
+};
+String RID_STR_DEFAULT_STATE
+{
+ Text [ en-US ] = "Default status" ;
+};
+String RID_STR_SUBMIT_ENCODING
+{
+ Text [ en-US ] = "Submission encoding" ;
+};
+String RID_STR_DEFAULTVALUE
+{
+ Text [ en-US ] = "Default value" ;
+};
+String RID_STR_DEFAULTTEXT
+{
+ Text [ en-US ] = "Default text";
+};
+String RID_STR_DEFAULTDATE
+{
+ Text [ en-US ] = "Default date";
+};
+String RID_STR_DEFAULTTIME
+{
+ Text [ en-US ] = "Default time";
+};
+String RID_STR_SUBMIT_TARGET
+{
+ Text [ en-US ] = "Frame" ;
+};
+
+Resource RID_RSC_ENUM_BORDER_TYPE
+{
+ String 1
+ {
+ Text [ en-US ] = "Without frame" ;
+ };
+ String 2
+ {
+ Text [ en-US ] = "3D look" ;
+ };
+ String 3
+ {
+ Text [ en-US ] = "Flat" ;
+ };
+};
+
+Resource RID_RSC_ENUM_LISTSOURCE_TYPE
+{
+ String 1
+ {
+ Text [ en-US ] = "Valuelist";
+ };
+ String 2
+ {
+ Text [ en-US ] = "Table";
+ };
+ String 3
+ {
+ Text [ en-US ] = "Query";
+ };
+ String 4
+ {
+ Text [ en-US ] = "Sql";
+ };
+ String 5
+ {
+ Text [ en-US ] = "Sql [Native]";
+ };
+ String 6
+ {
+ Text [ en-US ] = "Tablefields" ;
+ };
+};
+Resource RID_RSC_ENUM_ALIGNMENT
+{
+ String 1
+ {
+ Text [ en-US ] = "Left";
+ };
+ String 2
+ {
+ Text [ en-US ] = "Center";
+ };
+ String 3
+ {
+ Text [ en-US ] = "Right" ;
+ };
+};
+Resource RID_RSC_ENUM_BUTTONTYPE
+{
+ String 1
+ {
+ Text [ en-US ] = "None";
+ };
+ String 2
+ {
+ Text [ en-US ] = "Submit form";
+ };
+ String 3
+ {
+ Text [ en-US ] = "Reset form";
+ };
+ String 4
+ {
+ Text [ en-US ] = "Open document/web page";
+ };
+ String 5
+ {
+ Text [ en-US ] = "First record";
+ };
+ String 6
+ {
+ Text [ en-US ] = "Previous record";
+ };
+ String 7
+ {
+ Text [ en-US ] = "Next record";
+ };
+ String 8
+ {
+ Text [ en-US ] = "Last record";
+ };
+ String 9
+ {
+ Text [ en-US ] = "Save record";
+ };
+ String 10
+ {
+ Text [ en-US ] = "Undo data entry";
+ };
+ String 11
+ {
+ Text [ en-US ] = "New record";
+ };
+ String 12
+ {
+ Text [ en-US ] = "Delete record";
+ };
+ String 13
+ {
+ Text [ en-US ] = "Refresh form";
+ };
+};
+Resource RID_RSC_ENUM_SUBMIT_METHOD
+{
+ String 1
+ {
+ Text [ en-US ] = "Get";
+ };
+ String 2
+ {
+ Text [ en-US ] = "Post" ;
+ };
+};
+Resource RID_RSC_ENUM_SUBMIT_ENCODING
+{
+ String 1
+ {
+ Text [ en-US ] = "URL";
+ };
+ String 2
+ {
+ Text [ en-US ] = "Multipart";
+ };
+ String 3
+ {
+ Text [ en-US ] = "Text" ;
+ };
+};
+Resource RID_RSC_ENUM_DATEFORMAT_LIST
+{
+ String 1
+ {
+ Text [ en-US ] = "Standard (short)";
+ };
+ String 2
+ {
+ Text [ en-US ] = "Standard (short YY)";
+ };
+ String 3
+ {
+ Text [ en-US ] = "Standard (short YYYY)";
+ };
+ String 4
+ {
+ Text [ en-US ] = "Standard (long)";
+ };
+ String 5
+ {
+ Text [ en-US ] = "DD/MM/YY";
+ };
+ String 6
+ {
+ Text [ en-US ] = "MM/DD/YY";
+ };
+ String 7
+ {
+ Text [ en-US ] = "YY/MM/DD";
+ };
+ String 8
+ {
+ Text [ en-US ] = "DD/MM/YYYY";
+ };
+ String 9
+ {
+ Text [ en-US ] = "MM/DD/YYYY";
+ };
+ String 10
+ {
+ Text [ en-US ] = "YYYY/MM/DD";
+ };
+ String 11
+ {
+ Text [ en-US ] = "YY-MM-DD";
+ };
+ String 12
+ {
+ Text [ en-US ] = "YYYY-MM-DD" ;
+ };
+};
+Resource RID_RSC_ENUM_TIMEFORMAT_LIST
+{
+ String 1
+ {
+ Text [ en-US ] = "13:45";
+ };
+ String 2
+ {
+ Text [ en-US ] = "13:45:00";
+ };
+ String 3
+ {
+ Text [ en-US ] = "01:45 PM";
+ };
+ String 4
+ {
+ Text [ en-US ] = "01:45:00 PM" ;
+ };
+};
+Resource RID_RSC_ENUM_CHECKED
+{
+ String 1
+ {
+ Text [ en-US ] = "Not Selected";
+ };
+ String 2
+ {
+ Text [ en-US ] = "Selected";
+ };
+ String 3
+ {
+ Text [ en-US ] = "Not Defined" ;
+ };
+};
+Resource RID_RSC_ENUM_CYCLE
+{
+ String 1
+ {
+ Text [ en-US ] = "All records";
+ };
+ String 2
+ {
+ Text [ en-US ] = "Active record";
+ };
+ String 3
+ {
+ Text [ en-US ] = "Current page" ;
+ };
+};
+Resource RID_RSC_ENUM_NAVIGATION
+{
+ String 1
+ {
+ Text [ en-US ] = "No";
+ };
+ String 2
+ {
+ Text [ en-US ] = "Yes";
+ };
+ String 3
+ {
+ Text [ en-US ] = "Parent Form";
+ };
+};
+Resource RID_RSC_ENUM_SUBMIT_TARGET
+{
+ String 1 { Text = "_blank"; };
+ String 2 { Text = "_parent"; };
+ String 3 { Text = "_self"; };
+ String 4 { Text = "_top"; };
+};
+
+Resource RID_RSC_ENUM_SELECTION_TYPE
+{
+ String 1
+ {
+ Text [ en-US ] = "None" ;
+ };
+ String 2
+ {
+ Text [ en-US ] = "Single" ;
+ };
+ String 3
+ {
+ Text [ en-US ] = "Multi" ;
+ };
+ String 4
+ {
+ Text [ en-US ] = "Range" ;
+ };
+
+};
+
+String RID_STR_EVT_APPROVEPARAMETER
+{
+ Text [ en-US ] = "Fill parameters" ;
+};
+String RID_STR_EVT_ACTIONPERFORMED
+{
+ Text [ en-US ] = "Execute action" ;
+};
+String RID_STR_EVT_AFTERUPDATE
+{
+ Text [ en-US ] = "After updating" ;
+};
+String RID_STR_EVT_BEFOREUPDATE
+{
+ Text [ en-US ] = "Before updating" ;
+};
+String RID_STR_EVT_APPROVEROWCHANGE
+{
+ Text [ en-US ] = "Before record action" ;
+};
+String RID_STR_EVT_ROWCHANGE
+{
+ Text [ en-US ] = "After record action" ;
+};
+String RID_STR_EVT_CONFIRMDELETE
+{
+ Text [ en-US ] = "Confirm deletion" ;
+};
+String RID_STR_EVT_ERROROCCURED
+{
+ Text [ en-US ] = "Error occurred" ;
+};
+String RID_STR_EVT_FOCUSGAINED
+{
+ Text [ en-US ] = "When receiving focus" ;
+};
+String RID_STR_EVT_FOCUSLOST
+{
+ Text [ en-US ] = "When losing focus" ;
+};
+String RID_STR_EVT_ITEMSTATECHANGED
+{
+ Text [ en-US ] = "Item status changed" ;
+};
+String RID_STR_EVT_KEYTYPED
+{
+ Text [ en-US ] = "Key pressed" ;
+};
+String RID_STR_EVT_KEYUP
+{
+ Text [ en-US ] = "Key released" ;
+};
+String RID_STR_EVT_LOADED
+{
+ Text [ en-US ] = "When loading" ;
+};
+String RID_STR_EVT_RELOADING
+{
+ Text [ en-US ] = "Before reloading" ;
+};
+String RID_STR_EVT_RELOADED
+{
+ Text [ en-US ] = "When reloading" ;
+};
+String RID_STR_EVT_MOUSEDRAGGED
+{
+ Text [ en-US ] = "Mouse moved while key pressed" ;
+};
+String RID_STR_EVT_MOUSEENTERED
+{
+ Text [ en-US ] = "Mouse inside" ;
+};
+String RID_STR_EVT_MOUSEEXITED
+{
+ Text [ en-US ] = "Mouse outside" ;
+};
+String RID_STR_EVT_MOUSEMOVED
+{
+ Text [ en-US ] = "Mouse moved" ;
+};
+String RID_STR_EVT_MOUSEPRESSED
+{
+ Text [ en-US ] = "Mouse button pressed" ;
+};
+String RID_STR_EVT_MOUSERELEASED
+{
+ Text [ en-US ] = "Mouse button released" ;
+};
+String RID_STR_EVT_POSITIONING
+{
+ Text [ en-US ] = "Before record change" ;
+};
+String RID_STR_EVT_POSITIONED
+{
+ Text [ en-US ] = "After record change" ;
+};
+String RID_STR_EVT_RESETTED
+{
+ Text [ en-US ] = "After resetting" ;
+};
+String RID_STR_EVT_APPROVERESETTED
+{
+ Text [ en-US ] = "Prior to reset" ;
+};
+String RID_STR_EVT_APPROVEACTIONPERFORMED
+{
+ Text [ en-US ] = "Approve action" ;
+};
+String RID_STR_EVT_SUBMITTED
+{
+ Text [ en-US ] = "Before submitting" ;
+};
+String RID_STR_EVT_TEXTCHANGED
+{
+ Text [ en-US ] = "Text modified" ;
+};
+String RID_STR_EVT_UNLOADING
+{
+ Text [ en-US ] = "Before unloading" ;
+};
+String RID_STR_EVT_UNLOADED
+{
+ Text [ en-US ] = "When unloading" ;
+};
+String RID_STR_EVT_CHANGED
+{
+ Text [ en-US ] = "Changed" ;
+};
+String RID_STR_EVENTS
+{
+ Text [ en-US ] = "Events" ;
+};
+String RID_STR_ESCAPE_PROCESSING
+{
+ Text [ en-US ] = "Analyze SQL command";
+};
+String RID_STR_POSITIONX
+{
+ Text [ en-US ] = "PositionX";
+};
+String RID_STR_POSITIONY
+{
+ Text [ en-US ] = "PositionY";
+};
+String RID_STR_TITLE
+{
+ Text [ en-US ] = "Title";
+};
+String RID_STR_STEP
+{
+ Text [ en-US ] = "Page (step)";
+};
+String RID_STR_PROGRESSVALUE
+{
+ Text [ en-US ] = "Progress value";
+};
+String RID_STR_PROGRESSVALUE_MIN
+{
+ Text [ en-US ] = "Progress value min.";
+};
+String RID_STR_PROGRESSVALUE_MAX
+{
+ Text [ en-US ] = "Progress value max.";
+};
+String RID_STR_SCROLLVALUE
+{
+ Text [ en-US ] = "Scroll value";
+};
+String RID_STR_SCROLLVALUE_MAX
+{
+ Text [ en-US ] = "Scroll value max.";
+};
+String RID_STR_SCROLLVALUE_MIN
+{
+ Text [ en-US ] = "Scroll value min.";
+};
+String RID_STR_DEFAULT_SCROLLVALUE
+{
+ Text [ en-US ] = "Default scroll value";
+};
+String RID_STR_LINEINCREMENT
+{
+ Text [ en-US ] = "Small change";
+};
+String RID_STR_BLOCKINCREMENT
+{
+ Text [ en-US ] = "Large change";
+};
+String RID_STR_REPEAT_DELAY
+{
+ Text [ en-US ] = "Delay";
+};
+String RID_STR_REPEAT
+{
+ Text [ en-US ] = "Repeat";
+};
+String RID_STR_VISIBLESIZE
+{
+ Text [ en-US ] = "Visible size";
+};
+String RID_STR_ORIENTATION
+{
+ Text [ en-US ] = "Orientation";
+};
+Resource RID_RSC_ENUM_ORIENTATION
+{
+ String 1
+ {
+ Text [ en-US ] = "Horizontal";
+ };
+ String 2
+ {
+ Text [ en-US ] = "Vertical";
+ };
+};
+String RID_STR_EVT_ADJUSTMENTVALUECHANGED
+{
+ Text [ en-US ] = "While adjusting";
+};
+String RID_STR_DATE
+{
+ Text [ en-US ] = "Date";
+};
+String RID_STR_STATE
+{
+ Text [ en-US ] = "State";
+};
+String RID_STR_TIME
+{
+ Text [ en-US ] = "Time";
+};
+String RID_STR_SCALEIMAGE
+{
+ Text [ en-US ] = "Scale";
+};
+String RID_STR_PUSHBUTTONTYPE
+{
+ Text [ en-US ] = "Button type";
+};
+Resource RID_RSC_ENUM_PUSHBUTTONTYPE
+{
+ String 1
+ {
+ Text [ en-US ] = "Default";
+ };
+ String 2
+ {
+ Text [ en-US ] = "OK";
+ };
+ String 3
+ {
+ Text [ en-US ] = "Cancel";
+ };
+ String 4
+ {
+ Text [ en-US ] = "Help";
+ };
+};
+String RID_STR_UNABLETOCONNECT
+{
+ Text [ en-US ] = "The connection to the data source \"$name$\" could not be established.";
+};
+String RID_STR_TEXT
+{
+ Text [ en-US ] = "Text";
+};
+
+String RID_STR_BOUND_CELL
+{
+ Text [ en-US ] = "Linked cell";
+};
+
+String RID_STR_LIST_CELL_RANGE
+{
+ Text [ en-US ] = "Source cell range";
+};
+
+String RID_STR_CELL_EXCHANGE_TYPE
+{
+ Text [ en-US ] = "Contents of the linked cell";
+};
+
+Resource RID_RSC_ENUM_CELL_EXCHANGE_TYPE
+{
+ String 1
+ {
+ Text [ en-US ] = "The selected entry";
+ };
+ String 2
+ {
+ Text [ en-US ] = "Position of the selected entry";
+ };
+};
+
+String RID_STR_SHOW_SCROLLBARS
+{
+ Text [ en-US ] = "Scrollbars";
+};
+
+Resource RID_RSC_ENUM_TEXTTYPE
+{
+ String 1
+ {
+ Text [ en-US ] = "Single-line";
+ };
+ String 2
+ {
+ Text [ en-US ] = "Multi-line";
+ };
+ String 3
+ {
+ Text [ en-US ] = "Multi-line with formatting";
+ };
+};
+
+String RID_STR_SYMBOLCOLOR
+{
+ Text [ en-US ] = "Symbol color" ;
+};
+
+String RID_STR_LINEEND_FORMAT
+{
+ Text [ en-US ] = "Text lines end with";
+};
+
+Resource RID_RSC_ENUM_LINEEND_FORMAT
+{
+ String 1
+ {
+ Text [ en-US ] = "LF (Unix)";
+ };
+ String 2
+ {
+ Text [ en-US ] = "CR+LF (Windows)";
+ };
+};
+
+Resource RID_RSC_ENUM_SCROLLBARS
+{
+ String 1
+ {
+ Text [ en-US ] = "None";
+ };
+ String 2
+ {
+ Text [ en-US ] = "Horizontal";
+ };
+ String 3
+ {
+ Text [ en-US ] = "Vertical";
+ };
+ String 4
+ {
+ Text [ en-US ] = "Both";
+ };
+};
+
+Resource RID_RSC_ENUM_COMMAND_TYPE
+{
+ String 1
+ {
+ Text [ en-US ] = "Table";
+ };
+ String 2
+ {
+ Text [ en-US ] = "Query";
+ };
+ String 3
+ {
+ Text [ en-US ] = "SQL command";
+ };
+};
+String RID_STR_TOGGLE
+{
+ Text [ en-US ] = "Toggle";
+};
+
+String RID_STR_FOCUSONCLICK
+{
+ Text [ en-US ] = "Take Focus on Click";
+};
+
+String RID_STR_HIDEINACTIVESELECTION
+{
+ Text [ en-US ] = "Hide selection";
+};
+
+String RID_STR_VISUALEFFECT
+{
+ Text [ en-US ] = "Style";
+};
+
+Resource RID_RSC_ENUM_VISUALEFFECT
+{
+ String 1
+ {
+ Text [ en-US ] = "3D";
+ };
+ String 2
+ {
+ Text [ en-US ] = "Flat";
+ };
+};
+
+String RID_STR_BORDERCOLOR
+{
+ Text [ en-US ] = "Border color";
+};
+
+Resource RID_RSC_ENUM_IMAGE_POSITION
+{
+ String 1
+ {
+ Text [ en-US ] = "Left top";
+ };
+ String 2
+ {
+ Text [ en-US ] = "Left centered";
+ };
+ String 3
+ {
+ Text [ en-US ] = "Left bottom";
+ };
+ String 4
+ {
+ Text [ en-US ] = "Right top";
+ };
+ String 5
+ {
+ Text [ en-US ] = "Right centered";
+ };
+ String 6
+ {
+ Text [ en-US ] = "Right bottom";
+ };
+ String 7
+ {
+ Text [ en-US ] = "Above left";
+ };
+ String 8
+ {
+ Text [ en-US ] = "Above centered";
+ };
+ String 9
+ {
+ Text [ en-US ] = "Above right";
+ };
+ String 10
+ {
+ Text [ en-US ] = "Below left";
+ };
+ String 11
+ {
+ Text [ en-US ] = "Below centered";
+ };
+ String 12
+ {
+ Text [ en-US ] = "Below right";
+ };
+ String 13
+ {
+ Text [ en-US ] = "Centered";
+ };
+};
+
+String RID_STR_AUTOLINEBREAK
+{
+ Text [ en-US ] = "Wrap text automatically";
+};
+
+String RID_STR_TEXTTYPE
+{
+ Text [ en-US ] = "Text type";
+};
+
+Resource RID_RSC_ENUM_SHOWHIDE
+{
+ String 1
+ {
+ Text [ en-US ] = "Hide" ;
+ };
+ String 2
+ {
+ Text [ en-US ] = "Show" ;
+ };
+};
+String RID_STR_XML_DATA_MODEL
+{
+ Text [ en-US ] = "XML data model";
+};
+
+String RID_STR_BIND_EXPRESSION
+{
+ Text [ en-US ] = "Binding expression";
+};
+
+String RID_STR_XSD_REQUIRED
+{
+ Text [ en-US ] = "Required";
+};
+
+String RID_STR_LIST_BINDING
+{
+ Text [ en-US ] = "List entry source";
+};
+
+String RID_STR_XSD_RELEVANT
+{
+ Text [ en-US ] = "Relevant";
+};
+
+String RID_STR_XSD_READONLY
+{
+ Text [ en-US ] = "Read-only";
+};
+
+String RID_STR_XSD_CONSTRAINT
+{
+ Text [ en-US ] = "Constraint";
+};
+
+String RID_STR_XSD_CALCULATION
+{
+ Text [ en-US ] = "Calculation";
+};
+
+String RID_STR_XSD_DATA_TYPE
+{
+ Text [ en-US ] = "Data type";
+};
+
+String RID_STR_XSD_WHITESPACES
+{
+ Text [ en-US ] = "Whitespaces";
+};
+
+Resource RID_RSC_ENUM_WHITESPACE_HANDLING
+{
+ String 1
+ {
+ Text [ en-US ] = "Preserve";
+ };
+ String 2
+ {
+ Text [ en-US ] = "Replace";
+ };
+ String 3
+ {
+ Text [ en-US ] = "Collapse";
+ };
+};
+
+String RID_STR_XSD_PATTERN
+{
+ Text [ en-US ] = "Pattern";
+};
+
+String RID_STR_XSD_LENGTH
+{
+ Text [ en-US ] = "Length";
+};
+
+String RID_STR_XSD_MIN_LENGTH
+{
+ Text [ en-US ] = "Length (at least)";
+};
+
+String RID_STR_XSD_MAX_LENGTH
+{
+ Text [ en-US ] = "Length (at most)";
+};
+
+String RID_STR_XSD_TOTAL_DIGITS
+{
+ Text [ en-US ] = "Digits (total)";
+};
+
+String RID_STR_XSD_FRACTION_DIGITS
+{
+ Text [ en-US ] = "Digits (fraction)";
+};
+
+String RID_STR_XSD_MAX_INCLUSIVE
+{
+ Text [ en-US ] = "Max. (inclusive)";
+};
+
+String RID_STR_XSD_MAX_EXCLUSIVE
+{
+ Text [ en-US ] = "Max. (exclusive)";
+};
+
+String RID_STR_XSD_MIN_INCLUSIVE
+{
+ Text [ en-US ] = "Min. (inclusive)";
+};
+
+String RID_STR_XSD_MIN_EXCLUSIVE
+{
+ Text [ en-US ] = "Min. (exclusive)";
+};
+
+String RID_STR_SUBMISSION_ID
+{
+ Text [ en-US ] = "Submission";
+};
+
+String RID_STR_BINDING_UI_NAME
+{
+ Text [ en-US ] = "Binding" ;
+};
+
+String RID_STR_SELECTION_TYPE
+{
+ Text [ en-US ] = "Selection type" ;
+};
+
+String RID_STR_ROOT_DISPLAYED
+{
+ Text [ en-US ] = "Root displayed" ;
+};
+
+String RID_STR_SHOWS_HANDLES
+{
+ Text [ en-US ] = "Show handles" ;
+};
+
+String RID_STR_SHOWS_ROOT_HANDLES
+{
+ Text [ en-US ] = "Show root handles" ;
+};
+
+String RID_STR_EDITABLE
+{
+ Text [ en-US ] = "Editable" ;
+};
+
+String RID_STR_INVOKES_STOP_NOT_EDITING
+{
+ Text [ en-US ] = "Invokes stop node editing" ;
+};
+
+String RID_STR_DECORATION
+{
+ Text [ en-US ] = "With title bar" ;
+};
+
+String RID_STR_NOLABEL
+{
+ Text [ en-US ] = "No Label" ;
+};
+
+Resource RID_RSC_ENUM_SCALE_MODE
+{
+ String 1
+ {
+ Text [ en-US ] = "No";
+ };
+ String 2
+ {
+ Text [ en-US ] = "Keep Ratio";
+ };
+ String 3
+ {
+ Text [ en-US ] = "Fit to Size";
+ };
+};
+String RID_STR_INPUT_REQUIRED
+{
+ Text [ en-US ] = "Input required";
+};
+
+String RID_STR_WRITING_MODE
+{
+ Text [ en-US ] = "Text direction";
+};
+
+Resource RID_RSC_ENUM_WRITING_MODE
+{
+ String 1
+ {
+ Text [ en-US ] = "Left-to-right";
+ };
+ String 2
+ {
+ Text [ en-US ] = "Right-to-left";
+ };
+ String 3
+ {
+ Text [ en-US ] = "Use superordinate object settings";
+ };
+};
+
+Resource RID_RSC_ENUM_WHEEL_BEHAVIOR
+{
+ String 1
+ {
+ Text [ en-US ] = "Never";
+ };
+ String 2
+ {
+ Text [ en-US ] = "When focused";
+ };
+ String 3
+ {
+ Text [ en-US ] = "Always";
+ };
+};
+
+String RID_STR_ANCHOR_TYPE
+{
+ Text [ en-US ] = "Anchor";
+};
+
+Resource RID_RSC_ENUM_TEXT_ANCHOR_TYPE
+{
+ String 1
+ {
+ Text [ en-US ] = "To Paragraph";
+ };
+ String 2
+ {
+ Text [ en-US ] = "As Character";
+ };
+ String 3
+ {
+ Text [ en-US ] = "To Page";
+ };
+ String 4
+ {
+ Text [ en-US ] = "To Frame";
+ };
+ String 5
+ {
+ Text [ en-US ] = "To Character";
+ };
+};
+
+Resource RID_RSC_ENUM_SHEET_ANCHOR_TYPE
+{
+ String 1
+ {
+ Text [ en-US ] = "To Page";
+ };
+ String 2
+ {
+ Text [ en-US ] = "To Cell";
+ };
+};
+
+String RID_STR_FONTSTYLE_REGULAR
+{
+ Text [ en-US ] = "Regular";
+ Text [ x-comment ] = "That's the 'Regular' as used for a font style (as opposed to 'italic' and 'bold'), so please use a consistent translation.";
+};
+
+String RID_STR_FONTSTYLE_BOLD_ITALIC
+{
+ Text [ en-US ] = "Bold Italic";
+ Text [ x-comment ] = "That's the 'Bold Italic' as used for a font style, so please use a consistent translation.";
+};
+
+String RID_STR_FONTSTYLE_ITALIC
+{
+ Text [ en-US ] = "Italic";
+ Text [ x-comment ] = "That's the 'Italic' as used for a font style, so please use a consistent translation.";
+};
+
+String RID_STR_FONTSTYLE_BOLD
+{
+ Text [ en-US ] = "Bold";
+ Text [ x-comment ] = "That's the 'Bold' as used for a font style, so please use a consistent translation.";
+};
+
+String RID_STR_FONT_DEFAULT
+{
+ Text [ en-US ] = "(Default)";
+};
diff --git a/extensions/source/propctrlr/formresid.hrc b/extensions/source/propctrlr/formresid.hrc
new file mode 100644
index 000000000000..e05a6bbab365
--- /dev/null
+++ b/extensions/source/propctrlr/formresid.hrc
@@ -0,0 +1,390 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _EXTENSIONS_FORMCTRLR_PROPRESID_HRC_
+#define _EXTENSIONS_FORMCTRLR_PROPRESID_HRC_
+
+#ifndef EXTENSIONS_PROPRESID_HRC
+#include "propresid.hrc"
+#endif
+
+// -----------------------------------------------------------------------
+// - Strings
+
+#define RID_STR_FORMS ( RID_FORMBROWSER_START + 1 )
+#define RID_STR_PROPTITLE_DBGRID ( RID_FORMBROWSER_START + 2 )
+#define RID_STR_PROPTITLE_PATTERNFIELD ( RID_FORMBROWSER_START + 3 )
+#define RID_STR_PROPTITLE_CURRENCYFIELD ( RID_FORMBROWSER_START + 4 )
+#define RID_STR_PROPTITLE_NUMERICFIELD ( RID_FORMBROWSER_START + 5 )
+#define RID_STR_PROPTITLE_TIMEFIELD ( RID_FORMBROWSER_START + 6 )
+#define RID_STR_PROPTITLE_DATEFIELD ( RID_FORMBROWSER_START + 7 )
+#define RID_STR_PROPTITLE_FILECONTROL ( RID_FORMBROWSER_START + 8 )
+#define RID_STR_PROPTITLE_IMAGECONTROL ( RID_FORMBROWSER_START + 9 )
+#define RID_STR_PROPTITLE_IMAGEBUTTON ( RID_FORMBROWSER_START + 10 )
+#define RID_STR_PROPTITLE_COMBOBOX ( RID_FORMBROWSER_START + 11 )
+#define RID_STR_PROPTITLE_LISTBOX ( RID_FORMBROWSER_START + 12 )
+#define RID_STR_PROPTITLE_FORMATTED ( RID_FORMBROWSER_START + 13 )
+#define RID_STR_PROPTITLE_EDIT ( RID_FORMBROWSER_START + 14 )
+#define RID_STR_PROPTITLE_GROUPBOX ( RID_FORMBROWSER_START + 15 )
+#define RID_STR_PROPTITLE_FIXEDTEXT ( RID_FORMBROWSER_START + 16 )
+#define RID_STR_PROPTITLE_CHECKBOX ( RID_FORMBROWSER_START + 17 )
+#define RID_STR_PROPTITLE_RADIOBUTTON ( RID_FORMBROWSER_START + 18 )
+#define RID_STR_PROPTITLE_PUSHBUTTON ( RID_FORMBROWSER_START + 19 )
+#define RID_STR_PROPTITLE_HIDDENCONTROL ( RID_FORMBROWSER_START + 30 )
+#define RID_STR_PROPTITLE_UNKNOWNCONTROL ( RID_FORMBROWSER_START + 31 )
+
+#define RID_STR_NAME ( RID_FORMBROWSER_START + 32 )
+#define RID_STR_LABEL ( RID_FORMBROWSER_START + 33 )
+#define RID_STR_LABELCONTROL ( RID_FORMBROWSER_START + 34 )
+#define RID_STR_MAXTEXTLEN ( RID_FORMBROWSER_START + 35 )
+#define RID_STR_EDITMASK ( RID_FORMBROWSER_START + 36 )
+#define RID_STR_LITERALMASK ( RID_FORMBROWSER_START + 37 )
+#define RID_STR_STRICTFORMAT ( RID_FORMBROWSER_START + 38 )
+#define RID_STR_ENABLED ( RID_FORMBROWSER_START + 39 )
+#define RID_STR_READONLY ( RID_FORMBROWSER_START + 40 )
+#define RID_STR_PRINTABLE ( RID_FORMBROWSER_START + 41 )
+#define RID_STR_CONTROLSOURCE ( RID_FORMBROWSER_START + 42 )
+#define RID_STR_TABSTOP ( RID_FORMBROWSER_START + 43 )
+#define RID_STR_TABINDEX ( RID_FORMBROWSER_START + 44 )
+#define RID_STR_DATASOURCE ( RID_FORMBROWSER_START + 45 )
+#define RID_STR_CURSORSOURCE ( RID_FORMBROWSER_START + 46 )
+#define RID_STR_CURSORSOURCETYPE ( RID_FORMBROWSER_START + 47 )
+#define RID_STR_FILTER ( RID_FORMBROWSER_START + 48 )
+#define RID_STR_SORT_CRITERIA ( RID_FORMBROWSER_START + 49 )
+#define RID_STR_ALLOW_ADDITIONS ( RID_FORMBROWSER_START + 50 )
+#define RID_STR_ALLOW_EDITS ( RID_FORMBROWSER_START + 51 )
+#define RID_STR_ALLOW_DELETIONS ( RID_FORMBROWSER_START + 52 )
+#define RID_STR_DATAENTRY ( RID_FORMBROWSER_START + 53 )
+#define RID_STR_CYCLE ( RID_FORMBROWSER_START + 54 )
+#define RID_STR_VALUE ( RID_FORMBROWSER_START + 55 )
+#define RID_STR_VALUESTEP ( RID_FORMBROWSER_START + 56 )
+#define RID_STR_DECIMAL_ACCURACY ( RID_FORMBROWSER_START + 57 )
+#define RID_STR_SHOWTHOUSANDSEP ( RID_FORMBROWSER_START + 58 )
+#define RID_STR_REFVALUE ( RID_FORMBROWSER_START + 59 )
+#define RID_STR_CURRENCYSYMBOL ( RID_FORMBROWSER_START + 60 )
+#define RID_STR_CURRSYM_POSITION ( RID_FORMBROWSER_START + 61 )
+#define RID_STR_DATEMIN ( RID_FORMBROWSER_START + 62 )
+#define RID_STR_DATEMAX ( RID_FORMBROWSER_START + 63 )
+#define RID_STR_DATEFORMAT ( RID_FORMBROWSER_START + 64 )
+#define RID_STR_SELECTEDITEMS ( RID_FORMBROWSER_START + 65 )
+#define RID_STR_TIMEMIN ( RID_FORMBROWSER_START + 66 )
+#define RID_STR_TIMEMAX ( RID_FORMBROWSER_START + 67 )
+#define RID_STR_TIMEFORMAT ( RID_FORMBROWSER_START + 68 )
+#define RID_STR_VALUEMIN ( RID_FORMBROWSER_START + 69 )
+#define RID_STR_VALUEMAX ( RID_FORMBROWSER_START + 70 )
+#define RID_STR_FORMATKEY ( RID_FORMBROWSER_START + 71 )
+#define RID_STR_CLASSID ( RID_FORMBROWSER_START + 72 )
+#define RID_STR_HEIGHT ( RID_FORMBROWSER_START + 73 )
+#define RID_STR_WIDTH ( RID_FORMBROWSER_START + 74 )
+#define RID_STR_BOUNDCOLUMN ( RID_FORMBROWSER_START + 75 )
+#define RID_STR_LISTSOURCETYPE ( RID_FORMBROWSER_START + 76 )
+#define RID_STR_LISTSOURCE ( RID_FORMBROWSER_START + 77 )
+#define RID_STR_LISTINDEX ( RID_FORMBROWSER_START + 78 )
+#define RID_STR_STRINGITEMLIST ( RID_FORMBROWSER_START + 79 )
+#define RID_STR_DEFAULTVALUE ( RID_FORMBROWSER_START + 80 )
+#define RID_STR_FONT ( RID_FORMBROWSER_START + 81 )
+#define RID_STR_ALIGN ( RID_FORMBROWSER_START + 82 )
+#define RID_STR_ROWHEIGHT ( RID_FORMBROWSER_START + 83 )
+#define RID_STR_BACKGROUNDCOLOR ( RID_FORMBROWSER_START + 84 )
+#define RID_STR_FILLCOLOR ( RID_FORMBROWSER_START + 85 )
+#define RID_STR_LINECOLOR ( RID_FORMBROWSER_START + 86 )
+#define RID_STR_BORDER ( RID_FORMBROWSER_START + 87 )
+#define RID_STR_DROPDOWN ( RID_FORMBROWSER_START + 88 )
+#define RID_STR_AUTOCOMPLETE ( RID_FORMBROWSER_START + 89 )
+#define RID_STR_LINECOUNT ( RID_FORMBROWSER_START + 90 )
+#define RID_STR_MULTILINE ( RID_FORMBROWSER_START + 91 )
+#define RID_STR_MULTISELECTION ( RID_FORMBROWSER_START + 92 )
+#define RID_STR_BUTTONTYPE ( RID_FORMBROWSER_START + 93 )
+#define RID_STR_HSCROLL ( RID_FORMBROWSER_START + 94 )
+#define RID_STR_VSCROLL ( RID_FORMBROWSER_START + 95 )
+#define RID_STR_SPIN ( RID_FORMBROWSER_START + 96 )
+#define RID_STR_AUTOLINEBREAK ( RID_FORMBROWSER_START + 97 )
+#define RID_STR_TARGET_URL ( RID_FORMBROWSER_START + 98 )
+#define RID_STR_TARGET_FRAME ( RID_FORMBROWSER_START + 99 )
+#define RID_STR_SUBMIT_ACTION ( RID_FORMBROWSER_START + 100 )
+#define RID_STR_SUBMIT_TARGET ( RID_FORMBROWSER_START + 101 )
+#define RID_STR_SUBMIT_METHOD ( RID_FORMBROWSER_START + 102 )
+#define RID_STR_SUBMIT_ENCODING ( RID_FORMBROWSER_START + 103 )
+#define RID_STR_DEFAULT_STATE ( RID_FORMBROWSER_START + 104 )
+#define RID_STR_DEFAULT_BUTTON ( RID_FORMBROWSER_START + 105 )
+#define RID_STR_IMAGE_URL ( RID_FORMBROWSER_START + 106 )
+#define RID_STR_DEFAULT_SELECT_SEQ ( RID_FORMBROWSER_START + 107 )
+#define RID_STR_ECHO_CHAR ( RID_FORMBROWSER_START + 108 )
+#define RID_STR_EMPTY_IS_NULL ( RID_FORMBROWSER_START + 109 )
+#define RID_STR_TRISTATE ( RID_FORMBROWSER_START + 110 )
+#define RID_STR_MASTERFIELDS ( RID_FORMBROWSER_START + 111 )
+#define RID_STR_SLAVEFIELDS ( RID_FORMBROWSER_START + 112 )
+#define RID_STR_NAVIGATION ( RID_FORMBROWSER_START + 113 )
+#define RID_STR_RECORDMARKER ( RID_FORMBROWSER_START + 114 )
+#define RID_STR_FILTERPROPOSAL ( RID_FORMBROWSER_START + 115 )
+#define RID_STR_TAG ( RID_FORMBROWSER_START + 116 )
+#define RID_STR_HELPTEXT ( RID_FORMBROWSER_START + 117 )
+#define RID_STR_HELPURL ( RID_FORMBROWSER_START + 118 )
+#define RID_STR_INPUT_REQUIRED ( RID_FORMBROWSER_START + 119 )
+#define RID_STR_UNCHECKEDREFVALUE ( RID_FORMBROWSER_START + 120 )
+#define RID_STR_CURSOR_TYPE ( RID_FORMBROWSER_START + 121 )
+#define RID_STR_ENABLE_VISIBLE ( RID_FORMBROWSER_START + 122 )
+#define RID_STR_WHEEL_BEHAVIOR ( RID_FORMBROWSER_START + 123 )
+#define RID_STR_GROUP_NAME ( RID_FORMBROWSER_START + 124 )
+ // FREE
+ // FREE
+ // FREE
+ // FREE
+ // FREE
+ // FREE
+ // FREE
+#define RID_STR_ENUM_NAVIGATION ( RID_FORMBROWSER_START + 131 )
+#define RID_STR_EVT_APPROVEACTIONPERFORMED ( RID_FORMBROWSER_START + 132 )
+#define RID_STR_EVT_ACTIONPERFORMED ( RID_FORMBROWSER_START + 133 )
+#define RID_STR_EVT_CHANGED ( RID_FORMBROWSER_START + 134 )
+#define RID_STR_EVT_TEXTCHANGED ( RID_FORMBROWSER_START + 135 )
+#define RID_STR_EVT_ITEMSTATECHANGED ( RID_FORMBROWSER_START + 136 )
+#define RID_STR_EVT_FOCUSGAINED ( RID_FORMBROWSER_START + 137 )
+#define RID_STR_EVT_FOCUSLOST ( RID_FORMBROWSER_START + 138 )
+#define RID_STR_EVT_KEYTYPED ( RID_FORMBROWSER_START + 139 )
+#define RID_STR_EVT_KEYUP ( RID_FORMBROWSER_START + 140 )
+#define RID_STR_EVT_MOUSEENTERED ( RID_FORMBROWSER_START + 141 )
+#define RID_STR_EVT_MOUSEDRAGGED ( RID_FORMBROWSER_START + 142 )
+#define RID_STR_EVT_MOUSEMOVED ( RID_FORMBROWSER_START + 143 )
+#define RID_STR_EVT_MOUSEPRESSED ( RID_FORMBROWSER_START + 144 )
+#define RID_STR_EVT_MOUSERELEASED ( RID_FORMBROWSER_START + 145 )
+#define RID_STR_EVT_MOUSEEXITED ( RID_FORMBROWSER_START + 146 )
+#define RID_STR_EVT_APPROVERESETTED ( RID_FORMBROWSER_START + 147 )
+#define RID_STR_EVT_RESETTED ( RID_FORMBROWSER_START + 148 )
+#define RID_STR_EVT_SUBMITTED ( RID_FORMBROWSER_START + 149 )
+#define RID_STR_EVT_BEFOREUPDATE ( RID_FORMBROWSER_START + 150 )
+#define RID_STR_EVT_AFTERUPDATE ( RID_FORMBROWSER_START + 151 )
+#define RID_STR_EVT_LOADED ( RID_FORMBROWSER_START + 152 )
+#define RID_STR_EVT_RELOADING ( RID_FORMBROWSER_START + 153 )
+#define RID_STR_EVT_RELOADED ( RID_FORMBROWSER_START + 154 )
+#define RID_STR_EVT_UNLOADING ( RID_FORMBROWSER_START + 155 )
+#define RID_STR_EVT_UNLOADED ( RID_FORMBROWSER_START + 156 )
+#define RID_STR_EVT_CONFIRMDELETE ( RID_FORMBROWSER_START + 157 )
+#define RID_STR_EVT_APPROVEROWCHANGE ( RID_FORMBROWSER_START + 158 )
+#define RID_STR_EVT_ROWCHANGE ( RID_FORMBROWSER_START + 159 )
+#define RID_STR_EVT_POSITIONING ( RID_FORMBROWSER_START + 160 )
+#define RID_STR_EVT_POSITIONED ( RID_FORMBROWSER_START + 161 )
+#define RID_STR_EVT_APPROVEPARAMETER ( RID_FORMBROWSER_START + 162 )
+#define RID_STR_EVT_ERROROCCURED ( RID_FORMBROWSER_START + 163 )
+#define RID_STR_EVENTS ( RID_FORMBROWSER_START + 164 )
+#define RID_STR_ESCAPE_PROCESSING ( RID_FORMBROWSER_START + 165 )
+ // FREE
+#define RID_STR_POSITIONX ( RID_FORMBROWSER_START + 167 )
+#define RID_STR_POSITIONY ( RID_FORMBROWSER_START + 168 )
+#define RID_STR_TITLE ( RID_FORMBROWSER_START + 169 )
+#define RID_STR_STEP ( RID_FORMBROWSER_START + 170 )
+#define RID_STR_PROGRESSVALUE ( RID_FORMBROWSER_START + 171 )
+#define RID_STR_PROGRESSVALUE_MIN ( RID_FORMBROWSER_START + 172 )
+#define RID_STR_PROGRESSVALUE_MAX ( RID_FORMBROWSER_START + 173 )
+#define RID_STR_SCROLLVALUE ( RID_FORMBROWSER_START + 174 )
+#define RID_STR_SCROLLVALUE_MAX ( RID_FORMBROWSER_START + 175 )
+#define RID_STR_LINEINCREMENT ( RID_FORMBROWSER_START + 176 )
+#define RID_STR_BLOCKINCREMENT ( RID_FORMBROWSER_START + 177 )
+#define RID_STR_VISIBLESIZE ( RID_FORMBROWSER_START + 178 )
+#define RID_STR_ORIENTATION ( RID_FORMBROWSER_START + 179 )
+ // FREE
+#define RID_STR_VERTICAL_ALIGN ( RID_FORMBROWSER_START + 181 )
+#define RID_STR_EVT_ADJUSTMENTVALUECHANGED ( RID_FORMBROWSER_START + 182 )
+#define RID_STR_DATE ( RID_FORMBROWSER_START + 183 )
+#define RID_STR_STATE ( RID_FORMBROWSER_START + 184 )
+#define RID_STR_TIME ( RID_FORMBROWSER_START + 185 )
+#define RID_STR_SCALEIMAGE ( RID_FORMBROWSER_START + 186 )
+#define RID_STR_PUSHBUTTONTYPE ( RID_FORMBROWSER_START + 187 )
+#define RID_STR_ENUM_PUSHBUTTONTYPE ( RID_FORMBROWSER_START + 188 )
+#define RID_STR_UNABLETOCONNECT ( RID_FORMBROWSER_START + 189 )
+#define RID_STR_TEXT ( RID_FORMBROWSER_START + 190 )
+#define RID_STR_BOUND_CELL ( RID_FORMBROWSER_START + 191 )
+#define RID_STR_LIST_CELL_RANGE ( RID_FORMBROWSER_START + 192 )
+#define RID_STR_CELL_EXCHANGE_TYPE ( RID_FORMBROWSER_START + 193 )
+#define RID_STR_ANCHOR_TYPE ( RID_FORMBROWSER_START + 194 )
+#define RID_STR_SCROLLVALUE_MIN ( RID_FORMBROWSER_START + 195 )
+#define RID_STR_DEFAULT_SCROLLVALUE ( RID_FORMBROWSER_START + 196 )
+#define RID_STR_REPEAT_DELAY ( RID_FORMBROWSER_START + 197 )
+#define RID_STR_SYMBOLCOLOR ( RID_FORMBROWSER_START + 198 )
+#define RID_STR_REPEAT ( RID_FORMBROWSER_START + 199 )
+#define RID_STR_IMAGEPOSITION ( RID_FORMBROWSER_START + 200 )
+#define RID_STR_DEFAULTTEXT ( RID_FORMBROWSER_START + 201 )
+#define RID_STR_DEFAULTDATE ( RID_FORMBROWSER_START + 202 )
+#define RID_STR_DEFAULTTIME ( RID_FORMBROWSER_START + 203 )
+#define RID_STR_WORDBREAK ( RID_FORMBROWSER_START + 204 )
+#define RID_STR_SHOW_SCROLLBARS ( RID_FORMBROWSER_START + 205 )
+#define RID_STR_QUERYDESIGN_TITLE ( RID_FORMBROWSER_START + 206 )
+#define RID_STR_ICONSIZE ( RID_FORMBROWSER_START + 207 )
+#define RID_STR_WRITING_MODE ( RID_FORMBROWSER_START + 208 )
+#define RID_STR_SHOW_POSITION ( RID_FORMBROWSER_START + 209 )
+#define RID_STR_SHOW_NAVIGATION ( RID_FORMBROWSER_START + 210 )
+#define RID_STR_SHOW_RECORDACTIONS ( RID_FORMBROWSER_START + 211 )
+#define RID_STR_SHOW_FILTERSORT ( RID_FORMBROWSER_START + 212 )
+#define RID_STR_TEXTTYPE ( RID_FORMBROWSER_START + 213 )
+#define RID_STR_LINEEND_FORMAT ( RID_FORMBROWSER_START + 214 )
+#define RID_STR_TOGGLE ( RID_FORMBROWSER_START + 215 )
+#define RID_STR_FOCUSONCLICK ( RID_FORMBROWSER_START + 216 )
+#define RID_STR_HIDEINACTIVESELECTION ( RID_FORMBROWSER_START + 217 )
+#define RID_STR_VISUALEFFECT ( RID_FORMBROWSER_START + 218 )
+#define RID_STR_BORDERCOLOR ( RID_FORMBROWSER_START + 219 )
+ // FREE
+#define RID_STR_XML_DATA_MODEL ( RID_FORMBROWSER_START + 221 )
+#define RID_STR_BIND_EXPRESSION ( RID_FORMBROWSER_START + 222 )
+#define RID_STR_XSD_REQUIRED ( RID_FORMBROWSER_START + 223 )
+#define RID_STR_XSD_RELEVANT ( RID_FORMBROWSER_START + 224 )
+#define RID_STR_XSD_READONLY ( RID_FORMBROWSER_START + 225 )
+#define RID_STR_XSD_CONSTRAINT ( RID_FORMBROWSER_START + 226 )
+#define RID_STR_XSD_CALCULATION ( RID_FORMBROWSER_START + 227 )
+#define RID_STR_XSD_DATA_TYPE ( RID_FORMBROWSER_START + 228 )
+#define RID_STR_XSD_WHITESPACES ( RID_FORMBROWSER_START + 229 )
+#define RID_STR_XSD_PATTERN ( RID_FORMBROWSER_START + 230 )
+#define RID_STR_XSD_LENGTH ( RID_FORMBROWSER_START + 231 )
+#define RID_STR_XSD_MIN_LENGTH ( RID_FORMBROWSER_START + 232 )
+#define RID_STR_XSD_MAX_LENGTH ( RID_FORMBROWSER_START + 233 )
+#define RID_STR_XSD_TOTAL_DIGITS ( RID_FORMBROWSER_START + 234 )
+#define RID_STR_XSD_FRACTION_DIGITS ( RID_FORMBROWSER_START + 235 )
+#define RID_STR_XSD_MAX_INCLUSIVE ( RID_FORMBROWSER_START + 236 )
+#define RID_STR_XSD_MAX_EXCLUSIVE ( RID_FORMBROWSER_START + 237 )
+#define RID_STR_XSD_MIN_INCLUSIVE ( RID_FORMBROWSER_START + 238 )
+#define RID_STR_XSD_MIN_EXCLUSIVE ( RID_FORMBROWSER_START + 239 )
+#define RID_STR_SUBMISSION_ID ( RID_FORMBROWSER_START + 240 )
+#define RID_STR_LIST_BINDING ( RID_FORMBROWSER_START + 241 )
+#define RID_STR_BINDING_UI_NAME ( RID_FORMBROWSER_START + 242 )
+#define RID_STR_BINDING_NAME RID_STR_BINDING_UI_NAME
+#define RID_STR_DECORATION ( RID_FORMBROWSER_START + 243 )
+#define RID_STR_SELECTION_TYPE ( RID_FORMBROWSER_START + 244 )
+#define RID_STR_ROOT_DISPLAYED ( RID_FORMBROWSER_START + 245 )
+#define RID_STR_SHOWS_HANDLES ( RID_FORMBROWSER_START + 246 )
+#define RID_STR_SHOWS_ROOT_HANDLES ( RID_FORMBROWSER_START + 247 )
+#define RID_STR_EDITABLE ( RID_FORMBROWSER_START + 248 )
+#define RID_STR_INVOKES_STOP_NOT_EDITING ( RID_FORMBROWSER_START + 249 )
+#define RID_STR_NOLABEL ( RID_FORMBROWSER_START + 250 )
+#define RID_STR_FONTSTYLE_REGULAR ( RID_FORMBROWSER_START + 251 )
+#define RID_STR_FONTSTYLE_BOLD_ITALIC ( RID_FORMBROWSER_START + 252 )
+#define RID_STR_FONTSTYLE_ITALIC ( RID_FORMBROWSER_START + 253 )
+#define RID_STR_FONTSTYLE_BOLD ( RID_FORMBROWSER_START + 254 )
+#define RID_STR_FONT_DEFAULT ( RID_FORMBROWSER_START + 255 )
+
+
+// -----------------------------------------------------------------------
+// - message strings
+
+#define RID_STR_CONFIRM_DELETE_DATA_TYPE ( RID_FORMBROWSER_START + 500 )
+
+// -----------------------------------------------------------------------
+// - dialogs
+
+#define RID_DLG_SELECTLABELCONTROL ( RID_PROPCONTROLLER_START + 0 )
+#define RID_DLG_TABORDER ( RID_PROPCONTROLLER_START + 1 )
+#define RID_DLG_FORMLINKS ( RID_PROPCONTROLLER_START + 2 )
+#define RID_DLG_SELECTION ( RID_PROPCONTROLLER_START + 3 )
+#define RID_DLG_NEW_DATA_TYPE ( RID_PROPCONTROLLER_START + 4 )
+
+// -----------------------------------------------------------------------
+// - tab dialogs
+
+#define RID_TABDLG_FONTDIALOG ( RID_PROPCONTROLLER_START + 0 )
+
+// -----------------------------------------------------------------------
+// - ImageLists
+
+#define RID_IL_FORMEXPLORER ( RID_PROPCONTROLLER_START + 0 )
+#define RID_IL_FORMEXPLORER_HC ( RID_PROPCONTROLLER_START + 1 )
+
+// -----------------------------------------------------------------------
+// - untyped resources
+
+#define RID_RSC_ENUM_SCROLLBARS ( RID_PROPCONTROLLER_START + 0 )
+#define RID_RSC_ENUM_COMMAND_TYPE ( RID_PROPCONTROLLER_START + 1 )
+#define RID_RSC_ENUM_LINEEND_FORMAT ( RID_PROPCONTROLLER_START + 2 )
+#define RID_RSC_ENUM_TEXTTYPE ( RID_PROPCONTROLLER_START + 3 )
+#define RID_RSC_ENUM_VISUALEFFECT ( RID_PROPCONTROLLER_START + 4 )
+#define RID_RSC_ENUM_IMAGE_POSITION ( RID_PROPCONTROLLER_START + 5 )
+#define RID_RSC_BUTTON_IMAGES ( RID_PROPCONTROLLER_START + 6 )
+#define RID_RSC_ENUM_WHITESPACE_HANDLING ( RID_PROPCONTROLLER_START + 7 )
+#define RID_RSC_ENUM_VERTICAL_ALIGN ( RID_PROPCONTROLLER_START + 8 )
+#define RID_RSC_ENUM_BORDER_TYPE ( RID_PROPCONTROLLER_START + 9 )
+#define RID_RSC_ENUM_ICONSIZE_TYPE ( RID_PROPCONTROLLER_START + 10 )
+#define RID_RSC_ENUM_LISTSOURCE_TYPE ( RID_PROPCONTROLLER_START + 11 )
+#define RID_RSC_ENUM_ALIGNMENT ( RID_PROPCONTROLLER_START + 12 )
+#define RID_RSC_ENUM_BUTTONTYPE ( RID_PROPCONTROLLER_START + 13 )
+#define RID_RSC_ENUM_PUSHBUTTONTYPE ( RID_PROPCONTROLLER_START + 14 )
+#define RID_RSC_ENUM_SUBMIT_METHOD ( RID_PROPCONTROLLER_START + 15 )
+#define RID_RSC_ENUM_SUBMIT_ENCODING ( RID_PROPCONTROLLER_START + 16 )
+#define RID_RSC_ENUM_DATEFORMAT_LIST ( RID_PROPCONTROLLER_START + 17 )
+#define RID_RSC_ENUM_TIMEFORMAT_LIST ( RID_PROPCONTROLLER_START + 18 )
+#define RID_RSC_ENUM_CHECKED ( RID_PROPCONTROLLER_START + 19 )
+#define RID_RSC_ENUM_CYCLE ( RID_PROPCONTROLLER_START + 20 )
+#define RID_RSC_ENUM_NAVIGATION ( RID_PROPCONTROLLER_START + 21 )
+#define RID_RSC_ENUM_ORIENTATION ( RID_PROPCONTROLLER_START + 22 )
+#define RID_RSC_ENUM_CELL_EXCHANGE_TYPE ( RID_PROPCONTROLLER_START + 23 )
+#define RID_RSC_ENUM_SUBMIT_TARGET ( RID_PROPCONTROLLER_START + 24 )
+#define RID_RSC_ENUM_SELECTION_TYPE ( RID_PROPCONTROLLER_START + 25 )
+#define RID_RSC_ENUM_SCALE_MODE ( RID_PROPCONTROLLER_START + 26 )
+#define RID_RSC_ENUM_YESNO ( RID_PROPCONTROLLER_START + 27 )
+#define RID_RSC_ENUM_SHOWHIDE ( RID_PROPCONTROLLER_START + 28 )
+#define RID_RSC_ENUM_WRITING_MODE ( RID_PROPCONTROLLER_START + 29 )
+#define RID_RSC_ENUM_WHEEL_BEHAVIOR ( RID_PROPCONTROLLER_START + 30 )
+#define RID_RSC_ENUM_TEXT_ANCHOR_TYPE ( RID_PROPCONTROLLER_START + 31 )
+#define RID_RSC_ENUM_SHEET_ANCHOR_TYPE ( RID_PROPCONTROLLER_START + 32 )
+
+// -----------------------------------------------------------------------
+// - ImageList - local ids
+// -----------------------------------------------------------------------
+// HACK HACK HACK
+// as long as we have no real property browser, but this outsourcing only,
+// we do not duplicate images. Instead we do some hard coding for the image ids
+
+
+#define RID_SVXIMG_CONTROL 10144
+#define RID_SVXIMG_BUTTON 10594
+#define RID_SVXIMG_RADIOBUTTON 10595
+#define RID_SVXIMG_CHECKBOX 10596
+#define RID_SVXIMG_FIXEDTEXT 10597
+#define RID_SVXIMG_GROUPBOX 10598
+#define RID_SVXIMG_EDIT 10599
+#define RID_SVXIMG_LISTBOX 10600
+#define RID_SVXIMG_COMBOBOX 10601
+#define RID_SVXIMG_URLBUTTON 10602
+#define RID_SVXIMG_GRID 10603
+#define RID_SVXIMG_IMAGEBUTTON 10604
+#define RID_SVXIMG_FILECONTROL 10605
+#define RID_SVXIMG_DATEFIELD 10704
+#define RID_SVXIMG_TIMEFIELD 10705
+#define RID_SVXIMG_NUMERICFIELD 10706
+#define RID_SVXIMG_CURRENCYFIELD 10707
+#define RID_SVXIMG_PATTERNFIELD 10708
+#define RID_SVXIMG_IMAGECONTROL 10710
+#define RID_SVXIMG_HIDDEN 18022
+#define RID_SVXIMG_FORMATTEDFIELD 10728
+#define RID_SVXIMG_FILTER 10715
+#define RID_SVXIMG_FORMS 18013
+#define RID_SVXIMG_FORM 10593
+#define RID_SVXIMG_COLLAPSEDNODE 18002
+#define RID_SVXIMG_EXPANDEDNODE 18003
+#define RID_SVXIMG_SCROLLBAR 10768
+#define RID_SVXIMG_SPINBUTTON 10769
+#define RID_SVXIMG_NAVIGATIONBAR 10607
+
+
+#endif // _EXTENSIONS_FORMCTRLR_PROPRESID_HRC_
+
diff --git a/extensions/source/propctrlr/formstrings.cxx b/extensions/source/propctrlr/formstrings.cxx
new file mode 100644
index 000000000000..45aefb4b04bb
--- /dev/null
+++ b/extensions/source/propctrlr/formstrings.cxx
@@ -0,0 +1,38 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+
+#ifndef _EXTENSIONS_FORMSCTRLR_FORMSTRINGS_HXX_
+#define PCR_IMPLEMENT_STRINGS
+#include "formstrings.hxx"
+#undef PCR_IMPLEMENT_STRINGS
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/propctrlr/formstrings.hxx b/extensions/source/propctrlr/formstrings.hxx
new file mode 100644
index 000000000000..0910105dabc3
--- /dev/null
+++ b/extensions/source/propctrlr/formstrings.hxx
@@ -0,0 +1,310 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _EXTENSIONS_FORMSCTRLR_FORMSTRINGS_HXX_
+#define _EXTENSIONS_FORMSCTRLR_FORMSTRINGS_HXX_
+
+#include "stringdefine.hxx"
+
+//............................................................................
+namespace pcr
+{
+//............................................................................
+
+ PCR_CONSTASCII_STRING( PROPERTY_DEFAULTCONTROL, "DefaultControl" );
+ PCR_CONSTASCII_STRING( PROPERTY_INTROSPECTEDOBJECT, "IntrospectedObject" );
+ PCR_CONSTASCII_STRING( PROPERTY_CURRENTPAGE, "CurrentPage" );
+ PCR_CONSTASCII_STRING( PROPERTY_CONTROLCONTEXT, "ControlContext" );
+
+ // properties
+ PCR_CONSTASCII_STRING( PROPERTY_CLASSID, "ClassId" );
+ PCR_CONSTASCII_STRING( PROPERTY_CONTROLLABEL, "LabelControl");
+ PCR_CONSTASCII_STRING( PROPERTY_LABEL, "Label");
+ PCR_CONSTASCII_STRING( PROPERTY_TABINDEX, "TabIndex");
+ PCR_CONSTASCII_STRING( PROPERTY_WHEEL_BEHAVIOR, "MouseWheelBehavior");
+ PCR_CONSTASCII_STRING( PROPERTY_TAG, "Tag");
+ PCR_CONSTASCII_STRING( PROPERTY_NAME, "Name");
+ PCR_CONSTASCII_STRING( PROPERTY_GROUP_NAME, "GroupName");
+ PCR_CONSTASCII_STRING( PROPERTY_VALUE, "Value");
+ PCR_CONSTASCII_STRING( PROPERTY_TEXT, "Text");
+ PCR_CONSTASCII_STRING( PROPERTY_NAVIGATION, "NavigationBarMode");
+ PCR_CONSTASCII_STRING( PROPERTY_CYCLE, "Cycle");
+ PCR_CONSTASCII_STRING( PROPERTY_CONTROLSOURCE, "DataField");
+ PCR_CONSTASCII_STRING( PROPERTY_INPUT_REQUIRED, "InputRequired");
+ PCR_CONSTASCII_STRING( PROPERTY_ENABLED, "Enabled");
+ PCR_CONSTASCII_STRING( PROPERTY_ENABLE_VISIBLE, "EnableVisible" );
+ PCR_CONSTASCII_STRING( PROPERTY_READONLY, "ReadOnly");
+ PCR_CONSTASCII_STRING( PROPERTY_ISREADONLY, "IsReadOnly");
+ PCR_CONSTASCII_STRING( PROPERTY_FILTER, "Filter");
+ PCR_CONSTASCII_STRING( PROPERTY_WIDTH, "Width");
+ PCR_CONSTASCII_STRING( PROPERTY_MULTILINE, "MultiLine");
+ PCR_CONSTASCII_STRING( PROPERTY_WORDBREAK, "WordBreak");
+ PCR_CONSTASCII_STRING( PROPERTY_TARGET_URL, "TargetURL");
+ PCR_CONSTASCII_STRING( PROPERTY_TARGET_FRAME, "TargetFrame");
+ PCR_CONSTASCII_STRING( PROPERTY_MAXTEXTLEN, "MaxTextLen");
+ PCR_CONSTASCII_STRING( PROPERTY_EDITMASK, "EditMask");
+ PCR_CONSTASCII_STRING( PROPERTY_SPIN, "Spin");
+ PCR_CONSTASCII_STRING( PROPERTY_TRISTATE, "TriState");
+ PCR_CONSTASCII_STRING( PROPERTY_HIDDEN_VALUE, "HiddenValue");
+ PCR_CONSTASCII_STRING( PROPERTY_BUTTONTYPE, "ButtonType");
+ PCR_CONSTASCII_STRING( PROPERTY_XFORMS_BUTTONTYPE, "XFormsButtonType");
+ PCR_CONSTASCII_STRING( PROPERTY_STRINGITEMLIST, "StringItemList");
+ PCR_CONSTASCII_STRING( PROPERTY_DEFAULT_TEXT, "DefaultText");
+ PCR_CONSTASCII_STRING( PROPERTY_DEFAULT_STATE, "DefaultState");
+ PCR_CONSTASCII_STRING( PROPERTY_FORMATKEY, "FormatKey");
+ PCR_CONSTASCII_STRING( PROPERTY_FORMATSSUPPLIER, "FormatsSupplier");
+ PCR_CONSTASCII_STRING( PROPERTY_SUBMIT_ACTION, "SubmitAction");
+ PCR_CONSTASCII_STRING( PROPERTY_SUBMIT_TARGET, "SubmitTarget");
+ PCR_CONSTASCII_STRING( PROPERTY_SUBMIT_METHOD, "SubmitMethod");
+ PCR_CONSTASCII_STRING( PROPERTY_SUBMIT_ENCODING, "SubmitEncoding");
+ PCR_CONSTASCII_STRING( PROPERTY_IMAGE_URL, "ImageURL");
+ PCR_CONSTASCII_STRING( PROPERTY_EMPTY_IS_NULL, "ConvertEmptyToNull");
+ PCR_CONSTASCII_STRING( PROPERTY_LISTSOURCETYPE, "ListSourceType");
+ PCR_CONSTASCII_STRING( PROPERTY_LISTSOURCE, "ListSource");
+ PCR_CONSTASCII_STRING( PROPERTY_DEFAULT_SELECT_SEQ, "DefaultSelection");
+ PCR_CONSTASCII_STRING( PROPERTY_MULTISELECTION, "MultiSelection");
+ PCR_CONSTASCII_STRING( PROPERTY_ALIGN, "Align");
+ PCR_CONSTASCII_STRING( PROPERTY_VERTICAL_ALIGN, "VerticalAlign");
+ PCR_CONSTASCII_STRING( PROPERTY_DEFAULT_DATE, "DefaultDate");
+ PCR_CONSTASCII_STRING( PROPERTY_DEFAULT_TIME, "DefaultTime");
+ PCR_CONSTASCII_STRING( PROPERTY_DEFAULT_VALUE, "DefaultValue");
+ PCR_CONSTASCII_STRING( PROPERTY_DECIMAL_ACCURACY, "DecimalAccuracy");
+ PCR_CONSTASCII_STRING( PROPERTY_REFVALUE, "RefValue");
+ PCR_CONSTASCII_STRING( PROPERTY_UNCHECKEDREFVALUE, "SecondaryRefValue");
+ PCR_CONSTASCII_STRING( PROPERTY_VALUEMIN, "ValueMin");
+ PCR_CONSTASCII_STRING( PROPERTY_VALUEMAX, "ValueMax");
+ PCR_CONSTASCII_STRING( PROPERTY_STRICTFORMAT, "StrictFormat");
+ PCR_CONSTASCII_STRING( PROPERTY_ALLOWADDITIONS, "AllowInserts");
+ PCR_CONSTASCII_STRING( PROPERTY_ALLOWEDITS, "AllowUpdates");
+ PCR_CONSTASCII_STRING( PROPERTY_ALLOWDELETIONS, "AllowDeletes");
+ PCR_CONSTASCII_STRING( PROPERTY_MASTERFIELDS, "MasterFields");
+ PCR_CONSTASCII_STRING( PROPERTY_LITERALMASK, "LiteralMask");
+ PCR_CONSTASCII_STRING( PROPERTY_VALUESTEP, "ValueStep");
+ PCR_CONSTASCII_STRING( PROPERTY_SHOWTHOUSANDSEP, "ShowThousandsSeparator");
+ PCR_CONSTASCII_STRING( PROPERTY_CURRENCYSYMBOL, "CurrencySymbol");
+ PCR_CONSTASCII_STRING( PROPERTY_DATEFORMAT, "DateFormat");
+ PCR_CONSTASCII_STRING( PROPERTY_DATEMIN, "DateMin");
+ PCR_CONSTASCII_STRING( PROPERTY_DATEMAX, "DateMax");
+ PCR_CONSTASCII_STRING( PROPERTY_TIMEFORMAT, "TimeFormat");
+ PCR_CONSTASCII_STRING( PROPERTY_TIMEMIN, "TimeMin");
+ PCR_CONSTASCII_STRING( PROPERTY_TIMEMAX, "TimeMax");
+ PCR_CONSTASCII_STRING( PROPERTY_LINECOUNT, "LineCount");
+ PCR_CONSTASCII_STRING( PROPERTY_BOUNDCOLUMN, "BoundColumn");
+ PCR_CONSTASCII_STRING( PROPERTY_BACKGROUNDCOLOR, "BackgroundColor");
+ PCR_CONSTASCII_STRING( PROPERTY_FILLCOLOR, "FillColor");
+ PCR_CONSTASCII_STRING( PROPERTY_TEXTCOLOR, "TextColor");
+ PCR_CONSTASCII_STRING( PROPERTY_LINECOLOR, "LineColor");
+ PCR_CONSTASCII_STRING( PROPERTY_BORDER, "Border");
+ PCR_CONSTASCII_STRING( PROPERTY_ICONSIZE, "IconSize");
+ PCR_CONSTASCII_STRING( PROPERTY_DROPDOWN, "Dropdown");
+ PCR_CONSTASCII_STRING( PROPERTY_HSCROLL, "HScroll");
+ PCR_CONSTASCII_STRING( PROPERTY_VSCROLL, "VScroll");
+ PCR_CONSTASCII_STRING( PROPERTY_SHOW_SCROLLBARS, "ShowScrollbars");
+ PCR_CONSTASCII_STRING( PROPERTY_TABSTOP, "Tabstop");
+ PCR_CONSTASCII_STRING( PROPERTY_AUTOCOMPLETE, "Autocomplete");
+ PCR_CONSTASCII_STRING( PROPERTY_PRINTABLE, "Printable");
+ PCR_CONSTASCII_STRING( PROPERTY_ECHO_CHAR, "EchoChar");
+ PCR_CONSTASCII_STRING( PROPERTY_ROWHEIGHT, "RowHeight");
+ PCR_CONSTASCII_STRING( PROPERTY_HELPTEXT, "HelpText");
+ PCR_CONSTASCII_STRING( PROPERTY_FONT, "FontDescriptor");
+ PCR_CONSTASCII_STRING( PROPERTY_FONT_NAME, "FontName");
+ PCR_CONSTASCII_STRING( PROPERTY_FONT_STYLENAME, "FontStyleName");
+ PCR_CONSTASCII_STRING( PROPERTY_FONT_FAMILY, "FontFamily");
+ PCR_CONSTASCII_STRING( PROPERTY_FONT_CHARSET, "FontCharset");
+ PCR_CONSTASCII_STRING( PROPERTY_FONT_HEIGHT, "FontHeight");
+ PCR_CONSTASCII_STRING( PROPERTY_FONT_WEIGHT, "FontWeight");
+ PCR_CONSTASCII_STRING( PROPERTY_FONT_SLANT, "FontSlant");
+ PCR_CONSTASCII_STRING( PROPERTY_FONT_UNDERLINE, "FontUnderline");
+ PCR_CONSTASCII_STRING( PROPERTY_FONT_STRIKEOUT, "FontStrikeout");
+ PCR_CONSTASCII_STRING( PROPERTY_FONT_RELIEF, "FontRelief");
+ PCR_CONSTASCII_STRING( PROPERTY_FONT_EMPHASIS_MARK, "FontEmphasisMark");
+ PCR_CONSTASCII_STRING( PROPERTY_TEXTLINECOLOR, "TextLineColor");
+ PCR_CONSTASCII_STRING( PROPERTY_HELPURL, "HelpURL");
+ PCR_CONSTASCII_STRING( PROPERTY_RECORDMARKER, "HasRecordMarker");
+ PCR_CONSTASCII_STRING( PROPERTY_EFFECTIVE_DEFAULT, "EffectiveDefault");
+ PCR_CONSTASCII_STRING( PROPERTY_EFFECTIVE_MIN, "EffectiveMin");
+ PCR_CONSTASCII_STRING( PROPERTY_EFFECTIVE_MAX, "EffectiveMax");
+ PCR_CONSTASCII_STRING( PROPERTY_FILTERPROPOSAL, "UseFilterValueProposal");
+ PCR_CONSTASCII_STRING( PROPERTY_CURRSYM_POSITION, "PrependCurrencySymbol");
+ PCR_CONSTASCII_STRING( PROPERTY_COMMAND, "Command");
+ PCR_CONSTASCII_STRING( PROPERTY_COMMANDTYPE, "CommandType");
+ PCR_CONSTASCII_STRING( PROPERTY_INSERTONLY, "IgnoreResult");
+ PCR_CONSTASCII_STRING( PROPERTY_ESCAPE_PROCESSING, "EscapeProcessing");
+ PCR_CONSTASCII_STRING( PROPERTY_TITLE, "Title");
+ PCR_CONSTASCII_STRING( PROPERTY_SORT, "Order");
+ PCR_CONSTASCII_STRING( PROPERTY_DATASOURCE, "DataSourceName");
+ PCR_CONSTASCII_STRING( PROPERTY_DETAILFIELDS, "DetailFields");
+ PCR_CONSTASCII_STRING( PROPERTY_DEFAULTBUTTON, "DefaultButton");
+ PCR_CONSTASCII_STRING( PROPERTY_LISTINDEX, "ListIndex");
+ PCR_CONSTASCII_STRING( PROPERTY_HEIGHT, "Height");
+ PCR_CONSTASCII_STRING( PROPERTY_HASNAVIGATION, "HasNavigationBar");
+ PCR_CONSTASCII_STRING( PROPERTY_POSITIONX, "PositionX");
+ PCR_CONSTASCII_STRING( PROPERTY_POSITIONY, "PositionY");
+ PCR_CONSTASCII_STRING( PROPERTY_STEP, "Step");
+ PCR_CONSTASCII_STRING( PROPERTY_WORDLINEMODE, "FontWordLineMode");
+ PCR_CONSTASCII_STRING( PROPERTY_PROGRESSVALUE, "ProgressValue");
+ PCR_CONSTASCII_STRING( PROPERTY_PROGRESSVALUE_MIN, "ProgressValueMin");
+ PCR_CONSTASCII_STRING( PROPERTY_PROGRESSVALUE_MAX, "ProgressValueMax");
+ PCR_CONSTASCII_STRING( PROPERTY_SCROLLVALUE, "ScrollValue");
+ PCR_CONSTASCII_STRING( PROPERTY_DEFAULT_SCROLLVALUE, "DefaultScrollValue");
+ PCR_CONSTASCII_STRING( PROPERTY_SCROLLVALUE_MIN, "ScrollValueMin");
+ PCR_CONSTASCII_STRING( PROPERTY_SCROLLVALUE_MAX, "ScrollValueMax");
+ PCR_CONSTASCII_STRING( PROPERTY_LINEINCREMENT, "LineIncrement");
+ PCR_CONSTASCII_STRING( PROPERTY_BLOCKINCREMENT, "BlockIncrement");
+ PCR_CONSTASCII_STRING( PROPERTY_VISIBLESIZE, "VisibleSize");
+ PCR_CONSTASCII_STRING( PROPERTY_ORIENTATION, "Orientation");
+ PCR_CONSTASCII_STRING( PROPERTY_IMAGEPOSITION, "ImagePosition");
+ PCR_CONSTASCII_STRING( PROPERTY_ACTIVE_CONNECTION, "ActiveConnection");
+ PCR_CONSTASCII_STRING( PROPERTY_ACTIVECOMMAND, "ActiveCommand");
+ PCR_CONSTASCII_STRING( PROPERTY_DATE, "Date");
+ PCR_CONSTASCII_STRING( PROPERTY_STATE, "State");
+ PCR_CONSTASCII_STRING( PROPERTY_TIME, "Time");
+ PCR_CONSTASCII_STRING( PROPERTY_SCALEIMAGE, "ScaleImage");
+ PCR_CONSTASCII_STRING( PROPERTY_SCALE_MODE, "ScaleMode");
+ PCR_CONSTASCII_STRING( PROPERTY_PUSHBUTTONTYPE, "PushButtonType");
+ PCR_CONSTASCII_STRING( PROPERTY_EFFECTIVE_VALUE, "EffectiveValue");
+ PCR_CONSTASCII_STRING( PROPERTY_SELECTEDITEMS, "SelectedItems");
+ PCR_CONSTASCII_STRING( PROPERTY_REPEAT, "Repeat");
+ PCR_CONSTASCII_STRING( PROPERTY_REPEAT_DELAY, "RepeatDelay");
+ PCR_CONSTASCII_STRING( PROPERTY_SYMBOLCOLOR, "SymbolColor");
+ PCR_CONSTASCII_STRING( PROPERTY_SPINVALUE, "SpinValue");
+ PCR_CONSTASCII_STRING( PROPERTY_SPINVALUE_MIN, "SpinValueMin");
+ PCR_CONSTASCII_STRING( PROPERTY_SPINVALUE_MAX, "SpinValueMax");
+ PCR_CONSTASCII_STRING( PROPERTY_DEFAULT_SPINVALUE, "DefaultSpinValue");
+ PCR_CONSTASCII_STRING( PROPERTY_SPININCREMENT, "SpinIncrement");
+ PCR_CONSTASCII_STRING( PROPERTY_SHOW_POSITION, "ShowPosition" );
+ PCR_CONSTASCII_STRING( PROPERTY_SHOW_NAVIGATION, "ShowNavigation" );
+ PCR_CONSTASCII_STRING( PROPERTY_SHOW_RECORDACTIONS, "ShowRecordActions" );
+ PCR_CONSTASCII_STRING( PROPERTY_SHOW_FILTERSORT, "ShowFilterSort" );
+ PCR_CONSTASCII_STRING( PROPERTY_LINEEND_FORMAT, "LineEndFormat");
+ PCR_CONSTASCII_STRING( PROPERTY_DECORATION, "Decoration" );
+ PCR_CONSTASCII_STRING( PROPERTY_NOLABEL, "NoLabel" );
+
+ PCR_CONSTASCII_STRING( PROPERTY_SELECTION_TYPE, "SelectionType");
+ PCR_CONSTASCII_STRING( PROPERTY_ROOT_DISPLAYED, "RootDisplayed");
+ PCR_CONSTASCII_STRING( PROPERTY_SHOWS_HANDLES, "ShowsHandles");
+ PCR_CONSTASCII_STRING( PROPERTY_SHOWS_ROOT_HANDLES, "ShowsRootHandles");
+ PCR_CONSTASCII_STRING( PROPERTY_EDITABLE, "Editable");
+ PCR_CONSTASCII_STRING( PROPERTY_INVOKES_STOP_NOT_EDITING, "InvokesStopNodeEditing");
+
+ PCR_CONSTASCII_STRING( PROPERTY_HARDLINEBREAKS, "HardLineBreaks");
+
+ PCR_CONSTASCII_STRING( PROPERTY_TOGGLE, "Toggle" );
+ PCR_CONSTASCII_STRING( PROPERTY_FOCUSONCLICK, "FocusOnClick" );
+ PCR_CONSTASCII_STRING( PROPERTY_HIDEINACTIVESELECTION, "HideInactiveSelection" );
+ PCR_CONSTASCII_STRING( PROPERTY_VISUALEFFECT, "VisualEffect" );
+ PCR_CONSTASCII_STRING( PROPERTY_BORDERCOLOR, "BorderColor" );
+
+ PCR_CONSTASCII_STRING( PROPERTY_ADDRESS, "Address");
+ PCR_CONSTASCII_STRING( PROPERTY_REFERENCE_SHEET, "ReferenceSheet");
+ PCR_CONSTASCII_STRING( PROPERTY_UI_REPRESENTATION, "UserInterfaceRepresentation");
+
+ PCR_CONSTASCII_STRING( PROPERTY_XML_DATA_MODEL, "XMLDataModel" );
+ PCR_CONSTASCII_STRING( PROPERTY_BINDING_NAME, "BindingName" );
+ PCR_CONSTASCII_STRING( PROPERTY_BIND_EXPRESSION, "BindingExpression" );
+ PCR_CONSTASCII_STRING( PROPERTY_LIST_BINDING, "ListBinding" );
+ PCR_CONSTASCII_STRING( PROPERTY_XSD_REQUIRED, "RequiredExpression" );
+ PCR_CONSTASCII_STRING( PROPERTY_XSD_RELEVANT, "RelevantExpression" );
+ PCR_CONSTASCII_STRING( PROPERTY_XSD_READONLY, "ReadonlyExpression" );
+ PCR_CONSTASCII_STRING( PROPERTY_XSD_CONSTRAINT, "ConstraintExpression" );
+ PCR_CONSTASCII_STRING( PROPERTY_XSD_CALCULATION, "CalculateExpression" );
+ PCR_CONSTASCII_STRING( PROPERTY_XSD_DATA_TYPE, "Type" );
+ PCR_CONSTASCII_STRING( PROPERTY_XSD_WHITESPACES, "WhiteSpace" );
+ PCR_CONSTASCII_STRING( PROPERTY_XSD_PATTERN, "Pattern" );
+ PCR_CONSTASCII_STRING( PROPERTY_XSD_LENGTH, "Length" );
+ PCR_CONSTASCII_STRING( PROPERTY_XSD_MIN_LENGTH, "MinLength" );
+ PCR_CONSTASCII_STRING( PROPERTY_XSD_MAX_LENGTH, "MaxLength" );
+ PCR_CONSTASCII_STRING( PROPERTY_XSD_TOTAL_DIGITS, "TotalDigits" );
+ PCR_CONSTASCII_STRING( PROPERTY_XSD_FRACTION_DIGITS, "FractionDigits" );
+ PCR_CONSTASCII_STRING( PROPERTY_XSD_MAX_INCLUSIVE_INT, "MaxInclusiveInt" );
+ PCR_CONSTASCII_STRING( PROPERTY_XSD_MAX_EXCLUSIVE_INT, "MaxExclusiveInt" );
+ PCR_CONSTASCII_STRING( PROPERTY_XSD_MIN_INCLUSIVE_INT, "MinInclusiveInt" );
+ PCR_CONSTASCII_STRING( PROPERTY_XSD_MIN_EXCLUSIVE_INT, "MinExclusiveInt" );
+ PCR_CONSTASCII_STRING( PROPERTY_XSD_MAX_INCLUSIVE_DOUBLE, "MaxInclusiveDouble" );
+ PCR_CONSTASCII_STRING( PROPERTY_XSD_MAX_EXCLUSIVE_DOUBLE, "MaxExclusiveDouble" );
+ PCR_CONSTASCII_STRING( PROPERTY_XSD_MIN_INCLUSIVE_DOUBLE, "MinInclusiveDouble" );
+ PCR_CONSTASCII_STRING( PROPERTY_XSD_MIN_EXCLUSIVE_DOUBLE, "MinExclusiveDouble" );
+ PCR_CONSTASCII_STRING( PROPERTY_XSD_MAX_INCLUSIVE_DATE, "MaxInclusiveDate" );
+ PCR_CONSTASCII_STRING( PROPERTY_XSD_MAX_EXCLUSIVE_DATE, "MaxExclusiveDate" );
+ PCR_CONSTASCII_STRING( PROPERTY_XSD_MIN_INCLUSIVE_DATE, "MinInclusiveDate" );
+ PCR_CONSTASCII_STRING( PROPERTY_XSD_MIN_EXCLUSIVE_DATE, "MinExclusiveDate" );
+ PCR_CONSTASCII_STRING( PROPERTY_XSD_MAX_INCLUSIVE_TIME, "MaxInclusiveTime" );
+ PCR_CONSTASCII_STRING( PROPERTY_XSD_MAX_EXCLUSIVE_TIME, "MaxExclusiveTime" );
+ PCR_CONSTASCII_STRING( PROPERTY_XSD_MIN_INCLUSIVE_TIME, "MinInclusiveTime" );
+ PCR_CONSTASCII_STRING( PROPERTY_XSD_MIN_EXCLUSIVE_TIME, "MinExclusiveTime" );
+ PCR_CONSTASCII_STRING( PROPERTY_XSD_MAX_INCLUSIVE_DATE_TIME, "MaxInclusiveDateTime" );
+ PCR_CONSTASCII_STRING( PROPERTY_XSD_MAX_EXCLUSIVE_DATE_TIME, "MaxExclusiveDateTime" );
+ PCR_CONSTASCII_STRING( PROPERTY_XSD_MIN_INCLUSIVE_DATE_TIME, "MinInclusiveDateTime" );
+ PCR_CONSTASCII_STRING( PROPERTY_XSD_MIN_EXCLUSIVE_DATE_TIME, "MinExclusiveDateTime" );
+ PCR_CONSTASCII_STRING( PROPERTY_SUBMISSION_ID, "SubmissionID" );
+ PCR_CONSTASCII_STRING( PROPERTY_BINDING_ID, "BindingID" );
+ PCR_CONSTASCII_STRING( PROPERTY_ID, "ID" );
+ PCR_CONSTASCII_STRING( PROPERTY_WRITING_MODE, "WritingMode" );
+ PCR_CONSTASCII_STRING( PROPERTY_TEXT_ANCHOR_TYPE, "TextAnchorType" );
+ PCR_CONSTASCII_STRING( PROPERTY_SHEET_ANCHOR_TYPE, "SheetAnchorType" );
+ PCR_CONSTASCII_STRING( PROPERTY_ANCHOR_TYPE, "AnchorType" );
+ PCR_CONSTASCII_STRING( PROPERTY_ANCHOR, "Anchor" );
+ PCR_CONSTASCII_STRING( PROPERTY_IS_VISIBLE, "IsVisible" );
+
+ PCR_CONSTASCII_STRING( PROPERTY_MODEL, "Model" );
+
+ PCR_CONSTASCII_STRING( PROPERTY_CELL_EXCHANGE_TYPE, "ExchangeSelectionIndex");
+ PCR_CONSTASCII_STRING( PROPERTY_BOUND_CELL, "BoundCell");
+ PCR_CONSTASCII_STRING( PROPERTY_LIST_CELL_RANGE, "CellRange");
+ PCR_CONSTASCII_STRING( PROPERTY_AUTOLINEBREAK, "AutomaticLineBreak");
+ PCR_CONSTASCII_STRING( PROPERTY_TEXTTYPE, "TextType");
+ PCR_CONSTASCII_STRING( PROPERTY_RICHTEXT, "RichText");
+ PCR_CONSTASCII_STRING( PROPERTY_ROWSET, "RowSet");
+
+ // services
+ PCR_CONSTASCII_STRING( SERVICE_COMPONENT_GROUPBOX, "com.sun.star.form.component.GroupBox" );
+ PCR_CONSTASCII_STRING( SERVICE_COMPONENT_FIXEDTEXT, "com.sun.star.form.component.FixedText" );
+ PCR_CONSTASCII_STRING( SERVICE_COMPONENT_FORMATTEDFIELD,"com.sun.star.form.component.FormattedField" );
+ PCR_CONSTASCII_STRING( SERVICE_DATABASE_CONTEXT, "com.sun.star.sdb.DatabaseContext" );
+
+ PCR_CONSTASCII_STRING( SERVICE_TEXT_DOCUMENT, "com.sun.star.text.TextDocument" );
+ PCR_CONSTASCII_STRING( SERVICE_WEB_DOCUMENT, "com.sun.star.text.WebDocument" );
+ PCR_CONSTASCII_STRING( SERVICE_SPREADSHEET_DOCUMENT, "com.sun.star.sheet.SpreadsheetDocument" );
+ PCR_CONSTASCII_STRING( SERVICE_DRAWING_DOCUMENT, "com.sun.star.drawing.DrawingDocument" );
+ PCR_CONSTASCII_STRING( SERVICE_PRESENTATION_DOCUMENT, "com.sun.star.presentation.PresentationDocument" );
+
+ PCR_CONSTASCII_STRING( SERVICE_SHEET_CELL_BINDING, "com.sun.star.table.CellValueBinding" );
+ PCR_CONSTASCII_STRING( SERVICE_SHEET_CELL_INT_BINDING, "com.sun.star.table.ListPositionCellBinding" );
+ PCR_CONSTASCII_STRING( SERVICE_SHEET_CELLRANGE_LISTSOURCE, "com.sun.star.table.CellRangeListSource" );
+ PCR_CONSTASCII_STRING( SERVICE_ADDRESS_CONVERSION, "com.sun.star.table.CellAddressConversion" );
+ PCR_CONSTASCII_STRING( SERVICE_RANGEADDRESS_CONVERSION, "com.sun.star.table.CellRangeAddressConversion" );
+
+ PCR_CONSTASCII_STRING( SERVICE_DESKTOP, "com.sun.star.frame.Desktop" );
+
+//............................................................................
+} // namespace pcr
+//............................................................................
+
+#endif // _EXTENSIONS_FORMSCTRLR_FORMSTRINGS_HXX_
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/propctrlr/genericpropertyhandler.cxx b/extensions/source/propctrlr/genericpropertyhandler.cxx
new file mode 100644
index 000000000000..51d11c86f1ec
--- /dev/null
+++ b/extensions/source/propctrlr/genericpropertyhandler.cxx
@@ -0,0 +1,728 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+#include "genericpropertyhandler.hxx"
+#include "formmetadata.hxx"
+#include "handlerhelper.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/container/XHierarchicalNameAccess.hpp>
+#include <com/sun/star/reflection/XEnumTypeDescription.hpp>
+#include <com/sun/star/beans/XIntrospection.hpp>
+#include <com/sun/star/inspection/PropertyControlType.hpp>
+#include <com/sun/star/inspection/XHyperlinkControl.hpp>
+#include <com/sun/star/awt/XActionListener.hpp>
+#include <com/sun/star/util/XURLTransformer.hpp>
+#include <com/sun/star/frame/XDispatchProvider.hpp>
+/** === end UNO includes === **/
+#include <tools/debug.hxx>
+#include <cppuhelper/extract.hxx>
+
+#include <algorithm>
+
+//------------------------------------------------------------------------
+extern "C" void SAL_CALL createRegistryInfo_GenericPropertyHandler()
+{
+ ::pcr::OAutoRegistration< ::pcr::GenericPropertyHandler > aAutoRegistration;
+}
+
+//........................................................................
+namespace pcr
+{
+//........................................................................
+
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::beans;
+ using namespace ::com::sun::star::script;
+ using namespace ::com::sun::star::frame;
+ using namespace ::com::sun::star::lang;
+ using namespace ::com::sun::star::util;
+ using namespace ::com::sun::star::container;
+ using namespace ::com::sun::star::reflection;
+ using namespace ::com::sun::star::inspection;
+ using ::com::sun::star::awt::XActionListener;
+ using ::com::sun::star::awt::ActionEvent;
+
+ //====================================================================
+ //= EnumRepresentation
+ //====================================================================
+ class EnumRepresentation : public IPropertyEnumRepresentation
+ {
+ private:
+ oslInterlockedCount m_refCount;
+ Reference< XEnumTypeDescription > m_xTypeDescription;
+ Type m_aEnumType;
+
+ public:
+ EnumRepresentation( const Reference< XComponentContext >& _rxContext, const Type& _rEnumType );
+
+ // IPropertyEnumRepresentation implementqation
+ virtual ::std::vector< ::rtl::OUString >
+ SAL_CALL getDescriptions() const;
+ virtual void SAL_CALL getValueFromDescription( const ::rtl::OUString& _rDescription, ::com::sun::star::uno::Any& _out_rValue ) const;
+ virtual ::rtl::OUString SAL_CALL getDescriptionForValue( const ::com::sun::star::uno::Any& _rEnumValue ) const;
+
+ // IReference implementqation
+ virtual oslInterlockedCount SAL_CALL acquire();
+ virtual oslInterlockedCount SAL_CALL release();
+
+ private:
+ void impl_getValues( Sequence< sal_Int32 >& _out_rValues ) const;
+
+ private:
+ EnumRepresentation(); // never implemented
+ EnumRepresentation( const EnumRepresentation& ); // never implemented
+ EnumRepresentation& operator=( const EnumRepresentation& ); // never implemented
+ };
+
+ //--------------------------------------------------------------------
+ EnumRepresentation::EnumRepresentation( const Reference< XComponentContext >& _rxContext, const Type& _rEnumType )
+ :m_refCount( 0 )
+ ,m_aEnumType( _rEnumType )
+ {
+ try
+ {
+ if ( _rxContext.is() )
+ {
+ Reference< XHierarchicalNameAccess > xTypeDescProv(
+ _rxContext->getValueByName( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "/singletons/com.sun.star.reflection.theTypeDescriptionManager" ) ) ),
+ UNO_QUERY_THROW );
+
+ m_xTypeDescription = Reference< XEnumTypeDescription >( xTypeDescProv->getByHierarchicalName( m_aEnumType.getTypeName() ), UNO_QUERY_THROW );
+ }
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "EnumRepresentation::EnumRepresentation: caught an exception!" );
+ }
+ }
+
+ //--------------------------------------------------------------------
+ ::std::vector< ::rtl::OUString > EnumRepresentation::getDescriptions() const
+ {
+ Sequence< ::rtl::OUString > aNames;
+ try
+ {
+ if ( m_xTypeDescription.is() )
+ aNames = m_xTypeDescription->getEnumNames();
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "EnumRepresentation::getDescriptions: caught an exception!" );
+ }
+
+ return ::std::vector< ::rtl::OUString >( aNames.getConstArray(), aNames.getConstArray() + aNames.getLength() );
+ }
+
+ //--------------------------------------------------------------------
+ void EnumRepresentation::impl_getValues( Sequence< sal_Int32 >& _out_rValues ) const
+ {
+ _out_rValues.realloc( 0 );
+ try
+ {
+ if ( m_xTypeDescription.is() )
+ _out_rValues = m_xTypeDescription->getEnumValues();
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "EnumRepresentation::impl_getValues: caught an exception!" );
+ }
+ }
+
+ //--------------------------------------------------------------------
+ void EnumRepresentation::getValueFromDescription( const ::rtl::OUString& _rDescription, Any& _out_rValue ) const
+ {
+ ::std::vector< ::rtl::OUString > aDescriptions( getDescriptions() );
+
+ sal_Int32 index = ::std::find( aDescriptions.begin(), aDescriptions.end(),
+ _rDescription ) - aDescriptions.begin();
+
+ Sequence< sal_Int32 > aValues;
+ impl_getValues( aValues );
+
+ if ( ( index >= 0 ) && ( index < aValues.getLength() ) )
+ _out_rValue = ::cppu::int2enum( aValues[ index ], m_aEnumType );
+ else
+ {
+ DBG_ERROR( "EnumRepresentation::getValueFromDescription: cannot convert!" );
+ _out_rValue.clear();
+ }
+ }
+
+ //--------------------------------------------------------------------
+ ::rtl::OUString EnumRepresentation::getDescriptionForValue( const Any& _rEnumValue ) const
+ {
+ ::rtl::OUString sDescription;
+
+ sal_Int32 nAsInt = 0;
+ OSL_VERIFY( ::cppu::enum2int( nAsInt, _rEnumValue ) );
+
+ Sequence< sal_Int32 > aValues;
+ impl_getValues( aValues );
+
+ sal_Int32 index = ::std::find( aValues.getConstArray(), aValues.getConstArray() + aValues.getLength(),
+ nAsInt ) - aValues.getConstArray();
+
+ ::std::vector< ::rtl::OUString > aDescriptions( getDescriptions() );
+ if ( ( index >= 0 ) && ( index < (sal_Int32)aDescriptions.size() ) )
+ sDescription = aDescriptions[ index ];
+ else
+ {
+ DBG_ERROR( "EnumRepresentation::getDescriptionForValue: cannot convert!" );
+ }
+ return sDescription;
+ }
+
+ //--------------------------------------------------------------------
+ oslInterlockedCount SAL_CALL EnumRepresentation::acquire()
+ {
+ return osl_incrementInterlockedCount( &m_refCount );
+ }
+
+ //--------------------------------------------------------------------
+ oslInterlockedCount SAL_CALL EnumRepresentation::release()
+ {
+ if ( 0 == osl_decrementInterlockedCount( &m_refCount ) )
+ {
+ delete this;
+ return 0;
+ }
+ return m_refCount;
+ }
+
+ //====================================================================
+ //= UrlClickHandler
+ //====================================================================
+ typedef ::cppu::WeakImplHelper1 < XActionListener
+ > UrlClickHandler_Base;
+ class UrlClickHandler : public UrlClickHandler_Base
+ {
+ ComponentContext m_aContext;
+ public:
+ UrlClickHandler( const ComponentContext& _rContext, const Reference< XHyperlinkControl >& _rxControl );
+
+ protected:
+ ~UrlClickHandler();
+
+ // XActionListener
+ virtual void SAL_CALL actionPerformed( const ActionEvent& rEvent ) throw (RuntimeException);
+
+ // XEventListener
+ virtual void SAL_CALL disposing( const EventObject& Source ) throw (RuntimeException);
+
+ protected:
+ void impl_dispatch_throw( const ::rtl::OUString& _rURL );
+ };
+
+ //--------------------------------------------------------------------
+ DBG_NAME( UrlClickHandler )
+ //--------------------------------------------------------------------
+ UrlClickHandler::UrlClickHandler( const ComponentContext& _rContext, const Reference< XHyperlinkControl >& _rxControl )
+ :m_aContext( _rContext )
+ {
+ if ( !_rxControl.is() )
+ throw NullPointerException();
+
+ osl_incrementInterlockedCount( &m_refCount );
+ {
+ _rxControl->addActionListener( this );
+ }
+ osl_decrementInterlockedCount( &m_refCount );
+ OSL_ENSURE( m_refCount > 0, "UrlClickHandler::UrlClickHandler: leaking!" );
+
+ DBG_CTOR( UrlClickHandler, NULL );
+ }
+
+ //--------------------------------------------------------------------
+ UrlClickHandler::~UrlClickHandler()
+ {
+ DBG_DTOR( UrlClickHandler, NULL );
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL UrlClickHandler::actionPerformed( const ActionEvent& rEvent ) throw (RuntimeException)
+ {
+ Reference< XPropertyControl > xControl( rEvent.Source, UNO_QUERY_THROW );
+ Any aControlValue( xControl->getValue() );
+
+ ::rtl::OUString sURL;
+ if ( aControlValue.hasValue() && !( aControlValue >>= sURL ) )
+ throw RuntimeException( ::rtl::OUString(), *this );
+
+ if ( !sURL.getLength() )
+ return;
+
+ impl_dispatch_throw( sURL );
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL UrlClickHandler::disposing( const EventObject& /*Source*/ ) throw (RuntimeException)
+ {
+ // not interested in
+ }
+
+ //--------------------------------------------------------------------
+ void UrlClickHandler::impl_dispatch_throw( const ::rtl::OUString& _rURL )
+ {
+ Reference< XURLTransformer > xTransformer( m_aContext.createComponent( "com.sun.star.util.URLTransformer" ), UNO_QUERY_THROW );
+ URL aURL; aURL.Complete = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:OpenHyperlink" ) );
+ xTransformer->parseStrict( aURL );
+
+ Reference< XDispatchProvider > xDispProv( m_aContext.createComponent( "com.sun.star.frame.Desktop" ), UNO_QUERY_THROW );
+ Reference< XDispatch > xDispatch( xDispProv->queryDispatch( aURL, ::rtl::OUString(), 0 ), UNO_QUERY_THROW );
+
+ Sequence< PropertyValue > aDispatchArgs(1);
+ aDispatchArgs[0].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("URL"));
+ aDispatchArgs[0].Value <<= _rURL;
+
+ xDispatch->dispatch( aURL, aDispatchArgs );
+ }
+
+ //====================================================================
+ //= GenericPropertyHandler
+ //====================================================================
+ DBG_NAME( GenericPropertyHandler )
+ //--------------------------------------------------------------------
+ GenericPropertyHandler::GenericPropertyHandler( const Reference< XComponentContext >& _rxContext )
+ :GenericPropertyHandler_Base( m_aMutex )
+ ,m_aContext( _rxContext )
+ ,m_aPropertyListeners( m_aMutex )
+ ,m_bPropertyMapInitialized( false )
+ {
+ DBG_CTOR( GenericPropertyHandler, NULL );
+
+ m_xTypeConverter = Reference< XTypeConverter >(
+ m_aContext.createComponent( "com.sun.star.script.Converter" ),
+ UNO_QUERY_THROW
+ );
+ }
+
+ //--------------------------------------------------------------------
+ GenericPropertyHandler::~GenericPropertyHandler()
+ {
+ DBG_DTOR( GenericPropertyHandler, NULL );
+ }
+
+ //--------------------------------------------------------------------
+ ::rtl::OUString SAL_CALL GenericPropertyHandler::getImplementationName( ) throw (RuntimeException)
+ {
+ return getImplementationName_static();
+ }
+
+ //--------------------------------------------------------------------
+ ::sal_Bool SAL_CALL GenericPropertyHandler::supportsService( const ::rtl::OUString& ServiceName ) throw (RuntimeException)
+ {
+ StlSyntaxSequence< ::rtl::OUString > aAllServices( getSupportedServiceNames() );
+ return ::std::find( aAllServices.begin(), aAllServices.end(), ServiceName ) != aAllServices.end();
+ }
+
+ //--------------------------------------------------------------------
+ Sequence< ::rtl::OUString > SAL_CALL GenericPropertyHandler::getSupportedServiceNames( ) throw (RuntimeException)
+ {
+ return getSupportedServiceNames_static();
+ }
+
+ //--------------------------------------------------------------------
+ ::rtl::OUString SAL_CALL GenericPropertyHandler::getImplementationName_static( ) throw (RuntimeException)
+ {
+ return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.extensions.GenericPropertyHandler" ) );
+ }
+
+ //--------------------------------------------------------------------
+ Sequence< ::rtl::OUString > SAL_CALL GenericPropertyHandler::getSupportedServiceNames_static( ) throw (RuntimeException)
+ {
+ Sequence< ::rtl::OUString > aSupported( 1 );
+ aSupported[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.inspection.GenericPropertyHandler" ) );
+ return aSupported;
+ }
+
+ //--------------------------------------------------------------------
+ Reference< XInterface > SAL_CALL GenericPropertyHandler::Create( const Reference< XComponentContext >& _rxContext )
+ {
+ return *( new GenericPropertyHandler( _rxContext ) );
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL GenericPropertyHandler::inspect( const Reference< XInterface >& _rxIntrospectee ) throw (RuntimeException, NullPointerException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ if ( !_rxIntrospectee.is() )
+ throw NullPointerException();
+
+ // revoke old property change listeners
+ ::cppu::OInterfaceIteratorHelper iterRemove( m_aPropertyListeners );
+ ::cppu::OInterfaceIteratorHelper iterReAdd( m_aPropertyListeners ); // this holds a copy of the container ...
+ while ( iterRemove.hasMoreElements() )
+ m_xComponent->removePropertyChangeListener( ::rtl::OUString(), static_cast< XPropertyChangeListener* >( iterRemove.next() ) );
+
+ m_xComponentIntrospectionAccess.clear();
+ m_xComponent.clear();
+ m_xPropertyState.clear();
+
+ // create an introspection adapter for the component
+ Reference< XIntrospection > xIntrospection;
+ if ( !m_aContext.createComponent( "com.sun.star.beans.Introspection", xIntrospection ) )
+ throw RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Could not create an instance of the service com.sun.star.beans.Introspection." ) ), *this );
+
+ Reference< XIntrospectionAccess > xIntrospectionAccess( xIntrospection->inspect( makeAny( _rxIntrospectee ) ) );
+ if ( !xIntrospectionAccess.is() )
+ throw RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "The introspection service could not handle the given component." ) ), *this );
+
+ m_xComponent = Reference< XPropertySet >( xIntrospectionAccess->queryAdapter( XPropertySet::static_type() ), UNO_QUERY_THROW );
+ // now that we survived so far, remember m_xComponentIntrospectionAccess
+ m_xComponentIntrospectionAccess = xIntrospectionAccess;
+ m_xPropertyState = m_xPropertyState.query( m_xComponent );
+
+ m_bPropertyMapInitialized = false;
+ m_aProperties.clear();
+
+ // re-add the property change listeners
+ while ( iterReAdd.hasMoreElements() )
+ m_xComponent->addPropertyChangeListener( ::rtl::OUString(), static_cast< XPropertyChangeListener* >( iterReAdd.next() ) );
+ }
+
+ //--------------------------------------------------------------------
+ Any SAL_CALL GenericPropertyHandler::getPropertyValue( const ::rtl::OUString& _rPropertyName ) throw (UnknownPropertyException, RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ if ( !m_xComponent.is() )
+ throw UnknownPropertyException();
+
+ return m_xComponent->getPropertyValue( _rPropertyName );
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL GenericPropertyHandler::setPropertyValue( const ::rtl::OUString& _rPropertyName, const Any& _rValue ) throw (UnknownPropertyException, RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ if ( !m_xComponent.is() )
+ throw UnknownPropertyException();
+
+ m_xComponent->setPropertyValue( _rPropertyName, _rValue );
+ }
+
+ //--------------------------------------------------------------------
+ ::rtl::Reference< IPropertyEnumRepresentation > GenericPropertyHandler::impl_getEnumConverter( const Type& _rEnumType )
+ {
+ ::rtl::Reference< IPropertyEnumRepresentation >& rConverter = m_aEnumConverters[ _rEnumType ];
+ if ( !rConverter.is() )
+ rConverter = new EnumRepresentation( m_aContext.getUNOContext(), _rEnumType );
+ return rConverter;
+ }
+
+ //--------------------------------------------------------------------
+ Any SAL_CALL GenericPropertyHandler::convertToPropertyValue( const ::rtl::OUString& _rPropertyName, const Any& _rControlValue ) throw (UnknownPropertyException, RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ const_cast< GenericPropertyHandler* >( this )->impl_ensurePropertyMap();
+
+ PropertyMap::const_iterator pos = m_aProperties.find( _rPropertyName );
+ if ( pos == m_aProperties.end() )
+ throw UnknownPropertyException();
+
+ Any aPropertyValue;
+ if ( !_rControlValue.hasValue() )
+ // NULL is converted to NULL
+ return aPropertyValue;
+
+ if ( pos->second.Type.getTypeClass() == TypeClass_ENUM )
+ {
+ ::rtl::OUString sControlValue;
+ OSL_VERIFY( _rControlValue >>= sControlValue );
+ impl_getEnumConverter( pos->second.Type )->getValueFromDescription( sControlValue, aPropertyValue );
+ }
+ else
+ aPropertyValue = PropertyHandlerHelper::convertToPropertyValue( m_aContext.getContext(),m_xTypeConverter, pos->second, _rControlValue );
+
+ return aPropertyValue;
+ }
+
+ //--------------------------------------------------------------------
+ Any SAL_CALL GenericPropertyHandler::convertToControlValue( const ::rtl::OUString& _rPropertyName, const Any& _rPropertyValue, const Type& _rControlValueType ) throw (UnknownPropertyException, RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ const_cast< GenericPropertyHandler* >( this )->impl_ensurePropertyMap();
+
+ PropertyMap::const_iterator pos = m_aProperties.find( _rPropertyName );
+ if ( pos == m_aProperties.end() )
+ throw UnknownPropertyException();
+
+ Any aControlValue;
+ if ( !_rPropertyValue.hasValue() )
+ // NULL is converted to NULL
+ return aControlValue;
+
+ if ( pos->second.Type.getTypeClass() == TypeClass_ENUM )
+ {
+ aControlValue <<= impl_getEnumConverter( pos->second.Type )->getDescriptionForValue( _rPropertyValue );
+ }
+ else
+ aControlValue = PropertyHandlerHelper::convertToControlValue( m_aContext.getContext(),m_xTypeConverter, _rPropertyValue, _rControlValueType );
+ return aControlValue;
+ }
+
+ //--------------------------------------------------------------------
+ PropertyState SAL_CALL GenericPropertyHandler::getPropertyState( const ::rtl::OUString& _rPropertyName ) throw (UnknownPropertyException, RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ PropertyState eState = PropertyState_DIRECT_VALUE;
+ if ( m_xPropertyState.is() )
+ eState = m_xPropertyState->getPropertyState( _rPropertyName );
+ return eState;
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL GenericPropertyHandler::addPropertyChangeListener( const Reference< XPropertyChangeListener >& _rxListener ) throw (RuntimeException)
+ {
+ if ( !_rxListener.is() )
+ throw NullPointerException();
+
+ ::osl::MutexGuard aGuard( m_aMutex );
+ m_aPropertyListeners.addInterface( _rxListener );
+ if ( m_xComponent.is() )
+ {
+ try
+ {
+ m_xComponent->addPropertyChangeListener( ::rtl::OUString(), _rxListener );
+ }
+ catch( const UnknownPropertyException& )
+ {
+ OSL_ENSURE( false, "GenericPropertyHandler::addPropertyChangeListener:\nThe inspected component does not allow registering for all properties at once! This violates the interface contract!" );
+ }
+ }
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL GenericPropertyHandler::removePropertyChangeListener( const Reference< XPropertyChangeListener >& _rxListener ) throw (RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ if ( m_xComponent.is() )
+ {
+ try
+ {
+ m_xComponent->removePropertyChangeListener( ::rtl::OUString(), _rxListener );
+ }
+ catch( const UnknownPropertyException& )
+ {
+ OSL_ENSURE( false, "GenericPropertyHandler::removePropertyChangeListener:\nThe inspected component does not allow de-registering for all properties at once! This violates the interface contract!" );
+ }
+ }
+ m_aPropertyListeners.removeInterface( _rxListener );
+ }
+
+ //--------------------------------------------------------------------
+ void GenericPropertyHandler::impl_ensurePropertyMap()
+ {
+ if ( !m_bPropertyMapInitialized )
+ {
+ m_bPropertyMapInitialized = true;
+ try
+ {
+ Reference< XPropertySetInfo > xPSI;
+ if ( m_xComponent.is() )
+ xPSI = m_xComponent->getPropertySetInfo();
+ Sequence< Property > aProperties;
+ if ( xPSI.is() )
+ aProperties = xPSI->getProperties();
+ DBG_ASSERT( aProperties.getLength(), "GenericPropertyHandler::getSupportedProperties: no properties!" );
+
+ for ( const Property* pProperties = aProperties.getConstArray();
+ pProperties != aProperties.getConstArray() + aProperties.getLength();
+ ++pProperties
+ )
+ {
+ switch ( pProperties->Type.getTypeClass() )
+ {
+ case TypeClass_BOOLEAN:
+ case TypeClass_BYTE:
+ case TypeClass_SHORT:
+ case TypeClass_UNSIGNED_SHORT:
+ case TypeClass_LONG:
+ case TypeClass_UNSIGNED_LONG:
+ case TypeClass_HYPER:
+ case TypeClass_UNSIGNED_HYPER:
+ case TypeClass_FLOAT:
+ case TypeClass_DOUBLE:
+ case TypeClass_ENUM:
+ case TypeClass_STRING:
+ // allowed, we can handle this type
+ break;
+
+ case TypeClass_SEQUENCE:
+ {
+ TypeClass eElementTypeClass = ::comphelper::getSequenceElementType( pProperties->Type ).getTypeClass();
+ if ( ( eElementTypeClass != TypeClass_STRING )
+ && ( eElementTypeClass != TypeClass_BYTE )
+ && ( eElementTypeClass != TypeClass_SHORT )
+ && ( eElementTypeClass != TypeClass_UNSIGNED_SHORT )
+ && ( eElementTypeClass != TypeClass_LONG )
+ && ( eElementTypeClass != TypeClass_UNSIGNED_LONG )
+ )
+ // can only handle the above
+ continue;
+ }
+ break;
+
+ default:
+ // next property, we don't support this type
+ continue;
+ }
+
+ m_aProperties.insert( PropertyMap::value_type( pProperties->Name, *pProperties ) );
+ }
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "GenericPropertyHandler::impl_ensurePropertyMap: caught an exception!" );
+ }
+ }
+ }
+
+ //--------------------------------------------------------------------
+ Sequence< Property > SAL_CALL GenericPropertyHandler::getSupportedProperties() throw (RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ const_cast< GenericPropertyHandler* >( this )->impl_ensurePropertyMap();
+
+ Sequence< Property > aReturn( m_aProperties.size() );
+ ::std::transform( m_aProperties.begin(), m_aProperties.end(),
+ aReturn.getArray(), ::std::select2nd< PropertyMap::value_type >() );
+ return aReturn;
+ }
+
+ //--------------------------------------------------------------------
+ Sequence< ::rtl::OUString > SAL_CALL GenericPropertyHandler::getSupersededProperties( ) throw (RuntimeException)
+ {
+ // no superseded properties at all. This handler offers the very basic PropertyHandler
+ // functionality, so it's much more likely that other handlers want to supersede
+ // *our* properties ....
+ return Sequence< ::rtl::OUString >( );
+ }
+
+ //--------------------------------------------------------------------
+ Sequence< ::rtl::OUString > SAL_CALL GenericPropertyHandler::getActuatingProperties( ) throw (RuntimeException)
+ {
+ // This basic PropertyHandler implementation is too dumb^Wgeneric to know
+ // anything about property dependencies
+ return Sequence< ::rtl::OUString >( );
+ }
+
+ //--------------------------------------------------------------------
+ LineDescriptor SAL_CALL GenericPropertyHandler::describePropertyLine( const ::rtl::OUString& _rPropertyName,
+ const Reference< XPropertyControlFactory >& _rxControlFactory )
+ throw (UnknownPropertyException, NullPointerException, RuntimeException)
+ {
+ if ( !_rxControlFactory.is() )
+ throw NullPointerException();
+
+ ::osl::MutexGuard aGuard( m_aMutex );
+ const_cast< GenericPropertyHandler* >( this )->impl_ensurePropertyMap();
+
+ PropertyMap::const_iterator pos = m_aProperties.find( _rPropertyName );
+ if ( pos == m_aProperties.end() )
+ throw UnknownPropertyException();
+
+ LineDescriptor aDescriptor;
+ aDescriptor.DisplayName = _rPropertyName;
+ switch ( pos->second.Type.getTypeClass() )
+ {
+ case TypeClass_ENUM:
+ aDescriptor.Control = PropertyHandlerHelper::createListBoxControl( _rxControlFactory,
+ impl_getEnumConverter( pos->second.Type )->getDescriptions(),
+ PropertyHandlerHelper::requiresReadOnlyControl( pos->second.Attributes ),
+ sal_False );
+ break;
+ case TypeClass_STRING:
+ {
+ // some special handling for URL properties
+ bool bIsURLProperty = ( _rPropertyName.getLength() >= 3 ) && _rPropertyName.matchAsciiL( "URL", 3, _rPropertyName.getLength() - 3 );
+ if ( bIsURLProperty )
+ {
+ aDescriptor.Control = _rxControlFactory->createPropertyControl(
+ PropertyControlType::HyperlinkField, PropertyHandlerHelper::requiresReadOnlyControl( pos->second.Attributes ) );
+
+ Reference< XHyperlinkControl > xControl( aDescriptor.Control, UNO_QUERY_THROW );
+ Reference< XActionListener > xEnsureDelete( new UrlClickHandler( m_aContext, xControl ) );
+ }
+ }
+ break;
+ default:
+ break;
+ }
+ // fallback
+ if ( !aDescriptor.Control.is() )
+ PropertyHandlerHelper::describePropertyLine( pos->second, aDescriptor, _rxControlFactory );
+
+ aDescriptor.Category = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "General" ) );
+ return aDescriptor;
+ }
+
+ //--------------------------------------------------------------------
+ ::sal_Bool SAL_CALL GenericPropertyHandler::isComposable( const ::rtl::OUString& /*_rPropertyName*/ ) throw (UnknownPropertyException, RuntimeException)
+ {
+ return sal_False;
+ }
+
+ //--------------------------------------------------------------------
+ InteractiveSelectionResult SAL_CALL GenericPropertyHandler::onInteractivePropertySelection( const ::rtl::OUString& /*_rPropertyName*/, sal_Bool /*_bPrimary*/, Any& /*_rData*/, const Reference< XObjectInspectorUI >& /*_rxInspectorUI*/ ) throw (UnknownPropertyException, NullPointerException, RuntimeException)
+ {
+ DBG_ERROR( "GenericPropertyHandler::onInteractivePropertySelection: I'm too dumb to know anything about property browse buttons!" );
+ return InteractiveSelectionResult_Cancelled;
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL GenericPropertyHandler::actuatingPropertyChanged( const ::rtl::OUString& /*_rActuatingPropertyName*/, const Any& /*_rNewValue*/, const Any& /*_rOldValue*/, const Reference< XObjectInspectorUI >& /*_rxInspectorUI*/, sal_Bool /*_bFirstTimeInit*/ ) throw (NullPointerException, RuntimeException)
+ {
+ DBG_ERROR( "GenericPropertyHandler::actuatingPropertyChanged: no no no, I did not register for any actuating properties!" );
+ }
+
+ //--------------------------------------------------------------------
+ sal_Bool SAL_CALL GenericPropertyHandler::suspend( sal_Bool /*_bSuspend*/ ) throw (RuntimeException)
+ {
+ return sal_True;
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL GenericPropertyHandler::disposing()
+ {
+ m_aPropertyListeners.clear();
+ // not disposeAndClear: the listeners are (virtually) listeners at our introspectee, not
+ // at this handler instance
+ }
+
+ //--------------------------------------------------------------------
+ IMPLEMENT_FORWARD_XCOMPONENT( GenericPropertyHandler, GenericPropertyHandler_Base );
+
+//........................................................................
+} // namespace pcr
+//........................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/propctrlr/genericpropertyhandler.hxx b/extensions/source/propctrlr/genericpropertyhandler.hxx
new file mode 100644
index 000000000000..4d5fc7a1e8ac
--- /dev/null
+++ b/extensions/source/propctrlr/genericpropertyhandler.hxx
@@ -0,0 +1,163 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef EXTENSIONS_SOURCE_PROPCTRLR_GENERICPROPERTYHANDLER_HXX
+#define EXTENSIONS_SOURCE_PROPCTRLR_GENERICPROPERTYHANDLER_HXX
+
+#include "propertyhandler.hxx"
+#include "pcrcommontypes.hxx"
+#include "pcrcommon.hxx"
+#include "pcrcomponentcontext.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/beans/XPropertyState.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/beans/XIntrospectionAccess.hpp>
+/** === end UNO includes === **/
+#include <cppuhelper/compbase2.hxx>
+#include <cppuhelper/interfacecontainer.hxx>
+#include <rtl/ref.hxx>
+
+#include <map>
+
+//........................................................................
+namespace pcr
+{
+//........................................................................
+
+ struct TypeLess : ::std::binary_function< ::com::sun::star::uno::Type, ::com::sun::star::uno::Type, bool >
+ {
+ bool operator()( const ::com::sun::star::uno::Type& _rLHS, const ::com::sun::star::uno::Type& _rRHS ) const
+ {
+ return _rLHS.getTypeName() < _rRHS.getTypeName();
+ }
+ };
+
+ class IPropertyInfoService;
+ class IPropertyEnumRepresentation;
+ //====================================================================
+ //= GenericPropertyHandler
+ //====================================================================
+ typedef ::cppu::WeakComponentImplHelper2 < ::com::sun::star::inspection::XPropertyHandler
+ , ::com::sun::star::lang::XServiceInfo
+ > GenericPropertyHandler_Base;
+ class GenericPropertyHandler : public GenericPropertyHandler_Base
+ {
+ private:
+ mutable ::osl::Mutex m_aMutex;
+
+ private:
+ /// the service factory for creating services
+ ComponentContext m_aContext;
+ /// need this to keep alive as long as m_xComponent lives
+ ::com::sun::star::uno::Reference< ::com::sun::star::beans::XIntrospectionAccess > m_xComponentIntrospectionAccess;
+ /// the properties of the object we're handling
+ ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > m_xComponent;
+ /// cached interface of ->m_xComponent
+ ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyState > m_xPropertyState;
+ /// type converter, needed on various occasions
+ ::com::sun::star::uno::Reference< ::com::sun::star::script::XTypeConverter > m_xTypeConverter;
+ /// cache of our supported properties
+ PropertyMap m_aProperties;
+ /// property change listeners
+ ::cppu::OInterfaceContainerHelper m_aPropertyListeners;
+ ::std::map< ::com::sun::star::uno::Type, ::rtl::Reference< IPropertyEnumRepresentation >, TypeLess >
+ m_aEnumConverters;
+
+ /// has ->m_aProperties been initialized?
+ bool m_bPropertyMapInitialized : 1;
+
+ public:
+ // XServiceInfo - static versions
+ static ::rtl::OUString SAL_CALL getImplementationName_static( ) throw (::com::sun::star::uno::RuntimeException);
+ static ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames_static( ) throw (::com::sun::star::uno::RuntimeException);
+ static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > Create( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _rxContext );
+
+ protected:
+ GenericPropertyHandler(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _rxContext
+ );
+
+ ~GenericPropertyHandler();
+
+ protected:
+ // XPropertyHandler overridables
+ virtual void SAL_CALL inspect( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxIntrospectee ) throw (::com::sun::star::lang::NullPointerException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue( const ::rtl::OUString& _rPropertyName ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setPropertyValue( const ::rtl::OUString& _rPropertyName, const ::com::sun::star::uno::Any& _rValue ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Any SAL_CALL convertToPropertyValue( const ::rtl::OUString& _rPropertyName, const ::com::sun::star::uno::Any& _rControlValue ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Any SAL_CALL convertToControlValue( const ::rtl::OUString& _rPropertyName, const ::com::sun::star::uno::Any& _rPropertyValue, const ::com::sun::star::uno::Type& _rControlValueType ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::beans::PropertyState SAL_CALL getPropertyState( const ::rtl::OUString& _rPropertyName ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL addPropertyChangeListener( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& _rxListener ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL removePropertyChangeListener( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& _rxListener ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property >
+ SAL_CALL getSupportedProperties() throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString >
+ SAL_CALL getSupersededProperties() throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getActuatingProperties() throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::inspection::LineDescriptor SAL_CALL describePropertyLine( const ::rtl::OUString& _rPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyControlFactory >& _rxControlFactory ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::NullPointerException, ::com::sun::star::uno::RuntimeException);
+ virtual ::sal_Bool SAL_CALL isComposable( const ::rtl::OUString& _rPropertyName ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::inspection::InteractiveSelectionResult
+ SAL_CALL onInteractivePropertySelection( const ::rtl::OUString& _rPropertyName, sal_Bool _bPrimary, ::com::sun::star::uno::Any& _rData, const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XObjectInspectorUI >& _rxInspectorUI ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::NullPointerException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL actuatingPropertyChanged( const ::rtl::OUString& _rActuatingPropertyName, const ::com::sun::star::uno::Any& _rNewValue, const ::com::sun::star::uno::Any& _rOldValue, const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XObjectInspectorUI >& _rxInspectorUI, sal_Bool _bFirstTimeInit ) throw (::com::sun::star::lang::NullPointerException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL suspend( sal_Bool _bSuspend ) throw (::com::sun::star::uno::RuntimeException);
+
+ // XComponent
+ DECLARE_XCOMPONENT()
+ virtual void SAL_CALL disposing();
+
+ // XServiceInfo
+ virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw (::com::sun::star::uno::RuntimeException);
+
+ private:
+ /** ensures that ->m_aProperties is initialized
+ @precond
+ our mutex is locked
+ */
+ void impl_ensurePropertyMap();
+
+ /** retrieves the enum converter for the given ENUM type
+ */
+ ::rtl::Reference< IPropertyEnumRepresentation >
+ impl_getEnumConverter( const ::com::sun::star::uno::Type& _rEnumType );
+
+ private:
+ GenericPropertyHandler(); // never implemented
+ GenericPropertyHandler( const GenericPropertyHandler& ); // never implemented
+ GenericPropertyHandler& operator=( const GenericPropertyHandler& ); // never implemented
+ };
+
+//........................................................................
+} // namespace pcr
+//........................................................................
+
+#endif // EXTENSIONS_SOURCE_PROPCTRLR_GENERICPROPERTYHANDLER_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/propctrlr/handlerhelper.cxx b/extensions/source/propctrlr/handlerhelper.cxx
new file mode 100644
index 000000000000..9dcee3265d81
--- /dev/null
+++ b/extensions/source/propctrlr/handlerhelper.cxx
@@ -0,0 +1,290 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+#include "handlerhelper.hxx"
+#include "propresid.hrc"
+#include "formresid.hrc"
+#include <comphelper/extract.hxx>
+#include "modulepcr.hxx"
+#include "enumrepresentation.hxx"
+#include "formmetadata.hxx"
+#include "pcrcomponentcontext.hxx"
+
+/** === begin UNO includes === **/
+#include "com/sun/star/inspection/StringRepresentation.hpp"
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+#include <com/sun/star/uno/XComponentContext.hpp>
+#include <com/sun/star/util/XModifiable.hpp>
+#include <com/sun/star/awt/XWindow.hpp>
+#include <com/sun/star/inspection/LineDescriptor.hpp>
+#include <com/sun/star/inspection/PropertyControlType.hpp>
+#include <com/sun/star/inspection/XStringListControl.hpp>
+#include <com/sun/star/inspection/XNumericControl.hpp>
+/** === end UNO includes === **/
+#include <tools/debug.hxx>
+#include <tools/diagnose_ex.h>
+#include <tools/StringListResource.hxx>
+#include <toolkit/helper/vclunohelper.hxx>
+
+#include <algorithm>
+
+//........................................................................
+namespace pcr
+{
+//........................................................................
+
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::lang;
+ using namespace ::com::sun::star::awt;
+ using namespace ::com::sun::star::util;
+ using namespace ::com::sun::star::beans;
+ using namespace ::com::sun::star::script;
+ using namespace ::com::sun::star::inspection;
+
+ //====================================================================
+ //= PropertyHandlerHelper
+ //====================================================================
+ //--------------------------------------------------------------------
+ void PropertyHandlerHelper::describePropertyLine( const Property& _rProperty,
+ LineDescriptor& /* [out] */ _out_rDescriptor, const Reference< XPropertyControlFactory >& _rxControlFactory )
+ {
+ // display the pure property name - no L10N
+ _out_rDescriptor.DisplayName = _rProperty.Name;
+
+ OSL_PRECOND( _rxControlFactory.is(), "PropertyHandlerHelper::describePropertyLine: no factory -> no control!" );
+ if ( !_rxControlFactory.is() )
+ return;
+
+ sal_Bool bReadOnlyControl = requiresReadOnlyControl( _rProperty.Attributes );
+
+ // special handling for booleans (this will become a list)
+ if ( _rProperty.Type.getTypeClass() == TypeClass_BOOLEAN )
+ {
+ ::std::vector< ::rtl::OUString > aListEntries;
+ tools::StringListResource aRes(PcrRes(RID_RSC_ENUM_YESNO),aListEntries);
+ _out_rDescriptor.Control = createListBoxControl( _rxControlFactory, aListEntries, bReadOnlyControl, sal_False );
+ return;
+ }
+
+ sal_Int16 nControlType = PropertyControlType::TextField;
+ switch ( _rProperty.Type.getTypeClass() )
+ {
+ case TypeClass_BYTE:
+ case TypeClass_SHORT:
+ case TypeClass_UNSIGNED_SHORT:
+ case TypeClass_LONG:
+ case TypeClass_UNSIGNED_LONG:
+ case TypeClass_HYPER:
+ case TypeClass_UNSIGNED_HYPER:
+ case TypeClass_FLOAT:
+ case TypeClass_DOUBLE:
+ nControlType = PropertyControlType::NumericField;
+ break;
+
+ case TypeClass_SEQUENCE:
+ nControlType = PropertyControlType::StringListField;
+ break;
+
+ default:
+ DBG_ERROR( "PropertyHandlerHelper::describePropertyLine: don't know how to represent this at the UI!" );
+ // NO break!
+
+ case TypeClass_STRING:
+ nControlType = PropertyControlType::TextField;
+ break;
+ }
+
+ // create a control
+ _out_rDescriptor.Control = _rxControlFactory->createPropertyControl( nControlType, bReadOnlyControl );
+ }
+
+ //--------------------------------------------------------------------
+ namespace
+ {
+ Reference< XPropertyControl > lcl_implCreateListLikeControl(
+ const Reference< XPropertyControlFactory >& _rxControlFactory,
+ const ::std::vector< ::rtl::OUString >& _rInitialListEntries,
+ sal_Bool _bReadOnlyControl,
+ sal_Bool _bSorted,
+ sal_Bool _bTrueIfListBoxFalseIfComboBox
+ )
+ {
+ Reference< XStringListControl > xListControl(
+ _rxControlFactory->createPropertyControl(
+ _bTrueIfListBoxFalseIfComboBox ? PropertyControlType::ListBox : PropertyControlType::ComboBox, _bReadOnlyControl
+ ),
+ UNO_QUERY_THROW
+ );
+
+ ::std::vector< ::rtl::OUString > aInitialEntries( _rInitialListEntries );
+ if ( _bSorted )
+ ::std::sort( aInitialEntries.begin(), aInitialEntries.end() );
+
+ for ( ::std::vector< ::rtl::OUString >::const_iterator loop = aInitialEntries.begin();
+ loop != aInitialEntries.end();
+ ++loop
+ )
+ xListControl->appendListEntry( *loop );
+ return xListControl.get();
+ }
+ }
+
+ //--------------------------------------------------------------------
+ Reference< XPropertyControl > PropertyHandlerHelper::createListBoxControl( const Reference< XPropertyControlFactory >& _rxControlFactory,
+ const ::std::vector< ::rtl::OUString >& _rInitialListEntries, sal_Bool _bReadOnlyControl, sal_Bool _bSorted )
+ {
+ return lcl_implCreateListLikeControl( _rxControlFactory, _rInitialListEntries, _bReadOnlyControl, _bSorted, sal_True );
+ }
+
+ //--------------------------------------------------------------------
+ Reference< XPropertyControl > PropertyHandlerHelper::createComboBoxControl( const Reference< XPropertyControlFactory >& _rxControlFactory,
+ const ::std::vector< ::rtl::OUString >& _rInitialListEntries, sal_Bool _bReadOnlyControl, sal_Bool _bSorted )
+ {
+ return lcl_implCreateListLikeControl( _rxControlFactory, _rInitialListEntries, _bReadOnlyControl, _bSorted, sal_False );
+ }
+
+ //--------------------------------------------------------------------
+ Reference< XPropertyControl > PropertyHandlerHelper::createNumericControl( const Reference< XPropertyControlFactory >& _rxControlFactory,
+ sal_Int16 _nDigits, const Optional< double >& _rMinValue, const Optional< double >& _rMaxValue, sal_Bool _bReadOnlyControl )
+ {
+ Reference< XNumericControl > xNumericControl(
+ _rxControlFactory->createPropertyControl( PropertyControlType::NumericField, _bReadOnlyControl ),
+ UNO_QUERY_THROW
+ );
+
+ xNumericControl->setDecimalDigits( _nDigits );
+ xNumericControl->setMinValue( _rMinValue );
+ xNumericControl->setMaxValue( _rMaxValue );
+
+ return xNumericControl.get();
+ }
+
+ //--------------------------------------------------------------------
+ Any PropertyHandlerHelper::convertToPropertyValue( const Reference< XComponentContext >& _rxContext,const Reference< XTypeConverter >& _rxTypeConverter,
+ const Property& _rProperty, const Any& _rControlValue )
+ {
+ Any aPropertyValue( _rControlValue );
+ if ( !aPropertyValue.hasValue() )
+ // NULL is converted to NULL
+ return aPropertyValue;
+
+ if ( aPropertyValue.getValueType().equals( _rProperty.Type ) )
+ // nothing to do, type is already as desired
+ return aPropertyValue;
+
+ if ( _rControlValue.getValueType().getTypeClass() == TypeClass_STRING )
+ {
+ ::rtl::OUString sControlValue;
+ _rControlValue >>= sControlValue;
+
+ Reference< XStringRepresentation > xConversionHelper = StringRepresentation::create( _rxContext,_rxTypeConverter );
+ aPropertyValue = xConversionHelper->convertToPropertyValue( sControlValue, _rProperty.Type );
+ }
+ else
+ {
+ try
+ {
+ if ( _rxTypeConverter.is() )
+ aPropertyValue = _rxTypeConverter->convertTo( _rControlValue, _rProperty.Type );
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "PropertyHandlerHelper::convertToPropertyValue: caught an exception while converting via TypeConverter!" );
+ }
+ }
+
+ return aPropertyValue;
+ }
+
+ //--------------------------------------------------------------------
+ Any PropertyHandlerHelper::convertToControlValue( const Reference< XComponentContext >& _rxContext,const Reference< XTypeConverter >& _rxTypeConverter,
+ const Any& _rPropertyValue, const Type& _rControlValueType )
+ {
+ Any aControlValue( _rPropertyValue );
+ if ( !aControlValue.hasValue() )
+ // NULL is converted to NULL
+ return aControlValue;
+
+ if ( _rControlValueType.getTypeClass() == TypeClass_STRING )
+ {
+ Reference< XStringRepresentation > xConversionHelper = StringRepresentation::create( _rxContext,_rxTypeConverter );
+ aControlValue <<= xConversionHelper->convertToControlValue( _rPropertyValue );
+ }
+ else
+ {
+ try
+ {
+ if ( _rxTypeConverter.is() )
+ aControlValue = _rxTypeConverter->convertTo( _rPropertyValue, _rControlValueType );
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "PropertyHandlerHelper::convertToControlValue: caught an exception while converting via TypeConverter!" );
+ }
+ }
+
+ return aControlValue;
+ }
+
+ //--------------------------------------------------------------------
+ void PropertyHandlerHelper::setContextDocumentModified( const ComponentContext& _rContext )
+ {
+ try
+ {
+ Reference< XModifiable > xDocumentModifiable( _rContext.getContextValueByAsciiName( "ContextDocument" ), UNO_QUERY_THROW );
+ xDocumentModifiable->setModified( sal_True );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+
+ //--------------------------------------------------------------------
+ Window* PropertyHandlerHelper::getDialogParentWindow( const ComponentContext& _rContext )
+ {
+ Window* pInspectorWindow = NULL;
+ try
+ {
+ Reference< XWindow > xInspectorWindow( _rContext.getContextValueByAsciiName( "DialogParentWindow" ), UNO_QUERY_THROW );
+ pInspectorWindow = VCLUnoHelper::GetWindow( xInspectorWindow );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ return pInspectorWindow;
+ }
+
+//........................................................................
+} // namespace pcr
+//........................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/propctrlr/handlerhelper.hxx b/extensions/source/propctrlr/handlerhelper.hxx
new file mode 100644
index 000000000000..1505997e8292
--- /dev/null
+++ b/extensions/source/propctrlr/handlerhelper.hxx
@@ -0,0 +1,219 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef EXTENSIONS_SOURCE_PROPCTRLR_HANDLERHELPER_HXX
+#define EXTENSIONS_SOURCE_PROPCTRLR_HANDLERHELPER_HXX
+
+/** === begin UNO includes === **/
+#include <com/sun/star/beans/Property.hpp>
+#include <com/sun/star/uno/XComponentContext.hpp>
+#include <com/sun/star/script/XTypeConverter.hpp>
+#include <com/sun/star/beans/XPropertyChangeListener.hpp>
+#include <com/sun/star/inspection/XPropertyControlFactory.hpp>
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+#include <com/sun/star/beans/Optional.hpp>
+/** === end UNO includes === **/
+
+#include <vector>
+
+class Window;
+namespace com { namespace sun { namespace star {
+ namespace inspection {
+ struct LineDescriptor;
+ }
+} } }
+//........................................................................
+namespace pcr
+{
+//........................................................................
+
+ class ComponentContext;
+
+ //====================================================================
+ //= PropertyHandlerHelper
+ //====================================================================
+ class PropertyHandlerHelper
+ {
+ public:
+ /** helper for implementing XPropertyHandler::describePropertyLine in a generic way
+ */
+ static void describePropertyLine(
+ const ::com::sun::star::beans::Property& _rProperty,
+ ::com::sun::star::inspection::LineDescriptor& /* [out] */ _out_rDescriptor,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyControlFactory >& _rxControlFactory
+ );
+
+ /** helper for implementing XPropertyHandler::convertToPropertyValue
+ */
+ static ::com::sun::star::uno::Any convertToPropertyValue(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _rxContext,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::script::XTypeConverter >& _rxTypeConverter,
+ const ::com::sun::star::beans::Property& _rProperty,
+ const ::com::sun::star::uno::Any& _rControlValue
+ );
+
+ /// helper for implementing XPropertyHandler::convertToControlValue
+ static ::com::sun::star::uno::Any convertToControlValue(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _rxContext,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::script::XTypeConverter >& _rxTypeConverter,
+ const ::com::sun::star::uno::Any& _rPropertyValue,
+ const ::com::sun::star::uno::Type& _rControlValueType
+ );
+
+ /** creates an <member scope="com::sun::star::inspection">PropertyControlType::ListBox</member>-type control
+ and fills it with initial values
+
+ @param _rxControlFactory
+ A control factory. Must not be <NULL/>.
+
+ @param _rInitialListEntries
+ the initial values of the control
+
+ @param _bReadOnlyControl
+ determines whether the control should be read-only
+
+ @param _bSorted
+ determines whether the list entries should be sorted
+
+ @return
+ the newly created control
+ */
+ static ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyControl >
+ createListBoxControl(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyControlFactory >& _rxControlFactory,
+ const ::std::vector< ::rtl::OUString >& _rInitialListEntries,
+ sal_Bool _bReadOnlyControl,
+ sal_Bool _bSorted
+ );
+
+ /** creates an <member scope="com::sun::star::inspection">PropertyControlType::ComboBox</member>-type control
+ and fills it with initial values
+
+ @param _rxControlFactory
+ A control factory. Must not be <NULL/>.
+
+ @param _rInitialListEntries
+ the initial values of the control
+
+ @param _bReadOnlyControl
+ determines whether the control should be read-only
+
+ @param _bSorted
+ determines whether the list entries should be sorted
+
+ @return
+ the newly created control
+ */
+ static ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyControl >
+ createComboBoxControl(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyControlFactory >& _rxControlFactory,
+ const ::std::vector< ::rtl::OUString >& _rInitialListEntries,
+ sal_Bool _bReadOnlyControl,
+ sal_Bool _bSorted
+ );
+
+ /** creates an <member scope="com::sun::star::inspection">PropertyControlType::NumericField</member>-type control
+ and initializes it
+
+ @param _rxControlFactory
+ A control factory. Must not be <NULL/>.
+ @param _nDigits
+ number of decimal digits for the control
+ (<member scope="com::sun::star::inspection">XNumericControl::DecimalDigits</member>)
+ @param _rMinValue
+ minimum value which can be entered in the control
+ (<member scope="com::sun::star::inspection">XNumericControl::MinValue</member>)
+ @param _rMaxValue
+ maximum value which can be entered in the control
+ (<member scope="com::sun::star::inspection">XNumericControl::MaxValue</member>)
+ @param _bReadOnlyControl
+ determines whether the control should be read-only
+
+ @return
+ the newly created control
+ */
+ static ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyControl >
+ createNumericControl(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyControlFactory >& _rxControlFactory,
+ sal_Int16 _nDigits,
+ const ::com::sun::star::beans::Optional< double >& _rMinValue,
+ const ::com::sun::star::beans::Optional< double >& _rMaxValue,
+ sal_Bool _bReadOnlyControl
+ );
+
+ /** marks the document passed in our UNO context as modified
+
+ The method looks up a value called "ContextDocument" in the given UNO component context,
+ queries it for the ->com::sun::star::util::XModifiable interface, and calls its
+ setModified method. If either of those steps fails, this is asserted in a non-product
+ version, and silently ignore otherwise.
+
+ @param _rContext
+ the component context which was used to create the component calling this method
+ */
+ static void setContextDocumentModified(
+ const ComponentContext& _rContext
+ );
+
+ /** gets the window of the ObjectInspector in which an property handler lives
+
+ The method looks up a value called "DialogParentWindow" in the given UNO copmonent context,
+ queries it for XWindow, and returns the respective Window*. If either of those steps fails,
+ this is asserted in a non-product version, and silently ignore otherwise.
+
+ @param _rContext
+ the component context which was used to create the component calling this method
+ */
+ static Window* getDialogParentWindow( const ComponentContext& _rContext );
+
+
+ /** determines whether given PropertyAttributes require a to-be-created
+ <type scope="com::sun::star::inspection">XPropertyControl</type> to be read-only
+
+ @param _nPropertyAttributes
+ the attributes of the property which should be reflected by a to-be-created
+ <type scope="com::sun::star::inspection">XPropertyControl</type>
+ */
+ inline static sal_Bool requiresReadOnlyControl( sal_Int16 _nPropertyAttributes )
+ {
+ return ( _nPropertyAttributes & ::com::sun::star::beans::PropertyAttribute::READONLY ) != 0;
+ }
+
+ private:
+ PropertyHandlerHelper(); // never implemented
+ PropertyHandlerHelper( const PropertyHandlerHelper& ); // never implemented
+ PropertyHandlerHelper& operator=( const PropertyHandlerHelper& ); // never implemented
+ };
+
+//........................................................................
+} // namespace pcr
+//........................................................................
+
+#endif // EXTENSIONS_SOURCE_PROPCTRLR_HANDLERHELPER_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/propctrlr/inspectorhelpwindow.cxx b/extensions/source/propctrlr/inspectorhelpwindow.cxx
new file mode 100644
index 000000000000..2ed90d583b86
--- /dev/null
+++ b/extensions/source/propctrlr/inspectorhelpwindow.cxx
@@ -0,0 +1,153 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+#include "inspectorhelpwindow.hxx"
+#include "modulepcr.hxx"
+#include "propresid.hrc"
+
+/** === begin UNO includes === **/
+/** === end UNO includes === **/
+
+//........................................................................
+namespace pcr
+{
+//........................................................................
+
+ /** === begin UNO using === **/
+ /** === end UNO using === **/
+
+ //====================================================================
+ //= InspectorHelpWindow
+ //====================================================================
+ //--------------------------------------------------------------------
+ InspectorHelpWindow::InspectorHelpWindow( Window* _pParent )
+ :Window( _pParent, WB_DIALOGCONTROL )
+ ,m_aSeparator( this )
+ ,m_aHelpText( this, WB_LEFT | WB_READONLY | WB_AUTOVSCROLL )
+ ,m_nMinLines( 3 )
+ ,m_nMaxLines( 8 )
+ {
+ SetBackground();
+ SetPaintTransparent(TRUE);
+ m_aSeparator.SetText( String( PcrRes( RID_STR_HELP_SECTION_LABEL ) ) );
+ m_aSeparator.SetBackground();
+ m_aSeparator.Show();
+
+ m_aHelpText.SetControlBackground( /*m_aSeparator.GetBackground().GetColor() */);
+ m_aHelpText.SetBackground();
+ m_aHelpText.SetPaintTransparent(TRUE);
+ m_aHelpText.Show();
+ }
+
+ //--------------------------------------------------------------------
+ void InspectorHelpWindow::SetText( const XubString& _rStr )
+ {
+ m_aHelpText.SetText( _rStr );
+ }
+
+ //--------------------------------------------------------------------
+ void InspectorHelpWindow::SetLimits( sal_Int32 _nMinLines, sal_Int32 _nMaxLines )
+ {
+ m_nMinLines = _nMinLines;
+ m_nMaxLines = _nMaxLines;
+ }
+
+ //--------------------------------------------------------------------
+ long InspectorHelpWindow::impl_getHelpTextBorderHeight()
+ {
+ sal_Int32 nTop(0), nBottom(0), nDummy(0);
+ m_aHelpText.GetBorder( nDummy, nTop, nDummy, nBottom );
+ return nTop + nBottom;
+ }
+
+ //--------------------------------------------------------------------
+ long InspectorHelpWindow::impl_getSpaceAboveTextWindow()
+ {
+ Size aSeparatorSize( LogicToPixel( Size( 0, 8 ), MAP_APPFONT ) );
+ Size a3AppFontSize( LogicToPixel( Size( 3, 3 ), MAP_APPFONT ) );
+ return aSeparatorSize.Height() + a3AppFontSize.Height();
+ }
+
+ //--------------------------------------------------------------------
+ long InspectorHelpWindow::GetMinimalHeightPixel()
+ {
+ return impl_getMinimalTextWindowHeight() + impl_getSpaceAboveTextWindow();
+ }
+
+ //--------------------------------------------------------------------
+ long InspectorHelpWindow::impl_getMinimalTextWindowHeight()
+ {
+ return impl_getHelpTextBorderHeight() + m_aHelpText.GetTextHeight() * m_nMinLines;
+ }
+
+ //--------------------------------------------------------------------
+ long InspectorHelpWindow::impl_getMaximalTextWindowHeight()
+ {
+ return impl_getHelpTextBorderHeight() + m_aHelpText.GetTextHeight() * m_nMaxLines;
+ }
+
+ //--------------------------------------------------------------------
+ long InspectorHelpWindow::GetOptimalHeightPixel()
+ {
+ // --- calc the height as needed for the mere text window
+ long nMinTextWindowHeight = impl_getMinimalTextWindowHeight();
+ long nMaxTextWindowHeight = impl_getMaximalTextWindowHeight();
+
+ Rectangle aTextRect( Point( 0, 0 ), m_aHelpText.GetOutputSizePixel() );
+ aTextRect = m_aHelpText.GetTextRect( aTextRect, m_aHelpText.GetText(),
+ TEXT_DRAW_LEFT | TEXT_DRAW_TOP | TEXT_DRAW_MULTILINE | TEXT_DRAW_WORDBREAK );
+ long nActTextWindowHeight = impl_getHelpTextBorderHeight() + aTextRect.GetHeight();
+
+ long nOptTextWindowHeight = ::std::max( nMinTextWindowHeight, ::std::min( nMaxTextWindowHeight, nActTextWindowHeight ) );
+
+ // --- then add the space above the text window
+ return nOptTextWindowHeight + impl_getSpaceAboveTextWindow();
+ }
+
+ //--------------------------------------------------------------------
+ void InspectorHelpWindow::Resize()
+ {
+ Size a3AppFont( LogicToPixel( Size( 3, 3 ), MAP_APPFONT ) );
+
+ Rectangle aPlayground( Point( 0, 0 ), GetOutputSizePixel() );
+
+ Rectangle aSeparatorArea( aPlayground );
+ aSeparatorArea.Bottom() = aSeparatorArea.Top() + LogicToPixel( Size( 0, 8 ), MAP_APPFONT ).Height();
+ m_aSeparator.SetPosSizePixel( aSeparatorArea.TopLeft(), aSeparatorArea.GetSize() );
+
+ Rectangle aTextArea( aPlayground );
+ aTextArea.Top() = aSeparatorArea.Bottom() + a3AppFont.Height();
+ m_aHelpText.SetPosSizePixel( aTextArea.TopLeft(), aTextArea.GetSize() );
+ }
+
+//........................................................................
+} // namespace pcr
+//........................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/propctrlr/inspectorhelpwindow.hxx b/extensions/source/propctrlr/inspectorhelpwindow.hxx
new file mode 100644
index 000000000000..bae38265ab29
--- /dev/null
+++ b/extensions/source/propctrlr/inspectorhelpwindow.hxx
@@ -0,0 +1,80 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef INSPECTORHELPWINDOW_HXX
+#define INSPECTORHELPWINDOW_HXX
+
+/** === begin UNO includes === **/
+/** === end UNO includes === **/
+
+#include <vcl/fixed.hxx>
+#include <svtools/svmedit.hxx>
+
+//........................................................................
+namespace pcr
+{
+//........................................................................
+
+ //====================================================================
+ //= InspectorHelpWindow
+ //====================================================================
+ class InspectorHelpWindow : public Window
+ {
+ private:
+ FixedLine m_aSeparator;
+ MultiLineEdit m_aHelpText;
+
+ sal_Int32 m_nMinLines;
+ sal_Int32 m_nMaxLines;
+
+ public:
+ InspectorHelpWindow( Window* _pParent );
+
+ virtual void SetText( const XubString& rStr );
+
+ void SetLimits( sal_Int32 _nMinLines, sal_Int32 _nMaxLines );
+ long GetMinimalHeightPixel();
+ long GetOptimalHeightPixel();
+
+ protected:
+ // Window overridables
+ virtual void Resize();
+
+ private:
+ long impl_getMinimalTextWindowHeight();
+ long impl_getMaximalTextWindowHeight();
+ long impl_getHelpTextBorderHeight();
+ long impl_getSpaceAboveTextWindow();
+ };
+
+//........................................................................
+} // namespace pcr
+//........................................................................
+
+#endif // HELPWINDOW_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/propctrlr/inspectormodelbase.cxx b/extensions/source/propctrlr/inspectormodelbase.cxx
new file mode 100644
index 000000000000..3402d28a4077
--- /dev/null
+++ b/extensions/source/propctrlr/inspectormodelbase.cxx
@@ -0,0 +1,275 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+#include "inspectormodelbase.hxx"
+#include "pcrcommon.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+/** === end UNO includes === **/
+
+#include <comphelper/propertycontainerhelper.hxx>
+
+//........................................................................
+namespace pcr
+{
+//........................................................................
+
+#define MODEL_PROPERTY_ID_HAS_HELP_SECTION 2000
+#define MODEL_PROPERTY_ID_MIN_HELP_TEXT_LINES 2001
+#define MODEL_PROPERTY_ID_MAX_HELP_TEXT_LINES 2002
+#define MODEL_PROPERTY_ID_IS_READ_ONLY 2003
+
+ /** === begin UNO using === **/
+ using ::com::sun::star::uno::Reference;
+ using ::com::sun::star::uno::XComponentContext;
+ using ::com::sun::star::beans::XPropertySetInfo;
+ using ::com::sun::star::uno::RuntimeException;
+ using ::com::sun::star::uno::Any;
+ using ::com::sun::star::lang::IllegalArgumentException;
+ using ::com::sun::star::uno::Exception;
+ using ::com::sun::star::uno::Sequence;
+ using ::com::sun::star::inspection::PropertyCategoryDescriptor;
+ using ::com::sun::star::uno::makeAny;
+ using ::com::sun::star::beans::Property;
+ /** === end UNO using === **/
+ namespace PropertyAttribute = ::com::sun::star::beans::PropertyAttribute;
+
+ //====================================================================
+ //= InspectorModelProperties
+ //====================================================================
+ /** helper class for implementing the property set related functionality
+ of an ImplInspectorModel
+ */
+ class InspectorModelProperties : public ::comphelper::OPropertyContainerHelper
+ {
+ private:
+ ::osl::Mutex& m_rMutex;
+ sal_Bool m_bHasHelpSection;
+ sal_Int32 m_nMinHelpTextLines;
+ sal_Int32 m_nMaxHelpTextLines;
+ sal_Bool m_bIsReadOnly;
+ ::std::auto_ptr< ::cppu::IPropertyArrayHelper >
+ m_pPropertyInfo;
+
+ public:
+ InspectorModelProperties( ::osl::Mutex& _rMutex );
+
+ using ::comphelper::OPropertyContainerHelper::convertFastPropertyValue;
+ using ::comphelper::OPropertyContainerHelper::setFastPropertyValue;
+ using ::comphelper::OPropertyContainerHelper::getFastPropertyValue;
+
+ public:
+ inline sal_Bool hasHelpSection() const { return m_bHasHelpSection; }
+ inline sal_Bool isReadOnly() const { return m_bIsReadOnly; }
+ inline sal_Int32 getMinHelpTextLines() const { return m_nMinHelpTextLines; }
+ inline sal_Int32 getMaxHelpTextLines() const { return m_nMaxHelpTextLines; }
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo >
+ getPropertySetInfo();
+ ::cppu::IPropertyArrayHelper&
+ getInfoHelper();
+
+ void constructWithHelpSection( sal_Int32 _nMinHelpTextLines, sal_Int32 _nMaxHelpTextLines );
+ };
+
+ //====================================================================
+ //= InspectorModelProperties
+ //====================================================================
+ //--------------------------------------------------------------------
+ InspectorModelProperties::InspectorModelProperties( ::osl::Mutex& _rMutex )
+ :m_rMutex( _rMutex )
+ ,m_bHasHelpSection( sal_False )
+ ,m_nMinHelpTextLines( 3 )
+ ,m_nMaxHelpTextLines( 8 )
+ ,m_bIsReadOnly( sal_False )
+ {
+ registerProperty(
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "HasHelpSection" ) ),
+ MODEL_PROPERTY_ID_HAS_HELP_SECTION,
+ PropertyAttribute::READONLY,
+ &m_bHasHelpSection, ::getCppuType( &m_bHasHelpSection )
+ );
+ registerProperty(
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "MinHelpTextLines" ) ),
+ MODEL_PROPERTY_ID_MIN_HELP_TEXT_LINES,
+ PropertyAttribute::READONLY,
+ &m_nMinHelpTextLines, ::getCppuType( &m_nMinHelpTextLines )
+ );
+ registerProperty(
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "MaxHelpTextLines" ) ),
+ MODEL_PROPERTY_ID_MAX_HELP_TEXT_LINES,
+ PropertyAttribute::READONLY,
+ &m_nMaxHelpTextLines, ::getCppuType( &m_nMaxHelpTextLines )
+ );
+ registerProperty(
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IsReadOnly" ) ),
+ MODEL_PROPERTY_ID_IS_READ_ONLY,
+ PropertyAttribute::BOUND,
+ &m_bIsReadOnly, ::getCppuType( &m_bIsReadOnly )
+ );
+ }
+
+ //--------------------------------------------------------------------
+ void InspectorModelProperties::constructWithHelpSection( sal_Int32 _nMinHelpTextLines, sal_Int32 _nMaxHelpTextLines )
+ {
+ m_bHasHelpSection = sal_True;
+ m_nMinHelpTextLines = _nMinHelpTextLines;
+ m_nMaxHelpTextLines = _nMaxHelpTextLines;
+ // no need to notify this, those properties are not bound. Also, the method should
+ // only be used during construction phase, where we don't expect to have any listeners.
+ }
+
+ //--------------------------------------------------------------------
+ ::cppu::IPropertyArrayHelper& InspectorModelProperties::getInfoHelper()
+ {
+ ::osl::MutexGuard aGuard( m_rMutex );
+ if ( m_pPropertyInfo.get() == NULL )
+ {
+ Sequence< Property > aProperties;
+ describeProperties( aProperties );
+
+ m_pPropertyInfo.reset( new ::cppu::OPropertyArrayHelper( aProperties ) );
+ }
+ return *m_pPropertyInfo;
+ }
+
+ //--------------------------------------------------------------------
+ Reference< XPropertySetInfo > InspectorModelProperties::getPropertySetInfo()
+ {
+ return ::cppu::OPropertySetHelper::createPropertySetInfo( getInfoHelper() );
+ }
+
+ //====================================================================
+ //= ImplInspectorModel
+ //====================================================================
+ ImplInspectorModel::ImplInspectorModel( const Reference< XComponentContext >& _rxContext )
+ :ImplInspectorModel_PBase( GetBroadcastHelper() )
+ ,m_aContext( _rxContext )
+ ,m_pProperties( new InspectorModelProperties( m_aMutex ) )
+ {
+ }
+
+ //--------------------------------------------------------------------
+ ImplInspectorModel::~ImplInspectorModel()
+ {
+ }
+
+ //--------------------------------------------------------------------
+ IMPLEMENT_FORWARD_XINTERFACE2( ImplInspectorModel, ImplInspectorModel_Base, ImplInspectorModel_PBase )
+
+ //--------------------------------------------------------------------
+ IMPLEMENT_FORWARD_XTYPEPROVIDER2( ImplInspectorModel, ImplInspectorModel_Base, ImplInspectorModel_PBase )
+
+ //--------------------------------------------------------------------
+ Reference< XPropertySetInfo > SAL_CALL ImplInspectorModel::getPropertySetInfo( ) throw (RuntimeException)
+ {
+ return m_pProperties->getPropertySetInfo();
+ }
+
+ //--------------------------------------------------------------------
+ ::cppu::IPropertyArrayHelper& SAL_CALL ImplInspectorModel::getInfoHelper()
+ {
+ return m_pProperties->getInfoHelper();
+ }
+
+ //--------------------------------------------------------------------
+ sal_Bool SAL_CALL ImplInspectorModel::convertFastPropertyValue( Any & rConvertedValue, Any & rOldValue, sal_Int32 nHandle, const Any& rValue ) throw (IllegalArgumentException)
+ {
+ return m_pProperties->convertFastPropertyValue( rConvertedValue, rOldValue, nHandle, rValue );
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL ImplInspectorModel::setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const Any& rValue ) throw (Exception)
+ {
+ m_pProperties->setFastPropertyValue( nHandle, rValue );
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL ImplInspectorModel::getFastPropertyValue( Any& rValue, sal_Int32 nHandle ) const
+ {
+ m_pProperties->getFastPropertyValue( rValue, nHandle );
+ }
+
+ //--------------------------------------------------------------------
+ ::sal_Bool SAL_CALL ImplInspectorModel::getHasHelpSection() throw (RuntimeException)
+ {
+ return m_pProperties->hasHelpSection();
+ }
+
+ //--------------------------------------------------------------------
+ ::sal_Int32 SAL_CALL ImplInspectorModel::getMinHelpTextLines() throw (RuntimeException)
+ {
+ return m_pProperties->getMinHelpTextLines();
+ }
+
+ //--------------------------------------------------------------------
+ ::sal_Int32 SAL_CALL ImplInspectorModel::getMaxHelpTextLines() throw (RuntimeException)
+ {
+ return m_pProperties->getMaxHelpTextLines();
+ }
+
+ //--------------------------------------------------------------------
+ ::sal_Bool SAL_CALL ImplInspectorModel::getIsReadOnly() throw (::com::sun::star::uno::RuntimeException)
+ {
+ return m_pProperties->isReadOnly();
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL ImplInspectorModel::setIsReadOnly( ::sal_Bool _IsReadOnly ) throw (::com::sun::star::uno::RuntimeException)
+ {
+ setFastPropertyValue( MODEL_PROPERTY_ID_IS_READ_ONLY, makeAny( _IsReadOnly ) );
+ }
+
+ //--------------------------------------------------------------------
+ ::sal_Bool SAL_CALL ImplInspectorModel::supportsService( const ::rtl::OUString& ServiceName ) throw (RuntimeException)
+ {
+ StlSyntaxSequence< ::rtl::OUString > aSupported( getSupportedServiceNames() );
+ for ( StlSyntaxSequence< ::rtl::OUString >::const_iterator check = aSupported.begin();
+ check != aSupported.end();
+ ++check
+ )
+ if ( check->equals( ServiceName ) )
+ return sal_True;
+
+ return sal_False;
+ }
+
+ //--------------------------------------------------------------------
+ void ImplInspectorModel::enableHelpSectionProperties( sal_Int32 _nMinHelpTextLines, sal_Int32 _nMaxHelpTextLines )
+ {
+ m_pProperties->constructWithHelpSection( _nMinHelpTextLines, _nMaxHelpTextLines );
+ }
+
+//........................................................................
+} // namespace pcr
+//........................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/propctrlr/inspectormodelbase.hxx b/extensions/source/propctrlr/inspectormodelbase.hxx
new file mode 100644
index 000000000000..3c79dfe2d7c2
--- /dev/null
+++ b/extensions/source/propctrlr/inspectormodelbase.hxx
@@ -0,0 +1,110 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef INSPECTORMODELBASE_HXX
+#define INSPECTORMODELBASE_HXX
+
+/** === begin UNO includes === **/
+#include <com/sun/star/inspection/XObjectInspectorModel.hpp>
+#include <com/sun/star/lang/XInitialization.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+/** === end UNO includes === **/
+
+#include <cppuhelper/implbase3.hxx>
+#include <cppuhelper/propshlp.hxx>
+
+#include <comphelper/broadcasthelper.hxx>
+#include <comphelper/componentcontext.hxx>
+#include <comphelper/uno3.hxx>
+
+#include <memory>
+
+//........................................................................
+namespace pcr
+{
+//........................................................................
+
+ class InspectorModelProperties;
+ //====================================================================
+ //= ImplInspectorModel
+ //====================================================================
+ typedef ::cppu::WeakImplHelper3 < ::com::sun::star::inspection::XObjectInspectorModel
+ , ::com::sun::star::lang::XInitialization
+ , ::com::sun::star::lang::XServiceInfo
+ > ImplInspectorModel_Base;
+ typedef ::cppu::OPropertySetHelper ImplInspectorModel_PBase;
+
+ class ImplInspectorModel
+ :public ::comphelper::OMutexAndBroadcastHelper
+ ,public ImplInspectorModel_Base
+ ,public ImplInspectorModel_PBase
+ {
+ protected:
+ ::comphelper::ComponentContext m_aContext;
+ ::std::auto_ptr< InspectorModelProperties > m_pProperties;
+
+ protected:
+ ~ImplInspectorModel();
+
+ public:
+ ImplInspectorModel( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _rxContext );
+
+ DECLARE_XINTERFACE()
+ DECLARE_XTYPEPROVIDER()
+
+ // ::com::sun::star::beans::XPropertySet and friends
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper();
+ 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);
+ virtual void SAL_CALL setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const ::com::sun::star::uno::Any& rValue ) throw (::com::sun::star::uno::Exception);
+ virtual void SAL_CALL getFastPropertyValue( ::com::sun::star::uno::Any& rValue, sal_Int32 nHandle ) const;
+
+ // ::com::sun::star::inspection::XObjectInspectorModel
+ virtual ::sal_Bool SAL_CALL getHasHelpSection() throw (::com::sun::star::uno::RuntimeException);
+ virtual ::sal_Int32 SAL_CALL getMinHelpTextLines() throw (::com::sun::star::uno::RuntimeException);
+ virtual ::sal_Int32 SAL_CALL getMaxHelpTextLines() throw (::com::sun::star::uno::RuntimeException);
+ virtual ::sal_Bool SAL_CALL getIsReadOnly() throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setIsReadOnly( ::sal_Bool _IsReadOnly ) throw (::com::sun::star::uno::RuntimeException);
+
+ // ::com::sun::star::lang::XServiceInfo
+ virtual ::sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw (::com::sun::star::uno::RuntimeException);
+
+ protected:
+ void enableHelpSectionProperties( sal_Int32 _nMinHelpTextLines, sal_Int32 _nMaxHelpTextLines );
+
+ private:
+ using ImplInspectorModel_PBase::getFastPropertyValue;
+ };
+
+//........................................................................
+} // namespace pcr
+//........................................................................
+
+#endif // INSPECTORMODELBASE_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/propctrlr/linedescriptor.hxx b/extensions/source/propctrlr/linedescriptor.hxx
new file mode 100644
index 000000000000..84d11e17f4a2
--- /dev/null
+++ b/extensions/source/propctrlr/linedescriptor.hxx
@@ -0,0 +1,72 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef _EXTENSIONS_PROPCTRLR_LINEDESCRIPTOR_HXX_
+#define _EXTENSIONS_PROPCTRLR_LINEDESCRIPTOR_HXX_
+
+#include <vcl/image.hxx>
+/** === begin UNO includes === **/
+#include <com/sun/star/inspection/LineDescriptor.hpp>
+/** === end UNO includes === **/
+
+//............................................................................
+namespace pcr
+{
+//............................................................................
+
+ //========================================================================
+ //= OLineDescriptor
+ //========================================================================
+ struct OLineDescriptor : public ::com::sun::star::inspection::LineDescriptor
+ {
+ ::rtl::OUString sName; // the name of the property
+ ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyHandler >
+ xPropertyHandler; // the handler for this property
+ ::com::sun::star::uno::Any aValue; // the current value of the property
+
+ bool bUnknownValue : 1; // is the property value currently "unknown"? (PropertyState_AMBIGUOUS)
+ bool bReadOnly : 1;
+
+ OLineDescriptor()
+ :bUnknownValue( false )
+ ,bReadOnly( false )
+ {
+ }
+
+ void assignFrom( const ::com::sun::star::inspection::LineDescriptor& _rhs )
+ {
+ ::com::sun::star::inspection::LineDescriptor::operator=( _rhs );
+ }
+ };
+
+//............................................................................
+} // namespace pcr
+//............................................................................
+
+#endif // _EXTENSIONS_PROPCTRLR_LINEDESCRIPTOR_HXX_
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/propctrlr/listselectiondlg.cxx b/extensions/source/propctrlr/listselectiondlg.cxx
new file mode 100644
index 000000000000..9c8cfcd59aea
--- /dev/null
+++ b/extensions/source/propctrlr/listselectiondlg.cxx
@@ -0,0 +1,170 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+#include "listselectiondlg.hxx"
+#include "listselectiondlg.hrc"
+
+#include "modulepcr.hxx"
+#include "formresid.hrc"
+#include "formstrings.hxx"
+#include <vcl/msgbox.hxx>
+
+/** === begin UNO includes === **/
+/** === end UNO includes === **/
+
+//........................................................................
+namespace pcr
+{
+//........................................................................
+
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::beans;
+
+ //====================================================================
+ //= ListSelectionDialog
+ //====================================================================
+ //--------------------------------------------------------------------
+ ListSelectionDialog::ListSelectionDialog( Window* _pParent, const Reference< XPropertySet >& _rxListBox,
+ const ::rtl::OUString& _rPropertyName, const String& _rPropertyUIName )
+ :ModalDialog( _pParent, PcrRes( RID_DLG_SELECTION ) )
+ ,m_aLabel ( this, PcrRes( FT_ENTRIES ) )
+ ,m_aEntries ( this, PcrRes( LB_ENTRIES ) )
+ ,m_aOK ( this, PcrRes( PB_OK ) )
+ ,m_aCancel ( this, PcrRes( PB_CANCEL ) )
+ ,m_aHelp ( this, PcrRes( PB_HELP ) )
+ ,m_xListBox ( _rxListBox )
+ ,m_sPropertyName( _rPropertyName )
+ {
+ FreeResource();
+
+ OSL_PRECOND( m_xListBox.is(), "ListSelectionDialog::ListSelectionDialog: invalid list box!" );
+
+ SetText( _rPropertyUIName );
+ m_aLabel.SetText( _rPropertyUIName );
+
+ initialize( );
+ }
+
+ //------------------------------------------------------------------------
+ short ListSelectionDialog::Execute()
+ {
+ short nResult = ModalDialog::Execute();
+
+ if ( RET_OK == nResult )
+ commitSelection();
+
+ return nResult;
+ }
+
+ //--------------------------------------------------------------------
+ void ListSelectionDialog::initialize( )
+ {
+ if ( !m_xListBox.is() )
+ return;
+
+ m_aEntries.SetStyle( GetStyle() | WB_SIMPLEMODE );
+
+ try
+ {
+ // initialize the multi-selection flag
+ sal_Bool bMultiSelection = sal_False;
+ OSL_VERIFY( m_xListBox->getPropertyValue( PROPERTY_MULTISELECTION ) >>= bMultiSelection );
+ m_aEntries.EnableMultiSelection( bMultiSelection );
+
+ // fill the list box with all entries
+ Sequence< ::rtl::OUString > aListEntries;
+ OSL_VERIFY( m_xListBox->getPropertyValue( PROPERTY_STRINGITEMLIST ) >>= aListEntries );
+ fillEntryList( aListEntries );
+
+ // select entries according to the property
+ Sequence< sal_Int16 > aSelection;
+ OSL_VERIFY( m_xListBox->getPropertyValue( m_sPropertyName ) >>= aSelection );
+ selectEntries( aSelection );
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "ListSelectionDialog::initialize: caught an exception!" );
+ }
+ }
+
+ //--------------------------------------------------------------------
+ void ListSelectionDialog::commitSelection()
+ {
+ if ( !m_xListBox.is() )
+ return;
+
+ Sequence< sal_Int16 > aSelection;
+ collectSelection( aSelection );
+
+ try
+ {
+ m_xListBox->setPropertyValue( m_sPropertyName, makeAny( aSelection ) );
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "ListSelectionDialog::commitSelection: caught an exception!" );
+ }
+ }
+
+ //--------------------------------------------------------------------
+ void ListSelectionDialog::fillEntryList( const Sequence< ::rtl::OUString >& _rListEntries )
+ {
+ m_aEntries.Clear();
+ const ::rtl::OUString* _pListEntries = _rListEntries.getConstArray();
+ const ::rtl::OUString* _pListEntriesEnd = _rListEntries.getConstArray() + _rListEntries.getLength();
+ for ( ; _pListEntries < _pListEntriesEnd; ++_pListEntries )
+ m_aEntries.InsertEntry( *_pListEntries );
+ }
+
+ //--------------------------------------------------------------------
+ void ListSelectionDialog::collectSelection( Sequence< sal_Int16 >& /* [out] */ _rSelection )
+ {
+ sal_uInt16 nSelectedCount = m_aEntries.GetSelectEntryCount( );
+ _rSelection.realloc( nSelectedCount );
+ sal_Int16* pSelection = _rSelection.getArray();
+ for ( sal_uInt16 selected = 0; selected < nSelectedCount; ++selected, ++pSelection )
+ *pSelection = static_cast< sal_Int16 >( m_aEntries.GetSelectEntryPos( selected ) );
+ }
+
+ //--------------------------------------------------------------------
+ void ListSelectionDialog::selectEntries( const Sequence< sal_Int16 >& /* [in ] */ _rSelection )
+ {
+ m_aEntries.SetNoSelection();
+ const sal_Int16* pSelection = _rSelection.getConstArray();
+ const sal_Int16* pSelectionEnd = _rSelection.getConstArray() + _rSelection.getLength();
+ for ( ; pSelection != pSelectionEnd; ++pSelection )
+ m_aEntries.SelectEntryPos( *pSelection );
+ }
+
+//........................................................................
+} // namespace pcr
+//........................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/propctrlr/listselectiondlg.hrc b/extensions/source/propctrlr/listselectiondlg.hrc
new file mode 100644
index 000000000000..6419f530311b
--- /dev/null
+++ b/extensions/source/propctrlr/listselectiondlg.hrc
@@ -0,0 +1,39 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef EXTENSIONS_SOURCE_PROPCTRLR_LISTSELECTIONDLG_HRC
+#define EXTENSIONS_SOURCE_PROPCTRLR_LISTSELECTIONDLG_HRC
+
+#define FT_ENTRIES 1
+
+#define LB_ENTRIES 1
+
+#define PB_OK 1
+#define PB_CANCEL 2
+#define PB_HELP 3
+
+#endif // EXTENSIONS_SOURCE_PROPCTRLR_LISTSELECTIONDLG_HRC
diff --git a/extensions/source/propctrlr/listselectiondlg.hxx b/extensions/source/propctrlr/listselectiondlg.hxx
new file mode 100644
index 000000000000..feaf8c0fa0e4
--- /dev/null
+++ b/extensions/source/propctrlr/listselectiondlg.hxx
@@ -0,0 +1,89 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef EXTENSIONS_SOURCE_PROPCTRLR_LISTSELECTIONDLG_HXX
+#define EXTENSIONS_SOURCE_PROPCTRLR_LISTSELECTIONDLG_HXX
+
+#include <vcl/dialog.hxx>
+#include <vcl/fixed.hxx>
+#include <vcl/button.hxx>
+#include <vcl/lstbox.hxx>
+
+/** === begin UNO includes === **/
+#include <com/sun/star/beans/XPropertySet.hpp>
+/** === end UNO includes === **/
+
+//........................................................................
+namespace pcr
+{
+//........................................................................
+
+ //====================================================================
+ //= ListSelectionDialog
+ //====================================================================
+ class ListSelectionDialog : public ModalDialog
+ {
+ private:
+ FixedText m_aLabel;
+ ListBox m_aEntries;
+ OKButton m_aOK;
+ CancelButton m_aCancel;
+ HelpButton m_aHelp;
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >
+ m_xListBox;
+ ::rtl::OUString m_sPropertyName;
+
+ public:
+ ListSelectionDialog(
+ Window* _pParent,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxListBox,
+ const ::rtl::OUString& _rPropertyName,
+ const String& _rPropertyUIName
+ );
+
+ // Dialog overridables
+ virtual short Execute();
+
+ private:
+ void initialize( );
+ void commitSelection();
+
+ void fillEntryList ( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& _rListEntries );
+
+ void selectEntries ( const ::com::sun::star::uno::Sequence< sal_Int16 >& /* [in ] */ _rSelection );
+ void collectSelection( ::com::sun::star::uno::Sequence< sal_Int16 >& /* [out] */ _rSelection );
+ };
+
+//........................................................................
+} // namespacepcr
+//........................................................................
+
+#endif // EXTENSIONS_SOURCE_PROPCTRLR_LISTSELECTIONDLG_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/propctrlr/listselectiondlg.src b/extensions/source/propctrlr/listselectiondlg.src
new file mode 100644
index 000000000000..7b148e8a9908
--- /dev/null
+++ b/extensions/source/propctrlr/listselectiondlg.src
@@ -0,0 +1,80 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _EXTENSIONS_FORMCTRLR_PROPRESID_HRC_
+#include "formresid.hrc"
+#endif
+#include "propctrlr.hrc"
+#ifndef EXTENSIONS_SOURCE_PROPCTRLR_LISTSELECTIONDLG_HRC
+#include "listselectiondlg.hrc"
+#endif
+
+ModalDialog RID_DLG_SELECTION
+{
+ OutputSize = TRUE ;
+ Moveable = TRUE ;
+ Closeable = TRUE ;
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( 150, 120 ) ;
+
+ FixedText FT_ENTRIES
+ {
+ Pos = MAP_APPFONT( 6, 6 );
+ Size = MAP_APPFONT( 85, 8 );
+ };
+
+ ListBox LB_ENTRIES
+ {
+ Pos = MAP_APPFONT( 6, 17 );
+ Size = MAP_APPFONT( 85, 97 );
+
+ Border = TRUE;
+ DropDown = FALSE;
+ };
+
+ OKButton PB_OK
+ {
+ Pos = MAP_APPFONT( 97, 6 );
+ Size = MAP_APPFONT( 50, 14 );
+ TabStop = TRUE;
+ DefButton = TRUE;
+ };
+
+ CancelButton PB_CANCEL
+ {
+ Pos = MAP_APPFONT( 97, 23 );
+ Size = MAP_APPFONT( 50, 14 );
+ TabStop = TRUE;
+ };
+
+ HelpButton PB_HELP
+ {
+ Pos = MAP_APPFONT( 97, 43 );
+ Size = MAP_APPFONT( 50, 14 );
+ TabStop = TRUE;
+ };
+};
diff --git a/extensions/source/propctrlr/makefile.mk b/extensions/source/propctrlr/makefile.mk
new file mode 100644
index 000000000000..c69f47bcef1a
--- /dev/null
+++ b/extensions/source/propctrlr/makefile.mk
@@ -0,0 +1,146 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+PRJ=..$/..
+PRJINC=..$/inc
+
+PRJNAME=extensions
+TARGET=pcr
+USE_DEFFILE=TRUE
+
+ENABLE_EXCEPTIONS=TRUE
+VISIBILITY_HIDDEN=TRUE
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : $(PRJ)$/util$/makefile.pmk
+
+# --- Files --------------------------------------------------------
+
+SLOFILES= $(SLO)$/controlfontdialog.obj \
+ $(SLO)$/fontdialog.obj \
+ $(SLO)$/pcrservices.obj \
+ $(SLO)$/selectlabeldialog.obj \
+ $(SLO)$/propcontroller.obj \
+ $(SLO)$/formcontroller.obj \
+ $(SLO)$/modulepcr.obj \
+ $(SLO)$/cellbindinghelper.obj \
+ $(SLO)$/taborder.obj \
+ $(SLO)$/pcrunodialogs.obj \
+ $(SLO)$/unourl.obj \
+ $(SLO)$/formlinkdialog.obj \
+ $(SLO)$/listselectiondlg.obj \
+ $(SLO)$/browserlistbox.obj \
+ $(SLO)$/stringrepresentation.obj \
+ $(SLO)$/eformshelper.obj \
+ $(SLO)$/xsddatatypes.obj \
+ $(SLO)$/xsdvalidationhelper.obj \
+ $(SLO)$/pushbuttonnavigation.obj \
+ $(SLO)$/sqlcommanddesign.obj \
+ $(SLO)$/composeduiupdate.obj \
+ $(SLO)$/propertycomposer.obj \
+ $(SLO)$/pcrcomponentcontext.obj \
+ $(SLO)$/commoncontrol.obj \
+ $(SLO)$/standardcontrol.obj \
+ $(SLO)$/usercontrol.obj \
+ $(SLO)$/browserline.obj \
+ $(SLO)$/genericpropertyhandler.obj \
+ $(SLO)$/buttonnavigationhandler.obj \
+ $(SLO)$/handlerhelper.obj \
+ $(SLO)$/propertyhandler.obj \
+ $(SLO)$/eventhandler.obj \
+ $(SLO)$/editpropertyhandler.obj \
+ $(SLO)$/eformspropertyhandler.obj \
+ $(SLO)$/cellbindinghandler.obj \
+ $(SLO)$/submissionhandler.obj \
+ $(SLO)$/xsdvalidationpropertyhandler.obj \
+ $(SLO)$/formcomponenthandler.obj \
+ $(SLO)$/formmetadata.obj \
+ $(SLO)$/defaultforminspection.obj \
+ $(SLO)$/formbrowsertools.obj \
+ $(SLO)$/browserpage.obj \
+ $(SLO)$/propertyeditor.obj \
+ $(SLO)$/formstrings.obj \
+ $(SLO)$/pcrstrings.obj \
+ $(SLO)$/browserview.obj \
+ $(SLO)$/pcrcommon.obj \
+ $(SLO)$/newdatatype.obj \
+ $(SLO)$/propeventtranslation.obj \
+ $(SLO)$/objectinspectormodel.obj \
+ $(SLO)$/inspectorhelpwindow.obj \
+ $(SLO)$/defaulthelpprovider.obj \
+ $(SLO)$/MasterDetailLinkDialog.obj \
+ $(SLO)$/inspectormodelbase.obj \
+ $(SLO)$/propertycontrolextender.obj \
+ $(SLO)$/formgeometryhandler.obj
+
+SRS1NAME=$(TARGET)
+SRC1FILES= propres.src \
+ formres.src \
+ pcrmiscres.src \
+ taborder.src \
+ fontdialog.src \
+ selectlabeldialog.src \
+ formlinkdialog.src \
+ listselectiondlg.src \
+ newdatatype.src
+
+RESLIB1NAME=$(TARGET)
+RESLIB1IMAGES=$(PRJ)$/res
+RESLIB1SRSFILES= $(SRS)$/$(TARGET).srs
+
+SHL1TARGET= $(TARGET)$(DLLPOSTFIX)
+SHL1VERSIONMAP=$(SOLARENV)/src/component.map
+
+SHL1STDLIBS= \
+ $(EDITENGLIB) \
+ $(SVXCORELIB) \
+ $(SVXLIB) \
+ $(SFXLIB) \
+ $(SVTOOLLIB)\
+ $(TKLIB) \
+ $(VCLLIB) \
+ $(SVLLIB) \
+ $(TOOLSLIB) \
+ $(I18NISOLANGLIB) \
+ $(DBTOOLSLIB) \
+ $(COMPHELPERLIB) \
+ $(CPPUHELPERLIB) \
+ $(CPPULIB) \
+ $(UNOTOOLSLIB) \
+ $(SALLIB)
+
+SHL1LIBS= $(SLB)$/$(TARGET).lib
+SHL1IMPLIB= i$(TARGET)
+SHL1DEPN= $(SHL1LIBS)
+SHL1DEF= $(MISC)$/$(SHL1TARGET).def
+
+DEF1NAME= $(SHL1TARGET)
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : target.mk
+
diff --git a/extensions/source/propctrlr/modulepcr.cxx b/extensions/source/propctrlr/modulepcr.cxx
new file mode 100644
index 000000000000..06d89a385277
--- /dev/null
+++ b/extensions/source/propctrlr/modulepcr.cxx
@@ -0,0 +1,47 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+#include "modulepcr.hxx"
+
+#include <rtl/instance.hxx>
+#include <osl/getglobalmutex.hxx>
+
+//........................................................................
+namespace pcr
+{
+//........................................................................
+
+ IMPLEMENT_MODULE( PcrModule, "pcr" )
+
+//........................................................................
+} // namespace pcr
+//........................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/propctrlr/modulepcr.hxx b/extensions/source/propctrlr/modulepcr.hxx
new file mode 100644
index 000000000000..458aff77b7bf
--- /dev/null
+++ b/extensions/source/propctrlr/modulepcr.hxx
@@ -0,0 +1,47 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef EXTENSIONS_PROPCTRLR_MODULEPRC_HXX
+#define EXTENSIONS_PROPCTRLR_MODULEPRC_HXX
+
+#include <unotools/componentresmodule.hxx>
+
+//........................................................................
+namespace pcr
+{
+//........................................................................
+
+ DEFINE_MODULE( PcrModule, PcrClient, PcrRes )
+
+//........................................................................
+} // namespace pcr
+//........................................................................
+
+#endif // _EXTENSIONS_PROPCTRLR_MODULEPRC_HXX_
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/propctrlr/newdatatype.cxx b/extensions/source/propctrlr/newdatatype.cxx
new file mode 100644
index 000000000000..cf97f503caaf
--- /dev/null
+++ b/extensions/source/propctrlr/newdatatype.cxx
@@ -0,0 +1,105 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+#include "newdatatype.hxx"
+#include "newdatatype.hrc"
+
+#include "modulepcr.hxx"
+#include "formresid.hrc"
+
+/** === begin UNO includes === **/
+/** === end UNO includes === **/
+
+//........................................................................
+namespace pcr
+{
+//........................................................................
+
+ //====================================================================
+ //= NewDataTypeDialog
+ //====================================================================
+ //--------------------------------------------------------------------
+ NewDataTypeDialog::NewDataTypeDialog( Window* _pParent, const ::rtl::OUString& _rNameBase, const ::std::vector< ::rtl::OUString >& _rProhibitedNames )
+ :ModalDialog( _pParent, PcrRes( RID_DLG_NEW_DATA_TYPE ) )
+ ,m_aLabel ( this, PcrRes( FT_LABEL ) )
+ ,m_aName ( this, PcrRes( ED_NAME ) )
+ ,m_aOK ( this, PcrRes( PB_OK ) )
+ ,m_aCancel ( this, PcrRes( PB_CANCEL ) )
+ ,m_aProhibitedNames( _rProhibitedNames.begin(), _rProhibitedNames.end() )
+ {
+ FreeResource();
+
+ m_aName.SetModifyHdl( LINK( this, NewDataTypeDialog, OnNameModified ) );
+
+ // find an initial name
+ // for this, first remove trailing digits
+ sal_Int32 nStripUntil = _rNameBase.getLength();
+ while ( nStripUntil > 0 )
+ {
+ sal_Unicode nChar = _rNameBase[ --nStripUntil ];
+ if ( ( nChar < '0' ) || ( nChar > '9' ) )
+ {
+ if ( nChar == ' ' )
+ --nStripUntil; // strip the space, too
+ break;
+ }
+ }
+
+ String sNameBase( _rNameBase.copy( 0, nStripUntil ? nStripUntil + 1 : 0 ) );
+ sNameBase.Append( ' ' );
+ String sInitialName;
+ sal_Int32 nPostfixNumber = 1;
+ do
+ {
+ ( sInitialName = sNameBase ) += String::CreateFromInt32( nPostfixNumber++ );
+ }
+ while ( m_aProhibitedNames.find( sInitialName ) != m_aProhibitedNames.end() );
+
+ m_aName.SetText( sInitialName );
+ OnNameModified( NULL );
+ }
+
+ //--------------------------------------------------------------------
+ IMPL_LINK( NewDataTypeDialog, OnNameModified, void*, /*_pNotInterestedIn*/ )
+ {
+ String sCurrentName = GetName();
+ bool bNameIsOK = ( sCurrentName.Len() > 0 )
+ && ( m_aProhibitedNames.find( sCurrentName ) == m_aProhibitedNames.end() );
+
+ m_aOK.Enable( bNameIsOK );
+
+ return 0L;
+ }
+
+//........................................................................
+} // namespace pcr
+//........................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/propctrlr/newdatatype.hrc b/extensions/source/propctrlr/newdatatype.hrc
new file mode 100644
index 000000000000..91f64128581a
--- /dev/null
+++ b/extensions/source/propctrlr/newdatatype.hrc
@@ -0,0 +1,38 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef EXTENSIONS_SOURCE_PROPCTRLR_NEWDATATYPE_HRC
+#define EXTENSIONS_SOURCE_PROPCTRLR_NEWDATATYPE_HRC
+
+#define FT_LABEL 1
+
+#define ED_NAME 2
+
+#define PB_OK 1
+#define PB_CANCEL 2
+
+#endif
diff --git a/extensions/source/propctrlr/newdatatype.hxx b/extensions/source/propctrlr/newdatatype.hxx
new file mode 100644
index 000000000000..e4fc0aec2549
--- /dev/null
+++ b/extensions/source/propctrlr/newdatatype.hxx
@@ -0,0 +1,77 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef EXTENSIONS_SOURCE_PROPCTRLR_NEWDATATYPE_HXX
+#define EXTENSIONS_SOURCE_PROPCTRLR_NEWDATATYPE_HXX
+
+/** === begin UNO includes === **/
+/** === end UNO includes === **/
+
+#include <vcl/dialog.hxx>
+#include <vcl/fixed.hxx>
+#include <vcl/button.hxx>
+#include <vcl/edit.hxx>
+
+#include <set>
+#include <vector>
+
+//........................................................................
+namespace pcr
+{
+//........................................................................
+
+ //====================================================================
+ //= NewDataTypeDialog
+ //====================================================================
+ class NewDataTypeDialog : public ModalDialog
+ {
+ private:
+ FixedText m_aLabel;
+ Edit m_aName;
+ OKButton m_aOK;
+ CancelButton m_aCancel;
+
+ ::std::set< ::rtl::OUString >
+ m_aProhibitedNames;
+
+ public:
+ NewDataTypeDialog( Window* _pParent, const ::rtl::OUString& _rNameBase, const ::std::vector< ::rtl::OUString >& _rProhibitedNames );
+
+ inline String GetName() const { return m_aName.GetText(); }
+
+ private:
+ DECL_LINK( OnNameModified, void* );
+ };
+
+//........................................................................
+} // namespace pcr
+//........................................................................
+
+#endif // EXTENSIONS_SOURCE_PROPCTRLR_NEWDATATYPE_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/propctrlr/newdatatype.src b/extensions/source/propctrlr/newdatatype.src
new file mode 100644
index 000000000000..6cf39a322074
--- /dev/null
+++ b/extensions/source/propctrlr/newdatatype.src
@@ -0,0 +1,77 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef EXTENSIONS_PROPRESID_HRC
+#include "formresid.hrc"
+#endif
+#ifndef EXTENSIONS_SOURCE_PROPCTRLR_NEWDATATYPE_HRC
+#include "newdatatype.hrc"
+#endif
+
+#define DIALOG_WIDTH 150
+#define DIALOG_HEIGHT 55
+#define BUTTON_WIDTH 50
+#define BUTTON_HEIGHT 14
+
+ModalDialog RID_DLG_NEW_DATA_TYPE
+{
+ OutputSize = TRUE ;
+ Moveable = TRUE ;
+ Closeable = TRUE ;
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( DIALOG_WIDTH, DIALOG_HEIGHT ) ;
+
+ Text [ en-US ] = "New Data Type";
+
+ FixedText FT_LABEL
+ {
+ Pos = MAP_APPFONT( 6, 6 );
+ Size = MAP_APPFONT( DIALOG_WIDTH - 2 * 6, 8 );
+
+ Text [ en-US ] = "Type a name for the new data type:";
+ };
+
+ Edit ED_NAME
+ {
+ Pos = MAP_APPFONT( 6, 17 );
+ Size = MAP_APPFONT( DIALOG_WIDTH - 2 * 6, 12 );
+ Border = TRUE;
+ };
+
+ OKButton PB_OK
+ {
+ Pos = MAP_APPFONT( DIALOG_WIDTH - 6 - BUTTON_WIDTH - 3 - BUTTON_WIDTH, 35 );
+ Size = MAP_APPFONT( BUTTON_WIDTH, BUTTON_HEIGHT );
+ DefButton = TRUE;
+ };
+
+ CancelButton PB_CANCEL
+ {
+ Pos = MAP_APPFONT( DIALOG_WIDTH - 6 - BUTTON_WIDTH, 35 );
+ Size = MAP_APPFONT( BUTTON_WIDTH, BUTTON_HEIGHT );
+ };
+};
diff --git a/extensions/source/propctrlr/objectinspectormodel.cxx b/extensions/source/propctrlr/objectinspectormodel.cxx
new file mode 100644
index 000000000000..6c7a4f99149a
--- /dev/null
+++ b/extensions/source/propctrlr/objectinspectormodel.cxx
@@ -0,0 +1,245 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+#include "modulepcr.hxx"
+#include "pcrcommon.hxx"
+#include "inspectormodelbase.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/ucb/AlreadyInitializedException.hpp>
+#include <com/sun/star/lang/IllegalArgumentException.hpp>
+/** === end UNO includes === **/
+
+#include <cppuhelper/implbase3.hxx>
+
+#include <comphelper/broadcasthelper.hxx>
+#include <comphelper/uno3.hxx>
+
+//........................................................................
+namespace pcr
+{
+//........................................................................
+
+ /** === begin UNO using === **/
+ using ::com::sun::star::inspection::XObjectInspectorModel;
+ using ::com::sun::star::lang::XInitialization;
+ using ::com::sun::star::lang::XServiceInfo;
+ using ::com::sun::star::uno::Reference;
+ using ::com::sun::star::uno::XComponentContext;
+ using ::com::sun::star::uno::RuntimeException;
+ using ::com::sun::star::uno::Sequence;
+ using ::com::sun::star::uno::Any;
+ using ::com::sun::star::inspection::PropertyCategoryDescriptor;
+ using ::com::sun::star::uno::Exception;
+ using ::com::sun::star::uno::XInterface;
+ using ::com::sun::star::lang::IllegalArgumentException;
+ using ::com::sun::star::ucb::AlreadyInitializedException;
+ using ::com::sun::star::beans::XPropertySetInfo;
+ using ::com::sun::star::uno::makeAny;
+ /** === end UNO using === **/
+
+ //====================================================================
+ //= ObjectInspectorModel
+ //====================================================================
+ class ObjectInspectorModel : public ImplInspectorModel
+ {
+ private:
+ Sequence< Any > m_aFactories;
+
+ public:
+ ObjectInspectorModel( const Reference< XComponentContext >& _rxContext );
+
+ // XObjectInspectorModel
+ virtual Sequence< Any > SAL_CALL getHandlerFactories() throw (RuntimeException);
+ virtual Sequence< PropertyCategoryDescriptor > SAL_CALL describeCategories( ) throw (RuntimeException);
+ virtual ::sal_Int32 SAL_CALL getPropertyOrderIndex( const ::rtl::OUString& PropertyName ) throw (RuntimeException);
+
+ // XInitialization
+ virtual void SAL_CALL initialize( const Sequence< Any >& aArguments ) throw (Exception, RuntimeException);
+
+ // XServiceInfo
+ virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw (RuntimeException);
+ virtual Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw (RuntimeException);
+
+ // XServiceInfo - static versions
+ static ::rtl::OUString getImplementationName_static( ) throw(RuntimeException);
+ static Sequence< ::rtl::OUString > getSupportedServiceNames_static( ) throw(RuntimeException);
+ static Reference< XInterface > SAL_CALL
+ Create(const Reference< XComponentContext >&);
+
+ protected:
+ void createDefault();
+ void createWithHandlerFactories( const Sequence< Any >& _rFactories );
+ void createWithHandlerFactoriesAndHelpSection( const Sequence< Any >& _rFactories, sal_Int32 _nMinHelpTextLines, sal_Int32 _nMaxHelpTextLines );
+
+ private:
+ /** checks a given condition to be <TRUE/>, and throws an IllegalArgumentException if not
+ */
+ void impl_verifyArgument_throw( bool _bCondition, sal_Int16 _nArgumentPosition );
+ };
+
+ //====================================================================
+ //= ObjectInspectorModel
+ //====================================================================
+ ObjectInspectorModel::ObjectInspectorModel( const Reference< XComponentContext >& _rxContext )
+ :ImplInspectorModel( _rxContext )
+ {
+ }
+
+ //--------------------------------------------------------------------
+ Sequence< Any > SAL_CALL ObjectInspectorModel::getHandlerFactories() throw (RuntimeException)
+ {
+ return m_aFactories;
+ }
+
+ //--------------------------------------------------------------------
+ Sequence< PropertyCategoryDescriptor > SAL_CALL ObjectInspectorModel::describeCategories( ) throw (RuntimeException)
+ {
+ // no category info provided by this default implementation
+ return Sequence< PropertyCategoryDescriptor >( );
+ }
+
+ //--------------------------------------------------------------------
+ ::sal_Int32 SAL_CALL ObjectInspectorModel::getPropertyOrderIndex( const ::rtl::OUString& /*PropertyName*/ ) throw (RuntimeException)
+ {
+ // no ordering provided by this default implementation
+ return 0;
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL ObjectInspectorModel::initialize( const Sequence< Any >& _arguments ) throw (Exception, RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ if ( m_aFactories.getLength() )
+ throw AlreadyInitializedException();
+
+ StlSyntaxSequence< Any > arguments( _arguments );
+ if ( arguments.empty() )
+ { // constructor: "createDefault()"
+ createDefault();
+ return;
+ }
+
+ Sequence< Any > factories;
+ impl_verifyArgument_throw( arguments[0] >>= factories, 1 );
+
+ if ( arguments.size() == 1 )
+ { // constructor: "createWithHandlerFactories( any[] )"
+ createWithHandlerFactories( factories );
+ return;
+ }
+
+ sal_Int32 nMinHelpTextLines( 0 ), nMaxHelpTextLines( 0 );
+ if ( arguments.size() == 3 )
+ { // constructor: "createWithHandlerFactoriesAndHelpSection( any[], long, long )"
+ impl_verifyArgument_throw( arguments[1] >>= nMinHelpTextLines, 2 );
+ impl_verifyArgument_throw( arguments[2] >>= nMaxHelpTextLines, 3 );
+ createWithHandlerFactoriesAndHelpSection( factories, nMinHelpTextLines, nMaxHelpTextLines );
+ return;
+ }
+
+ impl_verifyArgument_throw( false, 2 );
+ }
+
+ //--------------------------------------------------------------------
+ ::rtl::OUString SAL_CALL ObjectInspectorModel::getImplementationName( ) throw (RuntimeException)
+ {
+ return getImplementationName_static();
+ }
+
+ //--------------------------------------------------------------------
+ Sequence< ::rtl::OUString > SAL_CALL ObjectInspectorModel::getSupportedServiceNames( ) throw (RuntimeException)
+ {
+ return getSupportedServiceNames_static();
+ }
+
+ //--------------------------------------------------------------------
+ ::rtl::OUString ObjectInspectorModel::getImplementationName_static( ) throw(RuntimeException)
+ {
+ return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "org.openoffice.comp.extensions.ObjectInspectorModel" ) );
+ }
+
+ //--------------------------------------------------------------------
+ Sequence< ::rtl::OUString > ObjectInspectorModel::getSupportedServiceNames_static( ) throw(RuntimeException)
+ {
+ ::rtl::OUString sService( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.inspection.ObjectInspectorModel" ) );
+ return Sequence< ::rtl::OUString >( &sService, 1 );
+ }
+
+ //--------------------------------------------------------------------
+ Reference< XInterface > SAL_CALL ObjectInspectorModel::Create(const Reference< XComponentContext >& _rxContext )
+ {
+ return *( new ObjectInspectorModel( _rxContext ) );
+ }
+
+ //--------------------------------------------------------------------
+ void ObjectInspectorModel::createDefault()
+ {
+ m_aFactories.realloc( 1 );
+ m_aFactories[0] <<= ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.inspection.GenericPropertyHandler" ) );
+ }
+
+ //--------------------------------------------------------------------
+ void ObjectInspectorModel::createWithHandlerFactories( const Sequence< Any >& _rFactories )
+ {
+ impl_verifyArgument_throw( _rFactories.getLength() > 0, 1 );
+ m_aFactories = _rFactories;
+ }
+
+ //--------------------------------------------------------------------
+ void ObjectInspectorModel::createWithHandlerFactoriesAndHelpSection( const Sequence< Any >& _rFactories, sal_Int32 _nMinHelpTextLines, sal_Int32 _nMaxHelpTextLines )
+ {
+ impl_verifyArgument_throw( _rFactories.getLength() > 0, 1 );
+ impl_verifyArgument_throw( _nMinHelpTextLines >= 1, 2 );
+ impl_verifyArgument_throw( _nMaxHelpTextLines >= 1, 3 );
+ impl_verifyArgument_throw( _nMinHelpTextLines <= _nMaxHelpTextLines, 2 );
+
+ m_aFactories = _rFactories;
+ enableHelpSectionProperties( _nMinHelpTextLines, _nMaxHelpTextLines );
+ }
+
+ //--------------------------------------------------------------------
+ void ObjectInspectorModel::impl_verifyArgument_throw( bool _bCondition, sal_Int16 _nArgumentPosition )
+ {
+ if ( !_bCondition )
+ throw IllegalArgumentException( ::rtl::OUString(), *this, _nArgumentPosition );
+ }
+
+//........................................................................
+} // namespace pcr
+//........................................................................
+
+//------------------------------------------------------------------------
+extern "C" void SAL_CALL createRegistryInfo_ObjectInspectorModel()
+{
+ ::pcr::OAutoRegistration< ::pcr::ObjectInspectorModel > aObjectInspectorModelRegistration;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/propctrlr/pcr.xml b/extensions/source/propctrlr/pcr.xml
new file mode 100644
index 000000000000..3507a452d056
--- /dev/null
+++ b/extensions/source/propctrlr/pcr.xml
@@ -0,0 +1,146 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE module-description SYSTEM "module-description.dtd">
+<module-description>
+ <module-name>pcr</module-name>
+
+ <component-description>
+ <author>Frank Sch&ouml;nheit</author>
+ <name>org.openoffice.comp.form.ui.OTabOrderDialog</name>
+ <description></description>
+ <loader-name>com.sun.star.loader.SharedLibrary</loader-name>
+ <language>c++</language>
+ <status value="non-published"/>
+ <supported-service>com.sun.star.form.ui.TabOrderDialog</supported-service>
+ </component-description>
+
+ <component-description>
+ <author>Frank Sch&ouml;nheit</author>
+ <name>org.openoffice.comp.form.ControlFontDialog</name>
+ <description></description>
+ <loader-name>com.sun.star.loader.SharedLibrary</loader-name>
+ <language>c++</language>
+ <status value="non-published"/>
+ <supported-service>com.sun.star.form.ui.TabOrderDialog</supported-service>
+ </component-description>
+
+ <component-description>
+ <author>Frank Sch&ouml;nheit</author>
+ <name>com.sun.star.comp.extensions.FormComponentPropertyHandler</name>
+ <description></description>
+ <loader-name>com.sun.star.loader.SharedLibrary</loader-name>
+ <language>c++</language>
+ <status value="non-published"/>
+ <supported-service>com.sun.star.form.inspection.FormComponentPropertyHandler</supported-service>
+ </component-description>
+
+ <component-description>
+ <author>Frank Sch&ouml;nheit</author>
+ <name>com.sun.star.comp.extensions.EFormsPropertyHandler</name>
+ <description></description>
+ <loader-name>com.sun.star.loader.SharedLibrary</loader-name>
+ <language>c++</language>
+ <status value="beta"/>
+ <supported-service>com.sun.star.form.inspection.XMLFormsPropertyHandler</supported-service>
+ </component-description>
+
+ <component-description>
+ <author>Frank Sch&ouml;nheit</author>
+ <name>com.sun.star.comp.extensions.EditPropertyHandler</name>
+ <description></description>
+ <loader-name>com.sun.star.loader.SharedLibrary</loader-name>
+ <language>c++</language>
+ <status value="beta"/>
+ <supported-service>com.sun.star.form.inspection.EditPropertyHandler</supported-service>
+ </component-description>
+
+ <component-description>
+ <author>Frank Sch&ouml;nheit</author>
+ <name>org.openoffice.comp.extensions.ObjectInspector</name>
+ <description></description>
+ <loader-name>com.sun.star.loader.SharedLibrary</loader-name>
+ <language>c++</language>
+ <status value="beta"/>
+ <supported-service>com.sun.star.inspection.ObjectInspector</supported-service>
+ </component-description>
+
+ <component-description>
+ <author>Frank Sch&ouml;nheit</author>
+ <name>org.openoffice.comp.extensions.ObjectInspectorModel</name>
+ <description></description>
+ <loader-name>com.sun.star.loader.SharedLibrary</loader-name>
+ <language>c++</language>
+ <status value="beta"/>
+ <supported-service>com.sun.star.inspection.ObjectInspectorModel</supported-service>
+ </component-description>
+
+ <component-description>
+ <author>Frank Sch&ouml;nheit</author>
+ <name>org.openoffice.comp.extensions.FormController</name>
+ <description></description>
+ <loader-name>com.sun.star.loader.SharedLibrary</loader-name>
+ <language>c++</language>
+ <status value="beta"/>
+ <supported-service>com.sun.star.form.PropertyBrowserController</supported-service>
+ </component-description>
+
+ <component-description>
+ <author>Frank Sch&ouml;nheit</author>
+ <name>com.sun.star.comp.extensions.GenericPropertyHandler</name>
+ <description></description>
+ <loader-name>com.sun.star.loader.SharedLibrary</loader-name>
+ <language>c++</language>
+ <status value="beta"/>
+ <supported-service>com.sun.star.inspection.GenericPropertyHandler</supported-service>
+ </component-description>
+
+ <component-description>
+ <author>Frank Sch&ouml;nheit</author>
+ <name>com.sun.star.comp.extensions.EventHandler</name>
+ <description></description>
+ <loader-name>com.sun.star.loader.SharedLibrary</loader-name>
+ <language>c++</language>
+ <status value="beta"/>
+ <supported-service>com.sun.star.form.inspection.EventHandler</supported-service>
+ </component-description>
+
+ <component-description>
+ <author>Frank Sch&ouml;nheit</author>
+ <name>com.sun.star.comp.extensions.XSDValidationPropertyHandler</name>
+ <description></description>
+ <loader-name>com.sun.star.loader.SharedLibrary</loader-name>
+ <language>c++</language>
+ <status value="beta"/>
+ <supported-service>com.sun.star.form.inspection.XSDValidationPropertyHandler</supported-service>
+ </component-description>
+
+ <component-description>
+ <author>Frank Sch&ouml;nheit</author>
+ <name>com.sun.star.comp.extensions.CellBindingPropertyHandler</name>
+ <description></description>
+ <loader-name>com.sun.star.loader.SharedLibrary</loader-name>
+ <language>c++</language>
+ <status value="beta"/>
+ <supported-service>com.sun.star.form.inspection.CellBindingPropertyHandler</supported-service>
+ </component-description>
+
+ <component-description>
+ <author>Frank Sch&ouml;nheit</author>
+ <name>com.sun.star.comp.extensions.ButtonNavigationHandler</name>
+ <description></description>
+ <loader-name>com.sun.star.loader.SharedLibrary</loader-name>
+ <language>c++</language>
+ <status value="beta"/>
+ <supported-service>com.sun.star.form.inspection.ButtonNavigationHandler</supported-service>
+ </component-description>
+
+ <component-description>
+ <author>Frank Sch&ouml;nheit</author>
+ <name>com.sun.star.comp.extensions.DefaultFormComponentInspectorModel</name>
+ <description></description>
+ <loader-name>com.sun.star.loader.SharedLibrary</loader-name>
+ <language>c++</language>
+ <status value="beta"/>
+ <supported-service>com.sun.star.form.inspection.DefaultFormComponentInspectorModel</supported-service>
+ </component-description>
+
+</module-description>
diff --git a/extensions/source/propctrlr/pcrcommon.cxx b/extensions/source/propctrlr/pcrcommon.cxx
new file mode 100644
index 000000000000..b04ddba264d1
--- /dev/null
+++ b/extensions/source/propctrlr/pcrcommon.cxx
@@ -0,0 +1,71 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+#include "pcrcommon.hxx"
+#include "modulepcr.hxx"
+#include "propresid.hrc"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/util/MeasureUnit.hpp>
+/** === end UNO includes === **/
+#include <rtl/ustrbuf.hxx>
+
+//............................................................................
+namespace pcr
+{
+//............................................................................
+
+ using namespace ::com::sun::star::util;
+
+ //========================================================================
+ //= HelpIdUrl
+ //========================================================================
+ //------------------------------------------------------------------------
+ SmartId HelpIdUrl::getHelpId( const ::rtl::OUString& _rHelpURL )
+ {
+ SmartId aSmartHelpId( _rHelpURL );
+ if ( 0 == _rHelpURL.compareToAscii( RTL_CONSTASCII_STRINGPARAM( "HID:" ) ) )
+ aSmartHelpId = SmartId( _rHelpURL.copy( sizeof( "HID:" ) - 1 ).toInt32() );
+ return aSmartHelpId;
+ }
+
+ //------------------------------------------------------------------------
+ ::rtl::OUString HelpIdUrl::getHelpURL( sal_uInt32 _nHelpId )
+ {
+ ::rtl::OUStringBuffer aBuffer;
+ aBuffer.appendAscii( "HID:" );
+ aBuffer.append( (sal_Int32)_nHelpId );
+ return aBuffer.makeStringAndClear();
+ }
+//............................................................................
+} // namespace pcr
+//............................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/propctrlr/pcrcommon.hxx b/extensions/source/propctrlr/pcrcommon.hxx
new file mode 100644
index 000000000000..f9a0fcda2489
--- /dev/null
+++ b/extensions/source/propctrlr/pcrcommon.hxx
@@ -0,0 +1,155 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _EXTENSIONS_PROPCTRLR_PCRCOMMON_HXX_
+#define _EXTENSIONS_PROPCTRLR_PCRCOMMON_HXX_
+
+#define EDITOR_LIST_APPEND (sal_uInt16)-1
+#define EDITOR_LIST_REPLACE_EXISTING (sal_uInt16)-1
+
+/** === begin UNO includes === **/
+#include <com/sun/star/uno/Sequence.hxx>
+#include <com/sun/star/beans/XPropertyChangeListener.hpp>
+#include <com/sun/star/beans/PropertyChangeEvent.hpp>
+/** === end UNO includes === **/
+
+#include <vcl/smartid.hxx>
+#include <tools/string.hxx>
+#include <toolkit/helper/vclunohelper.hxx>
+#include <comphelper/listenernotification.hxx>
+
+//............................................................................
+namespace pcr
+{
+//............................................................................
+
+ #define OWN_PROPERTY_ID_INTROSPECTEDOBJECT 0x0010
+ #define OWN_PROPERTY_ID_CURRENTPAGE 0x0011
+ #define OWN_PROPERTY_ID_CONTROLCONTEXT 0x0012
+ #define OWN_PROPERTY_ID_TABBINGMODEL 0x0013
+
+ //========================================================================
+ //= types
+ //========================================================================
+ typedef ::comphelper::OSimpleListenerContainer < ::com::sun::star::beans::XPropertyChangeListener
+ , ::com::sun::star::beans::PropertyChangeEvent
+ > PropertyChangeListeners;
+
+ //========================================================================
+ //= helper
+ //========================================================================
+ // small helper to make the "swap" call on an STL container a single-line call, which
+ // in it's canonic form "aFoo.swap( Container() )" doesn't compile with GCC
+ template< class CONTAINER >
+ void clearContainer( CONTAINER& _rContainer )
+ {
+ CONTAINER aEmpty;
+ _rContainer.swap( aEmpty );
+ }
+
+ //========================================================================
+ //= HelpIdUrl
+ //========================================================================
+ /// small helper to translate help ids into help urls
+ class HelpIdUrl
+ {
+ public:
+ static SmartId getHelpId( const ::rtl::OUString& _rHelpURL );
+ static ::rtl::OUString getHelpURL( sal_uInt32 _nHelpId );
+ };
+
+ //====================================================================
+ //= StlSyntaxSequence
+ //====================================================================
+ template< class ELEMENT >
+ class StlSyntaxSequence : public ::com::sun::star::uno::Sequence< ELEMENT >
+ {
+ private:
+ typedef ::com::sun::star::uno::Sequence< ELEMENT > UnoBase;
+
+ public:
+ inline StlSyntaxSequence() : UnoBase() { }
+ inline StlSyntaxSequence( const UnoBase& rSeq ) : UnoBase( rSeq ) { }
+ inline StlSyntaxSequence( const ELEMENT* pElements, sal_Int32 len ) : UnoBase( pElements, len ) { }
+ inline StlSyntaxSequence( sal_Int32 len ) : UnoBase( len ) { }
+
+ operator const UnoBase&() const { return *this; }
+ operator UnoBase&() { return *this; }
+
+ typedef const ELEMENT* const_iterator;
+ typedef ELEMENT* iterator;
+
+ inline const_iterator begin() const { return UnoBase::getConstArray(); }
+ inline const_iterator end() const { return UnoBase::getConstArray() + UnoBase::getLength(); }
+
+ inline iterator begin() { return UnoBase::getArray(); }
+ inline iterator end() { return UnoBase::getArray() + UnoBase::getLength(); }
+
+ inline sal_Int32 size() const { return UnoBase::getLength(); }
+ inline bool empty() const { return UnoBase::getLength() == 0; }
+
+ inline void resize( size_t _newSize ) { UnoBase::realloc( _newSize ); }
+
+ inline iterator erase( iterator _pos )
+ {
+ iterator loop = end();
+ while ( --loop != _pos )
+ *( loop - 1 ) = *loop;
+ resize( size() - 1 );
+ }
+ };
+
+ //========================================================================
+ //= UNO helpers
+ //========================================================================
+#define DECLARE_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 >& xListener ) 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);
+
+#define IMPLEMENT_FORWARD_XCOMPONENT( classname, baseclass ) \
+ void SAL_CALL classname::dispose( ) throw (::com::sun::star::uno::RuntimeException) \
+ { \
+ baseclass::WeakComponentImplHelperBase::dispose(); \
+ } \
+ void SAL_CALL classname::addEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& _Listener ) throw (::com::sun::star::uno::RuntimeException) \
+ { \
+ baseclass::WeakComponentImplHelperBase::addEventListener( _Listener ); \
+ } \
+ void SAL_CALL classname::removeEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& _Listener ) throw (::com::sun::star::uno::RuntimeException) \
+ { \
+ baseclass::WeakComponentImplHelperBase::removeEventListener( _Listener ); \
+ } \
+
+//............................................................................
+} // namespace pcr
+//............................................................................
+
+#endif // _EXTENSIONS_PROPCTRLR_PCRCOMMON_HXX_
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/propctrlr/pcrcommontypes.hxx b/extensions/source/propctrlr/pcrcommontypes.hxx
new file mode 100644
index 000000000000..0c20bf3cad01
--- /dev/null
+++ b/extensions/source/propctrlr/pcrcommontypes.hxx
@@ -0,0 +1,53 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef EXTENSIONS_SOURCE_PROPCTRLR_PCRCOMMONTYPES_HXX
+#define EXTENSIONS_SOURCE_PROPCTRLR_PCRCOMMONTYPES_HXX
+
+/** === begin UNO includes === **/
+#include <com/sun/star/beans/Property.hpp>
+/** === end UNO includes === **/
+#include <rtl/ustring.hxx>
+
+#include <hash_map>
+
+//........................................................................
+namespace pcr
+{
+//........................................................................
+
+ typedef ::std::hash_map< ::rtl::OUString, ::com::sun::star::beans::Property, ::rtl::OUStringHash >
+ PropertyMap;
+
+//........................................................................
+} // namespace pcr
+//........................................................................
+
+#endif // EXTENSIONS_SOURCE_PROPCTRLR_PCRCOMMONTYPES_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/propctrlr/pcrcomponentcontext.cxx b/extensions/source/propctrlr/pcrcomponentcontext.cxx
new file mode 100644
index 000000000000..afd60eff5baa
--- /dev/null
+++ b/extensions/source/propctrlr/pcrcomponentcontext.cxx
@@ -0,0 +1,108 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+#include "pcrcomponentcontext.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/lang/NullPointerException.hpp>
+#include <com/sun/star/lang/ServiceNotRegisteredException.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+/** === end UNO includes === **/
+
+//........................................................................
+namespace pcr
+{
+//........................................................................
+
+ /** === begin UNO using === **/
+ using ::com::sun::star::uno::Reference;
+ using ::com::sun::star::uno::XComponentContext;
+ using ::com::sun::star::lang::NullPointerException;
+ using ::com::sun::star::lang::ServiceNotRegisteredException;
+ using ::com::sun::star::uno::Exception;
+ using ::com::sun::star::uno::Any;
+ using ::com::sun::star::uno::XInterface;
+ using ::com::sun::star::uno::UNO_QUERY_THROW;
+ using ::com::sun::star::lang::XMultiServiceFactory;
+ using ::com::sun::star::beans::XPropertySet;
+ using ::com::sun::star::uno::UNO_QUERY;
+ using ::com::sun::star::uno::RuntimeException;
+ /** === end UNO using === **/
+
+ //====================================================================
+ //= ComponentContext
+ //====================================================================
+ //--------------------------------------------------------------------
+ ComponentContext::ComponentContext( const Reference< XComponentContext >& _rxContext )
+ :m_xContext( _rxContext )
+ {
+ if ( m_xContext.is() )
+ m_xORB = m_xContext->getServiceManager();
+ if ( !m_xORB.is() )
+ throw NullPointerException();
+ }
+
+ //------------------------------------------------------------------------
+ Any ComponentContext::getContextValueByName( const ::rtl::OUString& _rName ) const
+ {
+ Any aReturn;
+ try
+ {
+ aReturn = m_xContext->getValueByName( _rName );
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "PropertyHandler::getContextValueByName: caught an exception!" );
+ }
+ return aReturn;
+ }
+
+ //------------------------------------------------------------------------
+ Reference< XInterface > ComponentContext::createComponent( const ::rtl::OUString& _rServiceName ) const
+ {
+ Reference< XInterface > xComponent(
+ m_xORB->createInstanceWithContext( _rServiceName, m_xContext )
+ );
+ if ( !xComponent.is() )
+ throw ServiceNotRegisteredException( _rServiceName, NULL );
+ return xComponent;
+ }
+
+ //------------------------------------------------------------------------
+ Reference< XMultiServiceFactory > ComponentContext::getLegacyServiceFactory() const
+ {
+ return Reference< XMultiServiceFactory >( m_xORB, UNO_QUERY_THROW );
+ }
+
+//........................................................................
+} // namespace pcr
+//........................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/propctrlr/pcrcomponentcontext.hxx b/extensions/source/propctrlr/pcrcomponentcontext.hxx
new file mode 100644
index 000000000000..bfd52cd32741
--- /dev/null
+++ b/extensions/source/propctrlr/pcrcomponentcontext.hxx
@@ -0,0 +1,170 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef EXTENSIONS_SOURCE_PROPCTRLR_PCROMPONENTCONTEXT_HXX
+#define EXTENSIONS_SOURCE_PROPCTRLR_PCROMPONENTCONTEXT_HXX
+
+/** === begin UNO includes === **/
+#include <com/sun/star/uno/XComponentContext.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+/** === end UNO includes === **/
+
+//........................................................................
+namespace pcr
+{
+//........................................................................
+
+ //====================================================================
+ //= ComponentContext
+ //====================================================================
+ /** a helper class for working with a component context
+ */
+ class ComponentContext
+ {
+ private:
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > m_xContext;
+ ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiComponentFactory > m_xORB;
+
+ public:
+ /** constructs an instance
+ @param _rxContext
+ the component context to manage
+ @throws ::com::sun::star::lang::NullPointerException
+ if the given context, or its component factory, are <NULL/>
+ */
+ ComponentContext( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _rxContext );
+
+ /** returns the ->XComponentContext interface
+ */
+ inline ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >
+ getUNOContext() const { return m_xContext; }
+
+ /** determines whether the context is not <NULL/>
+ */
+ inline sal_Bool is() const
+ {
+ return m_xContext.is();
+ }
+
+ /** creates a component using our component factory/context
+ @throws ::com::sun::star::uno::Exception
+ @return
+ <TRUE/> if and only if the component could be successfully created
+ */
+ template < class INTERFACE >
+ bool createComponent( const ::rtl::OUString& _rServiceName, ::com::sun::star::uno::Reference< INTERFACE >& _out_rxComponent ) const
+ {
+ _out_rxComponent.clear();
+ _out_rxComponent = _out_rxComponent.query(
+ m_xORB->createInstanceWithContext( _rServiceName, m_xContext )
+ );
+ return _out_rxComponent.is();
+ }
+
+ /** creates a component using our component factory/context
+ @throws ::com::sun::star::uno::Exception
+ @return
+ <TRUE/> if and only if the component could be successfully created
+ */
+ template < class INTERFACE >
+ bool createComponent( const sal_Char* _pAsciiServiceName, ::com::sun::star::uno::Reference< INTERFACE >& _out_rxComponent ) const
+ {
+ return createComponent( ::rtl::OUString::createFromAscii( _pAsciiServiceName ), _out_rxComponent );
+ }
+
+ /** creates a component using our component factory/context
+
+ @throws ::com::sun::star::lang::ServiceNotRegisteredException
+ if the given service is not registered
+ @throws Exception
+ if an exception occured during creating the component
+ @return
+ the newly created component. Is never <NULL/>.
+ */
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > createComponent( const ::rtl::OUString& _rServiceName ) const;
+
+ /** creates a component using our component factory/context
+
+ @throws ::com::sun::star::lang::ServiceNotRegisteredException
+ if the given service is not registered
+ @throws Exception
+ if an exception occured during creating the component
+ @return
+ the newly created component. Is never <NULL/>.
+ */
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > createComponent( const sal_Char* _pAsciiServiceName ) const
+ {
+ return createComponent( ::rtl::OUString::createFromAscii( _pAsciiServiceName ) );
+ }
+
+ /** returns the ->XMultiServiceFactory interface of ->m_xORB, for passing to
+ older code which does not yet support ->XMultiComponentFactory
+ @throws ::com::sun::star::uno::RuntimeException
+ if our our component factory does not support this interface
+ */
+ ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >
+ getLegacyServiceFactory() const;
+
+ /** retrieves a value from our component context
+ @param _rName
+ the name of the value to retrieve
+ @return
+ the context value with the given name
+ @seealso XComponentContext::getValueByName
+ @seealso getContextValueByAsciiName
+ */
+ ::com::sun::star::uno::Any
+ getContextValueByName( const ::rtl::OUString& _rName ) const;
+
+ /** retrieves a value from our component context, specified by 8-bit ASCII string
+ @param _rName
+ the name of the value to retrieve, as ASCII character string
+ @return
+ the context value with the given name
+ @seealso XComponentContext::getValueByName
+ @seealso getContextValueByName
+ */
+ inline ::com::sun::star::uno::Any
+ getContextValueByAsciiName( const sal_Char* _pAsciiName ) const
+ {
+ return getContextValueByName( ::rtl::OUString::createFromAscii( _pAsciiName ) );
+ }
+
+ /** retrieve context to create interfaces by the ctors
+ */
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > getContext() const { return m_xContext;}
+
+ };
+
+//........................................................................
+} // namespace pcr
+//........................................................................
+
+#endif // EXTENSIONS_SOURCE_PROPCTRLR_PCROMPONENTCONTEXT_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/propctrlr/pcrmiscres.src b/extensions/source/propctrlr/pcrmiscres.src
new file mode 100644
index 000000000000..f898cf439983
--- /dev/null
+++ b/extensions/source/propctrlr/pcrmiscres.src
@@ -0,0 +1,189 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef EXTENSIONS_PROPRESID_HRC
+#include "formresid.hrc"
+#endif
+#ifndef _EXTENSIONS_PROPCTRLR_FORMLOCALID_HRC_
+#include "formlocalid.hrc"
+#endif
+
+String RID_STR_CONFIRM_DELETE_DATA_TYPE
+{
+ Text [ en-US ] = "Do you want to delete the data type '#type#' from the model?\n"
+ "Please note that this will affect all controls which are bound to this data type.";
+};
+
+Resource RID_RSC_BUTTON_IMAGES
+{
+ Image IMG_PLUS
+ {
+ ImageBitmap = Bitmap{ file = "buttonplus.png"; };
+ };
+ Image IMG_MINUS
+ {
+ ImageBitmap = Bitmap{ file = "buttonminus.png"; };
+ };
+ Image IMG_PLUS_HC
+ {
+ ImageBitmap = Bitmap{ file = "buttonplus_hc.png"; };
+ };
+ Image IMG_MINUS_HC
+ {
+ ImageBitmap = Bitmap{ file = "buttonminus_hc.png"; };
+ };
+};
+
+#define IMAGE_IDS \
+ IdList = \
+ { \
+ RID_SVXIMG_CONTROL; \
+ RID_SVXIMG_BUTTON; \
+ RID_SVXIMG_RADIOBUTTON; \
+ RID_SVXIMG_CHECKBOX; \
+ RID_SVXIMG_FIXEDTEXT; \
+ RID_SVXIMG_GROUPBOX; \
+ RID_SVXIMG_EDIT; \
+ RID_SVXIMG_LISTBOX; \
+ RID_SVXIMG_COMBOBOX; \
+ RID_SVXIMG_URLBUTTON; \
+ RID_SVXIMG_GRID; \
+ RID_SVXIMG_IMAGEBUTTON; \
+ RID_SVXIMG_FILECONTROL; \
+ RID_SVXIMG_DATEFIELD; \
+ RID_SVXIMG_TIMEFIELD; \
+ RID_SVXIMG_NUMERICFIELD; \
+ RID_SVXIMG_CURRENCYFIELD; \
+ RID_SVXIMG_PATTERNFIELD; \
+ RID_SVXIMG_IMAGECONTROL; \
+ RID_SVXIMG_HIDDEN; \
+ RID_SVXIMG_FORMATTEDFIELD; \
+ RID_SVXIMG_FILTER; \
+ RID_SVXIMG_FORMS; \
+ RID_SVXIMG_FORM; \
+ RID_SVXIMG_COLLAPSEDNODE; \
+ RID_SVXIMG_EXPANDEDNODE; \
+ RID_SVXIMG_SCROLLBAR; \
+ RID_SVXIMG_SPINBUTTON; \
+ RID_SVXIMG_NAVIGATIONBAR; \
+ }; \
+ IdCount = 29
+
+ImageList RID_IL_FORMEXPLORER
+{
+ Prefix = "sx";
+ MaskColor = Color { Red = 0xff00 ; Green = 0x0000 ; Blue = 0xff00 ; };
+ IMAGE_IDS;
+};
+
+ImageList RID_IL_FORMEXPLORER_HC
+{
+ Prefix = "sxh";
+ MaskColor = Color { Red = 0xff00 ; Green = 0x0000 ; Blue = 0xff00 ; };
+ IMAGE_IDS;
+};
+
+String RID_STR_PROPTITLE_PUSHBUTTON
+{
+ Text [ en-US ] = "Button" ;
+};
+String RID_STR_PROPTITLE_RADIOBUTTON
+{
+ Text [ en-US ] = "Option Button" ;
+};
+String RID_STR_PROPTITLE_CHECKBOX
+{
+ Text [ en-US ] = "Check Box" ;
+};
+String RID_STR_PROPTITLE_FIXEDTEXT
+{
+ Text [ en-US ] = "Label Field" ;
+};
+String RID_STR_PROPTITLE_GROUPBOX
+{
+ Text [ en-US ] = "Group Box" ;
+};
+String RID_STR_PROPTITLE_EDIT
+{
+ Text [ en-US ] = "Text Box" ;
+};
+String RID_STR_PROPTITLE_FORMATTED
+{
+ Text [ en-US ] = "Formatted Field";
+};
+String RID_STR_PROPTITLE_LISTBOX
+{
+ Text [ en-US ] = "List Box" ;
+};
+String RID_STR_PROPTITLE_COMBOBOX
+{
+ Text [ en-US ] = "Combo Box" ;
+};
+String RID_STR_PROPTITLE_IMAGEBUTTON
+{
+ Text [ en-US ] = "Image Button" ;
+};
+String RID_STR_PROPTITLE_HIDDENCONTROL
+{
+ Text [ en-US ] = "Hidden Control" ;
+};
+String RID_STR_PROPTITLE_UNKNOWNCONTROL
+{
+ Text [ en-US ] = "Control (unknown type)" ;
+};
+String RID_STR_PROPTITLE_IMAGECONTROL
+{
+ Text [ en-US ] = "Image Control" ;
+};
+String RID_STR_PROPTITLE_FILECONTROL
+{
+ Text [ en-US ] = "File Selection" ;
+};
+String RID_STR_PROPTITLE_DATEFIELD
+{
+ Text [ en-US ] = "Date Field" ;
+};
+String RID_STR_PROPTITLE_TIMEFIELD
+{
+ Text [ en-US ] = "Time Field" ;
+};
+String RID_STR_PROPTITLE_NUMERICFIELD
+{
+ Text [ en-US ] = "Numeric Field" ;
+};
+String RID_STR_PROPTITLE_CURRENCYFIELD
+{
+ Text [ en-US ] = "Currency Field" ;
+};
+String RID_STR_PROPTITLE_PATTERNFIELD
+{
+ Text [ en-US ] = "Pattern Field" ;
+};
+String RID_STR_PROPTITLE_DBGRID
+{
+ Text [ en-US ] = "Table Control " ;
+};
diff --git a/extensions/source/propctrlr/pcrservices.cxx b/extensions/source/propctrlr/pcrservices.cxx
new file mode 100644
index 000000000000..da6bbef37276
--- /dev/null
+++ b/extensions/source/propctrlr/pcrservices.cxx
@@ -0,0 +1,145 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+
+#include "modulepcr.hxx"
+
+//---------------------------------------------------------------------------------------
+
+using namespace ::rtl;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::registry;
+
+//---------------------------------------------------------------------------------------
+
+extern "C" void SAL_CALL createRegistryInfo_OPropertyBrowserController();
+extern "C" void SAL_CALL createRegistryInfo_FormController();
+extern "C" void SAL_CALL createRegistryInfo_DefaultFormComponentInspectorModel();
+extern "C" void SAL_CALL createRegistryInfo_DefaultHelpProvider();
+extern "C" void SAL_CALL createRegistryInfo_OControlFontDialog();
+extern "C" void SAL_CALL createRegistryInfo_OTabOrderDialog();
+extern "C" void SAL_CALL createRegistryInfo_CellBindingPropertyHandler();
+extern "C" void SAL_CALL createRegistryInfo_ButtonNavigationHandler();
+extern "C" void SAL_CALL createRegistryInfo_EditPropertyHandler();
+extern "C" void SAL_CALL createRegistryInfo_FormComponentPropertyHandler();
+extern "C" void SAL_CALL createRegistryInfo_EFormsPropertyHandler();
+extern "C" void SAL_CALL createRegistryInfo_XSDValidationPropertyHandler();
+extern "C" void SAL_CALL createRegistryInfo_EventHandler();
+extern "C" void SAL_CALL createRegistryInfo_GenericPropertyHandler();
+extern "C" void SAL_CALL createRegistryInfo_ObjectInspectorModel();
+extern "C" void SAL_CALL createRegistryInfo_SubmissionPropertyHandler();
+extern "C" void SAL_CALL createRegistryInfo_StringRepresentation();
+extern "C" void SAL_CALL createRegistryInfo_MasterDetailLinkDialog();
+extern "C" void SAL_CALL createRegistryInfo_FormGeometryHandler();
+
+//---------------------------------------------------------------------------------------
+
+extern "C" void SAL_CALL pcr_initializeModule()
+{
+ static sal_Bool s_bInit = sal_False;
+ if (!s_bInit)
+ {
+ createRegistryInfo_OPropertyBrowserController();
+ createRegistryInfo_FormController();
+ createRegistryInfo_DefaultFormComponentInspectorModel();
+ createRegistryInfo_DefaultHelpProvider();
+ createRegistryInfo_OControlFontDialog();
+ createRegistryInfo_OTabOrderDialog();
+ createRegistryInfo_CellBindingPropertyHandler();
+ createRegistryInfo_ButtonNavigationHandler();
+ createRegistryInfo_EditPropertyHandler();
+ createRegistryInfo_FormComponentPropertyHandler();
+ createRegistryInfo_EFormsPropertyHandler();
+ createRegistryInfo_XSDValidationPropertyHandler();
+ createRegistryInfo_EventHandler();
+ createRegistryInfo_GenericPropertyHandler();
+ createRegistryInfo_ObjectInspectorModel();
+ createRegistryInfo_SubmissionPropertyHandler();
+ createRegistryInfo_StringRepresentation();
+ createRegistryInfo_MasterDetailLinkDialog();
+ createRegistryInfo_FormGeometryHandler();
+ s_bInit = sal_True;
+ }
+}
+
+//---------------------------------------------------------------------------------------
+
+extern "C" SAL_DLLPUBLIC_EXPORT void SAL_CALL
+component_getImplementationEnvironment(
+ const sal_Char **ppEnvTypeName,
+ uno_Environment ** /*ppEnv*/
+ )
+{
+ pcr_initializeModule();
+ *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
+}
+
+//---------------------------------------------------------------------------------------
+extern "C" SAL_DLLPUBLIC_EXPORT sal_Bool SAL_CALL component_writeInfo(
+ void* pServiceManager,
+ void* pRegistryKey
+ )
+{
+ if (pRegistryKey)
+ try
+ {
+ return ::pcr::PcrModule::getInstance().writeComponentInfos(
+ static_cast<XMultiServiceFactory*>(pServiceManager),
+ static_cast<XRegistryKey*>(pRegistryKey));
+ }
+ catch (InvalidRegistryException& )
+ {
+ OSL_ASSERT("pcr::component_writeInfo: could not create a registry key (InvalidRegistryException) !");
+ }
+
+ return sal_False;
+}
+
+//---------------------------------------------------------------------------------------
+extern "C" SAL_DLLPUBLIC_EXPORT void* SAL_CALL component_getFactory(
+ const sal_Char* pImplementationName,
+ void* pServiceManager,
+ void* /*pRegistryKey*/)
+{
+ Reference< XInterface > xRet;
+ if (pServiceManager && pImplementationName)
+ {
+ xRet = ::pcr::PcrModule::getInstance().getComponentFactory(
+ ::rtl::OUString::createFromAscii(pImplementationName),
+ static_cast< XMultiServiceFactory* >(pServiceManager));
+ }
+
+ if (xRet.is())
+ xRet->acquire();
+ return xRet.get();
+};
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/propctrlr/pcrstrings.cxx b/extensions/source/propctrlr/pcrstrings.cxx
new file mode 100644
index 000000000000..378312fca422
--- /dev/null
+++ b/extensions/source/propctrlr/pcrstrings.cxx
@@ -0,0 +1,38 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+
+#ifndef _EXTENSIONS_FORMSCTRLR_PCRSTRINGS_HXX_
+#define PCR_IMPLEMENT_STRINGS
+#include "pcrstrings.hxx"
+#undef PCR_IMPLEMENT_STRINGS
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/propctrlr/pcrstrings.hxx b/extensions/source/propctrlr/pcrstrings.hxx
new file mode 100644
index 000000000000..413b1c6a6ffd
--- /dev/null
+++ b/extensions/source/propctrlr/pcrstrings.hxx
@@ -0,0 +1,48 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _EXTENSIONS_FORMSCTRLR_PCRSTRINGS_HXX_
+#define _EXTENSIONS_FORMSCTRLR_PCRSTRINGS_HXX_
+
+#include "stringdefine.hxx"
+
+//............................................................................
+namespace pcr
+{
+//............................................................................
+
+ // properties
+ PCR_CONSTASCII_STRING( PROPERTY_TABBINGMODEL, "TabbingModel" );
+
+//............................................................................
+} // namespace pcr
+//............................................................................
+
+#endif // _EXTENSIONS_FORMSCTRLR_PCRSTRINGS_HXX_
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/propctrlr/pcrunodialogs.cxx b/extensions/source/propctrlr/pcrunodialogs.cxx
new file mode 100644
index 000000000000..0a7b4acf1c82
--- /dev/null
+++ b/extensions/source/propctrlr/pcrunodialogs.cxx
@@ -0,0 +1,148 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+#include "pcrunodialogs.hxx"
+#include "formstrings.hxx"
+#include "pcrstrings.hxx"
+#include "taborder.hxx"
+#include "pcrcommon.hxx"
+
+extern "C" void SAL_CALL createRegistryInfo_OTabOrderDialog()
+{
+ ::pcr::OAutoRegistration< ::pcr::OTabOrderDialog > aAutoRegistration;
+}
+
+//........................................................................
+namespace pcr
+{
+//........................................................................
+
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::lang;
+ using namespace ::com::sun::star::beans;
+
+ //====================================================================
+ //= OTabOrderDialog
+ //====================================================================
+ //---------------------------------------------------------------------
+ OTabOrderDialog::OTabOrderDialog( const Reference< XComponentContext >& _rxContext )
+ :OGenericUnoDialog( _rxContext )
+ {
+ registerProperty( PROPERTY_CONTROLCONTEXT, OWN_PROPERTY_ID_CONTROLCONTEXT,
+ PropertyAttribute::BOUND | PropertyAttribute::TRANSIENT,
+ &m_xControlContext, ::getCppuType( &m_xControlContext ) );
+
+ registerProperty( PROPERTY_TABBINGMODEL, OWN_PROPERTY_ID_TABBINGMODEL,
+ PropertyAttribute::BOUND | PropertyAttribute::TRANSIENT,
+ &m_xTabbingModel, ::getCppuType( &m_xTabbingModel ) );
+ }
+
+ //---------------------------------------------------------------------
+ OTabOrderDialog::~OTabOrderDialog()
+ {
+ if ( m_pDialog )
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ if ( m_pDialog )
+ destroyDialog();
+ }
+ }
+
+ //---------------------------------------------------------------------
+ Sequence<sal_Int8> SAL_CALL OTabOrderDialog::getImplementationId( ) throw(RuntimeException)
+ {
+ static ::cppu::OImplementationId aId;
+ return aId.getImplementationId();
+ }
+
+ //---------------------------------------------------------------------
+ Reference< XInterface > SAL_CALL OTabOrderDialog::Create( const Reference< XComponentContext >& _rxContext )
+ {
+ return *( new OTabOrderDialog( _rxContext ) );
+ }
+
+ //---------------------------------------------------------------------
+ ::rtl::OUString SAL_CALL OTabOrderDialog::getImplementationName() throw(RuntimeException)
+ {
+ return getImplementationName_static();
+ }
+
+ //---------------------------------------------------------------------
+ ::rtl::OUString OTabOrderDialog::getImplementationName_static() throw(RuntimeException)
+ {
+ return ::rtl::OUString::createFromAscii( "org.openoffice.comp.form.ui.OTabOrderDialog" );
+ }
+
+ //---------------------------------------------------------------------
+ ::comphelper::StringSequence SAL_CALL OTabOrderDialog::getSupportedServiceNames() throw(RuntimeException)
+ {
+ return getSupportedServiceNames_static();
+ }
+
+ //---------------------------------------------------------------------
+ ::comphelper::StringSequence OTabOrderDialog::getSupportedServiceNames_static() throw(RuntimeException)
+ {
+ ::comphelper::StringSequence aSupported(1);
+ aSupported.getArray()[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.form.ui.TabOrderDialog" ) );
+ return aSupported;
+ }
+
+ //---------------------------------------------------------------------
+ Reference<XPropertySetInfo> SAL_CALL OTabOrderDialog::getPropertySetInfo() throw(RuntimeException)
+ {
+ Reference<XPropertySetInfo> xInfo( createPropertySetInfo( getInfoHelper() ) );
+ return xInfo;
+ }
+
+ //---------------------------------------------------------------------
+ ::cppu::IPropertyArrayHelper& OTabOrderDialog::getInfoHelper()
+ {
+ return *const_cast< OTabOrderDialog* >( this )->getArrayHelper();
+ }
+
+ //--------------------------------------------------------------------------
+ ::cppu::IPropertyArrayHelper* OTabOrderDialog::createArrayHelper( ) const
+ {
+ Sequence< Property > aProps;
+ describeProperties( aProps );
+ return new ::cppu::OPropertyArrayHelper( aProps );
+ }
+
+ //--------------------------------------------------------------------------
+ Dialog* OTabOrderDialog::createDialog( Window* _pParent )
+ {
+ return new TabOrderDialog( _pParent, m_xTabbingModel, m_xControlContext, m_aContext.getLegacyServiceFactory() );
+ }
+
+//........................................................................
+} // namespace pcr
+//........................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/propctrlr/pcrunodialogs.hxx b/extensions/source/propctrlr/pcrunodialogs.hxx
new file mode 100644
index 000000000000..5175cfe62eec
--- /dev/null
+++ b/extensions/source/propctrlr/pcrunodialogs.hxx
@@ -0,0 +1,96 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef EXTENSIONS_SOURCE_PROPCTRLR_PCRUNODIALOGS_HXX
+#define EXTENSIONS_SOURCE_PROPCTRLR_PCRUNODIALOGS_HXX
+
+#include <svtools/genericunodialog.hxx>
+#include "modulepcr.hxx"
+#include <com/sun/star/awt/XTabControllerModel.hpp>
+#include <com/sun/star/awt/XControlContainer.hpp>
+
+//........................................................................
+namespace pcr
+{
+//........................................................................
+
+ //====================================================================
+ //= OTabOrderDialog
+ //====================================================================
+ class OTabOrderDialog;
+ typedef ::svt::OGenericUnoDialog OTabOrderDialog_DBase;
+ typedef ::comphelper::OPropertyArrayUsageHelper< OTabOrderDialog > OTabOrderDialog_PBase;
+
+ class OTabOrderDialog
+ :public OTabOrderDialog_DBase
+ ,public OTabOrderDialog_PBase
+ ,public PcrClient
+ {
+ protected:
+ // <properties>
+ ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTabControllerModel >
+ m_xTabbingModel;
+ ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlContainer >
+ m_xControlContext;
+ // </properties>
+
+ public:
+ OTabOrderDialog( const com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext >& _rxContext );
+ ~OTabOrderDialog();
+
+ // XTypeProvider
+ virtual ::com::sun::star::uno::Sequence<sal_Int8> SAL_CALL getImplementationId( ) throw(::com::sun::star::uno::RuntimeException);
+
+ // XServiceInfo
+ virtual ::rtl::OUString SAL_CALL getImplementationName() throw(::com::sun::star::uno::RuntimeException);
+ virtual ::comphelper::StringSequence SAL_CALL getSupportedServiceNames() throw(::com::sun::star::uno::RuntimeException);
+
+ // XServiceInfo - static methods
+ static ::com::sun::star::uno::Sequence< ::rtl::OUString > getSupportedServiceNames_static(void) throw( ::com::sun::star::uno::RuntimeException );
+ static ::rtl::OUString getImplementationName_static(void) throw( ::com::sun::star::uno::RuntimeException );
+ static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >
+ SAL_CALL Create(const ::com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext >&);
+
+ // XPropertySet
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo> SAL_CALL getPropertySetInfo() throw(::com::sun::star::uno::RuntimeException);
+ virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper();
+
+ // OPropertyArrayUsageHelper
+ virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const;
+
+ protected:
+ // OGenericUnoDialog overridables
+ virtual Dialog* createDialog(Window* _pParent);
+ };
+
+//........................................................................
+} // namespacepcr
+//........................................................................
+
+#endif // EXTENSIONS_SOURCE_PROPCTRLR_PCRUNODIALOGS_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/propctrlr/propcontroller.cxx b/extensions/source/propctrlr/propcontroller.cxx
new file mode 100644
index 000000000000..8fd253a8ff6a
--- /dev/null
+++ b/extensions/source/propctrlr/propcontroller.cxx
@@ -0,0 +1,1773 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+#include "propcontroller.hxx"
+#include "pcrstrings.hxx"
+#include "standardcontrol.hxx"
+#include "linedescriptor.hxx"
+#include "propresid.hrc"
+#include "formresid.hrc"
+#include "propertyeditor.hxx"
+#include "modulepcr.hxx"
+#include "formstrings.hxx"
+#include "formmetadata.hxx"
+#include "formbrowsertools.hxx"
+#include "propertycomposer.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/awt/XWindow.hpp>
+#include <com/sun/star/util/XCloseable.hpp>
+#include <com/sun/star/inspection/PropertyControlType.hpp>
+#include <com/sun/star/ucb/AlreadyInitializedException.hpp>
+/** === end UNO includes === **/
+#include <tools/debug.hxx>
+#include <tools/diagnose_ex.h>
+#include <comphelper/types.hxx>
+#include <comphelper/extract.hxx>
+#include <toolkit/awt/vclxwindow.hxx>
+#include <toolkit/unohlp.hxx>
+#include <comphelper/property.hxx>
+#include <vcl/msgbox.hxx>
+#include <vcl/svapp.hxx>
+#include <osl/mutex.hxx>
+#include <cppuhelper/component_context.hxx>
+#include <cppuhelper/exc_hlp.hxx>
+
+#include <algorithm>
+#include <functional>
+#include <sal/macros.h>
+
+//------------------------------------------------------------------------
+// !!! outside the namespace !!!
+extern "C" void SAL_CALL createRegistryInfo_OPropertyBrowserController()
+{
+ ::pcr::OAutoRegistration< ::pcr::OPropertyBrowserController > aAutoRegistration;
+}
+
+//............................................................................
+namespace pcr
+{
+//............................................................................
+
+ using namespace ::com::sun::star;
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::awt;
+ using namespace ::com::sun::star::form;
+ using namespace ::com::sun::star::beans;
+ using namespace ::com::sun::star::script;
+ using namespace ::com::sun::star::lang;
+ using namespace ::com::sun::star::container;
+ using namespace ::com::sun::star::frame;
+ using namespace ::com::sun::star::util;
+ using namespace ::com::sun::star::inspection;
+ using namespace ::com::sun::star::ucb;
+ using namespace ::comphelper;
+
+#define THISREF() static_cast< XController* >(this)
+
+ //========================================================================
+ //= OPropertyBrowserController
+ //========================================================================
+ DBG_NAME(OPropertyBrowserController)
+ //------------------------------------------------------------------------
+ OPropertyBrowserController::OPropertyBrowserController( const Reference< XComponentContext >& _rxContext )
+ :m_aContext(_rxContext)
+ ,m_aDisposeListeners( m_aMutex )
+ ,m_aControlObservers( m_aMutex )
+ ,m_pView(NULL)
+ ,m_bContainerFocusListening( false )
+ ,m_bSuspendingPropertyHandlers( false )
+ ,m_bConstructed( false )
+ ,m_bBindingIntrospectee( false )
+ {
+ DBG_CTOR(OPropertyBrowserController,NULL);
+ }
+
+ //------------------------------------------------------------------------
+ OPropertyBrowserController::~OPropertyBrowserController()
+ {
+ // stop listening for property changes
+ acquire();
+ stopInspection( true );
+ DBG_DTOR(OPropertyBrowserController,NULL);
+ }
+
+ //------------------------------------------------------------------------
+ IMPLEMENT_FORWARD_REFCOUNT( OPropertyBrowserController, OPropertyBrowserController_Base )
+
+ //------------------------------------------------------------------------
+ Any SAL_CALL OPropertyBrowserController::queryInterface( const Type& _rType ) throw (RuntimeException)
+ {
+ Any aReturn = OPropertyBrowserController_Base::queryInterface( _rType );
+ if ( !aReturn.hasValue() )
+ aReturn = ::cppu::queryInterface(
+ _rType,
+ static_cast< XObjectInspectorUI* >( this )
+ );
+ return aReturn;
+ }
+
+ //------------------------------------------------------------------------
+ void OPropertyBrowserController::startContainerWindowListening()
+ {
+ if (m_bContainerFocusListening)
+ return;
+
+ if (m_xFrame.is())
+ {
+ Reference< XWindow > xContainerWindow = m_xFrame->getContainerWindow();
+ if (xContainerWindow.is())
+ {
+ xContainerWindow->addFocusListener(this);
+ m_bContainerFocusListening = sal_True;
+ }
+ }
+
+ DBG_ASSERT(m_bContainerFocusListening, "OPropertyBrowserController::startContainerWindowListening: unable to start listening (inconsistence)!");
+ }
+
+ //------------------------------------------------------------------------
+ void OPropertyBrowserController::stopContainerWindowListening()
+ {
+ if (!m_bContainerFocusListening)
+ return;
+
+ if (m_xFrame.is())
+ {
+ Reference< XWindow > xContainerWindow = m_xFrame->getContainerWindow();
+ if (xContainerWindow.is())
+ {
+ xContainerWindow->removeFocusListener(this);
+ m_bContainerFocusListening = sal_False;
+ }
+ }
+
+ DBG_ASSERT(!m_bContainerFocusListening, "OPropertyBrowserController::stopContainerWindowListening: unable to stop listening (inconsistence)!");
+ }
+
+ //--------------------------------------------------------------------
+ Reference< XObjectInspectorModel > SAL_CALL OPropertyBrowserController::getInspectorModel() throw (RuntimeException)
+ {
+ return m_xModel;
+ }
+
+ //--------------------------------------------------------------------
+ void OPropertyBrowserController::impl_initializeView_nothrow()
+ {
+ OSL_PRECOND( haveView(), "OPropertyBrowserController::impl_initializeView_nothrow: not to be called when we have no view!" );
+ if ( !haveView() )
+ return;
+
+ if ( !m_xModel.is() )
+ // allowed
+ return;
+
+ try
+ {
+ getPropertyBox().EnableHelpSection( m_xModel->getHasHelpSection() );
+ getPropertyBox().SetHelpLineLimites( m_xModel->getMinHelpTextLines(), m_xModel->getMaxHelpTextLines() );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+
+ //--------------------------------------------------------------------
+ void OPropertyBrowserController::impl_updateReadOnlyView_nothrow()
+ {
+ // this is a huge cudgel, admitted.
+ // The problem is that in case we were previously read-only, all our controls
+ // were created read-only, too. We cannot simply switch them to not-read-only.
+ // Even if they had an API for this, we do not know whether they were
+ // originally created read-only, or if they are read-only just because
+ // the model was.
+ impl_rebindToInspectee_nothrow( m_aInspectedObjects );
+ }
+
+ //--------------------------------------------------------------------
+ bool OPropertyBrowserController::impl_isReadOnlyModel_throw() const
+ {
+ if ( !m_xModel.is() )
+ return false;
+
+ return m_xModel->getIsReadOnly();
+ }
+
+ //--------------------------------------------------------------------
+ void OPropertyBrowserController::impl_startOrStopModelListening_nothrow( bool _bDoListen ) const
+ {
+ try
+ {
+ Reference< XPropertySet > xModelProperties( m_xModel, UNO_QUERY );
+ if ( !xModelProperties.is() )
+ // okay, so the model doesn't want to change its properties
+ // dynamically - fine with us
+ return;
+
+ void (SAL_CALL XPropertySet::*pListenerOperation)( const ::rtl::OUString&, const Reference< XPropertyChangeListener >& )
+ = _bDoListen ? &XPropertySet::addPropertyChangeListener : &XPropertySet::removePropertyChangeListener;
+
+ (xModelProperties.get()->*pListenerOperation)(
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IsReadOnly" ) ),
+ const_cast< OPropertyBrowserController* >( this )
+ );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+
+ //--------------------------------------------------------------------
+ void OPropertyBrowserController::impl_bindToNewModel_nothrow( const Reference< XObjectInspectorModel >& _rxInspectorModel )
+ {
+ impl_startOrStopModelListening_nothrow( false );
+ m_xModel = _rxInspectorModel;
+ impl_startOrStopModelListening_nothrow( true );
+
+ // initialize the view, if we already have one
+ if ( haveView() )
+ impl_initializeView_nothrow();
+
+ // inspect again, if we already have inspectees
+ if ( !m_aInspectedObjects.empty() )
+ impl_rebindToInspectee_nothrow( m_aInspectedObjects );
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL OPropertyBrowserController::setInspectorModel( const Reference< XObjectInspectorModel >& _inspectorModel ) throw (RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ if ( m_xModel == _inspectorModel )
+ return;
+
+ impl_bindToNewModel_nothrow( _inspectorModel );
+ }
+
+ //--------------------------------------------------------------------
+ Reference< XObjectInspectorUI > SAL_CALL OPropertyBrowserController::getInspectorUI() throw (RuntimeException)
+ {
+ // we're derived from this interface, though we do not expose it in queryInterface and getTypes.
+ return this;
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL OPropertyBrowserController::inspect( const Sequence< Reference< XInterface > >& _rObjects ) throw (com::sun::star::util::VetoException, RuntimeException)
+ {
+ SolarMutexGuard aSolarGuard;
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ if ( m_bSuspendingPropertyHandlers || !suspendAll_nothrow() )
+ { // we already are trying to suspend the component (this is somewhere up the stack)
+ // OR one of our property handlers raised a veto against closing. Well, we *need* to close
+ // it in order to inspect another object.
+ throw VetoException();
+ }
+ if ( m_bBindingIntrospectee )
+ throw VetoException();
+
+ m_bBindingIntrospectee = true;
+ impl_rebindToInspectee_nothrow( InterfaceArray( _rObjects.getConstArray(), _rObjects.getConstArray() + _rObjects.getLength() ) );
+ m_bBindingIntrospectee = false;
+
+ }
+
+ //--------------------------------------------------------------------
+ Reference< XDispatch > SAL_CALL OPropertyBrowserController::queryDispatch( const URL& /*URL*/, const ::rtl::OUString& /*TargetFrameName*/, ::sal_Int32 /*SearchFlags*/ ) throw (RuntimeException)
+ {
+ // we don't have any dispatches at all, right now
+ return Reference< XDispatch >();
+ }
+
+ //--------------------------------------------------------------------
+ Sequence< Reference< XDispatch > > SAL_CALL OPropertyBrowserController::queryDispatches( const Sequence< DispatchDescriptor >& Requests ) throw (RuntimeException)
+ {
+ Sequence< Reference< XDispatch > > aReturn;
+ sal_Int32 nLen = Requests.getLength();
+ aReturn.realloc( nLen );
+
+ Reference< XDispatch >* pReturn = aReturn.getArray();
+ const Reference< XDispatch >* pReturnEnd = aReturn.getArray() + nLen;
+ const DispatchDescriptor* pDescripts = Requests.getConstArray();
+
+ for ( ; pReturn != pReturnEnd; ++ pReturn, ++pDescripts )
+ *pReturn = queryDispatch( pDescripts->FeatureURL, pDescripts->FrameName, pDescripts->SearchFlags );
+
+ return aReturn;
+ }
+
+ //------------------------------------------------------------------------
+ void SAL_CALL OPropertyBrowserController::initialize( const Sequence< Any >& _arguments ) throw (Exception, RuntimeException)
+ {
+ if ( m_bConstructed )
+ throw AlreadyInitializedException();
+
+ StlSyntaxSequence< Any > arguments( _arguments );
+ if ( arguments.empty() )
+ { // constructor: "createDefault()"
+ createDefault();
+ return;
+ }
+
+ Reference< XObjectInspectorModel > xModel;
+ if ( arguments.size() == 1 )
+ { // constructor: "createWithModel( XObjectInspectorModel )"
+ if ( !( arguments[0] >>= xModel ) )
+ throw IllegalArgumentException( ::rtl::OUString(), *this, 0 );
+ createWithModel( xModel );
+ return;
+ }
+
+ throw IllegalArgumentException( ::rtl::OUString(), *this, 0 );
+ }
+
+ //------------------------------------------------------------------------
+ void OPropertyBrowserController::createDefault()
+ {
+ m_bConstructed = true;
+ }
+
+ //------------------------------------------------------------------------
+ void OPropertyBrowserController::createWithModel( const Reference< XObjectInspectorModel >& _rxModel )
+ {
+ osl_incrementInterlockedCount( &m_refCount );
+ {
+ setInspectorModel( _rxModel );
+ }
+ osl_decrementInterlockedCount( &m_refCount );
+
+ m_bConstructed = true;
+ }
+
+ //------------------------------------------------------------------------
+ void SAL_CALL OPropertyBrowserController::attachFrame( const Reference< XFrame >& _rxFrame ) throw(RuntimeException)
+ {
+ SolarMutexGuard aSolarGuard;
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ if (_rxFrame.is() && haveView())
+ throw RuntimeException(::rtl::OUString::createFromAscii("Unable to attach to a second frame."),*this);
+
+ // revoke as focus listener from the old container window
+ stopContainerWindowListening();
+
+ m_xFrame = _rxFrame;
+ if (!m_xFrame.is())
+ return;
+
+ // TODO: this construction perhaps should be done outside. Don't know the exact meaning of attachFrame.
+ // Maybe it is intended to only announce the frame to the controller, and the instance doing this
+ // announcement is responsible for calling setComponent, too.
+ Reference< XWindow > xContainerWindow = m_xFrame->getContainerWindow();
+ VCLXWindow* pContainerWindow = VCLXWindow::GetImplementation(xContainerWindow);
+ Window* pParentWin = pContainerWindow ? pContainerWindow->GetWindow() : NULL;
+ if (!pParentWin)
+ throw RuntimeException(::rtl::OUString::createFromAscii("The frame is invalid. Unable to extract the container window."),*this);
+
+ if ( Construct( pParentWin ) )
+ {
+ try
+ {
+ m_xFrame->setComponent( VCLUnoHelper::GetInterface( m_pView ), this );
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "OPropertyBrowserController::attachFrame: caught an exception!" );
+ }
+ }
+
+ startContainerWindowListening();
+
+ UpdateUI();
+ }
+
+ //------------------------------------------------------------------------
+ sal_Bool SAL_CALL OPropertyBrowserController::attachModel( const Reference< XModel >& _rxModel ) throw(RuntimeException)
+ {
+ Reference< XObjectInspectorModel > xModel( _rxModel, UNO_QUERY );
+ if ( !xModel.is() )
+ return false;
+
+ setInspectorModel( xModel );
+ return getInspectorModel() == _rxModel;
+ }
+
+ //------------------------------------------------------------------------
+ sal_Bool OPropertyBrowserController::suspendAll_nothrow()
+ {
+ // if there is a handle inside its "onInteractivePropertySelection" method,
+ // then veto
+ // Normally, we could expect every handler to do this itself, but being
+ // realistic, it's safer to handle this here in general.
+ if ( m_xInteractiveHandler.is() )
+ return sal_False;
+
+ m_bSuspendingPropertyHandlers = true;
+ sal_Bool bHandlerVeto = !suspendPropertyHandlers_nothrow( sal_True );
+ m_bSuspendingPropertyHandlers = false;
+ if ( bHandlerVeto )
+ return sal_False;
+
+ return sal_True;
+ }
+
+ //------------------------------------------------------------------------
+ sal_Bool OPropertyBrowserController::suspendPropertyHandlers_nothrow( sal_Bool _bSuspend )
+ {
+ PropertyHandlerArray aAllHandlers; // will contain every handler exactly once
+ for ( PropertyHandlerRepository::const_iterator handler = m_aPropertyHandlers.begin();
+ handler != m_aPropertyHandlers.end();
+ ++handler
+ )
+ {
+ if ( ::std::find( aAllHandlers.begin(), aAllHandlers.end(), handler->second ) != aAllHandlers.end() )
+ // already visited this particular handler (m_aPropertyHandlers usually contains
+ // the same handler more than once)
+ continue;
+ aAllHandlers.push_back( handler->second );
+ }
+
+ for ( PropertyHandlerArray::iterator loop = aAllHandlers.begin();
+ loop != aAllHandlers.end();
+ ++loop
+ )
+ {
+ try
+ {
+ if ( !(*loop)->suspend( _bSuspend ) )
+ if ( _bSuspend )
+ // if we're not suspending, but reactivating, ignore the error
+ return sal_False;
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "OPropertyBrowserController::suspendPropertyHandlers_nothrow: caught an exception!" );
+ }
+ }
+ return sal_True;
+ }
+
+ //------------------------------------------------------------------------
+ sal_Bool SAL_CALL OPropertyBrowserController::suspend( sal_Bool _bSuspend ) throw(RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ OSL_ENSURE( haveView(), "OPropertyBrowserController::suspend: don't have a view anymore!" );
+
+ if ( !_bSuspend )
+ { // this means a "suspend" is to be "revoked"
+ suspendPropertyHandlers_nothrow( sal_False );
+ // we ourself cannot revoke our suspend
+ return sal_False;
+ }
+
+ if ( !suspendAll_nothrow() )
+ return sal_False;
+
+ // commit the editor's content
+ if ( haveView() )
+ getPropertyBox().CommitModified();
+
+ // stop listening
+ stopContainerWindowListening();
+
+ // outtahere
+ return sal_True;
+ }
+
+ //------------------------------------------------------------------------
+ Any SAL_CALL OPropertyBrowserController::getViewData( ) throw(RuntimeException)
+ {
+ return makeAny( m_sPageSelection );
+ }
+
+ //------------------------------------------------------------------------
+ void SAL_CALL OPropertyBrowserController::restoreViewData( const Any& Data ) throw(RuntimeException)
+ {
+ ::rtl::OUString sPageSelection;
+ if ( ( Data >>= sPageSelection ) && sPageSelection.getLength() )
+ {
+ m_sPageSelection = sPageSelection;
+ selectPageFromViewData();
+ }
+ }
+
+ //------------------------------------------------------------------------
+ Reference< XModel > SAL_CALL OPropertyBrowserController::getModel( ) throw(RuntimeException)
+ {
+ // have no model
+ return Reference< XModel >();
+ }
+
+ //------------------------------------------------------------------------
+ Reference< XFrame > SAL_CALL OPropertyBrowserController::getFrame( ) throw(RuntimeException)
+ {
+ return m_xFrame;
+ }
+
+ //------------------------------------------------------------------------
+ void SAL_CALL OPropertyBrowserController::dispose( ) throw(RuntimeException)
+ {
+ SolarMutexGuard aSolarGuard;
+
+ // stop inspecting the current object
+ stopInspection( false );
+
+ // say our dispose listeners goodbye
+ ::com::sun::star::lang::EventObject aEvt;
+ aEvt.Source = static_cast< ::cppu::OWeakObject* >(this);
+ m_aDisposeListeners.disposeAndClear(aEvt);
+ m_aControlObservers.disposeAndClear(aEvt);
+
+ // don't delete explicitly (this is done by the frame we reside in)
+ m_pView = NULL;
+
+ Reference< XComponent > xViewAsComp( m_xView, UNO_QUERY );
+ if ( xViewAsComp.is() )
+ xViewAsComp->removeEventListener( static_cast< XPropertyChangeListener* >( this ) );
+ m_xView.clear( );
+
+ m_aInspectedObjects.clear();
+ impl_bindToNewModel_nothrow( NULL );
+ }
+
+ //------------------------------------------------------------------------
+ void SAL_CALL OPropertyBrowserController::addEventListener( const Reference< XEventListener >& _rxListener ) throw(RuntimeException)
+ {
+ m_aDisposeListeners.addInterface(_rxListener);
+ }
+
+ //------------------------------------------------------------------------
+ void SAL_CALL OPropertyBrowserController::removeEventListener( const Reference< XEventListener >& _rxListener ) throw(RuntimeException)
+ {
+ m_aDisposeListeners.removeInterface(_rxListener);
+ }
+
+ //------------------------------------------------------------------------
+ ::rtl::OUString SAL_CALL OPropertyBrowserController::getImplementationName( ) throw(RuntimeException)
+ {
+ return getImplementationName_static();
+ }
+
+ //------------------------------------------------------------------------
+ sal_Bool SAL_CALL OPropertyBrowserController::supportsService( const ::rtl::OUString& ServiceName ) throw(RuntimeException)
+ {
+ Sequence< ::rtl::OUString > aSupported(getSupportedServiceNames());
+ const ::rtl::OUString* pArray = aSupported.getConstArray();
+ for (sal_Int32 i = 0; i < aSupported.getLength(); ++i, ++pArray)
+ if (pArray->equals(ServiceName))
+ return sal_True;
+ return sal_False;
+ }
+
+ //------------------------------------------------------------------------
+ Sequence< ::rtl::OUString > SAL_CALL OPropertyBrowserController::getSupportedServiceNames( ) throw(RuntimeException)
+ {
+ return getSupportedServiceNames_static();
+ }
+
+ //------------------------------------------------------------------------
+ ::rtl::OUString OPropertyBrowserController::getImplementationName_static( ) throw(RuntimeException)
+ {
+ return ::rtl::OUString::createFromAscii("org.openoffice.comp.extensions.ObjectInspector");
+ }
+
+ //------------------------------------------------------------------------
+ Sequence< ::rtl::OUString > OPropertyBrowserController::getSupportedServiceNames_static( ) throw(RuntimeException)
+ {
+ Sequence< ::rtl::OUString > aSupported(1);
+ aSupported[0] = ::rtl::OUString::createFromAscii( "com.sun.star.inspection.ObjectInspector" );
+ return aSupported;
+ }
+
+ //------------------------------------------------------------------------
+ Reference< XInterface > SAL_CALL OPropertyBrowserController::Create(const Reference< XComponentContext >& _rxContext)
+ {
+ return *(new OPropertyBrowserController( _rxContext ) );
+ }
+
+ //------------------------------------------------------------------------
+ void SAL_CALL OPropertyBrowserController::focusGained( const FocusEvent& _rSource ) throw (RuntimeException)
+ {
+ Reference< XWindow > xSourceWindow(_rSource.Source, UNO_QUERY);
+ Reference< XWindow > xContainerWindow;
+ if (m_xFrame.is())
+ xContainerWindow = m_xFrame->getContainerWindow();
+
+ if ( xContainerWindow.get() == xSourceWindow.get() )
+ { // our container window got the focus
+ if ( haveView() )
+ getPropertyBox().GrabFocus();
+ }
+ }
+
+ //------------------------------------------------------------------------
+ void SAL_CALL OPropertyBrowserController::focusLost( const FocusEvent& /*_rSource*/ ) throw (RuntimeException)
+ {
+ // not interested in
+ }
+
+ //------------------------------------------------------------------------
+ void SAL_CALL OPropertyBrowserController::disposing( const EventObject& _rSource ) throw(RuntimeException)
+ {
+ if ( m_xView.is() && ( m_xView == _rSource.Source ) )
+ {
+ m_xView = NULL;
+ m_pView = NULL;
+ }
+
+ for ( InterfaceArray::iterator loop = m_aInspectedObjects.begin();
+ loop != m_aInspectedObjects.end();
+ ++loop
+ )
+ {
+ if ( *loop == _rSource.Source )
+ {
+ m_aInspectedObjects.erase( loop );
+ break;
+ }
+ }
+ }
+
+ //------------------------------------------------------------------------
+ IMPL_LINK(OPropertyBrowserController, OnPageActivation, void*, EMPTYARG)
+ {
+ updateViewDataFromActivePage();
+ return 0L;
+ }
+
+ //------------------------------------------------------------------------
+ void OPropertyBrowserController::updateViewDataFromActivePage()
+ {
+ if (!haveView())
+ return;
+
+ ::rtl::OUString sOldSelection = m_sPageSelection;
+ m_sPageSelection = ::rtl::OUString();
+
+ const sal_uInt16 nCurrentPage = m_pView->getActivaPage();
+ if ( (sal_uInt16)-1 != nCurrentPage )
+ {
+ for ( HashString2Int16::const_iterator pageId = m_aPageIds.begin();
+ pageId != m_aPageIds.end();
+ ++pageId
+ )
+ {
+ if ( nCurrentPage == pageId->second )
+ {
+ m_sPageSelection = pageId->first;
+ break;
+ }
+ }
+ }
+
+ if ( m_sPageSelection.getLength() )
+ m_sLastValidPageSelection = m_sPageSelection;
+ else if ( sOldSelection.getLength() )
+ m_sLastValidPageSelection = sOldSelection;
+ }
+
+ //------------------------------------------------------------------------
+ sal_uInt16 OPropertyBrowserController::impl_getPageIdForCategory_nothrow( const ::rtl::OUString& _rCategoryName ) const
+ {
+ sal_uInt16 nPageId = (sal_uInt16)-1;
+ HashString2Int16::const_iterator pagePos = m_aPageIds.find( _rCategoryName );
+ if ( pagePos != m_aPageIds.end() )
+ nPageId = pagePos->second;
+ return nPageId;
+ }
+
+ //------------------------------------------------------------------------
+ void OPropertyBrowserController::selectPageFromViewData()
+ {
+ sal_uInt16 nNewPage = impl_getPageIdForCategory_nothrow( m_sPageSelection );
+
+ if ( haveView() && ( nNewPage != (sal_uInt16)-1 ) )
+ m_pView->activatePage( nNewPage );
+
+ // just in case ...
+ updateViewDataFromActivePage();
+ }
+
+ //------------------------------------------------------------------------
+ sal_Bool OPropertyBrowserController::Construct(Window* _pParentWin)
+ {
+ DBG_ASSERT(!haveView(), "OPropertyBrowserController::Construct: already have a view!");
+ DBG_ASSERT(_pParentWin, "OPropertyBrowserController::Construct: invalid parent window!");
+
+ m_pView = new OPropertyBrowserView(m_aContext.getLegacyServiceFactory(), _pParentWin);
+ m_pView->setPageActivationHandler(LINK(this, OPropertyBrowserController, OnPageActivation));
+
+ // add as dispose listener for our view. The view is disposed by the frame we're plugged into,
+ // and this disposal _deletes_ the view, so it would be deadly if we use our m_pView member
+ // after that
+ m_xView = VCLUnoHelper::GetInterface(m_pView);
+ Reference< XComponent > xViewAsComp(m_xView, UNO_QUERY);
+ if (xViewAsComp.is())
+ xViewAsComp->addEventListener( static_cast< XPropertyChangeListener* >( this ) );
+
+ getPropertyBox().SetLineListener(this);
+ getPropertyBox().SetControlObserver(this);
+ impl_initializeView_nothrow();
+
+ m_pView->Show();
+
+ return sal_True;
+ }
+
+ //------------------------------------------------------------------------
+ void SAL_CALL OPropertyBrowserController::propertyChange( const PropertyChangeEvent& _rEvent ) throw (RuntimeException)
+ {
+ if ( _rEvent.Source == m_xModel )
+ {
+ if ( _rEvent.PropertyName.equalsAscii( "IsReadOnly" ) )
+ impl_updateReadOnlyView_nothrow();
+ return;
+ }
+
+ if ( m_sCommittingProperty == _rEvent.PropertyName )
+ return;
+
+ if ( !haveView() )
+ return;
+
+ Any aNewValue( _rEvent.NewValue );
+ if ( impl_hasPropertyHandlerFor_nothrow( _rEvent.PropertyName ) )
+ {
+ // forward the new value to the property box, to reflect the change in the UI
+ aNewValue = impl_getPropertyValue_throw( _rEvent.PropertyName );
+
+ // check whether the state is ambiguous. This is interesting in case we display the properties
+ // for multiple objects at once: In this case, we'll get a notification from one of the objects,
+ // but need to care for the "composed" value, which can be "ambiguous".
+ PropertyHandlerRef xHandler( impl_getHandlerForProperty_throw( _rEvent.PropertyName ), UNO_SET_THROW );
+ PropertyState ePropertyState( xHandler->getPropertyState( _rEvent.PropertyName ) );
+ bool bAmbiguousValue = ( PropertyState_AMBIGUOUS_VALUE == ePropertyState );
+
+ getPropertyBox().SetPropertyValue( _rEvent.PropertyName, aNewValue, bAmbiguousValue );
+ }
+
+ // if it's a actuating property, then update the UI for any dependent
+ // properties
+ if ( impl_isActuatingProperty_nothrow( _rEvent.PropertyName ) )
+ impl_broadcastPropertyChange_nothrow( _rEvent.PropertyName, aNewValue, _rEvent.OldValue, false );
+ }
+
+ //------------------------------------------------------------------------
+ Reference< XPropertyControl > SAL_CALL OPropertyBrowserController::createPropertyControl( ::sal_Int16 ControlType, ::sal_Bool _CreateReadOnly ) throw (IllegalArgumentException, RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ Reference< XPropertyControl > xControl;
+
+ // default winbits: a border only
+ WinBits nWinBits = WB_BORDER;
+
+ // read-only-ness
+ _CreateReadOnly |= (sal_Bool)impl_isReadOnlyModel_throw();
+ if ( _CreateReadOnly )
+ nWinBits |= WB_READONLY;
+
+ switch ( ControlType )
+ {
+ case PropertyControlType::StringListField:
+ xControl = new OMultilineEditControl( &getPropertyBox(), eStringList, nWinBits | WB_DROPDOWN | WB_TABSTOP );
+ break;
+
+ case PropertyControlType::MultiLineTextField:
+ xControl = new OMultilineEditControl( &getPropertyBox(), eMultiLineText, nWinBits | WB_DROPDOWN | WB_TABSTOP );
+ break;
+
+ case PropertyControlType::ListBox:
+ xControl = new OListboxControl( &getPropertyBox(), nWinBits | WB_TABSTOP | WB_DROPDOWN);
+ break;
+
+ case PropertyControlType::ComboBox:
+ xControl = new OComboboxControl( &getPropertyBox(), nWinBits | WB_TABSTOP | WB_DROPDOWN);
+ break;
+
+ case PropertyControlType::TextField:
+ xControl = new OEditControl( &getPropertyBox(), sal_False, nWinBits | WB_TABSTOP );
+ break;
+
+ case PropertyControlType::CharacterField:
+ xControl = new OEditControl( &getPropertyBox(), sal_True, nWinBits | WB_TABSTOP );
+ break;
+
+ case PropertyControlType::NumericField:
+ xControl = new ONumericControl( &getPropertyBox(), nWinBits | WB_TABSTOP | WB_SPIN | WB_REPEAT );
+ break;
+
+ case PropertyControlType::DateTimeField:
+ xControl = new ODateTimeControl( &getPropertyBox(), nWinBits | WB_TABSTOP );
+ break;
+
+ case PropertyControlType::DateField:
+ xControl = new ODateControl( &getPropertyBox(), nWinBits | WB_TABSTOP | WB_SPIN | WB_REPEAT );
+ break;
+
+ case PropertyControlType::TimeField:
+ xControl = new OTimeControl( &getPropertyBox(), nWinBits | WB_TABSTOP | WB_SPIN | WB_REPEAT );
+ break;
+
+ case PropertyControlType::ColorListBox:
+ xControl = new OColorControl( &getPropertyBox(), nWinBits | WB_TABSTOP | WB_DROPDOWN );
+ break;
+
+ case PropertyControlType::HyperlinkField:
+ xControl = new OHyperlinkControl( &getPropertyBox(), nWinBits | WB_TABSTOP | WB_DROPDOWN );
+ break;
+
+ default:
+ throw IllegalArgumentException( ::rtl::OUString(), *this, 1 );
+ }
+
+ return xControl;
+ }
+
+ //------------------------------------------------------------------------
+ void OPropertyBrowserController::impl_toggleInspecteeListening_nothrow( bool _bOn )
+ {
+ for ( InterfaceArray::const_iterator loop = m_aInspectedObjects.begin();
+ loop != m_aInspectedObjects.end();
+ ++loop
+ )
+ {
+ try
+ {
+ Reference< XComponent > xComp( *loop, UNO_QUERY );
+ if ( xComp.is() )
+ {
+ if ( _bOn )
+ xComp->addEventListener( static_cast< XPropertyChangeListener* >( this ) );
+ else
+ xComp->removeEventListener( static_cast< XPropertyChangeListener* >( this ) );
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+ }
+
+ //------------------------------------------------------------------------
+ void OPropertyBrowserController::stopInspection( bool _bCommitModified )
+ {
+ if ( haveView() )
+ {
+ if ( _bCommitModified )
+ // commit the editor's content
+ getPropertyBox().CommitModified();
+
+ // hide the property box so that it does not flicker
+ getPropertyBox().Hide();
+
+ // clear the property box
+ getPropertyBox().ClearAll();
+ }
+
+ // destroy the view first
+ if ( haveView() )
+ {
+ // remove the pages
+ for ( HashString2Int16::const_iterator erase = m_aPageIds.begin();
+ erase != m_aPageIds.end();
+ ++erase
+ )
+ getPropertyBox().RemovePage( erase->second );
+ clearContainer( m_aPageIds );
+ }
+
+ clearContainer( m_aProperties );
+
+ // de-register as dispose-listener from our inspected objects
+ impl_toggleInspecteeListening_nothrow( false );
+
+ // handlers are obsolete, so is our "composer" for their UI requests
+ if ( m_pUIRequestComposer.get() )
+ m_pUIRequestComposer->dispose();
+ m_pUIRequestComposer.reset( NULL );
+
+ // clean up the property handlers
+ PropertyHandlerArray aAllHandlers; // will contain every handler exactly once
+ for ( PropertyHandlerRepository::const_iterator aHandler = m_aPropertyHandlers.begin();
+ aHandler != m_aPropertyHandlers.end();
+ ++aHandler
+ )
+ if ( ::std::find( aAllHandlers.begin(), aAllHandlers.end(), aHandler->second ) == aAllHandlers.end() )
+ aAllHandlers.push_back( aHandler->second );
+
+ for ( PropertyHandlerArray::iterator loop = aAllHandlers.begin();
+ loop != aAllHandlers.end();
+ ++loop
+ )
+ {
+ try
+ {
+ (*loop)->removePropertyChangeListener( this );
+ (*loop)->dispose();
+ }
+ catch( const DisposedException& )
+ {
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+
+ clearContainer( m_aPropertyHandlers );
+ clearContainer( m_aDependencyHandlers );
+ }
+
+ //------------------------------------------------------------------------
+ bool OPropertyBrowserController::impl_hasPropertyHandlerFor_nothrow( const ::rtl::OUString& _rPropertyName ) const
+ {
+ PropertyHandlerRepository::const_iterator handlerPos = m_aPropertyHandlers.find( _rPropertyName );
+ return ( handlerPos != m_aPropertyHandlers.end() );
+ }
+
+ //------------------------------------------------------------------------
+ OPropertyBrowserController::PropertyHandlerRef OPropertyBrowserController::impl_getHandlerForProperty_throw( const ::rtl::OUString& _rPropertyName ) const
+ {
+ PropertyHandlerRepository::const_iterator handlerPos = m_aPropertyHandlers.find( _rPropertyName );
+ if ( handlerPos == m_aPropertyHandlers.end() )
+ throw RuntimeException();
+ return handlerPos->second;
+ }
+
+ //------------------------------------------------------------------------
+ Any OPropertyBrowserController::impl_getPropertyValue_throw( const ::rtl::OUString& _rPropertyName )
+ {
+ PropertyHandlerRef handler = impl_getHandlerForProperty_throw( _rPropertyName );
+ return handler->getPropertyValue( _rPropertyName );
+ }
+
+ //------------------------------------------------------------------------
+ void OPropertyBrowserController::impl_rebindToInspectee_nothrow( const InterfaceArray& _rObjects )
+ {
+ try
+ {
+ // stop inspecting the old object(s)
+ stopInspection( true );
+
+ // inspect the new object(s)
+ m_aInspectedObjects = _rObjects;
+ doInspection();
+
+ // update the user interface
+ UpdateUI();
+ }
+
+ catch(Exception&)
+ {
+ DBG_ERROR("OPropertyBrowserController::impl_rebindToInspectee_nothrow: caught an exception !");
+ }
+ }
+
+ //------------------------------------------------------------------------
+ void OPropertyBrowserController::doInspection()
+ {
+ try
+ {
+ //////////////////////////////////////////////////////////////////////
+ // obtain the properties of the object
+ ::std::vector< Property > aProperties;
+
+ PropertyHandlerArray aPropertyHandlers;
+ getPropertyHandlers( m_aInspectedObjects, aPropertyHandlers );
+
+ PropertyHandlerArray::iterator aHandler( aPropertyHandlers.begin() );
+ while ( aHandler != aPropertyHandlers.end() )
+ {
+ DBG_ASSERT( aHandler->get(), "OPropertyBrowserController::doInspection: invalid handler!" );
+
+ StlSyntaxSequence< Property > aThisHandlersProperties = (*aHandler)->getSupportedProperties();
+
+ if ( aThisHandlersProperties.empty() )
+ {
+ // this handler doesn't know anything about the current inspectee -> ignore it
+ (*aHandler)->dispose();
+ aHandler = aPropertyHandlers.erase( aHandler );
+ continue;
+ }
+
+ // append these properties to our "all properties" array
+ aProperties.reserve( aProperties.size() + aThisHandlersProperties.size() );
+ for ( StlSyntaxSequence< Property >::const_iterator copyProperty = aThisHandlersProperties.begin();
+ copyProperty != aThisHandlersProperties.end();
+ ++copyProperty
+ )
+ {
+ ::std::vector< Property >::const_iterator previous = ::std::find_if(
+ aProperties.begin(),
+ aProperties.end(),
+ FindPropertyByName( copyProperty->Name )
+ );
+ if ( previous == aProperties.end() )
+ {
+ aProperties.push_back( *copyProperty );
+ continue;
+ }
+
+ // there already was another (previous) handler which supported this property.
+ // Don't add it to aProperties, again.
+
+ // Also, ensure that handlers which previously expressed interest in *changes*
+ // of this property are not notified.
+ // This is 'cause we have a new handler which is responsible for this property,
+ // which means it can give it a completely different meaning than the previous
+ // handler for this property is prepared for.
+ ::std::pair< PropertyHandlerMultiRepository::iterator, PropertyHandlerMultiRepository::iterator >
+ aDepHandlers = m_aDependencyHandlers.equal_range( copyProperty->Name );
+ m_aDependencyHandlers.erase( aDepHandlers.first, aDepHandlers.second );
+ }
+
+ // determine the superseded properties
+ StlSyntaxSequence< ::rtl::OUString > aSupersededByThisHandler = (*aHandler)->getSupersededProperties();
+ for ( StlSyntaxSequence< ::rtl::OUString >::const_iterator superseded = aSupersededByThisHandler.begin();
+ superseded != aSupersededByThisHandler.end();
+ ++superseded
+ )
+ {
+ ::std::vector< Property >::iterator existent = ::std::find_if(
+ aProperties.begin(),
+ aProperties.end(),
+ FindPropertyByName( *superseded )
+ );
+ if ( existent != aProperties.end() )
+ // one of the properties superseded by this handler was supported by a previous
+ // one -> erase
+ aProperties.erase( existent );
+ }
+
+ // be notified of changes which this handler is responsible for
+ (*aHandler)->addPropertyChangeListener( this );
+
+ // remember this handler for every of the properties which it is responsible
+ // for
+ for ( StlSyntaxSequence< Property >::const_iterator remember = aThisHandlersProperties.begin();
+ remember != aThisHandlersProperties.end();
+ ++remember
+ )
+ {
+ m_aPropertyHandlers[ remember->Name ] = *aHandler;
+ // note that this implies that if two handlers support the same property,
+ // the latter wins
+ }
+
+ // see if the handler expresses interest in any actuating properties
+ StlSyntaxSequence< ::rtl::OUString > aInterestingActuations = (*aHandler)->getActuatingProperties();
+ for ( StlSyntaxSequence< ::rtl::OUString >::const_iterator aLoop = aInterestingActuations.begin();
+ aLoop != aInterestingActuations.end();
+ ++aLoop
+ )
+ {
+ m_aDependencyHandlers.insert( PropertyHandlerMultiRepository::value_type(
+ *aLoop, *aHandler ) );
+ }
+
+ ++aHandler;
+ }
+
+ // create a new composer for UI requests coming from the handlers
+ m_pUIRequestComposer.reset( new ComposedPropertyUIUpdate( getInspectorUI(), this ) );
+
+ // sort the properties by relative position, as indicated by the model
+ for ( ::std::vector< Property >::const_iterator sourceProps = aProperties.begin();
+ sourceProps != aProperties.end();
+ ++sourceProps
+ )
+ {
+ sal_Int32 nRelativePropertyOrder = sourceProps - aProperties.begin();
+ if ( m_xModel.is() )
+ nRelativePropertyOrder = m_xModel->getPropertyOrderIndex( sourceProps->Name );
+ while ( m_aProperties.find( nRelativePropertyOrder ) != m_aProperties.end() )
+ ++nRelativePropertyOrder;
+ m_aProperties[ nRelativePropertyOrder ] = *sourceProps;
+ }
+
+ // be notified when one of our inspectees dies
+ impl_toggleInspecteeListening_nothrow( true );
+ }
+ catch(Exception&)
+ {
+ DBG_ERROR("OPropertyBrowserController::doInspection : caught an exception !");
+ }
+ }
+
+ //------------------------------------------------------------------------
+ ::com::sun::star::awt::Size SAL_CALL OPropertyBrowserController::getMinimumSize() throw (::com::sun::star::uno::RuntimeException)
+ {
+ ::com::sun::star::awt::Size aSize;
+ if( m_pView )
+ return m_pView->getMinimumSize();
+ else
+ return aSize;
+ }
+
+ //------------------------------------------------------------------------
+ ::com::sun::star::awt::Size SAL_CALL OPropertyBrowserController::getPreferredSize() throw (::com::sun::star::uno::RuntimeException)
+ {
+ return getMinimumSize();
+ }
+
+ //------------------------------------------------------------------------
+ ::com::sun::star::awt::Size SAL_CALL OPropertyBrowserController::calcAdjustedSize( const ::com::sun::star::awt::Size& _rNewSize ) throw (::com::sun::star::uno::RuntimeException)
+ {
+ awt::Size aMinSize = getMinimumSize( );
+ awt::Size aAdjustedSize( _rNewSize );
+ if ( aAdjustedSize.Width < aMinSize.Width )
+ aAdjustedSize.Width = aMinSize.Width;
+ if ( aAdjustedSize.Height < aMinSize.Height )
+ aAdjustedSize.Height = aMinSize.Height;
+ return aAdjustedSize;
+ }
+
+ //------------------------------------------------------------------------
+ void OPropertyBrowserController::describePropertyLine( const Property& _rProperty, OLineDescriptor& _rDescriptor ) SAL_THROW((Exception))
+ {
+ try
+ {
+ PropertyHandlerRepository::const_iterator handler = m_aPropertyHandlers.find( _rProperty.Name );
+ if ( handler == m_aPropertyHandlers.end() )
+ throw RuntimeException(); // caught below
+
+ _rDescriptor.assignFrom( handler->second->describePropertyLine( _rProperty.Name, this ) );
+
+ //////////////////////////////////////////////////////////////////////
+
+ _rDescriptor.xPropertyHandler = handler->second;
+ _rDescriptor.sName = _rProperty.Name;
+ _rDescriptor.aValue = _rDescriptor.xPropertyHandler->getPropertyValue( _rProperty.Name );
+
+ if ( !_rDescriptor.DisplayName.getLength() )
+ {
+ #ifdef DBG_UTIL
+ ::rtl::OString sMessage( "OPropertyBrowserController::describePropertyLine: handler did not provide a display name for '" );
+ sMessage += ::rtl::OString( _rProperty.Name.getStr(), _rProperty.Name.getLength(), RTL_TEXTENCODING_ASCII_US );
+ sMessage += ::rtl::OString( "'!" );
+ DBG_ASSERT( _rDescriptor.DisplayName.getLength(), sMessage );
+ #endif
+ _rDescriptor.DisplayName = _rProperty.Name;
+ }
+
+ PropertyState ePropertyState( _rDescriptor.xPropertyHandler->getPropertyState( _rProperty.Name ) );
+ if ( PropertyState_AMBIGUOUS_VALUE == ePropertyState )
+ {
+ _rDescriptor.bUnknownValue = true;
+ _rDescriptor.aValue.clear();
+ }
+
+ _rDescriptor.bReadOnly = impl_isReadOnlyModel_throw();
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "OPropertyBrowserController::describePropertyLine: caught an exception!" );
+ }
+ }
+
+ //------------------------------------------------------------------------
+ void OPropertyBrowserController::impl_buildCategories_throw()
+ {
+ OSL_PRECOND( m_aPageIds.empty(), "OPropertyBrowserController::impl_buildCategories_throw: duplicate call!" );
+
+ StlSyntaxSequence< PropertyCategoryDescriptor > aCategories;
+ if ( m_xModel.is() )
+ aCategories = m_xModel->describeCategories();
+
+ for ( StlSyntaxSequence< PropertyCategoryDescriptor >::const_iterator category = aCategories.begin();
+ category != aCategories.end();
+ ++category
+ )
+ {
+ OSL_ENSURE( m_aPageIds.find( category->ProgrammaticName ) == m_aPageIds.end(),
+ "OPropertyBrowserController::impl_buildCategories_throw: duplicate programmatic name!" );
+
+ m_aPageIds[ category->ProgrammaticName ] =
+ getPropertyBox().AppendPage( category->UIName, HelpIdUrl::getHelpId( category->HelpURL ) );
+ }
+ }
+
+ //------------------------------------------------------------------------
+ void OPropertyBrowserController::UpdateUI()
+ {
+ try
+ {
+ if ( !haveView() )
+ // too early, will return later
+ return;
+
+ getPropertyBox().DisableUpdate();
+
+ sal_Bool bHaveFocus = getPropertyBox().HasChildPathFocus();
+
+ // create our tab pages
+ impl_buildCategories_throw();
+ // (and allow for pages to be actually unused)
+ ::std::set< sal_uInt16 > aUsedPages;
+
+ // when building the UI below, remember which properties are actuating,
+ // to allow for a initial actuatinPropertyChanged call
+ ::std::vector< ::rtl::OUString > aActuatingProperties;
+ ::std::vector< Any > aActuatingPropertyValues;
+
+ // ask the handlers to describe the property UI, and insert the resulting
+ // entries into our list boxes
+ OrderedPropertyMap::const_iterator property( m_aProperties.begin() );
+ for ( ; property != m_aProperties.end(); ++property )
+ {
+ OLineDescriptor aDescriptor;
+ describePropertyLine( property->second, aDescriptor );
+
+ bool bIsActuatingProperty = impl_isActuatingProperty_nothrow( property->second.Name );
+
+ #if OSL_DEBUG_LEVEL > 0
+ if ( !aDescriptor.Category.getLength() )
+ {
+ ::rtl::OString sMessage( "OPropertyBrowserController::UpdateUI: empty category provided for property '" );
+ sMessage += ::rtl::OString( property->second.Name.getStr(), property->second.Name.getLength(), osl_getThreadTextEncoding() );
+ sMessage += "'!";
+ OSL_ENSURE( false, sMessage );
+ }
+ #endif
+ // finally insert this property control
+ sal_uInt16 nTargetPageId = impl_getPageIdForCategory_nothrow( aDescriptor.Category );
+ if ( nTargetPageId == (sal_uInt16)-1 )
+ {
+ // this category does not yet exist. This is allowed, as an inspector model might be lazy, and not provide
+ // any category information of its own. In this case, we have a fallback ...
+ m_aPageIds[ aDescriptor.Category ] =
+ getPropertyBox().AppendPage( aDescriptor.Category, SmartId() );
+ nTargetPageId = impl_getPageIdForCategory_nothrow( aDescriptor.Category );
+ }
+
+ getPropertyBox().InsertEntry( aDescriptor, nTargetPageId );
+ aUsedPages.insert( nTargetPageId );
+
+ // if it's an actuating property, remember it
+ if ( bIsActuatingProperty )
+ {
+ aActuatingProperties.push_back( property->second.Name );
+ aActuatingPropertyValues.push_back( impl_getPropertyValue_throw( property->second.Name ) );
+ }
+ }
+
+ // update any dependencies for the actuating properties which we encountered
+ {
+ ::std::vector< ::rtl::OUString >::const_iterator aProperty = aActuatingProperties.begin();
+ ::std::vector< Any >::const_iterator aPropertyValue = aActuatingPropertyValues.begin();
+ for ( ; aProperty != aActuatingProperties.end(); ++aProperty, ++aPropertyValue )
+ impl_broadcastPropertyChange_nothrow( *aProperty, *aPropertyValue, *aPropertyValue, true );
+ }
+
+ // remove any unused pages (which we did not encounter properties for)
+ HashString2Int16 aSurvivingPageIds;
+ for ( HashString2Int16::iterator pageId = m_aPageIds.begin();
+ pageId != m_aPageIds.end();
+ ++pageId
+ )
+ {
+ if ( aUsedPages.find( pageId->second ) == aUsedPages.end() )
+ getPropertyBox().RemovePage( pageId->second );
+ else
+ aSurvivingPageIds.insert( *pageId );
+ }
+ m_aPageIds.swap( aSurvivingPageIds );
+
+
+ getPropertyBox().Show();
+ getPropertyBox().EnableUpdate();
+ if ( bHaveFocus )
+ getPropertyBox().GrabFocus();
+
+ // activate the first page
+ if ( !m_aPageIds.empty() )
+ {
+ Sequence< PropertyCategoryDescriptor > aCategories( m_xModel->describeCategories() );
+ if ( aCategories.getLength() )
+ m_pView->activatePage( m_aPageIds[ aCategories[0].ProgrammaticName ] );
+ else
+ // allowed: if we default-created the pages ...
+ m_pView->activatePage( m_aPageIds.begin()->second );
+ }
+
+ // activate the previously active page (if possible)
+ if ( m_sLastValidPageSelection.getLength() )
+ m_sPageSelection = m_sLastValidPageSelection;
+ selectPageFromViewData();
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+
+ //------------------------------------------------------------------------
+ void OPropertyBrowserController::Clicked( const ::rtl::OUString& _rName, sal_Bool _bPrimary )
+ {
+ try
+ {
+ // since the browse buttons do not get the focus when clicked with the mouse,
+ // we need to commit the changes in the current property field
+ getPropertyBox().CommitModified();
+
+ PropertyHandlerRepository::const_iterator handler = m_aPropertyHandlers.find( _rName );
+ DBG_ASSERT( handler != m_aPropertyHandlers.end(), "OPropertyBrowserController::Clicked: a property without handler? This will crash!" );
+
+ ComposedUIAutoFireGuard aAutoFireGuard( *m_pUIRequestComposer );
+
+ Any aData;
+ m_xInteractiveHandler = handler->second;
+ InteractiveSelectionResult eResult =
+ handler->second->onInteractivePropertySelection( _rName, _bPrimary, aData,
+ m_pUIRequestComposer->getUIForPropertyHandler( handler->second ) );
+
+ switch ( eResult )
+ {
+ case InteractiveSelectionResult_Cancelled:
+ case InteractiveSelectionResult_Success:
+ // okay, nothing to do
+ break;
+ case InteractiveSelectionResult_ObtainedValue:
+ handler->second->setPropertyValue( _rName, aData );
+ break;
+ case InteractiveSelectionResult_Pending:
+ // also okay, we expect that the handler has disabled the UI as necessary
+ break;
+ default:
+ OSL_ENSURE( false, "OPropertyBrowserController::Clicked: unknown result value!" );
+ break;
+ }
+ }
+ catch (Exception&)
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ m_xInteractiveHandler = NULL;
+ }
+
+ //------------------------------------------------------------------------
+ sal_Bool SAL_CALL OPropertyBrowserController::hasPropertyByName( const ::rtl::OUString& _rName ) throw (RuntimeException)
+ {
+ for ( OrderedPropertyMap::const_iterator search = m_aProperties.begin();
+ search != m_aProperties.end();
+ ++search
+ )
+ if ( search->second.Name == _rName )
+ return true;
+ return false;
+ }
+
+ //------------------------------------------------------------------------
+ void OPropertyBrowserController::Commit( const ::rtl::OUString& rName, const Any& _rValue )
+ {
+ try
+ {
+ rtl::OUString sPlcHolder = String( PcrRes( RID_EMBED_IMAGE_PLACEHOLDER ) );
+ bool bIsPlaceHolderValue = false;
+
+ if ( rName.equals( PROPERTY_IMAGE_URL ) )
+ {
+ // if the prop value is the PlaceHolder
+ // can ignore it
+ rtl::OUString sVal;
+ _rValue >>= sVal;
+ if ( sVal.equals( sPlcHolder ) )
+ bIsPlaceHolderValue = true;
+ }
+ m_sCommittingProperty = rName;
+
+ bool bIsActuatingProperty = impl_isActuatingProperty_nothrow( rName );
+
+ Any aOldValue;
+ if ( bIsActuatingProperty )
+ aOldValue = impl_getPropertyValue_throw( rName );
+
+ // do we have a dedicated handler for this property, which we can delegate some tasks to?
+ PropertyHandlerRef handler = impl_getHandlerForProperty_throw( rName );
+
+ //////////////////////////////////////////////////////////////////////
+ // set the value ( only if it's not a placeholder )
+ if ( !bIsPlaceHolderValue )
+ handler->setPropertyValue( rName, _rValue );
+
+ //////////////////////////////////////////////////////////////////////
+ // re-retrieve the value
+ Any aNormalizedValue = handler->getPropertyValue( rName );
+
+ // care for any inter-property dependencies
+ if ( bIsActuatingProperty )
+ impl_broadcastPropertyChange_nothrow( rName, aNormalizedValue, aOldValue, false );
+
+ // and display it again. This ensures proper formatting
+ getPropertyBox().SetPropertyValue( rName, aNormalizedValue, false );
+ }
+ catch(PropertyVetoException& eVetoException)
+ {
+ InfoBox(m_pView, eVetoException.Message).Execute();
+ PropertyHandlerRef handler = impl_getHandlerForProperty_throw( rName );
+ Any aNormalizedValue = handler->getPropertyValue( rName );
+ getPropertyBox().SetPropertyValue( rName, aNormalizedValue, false );
+ }
+ catch(Exception&)
+ {
+ DBG_ERROR("OPropertyBrowserController::Commit : caught an exception !");
+ }
+
+ m_sCommittingProperty = ::rtl::OUString();
+ }
+
+ //--------------------------------------------------------------------
+ namespace
+ {
+ }
+
+ //--------------------------------------------------------------------
+ void OPropertyBrowserController::focusGained( const Reference< XPropertyControl >& _Control )
+ {
+ m_aControlObservers.notifyEach( &XPropertyControlObserver::focusGained, _Control );
+ }
+
+ //--------------------------------------------------------------------
+ void OPropertyBrowserController::valueChanged( const Reference< XPropertyControl >& _Control )
+ {
+ m_aControlObservers.notifyEach( &XPropertyControlObserver::valueChanged, _Control );
+ }
+
+ //------------------------------------------------------------------------
+ namespace
+ {
+ Reference< XPropertyHandler > lcl_createHandler( const ComponentContext& _rContext, const Any& _rFactoryDescriptor )
+ {
+ Reference< XPropertyHandler > xHandler;
+
+ ::rtl::OUString sServiceName;
+ Reference< XSingleServiceFactory > xServiceFac;
+ Reference< XSingleComponentFactory > xComponentFac;
+
+ if ( _rFactoryDescriptor >>= sServiceName )
+ _rContext.createComponent( sServiceName, xHandler );
+ else if ( _rFactoryDescriptor >>= xServiceFac )
+ xHandler = xHandler.query( xServiceFac->createInstance() );
+ else if ( _rFactoryDescriptor >>= xComponentFac )
+ xHandler = xHandler.query( xComponentFac->createInstanceWithContext( _rContext.getUNOContext() ) );
+ OSL_ENSURE(xHandler.is(),"lcl_createHandler: Can not create handler");
+ return xHandler;
+ }
+ }
+
+ //------------------------------------------------------------------------
+ void OPropertyBrowserController::getPropertyHandlers( const InterfaceArray& _rObjects, PropertyHandlerArray& _rHandlers )
+ {
+ _rHandlers.resize( 0 );
+ if ( _rObjects.empty() )
+ return;
+
+ // create a component context for the handlers, containing some information about where
+ // they live
+ Reference< XComponentContext > xHandlerContext( m_aContext.getUNOContext() );
+
+ // if our own creator did not pass a dialog parent window, use our own view for this
+ Reference< XWindow > xParentWindow( m_aContext.getContextValueByAsciiName( "DialogParentWindow" ), UNO_QUERY );
+ if ( !xParentWindow.is() )
+ {
+ ::cppu::ContextEntry_Init aHandlerContextInfo[] =
+ {
+ ::cppu::ContextEntry_Init( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DialogParentWindow" ) ), makeAny( VCLUnoHelper::GetInterface( m_pView ) ) )
+ };
+ xHandlerContext = ::cppu::createComponentContext(
+ aHandlerContextInfo, SAL_N_ELEMENTS( aHandlerContextInfo ),
+ m_aContext.getUNOContext() );
+ }
+
+ Sequence< Any > aHandlerFactories;
+ if ( m_xModel.is() )
+ aHandlerFactories = m_xModel->getHandlerFactories();
+
+ const Any* pHandlerFactory = aHandlerFactories.getConstArray();
+ const Any* pHandlerFactoryEnd = aHandlerFactories.getConstArray() + aHandlerFactories.getLength();
+
+ while ( pHandlerFactory != pHandlerFactoryEnd )
+ {
+ if ( _rObjects.size() == 1 )
+ { // we're inspecting only one object -> one handler
+ Reference< XPropertyHandler > xHandler( lcl_createHandler( m_aContext, *pHandlerFactory ) );
+ if ( xHandler.is() )
+ {
+ xHandler->inspect( _rObjects[0] );
+ _rHandlers.push_back( xHandler );
+ }
+ }
+ else
+ {
+ // create a single handler for every single object
+ ::std::vector< Reference< XPropertyHandler > > aSingleHandlers( _rObjects.size() );
+ ::std::vector< Reference< XPropertyHandler > >::iterator pHandler = aSingleHandlers.begin();
+
+ InterfaceArray::const_iterator pObject = _rObjects.begin();
+ InterfaceArray::const_iterator pObjectEnd = _rObjects.end();
+
+ for ( ; pObject != pObjectEnd; ++pObject )
+ {
+ *pHandler = lcl_createHandler( m_aContext, *pHandlerFactory );
+ if ( pHandler->is() )
+ {
+ (*pHandler)->inspect( *pObject );
+ ++pHandler;
+ }
+ }
+ aSingleHandlers.resize( pHandler - aSingleHandlers.begin() );
+
+ // then create a handler which composes information out of those single handlers
+ if ( !aSingleHandlers.empty() )
+ _rHandlers.push_back( new PropertyComposer( aSingleHandlers ) );
+ }
+
+ ++pHandlerFactory;
+ }
+
+ // note that the handlers will not be used by our caller, if they indicate that there are no
+ // properties they feel responsible for
+ }
+
+ //------------------------------------------------------------------------
+ bool OPropertyBrowserController::impl_findObjectProperty_nothrow( const ::rtl::OUString& _rName, OrderedPropertyMap::const_iterator* _pProperty )
+ {
+ OrderedPropertyMap::const_iterator search = m_aProperties.begin();
+ for ( ; search != m_aProperties.end(); ++search )
+ if ( search->second.Name == _rName )
+ break;
+ if ( _pProperty )
+ *_pProperty = search;
+ return ( search != m_aProperties.end() );
+ }
+
+ //------------------------------------------------------------------------
+ void OPropertyBrowserController::rebuildPropertyUI( const ::rtl::OUString& _rPropertyName ) throw (RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ if ( !haveView() )
+ throw RuntimeException();
+
+ OrderedPropertyMap::const_iterator propertyPos;
+ if ( !impl_findObjectProperty_nothrow( _rPropertyName, &propertyPos ) )
+ return;
+
+ OLineDescriptor aDescriptor;
+ try
+ {
+ describePropertyLine( propertyPos->second, aDescriptor );
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "OPropertyBrowserController::rebuildPropertyUI: caught an exception!" );
+ }
+
+ getPropertyBox().ChangeEntry( aDescriptor );
+ }
+
+ //------------------------------------------------------------------------
+ void OPropertyBrowserController::enablePropertyUI( const ::rtl::OUString& _rPropertyName, sal_Bool _bEnable ) throw (RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ if ( !haveView() )
+ throw RuntimeException();
+
+ if ( !impl_findObjectProperty_nothrow( _rPropertyName ) )
+ return;
+
+ getPropertyBox().EnablePropertyLine( _rPropertyName, _bEnable );
+ }
+
+ //------------------------------------------------------------------------
+ void OPropertyBrowserController::enablePropertyUIElements( const ::rtl::OUString& _rPropertyName, sal_Int16 _nElements, sal_Bool _bEnable ) throw (RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ if ( !haveView() )
+ throw RuntimeException();
+
+ if ( !impl_findObjectProperty_nothrow( _rPropertyName ) )
+ return;
+
+ getPropertyBox().EnablePropertyControls( _rPropertyName, _nElements, _bEnable );
+ }
+
+ //------------------------------------------------------------------------
+ void OPropertyBrowserController::showPropertyUI( const ::rtl::OUString& _rPropertyName ) throw (RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ if ( !haveView() )
+ throw RuntimeException();
+
+ // look up the property in our object properties
+ OrderedPropertyMap::const_iterator propertyPos;
+ if ( !impl_findObjectProperty_nothrow( _rPropertyName, &propertyPos ) )
+ return;
+
+ if ( getPropertyBox().GetPropertyPos( _rPropertyName ) != LISTBOX_ENTRY_NOTFOUND )
+ {
+ rebuildPropertyUI( _rPropertyName );
+ return;
+ }
+
+ OLineDescriptor aDescriptor;
+ describePropertyLine( propertyPos->second, aDescriptor );
+
+ // look for the position to insert the property
+
+ // side note: The methods GetPropertyPos and InsertEntry of the OPropertyEditor work
+ // only on the current page. This implies that it's impossible to use this method here
+ // to show property lines which are *not* on the current page.
+ // This is sufficient for now, but should be changed in the future.
+
+ // by definition, the properties in m_aProperties are in the order in which they appear in the UI
+ // So all we need is a predecessor of pProperty in m_aProperties
+ sal_uInt16 nUIPos = LISTBOX_ENTRY_NOTFOUND;
+ do
+ {
+ if ( propertyPos != m_aProperties.begin() )
+ --propertyPos;
+ nUIPos = getPropertyBox().GetPropertyPos( propertyPos->second.Name );
+ }
+ while ( ( nUIPos == LISTBOX_ENTRY_NOTFOUND ) && ( propertyPos != m_aProperties.begin() ) );
+
+ if ( nUIPos == LISTBOX_ENTRY_NOTFOUND )
+ // insert at the very top
+ nUIPos = 0;
+ else
+ // insert right after the predecessor we found
+ ++nUIPos;
+
+ getPropertyBox().InsertEntry(
+ aDescriptor, impl_getPageIdForCategory_nothrow( aDescriptor.Category ), nUIPos );
+ }
+
+ //------------------------------------------------------------------------
+ void OPropertyBrowserController::hidePropertyUI( const ::rtl::OUString& _rPropertyName ) throw (RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ if ( !haveView() )
+ throw RuntimeException();
+
+ if ( !impl_findObjectProperty_nothrow( _rPropertyName ) )
+ return;
+
+ getPropertyBox().RemoveEntry( _rPropertyName );
+ }
+
+ //------------------------------------------------------------------------
+ void OPropertyBrowserController::showCategory( const ::rtl::OUString& _rCategory, sal_Bool _bShow ) throw (RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ if ( !haveView() )
+ throw RuntimeException();
+
+ sal_uInt16 nPageId = impl_getPageIdForCategory_nothrow( _rCategory );
+ OSL_ENSURE( nPageId != (sal_uInt16)-1, "OPropertyBrowserController::showCategory: invalid category!" );
+
+ getPropertyBox().ShowPropertyPage( nPageId, _bShow );
+ }
+
+ //------------------------------------------------------------------------
+ Reference< XPropertyControl > SAL_CALL OPropertyBrowserController::getPropertyControl( const ::rtl::OUString& _rPropertyName ) throw (RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ if ( !haveView() )
+ throw RuntimeException();
+
+ Reference< XPropertyControl > xControl( getPropertyBox().GetPropertyControl( _rPropertyName ) );
+ return xControl;
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL OPropertyBrowserController::registerControlObserver( const Reference< XPropertyControlObserver >& _Observer ) throw (RuntimeException)
+ {
+ m_aControlObservers.addInterface( _Observer );
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL OPropertyBrowserController::revokeControlObserver( const Reference< XPropertyControlObserver >& _Observer ) throw (RuntimeException)
+ {
+ m_aControlObservers.removeInterface( _Observer );
+ }
+
+ //------------------------------------------------------------------------
+ void SAL_CALL OPropertyBrowserController::setHelpSectionText( const ::rtl::OUString& _rHelpText ) throw (NoSupportException, RuntimeException)
+ {
+ SolarMutexGuard aSolarGuard;
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ if ( !haveView() )
+ throw DisposedException();
+
+ if ( !getPropertyBox().HasHelpSection() )
+ throw NoSupportException();
+
+ getPropertyBox().SetHelpText( _rHelpText );
+ }
+
+ //------------------------------------------------------------------------
+ void OPropertyBrowserController::impl_broadcastPropertyChange_nothrow( const ::rtl::OUString& _rPropertyName, const Any& _rNewValue, const Any& _rOldValue, bool _bFirstTimeInit ) const
+ {
+ // are there one or more handlers which are interested in the actuation?
+ ::std::pair< PropertyHandlerMultiRepository::const_iterator, PropertyHandlerMultiRepository::const_iterator > aInterestedHandlers =
+ m_aDependencyHandlers.equal_range( _rPropertyName );
+ if ( aInterestedHandlers.first == aInterestedHandlers.second )
+ // none of our handlers is interested in this
+ return;
+
+ ComposedUIAutoFireGuard aAutoFireGuard( *m_pUIRequestComposer );
+ try
+ {
+ // collect the responses from all interested handlers
+ PropertyHandlerMultiRepository::const_iterator handler = aInterestedHandlers.first;
+ while ( handler != aInterestedHandlers.second )
+ {
+ handler->second->actuatingPropertyChanged( _rPropertyName, _rNewValue, _rOldValue,
+ m_pUIRequestComposer->getUIForPropertyHandler( handler->second ),
+ _bFirstTimeInit );
+ ++handler;
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+
+//............................................................................
+} // namespace pcr
+//............................................................................
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/propctrlr/propcontroller.hxx b/extensions/source/propctrlr/propcontroller.hxx
new file mode 100644
index 000000000000..74d45dd48371
--- /dev/null
+++ b/extensions/source/propctrlr/propcontroller.hxx
@@ -0,0 +1,430 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _EXTENSIONS_PROPCTRLR_PROPCONTROLLER_HXX_
+#define _EXTENSIONS_PROPCTRLR_PROPCONTROLLER_HXX_
+
+#include "composeduiupdate.hxx"
+#include "formbrowsertools.hxx"
+#include "formmetadata.hxx"
+#include "proplinelistener.hxx"
+#include "propcontrolobserver.hxx"
+#include "browserview.hxx"
+#include "modulepcr.hxx"
+#include "propertyinfo.hxx"
+#include "pcrcomponentcontext.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/awt/XFocusListener.hpp>
+#include <com/sun/star/beans/XPropertyState.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/beans/XPropertyChangeListener.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/uno/XComponentContext.hpp>
+#include <com/sun/star/form/XForm.hpp>
+#include <com/sun/star/script/XEventAttacherManager.hpp>
+#include <com/sun/star/sdbc/XRowSet.hpp>
+#include <com/sun/star/uno/Sequence.hxx>
+#include <com/sun/star/frame/XController.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/lang/XEventListener.hpp>
+#include <com/sun/star/sdbc/XConnection.hpp>
+#include <com/sun/star/awt/XLayoutConstrains.hpp>
+#include <com/sun/star/awt/XLayoutConstrains.hpp>
+#include <com/sun/star/awt/XControlContainer.hpp>
+#include <com/sun/star/inspection/XPropertyControlFactory.hpp>
+#include <com/sun/star/inspection/XObjectInspector.hpp>
+#include <com/sun/star/inspection/XObjectInspectorUI.hpp>
+#include <com/sun/star/inspection/XPropertyHandler.hpp>
+#include <com/sun/star/lang/XInitialization.hpp>
+/** === end UNO includes === **/
+#include <connectivity/dbtools.hxx>
+#include <cppuhelper/interfacecontainer.hxx>
+#include <cppuhelper/implbase7.hxx>
+#include <comphelper/broadcasthelper.hxx>
+
+#include <map>
+#include <hash_map>
+#include <vector>
+#include <memory>
+
+class SvNumberFormatsSupplierObj;
+class Font;
+class Window;
+class SfxItemSet;
+
+//............................................................................
+namespace pcr
+{
+//............................................................................
+
+ class OPropertyEditor;
+ struct OLineDescriptor;
+
+#if OSL_DEBUG_LEVEL > 0
+ const char* CheckPropertyBrowserInvariants( const void* pVoid );
+ // for dignostics with DBG_CHKTHIS
+#endif
+ DBG_NAMEEX( OPropertyBrowserController )
+
+ //========================================================================
+ //= OPropertyBrowserController
+ //========================================================================
+ // #95343#------------------------------------------------------------------------------------
+ typedef ::cppu::WeakImplHelper7 < ::com::sun::star::lang::XServiceInfo
+ , ::com::sun::star::awt::XFocusListener
+ , ::com::sun::star::awt::XLayoutConstrains
+ , ::com::sun::star::beans::XPropertyChangeListener
+ , ::com::sun::star::inspection::XPropertyControlFactory
+ , ::com::sun::star::inspection::XObjectInspector
+ , ::com::sun::star::lang::XInitialization
+ > OPropertyBrowserController_Base;
+
+ class OPropertyBrowserController
+ :public ::comphelper::OMutexAndBroadcastHelper
+ ,public OPropertyBrowserController_Base
+ ,public ::com::sun::star::inspection::XObjectInspectorUI
+ // that's intentionally *not* part of the OPropertyBrowserController_Base
+ // We do not want this to be available in queryInterface, getTypes, and the like.
+ ,public IPropertyLineListener
+ ,public IPropertyControlObserver
+ ,public IPropertyExistenceCheck
+ {
+ private:
+ typedef ::std::map< sal_Int32, ::com::sun::star::beans::Property > OrderedPropertyMap;
+ typedef ::std::vector< ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > >
+ InterfaceArray;
+
+ protected:
+ ComponentContext m_aContext;
+
+ private:
+ ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > m_xFrame;
+ ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > m_xView;
+
+ ::cppu::OInterfaceContainerHelper m_aDisposeListeners;
+ ::cppu::OInterfaceContainerHelper m_aControlObservers;
+ // meta data about the properties
+ OPropertyBrowserView* m_pView;
+
+ ::rtl::OUString m_sPageSelection;
+ ::rtl::OUString m_sLastValidPageSelection;
+
+ typedef ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyHandler >
+ PropertyHandlerRef;
+ typedef ::std::vector< PropertyHandlerRef > PropertyHandlerArray;
+ typedef ::std::hash_map< ::rtl::OUString, PropertyHandlerRef, ::rtl::OUStringHash >
+ PropertyHandlerRepository;
+ typedef ::std::hash_multimap< ::rtl::OUString, PropertyHandlerRef, ::rtl::OUStringHash >
+ PropertyHandlerMultiRepository;
+ PropertyHandlerRepository m_aPropertyHandlers;
+ PropertyHandlerMultiRepository m_aDependencyHandlers;
+ PropertyHandlerRef m_xInteractiveHandler;
+
+ ::std::auto_ptr< ComposedPropertyUIUpdate > m_pUIRequestComposer;
+
+ /// our InspectorModel
+ ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XObjectInspectorModel >
+ m_xModel;
+ /// the object(s) we're currently inspecting
+ InterfaceArray m_aInspectedObjects;
+ /// the properties of the currently inspected object(s)
+ OrderedPropertyMap m_aProperties;
+ /// the property we're just committing
+ ::rtl::OUString m_sCommittingProperty;
+
+ typedef ::std::hash_map< ::rtl::OUString, sal_uInt16, ::rtl::OUStringHash > HashString2Int16;
+ HashString2Int16 m_aPageIds;
+
+ bool m_bContainerFocusListening;
+ bool m_bSuspendingPropertyHandlers;
+ bool m_bConstructed;
+ bool m_bBindingIntrospectee;
+
+ protected:
+ DECLARE_XINTERFACE()
+
+ // XServiceInfo
+ virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw(::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw(::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw(::com::sun::star::uno::RuntimeException);
+
+ // XController
+ virtual void SAL_CALL attachFrame( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& xFrame ) throw(::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL attachModel( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& xModel ) throw(::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL suspend( sal_Bool bSuspend ) throw(::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Any SAL_CALL getViewData( ) throw(::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL restoreViewData( const ::com::sun::star::uno::Any& Data ) throw(::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > SAL_CALL getModel( ) throw(::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > SAL_CALL getFrame( ) throw(::com::sun::star::uno::RuntimeException);
+
+ // 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 >& xListener ) 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);
+
+ // XFocusListener
+ virtual void SAL_CALL focusGained( const ::com::sun::star::awt::FocusEvent& _rSource ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL focusLost( const ::com::sun::star::awt::FocusEvent& _rSource ) throw (::com::sun::star::uno::RuntimeException);
+
+ // XEventListener
+ virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw(::com::sun::star::uno::RuntimeException);
+
+ // XLayoutConstrains #95343# ----------------
+ virtual ::com::sun::star::awt::Size SAL_CALL getMinimumSize( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::awt::Size SAL_CALL getPreferredSize( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::awt::Size SAL_CALL calcAdjustedSize( const ::com::sun::star::awt::Size& aNewSize ) throw (::com::sun::star::uno::RuntimeException);
+
+ // XPropertyChangeListener
+ virtual void SAL_CALL propertyChange( const ::com::sun::star::beans::PropertyChangeEvent& _rEvent ) throw (::com::sun::star::uno::RuntimeException);
+
+ /** XPropertyControlFactory
+ */
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyControl > SAL_CALL createPropertyControl( ::sal_Int16 ControlType, ::sal_Bool CreateReadOnly ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
+
+ public:
+ OPropertyBrowserController(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _rxContext);
+
+ protected:
+ virtual ~OPropertyBrowserController();
+
+ public:
+ // XServiceInfo - static versions
+ static ::rtl::OUString getImplementationName_static( ) throw(::com::sun::star::uno::RuntimeException);
+ static ::com::sun::star::uno::Sequence< ::rtl::OUString > getSupportedServiceNames_static( ) throw(::com::sun::star::uno::RuntimeException);
+ static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL
+ Create(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >&);
+
+ protected:
+ // IPropertyLineListener
+ virtual void Clicked( const ::rtl::OUString& _rName, sal_Bool _bPrimary );
+ virtual void Commit( const ::rtl::OUString& _rName, const ::com::sun::star::uno::Any& _rVal );
+
+ // IPropertyControlObserver
+ virtual void focusGained( const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyControl >& _Control );
+ virtual void valueChanged( const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyControl >& _Control );
+
+ // IPropertyExistenceCheck
+ virtual ::sal_Bool SAL_CALL hasPropertyByName( const ::rtl::OUString& _rName ) throw (::com::sun::star::uno::RuntimeException);
+
+ // XObjectInspectorUI
+ virtual void SAL_CALL enablePropertyUI( const ::rtl::OUString& _rPropertyName, ::sal_Bool _bEnable ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL enablePropertyUIElements( const ::rtl::OUString& _rPropertyName, ::sal_Int16 _nElements, ::sal_Bool _bEnable ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL rebuildPropertyUI( const ::rtl::OUString& _rPropertyName ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL showPropertyUI( const ::rtl::OUString& _rPropertyName ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL hidePropertyUI( const ::rtl::OUString& _rPropertyName ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL showCategory( const ::rtl::OUString& _rCategory, ::sal_Bool _bShow ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyControl > SAL_CALL getPropertyControl( const ::rtl::OUString& _rPropertyName ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL registerControlObserver( const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyControlObserver >& _Observer ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL revokeControlObserver( const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyControlObserver >& _Observer ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setHelpSectionText( const ::rtl::OUString& HelpText ) throw (::com::sun::star::lang::NoSupportException, ::com::sun::star::uno::RuntimeException);
+
+ // XObjectInspector
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XObjectInspectorModel > SAL_CALL getInspectorModel() throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setInspectorModel( const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XObjectInspectorModel >& _inspectormodel ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XObjectInspectorUI > SAL_CALL getInspectorUI() throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL inspect( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > >& Objects ) throw (::com::sun::star::util::VetoException, ::com::sun::star::uno::RuntimeException);
+
+ // XDispatchProvider
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch > SAL_CALL queryDispatch( const ::com::sun::star::util::URL& URL, const ::rtl::OUString& TargetFrameName, ::sal_Int32 SearchFlags ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch > > SAL_CALL queryDispatches( const ::com::sun::star::uno::Sequence< ::com::sun::star::frame::DispatchDescriptor >& Requests ) throw (::com::sun::star::uno::RuntimeException);
+
+ // 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:
+ void UpdateUI();
+
+ void startContainerWindowListening();
+ void stopContainerWindowListening();
+
+ // stop the inspection
+ void stopInspection( bool _bCommitModified );
+
+ sal_Bool haveView() const { return NULL != m_pView; }
+ OPropertyEditor& getPropertyBox() { return m_pView->getPropertyBox(); }
+
+ // does the inspection of the objects as indicated by our model
+ void doInspection();
+
+ // bind the browser to m_xIntrospecteeAsProperty
+ void impl_rebindToInspectee_nothrow( const InterfaceArray& _rObjects );
+
+ /** retrieves special property handlers for our introspectee
+ */
+ void getPropertyHandlers( const InterfaceArray& _rObjects, PropertyHandlerArray& _rHandlers );
+
+ /** called when a property changed, to broadcast any handlers which might have
+ registered for this property
+
+ @param _bFirstTimeInit
+ if set to <FALSE/>, this is a real change in the property value, not just a call
+ for purposes of initialization.
+ */
+ void impl_broadcastPropertyChange_nothrow( const ::rtl::OUString& _rPropertyName, const ::com::sun::star::uno::Any& _rNewValue, const ::com::sun::star::uno::Any& _rOldValue, bool _bFirstTimeInit ) const;
+
+ /** determines whether the given property is an actuating property, that is, at least one
+ handler expressed interest in changes to this property's value.
+ */
+ inline bool impl_isActuatingProperty_nothrow( const ::rtl::OUString& _rPropertyName ) const
+ {
+ return ( m_aDependencyHandlers.find( _rPropertyName ) != m_aDependencyHandlers.end() );
+ }
+
+ sal_uInt32 GetPropertyPos(const ::rtl::OUString& _rPropName);
+
+ /** retrieves the value of the given property, by asking the appropriate XPropertyHandler
+ @param _rPropertyName
+ the name whose handler is to be obtained. Must be the name of a property
+ for which a handler is registered.
+ @throws
+ RuntimeException if there is no handler for the given property
+ @return
+ the value of this property
+ */
+ ::com::sun::star::uno::Any
+ impl_getPropertyValue_throw( const ::rtl::OUString& _rPropertyName );
+
+ /// calls XPropertyHandler::suspend for all our property handlers
+ sal_Bool suspendPropertyHandlers_nothrow( sal_Bool _bSuspend );
+
+ /// suspends the complete inspector
+ sal_Bool suspendAll_nothrow();
+
+ /** selects a page according to our current view data
+ */
+ void selectPageFromViewData();
+
+ /** updates our view data from the currently active page
+ */
+ void updateViewDataFromActivePage();
+
+ /// describes the UI for the given property
+ void describePropertyLine( const ::com::sun::star::beans::Property& _rPropertyName, OLineDescriptor& _rDescriptor )
+ SAL_THROW((::com::sun::star::uno::Exception));
+
+ /** retrieves the position of the property given by name in m_aProperties
+ @return
+ <TRUE/> if and only if the property could be found. In this case, <arg>_pProperty</arg> (if
+ not <NULL/> contains the iterator pointing to this property.
+ */
+ bool impl_findObjectProperty_nothrow( const ::rtl::OUString& _rName, OrderedPropertyMap::const_iterator* _pProperty = NULL );
+
+ sal_Bool Construct(Window* _pParentWin);
+
+ /** retrieves the property handler for a given property name
+ @param _rPropertyName
+ the name whose handler is to be obtained. Must be the name of a property
+ for which a handler is registered.
+ @throws
+ RuntimeException if there is no handler for the given property
+ @return
+ the handler which is responsible for the given property
+ */
+ PropertyHandlerRef
+ impl_getHandlerForProperty_throw( const ::rtl::OUString& _rPropertyName ) const;
+
+ /** determines whether we have a handler for the given property
+ @param _rPropertyName
+ the name of the property for which the existence of a handler should be checked
+ */
+ bool
+ impl_hasPropertyHandlerFor_nothrow( const ::rtl::OUString& _rPropertyName ) const;
+
+ /** builds up m_aPageIds from InspectorModel::describeCategories, and insert all the
+ respective tab pages into our view
+ @precond
+ m_aPageIds is empty
+ @throws ::com::sun::star::uno::RuntimeException
+ if one of the callees of this method throws this exception
+ */
+ void
+ impl_buildCategories_throw();
+
+ /** retrieves the id of the tab page which represents a given category.
+ @param _rCategoryName
+ the programmatic name of a category.
+ @return
+ the id of the tab page, or <code>(sal_uInt16)-1</code> if there
+ is no tab page for the given category
+ */
+ sal_uInt16
+ impl_getPageIdForCategory_nothrow( const ::rtl::OUString& _rCategoryName ) const;
+
+ /** adds or removes ourself as XEventListener to/from all our inspectees
+ */
+ void impl_toggleInspecteeListening_nothrow( bool _bOn );
+
+ /** binds the instance to a new model
+ */
+ void impl_bindToNewModel_nothrow( const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XObjectInspectorModel >& _rxInspectorModel );
+
+ /** initializes our view, as indicated by the model's view-relevant properties
+
+ It's allowed to call this method when no model exists, yet. In this case, nothing
+ happens.
+ */
+ void impl_initializeView_nothrow();
+
+ /** determines whether the view should be readonly.
+
+ Effectively, this means that the method simply checks the IsReadOnly attribute of the model.
+ If there is no model, <FALSE/> is returned.
+
+ @throws ::com::sun::star::uno::RuntimeException
+ in case asking the model for its IsReadOnly attribute throws a ::com::sun::star::uno::RuntimeException
+ itself.
+ */
+ bool impl_isReadOnlyModel_throw() const;
+
+ /** updates our view so that it is read-only, as indicated by the model property
+ @see impl_isReadOnlyModel_throw
+ */
+ void impl_updateReadOnlyView_nothrow();
+
+ /** starts or stops listening at the model
+ */
+ void impl_startOrStopModelListening_nothrow( bool _bDoListen ) const;
+
+ private:
+ DECL_LINK(OnPageActivation, void*);
+
+ private:
+ // constructors
+ void createDefault();
+ void createWithModel( const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XObjectInspectorModel >& _rxModel );
+ };
+
+//............................................................................
+} // namespace pcr
+//............................................................................
+
+#endif // _EXTENSIONS_PROPCTRLR_PROPCONTROLLER_HXX_
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/propctrlr/propcontrolobserver.hxx b/extensions/source/propctrlr/propcontrolobserver.hxx
new file mode 100644
index 000000000000..fc4fcf2b36e4
--- /dev/null
+++ b/extensions/source/propctrlr/propcontrolobserver.hxx
@@ -0,0 +1,58 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef PROPCONTROLOBSERVER_HXX
+#define PROPCONTROLOBSERVER_HXX
+
+/** === begin UNO includes === **/
+#include <com/sun/star/inspection/XPropertyControl.hpp>
+/** === end UNO includes === **/
+
+//........................................................................
+namespace pcr
+{
+//........................................................................
+
+ //====================================================================
+ //= IPropertyControlObserver
+ //====================================================================
+ /** non-UNO version of the XPropertyControlObserver
+ */
+ class IPropertyControlObserver
+ {
+ public:
+ virtual void focusGained( const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyControl >& _Control ) = 0;
+ virtual void valueChanged( const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyControl >& _Control ) = 0;
+ };
+
+//........................................................................
+} // namespace pcr
+//........................................................................
+
+#endif // PROPCONTROLOBSERVER_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/propctrlr/propertycomposer.cxx b/extensions/source/propctrlr/propertycomposer.cxx
new file mode 100644
index 000000000000..469a4606d397
--- /dev/null
+++ b/extensions/source/propctrlr/propertycomposer.cxx
@@ -0,0 +1,518 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+#include "propertycomposer.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/lang/NullPointerException.hpp>
+#include <com/sun/star/lang/IllegalArgumentException.hpp>
+/** === end UNO includes === **/
+#include <osl/diagnose.h>
+#include <tools/diagnose_ex.h>
+
+#include <functional>
+#include <algorithm>
+#include <map>
+
+//........................................................................
+namespace pcr
+{
+//........................................................................
+
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::beans;
+ using namespace ::com::sun::star::lang;
+ using namespace ::com::sun::star::inspection;
+
+ //====================================================================
+ //= helper
+ //====================================================================
+ namespace
+ {
+ //----------------------------------------------------------------
+ struct SetPropertyValue : public ::std::unary_function< Reference< XPropertyHandler >, void >
+ {
+ ::rtl::OUString sPropertyName;
+ const Any& rValue;
+ SetPropertyValue( const ::rtl::OUString& _rPropertyName, const Any& _rValue ) : sPropertyName( _rPropertyName ), rValue( _rValue ) { }
+ void operator()( const Reference< XPropertyHandler >& _rHandler )
+ {
+ _rHandler->setPropertyValue( sPropertyName, rValue );
+ }
+ };
+
+ //----------------------------------------------------------------
+ template < class BagType >
+ void putIntoBag( const Sequence< typename BagType::value_type >& _rArray, BagType& /* [out] */ _rBag )
+ {
+ ::std::copy( _rArray.getConstArray(), _rArray.getConstArray() + _rArray.getLength(),
+ ::std::insert_iterator< BagType >( _rBag, _rBag.begin() ) );
+ }
+
+ //----------------------------------------------------------------
+ template < class BagType >
+ void copyBagToArray( const BagType& /* [out] */ _rBag, Sequence< typename BagType::value_type >& _rArray )
+ {
+ _rArray.realloc( _rBag.size() );
+ ::std::copy( _rBag.begin(), _rBag.end(), _rArray.getArray() );
+ }
+ }
+
+ //====================================================================
+ //= PropertyComposer
+ //====================================================================
+
+ // TODO: there are various places where we determine the first handler in our array which
+ // supports a given property id. This is, at the moment, done with searching all handlers,
+ // which is O( n * k ) at worst (n being the number of handlers, k being the maximum number
+ // of supported properties per handler). Shouldn't we cache this? So that it is O( log k )?
+
+ //--------------------------------------------------------------------
+ PropertyComposer::PropertyComposer( const ::std::vector< Reference< XPropertyHandler > >& _rSlaveHandlers )
+ :PropertyComposer_Base ( m_aMutex )
+ ,m_aSlaveHandlers ( _rSlaveHandlers )
+ ,m_aPropertyListeners ( m_aMutex )
+ ,m_bSupportedPropertiesAreKnown ( false )
+ {
+ if ( m_aSlaveHandlers.empty() )
+ throw IllegalArgumentException();
+
+ osl_incrementInterlockedCount( &m_refCount );
+ {
+ Reference< XPropertyChangeListener > xMeMyselfAndI( this );
+ for ( HandlerArray::const_iterator loop = m_aSlaveHandlers.begin();
+ loop != m_aSlaveHandlers.end();
+ ++loop
+ )
+ {
+ if ( !loop->is() )
+ throw NullPointerException();
+ (*loop)->addPropertyChangeListener( xMeMyselfAndI );
+ }
+ }
+ osl_decrementInterlockedCount( &m_refCount );
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL PropertyComposer::inspect( const Reference< XInterface >& _rxIntrospectee ) throw (RuntimeException, NullPointerException)
+ {
+ MethodGuard aGuard( *this );
+
+ for ( HandlerArray::const_iterator loop = m_aSlaveHandlers.begin();
+ loop != m_aSlaveHandlers.end();
+ ++loop
+ )
+ {
+ (*loop)->inspect( _rxIntrospectee );
+ }
+ }
+
+ //--------------------------------------------------------------------
+ Any SAL_CALL PropertyComposer::getPropertyValue( const ::rtl::OUString& _rPropertyName ) throw (UnknownPropertyException, RuntimeException)
+ {
+ MethodGuard aGuard( *this );
+ return m_aSlaveHandlers[0]->getPropertyValue( _rPropertyName );
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL PropertyComposer::setPropertyValue( const ::rtl::OUString& _rPropertyName, const Any& _rValue ) throw (UnknownPropertyException, RuntimeException)
+ {
+ MethodGuard aGuard( *this );
+ ::std::for_each( m_aSlaveHandlers.begin(), m_aSlaveHandlers.end(), SetPropertyValue( _rPropertyName, _rValue ) );
+ }
+
+ //--------------------------------------------------------------------
+ Any SAL_CALL PropertyComposer::convertToPropertyValue( const ::rtl::OUString& _rPropertyName, const Any& _rControlValue ) throw (UnknownPropertyException, RuntimeException)
+ {
+ MethodGuard aGuard( *this );
+ return m_aSlaveHandlers[0]->convertToPropertyValue( _rPropertyName, _rControlValue );
+ }
+
+ //--------------------------------------------------------------------
+ Any SAL_CALL PropertyComposer::convertToControlValue( const ::rtl::OUString& _rPropertyName, const Any& _rPropertyValue, const Type& _rControlValueType ) throw (UnknownPropertyException, RuntimeException)
+ {
+ MethodGuard aGuard( *this );
+ return m_aSlaveHandlers[0]->convertToControlValue( _rPropertyName, _rPropertyValue, _rControlValueType );
+ }
+
+ //--------------------------------------------------------------------
+ PropertyState SAL_CALL PropertyComposer::getPropertyState( const ::rtl::OUString& _rPropertyName ) throw (UnknownPropertyException, RuntimeException)
+ {
+ MethodGuard aGuard( *this );
+
+ // assume DIRECT for the moment. This will stay this way if *all* slaves
+ // tell the property has DIRECT state, and if *all* values equal
+ PropertyState eState = PropertyState_DIRECT_VALUE;
+
+ // check the master state
+ Reference< XPropertyHandler > xPrimary( *m_aSlaveHandlers.begin() );
+ Any aPrimaryValue = xPrimary->getPropertyValue( _rPropertyName );
+ eState = xPrimary->getPropertyState( _rPropertyName );
+
+ // loop through the secondary sets
+ PropertyState eSecondaryState = PropertyState_DIRECT_VALUE;
+ for ( HandlerArray::const_iterator loop = ( m_aSlaveHandlers.begin() + 1 );
+ loop != m_aSlaveHandlers.end();
+ ++loop
+ )
+ {
+ // the secondary state
+ eSecondaryState = (*loop)->getPropertyState( _rPropertyName );
+
+ // the secondary value
+ Any aSecondaryValue( (*loop)->getPropertyValue( _rPropertyName ) );
+
+ if ( ( PropertyState_AMBIGUOUS_VALUE == eSecondaryState ) // secondary is ambiguous
+ || ( aPrimaryValue != aSecondaryValue ) // unequal values
+ )
+ {
+ eState = PropertyState_AMBIGUOUS_VALUE;
+ break;
+ }
+ }
+
+ return eState;
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL PropertyComposer::addPropertyChangeListener( const Reference< XPropertyChangeListener >& _rxListener ) throw (RuntimeException)
+ {
+ MethodGuard aGuard( *this );
+ m_aPropertyListeners.addListener( _rxListener );
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL PropertyComposer::removePropertyChangeListener( const Reference< XPropertyChangeListener >& _rxListener ) throw (RuntimeException)
+ {
+ MethodGuard aGuard( *this );
+ m_aPropertyListeners.removeListener( _rxListener );
+ }
+
+ //--------------------------------------------------------------------
+ Sequence< Property > SAL_CALL PropertyComposer::getSupportedProperties() throw (RuntimeException)
+ {
+ MethodGuard aGuard( *this );
+
+ if ( !m_bSupportedPropertiesAreKnown )
+ {
+ // we support a property if and only if all of our slaves support it
+
+ // initially, use all the properties of an arbitrary handler (we take the first one)
+ putIntoBag( (*m_aSlaveHandlers.begin())->getSupportedProperties(), m_aSupportedProperties );
+
+ // now intersect with the properties of *all* other handlers
+ for ( HandlerArray::const_iterator loop = ( m_aSlaveHandlers.begin() + 1 );
+ loop != m_aSlaveHandlers.end();
+ ++loop
+ )
+ {
+ // the properties supported by the current handler
+ PropertyBag aThisRound;
+ putIntoBag( (*loop)->getSupportedProperties(), aThisRound );
+
+ // the intersection of those properties with all we already have
+ PropertyBag aIntersection;
+ ::std::set_intersection( aThisRound.begin(), aThisRound.end(), m_aSupportedProperties.begin(), m_aSupportedProperties.end(),
+ ::std::insert_iterator< PropertyBag >( aIntersection, aIntersection.begin() ), PropertyLessByName() );
+
+ m_aSupportedProperties.swap( aIntersection );
+ if ( m_aSupportedProperties.empty() )
+ break;
+ }
+
+ // remove those properties which are not composable
+ for ( PropertyBag::iterator check = m_aSupportedProperties.begin();
+ check != m_aSupportedProperties.end();
+ )
+ {
+ sal_Bool bIsComposable = isComposable( check->Name );
+ if ( !bIsComposable )
+ {
+ PropertyBag::iterator next = check; ++next;
+ m_aSupportedProperties.erase( check );
+ check = next;
+ }
+ else
+ ++check;
+ }
+
+ m_bSupportedPropertiesAreKnown = true;
+ }
+
+ Sequence< Property > aSurvived;
+ copyBagToArray( m_aSupportedProperties, aSurvived );
+ return aSurvived;
+ }
+
+ //--------------------------------------------------------------------
+ void uniteStringArrays( const PropertyComposer::HandlerArray& _rHandlers, Sequence< ::rtl::OUString > (SAL_CALL XPropertyHandler::*pGetter)( void ),
+ Sequence< ::rtl::OUString >& /* [out] */ _rUnion )
+ {
+ ::std::set< ::rtl::OUString > aUnitedBag;
+
+ Sequence< ::rtl::OUString > aThisRound;
+ for ( PropertyComposer::HandlerArray::const_iterator loop = _rHandlers.begin();
+ loop != _rHandlers.end();
+ ++loop
+ )
+ {
+ aThisRound = (loop->get()->*pGetter)();
+ putIntoBag( aThisRound, aUnitedBag );
+ }
+
+ copyBagToArray( aUnitedBag, _rUnion );
+ }
+
+ //--------------------------------------------------------------------
+ Sequence< ::rtl::OUString > SAL_CALL PropertyComposer::getSupersededProperties( ) throw (RuntimeException)
+ {
+ MethodGuard aGuard( *this );
+
+ // we supersede those properties which are superseded by at least one of our slaves
+ Sequence< ::rtl::OUString > aSuperseded;
+ uniteStringArrays( m_aSlaveHandlers, &XPropertyHandler::getSupersededProperties, aSuperseded );
+ return aSuperseded;
+ }
+
+ //--------------------------------------------------------------------
+ Sequence< ::rtl::OUString > SAL_CALL PropertyComposer::getActuatingProperties( ) throw (RuntimeException)
+ {
+ MethodGuard aGuard( *this );
+
+ // we're interested in those properties which at least one handler wants to have
+ Sequence< ::rtl::OUString > aActuating;
+ uniteStringArrays( m_aSlaveHandlers, &XPropertyHandler::getActuatingProperties, aActuating );
+ return aActuating;
+ }
+
+ //--------------------------------------------------------------------
+ LineDescriptor SAL_CALL PropertyComposer::describePropertyLine( const ::rtl::OUString& _rPropertyName,
+ const Reference< XPropertyControlFactory >& _rxControlFactory )
+ throw (UnknownPropertyException, NullPointerException, RuntimeException)
+ {
+ MethodGuard aGuard( *this );
+ return m_aSlaveHandlers[0]->describePropertyLine( _rPropertyName, _rxControlFactory );
+ }
+
+ //--------------------------------------------------------------------
+ ::sal_Bool SAL_CALL PropertyComposer::isComposable( const ::rtl::OUString& _rPropertyName ) throw (UnknownPropertyException, RuntimeException)
+ {
+ MethodGuard aGuard( *this );
+ return m_aSlaveHandlers[0]->isComposable( _rPropertyName );
+ }
+
+ //--------------------------------------------------------------------
+ InteractiveSelectionResult SAL_CALL PropertyComposer::onInteractivePropertySelection( const ::rtl::OUString& _rPropertyName, sal_Bool _bPrimary, Any& _rData, const Reference< XObjectInspectorUI >& _rxInspectorUI ) throw (UnknownPropertyException, NullPointerException, RuntimeException)
+ {
+ if ( !_rxInspectorUI.is() )
+ throw NullPointerException();
+
+ MethodGuard aGuard( *this );
+
+ impl_ensureUIRequestComposer( _rxInspectorUI );
+ ComposedUIAutoFireGuard aAutoFireGuard( *m_pUIRequestComposer );
+
+ // ask the first of the handlers
+ InteractiveSelectionResult eResult = (*m_aSlaveHandlers.begin())->onInteractivePropertySelection(
+ _rPropertyName,
+ _bPrimary,
+ _rData,
+ m_pUIRequestComposer->getUIForPropertyHandler( *m_aSlaveHandlers.begin() )
+ );
+
+ switch ( eResult )
+ {
+ case InteractiveSelectionResult_Cancelled:
+ // fine
+ break;
+
+ case InteractiveSelectionResult_Success:
+ case InteractiveSelectionResult_Pending:
+ OSL_ENSURE( false, "PropertyComposer::onInteractivePropertySelection: no chance to forward the new value to the other handlers!" );
+ // This means that we cannot know the new property value, which either has already been set
+ // at the first component ("Success"), or will be set later on once the asynchronous input
+ // is finished ("Pending"). So, we also cannot forward this new property value to the other
+ // handlers.
+ // We would need to be a listener at the property at the first component, but even this wouldn't
+ // be sufficient, since the property handler is free to change *any* property during a dedicated
+ // property UI.
+ eResult = InteractiveSelectionResult_Cancelled;
+ break;
+
+ case InteractiveSelectionResult_ObtainedValue:
+ // OK. Our own caller will pass this as setPropertyValue, and we will then pass it to
+ // all slave handlers
+ break;
+
+ default:
+ OSL_ENSURE( false, "OPropertyBrowserController::onInteractivePropertySelection: unknown result value!" );
+ break;
+ }
+
+ return eResult;
+ }
+
+ //--------------------------------------------------------------------
+ void PropertyComposer::impl_ensureUIRequestComposer( const Reference< XObjectInspectorUI >& _rxInspectorUI )
+ {
+ OSL_ENSURE( !m_pUIRequestComposer.get() || m_pUIRequestComposer->getDelegatorUI().get() == _rxInspectorUI.get(),
+ "PropertyComposer::impl_ensureUIRequestComposer: somebody's changing the horse in the mid of the race!" );
+
+ if ( !m_pUIRequestComposer.get() )
+ m_pUIRequestComposer.reset( new ComposedPropertyUIUpdate( _rxInspectorUI, this ) );
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL PropertyComposer::actuatingPropertyChanged( const ::rtl::OUString& _rActuatingPropertyName, const Any& _rNewValue, const Any& _rOldValue, const Reference< XObjectInspectorUI >& _rxInspectorUI, sal_Bool _bFirstTimeInit ) throw (NullPointerException, RuntimeException)
+ {
+ if ( !_rxInspectorUI.is() )
+ throw NullPointerException();
+
+ MethodGuard aGuard( *this );
+
+ impl_ensureUIRequestComposer( _rxInspectorUI );
+ ComposedUIAutoFireGuard aAutoFireGuard( *m_pUIRequestComposer );
+
+ // ask all handlers which expressed interest in this particular property, and "compose" their
+ // commands for the UIUpdater
+ for ( HandlerArray::const_iterator loop = m_aSlaveHandlers.begin();
+ loop != m_aSlaveHandlers.end();
+ ++loop
+ )
+ {
+ // TODO: make this cheaper (cache it?)
+ const StlSyntaxSequence< ::rtl::OUString > aThisHandlersActuatingProps = (*loop)->getActuatingProperties();
+ for ( StlSyntaxSequence< ::rtl::OUString >::const_iterator loopProps = aThisHandlersActuatingProps.begin();
+ loopProps != aThisHandlersActuatingProps.end();
+ ++loopProps
+ )
+ {
+ if ( *loopProps == _rActuatingPropertyName )
+ {
+ (*loop)->actuatingPropertyChanged( _rActuatingPropertyName, _rNewValue, _rOldValue,
+ m_pUIRequestComposer->getUIForPropertyHandler( *loop ),
+ _bFirstTimeInit );
+ break;
+ }
+ }
+ }
+ }
+
+ //--------------------------------------------------------------------
+ IMPLEMENT_FORWARD_XCOMPONENT( PropertyComposer, PropertyComposer_Base )
+
+ //--------------------------------------------------------------------
+ void SAL_CALL PropertyComposer::disposing()
+ {
+ MethodGuard aGuard( *this );
+
+ // dispose our slave handlers
+ for ( PropertyComposer::HandlerArray::const_iterator loop = m_aSlaveHandlers.begin();
+ loop != m_aSlaveHandlers.end();
+ ++loop
+ )
+ {
+ (*loop)->removePropertyChangeListener( this );
+ (*loop)->dispose();
+ }
+
+ clearContainer( m_aSlaveHandlers );
+
+ if ( m_pUIRequestComposer.get() )
+ m_pUIRequestComposer->dispose();
+ m_pUIRequestComposer.reset( NULL );
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL PropertyComposer::propertyChange( const PropertyChangeEvent& evt ) throw (RuntimeException)
+ {
+ if ( !impl_isSupportedProperty_nothrow( evt.PropertyName ) )
+ // A slave handler might fire events for more properties than we support. Ignore those.
+ return;
+
+ PropertyChangeEvent aTranslatedEvent( evt );
+ try
+ {
+ aTranslatedEvent.NewValue = getPropertyValue( evt.PropertyName );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ m_aPropertyListeners.notify( aTranslatedEvent, &XPropertyChangeListener::propertyChange );
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL PropertyComposer::disposing( const EventObject& Source ) throw (RuntimeException)
+ {
+ MethodGuard aGuard( *this );
+ m_aPropertyListeners.disposing( Source );
+ }
+
+ //--------------------------------------------------------------------
+ sal_Bool SAL_CALL PropertyComposer::suspend( sal_Bool _bSuspend ) throw (RuntimeException)
+ {
+ MethodGuard aGuard( *this );
+ for ( PropertyComposer::HandlerArray::const_iterator loop = m_aSlaveHandlers.begin();
+ loop != m_aSlaveHandlers.end();
+ ++loop
+ )
+ {
+ if ( !(*loop)->suspend( _bSuspend ) )
+ {
+ if ( _bSuspend && ( loop != m_aSlaveHandlers.begin() ) )
+ {
+ // if we tried to suspend, but one of the slave handlers vetoed,
+ // re-activate the handlers which actually did *not* veto
+ // the suspension
+ do
+ {
+ --loop;
+ (*loop)->suspend( sal_False );
+ }
+ while ( loop != m_aSlaveHandlers.begin() );
+ }
+ return false;
+ }
+ }
+ return true;
+ }
+
+ //--------------------------------------------------------------------
+ sal_Bool SAL_CALL PropertyComposer::hasPropertyByName( const ::rtl::OUString& _rName ) throw (RuntimeException)
+ {
+ return impl_isSupportedProperty_nothrow( _rName );
+ }
+
+//........................................................................
+} // namespace pcr
+//........................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/propctrlr/propertycomposer.hxx b/extensions/source/propctrlr/propertycomposer.hxx
new file mode 100644
index 000000000000..645023ad71c9
--- /dev/null
+++ b/extensions/source/propctrlr/propertycomposer.hxx
@@ -0,0 +1,159 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef EXTENSIONS_SOURCE_PROPCTRLR_PROPERTYCOMPOSER_HXX
+#define EXTENSIONS_SOURCE_PROPCTRLR_PROPERTYCOMPOSER_HXX
+
+#include "pcrcommon.hxx"
+#include "formbrowsertools.hxx"
+#include "composeduiupdate.hxx"
+#include "formbrowsertools.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/inspection/XPropertyHandler.hpp>
+#include <com/sun/star/lang/DisposedException.hpp>
+/** === end UNO includes === **/
+#include <cppuhelper/compbase2.hxx>
+#include <comphelper/broadcasthelper.hxx>
+#include <comphelper/listenernotification.hxx>
+
+#include <vector>
+#include <set>
+
+//........................................................................
+namespace pcr
+{
+//........................................................................
+
+ //====================================================================
+ //= PropertyComposer
+ //====================================================================
+ typedef ::cppu::WeakComponentImplHelper2 < ::com::sun::star::inspection::XPropertyHandler
+ , ::com::sun::star::beans::XPropertyChangeListener
+ > PropertyComposer_Base;
+ /** implements an <type>XPropertyHandler</type> which composes it's information
+ from a set of other property handlers
+ */
+ class PropertyComposer :public PropertyComposer_Base
+ ,public ::comphelper::OBaseMutex
+ ,public IPropertyExistenceCheck
+ {
+ public:
+ typedef ::std::vector< ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyHandler > >
+ HandlerArray;
+
+ private:
+ HandlerArray m_aSlaveHandlers;
+ ::std::auto_ptr< ComposedPropertyUIUpdate > m_pUIRequestComposer;
+ PropertyChangeListeners m_aPropertyListeners;
+ bool m_bSupportedPropertiesAreKnown;
+ PropertyBag m_aSupportedProperties;
+
+ public:
+ /** constructs an <type>XPropertyHandler</type> which composes it's information from a set
+ of other property handlers
+
+ @param _rSlaveHandlers
+ the set of slave handlers to invoke. Must not be <NULL/>
+ */
+ PropertyComposer( const ::std::vector< ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyHandler > >& _rSlaveHandlers );
+
+ public:
+ // XPropertyHandler overridables
+ virtual void SAL_CALL inspect( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxIntrospectee ) throw (::com::sun::star::lang::NullPointerException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue( const ::rtl::OUString& _rPropertyName ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setPropertyValue( const ::rtl::OUString& _rPropertyName, const ::com::sun::star::uno::Any& _rValue ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Any SAL_CALL convertToPropertyValue( const ::rtl::OUString& _rPropertyName, const ::com::sun::star::uno::Any& _rControlValue ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Any SAL_CALL convertToControlValue( const ::rtl::OUString& _rPropertyName, const ::com::sun::star::uno::Any& _rPropertyValue, const ::com::sun::star::uno::Type& _rControlValueType ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::beans::PropertyState
+ SAL_CALL getPropertyState( const ::rtl::OUString& _rPropertyName ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL addPropertyChangeListener( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& _rxListener ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL removePropertyChangeListener( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& _rxListener ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property >
+ SAL_CALL getSupportedProperties() throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString >
+ SAL_CALL getSupersededProperties( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString >
+ SAL_CALL getActuatingProperties( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::inspection::LineDescriptor
+ SAL_CALL describePropertyLine( const ::rtl::OUString& _rPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyControlFactory >& _rxControlFactory ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::NullPointerException, ::com::sun::star::uno::RuntimeException);
+ virtual ::sal_Bool SAL_CALL isComposable( const ::rtl::OUString& _rPropertyName ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::inspection::InteractiveSelectionResult
+ SAL_CALL onInteractivePropertySelection( const ::rtl::OUString& _rPropertyName, sal_Bool _bPrimary, ::com::sun::star::uno::Any& _rData, const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XObjectInspectorUI >& _rxInspectorUI ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::NullPointerException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL actuatingPropertyChanged( const ::rtl::OUString& _rActuatingPropertyName, const ::com::sun::star::uno::Any& _rNewValue, const ::com::sun::star::uno::Any& _rOldValue, const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XObjectInspectorUI >& _rxInspectorUI, sal_Bool _bFirstTimeInit ) throw (::com::sun::star::lang::NullPointerException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL suspend( sal_Bool _bSuspend ) throw (::com::sun::star::uno::RuntimeException);
+
+ // XComponent
+ DECLARE_XCOMPONENT()
+ virtual void SAL_CALL disposing();
+
+ // XPropertyChangeListener
+ virtual void SAL_CALL propertyChange( const ::com::sun::star::beans::PropertyChangeEvent& evt ) throw (::com::sun::star::uno::RuntimeException);
+
+ // XEventListener
+ virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw (::com::sun::star::uno::RuntimeException);
+
+ // IPropertyExistenceCheck
+ virtual ::sal_Bool SAL_CALL hasPropertyByName( const ::rtl::OUString& _rName ) throw (::com::sun::star::uno::RuntimeException);
+
+ private:
+ /** ensures that m_pUIRequestComposer exists
+ */
+ void impl_ensureUIRequestComposer( const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XObjectInspectorUI >& _rxInspectorUI );
+
+ /** checks whether a given property exists in <member>m_aSupportedProperties</member>
+ */
+ bool impl_isSupportedProperty_nothrow( const ::rtl::OUString& _rPropertyName )
+ {
+ ::com::sun::star::beans::Property aDummy; aDummy.Name = _rPropertyName;
+ return m_aSupportedProperties.find( aDummy ) != m_aSupportedProperties.end();
+ }
+
+ private:
+ class MethodGuard;
+ friend class MethodGuard;
+ class MethodGuard : public ::osl::MutexGuard
+ {
+ public:
+ MethodGuard( PropertyComposer& _rInstance )
+ : ::osl::MutexGuard( _rInstance.m_aMutex )
+ {
+ if ( _rInstance.m_aSlaveHandlers.empty() )
+ throw ::com::sun::star::lang::DisposedException( ::rtl::OUString(), *(&_rInstance) );
+ }
+ };
+ };
+
+//........................................................................
+} // namespace pcr
+//........................................................................
+
+#endif // EXTENSIONS_SOURCE_PROPCTRLR_PROPERTYCOMPOSER_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/propctrlr/propertycontrolextender.cxx b/extensions/source/propctrlr/propertycontrolextender.cxx
new file mode 100644
index 000000000000..5b69e210489e
--- /dev/null
+++ b/extensions/source/propctrlr/propertycontrolextender.cxx
@@ -0,0 +1,146 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+
+#include "propertycontrolextender.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/awt/KeyFunction.hpp>
+/** === end UNO includes === **/
+
+#include <tools/diagnose_ex.h>
+
+//........................................................................
+namespace pcr
+{
+//........................................................................
+
+ /** === begin UNO using === **/
+ using ::com::sun::star::uno::Reference;
+ using ::com::sun::star::uno::XInterface;
+ using ::com::sun::star::uno::UNO_QUERY;
+ using ::com::sun::star::uno::UNO_QUERY_THROW;
+ using ::com::sun::star::uno::UNO_SET_THROW;
+ using ::com::sun::star::uno::Exception;
+ using ::com::sun::star::uno::RuntimeException;
+ using ::com::sun::star::uno::Any;
+ using ::com::sun::star::uno::makeAny;
+ using ::com::sun::star::uno::Sequence;
+ using ::com::sun::star::uno::Type;
+ using ::com::sun::star::awt::XWindow;
+ using ::com::sun::star::awt::KeyEvent;
+ using ::com::sun::star::inspection::XPropertyControl;
+ using ::com::sun::star::lang::EventObject;
+ using ::com::sun::star::inspection::XPropertyControlContext;
+ /** === end UNO using === **/
+ namespace KeyFunction = ::com::sun::star::awt::KeyFunction;
+
+ //====================================================================
+ //= PropertyControlExtender_Data
+ //====================================================================
+ struct PropertyControlExtender_Data
+ {
+ Reference< XPropertyControl > xControl;
+ Reference< XWindow > xControlWindow;
+ };
+
+ //====================================================================
+ //= PropertyControlExtender
+ //====================================================================
+ //--------------------------------------------------------------------
+ PropertyControlExtender::PropertyControlExtender( const Reference< XPropertyControl >& _rxObservedControl )
+ :m_pData( new PropertyControlExtender_Data )
+ {
+ try
+ {
+ m_pData->xControl.set( _rxObservedControl, UNO_SET_THROW );
+ m_pData->xControlWindow.set( m_pData->xControl->getControlWindow(), UNO_SET_THROW );
+ m_pData->xControlWindow->addKeyListener( this );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+
+ //--------------------------------------------------------------------
+ PropertyControlExtender::~PropertyControlExtender()
+ {
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL PropertyControlExtender::keyPressed( const KeyEvent& _event ) throw (RuntimeException)
+ {
+ OSL_ENSURE( _event.Source == m_pData->xControlWindow, "PropertyControlExtender::keyPressed: where does this come from?" );
+ if ( ( _event.KeyFunc == KeyFunction::DELETE )
+ && ( _event.Modifiers == 0 )
+ )
+ {
+ try
+ {
+ Reference< XPropertyControl > xControl( m_pData->xControl, UNO_SET_THROW );
+
+ // reset the value
+ xControl->setValue( Any() );
+
+ // and notify the change
+ // don't use XPropertyControl::notifyModifiedValue. It only notifies when the control content
+ // is recognized as being modified by the user, which is not the case, since we just modified
+ // it programmatically.
+ Reference< XPropertyControlContext > xControlContext( xControl->getControlContext(), UNO_SET_THROW );
+ xControlContext->valueChanged( xControl );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL PropertyControlExtender::keyReleased( const KeyEvent& /*_event*/ ) throw (RuntimeException)
+ {
+ // not interested in
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL PropertyControlExtender::disposing( const EventObject& Source ) throw (RuntimeException)
+ {
+ OSL_ENSURE( Source.Source == m_pData->xControlWindow, "PropertyControlExtender::disposing: where does this come from?" );
+ (void)Source.Source;
+ m_pData->xControlWindow.clear();
+ m_pData->xControl.clear();
+ }
+
+
+//........................................................................
+} // namespace pcr
+//........................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/propctrlr/propertycontrolextender.hxx b/extensions/source/propctrlr/propertycontrolextender.hxx
new file mode 100644
index 000000000000..12e300cc2d5c
--- /dev/null
+++ b/extensions/source/propctrlr/propertycontrolextender.hxx
@@ -0,0 +1,77 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+************************************************************************/
+
+#ifndef EXTENSIONS_PROPERTYCONTROLEXTENDER_HXX
+#define EXTENSIONS_PROPERTYCONTROLEXTENDER_HXX
+
+/** === begin UNO includes === **/
+#include <com/sun/star/awt/XKeyListener.hpp>
+#include <com/sun/star/inspection/XPropertyControl.hpp>
+/** === end UNO includes === **/
+
+#include <cppuhelper/implbase1.hxx>
+
+#include <memory>
+
+//........................................................................
+namespace pcr
+{
+//........................................................................
+
+ //====================================================================
+ //= PropertyControlExtender
+ //====================================================================
+ struct PropertyControlExtender_Data;
+ typedef ::cppu::WeakImplHelper1 < ::com::sun::star::awt::XKeyListener
+ > PropertyControlExtender_Base;
+ class PropertyControlExtender : public PropertyControlExtender_Base
+ {
+ public:
+ PropertyControlExtender(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyControl >& _rxObservedControl
+ );
+
+ // XKeyListener
+ virtual void SAL_CALL keyPressed( const ::com::sun::star::awt::KeyEvent& e ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL keyReleased( const ::com::sun::star::awt::KeyEvent& e ) throw (::com::sun::star::uno::RuntimeException);
+ // XEventListener
+ virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw (::com::sun::star::uno::RuntimeException);
+
+ protected:
+ virtual ~PropertyControlExtender();
+
+ private:
+ ::std::auto_ptr< PropertyControlExtender_Data > m_pData;
+ };
+
+//........................................................................
+} // namespace pcr
+//........................................................................
+
+#endif // EXTENSIONS_PROPERTYCONTROLEXTENDER_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/propctrlr/propertyeditor.cxx b/extensions/source/propctrlr/propertyeditor.cxx
new file mode 100644
index 000000000000..ebab4b66dbcb
--- /dev/null
+++ b/extensions/source/propctrlr/propertyeditor.cxx
@@ -0,0 +1,544 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+#include "propertyeditor.hxx"
+#include "browserpage.hxx"
+#include "linedescriptor.hxx"
+
+/** === begin UNO includes === **/
+/** === end UNO includes === **/
+#include <tools/debug.hxx>
+
+//............................................................................
+namespace pcr
+{
+//............................................................................
+
+ #define LAYOUT_BORDER_LEFT 3
+ #define LAYOUT_BORDER_TOP 3
+ #define LAYOUT_BORDER_RIGHT 3
+ #define LAYOUT_BORDER_BOTTOM 3
+
+ /** === begin UNO using === **/
+ using ::com::sun::star::uno::Any;
+ using ::com::sun::star::inspection::XPropertyControl;
+ using ::com::sun::star::uno::Reference;
+ /** === end UNO using === **/
+
+ //==================================================================
+ // class OPropertyEditor
+ //==================================================================
+ DBG_NAME(OPropertyEditor)
+ //------------------------------------------------------------------
+ OPropertyEditor::OPropertyEditor( Window* pParent, WinBits nWinStyle)
+ :Control(pParent, nWinStyle)
+ ,m_aTabControl( this )
+ ,m_nNextId(1)
+ ,m_bHasHelpSection( false )
+ ,m_nMinHelpLines( 0 )
+ ,m_nMaxHelpLines( 0 )
+ {
+ DBG_CTOR(OPropertyEditor,NULL);
+
+ m_aTabControl.Show();
+ m_aTabControl.SetDeactivatePageHdl(LINK(this, OPropertyEditor, OnPageDeactivate));
+ m_aTabControl.SetActivatePageHdl(LINK(this, OPropertyEditor, OnPageActivate));
+ m_aTabControl.SetBackground(GetBackground());
+ m_aTabControl.SetPaintTransparent(sal_True);
+ }
+
+ //------------------------------------------------------------------
+ OPropertyEditor::~OPropertyEditor()
+ {
+ Hide();
+ ClearAll();
+ DBG_DTOR(OPropertyEditor,NULL);
+ }
+
+ //------------------------------------------------------------------
+ void OPropertyEditor::ClearAll()
+ {
+ m_nNextId=1;
+ sal_uInt16 nCount = m_aTabControl.GetPageCount();
+ for(long i = nCount-1; i >= 0; --i)
+ {
+ sal_uInt16 nID = m_aTabControl.GetPageId((sal_uInt16)i);
+ OBrowserPage* pPage = static_cast<OBrowserPage*>(m_aTabControl.GetTabPage(nID));
+ if (pPage)
+ {
+ pPage->EnableInput(sal_False);
+ m_aTabControl.RemovePage(nID);
+ delete pPage;
+ }
+ }
+ m_aTabControl.Clear();
+
+ {
+ MapStringToPageId aEmpty;
+ m_aPropertyPageIds.swap( aEmpty );
+ }
+
+ while ( !m_aHiddenPages.empty() )
+ {
+ delete m_aHiddenPages.begin()->second.pPage;
+ m_aHiddenPages.erase( m_aHiddenPages.begin() );
+ }
+ }
+
+ //------------------------------------------------------------------
+ sal_Int32 OPropertyEditor::getMinimumHeight()
+ {
+ sal_Int32 nMinHeight( LAYOUT_BORDER_TOP + LAYOUT_BORDER_BOTTOM );
+
+ if ( m_aTabControl.GetPageCount() > 0 )
+ {
+ sal_uInt16 nFirstID = m_aTabControl.GetPageId( 0 );
+
+ // reserve space for the tabs themself
+ Rectangle aTabArea( m_aTabControl.GetTabBounds( nFirstID ) );
+ nMinHeight += aTabArea.GetHeight();
+
+ // ask the page how much it requires
+ OBrowserPage* pPage = static_cast< OBrowserPage* >( m_aTabControl.GetTabPage( nFirstID ) );
+ if ( pPage )
+ nMinHeight += pPage->getMinimumHeight();
+ }
+ else
+ nMinHeight += 250; // arbitrary ...
+
+ return nMinHeight;
+ }
+
+ //------------------------------------------------------------------
+ sal_Int32 OPropertyEditor::getMinimumWidth()
+ {
+ sal_uInt16 nCount = m_aTabControl.GetPageCount();
+ sal_Int32 nPageMinWidth = 0;
+ for(long i = nCount-1; i >= 0; --i)
+ {
+ sal_uInt16 nID = m_aTabControl.GetPageId((sal_uInt16)i);
+ OBrowserPage* pPage = static_cast<OBrowserPage*>(m_aTabControl.GetTabPage(nID));
+ if (pPage)
+ {
+ sal_Int32 nCurPageMinWidth = pPage->getMinimumWidth();
+ if( nCurPageMinWidth > nPageMinWidth )
+ nPageMinWidth = nCurPageMinWidth;
+ }
+ }
+ return nPageMinWidth+6;
+ }
+
+ //------------------------------------------------------------------
+ void OPropertyEditor::CommitModified()
+ {
+ // commit all of my pages, if necessary
+
+ sal_uInt16 nCount = m_aTabControl.GetPageCount();
+ for ( sal_uInt16 i=0; i<nCount; ++i )
+ {
+ sal_uInt16 nID = m_aTabControl.GetPageId( i );
+ OBrowserPage* pPage = static_cast< OBrowserPage* >( m_aTabControl.GetTabPage( nID ) );
+
+ if ( pPage && pPage->getListBox().IsModified() )
+ pPage->getListBox().CommitModified();
+ }
+ }
+
+ //------------------------------------------------------------------
+ void OPropertyEditor::GetFocus()
+ {
+ m_aTabControl.GrabFocus();
+ }
+
+ //------------------------------------------------------------------
+ OBrowserPage* OPropertyEditor::getPage( const ::rtl::OUString& _rPropertyName )
+ {
+ OBrowserPage* pPage = NULL;
+ MapStringToPageId::const_iterator aPropertyPageIdPos = m_aPropertyPageIds.find( _rPropertyName );
+ if ( aPropertyPageIdPos != m_aPropertyPageIds.end() )
+ pPage = static_cast< OBrowserPage* >( m_aTabControl.GetTabPage( aPropertyPageIdPos->second ) );
+ return pPage;
+ }
+
+ //------------------------------------------------------------------
+ const OBrowserPage* OPropertyEditor::getPage( const ::rtl::OUString& _rPropertyName ) const
+ {
+ return const_cast< OPropertyEditor* >( this )->getPage( _rPropertyName );
+ }
+
+ //------------------------------------------------------------------
+ OBrowserPage* OPropertyEditor::getPage( sal_uInt16& _rPageId )
+ {
+ return static_cast< OBrowserPage* >( m_aTabControl.GetTabPage( _rPageId ) );
+ }
+
+ //------------------------------------------------------------------
+ const OBrowserPage* OPropertyEditor::getPage( sal_uInt16& _rPageId ) const
+ {
+ return const_cast< OPropertyEditor* >( this )->getPage( _rPageId );
+ }
+
+ //------------------------------------------------------------------
+ void OPropertyEditor::Resize()
+ {
+ Rectangle aPlayground(
+ Point( LAYOUT_BORDER_LEFT, LAYOUT_BORDER_TOP ),
+ Size(
+ GetOutputSizePixel().Width() - LAYOUT_BORDER_LEFT - LAYOUT_BORDER_RIGHT,
+ GetOutputSizePixel().Height() - LAYOUT_BORDER_TOP - LAYOUT_BORDER_BOTTOM
+ )
+ );
+
+ Rectangle aTabArea( aPlayground );
+ m_aTabControl.SetPosSizePixel( aTabArea.TopLeft(), aTabArea.GetSize() );
+ }
+
+ //------------------------------------------------------------------
+ sal_uInt16 OPropertyEditor::AppendPage( const String & _rText, const SmartId& _rHelpId )
+ {
+ // obtain a new id
+ sal_uInt16 nId = m_nNextId++;
+ // insert the id
+ m_aTabControl.InsertPage(nId, _rText);
+
+ // create a new page
+ OBrowserPage* pPage = new OBrowserPage(&m_aTabControl);
+ pPage->SetText( _rText );
+ // some knittings
+ pPage->SetSizePixel(m_aTabControl.GetTabPageSizePixel());
+ pPage->getListBox().SetListener(m_pListener);
+ pPage->getListBox().SetObserver(m_pObserver);
+ pPage->getListBox().EnableHelpSection( m_bHasHelpSection );
+ pPage->getListBox().SetHelpLineLimites( m_nMinHelpLines, m_nMaxHelpLines );
+ pPage->SetSmartHelpId( _rHelpId );
+
+ // immediately activate the page
+ m_aTabControl.SetTabPage(nId, pPage);
+ m_aTabControl.SetCurPageId(nId);
+
+ return nId;
+ }
+
+ //------------------------------------------------------------------
+ void OPropertyEditor::SetHelpId( sal_uInt32 nHelpId )
+ {
+ Control::SetHelpId(0);
+ m_aTabControl.SetHelpId(nHelpId);
+ }
+
+ //------------------------------------------------------------------
+ void OPropertyEditor::RemovePage(sal_uInt16 nID)
+ {
+ OBrowserPage* pPage = static_cast<OBrowserPage*>(m_aTabControl.GetTabPage(nID));
+
+ if (pPage)
+ pPage->EnableInput(sal_False);
+ m_aTabControl.RemovePage(nID);
+ if (pPage)
+ delete pPage;
+ }
+
+ //------------------------------------------------------------------
+ void OPropertyEditor::SetPage(sal_uInt16 nId)
+ {
+ m_aTabControl.SetCurPageId(nId);
+ }
+
+ //------------------------------------------------------------------
+ sal_uInt16 OPropertyEditor::GetCurPage()
+ {
+ if(m_aTabControl.GetPageCount()>0)
+ return m_aTabControl.GetCurPageId();
+ else
+ return 0;
+ }
+
+ //------------------------------------------------------------------
+ void OPropertyEditor::Update(const ::std::mem_fun_t<void,OBrowserListBox>& _aUpdateFunction)
+ {
+ // forward this to all our pages
+ sal_uInt16 nCount = m_aTabControl.GetPageCount();
+ for (sal_uInt16 i=0;i<nCount;++i)
+ {
+ sal_uInt16 nID = m_aTabControl.GetPageId(i);
+ OBrowserPage* pPage = static_cast<OBrowserPage*>(m_aTabControl.GetTabPage(nID));
+ if (pPage)
+ _aUpdateFunction(&pPage->getListBox());
+ }
+ }
+ //------------------------------------------------------------------
+ void OPropertyEditor::EnableUpdate()
+ {
+ Update(::std::mem_fun(&OBrowserListBox::EnableUpdate));
+ }
+ //------------------------------------------------------------------
+ void OPropertyEditor::DisableUpdate()
+ {
+ Update(::std::mem_fun(&OBrowserListBox::DisableUpdate));
+ }
+
+ //------------------------------------------------------------------
+ void OPropertyEditor::forEachPage( PageOperation _pOperation, const void* _pArgument )
+ {
+ sal_uInt16 nCount = m_aTabControl.GetPageCount();
+ for ( sal_uInt16 i=0; i<nCount; ++i )
+ {
+ sal_uInt16 nID = m_aTabControl.GetPageId(i);
+ OBrowserPage* pPage = static_cast< OBrowserPage* >( m_aTabControl.GetTabPage( nID ) );
+ if ( !pPage )
+ continue;
+ (this->*_pOperation)( *pPage, _pArgument );
+ }
+ }
+
+ //------------------------------------------------------------------
+ void OPropertyEditor::setPageLineListener( OBrowserPage& _rPage, const void* )
+ {
+ _rPage.getListBox().SetListener( m_pListener );
+ }
+
+ //------------------------------------------------------------------
+ void OPropertyEditor::SetLineListener(IPropertyLineListener* _pListener)
+ {
+ m_pListener = _pListener;
+ forEachPage( &OPropertyEditor::setPageLineListener );
+ }
+
+ //------------------------------------------------------------------
+ void OPropertyEditor::setPageControlObserver( OBrowserPage& _rPage, const void* )
+ {
+ _rPage.getListBox().SetObserver( m_pObserver );
+ }
+
+ //------------------------------------------------------------------
+ void OPropertyEditor::SetControlObserver( IPropertyControlObserver* _pObserver )
+ {
+ m_pObserver = _pObserver;
+ forEachPage( &OPropertyEditor::setPageControlObserver );
+ }
+
+ //------------------------------------------------------------------
+ void OPropertyEditor::EnableHelpSection( bool _bEnable )
+ {
+ m_bHasHelpSection = _bEnable;
+ forEachPage( &OPropertyEditor::enableHelpSection );
+ }
+
+ //------------------------------------------------------------------
+ bool OPropertyEditor::HasHelpSection() const
+ {
+ return m_bHasHelpSection;
+ }
+
+ //------------------------------------------------------------------
+ void OPropertyEditor::SetHelpText( const ::rtl::OUString& _rHelpText )
+ {
+ forEachPage( &OPropertyEditor::setHelpSectionText, &_rHelpText );
+ }
+
+ //------------------------------------------------------------------
+ void OPropertyEditor::SetHelpLineLimites( sal_Int32 _nMinLines, sal_Int32 _nMaxLines )
+ {
+ m_nMinHelpLines = _nMinLines;
+ m_nMaxHelpLines = _nMaxLines;
+ forEachPage( &OPropertyEditor::setHelpLineLimits );
+ }
+
+ //------------------------------------------------------------------
+ void OPropertyEditor::enableHelpSection( OBrowserPage& _rPage, const void* )
+ {
+ _rPage.getListBox().EnableHelpSection( m_bHasHelpSection );
+ }
+
+ //------------------------------------------------------------------
+ void OPropertyEditor::setHelpSectionText( OBrowserPage& _rPage, const void* _pPointerToOUString )
+ {
+ OSL_ENSURE( _pPointerToOUString, "OPropertyEditor::setHelpSectionText: invalid argument!" );
+ if ( !_pPointerToOUString )
+ return;
+
+ const ::rtl::OUString& rText( *(const ::rtl::OUString*)_pPointerToOUString );
+ _rPage.getListBox().SetHelpText( rText );
+ }
+
+ //------------------------------------------------------------------
+ void OPropertyEditor::setHelpLineLimits( OBrowserPage& _rPage, const void* )
+ {
+ _rPage.getListBox().SetHelpLineLimites( m_nMinHelpLines, m_nMaxHelpLines );
+ }
+
+ //------------------------------------------------------------------
+ sal_uInt16 OPropertyEditor::InsertEntry( const OLineDescriptor& rData, sal_uInt16 _nPageId, sal_uInt16 nPos )
+ {
+ // let the current page handle this
+ OBrowserPage* pPage = getPage( _nPageId );
+ DBG_ASSERT( pPage, "OPropertyEditor::InsertEntry: don't have such a page!" );
+ if ( !pPage )
+ return LISTBOX_ENTRY_NOTFOUND;
+
+ sal_uInt16 nEntry = pPage->getListBox().InsertEntry( rData, nPos );
+
+ OSL_ENSURE( m_aPropertyPageIds.find( rData.sName ) == m_aPropertyPageIds.end(),
+ "OPropertyEditor::InsertEntry: property already present in the map!" );
+ m_aPropertyPageIds.insert( MapStringToPageId::value_type( rData.sName, _nPageId ) );
+
+ return nEntry;
+ }
+
+ //------------------------------------------------------------------
+ void OPropertyEditor::RemoveEntry( const ::rtl::OUString& _rName )
+ {
+ OBrowserPage* pPage = getPage( _rName );
+ if ( pPage )
+ {
+ OSL_VERIFY( pPage->getListBox().RemoveEntry( _rName ) );
+
+ OSL_ENSURE( m_aPropertyPageIds.find( _rName ) != m_aPropertyPageIds.end(),
+ "OPropertyEditor::RemoveEntry: property not present in the map!" );
+ m_aPropertyPageIds.erase( _rName );
+ }
+ }
+
+ //------------------------------------------------------------------
+ void OPropertyEditor::ChangeEntry( const OLineDescriptor& rData )
+ {
+ OBrowserPage* pPage = getPage( rData.sName );
+ if ( pPage )
+ pPage->getListBox().ChangeEntry( rData, EDITOR_LIST_REPLACE_EXISTING );
+ }
+
+ //------------------------------------------------------------------
+ void OPropertyEditor::SetPropertyValue( const ::rtl::OUString& rEntryName, const Any& _rValue, bool _bUnknownValue )
+ {
+ OBrowserPage* pPage = getPage( rEntryName );
+ if ( pPage )
+ pPage->getListBox().SetPropertyValue( rEntryName, _rValue, _bUnknownValue );
+ }
+
+ //------------------------------------------------------------------
+ sal_uInt16 OPropertyEditor::GetPropertyPos( const ::rtl::OUString& rEntryName ) const
+ {
+ sal_uInt16 nVal=LISTBOX_ENTRY_NOTFOUND;
+ const OBrowserPage* pPage = getPage( rEntryName );
+ if ( pPage )
+ nVal = pPage->getListBox().GetPropertyPos( rEntryName );
+ return nVal;
+ }
+
+ //------------------------------------------------------------------
+ void OPropertyEditor::ShowPropertyPage( sal_uInt16 _nPageId, bool _bShow )
+ {
+ if ( !_bShow )
+ {
+ sal_uInt16 nPagePos = m_aTabControl.GetPagePos( _nPageId );
+ if ( TAB_PAGE_NOTFOUND == nPagePos )
+ return;
+ DBG_ASSERT( m_aHiddenPages.find( _nPageId ) == m_aHiddenPages.end(), "OPropertyEditor::ShowPropertyPage: page already hidden!" );
+
+ m_aHiddenPages[ _nPageId ] = HiddenPage( nPagePos, m_aTabControl.GetTabPage( _nPageId ) );
+ m_aTabControl.RemovePage( _nPageId );
+ }
+ else
+ {
+ ::std::map< sal_uInt16, HiddenPage >::iterator aPagePos = m_aHiddenPages.find( _nPageId );
+ if ( aPagePos == m_aHiddenPages.end() )
+ return;
+
+ aPagePos->second.pPage->SetSizePixel( m_aTabControl.GetTabPageSizePixel() );
+ m_aTabControl.InsertPage( aPagePos->first, aPagePos->second.pPage->GetText(), aPagePos->second.nPos );
+ m_aTabControl.SetTabPage( aPagePos->first, aPagePos->second.pPage );
+
+ m_aHiddenPages.erase( aPagePos );
+ }
+ }
+
+ //------------------------------------------------------------------
+ void OPropertyEditor::EnablePropertyControls( const ::rtl::OUString& _rEntryName, sal_Int16 _nControls, bool _bEnable )
+ {
+ for ( USHORT i = 0; i < m_aTabControl.GetPageCount(); ++i )
+ {
+ OBrowserPage* pPage = static_cast< OBrowserPage* >( m_aTabControl.GetTabPage( m_aTabControl.GetPageId( i ) ) );
+ if ( pPage )
+ pPage->getListBox().EnablePropertyControls( _rEntryName, _nControls, _bEnable );
+ }
+ }
+
+ //------------------------------------------------------------------
+ void OPropertyEditor::EnablePropertyLine( const ::rtl::OUString& _rEntryName, bool _bEnable )
+ {
+ for ( USHORT i = 0; i < m_aTabControl.GetPageCount(); ++i )
+ {
+ OBrowserPage* pPage = static_cast< OBrowserPage* >( m_aTabControl.GetTabPage( m_aTabControl.GetPageId( i ) ) );
+ if ( pPage )
+ pPage->getListBox().EnablePropertyLine( _rEntryName, _bEnable );
+ }
+ }
+
+ //------------------------------------------------------------------
+ Reference< XPropertyControl > OPropertyEditor::GetPropertyControl(const ::rtl::OUString& rEntryName)
+ {
+ Reference< XPropertyControl > xControl;
+ // let the current page handle this
+ OBrowserPage* pPage = static_cast<OBrowserPage*>(m_aTabControl.GetTabPage(m_aTabControl.GetCurPageId()));
+ if (pPage)
+ xControl = pPage->getListBox().GetPropertyControl(rEntryName);
+ return xControl;
+ }
+
+ //------------------------------------------------------------------
+ IMPL_LINK(OPropertyEditor, OnPageActivate, TabControl*, EMPTYARG)
+ {
+ if (m_aPageActivationHandler.IsSet())
+ m_aPageActivationHandler.Call(NULL);
+ return 0L;
+ }
+
+ //------------------------------------------------------------------
+ IMPL_LINK(OPropertyEditor, OnPageDeactivate, TabControl*, EMPTYARG)
+ {
+ // commit the data on the current (to-be-decativated) tab page
+ // (79404)
+ sal_Int32 nCurrentId = m_aTabControl.GetCurPageId();
+ OBrowserPage* pCurrentPage = static_cast<OBrowserPage*>(m_aTabControl.GetTabPage((sal_uInt16)nCurrentId));
+ if ( !pCurrentPage )
+ return 1L;
+
+ if ( pCurrentPage->getListBox().IsModified() )
+ pCurrentPage->getListBox().CommitModified();
+
+ return 1L;
+ }
+
+//............................................................................
+} // namespace pcr
+//............................................................................
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/propctrlr/propertyeditor.hxx b/extensions/source/propctrlr/propertyeditor.hxx
new file mode 100644
index 000000000000..eec51c6a03fa
--- /dev/null
+++ b/extensions/source/propctrlr/propertyeditor.hxx
@@ -0,0 +1,165 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _EXTENSIONS_PROPCTRLR_PROPERTYEDITOR_HXX_
+#define _EXTENSIONS_PROPCTRLR_PROPERTYEDITOR_HXX_
+
+#include "pcrcommon.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/inspection/XPropertyControl.hpp>
+/** === end UNO includes === **/
+#include <vcl/tabctrl.hxx>
+#include <comphelper/stl_types.hxx>
+#include <boost/mem_fn.hpp>
+#include <map>
+
+//............................................................................
+namespace pcr
+{
+//............................................................................
+
+ class IPropertyLineListener;
+ class IPropertyControlObserver;
+ class OBrowserPage;
+ struct OLineDescriptor;
+ class OBrowserListBox;
+
+ //========================================================================
+ //= OPropertyEditor
+ //========================================================================
+ class OPropertyEditor : public Control
+ {
+ private:
+ typedef ::std::map< ::rtl::OUString, sal_uInt16 > MapStringToPageId;
+ struct HiddenPage
+ {
+ sal_uInt16 nPos;
+ TabPage* pPage;
+ HiddenPage() : nPos( 0 ), pPage( NULL ) { }
+ HiddenPage( sal_uInt16 _nPos, TabPage* _pPage ) : nPos( _nPos ), pPage( _pPage ) { }
+ };
+
+ private:
+ TabControl m_aTabControl;
+ IPropertyLineListener* m_pListener;
+ IPropertyControlObserver* m_pObserver;
+ sal_uInt16 m_nNextId;
+ Link m_aPageActivationHandler;
+ bool m_bHasHelpSection;
+ sal_Int32 m_nMinHelpLines;
+ sal_Int32 m_nMaxHelpLines;
+
+ MapStringToPageId m_aPropertyPageIds;
+ ::std::map< sal_uInt16, HiddenPage > m_aHiddenPages;
+
+ protected:
+ void Resize();
+ void GetFocus();
+
+ public:
+ OPropertyEditor (Window* pParent, WinBits nWinStyle = WB_DIALOGCONTROL);
+
+ ~OPropertyEditor();
+
+ void EnableUpdate();
+ void DisableUpdate();
+
+ void SetLineListener( IPropertyLineListener* );
+ void SetControlObserver( IPropertyControlObserver* );
+
+ void EnableHelpSection( bool _bEnable );
+ bool HasHelpSection() const;
+ void SetHelpText( const ::rtl::OUString& _rHelpText );
+ void SetHelpLineLimites( sal_Int32 _nMinLines, sal_Int32 _nMaxLines );
+
+ void SetHelpId( sal_uInt32 nHelpId );
+ sal_uInt16 AppendPage( const String& r, const SmartId& _rHelpId );
+ void SetPage( sal_uInt16 );
+ void RemovePage(sal_uInt16 nID);
+ sal_uInt16 GetCurPage();
+ void ClearAll();
+
+ void SetPropertyValue(const ::rtl::OUString& _rEntryName, const ::com::sun::star::uno::Any& _rValue, bool _bUnknownValue );
+ ::com::sun::star::uno::Any GetPropertyValue(const ::rtl::OUString& rEntryName ) const;
+ sal_uInt16 GetPropertyPos(const ::rtl::OUString& rEntryName ) const;
+ ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyControl >
+ GetPropertyControl( const ::rtl::OUString& rEntryName );
+ void EnablePropertyLine( const ::rtl::OUString& _rEntryName, bool _bEnable );
+ void EnablePropertyControls( const ::rtl::OUString& _rEntryName, sal_Int16 _nControls, bool _bEnable );
+
+ void ShowPropertyPage( sal_uInt16 _nPageId, bool _bShow );
+
+ sal_uInt16 InsertEntry( const OLineDescriptor&, sal_uInt16 _nPageId, sal_uInt16 nPos = EDITOR_LIST_APPEND );
+ void RemoveEntry( const ::rtl::OUString& _rName );
+ void ChangeEntry( const OLineDescriptor& );
+
+ void setPageActivationHandler(const Link& _rHdl) { m_aPageActivationHandler = _rHdl; }
+ Link getPageActivationHandler() const { return m_aPageActivationHandler; }
+
+ // #95343# -------------------------------
+ sal_Int32 getMinimumWidth();
+ sal_Int32 getMinimumHeight();
+
+ void CommitModified();
+
+ protected:
+ using Window::SetHelpText;
+ using Window::Update;
+
+ private:
+ OBrowserPage* getPage( sal_uInt16& _rPageId );
+ const OBrowserPage* getPage( sal_uInt16& _rPageId ) const;
+
+ OBrowserPage* getPage( const ::rtl::OUString& _rPropertyName );
+ const OBrowserPage* getPage( const ::rtl::OUString& _rPropertyName ) const;
+
+ void Update(const ::std::mem_fun_t<void,OBrowserListBox>& _aUpdateFunction);
+
+ typedef void (OPropertyEditor::*PageOperation)( OBrowserPage&, const void* );
+ void forEachPage( PageOperation _pOperation, const void* _pArgument = NULL );
+
+ void setPageLineListener( OBrowserPage& _rPage, const void* );
+ void setPageControlObserver( OBrowserPage& _rPage, const void* );
+ void enableHelpSection( OBrowserPage& _rPage, const void* );
+ void setHelpSectionText( OBrowserPage& _rPage, const void* _pPointerToOUString );
+ void setHelpLineLimits( OBrowserPage& _rPage, const void* );
+
+ protected:
+ DECL_LINK(OnPageDeactivate, TabControl*);
+ DECL_LINK(OnPageActivate, TabControl*);
+ };
+
+//............................................................................
+} // namespace pcr
+//............................................................................
+
+#endif // _EXTENSIONS_PROPCTRLR_PROPERTYEDITOR_HXX_
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/propctrlr/propertyhandler.cxx b/extensions/source/propctrlr/propertyhandler.cxx
new file mode 100644
index 000000000000..2b4ee7768f5b
--- /dev/null
+++ b/extensions/source/propctrlr/propertyhandler.cxx
@@ -0,0 +1,466 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+#include "propertyhandler.hxx"
+#include "formmetadata.hxx"
+#include "formbrowsertools.hxx"
+#include "handlerhelper.hxx"
+#include "formstrings.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+#include <com/sun/star/lang/NullPointerException.hpp>
+#include <com/sun/star/util/XModifiable.hpp>
+/** === end UNO includes === **/
+
+#include <tools/debug.hxx>
+#include <unotools/confignode.hxx>
+#include <unotools/localedatawrapper.hxx>
+#include <unotools/syslocale.hxx>
+#include <toolkit/helper/vclunohelper.hxx>
+
+#include <algorithm>
+
+//........................................................................
+namespace pcr
+{
+//........................................................................
+
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::awt;
+ using namespace ::com::sun::star::beans;
+ using namespace ::com::sun::star::script;
+ using namespace ::com::sun::star::lang;
+ using namespace ::com::sun::star::util;
+ using namespace ::com::sun::star::frame;
+ using namespace ::com::sun::star::inspection;
+ using namespace ::comphelper;
+
+ //====================================================================
+ //= PropertyHandler
+ //====================================================================
+ DBG_NAME( PropertyHandler )
+ //--------------------------------------------------------------------
+ PropertyHandler::PropertyHandler( const Reference< XComponentContext >& _rxContext )
+ :PropertyHandler_Base( m_aMutex )
+ ,m_bSupportedPropertiesAreKnown( false )
+ ,m_aPropertyListeners( m_aMutex )
+ ,m_aContext( _rxContext )
+ ,m_pInfoService ( new OPropertyInfoService )
+ {
+ DBG_CTOR( PropertyHandler, NULL );
+
+ m_xTypeConverter = Reference< XTypeConverter >(
+ m_aContext.createComponent( "com.sun.star.script.Converter" ),
+ UNO_QUERY_THROW
+ );
+ }
+
+ //--------------------------------------------------------------------
+ PropertyHandler::~PropertyHandler()
+ {
+ DBG_DTOR( PropertyHandler, NULL );
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL PropertyHandler::inspect( const Reference< XInterface >& _rxIntrospectee ) throw (RuntimeException, NullPointerException)
+ {
+ if ( !_rxIntrospectee.is() )
+ throw NullPointerException();
+
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ Reference< XPropertySet > xNewComponent( _rxIntrospectee, UNO_QUERY );
+ if ( xNewComponent == m_xComponent )
+ return;
+
+ // remove all old property change listeners
+ ::std::auto_ptr< ::cppu::OInterfaceIteratorHelper > removeListener = m_aPropertyListeners.createIterator();
+ ::std::auto_ptr< ::cppu::OInterfaceIteratorHelper > readdListener = m_aPropertyListeners.createIterator(); // will copy the container as needed
+ while ( removeListener->hasMoreElements() )
+ removePropertyChangeListener( static_cast< XPropertyChangeListener* >( removeListener->next() ) );
+ OSL_ENSURE( m_aPropertyListeners.empty(), "PropertyHandler::inspect: derived classes are expected to forward the removePropertyChangeListener call to their base class (me)!" );
+
+ // remember the new component, and give derived classes the chance to react on it
+ m_xComponent = xNewComponent;
+ onNewComponent();
+
+ // add the listeners, again
+ while ( readdListener->hasMoreElements() )
+ addPropertyChangeListener( static_cast< XPropertyChangeListener* >( readdListener->next() ) );
+ }
+
+ //--------------------------------------------------------------------
+ void PropertyHandler::onNewComponent()
+ {
+ if ( m_xComponent.is() )
+ m_xComponentPropertyInfo = m_xComponent->getPropertySetInfo();
+ else
+ m_xComponentPropertyInfo.clear();
+
+ m_bSupportedPropertiesAreKnown = false;
+ m_aSupportedProperties.realloc( 0 );
+ }
+
+ //--------------------------------------------------------------------
+ Sequence< Property > SAL_CALL PropertyHandler::getSupportedProperties() throw (RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ if ( !m_bSupportedPropertiesAreKnown )
+ {
+ m_aSupportedProperties = doDescribeSupportedProperties();
+ m_bSupportedPropertiesAreKnown = true;
+ }
+ return (Sequence< Property >)m_aSupportedProperties;
+ }
+
+ //--------------------------------------------------------------------
+ Sequence< ::rtl::OUString > SAL_CALL PropertyHandler::getSupersededProperties( ) throw (RuntimeException)
+ {
+ return Sequence< ::rtl::OUString >();
+ }
+
+ //--------------------------------------------------------------------
+ Sequence< ::rtl::OUString > SAL_CALL PropertyHandler::getActuatingProperties( ) throw (RuntimeException)
+ {
+ return Sequence< ::rtl::OUString >();
+ }
+
+ //--------------------------------------------------------------------
+ Any SAL_CALL PropertyHandler::convertToPropertyValue( const ::rtl::OUString& _rPropertyName, const Any& _rControlValue ) throw (UnknownPropertyException, RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ PropertyId nPropId = m_pInfoService->getPropertyId( _rPropertyName );
+ Property aProperty( impl_getPropertyFromName_throw( _rPropertyName ) );
+
+ Any aPropertyValue;
+ if ( !_rControlValue.hasValue() )
+ // NULL is converted to NULL
+ return aPropertyValue;
+
+ if ( ( m_pInfoService->getPropertyUIFlags( nPropId ) & PROP_FLAG_ENUM ) != 0 )
+ {
+ ::rtl::OUString sControlValue;
+ OSL_VERIFY( _rControlValue >>= sControlValue );
+ ::rtl::Reference< IPropertyEnumRepresentation > aEnumConversion(
+ new DefaultEnumRepresentation( *m_pInfoService, aProperty.Type, nPropId ) );
+ // TODO/UNOize: cache those converters?
+ aEnumConversion->getValueFromDescription( sControlValue, aPropertyValue );
+ }
+ else
+ aPropertyValue = PropertyHandlerHelper::convertToPropertyValue(
+ m_aContext.getContext(),m_xTypeConverter, aProperty, _rControlValue );
+ return aPropertyValue;
+ }
+
+ //--------------------------------------------------------------------
+ Any SAL_CALL PropertyHandler::convertToControlValue( const ::rtl::OUString& _rPropertyName, const Any& _rPropertyValue, const Type& _rControlValueType ) throw (UnknownPropertyException, RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ PropertyId nPropId = m_pInfoService->getPropertyId( _rPropertyName );
+
+ if ( ( m_pInfoService->getPropertyUIFlags( nPropId ) & PROP_FLAG_ENUM ) != 0 )
+ {
+ DBG_ASSERT( _rControlValueType.getTypeClass() == TypeClass_STRING, "PropertyHandler::convertToControlValue: ENUM, but not STRING?" );
+
+ ::rtl::Reference< IPropertyEnumRepresentation > aEnumConversion(
+ new DefaultEnumRepresentation( *m_pInfoService, _rPropertyValue.getValueType(), nPropId ) );
+ // TODO/UNOize: cache those converters?
+ return makeAny( aEnumConversion->getDescriptionForValue( _rPropertyValue ) );
+ }
+
+ return PropertyHandlerHelper::convertToControlValue(
+ m_aContext.getContext(),m_xTypeConverter, _rPropertyValue, _rControlValueType );
+ }
+
+ //--------------------------------------------------------------------
+ PropertyState SAL_CALL PropertyHandler::getPropertyState( const ::rtl::OUString& /*_rPropertyName*/ ) throw (UnknownPropertyException, RuntimeException)
+ {
+ return PropertyState_DIRECT_VALUE;
+ }
+
+ //--------------------------------------------------------------------
+ LineDescriptor SAL_CALL PropertyHandler::describePropertyLine( const ::rtl::OUString& _rPropertyName,
+ const Reference< XPropertyControlFactory >& _rxControlFactory )
+ throw (UnknownPropertyException, NullPointerException, RuntimeException)
+ {
+ if ( !_rxControlFactory.is() )
+ throw NullPointerException();
+
+ ::osl::MutexGuard aGuard( m_aMutex );
+ PropertyId nPropId( impl_getPropertyId_throw( _rPropertyName ) );
+ const Property& rProperty( impl_getPropertyFromId_throw( nPropId ) );
+
+ LineDescriptor aDescriptor;
+ if ( ( m_pInfoService->getPropertyUIFlags( nPropId ) & PROP_FLAG_ENUM ) != 0 )
+ {
+ aDescriptor.Control = PropertyHandlerHelper::createListBoxControl(
+ _rxControlFactory, m_pInfoService->getPropertyEnumRepresentations( nPropId ),
+ PropertyHandlerHelper::requiresReadOnlyControl( rProperty.Attributes ), sal_False );
+ }
+ else
+ PropertyHandlerHelper::describePropertyLine( rProperty, aDescriptor, _rxControlFactory );
+
+ aDescriptor.HelpURL = HelpIdUrl::getHelpURL( m_pInfoService->getPropertyHelpId( nPropId ) );
+ aDescriptor.DisplayName = m_pInfoService->getPropertyTranslation( nPropId );
+
+ if ( ( m_pInfoService->getPropertyUIFlags( nPropId ) & PROP_FLAG_DATA_PROPERTY ) != 0 )
+ aDescriptor.Category = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Data" ) );
+ else
+ aDescriptor.Category = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "General" ) );
+ return aDescriptor;
+ }
+
+ //--------------------------------------------------------------------
+ ::sal_Bool SAL_CALL PropertyHandler::isComposable( const ::rtl::OUString& _rPropertyName ) throw (UnknownPropertyException, RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ return m_pInfoService->isComposeable( _rPropertyName );
+ }
+
+ //--------------------------------------------------------------------
+ InteractiveSelectionResult SAL_CALL PropertyHandler::onInteractivePropertySelection( const ::rtl::OUString& /*_rPropertyName*/, sal_Bool /*_bPrimary*/, Any& /*_rData*/, const Reference< XObjectInspectorUI >& /*_rxInspectorUI*/ ) throw (UnknownPropertyException, NullPointerException, RuntimeException)
+ {
+ DBG_ERROR( "PropertyHandler::onInteractivePropertySelection: not implemented!" );
+ return InteractiveSelectionResult_Cancelled;
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL PropertyHandler::actuatingPropertyChanged( const ::rtl::OUString& /*_rActuatingPropertyName*/, const Any& /*_rNewValue*/, const Any& /*_rOldValue*/, const Reference< XObjectInspectorUI >& /*_rxInspectorUI*/, sal_Bool /*_bFirstTimeInit*/ ) throw (NullPointerException, RuntimeException)
+ {
+ DBG_ERROR( "PropertyHandler::actuatingPropertyChanged: not implemented!" );
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL PropertyHandler::addPropertyChangeListener( const Reference< XPropertyChangeListener >& _rxListener ) throw (RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ if ( !_rxListener.is() )
+ throw NullPointerException();
+ m_aPropertyListeners.addListener( _rxListener );
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL PropertyHandler::removePropertyChangeListener( const Reference< XPropertyChangeListener >& _rxListener ) throw (RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ m_aPropertyListeners.removeListener( _rxListener );
+ }
+
+ //--------------------------------------------------------------------
+ sal_Bool SAL_CALL PropertyHandler::suspend( sal_Bool /*_bSuspend*/ ) throw (RuntimeException)
+ {
+ return sal_True;
+ }
+
+ //--------------------------------------------------------------------
+ IMPLEMENT_FORWARD_XCOMPONENT( PropertyHandler, PropertyHandler_Base )
+ //--------------------------------------------------------------------
+ void SAL_CALL PropertyHandler::disposing()
+ {
+ m_xComponent.clear();
+ m_aPropertyListeners.clear();
+ m_xTypeConverter.clear();
+ m_aSupportedProperties.realloc( 0 );
+ }
+
+ //--------------------------------------------------------------------
+ void PropertyHandler::firePropertyChange( const ::rtl::OUString& _rPropName, PropertyId _nPropId, const Any& _rOldValue, const Any& _rNewValue ) SAL_THROW(())
+ {
+ PropertyChangeEvent aEvent;
+ aEvent.Source = m_xComponent;
+ aEvent.PropertyHandle = _nPropId;
+ aEvent.PropertyName = _rPropName;
+ aEvent.OldValue = _rOldValue;
+ aEvent.NewValue = _rNewValue;
+ m_aPropertyListeners.notify( aEvent, &XPropertyChangeListener::propertyChange );
+ }
+
+ //--------------------------------------------------------------------
+ const Property* PropertyHandler::impl_getPropertyFromId_nothrow( PropertyId _nPropId ) const
+ {
+ const_cast< PropertyHandler* >( this )->getSupportedProperties();
+ const Property* pFound = ::std::find_if( m_aSupportedProperties.begin(), m_aSupportedProperties.end(),
+ FindPropertyByHandle( _nPropId )
+ );
+ if ( pFound != m_aSupportedProperties.end() )
+ return &(*pFound);
+ return NULL;
+ }
+
+ //--------------------------------------------------------------------
+ const Property& PropertyHandler::impl_getPropertyFromId_throw( PropertyId _nPropId ) const
+ {
+ const Property* pProperty = impl_getPropertyFromId_nothrow( _nPropId );
+ if ( !pProperty )
+ throw UnknownPropertyException();
+
+ return *pProperty;
+ }
+
+ //--------------------------------------------------------------------
+ const Property& PropertyHandler::impl_getPropertyFromName_throw( const ::rtl::OUString& _rPropertyName ) const
+ {
+ const_cast< PropertyHandler* >( this )->getSupportedProperties();
+ StlSyntaxSequence< Property >::const_iterator pFound = ::std::find_if( m_aSupportedProperties.begin(), m_aSupportedProperties.end(),
+ FindPropertyByName( _rPropertyName )
+ );
+ if ( pFound == m_aSupportedProperties.end() )
+ throw UnknownPropertyException();
+
+ return *pFound;
+ }
+
+ //--------------------------------------------------------------------
+ void PropertyHandler::implAddPropertyDescription( ::std::vector< Property >& _rProperties, const ::rtl::OUString& _rPropertyName, const Type& _rType, sal_Int16 _nAttribs ) const
+ {
+ _rProperties.push_back( Property(
+ _rPropertyName,
+ m_pInfoService->getPropertyId( _rPropertyName ),
+ _rType,
+ _nAttribs
+ ) );
+ }
+
+ //------------------------------------------------------------------------
+ Window* PropertyHandler::impl_getDefaultDialogParent_nothrow() const
+ {
+ return PropertyHandlerHelper::getDialogParentWindow( m_aContext );
+ }
+
+ //------------------------------------------------------------------------
+ PropertyId PropertyHandler::impl_getPropertyId_throw( const ::rtl::OUString& _rPropertyName ) const
+ {
+ PropertyId nPropId = m_pInfoService->getPropertyId( _rPropertyName );
+ if ( nPropId == -1 )
+ throw UnknownPropertyException();
+ return nPropId;
+ }
+
+ //------------------------------------------------------------------------
+ void PropertyHandler::impl_setContextDocumentModified_nothrow() const
+ {
+ Reference< XModifiable > xModifiable( impl_getContextDocument_nothrow(), UNO_QUERY );
+ if ( xModifiable.is() )
+ xModifiable->setModified( sal_True );
+ }
+
+ //------------------------------------------------------------------------
+ bool PropertyHandler::impl_componentHasProperty_throw( const ::rtl::OUString& _rPropName ) const
+ {
+ return m_xComponentPropertyInfo.is() && m_xComponentPropertyInfo->hasPropertyByName( _rPropName );
+ }
+
+ //--------------------------------------------------------------------
+ sal_Int16 PropertyHandler::impl_getDocumentMeasurementUnit_throw() const
+ {
+ FieldUnit eUnit = FUNIT_NONE;
+
+ Reference< XServiceInfo > xDocumentSI( impl_getContextDocument_nothrow(), UNO_QUERY );
+ OSL_ENSURE( xDocumentSI.is(), "PropertyHandlerHelper::impl_getDocumentMeasurementUnit_throw: No context document - where do I live?" );
+ if ( xDocumentSI.is() )
+ {
+ // determine the application type we live in
+ ::rtl::OUString sConfigurationLocation;
+ ::rtl::OUString sConfigurationProperty;
+ if ( xDocumentSI->supportsService( SERVICE_WEB_DOCUMENT ) )
+ { // writer
+ sConfigurationLocation = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "/org.openoffice.Office.WriterWeb/Layout/Other" ) );
+ sConfigurationProperty = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "MeasureUnit" ) );
+ }
+ else if ( xDocumentSI->supportsService( SERVICE_TEXT_DOCUMENT ) )
+ { // writer
+ sConfigurationLocation = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "/org.openoffice.Office.Writer/Layout/Other" ) );
+ sConfigurationProperty = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "MeasureUnit" ) );
+ }
+ else if ( xDocumentSI->supportsService( SERVICE_SPREADSHEET_DOCUMENT ) )
+ { // calc
+ sConfigurationLocation = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "/org.openoffice.Office.Calc/Layout/Other/MeasureUnit" ) );
+ sConfigurationProperty = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Metric" ) );
+ }
+ else if ( xDocumentSI->supportsService( SERVICE_DRAWING_DOCUMENT ) )
+ {
+ sConfigurationLocation = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "/org.openoffice.Office.Draw/Layout/Other/MeasureUnit" ) );
+ sConfigurationProperty = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Metric" ) );
+ }
+ else if ( xDocumentSI->supportsService( SERVICE_PRESENTATION_DOCUMENT ) )
+ {
+ sConfigurationLocation = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "/org.openoffice.Office.Impress/Layout/Other/MeasureUnit" ) );
+ sConfigurationProperty = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Metric" ) );
+ }
+
+ // read the measurement unit from the configuration
+ if ( sConfigurationLocation.getLength() && sConfigurationProperty.getLength() )
+ {
+ ::utl::OConfigurationTreeRoot aConfigTree( ::utl::OConfigurationTreeRoot::createWithServiceFactory(
+ m_aContext.getLegacyServiceFactory(), sConfigurationLocation, -1, ::utl::OConfigurationTreeRoot::CM_READONLY ) );
+ sal_Int32 nUnitAsInt = (sal_Int32)FUNIT_NONE;
+ aConfigTree.getNodeValue( sConfigurationProperty ) >>= nUnitAsInt;
+
+ // if this denotes a valid (and accepted) unit, then use it
+ if ( ( nUnitAsInt > FUNIT_NONE ) && ( nUnitAsInt <= FUNIT_100TH_MM ) )
+ eUnit = static_cast< FieldUnit >( nUnitAsInt );
+ }
+ }
+
+ if ( FUNIT_NONE == eUnit )
+ {
+ MeasurementSystem eSystem = SvtSysLocale().GetLocaleData().getMeasurementSystemEnum();
+ eUnit = MEASURE_METRIC == eSystem ? FUNIT_CM : FUNIT_INCH;
+ }
+
+ return VCLUnoHelper::ConvertToMeasurementUnit( eUnit, 1 );
+ }
+
+ //====================================================================
+ //= PropertyHandlerComponent
+ //====================================================================
+ //------------------------------------------------------------------------
+ PropertyHandlerComponent::PropertyHandlerComponent( const Reference< XComponentContext >& _rxContext )
+ :PropertyHandler( _rxContext )
+ {
+ }
+
+ //--------------------------------------------------------------------
+ IMPLEMENT_FORWARD_XINTERFACE2( PropertyHandlerComponent, PropertyHandler, PropertyHandlerComponent_Base )
+ IMPLEMENT_FORWARD_XTYPEPROVIDER2( PropertyHandlerComponent, PropertyHandler, PropertyHandlerComponent_Base )
+
+ //--------------------------------------------------------------------
+ ::sal_Bool SAL_CALL PropertyHandlerComponent::supportsService( const ::rtl::OUString& ServiceName ) throw (RuntimeException)
+ {
+ StlSyntaxSequence< ::rtl::OUString > aAllServices( getSupportedServiceNames() );
+ return ::std::find( aAllServices.begin(), aAllServices.end(), ServiceName ) != aAllServices.end();
+ }
+
+//........................................................................
+} // namespace pcr
+//........................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/propctrlr/propertyhandler.hxx b/extensions/source/propctrlr/propertyhandler.hxx
new file mode 100644
index 000000000000..8e5fa68ea67c
--- /dev/null
+++ b/extensions/source/propctrlr/propertyhandler.hxx
@@ -0,0 +1,457 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef EXTENSIONS_SOURCE_PROPCTRLR_PROPERTYHANDLER_HXX
+#define EXTENSIONS_SOURCE_PROPCTRLR_PROPERTYHANDLER_HXX
+
+#include "pcrcomponentcontext.hxx"
+#include "pcrcommon.hxx"
+#include "modulepcr.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/uno/XComponentContext.hpp>
+#include <com/sun/star/beans/PropertyState.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/beans/Property.hpp>
+#include <com/sun/star/script/XTypeConverter.hpp>
+#include <com/sun/star/frame/XModel.hpp>
+#include <com/sun/star/uno/Sequence.hxx>
+#include <com/sun/star/uno/Any.hxx>
+#include <com/sun/star/util/Date.hpp>
+#include <com/sun/star/util/Time.hpp>
+#include <com/sun/star/util/DateTime.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/inspection/XPropertyHandler.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+/** === end UNO includes === **/
+#include <osl/interlck.h>
+#include <cppuhelper/compbase1.hxx>
+#include <cppuhelper/implbase1.hxx>
+#include <comphelper/uno3.hxx>
+
+#include <memory>
+#include <vector>
+
+namespace com { namespace sun { namespace star {
+ namespace inspection {
+ struct LineDescriptor;
+ class XPropertyControlFactory;
+ }
+} } }
+
+class Window;
+//........................................................................
+namespace pcr
+{
+//........................................................................
+
+ typedef sal_Int32 PropertyId;
+
+ //====================================================================
+ //= PropertyHandler
+ //====================================================================
+ class OPropertyInfoService;
+ typedef ::cppu::WeakComponentImplHelper1 < ::com::sun::star::inspection::XPropertyHandler
+ > PropertyHandler_Base;
+ /** the base class for property handlers
+ */
+ class PropertyHandler : public PropertyHandler_Base
+ {
+ private:
+ /// cache for getSupportedProperties
+ mutable StlSyntaxSequence< ::com::sun::star::beans::Property >
+ m_aSupportedProperties;
+ mutable bool m_bSupportedPropertiesAreKnown;
+
+ /// helper which ensures that we can access resources as long as the instance lives
+ PcrClient m_aEnsureResAccess;
+
+ private:
+ /// the property listener which has been registered
+ PropertyChangeListeners m_aPropertyListeners;
+
+ protected:
+ mutable ::osl::Mutex m_aMutex;
+ /// the context in which the instance was created
+ ComponentContext m_aContext;
+ /// the component we're inspecting
+ ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > m_xComponent;
+ /// info about our component's properties
+ ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > m_xComponentPropertyInfo;
+ /// type converter, needed on various occasions
+ ::com::sun::star::uno::Reference< ::com::sun::star::script::XTypeConverter > m_xTypeConverter;
+ /// access to property meta data
+ ::std::auto_ptr< OPropertyInfoService > m_pInfoService;
+
+ protected:
+ PropertyHandler(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _rxContext
+ );
+ ~PropertyHandler();
+
+ // default implementations for XPropertyHandler
+ virtual void SAL_CALL inspect( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxIntrospectee ) throw (::com::sun::star::uno::RuntimeException, ::com::sun::star::lang::NullPointerException);
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property > SAL_CALL getSupportedProperties() throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupersededProperties( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getActuatingProperties( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Any SAL_CALL convertToPropertyValue( const ::rtl::OUString& _rPropertyName, const ::com::sun::star::uno::Any& _rControlValue ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Any SAL_CALL convertToControlValue( const ::rtl::OUString& _rPropertyName, const ::com::sun::star::uno::Any& _rPropertyValue, const ::com::sun::star::uno::Type& _rControlValueType ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::beans::PropertyState SAL_CALL getPropertyState( const ::rtl::OUString& _rPropertyName ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::inspection::LineDescriptor SAL_CALL describePropertyLine( const ::rtl::OUString& _rPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyControlFactory >& _rxControlFactory ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::NullPointerException, ::com::sun::star::uno::RuntimeException);
+ virtual ::sal_Bool SAL_CALL isComposable( const ::rtl::OUString& _rPropertyName ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::inspection::InteractiveSelectionResult SAL_CALL onInteractivePropertySelection( const ::rtl::OUString& _rPropertyName, sal_Bool _bPrimary, ::com::sun::star::uno::Any& _rData, const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XObjectInspectorUI >& _rxInspectorUI ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::NullPointerException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL actuatingPropertyChanged( const ::rtl::OUString& _rActuatingPropertyName, const ::com::sun::star::uno::Any& _rNewValue, const ::com::sun::star::uno::Any& _rOldValue, const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XObjectInspectorUI >& _rxInspectorUI, sal_Bool _bFirstTimeInit ) throw (::com::sun::star::lang::NullPointerException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL addPropertyChangeListener( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& _rxListener ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL removePropertyChangeListener( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& _rxListener ) throw (::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL suspend( sal_Bool _bSuspend ) throw (::com::sun::star::uno::RuntimeException);
+
+ // XComponent
+ DECLARE_XCOMPONENT()
+ virtual void SAL_CALL disposing();
+
+ // own overridables
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property >
+ SAL_CALL doDescribeSupportedProperties() const = 0;
+
+ /// called when XPropertyHandler::inspect has been called, and we thus have a new component to inspect
+ virtual void onNewComponent();
+
+ protected:
+ /** fires the change in a property value to our listener (if any)
+ @see addPropertyChangeListener
+ */
+ void firePropertyChange( const ::rtl::OUString& _rPropName, PropertyId _nPropId,
+ const ::com::sun::star::uno::Any& _rOldValue, const ::com::sun::star::uno::Any& _rNewValue ) SAL_THROW(());
+
+ /** retrieves a window which can be used as parent for dialogs
+ */
+ Window* impl_getDefaultDialogParent_nothrow() const;
+
+ /** retrieves the property id for a given property name
+ @throw com::sun::star::beans::UnknownPropertyException
+ if the property name is not known to our ->m_pInfoService
+ */
+ PropertyId impl_getPropertyId_throw( const ::rtl::OUString& _rPropertyName ) const;
+
+ //-------------------------------------------------------------------------------
+ // helper for implementing doDescribeSupportedProperties
+ /** adds a description for the given string property to the given property vector
+ Most probably to be called from within getSupportedProperties
+ */
+ inline void addStringPropertyDescription(
+ ::std::vector< ::com::sun::star::beans::Property >& _rProperties,
+ const ::rtl::OUString& _rPropertyName,
+ sal_Int16 _nAttribs = 0
+ ) const;
+
+ /** adds a description for the given int32 property to the given property vector
+ */
+ inline void addInt32PropertyDescription(
+ ::std::vector< ::com::sun::star::beans::Property >& _rProperties,
+ const ::rtl::OUString& _rPropertyName,
+ sal_Int16 _nAttribs = 0
+ ) const;
+
+ /** adds a description for the given int16 property to the given property vector
+ */
+ inline void addInt16PropertyDescription(
+ ::std::vector< ::com::sun::star::beans::Property >& _rProperties,
+ const ::rtl::OUString& _rPropertyName,
+ sal_Int16 _nAttribs = 0
+ ) const;
+
+ /** adds a description for the given double property to the given property vector
+ */
+ inline void addDoublePropertyDescription(
+ ::std::vector< ::com::sun::star::beans::Property >& _rProperties,
+ const ::rtl::OUString& _rPropertyName,
+ sal_Int16 _nAttribs = 0
+ ) const;
+
+ /** adds a description for the given date property to the given property vector
+ */
+ inline void addDatePropertyDescription(
+ ::std::vector< ::com::sun::star::beans::Property >& _rProperties,
+ const ::rtl::OUString& _rPropertyName,
+ sal_Int16 _nAttribs = 0
+ ) const;
+
+ /** adds a description for the given time property to the given property vector
+ */
+ inline void addTimePropertyDescription(
+ ::std::vector< ::com::sun::star::beans::Property >& _rProperties,
+ const ::rtl::OUString& _rPropertyName,
+ sal_Int16 _nAttribs = 0
+ ) const;
+
+ /** adds a description for the given DateTime property to the given property vector
+ */
+ inline void addDateTimePropertyDescription(
+ ::std::vector< ::com::sun::star::beans::Property >& _rProperties,
+ const ::rtl::OUString& _rPropertyName,
+ sal_Int16 _nAttribs = 0
+ ) const;
+
+ /// adds a Property, given by name only, to a given vector of Properties
+ void implAddPropertyDescription(
+ ::std::vector< ::com::sun::star::beans::Property >& _rProperties,
+ const ::rtl::OUString& _rPropertyName,
+ const ::com::sun::star::uno::Type& _rType,
+ sal_Int16 _nAttribs = 0
+ ) const;
+
+ //-------------------------------------------------------------------------------
+ // helper for accessing and maintaining meta data about our supported properties
+
+ /** retrieves a property given by handle
+
+ @return
+ a pointer to the descriptor for the given properties, if it is one of our
+ supported properties, <NULL/> else.
+
+ @see doDescribeSupportedProperties
+ @see impl_getPropertyFromId_throw
+ */
+ const ::com::sun::star::beans::Property*
+ impl_getPropertyFromId_nothrow( PropertyId _nPropId ) const;
+
+ /** retrieves a property given by handle
+
+ @throws UnknownPropertyException
+ if the handler does not support a property with the given handle
+
+ @seealso doDescribeSupportedProperties
+ @see impl_getPropertyFromId_nothrow
+ */
+ const ::com::sun::star::beans::Property&
+ impl_getPropertyFromId_throw( PropertyId _nPropId ) const;
+
+ /** determines whether a given property id is part of our supported properties
+ @see getSupportedProperties
+ @see doDescribeSupportedProperties
+ */
+ inline bool impl_isSupportedProperty_nothrow( PropertyId _nPropId ) const
+ {
+ return impl_getPropertyFromId_nothrow( _nPropId ) != NULL;
+ }
+
+ /** retrieves a property given by name
+
+ @throws UnknownPropertyException
+ if the handler does not support a property with the given name
+
+ @seealso doDescribeSupportedProperties
+ */
+ const ::com::sun::star::beans::Property&
+ impl_getPropertyFromName_throw( const ::rtl::OUString& _rPropertyName ) const;
+
+ /** get the name of a property given by handle
+ */
+ inline ::rtl::OUString
+ impl_getPropertyNameFromId_nothrow( PropertyId _nPropId ) const;
+
+ /** returns the value of the ContextDocument property in the ComponentContext which was used to create
+ this handler.
+ */
+ inline ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >
+ impl_getContextDocument_nothrow() const
+ {
+ return ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >(
+ m_aContext.getContextValueByAsciiName( "ContextDocument" ), ::com::sun::star::uno::UNO_QUERY );
+ }
+
+ /** marks the context document as modified
+
+ @see impl_getContextDocument_nothrow
+ */
+ void impl_setContextDocumentModified_nothrow() const;
+
+ /// determines whether our component has a given property
+ bool impl_componentHasProperty_throw( const ::rtl::OUString& _rPropName ) const;
+
+ /** determines the default measure unit for the document in which our component lives
+ */
+ sal_Int16 impl_getDocumentMeasurementUnit_throw() const;
+
+ private:
+ PropertyHandler(); // never implemented
+ PropertyHandler( const PropertyHandler& ); // never implemented
+ PropertyHandler& operator=( const PropertyHandler& ); // never implemented
+ };
+
+ //--------------------------------------------------------------------
+ inline void PropertyHandler::addStringPropertyDescription( ::std::vector< ::com::sun::star::beans::Property >& _rProperties, const ::rtl::OUString& _rPropertyName, sal_Int16 _nAttribs ) const
+ {
+ implAddPropertyDescription( _rProperties, _rPropertyName, ::getCppuType( static_cast< ::rtl::OUString* >( NULL ) ), _nAttribs );
+ }
+
+ inline void PropertyHandler::addInt32PropertyDescription( ::std::vector< ::com::sun::star::beans::Property >& _rProperties, const ::rtl::OUString& _rPropertyName, sal_Int16 _nAttribs ) const
+ {
+ implAddPropertyDescription( _rProperties, _rPropertyName, ::getCppuType( static_cast< sal_Int32* >( NULL ) ), _nAttribs );
+ }
+
+ inline void PropertyHandler::addInt16PropertyDescription( ::std::vector< ::com::sun::star::beans::Property >& _rProperties, const ::rtl::OUString& _rPropertyName, sal_Int16 _nAttribs ) const
+ {
+ implAddPropertyDescription( _rProperties, _rPropertyName, ::getCppuType( static_cast< sal_Int16* >( NULL ) ), _nAttribs );
+ }
+
+ inline void PropertyHandler::addDoublePropertyDescription( ::std::vector< ::com::sun::star::beans::Property >& _rProperties, const ::rtl::OUString& _rPropertyName, sal_Int16 _nAttribs ) const
+ {
+ implAddPropertyDescription( _rProperties, _rPropertyName, ::getCppuType( static_cast< double* >( NULL ) ), _nAttribs );
+ }
+
+ inline void PropertyHandler::addDatePropertyDescription( ::std::vector< ::com::sun::star::beans::Property >& _rProperties, const ::rtl::OUString& _rPropertyName, sal_Int16 _nAttribs ) const
+ {
+ implAddPropertyDescription( _rProperties, _rPropertyName, ::getCppuType( static_cast< com::sun::star::util::Date* >( NULL ) ), _nAttribs );
+ }
+
+ inline void PropertyHandler::addTimePropertyDescription( ::std::vector< ::com::sun::star::beans::Property >& _rProperties, const ::rtl::OUString& _rPropertyName, sal_Int16 _nAttribs ) const
+ {
+ implAddPropertyDescription( _rProperties, _rPropertyName, ::getCppuType( static_cast< com::sun::star::util::Time* >( NULL ) ), _nAttribs );
+ }
+
+ inline void PropertyHandler::addDateTimePropertyDescription( ::std::vector< ::com::sun::star::beans::Property >& _rProperties, const ::rtl::OUString& _rPropertyName, sal_Int16 _nAttribs ) const
+ {
+ implAddPropertyDescription( _rProperties, _rPropertyName, ::getCppuType( static_cast< com::sun::star::util::DateTime* >( NULL ) ), _nAttribs );
+ }
+
+ inline ::rtl::OUString PropertyHandler::impl_getPropertyNameFromId_nothrow( PropertyId _nPropId ) const
+ {
+ const ::com::sun::star::beans::Property* pProp = impl_getPropertyFromId_nothrow( _nPropId );
+ return pProp ? pProp->Name : ::rtl::OUString();
+ }
+
+ //====================================================================
+ //= PropertyHandlerComponent
+ //====================================================================
+ typedef ::cppu::ImplHelper1 < ::com::sun::star::lang::XServiceInfo
+ > PropertyHandlerComponent_Base;
+ /** PropertyHandler implementation which additionally supports XServiceInfo
+ */
+ class PropertyHandlerComponent :public PropertyHandler
+ ,public PropertyHandlerComponent_Base
+ {
+ protected:
+ PropertyHandlerComponent(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _rxContext
+ );
+
+ DECLARE_XINTERFACE()
+ DECLARE_XTYPEPROVIDER()
+
+ // XServiceInfo
+ virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw (::com::sun::star::uno::RuntimeException) = 0;
+ virtual ::sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw (::com::sun::star::uno::RuntimeException) = 0;
+ };
+
+ //====================================================================
+ //= HandlerComponentBase
+ //====================================================================
+ /** a PropertyHandlerComponent implementation which routes XServiceInfo::getImplementationName and
+ XServiceInfo::getSupportedServiceNames to static versions of those methods, which are part of
+ the derived class.
+
+ Additionally, a method <member>Create</member> is provided which takes a component context, and returns a new
+ instance of the derived class. This <member>Create</member> is used to register the implementation
+ of the derived class at the <type>PcrModule</type>.
+
+ Well, every time we're talking about derived class, we in fact mean the template argument of
+ <type>HandlerComponentBase</type>. But usually this equals your derived class:
+ <pre>
+ class MyHandler;
+ typedef HandlerComponentBase< MyHandler > MyHandler_Base;
+ class MyHandler : MyHandler_Base
+ {
+ ...
+ public:
+ static ::rtl::OUString SAL_CALL getImplementationName_static( ) throw (::com::sun::star::uno::RuntimeException);
+ static ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames_static( ) throw (::com::sun::star::uno::RuntimeException);
+ };
+ </pre>
+ */
+ template < class HANDLER >
+ class HandlerComponentBase : public PropertyHandlerComponent
+ {
+ protected:
+ HandlerComponentBase( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _rxContext )
+ :PropertyHandlerComponent( _rxContext )
+ {
+ }
+
+ protected:
+ // XServiceInfo
+ virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw (::com::sun::star::uno::RuntimeException);
+ static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL Create( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _rxContext );
+
+ public:
+ /** registers the implementation of HANDLER at the <type>PcrModule</type>
+ */
+ static void registerImplementation();
+ };
+
+ //--------------------------------------------------------------------
+ template < class HANDLER >
+ ::rtl::OUString SAL_CALL HandlerComponentBase< HANDLER >::getImplementationName( ) throw (::com::sun::star::uno::RuntimeException)
+ {
+ return HANDLER::getImplementationName_static();
+ }
+
+ //--------------------------------------------------------------------
+ template < class HANDLER >
+ ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL HandlerComponentBase< HANDLER >::getSupportedServiceNames( ) throw (::com::sun::star::uno::RuntimeException)
+ {
+ return HANDLER::getSupportedServiceNames_static();
+ }
+
+ //--------------------------------------------------------------------
+ template < class HANDLER >
+ void HandlerComponentBase< HANDLER >::registerImplementation()
+ {
+ PcrModule::getInstance().registerImplementation(
+ HANDLER::getImplementationName_static(),
+ HANDLER::getSupportedServiceNames_static(),
+ HANDLER::Create
+ );
+ }
+
+ //--------------------------------------------------------------------
+ template < class HANDLER >
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL HandlerComponentBase< HANDLER >::Create( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _rxContext )
+ {
+ return *( new HANDLER( _rxContext ) );
+ }
+
+//........................................................................
+} // namespace pcr
+//........................................................................
+
+#endif // EXTENSIONS_SOURCE_PROPCTRLR_PROPERTYHANDLER_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/propctrlr/propertyinfo.hxx b/extensions/source/propctrlr/propertyinfo.hxx
new file mode 100644
index 000000000000..4c46361f6d84
--- /dev/null
+++ b/extensions/source/propctrlr/propertyinfo.hxx
@@ -0,0 +1,67 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _EXTENSIONS_PROPCTRLR_PROPERTYINFO_HXX_
+#define _EXTENSIONS_PROPCTRLR_PROPERTYINFO_HXX_
+
+#include <sal/types.h>
+#include <tools/string.hxx>
+#include <rtl/ustring.hxx>
+#include <vector>
+
+//............................................................................
+namespace pcr
+{
+//............................................................................
+
+ //========================================================================
+ //= IPropertyInfoService
+ //========================================================================
+ class SAL_NO_VTABLE IPropertyInfoService
+ {
+ public:
+ virtual sal_Int32 getPropertyId(const String& _rName) const = 0;
+ virtual String getPropertyTranslation(sal_Int32 _nId) const = 0;
+ virtual sal_Int32 getPropertyHelpId(sal_Int32 _nId) const = 0;
+ virtual sal_Int16 getPropertyPos(sal_Int32 _nId) const = 0;
+ virtual sal_uInt32 getPropertyUIFlags(sal_Int32 _nId) const = 0;
+ virtual ::std::vector< ::rtl::OUString > getPropertyEnumRepresentations(sal_Int32 _nId) const = 0;
+
+ // this is only temporary, until the UNOization of the property browser is completed
+ virtual String getPropertyName( sal_Int32 _nPropId ) = 0;
+
+ virtual ~IPropertyInfoService() { }
+ };
+
+//............................................................................
+} // namespace pcr
+//............................................................................
+
+#endif // _EXTENSIONS_PROPCTRLR_PROPERTYINFO_HXX_
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/propctrlr/propeventtranslation.cxx b/extensions/source/propctrlr/propeventtranslation.cxx
new file mode 100644
index 000000000000..d3dabd93fe31
--- /dev/null
+++ b/extensions/source/propctrlr/propeventtranslation.cxx
@@ -0,0 +1,107 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+#include "propeventtranslation.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/lang/DisposedException.hpp>
+#include <com/sun/star/lang/NullPointerException.hpp>
+/** === end UNO includes === **/
+
+//........................................................................
+namespace pcr
+{
+//........................................................................
+
+ /** === begin UNO using === **/
+ using ::com::sun::star::beans::PropertyChangeEvent;
+ using ::com::sun::star::uno::RuntimeException;
+ using ::com::sun::star::lang::EventObject;
+ using ::com::sun::star::uno::Reference;
+ using ::com::sun::star::beans::XPropertyChangeListener;
+ using ::com::sun::star::uno::XInterface;
+ using ::com::sun::star::beans::PropertyChangeEvent;
+ using ::com::sun::star::lang::DisposedException;
+ using ::com::sun::star::lang::NullPointerException;
+ /** === end UNO using === **/
+
+ //====================================================================
+ //= PropertyEventTranslation
+ //====================================================================
+ //--------------------------------------------------------------------
+ PropertyEventTranslation::PropertyEventTranslation( const Reference< XPropertyChangeListener >& _rxDelegator,
+ const Reference< XInterface >& _rxTranslatedEventSource )
+ :m_xDelegator( _rxDelegator )
+ ,m_xTranslatedEventSource( _rxTranslatedEventSource )
+ {
+ if ( !m_xDelegator.is() )
+ throw NullPointerException();
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL PropertyEventTranslation::propertyChange( const PropertyChangeEvent& evt ) throw (RuntimeException)
+ {
+ if ( !m_xDelegator.is() )
+ throw DisposedException();
+
+ if ( !m_xTranslatedEventSource.is() )
+ m_xDelegator->propertyChange( evt );
+ else
+ {
+ PropertyChangeEvent aTranslatedEvent( evt );
+ aTranslatedEvent.Source = m_xTranslatedEventSource;
+ m_xDelegator->propertyChange( aTranslatedEvent );
+ }
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL PropertyEventTranslation::disposing( const EventObject& Source ) throw (RuntimeException)
+ {
+ if ( !m_xDelegator.is() )
+ throw DisposedException();
+
+ if ( !m_xTranslatedEventSource.is() )
+ m_xDelegator->disposing( Source );
+ else
+ {
+ EventObject aTranslatedEvent( Source );
+ aTranslatedEvent.Source = m_xTranslatedEventSource;
+ m_xDelegator->disposing( aTranslatedEvent );
+ }
+
+ m_xDelegator.clear();
+ m_xTranslatedEventSource.clear();
+ }
+
+//........................................................................
+} // namespace pcr
+//........................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/propctrlr/propeventtranslation.hxx b/extensions/source/propctrlr/propeventtranslation.hxx
new file mode 100644
index 000000000000..c5f5c8165b7c
--- /dev/null
+++ b/extensions/source/propctrlr/propeventtranslation.hxx
@@ -0,0 +1,86 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef EXTENSIONS_SOURCE_PROPCTRLR_PROPEVENTTRANSLATION_HXX
+#define EXTENSIONS_SOURCE_PROPCTRLR_PROPEVENTTRANSLATION_HXX
+
+/** === begin UNO includes === **/
+#include <com/sun/star/beans/XPropertyChangeListener.hpp>
+/** === end UNO includes === **/
+#include <cppuhelper/implbase1.hxx>
+
+//........................................................................
+namespace pcr
+{
+//........................................................................
+
+ //====================================================================
+ //= PropertyEventTranslation
+ //====================================================================
+ typedef ::cppu::WeakImplHelper1 < ::com::sun::star::beans::XPropertyChangeListener
+ > PropertyEventTranslation_Base;
+
+ class PropertyEventTranslation : public PropertyEventTranslation_Base
+ {
+ ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >
+ m_xDelegator;
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >
+ m_xTranslatedEventSource;
+
+ public:
+ /** constructs the object
+ @throws NullPointerException
+ if <arg>_rxDelegator</arg> is <NULL/>
+ */
+ PropertyEventTranslation(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& _rxDelegator,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxTranslatedEventSource
+ );
+
+ inline const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >&
+ getDelegator() const { return m_xDelegator; }
+
+ protected:
+ // XPropertyChangeListener
+ virtual void SAL_CALL propertyChange( const ::com::sun::star::beans::PropertyChangeEvent& evt ) throw (::com::sun::star::uno::RuntimeException);
+ // XEventListener
+ virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw (::com::sun::star::uno::RuntimeException);
+
+ private:
+ PropertyEventTranslation(); // never implemented
+ PropertyEventTranslation( const PropertyEventTranslation& ); // never implemented
+ PropertyEventTranslation& operator=( const PropertyEventTranslation& ); // never implemented
+ };
+
+//........................................................................
+} // namespace pcr
+//........................................................................
+
+#endif // EXTENSIONS_SOURCE_PROPCTRLR_PROPEVENTTRANSLATION_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/propctrlr/proplinelistener.hxx b/extensions/source/propctrlr/proplinelistener.hxx
new file mode 100644
index 000000000000..e1eb39e645fe
--- /dev/null
+++ b/extensions/source/propctrlr/proplinelistener.hxx
@@ -0,0 +1,53 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _EXTENSIONS_PROPCTRLR_PROPLINELISTENER_HXX_
+#define _EXTENSIONS_PROPCTRLR_PROPLINELISTENER_HXX_
+
+#include <tools/string.hxx>
+
+//........................................................................
+namespace pcr
+{
+//........................................................................
+
+ //====================================================================
+ class IPropertyLineListener
+ {
+ public:
+ virtual void Clicked( const ::rtl::OUString& _rName, sal_Bool _bPrimary ) = 0;
+ virtual void Commit( const ::rtl::OUString& _rName, const ::com::sun::star::uno::Any& _rVal ) = 0;
+ };
+
+//............................................................................
+} // namespace pcr
+//............................................................................
+
+#endif // _EXTENSIONS_PROPCTRLR_PROPLINELISTENER_HXX_
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/propctrlr/propres.src b/extensions/source/propctrlr/propres.src
new file mode 100644
index 000000000000..6449f86f045c
--- /dev/null
+++ b/extensions/source/propctrlr/propres.src
@@ -0,0 +1,68 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef EXTENSIONS_PROPRESID_HRC
+#include "propresid.hrc"
+#endif
+#include "formresid.hrc"
+
+String RID_STR_STANDARD
+{
+ Text [ en-US ] = "Default" ;
+};
+String RID_STR_PROPPAGE_DEFAULT
+{
+ Text [ en-US ] = "General" ;
+};
+String RID_STR_PROPPAGE_DATA
+{
+ Text [ en-US ] = "Data" ;
+};
+Resource RID_RSC_ENUM_YESNO
+{
+ String 1
+ {
+ Text [ en-US ] = "No" ;
+ };
+ String 2
+ {
+ Text [ en-US ] = "Yes" ;
+ };
+};
+String RID_STR_HELP_SECTION_LABEL
+{
+ Text [ en-US ] = "Help";
+};
+String RID_EMBED_IMAGE_PLACEHOLDER
+{
+ Text [ en-US ] = "<Embedded-Image>";
+};
+
+String RID_STR_TEXT_FORMAT
+{
+ Text [ en-US ] = "Text";
+};
diff --git a/extensions/source/propctrlr/propresid.hrc b/extensions/source/propctrlr/propresid.hrc
new file mode 100644
index 000000000000..e1fc83667ca2
--- /dev/null
+++ b/extensions/source/propctrlr/propresid.hrc
@@ -0,0 +1,48 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef EXTENSIONS_PROPRESID_HRC
+#define EXTENSIONS_PROPRESID_HRC
+
+// TODO: create a new resource range in <svl/solar.hrc>
+
+#define RID_PROPCONTROLLER_START 1000
+ // arbitrary at the moment
+#define RID_FORMBROWSER_START RID_PROPCONTROLLER_START + 2000
+
+// -----------------------------------------------------------------------
+// - Strings
+// -----------------------------------------------------------------------
+
+#define RID_STR_STANDARD ( RID_PROPCONTROLLER_START + 0 )
+#define RID_STR_PROPPAGE_DEFAULT ( RID_PROPCONTROLLER_START + 1 )
+#define RID_STR_PROPPAGE_DATA ( RID_PROPCONTROLLER_START + 2 )
+#define RID_STR_HELP_SECTION_LABEL ( RID_PROPCONTROLLER_START + 3 )
+#define RID_EMBED_IMAGE_PLACEHOLDER ( RID_PROPCONTROLLER_START + 4 )
+#define RID_STR_TEXT_FORMAT ( RID_PROPCONTROLLER_START + 5 )
+
+#endif // EXTENSIONS_PROPRESID_HRC
diff --git a/extensions/source/propctrlr/pushbuttonnavigation.cxx b/extensions/source/propctrlr/pushbuttonnavigation.cxx
new file mode 100644
index 000000000000..6195b99374b3
--- /dev/null
+++ b/extensions/source/propctrlr/pushbuttonnavigation.cxx
@@ -0,0 +1,309 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+#include "pushbuttonnavigation.hxx"
+#include <com/sun/star/form/FormButtonType.hpp>
+#include <com/sun/star/beans/XPropertyState.hpp>
+#include "formstrings.hxx"
+#include <cppuhelper/extract.hxx>
+#include <comphelper/property.hxx>
+#include <osl/diagnose.h>
+#include <tools/diagnose_ex.h>
+
+//............................................................................
+namespace pcr
+{
+//............................................................................
+
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::beans;
+ using namespace ::com::sun::star::form;
+
+ //------------------------------------------------------------------------
+ namespace
+ {
+ static const sal_Int32 s_nFirstVirtualButtonType = 1 + (sal_Int32)FormButtonType_URL;
+
+ static const sal_Char* pNavigationURLs[] =
+ {
+ ".uno:FormController/moveToFirst",
+ ".uno:FormController/moveToPrev",
+ ".uno:FormController/moveToNext",
+ ".uno:FormController/moveToLast",
+ ".uno:FormController/saveRecord",
+ ".uno:FormController/undoRecord",
+ ".uno:FormController/moveToNew",
+ ".uno:FormController/deleteRecord",
+ ".uno:FormController/refreshForm",
+ NULL
+ };
+
+ static sal_Int32 lcl_getNavigationURLIndex( const ::rtl::OUString& _rNavURL )
+ {
+ const sal_Char** pLookup = pNavigationURLs;
+ while ( *pLookup )
+ {
+ if ( _rNavURL.equalsAscii( *pLookup ) )
+ return pLookup - pNavigationURLs;
+ ++pLookup;
+ }
+ return -1;
+ }
+
+ static const sal_Char* lcl_getNavigationURL( sal_Int32 _nButtonTypeIndex )
+ {
+ const sal_Char** pLookup = pNavigationURLs;
+ while ( _nButtonTypeIndex-- && *pLookup++ )
+ ;
+ OSL_ENSURE( *pLookup, "lcl_getNavigationURL: invalid index!" );
+ return *pLookup;
+ }
+ }
+
+ //========================================================================
+ //= PushButtonNavigation
+ //========================================================================
+ //------------------------------------------------------------------------
+ PushButtonNavigation::PushButtonNavigation( const Reference< XPropertySet >& _rxControlModel )
+ :m_xControlModel( _rxControlModel )
+ ,m_bIsPushButton( sal_False )
+ {
+ OSL_ENSURE( m_xControlModel.is(), "PushButtonNavigation::PushButtonNavigation: invalid control model!" );
+
+ try
+ {
+ m_bIsPushButton = ::comphelper::hasProperty( PROPERTY_BUTTONTYPE, m_xControlModel );
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "PushButtonNavigation::PushButtonNavigation: caught an exception!" );
+ }
+ }
+
+ //------------------------------------------------------------------------
+ sal_Int32 PushButtonNavigation::implGetCurrentButtonType() const SAL_THROW((Exception))
+ {
+ sal_Int32 nButtonType = FormButtonType_PUSH;
+ if ( !m_xControlModel.is() )
+ return nButtonType;
+ OSL_VERIFY( ::cppu::enum2int( nButtonType, m_xControlModel->getPropertyValue( PROPERTY_BUTTONTYPE ) ) );
+
+ if ( nButtonType == FormButtonType_URL )
+ {
+ // there's a chance that this is a "virtual" button type
+ // (which are realized by special URLs)
+ ::rtl::OUString sTargetURL;
+ m_xControlModel->getPropertyValue( PROPERTY_TARGET_URL ) >>= sTargetURL;
+
+ sal_Int32 nNavigationURLIndex = lcl_getNavigationURLIndex( sTargetURL );
+ if ( nNavigationURLIndex >= 0)
+ // it actually *is* a virtual button type
+ nButtonType = s_nFirstVirtualButtonType + nNavigationURLIndex;
+ }
+ return nButtonType;
+ }
+
+ //------------------------------------------------------------------------
+ Any PushButtonNavigation::getCurrentButtonType() const SAL_THROW(())
+ {
+ OSL_ENSURE( m_bIsPushButton, "PushButtonNavigation::getCurrentButtonType: not expected to be called for forms!" );
+ Any aReturn;
+
+ try
+ {
+ aReturn <<= implGetCurrentButtonType();
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "PushButtonNavigation::getCurrentButtonType: caught an exception!" );
+ }
+ return aReturn;
+ }
+
+ //------------------------------------------------------------------------
+ void PushButtonNavigation::setCurrentButtonType( const Any& _rValue ) const SAL_THROW(())
+ {
+ OSL_ENSURE( m_bIsPushButton, "PushButtonNavigation::setCurrentButtonType: not expected to be called for forms!" );
+ if ( !m_xControlModel.is() )
+ return;
+
+ try
+ {
+ sal_Int32 nButtonType = FormButtonType_PUSH;
+ OSL_VERIFY( ::cppu::enum2int( nButtonType, _rValue ) );
+ ::rtl::OUString sTargetURL;
+
+ bool bIsVirtualButtonType = nButtonType >= s_nFirstVirtualButtonType;
+ if ( bIsVirtualButtonType )
+ {
+ const sal_Char* pURL = lcl_getNavigationURL( nButtonType - s_nFirstVirtualButtonType );
+ sTargetURL = ::rtl::OUString::createFromAscii( pURL );
+
+ nButtonType = FormButtonType_URL;
+ }
+
+ m_xControlModel->setPropertyValue( PROPERTY_BUTTONTYPE, makeAny( static_cast< FormButtonType >( nButtonType ) ) );
+ m_xControlModel->setPropertyValue( PROPERTY_TARGET_URL, makeAny( sTargetURL ) );
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "PushButtonNavigation::setCurrentButtonType: caught an exception!" );
+ }
+ }
+
+ //------------------------------------------------------------------------
+ PropertyState PushButtonNavigation::getCurrentButtonTypeState( ) const SAL_THROW(())
+ {
+ OSL_ENSURE( m_bIsPushButton, "PushButtonNavigation::getCurrentButtonTypeState: not expected to be called for forms!" );
+ PropertyState eState = PropertyState_DIRECT_VALUE;
+
+ try
+ {
+ Reference< XPropertyState > xStateAccess( m_xControlModel, UNO_QUERY );
+ if ( xStateAccess.is() )
+ {
+ // let's see what the model says about the ButtonType property
+ eState = xStateAccess->getPropertyState( PROPERTY_BUTTONTYPE );
+ if ( eState == PropertyState_DIRECT_VALUE )
+ {
+ sal_Int32 nRealButtonType = FormButtonType_PUSH;
+ OSL_VERIFY( ::cppu::enum2int( nRealButtonType, m_xControlModel->getPropertyValue( PROPERTY_BUTTONTYPE ) ) );
+ // perhaps it's one of the virtual button types?
+ if ( FormButtonType_URL == nRealButtonType )
+ {
+ // yes, it is -> rely on the state of the URL property
+ eState = xStateAccess->getPropertyState( PROPERTY_TARGET_URL );
+ }
+ }
+ }
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "PushButtonNavigation::getCurrentButtonTypeState: caught an exception!" );
+ }
+
+ return eState;
+ }
+
+ //------------------------------------------------------------------------
+ Any PushButtonNavigation::getCurrentTargetURL() const SAL_THROW(())
+ {
+ Any aReturn;
+ if ( !m_xControlModel.is() )
+ return aReturn;
+
+ try
+ {
+ aReturn = m_xControlModel->getPropertyValue( PROPERTY_TARGET_URL );
+ if ( m_bIsPushButton )
+ {
+ sal_Int32 nCurrentButtonType = implGetCurrentButtonType();
+ bool bIsVirtualButtonType = nCurrentButtonType >= s_nFirstVirtualButtonType;
+ if ( bIsVirtualButtonType )
+ {
+ // pretend (to the user) that there's no URL set - since
+ // virtual button types imply a special (technical) URL which
+ // the user should not see
+ aReturn <<= ::rtl::OUString();
+ }
+ }
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "PushButtonNavigation::getCurrentTargetURL: caught an exception!" );
+ }
+ return aReturn;
+ }
+
+ //------------------------------------------------------------------------
+ void PushButtonNavigation::setCurrentTargetURL( const Any& _rValue ) const SAL_THROW(())
+ {
+ if ( !m_xControlModel.is() )
+ return;
+
+ try
+ {
+ m_xControlModel->setPropertyValue( PROPERTY_TARGET_URL, _rValue );
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "PushButtonNavigation::setCurrentTargetURL: caught an exception!" );
+ }
+ }
+
+ //------------------------------------------------------------------------
+ PropertyState PushButtonNavigation::getCurrentTargetURLState( ) const SAL_THROW(())
+ {
+ PropertyState eState = PropertyState_DIRECT_VALUE;
+
+ try
+ {
+ Reference< XPropertyState > xStateAccess( m_xControlModel, UNO_QUERY );
+ if ( xStateAccess.is() )
+ {
+ eState = xStateAccess->getPropertyState( PROPERTY_TARGET_URL );
+ }
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "PushButtonNavigation::setCurrentTargetURL: caught an exception!" );
+ }
+
+ return eState;
+ }
+
+ //------------------------------------------------------------------------
+ bool PushButtonNavigation::currentButtonTypeIsOpenURL() const
+ {
+ sal_Int32 nButtonType( FormButtonType_PUSH );
+ try
+ {
+ nButtonType = implGetCurrentButtonType();
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ return nButtonType == FormButtonType_URL;
+ }
+
+ //------------------------------------------------------------------------
+ bool PushButtonNavigation::hasNonEmptyCurrentTargetURL() const
+ {
+ ::rtl::OUString sTargetURL;
+ OSL_VERIFY( getCurrentTargetURL() >>= sTargetURL );
+ return sTargetURL.getLength() != 0;
+ }
+
+//............................................................................
+} // namespace pcr
+//............................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/propctrlr/pushbuttonnavigation.hxx b/extensions/source/propctrlr/pushbuttonnavigation.hxx
new file mode 100644
index 000000000000..3626e4234eed
--- /dev/null
+++ b/extensions/source/propctrlr/pushbuttonnavigation.hxx
@@ -0,0 +1,111 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef EXTENSIONS_PROPCTRLR_PUSHBUTTONNAVIGATION_HXX
+#define EXTENSIONS_PROPCTRLR_PUSHBUTTONNAVIGATION_HXX
+
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/beans/PropertyState.hpp>
+
+//............................................................................
+namespace pcr
+{
+//............................................................................
+
+ //========================================================================
+ //= PushButtonNavigation
+ //========================================================================
+ class PushButtonNavigation
+ {
+ protected:
+ ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >
+ m_xControlModel;
+ sal_Bool m_bIsPushButton;
+
+ public:
+ /** ctor
+ @param _rxControlModel
+ the control model which is or will be bound
+ */
+ PushButtonNavigation(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxControlModel
+ );
+
+ /** returns the current value of the "ButtonType" property, taking into account
+ the "virtual" button types such as "move-to-next-record button".
+ */
+ ::com::sun::star::uno::Any
+ getCurrentButtonType() const SAL_THROW(());
+
+ /** sets the current value of the "ButtonType" property, taking into account
+ the "virtual" button types such as "move-to-next-record button".
+ */
+ void setCurrentButtonType( const ::com::sun::star::uno::Any& _rValue ) const SAL_THROW(());
+
+ /** retrieves the current state of the "ButtonType" property, taking into account
+ the "virtual" button types such as "move-to-next-record button".
+ */
+ ::com::sun::star::beans::PropertyState
+ getCurrentButtonTypeState( ) const SAL_THROW(());
+
+ /** returns the current value of the "TargetURL" property, taking into account
+ that some URLs are special values caused by "virtual" ButtonTypes
+ */
+ ::com::sun::star::uno::Any
+ getCurrentTargetURL() const SAL_THROW(());
+
+ /** sets the current value of the "TargetURL" property, taking into account
+ that some URLs are special values caused by "virtual" ButtonTypes
+ */
+ void setCurrentTargetURL( const ::com::sun::star::uno::Any& _rValue ) const SAL_THROW(());
+
+ /** retrieves the current state of the "TargetURL" property, taking into account
+ that some URLs are special values caused by "virtual" ButtonTypes
+ */
+ ::com::sun::star::beans::PropertyState
+ getCurrentTargetURLState( ) const SAL_THROW(());
+
+ /** determines whether the current button tpye is FormButtonType_URL
+ */
+ bool currentButtonTypeIsOpenURL() const;
+
+ /** determines whether the TargetURL property does currently denote a non-empty string
+ */
+ bool hasNonEmptyCurrentTargetURL() const;
+
+ private:
+ sal_Int32 implGetCurrentButtonType() const SAL_THROW(( ::com::sun::star::uno::Exception ));
+ };
+
+//............................................................................
+} // namespace pcr
+//............................................................................
+
+#endif // EXTENSIONS_PROPCTRLR_PUSHBUTTONNAVIGATION_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/propctrlr/selectlabeldialog.cxx b/extensions/source/propctrlr/selectlabeldialog.cxx
new file mode 100644
index 000000000000..d4237a52c6ac
--- /dev/null
+++ b/extensions/source/propctrlr/selectlabeldialog.cxx
@@ -0,0 +1,313 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+#include "selectlabeldialog.hxx"
+#include "formresid.hrc"
+#include "formbrowsertools.hxx"
+#include "formstrings.hxx"
+#include <com/sun/star/form/FormComponentType.hpp>
+#include <com/sun/star/container/XChild.hpp>
+#include <com/sun/star/container/XIndexAccess.hpp>
+#include <com/sun/star/sdbc/XResultSet.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <comphelper/property.hxx>
+#include <comphelper/types.hxx>
+
+//............................................................................
+namespace pcr
+{
+//............................................................................
+
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::container;
+ using namespace ::com::sun::star::beans;
+ using namespace ::com::sun::star::form;
+ using namespace ::com::sun::star::sdbc;
+ using namespace ::com::sun::star::lang;
+
+ //========================================================================
+ // OSelectLabelDialog
+ //========================================================================
+ DBG_NAME(OSelectLabelDialog)
+ //------------------------------------------------------------------------
+ OSelectLabelDialog::OSelectLabelDialog( Window* pParent, Reference< XPropertySet > _xControlModel )
+ :ModalDialog(pParent, PcrRes(RID_DLG_SELECTLABELCONTROL))
+ ,m_aMainDesc(this, PcrRes(1))
+ ,m_aControlTree(this, PcrRes(1))
+ ,m_aNoAssignment(this, PcrRes(1))
+ ,m_aSeparator(this, PcrRes(1))
+ ,m_aOk(this, PcrRes(1))
+ ,m_aCancel(this, PcrRes(1))
+ ,m_aModelImages(PcrRes(RID_IL_FORMEXPLORER))
+ ,m_xControlModel(_xControlModel)
+ ,m_pInitialSelection(NULL)
+ ,m_pLastSelected(NULL)
+ ,m_bHaveAssignableControl(sal_False)
+ {
+ DBG_CTOR(OSelectLabelDialog,NULL);
+
+ // initialize the TreeListBox
+ m_aControlTree.SetSelectionMode( SINGLE_SELECTION );
+ m_aControlTree.SetDragDropMode( 0 );
+ m_aControlTree.EnableInplaceEditing( sal_False );
+ m_aControlTree.SetWindowBits(WB_BORDER | WB_HASLINES | WB_HASLINESATROOT | WB_HASBUTTONS | WB_HASBUTTONSATROOT | WB_HSCROLL);
+
+ m_aControlTree.SetNodeBitmaps( m_aModelImages.GetImage( RID_SVXIMG_COLLAPSEDNODE ), m_aModelImages.GetImage( RID_SVXIMG_EXPANDEDNODE ) );
+ m_aControlTree.SetSelectHdl(LINK(this, OSelectLabelDialog, OnEntrySelected));
+ m_aControlTree.SetDeselectHdl(LINK(this, OSelectLabelDialog, OnEntrySelected));
+
+ // fill the description
+ UniString sDescription = m_aMainDesc.GetText();
+ sal_Int16 nClassID = FormComponentType::CONTROL;
+ if (::comphelper::hasProperty(PROPERTY_CLASSID, m_xControlModel))
+ nClassID = ::comphelper::getINT16(m_xControlModel->getPropertyValue(PROPERTY_CLASSID));
+
+ sDescription.SearchAndReplace(String::CreateFromAscii("$control_class$"), GetUIHeadlineName(nClassID, makeAny(m_xControlModel)));
+ UniString sName = ::comphelper::getString(m_xControlModel->getPropertyValue(PROPERTY_NAME)).getStr();
+ sDescription.SearchAndReplace(String::CreateFromAscii("$control_name$"), sName);
+ m_aMainDesc.SetText(sDescription);
+
+ // search for the root of the form hierarchy
+ Reference< XChild > xCont(m_xControlModel, UNO_QUERY);
+ Reference< XInterface > xSearch( xCont.is() ? xCont->getParent() : Reference< XInterface > ());
+ Reference< XResultSet > xParentAsResultSet(xSearch, UNO_QUERY);
+ while (xParentAsResultSet.is())
+ {
+ xCont = Reference< XChild > (xSearch, UNO_QUERY);
+ xSearch = xCont.is() ? xCont->getParent() : Reference< XInterface > ();
+ xParentAsResultSet = Reference< XResultSet > (xSearch, UNO_QUERY);
+ }
+
+ // and insert all entries below this root into the listbox
+ if (xSearch.is())
+ {
+ // check wich service the allowed components must suppport
+ sal_Int16 nClassId = 0;
+ try { nClassId = ::comphelper::getINT16(m_xControlModel->getPropertyValue(PROPERTY_CLASSID)); } catch(...) { }
+ m_sRequiredService = (FormComponentType::RADIOBUTTON == nClassId) ? SERVICE_COMPONENT_GROUPBOX : SERVICE_COMPONENT_FIXEDTEXT;
+ m_aRequiredControlImage = m_aModelImages.GetImage((FormComponentType::RADIOBUTTON == nClassId) ? RID_SVXIMG_GROUPBOX : RID_SVXIMG_FIXEDTEXT);
+
+ // calc the currently set label control (so InsertEntries can calc m_pInitialSelection)
+ Any aCurrentLabelControl( m_xControlModel->getPropertyValue(PROPERTY_CONTROLLABEL) );
+ DBG_ASSERT((aCurrentLabelControl.getValueTypeClass() == TypeClass_INTERFACE) || !aCurrentLabelControl.hasValue(),
+
+ "OSelectLabelDialog::OSelectLabelDialog : invalid ControlLabel property !");
+ if (aCurrentLabelControl.hasValue())
+ aCurrentLabelControl >>= m_xInitialLabelControl;
+
+ // insert the root
+ Image aRootImage = m_aModelImages.GetImage(RID_SVXIMG_FORMS);
+ SvLBoxEntry* pRoot = m_aControlTree.InsertEntry(PcrRes(RID_STR_FORMS), aRootImage, aRootImage);
+
+ // build the tree
+ m_pInitialSelection = NULL;
+ m_bHaveAssignableControl = sal_False;
+ InsertEntries(xSearch, pRoot);
+ m_aControlTree.Expand(pRoot);
+ }
+
+ if (m_pInitialSelection)
+ {
+ m_aControlTree.MakeVisible(m_pInitialSelection, sal_True);
+ m_aControlTree.Select(m_pInitialSelection, sal_True);
+ }
+ else
+ {
+ m_aControlTree.MakeVisible(m_aControlTree.First(), sal_True);
+ if (m_aControlTree.FirstSelected())
+ m_aControlTree.Select(m_aControlTree.FirstSelected(), sal_False);
+ m_aNoAssignment.Check(sal_True);
+ }
+
+ if (!m_bHaveAssignableControl)
+ { // no controls which can be assigned
+ m_aNoAssignment.Check(sal_True);
+ m_aNoAssignment.Enable(sal_False);
+ }
+
+ m_aNoAssignment.SetClickHdl(LINK(this, OSelectLabelDialog, OnNoAssignmentClicked));
+ m_aNoAssignment.GetClickHdl().Call(&m_aNoAssignment);
+
+ FreeResource();
+ }
+
+ //------------------------------------------------------------------------
+ OSelectLabelDialog::~OSelectLabelDialog()
+ {
+ // delete the entry datas of the listbox entries
+ SvLBoxEntry* pLoop = m_aControlTree.First();
+ while (pLoop)
+ {
+ void* pData = pLoop->GetUserData();
+ if (pData)
+ delete (Reference< XPropertySet > *)pData;
+ pLoop = m_aControlTree.Next(pLoop);
+ }
+
+ DBG_DTOR(OSelectLabelDialog,NULL);
+ }
+
+ //------------------------------------------------------------------------
+ sal_Int32 OSelectLabelDialog::InsertEntries(const Reference< XInterface > & _xContainer, SvLBoxEntry* pContainerEntry)
+ {
+ Reference< XIndexAccess > xContainer(_xContainer, UNO_QUERY);
+ if (!xContainer.is())
+ return 0;
+
+ sal_Int32 nChildren = 0;
+ UniString sName,sDisplayName;
+ Reference< XPropertySet > xAsSet;
+ for (sal_Int32 i=0; i<xContainer->getCount(); ++i)
+ {
+ xContainer->getByIndex(i) >>= xAsSet;
+ if (!xAsSet.is())
+ {
+ DBG_WARNING("OSelectLabelDialog::InsertEntries : strange : a form component which isn't a property set !");
+ continue;
+ }
+
+ if (!::comphelper::hasProperty(PROPERTY_NAME, xAsSet))
+ // we need at least a name for displaying ...
+ continue;
+ sName = ::comphelper::getString(xAsSet->getPropertyValue(PROPERTY_NAME)).getStr();
+
+ // we need to check if the control model supports the required service
+ Reference< XServiceInfo > xInfo(xAsSet, UNO_QUERY);
+ if (!xInfo.is())
+ continue;
+
+ if (!xInfo->supportsService(m_sRequiredService))
+ { // perhaps it is a container
+ Reference< XIndexAccess > xCont(xAsSet, UNO_QUERY);
+ if (xCont.is() && xCont->getCount())
+ { // yes -> step down
+ Image aFormImage = m_aModelImages.GetImage( RID_SVXIMG_FORM );
+ SvLBoxEntry* pCont = m_aControlTree.InsertEntry(sName, aFormImage, aFormImage, pContainerEntry);
+ sal_Int32 nContChildren = InsertEntries(xCont, pCont);
+ if (nContChildren)
+ {
+ m_aControlTree.Expand(pCont);
+ ++nChildren;
+ }
+ else
+ { // oops, no valid childs -> remove the entry
+ m_aControlTree.ModelIsRemoving(pCont);
+ m_aControlTree.GetModel()->Remove(pCont);
+ m_aControlTree.ModelHasRemoved(pCont);
+ }
+ }
+ continue;
+ }
+
+ // get the label
+ if (!::comphelper::hasProperty(PROPERTY_LABEL, xAsSet))
+ continue;
+ sDisplayName = ::comphelper::getString(xAsSet->getPropertyValue(PROPERTY_LABEL)).getStr();
+ sDisplayName += String::CreateFromAscii(" (");
+ sDisplayName += sName;
+ sDisplayName += ')';
+
+ // all requirements met -> insert
+ SvLBoxEntry* pCurrent = m_aControlTree.InsertEntry(sDisplayName, m_aRequiredControlImage, m_aRequiredControlImage, pContainerEntry);
+ pCurrent->SetUserData(new Reference< XPropertySet > (xAsSet));
+ ++nChildren;
+
+ if (m_xInitialLabelControl == xAsSet)
+ m_pInitialSelection = pCurrent;
+
+ m_bHaveAssignableControl = sal_True;
+ }
+
+ return nChildren;
+ }
+
+ //------------------------------------------------------------------------
+ IMPL_LINK(OSelectLabelDialog, OnEntrySelected, SvTreeListBox*, pLB)
+ {
+ DBG_ASSERT(pLB == &m_aControlTree, "OSelectLabelDialog::OnEntrySelected : where did this come from ?");
+ (void)pLB;
+ SvLBoxEntry* pSelected = m_aControlTree.FirstSelected();
+ void* pData = pSelected ? pSelected->GetUserData() : NULL;
+
+ if (pData)
+ m_xSelectedControl = Reference< XPropertySet > (*(Reference< XPropertySet > *)pData);
+
+ m_aNoAssignment.SetClickHdl(Link());
+ m_aNoAssignment.Check(pData == NULL);
+ m_aNoAssignment.SetClickHdl(LINK(this, OSelectLabelDialog, OnNoAssignmentClicked));
+
+ return 0L;
+ }
+
+ //------------------------------------------------------------------------
+ IMPL_LINK(OSelectLabelDialog, OnNoAssignmentClicked, Button*, pButton)
+ {
+ DBG_ASSERT(pButton == &m_aNoAssignment, "OSelectLabelDialog::OnNoAssignmentClicked : where did this come from ?");
+ (void)pButton;
+
+ if (m_aNoAssignment.IsChecked())
+ m_pLastSelected = m_aControlTree.FirstSelected();
+ else
+ {
+ DBG_ASSERT(m_bHaveAssignableControl, "OSelectLabelDialog::OnNoAssignmentClicked");
+ // search the first assignable entry
+ SvLBoxEntry* pSearch = m_aControlTree.First();
+ while (pSearch)
+ {
+ if (pSearch->GetUserData())
+ break;
+ pSearch = m_aControlTree.Next(pSearch);
+ }
+ // and select it
+ if (pSearch)
+ {
+ m_aControlTree.Select(pSearch);
+ m_pLastSelected = pSearch;
+ }
+ }
+
+ if (m_pLastSelected)
+ {
+ m_aControlTree.SetSelectHdl(Link());
+ m_aControlTree.SetDeselectHdl(Link());
+ m_aControlTree.Select(m_pLastSelected, !m_aNoAssignment.IsChecked());
+ m_aControlTree.SetSelectHdl(LINK(this, OSelectLabelDialog, OnEntrySelected));
+ m_aControlTree.SetDeselectHdl(LINK(this, OSelectLabelDialog, OnEntrySelected));
+ }
+
+ return 0L;
+ }
+
+//............................................................................
+} // namespace pcr
+//............................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/propctrlr/selectlabeldialog.hxx b/extensions/source/propctrlr/selectlabeldialog.hxx
new file mode 100644
index 000000000000..bb713b875862
--- /dev/null
+++ b/extensions/source/propctrlr/selectlabeldialog.hxx
@@ -0,0 +1,89 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _EXTENSIONS_PROPCTRLR_SELECTLABELDIALOG_HXX_
+#define _EXTENSIONS_PROPCTRLR_SELECTLABELDIALOG_HXX_
+
+#include <vcl/fixed.hxx>
+#include <svtools/svtreebx.hxx>
+#include <vcl/button.hxx>
+#include <vcl/image.hxx>
+#include <vcl/dialog.hxx>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include "modulepcr.hxx"
+
+//............................................................................
+namespace pcr
+{
+//............................................................................
+
+ //========================================================================
+ // OSelectLabelDialog
+ //========================================================================
+ class OSelectLabelDialog
+ :public ModalDialog
+ ,public PcrClient
+ {
+ FixedText m_aMainDesc;
+ SvTreeListBox m_aControlTree;
+ CheckBox m_aNoAssignment;
+ FixedLine m_aSeparator;
+ OKButton m_aOk;
+ CancelButton m_aCancel;
+
+ ImageList m_aModelImages;
+ ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > m_xControlModel;
+ ::rtl::OUString m_sRequiredService;
+ Image m_aRequiredControlImage;
+ SvLBoxEntry* m_pInitialSelection;
+ ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > m_xInitialLabelControl;
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > m_xSelectedControl;
+ SvLBoxEntry* m_pLastSelected;
+ sal_Bool m_bHaveAssignableControl;
+
+ public:
+ OSelectLabelDialog(Window* pParent, ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > _xControlModel);
+ ~OSelectLabelDialog();
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > GetSelected() const { return m_aNoAssignment.IsChecked() ? ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > () : m_xSelectedControl; }
+
+ protected:
+ sal_Int32 InsertEntries(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _xContainer, SvLBoxEntry* pContainerEntry);
+
+ DECL_LINK(OnEntrySelected, SvTreeListBox*);
+ DECL_LINK(OnNoAssignmentClicked, Button*);
+ };
+
+//............................................................................
+} // namespace pcr
+//............................................................................
+
+#endif // _EXTENSIONS_PROPCTRLR_SELECTLABELDIALOG_HXX_
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/propctrlr/selectlabeldialog.src b/extensions/source/propctrlr/selectlabeldialog.src
new file mode 100644
index 000000000000..93cf7d24ece8
--- /dev/null
+++ b/extensions/source/propctrlr/selectlabeldialog.src
@@ -0,0 +1,83 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef EXTENSIONS_PROPRESID_HRC
+#include "formresid.hrc"
+#endif
+
+ModalDialog RID_DLG_SELECTLABELCONTROL
+{
+ OutputSize = TRUE;
+ Size = MAP_APPFONT( 200, 151 );
+ Moveable = TRUE;
+ Closeable = TRUE;
+ FixedText 1
+ {
+ Pos = MAP_APPFONT( 6, 6 );
+ Size = MAP_APPFONT( 188, 20 );
+ WordBreak = TRUE;
+ Text [ en-US ] = "These are control fields that can be used as label fields for the $control_class$ $control_name$.";
+ };
+ Control 1
+ {
+ Pos = MAP_APPFONT( 6, 29 );
+ Size = MAP_APPFONT( 188, 83 );
+ TabStop = TRUE;
+ Border = TRUE ;
+ };
+ CheckBox 1
+ {
+ Pos = MAP_APPFONT( 6, 115 );
+ Size = MAP_APPFONT( 188, 8 );
+ Text [ en-US ] = "~No assignment";
+ };
+ FixedLine 1
+ {
+ Pos = MAP_APPFONT( 3, 126 );
+ Size = MAP_APPFONT( 194, 2 );
+ };
+ OKButton 1
+ {
+ Pos = MAP_APPFONT ( 91 , 131 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ DefButton = TRUE ;
+ };
+ CancelButton 1
+ {
+ Pos = MAP_APPFONT ( 144 , 131 ) ;
+ Size = MAP_APPFONT ( 50 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ Text [ en-US ] = "Label Field Selection";
+};
+
+String RID_STR_FORMS
+{
+ Text [ en-US ] = "Forms" ;
+};
+
diff --git a/extensions/source/propctrlr/sqlcommanddesign.cxx b/extensions/source/propctrlr/sqlcommanddesign.cxx
new file mode 100644
index 000000000000..d7abbc8b6c7e
--- /dev/null
+++ b/extensions/source/propctrlr/sqlcommanddesign.cxx
@@ -0,0 +1,391 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+#include "sqlcommanddesign.hxx"
+#include "formstrings.hxx"
+#include "formresid.hrc"
+#include "modulepcr.hxx"
+#include "unourl.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/awt/XWindow.hpp>
+#include <com/sun/star/awt/XTopWindow.hpp>
+#include <com/sun/star/uno/Sequence.hxx>
+#include <com/sun/star/frame/XTitle.hpp>
+#include <com/sun/star/frame/XComponentLoader.hpp>
+#include <com/sun/star/frame/XController.hpp>
+#include <com/sun/star/lang/NullPointerException.hpp>
+#include <com/sun/star/lang/DisposedException.hpp>
+#include <com/sun/star/frame/FrameSearchFlag.hpp>
+#include <com/sun/star/frame/XFramesSupplier.hpp>
+#include <com/sun/star/sdbc/XConnection.hpp>
+#include <com/sun/star/util/XCloseable.hpp>
+#include <com/sun/star/frame/XDispatchProvider.hpp>
+#include <com/sun/star/beans/XPropertySetInfo.hpp>
+#include <com/sun/star/sdb/CommandType.hpp>
+/** === end UNO includes === **/
+
+#include <svtools/localresaccess.hxx>
+#include <tools/diagnose_ex.h>
+#include <osl/diagnose.h>
+
+//........................................................................
+namespace pcr
+{
+//........................................................................
+
+ /** === begin UNO using === **/
+ using ::com::sun::star::uno::Reference;
+ using ::com::sun::star::lang::XMultiComponentFactory;
+ using ::com::sun::star::beans::PropertyChangeEvent;
+ using ::com::sun::star::uno::RuntimeException;
+ using ::com::sun::star::frame::XFrame;
+ using ::com::sun::star::awt::XTopWindow;
+ using ::com::sun::star::awt::XWindow;
+ using ::com::sun::star::uno::Exception;
+ using ::com::sun::star::uno::UNO_QUERY_THROW;
+ using ::com::sun::star::uno::UNO_QUERY;
+ using ::com::sun::star::beans::PropertyValue;
+ using ::com::sun::star::uno::Sequence;
+ using ::com::sun::star::lang::XComponent;
+ using ::com::sun::star::frame::XComponentLoader;
+ using ::com::sun::star::beans::XPropertySet;
+ using ::com::sun::star::beans::XPropertySetInfo;
+ using ::com::sun::star::frame::XController;
+ using ::com::sun::star::frame::XTitle;
+ using ::com::sun::star::lang::EventObject;
+ using ::com::sun::star::lang::NullPointerException;
+ using ::com::sun::star::lang::DisposedException;
+ using ::com::sun::star::uno::makeAny;
+ using ::com::sun::star::uno::XComponentContext;
+ using ::com::sun::star::frame::XFramesSupplier;
+ using ::com::sun::star::frame::XFrames;
+ using ::com::sun::star::util::XCloseable;
+ using ::com::sun::star::uno::TypeClass_STRING;
+ using ::com::sun::star::lang::XMultiServiceFactory;
+ using ::com::sun::star::frame::XDispatchProvider;
+ using ::com::sun::star::frame::XDispatch;
+ using ::com::sun::star::uno::Any;
+ /** === end UNO using === **/
+ namespace FrameSearchFlag = ::com::sun::star::frame::FrameSearchFlag;
+ namespace CommandType = ::com::sun::star::sdb::CommandType;
+
+ //====================================================================
+ //= ISQLCommandAdapter
+ //====================================================================
+ //--------------------------------------------------------------------
+ ISQLCommandAdapter::~ISQLCommandAdapter()
+ {
+ }
+
+ //====================================================================
+ //= SQLCommandDesigner
+ //====================================================================
+ //--------------------------------------------------------------------
+ SQLCommandDesigner::SQLCommandDesigner( const Reference< XComponentContext >& _rxContext,
+ const ::rtl::Reference< ISQLCommandAdapter >& _rxPropertyAdapter,
+ const ::dbtools::SharedConnection& _rConnection, const Link& _rCloseLink )
+ :m_xContext( _rxContext )
+ ,m_xConnection( _rConnection )
+ ,m_xObjectAdapter( _rxPropertyAdapter )
+ ,m_aCloseLink( _rCloseLink )
+ {
+ if ( m_xContext.is() )
+ m_xORB = m_xContext->getServiceManager();
+ if ( !m_xORB.is() || !_rxPropertyAdapter.is() || !m_xConnection.is() )
+ throw NullPointerException();
+
+ impl_doOpenDesignerFrame_nothrow();
+ }
+
+ //--------------------------------------------------------------------
+ SQLCommandDesigner::~SQLCommandDesigner()
+ {
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL SQLCommandDesigner::propertyChange( const PropertyChangeEvent& Event ) throw (RuntimeException)
+ {
+ OSL_ENSURE( m_xDesigner.is() && ( Event.Source == m_xDesigner ), "SQLCommandDesigner::propertyChange: where did this come from?" );
+
+ if ( m_xDesigner.is() && ( Event.Source == m_xDesigner ) )
+ {
+ try
+ {
+ if ( PROPERTY_ACTIVECOMMAND == Event.PropertyName )
+ {
+ ::rtl::OUString sCommand;
+ OSL_VERIFY( Event.NewValue >>= sCommand );
+ m_xObjectAdapter->setSQLCommand( sCommand );
+ }
+ else if ( PROPERTY_ESCAPE_PROCESSING == Event.PropertyName )
+ {
+ sal_Bool bEscapeProcessing( sal_False );
+ OSL_VERIFY( Event.NewValue >>= bEscapeProcessing );
+ m_xObjectAdapter->setEscapeProcessing( bEscapeProcessing );
+ }
+ }
+ catch( const RuntimeException& ) { throw; }
+ catch( const Exception& )
+ {
+ // not allowed to leave, so silence it
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL SQLCommandDesigner::disposing( const EventObject& Source ) throw (RuntimeException)
+ {
+ if ( m_xDesigner.is() && ( Source.Source == m_xDesigner ) )
+ {
+ impl_designerClosed_nothrow();
+ m_xDesigner.clear();
+ }
+ }
+
+ //--------------------------------------------------------------------
+ void SQLCommandDesigner::dispose()
+ {
+ if ( impl_isDisposed() )
+ return;
+
+ if ( isActive() )
+ impl_closeDesigner_nothrow();
+
+ m_xConnection.clear();
+ m_xContext.clear();
+ m_xORB.clear();
+ }
+
+ //--------------------------------------------------------------------
+ void SQLCommandDesigner::impl_checkDisposed_throw() const
+ {
+ if ( impl_isDisposed() )
+ throw DisposedException();
+ }
+
+ //--------------------------------------------------------------------
+ void SQLCommandDesigner::raise() const
+ {
+ impl_checkDisposed_throw();
+ impl_raise_nothrow();
+ }
+
+ //------------------------------------------------------------------------
+ bool SQLCommandDesigner::suspend() const
+ {
+ impl_checkDisposed_throw();
+ return impl_trySuspendDesigner_nothrow();
+ }
+
+ //--------------------------------------------------------------------
+ void SQLCommandDesigner::impl_raise_nothrow() const
+ {
+ OSL_PRECOND( isActive(), "SQLCommandDesigner::impl_raise_nothrow: not active!" );
+ if ( !isActive() )
+ return;
+
+ try
+ {
+ // activate the frame for this component
+ Reference< XFrame > xFrame( m_xDesigner->getFrame(), UNO_QUERY_THROW );
+ Reference< XWindow > xWindow( xFrame->getContainerWindow(), UNO_QUERY_THROW );
+ Reference< XTopWindow > xTopWindow( xWindow, UNO_QUERY_THROW );
+
+ xTopWindow->toFront();
+ xWindow->setFocus();
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+
+ //--------------------------------------------------------------------
+ void SQLCommandDesigner::impl_doOpenDesignerFrame_nothrow()
+ {
+ OSL_PRECOND( !isActive(),
+ "SQLCommandDesigner::impl_doOpenDesignerFrame_nothrow: already active!" );
+ OSL_PRECOND( m_xConnection.is(), "SQLCommandDesigner::impl_doOpenDesignerFrame_nothrow: this will crash!" );
+ osl_incrementInterlockedCount(&m_refCount);
+
+ try
+ {
+ // for various reasons, we don't want the new frame to appear in the desktop's frame list
+ // thus, we create a blank frame at the desktop, remove it from the desktop's frame list
+ // immediately, and then load the component into this blank (and now parent-less) frame
+ Reference< XComponentLoader > xLoader( impl_createEmptyParentlessTask_nothrow(), UNO_QUERY_THROW );
+ Sequence< PropertyValue > aArgs( 5 );
+ aArgs[0].Name = PROPERTY_ACTIVE_CONNECTION;
+ aArgs[0].Value <<= m_xConnection.getTyped();
+
+ aArgs[1].Name = PROPERTY_COMMAND;
+ aArgs[1].Value <<= m_xObjectAdapter->getSQLCommand();
+ aArgs[2].Name = PROPERTY_COMMANDTYPE;
+ aArgs[2].Value <<= (sal_Int32)CommandType::COMMAND;
+ aArgs[3].Name = PROPERTY_ESCAPE_PROCESSING;
+ aArgs[3].Value <<= m_xObjectAdapter->getEscapeProcessing();
+
+ aArgs[4].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "GraphicalDesign" ) );
+ aArgs[4].Value <<= m_xObjectAdapter->getEscapeProcessing();
+
+ Reference< XComponent > xQueryDesign = xLoader->loadComponentFromURL(
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".component:DB/QueryDesign" ) ),
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "_self" ) ),
+ FrameSearchFlag::TASKS | FrameSearchFlag::CREATE,
+ aArgs
+ );
+
+ // remember this newly loaded component - we need to care for it e.g. when we're suspended
+ m_xDesigner = m_xDesigner.query( xQueryDesign );
+ OSL_ENSURE( m_xDesigner.is() || !xQueryDesign.is(), "SQLCommandDesigner::impl_doOpenDesignerFrame_nothrow: the component is expected to be a controller!" );
+ if ( m_xDesigner.is() )
+ {
+ Reference< XPropertySet > xQueryDesignProps( m_xDesigner, UNO_QUERY );
+ OSL_ENSURE( xQueryDesignProps.is(), "SQLCommandDesigner::impl_doOpenDesignerFrame_nothrow: the controller should have properties!" );
+ if ( xQueryDesignProps.is() )
+ {
+ xQueryDesignProps->addPropertyChangeListener( PROPERTY_ACTIVECOMMAND, this );
+ xQueryDesignProps->addPropertyChangeListener( PROPERTY_ESCAPE_PROCESSING, this );
+ }
+ }
+
+ // get the frame which we just opened and set it's title
+ Reference< XTitle> xTitle(xQueryDesign,UNO_QUERY);
+ if ( xTitle.is() )
+ {
+ ::svt::OLocalResourceAccess aEnumStrings( PcrRes( RID_RSC_ENUM_COMMAND_TYPE ), RSC_RESOURCE );
+ ::rtl::OUString sDisplayName = String( PcrRes( CommandType::COMMAND + 1 ) );
+ xTitle->setTitle( sDisplayName );
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ m_xDesigner.clear();
+ }
+ osl_decrementInterlockedCount(&m_refCount);
+ }
+
+ //------------------------------------------------------------------------
+ Reference< XFrame > SQLCommandDesigner::impl_createEmptyParentlessTask_nothrow( ) const
+ {
+ OSL_PRECOND( m_xORB.is(), "SQLCommandDesigner::impl_createEmptyParentlessTask_nothrow: this will crash!" );
+
+ Reference< XFrame > xFrame;
+ try
+ {
+ Reference< XInterface > xDesktop ( m_xORB->createInstanceWithContext( SERVICE_DESKTOP, m_xContext ) );
+ Reference< XFrame > xDesktopFrame ( xDesktop, UNO_QUERY_THROW );
+ Reference< XFramesSupplier > xSuppDesktopFrames( xDesktopFrame, UNO_QUERY_THROW );
+
+ Reference< XFrames > xDesktopFramesCollection( xSuppDesktopFrames->getFrames(), UNO_QUERY_THROW );
+ xFrame = xDesktopFrame->findFrame( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "_blank" ) ), FrameSearchFlag::CREATE );
+ OSL_ENSURE( xFrame.is(), "SQLCommandDesigner::impl_createEmptyParentlessTask_nothrow: could not create an empty frame!" );
+ xDesktopFramesCollection->remove( xFrame );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ return xFrame;
+ }
+
+ //------------------------------------------------------------------------
+ void SQLCommandDesigner::impl_designerClosed_nothrow()
+ {
+ if ( m_aCloseLink.IsSet() )
+ m_aCloseLink.Call( this );
+ }
+
+ //------------------------------------------------------------------------
+ void SQLCommandDesigner::impl_closeDesigner_nothrow()
+ {
+ OSL_PRECOND( isActive(), "SQLCommandDesigner::impl_closeDesigner_nothrow: invalid calle!" );
+ // close it
+ try
+ {
+ // do not listen anymore ....
+ Reference< XPropertySet > xProps( m_xDesigner, UNO_QUERY );
+ if ( xProps.is() )
+ xProps->removePropertyChangeListener( PROPERTY_ACTIVECOMMAND, this );
+
+ // we need to close the frame via the "user interface", by dispatching a close command,
+ // instead of calling XCloseable::close directly. The latter method would also close
+ // the frame, but not care for things like shutting down the office when the last
+ // frame is gone ...
+ const UnoURL aCloseURL( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:CloseDoc" ) ),
+ Reference< XMultiServiceFactory >( m_xORB, UNO_QUERY ) );
+
+ Reference< XDispatchProvider > xProvider( m_xDesigner->getFrame(), UNO_QUERY_THROW );
+ Reference< XDispatch > xDispatch( xProvider->queryDispatch( aCloseURL, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "_top" ) ), FrameSearchFlag::SELF ) );
+ OSL_ENSURE( xDispatch.is(), "SQLCommandDesigner::impl_closeDesigner_nothrow: no dispatcher for the CloseDoc command!" );
+ if ( xDispatch.is() )
+ {
+ xDispatch->dispatch( aCloseURL, Sequence< PropertyValue >( ) );
+ }
+ else
+ {
+ // fallback: use the XCloseable::close (with all possible disadvantages)
+ Reference< XCloseable > xClose( m_xDesigner->getFrame(), UNO_QUERY );
+ if ( xClose.is() )
+ xClose->close( sal_True );
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+ m_xDesigner.clear();
+ }
+
+ //------------------------------------------------------------------------
+ bool SQLCommandDesigner::impl_trySuspendDesigner_nothrow() const
+ {
+ OSL_PRECOND( isActive(), "SQLCommandDesigner::impl_trySuspendDesigner_nothrow: no active designer, this will crash!" );
+ sal_Bool bAllow = sal_True;
+ try
+ {
+ bAllow = m_xDesigner->suspend( sal_True );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ return bAllow;
+ }
+
+//........................................................................
+} // namespace pcr
+//........................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/propctrlr/sqlcommanddesign.hxx b/extensions/source/propctrlr/sqlcommanddesign.hxx
new file mode 100644
index 000000000000..f439f67840b8
--- /dev/null
+++ b/extensions/source/propctrlr/sqlcommanddesign.hxx
@@ -0,0 +1,225 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef EXTENSIONS_SOURCE_PROPCTRLR_SQLCOMMANDDESIGN_HXX
+#define EXTENSIONS_SOURCE_PROPCTRLR_SQLCOMMANDDESIGN_HXX
+
+/** === begin UNO includes === **/
+#include <com/sun/star/lang/XMultiComponentFactory.hpp>
+#include <com/sun/star/beans/XPropertyChangeListener.hpp>
+#include <com/sun/star/frame/XController.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/uno/XComponentContext.hpp>
+#include <com/sun/star/inspection/XObjectInspectorUI.hpp>
+/** === end UNO includes === **/
+
+#include <connectivity/dbtools.hxx>
+#include <tools/link.hxx>
+#include <cppuhelper/implbase1.hxx>
+#include <rtl/ref.hxx>
+
+//........................................................................
+namespace pcr
+{
+//........................................................................
+
+ class ISQLCommandAdapter;
+ //====================================================================
+ //= SQLCommandDesigner
+ //====================================================================
+ typedef ::cppu::WeakImplHelper1 < ::com::sun::star::beans::XPropertyChangeListener
+ > SQLCommandDesigner_Base;
+ /** encapsulates the code for calling and managing a query design frame, used
+ for interactively designing the Command property of a ->RowSet
+ */
+ class SQLCommandDesigner : public SQLCommandDesigner_Base
+ {
+ private:
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > m_xContext;
+ ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiComponentFactory > m_xORB;
+ ::dbtools::SharedConnection m_xConnection;
+ ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController > m_xDesigner;
+ ::rtl::Reference< ISQLCommandAdapter > m_xObjectAdapter;
+ Link m_aCloseLink;
+
+ public:
+ /** creates the instance, and immediately opens the SQL command design frame
+
+ @param _rxContext
+ our component context. Must not be <NULL/>, and must provide a non-<NULL/> XMultiComponentFactory
+ @param _rxPropertyAdapter
+ an adapter to the object's SQL command related properties
+ @param _rConnection
+ the current connection of ->_rxRowSet. Must not be <NULL/>.
+ @param _rCloseLink
+ link to call when the component has been closed
+ @throws ::com::sun::star::lang::NullPointerException
+ if any of the arguments (except ->_rCloseLink) is <NULL/>, or if the component context
+ does not provide a valid component factory.
+ */
+ SQLCommandDesigner(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _rxContext,
+ const ::rtl::Reference< ISQLCommandAdapter >& _rxPropertyAdapter,
+ const ::dbtools::SharedConnection& _rConnection,
+ const Link& _rCloseLink
+ );
+
+ /** determines whether the SQL Command designer is currently active, i.e.
+ if there currently exists a frame which allows the user entering the SQL command
+ */
+ inline bool isActive() const { return m_xDesigner.is(); }
+
+ /** returns the property adapter used by the instance
+ */
+ inline const ::rtl::Reference< ISQLCommandAdapter >& getPropertyAdapter() const { return m_xObjectAdapter; }
+
+ /** raises the designer window to top
+ @precond
+ the designer is active (->isActive)
+ @precond
+ the instance is not disposed
+ */
+ void raise() const;
+
+ /** suspends the designer
+ @precond
+ the designer is active (->isActive)
+ @precond
+ the instance is not disposed
+ */
+ bool suspend() const;
+
+ /** disposes the instance so that it becomes non-functional
+ */
+ void dispose();
+
+ protected:
+ // XPropertyChangeListener
+ virtual void SAL_CALL propertyChange( const ::com::sun::star::beans::PropertyChangeEvent& evt ) throw (::com::sun::star::uno::RuntimeException);
+
+ // XEventListener
+ virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw (::com::sun::star::uno::RuntimeException);
+
+ protected:
+ ~SQLCommandDesigner();
+
+ /** opens a new frame for interactively designing an SQL command
+ @precond
+ the designer is not currently active (see ->isActive)
+ @precond
+ ->m_xConnection is not <NULL/>
+ */
+ void impl_doOpenDesignerFrame_nothrow();
+
+ /** impl-version of ->raise
+ */
+ void impl_raise_nothrow() const;
+
+ /** determines whether we are already disposed
+ */
+ bool impl_isDisposed() const
+ {
+ return !m_xContext.is();
+ }
+ /** checks whether we are already disposed
+ @throws ::com::sun::star::lang::DisposedException
+ if we in fact are disposed
+ */
+ void impl_checkDisposed_throw() const;
+
+ /** create an empty top-level frame, which does not belong to the desktop's frame list
+ @precond
+ ->m_xORB is not <NULL/>
+ */
+ ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >
+ impl_createEmptyParentlessTask_nothrow() const;
+
+ /** called whenever the component denoted by m_xDesigner has been closed
+ <em>by an external instance</em>
+ */
+ void impl_designerClosed_nothrow();
+
+ /** closes the component denoted by m_xDesigner
+ @precond
+ our designer component is actually active (->isActive)
+ @precond
+ we're not disposed already
+ */
+ void impl_closeDesigner_nothrow();
+
+ /** suspends our designer component
+ @precond
+ the designer component is actually active (->isActive)
+ @return
+ <TRUE/> if the suspension was successful, <FALSE/> if it was vetoed
+ */
+ bool impl_trySuspendDesigner_nothrow() const;
+
+ /** gets the current value of the command property
+ */
+ ::rtl::OUString
+ impl_getCommandPropertyValue_nothrow();
+
+ /** sets anew value for the command property
+ */
+ void impl_setCommandPropertyValue_nothrow( const ::rtl::OUString& _rCommand ) const;
+
+ private:
+ SQLCommandDesigner(); // never implemented
+ SQLCommandDesigner( const SQLCommandDesigner& ); // never implemented
+ SQLCommandDesigner& operator=( const SQLCommandDesigner& ); // never implemented
+ };
+
+ //====================================================================
+ //= ISQLCommandAdapter
+ //====================================================================
+ /** an adapter to forward changed SQL command property values to a component
+ */
+ class ISQLCommandAdapter : public ::rtl::IReference
+ {
+ public:
+ /// retrieves the current SQL command of the component
+ virtual ::rtl::OUString getSQLCommand() const = 0;
+ /// retrieves the current value of the EscapeProcessing property of the component
+ virtual sal_Bool getEscapeProcessing() const = 0;
+
+ /// sets a new SQL command
+ virtual void setSQLCommand( const ::rtl::OUString& _rCommand ) const = 0;
+ /// sets a new EscapeProcessing property value
+ virtual void setEscapeProcessing( const sal_Bool _bEscapeProcessing ) const = 0;
+
+ virtual ~ISQLCommandAdapter();
+ };
+
+//........................................................................
+} // namespace pcr
+//........................................................................
+
+#endif // EXTENSIONS_SOURCE_PROPCTRLR_SQLCOMMANDDESIGN_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/propctrlr/standardcontrol.cxx b/extensions/source/propctrlr/standardcontrol.cxx
new file mode 100644
index 000000000000..6d3f3c9a1475
--- /dev/null
+++ b/extensions/source/propctrlr/standardcontrol.cxx
@@ -0,0 +1,1440 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+#include "standardcontrol.hxx"
+#include "pcrcommon.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/util/DateTime.hpp>
+#include <com/sun/star/util/Date.hpp>
+#include <com/sun/star/util/Time.hpp>
+#include <com/sun/star/util/Color.hpp>
+#include <com/sun/star/util/MeasureUnit.hpp>
+#include <com/sun/star/inspection/PropertyControlType.hpp>
+/** === end UNO includes === **/
+#include <rtl/math.hxx>
+#include <sfx2/objsh.hxx>
+
+//==================================================================
+// ugly dependencies for the OColorControl
+#include <svx/svxids.hrc>
+#include <svx/drawitem.hxx>
+#include <xtable.hxx>
+//==================================================================
+#include <vcl/floatwin.hxx>
+#include <svtools/svmedit.hxx>
+#include <svtools/colorcfg.hxx>
+#include <unotools/syslocale.hxx>
+#include <unotools/datetime.hxx>
+#include <i18npool/mslangid.hxx>
+#include <vcl/button.hxx>
+#include <vcl/svapp.hxx>
+//==================================================================
+
+#include <memory>
+#include <limits>
+#include <boost/bind.hpp>
+
+//............................................................................
+namespace pcr
+{
+//............................................................................
+
+ using namespace ::com::sun::star;
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::awt;
+ using namespace ::com::sun::star::lang;
+ using namespace ::com::sun::star::util;
+ using namespace ::com::sun::star::beans;
+ using namespace ::com::sun::star::inspection;
+
+ //==================================================================
+ //= OTimeControl
+ //==================================================================
+ //------------------------------------------------------------------
+ OTimeControl::OTimeControl( Window* pParent, WinBits nWinStyle )
+ :OTimeControl_Base( PropertyControlType::TimeField, pParent, nWinStyle )
+ {
+ getTypedControlWindow()->SetStrictFormat( sal_True );
+ getTypedControlWindow()->SetFormat( TIMEF_SEC );
+ getTypedControlWindow()->EnableEmptyFieldValue( sal_True );
+ }
+
+ //------------------------------------------------------------------
+ void SAL_CALL OTimeControl::setValue( const Any& _rValue ) throw (IllegalTypeException, RuntimeException)
+ {
+ util::Time aUNOTime;
+ if ( !( _rValue >>= aUNOTime ) )
+ {
+ getTypedControlWindow()->SetText( String() );
+ getTypedControlWindow()->SetEmptyTime();
+ }
+ else
+ {
+ ::Time aTime( aUNOTime.Hours, aUNOTime.Minutes, aUNOTime.Seconds, aUNOTime.HundredthSeconds );
+ getTypedControlWindow()->SetTime( aTime );
+ }
+ }
+
+ //------------------------------------------------------------------
+ Any SAL_CALL OTimeControl::getValue() throw (RuntimeException)
+ {
+ Any aPropValue;
+ if ( getTypedControlWindow()->GetText().Len()>0 )
+ {
+ ::Time aTime( getTypedControlWindow()->GetTime() );
+ util::Time aUNOTime( aTime.Get100Sec(), aTime.GetSec(), aTime.GetMin(), aTime.GetHour() );
+ aPropValue <<= aUNOTime;
+ }
+ return aPropValue;
+ }
+
+ //------------------------------------------------------------------
+ Type SAL_CALL OTimeControl::getValueType() throw (RuntimeException)
+ {
+ return ::getCppuType( static_cast< util::Time* >( NULL ) );
+ }
+
+ //==================================================================
+ //= ODateControl
+ //==================================================================
+ //------------------------------------------------------------------
+ ODateControl::ODateControl( Window* pParent, WinBits nWinStyle )
+ :ODateControl_Base( PropertyControlType::DateField, pParent, nWinStyle | WB_DROPDOWN )
+ {
+ WindowType* pControlWindow = getTypedControlWindow();
+ pControlWindow->SetStrictFormat(sal_True);
+
+ pControlWindow->SetMin( ::Date( 1,1,1600 ) );
+ pControlWindow->SetFirst( ::Date( 1,1,1600 ) );
+ pControlWindow->SetLast( ::Date( 1, 1, 9999 ) );
+ pControlWindow->SetMax( ::Date( 1, 1, 9999 ) );
+
+ pControlWindow->SetExtDateFormat( XTDATEF_SYSTEM_SHORT_YYYY );
+ pControlWindow->EnableEmptyFieldValue( sal_True );
+ }
+
+ //------------------------------------------------------------------
+ void SAL_CALL ODateControl::setValue( const Any& _rValue ) throw (IllegalTypeException, RuntimeException)
+ {
+ util::Date aUNODate;
+ if ( !( _rValue >>= aUNODate ) )
+ {
+ getTypedControlWindow()->SetText( String() );
+ getTypedControlWindow()->SetEmptyDate();
+ }
+ else
+ {
+ ::Date aDate( aUNODate.Day, aUNODate.Month, aUNODate.Year );
+ getTypedControlWindow()->SetDate( aDate );
+ }
+ }
+
+ //------------------------------------------------------------------
+ Any SAL_CALL ODateControl::getValue() throw (RuntimeException)
+ {
+ Any aPropValue;
+ if ( getTypedControlWindow()->GetText().Len() > 0 )
+ {
+ ::Date aDate( getTypedControlWindow()->GetDate() );
+ util::Date aUNODate( aDate.GetDay(), aDate.GetMonth(), aDate.GetYear() );
+ aPropValue <<= aUNODate;
+ }
+ return aPropValue;
+ }
+
+ //------------------------------------------------------------------
+ Type SAL_CALL ODateControl::getValueType() throw (RuntimeException)
+ {
+ return ::getCppuType( static_cast< util::Date* >( NULL ) );
+ }
+
+ //==================================================================
+ //= OEditControl
+ //==================================================================
+ //------------------------------------------------------------------
+ OEditControl::OEditControl(Window* _pParent, sal_Bool _bPW, WinBits _nWinStyle)
+ :OEditControl_Base( _bPW ? PropertyControlType::CharacterField : PropertyControlType::TextField, _pParent, _nWinStyle )
+ {
+ m_bIsPassword = _bPW;
+
+ if ( m_bIsPassword )
+ getTypedControlWindow()->SetMaxTextLen( 1 );
+ }
+
+ //------------------------------------------------------------------
+ void SAL_CALL OEditControl::setValue( const Any& _rValue ) throw (IllegalTypeException, RuntimeException)
+ {
+ ::rtl::OUString sText;
+ if ( m_bIsPassword )
+ {
+ sal_Int16 nValue = 0;
+ _rValue >>= nValue;
+ if ( nValue )
+ {
+ sal_Unicode nCharacter = nValue;
+ sText = String( &nCharacter, 1 );
+ }
+ }
+ else
+ _rValue >>= sText;
+
+ getTypedControlWindow()->SetText( sText );
+ }
+
+ //------------------------------------------------------------------
+ Any SAL_CALL OEditControl::getValue() throw (RuntimeException)
+ {
+ Any aPropValue;
+
+ ::rtl::OUString sText( getTypedControlWindow()->GetText() );
+ if ( m_bIsPassword )
+ {
+ if ( sText.getLength() )
+ aPropValue <<= (sal_Int16)sText.getStr()[0];
+ }
+ else
+ aPropValue <<= sText;
+
+ return aPropValue;
+ }
+
+ //------------------------------------------------------------------
+ Type SAL_CALL OEditControl::getValueType() throw (RuntimeException)
+ {
+ return m_bIsPassword ? ::getCppuType( static_cast< sal_Int16* >( NULL ) ) : ::getCppuType( static_cast< ::rtl::OUString* >( NULL ) );
+ }
+
+ //------------------------------------------------------------------
+ void OEditControl::modified()
+ {
+ OEditControl_Base::modified();
+
+ // for pasword controls, we fire a commit for every single change
+ if ( m_bIsPassword )
+ m_aImplControl.notifyModifiedValue();
+ }
+
+ //------------------------------------------------------------------
+ static long ImplCalcLongValue( double nValue, sal_uInt16 nDigits )
+ {
+ double n = nValue;
+ for ( sal_uInt16 d = 0; d < nDigits; ++d )
+ n *= 10;
+
+ if ( n > ::std::numeric_limits< long >::max() )
+ return ::std::numeric_limits< long >::max();
+ return (long)n;
+ }
+
+ //------------------------------------------------------------------
+ static double ImplCalcDoubleValue( long nValue, sal_uInt16 nDigits )
+ {
+ double n = nValue;
+ for ( sal_uInt16 d = 0; d < nDigits; ++d )
+ n /= 10;
+ return n;
+ }
+
+ //==================================================================
+ // class ODateTimeControl
+ //==================================================================
+ //------------------------------------------------------------------
+ ODateTimeControl::ODateTimeControl( Window* _pParent, WinBits _nWinStyle)
+ :ODateTimeControl_Base( PropertyControlType::DateTimeField, _pParent, _nWinStyle )
+ {
+ getTypedControlWindow()->EnableEmptyField( sal_True );
+
+ // determine a default format
+ Locale aSysLocale = SvtSysLocale().GetLocaleData().getLocale();
+ LanguageType eSysLanguage = MsLangId::convertLocaleToLanguage( aSysLocale );
+
+ getTypedControlWindow()->SetFormatter( getTypedControlWindow()->StandardFormatter() );
+ SvNumberFormatter* pFormatter = getTypedControlWindow()->GetFormatter();
+ ULONG nStandardDateTimeFormat = pFormatter->GetStandardFormat( NUMBERFORMAT_DATETIME, eSysLanguage );
+
+ getTypedControlWindow()->SetFormatKey( nStandardDateTimeFormat );
+ }
+
+ //------------------------------------------------------------------
+ void SAL_CALL ODateTimeControl::setValue( const Any& _rValue ) throw (IllegalTypeException, RuntimeException)
+ {
+ if ( !_rValue.hasValue() )
+ {
+ getTypedControlWindow()->SetText( String() );
+ }
+ else
+ {
+ util::DateTime aUNODateTime;
+ OSL_VERIFY( _rValue >>= aUNODateTime );
+
+ ::DateTime aDateTime;
+ ::utl::typeConvert( aUNODateTime, aDateTime );
+
+ double nValue = aDateTime - ::DateTime( *getTypedControlWindow()->GetFormatter()->GetNullDate() );
+ getTypedControlWindow()->SetValue( nValue );
+ }
+ }
+
+ //------------------------------------------------------------------
+ Any SAL_CALL ODateTimeControl::getValue() throw (RuntimeException)
+ {
+ Any aPropValue;
+ if ( getTypedControlWindow()->GetText().Len() )
+ {
+ double nValue = getTypedControlWindow()->GetValue();
+
+ ::DateTime aDateTime( *getTypedControlWindow()->GetFormatter()->GetNullDate() );
+
+ // add the "days" part
+ double nDays = floor( nValue );
+ aDateTime += nDays;
+
+ // add the "time" part
+ double nTime = nValue - nDays;
+ nTime = ::rtl::math::round( nTime * 86400.0 ) / 86400.0;
+ // we're not interested in 100th seconds, and this here prevents rounding errors
+ aDateTime += nTime;
+
+ util::DateTime aUNODateTime;
+ ::utl::typeConvert( aDateTime, aUNODateTime );
+
+ aPropValue <<= aUNODateTime;
+ }
+ return aPropValue;
+ }
+
+ //------------------------------------------------------------------
+ Type SAL_CALL ODateTimeControl::getValueType() throw (RuntimeException)
+ {
+ return ::getCppuType( static_cast< util::DateTime* >( NULL ) );
+ }
+
+ //========================================================================
+ //= HyperlinkInput
+ //========================================================================
+ //--------------------------------------------------------------------
+ HyperlinkInput::HyperlinkInput( Window* _pParent, WinBits _nWinStyle )
+ :Edit( _pParent, _nWinStyle )
+ {
+ ::svtools::ColorConfig aColorConfig;
+ ::svtools::ColorConfigValue aLinkColor( aColorConfig.GetColorValue( ::svtools::LINKS ) );
+
+ AllSettings aAllSettings( GetSettings() );
+ StyleSettings aStyleSettings( aAllSettings.GetStyleSettings() );
+
+ Font aFieldFont( aStyleSettings.GetFieldFont() );
+ aFieldFont.SetUnderline( UNDERLINE_SINGLE );
+ aFieldFont.SetColor( aLinkColor.nColor );
+ aStyleSettings.SetFieldFont( aFieldFont );
+
+ aStyleSettings.SetFieldTextColor( aLinkColor.nColor );
+
+ aAllSettings.SetStyleSettings( aStyleSettings );
+ SetSettings( aAllSettings );
+ }
+
+ //--------------------------------------------------------------------
+ void HyperlinkInput::MouseMove( const ::MouseEvent& rMEvt )
+ {
+ Edit::MouseMove( rMEvt );
+
+ PointerStyle ePointerStyle( POINTER_TEXT );
+
+ if ( !rMEvt.IsLeaveWindow() )
+ {
+ if ( impl_textHitTest( rMEvt.GetPosPixel() ) )
+ ePointerStyle = POINTER_REFHAND;
+ }
+
+ SetPointer( Pointer( ePointerStyle ) );
+ }
+
+ //--------------------------------------------------------------------
+ void HyperlinkInput::MouseButtonDown( const ::MouseEvent& rMEvt )
+ {
+ Edit::MouseButtonDown( rMEvt );
+
+ if ( impl_textHitTest( rMEvt.GetPosPixel() ) )
+ m_aMouseButtonDownPos = rMEvt.GetPosPixel();
+ else
+ m_aMouseButtonDownPos.X() = m_aMouseButtonDownPos.Y() = -1;
+ }
+
+ //--------------------------------------------------------------------
+ void HyperlinkInput::MouseButtonUp( const ::MouseEvent& rMEvt )
+ {
+ Edit::MouseButtonUp( rMEvt );
+
+ impl_checkEndClick( rMEvt );
+ }
+
+ //--------------------------------------------------------------------
+ bool HyperlinkInput::impl_textHitTest( const ::Point& _rWindowPos )
+ {
+ xub_StrLen nPos = GetCharPos( _rWindowPos );
+ return ( ( nPos != STRING_LEN ) && ( nPos < GetText().Len() ) );
+ }
+
+ //--------------------------------------------------------------------
+ void HyperlinkInput::impl_checkEndClick( const ::MouseEvent rMEvt )
+ {
+ const MouseSettings& rMouseSettings( GetSettings().GetMouseSettings() );
+ if ( ( abs( rMEvt.GetPosPixel().X() - m_aMouseButtonDownPos.X() ) < rMouseSettings.GetStartDragWidth() )
+ && ( abs( rMEvt.GetPosPixel().Y() - m_aMouseButtonDownPos.Y() ) < rMouseSettings.GetStartDragHeight() )
+ )
+ Application::PostUserEvent( m_aClickHandler );
+ }
+
+ //--------------------------------------------------------------------
+ void HyperlinkInput::Tracking( const TrackingEvent& rTEvt )
+ {
+ Edit::Tracking( rTEvt );
+
+ if ( rTEvt.IsTrackingEnded() )
+ impl_checkEndClick( rTEvt.GetMouseEvent() );
+ }
+
+ //========================================================================
+ //= OHyperlinkControl
+ //========================================================================
+ //--------------------------------------------------------------------
+ OHyperlinkControl::OHyperlinkControl( Window* _pParent, WinBits _nWinStyle )
+ :OHyperlinkControl_Base( PropertyControlType::HyperlinkField, _pParent, _nWinStyle )
+ ,m_aActionListeners( m_aMutex )
+ {
+ getTypedControlWindow()->SetClickHdl( LINK( this, OHyperlinkControl, OnHyperlinkClicked ) );
+ }
+
+ //--------------------------------------------------------------------
+ Any SAL_CALL OHyperlinkControl::getValue() throw (RuntimeException)
+ {
+ ::rtl::OUString sText = getTypedControlWindow()->GetText();
+ return makeAny( sText );
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL OHyperlinkControl::setValue( const Any& _value ) throw (IllegalTypeException, RuntimeException)
+ {
+ ::rtl::OUString sText;
+ _value >>= sText;
+ getTypedControlWindow()->SetText( sText );
+ }
+
+ //--------------------------------------------------------------------
+ Type SAL_CALL OHyperlinkControl::getValueType() throw (RuntimeException)
+ {
+ return ::getCppuType( static_cast< ::rtl::OUString* >( NULL ) );
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL OHyperlinkControl::addActionListener( const Reference< XActionListener >& listener ) throw (RuntimeException)
+ {
+ if ( listener.is() )
+ m_aActionListeners.addInterface( listener );
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL OHyperlinkControl::removeActionListener( const Reference< XActionListener >& listener ) throw (RuntimeException)
+ {
+ m_aActionListeners.removeInterface( listener );
+ }
+
+ //------------------------------------------------------------------
+ void SAL_CALL OHyperlinkControl::disposing()
+ {
+ OHyperlinkControl_Base::disposing();
+
+ EventObject aEvent( *this );
+ m_aActionListeners.disposeAndClear( aEvent );
+ }
+
+ //------------------------------------------------------------------
+ IMPL_LINK( OHyperlinkControl, OnHyperlinkClicked, void*, /*_NotInterestedIn*/ )
+ {
+ ActionEvent aEvent( *this, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "clicked" ) ) );
+ m_aActionListeners.forEach< XActionListener >(
+ boost::bind(
+ &XActionListener::actionPerformed,
+ _1, boost::cref(aEvent) ) );
+
+ return 0;
+ }
+
+ //==================================================================
+ //= ONumericControl
+ //==================================================================
+ //------------------------------------------------------------------
+ ONumericControl::ONumericControl( Window* _pParent, WinBits _nWinStyle )
+ :ONumericControl_Base( PropertyControlType::NumericField, _pParent, _nWinStyle )
+ ,m_eValueUnit( FUNIT_NONE )
+ ,m_nFieldToUNOValueFactor( 1 )
+ {
+ getTypedControlWindow()->SetDefaultUnit( FUNIT_NONE );
+
+ getTypedControlWindow()->EnableEmptyFieldValue( sal_True );
+ getTypedControlWindow()->SetStrictFormat( sal_True );
+ Optional< double > value( getMaxValue() );
+ value.Value = -value.Value;
+ setMinValue( value );
+ }
+
+ //--------------------------------------------------------------------
+ ::sal_Int16 SAL_CALL ONumericControl::getDecimalDigits() throw (RuntimeException)
+ {
+ return getTypedControlWindow()->GetDecimalDigits();
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL ONumericControl::setDecimalDigits( ::sal_Int16 _decimaldigits ) throw (RuntimeException)
+ {
+ getTypedControlWindow()->SetDecimalDigits( _decimaldigits );
+ }
+
+ //--------------------------------------------------------------------
+ Optional< double > SAL_CALL ONumericControl::getMinValue() throw (RuntimeException)
+ {
+ Optional< double > aReturn( sal_True, 0 );
+
+ sal_Int64 minValue = getTypedControlWindow()->GetMin();
+ if ( minValue == ::std::numeric_limits< sal_Int64 >::min() )
+ aReturn.IsPresent = sal_False;
+ else
+ aReturn.Value = (double)minValue;
+
+ return aReturn;
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL ONumericControl::setMinValue( const Optional< double >& _minvalue ) throw (RuntimeException)
+ {
+ if ( !_minvalue.IsPresent )
+ getTypedControlWindow()->SetMin( ::std::numeric_limits< sal_Int64 >::min() );
+ else
+ getTypedControlWindow()->SetMin( impl_apiValueToFieldValue_nothrow( _minvalue.Value ) , m_eValueUnit);
+ }
+
+ //--------------------------------------------------------------------
+ Optional< double > SAL_CALL ONumericControl::getMaxValue() throw (RuntimeException)
+ {
+ Optional< double > aReturn( sal_True, 0 );
+
+ sal_Int64 maxValue = getTypedControlWindow()->GetMax();
+ if ( maxValue == ::std::numeric_limits< sal_Int64 >::max() )
+ aReturn.IsPresent = sal_False;
+ else
+ aReturn.Value = (double)maxValue;
+
+ return aReturn;
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL ONumericControl::setMaxValue( const Optional< double >& _maxvalue ) throw (RuntimeException)
+ {
+ if ( !_maxvalue.IsPresent )
+ getTypedControlWindow()->SetMax( ::std::numeric_limits< sal_Int64 >::max() );
+ else
+ getTypedControlWindow()->SetMax( impl_apiValueToFieldValue_nothrow( _maxvalue.Value ), m_eValueUnit );
+ }
+
+ //--------------------------------------------------------------------
+ ::sal_Int16 SAL_CALL ONumericControl::getDisplayUnit() throw (RuntimeException)
+ {
+ return VCLUnoHelper::ConvertToMeasurementUnit( getTypedControlWindow()->GetUnit(), 1 );
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL ONumericControl::setDisplayUnit( ::sal_Int16 _displayunit ) throw (IllegalArgumentException, RuntimeException)
+ {
+ if ( ( _displayunit < MeasureUnit::MM_100TH ) || ( _displayunit > MeasureUnit::PERCENT ) )
+ throw IllegalArgumentException();
+ if ( ( _displayunit == MeasureUnit::MM_100TH )
+ || ( _displayunit == MeasureUnit::MM_10TH )
+ || ( _displayunit == MeasureUnit::INCH_1000TH )
+ || ( _displayunit == MeasureUnit::INCH_100TH )
+ || ( _displayunit == MeasureUnit::INCH_10TH )
+ || ( _displayunit == MeasureUnit::PERCENT )
+ )
+ throw IllegalArgumentException();
+
+ sal_Int16 nDummyFactor = 1;
+ FieldUnit eFieldUnit = VCLUnoHelper::ConvertToFieldUnit( _displayunit, nDummyFactor );
+ if ( nDummyFactor != 1 )
+ // everything which survived the checks above should result in a factor of 1, i.e.,
+ // it should have a direct counterpart as FieldUnit
+ throw RuntimeException();
+ getTypedControlWindow()->MetricFormatter::SetUnit( eFieldUnit );
+ }
+
+ //--------------------------------------------------------------------
+ ::sal_Int16 SAL_CALL ONumericControl::getValueUnit() throw (RuntimeException)
+ {
+ return VCLUnoHelper::ConvertToMeasurementUnit( m_eValueUnit, m_nFieldToUNOValueFactor );
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL ONumericControl::setValueUnit( ::sal_Int16 _valueunit ) throw (RuntimeException)
+ {
+ if ( ( _valueunit < MeasureUnit::MM_100TH ) || ( _valueunit > MeasureUnit::PERCENT ) )
+ throw IllegalArgumentException();
+ m_eValueUnit = VCLUnoHelper::ConvertToFieldUnit( _valueunit, m_nFieldToUNOValueFactor );
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL ONumericControl::setValue( const Any& _rValue ) throw (IllegalTypeException, RuntimeException)
+ {
+ if ( !_rValue.hasValue() )
+ {
+ getTypedControlWindow()->SetText( String() );
+ getTypedControlWindow()->SetEmptyFieldValue();
+ }
+ else
+ {
+ double nValue( 0 );
+ OSL_VERIFY( _rValue >>= nValue );
+ long nControlValue = impl_apiValueToFieldValue_nothrow( nValue );
+ getTypedControlWindow()->SetValue( nControlValue, m_eValueUnit );
+ }
+ }
+
+ //------------------------------------------------------------------
+ long ONumericControl::impl_apiValueToFieldValue_nothrow( double _nApiValue ) const
+ {
+ long nControlValue = ImplCalcLongValue( _nApiValue, getTypedControlWindow()->GetDecimalDigits() );
+ nControlValue /= m_nFieldToUNOValueFactor;
+ return nControlValue;
+ }
+
+ //------------------------------------------------------------------
+ double ONumericControl::impl_fieldValueToApiValue_nothrow( sal_Int64 _nFieldValue ) const
+ {
+ double nApiValue = ImplCalcDoubleValue( (long)_nFieldValue, getTypedControlWindow()->GetDecimalDigits() );
+ nApiValue *= m_nFieldToUNOValueFactor;
+ return nApiValue;
+ }
+
+ //------------------------------------------------------------------
+ Any SAL_CALL ONumericControl::getValue() throw (RuntimeException)
+ {
+ Any aPropValue;
+ if ( getTypedControlWindow()->GetText().Len() )
+ {
+ double nValue = impl_fieldValueToApiValue_nothrow( getTypedControlWindow()->GetValue( m_eValueUnit ) );
+ aPropValue <<= nValue;
+ }
+ return aPropValue;
+ }
+
+ //------------------------------------------------------------------
+ Type SAL_CALL ONumericControl::getValueType() throw (RuntimeException)
+ {
+ return ::getCppuType( static_cast< double* >( NULL ) );
+ }
+
+ //==================================================================
+ //= OColorControl
+ //==================================================================
+ #define LB_DEFAULT_COUNT 20
+ //------------------------------------------------------------------
+ String MakeHexStr(sal_uInt32 nVal, sal_uInt32 nLength)
+ {
+ String aStr;
+ while (nVal>0)
+ {
+ char c=char(nVal & 0x000F);
+ nVal>>=4;
+ if (c<=9) c+='0';
+ else c+='A'-10;
+ aStr.Insert(c,0);
+ }
+ while (aStr.Len() < nLength) aStr.Insert('0',0);
+ return aStr;
+ }
+
+ //------------------------------------------------------------------
+ OColorControl::OColorControl(Window* pParent, WinBits nWinStyle)
+ :OColorControl_Base( PropertyControlType::ColorListBox, pParent, nWinStyle )
+ {
+ // initialize the color listbox
+ XColorTable* pColorTable = NULL;
+ SfxObjectShell* pDocSh = SfxObjectShell::Current();
+ const SfxPoolItem* pItem = pDocSh ? pDocSh->GetItem( SID_COLOR_TABLE ) : NULL;
+ if ( pItem )
+ {
+ DBG_ASSERT(pItem->ISA(SvxColorTableItem), "OColorControl::OColorControl: invalid color item!");
+ pColorTable = ( (SvxColorTableItem*)pItem )->GetColorTable();
+ }
+
+ if ( !pColorTable )
+ {
+ pColorTable = XColorTable::GetStdColorTable();
+ }
+
+
+ DBG_ASSERT(pColorTable, "OColorControl::OColorControl: no color table!");
+
+ if (pColorTable)
+ {
+ for (sal_uInt16 i = 0; i < pColorTable->Count(); ++i)
+ {
+ XColorEntry* pEntry = pColorTable->GetColor( i );
+ getTypedControlWindow()->InsertEntry( pEntry->GetColor(), pEntry->GetName() );
+ }
+ }
+
+ getTypedControlWindow()->SetDropDownLineCount( LB_DEFAULT_COUNT );
+ if ( ( nWinStyle & WB_READONLY ) != 0 )
+ {
+ getTypedControlWindow()->SetReadOnly( TRUE );
+ getTypedControlWindow()->Enable( TRUE );
+ }
+ }
+
+ //------------------------------------------------------------------
+ void SAL_CALL OColorControl::setValue( const Any& _rValue ) throw (IllegalTypeException, RuntimeException)
+ {
+ if ( _rValue.hasValue() )
+ {
+ ::com::sun::star::util::Color nColor = COL_TRANSPARENT;
+ if ( _rValue >>= nColor )
+ {
+ ::Color aRgbCol((ColorData)nColor);
+
+ getTypedControlWindow()->SelectEntry( aRgbCol );
+ if ( !getTypedControlWindow()->IsEntrySelected( aRgbCol ) )
+ { // the given color is not part of the list -> insert a new entry with the hex code of the color
+ String aStr = String::CreateFromAscii("0x");
+ aStr += MakeHexStr(nColor,8);
+ getTypedControlWindow()->InsertEntry( aRgbCol, aStr );
+ getTypedControlWindow()->SelectEntry( aRgbCol );
+ }
+ }
+ else
+ {
+ ::rtl::OUString sNonColorValue;
+ if ( !( _rValue >>= sNonColorValue ) )
+ throw IllegalTypeException();
+ getTypedControlWindow()->SelectEntry( sNonColorValue );
+ if ( !getTypedControlWindow()->IsEntrySelected( sNonColorValue ) )
+ getTypedControlWindow()->SetNoSelection();
+ }
+ }
+ else
+ getTypedControlWindow()->SetNoSelection();
+ }
+
+ //------------------------------------------------------------------
+ Any SAL_CALL OColorControl::getValue() throw (RuntimeException)
+ {
+ Any aPropValue;
+ if ( getTypedControlWindow()->GetSelectEntryCount() > 0 )
+ {
+ ::rtl::OUString sSelectedEntry = getTypedControlWindow()->GetSelectEntry();
+ if ( m_aNonColorEntries.find( sSelectedEntry ) != m_aNonColorEntries.end() )
+ aPropValue <<= sSelectedEntry;
+ else
+ {
+ ::Color aRgbCol = getTypedControlWindow()->GetSelectEntryColor();
+ aPropValue <<= (::com::sun::star::util::Color)aRgbCol.GetColor();
+ }
+ }
+ return aPropValue;
+ }
+
+ //------------------------------------------------------------------
+ Type SAL_CALL OColorControl::getValueType() throw (RuntimeException)
+ {
+ return ::getCppuType( static_cast< sal_Int32* >( NULL ) );
+ }
+
+ //------------------------------------------------------------------
+ void SAL_CALL OColorControl::clearList() throw (RuntimeException)
+ {
+ getTypedControlWindow()->Clear();
+ }
+
+ //------------------------------------------------------------------
+ void SAL_CALL OColorControl::prependListEntry( const ::rtl::OUString& NewEntry ) throw (RuntimeException)
+ {
+ getTypedControlWindow()->InsertEntry( NewEntry, 0 );
+ m_aNonColorEntries.insert( NewEntry );
+ }
+
+ //------------------------------------------------------------------
+ void SAL_CALL OColorControl::appendListEntry( const ::rtl::OUString& NewEntry ) throw (RuntimeException)
+ {
+ getTypedControlWindow()->InsertEntry( NewEntry );
+ m_aNonColorEntries.insert( NewEntry );
+ }
+ //------------------------------------------------------------------
+ Sequence< ::rtl::OUString > SAL_CALL OColorControl::getListEntries( ) throw (RuntimeException)
+ {
+ if ( !m_aNonColorEntries.empty() )
+ return Sequence< ::rtl::OUString >(&(*m_aNonColorEntries.begin()),m_aNonColorEntries.size());
+ return Sequence< ::rtl::OUString >();
+ }
+
+ //------------------------------------------------------------------
+ void OColorControl::modified()
+ {
+ OColorControl_Base::modified();
+
+ if ( !getTypedControlWindow()->IsTravelSelect() )
+ // fire a commit
+ m_aImplControl.notifyModifiedValue();
+ }
+
+ //==================================================================
+ //= OListboxControl
+ //==================================================================
+ //------------------------------------------------------------------
+ OListboxControl::OListboxControl( Window* pParent, WinBits nWinStyle)
+ :OListboxControl_Base( PropertyControlType::ListBox, pParent, nWinStyle )
+ {
+ getTypedControlWindow()->SetDropDownLineCount( LB_DEFAULT_COUNT );
+ if ( ( nWinStyle & WB_READONLY ) != 0 )
+ {
+ getTypedControlWindow()->SetReadOnly( TRUE );
+ getTypedControlWindow()->Enable( TRUE );
+ }
+ }
+
+ //------------------------------------------------------------------
+ Any SAL_CALL OListboxControl::getValue() throw (RuntimeException)
+ {
+ ::rtl::OUString sControlValue( getTypedControlWindow()->GetSelectEntry() );
+
+ Any aPropValue;
+ if ( sControlValue.getLength() )
+ aPropValue <<= sControlValue;
+ return aPropValue;
+ }
+
+ //------------------------------------------------------------------
+ Type SAL_CALL OListboxControl::getValueType() throw (RuntimeException)
+ {
+ return ::getCppuType( static_cast< ::rtl::OUString* >( NULL ) );
+ }
+
+ //------------------------------------------------------------------
+ void SAL_CALL OListboxControl::setValue( const Any& _rValue ) throw (IllegalTypeException, RuntimeException)
+ {
+ if ( !_rValue.hasValue() )
+ getTypedControlWindow()->SetNoSelection();
+ else
+ {
+ ::rtl::OUString sSelection;
+ _rValue >>= sSelection;
+
+ if ( !sSelection.equals( getTypedControlWindow()->GetSelectEntry() ) )
+ getTypedControlWindow()->SelectEntry( sSelection );
+
+ if ( !getTypedControlWindow()->IsEntrySelected( sSelection ) )
+ {
+ getTypedControlWindow()->InsertEntry( sSelection, 0 );
+ getTypedControlWindow()->SelectEntry( sSelection );
+ }
+ }
+ }
+
+ //------------------------------------------------------------------
+ void SAL_CALL OListboxControl::clearList() throw (RuntimeException)
+ {
+ getTypedControlWindow()->Clear();
+ }
+
+ //------------------------------------------------------------------
+ void SAL_CALL OListboxControl::prependListEntry( const ::rtl::OUString& NewEntry ) throw (RuntimeException)
+ {
+ getTypedControlWindow()->InsertEntry( NewEntry, 0 );
+ }
+
+ //------------------------------------------------------------------
+ void SAL_CALL OListboxControl::appendListEntry( const ::rtl::OUString& NewEntry ) throw (RuntimeException)
+ {
+ getTypedControlWindow()->InsertEntry( NewEntry );
+ }
+ //------------------------------------------------------------------
+ Sequence< ::rtl::OUString > SAL_CALL OListboxControl::getListEntries( ) throw (RuntimeException)
+ {
+ const USHORT nCount = getTypedControlWindow()->GetEntryCount();
+ Sequence< ::rtl::OUString > aRet(nCount);
+ ::rtl::OUString* pIter = aRet.getArray();
+ for (USHORT i = 0; i < nCount ; ++i,++pIter)
+ *pIter = getTypedControlWindow()->GetEntry(i);
+
+ return aRet;
+ }
+
+ //------------------------------------------------------------------
+ void OListboxControl::modified()
+ {
+ OListboxControl_Base::modified();
+
+ if ( !getTypedControlWindow()->IsTravelSelect() )
+ // fire a commit
+ m_aImplControl.notifyModifiedValue();
+ }
+
+ //==================================================================
+ //= OComboboxControl
+ //==================================================================
+ //------------------------------------------------------------------
+ OComboboxControl::OComboboxControl( Window* pParent, WinBits nWinStyle)
+ :OComboboxControl_Base( PropertyControlType::ComboBox, pParent, nWinStyle )
+ {
+ getTypedControlWindow()->SetDropDownLineCount( LB_DEFAULT_COUNT );
+ getTypedControlWindow()->SetSelectHdl( LINK( this, OComboboxControl, OnEntrySelected ) );
+ }
+
+ //------------------------------------------------------------------
+ void SAL_CALL OComboboxControl::setValue( const Any& _rValue ) throw (IllegalTypeException, RuntimeException)
+ {
+ ::rtl::OUString sText;
+ _rValue >>= sText;
+ getTypedControlWindow()->SetText( sText );
+ }
+
+ //------------------------------------------------------------------
+ Any SAL_CALL OComboboxControl::getValue() throw (RuntimeException)
+ {
+ return makeAny( ::rtl::OUString( getTypedControlWindow()->GetText() ) );
+ }
+
+ //------------------------------------------------------------------
+ Type SAL_CALL OComboboxControl::getValueType() throw (RuntimeException)
+ {
+ return ::getCppuType( static_cast< ::rtl::OUString* >( NULL ) );
+ }
+
+ //------------------------------------------------------------------
+ void SAL_CALL OComboboxControl::clearList() throw (RuntimeException)
+ {
+ getTypedControlWindow()->Clear();
+ }
+
+ //------------------------------------------------------------------
+ void SAL_CALL OComboboxControl::prependListEntry( const ::rtl::OUString& NewEntry ) throw (RuntimeException)
+ {
+ getTypedControlWindow()->InsertEntry( NewEntry, 0 );
+ }
+
+ //------------------------------------------------------------------
+ void SAL_CALL OComboboxControl::appendListEntry( const ::rtl::OUString& NewEntry ) throw (RuntimeException)
+ {
+ getTypedControlWindow()->InsertEntry( NewEntry );
+ }
+ //------------------------------------------------------------------
+ Sequence< ::rtl::OUString > SAL_CALL OComboboxControl::getListEntries( ) throw (RuntimeException)
+ {
+ const USHORT nCount = getTypedControlWindow()->GetEntryCount();
+ Sequence< ::rtl::OUString > aRet(nCount);
+ ::rtl::OUString* pIter = aRet.getArray();
+ for (USHORT i = 0; i < nCount ; ++i,++pIter)
+ *pIter = getTypedControlWindow()->GetEntry(i);
+
+ return aRet;
+ }
+
+ //------------------------------------------------------------------
+ IMPL_LINK( OComboboxControl, OnEntrySelected, void*, /*_pNothing*/ )
+ {
+ if ( !getTypedControlWindow()->IsTravelSelect() )
+ // fire a commit
+ m_aImplControl.notifyModifiedValue();
+ return 0L;
+ }
+
+ //==================================================================
+ //= OMultilineFloatingEdit
+ //==================================================================
+ class OMultilineFloatingEdit : public FloatingWindow
+ {
+ private:
+ MultiLineEdit m_aImplEdit;
+
+ protected:
+ virtual void Resize();
+
+ public:
+ OMultilineFloatingEdit(Window* _pParen);
+ MultiLineEdit* getEdit() { return &m_aImplEdit; }
+
+ protected:
+ virtual long PreNotify(NotifyEvent& _rNEvt);
+ };
+
+ //------------------------------------------------------------------
+ OMultilineFloatingEdit::OMultilineFloatingEdit(Window* _pParent)
+ :FloatingWindow(_pParent, WB_BORDER)
+ ,m_aImplEdit(this, WB_VSCROLL|WB_IGNORETAB|WB_NOBORDER)
+ {
+ m_aImplEdit.Show();
+ }
+
+ //------------------------------------------------------------------
+ void OMultilineFloatingEdit::Resize()
+ {
+ m_aImplEdit.SetSizePixel(GetOutputSizePixel());
+ }
+
+ //------------------------------------------------------------------
+ long OMultilineFloatingEdit::PreNotify(NotifyEvent& _rNEvt)
+ {
+ long nResult = sal_True;
+
+ sal_uInt16 nSwitch = _rNEvt.GetType();
+ if (EVENT_KEYINPUT == nSwitch)
+ {
+ const KeyCode& aKeyCode = _rNEvt.GetKeyEvent()->GetKeyCode();
+ sal_uInt16 nKey = aKeyCode.GetCode();
+
+ if ( ( (KEY_RETURN == nKey)
+ && !aKeyCode.IsShift()
+ )
+ || ( (KEY_UP == nKey)
+ && aKeyCode.IsMod2()
+ )
+ )
+ {
+ EndPopupMode();
+ }
+ else
+ nResult=FloatingWindow::PreNotify(_rNEvt);
+ }
+ else
+ nResult=FloatingWindow::PreNotify(_rNEvt);
+
+ return nResult;
+ }
+
+ //==================================================================
+ //= DropDownEditControl_Base
+ //==================================================================
+ //------------------------------------------------------------------
+ DropDownEditControl::DropDownEditControl( Window* _pParent, WinBits _nStyle )
+ :DropDownEditControl_Base( _pParent, _nStyle )
+ ,m_pFloatingEdit( NULL )
+ ,m_pImplEdit( NULL )
+ ,m_pDropdownButton( NULL )
+ ,m_nOperationMode( eStringList )
+ ,m_bDropdown( sal_False )
+ {
+ SetCompoundControl( TRUE );
+
+ m_pImplEdit = new MultiLineEdit( this, WB_TABSTOP | WB_IGNORETAB | WB_NOBORDER | (_nStyle & WB_READONLY) );
+ SetSubEdit( m_pImplEdit );
+ m_pImplEdit->Show();
+
+ if ( _nStyle & WB_DROPDOWN )
+ {
+ m_pDropdownButton = new PushButton( this, WB_NOLIGHTBORDER | WB_RECTSTYLE | WB_NOTABSTOP);
+ m_pDropdownButton->SetSymbol(SYMBOL_SPIN_DOWN);
+ m_pDropdownButton->SetClickHdl( LINK( this, DropDownEditControl, DropDownHdl ) );
+ m_pDropdownButton->Show();
+ }
+
+ m_pFloatingEdit = new OMultilineFloatingEdit(this); //FloatingWindow
+
+ m_pFloatingEdit->SetPopupModeEndHdl( LINK( this, DropDownEditControl, ReturnHdl ) );
+ m_pFloatingEdit->getEdit()->SetReadOnly( ( _nStyle & WB_READONLY ) != 0 );
+ }
+
+ //------------------------------------------------------------------
+ void DropDownEditControl::setControlHelper( ControlHelper& _rControlHelper )
+ {
+ DropDownEditControl_Base::setControlHelper( _rControlHelper );
+ m_pFloatingEdit->getEdit()->SetModifyHdl( LINK( &_rControlHelper, ControlHelper, ModifiedHdl ) );
+ m_pImplEdit->SetGetFocusHdl( LINK( &_rControlHelper, ControlHelper, GetFocusHdl ) );
+ m_pImplEdit->SetModifyHdl( LINK( &_rControlHelper, ControlHelper, ModifiedHdl ) );
+ m_pImplEdit->SetLoseFocusHdl( LINK( &_rControlHelper, ControlHelper, LoseFocusHdl ) );
+ }
+
+ //------------------------------------------------------------------
+ DropDownEditControl::~DropDownEditControl()
+ {
+ {
+ ::std::auto_ptr<Window> aTemp(m_pFloatingEdit);
+ m_pFloatingEdit = NULL;
+ }
+ {
+ ::std::auto_ptr<Window> aTemp(m_pImplEdit);
+ SetSubEdit( NULL );
+ m_pImplEdit = NULL;
+ }
+ {
+ ::std::auto_ptr<Window> aTemp(m_pDropdownButton);
+ m_pDropdownButton = NULL;
+ }
+ }
+
+ //------------------------------------------------------------------
+ void DropDownEditControl::Resize()
+ {
+ ::Size aOutSz = GetOutputSizePixel();
+
+ if (m_pDropdownButton!=NULL)
+ {
+ long nSBWidth = GetSettings().GetStyleSettings().GetScrollBarSize();
+ nSBWidth = CalcZoom( nSBWidth );
+ m_pImplEdit->SetPosSizePixel( 0, 1, aOutSz.Width() - nSBWidth, aOutSz.Height()-2 );
+ m_pDropdownButton->SetPosSizePixel( aOutSz.Width() - nSBWidth, 0, nSBWidth, aOutSz.Height() );
+ }
+ else
+ m_pImplEdit->SetPosSizePixel( 0, 1, aOutSz.Width(), aOutSz.Height()-2 );
+ }
+
+ //------------------------------------------------------------------
+ long DropDownEditControl::PreNotify( NotifyEvent& rNEvt )
+ {
+ long nResult = 1;
+
+ if (rNEvt.GetType() == EVENT_KEYINPUT)
+ {
+ const KeyCode& aKeyCode = rNEvt.GetKeyEvent()->GetKeyCode();
+ sal_uInt16 nKey = aKeyCode.GetCode();
+
+ if ( nKey == KEY_RETURN && !aKeyCode.IsShift() )
+ {
+ if ( m_pHelper )
+ {
+ m_pHelper->LoseFocusHdl( m_pImplEdit );
+ m_pHelper->activateNextControl();
+ }
+ }
+ else if ( nKey == KEY_DOWN && aKeyCode.IsMod2() )
+ {
+ Invalidate();
+ ShowDropDown( sal_True );
+ }
+ else if ( KEYGROUP_CURSOR == aKeyCode.GetGroup()
+ || nKey == KEY_HELP
+ || KEYGROUP_FKEYS == aKeyCode.GetGroup()
+ || m_nOperationMode == eMultiLineText
+ )
+ {
+ nResult = DropDownEditControl_Base::PreNotify( rNEvt );
+ }
+ else if ( m_nOperationMode == eStringList )
+ {
+ Selection aSel = m_pImplEdit->GetSelection();
+ if ( aSel.Min() != aSel.Max() )
+ {
+ aSel.Min() = FindPos( aSel.Min() );
+ aSel.Max() = FindPos( aSel.Max() );
+ }
+ else
+ {
+ aSel.Min() = FindPos( aSel.Min() );
+ aSel.Max() = aSel.Min();
+ }
+ Invalidate();
+ ShowDropDown( sal_True );
+ m_pFloatingEdit->getEdit()->GrabFocus();
+ m_pFloatingEdit->getEdit()->SetSelection( aSel );
+ Window* pFocusWin = Application::GetFocusWindow();
+ pFocusWin->KeyInput( *rNEvt.GetKeyEvent() );
+ }
+ }
+ else
+ nResult = DropDownEditControl_Base::PreNotify(rNEvt);
+
+ return nResult;
+ }
+
+ //------------------------------------------------------------------
+ namespace
+ {
+ //..............................................................
+ StlSyntaxSequence< ::rtl::OUString > lcl_convertMultiLineToList( const String& _rCompsedTextWithLineBreaks )
+ {
+ xub_StrLen nLines( _rCompsedTextWithLineBreaks.GetTokenCount( '\n' ) );
+ StlSyntaxSequence< ::rtl::OUString > aStrings( nLines );
+ StlSyntaxSequence< ::rtl::OUString >::iterator stringItem = aStrings.begin();
+ for ( xub_StrLen token = 0; token < nLines; ++token, ++stringItem )
+ *stringItem = _rCompsedTextWithLineBreaks.GetToken( token, '\n' );
+ return aStrings;
+ }
+
+ String lcl_convertListToMultiLine( const StlSyntaxSequence< ::rtl::OUString >& _rStrings )
+ {
+ String sMultiLineText;
+ for ( StlSyntaxSequence< ::rtl::OUString >::const_iterator item = _rStrings.begin();
+ item != _rStrings.end();
+ )
+ {
+ sMultiLineText += String( *item );
+ if ( ++item != _rStrings.end() )
+ sMultiLineText += '\n';
+ }
+ return sMultiLineText;
+ }
+
+ //..............................................................
+ String lcl_convertListToDisplayText( const StlSyntaxSequence< ::rtl::OUString >& _rStrings )
+ {
+ ::rtl::OUStringBuffer aComposed;
+ for ( StlSyntaxSequence< ::rtl::OUString >::const_iterator strings = _rStrings.begin();
+ strings != _rStrings.end();
+ ++strings
+ )
+ {
+ if ( strings != _rStrings.begin() )
+ aComposed.append( (sal_Unicode)';' );
+ aComposed.append( (sal_Unicode)'\"' );
+ aComposed.append( *strings );
+ aComposed.append( (sal_Unicode)'\"' );
+ }
+ return aComposed.makeStringAndClear();
+ }
+ }
+
+ //------------------------------------------------------------------
+ #define STD_HEIGHT 100
+ sal_Bool DropDownEditControl::ShowDropDown( sal_Bool bShow )
+ {
+ if (bShow)
+ {
+ ::Point aMePos= GetPosPixel();
+ aMePos = GetParent()->OutputToScreenPixel( aMePos );
+ ::Size aSize=GetSizePixel();
+ ::Rectangle aRect(aMePos,aSize);
+ aSize.Height() = STD_HEIGHT;
+ m_pFloatingEdit->SetOutputSizePixel(aSize);
+ m_pFloatingEdit->StartPopupMode( aRect, FLOATWIN_POPUPMODE_DOWN );
+
+ m_pFloatingEdit->Show();
+ m_pFloatingEdit->getEdit()->GrabFocus();
+ m_pFloatingEdit->getEdit()->SetSelection(Selection(m_pFloatingEdit->getEdit()->GetText().Len()));
+ m_bDropdown=sal_True;
+ if ( m_nOperationMode == eMultiLineText )
+ m_pFloatingEdit->getEdit()->SetText( m_pImplEdit->GetText() );
+ m_pImplEdit->SetText(String());
+ }
+ else
+ {
+ m_pFloatingEdit->Hide();
+ m_pFloatingEdit->Invalidate();
+ m_pFloatingEdit->Update();
+
+ // transfer the text from the floating edit to our own edit
+ String sDisplayText( m_pFloatingEdit->getEdit()->GetText() );
+ if ( m_nOperationMode == eStringList )
+ sDisplayText = lcl_convertListToDisplayText( lcl_convertMultiLineToList( sDisplayText ) );
+
+ m_pImplEdit->SetText( sDisplayText );
+ GetParent()->Invalidate( INVALIDATE_CHILDREN );
+ m_bDropdown = sal_False;
+ m_pImplEdit->GrabFocus();
+ }
+ return m_bDropdown;
+
+ }
+
+ //------------------------------------------------------------------
+ long DropDownEditControl::FindPos(long nSinglePos)
+ {
+ long nPos=0;
+ long nDiff=0;
+ String aOutput;
+ String aStr=m_pFloatingEdit->getEdit()->GetText();
+ String aStr1 = GetText();
+
+ if ((nSinglePos == 0) || (nSinglePos == aStr1.Len()))
+ {
+ return nSinglePos;
+ }
+
+ if (aStr.Len()>0)
+ {
+ sal_Int32 nCount = aStr.GetTokenCount('\n');
+
+ String aInput = aStr.GetToken(0,'\n' );
+
+ if (aInput.Len()>0)
+ {
+ aOutput+='\"';
+ nDiff++;
+ aOutput+=aInput;
+ aOutput+='\"';
+ }
+
+ if (nSinglePos <= aOutput.Len())
+ {
+ nPos=nSinglePos-nDiff;
+ }
+ else
+ {
+ for (sal_Int32 i=1; i<nCount; ++i)
+ {
+ aInput=aStr.GetToken((sal_uInt16)i, '\n');
+ if (aInput.Len()>0)
+ {
+ aOutput += ';';
+ aOutput += '\"';
+ nDiff += 2;
+ aOutput += aInput;
+ aOutput += '\"';
+
+ if (nSinglePos <= aOutput.Len())
+ {
+ nPos=nSinglePos-nDiff;
+ break;
+ }
+ }
+ }
+ }
+ }
+ return nPos;
+ }
+
+ //------------------------------------------------------------------
+ IMPL_LINK( DropDownEditControl, ReturnHdl, OMultilineFloatingEdit*, /*pMEd*/)
+ {
+
+ String aStr = m_pFloatingEdit->getEdit()->GetText();
+ String aStr2 = GetText();
+ ShowDropDown(sal_False);
+
+ if (aStr!=aStr2 || ( m_nOperationMode == eStringList ) )
+ {
+ if ( m_pHelper )
+ m_pHelper->notifyModifiedValue();
+ }
+
+ return 0;
+ }
+
+ //------------------------------------------------------------------
+ IMPL_LINK( DropDownEditControl, DropDownHdl, PushButton*, /*pPb*/ )
+ {
+ ShowDropDown(!m_bDropdown);
+ return 0;
+ }
+
+ //------------------------------------------------------------------
+ void DropDownEditControl::SetStringListValue( const StlSyntaxSequence< ::rtl::OUString >& _rStrings )
+ {
+ SetText( lcl_convertListToDisplayText( _rStrings ) );
+ m_pFloatingEdit->getEdit()->SetText( lcl_convertListToMultiLine( _rStrings ) );
+ }
+
+ //------------------------------------------------------------------
+ StlSyntaxSequence< ::rtl::OUString > DropDownEditControl::GetStringListValue() const
+ {
+ return lcl_convertMultiLineToList( m_pFloatingEdit->getEdit()->GetText() );
+ }
+
+ //------------------------------------------------------------------
+ void DropDownEditControl::SetTextValue( const ::rtl::OUString& _rText )
+ {
+ OSL_PRECOND( m_nOperationMode == eMultiLineText, "DropDownEditControl::SetTextValue: illegal call!" );
+
+ m_pFloatingEdit->getEdit()->SetText( _rText );
+ SetText( _rText );
+ }
+
+ //------------------------------------------------------------------
+ ::rtl::OUString DropDownEditControl::GetTextValue() const
+ {
+ OSL_PRECOND( m_nOperationMode == eMultiLineText, "DropDownEditControl::GetTextValue: illegal call!" );
+ return GetText();
+ }
+
+ //==================================================================
+ //= OMultilineEditControl
+ //==================================================================
+ //------------------------------------------------------------------
+ OMultilineEditControl::OMultilineEditControl( Window* pParent, MultiLineOperationMode _eMode, WinBits nWinStyle )
+ :OMultilineEditControl_Base( _eMode == eMultiLineText ? PropertyControlType::MultiLineTextField : PropertyControlType::StringListField
+ , pParent
+ , ( nWinStyle | WB_DIALOGCONTROL ) & ( ~WB_READONLY | ~WB_DROPDOWN )
+ , false )
+ {
+ getTypedControlWindow()->setOperationMode( _eMode );
+ }
+
+ //------------------------------------------------------------------
+ void SAL_CALL OMultilineEditControl::setValue( const Any& _rValue ) throw (IllegalTypeException, RuntimeException)
+ {
+ impl_checkDisposed_throw();
+
+ switch ( getTypedControlWindow()->getOperationMode() )
+ {
+ case eMultiLineText:
+ {
+ ::rtl::OUString sText;
+ if ( !( _rValue >>= sText ) && _rValue.hasValue() )
+ throw IllegalTypeException();
+ getTypedControlWindow()->SetTextValue( sText );
+ }
+ break;
+ case eStringList:
+ {
+ Sequence< ::rtl::OUString > aStringLines;
+ if ( !( _rValue >>= aStringLines ) && _rValue.hasValue() )
+ throw IllegalTypeException();
+ getTypedControlWindow()->SetStringListValue( aStringLines );
+ }
+ break;
+ }
+ }
+
+ //------------------------------------------------------------------
+ Any SAL_CALL OMultilineEditControl::getValue() throw (RuntimeException)
+ {
+ impl_checkDisposed_throw();
+
+ Any aValue;
+ switch ( getTypedControlWindow()->getOperationMode() )
+ {
+ case eMultiLineText:
+ aValue <<= getTypedControlWindow()->GetTextValue();
+ break;
+ case eStringList:
+ aValue <<= getTypedControlWindow()->GetStringListValue();
+ break;
+ }
+ return aValue;
+ }
+
+ //------------------------------------------------------------------
+ Type SAL_CALL OMultilineEditControl::getValueType() throw (RuntimeException)
+ {
+ if ( getTypedControlWindow()->getOperationMode() == eMultiLineText )
+ return ::getCppuType( static_cast< ::rtl::OUString* >( NULL ) );
+ return ::getCppuType( static_cast< Sequence< ::rtl::OUString >* >( NULL ) );
+ }
+
+//............................................................................
+} // namespace pcr
+//............................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/propctrlr/standardcontrol.hxx b/extensions/source/propctrlr/standardcontrol.hxx
new file mode 100644
index 000000000000..8fed840fc605
--- /dev/null
+++ b/extensions/source/propctrlr/standardcontrol.hxx
@@ -0,0 +1,447 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _EXTENSIONS_PROPCTRLR_STANDARDCONTROL_HXX_
+#define _EXTENSIONS_PROPCTRLR_STANDARDCONTROL_HXX_
+
+#include "commoncontrol.hxx"
+#include "pcrcommon.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/inspection/XNumericControl.hpp>
+#include <com/sun/star/inspection/XStringListControl.hpp>
+#include <com/sun/star/inspection/XHyperlinkControl.hpp>
+#include <com/sun/star/uno/Sequence.hxx>
+/** === end UNO includes === **/
+#include <vcl/field.hxx>
+#include <vcl/longcurr.hxx>
+#include <svtools/ctrlbox.hxx>
+#include <vcl/lstbox.hxx>
+#include <vcl/combobox.hxx>
+#include <svtools/calendar.hxx>
+#include <svtools/fmtfield.hxx>
+
+#include <set>
+
+class PushButton;
+class MultiLineEdit;
+//............................................................................
+namespace pcr
+{
+//............................................................................
+
+ //========================================================================
+ //= ListLikeControlWithModifyHandler
+ //========================================================================
+ /** Very small helper class which adds a SetModifyHdl to a ListBox-derived class,
+ thus giving this class the same API (as far as the CommonBehaviourControl is concerned)
+ as all other windows.
+ */
+ template< class LISTBOX_WINDOW >
+ class ListLikeControlWithModifyHandler : public ControlWindow< LISTBOX_WINDOW >
+ {
+ protected:
+ typedef ControlWindow< LISTBOX_WINDOW > ListBoxType;
+
+ public:
+ ListLikeControlWithModifyHandler( Window* _pParent, WinBits _nStyle )
+ :ListBoxType( _pParent, _nStyle )
+ {
+ }
+
+ void SetModifyHdl( const Link& _rLink ) { ListBoxType::SetSelectHdl( _rLink ); }
+
+ protected:
+ long PreNotify( NotifyEvent& _rNEvt );
+ };
+
+ //------------------------------------------------------------------------
+ template< class LISTBOX_WINDOW >
+ long ListLikeControlWithModifyHandler< LISTBOX_WINDOW >::PreNotify( NotifyEvent& _rNEvt )
+ {
+ if ( _rNEvt.GetType() == EVENT_KEYINPUT )
+ {
+ const ::KeyEvent* pKeyEvent = _rNEvt.GetKeyEvent();
+ if ( ( pKeyEvent->GetKeyCode().GetModifier() == 0 )
+ && ( ( pKeyEvent->GetKeyCode().GetCode() == KEY_PAGEUP )
+ || ( pKeyEvent->GetKeyCode().GetCode() == KEY_PAGEDOWN )
+ )
+ )
+ {
+ if ( !ListBoxType::IsInDropDown() )
+ {
+ // don't give the base class a chance to consume the event, in the property browser, it is
+ // intended to scroll the complete property page
+ return ListBoxType::GetParent()->PreNotify( _rNEvt );
+ }
+ }
+ }
+ return ListBoxType::PreNotify( _rNEvt );
+ }
+
+ //========================================================================
+ //= OTimeControl
+ //========================================================================
+ typedef CommonBehaviourControl< ::com::sun::star::inspection::XPropertyControl, ControlWindow< TimeField > > OTimeControl_Base;
+ class OTimeControl : public OTimeControl_Base
+ {
+ public:
+ OTimeControl( Window* pParent, WinBits nWinStyle );
+
+ // XPropertyControl
+ virtual ::com::sun::star::uno::Any SAL_CALL getValue() throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setValue( const ::com::sun::star::uno::Any& _value ) throw (::com::sun::star::beans::IllegalTypeException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Type SAL_CALL getValueType() throw (::com::sun::star::uno::RuntimeException);
+ };
+
+ //========================================================================
+ //= ODateControl
+ //========================================================================
+ typedef CommonBehaviourControl< ::com::sun::star::inspection::XPropertyControl, ControlWindow< CalendarField > > ODateControl_Base;
+ class ODateControl : public ODateControl_Base
+ {
+ public:
+ ODateControl( Window* pParent, WinBits nWinStyle );
+
+ // XPropertyControl
+ virtual ::com::sun::star::uno::Any SAL_CALL getValue() throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setValue( const ::com::sun::star::uno::Any& _value ) throw (::com::sun::star::beans::IllegalTypeException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Type SAL_CALL getValueType() throw (::com::sun::star::uno::RuntimeException);
+ };
+
+ //========================================================================
+ //= OEditControl
+ //========================================================================
+ typedef CommonBehaviourControl< ::com::sun::star::inspection::XPropertyControl, ControlWindow< Edit > > OEditControl_Base;
+ class OEditControl : public OEditControl_Base
+ {
+ protected:
+ sal_Bool m_bIsPassword : 1;
+
+ public:
+ OEditControl( Window* _pParent, sal_Bool _bPassWord, WinBits nWinStyle );
+
+ // XPropertyControl
+ virtual ::com::sun::star::uno::Any SAL_CALL getValue() throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setValue( const ::com::sun::star::uno::Any& _value ) throw (::com::sun::star::beans::IllegalTypeException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Type SAL_CALL getValueType() throw (::com::sun::star::uno::RuntimeException);
+
+ protected:
+ virtual void modified();
+ };
+
+ //========================================================================
+ //= ODateTimeControl
+ //========================================================================
+ typedef CommonBehaviourControl< ::com::sun::star::inspection::XPropertyControl, ControlWindow< FormattedField > > ODateTimeControl_Base;
+ class ODateTimeControl : public ODateTimeControl_Base
+ {
+ public:
+ ODateTimeControl( Window* pParent,WinBits nWinStyle );
+
+ // XPropertyControl
+ virtual ::com::sun::star::uno::Any SAL_CALL getValue() throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setValue( const ::com::sun::star::uno::Any& _value ) throw (::com::sun::star::beans::IllegalTypeException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Type SAL_CALL getValueType() throw (::com::sun::star::uno::RuntimeException);
+ };
+
+ //========================================================================
+ //= HyperlinkInput
+ //========================================================================
+ class HyperlinkInput : public Edit
+ {
+ private:
+ Point m_aMouseButtonDownPos;
+ Link m_aClickHandler;
+
+ public:
+ HyperlinkInput( Window* _pParent, WinBits _nWinStyle );
+
+ /** sets the handler which will (asynchronously, with locked SolarMutex) be called
+ when the hyperlink has been clicked by the user
+ */
+ void SetClickHdl( const Link& _rHdl ) { m_aClickHandler = _rHdl; }
+ const Link& GetClickHdl( ) const { return m_aClickHandler; }
+
+ protected:
+ virtual void MouseMove( const MouseEvent& rMEvt );
+ virtual void MouseButtonDown( const MouseEvent& rMEvt );
+ virtual void MouseButtonUp( const MouseEvent& rMEvt );
+ virtual void Tracking( const TrackingEvent& rTEvt );
+
+ private:
+ void impl_checkEndClick( const MouseEvent rMEvt );
+ bool impl_textHitTest( const Point& _rWindowPos );
+ };
+
+ //========================================================================
+ //= OHyperlinkControl
+ //========================================================================
+ typedef CommonBehaviourControl< ::com::sun::star::inspection::XHyperlinkControl, ControlWindow< HyperlinkInput > > OHyperlinkControl_Base;
+ class OHyperlinkControl : public OHyperlinkControl_Base
+ {
+ private:
+ ::cppu::OInterfaceContainerHelper m_aActionListeners;
+
+ public:
+ OHyperlinkControl( Window* _pParent, WinBits _nWinStyle );
+
+ // XPropertyControl
+ virtual ::com::sun::star::uno::Any SAL_CALL getValue() throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setValue( const ::com::sun::star::uno::Any& _value ) throw (::com::sun::star::beans::IllegalTypeException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Type SAL_CALL getValueType() throw (::com::sun::star::uno::RuntimeException);
+
+ // XHyperlinkControl
+ virtual void SAL_CALL addActionListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XActionListener >& listener ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL removeActionListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XActionListener >& listener ) throw (::com::sun::star::uno::RuntimeException);
+
+ protected:
+ // XComponent
+ virtual void SAL_CALL disposing();
+
+ protected:
+ DECL_LINK( OnHyperlinkClicked, void* );
+ };
+
+ //========================================================================
+ //= CustomConvertibleNumericField
+ //========================================================================
+ class CustomConvertibleNumericField : public ControlWindow< MetricField >
+ {
+ typedef ControlWindow< MetricField > BaseClass;
+
+ public:
+ CustomConvertibleNumericField( Window* _pParent, WinBits _nStyle )
+ :BaseClass( _pParent, _nStyle )
+ {
+ }
+
+ sal_Int64 GetLastValue() const { return mnLastValue; }
+ };
+
+ //========================================================================
+ //= ONumericControl
+ //========================================================================
+ typedef CommonBehaviourControl< ::com::sun::star::inspection::XNumericControl, CustomConvertibleNumericField > ONumericControl_Base;
+ class ONumericControl : public ONumericControl_Base
+ {
+ private:
+ FieldUnit m_eValueUnit;
+ sal_Int16 m_nFieldToUNOValueFactor;
+
+ public:
+ ONumericControl( Window* pParent, WinBits nWinStyle );
+
+ // XPropertyControl
+ virtual ::com::sun::star::uno::Any SAL_CALL getValue() throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setValue( const ::com::sun::star::uno::Any& _value ) throw (::com::sun::star::beans::IllegalTypeException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Type SAL_CALL getValueType() throw (::com::sun::star::uno::RuntimeException);
+
+ // XNumericControl
+ virtual ::sal_Int16 SAL_CALL getDecimalDigits() throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setDecimalDigits( ::sal_Int16 _decimaldigits ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::beans::Optional< double > SAL_CALL getMinValue() throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setMinValue( const ::com::sun::star::beans::Optional< double >& _minvalue ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::beans::Optional< double > SAL_CALL getMaxValue() throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setMaxValue( const ::com::sun::star::beans::Optional< double >& _maxvalue ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::sal_Int16 SAL_CALL getDisplayUnit() throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setDisplayUnit( ::sal_Int16 _displayunit ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
+ virtual ::sal_Int16 SAL_CALL getValueUnit() throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setValueUnit( ::sal_Int16 _valueunit ) throw (::com::sun::star::uno::RuntimeException);
+
+ private:
+ /** converts an API value (<code>double</code>, as passed into <code>set[Max|Min|]Value) into
+ a <code>long</code> value which can be passed to our NumericField.
+
+ The conversion respects our decimal digits as well as our value factor (<member>m_nFieldToUNOValueFactor</member>).
+ */
+ long impl_apiValueToFieldValue_nothrow( double _nApiValue ) const;
+
+ /** converts a control value, as obtained from our Numeric field, into a value which can passed
+ to outer callers via our UNO API.
+ */
+ double impl_fieldValueToApiValue_nothrow( sal_Int64 _nFieldValue ) const;
+ };
+
+ //========================================================================
+ //= OColorControl
+ //========================================================================
+ typedef CommonBehaviourControl < ::com::sun::star::inspection::XStringListControl
+ , ListLikeControlWithModifyHandler< ColorListBox >
+ > OColorControl_Base;
+ class OColorControl : public OColorControl_Base
+ {
+ private:
+ ::std::set< ::rtl::OUString > m_aNonColorEntries;
+
+ public:
+ OColorControl( Window* pParent, WinBits nWinStyle );
+
+ // XPropertyControl
+ virtual ::com::sun::star::uno::Any SAL_CALL getValue() throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setValue( const ::com::sun::star::uno::Any& _value ) throw (::com::sun::star::beans::IllegalTypeException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Type SAL_CALL getValueType() throw (::com::sun::star::uno::RuntimeException);
+
+ // XStringListControl
+ virtual void SAL_CALL clearList( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL prependListEntry( const ::rtl::OUString& NewEntry ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL appendListEntry( const ::rtl::OUString& NewEntry ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getListEntries( ) throw (::com::sun::star::uno::RuntimeException);
+
+ protected:
+ virtual void modified();
+ };
+
+ //========================================================================
+ //= OListboxControl
+ //========================================================================
+ typedef CommonBehaviourControl < ::com::sun::star::inspection::XStringListControl
+ , ListLikeControlWithModifyHandler< ListBox >
+ > OListboxControl_Base;
+ class OListboxControl : public OListboxControl_Base
+ {
+ public:
+ OListboxControl( Window* pParent, WinBits nWinStyle );
+
+ // XPropertyControl
+ virtual ::com::sun::star::uno::Any SAL_CALL getValue() throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setValue( const ::com::sun::star::uno::Any& _value ) throw (::com::sun::star::beans::IllegalTypeException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Type SAL_CALL getValueType() throw (::com::sun::star::uno::RuntimeException);
+
+ // XStringListControl
+ virtual void SAL_CALL clearList( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL prependListEntry( const ::rtl::OUString& NewEntry ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL appendListEntry( const ::rtl::OUString& NewEntry ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getListEntries( ) throw (::com::sun::star::uno::RuntimeException);
+
+ protected:
+ virtual void modified();
+ };
+
+ //========================================================================
+ //= OComboboxControl
+ //========================================================================
+ typedef CommonBehaviourControl< ::com::sun::star::inspection::XStringListControl, ControlWindow< ComboBox > > OComboboxControl_Base;
+ class OComboboxControl : public OComboboxControl_Base
+ {
+ public:
+ OComboboxControl( Window* pParent, WinBits nWinStyle );
+
+ // XPropertyControl
+ virtual ::com::sun::star::uno::Any SAL_CALL getValue() throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setValue( const ::com::sun::star::uno::Any& _value ) throw (::com::sun::star::beans::IllegalTypeException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Type SAL_CALL getValueType() throw (::com::sun::star::uno::RuntimeException);
+
+ // XStringListControl
+ virtual void SAL_CALL clearList( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL prependListEntry( const ::rtl::OUString& NewEntry ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL appendListEntry( const ::rtl::OUString& NewEntry ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getListEntries( ) throw (::com::sun::star::uno::RuntimeException);
+
+ protected:
+ DECL_LINK( OnEntrySelected, void* );
+ };
+
+ //========================================================================
+ //= DropDownEditControl
+ //========================================================================
+ enum MultiLineOperationMode
+ {
+ eStringList,
+ eMultiLineText
+ };
+ //========================================================================
+ //= DropDownEditControl
+ //========================================================================
+ class OMultilineFloatingEdit;
+ typedef ControlWindow< Edit > DropDownEditControl_Base;
+ /** an Edit field which can be used as ControlWindow, and has a drop-down button
+ */
+ class DropDownEditControl : public DropDownEditControl_Base
+ {
+ private:
+ OMultilineFloatingEdit* m_pFloatingEdit;
+ MultiLineEdit* m_pImplEdit;
+ PushButton* m_pDropdownButton;
+ MultiLineOperationMode m_nOperationMode;
+ sal_Bool m_bDropdown : 1;
+
+ public:
+ DropDownEditControl( Window* _pParent, WinBits _nStyle );
+ ~DropDownEditControl();
+
+ void setOperationMode( MultiLineOperationMode _eMode ) { m_nOperationMode = _eMode; }
+ MultiLineOperationMode getOperationMode() const { return m_nOperationMode; }
+
+ void SetTextValue( const ::rtl::OUString& _rText );
+ ::rtl::OUString GetTextValue() const;
+
+ void SetStringListValue( const StlSyntaxSequence< ::rtl::OUString >& _rStrings );
+ StlSyntaxSequence< ::rtl::OUString >
+ GetStringListValue() const;
+
+ // ControlWindow overridables
+ virtual void setControlHelper( ControlHelper& _rControlHelper );
+
+ protected:
+ // Window overridables
+ virtual long PreNotify( NotifyEvent& rNEvt );
+ virtual void Resize();
+
+ protected:
+ long FindPos(long nSinglePos);
+
+ private:
+ DECL_LINK( ReturnHdl, OMultilineFloatingEdit* );
+ DECL_LINK( DropDownHdl, PushButton* );
+
+ sal_Bool ShowDropDown( sal_Bool bShow );
+ };
+
+ //========================================================================
+ //= OMultilineEditControl
+ //========================================================================
+ typedef CommonBehaviourControl< ::com::sun::star::inspection::XPropertyControl, DropDownEditControl > OMultilineEditControl_Base;
+ class OMultilineEditControl : public OMultilineEditControl_Base
+ {
+ public:
+ OMultilineEditControl( Window* pParent, MultiLineOperationMode _eMode, WinBits nWinStyle );
+
+ // XPropertyControl
+ virtual ::com::sun::star::uno::Any SAL_CALL getValue() throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setValue( const ::com::sun::star::uno::Any& _value ) throw (::com::sun::star::beans::IllegalTypeException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Type SAL_CALL getValueType() throw (::com::sun::star::uno::RuntimeException);
+ };
+
+//............................................................................
+} // namespace pcr
+//............................................................................
+
+#endif // _EXTENSIONS_PROPCTRLR_STANDARDCONTROL_HXX_
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/propctrlr/stlops.hxx b/extensions/source/propctrlr/stlops.hxx
new file mode 100644
index 000000000000..b0249ec57821
--- /dev/null
+++ b/extensions/source/propctrlr/stlops.hxx
@@ -0,0 +1,72 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _EXTENSIONS_PROPCTRLR_STLOPS_HXX_
+#define _EXTENSIONS_PROPCTRLR_STLOPS_HXX_
+
+#include <comphelper/stl_types.hxx>
+#include <com/sun/star/beans/Property.hpp>
+
+//............................................................................
+namespace pcr
+{
+//............................................................................
+
+ //========================================================================
+ struct PropertyLessByName
+ :public ::std::binary_function < ::com::sun::star::beans::Property,
+ ::com::sun::star::beans::Property,
+ bool
+ >
+ {
+ bool operator() (::com::sun::star::beans::Property _rLhs, ::com::sun::star::beans::Property _rRhs) const
+ {
+ return _rLhs.Name < _rRhs.Name ? true : false;
+ }
+ };
+
+ //========================================================================
+ struct TypeLessByName
+ :public ::std::binary_function < ::com::sun::star::uno::Type,
+ ::com::sun::star::uno::Type,
+ bool
+ >
+ {
+ bool operator() (::com::sun::star::uno::Type _rLhs, ::com::sun::star::uno::Type _rRhs) const
+ {
+ return _rLhs.getTypeName() < _rRhs.getTypeName() ? true : false;
+ }
+ };
+
+//............................................................................
+} // namespace pcr
+//............................................................................
+
+#endif // _EXTENSIONS_PROPCTRLR_STLOPS_HXX_
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/propctrlr/stringdefine.hxx b/extensions/source/propctrlr/stringdefine.hxx
new file mode 100644
index 000000000000..b7101590dd8b
--- /dev/null
+++ b/extensions/source/propctrlr/stringdefine.hxx
@@ -0,0 +1,101 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _EXTENSIONS_FORMSCTRLR_STRINGDEFINE_HXX_
+#define _EXTENSIONS_FORMSCTRLR_STRINGDEFINE_HXX_
+
+#include <rtl/ustring.hxx>
+#include <tools/string.hxx>
+
+//............................................................................
+namespace pcr
+{
+//............................................................................
+
+ //============================================================
+ //= a helper for static ascii pseudo-unicode strings
+ //============================================================
+ struct ConstAsciiString
+ {
+ const sal_Char* ascii;
+ sal_Int32 length;
+
+ inline operator const ::rtl::OUString& () const;
+ inline operator const sal_Char* () const { return ascii; }
+
+ inline ConstAsciiString(const sal_Char* _pAsciiZeroTerminated, const sal_Int32 _nLength);
+ inline ~ConstAsciiString();
+
+ private:
+ mutable ::rtl::OUString* ustring;
+ };
+
+ //------------------------------------------------------------
+ inline ConstAsciiString::ConstAsciiString(const sal_Char* _pAsciiZeroTerminated, const sal_Int32 _nLength)
+ :ascii(_pAsciiZeroTerminated)
+ ,length(_nLength)
+ ,ustring(NULL)
+ {
+ }
+
+ //------------------------------------------------------------
+ inline ConstAsciiString::~ConstAsciiString()
+ {
+ delete ustring;
+ ustring = NULL;
+ }
+
+ //------------------------------------------------------------
+ inline ConstAsciiString::operator const ::rtl::OUString& () const
+ {
+ if (!ustring)
+ ustring = new ::rtl::OUString(ascii, length, RTL_TEXTENCODING_ASCII_US);
+ return *ustring;
+ }
+
+ //============================================================
+
+#define CONST_ASCII_LENGTH(c) \
+ (const sal_Char*)c, c.length()
+
+ //============================================================
+ //= concrete strings
+ //============================================================
+ #ifndef PCR_IMPLEMENT_STRINGS
+ #define PCR_CONSTASCII_STRING(ident, string) extern const ConstAsciiString ident
+ #else
+ #define PCR_CONSTASCII_STRING(ident, string) extern const ConstAsciiString ident(string, sizeof(string)-1)
+ #endif
+
+//............................................................................
+} // namespace pcr
+//............................................................................
+
+#endif // _EXTENSIONS_FORMSCTRLR_STRINGDEFINE_HXX_
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/propctrlr/stringrepresentation.cxx b/extensions/source/propctrlr/stringrepresentation.cxx
new file mode 100644
index 000000000000..92133ebba8ca
--- /dev/null
+++ b/extensions/source/propctrlr/stringrepresentation.cxx
@@ -0,0 +1,646 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+
+#include "sal/config.h"
+#include "cppuhelper/factory.hxx"
+#include "cppuhelper/implementationentry.hxx"
+#include "cppuhelper/implbase3.hxx"
+#include "com/sun/star/lang/XServiceInfo.hpp"
+#include "com/sun/star/inspection/XStringRepresentation.hpp"
+#include "com/sun/star/lang/XInitialization.hpp"
+#include "com/sun/star/script/XTypeConverter.hpp"
+#include <com/sun/star/container/XHierarchicalNameAccess.hpp>
+#include <com/sun/star/reflection/XConstantsTypeDescription.hpp>
+#include <com/sun/star/beans/XIntrospection.hpp>
+#include <com/sun/star/util/DateTime.hpp>
+#include <com/sun/star/util/Date.hpp>
+#include <com/sun/star/util/Time.hpp>
+#include <comphelper/sequence.hxx>
+#include <connectivity/dbconversion.hxx>
+#include "modulepcr.hxx"
+#include "formresid.hrc"
+#include <tools/debug.hxx>
+#include <tools/string.hxx>
+#include <tools/StringListResource.hxx>
+#include <comphelper/types.hxx>
+#include "modulepcr.hxx"
+
+#include <functional>
+#include <algorithm>
+
+// component helper namespace
+namespace comp_StringRepresentation {
+
+using namespace ::com::sun::star;
+
+// component and service helper functions:
+::rtl::OUString SAL_CALL _getImplementationName();
+uno::Sequence< ::rtl::OUString > SAL_CALL _getSupportedServiceNames();
+uno::Reference< uno::XInterface > SAL_CALL _create( uno::Reference< uno::XComponentContext > const & context );
+
+} // closing component helper namespace
+
+
+namespace pcr{
+
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+
+class StringRepresentation:
+ public ::cppu::WeakImplHelper3<
+ lang::XServiceInfo,
+ inspection::XStringRepresentation,
+ lang::XInitialization>
+{
+public:
+ explicit StringRepresentation(uno::Reference< uno::XComponentContext > const & context);
+
+ // lang::XServiceInfo:
+ virtual ::rtl::OUString SAL_CALL getImplementationName() throw (uno::RuntimeException);
+ virtual ::sal_Bool SAL_CALL supportsService(const ::rtl::OUString & ServiceName) throw (uno::RuntimeException);
+ virtual uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() throw (uno::RuntimeException);
+
+ // inspection::XStringRepresentation:
+ virtual ::rtl::OUString SAL_CALL convertToControlValue(const uno::Any & PropertyValue) throw (uno::RuntimeException, uno::Exception);
+ virtual uno::Any SAL_CALL convertToPropertyValue(const ::rtl::OUString & ControlValue, const uno::Type & ControlValueType) throw (uno::RuntimeException, uno::Exception);
+
+ // lang::XInitialization:
+ virtual void SAL_CALL initialize(const uno::Sequence< uno::Any > & aArguments) throw (uno::RuntimeException, uno::Exception);
+
+private:
+ StringRepresentation(StringRepresentation &); // not defined
+ void operator =(StringRepresentation &); // not defined
+
+ virtual ~StringRepresentation() {}
+
+ /** converts a generic value into a string representation
+
+ If you want to convert values whose string representation does not depend
+ on a concrete property, use this version
+
+ @return <TRUE/>
+ if and only if the value could be converted
+ */
+ bool convertGenericValueToString(
+ const uno::Any& _rValue,
+ ::rtl::OUString& _rStringRep
+ );
+
+ /** converts string representation into generic value
+
+ If you want to convert values whose string representation does not depend
+ on a concrete property, use this version
+
+ @return <TRUE/>
+ if and only if the value could be converted
+ */
+ bool convertStringToGenericValue(
+ const ::rtl::OUString& _rStringRep,
+ uno::Any& _rValue,
+ const uno::Type& _rTargetType
+ );
+
+ /** uses the simple convert method from the type converter
+ *
+ * \param _rValue the value to be converted
+ * \return the converted string.
+ */
+ ::rtl::OUString convertSimpleToString( const uno::Any& _rValue );
+
+ /** converts a string into his constant value if it exists, otherwise the type converter is used.
+ * \param _rValue the value to be converted
+ * \param _ePropertyType teh type of the propery to be converted into
+ * \return the converted value
+ */
+ uno::Any convertStringToSimple( const ::rtl::OUString& _rValue,const uno::TypeClass& _ePropertyType );
+
+ uno::Reference< uno::XComponentContext > m_xContext;
+ uno::Reference< script::XTypeConverter > m_xTypeConverter;
+ uno::Reference< reflection::XConstantsTypeDescription > m_xTypeDescription;
+ uno::Sequence< ::rtl::OUString > m_aValues;
+ uno::Sequence< uno::Reference< reflection::XConstantTypeDescription> > m_aConstants;
+
+};
+
+StringRepresentation::StringRepresentation(uno::Reference< uno::XComponentContext > const & context) :
+ m_xContext(context)
+{}
+
+// com.sun.star.uno.XServiceInfo:
+::rtl::OUString SAL_CALL StringRepresentation::getImplementationName() throw (uno::RuntimeException)
+{
+ return comp_StringRepresentation::_getImplementationName();
+}
+
+::sal_Bool SAL_CALL StringRepresentation::supportsService(::rtl::OUString const & serviceName) throw (uno::RuntimeException)
+{
+ return ::comphelper::existsValue(serviceName,comp_StringRepresentation::_getSupportedServiceNames());
+}
+
+uno::Sequence< ::rtl::OUString > SAL_CALL StringRepresentation::getSupportedServiceNames() throw (uno::RuntimeException)
+{
+ return comp_StringRepresentation::_getSupportedServiceNames();
+}
+
+// inspection::XStringRepresentation:
+::rtl::OUString SAL_CALL StringRepresentation::convertToControlValue(const uno::Any & PropertyValue) throw (uno::RuntimeException, uno::Exception)
+{
+ ::rtl::OUString sReturn;
+ if ( !convertGenericValueToString( PropertyValue, sReturn ) )
+ {
+ sReturn = convertSimpleToString( PropertyValue );
+#ifdef DBG_UTIL
+ if ( !sReturn.getLength() && PropertyValue.hasValue() )
+ {
+ ::rtl::OString sMessage( "StringRepresentation::convertPropertyValueToStringRepresentation: cannot convert values of type '" );
+ sMessage += ::rtl::OString( PropertyValue.getValueType().getTypeName().getStr(), PropertyValue.getValueType().getTypeName().getLength(), RTL_TEXTENCODING_ASCII_US );
+ sMessage += ::rtl::OString( "'!" );
+ DBG_ERROR( sMessage.getStr() );
+ }
+#endif
+ }
+
+ return sReturn;
+}
+
+uno::Any SAL_CALL StringRepresentation::convertToPropertyValue(const ::rtl::OUString & ControlValue, const uno::Type & ControlValueType) throw (uno::RuntimeException, uno::Exception)
+{
+ uno::Any aReturn;
+
+ uno::TypeClass ePropertyType = ControlValueType.getTypeClass();
+ switch ( ePropertyType )
+ {
+ case uno::TypeClass_FLOAT:
+ case uno::TypeClass_DOUBLE:
+ case uno::TypeClass_BYTE:
+ case uno::TypeClass_SHORT:
+ case uno::TypeClass_LONG:
+ case uno::TypeClass_HYPER:
+ case uno::TypeClass_UNSIGNED_SHORT:
+ case uno::TypeClass_UNSIGNED_LONG:
+ case uno::TypeClass_UNSIGNED_HYPER:
+ try
+ {
+ aReturn = convertStringToSimple(ControlValue, ePropertyType);
+ }
+ catch( const script::CannotConvertException& ) { }
+ catch( const lang::IllegalArgumentException& ) { }
+ break;
+
+ default:
+ #if OSL_DEBUG_LEVEL > 0
+ bool bCanConvert =
+ #endif
+ convertStringToGenericValue( ControlValue, aReturn, ControlValueType );
+
+ #if OSL_DEBUG_LEVEL > 0
+ // could not convert ...
+ if ( !bCanConvert && ControlValue.getLength() )
+ {
+ ::rtl::OString sMessage( "StringRepresentation::convertStringRepresentationToPropertyValue: cannot convert into values of type '" );
+ sMessage += ::rtl::OString( ControlValueType.getTypeName().getStr(), ControlValueType.getTypeName().getLength(), RTL_TEXTENCODING_ASCII_US );
+ sMessage += ::rtl::OString( "'!" );
+ DBG_ERROR( sMessage.getStr() );
+ }
+ #endif
+ }
+
+ return aReturn;
+}
+
+// lang::XInitialization:
+void SAL_CALL StringRepresentation::initialize(const uno::Sequence< uno::Any > & aArguments) throw (uno::RuntimeException, uno::Exception)
+{
+ sal_Int32 nLength = aArguments.getLength();
+ if ( nLength )
+ {
+ const uno::Any* pIter = aArguments.getConstArray();
+ m_xTypeConverter.set(*pIter++,uno::UNO_QUERY);
+ if ( nLength == 3 )
+ {
+ ::rtl::OUString sConstantName;
+ *pIter++ >>= sConstantName;
+ *pIter >>= m_aValues;
+
+ if ( m_xContext.is() )
+ {
+ uno::Reference< container::XHierarchicalNameAccess > xTypeDescProv(
+ m_xContext->getValueByName( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "/singletons/com.sun.star.reflection.theTypeDescriptionManager" ) ) ),
+ uno::UNO_QUERY_THROW );
+
+ m_xTypeDescription.set( xTypeDescProv->getByHierarchicalName( sConstantName ), uno::UNO_QUERY_THROW );
+ m_aConstants = m_xTypeDescription->getConstants();
+ }
+ }
+ }
+}
+//------------------------------------------------------------------------
+::rtl::OUString StringRepresentation::convertSimpleToString( const uno::Any& _rValue )
+{
+ ::rtl::OUString sReturn;
+ if ( m_xTypeConverter.is() && _rValue.hasValue() )
+ {
+ try
+ {
+ if ( m_aConstants.getLength() )
+ {
+ sal_Int16 nConstantValue = 0;
+ if ( _rValue >>= nConstantValue )
+ {
+ const uno::Reference< reflection::XConstantTypeDescription>* pIter = m_aConstants.getConstArray();
+ const uno::Reference< reflection::XConstantTypeDescription>* pEnd = pIter + m_aConstants.getLength();
+ for(sal_Int32 i = 0;pIter != pEnd;++pIter,++i)
+ {
+ if ( (*pIter)->getConstantValue() == _rValue )
+ {
+ OSL_ENSURE(i < m_aValues.getLength() ,"StringRepresentation::convertSimpleToString: Index is not in range of m_aValues");
+ sReturn = m_aValues[i];
+ break;
+ }
+ }
+ }
+ }
+
+ if ( !sReturn.getLength() )
+ m_xTypeConverter->convertToSimpleType( _rValue, uno::TypeClass_STRING ) >>= sReturn;
+ }
+ catch( script::CannotConvertException& ) { }
+ catch( lang::IllegalArgumentException& ) { }
+ }
+ return sReturn;
+}
+
+//--------------------------------------------------------------------
+namespace
+{
+ struct ConvertIntegerFromAndToString
+ {
+ ::rtl::OUString operator()( sal_Int32 _rIntValue ) const
+ {
+ return ::rtl::OUString::valueOf( (sal_Int32)_rIntValue );
+ }
+ sal_Int32 operator()( const ::rtl::OUString& _rStringValue ) const
+ {
+ return _rStringValue.toInt32();
+ }
+ };
+
+ struct StringIdentity
+ {
+ ::rtl::OUString operator()( const ::rtl::OUString& _rValue ) const
+ {
+ return _rValue;
+ }
+ };
+
+ template < class ElementType, class Transformer >
+ ::rtl::OUString composeSequenceElements( const Sequence< ElementType >& _rElements, const Transformer& _rTransformer )
+ {
+ String sCompose;
+
+ // loop through the elements and concatenate the string representations of the integers
+ // (separated by a line break)
+ const ElementType* pElements = _rElements.getConstArray();
+ const ElementType* pElementsEnd = pElements + _rElements.getLength();
+ for ( ; pElements != pElementsEnd; ++pElements )
+ {
+ sCompose += String( _rTransformer( *pElements ) );
+ if ( pElements != pElementsEnd )
+ sCompose += '\n';
+ }
+
+ return sCompose;
+ }
+
+ template < class ElementType, class Transformer >
+ void splitComposedStringToSequence( const ::rtl::OUString& _rComposed, Sequence< ElementType >& _out_SplitUp, const Transformer& _rTransformer )
+ {
+ _out_SplitUp.realloc( 0 );
+ if ( !_rComposed.getLength() )
+ return;
+ sal_Int32 tokenPos = 0;
+ do
+ {
+ _out_SplitUp.realloc( _out_SplitUp.getLength() + 1 );
+ _out_SplitUp[ _out_SplitUp.getLength() - 1 ] = (ElementType)_rTransformer( _rComposed.getToken( 0, '\n', tokenPos ) );
+ }
+ while ( tokenPos != -1 );
+ }
+}
+
+//--------------------------------------------------------------------
+bool StringRepresentation::convertGenericValueToString( const uno::Any& _rValue, ::rtl::OUString& _rStringRep )
+{
+ bool bCanConvert = true;
+
+ switch ( _rValue.getValueTypeClass() )
+ {
+ case uno::TypeClass_STRING:
+ _rValue >>= _rStringRep;
+ break;
+
+ case uno::TypeClass_BOOLEAN:
+ {
+ ::std::vector< ::rtl::OUString > aListEntries;
+ tools::StringListResource aRes(PcrRes(RID_RSC_ENUM_YESNO),aListEntries);
+ sal_Bool bValue = sal_False;
+ _rValue >>= bValue;
+ _rStringRep = bValue ? aListEntries[1] : aListEntries[0];
+ }
+ break;
+
+ // some sequence types
+ case uno::TypeClass_SEQUENCE:
+ {
+ Sequence< ::rtl::OUString > aStringValues;
+ Sequence< sal_Int8 > aInt8Values;
+ Sequence< sal_uInt16 > aUInt16Values;
+ Sequence< sal_Int16 > aInt16Values;
+ Sequence< sal_uInt32 > aUInt32Values;
+ Sequence< sal_Int32 > aInt32Values;
+
+ // string sequences
+ if ( _rValue >>= aStringValues )
+ {
+ _rStringRep = composeSequenceElements( aStringValues, StringIdentity() );
+ }
+ // byte sequences
+ else if ( _rValue >>= aInt8Values )
+ {
+ _rStringRep = composeSequenceElements( aInt8Values, ConvertIntegerFromAndToString() );
+ }
+ // uInt16 sequences
+ else if ( _rValue >>= aUInt16Values )
+ {
+ _rStringRep = composeSequenceElements( aUInt16Values, ConvertIntegerFromAndToString() );
+ }
+ // Int16 sequences
+ else if ( _rValue >>= aInt16Values )
+ {
+ _rStringRep = composeSequenceElements( aInt16Values, ConvertIntegerFromAndToString() );
+ }
+ // uInt32 sequences
+ else if ( _rValue >>= aUInt32Values )
+ {
+ _rStringRep = composeSequenceElements( aUInt32Values, ConvertIntegerFromAndToString() );
+ }
+ // Int32 sequences
+ else if ( _rValue >>= aInt32Values )
+ {
+ _rStringRep = composeSequenceElements( aInt32Values, ConvertIntegerFromAndToString() );
+ }
+ else
+ bCanConvert = false;
+ }
+ break;
+ case uno::TypeClass_CONSTANT:
+ {
+ int i = 0;
+ ++i;
+ }
+ break;
+
+ // some structs
+ case uno::TypeClass_STRUCT:
+ OSL_ENSURE( false, "StringRepresentation::convertGenericValueToString(STRUCT): this is dead code - isn't it?" );
+ if ( _rValue.getValueType().equals( ::getCppuType( static_cast< util::Date* >( NULL ) ) ) )
+ {
+ // weird enough, the string representation of dates, as used
+ // by the control displaying dates, and thus as passed through the layers,
+ // is YYYYMMDD.
+ util::Date aUnoDate;
+ _rValue >>= aUnoDate;
+ _rStringRep = ::dbtools::DBTypeConversion::toDateString(aUnoDate);
+ }
+ else if ( _rValue.getValueType().equals( ::getCppuType( static_cast< util::Time* >( NULL ) ) ) )
+ {
+ // similar for time (HHMMSSHH)
+ util::Time aUnoTime;
+ _rValue >>= aUnoTime;
+ _rStringRep = ::dbtools::DBTypeConversion::toTimeString(aUnoTime);
+ }
+ else if ( _rValue.getValueType().equals( ::getCppuType( static_cast< util::DateTime* >( NULL ) ) ) )
+ {
+ util::DateTime aUnoDateTime;
+ _rValue >>= aUnoDateTime;
+ _rStringRep = ::dbtools::DBTypeConversion::toDateTimeString(aUnoDateTime);
+ }
+ else
+ bCanConvert = false;
+ break;
+
+ default:
+ bCanConvert = false;
+ break;
+ }
+
+ return bCanConvert;
+}
+//------------------------------------------------------------------------
+uno::Any StringRepresentation::convertStringToSimple( const ::rtl::OUString& _rValue,const uno::TypeClass& _ePropertyType )
+{
+ uno::Any aReturn;
+ if ( m_xTypeConverter.is() && _rValue.getLength() )
+ {
+ try
+ {
+ if ( m_aConstants.getLength() && m_aValues.getLength() )
+ {
+ const ::rtl::OUString* pIter = m_aValues.getConstArray();
+ const ::rtl::OUString* pEnd = pIter + m_aValues.getLength();
+ for(sal_Int32 i = 0;pIter != pEnd;++pIter,++i)
+ {
+ if ( *pIter == _rValue )
+ {
+ OSL_ENSURE(i < m_aConstants.getLength() ,"StringRepresentation::convertSimpleToString: Index is not in range of m_aValues");
+ aReturn <<= m_aConstants[i]->getConstantValue();
+ break;
+ }
+ }
+ }
+
+ if ( !aReturn.hasValue() )
+ aReturn = m_xTypeConverter->convertToSimpleType( makeAny( _rValue ), _ePropertyType );
+ }
+ catch( script::CannotConvertException& ) { }
+ catch( lang::IllegalArgumentException& ) { }
+ }
+ return aReturn;
+}
+//--------------------------------------------------------------------
+bool StringRepresentation::convertStringToGenericValue( const ::rtl::OUString& _rStringRep, uno::Any& _rValue, const uno::Type& _rTargetType )
+{
+ bool bCanConvert = true;
+
+ switch ( _rTargetType.getTypeClass() )
+ {
+ case uno::TypeClass_STRING:
+ _rValue <<= _rStringRep;
+ break;
+
+ case uno::TypeClass_BOOLEAN:
+ {
+ ::std::vector< ::rtl::OUString > aListEntries;
+ tools::StringListResource aRes(PcrRes(RID_RSC_ENUM_YESNO),aListEntries);
+ if ( aListEntries[0] == _rStringRep )
+ _rValue <<= (sal_Bool)sal_False;
+ else
+ _rValue <<= (sal_Bool)sal_True;
+ }
+ break;
+
+ case uno::TypeClass_SEQUENCE:
+ {
+ uno::Type aElementType = ::comphelper::getSequenceElementType( _rTargetType );
+
+ String aStr( _rStringRep );
+ switch ( aElementType.getTypeClass() )
+ {
+ case uno::TypeClass_STRING:
+ {
+ Sequence< ::rtl::OUString > aElements;
+ splitComposedStringToSequence( aStr, aElements, StringIdentity() );
+ _rValue <<= aElements;
+ }
+ break;
+ case uno::TypeClass_SHORT:
+ {
+ Sequence< sal_Int16 > aElements;
+ splitComposedStringToSequence( aStr, aElements, ConvertIntegerFromAndToString() );
+ _rValue <<= aElements;
+ }
+ break;
+ case uno::TypeClass_UNSIGNED_SHORT:
+ {
+ Sequence< sal_uInt16 > aElements;
+ splitComposedStringToSequence( aStr, aElements, ConvertIntegerFromAndToString() );
+ _rValue <<= aElements;
+ }
+ break;
+ case uno::TypeClass_LONG:
+ {
+ Sequence< sal_Int32 > aElements;
+ splitComposedStringToSequence( aStr, aElements, ConvertIntegerFromAndToString() );
+ _rValue <<= aElements;
+ }
+ break;
+ case uno::TypeClass_UNSIGNED_LONG:
+ {
+ Sequence< sal_uInt32 > aElements;
+ splitComposedStringToSequence( aStr, aElements, ConvertIntegerFromAndToString() );
+ _rValue <<= aElements;
+ }
+ break;
+ case uno::TypeClass_BYTE:
+ {
+ Sequence< sal_Int8 > aElements;
+ splitComposedStringToSequence( aStr, aElements, ConvertIntegerFromAndToString() );
+ _rValue <<= aElements;
+ }
+ break;
+ default:
+ bCanConvert = false;
+ break;
+ }
+ }
+ break;
+
+ case uno::TypeClass_STRUCT:
+ OSL_ENSURE( false, "StringRepresentation::convertStringToGenericValue(STRUCT): this is dead code - isn't it?" );
+ if ( _rTargetType.equals( ::getCppuType( static_cast< util::Date* >( NULL ) ) ) )
+ {
+ // weird enough, the string representation of dates, as used
+ // by the control displaying dates, and thus as passed through the layers,
+ // is YYYYMMDD.
+
+ _rValue <<= ::dbtools::DBTypeConversion::toDate(_rStringRep);
+ }
+ else if ( _rTargetType.equals( ::getCppuType( static_cast< util::Time* >( NULL ) ) ) )
+ {
+ // similar for time (HHMMSSHH)
+ _rValue <<= ::dbtools::DBTypeConversion::toTime(_rStringRep);
+ }
+ else if ( _rTargetType.equals( ::getCppuType( static_cast< util::DateTime* >( NULL ) ) ) )
+ {
+ _rValue <<= ::dbtools::DBTypeConversion::toDateTime(_rStringRep);
+ }
+ else
+ bCanConvert = false;
+ break;
+
+ default:
+ bCanConvert = false;
+ break;
+ }
+
+ return bCanConvert;
+}
+//------------------------------------------------------------------------
+//------------------------------------------------------------------------
+} // pcr
+//------------------------------------------------------------------------
+
+
+// component helper namespace
+namespace comp_StringRepresentation {
+
+::rtl::OUString SAL_CALL _getImplementationName() {
+ return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
+ "StringRepresentation"));
+}
+
+uno::Sequence< ::rtl::OUString > SAL_CALL _getSupportedServiceNames()
+{
+ uno::Sequence< ::rtl::OUString > s(1);
+ s[0] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
+ "com.sun.star.inspection.StringRepresentation"));
+ return s;
+}
+
+uno::Reference< uno::XInterface > SAL_CALL _create(
+ const uno::Reference< uno::XComponentContext > & context)
+ SAL_THROW((uno::Exception))
+{
+ return static_cast< ::cppu::OWeakObject * >(new pcr::StringRepresentation(context));
+}
+
+} // closing component helper namespace
+
+//------------------------------------------------------------------------
+extern "C" void SAL_CALL createRegistryInfo_StringRepresentation()
+{
+ ::pcr::PcrModule::getInstance().registerImplementation(
+ comp_StringRepresentation::_getImplementationName(),
+ comp_StringRepresentation::_getSupportedServiceNames(),
+ comp_StringRepresentation::_create
+ );
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/propctrlr/submissionhandler.cxx b/extensions/source/propctrlr/submissionhandler.cxx
new file mode 100644
index 000000000000..fee3f2a61831
--- /dev/null
+++ b/extensions/source/propctrlr/submissionhandler.cxx
@@ -0,0 +1,450 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+#include "submissionhandler.hxx"
+#include "formmetadata.hxx"
+#include "formstrings.hxx"
+#include "handlerhelper.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/form/FormButtonType.hpp>
+#include <com/sun/star/container/XNamed.hpp>
+#include <com/sun/star/container/XIndexAccess.hpp>
+#include <com/sun/star/form/submission/XSubmissionSupplier.hpp>
+#include <com/sun/star/inspection/XObjectInspectorUI.hpp>
+/** === end UNO includes === **/
+#include <tools/debug.hxx>
+#include <rtl/ustrbuf.hxx>
+
+//------------------------------------------------------------------------
+extern "C" void SAL_CALL createRegistryInfo_SubmissionPropertyHandler()
+{
+ ::pcr::SubmissionPropertyHandler::registerImplementation();
+}
+
+//........................................................................
+namespace pcr
+{
+//........................................................................
+
+ using namespace ::comphelper;
+ using namespace ::com::sun::star;
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::lang;
+ using namespace ::com::sun::star::beans;
+ using namespace ::com::sun::star::script;
+ using namespace ::com::sun::star::form;
+ using namespace ::com::sun::star::xforms;
+ using namespace ::com::sun::star::container;
+ using namespace ::com::sun::star::inspection;
+
+ //====================================================================
+ //= SubmissionHelper
+ //====================================================================
+ //--------------------------------------------------------------------
+ SubmissionHelper::SubmissionHelper( ::osl::Mutex& _rMutex, const Reference< XPropertySet >& _rxIntrospectee, const Reference< frame::XModel >& _rxContextDocument )
+ :EFormsHelper( _rMutex, _rxIntrospectee, _rxContextDocument )
+ {
+ OSL_ENSURE( canTriggerSubmissions( _rxIntrospectee, _rxContextDocument ),
+ "SubmissionHelper::SubmissionHelper: you should not have instantiated me!" );
+ }
+
+ //--------------------------------------------------------------------
+ bool SubmissionHelper::canTriggerSubmissions( const Reference< XPropertySet >& _rxControlModel,
+ const Reference< frame::XModel >& _rxContextDocument ) SAL_THROW(())
+ {
+ if ( !EFormsHelper::isEForm( _rxContextDocument ) )
+ return false;
+
+ try
+ {
+ Reference< submission::XSubmissionSupplier > xSubmissionSupp( _rxControlModel, UNO_QUERY );
+ if ( xSubmissionSupp.is() )
+ return true;
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "SubmissionHelper::canTriggerSubmissions: caught an exception!" );
+ }
+ return false;
+ }
+
+ //====================================================================
+ //= SubmissionPropertyHandler
+ //====================================================================
+ DBG_NAME( SubmissionPropertyHandler )
+ //--------------------------------------------------------------------
+ SubmissionPropertyHandler::SubmissionPropertyHandler( const Reference< XComponentContext >& _rxContext )
+ :EditPropertyHandler_Base( _rxContext )
+ ,OPropertyChangeListener( m_aMutex )
+ ,m_pPropChangeMultiplexer( NULL )
+ {
+ DBG_CTOR( SubmissionPropertyHandler, NULL );
+ }
+
+ //--------------------------------------------------------------------
+ SubmissionPropertyHandler::~SubmissionPropertyHandler( )
+ {
+ disposeAdapter();
+ DBG_DTOR( SubmissionPropertyHandler, NULL );
+ }
+
+ //--------------------------------------------------------------------
+ ::rtl::OUString SAL_CALL SubmissionPropertyHandler::getImplementationName_static( ) throw (RuntimeException)
+ {
+ return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.extensions.SubmissionPropertyHandler" ) );
+ }
+
+ //--------------------------------------------------------------------
+ Sequence< ::rtl::OUString > SAL_CALL SubmissionPropertyHandler::getSupportedServiceNames_static( ) throw (RuntimeException)
+ {
+ Sequence< ::rtl::OUString > aSupported( 1 );
+ aSupported[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.form.inspection.SubmissionPropertyHandler" ) );
+ return aSupported;
+ }
+
+ //--------------------------------------------------------------------
+ Any SAL_CALL SubmissionPropertyHandler::getPropertyValue( const ::rtl::OUString& _rPropertyName ) throw (UnknownPropertyException, RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ PropertyId nPropId( impl_getPropertyId_throw( _rPropertyName ) );
+
+ OSL_ENSURE( m_pHelper.get(), "SubmissionPropertyHandler::getPropertyValue: inconsistency!" );
+ // if we survived impl_getPropertyId_throw, we should have a helper, since no helper implies no properties
+
+ Any aReturn;
+ try
+ {
+ switch ( nPropId )
+ {
+ case PROPERTY_ID_SUBMISSION_ID:
+ {
+ Reference< submission::XSubmissionSupplier > xSubmissionSupp( m_xComponent, UNO_QUERY );
+ OSL_ENSURE( xSubmissionSupp.is(), "SubmissionPropertyHandler::getPropertyValue: this should never happen ..." );
+ // this handler is not intended for components which are no XSubmissionSupplier
+ Reference< submission::XSubmission > xSubmission;
+ if ( xSubmissionSupp.is() )
+ xSubmission = xSubmissionSupp->getSubmission( );
+ aReturn <<= xSubmission;
+ }
+ break;
+
+ case PROPERTY_ID_XFORMS_BUTTONTYPE:
+ {
+ FormButtonType eType = FormButtonType_PUSH;
+ OSL_VERIFY( m_xComponent->getPropertyValue( PROPERTY_BUTTONTYPE ) >>= eType );
+ if ( ( eType != FormButtonType_PUSH ) && ( eType != FormButtonType_SUBMIT ) )
+ eType = FormButtonType_PUSH;
+ aReturn <<= eType;
+ }
+ break;
+
+ default:
+ DBG_ERROR( "SubmissionPropertyHandler::getPropertyValue: cannot handle this property!" );
+ break;
+ }
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "SubmissionPropertyHandler::getPropertyValue: caught an exception!" );
+ }
+
+ return aReturn;
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL SubmissionPropertyHandler::setPropertyValue( const ::rtl::OUString& _rPropertyName, const Any& _rValue ) throw (UnknownPropertyException, RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ PropertyId nPropId( impl_getPropertyId_throw( _rPropertyName ) );
+
+ OSL_ENSURE( m_pHelper.get(), "SubmissionPropertyHandler::setPropertyValue: inconsistency!" );
+ // if we survived impl_getPropertyId_throw, we should have a helper, since no helper implies no properties
+
+ try
+ {
+ switch ( nPropId )
+ {
+ case PROPERTY_ID_SUBMISSION_ID:
+ {
+ Reference< submission::XSubmission > xSubmission;
+ OSL_VERIFY( _rValue >>= xSubmission );
+
+ Reference< submission::XSubmissionSupplier > xSubmissionSupp( m_xComponent, UNO_QUERY );
+ OSL_ENSURE( xSubmissionSupp.is(), "SubmissionPropertyHandler::setPropertyValue: this should never happen ..." );
+ // this handler is not intended for components which are no XSubmissionSupplier
+ if ( xSubmissionSupp.is() )
+ {
+ xSubmissionSupp->setSubmission( xSubmission );
+ impl_setContextDocumentModified_nothrow();
+ }
+ }
+ break;
+
+ case PROPERTY_ID_XFORMS_BUTTONTYPE:
+ m_xComponent->setPropertyValue( PROPERTY_BUTTONTYPE, _rValue );
+ break;
+
+ default:
+ OSL_ENSURE( sal_False, "SubmissionPropertyHandler::setPropertyValue: cannot handle this id!" );
+ }
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "SubmissionPropertyHandler::setPropertyValue: caught an exception!" );
+ }
+ }
+
+ //--------------------------------------------------------------------
+ Sequence< ::rtl::OUString > SAL_CALL SubmissionPropertyHandler::getActuatingProperties( ) throw (RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ if ( !m_pHelper.get() )
+ return Sequence< ::rtl::OUString >();
+
+ Sequence< ::rtl::OUString > aReturn( 1 );
+ aReturn[ 0 ] = PROPERTY_XFORMS_BUTTONTYPE;
+ return aReturn;
+ }
+
+ //--------------------------------------------------------------------
+ Sequence< ::rtl::OUString > SAL_CALL SubmissionPropertyHandler::getSupersededProperties( ) throw (RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ if ( !m_pHelper.get() )
+ return Sequence< ::rtl::OUString >();
+
+ Sequence< ::rtl::OUString > aReturn( 3 );
+ aReturn[ 0 ] = PROPERTY_TARGET_URL;
+ aReturn[ 1 ] = PROPERTY_TARGET_FRAME;
+ aReturn[ 2 ] = PROPERTY_BUTTONTYPE;
+ return aReturn;
+ }
+
+ //--------------------------------------------------------------------
+ void SubmissionPropertyHandler::onNewComponent()
+ {
+ if ( m_pPropChangeMultiplexer )
+ {
+ m_pPropChangeMultiplexer->dispose();
+ m_pPropChangeMultiplexer->release();
+ m_pPropChangeMultiplexer = NULL;
+ }
+
+ EditPropertyHandler_Base::onNewComponent();
+
+ Reference< frame::XModel > xDocument( impl_getContextDocument_nothrow() );
+ DBG_ASSERT( xDocument.is(), "SubmissionPropertyHandler::onNewComponent: no document!" );
+
+ m_pHelper.reset( NULL );
+
+ if ( SubmissionHelper::canTriggerSubmissions( m_xComponent, xDocument ) )
+ {
+ m_pHelper.reset( new SubmissionHelper( m_aMutex, m_xComponent, xDocument ) );
+
+ m_pPropChangeMultiplexer = new OPropertyChangeMultiplexer( this, m_xComponent );
+ m_pPropChangeMultiplexer->acquire();
+ m_pPropChangeMultiplexer->addProperty( PROPERTY_BUTTONTYPE );
+ }
+ }
+
+ //--------------------------------------------------------------------
+ Sequence< Property > SAL_CALL SubmissionPropertyHandler::doDescribeSupportedProperties() const
+ {
+ ::std::vector< Property > aProperties;
+ if ( m_pHelper.get() )
+ {
+ implAddPropertyDescription( aProperties, PROPERTY_SUBMISSION_ID, ::getCppuType( static_cast< Reference< submission::XSubmission > * >( NULL ) ) );
+ implAddPropertyDescription( aProperties, PROPERTY_XFORMS_BUTTONTYPE, ::getCppuType( static_cast< FormButtonType* >( NULL ) ) );
+ }
+ if ( aProperties.empty() )
+ return Sequence< Property >();
+ return Sequence< Property >( &(*aProperties.begin()), aProperties.size() );
+ }
+
+ //--------------------------------------------------------------------
+ LineDescriptor SAL_CALL SubmissionPropertyHandler::describePropertyLine( const ::rtl::OUString& _rPropertyName,
+ const Reference< XPropertyControlFactory >& _rxControlFactory )
+ throw (UnknownPropertyException, NullPointerException, RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ if ( !_rxControlFactory.is() )
+ throw NullPointerException();
+ if ( !m_pHelper.get() )
+ RuntimeException();
+
+ ::std::vector< ::rtl::OUString > aListEntries;
+ PropertyId nPropId( impl_getPropertyId_throw( _rPropertyName ) );
+ switch ( nPropId )
+ {
+ case PROPERTY_ID_SUBMISSION_ID:
+ const_cast< SubmissionHelper* >( m_pHelper.get() )->getAllElementUINames( EFormsHelper::Submission, aListEntries, false );
+ break;
+
+ case PROPERTY_ID_XFORMS_BUTTONTYPE:
+ {
+ // available options are nearly the same as for the "normal" button type, but only the
+ // first two options
+ aListEntries = m_pInfoService->getPropertyEnumRepresentations( PROPERTY_ID_BUTTONTYPE );
+ aListEntries.resize( 2 );
+ }
+ break;
+
+ default:
+ OSL_ENSURE( sal_False, "SubmissionPropertyHandler::describePropertyLine: cannot handle this id!" );
+ return LineDescriptor();
+ }
+
+ LineDescriptor aDescriptor;
+ aDescriptor.Control = PropertyHandlerHelper::createListBoxControl( _rxControlFactory, aListEntries, sal_False, sal_True );
+ aDescriptor.DisplayName = m_pInfoService->getPropertyTranslation( nPropId );
+ aDescriptor.Category = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "General" ) );
+ aDescriptor.HelpURL = HelpIdUrl::getHelpURL( m_pInfoService->getPropertyHelpId( nPropId ) );
+ return aDescriptor;
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL SubmissionPropertyHandler::actuatingPropertyChanged( const ::rtl::OUString& _rActuatingPropertyName, const Any& _rNewValue, const Any& /*_rOldValue*/, const Reference< XObjectInspectorUI >& _rxInspectorUI, sal_Bool ) throw (NullPointerException, RuntimeException)
+ {
+ if ( !_rxInspectorUI.is() )
+ throw NullPointerException();
+
+ ::osl::MutexGuard aGuard( m_aMutex );
+ PropertyId nActuatingPropId( impl_getPropertyId_throw( _rActuatingPropertyName ) );
+ OSL_PRECOND( m_pHelper.get(), "SubmissionPropertyHandler::actuatingPropertyChanged: inconsistentcy!" );
+ // if we survived impl_getPropertyId_throw, we should have a helper, since no helper implies no properties
+
+ switch ( nActuatingPropId )
+ {
+ case PROPERTY_ID_XFORMS_BUTTONTYPE:
+ {
+ FormButtonType eType = FormButtonType_PUSH;
+ OSL_VERIFY( _rNewValue >>= eType );
+ _rxInspectorUI->enablePropertyUI( PROPERTY_SUBMISSION_ID, eType == FormButtonType_SUBMIT );
+ }
+ break;
+
+ default:
+ OSL_ENSURE( sal_False, "SubmissionPropertyHandler::actuatingPropertyChanged: cannot handle this id!" );
+ }
+ }
+
+ //--------------------------------------------------------------------
+ Any SAL_CALL SubmissionPropertyHandler::convertToPropertyValue( const ::rtl::OUString& _rPropertyName, const Any& _rControlValue ) throw (UnknownPropertyException, RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ Any aPropertyValue;
+
+ OSL_ENSURE( m_pHelper.get(), "SubmissionPropertyHandler::convertToPropertyValue: we have no SupportedProperties!" );
+ if ( !m_pHelper.get() )
+ return aPropertyValue;
+
+ ::rtl::OUString sControlValue;
+ OSL_VERIFY( _rControlValue >>= sControlValue );
+
+ PropertyId nPropId( m_pInfoService->getPropertyId( _rPropertyName ) );
+ switch ( nPropId )
+ {
+ case PROPERTY_ID_SUBMISSION_ID:
+ {
+ Reference< XSubmission > xSubmission( m_pHelper->getModelElementFromUIName( EFormsHelper::Submission, sControlValue ), UNO_QUERY );
+ aPropertyValue <<= xSubmission;
+ }
+ break;
+
+ case PROPERTY_ID_XFORMS_BUTTONTYPE:
+ {
+ ::rtl::Reference< IPropertyEnumRepresentation > aEnumConversion(
+ new DefaultEnumRepresentation( *m_pInfoService, ::getCppuType( static_cast< FormButtonType* >( NULL ) ), PROPERTY_ID_BUTTONTYPE ) );
+ // TODO/UNOize: make aEnumConversion a member?
+ aEnumConversion->getValueFromDescription( sControlValue, aPropertyValue );
+ }
+ break;
+
+ default:
+ OSL_ENSURE( sal_False, "SubmissionPropertyHandler::convertToPropertyValue: cannot handle this id!" );
+ }
+
+ return aPropertyValue;
+ }
+
+ //--------------------------------------------------------------------
+ Any SAL_CALL SubmissionPropertyHandler::convertToControlValue( const ::rtl::OUString& _rPropertyName, const Any& _rPropertyValue, const Type& _rControlValueType ) throw (UnknownPropertyException, RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ Any aControlValue;
+
+ OSL_ENSURE( m_pHelper.get(), "SubmissionPropertyHandler::convertToControlValue: we have no SupportedProperties!" );
+ if ( !m_pHelper.get() )
+ return aControlValue;
+
+ OSL_ENSURE( _rControlValueType.getTypeClass() == TypeClass_STRING,
+ "SubmissionPropertyHandler::convertToControlValue: all our controls should use strings for value exchange!" );
+ (void)_rControlValueType;
+
+ PropertyId nPropId( m_pInfoService->getPropertyId( _rPropertyName ) );
+ switch ( nPropId )
+ {
+ case PROPERTY_ID_SUBMISSION_ID:
+ {
+ Reference< XPropertySet > xSubmission( _rPropertyValue, UNO_QUERY );
+ if ( xSubmission.is() )
+ aControlValue <<= m_pHelper->getModelElementUIName( EFormsHelper::Submission, xSubmission );
+ }
+ break;
+
+ case PROPERTY_ID_XFORMS_BUTTONTYPE:
+ {
+ ::rtl::Reference< IPropertyEnumRepresentation > aEnumConversion(
+ new DefaultEnumRepresentation( *m_pInfoService, _rPropertyValue.getValueType(), PROPERTY_ID_BUTTONTYPE ) );
+ // TODO/UNOize: make aEnumConversion a member?
+ aControlValue <<= aEnumConversion->getDescriptionForValue( _rPropertyValue );
+ }
+ break;
+
+ default:
+ OSL_ENSURE( sal_False, "SubmissionPropertyHandler::convertToControlValue: cannot handle this id!" );
+ }
+
+ return aControlValue;
+ }
+
+ //--------------------------------------------------------------------
+ void SubmissionPropertyHandler::_propertyChanged( const PropertyChangeEvent& _rEvent ) throw(RuntimeException)
+ {
+ if ( _rEvent.PropertyName == PROPERTY_BUTTONTYPE )
+ firePropertyChange( PROPERTY_XFORMS_BUTTONTYPE, PROPERTY_ID_XFORMS_BUTTONTYPE, _rEvent.OldValue, _rEvent.NewValue );
+ }
+
+//........................................................................
+} // namespace pcr
+//........................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/propctrlr/submissionhandler.hxx b/extensions/source/propctrlr/submissionhandler.hxx
new file mode 100644
index 000000000000..1c2bd4082531
--- /dev/null
+++ b/extensions/source/propctrlr/submissionhandler.hxx
@@ -0,0 +1,127 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef EXTENSIONS_SOURCE_PROPCTRLR_SUBMISSIONHANDLER_HXX
+#define EXTENSIONS_SOURCE_PROPCTRLR_SUBMISSIONHANDLER_HXX
+
+#include "propertyhandler.hxx"
+#include "eformshelper.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/xforms/XSubmission.hpp>
+/** === end UNO includes === **/
+#include <comphelper/propmultiplex.hxx>
+
+namespace comphelper
+{
+ class OPropertyChangeMultiplexer;
+}
+
+//........................................................................
+namespace pcr
+{
+//........................................................................
+
+ //====================================================================
+ //= SubmissionHelper
+ //====================================================================
+ class SubmissionHelper : public EFormsHelper
+ {
+ public:
+ SubmissionHelper(
+ osl::Mutex& _rMutex,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxIntrospectee,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& _rxContextDocument
+ );
+
+ /** determines whether the given control model is able to trigger submissions
+
+ Instances of the <type>SubmissionHelper</type> class should not be instantiated
+ for components where this method returned <FALSE/>
+ */
+ static bool canTriggerSubmissions(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxControlModel,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& _rxContextDocument
+ ) SAL_THROW(());
+ };
+
+ //====================================================================
+ //= SubmissionPropertyHandler
+ //====================================================================
+ class SubmissionPropertyHandler;
+ typedef HandlerComponentBase< SubmissionPropertyHandler > EditPropertyHandler_Base;
+ /** a property handler for any virtual string properties
+ */
+ class SubmissionPropertyHandler : public EditPropertyHandler_Base, public ::comphelper::OPropertyChangeListener
+ {
+ private:
+ ::osl::Mutex m_aMutex;
+ ::std::auto_ptr< SubmissionHelper > m_pHelper;
+ ::comphelper::OPropertyChangeMultiplexer* m_pPropChangeMultiplexer;
+
+ public:
+ SubmissionPropertyHandler(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _rxContext
+ );
+
+ static ::rtl::OUString SAL_CALL getImplementationName_static( ) throw (::com::sun::star::uno::RuntimeException);
+ static ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames_static( ) throw (::com::sun::star::uno::RuntimeException);
+
+ ~SubmissionPropertyHandler();
+
+ protected:
+ // XPropertyHandler overriables
+ virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue( const ::rtl::OUString& _rPropertyName ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setPropertyValue( const ::rtl::OUString& _rPropertyName, const ::com::sun::star::uno::Any& _rValue ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString >
+ SAL_CALL getActuatingProperties( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString >
+ SAL_CALL getSupersededProperties( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::inspection::LineDescriptor
+ SAL_CALL describePropertyLine( const ::rtl::OUString& _rPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyControlFactory >& _rxControlFactory ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::NullPointerException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL actuatingPropertyChanged( const ::rtl::OUString& _rActuatingPropertyName, const ::com::sun::star::uno::Any& _rNewValue, const ::com::sun::star::uno::Any& _rOldValue, const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XObjectInspectorUI >& _rxInspectorUI, sal_Bool ) throw (::com::sun::star::lang::NullPointerException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Any SAL_CALL convertToPropertyValue( const ::rtl::OUString& _rPropertyName, const ::com::sun::star::uno::Any& _rControlValue ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Any SAL_CALL convertToControlValue( const ::rtl::OUString& _rPropertyName, const ::com::sun::star::uno::Any& _rPropertyValue, const ::com::sun::star::uno::Type& _rControlValueType ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
+
+ // PropertyHandler overridables
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property >
+ SAL_CALL doDescribeSupportedProperties() const;
+ virtual void onNewComponent();
+
+ private:
+ // OPropertyChangeListener
+ virtual void _propertyChanged(const ::com::sun::star::beans::PropertyChangeEvent& _rEvent) throw( ::com::sun::star::uno::RuntimeException);
+ };
+
+//........................................................................
+} // namespace pcr
+//........................................................................
+
+#endif // EXTENSIONS_SOURCE_PROPCTRLR_SUBMISSIONHANDLER_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/propctrlr/taborder.cxx b/extensions/source/propctrlr/taborder.cxx
new file mode 100644
index 000000000000..ae24730a4a7f
--- /dev/null
+++ b/extensions/source/propctrlr/taborder.cxx
@@ -0,0 +1,421 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+#include "taborder.hxx"
+#include "taborder.hrc"
+
+#include "modulepcr.hxx"
+#include "formresid.hrc"
+#include "formstrings.hxx"
+#include <comphelper/types.hxx>
+#include <comphelper/property.hxx>
+#include <cppuhelper/implbase1.hxx>
+#include <com/sun/star/form/FormComponentType.hpp>
+#include <com/sun/star/awt/XTabController.hpp>
+#include <vcl/scrbar.hxx>
+
+//............................................................................
+namespace pcr
+{
+//............................................................................
+
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::awt;
+ using namespace ::com::sun::star::lang;
+ using namespace ::com::sun::star::form;
+ using namespace ::com::sun::star::beans;
+ using namespace ::com::sun::star::datatransfer;
+
+ //========================================================================
+ //= OSimpleTabModel
+ //========================================================================
+ class OSimpleTabModel : public ::cppu::WeakImplHelper1< XTabControllerModel>
+ {
+ Sequence< Reference< XControlModel > > m_aModels;
+
+ public:
+ OSimpleTabModel( const Sequence< Reference< XControlModel > >& _rModels )
+ :m_aModels( _rModels )
+ {
+ }
+
+ // XTabControllerModel
+ virtual void SAL_CALL setControlModels(const Sequence< Reference< XControlModel > >& rModels) throw( RuntimeException ) {m_aModels = rModels;}
+ virtual Sequence< Reference< XControlModel > > SAL_CALL getControlModels(void) throw( RuntimeException ) {return m_aModels;}
+ virtual void SAL_CALL setGroup(const Sequence< Reference< XControlModel > >& /*Group*/, const ::rtl::OUString& /*GroupName*/) throw( RuntimeException ) {}
+ virtual sal_Int32 SAL_CALL getGroupCount(void) throw( RuntimeException ) {return 0;}
+ virtual void SAL_CALL getGroup(sal_Int32 /*nGroup*/, Sequence< Reference< XControlModel > >& /*Group*/, ::rtl::OUString& /*Name*/) throw( RuntimeException ) {}
+ virtual void SAL_CALL getGroupByName(const ::rtl::OUString& /*Name*/, Sequence< Reference< XControlModel > >& /*Group*/) throw( RuntimeException ) {}
+ virtual sal_Bool SAL_CALL getGroupControl(void) throw( RuntimeException ){return sal_False;} ;
+ virtual void SAL_CALL setGroupControl(sal_Bool /*GroupControl*/) throw( RuntimeException ){};
+ };
+
+ //========================================================================
+ //= TabOrderDialog
+ //========================================================================
+ DBG_NAME(TabOrderDialog)
+ //------------------------------------------------------------------------
+ TabOrderDialog::TabOrderDialog( Window* _pParent, const Reference< XTabControllerModel >& _rxTabModel,
+ const Reference< XControlContainer >& _rxControlCont, const Reference< XMultiServiceFactory >& _rxORB )
+ :ModalDialog( _pParent, PcrRes( RID_DLG_TABORDER ) )
+ ,m_xModel( _rxTabModel )
+ ,m_xControlContainer( _rxControlCont )
+ ,m_xORB( _rxORB )
+ ,aFT_Controls( this, PcrRes( FT_CONTROLS ) )
+ ,aLB_Controls( this, PcrRes( CTRL_TREE ) )
+ ,aPB_OK( this, PcrRes( PB_OK ) )
+ ,aPB_CANCEL( this, PcrRes( PB_CANCEL ) )
+ ,aPB_HELP( this, PcrRes( PB_HELP ) )
+ ,aPB_MoveUp( this, PcrRes( PB_MOVE_UP ) )
+ ,aPB_MoveDown( this, PcrRes( PB_MOVE_DOWN ) )
+ ,aPB_AutoOrder( this, PcrRes( PB_AUTO_ORDER ) )
+ ,pImageList( NULL )
+ {
+ DBG_CTOR(TabOrderDialog,NULL);
+
+ aPB_MoveUp.SetClickHdl( LINK( this, TabOrderDialog, MoveUpClickHdl ) );
+ aPB_MoveDown.SetClickHdl( LINK( this, TabOrderDialog, MoveDownClickHdl ) );
+ aPB_AutoOrder.SetClickHdl( LINK( this, TabOrderDialog, AutoOrderClickHdl ) );
+ aPB_OK.SetClickHdl( LINK( this, TabOrderDialog, OKClickHdl ) );
+ aPB_OK.Disable();
+
+ sal_Bool bIsHighContrast = GetSettings().GetStyleSettings().GetHighContrastMode();
+ pImageList = new ImageList( PcrRes( bIsHighContrast ? RID_IL_FORMEXPLORER_HC : RID_IL_FORMEXPLORER ) );
+
+
+ if ( m_xModel.is() )
+ m_xTempModel = new OSimpleTabModel( m_xModel->getControlModels() );
+
+ if ( m_xTempModel.is() && m_xControlContainer.is() )
+ FillList();
+
+ if ( aLB_Controls.GetEntryCount() < 2 )
+ {
+ aPB_MoveUp.Disable();
+ aPB_MoveDown.Disable();
+ aPB_AutoOrder.Disable();
+ }
+
+ FreeResource();
+ }
+
+ //------------------------------------------------------------------------
+ void TabOrderDialog::SetModified()
+ {
+ aPB_OK.Enable();
+ }
+
+ //------------------------------------------------------------------------
+ TabOrderDialog::~TabOrderDialog()
+ {
+ aLB_Controls.Hide();
+ // delete pLB_Controls;
+ delete pImageList;
+
+ DBG_DTOR(TabOrderDialog,NULL);
+ }
+
+ //------------------------------------------------------------------------
+ Image TabOrderDialog::GetImage( const Reference< XPropertySet >& _rxSet ) const
+ {
+ sal_uInt16 nImageId = RID_SVXIMG_CONTROL;
+ // TODO: classify controls also in Basic propbrw
+ if ( _rxSet.is() && ::comphelper::hasProperty( PROPERTY_CLASSID, _rxSet ) )
+ {
+ switch( ::comphelper::getINT16( _rxSet->getPropertyValue( PROPERTY_CLASSID ) ) )
+ {
+ case FormComponentType::COMMANDBUTTON: nImageId = RID_SVXIMG_BUTTON; break;
+ case FormComponentType::FIXEDTEXT: nImageId = RID_SVXIMG_FIXEDTEXT; break;
+ case FormComponentType::TEXTFIELD: nImageId = RID_SVXIMG_EDIT; break;
+ case FormComponentType::RADIOBUTTON: nImageId = RID_SVXIMG_RADIOBUTTON; break;
+ case FormComponentType::CHECKBOX: nImageId = RID_SVXIMG_CHECKBOX; break;
+ case FormComponentType::LISTBOX: nImageId = RID_SVXIMG_LISTBOX; break;
+ case FormComponentType::COMBOBOX: nImageId = RID_SVXIMG_COMBOBOX; break;
+ case FormComponentType::GROUPBOX: nImageId = RID_SVXIMG_GROUPBOX; break;
+ case FormComponentType::IMAGEBUTTON: nImageId = RID_SVXIMG_IMAGEBUTTON; break;
+ case FormComponentType::FILECONTROL: nImageId = RID_SVXIMG_FILECONTROL; break;
+ case FormComponentType::HIDDENCONTROL: nImageId = RID_SVXIMG_HIDDEN; break;
+ case FormComponentType::DATEFIELD: nImageId = RID_SVXIMG_DATEFIELD; break;
+ case FormComponentType::TIMEFIELD: nImageId = RID_SVXIMG_TIMEFIELD; break;
+ case FormComponentType::NUMERICFIELD: nImageId = RID_SVXIMG_NUMERICFIELD; break;
+ case FormComponentType::CURRENCYFIELD: nImageId = RID_SVXIMG_CURRENCYFIELD; break;
+ case FormComponentType::PATTERNFIELD: nImageId = RID_SVXIMG_PATTERNFIELD; break;
+ case FormComponentType::IMAGECONTROL: nImageId = RID_SVXIMG_IMAGECONTROL; break;
+ case FormComponentType::GRIDCONTROL: nImageId = RID_SVXIMG_GRID; break;
+ case FormComponentType::SCROLLBAR: nImageId = RID_SVXIMG_SCROLLBAR; break;
+ case FormComponentType::SPINBUTTON: nImageId = RID_SVXIMG_SPINBUTTON; break;
+ case FormComponentType::NAVIGATIONBAR: nImageId = RID_SVXIMG_NAVIGATIONBAR; break;
+ default:
+ DBG_ERROR( "TabOrderDialog::GetImage: unknown control type" );
+ }
+ }
+
+ return pImageList->GetImage( nImageId );
+ }
+
+ //------------------------------------------------------------------------
+ void TabOrderDialog::FillList()
+ {
+ DBG_ASSERT( m_xTempModel.is() && m_xControlContainer.is(), "TabOrderDialog::FillList: invalid call!" );
+ if ( !m_xTempModel.is() || !m_xControlContainer.is() )
+ return;
+
+ aLB_Controls.Clear();
+
+ try
+ {
+ Sequence< Reference< XControlModel > > aControlModels( m_xTempModel->getControlModels() );
+ const Reference< XControlModel >* pControlModels = aControlModels.getConstArray();
+
+ ::rtl::OUString aName;
+ Image aImage;
+
+ for ( sal_Int32 i=0; i < aControlModels.getLength(); ++i, ++pControlModels )
+ {
+ Reference< XPropertySet > xControl( *pControlModels, UNO_QUERY );
+ Reference< XPropertySetInfo > xPI;
+ if ( xControl.is() )
+ xPI = xControl->getPropertySetInfo();
+
+ if ( xPI.is() )
+ {
+ if ( xPI->hasPropertyByName( PROPERTY_TABSTOP ) )
+ {
+ aName = ::comphelper::getString( xControl->getPropertyValue( PROPERTY_NAME ) );
+ // TODO: do Basic controls have a name?
+ aImage = GetImage( xControl );
+ aLB_Controls.InsertEntry( aName, aImage, aImage, 0, sal_False, LIST_APPEND, xControl.get() );
+ }
+ }
+ else
+ {
+ // no property set -> no tab order
+ DBG_ERROR( "TabOrderDialog::FillList: invalid control encountered!" );
+ aLB_Controls.Clear();
+ break;
+ }
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_ERROR( "TabOrderDialog::FillList: caught an exception!" );
+ }
+
+ // select first entry
+ SvLBoxEntry* pFirstEntry = aLB_Controls.GetEntry( 0 );
+ if ( pFirstEntry )
+ aLB_Controls.Select( pFirstEntry );
+ }
+
+ //------------------------------------------------------------------------
+ IMPL_LINK( TabOrderDialog, MoveUpClickHdl, Button*, /*pButton*/ )
+ {
+ aLB_Controls.MoveSelection( -1 );
+ return 0;
+ }
+
+ //------------------------------------------------------------------------
+ IMPL_LINK( TabOrderDialog, MoveDownClickHdl, Button*, /*pButton*/ )
+ {
+ aLB_Controls.MoveSelection( 1 );
+ return 0;
+ }
+
+ //------------------------------------------------------------------------
+ IMPL_LINK( TabOrderDialog, AutoOrderClickHdl, Button*, /*pButton*/ )
+ {
+ try
+ {
+ Reference< XTabController > xTabController;
+ if ( m_xORB.is() )
+ xTabController = xTabController.query( m_xORB->createInstance( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.form.FormController" ) ) ) );
+ DBG_ASSERT( xTabController.is(), "TabOrderDialog::AutoOrderClickHdl: could not instantiate a tab controller!" );
+ if ( !xTabController.is() )
+ return 0;
+
+ xTabController->setModel( m_xTempModel );
+ xTabController->setContainer( m_xControlContainer );
+ xTabController->autoTabOrder();
+
+ SetModified();
+ FillList();
+
+ ::comphelper::disposeComponent( xTabController );
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "TabOrderDialog::AutoOrderClickHdl: caught an exception!" );
+ }
+
+ return 0;
+ }
+
+ //------------------------------------------------------------------------
+ IMPL_LINK( TabOrderDialog, OKClickHdl, Button*, /*pButton*/ )
+ {
+ ULONG nEntryCount = aLB_Controls.GetEntryCount();
+ Sequence< Reference< XControlModel > > aSortedControlModelSeq( nEntryCount );
+ Sequence< Reference< XControlModel > > aControlModels( m_xTempModel->getControlModels());
+ Reference< XControlModel > * pSortedControlModels = aSortedControlModelSeq.getArray();
+ const Reference< XControlModel > * pControlModels = aControlModels.getConstArray();
+
+ for (ULONG i=0; i < nEntryCount; i++)
+ {
+ SvLBoxEntry* pEntry = aLB_Controls.GetEntry(i);
+
+ for( sal_Int32 j=0; j<aControlModels.getLength(); j++ )
+ {
+ Reference< XPropertySet > xSet(pControlModels[j], UNO_QUERY);
+ if ((XPropertySet*)xSet.get() == ((XPropertySet*)pEntry->GetUserData()))
+ {
+ pSortedControlModels[i] = pControlModels[j];
+ break;
+ }
+ }
+ }
+
+ // TODO: UNO action (to bracket all the single actions which are being created)
+// pDrawModel->BegUndo(PcrRes(RID_STR_UNDO_TABORDER));
+ m_xModel->setControlModels( aSortedControlModelSeq );
+// pDrawModel->EndUndo();
+
+ EndDialog( sal_True );
+ return 0;
+ }
+
+ //========================================================================
+ //= TabOrderListBox
+ //========================================================================
+ DBG_NAME(TabOrderListBox);
+ //------------------------------------------------------------------------
+ TabOrderListBox::TabOrderListBox( Window* pParent, const ResId& rResId )
+ :SvTreeListBox( pParent, rResId )
+ {
+ DBG_CTOR(TabOrderListBox,NULL);
+ SetDragDropMode(0xFFFF/*SV_DRAGDROP_CTRL_MOVE*/);
+ // Hmm. The flag alone is not enough, so to be on the safe side ...
+
+ SetSelectionMode( MULTIPLE_SELECTION );
+ }
+
+ //------------------------------------------------------------------------
+ TabOrderListBox::~TabOrderListBox()
+ {
+ DBG_DTOR(TabOrderListBox,NULL);
+ }
+
+ //------------------------------------------------------------------------
+ void TabOrderListBox::ModelHasMoved( SvListEntry* _pSource )
+ {
+ SvTreeListBox::ModelHasMoved( _pSource );
+
+ ((TabOrderDialog*)Window::GetParent())->SetModified();
+ }
+
+ //------------------------------------------------------------------------
+ void TabOrderListBox::MoveSelection( long nRelPos )
+ {
+ UniString aSelEntryPrevText,aSelEntryNextText;
+ Image aImage;
+ for (long i=0; i<labs(nRelPos); i++)
+ {
+ ((TabOrderDialog*)Window::GetParent())->SetModified();
+
+ //////////////////////////////////////////////////////////////////////
+ // move entries
+ if( nRelPos < 0 )
+ {
+ SvLBoxEntry* pFirstSelected = FirstSelected();
+ if( !pFirstSelected ) return;
+ ULONG nFirstSelPos = GetModel()->GetAbsPos( pFirstSelected );
+ if( nFirstSelPos == 0 ) return;
+
+ SvLBoxEntry* pSelEntry = pFirstSelected;
+ while( pSelEntry )
+ {
+ ULONG nSelEntryPos = GetModel()->GetAbsPos( pSelEntry );
+ SvLBoxEntry* pSelEntryPrev = GetEntry( nSelEntryPos-1 );
+ aSelEntryPrevText = GetEntryText( pSelEntryPrev );
+ aImage = GetExpandedEntryBmp(pSelEntryPrev);
+ void* pData = pSelEntryPrev->GetUserData();
+
+ GetModel()->Remove( pSelEntryPrev );
+ InsertEntry( aSelEntryPrevText, aImage, aImage, 0, sal_False, nSelEntryPos, pData );
+
+ pSelEntry = NextSelected( pSelEntry );
+ }
+ }
+
+ else if( nRelPos > 0 )
+ {
+ SvLBoxEntry* pLastSelected = LastSelected();
+ if( !pLastSelected ) return;
+ ULONG nLastSelPos = GetModel()->GetAbsPos( pLastSelected );
+
+ if( (nLastSelPos + nRelPos - i) > (GetEntryCount()-1) ) return;
+
+#if OSL_DEBUG_LEVEL > 0
+ ULONG nSelCount = GetSelectionCount();
+ (void)nSelCount;
+#endif
+
+
+ SvLBoxEntry* pSelEntry = pLastSelected;
+ while( pSelEntry )
+ {
+ ULONG nSelEntryPos = GetModel()->GetAbsPos( pSelEntry );
+ SvLBoxEntry* pSelEntryNext = GetEntry( nSelEntryPos+1 );
+ void* pData = pSelEntryNext->GetUserData();
+
+ aSelEntryNextText = GetEntryText( pSelEntryNext );
+ aImage = GetExpandedEntryBmp(pSelEntryNext);
+
+ GetModel()->Remove( pSelEntryNext );
+ InsertEntry( aSelEntryNextText, aImage, aImage, 0, sal_False, nSelEntryPos, pData );
+
+ pSelEntry = PrevSelected( pSelEntry );
+ }
+ long nThumbPos = GetVScroll()->GetThumbPos();
+ long nVisibleSize = GetVScroll()->GetVisibleSize();
+ long nFirstVisible = GetModel()->GetAbsPos( FirstVisible());
+
+ if ( ( nThumbPos + nVisibleSize + 1 ) < (long)( nLastSelPos + 3 ) )
+ GetVScroll()->DoScrollAction(SCROLL_LINEDOWN);
+ else if((nThumbPos+nVisibleSize+1) >= (nFirstVisible))
+ GetVScroll()->DoScrollAction(SCROLL_LINEUP);
+ }
+ }
+ }
+
+//............................................................................
+} // namespace pcr
+//............................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/propctrlr/taborder.hrc b/extensions/source/propctrlr/taborder.hrc
new file mode 100644
index 000000000000..03be169a18eb
--- /dev/null
+++ b/extensions/source/propctrlr/taborder.hrc
@@ -0,0 +1,45 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef EXTENSIONS_SOURCE_PROPCTRLR_TABORDER_HRC
+#define EXTENSIONS_SOURCE_PROPCTRLR_TABORDER_HRC
+
+#define FT_CONTROLS 1
+
+#define LB_CONTROLS 1
+
+#define PB_MOVE_UP 1
+#define PB_MOVE_DOWN 2
+#define PB_AUTO_ORDER 3
+
+#define PB_OK 4
+#define PB_CANCEL 5
+#define PB_HELP 6
+
+#define CTRL_TREE 1
+
+#endif // EXTENSIONS_SOURCE_PROPCTRLR_TABORDER_HRC
+
diff --git a/extensions/source/propctrlr/taborder.hxx b/extensions/source/propctrlr/taborder.hxx
new file mode 100644
index 000000000000..fbe134f79a9f
--- /dev/null
+++ b/extensions/source/propctrlr/taborder.hxx
@@ -0,0 +1,127 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef EXTENSIONS_SOURCE_PROPCTRLR_TABORDER_HXX
+#define EXTENSIONS_SOURCE_PROPCTRLR_TABORDER_HXX
+
+#include <svtools/svtreebx.hxx>
+#include <com/sun/star/awt/XTabControllerModel.hpp>
+#include <com/sun/star/awt/XControlContainer.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+
+#include <vcl/dialog.hxx>
+
+#include <vcl/button.hxx>
+#include <vcl/lstbox.hxx>
+
+#include <vcl/fixed.hxx>
+
+#include <tools/list.hxx>
+#include <comphelper/uno3.hxx>
+
+//............................................................................
+namespace pcr
+{
+//............................................................................
+
+ //========================================================================
+ //= TabOrderListBox
+ //========================================================================
+ class TabOrderListBox : public SvTreeListBox
+ {
+ public:
+ TabOrderListBox( Window* pParent, const ResId& rResId );
+ virtual ~TabOrderListBox();
+
+ void MoveSelection( long nRelPos );
+
+ protected:
+ virtual void ModelHasMoved(SvListEntry* pSource );
+
+ private:
+ using SvTreeListBox::MoveSelection;
+ };
+
+
+ //========================================================================
+ //= TabOrderDialog
+ //========================================================================
+ class TabOrderDialog : public ModalDialog
+ {
+ ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTabControllerModel >
+ m_xTempModel;
+ ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTabControllerModel >
+ m_xModel;
+ ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlContainer >
+ m_xControlContainer;
+ ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >
+ m_xORB;
+
+ FixedText aFT_Controls;
+ TabOrderListBox aLB_Controls;
+
+ OKButton aPB_OK;
+ CancelButton aPB_CANCEL;
+ HelpButton aPB_HELP;
+
+ PushButton aPB_MoveUp;
+ PushButton aPB_MoveDown;
+ PushButton aPB_AutoOrder;
+
+ ImageList* pImageList;
+
+ DECL_LINK( MoveUpClickHdl, Button* );
+ DECL_LINK( MoveDownClickHdl, Button* );
+ DECL_LINK( AutoOrderClickHdl, Button* );
+ DECL_LINK( OKClickHdl, Button* );
+
+ void FillList();
+ Image GetImage(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > & _rxSet
+ ) const;
+
+ public:
+ TabOrderDialog(
+ Window* _pParent,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XTabControllerModel >& _rxTabModel,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlContainer >& _rxControlCont,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB
+ );
+
+ virtual ~TabOrderDialog();
+
+ void SetModified();
+ };
+
+//............................................................................
+} // namespace pcr
+//............................................................................
+
+#endif // EXTENSIONS_SOURCE_PROPCTRLR_TABORDER_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/propctrlr/taborder.src b/extensions/source/propctrlr/taborder.src
new file mode 100644
index 000000000000..fe55988f34af
--- /dev/null
+++ b/extensions/source/propctrlr/taborder.src
@@ -0,0 +1,103 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _EXTENSIONS_FORMCTRLR_PROPRESID_HRC_
+#include "formresid.hrc"
+#endif
+#ifndef EXTENSIONS_SOURCE_PROPCTRLR_TABORDER_HRC
+#include "taborder.hrc"
+#endif
+#include "propctrlr.hrc"
+
+ModalDialog RID_DLG_TABORDER
+{
+ OutputSize = TRUE ;
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( 168 , 158 ) ;
+ Text [ en-US ] = "Tab Order" ;
+ Moveable = TRUE ;
+ Closeable = TRUE ;
+
+ FixedText FT_CONTROLS
+ {
+ Pos = MAP_APPFONT ( 6 , 3 ) ;
+ Size = MAP_APPFONT ( 90 , 8 ) ;
+ Text [ en-US ] = "Controls" ;
+ };
+
+ Control CTRL_TREE
+ {
+ Border = TRUE;
+ Pos = MAP_APPFONT ( 6, 14) ;
+ Size = MAP_APPFONT ( 90, 136 ) ;
+ TabStop = TRUE;
+ HelpId = HID_PROP_TABORDER_CONTROLS;
+ };
+
+ PushButton PB_MOVE_UP
+ {
+ Pos = MAP_APPFONT ( 102 , 14 ) ;
+ Size = MAP_APPFONT ( 60 , 14 ) ;
+ Text [ en-US ] = "Move Up" ;
+ };
+
+ PushButton PB_MOVE_DOWN
+ {
+ Pos = MAP_APPFONT ( 102 , 32 ) ;
+ Size = MAP_APPFONT ( 60 , 14 ) ;
+ Text [ en-US ] = "Move Down" ;
+ };
+
+ PushButton PB_AUTO_ORDER
+ {
+ Pos = MAP_APPFONT ( 102 , 50 ) ;
+ Size = MAP_APPFONT ( 60 , 14 ) ;
+ Text [ en-US ] = "Automatic Sort" ;
+ };
+ OKButton PB_OK
+ {
+ Pos = MAP_APPFONT ( 102 , 100 ) ;
+ Size = MAP_APPFONT ( 60 , 14 ) ;
+ TabStop = TRUE ;
+ DefButton = TRUE;
+ };
+
+ CancelButton PB_CANCEL
+ {
+ Pos = MAP_APPFONT ( 102 , 118 ) ;
+ Size = MAP_APPFONT ( 60 , 14 ) ;
+ TabStop = TRUE ;
+ };
+
+ HelpButton PB_HELP
+ {
+ Pos = MAP_APPFONT ( 102 , 136 ) ;
+ Size = MAP_APPFONT ( 60 , 14 ) ;
+ TabStop = TRUE ;
+ };
+};
+
diff --git a/extensions/source/propctrlr/unourl.cxx b/extensions/source/propctrlr/unourl.cxx
new file mode 100644
index 000000000000..136969621e07
--- /dev/null
+++ b/extensions/source/propctrlr/unourl.cxx
@@ -0,0 +1,72 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+#include "unourl.hxx"
+#include <com/sun/star/util/XURLTransformer.hpp>
+
+//........................................................................
+namespace pcr
+{
+//........................................................................
+
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::lang;
+ using namespace ::com::sun::star::util;
+
+ //====================================================================
+ //= UnoURL
+ //====================================================================
+ UnoURL::UnoURL( const ::rtl::OUString& _rCompleteURL, const Reference< XMultiServiceFactory >& _rxORB )
+ {
+ m_aURL.Complete = _rCompleteURL;
+
+ OSL_ENSURE( _rxORB.is(), "UnoURL::UnoURL: invalid ORB!" );
+ Reference< XURLTransformer > xTransform;
+ try
+ {
+ if ( _rxORB.is() )
+ {
+ xTransform = xTransform.query( _rxORB->createInstance( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.util.URLTransformer" ) ) ) );
+ OSL_ENSURE( xTransform.is(), "UnoURL::UnoURL: could not create an URL transformer!" );
+ if ( xTransform.is() )
+ xTransform->parseStrict( m_aURL );
+ }
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "UnoURL::UnoURL: caught an exception!" );
+ }
+ }
+
+//........................................................................
+} // namespace pcr
+//........................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/propctrlr/unourl.hxx b/extensions/source/propctrlr/unourl.hxx
new file mode 100644
index 000000000000..8324751050dd
--- /dev/null
+++ b/extensions/source/propctrlr/unourl.hxx
@@ -0,0 +1,67 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef EXTENSIONS_SOURCE_PROPCTRLR_UNOURL_HXX
+#define EXTENSIONS_SOURCE_PROPCTRLR_UNOURL_HXX
+
+#include <rtl/ustring.hxx>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/util/URL.hpp>
+
+//........................................................................
+namespace pcr
+{
+//........................................................................
+
+ //====================================================================
+ //= UnoURL
+ //====================================================================
+ class UnoURL
+ {
+ private:
+ ::com::sun::star::util::URL m_aURL;
+
+ public:
+ UnoURL(
+ const ::rtl::OUString& _rCompleteURL,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB
+ );
+
+ inline operator const ::rtl::OUString& () const { return m_aURL.Complete; }
+ inline operator const ::com::sun::star::util::URL& () const { return m_aURL; }
+
+ private:
+ UnoURL(); // never implemented
+ };
+
+//........................................................................
+} // namespacepcr
+//........................................................................
+
+#endif // EXTENSIONS_SOURCE_PROPCTRLR_UNOURL_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/propctrlr/usercontrol.cxx b/extensions/source/propctrlr/usercontrol.cxx
new file mode 100644
index 000000000000..a6dbea212338
--- /dev/null
+++ b/extensions/source/propctrlr/usercontrol.cxx
@@ -0,0 +1,372 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+#include "usercontrol.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/inspection/PropertyControlType.hpp>
+#include <com/sun/star/inspection/PropertyControlType.hpp>
+/** === end UNO includes === **/
+#include <svl/numuno.hxx>
+#include <rtl/math.hxx>
+#include <tools/debug.hxx>
+#include <svl/zformat.hxx>
+#include <connectivity/dbconversion.hxx>
+#include <com/sun/star/util/Time.hpp>
+#include "modulepcr.hxx"
+#include "propresid.hrc"
+
+//............................................................................
+namespace pcr
+{
+//............................................................................
+
+ /** === begin UNO using === **/
+ using ::com::sun::star::uno::Any;
+ using ::com::sun::star::uno::Type;
+ using ::com::sun::star::beans::IllegalTypeException;
+ using ::com::sun::star::uno::RuntimeException;
+ /** === end UNO using === **/
+ namespace PropertyControlType = ::com::sun::star::inspection::PropertyControlType;
+
+ //==================================================================
+ // NumberFormatSampleField
+ //==================================================================
+ //------------------------------------------------------------------
+ long NumberFormatSampleField::PreNotify( NotifyEvent& rNEvt )
+ {
+ // want to handle two keys myself : Del/Backspace should empty the window (setting my prop to "standard" this way)
+ if (EVENT_KEYINPUT == rNEvt.GetType())
+ {
+ sal_uInt16 nKey = rNEvt.GetKeyEvent()->GetKeyCode().GetCode();
+
+ if ((KEY_DELETE == nKey) || (KEY_BACKSPACE == nKey))
+ {
+ SetText( String() );
+ if ( m_pHelper )
+ m_pHelper->ModifiedHdl( this );
+ return 1;
+ }
+ }
+
+ return BaseClass::PreNotify( rNEvt );
+ }
+
+ //------------------------------------------------------------------
+ void NumberFormatSampleField::SetFormatSupplier( const SvNumberFormatsSupplierObj* pSupplier )
+ {
+ if ( pSupplier )
+ {
+ TreatAsNumber( sal_True );
+
+ SvNumberFormatter* pFormatter = pSupplier->GetNumberFormatter();
+ SetFormatter( pFormatter, sal_True );
+ SetValue( 1234.56789 );
+ }
+ else
+ {
+ TreatAsNumber( sal_False );
+ SetFormatter( NULL, sal_True );
+ SetText( String() );
+ }
+ }
+
+ //==================================================================
+ // OFormatSampleControl
+ //==================================================================
+ //------------------------------------------------------------------
+ OFormatSampleControl::OFormatSampleControl( Window* pParent, WinBits nWinStyle )
+ :OFormatSampleControl_Base( PropertyControlType::Unknown, pParent, nWinStyle )
+ {
+ }
+
+ //------------------------------------------------------------------
+ void SAL_CALL OFormatSampleControl::setValue( const Any& _rValue ) throw (IllegalTypeException, RuntimeException)
+ {
+ sal_Int32 nFormatKey = 0;
+ if ( _rValue >>= nFormatKey )
+ {
+ // else set the new format key, the text will be reformatted
+ getTypedControlWindow()->SetFormatKey( nFormatKey );
+
+ SvNumberFormatter* pNF = getTypedControlWindow()->GetFormatter();
+ const SvNumberformat* pEntry = pNF->GetEntry( nFormatKey );
+ OSL_ENSURE( pEntry, "OFormatSampleControl::setValue: invalid format entry!" );
+
+ const bool bIsTextFormat = ( pEntry && pEntry->IsTextFormat() );
+ if ( bIsTextFormat )
+ getTypedControlWindow()->SetText( String( PcrRes( RID_STR_TEXT_FORMAT ) ) );
+ else
+ getTypedControlWindow()->SetValue( pEntry ? getPreviewValue( *pEntry ) : 1234.56789 );
+ }
+ else
+ getTypedControlWindow()->SetText( String() );
+ }
+ //------------------------------------------------------------------
+ double OFormatSampleControl::getPreviewValue( const SvNumberformat& i_rEntry )
+ {
+ double nValue = 1234.56789;
+ switch ( i_rEntry.GetType() & ~NUMBERFORMAT_DEFINED )
+ {
+ case NUMBERFORMAT_DATE:
+ {
+ Date aCurrentDate;
+ static ::com::sun::star::util::Date STANDARD_DB_DATE(30,12,1899);
+ nValue = ::dbtools::DBTypeConversion::toDouble(::dbtools::DBTypeConversion::toDate(static_cast<sal_Int32>(aCurrentDate.GetDate())),STANDARD_DB_DATE);
+ }
+ break;
+ case NUMBERFORMAT_TIME:
+ case NUMBERFORMAT_DATETIME:
+ {
+ Time aCurrentTime;
+ nValue = ::dbtools::DBTypeConversion::toDouble(::dbtools::DBTypeConversion::toTime(aCurrentTime.GetTime()));
+ }
+ break;
+ default:
+ break;
+ }
+ return nValue;
+ }
+
+ //------------------------------------------------------------------
+ double OFormatSampleControl::getPreviewValue(SvNumberFormatter* _pNF,sal_Int32 _nFormatKey)
+ {
+ const SvNumberformat* pEntry = _pNF->GetEntry(_nFormatKey);
+ DBG_ASSERT( pEntry, "OFormattedNumericControl::SetFormatDescription: invalid format key!" );
+ double nValue = 1234.56789;
+ if ( pEntry )
+ nValue = getPreviewValue( *pEntry );
+ return nValue;
+ }
+ //------------------------------------------------------------------
+ Any SAL_CALL OFormatSampleControl::getValue() throw (RuntimeException)
+ {
+ Any aPropValue;
+ if ( getTypedControlWindow()->GetText().Len() )
+ aPropValue <<= (sal_Int32)getTypedControlWindow()->GetFormatKey();
+ return aPropValue;
+ }
+
+ //------------------------------------------------------------------
+ Type SAL_CALL OFormatSampleControl::getValueType() throw (RuntimeException)
+ {
+ return ::getCppuType( static_cast< sal_Int32* >( NULL ) );
+ }
+
+ //==================================================================
+ // class OFormattedNumericControl
+ //==================================================================
+ DBG_NAME(OFormattedNumericControl);
+ //------------------------------------------------------------------
+ OFormattedNumericControl::OFormattedNumericControl( Window* pParent, WinBits nWinStyle )
+ :OFormattedNumericControl_Base( PropertyControlType::Unknown, pParent, nWinStyle )
+ {
+ DBG_CTOR(OFormattedNumericControl,NULL);
+
+ getTypedControlWindow()->TreatAsNumber(sal_True);
+
+ m_nLastDecimalDigits = getTypedControlWindow()->GetDecimalDigits();
+ }
+
+ //------------------------------------------------------------------
+ OFormattedNumericControl::~OFormattedNumericControl()
+ {
+ DBG_DTOR(OFormattedNumericControl,NULL);
+ }
+
+ //------------------------------------------------------------------
+ void SAL_CALL OFormattedNumericControl::setValue( const Any& _rValue ) throw (IllegalTypeException, RuntimeException)
+ {
+ double nValue( 0 );
+ if ( _rValue >>= nValue )
+ getTypedControlWindow()->SetValue( nValue );
+ else
+ getTypedControlWindow()->SetText(String());
+ }
+
+ //------------------------------------------------------------------
+ Any SAL_CALL OFormattedNumericControl::getValue() throw (RuntimeException)
+ {
+ Any aPropValue;
+ if ( getTypedControlWindow()->GetText().Len() )
+ aPropValue <<= (double)getTypedControlWindow()->GetValue();
+ return aPropValue;
+ }
+
+ //------------------------------------------------------------------
+ Type SAL_CALL OFormattedNumericControl::getValueType() throw (RuntimeException)
+ {
+ return ::getCppuType( static_cast< double* >( NULL ) );
+ }
+
+ //------------------------------------------------------------------
+ void OFormattedNumericControl::SetFormatDescription(const FormatDescription& rDesc)
+ {
+ sal_Bool bFallback = sal_True;
+
+ if (rDesc.pSupplier)
+ {
+ getTypedControlWindow()->TreatAsNumber(sal_True);
+
+ SvNumberFormatter* pFormatter = rDesc.pSupplier->GetNumberFormatter();
+ if (pFormatter != getTypedControlWindow()->GetFormatter())
+ getTypedControlWindow()->SetFormatter(pFormatter, sal_True);
+ getTypedControlWindow()->SetFormatKey(rDesc.nKey);
+
+ const SvNumberformat* pEntry = getTypedControlWindow()->GetFormatter()->GetEntry(getTypedControlWindow()->GetFormatKey());
+ DBG_ASSERT( pEntry, "OFormattedNumericControl::SetFormatDescription: invalid format key!" );
+ if ( pEntry )
+ {
+ switch (pEntry->GetType() & ~NUMBERFORMAT_DEFINED)
+ {
+ case NUMBERFORMAT_NUMBER:
+ case NUMBERFORMAT_CURRENCY:
+ case NUMBERFORMAT_SCIENTIFIC:
+ case NUMBERFORMAT_FRACTION:
+ case NUMBERFORMAT_PERCENT:
+ m_nLastDecimalDigits = getTypedControlWindow()->GetDecimalDigits();
+ break;
+ case NUMBERFORMAT_DATETIME:
+ case NUMBERFORMAT_DATE:
+ case NUMBERFORMAT_TIME:
+ m_nLastDecimalDigits = 7;
+ break;
+ default:
+ m_nLastDecimalDigits = 0;
+ break;
+ }
+ bFallback = sal_False;
+ }
+
+ }
+
+ if ( bFallback )
+ {
+ getTypedControlWindow()->TreatAsNumber(sal_False);
+ getTypedControlWindow()->SetFormatter(NULL, sal_True);
+ getTypedControlWindow()->SetText(String());
+ m_nLastDecimalDigits = 0;
+ }
+ }
+
+ //========================================================================
+ //= OFileUrlControl
+ //========================================================================
+ //------------------------------------------------------------------
+ OFileUrlControl::OFileUrlControl( Window* pParent, WinBits nWinStyle )
+ :OFileUrlControl_Base( PropertyControlType::Unknown, pParent, nWinStyle | WB_DROPDOWN )
+ {
+ getTypedControlWindow()->SetDropDownLineCount( 10 );
+ getTypedControlWindow()->SetPlaceHolder( String( PcrRes( RID_EMBED_IMAGE_PLACEHOLDER ) ) ) ;
+ }
+
+ //------------------------------------------------------------------
+ OFileUrlControl::~OFileUrlControl()
+ {
+ }
+
+ //------------------------------------------------------------------
+ void SAL_CALL OFileUrlControl::setValue( const Any& _rValue ) throw (IllegalTypeException, RuntimeException)
+ {
+ ::rtl::OUString sURL;
+ if ( ( _rValue >>= sURL ) )
+ {
+ if ( sURL.indexOf( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "vnd.sun.star.GraphicObject:" ) ) ) == 0 )
+ getTypedControlWindow()->DisplayURL( getTypedControlWindow()->GetPlaceHolder() );
+ else
+ getTypedControlWindow()->DisplayURL( sURL );
+ }
+ else
+ getTypedControlWindow()->SetText( String() );
+ }
+
+ //------------------------------------------------------------------
+ Any SAL_CALL OFileUrlControl::getValue() throw (RuntimeException)
+ {
+ Any aPropValue;
+ if ( getTypedControlWindow()->GetText().Len() )
+ aPropValue <<= (::rtl::OUString)getTypedControlWindow()->GetURL();
+ return aPropValue;
+ }
+
+ //------------------------------------------------------------------
+ Type SAL_CALL OFileUrlControl::getValueType() throw (RuntimeException)
+ {
+ return ::getCppuType( static_cast< ::rtl::OUString* >( NULL ) );
+ }
+
+ //========================================================================
+ //= OTimeDurationControl
+ //========================================================================
+ //------------------------------------------------------------------
+ OTimeDurationControl::OTimeDurationControl( ::Window* pParent, WinBits nWinStyle )
+ :ONumericControl( pParent, nWinStyle )
+ {
+ getTypedControlWindow()->SetUnit( FUNIT_CUSTOM );
+ getTypedControlWindow()->SetCustomUnitText( String::CreateFromAscii( " ms" ) );
+ getTypedControlWindow()->SetCustomConvertHdl( LINK( this, OTimeDurationControl, OnCustomConvert ) );
+ }
+
+ //------------------------------------------------------------------
+ OTimeDurationControl::~OTimeDurationControl()
+ {
+ }
+
+ //------------------------------------------------------------------
+ ::sal_Int16 SAL_CALL OTimeDurationControl::getControlType() throw (::com::sun::star::uno::RuntimeException)
+ {
+ // don't use the base class'es method, it would claim we're a standard control, which
+ // we in fact aren't
+ return PropertyControlType::Unknown;
+ }
+
+ //------------------------------------------------------------------
+ IMPL_LINK( OTimeDurationControl, OnCustomConvert, MetricField*, /*pField*/ )
+ {
+ long nMultiplier = 1;
+ if ( getTypedControlWindow()->GetCurUnitText().EqualsIgnoreCaseAscii( "ms" ) )
+ nMultiplier = 1;
+ if ( getTypedControlWindow()->GetCurUnitText().EqualsIgnoreCaseAscii( "s" ) )
+ nMultiplier = 1000;
+ else if ( getTypedControlWindow()->GetCurUnitText().EqualsIgnoreCaseAscii( "m" ) )
+ nMultiplier = 1000 * 60;
+ else if ( getTypedControlWindow()->GetCurUnitText().EqualsIgnoreCaseAscii( "h" ) )
+ nMultiplier = 1000 * 60 * 60;
+
+ getTypedControlWindow()->SetValue( getTypedControlWindow()->GetLastValue() * nMultiplier );
+
+ return 0L;
+ }
+
+//............................................................................
+} // namespace pcr
+//............................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/propctrlr/usercontrol.hxx b/extensions/source/propctrlr/usercontrol.hxx
new file mode 100644
index 000000000000..6bd985b2e3b7
--- /dev/null
+++ b/extensions/source/propctrlr/usercontrol.hxx
@@ -0,0 +1,174 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _EXTENSIONS_PROPCTRLR_USERCONTROL_HXX_
+#define _EXTENSIONS_PROPCTRLR_USERCONTROL_HXX_
+
+#include "commoncontrol.hxx"
+#define _ZFORLIST_DECLARE_TABLE
+#include <svtools/fmtfield.hxx>
+#include <svtools/fileurlbox.hxx>
+#include "standardcontrol.hxx"
+
+class SvNumberFormatsSupplierObj;
+
+//............................................................................
+namespace pcr
+{
+//............................................................................
+
+ //========================================================================
+ //= NumberFormatSampleField
+ //========================================================================
+ class NumberFormatSampleField : public ControlWindow< FormattedField >
+ {
+ private:
+ typedef ControlWindow< FormattedField > BaseClass;
+
+ public:
+ NumberFormatSampleField( Window* _pParent, WinBits _nStyle )
+ :BaseClass( _pParent, _nStyle )
+ {
+ }
+
+ void SetFormatSupplier( const SvNumberFormatsSupplierObj* pSupplier );
+
+ protected:
+ virtual long PreNotify( NotifyEvent& rNEvt );
+ };
+
+ //========================================================================
+ //= OFormatSampleControl
+ //========================================================================
+ typedef CommonBehaviourControl< ::com::sun::star::inspection::XPropertyControl, NumberFormatSampleField > OFormatSampleControl_Base;
+ class OFormatSampleControl : public OFormatSampleControl_Base
+ {
+ public:
+ OFormatSampleControl( Window* pParent, WinBits nWinStyle );
+
+ // XPropertyControl
+ virtual ::com::sun::star::uno::Any SAL_CALL getValue() throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setValue( const ::com::sun::star::uno::Any& _value ) throw (::com::sun::star::beans::IllegalTypeException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Type SAL_CALL getValueType() throw (::com::sun::star::uno::RuntimeException);
+
+ inline void SetFormatSupplier( const SvNumberFormatsSupplierObj* _pSupplier )
+ {
+ getTypedControlWindow()->SetFormatSupplier( _pSupplier );
+ }
+
+ /** returns the default preview value for the given format key
+ *
+ * \param _pNF the number formatter
+ * \param _nFormatKey the format key
+ * \return current date or time or the value 1234.56789
+ */
+ static double getPreviewValue(SvNumberFormatter* _pNF,sal_Int32 _nFormatKey);
+
+ private:
+ static double getPreviewValue( const SvNumberformat& i_rEntry );
+ };
+
+ //========================================================================
+ //= FormatDescription
+ //========================================================================
+ struct FormatDescription
+ {
+ SvNumberFormatsSupplierObj* pSupplier;
+ sal_Int32 nKey;
+ };
+
+ //========================================================================
+ //= OFormattedNumericControl
+ //========================================================================
+ typedef CommonBehaviourControl< ::com::sun::star::inspection::XPropertyControl, ControlWindow< FormattedField > > OFormattedNumericControl_Base;
+ class OFormattedNumericControl : public OFormattedNumericControl_Base
+ {
+ private:
+ sal_Int32 m_nLastDecimalDigits;
+
+ public:
+ OFormattedNumericControl( Window* pParent, WinBits nWinStyle = WB_TABSTOP);
+
+ // XPropertyControl
+ virtual ::com::sun::star::uno::Any SAL_CALL getValue() throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setValue( const ::com::sun::star::uno::Any& _value ) throw (::com::sun::star::beans::IllegalTypeException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Type SAL_CALL getValueType() throw (::com::sun::star::uno::RuntimeException);
+
+ void SetFormatDescription( const FormatDescription& rDesc );
+
+ // make some FormattedField methods available
+ void SetDecimalDigits(sal_uInt16 nPrecision) { getTypedControlWindow()->SetDecimalDigits(nPrecision); m_nLastDecimalDigits = nPrecision; }
+ void SetDefaultValue(double dDef) { getTypedControlWindow()->SetDefaultValue(dDef); }
+ void EnableEmptyField(sal_Bool bEnable) { getTypedControlWindow()->EnableEmptyField(bEnable); }
+ void SetThousandsSep(sal_Bool bEnable) { getTypedControlWindow()->SetThousandsSep(bEnable); }
+
+ protected:
+ ~OFormattedNumericControl();
+ };
+
+ //========================================================================
+ //= OFileUrlControl
+ //========================================================================
+ typedef CommonBehaviourControl< ::com::sun::star::inspection::XPropertyControl, ControlWindow< ::svt::FileURLBox > > OFileUrlControl_Base;
+ class OFileUrlControl : public OFileUrlControl_Base
+ {
+ public:
+ OFileUrlControl( Window* pParent, WinBits nWinStyle );
+
+ // XPropertyControl
+ virtual ::com::sun::star::uno::Any SAL_CALL getValue() throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setValue( const ::com::sun::star::uno::Any& _value ) throw (::com::sun::star::beans::IllegalTypeException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Type SAL_CALL getValueType() throw (::com::sun::star::uno::RuntimeException);
+
+ protected:
+ ~OFileUrlControl();
+ };
+
+ //========================================================================
+ //= OTimeDurationControl
+ //========================================================================
+ class OTimeDurationControl : public ONumericControl
+ {
+ public:
+ OTimeDurationControl( ::Window* pParent, WinBits nWinStyle );
+ ~OTimeDurationControl();
+
+ // XPropertyControl
+ ::sal_Int16 SAL_CALL getControlType() throw (::com::sun::star::uno::RuntimeException);
+
+ private:
+ DECL_LINK( OnCustomConvert, MetricField* );
+ };
+
+//............................................................................
+} // namespace pcr
+//............................................................................
+
+#endif // _EXTENSIONS_PROPCTRLR_USERCONTROL_HXX_
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/propctrlr/xsddatatypes.cxx b/extensions/source/propctrlr/xsddatatypes.cxx
new file mode 100644
index 000000000000..d9c8cff9b807
--- /dev/null
+++ b/extensions/source/propctrlr/xsddatatypes.cxx
@@ -0,0 +1,252 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+#include "xsddatatypes.hxx"
+#include "formstrings.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/xsd/DataTypeClass.hpp>
+#include <com/sun/star/xsd/XDataType.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+/** === end UNO includes === **/
+#include <tools/debug.hxx>
+
+//........................................................................
+namespace pcr
+{
+//........................................................................
+
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::xsd;
+ using namespace ::com::sun::star::beans;
+
+ //====================================================================
+ //= helper
+ //====================================================================
+ //--------------------------------------------------------------------
+ template< typename INTERFACE, typename ARGUMENT >
+ void setSave( INTERFACE* pObject, void ( SAL_CALL INTERFACE::*pSetter )( ARGUMENT ), ARGUMENT _rArg )
+ {
+ try
+ {
+ (pObject->*pSetter)( _rArg );
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "XSDDataType: setSave: caught an exception!" );
+ }
+ }
+
+ //--------------------------------------------------------------------
+ template< typename INTERFACE, typename ARGUMENT >
+ ARGUMENT getSave( INTERFACE* pObject, ARGUMENT ( SAL_CALL INTERFACE::*pGetter )( ) )
+ {
+ ARGUMENT aReturn = ARGUMENT();
+ try
+ {
+ aReturn = (pObject->*pGetter)( );
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "XSDDataType: getSave: caught an exception!" );
+ }
+ return aReturn;
+ }
+
+ template< typename FACETTYPE >
+ FACETTYPE getFacet( const Reference< XPropertySet >& _rxFacets, const ::rtl::OUString& _rFacetName ) SAL_THROW(())
+ {
+ FACETTYPE aReturn;
+ try
+ {
+ OSL_VERIFY( _rxFacets->getPropertyValue( _rFacetName ) >>= aReturn );
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "XSDDataType: getFacet: caught an exception!" );
+ }
+ return aReturn;
+ }
+
+ //====================================================================
+ //= XSDDataType
+ //====================================================================
+ //--------------------------------------------------------------------
+ XSDDataType::XSDDataType( const Reference< XDataType >& _rxDataType )
+ :m_xDataType( _rxDataType )
+ ,m_refCount( 0 )
+ {
+ DBG_ASSERT( m_xDataType.is(), "XSDDataType::XSDDataType: invalid UNO object!" );
+ if ( m_xDataType.is() )
+ m_xFacetInfo = m_xDataType->getPropertySetInfo();
+ }
+
+ //--------------------------------------------------------------------
+ oslInterlockedCount SAL_CALL XSDDataType::acquire()
+ {
+ return osl_incrementInterlockedCount( &m_refCount );
+ }
+
+ //--------------------------------------------------------------------
+ oslInterlockedCount SAL_CALL XSDDataType::release()
+ {
+ if ( 0 == osl_decrementInterlockedCount( &m_refCount ) )
+ {
+ delete this;
+ return 0;
+ }
+ return m_refCount;
+ }
+
+ //--------------------------------------------------------------------
+ XSDDataType::~XSDDataType()
+ {
+ }
+
+ //--------------------------------------------------------------------
+ sal_Int16 XSDDataType::classify() const SAL_THROW(())
+ {
+ sal_Int16 nTypeClass = DataTypeClass::STRING;
+ try
+ {
+ if ( m_xDataType.is() )
+ nTypeClass = m_xDataType->getTypeClass();
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "XSDDataType::classify: caught an exception!" );
+ }
+ return nTypeClass;
+ }
+
+ //--------------------------------------------------------------------
+ bool XSDDataType::isBasicType() const SAL_THROW(())
+ {
+ return getSave( m_xDataType.get(), &XDataType::getIsBasic );
+ }
+
+ //--------------------------------------------------------------------
+ ::rtl::OUString XSDDataType::getName() const SAL_THROW(())
+ {
+ return getSave( m_xDataType.get(), &XDataType::getName );
+ }
+
+ //--------------------------------------------------------------------
+ void XSDDataType::setFacet( const ::rtl::OUString& _rFacetName, const Any& _rValue ) SAL_THROW(())
+ {
+ try
+ {
+ m_xDataType->setPropertyValue( _rFacetName, _rValue );
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "XSDDataType::setFacet: caught an exception - sure this is the right data type class for this property?" );
+ }
+ }
+
+ //--------------------------------------------------------------------
+ bool XSDDataType::hasFacet( const ::rtl::OUString& _rFacetName ) const SAL_THROW(())
+ {
+ bool bReturn = false;
+ try
+ {
+ bReturn = m_xFacetInfo.is() && m_xFacetInfo->hasPropertyByName( _rFacetName );
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "XSDDataType::hasFacet: caught an exception!" );
+ }
+ return bReturn;
+ }
+ //--------------------------------------------------------------------
+ Any XSDDataType::getFacet( const ::rtl::OUString& _rFacetName ) SAL_THROW(())
+ {
+ Any aReturn;
+ try
+ {
+ aReturn = m_xDataType->getPropertyValue( _rFacetName );
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "XSDDataType::getFacet: caught an exception - sure this is the right data type class for this property?" );
+ }
+ return aReturn;
+ }
+
+ //--------------------------------------------------------------------
+ namespace
+ {
+ void lcl_copyProperties( const Reference< XPropertySet >& _rxSource, const Reference< XPropertySet >& _rxDest )
+ {
+ Reference< XPropertySetInfo > xSourceInfo;
+ if ( _rxSource.is() )
+ xSourceInfo = _rxSource->getPropertySetInfo();
+ Reference< XPropertySetInfo > xDestInfo;
+ if ( _rxDest.is() )
+ xDestInfo = _rxDest->getPropertySetInfo();
+ OSL_ENSURE( xSourceInfo.is() && xDestInfo.is(), "lcl_copyProperties: invalid property set( info)s!" );
+ if ( !xSourceInfo.is() || !xDestInfo.is() )
+ return;
+
+ Sequence< Property > aProperties( xSourceInfo->getProperties() );
+ const Property* pProperties = aProperties.getConstArray();
+ const Property* pPropertiesEnd = pProperties + aProperties.getLength();
+ for ( ; pProperties != pPropertiesEnd; ++pProperties )
+ {
+ if ( xDestInfo->hasPropertyByName( pProperties->Name ) )
+ _rxDest->setPropertyValue( pProperties->Name, _rxSource->getPropertyValue( pProperties->Name ) );
+ }
+ }
+ }
+
+ //--------------------------------------------------------------------
+ void XSDDataType::copyFacetsFrom( const ::rtl::Reference< XSDDataType >& _pSourceType )
+ {
+ OSL_ENSURE( _pSourceType.is(), "XSDDataType::copyFacetsFrom: invalid source type!" );
+ if ( !_pSourceType.is() )
+ return;
+
+ try
+ {
+ Reference< XPropertySet > xSource( _pSourceType->getUnoDataType(), UNO_QUERY );
+ Reference< XPropertySet > xDest( getUnoDataType(), UNO_QUERY );
+ lcl_copyProperties( xSource, xDest );
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "XSDDataType::copyFacetsFrom: caught an exception!" );
+ }
+ }
+
+//........................................................................
+} // namespace pcr
+//........................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/propctrlr/xsddatatypes.hxx b/extensions/source/propctrlr/xsddatatypes.hxx
new file mode 100644
index 000000000000..22307028b2dd
--- /dev/null
+++ b/extensions/source/propctrlr/xsddatatypes.hxx
@@ -0,0 +1,116 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef EXTENSIONS_SOURCE_PROPCTRLR_XSDDATATYPES_HXX
+#define EXTENSIONS_SOURCE_PROPCTRLR_XSDDATATYPES_HXX
+
+/** === begin UNO includes === **/
+#include <com/sun/star/uno/Reference.hxx>
+/** === end UNO includes === **/
+#include <rtl/ref.hxx>
+
+namespace com { namespace sun { namespace star {
+ namespace xsd {
+ class XDataType;
+ }
+ namespace beans {
+ class XPropertySet;
+ class XPropertySetInfo;
+ }
+} } }
+
+//........................................................................
+namespace pcr
+{
+//........................................................................
+
+ //====================================================================
+ //= XSDDataType
+ //====================================================================
+ class XSDDataType : public ::rtl::IReference
+ {
+ private:
+ ::com::sun::star::uno::Reference< ::com::sun::star::xsd::XDataType >
+ m_xDataType;
+ ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo >
+ m_xFacetInfo;
+
+ protected:
+ oslInterlockedCount m_refCount;
+
+ protected:
+ inline ::com::sun::star::xsd::XDataType* getDataTypeInterface() const { return m_xDataType.get(); }
+
+ public:
+ XSDDataType(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::xsd::XDataType >& _rxDataType
+ );
+
+ // IReference
+ virtual oslInterlockedCount SAL_CALL acquire();
+ virtual oslInterlockedCount SAL_CALL release();
+
+ /// retrieves the underlying UNO component
+ inline const ::com::sun::star::uno::Reference< ::com::sun::star::xsd::XDataType >&
+ getUnoDataType() const { return m_xDataType; }
+
+ /// classifies the data typ
+ sal_Int16 classify() const SAL_THROW(());
+
+ // attribute access
+ ::rtl::OUString getName() const SAL_THROW(());
+ bool isBasicType() const SAL_THROW(());
+
+ /// determines whether a given facet exists at the type
+ bool hasFacet( const ::rtl::OUString& _rFacetName ) const SAL_THROW(());
+ /// retrieves a facet value
+ ::com::sun::star::uno::Any
+ getFacet( const ::rtl::OUString& _rFacetName ) SAL_THROW(());
+ /// sets a facet value
+ void setFacet( const ::rtl::OUString& _rFacetName, const ::com::sun::star::uno::Any& _rFacetValue ) SAL_THROW(());
+
+ /** copies as much facets (values, respectively) from a give data type instance
+ */
+ void copyFacetsFrom( const ::rtl::Reference< XSDDataType >& _pSourceType );
+
+ protected:
+ virtual ~XSDDataType();
+
+ private:
+ XSDDataType(); // never implemented
+ XSDDataType( const XSDDataType& ); // never implemented
+ XSDDataType& operator=( const XSDDataType& ); // never implemented
+ };
+
+//........................................................................
+} // namespace pcr
+//........................................................................
+
+#endif // EXTENSIONS_SOURCE_PROPCTRLR_XSDDATATYPES_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/propctrlr/xsdvalidationhelper.cxx b/extensions/source/propctrlr/xsdvalidationhelper.cxx
new file mode 100644
index 000000000000..88d15f8c613f
--- /dev/null
+++ b/extensions/source/propctrlr/xsdvalidationhelper.cxx
@@ -0,0 +1,414 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+#include "xsdvalidationhelper.hxx"
+#include "xsddatatypes.hxx"
+#include "formstrings.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/xsd/DataTypeClass.hpp>
+#include <com/sun/star/util/NumberFormat.hpp>
+#include <com/sun/star/util/XNumberFormatTypes.hpp>
+#include <com/sun/star/util/XNumberFormatsSupplier.hpp>
+#include <com/sun/star/xforms/XDataTypeRepository.hpp>
+/** === end UNO includes === **/
+#include <unotools/syslocale.hxx>
+#include <tools/diagnose_ex.h>
+
+//........................................................................
+namespace pcr
+{
+//........................................................................
+
+ using namespace ::com::sun::star;
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::beans;
+ using namespace ::com::sun::star::xsd;
+ using namespace ::com::sun::star::util;
+ using namespace ::com::sun::star::lang;
+ using namespace ::com::sun::star::xforms;
+
+ namespace NumberFormat = ::com::sun::star::util::NumberFormat;
+
+ //====================================================================
+ //= XSDValidationHelper
+ //====================================================================
+ //--------------------------------------------------------------------
+ XSDValidationHelper::XSDValidationHelper( ::osl::Mutex& _rMutex, const Reference< XPropertySet >& _rxIntrospectee, const Reference< frame::XModel >& _rxContextDocument )
+ :EFormsHelper( _rMutex, _rxIntrospectee, _rxContextDocument )
+ ,m_bInspectingFormattedField( false )
+ {
+ try
+ {
+ Reference< XPropertySetInfo > xPSI;
+ Reference< XServiceInfo > xSI( _rxIntrospectee, UNO_QUERY );
+ if ( m_xControlModel.is() )
+ xPSI = m_xControlModel->getPropertySetInfo();
+ if ( xPSI.is()
+ && xPSI->hasPropertyByName( PROPERTY_FORMATKEY )
+ && xPSI->hasPropertyByName( PROPERTY_FORMATSSUPPLIER )
+ && xSI.is()
+ && xSI->supportsService( SERVICE_COMPONENT_FORMATTEDFIELD )
+ )
+ m_bInspectingFormattedField = true;
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "XSDValidationHelper::XSDValidationHelper: caught an exception while examining the introspectee!" );
+ }
+ }
+
+ //--------------------------------------------------------------------
+ void XSDValidationHelper::getAvailableDataTypeNames( ::std::vector< ::rtl::OUString >& /* [out] */ _rNames ) const SAL_THROW(())
+ {
+ _rNames.resize( 0 );
+
+ try
+ {
+ Reference< XDataTypeRepository > xRepository = getDataTypeRepository();
+ Sequence< ::rtl::OUString > aElements;
+ if ( xRepository.is() )
+ aElements = xRepository->getElementNames();
+
+ _rNames.resize( aElements.getLength() );
+ ::std::copy( aElements.getConstArray(), aElements.getConstArray() + aElements.getLength(), _rNames.begin() );
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "XSDValidationHelper::getAvailableDataTypeNames: caught an exception!" );
+ }
+ }
+
+ //--------------------------------------------------------------------
+ Reference< XDataTypeRepository > XSDValidationHelper::getDataTypeRepository() const SAL_THROW((Exception))
+ {
+ Reference< XDataTypeRepository > xRepository;
+
+ Reference< xforms::XModel > xModel( getCurrentFormModel( ) );
+ if ( xModel.is() )
+ xRepository = xModel->getDataTypeRepository();
+
+ return xRepository;
+ }
+
+ //--------------------------------------------------------------------
+ Reference< XDataTypeRepository > XSDValidationHelper::getDataTypeRepository( const ::rtl::OUString& _rModelName ) const SAL_THROW((Exception))
+ {
+ Reference< XDataTypeRepository > xRepository;
+
+ Reference< xforms::XModel > xModel( getFormModelByName( _rModelName ) );
+ if ( xModel.is() )
+ xRepository = xModel->getDataTypeRepository();
+
+ return xRepository;
+ }
+
+ //--------------------------------------------------------------------
+ Reference< XDataType > XSDValidationHelper::getDataType( const ::rtl::OUString& _rName ) const SAL_THROW((Exception))
+ {
+ Reference< XDataType > xDataType;
+
+ if ( _rName.getLength() )
+ {
+ Reference< XDataTypeRepository > xRepository = getDataTypeRepository();
+ if ( xRepository.is() )
+ xDataType = xRepository->getDataType( _rName );
+ }
+ return xDataType;
+ }
+
+ //--------------------------------------------------------------------
+ ::rtl::OUString XSDValidationHelper::getValidatingDataTypeName( ) const SAL_THROW(())
+ {
+ ::rtl::OUString sDataTypeName;
+ try
+ {
+ Reference< XPropertySet > xBinding( getCurrentBinding() );
+ // it's allowed here to not (yet) have a binding
+ if ( xBinding.is() )
+ {
+ OSL_VERIFY( xBinding->getPropertyValue( PROPERTY_XSD_DATA_TYPE ) >>= sDataTypeName );
+ }
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "XSDValidationHelper::getValidatingDataTypeName: caught an exception!" );
+ }
+ return sDataTypeName;
+ }
+
+ //--------------------------------------------------------------------
+ ::rtl::Reference< XSDDataType > XSDValidationHelper::getDataTypeByName( const ::rtl::OUString& _rName ) const SAL_THROW(())
+ {
+ ::rtl::Reference< XSDDataType > pReturn;
+
+ try
+ {
+ Reference< XDataType > xValidatedAgainst;
+
+ if ( _rName.getLength() )
+ xValidatedAgainst = getDataType( _rName );
+
+ if ( xValidatedAgainst.is() )
+ pReturn = new XSDDataType( xValidatedAgainst );
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "XSDValidationHelper::getDataTypeByName: caught an exception!" );
+ }
+
+ return pReturn;
+ }
+
+ //--------------------------------------------------------------------
+ ::rtl::Reference< XSDDataType > XSDValidationHelper::getValidatingDataType( ) const SAL_THROW(())
+ {
+ return getDataTypeByName( getValidatingDataTypeName() );
+ }
+
+ //--------------------------------------------------------------------
+ bool XSDValidationHelper::cloneDataType( const ::rtl::Reference< XSDDataType >& _pDataType, const ::rtl::OUString& _rNewName ) const SAL_THROW(())
+ {
+ OSL_ENSURE( _pDataType.is(), "XSDValidationHelper::removeDataTypeFromRepository: invalid data type!" );
+ if ( !_pDataType.is() )
+ return false;
+
+ try
+ {
+ Reference< XDataTypeRepository > xRepository( getDataTypeRepository() );
+ OSL_ENSURE( xRepository.is(), "XSDValidationHelper::removeDataTypeFromRepository: invalid data type repository!" );
+ if ( !xRepository.is() )
+ return false;
+
+ Reference< XDataType > xDataType( _pDataType->getUnoDataType() );
+ OSL_ENSURE( xDataType.is(), "XSDValidationHelper::removeDataTypeFromRepository: invalid data type (II)!" );
+ if ( !xDataType.is() )
+ return false;
+
+ xRepository->cloneDataType( xDataType->getName(), _rNewName );
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "XSDValidationHelper::cloneDataType: caught an exception!" );
+ }
+ return true;
+ }
+
+ //--------------------------------------------------------------------
+ bool XSDValidationHelper::removeDataTypeFromRepository( const ::rtl::OUString& _rName ) const SAL_THROW(())
+ {
+ try
+ {
+ Reference< XDataTypeRepository > xRepository( getDataTypeRepository() );
+ OSL_ENSURE( xRepository.is(), "XSDValidationHelper::removeDataTypeFromRepository: invalid data type repository!" );
+ if ( !xRepository.is() )
+ return false;
+
+ if ( !xRepository->hasByName( _rName ) )
+ {
+ OSL_ENSURE( sal_False, "XSDValidationHelper::removeDataTypeFromRepository: invalid repository and/or data type!" );
+ return false;
+ }
+
+ xRepository->revokeDataType( _rName );
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "XSDValidationHelper::removeDataTypeFromRepository: caught an exception!" );
+ return false;
+ }
+ return true;
+ }
+
+ //--------------------------------------------------------------------
+ void XSDValidationHelper::setValidatingDataTypeByName( const ::rtl::OUString& _rName ) const SAL_THROW(())
+ {
+ try
+ {
+ Reference< XPropertySet > xBinding( getCurrentBinding() );
+ OSL_ENSURE( xBinding.is(), "XSDValidationHelper::setValidatingDataTypeByName: no active binding - how this?" );
+
+ if ( xBinding.is() )
+ {
+ // get the old data type - this is necessary for notifying property changes
+ ::rtl::OUString sOldDataTypeName;
+ OSL_VERIFY( xBinding->getPropertyValue( PROPERTY_XSD_DATA_TYPE ) >>= sOldDataTypeName );
+ Reference< XPropertySet > xOldType;
+ try { xOldType = xOldType.query( getDataType( sOldDataTypeName ) ); } catch( const Exception& ) { }
+
+ // set the new data type name
+ xBinding->setPropertyValue( PROPERTY_XSD_DATA_TYPE, makeAny( _rName ) );
+
+ // retrieve the new data type object
+ Reference< XPropertySet > xNewType( getDataType( _rName ), UNO_QUERY );
+
+ // fire any changes in the properties which result from this new type
+ std::set< ::rtl::OUString > aFilter; aFilter.insert( PROPERTY_NAME );
+ firePropertyChanges( xOldType, xNewType, aFilter );
+
+ // fire the change in the Data Type property
+ ::rtl::OUString sNewDataTypeName;
+ OSL_VERIFY( xBinding->getPropertyValue( PROPERTY_XSD_DATA_TYPE ) >>= sNewDataTypeName );
+ firePropertyChange( PROPERTY_XSD_DATA_TYPE, makeAny( sOldDataTypeName ), makeAny( sNewDataTypeName ) );
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+
+ //--------------------------------------------------------------------
+ void XSDValidationHelper::copyDataType( const ::rtl::OUString& _rFromModel, const ::rtl::OUString& _rToModel,
+ const ::rtl::OUString& _rDataTypeName ) const SAL_THROW(())
+ {
+ if ( _rFromModel == _rToModel )
+ // nothing to do (me thinks)
+ return;
+
+ try
+ {
+ Reference< XDataTypeRepository > xFromRepository, xToRepository;
+ if ( _rFromModel.getLength() )
+ xFromRepository = getDataTypeRepository( _rFromModel );
+ if ( _rToModel.getLength() )
+ xToRepository = getDataTypeRepository( _rToModel );
+
+ if ( !xFromRepository.is() || !xToRepository.is() )
+ return;
+
+ if ( !xFromRepository->hasByName( _rDataTypeName ) || xToRepository->hasByName( _rDataTypeName ) )
+ // not existent in the source, or already existent (by name) in the destination
+ return;
+
+ // determine the built-in type belonging to the source type
+ ::rtl::Reference< XSDDataType > pSourceType = new XSDDataType( xFromRepository->getDataType( _rDataTypeName ) );
+ ::rtl::OUString sTargetBaseType = getBasicTypeNameForClass( pSourceType->classify(), xToRepository );
+
+ // create the target type
+ Reference< XDataType > xTargetType = xToRepository->cloneDataType( sTargetBaseType, _rDataTypeName );
+ ::rtl::Reference< XSDDataType > pTargetType = new XSDDataType( xTargetType );
+
+ // copy the facets
+ pTargetType->copyFacetsFrom( pSourceType );
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "XSDValidationHelper::copyDataType: caught an exception!" );
+ }
+ }
+
+ //--------------------------------------------------------------------
+ void XSDValidationHelper::findDefaultFormatForIntrospectee() SAL_THROW(())
+ {
+ try
+ {
+ ::rtl::Reference< XSDDataType > xDataType = getValidatingDataType();
+ if ( xDataType.is() )
+ {
+ // find a NumberFormat type corresponding to the DataTypeClass
+ sal_Int16 nNumberFormatType = NumberFormat::NUMBER;
+ switch ( xDataType->classify() )
+ {
+ case DataTypeClass::DATETIME:
+ nNumberFormatType = NumberFormat::DATETIME;
+ break;
+ case DataTypeClass::DATE:
+ nNumberFormatType = NumberFormat::DATE;
+ break;
+ case DataTypeClass::TIME:
+ nNumberFormatType = NumberFormat::TIME;
+ break;
+ case DataTypeClass::STRING:
+ case DataTypeClass::anyURI:
+ case DataTypeClass::QName:
+ case DataTypeClass::NOTATION:
+ nNumberFormatType = NumberFormat::TEXT;
+ break;
+ }
+
+ // get the number formatter from the introspectee
+ Reference< XNumberFormatsSupplier > xSupplier;
+ Reference< XNumberFormatTypes > xFormatTypes;
+ OSL_VERIFY( m_xControlModel->getPropertyValue( PROPERTY_FORMATSSUPPLIER ) >>= xSupplier );
+ if ( xSupplier.is() )
+ xFormatTypes = xFormatTypes.query( xSupplier->getNumberFormats() );
+ OSL_ENSURE( xFormatTypes.is(), "XSDValidationHelper::findDefaultFormatForIntrospectee: no number formats for the introspectee!" );
+ if ( !xFormatTypes.is() )
+ return;
+
+ // and the standard format for the given NumberFormat type
+ sal_Int32 nDesiredFormat = xFormatTypes->getStandardFormat( nNumberFormatType, SvtSysLocale().GetLocaleData().getLocale() );
+
+ // set this at the introspectee
+ m_xControlModel->setPropertyValue( PROPERTY_FORMATKEY, makeAny( nDesiredFormat ) );
+ }
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "XSDValidationHelper::findDefaultFormatForIntrospectee: caught an exception!" );
+ }
+ }
+
+ //--------------------------------------------------------------------
+ ::rtl::OUString XSDValidationHelper::getBasicTypeNameForClass( sal_Int16 _nClass ) const SAL_THROW(())
+ {
+ return getBasicTypeNameForClass( _nClass, getDataTypeRepository() );
+ }
+
+ //--------------------------------------------------------------------
+ ::rtl::OUString XSDValidationHelper::getBasicTypeNameForClass( sal_Int16 _nClass, Reference< XDataTypeRepository > _rxRepository ) const SAL_THROW(())
+ {
+ ::rtl::OUString sReturn;
+ OSL_ENSURE( _rxRepository.is(), "XSDValidationHelper::getBasicTypeNameForClass: invalid repository!" );
+ if ( !_rxRepository.is() )
+ return sReturn;
+
+ try
+ {
+ Reference< XDataType > xDataType = _rxRepository->getBasicDataType( _nClass );
+ OSL_ENSURE( xDataType.is(), "XSDValidationHelper::getBasicTypeNameForClass: invalid data type returned!" );
+ if ( xDataType.is() )
+ sReturn = xDataType->getName();
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "XSDValidationHelper::getBasicTypeNameForClass: caught an exception!" );
+ }
+
+ return sReturn;
+ }
+
+//........................................................................
+} // namespace pcr
+//........................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/propctrlr/xsdvalidationhelper.hxx b/extensions/source/propctrlr/xsdvalidationhelper.hxx
new file mode 100644
index 000000000000..4b514b75765d
--- /dev/null
+++ b/extensions/source/propctrlr/xsdvalidationhelper.hxx
@@ -0,0 +1,152 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef EXTENSIONS_SOURCE_PROPCTRLR_XSDVALIDATIONHELPER_HXX
+#define EXTENSIONS_SOURCE_PROPCTRLR_XSDVALIDATIONHELPER_HXX
+
+#include "eformshelper.hxx"
+#include "xsddatatypes.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/xsd/XDataType.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+/** === end UNO includes === **/
+#include <rtl/ref.hxx>
+
+//........................................................................
+namespace pcr
+{
+//........................................................................
+
+ class XSDDataType;
+ //====================================================================
+ //= XSDValidationHelper
+ //====================================================================
+ class XSDValidationHelper : public EFormsHelper
+ {
+ private:
+ bool m_bInspectingFormattedField;
+ public:
+ bool isInspectingFormattedField() const { return m_bInspectingFormattedField; }
+
+ public:
+ XSDValidationHelper(
+ ::osl::Mutex& _rMutex,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _rxIntrospectee,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& _rxContextDocument
+ );
+
+ /** retrieves the names of all XForms models in the document the control lives in
+ */
+ void getAvailableDataTypeNames( ::std::vector< ::rtl::OUString >& /* [out] */ _rNames ) const SAL_THROW(());
+
+ /** retrieves a particular data type given by name
+ */
+ ::rtl::Reference< XSDDataType >
+ getDataTypeByName( const ::rtl::OUString& _rName ) const SAL_THROW(());
+
+ /** retrieves the DataType instance which the control model is currently validated against
+
+ If there is a binding set at our control model, which at the same time acts as validator,
+ and if this validator is bound to an XDataType, then this data type is retrieved here.
+ */
+ ::rtl::Reference< XSDDataType >
+ getValidatingDataType( ) const SAL_THROW(());
+
+ /** retrieves the name of the data type which the control model is currently validated against
+
+ @seealso getValidatingDataType
+ */
+ ::rtl::OUString
+ getValidatingDataTypeName( ) const SAL_THROW(());
+
+ /** binds the validator to a new data type
+
+ To be called with an active binding only.
+ */
+ void setValidatingDataTypeByName( const ::rtl::OUString& _rName ) const SAL_THROW(());
+
+ /** removes the data type given by name from the data type repository
+ */
+ bool removeDataTypeFromRepository( const ::rtl::OUString& _rName ) const SAL_THROW(());
+
+ /** creates a new data type, which is a clone of an existing data type
+ */
+ bool cloneDataType( const ::rtl::Reference< XSDDataType >& _pDataType, const ::rtl::OUString& _rNewName ) const SAL_THROW(());
+
+ /** retrieves the name of the basic data type which has the given class
+ */
+ ::rtl::OUString
+ getBasicTypeNameForClass( sal_Int16 _eClass ) const SAL_THROW(());
+
+ /** copy a data type from one model to another
+
+ If a data type with the given name already exists in the target model, then nothing
+ happens. In particular, the facets of the data type are not copied.
+ */
+ void copyDataType( const ::rtl::OUString& _rFromModel, const ::rtl::OUString& _rToModel,
+ const ::rtl::OUString& _rDataTypeName ) const SAL_THROW(());
+
+ /** finds (and sets) a default format for the formatted field we're inspecting,
+ according to the current data type the control value is evaluated against
+ */
+ void findDefaultFormatForIntrospectee() SAL_THROW(());
+
+ private:
+ /** retrieves the data type repository associated with the current model
+ */
+ ::com::sun::star::uno::Reference< ::com::sun::star::xforms::XDataTypeRepository >
+ getDataTypeRepository() const SAL_THROW((::com::sun::star::uno::Exception));
+
+ /** retrieves the data type repository associated with any model
+ */
+ ::com::sun::star::uno::Reference< ::com::sun::star::xforms::XDataTypeRepository >
+ getDataTypeRepository( const ::rtl::OUString& _rModelName ) const SAL_THROW((::com::sun::star::uno::Exception));
+
+ /** retrieves the data type object for the given name
+ */
+ ::com::sun::star::uno::Reference< ::com::sun::star::xsd::XDataType >
+ getDataType( const ::rtl::OUString& _rName ) const
+ SAL_THROW((::com::sun::star::uno::Exception));
+
+ /** retrieves the name of the basic data type which has the given class, in the given repository
+ */
+ ::rtl::OUString
+ getBasicTypeNameForClass(
+ sal_Int16 _nClass,
+ ::com::sun::star::uno::Reference< ::com::sun::star::xforms::XDataTypeRepository > _rxRepository
+ ) const SAL_THROW(());
+ };
+
+//........................................................................
+} // namespace pcr
+//........................................................................
+
+#endif // EXTENSIONS_SOURCE_PROPCTRLR_XSDVALIDATIONHELPER_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/propctrlr/xsdvalidationpropertyhandler.cxx b/extensions/source/propctrlr/xsdvalidationpropertyhandler.cxx
new file mode 100644
index 000000000000..7555ecbad4ce
--- /dev/null
+++ b/extensions/source/propctrlr/xsdvalidationpropertyhandler.cxx
@@ -0,0 +1,695 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+#include "xsdvalidationpropertyhandler.hxx"
+#include "formstrings.hxx"
+#include "formmetadata.hxx"
+#include "xsddatatypes.hxx"
+#include "modulepcr.hxx"
+#include "formresid.hrc"
+#include "formlocalid.hrc"
+#include "propctrlr.hrc"
+#include "newdatatype.hxx"
+#include "xsdvalidationhelper.hxx"
+#include "pcrcommon.hxx"
+#include "handlerhelper.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+#include <com/sun/star/xsd/WhiteSpaceTreatment.hpp>
+#include <com/sun/star/xsd/DataTypeClass.hpp>
+#include <com/sun/star/inspection/PropertyControlType.hpp>
+#include <com/sun/star/beans/Optional.hpp>
+#include <com/sun/star/inspection/XObjectInspectorUI.hpp>
+#include <com/sun/star/inspection/PropertyLineElement.hpp>
+/** === end UNO includes === **/
+#include <vcl/msgbox.hxx>
+#include <tools/debug.hxx>
+#include <svtools/localresaccess.hxx>
+#include <sal/macros.h>
+
+#include <algorithm>
+#include <functional>
+#include <limits>
+
+//------------------------------------------------------------------------
+extern "C" void SAL_CALL createRegistryInfo_XSDValidationPropertyHandler()
+{
+ ::pcr::XSDValidationPropertyHandler::registerImplementation();
+}
+
+//........................................................................
+namespace pcr
+{
+//........................................................................
+
+ using namespace ::com::sun::star;
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::lang;
+ using namespace ::com::sun::star::beans;
+ using namespace ::com::sun::star::xforms;
+ using namespace ::com::sun::star::xsd;
+ using namespace ::com::sun::star::script;
+ using namespace ::com::sun::star::inspection;
+
+ using ::com::sun::star::beans::PropertyAttribute::MAYBEVOID;
+
+ //====================================================================
+ //= XSDValidationPropertyHandler
+ //====================================================================
+ DBG_NAME( XSDValidationPropertyHandler )
+ //--------------------------------------------------------------------
+ XSDValidationPropertyHandler::XSDValidationPropertyHandler( const Reference< XComponentContext >& _rxContext )
+ :XSDValidationPropertyHandler_Base( _rxContext )
+ {
+ DBG_CTOR( XSDValidationPropertyHandler, NULL );
+ }
+
+ //--------------------------------------------------------------------
+ XSDValidationPropertyHandler::~XSDValidationPropertyHandler()
+ {
+ DBG_DTOR( XSDValidationPropertyHandler, NULL );
+ }
+
+ //--------------------------------------------------------------------
+ ::rtl::OUString SAL_CALL XSDValidationPropertyHandler::getImplementationName_static( ) throw (RuntimeException)
+ {
+ return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.extensions.XSDValidationPropertyHandler" ) );
+ }
+
+ //--------------------------------------------------------------------
+ Sequence< ::rtl::OUString > SAL_CALL XSDValidationPropertyHandler::getSupportedServiceNames_static( ) throw (RuntimeException)
+ {
+ Sequence< ::rtl::OUString > aSupported( 1 );
+ aSupported[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.form.inspection.XSDValidationPropertyHandler" ) );
+ return aSupported;
+ }
+
+ //--------------------------------------------------------------------
+ Any SAL_CALL XSDValidationPropertyHandler::getPropertyValue( const ::rtl::OUString& _rPropertyName ) throw (UnknownPropertyException, RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ PropertyId nPropId( impl_getPropertyId_throw( _rPropertyName ) );
+
+ OSL_ENSURE( m_pHelper.get(), "XSDValidationPropertyHandler::getPropertyValue: inconsistency!" );
+ // if we survived impl_getPropertyId_throw, we should have a helper, since no helper implies no properties
+
+ Any aReturn;
+ ::rtl::Reference< XSDDataType > pType = m_pHelper->getValidatingDataType();
+ switch ( nPropId )
+ {
+ // common facets
+ case PROPERTY_ID_XSD_DATA_TYPE: aReturn = pType.is() ? pType->getFacet( PROPERTY_NAME ) : makeAny( ::rtl::OUString() ); break;
+ case PROPERTY_ID_XSD_WHITESPACES:aReturn = pType.is() ? pType->getFacet( PROPERTY_XSD_WHITESPACES ) : makeAny( WhiteSpaceTreatment::Preserve ); break;
+ case PROPERTY_ID_XSD_PATTERN: aReturn = pType.is() ? pType->getFacet( PROPERTY_XSD_PATTERN ) : makeAny( ::rtl::OUString() ); break;
+
+ // all other properties are simply forwarded, if they exist at the given type
+ default:
+ {
+ if ( pType.is() && pType->hasFacet( _rPropertyName ) )
+ aReturn = pType->getFacet( _rPropertyName );
+ }
+ break;
+ }
+
+ return aReturn;
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL XSDValidationPropertyHandler::setPropertyValue( const ::rtl::OUString& _rPropertyName, const Any& _rValue ) throw (UnknownPropertyException, RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ PropertyId nPropId( impl_getPropertyId_throw( _rPropertyName ) );
+
+ OSL_ENSURE( m_pHelper.get(), "XSDValidationPropertyHandler::getPropertyValue: inconsistency!" );
+ // if we survived impl_getPropertyId_throw, we should have a helper, since no helper implies no properties
+
+ if ( PROPERTY_ID_XSD_DATA_TYPE == nPropId )
+ {
+ ::rtl::OUString sTypeName;
+ OSL_VERIFY( _rValue >>= sTypeName );
+ m_pHelper->setValidatingDataTypeByName( sTypeName );
+ impl_setContextDocumentModified_nothrow();
+ return;
+ }
+
+ ::rtl::Reference< XSDDataType > pType = m_pHelper->getValidatingDataType();
+ if ( !pType.is() )
+ {
+ DBG_ERROR( "XSDValidationPropertyHandler::setPropertyValue: you're trying to set a type facet, without a current type!" );
+ return;
+ }
+
+ pType->setFacet( _rPropertyName, _rValue );
+ impl_setContextDocumentModified_nothrow();
+ }
+
+ //--------------------------------------------------------------------
+ void XSDValidationPropertyHandler::onNewComponent()
+ {
+ XSDValidationPropertyHandler_Base::onNewComponent();
+
+ Reference< frame::XModel > xDocument( impl_getContextDocument_nothrow() );
+ DBG_ASSERT( xDocument.is(), "XSDValidationPropertyHandler::onNewComponent: no document!" );
+ if ( EFormsHelper::isEForm( xDocument ) )
+ m_pHelper.reset( new XSDValidationHelper( m_aMutex, m_xComponent, xDocument ) );
+ else
+ m_pHelper.reset( NULL );
+ }
+
+ //--------------------------------------------------------------------
+ Sequence< Property > XSDValidationPropertyHandler::doDescribeSupportedProperties() const
+ {
+ ::std::vector< Property > aProperties;
+
+ if ( m_pHelper.get() )
+ {
+ bool bAllowBinding = m_pHelper->canBindToAnyDataType();
+
+ if ( bAllowBinding )
+ {
+ aProperties.reserve( 12 );
+
+ addStringPropertyDescription( aProperties, PROPERTY_XSD_DATA_TYPE );
+ addInt16PropertyDescription ( aProperties, PROPERTY_XSD_WHITESPACES );
+ addStringPropertyDescription( aProperties, PROPERTY_XSD_PATTERN );
+
+ // string facets
+ addInt32PropertyDescription( aProperties, PROPERTY_XSD_LENGTH, MAYBEVOID );
+ addInt32PropertyDescription( aProperties, PROPERTY_XSD_MIN_LENGTH, MAYBEVOID );
+ addInt32PropertyDescription( aProperties, PROPERTY_XSD_MAX_LENGTH, MAYBEVOID );
+
+ // decimal facets
+ addInt32PropertyDescription( aProperties, PROPERTY_XSD_TOTAL_DIGITS, MAYBEVOID );
+ addInt32PropertyDescription( aProperties, PROPERTY_XSD_FRACTION_DIGITS, MAYBEVOID );
+
+ // facets for different types
+ addInt16PropertyDescription( aProperties, PROPERTY_XSD_MAX_INCLUSIVE_INT, MAYBEVOID );
+ addInt16PropertyDescription( aProperties, PROPERTY_XSD_MAX_EXCLUSIVE_INT, MAYBEVOID );
+ addInt16PropertyDescription( aProperties, PROPERTY_XSD_MIN_INCLUSIVE_INT, MAYBEVOID );
+ addInt16PropertyDescription( aProperties, PROPERTY_XSD_MIN_EXCLUSIVE_INT, MAYBEVOID );
+ addDoublePropertyDescription( aProperties, PROPERTY_XSD_MAX_INCLUSIVE_DOUBLE, MAYBEVOID );
+ addDoublePropertyDescription( aProperties, PROPERTY_XSD_MAX_EXCLUSIVE_DOUBLE, MAYBEVOID );
+ addDoublePropertyDescription( aProperties, PROPERTY_XSD_MIN_INCLUSIVE_DOUBLE, MAYBEVOID );
+ addDoublePropertyDescription( aProperties, PROPERTY_XSD_MIN_EXCLUSIVE_DOUBLE, MAYBEVOID );
+ addDatePropertyDescription( aProperties, PROPERTY_XSD_MAX_INCLUSIVE_DATE, MAYBEVOID );
+ addDatePropertyDescription( aProperties, PROPERTY_XSD_MAX_EXCLUSIVE_DATE, MAYBEVOID );
+ addDatePropertyDescription( aProperties, PROPERTY_XSD_MIN_INCLUSIVE_DATE, MAYBEVOID );
+ addDatePropertyDescription( aProperties, PROPERTY_XSD_MIN_EXCLUSIVE_DATE, MAYBEVOID );
+ addTimePropertyDescription( aProperties, PROPERTY_XSD_MAX_INCLUSIVE_TIME, MAYBEVOID );
+ addTimePropertyDescription( aProperties, PROPERTY_XSD_MAX_EXCLUSIVE_TIME, MAYBEVOID );
+ addTimePropertyDescription( aProperties, PROPERTY_XSD_MIN_INCLUSIVE_TIME, MAYBEVOID );
+ addTimePropertyDescription( aProperties, PROPERTY_XSD_MIN_EXCLUSIVE_TIME, MAYBEVOID );
+ addDateTimePropertyDescription( aProperties, PROPERTY_XSD_MAX_INCLUSIVE_DATE_TIME, MAYBEVOID );
+ addDateTimePropertyDescription( aProperties, PROPERTY_XSD_MAX_EXCLUSIVE_DATE_TIME, MAYBEVOID );
+ addDateTimePropertyDescription( aProperties, PROPERTY_XSD_MIN_INCLUSIVE_DATE_TIME, MAYBEVOID );
+ addDateTimePropertyDescription( aProperties, PROPERTY_XSD_MIN_EXCLUSIVE_DATE_TIME, MAYBEVOID );
+ }
+ }
+
+ if ( aProperties.empty() )
+ return Sequence< Property >();
+ return Sequence< Property >( &(*aProperties.begin()), aProperties.size() );
+ }
+
+ //--------------------------------------------------------------------
+ Sequence< ::rtl::OUString > SAL_CALL XSDValidationPropertyHandler::getSupersededProperties( ) throw (RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ ::std::vector< ::rtl::OUString > aSuperfluous;
+ if ( m_pHelper.get() )
+ {
+ aSuperfluous.push_back( PROPERTY_CONTROLSOURCE );
+ aSuperfluous.push_back( PROPERTY_EMPTY_IS_NULL );
+ aSuperfluous.push_back( PROPERTY_FILTERPROPOSAL );
+ aSuperfluous.push_back( PROPERTY_LISTSOURCETYPE );
+ aSuperfluous.push_back( PROPERTY_LISTSOURCE );
+ aSuperfluous.push_back( PROPERTY_BOUNDCOLUMN );
+
+ bool bAllowBinding = m_pHelper->canBindToAnyDataType();
+
+ if ( bAllowBinding )
+ {
+ aSuperfluous.push_back( PROPERTY_MAXTEXTLEN );
+ aSuperfluous.push_back( PROPERTY_VALUEMIN );
+ aSuperfluous.push_back( PROPERTY_VALUEMAX );
+ aSuperfluous.push_back( PROPERTY_DECIMAL_ACCURACY );
+ aSuperfluous.push_back( PROPERTY_TIMEMIN );
+ aSuperfluous.push_back( PROPERTY_TIMEMAX );
+ aSuperfluous.push_back( PROPERTY_DATEMIN );
+ aSuperfluous.push_back( PROPERTY_DATEMAX );
+ aSuperfluous.push_back( PROPERTY_EFFECTIVE_MIN );
+ aSuperfluous.push_back( PROPERTY_EFFECTIVE_MAX );
+ }
+ }
+
+ if ( aSuperfluous.empty() )
+ return Sequence< ::rtl::OUString >();
+ return Sequence< ::rtl::OUString >( &(*aSuperfluous.begin()), aSuperfluous.size() );
+ }
+
+ //--------------------------------------------------------------------
+ Sequence< ::rtl::OUString > SAL_CALL XSDValidationPropertyHandler::getActuatingProperties( ) throw (RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ ::std::vector< ::rtl::OUString > aInterestedInActuations( 2 );
+ if ( m_pHelper.get() )
+ {
+ aInterestedInActuations.push_back( PROPERTY_XSD_DATA_TYPE );
+ aInterestedInActuations.push_back( PROPERTY_XML_DATA_MODEL );
+ }
+ if ( aInterestedInActuations.empty() )
+ return Sequence< ::rtl::OUString >();
+ return Sequence< ::rtl::OUString >( &(*aInterestedInActuations.begin()), aInterestedInActuations.size() );
+ }
+
+ //--------------------------------------------------------------------
+ namespace
+ {
+ void showPropertyUI( const Reference< XObjectInspectorUI >& _rxInspectorUI, const ::rtl::OUString& _rPropertyName, bool _bShow )
+ {
+ if ( _bShow )
+ _rxInspectorUI->showPropertyUI( _rPropertyName );
+ else
+ _rxInspectorUI->hidePropertyUI( _rPropertyName );
+ }
+ }
+
+ //--------------------------------------------------------------------
+ LineDescriptor SAL_CALL XSDValidationPropertyHandler::describePropertyLine( const ::rtl::OUString& _rPropertyName,
+ const Reference< XPropertyControlFactory >& _rxControlFactory )
+ throw (UnknownPropertyException, NullPointerException, RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ if ( !_rxControlFactory.is() )
+ throw NullPointerException();
+ if ( !m_pHelper.get() )
+ throw RuntimeException();
+
+ PropertyId nPropId( impl_getPropertyId_throw( _rPropertyName ) );
+
+ LineDescriptor aDescriptor;
+ if ( nPropId != PROPERTY_ID_XSD_DATA_TYPE )
+ aDescriptor.IndentLevel = 1;
+
+ // collect some information about the to-be-created control
+ sal_Int16 nControlType = PropertyControlType::TextField;
+ ::std::vector< ::rtl::OUString > aListEntries;
+ Optional< double > aMinValue( sal_False, 0 );
+ Optional< double > aMaxValue( sal_False, 0 );
+
+ switch ( nPropId )
+ {
+ case PROPERTY_ID_XSD_DATA_TYPE:
+ nControlType = PropertyControlType::ListBox;
+
+ implGetAvailableDataTypeNames( aListEntries );
+
+ aDescriptor.PrimaryButtonId = UID_PROP_ADD_DATA_TYPE;
+ aDescriptor.SecondaryButtonId = UID_PROP_REMOVE_DATA_TYPE;
+ aDescriptor.HasPrimaryButton = aDescriptor.HasSecondaryButton = sal_True;
+ aDescriptor.PrimaryButtonImageURL = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "private:graphicrepository/extensions/res/buttonplus.png" ) );
+ aDescriptor.SecondaryButtonImageURL = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "private:graphicrepository/extensions/res/buttonminus.png" ) );
+ break;
+
+ case PROPERTY_ID_XSD_WHITESPACES:
+ {
+ nControlType = PropertyControlType::ListBox;
+ aListEntries = m_pInfoService->getPropertyEnumRepresentations( PROPERTY_ID_XSD_WHITESPACES );
+ }
+ break;
+
+ case PROPERTY_ID_XSD_PATTERN:
+ nControlType = PropertyControlType::TextField;
+ break;
+
+ case PROPERTY_ID_XSD_LENGTH:
+ case PROPERTY_ID_XSD_MIN_LENGTH:
+ case PROPERTY_ID_XSD_MAX_LENGTH:
+ nControlType = PropertyControlType::NumericField;
+ break;
+
+ case PROPERTY_ID_XSD_TOTAL_DIGITS:
+ case PROPERTY_ID_XSD_FRACTION_DIGITS:
+ nControlType = PropertyControlType::NumericField;
+ break;
+
+ case PROPERTY_ID_XSD_MAX_INCLUSIVE_INT:
+ case PROPERTY_ID_XSD_MAX_EXCLUSIVE_INT:
+ case PROPERTY_ID_XSD_MIN_INCLUSIVE_INT:
+ case PROPERTY_ID_XSD_MIN_EXCLUSIVE_INT:
+ {
+ nControlType = PropertyControlType::NumericField;
+
+ // handle limits for various 'INT' types according to
+ // their actual semantics (year, month, day)
+
+ ::rtl::Reference< XSDDataType > xDataType( m_pHelper->getValidatingDataType() );
+ sal_Int16 nTypeClass = xDataType.is() ? xDataType->classify() : DataTypeClass::STRING;
+
+ aMinValue.IsPresent = aMaxValue.IsPresent = sal_True;
+ aMinValue.Value = DataTypeClass::gYear == nTypeClass ? 0 : 1;
+ aMaxValue.Value = ::std::numeric_limits< sal_Int32 >::max();
+ if ( DataTypeClass::gMonth == nTypeClass )
+ aMaxValue.Value = 12;
+ else if ( DataTypeClass::gDay == nTypeClass )
+ aMaxValue.Value = 31;
+ }
+ break;
+
+ case PROPERTY_ID_XSD_MAX_INCLUSIVE_DOUBLE:
+ case PROPERTY_ID_XSD_MAX_EXCLUSIVE_DOUBLE:
+ case PROPERTY_ID_XSD_MIN_INCLUSIVE_DOUBLE:
+ case PROPERTY_ID_XSD_MIN_EXCLUSIVE_DOUBLE:
+ nControlType = PropertyControlType::NumericField;
+ // TODO/eForms: do we have "auto-digits"?
+ break;
+
+ case PROPERTY_ID_XSD_MAX_INCLUSIVE_DATE:
+ case PROPERTY_ID_XSD_MAX_EXCLUSIVE_DATE:
+ case PROPERTY_ID_XSD_MIN_INCLUSIVE_DATE:
+ case PROPERTY_ID_XSD_MIN_EXCLUSIVE_DATE:
+ nControlType = PropertyControlType::DateField;
+ break;
+
+ case PROPERTY_ID_XSD_MAX_INCLUSIVE_TIME:
+ case PROPERTY_ID_XSD_MAX_EXCLUSIVE_TIME:
+ case PROPERTY_ID_XSD_MIN_INCLUSIVE_TIME:
+ case PROPERTY_ID_XSD_MIN_EXCLUSIVE_TIME:
+ nControlType = PropertyControlType::TimeField;
+ break;
+
+ case PROPERTY_ID_XSD_MAX_INCLUSIVE_DATE_TIME:
+ case PROPERTY_ID_XSD_MAX_EXCLUSIVE_DATE_TIME:
+ case PROPERTY_ID_XSD_MIN_INCLUSIVE_DATE_TIME:
+ case PROPERTY_ID_XSD_MIN_EXCLUSIVE_DATE_TIME:
+ nControlType = PropertyControlType::DateTimeField;
+ break;
+
+ default:
+ DBG_ERROR( "XSDValidationPropertyHandler::describePropertyLine: cannot handle this property!" );
+ break;
+ }
+
+ switch ( nControlType )
+ {
+ case PropertyControlType::ListBox:
+ aDescriptor.Control = PropertyHandlerHelper::createListBoxControl( _rxControlFactory, aListEntries, sal_False, sal_False );
+ break;
+ case PropertyControlType::NumericField:
+ aDescriptor.Control = PropertyHandlerHelper::createNumericControl( _rxControlFactory, 0, aMinValue, aMaxValue, sal_False );
+ break;
+ default:
+ aDescriptor.Control = _rxControlFactory->createPropertyControl( nControlType, sal_False );
+ break;
+ }
+
+ aDescriptor.Category = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Data" ) );
+ aDescriptor.DisplayName = m_pInfoService->getPropertyTranslation( nPropId );
+ aDescriptor.HelpURL = HelpIdUrl::getHelpURL( m_pInfoService->getPropertyHelpId( nPropId ) );
+
+ return aDescriptor;
+ }
+
+ //--------------------------------------------------------------------
+ InteractiveSelectionResult SAL_CALL XSDValidationPropertyHandler::onInteractivePropertySelection( const ::rtl::OUString& _rPropertyName, sal_Bool _bPrimary, Any& /*_rData*/, const Reference< XObjectInspectorUI >& _rxInspectorUI ) throw (UnknownPropertyException, NullPointerException, RuntimeException)
+ {
+ if ( !_rxInspectorUI.is() )
+ throw NullPointerException();
+
+ ::osl::MutexGuard aGuard( m_aMutex );
+ OSL_ENSURE( m_pHelper.get(), "XSDValidationPropertyHandler::onInteractivePropertySelection: we don't have any SupportedProperties!" );
+ if ( !m_pHelper.get() )
+ return InteractiveSelectionResult_Cancelled;
+
+ PropertyId nPropId( impl_getPropertyId_throw( _rPropertyName ) );
+
+ switch ( nPropId )
+ {
+ case PROPERTY_ID_XSD_DATA_TYPE:
+ {
+ if ( _bPrimary )
+ {
+ ::rtl::OUString sNewDataTypeName;
+ if ( implPrepareCloneDataCurrentType( sNewDataTypeName ) )
+ {
+ implDoCloneCurrentDataType( sNewDataTypeName );
+ return InteractiveSelectionResult_Success;
+ }
+ }
+ else
+ return implPrepareRemoveCurrentDataType() && implDoRemoveCurrentDataType() ? InteractiveSelectionResult_Success : InteractiveSelectionResult_Cancelled;
+ }
+ break;
+
+ default:
+ DBG_ERROR( "XSDValidationPropertyHandler::onInteractivePropertySelection: unexpected property to build a dedicated UI!" );
+ break;
+ }
+ return InteractiveSelectionResult_Cancelled;
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL XSDValidationPropertyHandler::addPropertyChangeListener( const Reference< XPropertyChangeListener >& _rxListener ) throw (RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ XSDValidationPropertyHandler_Base::addPropertyChangeListener( _rxListener );
+ if ( m_pHelper.get() )
+ m_pHelper->registerBindingListener( _rxListener );
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL XSDValidationPropertyHandler::removePropertyChangeListener( const Reference< XPropertyChangeListener >& _rxListener ) throw (RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ if ( m_pHelper.get() )
+ m_pHelper->revokeBindingListener( _rxListener );
+ XSDValidationPropertyHandler_Base::removePropertyChangeListener( _rxListener );
+ }
+
+ //--------------------------------------------------------------------
+ bool XSDValidationPropertyHandler::implPrepareCloneDataCurrentType( ::rtl::OUString& _rNewName ) SAL_THROW(())
+ {
+ OSL_PRECOND( m_pHelper.get(), "XSDValidationPropertyHandler::implPrepareCloneDataCurrentType: this will crash!" );
+
+ ::rtl::Reference< XSDDataType > pType = m_pHelper->getValidatingDataType();
+ if ( !pType.is() )
+ {
+ DBG_ERROR( "XSDValidationPropertyHandler::implPrepareCloneDataCurrentType: invalid current data type!" );
+ return false;
+ }
+
+ ::std::vector< ::rtl::OUString > aExistentNames;
+ m_pHelper->getAvailableDataTypeNames( aExistentNames );
+
+ NewDataTypeDialog aDialog( NULL, pType->getName(), aExistentNames ); // TODO/eForms: proper parent
+ if ( aDialog.Execute() != RET_OK )
+ return false;
+
+ _rNewName = aDialog.GetName();
+ return true;
+ }
+
+ //--------------------------------------------------------------------
+ bool XSDValidationPropertyHandler::implDoCloneCurrentDataType( const ::rtl::OUString& _rNewName ) SAL_THROW(())
+ {
+ OSL_PRECOND( m_pHelper.get(), "XSDValidationPropertyHandler::implDoCloneCurrentDataType: this will crash!" );
+
+ ::rtl::Reference< XSDDataType > pType = m_pHelper->getValidatingDataType();
+ if ( !pType.is() )
+ return false;
+
+ if ( !m_pHelper->cloneDataType( pType, _rNewName ) )
+ return false;
+
+ m_pHelper->setValidatingDataTypeByName( _rNewName );
+ return true;
+ }
+
+ //--------------------------------------------------------------------
+ bool XSDValidationPropertyHandler::implPrepareRemoveCurrentDataType() SAL_THROW(())
+ {
+ OSL_PRECOND( m_pHelper.get(), "XSDValidationPropertyHandler::implPrepareRemoveCurrentDataType: this will crash!" );
+
+ ::rtl::Reference< XSDDataType > pType = m_pHelper->getValidatingDataType();
+ if ( !pType.is() )
+ {
+ DBG_ERROR( "XSDValidationPropertyHandler::implPrepareRemoveCurrentDataType: invalid current data type!" );
+ return false;
+ }
+
+ // confirmation message
+ String sConfirmation( PcrRes( RID_STR_CONFIRM_DELETE_DATA_TYPE ) );
+ sConfirmation.SearchAndReplaceAscii( "#type#", pType->getName() );
+ QueryBox aQuery( NULL, WB_YES_NO, sConfirmation ); // TODO/eForms: proper parent
+ if ( aQuery.Execute() != RET_YES )
+ return false;
+
+ return true;
+ }
+
+ //--------------------------------------------------------------------
+ bool XSDValidationPropertyHandler::implDoRemoveCurrentDataType() SAL_THROW(())
+ {
+ OSL_PRECOND( m_pHelper.get(), "XSDValidationPropertyHandler::implDoRemoveCurrentDataType: this will crash!" );
+
+ ::rtl::Reference< XSDDataType > pType = m_pHelper->getValidatingDataType();
+ if ( !pType.is() )
+ return false;
+
+ // set a new data type at the binding, which is the "basic" type for the one
+ // we are going to delete
+ // (do this before the actual deletion, so the old type is still valid for property change
+ // notifications)
+ m_pHelper->setValidatingDataTypeByName( m_pHelper->getBasicTypeNameForClass( pType->classify() ) );
+ // now remove the type
+ m_pHelper->removeDataTypeFromRepository( pType->getName() );
+
+ return true;
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL XSDValidationPropertyHandler::actuatingPropertyChanged( const ::rtl::OUString& _rActuatingPropertyName, const Any& _rNewValue, const Any& _rOldValue, const Reference< XObjectInspectorUI >& _rxInspectorUI, sal_Bool _bFirstTimeInit ) throw (NullPointerException, RuntimeException)
+ {
+ if ( !_rxInspectorUI.is() )
+ throw NullPointerException();
+
+ ::osl::MutexGuard aGuard( m_aMutex );
+ PropertyId nActuatingPropId( impl_getPropertyId_throw( _rActuatingPropertyName ) );
+ if ( !m_pHelper.get() )
+ throw RuntimeException();
+ // if we survived impl_getPropertyId_throw, we should have a helper, since no helper implies no properties
+
+ switch ( nActuatingPropId )
+ {
+ case PROPERTY_ID_XSD_DATA_TYPE:
+ {
+ ::rtl::Reference< XSDDataType > xDataType( m_pHelper->getValidatingDataType() );
+
+ // is removal of this type possible?
+ sal_Bool bIsBasicType = xDataType.is() && xDataType->isBasicType();
+ _rxInspectorUI->enablePropertyUIElements( PROPERTY_XSD_DATA_TYPE, PropertyLineElement::PrimaryButton, xDataType.is() );
+ _rxInspectorUI->enablePropertyUIElements( PROPERTY_XSD_DATA_TYPE, PropertyLineElement::SecondaryButton, xDataType.is() && !bIsBasicType );
+
+ //------------------------------------------------------------
+ // show the facets which are available at the data type
+ ::rtl::OUString aFacets[] = {
+ PROPERTY_XSD_WHITESPACES, PROPERTY_XSD_PATTERN,
+ PROPERTY_XSD_LENGTH, PROPERTY_XSD_MIN_LENGTH, PROPERTY_XSD_MAX_LENGTH, PROPERTY_XSD_TOTAL_DIGITS,
+ PROPERTY_XSD_FRACTION_DIGITS,
+ PROPERTY_XSD_MAX_INCLUSIVE_INT,
+ PROPERTY_XSD_MAX_EXCLUSIVE_INT,
+ PROPERTY_XSD_MIN_INCLUSIVE_INT,
+ PROPERTY_XSD_MIN_EXCLUSIVE_INT,
+ PROPERTY_XSD_MAX_INCLUSIVE_DOUBLE,
+ PROPERTY_XSD_MAX_EXCLUSIVE_DOUBLE,
+ PROPERTY_XSD_MIN_INCLUSIVE_DOUBLE,
+ PROPERTY_XSD_MIN_EXCLUSIVE_DOUBLE,
+ PROPERTY_XSD_MAX_INCLUSIVE_DATE,
+ PROPERTY_XSD_MAX_EXCLUSIVE_DATE,
+ PROPERTY_XSD_MIN_INCLUSIVE_DATE,
+ PROPERTY_XSD_MIN_EXCLUSIVE_DATE,
+ PROPERTY_XSD_MAX_INCLUSIVE_TIME,
+ PROPERTY_XSD_MAX_EXCLUSIVE_TIME,
+ PROPERTY_XSD_MIN_INCLUSIVE_TIME,
+ PROPERTY_XSD_MIN_EXCLUSIVE_TIME,
+ PROPERTY_XSD_MAX_INCLUSIVE_DATE_TIME,
+ PROPERTY_XSD_MAX_EXCLUSIVE_DATE_TIME,
+ PROPERTY_XSD_MIN_INCLUSIVE_DATE_TIME,
+ PROPERTY_XSD_MIN_EXCLUSIVE_DATE_TIME
+ };
+
+ size_t i=0;
+ const ::rtl::OUString* pLoop = NULL;
+ for ( i = 0, pLoop = aFacets;
+ i < SAL_N_ELEMENTS( aFacets );
+ ++i, ++pLoop
+ )
+ {
+ showPropertyUI( _rxInspectorUI, *pLoop, xDataType.is() && xDataType->hasFacet( *pLoop ) );
+ _rxInspectorUI->enablePropertyUI( *pLoop, !bIsBasicType );
+ }
+ }
+ break;
+
+ case PROPERTY_ID_XML_DATA_MODEL:
+ {
+ // The data type which the current binding works with may not be present in the
+ // new model. Thus, transfer it.
+ ::rtl::OUString sOldModelName; _rOldValue >>= sOldModelName;
+ ::rtl::OUString sNewModelName; _rNewValue >>= sNewModelName;
+ ::rtl::OUString sDataType = m_pHelper->getValidatingDataTypeName();
+ m_pHelper->copyDataType( sOldModelName, sNewModelName, sDataType );
+
+ // the list of available data types depends on the chosen model, so update this
+ if ( !_bFirstTimeInit )
+ _rxInspectorUI->rebuildPropertyUI( PROPERTY_XSD_DATA_TYPE );
+ }
+ break;
+
+ default:
+ DBG_ERROR( "XSDValidationPropertyHandler::actuatingPropertyChanged: cannot handle this property!" );
+ return;
+ }
+
+ // in both cases, we need to care for the current value of the XSD_DATA_TYPE property,
+ // and update the FormatKey of the formatted field we're inspecting (if any)
+ if ( !_bFirstTimeInit && m_pHelper->isInspectingFormattedField() )
+ m_pHelper->findDefaultFormatForIntrospectee();
+ }
+
+ //--------------------------------------------------------------------
+ void XSDValidationPropertyHandler::implGetAvailableDataTypeNames( ::std::vector< ::rtl::OUString >& /* [out] */ _rNames ) const SAL_THROW(())
+ {
+ OSL_PRECOND( m_pHelper.get(), "XSDValidationPropertyHandler::implGetAvailableDataTypeNames: this will crash!" );
+ // start with *all* types which are available at the model
+ ::std::vector< ::rtl::OUString > aAllTypes;
+ m_pHelper->getAvailableDataTypeNames( aAllTypes );
+ _rNames.clear();
+ _rNames.reserve( aAllTypes.size() );
+
+ // then allow only those which are "compatible" with our control
+ for ( ::std::vector< ::rtl::OUString >::const_iterator dataType = aAllTypes.begin();
+ dataType != aAllTypes.end();
+ ++dataType
+ )
+ {
+ ::rtl::Reference< XSDDataType > pType = m_pHelper->getDataTypeByName( *dataType );
+ if ( pType.is() && m_pHelper->canBindToDataType( pType->classify() ) )
+ _rNames.push_back( *dataType );
+ }
+ }
+
+//........................................................................
+} // namespace pcr
+//........................................................................
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/propctrlr/xsdvalidationpropertyhandler.hxx b/extensions/source/propctrlr/xsdvalidationpropertyhandler.hxx
new file mode 100644
index 000000000000..9763d43ba303
--- /dev/null
+++ b/extensions/source/propctrlr/xsdvalidationpropertyhandler.hxx
@@ -0,0 +1,105 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef EXTENSIONS_SOURCE_PROPCTRLR_XSDVALIDATIONPROPERTYHANDLER_HXX
+#define EXTENSIONS_SOURCE_PROPCTRLR_XSDVALIDATIONPROPERTYHANDLER_HXX
+
+#include "propertyhandler.hxx"
+
+/** === begin UNO includes === **/
+/** === end UNO includes === **/
+
+#include <memory>
+
+//........................................................................
+namespace pcr
+{
+//........................................................................
+
+ class XSDValidationHelper;
+ //====================================================================
+ //= XSDValidationPropertyHandler
+ //====================================================================
+ class XSDValidationPropertyHandler;
+ typedef HandlerComponentBase< XSDValidationPropertyHandler > XSDValidationPropertyHandler_Base;
+ class XSDValidationPropertyHandler : public XSDValidationPropertyHandler_Base
+ {
+ private:
+ ::std::auto_ptr< XSDValidationHelper > m_pHelper;
+
+ public:
+ XSDValidationPropertyHandler(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _rxContext
+ );
+
+ static ::rtl::OUString SAL_CALL getImplementationName_static( ) throw (::com::sun::star::uno::RuntimeException);
+ static ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames_static( ) throw (::com::sun::star::uno::RuntimeException);
+
+ protected:
+ ~XSDValidationPropertyHandler();
+
+ protected:
+ // XPropertyHandler overriables
+ virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue( const ::rtl::OUString& _rPropertyName ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setPropertyValue( const ::rtl::OUString& _rPropertyName, const ::com::sun::star::uno::Any& _rValue ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString >
+ SAL_CALL getSupersededProperties( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString >
+ SAL_CALL getActuatingProperties( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::inspection::LineDescriptor
+ SAL_CALL describePropertyLine( const ::rtl::OUString& _rPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XPropertyControlFactory >& _rxControlFactory ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::NullPointerException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::inspection::InteractiveSelectionResult
+ SAL_CALL onInteractivePropertySelection( const ::rtl::OUString& _rPropertyName, sal_Bool _bPrimary, ::com::sun::star::uno::Any& _rData, const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XObjectInspectorUI >& _rxInspectorUI ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::NullPointerException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL actuatingPropertyChanged( const ::rtl::OUString& _rActuatingPropertyName, const ::com::sun::star::uno::Any& _rNewValue, const ::com::sun::star::uno::Any& _rOldValue, const ::com::sun::star::uno::Reference< ::com::sun::star::inspection::XObjectInspectorUI >& _rxInspectorUI, sal_Bool ) throw (::com::sun::star::lang::NullPointerException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL addPropertyChangeListener( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& _rxListener ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL removePropertyChangeListener( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& _rxListener ) throw (::com::sun::star::uno::RuntimeException);
+
+ // PropertyHandler overridables
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property >
+ SAL_CALL doDescribeSupportedProperties() const;
+ virtual void onNewComponent();
+
+ private:
+ bool implPrepareRemoveCurrentDataType() SAL_THROW(());
+ bool implDoRemoveCurrentDataType() SAL_THROW(());
+
+ bool implPrepareCloneDataCurrentType( ::rtl::OUString& _rNewName ) SAL_THROW(());
+ bool implDoCloneCurrentDataType( const ::rtl::OUString& _rNewName ) SAL_THROW(());
+
+ /** retrieves the names of the data types which our introspectee can be validated against
+ */
+ void implGetAvailableDataTypeNames( ::std::vector< ::rtl::OUString >& /* [out] */ _rNames ) const SAL_THROW(());
+ };
+
+//........................................................................
+} // namespace pcr
+//........................................................................
+
+#endif // EXTENSIONS_SOURCE_PROPCTRLR_XSDVALIDATIONPROPERTYHANDLER_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/resource/exports.dxp b/extensions/source/resource/exports.dxp
new file mode 100644
index 000000000000..9e59e94034a6
--- /dev/null
+++ b/extensions/source/resource/exports.dxp
@@ -0,0 +1,3 @@
+component_writeInfo
+component_getImplementationEnvironment
+component_getFactory
diff --git a/extensions/source/resource/makefile.mk b/extensions/source/resource/makefile.mk
new file mode 100644
index 000000000000..a89d690b7393
--- /dev/null
+++ b/extensions/source/resource/makefile.mk
@@ -0,0 +1,76 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+PRJ=..$/..
+
+PRJNAME=extensions
+TARGET=res
+LIBTARGET=NO
+USE_LDUMP2=TRUE
+USE_DEFFILE=TRUE
+ENABLE_EXCEPTIONS=TRUE
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : $(PRJ)$/util$/makefile.pmk
+
+# --- Files --------------------------------------------------------
+
+SLOFILES= $(SLO)$/resource.obj \
+ $(SLO)$/oooresourceloader.obj \
+ $(SLO)$/res_services.obj
+
+LIB1TARGET= $(SLB)$/$(TARGET).lib
+LIB1OBJFILES= $(SLOFILES)
+
+SHL1TARGET= $(TARGET)$(DLLPOSTFIX)
+
+SHL1STDLIBS= \
+ $(CPPULIB) \
+ $(CPPUHELPERLIB) \
+ $(SALLIB) \
+ $(VCLLIB) \
+ $(TOOLSLIB)
+
+SHL1DEPN=
+SHL1IMPLIB= ires
+SHL1LIBS= $(LIB1TARGET)
+SHL1DEF= $(MISC)$/$(SHL1TARGET).def
+
+SHL1DEF=$(MISC)$/$(SHL1TARGET).def
+SHL1IMPLIB=i$(TARGET)
+SHL1LIBS=$(SLB)$/$(TARGET).lib
+SHL1VERSIONMAP=$(SOLARENV)/src/component.map
+
+DEF1NAME= $(SHL1TARGET)
+DEF1EXPORTFILE= exports.dxp
+
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : target.mk
+.INCLUDE : $(PRJ)$/util$/target.pmk
+
diff --git a/extensions/source/resource/oooresourceloader.cxx b/extensions/source/resource/oooresourceloader.cxx
new file mode 100644
index 000000000000..59b71c143516
--- /dev/null
+++ b/extensions/source/resource/oooresourceloader.cxx
@@ -0,0 +1,492 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+
+#ifndef EXTENSIONS_SOURCE_RESOURCE_OOORESOURCELOADER_CXX
+#define EXTENSIONS_SOURCE_RESOURCE_OOORESOURCELOADER_CXX
+#include "res_services.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/resource/XResourceBundleLoader.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/uno/XComponentContext.hpp>
+/** === end UNO includes === **/
+#include <vcl/svapp.hxx>
+#include <tools/simplerm.hxx>
+#include <tools/rcid.h>
+#include <cppuhelper/implbase1.hxx>
+#include <cppuhelper/weakref.hxx>
+
+#include <boost/shared_ptr.hpp>
+#include <map>
+
+//........................................................................
+namespace res
+{
+//........................................................................
+
+ /** === begin UNO using === **/
+ using ::com::sun::star::uno::Reference;
+ using ::com::sun::star::resource::XResourceBundleLoader;
+ using ::com::sun::star::resource::XResourceBundle;
+ using ::com::sun::star::resource::MissingResourceException;
+ using ::com::sun::star::uno::XComponentContext;
+ using ::com::sun::star::uno::Sequence;
+ using ::com::sun::star::uno::XInterface;
+ using ::com::sun::star::uno::RuntimeException;
+ using ::com::sun::star::lang::Locale;
+ using ::com::sun::star::uno::Any;
+ using ::com::sun::star::container::NoSuchElementException;
+ using ::com::sun::star::lang::WrappedTargetException;
+ using ::com::sun::star::uno::Type;
+ using ::com::sun::star::uno::WeakReference;
+ /** === end UNO using === **/
+
+ //====================================================================
+ //= helper
+ //====================================================================
+ typedef ::std::pair< ::rtl::OUString, Locale > ResourceBundleDescriptor;
+
+ struct ResourceBundleDescriptorLess : public ::std::binary_function< ResourceBundleDescriptor, ResourceBundleDescriptor, bool >
+ {
+ bool operator()( const ResourceBundleDescriptor& _lhs, const ResourceBundleDescriptor& _rhs ) const
+ {
+ if ( _lhs.first < _rhs.first )
+ return true;
+ if ( _lhs.second.Language < _rhs.second.Language )
+ return true;
+ if ( _lhs.second.Country < _rhs.second.Country )
+ return true;
+ if ( _lhs.second.Variant < _rhs.second.Variant )
+ return true;
+ return false;
+ }
+ };
+
+ //====================================================================
+ //= OpenOfficeResourceLoader
+ //====================================================================
+ typedef ::cppu::WeakImplHelper1 < XResourceBundleLoader
+ > OpenOfficeResourceLoader_Base;
+ class OpenOfficeResourceLoader : public OpenOfficeResourceLoader_Base
+ {
+ private:
+ typedef ::std::map< ResourceBundleDescriptor, WeakReference< XResourceBundle >, ResourceBundleDescriptorLess >
+ ResourceBundleCache;
+
+ private:
+ Reference< XComponentContext > m_xContext;
+ ::osl::Mutex m_aMutex;
+ ResourceBundleCache m_aBundleCache;
+
+ protected:
+ OpenOfficeResourceLoader( const Reference< XComponentContext >& _rxContext );
+
+ public:
+ static Sequence< ::rtl::OUString > getSupportedServiceNames_static();
+ static ::rtl::OUString getImplementationName_static();
+ static ::rtl::OUString getSingletonName_static();
+ static Reference< XInterface > Create( const Reference< XComponentContext >& _rxContext );
+
+ // XResourceBundleLoader
+ virtual Reference< XResourceBundle > SAL_CALL loadBundle_Default( const ::rtl::OUString& aBaseName ) throw (MissingResourceException, RuntimeException);
+ virtual Reference< XResourceBundle > SAL_CALL loadBundle( const ::rtl::OUString& abaseName, const Locale& aLocale ) throw (MissingResourceException, RuntimeException);
+
+ private:
+ OpenOfficeResourceLoader(); // never implemented
+ OpenOfficeResourceLoader( const OpenOfficeResourceLoader& ); // never implemented
+ OpenOfficeResourceLoader& operator=( const OpenOfficeResourceLoader& ); // never implemented
+ };
+
+ //====================================================================
+ //= IResourceType
+ //====================================================================
+ /** encapsulates access to a fixed resource type
+ */
+ class IResourceType
+ {
+ public:
+ /** returns the RESOURCE_TYPE associated with this instance
+ */
+ virtual RESOURCE_TYPE getResourceType() const = 0;
+
+ /** reads a single resource from the given resource manager
+ @param _resourceManager
+ the resource manager to read from
+ @param _resourceId
+ the id of the resource to read
+ @return
+ the required resource
+ @precond
+ the caler checked via <code>_resourceManager.IsAvailable( getResourceType(), _resourceId )</code>
+ that the required resource really exists
+ */
+ virtual Any getResource( SimpleResMgr& _resourceManager, sal_Int32 _resourceId ) const = 0;
+
+ virtual ~IResourceType() { };
+ };
+
+ //====================================================================
+ //= StringResourceAccess
+ //====================================================================
+ class StringResourceAccess : public IResourceType
+ {
+ public:
+ StringResourceAccess();
+
+ // IResourceType
+ virtual RESOURCE_TYPE getResourceType() const;
+ virtual Any getResource( SimpleResMgr& _resourceManager, sal_Int32 _resourceId ) const;
+ };
+
+ //--------------------------------------------------------------------
+ StringResourceAccess::StringResourceAccess()
+ {
+ }
+
+ //--------------------------------------------------------------------
+ RESOURCE_TYPE StringResourceAccess::getResourceType() const
+ {
+ return RSC_STRING;
+ }
+
+ //--------------------------------------------------------------------
+ Any StringResourceAccess::getResource( SimpleResMgr& _resourceManager, sal_Int32 _resourceId ) const
+ {
+ OSL_PRECOND( _resourceManager.IsAvailable( getResourceType(), _resourceId ), "StringResourceAccess::getResource: precondition not met!" );
+ Any aResource;
+ aResource <<= ::rtl::OUString( _resourceManager.ReadString( _resourceId ) );
+ return aResource;
+ }
+
+ //====================================================================
+ //= OpenOfficeResourceBundle
+ //====================================================================
+ typedef ::cppu::WeakImplHelper1 < XResourceBundle
+ > OpenOfficeResourceBundle_Base;
+ class OpenOfficeResourceBundle : public OpenOfficeResourceBundle_Base
+ {
+ private:
+ typedef ::boost::shared_ptr< IResourceType > ResourceTypePtr;
+ typedef ::std::map< ::rtl::OUString, ResourceTypePtr > ResourceTypes;
+
+ ::osl::Mutex m_aMutex;
+ Reference< XResourceBundle > m_xParent;
+ Locale m_aLocale;
+ SimpleResMgr* m_pResourceManager;
+ ResourceTypes m_aResourceTypes;
+
+ public:
+ OpenOfficeResourceBundle(
+ const Reference< XComponentContext >& _rxContext,
+ const ::rtl::OUString& _rBaseName,
+ const Locale& _rLocale
+ );
+
+ protected:
+ ~OpenOfficeResourceBundle();
+
+ public:
+ // XResourceBundle
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::resource::XResourceBundle > SAL_CALL getParent() throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setParent( const ::com::sun::star::uno::Reference< ::com::sun::star::resource::XResourceBundle >& _parent ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::lang::Locale SAL_CALL getLocale( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Any SAL_CALL getDirectElement( const ::rtl::OUString& key ) throw (::com::sun::star::uno::RuntimeException);
+
+ // XNameAccess (base of XResourceBundle)
+ virtual ::com::sun::star::uno::Any SAL_CALL getByName( const ::rtl::OUString& aName ) throw (::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getElementNames( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::sal_Bool SAL_CALL hasByName( const ::rtl::OUString& aName ) throw (::com::sun::star::uno::RuntimeException);
+
+ // XElementAccess (base of XNameAccess)
+ virtual ::com::sun::star::uno::Type SAL_CALL getElementType( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::sal_Bool SAL_CALL hasElements( ) throw (::com::sun::star::uno::RuntimeException);
+
+ private:
+ /** retrievs the element with the given key, without asking our parent bundle
+ @param _key
+ the key of the element to retrieve
+ @param _out_Element
+ will contained the retrieved element upon successful return. If the method is unsuccessful, the
+ value will not be touched.
+ @return
+ <TRUE/> if and only if the element could be retrieved
+ @precond
+ our mutex is locked
+ */
+ bool impl_getDirectElement_nothrow( const ::rtl::OUString& _key, Any& _out_Element ) const;
+
+ /** retrieves the resource type and id from a given resource key, which assembles those two
+ @param _key
+ the resource key as got via a public API call
+ @param _out_resourceType
+ the resource type, if successful
+ @param _out_resourceId
+ the resource id, if successful
+ @return
+ <TRUE/> if and only if the given key specifies a known resource type, and contains a valid
+ resource id
+ */
+ bool impl_getResourceTypeAndId_nothrow( const ::rtl::OUString& _key, ResourceTypePtr& _out_resourceType, sal_Int32& _out_resourceId ) const;
+ };
+
+ //====================================================================
+ //= OpenOfficeResourceLoader
+ //====================================================================
+ //--------------------------------------------------------------------
+ OpenOfficeResourceLoader::OpenOfficeResourceLoader( const Reference< XComponentContext >& _rxContext )
+ :m_xContext( _rxContext )
+ {
+ }
+
+ //--------------------------------------------------------------------
+ Sequence< ::rtl::OUString > OpenOfficeResourceLoader::getSupportedServiceNames_static()
+ {
+ Sequence< ::rtl::OUString > aServices( 1 );
+ aServices[ 0 ] = getSingletonName_static();
+ return aServices;
+ }
+
+ //--------------------------------------------------------------------
+ ::rtl::OUString OpenOfficeResourceLoader::getImplementationName_static()
+ {
+ return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.resource.OpenOfficeResourceLoader" ) );
+ }
+
+ //--------------------------------------------------------------------
+ ::rtl::OUString OpenOfficeResourceLoader::getSingletonName_static()
+ {
+ return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.resource.OfficeResourceLoader" ) );
+ }
+
+ //--------------------------------------------------------------------
+ Reference< XInterface > OpenOfficeResourceLoader::Create( const Reference< XComponentContext >& _rxContext )
+ {
+ return *( new OpenOfficeResourceLoader( _rxContext ) );
+ }
+
+ //--------------------------------------------------------------------
+ Reference< XResourceBundle > SAL_CALL OpenOfficeResourceLoader::loadBundle_Default( const ::rtl::OUString& _baseName ) throw (MissingResourceException, RuntimeException)
+ {
+ return loadBundle( _baseName, Application::GetSettings().GetUILocale() );
+ }
+
+ //--------------------------------------------------------------------
+ Reference< XResourceBundle > SAL_CALL OpenOfficeResourceLoader::loadBundle( const ::rtl::OUString& _baseName, const Locale& _locale ) throw (MissingResourceException, RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ Reference< XResourceBundle > xBundle;
+
+ ResourceBundleDescriptor resourceDescriptor( _baseName, _locale );
+ ResourceBundleCache::iterator cachePos = m_aBundleCache.find( resourceDescriptor );
+ if ( cachePos != m_aBundleCache.end() )
+ xBundle = cachePos->second;
+
+ if ( !xBundle.is() )
+ { // not in the cache, or already died
+ xBundle = new OpenOfficeResourceBundle( m_xContext, _baseName, _locale );
+ m_aBundleCache.insert( ResourceBundleCache::value_type( resourceDescriptor, xBundle ) );
+ }
+
+ return xBundle;
+ }
+
+ //--------------------------------------------------------------------
+ ComponentInfo getComponentInfo_OpenOfficeResourceLoader()
+ {
+ ComponentInfo aInfo;
+ aInfo.aSupportedServices = OpenOfficeResourceLoader::getSupportedServiceNames_static();
+ aInfo.sImplementationName = OpenOfficeResourceLoader::getImplementationName_static();
+ aInfo.sSingletonName = OpenOfficeResourceLoader::getSingletonName_static();
+ aInfo.pFactory = &OpenOfficeResourceLoader::Create;
+ return aInfo;
+ }
+
+ //====================================================================
+ //= OpenOfficeResourceBundle
+ //====================================================================
+ //--------------------------------------------------------------------
+ OpenOfficeResourceBundle::OpenOfficeResourceBundle( const Reference< XComponentContext >& /*_rxContext*/, const ::rtl::OUString& _rBaseName, const Locale& _rLocale )
+ :m_aLocale( _rLocale )
+ ,m_pResourceManager( NULL )
+ {
+ ::rtl::OUString sBaseName( _rBaseName );
+ m_pResourceManager = new SimpleResMgr( sBaseName, m_aLocale );
+
+ if ( !m_pResourceManager->IsValid() )
+ {
+ delete m_pResourceManager, m_pResourceManager = NULL;
+ throw MissingResourceException();
+ }
+
+ // supported resource types so far: strings
+ m_aResourceTypes[ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "string" ) ) ] =
+ ResourceTypePtr( new StringResourceAccess );
+ }
+
+ //--------------------------------------------------------------------
+ OpenOfficeResourceBundle::~OpenOfficeResourceBundle()
+ {
+ delete m_pResourceManager;
+ }
+
+ //--------------------------------------------------------------------
+ Reference< XResourceBundle > SAL_CALL OpenOfficeResourceBundle::getParent() throw (RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ return m_xParent;
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL OpenOfficeResourceBundle::setParent( const Reference< XResourceBundle >& _parent ) throw (RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ m_xParent = _parent;
+ }
+
+ //--------------------------------------------------------------------
+ Locale SAL_CALL OpenOfficeResourceBundle::getLocale( ) throw (RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ return m_aLocale;
+ }
+
+ //--------------------------------------------------------------------
+ bool OpenOfficeResourceBundle::impl_getResourceTypeAndId_nothrow( const ::rtl::OUString& _key, ResourceTypePtr& _out_resourceType, sal_Int32& _out_resourceId ) const
+ {
+ sal_Int32 typeSeparatorPos = _key.indexOf( ':' );
+ if ( typeSeparatorPos == -1 )
+ // invalid key
+ return false;
+
+ ::rtl::OUString resourceType = _key.copy( 0, typeSeparatorPos );
+
+ ResourceTypes::const_iterator typePos = m_aResourceTypes.find( resourceType );
+ if ( typePos == m_aResourceTypes.end() )
+ // don't know this resource type
+ return false;
+
+ _out_resourceType = typePos->second;
+ _out_resourceId = _key.copy( typeSeparatorPos + 1 ).toInt32();
+ return true;
+ }
+
+ //--------------------------------------------------------------------
+ bool OpenOfficeResourceBundle::impl_getDirectElement_nothrow( const ::rtl::OUString& _key, Any& _out_Element ) const
+ {
+ ResourceTypePtr resourceType;
+ sal_Int32 resourceId( 0 );
+ if ( !impl_getResourceTypeAndId_nothrow( _key, resourceType, resourceId ) )
+ return false;
+
+ if ( !m_pResourceManager->IsAvailable( resourceType->getResourceType(), resourceId ) )
+ // no such resource with the given type/id
+ return false;
+
+ _out_Element = resourceType->getResource( *m_pResourceManager, resourceId );
+ return _out_Element.hasValue();
+ }
+
+ //--------------------------------------------------------------------
+ Any SAL_CALL OpenOfficeResourceBundle::getDirectElement( const ::rtl::OUString& _key ) throw (RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ Any aElement;
+ impl_getDirectElement_nothrow( _key, aElement );
+ return aElement;
+ }
+
+ //--------------------------------------------------------------------
+ Any SAL_CALL OpenOfficeResourceBundle::getByName( const ::rtl::OUString& _key ) throw (NoSuchElementException, WrappedTargetException, RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ Any aElement;
+ if ( !impl_getDirectElement_nothrow( _key, aElement ) )
+ {
+ if ( m_xParent.is() )
+ aElement = m_xParent->getByName( _key );
+ }
+
+ if ( !aElement.hasValue() )
+ throw NoSuchElementException( ::rtl::OUString(), *this );
+
+ return aElement;
+ }
+
+ //--------------------------------------------------------------------
+ Sequence< ::rtl::OUString > SAL_CALL OpenOfficeResourceBundle::getElementNames( ) throw (RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ OSL_ENSURE( false, "OpenOfficeResourceBundle::getElementNames: not implemented!" );
+ // the (Simple)ResManager does not provide an API to enumerate the resources
+ return Sequence< ::rtl::OUString >( );
+ }
+
+ //--------------------------------------------------------------------
+ ::sal_Bool SAL_CALL OpenOfficeResourceBundle::hasByName( const ::rtl::OUString& _key ) throw (RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ ResourceTypePtr resourceType;
+ sal_Int32 resourceId( 0 );
+ if ( !impl_getResourceTypeAndId_nothrow( _key, resourceType, resourceId ) )
+ return sal_False;
+
+ if ( !m_pResourceManager->IsAvailable( resourceType->getResourceType(), resourceId ) )
+ return sal_False;
+
+ return sal_True;
+ }
+
+ //--------------------------------------------------------------------
+ Type SAL_CALL OpenOfficeResourceBundle::getElementType( ) throw (RuntimeException)
+ {
+ return ::cppu::UnoType< Any >::get();
+ }
+
+ //--------------------------------------------------------------------
+ ::sal_Bool SAL_CALL OpenOfficeResourceBundle::hasElements( ) throw (RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ OSL_ENSURE( false, "OpenOfficeResourceBundle::hasElements: not implemented!" );
+ // the (Simple)ResManager does not provide an API to enumerate the resources
+ return ::sal_Bool( );
+ }
+
+//........................................................................
+} // namespace res
+//........................................................................
+
+#endif // EXTENSIONS_SOURCE_RESOURCE_OOORESOURCELOADER_CXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/resource/res_services.cxx b/extensions/source/resource/res_services.cxx
new file mode 100644
index 000000000000..c87e59f0db2c
--- /dev/null
+++ b/extensions/source/resource/res_services.cxx
@@ -0,0 +1,131 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+#include "res_services.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/registry/XRegistryKey.hpp>
+/** === end UNO includes === **/
+
+/** === begin UNO using === **/
+using ::com::sun::star::registry::XRegistryKey;
+using ::com::sun::star::uno::Reference;
+using ::com::sun::star::uno::Sequence;
+using ::com::sun::star::uno::Exception;
+using ::com::sun::star::lang::XMultiServiceFactory;
+using ::com::sun::star::lang::XSingleServiceFactory;
+using ::com::sun::star::uno::UNO_QUERY;
+/** === end UNO using === **/
+
+#include <vector>
+
+namespace res
+{
+ ::std::vector< ComponentInfo > getComponentInfos()
+ {
+ ::std::vector< ::res::ComponentInfo > aComponentInfos;
+ aComponentInfos.push_back( getComponentInfo_VclStringResourceLoader() );
+ aComponentInfos.push_back( getComponentInfo_OpenOfficeResourceLoader() );
+ return aComponentInfos;
+ }
+}
+
+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*/, XRegistryKey * pRegistryKey )
+{
+ try
+ {
+ ::std::vector< ::res::ComponentInfo > aComponentInfos( ::res::getComponentInfos() );
+ for ( ::std::vector< ::res::ComponentInfo >::const_iterator loop = aComponentInfos.begin();
+ loop != aComponentInfos.end();
+ ++loop
+ )
+ {
+ Reference< XRegistryKey > xNewKey =
+ pRegistryKey->createKey( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("/") )
+ + loop->sImplementationName + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "/UNO/SERVICES" ) ) );
+
+ for( sal_Int32 i = 0; i < loop->aSupportedServices.getLength(); ++i )
+ xNewKey->createKey( loop->aSupportedServices.getConstArray()[i]);
+
+ if ( loop->sSingletonName.getLength() )
+ {
+ OSL_ENSURE( loop->aSupportedServices.getLength() == 1, "singletons must support exactly one service!" );
+ xNewKey = pRegistryKey->createKey( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("/") )
+ + loop->sImplementationName + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "/UNO/SINGLETONS/" ) )
+ + loop->sSingletonName );
+ xNewKey->setStringValue( loop->aSupportedServices[ 0 ] );
+ }
+ }
+
+ return sal_True;
+ }
+ catch (Exception &)
+ {
+ // not allowed to throw an exception over the c function.
+ //OSL_ENSURE( sal_False, "Exception cannot register component!" );
+ return sal_False;
+ }
+}
+
+void * SAL_CALL component_getFactory(
+ const sal_Char * pImplName, XMultiServiceFactory * /*pServiceManager*/, void * /*pRegistryKey*/ )
+{
+ void * pRet = 0;
+ ::std::vector< ::res::ComponentInfo > aComponentInfos( ::res::getComponentInfos() );
+ for ( ::std::vector< ::res::ComponentInfo >::const_iterator loop = aComponentInfos.begin();
+ loop != aComponentInfos.end();
+ ++loop
+ )
+ {
+ if ( 0 == loop->sImplementationName.compareToAscii( pImplName ) )
+ {
+ // create the factory
+ Reference< XSingleServiceFactory > xFactory( ::cppu::createSingleComponentFactory(
+ loop->pFactory, loop->sImplementationName, loop->aSupportedServices ),
+ UNO_QUERY );
+ // acquire, because we return an interface pointer instead of a reference
+ xFactory->acquire();
+ pRet = xFactory.get();
+ }
+ }
+ return pRet;
+}
+
+} // extern "C"
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/resource/res_services.hxx b/extensions/source/resource/res_services.hxx
new file mode 100644
index 000000000000..3f47764e51ba
--- /dev/null
+++ b/extensions/source/resource/res_services.hxx
@@ -0,0 +1,67 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef EXTENSIONS_RESOURCE_SERVICES_HXX
+#define EXTENSIONS_RESOURCE_SERVICES_HXX
+
+/** === begin UNO includes === **/
+#include <com/sun/star/uno/Sequence.hxx>
+#include <com/sun/star/uno/Reference.hxx>
+#include <com/sun/star/uno/XInterface.hpp>
+/** === end UNO includes === **/
+#include <cppuhelper/factory.hxx>
+
+//........................................................................
+namespace res
+{
+//........................................................................
+
+ struct ComponentInfo
+ {
+ /// services supported by the component
+ ::com::sun::star::uno::Sequence< ::rtl::OUString > aSupportedServices;
+ /// implementation name of the component
+ ::rtl::OUString sImplementationName;
+ /** name of the singleton instance of the component, if it is a singleton, empty otherwise
+ If the component is a singleton, aSupportedServices must contain exactly one element.
+ */
+ ::rtl::OUString sSingletonName;
+ /// factory for creating the component
+ ::cppu::ComponentFactoryFunc pFactory;
+ };
+
+ ComponentInfo getComponentInfo_VclStringResourceLoader();
+ ComponentInfo getComponentInfo_OpenOfficeResourceLoader();
+
+//........................................................................
+} // namespace res
+//........................................................................
+
+#endif // EXTENSIONS_RESOURCE_SERVICES_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/resource/resource.cxx b/extensions/source/resource/resource.cxx
new file mode 100644
index 000000000000..8ebd503c0d98
--- /dev/null
+++ b/extensions/source/resource/resource.cxx
@@ -0,0 +1,472 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+#include "res_services.hxx"
+
+#include <osl/mutex.hxx>
+#include <uno/lbnames.h> // CPPU_CURRENT_LANGUAGE_BINDING_NAME macro, which specify the environment type
+#include <cppuhelper/factory.hxx> // helper for factories
+#include <cppuhelper/implbase3.hxx> // helper for implementations
+
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/script/XInvocation.hpp>
+#include <com/sun/star/script/XTypeConverter.hpp>
+#include <com/sun/star/reflection/InvocationTargetException.hpp>
+#include <com/sun/star/beans/XExactName.hpp>
+#include <com/sun/star/beans/PropertyValue.hpp>
+#include <com/sun/star/beans/PropertyState.hpp>
+
+#include <tools/resmgr.hxx>
+#include <tools/rcid.h>
+#include <tools/resary.hxx>
+#include <vcl/svapp.hxx>
+
+#include <rtl/ustring.hxx>
+#include <rtl/strbuf.hxx>
+
+using namespace rtl;
+using namespace com::sun::star::uno;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::registry;
+using namespace com::sun::star::script;
+using namespace com::sun::star::beans;
+using namespace com::sun::star::reflection;
+
+//------------------------------------------------------------------------
+//------------------------------------------------------------------------
+//------------------------------------------------------------------------
+class ResourceService : public cppu::WeakImplHelper3< XInvocation, XExactName, XServiceInfo >
+{
+public:
+ ResourceService( const Reference< XMultiServiceFactory > & );
+ ~ResourceService();
+
+ // XServiceInfo
+ OUString SAL_CALL getImplementationName() throw();
+ BOOL SAL_CALL supportsService(const OUString& ServiceName) throw();
+ Sequence< OUString > SAL_CALL getSupportedServiceNames(void) throw();
+
+ static Sequence< OUString > getSupportedServiceNames_Static(void) throw();
+ static OUString getImplementationName_Static() throw()
+ {
+ return OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.extensions.ResourceService"));
+ }
+ static Reference< XInterface > Create( const Reference< XComponentContext >& _rxContext );
+
+ // XExactName
+ OUString SAL_CALL getExactName( const OUString & ApproximateName ) throw(RuntimeException);
+
+ // XInvokation
+ Reference< XIntrospectionAccess > SAL_CALL getIntrospection(void) throw(RuntimeException);
+ Any SAL_CALL invoke(const OUString& FunctionName, const Sequence< Any >& Params, Sequence< sal_Int16 >& OutParamIndex, Sequence< Any >& OutParam) throw(IllegalArgumentException, CannotConvertException, InvocationTargetException, RuntimeException);
+ void SAL_CALL setValue(const OUString& PropertyName, const Any& Value) throw(UnknownPropertyException, CannotConvertException, InvocationTargetException, RuntimeException);
+ Any SAL_CALL getValue(const OUString& PropertyName) throw(UnknownPropertyException, RuntimeException);
+ BOOL SAL_CALL hasMethod(const OUString& Name) throw(RuntimeException);
+ BOOL SAL_CALL hasProperty(const OUString& Name) throw(RuntimeException);
+private:
+ Reference< XTypeConverter > getTypeConverter() const;
+ Reference< XInvocation > getDefaultInvocation() const;
+
+ Reference< XMultiServiceFactory > xSMgr;
+ Reference< XInvocation > xDefaultInvocation;
+ Reference< XTypeConverter > xTypeConverter;
+ OUString aFileName;
+ ResMgr * pResMgr;
+};
+
+
+//-----------------------------------------------------------------------------
+ResourceService::ResourceService( const Reference< XMultiServiceFactory > & rSMgr )
+ : xSMgr( rSMgr )
+ , pResMgr( NULL )
+{
+}
+
+//-----------------------------------------------------------------------------
+Reference< XInterface > ResourceService::Create( const Reference< XComponentContext >& _rxContext )
+{
+ Reference< XMultiServiceFactory > xFactory( _rxContext->getServiceManager(), UNO_QUERY_THROW );
+ return *( new ResourceService( xFactory ) );
+}
+
+//-----------------------------------------------------------------------------
+ResourceService::~ResourceService()
+{
+ delete pResMgr;
+}
+
+// XServiceInfo
+OUString ResourceService::getImplementationName() throw()
+{
+ return getImplementationName_Static();
+}
+
+// XServiceInfo
+BOOL SAL_CALL ResourceService::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 TRUE;
+ return FALSE;
+}
+
+// XServiceInfo
+Sequence< OUString > SAL_CALL ResourceService::getSupportedServiceNames(void) throw()
+{
+ return getSupportedServiceNames_Static();
+}
+
+// ResourceService
+Sequence< OUString > ResourceService::getSupportedServiceNames_Static(void) throw()
+{
+ Sequence< OUString > aSNS( 1 );
+ aSNS.getArray()[0] = OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.resource.VclStringResourceLoader"));
+ return aSNS;
+}
+
+// ResourceService
+Reference< XTypeConverter > ResourceService::getTypeConverter() const
+{
+ SolarMutexGuard aGuard;
+ if( xSMgr.is() )
+ {
+ Reference< XTypeConverter > xConv( xSMgr->createInstance( OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.script.Converter" ))), UNO_QUERY );
+ ((ResourceService*)this)->xTypeConverter = xConv;
+ }
+ return xTypeConverter;
+}
+
+// ResourceService
+Reference< XInvocation > ResourceService::getDefaultInvocation() const
+{
+ SolarMutexGuard aGuard;
+ /* f�hrt zur Zeit noch zu einer rekursion
+ if( xSMgr.is() )
+ {
+ Reference< XSingleServiceFactory > xFact( xSMgr->createInstance( OUString::createFromAscii("com.sun.star.script.Invocation") ), UNO_QUERY );
+ if( xFact.is() )
+ {
+ Sequence< Any > aArgs( 1 );
+ Reference< XInterface > xThis( *this );
+ aArgs.getArray()[0].set( &xThis, XInterface_Reference< get >lection() );
+ Reference< XInvokation > xI( xFact->createInstanceWithArguments( aArgs ), UNO_QUERY );
+ ((ResourceService*)this)->xDefaultInvocation = xI;
+ }
+ }
+ */
+ return xDefaultInvocation;
+}
+
+// XExactName
+OUString SAL_CALL ResourceService::getExactName( const OUString & ApproximateName ) throw(RuntimeException)
+{
+ OUString aName( ApproximateName );
+ aName = aName.toAsciiLowerCase();
+ if( aName.equalsAscii("filename") )
+ return OUString(RTL_CONSTASCII_USTRINGPARAM("FileName"));
+ else if( aName.equalsAscii("getstring" ))
+ return OUString(RTL_CONSTASCII_USTRINGPARAM("getString"));
+ else if( aName.equalsAscii("getstrings" ))
+ return OUString(RTL_CONSTASCII_USTRINGPARAM("getStrings"));
+ else if( aName.equalsAscii("hasstring") )
+ return OUString(RTL_CONSTASCII_USTRINGPARAM("hasString"));
+ else if( aName.equalsAscii("hasstrings") )
+ return OUString(RTL_CONSTASCII_USTRINGPARAM("hasStrings"));
+ else if( aName.equalsAscii("getstringlist") )
+ return OUString(RTL_CONSTASCII_USTRINGPARAM("getStringList"));
+ else if( aName.equalsAscii("hasStringList") )
+ return OUString(RTL_CONSTASCII_USTRINGPARAM("hasStringList"));
+ Reference< XExactName > xEN( getDefaultInvocation(), UNO_QUERY );
+ if( xEN.is() )
+ return xEN->getExactName( ApproximateName );
+ return OUString();
+}
+
+// XInvokation
+Reference< XIntrospectionAccess > SAL_CALL ResourceService::getIntrospection(void)
+ throw(RuntimeException)
+{
+ Reference< XInvocation > xI = getDefaultInvocation();
+ if( xI.is() )
+ return xI->getIntrospection();
+ return Reference< XIntrospectionAccess >();
+}
+
+// XInvokation
+Any SAL_CALL ResourceService::invoke
+(
+ const OUString& FunctionName,
+ const Sequence< Any >& Params,
+ Sequence< sal_Int16 >& OutParamIndex,
+ Sequence< Any >& OutParam
+)
+ throw(IllegalArgumentException, CannotConvertException, InvocationTargetException, RuntimeException)
+{
+ Any aRet;
+ if( FunctionName.equalsAscii("getString")
+ || FunctionName.equalsAscii("getStrings" )
+ || FunctionName.equalsAscii("hasString" )
+ || FunctionName.equalsAscii("hasStrings" )
+ )
+ {
+ sal_Int32 nElements = Params.getLength();
+ if( nElements < 1 )
+ throw IllegalArgumentException();
+ if( nElements > 1 && (FunctionName.equalsAscii("getString") || FunctionName.equalsAscii("hasString") ) )
+ throw IllegalArgumentException();
+ if( !pResMgr )
+ throw IllegalArgumentException();
+
+ Sequence< OUString > aStrings( Params.getLength() );
+ Sequence< sal_Bool > aBools( Params.getLength() );
+ const Any* pIn = Params.getConstArray();
+ OUString* pOutString = aStrings.getArray();
+ sal_Bool* pOutBool = aBools.getArray();
+
+ Reference< XTypeConverter > xC = getTypeConverter();
+ bool bGetBranch = FunctionName.equalsAscii( "getString" ) || FunctionName.equalsAscii( "getStrings" );
+
+ SolarMutexGuard aGuard;
+ for( sal_Int32 n = 0; n < nElements; n++ )
+ {
+ sal_Int32 nId = 0;
+ if( !(pIn[n] >>= nId) )
+ {
+ if( xC.is() )
+ {
+ xC->convertToSimpleType( pIn[n], TypeClass_LONG ) >>= nId;
+ }
+ else
+ throw CannotConvertException();
+ }
+ if( nId > 0xFFFF || nId < 0 )
+ throw IllegalArgumentException();
+
+ if( bGetBranch )
+ {
+ ResId aId( (USHORT)nId, *pResMgr );
+ aId.SetRT( RSC_STRING );
+ if( pResMgr->IsAvailable( aId ) )
+ {
+ String aStr( aId );
+ pOutString[n] = aStr;
+ }
+ else
+ throw IllegalArgumentException();
+ }
+ else // hasString(s)
+ {
+ sal_Bool bRet = sal_False;
+ if( pResMgr )
+ {
+ ResId aId( (USHORT)nId, *pResMgr );
+ aId.SetRT( RSC_STRING );
+ bRet = pResMgr->IsAvailable( aId );
+ }
+ pOutBool[n] = bRet;
+ }
+ }
+ if( FunctionName.equalsAscii("getString") )
+ aRet <<= pOutString[0];
+ else if( FunctionName.equalsAscii("getStrings" ) )
+ aRet <<= aStrings;
+ else if( FunctionName.equalsAscii("hasString" ) )
+ aRet <<= pOutBool[0];
+ else
+ aRet <<= aBools;
+ }
+ else if( FunctionName.equalsAscii("getStringList") || FunctionName.equalsAscii("hasStringList" ) )
+ {
+ if( Params.getLength() != 1 )
+ throw IllegalArgumentException();
+ Reference< XTypeConverter > xC = getTypeConverter();
+ SolarMutexGuard aGuard;
+
+ sal_Int32 nId = 0;
+ if( !(Params.getConstArray()[0] >>= nId) )
+ {
+ if( xC.is() )
+ {
+ xC->convertToSimpleType( Params.getConstArray()[0], TypeClass_LONG ) >>= nId;
+ }
+ else
+ throw CannotConvertException();
+ }
+
+ if( FunctionName.equalsAscii("getStringList") )
+ {
+ ResId aId( (USHORT)nId, *pResMgr );
+ aId.SetRT( RSC_STRINGARRAY );
+ if( pResMgr->IsAvailable( aId ) )
+ {
+ ResStringArray aStr( aId );
+ int nEntries = aStr.Count();
+ Sequence< PropertyValue > aPropSeq( nEntries );
+ PropertyValue* pOut = aPropSeq.getArray();
+ for( int i = 0; i < nEntries; i++ )
+ {
+ pOut[i].Name = aStr.GetString( i );
+ pOut[i].Handle = -1;
+ pOut[i].Value <<= aStr.GetValue( i );
+ pOut[i].State = PropertyState_DIRECT_VALUE;
+ }
+ aRet <<= aPropSeq;
+ }
+ else
+ throw IllegalArgumentException();
+ }
+ else // hasStringList
+ {
+ sal_Bool bRet = sal_False;
+ if( pResMgr )
+ {
+ ResId aId( (USHORT)nId, *pResMgr );
+ aId.SetRT( RSC_STRINGARRAY );
+ bRet = pResMgr->IsAvailable( aId );
+ }
+ aRet <<= bRet;
+ }
+ }
+ else
+ {
+ Reference< XInvocation > xI = getDefaultInvocation();
+ if( xI.is() )
+ return xI->invoke( FunctionName, Params, OutParamIndex, OutParam );
+ else
+ throw IllegalArgumentException();
+ }
+ return aRet;
+}
+
+// XInvokation
+void SAL_CALL ResourceService::setValue(const OUString& PropertyName, const Any& Value)
+ throw(UnknownPropertyException, CannotConvertException, InvocationTargetException, RuntimeException)
+{
+ if( PropertyName.equalsAscii("FileName") )
+ {
+ OUString aName;
+ if( !(Value >>= aName) )
+ {
+ Reference< XTypeConverter > xC = getTypeConverter();
+ if( xC.is() )
+ xC->convertToSimpleType( Value, TypeClass_STRING ) >>= aName;
+ else
+ throw CannotConvertException();
+ }
+
+ SolarMutexGuard aGuard;
+ OStringBuffer aBuf( aName.getLength()+8 );
+ aBuf.append( OUStringToOString( aName, osl_getThreadTextEncoding() ) );
+ ResMgr * pRM = ResMgr::CreateResMgr( aBuf.getStr() );
+ if( !pRM )
+ throw InvocationTargetException();
+ if( pResMgr )
+ delete pResMgr;
+ pResMgr = pRM;
+ aFileName = OStringToOUString( aBuf.makeStringAndClear(), osl_getThreadTextEncoding() );
+ }
+ else
+ {
+ Reference< XInvocation > xI = getDefaultInvocation();
+ if( xI.is() )
+ xI->setValue( PropertyName, Value );
+ else
+ throw UnknownPropertyException();
+ }
+}
+
+// XInvokation
+Any SAL_CALL ResourceService::getValue(const OUString& PropertyName)
+ throw(UnknownPropertyException, RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ if( PropertyName.equalsAscii("FileName" ))
+ return makeAny( aFileName );
+
+ Reference< XInvocation > xI = getDefaultInvocation();
+ if( xI.is() )
+ return xI->getValue( PropertyName );
+
+ throw UnknownPropertyException();
+}
+
+// XInvokation
+BOOL SAL_CALL ResourceService::hasMethod(const OUString& Name)
+ throw(RuntimeException)
+{
+ if( Name.equalsAscii("getString") ||
+ Name.equalsAscii("getStrings") ||
+ Name.equalsAscii("hasString") ||
+ Name.equalsAscii("hasStrings") ||
+ Name.equalsAscii("getStringList") ||
+ Name.equalsAscii("hasStringList")
+ )
+ return TRUE;
+ else
+ {
+ Reference< XInvocation > xI = getDefaultInvocation();
+ if( xI.is() )
+ return xI->hasMethod( Name );
+ else
+ return FALSE;
+ }
+}
+
+// XInvokation
+BOOL SAL_CALL ResourceService::hasProperty(const OUString& Name)
+ throw(RuntimeException)
+{
+ if( Name.equalsAscii("FileName") )
+ return TRUE;
+ else
+ {
+ Reference< XInvocation > xI = getDefaultInvocation();
+ if( xI.is() )
+ return xI->hasProperty( Name );
+ else
+ return FALSE;
+ }
+}
+
+namespace res
+{
+ ComponentInfo getComponentInfo_VclStringResourceLoader()
+ {
+ ComponentInfo aInfo;
+ aInfo.aSupportedServices = ResourceService::getSupportedServiceNames_Static();
+ aInfo.sImplementationName = ResourceService::getImplementationName_Static();
+ aInfo.pFactory = &ResourceService::Create;
+ return aInfo;
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/scanner/exports.dxp b/extensions/source/scanner/exports.dxp
new file mode 100644
index 000000000000..9630d7e06768
--- /dev/null
+++ b/extensions/source/scanner/exports.dxp
@@ -0,0 +1,3 @@
+component_getImplementationEnvironment
+component_writeInfo
+component_getFactory
diff --git a/extensions/source/scanner/grid.cxx b/extensions/source/scanner/grid.cxx
new file mode 100644
index 000000000000..df48ec6cf155
--- /dev/null
+++ b/extensions/source/scanner/grid.cxx
@@ -0,0 +1,611 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+#include <grid.hrc>
+#include <cstdio>
+#include <math.h> // for M_LN10 and M_E
+
+#define _USE_MATH_DEFINES
+#include <cmath>
+#undef _USE_MATH_DEFINES
+
+#include <grid.hxx>
+
+// for ::std::sort
+#include <algorithm>
+
+ResId SaneResId( sal_uInt32 );
+
+/***********************************************************************
+ *
+ * GridWindow
+ *
+ ***********************************************************************/
+
+// ---------------------------------------------------------------------
+
+GridWindow::GridWindow(double* pXValues, double* pYValues, int nValues, Window* pParent, BOOL bCutValues )
+: ModalDialog( pParent, SaneResId( GRID_DIALOG ) ),
+ m_aGridArea( 50, 15, 100, 100 ),
+ m_pXValues( pXValues ),
+ m_pOrigYValues( pYValues ),
+ m_nValues( nValues ),
+ m_pNewYValues( NULL ),
+ m_bCutValues( bCutValues ),
+ m_aHandles(),
+ m_nDragIndex( 0xffffffff ),
+ m_aMarkerBitmap( Bitmap( SaneResId( GRID_DIALOG_HANDLE_BMP ) ), Color( 255, 255, 255 ) ),
+ m_aOKButton( this, SaneResId( GRID_DIALOG_OK_BTN ) ),
+ m_aCancelButton( this, SaneResId( GRID_DIALOG_CANCEL_BTN ) ),
+ m_aResetTypeBox( this, SaneResId( GRID_DIALOG_TYPE_BOX ) ),
+ m_aResetButton( this, SaneResId( GRID_DIALOG_RESET_BTN ) )
+{
+ USHORT nPos = m_aResetTypeBox.InsertEntry( String( SaneResId( RESET_TYPE_LINEAR_ASCENDING ) ) );
+ m_aResetTypeBox.SetEntryData( nPos, (void *)RESET_TYPE_LINEAR_ASCENDING );
+
+ nPos = m_aResetTypeBox.InsertEntry( String( SaneResId( RESET_TYPE_LINEAR_DESCENDING ) ) );
+ m_aResetTypeBox.SetEntryData( nPos, (void *)RESET_TYPE_LINEAR_DESCENDING );
+
+ nPos = m_aResetTypeBox.InsertEntry( String( SaneResId( RESET_TYPE_RESET ) ) );
+ m_aResetTypeBox.SetEntryData( nPos, (void *)RESET_TYPE_RESET );
+
+ nPos = m_aResetTypeBox.InsertEntry( String( SaneResId( RESET_TYPE_EXPONENTIAL ) ) );
+ m_aResetTypeBox.SetEntryData( nPos, (void *)RESET_TYPE_EXPONENTIAL );
+
+ m_aResetTypeBox.SelectEntryPos( 0 );
+
+ m_aResetButton.SetClickHdl( LINK( this, GridWindow, ClickButtonHdl ) );
+
+ SetMapMode( MapMode( MAP_PIXEL ) );
+ Size aSize = GetOutputSizePixel();
+ Size aBtnSize = m_aOKButton.GetOutputSizePixel();
+ m_aGridArea.setWidth( aSize.Width() - aBtnSize.Width() - 80 );
+ m_aGridArea.setHeight( aSize.Height() - 40 );
+
+ if( m_pOrigYValues && m_nValues )
+ {
+ m_pNewYValues = new double[ m_nValues ];
+ memcpy( m_pNewYValues, m_pOrigYValues, sizeof( double ) * m_nValues );
+ }
+
+ setBoundings( 0, 0, 1023, 1023 );
+ computeExtremes();
+
+ // create left and right marker as first and last entry
+ m_BmOffX = sal_uInt16(m_aMarkerBitmap.GetSizePixel().Width() >> 1);
+ m_BmOffY = sal_uInt16(m_aMarkerBitmap.GetSizePixel().Height() >> 1);
+ m_aHandles.push_back(impHandle(transform(findMinX(), findMinY()), m_BmOffX, m_BmOffY));
+ m_aHandles.push_back(impHandle(transform(findMaxX(), findMaxY()), m_BmOffX, m_BmOffY));
+
+ FreeResource();
+}
+
+// ---------------------------------------------------------------------
+
+GridWindow::~GridWindow()
+{
+ if( m_pNewYValues )
+ delete [] m_pNewYValues;
+}
+
+// ---------------------------------------------------------------------
+
+double GridWindow::findMinX()
+{
+ if( ! m_pXValues )
+ return 0.0;
+ double fMin = m_pXValues[0];
+ for( int i = 1; i < m_nValues; i++ )
+ if( m_pXValues[ i ] < fMin )
+ fMin = m_pXValues[ i ];
+ return fMin;
+}
+
+// ---------------------------------------------------------------------
+
+double GridWindow::findMinY()
+{
+ if( ! m_pNewYValues )
+ return 0.0;
+ double fMin = m_pNewYValues[0];
+ for( int i = 1; i < m_nValues; i++ )
+ if( m_pNewYValues[ i ] < fMin )
+ fMin = m_pNewYValues[ i ];
+ return fMin;
+}
+
+// ---------------------------------------------------------------------
+
+double GridWindow::findMaxX()
+{
+ if( ! m_pXValues )
+ return 0.0;
+ double fMax = m_pXValues[0];
+ for( int i = 1; i < m_nValues; i++ )
+ if( m_pXValues[ i ] > fMax )
+ fMax = m_pXValues[ i ];
+ return fMax;
+}
+
+// ---------------------------------------------------------------------
+
+double GridWindow::findMaxY()
+{
+ if( ! m_pNewYValues )
+ return 0.0;
+ double fMax = m_pNewYValues[0];
+ for( int i = 1; i < m_nValues; i++ )
+ if( m_pNewYValues[ i ] > fMax )
+ fMax = m_pNewYValues[ i ];
+ return fMax;
+}
+
+// ---------------------------------------------------------------------
+
+void GridWindow::computeExtremes()
+{
+ if( m_nValues && m_pXValues && m_pOrigYValues )
+ {
+ m_fMaxX = m_fMinX = m_pXValues[0];
+ m_fMaxY = m_fMinY = m_pOrigYValues[0];
+ for( int i = 1; i < m_nValues; i++ )
+ {
+ if( m_pXValues[ i ] > m_fMaxX )
+ m_fMaxX = m_pXValues[ i ];
+ else if( m_pXValues[ i ] < m_fMinX )
+ m_fMinX = m_pXValues[ i ];
+ if( m_pOrigYValues[ i ] > m_fMaxY )
+ m_fMaxY = m_pOrigYValues[ i ];
+ else if( m_pOrigYValues[ i ] < m_fMinY )
+ m_fMinY = m_pOrigYValues[ i ];
+ }
+ setBoundings( m_fMinX, m_fMinY, m_fMaxX, m_fMaxY );
+ }
+}
+
+// ---------------------------------------------------------------------
+
+Point GridWindow::transform( double x, double y )
+{
+ Point aRet;
+
+ aRet.X() = (long)( ( x - m_fMinX ) *
+ (double)m_aGridArea.GetWidth() / ( m_fMaxX - m_fMinX )
+ + m_aGridArea.Left() );
+ aRet.Y() = (long)(
+ m_aGridArea.Bottom() -
+ ( y - m_fMinY ) *
+ (double)m_aGridArea.GetHeight() / ( m_fMaxY - m_fMinY ) );
+ return aRet;
+}
+
+// ---------------------------------------------------------------------
+
+void GridWindow::transform( const Point& rOriginal, double& x, double& y )
+{
+ x = ( rOriginal.X() - m_aGridArea.Left() ) * (m_fMaxX - m_fMinX) / (double)m_aGridArea.GetWidth() + m_fMinX;
+ y = ( m_aGridArea.Bottom() - rOriginal.Y() ) * (m_fMaxY - m_fMinY) / (double)m_aGridArea.GetHeight() + m_fMinY;
+}
+
+// ---------------------------------------------------------------------
+
+void GridWindow::drawLine( double x1, double y1, double x2, double y2 )
+{
+ DrawLine( transform( x1, y1 ), transform( x2, y2 ) );
+}
+
+// ---------------------------------------------------------------------
+
+void GridWindow::computeChunk( double fMin, double fMax, double& fChunkOut, double& fMinChunkOut )
+{
+ // get a nice chunk size like 10, 100, 25 or such
+ fChunkOut = ( fMax - fMin ) / 6.0;
+ int logchunk = (int)std::log10( fChunkOut );
+ int nChunk = (int)( fChunkOut / std::exp( (double)(logchunk-1) * M_LN10 ) );
+ if( nChunk >= 75 )
+ nChunk = 100;
+ else if( nChunk >= 35 )
+ nChunk = 50;
+ else if ( nChunk > 20 )
+ nChunk = 25;
+ else if ( nChunk >= 13 )
+ nChunk = 20;
+ else if( nChunk > 5 )
+ nChunk = 10;
+ else
+ nChunk = 5;
+ fChunkOut = (double) nChunk * exp( (double)(logchunk-1) * M_LN10 );
+ // compute whole chunks fitting into fMin
+ nChunk = (int)( fMin / fChunkOut );
+ fMinChunkOut = (double)nChunk * fChunkOut;
+ while( fMinChunkOut < fMin )
+ fMinChunkOut += fChunkOut;
+}
+
+// ---------------------------------------------------------------------
+
+void GridWindow::computeNew()
+{
+ if(2L == m_aHandles.size())
+ {
+ // special case: only left and right markers
+ double xleft, yleft;
+ double xright, yright;
+ transform(m_aHandles[0L].maPos, xleft, yleft);
+ transform(m_aHandles[1L].maPos, xright, yright );
+ double factor = (yright-yleft)/(xright-xleft);
+ for( int i = 0; i < m_nValues; i++ )
+ {
+ m_pNewYValues[ i ] = yleft + ( m_pXValues[ i ] - xleft )*factor;
+ }
+ }
+ else
+ {
+ // sort markers
+ std::sort(m_aHandles.begin(), m_aHandles.end());
+ const int nSorted = m_aHandles.size();
+ int i;
+
+ // get node arrays
+ double* nodex = new double[ nSorted ];
+ double* nodey = new double[ nSorted ];
+
+ for( i = 0L; i < nSorted; i++ )
+ transform( m_aHandles[i].maPos, nodex[ i ], nodey[ i ] );
+
+ for( i = 0; i < m_nValues; i++ )
+ {
+ double x = m_pXValues[ i ];
+ m_pNewYValues[ i ] = interpolate( x, nodex, nodey, nSorted );
+ if( m_bCutValues )
+ {
+ if( m_pNewYValues[ i ] > m_fMaxY )
+ m_pNewYValues[ i ] = m_fMaxY;
+ else if( m_pNewYValues[ i ] < m_fMinY )
+ m_pNewYValues[ i ] = m_fMinY;
+ }
+ }
+
+ delete [] nodex;
+ delete [] nodey;
+ }
+}
+
+// ---------------------------------------------------------------------
+
+double GridWindow::interpolate(
+ double x,
+ double* pNodeX,
+ double* pNodeY,
+ int nNodes )
+{
+ // compute Lagrange interpolation
+ double ret = 0;
+ for( int i = 0; i < nNodes; i++ )
+ {
+ double sum = pNodeY[ i ];
+ for( int n = 0; n < nNodes; n++ )
+ {
+ if( n != i )
+ {
+ sum *= x - pNodeX[ n ];
+ sum /= pNodeX[ i ] - pNodeX[ n ];
+ }
+ }
+ ret += sum;
+ }
+ return ret;
+}
+
+// ---------------------------------------------------------------------
+
+void GridWindow::setBoundings( double fMinX, double fMinY, double fMaxX, double fMaxY )
+{
+ m_fMinX = fMinX;
+ m_fMinY = fMinY;
+ m_fMaxX = fMaxX;
+ m_fMaxY = fMaxY;
+
+ computeChunk( m_fMinX, m_fMaxX, m_fChunkX, m_fMinChunkX );
+ computeChunk( m_fMinY, m_fMaxY, m_fChunkY, m_fMinChunkY );
+}
+
+// ---------------------------------------------------------------------
+
+void GridWindow::drawGrid()
+{
+ char pBuf[256];
+ SetLineColor( Color( COL_BLACK ) );
+ // draw vertical lines
+ for( double fX = m_fMinChunkX; fX < m_fMaxX; fX += m_fChunkX )
+ {
+ drawLine( fX, m_fMinY, fX, m_fMaxY );
+ // draw tickmarks
+ Point aPt = transform( fX, m_fMinY );
+ std::sprintf( pBuf, "%g", fX );
+ String aMark( pBuf, gsl_getSystemTextEncoding() );
+ Size aTextSize( GetTextWidth( aMark ), GetTextHeight() );
+ aPt.X() -= aTextSize.Width()/2;
+ aPt.Y() += aTextSize.Height()/2;
+ DrawText( aPt, aMark );
+ }
+ // draw horizontal lines
+ for( double fY = m_fMinChunkY; fY < m_fMaxY; fY += m_fChunkY )
+ {
+ drawLine( m_fMinX, fY, m_fMaxX, fY );
+ // draw tickmarks
+ Point aPt = transform( m_fMinX, fY );
+ std::sprintf( pBuf, "%g", fY );
+ String aMark( pBuf, gsl_getSystemTextEncoding() );
+ Size aTextSize( GetTextWidth( aMark ), GetTextHeight() );
+ aPt.X() -= aTextSize.Width() + 2;
+ aPt.Y() -= aTextSize.Height()/2;
+ DrawText( aPt, aMark );
+ }
+
+ // draw boundings
+ drawLine( m_fMinX, m_fMinY, m_fMaxX, m_fMinY );
+ drawLine( m_fMinX, m_fMaxY, m_fMaxX, m_fMaxY );
+ drawLine( m_fMinX, m_fMinY, m_fMinX, m_fMaxY );
+ drawLine( m_fMaxX, m_fMinY, m_fMaxX, m_fMaxY );
+}
+
+// ---------------------------------------------------------------------
+
+void GridWindow::drawOriginal()
+{
+ if( m_nValues && m_pXValues && m_pOrigYValues )
+ {
+ SetLineColor( Color( COL_RED ) );
+ for( int i = 0; i < m_nValues-1; i++ )
+ {
+ drawLine( m_pXValues[ i ], m_pOrigYValues[ i ],
+ m_pXValues[ i+1 ], m_pOrigYValues[ i+1 ] );
+ }
+ }
+}
+
+// ---------------------------------------------------------------------
+
+void GridWindow::drawNew()
+{
+ if( m_nValues && m_pXValues && m_pNewYValues )
+ {
+ SetClipRegion( m_aGridArea );
+ SetLineColor( Color( COL_YELLOW ) );
+ for( int i = 0; i < m_nValues-1; i++ )
+ {
+ drawLine( m_pXValues[ i ], m_pNewYValues[ i ],
+ m_pXValues[ i+1 ], m_pNewYValues[ i+1 ] );
+ }
+ SetClipRegion();
+ }
+}
+
+// ---------------------------------------------------------------------
+
+void GridWindow::drawHandles()
+{
+ for(sal_uInt32 i(0L); i < m_aHandles.size(); i++)
+ {
+ m_aHandles[i].draw(*this, m_aMarkerBitmap);
+ }
+}
+
+// ---------------------------------------------------------------------
+
+void GridWindow::Paint( const Rectangle& rRect )
+{
+ ModalDialog::Paint( rRect );
+ drawGrid();
+ drawOriginal();
+ drawNew();
+ drawHandles();
+}
+
+// ---------------------------------------------------------------------
+
+void GridWindow::MouseMove( const MouseEvent& rEvt )
+{
+ if( rEvt.GetButtons() == MOUSE_LEFT && m_nDragIndex != 0xffffffff )
+ {
+ Point aPoint( rEvt.GetPosPixel() );
+
+ if( m_nDragIndex == 0L || m_nDragIndex == m_aHandles.size() - 1L)
+ {
+ aPoint.X() = m_aHandles[m_nDragIndex].maPos.X();
+ }
+ else
+ {
+ if(aPoint.X() < m_aGridArea.Left())
+ aPoint.X() = m_aGridArea.Left();
+ else if(aPoint.X() > m_aGridArea.Right())
+ aPoint.X() = m_aGridArea.Right();
+ }
+
+ if( aPoint.Y() < m_aGridArea.Top() )
+ aPoint.Y() = m_aGridArea.Top();
+ else if( aPoint.Y() > m_aGridArea.Bottom() )
+ aPoint.Y() = m_aGridArea.Bottom();
+
+ if( aPoint != m_aHandles[m_nDragIndex].maPos )
+ {
+ m_aHandles[m_nDragIndex].maPos = aPoint;
+ Invalidate( m_aGridArea );
+ }
+ }
+
+ ModalDialog::MouseMove( rEvt );
+}
+
+// ---------------------------------------------------------------------
+
+void GridWindow::MouseButtonUp( const MouseEvent& rEvt )
+{
+ if( rEvt.GetButtons() == MOUSE_LEFT )
+ {
+ if( m_nDragIndex != 0xffffffff )
+ {
+ m_nDragIndex = 0xffffffff;
+ computeNew();
+ Invalidate( m_aGridArea );
+ Paint( m_aGridArea );
+ }
+ }
+
+ ModalDialog::MouseButtonUp( rEvt );
+}
+
+// ---------------------------------------------------------------------
+
+void GridWindow::MouseButtonDown( const MouseEvent& rEvt )
+{
+ Point aPoint( rEvt.GetPosPixel() );
+ sal_uInt32 nMarkerIndex = 0xffffffff;
+
+ for(sal_uInt32 a(0L); nMarkerIndex == 0xffffffff && a < m_aHandles.size(); a++)
+ {
+ if(m_aHandles[a].isHit(*this, aPoint))
+ {
+ nMarkerIndex = a;
+ }
+ }
+
+ if( rEvt.GetButtons() == MOUSE_LEFT )
+ {
+ // user wants to drag a button
+ if( nMarkerIndex != 0xffffffff )
+ {
+ m_nDragIndex = nMarkerIndex;
+ }
+ }
+ else if( rEvt.GetButtons() == MOUSE_RIGHT )
+ {
+ // user wants to add/delete a button
+ if( nMarkerIndex != 0xffffffff )
+ {
+ if( nMarkerIndex != 0L && nMarkerIndex != m_aHandles.size() - 1L)
+ {
+ // delete marker under mouse
+ if( m_nDragIndex == nMarkerIndex )
+ m_nDragIndex = 0xffffffff;
+
+ m_aHandles.erase(m_aHandles.begin() + nMarkerIndex);
+ }
+ }
+ else
+ {
+ m_BmOffX = sal_uInt16(m_aMarkerBitmap.GetSizePixel().Width() >> 1);
+ m_BmOffY = sal_uInt16(m_aMarkerBitmap.GetSizePixel().Height() >> 1);
+ m_aHandles.push_back(impHandle(aPoint, m_BmOffX, m_BmOffY));
+ }
+
+ computeNew();
+ Invalidate( m_aGridArea );
+ Paint( m_aGridArea );
+ }
+
+ ModalDialog::MouseButtonDown( rEvt );
+}
+
+// ---------------------------------------------------------------------
+
+IMPL_LINK( GridWindow, ClickButtonHdl, Button*, pButton )
+{
+ if( pButton == &m_aResetButton )
+ {
+ int nType = (int)(sal_IntPtr)m_aResetTypeBox.GetEntryData( m_aResetTypeBox.GetSelectEntryPos() );
+ switch( nType )
+ {
+ case RESET_TYPE_LINEAR_ASCENDING:
+ {
+ for( int i = 0; i < m_nValues; i++ )
+ {
+ m_pNewYValues[ i ] = m_fMinY + (m_fMaxY-m_fMinY)/(m_fMaxX-m_fMinX)*(m_pXValues[i]-m_fMinX);
+ }
+ }
+ break;
+ case RESET_TYPE_LINEAR_DESCENDING:
+ {
+ for( int i = 0; i < m_nValues; i++ )
+ {
+ m_pNewYValues[ i ] = m_fMaxY - (m_fMaxY-m_fMinY)/(m_fMaxX-m_fMinX)*(m_pXValues[i]-m_fMinX);
+ }
+ }
+ break;
+ case RESET_TYPE_RESET:
+ {
+ if( m_pOrigYValues && m_pNewYValues && m_nValues )
+ memcpy( m_pNewYValues, m_pOrigYValues, m_nValues*sizeof(double) );
+ }
+ break;
+ case RESET_TYPE_EXPONENTIAL:
+ {
+ for( int i = 0; i < m_nValues; i++ )
+ {
+ m_pNewYValues[ i ] = m_fMinY + (m_fMaxY-m_fMinY)*(std::exp((m_pXValues[i]-m_fMinX)/(m_fMaxX-m_fMinX))-1.0)/(M_E-1.0);
+ }
+ }
+ break;
+
+ default:
+ break;
+ }
+
+ for(sal_uInt32 i(0L); i < m_aHandles.size(); i++)
+ {
+ // find nearest xvalue
+ double x, y;
+ transform( m_aHandles[i].maPos, x, y );
+ int nIndex = 0;
+ double delta = std::fabs( x-m_pXValues[0] );
+ for( int n = 1; n < m_nValues; n++ )
+ {
+ if( delta > std::fabs( x - m_pXValues[ n ] ) )
+ {
+ delta = std::fabs( x - m_pXValues[ n ] );
+ nIndex = n;
+ }
+ }
+ if( 0 == i )
+ m_aHandles[i].maPos = transform( m_fMinX, m_pNewYValues[ nIndex ] );
+ else if( m_aHandles.size() - 1L == i )
+ m_aHandles[i].maPos = transform( m_fMaxX, m_pNewYValues[ nIndex ] );
+ else
+ m_aHandles[i].maPos = transform( m_pXValues[ nIndex ], m_pNewYValues[ nIndex ] );
+ }
+
+ Invalidate( m_aGridArea );
+ Paint(Rectangle());
+ }
+ return 0;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/scanner/grid.hrc b/extensions/source/scanner/grid.hrc
new file mode 100644
index 000000000000..fa364b909102
--- /dev/null
+++ b/extensions/source/scanner/grid.hrc
@@ -0,0 +1,42 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef GRID_HRC
+#define GRID_HRC
+
+#define GRID_DIALOG 1100
+#define GRID_DIALOG_OK_BTN 1
+#define GRID_DIALOG_CANCEL_BTN 2
+#define GRID_DIALOG_RESET_BTN 3
+#define GRID_DIALOG_TYPE_BOX 4
+#define GRID_DIALOG_HANDLE_BMP 5
+
+#define RESET_TYPE_LINEAR_ASCENDING 10
+#define RESET_TYPE_LINEAR_DESCENDING 11
+#define RESET_TYPE_RESET 12
+#define RESET_TYPE_EXPONENTIAL 13
+
+#endif
diff --git a/extensions/source/scanner/grid.hxx b/extensions/source/scanner/grid.hxx
new file mode 100644
index 000000000000..d598b1a6a469
--- /dev/null
+++ b/extensions/source/scanner/grid.hxx
@@ -0,0 +1,150 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef _EXTENSIONS_SCANNER_GRID_HXX
+#define _EXTENSIONS_SCANNER_GRID_HXX
+
+#include <vcl/window.hxx>
+#include <vcl/button.hxx>
+#include <vcl/lstbox.hxx>
+#include <vcl/dialog.hxx>
+
+class GridWindow : public ModalDialog
+{
+ // helper class for handles
+ struct impHandle
+ {
+ Point maPos;
+ sal_uInt16 mnOffX;
+ sal_uInt16 mnOffY;
+
+ impHandle(const Point& rPos, sal_uInt16 nX, sal_uInt16 nY)
+ : maPos(rPos), mnOffX(nX), mnOffY(nY)
+ {
+ }
+
+ bool operator<(const impHandle& rComp) const
+ {
+ return (maPos.X() < rComp.maPos.X());
+ }
+
+ void draw(Window& rWin, const BitmapEx& rBitmapEx)
+ {
+ const Point aOffset(rWin.PixelToLogic(Point(mnOffX, mnOffY)));
+ rWin.DrawBitmapEx(maPos - aOffset, rBitmapEx);
+ }
+
+ bool isHit(Window& rWin, const Point& rPos)
+ {
+ const Point aOffset(rWin.PixelToLogic(Point(mnOffX, mnOffY)));
+ const Rectangle aTarget(maPos - aOffset, maPos + aOffset);
+ return aTarget.IsInside(rPos);
+ }
+ };
+
+ Rectangle m_aGridArea;
+
+ double m_fMinX;
+ double m_fMinY;
+ double m_fMaxX;
+ double m_fMaxY;
+
+ double m_fChunkX;
+ double m_fMinChunkX;
+ double m_fChunkY;
+ double m_fMinChunkY;
+
+ double* m_pXValues;
+ double* m_pOrigYValues;
+ int m_nValues;
+ double* m_pNewYValues;
+
+ sal_uInt16 m_BmOffX;
+ sal_uInt16 m_BmOffY;
+
+ BOOL m_bCutValues;
+
+ // stuff for handles
+ std::vector< impHandle > m_aHandles;
+ sal_uInt32 m_nDragIndex;
+
+ BitmapEx m_aMarkerBitmap;
+
+ OKButton m_aOKButton;
+ CancelButton m_aCancelButton;
+
+ ListBox m_aResetTypeBox;
+ PushButton m_aResetButton;
+
+
+ Point transform( double x, double y );
+ void transform( const Point& rOriginal, double& x, double& y );
+
+ double findMinX();
+ double findMinY();
+ double findMaxX();
+ double findMaxY();
+
+ void drawGrid();
+ void drawOriginal();
+ void drawNew();
+ void drawHandles();
+
+ void computeExtremes();
+ void computeChunk( double fMin, double fMax, double& fChunkOut, double& fMinChunkOut );
+ void computeNew();
+ double interpolate( double x, double* pNodeX, double* pNodeY, int nNodes );
+
+ DECL_LINK( ClickButtonHdl, Button* );
+
+ virtual void MouseMove( const MouseEvent& );
+ virtual void MouseButtonDown( const MouseEvent& );
+ virtual void MouseButtonUp( const MouseEvent& );
+public:
+ GridWindow( double* pXValues, double* pYValues, int nValues,
+ Window* pParent, BOOL bCutValues = TRUE );
+ ~GridWindow();
+
+ void setBoundings( double fMinX, double fMinY, double fMaxX, double fMaxY );
+ double getMinX() { return m_fMinX; }
+ double getMinY() { return m_fMinY; }
+ double getMaxX() { return m_fMaxX; }
+ double getMaxY() { return m_fMaxY; }
+
+ int countValues() { return m_nValues; }
+ double* getXValues() { return m_pXValues; }
+ double* getOrigYValues() { return m_pOrigYValues; }
+ double* getNewYValues() { return m_pNewYValues; }
+
+ void drawLine( double x1, double y1, double x2, double y2 );
+
+ virtual void Paint( const Rectangle& rRect );
+};
+
+#endif // _EXTENSIONS_SCANNER_GRID_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/scanner/grid.src b/extensions/source/scanner/grid.src
new file mode 100644
index 000000000000..ddf593ef77ce
--- /dev/null
+++ b/extensions/source/scanner/grid.src
@@ -0,0 +1,112 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#include <grid.hrc>
+
+ModalDialog GRID_DIALOG
+{
+ OutputSize = TRUE ;
+ SVLook = TRUE ;
+ Pos = MAP_APPFONT ( 10 , 10 ) ;
+ Size = MAP_APPFONT ( 300, 200 ) ;
+ Moveable = TRUE ;
+ Closeable = TRUE ;
+
+ OKButton GRID_DIALOG_OK_BTN
+ {
+ Pos = MAP_APPFONT( 245, 5 );
+ Size = MAP_APPFONT( 50, 15 );
+ DefButton = TRUE;
+ };
+ CancelButton GRID_DIALOG_CANCEL_BTN
+ {
+ Pos = MAP_APPFONT ( 245 , 25 ) ;
+ Size = MAP_APPFONT ( 50 , 15 ) ;
+ };
+ ListBox GRID_DIALOG_TYPE_BOX
+ {
+ Border = TRUE ;
+ Dropdown = TRUE ;
+ Pos = MAP_APPFONT( 245, 45 );
+ Size = MAP_APPFONT( 50, 130 );
+ };
+ PushButton GRID_DIALOG_RESET_BTN
+ {
+ Pos = MAP_APPFONT( 245, 65 );
+ Size = MAP_APPFONT( 50, 15 );
+ Text [ en-US ] = "Set";
+ };
+ Bitmap GRID_DIALOG_HANDLE_BMP
+ {
+ File = "handle.bmp";
+ };
+ String RESET_TYPE_LINEAR_ASCENDING
+ {
+ Text [ en-US ] = "Linear ascending";
+ };
+ String RESET_TYPE_LINEAR_DESCENDING
+ {
+ Text [ en-US ] = "Linear descending";
+ };
+ String RESET_TYPE_RESET
+ {
+ Text [ en-US ] = "Original values";
+ };
+ String RESET_TYPE_EXPONENTIAL
+ {
+ Text [ en-US ] = "Exponential increasing";
+ };
+};
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/extensions/source/scanner/makefile.mk b/extensions/source/scanner/makefile.mk
new file mode 100644
index 000000000000..baaefdf66e7d
--- /dev/null
+++ b/extensions/source/scanner/makefile.mk
@@ -0,0 +1,96 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+PRJ=..$/..
+PRJNAME=extensions
+TARGET=scn
+ENABLE_EXCEPTIONS=TRUE
+PACKAGE=com$/sun$/star$/scanner
+USE_DEFFILE=TRUE
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : $(PRJ)$/util$/makefile.pmk
+
+# --- Files --------------------------------------------------------
+
+SLOFILES=\
+ $(SLO)$/scnserv.obj \
+ $(SLO)$/scanner.obj
+
+.IF "$(GUI)"=="WNT"
+SLOFILES+=\
+ $(SLO)$/scanwin.obj
+.ENDIF
+
+.IF "$(GUI)"=="UNX" || "$(GUI)" =="OS2"
+SLOFILES+=\
+ $(SLO)$/sane.obj \
+ $(SLO)$/sanedlg.obj \
+ $(SLO)$/scanunx.obj \
+ $(SLO)$/grid.obj
+
+.ENDIF
+
+SRS1NAME=$(TARGET)
+SRC1FILES=\
+ sanedlg.src \
+ grid.src
+
+RESLIB1NAME=san
+RESLIB1IMAGES=$(PRJ)$/source$/scanner
+RESLIB1SRSFILES= $(SRS)$/scn.srs
+RESLIB1DEPN= sanedlg.src sanedlg.hrc grid.src grid.hrc
+
+SHL1TARGET= $(TARGET)$(DLLPOSTFIX)
+SHL1STDLIBS=\
+ $(CPPULIB) \
+ $(CPPUHELPERLIB) \
+ $(COMPHELPERLIB) \
+ $(SALLIB) \
+ $(ONELIB) \
+ $(TOOLSLIB) \
+ $(VCLLIB) \
+ $(SVTOOLLIB)
+
+.IF "$(GUI)"=="UNX" && "$(OS)"!="FREEBSD" && \
+ "$(OS)"!="NETBSD" && "$(OS)"!="OPENBSD"
+SHL1STDLIBS+=$(SVTOOLLIB) -ldl
+.ENDIF
+
+SHL1DEF=$(MISC)$/$(SHL1TARGET).def
+SHL1IMPLIB=i$(TARGET)
+SHL1LIBS=$(SLB)$/$(TARGET).lib
+SHL1VERSIONMAP=$(SOLARENV)/src/component.map
+
+DEF1NAME=$(SHL1TARGET)
+DEF1EXPORTFILE=exports.dxp
+
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : target.mk
+
diff --git a/extensions/source/scanner/sane.cxx b/extensions/source/scanner/sane.cxx
new file mode 100644
index 000000000000..717cf4c6140a
--- /dev/null
+++ b/extensions/source/scanner/sane.cxx
@@ -0,0 +1,1008 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+#include <cstdarg>
+#include <math.h>
+#include <osl/file.h>
+#include <tools/stream.hxx>
+#include <sane.hxx>
+#include <dlfcn.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <sys/time.h>
+#include <sys/types.h>
+#include <sal/config.h>
+#include <sal/macros.h>
+
+#if (OSL_DEBUG_LEVEL > 1) || defined DBG_UTIL
+#include <stdarg.h>
+#define dump_state( a, b, c, d ) fprintf( stderr, a, b, c, d );
+#else
+#define dump_state( a, b, c, d ) ;
+#endif
+inline void dbg_msg( const char* pString, ... )
+{
+#if (OSL_DEBUG_LEVEL > 1) || defined DBG_UTIL
+ va_list ap;
+ va_start( ap, pString );
+ vfprintf( stderr, pString, ap );
+ va_end( ap );
+#else
+ (void)pString;
+#endif
+}
+
+#define FAIL_SHUTDOWN_STATE( x, y, z ) \
+ if( x != SANE_STATUS_GOOD ) \
+ { \
+ dump_state( "%s returned error %d (%s)\n", \
+ y, x, p_strstatus( x ) ); \
+ DeInit(); \
+ return z; \
+ }
+
+#define FAIL_STATE( x, y, z ) \
+ if( x != SANE_STATUS_GOOD ) \
+ { \
+ dump_state( "%s returned error %d (%s)\n", \
+ y, x, p_strstatus( x ) ); \
+ return z; \
+ }
+
+#define DUMP_STATE( x, y ) \
+ if( x != SANE_STATUS_GOOD ) \
+ { \
+ dump_state( "%s returned error %d (%s)\n", \
+ y, x, p_strstatus( x ) ); \
+ }
+
+#define CHECK_STATE( x, y ) \
+ if( x != SANE_STATUS_GOOD ) \
+ { \
+ dump_state( "%s returned error %d (%s)\n", \
+ y, x, p_strstatus( x ) ); \
+ } \
+ else
+
+int Sane::nRefCount = 0;
+oslModule Sane::pSaneLib = 0;
+SANE_Int Sane::nVersion = 0;
+SANE_Device** Sane::ppDevices = 0;
+int Sane::nDevices = 0;
+
+SANE_Status (*Sane::p_init)( SANE_Int*,
+ SANE_Auth_Callback ) = 0;
+void (*Sane::p_exit)() = 0;
+SANE_Status (*Sane::p_get_devices)( const SANE_Device***,
+ SANE_Bool ) = 0;
+SANE_Status (*Sane::p_open)( SANE_String_Const, SANE_Handle ) = 0;
+void (*Sane::p_close)( SANE_Handle ) = 0;
+const SANE_Option_Descriptor* (*Sane::p_get_option_descriptor)(
+ SANE_Handle, SANE_Int ) = 0;
+SANE_Status (*Sane::p_control_option)( SANE_Handle, SANE_Int,
+ SANE_Action, void*,
+ SANE_Int* ) = 0;
+SANE_Status (*Sane::p_get_parameters)( SANE_Handle,
+ SANE_Parameters* ) = 0;
+SANE_Status (*Sane::p_start)( SANE_Handle ) = 0;
+SANE_Status (*Sane::p_read)( SANE_Handle, SANE_Byte*, SANE_Int,
+ SANE_Int* ) = 0;
+void (*Sane::p_cancel)( SANE_Handle ) = 0;
+SANE_Status (*Sane::p_set_io_mode)( SANE_Handle, SANE_Bool ) = 0;
+SANE_Status (*Sane::p_get_select_fd)( SANE_Handle, SANE_Int* ) = 0;
+SANE_String_Const (*Sane::p_strstatus)( SANE_Status ) = 0;
+
+static BOOL bSaneSymbolLoadFailed = FALSE;
+
+inline oslGenericFunction Sane::LoadSymbol( const char* pSymbolname )
+{
+ oslGenericFunction pFunction = osl_getAsciiFunctionSymbol( pSaneLib, pSymbolname );
+ if( ! pFunction )
+ {
+ fprintf( stderr, "Could not load symbol %s\n",
+ pSymbolname );
+ bSaneSymbolLoadFailed = TRUE;
+ }
+ return pFunction;
+}
+
+SANE_Status Sane::ControlOption( int nOption, SANE_Action nAction,
+ void* pData )
+{
+ SANE_Status nStatus = SANE_STATUS_GOOD;
+ SANE_Int nInfo = 0;
+
+ nStatus = p_control_option( maHandle, (SANE_Int)nOption,
+ nAction, pData, &nInfo );
+ DUMP_STATE( nStatus, "sane_control_option" );
+#if OSL_DEBUG_LEVEL > 1
+ if( nStatus != SANE_STATUS_GOOD )
+ {
+ const char* pAction = "Unknown";
+ switch( nAction )
+ {
+ case SANE_ACTION_GET_VALUE:
+ pAction = "SANE_ACTION_GET_VALUE";break;
+ case SANE_ACTION_SET_VALUE:
+ pAction = "SANE_ACTION_SET_VALUE";break;
+ case SANE_ACTION_SET_AUTO:
+ pAction = "SANE_ACTION_SET_AUTO";break;
+ }
+ dbg_msg( "Option: \"%s\" action: %s\n",
+ ByteString( GetOptionName( nOption ), gsl_getSystemTextEncoding() ).GetBuffer(),
+ pAction );
+ }
+#endif
+// if( nInfo & ( SANE_INFO_RELOAD_OPTIONS | SANE_INFO_RELOAD_PARAMS ) )
+ if( nInfo & SANE_INFO_RELOAD_OPTIONS )
+ ReloadOptions();
+ return nStatus;
+}
+
+Sane::Sane() :
+ mppOptions( 0 ),
+ mnOptions( 0 ),
+ mnDevice( -1 ),
+ maHandle( 0 )
+{
+ if( ! nRefCount || ! pSaneLib )
+ Init();
+ nRefCount++;
+};
+
+Sane::~Sane()
+{
+ if( IsOpen() )
+ Close();
+ nRefCount--;
+ if( ! nRefCount && pSaneLib )
+ DeInit();
+}
+
+void Sane::Init()
+{
+ ::rtl::OUString sSaneLibName( ::rtl::OUString::createFromAscii( "libsane" SAL_DLLEXTENSION ) );
+ pSaneLib = osl_loadModule( sSaneLibName.pData, SAL_LOADMODULE_LAZY );
+ if( ! pSaneLib )
+ {
+ sSaneLibName = ::rtl::OUString::createFromAscii( "libsane" SAL_DLLEXTENSION ".1" );
+ pSaneLib = osl_loadModule( sSaneLibName.pData, SAL_LOADMODULE_LAZY );
+ }
+ // try reasonable places that might not be in the library search path
+ if( ! pSaneLib )
+ {
+ ::rtl::OUString sSaneLibSystemPath( ::rtl::OUString::createFromAscii( "/usr/local/lib/libsane" SAL_DLLEXTENSION ) );
+ osl_getFileURLFromSystemPath( sSaneLibSystemPath.pData, &sSaneLibName.pData );
+ pSaneLib = osl_loadModule( sSaneLibName.pData, SAL_LOADMODULE_LAZY );
+ }
+
+ if( pSaneLib )
+ {
+ bSaneSymbolLoadFailed = FALSE;
+ p_init = (SANE_Status(*)(SANE_Int*, SANE_Auth_Callback ))
+ LoadSymbol( "sane_init" );
+ p_exit = (void(*)())
+ LoadSymbol( "sane_exit" );
+ p_get_devices = (SANE_Status(*)(const SANE_Device***,
+ SANE_Bool ))
+ LoadSymbol( "sane_get_devices" );
+ p_open = (SANE_Status(*)(SANE_String_Const, SANE_Handle ))
+ LoadSymbol( "sane_open" );
+ p_close = (void(*)(SANE_Handle))
+ LoadSymbol( "sane_close" );
+ p_get_option_descriptor = (const SANE_Option_Descriptor*(*)(SANE_Handle,
+ SANE_Int))
+ LoadSymbol( "sane_get_option_descriptor" );
+ p_control_option = (SANE_Status(*)(SANE_Handle, SANE_Int,
+ SANE_Action, void*, SANE_Int*))
+ LoadSymbol( "sane_control_option" );
+ p_get_parameters = (SANE_Status(*)(SANE_Handle,SANE_Parameters*))
+ LoadSymbol( "sane_get_parameters" );
+ p_start = (SANE_Status(*)(SANE_Handle))
+ LoadSymbol( "sane_start" );
+ p_read = (SANE_Status(*)(SANE_Handle, SANE_Byte*,
+ SANE_Int, SANE_Int* ))
+ LoadSymbol( "sane_read" );
+ p_cancel = (void(*)(SANE_Handle))
+ LoadSymbol( "sane_cancel" );
+ p_set_io_mode = (SANE_Status(*)(SANE_Handle, SANE_Bool))
+ LoadSymbol( "sane_set_io_mode" );
+ p_get_select_fd = (SANE_Status(*)(SANE_Handle, SANE_Int*))
+ LoadSymbol( "sane_get_select_fd" );
+ p_strstatus = (SANE_String_Const(*)(SANE_Status))
+ LoadSymbol( "sane_strstatus" );
+ if( bSaneSymbolLoadFailed )
+ DeInit();
+ else
+ {
+ SANE_Status nStatus = p_init( &nVersion, 0 );
+ FAIL_SHUTDOWN_STATE( nStatus, "sane_init", );
+ nStatus = p_get_devices( (const SANE_Device***)&ppDevices,
+ SANE_FALSE );
+ FAIL_SHUTDOWN_STATE( nStatus, "sane_get_devices", );
+ for( nDevices = 0 ; ppDevices[ nDevices ]; nDevices++ ) ;
+ }
+ }
+#if (OSL_DEBUG_LEVEL > 1) || defined DBG_UTIL
+ else
+ fprintf( stderr, "libsane%s could not be opened: %s\n", SAL_DLLEXTENSION,
+ dlerror() );
+#endif
+}
+
+void Sane::DeInit()
+{
+ if( pSaneLib )
+ {
+ p_exit();
+ osl_unloadModule( pSaneLib );
+ pSaneLib = 0;
+ }
+}
+
+void Sane::ReloadDevices()
+{
+ if( IsOpen() )
+ Close();
+ DeInit();
+ Init();
+}
+
+void Sane::ReloadOptions()
+{
+ if( ! IsOpen() )
+ return;
+
+ SANE_Option_Descriptor* pZero = (SANE_Option_Descriptor*)
+ p_get_option_descriptor( maHandle, 0 );
+ SANE_Word pOptions[2];
+ SANE_Status nStatus = p_control_option( maHandle, 0, SANE_ACTION_GET_VALUE,
+ (void*)pOptions, NULL );
+ if( nStatus != SANE_STATUS_GOOD )
+ fprintf( stderr, "Error: sane driver returned %s while reading number of options !\n", p_strstatus( nStatus ) );
+
+ mnOptions = pOptions[ 0 ];
+ if( (size_t)pZero->size > sizeof( SANE_Word ) )
+ fprintf( stderr, "driver returned numer of options with larger size tha SANE_Word !!!\n" );
+ if( mppOptions )
+ delete [] mppOptions;
+ mppOptions = (const SANE_Option_Descriptor**)new SANE_Option_Descriptor*[ mnOptions ];
+ mppOptions[ 0 ] = (SANE_Option_Descriptor*)pZero;
+ for( int i = 1; i < mnOptions; i++ )
+ mppOptions[ i ] = (SANE_Option_Descriptor*)
+ p_get_option_descriptor( maHandle, i );
+
+ CheckConsistency( NULL, TRUE );
+
+ maReloadOptionsLink.Call( this );
+}
+
+BOOL Sane::Open( const char* name )
+{
+ int i;
+
+ SANE_Status nStatus = p_open( (SANE_String_Const)name, &maHandle );
+ FAIL_STATE( nStatus, "sane_open", FALSE );
+
+ ReloadOptions();
+
+ if( mnDevice == -1 )
+ {
+ ByteString aDevice( name );
+ for( i = 0; i < nDevices; i++ )
+ {
+ if( aDevice.Equals( ppDevices[i]->name ) )
+ {
+ mnDevice = i;
+ break;
+ }
+ }
+ }
+
+ return TRUE;
+}
+
+BOOL Sane::Open( int n )
+{
+ if( n >= 0 && n < nDevices )
+ {
+ mnDevice = n;
+ return Open( (char*)ppDevices[n]->name );
+ }
+ return FALSE;
+}
+
+void Sane::Close()
+{
+ if( maHandle )
+ {
+ p_close( maHandle );
+ delete [] mppOptions;
+ mppOptions = 0;
+ maHandle = 0;
+ mnDevice = -1;
+ }
+}
+
+int Sane::GetOptionByName( const char* rName )
+{
+ int i;
+ ByteString aOption( rName );
+ for( i = 0; i < mnOptions; i++ )
+ {
+ if( mppOptions[i]->name && aOption.Equals( mppOptions[i]->name ) )
+ return i;
+ }
+ return -1;
+}
+
+BOOL Sane::GetOptionValue( int n, BOOL& rRet )
+{
+ if( ! maHandle || mppOptions[n]->type != SANE_TYPE_BOOL )
+ return FALSE;
+ SANE_Word nRet;
+ SANE_Status nStatus = ControlOption( n, SANE_ACTION_GET_VALUE, &nRet );
+ if( nStatus != SANE_STATUS_GOOD )
+ return FALSE;
+
+ rRet = nRet;
+ return TRUE;
+}
+
+BOOL Sane::GetOptionValue( int n, ByteString& rRet )
+{
+ BOOL bSuccess = FALSE;
+ if( ! maHandle || mppOptions[n]->type != SANE_TYPE_STRING )
+ return FALSE;
+ char* pRet = new char[mppOptions[n]->size+1];
+ SANE_Status nStatus = ControlOption( n, SANE_ACTION_GET_VALUE, pRet );
+ if( nStatus == SANE_STATUS_GOOD )
+ {
+ bSuccess = TRUE;
+ rRet = pRet;
+ }
+ delete [] pRet;
+ return bSuccess;
+}
+
+BOOL Sane::GetOptionValue( int n, double& rRet, int nElement )
+{
+ BOOL bSuccess = FALSE;
+
+ if( ! maHandle || ( mppOptions[n]->type != SANE_TYPE_INT &&
+ mppOptions[n]->type != SANE_TYPE_FIXED ) )
+ return FALSE;
+
+ SANE_Word* pRet = new SANE_Word[mppOptions[n]->size/sizeof(SANE_Word)];
+ SANE_Status nStatus = ControlOption( n, SANE_ACTION_GET_VALUE, pRet );
+ if( nStatus == SANE_STATUS_GOOD )
+ {
+ bSuccess = TRUE;
+ if( mppOptions[n]->type == SANE_TYPE_INT )
+ rRet = (double)pRet[ nElement ];
+ else
+ rRet = SANE_UNFIX( pRet[nElement] );
+ }
+ delete [] pRet;
+ return bSuccess;
+}
+
+BOOL Sane::GetOptionValue( int n, double* pSet )
+{
+ if( ! maHandle || ! ( mppOptions[n]->type == SANE_TYPE_FIXED ||
+ mppOptions[n]->type == SANE_TYPE_INT ) )
+ return FALSE;
+
+ SANE_Word* pFixedSet = new SANE_Word[mppOptions[n]->size/sizeof(SANE_Word)];
+ SANE_Status nStatus = ControlOption( n, SANE_ACTION_GET_VALUE, pFixedSet );
+ if( nStatus != SANE_STATUS_GOOD )
+ {
+ delete [] pFixedSet;
+ return FALSE;
+ }
+ for( size_t i = 0; i <mppOptions[n]->size/sizeof(SANE_Word); i++ )
+ {
+ if( mppOptions[n]->type == SANE_TYPE_FIXED )
+ pSet[i] = SANE_UNFIX( pFixedSet[i] );
+ else
+ pSet[i] = (double) pFixedSet[i];
+ }
+ delete [] pFixedSet;
+ return TRUE;
+}
+
+BOOL Sane::SetOptionValue( int n, BOOL bSet )
+{
+ if( ! maHandle || mppOptions[n]->type != SANE_TYPE_BOOL )
+ return FALSE;
+ SANE_Word nRet = bSet ? SANE_TRUE : SANE_FALSE;
+ SANE_Status nStatus = ControlOption( n, SANE_ACTION_SET_VALUE, &nRet );
+ if( nStatus != SANE_STATUS_GOOD )
+ return FALSE;
+ return TRUE;
+}
+
+BOOL Sane::SetOptionValue( int n, const String& rSet )
+{
+ if( ! maHandle || mppOptions[n]->type != SANE_TYPE_STRING )
+ return FALSE;
+ ByteString aSet( rSet, gsl_getSystemTextEncoding() );
+ SANE_Status nStatus = ControlOption( n, SANE_ACTION_SET_VALUE, (void*)aSet.GetBuffer() );
+ if( nStatus != SANE_STATUS_GOOD )
+ return FALSE;
+ return TRUE;
+}
+
+BOOL Sane::SetOptionValue( int n, double fSet, int nElement )
+{
+ BOOL bSuccess = FALSE;
+
+ if( ! maHandle || ( mppOptions[n]->type != SANE_TYPE_INT &&
+ mppOptions[n]->type != SANE_TYPE_FIXED ) )
+ return FALSE;
+
+ SANE_Status nStatus;
+ if( mppOptions[n]->size/sizeof(SANE_Word) > 1 )
+ {
+ SANE_Word* pSet = new SANE_Word[mppOptions[n]->size/sizeof(SANE_Word)];
+ nStatus = ControlOption( n, SANE_ACTION_GET_VALUE, pSet );
+ if( nStatus == SANE_STATUS_GOOD )
+ {
+ pSet[nElement] = mppOptions[n]->type == SANE_TYPE_INT ?
+ (SANE_Word)fSet : SANE_FIX( fSet );
+ nStatus = ControlOption( n, SANE_ACTION_SET_VALUE, pSet );
+ }
+ delete [] pSet;
+ }
+ else
+ {
+ SANE_Word nSetTo =
+ mppOptions[n]->type == SANE_TYPE_INT ?
+ (SANE_Word)fSet : SANE_FIX( fSet );
+
+ nStatus = ControlOption( n, SANE_ACTION_SET_VALUE, &nSetTo );
+ if( nStatus == SANE_STATUS_GOOD )
+ bSuccess = TRUE;
+ }
+ return bSuccess;
+}
+
+BOOL Sane::SetOptionValue( int n, double* pSet )
+{
+ if( ! maHandle || ( mppOptions[n]->type != SANE_TYPE_INT &&
+ mppOptions[n]->type != SANE_TYPE_FIXED ) )
+ return FALSE;
+ SANE_Word* pFixedSet = new SANE_Word[mppOptions[n]->size/sizeof(SANE_Word)];
+ for( size_t i = 0; i < mppOptions[n]->size/sizeof(SANE_Word); i++ )
+ {
+ if( mppOptions[n]->type == SANE_TYPE_FIXED )
+ pFixedSet[i] = SANE_FIX( pSet[i] );
+ else
+ pFixedSet[i] = (SANE_Word)pSet[i];
+ }
+ SANE_Status nStatus = ControlOption( n, SANE_ACTION_SET_VALUE, pFixedSet );
+ delete [] pFixedSet;
+ if( nStatus != SANE_STATUS_GOOD )
+ return FALSE;
+ return TRUE;
+}
+
+enum FrameStyleType {
+ FrameStyle_BW, FrameStyle_Gray, FrameStyle_RGB, FrameStyle_Separated
+};
+
+#define BYTE_BUFFER_SIZE 32768
+
+static inline UINT8 _ReadValue( FILE* fp, int depth )
+{
+ if( depth == 16 )
+ {
+ UINT16 nWord;
+ // data always come in native byte order !
+ // 16 bits is not really supported by backends as of now
+ // e.g. UMAX Astra 1200S delivers 16 bit but in BIGENDIAN
+ // against SANE documentation (xscanimage gets the same result
+ // as we do
+ fread( &nWord, 1, 2, fp );
+ return (UINT8)( nWord / 256 );
+ }
+ UINT8 nByte;
+ fread( &nByte, 1, 1, fp );
+ return nByte;
+}
+
+BOOL Sane::CheckConsistency( const char* pMes, BOOL bInit )
+{
+ static SANE_Option_Descriptor** pDescArray = NULL;
+ static SANE_Option_Descriptor* pZero = NULL;
+
+ if( bInit )
+ {
+ pDescArray = (SANE_Option_Descriptor**)mppOptions;
+ if( mppOptions )
+ pZero = (SANE_Option_Descriptor*)mppOptions[0];
+ return TRUE;
+ }
+
+ BOOL bConsistent = TRUE;
+
+ if( pDescArray != mppOptions )
+ bConsistent = FALSE;
+ if( pZero != mppOptions[0] )
+ bConsistent = FALSE;
+
+ if( ! bConsistent )
+ dbg_msg( "Sane is not consistent. (%s)\n", pMes );
+
+ return bConsistent;
+}
+
+BOOL Sane::Start( BitmapTransporter& rBitmap )
+{
+ int nStream = 0, nLine = 0, i = 0;
+ SANE_Parameters aParams;
+ FrameStyleType eType = FrameStyle_Gray;
+ BOOL bSuccess = TRUE;
+ BOOL bWidthSet = FALSE;
+
+ if( ! maHandle )
+ return FALSE;
+
+ int nWidthMM = 0;
+ int nHeightMM = 0;
+ double fTLx, fTLy, fBRx, fBRy, fResl = 0.0;
+ int nOption;
+ if( ( nOption = GetOptionByName( "tl-x" ) ) != -1 &&
+ GetOptionValue( nOption, fTLx, 0 ) &&
+ GetOptionUnit( nOption ) == SANE_UNIT_MM )
+ {
+ if( ( nOption = GetOptionByName( "br-x" ) ) != -1 &&
+ GetOptionValue( nOption, fBRx, 0 ) &&
+ GetOptionUnit( nOption ) == SANE_UNIT_MM )
+ {
+ nWidthMM = (int)fabs(fBRx - fTLx);
+ }
+ }
+ if( ( nOption = GetOptionByName( "tl-y" ) ) != -1 &&
+ GetOptionValue( nOption, fTLy, 0 ) &&
+ GetOptionUnit( nOption ) == SANE_UNIT_MM )
+ {
+ if( ( nOption = GetOptionByName( "br-y" ) ) != -1 &&
+ GetOptionValue( nOption, fBRy, 0 ) &&
+ GetOptionUnit( nOption ) == SANE_UNIT_MM )
+ {
+ nHeightMM = (int)fabs(fBRy - fTLy);
+ }
+ }
+ if( ( nOption = GetOptionByName( "resolution" ) ) != -1 )
+ GetOptionValue( nOption, fResl );
+
+ BYTE* pBuffer = NULL;
+
+ SANE_Status nStatus = SANE_STATUS_GOOD;
+
+ rBitmap.lock();
+ SvMemoryStream& aConverter = rBitmap.getStream();
+ aConverter.Seek( 0 );
+ aConverter.SetNumberFormatInt( NUMBERFORMAT_INT_LITTLEENDIAN );
+
+ // write bitmap stream header
+ aConverter << 'B' << 'M';
+ aConverter << (sal_uInt32) 0;
+ aConverter << (sal_uInt32) 0;
+ aConverter << (sal_uInt32) 60;
+
+ // write BITMAPINFOHEADER
+ aConverter << (UINT32)40;
+ aConverter << (UINT32)0; // fill in width later
+ aConverter << (UINT32)0; // fill in height later
+ aConverter << (UINT16)1;
+ // create header for 24 bits
+ // correct later if necessary
+ aConverter << (UINT16)24;
+ aConverter << (UINT32)0;
+ aConverter << (UINT32)0;
+ aConverter << (UINT32)0;
+ aConverter << (UINT32)0;
+ aConverter << (UINT32)0;
+ aConverter << (UINT32)0;
+
+ for( nStream=0; nStream < 3 && bSuccess ; nStream++ )
+ {
+ nStatus = p_start( maHandle );
+ DUMP_STATE( nStatus, "sane_start" );
+ CheckConsistency( "sane_start" );
+ if( nStatus == SANE_STATUS_GOOD )
+ {
+ nStatus = p_get_parameters( maHandle, &aParams );
+ DUMP_STATE( nStatus, "sane_get_parameters" );
+ CheckConsistency( "sane_get_parameters" );
+ if (nStatus != SANE_STATUS_GOOD || aParams.bytes_per_line == 0)
+ {
+ bSuccess = FALSE;
+ break;
+ }
+#if (OSL_DEBUG_LEVEL > 1) || defined DBG_UTIL
+ const char* ppFormats[] = { "SANE_FRAME_GRAY", "SANE_FRAME_RGB",
+ "SANE_FRAME_RED", "SANE_FRAME_GREEN",
+ "SANE_FRAME_BLUE", "Unknown !!!" };
+ fprintf( stderr, "Parameters for frame %d:\n", nStream );
+ if( aParams.format < 0 || aParams.format > 4 )
+ aParams.format = (SANE_Frame)5;
+ fprintf( stderr, "format: %s\n", ppFormats[ (int)aParams.format ] );
+ fprintf( stderr, "last_frame: %s\n", aParams.last_frame ? "TRUE" : "FALSE" );
+ fprintf( stderr, "depth: %d\n", (int)aParams.depth );
+ fprintf( stderr, "pixels_per_line: %d\n", (int)aParams.pixels_per_line );
+ fprintf( stderr, "bytes_per_line: %d\n", (int)aParams.bytes_per_line );
+#endif
+ if( ! pBuffer )
+ {
+ pBuffer = new BYTE[ BYTE_BUFFER_SIZE < 4*aParams.bytes_per_line ? 4*aParams.bytes_per_line : BYTE_BUFFER_SIZE ];
+ }
+
+ if( aParams.last_frame )
+ nStream=3;
+
+ switch( aParams.format )
+ {
+ case SANE_FRAME_GRAY:
+ eType = FrameStyle_Gray;
+ if( aParams.depth == 1 )
+ eType = FrameStyle_BW;
+ break;
+ case SANE_FRAME_RGB:
+ eType = FrameStyle_RGB;
+ break;
+ case SANE_FRAME_RED:
+ case SANE_FRAME_GREEN:
+ case SANE_FRAME_BLUE:
+ eType = FrameStyle_Separated;
+ break;
+ default:
+ fprintf( stderr, "Warning: unknown frame style !!!\n" );
+ }
+
+ BOOL bSynchronousRead = TRUE;
+
+ // should be fail safe, but ... ??
+ nStatus = p_set_io_mode( maHandle, SANE_FALSE );
+ CheckConsistency( "sane_set_io_mode" );
+ if( nStatus != SANE_STATUS_GOOD )
+ {
+ bSynchronousRead = FALSE;
+ nStatus = p_set_io_mode( maHandle, SANE_TRUE );
+ CheckConsistency( "sane_set_io_mode" );
+#if (OSL_DEBUG_LEVEL > 1) || defined DBG_UTIL
+ if( nStatus != SANE_STATUS_GOOD )
+ // what ?!?
+ fprintf( stderr, "Sane::Start: driver is confused\n" );
+#endif
+ }
+
+ SANE_Int nLen=0;
+ SANE_Int fd = 0;
+
+ if( ! bSynchronousRead )
+ {
+ nStatus = p_get_select_fd( maHandle, &fd );
+ DUMP_STATE( nStatus, "sane_get_select_fd" );
+ CheckConsistency( "sane_get_select_fd" );
+ if( nStatus != SANE_STATUS_GOOD )
+ bSynchronousRead = TRUE;
+ }
+ FILE* pFrame = tmpfile();
+ if( ! pFrame )
+ {
+ bSuccess = FALSE;
+ break;
+ }
+ do {
+ if( ! bSynchronousRead )
+ {
+ fd_set fdset;
+ struct timeval tv;
+
+ FD_ZERO( &fdset );
+ FD_SET( (int)fd, &fdset );
+ tv.tv_sec = 5;
+ tv.tv_usec = 0;
+ if( select( fd+1, &fdset, NULL, NULL, &tv ) == 0 )
+ fprintf( stderr, "Timout on sane_read descriptor\n" );
+ }
+ nLen = 0;
+ nStatus = p_read( maHandle, pBuffer, BYTE_BUFFER_SIZE, &nLen );
+ CheckConsistency( "sane_read" );
+ if( nLen && ( nStatus == SANE_STATUS_GOOD ||
+ nStatus == SANE_STATUS_EOF ) )
+ {
+ fwrite( pBuffer, 1, nLen, pFrame );
+ }
+ else
+ DUMP_STATE( nStatus, "sane_read" );
+ } while( nStatus == SANE_STATUS_GOOD );
+ if( nStatus != SANE_STATUS_EOF )
+ {
+ fclose( pFrame );
+ bSuccess = FALSE;
+ break;
+ }
+
+ int nFrameLength = ftell( pFrame );
+ fseek( pFrame, 0, SEEK_SET );
+ UINT32 nWidth = (UINT32) aParams.pixels_per_line;
+ UINT32 nHeight = (UINT32) (nFrameLength / aParams.bytes_per_line);
+ if( ! bWidthSet )
+ {
+ if( ! fResl )
+ fResl = 300; // if all else fails that's a good guess
+ if( ! nWidthMM )
+ nWidthMM = (int)(((double)nWidth / fResl) * 25.4);
+ if( ! nHeightMM )
+ nHeightMM = (int)(((double)nHeight / fResl) * 25.4);
+#if OSL_DEBUG_LEVEL > 1
+ fprintf( stderr, "set dimensions to (%d, %d) Pixel, (%d, %d) mm, resolution is %lg\n", (int)nWidth, (int)nHeight, (int)nWidthMM, (int)nHeightMM, fResl );
+#endif
+
+ aConverter.Seek( 18 );
+ aConverter << (UINT32)nWidth;
+ aConverter << (UINT32)nHeight;
+ aConverter.Seek( 38 );
+ aConverter << (UINT32)(1000*nWidth/nWidthMM);
+ aConverter << (UINT32)(1000*nHeight/nHeightMM);
+ bWidthSet = TRUE;
+ }
+ aConverter.Seek(60);
+
+ if( eType == FrameStyle_BW )
+ {
+ aConverter.Seek( 10 );
+ aConverter << (sal_uInt32)64;
+ aConverter.Seek( 28 );
+ aConverter << (UINT16) 1;
+ aConverter.Seek( 54 );
+ // write color table
+ aConverter << (UINT16)0xffff;
+ aConverter << (UINT8)0xff;
+ aConverter << (UINT8)0;
+ aConverter << (UINT32)0;
+ aConverter.Seek( 64 );
+ }
+ else if( eType == FrameStyle_Gray )
+ {
+ aConverter.Seek( 10 );
+ aConverter << (sal_uInt32)1084;
+ aConverter.Seek( 28 );
+ aConverter << (UINT16) 8;
+ aConverter.Seek( 54 );
+ // write color table
+ for( nLine = 0; nLine < 256; nLine++ )
+ {
+ aConverter << (UINT8)nLine;
+ aConverter << (UINT8)nLine;
+ aConverter << (UINT8)nLine;
+ aConverter << (UINT8)0;
+ }
+ aConverter.Seek( 1084 );
+ }
+
+ for( nLine = nHeight-1;
+ nLine >= 0; nLine-- )
+ {
+ fseek( pFrame, nLine * aParams.bytes_per_line, SEEK_SET );
+ if( eType == FrameStyle_BW ||
+ ( eType == FrameStyle_Gray && aParams.depth == 8 )
+ )
+ {
+ fread( pBuffer, 1, aParams.bytes_per_line, pFrame );
+ aConverter.Write( pBuffer, aParams.bytes_per_line );
+ }
+ else if( eType == FrameStyle_Gray )
+ {
+ for( i = 0; i < (aParams.pixels_per_line); i++ )
+ {
+ UINT8 nGray = _ReadValue( pFrame, aParams.depth );
+ aConverter << nGray;
+ }
+ }
+ else if( eType == FrameStyle_RGB )
+ {
+ for( i = 0; i < (aParams.pixels_per_line); i++ )
+ {
+ UINT8 nRed, nGreen, nBlue;
+ nRed = _ReadValue( pFrame, aParams.depth );
+ nGreen = _ReadValue( pFrame, aParams.depth );
+ nBlue = _ReadValue( pFrame, aParams.depth );
+ aConverter << nBlue;
+ aConverter << nGreen;
+ aConverter << nRed;
+ }
+ }
+ else if( eType == FrameStyle_Separated )
+ {
+ for( i = 0; i < (aParams.pixels_per_line); i++ )
+ {
+ UINT8 nValue = _ReadValue( pFrame, aParams.depth );
+ switch( aParams.format )
+ {
+ case SANE_FRAME_RED:
+ aConverter.SeekRel( 2 );
+ aConverter << nValue;
+ break;
+ case SANE_FRAME_GREEN:
+ aConverter.SeekRel( 1 );
+ aConverter << nValue;
+ aConverter.SeekRel( 1 );
+ break;
+ case SANE_FRAME_BLUE:
+ aConverter << nValue;
+ aConverter.SeekRel( 2 );
+ break;
+ case SANE_FRAME_GRAY:
+ case SANE_FRAME_RGB:
+ break;
+ }
+ }
+ }
+ int nGap = aConverter.Tell() & 3;
+ if( nGap )
+ aConverter.SeekRel( 4-nGap );
+ }
+ fclose( pFrame ); // deletes tmpfile
+ if( eType != FrameStyle_Separated )
+ break;
+ }
+ else
+ bSuccess = FALSE;
+ }
+ // get stream length
+ aConverter.Seek( STREAM_SEEK_TO_END );
+ int nPos = aConverter.Tell();
+
+ aConverter.Seek( 2 );
+ aConverter << (sal_uInt32) nPos+1;
+ aConverter.Seek( 0 );
+
+ rBitmap.unlock();
+
+ if( bSuccess )
+ {
+ // only cancel a successful operation
+ // sane disrupts memory else
+ p_cancel( maHandle );
+ CheckConsistency( "sane_cancel" );
+ }
+ if( pBuffer )
+ delete [] pBuffer;
+
+ ReloadOptions();
+
+
+ dbg_msg( "Sane::Start returns with %s\n", bSuccess ? "TRUE" : "FALSE" );
+
+ return bSuccess;
+}
+
+int Sane::GetRange( int n, double*& rpDouble )
+{
+ if( mppOptions[n]->constraint_type != SANE_CONSTRAINT_RANGE &&
+ mppOptions[n]->constraint_type != SANE_CONSTRAINT_WORD_LIST )
+ {
+ return -1;
+ }
+
+ rpDouble = 0;
+ int nItems, i;
+ BOOL bIsFixed = mppOptions[n]->type == SANE_TYPE_FIXED ? TRUE : FALSE;
+
+ dbg_msg( "Sane::GetRange of option %s ", mppOptions[n]->name );
+ if(mppOptions[n]->constraint_type == SANE_CONSTRAINT_RANGE )
+ {
+ double fMin, fMax, fQuant;
+ if( bIsFixed )
+ {
+ fMin = SANE_UNFIX( mppOptions[n]->constraint.range->min );
+ fMax = SANE_UNFIX( mppOptions[n]->constraint.range->max );
+ fQuant = SANE_UNFIX( mppOptions[n]->constraint.range->quant );
+ }
+ else
+ {
+ fMin = (double)mppOptions[n]->constraint.range->min;
+ fMax = (double)mppOptions[n]->constraint.range->max;
+ fQuant = (double)mppOptions[n]->constraint.range->quant;
+ }
+ if( fQuant != 0.0 )
+ {
+ dbg_msg( "quantum range [ %lg ; %lg ; %lg ]\n",
+ fMin, fQuant, fMax );
+ nItems = (int)((fMax - fMin)/fQuant)+1;
+ rpDouble = new double[ nItems ];
+ double fValue = fMin;
+ for( i = 0; i < nItems; i++, fValue += fQuant )
+ rpDouble[i] = fValue;
+ rpDouble[ nItems-1 ] = fMax;
+ return nItems;
+ }
+ else
+ {
+ dbg_msg( "normal range [ %lg %lg ]\n",
+ fMin, fMax );
+ rpDouble = new double[2];
+ rpDouble[0] = fMin;
+ rpDouble[1] = fMax;
+ return 0;
+ }
+ }
+ else
+ {
+ nItems = mppOptions[n]->constraint.word_list[0];
+ rpDouble = new double[nItems];
+ for( i=0; i<nItems; i++ )
+ {
+ rpDouble[i] = bIsFixed ?
+ SANE_UNFIX( mppOptions[n]->constraint.word_list[i+1] ) :
+ (double)mppOptions[n]->constraint.word_list[i+1];
+ }
+ dbg_msg( "wordlist [ %lg ... %lg ]\n",
+ rpDouble[ 0 ], rpDouble[ nItems-1 ] );
+ return nItems;
+ }
+}
+
+static const char *ppUnits[] = {
+ "",
+ "[Pixel]",
+ "[Bit]",
+ "[mm]",
+ "[DPI]",
+ "[%]",
+ "[usec]"
+};
+
+String Sane::GetOptionUnitName( int n )
+{
+ String aText;
+ SANE_Unit nUnit = mppOptions[n]->unit;
+ size_t nUnitAsSize = (size_t)nUnit;
+ if( nUnitAsSize > SAL_N_ELEMENTS( ppUnits ) )
+ aText = String::CreateFromAscii( "[unknown units]" );
+ else
+ aText = String( ppUnits[ nUnit ], gsl_getSystemTextEncoding() );
+ return aText;
+}
+
+BOOL Sane::ActivateButtonOption( int n )
+{
+ SANE_Status nStatus = ControlOption( n, SANE_ACTION_SET_VALUE, NULL );
+ if( nStatus != SANE_STATUS_GOOD )
+ return FALSE;
+ return TRUE;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/scanner/sane.hxx b/extensions/source/scanner/sane.hxx
new file mode 100644
index 000000000000..7cf91a5b9fc5
--- /dev/null
+++ b/extensions/source/scanner/sane.hxx
@@ -0,0 +1,203 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef _SANE_HXX
+#define _SANE_HXX
+
+#include <osl/thread.h>
+#include <osl/module.h>
+#include <tools/string.hxx>
+#include <vcl/bitmap.hxx>
+#include <sane/sane.h>
+#include <scanner.hxx>
+
+// ---------------------
+// - BitmapTransporter -
+// ---------------------
+
+class BitmapTransporter : public OWeakObject, AWT::XBitmap
+{
+ SvMemoryStream m_aStream;
+ osl::Mutex m_aProtector;
+
+public:
+
+ BitmapTransporter();
+ virtual ~BitmapTransporter();
+
+
+ // 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(); }
+
+ virtual AWT::Size SAL_CALL getSize() throw();
+ virtual SEQ( sal_Int8 ) SAL_CALL getDIB() throw();
+ virtual SEQ( sal_Int8 ) SAL_CALL getMaskDIB() throw() { return SEQ( sal_Int8 )(); }
+
+ // Misc
+ void lock() { m_aProtector.acquire(); }
+ void unlock() { m_aProtector.release(); }
+ SvMemoryStream& getStream() { return m_aStream; }
+};
+
+// --------
+// - Sane -
+// --------
+
+class Sane
+{
+private:
+ static int nRefCount;
+ static oslModule pSaneLib;
+
+ static SANE_Status (*p_init)( SANE_Int*,
+ SANE_Auth_Callback );
+ static void (*p_exit)();
+ static SANE_Status (*p_get_devices)( const SANE_Device***,
+ SANE_Bool );
+ static SANE_Status (*p_open)( SANE_String_Const, SANE_Handle );
+ static void (*p_close)( SANE_Handle );
+ static const SANE_Option_Descriptor* (*p_get_option_descriptor)(
+ SANE_Handle, SANE_Int );
+ static SANE_Status (*p_control_option)( SANE_Handle, SANE_Int,
+ SANE_Action, void*,
+ SANE_Int* );
+ static SANE_Status (*p_get_parameters)( SANE_Handle,
+ SANE_Parameters* );
+ static SANE_Status (*p_start)( SANE_Handle );
+ static SANE_Status (*p_read)( SANE_Handle, SANE_Byte*, SANE_Int,
+ SANE_Int* );
+ static void (*p_cancel)( SANE_Handle );
+ static SANE_Status (*p_set_io_mode)( SANE_Handle, SANE_Bool );
+ static SANE_Status (*p_get_select_fd)( SANE_Handle, SANE_Int* );
+ static SANE_String_Const (*p_strstatus)( SANE_Status );
+
+ static SANE_Int nVersion;
+ static SANE_Device** ppDevices;
+ static int nDevices;
+
+ const SANE_Option_Descriptor** mppOptions;
+ int mnOptions;
+ int mnDevice;
+ SANE_Handle maHandle;
+
+ Link maReloadOptionsLink;
+
+ inline oslGenericFunction
+ LoadSymbol( const char* );
+ void Init();
+ void DeInit();
+
+ SANE_Status ControlOption( int, SANE_Action, void* );
+
+ BOOL CheckConsistency( const char*, BOOL bInit = FALSE );
+
+public:
+ Sane();
+ ~Sane();
+
+ static BOOL IsSane()
+ { return pSaneLib ? TRUE : FALSE; }
+ BOOL IsOpen()
+ { return maHandle ? TRUE : FALSE; }
+ static int CountDevices()
+ { return nDevices; }
+ static String GetName( int n )
+ { return String( ppDevices[n]->name ? ppDevices[n]->name : "", osl_getThreadTextEncoding() ); }
+ static String GetVendor( int n )
+ { return String( ppDevices[n]->vendor ? ppDevices[n]->vendor : "", osl_getThreadTextEncoding() ); }
+ static String GetModel( int n )
+ { return String( ppDevices[n]->model ? ppDevices[n]->model : "", osl_getThreadTextEncoding() ); }
+ static String GetType( int n )
+ { return String( ppDevices[n]->type ? ppDevices[n]->type : "", osl_getThreadTextEncoding() ); }
+
+ String GetOptionName( int n )
+ { return String( mppOptions[n]->name ? (char*)mppOptions[n]->name : "", osl_getThreadTextEncoding() ); }
+ String GetOptionTitle( int n )
+ { return String( mppOptions[n]->title ? (char*)mppOptions[n]->title : "", osl_getThreadTextEncoding() ); }
+ SANE_Value_Type GetOptionType( int n )
+ { return mppOptions[n]->type; }
+ SANE_Unit GetOptionUnit( int n )
+ { return mppOptions[n]->unit; }
+ String GetOptionUnitName( int n );
+ SANE_Int GetOptionCap( int n )
+ { return mppOptions[n]->cap; }
+ SANE_Constraint_Type GetOptionConstraintType( int n )
+ { return mppOptions[n]->constraint_type; }
+ const char** GetStringConstraint( int n )
+ { return (const char**)mppOptions[n]->constraint.string_list; }
+ int GetRange( int, double*& );
+
+ inline int GetOptionElements( int n );
+ int GetOptionByName( const char* );
+ BOOL GetOptionValue( int, BOOL& );
+ BOOL GetOptionValue( int, ByteString& );
+ BOOL GetOptionValue( int, double&, int nElement = 0 );
+ BOOL GetOptionValue( int, double* );
+
+ BOOL SetOptionValue( int, BOOL );
+ BOOL SetOptionValue( int, const String& );
+ BOOL SetOptionValue( int, double, int nElement = 0 );
+ BOOL SetOptionValue( int, double* );
+
+ BOOL ActivateButtonOption( int );
+
+ int CountOptions() { return mnOptions; }
+ int GetDeviceNumber() { return mnDevice; }
+
+ BOOL Open( const char* );
+ BOOL Open( int );
+ void Close();
+ void ReloadDevices();
+ void ReloadOptions();
+
+ BOOL Start( BitmapTransporter& );
+
+ inline Link SetReloadOptionsHdl( const Link& rLink );
+};
+
+inline int Sane::GetOptionElements( int n )
+{
+ if( mppOptions[n]->type == SANE_TYPE_FIXED ||
+ mppOptions[n]->type == SANE_TYPE_INT )
+ {
+ return mppOptions[n]->size/sizeof( SANE_Word );
+ }
+ return 1;
+}
+
+inline Link Sane::SetReloadOptionsHdl( const Link& rLink )
+{
+ Link aRet = maReloadOptionsLink;
+ maReloadOptionsLink = rLink;
+ return aRet;
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/scanner/sanedlg.cxx b/extensions/source/scanner/sanedlg.cxx
new file mode 100644
index 000000000000..98c654695ee4
--- /dev/null
+++ b/extensions/source/scanner/sanedlg.cxx
@@ -0,0 +1,1433 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <tools/config.hxx>
+
+#include <vcl/msgbox.hxx>
+#include <sanedlg.hxx>
+#include <sanedlg.hrc>
+#include <grid.hxx>
+#include <math.h>
+#include <sal/macros.h>
+
+#define USE_SAVE_STATE
+#undef SAVE_ALL_STATES
+
+ResId SaneResId( sal_uInt32 nID )
+{
+ static ResMgr* pResMgr = ResMgr::CreateResMgr( "san" );
+ return ResId( nID, *pResMgr );
+}
+
+SaneDlg::SaneDlg( Window* pParent, Sane& rSane ) :
+ ModalDialog( pParent, SaneResId( RID_SANE_DIALOG ) ),
+ mrSane( rSane ),
+ mbIsDragging( FALSE ),
+ mbDragDrawn( FALSE ),
+ maMapMode( MAP_APPFONT ),
+ maOKButton( this, SaneResId( RID_SCAN_OK ) ),
+ maCancelButton( this, SaneResId( RID_SCAN_CANCEL ) ),
+ maDeviceInfoButton( this, SaneResId( RID_DEVICEINFO_BTN ) ),
+ maPreviewButton( this, SaneResId( RID_PREVIEW_BTN ) ),
+ maButtonOption( this, SaneResId( RID_SCAN_BUTTON_OPTION_BTN ) ),
+ maOptionsTxt( this, SaneResId( RID_SCAN_OPTION_TXT ) ),
+ maOptionTitle( this, SaneResId( RID_SCAN_OPTIONTITLE_TXT ) ),
+ maOptionDescTxt( this, SaneResId( RID_SCAN_OPTION_DESC_TXT ) ),
+ maVectorTxt( this, SaneResId( RID_SCAN_NUMERIC_VECTOR_TXT ) ),
+ maScanLeftTxt( this, SaneResId( RID_SCAN_LEFT_TXT ) ),
+ maLeftField( this, SaneResId( RID_SCAN_LEFT_BOX ) ),
+ maScanTopTxt( this, SaneResId( RID_SCAN_TOP_TXT ) ),
+ maTopField( this, SaneResId( RID_SCAN_TOP_BOX ) ),
+ maRightTxt( this, SaneResId( RID_SCAN_RIGHT_TXT ) ),
+ maRightField( this, SaneResId( RID_SCAN_RIGHT_BOX ) ),
+ maBottomTxt( this, SaneResId( RID_SCAN_BOTTOM_TXT ) ),
+ maBottomField( this, SaneResId( RID_SCAN_BOTTOM_BOX ) ),
+ maDeviceBoxTxt( this, SaneResId( RID_DEVICE_BOX_TXT ) ),
+ maDeviceBox( this, SaneResId( RID_DEVICE_BOX ) ),
+ maReslTxt( this, SaneResId( RID_SCAN_RESOLUTION_TXT ) ),
+ maReslBox( this, SaneResId( RID_SCAN_RESOLUTION_BOX ) ),
+ maAdvancedTxt( this, SaneResId( RID_SCAN_ADVANCED_TXT ) ),
+ maAdvancedBox( this, SaneResId( RID_SCAN_ADVANCED_BOX ) ),
+ maVectorBox( this, SaneResId( RID_SCAN_NUMERIC_VECTOR_BOX ) ),
+ maQuantumRangeBox( this, SaneResId( RID_SCAN_QUANTUM_RANGE_BOX ) ),
+ maStringRangeBox( this, SaneResId( RID_SCAN_STRING_RANGE_BOX ) ),
+ maPreviewBox( this, SaneResId( RID_PREVIEW_BOX ) ),
+ maAreaBox( this, SaneResId( RID_SCANAREA_BOX ) ),
+ maBoolCheckBox( this, SaneResId( RID_SCAN_BOOL_OPTION_BOX ) ),
+ maStringEdit( this, SaneResId( RID_SCAN_STRING_OPTION_EDT ) ),
+ maNumericEdit( this, SaneResId( RID_SCAN_NUMERIC_OPTION_EDT ) ),
+ maOptionBox( this, SaneResId( RID_SCAN_OPTION_BOX ) ),
+ mpRange( 0 )
+{
+ if( Sane::IsSane() )
+ {
+ InitDevices(); // opens first sane device
+ DisableOption();
+ InitFields();
+ }
+
+ maDeviceInfoButton.SetClickHdl( LINK( this, SaneDlg, ClickBtnHdl ) );
+ maPreviewButton.SetClickHdl( LINK( this, SaneDlg, ClickBtnHdl ) );
+ maButtonOption.SetClickHdl( LINK( this, SaneDlg, ClickBtnHdl ) );
+ maDeviceBox.SetSelectHdl( LINK( this, SaneDlg, SelectHdl ) );
+ maOptionBox.SetSelectHdl( LINK( this, SaneDlg, OptionsBoxSelectHdl ) );
+ maOKButton.SetClickHdl( LINK( this, SaneDlg, ClickBtnHdl ) );
+ maCancelButton.SetClickHdl( LINK( this, SaneDlg, ClickBtnHdl ) );
+ maBoolCheckBox.SetClickHdl( LINK( this, SaneDlg, ClickBtnHdl ) );
+ maStringEdit.SetModifyHdl( LINK( this, SaneDlg, ModifyHdl ) );
+ maNumericEdit.SetModifyHdl( LINK( this, SaneDlg, ModifyHdl ) );
+ maVectorBox.SetModifyHdl( LINK( this, SaneDlg, ModifyHdl ) );
+ maReslBox.SetModifyHdl( LINK( this, SaneDlg, ModifyHdl ) );
+ maStringRangeBox.SetSelectHdl( LINK( this, SaneDlg, SelectHdl ) );
+ maQuantumRangeBox.SetSelectHdl( LINK( this, SaneDlg, SelectHdl ) );
+ maLeftField.SetModifyHdl( LINK( this, SaneDlg, ModifyHdl ) );
+ maRightField.SetModifyHdl( LINK( this, SaneDlg, ModifyHdl ) );
+ maTopField.SetModifyHdl( LINK( this, SaneDlg, ModifyHdl ) );
+ maBottomField.SetModifyHdl( LINK( this, SaneDlg, ModifyHdl ) );
+ maAdvancedBox.SetClickHdl( LINK( this, SaneDlg, ClickBtnHdl ) );
+
+ maOldLink = mrSane.SetReloadOptionsHdl( LINK( this, SaneDlg, ReloadSaneOptionsHdl ) );
+
+ maOptionBox.SetNodeBitmaps(
+ Bitmap( SaneResId( RID_SCAN_BITMAP_PLUS ) ),
+ Bitmap( SaneResId( RID_SCAN_BITMAP_MINUS ) )
+ );
+ maOptionBox.SetWindowBits( WB_HASLINES |
+ WB_HASBUTTONS |
+ WB_NOINITIALSELECTION |
+ WB_HASBUTTONSATROOT |
+ WB_HASLINESATROOT
+ );
+ FreeResource();
+}
+
+SaneDlg::~SaneDlg()
+{
+ mrSane.SetReloadOptionsHdl( maOldLink );
+}
+
+short SaneDlg::Execute()
+{
+ if( ! Sane::IsSane() )
+ {
+ ErrorBox aErrorBox( NULL, WB_OK | WB_DEF_OK,
+ String( SaneResId( RID_SANE_NOSANELIB_TXT ) ) );
+ aErrorBox.Execute();
+ return FALSE;
+ }
+ LoadState();
+ return ModalDialog::Execute();
+}
+
+void SaneDlg::InitDevices()
+{
+ if( ! Sane::IsSane() )
+ return;
+
+ if( mrSane.IsOpen() )
+ mrSane.Close();
+ mrSane.ReloadDevices();
+ maDeviceBox.Clear();
+ for( int i = 0; i < Sane::CountDevices(); i++ )
+ maDeviceBox.InsertEntry( Sane::GetName( i ) );
+ if( Sane::CountDevices() )
+ {
+ mrSane.Open( 0 );
+ maDeviceBox.SelectEntry( Sane::GetName( 0 ) );
+
+ }
+}
+
+void SaneDlg::InitFields()
+{
+ if( ! Sane::IsSane() )
+ return;
+
+ int nOption, i, nValue;
+ double fValue;
+ BOOL bSuccess = FALSE;
+ const char *ppSpecialOptions[] = {
+ "resolution",
+ "tl-x",
+ "tl-y",
+ "br-x",
+ "br-y",
+ "preview"
+ };
+
+ mbDragEnable = TRUE;
+ maReslBox.Clear();
+ maMinTopLeft = Point( 0, 0 );
+ maMaxBottomRight = Point( PREVIEW_WIDTH, PREVIEW_HEIGHT );
+
+ if( ! mrSane.IsOpen() )
+ return;
+
+ // set Resolution
+ nOption = mrSane.GetOptionByName( "resolution" );
+ if( nOption != -1 )
+ {
+ double fRes;
+
+ bSuccess = mrSane.GetOptionValue( nOption, fRes );
+ if( bSuccess )
+ {
+ maReslBox.Enable( TRUE );
+
+ maReslBox.SetValue( (long)fRes );
+ double *pDouble = NULL;
+ nValue = mrSane.GetRange( nOption, pDouble );
+ if( nValue > -1 )
+ {
+ if( nValue )
+ {
+ maReslBox.SetMin( (long)pDouble[0] );
+ maReslBox.SetMax( (long)pDouble[ nValue-1 ] );
+ for( i=0; i<nValue; i++ )
+ {
+ if( i == 0 || i == nValue-1 || ! ( ((int)pDouble[i]) % 20) )
+ maReslBox.InsertValue( (long)pDouble[i] );
+ }
+ }
+ else
+ {
+ maReslBox.SetMin( (long)pDouble[0] );
+ maReslBox.SetMax( (long)pDouble[1] );
+ maReslBox.InsertValue( (long)pDouble[0] );
+ // mh@openoffice.org: issue 68557: Can only select 75 and 2400 dpi in Scanner dialogue
+ // scanner allows random setting of dpi resolution, a slider might be useful
+ // support that
+ // workaround: offer at least some more standard dpi resolution between
+ // min and max value
+ int bGot300 = 0;
+ for ( int nRes = (long) pDouble[0] * 2; nRes < (long) pDouble[1]; nRes = nRes * 2 )
+ {
+ if ( !bGot300 && nRes > 300 ) {
+ nRes = 300; bGot300 = 1;
+ }
+ maReslBox.InsertValue(nRes);
+ }
+ maReslBox.InsertValue( (long)pDouble[1] );
+ }
+ if( pDouble )
+ delete [] pDouble;
+ }
+ else
+ maReslBox.Enable( FALSE );
+ }
+ }
+ else
+ maReslBox.Enable( FALSE );
+
+ // set scan area
+ for( i = 0; i < 4; i++ )
+ {
+ char const *pOptionName = NULL;
+ MetricField* pField = NULL;
+ switch( i )
+ {
+ case 0:
+ pOptionName = "tl-x";
+ pField = &maLeftField;
+ break;
+ case 1:
+ pOptionName = "tl-y";
+ pField = &maTopField;
+ break;
+ case 2:
+ pOptionName = "br-x";
+ pField = &maRightField;
+ break;
+ case 3:
+ pOptionName = "br-y";
+ pField = &maBottomField;
+ }
+ nOption = pOptionName ? mrSane.GetOptionByName( pOptionName ) : -1;
+ bSuccess = FALSE;
+ if( nOption != -1 )
+ {
+ bSuccess = mrSane.GetOptionValue( nOption, fValue, 0 );
+ if( bSuccess )
+ {
+ if( mrSane.GetOptionUnit( nOption ) == SANE_UNIT_MM )
+ {
+ pField->SetUnit( FUNIT_MM );
+ pField->SetValue( (int)fValue, FUNIT_MM );
+ }
+ else // SANE_UNIT_PIXEL
+ {
+ pField->SetValue( (int)fValue, FUNIT_CUSTOM );
+ pField->SetCustomUnitText( String::CreateFromAscii( "Pixel" ) );
+ }
+ switch( i ) {
+ case 0: maTopLeft.X() = (int)fValue;break;
+ case 1: maTopLeft.Y() = (int)fValue;break;
+ case 2: maBottomRight.X() = (int)fValue;break;
+ case 3: maBottomRight.Y() = (int)fValue;break;
+ }
+ }
+ double *pDouble = NULL;
+ nValue = mrSane.GetRange( nOption, pDouble );
+ if( nValue > -1 )
+ {
+ if( pDouble )
+ {
+ pField->SetMin( (long)pDouble[0] );
+ if( nValue )
+ pField->SetMax( (long)pDouble[ nValue-1 ] );
+ else
+ pField->SetMax( (long)pDouble[ 1 ] );
+ delete [] pDouble;
+ }
+ switch( i ) {
+ case 0: maMinTopLeft.X() = pField->GetMin();break;
+ case 1: maMinTopLeft.Y() = pField->GetMin();break;
+ case 2: maMaxBottomRight.X() = pField->GetMax();break;
+ case 3: maMaxBottomRight.Y() = pField->GetMax();break;
+ }
+ }
+ else
+ {
+ switch( i ) {
+ case 0: maMinTopLeft.X() = (int)fValue;break;
+ case 1: maMinTopLeft.Y() = (int)fValue;break;
+ case 2: maMaxBottomRight.X() = (int)fValue;break;
+ case 3: maMaxBottomRight.Y() = (int)fValue;break;
+ }
+ }
+ pField->Enable( TRUE );
+ }
+ else
+ {
+ mbDragEnable = FALSE;
+ pField->SetMin( 0 );
+ switch( i ) {
+ case 0:
+ maMinTopLeft.X() = 0;
+ maTopLeft.X() = 0;
+ pField->SetMax( PREVIEW_WIDTH );
+ pField->SetValue( 0 );
+ break;
+ case 1:
+ maMinTopLeft.Y() = 0;
+ maTopLeft.Y() = 0;
+ pField->SetMax( PREVIEW_HEIGHT );
+ pField->SetValue( 0 );
+ break;
+ case 2:
+ maMaxBottomRight.X() = PREVIEW_WIDTH;
+ maBottomRight.X() = PREVIEW_WIDTH;
+ pField->SetMax( PREVIEW_WIDTH );
+ pField->SetValue( PREVIEW_WIDTH );
+ break;
+ case 3:
+ maMaxBottomRight.Y() = PREVIEW_HEIGHT;
+ maBottomRight.Y() = PREVIEW_HEIGHT;
+ pField->SetMax( PREVIEW_HEIGHT );
+ pField->SetValue( PREVIEW_HEIGHT );
+ break;
+ }
+ pField->Enable( FALSE );
+ }
+ }
+ maTopLeft = GetPixelPos( maTopLeft );
+ maBottomRight = GetPixelPos( maBottomRight );
+ maPreviewRect = Rectangle( maTopLeft,
+ Size( maBottomRight.X() - maTopLeft.X(),
+ maBottomRight.Y() - maTopLeft.Y() )
+ );
+ // fill OptionBox
+ maOptionBox.Clear();
+ SvLBoxEntry* pParentEntry = 0;
+ BOOL bGroupRejected = FALSE;
+ for( i = 1; i < mrSane.CountOptions(); i++ )
+ {
+ String aOption=mrSane.GetOptionName( i );
+ BOOL bInsertAdvanced =
+ mrSane.GetOptionCap( i ) & SANE_CAP_ADVANCED &&
+ ! maAdvancedBox.IsChecked() ? FALSE : TRUE;
+ if( mrSane.GetOptionType( i ) == SANE_TYPE_GROUP )
+ {
+ if( bInsertAdvanced )
+ {
+ aOption = mrSane.GetOptionTitle( i );
+ pParentEntry = maOptionBox.InsertEntry( aOption );
+ bGroupRejected = FALSE;
+ }
+ else
+ bGroupRejected = TRUE;
+ }
+ else if( aOption.Len() &&
+ ! ( mrSane.GetOptionCap( i ) &
+ (
+ SANE_CAP_HARD_SELECT |
+ SANE_CAP_INACTIVE
+ ) ) &&
+ bInsertAdvanced && ! bGroupRejected )
+ {
+ BOOL bIsSpecial = FALSE;
+ for( size_t n = 0; !bIsSpecial &&
+ n < SAL_N_ELEMENTS(ppSpecialOptions); n++ )
+ {
+ if( aOption.EqualsAscii( ppSpecialOptions[n] ) )
+ bIsSpecial=TRUE;
+ }
+ if( ! bIsSpecial )
+ {
+ if( pParentEntry )
+ maOptionBox.InsertEntry( aOption, pParentEntry );
+ else
+ maOptionBox.InsertEntry( aOption );
+ }
+ }
+ }
+}
+
+IMPL_LINK( SaneDlg, ClickBtnHdl, Button*, pButton )
+{
+ if( mrSane.IsOpen() )
+ {
+ if( pButton == &maDeviceInfoButton )
+ {
+ String aString( SaneResId( RID_SANE_DEVICEINFO_TXT ) );
+ String aSR( RTL_CONSTASCII_USTRINGPARAM( "%s" ) );
+ aString.SearchAndReplace( aSR, Sane::GetName( mrSane.GetDeviceNumber() ) );
+ aString.SearchAndReplace( aSR, Sane::GetVendor( mrSane.GetDeviceNumber() ) );
+ aString.SearchAndReplace( aSR, Sane::GetModel( mrSane.GetDeviceNumber() ) );
+ aString.SearchAndReplace( aSR, Sane::GetType( mrSane.GetDeviceNumber() ) );
+ InfoBox aInfoBox( this, aString );
+ aInfoBox.Execute();
+ }
+ else if( pButton == &maPreviewButton )
+ AcquirePreview();
+ else if( pButton == &maBoolCheckBox )
+ {
+ mrSane.SetOptionValue( mnCurrentOption,
+ maBoolCheckBox.IsChecked() ?
+ (BOOL)TRUE : (BOOL)FALSE );
+ }
+ else if( pButton == &maButtonOption )
+ {
+
+ SANE_Value_Type nType = mrSane.GetOptionType( mnCurrentOption );
+ switch( nType )
+ {
+ case SANE_TYPE_BUTTON:
+ mrSane.ActivateButtonOption( mnCurrentOption );
+ break;
+ case SANE_TYPE_FIXED:
+ case SANE_TYPE_INT:
+ {
+ int nElements = mrSane.GetOptionElements( mnCurrentOption );
+ double* x = new double[ nElements ];
+ double* y = new double[ nElements ];
+ for( int i = 0; i < nElements; i++ )
+ x[ i ] = (double)i;
+ mrSane.GetOptionValue( mnCurrentOption, y );
+
+ GridWindow aGrid( x, y, nElements, this );
+ aGrid.SetText( mrSane.GetOptionName( mnCurrentOption ) );
+ aGrid.setBoundings( 0, mfMin, nElements, mfMax );
+ if( aGrid.Execute() && aGrid.getNewYValues() )
+ mrSane.SetOptionValue( mnCurrentOption, aGrid.getNewYValues() );
+
+ delete [] x;
+ delete [] y;
+ }
+ break;
+ case SANE_TYPE_BOOL:
+ case SANE_TYPE_STRING:
+ case SANE_TYPE_GROUP:
+ break;
+ }
+ }
+ else if( pButton == &maAdvancedBox )
+ {
+ ReloadSaneOptionsHdl( NULL );
+ }
+ }
+ if( pButton == &maOKButton )
+ {
+ double fRes = (double)maReslBox.GetValue();
+ SetAdjustedNumericalValue( "resolution", fRes );
+ UpdateScanArea( TRUE );
+ SaveState();
+ EndDialog( mrSane.IsOpen() ? 1 : 0 );
+ }
+ else if( pButton == &maCancelButton )
+ {
+ mrSane.Close();
+ EndDialog( 0 );
+ }
+ return 0;
+}
+
+IMPL_LINK( SaneDlg, SelectHdl, ListBox*, pListBox )
+{
+ if( pListBox == &maDeviceBox && Sane::IsSane() && Sane::CountDevices() )
+ {
+ String aNewDevice = maDeviceBox.GetSelectEntry();
+ int nNumber;
+ if( aNewDevice.Equals( Sane::GetName( nNumber = mrSane.GetDeviceNumber() ) ) )
+ {
+ mrSane.Close();
+ mrSane.Open( nNumber );
+ InitFields();
+ }
+ }
+ if( mrSane.IsOpen() )
+ {
+ if( pListBox == &maQuantumRangeBox )
+ {
+ ByteString aValue( maQuantumRangeBox.GetSelectEntry(), osl_getThreadTextEncoding() );
+ double fValue = atof( aValue.GetBuffer() );
+ mrSane.SetOptionValue( mnCurrentOption, fValue, mnCurrentElement );
+ }
+ else if( pListBox == &maStringRangeBox )
+ {
+ mrSane.SetOptionValue( mnCurrentOption, maStringRangeBox.GetSelectEntry() );
+ }
+ }
+ return 0;
+}
+
+IMPL_LINK( SaneDlg, OptionsBoxSelectHdl, SvTreeListBox*, pBox )
+{
+ if( pBox == &maOptionBox && Sane::IsSane() )
+ {
+ String aOption =
+ maOptionBox.GetEntryText( maOptionBox.FirstSelected() );
+ int nOption = mrSane.GetOptionByName( ByteString( aOption, osl_getThreadTextEncoding() ).GetBuffer() );
+ if( nOption != -1 && nOption != mnCurrentOption )
+ {
+ DisableOption();
+ mnCurrentOption = nOption;
+ maOptionTitle.SetText( mrSane.GetOptionTitle( mnCurrentOption ) );
+ SANE_Value_Type nType = mrSane.GetOptionType( mnCurrentOption );
+ SANE_Constraint_Type nConstraint;
+ switch( nType )
+ {
+ case SANE_TYPE_BOOL: EstablishBoolOption();break;
+ case SANE_TYPE_STRING:
+ nConstraint = mrSane.GetOptionConstraintType( mnCurrentOption );
+ if( nConstraint == SANE_CONSTRAINT_STRING_LIST )
+ EstablishStringRange();
+ else
+ EstablishStringOption();
+ break;
+ case SANE_TYPE_FIXED:
+ case SANE_TYPE_INT:
+ {
+ nConstraint = mrSane.GetOptionConstraintType( mnCurrentOption );
+ int nElements = mrSane.GetOptionElements( mnCurrentOption );
+ mnCurrentElement = 0;
+ if( nConstraint == SANE_CONSTRAINT_RANGE ||
+ nConstraint == SANE_CONSTRAINT_WORD_LIST )
+ EstablishQuantumRange();
+ else
+ {
+ mfMin = mfMax = 0.0;
+ EstablishNumericOption();
+ }
+ if( nElements > 1 )
+ {
+ if( nElements <= 10 )
+ {
+ maVectorBox.SetValue( 1 );
+ maVectorBox.SetMin( 1 );
+ maVectorBox.SetMax(
+ mrSane.GetOptionElements( mnCurrentOption ) );
+ maVectorBox.Show( TRUE );
+ maVectorTxt.Show( TRUE );
+ }
+ else
+ {
+ DisableOption();
+ // bring up dialog only on button click
+ EstablishButtonOption();
+ }
+ }
+ }
+ break;
+ case SANE_TYPE_BUTTON:
+ EstablishButtonOption();
+ break;
+ default: break;
+ }
+ }
+ }
+ return 0;
+}
+
+IMPL_LINK( SaneDlg, ModifyHdl, Edit*, pEdit )
+{
+ if( mrSane.IsOpen() )
+ {
+ if( pEdit == &maStringEdit )
+ {
+ mrSane.SetOptionValue( mnCurrentOption, maStringEdit.GetText() );
+ }
+ else if( pEdit == &maReslBox )
+ {
+ double fRes = (double)maReslBox.GetValue();
+ int nOption = mrSane.GetOptionByName( "resolution" );
+ if( nOption != -1 )
+ {
+ double* pDouble = NULL;
+ int nValues = mrSane.GetRange( nOption, pDouble );
+ if( nValues > 0 )
+ {
+ int i;
+ for( i = 0; i < nValues; i++ )
+ {
+ if( fRes == pDouble[i] )
+ break;
+ }
+ if( i >= nValues )
+ fRes = pDouble[0];
+ }
+ else if( nValues == 0 )
+ {
+ if( fRes < pDouble[ 0 ] )
+ fRes = pDouble[ 0 ];
+ if( fRes > pDouble[ 1 ] )
+ fRes = pDouble[ 1 ];
+ }
+ maReslBox.SetValue( (ULONG)fRes );
+ }
+ }
+ else if( pEdit == &maNumericEdit )
+ {
+ double fValue;
+ char pBuf[256];
+ ByteString aContents( maNumericEdit.GetText(), osl_getThreadTextEncoding() );
+ fValue = atof( aContents.GetBuffer() );
+ if( mfMin != mfMax && ( fValue < mfMin || fValue > mfMax ) )
+ {
+ if( fValue < mfMin )
+ fValue = mfMin;
+ else if( fValue > mfMax )
+ fValue = mfMax;
+ sprintf( pBuf, "%g", fValue );
+ maNumericEdit.SetText( String( pBuf, osl_getThreadTextEncoding() ) );
+ }
+ mrSane.SetOptionValue( mnCurrentOption, fValue, mnCurrentElement );
+ }
+ else if( pEdit == &maVectorBox )
+ {
+ char pBuf[256];
+ mnCurrentElement = maVectorBox.GetValue()-1;
+ double fValue;
+ mrSane.GetOptionValue( mnCurrentOption, fValue, mnCurrentElement );
+ sprintf( pBuf, "%g", fValue );
+ String aValue( pBuf, osl_getThreadTextEncoding() );
+ maNumericEdit.SetText( aValue );
+ maQuantumRangeBox.SelectEntry( aValue );
+ }
+ else if( pEdit == &maTopField )
+ {
+ Point aPoint( 0, maTopField.GetValue() );
+ aPoint = GetPixelPos( aPoint );
+ maTopLeft.Y() = aPoint.Y();
+ DrawDrag();
+ }
+ else if( pEdit == &maLeftField )
+ {
+ Point aPoint( maLeftField.GetValue(), 0 );
+ aPoint = GetPixelPos( aPoint );
+ maTopLeft.X() = aPoint.X();
+ DrawDrag();
+ }
+ else if( pEdit == &maBottomField )
+ {
+ Point aPoint( 0, maBottomField.GetValue() );
+ aPoint = GetPixelPos( aPoint );
+ maBottomRight.Y() = aPoint.Y();
+ DrawDrag();
+ }
+ else if( pEdit == &maRightField )
+ {
+ Point aPoint( maRightField.GetValue(), 0 );
+ aPoint = GetPixelPos( aPoint );
+ maBottomRight.X() = aPoint.X();
+ DrawDrag();
+ }
+ }
+ return 0;
+}
+
+IMPL_LINK( SaneDlg, ReloadSaneOptionsHdl, Sane*, /*pSane*/ )
+{
+ mnCurrentOption = -1;
+ mnCurrentElement = 0;
+ DisableOption();
+ // #92024# preserve preview rect, should only be set
+ // initially or in AcquirePreview
+ Rectangle aPreviewRect = maPreviewRect;
+ InitFields();
+ maPreviewRect = aPreviewRect;
+ Rectangle aDummyRect( Point( 0, 0 ), GetSizePixel() );
+ Paint( aDummyRect );
+ return 0;
+}
+
+void SaneDlg::AcquirePreview()
+{
+ if( ! mrSane.IsOpen() )
+ return;
+
+ UpdateScanArea( TRUE );
+ // set small resolution for preview
+ double fResl = (double)maReslBox.GetValue();
+ SetAdjustedNumericalValue( "resolution", 30.0 );
+
+ int nOption = mrSane.GetOptionByName( "preview" );
+ if( nOption == -1 )
+ {
+ String aString( SaneResId( RID_SANE_NORESOLUTIONOPTION_TXT ) );
+ WarningBox aBox( this, WB_OK_CANCEL | WB_DEF_OK, aString );
+ if( aBox.Execute() == RET_CANCEL )
+ return;
+ }
+ else
+ mrSane.SetOptionValue( nOption, (BOOL)TRUE );
+
+ BitmapTransporter aTransporter;
+ if( ! mrSane.Start( aTransporter ) )
+ {
+ ErrorBox aErrorBox( this, WB_OK | WB_DEF_OK,
+ String( SaneResId( RID_SANE_SCANERROR_TXT ) ) );
+ aErrorBox.Execute();
+ }
+ else
+ {
+#if OSL_DEBUG_LEVEL > 1
+ aTransporter.getStream().Seek( STREAM_SEEK_TO_END );
+ fprintf( stderr, "Previewbitmapstream contains %d bytes\n", (int)aTransporter.getStream().Tell() );
+#endif
+ aTransporter.getStream().Seek( STREAM_SEEK_TO_BEGIN );
+ maPreviewBitmap.Read( aTransporter.getStream(), TRUE );
+ }
+
+ SetAdjustedNumericalValue( "resolution", fResl );
+ maReslBox.SetValue( (ULONG)fResl );
+
+ if( mbDragEnable )
+ {
+ maPreviewRect = Rectangle( maTopLeft,
+ Size( maBottomRight.X() - maTopLeft.X(),
+ maBottomRight.Y() - maTopLeft.Y() )
+ );
+ }
+ else
+ {
+ Size aBMSize( maPreviewBitmap.GetSizePixel() );
+ if( aBMSize.Width() > aBMSize.Height() && aBMSize.Width() )
+ {
+ int nVHeight = (maBottomRight.X() - maTopLeft.X()) * aBMSize.Height() / aBMSize.Width();
+ maPreviewRect = Rectangle( Point( maTopLeft.X(), ( maTopLeft.Y() + maBottomRight.Y() )/2 - nVHeight/2 ),
+ Size( maBottomRight.X() - maTopLeft.X(),
+ nVHeight ) );
+ }
+ else if (aBMSize.Height())
+ {
+ int nVWidth = (maBottomRight.Y() - maTopLeft.Y()) * aBMSize.Width() / aBMSize.Height();
+ maPreviewRect = Rectangle( Point( ( maTopLeft.X() + maBottomRight.X() )/2 - nVWidth/2, maTopLeft.Y() ),
+ Size( nVWidth,
+ maBottomRight.Y() - maTopLeft.Y() ) );
+ }
+ }
+
+ Paint( Rectangle( Point( 0, 0 ), GetSizePixel() ) );
+}
+
+void SaneDlg::Paint( const Rectangle& rRect )
+{
+ SetMapMode( maMapMode );
+ SetFillColor( Color( COL_WHITE ) );
+ SetLineColor( Color( COL_WHITE ) );
+ DrawRect( Rectangle( Point( PREVIEW_UPPER_LEFT, PREVIEW_UPPER_TOP ),
+ Size( PREVIEW_WIDTH, PREVIEW_HEIGHT ) ) );
+ SetMapMode( MapMode( MAP_PIXEL ) );
+ // check for sane values
+ DrawBitmap( maPreviewRect.TopLeft(), maPreviewRect.GetSize(),
+ maPreviewBitmap );
+
+ mbDragDrawn = FALSE;
+ DrawDrag();
+
+ ModalDialog::Paint( rRect );
+}
+
+void SaneDlg::DisableOption()
+{
+ maBoolCheckBox.Show( FALSE );
+ maStringEdit.Show( FALSE );
+ maNumericEdit.Show( FALSE );
+ maQuantumRangeBox.Show( FALSE );
+ maStringRangeBox.Show( FALSE );
+ maButtonOption.Show( FALSE );
+ maVectorBox.Show( FALSE );
+ maVectorTxt.Show( FALSE );
+ maOptionDescTxt.Show( FALSE );
+}
+
+void SaneDlg::EstablishBoolOption()
+{
+ BOOL bSuccess, bValue;
+
+ bSuccess = mrSane.GetOptionValue( mnCurrentOption, bValue );
+ if( bSuccess )
+ {
+ maOptionDescTxt.SetText( mrSane.GetOptionName( mnCurrentOption ) );
+ maOptionDescTxt.Show( TRUE );
+ maBoolCheckBox.Check( bValue );
+ maBoolCheckBox.Show( TRUE );
+ }
+}
+
+void SaneDlg::EstablishStringOption()
+{
+ BOOL bSuccess;
+ ByteString aValue;
+
+ bSuccess = mrSane.GetOptionValue( mnCurrentOption, aValue );
+ if( bSuccess )
+ {
+ maOptionDescTxt.SetText( mrSane.GetOptionName( mnCurrentOption ) );
+ maOptionDescTxt.Show( TRUE );
+ maStringEdit.SetText( String( aValue, osl_getThreadTextEncoding() ) );
+ maStringEdit.Show( TRUE );
+ }
+}
+
+void SaneDlg::EstablishStringRange()
+{
+ const char** ppStrings = mrSane.GetStringConstraint( mnCurrentOption );
+ maStringRangeBox.Clear();
+ for( int i = 0; ppStrings[i] != 0; i++ )
+ maStringRangeBox.InsertEntry( String( ppStrings[i], osl_getThreadTextEncoding() ) );
+ ByteString aValue;
+ mrSane.GetOptionValue( mnCurrentOption, aValue );
+ maStringRangeBox.SelectEntry( String( aValue, osl_getThreadTextEncoding() ) );
+ maStringRangeBox.Show( TRUE );
+ maOptionDescTxt.SetText( mrSane.GetOptionName( mnCurrentOption ) );
+ maOptionDescTxt.Show( TRUE );
+}
+
+void SaneDlg::EstablishQuantumRange()
+{
+ if( mpRange )
+ {
+ delete [] mpRange;
+ mpRange = 0;
+ }
+ int nValues = mrSane.GetRange( mnCurrentOption, mpRange );
+ if( nValues == 0 )
+ {
+ mfMin = mpRange[ 0 ];
+ mfMax = mpRange[ 1 ];
+ delete [] mpRange;
+ mpRange = 0;
+ EstablishNumericOption();
+ }
+ else if( nValues > 0 )
+ {
+ char pBuf[ 256 ];
+ maQuantumRangeBox.Clear();
+ mfMin = mpRange[ 0 ];
+ mfMax = mpRange[ nValues-1 ];
+ for( int i = 0; i < nValues; i++ )
+ {
+ sprintf( pBuf, "%g", mpRange[ i ] );
+ maQuantumRangeBox.InsertEntry( String( pBuf, osl_getThreadTextEncoding() ) );
+ }
+ double fValue;
+ if( mrSane.GetOptionValue( mnCurrentOption, fValue, mnCurrentElement ) )
+ {
+ sprintf( pBuf, "%g", fValue );
+ maQuantumRangeBox.SelectEntry( String( pBuf, osl_getThreadTextEncoding() ) );
+ }
+ maQuantumRangeBox.Show( TRUE );
+ String aText( mrSane.GetOptionName( mnCurrentOption ) );
+ aText += ' ';
+ aText += mrSane.GetOptionUnitName( mnCurrentOption );
+ maOptionDescTxt.SetText( aText );
+ maOptionDescTxt.Show( TRUE );
+ }
+}
+
+void SaneDlg::EstablishNumericOption()
+{
+ BOOL bSuccess;
+ double fValue;
+
+ bSuccess = mrSane.GetOptionValue( mnCurrentOption, fValue );
+ if( ! bSuccess )
+ return;
+
+ char pBuf[256];
+ String aText( mrSane.GetOptionName( mnCurrentOption ) );
+ aText += ' ';
+ aText += mrSane.GetOptionUnitName( mnCurrentOption );
+ if( mfMin != mfMax )
+ {
+ sprintf( pBuf, " < %g ; %g >", mfMin, mfMax );
+ aText += String( pBuf, osl_getThreadTextEncoding() );
+ }
+ maOptionDescTxt.SetText( aText );
+ maOptionDescTxt.Show( TRUE );
+ sprintf( pBuf, "%g", fValue );
+ maNumericEdit.SetText( String( pBuf, osl_getThreadTextEncoding() ) );
+ maNumericEdit.Show( TRUE );
+}
+
+void SaneDlg::EstablishButtonOption()
+{
+ maOptionDescTxt.SetText( mrSane.GetOptionName( mnCurrentOption ) );
+ maOptionDescTxt.Show( TRUE );
+ maButtonOption.Show( TRUE );
+}
+
+#define RECT_SIZE_PIX 7
+
+void SaneDlg::MouseMove( const MouseEvent& rMEvt )
+{
+ if( mbIsDragging )
+ {
+ Point aMousePos = rMEvt.GetPosPixel();
+ // move into valid area
+ Point aLogicPos = GetLogicPos( aMousePos );
+ aMousePos = GetPixelPos( aLogicPos );
+ switch( meDragDirection )
+ {
+ case TopLeft: maTopLeft = aMousePos; break;
+ case Top: maTopLeft.Y() = aMousePos.Y(); break;
+ case TopRight:
+ maTopLeft.Y() = aMousePos.Y();
+ maBottomRight.X() = aMousePos.X();
+ break;
+ case Right: maBottomRight.X() = aMousePos.X(); break;
+ case BottomRight: maBottomRight = aMousePos; break;
+ case Bottom: maBottomRight.Y() = aMousePos.Y(); break;
+ case BottomLeft:
+ maTopLeft.X() = aMousePos.X();
+ maBottomRight.Y() = aMousePos.Y();
+ break;
+ case Left: maTopLeft.X() = aMousePos.X(); break;
+ default: break;
+ }
+ int nSwap;
+ if( maTopLeft.X() > maBottomRight.X() )
+ {
+ nSwap = maTopLeft.X();
+ maTopLeft.X() = maBottomRight.X();
+ maBottomRight.X() = nSwap;
+ }
+ if( maTopLeft.Y() > maBottomRight.Y() )
+ {
+ nSwap = maTopLeft.Y();
+ maTopLeft.Y() = maBottomRight.Y();
+ maBottomRight.Y() = nSwap;
+ }
+ DrawDrag();
+ UpdateScanArea( FALSE );
+ }
+ ModalDialog::MouseMove( rMEvt );
+}
+
+void SaneDlg::MouseButtonDown( const MouseEvent& rMEvt )
+{
+ Point aMousePixel = rMEvt.GetPosPixel();
+
+ if( ! mbIsDragging && mbDragEnable )
+ {
+ int nMiddleX = ( maBottomRight.X() - maTopLeft.X() ) / 2 - RECT_SIZE_PIX/2 + maTopLeft.X();
+ int nMiddleY = ( maBottomRight.Y() - maTopLeft.Y() ) / 2 - RECT_SIZE_PIX/2 + maTopLeft.Y();
+ if( aMousePixel.Y() >= maTopLeft.Y() &&
+ aMousePixel.Y() < maTopLeft.Y() + RECT_SIZE_PIX )
+ {
+ if( aMousePixel.X() >= maTopLeft.X() &&
+ aMousePixel.X() < maTopLeft.X() + RECT_SIZE_PIX )
+ {
+ meDragDirection = TopLeft;
+ aMousePixel = maTopLeft;
+ mbIsDragging = TRUE;
+ }
+ else if( aMousePixel.X() >= nMiddleX &&
+ aMousePixel.X() < nMiddleX + RECT_SIZE_PIX )
+ {
+ meDragDirection = Top;
+ aMousePixel.Y() = maTopLeft.Y();
+ mbIsDragging = TRUE;
+ }
+ else if( aMousePixel.X() > maBottomRight.X() - RECT_SIZE_PIX &&
+ aMousePixel.X() <= maBottomRight.X() )
+ {
+ meDragDirection = TopRight;
+ aMousePixel = Point( maBottomRight.X(), maTopLeft.Y() );
+ mbIsDragging = TRUE;
+ }
+ }
+ else if( aMousePixel.Y() >= nMiddleY &&
+ aMousePixel.Y() < nMiddleY + RECT_SIZE_PIX )
+ {
+ if( aMousePixel.X() >= maTopLeft.X() &&
+ aMousePixel.X() < maTopLeft.X() + RECT_SIZE_PIX )
+ {
+ meDragDirection = Left;
+ aMousePixel.X() = maTopLeft.X();
+ mbIsDragging = TRUE;
+ }
+ else if( aMousePixel.X() > maBottomRight.X() - RECT_SIZE_PIX &&
+ aMousePixel.X() <= maBottomRight.X() )
+ {
+ meDragDirection = Right;
+ aMousePixel.X() = maBottomRight.X();
+ mbIsDragging = TRUE;
+ }
+ }
+ else if( aMousePixel.Y() <= maBottomRight.Y() &&
+ aMousePixel.Y() > maBottomRight.Y() - RECT_SIZE_PIX )
+ {
+ if( aMousePixel.X() >= maTopLeft.X() &&
+ aMousePixel.X() < maTopLeft.X() + RECT_SIZE_PIX )
+ {
+ meDragDirection = BottomLeft;
+ aMousePixel = Point( maTopLeft.X(), maBottomRight.Y() );
+ mbIsDragging = TRUE;
+ }
+ else if( aMousePixel.X() >= nMiddleX &&
+ aMousePixel.X() < nMiddleX + RECT_SIZE_PIX )
+ {
+ meDragDirection = Bottom;
+ aMousePixel.Y() = maBottomRight.Y();
+ mbIsDragging = TRUE;
+ }
+ else if( aMousePixel.X() > maBottomRight.X() - RECT_SIZE_PIX &&
+ aMousePixel.X() <= maBottomRight.X() )
+ {
+ meDragDirection = BottomRight;
+ aMousePixel = maBottomRight;
+ mbIsDragging = TRUE;
+ }
+ }
+ }
+ if( mbIsDragging )
+ {
+ SetPointerPosPixel( aMousePixel );
+ DrawDrag();
+ }
+ ModalDialog::MouseButtonDown( rMEvt );
+}
+
+void SaneDlg::MouseButtonUp( const MouseEvent& rMEvt )
+{
+ if( mbIsDragging )
+ {
+ UpdateScanArea( TRUE );
+ }
+ mbIsDragging = FALSE;
+
+ ModalDialog::MouseButtonUp( rMEvt );
+}
+
+void SaneDlg::DrawRectangles( Point& rUL, Point& rBR )
+{
+ int nMiddleX, nMiddleY;
+ Point aBL, aUR;
+
+ aUR = Point( rBR.X(), rUL.Y() );
+ aBL = Point( rUL.X(), rBR.Y() );
+ nMiddleX = ( rBR.X() - rUL.X() ) / 2 + rUL.X();
+ nMiddleY = ( rBR.Y() - rUL.Y() ) / 2 + rUL.Y();
+
+ DrawLine( rUL, aBL );
+ DrawLine( aBL, rBR );
+ DrawLine( rBR, aUR );
+ DrawLine( aUR, rUL );
+ DrawRect( Rectangle( rUL, Size( RECT_SIZE_PIX,RECT_SIZE_PIX ) ) );
+ DrawRect( Rectangle( aBL, Size( RECT_SIZE_PIX, -RECT_SIZE_PIX ) ) );
+ DrawRect( Rectangle( rBR, Size( -RECT_SIZE_PIX, -RECT_SIZE_PIX ) ) );
+ DrawRect( Rectangle( aUR, Size( -RECT_SIZE_PIX, RECT_SIZE_PIX ) ) );
+ DrawRect( Rectangle( Point( nMiddleX - RECT_SIZE_PIX/2, rUL.Y() ), Size( RECT_SIZE_PIX, RECT_SIZE_PIX ) ) );
+ DrawRect( Rectangle( Point( nMiddleX - RECT_SIZE_PIX/2, rBR.Y() ), Size( RECT_SIZE_PIX, -RECT_SIZE_PIX ) ) );
+ DrawRect( Rectangle( Point( rUL.X(), nMiddleY - RECT_SIZE_PIX/2 ), Size( RECT_SIZE_PIX, RECT_SIZE_PIX ) ) );
+ DrawRect( Rectangle( Point( rBR.X(), nMiddleY - RECT_SIZE_PIX/2 ), Size( -RECT_SIZE_PIX, RECT_SIZE_PIX ) ) );
+}
+
+void SaneDlg::DrawDrag()
+{
+ static Point aLastUL, aLastBR;
+
+ if( ! mbDragEnable )
+ return;
+
+ RasterOp eROP = GetRasterOp();
+ SetRasterOp( ROP_INVERT );
+ SetMapMode( MapMode( MAP_PIXEL ) );
+
+ if( mbDragDrawn )
+ DrawRectangles( aLastUL, aLastBR );
+
+ aLastUL = maTopLeft;
+ aLastBR = maBottomRight;
+ DrawRectangles( maTopLeft, maBottomRight );
+
+ mbDragDrawn = TRUE;
+ SetRasterOp( eROP );
+ SetMapMode( maMapMode );
+}
+
+Point SaneDlg::GetPixelPos( const Point& rIn )
+{
+ Point aConvert(
+ ( ( rIn.X() * PREVIEW_WIDTH ) /
+ ( maMaxBottomRight.X() - maMinTopLeft.X() ) )
+ + PREVIEW_UPPER_LEFT,
+ ( ( rIn.Y() * PREVIEW_HEIGHT )
+ / ( maMaxBottomRight.Y() - maMinTopLeft.Y() ) )
+ + PREVIEW_UPPER_TOP );
+
+ return LogicToPixel( aConvert, maMapMode );
+}
+
+Point SaneDlg::GetLogicPos( const Point& rIn )
+{
+ Point aConvert = PixelToLogic( rIn, maMapMode );
+ aConvert.X() -= PREVIEW_UPPER_LEFT;
+ aConvert.Y() -= PREVIEW_UPPER_TOP;
+ if( aConvert.X() < 0 )
+ aConvert.X() = 0;
+ if( aConvert.X() >= PREVIEW_WIDTH )
+ aConvert.X() = PREVIEW_WIDTH-1;
+ if( aConvert.Y() < 0 )
+ aConvert.Y() = 0;
+ if( aConvert.Y() >= PREVIEW_HEIGHT )
+ aConvert.Y() = PREVIEW_HEIGHT-1;
+
+ aConvert.X() *= ( maMaxBottomRight.X() - maMinTopLeft.X() );
+ aConvert.X() /= PREVIEW_WIDTH;
+ aConvert.Y() *= ( maMaxBottomRight.Y() - maMinTopLeft.Y() );
+ aConvert.Y() /= PREVIEW_HEIGHT;
+ return aConvert;
+}
+
+void SaneDlg::UpdateScanArea( BOOL bSend )
+{
+ if( ! mbDragEnable )
+ return;
+
+ Point aUL = GetLogicPos( maTopLeft );
+ Point aBR = GetLogicPos( maBottomRight );
+
+ maLeftField.SetValue( aUL.X() );
+ maTopField.SetValue( aUL.Y() );
+ maRightField.SetValue( aBR.X() );
+ maBottomField.SetValue( aBR.Y() );
+
+ if( ! bSend )
+ return;
+
+ if( mrSane.IsOpen() )
+ {
+ SetAdjustedNumericalValue( "tl-x", (double)aUL.X() );
+ SetAdjustedNumericalValue( "tl-y", (double)aUL.Y() );
+ SetAdjustedNumericalValue( "br-x", (double)aBR.X() );
+ SetAdjustedNumericalValue( "br-y", (double)aBR.Y() );
+ }
+}
+
+BOOL SaneDlg::LoadState()
+{
+#ifdef USE_SAVE_STATE
+ int i;
+
+ if( ! Sane::IsSane() )
+ return FALSE;
+
+ const char* pEnv = getenv("HOME");
+ String aFileName( pEnv ? pEnv : "", osl_getThreadTextEncoding() );
+ aFileName += String( RTL_CONSTASCII_USTRINGPARAM( "/.so_sane_state" ) );
+ Config aConfig( aFileName );
+ if( ! aConfig.HasGroup( "SANE" ) )
+ return FALSE;
+
+ aConfig.SetGroup( "SANE" );
+ ByteString aString = aConfig.ReadKey( "SO_LastSaneDevice" );
+ for( i = 0; i < Sane::CountDevices() && ! aString.Equals( ByteString( Sane::GetName( i ), osl_getThreadTextEncoding() ) ); i++ ) ;
+ if( i == Sane::CountDevices() )
+ return FALSE;
+
+ mrSane.Close();
+ mrSane.Open( aString.GetBuffer() );
+
+ DisableOption();
+ InitFields();
+
+ if( mrSane.IsOpen() )
+ {
+ int iMax = aConfig.GetKeyCount();
+ for( i = 0; i < iMax; i++ )
+ {
+ aString = aConfig.GetKeyName( i );
+ ByteString aValue = aConfig.ReadKey( i );
+ int nOption = mrSane.GetOptionByName( aString.GetBuffer() );
+ if( nOption != -1 )
+ {
+ if( aValue.CompareTo( "BOOL=", 5 ) == COMPARE_EQUAL )
+ {
+ aValue.Erase( 0, 5 );
+ BOOL aBOOL = (BOOL)aValue.ToInt32();
+ mrSane.SetOptionValue( nOption, aBOOL );
+ }
+ else if( aValue.CompareTo( "STRING=", 7 ) == COMPARE_EQUAL )
+ {
+ aValue.Erase( 0, 7 );
+ mrSane.SetOptionValue( nOption, String( aValue, osl_getThreadTextEncoding() ) );
+ }
+ else if( aValue.CompareTo( "NUMERIC=", 8 ) == COMPARE_EQUAL )
+ {
+ aValue.Erase( 0, 8 );
+ int nMax = aValue.GetTokenCount( ':' );
+ double fValue=0.0;
+ for( int n = 0; n < nMax ; n++ )
+ {
+ ByteString aSub = aValue.GetToken( n, ':' );
+ sscanf( aSub.GetBuffer(), "%lg", &fValue );
+ SetAdjustedNumericalValue( aString.GetBuffer(), fValue, n );
+ }
+ }
+ }
+ }
+ }
+
+ DisableOption();
+ InitFields();
+
+ return TRUE;
+#else
+ return FALSE;
+#endif
+}
+
+void SaneDlg::SaveState()
+{
+#ifdef USE_SAVE_STATE
+ if( ! Sane::IsSane() )
+ return;
+
+ const char* pEnv = getenv( "HOME" );
+ String aFileName( pEnv ? pEnv : "", osl_getThreadTextEncoding() );
+ aFileName.AppendAscii( "/.so_sane_state" );
+
+ Config aConfig( aFileName );
+ aConfig.DeleteGroup( "SANE" );
+ aConfig.SetGroup( "SANE" );
+ aConfig.WriteKey( "SO_LastSANEDevice", ByteString( maDeviceBox.GetSelectEntry(), RTL_TEXTENCODING_UTF8 ) );
+
+#ifdef SAVE_ALL_STATES
+ for( int i = 1; i < mrSane.CountOptions(); i++ )
+ {
+ String aOption=mrSane.GetOptionName( i );
+ SANE_Value_Type nType = mrSane.GetOptionType( i );
+ switch( nType )
+ {
+ case SANE_TYPE_BOOL:
+ {
+ BOOL bValue;
+ if( mrSane.GetOptionValue( i, bValue ) )
+ {
+ ByteString aString( "BOOL=" );
+ aString += (ULONG)bValue;
+ aConfig.WriteKey( aOption, aString );
+ }
+ }
+ break;
+ case SANE_TYPE_STRING:
+ {
+ String aString( "STRING=" );
+ String aValue;
+ if( mrSane.GetOptionValue( i, aValue ) )
+ {
+ aString += aValue;
+ aConfig.WriteKey( aOption, aString );
+ }
+ }
+ break;
+ case SANE_TYPE_FIXED:
+ case SANE_TYPE_INT:
+ {
+ String aString( "NUMERIC=" );
+ double fValue;
+ char buf[256];
+ for( int n = 0; n < mrSane.GetOptionElements( i ); n++ )
+ {
+ if( ! mrSane.GetOptionValue( i, fValue, n ) )
+ break;
+ if( n > 0 )
+ aString += ":";
+ sprintf( buf, "%lg", fValue );
+ aString += buf;
+ }
+ if( n >= mrSane.GetOptionElements( i ) )
+ aConfig.WriteKey( aOption, aString );
+ }
+ break;
+ default:
+ break;
+ }
+ }
+#else
+ static char const* pSaveOptions[] = {
+ "resolution",
+ "tl-x",
+ "tl-y",
+ "br-x",
+ "br-y"
+ };
+ for( size_t i = 0; i < SAL_N_ELEMENTS(pSaveOptions); i++ )
+ {
+ ByteString aOption = pSaveOptions[i];
+ int nOption = mrSane.GetOptionByName( pSaveOptions[i] );
+ if( nOption > -1 )
+ {
+ SANE_Value_Type nType = mrSane.GetOptionType( nOption );
+ switch( nType )
+ {
+ case SANE_TYPE_BOOL:
+ {
+ BOOL bValue;
+ if( mrSane.GetOptionValue( nOption, bValue ) )
+ {
+ ByteString aString( "BOOL=" );
+ aString += ByteString::CreateFromInt32(bValue);
+ aConfig.WriteKey( aOption, aString );
+ }
+ }
+ break;
+ case SANE_TYPE_STRING:
+ {
+ ByteString aString( "STRING=" );
+ ByteString aValue;
+ if( mrSane.GetOptionValue( nOption, aValue ) )
+ {
+ aString += aValue;
+ aConfig.WriteKey( aOption, aString );
+ }
+ }
+ break;
+ case SANE_TYPE_FIXED:
+ case SANE_TYPE_INT:
+ {
+ ByteString aString( "NUMERIC=" );
+ double fValue;
+ char buf[256];
+ int n;
+
+ for( n = 0; n < mrSane.GetOptionElements( nOption ); n++ )
+ {
+ if( ! mrSane.GetOptionValue( nOption, fValue, n ) )
+ break;
+ if( n > 0 )
+ aString += ":";
+ sprintf( buf, "%lg", fValue );
+ aString += buf;
+ }
+ if( n >= mrSane.GetOptionElements( nOption ) )
+ aConfig.WriteKey( aOption, aString );
+ }
+ break;
+ default:
+ break;
+ }
+ }
+ }
+#endif
+#endif
+}
+
+BOOL SaneDlg::SetAdjustedNumericalValue(
+ const char* pOption,
+ double fValue,
+ int nElement )
+{
+ int nOption;
+ if( ! Sane::IsSane() || ! mrSane.IsOpen() || ( nOption = mrSane.GetOptionByName( pOption ) ) == -1 )
+ return FALSE;
+
+ if( nElement < 0 || nElement >= mrSane.GetOptionElements( nOption ) )
+ return FALSE;
+
+ double* pValues = NULL;
+ int nValues;
+ if( ( nValues = mrSane.GetRange( nOption, pValues ) ) < 0 )
+ return FALSE;
+
+#if OSL_DEBUG_LEVEL > 1
+ fprintf( stderr, "SaneDlg::SetAdjustedNumericalValue( \"%s\", %lg ) ",
+ pOption, fValue );
+#endif
+
+ if( nValues )
+ {
+ int nNearest = 0;
+ double fNearest = 1e6;
+ for( int i = 0; i < nValues; i++ )
+ {
+ if( fabs( fValue - pValues[ i ] ) < fNearest )
+ {
+ fNearest = fabs( fValue - pValues[ i ] );
+ nNearest = i;
+ }
+ }
+ fValue = pValues[ nNearest ];
+ }
+ else
+ {
+ if( fValue < pValues[0] )
+ fValue = pValues[0];
+ if( fValue > pValues[1] )
+ fValue = pValues[1];
+ }
+ delete [] pValues;
+ mrSane.SetOptionValue( nOption, fValue, nElement );
+#if OSL_DEBUG_LEVEL > 1
+ fprintf( stderr, "yields %lg\n", fValue );
+#endif
+
+
+ return TRUE;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/scanner/sanedlg.hrc b/extensions/source/scanner/sanedlg.hrc
new file mode 100644
index 000000000000..711caff9ac2b
--- /dev/null
+++ b/extensions/source/scanner/sanedlg.hrc
@@ -0,0 +1,82 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef _SVT_SANEDLG_HRC
+#define _SVT_SANEDLG_HRC
+
+#define RID_SANE_DIALOG 1000
+#define RID_SCAN_OK 1
+#define RID_SCAN_CANCEL 2
+#define RID_DEVICEINFO_BTN 3
+#define RID_PREVIEW_BOX 4
+#define RID_DEVICE_BOX_TXT 5
+#define RID_DEVICE_BOX 6
+#define RID_SCANAREA_BOX 7
+#define RID_SCAN_LEFT_TXT 8
+#define RID_SCAN_LEFT_BOX 9
+#define RID_SCAN_TOP_BOX 10
+#define RID_SCAN_TOP_TXT 11
+#define RID_SCAN_RIGHT_TXT 12
+#define RID_SCAN_RIGHT_BOX 13
+#define RID_SCAN_BOTTOM_TXT 14
+#define RID_SCAN_BOTTOM_BOX 15
+#define RID_SCAN_RESOLUTION_TXT 16
+#define RID_SCAN_RESOLUTION_BOX 17
+#define RID_PREVIEW_BTN 18
+#define RID_SCAN_OPTION_BOX 19
+#define RID_SCAN_OPTIONTITLE_TXT 20
+#define RID_SCAN_OPTION_DESC_TXT 21
+#define RID_SCAN_BOOL_OPTION_BOX 22
+#define RID_SCAN_OPTION_TXT 23
+#define RID_SCAN_STRING_OPTION_EDT 24
+#define RID_SCAN_QUANTUM_RANGE_BOX 25
+#define RID_SCAN_STRING_RANGE_BOX 26
+#define RID_SCAN_NUMERIC_OPTION_EDT 27
+#define RID_SCAN_BUTTON_OPTION_BTN 28
+#define RID_SCAN_NUMERIC_VECTOR_BOX 29
+#define RID_SCAN_NUMERIC_VECTOR_TXT 30
+#define RID_SCAN_BITMAP_PLUS 31
+#define RID_SCAN_BITMAP_MINUS 32
+#define RID_SCAN_ADVANCED_BOX 33
+#define RID_SCAN_ADVANCED_TXT 34
+
+#define RID_SANE_DEVICEINFO_TXT 1001
+#define RID_SANE_SCANERROR_TXT 1002
+#define RID_SANE_NORESOLUTIONOPTION_TXT 1003
+#define RID_SANE_NOSANELIB_TXT 1004
+
+#define SCAN_AREA_TOP 17
+#define SCAN_AREA_LEFT 8
+#define PREVIEW_UPPER_LEFT SCAN_AREA_LEFT
+#define PREVIEW_UPPER_TOP SCAN_AREA_TOP + 80
+#define PREVIEW_WIDTH 113
+#define PREVIEW_HEIGHT 160
+#define PREVIEW_BOTTOM PREVIEW_UPPER_TOP + PREVIEW_HEIGHT
+#define PREVIEW_RIGHT PREVIEW_UPPER_LEFT + PREVIEW_WIDTH
+#define SECOND_COLUMN PREVIEW_WIDTH + 20
+#define THIRD_COLUMN SECOND_COLUMN + 135
+
+#endif
diff --git a/extensions/source/scanner/sanedlg.hxx b/extensions/source/scanner/sanedlg.hxx
new file mode 100644
index 000000000000..cacd411afdb5
--- /dev/null
+++ b/extensions/source/scanner/sanedlg.hxx
@@ -0,0 +1,153 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef _SVT_SANEDLG_HXX
+#define _SVT_SANEDLG_HXX
+
+#include <vcl/dialog.hxx>
+#include <tools/config.hxx>
+#include <vcl/lstbox.hxx>
+#include <vcl/button.hxx>
+#include <vcl/fixed.hxx>
+#include <vcl/group.hxx>
+#include <vcl/field.hxx>
+#include <vcl/edit.hxx>
+#include <svtools/svtreebx.hxx>
+
+#include <sane.hxx>
+
+class SaneDlg : public ModalDialog
+{
+private:
+ enum DragDirection { TopLeft, Top, TopRight, Right, BottomRight, Bottom,
+ BottomLeft, Left };
+
+ Sane& mrSane;
+ Bitmap maPreviewBitmap;
+ Rectangle maPreviewRect;
+ Point maTopLeft, maBottomRight;
+ Point maMinTopLeft, maMaxBottomRight;
+ BOOL mbDragEnable;
+ BOOL mbIsDragging;
+ int mnDragMode;
+ BOOL mbDragDrawn;
+ DragDirection meDragDirection;
+
+ MapMode maMapMode;
+
+ Link maOldLink;
+
+ OKButton maOKButton;
+ CancelButton maCancelButton;
+ PushButton maDeviceInfoButton;
+ PushButton maPreviewButton;
+ PushButton maButtonOption;
+
+ FixedText maOptionsTxt;
+ FixedText maOptionTitle;
+ FixedText maOptionDescTxt;
+ FixedText maVectorTxt;
+
+ FixedText maScanLeftTxt;
+ MetricField maLeftField;
+ FixedText maScanTopTxt;
+ MetricField maTopField;
+ FixedText maRightTxt;
+ MetricField maRightField;
+ FixedText maBottomTxt;
+ MetricField maBottomField;
+
+ FixedText maDeviceBoxTxt;
+ ListBox maDeviceBox;
+ FixedText maReslTxt;
+ NumericBox maReslBox;
+ FixedText maAdvancedTxt;
+ CheckBox maAdvancedBox;
+
+ NumericField maVectorBox;
+ ListBox maQuantumRangeBox;
+ ListBox maStringRangeBox;
+
+ FixedLine maPreviewBox;
+ FixedLine maAreaBox;
+
+ CheckBox maBoolCheckBox;
+
+ Edit maStringEdit;
+ Edit maNumericEdit;
+
+ SvTreeListBox maOptionBox;
+
+ int mnCurrentOption;
+ int mnCurrentElement;
+ double* mpRange;
+ double mfMin, mfMax;
+
+ DECL_LINK( ClickBtnHdl, Button* );
+ DECL_LINK( SelectHdl, ListBox* );
+ DECL_LINK( ModifyHdl, Edit* );
+ DECL_LINK( ReloadSaneOptionsHdl, Sane* );
+ DECL_LINK( OptionsBoxSelectHdl, SvTreeListBox* );
+
+ void SaveState();
+ BOOL LoadState();
+
+ void InitDevices();
+ void InitFields();
+ void AcquirePreview();
+ void DisableOption();
+ void EstablishBoolOption();
+ void EstablishStringOption();
+ void EstablishStringRange();
+ void EstablishQuantumRange();
+ void EstablishNumericOption();
+ void EstablishButtonOption();
+
+ void DrawRectangles( Point&, Point& );
+ void DrawDrag();
+ Point GetPixelPos( const Point& );
+ Point GetLogicPos( const Point& );
+ void UpdateScanArea( BOOL );
+
+ // helper
+ BOOL SetAdjustedNumericalValue( const char* pOption, double fValue, int nElement = 0 );
+
+ virtual void Paint( const Rectangle& );
+ virtual void MouseMove( const MouseEvent& rMEvt );
+ virtual void MouseButtonDown( const MouseEvent& rMEvt );
+ virtual void MouseButtonUp( const MouseEvent& rMEvt );
+public:
+ SaneDlg( Window*, Sane& );
+ ~SaneDlg();
+
+ virtual short Execute();
+};
+
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/scanner/sanedlg.src b/extensions/source/scanner/sanedlg.src
new file mode 100644
index 000000000000..2b41785c880d
--- /dev/null
+++ b/extensions/source/scanner/sanedlg.src
@@ -0,0 +1,301 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#include <sanedlg.hrc>
+ModalDialog RID_SANE_DIALOG
+{
+ OutputSize = TRUE ;
+ SVLook = TRUE ;
+ Pos = MAP_APPFONT ( 10 , 10 ) ;
+ Size = MAP_APPFONT ( THIRD_COLUMN + 60 , 268 ) ;
+ Moveable = TRUE ;
+ Closeable = TRUE ;
+ OKButton RID_SCAN_OK
+ {
+ Pos = MAP_APPFONT ( THIRD_COLUMN , 6 ) ;
+ Size = MAP_APPFONT ( 55 , 14 ) ;
+ DefButton = TRUE;
+ };
+ CancelButton RID_SCAN_CANCEL
+ {
+ Pos = MAP_APPFONT ( THIRD_COLUMN , 25 ) ;
+ Size = MAP_APPFONT ( 55 , 14 ) ;
+ };
+ PushButton RID_DEVICEINFO_BTN
+ {
+ Pos = MAP_APPFONT ( THIRD_COLUMN , 44 ) ;
+ Size = MAP_APPFONT ( 55 , 22 ) ;
+ Text [ en-US ] = "About\n Dev~ice" ;
+ };
+ PushButton RID_PREVIEW_BTN
+ {
+ Pos = MAP_APPFONT ( THIRD_COLUMN , 71 ) ;
+ Size = MAP_APPFONT ( 55 , 22 ) ;
+ Text [ en-US ] = "Create\nPreview" ;
+ };
+ FixedLine RID_PREVIEW_BOX
+ {
+ Pos = MAP_APPFONT ( PREVIEW_UPPER_LEFT - 5 , PREVIEW_UPPER_TOP - 8 ) ;
+ Size = MAP_APPFONT ( PREVIEW_WIDTH + 10 , 8 ) ;
+ Text [ en-US ] = "Preview" ;
+ };
+ FixedLine RID_SCANAREA_BOX
+ {
+ Pos = MAP_APPFONT ( SCAN_AREA_LEFT - 5 , SCAN_AREA_TOP - 12 ) ;
+ Size = MAP_APPFONT ( PREVIEW_WIDTH + 10 , 8 ) ;
+ Text [ en-US ] = "Scan area" ;
+ };
+ FixedText RID_SCAN_LEFT_TXT
+ {
+ Pos = MAP_APPFONT ( SCAN_AREA_LEFT , SCAN_AREA_TOP ) ;
+ Size = MAP_APPFONT ( 50 , 8 ) ;
+ Text [ en-US ] = "Left:" ;
+ };
+ MetricField RID_SCAN_LEFT_BOX
+ {
+ Spin = TRUE ;
+ Repeat = TRUE ;
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( SCAN_AREA_LEFT + 50 , SCAN_AREA_TOP - 2 ) ;
+ Size = MAP_APPFONT ( PREVIEW_WIDTH - 50 , 12 ) ;
+ };
+ FixedText RID_SCAN_TOP_TXT
+ {
+ Pos = MAP_APPFONT ( SCAN_AREA_LEFT , SCAN_AREA_TOP + 17 ) ;
+ Size = MAP_APPFONT ( 50 , 8 ) ;
+ Text [ en-US ] = "Top:" ;
+ };
+ MetricField RID_SCAN_TOP_BOX
+ {
+ Spin = TRUE ;
+ Repeat = TRUE ;
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( SCAN_AREA_LEFT + 50 , SCAN_AREA_TOP + 15 ) ;
+ Size = MAP_APPFONT ( PREVIEW_WIDTH - 50 , 12 ) ;
+ };
+ FixedText RID_SCAN_RIGHT_TXT
+ {
+ Pos = MAP_APPFONT ( SCAN_AREA_LEFT , SCAN_AREA_TOP + 34 ) ;
+ Size = MAP_APPFONT ( 50 , 8 ) ;
+ Text [ en-US ] = "Right:" ;
+ };
+ MetricField RID_SCAN_RIGHT_BOX
+ {
+ Spin = TRUE ;
+ Repeat = TRUE ;
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( SCAN_AREA_LEFT + 50 , SCAN_AREA_TOP + 32 ) ;
+ Size = MAP_APPFONT ( PREVIEW_WIDTH - 50 , 12 ) ;
+ };
+ FixedText RID_SCAN_BOTTOM_TXT
+ {
+ Pos = MAP_APPFONT ( SCAN_AREA_LEFT , SCAN_AREA_TOP + 51 ) ;
+ Size = MAP_APPFONT ( 50 , 8 ) ;
+ Text [ en-US ] = "Bottom:" ;
+ };
+ MetricField RID_SCAN_BOTTOM_BOX
+ {
+ Spin = TRUE ;
+ Repeat = TRUE ;
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( SCAN_AREA_LEFT + 50 , SCAN_AREA_TOP + 49 ) ;
+ Size = MAP_APPFONT ( PREVIEW_WIDTH - 50 , 12 ) ;
+ };
+ FixedText RID_DEVICE_BOX_TXT
+ {
+ Pos = MAP_APPFONT ( SECOND_COLUMN , 8 ) ;
+ Size = MAP_APPFONT ( 70 , 8 ) ;
+ Text [ en-US ] = "Device used:" ;
+ };
+ ListBox RID_DEVICE_BOX
+ {
+ Border = TRUE ;
+ Dropdown = TRUE ;
+ Sort = TRUE ;
+ Pos = MAP_APPFONT ( SECOND_COLUMN + 70 , 6 ) ;
+ Size = MAP_APPFONT ( 60 , 80 ) ;
+ };
+ FixedText RID_SCAN_RESOLUTION_TXT
+ {
+ Pos = MAP_APPFONT ( SECOND_COLUMN , 25 ) ;
+ Size = MAP_APPFONT ( 70 , 8 ) ;
+ Text [ en-US ] = "Resolution [~DPI]" ;
+ };
+ NumericBox RID_SCAN_RESOLUTION_BOX
+ {
+ Dropdown = TRUE ;
+ Pos = MAP_APPFONT ( SECOND_COLUMN + 70 , 23 ) ;
+ Size = MAP_APPFONT ( 60 , 80 ) ;
+ };
+ FixedText RID_SCAN_ADVANCED_TXT
+ {
+ Pos = MAP_APPFONT ( SECOND_COLUMN , 40 ) ;
+ Size = MAP_APPFONT ( 120 , 8 ) ;
+ Text [ en-US ] = "Show advanced options" ;
+ };
+ CheckBox RID_SCAN_ADVANCED_BOX
+ {
+ Check = FALSE ;
+ Pos = MAP_APPFONT ( SECOND_COLUMN + 120 , 40 ) ;
+ Size = MAP_APPFONT ( 8 , 8 ) ;
+ };
+ FixedText RID_SCAN_OPTION_TXT
+ {
+ Pos = MAP_APPFONT ( SECOND_COLUMN , 54 ) ;
+ Size = MAP_APPFONT ( 130 , 8 ) ;
+ Text [ en-US ] = "Options:" ;
+ };
+ Control RID_SCAN_OPTION_BOX
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( SECOND_COLUMN , 63 ) ;
+ Size = MAP_APPFONT ( 130 , 102 ) ;
+ };
+ FixedText RID_SCAN_OPTIONTITLE_TXT
+ {
+ WordBreak = TRUE ;
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( SECOND_COLUMN , 170 ) ;
+ Size = MAP_APPFONT ( 130 , 50 ) ;
+ };
+ FixedText RID_SCAN_OPTION_DESC_TXT
+ {
+ Pos = MAP_APPFONT ( SECOND_COLUMN , 225 ) ;
+ Size = MAP_APPFONT ( 120 , 8 ) ;
+ };
+ CheckBox RID_SCAN_BOOL_OPTION_BOX
+ {
+ Pos = MAP_APPFONT ( SECOND_COLUMN + 120 , 225 ) ;
+ Size = MAP_APPFONT ( 8 , 8 ) ;
+ };
+ Edit RID_SCAN_STRING_OPTION_EDT
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( SECOND_COLUMN , 234 ) ;
+ Size = MAP_APPFONT ( 130 , 12 ) ;
+ };
+ ListBox RID_SCAN_QUANTUM_RANGE_BOX
+ {
+ Border = TRUE ;
+ Dropdown = TRUE ;
+ Pos = MAP_APPFONT ( SECOND_COLUMN , 234 ) ;
+ Size = MAP_APPFONT ( 130 , 80 ) ;
+ };
+ ListBox RID_SCAN_STRING_RANGE_BOX
+ {
+ Border = TRUE ;
+ Dropdown = TRUE ;
+ Pos = MAP_APPFONT ( SECOND_COLUMN , 234 ) ;
+ Size = MAP_APPFONT ( 130 , 80 ) ;
+ };
+ Edit RID_SCAN_NUMERIC_OPTION_EDT
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( SECOND_COLUMN , 234 ) ;
+ Size = MAP_APPFONT ( 130 , 12 ) ;
+ };
+ FixedText RID_SCAN_NUMERIC_VECTOR_TXT
+ {
+ Pos = MAP_APPFONT ( SECOND_COLUMN , 253 ) ;
+ Size = MAP_APPFONT ( 90 , 8 ) ;
+ Text [ en-US ] = "Vector element" ;
+ };
+ NumericField RID_SCAN_NUMERIC_VECTOR_BOX
+ {
+ Border = TRUE ;
+ Spin = TRUE ;
+ Repeat = TRUE ;
+ Pos = MAP_APPFONT ( SECOND_COLUMN + 90 , 251 ) ;
+ Size = MAP_APPFONT ( 40 , 12 ) ;
+ };
+ PushButton RID_SCAN_BUTTON_OPTION_BTN
+ {
+ Pos = MAP_APPFONT ( SECOND_COLUMN , 234 ) ;
+ Size = MAP_APPFONT ( 130 , 14 ) ;
+ Text [ en-US ] = "Set" ;
+ };
+ Bitmap RID_SCAN_BITMAP_PLUS
+ {
+ File = "plus.bmp" ;
+ };
+ Bitmap RID_SCAN_BITMAP_MINUS
+ {
+ File = "minus.bmp" ;
+ };
+ Text [ en-US ] = "Scanner" ;
+};
+String RID_SANE_DEVICEINFO_TXT
+{
+ Text [ en-US ] = "Device: %s\nVendor: %s\nModel: %s\nType: %s" ;
+};
+String RID_SANE_SCANERROR_TXT
+{
+ Text [ en-US ] = "An error occurred while scanning." ;
+};
+String RID_SANE_NORESOLUTIONOPTION_TXT
+{
+ Text [ en-US ] = "The device does not offer a preview option. Therefore, a normal scan will be used as a preview instead. This may take a considerable amount of time." ;
+};
+String RID_SANE_NOSANELIB_TXT
+{
+ Text [ en-US ] = "The SANE interface could not be initialized. Scanning is not possible." ;
+};
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/extensions/source/scanner/scanner.cxx b/extensions/source/scanner/scanner.cxx
new file mode 100644
index 000000000000..97d8b925c1e4
--- /dev/null
+++ b/extensions/source/scanner/scanner.cxx
@@ -0,0 +1,107 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+#include <scanner.hxx>
+
+// ------------------
+// - ScannerManager -
+// ------------------
+
+REF( XInterface ) SAL_CALL ScannerManager_CreateInstance( const REF( com::sun::star::lang::XMultiServiceFactory )& /*rxFactory*/ ) throw ( Exception )
+{
+ return *( new ScannerManager() );
+}
+
+// -----------------------------------------------------------------------------
+
+ScannerManager::ScannerManager() :
+ mpData( NULL )
+{
+ AcquireData();
+}
+
+// -----------------------------------------------------------------------------
+
+ScannerManager::~ScannerManager()
+{
+ ReleaseData();
+}
+
+// -----------------------------------------------------------------------------
+
+ANY SAL_CALL ScannerManager::queryInterface( const Type& rType ) throw( RuntimeException )
+{
+ const ANY aRet( cppu::queryInterface( rType,
+ static_cast< XScannerManager* >( this ),
+ static_cast< AWT::XBitmap* >( this ) ) );
+
+ return( aRet.hasValue() ? aRet : OWeakObject::queryInterface( rType ) );
+}
+
+// -----------------------------------------------------------------------------
+
+void SAL_CALL ScannerManager::acquire() throw()
+{
+ OWeakObject::acquire();
+}
+
+// -----------------------------------------------------------------------------
+
+void SAL_CALL ScannerManager::release() throw()
+{
+ OWeakObject::release();
+}
+
+// -----------------------------------------------------------------------------
+
+SEQ( sal_Int8 ) SAL_CALL ScannerManager::getMaskDIB() throw()
+{
+ return SEQ( sal_Int8 )();
+}
+
+// -----------------------------------------------------------------------------
+
+OUString ScannerManager::getImplementationName_Static() throw()
+{
+ return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.scanner.ScannerManager" ) );
+}
+
+// -----------------------------------------------------------------------------
+
+SEQ( OUString ) ScannerManager::getSupportedServiceNames_Static() throw ()
+{
+ SEQ( OUString ) aSNS( 1 );
+
+ aSNS.getArray()[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.scanner.ScannerManager" ) );
+
+ return aSNS;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/scanner/scanner.hxx b/extensions/source/scanner/scanner.hxx
new file mode 100644
index 000000000000..f8420bd4483f
--- /dev/null
+++ b/extensions/source/scanner/scanner.hxx
@@ -0,0 +1,113 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _EXT_SCANNER_HXX
+#define _EXT_SCANNER_HXX
+
+#include <tools/stream.hxx>
+#include <osl/mutex.hxx>
+#include <rtl/ustring.hxx>
+#include <cppuhelper/weak.hxx>
+#include <cppuhelper/weak.hxx>
+#include <com/sun/star/uno/Reference.h>
+#include <com/sun/star/uno/Sequence.h>
+#include <com/sun/star/awt/XBitmap.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/lang/XEventListener.hpp>
+#include <com/sun/star/lang/EventObject.hpp>
+#include <com/sun/star/scanner/XScannerManager.hpp>
+#include <com/sun/star/scanner/ScannerException.hpp>
+
+using namespace rtl;
+using namespace cppu;
+using namespace com::sun::star::uno;
+using namespace com::sun::star::scanner;
+
+// -----------
+// - Defines -
+// -----------
+
+#define REF( _def_Obj ) Reference< _def_Obj >
+#define SEQ( _def_Obj ) Sequence< _def_Obj >
+#define ANY Any
+#define AWT com::sun::star::awt
+
+// ------------------
+// - ScannerManager -
+// ------------------
+
+class ScannerManager : public OWeakObject, XScannerManager, AWT::XBitmap
+{
+protected:
+
+ osl::Mutex maProtector;
+ void* mpData;
+
+ void AcquireData();
+ void ReleaseData();
+
+public:
+
+ ScannerManager();
+ virtual ~ScannerManager();
+
+ // XInterface
+ virtual ANY SAL_CALL queryInterface( const Type & rType ) throw( RuntimeException );
+ virtual void SAL_CALL acquire() throw();
+ virtual void SAL_CALL release() throw();
+
+ // XScannerManager
+ virtual SEQ( ScannerContext ) SAL_CALL getAvailableScanners() throw();
+ virtual BOOL SAL_CALL configureScanner( ScannerContext& scanner_context ) throw( ScannerException );
+ virtual void SAL_CALL startScan( const ScannerContext& scanner_context, const REF( com::sun::star::lang::XEventListener )& rxListener ) throw( ScannerException );
+ virtual ScanError SAL_CALL getError( const ScannerContext& scanner_context ) throw( ScannerException );
+ virtual REF( AWT::XBitmap ) SAL_CALL getBitmap( const ScannerContext& scanner_context ) throw( ScannerException );
+
+ // XBitmap
+ virtual AWT::Size SAL_CALL getSize() throw();
+ virtual SEQ( sal_Int8 ) SAL_CALL getDIB() throw();
+ virtual SEQ( sal_Int8 ) SAL_CALL getMaskDIB() throw();
+
+ // Misc
+ static OUString getImplementationName_Static() throw();
+ static Sequence< OUString > getSupportedServiceNames_Static() throw();
+
+ void Lock() { maProtector.acquire(); }
+ void Unlock() { maProtector.release(); }
+
+ void* GetData() const { return mpData; }
+ void SetData( void* pData ) { ReleaseData(); mpData = pData; }
+};
+
+// -----------------------------------------------------------------------------
+
+REF( XInterface ) SAL_CALL ScannerManager_CreateInstance( const REF( com::sun::star::lang::XMultiServiceFactory )& rxFactory ) throw( Exception );
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/scanner/scanunx.cxx b/extensions/source/scanner/scanunx.cxx
new file mode 100644
index 000000000000..0dcf457713b9
--- /dev/null
+++ b/extensions/source/scanner/scanunx.cxx
@@ -0,0 +1,386 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+#include <scanner.hxx>
+#include <sanedlg.hxx>
+#include <osl/thread.hxx>
+#include <tools/list.hxx>
+#include <boost/shared_ptr.hpp>
+
+#if OSL_DEBUG_LEVEL > 1
+#include <stdio.h>
+#endif
+
+BitmapTransporter::BitmapTransporter()
+{
+#if OSL_DEBUG_LEVEL > 1
+ fprintf( stderr, "BitmapTransporter\n" );
+#endif
+}
+
+BitmapTransporter::~BitmapTransporter()
+{
+#if OSL_DEBUG_LEVEL > 1
+ fprintf( stderr, "~BitmapTransporter\n" );
+#endif
+}
+
+// -----------------------------------------------------------------------------
+
+ANY SAL_CALL BitmapTransporter::queryInterface( const Type& rType ) throw( RuntimeException )
+{
+ const ANY aRet( cppu::queryInterface( rType, static_cast< AWT::XBitmap* >( this ) ) );
+
+ return( aRet.hasValue() ? aRet : OWeakObject::queryInterface( rType ) );
+}
+
+// -----------------------------------------------------------------------------
+
+AWT::Size BitmapTransporter::getSize() throw()
+{
+ osl::MutexGuard aGuard( m_aProtector );
+ int nPreviousPos = m_aStream.Tell();
+ AWT::Size aRet;
+
+ // ensure that there is at least a header
+ m_aStream.Seek( STREAM_SEEK_TO_END );
+ int nLen = m_aStream.Tell();
+ if( nLen > 15 )
+ {
+ m_aStream.Seek( 4 );
+ m_aStream >> aRet.Width >> aRet.Height;
+ }
+ else
+ aRet.Width = aRet.Height = 0;
+
+ m_aStream.Seek( nPreviousPos );
+
+ return aRet;
+}
+
+// -----------------------------------------------------------------------------
+
+SEQ( sal_Int8 ) BitmapTransporter::getDIB() throw()
+{
+ osl::MutexGuard aGuard( m_aProtector );
+ int nPreviousPos = m_aStream.Tell();
+
+ // create return value
+ m_aStream.Seek( STREAM_SEEK_TO_END );
+ int nBytes = m_aStream.Tell();
+ m_aStream.Seek( 0 );
+
+ SEQ( sal_Int8 ) aValue( nBytes );
+ m_aStream.Read( aValue.getArray(), nBytes );
+ m_aStream.Seek( nPreviousPos );
+
+ return aValue;
+}
+
+// --------------
+// - SaneHolder -
+// --------------
+
+struct SaneHolder
+{
+ Sane m_aSane;
+ REF( AWT::XBitmap ) m_xBitmap;
+ osl::Mutex m_aProtector;
+ ScanError m_nError;
+ bool m_bBusy;
+
+ SaneHolder() : m_nError(ScanError_ScanErrorNone), m_bBusy(false) {}
+};
+
+namespace
+{
+ typedef std::vector< boost::shared_ptr<SaneHolder> > sanevec;
+ class allSanes
+ {
+ private:
+ int mnRefCount;
+ public:
+ sanevec m_aSanes;
+ allSanes() : mnRefCount(0) {}
+ void acquire();
+ void release();
+ };
+
+ void allSanes::acquire()
+ {
+ ++mnRefCount;
+ }
+
+ void allSanes::release()
+ {
+ // was unused, now because of i99835: "Scanning interface not SANE API
+ // compliant" destroy all SaneHolder to get Sane Dtor called
+ --mnRefCount;
+ if (!mnRefCount)
+ m_aSanes.clear();
+ }
+
+ struct theSaneProtector : public rtl::Static<osl::Mutex, theSaneProtector> {};
+ struct theSanes : public rtl::Static<allSanes, theSanes> {};
+}
+
+// -----------------
+// - ScannerThread -
+// -----------------
+
+class ScannerThread : public osl::Thread
+{
+ boost::shared_ptr<SaneHolder> m_pHolder;
+ REF( com::sun::star::lang::XEventListener ) m_xListener;
+ ScannerManager* m_pManager; // just for the disposing call
+
+public:
+ virtual void run();
+ virtual void onTerminated() { delete this; }
+public:
+ ScannerThread( boost::shared_ptr<SaneHolder> pHolder,
+ const REF( com::sun::star::lang::XEventListener )& listener,
+ ScannerManager* pManager );
+ virtual ~ScannerThread();
+};
+
+// -----------------------------------------------------------------------------
+
+ScannerThread::ScannerThread(
+ boost::shared_ptr<SaneHolder> pHolder,
+ const REF( com::sun::star::lang::XEventListener )& listener,
+ ScannerManager* pManager )
+ : m_pHolder( pHolder ), m_xListener( listener ), m_pManager( pManager )
+{
+#if OSL_DEBUG_LEVEL > 1
+ fprintf( stderr, "ScannerThread\n" );
+#endif
+}
+
+ScannerThread::~ScannerThread()
+{
+#if OSL_DEBUG_LEVEL > 1
+ fprintf( stderr, "~ScannerThread\n" );
+#endif
+}
+
+void ScannerThread::run()
+{
+ osl::MutexGuard aGuard( m_pHolder->m_aProtector );
+ BitmapTransporter* pTransporter = new BitmapTransporter;
+ REF( XInterface ) aIf( static_cast< OWeakObject* >( pTransporter ) );
+
+ m_pHolder->m_xBitmap = REF( AWT::XBitmap )( aIf, UNO_QUERY );
+
+ m_pHolder->m_bBusy = true;
+ if( m_pHolder->m_aSane.IsOpen() )
+ {
+ int nOption = m_pHolder->m_aSane.GetOptionByName( "preview" );
+ if( nOption != -1 )
+ m_pHolder->m_aSane.SetOptionValue( nOption, (BOOL)FALSE );
+
+ m_pHolder->m_nError =
+ m_pHolder->m_aSane.Start( *pTransporter ) ?
+ ScanError_ScanErrorNone : ScanError_ScanCanceled;
+ }
+ else
+ m_pHolder->m_nError = ScanError_ScannerNotAvailable;
+
+
+ REF( XInterface ) xXInterface( static_cast< OWeakObject* >( m_pManager ) );
+ m_xListener->disposing( com::sun::star::lang::EventObject(xXInterface) );
+ m_pHolder->m_bBusy = false;
+}
+
+// ------------------
+// - ScannerManager -
+// ------------------
+
+void ScannerManager::AcquireData()
+{
+ osl::MutexGuard aGuard( theSaneProtector::get() );
+ theSanes::get().acquire();
+}
+
+void ScannerManager::ReleaseData()
+{
+ osl::MutexGuard aGuard( theSaneProtector::get() );
+ theSanes::get().release();
+}
+
+// -----------------------------------------------------------------------------
+
+AWT::Size ScannerManager::getSize() throw()
+{
+ AWT::Size aRet;
+ aRet.Width = aRet.Height = 0;
+ return aRet;
+}
+
+// -----------------------------------------------------------------------------
+
+SEQ( sal_Int8 ) ScannerManager::getDIB() throw()
+{
+ return SEQ( sal_Int8 )();
+}
+
+// -----------------------------------------------------------------------------
+
+SEQ( ScannerContext ) ScannerManager::getAvailableScanners() throw()
+{
+ osl::MutexGuard aGuard( theSaneProtector::get() );
+ sanevec &rSanes = theSanes::get().m_aSanes;
+
+ if( rSanes.empty() )
+ {
+ boost::shared_ptr<SaneHolder> pSaneHolder(new SaneHolder);
+ if( Sane::IsSane() )
+ rSanes.push_back( pSaneHolder );
+ }
+
+ if( Sane::IsSane() )
+ {
+ SEQ( ScannerContext ) aRet(1);
+ aRet.getArray()[0].ScannerName = ::rtl::OUString::createFromAscii( "SANE" );
+ aRet.getArray()[0].InternalData = 0;
+ return aRet;
+ }
+
+ return SEQ( ScannerContext )();
+}
+
+// -----------------------------------------------------------------------------
+
+BOOL ScannerManager::configureScanner( ScannerContext& scanner_context ) throw( ScannerException )
+{
+ osl::MutexGuard aGuard( theSaneProtector::get() );
+ sanevec &rSanes = theSanes::get().m_aSanes;
+
+#if OSL_DEBUG_LEVEL > 1
+ fprintf( stderr, "ScannerManager::configureScanner\n" );
+#endif
+
+ if( scanner_context.InternalData < 0 || (ULONG)scanner_context.InternalData >= rSanes.size() )
+ throw ScannerException(
+ ::rtl::OUString::createFromAscii( "Scanner does not exist" ),
+ REF( XScannerManager )( this ),
+ ScanError_InvalidContext
+ );
+
+ boost::shared_ptr<SaneHolder> pHolder = rSanes[scanner_context.InternalData];
+ if( pHolder->m_bBusy )
+ throw ScannerException(
+ ::rtl::OUString::createFromAscii( "Scanner is busy" ),
+ REF( XScannerManager )( this ),
+ ScanError_ScanInProgress
+ );
+
+ pHolder->m_bBusy = true;
+ SaneDlg aDlg( NULL, pHolder->m_aSane );
+ BOOL bRet = (BOOL)aDlg.Execute();
+ pHolder->m_bBusy = false;
+
+ return bRet;
+}
+
+// -----------------------------------------------------------------------------
+
+void ScannerManager::startScan( const ScannerContext& scanner_context,
+ const REF( com::sun::star::lang::XEventListener )& listener ) throw( ScannerException )
+{
+ osl::MutexGuard aGuard( theSaneProtector::get() );
+ sanevec &rSanes = theSanes::get().m_aSanes;
+
+#if OSL_DEBUG_LEVEL > 1
+ fprintf( stderr, "ScannerManager::startScan\n" );
+#endif
+
+ if( scanner_context.InternalData < 0 || (ULONG)scanner_context.InternalData >= rSanes.size() )
+ throw ScannerException(
+ ::rtl::OUString::createFromAscii( "Scanner does not exist" ),
+ REF( XScannerManager )( this ),
+ ScanError_InvalidContext
+ );
+ boost::shared_ptr<SaneHolder> pHolder = rSanes[scanner_context.InternalData];
+ if( pHolder->m_bBusy )
+ throw ScannerException(
+ ::rtl::OUString::createFromAscii( "Scanner is busy" ),
+ REF( XScannerManager )( this ),
+ ScanError_ScanInProgress
+ );
+ pHolder->m_bBusy = true;
+
+ ScannerThread* pThread = new ScannerThread( pHolder, listener, this );
+ pThread->create();
+}
+
+// -----------------------------------------------------------------------------
+
+ScanError ScannerManager::getError( const ScannerContext& scanner_context ) throw( ScannerException )
+{
+ osl::MutexGuard aGuard( theSaneProtector::get() );
+ sanevec &rSanes = theSanes::get().m_aSanes;
+
+ if( scanner_context.InternalData < 0 || (ULONG)scanner_context.InternalData >= rSanes.size() )
+ throw ScannerException(
+ ::rtl::OUString::createFromAscii( "Scanner does not exist" ),
+ REF( XScannerManager )( this ),
+ ScanError_InvalidContext
+ );
+
+ boost::shared_ptr<SaneHolder> pHolder = rSanes[scanner_context.InternalData];
+
+ return pHolder->m_nError;
+}
+
+// -----------------------------------------------------------------------------
+
+REF( AWT::XBitmap ) ScannerManager::getBitmap( const ScannerContext& scanner_context ) throw( ScannerException )
+{
+ osl::MutexGuard aGuard( theSaneProtector::get() );
+ sanevec &rSanes = theSanes::get().m_aSanes;
+
+ if( scanner_context.InternalData < 0 || (ULONG)scanner_context.InternalData >= rSanes.size() )
+ throw ScannerException(
+ ::rtl::OUString::createFromAscii( "Scanner does not exist" ),
+ REF( XScannerManager )( this ),
+ ScanError_InvalidContext
+ );
+ boost::shared_ptr<SaneHolder> pHolder = rSanes[scanner_context.InternalData];
+
+ osl::MutexGuard aProtGuard( pHolder->m_aProtector );
+
+ REF( AWT::XBitmap ) xRet( pHolder->m_xBitmap );
+ pHolder->m_xBitmap = REF( AWT::XBitmap )();
+
+ return xRet;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/scanner/scanwin.cxx b/extensions/source/scanner/scanwin.cxx
new file mode 100644
index 000000000000..a23181a66624
--- /dev/null
+++ b/extensions/source/scanner/scanwin.cxx
@@ -0,0 +1,1060 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+#include <com/sun/star/uno/Any.hxx>
+#include <com/sun/star/uno/Reference.hxx>
+#include <com/sun/star/util/XCloseable.hpp>
+#include <com/sun/star/util/XCloseBroadcaster.hpp>
+#include <com/sun/star/util/XCloseListener.hpp>
+#include <com/sun/star/frame/XFrame.hpp>
+#include <com/sun/star/frame/XDesktop.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <cppuhelper/implbase1.hxx>
+#include <comphelper/processfactory.hxx>
+
+#include <math.h>
+#include <tools/svwin.h>
+#include <tools/stream.hxx>
+#include <osl/mutex.hxx>
+#include <osl/module.hxx>
+#include <vcl/svapp.hxx>
+#include <vcl/wrkwin.hxx>
+#include <vcl/sysdata.hxx>
+#include <vcl/salbtype.hxx>
+#include "scanner.hxx"
+
+#pragma warning (push,1)
+#pragma warning (disable:4668)
+#include "twain/twain.h"
+#pragma warning (pop)
+
+using namespace ::com::sun::star;
+
+// -----------
+// - Defines -
+// -----------
+
+#define TWAIN_SELECT 0x00000001UL
+#define TWAIN_ACQUIRE 0x00000002UL
+#define TWAIN_TERMINATE 0xFFFFFFFFUL
+
+#define TWAIN_EVENT_NONE 0x00000000UL
+#define TWAIN_EVENT_QUIT 0x00000001UL
+#define TWAIN_EVENT_SCANNING 0x00000002UL
+#define TWAIN_EVENT_XFER 0x00000004UL
+
+#define PFUNC (*pDSM)
+#define PTWAINMSG MSG*
+#define FIXTODOUBLE( nFix ) ((double)nFix.Whole+(double)nFix.Frac/65536.)
+#define FIXTOLONG( nFix ) ((long)floor(FIXTODOUBLE(nFix)+0.5))
+
+#if defined WIN
+#define TWAIN_LIBNAME "TWAIN.DLL"
+#define TWAIN_FUNCNAME "DSM_Entry"
+#elif defined WNT
+#define TWAIN_LIBNAME "TWAIN_32.DLL"
+#define TWAIN_FUNCNAME "DSM_Entry"
+#endif
+
+// --------------
+// - TwainState -
+// --------------
+
+enum TwainState
+{
+ TWAIN_STATE_NONE = 0,
+ TWAIN_STATE_SCANNING = 1,
+ TWAIN_STATE_DONE = 2,
+ TWAIN_STATE_CANCELED = 3
+};
+
+// ------------
+// - ImpTwain -
+// ------------
+
+class ImpTwain : public ::cppu::WeakImplHelper1< util::XCloseListener >
+{
+ friend LRESULT CALLBACK TwainMsgProc( int nCode, WPARAM wParam, LPARAM lParam );
+
+ uno::Reference< uno::XInterface > mxSelfRef;
+ uno::Reference< scanner::XScannerManager > mxMgr;
+ ScannerManager& mrMgr;
+ TW_IDENTITY aAppIdent;
+ TW_IDENTITY aSrcIdent;
+ Link aNotifyLink;
+ DSMENTRYPROC pDSM;
+ osl::Module* pMod;
+ ULONG nCurState;
+ HWND hTwainWnd;
+ HHOOK hTwainHook;
+ bool mbCloseFrameOnExit;
+
+ bool ImplHandleMsg( void* pMsg );
+ void ImplCreate();
+ void ImplOpenSourceManager();
+ void ImplOpenSource();
+ bool ImplEnableSource();
+ void ImplXfer();
+ void ImplFallback( ULONG nEvent );
+ void ImplSendCloseEvent();
+ void ImplDeregisterCloseListener();
+ void ImplRegisterCloseListener();
+ uno::Reference< frame::XFrame > ImplGetActiveFrame();
+ uno::Reference< util::XCloseBroadcaster > ImplGetActiveFrameCloseBroadcaster();
+
+ DECL_LINK( ImplFallbackHdl, void* );
+ DECL_LINK( ImplDestroyHdl, void* );
+
+ // from util::XCloseListener
+ virtual void SAL_CALL queryClosing( const lang::EventObject& Source, sal_Bool GetsOwnership ) throw (util::CloseVetoException, uno::RuntimeException);
+ virtual void SAL_CALL notifyClosing( const lang::EventObject& Source ) throw (uno::RuntimeException);
+
+ // from lang::XEventListener
+ virtual void SAL_CALL disposing( const lang::EventObject& Source ) throw (uno::RuntimeException);
+
+public:
+
+ ImpTwain( ScannerManager& rMgr, const Link& rNotifyLink );
+ ~ImpTwain();
+
+ void Destroy();
+
+ bool SelectSource();
+ bool InitXfer();
+};
+
+// ---------
+// - Procs -
+// ---------
+
+static ImpTwain* pImpTwainInstance = NULL;
+
+// -------------------------------------------------------------------------
+
+LRESULT CALLBACK TwainWndProc( HWND hWnd,UINT nMsg, WPARAM nPar1, LPARAM nPar2 )
+{
+ return DefWindowProc( hWnd, nMsg, nPar1, nPar2 );
+}
+
+// -------------------------------------------------------------------------
+
+LRESULT CALLBACK TwainMsgProc( int nCode, WPARAM wParam, LPARAM lParam )
+{
+ MSG* pMsg = (MSG*) lParam;
+
+ if( ( nCode < 0 ) || ( pImpTwainInstance->hTwainWnd != pMsg->hwnd ) || !pImpTwainInstance->ImplHandleMsg( (void*) lParam ) )
+ {
+ return CallNextHookEx( pImpTwainInstance->hTwainHook, nCode, wParam, lParam );
+ }
+ else
+ {
+ pMsg->message = WM_USER;
+ pMsg->lParam = 0;
+
+ return 0;
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+// #107835# hold reference to ScannerManager, to prevent premature death
+ImpTwain::ImpTwain( ScannerManager& rMgr, const Link& rNotifyLink ) :
+ mrMgr( rMgr ),
+ mxMgr( uno::Reference< scanner::XScannerManager >( static_cast< OWeakObject* >( &rMgr ), uno::UNO_QUERY) ),
+ aNotifyLink( rNotifyLink ),
+ pDSM( NULL ),
+ pMod( NULL ),
+ hTwainWnd( 0 ),
+ hTwainHook( 0 ),
+ nCurState( 1 ),
+ mbCloseFrameOnExit( false )
+{
+ // setup TWAIN window
+ pImpTwainInstance = this;
+
+ aAppIdent.Id = 0;
+ aAppIdent.Version.MajorNum = 1;
+ aAppIdent.Version.MinorNum = 0;
+ aAppIdent.Version.Language = TWLG_USA;
+ aAppIdent.Version.Country = TWCY_USA;
+ aAppIdent.ProtocolMajor = TWON_PROTOCOLMAJOR;
+ aAppIdent.ProtocolMinor = TWON_PROTOCOLMINOR;
+ aAppIdent.SupportedGroups = DG_IMAGE | DG_CONTROL;
+ strncpy( aAppIdent.Version.Info, "8.0", 32 );
+ aAppIdent.Version.Info[32] = aAppIdent.Version.Info[33] = 0;
+ strncpy( aAppIdent.Manufacturer, "Sun Microsystems", 32 );
+ aAppIdent.Manufacturer[32] = aAppIdent.Manufacturer[33] = 0;
+ strncpy( aAppIdent.ProductFamily,"Office", 32 );
+ aAppIdent.ProductFamily[32] = aAppIdent.ProductFamily[33] = 0;
+ strncpy( aAppIdent.ProductName, "Office", 32 );
+ aAppIdent.ProductName[32] = aAppIdent.ProductName[33] = 0;
+
+ WNDCLASS aWc = { 0, &TwainWndProc, 0, sizeof( WNDCLASS ), GetModuleHandle( NULL ), NULL, NULL, NULL, NULL, "TwainClass" };
+ RegisterClass( &aWc );
+
+ hTwainWnd = CreateWindowEx( WS_EX_TOPMOST, aWc.lpszClassName, "TWAIN", 0, 0, 0, 0, 0, HWND_DESKTOP, NULL, aWc.hInstance, 0 );
+ hTwainHook = SetWindowsHookEx( WH_GETMESSAGE, &TwainMsgProc, NULL, GetCurrentThreadId() );
+
+ // #107835# block destruction until ImplDestroyHdl is called
+ mxSelfRef = static_cast< ::cppu::OWeakObject* >( this );
+}
+
+// -----------------------------------------------------------------------------
+
+ImpTwain::~ImpTwain()
+{
+ // are we responsible for application shutdown?
+ if( mbCloseFrameOnExit )
+ ImplSendCloseEvent();
+}
+
+// -----------------------------------------------------------------------------
+
+void ImpTwain::Destroy()
+{
+ ImplFallback( TWAIN_EVENT_NONE );
+ Application::PostUserEvent( LINK( this, ImpTwain, ImplDestroyHdl ), NULL );
+}
+
+// -----------------------------------------------------------------------------
+
+bool ImpTwain::SelectSource()
+{
+ TW_UINT16 nRet = TWRC_FAILURE;
+
+ ImplOpenSourceManager();
+
+ if( 3 == nCurState )
+ {
+ TW_IDENTITY aIdent;
+
+ aIdent.Id = 0, aIdent.ProductName[ 0 ] = '\0';
+ aNotifyLink.Call( (void*) TWAIN_EVENT_SCANNING );
+ nRet = PFUNC( &aAppIdent, NULL, DG_CONTROL, DAT_IDENTITY, MSG_USERSELECT, &aIdent );
+ }
+
+ ImplFallback( TWAIN_EVENT_QUIT );
+
+ return( TWRC_SUCCESS == nRet );
+}
+
+// -----------------------------------------------------------------------------
+
+bool ImpTwain::InitXfer()
+{
+ bool bRet = false;
+
+ ImplOpenSourceManager();
+
+ if( 3 == nCurState )
+ {
+ ImplOpenSource();
+
+ if( 4 == nCurState )
+ bRet = ImplEnableSource();
+ }
+
+ if( !bRet )
+ ImplFallback( TWAIN_EVENT_QUIT );
+
+ return bRet;
+}
+
+// -----------------------------------------------------------------------------
+
+void ImpTwain::ImplOpenSourceManager()
+{
+ if( 1 == nCurState )
+ {
+ pMod = new ::osl::Module( ::rtl::OUString() );
+
+ if( pMod->load( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( TWAIN_LIBNAME ) ) ) )
+ {
+ nCurState = 2;
+
+ if( ( ( pDSM = (DSMENTRYPROC) pMod->getSymbol( String( RTL_CONSTASCII_USTRINGPARAM( TWAIN_FUNCNAME ) ) ) ) != NULL ) &&
+ ( PFUNC( &aAppIdent, NULL, DG_CONTROL, DAT_PARENT, MSG_OPENDSM, &hTwainWnd ) == TWRC_SUCCESS ) )
+ {
+ nCurState = 3;
+ }
+ }
+ else
+ {
+ delete pMod;
+ pMod = NULL;
+ }
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+void ImpTwain::ImplOpenSource()
+{
+ if( 3 == nCurState )
+ {
+ if( ( PFUNC( &aAppIdent, NULL, DG_CONTROL, DAT_IDENTITY, MSG_GETDEFAULT, &aSrcIdent ) == TWRC_SUCCESS ) &&
+ ( PFUNC( &aAppIdent, NULL, DG_CONTROL, DAT_IDENTITY, MSG_OPENDS, &aSrcIdent ) == TWRC_SUCCESS ) )
+ {
+ TW_CAPABILITY aCap = { CAP_XFERCOUNT, TWON_ONEVALUE, GlobalAlloc( GHND, sizeof( TW_ONEVALUE ) ) };
+ TW_ONEVALUE* pVal = (TW_ONEVALUE*) GlobalLock( aCap.hContainer );
+
+ pVal->ItemType = TWTY_INT16, pVal->Item = 1;
+ GlobalUnlock( aCap.hContainer );
+ PFUNC( &aAppIdent, &aSrcIdent, DG_CONTROL, DAT_CAPABILITY, MSG_SET, &aCap );
+ GlobalFree( aCap.hContainer );
+ nCurState = 4;
+ }
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+bool ImpTwain::ImplEnableSource()
+{
+ bool bRet = false;
+
+ if( 4 == nCurState )
+ {
+ TW_USERINTERFACE aUI = { true, true, hTwainWnd };
+
+ aNotifyLink.Call( (void*) TWAIN_EVENT_SCANNING );
+ nCurState = 5;
+
+ // #107835# register as vetoable close listener, to prevent application to die under us
+ ImplRegisterCloseListener();
+
+ if( PFUNC( &aAppIdent, &aSrcIdent, DG_CONTROL, DAT_USERINTERFACE, MSG_ENABLEDS, &aUI ) == TWRC_SUCCESS )
+ {
+ bRet = true;
+ }
+ else
+ {
+ nCurState = 4;
+
+ // #107835# deregister as vetoable close listener, dialog failed
+ ImplDeregisterCloseListener();
+ }
+ }
+
+ return bRet;
+}
+
+// -----------------------------------------------------------------------------
+
+bool ImpTwain::ImplHandleMsg( void* pMsg )
+{
+ TW_UINT16 nRet;
+ PTWAINMSG pMess = (PTWAINMSG) pMsg;
+ TW_EVENT aEvt = { pMess, MSG_NULL };
+
+ nRet = PFUNC( &aAppIdent, &aSrcIdent, DG_CONTROL, DAT_EVENT, MSG_PROCESSEVENT, &aEvt );
+
+ if( aEvt.TWMessage != MSG_NULL )
+ {
+ switch( aEvt.TWMessage )
+ {
+ case MSG_XFERREADY:
+ {
+ ULONG nEvent = TWAIN_EVENT_QUIT;
+
+ if( 5 == nCurState )
+ {
+ nCurState = 6;
+ ImplXfer();
+
+ if( mrMgr.GetData() )
+ nEvent = TWAIN_EVENT_XFER;
+ }
+
+ ImplFallback( nEvent );
+ }
+ break;
+
+ case MSG_CLOSEDSREQ:
+ ImplFallback( TWAIN_EVENT_QUIT );
+ break;
+
+ default:
+ break;
+ }
+ }
+ else
+ nRet = TWRC_NOTDSEVENT;
+
+ return( TWRC_DSEVENT == nRet );
+}
+
+// -----------------------------------------------------------------------------
+
+void ImpTwain::ImplXfer()
+{
+ if( nCurState == 6 )
+ {
+ TW_IMAGEINFO aInfo;
+ TW_UINT32 hDIB = 0;
+ long nWidth, nHeight, nXRes, nYRes;
+
+ if( PFUNC( &aAppIdent, &aSrcIdent, DG_IMAGE, DAT_IMAGEINFO, MSG_GET, &aInfo ) == TWRC_SUCCESS )
+ {
+ nWidth = aInfo.ImageWidth;
+ nHeight = aInfo.ImageLength;
+ nXRes = FIXTOLONG( aInfo.XResolution );
+ nYRes = FIXTOLONG( aInfo.YResolution );
+ }
+ else
+ nWidth = nHeight = nXRes = nYRes = -1L;
+
+ switch( PFUNC( &aAppIdent, &aSrcIdent, DG_IMAGE, DAT_IMAGENATIVEXFER, MSG_GET, &hDIB ) )
+ {
+ case( TWRC_CANCEL ):
+ nCurState = 7;
+ break;
+
+ case( TWRC_XFERDONE ):
+ {
+ if( hDIB )
+ {
+ if( ( nXRes != -1 ) && ( nYRes != - 1 ) && ( nWidth != - 1 ) && ( nHeight != - 1 ) )
+ {
+ // set resolution of bitmap
+ BITMAPINFOHEADER* pBIH = (BITMAPINFOHEADER*) GlobalLock( (HGLOBAL) hDIB );
+ static const double fFactor = 100.0 / 2.54;
+
+ pBIH->biXPelsPerMeter = FRound( fFactor * nXRes );
+ pBIH->biYPelsPerMeter = FRound( fFactor * nYRes );
+
+ GlobalUnlock( (HGLOBAL) hDIB );
+ }
+
+ mrMgr.SetData( (void*)(long) hDIB );
+ }
+ else
+ GlobalFree( (HGLOBAL) hDIB );
+
+ nCurState = 7;
+ }
+ break;
+
+ default:
+ break;
+ }
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+void ImpTwain::ImplFallback( ULONG nEvent )
+{
+ Application::PostUserEvent( LINK( this, ImpTwain, ImplFallbackHdl ), (void*) nEvent );
+}
+
+// -----------------------------------------------------------------------------
+
+IMPL_LINK( ImpTwain, ImplFallbackHdl, void*, pData )
+{
+ const ULONG nEvent = (ULONG) pData;
+ bool bFallback = true;
+
+ switch( nCurState )
+ {
+ case( 7 ):
+ case( 6 ):
+ {
+ TW_PENDINGXFERS aXfers;
+
+ if( PFUNC( &aAppIdent, &aSrcIdent, DG_CONTROL, DAT_PENDINGXFERS, MSG_ENDXFER, &aXfers ) == TWRC_SUCCESS )
+ {
+ if( aXfers.Count != 0 )
+ PFUNC( &aAppIdent, &aSrcIdent, DG_CONTROL, DAT_PENDINGXFERS, MSG_RESET, &aXfers );
+ }
+
+ nCurState = 5;
+ }
+ break;
+
+ case( 5 ):
+ {
+ TW_USERINTERFACE aUI = { true, true, hTwainWnd };
+
+ PFUNC( &aAppIdent, &aSrcIdent, DG_CONTROL, DAT_USERINTERFACE, MSG_DISABLEDS, &aUI );
+ nCurState = 4;
+
+ // #107835# deregister as vetoable close listener
+ ImplDeregisterCloseListener();
+ }
+ break;
+
+ case( 4 ):
+ {
+ PFUNC( &aAppIdent, NULL, DG_CONTROL, DAT_IDENTITY, MSG_CLOSEDS, &aSrcIdent );
+ nCurState = 3;
+ }
+ break;
+
+ case( 3 ):
+ {
+ PFUNC( &aAppIdent, NULL, DG_CONTROL, DAT_PARENT, MSG_CLOSEDSM, &hTwainWnd );
+ nCurState = 2;
+ }
+ break;
+
+ case( 2 ):
+ {
+ delete pMod;
+ pMod = NULL;
+ nCurState = 1;
+ }
+ break;
+
+ default:
+ {
+ if( nEvent != TWAIN_EVENT_NONE )
+ aNotifyLink.Call( (void*) nEvent );
+
+ bFallback = false;
+ }
+ break;
+ }
+
+ if( bFallback )
+ ImplFallback( nEvent );
+
+ return 0L;
+}
+
+// -----------------------------------------------------------------------------
+
+IMPL_LINK( ImpTwain, ImplDestroyHdl, void*, /*p*/ )
+{
+ if( hTwainWnd )
+ DestroyWindow( hTwainWnd );
+
+ if( hTwainHook )
+ UnhookWindowsHookEx( hTwainHook );
+
+ // #107835# permit destruction of ourselves (normally, refcount
+ // should drop to zero exactly here)
+ mxSelfRef = NULL;
+ pImpTwainInstance = NULL;
+
+ return 0L;
+}
+
+// -----------------------------------------------------------------------------
+
+uno::Reference< frame::XFrame > ImpTwain::ImplGetActiveFrame()
+{
+ try
+ {
+ uno::Reference< lang::XMultiServiceFactory > xMgr( ::comphelper::getProcessServiceFactory() );
+
+ if( xMgr.is() )
+ {
+ // query desktop instance
+ uno::Reference< frame::XDesktop > xDesktop( xMgr->createInstance(
+ OUString::createFromAscii( "com.sun.star.frame.Desktop" ) ), uno::UNO_QUERY );
+
+ if( xDesktop.is() )
+ {
+ // query property set from desktop, which contains the currently active frame
+ uno::Reference< beans::XPropertySet > xDesktopProps( xDesktop, uno::UNO_QUERY );
+
+ if( xDesktopProps.is() )
+ {
+ uno::Any aActiveFrame;
+
+ try
+ {
+ aActiveFrame = xDesktopProps->getPropertyValue(
+ OUString::createFromAscii( "ActiveFrame" ) );
+ }
+ catch( const beans::UnknownPropertyException& )
+ {
+ // property unknown.
+ DBG_ERROR("ImpTwain::ImplGetActiveFrame: ActiveFrame property unknown, cannot determine active frame!");
+ return uno::Reference< frame::XFrame >();
+ }
+
+ uno::Reference< frame::XFrame > xActiveFrame;
+
+ if( (aActiveFrame >>= xActiveFrame) &&
+ xActiveFrame.is() )
+ {
+ return xActiveFrame;
+ }
+ }
+ }
+ }
+ }
+ catch( const uno::Exception& )
+ {
+ }
+
+ DBG_ERROR("ImpTwain::ImplGetActiveFrame: Could not determine active frame!");
+ return uno::Reference< frame::XFrame >();
+}
+
+// -----------------------------------------------------------------------------
+
+uno::Reference< util::XCloseBroadcaster > ImpTwain::ImplGetActiveFrameCloseBroadcaster()
+{
+ try
+ {
+ return uno::Reference< util::XCloseBroadcaster >( ImplGetActiveFrame(), uno::UNO_QUERY );
+ }
+ catch( const uno::Exception& )
+ {
+ }
+
+ DBG_ERROR("ImpTwain::ImplGetActiveFrameCloseBroadcaster: Could determine close broadcaster on active frame!");
+ return uno::Reference< util::XCloseBroadcaster >();
+}
+
+// -----------------------------------------------------------------------------
+
+void ImpTwain::ImplRegisterCloseListener()
+{
+ try
+ {
+ uno::Reference< util::XCloseBroadcaster > xCloseBroadcaster( ImplGetActiveFrameCloseBroadcaster() );
+
+ if( xCloseBroadcaster.is() )
+ {
+ xCloseBroadcaster->addCloseListener(this);
+ return; // successfully registered as a close listener
+ }
+ else
+ {
+ // interface unknown. don't register, then
+ DBG_ERROR("ImpTwain::ImplRegisterCloseListener: XFrame has no XCloseBroadcaster!");
+ return;
+ }
+ }
+ catch( const uno::Exception& )
+ {
+ }
+
+ DBG_ERROR("ImpTwain::ImplRegisterCloseListener: Could not register as close listener!");
+}
+
+// -----------------------------------------------------------------------------
+
+void ImpTwain::ImplDeregisterCloseListener()
+{
+ try
+ {
+ uno::Reference< util::XCloseBroadcaster > xCloseBroadcaster(
+ ImplGetActiveFrameCloseBroadcaster() );
+
+ if( xCloseBroadcaster.is() )
+ {
+ xCloseBroadcaster->removeCloseListener(this);
+ return; // successfully deregistered as a close listener
+ }
+ else
+ {
+ // interface unknown. don't deregister, then
+ DBG_ERROR("ImpTwain::ImplDeregisterCloseListener: XFrame has no XCloseBroadcaster!");
+ return;
+ }
+ }
+ catch( const uno::Exception& )
+ {
+ }
+
+ DBG_ERROR("ImpTwain::ImplDeregisterCloseListener: Could not deregister as close listener!");
+}
+
+// -----------------------------------------------------------------------------
+
+void SAL_CALL ImpTwain::queryClosing( const lang::EventObject& /*Source*/, sal_Bool GetsOwnership ) throw (util::CloseVetoException, uno::RuntimeException)
+{
+ // shall we re-send the close query later on?
+ mbCloseFrameOnExit = GetsOwnership;
+
+ // the sole purpose of this listener is to forbid closing of the listened-at frame
+ throw util::CloseVetoException();
+}
+
+// -----------------------------------------------------------------------------
+
+void SAL_CALL ImpTwain::notifyClosing( const lang::EventObject& /*Source*/ ) throw (uno::RuntimeException)
+{
+ // should not happen
+ DBG_ERROR("ImpTwain::notifyClosing called, but we vetoed the closing before!");
+}
+
+// -----------------------------------------------------------------------------
+
+void SAL_CALL ImpTwain::disposing( const lang::EventObject& /*Source*/ ) throw (uno::RuntimeException)
+{
+ // we're not holding any references to the frame, thus noop
+}
+
+// -----------------------------------------------------------------------------
+
+void ImpTwain::ImplSendCloseEvent()
+{
+ try
+ {
+ uno::Reference< util::XCloseable > xCloseable( ImplGetActiveFrame(), uno::UNO_QUERY );
+
+ if( xCloseable.is() )
+ xCloseable->close( true );
+ }
+ catch( const uno::Exception& )
+ {
+ }
+
+ DBG_ERROR("ImpTwain::ImplSendCloseEvent: Could not send required close broadcast!");
+}
+
+
+// ---------
+// - Twain -
+// ---------
+
+class Twain
+{
+ uno::Reference< lang::XEventListener > mxListener;
+ uno::Reference< scanner::XScannerManager > mxMgr;
+ const ScannerManager* mpCurMgr;
+ ImpTwain* mpImpTwain;
+ TwainState meState;
+
+ DECL_LINK( ImpNotifyHdl, ImpTwain* );
+
+public:
+
+ Twain();
+ ~Twain();
+
+ bool SelectSource( ScannerManager& rMgr );
+ bool PerformTransfer( ScannerManager& rMgr, const uno::Reference< lang::XEventListener >& rxListener );
+
+ TwainState GetState() const { return meState; }
+};
+
+// ------------------------------------------------------------------------
+
+Twain::Twain() :
+ mpCurMgr( NULL ),
+ mpImpTwain( NULL ),
+ meState( TWAIN_STATE_NONE )
+{
+}
+
+// ------------------------------------------------------------------------
+
+Twain::~Twain()
+{
+ if( mpImpTwain )
+ mpImpTwain->Destroy();
+}
+
+// ------------------------------------------------------------------------
+
+bool Twain::SelectSource( ScannerManager& rMgr )
+{
+ bool bRet;
+
+ if( !mpImpTwain )
+ {
+ // #107835# hold reference to ScannerManager, to prevent premature death
+ mxMgr = uno::Reference< scanner::XScannerManager >( static_cast< OWeakObject* >( const_cast< ScannerManager* >( mpCurMgr = &rMgr ) ),
+ uno::UNO_QUERY ),
+
+ meState = TWAIN_STATE_NONE;
+ mpImpTwain = new ImpTwain( rMgr, LINK( this, Twain, ImpNotifyHdl ) );
+ bRet = mpImpTwain->SelectSource();
+ }
+ else
+ bRet = false;
+
+ return bRet;
+}
+
+// ------------------------------------------------------------------------
+
+bool Twain::PerformTransfer( ScannerManager& rMgr, const uno::Reference< lang::XEventListener >& rxListener )
+{
+ bool bRet;
+
+ if( !mpImpTwain )
+ {
+ // #107835# hold reference to ScannerManager, to prevent premature death
+ mxMgr = uno::Reference< scanner::XScannerManager >( static_cast< OWeakObject* >( const_cast< ScannerManager* >( mpCurMgr = &rMgr ) ),
+ uno::UNO_QUERY ),
+
+ mxListener = rxListener;
+ meState = TWAIN_STATE_NONE;
+ mpImpTwain = new ImpTwain( rMgr, LINK( this, Twain, ImpNotifyHdl ) );
+ bRet = mpImpTwain->InitXfer();
+ }
+ else
+ bRet = false;
+
+ return bRet;
+}
+
+// ------------------------------------------------------------------------
+
+IMPL_LINK( Twain, ImpNotifyHdl, ImpTwain*, nEvent )
+{
+ switch( (ULONG)(void*) nEvent )
+ {
+ case( TWAIN_EVENT_SCANNING ):
+ meState = TWAIN_STATE_SCANNING;
+ break;
+
+ case( TWAIN_EVENT_QUIT ):
+ {
+ if( meState != TWAIN_STATE_DONE )
+ meState = TWAIN_STATE_CANCELED;
+
+ if( mpImpTwain )
+ {
+ mpImpTwain->Destroy();
+ mpImpTwain = NULL;
+ mpCurMgr = NULL;
+ }
+
+ if( mxListener.is() )
+ mxListener->disposing( lang::EventObject( mxMgr ) );
+
+ mxListener = NULL;
+ }
+ break;
+
+ case( TWAIN_EVENT_XFER ):
+ {
+ if( mpImpTwain )
+ {
+ meState = ( mpCurMgr->GetData() ? TWAIN_STATE_DONE : TWAIN_STATE_CANCELED );
+
+ mpImpTwain->Destroy();
+ mpImpTwain = NULL;
+ mpCurMgr = NULL;
+
+ if( mxListener.is() )
+ mxListener->disposing( lang::EventObject( mxMgr ) );
+ }
+
+ mxListener = NULL;
+ }
+ break;
+
+ default:
+ break;
+ }
+
+ return 0L;
+}
+
+// -----------
+// - statics -
+// -----------
+
+static Twain aTwain;
+
+// ------------------
+// - ScannerManager -
+// ------------------
+
+void ScannerManager::AcquireData()
+{
+}
+
+void ScannerManager::ReleaseData()
+{
+ if( mpData )
+ {
+ GlobalFree( (HGLOBAL)(long) mpData );
+ mpData = NULL;
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+AWT::Size ScannerManager::getSize() throw()
+{
+ AWT::Size aRet;
+ HGLOBAL hDIB = (HGLOBAL)(long) mpData;
+
+ if( hDIB )
+ {
+ BITMAPINFOHEADER* pBIH = (BITMAPINFOHEADER*) GlobalLock( hDIB );
+
+ if( pBIH )
+ {
+ aRet.Width = pBIH->biWidth;
+ aRet.Height = pBIH->biHeight;
+ }
+ else
+ aRet.Width = aRet.Height = 0;
+
+ GlobalUnlock( hDIB );
+ }
+ else
+ aRet.Width = aRet.Height = 0;
+
+ return aRet;
+}
+
+// -----------------------------------------------------------------------------
+
+SEQ( sal_Int8 ) ScannerManager::getDIB() throw()
+{
+ SEQ( sal_Int8 ) aRet;
+
+ if( mpData )
+ {
+ HGLOBAL hDIB = (HGLOBAL)(long) mpData;
+ const sal_uInt32 nDIBSize = GlobalSize( hDIB );
+ BITMAPINFOHEADER* pBIH = (BITMAPINFOHEADER*) GlobalLock( hDIB );
+
+ if( pBIH )
+ {
+ sal_uInt32 nColEntries;
+
+ switch( pBIH->biBitCount )
+ {
+ case( 1 ):
+ case( 4 ):
+ case( 8 ):
+ nColEntries = pBIH->biClrUsed ? pBIH->biClrUsed : ( 1 << pBIH->biBitCount );
+ break;
+
+ case( 24 ):
+ nColEntries = pBIH->biClrUsed ? pBIH->biClrUsed : 0;
+ break;
+
+ case( 16 ):
+ case( 32 ):
+ {
+ nColEntries = pBIH->biClrUsed;
+
+ if( pBIH->biCompression == BI_BITFIELDS )
+ nColEntries += 3;
+ }
+ break;
+
+ default:
+ nColEntries = 0;
+ break;
+ }
+
+ aRet = SEQ( sal_Int8 )( sizeof( BITMAPFILEHEADER ) + nDIBSize );
+
+ sal_Int8* pBuf = aRet.getArray();
+ SvMemoryStream* pMemStm = new SvMemoryStream( (char*) pBuf, sizeof( BITMAPFILEHEADER ), STREAM_WRITE );
+
+ *pMemStm << 'B' << 'M' << (sal_uInt32) 0 << (sal_uInt32) 0;
+ *pMemStm << (sal_uInt32) ( sizeof( BITMAPFILEHEADER ) + pBIH->biSize + ( nColEntries * sizeof( RGBQUAD ) ) );
+
+ delete pMemStm;
+ memcpy( pBuf + sizeof( BITMAPFILEHEADER ), pBIH, nDIBSize );
+ }
+
+ GlobalUnlock( hDIB );
+ ReleaseData();
+ }
+
+ return aRet;
+}
+
+// -----------------------------------------------------------------------------
+
+SEQ( ScannerContext ) SAL_CALL ScannerManager::getAvailableScanners() throw()
+{
+ osl::MutexGuard aGuard( maProtector );
+ SEQ( ScannerContext ) aRet( 1 );
+
+ aRet.getArray()[0].ScannerName = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "TWAIN" ) );
+ aRet.getArray()[0].InternalData = 0;
+
+ return aRet;
+}
+
+// -----------------------------------------------------------------------------
+
+BOOL SAL_CALL ScannerManager::configureScanner( ScannerContext& rContext )
+ throw( ScannerException )
+{
+ osl::MutexGuard aGuard( maProtector );
+ uno::Reference< XScannerManager > xThis( this );
+
+ if( rContext.InternalData != 0 || rContext.ScannerName != ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "TWAIN" ) ) )
+ throw ScannerException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Scanner does not exist" ) ), xThis, ScanError_InvalidContext );
+
+ ReleaseData();
+
+ return aTwain.SelectSource( *this );
+}
+
+// -----------------------------------------------------------------------------
+
+void SAL_CALL ScannerManager::startScan( const ScannerContext& rContext, const uno::Reference< lang::XEventListener >& rxListener )
+ throw( ScannerException )
+{
+ osl::MutexGuard aGuard( maProtector );
+ uno::Reference< XScannerManager > xThis( this );
+
+ if( rContext.InternalData != 0 || rContext.ScannerName != ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "TWAIN" ) ) )
+ throw ScannerException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Scanner does not exist" ) ), xThis, ScanError_InvalidContext );
+
+ ReleaseData();
+ aTwain.PerformTransfer( *this, rxListener );
+}
+
+// -----------------------------------------------------------------------------
+
+ScanError SAL_CALL ScannerManager::getError( const ScannerContext& rContext )
+ throw( ScannerException )
+{
+ osl::MutexGuard aGuard( maProtector );
+ uno::Reference< XScannerManager > xThis( this );
+
+ if( rContext.InternalData != 0 || rContext.ScannerName != ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "TWAIN" ) ) )
+ throw ScannerException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Scanner does not exist" ) ), xThis, ScanError_InvalidContext );
+
+ return( ( aTwain.GetState() == TWAIN_STATE_CANCELED ) ? ScanError_ScanCanceled : ScanError_ScanErrorNone );
+}
+
+// -----------------------------------------------------------------------------
+
+uno::Reference< awt::XBitmap > SAL_CALL ScannerManager::getBitmap( const ScannerContext& /*rContext*/ )
+ throw( ScannerException )
+{
+ osl::MutexGuard aGuard( maProtector );
+ return uno::Reference< awt::XBitmap >( this );
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/scanner/scnserv.cxx b/extensions/source/scanner/scnserv.cxx
new file mode 100644
index 000000000000..f77acc084a4e
--- /dev/null
+++ b/extensions/source/scanner/scnserv.cxx
@@ -0,0 +1,107 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+#include <osl/diagnose.h>
+#include <cppuhelper/factory.hxx>
+#include <uno/mapping.hxx>
+#include "scanner.hxx"
+
+#include <com/sun/star/registry/XRegistryKey.hpp>
+
+using namespace com::sun::star::registry;
+
+// ------------------------------------------
+// - component_getImplementationEnvironment -
+// ------------------------------------------
+
+extern "C" void SAL_CALL component_getImplementationEnvironment( const sal_Char** ppEnvTypeName, uno_Environment** /*ppEnv*/ )
+{
+ *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
+}
+
+// -----------------------
+// - component_writeInfo -
+// -----------------------
+
+extern "C" sal_Bool SAL_CALL component_writeInfo( void* /*pServiceManager*/, void* pRegistryKey )
+{
+ sal_Bool bRet = sal_False;
+
+ if( pRegistryKey )
+ {
+ try
+ {
+ ::rtl::OUString aImplName( '/' );
+
+ aImplName += ScannerManager::getImplementationName_Static();
+ aImplName += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "/UNO/SERVICES/" ) );
+ aImplName += ScannerManager::getImplementationName_Static();
+
+ REF( XRegistryKey ) xNewKey1( static_cast< XRegistryKey* >( pRegistryKey )->createKey( aImplName ) );
+
+ bRet = sal_True;
+ }
+ catch( InvalidRegistryException& )
+ {
+ OSL_ENSURE( sal_False, "### InvalidRegistryException!" );
+ }
+ }
+
+ return bRet;
+}
+
+// ------------------------
+// - component_getFactory -
+// ------------------------
+
+extern "C" void* SAL_CALL component_getFactory( const sal_Char* pImplName, void* pServiceManager, void* /*pRegistryKey*/ )
+{
+ REF( ::com::sun::star::lang::XSingleServiceFactory ) xFactory;
+ void* pRet = 0;
+
+ if( ::rtl::OUString::createFromAscii( pImplName ) == ScannerManager::getImplementationName_Static() )
+ {
+ xFactory = REF( ::com::sun::star::lang::XSingleServiceFactory )( ::cppu::createSingleFactory(
+ static_cast< ::com::sun::star::lang::XMultiServiceFactory* >( pServiceManager ),
+ ScannerManager::getImplementationName_Static(),
+ ScannerManager_CreateInstance,
+ ScannerManager::getSupportedServiceNames_Static() ) );
+ }
+
+ if( xFactory.is() )
+ {
+ xFactory->acquire();
+ pRet = xFactory.get();
+ }
+
+ return pRet;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/scanner/twain.cxx b/extensions/source/scanner/twain.cxx
new file mode 100644
index 000000000000..d2a6684f3a86
--- /dev/null
+++ b/extensions/source/scanner/twain.cxx
@@ -0,0 +1,535 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+
+#include <string.h>
+#include <math.h>
+
+#if defined( WNT ) || defined (WIN)
+#include <tools/svwin.h>
+#endif
+#ifdef OS2
+#include <svpm.h>
+#endif // OS2
+#include <osl/module.hxx>
+#include <tools/stream.hxx>
+#include <vcl/svapp.hxx>
+#include <vcl/wrkwin.hxx>
+#include <vcl/sysdata.hxx>
+#include "twain.hxx"
+
+// -----------
+// - Defines -
+// -----------
+
+#define PFUNC (*pDSM)
+#define FIXTODOUBLE( nFix ) ((double)nFix.Whole+(double)nFix.Frac/65536.)
+#define FIXTOLONG( nFix ) ((long)floor(FIXTODOUBLE(nFix)+0.5))
+
+#if defined WIN
+#define TWAIN_LIBNAME "TWAIN.DLL"
+#define TWAIN_FUNCNAME "DSM_Entry"
+#elif defined WNT
+#define TWAIN_LIBNAME "TWAIN_32.DLL"
+#define TWAIN_FUNCNAME "DSM_Entry"
+#elif defined OS2
+#define TWAIN_LIBNAME "twain"
+#define TWAIN_FUNCNAME "DSM_ENTRY"
+#endif
+
+// -----------
+// - Statics -
+// -----------
+
+static ImpTwain* pImpTwainInstance = NULL;
+
+// ---------
+// - Procs -
+// ---------
+
+#ifdef OS2
+
+ #define PTWAINMSG QMSG*
+
+ MRESULT EXPENTRY TwainWndProc( HWND hWnd, ULONG nMsg, MPARAM nParam1, MPARAM nParam2 )
+ {
+ return (MRESULT) TRUE;
+ }
+
+
+#else // OS2
+
+ #define PTWAINMSG MSG*
+
+ // -------------------------------------------------------------------------
+
+ LRESULT CALLBACK TwainWndProc( HWND hWnd,UINT nMsg, WPARAM nPar1, LPARAM nPar2 )
+ {
+ return DefWindowProc( hWnd, nMsg, nPar1, nPar2 );
+ }
+
+ // -------------------------------------------------------------------------
+
+ LRESULT CALLBACK TwainMsgProc( int nCode, WPARAM wParam, LPARAM lParam )
+ {
+ MSG* pMsg = (MSG*) lParam;
+
+ if( ( nCode < 0 ) ||
+ ( pImpTwainInstance->hTwainWnd != pMsg->hwnd ) ||
+ !pImpTwainInstance->ImplHandleMsg( (void*) lParam ) )
+ {
+ return CallNextHookEx( pImpTwainInstance->hTwainHook, nCode, wParam, lParam );
+ }
+ else
+ {
+ pMsg->message = WM_USER;
+ pMsg->lParam = 0;
+
+ return 0;
+ }
+ }
+
+#endif // OS2
+
+// ------------
+// - ImpTwain -
+// ------------
+
+ImpTwain::ImpTwain( const Link& rNotifyLink ) :
+ aNotifyLink ( rNotifyLink ),
+ pDSM ( NULL ),
+ pMod ( NULL ),
+ hTwainWnd ( 0 ),
+ hTwainHook ( 0 ),
+ nCurState ( 1 )
+{
+ pImpTwainInstance = this;
+
+ aAppIdent.Id = 0;
+ aAppIdent.Version.MajorNum = 1;
+ aAppIdent.Version.MinorNum = 0;
+ aAppIdent.Version.Language = TWLG_USA;
+ aAppIdent.Version.Country = TWCY_USA;
+ aAppIdent.ProtocolMajor = TWON_PROTOCOLMAJOR;
+ aAppIdent.ProtocolMinor = TWON_PROTOCOLMINOR;
+ aAppIdent.SupportedGroups = DG_IMAGE | DG_CONTROL;
+ strcpy( aAppIdent.Version.Info, "6.0" );
+ strcpy( aAppIdent.Manufacturer, "Sun Microsystems");
+ strcpy( aAppIdent.ProductFamily,"Office");
+ strcpy( aAppIdent.ProductName, "Office");
+
+#ifdef OS2
+
+ hAB = Sysdepen::GethAB();
+ ImplFallback( TWAIN_EVENT_QUIT );
+ // hTwainWnd = WinCreateWindow( HWND_DESKTOP, WC_FRAME, "dummy", 0, 0, 0, 0, 0, HWND_DESKTOP, HWND_BOTTOM, 0, 0, 0 );
+
+#else
+
+ HWND hParentWnd = HWND_DESKTOP;
+ WNDCLASS aWc = { 0, &TwainWndProc, 0, sizeof( WNDCLASS ), GetModuleHandle( NULL ),
+ NULL, NULL, NULL, NULL, "TwainClass" };
+
+ RegisterClass( &aWc );
+ hTwainWnd = CreateWindowEx( WS_EX_TOPMOST, aWc.lpszClassName, "TWAIN", 0, 0, 0, 0, 0, hParentWnd, NULL, aWc.hInstance, 0 );
+ hTwainHook = SetWindowsHookEx( WH_GETMESSAGE, &TwainMsgProc, NULL, GetCurrentThreadId() );
+
+#endif
+}
+
+// -----------------------------------------------------------------------------
+
+ImpTwain::~ImpTwain()
+{
+}
+
+// -----------------------------------------------------------------------------
+
+void ImpTwain::Destroy()
+{
+ ImplFallback( TWAIN_EVENT_NONE );
+ Application::PostUserEvent( LINK( this, ImpTwain, ImplDestroyHdl ), NULL );
+}
+
+// -----------------------------------------------------------------------------
+
+BOOL ImpTwain::SelectSource()
+{
+ TW_UINT16 nRet = TWRC_FAILURE;
+
+ if( !!aBitmap )
+ aBitmap = Bitmap();
+
+ ImplOpenSourceManager();
+
+ if( 3 == nCurState )
+ {
+ TW_IDENTITY aIdent;
+
+ aIdent.Id = 0, aIdent.ProductName[ 0 ] = '\0';
+ aNotifyLink.Call( (void*) TWAIN_EVENT_SCANNING );
+ nRet = PFUNC( &aAppIdent, NULL, DG_CONTROL, DAT_IDENTITY, MSG_USERSELECT, &aIdent );
+ }
+
+ ImplFallback( TWAIN_EVENT_QUIT );
+
+ return( nRet == TWRC_SUCCESS || nRet == TWRC_CANCEL );
+}
+
+// -----------------------------------------------------------------------------
+
+BOOL ImpTwain::InitXfer()
+{
+ BOOL bRet = FALSE;
+
+ if( !!aBitmap )
+ aBitmap = Bitmap();
+
+ ImplOpenSourceManager();
+
+ if( 3 == nCurState )
+ {
+ ImplOpenSource();
+
+ if( 4 == nCurState )
+ bRet = ImplEnableSource();
+ }
+
+ if( !bRet )
+ ImplFallback( TWAIN_EVENT_QUIT );
+
+ return bRet;
+}
+
+// -----------------------------------------------------------------------------
+
+Bitmap ImpTwain::GetXferBitmap()
+{
+ Bitmap aRet( aBitmap );
+ aBitmap = Bitmap();
+ return aRet;
+}
+
+// -----------------------------------------------------------------------------
+
+void ImpTwain::ImplOpenSourceManager()
+{
+ if( 1 == nCurState )
+ {
+ pMod = new osl::Module();
+
+ if( pMod->load( TWAIN_LIBNAME ) )
+ {
+ nCurState = 2;
+
+ if( ( ( pDSM = (DSMENTRYPROC) pMod->getSymbol( TWAIN_FUNCNAME ) ) != NULL ) &&
+ ( PFUNC( &aAppIdent, NULL, DG_CONTROL, DAT_PARENT, MSG_OPENDSM, &hTwainWnd ) == TWRC_SUCCESS ) )
+ {
+ nCurState = 3;
+ }
+ }
+ else
+ {
+ delete pMod;
+ pMod = NULL;
+ }
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+void ImpTwain::ImplOpenSource()
+{
+ if( 3 == nCurState )
+ {
+ if( ( PFUNC( &aAppIdent, NULL, DG_CONTROL, DAT_IDENTITY, MSG_GETDEFAULT, &aSrcIdent ) == TWRC_SUCCESS ) &&
+ ( PFUNC( &aAppIdent, NULL, DG_CONTROL, DAT_IDENTITY, MSG_OPENDS, &aSrcIdent ) == TWRC_SUCCESS ) )
+ {
+#ifdef OS2
+
+ // negotiate capabilities
+
+#else
+
+ TW_CAPABILITY aCap = { CAP_XFERCOUNT, TWON_ONEVALUE, GlobalAlloc( GHND, sizeof( TW_ONEVALUE ) ) };
+ TW_ONEVALUE* pVal = (TW_ONEVALUE*) GlobalLock( aCap.hContainer );
+
+ pVal->ItemType = TWTY_INT16, pVal->Item = 1;
+ GlobalUnlock( aCap.hContainer );
+ PFUNC( &aAppIdent, &aSrcIdent, DG_CONTROL, DAT_CAPABILITY, MSG_SET, &aCap );
+ GlobalFree( aCap.hContainer );
+#endif
+
+ nCurState = 4;
+ }
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+BOOL ImpTwain::ImplEnableSource()
+{
+ BOOL bRet = FALSE;
+
+ if( 4 == nCurState )
+ {
+ TW_USERINTERFACE aUI = { TRUE, TRUE, hTwainWnd };
+
+ aNotifyLink.Call( (void*) TWAIN_EVENT_SCANNING );
+ nCurState = 5;
+
+ if( PFUNC( &aAppIdent, &aSrcIdent, DG_CONTROL, DAT_USERINTERFACE, MSG_ENABLEDS, &aUI ) == TWRC_SUCCESS )
+ bRet = TRUE;
+ else
+ nCurState = 4;
+ }
+
+ return bRet;
+}
+
+// -----------------------------------------------------------------------------
+
+BOOL ImpTwain::ImplHandleMsg( void* pMsg )
+{
+ TW_UINT16 nRet;
+ PTWAINMSG pMess = (PTWAINMSG) pMsg;
+ TW_EVENT aEvt = { pMess, MSG_NULL };
+
+ nRet = PFUNC( &aAppIdent, &aSrcIdent, DG_CONTROL, DAT_EVENT, MSG_PROCESSEVENT, &aEvt );
+
+ if( aEvt.TWMessage != MSG_NULL )
+ {
+ switch( aEvt.TWMessage )
+ {
+ case MSG_XFERREADY:
+ {
+ ULONG nEvent = TWAIN_EVENT_QUIT;
+
+ if( 5 == nCurState )
+ {
+ nCurState = 6;
+ ImplXfer();
+
+ if( !!aBitmap )
+ nEvent = TWAIN_EVENT_XFER;
+ }
+
+ ImplFallback( nEvent );
+ }
+ break;
+
+ case MSG_CLOSEDSREQ:
+ ImplFallback( TWAIN_EVENT_QUIT );
+ break;
+
+ default:
+ break;
+ }
+ }
+ else
+ nRet = TWRC_NOTDSEVENT;
+
+ return( TWRC_DSEVENT == nRet );
+}
+
+// -----------------------------------------------------------------------------
+
+void ImpTwain::ImplXfer()
+{
+ if( nCurState == 6 )
+ {
+ TW_IMAGEINFO aInfo;
+ TW_UINT32 hDIB = 0;
+ long nWidth = aInfo.ImageWidth;
+ long nHeight = aInfo.ImageLength;
+ long nXRes = FIXTOLONG( aInfo.XResolution );
+ long nYRes = FIXTOLONG( aInfo.YResolution );
+
+ if( PFUNC( &aAppIdent, &aSrcIdent, DG_IMAGE, DAT_IMAGEINFO, MSG_GET, &aInfo ) == TWRC_SUCCESS )
+ {
+ nWidth = aInfo.ImageWidth;
+ nHeight = aInfo.ImageLength;
+ nXRes = FIXTOLONG( aInfo.XResolution );
+ nYRes = FIXTOLONG( aInfo.YResolution );
+ }
+ else
+ nWidth = nHeight = nXRes = nYRes = -1L;
+
+ switch( PFUNC( &aAppIdent, &aSrcIdent, DG_IMAGE, DAT_IMAGENATIVEXFER, MSG_GET, &hDIB ) )
+ {
+ case( TWRC_CANCEL ):
+ nCurState = 7;
+ break;
+
+ case( TWRC_XFERDONE ):
+ {
+#ifdef OS2
+
+ // get OS/2-Bitmap
+
+#else // OS2
+ const ULONG nSize = GlobalSize( (HGLOBAL) hDIB );
+ char* pBuf = (char*) GlobalLock( (HGLOBAL) hDIB );
+
+ if( pBuf )
+ {
+ SvMemoryStream aMemStm;
+ aMemStm.SetBuffer( pBuf, nSize, FALSE, nSize );
+ aBitmap.Read( aMemStm, FALSE );
+ GlobalUnlock( (HGLOBAL) hDIB );
+ }
+
+ GlobalFree( (HGLOBAL) hDIB );
+#endif // OS2
+
+ // set resolution of bitmap if neccessary
+ if ( ( nXRes != -1 ) && ( nYRes != - 1 ) && ( nWidth != - 1 ) && ( nHeight != - 1 ) )
+ {
+ const MapMode aMapMode( MAP_100TH_INCH, Point(), Fraction( 100, nXRes ), Fraction( 100, nYRes ) );
+ aBitmap.SetPrefMapMode( aMapMode );
+ aBitmap.SetPrefSize( Size( nWidth, nHeight ) );
+ }
+
+ nCurState = 7;
+ }
+ break;
+
+ default:
+ break;
+ }
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+void ImpTwain::ImplFallback( ULONG nEvent )
+{
+ Application::PostUserEvent( LINK( this, ImpTwain, ImplFallbackHdl ), (void*) nEvent );
+}
+
+// -----------------------------------------------------------------------------
+
+IMPL_LINK( ImpTwain, ImplFallbackHdl, void*, pData )
+{
+ const ULONG nEvent = (ULONG) pData;
+ BOOL bFallback = TRUE;
+
+ switch( nCurState )
+ {
+ case( 7 ):
+ case( 6 ):
+ {
+ TW_PENDINGXFERS aXfers;
+
+ if( PFUNC( &aAppIdent, &aSrcIdent, DG_CONTROL, DAT_PENDINGXFERS, MSG_ENDXFER, &aXfers ) == TWRC_SUCCESS )
+ {
+ if( aXfers.Count != 0 )
+ PFUNC( &aAppIdent, &aSrcIdent, DG_CONTROL, DAT_PENDINGXFERS, MSG_RESET, &aXfers );
+ }
+
+ nCurState = 5;
+ }
+ break;
+
+ case( 5 ):
+ {
+ TW_USERINTERFACE aUI = { TRUE, TRUE, hTwainWnd };
+
+ PFUNC( &aAppIdent, &aSrcIdent, DG_CONTROL, DAT_USERINTERFACE, MSG_DISABLEDS, &aUI );
+ nCurState = 4;
+ }
+ break;
+
+ case( 4 ):
+ {
+ PFUNC( &aAppIdent, NULL, DG_CONTROL, DAT_IDENTITY, MSG_CLOSEDS, &aSrcIdent );
+ nCurState = 3;
+ }
+ break;
+
+ case( 3 ):
+ {
+ PFUNC( &aAppIdent, NULL, DG_CONTROL, DAT_PARENT, MSG_CLOSEDSM, &hTwainWnd );
+ nCurState = 2;
+ }
+ break;
+
+ case( 2 ):
+ {
+ delete pMod;
+ pMod = NULL;
+ nCurState = 1;
+ }
+ break;
+
+ default:
+ {
+ if( nEvent != TWAIN_EVENT_NONE )
+ aNotifyLink.Call( (void*) nEvent );
+
+ bFallback = FALSE;
+ }
+ break;
+ }
+
+ if( bFallback )
+ ImplFallback( nEvent );
+
+ return 0L;
+}
+
+// -----------------------------------------------------------------------------
+
+IMPL_LINK( ImpTwain, ImplDestroyHdl, void*, p )
+{
+#ifdef OS2
+
+ if( hWndTwain )
+ WinDestroyWindow( hWndTwain );
+
+ // unset hook
+
+#else
+
+ if( hTwainWnd )
+ DestroyWindow( hTwainWnd );
+
+ if( hTwainHook )
+ UnhookWindowsHookEx( hTwainHook );
+
+#endif
+
+ delete this;
+ pImpTwainInstance = NULL;
+
+ return 0L;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/scanner/twain.hxx b/extensions/source/scanner/twain.hxx
new file mode 100644
index 000000000000..ca7d80240c43
--- /dev/null
+++ b/extensions/source/scanner/twain.hxx
@@ -0,0 +1,101 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _TWAIN_HXX
+#define _TWAIN_HXX
+
+#include <osl/module.hxx>
+#include <vcl/bitmap.hxx>
+#include "twain/twain.h"
+
+
+// -----------
+// - Defines -
+// -----------
+
+#define TWAIN_SELECT 0x00000001UL
+#define TWAIN_ACQUIRE 0x00000002UL
+#define TWAIN_TERMINATE 0xFFFFFFFFUL
+
+#define TWAIN_EVENT_NONE 0x00000000UL
+#define TWAIN_EVENT_QUIT 0x00000001UL
+#define TWAIN_EVENT_SCANNING 0x00000002UL
+#define TWAIN_EVENT_XFER 0x00000004UL
+
+// ------------
+// - ImpTwain -
+// ------------
+
+class ImpTwain
+{
+ TW_IDENTITY aAppIdent;
+ TW_IDENTITY aSrcIdent;
+ Link aNotifyLink;
+ Bitmap aBitmap;
+ DSMENTRYPROC pDSM;
+ osl::Module pMod;
+ ULONG nCurState;
+
+ void ImplCreate();
+ void ImplOpenSourceManager();
+ void ImplOpenSource();
+ BOOL ImplEnableSource();
+ void ImplXfer();
+ void ImplFallback( ULONG nEvent );
+
+ DECL_LINK( ImplFallbackHdl, void* );
+ DECL_LINK( ImplDestroyHdl, void* );
+
+public:
+
+ BOOL ImplHandleMsg( void* pMsg );
+
+#ifdef OS2
+ HAB hAB;
+ HWND hTwainWnd;
+ long hTwainHook;
+#else
+ HWND hTwainWnd;
+ HHOOK hTwainHook;
+#endif
+
+public:
+
+ ImpTwain( const Link& rNotifyLink );
+ ~ImpTwain();
+
+ void Destroy();
+
+ BOOL SelectSource();
+ BOOL InitXfer();
+ Bitmap GetXferBitmap();
+};
+
+#endif // _TWAIN_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/svg/makefile.mk b/extensions/source/svg/makefile.mk
new file mode 100644
index 000000000000..c46aede54920
--- /dev/null
+++ b/extensions/source/svg/makefile.mk
@@ -0,0 +1,67 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ=..$/..
+PRJNAME=extensions
+TARGET=svg
+
+ENABLE_EXCEPTIONS=TRUE
+
+# --- Settings ----------------------------------
+
+.INCLUDE : $(PRJ)$/util$/makefile.pmk
+
+# --- Files -------------------------------------
+
+SLOFILES= $(SLO)$/svgprinter.obj \
+ $(SLO)$/svguno.obj \
+ $(SLO)$/svgwriter.obj \
+ $(SLO)$/svgaction.obj
+
+# --- Library -----------------------------------
+
+SHL1TARGET=$(TARGET)$(DLLPOSTFIX)
+SHL1IMPLIB=i$(SHL1TARGET)
+
+SHL1VERSIONMAP=$(SOLARENV)/src/component.map
+SHL1DEF=$(MISC)$/$(SHL1TARGET).def
+DEF1NAME=$(SHL1TARGET)
+
+SHL1STDLIBS=\
+ $(XMLOFFLIB) \
+ $(VCLLIB) \
+ $(TOOLSLIB) \
+ $(CPPUHELPERLIB) \
+ $(CPPULIB) \
+ $(SALLIB)
+
+SHL1LIBS= $(SLB)$/$(TARGET).lib
+
+# --- Targets ----------------------------------
+
+.INCLUDE : target.mk
+
diff --git a/extensions/source/svg/svgaction.cxx b/extensions/source/svg/svgaction.cxx
new file mode 100644
index 000000000000..fd460f0c47b7
--- /dev/null
+++ b/extensions/source/svg/svgaction.cxx
@@ -0,0 +1,1461 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+
+#include "svgaction.hxx"
+#include <vcl/virdev.hxx>
+#include <vcl/cvtgrf.hxx>
+#include <vcl/metric.hxx>
+
+#undef _SVG_USE_NATIVE_TEXTDECORATION
+#undef _SVG_USE_TSPANS
+
+// -----------
+// - statics -
+// -----------
+
+static const char aXMLElemSVG[] = "svg";
+static const char aXMLElemG[] = "g";
+static const char aXMLElemDefs[] = "defs";
+static const char aXMLElemClipPath[] = "clipPath";
+static const char aXMLElemLine[] = "line";
+static const char aXMLElemRect[] = "rect";
+static const char aXMLElemEllipse[] = "ellipse";
+static const char aXMLElemPath[] = "path";
+static const char aXMLElemPolygon[] = "polygon";
+static const char aXMLElemPolyLine[] = "polyline";
+static const char aXMLElemText[] = "text";
+static const char aXMLElemTSpan[] = "tspan";
+static const char aXMLElemImage[] = "image";
+
+static const char aXMLAttrTransform[] = "transform";
+static const char aXMLAttrStyle[] = "style";
+static const char aXMLAttrId[] = "id";
+
+static const char aXMLAttrD[] = "d";
+static const char aXMLAttrX[] = "x";
+static const char aXMLAttrY[] = "y";
+static const char aXMLAttrX1[] = "x1";
+static const char aXMLAttrY1[] = "y1";
+static const char aXMLAttrX2[] = "x2";
+static const char aXMLAttrY2[] = "y2";
+static const char aXMLAttrCX[] = "cx";
+static const char aXMLAttrCY[] = "cy";
+static const char aXMLAttrRX[] = "rx";
+static const char aXMLAttrRY[] = "ry";
+static const char aXMLAttrWidth[] = "width";
+static const char aXMLAttrHeight[] = "height";
+static const char aXMLAttrPoints[] = "points";
+static const char aXMLAttrXLinkHRef[] = "xlink:href";
+
+static const sal_Unicode pBase64[] =
+{
+ //0 1 2 3 4 5 6 7
+ 'A','B','C','D','E','F','G','H', // 0
+ 'I','J','K','L','M','N','O','P', // 1
+ 'Q','R','S','T','U','V','W','X', // 2
+ 'Y','Z','a','b','c','d','e','f', // 3
+ 'g','h','i','j','k','l','m','n', // 4
+ 'o','p','q','r','s','t','u','v', // 5
+ 'w','x','y','z','0','1','2','3', // 6
+ '4','5','6','7','8','9','+','/' // 7
+};
+
+// --------------
+// - FastString -
+// --------------
+
+FastString::FastString( sal_uInt32 nInitLen, sal_uInt32 nIncrement ) :
+ mpBuffer( new sal_Unicode[ nInitLen * sizeof( sal_Unicode ) ] ),
+ mnBufLen( nInitLen ),
+ mnCurLen( 0 ),
+ mnBufInc( nIncrement ),
+ mnPartPos( 0 )
+{
+ DBG_ASSERT( nInitLen, "invalid initial length" );
+ DBG_ASSERT( nIncrement, "invalid increment" );
+}
+
+// -----------------------------------------------------------------------------
+
+FastString::FastString( sal_Char* pBufferForBase64Encoding, sal_uInt32 nBufLen ) :
+ mnBufInc( 2048 ),
+ mnPartPos( 0 )
+{
+ DBG_ASSERT( pBufferForBase64Encoding && nBufLen, "invalid arguments" );
+
+ const sal_uInt32 nQuadCount = nBufLen / 3;
+ const sal_uInt32 nRest = nBufLen % 3;
+
+ if( nQuadCount || nRest )
+ {
+ mnBufLen = mnCurLen = ( ( nQuadCount + ( nRest ? 1 : 0 ) ) << 2 );
+ mpBuffer = new sal_Unicode[ mnBufLen * sizeof( sal_Unicode ) ];
+
+ sal_Char* pTmpSrc = pBufferForBase64Encoding;
+ sal_Unicode* pTmpDst = mpBuffer;
+
+ for( sal_uInt32 i = 0; i < nQuadCount; i++ )
+ {
+ const sal_Int32 nA = *pTmpSrc++;
+ const sal_Int32 nB = *pTmpSrc++;
+ const sal_Int32 nC = *pTmpSrc++;
+
+ *pTmpDst++ = pBase64[ ( nA >> 2 ) & 0x3f ];
+ *pTmpDst++ = pBase64[ ( ( nA << 4 ) & 0x30 ) + ( ( nB >> 4 ) & 0xf ) ];
+ *pTmpDst++ = pBase64[ ( ( nB << 2 ) & 0x3c ) + ( ( nC >> 6 ) & 0x3 ) ];
+ *pTmpDst++ = pBase64[ nC & 0x3f ];
+ }
+
+ if( 1 == nRest )
+ {
+ const sal_Int32 nA = *pTmpSrc;
+
+ *pTmpDst++ = pBase64[ ( nA >> 2 ) & 0x3f ];
+ *pTmpDst++ = pBase64[ ( nA << 4 ) & 0x30 ];
+ *pTmpDst++ = '=';
+ *pTmpDst = '=';
+ }
+ else if( 2 == nRest )
+ {
+ const sal_Int32 nA = *pTmpSrc++;
+ const sal_Int32 nB = *pTmpSrc;
+
+ *pTmpDst++ = pBase64[ ( nA >> 2 ) & 0x3f ];
+ *pTmpDst++ = pBase64[ ( ( nA << 4 ) & 0x30 ) + ( ( nB >> 4 ) & 0xf ) ];
+ *pTmpDst++ = pBase64[ ( nB << 2 ) & 0x3c ];
+ *pTmpDst = '=';
+ }
+ }
+ else
+ {
+ mpBuffer = new sal_Unicode[ ( mnBufLen = 1 ) * sizeof( sal_Unicode ) ];
+ mnCurLen = 0;
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+FastString::~FastString()
+{
+ delete[] mpBuffer;
+}
+
+// -----------------------------------------------------------------------------
+
+FastString& FastString::operator+=( const NMSP_RTL::OUString& rStr )
+{
+ if( rStr.getLength() )
+ {
+ if( ( mnCurLen + rStr.getLength() ) > mnBufLen )
+ {
+ const sal_uInt32 nNewBufLen = ( mnBufLen + ( ( ( mnCurLen + rStr.getLength() ) - mnBufLen ) / mnBufInc + 1 ) * mnBufInc );
+ sal_Unicode* pNewBuffer = new sal_Unicode[ nNewBufLen * sizeof( sal_Unicode ) ];
+
+ memcpy( pNewBuffer, mpBuffer, mnBufLen * sizeof( sal_Unicode ) );
+ delete[] mpBuffer;
+ mpBuffer = pNewBuffer;
+ mnBufLen = nNewBufLen;
+ }
+
+ memcpy( mpBuffer + mnCurLen, rStr.getStr(), rStr.getLength() * sizeof( sal_Unicode ) );
+ mnCurLen += rStr.getLength();
+
+ if( maString.getLength() )
+ maString = NMSP_RTL::OUString();
+ }
+
+ return *this;
+}
+
+// -----------------------------------------------------------------------------
+
+const NMSP_RTL::OUString& FastString::GetString() const
+{
+ if( !maString.getLength() && mnCurLen )
+ ( (FastString*) this )->maString = NMSP_RTL::OUString( mpBuffer, mnCurLen );
+
+ return maString;
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Bool FastString::GetFirstPartString( const sal_uInt32 nPartLen, NMSP_RTL::OUString& rPartString )
+{
+ const sal_uInt32 nLength = Min( mnCurLen, nPartLen );
+
+ mnPartPos = 0;
+
+ if( nLength )
+ {
+ rPartString = NMSP_RTL::OUString( mpBuffer, nLength );
+ mnPartPos = nLength;
+ }
+
+ return( rPartString.getLength() > 0 );
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Bool FastString::GetNextPartString( const sal_uInt32 nPartLen, NMSP_RTL::OUString& rPartString )
+{
+ if( mnPartPos < mnCurLen )
+ {
+ const sal_uInt32 nLength = Min( mnCurLen - mnPartPos, nPartLen );
+ rPartString = NMSP_RTL::OUString( mpBuffer + mnPartPos, nLength );
+ mnPartPos += nLength;
+ }
+ else
+ rPartString = NMSP_RTL::OUString();
+
+ return( rPartString.getLength() > 0 );
+}
+
+// ----------------------
+// - SVGAttributeWriter -
+// ----------------------
+
+SVGAttributeWriter::SVGAttributeWriter( SVGActionWriter& rParent, SvXMLExport& rExport ) :
+ mrParent( rParent ),
+ mrExport( rExport ),
+ mpElemFont( NULL ),
+ mpElemPaint( NULL )
+{
+}
+
+// -----------------------------------------------------------------------------
+
+SVGAttributeWriter::~SVGAttributeWriter()
+{
+ delete mpElemPaint;
+ delete mpElemFont;
+}
+
+// -----------------------------------------------------------------------------
+
+NMSP_RTL::OUString SVGAttributeWriter::GetFontStyle( const Font& rFont )
+{
+ FastString aStyle;
+
+ // font family
+ aStyle += B2UCONST( "font-family:" );
+ aStyle += NMSP_RTL::OUString( rFont.GetName().GetToken( 0, ';' ) );
+
+ // font size
+ aStyle += B2UCONST( ";" );
+ aStyle += B2UCONST( "font-size:" );
+ aStyle += mrParent.GetValueString( mrParent.ImplMap( Size( 0, rFont.GetHeight() ) ).Height(), mrParent.HasDoublePoints() );
+
+ // font style
+ if( rFont.GetItalic() != ITALIC_NONE )
+ {
+ aStyle += B2UCONST( ";" );
+ aStyle += B2UCONST( "font-style:" );
+
+ if( rFont.GetItalic() == ITALIC_OBLIQUE )
+ aStyle += B2UCONST( "oblique" );
+ else
+ aStyle += B2UCONST( "italic" );
+ }
+
+ // font weight
+ sal_Int32 nFontWeight;
+
+ switch( rFont.GetWeight() )
+ {
+ case WEIGHT_THIN: nFontWeight = 100; break;
+ case WEIGHT_ULTRALIGHT: nFontWeight = 200; break;
+ case WEIGHT_LIGHT: nFontWeight = 300; break;
+ case WEIGHT_SEMILIGHT: nFontWeight = 400; break;
+ case WEIGHT_NORMAL: nFontWeight = 400; break;
+ case WEIGHT_MEDIUM: nFontWeight = 500; break;
+ case WEIGHT_SEMIBOLD: nFontWeight = 600; break;
+ case WEIGHT_BOLD: nFontWeight = 700; break;
+ case WEIGHT_ULTRABOLD: nFontWeight = 800; break;
+ case WEIGHT_BLACK: nFontWeight = 900; break;
+ default: nFontWeight = 400; break;
+ }
+
+ aStyle += B2UCONST( ";" );
+ aStyle += B2UCONST( "font-weight:" );
+ aStyle += NMSP_RTL::OUString::valueOf( nFontWeight );
+
+ // !!!
+ // font-variant
+ // font-stretch
+ // font-size-adjust
+
+#ifdef _SVG_USE_NATIVE_TEXTDECORATION
+
+ if( rFont.GetUnderline() != UNDERLINE_NONE || rFont.GetStrikeout() != STRIKEOUT_NONE )
+ {
+ aStyle += B2UCONST( ";" );
+ aStyle += B2UCONST( "text-decoration:" );
+
+ if( rFont.GetUnderline() != UNDERLINE_NONE )
+ aStyle += B2UCONST( " underline" );
+
+ if( rFont.GetStrikeout() != STRIKEOUT_NONE )
+ aStyle += B2UCONST( " line-through" );
+ }
+
+#endif // _SVG_USE_NATIVE_TEXTDECORATION
+
+ return aStyle.GetString();
+}
+
+// -----------------------------------------------------------------------------
+
+NMSP_RTL::OUString SVGAttributeWriter::GetPaintStyle( const Color& rLineColor, const Color& rFillColor )
+{
+ FastString aStyle;
+
+ // line color
+ aStyle += B2UCONST( "stroke:" );
+
+ if( rLineColor.GetTransparency() == 255 )
+ aStyle += B2UCONST( "none" );
+ else
+ {
+ // line color value in rgb
+ aStyle += B2UCONST( "rgb(" );
+ aStyle += NMSP_RTL::OUString::valueOf( (sal_Int32) rLineColor.GetRed() );
+ aStyle += B2UCONST( "," );
+ aStyle += NMSP_RTL::OUString::valueOf( (sal_Int32) rLineColor.GetGreen() );
+ aStyle += B2UCONST( "," );
+ aStyle += NMSP_RTL::OUString::valueOf( (sal_Int32) rLineColor.GetBlue() );
+ aStyle += B2UCONST( ")" );
+
+ // line color opacity in percent if neccessary
+ if( rLineColor.GetTransparency() )
+ {
+ aStyle += B2UCONST( ";" );
+ aStyle += B2UCONST( "stroke-opacity:" );
+ aStyle += NMSP_RTL::OUString::valueOf( (sal_Int32) ( ( 255 - (double) rLineColor.GetTransparency() ) / 2.55 ) );
+ aStyle += B2UCONST( "%" );
+ }
+ }
+
+ // fill color
+ aStyle += B2UCONST( ";" );
+ aStyle += B2UCONST( "fill:" );
+
+ if( rFillColor.GetTransparency() == 255 )
+ aStyle += B2UCONST( "none" );
+ else
+ {
+ // fill color value in rgb
+ aStyle += B2UCONST( "rgb(" );
+ aStyle += NMSP_RTL::OUString::valueOf( (sal_Int32) rFillColor.GetRed() );
+ aStyle += B2UCONST( "," );
+ aStyle += NMSP_RTL::OUString::valueOf( (sal_Int32) rFillColor.GetGreen() );
+ aStyle += B2UCONST( "," );
+ aStyle += NMSP_RTL::OUString::valueOf( (sal_Int32) rFillColor.GetBlue() );
+ aStyle += B2UCONST( ")" );
+
+ // fill color opacity in percent if neccessary
+ if( rFillColor.GetTransparency() )
+ {
+ aStyle += B2UCONST( ";" );
+ aStyle += B2UCONST( "fill-opacity:" );
+ aStyle += NMSP_RTL::OUString::valueOf( (sal_Int32) ( ( 255 - (double) rFillColor.GetTransparency() ) / 2.55 ) );
+ aStyle += B2UCONST( "%" );
+ }
+ }
+
+ return aStyle.GetString();
+}
+
+// -----------------------------------------------------------------------------
+
+void SVGAttributeWriter::SetFontAttr( const Font& rFont )
+{
+ if( !mpElemFont || ( rFont != maCurFont ) )
+ {
+ delete mpElemPaint, mpElemPaint = NULL;
+ delete mpElemFont;
+ mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrStyle, GetFontStyle( maCurFont = rFont ) );
+ mpElemFont = new SvXMLElementExport( mrExport, XML_NAMESPACE_NONE, aXMLElemG, TRUE, TRUE );
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+void SVGAttributeWriter::SetPaintAttr( const Color& rLineColor, const Color& rFillColor )
+{
+ if( !mpElemPaint || ( rLineColor != maCurLineColor ) || ( rFillColor != maCurFillColor ) )
+ {
+ delete mpElemPaint;
+ mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrStyle, GetPaintStyle( maCurLineColor = rLineColor, maCurFillColor = rFillColor ) );
+ mpElemPaint = new SvXMLElementExport( mrExport, XML_NAMESPACE_NONE, aXMLElemG, TRUE, TRUE );
+ }
+}
+
+// -------------------
+// - SVGActionWriter -
+// -------------------
+
+SVGActionWriter::SVGActionWriter( SvXMLExport& rExport, const GDIMetaFile& rMtf,
+ VirtualDevice* pParentVDev, sal_Bool bWriteDoublePoints ) :
+ mrExport( rExport ),
+ mrMtf( rMtf ),
+ mpContext( NULL ),
+ mnCurClipId( 1 ),
+ mbClipAttrChanged( sal_False ),
+ mbDoublePoints( bWriteDoublePoints )
+{
+ if( pParentVDev )
+ {
+ mpVDev = pParentVDev;
+ mbDestroyVDev = sal_False;
+ maTargetMapMode = mpVDev->GetMapMode();
+ }
+ else
+ {
+ mpVDev = new VirtualDevice;
+ mpVDev->EnableOutput( sal_False );
+ mbDestroyVDev = sal_True;
+ maTargetMapMode = MAP_100TH_MM;
+ }
+
+ mpVDev->Push();
+ mpVDev->SetMapMode( mrMtf.GetPrefMapMode() );
+ ImplWriteActions( mrMtf );
+ mpVDev->Pop();
+}
+
+// -----------------------------------------------------------------------------
+
+SVGActionWriter::~SVGActionWriter()
+{
+ DBG_ASSERT( !mpContext, "Not all contexts are closed" );
+
+ if( mbDestroyVDev )
+ delete mpVDev;
+}
+
+// -----------------------------------------------------------------------------
+
+long SVGActionWriter::ImplMap( sal_Int32 nVal ) const
+{
+ return ImplMap( Size( nVal, nVal ) ).Width();
+}
+
+// -----------------------------------------------------------------------------
+
+Point SVGActionWriter::ImplMap( const Point& rPt ) const
+{
+ return mpVDev->LogicToLogic( rPt, mpVDev->GetMapMode(), maTargetMapMode );
+}
+
+// -----------------------------------------------------------------------------
+
+Size SVGActionWriter::ImplMap( const Size& rSz ) const
+{
+ return mpVDev->LogicToLogic( rSz, mpVDev->GetMapMode(), maTargetMapMode );
+}
+
+// -----------------------------------------------------------------------------
+
+NMSP_RTL::OUString SVGActionWriter::GetValueString( sal_Int32 nVal, sal_Bool bDoublePoints )
+{
+ if( !bDoublePoints )
+ return NMSP_RTL::OUString::valueOf( nVal );
+ else
+ {
+ const double fPoints = nVal * 72.0 / 2540.0;
+ const sal_Int32 nInt = (sal_Int32) fPoints;
+
+ return( ( NMSP_RTL::OUString::valueOf( nInt ) +=
+ NMSP_RTL::OUString::valueOf( (sal_Unicode) '.' ) ) +=
+ NMSP_RTL::OUString::valueOf( labs( (sal_Int32) ( ( fPoints - nInt ) * 100.0 ) ) ) );
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+void SVGActionWriter::ImplWriteLine( const Point& rPt1, const Point& rPt2, const Color* pLineColor,
+ const NMSP_RTL::OUString* pStyle )
+{
+ const Point aPt1( ImplMap( rPt1 ) );
+ const Point aPt2( ImplMap( rPt2 ) );
+
+ mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrX1, GetValueString( aPt1.X(), mbDoublePoints ) );
+ mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrY1, GetValueString( aPt1.Y(), mbDoublePoints ) );
+ mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrX2, GetValueString( aPt2.X(), mbDoublePoints ) );
+ mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrY2, GetValueString( aPt2.Y(), mbDoublePoints ) );
+
+ // add additional style if requested
+ if( pStyle )
+ mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrStyle, *pStyle );
+
+ if( pLineColor )
+ {
+ // !!! mrExport.AddAttribute( XML_NAMESPACE_NONE, ... )
+ DBG_ERROR( "SVGActionWriter::ImplWriteLine: Line color not implemented" );
+ }
+
+ {
+ SvXMLElementExport aElem( mrExport, XML_NAMESPACE_NONE, aXMLElemLine, TRUE, TRUE );
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+void SVGActionWriter::ImplWriteRect( const Rectangle& rRect, long nRadX, long nRadY,
+ const NMSP_RTL::OUString* pStyle )
+{
+ const Rectangle aRect( ImplMap( rRect ) );
+
+ mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrX, GetValueString( aRect.Left(), mbDoublePoints ) );
+ mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrY, GetValueString( aRect.Top(), mbDoublePoints ) );
+ mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrWidth, GetValueString( aRect.GetWidth(), mbDoublePoints ) );
+ mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrHeight, GetValueString( aRect.GetHeight(), mbDoublePoints ) );
+
+ if( nRadX )
+ mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrRX, GetValueString( ImplMap( nRadX ), mbDoublePoints ) );
+
+ if( nRadY )
+ mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrRY, GetValueString( ImplMap( nRadY ), mbDoublePoints ) );
+
+ // add additional style if requested
+ if( pStyle )
+ mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrStyle, *pStyle );
+
+ {
+ SvXMLElementExport aElem( mrExport, XML_NAMESPACE_NONE, aXMLElemRect, TRUE, TRUE );
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+void SVGActionWriter::ImplWriteEllipse( const Point& rCenter, long nRadX, long nRadY,
+ const NMSP_RTL::OUString* pStyle )
+{
+ const Point aCenter( ImplMap( rCenter ) );
+
+ mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrCX, GetValueString( aCenter.X(), mbDoublePoints ) );
+ mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrCY, GetValueString( aCenter.Y(), mbDoublePoints ) );
+ mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrRX, GetValueString( ImplMap( nRadX ), mbDoublePoints ) );
+ mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrRY, GetValueString( ImplMap( nRadY ), mbDoublePoints ) );
+
+ // add additional style if requested
+ if( pStyle )
+ mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrStyle, *pStyle );
+
+ {
+ SvXMLElementExport aElem( mrExport, XML_NAMESPACE_NONE, aXMLElemEllipse, TRUE, TRUE );
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+void SVGActionWriter::ImplWritePolygon( const Polygon& rPoly, sal_Bool bLineOnly,
+ const NMSP_RTL::OUString* pStyle )
+{
+ if( rPoly.GetSize() )
+ {
+ if( rPoly.HasFlags() )
+ ImplWritePolyPolygon( rPoly, bLineOnly, pStyle );
+ else
+ {
+ FastString aStyle;
+ FastString aPoints;
+ USHORT i = 0, nSize = rPoly.GetSize();
+ const NMSP_RTL::OUString aBlank( B2UCONST( " " ) );
+
+ // points
+ while( i < nSize )
+ {
+ const Point aPolyPoint( ImplMap( rPoly[ i ] ) );
+
+ aPoints += GetValueString( aPolyPoint.X(), mbDoublePoints );
+ aPoints += B2UCONST( "," );
+ aPoints += GetValueString( aPolyPoint.Y(), mbDoublePoints );
+
+ if( ++i < nSize )
+ aPoints += aBlank;
+ }
+
+ // style
+ if( bLineOnly )
+ {
+ aStyle += B2UCONST( "fill:none" );
+
+ if( pStyle )
+ {
+ aStyle += B2UCONST( ";" );
+ aStyle += *pStyle;
+ }
+ }
+ else if( pStyle )
+ aStyle += *pStyle;
+
+ // add point attribute
+ mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrPoints, aPoints.GetString() );
+
+ // add style attribute
+ if( aStyle.GetLength() )
+ mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrStyle, aStyle.GetString() );
+
+ {
+ // write polyline/polygon element
+ SvXMLElementExport aElem( mrExport, XML_NAMESPACE_NONE, bLineOnly ? aXMLElemPolyLine : aXMLElemPolygon, TRUE, TRUE );
+ }
+ }
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+void SVGActionWriter::ImplWritePolyPolygon( const PolyPolygon& rPolyPoly, sal_Bool bLineOnly,
+ const NMSP_RTL::OUString* pStyle )
+{
+ if( rPolyPoly.Count() )
+ {
+ if( ( rPolyPoly.Count() == 1 ) && ( rPolyPoly[ 0 ].HasFlags() == sal_False ) )
+ ImplWritePolygon( rPolyPoly[ 0 ], bLineOnly, pStyle );
+ else
+ {
+ FastString aStyle;
+ FastString aPathData;
+ const NMSP_RTL::OUString aBlank( B2UCONST( " " ) );
+ const NMSP_RTL::OUString aComma( B2UCONST( "," ) );
+ Point aPolyPoint;
+
+ for( long i = 0, nCount = rPolyPoly.Count(); i < nCount; i++ )
+ {
+ const Polygon& rPoly = rPolyPoly[ (USHORT) i ];
+ USHORT n = 1, nSize = rPoly.GetSize();
+
+ if( nSize > 1 )
+ {
+ aPathData += B2UCONST( "M " );
+ aPathData += GetValueString( ( aPolyPoint = ImplMap( rPoly[ 0 ] ) ).X(), mbDoublePoints );
+ aPathData += aComma;
+ aPathData += GetValueString( aPolyPoint.Y(), mbDoublePoints );
+ sal_Char nCurrentMode = 0;
+
+ while( n < nSize )
+ {
+ aPathData += aBlank;
+ if ( ( rPoly.GetFlags( n ) == POLY_CONTROL ) && ( ( n + 2 ) < nSize ) )
+ {
+ if ( nCurrentMode != 'C' )
+ {
+ nCurrentMode = 'C';
+ aPathData += B2UCONST( "C " );
+ }
+ for ( int j = 0; j < 3; j++ )
+ {
+ if ( j )
+ aPathData += aBlank;
+ aPathData += GetValueString( ( aPolyPoint = ImplMap( rPoly[ n++ ] ) ).X(), mbDoublePoints );
+ aPathData += aComma;
+ aPathData += GetValueString( aPolyPoint.Y(), mbDoublePoints );
+ }
+ }
+ else
+ {
+ if ( nCurrentMode != 'L' )
+ {
+ nCurrentMode = 'L';
+ aPathData += B2UCONST( "L " );
+ }
+ aPathData += GetValueString( ( aPolyPoint = ImplMap( rPoly[ n++ ] ) ).X(), mbDoublePoints );
+ aPathData += aComma;
+ aPathData += GetValueString( aPolyPoint.Y(), mbDoublePoints );
+ }
+ }
+ aPathData += B2UCONST( " Z" );
+
+ if( i < ( nCount - 1 ) )
+ aPathData += aBlank;
+ }
+ }
+ if( bLineOnly )
+ {
+ aStyle += B2UCONST( "fill:none" );
+ if( pStyle )
+ aStyle += B2UCONST( ";" );
+ }
+ if( pStyle )
+ aStyle += *pStyle;
+
+ // add style attribute
+ if( aStyle.GetLength() )
+ mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrStyle, aStyle.GetString() );
+
+ // add path data attribute
+ mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrD, aPathData.GetString() );
+ {
+ // write polyline/polygon element
+ SvXMLElementExport aElem( mrExport, XML_NAMESPACE_NONE, aXMLElemPath, TRUE, TRUE );
+ }
+ }
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+void SVGActionWriter::ImplWriteGradientEx( const PolyPolygon& rPolyPoly, const Gradient& rGradient,
+ const NMSP_RTL::OUString* pStyle )
+{
+ if( rPolyPoly.Count() )
+ {
+ SvXMLElementExport aElemG( mrExport, XML_NAMESPACE_NONE, aXMLElemG, TRUE, TRUE );
+ FastString aClipId;
+ FastString aClipStyle;
+
+ aClipId += B2UCONST( "clip" );
+ aClipId += NMSP_RTL::OUString::valueOf( ImplGetNextClipId() );
+
+ {
+ SvXMLElementExport aElemDefs( mrExport, XML_NAMESPACE_NONE, aXMLElemDefs, TRUE, TRUE );
+
+ mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrId, aClipId.GetString() );
+
+ {
+ SvXMLElementExport aElemClipPath( mrExport, XML_NAMESPACE_NONE, aXMLElemClipPath, TRUE, TRUE );
+ ImplWritePolyPolygon( rPolyPoly, sal_False );
+ }
+ }
+
+ // create new context with clippath set
+ aClipStyle += B2UCONST( "clip-path:URL(#" );
+ aClipStyle += aClipId.GetString();
+ aClipStyle += B2UCONST( ")" );
+
+ mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrStyle, aClipStyle.GetString() );
+
+ {
+ GDIMetaFile aTmpMtf;
+ SvXMLElementExport aElemG2( mrExport, XML_NAMESPACE_NONE, aXMLElemG, TRUE, TRUE );
+
+ mpVDev->AddGradientActions( rPolyPoly.GetBoundRect(), rGradient, aTmpMtf );
+ ImplWriteActions( aTmpMtf, pStyle );
+ }
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+void SVGActionWriter::ImplWriteText( const Point& rPos, const String& rText,
+ const sal_Int32* pDXArray, long nWidth,
+ const NMSP_RTL::OUString* pStyle )
+{
+ String aText( rText ); aText.EraseLeadingChars( ' ' );
+ UINT32 nLen = aText.Len(), i;
+
+ if( nLen )
+ {
+ Size aNormSize;
+ sal_Int32* pOwnArray;
+ sal_Int32* pDX;
+
+ // get text sizes
+ if( pDXArray )
+ {
+ pOwnArray = NULL;
+ aNormSize = Size( mpVDev->GetTextWidth( aText ), 0 );
+ pDX = const_cast< sal_Int32* >( pDXArray );
+ }
+ else
+ {
+ pOwnArray = new sal_Int32[ nLen ];
+ aNormSize = Size( mpVDev->GetTextArray( aText, pOwnArray ), 0 );
+ pDX = pOwnArray;
+ }
+
+ if( nLen > 1 )
+ {
+ aNormSize.Width() = pDX[ nLen - 2 ] + mpVDev->GetTextWidth( aText.GetChar( (USHORT) nLen - 1 ) );
+
+ if( nWidth && aNormSize.Width() && ( nWidth != aNormSize.Width() ) )
+ {
+ const double fFactor = (double) nWidth / aNormSize.Width();
+
+ for( i = 0; i < ( nLen - 1 ); i++ )
+ pDX[ i ] = FRound( pDX[ i ] * fFactor );
+ }
+ }
+
+ FastString aStyle;
+ const Font& rFont = mpVDev->GetFont();
+ const FontMetric aMetric( mpVDev->GetFontMetric() );
+ Point aBaseLinePos( rPos );
+ SvXMLElementExport* pTransform = NULL;
+
+ // leading whitespaces erased? => adjust position
+ if( nLen < rText.Len() )
+ {
+ aBaseLinePos.X() += mpVDev->GetTextWidth( ' ' ) * ( rText.Len() - nLen );
+ }
+
+ // always adjust text position to match baseline alignment
+ switch( rFont.GetAlign() )
+ {
+ case( ALIGN_TOP ):
+ aBaseLinePos.Y() += aMetric.GetAscent();
+ break;
+
+ case( ALIGN_BOTTOM ):
+ aBaseLinePos.Y() -= aMetric.GetDescent();
+ break;
+
+ default:
+ break;
+ }
+
+ // get mapped text position
+ const Point aPt( ImplMap( aBaseLinePos ) );
+
+ // if text is rotated, set transform at new g element
+ if( rFont.GetOrientation() )
+ {
+ String aTransform;
+
+ aTransform = NMSP_RTL::OUString::createFromAscii( "translate" );
+ aTransform += '(';
+ aTransform += String( GetValueString( aPt.X(), mbDoublePoints ) );
+ aTransform += ',';
+ aTransform += String( GetValueString( aPt.Y(), mbDoublePoints ) );
+ aTransform += ')';
+
+ aTransform += String( NMSP_RTL::OUString::createFromAscii( " rotate" ) );
+ aTransform += '(';
+ aTransform += String( NMSP_RTL::OUString::valueOf( rFont.GetOrientation() * -0.1 ) );
+ aTransform += ')';
+
+ aTransform += String( NMSP_RTL::OUString::createFromAscii( " translate" ) );
+ aTransform += '(';
+ aTransform += String( GetValueString( -aPt.X(), mbDoublePoints ) );
+ aTransform += ',';
+ aTransform += String( GetValueString( -aPt.Y(), mbDoublePoints ) );
+ aTransform += ')';
+
+ mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrTransform, aTransform );
+ pTransform = new SvXMLElementExport( mrExport, XML_NAMESPACE_NONE, aXMLElemG, TRUE, TRUE );
+ }
+
+ // add additional style if requested
+ if( pStyle && pStyle->getLength() )
+ mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrStyle, *pStyle );
+
+ // write text element
+#ifdef _SVG_USE_TSPANS
+ if( pDXArray )
+ {
+ SvXMLElementExport aElem( mrExport, XML_NAMESPACE_NONE, aXMLElemText, TRUE, TRUE );
+ FastString aTSpanX;
+ const NMSP_RTL::OUString aSpace( ' ' );
+ long i, nX, nCount;
+
+ aTSpanX += GetValueString( aPt.X(), mbDoublePoints );
+ aTSpanX += aSpace;
+
+ for( i = 0, nX = aPt.X(), nCount = ( nLen - 1 ); i < nCount; )
+ {
+ aTSpanX += GetValueString( aPt.X() + pDX[ i++ ], mbDoublePoints );
+ aTSpanX += aSpace;
+ }
+
+ mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrX, aTSpanX.GetString() );
+ mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrY, GetValueString( aPt.Y(), mbDoublePoints ) );
+
+ {
+ try
+ {
+ try
+ {
+ SvXMLElementExport aElem( mrExport, XML_NAMESPACE_NONE, aXMLElemTSpan, TRUE, TRUE );
+ mrExport.GetDocHandler()->characters( NMSP_RTL::OUString( UniString( aText ) ) );
+ }
+ catch( ::com::sun::star::xml::sax::SAXException& )
+ {
+ // string seems to contain invalid characters
+ }
+ }
+ }
+ }
+ else
+#endif
+ {
+ mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrX, GetValueString( aPt.X(), mbDoublePoints ) );
+ mrExport.AddAttribute( XML_NAMESPACE_NONE, aXMLAttrY, GetValueString( aPt.Y(), mbDoublePoints ) );
+
+ try
+ {
+ SvXMLElementExport aElem( mrExport, XML_NAMESPACE_NONE, aXMLElemText, TRUE, TRUE );
+ mrExport.GetDocHandler()->characters( NMSP_RTL::OUString( UniString( aText ) ) );
+ }
+ catch( ::com::sun::star::xml::sax::SAXException& )
+ {
+ // string seems to contain invalid characters
+ }
+ }
+
+#ifndef _SVG_USE_NATIVE_TEXTDECORATION
+
+ // write strikeout if neccessary
+ if( ( rFont.GetStrikeout() != STRIKEOUT_NONE ) || ( rFont.GetUnderline() != UNDERLINE_NONE ) )
+ {
+ Polygon aPoly( 4 );
+ const long nLineHeight = Max( (long) FRound( aMetric.GetLineHeight() * 0.05 ), (long) 1 );
+
+ if( rFont.GetStrikeout() )
+ {
+ const long nYLinePos = aBaseLinePos.Y() - FRound( aMetric.GetAscent() * 0.26 );
+
+ aPoly[ 0 ].X() = aBaseLinePos.X(); aPoly[ 0 ].Y() = nYLinePos - ( nLineHeight >> 1 );
+ aPoly[ 1 ].X() = aBaseLinePos.X() + aNormSize.Width() - 1; aPoly[ 1 ].Y() = aPoly[ 0 ].Y();
+ aPoly[ 2 ].X() = aPoly[ 1 ].X(); aPoly[ 2 ].Y() = aPoly[ 0 ].Y() + nLineHeight - 1;
+ aPoly[ 3 ].X() = aPoly[ 0 ].X(); aPoly[ 3 ].Y() = aPoly[ 2 ].Y();
+
+ ImplWritePolygon( aPoly, FALSE );
+ }
+
+ if( rFont.GetUnderline() )
+ {
+ const long nYLinePos = aBaseLinePos.Y() + ( nLineHeight << 1 );
+
+ aPoly[ 0 ].X() = aBaseLinePos.X(); aPoly[ 0 ].Y() = nYLinePos - ( nLineHeight >> 1 );
+ aPoly[ 1 ].X() = aBaseLinePos.X() + aNormSize.Width() - 1; aPoly[ 1 ].Y() = aPoly[ 0 ].Y();
+ aPoly[ 2 ].X() = aPoly[ 1 ].X(); aPoly[ 2 ].Y() = aPoly[ 0 ].Y() + nLineHeight - 1;
+ aPoly[ 3 ].X() = aPoly[ 0 ].X(); aPoly[ 3 ].Y() = aPoly[ 2 ].Y();
+
+ ImplWritePolygon( aPoly, FALSE );
+ }
+ }
+
+#endif // _SVG_USE_NATIVE_TEXTDECORATION
+
+ delete[] pOwnArray;
+ delete pTransform;
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+void SVGActionWriter::ImplWriteBmp( const BitmapEx& rBmpEx,
+ const Point& rPt, const Size& rSz,
+ const Point& rSrcPt, const Size& rSrcSz,
+ const NMSP_RTL::OUString* /*pStyle*/ )
+{
+ if( !!rBmpEx )
+ {
+ BitmapEx aBmpEx( rBmpEx );
+ Point aPoint = Point();
+ const Rectangle aBmpRect( aPoint, rBmpEx.GetSizePixel() );
+ const Rectangle aSrcRect( rSrcPt, rSrcSz );
+
+ if( aSrcRect != aBmpRect )
+ aBmpEx.Crop( aSrcRect );
+
+ if( !!aBmpEx )
+ {
+ SvMemoryStream aOStm( 65535, 65535 );
+
+ if( GraphicConverter::Export( aOStm, rBmpEx, CVT_PNG ) == ERRCODE_NONE )
+ {
+ const Point aPt( ImplMap( rPt ) );
+ const Size aSz( ImplMap( rSz ) );
+ FastString aImageData( (sal_Char*) aOStm.GetData(), aOStm.Tell() );
+ REF( NMSP_SAX::XExtendedDocumentHandler ) xExtDocHandler( mrExport.GetDocHandler(), NMSP_UNO::UNO_QUERY );
+
+ if( xExtDocHandler.is() )
+ {
+ static const sal_uInt32 nPartLen = 64;
+ const NMSP_RTL::OUString aSpace( ' ' );
+ const NMSP_RTL::OUString aLineFeed( NMSP_RTL::OUString::valueOf( (sal_Unicode) 0x0a ) );
+ NMSP_RTL::OUString aString;
+ NMSP_RTL::OUString aImageString;
+
+ aString = aLineFeed;
+ aString += B2UCONST( "<" );
+ aString += NMSP_RTL::OUString::createFromAscii( aXMLElemImage );
+ aString += aSpace;
+
+ aString += NMSP_RTL::OUString::createFromAscii( aXMLAttrX );
+ aString += B2UCONST( "=\"" );
+ aString += GetValueString( aPt.X(), mbDoublePoints );
+ aString += B2UCONST( "\" " );
+
+ aString += NMSP_RTL::OUString::createFromAscii( aXMLAttrY );
+ aString += B2UCONST( "=\"" );
+ aString += GetValueString( aPt.Y(), mbDoublePoints );
+ aString += B2UCONST( "\" " );
+
+ aString += NMSP_RTL::OUString::createFromAscii( aXMLAttrWidth );
+ aString += B2UCONST( "=\"" );
+ aString += GetValueString( aSz.Width(), mbDoublePoints );
+ aString += B2UCONST( "\" " );
+
+ aString += NMSP_RTL::OUString::createFromAscii( aXMLAttrHeight );
+ aString += B2UCONST( "=\"" );
+ aString += GetValueString( aSz.Height(), mbDoublePoints );
+ aString += B2UCONST( "\" " );
+
+ aString += NMSP_RTL::OUString::createFromAscii( aXMLAttrXLinkHRef );
+ aString += B2UCONST( "=\"data:image/png;base64," );
+
+ if( aImageData.GetFirstPartString( nPartLen, aImageString ) )
+ {
+ xExtDocHandler->unknown( aString += aImageString );
+
+ while( aImageData.GetNextPartString( nPartLen, aImageString ) )
+ {
+ xExtDocHandler->unknown( aLineFeed );
+ xExtDocHandler->unknown( aImageString );
+ }
+ }
+
+ xExtDocHandler->unknown( B2UCONST( "\"/>" ) );
+ }
+ }
+ }
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+void SVGActionWriter::ImplWriteActions( const GDIMetaFile& rMtf, const NMSP_RTL::OUString* pStyle )
+{
+ ImplAcquireContext();
+
+ for( ULONG i = 0, nCount = rMtf.GetActionCount(); i < nCount; i++ )
+ {
+ const MetaAction* pAction = rMtf.GetAction( i );
+ const USHORT nType = pAction->GetType();
+
+ switch( nType )
+ {
+ case( META_PIXEL_ACTION ):
+ {
+ const MetaPixelAction* pA = (const MetaPixelAction*) pAction;
+
+ mpContext->SetPaintAttr( pA->GetColor(), pA->GetColor() );
+ ImplWriteLine( pA->GetPoint(), pA->GetPoint(), &pA->GetColor(), pStyle );
+ }
+ break;
+
+ case( META_POINT_ACTION ):
+ {
+ const MetaPointAction* pA = (const MetaPointAction*) pAction;
+
+ mpContext->SetPaintAttr( mpVDev->GetLineColor(), mpVDev->GetLineColor() );
+ ImplWriteLine( pA->GetPoint(), pA->GetPoint(), NULL, pStyle );
+ }
+ break;
+
+ case( META_LINE_ACTION ):
+ {
+ const MetaLineAction* pA = (const MetaLineAction*) pAction;
+
+ mpContext->SetPaintAttr( mpVDev->GetLineColor(), mpVDev->GetLineColor() );
+ ImplWriteLine( pA->GetStartPoint(), pA->GetEndPoint(), NULL, pStyle );
+ }
+ break;
+
+ case( META_RECT_ACTION ):
+ {
+ mpContext->SetPaintAttr( mpVDev->GetLineColor(), mpVDev->GetFillColor() );
+ ImplWriteRect( ( (const MetaRectAction*) pAction )->GetRect(), 0, 0, pStyle );
+ }
+ break;
+
+ case( META_ROUNDRECT_ACTION ):
+ {
+ const MetaRoundRectAction* pA = (const MetaRoundRectAction*) pAction;
+
+ mpContext->SetPaintAttr( mpVDev->GetLineColor(), mpVDev->GetFillColor() );
+ ImplWriteRect( pA->GetRect(), pA->GetHorzRound(), pA->GetVertRound(), pStyle );
+ }
+ break;
+
+ case( META_ELLIPSE_ACTION ):
+ {
+ const MetaEllipseAction* pA = (const MetaEllipseAction*) pAction;
+ const Rectangle& rRect = pA->GetRect();
+
+ mpContext->SetPaintAttr( mpVDev->GetLineColor(), mpVDev->GetFillColor() );
+ ImplWriteEllipse( rRect.Center(), rRect.GetWidth() >> 1, rRect.GetHeight() >> 1, pStyle );
+ }
+ break;
+
+ case( META_ARC_ACTION ):
+ case( META_PIE_ACTION ):
+ case( META_CHORD_ACTION ):
+ case( META_POLYGON_ACTION ):
+ {
+ Polygon aPoly;
+
+ switch( nType )
+ {
+ case( META_ARC_ACTION ):
+ {
+ const MetaArcAction* pA = (const MetaArcAction*) pAction;
+ aPoly = Polygon( pA->GetRect(), pA->GetStartPoint(), pA->GetEndPoint(), POLY_ARC );
+ }
+ break;
+
+ case( META_PIE_ACTION ):
+ {
+ const MetaPieAction* pA = (const MetaPieAction*) pAction;
+ aPoly = Polygon( pA->GetRect(), pA->GetStartPoint(), pA->GetEndPoint(), POLY_PIE );
+ }
+ break;
+
+ case( META_CHORD_ACTION ):
+ {
+ const MetaChordAction* pA = (const MetaChordAction*) pAction;
+ aPoly = Polygon( pA->GetRect(), pA->GetStartPoint(), pA->GetEndPoint(), POLY_CHORD );
+ }
+ break;
+
+ case( META_POLYGON_ACTION ):
+ aPoly = ( (const MetaPolygonAction*) pAction )->GetPolygon();
+ break;
+ }
+
+ if( aPoly.GetSize() )
+ {
+ mpContext->SetPaintAttr( mpVDev->GetLineColor(), mpVDev->GetFillColor() );
+ ImplWritePolygon( aPoly, sal_False, pStyle );
+ }
+ }
+ break;
+
+ case( META_POLYLINE_ACTION ):
+ {
+ const MetaPolyLineAction* pA = (const MetaPolyLineAction*) pAction;
+ const Polygon& rPoly = pA->GetPolygon();
+
+ if( rPoly.GetSize() )
+ {
+ mpContext->SetPaintAttr( mpVDev->GetLineColor(), mpVDev->GetFillColor() );
+ ImplWritePolygon( rPoly, sal_True, pStyle );
+ }
+ }
+ break;
+
+ case( META_POLYPOLYGON_ACTION ):
+ {
+ const MetaPolyPolygonAction* pA = (const MetaPolyPolygonAction*) pAction;
+ const PolyPolygon& rPolyPoly = pA->GetPolyPolygon();
+
+ if( rPolyPoly.Count() )
+ {
+ mpContext->SetPaintAttr( mpVDev->GetLineColor(), mpVDev->GetFillColor() );
+ ImplWritePolyPolygon( rPolyPoly, sal_False, pStyle );
+ }
+ }
+ break;
+
+ case( META_GRADIENT_ACTION ):
+ {
+ const MetaGradientAction* pA = (const MetaGradientAction*) pAction;
+ GDIMetaFile aTmpMtf;
+
+ mpVDev->AddGradientActions( pA->GetRect(), pA->GetGradient(), aTmpMtf );
+ ImplWriteActions( aTmpMtf, pStyle );
+ }
+ break;
+
+ case( META_GRADIENTEX_ACTION ):
+ {
+ const MetaGradientExAction* pA = (const MetaGradientExAction*) pAction;
+ ImplWriteGradientEx( pA->GetPolyPolygon(), pA->GetGradient(), pStyle );
+ }
+ break;
+
+ case META_HATCH_ACTION:
+ {
+ const MetaHatchAction* pA = (const MetaHatchAction*) pAction;
+ GDIMetaFile aTmpMtf;
+
+ mpVDev->AddHatchActions( pA->GetPolyPolygon(), pA->GetHatch(), aTmpMtf );
+ ImplWriteActions( aTmpMtf, pStyle );
+ }
+ break;
+
+ case( META_TRANSPARENT_ACTION ):
+ {
+ const MetaTransparentAction* pA = (const MetaTransparentAction*) pAction;
+ const PolyPolygon& rPolyPoly = pA->GetPolyPolygon();
+
+ if( rPolyPoly.Count() )
+ {
+ mpContext->SetPaintAttr( mpVDev->GetLineColor(), mpVDev->GetFillColor() );
+ ImplWritePolyPolygon( rPolyPoly, sal_False, pStyle );
+ }
+ }
+ break;
+
+ case( META_FLOATTRANSPARENT_ACTION ):
+ {
+ const MetaFloatTransparentAction* pA = (const MetaFloatTransparentAction*) pAction;
+ GDIMetaFile aTmpMtf( pA->GetGDIMetaFile() );
+ Point aSrcPt( aTmpMtf.GetPrefMapMode().GetOrigin() );
+ const Size aSrcSize( aTmpMtf.GetPrefSize() );
+ const Point aDestPt( pA->GetPoint() );
+ const Size aDestSize( pA->GetSize() );
+ const double fScaleX = aSrcSize.Width() ? (double) aDestSize.Width() / aSrcSize.Width() : 1.0;
+ const double fScaleY = aSrcSize.Height() ? (double) aDestSize.Height() / aSrcSize.Height() : 1.0;
+ long nMoveX, nMoveY;
+
+ if( fScaleX != 1.0 || fScaleY != 1.0 )
+ {
+ aTmpMtf.Scale( fScaleX, fScaleY );
+ aSrcPt.X() = FRound( aSrcPt.X() * fScaleX ), aSrcPt.Y() = FRound( aSrcPt.Y() * fScaleY );
+ }
+
+ nMoveX = aDestPt.X() - aSrcPt.X(), nMoveY = aDestPt.Y() - aSrcPt.Y();
+
+ if( nMoveX || nMoveY )
+ aTmpMtf.Move( nMoveX, nMoveY );
+
+ mpVDev->Push();
+ ImplWriteActions( aTmpMtf, pStyle );
+ mpVDev->Pop();
+ }
+ break;
+
+ case( META_EPS_ACTION ):
+ {
+ const MetaEPSAction* pA = (const MetaEPSAction*) pAction;
+ const GDIMetaFile aGDIMetaFile( pA->GetSubstitute() );
+ sal_Bool bFound = sal_False;
+
+ for( ULONG j = 0, nCount2 = aGDIMetaFile.GetActionCount(); ( j < nCount2 ) && !bFound; j++ )
+ {
+ const MetaAction* pSubstAct = aGDIMetaFile.GetAction( j );
+
+ if( pSubstAct->GetType() == META_BMPSCALE_ACTION )
+ {
+ bFound = sal_True;
+ const MetaBmpScaleAction* pBmpScaleAction = (const MetaBmpScaleAction*) pSubstAct;
+ mpContext->SetPaintAttr( mpVDev->GetLineColor(), mpVDev->GetFillColor() );
+ ImplWriteBmp( pBmpScaleAction->GetBitmap(),
+ pA->GetPoint(), pA->GetSize(),
+ Point(), pBmpScaleAction->GetBitmap().GetSizePixel(), pStyle );
+ }
+ }
+ }
+ break;
+
+ case( META_COMMENT_ACTION ):
+ {
+ const MetaCommentAction* pA = (const MetaCommentAction*) pAction;
+ String aSkipComment;
+
+ if( pA->GetComment().CompareIgnoreCaseToAscii( "XGRAD_SEQ_BEGIN" ) == COMPARE_EQUAL )
+ {
+ const MetaGradientExAction* pGradAction = NULL;
+ sal_Bool bDone = sal_False;
+
+ while( !bDone && ( ++i < nCount ) )
+ {
+ pAction = rMtf.GetAction( i );
+
+ if( pAction->GetType() == META_GRADIENTEX_ACTION )
+ pGradAction = (const MetaGradientExAction*) pAction;
+ else if( ( pAction->GetType() == META_COMMENT_ACTION ) &&
+ ( ( (const MetaCommentAction*) pAction )->GetComment().CompareIgnoreCaseToAscii( "XGRAD_SEQ_END" ) == COMPARE_EQUAL ) )
+ {
+ bDone = sal_True;
+ }
+ }
+
+ if( pGradAction )
+ ImplWriteGradientEx( pGradAction->GetPolyPolygon(), pGradAction->GetGradient(), pStyle );
+ }
+ }
+ break;
+
+ case( META_BMP_ACTION ):
+ {
+ const MetaBmpAction* pA = (const MetaBmpAction*) pAction;
+
+ mpContext->SetPaintAttr( mpVDev->GetLineColor(), mpVDev->GetFillColor() );
+ ImplWriteBmp( pA->GetBitmap(),
+ pA->GetPoint(), mpVDev->PixelToLogic( pA->GetBitmap().GetSizePixel() ),
+ Point(), pA->GetBitmap().GetSizePixel(), pStyle );
+ }
+ break;
+
+ case( META_BMPSCALE_ACTION ):
+ {
+ const MetaBmpScaleAction* pA = (const MetaBmpScaleAction*) pAction;
+
+ mpContext->SetPaintAttr( mpVDev->GetLineColor(), mpVDev->GetFillColor() );
+ ImplWriteBmp( pA->GetBitmap(),
+ pA->GetPoint(), pA->GetSize(),
+ Point(), pA->GetBitmap().GetSizePixel(), pStyle );
+ }
+ break;
+
+ case( META_BMPSCALEPART_ACTION ):
+ {
+ const MetaBmpScalePartAction* pA = (const MetaBmpScalePartAction*) pAction;
+
+ mpContext->SetPaintAttr( mpVDev->GetLineColor(), mpVDev->GetFillColor() );
+ ImplWriteBmp( pA->GetBitmap(),
+ pA->GetDestPoint(), pA->GetDestSize(),
+ pA->GetSrcPoint(), pA->GetSrcSize(), pStyle );
+ }
+ break;
+
+ case( META_BMPEX_ACTION ):
+ {
+ const MetaBmpExAction* pA = (const MetaBmpExAction*) pAction;
+
+ mpContext->SetPaintAttr( mpVDev->GetLineColor(), mpVDev->GetFillColor() );
+ ImplWriteBmp( pA->GetBitmapEx(),
+ pA->GetPoint(), mpVDev->PixelToLogic( pA->GetBitmapEx().GetSizePixel() ),
+ Point(), pA->GetBitmapEx().GetSizePixel(), pStyle );
+ }
+ break;
+
+ case( META_BMPEXSCALE_ACTION ):
+ {
+ const MetaBmpExScaleAction* pA = (const MetaBmpExScaleAction*) pAction;
+
+ mpContext->SetPaintAttr( mpVDev->GetLineColor(), mpVDev->GetFillColor() );
+ ImplWriteBmp( pA->GetBitmapEx(),
+ pA->GetPoint(), pA->GetSize(),
+ Point(), pA->GetBitmapEx().GetSizePixel(), pStyle );
+ }
+ break;
+
+ case( META_BMPEXSCALEPART_ACTION ):
+ {
+ const MetaBmpExScalePartAction* pA = (const MetaBmpExScalePartAction*) pAction;
+
+ mpContext->SetPaintAttr( mpVDev->GetLineColor(), mpVDev->GetFillColor() );
+ ImplWriteBmp( pA->GetBitmapEx(),
+ pA->GetDestPoint(), pA->GetDestSize(),
+ pA->GetSrcPoint(), pA->GetSrcSize(), pStyle );
+ }
+ break;
+
+ case( META_TEXT_ACTION ):
+ {
+ const MetaTextAction* pA = (const MetaTextAction*) pAction;
+
+ mpContext->SetFontAttr( mpVDev->GetFont() );
+ mpContext->SetPaintAttr( COL_TRANSPARENT, mpVDev->GetFont().GetColor() );
+ ImplWriteText( pA->GetPoint(), String( pA->GetText(), pA->GetIndex(), pA->GetLen() ), NULL, 0, pStyle );
+ }
+ break;
+
+ case( META_TEXTRECT_ACTION ):
+ {
+ const MetaTextRectAction* pA = (const MetaTextRectAction*) pAction;
+
+ mpContext->SetFontAttr( mpVDev->GetFont() );
+ mpContext->SetPaintAttr( COL_TRANSPARENT, mpVDev->GetFont().GetColor() );
+ ImplWriteText( pA->GetRect().TopLeft(), pA->GetText(), NULL, 0, pStyle );
+ }
+ break;
+
+ case( META_TEXTARRAY_ACTION ):
+ {
+ const MetaTextArrayAction* pA = (const MetaTextArrayAction*) pAction;
+ const Point aPos( ImplMap( pA->GetPoint() ) );
+
+ mpContext->SetFontAttr( mpVDev->GetFont() );
+ mpContext->SetPaintAttr( COL_TRANSPARENT, mpVDev->GetFont().GetColor() );
+ ImplWriteText( pA->GetPoint(), String( pA->GetText(), pA->GetIndex(), pA->GetLen() ), pA->GetDXArray(), 0, pStyle );
+ }
+ break;
+
+ case( META_STRETCHTEXT_ACTION ):
+ {
+ const MetaStretchTextAction* pA = (const MetaStretchTextAction*) pAction;
+
+ mpContext->SetFontAttr( mpVDev->GetFont() );
+ mpContext->SetPaintAttr( COL_TRANSPARENT, mpVDev->GetFont().GetColor() );
+ ImplWriteText( pA->GetPoint(), String( pA->GetText(), pA->GetIndex(), pA->GetLen() ), NULL, pA->GetWidth(), pStyle );
+ }
+ break;
+
+ case( META_CLIPREGION_ACTION ):
+ case( META_ISECTRECTCLIPREGION_ACTION ):
+ case( META_ISECTREGIONCLIPREGION_ACTION ):
+ case( META_MOVECLIPREGION_ACTION ):
+ {
+ ( (MetaAction*) pAction )->Execute( mpVDev );
+ mbClipAttrChanged = sal_True;
+ }
+ break;
+
+ case( META_REFPOINT_ACTION ):
+ case( META_MAPMODE_ACTION ):
+ case( META_LINECOLOR_ACTION ):
+ case( META_FILLCOLOR_ACTION ):
+ case( META_TEXTLINECOLOR_ACTION ):
+ case( META_TEXTFILLCOLOR_ACTION ):
+ case( META_TEXTCOLOR_ACTION ):
+ case( META_TEXTALIGN_ACTION ):
+ case( META_FONT_ACTION ):
+ case( META_PUSH_ACTION ):
+ case( META_POP_ACTION ):
+ {
+ ( (MetaAction*) pAction )->Execute( mpVDev );
+ }
+ break;
+
+ case( META_RASTEROP_ACTION ):
+ case( META_MASK_ACTION ):
+ case( META_MASKSCALE_ACTION ):
+ case( META_MASKSCALEPART_ACTION ):
+ case( META_WALLPAPER_ACTION ):
+ case( META_TEXTLINE_ACTION ):
+ case( META_LAYOUTMODE_ACTION ):
+ {
+ // !!! >>> we don't want to support these actions
+ }
+ break;
+
+#ifdef DBG_UTIL
+ default :
+ ByteString aDbgOut( "SVGActionWriter::ImplWriteActions: unsupported MetaAction #" );
+ aDbgOut.Append( ByteString::CreateFromInt32( nType ) );
+ DBG_ERROR( aDbgOut.GetBuffer() );
+ break;
+#endif
+ }
+ }
+
+ ImplReleaseContext();
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/svg/svgaction.hxx b/extensions/source/svg/svgaction.hxx
new file mode 100644
index 000000000000..9ec1e887f86e
--- /dev/null
+++ b/extensions/source/svg/svgaction.hxx
@@ -0,0 +1,167 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _SVGACTION_HXX
+#define _SVGACTION_HXX
+
+#include "svgcom.hxx"
+
+// --------------
+// - FastString -
+// --------------
+
+class FastString
+{
+private:
+
+ NMSP_RTL::OUString maString;
+ sal_Unicode* mpBuffer;
+ sal_uInt32 mnBufLen;
+ sal_uInt32 mnCurLen;
+ sal_uInt32 mnBufInc;
+ sal_uInt32 mnPartPos;
+
+public:
+
+ FastString( sal_uInt32 nInitLen = 2048, sal_uInt32 nIncrement = 2048 );
+ FastString( sal_Char* pBufferForBase64Encoding, sal_uInt32 nBufLen );
+ ~FastString();
+
+ FastString& operator+=( const NMSP_RTL::OUString& rStr );
+
+ const NMSP_RTL::OUString& GetString() const;
+ sal_Bool GetFirstPartString( const sal_uInt32 nPartLen, NMSP_RTL::OUString& rPartString );
+ sal_Bool GetNextPartString( const sal_uInt32 nPartLen, NMSP_RTL::OUString& rPartString );
+
+ sal_uInt32 GetLength() const { return mnCurLen; }
+ void Clear() { mnCurLen = 0, maString = NMSP_RTL::OUString(); }
+};
+
+// ----------------------
+// - SVGAttributeWriter -
+// ----------------------
+
+class SVGActionWriter;
+
+class SVGAttributeWriter
+{
+private:
+
+ Font maCurFont;
+ Color maCurLineColor;
+ Color maCurFillColor;
+ SVGActionWriter& mrParent;
+ SvXMLExport& mrExport;
+ SvXMLElementExport* mpElemFont;
+ SvXMLElementExport* mpElemPaint;
+
+ SVGAttributeWriter();
+
+public:
+
+ SVGAttributeWriter( SVGActionWriter& rParent, SvXMLExport& rExport );
+ virtual ~SVGAttributeWriter();
+
+ NMSP_RTL::OUString GetFontStyle( const Font& rFont );
+ NMSP_RTL::OUString GetPaintStyle( const Color& rLineColor, const Color& rFillColor );
+
+ void SetFontAttr( const Font& rFont );
+ void SetPaintAttr( const Color& rLineColor, const Color& rFillColor );
+};
+
+// -------------------
+// - SVGActionWriter -
+// -------------------
+
+class SVGAttributeWriter;
+class SvXMLExport;
+class GDIMetaFile;
+
+class SVGActionWriter
+{
+ friend class SVGAttributeWriter;
+
+private:
+
+ Stack maContextStack;
+ SvXMLExport& mrExport;
+ const GDIMetaFile& mrMtf;
+ SVGAttributeWriter* mpContext;
+ VirtualDevice* mpVDev;
+ MapMode maTargetMapMode;
+ sal_Int32 mnCurClipId;
+ sal_Bool mbDestroyVDev;
+ sal_Bool mbPaintAttrChanged;
+ sal_Bool mbFontAttrChanged;
+ sal_Bool mbClipAttrChanged;
+ sal_Bool mbDoublePoints;
+
+ SVGAttributeWriter* ImplAcquireContext() { maContextStack.Push( mpContext = new SVGAttributeWriter( *this, mrExport ) ); return mpContext; }
+ void ImplReleaseContext() { delete (SVGAttributeWriter*) maContextStack.Pop(); mpContext = (SVGAttributeWriter*) maContextStack.Top(); }
+
+ long ImplMap( sal_Int32 nVal ) const;
+ Point ImplMap( const Point& rPt ) const;
+ Size ImplMap( const Size& rSz ) const;
+ inline Rectangle ImplMap( const Rectangle& rRect ) const { return Rectangle( ImplMap( rRect.TopLeft() ), ImplMap( rRect.GetSize() ) ); }
+
+ void ImplWriteLine( const Point& rPt1, const Point& rPt2, const Color* pLineColor = NULL, const NMSP_RTL::OUString* pStyle = NULL );
+ void ImplWriteRect( const Rectangle& rRect, long nRadX = 0, long nRadY = 0, const NMSP_RTL::OUString* pStyle = NULL );
+ void ImplWriteEllipse( const Point& rCenter, long nRadX, long nRadY, const NMSP_RTL::OUString* pStyle = NULL );
+ void ImplWritePolygon( const Polygon& rPoly, sal_Bool bLineOnly, const NMSP_RTL::OUString* pStyle = NULL );
+ void ImplWritePolyPolygon( const PolyPolygon& rPolyPoly, sal_Bool bLineOnly, const NMSP_RTL::OUString* pStyle = NULL );
+ void ImplWriteGradientEx( const PolyPolygon& rPolyPoly, const Gradient& rGradient, const NMSP_RTL::OUString* pStyle = NULL );
+ void ImplWriteText( const Point& rPos, const String& rText, const sal_Int32* pDXArray, long nWidth, const NMSP_RTL::OUString* pStyle = NULL );
+ void ImplWriteBmp( const BitmapEx& rBmpEx, const Point& rPt, const Size& rSz, const Point& rSrcPt, const Size& rSrcSz, const NMSP_RTL::OUString* pStyle = NULL );
+
+ void ImplCheckFontAttributes();
+ void ImplCheckPaintAttributes();
+
+ void ImplWriteActions( const GDIMetaFile& rMtf, const NMSP_RTL::OUString* pStyle = NULL );
+
+ sal_Int32 ImplGetNextClipId() { return mnCurClipId++; }
+
+ SVGActionWriter();
+
+public:
+
+ static NMSP_RTL::OUString GetValueString( sal_Int32 nVal, sal_Bool bDoublePoints );
+
+public:
+
+ SVGActionWriter( SvXMLExport& rExport, const GDIMetaFile& rMtf,
+ VirtualDevice* pParentVDev = NULL,
+ sal_Bool bWriteDoublePoints = sal_False );
+ virtual ~SVGActionWriter();
+
+ const VirtualDevice& GetVDev() const { return *mpVDev; }
+ BOOL HasDoublePoints() const { return mbDoublePoints; }
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/svg/svgcom.hxx b/extensions/source/svg/svgcom.hxx
new file mode 100644
index 000000000000..20ac4c24ee54
--- /dev/null
+++ b/extensions/source/svg/svgcom.hxx
@@ -0,0 +1,77 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _SVGCOM_HXX
+#define _SVGCOM_HXX
+
+#include <cppuhelper/weak.hxx>
+#include <rtl/ustring.hxx>
+#include <tools/debug.hxx>
+#include <tools/stream.hxx>
+#include <tools/string.hxx>
+#include <tools/urlobj.hxx>
+#include <tools/stack.hxx>
+#include <vcl/salbtype.hxx>
+#include <vcl/gdimtf.hxx>
+#include <vcl/metaact.hxx>
+
+#include <com/sun/star/uno/Reference.h>
+#include <com/sun/star/uno/RuntimeException.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/lang/XComponent.hpp>
+#include <com/sun/star/registry/XRegistryKey.hpp>
+#include <com/sun/star/lang/XComponent.hpp>
+#include <com/sun/star/io/XInputStream.hpp>
+#include <com/sun/star/io/XOutputStream.hpp>
+#include <com/sun/star/xml/sax/XDocumentHandler.hpp>
+#include <com/sun/star/xml/sax/XExtendedDocumentHandler.hpp>
+#include <com/sun/star/svg/XSVGWriter.hpp>
+#include <com/sun/star/svg/XSVGPrinter.hpp>
+#include <xmloff/xmlexp.hxx>
+#include <xmloff/nmspmap.hxx>
+
+// -----------------------------------------------------------------------------
+
+#define NMSP_CPPU cppu
+#define NMSP_RTL rtl
+#define NMSP_UNO com::sun::star::uno
+#define NMSP_LANG com::sun::star::lang
+#define NMSP_SAX com::sun::star::xml::sax
+#define NMSP_SVG com::sun::star::svg
+#define NMSP_REGISTRY com::sun::star::registry
+
+
+#define REF( _def_Obj ) NMSP_UNO::Reference< _def_Obj >
+#define SEQ( _def_Obj ) NMSP_UNO::Sequence< _def_Obj >
+#define ANY NMSP_UNO::Any
+#define B2UCONST( _def_pChar ) (NMSP_RTL::OUString(RTL_CONSTASCII_USTRINGPARAM(_def_pChar )))
+#define SVG_DTD_STRING B2UCONST( "<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\" \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">" )
+
+#endif // _SYNCCOM_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/svg/svgprinter.cxx b/extensions/source/svg/svgprinter.cxx
new file mode 100644
index 000000000000..b52a181ccb38
--- /dev/null
+++ b/extensions/source/svg/svgprinter.cxx
@@ -0,0 +1,331 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+
+#define _RMPRINTER_EXT
+
+#include "svgprinter.hxx"
+#include "svgaction.hxx"
+#include <uno/mapping.hxx>
+#include <vcl/print.hxx>
+#include <vcl/virdev.hxx>
+
+static const char aXMLElemSVG[] = "svg";
+static const char aXMLElemMetaSVG[] = "staroffice:svgElementMeta";
+static const char aXMLElemDesc[] = "desc";
+static const char aXMLElemMeta[] = "metadata";
+static const char aXMLElemRect[] = "rect";
+
+static const char aXMLAttrMetaSVGOuter[] = "isOuterElement";
+static const char aXMLAttrMetaSVGPage[] = "isPageElement";
+static const char aXMLAttrViewBox[] = "viewBox";
+static const char aXMLAttrX[] = "x";
+static const char aXMLAttrY[] = "y";
+static const char aXMLAttrWidth[] = "width";
+static const char aXMLAttrHeight[] = "height";
+
+// ----------------
+// - SVGMtfExport -
+// ----------------
+
+class SVGPrinterExport : public SvXMLExport
+{
+private:
+
+ Printer maPrinter;
+ VirtualDevice* mpVDev;
+ SvXMLElementExport* mpOuterElement;
+ sal_uInt32 mnPage;
+
+ SVGPrinterExport();
+
+ SvXMLElementExport* ImplCreateSVGElement( const JobSetup& rSetup, Size& rOutputSize );
+ void ImplWriteMetaAttr( sal_Bool bOuter, sal_Bool bPage );
+
+protected:
+
+ virtual void _ExportMeta() {}
+ virtual void _ExportStyles( BOOL /*bUsed*/ ) {}
+ virtual void _ExportAutoStyles() {}
+ virtual void _ExportContent() {}
+ virtual void _ExportMasterStyles() {}
+ virtual sal_uInt32 exportDoc( enum ::xmloff::token::XMLTokenEnum eClass = ::xmloff::token::XML_TOKEN_INVALID ) { (void)eClass; return 0; }
+
+public:
+
+ // #110680#
+ SVGPrinterExport(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xServiceFactory,
+ const REF( NMSP_SAX::XDocumentHandler )& rxHandler,
+ const JobSetup& rSetup,
+ const NMSP_RTL::OUString& rJobName,
+ sal_uInt32 nCopies,
+ sal_Bool bCollate );
+
+ virtual ~SVGPrinterExport();
+
+ virtual void writePage( const JobSetup& rJobSetup, const GDIMetaFile& rMtf );
+};
+
+// -----------------------------------------------------------------------------
+
+// #110680#
+SVGPrinterExport::SVGPrinterExport(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xServiceFactory,
+ const REF( NMSP_SAX::XDocumentHandler )& rxHandler,
+ const JobSetup& rSetup,
+ const NMSP_RTL::OUString& rJobName,
+ sal_uInt32 /*nCopies*/,
+ sal_Bool /*bCollate*/ )
+: SvXMLExport( xServiceFactory, NMSP_RTL::OUString(), rxHandler ),
+ mpVDev( NULL ),
+ mnPage( 0 )
+{
+ maPrinter.SetJobSetup( rSetup );
+
+ GetDocHandler()->startDocument();
+
+ REF( NMSP_SAX::XExtendedDocumentHandler ) xExtDocHandler( GetDocHandler(), NMSP_UNO::UNO_QUERY );
+
+ if( xExtDocHandler.is() )
+ {
+ NMSP_RTL::OUString aString;
+ const NMSP_RTL::OUString aLineFeed( NMSP_RTL::OUString::valueOf( (sal_Unicode) 0x0a ) );
+
+ // intro
+ xExtDocHandler->unknown( ( aString = SVG_DTD_STRING ) += aLineFeed );
+ xExtDocHandler->unknown( ( aString = B2UCONST( "<!ELEMENT metadata (#PCDATA | staroffice:svgElementMeta)*> " ) += aLineFeed ) );
+ xExtDocHandler->unknown( ( aString = B2UCONST( "<!ELEMENT staroffice:svgElementMeta ANY> " ) += aLineFeed ) );
+ xExtDocHandler->unknown( ( aString = B2UCONST( "<!ATTLIST staroffice:svgElementMeta " ) += aLineFeed ) );
+
+ // ATTLIST
+ xExtDocHandler->unknown( ( aString = B2UCONST( "isOuterElement (true | false) \"false\" " ) += aLineFeed ) );
+ xExtDocHandler->unknown( ( aString = B2UCONST( "isPageElement (true | false) \"true\"" ) += aLineFeed ) );
+
+ // end of intro
+ xExtDocHandler->unknown( ( aString = B2UCONST( ">" ) += aLineFeed ) );
+ xExtDocHandler->unknown( ( aString = B2UCONST( "]>" ) ) );
+ }
+
+ // create outer element
+ Size aOutputSize;
+
+ mpOuterElement = ImplCreateSVGElement( rSetup, aOutputSize );
+
+ // write description
+ SvXMLElementExport* pDescElem = new SvXMLElementExport( *this, XML_NAMESPACE_NONE, aXMLElemDesc, TRUE, TRUE );
+ NMSP_RTL::OUString aDesc( B2UCONST( "document name: " ) );
+
+ GetDocHandler()->characters( aDesc += rJobName );
+ delete pDescElem;
+
+ // write meta attributes
+ ImplWriteMetaAttr( TRUE, FALSE );
+}
+
+// -----------------------------------------------------------------------------
+
+SVGPrinterExport::~SVGPrinterExport()
+{
+ delete mpOuterElement;
+ GetDocHandler()->endDocument();
+ delete mpVDev;
+}
+
+// -----------------------------------------------------------------------------
+
+SvXMLElementExport* SVGPrinterExport::ImplCreateSVGElement( const JobSetup& rSetup, Size& rOutputSize )
+{
+ NMSP_RTL::OUString aAttr;
+
+ delete mpVDev;
+ mpVDev = new VirtualDevice;
+ mpVDev->EnableOutput( FALSE );
+ mpVDev->SetMapMode( MAP_100TH_MM );
+ maPrinter.SetJobSetup( rSetup );
+
+ rOutputSize = maPrinter.PixelToLogic( maPrinter.GetOutputSizePixel(), mpVDev->GetMapMode() );
+
+ aAttr = SVGActionWriter::GetValueString( rOutputSize.Width(), sal_True );
+ AddAttribute( XML_NAMESPACE_NONE, aXMLAttrWidth, aAttr );
+
+ aAttr = SVGActionWriter::GetValueString( rOutputSize.Height(), sal_True );
+ AddAttribute( XML_NAMESPACE_NONE, aXMLAttrHeight, aAttr );
+
+ aAttr = B2UCONST( "0.0 0.0 " );
+ aAttr += SVGActionWriter::GetValueString( rOutputSize.Width(), sal_True );
+ aAttr += B2UCONST( " " );
+ aAttr += SVGActionWriter::GetValueString( rOutputSize.Height(), sal_True );
+ AddAttribute( XML_NAMESPACE_NONE, aXMLAttrViewBox, aAttr );
+
+ return( new SvXMLElementExport( *this, XML_NAMESPACE_NONE, aXMLElemSVG, TRUE, TRUE ) );
+}
+
+// -----------------------------------------------------------------------------
+
+void SVGPrinterExport::ImplWriteMetaAttr( sal_Bool bOuter, sal_Bool bPage )
+{
+ SvXMLElementExport aMetaData( *this, XML_NAMESPACE_NONE, aXMLElemMeta, TRUE, TRUE );
+ NMSP_RTL::OUString aAttr;
+
+ aAttr = bOuter ? B2UCONST( "true" ) : B2UCONST( "false" );
+ AddAttribute( XML_NAMESPACE_NONE, aXMLAttrMetaSVGOuter, aAttr );
+
+ aAttr = bPage ? B2UCONST( "true" ) : B2UCONST( "false" );
+ AddAttribute( XML_NAMESPACE_NONE, aXMLAttrMetaSVGPage, aAttr );
+
+ {
+ delete( new SvXMLElementExport( *this, XML_NAMESPACE_NONE, aXMLElemMetaSVG, TRUE, TRUE ) );
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+void SVGPrinterExport::writePage( const JobSetup& rSetup, const GDIMetaFile& rMtf )
+{
+ Size aOutputSize;
+ NMSP_RTL::OUString aAttr;
+ SvXMLElementExport* pPageElem = ImplCreateSVGElement( rSetup, aOutputSize );
+
+ // write description
+ SvXMLElementExport* pDescElem = new SvXMLElementExport( *this, XML_NAMESPACE_NONE, aXMLElemDesc, TRUE, TRUE );
+ NMSP_RTL::OUString aDesc( B2UCONST( "page: " ) );
+
+ GetDocHandler()->characters( aDesc += NMSP_RTL::OUString::valueOf( (sal_Int32) ++mnPage ) );
+ delete pDescElem;
+
+ // write meta attributes
+ ImplWriteMetaAttr( FALSE, TRUE );
+
+ // write dummy rect element
+ aAttr = B2UCONST( "0.0" );
+ AddAttribute( XML_NAMESPACE_NONE, aXMLAttrX, aAttr );
+ AddAttribute( XML_NAMESPACE_NONE, aXMLAttrY, aAttr );
+
+ aAttr = SVGActionWriter::GetValueString( aOutputSize.Width(), sal_True );
+ AddAttribute( XML_NAMESPACE_NONE, aXMLAttrWidth, aAttr );
+
+ aAttr = SVGActionWriter::GetValueString( aOutputSize.Height(), sal_True );
+ AddAttribute( XML_NAMESPACE_NONE, aXMLAttrHeight, aAttr );
+
+ delete( new SvXMLElementExport( *this, XML_NAMESPACE_NONE, aXMLElemRect, TRUE, TRUE ) );
+ delete( new SVGActionWriter( *this, rMtf, mpVDev, TRUE ) );
+
+ delete pPageElem;
+}
+
+// --------------
+// - SVGPrinter -
+// --------------
+
+SVGPrinter::SVGPrinter( const REF( NMSP_LANG::XMultiServiceFactory )& rxMgr ) :
+ mxFact( rxMgr ),
+ mpWriter( NULL )
+{
+}
+
+// -----------------------------------------------------------------------------
+
+SVGPrinter::~SVGPrinter()
+{
+ delete mpWriter;
+}
+
+// -----------------------------------------------------------------------------
+
+
+ANY SAL_CALL SVGPrinter::queryInterface( const NMSP_UNO::Type & rType ) throw( NMSP_UNO::RuntimeException )
+{
+ const ANY aRet( NMSP_CPPU::queryInterface( rType, static_cast< NMSP_SVG::XSVGPrinter* >( this ) ) );
+
+ return( aRet.hasValue() ? aRet : OWeakObject::queryInterface( rType ) );
+}
+
+// -----------------------------------------------------------------------------
+
+void SAL_CALL SVGPrinter::acquire() throw()
+{
+ OWeakObject::acquire();
+}
+
+// -----------------------------------------------------------------------------
+
+void SAL_CALL SVGPrinter::release() throw()
+{
+ OWeakObject::release();
+}
+
+// -----------------------------------------------------------------------------
+
+sal_Bool SAL_CALL SVGPrinter::startJob( const REF( NMSP_SAX::XDocumentHandler )& rxHandler,
+ const SEQ( sal_Int8 )& rJobSetupSeq,
+ const NMSP_RTL::OUString& rJobName,
+ sal_uInt32 nCopies, sal_Bool bCollate ) throw( NMSP_UNO::RuntimeException )
+{
+ const sal_Bool bRet = ( mpWriter == NULL );
+
+ if( bRet )
+ {
+ SvMemoryStream aMemStm( (char*) rJobSetupSeq.getConstArray(), rJobSetupSeq.getLength(), STREAM_READ );
+ JobSetup aJobSetup;
+
+ aMemStm.SetCompressMode( COMPRESSMODE_FULL );
+ aMemStm >> aJobSetup;
+
+ const REF( NMSP_SAX::XDocumentHandler ) xDocumentHandler( rxHandler );
+
+ // #110680#
+ // mpWriter = new SVGPrinterExport( xDocumentHandler, aJobSetup, rJobName, nCopies, bCollate );
+ mpWriter = new SVGPrinterExport( mxFact, xDocumentHandler, aJobSetup, rJobName, nCopies, bCollate );
+ }
+
+ return bRet;
+}
+
+// -----------------------------------------------------------------------------
+
+void SAL_CALL SVGPrinter::printPage( const SEQ( sal_Int8 )& rPrintPage ) throw( NMSP_UNO::RuntimeException )
+{
+ SvMemoryStream aMemStm( (char*) rPrintPage.getConstArray(), rPrintPage.getLength(), STREAM_READ );
+ PrinterPage aPage;
+
+ aMemStm.SetCompressMode( COMPRESSMODE_FULL );
+ aMemStm >> aPage;
+ mpWriter->writePage( aPage.GetJobSetup(), *aPage.GetGDIMetaFile() );
+}
+
+// -----------------------------------------------------------------------------
+
+void SAL_CALL SVGPrinter::endJob() throw( NMSP_UNO::RuntimeException )
+{
+ delete mpWriter, mpWriter = NULL;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/svg/svgprinter.hxx b/extensions/source/svg/svgprinter.hxx
new file mode 100644
index 000000000000..24b6bfcf0e13
--- /dev/null
+++ b/extensions/source/svg/svgprinter.hxx
@@ -0,0 +1,70 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _SVGPRINTER_HXX
+#define _SVGPRINTER_HXX
+
+#include "svgcom.hxx"
+
+// -------------
+// - SVGWriter -
+// -------------
+
+class SVGPrinterExport;
+
+class SVGPrinter : public NMSP_CPPU::OWeakObject, NMSP_SVG::XSVGPrinter
+{
+private:
+
+ REF( NMSP_LANG::XMultiServiceFactory ) mxFact;
+ SVGPrinterExport* mpWriter;
+
+ SVGPrinter();
+
+public:
+
+ SVGPrinter( const REF( NMSP_LANG::XMultiServiceFactory )& rxMgr );
+ virtual ~SVGPrinter();
+
+ // XInterface
+ virtual ANY SAL_CALL queryInterface( const NMSP_UNO::Type & rType ) throw( NMSP_UNO::RuntimeException );
+ virtual void SAL_CALL acquire() throw();
+ virtual void SAL_CALL release() throw();
+
+ // XSVGPrinter
+ virtual sal_Bool SAL_CALL startJob( const REF( NMSP_SAX::XDocumentHandler )& rxHandler,
+ const SEQ( sal_Int8 )& rJobSetup,
+ const NMSP_RTL::OUString& rJobName,
+ sal_uInt32 nCopies, sal_Bool bCollate ) throw( NMSP_UNO::RuntimeException );
+ virtual void SAL_CALL printPage( const SEQ( sal_Int8 )& rPrintPage ) throw( NMSP_UNO::RuntimeException );
+ virtual void SAL_CALL endJob() throw( NMSP_UNO::RuntimeException );
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/svg/svguno.cxx b/extensions/source/svg/svguno.cxx
new file mode 100644
index 000000000000..e94761253d34
--- /dev/null
+++ b/extensions/source/svg/svguno.cxx
@@ -0,0 +1,131 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+
+#include "svgcom.hxx"
+#include "svgwriter.hxx"
+#include "svgprinter.hxx"
+
+#include <cppuhelper/factory.hxx>
+#include <uno/mapping.hxx>
+
+// -------------------
+// - factory methods -
+// -------------------
+
+static REF( NMSP_UNO::XInterface ) SAL_CALL create_SVGWriter( const REF( NMSP_LANG::XMultiServiceFactory )& rxFact )
+{
+ return REF( NMSP_UNO::XInterface )( *new SVGWriter( rxFact ) );
+}
+
+// -----------------------------------------------------------------------------
+
+static REF( NMSP_UNO::XInterface ) SAL_CALL create_SVGPrinter( const REF( NMSP_LANG::XMultiServiceFactory )& rxFact )
+{
+ return REF( NMSP_UNO::XInterface )( *new SVGPrinter( rxFact ) );
+}
+
+// ------------------------------------------
+// - component_getImplementationEnvironment -
+// ------------------------------------------
+
+extern "C" void SAL_CALL component_getImplementationEnvironment( const sal_Char ** ppEnvTypeName, uno_Environment ** /*ppEnv*/ )
+{
+ *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
+}
+
+// -----------------------
+// - component_writeInfo -
+// -----------------------
+
+extern "C" sal_Bool SAL_CALL component_writeInfo( void* /*pServiceManager*/, void* pRegistryKey )
+{
+ sal_Bool bRet = sal_False;
+
+ if( pRegistryKey )
+ {
+ try
+ {
+ REF( NMSP_REGISTRY::XRegistryKey ) xNewKey1(
+ static_cast< NMSP_REGISTRY::XRegistryKey* >( pRegistryKey )->createKey(
+ B2UCONST( "/com.sun.star.comp.extensions.SVGWriter/UNO/SERVICES/com.sun.star.svg.SVGWriter" ) ) );
+ REF( NMSP_REGISTRY::XRegistryKey ) xNewKey2(
+ static_cast< NMSP_REGISTRY::XRegistryKey* >( pRegistryKey )->createKey(
+ B2UCONST( "/com.sun.star.comp.extensions.SVGPrinter/UNO/SERVICES/com.sun.star.svg.SVGPrinter" ) ) );
+
+ bRet = sal_True;
+ }
+ catch( NMSP_REGISTRY::InvalidRegistryException& )
+ {
+ OSL_ENSURE( sal_False, "### InvalidRegistryException!" );
+ }
+ }
+
+ return bRet;
+}
+
+// ------------------------
+// - component_getFactory -
+// ------------------------
+
+extern "C" void* SAL_CALL component_getFactory( const sal_Char* pImplName, void* pServiceManager, void* /*pRegistryKey*/ )
+{
+ REF( NMSP_LANG::XSingleServiceFactory ) xFactory;
+ void* pRet = 0;
+
+ if( rtl_str_compare( pImplName, "com.sun.star.comp.extensions.SVGWriter" ) == 0 )
+ {
+ const NMSP_RTL::OUString aServiceName( B2UCONST( "com.sun.star.svg.SVGWriter" ) );
+
+ xFactory = REF( NMSP_LANG::XSingleServiceFactory )( NMSP_CPPU::createSingleFactory(
+ reinterpret_cast< NMSP_LANG::XMultiServiceFactory* >( pServiceManager ),
+ B2UCONST( "com.sun.star.comp.extensions.SVGWriter" ),
+ create_SVGWriter, SEQ( NMSP_RTL::OUString )( &aServiceName, 1 ) ) );
+ }
+ else if( rtl_str_compare( pImplName, "com.sun.star.comp.extensions.SVGPrinter" ) == 0 )
+ {
+ const NMSP_RTL::OUString aServiceName( B2UCONST( "com.sun.star.svg.SVGPrinter" ) );
+
+ xFactory = REF( NMSP_LANG::XSingleServiceFactory )( NMSP_CPPU::createSingleFactory(
+ reinterpret_cast< NMSP_LANG::XMultiServiceFactory* >( pServiceManager ),
+ B2UCONST( "com.sun.star.comp.extensions.SVGPrinter" ),
+ create_SVGPrinter, SEQ( NMSP_RTL::OUString )( &aServiceName, 1 ) ) );
+ }
+
+ if( xFactory.is() )
+ {
+ xFactory->acquire();
+ pRet = xFactory.get();
+ }
+
+ return pRet;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/svg/svgwriter.cxx b/extensions/source/svg/svgwriter.cxx
new file mode 100644
index 000000000000..3116199d92b4
--- /dev/null
+++ b/extensions/source/svg/svgwriter.cxx
@@ -0,0 +1,178 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+
+#include "svgwriter.hxx"
+#include "svgaction.hxx"
+#include <uno/mapping.hxx>
+
+// ----------------
+// - SVGMtfExport -
+// ----------------
+
+class SVGMtfExport : public SvXMLExport
+{
+private:
+
+ SVGMtfExport();
+
+protected:
+
+ virtual void _ExportMeta() {}
+ virtual void _ExportStyles( BOOL /*bUsed*/ ) {}
+ virtual void _ExportAutoStyles() {}
+ virtual void _ExportContent() {}
+ virtual void _ExportMasterStyles() {}
+ virtual sal_uInt32 exportDoc( enum ::xmloff::token::XMLTokenEnum /*eClass*/ ) { return 0; }
+
+public:
+
+ // #110680#
+ SVGMtfExport(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xServiceFactory,
+ const REF( NMSP_SAX::XDocumentHandler )& rxHandler );
+
+ virtual ~SVGMtfExport();
+
+ virtual void writeMtf( const GDIMetaFile& rMtf );
+};
+
+// -----------------------------------------------------------------------------
+
+// #110680#
+SVGMtfExport::SVGMtfExport(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xServiceFactory,
+ const REF( NMSP_SAX::XDocumentHandler )& rxHandler )
+: SvXMLExport( xServiceFactory, NMSP_RTL::OUString(), rxHandler )
+{
+ GetDocHandler()->startDocument();
+}
+
+// -----------------------------------------------------------------------------
+
+SVGMtfExport::~SVGMtfExport()
+{
+ GetDocHandler()->endDocument();
+}
+
+// -----------------------------------------------------------------------------
+
+void SVGMtfExport::writeMtf( const GDIMetaFile& rMtf )
+{
+ const Size aSize( OutputDevice::LogicToLogic( rMtf.GetPrefSize(), rMtf.GetPrefMapMode(), MAP_MM ) );
+ NMSP_RTL::OUString aAttr;
+ REF( NMSP_SAX::XExtendedDocumentHandler ) xExtDocHandler( GetDocHandler(), NMSP_UNO::UNO_QUERY );
+
+ if( xExtDocHandler.is() )
+ xExtDocHandler->unknown( SVG_DTD_STRING );
+
+ aAttr = NMSP_RTL::OUString::valueOf( aSize.Width() );
+ aAttr += B2UCONST( "mm" );
+ AddAttribute( XML_NAMESPACE_NONE, "width", aAttr );
+
+ aAttr = NMSP_RTL::OUString::valueOf( aSize.Height() );
+ aAttr += B2UCONST( "mm" );
+ AddAttribute( XML_NAMESPACE_NONE, "height", aAttr );
+
+ aAttr = B2UCONST( "0 0 " );
+ aAttr += NMSP_RTL::OUString::valueOf( aSize.Width() * 100L );
+ aAttr += B2UCONST( " " );
+ aAttr += NMSP_RTL::OUString::valueOf( aSize.Height() * 100L );
+ AddAttribute( XML_NAMESPACE_NONE, "viewBox", aAttr );
+
+ {
+ SvXMLElementExport aSVG( *this, XML_NAMESPACE_NONE, "svg", TRUE, TRUE );
+ SVGActionWriter* pWriter = new SVGActionWriter( *this, rMtf );
+
+ delete pWriter;
+ }
+}
+
+// -------------
+// - SVGWriter -
+// -------------
+
+SVGWriter::SVGWriter( const REF( NMSP_LANG::XMultiServiceFactory )& rxMgr ) :
+ mxFact( rxMgr )
+{
+}
+
+// -----------------------------------------------------------------------------
+
+SVGWriter::~SVGWriter()
+{
+}
+
+// -----------------------------------------------------------------------------
+
+
+ANY SAL_CALL SVGWriter::queryInterface( const NMSP_UNO::Type & rType ) throw( NMSP_UNO::RuntimeException )
+{
+ const ANY aRet( NMSP_CPPU::queryInterface( rType, static_cast< NMSP_SVG::XSVGWriter* >( this ) ) );
+
+ return( aRet.hasValue() ? aRet : OWeakObject::queryInterface( rType ) );
+}
+
+// -----------------------------------------------------------------------------
+
+void SAL_CALL SVGWriter::acquire() throw()
+{
+ OWeakObject::acquire();
+}
+
+// -----------------------------------------------------------------------------
+
+void SAL_CALL SVGWriter::release() throw()
+{
+ OWeakObject::release();
+}
+
+// -----------------------------------------------------------------------------
+
+void SAL_CALL SVGWriter::write( const REF( NMSP_SAX::XDocumentHandler )& rxDocHandler,
+ const SEQ( sal_Int8 )& rMtfSeq ) throw( NMSP_UNO::RuntimeException )
+{
+ SvMemoryStream aMemStm( (char*) rMtfSeq.getConstArray(), rMtfSeq.getLength(), STREAM_READ );
+ GDIMetaFile aMtf;
+
+ aMemStm.SetCompressMode( COMPRESSMODE_FULL );
+ aMemStm >> aMtf;
+
+ const REF( NMSP_SAX::XDocumentHandler ) xDocumentHandler( rxDocHandler );
+
+ // #110680#
+ // SVGMtfExport* pWriter = new SVGMtfExport( xDocumentHandler );
+ SVGMtfExport* pWriter = new SVGMtfExport( mxFact, xDocumentHandler );
+
+ pWriter->writeMtf( aMtf );
+ delete pWriter;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/svg/svgwriter.hxx b/extensions/source/svg/svgwriter.hxx
new file mode 100644
index 000000000000..0da9762e2447
--- /dev/null
+++ b/extensions/source/svg/svgwriter.hxx
@@ -0,0 +1,63 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _SVGWRITER_HXX
+#define _SVGWRITER_HXX
+
+#include "svgcom.hxx"
+
+// -------------
+// - SVGWriter -
+// -------------
+
+class SVGWriter : public NMSP_CPPU::OWeakObject, NMSP_SVG::XSVGWriter
+{
+private:
+
+ REF( NMSP_LANG::XMultiServiceFactory ) mxFact;
+
+ SVGWriter();
+
+public:
+
+ SVGWriter( const REF( NMSP_LANG::XMultiServiceFactory )& rxMgr );
+ virtual ~SVGWriter();
+
+ // XInterface
+ virtual ANY SAL_CALL queryInterface( const NMSP_UNO::Type & rType ) throw( NMSP_UNO::RuntimeException );
+ virtual void SAL_CALL acquire() throw();
+ virtual void SAL_CALL release() throw();
+
+ // XSVGWriter
+ virtual void SAL_CALL write( const REF( NMSP_SAX::XDocumentHandler )& rxDocHandler,
+ const SEQ( sal_Int8 )& rMtfSeq ) throw( NMSP_UNO::RuntimeException );
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/unoactivex/main/initwindowpeer.cxx b/extensions/source/unoactivex/main/initwindowpeer.cxx
new file mode 100644
index 000000000000..195f5811e6a9
--- /dev/null
+++ b/extensions/source/unoactivex/main/initwindowpeer.cxx
@@ -0,0 +1,89 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+
+#include "initwindowpeer.hxx"
+
+using namespace ::com::sun::star;
+
+
+uno::Any SAL_CALL InitWindowPeer::getWindowHandle( const uno::Sequence< sal_Int8 >& ProcessId, sal_Int16 SystemType )
+ throw ( uno::RuntimeException )
+{
+ uno::Any aRes;
+ sal_Int32 nHwnd = (sal_Int32)m_hwnd;
+ aRes <<= nHwnd;
+ return aRes;
+}
+
+
+uno::Reference< awt::XToolkit > SAL_CALL InitWindowPeer::getToolkit()
+ throw ( uno::RuntimeException )
+{
+ return uno::Reference< awt::XToolkit >();
+}
+
+void SAL_CALL InitWindowPeer::setPointer( const uno::Reference< awt::XPointer >& Pointer )
+ throw ( uno::RuntimeException )
+{
+}
+
+void SAL_CALL InitWindowPeer::setBackground( sal_Int32 Color )
+ throw ( uno::RuntimeException )
+{
+}
+
+void SAL_CALL InitWindowPeer::invalidate( sal_Int16 Flags )
+ throw ( uno::RuntimeException )
+{
+}
+
+void SAL_CALL InitWindowPeer::invalidateRect( const awt::Rectangle& Rect, sal_Int16 Flags )
+ throw ( uno::RuntimeException )
+{
+}
+
+void SAL_CALL InitWindowPeer::dispose()
+ throw ( uno::RuntimeException )
+{
+}
+
+void SAL_CALL InitWindowPeer::addEventListener( const uno::Reference< lang::XEventListener >& xListener )
+ throw ( uno::RuntimeException )
+{
+}
+
+void SAL_CALL InitWindowPeer::removeEventListener( const uno::Reference< lang::XEventListener >& aListener )
+ throw ( uno::RuntimeException )
+{
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/update/check/Addons.xcu b/extensions/source/update/check/Addons.xcu
new file mode 100644
index 000000000000..8794ce858073
--- /dev/null
+++ b/extensions/source/update/check/Addons.xcu
@@ -0,0 +1,26 @@
+<?xml version='1.0' encoding='UTF-8'?>
+
+<oor:component-data oor:name="Addons" oor:package="org.openoffice.Office" xmlns:install="http://openoffice.org/2004/installation" xmlns:oor="http://openoffice.org/2001/registry" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <node oor:name="AddonUI">
+ <node oor:name="OfficeHelp">
+ <node oor:name="UpdateCheckJob" oor:op="replace">
+ <prop oor:name="URL" oor:type="xs:string">
+ <value>vnd.sun.star.job:alias=UpdateCheck</value>
+ </prop>
+ <prop oor:name="ImageIdentifier" oor:type="xs:string">
+ <value/>
+ </prop>
+ <prop oor:name="Title" oor:type="xs:string">
+ <value xml:lang="en-US">Check for ~Updates...</value>
+ </prop>
+ <prop oor:name="Target" oor:type="xs:string">
+ <value>_self</value>
+ </prop>
+ <prop oor:name="Context" oor:type="xs:string">
+ <value/>
+ </prop>
+ </node>
+ </node>
+ </node>
+</oor:component-data>
+
diff --git a/extensions/source/update/check/Jobs.xcu b/extensions/source/update/check/Jobs.xcu
new file mode 100644
index 000000000000..ed324650c66f
--- /dev/null
+++ b/extensions/source/update/check/Jobs.xcu
@@ -0,0 +1,42 @@
+<?xml version='1.0' encoding='UTF-8'?>
+
+<oor:component-data oor:name="Jobs" oor:package="org.openoffice.Office" xmlns:install="http://openoffice.org/2004/installation" xmlns:oor="http://openoffice.org/2001/registry" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <node oor:name="Jobs">
+ <node oor:name="UpdateCheck" oor:op="replace">
+ <prop oor:name="Service">
+ <value>com.sun.star.setup.UpdateCheck</value>
+ </prop>
+ <node oor:name="Arguments">
+ <prop oor:name="AutoCheckEnabled" oor:type="xs:boolean" oor:op="replace">
+ <value>false</value>
+ </prop>
+ <prop oor:name="LastCheck" oor:type="xs:long" oor:op="replace">
+ <value>0</value>
+ </prop>
+ <prop oor:name="CheckInterval" oor:type="xs:long" oor:op="replace">
+ <value>604800</value>
+ </prop>
+ <prop oor:name="DownloadDestination" oor:type="xs:string" oor:op="replace">
+ <value></value>
+ </prop>
+ <prop oor:name="AutoDownloadEnabled" oor:type="xs:boolean" oor:op="replace">
+ <value>false</value>
+ </prop>
+ <prop oor:name="DownloadSupported" oor:type="xs:boolean" oor:op="replace">
+ <value>true</value>
+ </prop>
+ <prop oor:name="DownloadPaused" oor:type="xs:boolean" oor:op="replace">
+ <value>false</value>
+ </prop>
+ </node>
+ </node>
+ </node>
+ <node oor:name="Events">
+ <node oor:name="onFirstVisibleTask" oor:op="fuse">
+ <node oor:name="JobList">
+ <node oor:name="UpdateCheck" oor:op="replace"/>
+ </node>
+ </node>
+ </node>
+</oor:component-data>
+
diff --git a/extensions/source/update/check/actionlistener.hxx b/extensions/source/update/check/actionlistener.hxx
new file mode 100644
index 000000000000..e5df3dd5ad52
--- /dev/null
+++ b/extensions/source/update/check/actionlistener.hxx
@@ -0,0 +1,48 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef INCLUDED_ACTION_LISTENER_HXX
+#define INCLUDED_ACTION_LISTENER_HXX
+
+#include <rtl/ref.hxx>
+
+class IActionListener : public rtl::IReference
+{
+ public:
+
+ virtual void cancel() = 0;
+ virtual void download() = 0;
+ virtual void install() = 0;
+ virtual void pause() = 0;
+ virtual void resume() = 0;
+ virtual void closeAfterFailure() = 0;
+};
+
+#endif //INCLUDED_ACTION_LISTENER_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/update/check/download.cxx b/extensions/source/update/check/download.cxx
new file mode 100644
index 000000000000..ff1905be1cf2
--- /dev/null
+++ b/extensions/source/update/check/download.cxx
@@ -0,0 +1,463 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+
+#if defined WNT
+#ifdef _MSC_VER
+#pragma warning(push, 1) /* disable warnings within system headers */
+#endif
+#include <curl/curl.h>
+#ifdef _MSC_VER
+#pragma warning(pop)
+#endif
+#else
+#include <curl/curl.h>
+#endif
+#include <com/sun/star/beans/PropertyValue.hpp>
+#include <com/sun/star/container/XNameAccess.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+
+#include "download.hxx"
+
+namespace beans = com::sun::star::beans ;
+namespace container = com::sun::star::container ;
+namespace lang = com::sun::star::lang ;
+namespace uno = com::sun::star::uno ;
+
+#define UNISTRING(s) rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(s))
+
+
+struct OutData
+{
+ rtl::Reference< DownloadInteractionHandler >Handler;
+ rtl::OUString File;
+ rtl::OUString DestinationDir;
+ oslFileHandle FileHandle;
+ sal_uInt64 Offset;
+ osl::Condition& StopCondition;
+ CURL *curl;
+
+ OutData(osl::Condition& rCondition) : FileHandle(NULL), Offset(0), StopCondition(rCondition), curl(NULL) {};
+};
+
+//------------------------------------------------------------------------------
+
+static void openFile( OutData& out )
+{
+ char * effective_url;
+ curl_easy_getinfo(out.curl, CURLINFO_EFFECTIVE_URL, &effective_url);
+
+ double fDownloadSize;
+ curl_easy_getinfo(out.curl, CURLINFO_CONTENT_LENGTH_DOWNLOAD, &fDownloadSize);
+
+ rtl::OString aURL(effective_url);
+
+ // ensure no trailing '/'
+ sal_Int32 nLen = aURL.getLength();
+ while( (nLen > 0) && ('/' == aURL[nLen-1]) )
+ aURL = aURL.copy(0, --nLen);
+
+ // extract file name last '/'
+ sal_Int32 nIndex = aURL.lastIndexOf('/');
+ if( nIndex > 0 )
+ {
+ out.File = out.DestinationDir + rtl::OStringToOUString(aURL.copy(nIndex), RTL_TEXTENCODING_UTF8);
+
+ oslFileError rc;
+
+ // Give the user an overwrite warning if the target file exists
+ const sal_Int32 openFlags = osl_File_OpenFlag_Write | osl_File_OpenFlag_Create;
+ do
+ {
+ rc = osl_openFile(out.File.pData, &out.FileHandle, openFlags);
+
+ if( osl_File_E_EXIST == rc && ! out.Handler->downloadTargetExists(out.File) )
+ {
+ out.StopCondition.set();
+ break;
+ }
+
+ } while( osl_File_E_EXIST == rc );
+
+ if( osl_File_E_None == rc )
+ out.Handler->downloadStarted(out.File, (sal_Int64) fDownloadSize);
+ }
+}
+
+//------------------------------------------------------------------------------
+
+static inline rtl::OString
+getStringValue(const uno::Reference< container::XNameAccess >& xNameAccess, const rtl::OUString& aName)
+{
+ rtl::OString aRet;
+
+ OSL_ASSERT(xNameAccess->hasByName(aName));
+ uno::Any aValue = xNameAccess->getByName(aName);
+
+ return rtl::OUStringToOString(aValue.get<rtl::OUString>(), RTL_TEXTENCODING_UTF8);
+}
+
+//------------------------------------------------------------------------------
+
+static inline sal_Int32
+getInt32Value(const uno::Reference< container::XNameAccess >& xNameAccess,
+ const rtl::OUString& aName, sal_Int32 nDefault=-1)
+{
+ OSL_ASSERT(xNameAccess->hasByName(aName));
+ uno::Any aValue = xNameAccess->getByName(aName);
+
+ sal_Int32 n=nDefault;
+ aValue >>= n;
+ return n;
+}
+
+//------------------------------------------------------------------------------
+
+static size_t
+write_function( void *ptr, size_t size, size_t nmemb, void *stream )
+{
+ OutData *out = reinterpret_cast < OutData * > (stream);
+
+ if( NULL == out->FileHandle )
+ openFile(*out);
+
+ sal_uInt64 nBytesWritten = 0;
+
+ if( NULL != out->FileHandle )
+ osl_writeFile(out->FileHandle, ptr, size * nmemb, &nBytesWritten);
+
+ return (size_t) nBytesWritten;
+}
+
+//------------------------------------------------------------------------------
+
+static int
+progress_callback( void *clientp, double dltotal, double dlnow, double ultotal, double ulnow )
+{
+ (void) ultotal;
+ (void) ulnow;
+
+ OutData *out = reinterpret_cast < OutData * > (clientp);
+
+ OSL_ASSERT( out );
+
+ if( ! out->StopCondition.check() )
+ {
+ double fPercent = 0;
+ if ( dltotal + out->Offset )
+ fPercent = (dlnow + out->Offset) * 100 / (dltotal + out->Offset);
+ if( fPercent < 0 )
+ fPercent = 0;
+
+ // Do not report progress for redirection replies
+ long nCode;
+ curl_easy_getinfo(out->curl, CURLINFO_RESPONSE_CODE, &nCode);
+ if( (nCode != 302) && (nCode != 303) && (dltotal > 0) )
+ out->Handler->downloadProgressAt((sal_Int8)fPercent);
+
+ return 0;
+ }
+
+ // If stop condition is set, return non 0 value to abort
+ return -1;
+}
+
+//------------------------------------------------------------------------------
+
+void
+Download::getProxyForURL(const rtl::OUString& rURL, rtl::OString& rHost, sal_Int32& rPort) const
+{
+ if( !m_xContext.is() )
+ throw uno::RuntimeException(
+ UNISTRING( "Download: empty component context" ),
+ uno::Reference< uno::XInterface >() );
+
+ uno::Reference< lang::XMultiComponentFactory > xServiceManager(m_xContext->getServiceManager());
+
+ if( !xServiceManager.is() )
+ throw uno::RuntimeException(
+ UNISTRING( "Download: unable to obtain service manager from component context" ),
+ uno::Reference< uno::XInterface >() );
+
+ uno::Reference< lang::XMultiServiceFactory > xConfigProvider(
+ xServiceManager->createInstanceWithContext( UNISTRING( "com.sun.star.configuration.ConfigurationProvider" ), m_xContext ),
+ uno::UNO_QUERY_THROW);
+
+ beans::PropertyValue aProperty;
+ aProperty.Name = UNISTRING( "nodepath" );
+ aProperty.Value = uno::makeAny( UNISTRING("org.openoffice.Inet/Settings") );
+
+ uno::Sequence< uno::Any > aArgumentList( 1 );
+ aArgumentList[0] = uno::makeAny( aProperty );
+
+ uno::Reference< container::XNameAccess > xNameAccess(
+ xConfigProvider->createInstanceWithArguments(
+ UNISTRING("com.sun.star.configuration.ConfigurationAccess"), aArgumentList ),
+ uno::UNO_QUERY_THROW );
+
+ OSL_ASSERT(xNameAccess->hasByName(UNISTRING("ooInetProxyType")));
+ uno::Any aValue = xNameAccess->getByName(UNISTRING("ooInetProxyType"));
+
+ sal_Int32 nProxyType = aValue.get< sal_Int32 >();
+ if( 0 != nProxyType ) // type 0 means "direct connection to the internet
+ {
+ if( rURL.matchAsciiL(RTL_CONSTASCII_STRINGPARAM("http:")) )
+ {
+ rHost = getStringValue(xNameAccess, UNISTRING("ooInetHTTPProxyName"));
+ rPort = getInt32Value(xNameAccess, UNISTRING("ooInetHTTPProxyPort"));
+ }
+ else if( rURL.matchAsciiL(RTL_CONSTASCII_STRINGPARAM("https:")) )
+ {
+ rHost = getStringValue(xNameAccess, UNISTRING("ooInetHTTPSProxyName"));
+ rPort = getInt32Value(xNameAccess, UNISTRING("ooInetHTTPSProxyPort"));
+ }
+ else if( rURL.matchAsciiL(RTL_CONSTASCII_STRINGPARAM("ftp:")) )
+ {
+ rHost = getStringValue(xNameAccess, UNISTRING("ooInetFTPProxyName"));
+ rPort = getInt32Value(xNameAccess, UNISTRING("ooInetFTPProxyPort"));
+ }
+ }
+}
+
+//------------------------------------------------------------------------------
+
+bool curl_run(const rtl::OUString& rURL, OutData& out, const rtl::OString& aProxyHost, sal_Int32 nProxyPort)
+{
+ /* Need to investigate further whether it is necessary to call
+ * curl_global_init or not - leave it for now (as the ftp UCB content
+ * provider does as well).
+ */
+
+ CURL * pCURL = curl_easy_init();
+ bool ret = false;
+
+ if( NULL != pCURL )
+ {
+ out.curl = pCURL;
+
+ rtl::OString aURL(rtl::OUStringToOString(rURL, RTL_TEXTENCODING_UTF8));
+ curl_easy_setopt(pCURL, CURLOPT_URL, aURL.getStr());
+
+ // abort on http errors
+ curl_easy_setopt(pCURL, CURLOPT_FAILONERROR, 1);
+
+ // enable redirection
+ curl_easy_setopt(pCURL, CURLOPT_FOLLOWLOCATION, 1);
+
+ // write function
+ curl_easy_setopt(pCURL, CURLOPT_WRITEDATA, &out);
+ curl_easy_setopt(pCURL, CURLOPT_WRITEFUNCTION, &write_function);
+
+ // progress handler - Condition::check unfortunatly is not defined const
+ curl_easy_setopt(pCURL, CURLOPT_NOPROGRESS, 0);
+ curl_easy_setopt(pCURL, CURLOPT_PROGRESSFUNCTION, &progress_callback);
+ curl_easy_setopt(pCURL, CURLOPT_PROGRESSDATA, &out);
+
+ // proxy
+ curl_easy_setopt(pCURL, CURLOPT_PROXY, aProxyHost.getStr());
+ curl_easy_setopt(pCURL, CURLOPT_PROXYTYPE, CURLPROXY_HTTP);
+ if( -1 != nProxyPort )
+ curl_easy_setopt(pCURL, CURLOPT_PROXYPORT, nProxyPort);
+
+ if( out.Offset > 0 )
+ {
+ // curl_off_t offset = nOffset; libcurl seems to be compiled with large
+ // file support (and we not) ..
+ sal_Int64 offset = (sal_Int64) out.Offset;
+ curl_easy_setopt(pCURL, CURLOPT_RESUME_FROM_LARGE, offset);
+ }
+
+ CURLcode cc = curl_easy_perform(pCURL);
+
+ // treat zero byte downloads as errors
+ if( NULL == out.FileHandle )
+ openFile(out);
+
+ if( CURLE_OK == cc )
+ {
+ out.Handler->downloadFinished(out.File);
+ ret = true;
+ }
+
+ if ( CURLE_PARTIAL_FILE == cc )
+ {
+ // this sometimes happens, when a user throws away his user data, but has already
+ // completed the download of an update.
+ double fDownloadSize;
+ curl_easy_getinfo( pCURL, CURLINFO_CONTENT_LENGTH_DOWNLOAD, &fDownloadSize );
+ if ( -1 == fDownloadSize )
+ {
+ out.Handler->downloadFinished(out.File);
+ ret = true;
+ }
+ }
+
+ // Avoid target file being removed
+ else if( (CURLE_ABORTED_BY_CALLBACK == cc) || out.StopCondition.check() )
+ ret = true;
+
+ // Only report errors when not stopped
+ else
+ {
+ rtl::OString aMessage(RTL_CONSTASCII_STRINGPARAM("Unknown error"));
+
+ const char * error_message = curl_easy_strerror(cc);
+ if( NULL != error_message )
+ aMessage = error_message;
+
+ if ( CURLE_HTTP_RETURNED_ERROR == cc )
+ {
+ long nError;
+ curl_easy_getinfo( pCURL, CURLINFO_RESPONSE_CODE, &nError );
+
+ if ( 403 == nError )
+ aMessage += rtl::OString( RTL_CONSTASCII_STRINGPARAM( " 403: Access denied!" ) );
+ else if ( 404 == nError )
+ aMessage += rtl::OString( RTL_CONSTASCII_STRINGPARAM( " 404: File not found!" ) );
+ else if ( 416 == nError )
+ {
+ // we got this error probably, because we already downloaded the file
+ out.Handler->downloadFinished(out.File);
+ ret = true;
+ }
+ else
+ {
+ aMessage += rtl::OString( RTL_CONSTASCII_STRINGPARAM( ":error code = " ) );
+ aMessage += aMessage.valueOf( nError );
+ aMessage += rtl::OString( RTL_CONSTASCII_STRINGPARAM( " !" ) );
+ }
+ }
+ if ( !ret )
+ out.Handler->downloadStalled( rtl::OStringToOUString(aMessage, RTL_TEXTENCODING_UTF8) );
+ }
+
+ curl_easy_cleanup(pCURL);
+ }
+
+ return ret;
+}
+
+//------------------------------------------------------------------------------
+
+bool
+Download::start(const rtl::OUString& rURL, const rtl::OUString& rFile, const rtl::OUString& rDestinationDir)
+{
+ OSL_ASSERT( m_aHandler.is() );
+
+ OutData out(m_aCondition);
+ rtl::OUString aFile( rFile );
+
+ // when rFile is empty, there is no remembered file name. If there is already a file with the
+ // same name ask the user if she wants to resume a download or restart the download
+ if ( !aFile.getLength() )
+ {
+ // GetFileName()
+ rtl::OUString aURL( rURL );
+ // ensure no trailing '/'
+ sal_Int32 nLen = aURL.getLength();
+ while( (nLen > 0) && ('/' == aURL[ nLen-1 ]) )
+ aURL = aURL.copy( 0, --nLen );
+
+ // extract file name last '/'
+ sal_Int32 nIndex = aURL.lastIndexOf('/');
+ aFile = rDestinationDir + aURL.copy( nIndex );
+
+ // check for existing file
+ oslFileError rc = osl_openFile( aFile.pData, &out.FileHandle, osl_File_OpenFlag_Write | osl_File_OpenFlag_Create );
+ osl_closeFile(out.FileHandle);
+ out.FileHandle = NULL;
+
+ if( osl_File_E_EXIST == rc )
+ {
+ if ( m_aHandler->checkDownloadDestination( aURL.copy( nIndex+1 ) ) )
+ {
+ osl_removeFile( aFile.pData );
+ aFile = rtl::OUString();
+ }
+ else
+ m_aHandler->downloadStarted( aFile, 0 );
+ }
+ else
+ {
+ osl_removeFile( aFile.pData );
+ aFile = rtl::OUString();
+ }
+ }
+
+ out.File = aFile;
+ out.DestinationDir = rDestinationDir;
+ out.Handler = m_aHandler;
+
+ if( aFile.getLength() > 0 )
+ {
+ oslFileError rc = osl_openFile(aFile.pData, &out.FileHandle, osl_File_OpenFlag_Write);
+
+ if( osl_File_E_None == rc )
+ {
+ // Set file pointer to the end of the file on resume
+ if( osl_File_E_None == osl_setFilePos(out.FileHandle, osl_Pos_End, 0) )
+ {
+ osl_getFilePos(out.FileHandle, &out.Offset);
+ }
+ }
+ else if( osl_File_E_NOENT == rc ) // file has been deleted meanwhile ..
+ out.File = rtl::OUString();
+ }
+
+ rtl::OString aProxyHost;
+ sal_Int32 nProxyPort = -1;
+ getProxyForURL(rURL, aProxyHost, nProxyPort);
+
+ bool ret = curl_run(rURL, out, aProxyHost, nProxyPort);
+
+ if( NULL != out.FileHandle )
+ {
+ osl_syncFile(out.FileHandle);
+ osl_closeFile(out.FileHandle);
+
+// #i90930# Don't remove already downloaded bits, when curl_run reports an error
+// because later calls might be successful
+// if( ! ret )
+// osl_removeFile(out.File.pData);
+ }
+
+ m_aCondition.reset();
+ return ret;
+}
+
+//------------------------------------------------------------------------------
+
+void
+Download::stop()
+{
+ m_aCondition.set();
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/update/check/download.hxx b/extensions/source/update/check/download.hxx
new file mode 100644
index 000000000000..8aa9e4ea3184
--- /dev/null
+++ b/extensions/source/update/check/download.hxx
@@ -0,0 +1,86 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+
+#include <com/sun/star/uno/XComponentContext.hpp>
+
+#include <rtl/ref.hxx>
+#include <rtl/ustring.hxx>
+#include <osl/conditn.hxx>
+#include <osl/file.h>
+
+struct DownloadInteractionHandler : public rtl::IReference
+{
+ virtual bool checkDownloadDestination(const rtl::OUString& rFileName) = 0;
+
+ // called if the destination file already exists, but resume is false
+ virtual bool downloadTargetExists(const rtl::OUString& rFileName) = 0;
+
+ // called when curl reports an error
+ virtual void downloadStalled(const rtl::OUString& rErrorMessage) = 0;
+
+ // progress handler
+ virtual void downloadProgressAt(sal_Int8 nPercent) = 0;
+
+ // called on first progress notification
+ virtual void downloadStarted(const rtl::OUString& rFileName, sal_Int64 nFileSize) = 0;
+
+ // called when download has been finished
+ virtual void downloadFinished(const rtl::OUString& rFileName) = 0;
+};
+
+
+class Download
+{
+public:
+ Download(const com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext >& xContext,
+ const rtl::Reference< DownloadInteractionHandler >& rHandler) : m_xContext(xContext), m_aHandler(rHandler) {};
+
+ // returns true when the content of rURL was successfully written to rLocalFile
+ bool start(const rtl::OUString& rURL, const rtl::OUString& rFile, const rtl::OUString& rDestinationDir);
+
+ // stops the download after the next write operation
+ void stop();
+
+ // returns true if the stop condition is set
+ bool isStopped() const
+ { return sal_True == const_cast <Download *> (this)->m_aCondition.check(); };
+
+protected:
+
+ // Determines the appropriate proxy settings for the given URL. Returns true if a proxy should be used
+ void getProxyForURL(const rtl::OUString& rURL, rtl::OString& rHost, sal_Int32& rPort) const;
+
+private:
+ osl::Condition m_aCondition;
+ const com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext >& m_xContext;
+ const rtl::Reference< DownloadInteractionHandler > m_aHandler;
+};
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/update/check/makefile.mk b/extensions/source/update/check/makefile.mk
new file mode 100644
index 000000000000..9f5f544102dd
--- /dev/null
+++ b/extensions/source/update/check/makefile.mk
@@ -0,0 +1,134 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+PRJ=..$/..$/..
+
+PRJNAME=extensions
+TARGET=updchk
+PACKAGE=org.openoffice.Office
+
+LIBTARGET=NO
+ENABLE_EXCEPTIONS=TRUE
+
+ABSXCSROOT=$(SOLARXMLDIR)
+XCSROOT=..
+DTDDIR=$(ABSXCSROOT)
+XSLDIR=$(ABSXCSROOT)$/processing
+PROCESSOUT=$(MISC)$/$(TARGET)
+PROCESSORDIR=$(SOLARBINDIR)
+
+# no validation by inspector class
+NO_INSPECTION=TRUE
+
+# --- Settings ---
+
+.INCLUDE : settings.mk
+
+# no "lib" prefix
+DLLPRE =
+
+# --- Files ---
+
+SRS2NAME=$(TARGET)
+SRC2FILES=\
+ updatehdl.src
+
+RESLIB2NAME=upd
+RESLIB2SRSFILES= $(SRS)$/updchk.srs
+RESLIB2DEPN= updatehdl.src updatehdl.hrc
+
+SLOFILES=\
+ $(SLO)$/download.obj \
+ $(SLO)$/updatecheck.obj \
+ $(SLO)$/updatecheckjob.obj \
+ $(SLO)$/updatecheckconfig.obj \
+ $(SLO)$/updateprotocol.obj \
+ $(SLO)$/updatehdl.obj
+
+SHL1NOCHECK=TRUE
+SHL1TARGET=$(TARGET).uno
+SHL1OBJS=$(SLOFILES)
+SHL1DEF=$(MISC)$/$(SHL1TARGET).def
+
+SHL1IMPLIB=i$(SHL1TARGET)
+SHL1STDLIBS= \
+ $(CPPUHELPERLIB) \
+ $(CPPULIB) \
+ $(CURLLIB) \
+ $(SALLIB) \
+ $(SHELL32LIB) \
+ $(OLE32LIB)
+
+SHL1VERSIONMAP=$(SOLARENV)/src/component.map
+SHL1DEF=$(MISC)$/$(SHL1TARGET).def
+DEF1NAME=$(SHL1TARGET)
+
+PACKAGEDIR=$(subst,.,$/ $(PACKAGE))
+SPOOLDIR=$(MISC)$/registry$/spool
+
+XCUFILES= \
+ Addons.xcu \
+ Jobs.xcu
+
+MYXCUFILES= \
+ $(SPOOLDIR)$/$(PACKAGEDIR)$/Addons$/Addons-onlineupdate.xcu \
+ $(SPOOLDIR)$/$(PACKAGEDIR)$/Jobs$/Jobs-onlineupdate.xcu
+
+LOCALIZEDFILES= \
+ Addons.xcu \
+ Jobs.xcu
+
+.IF "$(test)" != ""
+APP1TARGET=updateprotocoltest
+APP1STDLIBS= $(SHL1STDLIBS)
+APP1OBJS= \
+ $(SLO)$/updateprotocol.obj \
+ $(SLO)$/updateprotocoltest.obj
+
+
+.ENDIF # "$(test)" != ""
+
+# --- Targets ---
+
+.INCLUDE : target.mk
+
+ALLTAR : $(MYXCUFILES)
+
+.IF "$(WITH_LANG)"!=""
+XCU_SOURCEDIR:=$(PROCESSOUT)$/merge$/$(PACKAGEDIR)
+.ELSE # "$(WITH_LANG)"!=""
+XCU_SOURCEDIR:=.
+.ENDIF # "$(WITH_LANG)"!=""
+
+$(SPOOLDIR)$/$(PACKAGEDIR)$/Addons$/Addons-onlineupdate.xcu : $(XCU_SOURCEDIR)$/Addons.xcu
+ @-$(MKDIRHIER) $(@:d)
+ @$(COPY) $< $@
+
+$(SPOOLDIR)$/$(PACKAGEDIR)$/Jobs$/Jobs-onlineupdate.xcu : $(XCU_SOURCEDIR)$/Jobs.xcu
+ @-$(MKDIRHIER) $(@:d)
+ @$(COPY) $< $@
+# @$(PERL) transform.pl < $< > $@
+
diff --git a/extensions/source/update/check/transform.pl b/extensions/source/update/check/transform.pl
new file mode 100644
index 000000000000..760acf55e60e
--- /dev/null
+++ b/extensions/source/update/check/transform.pl
@@ -0,0 +1,61 @@
+:
+eval 'exec perl -wS $0 ${1+"$@"}'
+ if 0;
+
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+while (<>) {
+
+ if( /<prop/ ) {
+ $prop = $_;
+ next if( /Text/ || /Bubble/ );
+ }
+
+ if( /<\/prop>/ ) {
+ next if( $prop =~ /Text/ || $prop =~ /Bubble/ );
+ }
+
+ if( /xml:lang/ ) {
+ $lang = $_;
+ $lang =~ s/.*xml:lang=\"//;
+ $lang =~ s/\".*//;
+ chomp $lang;
+ $line = $prop;
+ $line =~ s/\" oor:type/_$lang\" oor:type/;
+ print $line;
+ $line = $_;
+ $line =~ s/ xml:lang=\".*\"//;
+ print $line;
+ $line = $prop;
+ $line =~ s/<prop.*/<\/prop>/;
+ print $line;
+ next;
+ }
+
+ print;
+} \ No newline at end of file
diff --git a/extensions/source/update/check/updatecheck.cxx b/extensions/source/update/check/updatecheck.cxx
new file mode 100644
index 000000000000..310d585649e8
--- /dev/null
+++ b/extensions/source/update/check/updatecheck.cxx
@@ -0,0 +1,1691 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+
+#include "updatecheck.hxx"
+
+#include <cppuhelper/implbase1.hxx>
+#include <com/sun/star/beans/XFastPropertySet.hpp>
+#include <com/sun/star/lang/XComponent.hpp>
+#include <com/sun/star/frame/XDesktop.hpp>
+#include <com/sun/star/frame/XFrame.hpp>
+#include <com/sun/star/frame/DispatchResultEvent.hpp>
+#include <com/sun/star/frame/DispatchResultState.hpp>
+#include <com/sun/star/system/XSystemShellExecute.hpp>
+#include <com/sun/star/system/SystemShellExecuteFlags.hpp>
+#include <com/sun/star/task/XJob.hpp>
+#include <com/sun/star/task/XJobExecutor.hpp>
+
+#include <rtl/ustrbuf.hxx>
+
+#include <rtl/bootstrap.hxx>
+#include <osl/process.h>
+#include <osl/module.hxx>
+#include <osl/file.hxx>
+
+#ifdef WNT
+#ifdef _MSC_VER
+#pragma warning(push,1) // disable warnings within system headers
+//#pragma warning(disable: 4917)
+#endif
+#include <objbase.h>
+#ifdef _MSC_VER
+#pragma warning(pop)
+#endif
+#endif
+
+#include "updateprotocol.hxx"
+#include "updatecheckconfig.hxx"
+
+namespace awt = com::sun::star::awt ;
+namespace beans = com::sun::star::beans ;
+namespace container = com::sun::star::container ;
+namespace deployment = com::sun::star::deployment ;
+namespace frame = com::sun::star::frame ;
+namespace lang = com::sun::star::lang ;
+namespace c3s = com::sun::star::system ;
+namespace task = com::sun::star::task ;
+namespace util = com::sun::star::util ;
+namespace uno = com::sun::star::uno ;
+
+#define UNISTRING(s) rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(s))
+
+#define PROPERTY_TITLE UNISTRING("BubbleHeading")
+#define PROPERTY_TEXT UNISTRING("BubbleText")
+#define PROPERTY_IMAGE UNISTRING("BubbleImageURL")
+#define PROPERTY_SHOW_BUBBLE UNISTRING("BubbleVisible")
+#define PROPERTY_CLICK_HDL UNISTRING("MenuClickHDL")
+#define PROPERTY_DEFAULT_TITLE UNISTRING("DefaultHeading")
+#define PROPERTY_DEFAULT_TEXT UNISTRING("DefaultText")
+#define PROPERTY_SHOW_MENUICON UNISTRING("MenuIconVisible")
+
+//------------------------------------------------------------------------------
+
+// Returns the URL of the release note for the given position
+rtl::OUString getReleaseNote(const UpdateInfo& rInfo, sal_uInt8 pos, bool autoDownloadEnabled)
+{
+ std::vector< ReleaseNote >::const_iterator iter = rInfo.ReleaseNotes.begin();
+ while( iter != rInfo.ReleaseNotes.end() )
+ {
+ if( pos == iter->Pos )
+ {
+ if( (pos > 2) || !autoDownloadEnabled || ! (iter->URL2.getLength() > 0) )
+ return iter->URL;
+ }
+ else if( (pos == iter->Pos2) && ((1 == iter->Pos) || (2 == iter->Pos)) && autoDownloadEnabled )
+ return iter->URL2;
+
+ ++iter;
+ }
+
+ return rtl::OUString();
+}
+
+//------------------------------------------------------------------------------
+
+namespace
+{
+
+static inline rtl::OUString getBuildId()
+{
+ rtl::OUString aPathVal(UNISTRING("${$OOO_BASE_DIR/program/" SAL_CONFIGFILE("version") ":buildid}"));
+ rtl::Bootstrap::expandMacros(aPathVal);
+ return aPathVal;
+}
+
+//------------------------------------------------------------------------------
+static inline rtl::OUString getBaseInstallation()
+{
+ rtl::OUString aPathVal(UNISTRING("${$BRAND_BASE_DIR/program/" SAL_CONFIGFILE("bootstrap") ":BaseInstallation}"));
+ rtl::Bootstrap::expandMacros(aPathVal);
+ return aPathVal;
+}
+
+//------------------------------------------------------------------------------
+
+inline bool isObsoleteUpdateInfo(const rtl::OUString& rBuildId)
+{
+ return sal_True != rBuildId.equals(getBuildId()) && rBuildId.getLength() > 0;
+}
+
+
+//------------------------------------------------------------------------------
+
+rtl::OUString getImageFromFileName(const rtl::OUString& aFile)
+{
+#ifndef WNT
+ rtl::OUString aUnpackPath;
+ if( osl_getExecutableFile(&aUnpackPath.pData) == osl_Process_E_None )
+ {
+ sal_uInt32 lastIndex = aUnpackPath.lastIndexOf('/');
+ if ( lastIndex > 0 )
+ {
+ aUnpackPath = aUnpackPath.copy( 0, lastIndex+1 );
+ aUnpackPath += UNISTRING( "unpack_update" );
+ }
+
+ oslFileHandle hOut = NULL;
+ oslProcess hProcess = NULL;
+
+ rtl::OUString aSystemPath;
+ osl::File::getSystemPathFromFileURL(aFile, aSystemPath);
+
+ oslProcessError rc = osl_executeProcess_WithRedirectedIO(
+ aUnpackPath.pData, // [in] Image name
+ &aSystemPath.pData, 1, // [in] Arguments
+ osl_Process_WAIT || osl_Process_NORMAL, // [in] Options
+ NULL, // [in] Security
+ NULL, // [in] Working directory
+ NULL, 0, // [in] Environment variables
+ &hProcess, // [out] Process handle
+ NULL, &hOut, NULL // [out] File handles for redirected I/O
+ );
+
+ if( osl_Process_E_None == rc )
+ {
+ oslProcessInfo aInfo;
+ aInfo.Size = sizeof(oslProcessInfo);
+
+ if( osl_Process_E_None == osl_getProcessInfo(hProcess, osl_Process_EXITCODE, &aInfo) )
+ {
+ if( 0 == aInfo.Code )
+ {
+ sal_Char szBuffer[4096];
+ sal_uInt64 nBytesRead = 0;
+ const sal_uInt64 nBytesToRead = sizeof(szBuffer) - 1;
+
+ rtl::OUString aImageName;
+ while( osl_File_E_None == osl_readFile(hOut, szBuffer, nBytesToRead, &nBytesRead) )
+ {
+ sal_Char *pc = szBuffer + nBytesRead;
+ do
+ {
+ *pc = '\0'; --pc;
+ }
+ while( ('\n' == *pc) || ('\r' == *pc) );
+
+ aImageName += rtl::OUString(szBuffer, pc - szBuffer + 1, osl_getThreadTextEncoding());
+
+ if( nBytesRead < nBytesToRead )
+ break;
+ }
+
+ if( osl::FileBase::E_None == osl::FileBase::getFileURLFromSystemPath(aImageName, aImageName) )
+ return aImageName;
+ }
+ }
+
+ osl_closeFile(hOut);
+ osl_freeProcessHandle(hProcess);
+ }
+ }
+#endif
+
+ return aFile;
+}
+
+
+//------------------------------------------------------------------------------
+
+static uno::Reference< beans::XPropertySet > createMenuBarUI(
+ const uno::Reference< uno::XComponentContext >& xContext,
+ const uno::Reference< task::XJob >& xJob)
+{
+ if( !xContext.is() )
+ throw uno::RuntimeException(
+ UNISTRING( "UpdateCheckJob: empty component context" ), uno::Reference< uno::XInterface > () );
+
+ uno::Reference< lang::XMultiComponentFactory > xServiceManager(xContext->getServiceManager());
+ if( !xServiceManager.is() )
+ throw uno::RuntimeException(
+ UNISTRING( "UpdateCheckJob: unable to obtain service manager from component context" ), uno::Reference< uno::XInterface > () );
+
+ uno::Reference< beans::XPropertySet > xMenuBarUI =
+ uno::Reference< beans::XPropertySet > (
+ xServiceManager->createInstanceWithContext( UNISTRING( "com.sun.star.setup.UpdateCheckUI" ), xContext ),
+ uno::UNO_QUERY_THROW);
+
+ xMenuBarUI->setPropertyValue( PROPERTY_CLICK_HDL, uno::makeAny( xJob ) );
+
+ return xMenuBarUI;
+}
+
+//------------------------------------------------------------------------------
+
+
+
+typedef sal_Bool (* OnlineCheckFunc) ();
+
+class UpdateCheckThread : public WorkerThread
+{
+
+public:
+ UpdateCheckThread( osl::Condition& rCondition,
+ const uno::Reference<uno::XComponentContext>& xContext );
+
+ virtual void SAL_CALL join();
+ virtual void SAL_CALL terminate();
+ virtual void SAL_CALL cancel();
+
+protected:
+ virtual ~UpdateCheckThread();
+
+ virtual void SAL_CALL run();
+ virtual void SAL_CALL onTerminated();
+
+ /* Wrapper around checkForUpdates */
+ bool runCheck( bool & rbExtensionsChecked );
+
+private:
+
+ /* Used to avoid dialup login windows (on platforms we know how to double this) */
+ inline bool hasInternetConnection() const
+ {
+ if(m_pHasInternetConnection != NULL )
+ return (sal_True == m_pHasInternetConnection());
+ return true;
+ }
+
+ /* Creates a new instance of UpdateInformationProvider and returns this instance */
+ inline uno::Reference<deployment::XUpdateInformationProvider> createProvider()
+ {
+ osl::MutexGuard aGuard(m_aMutex);
+ m_xProvider = deployment::UpdateInformationProvider::create(m_xContext);
+ return m_xProvider;
+ };
+
+ /* Returns the remembered instance of UpdateInformationProvider if any */
+ inline uno::Reference<deployment::XUpdateInformationProvider> getProvider()
+ { osl::MutexGuard aGuard(m_aMutex); return m_xProvider; };
+
+ /* Releases the remembered instance of UpdateInformationProvider if any */
+ inline void clearProvider()
+ { osl::MutexGuard aGuard(m_aMutex); m_xProvider.clear(); };
+
+ osl::Mutex m_aMutex;
+ osl::Module m_aModule;
+
+protected:
+ osl::Condition& m_aCondition;
+
+private:
+
+// const
+ OnlineCheckFunc m_pHasInternetConnection;
+
+ const uno::Reference<uno::XComponentContext> m_xContext;
+ uno::Reference<deployment::XUpdateInformationProvider> m_xProvider;
+};
+
+
+class ManualUpdateCheckThread : public UpdateCheckThread
+{
+public:
+ ManualUpdateCheckThread( osl::Condition& rCondition, const uno::Reference<uno::XComponentContext>& xContext ) :
+ UpdateCheckThread(rCondition, xContext) {};
+
+ virtual void SAL_CALL run();
+};
+
+
+class MenuBarButtonJob : public ::cppu::WeakImplHelper1< task::XJob >
+{
+public:
+ MenuBarButtonJob(const rtl::Reference< UpdateCheck >& rUpdateCheck);
+
+ // XJob
+ virtual uno::Any SAL_CALL execute(const uno::Sequence<beans::NamedValue>&)
+ throw (lang::IllegalArgumentException, uno::Exception);
+
+private:
+ rtl::Reference< UpdateCheck > m_aUpdateCheck;
+};
+
+class DownloadThread : public WorkerThread
+{
+public:
+ DownloadThread(
+ osl::Condition& rCondition,
+ const uno::Reference<uno::XComponentContext>& xContext,
+ const rtl::Reference< DownloadInteractionHandler >& rHandler,
+ const rtl::OUString& rURL );
+
+ virtual void SAL_CALL run();
+ virtual void SAL_CALL cancel();
+ virtual void SAL_CALL suspend();
+ virtual void SAL_CALL onTerminated();
+
+protected:
+ ~DownloadThread();
+
+private:
+ osl::Condition& m_aCondition;
+ const uno::Reference<uno::XComponentContext> m_xContext;
+ const rtl::OUString m_aURL;
+ Download m_aDownload;
+};
+
+//------------------------------------------------------------------------------
+class ShutdownThread : public osl::Thread
+{
+public:
+ ShutdownThread( const uno::Reference<uno::XComponentContext>& xContext );
+
+ virtual void SAL_CALL run();
+ virtual void SAL_CALL onTerminated();
+
+protected:
+ ~ShutdownThread();
+
+private:
+ osl::Condition m_aCondition;
+ const uno::Reference<uno::XComponentContext> m_xContext;
+};
+
+//------------------------------------------------------------------------------
+
+UpdateCheckThread::UpdateCheckThread( osl::Condition& rCondition,
+ const uno::Reference<uno::XComponentContext>& xContext ) :
+ m_aCondition(rCondition),
+ m_pHasInternetConnection(NULL),
+ m_xContext(xContext)
+{
+
+#ifdef WNT
+ rtl::OUString aPath;
+ if( osl_getExecutableFile(&aPath.pData) == osl_Process_E_None )
+ {
+ sal_uInt32 lastIndex = aPath.lastIndexOf('/');
+ if ( lastIndex > 0 )
+ {
+ aPath = aPath.copy( 0, lastIndex+1 );
+ aPath += UNISTRING( "onlinecheck" );
+ }
+
+ if ( m_aModule.load(aPath) )
+ {
+ m_pHasInternetConnection =
+ reinterpret_cast < OnlineCheckFunc > (
+ m_aModule.getFunctionSymbol( UNISTRING("hasInternetConnection")));
+ }
+ }
+#endif
+
+ createSuspended();
+
+ // actually run the thread
+ resume();
+}
+
+//------------------------------------------------------------------------------
+
+UpdateCheckThread::~UpdateCheckThread()
+{
+}
+
+//------------------------------------------------------------------------------
+
+
+void SAL_CALL
+UpdateCheckThread::terminate()
+{
+ // Cancel potentially hanging http request ..
+ cancel();
+ // .. before terminating
+ osl::Thread::terminate();
+}
+
+//------------------------------------------------------------------------------
+
+void SAL_CALL
+UpdateCheckThread::join()
+{
+ uno::Reference< deployment::XUpdateInformationProvider > xProvider(getProvider());
+
+ // do not join during an update check until #i73893# is fixed
+ if( ! xProvider.is() )
+ {
+ osl::Thread::join();
+ }
+}
+
+//------------------------------------------------------------------------------
+
+void SAL_CALL
+UpdateCheckThread::cancel()
+{
+ uno::Reference< deployment::XUpdateInformationProvider > xProvider(getProvider());
+
+ if( xProvider.is() )
+ xProvider->cancel();
+}
+
+//------------------------------------------------------------------------------
+
+bool
+UpdateCheckThread::runCheck( bool & rbExtensionsChecked )
+{
+ bool ret = false;
+ UpdateState eUIState = UPDATESTATE_NO_UPDATE_AVAIL;
+
+ UpdateInfo aInfo;
+ rtl::Reference< UpdateCheck > aController(UpdateCheck::get());
+
+ if( checkForUpdates(aInfo, m_xContext, aController->getInteractionHandler(), createProvider()) )
+ {
+ aController->setUpdateInfo(aInfo);
+ eUIState = aController->getUIState(aInfo);
+ ret = true;
+ }
+ else
+ aController->setCheckFailedState();
+
+ // We will only look for extension updates, when there is no 'check for office updates' dialog open
+ // and when there was no office update found
+ if ( ( eUIState != UPDATESTATE_UPDATE_AVAIL ) &&
+ ( eUIState != UPDATESTATE_UPDATE_NO_DOWNLOAD ) &&
+ !aController->isDialogShowing() &&
+ !rbExtensionsChecked )
+ {
+ bool bHasExtensionUpdates = checkForExtensionUpdates( m_xContext );
+ aController->setHasExtensionUpdates( bHasExtensionUpdates );
+ if ( bHasExtensionUpdates )
+ aController->setUIState( UPDATESTATE_EXT_UPD_AVAIL );
+ rbExtensionsChecked = true;
+ }
+
+ // joining with this thread is safe again
+ clearProvider();
+ return ret;
+}
+
+//------------------------------------------------------------------------------
+
+void SAL_CALL
+UpdateCheckThread::onTerminated()
+{
+ delete this;
+}
+
+//------------------------------------------------------------------------------
+
+void SAL_CALL
+UpdateCheckThread::run()
+{
+ bool bExtensionsChecked = false;
+ TimeValue systime;
+ TimeValue nExtCheckTime;
+ osl_getSystemTime( &nExtCheckTime );
+
+ osl::Condition::Result aResult = osl::Condition::result_timeout;
+ TimeValue tv = { 10, 0 };
+
+ // Initial wait to avoid doing further time consuming tasks during start-up
+ aResult = m_aCondition.wait(&tv);
+
+ try {
+
+ while( sal_True == schedule() )
+ {
+ /* Use cases:
+ * a) manual check requested from auto check thread - "last check" should not be checked (one time)
+ * a1) manual check was requested in the middle of a running auto check,
+ * condition is set
+ * a2) manual check was requested while waiting for a retry,
+ * condition is set
+ * a3) manual check was requested while waiting for time to next
+ * scheduled check elapsing, condition is set
+ * a4) manual check was requested during initial wait, condition is set
+ * b) check interval got changed, condition may be set - same sub-cases as a),
+ * but "last check" should be honored
+ * c) normal auto check mode, condition not set - "last check" should be honored
+ */
+
+ // Accessing const members without synchronization
+ rtl::Reference< UpdateCheck > aController(UpdateCheck::get());
+ rtl::Reference< UpdateCheckConfig > rModel = UpdateCheckConfig::get(m_xContext, *aController);
+
+ // FIXME: remember last & offset ?
+ sal_Int64 last = rModel->getLastChecked();
+ sal_Int64 offset = rModel->getCheckInterval();
+
+ rModel.clear();
+
+ // last == 0 means check immediately
+ bool checkNow = ! (last > 0);
+
+ // Reset the condition to avoid busy loops
+ if( osl::Condition::result_ok == aResult )
+ {
+ m_aCondition.reset();
+ aResult = osl::Condition::result_timeout;
+ checkNow = aController->isDialogShowing();
+ }
+
+ if( ! checkNow )
+ {
+ osl_getSystemTime(&systime);
+
+ // Go back to sleep until time has elapsed
+ sal_Int64 next = last + offset;
+ if( last + offset > systime.Seconds )
+ {
+ // This can not be > 32 Bit for now ..
+ tv.Seconds = static_cast< sal_Int32 > (next - systime.Seconds);
+ aResult = m_aCondition.wait(&tv);
+ continue;
+ }
+ }
+
+ static sal_uInt8 n = 0;
+
+ if( ! hasInternetConnection() || ! runCheck( bExtensionsChecked ) )
+ {
+ // the extension update check should be independent from the office update check
+ //
+ osl_getSystemTime( &systime );
+ if ( nExtCheckTime.Seconds + offset < systime.Seconds )
+ bExtensionsChecked = false;
+
+ // Increase next by 15, 60, .. minutes
+ static const sal_Int32 nRetryInterval[] = { 900, 3600, 14400, 86400 };
+
+ if( n < sizeof(nRetryInterval) / sizeof(sal_Int32) )
+ ++n;
+
+ tv.Seconds = nRetryInterval[n-1];
+ aResult = m_aCondition.wait(&tv);
+ }
+ else // reset retry counter
+ {
+ n = 0;
+ bExtensionsChecked = false;
+ }
+ }
+ }
+
+ catch(const uno::Exception& e) {
+ // Silently catch all errors
+ OSL_TRACE( "Caught exception: %s\n thread terminated.\n",
+ rtl::OUStringToOString(e.Message, RTL_TEXTENCODING_UTF8).getStr() );
+ }
+}
+
+//------------------------------------------------------------------------------
+
+void SAL_CALL
+ManualUpdateCheckThread::run()
+{
+ bool bExtensionsChecked = false;
+
+ try {
+ runCheck( bExtensionsChecked );
+ m_aCondition.reset();
+ }
+ catch(const uno::Exception& e) {
+ // Silently catch all errors
+ OSL_TRACE( "Caught exception: %s\n thread terminated.\n",
+ rtl::OUStringToOString(e.Message, RTL_TEXTENCODING_UTF8).getStr() );
+ }
+}
+
+//------------------------------------------------------------------------------
+
+MenuBarButtonJob::MenuBarButtonJob(const rtl::Reference< UpdateCheck >& rUpdateCheck) :
+ m_aUpdateCheck(rUpdateCheck)
+{
+};
+
+//------------------------------------------------------------------------------
+
+uno::Any SAL_CALL
+MenuBarButtonJob::execute(const uno::Sequence<beans::NamedValue>& )
+ throw (lang::IllegalArgumentException, uno::Exception)
+{
+ if ( m_aUpdateCheck->shouldShowExtUpdDlg() )
+ m_aUpdateCheck->showExtensionDialog();
+ else
+ m_aUpdateCheck->showDialog();
+
+ return uno::Any();
+}
+
+//------------------------------------------------------------------------------
+
+DownloadThread::DownloadThread(osl::Condition& rCondition,
+ const uno::Reference<uno::XComponentContext>& xContext,
+ const rtl::Reference< DownloadInteractionHandler >& rHandler,
+ const rtl::OUString& rURL) :
+ m_aCondition(rCondition),
+ m_xContext(xContext),
+ m_aURL(rURL),
+ m_aDownload(xContext, rHandler)
+{
+ createSuspended();
+}
+
+//------------------------------------------------------------------------------
+
+DownloadThread::~DownloadThread()
+{
+}
+
+//------------------------------------------------------------------------------
+
+void SAL_CALL
+DownloadThread::run()
+{
+#ifdef WNT
+ CoUninitialize();
+ CoInitialize( NULL );
+#endif
+
+ while( schedule() )
+ {
+ rtl::Reference< UpdateCheckConfig > rModel = UpdateCheckConfig::get(m_xContext);
+
+ rtl::OUString aLocalFile = rModel->getLocalFileName();
+ rtl::OUString aDownloadDest = rModel->getDownloadDestination();
+
+ // release config class for now
+ rModel.clear();
+
+ static sal_uInt8 n = 0;
+ if( ! m_aDownload.start(m_aURL, aLocalFile, aDownloadDest ) )
+ {
+ // retry every 15s unless the dialog is not visible
+ TimeValue tv;
+ tv.Seconds = 15;
+
+ if( ! UpdateCheck::get()->isDialogShowing() )
+ {
+ // Increase next by 1, 5, 15, 60, .. minutes
+ static const sal_Int16 nRetryInterval[] = { 60, 300, 900, 3600 };
+
+ if( n < sizeof(nRetryInterval) / sizeof(sal_Int16) )
+ ++n;
+
+ tv.Seconds = nRetryInterval[n-1];
+ }
+ m_aCondition.wait(&tv);
+ }
+ else
+ {
+ // reset wait period after successful download
+ n=0;
+ }
+ }
+}
+
+//------------------------------------------------------------------------------
+
+void SAL_CALL DownloadThread::cancel()
+{
+ m_aDownload.stop();
+ resume();
+
+ rtl::Reference< UpdateCheck > aController(UpdateCheck::get());
+ aController->cancelDownload();
+}
+
+//------------------------------------------------------------------------------
+
+void SAL_CALL DownloadThread::suspend()
+{
+ osl::Thread::suspend();
+ m_aDownload.stop();
+}
+
+//------------------------------------------------------------------------------
+
+void SAL_CALL DownloadThread::onTerminated()
+{
+ delete this;
+}
+
+//------------------------------------------------------------------------------
+ShutdownThread::ShutdownThread( const uno::Reference<uno::XComponentContext>& xContext) :
+ m_xContext( xContext )
+{
+ create();
+}
+
+//------------------------------------------------------------------------------
+ShutdownThread::~ShutdownThread()
+{
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL
+ShutdownThread::run()
+{
+ TimeValue tv = { 0, 250 };
+
+ m_aCondition.wait(&tv);
+
+ // Tell QuickStarter not to veto ..
+ uno::Reference< beans::XFastPropertySet > xQuickStarter(
+ UpdateCheck::createService(UNISTRING("com.sun.star.office.Quickstart"), m_xContext),
+ uno::UNO_QUERY
+ );
+
+ if (xQuickStarter.is())
+ xQuickStarter->setFastPropertyValue(0, uno::makeAny(false));
+
+ // Shutdown the office
+ uno::Reference< frame::XDesktop > xDesktop(
+ UpdateCheck::createService(UNISTRING("com.sun.star.frame.Desktop"), m_xContext),
+ uno::UNO_QUERY);
+
+ if( xDesktop.is() )
+ xDesktop->terminate();
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL ShutdownThread::onTerminated()
+{
+ delete this;
+}
+
+//------------------------------------------------------------------------------
+
+} // anonymous namespace
+
+
+//------------------------------------------------------------------------------
+
+
+void
+UpdateCheck::initialize(const uno::Sequence< beans::NamedValue >& rValues,
+ const uno::Reference<uno::XComponentContext>& xContext)
+{
+ osl::MutexGuard aGuard(m_aMutex);
+
+ if( NOT_INITIALIZED == m_eState )
+ {
+ NamedValueByNameAccess aNameAccess(rValues);
+ UpdateCheckROModel aModel( aNameAccess );
+ m_xContext = xContext;
+
+ rtl::OUString aUpdateEntryVersion = aModel.getUpdateEntryVersion();
+
+ aModel.getUpdateEntry(m_aUpdateInfo);
+
+ bool obsoleteUpdateInfo = isObsoleteUpdateInfo(aUpdateEntryVersion);
+ bool bContinueDownload = false;
+ bool bDownloadAvailable = false;
+
+ m_bHasExtensionUpdate = checkForPendingUpdates( xContext );
+ m_bShowExtUpdDlg = false;
+
+ rtl::OUString aLocalFileName = aModel.getLocalFileName();
+
+ if( aLocalFileName.getLength() > 0 )
+ {
+ bContinueDownload = true;
+
+ // Try to get the number of bytes already on disk
+ osl::DirectoryItem aDirectoryItem;
+ if( osl::DirectoryItem::E_None == osl::DirectoryItem::get(aLocalFileName, aDirectoryItem) )
+ {
+ osl::FileStatus aFileStatus(FileStatusMask_FileSize);
+ if( osl::DirectoryItem::E_None == aDirectoryItem.getFileStatus(aFileStatus) )
+ {
+ sal_Int64 nDownloadSize = aModel.getDownloadSize();
+ sal_Int64 nFileSize = aFileStatus.getFileSize();
+
+ if( nDownloadSize > 0 )
+ {
+ if ( nDownloadSize <= nFileSize ) // we have already downloaded everthing
+ {
+ bContinueDownload = false;
+ bDownloadAvailable = true;
+ m_aImageName = getImageFromFileName( aLocalFileName );
+ }
+ else // Calculate initial percent value.
+ {
+ sal_Int32 nPercent = (sal_Int32) (100 * nFileSize / nDownloadSize);
+ getUpdateHandler()->setProgress( nPercent );
+ }
+ }
+ }
+ }
+
+ if ( bContinueDownload )
+ {
+ bool downloadPaused = aModel.isDownloadPaused();
+
+ enableDownload(true, downloadPaused);
+ setUIState(downloadPaused ? UPDATESTATE_DOWNLOAD_PAUSED : UPDATESTATE_DOWNLOADING);
+ }
+
+ }
+ if ( !bContinueDownload )
+ {
+ // We do this intentionally only if no download is in progress ..
+ if( obsoleteUpdateInfo )
+ {
+ // Bring-up release note for position 5 ..
+ const rtl::OUString aURL(getReleaseNote(m_aUpdateInfo, 5));
+ if( aURL.getLength() > 0 )
+ showReleaseNote(aURL);
+
+ // Data is outdated, probably due to installed update
+ rtl::Reference< UpdateCheckConfig > aConfig = UpdateCheckConfig::get( xContext, *this );
+ aConfig->clearUpdateFound();
+ aConfig->clearLocalFileName();
+
+
+ m_aUpdateInfo = UpdateInfo();
+ // Remove outdated release notes
+ storeReleaseNote( 1, rtl::OUString() );
+ storeReleaseNote( 2, rtl::OUString() );
+ }
+ else
+ {
+ enableAutoCheck(aModel.isAutoCheckEnabled());
+ if ( bDownloadAvailable )
+ setUIState( UPDATESTATE_DOWNLOAD_AVAIL );
+ else
+ setUIState(getUIState(m_aUpdateInfo));
+ }
+ }
+ }
+}
+
+//------------------------------------------------------------------------------
+
+void
+UpdateCheck::cancel()
+{
+ osl::ClearableMutexGuard aGuard(m_aMutex);
+
+ WorkerThread *pThread = m_pThread;
+ UpdateState eUIState = getUIState(m_aUpdateInfo);
+
+ aGuard.clear();
+
+ if( NULL != pThread )
+ pThread->cancel();
+
+ setUIState(eUIState);
+}
+
+//------------------------------------------------------------------------------
+
+void
+UpdateCheck::download()
+{
+ osl::ClearableMutexGuard aGuard(m_aMutex);
+ UpdateInfo aInfo(m_aUpdateInfo);
+ State eState = m_eState;
+ aGuard.clear();
+
+ if( aInfo.Sources[0].IsDirect )
+ {
+ // Ignore second click of a double click
+ if( DOWNLOADING != eState )
+ {
+ shutdownThread(true);
+
+ osl::ClearableMutexGuard aGuard2(m_aMutex);
+ enableDownload(true);
+ aGuard2.clear();
+ setUIState(UPDATESTATE_DOWNLOADING);
+ }
+ }
+ else
+ {
+ showReleaseNote(aInfo.Sources[0].URL); // Display in browser
+ }
+}
+
+//------------------------------------------------------------------------------
+
+void
+UpdateCheck::install()
+{
+ osl::MutexGuard aGuard(m_aMutex);
+
+ const uno::Reference< c3s::XSystemShellExecute > xShellExecute(
+ createService( UNISTRING( "com.sun.star.system.SystemShellExecute" ), m_xContext ),
+ uno::UNO_QUERY );
+
+ try {
+ // Construct install command ??
+
+ // Store release note for position 3 and 4
+ rtl::OUString aURL(getReleaseNote(m_aUpdateInfo, 3));
+ storeReleaseNote(1, aURL);
+
+ aURL = getReleaseNote(m_aUpdateInfo, 4);
+ storeReleaseNote(2, aURL);
+
+ if( xShellExecute.is() )
+ {
+ rtl::OUString aInstallImage(m_aImageName);
+ osl::FileBase::getSystemPathFromFileURL(aInstallImage, aInstallImage);
+
+ rtl::OUString aParameter;
+ sal_Int32 nFlags = c3s::SystemShellExecuteFlags::DEFAULTS;
+#if ( defined LINUX || defined SOLARIS )
+ nFlags = 42;
+ aParameter = getBaseInstallation();
+ if( aParameter.getLength() > 0 )
+ osl::FileBase::getSystemPathFromFileURL(aParameter, aParameter);
+
+ aParameter += UNISTRING(" &");
+#endif
+
+ rtl::Reference< UpdateCheckConfig > rModel = UpdateCheckConfig::get( m_xContext );
+ rModel->clearLocalFileName();
+
+ xShellExecute->execute(aInstallImage, aParameter, nFlags);
+ ShutdownThread *pShutdownThread = new ShutdownThread( m_xContext );
+ (void) pShutdownThread;
+ }
+ } catch(uno::Exception&) {
+ m_aUpdateHandler->setErrorMessage( m_aUpdateHandler->getDefaultInstErrMsg() );
+ }
+}
+
+//------------------------------------------------------------------------------
+
+void
+UpdateCheck::pause()
+{
+ osl::ClearableMutexGuard aGuard(m_aMutex);
+
+ if( NULL != m_pThread )
+ m_pThread->suspend();
+
+ rtl::Reference< UpdateCheckConfig > rModel = UpdateCheckConfig::get(m_xContext);
+ aGuard.clear();
+
+ rModel->storeDownloadPaused(true);
+ setUIState(UPDATESTATE_DOWNLOAD_PAUSED);
+}
+
+//------------------------------------------------------------------------------
+
+void
+UpdateCheck::resume()
+{
+ osl::ClearableMutexGuard aGuard(m_aMutex);
+
+ if( NULL != m_pThread )
+ m_pThread->resume();
+
+ rtl::Reference< UpdateCheckConfig > rModel = UpdateCheckConfig::get(m_xContext);
+ aGuard.clear();
+
+ rModel->storeDownloadPaused(false);
+ setUIState(UPDATESTATE_DOWNLOADING);
+}
+
+//------------------------------------------------------------------------------
+
+void
+UpdateCheck::closeAfterFailure()
+{
+ osl::ClearableMutexGuard aGuard(m_aMutex);
+
+ if ( ( m_eState == DISABLED ) || ( m_eState == CHECK_SCHEDULED ) )
+ {
+ const UpdateState eUIState = getUIState( m_aUpdateInfo );
+ aGuard.clear();
+ setUIState( eUIState, true );
+ }
+}
+
+//------------------------------------------------------------------------------
+
+void
+UpdateCheck::shutdownThread(bool join)
+{
+ osl::ClearableMutexGuard aGuard(m_aMutex);
+
+ // copy thread object pointer to stack
+ osl::Thread *pThread = m_pThread;
+ m_pThread = NULL;
+ aGuard.clear();
+
+ if( NULL != pThread )
+ {
+ pThread->terminate();
+ if( join )
+ {
+ m_aCondition.set();
+ pThread->join();
+ m_aCondition.reset();
+ }
+ }
+}
+
+//------------------------------------------------------------------------------
+
+void
+UpdateCheck::enableAutoCheck(bool enable)
+{
+ if( enable )
+ m_pThread = new UpdateCheckThread(m_aCondition, m_xContext);
+
+ m_eState = enable ? CHECK_SCHEDULED : DISABLED;
+}
+
+//------------------------------------------------------------------------------
+
+void
+UpdateCheck::enableDownload(bool enable, bool paused)
+{
+ OSL_ASSERT(NULL == m_pThread);
+
+ State eState = DISABLED;
+ if( enable )
+ {
+ m_pThread = new DownloadThread(m_aCondition, m_xContext, this, m_aUpdateInfo.Sources[0].URL );
+ if( !paused )
+ {
+ eState = DOWNLOADING;
+ m_pThread->resume();
+ }
+ else
+ eState = DOWNLOAD_PAUSED;
+
+ m_eState = eState;
+ }
+ else {
+ enableAutoCheck(UpdateCheckConfig::get(m_xContext)->isAutoCheckEnabled());
+ }
+
+}
+
+//------------------------------------------------------------------------------
+
+bool
+UpdateCheck::downloadTargetExists(const rtl::OUString& rFileName)
+{
+ osl::ClearableMutexGuard aGuard(m_aMutex);
+
+ rtl::Reference< UpdateHandler > aUpdateHandler(getUpdateHandler());
+ UpdateState eUIState = UPDATESTATE_DOWNLOADING;
+
+ bool cont = false;
+
+ if( aUpdateHandler->isVisible() )
+ {
+ cont = aUpdateHandler->showOverwriteWarning();
+ if( cont )
+ {
+ if( osl_File_E_None != osl_removeFile(rFileName.pData) )
+ {
+ // FIXME: error message
+ cont = false;
+ }
+ }
+ else
+ eUIState = getUIState(m_aUpdateInfo);
+ }
+ else
+ {
+ m_aImageName = getImageFromFileName(rFileName);
+ eUIState = UPDATESTATE_DOWNLOAD_AVAIL;
+ }
+
+ if( !cont )
+ {
+ shutdownThread(false);
+ enableDownload(false);
+
+ aGuard.clear();
+ setUIState(eUIState);
+ }
+
+ return cont;
+}
+
+//------------------------------------------------------------------------------
+bool UpdateCheck::checkDownloadDestination( const rtl::OUString& rFileName )
+{
+ osl::ClearableMutexGuard aGuard(m_aMutex);
+
+ rtl::Reference< UpdateHandler > aUpdateHandler( getUpdateHandler() );
+
+ bool bReload = false;
+
+ if( aUpdateHandler->isVisible() )
+ {
+ bReload = aUpdateHandler->showOverwriteWarning( rFileName );
+ }
+
+ return bReload;
+}
+
+//------------------------------------------------------------------------------
+
+void
+UpdateCheck::downloadStalled(const rtl::OUString& rErrorMessage)
+{
+ osl::ClearableMutexGuard aGuard(m_aMutex);
+ rtl::Reference< UpdateHandler > aUpdateHandler(getUpdateHandler());
+ aGuard.clear();
+
+ aUpdateHandler->setErrorMessage(rErrorMessage);
+ setUIState(UPDATESTATE_ERROR_DOWNLOADING);
+}
+
+//------------------------------------------------------------------------------
+
+void
+UpdateCheck::downloadProgressAt(sal_Int8 nPercent)
+{
+ osl::ClearableMutexGuard aGuard(m_aMutex);
+ rtl::Reference< UpdateHandler > aUpdateHandler(getUpdateHandler());
+ aGuard.clear();
+
+ aUpdateHandler->setProgress(nPercent);
+ setUIState(UPDATESTATE_DOWNLOADING);
+}
+
+//------------------------------------------------------------------------------
+
+void
+UpdateCheck::downloadStarted(const rtl::OUString& rLocalFileName, sal_Int64 nFileSize)
+{
+ if ( nFileSize > 0 )
+ {
+ osl::MutexGuard aGuard(m_aMutex);
+
+ rtl::Reference< UpdateCheckConfig > aModel(UpdateCheckConfig::get(m_xContext));
+ aModel->storeLocalFileName(rLocalFileName, nFileSize);
+
+ // Bring-up release note for position 1 ..
+ const rtl::OUString aURL(getReleaseNote(m_aUpdateInfo, 1, aModel->isAutoDownloadEnabled()));
+ if( aURL.getLength() > 0 )
+ showReleaseNote(aURL);
+ }
+}
+
+//------------------------------------------------------------------------------
+
+void
+UpdateCheck::downloadFinished(const rtl::OUString& rLocalFileName)
+{
+ osl::ClearableMutexGuard aGuard(m_aMutex);
+
+ // no more retries
+ m_pThread->terminate();
+
+ m_aImageName = getImageFromFileName(rLocalFileName);
+ UpdateInfo aUpdateInfo(m_aUpdateInfo);
+
+ aGuard.clear();
+ setUIState(UPDATESTATE_DOWNLOAD_AVAIL);
+
+ // Bring-up release note for position 2 ..
+ rtl::Reference< UpdateCheckConfig > rModel = UpdateCheckConfig::get( m_xContext );
+ const rtl::OUString aURL(getReleaseNote(aUpdateInfo, 2, rModel->isAutoDownloadEnabled()));
+ if( aURL.getLength() > 0 )
+ showReleaseNote(aURL);
+}
+
+//------------------------------------------------------------------------------
+
+void
+UpdateCheck::cancelDownload()
+{
+ shutdownThread(true);
+
+ osl::MutexGuard aGuard(m_aMutex);
+ enableDownload(false);
+
+ rtl::Reference< UpdateCheckConfig > rModel = UpdateCheckConfig::get(m_xContext);
+
+ rtl::OUString aLocalFile(rModel->getLocalFileName());
+ rModel->clearLocalFileName();
+ rModel->storeDownloadPaused(false);
+
+ if( isObsoleteUpdateInfo(rModel->getUpdateEntryVersion()) )
+ {
+ rModel->clearUpdateFound(); // This wasn't done during init yet ..
+ m_aUpdateInfo = UpdateInfo();
+ }
+
+ /*oslFileError rc =*/ osl_removeFile(aLocalFile.pData);
+ // FIXME: error handling ..
+
+}
+
+//------------------------------------------------------------------------------
+
+void
+UpdateCheck::showDialog(bool forceCheck)
+{
+ osl::ResettableMutexGuard aGuard(m_aMutex);
+
+ bool update_found = m_aUpdateInfo.BuildId.getLength() > 0;
+ bool bSetUIState = ! m_aUpdateHandler.is();
+
+ UpdateState eDialogState = UPDATESTATES_COUNT;
+
+ switch( m_eState )
+ {
+ case DISABLED:
+ case CHECK_SCHEDULED:
+ if( forceCheck || ! update_found ) // Run check when forced or if we did not find an update yet
+ {
+ eDialogState = UPDATESTATE_CHECKING;
+ bSetUIState = true;
+ }
+ else if(m_aUpdateInfo.Sources[0].IsDirect)
+ eDialogState = UPDATESTATE_UPDATE_AVAIL;
+ else
+ eDialogState = UPDATESTATE_UPDATE_NO_DOWNLOAD;
+ break;
+
+ case DOWNLOADING:
+ eDialogState = UPDATESTATE_DOWNLOADING;
+ break;
+
+ case DOWNLOAD_PAUSED:
+ eDialogState = UPDATESTATE_DOWNLOAD_PAUSED;
+ break;
+
+ case NOT_INITIALIZED:
+ OSL_ASSERT( false );
+ break;
+ }
+
+ if( bSetUIState )
+ {
+ aGuard.clear();
+ setUIState(eDialogState, true); // suppress bubble as Dialog will be visible soon
+ aGuard.reset();
+ }
+
+ getUpdateHandler()->setVisible(true);
+
+ // Run check in separate thread ..
+ if( UPDATESTATE_CHECKING == eDialogState )
+ {
+ if( DISABLED == m_eState )
+ {
+ // destructs itself when done, not cancellable for now ..
+ new ManualUpdateCheckThread(m_aCondition, m_xContext);
+ }
+
+ m_aCondition.set();
+ }
+}
+
+//------------------------------------------------------------------------------
+
+void
+UpdateCheck::setUpdateInfo(const UpdateInfo& aInfo)
+{
+ osl::ClearableMutexGuard aGuard(m_aMutex);
+
+ bool bSuppressBubble = (sal_True == aInfo.BuildId.equals(m_aUpdateInfo.BuildId));
+ m_aUpdateInfo = aInfo;
+
+ OSL_ASSERT(DISABLED == m_eState || CHECK_SCHEDULED == m_eState);
+
+ // Ignore leading non direct download if we get direct ones
+ std::vector< DownloadSource >::iterator iter = m_aUpdateInfo.Sources.begin();
+ while( iter != m_aUpdateInfo.Sources.end() )
+ {
+ if( iter->IsDirect )
+ break;
+
+ ++iter;
+ }
+
+ if( (iter != m_aUpdateInfo.Sources.begin()) &&
+ (iter != m_aUpdateInfo.Sources.end()) &&
+ iter->IsDirect )
+ {
+ m_aUpdateInfo.Sources.erase(m_aUpdateInfo.Sources.begin(), --iter);
+ }
+
+ rtl::Reference< UpdateCheckConfig > rModel = UpdateCheckConfig::get(m_xContext, *this);
+ OSL_ASSERT( rModel.is() );
+
+ // Decide whether to use alternate release note pos ..
+ bool autoDownloadEnabled = rModel->isAutoDownloadEnabled();
+
+ std::vector< ReleaseNote >::iterator iter2 = m_aUpdateInfo.ReleaseNotes.begin();
+ while( iter2 != m_aUpdateInfo.ReleaseNotes.end() )
+ {
+ if( ((1 == iter2->Pos) || (2 == iter2->Pos)) && autoDownloadEnabled && (iter2->URL2.getLength() > 0))
+ {
+ iter2->URL = iter2->URL2;
+ iter2->URL2 = rtl::OUString();
+ iter2->Pos = iter2->Pos2;
+ iter2->Pos2 = 0;
+ }
+
+ ++iter2;
+ }
+
+ // do not move below store/clear ..
+ rModel->updateLastChecked();
+
+ UpdateState eUIState;
+ if( m_aUpdateInfo.Sources.size() > 0 )
+ {
+ rModel->storeUpdateFound(aInfo, getBuildId());
+
+ if( m_aUpdateInfo.Sources[0].IsDirect )
+ {
+ eUIState = UPDATESTATE_UPDATE_AVAIL;
+
+ if( rModel->isAutoDownloadEnabled() )
+ {
+ shutdownThread(false);
+ eUIState = UPDATESTATE_DOWNLOADING;
+ enableDownload(true);
+ }
+ }
+ else
+ eUIState = UPDATESTATE_UPDATE_NO_DOWNLOAD;
+ }
+ else
+ {
+ eUIState = UPDATESTATE_NO_UPDATE_AVAIL;
+ rModel->clearUpdateFound();
+ }
+
+ aGuard.clear();
+ setUIState(eUIState, bSuppressBubble);
+}
+
+//------------------------------------------------------------------------------
+
+void
+UpdateCheck::setCheckFailedState()
+{
+ setUIState(UPDATESTATE_ERROR_CHECKING);
+}
+
+//------------------------------------------------------------------------------
+void UpdateCheck::handleMenuBarUI( rtl::Reference< UpdateHandler > rUpdateHandler,
+ UpdateState& eState,
+ bool suppressBubble )
+{
+ uno::Reference<beans::XPropertySet> xMenuBarUI( m_xMenuBarUI );
+
+ if ( ( UPDATESTATE_NO_UPDATE_AVAIL == eState ) && m_bHasExtensionUpdate )
+ eState = UPDATESTATE_EXT_UPD_AVAIL;
+
+ if ( UPDATESTATE_EXT_UPD_AVAIL == eState )
+ m_bShowExtUpdDlg = true;
+ else
+ m_bShowExtUpdDlg = false;
+
+ if( xMenuBarUI.is() )
+ {
+ if( UPDATESTATE_NO_UPDATE_AVAIL == eState )
+ {
+ xMenuBarUI->setPropertyValue( PROPERTY_SHOW_MENUICON, uno::makeAny(sal_False) );
+ }
+ else
+ {
+ xMenuBarUI->setPropertyValue( PROPERTY_TITLE, uno::makeAny(rUpdateHandler->getBubbleTitle(eState)) );
+ xMenuBarUI->setPropertyValue( PROPERTY_TEXT, uno::makeAny(rUpdateHandler->getBubbleText(eState)) );
+
+ if( ! suppressBubble && ( ! rUpdateHandler->isVisible() || rUpdateHandler->isMinimized() ) )
+ xMenuBarUI->setPropertyValue( PROPERTY_SHOW_BUBBLE, uno::makeAny( sal_True ) );
+
+ if( UPDATESTATE_CHECKING != eState )
+ xMenuBarUI->setPropertyValue( PROPERTY_SHOW_MENUICON, uno::makeAny(sal_True) );
+ }
+ }
+}
+
+//------------------------------------------------------------------------------
+void UpdateCheck::setUIState(UpdateState eState, bool suppressBubble)
+{
+ osl::ClearableMutexGuard aGuard(m_aMutex);
+
+ if( ! m_xMenuBarUI.is() &&
+ (DISABLED != m_eState) &&
+ ( m_bHasExtensionUpdate || (UPDATESTATE_NO_UPDATE_AVAIL != eState)) &&
+ (UPDATESTATE_CHECKING != eState) &&
+ (UPDATESTATE_ERROR_CHECKING != eState)
+ )
+ {
+ m_xMenuBarUI = createMenuBarUI(m_xContext, new MenuBarButtonJob(this));
+ }
+
+ // Show bubble only when the status has changed
+ if ( eState == m_eUpdateState )
+ suppressBubble = true;
+ else
+ m_eUpdateState = eState;
+
+ rtl::Reference<UpdateHandler> aUpdateHandler(getUpdateHandler());
+ OSL_ASSERT( aUpdateHandler.is() );
+
+ UpdateInfo aUpdateInfo(m_aUpdateInfo);
+ rtl::OUString aImageName(m_aImageName);
+
+ aGuard.clear();
+
+ handleMenuBarUI( aUpdateHandler, eState, suppressBubble );
+
+ if( (UPDATESTATE_UPDATE_AVAIL == eState)
+ || (UPDATESTATE_DOWNLOAD_PAUSED == eState)
+ || (UPDATESTATE_DOWNLOADING == eState) )
+ {
+ uno::Reference< uno::XComponentContext > xContext(m_xContext);
+
+ rtl::OUString aDownloadDestination =
+ UpdateCheckConfig::get(xContext, this)->getDownloadDestination();
+
+ osl_getSystemPathFromFileURL(aDownloadDestination.pData, &aDownloadDestination.pData);
+
+ aUpdateHandler->setDownloadPath(aDownloadDestination);
+ }
+ else if( UPDATESTATE_DOWNLOAD_AVAIL == eState )
+ {
+ aUpdateHandler->setDownloadFile(aImageName);
+ }
+
+ aUpdateHandler->setDescription(aUpdateInfo.Description);
+ aUpdateHandler->setNextVersion(aUpdateInfo.Version);
+ aUpdateHandler->setState(eState);
+}
+
+//------------------------------------------------------------------------------
+
+UpdateState
+UpdateCheck::getUIState(const UpdateInfo& rInfo)
+{
+ UpdateState eUIState = UPDATESTATE_NO_UPDATE_AVAIL;
+
+ if( rInfo.BuildId.getLength() > 0 )
+ {
+ if( rInfo.Sources[0].IsDirect )
+ eUIState = UPDATESTATE_UPDATE_AVAIL;
+ else
+ eUIState = UPDATESTATE_UPDATE_NO_DOWNLOAD;
+ }
+
+ return eUIState;
+}
+
+//------------------------------------------------------------------------------
+
+void
+UpdateCheck::showReleaseNote(const rtl::OUString& rURL) const
+{
+ const uno::Reference< c3s::XSystemShellExecute > xShellExecute(
+ createService( UNISTRING( "com.sun.star.system.SystemShellExecute" ), m_xContext ),
+ uno::UNO_QUERY );
+
+ try {
+
+ if( xShellExecute.is() )
+ xShellExecute->execute(rURL, rtl::OUString(), c3s::SystemShellExecuteFlags::DEFAULTS);
+ } catch(c3s::SystemShellExecuteException&) {
+ }
+}
+
+//------------------------------------------------------------------------------
+
+bool
+UpdateCheck::storeReleaseNote(sal_Int8 nNum, const rtl::OUString &rURL)
+{
+ osl::FileBase::RC rc;
+ rtl::OUString aTargetDir( UpdateCheckConfig::getAllUsersDirectory() + UNISTRING( "/sun" ) );
+
+ rc = osl::Directory::createPath( aTargetDir );
+
+ rtl::OUString aFileName = UNISTRING("releasenote") +
+ rtl::OUString::valueOf( (sal_Int32) nNum ) +
+ UNISTRING(".url");
+
+ rtl::OUString aFilePath;
+ rc = osl::FileBase::getAbsoluteFileURL( aTargetDir, aFileName, aFilePath );
+ if ( rc != osl::FileBase::E_None ) return false;
+
+ rc = osl::File::remove( aFilePath );
+
+ // don't store empty release notes, but delete old ones
+ if ( rURL.getLength() == 0 )
+ return true;
+
+ osl::File aFile( aFilePath );
+ rc = aFile.open( OpenFlag_Write | OpenFlag_Create );
+
+ if ( rc != osl::FileBase::E_None ) return false;
+
+ rtl::OString aLineBuf("[InternetShortcut]\r\n");
+ sal_uInt64 nWritten = 0;
+
+ rtl::OUString aURL( rURL );
+#ifdef WNT
+ rc = aFile.write( aLineBuf.getStr(), aLineBuf.getLength(), nWritten );
+ if ( rc != osl::FileBase::E_None ) return false;
+ aURL = UNISTRING("URL=") + rURL;
+#endif
+ aLineBuf = rtl::OUStringToOString( aURL, RTL_TEXTENCODING_UTF8 );
+ rc = aFile.write( aLineBuf.getStr(), aLineBuf.getLength(), nWritten );
+ if ( rc != osl::FileBase::E_None ) return false;
+
+ aFile.close();
+ return true;
+}
+
+//------------------------------------------------------------------------------
+void UpdateCheck::showExtensionDialog()
+{
+ rtl::OUString sServiceName = UNISTRING("com.sun.star.deployment.ui.PackageManagerDialog");
+ rtl::OUString sArguments = UNISTRING("SHOW_UPDATE_DIALOG");
+ uno::Reference< uno::XInterface > xService;
+
+ if( ! m_xContext.is() )
+ throw uno::RuntimeException(
+ UNISTRING( "UpdateCheck::showExtensionDialog(): empty component context" ), uno::Reference< uno::XInterface > () );
+
+ uno::Reference< lang::XMultiComponentFactory > xServiceManager( m_xContext->getServiceManager() );
+ if( !xServiceManager.is() )
+ throw uno::RuntimeException(
+ UNISTRING( "UpdateCheck::showExtensionDialog(): unable to obtain service manager from component context" ), uno::Reference< uno::XInterface > () );
+
+ xService = xServiceManager->createInstanceWithContext( sServiceName, m_xContext );
+ uno::Reference< task::XJobExecutor > xExecuteable( xService, uno::UNO_QUERY );
+ if ( xExecuteable.is() )
+ xExecuteable->trigger( sArguments );
+}
+
+//------------------------------------------------------------------------------
+
+rtl::Reference<UpdateHandler>
+UpdateCheck::getUpdateHandler()
+{
+ osl::MutexGuard aGuard(m_aMutex);
+
+ if( ! m_aUpdateHandler.is() )
+ m_aUpdateHandler = new UpdateHandler(m_xContext, this);
+
+ return m_aUpdateHandler;
+}
+
+//------------------------------------------------------------------------------
+
+uno::Reference< task::XInteractionHandler >
+UpdateCheck::getInteractionHandler() const
+{
+ osl::MutexGuard aGuard(m_aMutex);
+
+ uno::Reference< task::XInteractionHandler > xHandler;
+
+ if( m_aUpdateHandler.is() && m_aUpdateHandler->isVisible() )
+ xHandler = m_aUpdateHandler.get();
+
+ return xHandler;
+}
+
+//------------------------------------------------------------------------------
+
+uno::Reference< uno::XInterface >
+UpdateCheck::createService(const rtl::OUString& rServiceName,
+ const uno::Reference<uno::XComponentContext>& xContext)
+{
+ if( !xContext.is() )
+ throw uno::RuntimeException(
+ UNISTRING( "UpdateCheckConfig: empty component context" ),
+ uno::Reference< uno::XInterface >() );
+
+ const uno::Reference< lang::XMultiComponentFactory > xServiceManager(xContext->getServiceManager());
+
+ if( !xServiceManager.is() )
+ throw uno::RuntimeException(
+ UNISTRING( "UpdateCheckConfig: unable to obtain service manager from component context" ),
+ uno::Reference< uno::XInterface >() );
+
+ return xServiceManager->createInstanceWithContext(rServiceName, xContext);
+}
+
+//------------------------------------------------------------------------------
+
+bool
+UpdateCheck::isDialogShowing() const
+{
+ osl::MutexGuard aGuard(m_aMutex);
+ return sal_True == m_aUpdateHandler.is() && m_aUpdateHandler->isVisible();
+};
+
+//------------------------------------------------------------------------------
+
+void
+UpdateCheck::autoCheckStatusChanged(bool enabled)
+{
+ osl::ClearableMutexGuard aGuard(m_aMutex);
+
+ if( (CHECK_SCHEDULED == m_eState) && !enabled )
+ shutdownThread(false);
+
+ if( (DISABLED == m_eState) || (CHECK_SCHEDULED == m_eState) )
+ {
+ enableAutoCheck(enabled);
+ UpdateState eState = getUIState(m_aUpdateInfo);
+ aGuard.clear();
+ setUIState(eState);
+ }
+};
+
+//------------------------------------------------------------------------------
+
+void
+UpdateCheck::autoCheckIntervalChanged()
+{
+ // just wake-up
+ m_aCondition.set();
+};
+
+//------------------------------------------------------------------------------
+
+oslInterlockedCount SAL_CALL
+UpdateCheck::acquire() SAL_THROW(())
+{
+ return ReferenceObject::acquire();
+}
+
+//------------------------------------------------------------------------------
+
+oslInterlockedCount SAL_CALL
+UpdateCheck::release() SAL_THROW(())
+{
+ return ReferenceObject::release();
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/update/check/updatecheck.hxx b/extensions/source/update/check/updatecheck.hxx
new file mode 100644
index 000000000000..00d3ede1fe78
--- /dev/null
+++ b/extensions/source/update/check/updatecheck.hxx
@@ -0,0 +1,197 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include <com/sun/star/beans/NamedValue.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/task/XInteractionHandler.hpp>
+#include <com/sun/star/uno/XComponentContext.hpp>
+
+#include <osl/conditn.hxx>
+#include <osl/thread.hxx>
+#include <rtl/instance.hxx>
+#include <salhelper/refobj.hxx>
+
+#include "updateinfo.hxx"
+#include "updatecheckconfiglistener.hxx"
+#include "actionlistener.hxx"
+#include "updatehdl.hxx"
+#include "download.hxx"
+
+
+class UpdateCheck;
+class UpdateCheckConfig;
+
+class UpdateCheckInitData {
+
+public:
+ inline rtl::Reference< UpdateCheck > SAL_CALL operator() () const;
+};
+
+class WorkerThread : public osl::Thread
+{
+public:
+ virtual void SAL_CALL cancel() = 0;
+};
+
+class UpdateCheck :
+ public UpdateCheckConfigListener,
+ public IActionListener,
+ public DownloadInteractionHandler,
+ public salhelper::ReferenceObject,
+ public rtl::StaticWithInit< rtl::Reference< UpdateCheck >, UpdateCheckInitData >
+{
+ UpdateCheck() : m_eState(NOT_INITIALIZED), m_eUpdateState(UPDATESTATES_COUNT), m_pThread(NULL) {};
+
+public:
+ inline SAL_CALL operator rtl::Reference< UpdateCheckConfigListener > ()
+ { return static_cast< UpdateCheckConfigListener * > (this); }
+
+ void initialize(const com::sun::star::uno::Sequence<com::sun::star::beans::NamedValue>& rValues,
+ const com::sun::star::uno::Reference<com::sun::star::uno::XComponentContext>& xContext);
+
+ /* Returns an instance of the specified service obtained from the specified
+ * component context
+ */
+
+ static com::sun::star::uno::Reference< com::sun::star::uno::XInterface > createService(
+ const rtl::OUString& aServiceName,
+ const com::sun::star::uno::Reference<com::sun::star::uno::XComponentContext>& xContext);
+
+ // Update internal update info member
+ void setUpdateInfo(const UpdateInfo& aInfo);
+
+ /* This method turns on the menubar icon, triggers the bubble window or
+ * updates the dialog text when appropriate
+ */
+ void setUIState(UpdateState eState, bool suppressBubble = false);
+
+ // Returns the UI state that matches rInfo best
+ static UpdateState getUIState(const UpdateInfo& rInfo);
+
+ // Check for updates failed
+ void setCheckFailedState();
+
+ // Executes the update check dialog for manual checks and downloads interaction
+ void showDialog(bool forceCheck = false);
+
+ // Returns true if the update dialog is currently showing
+ bool isDialogShowing() const;
+ bool shouldShowExtUpdDlg() const { return ( m_bShowExtUpdDlg && m_bHasExtensionUpdate ); }
+ void showExtensionDialog();
+ void setHasExtensionUpdates( bool bHasUpdates ) { m_bHasExtensionUpdate = bHasUpdates; }
+ bool hasOfficeUpdate() const { return (m_aUpdateInfo.BuildId.getLength() > 0); }
+
+ // DownloadInteractionHandler
+ virtual bool downloadTargetExists(const rtl::OUString& rFileName);
+ virtual void downloadStalled(const rtl::OUString& rErrorMessage);
+ virtual void downloadProgressAt(sal_Int8 nProcent);
+ virtual void downloadStarted(const rtl::OUString& rLocalFileName, sal_Int64 nFileSize);
+ virtual void downloadFinished(const rtl::OUString& rLocalFileName);
+ // checks if the download target already exists and asks user what to do next
+ virtual bool checkDownloadDestination( const rtl::OUString& rFile );
+
+ // Cancels the download action (and resumes checking if enabled)
+ void cancelDownload();
+
+ // Returns the XInteractionHandler of the UpdateHandler instance if present (and visible)
+ com::sun::star::uno::Reference< com::sun::star::task::XInteractionHandler > getInteractionHandler() const;
+
+ // UpdateCheckConfigListener
+ virtual void autoCheckStatusChanged(bool enabled);
+ virtual void autoCheckIntervalChanged();
+
+ // IActionListener
+ void cancel();
+ void download();
+ void install();
+ void pause();
+ void resume();
+ void closeAfterFailure();
+
+ // rtl::IReference
+ virtual oslInterlockedCount SAL_CALL acquire() SAL_THROW(());
+ virtual oslInterlockedCount SAL_CALL release() SAL_THROW(());
+
+private:
+
+ // Schedules or cancels next automatic check for updates
+ void enableAutoCheck(bool enable);
+
+ // Starts/resumes or stops a download
+ void enableDownload(bool enable, bool paused=false);
+
+ // Shuts down the currently running thread
+ void shutdownThread(bool join);
+
+ // Returns the update handler instance
+ rtl::Reference<UpdateHandler> getUpdateHandler();
+
+ // Open the given URL in a browser
+ void showReleaseNote(const rtl::OUString& rURL) const;
+
+ // stores the release note url on disk to be used by setup app
+ static bool storeReleaseNote(sal_Int8 nNum, const rtl::OUString &rURL);
+
+ /* This method turns on the menubar icon and triggers the bubble window
+ */
+ void handleMenuBarUI( rtl::Reference< UpdateHandler > rUpdateHandler,
+ UpdateState& eState, bool suppressBubble );
+ enum State {
+ NOT_INITIALIZED,
+ DISABLED,
+ CHECK_SCHEDULED,
+ DOWNLOADING,
+ DOWNLOAD_PAUSED
+ };
+
+ State m_eState;
+ UpdateState m_eUpdateState;
+
+ mutable osl::Mutex m_aMutex;
+ WorkerThread *m_pThread;
+ osl::Condition m_aCondition;
+
+ UpdateInfo m_aUpdateInfo;
+ rtl::OUString m_aImageName;
+ bool m_bHasExtensionUpdate;
+ bool m_bShowExtUpdDlg;
+
+ rtl::Reference<UpdateHandler> m_aUpdateHandler;
+ com::sun::star::uno::Reference<com::sun::star::beans::XPropertySet> m_xMenuBarUI;
+ com::sun::star::uno::Reference<com::sun::star::uno::XComponentContext> m_xContext;
+
+ friend class UpdateCheckInitData;
+};
+
+inline rtl::Reference< UpdateCheck > SAL_CALL
+UpdateCheckInitData::operator() () const
+{
+ return rtl::Reference< UpdateCheck > (new UpdateCheck());
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/update/check/updatecheckconfig.cxx b/extensions/source/update/check/updatecheckconfig.cxx
new file mode 100644
index 000000000000..7f4227daedbe
--- /dev/null
+++ b/extensions/source/update/check/updatecheckconfig.cxx
@@ -0,0 +1,763 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+
+
+#include "updatecheckconfig.hxx"
+#include <com/sun/star/beans/PropertyValue.hpp>
+#include <com/sun/star/beans/XPropertyState.hpp>
+
+#include <com/sun/star/beans/XPropertyState.hpp>
+
+#include <osl/security.hxx>
+#include <osl/time.h>
+#include <osl/file.hxx>
+
+#ifdef WNT
+#ifdef _MSC_VER
+#pragma warning(push,1) // disable warnings within system headers
+#pragma warning(disable: 4917)
+#endif
+#include <shlobj.h>
+#ifdef _MSC_VER
+#pragma warning(pop)
+#endif
+#endif
+
+namespace container = com::sun::star::container ;
+namespace beans = com::sun::star::beans ;
+namespace lang = com::sun::star::lang ;
+namespace util = com::sun::star::util ;
+namespace uno = com::sun::star::uno ;
+
+#define UNISTRING(s) rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(s))
+
+#define LAST_CHECK "LastCheck"
+#define VERSION_FOUND "UpdateVersionFound"
+#define UPDATE_VERSION "UpdateVersion"
+#define UPDATE_BUILDID "UpdateBuildId"
+#define UPDATE_DESCRIPTION "UpdateDescription"
+#define DOWNLOAD_URL "DownloadURL"
+#define IS_DIRECT_DOWNLOAD "IsDirectDownload"
+#define OLD_VERSION "UpdateFoundFor"
+#define AUTOCHECK_ENABLED "AutoCheckEnabled"
+#define AUTODOWNLOAD_ENABLED "AutoDownloadEnabled"
+#define CHECK_INTERVAL "CheckInterval"
+#define LOCAL_FILE "LocalFile"
+#define DOWNLOAD_SIZE "DownloadSize"
+#define DOWNLOAD_PAUSED "DownloadPaused"
+#define DOWNLOAD_DESTINATION "DownloadDestination"
+#define RELEASE_NOTE "ReleaseNote"
+#define EXTENSION_PREFIX "Extension_"
+
+static const sal_Char * const aUpdateEntryProperties[] = {
+ UPDATE_VERSION,
+ UPDATE_BUILDID,
+ UPDATE_DESCRIPTION,
+ DOWNLOAD_URL,
+ IS_DIRECT_DOWNLOAD,
+ RELEASE_NOTE"1",
+ RELEASE_NOTE"2",
+ RELEASE_NOTE"3",
+ RELEASE_NOTE"4",
+ RELEASE_NOTE"5",
+ OLD_VERSION
+};
+
+static const sal_uInt32 nUpdateEntryProperties = sizeof(aUpdateEntryProperties) / sizeof(sal_Char *);
+
+//------------------------------------------------------------------------------
+
+NamedValueByNameAccess::~NamedValueByNameAccess()
+{
+}
+
+//------------------------------------------------------------------------------
+
+::com::sun::star::uno::Any
+NamedValueByNameAccess::getValue(const sal_Char * pName)
+{
+ const sal_Int32 nLen = m_rValues.getLength();
+ for( sal_Int32 n=0; n < nLen; ++n )
+ {
+ if( m_rValues[n].Name.equalsAscii( pName ) )
+ return m_rValues[n].Value;
+ }
+ return ::com::sun::star::uno::Any();
+}
+
+
+//------------------------------------------------------------------------------
+
+bool
+UpdateCheckROModel::isAutoCheckEnabled() const
+{
+ return sal_True == m_aNameAccess.getValue(AUTOCHECK_ENABLED).get< sal_Bool >();
+}
+
+//------------------------------------------------------------------------------
+
+bool
+UpdateCheckROModel::isDownloadPaused() const
+{
+ return sal_True == m_aNameAccess.getValue(DOWNLOAD_PAUSED).get< sal_Bool >();
+}
+
+//------------------------------------------------------------------------------
+
+rtl::OUString
+UpdateCheckROModel::getStringValue(const sal_Char * pStr) const
+{
+ uno::Any aAny( m_aNameAccess.getValue(pStr) );
+ rtl::OUString aRet;
+
+ aAny >>= aRet;
+
+ return aRet;
+}
+
+//------------------------------------------------------------------------------
+
+rtl::OUString UpdateCheckROModel::getLocalFileName() const
+{
+ return getStringValue(LOCAL_FILE);
+};
+
+//------------------------------------------------------------------------------
+
+sal_Int64 UpdateCheckROModel::getDownloadSize() const
+{
+ uno::Any aAny( m_aNameAccess.getValue(DOWNLOAD_SIZE) );
+ sal_Int64 nRet = -1;
+
+ aAny >>= nRet;
+ return nRet;
+};
+
+//------------------------------------------------------------------------------
+
+rtl::OUString
+UpdateCheckROModel::getUpdateEntryVersion() const
+{
+ return getStringValue(OLD_VERSION);
+}
+
+//------------------------------------------------------------------------------
+
+void
+UpdateCheckROModel::getUpdateEntry(UpdateInfo& rInfo) const
+{
+ rInfo.BuildId = getStringValue(UPDATE_BUILDID);
+ rInfo.Version = getStringValue(UPDATE_VERSION);
+ rInfo.Description = getStringValue(UPDATE_DESCRIPTION);
+
+ sal_Bool isDirectDownload = sal_False;
+ m_aNameAccess.getValue(IS_DIRECT_DOWNLOAD) >>= isDirectDownload;
+
+ rInfo.Sources.push_back( DownloadSource( isDirectDownload, getStringValue(DOWNLOAD_URL) ) );
+
+ rtl::OString aStr(RELEASE_NOTE);
+ for(sal_Int32 n=1; n < 6; ++n )
+ {
+ rtl::OUString aUStr = getStringValue(aStr + rtl::OString::valueOf(n));
+ if( aUStr.getLength() > 0 )
+ rInfo.ReleaseNotes.push_back(ReleaseNote((sal_Int8) n, aUStr));
+ }
+}
+
+
+//------------------------------------------------------------------------------
+
+rtl::OUString UpdateCheckConfig::getDesktopDirectory()
+{
+ rtl::OUString aRet;
+
+#ifdef WNT
+ WCHAR szPath[MAX_PATH];
+
+ if( ! FAILED( SHGetSpecialFolderPathW( NULL, szPath, CSIDL_DESKTOPDIRECTORY, true ) ) )
+ {
+ aRet = rtl::OUString( reinterpret_cast< sal_Unicode * >(szPath) );
+ osl::FileBase::getFileURLFromSystemPath( aRet, aRet );
+ }
+#else
+ // This should become a desktop specific setting in some system backend ..
+ rtl::OUString aHomeDir;
+ osl::Security().getHomeDir( aHomeDir );
+ aRet = aHomeDir + rtl::OUString::createFromAscii("/Desktop");
+
+ // Set path to home directory when there is no /Desktop directory
+ osl::Directory aDocumentsDir( aRet );
+ if( osl::FileBase::E_None != aDocumentsDir.open() )
+ aRet = aHomeDir;
+#endif
+
+ return aRet;
+}
+
+//------------------------------------------------------------------------------
+
+rtl::OUString UpdateCheckConfig::getAllUsersDirectory()
+{
+ rtl::OUString aRet;
+
+#ifdef WNT
+ WCHAR szPath[MAX_PATH];
+
+ if( ! FAILED( SHGetSpecialFolderPathW( NULL, szPath, CSIDL_COMMON_DOCUMENTS, true ) ) )
+ {
+ aRet = rtl::OUString( reinterpret_cast< sal_Unicode * >(szPath) );
+ osl::FileBase::RC rc;
+ rc = osl::FileBase::getFileURLFromSystemPath( aRet, aRet );
+ }
+#else
+ osl::FileBase::getTempDirURL(aRet);
+#endif
+
+ return aRet;
+}
+
+//------------------------------------------------------------------------------
+
+UpdateCheckConfig::UpdateCheckConfig(
+ const uno::Reference<container::XNameContainer>& xContainer,
+ const ::rtl::Reference< UpdateCheckConfigListener >& rListener
+) : m_xContainer(xContainer), m_rListener(rListener)
+{
+}
+
+//------------------------------------------------------------------------------
+
+UpdateCheckConfig::~UpdateCheckConfig()
+{
+}
+
+//------------------------------------------------------------------------------
+
+::rtl::Reference< UpdateCheckConfig >
+UpdateCheckConfig::get(
+ const uno::Reference<uno::XComponentContext>& xContext,
+ const ::rtl::Reference< UpdateCheckConfigListener >& rListener)
+{
+ if( !xContext.is() )
+ throw uno::RuntimeException(
+ UNISTRING( "UpdateCheckConfig: empty component context" ),
+ uno::Reference< uno::XInterface >() );
+
+ uno::Reference< lang::XMultiComponentFactory > xServiceManager(xContext->getServiceManager());
+
+ if( !xServiceManager.is() )
+ throw uno::RuntimeException(
+ UNISTRING( "UpdateCheckConfig: unable to obtain service manager from component context" ),
+ uno::Reference< uno::XInterface >() );
+
+ uno::Reference< lang::XMultiServiceFactory > xConfigProvider(
+ xServiceManager->createInstanceWithContext( UNISTRING( "com.sun.star.configuration.ConfigurationProvider" ), xContext ),
+ uno::UNO_QUERY_THROW);
+
+ beans::PropertyValue aProperty;
+ aProperty.Name = UNISTRING( "nodepath" );
+ aProperty.Value = uno::makeAny( UNISTRING("org.openoffice.Office.Jobs/Jobs/UpdateCheck/Arguments") );
+
+ uno::Sequence< uno::Any > aArgumentList( 1 );
+ aArgumentList[0] = uno::makeAny( aProperty );
+
+ uno::Reference< container::XNameContainer > xContainer(
+ xConfigProvider->createInstanceWithArguments(
+ UNISTRING("com.sun.star.configuration.ConfigurationUpdateAccess"), aArgumentList ),
+ uno::UNO_QUERY_THROW );
+
+ return new UpdateCheckConfig( xContainer, rListener );
+}
+
+//------------------------------------------------------------------------------
+
+bool
+UpdateCheckConfig::isAutoCheckEnabled() const
+{
+ sal_Bool nValue = sal_False;
+ const_cast < UpdateCheckConfig *> (this)->getByName( UNISTRING( AUTOCHECK_ENABLED ) ) >>= nValue;
+ return nValue;
+}
+
+//------------------------------------------------------------------------------
+
+bool
+UpdateCheckConfig::isAutoDownloadEnabled() const
+{
+ sal_Bool nValue = sal_False;
+ const_cast < UpdateCheckConfig *> (this)->getByName( UNISTRING( AUTODOWNLOAD_ENABLED ) ) >>= nValue;
+ return nValue;
+}
+
+//------------------------------------------------------------------------------
+
+rtl::OUString
+UpdateCheckConfig::getUpdateEntryVersion() const
+{
+ rtl::OUString aValue;
+
+ // getByName is defined as non const in XNameAccess
+ const_cast < UpdateCheckConfig *> (this)->getByName( UNISTRING( OLD_VERSION ) ) >>= aValue;
+
+ return aValue;
+}
+
+//------------------------------------------------------------------------------
+
+sal_Int64
+UpdateCheckConfig::getLastChecked() const
+{
+ sal_Int64 nValue = 0;
+
+ // getByName is defined as non const in XNameAccess
+ const_cast < UpdateCheckConfig *> (this)->getByName( UNISTRING( LAST_CHECK ) ) >>= nValue;
+
+ return nValue;
+}
+
+//------------------------------------------------------------------------------
+
+sal_Int64
+UpdateCheckConfig::getCheckInterval() const
+{
+ sal_Int64 nValue = 0;
+
+ // getByName is defined as non const in XNameAccess
+ const_cast < UpdateCheckConfig *> (this)->getByName( UNISTRING( CHECK_INTERVAL ) ) >>= nValue;
+
+ return nValue;
+}
+
+//------------------------------------------------------------------------------
+
+rtl::OUString
+UpdateCheckConfig::getLocalFileName() const
+{
+ rtl::OUString aName = UNISTRING(LOCAL_FILE);
+ rtl::OUString aRet;
+
+ if( m_xContainer->hasByName(aName) )
+ m_xContainer->getByName(aName) >>= aRet;
+
+ return aRet;
+}
+
+//------------------------------------------------------------------------------
+
+rtl::OUString
+UpdateCheckConfig::getDownloadDestination() const
+{
+ rtl::OUString aName = UNISTRING(DOWNLOAD_DESTINATION);
+ rtl::OUString aRet;
+
+ const_cast <UpdateCheckConfig *> (this)->getByName(aName) >>= aRet;
+
+ return aRet;
+}
+
+//------------------------------------------------------------------------------
+
+void
+UpdateCheckConfig::storeLocalFileName(const rtl::OUString& rLocalFileName, sal_Int64 nFileSize)
+{
+ const sal_uInt8 nItems = 2;
+ const rtl::OUString aNameList[nItems] = { UNISTRING(LOCAL_FILE), UNISTRING(DOWNLOAD_SIZE) };
+ const uno::Any aValueList[nItems] = { uno::makeAny(rLocalFileName), uno::makeAny(nFileSize) };
+
+ for( sal_uInt8 i=0; i < nItems; ++i )
+ {
+ if( m_xContainer->hasByName(aNameList[i]) )
+ m_xContainer->replaceByName(aNameList[i], aValueList[i]);
+ else
+ m_xContainer->insertByName(aNameList[i], aValueList[i]);
+ }
+
+ commitChanges();
+}
+
+//------------------------------------------------------------------------------
+
+void
+UpdateCheckConfig::clearLocalFileName()
+{
+ const sal_uInt8 nItems = 2;
+ const rtl::OUString aNameList[nItems] = { UNISTRING(LOCAL_FILE), UNISTRING(DOWNLOAD_SIZE) };
+
+ for( sal_uInt8 i=0; i < nItems; ++i )
+ {
+ if( m_xContainer->hasByName(aNameList[i]) )
+ m_xContainer->removeByName(aNameList[i]);
+ }
+
+ commitChanges();
+}
+
+//------------------------------------------------------------------------------
+
+void
+UpdateCheckConfig::storeDownloadPaused(bool paused)
+{
+ replaceByName(UNISTRING(DOWNLOAD_PAUSED) , uno::makeAny(paused));
+ commitChanges();
+}
+
+//------------------------------------------------------------------------------
+
+void
+UpdateCheckConfig::updateLastChecked()
+{
+ TimeValue systime;
+ osl_getSystemTime(&systime);
+
+ sal_Int64 lastCheck = systime.Seconds;
+
+ replaceByName(UNISTRING(LAST_CHECK), uno::makeAny(lastCheck));
+}
+
+//------------------------------------------------------------------------------
+
+void
+UpdateCheckConfig::storeUpdateFound( const UpdateInfo& rInfo, const rtl::OUString& aCurrentBuild)
+
+{
+ bool autoDownloadEnabled = isAutoDownloadEnabled();
+
+ uno::Any aValues[nUpdateEntryProperties] =
+ {
+ uno::makeAny(rInfo.Version),
+ uno::makeAny(rInfo.BuildId),
+ uno::makeAny(rInfo.Description),
+ uno::makeAny(rInfo.Sources[0].URL),
+ uno::makeAny(rInfo.Sources[0].IsDirect ? sal_True : sal_False),
+ uno::makeAny(getReleaseNote(rInfo, 1, autoDownloadEnabled) ),
+ uno::makeAny(getReleaseNote(rInfo, 2, autoDownloadEnabled) ),
+ uno::makeAny(getReleaseNote(rInfo, 3, autoDownloadEnabled) ),
+ uno::makeAny(getReleaseNote(rInfo, 4, autoDownloadEnabled) ),
+ uno::makeAny(getReleaseNote(rInfo, 5, autoDownloadEnabled) ),
+ uno::makeAny(aCurrentBuild)
+ };
+
+ rtl::OUString aName;
+ for( sal_uInt32 n=0; n < nUpdateEntryProperties; ++n )
+ {
+ aName = rtl::OUString::createFromAscii(aUpdateEntryProperties[n]);
+
+ if( m_xContainer->hasByName(aName) )
+ m_xContainer->replaceByName(aName, aValues[n]);
+ else
+ m_xContainer->insertByName(aName,aValues[n]);
+ }
+
+ commitChanges();
+}
+
+//------------------------------------------------------------------------------
+
+void
+UpdateCheckConfig::clearUpdateFound()
+{
+ rtl::OUString aName;
+
+ for( sal_uInt32 n=0; n < nUpdateEntryProperties; ++n )
+ {
+ aName = rtl::OUString::createFromAscii(aUpdateEntryProperties[n]);
+
+ try {
+ if( m_xContainer->hasByName(aName) )
+ m_xContainer->removeByName(aName);
+ } catch(const lang::WrappedTargetException& ) {
+ // Can not remove value, probably in share layer
+ OSL_ASSERT(false);
+ m_xContainer->replaceByName(aName, uno::makeAny(rtl::OUString()));
+ }
+ }
+
+ /* As we have removed UpdateVersionFound from the shared configuration
+ * existing entries in the user layer do not have a oor operation and
+ * thus are completly ignored (which also means they can not be removed).
+ */
+
+ commitChanges();
+}
+
+//------------------------------------------------------------------------------
+
+uno::Sequence< rtl::OUString >
+UpdateCheckConfig::getServiceNames()
+{
+ uno::Sequence< rtl::OUString > aServiceList(1);
+ aServiceList[0] = UNISTRING( "com.sun.star.setup.UpdateCheckConfig");
+ return aServiceList;
+}
+
+//------------------------------------------------------------------------------
+
+rtl::OUString
+UpdateCheckConfig::getImplName()
+{
+ return UNISTRING( "vnd.sun.UpdateCheckConfig");
+}
+
+//------------------------------------------------------------------------------
+
+uno::Type SAL_CALL
+UpdateCheckConfig::getElementType() throw (uno::RuntimeException)
+{
+ return m_xContainer->getElementType();
+}
+
+//------------------------------------------------------------------------------
+
+sal_Bool SAL_CALL
+UpdateCheckConfig::hasElements() throw (uno::RuntimeException)
+{
+ return m_xContainer->hasElements();
+}
+
+//------------------------------------------------------------------------------
+
+uno::Any SAL_CALL
+UpdateCheckConfig::getByName( const ::rtl::OUString& aName )
+ throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException)
+{
+ uno::Any aValue = m_xContainer->getByName( aName );
+
+ // Provide dynamic default value
+ if( aName.equalsAscii(DOWNLOAD_DESTINATION) )
+ {
+ rtl::OUString aStr;
+ aValue >>= aStr;
+
+ if( aStr.getLength() == 0 )
+ aValue = uno::makeAny(getDesktopDirectory());
+ }
+
+ return aValue;
+}
+
+//------------------------------------------------------------------------------
+
+uno::Sequence< ::rtl::OUString > SAL_CALL
+UpdateCheckConfig::getElementNames( ) throw (uno::RuntimeException)
+{
+ return m_xContainer->getElementNames();
+}
+
+//------------------------------------------------------------------------------
+
+sal_Bool SAL_CALL
+UpdateCheckConfig::hasByName( const ::rtl::OUString& aName ) throw (uno::RuntimeException)
+{
+ return m_xContainer->hasByName( aName );
+}
+
+//------------------------------------------------------------------------------
+
+void SAL_CALL
+UpdateCheckConfig::replaceByName( const ::rtl::OUString& aName, const uno::Any& aElement )
+ throw (lang::IllegalArgumentException, container::NoSuchElementException,
+ lang::WrappedTargetException, uno::RuntimeException)
+{
+ return m_xContainer->replaceByName( aName, aElement );
+}
+
+//------------------------------------------------------------------------------
+// XChangesBatch
+
+void SAL_CALL
+UpdateCheckConfig::commitChanges()
+ throw (lang::WrappedTargetException, uno::RuntimeException)
+{
+ uno::Reference< util::XChangesBatch > xChangesBatch(m_xContainer, uno::UNO_QUERY);
+ if( xChangesBatch.is() && xChangesBatch->hasPendingChanges() )
+ {
+ util::ChangesSet aChangesSet = xChangesBatch->getPendingChanges();
+ xChangesBatch->commitChanges();
+
+ if( m_rListener.is() )
+ {
+ const sal_Int32 nChanges = aChangesSet.getLength();
+ rtl::OUString aString;
+
+ for( sal_Int32 i=0; i<nChanges; ++i )
+ {
+ aChangesSet[i].Accessor >>= aString;
+
+ // FIXME: use non IgnoreAsciiCase version as soon as it becomes available
+ if( aString.endsWithIgnoreAsciiCaseAsciiL(AUTOCHECK_ENABLED "']", sizeof(AUTOCHECK_ENABLED)+1) )
+ {
+ sal_Bool bEnabled = sal_False;
+ aChangesSet[i].Element >>= bEnabled;
+ m_rListener->autoCheckStatusChanged(sal_True == bEnabled);
+ }
+ // FIXME: use non IgnoreAsciiCase version as soon as it becomes available
+ else if( aString.endsWithIgnoreAsciiCaseAsciiL(CHECK_INTERVAL "']", sizeof(CHECK_INTERVAL)+1) )
+ {
+ m_rListener->autoCheckIntervalChanged();
+ }
+ }
+ }
+ }
+}
+
+//------------------------------------------------------------------------------
+
+sal_Bool SAL_CALL
+UpdateCheckConfig::hasPendingChanges( ) throw (uno::RuntimeException)
+{
+ uno::Reference< util::XChangesBatch > xChangesBatch(m_xContainer, uno::UNO_QUERY);
+ if( xChangesBatch.is() )
+ return xChangesBatch->hasPendingChanges();
+
+ return sal_False;
+}
+
+//------------------------------------------------------------------------------
+
+uno::Sequence< util::ElementChange > SAL_CALL
+UpdateCheckConfig::getPendingChanges( ) throw (uno::RuntimeException)
+{
+ uno::Reference< util::XChangesBatch > xChangesBatch(m_xContainer, uno::UNO_QUERY);
+ if( xChangesBatch.is() )
+ return xChangesBatch->getPendingChanges();
+
+ return uno::Sequence< util::ElementChange >();
+}
+
+//------------------------------------------------------------------------------
+void UpdateCheckConfig::storeExtensionVersion( const rtl::OUString& rExtensionName,
+ const rtl::OUString& rVersion )
+{
+ const rtl::OUString aExtName = UNISTRING( EXTENSION_PREFIX ) + rExtensionName;
+ const uno::Any aValue = uno::makeAny( rVersion );
+
+ if( m_xContainer->hasByName( aExtName ) )
+ m_xContainer->replaceByName( aExtName, aValue );
+ else
+ m_xContainer->insertByName( aExtName, aValue );
+
+ commitChanges();
+}
+
+//------------------------------------------------------------------------------
+bool UpdateCheckConfig::checkExtensionVersion( const rtl::OUString& rExtensionName,
+ const rtl::OUString& rVersion )
+{
+ const rtl::OUString aExtName = UNISTRING( EXTENSION_PREFIX ) + rExtensionName;
+
+ if( m_xContainer->hasByName( aExtName ) )
+ {
+ uno::Any aValue = m_xContainer->getByName( aExtName );
+ rtl::OUString aStoredVersion;
+ aValue >>= aStoredVersion;
+
+ if ( isVersionGreater( rVersion, aStoredVersion ) )
+ return true;
+ else
+ {
+ m_xContainer->removeByName( aExtName );
+ commitChanges();
+ }
+ }
+ return false;
+}
+
+//------------------------------------------------------------------------------
+rtl::OUString UpdateCheckConfig::getSubVersion( const rtl::OUString& rVersion,
+ sal_Int32 *nIndex )
+{
+ while ( *nIndex < rVersion.getLength() && rVersion[*nIndex] == '0')
+ {
+ ++*nIndex;
+ }
+
+ return rVersion.getToken( 0, '.', *nIndex );
+}
+
+//------------------------------------------------------------------------------
+// checks if the second version string is greater than the first one
+
+bool UpdateCheckConfig::isVersionGreater( const rtl::OUString& rVersion1,
+ const rtl::OUString& rVersion2 )
+{
+ for ( sal_Int32 i1 = 0, i2 = 0; i1 >= 0 || i2 >= 0; )
+ {
+ ::rtl::OUString sSub1( getSubVersion( rVersion1, &i1 ) );
+ ::rtl::OUString sSub2( getSubVersion( rVersion2, &i2 ) );
+
+ if ( sSub1.getLength() < sSub2.getLength() ) {
+ return true;
+ } else if ( sSub1.getLength() > sSub2.getLength() ) {
+ return false;
+ } else if ( sSub1 < sSub2 ) {
+ return true;
+ } else if ( sSub1 > sSub2 ) {
+ return false;
+ }
+ }
+ return false;
+}
+
+//------------------------------------------------------------------------------
+//------------------------------------------------------------------------------
+//------------------------------------------------------------------------------
+
+rtl::OUString SAL_CALL
+UpdateCheckConfig::getImplementationName() throw (uno::RuntimeException)
+{
+ return getImplName();
+}
+
+//------------------------------------------------------------------------------
+
+sal_Bool SAL_CALL
+UpdateCheckConfig::supportsService(rtl::OUString const & serviceName)
+ throw (uno::RuntimeException)
+{
+ uno::Sequence< rtl::OUString > aServiceNameList = getServiceNames();
+
+ for( sal_Int32 n=0; n < aServiceNameList.getLength(); n++ )
+ if( aServiceNameList[n].equals(serviceName) )
+ return sal_True;
+
+ return sal_False;
+}
+
+//------------------------------------------------------------------------------
+
+uno::Sequence< rtl::OUString > SAL_CALL
+UpdateCheckConfig::getSupportedServiceNames() throw (uno::RuntimeException)
+{
+ return getServiceNames();
+}
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/update/check/updatecheckconfig.hxx b/extensions/source/update/check/updatecheckconfig.hxx
new file mode 100644
index 000000000000..4149e9993aa7
--- /dev/null
+++ b/extensions/source/update/check/updatecheckconfig.hxx
@@ -0,0 +1,241 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include <cppuhelper/implbase3.hxx>
+#include <com/sun/star/beans/NamedValue.hpp>
+#include <com/sun/star/container/XNameContainer.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/uno/XComponentContext.hpp>
+#include <com/sun/star/util/XChangesBatch.hpp>
+#include <rtl/ref.hxx>
+
+#include "updatecheckconfiglistener.hxx"
+#include "updateinfo.hxx"
+
+/* Interface to acess configuration data read-only */
+struct IByNameAccess
+{
+ virtual ::com::sun::star::uno::Any getValue(const sal_Char * pName) = 0;
+};
+
+/* This helper class provides by name access to a sequence of named values */
+class NamedValueByNameAccess : public IByNameAccess
+{
+ const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue >& m_rValues;
+
+public:
+ NamedValueByNameAccess(
+ const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue >& rValues) :
+ m_rValues(rValues) {} ;
+
+ virtual ~NamedValueByNameAccess();
+
+ virtual ::com::sun::star::uno::Any getValue(const sal_Char * pName);
+};
+
+
+/* This class encapsulates the configuration item actually used for storing the state
+ * the update check is actually in.
+ */
+class UpdateCheckROModel
+{
+public:
+ UpdateCheckROModel(IByNameAccess& aNameAccess) : m_aNameAccess(aNameAccess) {};
+
+ bool isAutoCheckEnabled() const;
+ bool isDownloadPaused() const;
+ rtl::OUString getLocalFileName() const;
+ sal_Int64 getDownloadSize() const;
+
+ rtl::OUString getUpdateEntryVersion() const;
+ void getUpdateEntry(UpdateInfo& rInfo) const;
+
+private:
+
+ rtl::OUString getStringValue(const sal_Char *) const;
+
+ IByNameAccess& m_aNameAccess;
+};
+
+
+
+/* This class implements the non published UNO service com.sun.star.setup.UpdateCheckConfig,
+ * which primary use is to be able to track changes done in the Toos -> Options page of this
+ * component, as this is not supported by the OOo configuration for extendable groups.
+ */
+
+class UpdateCheckConfig : public ::cppu::WeakImplHelper3<
+ ::com::sun::star::container::XNameReplace,
+ ::com::sun::star::util::XChangesBatch,
+ ::com::sun::star::lang::XServiceInfo >
+{
+ UpdateCheckConfig(const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >& xContainer,
+ const ::rtl::Reference< UpdateCheckConfigListener >& rListener );
+
+ virtual ~UpdateCheckConfig();
+
+public:
+
+ static ::com::sun::star::uno::Sequence< rtl::OUString > getServiceNames();
+ static rtl::OUString getImplName();
+
+ static ::rtl::Reference< UpdateCheckConfig > get(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& xContext,
+ const ::rtl::Reference< UpdateCheckConfigListener >& rListener = ::rtl::Reference< UpdateCheckConfigListener >());
+
+ // Should really implement ROModel ..
+ bool isAutoCheckEnabled() const;
+ bool isAutoDownloadEnabled() const;
+ rtl::OUString getUpdateEntryVersion() const;
+
+ /* Updates the timestamp of last check, but does not commit the change
+ * as either clearUpdateFound() or setUpdateFound() are expected to get
+ * called next.
+ */
+ void updateLastChecked();
+
+ /* Returns the date of the last successful check in seconds since 1970 */
+ sal_Int64 getLastChecked() const;
+
+ /* Returns configured check interval in seconds */
+ sal_Int64 getCheckInterval() const;
+
+ /* Reset values of previously remembered update
+ */
+ void clearUpdateFound();
+
+ /* Stores the specified data of an available update
+ */
+ void storeUpdateFound(const UpdateInfo& rInfo, const rtl::OUString& aCurrentBuild);
+
+ // Returns the local file name of a started download
+ rtl::OUString getLocalFileName() const;
+
+ // Returns the local file name of a started download
+ rtl::OUString getDownloadDestination() const;
+
+ // stores the local file name of a just started download
+ void storeLocalFileName(const rtl::OUString& rFileName, sal_Int64 nFileSize);
+
+ // Removes the local file name of a download
+ void clearLocalFileName();
+
+ // Stores the bool value for manually paused downloads
+ void storeDownloadPaused(bool paused);
+
+ // Returns the directory that acts as the user's desktop
+ static rtl::OUString getDesktopDirectory();
+
+ // Returns a directory accessible for all users
+ static rtl::OUString getAllUsersDirectory();
+
+ // store and retrieve information about extensions
+ void storeExtensionVersion( const rtl::OUString& rExtensionName,
+ const rtl::OUString& rVersion );
+ bool checkExtensionVersion( const rtl::OUString& rExtensionName,
+ const rtl::OUString& rVersion );
+
+ // XElementAccess
+ virtual ::com::sun::star::uno::Type SAL_CALL getElementType( )
+ throw (::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL hasElements( )
+ throw (::com::sun::star::uno::RuntimeException);
+
+ // XNameAccess
+ virtual ::com::sun::star::uno::Any SAL_CALL getByName( const ::rtl::OUString& aName )
+ throw (::com::sun::star::container::NoSuchElementException,
+ ::com::sun::star::lang::WrappedTargetException,
+ ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getElementNames( )
+ throw (::com::sun::star::uno::RuntimeException);
+ virtual ::sal_Bool SAL_CALL hasByName( const ::rtl::OUString& aName )
+ throw (::com::sun::star::uno::RuntimeException);
+
+ // XNameReplace
+ virtual void SAL_CALL replaceByName( const ::rtl::OUString& aName, const ::com::sun::star::uno::Any& aElement )
+ throw (::com::sun::star::lang::IllegalArgumentException,
+ ::com::sun::star::container::NoSuchElementException,
+ ::com::sun::star::lang::WrappedTargetException,
+ ::com::sun::star::uno::RuntimeException);
+
+ // XChangesBatch
+ virtual void SAL_CALL commitChanges( )
+ throw (::com::sun::star::lang::WrappedTargetException,
+ ::com::sun::star::uno::RuntimeException);
+ virtual ::sal_Bool SAL_CALL hasPendingChanges( )
+ throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::util::ElementChange > SAL_CALL getPendingChanges( )
+ throw (::com::sun::star::uno::RuntimeException);
+
+ // XServiceInfo
+ virtual rtl::OUString SAL_CALL getImplementationName()
+ throw (::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsService(rtl::OUString const & serviceName)
+ throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL getSupportedServiceNames()
+ throw (::com::sun::star::uno::RuntimeException);
+
+private:
+
+ static rtl::OUString getSubVersion( const rtl::OUString& rVersion, sal_Int32 *nIndex );
+ static bool isVersionGreater( const rtl::OUString& rVersion1, const rtl::OUString& rVersion2 );
+
+ const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer > m_xContainer;
+ const ::rtl::Reference< UpdateCheckConfigListener > m_rListener;
+};
+
+//------------------------------------------------------------------------------
+
+
+template <typename T>
+T getValue( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::NamedValue >& rNamedValues, const sal_Char * pszName )
+ throw (::com::sun::star::uno::RuntimeException)
+{
+ for( sal_Int32 n=0; n < rNamedValues.getLength(); n++ )
+ {
+ // Unfortunatly gcc-3.3 does not like Any.get<T>();
+ if( rNamedValues[n].Name.equalsAscii( pszName ) )
+ {
+ T value = T();
+ if( ! (rNamedValues[n].Value >>= value) )
+ throw ::com::sun::star::uno::RuntimeException(
+ ::rtl::OUString(
+ cppu_Any_extraction_failure_msg(
+ &rNamedValues[n].Value,
+ ::cppu::getTypeFavourUnsigned(&value).getTypeLibType() ),
+ SAL_NO_ACQUIRE ),
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >() );
+
+ return value;
+ }
+ }
+
+ return T();
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/update/check/updatecheckconfiglistener.hxx b/extensions/source/update/check/updatecheckconfiglistener.hxx
new file mode 100644
index 000000000000..d0c79eb655fa
--- /dev/null
+++ b/extensions/source/update/check/updatecheckconfiglistener.hxx
@@ -0,0 +1,46 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include <rtl/ref.hxx>
+
+#ifndef _UPDATECHECKCONFIGLISTENER_HXX_
+#define _UPDATECHECKCONFIGLISTENER_HXX_
+
+/* This interface should be implemented by classes acting
+ * as controller (as in the MVC pattern).
+ */
+
+struct UpdateCheckConfigListener : public rtl::IReference
+{
+ virtual void autoCheckStatusChanged(bool enabled) = 0;
+ virtual void autoCheckIntervalChanged() = 0;
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/update/check/updatecheckjob.cxx b/extensions/source/update/check/updatecheckjob.cxx
new file mode 100644
index 000000000000..995e4f526b22
--- /dev/null
+++ b/extensions/source/update/check/updatecheckjob.cxx
@@ -0,0 +1,413 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+
+#include <memory>
+
+#include "updatecheck.hxx"
+#include "updatecheckconfig.hxx"
+#include "updatehdl.hxx"
+#include "updateprotocol.hxx"
+
+#include <cppuhelper/implbase3.hxx>
+#include <cppuhelper/implementationentry.hxx>
+
+#include "com/sun/star/frame/XDesktop.hpp"
+#include "com/sun/star/frame/XTerminateListener.hpp"
+#include <com/sun/star/task/XJob.hpp>
+
+namespace beans = com::sun::star::beans ;
+namespace frame = com::sun::star::frame ;
+namespace lang = com::sun::star::lang ;
+namespace task = com::sun::star::task ;
+namespace uno = com::sun::star::uno ;
+
+#define UNISTRING(s) rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(s))
+
+namespace
+{
+
+class InitUpdateCheckJobThread : public osl::Thread
+{
+public:
+ InitUpdateCheckJobThread( const uno::Reference< uno::XComponentContext > &xContext,
+ const uno::Sequence< beans::NamedValue > &xParameters,
+ bool bShowDialog );
+
+ virtual void SAL_CALL run();
+
+ void setTerminating();
+
+private:
+ osl::Condition m_aCondition;
+ uno::Reference<uno::XComponentContext> m_xContext;
+ uno::Sequence<beans::NamedValue> m_xParameters;
+ bool m_bShowDialog;
+ bool m_bTerminating;
+};
+
+class UpdateCheckJob :
+ public ::cppu::WeakImplHelper3< task::XJob, lang::XServiceInfo, frame::XTerminateListener >
+{
+ virtual ~UpdateCheckJob();
+
+public:
+
+ UpdateCheckJob(const uno::Reference<uno::XComponentContext>& xContext);
+
+ static uno::Sequence< rtl::OUString > getServiceNames();
+ static rtl::OUString getImplName();
+
+ // Allows runtime exceptions to be thrown by const methods
+ inline SAL_CALL operator uno::Reference< uno::XInterface > () const
+ { return const_cast< cppu::OWeakObject * > (static_cast< cppu::OWeakObject const * > (this)); };
+
+ // XJob
+ virtual uno::Any SAL_CALL execute(const uno::Sequence<beans::NamedValue>&)
+ throw (lang::IllegalArgumentException, uno::Exception);
+
+ // XServiceInfo
+ virtual rtl::OUString SAL_CALL getImplementationName()
+ throw (uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsService(rtl::OUString const & serviceName)
+ throw (uno::RuntimeException);
+ virtual uno::Sequence< rtl::OUString > SAL_CALL getSupportedServiceNames()
+ throw (uno::RuntimeException);
+
+ // XEventListener
+ virtual void SAL_CALL disposing( ::com::sun::star::lang::EventObject const & evt )
+ throw (::com::sun::star::uno::RuntimeException);
+
+ // XTerminateListener
+ virtual void SAL_CALL queryTermination( lang::EventObject const & evt )
+ throw ( frame::TerminationVetoException, uno::RuntimeException );
+ virtual void SAL_CALL notifyTermination( lang::EventObject const & evt )
+ throw ( uno::RuntimeException );
+
+private:
+ uno::Reference<uno::XComponentContext> m_xContext;
+ uno::Reference< frame::XDesktop > m_xDesktop;
+ std::auto_ptr< InitUpdateCheckJobThread > m_pInitThread;
+
+ void handleExtensionUpdates( const uno::Sequence< beans::NamedValue > &rListProp );
+};
+
+//------------------------------------------------------------------------------
+//------------------------------------------------------------------------------
+//------------------------------------------------------------------------------
+InitUpdateCheckJobThread::InitUpdateCheckJobThread(
+ const uno::Reference< uno::XComponentContext > &xContext,
+ const uno::Sequence< beans::NamedValue > &xParameters,
+ bool bShowDialog ) :
+ m_xContext( xContext ),
+ m_xParameters( xParameters ),
+ m_bShowDialog( bShowDialog ),
+ m_bTerminating( false )
+{
+ create();
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL InitUpdateCheckJobThread::run()
+{
+ if (!m_bShowDialog) {
+ TimeValue tv = { 25, 0 };
+ m_aCondition.wait( &tv );
+ if ( m_bTerminating )
+ return;
+ }
+
+ rtl::Reference< UpdateCheck > aController( UpdateCheck::get() );
+ aController->initialize( m_xParameters, m_xContext );
+
+ if ( m_bShowDialog )
+ aController->showDialog( true );
+}
+
+void InitUpdateCheckJobThread::setTerminating() {
+ m_bTerminating = true;
+ m_aCondition.set();
+}
+
+//------------------------------------------------------------------------------
+//------------------------------------------------------------------------------
+//------------------------------------------------------------------------------
+
+UpdateCheckJob::UpdateCheckJob( const uno::Reference<uno::XComponentContext>& xContext ) :
+ m_xContext(xContext)
+{
+ m_xDesktop.set( xContext->getServiceManager()->createInstanceWithContext( UNISTRING("com.sun.star.frame.Desktop"), xContext ), uno::UNO_QUERY );
+ if ( m_xDesktop.is() )
+ m_xDesktop->addTerminateListener( this );
+}
+
+//------------------------------------------------------------------------------
+
+UpdateCheckJob::~UpdateCheckJob()
+{
+}
+
+//------------------------------------------------------------------------------
+
+uno::Sequence< rtl::OUString >
+UpdateCheckJob::getServiceNames()
+{
+ uno::Sequence< rtl::OUString > aServiceList(1);
+ aServiceList[0] = UNISTRING( "com.sun.star.setup.UpdateCheck");
+ return aServiceList;
+};
+
+//------------------------------------------------------------------------------
+
+rtl::OUString
+UpdateCheckJob::getImplName()
+{
+ return UNISTRING( "vnd.sun.UpdateCheck");
+}
+
+
+//------------------------------------------------------------------------------
+
+uno::Any
+UpdateCheckJob::execute(const uno::Sequence<beans::NamedValue>& namedValues)
+ throw (lang::IllegalArgumentException, uno::Exception)
+{
+ for ( sal_Int32 n=namedValues.getLength(); n-- > 0; )
+ {
+ if ( namedValues[ n ].Name.equalsAscii( "DynamicData" ) )
+ {
+ uno::Sequence<beans::NamedValue> aListProp;
+ if ( namedValues[n].Value >>= aListProp )
+ {
+ for ( sal_Int32 i=aListProp.getLength(); i-- > 0; )
+ {
+ if ( aListProp[ i ].Name.equalsAscii( "updateList" ) )
+ {
+ handleExtensionUpdates( aListProp );
+ return uno::Any();
+ }
+ }
+ }
+ }
+ }
+
+ uno::Sequence<beans::NamedValue> aConfig =
+ getValue< uno::Sequence<beans::NamedValue> > (namedValues, "JobConfig");
+
+ /* Determine the way we got invoked here -
+ * see Developers Guide Chapter "4.7.2 Jobs" to understand the magic
+ */
+
+ uno::Sequence<beans::NamedValue> aEnvironment =
+ getValue< uno::Sequence<beans::NamedValue> > (namedValues, "Environment");
+
+ rtl::OUString aEventName = getValue< rtl::OUString > (aEnvironment, "EventName");
+
+ m_pInitThread.reset(
+ new InitUpdateCheckJobThread(
+ m_xContext, aConfig,
+ !aEventName.equalsAscii("onFirstVisibleTask")));
+
+ return uno::Any();
+}
+
+//------------------------------------------------------------------------------
+void UpdateCheckJob::handleExtensionUpdates( const uno::Sequence< beans::NamedValue > &rListProp )
+{
+ try {
+ uno::Sequence< uno::Sequence< rtl::OUString > > aList =
+ getValue< uno::Sequence< uno::Sequence< rtl::OUString > > > ( rListProp, "updateList" );
+ bool bPrepareOnly = getValue< bool > ( rListProp, "prepareOnly" );
+
+ // we will first store any new found updates and then check, if there are any
+ // pending updates.
+ storeExtensionUpdateInfos( m_xContext, aList );
+
+ if ( bPrepareOnly )
+ return;
+
+ bool bHasUpdates = checkForPendingUpdates( m_xContext );
+
+ rtl::Reference<UpdateCheck> aController( UpdateCheck::get() );
+ if ( ! aController.is() )
+ return;
+
+ aController->setHasExtensionUpdates( bHasUpdates );
+
+ if ( ! aController->hasOfficeUpdate() )
+ {
+ if ( bHasUpdates )
+ aController->setUIState( UPDATESTATE_EXT_UPD_AVAIL, true );
+ else
+ aController->setUIState( UPDATESTATE_NO_UPDATE_AVAIL, true );
+ }
+ }
+ catch( const uno::Exception& e )
+ {
+ OSL_TRACE( "Caught exception: %s\n thread terminated.\n",
+ rtl::OUStringToOString(e.Message, RTL_TEXTENCODING_UTF8).getStr());
+ }
+}
+
+//------------------------------------------------------------------------------
+
+rtl::OUString SAL_CALL
+UpdateCheckJob::getImplementationName() throw (uno::RuntimeException)
+{
+ return getImplName();
+}
+
+//------------------------------------------------------------------------------
+
+uno::Sequence< rtl::OUString > SAL_CALL
+UpdateCheckJob::getSupportedServiceNames() throw (uno::RuntimeException)
+{
+ return getServiceNames();
+}
+
+//------------------------------------------------------------------------------
+
+sal_Bool SAL_CALL
+UpdateCheckJob::supportsService( rtl::OUString const & serviceName ) throw (uno::RuntimeException)
+{
+ uno::Sequence< rtl::OUString > aServiceNameList = getServiceNames();
+
+ for( sal_Int32 n=0; n < aServiceNameList.getLength(); n++ )
+ if( aServiceNameList[n].equals(serviceName) )
+ return sal_True;
+
+ return sal_False;
+}
+
+//------------------------------------------------------------------------------
+// XEventListener
+void SAL_CALL UpdateCheckJob::disposing( lang::EventObject const & rEvt )
+ throw ( uno::RuntimeException )
+{
+ bool shutDown = ( rEvt.Source == m_xDesktop );
+
+ if ( shutDown && m_xDesktop.is() )
+ {
+ m_xDesktop->removeTerminateListener( this );
+ m_xDesktop.clear();
+ }
+}
+
+//------------------------------------------------------------------------------
+// XTerminateListener
+void SAL_CALL UpdateCheckJob::queryTermination( lang::EventObject const & )
+ throw ( frame::TerminationVetoException, uno::RuntimeException )
+{
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL UpdateCheckJob::notifyTermination( lang::EventObject const & rEvt )
+ throw ( uno::RuntimeException )
+{
+ if ( m_pInitThread.get() != 0 )
+ m_pInitThread->setTerminating();
+
+ disposing( rEvt );
+}
+
+} // anonymous namespace
+
+//------------------------------------------------------------------------------
+
+static uno::Reference<uno::XInterface> SAL_CALL
+createJobInstance(const uno::Reference<uno::XComponentContext>& xContext)
+{
+ return *new UpdateCheckJob(xContext);
+}
+
+//------------------------------------------------------------------------------
+
+static uno::Reference<uno::XInterface> SAL_CALL
+createConfigInstance(const uno::Reference<uno::XComponentContext>& xContext)
+{
+ return *UpdateCheckConfig::get(xContext, *UpdateCheck::get());
+}
+
+//------------------------------------------------------------------------------
+
+static const cppu::ImplementationEntry kImplementations_entries[] =
+{
+ {
+ createJobInstance,
+ UpdateCheckJob::getImplName,
+ UpdateCheckJob::getServiceNames,
+ cppu::createSingleComponentFactory,
+ NULL,
+ 0
+ },
+ {
+ createConfigInstance,
+ UpdateCheckConfig::getImplName,
+ UpdateCheckConfig::getServiceNames,
+ cppu::createSingleComponentFactory,
+ NULL,
+ 0
+ },
+ { NULL, NULL, NULL, NULL, NULL, 0 }
+} ;
+
+//------------------------------------------------------------------------------
+
+extern "C" void SAL_CALL
+component_getImplementationEnvironment( const sal_Char **aEnvTypeName, uno_Environment **)
+{
+ *aEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME ;
+}
+
+//------------------------------------------------------------------------------
+
+extern "C" sal_Bool SAL_CALL
+component_writeInfo(void *pServiceManager, void *pRegistryKey)
+{
+ return cppu::component_writeInfoHelper(
+ pServiceManager,
+ pRegistryKey,
+ kImplementations_entries
+ );
+}
+
+//------------------------------------------------------------------------------
+
+extern "C" void *
+component_getFactory(const sal_Char *pszImplementationName, void *pServiceManager, void *pRegistryKey)
+{
+ return cppu::component_getFactoryHelper(
+ pszImplementationName,
+ pServiceManager,
+ pRegistryKey,
+ kImplementations_entries) ;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/update/check/updatehdl.cxx b/extensions/source/update/check/updatehdl.cxx
new file mode 100644
index 000000000000..6210a8af77a7
--- /dev/null
+++ b/extensions/source/update/check/updatehdl.cxx
@@ -0,0 +1,1422 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+
+#include "updatehdl.hxx"
+#include "update.hrc"
+
+#include "osl/diagnose.h"
+#include "osl/thread.hxx"
+#include "osl/file.hxx"
+#include "rtl/ustring.hxx"
+#include "rtl/bootstrap.hxx"
+
+#include "com/sun/star/uno/Sequence.h"
+
+#include <com/sun/star/style/VerticalAlignment.hpp>
+
+#include "com/sun/star/awt/ActionEvent.hpp"
+#include "com/sun/star/awt/PushButtonType.hpp"
+#include "com/sun/star/awt/VclWindowPeerAttribute.hpp"
+#include "com/sun/star/awt/WindowAttribute.hpp"
+#include "com/sun/star/awt/XButton.hpp"
+#include "com/sun/star/awt/XControl.hpp"
+#include "com/sun/star/awt/XControlContainer.hpp"
+#include "com/sun/star/awt/XMessageBox.hpp"
+#include "com/sun/star/awt/XThrobber.hpp"
+#include "com/sun/star/awt/XTopWindow.hpp"
+#include "com/sun/star/awt/XVclWindowPeer.hpp"
+#include "com/sun/star/awt/XVclContainer.hpp"
+#include "com/sun/star/awt/XWindow.hpp"
+#include "com/sun/star/awt/XWindow2.hpp"
+
+#include <com/sun/star/beans/PropertyValue.hpp>
+#include "com/sun/star/beans/XPropertySet.hpp"
+
+#include "com/sun/star/container/XNameContainer.hpp"
+
+#include "com/sun/star/frame/XDesktop.hpp"
+
+#include "com/sun/star/lang/XMultiServiceFactory.hpp"
+#include "com/sun/star/task/InteractionRequestStringResolver.hpp"
+
+#include <com/sun/star/resource/XResourceBundleLoader.hpp>
+
+#include "updatehdl.hrc"
+
+#define UNISTRING(s) rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(s))
+
+#define COMMAND_CLOSE UNISTRING("close")
+
+#define CTRL_THROBBER UNISTRING("throbber")
+#define CTRL_PROGRESS UNISTRING("progress")
+
+#define TEXT_STATUS UNISTRING("text_status")
+#define TEXT_PERCENT UNISTRING("text_percent")
+#define TEXT_DESCRIPTION UNISTRING("text_description")
+
+#define FIXED_LINE_MODEL UNISTRING("com.sun.star.awt.UnoControlFixedLineModel")
+#define FIXED_TEXT_MODEL UNISTRING("com.sun.star.awt.UnoControlFixedTextModel")
+#define EDIT_FIELD_MODEL UNISTRING("com.sun.star.awt.UnoControlEditModel")
+#define BUTTON_MODEL UNISTRING("com.sun.star.awt.UnoControlButtonModel")
+#define GROUP_BOX_MODEL UNISTRING("com.sun.star.awt.UnoControlGroupBoxModel")
+
+using namespace com::sun::star;
+
+//--------------------------------------------------------------------
+UpdateHandler::UpdateHandler( const uno::Reference< uno::XComponentContext > & rxContext,
+ const rtl::Reference< IActionListener > & rxActionListener ) :
+ mxContext( rxContext ),
+ mxActionListener( rxActionListener ),
+ meCurState( UPDATESTATES_COUNT ),
+ meLastState( UPDATESTATES_COUNT ),
+ mnPercent( 0 ),
+ mnLastCtrlState( -1 ),
+ mbDownloadBtnHasDots( false ),
+ mbVisible( false ),
+ mbStringsLoaded( false ),
+ mbMinimized( false ),
+ mbListenerAdded(false),
+ mbShowsMessageBox(false)
+{
+}
+
+//--------------------------------------------------------------------
+UpdateHandler::~UpdateHandler()
+{
+ mxContext = NULL;
+ mxUpdDlg = NULL;
+ mxInteractionHdl = NULL;
+ mxActionListener = NULL;
+}
+
+//--------------------------------------------------------------------
+void UpdateHandler::enableControls( short nCtrlState )
+{
+ osl::MutexGuard aGuard( maMutex );
+
+ if ( nCtrlState == mnLastCtrlState )
+ return;
+
+ bool bEnableControl;
+
+ short nCurStateVal = nCtrlState;
+ short nOldStateVal = mnLastCtrlState;
+
+ // the help button should always be the last button in the
+ // enum list und must never be disabled
+ for ( int i=0; i<HELP_BUTTON; i++ )
+ {
+ nCurStateVal = (short)(nCtrlState >> i);
+ nOldStateVal = (short)(mnLastCtrlState >> i);
+ if ( ( nCurStateVal & 0x01 ) != ( nOldStateVal & 0x01 ) )
+ {
+ bEnableControl = ( ( nCurStateVal & 0x01 ) == 0x01 );
+ setControlProperty( msButtonIDs[i], UNISTRING("Enabled"), uno::Any( bEnableControl ) );
+ }
+ }
+
+ mnLastCtrlState = nCtrlState;
+}
+
+//--------------------------------------------------------------------
+void UpdateHandler::setDownloadBtnLabel( bool bAppendDots )
+{
+ osl::MutexGuard aGuard( maMutex );
+
+ if ( mbDownloadBtnHasDots != bAppendDots )
+ {
+ rtl::OUString aLabel( msDownload );
+
+ if ( bAppendDots )
+ aLabel += UNISTRING( "..." );
+
+ setControlProperty( msButtonIDs[DOWNLOAD_BUTTON], UNISTRING("Label"), uno::Any( aLabel ) );
+ setControlProperty( msButtonIDs[DOWNLOAD_BUTTON], UNISTRING("HelpURL"), uno::Any( UNISTRING( "HID:" ) + rtl::OUString::valueOf( (sal_Int32) HID_CHECK_FOR_UPD_DOWNLOAD2 ) ) );
+
+ mbDownloadBtnHasDots = bAppendDots;
+ }
+}
+
+//--------------------------------------------------------------------
+void UpdateHandler::setState( UpdateState eState )
+{
+ osl::MutexGuard aGuard( maMutex );
+
+ meCurState = eState;
+
+ if ( mxUpdDlg.is() && mbVisible )
+ updateState( meCurState );
+}
+
+//--------------------------------------------------------------------
+bool UpdateHandler::isVisible() const
+{
+ if ( !mxUpdDlg.is() ) return false;
+
+ uno::Reference< awt::XWindow2 > xWindow( mxUpdDlg, uno::UNO_QUERY );
+
+ if ( xWindow.is() )
+ return xWindow->isVisible();
+ else
+ return false;
+}
+
+//--------------------------------------------------------------------
+void UpdateHandler::setVisible( bool bVisible )
+{
+ osl::MutexGuard aGuard( maMutex );
+
+ mbVisible = bVisible;
+
+ if ( bVisible )
+ {
+ if ( !mxUpdDlg.is() )
+ createDialog();
+
+ // this should never happen, but if it happens we better return here
+ if ( !mxUpdDlg.is() )
+ return;
+
+ updateState( meCurState );
+
+ uno::Reference< awt::XWindow > xWindow( mxUpdDlg, uno::UNO_QUERY );
+
+ if ( xWindow.is() )
+ xWindow->setVisible( bVisible );
+
+ uno::Reference< awt::XTopWindow > xTopWindow( mxUpdDlg, uno::UNO_QUERY );
+ if ( xTopWindow.is() )
+ {
+ xTopWindow->toFront();
+ if ( !mbListenerAdded )
+ {
+ xTopWindow->addTopWindowListener( this );
+ mbListenerAdded = true;
+ }
+ }
+ }
+ else if ( mxUpdDlg.is() )
+ {
+ uno::Reference< awt::XWindow > xWindow( mxUpdDlg, uno::UNO_QUERY );
+
+ if ( xWindow.is() )
+ xWindow->setVisible( bVisible );
+ }
+}
+
+//--------------------------------------------------------------------
+void UpdateHandler::setProgress( sal_Int32 nPercent )
+{
+ if ( nPercent > 100 )
+ nPercent = 100;
+ else if ( nPercent < 0 )
+ nPercent = 0;
+
+ if ( nPercent != mnPercent )
+ {
+ osl::MutexGuard aGuard( maMutex );
+
+ mnPercent = nPercent;
+ setControlProperty( CTRL_PROGRESS, UNISTRING("ProgressValue"), uno::Any( nPercent ) );
+ setControlProperty( TEXT_PERCENT, UNISTRING("Text"), uno::Any( substVariables(msPercent) ) );
+ }
+}
+
+//--------------------------------------------------------------------
+void UpdateHandler::setErrorMessage( const rtl::OUString& rErrorMsg )
+{
+ setControlProperty( TEXT_DESCRIPTION, UNISTRING("Text"), uno::Any( rErrorMsg ) );
+}
+
+//--------------------------------------------------------------------
+void UpdateHandler::setDownloadFile( const rtl::OUString& rFilePath )
+{
+ sal_Int32 nLast = rFilePath.lastIndexOf( '/' );
+ if ( nLast != -1 )
+ {
+ msDownloadFile = rFilePath.copy( nLast+1 );
+ const rtl::OUString aDownloadURL = rFilePath.copy( 0, nLast );
+ osl::FileBase::getSystemPathFromFileURL( aDownloadURL, msDownloadPath );
+ }
+}
+
+//--------------------------------------------------------------------
+rtl::OUString UpdateHandler::getBubbleText( UpdateState eState )
+{
+ osl::MutexGuard aGuard( maMutex );
+
+ rtl::OUString sText;
+ sal_Int32 nIndex = (sal_Int32) eState;
+
+ loadStrings();
+
+ if ( ( UPDATESTATE_UPDATE_AVAIL <= nIndex ) && ( nIndex < UPDATESTATES_COUNT ) )
+ sText = substVariables( msBubbleTexts[ nIndex - UPDATESTATE_UPDATE_AVAIL ] );
+
+ return sText;
+}
+
+//--------------------------------------------------------------------
+rtl::OUString UpdateHandler::getBubbleTitle( UpdateState eState )
+{
+ osl::MutexGuard aGuard( maMutex );
+
+ rtl::OUString sText;
+ sal_Int32 nIndex = (sal_Int32) eState;
+
+ loadStrings();
+
+ if ( ( UPDATESTATE_UPDATE_AVAIL <= nIndex ) && ( nIndex < UPDATESTATES_COUNT ) )
+ sText = substVariables( msBubbleTitles[ nIndex - UPDATESTATE_UPDATE_AVAIL] );
+
+ return sText;
+}
+
+//--------------------------------------------------------------------
+rtl::OUString UpdateHandler::getDefaultInstErrMsg()
+{
+ osl::MutexGuard aGuard( maMutex );
+
+ loadStrings();
+
+ return substVariables( msInstallError );
+}
+
+// XActionListener
+//--------------------------------------------------------------------
+void SAL_CALL UpdateHandler::disposing( const lang::EventObject& rEvt )
+ throw( uno::RuntimeException )
+{
+ if ( rEvt.Source == mxUpdDlg )
+ mxUpdDlg.clear();
+}
+
+//--------------------------------------------------------------------
+void SAL_CALL UpdateHandler::actionPerformed( awt::ActionEvent const & rEvent )
+ throw( uno::RuntimeException )
+{
+ DialogControls eButton = BUTTON_COUNT;
+ for ( int i = 0; i < BUTTON_COUNT; i++ )
+ {
+ if ( rEvent.ActionCommand.equals( msButtonIDs[i] ) )
+ {
+ eButton = (DialogControls) i;
+ break;
+ }
+ }
+
+ if ( rEvent.ActionCommand.equals( COMMAND_CLOSE ) )
+ {
+ if ( ( mnLastCtrlState & ( 1 << CLOSE_BUTTON ) ) == ( 1 << CLOSE_BUTTON ) )
+ eButton = CLOSE_BUTTON;
+ else
+ eButton = CANCEL_BUTTON;
+ }
+
+ switch ( eButton ) {
+ case CANCEL_BUTTON:
+ {
+ bool bCancel = true;
+
+ if ( ( meCurState == UPDATESTATE_DOWNLOADING ) ||
+ ( meCurState == UPDATESTATE_DOWNLOAD_PAUSED ) ||
+ ( meCurState == UPDATESTATE_ERROR_DOWNLOADING ) )
+ bCancel = showWarning( msCancelMessage );
+
+ if ( bCancel )
+ {
+ mxActionListener->cancel();
+ setVisible( false );
+ }
+ break;
+ }
+ case CLOSE_BUTTON:
+ setVisible( false );
+ if ( meCurState == UPDATESTATE_ERROR_CHECKING )
+ mxActionListener->closeAfterFailure();
+ break;
+ case DOWNLOAD_BUTTON:
+ mxActionListener->download();
+ break;
+ case INSTALL_BUTTON:
+ if ( showWarning( msInstallMessage ) )
+ mxActionListener->install();
+ break;
+ case PAUSE_BUTTON:
+ mxActionListener->pause();
+ break;
+ case RESUME_BUTTON:
+ mxActionListener->resume();
+ break;
+ case HELP_BUTTON:
+ break;
+ default:
+ OSL_ENSURE( false, "UpdateHandler::actionPerformed: unknown command!" );
+ }
+}
+
+// XTopWindowListener
+//--------------------------------------------------------------------
+void SAL_CALL UpdateHandler::windowOpened( const lang::EventObject& )
+ throw( uno::RuntimeException )
+{
+}
+
+//--------------------------------------------------------------------
+void SAL_CALL UpdateHandler::windowClosing( const lang::EventObject& e )
+ throw( uno::RuntimeException )
+{
+ awt::ActionEvent aActionEvt;
+ aActionEvt.ActionCommand = COMMAND_CLOSE;
+ aActionEvt.Source = e.Source;
+
+ actionPerformed( aActionEvt );
+}
+
+//--------------------------------------------------------------------
+void SAL_CALL UpdateHandler::windowClosed( const lang::EventObject& )
+ throw( uno::RuntimeException )
+{
+}
+
+//--------------------------------------------------------------------
+void SAL_CALL UpdateHandler::windowMinimized( const lang::EventObject& )
+ throw( uno::RuntimeException )
+{
+ mbMinimized = true;
+}
+
+//--------------------------------------------------------------------
+void SAL_CALL UpdateHandler::windowNormalized( const lang::EventObject& )
+ throw( uno::RuntimeException )
+{
+ mbMinimized = false;
+}
+
+//--------------------------------------------------------------------
+void SAL_CALL UpdateHandler::windowActivated( const lang::EventObject& )
+ throw( uno::RuntimeException )
+{
+}
+
+//--------------------------------------------------------------------
+void SAL_CALL UpdateHandler::windowDeactivated( const lang::EventObject& )
+ throw( uno::RuntimeException )
+{
+}
+
+// XInteractionHandler
+//------------------------------------------------------------------------------
+void SAL_CALL UpdateHandler::handle( uno::Reference< task::XInteractionRequest > const & rRequest)
+ throw (uno::RuntimeException)
+{
+ if ( !mxInteractionHdl.is() )
+ {
+ if( !mxContext.is() )
+ throw uno::RuntimeException( UNISTRING( "UpdateHandler:: empty component context" ), *this );
+
+ uno::Reference< lang::XMultiComponentFactory > xServiceManager(mxContext->getServiceManager());
+
+ if( !xServiceManager.is() )
+ throw uno::RuntimeException( UNISTRING( "UpdateHandler: unable to obtain service manager from component context" ), *this );
+
+ mxInteractionHdl = uno::Reference<task::XInteractionHandler> (
+ xServiceManager->createInstanceWithContext(
+ UNISTRING( "com.sun.star.task.InteractionHandler" ),
+ mxContext),
+ uno::UNO_QUERY_THROW);
+ if( !mxInteractionHdl.is() )
+ throw uno::RuntimeException( UNISTRING( "UpdateHandler:: could not get default interaction handler" ), *this );
+ }
+ uno::Reference< task::XInteractionRequestStringResolver > xStrResolver =
+ task::InteractionRequestStringResolver::create( mxContext );
+ beans::Optional< ::rtl::OUString > aErrorText = xStrResolver->getStringFromInformationalRequest( rRequest );
+ if ( aErrorText.IsPresent )
+ {
+ setControlProperty( TEXT_DESCRIPTION, UNISTRING("Text"), uno::Any( aErrorText.Value ) );
+
+ uno::Sequence< uno::Reference< task::XInteractionContinuation > > xContinuations = rRequest->getContinuations();
+ if ( xContinuations.getLength() == 1 )
+ {
+ if ( meCurState == UPDATESTATE_CHECKING )
+ setState( UPDATESTATE_ERROR_CHECKING );
+ else if ( meCurState == UPDATESTATE_DOWNLOADING )
+ setState( UPDATESTATE_ERROR_DOWNLOADING );
+
+ xContinuations[0]->select();
+ }
+ else
+ mxInteractionHdl->handle( rRequest );
+ }
+ else
+ mxInteractionHdl->handle( rRequest );
+}
+
+//------------------------------------------------------------------------------
+// XTerminateListener
+//------------------------------------------------------------------------------
+void SAL_CALL UpdateHandler::queryTermination( const lang::EventObject& )
+ throw ( frame::TerminationVetoException, uno::RuntimeException )
+{
+ if ( mbShowsMessageBox )
+ {
+ uno::Reference< awt::XTopWindow > xTopWindow( mxUpdDlg, uno::UNO_QUERY );
+ if ( xTopWindow.is() )
+ xTopWindow->toFront();
+
+ throw frame::TerminationVetoException(
+ UNISTRING("The office cannot be closed while displaying a warning!"),
+ uno::Reference<XInterface>(static_cast<frame::XTerminateListener*>(this), uno::UNO_QUERY));
+ }
+ else
+ setVisible( false );
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL UpdateHandler::notifyTermination( const lang::EventObject& )
+ throw ( uno::RuntimeException )
+{
+ osl::MutexGuard aGuard( maMutex );
+
+ if ( mxUpdDlg.is() )
+ {
+ uno::Reference< awt::XTopWindow > xTopWindow( mxUpdDlg, uno::UNO_QUERY );
+ if ( xTopWindow.is() )
+ xTopWindow->removeTopWindowListener( this );
+
+ uno::Reference< lang::XComponent > xComponent( mxUpdDlg, uno::UNO_QUERY );
+ if ( xComponent.is() )
+ xComponent->dispose();
+
+ mxUpdDlg.clear();
+ }
+}
+
+//--------------------------------------------------------------------
+//--------------------------------------------------------------------
+//--------------------------------------------------------------------
+void UpdateHandler::updateState( UpdateState eState )
+{
+ if ( meLastState == eState )
+ return;
+
+ if ( isVisible() )
+ {} // ToTop();
+
+ rtl::OUString sText;
+
+ switch ( eState )
+ {
+ case UPDATESTATE_CHECKING:
+ showControls( (1<<CANCEL_BUTTON) + (1<<THROBBER_CTRL) );
+ enableControls( 1<<CANCEL_BUTTON );
+ setControlProperty( TEXT_STATUS, UNISTRING("Text"), uno::Any( substVariables(msChecking) ) );
+ setControlProperty( TEXT_DESCRIPTION, UNISTRING("Text"), uno::Any( rtl::OUString() ) );
+ focusControl( CANCEL_BUTTON );
+ break;
+ case UPDATESTATE_ERROR_CHECKING:
+ showControls( 0 );
+ enableControls( 1 << CLOSE_BUTTON );
+ setControlProperty( TEXT_STATUS, UNISTRING("Text"), uno::Any( substVariables(msCheckingError) ) );
+ focusControl( CLOSE_BUTTON );
+ break;
+ case UPDATESTATE_UPDATE_AVAIL:
+ showControls( 0 );
+ enableControls( ( 1 << CLOSE_BUTTON ) + ( 1 << DOWNLOAD_BUTTON ) );
+ setControlProperty( TEXT_STATUS, UNISTRING("Text"), uno::Any( substVariables(msUpdFound) ) );
+
+ sText = substVariables(msDownloadWarning);
+ if ( msDescriptionMsg.getLength() )
+ sText += UNISTRING("\n\n") + msDescriptionMsg;
+ setControlProperty( TEXT_DESCRIPTION, UNISTRING("Text"), uno::Any( sText ) );
+
+ setDownloadBtnLabel( false );
+ focusControl( DOWNLOAD_BUTTON );
+ break;
+ case UPDATESTATE_UPDATE_NO_DOWNLOAD:
+ showControls( 0 );
+ enableControls( ( 1 << CLOSE_BUTTON ) + ( 1 << DOWNLOAD_BUTTON ) );
+ setControlProperty( TEXT_STATUS, UNISTRING("Text"), uno::Any( substVariables(msUpdFound) ) );
+
+ sText = substVariables(msDownloadNotAvail);
+ if ( msDescriptionMsg.getLength() )
+ sText += UNISTRING("\n\n") + msDescriptionMsg;
+ setControlProperty( TEXT_DESCRIPTION, UNISTRING("Text"), uno::Any( sText ) );
+
+ setDownloadBtnLabel( true );
+ focusControl( DOWNLOAD_BUTTON );
+ break;
+ case UPDATESTATE_NO_UPDATE_AVAIL:
+ case UPDATESTATE_EXT_UPD_AVAIL: // will only be set, when there are no office updates avail
+ showControls( 0 );
+ enableControls( 1 << CLOSE_BUTTON );
+ setControlProperty( TEXT_STATUS, UNISTRING("Text"), uno::Any( substVariables(msNoUpdFound) ) );
+ setControlProperty( TEXT_DESCRIPTION, UNISTRING("Text"), uno::Any( rtl::OUString() ) );
+ focusControl( CLOSE_BUTTON );
+ break;
+ case UPDATESTATE_DOWNLOADING:
+ showControls( (1<<PROGRESS_CTRL) + (1<<CANCEL_BUTTON) + (1<<PAUSE_BUTTON) + (1<<RESUME_BUTTON) );
+ enableControls( (1<<CLOSE_BUTTON) + (1<<CANCEL_BUTTON) + (1<<PAUSE_BUTTON) );
+ setControlProperty( TEXT_STATUS, UNISTRING("Text"), uno::Any( substVariables(msDownloading) ) );
+ setControlProperty( TEXT_PERCENT, UNISTRING("Text"), uno::Any( substVariables(msPercent) ) );
+ setControlProperty( TEXT_DESCRIPTION, UNISTRING("Text"), uno::Any( substVariables(msDownloadWarning) ) );
+ setControlProperty( CTRL_PROGRESS, UNISTRING("ProgressValue"), uno::Any( mnPercent ) );
+ focusControl( CLOSE_BUTTON );
+ break;
+ case UPDATESTATE_DOWNLOAD_PAUSED:
+ showControls( (1<<PROGRESS_CTRL) + (1<<CANCEL_BUTTON) + (1<<PAUSE_BUTTON) + (1<<RESUME_BUTTON) );
+ enableControls( (1<<CLOSE_BUTTON) + (1<<CANCEL_BUTTON) + (1<<RESUME_BUTTON) );
+ setControlProperty( TEXT_STATUS, UNISTRING("Text"), uno::Any( substVariables(msDownloadPause) ) );
+ setControlProperty( TEXT_PERCENT, UNISTRING("Text"), uno::Any( substVariables(msPercent) ) );
+ setControlProperty( TEXT_DESCRIPTION, UNISTRING("Text"), uno::Any( substVariables(msDownloadWarning) ) );
+ setControlProperty( CTRL_PROGRESS, UNISTRING("ProgressValue"), uno::Any( mnPercent ) );
+ focusControl( CLOSE_BUTTON );
+ break;
+ case UPDATESTATE_ERROR_DOWNLOADING:
+ showControls( (1<<PROGRESS_CTRL) + (1<<CANCEL_BUTTON) + (1<<PAUSE_BUTTON) + (1<<RESUME_BUTTON) );
+ enableControls( (1<<CLOSE_BUTTON) + (1<<CANCEL_BUTTON) );
+ setControlProperty( TEXT_STATUS, UNISTRING("Text"), uno::Any( substVariables(msDownloadError) ) );
+ focusControl( CLOSE_BUTTON );
+ break;
+ case UPDATESTATE_DOWNLOAD_AVAIL:
+ showControls( 0 );
+ enableControls( (1<<CLOSE_BUTTON) + (1<<INSTALL_BUTTON) );
+ setControlProperty( TEXT_STATUS, UNISTRING("Text"), uno::Any( substVariables(msReady2Install) ) );
+ setControlProperty( TEXT_DESCRIPTION, UNISTRING("Text"), uno::Any( substVariables(msDownloadDescr) ) );
+ focusControl( INSTALL_BUTTON );
+ break;
+ case UPDATESTATE_AUTO_START:
+ case UPDATESTATES_COUNT:
+ //do nothing, only count!
+ break;
+ }
+
+ meLastState = eState;
+}
+
+//--------------------------------------------------------------------
+void UpdateHandler::searchAndReplaceAll( rtl::OUString &rText,
+ const rtl::OUString &rWhat,
+ const rtl::OUString &rWith ) const
+{
+ sal_Int32 nIndex = rText.indexOf( rWhat );
+
+ while ( nIndex != -1 )
+ {
+ rText = rText.replaceAt( nIndex, rWhat.getLength(), rWith );
+ nIndex = rText.indexOf( rWhat, nIndex );
+ }
+}
+
+//--------------------------------------------------------------------
+rtl::OUString UpdateHandler::loadString( const uno::Reference< resource::XResourceBundle > xBundle,
+ sal_Int32 nResourceId ) const
+{
+ rtl::OUString sString;
+ rtl::OUString sKey = UNISTRING( "string:" ) + rtl::OUString::valueOf( nResourceId );
+
+ try
+ {
+ OSL_VERIFY( xBundle->getByName( sKey ) >>= sString );
+ }
+ catch( const uno::Exception& )
+ {
+ OSL_ENSURE( false, "UpdateHandler::loadString: caught an exception!" );
+ sString = UNISTRING("Missing ") + sKey;
+ }
+
+ return sString;
+}
+
+rtl::OUString UpdateHandler::substVariables( const rtl::OUString &rSource ) const
+{
+ rtl::OUString sString( rSource );
+
+ searchAndReplaceAll( sString, UNISTRING( "%NEXTVERSION" ), msNextVersion );
+ searchAndReplaceAll( sString, UNISTRING( "%DOWNLOAD_PATH" ), msDownloadPath );
+ searchAndReplaceAll( sString, UNISTRING( "%FILE_NAME" ), msDownloadFile );
+ searchAndReplaceAll( sString, UNISTRING( "%PERCENT" ), rtl::OUString::valueOf( mnPercent ) );
+
+ return sString;
+}
+
+//--------------------------------------------------------------------
+void UpdateHandler::loadStrings()
+{
+ if ( mbStringsLoaded )
+ return;
+ else
+ mbStringsLoaded = true;
+
+ uno::Reference< resource::XResourceBundleLoader > xLoader;
+ try
+ {
+ uno::Any aValue( mxContext->getValueByName(
+ UNISTRING( "/singletons/com.sun.star.resource.OfficeResourceLoader" ) ) );
+ OSL_VERIFY( aValue >>= xLoader );
+ }
+ catch( const uno::Exception& )
+ {
+ OSL_ENSURE( false, "UpdateHandler::loadStrings: could not create the resource loader!" );
+ }
+
+ if ( !xLoader.is() ) return;
+
+ uno::Reference< resource::XResourceBundle > xBundle;
+
+ try
+ {
+ xBundle = xLoader->loadBundle_Default( UNISTRING( "upd" ) );
+ }
+ catch( const resource::MissingResourceException& )
+ {
+ OSL_ENSURE( false, "UpdateHandler::loadStrings: missing the resource bundle!" );
+ }
+
+ if ( !xBundle.is() ) return;
+
+ msChecking = loadString( xBundle, RID_UPDATE_STR_CHECKING );
+ msCheckingError = loadString( xBundle, RID_UPDATE_STR_CHECKING_ERR );
+ msNoUpdFound = loadString( xBundle, RID_UPDATE_STR_NO_UPD_FOUND );
+
+ msUpdFound = loadString( xBundle, RID_UPDATE_STR_UPD_FOUND );
+ setFullVersion( msUpdFound );
+
+ msDlgTitle = loadString( xBundle, RID_UPDATE_STR_DLG_TITLE );
+ msDownloadPause = loadString( xBundle, RID_UPDATE_STR_DOWNLOAD_PAUSE );
+ msDownloadError = loadString( xBundle, RID_UPDATE_STR_DOWNLOAD_ERR );
+ msDownloadWarning = loadString( xBundle, RID_UPDATE_STR_DOWNLOAD_WARN );
+ msDownloadDescr = loadString( xBundle, RID_UPDATE_STR_DOWNLOAD_DESCR );
+ msDownloadNotAvail = loadString( xBundle, RID_UPDATE_STR_DOWNLOAD_UNAVAIL );
+ msDownloading = loadString( xBundle, RID_UPDATE_STR_DOWNLOADING );
+ msReady2Install = loadString( xBundle, RID_UPDATE_STR_READY_INSTALL );
+ msCancelTitle = loadString( xBundle, RID_UPDATE_STR_CANCEL_TITLE );
+ msCancelMessage = loadString( xBundle, RID_UPDATE_STR_CANCEL_DOWNLOAD );
+ msInstallMessage = loadString( xBundle, RID_UPDATE_STR_BEGIN_INSTALL );
+ msInstallNow = loadString( xBundle, RID_UPDATE_STR_INSTALL_NOW );
+ msInstallLater = loadString( xBundle, RID_UPDATE_STR_INSTALL_LATER );
+ msInstallError = loadString( xBundle, RID_UPDATE_STR_INSTALL_ERROR );
+ msOverwriteWarning = loadString( xBundle, RID_UPDATE_STR_OVERWRITE_WARNING );
+ msPercent = loadString( xBundle, RID_UPDATE_STR_PERCENT );
+ msReloadWarning = loadString( xBundle, RID_UPDATE_STR_RELOAD_WARNING );
+ msReloadReload = loadString( xBundle, RID_UPDATE_STR_RELOAD_RELOAD );
+ msReloadContinue = loadString( xBundle, RID_UPDATE_STR_RELOAD_CONTINUE );
+
+ msStatusFL = loadString( xBundle, RID_UPDATE_FT_STATUS );
+ msDescription = loadString( xBundle, RID_UPDATE_FT_DESCRIPTION );
+
+ msClose = loadString( xBundle, RID_UPDATE_BTN_CLOSE );
+ msDownload = loadString( xBundle, RID_UPDATE_BTN_DOWNLOAD );
+ msInstall = loadString( xBundle, RID_UPDATE_BTN_INSTALL );
+ msPauseBtn = loadString( xBundle, RID_UPDATE_BTN_PAUSE );
+ msResumeBtn = loadString( xBundle, RID_UPDATE_BTN_RESUME );
+ msCancelBtn = loadString( xBundle, RID_UPDATE_BTN_CANCEL );
+
+ // all update states before UPDATESTATE_UPDATE_AVAIL don't have a bubble
+ // so we can ignore them
+ for ( int i=0; i < (int)(UPDATESTATES_COUNT - UPDATESTATE_UPDATE_AVAIL); i++ )
+ {
+ msBubbleTexts[ i ] = loadString( xBundle, RID_UPDATE_BUBBLE_TEXT_START + i );
+ msBubbleTitles[ i ] = loadString( xBundle, RID_UPDATE_BUBBLE_T_TEXT_START + i );
+ }
+
+ for ( int i=0; i < BUTTON_COUNT; i++ )
+ {
+ msButtonIDs[ i ] = UNISTRING("BUTTON_") + rtl::OUString::valueOf( (sal_Int32) i );
+ }
+}
+
+
+//--------------------------------------------------------------------
+void UpdateHandler::startThrobber( bool bStart )
+{
+ uno::Reference< awt::XControlContainer > xContainer( mxUpdDlg, uno::UNO_QUERY );
+ uno::Reference< awt::XThrobber > xThrobber( xContainer->getControl( CTRL_THROBBER ), uno::UNO_QUERY );
+
+ if ( xThrobber.is() )
+ {
+ if ( bStart )
+ xThrobber->start();
+ else
+ xThrobber->stop();
+ }
+
+ uno::Reference< awt::XWindow > xWindow( xContainer->getControl( CTRL_THROBBER ), uno::UNO_QUERY );
+ if (xWindow.is() )
+ xWindow->setVisible( bStart );
+}
+
+//--------------------------------------------------------------------
+void UpdateHandler::setControlProperty( const rtl::OUString &rCtrlName,
+ const rtl::OUString &rPropName,
+ const uno::Any &rPropValue )
+{
+ if ( !mxUpdDlg.is() ) return;
+
+ uno::Reference< awt::XControlContainer > xContainer( mxUpdDlg, uno::UNO_QUERY );
+ uno::Reference< awt::XControl > xControl( xContainer->getControl( rCtrlName ), uno::UNO_QUERY_THROW );
+ uno::Reference< awt::XControlModel > xControlModel( xControl->getModel(), uno::UNO_QUERY_THROW );
+ uno::Reference< beans::XPropertySet > xPropSet( xControlModel, uno::UNO_QUERY_THROW );
+
+ try {
+ xPropSet->setPropertyValue( rPropName, rPropValue );
+ }
+ catch( const beans::UnknownPropertyException& )
+ {
+ OSL_ENSURE( false, "UpdateHandler::setControlProperty: caught an exception!" );
+ }
+}
+
+//--------------------------------------------------------------------
+void UpdateHandler::showControl( const rtl::OUString &rCtrlName, bool bShow )
+{
+ uno::Reference< awt::XControlContainer > xContainer( mxUpdDlg, uno::UNO_QUERY );
+
+ if ( !xContainer.is() )
+ {
+ OSL_ENSURE( false, "UpdateHandler::showControl: could not get control container!" );
+ return;
+ }
+
+ uno::Reference< awt::XWindow > xWindow( xContainer->getControl( rCtrlName ), uno::UNO_QUERY );
+ if ( xWindow.is() )
+ xWindow->setVisible( bShow );
+}
+
+//--------------------------------------------------------------------
+void UpdateHandler::focusControl( DialogControls eID )
+{
+ uno::Reference< awt::XControlContainer > xContainer( mxUpdDlg, uno::UNO_QUERY );
+
+ if ( !xContainer.is() )
+ {
+ OSL_ENSURE( false, "UpdateHandler::focusControl: could not get control container!" );
+ return;
+ }
+
+ OSL_ENSURE( (eID < BUTTON_COUNT), "UpdateHandler::focusControl: id to big!" );
+
+ uno::Reference< awt::XWindow > xWindow( xContainer->getControl( msButtonIDs[(short)eID] ), uno::UNO_QUERY );
+ if ( xWindow.is() )
+ xWindow->setFocus();
+}
+
+//--------------------------------------------------------------------
+void UpdateHandler::insertControlModel( uno::Reference< awt::XControlModel > & rxDialogModel,
+ rtl::OUString const & rServiceName,
+ rtl::OUString const & rControlName,
+ awt::Rectangle const & rPosSize,
+ uno::Sequence< beans::NamedValue > const & rProps )
+{
+ uno::Reference< lang::XMultiServiceFactory > xFactory (rxDialogModel, uno::UNO_QUERY_THROW);
+ uno::Reference< awt::XControlModel > xModel (xFactory->createInstance (rServiceName), uno::UNO_QUERY_THROW);
+ uno::Reference< beans::XPropertySet > xPropSet (xModel, uno::UNO_QUERY_THROW);
+
+ for (sal_Int32 i = 0, n = rProps.getLength(); i < n; i++)
+ {
+ xPropSet->setPropertyValue (rProps[i].Name, rProps[i].Value);
+ }
+
+ // @see awt/UnoControlDialogElement.idl
+ xPropSet->setPropertyValue( UNISTRING("Name"), uno::Any (rControlName) );
+ xPropSet->setPropertyValue( UNISTRING("PositionX"), uno::Any (rPosSize.X) );
+ xPropSet->setPropertyValue( UNISTRING("PositionY"), uno::Any (rPosSize.Y) );
+ xPropSet->setPropertyValue( UNISTRING("Height"), uno::Any (rPosSize.Height) );
+ xPropSet->setPropertyValue( UNISTRING("Width"), uno::Any (rPosSize.Width) );
+
+ // insert by Name into DialogModel container
+ uno::Reference< container::XNameContainer > xContainer (rxDialogModel, uno::UNO_QUERY_THROW);
+ xContainer->insertByName( rControlName, uno::Any (uno::Reference< uno::XInterface >(xModel, uno::UNO_QUERY)));
+}
+
+//--------------------------------------------------------------------
+void UpdateHandler::setFullVersion( rtl::OUString& rString )
+{
+ if( !mxContext.is() )
+ throw uno::RuntimeException( UNISTRING( "getProductName: empty component context" ), *this );
+
+ uno::Reference< lang::XMultiComponentFactory > xServiceManager( mxContext->getServiceManager() );
+
+ if( !xServiceManager.is() )
+ throw uno::RuntimeException( UNISTRING( "getProductName: unable to obtain service manager from component context" ), *this );
+
+ uno::Reference< lang::XMultiServiceFactory > xConfigurationProvider(
+ xServiceManager->createInstanceWithContext( UNISTRING( "com.sun.star.configuration.ConfigurationProvider" ), mxContext ),
+ uno::UNO_QUERY_THROW);
+
+ beans::PropertyValue aProperty;
+ aProperty.Name = UNISTRING( "nodepath" );
+ aProperty.Value = uno::makeAny( UNISTRING("org.openoffice.Setup/Product") );
+
+ uno::Sequence< uno::Any > aArgumentList( 1 );
+ aArgumentList[0] = uno::makeAny( aProperty );
+
+ uno::Reference< uno::XInterface > xConfigAccess;
+ xConfigAccess = xConfigurationProvider->createInstanceWithArguments( UNISTRING("com.sun.star.configuration.ConfigurationAccess"),
+ aArgumentList );
+
+ uno::Reference< container::XNameAccess > xNameAccess( xConfigAccess, uno::UNO_QUERY_THROW );
+
+ rtl::OUString aProductVersion;
+ rtl::OUString aProductFullVersion;
+
+ xNameAccess->getByName(UNISTRING("ooSetupVersion")) >>= aProductVersion;
+ aProductFullVersion = aProductVersion;
+
+ sal_Int32 nVerIndex = rString.indexOf( aProductVersion );
+ if ( nVerIndex != -1 )
+ {
+ rtl::OUString aPackageVersion = UNISTRING( "${$OOO_BASE_DIR/program/" SAL_CONFIGFILE("version") ":OOOPackageVersion}" );
+ rtl::Bootstrap::expandMacros( aPackageVersion );
+
+ if ( aPackageVersion.getLength() )
+ {
+ sal_Int32 nTokIndex = 0;
+ rtl::OUString aVersionMinor = aPackageVersion.getToken( 1, '.', nTokIndex );
+ rtl::OUString aVersionMicro;
+
+ if ( nTokIndex > 0 )
+ aVersionMicro = aPackageVersion.getToken( 0, '.', nTokIndex );
+
+ if ( aVersionMinor.getLength() == 0 )
+ aVersionMinor = UNISTRING( "0" );
+ if ( aVersionMicro.getLength() == 0 )
+ aVersionMicro = UNISTRING( "0" );
+
+ sal_Int32 nIndex = aProductFullVersion.indexOf( '.' );
+ if ( nIndex == -1 )
+ {
+ aProductFullVersion += UNISTRING( "." );
+ aProductFullVersion += aVersionMinor;
+ }
+ else
+ {
+ nIndex = aProductFullVersion.indexOf( '.', nIndex+1 );
+ }
+ if ( nIndex == -1 )
+ {
+ aProductFullVersion += UNISTRING( "." );
+ aProductFullVersion += aVersionMicro;
+ }
+ else
+ {
+ aProductFullVersion = aProductFullVersion.replaceAt( nIndex+1, aProductFullVersion.getLength()-nIndex-1, aVersionMicro );
+ }
+ }
+ rString = rString.replaceAt( nVerIndex, aProductVersion.getLength(), aProductFullVersion );
+ }
+}
+
+//--------------------------------------------------------------------
+bool UpdateHandler::showWarning( const rtl::OUString &rWarningText ) const
+{
+ bool bRet = false;
+
+ uno::Reference< awt::XControl > xControl( mxUpdDlg, uno::UNO_QUERY );
+ if ( !xControl.is() ) return bRet;
+
+ uno::Reference< awt::XWindowPeer > xPeer = xControl->getPeer();
+ if ( !xPeer.is() ) return bRet;
+
+ uno::Reference< awt::XToolkit > xToolkit = xPeer->getToolkit();
+ if ( !xToolkit.is() ) return bRet;
+
+ awt::WindowDescriptor aDescriptor;
+
+ sal_Int32 nWindowAttributes = awt::WindowAttribute::BORDER | awt::WindowAttribute::MOVEABLE | awt::WindowAttribute::CLOSEABLE;
+ nWindowAttributes |= awt::VclWindowPeerAttribute::YES_NO;
+ nWindowAttributes |= awt::VclWindowPeerAttribute::DEF_NO;
+
+ aDescriptor.Type = awt::WindowClass_MODALTOP;
+ aDescriptor.WindowServiceName = UNISTRING( "warningbox" );
+ aDescriptor.ParentIndex = -1;
+ aDescriptor.Parent = xPeer;
+ aDescriptor.Bounds = awt::Rectangle( 10, 10, 250, 150 );
+ aDescriptor.WindowAttributes = nWindowAttributes;
+
+ uno::Reference< awt::XMessageBox > xMsgBox( xToolkit->createWindow( aDescriptor ), uno::UNO_QUERY );
+ if ( xMsgBox.is() )
+ {
+ mbShowsMessageBox = true;
+ sal_Int16 nRet;
+ // xMsgBox->setCaptionText( msCancelTitle );
+ xMsgBox->setMessageText( rWarningText );
+ nRet = xMsgBox->execute();
+ if ( nRet == 2 ) // RET_YES == 2
+ bRet = true;
+ mbShowsMessageBox = false;
+ }
+
+ uno::Reference< lang::XComponent > xComponent( xMsgBox, uno::UNO_QUERY );
+ if ( xComponent.is() )
+ xComponent->dispose();
+
+ return bRet;
+}
+
+//--------------------------------------------------------------------
+bool UpdateHandler::showWarning( const rtl::OUString &rWarningText,
+ const rtl::OUString &rBtnText_1,
+ const rtl::OUString &rBtnText_2 ) const
+{
+ bool bRet = false;
+
+ uno::Reference< awt::XControl > xControl( mxUpdDlg, uno::UNO_QUERY );
+ if ( !xControl.is() ) return bRet;
+
+ uno::Reference< awt::XWindowPeer > xPeer = xControl->getPeer();
+ if ( !xPeer.is() ) return bRet;
+
+ uno::Reference< awt::XToolkit > xToolkit = xPeer->getToolkit();
+ if ( !xToolkit.is() ) return bRet;
+
+ awt::WindowDescriptor aDescriptor;
+
+ sal_Int32 nWindowAttributes = awt::WindowAttribute::BORDER | awt::WindowAttribute::MOVEABLE | awt::WindowAttribute::CLOSEABLE;
+ nWindowAttributes |= awt::VclWindowPeerAttribute::YES_NO;
+ nWindowAttributes |= awt::VclWindowPeerAttribute::DEF_NO;
+
+ aDescriptor.Type = awt::WindowClass_MODALTOP;
+ aDescriptor.WindowServiceName = UNISTRING( "warningbox" );
+ aDescriptor.ParentIndex = -1;
+ aDescriptor.Parent = xPeer;
+ aDescriptor.Bounds = awt::Rectangle( 10, 10, 250, 150 );
+ aDescriptor.WindowAttributes = nWindowAttributes;
+
+ uno::Reference< awt::XMessageBox > xMsgBox( xToolkit->createWindow( aDescriptor ), uno::UNO_QUERY );
+ if ( xMsgBox.is() )
+ {
+ uno::Reference< awt::XVclContainer > xMsgBoxCtrls( xMsgBox, uno::UNO_QUERY );
+ if ( xMsgBoxCtrls.is() )
+ {
+ uno::Sequence< uno::Reference< awt::XWindow > > xChildren = xMsgBoxCtrls->getWindows();
+
+ for ( long i=0; i < xChildren.getLength(); i++ )
+ {
+ uno::Reference< awt::XVclWindowPeer > xMsgBoxCtrl( xChildren[i], uno::UNO_QUERY );
+ if ( xMsgBoxCtrl.is() )
+ {
+ bool bIsDefault = true;
+ uno::Any aValue = xMsgBoxCtrl->getProperty( UNISTRING("DefaultButton") );
+ aValue >>= bIsDefault;
+ if ( bIsDefault )
+ xMsgBoxCtrl->setProperty( UNISTRING("Text"), uno::Any( rBtnText_1 ) );
+ else
+ xMsgBoxCtrl->setProperty( UNISTRING("Text"), uno::Any( rBtnText_2 ) );
+ }
+ }
+ }
+
+ sal_Int16 nRet;
+ // xMsgBox->setCaptionText( msCancelTitle );
+ mbShowsMessageBox = true;
+ xMsgBox->setMessageText( rWarningText );
+ nRet = xMsgBox->execute();
+ if ( nRet == 2 ) // RET_YES == 2
+ bRet = true;
+
+ mbShowsMessageBox = false;
+ }
+
+ uno::Reference< lang::XComponent > xComponent( xMsgBox, uno::UNO_QUERY );
+ if ( xComponent.is() )
+ xComponent->dispose();
+
+ return bRet;
+}
+
+//--------------------------------------------------------------------
+bool UpdateHandler::showOverwriteWarning( const rtl::OUString& rFileName ) const
+{
+ rtl::OUString aMsg( msReloadWarning );
+ searchAndReplaceAll( aMsg, UNISTRING( "%FILENAME" ), rFileName );
+ searchAndReplaceAll( aMsg, UNISTRING( "%DOWNLOAD_PATH" ), msDownloadPath );
+ return showWarning( aMsg, msReloadContinue, msReloadReload );
+}
+
+//--------------------------------------------------------------------
+bool UpdateHandler::showOverwriteWarning() const
+{
+ return showWarning( msOverwriteWarning );
+}
+
+//--------------------------------------------------------------------
+#define BUTTON_HEIGHT 14
+#define BUTTON_WIDTH 50
+#define BUTTON_X_OFFSET 7
+#define BUTTON_Y_OFFSET 3
+#define LABEL_HEIGHT 10
+
+#define DIALOG_WIDTH 300
+#define DIALOG_BORDER 5
+#define INNER_BORDER 3
+#define TEXT_OFFSET 1
+#define BOX_HEIGHT1 ( LABEL_HEIGHT + 3*BUTTON_HEIGHT + 2*BUTTON_Y_OFFSET + 2*INNER_BORDER )
+#define BOX_HEIGHT2 50
+#define EDIT_WIDTH ( DIALOG_WIDTH - 2 * DIALOG_BORDER )
+#define BOX1_BTN_X ( DIALOG_BORDER + EDIT_WIDTH - BUTTON_WIDTH - INNER_BORDER )
+#define BOX1_BTN_Y ( DIALOG_BORDER + LABEL_HEIGHT + INNER_BORDER)
+#define THROBBER_WIDTH 14
+#define THROBBER_HEIGHT 14
+#define THROBBER_X_POS ( DIALOG_BORDER + 8 )
+#define THROBBER_Y_POS ( DIALOG_BORDER + 23 )
+#define BUTTON_BAR_HEIGHT 24
+#define LABEL_OFFSET ( LABEL_HEIGHT + 4 )
+#define DIALOG_HEIGHT ( BOX_HEIGHT1 + BOX_HEIGHT2 + LABEL_OFFSET + BUTTON_BAR_HEIGHT + 3 * DIALOG_BORDER )
+#define LABEL_Y_POS ( 2 * DIALOG_BORDER + BOX_HEIGHT1 )
+#define EDIT2_Y_POS ( LABEL_Y_POS + LABEL_HEIGHT )
+#define BUTTON_BAR_Y_POS ( EDIT2_Y_POS + DIALOG_BORDER + BOX_HEIGHT2 )
+#define BUTTON_Y_POS ( BUTTON_BAR_Y_POS + 8 )
+#define CLOSE_BTN_X ( DIALOG_WIDTH - DIALOG_BORDER - BUTTON_WIDTH )
+#define INSTALL_BTN_X ( CLOSE_BTN_X - 2 * BUTTON_X_OFFSET - BUTTON_WIDTH )
+#define DOWNLOAD_BTN_X ( INSTALL_BTN_X - BUTTON_X_OFFSET - BUTTON_WIDTH )
+#define PROGRESS_WIDTH 80
+#define PROGRESS_HEIGHT 10
+#define PROGRESS_X_POS ( DIALOG_BORDER + 8 )
+#define PROGRESS_Y_POS ( DIALOG_BORDER + 2*LABEL_OFFSET )
+
+//--------------------------------------------------------------------
+void UpdateHandler::showControls( short nControls )
+{
+ // The buttons from CANCEL_BUTTON to RESUME_BUTTON will be shown or
+ // hidden on demand
+ short nShiftMe;
+ for ( int i = 0; i <= (int)RESUME_BUTTON; i++ )
+ {
+ nShiftMe = (short)(nControls >> i);
+ showControl( msButtonIDs[i], (bool)(nShiftMe & 0x01) );
+ }
+
+ nShiftMe = (short)(nControls >> THROBBER_CTRL);
+ startThrobber( (bool)(nShiftMe & 0x01) );
+
+ nShiftMe = (short)(nControls >> PROGRESS_CTRL);
+ showControl( CTRL_PROGRESS, (bool)(nShiftMe & 0x01) );
+ showControl( TEXT_PERCENT, (bool)(nShiftMe & 0x01) );
+
+ // Status text needs to be smaller, when there are buttons at the right side of the dialog
+ if ( ( nControls & ( (1<<CANCEL_BUTTON) + (1<<PAUSE_BUTTON) + (1<<RESUME_BUTTON) ) ) != 0 )
+ setControlProperty( TEXT_STATUS, UNISTRING("Width"), uno::Any( sal_Int32(EDIT_WIDTH - BUTTON_WIDTH - 2*INNER_BORDER - TEXT_OFFSET ) ) );
+ else
+ setControlProperty( TEXT_STATUS, UNISTRING("Width"), uno::Any( sal_Int32(EDIT_WIDTH - 2*TEXT_OFFSET ) ) );
+
+ // Status text needs to be taller, when we show the progress bar
+ if ( ( nControls & ( 1<<PROGRESS_CTRL ) ) != 0 )
+ setControlProperty( TEXT_STATUS, UNISTRING("Height"), uno::Any( sal_Int32(LABEL_HEIGHT) ) );
+ else
+ setControlProperty( TEXT_STATUS, UNISTRING("Height"), uno::Any( sal_Int32(BOX_HEIGHT1 - 4*TEXT_OFFSET - LABEL_HEIGHT ) ) );
+}
+
+//--------------------------------------------------------------------
+void UpdateHandler::createDialog()
+{
+ if ( !mxContext.is() )
+ {
+ OSL_ASSERT( false );
+ return;
+ }
+
+ uno::Reference< lang::XMultiComponentFactory > xServiceManager( mxContext->getServiceManager() );
+
+ if( xServiceManager.is() )
+ {
+ uno::Reference< frame::XDesktop > xDesktop(
+ xServiceManager->createInstanceWithContext( UNISTRING( "com.sun.star.frame.Desktop"), mxContext ),
+ uno::UNO_QUERY );
+ if ( xDesktop.is() )
+ xDesktop->addTerminateListener( this );
+ }
+
+ loadStrings();
+
+ uno::Reference< lang::XMultiComponentFactory > xFactory( mxContext->getServiceManager(), uno::UNO_QUERY_THROW );
+ uno::Reference< awt::XControlModel > xControlModel( xFactory->createInstanceWithContext(
+ UNISTRING("com.sun.star.awt.UnoControlDialogModel"),
+ mxContext), uno::UNO_QUERY_THROW );
+ {
+ // @see awt/UnoControlDialogModel.idl
+ uno::Reference< beans::XPropertySet > xPropSet( xControlModel, uno::UNO_QUERY_THROW );
+
+ xPropSet->setPropertyValue( UNISTRING("Title"), uno::Any( msDlgTitle ) );
+ xPropSet->setPropertyValue( UNISTRING("Closeable"), uno::Any( true ) );
+ xPropSet->setPropertyValue( UNISTRING("Enabled"), uno::Any( true ) );
+ xPropSet->setPropertyValue( UNISTRING("Moveable"), uno::Any( true ) );
+ xPropSet->setPropertyValue( UNISTRING("Sizeable"), uno::Any( true ) );
+ xPropSet->setPropertyValue( UNISTRING("DesktopAsParent"), uno::Any( true ) );
+ xPropSet->setPropertyValue( UNISTRING("PositionX"), uno::Any(sal_Int32( 100 )) );
+ xPropSet->setPropertyValue( UNISTRING("PositionY"), uno::Any(sal_Int32( 100 )) );
+ xPropSet->setPropertyValue( UNISTRING("Width"), uno::Any(sal_Int32( DIALOG_WIDTH )) );
+ xPropSet->setPropertyValue( UNISTRING("Height"), uno::Any(sal_Int32( DIALOG_HEIGHT )) );
+ xPropSet->setPropertyValue( UNISTRING("HelpURL"), uno::Any( UNISTRING( "HID:" ) + rtl::OUString::valueOf( (sal_Int32) HID_CHECK_FOR_UPD_DLG ) ) );
+ }
+ { // Label (fixed text) <status>
+ uno::Sequence< beans::NamedValue > aProps(1);
+
+ setProperty( aProps, 0, UNISTRING("Label"), uno::Any( msStatusFL ) );
+
+ insertControlModel( xControlModel, FIXED_TEXT_MODEL, UNISTRING( "fixedLineStatus" ),
+ awt::Rectangle( DIALOG_BORDER+1, DIALOG_BORDER, EDIT_WIDTH-2, LABEL_HEIGHT ),
+ aProps );
+ }
+ { // box around <status> text
+ uno::Sequence< beans::NamedValue > aProps;
+
+ insertControlModel( xControlModel, GROUP_BOX_MODEL, UNISTRING( "StatusBox" ),
+ awt::Rectangle( DIALOG_BORDER, DIALOG_BORDER + LABEL_HEIGHT, EDIT_WIDTH, BOX_HEIGHT1 - LABEL_HEIGHT ),
+ aProps );
+ }
+ { // Text (multiline edit) <status>
+ uno::Sequence< beans::NamedValue > aProps(7);
+
+ setProperty( aProps, 0, UNISTRING("Text"), uno::Any( substVariables(msChecking) ) );
+ setProperty( aProps, 1, UNISTRING("Border"), uno::Any( sal_Int16( 0 ) ) );
+ setProperty( aProps, 2, UNISTRING("PaintTransparent"), uno::Any( true ) );
+ setProperty( aProps, 3, UNISTRING("MultiLine"), uno::Any( true ) );
+ setProperty( aProps, 4, UNISTRING("ReadOnly"), uno::Any( true ) );
+ setProperty( aProps, 5, UNISTRING("AutoVScroll"), uno::Any( true ) );
+ setProperty( aProps, 6, UNISTRING("HelpURL"), uno::Any( UNISTRING( "HID:" ) + rtl::OUString::valueOf( (sal_Int32) HID_CHECK_FOR_UPD_STATUS ) ) );
+
+ insertControlModel( xControlModel, EDIT_FIELD_MODEL, TEXT_STATUS,
+ awt::Rectangle( DIALOG_BORDER + TEXT_OFFSET,
+ DIALOG_BORDER + LABEL_HEIGHT + TEXT_OFFSET,
+ EDIT_WIDTH - 2*TEXT_OFFSET,
+ BOX_HEIGHT1 - 4*TEXT_OFFSET - LABEL_HEIGHT ),
+ aProps );
+ }
+ { // Text (edit) <percent>
+ uno::Sequence< beans::NamedValue > aProps(4);
+
+ setProperty( aProps, 0, UNISTRING("Text"), uno::Any( msPercent ) );
+ setProperty( aProps, 1, UNISTRING("Border"), uno::Any( sal_Int16( 0 ) ) );
+ setProperty( aProps, 2, UNISTRING("PaintTransparent"), uno::Any( true ) );
+ setProperty( aProps, 3, UNISTRING("ReadOnly"), uno::Any( true ) );
+
+ insertControlModel( xControlModel, EDIT_FIELD_MODEL, TEXT_PERCENT,
+ awt::Rectangle( PROGRESS_X_POS + PROGRESS_WIDTH + DIALOG_BORDER,
+ PROGRESS_Y_POS,
+ EDIT_WIDTH - PROGRESS_WIDTH - BUTTON_WIDTH - 2*DIALOG_BORDER,
+ LABEL_HEIGHT ),
+ aProps );
+ }
+ { // pause button
+ uno::Sequence< beans::NamedValue > aProps(5);
+
+ setProperty( aProps, 0, UNISTRING("DefaultButton"), uno::Any( false ) );
+ setProperty( aProps, 1, UNISTRING("Enabled"), uno::Any( true ) );
+ setProperty( aProps, 2, UNISTRING("PushButtonType"), uno::Any( sal_Int16(awt::PushButtonType_STANDARD) ) );
+ setProperty( aProps, 3, UNISTRING("Label"), uno::Any( msPauseBtn ) );
+ setProperty( aProps, 4, UNISTRING("HelpURL"), uno::Any( UNISTRING( "HID:" ) + rtl::OUString::valueOf( (sal_Int32) HID_CHECK_FOR_UPD_PAUSE ) ) );
+
+ insertControlModel ( xControlModel, BUTTON_MODEL, msButtonIDs[PAUSE_BUTTON],
+ awt::Rectangle( BOX1_BTN_X, BOX1_BTN_Y, BUTTON_WIDTH, BUTTON_HEIGHT ),
+ aProps );
+ }
+ { // resume button
+ uno::Sequence< beans::NamedValue > aProps(5);
+
+ setProperty( aProps, 0, UNISTRING("DefaultButton"), uno::Any( false ) );
+ setProperty( aProps, 1, UNISTRING("Enabled"), uno::Any( true ) );
+ setProperty( aProps, 2, UNISTRING("PushButtonType"), uno::Any( sal_Int16(awt::PushButtonType_STANDARD) ) );
+ setProperty( aProps, 3, UNISTRING("Label"), uno::Any( msResumeBtn ) );
+ setProperty( aProps, 4, UNISTRING("HelpURL"), uno::Any( UNISTRING( "HID:" ) + rtl::OUString::valueOf( (sal_Int32) HID_CHECK_FOR_UPD_RESUME ) ) );
+
+ insertControlModel ( xControlModel, BUTTON_MODEL, msButtonIDs[RESUME_BUTTON],
+ awt::Rectangle( BOX1_BTN_X,
+ BOX1_BTN_Y + BUTTON_Y_OFFSET + BUTTON_HEIGHT,
+ BUTTON_WIDTH,
+ BUTTON_HEIGHT ),
+ aProps );
+ }
+ { // abort button
+ uno::Sequence< beans::NamedValue > aProps(5);
+
+ setProperty( aProps, 0, UNISTRING("DefaultButton"), uno::Any( false ) );
+ setProperty( aProps, 1, UNISTRING("Enabled"), uno::Any( true ) );
+ setProperty( aProps, 2, UNISTRING("PushButtonType"), uno::Any( sal_Int16(awt::PushButtonType_STANDARD) ) );
+ setProperty( aProps, 3, UNISTRING("Label"), uno::Any( msCancelBtn ) );
+ setProperty( aProps, 4, UNISTRING("HelpURL"), uno::Any( UNISTRING( "HID:" ) + rtl::OUString::valueOf( (sal_Int32) HID_CHECK_FOR_UPD_CANCEL ) ) );
+
+ insertControlModel ( xControlModel, BUTTON_MODEL, msButtonIDs[CANCEL_BUTTON],
+ awt::Rectangle( BOX1_BTN_X,
+ BOX1_BTN_Y + (2*(BUTTON_HEIGHT+BUTTON_Y_OFFSET)),
+ BUTTON_WIDTH,
+ BUTTON_HEIGHT ),
+ aProps );
+ }
+ { // Label (FixedText) <description>
+ uno::Sequence< beans::NamedValue > aProps(1);
+
+ setProperty( aProps, 0, UNISTRING("Label"), uno::Any( msDescription ) );
+
+ insertControlModel( xControlModel, FIXED_TEXT_MODEL, UNISTRING( "fixedTextDescription" ),
+ awt::Rectangle( DIALOG_BORDER+1, LABEL_Y_POS, EDIT_WIDTH-2, LABEL_HEIGHT ),
+ aProps );
+ }
+ { // box around <description> text
+ uno::Sequence< beans::NamedValue > aProps;
+
+ insertControlModel( xControlModel, GROUP_BOX_MODEL, UNISTRING( "DescriptionBox" ),
+ awt::Rectangle( DIALOG_BORDER, EDIT2_Y_POS, EDIT_WIDTH, BOX_HEIGHT2 ),
+ aProps );
+ }
+ { // Text (MultiLineEdit) <description>
+ uno::Sequence< beans::NamedValue > aProps(7);
+
+ setProperty( aProps, 0, UNISTRING("Text"), uno::Any( rtl::OUString() ) );
+ setProperty( aProps, 1, UNISTRING("Border"), uno::Any( sal_Int16( 0 ) ) );
+ setProperty( aProps, 2, UNISTRING("PaintTransparent"), uno::Any( true ) );
+ setProperty( aProps, 3, UNISTRING("MultiLine"), uno::Any( true ) );
+ setProperty( aProps, 4, UNISTRING("ReadOnly"), uno::Any( true ) );
+ setProperty( aProps, 5, UNISTRING("AutoVScroll"), uno::Any( true ) );
+ setProperty( aProps, 6, UNISTRING("HelpURL"), uno::Any( UNISTRING( "HID:" ) + rtl::OUString::valueOf( (sal_Int32) HID_CHECK_FOR_UPD_DESCRIPTION ) ) );
+
+ insertControlModel( xControlModel, EDIT_FIELD_MODEL, TEXT_DESCRIPTION,
+ awt::Rectangle( DIALOG_BORDER + TEXT_OFFSET,
+ EDIT2_Y_POS + 2*TEXT_OFFSET,
+ EDIT_WIDTH - 3*TEXT_OFFSET,
+ BOX_HEIGHT2 - 3*TEXT_OFFSET ),
+ aProps );
+ }
+ { // @see awt/UnoControlFixedLineModel.idl
+ uno::Sequence< beans::NamedValue > aProps(1);
+
+ setProperty( aProps, 0, UNISTRING("Orientation"), uno::Any( sal_Int32( 0 ) ) );
+
+ insertControlModel( xControlModel, FIXED_LINE_MODEL, UNISTRING("fixedLine"),
+ awt::Rectangle( 0, BUTTON_BAR_Y_POS, DIALOG_WIDTH, 5 ),
+ aProps );
+ }
+ { // close button // @see awt/UnoControlButtonModel.idl
+ uno::Sequence< beans::NamedValue > aProps(5);
+
+ setProperty( aProps, 0, UNISTRING("DefaultButton"), uno::Any( false ) );
+ setProperty( aProps, 1, UNISTRING("Enabled"), uno::Any( true ) );
+ // [property] short PushButtonType
+ // with own "ButtonActionListener"
+ setProperty( aProps, 2, UNISTRING("PushButtonType"), uno::Any( sal_Int16(awt::PushButtonType_STANDARD) ) );
+ // with default ActionListener => endDialog().
+ // setProperty( aProps, 2, UNISTRING("PushButtonType"), uno::Any( sal_Int16(awt::PushButtonType_CANCEL) ) );
+ // [property] string Label // only if PushButtonType_STANDARD
+ setProperty( aProps, 3, UNISTRING("Label"), uno::Any( msClose ) );
+ setProperty( aProps, 4, UNISTRING("HelpURL"), uno::Any( UNISTRING( "HID:" ) + rtl::OUString::valueOf( (sal_Int32) HID_CHECK_FOR_UPD_CLOSE ) ) );
+
+ insertControlModel ( xControlModel, BUTTON_MODEL, msButtonIDs[ CLOSE_BUTTON ],
+ awt::Rectangle( CLOSE_BTN_X, BUTTON_Y_POS, BUTTON_WIDTH, BUTTON_HEIGHT ),
+ aProps );
+ }
+ { // install button
+ uno::Sequence< beans::NamedValue > aProps(5);
+
+ setProperty( aProps, 0, UNISTRING("DefaultButton"), uno::Any( false ) );
+ setProperty( aProps, 1, UNISTRING("Enabled"), uno::Any( true ) );
+ setProperty( aProps, 2, UNISTRING("PushButtonType"), uno::Any( sal_Int16(awt::PushButtonType_STANDARD) ) );
+ setProperty( aProps, 3, UNISTRING("Label"), uno::Any( msInstall ) );
+ setProperty( aProps, 4, UNISTRING("HelpURL"), uno::Any( UNISTRING( "HID:" ) + rtl::OUString::valueOf( (sal_Int32) HID_CHECK_FOR_UPD_INSTALL ) ) );
+
+ insertControlModel ( xControlModel, BUTTON_MODEL, msButtonIDs[INSTALL_BUTTON],
+ awt::Rectangle( INSTALL_BTN_X, BUTTON_Y_POS, BUTTON_WIDTH, BUTTON_HEIGHT ),
+ aProps );
+ }
+ { // download button
+ uno::Sequence< beans::NamedValue > aProps(5);
+
+ setProperty( aProps, 0, UNISTRING("DefaultButton"), uno::Any( false ) );
+ setProperty( aProps, 1, UNISTRING("Enabled"), uno::Any( true ) );
+ setProperty( aProps, 2, UNISTRING("PushButtonType"), uno::Any( sal_Int16(awt::PushButtonType_STANDARD) ) );
+ setProperty( aProps, 3, UNISTRING("Label"), uno::Any( msDownload ) );
+ setProperty( aProps, 4, UNISTRING("HelpURL"), uno::Any( UNISTRING( "HID:" ) + rtl::OUString::valueOf( (sal_Int32) HID_CHECK_FOR_UPD_DOWNLOAD ) ) );
+
+ insertControlModel ( xControlModel, BUTTON_MODEL, msButtonIDs[DOWNLOAD_BUTTON],
+ awt::Rectangle( DOWNLOAD_BTN_X, BUTTON_Y_POS, BUTTON_WIDTH, BUTTON_HEIGHT ),
+ aProps );
+ }
+ { // help button
+ uno::Sequence< beans::NamedValue > aProps(3);
+
+ setProperty( aProps, 0, UNISTRING("DefaultButton"), uno::Any( false ) );
+ setProperty( aProps, 1, UNISTRING("Enabled"), uno::Any( true ) );
+ setProperty( aProps, 2, UNISTRING("PushButtonType"), uno::Any( sal_Int16(awt::PushButtonType_HELP) ) );
+
+ insertControlModel( xControlModel, BUTTON_MODEL, msButtonIDs[HELP_BUTTON],
+ awt::Rectangle( DIALOG_BORDER, BUTTON_Y_POS, BUTTON_WIDTH, BUTTON_HEIGHT ),
+ aProps );
+ }
+ { // @see awt/UnoControlThrobberModel.idl
+ uno::Sequence< beans::NamedValue > aProps;
+
+ insertControlModel( xControlModel, UNISTRING("com.sun.star.awt.UnoThrobberControlModel"), CTRL_THROBBER,
+ awt::Rectangle( THROBBER_X_POS, THROBBER_Y_POS, THROBBER_WIDTH, THROBBER_HEIGHT),
+ aProps );
+ }
+ { // @see awt/UnoControlProgressBarModel.idl
+ uno::Sequence< beans::NamedValue > aProps(4);
+ setProperty( aProps, 0, UNISTRING("Enabled"), uno::Any( true ) );
+ setProperty( aProps, 1, UNISTRING("ProgressValue"), uno::Any( sal_Int32( 0 ) ) );
+ setProperty( aProps, 2, UNISTRING("ProgressValueMax"), uno::Any( sal_Int32( 100 ) ) );
+ setProperty( aProps, 3, UNISTRING("ProgressValueMin"), uno::Any( sal_Int32( 0 ) ) );
+
+ insertControlModel( xControlModel, UNISTRING("com.sun.star.awt.UnoControlProgressBarModel"), CTRL_PROGRESS,
+ awt::Rectangle( PROGRESS_X_POS, PROGRESS_Y_POS, PROGRESS_WIDTH, PROGRESS_HEIGHT ),
+ aProps);
+ }
+
+ uno::Reference< awt::XControl > xControl(
+ xFactory->createInstanceWithContext( UNISTRING("com.sun.star.awt.UnoControlDialog"), mxContext),
+ uno::UNO_QUERY_THROW );
+ xControl->setModel( xControlModel );
+
+ if ( mbVisible == false )
+ {
+ uno::Reference< awt::XWindow > xWindow( xControl, uno::UNO_QUERY );
+
+ if ( xWindow.is() )
+ xWindow->setVisible( false );
+ }
+
+ xControl->createPeer( NULL, NULL );
+ {
+ uno::Reference< awt::XControlContainer > xContainer (xControl, uno::UNO_QUERY);
+ for ( int i = 0; i < HELP_BUTTON; i++ )
+ {
+ uno::Reference< awt::XButton > xButton ( xContainer->getControl( msButtonIDs[i] ), uno::UNO_QUERY);
+ if (xButton.is())
+ {
+ xButton->setActionCommand( msButtonIDs[i] );
+ xButton->addActionListener( this );
+ }
+ }
+ }
+
+ mxUpdDlg.set( xControl, uno::UNO_QUERY_THROW );
+ mnLastCtrlState = -1;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/update/check/updatehdl.hrc b/extensions/source/update/check/updatehdl.hrc
new file mode 100644
index 000000000000..6d7b93086cb3
--- /dev/null
+++ b/extensions/source/update/check/updatehdl.hrc
@@ -0,0 +1,83 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+ #define RID_UPDATE_HDL_START 1200
+
+ #define RID_UPDATE_STR_CHECKING RID_UPDATE_HDL_START + 1
+ #define RID_UPDATE_STR_NO_UPD_FOUND RID_UPDATE_HDL_START + 2
+ #define RID_UPDATE_STR_UPD_FOUND RID_UPDATE_HDL_START + 3
+ #define RID_UPDATE_STR_DLG_TITLE RID_UPDATE_HDL_START + 4
+ #define RID_UPDATE_STR_DOWNLOAD_ERR RID_UPDATE_HDL_START + 5
+ #define RID_UPDATE_STR_DOWNLOAD_WARN RID_UPDATE_HDL_START + 6
+ #define RID_UPDATE_STR_DOWNLOADING RID_UPDATE_HDL_START + 7
+ #define RID_UPDATE_STR_READY_INSTALL RID_UPDATE_HDL_START + 8
+ #define RID_UPDATE_STR_CANCEL_TITLE RID_UPDATE_HDL_START + 9
+ #define RID_UPDATE_STR_CANCEL_DOWNLOAD RID_UPDATE_HDL_START + 10
+ #define RID_UPDATE_STR_BEGIN_INSTALL RID_UPDATE_HDL_START + 11
+ #define RID_UPDATE_STR_INSTALL_NOW RID_UPDATE_HDL_START + 12
+ #define RID_UPDATE_STR_INSTALL_LATER RID_UPDATE_HDL_START + 13
+ #define RID_UPDATE_STR_CHECKING_ERR RID_UPDATE_HDL_START + 14
+ #define RID_UPDATE_STR_OVERWRITE_WARNING RID_UPDATE_HDL_START + 15
+ #define RID_UPDATE_STR_DOWNLOAD_PAUSE RID_UPDATE_HDL_START + 16
+ #define RID_UPDATE_STR_DOWNLOAD_UNAVAIL RID_UPDATE_HDL_START + 17
+ #define RID_UPDATE_STR_PERCENT RID_UPDATE_HDL_START + 18
+ #define RID_UPDATE_STR_DOWNLOAD_DESCR RID_UPDATE_HDL_START + 19
+ #define RID_UPDATE_STR_INSTALL_ERROR RID_UPDATE_HDL_START + 20
+ #define RID_UPDATE_STR_RELOAD_WARNING RID_UPDATE_HDL_START + 21
+ #define RID_UPDATE_STR_RELOAD_RELOAD RID_UPDATE_HDL_START + 22
+ #define RID_UPDATE_STR_RELOAD_CONTINUE RID_UPDATE_HDL_START + 23
+
+ #define RID_UPDATE_FT_DESCRIPTION RID_UPDATE_HDL_START + 25
+ #define RID_UPDATE_FT_STATUS RID_UPDATE_HDL_START + 26
+
+ #define RID_UPDATE_BTN_CLOSE RID_UPDATE_HDL_START + 30
+ #define RID_UPDATE_BTN_DOWNLOAD RID_UPDATE_HDL_START + 31
+ #define RID_UPDATE_BTN_INSTALL RID_UPDATE_HDL_START + 32
+ #define RID_UPDATE_BTN_PAUSE RID_UPDATE_HDL_START + 33
+ #define RID_UPDATE_BTN_RESUME RID_UPDATE_HDL_START + 34
+ #define RID_UPDATE_BTN_CANCEL RID_UPDATE_HDL_START + 35
+
+ #define RID_UPDATE_BUBBLE_TEXT_START RID_UPDATE_HDL_START + 40
+ #define RID_UPDATE_BUBBLE_UPDATE_AVAIL RID_UPDATE_BUBBLE_TEXT_START + 0
+ #define RID_UPDATE_BUBBLE_UPDATE_NO_DOWN RID_UPDATE_BUBBLE_TEXT_START + 1
+ #define RID_UPDATE_BUBBLE_AUTO_START RID_UPDATE_BUBBLE_TEXT_START + 2
+ #define RID_UPDATE_BUBBLE_DOWNLOADING RID_UPDATE_BUBBLE_TEXT_START + 3
+ #define RID_UPDATE_BUBBLE_DOWNLOAD_PAUSED RID_UPDATE_BUBBLE_TEXT_START + 4
+ #define RID_UPDATE_BUBBLE_ERROR_DOWNLOADING RID_UPDATE_BUBBLE_TEXT_START + 5
+ #define RID_UPDATE_BUBBLE_DOWNLOAD_AVAIL RID_UPDATE_BUBBLE_TEXT_START + 6
+ #define RID_UPDATE_BUBBLE_EXT_UPD_AVAIL RID_UPDATE_BUBBLE_TEXT_START + 7
+
+ #define RID_UPDATE_BUBBLE_T_TEXT_START RID_UPDATE_HDL_START + 50
+ #define RID_UPDATE_BUBBLE_T_UPDATE_AVAIL RID_UPDATE_BUBBLE_T_TEXT_START + 0
+ #define RID_UPDATE_BUBBLE_T_UPDATE_NO_DOWN RID_UPDATE_BUBBLE_T_TEXT_START + 1
+ #define RID_UPDATE_BUBBLE_T_AUTO_START RID_UPDATE_BUBBLE_T_TEXT_START + 2
+ #define RID_UPDATE_BUBBLE_T_DOWNLOADING RID_UPDATE_BUBBLE_T_TEXT_START + 3
+ #define RID_UPDATE_BUBBLE_T_DOWNLOAD_PAUSED RID_UPDATE_BUBBLE_T_TEXT_START + 4
+ #define RID_UPDATE_BUBBLE_T_ERROR_DOWNLOADING RID_UPDATE_BUBBLE_T_TEXT_START + 5
+ #define RID_UPDATE_BUBBLE_T_DOWNLOAD_AVAIL RID_UPDATE_BUBBLE_T_TEXT_START + 6
+ #define RID_UPDATE_BUBBLE_T_EXT_UPD_AVAIL RID_UPDATE_BUBBLE_T_TEXT_START + 7
+
diff --git a/extensions/source/update/check/updatehdl.hxx b/extensions/source/update/check/updatehdl.hxx
new file mode 100644
index 000000000000..cc451df57336
--- /dev/null
+++ b/extensions/source/update/check/updatehdl.hxx
@@ -0,0 +1,222 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef INCLUDED_UPDATE_HDL_HXX
+#define INCLUDED_UPDATE_HDL_HXX
+
+#include "boost/utility.hpp"
+#include <osl/mutex.hxx>
+#include "com/sun/star/uno/Any.h"
+#include "com/sun/star/uno/Reference.h"
+#include "com/sun/star/uno/XComponentContext.hpp"
+#include "com/sun/star/awt/Rectangle.hpp"
+#include "com/sun/star/awt/XActionListener.hpp"
+#include "com/sun/star/awt/XControlModel.hpp"
+#include "com/sun/star/awt/XDialog.hpp"
+#include "com/sun/star/awt/XTopWindowListener.hpp"
+#include "com/sun/star/beans/NamedValue.hpp"
+#include "com/sun/star/frame/XTerminateListener.hpp"
+#include <com/sun/star/resource/XResourceBundle.hpp>
+#include <com/sun/star/task/XInteractionHandler.hpp>
+#include "cppuhelper/implbase4.hxx"
+
+#include "actionlistener.hxx"
+
+enum DialogControls
+{
+ CANCEL_BUTTON = 0,
+ PAUSE_BUTTON,
+ RESUME_BUTTON,
+ INSTALL_BUTTON,
+ DOWNLOAD_BUTTON,
+ CLOSE_BUTTON,
+ HELP_BUTTON,
+ BUTTON_COUNT,
+ THROBBER_CTRL,
+ PROGRESS_CTRL
+};
+
+enum UpdateState {
+ UPDATESTATE_CHECKING = 0,
+ UPDATESTATE_ERROR_CHECKING,
+ UPDATESTATE_NO_UPDATE_AVAIL,
+ UPDATESTATE_UPDATE_AVAIL,
+ UPDATESTATE_UPDATE_NO_DOWNLOAD,
+ UPDATESTATE_AUTO_START,
+ UPDATESTATE_DOWNLOADING,
+ UPDATESTATE_DOWNLOAD_PAUSED,
+ UPDATESTATE_ERROR_DOWNLOADING,
+ UPDATESTATE_DOWNLOAD_AVAIL,
+ UPDATESTATE_EXT_UPD_AVAIL,
+ UPDATESTATES_COUNT
+};
+
+class UpdateHandler : ::boost::noncopyable,
+ public cppu::WeakImplHelper4< com::sun::star::awt::XActionListener,
+ com::sun::star::awt::XTopWindowListener,
+ com::sun::star::task::XInteractionHandler,
+ com::sun::star::frame::XTerminateListener >
+{
+private:
+ com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext > mxContext;
+ com::sun::star::uno::Reference< com::sun::star::awt::XDialog > mxUpdDlg;
+ com::sun::star::uno::Reference< com::sun::star::task::XInteractionHandler > mxInteractionHdl;
+ rtl::Reference< IActionListener > mxActionListener;
+
+ UpdateState meCurState;
+ UpdateState meLastState;
+ sal_Int32 mnPercent;
+ short mnLastCtrlState;
+ bool mbDownloadBtnHasDots;
+ bool mbVisible;
+ bool mbStringsLoaded;
+ bool mbMinimized;
+ bool mbListenerAdded;
+ mutable bool mbShowsMessageBox;
+
+ osl::Mutex maMutex;
+
+ rtl::OUString msNextVersion;
+ rtl::OUString msDownloadPath;
+ rtl::OUString msDownloadFile;
+ rtl::OUString msDescriptionMsg;
+ rtl::OUString msChecking; // RID_UPDATE_STR_CHECKING
+ rtl::OUString msCheckingError; // RID_UPDATE_STR_CHECKING_ERR
+ rtl::OUString msNoUpdFound; // RID_UPDATE_STR_NO_UPD_FOUND
+ rtl::OUString msUpdFound; // RID_UPDATE_STR_UPD_FOUND
+ rtl::OUString msDlgTitle; // RID_UPDATE_STR_DLG_TITLE
+ rtl::OUString msDownloadPause; // RID_UPDATE_STR_DOWNLOAD_PAUSE
+ rtl::OUString msDownloadError; // RID_UPDATE_STR_DOWNLOAD_ERR
+ rtl::OUString msDownloadWarning; // RID_UPDATE_STR_DOWNLOAD_WARN
+ rtl::OUString msDownloadDescr; // RID_UPDATE_STR_DOWNLOAD_WARN
+ rtl::OUString msDownloadNotAvail; // RID_UPDATE_STR_DOWNLOAD_UNAVAIL
+ rtl::OUString msDownloading; // RID_UPDATE_STR_DOWNLOADING
+ rtl::OUString msReady2Install; // RID_UPDATE_STR_READY_INSTALL
+ rtl::OUString msCancelTitle; // RID_UPDATE_STR_CANCEL_TITLE
+ rtl::OUString msCancelMessage; // RID_UPDATE_STR_CANCEL_DOWNLOAD
+ rtl::OUString msInstallMessage; // RID_UPDATE_STR_BEGIN_INSTALL
+ rtl::OUString msInstallNow; // RID_UPDATE_STR_INSTALL_NOW
+ rtl::OUString msInstallLater; // RID_UPDATE_STR_INSTALL_LATER
+ rtl::OUString msInstallError; // RID_UPDATE_STR_INSTALL_ERROR
+ rtl::OUString msOverwriteWarning; // RID_UPDATE_STR_OVERWRITE_WARNING
+ rtl::OUString msPercent; // RID_UPDATE_STR_PERCENT
+ rtl::OUString msReloadWarning; // RID_UPDATE_STR_OVERWRITE_WARNING
+ rtl::OUString msReloadReload; // RID_UPDATE_STR_OVERWRITE_WARNING
+ rtl::OUString msReloadContinue; // RID_UPDATE_STR_OVERWRITE_WARNING
+ rtl::OUString msStatusFL; // RID_UPDATE_FT_STATUS
+ rtl::OUString msDescription; // RID_UPDATE_FT_DESCRIPTION
+ rtl::OUString msClose; // RID_UPDATE_BTN_CLOSE
+ rtl::OUString msDownload; // RID_UPDATE_BTN_DOWNLOAD
+ rtl::OUString msInstall; // RID_UPDATE_BTN_INSTALL
+ rtl::OUString msPauseBtn; // RID_UPDATE_BTN_PAUSE
+ rtl::OUString msResumeBtn; // RID_UPDATE_BTN_RESUME
+ rtl::OUString msCancelBtn; // RID_UPDATE_BTN_CANCEL
+ rtl::OUString msButtonIDs[ BUTTON_COUNT ];
+ rtl::OUString msBubbleTexts[ UPDATESTATES_COUNT ];
+ rtl::OUString msBubbleTitles[ UPDATESTATES_COUNT ];
+
+ void createDialog();
+ void updateState( UpdateState eNewState );
+ void startThrobber( bool bStart = true );
+ void setControlProperty( const rtl::OUString &rCtrlName,
+ const rtl::OUString &rPropName,
+ const com::sun::star::uno::Any &rPropValue );
+ void showControl( const rtl::OUString &rCtrlName, bool bShow = true );
+ void showControls( short nControls );
+ void focusControl( DialogControls eID );
+ void enableControls( short nCtrlState );
+ void setDownloadBtnLabel( bool bAppendDots );
+ void loadStrings();
+ rtl::OUString loadString( const com::sun::star::uno::Reference< com::sun::star::resource::XResourceBundle > xBundle,
+ sal_Int32 nResourceId ) const;
+ rtl::OUString substVariables( const rtl::OUString &rSource ) const;
+ static void setProperty( com::sun::star::uno::Sequence< com::sun::star::beans::NamedValue > &rProps,
+ const int nIndex, const rtl::OUString &rPropName, const com::sun::star::uno::Any &rPropValue )
+ { rProps[ nIndex ].Name = rPropName; rProps[ nIndex ].Value = rPropValue; }
+ static void insertControlModel( com::sun::star::uno::Reference< com::sun::star::awt::XControlModel > & rxDialogModel,
+ rtl::OUString const & rServiceName,
+ rtl::OUString const & rControlName,
+ com::sun::star::awt::Rectangle const & rPosSize,
+ com::sun::star::uno::Sequence< com::sun::star::beans::NamedValue > const & rProps );
+
+ void setFullVersion( rtl::OUString& rString );
+ void searchAndReplaceAll( rtl::OUString &rText, const rtl::OUString &rWhat, const rtl::OUString &rWith ) const;
+
+public:
+ UpdateHandler( const com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext > & rxContext,
+ const rtl::Reference< IActionListener > & rxActionListener );
+ virtual ~UpdateHandler();
+
+ bool isVisible() const;
+ bool isMinimized() const { return mbMinimized; }
+ void setVisible( bool bVisible = true );
+ void setProgress( sal_Int32 nPercent );
+ void setNextVersion( const rtl::OUString &rNextVersion ) { msNextVersion = rNextVersion; }
+ void setDownloadPath( const rtl::OUString &rPath ) { msDownloadPath = rPath; }
+ void setDownloadFile( const rtl::OUString &rPath );
+ void setErrorMessage( const rtl::OUString &rErrorMsg );
+ void setDescription( const rtl::OUString &rDescription ){ msDescriptionMsg = rDescription; }
+
+ void setState( UpdateState eState );
+ rtl::OUString getBubbleText( UpdateState eState );
+ rtl::OUString getBubbleTitle( UpdateState eState );
+ rtl::OUString getDefaultInstErrMsg();
+ bool showWarning( const rtl::OUString &rWarning ) const;
+ bool showWarning( const rtl::OUString &rWarning, const rtl::OUString& rBtnText_1, const rtl::OUString& rBtnText_2 ) const;
+ bool showOverwriteWarning( const rtl::OUString &rFileName ) const;
+ bool showOverwriteWarning() const;
+
+ // Allows runtime exceptions to be thrown by const methods
+ inline SAL_CALL operator com::sun::star::uno::Reference< com::sun::star::uno::XInterface > () const
+ { return const_cast< cppu::OWeakObject * > (static_cast< cppu::OWeakObject const * > (this)); };
+
+ // XActionListener
+ virtual void SAL_CALL disposing( const com::sun::star::lang::EventObject &rObj ) throw( com::sun::star::uno::RuntimeException );
+ virtual void SAL_CALL actionPerformed( com::sun::star::awt::ActionEvent const & rEvent) throw( com::sun::star::uno::RuntimeException );
+
+ // XTopWindowListener
+ virtual void SAL_CALL windowOpened( const ::com::sun::star::lang::EventObject& e ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL windowClosing( const ::com::sun::star::lang::EventObject& e ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL windowClosed( const ::com::sun::star::lang::EventObject& e ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL windowMinimized( const ::com::sun::star::lang::EventObject& e ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL windowNormalized( const ::com::sun::star::lang::EventObject& e ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL windowActivated( const ::com::sun::star::lang::EventObject& e ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL windowDeactivated( const ::com::sun::star::lang::EventObject& e ) throw (::com::sun::star::uno::RuntimeException);
+
+ // XInteractionHandler
+ virtual void SAL_CALL handle( const com::sun::star::uno::Reference< com::sun::star::task::XInteractionRequest >& Request )
+ throw( com::sun::star::uno::RuntimeException );
+
+ // XTerminateListener
+ virtual void SAL_CALL queryTermination( const ::com::sun::star::lang::EventObject& e ) throw (::com::sun::star::frame::TerminationVetoException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL notifyTermination( const ::com::sun::star::lang::EventObject& e ) throw (::com::sun::star::uno::RuntimeException);
+};
+
+#endif /* INCLUDED_UPDATE_HDL_HXX */
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/update/check/updatehdl.src b/extensions/source/update/check/updatehdl.src
new file mode 100644
index 000000000000..3dbc0b3676cf
--- /dev/null
+++ b/extensions/source/update/check/updatehdl.src
@@ -0,0 +1,264 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "updatehdl.hrc"
+
+String RID_UPDATE_STR_CHECKING
+{
+ Text [ en-US ] = "Checking...";
+};
+
+String RID_UPDATE_STR_CHECKING_ERR
+{
+ Text [ en-US ] = "Checking for an update failed.";
+};
+
+String RID_UPDATE_STR_NO_UPD_FOUND
+{
+ Text [ en-US ] = "%PRODUCTNAME %PRODUCTVERSION is up to date.";
+};
+
+String RID_UPDATE_STR_UPD_FOUND
+{
+ Text [ en-US ] = "%PRODUCTNAME %NEXTVERSION is available.\n\nThe installed version is %PRODUCTNAME %PRODUCTVERSION.\n\nNote: Before downloading an update, please ensure that you have sufficient access rights to install it.\nA password, usually the administrator's or root password, may be required.";
+};
+
+String RID_UPDATE_STR_DLG_TITLE
+{
+ Text [ en-US ] = "Check for Updates";
+};
+
+String RID_UPDATE_STR_DOWNLOAD_PAUSE
+{
+ Text [ en-US ] = "Downloading %PRODUCTNAME %NEXTVERSION paused at...";
+};
+
+String RID_UPDATE_STR_DOWNLOAD_ERR
+{
+ Text [ en-US ] = "Downloading %PRODUCTNAME %NEXTVERSION stalled at";
+};
+
+String RID_UPDATE_STR_DOWNLOAD_WARN
+{
+ Text [ en-US ] = "The download location is: %DOWNLOAD_PATH.\n\nUnder Tools – Options... - %PRODUCTNAME – Online Update you can change the download location.";
+};
+
+String RID_UPDATE_STR_DOWNLOAD_DESCR
+{
+ Text [ en-US ] = "%FILE_NAME has been downloaded to %DOWNLOAD_PATH.";
+};
+
+String RID_UPDATE_STR_DOWNLOAD_UNAVAIL
+{
+ Text [ en-US ] = "The automatic download of the update is currently not available.\n\nClick 'Download...' to download %PRODUCTNAME %NEXTVERSION manually from the web site.";
+};
+
+String RID_UPDATE_STR_DOWNLOADING
+{
+ Text [ en-US ] = "Downloading %PRODUCTNAME %NEXTVERSION...";
+};
+
+String RID_UPDATE_STR_READY_INSTALL
+{
+ Text [ en-US ] = "Download of %PRODUCTNAME %NEXTVERSION completed. Ready for installation.";
+};
+
+String RID_UPDATE_STR_CANCEL_TITLE
+{
+ Text [ en-US ] = "%PRODUCTNAME %PRODUCTVERSION";
+};
+
+String RID_UPDATE_STR_CANCEL_DOWNLOAD
+{
+ Text [ en-US ] = "Do you really want to cancel the download?";
+};
+
+String RID_UPDATE_STR_BEGIN_INSTALL
+{
+ Text [ en-US ] = "To install the update, %PRODUCTNAME %PRODUCTVERSION needs to be closed. Do you want to install the update now?";
+};
+
+String RID_UPDATE_STR_INSTALL_NOW
+{
+ Text [ en-US ] = "Install ~now";
+};
+
+String RID_UPDATE_STR_INSTALL_LATER
+{
+ Text [ en-US ] = "Install ~later";
+};
+
+String RID_UPDATE_STR_INSTALL_ERROR
+{
+ Text [ en-US ] = "Could not run the installer application, please run %FILE_NAME in %DOWNLOAD_PATH manually.";
+};
+
+String RID_UPDATE_STR_OVERWRITE_WARNING
+{
+ Text [ en-US ] = "A file with that name already exists! Do you want to overwrite the existing file?";
+};
+
+String RID_UPDATE_STR_RELOAD_WARNING
+{
+ Text [ en-US ] = "A file with the name '%FILENAME' already exists in '%DOWNLOAD_PATH'! Do you want to continue with the download or delete and reload the file?";
+};
+
+String RID_UPDATE_STR_RELOAD_RELOAD
+{
+ Text [ en-US ] = "Reload File";
+};
+
+String RID_UPDATE_STR_RELOAD_CONTINUE
+{
+ Text [ en-US ] = "Continue";
+};
+
+String RID_UPDATE_STR_PERCENT
+{
+ Text [ en-US ] = "%PERCENT%";
+};
+
+String RID_UPDATE_FT_STATUS
+{
+ Text [ en-US ] = "Status";
+};
+
+String RID_UPDATE_FT_DESCRIPTION
+{
+ Text [ en-US ] = "Description";
+};
+
+String RID_UPDATE_BTN_CLOSE
+{
+ Text [ en-US ] = "Close";
+};
+
+String RID_UPDATE_BTN_DOWNLOAD
+{
+ Text [ en-US ] = "~Download";
+};
+
+String RID_UPDATE_BTN_INSTALL
+{
+ Text [ en-US ] = "~Install";
+};
+
+String RID_UPDATE_BTN_PAUSE
+{
+ Text [ en-US ] = "~Pause";
+};
+
+String RID_UPDATE_BTN_RESUME
+{
+ Text [ en-US ] = "~Resume";
+};
+
+String RID_UPDATE_BTN_CANCEL
+{
+ Text [ en-US ] = "Cancel";
+};
+
+String RID_UPDATE_BUBBLE_T_UPDATE_AVAIL
+{
+ Text [ en-US ] = "%PRODUCTNAME update available";
+};
+
+String RID_UPDATE_BUBBLE_UPDATE_AVAIL
+{
+ Text [ en-US ] = "Click here to start the download.";
+};
+
+String RID_UPDATE_BUBBLE_T_UPDATE_NO_DOWN
+{
+ Text [ en-US ] = "%PRODUCTNAME update available";
+};
+
+String RID_UPDATE_BUBBLE_UPDATE_NO_DOWN
+{
+ Text [ en-US ] = "Click here for more information.";
+};
+
+String RID_UPDATE_BUBBLE_T_AUTO_START
+{
+ Text [ en-US ] = "%PRODUCTNAME update available";
+};
+
+String RID_UPDATE_BUBBLE_AUTO_START
+{
+ Text [ en-US ] = "Download of update begins.";
+};
+
+String RID_UPDATE_BUBBLE_T_DOWNLOADING
+{
+ Text [ en-US ] = "Download of update in progress";
+};
+
+String RID_UPDATE_BUBBLE_DOWNLOADING
+{
+ Text [ en-US ] = "";
+};
+
+String RID_UPDATE_BUBBLE_T_DOWNLOAD_PAUSED
+{
+ Text [ en-US ] = "Download of update paused";
+};
+
+String RID_UPDATE_BUBBLE_DOWNLOAD_PAUSED
+{
+ Text [ en-US ] = "Click here to resume.";
+};
+
+String RID_UPDATE_BUBBLE_T_ERROR_DOWNLOADING
+{
+ Text [ en-US ] = "Download of update stalled";
+};
+
+String RID_UPDATE_BUBBLE_ERROR_DOWNLOADING
+{
+ Text [ en-US ] = "Click here for more information.";
+};
+
+String RID_UPDATE_BUBBLE_T_DOWNLOAD_AVAIL
+{
+ Text [ en-US ] = "Download of update completed";
+};
+
+String RID_UPDATE_BUBBLE_DOWNLOAD_AVAIL
+{
+ Text [ en-US ] = "Click here to start the installation.";
+};
+
+String RID_UPDATE_BUBBLE_T_EXT_UPD_AVAIL
+{
+ Text [ en-US ] = "Updates for extensions available";
+};
+
+String RID_UPDATE_BUBBLE_EXT_UPD_AVAIL
+{
+ Text [ en-US ] = "Click here for more information.";
+};
+
diff --git a/extensions/source/update/check/updateinfo.hxx b/extensions/source/update/check/updateinfo.hxx
new file mode 100644
index 000000000000..0db0c4e6608d
--- /dev/null
+++ b/extensions/source/update/check/updateinfo.hxx
@@ -0,0 +1,89 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _UPDATE_INFO_INCLUDED_
+#define _UPDATE_INFO_INCLUDED_
+
+#include <rtl/ustring.hxx>
+#include <vector>
+
+struct DownloadSource
+{
+ bool IsDirect;
+ rtl::OUString URL;
+
+ DownloadSource(bool bIsDirect, const rtl::OUString& aURL) : IsDirect(bIsDirect), URL(aURL) {};
+ DownloadSource(const DownloadSource& ds) : IsDirect(ds.IsDirect), URL(ds.URL) {};
+
+ DownloadSource & operator=( const DownloadSource & ds ) { IsDirect = ds.IsDirect; URL = ds.URL; return *this; };
+};
+
+struct ReleaseNote
+{
+ sal_uInt8 Pos;
+ rtl::OUString URL;
+ sal_uInt8 Pos2;
+ rtl::OUString URL2;
+
+ ReleaseNote(sal_uInt8 pos, const rtl::OUString aURL) : Pos(pos), URL(aURL), Pos2(0), URL2() {};
+ ReleaseNote(sal_uInt8 pos, const rtl::OUString aURL, sal_uInt8 pos2, const rtl::OUString aURL2) : Pos(pos), URL(aURL), Pos2(pos2), URL2(aURL2) {};
+
+ ReleaseNote(const ReleaseNote& rn) :Pos(rn.Pos), URL(rn.URL), Pos2(rn.Pos2), URL2(rn.URL2) {};
+ ReleaseNote & operator=( const ReleaseNote& rn) { Pos=rn.Pos; URL=rn.URL; Pos2=rn.Pos2; URL2=rn.URL2; return *this; };
+};
+
+struct UpdateInfo
+{
+ rtl::OUString BuildId;
+ rtl::OUString Version;
+ rtl::OUString Description;
+ std::vector< DownloadSource > Sources;
+ std::vector< ReleaseNote > ReleaseNotes;
+
+ UpdateInfo() : BuildId(), Version(), Description(), Sources(), ReleaseNotes() {};
+ UpdateInfo(const UpdateInfo& ui) : BuildId(ui.BuildId), Version(ui.Version), Description(ui.Description), Sources(ui.Sources), ReleaseNotes(ui.ReleaseNotes) {};
+ inline UpdateInfo & operator=( const UpdateInfo& ui );
+};
+
+UpdateInfo & UpdateInfo::operator=( const UpdateInfo& ui )
+{
+ BuildId = ui.BuildId;
+ Version = ui.Version;
+ Description = ui.Description;
+ Sources = ui.Sources;
+ ReleaseNotes = ui.ReleaseNotes;
+ return *this;
+}
+
+
+// Returns the URL of the release note for the given position
+rtl::OUString getReleaseNote(const UpdateInfo& rInfo, sal_uInt8 pos, bool autoDownloadEnabled=false);
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/update/check/updateprotocol.cxx b/extensions/source/update/check/updateprotocol.cxx
new file mode 100644
index 000000000000..cafda1b8cc8f
--- /dev/null
+++ b/extensions/source/update/check/updateprotocol.cxx
@@ -0,0 +1,334 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+#include <com/sun/star/xml/xpath/XXPathAPI.hpp>
+
+#include "updateprotocol.hxx"
+#include "updatecheckconfig.hxx"
+
+#include <com/sun/star/deployment/UpdateInformationEntry.hpp>
+#include <com/sun/star/deployment/XPackageInformationProvider.hpp>
+
+
+#include <rtl/ref.hxx>
+#include <rtl/uri.hxx>
+#include <rtl/strbuf.hxx>
+#include <rtl/ustrbuf.hxx>
+#include <rtl/bootstrap.hxx>
+#include <osl/process.h>
+
+#include <cppuhelper/implbase1.hxx>
+
+namespace css = com::sun::star ;
+namespace container = css::container ;
+namespace deployment = css::deployment ;
+namespace lang = css::lang ;
+namespace uno = css::uno ;
+namespace task = css::task ;
+namespace xml = css::xml ;
+
+#define UNISTRING(s) rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(s))
+
+//------------------------------------------------------------------------------
+
+static bool
+getBootstrapData(
+ uno::Sequence< ::rtl::OUString > & rRepositoryList,
+ ::rtl::OUString & rBuildID,
+ ::rtl::OUString & rInstallSetID)
+{
+ rBuildID = UNISTRING( "${$OOO_BASE_DIR/program/" SAL_CONFIGFILE("version") ":ProductBuildid}" );
+ rtl::Bootstrap::expandMacros( rBuildID );
+ if ( ! rBuildID.getLength() )
+ return false;
+
+ rInstallSetID = UNISTRING( "${$BRAND_BASE_DIR/program/" SAL_CONFIGFILE("version") ":UpdateID}" );
+ rtl::Bootstrap::expandMacros( rInstallSetID );
+ if ( ! rInstallSetID.getLength() )
+ return false;
+
+ rtl::OUString aValue( UNISTRING( "${$BRAND_BASE_DIR/program/" SAL_CONFIGFILE("version") ":UpdateURL}" ) );
+ rtl::Bootstrap::expandMacros( aValue );
+
+ if( aValue.getLength() > 0 )
+ {
+ rRepositoryList.realloc(1);
+ rRepositoryList[0] = aValue;
+ }
+
+ return true;
+}
+
+//------------------------------------------------------------------------------
+
+// Returns 'true' if successfully connected to the update server
+bool
+checkForUpdates(
+ UpdateInfo& o_rUpdateInfo,
+ uno::Reference< uno::XComponentContext > const & rxContext,
+ uno::Reference< task::XInteractionHandler > const & rxInteractionHandler,
+ const uno::Reference< deployment::XUpdateInformationProvider >& rUpdateInfoProvider)
+{
+ OSL_TRACE("checking for updates ..\n");
+
+ ::rtl::OUString myArch;
+ ::rtl::OUString myOS;
+
+ rtl::Bootstrap::get(UNISTRING("_OS"), myOS);
+ rtl::Bootstrap::get(UNISTRING("_ARCH"), myArch);
+
+ uno::Sequence< ::rtl::OUString > aRepositoryList;
+ ::rtl::OUString aBuildID;
+ ::rtl::OUString aInstallSetID;
+
+ if( ! ( getBootstrapData(aRepositoryList, aBuildID, aInstallSetID) && (aRepositoryList.getLength() > 0) ) )
+ return false;
+
+ if( !rxContext.is() )
+ throw uno::RuntimeException(
+ UNISTRING( "checkForUpdates: empty component context" ), uno::Reference< uno::XInterface >() );
+
+ OSL_ASSERT( rxContext->getServiceManager().is() );
+
+ // XPath implementation
+ uno::Reference< xml::xpath::XXPathAPI > xXPath(
+ rxContext->getServiceManager()->createInstanceWithContext( UNISTRING( "com.sun.star.xml.xpath.XPathAPI" ), rxContext ),
+ uno::UNO_QUERY_THROW);
+
+ xXPath->registerNS( UNISTRING("inst"), UNISTRING("http://installation.openoffice.org/description") );
+
+ if( rxInteractionHandler.is() )
+ rUpdateInfoProvider->setInteractionHandler(rxInteractionHandler);
+
+ try
+ {
+ uno::Reference< container::XEnumeration > aUpdateInfoEnumeration =
+ rUpdateInfoProvider->getUpdateInformationEnumeration( aRepositoryList, aInstallSetID );
+
+ if ( !aUpdateInfoEnumeration.is() )
+ return false; // something went wrong ..
+
+ rtl::OUStringBuffer aBuffer;
+ aBuffer.appendAscii("/child::inst:description[inst:os=\'");
+ aBuffer.append( myOS );
+ aBuffer.appendAscii("\' and inst:arch=\'");
+ aBuffer.append( myArch );
+ aBuffer.appendAscii("\' and inst:buildid>");
+ aBuffer.append( aBuildID );
+ aBuffer.appendAscii("]");
+
+ rtl::OUString aXPathExpression = aBuffer.makeStringAndClear();
+
+ while( aUpdateInfoEnumeration->hasMoreElements() )
+ {
+ deployment::UpdateInformationEntry aEntry;
+
+ if( aUpdateInfoEnumeration->nextElement() >>= aEntry )
+ {
+ uno::Reference< xml::dom::XNode > xNode( aEntry.UpdateDocument.get() );
+ uno::Reference< xml::dom::XNodeList > xNodeList;
+ try {
+ xNodeList = xXPath->selectNodeList(xNode, aXPathExpression
+ + UNISTRING("/inst:update/attribute::src"));
+ } catch (css::xml::xpath::XPathException &) {
+ // ignore
+ }
+
+/*
+ o_rUpdateInfo.Sources.push_back( DownloadSource(true,
+ UNISTRING("http://openoffice.bouncer.osuosl.org/?product=OpenOffice.org&os=solarissparcwjre&lang=en-US&version=2.2.1") ) );
+*/
+
+ sal_Int32 i, imax = xNodeList->getLength();
+ for( i = 0; i < imax; ++i )
+ {
+ uno::Reference< xml::dom::XNode > xNode2( xNodeList->item(i) );
+
+ if( xNode2.is() )
+ {
+ uno::Reference< xml::dom::XElement > xParent(xNode2->getParentNode(), uno::UNO_QUERY_THROW);
+ rtl::OUString aType = xParent->getAttribute(UNISTRING("type"));
+ bool bIsDirect = ( sal_False == aType.equalsIgnoreAsciiCaseAscii("text/html") );
+
+ o_rUpdateInfo.Sources.push_back( DownloadSource(bIsDirect, xNode2->getNodeValue()) );
+ }
+ }
+
+ uno::Reference< xml::dom::XNode > xNode2;
+ try {
+ xNode2 = xXPath->selectSingleNode(xNode, aXPathExpression
+ + UNISTRING("/inst:version/text()"));
+ } catch (css::xml::xpath::XPathException &) {
+ // ignore
+ }
+
+ if( xNode2.is() )
+ o_rUpdateInfo.Version = xNode2->getNodeValue();
+
+ try {
+ xNode2 = xXPath->selectSingleNode(xNode, aXPathExpression
+ + UNISTRING("/inst:buildid/text()"));
+ } catch (css::xml::xpath::XPathException &) {
+ // ignore
+ }
+
+ if( xNode2.is() )
+ o_rUpdateInfo.BuildId = xNode2->getNodeValue();
+
+ o_rUpdateInfo.Description = aEntry.Description;
+
+ // Release Notes
+ try {
+ xNodeList = xXPath->selectNodeList(xNode, aXPathExpression
+ + UNISTRING("/inst:relnote"));
+ } catch (css::xml::xpath::XPathException &) {
+ // ignore
+ }
+ imax = xNodeList->getLength();
+ for( i = 0; i < imax; ++i )
+ {
+ uno::Reference< xml::dom::XElement > xRelNote(xNodeList->item(i), uno::UNO_QUERY);
+ if( xRelNote.is() )
+ {
+ sal_Int32 pos = xRelNote->getAttribute(UNISTRING("pos")).toInt32();
+
+ ReleaseNote aRelNote((sal_uInt8) pos, xRelNote->getAttribute(UNISTRING("src")));
+
+ if( xRelNote->hasAttribute(UNISTRING("src2")) )
+ {
+ pos = xRelNote->getAttribute(UNISTRING("pos2")).toInt32();
+ aRelNote.Pos2 = (sal_Int8) pos;
+ aRelNote.URL2 = xRelNote->getAttribute(UNISTRING("src2"));
+ }
+
+ o_rUpdateInfo.ReleaseNotes.push_back(aRelNote);
+ }
+ }
+/*
+ o_rUpdateInfo.ReleaseNotes.push_back(
+ ReleaseNote(1, UNISTRING("http://qa.openoffice.org/tests/online_update_test.html"))
+ );
+*/
+
+ if( o_rUpdateInfo.Sources.size() > 0 )
+ return true;
+ }
+ }
+ }
+ catch( ... )
+ {
+ return false;
+ }
+
+ return true;
+}
+
+//------------------------------------------------------------------------------
+bool storeExtensionUpdateInfos( const uno::Reference< uno::XComponentContext > & rxContext,
+ const uno::Sequence< uno::Sequence< rtl::OUString > > &rUpdateInfos )
+{
+ if ( rUpdateInfos.hasElements() )
+ {
+ rtl::Reference< UpdateCheckConfig > aConfig = UpdateCheckConfig::get( rxContext );
+
+ for ( sal_Int32 i = rUpdateInfos.getLength() - 1; i >= 0; i-- )
+ {
+ aConfig->storeExtensionVersion( rUpdateInfos[i][0], rUpdateInfos[i][1] );
+ }
+ }
+ return rUpdateInfos.hasElements();
+}
+
+//------------------------------------------------------------------------------
+// Returns 'true' if there are updates for any extension
+
+bool checkForExtensionUpdates( const uno::Reference< uno::XComponentContext > & rxContext )
+{
+ uno::Sequence< uno::Sequence< rtl::OUString > > aUpdateList;
+
+ uno::Reference< deployment::XPackageInformationProvider > xInfoProvider;
+ try
+ {
+ uno::Any aValue( rxContext->getValueByName(
+ UNISTRING( "/singletons/com.sun.star.deployment.PackageInformationProvider" ) ) );
+ OSL_VERIFY( aValue >>= xInfoProvider );
+ }
+ catch( const uno::Exception& )
+ {
+ OSL_ENSURE( false, "checkForExtensionUpdates: could not create the PackageInformationProvider!" );
+ }
+
+ if ( !xInfoProvider.is() ) return false;
+
+ aUpdateList = xInfoProvider->isUpdateAvailable( ::rtl::OUString() );
+ storeExtensionUpdateInfos( rxContext, aUpdateList );
+
+ return aUpdateList.hasElements();
+}
+
+//------------------------------------------------------------------------------
+// Returns 'true' if there are any pending updates for any extension (offline check)
+
+bool checkForPendingUpdates( const uno::Reference< uno::XComponentContext > & rxContext )
+{
+ uno::Sequence< uno::Sequence< rtl::OUString > > aExtensionList;
+ uno::Reference< deployment::XPackageInformationProvider > xInfoProvider;
+ try
+ {
+ uno::Any aValue( rxContext->getValueByName(
+ UNISTRING( "/singletons/com.sun.star.deployment.PackageInformationProvider" ) ) );
+ OSL_VERIFY( aValue >>= xInfoProvider );
+ }
+ catch( const uno::Exception& )
+ {
+ OSL_ENSURE( false, "checkForExtensionUpdates: could not create the PackageInformationProvider!" );
+ }
+
+ if ( !xInfoProvider.is() ) return false;
+
+ bool bPendingUpdateFound = false;
+
+ aExtensionList = xInfoProvider->getExtensionList();
+ if ( aExtensionList.hasElements() )
+ {
+ rtl::Reference< UpdateCheckConfig > aConfig = UpdateCheckConfig::get( rxContext );
+
+ for ( sal_Int32 i = aExtensionList.getLength() - 1; i >= 0; i-- )
+ {
+ bPendingUpdateFound = aConfig->checkExtensionVersion( aExtensionList[i][0], aExtensionList[i][1] );
+ if ( bPendingUpdateFound )
+ break;
+ }
+ }
+
+ return bPendingUpdateFound;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/update/check/updateprotocol.hxx b/extensions/source/update/check/updateprotocol.hxx
new file mode 100644
index 000000000000..3510367b0ebb
--- /dev/null
+++ b/extensions/source/update/check/updateprotocol.hxx
@@ -0,0 +1,58 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include <com/sun/star/uno/XComponentContext.hpp>
+#include <com/sun/star/task/XInteractionHandler.hpp>
+#include <com/sun/star/deployment/UpdateInformationProvider.hpp>
+
+#include <vector>
+#include "updateinfo.hxx"
+
+// Returns 'true' if successfully connected to the update server
+bool checkForUpdates(
+ UpdateInfo& o_rUpdateInfo,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler >& rxInteractionHandler,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XUpdateInformationProvider >& rxProvider
+);
+
+// Returns 'true' if there are updates for any extension
+bool checkForExtensionUpdates(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext
+);
+
+bool checkForPendingUpdates(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext
+);
+
+bool storeExtensionUpdateInfos(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext,
+ const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< rtl::OUString > > &rUpdateInfos
+);
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/update/check/updateprotocoltest.cxx b/extensions/source/update/check/updateprotocoltest.cxx
new file mode 100644
index 000000000000..c9fe2f33c0eb
--- /dev/null
+++ b/extensions/source/update/check/updateprotocoltest.cxx
@@ -0,0 +1,97 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+
+#include <cppuhelper/bootstrap.hxx>
+
+#include "updateprotocol.hxx"
+
+#include <sal/main.h>
+#include <osl/process.h>
+#include <stdio.h>
+
+#define UNISTRING(s) rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(s))
+
+namespace task = ::com::sun::star::task;
+namespace uno = ::com::sun::star::uno;
+
+// -----------------------------------------------------------------------
+
+SAL_IMPLEMENT_MAIN()
+{
+ (void) argv;
+ (void) argc;
+
+ if( osl_getCommandArgCount() != 0 )
+ {
+ fprintf(stderr, "Usage: updateprotocoltest\n");
+ return -1;
+ }
+
+ // create the initial component context
+ uno::Reference< uno::XComponentContext > rComponentContext = cppu::defaultBootstrap_InitialComponentContext();
+
+ // initialize UCB
+ uno::Sequence< uno::Any > theArguments(2);
+ theArguments[0] = uno::makeAny( UNISTRING( "Local") );
+ theArguments[1] = uno::makeAny( UNISTRING( "Office") );
+
+ uno::Reference< uno::XInterface > xUCB =
+ rComponentContext->getServiceManager()->createInstanceWithArgumentsAndContext(
+ UNISTRING( "com.sun.star.ucb.UniversalContentBroker" ),
+ theArguments,
+ rComponentContext );
+
+
+ rtl::OUString aURL;
+ rtl::OUString aVersion;
+
+ try
+ {
+ if( checkForUpdates(rComponentContext, uno::Reference< task::XInteractionHandler > (), aURL, aVersion) )
+ {
+ OSL_TRACE( "Update found: %s on %s",
+ rtl::OUStringToOString( aVersion, RTL_TEXTENCODING_UTF8).getStr(),
+ rtl::OUStringToOString( aURL, RTL_TEXTENCODING_UTF8).getStr());
+ }
+ else
+ {
+ OSL_TRACE( "no updates found" );
+ }
+ }
+ catch( ... )
+ {
+ OSL_TRACE( "unhandled exception caught" );
+ }
+
+ return 0;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/update/check/updchk.xml b/extensions/source/update/check/updchk.xml
new file mode 100644
index 000000000000..487034ecf180
--- /dev/null
+++ b/extensions/source/update/check/updchk.xml
@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE module-description PUBLIC "-//StarOffice//DTD ComponentDescription 1.0//EN" "module-description.dtd">
+<module-description xmlns:xlink="http://www.w3.org/1999/xlink">
+ <module-name>updchk</module-name>
+ <component-description>
+ <author> Oliver Braun </author>
+ <name>vnd.sun.UpdateCheck</name>
+ <description> The </description>
+ <loader-name>com.sun.star.loader.SharedLibrary</loader-name>
+ <language>c++</language>
+ <status value="beta"/>
+ <supported-service>com.sun.star.setup.UpdateCheck</supported-service>
+ <service-dependency>...</service-dependency>
+ <type>com.sun.star.beans.NamedValue</type>
+ <type>com.sun.star.beans.PropertyValue</type>
+ <type>com.sun.star.container.XNameReplace</type>
+ <type>com.sun.star.deployment.UpdateInformationProvider</type>
+ <type>com.sun.star.frame.DispatchResultEvent</type>
+ <type>com.sun.star.frame.DispatchResultState</type>
+ <type>com.sun.star.frame.XFrame</type>
+ <type>com.sun.star.io.XInputStream</type>
+ <type>com.sun.star.io.XOutputStream</type>
+ <type>com.sun.star.lang.XComponent</type>
+ <type>com.sun.star.lang.XMultiComponentFactory</type>
+ <type>com.sun.star.lang.XMultiServiceFactory</type>
+ <type>com.sun.star.lang.XServiceInfo</type>
+ <type>com.sun.star.lang.XSingleComponentFactory</type>
+ <type>com.sun.star.lang.XSingleServiceFactory</type>
+ <type>com.sun.star.lang.XTypeProvider</type>
+ <type>com.sun.star.registry.XRegistryKey</type>
+ <type>com.sun.star.system.SystemShellExecuteFlags</type>
+ <type>com.sun.star.system.XSystemShellExecute</type>
+ <type>com.sun.star.task.XInteractionHandler</type>
+ <type>com.sun.star.task.XJob</type>
+ <type>com.sun.star.uno.TypeClass</type>
+ <type>com.sun.star.uno.XAggregation</type>
+ <type>com.sun.star.uno.XComponentContext</type>
+ <type>com.sun.star.uno.XCurrentContext</type>
+ <type>com.sun.star.uno.XWeak</type>
+ <type>com.sun.star.util.XChangesBatch</type>
+ <type>com.sun.star.xml.xpath.XXPathAPI</type>
+ </component-description>
+ <project-build-dependency>cppuhelper</project-build-dependency>
+ <project-build-dependency>cppu</project-build-dependency>
+ <project-build-dependency>sal</project-build-dependency>
+ <runtime-module-dependency>cppuhelper3$(COM)</runtime-module-dependency>
+ <runtime-module-dependency>cppu3</runtime-module-dependency>
+ <runtime-module-dependency>sal3</runtime-module-dependency>
+</module-description>
diff --git a/extensions/source/update/feed/makefile.mk b/extensions/source/update/feed/makefile.mk
new file mode 100644
index 000000000000..7e12970ddef1
--- /dev/null
+++ b/extensions/source/update/feed/makefile.mk
@@ -0,0 +1,64 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+PRJ=..$/..$/..
+
+PRJNAME=extensions
+TARGET=updatefeed
+
+LIBTARGET=NO
+ENABLE_EXCEPTIONS=TRUE
+
+# --- Settings ---
+
+.INCLUDE : settings.mk
+
+# no "lib" prefix
+DLLPRE =
+
+# --- Files ---
+
+SLOFILES=\
+ $(SLO)$/updatefeed.obj \
+
+SHL1NOCHECK=TRUE
+SHL1TARGET=$(TARGET).uno
+SHL1OBJS=$(SLOFILES)
+
+SHL1IMPLIB=i$(SHL1TARGET)
+SHL1STDLIBS= \
+ $(CPPUHELPERLIB) \
+ $(CPPULIB) \
+ $(SALLIB)
+
+SHL1VERSIONMAP=$(SOLARENV)/src/component.map
+SHL1DEF=$(MISC)$/$(SHL1TARGET).def
+DEF1NAME=$(SHL1TARGET)
+
+# --- Targets ---
+
+.INCLUDE : target.mk
+
diff --git a/extensions/source/update/feed/test/makefile.mk b/extensions/source/update/feed/test/makefile.mk
new file mode 100644
index 000000000000..3d972a761233
--- /dev/null
+++ b/extensions/source/update/feed/test/makefile.mk
@@ -0,0 +1,58 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+PRJ=..$/..$/..$/..
+
+PRJNAME=extensions
+TARGET=updatefeedtest
+
+TARGETTYPE=CUI
+ENABLE_EXCEPTIONS=TRUE
+
+INCPRE=$(OUT)$/inc$/updatefeed
+
+# --- Settings ---
+
+.INCLUDE : settings.mk
+
+# --- Files ---
+
+
+SLOFILES=\
+ $(SLO)$/updatefeedtest.obj \
+
+APP1TARGET=$(TARGET)
+APP1OBJS=$(SLOFILES)
+
+APP1STDLIBS= \
+ $(CPPUHELPERLIB) \
+ $(CPPULIB) \
+ $(SALLIB)
+
+# --- Targets ---
+
+.INCLUDE : target.mk
+
diff --git a/extensions/source/update/feed/test/updatefeedtest.cxx b/extensions/source/update/feed/test/updatefeedtest.cxx
new file mode 100644
index 000000000000..073eb92166ed
--- /dev/null
+++ b/extensions/source/update/feed/test/updatefeedtest.cxx
@@ -0,0 +1,109 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+#include <comphelper/processfactory.hxx>
+
+#include <cppuhelper/servicefactory.hxx>
+#include <cppuhelper/bootstrap.hxx>
+
+#include <com/sun/star/lang/XInitialization.hpp>
+
+
+#include <com/sun/star/deployment/UpdateInformationProvider.hpp>
+
+#include <sal/main.h>
+#include <osl/process.h>
+#include <stdio.h>
+
+namespace deployment = ::com::sun::star::deployment;
+namespace lang = ::com::sun::star::lang;
+namespace uno = ::com::sun::star::uno;
+namespace xml = ::com::sun::star::xml;
+
+#define UNISTRING(s) rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(s))
+
+// -----------------------------------------------------------------------
+
+SAL_IMPLEMENT_MAIN()
+{
+ (void) argv;
+ (void) argc;
+
+ if( osl_getCommandArgCount() != 1 )
+ {
+ fprintf(stderr, "Usage: updatefeedtest <url>\n");
+ return -1;
+ }
+
+ // create the initial component context
+ uno::Reference< uno::XComponentContext > rComponentContext = cppu::defaultBootstrap_InitialComponentContext();
+
+ // initialize UCB
+ uno::Sequence< uno::Any > theArguments(2);
+ theArguments[0] = uno::makeAny( UNISTRING( "Local") );
+ theArguments[1] = uno::makeAny( UNISTRING( "Office") );
+
+ uno::Reference< uno::XInterface > xUCB =
+ rComponentContext->getServiceManager()->createInstanceWithArgumentsAndContext(
+ UNISTRING( "com.sun.star.ucb.UniversalContentBroker" ),
+ theArguments,
+ rComponentContext );
+
+ // retrieve the update information provider
+ uno::Reference< deployment::XUpdateInformationProvider > rUpdateInformationProvider =
+ deployment::UpdateInformationProvider::create( rComponentContext );
+
+ uno::Sequence< rtl::OUString > theURLs(1);
+ osl_getCommandArg( 0, &theURLs[0].pData );
+ // theURLs[0] = UNISTRING( "http://localhost/~olli/atomfeed.xml" );
+
+ rtl::OUString aExtension = UNISTRING( "MyExtension" );
+
+ try
+ {
+ uno::Sequence< uno::Reference< xml::dom::XElement > > theUpdateInfo =
+ rUpdateInformationProvider->getUpdateInformation( theURLs, aExtension );
+
+ OSL_TRACE( "getUpdateInformation returns %d element(s)", theUpdateInfo.getLength() );
+ }
+ catch( const uno::Exception & e )
+ {
+ OSL_TRACE( "exception caught: %s", rtl::OUStringToOString( e.Message, RTL_TEXTENCODING_UTF8 ).getStr());
+ }
+ catch( ... )
+ {
+ OSL_TRACE( "exception of undetermined type caught" );
+ }
+
+
+ return 0;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/update/feed/updatefeed.cxx b/extensions/source/update/feed/updatefeed.cxx
new file mode 100644
index 000000000000..ff1a10d86a17
--- /dev/null
+++ b/extensions/source/update/feed/updatefeed.cxx
@@ -0,0 +1,877 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+
+#include <cppuhelper/implbase1.hxx>
+#include <cppuhelper/implbase4.hxx>
+#include <cppuhelper/implementationentry.hxx>
+#include <com/sun/star/beans/Property.hpp>
+#include <com/sun/star/beans/XPropertySetInfo.hpp>
+#include <com/sun/star/beans/PropertyValue.hpp>
+#include <com/sun/star/container/XNameAccess.hpp>
+#include <com/sun/star/deployment/UpdateInformationEntry.hpp>
+#include <com/sun/star/deployment/UpdateInformationProvider.hpp>
+#include <com/sun/star/io/XActiveDataSink.hpp>
+#include <com/sun/star/io/XInputStream.hpp>
+#include <com/sun/star/lang/XComponent.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/ucb/XCommandEnvironment.hpp>
+#include <com/sun/star/ucb/XWebDAVCommandEnvironment.hpp>
+#include <com/sun/star/ucb/XCommandProcessor2.hpp>
+#include <com/sun/star/ucb/XContentIdentifierFactory.hpp>
+#include <com/sun/star/ucb/XContentProvider.hpp>
+#include "com/sun/star/ucb/XInteractionSupplyAuthentication.hpp"
+#include <com/sun/star/ucb/OpenCommandArgument2.hpp>
+#include <com/sun/star/ucb/OpenMode.hpp>
+#include <com/sun/star/sdbc/XRow.hpp>
+#include <com/sun/star/task/PasswordContainerInteractionHandler.hpp>
+#include <com/sun/star/xml/dom/XDocumentBuilder.hpp>
+#include <com/sun/star/xml/xpath/XXPathAPI.hpp>
+
+#include <rtl/ref.hxx>
+#include <rtl/memory.h>
+#include <rtl/bootstrap.hxx>
+#include <rtl/ustrbuf.hxx>
+#include <osl/process.h>
+#include <osl/conditn.hxx>
+
+namespace beans = com::sun::star::beans ;
+namespace container = com::sun::star::container ;
+namespace deployment = com::sun::star::deployment ;
+namespace io = com::sun::star::io ;
+namespace lang = com::sun::star::lang ;
+namespace task = com::sun::star::task ;
+namespace ucb = com::sun::star::ucb ;
+namespace uno = com::sun::star::uno ;
+namespace xml = com::sun::star::xml ;
+namespace sdbc = com::sun::star::sdbc ;
+
+#define UNISTRING(s) rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(s))
+
+//------------------------------------------------------------------------------
+
+namespace
+{
+
+#ifdef DEBUG
+
+class InputStreamWrapper : public ::cppu::WeakImplHelper1< io::XInputStream >
+{
+ uno::Reference< io::XInputStream > m_xStream;
+
+public:
+ InputStreamWrapper(const uno::Reference< io::XInputStream >& rxStream) :
+ m_xStream(rxStream) {};
+
+ virtual sal_Int32 SAL_CALL readBytes(uno::Sequence< sal_Int8 >& aData, sal_Int32 nBytesToRead)
+ throw (io::NotConnectedException, io::BufferSizeExceededException, io::IOException, uno::RuntimeException)
+ {
+ sal_Int32 n = m_xStream->readBytes(aData, nBytesToRead);
+ if ( n )
+ OSL_TRACE( "Read [%d] bytes: %s\n", n, aData.get()->elements );
+ return n;
+ };
+ virtual sal_Int32 SAL_CALL readSomeBytes(uno::Sequence< sal_Int8 >& aData, sal_Int32 nMaxBytesToRead)
+ throw (io::NotConnectedException, io::BufferSizeExceededException, io::IOException, uno::RuntimeException)
+ {
+ sal_Int32 n = m_xStream->readSomeBytes(aData, nMaxBytesToRead);
+ if ( n )
+ OSL_TRACE( "Read [%d] bytes: %s\n", n, aData.get()->elements );
+ return n;
+ };
+ virtual void SAL_CALL skipBytes( sal_Int32 nBytesToSkip )
+ throw (io::NotConnectedException, io::BufferSizeExceededException, io::IOException, uno::RuntimeException)
+ { m_xStream->skipBytes(nBytesToSkip); };
+ virtual sal_Int32 SAL_CALL available()
+ throw (io::NotConnectedException, io::IOException, uno::RuntimeException)
+ { return m_xStream->available(); };
+ virtual void SAL_CALL closeInput( )
+ throw (io::NotConnectedException, io::IOException, uno::RuntimeException)
+ {};
+};
+
+#define INPUT_STREAM(i) new InputStreamWrapper(i)
+#else
+#define INPUT_STREAM(i) i
+#endif
+
+//------------------------------------------------------------------------------
+
+class ActiveDataSink : public ::cppu::WeakImplHelper1< io::XActiveDataSink >
+{
+ uno::Reference< io::XInputStream > m_xStream;
+
+public:
+ ActiveDataSink() {};
+
+ inline operator uno::Reference< io::XActiveDataSink > () { return this; };
+
+ virtual uno::Reference< io::XInputStream > SAL_CALL getInputStream()
+ throw (uno::RuntimeException) { return m_xStream; };
+ virtual void SAL_CALL setInputStream( uno::Reference< io::XInputStream > const & rStream )
+ throw (uno::RuntimeException) { m_xStream = rStream; };
+};
+
+//------------------------------------------------------------------------------
+
+class UpdateInformationProvider :
+ public ::cppu::WeakImplHelper4< deployment::XUpdateInformationProvider,
+ ucb::XCommandEnvironment,
+ ucb::XWebDAVCommandEnvironment,
+ lang::XServiceInfo >
+{
+public:
+ static uno::Reference< uno::XInterface > createInstance(const uno::Reference<uno::XComponentContext>& xContext);
+
+ static uno::Sequence< rtl::OUString > getServiceNames();
+ static rtl::OUString getImplName();
+
+ uno::Reference< xml::dom::XElement > getDocumentRoot(const uno::Reference< xml::dom::XNode >& rxNode);
+ uno::Reference< xml::dom::XNode > getChildNode(const uno::Reference< xml::dom::XNode >& rxNode, const rtl::OUString& rName);
+
+
+ // XUpdateInformationService
+ virtual uno::Sequence< uno::Reference< xml::dom::XElement > > SAL_CALL
+ getUpdateInformation(
+ uno::Sequence< rtl::OUString > const & repositories,
+ rtl::OUString const & extensionId
+ ) throw (uno::Exception, uno::RuntimeException);
+
+ virtual void SAL_CALL cancel()
+ throw (uno::RuntimeException);
+
+ virtual void SAL_CALL setInteractionHandler(
+ uno::Reference< task::XInteractionHandler > const & handler )
+ throw (uno::RuntimeException);
+
+ virtual uno::Reference< container::XEnumeration > SAL_CALL
+ getUpdateInformationEnumeration(
+ uno::Sequence< rtl::OUString > const & repositories,
+ rtl::OUString const & extensionId
+ ) throw (uno::Exception, uno::RuntimeException);
+
+ // XCommandEnvironment
+ virtual uno::Reference< task::XInteractionHandler > SAL_CALL getInteractionHandler()
+ throw ( uno::RuntimeException );
+
+ virtual uno::Reference< ucb::XProgressHandler > SAL_CALL getProgressHandler()
+ throw ( uno::RuntimeException ) { return uno::Reference< ucb::XProgressHandler >(); };
+
+ // XWebDAVCommandEnvironment
+ virtual uno::Sequence< beans::NamedValue > SAL_CALL getUserRequestHeaders(
+ const rtl::OUString&, const rtl::OUString& )
+ throw ( uno::RuntimeException ) { return m_aRequestHeaderList; };
+
+ // XServiceInfo
+ virtual rtl::OUString SAL_CALL getImplementationName()
+ throw (uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsService(rtl::OUString const & serviceName)
+ throw (uno::RuntimeException);
+ virtual uno::Sequence< rtl::OUString > SAL_CALL getSupportedServiceNames()
+ throw (uno::RuntimeException);
+
+protected:
+
+ virtual ~UpdateInformationProvider();
+ static uno::Any getConfigurationItem(uno::Reference<lang::XMultiServiceFactory> const & configurationProvider, rtl::OUString const & node, rtl::OUString const & item);
+
+private:
+ uno::Reference< io::XInputStream > load(const rtl::OUString& rURL);
+
+ void storeCommandInfo( sal_Int32 nCommandId,
+ uno::Reference< ucb::XCommandProcessor > const & rxCommandProcessor);
+
+ UpdateInformationProvider(const uno::Reference<uno::XComponentContext>& xContext,
+ const uno::Reference< ucb::XContentIdentifierFactory >& xContentIdFactory,
+ const uno::Reference< ucb::XContentProvider >& xContentProvider,
+ const uno::Reference< xml::dom::XDocumentBuilder >& xDocumentBuilder,
+ const uno::Reference< xml::xpath::XXPathAPI >& xXPathAPI);
+
+ const uno::Reference< uno::XComponentContext> m_xContext;
+
+ const uno::Reference< ucb::XContentIdentifierFactory > m_xContentIdFactory;
+ const uno::Reference< ucb::XContentProvider > m_xContentProvider;
+ const uno::Reference< xml::dom::XDocumentBuilder > m_xDocumentBuilder;
+ const uno::Reference< xml::xpath::XXPathAPI > m_xXPathAPI;
+
+ uno::Sequence< beans::NamedValue > m_aRequestHeaderList;
+
+ uno::Reference< ucb::XCommandProcessor > m_xCommandProcessor;
+ uno::Reference< task::XInteractionHandler > m_xInteractionHandler;
+ uno::Reference< task::XInteractionHandler > m_xPwContainerInteractionHandler;
+
+ osl::Mutex m_aMutex;
+ osl::Condition m_bCancelled;
+
+ sal_Int32 m_nCommandId;
+};
+
+//------------------------------------------------------------------------------
+
+class UpdateInformationEnumeration : public ::cppu::WeakImplHelper1< container::XEnumeration >
+{
+public:
+ UpdateInformationEnumeration(const uno::Reference< xml::dom::XNodeList >& xNodeList,
+ const uno::Reference< UpdateInformationProvider > xUpdateInformationProvider) :
+ m_xUpdateInformationProvider(xUpdateInformationProvider),
+ m_xNodeList(xNodeList),
+ m_nNodes(xNodeList.is() ? xNodeList->getLength() : 0),
+ m_nCount(0)
+ {
+ };
+
+ virtual ~UpdateInformationEnumeration() {};
+
+ // XEnumeration
+ sal_Bool SAL_CALL hasMoreElements() throw (uno::RuntimeException) { return m_nCount < m_nNodes; };
+ uno::Any SAL_CALL nextElement() throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException)
+ {
+ OSL_ASSERT( m_xNodeList.is() );
+ OSL_ASSERT( m_xUpdateInformationProvider.is() );
+
+ if( !(m_nCount < m_nNodes ) )
+ throw container::NoSuchElementException(rtl::OUString::valueOf(m_nCount), *this);
+
+ try
+ {
+ deployment::UpdateInformationEntry aEntry;
+
+ uno::Reference< xml::dom::XNode > xAtomEntryNode( m_xNodeList->item(m_nCount++) );
+
+ uno::Reference< xml::dom::XNode > xSummaryNode(
+ m_xUpdateInformationProvider->getChildNode( xAtomEntryNode, UNISTRING( "summary/text()" ) )
+ );
+
+ if( xSummaryNode.is() )
+ aEntry.Description = xSummaryNode->getNodeValue();
+
+ uno::Reference< xml::dom::XNode > xContentNode(
+ m_xUpdateInformationProvider->getChildNode( xAtomEntryNode, UNISTRING( "content" ) ) );
+
+ if( xContentNode.is() )
+ aEntry.UpdateDocument = m_xUpdateInformationProvider->getDocumentRoot(xContentNode);
+
+ return uno::makeAny(aEntry);
+ }
+
+ // action has been aborted
+ catch( ucb::CommandAbortedException const & e)
+ { throw lang::WrappedTargetException( UNISTRING( "Command aborted" ), *this, uno::makeAny(e) ); }
+
+ // let runtime exception pass
+ catch( uno::RuntimeException const & ) { throw; }
+
+ // document not accessible
+ catch( uno::Exception const & e)
+ { throw lang::WrappedTargetException( UNISTRING( "Document not accessible" ), *this, uno::makeAny(e) ); }
+ }
+
+private:
+ const uno::Reference< UpdateInformationProvider > m_xUpdateInformationProvider;
+ const uno::Reference< xml::dom::XNodeList > m_xNodeList;
+ const sal_Int32 m_nNodes;
+ sal_Int32 m_nCount;
+};
+
+//------------------------------------------------------------------------------
+
+class SingleUpdateInformationEnumeration : public ::cppu::WeakImplHelper1< container::XEnumeration >
+{
+public:
+ SingleUpdateInformationEnumeration(const uno::Reference< xml::dom::XElement >& xElement)
+ : m_nCount(0) { m_aEntry.UpdateDocument = xElement; };
+ virtual ~SingleUpdateInformationEnumeration() {};
+
+ // XEnumeration
+ sal_Bool SAL_CALL hasMoreElements() throw (uno::RuntimeException) { return 0 == m_nCount; };
+ uno::Any SAL_CALL nextElement() throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException)
+ {
+ if( m_nCount > 0 )
+ throw container::NoSuchElementException(rtl::OUString::valueOf(m_nCount), *this);
+
+ ++m_nCount;
+ return uno::makeAny(m_aEntry);
+ };
+
+private:
+ sal_uInt8 m_nCount;
+ deployment::UpdateInformationEntry m_aEntry;
+};
+
+
+//------------------------------------------------------------------------------
+
+UpdateInformationProvider::UpdateInformationProvider(
+ const uno::Reference<uno::XComponentContext>& xContext,
+ const uno::Reference< ucb::XContentIdentifierFactory >& xContentIdFactory,
+ const uno::Reference< ucb::XContentProvider >& xContentProvider,
+ const uno::Reference< xml::dom::XDocumentBuilder >& xDocumentBuilder,
+ const uno::Reference< xml::xpath::XXPathAPI >& xXPathAPI
+) : m_xContext(xContext), m_xContentIdFactory(xContentIdFactory),
+ m_xContentProvider(xContentProvider), m_xDocumentBuilder(xDocumentBuilder),
+ m_xXPathAPI(xXPathAPI), m_aRequestHeaderList(1)
+{
+ uno::Reference< lang::XMultiComponentFactory > xServiceManager(xContext->getServiceManager());
+ if( !xServiceManager.is() )
+ throw uno::RuntimeException(
+ UNISTRING("unable to obtain service manager from component context"),
+ uno::Reference< uno::XInterface >());
+
+ uno::Reference< lang::XMultiServiceFactory > xConfigurationProvider(
+ xServiceManager->createInstanceWithContext(
+ UNISTRING("com.sun.star.configuration.ConfigurationProvider"),
+ xContext ),
+ uno::UNO_QUERY_THROW);
+
+ rtl::OUStringBuffer buf;
+ rtl::OUString name;
+ getConfigurationItem(
+ xConfigurationProvider,
+ UNISTRING("org.openoffice.Setup/Product"),
+ UNISTRING("ooName")) >>= name;
+ buf.append(name);
+ buf.append(sal_Unicode(' '));
+ rtl::OUString version;
+ getConfigurationItem(
+ xConfigurationProvider,
+ UNISTRING("org.openoffice.Setup/Product"),
+ UNISTRING("ooSetupVersion")) >>= version;
+ buf.append(version);
+ rtl::OUString edition(
+ UNISTRING(
+ "${${BRAND_BASE_DIR}/program/edition/edition.ini:"
+ "EDITIONNAME}"));
+ rtl::Bootstrap::expandMacros(edition);
+ if (edition.getLength() != 0) {
+ buf.append(sal_Unicode(' '));
+ buf.append(edition);
+ }
+ rtl::OUString extension;
+ getConfigurationItem(
+ xConfigurationProvider,
+ UNISTRING("org.openoffice.Setup/Product"),
+ UNISTRING("ooSetupExtension")) >>= extension;
+ if (extension.getLength() != 0) {
+ buf.append(sal_Unicode(' '));
+ buf.append(extension);
+ }
+ rtl::OUString product(buf.makeStringAndClear());
+
+ rtl::OUString aBaseBuildId( UNISTRING( "${$OOO_BASE_DIR/program/" SAL_CONFIGFILE("version") ":buildid}" ) );
+ rtl::Bootstrap::expandMacros( aBaseBuildId );
+
+ rtl::OUString aBrandBuildId( UNISTRING( "${$BRAND_BASE_DIR/program/" SAL_CONFIGFILE("version") ":buildid}" ) );
+ rtl::Bootstrap::expandMacros( aBrandBuildId );
+
+ rtl::OUString aUserAgent( UNISTRING( "${$BRAND_BASE_DIR/program/" SAL_CONFIGFILE("version") ":UpdateUserAgent}" ) );
+ rtl::Bootstrap::expandMacros( aUserAgent );
+
+ if ( ! aBaseBuildId.equals( aBrandBuildId ) )
+ {
+ sal_Int32 nIndex = aUserAgent.indexOf( aBrandBuildId, 0 );
+ if ( nIndex != -1 )
+ aUserAgent = aUserAgent.replaceAt( nIndex, aBrandBuildId.getLength(), aBaseBuildId );
+ }
+
+ for (sal_Int32 i = 0;;) {
+ i = aUserAgent.indexOfAsciiL(
+ RTL_CONSTASCII_STRINGPARAM("<PRODUCT>"), i);
+ if (i == -1) {
+ break;
+ }
+ aUserAgent = aUserAgent.replaceAt(
+ i, RTL_CONSTASCII_LENGTH("<PRODUCT>"), product);
+ i += product.getLength();
+ }
+
+ m_aRequestHeaderList[0].Name = UNISTRING("Accept-Language");
+ m_aRequestHeaderList[0].Value = getConfigurationItem( xConfigurationProvider, UNISTRING("org.openoffice.Setup/L10N"), UNISTRING("ooLocale") );
+ if( aUserAgent.getLength() > 0 )
+ {
+ m_aRequestHeaderList.realloc(2);
+ m_aRequestHeaderList[1].Name = UNISTRING("User-Agent");
+ m_aRequestHeaderList[1].Value = uno::makeAny(aUserAgent);
+ }
+}
+
+//------------------------------------------------------------------------------
+uno::Reference< uno::XInterface >
+UpdateInformationProvider::createInstance(const uno::Reference<uno::XComponentContext>& xContext)
+{
+ uno::Reference< lang::XMultiComponentFactory > xServiceManager(xContext->getServiceManager());
+ if( !xServiceManager.is() )
+ throw uno::RuntimeException(
+ UNISTRING( "unable to obtain service manager from component context" ),
+ uno::Reference< uno::XInterface > ());
+
+ uno::Reference< ucb::XContentIdentifierFactory > xContentIdFactory(
+ xServiceManager->createInstanceWithContext( UNISTRING( "com.sun.star.ucb.UniversalContentBroker" ), xContext ),
+ uno::UNO_QUERY_THROW);
+
+ uno::Reference< ucb::XContentProvider > xContentProvider(xContentIdFactory, uno::UNO_QUERY_THROW);
+
+ uno::Reference< xml::dom::XDocumentBuilder > xDocumentBuilder(
+ xServiceManager->createInstanceWithContext( UNISTRING( "com.sun.star.xml.dom.DocumentBuilder" ), xContext ),
+ uno::UNO_QUERY_THROW);
+
+ uno::Reference< xml::xpath::XXPathAPI > xXPath(
+ xServiceManager->createInstanceWithContext( UNISTRING( "com.sun.star.xml.xpath.XPathAPI" ), xContext ),
+ uno::UNO_QUERY_THROW);
+
+ xXPath->registerNS( UNISTRING("atom"), UNISTRING("http://www.w3.org/2005/Atom") );
+
+ return *new UpdateInformationProvider(xContext, xContentIdFactory, xContentProvider, xDocumentBuilder, xXPath);
+}
+
+//------------------------------------------------------------------------------
+
+UpdateInformationProvider::~UpdateInformationProvider()
+{
+}
+
+//------------------------------------------------------------------------------
+
+uno::Any
+UpdateInformationProvider::getConfigurationItem(uno::Reference<lang::XMultiServiceFactory> const & configurationProvider, rtl::OUString const & node, rtl::OUString const & item)
+{
+ beans::PropertyValue aProperty;
+ aProperty.Name = UNISTRING("nodepath");
+ aProperty.Value = uno::makeAny(node);
+
+ uno::Sequence< uno::Any > aArgumentList( 1 );
+ aArgumentList[0] = uno::makeAny( aProperty );
+
+ uno::Reference< container::XNameAccess > xNameAccess(
+ configurationProvider->createInstanceWithArguments(
+ UNISTRING("com.sun.star.configuration.ConfigurationAccess"),
+ aArgumentList ),
+ uno::UNO_QUERY_THROW);
+
+ return xNameAccess->getByName(item);
+}
+
+//------------------------------------------------------------------------------
+
+void
+UpdateInformationProvider::storeCommandInfo(
+ sal_Int32 nCommandId,
+ uno::Reference< ucb::XCommandProcessor > const & rxCommandProcessor)
+{
+ osl::MutexGuard aGuard(m_aMutex);
+
+ m_nCommandId = nCommandId;
+ m_xCommandProcessor = rxCommandProcessor;
+}
+
+//------------------------------------------------------------------------------
+
+uno::Reference< io::XInputStream >
+UpdateInformationProvider::load(const rtl::OUString& rURL)
+{
+ uno::Reference< ucb::XContentIdentifier > xId = m_xContentIdFactory->createContentIdentifier(rURL);
+
+ if( !xId.is() )
+ throw uno::RuntimeException(
+ UNISTRING( "unable to obtain universal content id" ), *this);
+
+ uno::Reference< ucb::XCommandProcessor > xCommandProcessor(m_xContentProvider->queryContent(xId), uno::UNO_QUERY_THROW);
+ rtl::Reference< ActiveDataSink > aSink(new ActiveDataSink());
+
+ ucb::OpenCommandArgument2 aOpenArgument;
+ aOpenArgument.Mode = ucb::OpenMode::DOCUMENT;
+ aOpenArgument.Priority = 32768;
+ aOpenArgument.Sink = *aSink;
+
+ ucb::Command aCommand;
+ aCommand.Name = UNISTRING("open");
+ aCommand.Argument = uno::makeAny(aOpenArgument);
+
+ sal_Int32 nCommandId = xCommandProcessor->createCommandIdentifier();
+
+ storeCommandInfo(nCommandId, xCommandProcessor);
+ try
+ {
+ uno::Any aResult = xCommandProcessor->execute(aCommand, nCommandId,
+ static_cast < XCommandEnvironment *> (this));
+ }
+ catch( const uno::Exception & /* e */ )
+ {
+ storeCommandInfo(0, uno::Reference< ucb::XCommandProcessor > ());
+
+ uno::Reference< ucb::XCommandProcessor2 > xCommandProcessor2(xCommandProcessor, uno::UNO_QUERY);
+ if( xCommandProcessor2.is() )
+ xCommandProcessor2->releaseCommandIdentifier(nCommandId);
+
+ throw;
+ }
+ storeCommandInfo(0, uno::Reference< ucb::XCommandProcessor > ());
+
+ uno::Reference< ucb::XCommandProcessor2 > xCommandProcessor2(xCommandProcessor, uno::UNO_QUERY);
+ if( xCommandProcessor2.is() )
+ xCommandProcessor2->releaseCommandIdentifier(nCommandId);
+
+ return INPUT_STREAM(aSink->getInputStream());
+}
+
+//------------------------------------------------------------------------------
+
+// TODO: docu content node
+
+uno::Reference< xml::dom::XElement >
+UpdateInformationProvider::getDocumentRoot(const uno::Reference< xml::dom::XNode >& rxNode)
+{
+ OSL_ASSERT(m_xDocumentBuilder.is());
+
+ uno::Reference< xml::dom::XElement > xElement(rxNode, uno::UNO_QUERY_THROW);
+
+ // load the document referenced in 'src' attribute ..
+ if( xElement->hasAttribute( UNISTRING("src") ) )
+ {
+ uno::Reference< xml::dom::XDocument > xUpdateXML =
+ m_xDocumentBuilder->parse(load(xElement->getAttribute( UNISTRING("src") )));
+
+ OSL_ASSERT( xUpdateXML.is() );
+
+ if( xUpdateXML.is() )
+ return xUpdateXML->getDocumentElement();
+ }
+ // .. or return the (single) child element
+ else
+ {
+ uno::Reference< xml::dom::XNodeList> xChildNodes = rxNode->getChildNodes();
+
+ // ignore possible #text nodes
+ sal_Int32 nmax = xChildNodes->getLength();
+ for(sal_Int32 n=0; n < nmax; n++)
+ {
+ uno::Reference< xml::dom::XElement > xChildElement(xChildNodes->item(n), uno::UNO_QUERY);
+ if( xChildElement.is() )
+ {
+ /* Copy the content to a dedicated document since XXPathAPI->selectNodeList
+ * seems to evaluate expression always relative to the root node.
+ */
+ uno::Reference< xml::dom::XDocument > xUpdateXML = m_xDocumentBuilder->newDocument();
+ xUpdateXML->appendChild( xUpdateXML->importNode(xChildElement.get(), sal_True ) );
+ return xUpdateXML->getDocumentElement();
+ }
+ }
+ }
+
+ return uno::Reference< xml::dom::XElement > ();
+}
+
+//------------------------------------------------------------------------------
+
+uno::Reference< xml::dom::XNode >
+UpdateInformationProvider::getChildNode(const uno::Reference< xml::dom::XNode >& rxNode,
+ const rtl::OUString& rName)
+{
+ OSL_ASSERT(m_xXPathAPI.is());
+ try {
+ return m_xXPathAPI->selectSingleNode(rxNode, UNISTRING( "./atom:" ) + rName);
+ } catch (xml::xpath::XPathException &) {
+ // ignore
+ return 0;
+ }
+}
+
+//------------------------------------------------------------------------------
+
+uno::Reference< container::XEnumeration > SAL_CALL
+UpdateInformationProvider::getUpdateInformationEnumeration(
+ uno::Sequence< rtl::OUString > const & repositories,
+ rtl::OUString const & extensionId
+) throw (uno::Exception, uno::RuntimeException)
+{
+ OSL_ASSERT(m_xDocumentBuilder.is());
+
+ // reset cancelled flag
+ m_bCancelled.reset();
+
+ for(sal_Int32 n=0; n<repositories.getLength(); n++)
+ {
+ try
+ {
+ uno::Reference< xml::dom::XDocument > xDocument = m_xDocumentBuilder->parse(load(repositories[n]));
+ uno::Reference< xml::dom::XElement > xElement;
+
+ if( xDocument.is() )
+ xElement = xDocument->getDocumentElement();
+
+ if( xElement.is() )
+ {
+ if( xElement->getNodeName().equalsAsciiL("feed", 4) )
+ {
+ rtl::OUString aXPathExpression;
+
+ if( extensionId.getLength() > 0 )
+ aXPathExpression = UNISTRING("//atom:entry/atom:category[@term=\'") + extensionId + UNISTRING("\']/..");
+ else
+ aXPathExpression = UNISTRING("//atom:entry");
+
+ uno::Reference< xml::dom::XNodeList > xNodeList;
+ try {
+ xNodeList = m_xXPathAPI->selectNodeList(xDocument.get(),
+ aXPathExpression);
+ } catch (xml::xpath::XPathException &) {
+ // ignore
+ }
+
+ return new UpdateInformationEnumeration(xNodeList, this);
+ }
+ else
+ {
+ return new SingleUpdateInformationEnumeration(xElement);
+ }
+ }
+
+ if( m_bCancelled.check() )
+ break;
+ }
+ // rethrow runtime exceptions
+ catch( uno::RuntimeException const & ) { throw; }
+
+ // rethrow only if last url in the list
+ catch( uno::Exception const & )
+ {
+ if( n+1 >= repositories.getLength() )
+ throw;
+ }
+ }
+
+ return uno::Reference< container::XEnumeration >();
+}
+
+//------------------------------------------------------------------------------
+
+uno::Sequence< uno::Reference< xml::dom::XElement > > SAL_CALL
+UpdateInformationProvider::getUpdateInformation(
+ uno::Sequence< rtl::OUString > const & repositories,
+ rtl::OUString const & extensionId
+) throw (uno::Exception, uno::RuntimeException)
+{
+ uno::Reference< container::XEnumeration > xEnumeration(
+ getUpdateInformationEnumeration(repositories, extensionId)
+ );
+
+ uno::Sequence< uno::Reference< xml::dom::XElement > > aRet;
+
+ if( xEnumeration.is() )
+ {
+ while( xEnumeration->hasMoreElements() )
+ {
+ try
+ {
+ deployment::UpdateInformationEntry aEntry;
+ if( (xEnumeration->nextElement() >>= aEntry ) && aEntry.UpdateDocument.is() )
+ {
+ sal_Int32 n = aRet.getLength();
+ aRet.realloc(n + 1);
+ aRet[n] = aEntry.UpdateDocument;
+ }
+ }
+
+ catch( const lang::WrappedTargetException& e )
+ {
+ // command aborted, return what we have got so far
+ if( e.TargetException.isExtractableTo( ::cppu::UnoType< ::com::sun::star::ucb::CommandAbortedException >::get() ) )
+ {
+ break;
+ }
+
+ // ignore files that can't be loaded
+ }
+ }
+ }
+
+ return aRet;
+}
+
+//------------------------------------------------------------------------------
+
+void SAL_CALL
+UpdateInformationProvider::cancel() throw (uno::RuntimeException)
+{
+ m_bCancelled.set();
+
+ osl::MutexGuard aGuard(m_aMutex);
+ if( m_xCommandProcessor.is() )
+ m_xCommandProcessor->abort(m_nCommandId);
+}
+
+//------------------------------------------------------------------------------
+
+void SAL_CALL
+UpdateInformationProvider::setInteractionHandler(
+ uno::Reference< task::XInteractionHandler > const & handler )
+ throw (uno::RuntimeException)
+{
+ osl::MutexGuard aGuard(m_aMutex);
+ m_xInteractionHandler = handler;
+}
+
+//------------------------------------------------------------------------------
+
+uno::Reference< task::XInteractionHandler > SAL_CALL
+UpdateInformationProvider::getInteractionHandler()
+ throw ( uno::RuntimeException )
+{
+ osl::MutexGuard aGuard( m_aMutex );
+
+ if ( m_xInteractionHandler.is() )
+ return m_xInteractionHandler;
+ else
+ {
+ try
+ {
+ // Supply an interaction handler that uses the password container
+ // service to obtain credentials without displaying a password gui.
+
+ if ( !m_xPwContainerInteractionHandler.is() )
+ m_xPwContainerInteractionHandler
+ = task::PasswordContainerInteractionHandler::create(
+ m_xContext );
+ }
+ catch ( uno::RuntimeException const & )
+ {
+ throw;
+ }
+ catch ( uno::Exception const & )
+ {
+ }
+ return m_xPwContainerInteractionHandler;
+ }
+}
+//------------------------------------------------------------------------------
+
+uno::Sequence< rtl::OUString >
+UpdateInformationProvider::getServiceNames()
+{
+ uno::Sequence< rtl::OUString > aServiceList(1);
+ aServiceList[0] = UNISTRING( "com.sun.star.deployment.UpdateInformationProvider");
+ return aServiceList;
+};
+
+//------------------------------------------------------------------------------
+
+rtl::OUString
+UpdateInformationProvider::getImplName()
+{
+ return UNISTRING( "vnd.sun.UpdateInformationProvider");
+}
+
+//------------------------------------------------------------------------------
+
+rtl::OUString SAL_CALL
+UpdateInformationProvider::getImplementationName() throw (uno::RuntimeException)
+{
+ return getImplName();
+}
+
+//------------------------------------------------------------------------------
+
+uno::Sequence< rtl::OUString > SAL_CALL
+UpdateInformationProvider::getSupportedServiceNames() throw (uno::RuntimeException)
+{
+ return getServiceNames();
+}
+
+//------------------------------------------------------------------------------
+
+sal_Bool SAL_CALL
+UpdateInformationProvider::supportsService( rtl::OUString const & serviceName ) throw (uno::RuntimeException)
+{
+ uno::Sequence< rtl::OUString > aServiceNameList = getServiceNames();
+
+ for( sal_Int32 n=0; n < aServiceNameList.getLength(); n++ )
+ if( aServiceNameList[n].equals(serviceName) )
+ return sal_True;
+
+ return sal_False;
+}
+
+} // anonymous namespace
+
+//------------------------------------------------------------------------------
+
+static uno::Reference<uno::XInterface> SAL_CALL
+createInstance(uno::Reference<uno::XComponentContext> const & xContext)
+{
+ return UpdateInformationProvider::createInstance(xContext);
+}
+
+//------------------------------------------------------------------------------
+
+static const cppu::ImplementationEntry kImplementations_entries[] =
+{
+ {
+ createInstance,
+ UpdateInformationProvider::getImplName,
+ UpdateInformationProvider::getServiceNames,
+ cppu::createSingleComponentFactory,
+ NULL,
+ 0
+ },
+ { NULL, NULL, NULL, NULL, NULL, 0 }
+} ;
+
+//------------------------------------------------------------------------------
+
+extern "C" void SAL_CALL
+component_getImplementationEnvironment( const sal_Char **aEnvTypeName, uno_Environment **)
+{
+ *aEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME ;
+}
+
+//------------------------------------------------------------------------------
+
+extern "C" sal_Bool SAL_CALL
+component_writeInfo(void *pServiceManager, void *pRegistryKey)
+{
+ return cppu::component_writeInfoHelper(
+ pServiceManager,
+ pRegistryKey,
+ kImplementations_entries
+ );
+}
+
+//------------------------------------------------------------------------------
+
+extern "C" void *
+component_getFactory(const sal_Char *pszImplementationName, void *pServiceManager, void *pRegistryKey)
+{
+ return cppu::component_getFactoryHelper(
+ pszImplementationName,
+ pServiceManager,
+ pRegistryKey,
+ kImplementations_entries) ;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/update/feed/updatefeed.xml b/extensions/source/update/feed/updatefeed.xml
new file mode 100644
index 000000000000..b8606a643c93
--- /dev/null
+++ b/extensions/source/update/feed/updatefeed.xml
@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE module-description PUBLIC "-//StarOffice//DTD ComponentDescription 1.0//EN" "module-description.dtd">
+<module-description xmlns:xlink="http://www.w3.org/1999/xlink">
+ <module-name>updatefeed</module-name>
+ <component-description>
+ <author> Oliver Braun </author>
+ <name>vnd.sun.UpdateCheck</name>
+ <description> The </description>
+ <loader-name>com.sun.star.loader.SharedLibrary</loader-name>
+ <language>c++</language>
+ <status value="beta"/>
+ <supported-service>com.sun.star.deployment.UpdateInformationProvider</supported-service>
+ <service-dependency>...</service-dependency>
+ <type>com.sun.star.beans.NamedValue</type>
+ <type>com.sun.star.beans.PropertyValue</type>
+ <type>com.sun.star.container.XNameReplace</type>
+ <type>com.sun.star.deployment.UpdateInformationProvider</type>
+ <type>com.sun.star.io.XInputStream</type>
+ <type>com.sun.star.io.XOutputStream</type>
+ <type>com.sun.star.lang.XComponent</type>
+ <type>com.sun.star.lang.XInitialization</type>
+ <type>com.sun.star.lang.XMultiComponentFactory</type>
+ <type>com.sun.star.lang.XMultiServiceFactory</type>
+ <type>com.sun.star.lang.XServiceInfo</type>
+ <type>com.sun.star.lang.XSingleComponentFactory</type>
+ <type>com.sun.star.lang.XSingleServiceFactory</type>
+ <type>com.sun.star.lang.XTypeProvider</type>
+ <type>com.sun.star.registry.XRegistryKey</type>
+ <type>com.sun.star.task.XInteractionHandler</type>
+ <type>com.sun.star.ucb.PostCommandArgument2</type>
+ <type>com.sun.star.ucb.XCommandEnvironment</type>
+ <type>com.sun.star.ucb.XCommandProcessor2</type>
+ <type>com.sun.star.ucb.XContentIdentifierFactory</type>
+ <type>com.sun.star.ucb.XContentProvider</type>
+ <type>com.sun.star.ucb.XProgressHandler</type>
+ <type>com.sun.star.uno.TypeClass</type>
+ <type>com.sun.star.uno.XAggregation</type>
+ <type>com.sun.star.uno.XComponentContext</type>
+ <type>com.sun.star.uno.XCurrentContext</type>
+ <type>com.sun.star.uno.XWeak</type>
+ <type>com.sun.star.util.XChangesBatch</type>
+ </component-description>
+ <project-build-dependency>cppuhelper</project-build-dependency>
+ <project-build-dependency>cppu</project-build-dependency>
+ <project-build-dependency>sal</project-build-dependency>
+ <runtime-module-dependency>cppuhelper3$(COM)</runtime-module-dependency>
+ <runtime-module-dependency>cppu3</runtime-module-dependency>
+ <runtime-module-dependency>sal3</runtime-module-dependency>
+</module-description>
diff --git a/extensions/source/update/tools/makefile.mk b/extensions/source/update/tools/makefile.mk
new file mode 100644
index 000000000000..d6baac98680a
--- /dev/null
+++ b/extensions/source/update/tools/makefile.mk
@@ -0,0 +1,68 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ = ..$/..$/..
+PRJNAME = extensions
+TARGET = ztool
+LIBTARGET = NO
+TARGETTYPE = CUI
+ENABLE_EXCEPTIONS=TRUE
+
+.INCLUDE: settings.mk
+
+OBJFILES = \
+ $(OBJ)$/ztool.obj
+
+APP1TARGET = ztool
+APP1OBJS = $(OBJ)$/ztool.obj
+APP1STDLIBS = $(TOOLSLIB)
+
+#APP1TARGET = ztool
+#APP1OBJS = $(OBJ)$/ztool.obj
+#.IF "$(GUI)" == "UNX"
+#APP1STDLIBS = $(TOOLSLIB)
+#.ELSE
+#APP1LIBS = $(LB)$/itools.lib
+#.ENDIF
+
+#APP2TARGET = urltest
+#APP2OBJS = $(OBJ)$/urltest.obj
+#.IF "$(GUI)" == "UNX"
+#APP2STDLIBS = $(TOOLSLIB) $(SALLIB) $(CPPULIB) $(CPPUHELPERLIB)
+#.ELSE
+#APP2STDLIBS = $(LB)$/itools.lib isal.lib icppu.lib icppuhelper.lib
+#.ENDIF
+
+# APP3TARGET = tldem
+# APP3OBJS = $(OBJ)$/tldem.obj
+# .IF "$(GUI)" == "UNX"
+# APP3STDLIBS = $(TOOLSLIB)
+# .ELSE
+# APP3STDLIBS = $(LB)$/itools.lib
+# .ENDIF
+
+.INCLUDE: target.mk
diff --git a/extensions/source/update/tools/ztool.cxx b/extensions/source/update/tools/ztool.cxx
new file mode 100644
index 000000000000..3695823110b6
--- /dev/null
+++ b/extensions/source/update/tools/ztool.cxx
@@ -0,0 +1,66 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include <stdio.h>
+
+#include <tools/stream.hxx>
+#include <tools/zcodec.hxx>
+
+void show_usage()
+{
+ fputs("ztool usage: ztool <source> <dest>\n", stderr);
+}
+
+int
+#ifdef WNT
+__cdecl
+#endif
+main( int argc, char **argv )
+{
+ if ( argc != 3 )
+ {
+ show_usage();
+ return -1;
+ }
+ UniString aInName = UniString::CreateFromAscii( argv[1] );
+ UniString aOutName = UniString::CreateFromAscii( argv[2] );
+ SvFileStream aInFile( aInName, STREAM_READ );
+ SvFileStream aOutFile( aOutName, STREAM_WRITE | STREAM_TRUNC );
+
+ ZCodec aCompressor;
+ aCompressor.BeginCompression();
+ aCompressor.Compress( aInFile, aOutFile );
+ aCompressor.EndCompression();
+
+ return 0;
+}
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/update/ui/makefile.mk b/extensions/source/update/ui/makefile.mk
new file mode 100644
index 000000000000..c4826efba9ca
--- /dev/null
+++ b/extensions/source/update/ui/makefile.mk
@@ -0,0 +1,74 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+PRJ=..$/..$/..
+
+PRJNAME=extensions
+TARGET=updchkui
+
+LIBTARGET=NO
+ENABLE_EXCEPTIONS=TRUE
+
+# --- Settings ---
+
+.INCLUDE : settings.mk
+
+# --- Files ---
+
+SLOFILES=\
+ $(SLO)$/updatecheckui.obj
+
+SRS1NAME=$(TARGET)
+SRC1FILES=\
+ updatecheckui.src
+
+RESLIB1NAME=updchk
+RESLIB1IMAGES=$(PRJ)$/source$/update$/ui
+RESLIB1SRSFILES= $(SRS)$/updchkui.srs
+RESLIB1DEPN= updatecheckui.src updatecheckui.hrc
+
+SHL1NOCHECK=TRUE
+SHL1TARGET=updchk$(DLLPOSTFIX)
+SHL1OBJS=$(SLOFILES)
+SHL1DEF=$(MISC)$/$(SHL1TARGET).def
+
+SHL1IMPLIB=i$(SHL1TARGET)
+SHL1STDLIBS= \
+ $(COMPHELPERLIB) \
+ $(CPPUHELPERLIB) \
+ $(CPPULIB) \
+ $(SALLIB) \
+ $(VCLLIB) \
+ $(TOOLSLIB)
+
+SHL1VERSIONMAP=$(SOLARENV)/src/component.map
+SHL1DEF=$(MISC)$/$(SHL1TARGET).def
+DEF1NAME=$(SHL1TARGET)
+
+# --- Targets ---
+
+.INCLUDE : target.mk
+
diff --git a/extensions/source/update/ui/updatecheckui.cxx b/extensions/source/update/ui/updatecheckui.cxx
new file mode 100644
index 000000000000..fe784a7d5630
--- /dev/null
+++ b/extensions/source/update/ui/updatecheckui.cxx
@@ -0,0 +1,1085 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+
+#include <list>
+
+#include <cppuhelper/implbase3.hxx>
+#include <cppuhelper/implementationentry.hxx>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/lang/XComponent.hpp>
+#include <com/sun/star/document/XEventListener.hpp>
+#include <com/sun/star/document/XEventBroadcaster.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/graphic/XGraphicProvider.hpp>
+#include <com/sun/star/task/XJob.hpp>
+
+#include <comphelper/processfactory.hxx>
+
+#include <osl/mutex.hxx>
+#include <osl/mutex.hxx>
+
+#include <vcl/window.hxx>
+#include <vcl/floatwin.hxx>
+#include <vcl/timer.hxx>
+#include <vcl/menu.hxx>
+#include <vcl/outdev.hxx>
+#include <vcl/msgbox.hxx>
+#include <vcl/lineinfo.hxx>
+#include <vcl/imagebtn.hxx>
+#include <vcl/settings.hxx>
+#include <vcl/svapp.hxx>
+#include <sfx2/sfx.hrc>
+#include "rtl/ustrbuf.hxx"
+
+#include "updatecheckui.hrc"
+
+#define UNISTRING(s) rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(s))
+
+#define MSG_ERR_NO_WEBBROWSER_FOUND (RID_SFX_APP_START + 7)
+#define DEFAULT_MENUBAR_HEIGHT 24
+
+#define PROPERTY_TITLE RTL_CONSTASCII_STRINGPARAM("BubbleHeading")
+#define PROPERTY_TEXT RTL_CONSTASCII_STRINGPARAM("BubbleText")
+#define PROPERTY_IMAGE RTL_CONSTASCII_STRINGPARAM("BubbleImageURL")
+#define PROPERTY_SHOW_BUBBLE RTL_CONSTASCII_STRINGPARAM("BubbleVisible")
+#define PROPERTY_CLICK_HDL RTL_CONSTASCII_STRINGPARAM("MenuClickHDL")
+#define PROPERTY_SHOW_MENUICON RTL_CONSTASCII_STRINGPARAM("MenuIconVisible")
+
+#define START_TIMER 1
+
+using namespace ::com::sun::star;
+
+//------------------------------------------------------------------------------
+
+static uno::Sequence< rtl::OUString > getServiceNames()
+{
+ uno::Sequence< rtl::OUString > aServiceList(1);
+ aServiceList[0] = UNISTRING( "com.sun.star.setup.UpdateCheckUI");
+ return aServiceList;
+}
+
+//------------------------------------------------------------------------------
+
+static rtl::OUString getImplementationName()
+{
+ return UNISTRING( "vnd.sun.UpdateCheckUI");
+}
+
+//------------------------------------------------------------------------------
+
+namespace
+{
+
+//------------------------------------------------------------------------------
+class BubbleWindow : public FloatingWindow
+{
+ Point maTipPos;
+ Region maBounds;
+ Polygon maRectPoly;
+ Polygon maTriPoly;
+ XubString maBubbleTitle;
+ XubString maBubbleText;
+ Image maBubbleImage;
+ Size maMaxTextSize;
+ Rectangle maTitleRect;
+ Rectangle maTextRect;
+ long mnTipOffset;
+
+private:
+ void RecalcTextRects();
+
+public:
+ BubbleWindow( Window* pParent, const XubString& rTitle,
+ const XubString& rText, const Image& rImage );
+ ~BubbleWindow();
+
+ virtual void MouseButtonDown( const MouseEvent& rMEvt );
+ virtual void Paint( const Rectangle& rRect );
+ void Resize();
+ void Show( BOOL bVisible = TRUE, USHORT nFlags = SHOW_NOACTIVATE );
+ void SetTipPosPixel( const Point& rTipPos ) { maTipPos = rTipPos; }
+ void SetTitleAndText( const XubString& rTitle, const XubString& rText,
+ const Image& rImage );
+};
+
+//------------------------------------------------------------------------------
+class UpdateCheckUI : public ::cppu::WeakImplHelper3
+ < lang::XServiceInfo, document::XEventListener, beans::XPropertySet >
+{
+ uno::Reference< uno::XComponentContext > m_xContext;
+ uno::Reference< task::XJob > mrJob;
+ rtl::OUString maBubbleTitle;
+ rtl::OUString maBubbleText;
+ rtl::OUString maBubbleImageURL;
+ Image maBubbleImage;
+ BubbleWindow* mpBubbleWin;
+ SystemWindow* mpIconSysWin;
+ MenuBar* mpIconMBar;
+ ResMgr* mpUpdResMgr;
+ ResMgr* mpSfxResMgr;
+ Timer maWaitTimer;
+ Timer maTimeoutTimer;
+ Link maWindowEventHdl;
+ Link maApplicationEventHdl;
+ bool mbShowBubble;
+ bool mbShowMenuIcon;
+ bool mbBubbleChanged;
+ USHORT mnIconID;
+
+private:
+ DECL_LINK( ClickHdl, USHORT* );
+ DECL_LINK( HighlightHdl, MenuBar::MenuBarButtonCallbackArg* );
+ DECL_LINK( WaitTimeOutHdl, Timer* );
+ DECL_LINK( TimeOutHdl, Timer* );
+ DECL_LINK( UserEventHdl, UpdateCheckUI* );
+ DECL_LINK( WindowEventHdl, VclWindowEvent* );
+ DECL_LINK( ApplicationEventHdl, VclSimpleEvent* );
+
+ BubbleWindow* GetBubbleWindow();
+ void RemoveBubbleWindow( bool bRemoveIcon );
+ Image GetMenuBarIcon( MenuBar* pMBar );
+ void AddMenuBarIcon( SystemWindow* pSysWin, bool bAddEventHdl );
+ Image GetBubbleImage( ::rtl::OUString &rURL );
+
+ uno::Reference< document::XEventBroadcaster > getGlobalEventBroadcaster() const
+ throw (uno::RuntimeException);
+
+public:
+ UpdateCheckUI(const uno::Reference<uno::XComponentContext>&);
+ virtual ~UpdateCheckUI();
+
+ // XServiceInfo
+ virtual rtl::OUString SAL_CALL getImplementationName()
+ throw (uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsService(rtl::OUString const & serviceName)
+ throw (uno::RuntimeException);
+ virtual uno::Sequence< rtl::OUString > SAL_CALL getSupportedServiceNames()
+ throw (uno::RuntimeException);
+
+ // XEventListener
+ virtual void SAL_CALL notifyEvent(const document::EventObject& Event)
+ throw (uno::RuntimeException);
+ virtual void SAL_CALL disposing(const lang::EventObject& Event)
+ throw (uno::RuntimeException);
+
+ //XPropertySet
+ virtual uno::Reference< beans::XPropertySetInfo > SAL_CALL getPropertySetInfo(void)
+ throw ( uno::RuntimeException );
+ virtual void SAL_CALL setPropertyValue(const rtl::OUString& PropertyName, const uno::Any& aValue)
+ throw( beans::UnknownPropertyException, beans::PropertyVetoException,
+ lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException );
+ virtual uno::Any SAL_CALL getPropertyValue(const rtl::OUString& PropertyName)
+ throw ( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException );
+ virtual void SAL_CALL addPropertyChangeListener(const rtl::OUString& PropertyName,
+ const uno::Reference< beans::XPropertyChangeListener > & aListener)
+ throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException );
+ virtual void SAL_CALL removePropertyChangeListener(const rtl::OUString& PropertyName,
+ const uno::Reference< beans::XPropertyChangeListener > & aListener)
+ throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException );
+ virtual void SAL_CALL addVetoableChangeListener(const rtl::OUString& PropertyName,
+ const uno::Reference< beans::XVetoableChangeListener > & aListener)
+ throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException );
+ virtual void SAL_CALL removeVetoableChangeListener(const rtl::OUString& PropertyName,
+ const uno::Reference< beans::XVetoableChangeListener > & aListener)
+ throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException );
+};
+
+//------------------------------------------------------------------------------
+UpdateCheckUI::UpdateCheckUI(const uno::Reference<uno::XComponentContext>& xContext) :
+ m_xContext(xContext)
+ , mpBubbleWin( NULL )
+ , mpIconSysWin( NULL )
+ , mpIconMBar( NULL )
+ , mbShowBubble( false )
+ , mbShowMenuIcon( false )
+ , mbBubbleChanged( false )
+ , mnIconID( 0 )
+{
+ mpUpdResMgr = ResMgr::CreateResMgr( "updchk" );
+ mpSfxResMgr = ResMgr::CreateResMgr( "sfx" );
+
+ maBubbleImage = GetBubbleImage( maBubbleImageURL );
+
+ maWaitTimer.SetTimeout( 400 );
+ maWaitTimer.SetTimeoutHdl( LINK( this, UpdateCheckUI, WaitTimeOutHdl ) );
+
+ maTimeoutTimer.SetTimeout( 10000 );
+ maTimeoutTimer.SetTimeoutHdl( LINK( this, UpdateCheckUI, TimeOutHdl ) );
+
+ uno::Reference< document::XEventBroadcaster > xBroadcaster( getGlobalEventBroadcaster() );
+ xBroadcaster->addEventListener( this );
+
+ maWindowEventHdl = LINK( this, UpdateCheckUI, WindowEventHdl );
+ maApplicationEventHdl = LINK( this, UpdateCheckUI, ApplicationEventHdl );
+ Application::AddEventListener( maApplicationEventHdl );
+}
+
+//------------------------------------------------------------------------------
+UpdateCheckUI::~UpdateCheckUI()
+{
+ Application::RemoveEventListener( maApplicationEventHdl );
+ RemoveBubbleWindow( true );
+ delete mpUpdResMgr;
+ delete mpSfxResMgr;
+}
+
+//------------------------------------------------------------------------------
+uno::Reference<document::XEventBroadcaster>
+UpdateCheckUI::getGlobalEventBroadcaster() const throw (uno::RuntimeException)
+{
+ if( !m_xContext.is() )
+ throw uno::RuntimeException(
+ UNISTRING( "UpdateCheckUI: empty component context" ),
+ uno::Reference< uno::XInterface >() );
+
+ uno::Reference< lang::XMultiComponentFactory > xServiceManager(m_xContext->getServiceManager());
+
+ if( !xServiceManager.is() )
+ throw uno::RuntimeException(
+ UNISTRING( "UpdateCheckUI: unable to obtain service manager from component context" ),
+ uno::Reference< uno::XInterface >() );
+
+ return uno::Reference<document::XEventBroadcaster> (
+ xServiceManager->createInstanceWithContext(
+ UNISTRING( "com.sun.star.frame.GlobalEventBroadcaster" ),
+ m_xContext),
+ uno::UNO_QUERY_THROW);
+}
+
+//------------------------------------------------------------------------------
+rtl::OUString SAL_CALL
+UpdateCheckUI::getImplementationName() throw (uno::RuntimeException)
+{
+ return ::getImplementationName();
+}
+
+//------------------------------------------------------------------------------
+uno::Sequence< rtl::OUString > SAL_CALL
+UpdateCheckUI::getSupportedServiceNames() throw (uno::RuntimeException)
+{
+ return ::getServiceNames();
+}
+
+//------------------------------------------------------------------------------
+sal_Bool SAL_CALL
+UpdateCheckUI::supportsService( rtl::OUString const & serviceName ) throw (uno::RuntimeException)
+{
+ uno::Sequence< rtl::OUString > aServiceNameList = ::getServiceNames();
+
+ for( sal_Int32 n=0; n < aServiceNameList.getLength(); n++ )
+ if( aServiceNameList[n].equals(serviceName) )
+ return sal_True;
+
+ return sal_False;
+}
+
+//------------------------------------------------------------------------------
+Image UpdateCheckUI::GetMenuBarIcon( MenuBar* pMBar )
+{
+ sal_uInt32 nResID;
+ Window *pMBarWin = pMBar->GetWindow();
+ sal_uInt32 nMBarHeight = 20;
+
+ if ( pMBarWin )
+ nMBarHeight = pMBarWin->GetOutputSizePixel().getHeight();
+
+ if ( Application::GetSettings().GetStyleSettings().GetHighContrastMode() ) {
+ if ( nMBarHeight >= 35 )
+ nResID = RID_UPDATE_AVAILABLE_26_HC;
+ else
+ nResID = RID_UPDATE_AVAILABLE_16_HC;
+ } else {
+ if ( nMBarHeight >= 35 )
+ nResID = RID_UPDATE_AVAILABLE_26;
+ else
+ nResID = RID_UPDATE_AVAILABLE_16;
+ }
+
+ return Image( ResId( nResID, *mpUpdResMgr ) );
+}
+
+//------------------------------------------------------------------------------
+Image UpdateCheckUI::GetBubbleImage( ::rtl::OUString &rURL )
+{
+ Image aImage;
+
+ if ( maBubbleImageURL.getLength() != 0 )
+ {
+ uno::Reference< lang::XMultiServiceFactory > xServiceManager = ::comphelper::getProcessServiceFactory();
+
+ if( !xServiceManager.is() )
+ throw uno::RuntimeException(
+ UNISTRING( "UpdateCheckUI: unable to obtain service manager from component context" ),
+ uno::Reference< uno::XInterface >() );
+
+ try
+ {
+ uno::Reference< graphic::XGraphicProvider > xGraphProvider(
+ xServiceManager->createInstance(
+ ::rtl::OUString::createFromAscii( "com.sun.star.graphic.GraphicProvider" ) ),
+ uno::UNO_QUERY );
+ if ( xGraphProvider.is() )
+ {
+ uno::Sequence< beans::PropertyValue > aMediaProps( 1 );
+ aMediaProps[0].Name = ::rtl::OUString::createFromAscii( "URL" );
+ aMediaProps[0].Value <<= rURL;
+
+ uno::Reference< graphic::XGraphic > xGraphic = xGraphProvider->queryGraphic( aMediaProps );
+ if ( xGraphic.is() )
+ {
+ aImage = Image( xGraphic );
+ }
+ }
+ }
+ catch( uno::Exception& )
+ {
+ }
+ }
+
+ if ( aImage.GetSizePixel().Width() == 0 )
+ aImage = InfoBox::GetStandardImage();
+
+ return aImage;
+}
+
+//------------------------------------------------------------------------------
+void UpdateCheckUI::AddMenuBarIcon( SystemWindow *pSysWin, bool bAddEventHdl )
+{
+ if ( ! mbShowMenuIcon )
+ return;
+
+ SolarMutexGuard aGuard;
+
+ MenuBar *pActiveMBar = pSysWin->GetMenuBar();
+ if ( ( pSysWin != mpIconSysWin ) || ( pActiveMBar != mpIconMBar ) )
+ {
+ if ( bAddEventHdl && mpIconSysWin )
+ mpIconSysWin->RemoveEventListener( maWindowEventHdl );
+
+ RemoveBubbleWindow( true );
+
+ if ( pActiveMBar )
+ {
+ rtl::OUStringBuffer aBuf;
+ if( maBubbleTitle.getLength() )
+ aBuf.append( maBubbleTitle );
+ if( maBubbleText.getLength() )
+ {
+ if( maBubbleTitle.getLength() )
+ aBuf.appendAscii( "\n\n" );
+ aBuf.append( maBubbleText );
+ }
+
+ Image aImage = GetMenuBarIcon( pActiveMBar );
+ mnIconID = pActiveMBar->AddMenuBarButton( aImage,
+ LINK( this, UpdateCheckUI, ClickHdl ),
+ aBuf.makeStringAndClear()
+ );
+ pActiveMBar->SetMenuBarButtonHighlightHdl( mnIconID,
+ LINK( this, UpdateCheckUI, HighlightHdl ) );
+ }
+ mpIconMBar = pActiveMBar;
+ mpIconSysWin = pSysWin;
+ if ( bAddEventHdl && mpIconSysWin )
+ mpIconSysWin->AddEventListener( maWindowEventHdl );
+ }
+
+ if ( mbShowBubble && pActiveMBar )
+ {
+ mpBubbleWin = GetBubbleWindow();
+ if ( mpBubbleWin )
+ {
+ mpBubbleWin->Show( TRUE );
+ maTimeoutTimer.Start();
+ }
+ mbShowBubble = false;
+ }
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL UpdateCheckUI::notifyEvent(const document::EventObject& rEvent)
+ throw (uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ if( rEvent.EventName.compareToAscii( RTL_CONSTASCII_STRINGPARAM("OnPrepareViewClosing") ) == 0 )
+ {
+ RemoveBubbleWindow( true );
+ }
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL UpdateCheckUI::disposing(const lang::EventObject&)
+ throw (uno::RuntimeException)
+{
+}
+
+//------------------------------------------------------------------------------
+uno::Reference< beans::XPropertySetInfo > UpdateCheckUI::getPropertySetInfo(void)
+ throw ( uno::RuntimeException )
+{
+ return NULL;
+}
+
+//------------------------------------------------------------------------------
+void UpdateCheckUI::setPropertyValue(const rtl::OUString& rPropertyName,
+ const uno::Any& rValue)
+ throw( beans::UnknownPropertyException, beans::PropertyVetoException,
+ lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException)
+{
+ SolarMutexGuard aGuard;
+
+ rtl::OUString aString;
+
+ if( rPropertyName.compareToAscii( PROPERTY_TITLE ) == 0 ) {
+ rValue >>= aString;
+ if ( aString != maBubbleTitle ) {
+ maBubbleTitle = aString;
+ mbBubbleChanged = true;
+ }
+ }
+ else if( rPropertyName.compareToAscii( PROPERTY_TEXT ) == 0 ) {
+ rValue >>= aString;
+ if ( aString != maBubbleText ) {
+ maBubbleText = aString;
+ mbBubbleChanged = true;
+ }
+ }
+ else if( rPropertyName.compareToAscii( PROPERTY_IMAGE ) == 0 ) {
+ rValue >>= aString;
+ if ( aString != maBubbleImageURL ) {
+ maBubbleImageURL = aString;
+ maBubbleImage = GetBubbleImage( maBubbleImageURL );
+ mbBubbleChanged = true;
+ }
+ }
+ else if( rPropertyName.compareToAscii( PROPERTY_SHOW_BUBBLE ) == 0 ) {
+ rValue >>= mbShowBubble;
+ if ( mbShowBubble )
+ Application::PostUserEvent( LINK( this, UpdateCheckUI, UserEventHdl ) );
+ else if ( mpBubbleWin )
+ mpBubbleWin->Show( FALSE );
+ }
+ else if( rPropertyName.compareToAscii( PROPERTY_CLICK_HDL ) == 0 ) {
+ uno::Reference< task::XJob > aJob;
+ rValue >>= aJob;
+ if ( aJob.is() )
+ mrJob = aJob;
+ else
+ throw lang::IllegalArgumentException();
+ }
+ else if (rPropertyName.compareToAscii( PROPERTY_SHOW_MENUICON ) == 0) {
+ bool bShowMenuIcon = sal_False;
+ rValue >>= bShowMenuIcon;
+ if ( bShowMenuIcon != mbShowMenuIcon )
+ {
+ mbShowMenuIcon = bShowMenuIcon;
+ if ( bShowMenuIcon )
+ Application::PostUserEvent( LINK( this, UpdateCheckUI, UserEventHdl ) );
+ else
+ RemoveBubbleWindow( true );
+ }
+ }
+ else
+ throw beans::UnknownPropertyException();
+
+ if ( mbBubbleChanged && mpBubbleWin )
+ mpBubbleWin->Show( FALSE );
+}
+
+//------------------------------------------------------------------------------
+uno::Any UpdateCheckUI::getPropertyValue(const rtl::OUString& rPropertyName)
+ throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException )
+{
+ SolarMutexGuard aGuard;
+
+ uno::Any aRet;
+
+ if( rPropertyName.compareToAscii( PROPERTY_TITLE ) == 0 )
+ aRet = uno::makeAny( maBubbleTitle );
+ else if( rPropertyName.compareToAscii( PROPERTY_TEXT ) == 0 )
+ aRet = uno::makeAny( maBubbleText );
+ else if( rPropertyName.compareToAscii( PROPERTY_SHOW_BUBBLE ) == 0 )
+ aRet = uno::makeAny( mbShowBubble );
+ else if( rPropertyName.compareToAscii( PROPERTY_IMAGE ) == 0 )
+ aRet = uno::makeAny( maBubbleImageURL );
+ else if( rPropertyName.compareToAscii( PROPERTY_CLICK_HDL ) == 0 )
+ aRet = uno::makeAny( mrJob );
+ else if( rPropertyName.compareToAscii( PROPERTY_SHOW_MENUICON ) == 0 )
+ aRet = uno::makeAny( mbShowMenuIcon );
+ else
+ throw beans::UnknownPropertyException();
+
+ return aRet;
+}
+
+//------------------------------------------------------------------------------
+void UpdateCheckUI::addPropertyChangeListener( const rtl::OUString& /*aPropertyName*/,
+ const uno::Reference< beans::XPropertyChangeListener > & /*aListener*/)
+ throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException )
+{
+ //no bound properties
+}
+
+//------------------------------------------------------------------------------
+void UpdateCheckUI::removePropertyChangeListener( const rtl::OUString& /*aPropertyName*/,
+ const uno::Reference< beans::XPropertyChangeListener > & /*aListener*/)
+ throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException )
+{
+ //no bound properties
+}
+
+//------------------------------------------------------------------------------
+void UpdateCheckUI::addVetoableChangeListener( const rtl::OUString& /*aPropertyName*/,
+ const uno::Reference< beans::XVetoableChangeListener > & /*aListener*/)
+ throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException )
+{
+ //no vetoable properties
+}
+
+//------------------------------------------------------------------------------
+void UpdateCheckUI::removeVetoableChangeListener( const rtl::OUString& /*aPropertyName*/,
+ const uno::Reference< beans::XVetoableChangeListener > & /*aListener*/)
+ throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException )
+{
+ //no vetoable properties
+}
+
+
+//------------------------------------------------------------------------------
+//------------------------------------------------------------------------------
+//------------------------------------------------------------------------------
+BubbleWindow * UpdateCheckUI::GetBubbleWindow()
+{
+ if ( !mpIconSysWin )
+ return NULL;
+
+ Rectangle aIconRect = mpIconMBar->GetMenuBarButtonRectPixel( mnIconID );
+ if( aIconRect.IsEmpty() )
+ return NULL;
+
+ BubbleWindow* pBubbleWin = mpBubbleWin;
+
+ if ( !pBubbleWin ) {
+ pBubbleWin = new BubbleWindow( mpIconSysWin,
+ XubString( maBubbleTitle ),
+ XubString( maBubbleText ),
+ maBubbleImage );
+ mbBubbleChanged = false;
+ }
+ else if ( mbBubbleChanged ) {
+ pBubbleWin->SetTitleAndText( XubString( maBubbleTitle ),
+ XubString( maBubbleText ),
+ maBubbleImage );
+ mbBubbleChanged = false;
+ }
+
+ Point aWinPos = aIconRect.BottomCenter();
+
+ pBubbleWin->SetTipPosPixel( aWinPos );
+
+ return pBubbleWin;
+}
+
+//------------------------------------------------------------------------------
+void UpdateCheckUI::RemoveBubbleWindow( bool bRemoveIcon )
+{
+ SolarMutexGuard aGuard;
+
+ maWaitTimer.Stop();
+ maTimeoutTimer.Stop();
+
+ if ( mpBubbleWin )
+ {
+ delete mpBubbleWin;
+ mpBubbleWin = NULL;
+ }
+
+ if ( bRemoveIcon )
+ {
+ try {
+ if ( mpIconMBar && ( mnIconID != 0 ) )
+ {
+ mpIconMBar->RemoveMenuBarButton( mnIconID );
+ mpIconMBar = NULL;
+ mnIconID = 0;
+ }
+ }
+ catch ( ... ) {
+ mpIconMBar = NULL;
+ mnIconID = 0;
+ }
+
+ mpIconSysWin = NULL;
+ }
+}
+
+// -----------------------------------------------------------------------
+IMPL_LINK( UpdateCheckUI, ClickHdl, USHORT*, EMPTYARG )
+{
+ SolarMutexGuard aGuard;
+
+ maWaitTimer.Stop();
+ if ( mpBubbleWin )
+ mpBubbleWin->Show( FALSE );
+
+ if ( mrJob.is() )
+ {
+ try {
+ uno::Sequence<beans::NamedValue> aEmpty;
+ mrJob->execute( aEmpty );
+ }
+ catch(const uno::Exception&) {
+ ErrorBox( NULL, ResId( MSG_ERR_NO_WEBBROWSER_FOUND, *mpSfxResMgr )).Execute();
+ }
+ }
+
+ return 0;
+}
+
+// -----------------------------------------------------------------------
+IMPL_LINK( UpdateCheckUI, HighlightHdl, MenuBar::MenuBarButtonCallbackArg*, pData )
+{
+ if ( pData->bHighlight )
+ maWaitTimer.Start();
+ else
+ RemoveBubbleWindow( false );
+
+ return 0;
+}
+
+// -----------------------------------------------------------------------
+IMPL_LINK( UpdateCheckUI, WaitTimeOutHdl, Timer*, EMPTYARG )
+{
+ SolarMutexGuard aGuard;
+
+ mpBubbleWin = GetBubbleWindow();
+
+ if ( mpBubbleWin )
+ {
+ mpBubbleWin->Show();
+ }
+
+ return 0;
+}
+
+// -----------------------------------------------------------------------
+IMPL_LINK( UpdateCheckUI, TimeOutHdl, Timer*, EMPTYARG )
+{
+ RemoveBubbleWindow( false );
+
+ return 0;
+}
+
+// -----------------------------------------------------------------------
+IMPL_LINK( UpdateCheckUI, UserEventHdl, UpdateCheckUI*, EMPTYARG )
+{
+ SolarMutexGuard aGuard;
+
+ Window *pTopWin = Application::GetFirstTopLevelWindow();
+ Window *pActiveWin = Application::GetActiveTopWindow();
+ SystemWindow *pActiveSysWin = NULL;
+
+ Window *pBubbleWin = NULL;
+ if ( mpBubbleWin )
+ pBubbleWin = mpBubbleWin;
+
+ if ( pActiveWin && ( pActiveWin != pBubbleWin ) && pActiveWin->IsTopWindow() )
+ pActiveSysWin = pActiveWin->GetSystemWindow();
+
+ if ( pActiveWin == pBubbleWin )
+ pActiveSysWin = NULL;
+
+ while ( !pActiveSysWin && pTopWin )
+ {
+ if ( ( pTopWin != pBubbleWin ) && pTopWin->IsTopWindow() )
+ pActiveSysWin = pTopWin->GetSystemWindow();
+ if ( !pActiveSysWin )
+ pTopWin = Application::GetNextTopLevelWindow( pTopWin );
+ }
+
+ if ( pActiveSysWin )
+ AddMenuBarIcon( pActiveSysWin, true );
+
+ return 0;
+}
+
+// -----------------------------------------------------------------------
+IMPL_LINK( UpdateCheckUI, WindowEventHdl, VclWindowEvent*, pEvent )
+{
+ ULONG nEventID = pEvent->GetId();
+
+ if ( VCLEVENT_OBJECT_DYING == nEventID )
+ {
+ SolarMutexGuard aGuard;
+ if ( mpIconSysWin == pEvent->GetWindow() )
+ {
+ mpIconSysWin->RemoveEventListener( maWindowEventHdl );
+ RemoveBubbleWindow( true );
+ }
+ }
+ else if ( VCLEVENT_WINDOW_MENUBARADDED == nEventID )
+ {
+ SolarMutexGuard aGuard;
+ Window *pWindow = pEvent->GetWindow();
+ if ( pWindow )
+ {
+ SystemWindow *pSysWin = pWindow->GetSystemWindow();
+ if ( pSysWin )
+ {
+ AddMenuBarIcon( pSysWin, false );
+ }
+ }
+ }
+ else if ( VCLEVENT_WINDOW_MENUBARREMOVED == nEventID )
+ {
+ SolarMutexGuard aGuard;
+ MenuBar *pMBar = (MenuBar*) pEvent->GetData();
+ if ( pMBar && ( pMBar == mpIconMBar ) )
+ RemoveBubbleWindow( true );
+ }
+ else if ( ( nEventID == VCLEVENT_WINDOW_MOVE ) ||
+ ( nEventID == VCLEVENT_WINDOW_RESIZE ) )
+ {
+ SolarMutexGuard aGuard;
+ if ( ( mpIconSysWin == pEvent->GetWindow() ) &&
+ ( mpBubbleWin != NULL ) && ( mpIconMBar != NULL ) )
+ {
+ Rectangle aIconRect = mpIconMBar->GetMenuBarButtonRectPixel( mnIconID );
+ Point aWinPos = aIconRect.BottomCenter();
+ mpBubbleWin->SetTipPosPixel( aWinPos );
+ if ( mpBubbleWin->IsVisible() )
+ mpBubbleWin->Show(); // This will recalc the screen positon of the bubble
+ }
+ }
+
+ return 0;
+}
+
+//------------------------------------------------------------------------------
+IMPL_LINK( UpdateCheckUI, ApplicationEventHdl, VclSimpleEvent *, pEvent)
+{
+ switch (pEvent->GetId())
+ {
+ case VCLEVENT_WINDOW_SHOW:
+ case VCLEVENT_WINDOW_ACTIVATE:
+ case VCLEVENT_WINDOW_GETFOCUS: {
+ SolarMutexGuard aGuard;
+
+ Window *pWindow = static_cast< VclWindowEvent * >(pEvent)->GetWindow();
+ if ( pWindow && pWindow->IsTopWindow() )
+ {
+ SystemWindow *pSysWin = pWindow->GetSystemWindow();
+ MenuBar *pMBar = pSysWin->GetMenuBar();
+ if ( pSysWin && pMBar )
+ {
+ AddMenuBarIcon( pSysWin, true );
+ }
+ }
+ break;
+ }
+ }
+ return 0;
+}
+//------------------------------------------------------------------------------
+//------------------------------------------------------------------------------
+//------------------------------------------------------------------------------
+
+#define TIP_HEIGHT 15
+#define TIP_WIDTH 7
+#define TIP_RIGHT_OFFSET 18
+#define BUBBLE_BORDER 10
+#define TEXT_MAX_WIDTH 300
+#define TEXT_MAX_HEIGHT 200
+#define INITIAL_SHOW_TIME 10000
+
+//------------------------------------------------------------------------------
+BubbleWindow::BubbleWindow( Window* pParent, const XubString& rTitle,
+ const XubString& rText, const Image& rImage )
+ : FloatingWindow( pParent, WB_SYSTEMWINDOW
+ | WB_OWNERDRAWDECORATION
+ | WB_NOBORDER
+ )
+ , maBubbleTitle( rTitle )
+ , maBubbleText( rText )
+ , maBubbleImage( rImage )
+ , maMaxTextSize( TEXT_MAX_WIDTH, TEXT_MAX_HEIGHT )
+ , mnTipOffset( 0 )
+{
+ SetBackground( Wallpaper( GetSettings().GetStyleSettings().GetHelpColor() ) );
+}
+
+//------------------------------------------------------------------------------
+BubbleWindow::~BubbleWindow()
+{
+}
+
+//------------------------------------------------------------------------------
+void BubbleWindow::Resize()
+{
+ SolarMutexGuard aGuard;
+
+ FloatingWindow::Resize();
+
+ Size aSize = GetSizePixel();
+
+ if ( ( aSize.Height() < 20 ) || ( aSize.Width() < 60 ) )
+ return;
+
+ Rectangle aRect( 0, TIP_HEIGHT, aSize.Width(), aSize.Height() - TIP_HEIGHT );
+ maRectPoly = Polygon( aRect, 6, 6 );
+ Region aRegion( maRectPoly );
+ long nTipOffset = aSize.Width() - TIP_RIGHT_OFFSET + mnTipOffset;
+
+ Point aPointArr[4];
+ aPointArr[0] = Point( nTipOffset, TIP_HEIGHT );
+ aPointArr[1] = Point( nTipOffset, 0 );
+ aPointArr[2] = Point( nTipOffset + TIP_WIDTH , TIP_HEIGHT );
+ aPointArr[3] = Point( nTipOffset, TIP_HEIGHT );
+ maTriPoly = Polygon( 4, aPointArr );
+ Region aTriRegion( maTriPoly );
+
+ aRegion.Union( aTriRegion);
+ maBounds = aRegion;
+
+ SetWindowRegionPixel( maBounds );
+}
+
+//------------------------------------------------------------------------------
+void BubbleWindow::SetTitleAndText( const XubString& rTitle,
+ const XubString& rText,
+ const Image& rImage )
+{
+ maBubbleTitle = rTitle;
+ maBubbleText = rText;
+ maBubbleImage = rImage;
+
+ Resize();
+}
+
+//------------------------------------------------------------------------------
+void BubbleWindow::Paint( const Rectangle& )
+{
+ SolarMutexGuard aGuard;
+
+ LineInfo aThickLine( LINE_SOLID, 2 );
+
+ DrawPolyLine( maRectPoly, aThickLine );
+ DrawPolyLine( maTriPoly );
+
+ Color aOldLine = GetLineColor();
+ Size aSize = GetSizePixel();
+ long nTipOffset = aSize.Width() - TIP_RIGHT_OFFSET + mnTipOffset;
+
+ SetLineColor( GetSettings().GetStyleSettings().GetHelpColor() );
+ DrawLine( Point( nTipOffset+2, TIP_HEIGHT ),
+ Point( nTipOffset + TIP_WIDTH -1 , TIP_HEIGHT ),
+ aThickLine );
+ SetLineColor( aOldLine );
+
+ //Image aImage = InfoBox::GetStandardImage();
+ Size aImgSize = maBubbleImage.GetSizePixel();
+
+ DrawImage( Point( BUBBLE_BORDER, BUBBLE_BORDER + TIP_HEIGHT ), maBubbleImage );
+
+ Font aOldFont = GetFont();
+ Font aBoldFont = aOldFont;
+ aBoldFont.SetWeight( WEIGHT_BOLD );
+
+ SetFont( aBoldFont );
+ Rectangle aTitleRect = maTitleRect;
+ aTitleRect.Move( aImgSize.Width(), 0 );
+ DrawText( aTitleRect, maBubbleTitle, TEXT_DRAW_MULTILINE | TEXT_DRAW_WORDBREAK );
+
+ SetFont( aOldFont );
+ Rectangle aTextRect = maTextRect;
+ aTextRect.Move( aImgSize.Width(), 0 );
+ DrawText( aTextRect, maBubbleText, TEXT_DRAW_MULTILINE | TEXT_DRAW_WORDBREAK );
+}
+
+//------------------------------------------------------------------------------
+void BubbleWindow::MouseButtonDown( const MouseEvent& )
+{
+ Show( FALSE );
+}
+
+//------------------------------------------------------------------------------
+void BubbleWindow::Show( BOOL bVisible, USHORT nFlags )
+{
+ SolarMutexGuard aGuard;
+
+ if ( !bVisible )
+ {
+ FloatingWindow::Show( bVisible );
+ return;
+ }
+
+ // don't show bubbles without a text
+ if ( ( maBubbleTitle.Len() == 0 ) && ( maBubbleText.Len() == 0 ) )
+ return;
+
+ Size aWindowSize = GetSizePixel();
+
+ // Image aImage = InfoBox::GetStandardImage();
+ Size aImgSize = maBubbleImage.GetSizePixel();
+
+ RecalcTextRects();
+
+ aWindowSize.setHeight( maTitleRect.GetHeight() * 7 / 4+ maTextRect.GetHeight() +
+ 3 * BUBBLE_BORDER + TIP_HEIGHT );
+
+ if ( maTitleRect.GetWidth() > maTextRect.GetWidth() )
+ aWindowSize.setWidth( maTitleRect.GetWidth() );
+ else
+ aWindowSize.setWidth( maTextRect.GetWidth() );
+
+ aWindowSize.setWidth( aWindowSize.Width() + 3 * BUBBLE_BORDER + aImgSize.Width() );
+
+ if ( aWindowSize.Height() < aImgSize.Height() + TIP_HEIGHT + 2 * BUBBLE_BORDER )
+ aWindowSize.setHeight( aImgSize.Height() + TIP_HEIGHT + 2 * BUBBLE_BORDER );
+
+ Point aPos;
+ aPos.X() = maTipPos.X() - aWindowSize.Width() + TIP_RIGHT_OFFSET;
+ aPos.Y() = maTipPos.Y();
+ Point aScreenPos = GetParent()->OutputToAbsoluteScreenPixel( aPos );
+ if ( aScreenPos.X() < 0 )
+ {
+ mnTipOffset = aScreenPos.X();
+ aPos.X() -= mnTipOffset;
+ }
+ SetPosSizePixel( aPos, aWindowSize );
+
+ FloatingWindow::Show( bVisible, nFlags );
+}
+
+//------------------------------------------------------------------------------
+void BubbleWindow::RecalcTextRects()
+{
+ Size aTotalSize;
+ BOOL bFinished = FALSE;
+ Font aOldFont = GetFont();
+ Font aBoldFont = aOldFont;
+
+ aBoldFont.SetWeight( WEIGHT_BOLD );
+
+ while ( !bFinished )
+ {
+ SetFont( aBoldFont );
+
+ maTitleRect = GetTextRect( Rectangle( Point( 0, 0 ), maMaxTextSize ),
+ maBubbleTitle,
+ TEXT_DRAW_MULTILINE | TEXT_DRAW_WORDBREAK );
+
+ SetFont( aOldFont );
+ maTextRect = GetTextRect( Rectangle( Point( 0, 0 ), maMaxTextSize ),
+ maBubbleText,
+ TEXT_DRAW_MULTILINE | TEXT_DRAW_WORDBREAK );
+
+ if ( maTextRect.GetHeight() < 10 )
+ maTextRect.setHeight( 10 );
+
+ aTotalSize.setHeight( maTitleRect.GetHeight() +
+ aBoldFont.GetHeight() * 3 / 4 +
+ maTextRect.GetHeight() +
+ 3 * BUBBLE_BORDER + TIP_HEIGHT );
+ if ( aTotalSize.Height() > maMaxTextSize.Height() )
+ {
+ maMaxTextSize.Width() = maMaxTextSize.Width() * 3 / 2;
+ maMaxTextSize.Height() = maMaxTextSize.Height() * 3 / 2;
+ }
+ else
+ bFinished = TRUE;
+ }
+ maTitleRect.Move( 2*BUBBLE_BORDER, BUBBLE_BORDER + TIP_HEIGHT );
+ maTextRect.Move( 2*BUBBLE_BORDER, BUBBLE_BORDER + TIP_HEIGHT + maTitleRect.GetHeight() + aBoldFont.GetHeight() * 3 / 4 );
+}
+//------------------------------------------------------------------------------
+//------------------------------------------------------------------------------
+//------------------------------------------------------------------------------
+
+} // anonymous namespace
+
+//------------------------------------------------------------------------------
+
+static uno::Reference<uno::XInterface> SAL_CALL
+createInstance(const uno::Reference<uno::XComponentContext>& xContext)
+{
+ return *new UpdateCheckUI(xContext);
+}
+
+//------------------------------------------------------------------------------
+
+static const cppu::ImplementationEntry kImplementations_entries[] =
+{
+ {
+ createInstance,
+ getImplementationName,
+ getServiceNames,
+ cppu::createSingleComponentFactory,
+ NULL,
+ 0
+ },
+ { NULL, NULL, NULL, NULL, NULL, 0 }
+} ;
+
+//------------------------------------------------------------------------------
+
+extern "C" void SAL_CALL
+component_getImplementationEnvironment( const sal_Char **aEnvTypeName, uno_Environment **)
+{
+ *aEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME ;
+}
+
+//------------------------------------------------------------------------------
+
+extern "C" sal_Bool SAL_CALL
+component_writeInfo(void *pServiceManager, void *pRegistryKey)
+{
+ return cppu::component_writeInfoHelper(
+ pServiceManager,
+ pRegistryKey,
+ kImplementations_entries
+ );
+}
+
+//------------------------------------------------------------------------------
+
+extern "C" void *
+component_getFactory(const sal_Char *pszImplementationName, void *pServiceManager, void *pRegistryKey)
+{
+ return cppu::component_getFactoryHelper(
+ pszImplementationName,
+ pServiceManager,
+ pRegistryKey,
+ kImplementations_entries) ;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/update/ui/updatecheckui.hrc b/extensions/source/update/ui/updatecheckui.hrc
new file mode 100644
index 000000000000..3b451fa99d77
--- /dev/null
+++ b/extensions/source/update/ui/updatecheckui.hrc
@@ -0,0 +1,36 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+ #define RID_UPDATECHECKUI_START 1100
+
+ #define RID_UPDATE_AVAIL_IMAGES RID_UPDATECHECKUI_START + 1
+
+ #define RID_UPDATE_AVAILABLE_16 RID_UPDATECHECKUI_START + 1
+ #define RID_UPDATE_AVAILABLE_26 RID_UPDATECHECKUI_START + 2
+ #define RID_UPDATE_AVAILABLE_16_HC RID_UPDATECHECKUI_START + 3
+ #define RID_UPDATE_AVAILABLE_26_HC RID_UPDATECHECKUI_START + 4
+
diff --git a/extensions/source/update/ui/updatecheckui.src b/extensions/source/update/ui/updatecheckui.src
new file mode 100644
index 000000000000..813e3e19b9e2
--- /dev/null
+++ b/extensions/source/update/ui/updatecheckui.src
@@ -0,0 +1,51 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "updatecheckui.hrc"
+
+#define STD_MASK_COLOR MaskColor = Color { Red = 0xFFFF; Green = 0x0000; Blue = 0xFFFF; };
+
+ Image RID_UPDATE_AVAILABLE_16
+ {
+ ImageBitmap = Bitmap{ file = "onlineupdate_16.png"; };
+ STD_MASK_COLOR
+ };
+ Image RID_UPDATE_AVAILABLE_26
+ {
+ ImageBitmap = Bitmap{ file = "onlineupdate_26.png"; };
+ STD_MASK_COLOR
+ };
+ Image RID_UPDATE_AVAILABLE_16_HC
+ {
+ ImageBitmap = Bitmap{ file = "onlineupdate_16_h.png"; };
+ STD_MASK_COLOR
+ };
+ Image RID_UPDATE_AVAILABLE_26_HC
+ {
+ ImageBitmap = Bitmap{ file = "onlineupdate_26_h.png"; };
+ STD_MASK_COLOR
+ };
diff --git a/extensions/source/update/ui/updchkui.xml b/extensions/source/update/ui/updchkui.xml
new file mode 100644
index 000000000000..6c7625ad3358
--- /dev/null
+++ b/extensions/source/update/ui/updchkui.xml
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE module-description PUBLIC "-//StarOffice//DTD ComponentDescription 1.0//EN" "module-description.dtd">
+<module-description xmlns:xlink="http://www.w3.org/1999/xlink">
+ <module-name>updchkui</module-name>
+ <component-description>
+ <author> Oliver Braun </author>
+ <name>vnd.sun.UpdateCheck</name>
+ <description> The </description>
+ <loader-name>com.sun.star.loader.SharedLibrary</loader-name>
+ <language>c++</language>
+ <status value="beta"/>
+ <supported-service>com.sun.star.setup.UpdateCheckUI</supported-service>
+ <service-dependency>...</service-dependency>
+ <type>com.sun.star.document.XEventBroadcaster</type>
+ <type>com.sun.star.document.XEventListener</type>
+ <type>com.sun.star.lang.XEventListener</type>
+ <type>com.sun.star.lang.XMultiComponentFactory</type>
+ <type>com.sun.star.lang.XServiceInfo</type>
+ <type>com.sun.star.lang.XSingleComponentFactory</type>
+ <type>com.sun.star.lang.XTypeProvider</type>
+ <type>com.sun.star.uno.TypeClass</type>
+ <type>com.sun.star.uno.XAggregation</type>
+ <type>com.sun.star.uno.XComponentContext</type>
+ <type>com.sun.star.uno.XCurrentContext</type>
+ <type>com.sun.star.uno.XWeak</type>
+ <type>com.sun.star.registry.XRegistryKey</type>
+ </component-description>
+ <project-build-dependency>cppuhelper</project-build-dependency>
+ <project-build-dependency>cppu</project-build-dependency>
+ <project-build-dependency>sal</project-build-dependency>
+ <runtime-module-dependency>cppuhelper3$(COM)</runtime-module-dependency>
+ <runtime-module-dependency>cppu3</runtime-module-dependency>
+ <runtime-module-dependency>sal3</runtime-module-dependency>
+</module-description>
diff --git a/extensions/source/xmlextract/makefile.mk b/extensions/source/xmlextract/makefile.mk
new file mode 100644
index 000000000000..0a021027f4b4
--- /dev/null
+++ b/extensions/source/xmlextract/makefile.mk
@@ -0,0 +1,65 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ=..$/..
+PRJNAME=extensions
+TARGET=xmx
+
+ENABLE_EXCEPTIONS=TRUE
+USE_DEFFILE=TRUE
+
+# --- Settings ----------------------------------
+
+.INCLUDE : $(PRJ)$/util$/makefile.pmk
+
+# --- Files -------------------------------------
+
+SLOFILES= $(SLO)$/xmxuno.obj \
+ $(SLO)$/xmxtrct.obj
+
+# --- Library -----------------------------------
+
+SHL1TARGET=$(TARGET)$(DLLPOSTFIX)
+SHL1IMPLIB= i$(SHL1TARGET)
+
+SHL1VERSIONMAP=$(SOLARENV)/src/component.map
+SHL1DEF=$(MISC)$/$(SHL1TARGET).def
+DEF1NAME=$(SHL1TARGET)
+
+SHL1STDLIBS=\
+ $(SOTLIB) \
+ $(UNOTOOLSLIB) \
+ $(TOOLSLIB) \
+ $(CPPUHELPERLIB) \
+ $(CPPULIB) \
+ $(SALLIB)
+
+SHL1LIBS= $(SLB)$/$(TARGET).lib
+
+# --- Targets ----------------------------------
+
+.INCLUDE : target.mk
diff --git a/extensions/source/xmlextract/xmxcom.hxx b/extensions/source/xmlextract/xmxcom.hxx
new file mode 100644
index 000000000000..a3ce42f843c9
--- /dev/null
+++ b/extensions/source/xmlextract/xmxcom.hxx
@@ -0,0 +1,66 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _XMXCOM_HXX
+#define _XMXCOM_HXX
+
+#include <cppuhelper/weak.hxx>
+#include <rtl/ustring.hxx>
+#include <tools/debug.hxx>
+#include <tools/stream.hxx>
+#include <tools/string.hxx>
+#include <tools/urlobj.hxx>
+#include <cppuhelper/implbase1.hxx>
+
+#include <com/sun/star/uno/Reference.h>
+#include <com/sun/star/uno/RuntimeException.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/lang/XComponent.hpp>
+#include <com/sun/star/registry/XRegistryKey.hpp>
+#include <com/sun/star/lang/XComponent.hpp>
+#include <com/sun/star/io/XInputStream.hpp>
+#include <com/sun/star/io/XXMLExtractor.hpp>
+
+// -----------------------------------------------------------------------------
+
+#define NMSP_CPPU ::cppu
+#define NMSP_RTL ::rtl
+#define NMSP_UNO ::com::sun::star::uno
+#define NMSP_LANG ::com::sun::star::lang
+#define NMSP_IO ::com::sun::star::io
+#define NMSP_REGISTRY ::com::sun::star::registry
+
+
+#define REF( _def_Obj ) NMSP_UNO::Reference< _def_Obj >
+#define SEQ( _def_Obj ) NMSP_UNO::Sequence< _def_Obj >
+#define ANY NMSP_UNO::Any
+#define B2UCONST( _def_pChar ) (NMSP_RTL::OUString(RTL_CONSTASCII_USTRINGPARAM(_def_pChar )))
+
+#endif // _XMXCOM_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/xmlextract/xmxtrct.cxx b/extensions/source/xmlextract/xmxtrct.cxx
new file mode 100644
index 000000000000..7a5b1a87a574
--- /dev/null
+++ b/extensions/source/xmlextract/xmxtrct.cxx
@@ -0,0 +1,200 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+
+#include "xmxtrct.hxx"
+
+#include <rtl/memory.h>
+#include <tools/zcodec.hxx>
+#include <unotools/streamhelper.hxx>
+#include <sot/storage.hxx>
+
+// ----------------
+// - XMXLockBytes -
+// ----------------
+
+class XMXLockBytes : public SvLockBytes
+{
+ REF( NMSP_IO::XInputStream ) mxIStm;
+ SEQ( sal_Int8 ) maSeq;
+
+ XMXLockBytes();
+
+public:
+
+ XMXLockBytes( const REF( NMSP_IO::XInputStream )& rxIStm );
+ virtual ~XMXLockBytes();
+
+ virtual ErrCode ReadAt( sal_Size nPos, void* pBuffer, sal_Size nCount, sal_Size* pRead ) const;
+ virtual ErrCode WriteAt( sal_Size nPos, const void* pBuffer, sal_Size nCount, sal_Size* pWritten );
+ virtual ErrCode Flush() const;
+ virtual ErrCode SetSize( sal_Size nSize );
+ virtual ErrCode Stat( SvLockBytesStat*, SvLockBytesStatFlag ) const;
+};
+
+// ------------------------------------------------------------------------
+
+XMXLockBytes::XMXLockBytes( const REF( NMSP_IO::XInputStream )& rxIStm ) :
+ mxIStm( rxIStm )
+{
+ if( mxIStm.is() )
+ {
+ const sal_uInt32 nBytesToRead = 65535;
+ sal_uInt32 nRead;
+
+ do
+ {
+ SEQ( sal_Int8 ) aReadSeq;
+
+ nRead = mxIStm->readSomeBytes( aReadSeq, nBytesToRead );
+
+ if( nRead )
+ {
+ const sal_uInt32 nOldLength = maSeq.getLength();
+ maSeq.realloc( nOldLength + nRead );
+ rtl_copyMemory( maSeq.getArray() + nOldLength, aReadSeq.getConstArray(), aReadSeq.getLength() );
+ }
+ }
+ while( nBytesToRead == nRead );
+ }
+}
+
+// ------------------------------------------------------------------------
+
+XMXLockBytes::~XMXLockBytes()
+{
+}
+
+// ------------------------------------------------------------------------
+
+ErrCode XMXLockBytes::ReadAt( sal_Size nPos, void* pBuffer, sal_Size nCount, sal_Size* pRead ) const
+{
+ const sal_Size nSeqLen = maSeq.getLength();
+ ErrCode nErr = ERRCODE_NONE;
+
+ if( nPos < nSeqLen )
+ {
+ if( ( nPos + nCount ) > nSeqLen )
+ nCount = nSeqLen - nPos;
+
+ rtl_copyMemory( pBuffer, maSeq.getConstArray() + nPos, nCount );
+ *pRead = nCount;
+ }
+ else
+ *pRead = 0UL;
+
+ return nErr;
+}
+
+// ------------------------------------------------------------------------
+
+ErrCode XMXLockBytes::WriteAt( sal_Size /*nPos*/, const void* /*pBuffer*/, sal_Size /*nCount*/, sal_Size* /*pWritten*/ )
+{
+ return ERRCODE_IO_CANTWRITE;
+}
+
+// ------------------------------------------------------------------------
+
+ErrCode XMXLockBytes::Flush() const
+{
+ return ERRCODE_NONE;
+}
+
+// ------------------------------------------------------------------------
+
+ErrCode XMXLockBytes::SetSize( sal_Size /*nSize*/ )
+{
+ return ERRCODE_IO_CANTWRITE;
+}
+
+// ------------------------------------------------------------------------
+
+ErrCode XMXLockBytes::Stat( SvLockBytesStat* pStat, SvLockBytesStatFlag /*eFlag*/ ) const
+{
+ pStat->nSize = maSeq.getLength();
+ return ERRCODE_NONE;
+}
+
+// ----------------
+// - XMLExtractor -
+// ----------------
+
+XMLExtractor::XMLExtractor( const REF( NMSP_LANG::XMultiServiceFactory )& rxMgr ) :
+ mxFact( rxMgr )
+{
+}
+
+// -----------------------------------------------------------------------------
+
+XMLExtractor::~XMLExtractor()
+{
+}
+
+// -----------------------------------------------------------------------------
+
+REF( NMSP_IO::XInputStream ) SAL_CALL XMLExtractor::extract( const REF( NMSP_IO::XInputStream )& rxIStm ) throw( NMSP_UNO::RuntimeException )
+{
+ REF( NMSP_IO::XInputStream ) xRet;
+
+ if( rxIStm.is() )
+ {
+ SvStream aIStm( new XMXLockBytes( rxIStm ) );
+ SvStorageRef aStorage( new SvStorage( aIStm ) );
+ String aStmName;
+ const String aFormat1( String::CreateFromAscii( "XMLFormat" ) );
+ const String aFormat2( String::CreateFromAscii( "XMLFormat2" ) );
+
+ if( aStorage->IsContained( aFormat2 ) )
+ aStmName = aFormat2;
+ else if( aStorage->IsContained( aFormat1 ) )
+ aStmName = aFormat1;
+
+ if( !aStorage->GetError() && aStmName.Len() && aStorage->IsStream( aStmName ) )
+ {
+ SvStorageStreamRef xStream( aStorage->OpenSotStream( aStmName ) );
+
+ if( xStream.Is() )
+ {
+ SvMemoryStream* pMemStm = new SvMemoryStream( 65535, 65535 );
+ ZCodec aCodec;
+
+ aCodec.BeginCompression( ZCODEC_BEST_COMPRESSION );
+ aCodec.Decompress( *xStream, *pMemStm );
+ aCodec.EndCompression();
+
+ xRet = new ::utl::OInputStreamHelper( new SvLockBytes( pMemStm, TRUE ), 65535 );
+ }
+ }
+ }
+
+ return xRet;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/xmlextract/xmxtrct.hxx b/extensions/source/xmlextract/xmxtrct.hxx
new file mode 100644
index 000000000000..8b972530bd98
--- /dev/null
+++ b/extensions/source/xmlextract/xmxtrct.hxx
@@ -0,0 +1,57 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _XMXTRCT_HXX
+#define _XMXTRCT_HXX
+
+#include "xmxcom.hxx"
+
+// ----------------
+// - XMLExtractor -
+// ----------------
+
+class XMLExtractor : public ::cppu::WeakImplHelper1< NMSP_IO::XXMLExtractor >
+{
+private:
+
+ REF( NMSP_LANG::XMultiServiceFactory ) mxFact;
+
+ XMLExtractor();
+
+public:
+
+ XMLExtractor( const REF( NMSP_LANG::XMultiServiceFactory )& rxMgr );
+ virtual ~XMLExtractor();
+
+ // XXMLExtractor
+ virtual REF( NMSP_IO::XInputStream ) SAL_CALL extract( const REF( NMSP_IO::XInputStream )& rxIStm ) throw( NMSP_UNO::RuntimeException );
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/xmlextract/xmxuno.cxx b/extensions/source/xmlextract/xmxuno.cxx
new file mode 100644
index 000000000000..ac28ccc7e1ad
--- /dev/null
+++ b/extensions/source/xmlextract/xmxuno.cxx
@@ -0,0 +1,103 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+
+#include "xmxcom.hxx"
+#include "xmxtrct.hxx"
+#include <osl/diagnose.h>
+#include <cppuhelper/factory.hxx>
+#include <uno/mapping.hxx>
+
+// -------------------
+// - factory methods -
+// -------------------
+
+static REF( NMSP_UNO::XInterface ) SAL_CALL create_XMLExtractor( const REF( NMSP_LANG::XMultiServiceFactory )& rxFact )
+{
+ return REF( NMSP_UNO::XInterface )( *new XMLExtractor( rxFact ) );
+}
+
+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
+ {
+ REF( NMSP_REGISTRY::XRegistryKey ) xNewKey(
+ reinterpret_cast< NMSP_REGISTRY::XRegistryKey * >( pRegistryKey )->createKey(
+ NMSP_RTL::OUString( RTL_CONSTASCII_USTRINGPARAM("/com.sun.star.comp.io.XMLExtractor/UNO/SERVICES/com.sun.star.io.XMLExtractor") ) ) );
+
+ return sal_True;
+ }
+ catch (NMSP_REGISTRY::InvalidRegistryException &)
+ {
+ OSL_ENSURE( 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, "com.sun.star.comp.io.XMLExtractor" ) == 0)
+ {
+ NMSP_RTL::OUString aServiceName( B2UCONST( "com.sum.star.io.XMLExtractor" ) );
+
+ REF( NMSP_LANG::XSingleServiceFactory ) xFactory( NMSP_CPPU::createSingleFactory(
+ reinterpret_cast< NMSP_LANG::XMultiServiceFactory * >( pServiceManager ),
+ NMSP_RTL::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.io.XMLExtractor") ),
+ create_XMLExtractor,
+ SEQ( NMSP_RTL::OUString )( &aServiceName, 1 ) ) );
+
+ if (xFactory.is())
+ {
+ xFactory->acquire();
+ pRet = xFactory.get();
+ }
+ }
+
+ return pRet;
+}
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/stardiv/fontest/fontest.idl b/extensions/stardiv/fontest/fontest.idl
new file mode 100644
index 000000000000..85d8916199dc
--- /dev/null
+++ b/extensions/stardiv/fontest/fontest.idl
@@ -0,0 +1,111 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef _EXTENSIONS_FONTEST_IDL
+#define _EXTENSIONS_FONTEST_IDL
+
+
+#include <uno/intrface.idl>
+#include <stardiv/uno/beans/propset.idl>
+#include <stardiv/uno/lang/ulexcp.idl>
+
+module stardiv
+{
+
+ module extensions
+ {
+
+ module fontest
+ {
+
+/** a flag called "surpressed" changes the action of check and checkWithDialog
+ @author Berndt Reinhold
+ @see stardiv::uno::XInterface
+ */
+ [ uik(BF6D5A72-B53B-11d2-A17B00A0-243D2A0B), ident("FonTest", 1.0) ]
+ interface XFonTest: stardiv::uno::XInterface
+ {
+ /** Checks if "StarMath" and "StarBats" fonts are installed.
+ <P>
+ @param bForce: If TRUE check the fonts even if surpressed.
+ Otherwise check the fonts only if not surpressed.
+ @see resetSurpressed
+ @returns TRUE if the fonts are available. Also TRUE if surpressed
+ is TRUE and bForce is FALSE. Otherwise return FALSE.
+ </P>
+ */
+ boolean check([in] boolean bForce);
+
+ /** Same as check but additional shows a dialog if result is FALSE.
+ <P>
+ @param bForce: same as in check
+ @see check
+ @see resetSurpressed
+ </P>
+ */
+ boolean checkWithDialog([in] boolean bForce);
+
+ /** Shows a dialog if the font "StarBats" or "StarMath" is missing.
+ <P>
+ The dialog shows which font(s) is/are missing and have a checkbox,
+ that represents the state of the flag surpressed. This dialog is
+ the only way to set the flag surpressed to TRUE. This method is
+ not affected by the value of the flag surpressed.
+ @see resetSurpressed
+ </P>
+ */
+ boolean executeDialog();
+
+ /** Set flag surpressed to FALSE
+ <P>
+ The flag surpressed is stored in the registry. If surpressed is
+ FALSE the methods check and checkWithDialog ignores the parameter
+ bForce. if surpressed is TRUE check and checkWithDialog only
+ perform any action if their parameter bForce is TRUE. otherwise
+ they simply return TRUE.
+ </P>
+ */
+ void resetSurpressed();
+ };
+
+/*-------------- services -------------------------------------------
+ This service is the implementation of the interface XFonTest.
+ @version 1.0
+ @author Berndt Reinhold
+ */
+
+ service FonTestService
+ {
+ interface XFonTest;
+ };
+
+//-------------------------------------------------------------------
+
+ }; // fontest
+ }; // extensions
+}; // stardiv
+
+#endif
diff --git a/extensions/stardiv/fontest/makefile.mk b/extensions/stardiv/fontest/makefile.mk
new file mode 100644
index 000000000000..3ea8d98cfc87
--- /dev/null
+++ b/extensions/stardiv/fontest/makefile.mk
@@ -0,0 +1,48 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+prjpch=
+
+PRJ=..$/..
+
+PRJNAME=extensions
+TARGET=fontestidl
+IDLMAP=stardiv$/usrmap.idl
+PACKAGE=stardiv$/fontest
+ENABLE_EXCEPTIONS=TRUE
+
+
+# --- Settings -----------------------------------------------------
+.INCLUDE : $(PRJ)$/util$/makefile.pmk
+
+# ------------------------------------------------------------------
+IDLFILES= fontest.idl
+
+# ------------------------------------------------------------------
+.INCLUDE : target.mk
+.INCLUDE : $(PRJ)$/util$/target.pmk
+
diff --git a/extensions/stardiv/oinstchk/makefile.mk b/extensions/stardiv/oinstchk/makefile.mk
new file mode 100644
index 000000000000..ea496166956c
--- /dev/null
+++ b/extensions/stardiv/oinstchk/makefile.mk
@@ -0,0 +1,47 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+prjpch=
+
+PRJ=..$/..
+
+PRJNAME=extensions
+TARGET=oinstchkidl
+IDLMAP=stardiv$/usrmap.idl
+PACKAGE=stardiv$/oinstchk
+ENABLE_EXCEPTIONS=TRUE
+
+
+# --- Settings -----------------------------------------------------
+.INCLUDE : $(PRJ)$/util$/makefile.pmk
+
+# ------------------------------------------------------------------
+IDLFILES= oinstchk.idl
+
+# ------------------------------------------------------------------
+.INCLUDE : target.mk
+.INCLUDE : $(PRJ)$/util$/target.pmk
diff --git a/extensions/stardiv/oinstchk/oinstchk.idl b/extensions/stardiv/oinstchk/oinstchk.idl
new file mode 100644
index 000000000000..5c1a3b159cdf
--- /dev/null
+++ b/extensions/stardiv/oinstchk/oinstchk.idl
@@ -0,0 +1,108 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef _INSTALLATION_OINSTCHK_IDL
+#define _INSTALLATION_OINSTCHK_IDL
+
+
+#include <uno/intrface.idl>
+#include <stardiv/uno/beans/propset.idl>
+#include <stardiv/uno/lang/ulexcp.idl>
+
+module stardiv
+{
+
+ module installation
+ {
+
+/** a flag called "surpressed" changes the action of check and checkWithDialog
+ @author Berndt Reinhold
+ @see stardiv::uno::XInterface
+ */
+
+ [ uik(BF6D5A72-B53B-11d2-A17B00A0-243D2A0B), ident("OInstChk", 1.0) ]
+ interface XOInstChk: stardiv::uno::XInterface
+ {
+ /** Checks if "StarMath" and "StarBats" fonts are installed.
+ <P>
+ @param bForce: If TRUE check the fonts even if surpressed.
+ Otherwise check the fonts only if not surpressed.
+ @see resetSurpressed
+ @returns TRUE if the fonts are available. Also TRUE if surpressed
+ is TRUE and bForce is FALSE. Otherwise return FALSE.
+ </P>
+ */
+ boolean check([in] boolean bForce);
+
+ /** Same as check but additional shows a dialog if result is FALSE.
+ <P>
+ @param bForce: same as in check
+ @see check
+ @see resetSurpressed
+ </P>
+ */
+ boolean checkWithDialog([in] boolean bForce);
+
+ /** Shows a dialog if the font "StarBats" or "StarMath" is missing.
+ <P>
+ The dialog shows which font(s) is/are missing and have a checkbox,
+ that represents the state of the flag surpressed. This dialog is
+ the only way to set the flag surpressed to TRUE. This method is
+ not affected by the value of the flag surpressed.
+ @see resetSurpressed
+ </P>
+ */
+ boolean executeDialog();
+
+ /** Set flag surpressed to FALSE
+ <P>
+ The flag surpressed is stored in the registry. If surpressed is
+ FALSE the methods check and checkWithDialog ignores the parameter
+ bForce. if surpressed is TRUE check and checkWithDialog only
+ perform any action if their parameter bForce is TRUE. otherwise
+ they simply return TRUE.
+ </P>
+ */
+ void resetSurpressed();
+ };
+
+/*-------------- services -------------------------------------------
+ This service is the implementation of the interface XOInstChk.
+ @version 1.0
+ @author Berndt Reinhold
+ */
+
+ service OInstChkService
+ {
+ interface XOInstChk;
+ };
+
+//-------------------------------------------------------------------
+
+ }; // installation
+}; // stardiv
+
+#endif
diff --git a/extensions/stardiv/pgp/makefile.mk b/extensions/stardiv/pgp/makefile.mk
new file mode 100644
index 000000000000..dbce7d52b388
--- /dev/null
+++ b/extensions/stardiv/pgp/makefile.mk
@@ -0,0 +1,53 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+prjpch=
+
+PRJ=..$/..
+
+PRJNAME=extensions
+TARGET=pgpidl
+IDLMAP=stardiv$/usrmap.idl
+PACKAGE=stardiv$/extensions$/pgp
+ENABLE_EXCEPTIONS=TRUE
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : $(PRJ)$/util$/makefile.pmk
+
+#javauno=
+
+# --- Files --------------------------------------------------------
+
+JARFILES+= usr.jar
+IDLFILES= pgp.idl
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : target.mk
+.INCLUDE : $(PRJ)$/util$/target.pmk
+
diff --git a/extensions/test/ole/AxTestComponents/AxTestComponents.cpp b/extensions/test/ole/AxTestComponents/AxTestComponents.cpp
new file mode 100644
index 000000000000..7d82204aa917
--- /dev/null
+++ b/extensions/test/ole/AxTestComponents/AxTestComponents.cpp
@@ -0,0 +1,101 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+
+// Note: Proxy/Stub Information
+// To build a separate proxy/stub DLL,
+// run nmake -f AxTestComponentsps.mk in the project directory.
+
+#include "stdafx.h"
+#include "resource.h"
+#include <initguid.h>
+
+#include "Basic.h"
+#include "Foo.h"
+
+
+CComModule _Module;
+
+BEGIN_OBJECT_MAP(ObjectMap)
+OBJECT_ENTRY(CLSID_Basic, CBasic)
+OBJECT_ENTRY(CLSID_Foo, CFoo)
+END_OBJECT_MAP()
+
+/////////////////////////////////////////////////////////////////////////////
+// DLL Entry Point
+
+extern "C"
+BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/)
+{
+ if (dwReason == DLL_PROCESS_ATTACH)
+ {
+ _Module.Init(ObjectMap, hInstance, &LIBID_AXTESTCOMPONENTSLib);
+ DisableThreadLibraryCalls(hInstance);
+ }
+ else if (dwReason == DLL_PROCESS_DETACH)
+ _Module.Term();
+ return TRUE; // ok
+}
+
+/////////////////////////////////////////////////////////////////////////////
+// Used to determine whether the DLL can be unloaded by OLE
+
+STDAPI DllCanUnloadNow(void)
+{
+ return (_Module.GetLockCount()==0) ? S_OK : S_FALSE;
+}
+
+/////////////////////////////////////////////////////////////////////////////
+// Returns a class factory to create an object of the requested type
+
+STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv)
+{
+ return _Module.GetClassObject(rclsid, riid, ppv);
+}
+
+/////////////////////////////////////////////////////////////////////////////
+// DllRegisterServer - Adds entries to the system registry
+
+STDAPI DllRegisterServer(void)
+{
+ // registers object, typelib and all interfaces in typelib
+ return _Module.RegisterServer(TRUE);
+}
+
+/////////////////////////////////////////////////////////////////////////////
+// DllUnregisterServer - Removes entries from the system registry
+
+STDAPI DllUnregisterServer(void)
+{
+ return _Module.UnregisterServer(TRUE);
+}
+
+
+//VT_I4 size_t V_ERROR VARIANT VARIANT_FALSE CComVariant FADF_EMBEDDED
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/test/ole/AxTestComponents/AxTestComponents.def b/extensions/test/ole/AxTestComponents/AxTestComponents.def
new file mode 100644
index 000000000000..5d8c019adefc
--- /dev/null
+++ b/extensions/test/ole/AxTestComponents/AxTestComponents.def
@@ -0,0 +1,9 @@
+; AxTestComponents.def : Declares the module parameters.
+
+LIBRARY "AxTestComponents.DLL"
+
+EXPORTS
+ DllCanUnloadNow PRIVATE
+ DllGetClassObject PRIVATE
+ DllRegisterServer PRIVATE
+ DllUnregisterServer PRIVATE
diff --git a/extensions/test/ole/AxTestComponents/AxTestComponents.dsp b/extensions/test/ole/AxTestComponents/AxTestComponents.dsp
new file mode 100644
index 000000000000..43fbbe53d344
--- /dev/null
+++ b/extensions/test/ole/AxTestComponents/AxTestComponents.dsp
@@ -0,0 +1,325 @@
+# Microsoft Developer Studio Project File - Name="AxTestComponents" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
+
+CFG=AxTestComponents - Win32 Debug
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE
+!MESSAGE NMAKE /f "AxTestComponents.mak".
+!MESSAGE
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE
+!MESSAGE NMAKE /f "AxTestComponents.mak" CFG="AxTestComponents - Win32 Debug"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "AxTestComponents - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE "AxTestComponents - Win32 Unicode Debug" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE "AxTestComponents - Win32 Release MinSize" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE "AxTestComponents - Win32 Release MinDependency" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE "AxTestComponents - Win32 Unicode Release MinSize" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE "AxTestComponents - Win32 Unicode Release MinDependency" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=cl.exe
+MTL=midl.exe
+RSC=rc.exe
+
+!IF "$(CFG)" == "AxTestComponents - Win32 Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "Debug"
+# PROP BASE Intermediate_Dir "Debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "Debug"
+# PROP Intermediate_Dir "Debug"
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MTd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /Yu"stdafx.h" /FD /GZ /c
+# ADD CPP /nologo /MTd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /FR /Yu"stdafx.h" /FD /GZ /c
+# ADD BASE RSC /l 0x409 /d "_DEBUG"
+# ADD RSC /l 0x409 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386 /pdbtype:sept
+# Begin Custom Build - Performing registration
+OutDir=.\Debug
+TargetPath=.\Debug\AxTestComponents.dll
+InputPath=.\Debug\AxTestComponents.dll
+SOURCE="$(InputPath)"
+
+"$(OutDir)\regsvr32.trg" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ regsvr32 /s /c "$(TargetPath)"
+ echo regsvr32 exec. time > "$(OutDir)\regsvr32.trg"
+
+# End Custom Build
+
+!ELSEIF "$(CFG)" == "AxTestComponents - Win32 Unicode Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "DebugU"
+# PROP BASE Intermediate_Dir "DebugU"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "DebugU"
+# PROP Intermediate_Dir "DebugU"
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MTd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_USRDLL" /D "_UNICODE" /Yu"stdafx.h" /FD /GZ /c
+# ADD CPP /nologo /MTd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_USRDLL" /D "_UNICODE" /Yu"stdafx.h" /FD /GZ /c
+# ADD BASE RSC /l 0x409 /d "_DEBUG"
+# ADD RSC /l 0x409 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386 /pdbtype:sept
+# Begin Custom Build - Performing registration
+OutDir=.\DebugU
+TargetPath=.\DebugU\AxTestComponents.dll
+InputPath=.\DebugU\AxTestComponents.dll
+SOURCE="$(InputPath)"
+
+"$(OutDir)\regsvr32.trg" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ if "%OS%"=="" goto NOTNT
+ if not "%OS%"=="Windows_NT" goto NOTNT
+ regsvr32 /s /c "$(TargetPath)"
+ echo regsvr32 exec. time > "$(OutDir)\regsvr32.trg"
+ goto end
+ :NOTNT
+ echo Warning : Cannot register Unicode DLL on Windows 95
+ :end
+
+# End Custom Build
+
+!ELSEIF "$(CFG)" == "AxTestComponents - Win32 Release MinSize"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "ReleaseMinSize"
+# PROP BASE Intermediate_Dir "ReleaseMinSize"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "ReleaseMinSize"
+# PROP Intermediate_Dir "ReleaseMinSize"
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MT /W3 /O1 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "_ATL_DLL" /D "_ATL_MIN_CRT" /Yu"stdafx.h" /FD /c
+# ADD CPP /nologo /MT /W3 /O1 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "_ATL_DLL" /D "_ATL_MIN_CRT" /Yu"stdafx.h" /FD /c
+# ADD BASE RSC /l 0x409 /d "NDEBUG"
+# ADD RSC /l 0x409 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386
+# Begin Custom Build - Performing registration
+OutDir=.\ReleaseMinSize
+TargetPath=.\ReleaseMinSize\AxTestComponents.dll
+InputPath=.\ReleaseMinSize\AxTestComponents.dll
+SOURCE="$(InputPath)"
+
+"$(OutDir)\regsvr32.trg" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ regsvr32 /s /c "$(TargetPath)"
+ echo regsvr32 exec. time > "$(OutDir)\regsvr32.trg"
+
+# End Custom Build
+
+!ELSEIF "$(CFG)" == "AxTestComponents - Win32 Release MinDependency"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "ReleaseMinDependency"
+# PROP BASE Intermediate_Dir "ReleaseMinDependency"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "ReleaseMinDependency"
+# PROP Intermediate_Dir "ReleaseMinDependency"
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MT /W3 /O1 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "_ATL_STATIC_REGISTRY" /D "_ATL_MIN_CRT" /Yu"stdafx.h" /FD /c
+# ADD CPP /nologo /MT /W3 /O1 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "_ATL_STATIC_REGISTRY" /D "_ATL_MIN_CRT" /Yu"stdafx.h" /FD /c
+# ADD BASE RSC /l 0x409 /d "NDEBUG"
+# ADD RSC /l 0x409 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386
+# Begin Custom Build - Performing registration
+OutDir=.\ReleaseMinDependency
+TargetPath=.\ReleaseMinDependency\AxTestComponents.dll
+InputPath=.\ReleaseMinDependency\AxTestComponents.dll
+SOURCE="$(InputPath)"
+
+"$(OutDir)\regsvr32.trg" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ regsvr32 /s /c "$(TargetPath)"
+ echo regsvr32 exec. time > "$(OutDir)\regsvr32.trg"
+
+# End Custom Build
+
+!ELSEIF "$(CFG)" == "AxTestComponents - Win32 Unicode Release MinSize"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "ReleaseUMinSize"
+# PROP BASE Intermediate_Dir "ReleaseUMinSize"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "ReleaseUMinSize"
+# PROP Intermediate_Dir "ReleaseUMinSize"
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MT /W3 /O1 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_USRDLL" /D "_UNICODE" /D "_ATL_DLL" /D "_ATL_MIN_CRT" /Yu"stdafx.h" /FD /c
+# ADD CPP /nologo /MT /W3 /O1 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_USRDLL" /D "_UNICODE" /D "_ATL_DLL" /D "_ATL_MIN_CRT" /Yu"stdafx.h" /FD /c
+# ADD BASE RSC /l 0x409 /d "NDEBUG"
+# ADD RSC /l 0x409 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386
+# Begin Custom Build - Performing registration
+OutDir=.\ReleaseUMinSize
+TargetPath=.\ReleaseUMinSize\AxTestComponents.dll
+InputPath=.\ReleaseUMinSize\AxTestComponents.dll
+SOURCE="$(InputPath)"
+
+"$(OutDir)\regsvr32.trg" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ if "%OS%"=="" goto NOTNT
+ if not "%OS%"=="Windows_NT" goto NOTNT
+ regsvr32 /s /c "$(TargetPath)"
+ echo regsvr32 exec. time > "$(OutDir)\regsvr32.trg"
+ goto end
+ :NOTNT
+ echo Warning : Cannot register Unicode DLL on Windows 95
+ :end
+
+# End Custom Build
+
+!ELSEIF "$(CFG)" == "AxTestComponents - Win32 Unicode Release MinDependency"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "ReleaseUMinDependency"
+# PROP BASE Intermediate_Dir "ReleaseUMinDependency"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "ReleaseUMinDependency"
+# PROP Intermediate_Dir "ReleaseUMinDependency"
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MT /W3 /O1 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_USRDLL" /D "_UNICODE" /D "_ATL_STATIC_REGISTRY" /D "_ATL_MIN_CRT" /Yu"stdafx.h" /FD /c
+# ADD CPP /nologo /MT /W3 /O1 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_USRDLL" /D "_UNICODE" /D "_ATL_STATIC_REGISTRY" /D "_ATL_MIN_CRT" /Yu"stdafx.h" /FD /c
+# ADD BASE RSC /l 0x409 /d "NDEBUG"
+# ADD RSC /l 0x409 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386
+# Begin Custom Build - Performing registration
+OutDir=.\ReleaseUMinDependency
+TargetPath=.\ReleaseUMinDependency\AxTestComponents.dll
+InputPath=.\ReleaseUMinDependency\AxTestComponents.dll
+SOURCE="$(InputPath)"
+
+"$(OutDir)\regsvr32.trg" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ if "%OS%"=="" goto NOTNT
+ if not "%OS%"=="Windows_NT" goto NOTNT
+ regsvr32 /s /c "$(TargetPath)"
+ echo regsvr32 exec. time > "$(OutDir)\regsvr32.trg"
+ goto end
+ :NOTNT
+ echo Warning : Cannot register Unicode DLL on Windows 95
+ :end
+
+# End Custom Build
+
+!ENDIF
+
+# Begin Target
+
+# Name "AxTestComponents - Win32 Debug"
+# Name "AxTestComponents - Win32 Unicode Debug"
+# Name "AxTestComponents - Win32 Release MinSize"
+# Name "AxTestComponents - Win32 Release MinDependency"
+# Name "AxTestComponents - Win32 Unicode Release MinSize"
+# Name "AxTestComponents - Win32 Unicode Release MinDependency"
+# Begin Group "Source Files"
+
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+# Begin Source File
+
+SOURCE=.\AxTestComponents.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\AxTestComponents.def
+# End Source File
+# Begin Source File
+
+SOURCE=.\AxTestComponents.idl
+# ADD MTL /tlb ".\AxTestComponents.tlb" /h "AxTestComponents.h" /iid "AxTestComponents_i.c" /Oicf
+# End Source File
+# Begin Source File
+
+SOURCE=.\AxTestComponents.rc
+# End Source File
+# Begin Source File
+
+SOURCE=.\Basic.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\StdAfx.cpp
+# ADD CPP /Yc"stdafx.h"
+# End Source File
+# End Group
+# Begin Group "Header Files"
+
+# PROP Default_Filter "h;hpp;hxx;hm;inl"
+# Begin Source File
+
+SOURCE=.\Basic.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\Resource.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\StdAfx.h
+# End Source File
+# End Group
+# Begin Group "Resource Files"
+
+# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
+# Begin Source File
+
+SOURCE=.\Basic.rgs
+# End Source File
+# End Group
+# End Target
+# End Project
+
+
diff --git a/extensions/test/ole/AxTestComponents/AxTestComponents.idl b/extensions/test/ole/AxTestComponents/AxTestComponents.idl
new file mode 100644
index 000000000000..ad8cca5d2928
--- /dev/null
+++ b/extensions/test/ole/AxTestComponents/AxTestComponents.idl
@@ -0,0 +1,257 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+// AxTestComponents.idl : IDL source for AxTestComponents.dll
+//
+
+// This file will be processed by the MIDL tool to
+// produce the type library (AxTestComponents.tlb) and marshalling code.
+// next id 86
+import "oaidl.idl";
+import "ocidl.idl";
+ [
+ object,
+ uuid(BFE10EBD-8584-11D4-8335-005004526AB4),
+ dual,
+ helpstring("IBasic Interface"),
+ pointer_default(unique)
+ ]
+ interface IBasic : IDispatch
+ {
+ [id(82), helpstring("method inBool")] HRESULT inBool([in]VARIANT_BOOL val);
+ [id(1), helpstring("method inByte")] HRESULT inByte([in] unsigned char val);
+ [id(2), helpstring("method inShort")] HRESULT inShort([in] short val);
+ [id(3), helpstring("method inLong")] HRESULT inLong([in] long val);
+ [id(4), helpstring("method inString")] HRESULT inString([in] BSTR val);
+ [id(5), helpstring("method inFloat")] HRESULT inFloat([in] float val);
+ [id(6), helpstring("method inDouble")] HRESULT inDouble([in] double val);
+ [id(7), helpstring("method inVariant")] HRESULT inVariant([in] VARIANT val);
+ [id(8), helpstring("method inArray")] HRESULT inArray([in] SAFEARRAY(VARIANT) val);
+ [id(9), helpstring("method inObject")] HRESULT inObject([in] IDispatch* val);
+ [id(83), helpstring("method inoutBool")] HRESULT inoutBool([in,out]VARIANT_BOOL* val);
+ [id(12), helpstring("method inoutByte")] HRESULT inoutByte([in,out] unsigned char* val);
+ [id(13), helpstring("method inoutShort")] HRESULT inoutShort([in,out] short* val);
+ [id(14), helpstring("method inoutLong")] HRESULT inoutLong([in,out] long * val);
+ [id(15), helpstring("method inoutString")] HRESULT inoutString([in, out] BSTR* val);
+ [id(16), helpstring("method inoutFloat")] HRESULT inoutFloat([in,out] float * val);
+ [id(17), helpstring("method inoutDouble")] HRESULT inoutDouble([in,out] double * val);
+ [id(18), helpstring("method inoutVariant")] HRESULT inoutVariant([in,out] VARIANT * val);
+ [id(19), helpstring("method inoutArray")] HRESULT inoutArray([in,out] SAFEARRAY(VARIANT) * val);
+ [id(20), helpstring("method inoutObject")] HRESULT inoutObject([in,out] IDispatch** val);
+ [id(84), helpstring("method outBool")] HRESULT outBool([out] VARIANT_BOOL* val);
+ [id(23), helpstring("method outByte")] HRESULT outByte([out] unsigned char* val);
+ [id(24), helpstring("method outShort")] HRESULT outShort([out] short* val);
+ [id(25), helpstring("method outLong")] HRESULT outLong([out] long* val);
+ [id(26), helpstring("method outString")] HRESULT outString([out] BSTR* val);
+ [id(27), helpstring("method outFloat")] HRESULT outFloat([out] float* val);
+ [id(28), helpstring("method outDouble")] HRESULT outDouble([out] double* val);
+ [id(29), helpstring("method outVariant")] HRESULT outVariant([out] VARIANT* val);
+ [id(30), helpstring("method outArray")] HRESULT outArray([out] SAFEARRAY(VARIANT) * val);
+ [id(31), helpstring("method outObject")] HRESULT outObject([out] IDispatch** val);
+ [propget, id(85), helpstring("property prpBool")] HRESULT prpBool([out, retval] VARIANT_BOOL *pVal);
+ [propput, id(85), helpstring("property prpBool")] HRESULT prpBool([in] VARIANT_BOOL newVal);
+ [propget, id(34), helpstring("property prpByte")] HRESULT prpByte([out, retval] unsigned char *pVal);
+ [propput, id(34), helpstring("property prpByte")] HRESULT prpByte([in] unsigned char newVal);
+ [propget, id(35), helpstring("property prpShort")] HRESULT prpShort([out, retval] short *pVal);
+ [propput, id(35), helpstring("property prpShort")] HRESULT prpShort([in] short newVal);
+ [propget, id(36), helpstring("property prpLong")] HRESULT prpLong([out, retval] long *pVal);
+ [propput, id(36), helpstring("property prpLong")] HRESULT prpLong([in] long newVal);
+ [propget, id(37), helpstring("property prpString")] HRESULT prpString([out, retval] BSTR *pVal);
+ [propput, id(37), helpstring("property prpString")] HRESULT prpString([in] BSTR newVal);
+ [propget, id(38), helpstring("property prpFloat")] HRESULT prpFloat([out, retval] float *pVal);
+ [propput, id(38), helpstring("property prpFloat")] HRESULT prpFloat([in] float newVal);
+ [propget, id(39), helpstring("property prpDouble")] HRESULT prpDouble([out, retval] double *pVal);
+ [propput, id(39), helpstring("property prpDouble")] HRESULT prpDouble([in] double newVal);
+ [propget, id(40), helpstring("property prpVariant")] HRESULT prpVariant([out, retval] VARIANT *pVal);
+ [propput, id(40), helpstring("property prpVariant")] HRESULT prpVariant([in] VARIANT newVal);
+ [propget, id(41), helpstring("property prpArray")] HRESULT prpArray([out, retval]SAFEARRAY(VARIANT) *pVal);
+ [propput, id(41), helpstring("property prpArray")] HRESULT prpArray([in] SAFEARRAY(VARIANT) newVal);
+ [propget, id(42), helpstring("property prpObject")] HRESULT prpObject([out, retval] IDispatch* *pVal);
+ [propput, id(42), helpstring("property prpObject")] HRESULT prpObject([in] IDispatch* newVal);
+ [id(43), helpstring("method mixed1")] HRESULT mixed1(
+ [in, out] unsigned char* aChar,
+ [in, out] float *aFloat,
+ [in,out] VARIANT* inoutVar);
+ [id(44), helpstring("method inSequenceLong")] HRESULT inSequenceLong([in] SAFEARRAY(long) ar);
+ [id(45), helpstring("method inSequenceByte")] HRESULT inSequenceByte([in] SAFEARRAY(byte) ar);
+ [id(46), helpstring("method inSequenceShort")] HRESULT inSequenceShort([in] SAFEARRAY(short) ar);
+ [id(47), helpstring("method inSequenceString")] HRESULT inSequenceString([in] SAFEARRAY( BSTR) ar);
+ [id(48), helpstring("method inSequenceFloat")] HRESULT inSequenceFloat([in] SAFEARRAY(float) ar);
+ [id(49), helpstring("method inSequenceDouble")] HRESULT inSequenceDouble([in] SAFEARRAY(double) ar);
+ [id(50), helpstring("method inSequenceObject")] HRESULT inSequenceObject([in] SAFEARRAY(IDispatch*) ar);
+ [id(51), helpstring("method outSequenceByte")] HRESULT outSequenceByte([out] SAFEARRAY(unsigned char)* val);
+ [id(52), helpstring("method outSequenceShort")] HRESULT outSequenceShort([out] SAFEARRAY(short)* val);
+ [id(53), helpstring("method outSequenceLong")] HRESULT outSequenceLong([out] SAFEARRAY(long )*val);
+ [id(54), helpstring("method outSequenceString")] HRESULT outSequenceString([out] SAFEARRAY(BSTR)* val);
+ [id(55), helpstring("method outSequenceFloat")] HRESULT outSequenceFloat([out] SAFEARRAY(float)* val);
+ [id(56), helpstring("method outSequenceDouble")] HRESULT outSequenceDouble([out] SAFEARRAY(double)* val);
+ [id(57), helpstring("method outSequenceObject")] HRESULT outSequenceObject([out] SAFEARRAY(IDispatch*)* val);
+ [id(58), helpstring("method inoutSequenceByte")] HRESULT inoutSequenceByte([in,out] SAFEARRAY(unsigned char)* val);
+ [id(59), helpstring("method inoutSequenceShort")] HRESULT inoutSequenceShort([in,out] SAFEARRAY(short)* val);
+ [id(60), helpstring("method inoutSequenceLong")] HRESULT inoutSequenceLong([in,out] SAFEARRAY( long)*val);
+ [id(61), helpstring("method inoutSequenceString")] HRESULT inoutSequenceString([in,out] SAFEARRAY(BSTR)* val);
+ [id(62), helpstring("method inoutSequenceFloat")] HRESULT inoutSequenceFloat([in,out] SAFEARRAY(float)* val);
+ [id(63), helpstring("method inoutSequenceDouble")] HRESULT inoutSequenceDouble([in,out] SAFEARRAY(double)* val);
+ [id(64), helpstring("method inoutSequenceObject")] HRESULT inoutSequenceObject([in,out] SAFEARRAY(IDispatch*)* val);
+ [id(65), helpstring("method inMulDimArrayLong")] HRESULT inMulDimArrayLong([in] SAFEARRAY(long) val );
+ [id(66), helpstring("method inMulDimArrayVariant")] HRESULT inMulDimArrayVariant([in] SAFEARRAY(VARIANT) val);
+ [id(67), helpstring("method inMulDimArrayLong2")] HRESULT inMulDimArrayLong2([in] SAFEARRAY(long) val);
+ [id(68), helpstring("method inMulDimArrayVariant2")] HRESULT inMulDimArrayVariant2([in] SAFEARRAY(VARIANT) val);
+ [id(69), helpstring("method inMulDimArrayByte")] HRESULT inMulDimArrayByte([in] SAFEARRAY(unsigned char) val);
+ [id(70), helpstring("method inMulDimArrayByte2")] HRESULT inMulDimArrayByte2([in] SAFEARRAY(unsigned char) val);
+ [id(71), helpstring("method outMore")] HRESULT outMore([out]long* val1, [out]long* val2);
+
+ [id(72), helpstring("method optional1")]
+ HRESULT optional1([in] long val1, [in, optional] VARIANT* val2);
+ [id(73), helpstring("method optional2")]
+ HRESULT optional2([out] long* val1, [out, optional] VARIANT* val2);
+ [id(74), helpstring("method optional3")]
+ HRESULT optional3([in, optional] VARIANT* val1, [in, optional] VARIANT* val2);
+ [id(75), helpstring("method optional4")]
+ HRESULT optional4([in, out, optional] VARIANT* val1, [in, out, optional] VARIANT* val2);
+ [id(76), helpstring("method optional5")]
+ HRESULT optional5([out, optional] VARIANT* val1, [out, optional] VARIANT* val2);
+ //midl creates for val4 a BSTR "4" as default value in the TLB. The midl complains
+ //but the error message seems to be not for this case.
+ //in defaultvalue2 val4 has an VT_I4 in the TLB. This must be a bug!
+ [id(77), helpstring("method defaultvalue1")]
+ HRESULT defaultvalue1([in, defaultvalue(1)] long val1,
+ [in, defaultvalue(2)] double* val2,
+ // [in, defaultvalue(3)] VARIANT val3, //ok
+ [in, defaultvalue(4)] VARIANT* val4);
+
+ // bug im midl: when val3 and val4 are pointers then the generated header cretates
+ // for all params default values:
+ //HRESULT STDMETHODCALLTYPE defaultvalue2(
+ // /* [defaultvalue][in] */ long *val1 = 10,
+ // /* [defaultvalue][in] */ double *val2 = 3.14,
+ // /* [defaultvalue][in] */ VARIANT *val3 = 10,
+ // /* [defaultvalue][in] */ VARIANT *val4 = 100) = 0;
+ // And that does not compile.
+ //Therefore we must not include the midl generated header, instead use
+ // #import to create the interface header
+ [id(78), helpstring("method defaultvalue2")]
+ HRESULT defaultvalue2([in, out, defaultvalue(1)]long* val1,
+ [in, out, defaultvalue(2)] double* val2,
+ // [in, out, defaultvalue(3)] VARIANT *val3,
+ [in, out, defaultvalue(4)] VARIANT *val4);
+
+ [id(79), helpstring("method varargfunc1"),vararg]
+ HRESULT varargfunc1([in] long val1, [in] SAFEARRAY(VARIANT) val2);
+ [id(80), helpstring("method varargfunc2")]
+ HRESULT varargfunc2([out] long* val1, [out] SAFEARRAY(VARIANT)* val2);
+
+
+ [id(86), helpstring("method inSequenceByteDim2")] HRESULT inSequenceByteDim2([in] SAFEARRAY(byte) val);
+ [id(87), helpstring("method inCurrency")] HRESULT inCurrency([in] CY val);
+ [id(88), helpstring("method outCurrency")] HRESULT outCurrency([out] CY* val);
+ [id(89), helpstring("method inoutCurrency")] HRESULT inoutCurrency([in,out] CY* val);
+ [id(90), helpstring("method inDate")] HRESULT inDate([in] DATE val);
+ [id(91), helpstring("method outDate")] HRESULT outDate([out] DATE* val);
+ [id(92), helpstring("method inoutDate")] HRESULT inoutDate([in,out] DATE* val);
+ [propget, id(93), helpstring("property prpCY")] HRESULT prpCurrency([out, retval] CY* pVal);
+ [propput, id(93), helpstring("property prpCY")] HRESULT prpCurrency([in] CY newVal);
+ [propget, id(94), helpstring("property prpDate")] HRESULT prpDate([out, retval] DATE* pVal);
+ [propput, id(94), helpstring("property prpDate")] HRESULT prpDate([in] DATE newVal);
+ [id(95), helpstring("method inDecimal")] HRESULT inDecimal([in] DECIMAL val);
+ [id(96), helpstring("method outDecimal")] HRESULT outDecimal([out] DECIMAL* val);
+ [id(97), helpstring("method inoutDecimal")] HRESULT inoutDecimal([in,out] DECIMAL* val);
+ [propget, id(98), helpstring("property prpDecimal")] HRESULT prpDecimal([out, retval] DECIMAL* pVal);
+ [propput, id(98), helpstring("property prpDecimal")] HRESULT prpDecimal([in] DECIMAL newVal);
+ [id(99), helpstring("method inSCode")] HRESULT inSCode([in] SCODE val);
+ [id(100), helpstring("method outScode")] HRESULT outScode([out] SCODE* val);
+ [id(101), helpstring("method inoutSCode")] HRESULT inoutSCode([in,out] SCODE* val);
+ [propget, id(102), helpstring("property prpSCode")] HRESULT prpSCode([out, retval] SCODE* pVal);
+ [propput, id(102), helpstring("property prpSCode")] HRESULT prpSCode([in] SCODE newVal);
+ [id(103), helpstring("method inrefLong")] HRESULT inrefLong([in] LONG* val);
+ [id(104), helpstring("method inrefVARIANT")] HRESULT inrefVariant([in] VARIANT* val);
+ [id(105), helpstring("method inrefDecimal")] HRESULT inrefDecimal(DECIMAL* val);
+ [propget, id(106), helpstring("property prpRefLong")] HRESULT prpRefLong([out, retval] long* pVal);
+ [propputref, id(106), helpstring("property prpRefLong")] HRESULT prpRefLong([in] long* newVal);
+ [propget, id(107), helpstring("property prprefVariant")] HRESULT prprefVariant([out, retval] VARIANT* pVal);
+ [propputref, id(107), helpstring("property prprefVariant")] HRESULT prprefVariant([in] VARIANT* newVal);
+ [propget, id(108), helpstring("property prprefDecimal")] HRESULT prprefDecimal([out, retval] DECIMAL* pVal);
+ [propputref, id(108), helpstring("property prprefDecimal")] HRESULT prprefDecimal([in] DECIMAL* newVal);
+ [id(109), helpstring("method optional6")] HRESULT optional6([in,optional] VARIANT* val1,
+ [in,optional] VARIANT * val2, [in,optional] VARIANT* val3, [in,optional] VARIANT* val4);
+ [id(110), helpstring("method optional7")] HRESULT optional7([out,optional] VARIANT* val1,
+ [out,optional] VARIANT * val2, [out,optional] VARIANT* val3, [out,optional] VARIANT* val4);
+
+ [propget, id(111), helpstring("property prpMultiArg1")] HRESULT prpMultiArg1([in,out,optional] VARIANT* val1, [in,out,optional] VARIANT* val2, [out, optional, retval] VARIANT* pVal);
+ [propput, id(111), helpstring("property prpMultiArg1")] HRESULT prpMultiArg1([in,out,optional] VARIANT* val1, [in,out,optional] VARIANT* val2, [in] VARIANT* newVal);
+ [propget, id(112), helpstring("property prpMultiArg2")] HRESULT prpMultiArg2([in] VARIANT val1, [out, retval] VARIANT* pVal);
+ [propput, id(112), helpstring("property prpMultiArg2")] HRESULT prpMultiArg2([in] VARIANT val1, [in] VARIANT newVal);
+ [id(113), helpstring("method prpMultiArg2GetValues")] HRESULT prpMultiArg2GetValues([out] VARIANT* val1, [out] VARIANT* valProperty);
+ [propget, id(114), helpstring("property prpMultiArg3")] HRESULT prpMultiArg3([in,out] LONG* val1, [out, retval] LONG* pVal);
+ [propput, id(114), helpstring("property prpMultiArg3")] HRESULT prpMultiArg3([in,out] LONG* val1, [in] LONG newVal);
+ [id(115), helpstring("method inUnknown")] HRESULT inUnknown([in] IUnknown* val);
+ [id(116), helpstring("method outUnknown")] HRESULT outUnknown([out] IUnknown** val);
+ [id(117), helpstring("method inoutUnknown")] HRESULT inoutUnknown([in,out] IUnknown** val);
+ [propget, id(118), helpstring("property prpUnknown")] HRESULT prpUnknown([out, retval] IUnknown** pVal);
+ [propput, id(118), helpstring("property prpUnknown")] HRESULT prpUnknown([in] IUnknown* newVal);
+};
+
+[
+ object,
+ uuid(96E6105A-A436-48b3-BFE7-C9302D927CCF),
+ dual,
+ helpstring("IFoo Interface"),
+ pointer_default(unique)
+]
+interface IFoo : IUnknown
+{
+ HRESULT Foo([in] IUnknown* val);
+};
+
+[
+ uuid(BFE10EB1-8584-11D4-8335-005004526AB4),
+ version(1.0),
+ helpstring("AxTestComponents 1.0 Type Library")
+]
+library AXTESTCOMPONENTSLib
+{
+ importlib("stdole32.tlb");
+ importlib("stdole2.tlb");
+
+ [
+ uuid(BFE10EBE-8584-11D4-8335-005004526AB4),
+ helpstring("Basic Class")
+ ]
+ coclass Basic
+ {
+ [default] interface IBasic;
+ };
+
+ [
+ uuid(14DE9D5D-EB9D-4091-8E1B-A1B1672D8C1D),
+ helpstring("Foo Class")
+ ]
+ coclass Foo
+ {
+ [default] interface IFoo;
+ };
+
+};
diff --git a/extensions/test/ole/AxTestComponents/AxTestComponents.rc b/extensions/test/ole/AxTestComponents/AxTestComponents.rc
new file mode 100644
index 000000000000..b2b3c96ba6c2
--- /dev/null
+++ b/extensions/test/ole/AxTestComponents/AxTestComponents.rc
@@ -0,0 +1,164 @@
+/*************************************************************************
+*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+**************************************************************************/
+
+//Microsoft Developer Studio generated resource script.
+//
+#include "resource.h"
+
+#define APSTUDIO_READONLY_SYMBOLS
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 2 resource.
+//
+#include "winres.h"
+
+/////////////////////////////////////////////////////////////////////////////
+#undef APSTUDIO_READONLY_SYMBOLS
+
+/////////////////////////////////////////////////////////////////////////////
+// German (Germany) resources
+
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_DEU)
+#ifdef _WIN32
+LANGUAGE LANG_GERMAN, SUBLANG_GERMAN
+#pragma code_page(1252)
+#endif //_WIN32
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// REGISTRY
+//
+
+IDR_BASIC REGISTRY DISCARDABLE "Basic.rgs"
+IDR_FOO REGISTRY DISCARDABLE "Basic.rgs"
+#endif // German (Germany) resources
+/////////////////////////////////////////////////////////////////////////////
+
+
+/////////////////////////////////////////////////////////////////////////////
+// English (U.S.) resources
+
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
+#ifdef _WIN32
+LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
+#pragma code_page(1252)
+#endif //_WIN32
+
+#ifdef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// TEXTINCLUDE
+//
+
+1 TEXTINCLUDE DISCARDABLE
+BEGIN
+ "resource.h\0"
+END
+
+2 TEXTINCLUDE DISCARDABLE
+BEGIN
+ "#include ""winres.h""\r\n"
+ "\0"
+END
+
+3 TEXTINCLUDE DISCARDABLE
+BEGIN
+ "1 TYPELIB ""AxTestComponents.tlb""\r\n"
+ "\0"
+END
+
+#endif // APSTUDIO_INVOKED
+
+
+#ifndef _MAC
+/////////////////////////////////////////////////////////////////////////////
+//
+// Version
+//
+
+VS_VERSION_INFO VERSIONINFO
+ FILEVERSION 1,0,0,1
+ PRODUCTVERSION 1,0,0,1
+ FILEFLAGSMASK 0x3fL
+#ifdef _DEBUG
+ FILEFLAGS 0x1L
+#else
+ FILEFLAGS 0x0L
+#endif
+ FILEOS 0x4L
+ FILETYPE 0x2L
+ FILESUBTYPE 0x0L
+BEGIN
+ BLOCK "StringFileInfo"
+ BEGIN
+ BLOCK "040904B0"
+ BEGIN
+ VALUE "CompanyName", "\0"
+ VALUE "FileDescription", "AxTestComponents Module\0"
+ VALUE "FileVersion", "1, 0, 0, 1\0"
+ VALUE "InternalName", "AxTestComponents\0"
+ VALUE "LegalCopyright", "Copyright 2000\0"
+ VALUE "OriginalFilename", "AxTestComponents.DLL\0"
+ VALUE "ProductName", "AxTestComponents Module\0"
+ VALUE "ProductVersion", "1, 0, 0, 1\0"
+ VALUE "OLESelfRegister", "\0"
+ END
+ END
+ BLOCK "VarFileInfo"
+ BEGIN
+ VALUE "Translation", 0x409, 1200
+ END
+END
+
+#endif // !_MAC
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// String Table
+//
+
+STRINGTABLE DISCARDABLE
+BEGIN
+ IDS_PROJNAME "AxTestComponents"
+END
+
+#endif // English (U.S.) resources
+/////////////////////////////////////////////////////////////////////////////
+
+
+
+#ifndef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 3 resource.
+//
+1 TYPELIB "AxTestComponents.tlb"
+
+/////////////////////////////////////////////////////////////////////////////
+#endif // not APSTUDIO_INVOKED
+
diff --git a/extensions/test/ole/AxTestComponents/AxTestComponents.sln b/extensions/test/ole/AxTestComponents/AxTestComponents.sln
new file mode 100644
index 000000000000..eadaa373ed94
--- /dev/null
+++ b/extensions/test/ole/AxTestComponents/AxTestComponents.sln
@@ -0,0 +1,31 @@
+Microsoft Visual Studio Solution File, Format Version 10.00
+# Visual Studio 2008
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "AxTestComponents", "AxTestComponents.vcproj", "{CF6DC513-B04E-420A-A0F9-6D1F4046D098}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Win32 = Debug|Win32
+ Release MinDependency|Win32 = Release MinDependency|Win32
+ Release MinSize|Win32 = Release MinSize|Win32
+ Unicode Debug|Win32 = Unicode Debug|Win32
+ Unicode Release MinDependency|Win32 = Unicode Release MinDependency|Win32
+ Unicode Release MinSize|Win32 = Unicode Release MinSize|Win32
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {CF6DC513-B04E-420A-A0F9-6D1F4046D098}.Debug|Win32.ActiveCfg = Debug|Win32
+ {CF6DC513-B04E-420A-A0F9-6D1F4046D098}.Debug|Win32.Build.0 = Debug|Win32
+ {CF6DC513-B04E-420A-A0F9-6D1F4046D098}.Release MinDependency|Win32.ActiveCfg = Release MinDependency|Win32
+ {CF6DC513-B04E-420A-A0F9-6D1F4046D098}.Release MinDependency|Win32.Build.0 = Release MinDependency|Win32
+ {CF6DC513-B04E-420A-A0F9-6D1F4046D098}.Release MinSize|Win32.ActiveCfg = Release MinSize|Win32
+ {CF6DC513-B04E-420A-A0F9-6D1F4046D098}.Release MinSize|Win32.Build.0 = Release MinSize|Win32
+ {CF6DC513-B04E-420A-A0F9-6D1F4046D098}.Unicode Debug|Win32.ActiveCfg = Unicode Debug|Win32
+ {CF6DC513-B04E-420A-A0F9-6D1F4046D098}.Unicode Debug|Win32.Build.0 = Unicode Debug|Win32
+ {CF6DC513-B04E-420A-A0F9-6D1F4046D098}.Unicode Release MinDependency|Win32.ActiveCfg = Unicode Release MinDependency|Win32
+ {CF6DC513-B04E-420A-A0F9-6D1F4046D098}.Unicode Release MinDependency|Win32.Build.0 = Unicode Release MinDependency|Win32
+ {CF6DC513-B04E-420A-A0F9-6D1F4046D098}.Unicode Release MinSize|Win32.ActiveCfg = Unicode Release MinSize|Win32
+ {CF6DC513-B04E-420A-A0F9-6D1F4046D098}.Unicode Release MinSize|Win32.Build.0 = Unicode Release MinSize|Win32
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
diff --git a/extensions/test/ole/AxTestComponents/AxTestComponents.vcproj b/extensions/test/ole/AxTestComponents/AxTestComponents.vcproj
new file mode 100644
index 000000000000..078daba3da2f
--- /dev/null
+++ b/extensions/test/ole/AxTestComponents/AxTestComponents.vcproj
@@ -0,0 +1,819 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="9,00"
+ Name="AxTestComponents"
+ ProjectGUID="{CF6DC513-B04E-420A-A0F9-6D1F4046D098}"
+ RootNamespace="AxTestComponents"
+ Keyword="AtlProj"
+ TargetFrameworkVersion="131072"
+ >
+ <Platforms>
+ <Platform
+ Name="Win32"
+ />
+ </Platforms>
+ <ToolFiles>
+ </ToolFiles>
+ <Configurations>
+ <Configuration
+ Name="Unicode Release MinDependency|Win32"
+ OutputDirectory=".\ReleaseUMinDependency"
+ IntermediateDirectory=".\ReleaseUMinDependency"
+ ConfigurationType="2"
+ InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
+ UseOfMFC="0"
+ UseOfATL="1"
+ ATLMinimizesCRunTimeLibraryUsage="false"
+ CharacterSet="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ Description="Performing registration"
+ CommandLine="if &quot;%OS%&quot;==&quot;&quot; goto NOTNT&#x0D;&#x0A;if not &quot;%OS%&quot;==&quot;Windows_NT&quot; goto NOTNT&#x0D;&#x0A;regsvr32 /s /c &quot;$(TargetPath)&quot;&#x0D;&#x0A;echo regsvr32 exec. time &gt; &quot;$(OutDir)\regsvr32.trg&quot;&#x0D;&#x0A;goto end&#x0D;&#x0A;:NOTNT&#x0D;&#x0A;echo Warning : Cannot register Unicode DLL on Windows 95&#x0D;&#x0A;:end&#x0D;&#x0A;"
+ Outputs="$(OutDir)\regsvr32.trg"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ TypeLibraryName=".\ReleaseUMinDependency/AxTestComponents.tlb"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ InlineFunctionExpansion="1"
+ PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL"
+ StringPooling="true"
+ RuntimeLibrary="0"
+ EnableFunctionLevelLinking="true"
+ UsePrecompiledHeader="2"
+ PrecompiledHeaderThrough="stdafx.h"
+ PrecompiledHeaderFile=".\ReleaseUMinDependency/AxTestComponents.pch"
+ AssemblerListingLocation=".\ReleaseUMinDependency/"
+ ObjectFile=".\ReleaseUMinDependency/"
+ ProgramDataBaseFileName=".\ReleaseUMinDependency/"
+ WarningLevel="3"
+ SuppressStartupBanner="true"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ PreprocessorDefinitions="NDEBUG"
+ Culture="1033"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalOptions="/MACHINE:I386"
+ AdditionalDependencies="odbc32.lib odbccp32.lib"
+ OutputFile=".\ReleaseUMinDependency/AxTestComponents.dll"
+ LinkIncremental="1"
+ SuppressStartupBanner="true"
+ ModuleDefinitionFile=".\AxTestComponents.def"
+ ProgramDatabaseFile=".\ReleaseUMinDependency/AxTestComponents.pdb"
+ SubSystem="2"
+ RandomizedBaseAddress="1"
+ DataExecutionPrevention="0"
+ ImportLibrary=".\ReleaseUMinDependency/AxTestComponents.lib"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release MinSize|Win32"
+ OutputDirectory=".\ReleaseMinSize"
+ IntermediateDirectory=".\ReleaseMinSize"
+ ConfigurationType="2"
+ InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
+ UseOfMFC="0"
+ UseOfATL="2"
+ ATLMinimizesCRunTimeLibraryUsage="false"
+ CharacterSet="2"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ Description="Performing registration"
+ CommandLine="regsvr32 /s /c &quot;$(TargetPath)&quot;&#x0D;&#x0A;echo regsvr32 exec. time &gt; &quot;$(OutDir)\regsvr32.trg&quot;&#x0D;&#x0A;"
+ Outputs="$(OutDir)\regsvr32.trg"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ TypeLibraryName=".\ReleaseMinSize/AxTestComponents.tlb"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ InlineFunctionExpansion="1"
+ PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL"
+ StringPooling="true"
+ RuntimeLibrary="0"
+ EnableFunctionLevelLinking="true"
+ UsePrecompiledHeader="2"
+ PrecompiledHeaderThrough="stdafx.h"
+ PrecompiledHeaderFile=".\ReleaseMinSize/AxTestComponents.pch"
+ AssemblerListingLocation=".\ReleaseMinSize/"
+ ObjectFile=".\ReleaseMinSize/"
+ ProgramDataBaseFileName=".\ReleaseMinSize/"
+ WarningLevel="3"
+ SuppressStartupBanner="true"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ PreprocessorDefinitions="NDEBUG"
+ Culture="1033"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalOptions="/MACHINE:I386"
+ AdditionalDependencies="odbc32.lib odbccp32.lib"
+ OutputFile=".\ReleaseMinSize/AxTestComponents.dll"
+ LinkIncremental="1"
+ SuppressStartupBanner="true"
+ ModuleDefinitionFile=".\AxTestComponents.def"
+ ProgramDatabaseFile=".\ReleaseMinSize/AxTestComponents.pdb"
+ SubSystem="2"
+ RandomizedBaseAddress="1"
+ DataExecutionPrevention="0"
+ ImportLibrary=".\ReleaseMinSize/AxTestComponents.lib"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Unicode Release MinSize|Win32"
+ OutputDirectory=".\ReleaseUMinSize"
+ IntermediateDirectory=".\ReleaseUMinSize"
+ ConfigurationType="2"
+ InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
+ UseOfMFC="0"
+ UseOfATL="2"
+ ATLMinimizesCRunTimeLibraryUsage="false"
+ CharacterSet="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ Description="Performing registration"
+ CommandLine="if &quot;%OS%&quot;==&quot;&quot; goto NOTNT&#x0D;&#x0A;if not &quot;%OS%&quot;==&quot;Windows_NT&quot; goto NOTNT&#x0D;&#x0A;regsvr32 /s /c &quot;$(TargetPath)&quot;&#x0D;&#x0A;echo regsvr32 exec. time &gt; &quot;$(OutDir)\regsvr32.trg&quot;&#x0D;&#x0A;goto end&#x0D;&#x0A;:NOTNT&#x0D;&#x0A;echo Warning : Cannot register Unicode DLL on Windows 95&#x0D;&#x0A;:end&#x0D;&#x0A;"
+ Outputs="$(OutDir)\regsvr32.trg"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ TypeLibraryName=".\ReleaseUMinSize/AxTestComponents.tlb"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ InlineFunctionExpansion="1"
+ PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL"
+ StringPooling="true"
+ RuntimeLibrary="0"
+ EnableFunctionLevelLinking="true"
+ UsePrecompiledHeader="2"
+ PrecompiledHeaderThrough="stdafx.h"
+ PrecompiledHeaderFile=".\ReleaseUMinSize/AxTestComponents.pch"
+ AssemblerListingLocation=".\ReleaseUMinSize/"
+ ObjectFile=".\ReleaseUMinSize/"
+ ProgramDataBaseFileName=".\ReleaseUMinSize/"
+ WarningLevel="3"
+ SuppressStartupBanner="true"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ PreprocessorDefinitions="NDEBUG"
+ Culture="1033"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalOptions="/MACHINE:I386"
+ AdditionalDependencies="odbc32.lib odbccp32.lib"
+ OutputFile=".\ReleaseUMinSize/AxTestComponents.dll"
+ LinkIncremental="1"
+ SuppressStartupBanner="true"
+ ModuleDefinitionFile=".\AxTestComponents.def"
+ ProgramDatabaseFile=".\ReleaseUMinSize/AxTestComponents.pdb"
+ SubSystem="2"
+ RandomizedBaseAddress="1"
+ DataExecutionPrevention="0"
+ ImportLibrary=".\ReleaseUMinSize/AxTestComponents.lib"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release MinDependency|Win32"
+ OutputDirectory=".\ReleaseMinDependency"
+ IntermediateDirectory=".\ReleaseMinDependency"
+ ConfigurationType="2"
+ InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
+ UseOfMFC="0"
+ UseOfATL="1"
+ ATLMinimizesCRunTimeLibraryUsage="false"
+ CharacterSet="2"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ Description="Performing registration"
+ CommandLine="regsvr32 /s /c &quot;$(TargetPath)&quot;&#x0D;&#x0A;echo regsvr32 exec. time &gt; &quot;$(OutDir)\regsvr32.trg&quot;&#x0D;&#x0A;"
+ Outputs="$(OutDir)\regsvr32.trg"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ TypeLibraryName=".\ReleaseMinDependency/AxTestComponents.tlb"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ InlineFunctionExpansion="1"
+ PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL"
+ StringPooling="true"
+ RuntimeLibrary="0"
+ EnableFunctionLevelLinking="true"
+ UsePrecompiledHeader="2"
+ PrecompiledHeaderThrough="stdafx.h"
+ PrecompiledHeaderFile=".\ReleaseMinDependency/AxTestComponents.pch"
+ AssemblerListingLocation=".\ReleaseMinDependency/"
+ ObjectFile=".\ReleaseMinDependency/"
+ ProgramDataBaseFileName=".\ReleaseMinDependency/"
+ WarningLevel="3"
+ SuppressStartupBanner="true"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ PreprocessorDefinitions="NDEBUG"
+ Culture="1033"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalOptions="/MACHINE:I386"
+ AdditionalDependencies="odbc32.lib odbccp32.lib"
+ OutputFile=".\ReleaseMinDependency/AxTestComponents.dll"
+ LinkIncremental="1"
+ SuppressStartupBanner="true"
+ ModuleDefinitionFile=".\AxTestComponents.def"
+ ProgramDatabaseFile=".\ReleaseMinDependency/AxTestComponents.pdb"
+ SubSystem="2"
+ RandomizedBaseAddress="1"
+ DataExecutionPrevention="0"
+ ImportLibrary=".\ReleaseMinDependency/AxTestComponents.lib"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory=".\Debug"
+ IntermediateDirectory=".\Debug"
+ ConfigurationType="2"
+ InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
+ UseOfMFC="0"
+ ATLMinimizesCRunTimeLibraryUsage="false"
+ CharacterSet="2"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ Description="Performing registration"
+ CommandLine="regsvr32 /s /c &quot;$(TargetPath)&quot;&#x0D;&#x0A;echo regsvr32 exec. time &gt; &quot;$(OutDir)\regsvr32.trg&quot;&#x0D;&#x0A;"
+ Outputs="$(OutDir)\regsvr32.trg"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ TypeLibraryName=".\Debug/AxTestComponents.tlb"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalOptions="/D_CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES"
+ Optimization="0"
+ PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="1"
+ UsePrecompiledHeader="2"
+ PrecompiledHeaderThrough="stdafx.h"
+ PrecompiledHeaderFile=".\Debug/AxTestComponents.pch"
+ AssemblerListingLocation=".\Debug/"
+ ObjectFile=".\Debug/"
+ ProgramDataBaseFileName=".\Debug/"
+ BrowseInformation="1"
+ WarningLevel="3"
+ SuppressStartupBanner="false"
+ DebugInformationFormat="4"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ PreprocessorDefinitions="_DEBUG"
+ Culture="1033"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalOptions="/MACHINE:I386"
+ AdditionalDependencies="odbc32.lib odbccp32.lib"
+ OutputFile=".\Debug/AxTestComponents.dll"
+ LinkIncremental="2"
+ SuppressStartupBanner="true"
+ ModuleDefinitionFile=".\AxTestComponents.def"
+ GenerateDebugInformation="true"
+ ProgramDatabaseFile=".\Debug/AxTestComponents.pdb"
+ SubSystem="2"
+ RandomizedBaseAddress="1"
+ DataExecutionPrevention="0"
+ ImportLibrary=".\Debug/AxTestComponents.lib"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Unicode Debug|Win32"
+ OutputDirectory=".\DebugU"
+ IntermediateDirectory=".\DebugU"
+ ConfigurationType="2"
+ InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
+ UseOfMFC="0"
+ ATLMinimizesCRunTimeLibraryUsage="false"
+ CharacterSet="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ Description="Performing registration"
+ CommandLine="if &quot;%OS%&quot;==&quot;&quot; goto NOTNT&#x0D;&#x0A;if not &quot;%OS%&quot;==&quot;Windows_NT&quot; goto NOTNT&#x0D;&#x0A;regsvr32 /s /c &quot;$(TargetPath)&quot;&#x0D;&#x0A;echo regsvr32 exec. time &gt; &quot;$(OutDir)\regsvr32.trg&quot;&#x0D;&#x0A;goto end&#x0D;&#x0A;:NOTNT&#x0D;&#x0A;echo Warning : Cannot register Unicode DLL on Windows 95&#x0D;&#x0A;:end&#x0D;&#x0A;"
+ Outputs="$(OutDir)\regsvr32.trg"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ TypeLibraryName=".\DebugU/AxTestComponents.tlb"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="1"
+ UsePrecompiledHeader="2"
+ PrecompiledHeaderThrough="stdafx.h"
+ PrecompiledHeaderFile=".\DebugU/AxTestComponents.pch"
+ AssemblerListingLocation=".\DebugU/"
+ ObjectFile=".\DebugU/"
+ ProgramDataBaseFileName=".\DebugU/"
+ WarningLevel="3"
+ SuppressStartupBanner="true"
+ DebugInformationFormat="4"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ PreprocessorDefinitions="_DEBUG"
+ Culture="1033"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalOptions="/MACHINE:I386"
+ AdditionalDependencies="odbc32.lib odbccp32.lib"
+ OutputFile=".\DebugU/AxTestComponents.dll"
+ LinkIncremental="2"
+ SuppressStartupBanner="true"
+ ModuleDefinitionFile=".\AxTestComponents.def"
+ GenerateDebugInformation="true"
+ ProgramDatabaseFile=".\DebugU/AxTestComponents.pdb"
+ SubSystem="2"
+ RandomizedBaseAddress="1"
+ DataExecutionPrevention="0"
+ ImportLibrary=".\DebugU/AxTestComponents.lib"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Name="Source Files"
+ Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+ >
+ <File
+ RelativePath=".\AxTestComponents.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\AxTestComponents.def"
+ >
+ </File>
+ <File
+ RelativePath=".\AxTestComponents.idl"
+ >
+ <FileConfiguration
+ Name="Unicode Release MinDependency|Win32"
+ >
+ <Tool
+ Name="VCMIDLTool"
+ GenerateStublessProxies="true"
+ TypeLibraryName=".\AxTestComponents.tlb"
+ HeaderFileName="AxTestComponents.h"
+ InterfaceIdentifierFileName="AxTestComponents_i.c"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release MinSize|Win32"
+ >
+ <Tool
+ Name="VCMIDLTool"
+ GenerateStublessProxies="true"
+ TypeLibraryName=".\AxTestComponents.tlb"
+ HeaderFileName="AxTestComponents.h"
+ InterfaceIdentifierFileName="AxTestComponents_i.c"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Unicode Release MinSize|Win32"
+ >
+ <Tool
+ Name="VCMIDLTool"
+ GenerateStublessProxies="true"
+ TypeLibraryName=".\AxTestComponents.tlb"
+ HeaderFileName="AxTestComponents.h"
+ InterfaceIdentifierFileName="AxTestComponents_i.c"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release MinDependency|Win32"
+ >
+ <Tool
+ Name="VCMIDLTool"
+ GenerateStublessProxies="true"
+ TypeLibraryName=".\AxTestComponents.tlb"
+ HeaderFileName="AxTestComponents.h"
+ InterfaceIdentifierFileName="AxTestComponents_i.c"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCMIDLTool"
+ GenerateStublessProxies="true"
+ TypeLibraryName=".\AxTestComponents.tlb"
+ HeaderFileName="AxTestComponents.h"
+ InterfaceIdentifierFileName="AxTestComponents_i.c"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Unicode Debug|Win32"
+ >
+ <Tool
+ Name="VCMIDLTool"
+ GenerateStublessProxies="true"
+ TypeLibraryName=".\AxTestComponents.tlb"
+ HeaderFileName="AxTestComponents.h"
+ InterfaceIdentifierFileName="AxTestComponents_i.c"
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath=".\AxTestComponents.rc"
+ >
+ <FileConfiguration
+ Name="Unicode Release MinDependency|Win32"
+ >
+ <Tool
+ Name="VCResourceCompilerTool"
+ AdditionalIncludeDirectories="$(OUTDIR);$(NoInherit)"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release MinSize|Win32"
+ >
+ <Tool
+ Name="VCResourceCompilerTool"
+ AdditionalIncludeDirectories="$(OUTDIR);$(NoInherit)"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Unicode Release MinSize|Win32"
+ >
+ <Tool
+ Name="VCResourceCompilerTool"
+ AdditionalIncludeDirectories="$(OUTDIR);$(NoInherit)"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release MinDependency|Win32"
+ >
+ <Tool
+ Name="VCResourceCompilerTool"
+ AdditionalIncludeDirectories="$(OUTDIR);$(NoInherit)"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCResourceCompilerTool"
+ AdditionalIncludeDirectories="$(OUTDIR);$(NoInherit)"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Unicode Debug|Win32"
+ >
+ <Tool
+ Name="VCResourceCompilerTool"
+ AdditionalIncludeDirectories="$(OUTDIR);$(NoInherit)"
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath=".\Basic.cpp"
+ >
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalOptions=" /Ob0"
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="Foo.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\StdAfx.cpp"
+ >
+ <FileConfiguration
+ Name="Unicode Release MinDependency|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ UsePrecompiledHeader="1"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release MinSize|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ UsePrecompiledHeader="1"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Unicode Release MinSize|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ UsePrecompiledHeader="1"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release MinDependency|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ UsePrecompiledHeader="1"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ UsePrecompiledHeader="1"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Unicode Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ UsePrecompiledHeader="1"
+ />
+ </FileConfiguration>
+ </File>
+ </Filter>
+ <Filter
+ Name="Header Files"
+ Filter="h;hpp;hxx;hm;inl"
+ >
+ <File
+ RelativePath=".\Basic.h"
+ >
+ </File>
+ <File
+ RelativePath="Foo.h"
+ >
+ </File>
+ <File
+ RelativePath=".\Resource.h"
+ >
+ </File>
+ <File
+ RelativePath=".\StdAfx.h"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="Resource Files"
+ Filter="ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
+ >
+ <File
+ RelativePath=".\Basic.rgs"
+ >
+ </File>
+ </Filter>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
diff --git a/extensions/test/ole/AxTestComponents/Basic.cpp b/extensions/test/ole/AxTestComponents/Basic.cpp
new file mode 100644
index 000000000000..fab6e68f59c0
--- /dev/null
+++ b/extensions/test/ole/AxTestComponents/Basic.cpp
@@ -0,0 +1,1366 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "stdafx.h"
+#include "Basic.h"
+
+
+/////////////////////////////////////////////////////////////////////////////
+// CBasic
+CBasic::CBasic(): m_cPrpByte(0),m_nPrpShort(0),m_lPrpLong(0),m_fPrpFloat(0), m_dPrpDouble(0),m_PrpArray(0),
+m_safearray(NULL), m_bool(VARIANT_FALSE),
+m_arByte(0), m_arShort(0), m_arLong(0), m_arString(0), m_arVariant(0), m_arFloat(0),
+m_arDouble(0), m_arObject(0), m_arByteDim2(0), m_date(0.), m_scode(0)
+
+{
+ memset(&m_cy, 0, sizeof(CY));
+ memset(&m_decimal, 0, sizeof(DECIMAL));
+}
+
+CBasic::~CBasic()
+{
+ SafeArrayDestroy(m_safearray);
+ SafeArrayDestroy(m_arByte);
+ SafeArrayDestroy(m_arShort);
+ SafeArrayDestroy(m_arLong);
+ SafeArrayDestroy(m_arString);
+ SafeArrayDestroy(m_arVariant);
+ SafeArrayDestroy(m_arFloat);
+ SafeArrayDestroy(m_arDouble);
+ SafeArrayDestroy(m_arObject);
+ SafeArrayDestroy(m_arByteDim2);
+
+}
+STDMETHODIMP CBasic::inBool(VARIANT_BOOL val)
+{
+ m_bool = val;
+ return S_OK;
+}
+STDMETHODIMP CBasic::inByte(unsigned char val)
+{
+ m_byte = val;
+ return S_OK;
+}
+
+STDMETHODIMP CBasic::inShort(short val)
+{
+ m_short = val;
+ return S_OK;
+}
+
+STDMETHODIMP CBasic::inLong(long val)
+{
+ m_long = val;
+ return S_OK;
+}
+
+STDMETHODIMP CBasic::inString(BSTR val)
+{
+ m_bstr = val;
+ return S_OK;
+}
+
+STDMETHODIMP CBasic::inFloat(float val)
+{
+ m_float = val;
+ return S_OK;
+}
+
+STDMETHODIMP CBasic::inDouble(double val)
+{
+ m_double = val;
+
+ CComVariant varDest;
+ CComVariant varSource(val);
+ HRESULT hr = VariantChangeType(&varDest, &varSource, 0, VT_BSTR);
+ return S_OK;
+}
+
+STDMETHODIMP CBasic::inVariant(VARIANT val)
+{
+ m_var1 = val;
+ return S_OK;
+}
+
+STDMETHODIMP CBasic::inArray(LPSAFEARRAY val)
+{
+ HRESULT hr = S_OK;
+ if (FAILED(hr = SafeArrayDestroy(m_safearray)))
+ return hr;
+ if (FAILED(hr = SafeArrayCopy(val, &m_safearray)))
+ return hr;
+ return S_OK;
+}
+
+STDMETHODIMP CBasic::inObject(IDispatch *val)
+{
+ m_obj = val;
+ return S_OK;
+}
+
+STDMETHODIMP CBasic::inoutBool(VARIANT_BOOL* val)
+{
+ VARIANT_BOOL aBool = *val;
+ *val = m_bool;
+ m_bool = aBool;
+ return S_OK;
+}
+
+
+STDMETHODIMP CBasic::inoutByte(unsigned char* val)
+{
+ unsigned char aByte = *val;
+ *val = m_byte;
+ m_byte = aByte;
+ return S_OK;
+}
+
+STDMETHODIMP CBasic::inoutShort(short *val)
+{
+ short aShort = *val;
+ *val = m_short;
+ m_short = aShort;
+ return S_OK;
+}
+
+STDMETHODIMP CBasic::inoutLong(long *val)
+{
+ long aLong = *val;
+ *val = m_long;
+ m_long = aLong;
+ return S_OK;
+}
+
+STDMETHODIMP CBasic::inoutString(BSTR *val)
+{
+ CComBSTR aStr = *val;
+ HRESULT hr = S_OK;
+ if (FAILED( hr = m_bstr.CopyTo(val)))
+ return hr;
+ m_bstr = aStr;
+ return S_OK;
+}
+
+STDMETHODIMP CBasic::inoutFloat(float *val)
+{
+ float aFloat = *val;
+ *val = m_float;
+ m_float = aFloat;
+ return S_OK;
+}
+
+STDMETHODIMP CBasic::inoutDouble(double *val)
+{
+ double aDouble = *val;
+ *val = m_double;
+ m_double = aDouble;
+ return S_OK;
+}
+
+STDMETHODIMP CBasic::inoutVariant(VARIANT *val)
+{
+ CComVariant aVar = *val;
+ HRESULT hr = S_OK;
+ if (FAILED(hr = VariantCopy(val, &m_var1)))
+ return hr;
+ m_var1 = aVar;
+ return S_OK;
+}
+
+/* The array contains VARIANT according to IDL.
+ If the VARIANTs contain strings then we append "out" to each string.
+*/
+STDMETHODIMP CBasic::inoutArray(LPSAFEARRAY *val)
+{
+ SAFEARRAY* aAr = NULL;
+ HRESULT hr = S_OK;
+ if (FAILED(hr = SafeArrayCopy(*val, &aAr)))
+ return hr;
+ if (FAILED(hr = SafeArrayCopy(m_safearray, val)))
+ return hr;
+ if (FAILED(hr = SafeArrayCopy(aAr, & m_safearray)))
+ return hr;
+ return S_OK;
+}
+
+STDMETHODIMP CBasic::inoutObject(IDispatch **val)
+{
+ CComPtr<IDispatch> disp = *val;
+ if (*val)
+ (*val)->Release();
+ *val = m_obj;
+ if (*val)
+ (*val)->AddRef();
+ m_obj = disp;
+ return S_OK;
+}
+
+
+STDMETHODIMP CBasic::outBool(VARIANT_BOOL* val)
+{
+ *val = m_bool;
+ return S_OK;
+}
+
+STDMETHODIMP CBasic::outByte(unsigned char *val)
+{
+ *val= m_byte;
+ return S_OK;
+}
+
+STDMETHODIMP CBasic::outShort(short *val)
+{
+ *val= m_short;
+ return S_OK;
+}
+
+STDMETHODIMP CBasic::outLong(long *val)
+{
+ *val= m_long;
+ return S_OK;
+}
+
+STDMETHODIMP CBasic::outString(BSTR *val)
+{
+ *val= SysAllocString(m_bstr);
+ return S_OK;
+}
+
+STDMETHODIMP CBasic::outFloat(float *val)
+{
+ *val= m_float;
+ return S_OK;
+}
+
+STDMETHODIMP CBasic::outDouble(double *val)
+{
+ *val= m_double;
+ return S_OK;
+}
+
+STDMETHODIMP CBasic::outVariant(VARIANT *val)
+{
+ HRESULT hr = S_OK;
+ if (FAILED(hr = VariantCopy(val, &m_var1)))
+ return hr;
+ return S_OK;
+}
+
+STDMETHODIMP CBasic::outArray(LPSAFEARRAY *val)
+{
+ HRESULT hr = S_OK;
+ if (FAILED(hr = SafeArrayCopy(m_safearray, val)))
+ return false;
+ return S_OK;
+}
+
+STDMETHODIMP CBasic::outObject(IDispatch* *val)
+{
+ *val = m_obj;
+ if (m_obj)
+ (*val)->AddRef();
+
+ return S_OK;
+}
+
+
+STDMETHODIMP CBasic::get_prpBool(VARIANT_BOOL* pVal)
+{
+ if (!pVal) return E_POINTER;
+ *pVal = m_bool;
+ return S_OK;
+}
+
+STDMETHODIMP CBasic::put_prpBool(VARIANT_BOOL val)
+{
+ m_bool = val;
+ return S_OK;
+}
+
+
+STDMETHODIMP CBasic::get_prpByte(unsigned char *pVal)
+{
+ if( !pVal)
+ return E_POINTER;
+ *pVal= m_cPrpByte;
+ return S_OK;
+}
+
+STDMETHODIMP CBasic::put_prpByte(unsigned char newVal)
+{
+ m_cPrpByte= newVal;
+ return S_OK;
+}
+
+STDMETHODIMP CBasic::get_prpShort(short *pVal)
+{
+ if( !pVal)
+ return E_POINTER;
+ *pVal= m_nPrpShort;
+ return S_OK;
+}
+
+STDMETHODIMP CBasic::put_prpShort(short newVal)
+{
+ m_nPrpShort= newVal;
+ return S_OK;
+}
+
+STDMETHODIMP CBasic::get_prpLong(long *pVal)
+{
+ if( !pVal)
+ return E_POINTER;
+ *pVal= m_lPrpLong;
+ return S_OK;
+}
+
+STDMETHODIMP CBasic::put_prpLong(long newVal)
+{
+ m_lPrpLong= newVal;
+ return S_OK;
+}
+
+STDMETHODIMP CBasic::get_prpString(BSTR *pVal)
+{
+ if( !pVal)
+ return E_POINTER;
+ m_bstrPrpString.CopyTo( pVal );
+ return S_OK;
+}
+
+STDMETHODIMP CBasic::put_prpString(BSTR newVal)
+{
+ m_bstrPrpString= newVal;
+ return S_OK;
+}
+
+STDMETHODIMP CBasic::get_prpFloat(float *pVal)
+{
+ if( !pVal)
+ return E_POINTER;
+ *pVal= m_fPrpFloat;
+ return S_OK;
+}
+
+STDMETHODIMP CBasic::put_prpFloat(float newVal)
+{
+ m_fPrpFloat= newVal;
+ return S_OK;
+}
+
+STDMETHODIMP CBasic::get_prpDouble(double *pVal)
+{
+ if( !pVal)
+ return E_POINTER;
+ *pVal= m_dPrpDouble;
+ return S_OK;
+}
+
+STDMETHODIMP CBasic::put_prpDouble(double newVal)
+{
+ m_dPrpDouble= newVal;
+ return S_OK;
+}
+
+STDMETHODIMP CBasic::get_prpVariant(VARIANT *pVal)
+{
+ if( !pVal)
+ return E_POINTER;
+ HRESULT hr = S_OK;
+ if (FAILED(hr = VariantCopy( pVal, &m_PropVariant)))
+ return hr;
+ return hr;
+}
+
+STDMETHODIMP CBasic::put_prpVariant(VARIANT newVal)
+{
+ m_PropVariant= newVal;
+ return S_OK;
+}
+
+STDMETHODIMP CBasic::get_prpArray(LPSAFEARRAY *pVal)
+{
+ if( !pVal)
+ return E_POINTER;
+ HRESULT hr = S_OK;
+ if (FAILED(hr = SafeArrayCopy( m_PrpArray, pVal)))
+ return hr;
+ return hr;
+}
+
+STDMETHODIMP CBasic::put_prpArray(LPSAFEARRAY newVal)
+{
+ HRESULT hr = S_OK;
+ if (FAILED(hr = SafeArrayDestroy( m_PrpArray)))
+ return hr;
+ if (FAILED(hr = SafeArrayCopy( newVal, &m_PrpArray)))
+ return hr;
+ return hr;
+}
+
+STDMETHODIMP CBasic::get_prpObject(IDispatch **pVal)
+{
+ if( !pVal)
+ return E_POINTER;
+ *pVal= m_PrpObject;
+ if( *pVal != NULL)
+ (*pVal)->AddRef();
+ return S_OK;
+}
+
+STDMETHODIMP CBasic::put_prpObject(IDispatch *newVal)
+{
+ m_PrpObject= newVal;
+ return S_OK;
+}
+
+STDMETHODIMP CBasic::mixed1(
+ /* [out][in] */ unsigned char *aChar,
+ /* [out][in] */ float *aFloat,
+ /* [out][in] */ VARIANT *aVar)
+
+{
+ HRESULT hr= S_OK;
+ inoutByte(aChar);
+ inoutFloat(aFloat);
+ inoutVariant(aVar);
+ return hr;
+}
+
+
+
+
+// VT_UI1
+
+STDMETHODIMP CBasic::inSequenceLong(LPSAFEARRAY val)
+{
+ HRESULT hr = S_OK;
+ if (FAILED(hr = SafeArrayDestroy(m_arLong)))
+ return hr;
+ if (FAILED(hr = SafeArrayCopy(val, & m_arLong)))
+ return hr;
+ return hr;
+}
+
+STDMETHODIMP CBasic::inSequenceByte( LPSAFEARRAY val)
+{
+ HRESULT hr = S_OK;
+ if (FAILED(hr = SafeArrayDestroy(m_arByte)))
+ return hr;
+ if (FAILED(hr = SafeArrayCopy(val, & m_arByte)))
+ return hr;
+ return hr;
+}
+
+STDMETHODIMP CBasic::inSequenceShort(LPSAFEARRAY val)
+{
+ HRESULT hr = S_OK;
+ if (FAILED(hr = SafeArrayDestroy(m_arShort)))
+ return hr;
+ if (FAILED(hr = SafeArrayCopy(val, & m_arShort)))
+ return hr;
+ return hr;
+}
+
+STDMETHODIMP CBasic::inSequenceString(LPSAFEARRAY val)
+{
+ HRESULT hr = S_OK;
+ if (FAILED(hr = SafeArrayDestroy(m_arString)))
+ return hr;
+ if (FAILED(hr = SafeArrayCopy(val, & m_arString)))
+ return hr;
+ return hr;
+}
+
+STDMETHODIMP CBasic::inSequenceFloat(LPSAFEARRAY val)
+{
+ HRESULT hr = S_OK;
+ if (FAILED(hr = SafeArrayDestroy(m_arFloat)))
+ return hr;
+ if (FAILED(hr = SafeArrayCopy(val, & m_arFloat)))
+ return hr;
+ return hr;
+}
+
+STDMETHODIMP CBasic::inSequenceDouble(LPSAFEARRAY val)
+{
+ HRESULT hr = S_OK;
+ if (FAILED(hr = SafeArrayDestroy(m_arDouble)))
+ return hr;
+ if (FAILED(hr = SafeArrayCopy(val, & m_arDouble)))
+ return hr;
+ return hr;
+}
+
+STDMETHODIMP CBasic::inSequenceObject(LPSAFEARRAY val)
+{
+ HRESULT hr = S_OK;
+ if (FAILED(hr = SafeArrayDestroy(m_arObject)))
+ return hr;
+ if (FAILED(hr = SafeArrayCopy(val, & m_arObject)))
+ return hr;
+ return hr;
+}
+
+void CBasic::printArray( LPSAFEARRAY val, BSTR message, VARTYPE type)
+{
+
+ HRESULT hr= S_OK;
+ USES_CONVERSION;
+ long lbound=0;
+ long ubound= 0;
+ hr= SafeArrayGetLBound( val, 1, &lbound);
+ hr= SafeArrayGetUBound( val, 1, &ubound);
+ long length= ubound - lbound +1;
+
+ CComVariant varElement;
+ char buf[1024];
+ sprintf( buf,"%s", W2A(message));
+
+ for( long i= 0; i < length ; i++)
+ {
+ char tmp[1024];
+ long data=0;
+ CComVariant var;
+ switch( type)
+ {
+ case VT_UI1:
+ case VT_I2:
+ case VT_I4:
+ case VT_ERROR:
+ hr= SafeArrayGetElement( val, &i, (void*)&data);
+ sprintf( tmp, "%d \n", *(long*)&data);
+ break;
+ case VT_BSTR:
+ hr= SafeArrayGetElement( val, &i, (void*)&data);
+ sprintf( tmp, "%S \n", (BSTR)data);
+ break;
+ case VT_VARIANT:
+ hr= SafeArrayGetElement( val, &i, &var);
+ sprintf( tmp, "%x \n", var.byref);
+ break;
+ case VT_R4:
+ hr= SafeArrayGetElement( val, &i, (void*)&data);
+ sprintf( tmp, "%f \n", *(float*) &data);
+ break;
+ case VT_R8: ;
+ hr= SafeArrayGetElement( val, &i, (void*)&data);
+ sprintf( tmp, "%f \n", *(double*) &data);
+ break;
+ case VT_DISPATCH:
+ // we assume the objects are instances of this component and have the
+ // property prpString set.
+ hr= SafeArrayGetElement( val, &i, (void*)&data);
+ IDispatch* pdisp= ( IDispatch*) data;
+ CComDispatchDriver driver( pdisp);
+ CComVariant var;
+ if( pdisp)
+ {
+ driver.GetPropertyByName(L"prpString", &var);
+ sprintf( tmp, "%x : %S \n", *(long*)&data, var.bstrVal);
+ }
+ else
+ sprintf( tmp, "%x\n", *(long*)&data);
+ }
+
+ strcat( buf, tmp);
+ }
+ MessageBox( NULL, _T(A2T(buf)), _T("AxTestComponents.Basic"), MB_OK);
+
+}
+// V_ERROR OLECHAR VARIANT VT_UI1
+
+STDMETHODIMP CBasic::outSequenceByte(LPSAFEARRAY* val)
+{
+ HRESULT hr= S_OK;
+ hr = SafeArrayCopy(m_arByte, val);
+ return hr;
+}
+
+STDMETHODIMP CBasic::outSequenceShort(LPSAFEARRAY* val)
+{
+ HRESULT hr= S_OK;
+ hr = SafeArrayCopy(m_arShort, val);
+ return hr;
+}
+
+STDMETHODIMP CBasic::outSequenceLong(LPSAFEARRAY* val)
+{
+ HRESULT hr= S_OK;
+ hr = SafeArrayCopy(m_arLong, val);
+ return hr;
+}
+
+STDMETHODIMP CBasic::outSequenceString(LPSAFEARRAY* val)
+{
+ HRESULT hr= S_OK;
+ hr = SafeArrayCopy(m_arString, val);
+ return hr;
+}
+
+STDMETHODIMP CBasic::outSequenceFloat(LPSAFEARRAY* val)
+{
+ HRESULT hr= S_OK;
+ hr = SafeArrayCopy(m_arFloat, val);
+ return hr;
+}
+
+STDMETHODIMP CBasic::outSequenceDouble(LPSAFEARRAY* val)
+{
+ HRESULT hr= S_OK;
+ hr = SafeArrayCopy(m_arDouble, val);
+ return hr;
+}
+
+STDMETHODIMP CBasic::outSequenceObject(LPSAFEARRAY* val)
+{
+ HRESULT hr = S_OK;
+ hr = SafeArrayCopy(m_arObject, val);
+ return S_OK;
+}
+
+STDMETHODIMP CBasic::inoutSequenceByte(LPSAFEARRAY* val)
+{
+ HRESULT hr = S_OK;
+ SAFEARRAY *arTemp = NULL;
+ if (FAILED(hr = SafeArrayCopy(*val, &arTemp)))
+ return hr;
+ if (FAILED(hr = SafeArrayCopy(m_arByte, val)))
+ return hr;
+ m_arByte = arTemp;
+ return hr;
+}
+
+STDMETHODIMP CBasic::inoutSequenceShort(LPSAFEARRAY* val)
+{
+ HRESULT hr = S_OK;
+ SAFEARRAY *arTemp = NULL;
+ if (FAILED(hr = SafeArrayCopy(*val, &arTemp)))
+ return hr;
+ if (FAILED(hr = SafeArrayCopy(m_arShort, val)))
+ return hr;
+ m_arShort = arTemp;
+ return hr;
+}
+
+STDMETHODIMP CBasic::inoutSequenceLong(LPSAFEARRAY* val)
+{
+ HRESULT hr = S_OK;
+ SAFEARRAY *arTemp = NULL;
+ if (FAILED(hr = SafeArrayCopy(*val, &arTemp)))
+ return hr;
+ if (FAILED(hr = SafeArrayCopy(m_arLong, val)))
+ return hr;
+ m_arLong = arTemp;
+ return hr;
+}
+
+STDMETHODIMP CBasic::inoutSequenceString(LPSAFEARRAY* val)
+{
+ HRESULT hr = S_OK;
+ SAFEARRAY *arTemp = NULL;
+ if (FAILED(hr = SafeArrayCopy(*val, &arTemp)))
+ return hr;
+ if (FAILED(hr = SafeArrayCopy(m_arString, val)))
+ return hr;
+ m_arString = arTemp;
+ return hr;
+}
+
+STDMETHODIMP CBasic::inoutSequenceFloat(LPSAFEARRAY* val)
+{
+ HRESULT hr = S_OK;
+ SAFEARRAY *arTemp = NULL;
+ if (FAILED(hr = SafeArrayCopy(*val, &arTemp)))
+ return hr;
+ if (FAILED(hr = SafeArrayCopy(m_arFloat, val)))
+ return hr;
+ m_arFloat = arTemp;
+ return hr;
+}
+
+STDMETHODIMP CBasic::inoutSequenceDouble(LPSAFEARRAY* val)
+{
+ HRESULT hr = S_OK;
+ SAFEARRAY *arTemp = NULL;
+ if (FAILED(hr = SafeArrayCopy(*val, &arTemp)))
+ return hr;
+ if (FAILED(hr = SafeArrayCopy(m_arDouble, val)))
+ return hr;
+ m_arDouble = arTemp;
+ return hr;
+}
+
+STDMETHODIMP CBasic::inoutSequenceObject(LPSAFEARRAY* val)
+{
+ HRESULT hr = S_OK;
+ SAFEARRAY *arTemp = NULL;
+ if (FAILED(hr = SafeArrayCopy(*val, &arTemp)))
+ return hr;
+ if (FAILED(hr = SafeArrayCopy(m_arObject, val)))
+ return hr;
+ m_arObject = arTemp;
+ return hr;
+}
+
+// 2-dimensional Array
+STDMETHODIMP CBasic::inMulDimArrayLong(LPSAFEARRAY val)
+{
+ printMulArray( val, VT_I4);
+ return S_OK;
+}
+// 2-dimensional Array
+STDMETHODIMP CBasic::inMulDimArrayVariant(LPSAFEARRAY val)
+{
+ printMulArray( val, VT_VARIANT);
+ return S_OK;
+}
+// 3-dimensional Array
+STDMETHODIMP CBasic::inMulDimArrayLong2(LPSAFEARRAY val)
+{
+ printMulArray( val, VT_I4);
+ return S_OK;
+}
+// 3-dimensional Array
+STDMETHODIMP CBasic::inMulDimArrayVariant2(LPSAFEARRAY val)
+{
+ return S_OK;
+}
+
+
+STDMETHODIMP CBasic::inMulDimArrayByte(LPSAFEARRAY val)
+{
+ HRESULT hr = S_OK;
+ if (FAILED(hr = SafeArrayDestroy(m_arByteDim2)))
+ return hr;
+ if (FAILED(hr = SafeArrayCopy(val, & m_arByteDim2)))
+ return hr;
+ return hr;
+}
+// 3-dimensionales array
+STDMETHODIMP CBasic::inMulDimArrayByte2(LPSAFEARRAY val)
+{
+
+ // TODO: Add your implementation code here
+ //printMulArray( val, VT_UI1);
+ return S_OK;
+}
+
+// supports 2 and 3 dimensionals SAFEARRAY with elements of long or VARIANT
+void CBasic::printMulArray( SAFEARRAY* val, VARTYPE type)
+{
+ HRESULT hr= S_OK;
+ UINT dims= SafeArrayGetDim( val);
+ long lbound1;
+ long ubound1;
+ long lbound2;
+ long ubound2;
+ long lbound3;
+ long ubound3;
+ long length1;
+ long length2;
+ long length3;
+
+ char buff[4096];
+ buff[0]=0;
+
+ if( dims == 2)
+ {
+ hr= SafeArrayGetLBound( val, 1, &lbound1);
+ hr= SafeArrayGetUBound( val, 1, &ubound1);
+ length1= ubound1 - lbound1 +1;
+
+ hr= SafeArrayGetLBound( val, 2, &lbound2);
+ hr= SafeArrayGetUBound( val, 2, &ubound2);
+ length2= ubound2 - lbound2 + 1;
+ char tmpBuf[1024];
+ tmpBuf[0]=0;
+ long index[2];
+ for( long i= 0; i< length2; i++)
+ {
+ for( long j= 0; j<length1; j++)
+ {
+ index[0]= j;
+ index[1]= i;
+ long longVal;
+ CComVariant var;
+ switch( type)
+ {
+ case VT_I4:
+ hr= SafeArrayGetElement( val, index, &longVal);
+ sprintf( tmpBuf, "(%d,%d): %d\n", index[1], index[0], longVal);
+ break;
+ case VT_UI1:
+ hr= SafeArrayGetElement( val, index, &longVal);
+ sprintf( tmpBuf, "(%d,%d): %d\n", index[1], index[0], (unsigned char)longVal);
+ break;
+ case VT_VARIANT:
+ hr= SafeArrayGetElement( val, index, &var );
+ sprintf( tmpBuf, "(%d,%d): %d (vartype %d)\n", index[1], index[0], var.byref, var.vt);
+ break;
+ }
+ strcat( buff,tmpBuf);
+ }
+
+ }
+
+
+ }
+ else if( dims == 3 )
+ {
+ hr= SafeArrayGetLBound( val, 1, &lbound1);
+ hr= SafeArrayGetUBound( val, 1, &ubound1);
+ length1= ubound1 - lbound1 +1;
+
+ hr= SafeArrayGetLBound( val, 2, &lbound2);
+ hr= SafeArrayGetUBound( val, 2, &ubound2);
+ length2= ubound2 - lbound2 + 1;
+
+ hr= SafeArrayGetLBound( val, 3, &lbound3);
+ hr= SafeArrayGetUBound( val, 3, &ubound3);
+ length3= ubound3 - lbound3 +1;
+ char tmpBuf[1024];
+ tmpBuf[0]=0;
+ long index[3];
+ for( long i= 0; i< length3; i++)
+ {
+ for( long j= 0; j<length2; j++)
+ {
+ for( long k= 0; k<length1; k++)
+ {
+ index[0]= k;
+ index[1]= j;
+ index[2]= i;
+ long longVal;
+ CComVariant var;
+ switch( type)
+ {
+ case VT_I4:
+ hr= SafeArrayGetElement( val, index, &longVal);
+ sprintf( tmpBuf, "(%d,%d,%d): %d\n", index[2], index[1], index[0], longVal);
+ break;
+ case VT_UI1:
+ hr= SafeArrayGetElement( val, index, &longVal);
+ sprintf( tmpBuf, "(%d,%d,%d): %d\n", index[2], index[1], index[0], (unsigned char)longVal);
+ break;
+
+ case VT_VARIANT:
+ hr= SafeArrayGetElement( val, index, &var );
+ sprintf( tmpBuf, "(%d,%d,%d): %d (vartype %d)\n", index[2], index[1], index[0], var.byref, var.vt);
+ break;
+ }
+ strcat( buff,tmpBuf);
+ }
+ }
+
+ }
+
+ }
+
+ MessageBox( NULL, A2T( buff), _T("AxTestControl.Basic"), MB_OK);
+
+
+}
+
+
+
+
+STDMETHODIMP CBasic::outMore(long* val1, long* val2)
+{
+ // TODO: Add your implementation code here
+ *val1= 111;
+ *val2= 112;
+ return S_OK;
+}
+// If an optional parameter was not provided then the respective member will
+// not be set
+STDMETHODIMP CBasic::optional1(/*[in]*/ long val1, /*[in, optional]*/ VARIANT* val2)
+{
+ m_long = val1;
+ if (val2->vt != VT_ERROR)
+ m_var1 = *val2;
+ return S_OK;
+}
+
+STDMETHODIMP CBasic::optional2(/*[out]*/ long* val1,/*[out, optional]*/ VARIANT* val2)
+{
+ HRESULT hr = S_OK;
+ *val1 = m_long;
+
+ if (val2->vt != VT_ERROR)
+ hr = VariantCopy(val2, & m_var1);
+ return hr;
+}
+
+STDMETHODIMP CBasic::optional3(/*[in, optional]*/ VARIANT* val1,/*[in, optional]*/ VARIANT* val2)
+{
+ //if (val1->vt != VT_ERROR)
+ m_var1 = *val1;
+
+ //if (val2->vt != VT_ERROR)
+ m_var2 = *val2;
+ return S_OK;
+}
+
+STDMETHODIMP CBasic::optional4(/*[in, out, optional]*/ VARIANT* val1,
+ /*[in, out, optional]*/ VARIANT* val2)
+{
+ HRESULT hr = S_OK;
+ //return the previously set in values
+ if (val1->vt != VT_ERROR)
+ {
+ CComVariant var1(*val1);
+ if (FAILED(hr = VariantCopy(val1, & m_var1)))
+ return hr;
+ m_var1 = var1;
+ }
+ if (val2->vt != VT_ERROR)
+ {
+ CComVariant var2(*val2);
+ if (FAILED(hr = VariantCopy(val2, & m_var2)))
+ return hr;
+ m_var2 = var2;
+ }
+ return hr;
+}
+
+STDMETHODIMP CBasic::optional5(/*[out, optional]*/ VARIANT* val1,
+ /*[out, optional]*/ VARIANT* val2)
+{
+ HRESULT hr = S_OK;
+ if (FAILED(hr = VariantCopy(val1, &m_var1)))
+ return hr;
+ if (FAILED(hr = VariantCopy(val2, &m_var2)))
+ return hr;
+ return hr;
+}
+
+STDMETHODIMP CBasic::defaultvalue1(/*[in, defaultvalue(10)]*/ long val1,
+ /*[in, defaultvalue(3.14)]*/ double* val2,
+ // /*[in, defaultvalue(10)]*/ VARIANT val3,
+ /*[in, defaultvalue(100)]*/ VARIANT* val4)
+{
+ m_long = val1;
+ m_double = *val2;
+// m_var1 = val3;
+ m_var2 = *val4;
+ return S_OK;
+}
+STDMETHODIMP CBasic::defaultvalue2(/*[in, out, defaultvalue(10)]*/ long* val1,
+ /*[in, out, defaultvalue(3.14)]*/ double* val2,
+ // /*[in, out, defaultvalue(10)]*/ VARIANT* val3,
+ /*[in, out, defaultvalue(100)]*/ VARIANT* val4)
+{
+ HRESULT hr = S_OK;
+ long aLong = *val1;
+ double aDouble = *val2;
+// CComVariant var1(*val3);
+ CComVariant var2(*val4);
+ *val1 = m_long;
+ *val2 = m_double;
+ //if (FAILED(hr = VariantCopy(val3, &m_var1)))
+ // return hr;
+ if (FAILED(hr = VariantCopy(val4, &m_var2)))
+ return hr;
+ m_long = aLong;
+ m_double = aDouble;
+// m_var1 = var1;
+ m_var2 = var2;
+ return hr;
+}
+/* val2 contains the variable argument list. If no such arguments are supplied
+ then the safearray is invalid. SafeArrayCopy then returns E_INVALIDARG
+*/
+STDMETHODIMP CBasic::varargfunc1(/*[in]*/ long val1,/*[in]*/ LPSAFEARRAY val2)
+{
+ m_long = val1;
+
+ HRESULT hr = S_OK;
+ if (FAILED(hr = SafeArrayDestroy(m_safearray)))
+ return hr;
+ if (FAILED(hr = SafeArrayCopy(val2, & m_safearray)))
+ {
+ if (hr != E_INVALIDARG)
+ return hr;
+ }
+ return S_OK;
+}
+
+STDMETHODIMP CBasic::varargfunc2(/*[out]*/ long* val1, /*[out]*/ SAFEARRAY ** val2)
+{
+ *val1 = m_long;
+ HRESULT hr = SafeArrayCopy(m_safearray, val2);
+ return hr;
+}
+
+STDMETHODIMP CBasic::inSequenceByteDim2(LPSAFEARRAY val)
+{
+ HRESULT hr = S_OK;
+ if (FAILED(hr = SafeArrayDestroy(m_arByteDim2)))
+ return hr;
+ if (FAILED(hr = SafeArrayCopy(val, & m_arByteDim2)))
+ return hr;
+ return hr;
+}
+
+
+STDMETHODIMP CBasic::inCurrency(CY val)
+{
+ m_cy = val;
+ return S_OK;
+}
+
+STDMETHODIMP CBasic::outCurrency(CY* val)
+{
+ *val = m_cy;
+ return S_OK;
+}
+
+STDMETHODIMP CBasic::inoutCurrency(CY* val)
+{
+ CY tmp = *val;
+ *val = m_cy;
+ m_cy = tmp;
+ return S_OK;
+}
+
+STDMETHODIMP CBasic::inDate(DATE val)
+{
+ m_date = val;
+ return S_OK;
+}
+
+STDMETHODIMP CBasic::outDate(DATE* val)
+{
+ *val = m_date;
+ return S_OK;
+}
+
+STDMETHODIMP CBasic::inoutDate(DATE* val)
+{
+ DATE tmp = *val;
+ *val = m_date;
+ m_date = tmp;
+ return S_OK;
+}
+
+STDMETHODIMP CBasic::get_prpCurrency(CY* pVal)
+{
+ *pVal = m_cy;
+ return S_OK;
+}
+
+STDMETHODIMP CBasic::put_prpCurrency(CY newVal)
+{
+ m_cy = newVal;
+ return S_OK;
+}
+
+STDMETHODIMP CBasic::get_prpDate(DATE* pVal)
+{
+ *pVal = m_date;
+ return S_OK;
+}
+
+STDMETHODIMP CBasic::put_prpDate(DATE newVal)
+{
+ m_date = newVal;
+ return S_OK;
+}
+
+//VT_I4 DECIMAL_NEG //tagVARIANT DISPATCH_PROPERTYPUT
+STDMETHODIMP CBasic::inDecimal(DECIMAL val)
+{
+ m_decimal = val;
+ return S_OK;
+}
+
+STDMETHODIMP CBasic::outDecimal(DECIMAL* val)
+{
+ * val = m_decimal;
+ return S_OK;
+}
+
+STDMETHODIMP CBasic::inoutDecimal(DECIMAL* val)
+{
+ DECIMAL tmp;
+ tmp = * val;
+ * val = m_decimal;
+ m_decimal = tmp;
+ return S_OK;
+}
+
+STDMETHODIMP CBasic::get_prpDecimal(DECIMAL* pVal)
+{
+ * pVal = m_decimal;
+ return S_OK;
+}
+
+STDMETHODIMP CBasic::put_prpDecimal(DECIMAL newVal)
+{
+ m_decimal = newVal;
+ return S_OK;
+}
+
+STDMETHODIMP CBasic::inSCode(SCODE val)
+{
+ m_scode = val;
+ return S_OK;
+}
+
+STDMETHODIMP CBasic::outScode(SCODE* val)
+{
+ * val = m_scode;
+ return S_OK;
+}
+
+STDMETHODIMP CBasic::inoutSCode(SCODE* val)
+{
+ SCODE tmp = *val;
+ * val = m_scode;
+ m_scode = tmp;
+ return S_OK;
+}
+
+STDMETHODIMP CBasic::get_prpSCode(SCODE* pVal)
+{
+ * pVal = m_scode;
+ return S_OK;
+}
+
+STDMETHODIMP CBasic::put_prpSCode(SCODE newVal)
+{
+ m_scode = newVal;
+ return S_OK;
+}
+
+STDMETHODIMP CBasic::inrefLong(LONG* val)
+{
+ m_long = * val;
+ return S_OK;
+}
+
+STDMETHODIMP CBasic::inrefVariant(VARIANT* val)
+{
+ HRESULT hr = S_OK;
+ if (FAILED(hr = VariantCopy( & m_var1, val)))
+ return hr;
+ return S_OK;
+}
+
+STDMETHODIMP CBasic::inrefDecimal(DECIMAL* val)
+{
+ m_decimal = * val;
+ return S_OK;
+}
+
+STDMETHODIMP CBasic::get_prpRefLong(long* pVal)
+{
+ *pVal = m_long;
+ return S_OK;
+}
+
+STDMETHODIMP CBasic::putref_prpRefLong(long* newVal)
+{
+ m_long = * newVal;
+ return S_OK;
+}
+
+STDMETHODIMP CBasic::get_prprefVariant(VARIANT* pVal)
+{
+ HRESULT hr = S_OK;
+ hr = VariantCopy(pVal, & m_var1);
+ return hr;
+}
+
+STDMETHODIMP CBasic::putref_prprefVariant(VARIANT* newVal)
+{
+ m_var1 = * newVal;
+ return S_OK;
+}
+
+STDMETHODIMP CBasic::get_prprefDecimal(DECIMAL* pVal)
+{
+ * pVal = m_decimal;
+ return S_OK;
+}
+
+STDMETHODIMP CBasic::putref_prprefDecimal(DECIMAL* newVal)
+{
+ m_decimal = *newVal;
+ return S_OK;
+}
+
+
+STDMETHODIMP CBasic::optional6(VARIANT* val1, VARIANT* val2, VARIANT* val3, VARIANT* val4)
+{
+ HRESULT hr = S_OK;
+ if (FAILED(hr = m_var1.Copy(val1)))
+ return hr;
+ if (FAILED(hr = m_var2.Copy(val2)))
+ return hr;
+ if (FAILED(hr = m_var3.Copy(val3)))
+ return hr;
+ if (FAILED(hr = m_var4.Copy(val4)))
+ return hr;
+ return S_OK;
+}
+
+STDMETHODIMP CBasic::optional7(VARIANT* val1, VARIANT* val2, VARIANT* val3, VARIANT* val4)
+{
+ HRESULT hr = S_OK;
+ if (FAILED(hr = VariantCopy(val1, & m_var1)))
+ return hr;
+ if (FAILED(hr = VariantCopy(val2, & m_var2)))
+ return hr;
+ if (FAILED(hr = VariantCopy(val3, & m_var3)))
+ return hr;
+ if (FAILED(hr = VariantCopy(val4, & m_var4)))
+ return hr;
+
+ return S_OK;
+}
+
+STDMETHODIMP CBasic::get_prpMultiArg1(VARIANT* val1, VARIANT* val2, VARIANT* pVal)
+{
+ HRESULT hr = S_OK;
+ CComVariant tmp1(*val1);
+ CComVariant tmp2(*val2);
+
+ if (FAILED(hr = VariantCopy(val1, & m_var1)))
+ return hr;
+ if (FAILED(hr = VariantCopy(val2, & m_var2)))
+ return hr;
+ m_var1 = tmp1;
+ m_var2 = tmp2;
+ if (FAILED(hr = VariantCopy(pVal, & m_var3)))
+ return hr;
+ return S_OK;
+}
+
+STDMETHODIMP CBasic::put_prpMultiArg1(VARIANT* val1, VARIANT* val2, VARIANT* newVal)
+{
+ HRESULT hr = S_OK;
+ CComVariant tmp1( * val1);
+ CComVariant tmp2( * val2);
+
+ if (FAILED(hr = VariantCopy(val1, & m_var1)))
+ return hr;
+ if (FAILED(hr = VariantCopy(val2, & m_var2)))
+ return hr;
+ m_var1 = tmp1;
+ m_var2 = tmp2;
+
+ m_var3 = *newVal;
+ return S_OK;
+}
+
+// tagVARIANT DISPATCH_PROPERTYPUT DISPID_PROPERTYPUT VARIANTARG LOCALE_USER_DEFAULT
+
+STDMETHODIMP CBasic::get_prpMultiArg2(VARIANT val1, VARIANT* pVal)
+{
+ HRESULT hr = S_OK;
+ m_var1 = val1;
+
+ if (FAILED(hr = VariantCopy(pVal, & m_var2)))
+ return hr;
+ return S_OK;
+}
+
+STDMETHODIMP CBasic::put_prpMultiArg2(VARIANT val1, VARIANT newVal)
+{
+ m_var1 = val1;
+ m_var2 = newVal;
+ return S_OK;
+}
+
+// returns the values set by prpMultiArg2
+STDMETHODIMP CBasic::prpMultiArg2GetValues(VARIANT* val1, VARIANT* valProperty)
+{
+ HRESULT hr = S_OK;
+ if (FAILED(VariantCopy(val1, & m_var1)))
+ return hr;
+ if (FAILED(VariantCopy(valProperty, & m_var2)))
+ return hr;
+ return S_OK;
+}
+
+STDMETHODIMP CBasic::get_prpMultiArg3(LONG* val1, LONG* pVal)
+{
+ long aLong = *val1;
+ *val1 = m_long;
+ m_long = aLong;
+
+ * pVal = m_long2;
+ return S_OK;
+}
+
+STDMETHODIMP CBasic::put_prpMultiArg3(LONG* val1, LONG newVal)
+{
+ long aLong = *val1;
+ *val1 = m_long;
+ m_long = aLong;
+
+ m_long2 = newVal;
+ return S_OK;
+}
+
+STDMETHODIMP CBasic::inUnknown(IUnknown* val)
+{
+ m_unknown = val;
+
+ return S_OK;
+}
+
+STDMETHODIMP CBasic::outUnknown(IUnknown** val)
+{
+ m_unknown.CopyTo(val);
+ return S_OK;
+}
+
+STDMETHODIMP CBasic::inoutUnknown(IUnknown** val)
+{
+ CComPtr<IUnknown> tmp = *val;
+ m_unknown.CopyTo(val);
+ m_unknown = tmp;
+ return S_OK;
+}
+
+STDMETHODIMP CBasic::get_prpUnknown(IUnknown** pVal)
+{
+ m_prpUnknown.CopyTo(pVal);
+ return S_OK;
+}
+
+STDMETHODIMP CBasic::put_prpUnknown(IUnknown* newVal)
+{
+ m_prpUnknown = newVal;
+ return S_OK;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/test/ole/AxTestComponents/Basic.h b/extensions/test/ole/AxTestComponents/Basic.h
new file mode 100644
index 000000000000..eb67ce8bbb21
--- /dev/null
+++ b/extensions/test/ole/AxTestComponents/Basic.h
@@ -0,0 +1,270 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+// Basic.h : Declaration of the CBasic
+
+#ifndef __BASIC_H_
+#define __BASIC_H_
+
+#include "resource.h" // main symbols
+#import "AxTestComponents.tlb" no_namespace no_implementation raw_interfaces_only named_guids
+
+/////////////////////////////////////////////////////////////////////////////
+// CBasic
+class ATL_NO_VTABLE CBasic :
+ public CComObjectRootEx<CComSingleThreadModel>,
+ public CComCoClass<CBasic, &CLSID_Basic>,
+ public IDispatchImpl<IBasic, &IID_IBasic, &LIBID_AXTESTCOMPONENTSLib>
+ {
+public:
+ CBasic();
+ ~CBasic();
+
+ DECLARE_REGISTRY_RESOURCEID(IDR_BASIC)
+
+ DECLARE_PROTECT_FINAL_CONSTRUCT()
+
+ BEGIN_COM_MAP(CBasic)
+ COM_INTERFACE_ENTRY(IBasic)
+ COM_INTERFACE_ENTRY(IDispatch)
+ END_COM_MAP()
+
+ // IBasic
+public:
+ STDMETHOD(outMore)(/*[out]*/long* val1, /*[out]*/long* val2);
+ STDMETHOD(inMulDimArrayByte2)(LPSAFEARRAY val);
+ STDMETHOD(inMulDimArrayByte)(LPSAFEARRAY val);
+ STDMETHOD(inMulDimArrayVariant2)(LPSAFEARRAY val);
+ STDMETHOD(inMulDimArrayLong2)(LPSAFEARRAY val);
+ STDMETHOD(inMulDimArrayVariant)(LPSAFEARRAY val);
+ STDMETHOD(inMulDimArrayLong)( LPSAFEARRAY val);
+ STDMETHOD(inoutSequenceObject)(LPSAFEARRAY* val);
+ STDMETHOD(inoutSequenceDouble)(LPSAFEARRAY * val);
+ STDMETHOD(inoutSequenceFloat)(LPSAFEARRAY * val);
+ STDMETHOD(inoutSequenceString)(LPSAFEARRAY* val);
+ STDMETHOD(inoutSequenceLong)(LPSAFEARRAY * val);
+ STDMETHOD(inoutSequenceShort)(LPSAFEARRAY * val);
+ STDMETHOD(inoutSequenceByte)(LPSAFEARRAY * val);
+ STDMETHOD(outSequenceObject)(/*[out]*/ LPSAFEARRAY* val);
+ STDMETHOD(outSequenceDouble)(/*[out]*/ LPSAFEARRAY* val);
+ STDMETHOD(outSequenceFloat)(/*[out]*/ LPSAFEARRAY* val);
+ STDMETHOD(outSequenceString)(/*[out]*/ LPSAFEARRAY* val);
+ STDMETHOD(outSequenceLong)(/*[out]*/ LPSAFEARRAY* val);
+ STDMETHOD(outSequenceShort)(/*[out]*/ LPSAFEARRAY* val);
+ STDMETHOD(outSequenceByte)(/*[out]*/ LPSAFEARRAY* val);
+ STDMETHOD(inSequenceObject)(LPSAFEARRAY ar);
+ STDMETHOD(inSequenceDouble)(LPSAFEARRAY ar);
+ STDMETHOD(inSequenceFloat)(LPSAFEARRAY ar);
+ STDMETHOD(inSequenceString)(LPSAFEARRAY ar);
+ STDMETHOD(inSequenceShort)(LPSAFEARRAY ar);
+ STDMETHOD(inSequenceByte)(LPSAFEARRAY ar);
+ STDMETHOD(inSequenceLong)(LPSAFEARRAY ar);
+ STDMETHOD(mixed1)(
+ /* [out][in] */ unsigned char *aChar,
+ /* [out][in] */ float *aFloat,
+ /* [out][in] */ VARIANT *aVar);
+ STDMETHOD(get_prpObject)(/*[out, retval]*/ IDispatch* *pVal);
+ STDMETHOD(put_prpObject)(/*[in]*/ IDispatch* newVal);
+ STDMETHOD(get_prpArray)(/*[out, retval]*/ LPSAFEARRAY *pVal);
+ STDMETHOD(put_prpArray)(/*[in]*/ LPSAFEARRAY newVal);
+ STDMETHOD(get_prpVariant)(/*[out, retval]*/ VARIANT *pVal);
+ STDMETHOD(put_prpVariant)(/*[in]*/ VARIANT newVal);
+ STDMETHOD(get_prpDouble)(/*[out, retval]*/ double *pVal);
+ STDMETHOD(put_prpDouble)(/*[in]*/ double newVal);
+ STDMETHOD(get_prpFloat)(/*[out, retval]*/ float *pVal);
+ STDMETHOD(put_prpFloat)(/*[in]*/ float newVal);
+ STDMETHOD(get_prpString)(/*[out, retval]*/ BSTR *pVal);
+ STDMETHOD(put_prpString)(/*[in]*/ BSTR newVal);
+ STDMETHOD(get_prpLong)(/*[out, retval]*/ long *pVal);
+ STDMETHOD(put_prpLong)(/*[in]*/ long newVal);
+ STDMETHOD(get_prpShort)(/*[out, retval]*/ short *pVal);
+ STDMETHOD(put_prpShort)(/*[in]*/ short newVal);
+ STDMETHOD(get_prpByte)(/*[out, retval]*/ unsigned char *pVal);
+ STDMETHOD(put_prpByte)(/*[in]*/ unsigned char newVal);
+ STDMETHOD(get_prpBool)(/*[out, retval]*/ VARIANT_BOOL *pVal);
+ STDMETHOD(put_prpBool)(/*[in]*/ VARIANT_BOOL newVal);
+
+ STDMETHOD(outObject)(/*[out]*/ IDispatch* *val);
+ STDMETHOD(outArray)(/*[out]*/ LPSAFEARRAY * val);
+ STDMETHOD(outVariant)(/*[out]*/ VARIANT* val);
+ STDMETHOD(outDouble)(/*[out]*/ double* val);
+ STDMETHOD(outFloat)(/*[out]*/ float* val);
+ STDMETHOD(outString)(/*[out]*/ BSTR* val);
+ STDMETHOD(outLong)(/*[out]*/ long* val);
+ STDMETHOD(outShort)(/*[out]*/ short* val);
+ STDMETHOD(outByte)(/*[out]*/ unsigned char* val);
+ STDMETHOD(outBool)(/*[out]*/ VARIANT_BOOL* val);
+
+ STDMETHOD(inoutObject)(/*[in,out]*/ IDispatch* *val);
+ STDMETHOD(inoutArray)(/*[in,out]*/ LPSAFEARRAY * val);
+ STDMETHOD(inoutVariant)(/*[in,out]*/ VARIANT * val);
+ STDMETHOD(inoutDouble)(/*[in,out]*/ double * val);
+ STDMETHOD(inoutFloat)(/*[in,out]*/ float * val);
+ STDMETHOD(inoutString)(/*[in, out]*/ BSTR* val);
+ STDMETHOD(inoutLong)(/*[in,out]*/ long * val);
+ STDMETHOD(inoutShort)(/*[in,out]*/ short* val);
+ STDMETHOD(inoutByte)(/*[in,out]*/ unsigned char* val);
+ STDMETHOD(inoutBool)(/*[in,out]*/ VARIANT_BOOL* val);
+
+
+ STDMETHOD(inObject)(/*[in]*/ IDispatch* val);
+ STDMETHOD(inArray)(/*[in]*/ LPSAFEARRAY val);
+ STDMETHOD(inVariant)(/*[in]*/ VARIANT val);
+ STDMETHOD(inDouble)(/*[in]*/ double val);
+ STDMETHOD(inFloat)(/*[in]*/ float val);
+ STDMETHOD(inString)(/*[in]*/ BSTR val);
+ STDMETHOD(inLong)(/*[in]*/ long val);
+ STDMETHOD(inShort)(/*[in]*/ short val);
+ STDMETHOD(inByte)(/*[in]*/ unsigned char val);
+ STDMETHOD(inBool)(/*[in]*/ VARIANT_BOOL val);
+
+
+ STDMETHOD(optional1)(/*[in]*/ long val1, /*[in, optional]*/ VARIANT* val2);
+ STDMETHOD(optional2)(/*[out]*/ long* val1,/*[out, optional]*/ VARIANT* val2);
+ STDMETHOD(optional3)(/*[in, optional]*/ VARIANT* val1,/*[in, optional]*/ VARIANT* val2);
+ STDMETHOD(optional4)(/*[in, out, optional]*/ VARIANT* val1,/*[in, out, optional]*/ VARIANT* val2);
+ STDMETHOD(optional5)(/*[out, optional]*/ VARIANT* val1,/*[out, optional]*/ VARIANT* val2);
+
+
+ STDMETHOD(defaultvalue1)(/*[in, defaultvalue(10)]*/ long val1,
+ /*[in, defaultvalue(3.14)]*/ double* val2,
+ // /*[in, defaultvalue(10)]*/ VARIANT val3,
+ /*[in, defaultvalue(100)]*/ VARIANT* val4);
+
+ STDMETHOD(defaultvalue2)(/*[in, out, defaultvalue(10)]*/ long* val1,
+ /*[in, out, defaultvalue(3.14)]*/ double* val2,
+ // /*[in, out, defaultvalue(10)]*/ VARIANT* val3,
+ /*[in, out, defaultvalue(100)]*/ VARIANT* val4);
+
+ STDMETHOD(varargfunc1)(/*[in]*/ long val1,/*[in]*/ LPSAFEARRAY val2);
+
+ STDMETHOD(varargfunc2)(/*[out]*/ long* val1, /*[out]*/ SAFEARRAY ** val2);
+
+
+ // members for property implementations
+ unsigned char m_cPrpByte;
+ short m_nPrpShort;
+ long m_lPrpLong;
+ float m_fPrpFloat;
+ double m_dPrpDouble;
+ CComPtr<IDispatch> m_PrpObject;
+ CComPtr<IUnknown> m_prpUnknown;
+
+ CComBSTR m_bstrPrpString;
+ CComVariant m_PropVariant;
+ LPSAFEARRAY m_PrpArray;
+protected:
+ VARIANT_BOOL m_bool;
+ unsigned char m_byte;
+ short m_short;
+ long m_long;
+ long m_long2;
+ float m_float;
+ double m_double;
+ CComVariant m_var1;
+ CComVariant m_var2;
+ CComVariant m_var3;
+ CComVariant m_var4;
+ CComBSTR m_bstr;
+ CY m_cy;
+ DATE m_date;
+ DECIMAL m_decimal;
+ SCODE m_scode;
+ SAFEARRAY * m_safearray;
+ CComPtr<IDispatch> m_obj;
+ CComPtr<IUnknown> m_unknown;
+
+ SAFEARRAY * m_arByte;
+ SAFEARRAY * m_arShort;
+ SAFEARRAY * m_arLong;
+ SAFEARRAY * m_arString;
+ SAFEARRAY * m_arVariant;
+ SAFEARRAY * m_arFloat;
+ SAFEARRAY * m_arDouble;
+ SAFEARRAY * m_arObject;
+ SAFEARRAY * m_arByteDim2;
+
+ static void printArray(LPSAFEARRAY val, BSTR message, VARTYPE type);
+ static void printMulArray(LPSAFEARRAY val, VARTYPE type);
+
+
+public:
+ STDMETHOD(inSequenceByteDim2)(LPSAFEARRAY val);
+ STDMETHOD(inCurrency)(CY val);
+ STDMETHOD(outCurrency)(CY* val);
+ STDMETHOD(inoutCurrency)(CY* val);
+ STDMETHOD(inDate)(DATE val);
+ STDMETHOD(outDate)(DATE* val);
+ STDMETHOD(inoutDate)(DATE* val);
+ STDMETHOD(get_prpCurrency)(CY* pVal);
+ STDMETHOD(put_prpCurrency)(CY newVal);
+ STDMETHOD(get_prpDate)(DATE* pVal);
+ STDMETHOD(put_prpDate)(DATE newVal);
+ STDMETHOD(inDecimal)(DECIMAL val);
+ STDMETHOD(outDecimal)(DECIMAL* val);
+ STDMETHOD(inoutDecimal)(DECIMAL* val);
+ STDMETHOD(get_prpDecimal)(DECIMAL* pVal);
+ STDMETHOD(put_prpDecimal)(DECIMAL newVal);
+ STDMETHOD(inSCode)(SCODE val);
+ STDMETHOD(outScode)(SCODE* val);
+ STDMETHOD(inoutSCode)(SCODE* val);
+ STDMETHOD(get_prpSCode)(SCODE* pVal);
+ STDMETHOD(put_prpSCode)(SCODE newVal);
+ STDMETHOD(inrefLong)(LONG* val);
+ STDMETHOD(inrefVariant)(VARIANT* val);
+ STDMETHOD(inrefDecimal)(DECIMAL* val);
+ STDMETHOD(get_prpRefLong)(long* pVal);
+ STDMETHOD(putref_prpRefLong)(long* newVal);
+ STDMETHOD(get_prprefVariant)(VARIANT* pVal);
+ STDMETHOD(putref_prprefVariant)(VARIANT* newVal);
+ STDMETHOD(get_prprefDecimal)(DECIMAL* pVal);
+ STDMETHOD(putref_prprefDecimal)(DECIMAL* newVal);
+ STDMETHOD(optional6)(VARIANT* val1, VARIANT* val2, VARIANT* val3, VARIANT* val4);
+ STDMETHOD(optional7)(VARIANT* val1, VARIANT* val2, VARIANT* val3, VARIANT* val4);
+
+ STDMETHOD(get_prpMultiArg1)(VARIANT* val1, VARIANT* val2, VARIANT* pVal);
+ //STDMETHOD(get_prpMultiArg1)(VARIANT* val1, VARIANT* pVal);
+ STDMETHOD(put_prpMultiArg1)(VARIANT* val1, VARIANT* val2, VARIANT* newVal);
+ //STDMETHOD(put_prpMultiArg1)(VARIANT* val1, VARIANT* newVal);
+ STDMETHOD(get_prpMultiArg2)(VARIANT val1, VARIANT* pVal);
+ STDMETHOD(put_prpMultiArg2)(VARIANT val1, VARIANT newVal);
+ STDMETHOD(prpMultiArg2GetValues)(VARIANT* val1, VARIANT* valProperty);
+ STDMETHOD(get_prpMultiArg3)(LONG* val1, LONG* pVal);
+ STDMETHOD(put_prpMultiArg3)(LONG* val1, LONG newVal);
+
+ // IFoo Methods
+public:
+ STDMETHOD(inUnknown)(IUnknown* val);
+ STDMETHOD(outUnknown)(IUnknown** val);
+ STDMETHOD(inoutUnknown)(IUnknown** val);
+ STDMETHOD(get_prpUnknown)(IUnknown** pVal);
+ STDMETHOD(put_prpUnknown)(IUnknown* newVal);
+};
+
+#endif //__BASIC_H_
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/test/ole/AxTestComponents/Basic.rgs b/extensions/test/ole/AxTestComponents/Basic.rgs
new file mode 100644
index 000000000000..67fa8600897e
--- /dev/null
+++ b/extensions/test/ole/AxTestComponents/Basic.rgs
@@ -0,0 +1,50 @@
+HKCR
+{
+ AxTestComponents.Basic.1 = s 'Basic Class'
+ {
+ CLSID = s '{BFE10EBE-8584-11D4-8335-005004526AB4}'
+ }
+ AxTestComponents.Basic = s 'Basic Class'
+ {
+ CLSID = s '{BFE10EBE-8584-11D4-8335-005004526AB4}'
+ CurVer = s 'AxTestComponents.Basic.1'
+ }
+ NoRemove CLSID
+ {
+ ForceRemove {BFE10EBE-8584-11D4-8335-005004526AB4} = s 'Basic Class'
+ {
+ ProgID = s 'AxTestComponents.Basic.1'
+ VersionIndependentProgID = s 'AxTestComponents.Basic'
+ ForceRemove 'Programmable'
+ InprocServer32 = s '%MODULE%'
+ {
+ val ThreadingModel = s 'Apartment'
+ }
+ 'TypeLib' = s '{BFE10EB1-8584-11D4-8335-005004526AB4}'
+ }
+ }
+ AxTestComponents.Foo.1 = s 'Foo Class'
+ {
+ CLSID = s '{14DE9D5D-EB9D-4091-8E1B-A1B1672D8C1D}'
+ }
+ AxTestComponents.Foo = s 'Foo Class'
+ {
+ CLSID = s '{14DE9D5D-EB9D-4091-8E1B-A1B1672D8C1D}'
+ CurVer = s 'AxTestComponents.Foo.1'
+ }
+ NoRemove CLSID
+ {
+ ForceRemove {14DE9D5D-EB9D-4091-8E1B-A1B1672D8C1D} = s 'Foo Class'
+ {
+ ProgID = s 'AxTestComponents.Foo.1'
+ VersionIndependentProgID = s 'AxTestComponents.Foo'
+ ForceRemove 'Programmable'
+ InprocServer32 = s '%MODULE%'
+ {
+ val ThreadingModel = s 'Apartment'
+ }
+ 'TypeLib' = s '{BFE10EB1-8584-11D4-8335-005004526AB4}'
+ }
+ }
+
+}
diff --git a/extensions/test/ole/AxTestComponents/Foo.cpp b/extensions/test/ole/AxTestComponents/Foo.cpp
new file mode 100644
index 000000000000..6eacea7727be
--- /dev/null
+++ b/extensions/test/ole/AxTestComponents/Foo.cpp
@@ -0,0 +1,49 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "stdafx.h"
+#include "Foo.h"
+
+
+/////////////////////////////////////////////////////////////////////////////
+// CBasic
+CFoo::CFoo()
+{
+}
+
+CFoo::~CFoo()
+{
+
+}
+
+STDMETHODIMP CFoo::Foo(IUnknown *pVal)
+{
+ return S_OK;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/test/ole/AxTestComponents/Foo.h b/extensions/test/ole/AxTestComponents/Foo.h
new file mode 100644
index 000000000000..a4024ea01a7a
--- /dev/null
+++ b/extensions/test/ole/AxTestComponents/Foo.h
@@ -0,0 +1,66 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+// Basic.h : Declaration of the CBasic
+
+#ifndef __Foo_H_
+#define __Foo_H_
+
+#include "resource.h" // main symbols
+#import "AxTestComponents.tlb" no_namespace no_implementation raw_interfaces_only named_guids
+
+/////////////////////////////////////////////////////////////////////////////
+// CBasic
+class ATL_NO_VTABLE CFoo :
+ public CComObjectRootEx<CComSingleThreadModel>,
+ public CComCoClass<CFoo, &CLSID_Foo>,
+ public IFoo
+
+// public IDispatchImpl<IFoo, &__uuidof(IFoo), &LIBID_AXTESTCOMPONENTSLib, /* wMajor = */ 1, /* wMinor = */ 0>
+{
+public:
+ CFoo();
+ ~CFoo();
+
+ DECLARE_REGISTRY_RESOURCEID(IDR_BASIC)
+
+ DECLARE_PROTECT_FINAL_CONSTRUCT()
+
+ BEGIN_COM_MAP(CFoo)
+ COM_INTERFACE_ENTRY(IFoo)
+ END_COM_MAP()
+
+
+STDMETHOD(Foo)(IUnknown* val);
+
+ // IFoo Methods
+public:
+};
+
+#endif //__BASIC_H_
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/test/ole/AxTestComponents/StdAfx.cpp b/extensions/test/ole/AxTestComponents/StdAfx.cpp
new file mode 100644
index 000000000000..d881698b27d3
--- /dev/null
+++ b/extensions/test/ole/AxTestComponents/StdAfx.cpp
@@ -0,0 +1,35 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "stdafx.h"
+
+#ifdef _ATL_STATIC_REGISTRY
+#include <statreg.h>
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/test/ole/AxTestComponents/StdAfx.h b/extensions/test/ole/AxTestComponents/StdAfx.h
new file mode 100644
index 000000000000..a46eeeb618af
--- /dev/null
+++ b/extensions/test/ole/AxTestComponents/StdAfx.h
@@ -0,0 +1,59 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+// stdafx.h : include file for standard system include files,
+// or project specific include files that are used frequently,
+// but are changed infrequently
+
+#if !defined(AFX_STDAFX_H__BFE10EB4_8584_11D4_8335_005004526AB4__INCLUDED_)
+#define AFX_STDAFX_H__BFE10EB4_8584_11D4_8335_005004526AB4__INCLUDED_
+
+#if _MSC_VER > 1000
+#pragma once
+#endif // _MSC_VER > 1000
+
+#define STRICT
+#ifndef _WIN32_WINNT
+#define _WIN32_WINNT 0x0400
+#endif
+#define _ATL_APARTMENT_THREADED
+
+#include <atlbase.h>
+//You may derive a class from CComModule and use it if you want to override
+//something, but do not change the name of _Module
+extern CComModule _Module;
+#include <atlcom.h>
+#include <stdio.h>
+#include <tchar.h>
+#include <string.h>
+
+//{{AFX_INSERT_LOCATION}}
+// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
+
+#endif // !defined(AFX_STDAFX_H__BFE10EB4_8584_11D4_8335_005004526AB4__INCLUDED)
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/test/ole/AxTestComponents/readme.txt b/extensions/test/ole/AxTestComponents/readme.txt
new file mode 100644
index 000000000000..363a0ed33bb6
--- /dev/null
+++ b/extensions/test/ole/AxTestComponents/readme.txt
@@ -0,0 +1,4 @@
+
+The component does not use the AxTestComponent.h created by the midl
+compiler. Instead #import is used. This is because of a bug when
+using attribute "defaultvalue" in idl. \ No newline at end of file
diff --git a/extensions/test/ole/AxTestComponents/resource.h b/extensions/test/ole/AxTestComponents/resource.h
new file mode 100644
index 000000000000..b926189183ec
--- /dev/null
+++ b/extensions/test/ole/AxTestComponents/resource.h
@@ -0,0 +1,47 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+//{{NO_DEPENDENCIES}}
+// Microsoft Developer Studio generated include file.
+// Used by AxTestComponents.rc
+//
+#define IDS_PROJNAME 100
+#define IDR_BASIC 101
+//#define IDR_FOO 501
+
+// Next default values for new objects
+//
+#ifdef APSTUDIO_INVOKED
+#ifndef APSTUDIO_READONLY_SYMBOLS
+#define _APS_NEXT_RESOURCE_VALUE 201
+#define _APS_NEXT_COMMAND_VALUE 32768
+#define _APS_NEXT_CONTROL_VALUE 201
+#define _APS_NEXT_SYMED_VALUE 102
+#endif
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/test/ole/DCOM/Clients/WriterDemo/Module1.bas b/extensions/test/ole/DCOM/Clients/WriterDemo/Module1.bas
new file mode 100644
index 000000000000..e9bb197ed692
--- /dev/null
+++ b/extensions/test/ole/DCOM/Clients/WriterDemo/Module1.bas
@@ -0,0 +1,8 @@
+Attribute VB_Name = "Module1"
+Option Explicit
+
+Sub main()
+ Dim obj As Object
+ Set obj = CreateObject("dcomtest.writerdemo.wsc")
+ obj.run
+End Sub
diff --git a/extensions/test/ole/DCOM/Clients/WriterDemo/client_writerdemo.vbp b/extensions/test/ole/DCOM/Clients/WriterDemo/client_writerdemo.vbp
new file mode 100644
index 000000000000..ca477cff6b66
--- /dev/null
+++ b/extensions/test/ole/DCOM/Clients/WriterDemo/client_writerdemo.vbp
@@ -0,0 +1,33 @@
+Type=Exe
+Reference=*\G{00020430-0000-0000-C000-000000000046}#2.0#0#C:\WINNT\System32\stdole2.tlb#OLE Automation
+Module=Module1; Module1.bas
+Startup="Sub Main"
+HelpFile=""
+Command32=""
+Name="client_writerdemo"
+HelpContextID="0"
+CompatibleMode="0"
+MajorVer=1
+MinorVer=0
+RevisionVer=0
+AutoIncrementVer=0
+ServerSupportFiles=0
+VersionCompanyName="StarOffice"
+CompilationType=0
+OptimizationType=0
+FavorPentiumPro(tm)=0
+CodeViewDebugInfo=0
+NoAliasing=0
+BoundsCheck=0
+OverflowCheck=0
+FlPointCheck=0
+FDIVCheck=0
+UnroundedFP=0
+StartMode=0
+Unattended=0
+Retained=0
+ThreadPerObject=0
+MaxNumberOfThreads=1
+
+[MS Transaction Server]
+AutoRefresh=1
diff --git a/extensions/test/ole/DCOM/Clients/WriterDemo/client_writerdemo.vbw b/extensions/test/ole/DCOM/Clients/WriterDemo/client_writerdemo.vbw
new file mode 100644
index 000000000000..067d7529ee0b
--- /dev/null
+++ b/extensions/test/ole/DCOM/Clients/WriterDemo/client_writerdemo.vbw
@@ -0,0 +1 @@
+Module1 = 108, 108, 685, 544,
diff --git a/extensions/test/ole/DCOM/Clients/WriterDemo/readme.txt b/extensions/test/ole/DCOM/Clients/WriterDemo/readme.txt
new file mode 100644
index 000000000000..1d5a63492126
--- /dev/null
+++ b/extensions/test/ole/DCOM/Clients/WriterDemo/readme.txt
@@ -0,0 +1,4 @@
+Visual Basic client that instantiates a Windows Script Component
+,dcomtest.writerdemo.wsc. That component is located in
+extensions/test/ole/DCOM/scriptComponents/WriterDemo.wsc. Don't forget to
+register that component (right-click,select register).
diff --git a/extensions/test/ole/DCOM/dcom_test/Module1.bas b/extensions/test/ole/DCOM/dcom_test/Module1.bas
new file mode 100644
index 000000000000..c41c3a073967
--- /dev/null
+++ b/extensions/test/ole/DCOM/dcom_test/Module1.bas
@@ -0,0 +1,38 @@
+Attribute VB_Name = "Module1"
+Option Explicit
+
+Sub main()
+
+MsgBox "hallo"
+
+'The service manager is always the starting point
+'If there is no office running then an office is started up
+Dim objServiceManager As Object
+Set objServiceManager = CreateObject("com.sun.star.ServiceManager")
+
+'Create the CoreReflection service that is later used to create structs
+Set objCoreReflection = objServiceManager.createInstance("com.sun.star.reflection.CoreReflection")
+
+'Create the Desktop
+Set objDesktop = objServiceManager.createInstance("com.sun.star.frame.Desktop")
+
+'Open a new empty writer document
+
+Set objCoreReflection = objServiceManager.createInstance("com.sun.star.reflection.CoreReflection")
+'get a type description class for Size
+Set propClass = objCoreReflection.forName("com.sun.star.beans.PropertyValue")
+
+Dim prop
+propClass.CreateObject prop
+prop.Name = "Hidden"
+prop.Value = True
+
+'create the actual object
+Dim args(0)
+Set args(0) = prop
+
+Dim args2()
+'Set objDocument= objDesktop.loadComponentFromURL("private:factory/swriter", "_blank", 0, args)
+Set objDocument = objDesktop.loadComponentFromURL("private:factory/swriter", "_blank", 0, args2)
+
+End Sub
diff --git a/extensions/test/ole/DCOM/dcom_test/dcom_test.vbp b/extensions/test/ole/DCOM/dcom_test/dcom_test.vbp
new file mode 100644
index 000000000000..5b896434fb6d
--- /dev/null
+++ b/extensions/test/ole/DCOM/dcom_test/dcom_test.vbp
@@ -0,0 +1,37 @@
+Type=Exe
+Reference=*\G{00020430-0000-0000-C000-000000000046}#2.0#0#C:\WINNT\System32\stdole2.tlb#OLE Automation
+Module=Module1; ..\..\..\..\..\..\Projects\VBasic\dcom_test\Module1.bas
+Startup="Sub Main"
+HelpFile=""
+Title="dcom_test"
+ExeName32="dcom_test.exe"
+Path32="..\..\..\..\..\..\Projects\VBasic\dcom_test"
+Command32=""
+Name="dcom_test"
+HelpContextID="0"
+CompatibleMode="0"
+MajorVer=1
+MinorVer=0
+RevisionVer=0
+AutoIncrementVer=0
+ServerSupportFiles=0
+VersionCompanyName="StarOffice"
+CompilationType=0
+OptimizationType=0
+FavorPentiumPro(tm)=0
+CodeViewDebugInfo=0
+NoAliasing=0
+BoundsCheck=0
+OverflowCheck=0
+FlPointCheck=0
+FDIVCheck=0
+UnroundedFP=0
+StartMode=0
+Unattended=0
+Retained=0
+ThreadPerObject=0
+MaxNumberOfThreads=1
+DebugStartupOption=0
+
+[MS Transaction Server]
+AutoRefresh=1
diff --git a/extensions/test/ole/DCOM/dcom_test/dcom_test.vbw b/extensions/test/ole/DCOM/dcom_test/dcom_test.vbw
new file mode 100644
index 000000000000..dfe34e0d1de2
--- /dev/null
+++ b/extensions/test/ole/DCOM/dcom_test/dcom_test.vbw
@@ -0,0 +1 @@
+Module1 = 1, 1, 849, 604, Z
diff --git a/extensions/test/ole/DCOM/dcom_test/readme.txt b/extensions/test/ole/DCOM/dcom_test/readme.txt
new file mode 100644
index 000000000000..215d6f409f2c
--- /dev/null
+++ b/extensions/test/ole/DCOM/dcom_test/readme.txt
@@ -0,0 +1,5 @@
+The program creates the com.sun.star.Servicemanager on a remote machine:
+
+Set objServiceManager = CreateObject("com.sun.star.ServiceManager", "\\jl-1036")
+
+creates a document and writes in it. \ No newline at end of file
diff --git a/extensions/test/ole/DCOM/scriptComponents/WriterDemo.wsc b/extensions/test/ole/DCOM/scriptComponents/WriterDemo.wsc
new file mode 100644
index 000000000000..bb331779397e
--- /dev/null
+++ b/extensions/test/ole/DCOM/scriptComponents/WriterDemo.wsc
@@ -0,0 +1,186 @@
+<?xml version="1.0"?>
+<component>
+
+<?component error="true" debug="true"?>
+
+<registration
+ description="writerdemo script component"
+ progid="dcomtest.writerdemo.WSC"
+ version="1.00"
+ classid="{90c5ca1a-5e38-4c6d-9634-b0c740c569ad}"
+ remotable="true"
+>
+</registration>
+
+<public>
+ <method name="run">
+ </method>
+</public>
+
+<script language="JScript">
+<![CDATA[
+
+var description = new jscripttest;
+
+function jscripttest()
+{
+
+ this.run = run;
+}
+
+function run()
+{
+//The service manager is always the starting point
+//If there is no office running then an office is started up
+
+var objServiceManager= new ActiveXObject("com.sun.star.ServiceManager","\\jl-1036");
+
+//Create the CoreReflection service that is later used to create structs
+var objCoreReflection= objServiceManager.createInstance("com.sun.star.reflection.CoreReflection");
+
+//Create the Desktop
+var objDesktop= objServiceManager.createInstance("com.sun.star.frame.Desktop");
+
+//Open a new empty writer document
+var objCoreReflection= objServiceManager.createInstance("com.sun.star.reflection.CoreReflection");
+
+//get a type description class for Size
+//var propClass = objCoreReflection.forName( "com.sun.star.beans.PropertyValue" );
+
+//var propParam= new Array();
+//propClass.createObject(propParam);
+//var prop= propParam[0];
+//prop.Name= "Hidden";
+//prop.Value= true;
+
+//create the actual object
+var args= new Array();
+var objDocument= objDesktop.loadComponentFromURL("private:factory/swriter", "_blank", 0, args);
+
+//Create a text object
+var objText= objDocument.getText();
+
+//Create a cursor object
+var objCursor= objText.createTextCursor();
+
+//Inserting some Text
+objText.insertString( objCursor, "The first line in the newly created text document.\n", false);
+
+//Inserting a second line
+objText.insertString( objCursor, "Now we're in the second line", false);
+
+//Create instance of a text table with 4 columns and 4 rows
+var objTable= objDocument.createInstance( "com.sun.star.text.TextTable");
+objTable.initialize( 4, 4);
+
+//Insert the table
+objText.insertTextContent( objCursor, objTable, false);
+
+//Get first row
+var objRows= objTable.getRows();
+var objRow= objRows.getByIndex( 0);
+
+//Set the table background color
+objTable.setPropertyValue( "BackTransparent", false);
+objTable.setPropertyValue( "BackColor", 13421823);
+
+//Set a different background color for the first row
+objRow.setPropertyValue( "BackTransparent", false);
+objRow.setPropertyValue( "BackColor", 6710932);
+
+//Fill the first table row
+insertIntoCell( "A1","FirstColumn", objTable);
+insertIntoCell( "B1","SecondColumn", objTable);
+insertIntoCell( "C1","ThirdColumn", objTable);
+insertIntoCell( "D1","SUM", objTable);
+
+
+objTable.getCellByName("A2").setValue( 22.5);
+objTable.getCellByName("B2").setValue( 5615.3);
+objTable.getCellByName("C2").setValue( -2315.7);
+objTable.getCellByName("D2").setFormula("sum <A2:C2>");
+
+objTable.getCellByName("A3").setValue( 21.5);
+objTable.getCellByName("B3").setValue( 615.3);
+objTable.getCellByName("C3").setValue( -315.7);
+objTable.getCellByName("D3").setFormula( "sum <A3:C3>");
+
+objTable.getCellByName("A4").setValue( 121.5);
+objTable.getCellByName("B4").setValue( -615.3);
+objTable.getCellByName("C4").setValue( 415.7);
+objTable.getCellByName("D4").setFormula( "sum <A4:C4>");
+
+//Change the CharColor and add a Shadow
+objCursor.setPropertyValue( "CharColor", 255);
+objCursor.setPropertyValue( "CharShadowed", true);
+
+//Create a paragraph break
+//The second argument is a com::sun::star::text::ControlCharacter::PARAGRAPH_BREAK constant
+objText.insertControlCharacter( objCursor, 0 , false);
+
+//Inserting colored Text.
+objText.insertString( objCursor, " This is a colored Text - blue with shadow\n", false);
+
+//Create a paragraph break ( ControlCharacter::PARAGRAPH_BREAK).
+objText.insertControlCharacter( objCursor, 0, false );
+
+//Create a TextFrame.
+var objTextFrame= objDocument.createInstance("com.sun.star.text.TextFrame");
+
+//Create a Size struct.
+var objSize= createStruct("com.sun.star.awt.Size");
+objSize.Width= 15000;
+objSize.Height= 400;
+objTextFrame.setSize( objSize);
+
+//TextContentAnchorType.AS_CHARACTER = 1
+objTextFrame.setPropertyValue( "AnchorType", 1);
+
+//insert the frame
+objText.insertTextContent( objCursor, objTextFrame, false);
+
+//Get the text object of the frame
+var objFrameText= objTextFrame.getText();
+
+//Create a cursor object
+var objFrameTextCursor= objFrameText.createTextCursor();
+
+//Inserting some Text
+objFrameText.insertString( objFrameTextCursor, "The first line in the newly created text frame.",
+ false);
+objFrameText.insertString(objFrameTextCursor,
+ "With this second line the height of the frame raises.", false );
+
+//Create a paragraph break
+//The second argument is a com::sun::star::text::ControlCharacter::PARAGRAPH_BREAK constant
+objFrameText.insertControlCharacter( objCursor, 0 , false);
+
+//Change the CharColor and add a Shadow
+objCursor.setPropertyValue( "CharColor", 65536);
+objCursor.setPropertyValue( "CharShadowed", false);
+
+//Insert another string
+objText.insertString( objCursor, " That's all for now !!", false );
+
+function insertIntoCell( strCellName, strText, objTable)
+{
+ var objCellText= objTable.getCellByName( strCellName);
+ var objCellCursor= objCellText.createTextCursor();
+ objCellCursor.setPropertyValue( "CharColor",16777215);
+ objCellText.insertString( objCellCursor, strText, false);
+}
+function createStruct( strTypeName)
+{
+ var classSize= objCoreReflection.forName( strTypeName);
+ var aStruct= new Array();
+ classSize.createObject( aStruct);
+ return aStruct[0];
+}
+
+
+}
+
+]]>
+</script>
+
+</component>
diff --git a/extensions/test/ole/DCOM/scriptComponents/readme.txt b/extensions/test/ole/DCOM/scriptComponents/readme.txt
new file mode 100644
index 000000000000..81dff56b47f4
--- /dev/null
+++ b/extensions/test/ole/DCOM/scriptComponents/readme.txt
@@ -0,0 +1,13 @@
+WriterDemo.wsc
+=================================================================================
+Register the component by right-clicking on the file in the file explorer and select
+register.
+The component registered as being remotable.That is, it has got an AppID entry (with
+a DllSurrogate subkey).That enables us to use dcomcnfg.exe in order to set AccessPermissions,etc.
+which is necessary because of the use of the JScript Array object. The automation
+bridge will query for IDispatchEx,which is a call from server to client.Hence the server
+needs the proper right within the client.
+
+The component implements a run function, which runs the demo example that is written
+in JScript.
+
diff --git a/extensions/test/ole/EventListenerSample/EventListener/EventListener.cpp b/extensions/test/ole/EventListenerSample/EventListener/EventListener.cpp
new file mode 100644
index 000000000000..9512ec4c2372
--- /dev/null
+++ b/extensions/test/ole/EventListenerSample/EventListener/EventListener.cpp
@@ -0,0 +1,74 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+// EventListener.cpp : Implementation of DLL Exports.
+
+
+// Note: Proxy/Stub Information
+// To build a separate proxy/stub DLL,
+// run nmake -f EventListenerps.mk in the project directory.
+
+#include "stdafx.h"
+#include "resource.h"
+#include <initguid.h>
+#include "EventListener.h"
+
+#include "EventListener_i.c"
+#include "EvtListener.h"
+
+
+CComModule _Module;
+
+BEGIN_OBJECT_MAP(ObjectMap)
+OBJECT_ENTRY(CLSID_EvtListener, CEvtListener)
+END_OBJECT_MAP()
+
+/////////////////////////////////////////////////////////////////////////////
+// DLL Entry Point
+
+extern "C"
+BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/)
+{
+ if (dwReason == DLL_PROCESS_ATTACH)
+ {
+ _Module.Init(ObjectMap, hInstance, &LIBID_EVENTLISTENERLib);
+ DisableThreadLibraryCalls(hInstance);
+ }
+ else if (dwReason == DLL_PROCESS_DETACH)
+ _Module.Term();
+ return TRUE; // ok
+}
+
+/////////////////////////////////////////////////////////////////////////////
+// Used to determine whether the DLL can be unloaded by OLE
+
+STDAPI DllCanUnloadNow(void)
+{
+ return (_Module.GetLockCount()==0) ? S_OK : S_FALSE;
+}
+
+/////////////////////////////////////////////////////////////////////////////
+// Returns a class factory to create an object of the requested type
+
+STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv)
+{
+ return _Module.GetClassObject(rclsid, riid, ppv);
+}
+
+/////////////////////////////////////////////////////////////////////////////
+// DllRegisterServer - Adds entries to the system registry
+
+STDAPI DllRegisterServer(void)
+{
+ // registers object, typelib and all interfaces in typelib
+ return _Module.RegisterServer(TRUE);
+}
+
+/////////////////////////////////////////////////////////////////////////////
+// DllUnregisterServer - Removes entries from the system registry
+
+STDAPI DllUnregisterServer(void)
+{
+ return _Module.UnregisterServer(TRUE);
+}
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/test/ole/EventListenerSample/EventListener/EventListener.def b/extensions/test/ole/EventListenerSample/EventListener/EventListener.def
new file mode 100644
index 000000000000..9d88a68f7f39
--- /dev/null
+++ b/extensions/test/ole/EventListenerSample/EventListener/EventListener.def
@@ -0,0 +1,9 @@
+; EventListener.def : Declares the module parameters.
+
+LIBRARY "EventListener.DLL"
+
+EXPORTS
+ DllCanUnloadNow PRIVATE
+ DllGetClassObject PRIVATE
+ DllRegisterServer PRIVATE
+ DllUnregisterServer PRIVATE
diff --git a/extensions/test/ole/EventListenerSample/EventListener/EventListener.idl b/extensions/test/ole/EventListenerSample/EventListener/EventListener.idl
new file mode 100644
index 000000000000..6272173a24d9
--- /dev/null
+++ b/extensions/test/ole/EventListenerSample/EventListener/EventListener.idl
@@ -0,0 +1,39 @@
+// EventListener.idl : IDL source for EventListener.dll
+//
+
+// This file will be processed by the MIDL tool to
+// produce the type library (EventListener.tlb) and marshalling code.
+
+import "oaidl.idl";
+import "ocidl.idl";
+ [
+ object,
+ uuid(86653399-24C6-4C2B-9E8A-564175250CB2),
+ dual,
+ helpstring("IEvtListener-Schnittstelle"),
+ pointer_default(unique)
+ ]
+ interface IEvtListener : IDispatch
+ {
+ [id(1), helpstring("Methode disposing")] HRESULT disposing([in] IDispatch* source);
+ };
+
+[
+ uuid(E3E61535-3262-45E6-BFD9-EE8AED051BD1),
+ version(1.0),
+ helpstring("EventListener 1.0 Type Library")
+]
+library EVENTLISTENERLib
+{
+ importlib("stdole32.tlb");
+ importlib("stdole2.tlb");
+
+ [
+ uuid(830E0743-87C1-4C99-A77A-5FBA0C2EBD9A),
+ helpstring("EvtListener Class")
+ ]
+ coclass EvtListener
+ {
+ [default] interface IEvtListener;
+ };
+};
diff --git a/extensions/test/ole/EventListenerSample/EventListener/EventListener.rc b/extensions/test/ole/EventListenerSample/EventListener/EventListener.rc
new file mode 100644
index 000000000000..90f0c7bd2ce5
--- /dev/null
+++ b/extensions/test/ole/EventListenerSample/EventListener/EventListener.rc
@@ -0,0 +1,136 @@
+//Microsoft Developer Studio generated resource script.
+//
+#include "resource.h"
+
+#define APSTUDIO_READONLY_SYMBOLS
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 2 resource.
+//
+#include "winres.h"
+
+/////////////////////////////////////////////////////////////////////////////
+#undef APSTUDIO_READONLY_SYMBOLS
+
+/////////////////////////////////////////////////////////////////////////////
+// Deutsch (Deutschland) resources
+
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_DEU)
+#ifdef _WIN32
+LANGUAGE LANG_GERMAN, SUBLANG_GERMAN
+#pragma code_page(1252)
+#endif //_WIN32
+
+#ifdef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// TEXTINCLUDE
+//
+
+1 TEXTINCLUDE DISCARDABLE
+BEGIN
+ "resource.h\0"
+END
+
+2 TEXTINCLUDE DISCARDABLE
+BEGIN
+ "#include ""winres.h""\r\n"
+ "\0"
+END
+
+3 TEXTINCLUDE DISCARDABLE
+BEGIN
+ "1 TYPELIB ""EventListener.tlb""\r\n"
+ "\0"
+END
+
+#endif // APSTUDIO_INVOKED
+
+
+#ifndef _MAC
+/////////////////////////////////////////////////////////////////////////////
+//
+// Version
+//
+
+VS_VERSION_INFO VERSIONINFO
+ FILEVERSION 1,0,0,1
+ PRODUCTVERSION 1,0,0,1
+ FILEFLAGSMASK 0x3fL
+#ifdef _DEBUG
+ FILEFLAGS 0x1L
+#else
+ FILEFLAGS 0x0L
+#endif
+ FILEOS 0x4L
+ FILETYPE 0x2L
+ FILESUBTYPE 0x0L
+BEGIN
+ BLOCK "StringFileInfo"
+ BEGIN
+ BLOCK "040904B0"
+ BEGIN
+ VALUE "CompanyName", "\0"
+ VALUE "FileDescription", "EventListener Module\0"
+ VALUE "FileVersion", "1, 0, 0, 1\0"
+ VALUE "InternalName", "EventListener\0"
+ VALUE "LegalCopyright", "Copyright 2001\0"
+ VALUE "OriginalFilename", "EventListener.DLL\0"
+ VALUE "ProductName", "EventListener Module\0"
+ VALUE "ProductVersion", "1, 0, 0, 1\0"
+ VALUE "OLESelfRegister", "\0"
+ END
+ END
+ BLOCK "VarFileInfo"
+ BEGIN
+ VALUE "Translation", 0x409, 1200
+ END
+END
+
+#endif // !_MAC
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// String Table
+//
+
+STRINGTABLE DISCARDABLE
+BEGIN
+ IDS_PROJNAME "EventListener"
+END
+
+#endif // Deutsch (Deutschland) resources
+/////////////////////////////////////////////////////////////////////////////
+
+
+/////////////////////////////////////////////////////////////////////////////
+// Englisch (USA) resources
+
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
+#ifdef _WIN32
+LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
+#pragma code_page(1252)
+#endif //_WIN32
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// REGISTRY
+//
+
+IDR_EVTLISTENER REGISTRY DISCARDABLE "EvtListener.rgs"
+#endif // Englisch (USA) resources
+/////////////////////////////////////////////////////////////////////////////
+
+
+
+#ifndef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 3 resource.
+//
+1 TYPELIB "EventListener.tlb"
+
+/////////////////////////////////////////////////////////////////////////////
+#endif // not APSTUDIO_INVOKED
+
diff --git a/extensions/test/ole/EventListenerSample/EventListener/EventListener.sln b/extensions/test/ole/EventListenerSample/EventListener/EventListener.sln
new file mode 100644
index 000000000000..8420bb49259a
--- /dev/null
+++ b/extensions/test/ole/EventListenerSample/EventListener/EventListener.sln
@@ -0,0 +1,32 @@
+
+Microsoft Visual Studio Solution File, Format Version 10.00
+# Visual Studio 2008
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "EventListener", "EventListener.vcproj", "{055137B6-A402-4913-AC11-9A096E866F5B}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Win32 = Debug|Win32
+ Release MinDependency|Win32 = Release MinDependency|Win32
+ Release MinSize|Win32 = Release MinSize|Win32
+ Unicode Debug|Win32 = Unicode Debug|Win32
+ Unicode Release MinDependency|Win32 = Unicode Release MinDependency|Win32
+ Unicode Release MinSize|Win32 = Unicode Release MinSize|Win32
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {055137B6-A402-4913-AC11-9A096E866F5B}.Debug|Win32.ActiveCfg = Debug|Win32
+ {055137B6-A402-4913-AC11-9A096E866F5B}.Debug|Win32.Build.0 = Debug|Win32
+ {055137B6-A402-4913-AC11-9A096E866F5B}.Release MinDependency|Win32.ActiveCfg = Release MinDependency|Win32
+ {055137B6-A402-4913-AC11-9A096E866F5B}.Release MinDependency|Win32.Build.0 = Release MinDependency|Win32
+ {055137B6-A402-4913-AC11-9A096E866F5B}.Release MinSize|Win32.ActiveCfg = Release MinSize|Win32
+ {055137B6-A402-4913-AC11-9A096E866F5B}.Release MinSize|Win32.Build.0 = Release MinSize|Win32
+ {055137B6-A402-4913-AC11-9A096E866F5B}.Unicode Debug|Win32.ActiveCfg = Unicode Debug|Win32
+ {055137B6-A402-4913-AC11-9A096E866F5B}.Unicode Debug|Win32.Build.0 = Unicode Debug|Win32
+ {055137B6-A402-4913-AC11-9A096E866F5B}.Unicode Release MinDependency|Win32.ActiveCfg = Unicode Release MinDependency|Win32
+ {055137B6-A402-4913-AC11-9A096E866F5B}.Unicode Release MinDependency|Win32.Build.0 = Unicode Release MinDependency|Win32
+ {055137B6-A402-4913-AC11-9A096E866F5B}.Unicode Release MinSize|Win32.ActiveCfg = Unicode Release MinSize|Win32
+ {055137B6-A402-4913-AC11-9A096E866F5B}.Unicode Release MinSize|Win32.Build.0 = Unicode Release MinSize|Win32
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
diff --git a/extensions/test/ole/EventListenerSample/EventListener/EventListener.vcproj b/extensions/test/ole/EventListenerSample/EventListener/EventListener.vcproj
new file mode 100644
index 000000000000..e8aef55323bb
--- /dev/null
+++ b/extensions/test/ole/EventListenerSample/EventListener/EventListener.vcproj
@@ -0,0 +1,927 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="9,00"
+ Name="EventListener"
+ ProjectGUID="{055137B6-A402-4913-AC11-9A096E866F5B}"
+ RootNamespace="EventListener"
+ Keyword="AtlProj"
+ TargetFrameworkVersion="0"
+ >
+ <Platforms>
+ <Platform
+ Name="Win32"
+ />
+ </Platforms>
+ <ToolFiles>
+ </ToolFiles>
+ <Configurations>
+ <Configuration
+ Name="Unicode Release MinSize|Win32"
+ OutputDirectory=".\ReleaseUMinSize"
+ IntermediateDirectory=".\ReleaseUMinSize"
+ ConfigurationType="2"
+ InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
+ UseOfMFC="0"
+ UseOfATL="2"
+ ATLMinimizesCRunTimeLibraryUsage="true"
+ CharacterSet="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ Description="Performing registration"
+ CommandLine="if &quot;%OS%&quot;==&quot;&quot; goto NOTNT&#x0D;&#x0A;if not &quot;%OS%&quot;==&quot;Windows_NT&quot; goto NOTNT&#x0D;&#x0A;regsvr32 /s /c &quot;$(TargetPath)&quot;&#x0D;&#x0A;echo regsvr32 exec. time &gt; &quot;$(OutDir)\regsvr32.trg&quot;&#x0D;&#x0A;goto end&#x0D;&#x0A;:NOTNT&#x0D;&#x0A;echo Warning : Cannot register Unicode DLL on Windows 95&#x0D;&#x0A;:end&#x0D;&#x0A;"
+ Outputs="$(OutDir)\regsvr32.trg"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ TypeLibraryName=".\ReleaseUMinSize/EventListener.tlb"
+ HeaderFileName=""
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="1"
+ InlineFunctionExpansion="1"
+ PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL"
+ StringPooling="true"
+ RuntimeLibrary="0"
+ EnableFunctionLevelLinking="true"
+ UsePrecompiledHeader="2"
+ PrecompiledHeaderThrough="stdafx.h"
+ PrecompiledHeaderFile=".\ReleaseUMinSize/EventListener.pch"
+ AssemblerListingLocation=".\ReleaseUMinSize/"
+ ObjectFile=".\ReleaseUMinSize/"
+ ProgramDataBaseFileName=".\ReleaseUMinSize/"
+ WarningLevel="3"
+ SuppressStartupBanner="true"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ PreprocessorDefinitions="NDEBUG"
+ Culture="1031"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ OutputFile=".\ReleaseUMinSize/EventListener.dll"
+ LinkIncremental="1"
+ SuppressStartupBanner="true"
+ ModuleDefinitionFile=".\EventListener.def"
+ ProgramDatabaseFile=".\ReleaseUMinSize/EventListener.pdb"
+ SubSystem="2"
+ RandomizedBaseAddress="1"
+ DataExecutionPrevention="0"
+ ImportLibrary=".\ReleaseUMinSize/EventListener.lib"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ SuppressStartupBanner="true"
+ OutputFile=".\ReleaseUMinSize/EventListener.bsc"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Unicode Debug|Win32"
+ OutputDirectory=".\DebugU"
+ IntermediateDirectory=".\DebugU"
+ ConfigurationType="2"
+ InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
+ UseOfMFC="0"
+ ATLMinimizesCRunTimeLibraryUsage="false"
+ CharacterSet="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ Description="Performing registration"
+ CommandLine="if &quot;%OS%&quot;==&quot;&quot; goto NOTNT&#x0D;&#x0A;if not &quot;%OS%&quot;==&quot;Windows_NT&quot; goto NOTNT&#x0D;&#x0A;regsvr32 /s /c &quot;$(TargetPath)&quot;&#x0D;&#x0A;echo regsvr32 exec. time &gt; &quot;$(OutDir)\regsvr32.trg&quot;&#x0D;&#x0A;goto end&#x0D;&#x0A;:NOTNT&#x0D;&#x0A;echo Warning : Cannot register Unicode DLL on Windows 95&#x0D;&#x0A;:end&#x0D;&#x0A;"
+ Outputs="$(OutDir)\regsvr32.trg"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ TypeLibraryName=".\DebugU/EventListener.tlb"
+ HeaderFileName=""
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL"
+ MinimalRebuild="true"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="1"
+ UsePrecompiledHeader="2"
+ PrecompiledHeaderThrough="stdafx.h"
+ PrecompiledHeaderFile=".\DebugU/EventListener.pch"
+ AssemblerListingLocation=".\DebugU/"
+ ObjectFile=".\DebugU/"
+ ProgramDataBaseFileName=".\DebugU/"
+ WarningLevel="3"
+ SuppressStartupBanner="true"
+ DebugInformationFormat="4"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ PreprocessorDefinitions="_DEBUG"
+ Culture="1031"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ OutputFile=".\DebugU/EventListener.dll"
+ LinkIncremental="2"
+ SuppressStartupBanner="true"
+ ModuleDefinitionFile=".\EventListener.def"
+ GenerateDebugInformation="true"
+ ProgramDatabaseFile=".\DebugU/EventListener.pdb"
+ SubSystem="2"
+ RandomizedBaseAddress="1"
+ DataExecutionPrevention="0"
+ ImportLibrary=".\DebugU/EventListener.lib"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ SuppressStartupBanner="true"
+ OutputFile=".\DebugU/EventListener.bsc"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release MinDependency|Win32"
+ OutputDirectory=".\ReleaseMinDependency"
+ IntermediateDirectory=".\ReleaseMinDependency"
+ ConfigurationType="2"
+ InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
+ UseOfMFC="0"
+ UseOfATL="1"
+ ATLMinimizesCRunTimeLibraryUsage="true"
+ CharacterSet="2"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ Description="Performing registration"
+ CommandLine="regsvr32 /s /c &quot;$(TargetPath)&quot;&#x0D;&#x0A;echo regsvr32 exec. time &gt; &quot;$(OutDir)\regsvr32.trg&quot;&#x0D;&#x0A;"
+ Outputs="$(OutDir)\regsvr32.trg"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ TypeLibraryName=".\ReleaseMinDependency/EventListener.tlb"
+ HeaderFileName=""
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="1"
+ InlineFunctionExpansion="1"
+ PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL"
+ StringPooling="true"
+ RuntimeLibrary="0"
+ EnableFunctionLevelLinking="true"
+ UsePrecompiledHeader="2"
+ PrecompiledHeaderThrough="stdafx.h"
+ PrecompiledHeaderFile=".\ReleaseMinDependency/EventListener.pch"
+ AssemblerListingLocation=".\ReleaseMinDependency/"
+ ObjectFile=".\ReleaseMinDependency/"
+ ProgramDataBaseFileName=".\ReleaseMinDependency/"
+ WarningLevel="3"
+ SuppressStartupBanner="true"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ PreprocessorDefinitions="NDEBUG"
+ Culture="1031"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ OutputFile=".\ReleaseMinDependency/EventListener.dll"
+ LinkIncremental="1"
+ SuppressStartupBanner="true"
+ ModuleDefinitionFile=".\EventListener.def"
+ ProgramDatabaseFile=".\ReleaseMinDependency/EventListener.pdb"
+ SubSystem="2"
+ RandomizedBaseAddress="1"
+ DataExecutionPrevention="0"
+ ImportLibrary=".\ReleaseMinDependency/EventListener.lib"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ SuppressStartupBanner="true"
+ OutputFile=".\ReleaseMinDependency/EventListener.bsc"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release MinSize|Win32"
+ OutputDirectory=".\ReleaseMinSize"
+ IntermediateDirectory=".\ReleaseMinSize"
+ ConfigurationType="2"
+ InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
+ UseOfMFC="0"
+ UseOfATL="2"
+ ATLMinimizesCRunTimeLibraryUsage="true"
+ CharacterSet="2"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ Description="Performing registration"
+ CommandLine="regsvr32 /s /c &quot;$(TargetPath)&quot;&#x0D;&#x0A;echo regsvr32 exec. time &gt; &quot;$(OutDir)\regsvr32.trg&quot;&#x0D;&#x0A;"
+ Outputs="$(OutDir)\regsvr32.trg"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ TypeLibraryName=".\ReleaseMinSize/EventListener.tlb"
+ HeaderFileName=""
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="1"
+ InlineFunctionExpansion="1"
+ PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL"
+ StringPooling="true"
+ RuntimeLibrary="0"
+ EnableFunctionLevelLinking="true"
+ UsePrecompiledHeader="2"
+ PrecompiledHeaderThrough="stdafx.h"
+ PrecompiledHeaderFile=".\ReleaseMinSize/EventListener.pch"
+ AssemblerListingLocation=".\ReleaseMinSize/"
+ ObjectFile=".\ReleaseMinSize/"
+ ProgramDataBaseFileName=".\ReleaseMinSize/"
+ WarningLevel="3"
+ SuppressStartupBanner="true"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ PreprocessorDefinitions="NDEBUG"
+ Culture="1031"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ OutputFile=".\ReleaseMinSize/EventListener.dll"
+ LinkIncremental="1"
+ SuppressStartupBanner="true"
+ ModuleDefinitionFile=".\EventListener.def"
+ ProgramDatabaseFile=".\ReleaseMinSize/EventListener.pdb"
+ SubSystem="2"
+ RandomizedBaseAddress="1"
+ DataExecutionPrevention="0"
+ ImportLibrary=".\ReleaseMinSize/EventListener.lib"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ SuppressStartupBanner="true"
+ OutputFile=".\ReleaseMinSize/EventListener.bsc"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory=".\Debug"
+ IntermediateDirectory=".\Debug"
+ ConfigurationType="2"
+ InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
+ UseOfMFC="0"
+ ATLMinimizesCRunTimeLibraryUsage="false"
+ CharacterSet="2"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ Description="Performing registration"
+ CommandLine="regsvr32 /s /c &quot;$(TargetPath)&quot;&#x0D;&#x0A;echo regsvr32 exec. time &gt; &quot;$(OutDir)\regsvr32.trg&quot;&#x0D;&#x0A;"
+ Outputs="$(OutDir)\regsvr32.trg"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ TypeLibraryName=".\Debug/EventListener.tlb"
+ HeaderFileName=""
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL"
+ MinimalRebuild="true"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="1"
+ UsePrecompiledHeader="2"
+ PrecompiledHeaderThrough="stdafx.h"
+ PrecompiledHeaderFile=".\Debug/EventListener.pch"
+ AssemblerListingLocation=".\Debug/"
+ ObjectFile=".\Debug/"
+ ProgramDataBaseFileName=".\Debug/"
+ WarningLevel="3"
+ SuppressStartupBanner="true"
+ DebugInformationFormat="4"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ PreprocessorDefinitions="_DEBUG"
+ Culture="1031"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ OutputFile=".\Debug/EventListener.dll"
+ LinkIncremental="2"
+ SuppressStartupBanner="true"
+ ModuleDefinitionFile=".\EventListener.def"
+ GenerateDebugInformation="true"
+ ProgramDatabaseFile=".\Debug/EventListener.pdb"
+ SubSystem="2"
+ RandomizedBaseAddress="1"
+ DataExecutionPrevention="0"
+ ImportLibrary=".\Debug/EventListener.lib"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ SuppressStartupBanner="true"
+ OutputFile=".\Debug/EventListener.bsc"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Unicode Release MinDependency|Win32"
+ OutputDirectory=".\ReleaseUMinDependency"
+ IntermediateDirectory=".\ReleaseUMinDependency"
+ ConfigurationType="2"
+ InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
+ UseOfMFC="0"
+ UseOfATL="1"
+ ATLMinimizesCRunTimeLibraryUsage="true"
+ CharacterSet="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ Description="Performing registration"
+ CommandLine="if &quot;%OS%&quot;==&quot;&quot; goto NOTNT&#x0D;&#x0A;if not &quot;%OS%&quot;==&quot;Windows_NT&quot; goto NOTNT&#x0D;&#x0A;regsvr32 /s /c &quot;$(TargetPath)&quot;&#x0D;&#x0A;echo regsvr32 exec. time &gt; &quot;$(OutDir)\regsvr32.trg&quot;&#x0D;&#x0A;goto end&#x0D;&#x0A;:NOTNT&#x0D;&#x0A;echo Warning : Cannot register Unicode DLL on Windows 95&#x0D;&#x0A;:end&#x0D;&#x0A;"
+ Outputs="$(OutDir)\regsvr32.trg"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ TypeLibraryName=".\ReleaseUMinDependency/EventListener.tlb"
+ HeaderFileName=""
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="1"
+ InlineFunctionExpansion="1"
+ PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL"
+ StringPooling="true"
+ RuntimeLibrary="0"
+ EnableFunctionLevelLinking="true"
+ UsePrecompiledHeader="2"
+ PrecompiledHeaderThrough="stdafx.h"
+ PrecompiledHeaderFile=".\ReleaseUMinDependency/EventListener.pch"
+ AssemblerListingLocation=".\ReleaseUMinDependency/"
+ ObjectFile=".\ReleaseUMinDependency/"
+ ProgramDataBaseFileName=".\ReleaseUMinDependency/"
+ WarningLevel="3"
+ SuppressStartupBanner="true"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ PreprocessorDefinitions="NDEBUG"
+ Culture="1031"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ OutputFile=".\ReleaseUMinDependency/EventListener.dll"
+ LinkIncremental="1"
+ SuppressStartupBanner="true"
+ ModuleDefinitionFile=".\EventListener.def"
+ ProgramDatabaseFile=".\ReleaseUMinDependency/EventListener.pdb"
+ SubSystem="2"
+ RandomizedBaseAddress="1"
+ DataExecutionPrevention="0"
+ ImportLibrary=".\ReleaseUMinDependency/EventListener.lib"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ SuppressStartupBanner="true"
+ OutputFile=".\ReleaseUMinDependency/EventListener.bsc"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Name="Source Files"
+ Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+ >
+ <File
+ RelativePath="EventListener.cpp"
+ >
+ <FileConfiguration
+ Name="Unicode Release MinSize|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions="_ATL_MIN_CRT"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Unicode Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release MinDependency|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions="_ATL_MIN_CRT"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release MinSize|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions="_ATL_MIN_CRT"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Unicode Release MinDependency|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions="_ATL_MIN_CRT"
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="EventListener.def"
+ >
+ </File>
+ <File
+ RelativePath="EventListener.idl"
+ >
+ <FileConfiguration
+ Name="Unicode Release MinSize|Win32"
+ >
+ <Tool
+ Name="VCMIDLTool"
+ GenerateStublessProxies="true"
+ TypeLibraryName=".\EventListener.tlb"
+ HeaderFileName="EventListener.h"
+ InterfaceIdentifierFileName="EventListener_i.c"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Unicode Debug|Win32"
+ >
+ <Tool
+ Name="VCMIDLTool"
+ GenerateStublessProxies="true"
+ TypeLibraryName=".\EventListener.tlb"
+ HeaderFileName="EventListener.h"
+ InterfaceIdentifierFileName="EventListener_i.c"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release MinDependency|Win32"
+ >
+ <Tool
+ Name="VCMIDLTool"
+ GenerateStublessProxies="true"
+ TypeLibraryName=".\EventListener.tlb"
+ HeaderFileName="EventListener.h"
+ InterfaceIdentifierFileName="EventListener_i.c"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release MinSize|Win32"
+ >
+ <Tool
+ Name="VCMIDLTool"
+ GenerateStublessProxies="true"
+ TypeLibraryName=".\EventListener.tlb"
+ HeaderFileName="EventListener.h"
+ InterfaceIdentifierFileName="EventListener_i.c"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCMIDLTool"
+ GenerateStublessProxies="true"
+ TypeLibraryName=".\EventListener.tlb"
+ HeaderFileName="EventListener.h"
+ InterfaceIdentifierFileName="EventListener_i.c"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Unicode Release MinDependency|Win32"
+ >
+ <Tool
+ Name="VCMIDLTool"
+ GenerateStublessProxies="true"
+ TypeLibraryName=".\EventListener.tlb"
+ HeaderFileName="EventListener.h"
+ InterfaceIdentifierFileName="EventListener_i.c"
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="EventListener.rc"
+ >
+ <FileConfiguration
+ Name="Unicode Release MinSize|Win32"
+ >
+ <Tool
+ Name="VCResourceCompilerTool"
+ PreprocessorDefinitions=""
+ AdditionalIncludeDirectories="$(OUTDIR)"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Unicode Debug|Win32"
+ >
+ <Tool
+ Name="VCResourceCompilerTool"
+ PreprocessorDefinitions=""
+ AdditionalIncludeDirectories="$(OUTDIR)"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release MinDependency|Win32"
+ >
+ <Tool
+ Name="VCResourceCompilerTool"
+ PreprocessorDefinitions=""
+ AdditionalIncludeDirectories="$(OUTDIR)"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release MinSize|Win32"
+ >
+ <Tool
+ Name="VCResourceCompilerTool"
+ PreprocessorDefinitions=""
+ AdditionalIncludeDirectories="$(OUTDIR)"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCResourceCompilerTool"
+ PreprocessorDefinitions=""
+ AdditionalIncludeDirectories="$(OUTDIR)"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Unicode Release MinDependency|Win32"
+ >
+ <Tool
+ Name="VCResourceCompilerTool"
+ PreprocessorDefinitions=""
+ AdditionalIncludeDirectories="$(OUTDIR)"
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="EvtListener.cpp"
+ >
+ <FileConfiguration
+ Name="Unicode Release MinSize|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions="_ATL_MIN_CRT"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Unicode Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release MinDependency|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions="_ATL_MIN_CRT"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release MinSize|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions="_ATL_MIN_CRT"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions=""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Unicode Release MinDependency|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions="_ATL_MIN_CRT"
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="StdAfx.cpp"
+ >
+ <FileConfiguration
+ Name="Unicode Release MinSize|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions="_ATL_MIN_CRT"
+ UsePrecompiledHeader="1"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Unicode Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions=""
+ UsePrecompiledHeader="1"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release MinDependency|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions="_ATL_MIN_CRT"
+ UsePrecompiledHeader="1"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release MinSize|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions="_ATL_MIN_CRT"
+ UsePrecompiledHeader="1"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions=""
+ UsePrecompiledHeader="1"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Unicode Release MinDependency|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions="_ATL_MIN_CRT"
+ UsePrecompiledHeader="1"
+ />
+ </FileConfiguration>
+ </File>
+ </Filter>
+ <Filter
+ Name="Header Files"
+ Filter="h;hpp;hxx;hm;inl"
+ >
+ <File
+ RelativePath="EvtListener.h"
+ >
+ </File>
+ <File
+ RelativePath="Resource.h"
+ >
+ </File>
+ <File
+ RelativePath="StdAfx.h"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="Resource Files"
+ Filter="ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
+ >
+ <File
+ RelativePath="EvtListener.rgs"
+ >
+ </File>
+ </Filter>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
diff --git a/extensions/test/ole/EventListenerSample/EventListener/EvtListener.cpp b/extensions/test/ole/EventListenerSample/EventListener/EvtListener.cpp
new file mode 100644
index 000000000000..1605b098240d
--- /dev/null
+++ b/extensions/test/ole/EventListenerSample/EventListener/EvtListener.cpp
@@ -0,0 +1,21 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+// EvtListener.cpp : Implementierung von CEvtListener
+#include "stdafx.h"
+#include "EventListener.h"
+#include "EvtListener.h"
+
+/////////////////////////////////////////////////////////////////////////////
+// CEvtListener
+
+STDMETHODIMP CEvtListener::disposing( IDispatch* source)
+{
+ ::MessageBox(NULL,_T("XEventListener::disposing"),
+ _T("EventListener.EvtListener component"), MB_OK);
+ return S_OK;
+}
+
+CEvtListener::~CEvtListener()
+{
+
+}
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/test/ole/EventListenerSample/EventListener/EvtListener.h b/extensions/test/ole/EventListenerSample/EventListener/EvtListener.h
new file mode 100644
index 000000000000..2bc0a6a9aef9
--- /dev/null
+++ b/extensions/test/ole/EventListenerSample/EventListener/EvtListener.h
@@ -0,0 +1,38 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+// EvtListener.h : Deklaration von CEvtListener
+
+#ifndef __EVTLISTENER_H_
+#define __EVTLISTENER_H_
+
+#include "resource.h" // Hauptsymbole
+
+/////////////////////////////////////////////////////////////////////////////
+// CEvtListener
+class ATL_NO_VTABLE CEvtListener :
+ public CComObjectRootEx<CComSingleThreadModel>,
+ public CComCoClass<CEvtListener, &CLSID_EvtListener>,
+ public IDispatchImpl<IEvtListener, &IID_IEvtListener, &LIBID_EVENTLISTENERLib>
+{
+public:
+ CEvtListener()
+ {
+ }
+ ~CEvtListener();
+
+DECLARE_REGISTRY_RESOURCEID(IDR_EVTLISTENER)
+
+DECLARE_PROTECT_FINAL_CONSTRUCT()
+
+BEGIN_COM_MAP(CEvtListener)
+ COM_INTERFACE_ENTRY(IEvtListener)
+ COM_INTERFACE_ENTRY(IDispatch)
+END_COM_MAP()
+
+// IEvtListener
+public:
+ STDMETHOD(disposing)(IDispatch* source);
+};
+
+#endif //__EVTLISTENER_H_
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/test/ole/EventListenerSample/EventListener/EvtListener.rgs b/extensions/test/ole/EventListenerSample/EventListener/EvtListener.rgs
new file mode 100644
index 000000000000..e0aa9bbb7c37
--- /dev/null
+++ b/extensions/test/ole/EventListenerSample/EventListener/EvtListener.rgs
@@ -0,0 +1,26 @@
+HKCR
+{
+ EventListener.EvtListener.1 = s 'EvtListener Class'
+ {
+ CLSID = s '{830E0743-87C1-4C99-A77A-5FBA0C2EBD9A}'
+ }
+ EventListener.EvtListener = s 'EvtListener Class'
+ {
+ CLSID = s '{830E0743-87C1-4C99-A77A-5FBA0C2EBD9A}'
+ CurVer = s 'EventListener.EvtListener.1'
+ }
+ NoRemove CLSID
+ {
+ ForceRemove {830E0743-87C1-4C99-A77A-5FBA0C2EBD9A} = s 'EvtListener Class'
+ {
+ ProgID = s 'EventListener.EvtListener.1'
+ VersionIndependentProgID = s 'EventListener.EvtListener'
+ ForceRemove 'Programmable'
+ InprocServer32 = s '%MODULE%'
+ {
+ val ThreadingModel = s 'Apartment'
+ }
+ 'TypeLib' = s '{E3E61535-3262-45E6-BFD9-EE8AED051BD1}'
+ }
+ }
+}
diff --git a/extensions/test/ole/EventListenerSample/EventListener/StdAfx.cpp b/extensions/test/ole/EventListenerSample/EventListener/StdAfx.cpp
new file mode 100644
index 000000000000..c25536a52169
--- /dev/null
+++ b/extensions/test/ole/EventListenerSample/EventListener/StdAfx.cpp
@@ -0,0 +1,15 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+// stdafx.cpp : source file that includes just the standard includes
+// stdafx.pch will be the pre-compiled header
+// stdafx.obj will contain the pre-compiled type information
+
+#include "stdafx.h"
+
+#ifdef _ATL_STATIC_REGISTRY
+#include <statreg.h>
+#include <statreg.cpp>
+#endif
+
+#include <atlimpl.cpp>
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/test/ole/EventListenerSample/EventListener/StdAfx.h b/extensions/test/ole/EventListenerSample/EventListener/StdAfx.h
new file mode 100644
index 000000000000..def66faf10db
--- /dev/null
+++ b/extensions/test/ole/EventListenerSample/EventListener/StdAfx.h
@@ -0,0 +1,30 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+// stdafx.h : include file for standard system include files,
+// or project specific include files that are used frequently,
+// but are changed infrequently
+
+#if !defined(AFX_STDAFX_H__E275407A_804A_477E_9A28_F5CA84E711C3__INCLUDED_)
+#define AFX_STDAFX_H__E275407A_804A_477E_9A28_F5CA84E711C3__INCLUDED_
+
+#if _MSC_VER > 1000
+#pragma once
+#endif // _MSC_VER > 1000
+
+#define STRICT
+#ifndef _WIN32_WINNT
+#define _WIN32_WINNT 0x0400
+#endif
+#define _ATL_APARTMENT_THREADED
+
+#include <atlbase.h>
+//You may derive a class from CComModule and use it if you want to override
+//something, but do not change the name of _Module
+extern CComModule _Module;
+#include <atlcom.h>
+
+//{{AFX_INSERT_LOCATION}}
+// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
+
+#endif // !defined(AFX_STDAFX_H__E275407A_804A_477E_9A28_F5CA84E711C3__INCLUDED)
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/test/ole/EventListenerSample/EventListener/resource.h b/extensions/test/ole/EventListenerSample/EventListener/resource.h
new file mode 100644
index 000000000000..70bf51a6f1ff
--- /dev/null
+++ b/extensions/test/ole/EventListenerSample/EventListener/resource.h
@@ -0,0 +1,20 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+//{{NO_DEPENDENCIES}}
+// Microsoft Developer Studio generated include file.
+// Used by EventListener.rc
+//
+#define IDS_PROJNAME 100
+#define IDR_EVTLISTENER 101
+
+// Next default values for new objects
+//
+#ifdef APSTUDIO_INVOKED
+#ifndef APSTUDIO_READONLY_SYMBOLS
+#define _APS_NEXT_RESOURCE_VALUE 201
+#define _APS_NEXT_COMMAND_VALUE 32768
+#define _APS_NEXT_CONTROL_VALUE 201
+#define _APS_NEXT_SYMED_VALUE 102
+#endif
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/test/ole/EventListenerSample/VBEventListener/Module1.bas b/extensions/test/ole/EventListenerSample/VBEventListener/Module1.bas
new file mode 100644
index 000000000000..aafd265a0d48
--- /dev/null
+++ b/extensions/test/ole/EventListenerSample/VBEventListener/Module1.bas
@@ -0,0 +1,9 @@
+Attribute VB_Name = "Module1"
+Option Explicit
+
+
+Sub Main()
+
+End Sub
+
+
diff --git a/extensions/test/ole/EventListenerSample/VBEventListener/VBEventListener.cls b/extensions/test/ole/EventListenerSample/VBEventListener/VBEventListener.cls
new file mode 100644
index 000000000000..4c36785b56dc
--- /dev/null
+++ b/extensions/test/ole/EventListenerSample/VBEventListener/VBEventListener.cls
@@ -0,0 +1,78 @@
+'*************************************************************************
+'
+' DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+'
+' Copyright 2000, 2010 Oracle and/or its affiliates.
+'
+' OpenOffice.org - a multi-platform office productivity suite
+'
+' This file is part of OpenOffice.org.
+'
+' OpenOffice.org is free software: you can redistribute it and/or modify
+' it under the terms of the GNU Lesser General Public License version 3
+' only, as published by the Free Software Foundation.
+'
+' OpenOffice.org is distributed in the hope that it will be useful,
+' but WITHOUT ANY WARRANTY; without even the implied warranty of
+' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+' GNU Lesser General Public License version 3 for more details
+' (a copy is included in the LICENSE file that accompanied this code).
+'
+' You should have received a copy of the GNU Lesser General Public License
+' version 3 along with OpenOffice.org. If not, see
+' <http://www.openoffice.org/license.html>
+' for a copy of the LGPLv3 License.
+'
+'*************************************************************************
+
+VERSION 1.0 CLASS
+BEGIN
+ MultiUse = -1 'True
+ Persistable = 0 'NotPersistable
+ DataBindingBehavior = 0 'vbNone
+ DataSourceBehavior = 0 'vbNone
+ MTSTransactionMode = 0 'NotAnMTSObject
+END
+Attribute VB_Name = "VBEventListener"
+Attribute VB_GlobalNameSpace = False
+Attribute VB_Creatable = True
+Attribute VB_PredeclaredId = False
+Attribute VB_Exposed = True
+Option Explicit
+Private interfaces(0) As String
+Private bDisposingCalled As Boolean
+Private bQuiet As Boolean
+
+Public Property Get Bridge_ImplementedInterfaces() As Variant
+ Bridge_ImplementedInterfaces = interfaces
+End Property
+
+Private Sub Class_Initialize()
+interfaces(0) = "com.sun.star.lang.XEventListener"
+bDisposingCalled = False
+bQuiet = False
+End Sub
+
+Private Sub Class_Terminate()
+ On Error Resume Next
+ Debug.Print "Terminate VBEventListener"
+End Sub
+
+Public Sub disposing(ByVal source As Object)
+ If bQuiet = False Then
+ MsgBox "disposing called"
+ End If
+ bDisposingCalled = True
+End Sub
+
+Public Sub setQuiet(quiet As Boolean)
+ bQuiet = quiet
+End Sub
+
+Public Sub resetDisposing()
+ bDisposingCalled = False
+End Sub
+
+Public Function disposingCalled()
+ disposingCalled = bDisposingCalled
+End Function
diff --git a/extensions/test/ole/EventListenerSample/VBEventListener/VBasicEventListener.dll b/extensions/test/ole/EventListenerSample/VBEventListener/VBasicEventListener.dll
new file mode 100644
index 000000000000..5ac90de3950a
--- /dev/null
+++ b/extensions/test/ole/EventListenerSample/VBEventListener/VBasicEventListener.dll
Binary files differ
diff --git a/extensions/test/ole/EventListenerSample/VBEventListener/VBasicEventListener.vbp b/extensions/test/ole/EventListenerSample/VBEventListener/VBasicEventListener.vbp
new file mode 100644
index 000000000000..f89b866befab
--- /dev/null
+++ b/extensions/test/ole/EventListenerSample/VBEventListener/VBasicEventListener.vbp
@@ -0,0 +1,38 @@
+Type=OleDll
+Class=VBEventListener; VBEventListener.cls
+Module=Module1; Module1.bas
+Startup="Sub Main"
+HelpFile=""
+ExeName32="VBasicEventListener.dll"
+Command32=""
+Name="VBasicEventListener"
+HelpContextID="0"
+Description="Implementation of UNO XEventListener"
+CompatibleMode="1"
+CompatibleEXE32="VBasicEventListener.dll"
+MajorVer=1
+MinorVer=0
+RevisionVer=0
+AutoIncrementVer=0
+ServerSupportFiles=0
+VersionCompanyName="StarOffice"
+CompilationType=0
+OptimizationType=0
+FavorPentiumPro(tm)=0
+CodeViewDebugInfo=0
+NoAliasing=0
+BoundsCheck=0
+OverflowCheck=0
+FlPointCheck=0
+FDIVCheck=0
+UnroundedFP=0
+StartMode=1
+Unattended=0
+Retained=0
+ThreadPerObject=0
+MaxNumberOfThreads=1
+ThreadingModel=1
+DebugStartupOption=0
+
+[MS Transaction Server]
+AutoRefresh=1
diff --git a/extensions/test/ole/EventListenerSample/VBEventListener/VBasicEventListener.vbw b/extensions/test/ole/EventListenerSample/VBEventListener/VBasicEventListener.vbw
new file mode 100644
index 000000000000..cf737ac409bc
--- /dev/null
+++ b/extensions/test/ole/EventListenerSample/VBEventListener/VBasicEventListener.vbw
@@ -0,0 +1,2 @@
+VBEventListener = 132, 132, 732, 748,
+Module1 = 64, 33, 849, 530,
diff --git a/extensions/test/ole/EventListenerSample/VBEventListener/readme.txt b/extensions/test/ole/EventListenerSample/VBEventListener/readme.txt
new file mode 100644
index 000000000000..1daace2673f3
--- /dev/null
+++ b/extensions/test/ole/EventListenerSample/VBEventListener/readme.txt
@@ -0,0 +1,7 @@
+VBasicEventListener.dll is an ActiveX component written with VisualBasic. The
+component registers on the system with a particular ID. When the library is build
+this ID is generated, unless a previously build library exists. Then the ID of that
+library is used. In order to use always the same ID, the library must be as binary in
+the cvs.
+
+The library can be used under the licences noted in VBEventListener.cls. \ No newline at end of file
diff --git a/extensions/test/ole/EventListenerSample/events.htm b/extensions/test/ole/EventListenerSample/events.htm
new file mode 100644
index 000000000000..973a21528643
--- /dev/null
+++ b/extensions/test/ole/EventListenerSample/events.htm
@@ -0,0 +1,98 @@
+<HTML>
+<HEAD>
+<META NAME="GENERATOR" Content="Microsoft Developer Studio">
+<META HTTP-EQUIV="Content-Type" content="text/html; charset=iso-8859-1">
+<TITLE>Document Title</TITLE>
+</HEAD>
+<BODY id=theBody>
+
+<script language="JScript">
+function Main( id)
+{
+var objServiceManager= new ActiveXObject("com.sun.star.ServiceManager");
+
+var objDesktop= objServiceManager.createInstance("com.sun.star.frame.Desktop");
+
+var args= new Array();
+
+var objDocument= objDesktop.loadComponentFromURL("private:factory/swriter", "_blank", 0, args);
+
+var listener;
+if( id == 0)
+ listener= new XEventListener_Impl();
+else if(id == 1)
+ listener= new ActiveXObject("EventListener.EvtListener");
+objDocument.addEventListener( listener);
+}
+
+
+function XEventListener_Impl()
+{
+ this._environment= "JScript";
+ this._implementedInterfaces= new Array( "com.sun.star.lang.XEventListener");
+
+ //XEventListener
+ this.disposing= XEventListener_disposing;
+}
+
+function XEventListener_disposing( source)
+{
+ alert("JScript Event Listener \n The document was closed");
+}
+</script>
+
+<script language="VBScript">
+SUB MainVB( id)
+Set objServiceManager= CreateObject("com.sun.star.ServiceManager")
+
+Set objCoreReflection= objServiceManager.createInstance("com.sun.star.reflection.CoreReflection")
+
+Set objDesktop= objServiceManager.createInstance("com.sun.star.frame.Desktop")
+
+'Open a new empty writer document
+Dim args()
+Set objDocument= objDesktop.loadComponentFromURL("private:factory/swriter", "_blank", 0, args)
+
+Dim eventListener
+select case id
+ case 0
+ Set eventListener= CreateObject("EventListener.EvtListener")
+ case 1
+ Set eventListener= CreateObject("VBasicEventListener.VBEventListener")
+end select
+
+objDocument.addEventListener eventlistener
+END SUB
+
+</script>
+<p>
+The script on this page creates a new StarOffice document and connects an event listener
+to it. When the document is closed then the XEventListener::disposing method is called on the
+listener object. How the listener is set up depends on the button being clicked.
+</p>
+<p>
+The button will run JScript code that and adds an JScript event listener to the document.
+The listener is also implemented in JScript an is on this page..
+</p>
+<button onclick='Main(0)'>JScript go</Button>
+<p>
+
+The button runs JScript code that creates the ActiveX component EventListener.EvtListener that
+is written in C++ and housed in a dll. Then the event listener is added to the document.
+</p>
+<button onclick='Main( 1)'>JScript go</Button>
+<p>
+The button runs VBScript code that creates the components EventListener.EvtListener and adds it
+to the document.
+</p>
+<button onclick='MainVB(0)'>VBScript</Button>
+<p>
+Runs VBScript code that creates VBasicEventListener.VBEventListener ActiveX component which was
+written with VB
+</p>
+<button onclick='MainVB(1)'>VBScript</Button>
+
+</body>
+</html>
+
+
diff --git a/extensions/test/ole/EventListenerSample/readme.txt b/extensions/test/ole/EventListenerSample/readme.txt
new file mode 100644
index 000000000000..6485571ec928
--- /dev/null
+++ b/extensions/test/ole/EventListenerSample/readme.txt
@@ -0,0 +1,20 @@
+EventListener
+========================================
+
+The folder EventListener contains an MSDEV project that builds a dll that
+contains the EventListener.EvtListener ActiveX component. The component
+implements the XEventListener interface according to the rules of the
+OleBridge. The component will be used from the HTML page events.htm.
+
+
+VBEventListener:
+========================================
+
+Contains a Visual Basic project that builds an ActiveX component that implements
+com.sun.star.lang.XEventListener. Its ProgId is
+VBasicEventListener.VBEventListener The dll should also be checked in. VB needs
+its TLB, so it uses the same CLSIDs on the next build. The component will create
+a message box when its disposing function has been called.
+
+The project also contains a client that builds a Project1.exe (in the same
+folder) that creates VBEventListener and adds it to a StarOffice document
diff --git a/extensions/test/ole/JScriptNewStyle.htm b/extensions/test/ole/JScriptNewStyle.htm
new file mode 100644
index 000000000000..016119d1908b
--- /dev/null
+++ b/extensions/test/ole/JScriptNewStyle.htm
@@ -0,0 +1,1054 @@
+<HTML>
+<HEAD>
+<META NAME="GENERATOR" Content="Microsoft Developer Studio">
+<META HTTP-EQUIV="Content-Type" content="text/html; charset=iso-8859-1">
+<TITLE>Document Title</TITLE>
+</HEAD>
+<BODY id=theBody>
+
+<script language="JScript">
+function callOleTest( id)
+{
+ var factory= new ActiveXObject("com.sun.star.ServiceManager");
+ var oletest= factory.createInstance("oletest.OleTest");
+// alert(oletest);
+
+ var arr= new Array( 1, 2, 3, 4, 0);
+ var arrDouble= new Array( 1.2345, 12.345, 123,45, 1234.5, 12345);
+ var arrBool= new Array( 1, 0, 2, 0, 3);
+ var arrChar= new Array( '1', 'A', "1", "A", ' ', 55, 56);
+ var arrString= new Array("hamburger","cheeseburger", "chicken nuggets", "chicken wings" , "pizza");
+ var arrAny= new Array( 100, 100.1235,"hallo");
+ var arrSeq= new Array( arr, arr, arr);
+ var arrSeq2= new Array( arrSeq, arrSeq, arrSeq)
+
+// var ob= new Object();
+// ob.value= "A JScript object";
+// var arrObject= new Array( ob, ob, ob);
+
+
+ var arrout1= new Array();
+ var arrout2= new Array();
+ var arrout3= new Array();
+
+ var ret, i;
+ var sfarray, sfarray1, sfarray2, sfarray3;
+ var value= oletest._GetValueObject();
+ var outValue= oletest._GetValueObject();
+ outValue.InitOutParam();
+ var outValue2= oletest._GetValueObject();
+ outValue2.InitOutParam();
+ var outValue3= oletest._GetValueObject();
+ outValue3.InitOutParam();
+
+ var inoutValue= oletest._GetValueObject();
+// inoutValue.InitInOutParam();
+
+ switch( id)
+ {
+ // Array in-params
+ case 1:
+ value.Set("[]byte", arr)
+ ret= oletest.methodByte( value);
+ sfarray= new VBArray( ret);
+ document.writeln( "Param: " + arr.toString() + "<br>");
+ document.writeln( "Returns a Sequence&lt BYTE &gt <br>" + sfarray.toArray()) ; break;
+
+ case 2:
+ value.Set("[]double", arrDouble)
+ ret= oletest.methodDouble( value);
+ sfarray= new VBArray( ret);
+ document.writeln( "Param: " + arrDouble.toString() +"<br>");
+ document.writeln( "Returns a Sequence&lt double &gt <br>" + sfarray.toArray()) ; break;
+
+ case 3:
+ value.Set("[]boolean", arrBool)
+ ret= oletest.methodBool( value);
+ sfarray= new VBArray( ret);
+ document.writeln( "Param: " + arrBool.toString() +"<br>");
+ document.writeln( "Returns a Sequence&lt BOOL &gt <br>" + sfarray.toArray()) ; break;
+
+ case 4:
+ value.Set("[]short", arr)
+ ret= oletest.methodShort( value);
+ sfarray= new VBArray( ret);
+ document.writeln( "Param: " + arr.toString() +"<br>");
+ document.writeln( "Returns a Sequence&lt SHORT &gt <br>" + sfarray.toArray()) ; break;
+
+ case 5:
+ value.Set("[]unsigned short", arr)
+ ret= oletest.methodUShort( value);
+ sfarray= new VBArray( ret);
+ document.writeln( "Param: " + arr.toString() +"<br>");
+ document.writeln( "Returns a Sequence&lt unsigned SHORT &gt <br>" + sfarray.toArray()) ; break;
+
+ case 6:
+ value.Set("[]long", arr)
+ ret= oletest.methodLong( value);
+ sfarray= new VBArray( ret);
+ document.writeln( "Param: " + arr.toString() +"<br>");
+ document.writeln( "Returns a Sequence&lt LONG &gt <br>" + sfarray.toArray()) ; break;
+
+ case 7:
+ value.Set("[]unsigned long", arr)
+ ret= oletest.methodULong( value);
+ sfarray= new VBArray( ret);
+ document.writeln( "Param: " + arr.toString() +"<br>");
+ document.writeln( "Returns a Sequence&lt unsigned LONG &gt <br>" + sfarray.toArray()) ; break;
+
+ case 8:
+ value.Set("[]char", arrChar)
+ ret= oletest.methodChar( value);
+ sfarray= new VBArray( ret);
+ document.writeln( "Param: " + arrChar.toString() +"<br>");
+ document.writeln( "Returns a Sequence&lt wchar_t &gt <br>" + sfarray.toArray()) ; break;
+
+ case 9:
+ value.Set("[]string", arrString)
+ ret= oletest.methodString( value);
+ sfarray= new VBArray( ret);
+ document.writeln( "Param: " + arrString.toString() +"<br>");
+ document.writeln( "Returns a Sequence&lt UString &gt <br>" + sfarray.toArray()) ; break;
+
+ case 10:
+ value.Set("[]any", arrAny)
+ ret= oletest.methodAny( value);
+ sfarray= new VBArray( ret);
+ document.writeln( "Param: " + arrAny.toString() +"<br>");
+ document.writeln( "Returns a Sequence&lt UsrAny &gt <br>" + sfarray.toArray() ) ; break;
+
+ case 11:
+ var allArray= new Array();
+ for(var i= 0; i <3; i++)
+ {
+ var value1= oletest._GetValueObject();
+ value1.Set("[]long", arr);
+ allArray[i]= value1;
+ }
+
+ value.Set("[][]long", allArray);
+
+ ret= oletest.methodSequence( value);
+ sfarray= new VBArray( ret);
+ document.writeln( "Param: " + arrSeq.toString() +"<br>");
+ document.writeln("Returns a Sequence&lt Sequence &lt long &gt&gt <br>") ;
+ var arr1= new Array();
+ arr1= sfarray.toArray();
+ for( i=0; i < arr1.length; i++)
+ {
+ sfarray2= new VBArray( arr1[i]);
+ var arr2= new Array();
+ arr2= sfarray2.toArray();
+ document.writeln( arr2.toString() + "<br>" );
+ }
+ break;
+
+ case 12:
+ var array1= new Array();
+ for(var i= 0; i <3; i++)
+ {
+ var array2 = new Array();
+ for( var j= 0; j < 3; j++)
+ {
+ var value2= oletest._GetValueObject();
+ value2.Set("[]long", arr);
+ array2[j]= value2;
+ }
+
+ var value1= oletest._GetValueObject();
+ value1.Set("[][]long", array2)
+ array1[i]= value1;
+ }
+ var valueAll= oletest._GetValueObject();
+ valueAll.Set("[][][]long",array1);
+
+ ret= oletest.methodSequence2( valueAll);
+ document.writeln( "Param: " + arrSeq2.toString() +"<br>");
+ sfarray1= new VBArray( ret);
+ arr1= sfarray1.toArray();
+ for( i=0; i < arr1.length; i++)
+ {
+ sfarray2= new VBArray( arr1[i]);
+ arr2= sfarray2.toArray();
+
+ for ( j=0; j < arr2.length; j++)
+ {
+ sfarray3= new VBArray( arr2[j]);
+ arr3= sfarray3.toArray();
+ document.write( i+ " ");
+ document.writeln(j + ": "+ arr3.toString() + "<br>" );
+ }
+
+ }
+ break;
+
+ case 13:
+
+ var ar= new Array();
+ for( i=0; i< 3; i++)
+ {
+ var ob= new Object();
+ var valueObject= oletest._GetValueObject();
+ ob.value= "A JScript object!";
+ valueObject.Set("com.sun.star.uno.XInterface", ob);
+// valueObject.Set("long", 5);
+ ar[i]= valueObject;
+ }
+ value.Set("[]com.sun.star.uno.XInterface", ar);
+// value.Set("[]long", ar);
+
+ ret = oletest.methodXInterface( value);
+ sfarray= new VBArray( ret);
+ var arRet= sfarray.toArray();
+
+ document.writeln( "Params : Array containing objects ")
+ for( index in ar)
+ {
+ document.writeln( "object " + index + ": " + ar[index].Get().value +" ");
+ }
+ document.writeln( "<br>" ) ;
+ document.writeln("Return: <br>");
+ for( index in arRet)
+ {
+ document.writeln( "object " + index + ": " + arRet[index].value + " ");
+ }
+ break;
+
+
+
+
+ // Properties: setting and getting values
+ case 200:
+ value.Set("[]byte", arr)
+ oletest.AttrByte = value;
+ ret= oletest.AttrByte;
+ sfarray= new VBArray( ret);
+ document.writeln("Setting AttrByte: " + arr.toString() + "<p>");
+ document.writeln("Getting AttrByte: " + sfarray.toArray()); break;
+
+ case 201:
+ value.Set("[]double", arrDouble)
+ oletest.AttrDouble= value;
+ ret= oletest.AttrDouble;
+ sfarray= new VBArray( ret);
+ document.writeln("Setting AttrDouble: " + arrDouble.toString() + "<p>");
+ document.writeln("Getting AttrDouble: " + sfarray.toArray()); break;
+
+ case 202:
+ value.Set("[]boolean", arrBool)
+ oletest.AttrBool= value;
+ ret= oletest.AttrBool;
+ sfarray= new VBArray( ret);
+ document.writeln("Setting AttrBool: " + arrBool.toString() + "<p>");
+ document.writeln("Getting AttrBool: " + sfarray.toArray()); break;
+
+ case 203:
+ value.Set("[]short", arr)
+ oletest.AttrShort= value;
+ ret= oletest.AttrShort;
+ sfarray= new VBArray( ret);
+ document.writeln("Setting AttrShort: " + arr.toString() + "<p>");
+ document.writeln("Getting AttrShort: " + sfarray.toArray()); break;
+
+ case 204:
+ value.Set("[]unsigned short", arr)
+ oletest.AttrUShort= value;
+ ret= oletest.AttrUShort;
+ sfarray= new VBArray( ret);
+ document.writeln("Setting AttrUShort: " + arr.toString() + "<p>");
+ document.writeln("Getting AttrUShort: " + sfarray.toArray()); break;
+
+ case 205:
+ value.Set("[]long", arr)
+ oletest.AttrLong= value;
+ ret= oletest.AttrLong;
+ sfarray= new VBArray( ret);
+ document.writeln("Setting AttrLong: " + arr.toString() + "<p>");
+ document.writeln("Getting AttrLong: " + sfarray.toArray()); break;
+
+ case 206:
+ value.Set("[]unsigned long", arr)
+ oletest.AttrULong= value;
+ ret= oletest.AttrULong;
+ sfarray= new VBArray( ret);
+ document.writeln("Setting AttrULong: " + arr.toString() + "<p>");
+ document.writeln("Getting AttrULong: " + sfarray.toArray()); break;
+
+ case 207:
+ value.Set("[]char", arrChar)
+ oletest.AttrChar= value;
+ ret= oletest.AttrChar;
+ sfarray= new VBArray( ret);
+ document.writeln("Setting AttrChar: " + arrChar.toString() + "<p>");
+ document.writeln("Getting AttrChar: " + sfarray.toArray()); break;
+
+ case 208:
+ value.Set("[]string", arrString)
+ oletest.AttrString= value;
+ ret= oletest.AttrString;
+ sfarray= new VBArray( ret);
+ document.writeln("Setting AttrString: " + arrString.toString() + "<p>");
+ document.writeln("Getting AttrString: " + sfarray.toArray()); break;
+
+ case 209:
+ value.Set("[]any", arrAny)
+ oletest.AttrAny= value;
+ ret= oletest.AttrAny;
+ sfarray= new VBArray( ret);
+ document.writeln("Setting AttrAny: " + arrAny.toString() + "<p>");
+ document.writeln("Getting AttrAny: " + sfarray.toArray()); break;
+
+ case 210:
+ var allArray= new Array();
+ for(var i= 0; i <3; i++)
+ {
+ var value1= oletest._GetValueObject();
+ value1.Set("[]long", arr);
+ allArray[i]= value1;
+ }
+
+ value.Set("[][]long", allArray);
+
+ oletest.AttrSequence= value;
+ ret= oletest.AttrSequence;
+ sfarray= new VBArray( ret);
+
+ document.writeln( "Param: " + arrSeq.toString() +"<br>");
+ document.writeln("Returns a Sequence&lt Sequence &lt long &gt&gt <br>") ;
+ var arr1= new Array();
+ arr1= sfarray.toArray();
+ for( i=0; i < arr1.length; i++)
+ {
+ sfarray2= new VBArray( arr1[i]);
+ var arr2= new Array();
+ arr2= sfarray2.toArray();
+ document.writeln( arr2.toString() + "<br>" );
+ }
+ break;
+
+ case 211:
+ var array1= new Array();
+ for(var i= 0; i <3; i++)
+ {
+ var array2 = new Array();
+ for( var j= 0; j < 3; j++)
+ {
+ var value2= oletest._GetValueObject();
+ value2.Set("[]long", arr);
+ array2[j]= value2;
+ }
+
+ var value1= oletest._GetValueObject();
+ value1.Set("[][]long", array2)
+ array1[i]= value1;
+ }
+ var valueAll= oletest._GetValueObject();
+ valueAll.Set("[][][]long",array1);
+
+ oletest.AttrSequence2= valueAll;
+ ret= oletest.AttrSequence2;
+ sfarray1= new VBArray( ret);
+ arr1= sfarray1.toArray();
+ for( i=0; i < arr1.length; i++)
+ {
+ sfarray2= new VBArray( arr1[i]);
+ arr2= sfarray2.toArray();
+
+ for ( j=0; j < arr2.length; j++)
+ {
+ sfarray3= new VBArray( arr2[j]);
+ arr3= sfarray3.toArray();
+ document.write( i+ " ");
+ document.writeln(j + ": "+ arr3.toString() + "<br>" );
+ }
+
+ }
+ break;
+
+ case 212:
+ var ar= new Array();
+ for( i=0; i< 3; i++)
+ {
+ var ob= new Object();
+ var valueObject= oletest._GetValueObject();
+ ob.value= "A JScript object!";
+ valueObject.Set("com.sun.star.uno.XInterface", ob);
+ ar[i]= valueObject;
+ }
+ value.Set("[]com.sun.star.uno.XInterface", ar);
+
+ oletest.AttrXInterface= value;
+ ret= oletest.AttrXInterface;
+ sfarray= new VBArray( ret);
+ var arRet= sfarray.toArray();
+
+ document.writeln( "Params : Array containing objects ")
+ for( index in ar)
+ {
+ document.writeln( "object " + index + ": " + ar[index].Get().value +" ");
+ }
+ document.writeln( "<br>" ) ;
+ document.writeln("Return: <br>");
+ for( index in arRet)
+ {
+ document.writeln( "object " + index + ": " + arRet[index].value + " ");
+ }
+
+ break;
+
+ // Out-parameter ------------------------------------------------------------
+ case (2000):
+
+ oletest.testout_methodByte( outValue );
+ alert("byte: " + outValue.Get() ); break;
+ case (2001):
+ oletest.testout_methodDouble( outValue );
+ alert( "double: " + outValue.Get() ); break;
+ case (2002):
+ oletest.testout_methodBool( outValue );
+ alert( "boolean: " + outValue.Get() ); break;
+ case (2003):
+ oletest.testout_methodShort( outValue );
+ alert( "short: " + outValue.Get() ); break;
+ case (2004):
+ oletest.testout_methodUShort( outValue );
+ alert( "unsigned short: " + outValue.Get() ); break;
+ case (2005):
+ oletest.testout_methodLong( outValue );
+ alert( "long: " + outValue.Get() ); break;
+ case (2006):
+ oletest.testout_methodULong( outValue );
+ alert( "unsigned long: " + outValue.Get() ); break;
+ case (2007):
+ oletest.testout_methodChar( outValue );
+ alert( "char: " + outValue.Get() ); break;
+ case (2008):
+ oletest.testout_methodString( outValue );
+ alert( "string: " + outValue.Get()); break;
+ case (2009):
+ oletest.testout_methodAny( outValue );
+ alert( "any: " + outValue.Get() ); break;
+ case (2010):
+ oletest.testout_methodSequence( outValue );
+ var sfarray= new VBArray( outValue.Get());
+ arr= sfarray.toArray();
+ document.writeln("use the browser's back arrow to go to the previous page <p>");
+ document.writeln( arr.toString());
+ break;
+ case (2011):
+ oletest.testout_methodSequence2( outValue );
+ var sfarray= new VBArray( outValue.Get());
+ arr= sfarray.toArray();
+ var i;
+ for( i=0; i < arr.length; i++)
+ {
+ var sfarray= new VBArray( arr[i]);
+ var arr2= new Array();
+ arr2= sfarray.toArray();
+ document.writeln( arr2.toString() + "<br>" );
+ }
+ break;
+ case (2012):
+ oletest.testout_methodMulParams1( outValue, outValue2 );
+ document.writeln( "int : " + outValue.Get() + " int :" + outValue2.Get()); break;
+ case (2013):
+ oletest.testout_methodMulParams2( outValue, outValue2, outValue3 );
+ document.writeln( "int: " + outValue.Get() + " int: " + outValue2.Get() + " string: " + outValue3.Get() ); break;
+ case (2014):
+ oletest.testout_methodMulParams3( "hallo", outValue );
+ document.writeln( "string: " + outValue.Get() ); break;
+ case (2015):
+ oletest.testout_methodXInterface( outValue );
+ var out= outValue.Get();
+ document.writeln( "string: " + out.AttrAny2); break;
+
+ // INOUT - Parameter -------------------------------------------------------------------------------
+ // The in value has to be placed on index 0 of the passed in array
+ case (500):
+ inoutValue.InitInOutParam("byte", 100);
+ oletest.testinout_methodByte( inoutValue );
+ alert("byte: " + inoutValue.Get() ); break;
+ case (501):
+ inoutValue.InitInOutParam("double", 3.14);
+ oletest.testinout_methodDouble( inoutValue );
+ alert( "double: " + inoutValue.Get() ); break;
+ case (502):
+ inoutValue.InitInOutParam("boolean", false);
+ oletest.testinout_methodBool( inoutValue );
+ alert( "boolean: " + inoutValue.Get() ); break;
+ case (503):
+ inoutValue.InitInOutParam( "short", 200);
+ oletest.testinout_methodShort( inoutValue );
+ alert( "short: " + inoutValue.Get() ); break;
+ case (504):
+ inoutValue.InitInOutParam("unsigned short", 300);
+ oletest.testinout_methodUShort( inoutValue );
+ alert( "unsigned short: " + inoutValue.Get() ); break;
+ case (505):
+ inoutValue.InitInOutParam("long", 400);
+ oletest.testinout_methodLong( inoutValue );
+ alert( "long: " + inoutValue.Get() ); break;
+ case (506):
+ inoutValue.InitInOutParam( "unsigned long", 500);
+ oletest.testinout_methodULong( inoutValue );
+ alert( "unsigned long: " + inoutValue.Get() ); break;
+ case (507):
+ inoutValue.InitInOutParam( "char", "A");
+ oletest.testinout_methodChar( inoutValue );
+ alert( "char: " + inoutValue.Get() ); break;
+ case (508):
+ inoutValue.InitInOutParam("string", "I am a string");
+ oletest.testinout_methodString( inoutValue );
+ alert( "string: " + inoutValue.Get() ); break;
+ case (509):
+ inoutValue.InitInOutParam("[]long", arr);
+ oletest.testinout_methodAny( inoutValue ); // the method simply returns the argument
+ sfarray= new VBArray( inoutValue.Get());
+ arr= sfarray.toArray();
+ alert( "any: " + arr.toString() ); break;
+ case (510):
+ inoutValue.InitInOutParam("[]long", arr);
+ oletest.testinout_methodSequence( inoutValue );
+ var sfarray= new VBArray( inoutValue.Get());
+ arr= sfarray.toArray();
+ document.writeln("use the browser's back arrow to go to the previous page <p>");
+ document.writeln( arr.toString());
+ break;
+ case (511):
+ inoutValue.InitInOutParam( "[][]long", arrSeq);
+ oletest.testinout_methodSequence2( inoutValue );
+ var sfarray= new VBArray( inoutValue.Get());
+ arr= sfarray.toArray();
+ var i;
+ for( i=0; i < arr.length; i++)
+ {
+ var sfarray= new VBArray( arr[i]);
+ var arr2= new Array();
+ arr2= sfarray.toArray();
+ document.writeln( arr2.toString() + "<br>" );
+ }
+ break;
+ case 512:
+ var ob= new Object();
+ ob.value= "this is a string";
+ inoutValue.InitInOutParam( "com.sun.star.script.XInvocation", ob);
+ oletest.testinout_methodXInterface( inoutValue);
+ document.write("Out value: " + inoutValue.Get().value );
+ break;
+
+
+
+
+
+ // Test ANY
+ // Methods
+ case 1000:
+ i= 100;
+ ret= oletest.methodAnyTest1( i);
+ document.writeln( "in: " + i + " ret: " + ret);
+ break;
+ case 1001:
+ i= 3.14;
+ ret= oletest.methodAnyTest1( i);
+ document.writeln( "in: " + i + " ret: " + ret);
+ break;
+ case 1002:
+ i= "Hallo"
+ ret= oletest.methodAnyTest1( i);
+ document.writeln( "in: " + i + " ret: " + ret);
+ break;
+ case 1003:
+ i= arr;
+ ret= oletest.methodAnyTest1( i);
+ sfarray= new VBArray( ret);
+ document.writeln( "in: " + i + " ret: " + sfarray.toArray());
+ break;
+ case 1004:
+ var obj= new Object();
+ obj[1]= "This is index 0";
+ ret= oletest.methodAnyTest1( obj);
+ document.writeln( "in: " + obj + " ret: " + ret);
+ break;
+
+
+ // Test ANY property
+ case 1010:
+ i= 100;
+ oletest.AttrAny2= i;
+ ret= oletest.AttrAny2;
+ document.writeln( "set: " + i + " get: " + ret);
+ break;
+ case 1011:
+ i= 3.14;
+ oletest.AttrAny2= i;
+ ret= oletest.AttrAny2;
+ document.writeln( "set: " + i + " get: " + ret);
+ break;
+ case 1012:
+ i= "Hallo"
+ oletest.AttrAny2= i;
+ ret= oletest.AttrAny2;
+ document.writeln( "set: " + i + " get: " + ret);
+ break;
+ case 1013:
+ i= arr;
+ oletest.AttrAny2= i;
+ ret= oletest.AttrAny2;
+ sfarray= new VBArray( ret);
+ document.writeln( "set: " + i + " get: " + sfarray.toArray());
+ break;
+ case 1014:
+ var obj= new Object();
+ obj[1]= "This is index 0";
+ oletest.AttrAny2= obj;
+ ret= oletest.AttrAny2;
+ document.writeln( "set: " + obj + " get: " + ret);
+ break;
+
+
+ case 2100:
+ alert("2100");
+ var ret= oletest.retMethodByte();
+ var sfarray= VBArray( ret);
+ document.writeln( sfarray.toArray() );
+ break;
+
+
+// case 5000:
+// oletest.other_methodAnyIn("hallo");
+
+
+
+ }
+
+}
+
+function funcOut( out)
+{
+ out["du"]= 0xffff;
+}
+
+</script>
+
+<script language="VBScript">
+
+sub callBasic(id)
+
+ Dim factory
+ Set factory= GetObject("", "com.sun.star.ServiceManager")
+
+ Set oletest= factory.createInstance("oletest.OleTest")
+
+
+ arrInt= Array(1,2,3,4,5)
+ arrInt2= Array( -1, -2, 127, 128, 0)
+ arrDouble= Array(1.1, 2.2, 3.3, 4.4, 5.5)
+ arrBool= Array(0,1,0,2,0)
+ arrLong= Array( &Hff, &Hffff, &Hffffff, &Hffffffff)
+ arrString= Array("Chicken Wings", "Cheeseburger", "Hamburger")
+ arrChar= Array("a",65, "M")
+ arrAny= Array("Mickey", 3.14, 100, "A")
+
+ Dim arrDim2Int(1,1)
+ For i= 0 To 1
+ For j= 0 To 1
+ arrDim2Int(i,j) = i*2 + j
+ Next
+ Next
+
+ Dim arrDim3Int(1,1,1)
+ For i= 0 To 1
+ For j= 0 To 1
+ For k=0 To 1
+ arrDim3Int(i,j,k) = i*2 + j*2 + k
+ Next
+ Next
+ Next
+
+
+ set outValue= factory.Bridge_GetValueObject()
+ outValue.InitOutParam
+ set value= factory.Bridge_GetValueObject()
+ select case id
+ case 0
+ value.Set "[]byte", arrInt
+ ret= oletest.methodByte(value)
+ document.writeln "<br> return value: "
+ printArray ret
+ case 1
+ document.writeln "param: "
+ printArray arrDouble
+ ret= oletest.methodDouble(arrDouble)
+ document.writeln "<br> return value: "
+ printArray ret
+ case 2
+ document.writeln "param: "
+ printArray arrBool
+ ret= oletest.methodBool(arrBool)
+ document.writeln "<br> return value: "
+ printArray ret
+ case 3
+ document.writeln "param: "
+ printArray arrInt2
+ ret= oletest.methodShort(arrInt2)
+ document.writeln "<br> return value: "
+ printArray ret
+ case 4
+ document.writeln "param: "
+ printArray arrInt
+ ret= oletest.methodUShort(arrInt)
+ document.writeln "<br> return value: "
+ printArray ret
+ case 5
+ document.writeln "param: "
+ printArray arrLong
+ ret= oletest.methodLong(arrLong)
+ document.writeln "<br> return value: "
+ printArray ret
+ case 6
+ document.writeln "param: "
+ printArray arrInt
+ ret= oletest.methodULong(arrInt)
+ document.writeln "<br> return value: "
+ printArray ret
+ case 7
+ document.writeln "param: "
+ printArray arrString
+ ret= oletest.methodString(arrString)
+ document.writeln "<br> return value: "
+ printArray ret
+ case 8
+ document.writeln "param: "
+ printArray arrChar
+ ret= oletest.methodChar(arrChar)
+ document.writeln "<br> return value: "
+ printArray ret
+ case 9
+ document.writeln "param: "
+ printArray arrAny
+ ret= oletest.methodAny(arrAny)
+ document.writeln "<br> return value: "
+ printArray ret
+ case 10
+ document.writeln "param: "
+ printArray2 arrDim2Int
+ ret= oletest.methodSequence(arrDim2Int)
+ document.writeln "<br> return value: "
+ for each val in ret
+ document.write "<br> array: "
+ for each val2 in val
+ document.write val2
+ next
+ next
+
+ // In Out Parameter --------------------------------------------------
+ case 100
+ a= 100
+ document.write "param: " & CStr( a) & "<br>"
+ oletest.testinout_methodByte a
+ document.write a
+ case 101
+ a= 1.11
+ document.write "param: " & CStr( a) & "<br>"
+ oletest.testinout_methodDouble a
+ document.write a
+ case 102
+ a= 5
+ document.write "param: "& CStr( a) & "<br>"
+ oletest.testinout_methodBool a
+ document.write a
+ case 103
+ a= -10
+ document.write "param: "& CStr( a) & "<br>"
+ oletest.testinout_methodShort a
+ document.write a
+ case 104
+ a= 128
+ document.write "param: "& CStr( a) & "<br>"
+ oletest.testinout_methodUShort a
+ document.write a
+ case 105
+ a= 65556
+ document.write "param: "& CStr( a) & "<br>"
+ oletest.testinout_methodLong a
+ document.write a
+ case 106
+ a= 65556
+ document.write "param: "& CStr( a) & "<br>"
+ oletest.testinout_methodULong a
+ document.write a
+ case 107
+ a= "ein test string"
+ document.write "param: "& CStr( a) & "<br>"
+ oletest.testinout_methodString a
+ document.write a
+ case 108
+ a= "W"
+ document.write "param: "& CStr( a) & "<br>"
+ oletest.testinout_methodChar a
+ document.write a
+ case 109
+ a= "Ein String im Any"
+ document.write "param: "& CStr( a) & "<br>"
+ oletest.other_methodAnyIn a
+ document.write a
+// Attributes -----------------------------------------------------------------
+ case 200
+ document.write "set: "
+ printArray arrInt
+ oletest.AttrByte= arrInt
+ b= oletest.AttrByte
+ call printArrayEx( "<br> get: ", "<br>", b)
+ case 201
+ document.write "set: "
+ printArray arrDouble
+ oletest.AttrDouble= arrDouble
+ b= oletest.AttrDouble
+ call printArrayEx( "<br> get: ", "<br>", b)
+ case 202
+ document.write "set: "
+ printArray arrBool :
+ oletest.AttrBool= arrBool
+ b= oletest.AttrBool
+ call printArrayEx( "<br> get: ", "<br>", b)
+ case 203
+ document.write "set: "
+ printArray arrInt2 :
+ oletest.AttrShort= arrInt2
+ b= oletest.AttrShort
+ call printArrayEx( "<br> get: ", "<br>", b)
+ case 204
+ document.write "set: "
+ printArray arrInt
+ oletest.AttrUShort= arrInt
+ b= oletest.AttrUShort
+ call printArrayEx( "<br> get: ", "<br>", b)
+ case 205
+ document.write "set: "
+ printArray arrInt2
+ oletest.AttrLong= arrInt2
+ b= oletest.AttrLong
+ call printArrayEx( "<br> get: ", "<br>", b)
+ case 206
+ document.write "set: "
+ printArray arrInt
+ oletest.AttrULong= arrInt
+ b= oletest.AttrULong
+ call printArrayEx( "<br> get: ", "<br>", b)
+ case 207
+ document.write "set: "
+ printArray arrString
+ oletest.AttrString= arrString
+ b= oletest.AttrString
+ call printArrayEx( "<br> get: ", "<br>", b)
+ case 208
+ document.write "set: "
+ printArray arrChar
+ oletest.AttrChar= arrChar
+ b= oletest.AttrChar
+ call printArrayEx( "<br> get: ", "<br>", b)
+ case 209
+ document.write "set: "
+ printArray arrAny
+ oletest.AttrAny= arrAny
+ b= oletest.AttrAny
+ call printArrayEx( "<br> get: ", "<br>", b)
+
+ case 210
+ document.write "set: <br>"
+ printArray2 arrDim2Int :
+ oletest.AttrSequence= arrDim2Int
+ ret= oletest.AttrSequence
+ document.write "get: "
+ for each val in ret
+ document.write "<br> array: "
+ for each val2 in val
+ document.write val2
+ next
+ next
+
+// out params
+ case 300
+ oletest.testout_methodByte( outValue )
+ alert("byte: " & outValue.Get() )
+
+
+ end select
+end sub
+sub printArray( arr)
+ document.write "array: "
+ For Each val In arr
+ document.write CStr(val) & " "
+ Next
+end sub
+
+// print a 2 dimensional Array
+
+sub printArray2( arr)
+ elements1= UBound( arr, 1) - LBound( arr, 1) +1
+ elements2= UBound( arr, 2) - LBound( arr, 2) +1
+
+ For i=0 To elements1 -1
+ document.write( "array " & CStr( i) & ": " )
+ For j=0 To elements2 -1
+ document.write CStr( arr(i,j))
+ Next
+ document.write( "<br>")
+ Next
+end sub
+
+sub printArrayEx( pre, post, array)
+ document.write pre
+ printArray array
+ document.write post
+end sub
+</script>
+
+<div id=out> </div>
+
+<!-- Insert HTML here -->
+
+<h2> JScript with _GetValueObject </h2>
+Tests Array/Sequence conversion.<br>
+All methods receive a Sequence as Parameter. The element type of the Sequence is written on the buttons.
+<br>
+<button onclick='callOleTest( 1)'>byte</Button>
+<button onclick='callOleTest( 2)'>double</Button>
+<button onclick='callOleTest( 3)'>boolean</Button>
+<button onclick='callOleTest( 4)'>short</Button>
+<button onclick='callOleTest( 5)'>unsigned short</Button>
+<button onclick='callOleTest( 6)'>long</Button>
+<button onclick='callOleTest( 7)'>unsigned long</Button>
+<button onclick='callOleTest( 8)'>char</Button>
+<button onclick='callOleTest( 10)'>any</Button>
+<button onclick='callOleTest( 11)'>sequence&ltlong&gt </Button>
+<button onclick='callOleTest( 12)'>sequence&ltsequence&ltlong&gt &gt </Button>
+<button onclick='callOleTest( 13)'>XInterface</Button>
+<p>
+
+
+Out Parameter <br>
+<button onclick='callOleTest( 2000)'>byte </Button>
+<button onclick='callOleTest( 2001)'>double</Button>
+<button onclick='callOleTest( 2002)'>boolean</Button>
+<button onclick='callOleTest( 2003)'>short</Button>
+<button onclick='callOleTest( 2004)'>unsigned short</Button>
+<button onclick='callOleTest( 2005)'>long</Button>
+<button onclick='callOleTest( 2006)'>unsigned long</Button>
+<button onclick='callOleTest( 2007)'>char</Button>
+<button onclick='callOleTest( 2008)'>string</Button>
+<button onclick='callOleTest( 2009)'>any</Button>
+<button onclick='callOleTest( 2010)'>sequence&ltlong&gt </Button>
+<button onclick='callOleTest( 2011)'>sequence&ltsequence&ltlong&gt &gt </Button>
+<button onclick='callOleTest( 2012)'>2 out </Button>
+<button onclick='callOleTest( 2013)'>3 out </Button>
+<button onclick='callOleTest( 2014)'>1 in & 1 out </Button>
+<button onclick='callOleTest( 2015)'>XInterface </Button>
+
+<p>
+In Out Parameter <br>
+<button onclick='callOleTest( 500)'>byte </Button>
+<button onclick='callOleTest( 501)'>double</Button>
+<button onclick='callOleTest( 502)'>boolean</Button>
+<button onclick='callOleTest( 503)'>short</Button>
+<button onclick='callOleTest( 504)'>unsigned short</Button>
+<button onclick='callOleTest( 505)'>long</Button>
+<button onclick='callOleTest( 506)'>unsigned long</Button>
+<button onclick='callOleTest( 507)'>char</Button>
+<button onclick='callOleTest( 508)'>string</Button>
+<button onclick='callOleTest( 509)'>any</Button>
+<button onclick='callOleTest( 510)'>sequence&ltlong&gt </Button>
+<button onclick='callOleTest( 511)'>sequence&ltsequence&ltlong&gt &gt </Button>
+<button onclick='callOleTest( 512)'>XInterface </Button>
+<p>
+
+Tests Array/Sequence conversion with Attributes. All params are of type Sequence and
+ the element type of the Sequence is written on the buttons. <br>
+<button onclick='callOleTest( 200)'>byte </Button>
+<button onclick='callOleTest( 201)'>double</Button>
+<button onclick='callOleTest( 202)'>boolean</Button>
+<button onclick='callOleTest( 203)'>short</Button>
+<button onclick='callOleTest( 204)'>unsigned short</Button>
+<button onclick='callOleTest( 205)'>long</Button>
+<button onclick='callOleTest( 206)'>unsigned long</Button>
+<button onclick='callOleTest( 207)'>char</Button>
+<button onclick='callOleTest( 208)'>string</Button>
+<button onclick='callOleTest( 209)'>any</Button>
+<button onclick='callOleTest( 210)'>sequence&ltlong&gt </Button>
+<button onclick='callOleTest( 211)'>sequence&ltsequence&ltlong&gt &gt </Button>
+<button onclick='callOleTest( 212)'>XInterface </Button>
+<p>
+
+<!--
+Test of Any parameter in a method. Any contains:<br>
+<button onclick='callOleTest( 1000)'>integer </Button>
+<button onclick='callOleTest( 1001)'>double </Button>
+<button onclick='callOleTest( 1002)'>string</Button>
+<button onclick='callOleTest( 1003)'>array</Button>
+<button onclick='callOleTest( 1004)'>object</Button>
+<p>
+Test of Any parameter in a property. Any contains:<br>
+<button onclick='callOleTest( 1010)'>integer </Button>
+<button onclick='callOleTest( 1011)'>double </Button>
+<button onclick='callOleTest( 1012)'>string</Button>
+<button onclick='callOleTest( 1013)'>array</Button>
+<button onclick='callOleTest( 1014)'>object</Button>
+<p>
+<p>
+-->
+
+<h2> Visual Basic Tests </h2>
+Test array /Sequence conversion and return value<br>
+Template: <b> Sequence &lt type &gt method( Sequence&lt type &gt ) </b>
+<p>
+
+
+<button onclick='callBasic(0)'>byte</button>
+<!--
+<button onclick='callBasic(1)'>double</button>
+<button onclick='callBasic(2)'>boolean</button>
+<button onclick='callBasic(3)'>short</button>
+<button onclick='callBasic(4)'>u short</button>
+<button onclick='callBasic(5)'>long</button>
+<button onclick='callBasic(6)'>u long</button>
+<button onclick='callBasic(7)'>string</button>
+<button onclick='callBasic(8)'>char</button>
+<button onclick='callBasic(9)'>any</button> <br>
+<button onclick='callBasic(10)'>Seq &lt int &gt</button>
+-->
+<p>
+
+
+Out parameter <br>
+Template: <b> void method( Sequence &lt type &gt ) </b> <br>
+<button onclick='callBasic(300)'>byte</button>
+<!--
+<button onclick='callBasic(101)'>double</button>
+<button onclick='callBasic(102)'>boolean</button>
+<button onclick='callBasic(103)'>short</button>
+<button onclick='callBasic(104)'>u short</button>
+<button onclick='callBasic(105)'>long</button>
+<button onclick='callBasic(106)'>u long</button>
+<button onclick='callBasic(107)'>string</button>
+<button onclick='callBasic(108)'>char</button>
+<button onclick='callBasic(109)'>any</button> <br>
+-->
+<p>
+<!--
+Tests Array/Sequence conversion with <b>Attributes</b>. All params are of type Sequence and
+ the element type of the Sequence is written on the buttons. <br>
+<button onclick='callBasic( 200)'>byte </Button>
+<button onclick='callBasic( 201)'>double</Button>
+<button onclick='callBasic( 202)'>boolean</Button>
+<button onclick='callBasic( 203)'>short</Button>
+<button onclick='callBasic( 204)'>unsigned short</Button>
+<button onclick='callBasic( 205)'>long</Button>
+<button onclick='callBasic( 206)'>unsigned long</Button>
+<button onclick='callBasic( 207)'>string</Button>
+<button onclick='callBasic( 208)'>char</Button>
+<button onclick='callBasic( 209)'>any</Button>
+<button onclick='callBasic( 210)'>sequence&ltlong&gt </Button>
+-->
+
+
+
diff --git a/extensions/test/ole/MfcControl/MfcControl.cpp b/extensions/test/ole/MfcControl/MfcControl.cpp
new file mode 100644
index 000000000000..355476237f93
--- /dev/null
+++ b/extensions/test/ole/MfcControl/MfcControl.cpp
@@ -0,0 +1,82 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+// MfcControl.cpp : Implementation of CMfcControlApp and DLL registration.
+
+#include "stdafx.h"
+#include "MfcControl.h"
+
+#ifdef _DEBUG
+#define new DEBUG_NEW
+#undef THIS_FILE
+static char THIS_FILE[] = __FILE__;
+#endif
+
+
+CMfcControlApp NEAR theApp;
+
+const GUID CDECL BASED_CODE _tlid =
+ { 0xac221fb3, 0xa0d8, 0x11d4, { 0x83, 0x3b, 0, 0x50, 0x4, 0x52, 0x6a, 0xb4 } };
+const WORD _wVerMajor = 1;
+const WORD _wVerMinor = 0;
+
+
+////////////////////////////////////////////////////////////////////////////
+// CMfcControlApp::InitInstance - DLL initialization
+
+BOOL CMfcControlApp::InitInstance()
+{
+ BOOL bInit = COleControlModule::InitInstance();
+
+ if (bInit)
+ {
+ // TODO: Add your own module initialization code here.
+ }
+
+ return bInit;
+}
+
+
+////////////////////////////////////////////////////////////////////////////
+// CMfcControlApp::ExitInstance - DLL termination
+
+int CMfcControlApp::ExitInstance()
+{
+ // TODO: Add your own module termination code here.
+
+ return COleControlModule::ExitInstance();
+}
+
+
+/////////////////////////////////////////////////////////////////////////////
+// DllRegisterServer - Adds entries to the system registry
+
+STDAPI DllRegisterServer(void)
+{
+ AFX_MANAGE_STATE(_afxModuleAddrThis);
+
+ if (!AfxOleRegisterTypeLib(AfxGetInstanceHandle(), _tlid))
+ return ResultFromScode(SELFREG_E_TYPELIB);
+
+ if (!COleObjectFactoryEx::UpdateRegistryAll(TRUE))
+ return ResultFromScode(SELFREG_E_CLASS);
+
+ return NOERROR;
+}
+
+
+/////////////////////////////////////////////////////////////////////////////
+// DllUnregisterServer - Removes entries from the system registry
+
+STDAPI DllUnregisterServer(void)
+{
+ AFX_MANAGE_STATE(_afxModuleAddrThis);
+
+ if (!AfxOleUnregisterTypeLib(_tlid, _wVerMajor, _wVerMinor))
+ return ResultFromScode(SELFREG_E_TYPELIB);
+
+ if (!COleObjectFactoryEx::UpdateRegistryAll(FALSE))
+ return ResultFromScode(SELFREG_E_CLASS);
+
+ return NOERROR;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/test/ole/MfcControl/MfcControl.def b/extensions/test/ole/MfcControl/MfcControl.def
new file mode 100644
index 000000000000..8c164a7b5399
--- /dev/null
+++ b/extensions/test/ole/MfcControl/MfcControl.def
@@ -0,0 +1,9 @@
+; MfcControl.def : Declares the module parameters.
+
+LIBRARY "MFCCONTROL.OCX"
+
+EXPORTS
+ DllCanUnloadNow PRIVATE
+ DllGetClassObject PRIVATE
+ DllRegisterServer PRIVATE
+ DllUnregisterServer PRIVATE
diff --git a/extensions/test/ole/MfcControl/MfcControl.dsp b/extensions/test/ole/MfcControl/MfcControl.dsp
new file mode 100644
index 000000000000..f327a989368e
--- /dev/null
+++ b/extensions/test/ole/MfcControl/MfcControl.dsp
@@ -0,0 +1,265 @@
+# Microsoft Developer Studio Project File - Name="MfcControl" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
+
+CFG=MfcControl - Win32 Debug
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE
+!MESSAGE NMAKE /f "MfcControl.mak".
+!MESSAGE
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE
+!MESSAGE NMAKE /f "MfcControl.mak" CFG="MfcControl - Win32 Debug"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "MfcControl - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE "MfcControl - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE "MfcControl - Win32 Unicode Debug" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE "MfcControl - Win32 Unicode Release" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=cl.exe
+MTL=midl.exe
+RSC=rc.exe
+
+!IF "$(CFG)" == "MfcControl - Win32 Release"
+
+# PROP BASE Use_MFC 2
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release"
+# PROP BASE Intermediate_Dir "Release"
+# PROP BASE Target_Ext "ocx"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 2
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Release"
+# PROP Intermediate_Dir "Release"
+# PROP Target_Ext "ocx"
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MD /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_WINDLL" /D "_AFXDLL" /Yu"stdafx.h" /FD /c
+# ADD CPP /nologo /MD /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_WINDLL" /D "_AFXDLL" /D "_MBCS" /D "_USRDLL" /Yu"stdafx.h" /FD /c
+# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x409 /d "NDEBUG" /d "_AFXDLL"
+# ADD RSC /l 0x409 /d "NDEBUG" /d "_AFXDLL"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 /nologo /subsystem:windows /dll /machine:I386
+# ADD LINK32 /nologo /subsystem:windows /dll /machine:I386
+# Begin Custom Build - Registering ActiveX Control...
+OutDir=.\Release
+TargetPath=.\Release\MfcControl.ocx
+InputPath=.\Release\MfcControl.ocx
+SOURCE="$(InputPath)"
+
+"$(OutDir)\regsvr32.trg" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ regsvr32 /s /c "$(TargetPath)"
+ echo regsvr32 exec. time > "$(OutDir)\regsvr32.trg"
+
+# End Custom Build
+
+!ELSEIF "$(CFG)" == "MfcControl - Win32 Debug"
+
+# PROP BASE Use_MFC 2
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "Debug"
+# PROP BASE Intermediate_Dir "Debug"
+# PROP BASE Target_Ext "ocx"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 2
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "Debug"
+# PROP Intermediate_Dir "Debug"
+# PROP Target_Ext "ocx"
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_WINDLL" /D "_AFXDLL" /Yu"stdafx.h" /FD /GZ /c
+# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_WINDLL" /D "_AFXDLL" /D "_MBCS" /D "_USRDLL" /FR /Yu"stdafx.h" /FD /GZ /c
+# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x409 /d "_DEBUG" /d "_AFXDLL"
+# ADD RSC /l 0x409 /d "_DEBUG" /d "_AFXDLL"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 /nologo /subsystem:windows /dll /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 /nologo /subsystem:windows /dll /debug /machine:I386 /pdbtype:sept
+# Begin Custom Build - Registering ActiveX Control...
+OutDir=.\Debug
+TargetPath=.\Debug\MfcControl.ocx
+InputPath=.\Debug\MfcControl.ocx
+SOURCE="$(InputPath)"
+
+"$(OutDir)\regsvr32.trg" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ regsvr32 /s /c "$(TargetPath)"
+ echo regsvr32 exec. time > "$(OutDir)\regsvr32.trg"
+
+# End Custom Build
+
+!ELSEIF "$(CFG)" == "MfcControl - Win32 Unicode Debug"
+
+# PROP BASE Use_MFC 2
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "DebugU"
+# PROP BASE Intermediate_Dir "DebugU"
+# PROP BASE Target_Ext "ocx"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 2
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "DebugU"
+# PROP Intermediate_Dir "DebugU"
+# PROP Target_Ext "ocx"
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_WINDLL" /D "_AFXDLL" /D "_MBCS" /D "_USRDLL" /Yu"stdafx.h" /FD /GZ /c
+# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_WINDLL" /D "_AFXDLL" /D "_USRDLL" /D "_UNICODE" /Yu"stdafx.h" /FD /GZ /c
+# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x409 /d "_DEBUG" /d "_AFXDLL"
+# ADD RSC /l 0x409 /d "_DEBUG" /d "_AFXDLL"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 /nologo /subsystem:windows /dll /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 /nologo /subsystem:windows /dll /debug /machine:I386 /pdbtype:sept
+# Begin Custom Build - Registering ActiveX Control...
+OutDir=.\DebugU
+TargetPath=.\DebugU\MfcControl.ocx
+InputPath=.\DebugU\MfcControl.ocx
+SOURCE="$(InputPath)"
+
+"$(OutDir)\regsvr32.trg" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ regsvr32 /s /c "$(TargetPath)"
+ echo regsvr32 exec. time > "$(OutDir)\regsvr32.trg"
+
+# End Custom Build
+
+!ELSEIF "$(CFG)" == "MfcControl - Win32 Unicode Release"
+
+# PROP BASE Use_MFC 2
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "ReleaseU"
+# PROP BASE Intermediate_Dir "ReleaseU"
+# PROP BASE Target_Ext "ocx"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 2
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "ReleaseU"
+# PROP Intermediate_Dir "ReleaseU"
+# PROP Target_Ext "ocx"
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MD /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_WINDLL" /D "_AFXDLL" /D "_MBCS" /D "_USRDLL" /Yu"stdafx.h" /FD /c
+# ADD CPP /nologo /MD /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_WINDLL" /D "_AFXDLL" /D "_USRDLL" /D "_UNICODE" /Yu"stdafx.h" /FD /c
+# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x409 /d "NDEBUG" /d "_AFXDLL"
+# ADD RSC /l 0x409 /d "NDEBUG" /d "_AFXDLL"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 /nologo /subsystem:windows /dll /machine:I386
+# ADD LINK32 /nologo /subsystem:windows /dll /machine:I386
+# Begin Custom Build - Registering ActiveX Control...
+OutDir=.\ReleaseU
+TargetPath=.\ReleaseU\MfcControl.ocx
+InputPath=.\ReleaseU\MfcControl.ocx
+SOURCE="$(InputPath)"
+
+"$(OutDir)\regsvr32.trg" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ regsvr32 /s /c "$(TargetPath)"
+ echo regsvr32 exec. time > "$(OutDir)\regsvr32.trg"
+
+# End Custom Build
+
+!ENDIF
+
+# Begin Target
+
+# Name "MfcControl - Win32 Release"
+# Name "MfcControl - Win32 Debug"
+# Name "MfcControl - Win32 Unicode Debug"
+# Name "MfcControl - Win32 Unicode Release"
+# Begin Group "Source Files"
+
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+# Begin Source File
+
+SOURCE=.\MfcControl.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\MfcControl.def
+# End Source File
+# Begin Source File
+
+SOURCE=.\MfcControl.odl
+# End Source File
+# Begin Source File
+
+SOURCE=.\MfcControl.rc
+# End Source File
+# Begin Source File
+
+SOURCE=.\MfcControlCtl.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\MfcControlPpg.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\StdAfx.cpp
+# ADD CPP /Yc"stdafx.h"
+# End Source File
+# End Group
+# Begin Group "Header Files"
+
+# PROP Default_Filter "h;hpp;hxx;hm;inl"
+# Begin Source File
+
+SOURCE=.\MfcControl.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\MfcControlCtl.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\MfcControlPpg.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\Resource.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\StdAfx.h
+# End Source File
+# End Group
+# Begin Group "Resource Files"
+
+# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
+# Begin Source File
+
+SOURCE=.\MfcControlCtl.bmp
+# End Source File
+# End Group
+# Begin Source File
+
+SOURCE=.\ReadMe.txt
+# End Source File
+# End Target
+# End Project
+
diff --git a/extensions/test/ole/MfcControl/MfcControl.h b/extensions/test/ole/MfcControl/MfcControl.h
new file mode 100644
index 000000000000..6c6a190b5b09
--- /dev/null
+++ b/extensions/test/ole/MfcControl/MfcControl.h
@@ -0,0 +1,36 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+#if !defined(AFX_MFCCONTROL_H__AC221FBC_A0D8_11D4_833B_005004526AB4__INCLUDED_)
+#define AFX_MFCCONTROL_H__AC221FBC_A0D8_11D4_833B_005004526AB4__INCLUDED_
+
+#if _MSC_VER > 1000
+#pragma once
+#endif // _MSC_VER > 1000
+
+// MfcControl.h : main header file for MFCCONTROL.DLL
+
+#if !defined( __AFXCTL_H__ )
+ #error include 'afxctl.h' before including this file
+#endif
+
+#include "resource.h" // main symbols
+
+/////////////////////////////////////////////////////////////////////////////
+// CMfcControlApp : See MfcControl.cpp for implementation.
+
+class CMfcControlApp : public COleControlModule
+{
+public:
+ BOOL InitInstance();
+ int ExitInstance();
+};
+
+extern const GUID CDECL _tlid;
+extern const WORD _wVerMajor;
+extern const WORD _wVerMinor;
+
+//{{AFX_INSERT_LOCATION}}
+// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
+
+#endif // !defined(AFX_MFCCONTROL_H__AC221FBC_A0D8_11D4_833B_005004526AB4__INCLUDED)
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/test/ole/MfcControl/MfcControl.odl b/extensions/test/ole/MfcControl/MfcControl.odl
new file mode 100644
index 000000000000..f00ebe518179
--- /dev/null
+++ b/extensions/test/ole/MfcControl/MfcControl.odl
@@ -0,0 +1,82 @@
+// MfcControl.odl : type library source for ActiveX Control project.
+
+// This file will be processed by the Make Type Library (mktyplib) tool to
+// produce the type library (MfcControl.tlb) that will become a resource in
+// MfcControl.ocx.
+
+#include <olectl.h>
+#include <idispids.h>
+
+[ uuid(AC221FB3-A0D8-11D4-833B-005004526AB4), version(1.0),
+ helpfile("MfcControl.hlp"),
+ helpstring("MfcControl ActiveX Control module"),
+ control ]
+library MFCCONTROLLib
+{
+ importlib(STDOLE_TLB);
+ importlib(STDTYPE_TLB);
+
+ // Primary dispatch interface for CMfcControlCtrl
+
+ [ uuid(AC221FB4-A0D8-11D4-833B-005004526AB4),
+ helpstring("Dispatch interface for MfcControl Control"), hidden ]
+ dispinterface _DMfcControl
+ {
+ properties:
+ // NOTE - ClassWizard will maintain property information here.
+ // Use extreme caution when editing this section.
+ //{{AFX_ODL_PROP(CMfcControlCtrl)
+ //}}AFX_ODL_PROP
+
+ methods:
+ // NOTE - ClassWizard will maintain method information here.
+ // Use extreme caution when editing this section.
+ //{{AFX_ODL_METHOD(CMfcControlCtrl)
+ [id(1)] short inShort(short val);
+ [id(2)] long inLong(long val);
+ [id(3)] BSTR inString(BSTR* val);
+ [id(4)] float inFloat(float val);
+ [id(5)] double inDouble(double val);
+ [id(6)] VARIANT inVariant(VARIANT val);
+ [id(7)] IDispatch* inObject(IDispatch* val);
+ [id(8)] void outShort([out] short* val);
+ [id(9)] void outLong([out] long* val);
+ [id(10)] void outString([out] BSTR* val);
+ [id(11)] void outFloat([out] float* val);
+ [id(12)] void outDouble([out] double* val);
+ [id(13)] void outVariant([out] VARIANT* val);
+ [id(14)] void outObject([out] IDispatch** val);
+ //}}AFX_ODL_METHOD
+ };
+
+ // Event dispatch interface for CMfcControlCtrl
+
+ [ uuid(AC221FB5-A0D8-11D4-833B-005004526AB4),
+ helpstring("Event interface for MfcControl Control") ]
+ dispinterface _DMfcControlEvents
+ {
+ properties:
+ // Event interface has no properties
+
+ methods:
+ // NOTE - ClassWizard will maintain event information here.
+ // Use extreme caution when editing this section.
+ //{{AFX_ODL_EVENT(CMfcControlCtrl)
+ //}}AFX_ODL_EVENT
+ };
+
+ // Class information for CMfcControlCtrl
+
+ [ uuid(AC221FB6-A0D8-11D4-833B-005004526AB4),
+ helpstring("MfcControl Control"), control ]
+ coclass MfcControl
+ {
+ [default] dispinterface _DMfcControl;
+ [default, source] dispinterface _DMfcControlEvents;
+ };
+
+
+ //{{AFX_APPEND_ODL}}
+ //}}AFX_APPEND_ODL}}
+};
+//VT_I2
diff --git a/extensions/test/ole/MfcControl/MfcControl.rc b/extensions/test/ole/MfcControl/MfcControl.rc
new file mode 100644
index 000000000000..e052b9f261a6
--- /dev/null
+++ b/extensions/test/ole/MfcControl/MfcControl.rc
@@ -0,0 +1,145 @@
+//Microsoft Visual C++ generated resource script.
+//
+#include "resource.h"
+
+#define APSTUDIO_READONLY_SYMBOLS
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 2 resource.
+//
+#include "afxres.h"
+
+/////////////////////////////////////////////////////////////////////////////
+#undef APSTUDIO_READONLY_SYMBOLS
+
+#ifdef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// TEXTINCLUDE
+//
+
+1 TEXTINCLUDE DISCARDABLE
+BEGIN
+ "resource.h\0"
+END
+
+2 TEXTINCLUDE DISCARDABLE
+BEGIN
+ "#include ""afxres.h""\r\n"
+ "\0"
+END
+
+3 TEXTINCLUDE DISCARDABLE
+BEGIN
+ "1 TYPELIB ""MfcControl.tlb""\r\n"
+ "\0"
+END
+
+/////////////////////////////////////////////////////////////////////////////
+#endif // APSTUDIO_INVOKED
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Version
+//
+
+VS_VERSION_INFO VERSIONINFO
+ FILEVERSION 1,0,0,1
+ PRODUCTVERSION 1,0,0,1
+ FILEFLAGSMASK 0x3fL
+#ifdef _DEBUG
+ FILEFLAGS 0x1L
+#else
+ FILEFLAGS 0x0L
+#endif
+ FILEOS 0x4L
+ FILETYPE 0x2L
+ FILESUBTYPE 0x0L
+BEGIN
+ BLOCK "StringFileInfo"
+ BEGIN
+ BLOCK "040904B0"
+ BEGIN
+ VALUE "CompanyName", "Star Office Entwicklungs GmbH\0"
+ VALUE "FileDescription", "MfcControl ActiveX Control Module\0"
+ VALUE "FileVersion", "1, 0, 0, 1\0"
+ VALUE "InternalName", "MfcControl\0"
+ VALUE "LegalCopyright", "Copyright (C) 2000\0"
+ VALUE "LegalTrademarks", "\0"
+ VALUE "OriginalFilename", "MfcControl.OCX\0"
+ VALUE "ProductName", "MfcControl ActiveX Control Module\0"
+ VALUE "ProductVersion", "1, 0, 0, 1\0"
+ VALUE "OLESelfRegister", "\0"
+ END
+ END
+ BLOCK "VarFileInfo"
+ BEGIN
+ VALUE "Translation", 0x409, 1200
+ END
+END
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Bitmap
+//
+
+//IDB_MFCCONTROL BITMAP DISCARDABLE "MfcControlCtl.bmp"
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Dialog
+//
+
+
+IDD_PROPPAGE_MFCCONTROL DIALOG DISCARDABLE 0, 0, 250, 62
+STYLE WS_CHILD
+FONT 8, "MS Sans Serif"
+BEGIN
+ LTEXT "TODO: Place controls to manipulate properties of MfcControl Control on this dialog.",
+ IDC_STATIC,7,25,229,16
+END
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// DESIGNINFO
+//
+
+#ifdef APSTUDIO_INVOKED
+GUIDELINES DESIGNINFO DISCARDABLE
+BEGIN
+ IDD_PROPPAGE_MFCCONTROL, DIALOG
+ BEGIN
+ LEFTMARGIN, 7
+ RIGHTMARGIN, 243
+ TOPMARGIN, 7
+ BOTTOMMARGIN, 55
+ END
+END
+#endif // APSTUDIO_INVOKED
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// String Table
+//
+
+STRINGTABLE DISCARDABLE
+BEGIN
+ IDS_MFCCONTROL "MfcControl Control"
+ IDS_MFCCONTROL_PPG "MfcControl Property Page"
+ IDS_MFCCONTROL_PPG_CAPTION "General"
+
+END
+
+
+#ifndef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 3 resource.
+//
+1 TYPELIB "MfcControl.tlb"
+
+/////////////////////////////////////////////////////////////////////////////
+#endif // not APSTUDIO_INVOKED
+
diff --git a/extensions/test/ole/MfcControl/MfcControl.sln b/extensions/test/ole/MfcControl/MfcControl.sln
new file mode 100644
index 000000000000..24e646c8626b
--- /dev/null
+++ b/extensions/test/ole/MfcControl/MfcControl.sln
@@ -0,0 +1,25 @@
+Microsoft Visual Studio Solution File, Format Version 10.00
+# Visual Studio 2008
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MfcControl", "MfcControl.vcproj", "{07D59661-3519-4F10-AE9F-22DB0479E25A}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Win32 = Debug|Win32
+ Release|Win32 = Release|Win32
+ Unicode Debug|Win32 = Unicode Debug|Win32
+ Unicode Release|Win32 = Unicode Release|Win32
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {07D59661-3519-4F10-AE9F-22DB0479E25A}.Debug|Win32.ActiveCfg = Debug|Win32
+ {07D59661-3519-4F10-AE9F-22DB0479E25A}.Debug|Win32.Build.0 = Debug|Win32
+ {07D59661-3519-4F10-AE9F-22DB0479E25A}.Release|Win32.ActiveCfg = Release|Win32
+ {07D59661-3519-4F10-AE9F-22DB0479E25A}.Release|Win32.Build.0 = Release|Win32
+ {07D59661-3519-4F10-AE9F-22DB0479E25A}.Unicode Debug|Win32.ActiveCfg = Unicode Debug|Win32
+ {07D59661-3519-4F10-AE9F-22DB0479E25A}.Unicode Debug|Win32.Build.0 = Unicode Debug|Win32
+ {07D59661-3519-4F10-AE9F-22DB0479E25A}.Unicode Release|Win32.ActiveCfg = Unicode Release|Win32
+ {07D59661-3519-4F10-AE9F-22DB0479E25A}.Unicode Release|Win32.Build.0 = Unicode Release|Win32
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
diff --git a/extensions/test/ole/MfcControl/MfcControl.vcproj b/extensions/test/ole/MfcControl/MfcControl.vcproj
new file mode 100644
index 000000000000..6099d8242de6
--- /dev/null
+++ b/extensions/test/ole/MfcControl/MfcControl.vcproj
@@ -0,0 +1,581 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="9,00"
+ Name="MfcControl"
+ ProjectGUID="{07D59661-3519-4F10-AE9F-22DB0479E25A}"
+ RootNamespace="MfcControl"
+ Keyword="MFCProj"
+ TargetFrameworkVersion="131072"
+ >
+ <Platforms>
+ <Platform
+ Name="Win32"
+ />
+ </Platforms>
+ <ToolFiles>
+ </ToolFiles>
+ <Configurations>
+ <Configuration
+ Name="Unicode Release|Win32"
+ OutputDirectory=".\ReleaseU"
+ IntermediateDirectory=".\ReleaseU"
+ ConfigurationType="2"
+ InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC70.vsprops"
+ UseOfMFC="2"
+ ATLMinimizesCRunTimeLibraryUsage="false"
+ CharacterSet="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ Description="Registering ActiveX Control..."
+ CommandLine="regsvr32 /s /c &quot;$(TargetPath)&quot;&#x0D;&#x0A;echo regsvr32 exec. time &gt; &quot;$(OutDir)\regsvr32.trg&quot;&#x0D;&#x0A;"
+ Outputs="$(OutDir)\regsvr32.trg"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ PreprocessorDefinitions="NDEBUG"
+ MkTypLibCompatible="true"
+ SuppressStartupBanner="true"
+ TargetEnvironment="1"
+ TypeLibraryName=".\ReleaseU/MfcControl.tlb"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ InlineFunctionExpansion="1"
+ PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL"
+ StringPooling="true"
+ RuntimeLibrary="2"
+ EnableFunctionLevelLinking="true"
+ UsePrecompiledHeader="2"
+ PrecompiledHeaderThrough="stdafx.h"
+ PrecompiledHeaderFile=".\ReleaseU/MfcControl.pch"
+ AssemblerListingLocation=".\ReleaseU/"
+ ObjectFile=".\ReleaseU/"
+ ProgramDataBaseFileName=".\ReleaseU/"
+ WarningLevel="3"
+ SuppressStartupBanner="true"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ PreprocessorDefinitions="_AFXDLL;NDEBUG"
+ Culture="1033"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalOptions="/MACHINE:I386"
+ OutputFile=".\ReleaseU/MfcControl.ocx"
+ LinkIncremental="1"
+ SuppressStartupBanner="true"
+ ModuleDefinitionFile=".\MfcControl.def"
+ ProgramDatabaseFile=".\ReleaseU/MfcControl.pdb"
+ SubSystem="2"
+ RandomizedBaseAddress="1"
+ DataExecutionPrevention="0"
+ ImportLibrary=".\ReleaseU/MfcControl.lib"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Unicode Debug|Win32"
+ OutputDirectory=".\DebugU"
+ IntermediateDirectory=".\DebugU"
+ ConfigurationType="2"
+ InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC70.vsprops"
+ UseOfMFC="2"
+ ATLMinimizesCRunTimeLibraryUsage="false"
+ CharacterSet="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ Description="Registering ActiveX Control..."
+ CommandLine="regsvr32 /s /c &quot;$(TargetPath)&quot;&#x0D;&#x0A;echo regsvr32 exec. time &gt; &quot;$(OutDir)\regsvr32.trg&quot;&#x0D;&#x0A;"
+ Outputs="$(OutDir)\regsvr32.trg"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ PreprocessorDefinitions="_DEBUG"
+ MkTypLibCompatible="true"
+ SuppressStartupBanner="true"
+ TargetEnvironment="1"
+ TypeLibraryName=".\DebugU/MfcControl.tlb"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="3"
+ UsePrecompiledHeader="2"
+ PrecompiledHeaderThrough="stdafx.h"
+ PrecompiledHeaderFile=".\DebugU/MfcControl.pch"
+ AssemblerListingLocation=".\DebugU/"
+ ObjectFile=".\DebugU/"
+ ProgramDataBaseFileName=".\DebugU/"
+ WarningLevel="3"
+ SuppressStartupBanner="true"
+ DebugInformationFormat="4"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ PreprocessorDefinitions="_AFXDLL;_DEBUG"
+ Culture="1033"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalOptions="/MACHINE:I386"
+ OutputFile=".\DebugU/MfcControl.ocx"
+ LinkIncremental="2"
+ SuppressStartupBanner="true"
+ ModuleDefinitionFile=".\MfcControl.def"
+ GenerateDebugInformation="true"
+ ProgramDatabaseFile=".\DebugU/MfcControl.pdb"
+ SubSystem="2"
+ RandomizedBaseAddress="1"
+ DataExecutionPrevention="0"
+ ImportLibrary=".\DebugU/MfcControl.lib"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory=".\Release"
+ IntermediateDirectory=".\Release"
+ ConfigurationType="2"
+ InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC70.vsprops"
+ UseOfMFC="2"
+ ATLMinimizesCRunTimeLibraryUsage="false"
+ CharacterSet="2"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ Description="Registering ActiveX Control..."
+ CommandLine="regsvr32 /s /c &quot;$(TargetPath)&quot;&#x0D;&#x0A;echo regsvr32 exec. time &gt; &quot;$(OutDir)\regsvr32.trg&quot;&#x0D;&#x0A;"
+ Outputs="$(OutDir)\regsvr32.trg"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ PreprocessorDefinitions="NDEBUG"
+ MkTypLibCompatible="true"
+ SuppressStartupBanner="true"
+ TargetEnvironment="1"
+ TypeLibraryName=".\Release/MfcControl.tlb"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ InlineFunctionExpansion="1"
+ PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL"
+ StringPooling="true"
+ RuntimeLibrary="2"
+ EnableFunctionLevelLinking="true"
+ UsePrecompiledHeader="2"
+ PrecompiledHeaderThrough="stdafx.h"
+ PrecompiledHeaderFile=".\Release/MfcControl.pch"
+ AssemblerListingLocation=".\Release/"
+ ObjectFile=".\Release/"
+ ProgramDataBaseFileName=".\Release/"
+ WarningLevel="3"
+ SuppressStartupBanner="true"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ PreprocessorDefinitions="_AFXDLL;NDEBUG"
+ Culture="1033"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalOptions="/MACHINE:I386"
+ OutputFile=".\Release/MfcControl.ocx"
+ LinkIncremental="1"
+ SuppressStartupBanner="true"
+ ModuleDefinitionFile=".\MfcControl.def"
+ ProgramDatabaseFile=".\Release/MfcControl.pdb"
+ SubSystem="2"
+ RandomizedBaseAddress="1"
+ DataExecutionPrevention="0"
+ ImportLibrary=".\Release/MfcControl.lib"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory=".\Debug"
+ IntermediateDirectory=".\Debug"
+ ConfigurationType="2"
+ InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC70.vsprops"
+ UseOfMFC="2"
+ ATLMinimizesCRunTimeLibraryUsage="false"
+ CharacterSet="2"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ Description="Registering ActiveX Control..."
+ CommandLine="regsvr32 /s /c &quot;$(TargetPath)&quot;&#x0D;&#x0A;echo regsvr32 exec. time &gt; &quot;$(OutDir)\regsvr32.trg&quot;&#x0D;&#x0A;"
+ Outputs="$(OutDir)\regsvr32.trg"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ PreprocessorDefinitions="_DEBUG"
+ MkTypLibCompatible="true"
+ SuppressStartupBanner="true"
+ TargetEnvironment="1"
+ TypeLibraryName=".\Debug/MfcControl.tlb"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalOptions="/D_CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES"
+ Optimization="0"
+ PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="3"
+ UsePrecompiledHeader="2"
+ PrecompiledHeaderThrough="stdafx.h"
+ PrecompiledHeaderFile=".\Debug/MfcControl.pch"
+ AssemblerListingLocation=".\Debug/"
+ ObjectFile=".\Debug/"
+ ProgramDataBaseFileName=".\Debug/"
+ BrowseInformation="1"
+ WarningLevel="3"
+ SuppressStartupBanner="true"
+ DebugInformationFormat="4"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ PreprocessorDefinitions="_AFXDLL;_DEBUG"
+ Culture="1033"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalOptions="/MACHINE:I386"
+ OutputFile=".\Debug/MfcControl.ocx"
+ LinkIncremental="2"
+ SuppressStartupBanner="true"
+ ModuleDefinitionFile=".\MfcControl.def"
+ GenerateDebugInformation="true"
+ ProgramDatabaseFile=".\Debug/MfcControl.pdb"
+ SubSystem="2"
+ RandomizedBaseAddress="1"
+ DataExecutionPrevention="0"
+ ImportLibrary=".\Debug/MfcControl.lib"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Name="Source Files"
+ Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+ >
+ <File
+ RelativePath=".\MfcControl.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\MfcControl.def"
+ >
+ </File>
+ <File
+ RelativePath=".\MfcControl.odl"
+ >
+ <FileConfiguration
+ Name="Unicode Release|Win32"
+ >
+ <Tool
+ Name="VCMIDLTool"
+ TargetEnvironment="1"
+ HeaderFileName="MfcControl_h.h"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Unicode Debug|Win32"
+ >
+ <Tool
+ Name="VCMIDLTool"
+ TargetEnvironment="1"
+ HeaderFileName="MfcControl_h.h"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCMIDLTool"
+ TargetEnvironment="1"
+ HeaderFileName="MfcControl_h.h"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCMIDLTool"
+ TargetEnvironment="1"
+ HeaderFileName="MfcControl_h.h"
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath=".\MfcControl.rc"
+ >
+ <FileConfiguration
+ Name="Unicode Release|Win32"
+ >
+ <Tool
+ Name="VCResourceCompilerTool"
+ AdditionalIncludeDirectories="$(OUTDIR);$(NoInherit)"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Unicode Debug|Win32"
+ >
+ <Tool
+ Name="VCResourceCompilerTool"
+ AdditionalIncludeDirectories="$(OUTDIR);$(NoInherit)"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCResourceCompilerTool"
+ AdditionalIncludeDirectories="$(OUTDIR);$(NoInherit)"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCResourceCompilerTool"
+ AdditionalIncludeDirectories="$(OUTDIR);$(NoInherit)"
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath=".\MfcControlCtl.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\MfcControlPpg.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\StdAfx.cpp"
+ >
+ <FileConfiguration
+ Name="Unicode Release|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ UsePrecompiledHeader="1"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Unicode Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ UsePrecompiledHeader="1"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ UsePrecompiledHeader="1"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ UsePrecompiledHeader="1"
+ />
+ </FileConfiguration>
+ </File>
+ </Filter>
+ <Filter
+ Name="Header Files"
+ Filter="h;hpp;hxx;hm;inl"
+ >
+ <File
+ RelativePath=".\MfcControl.h"
+ >
+ </File>
+ <File
+ RelativePath=".\MfcControlCtl.h"
+ >
+ </File>
+ <File
+ RelativePath=".\MfcControlPpg.h"
+ >
+ </File>
+ <File
+ RelativePath=".\Resource.h"
+ >
+ </File>
+ <File
+ RelativePath=".\StdAfx.h"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="Resource Files"
+ Filter="ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
+ >
+ <File
+ RelativePath=".\MfcControlCtl.bmp"
+ >
+ </File>
+ </Filter>
+ <File
+ RelativePath=".\ReadMe.txt"
+ >
+ </File>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
diff --git a/extensions/test/ole/MfcControl/MfcControlCtl.cpp b/extensions/test/ole/MfcControl/MfcControlCtl.cpp
new file mode 100644
index 000000000000..399fb5db95c2
--- /dev/null
+++ b/extensions/test/ole/MfcControl/MfcControlCtl.cpp
@@ -0,0 +1,347 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+// MfcControlCtl.cpp : Implementation of the CMfcControlCtrl ActiveX Control class.
+
+#include "stdafx.h"
+#include "MfcControl.h"
+#include "MfcControlCtl.h"
+#include "MfcControlPpg.h"
+
+
+#ifdef _DEBUG
+#define new DEBUG_NEW
+#undef THIS_FILE
+static char THIS_FILE[] = __FILE__;
+#endif
+
+
+IMPLEMENT_DYNCREATE(CMfcControlCtrl, COleControl)
+
+
+/////////////////////////////////////////////////////////////////////////////
+// Message map
+
+BEGIN_MESSAGE_MAP(CMfcControlCtrl, COleControl)
+ //{{AFX_MSG_MAP(CMfcControlCtrl)
+ // NOTE - ClassWizard will add and remove message map entries
+ // DO NOT EDIT what you see in these blocks of generated code !
+ //}}AFX_MSG_MAP
+ ON_OLEVERB(AFX_IDS_VERB_PROPERTIES, OnProperties)
+END_MESSAGE_MAP()
+
+
+/////////////////////////////////////////////////////////////////////////////
+// Dispatch map
+
+BEGIN_DISPATCH_MAP(CMfcControlCtrl, COleControl)
+ //{{AFX_DISPATCH_MAP(CMfcControlCtrl)
+ DISP_FUNCTION(CMfcControlCtrl, "inShort", inShort, VT_I2, VTS_I2)
+ DISP_FUNCTION(CMfcControlCtrl, "inLong", inLong, VT_I4, VTS_I4)
+ DISP_FUNCTION(CMfcControlCtrl, "inString", inString, VT_BSTR, VTS_PBSTR)
+ DISP_FUNCTION(CMfcControlCtrl, "inFloat", inFloat, VT_R4, VTS_R4)
+ DISP_FUNCTION(CMfcControlCtrl, "inDouble", inDouble, VT_R8, VTS_R8)
+ DISP_FUNCTION(CMfcControlCtrl, "inVariant", inVariant, VT_VARIANT, VTS_VARIANT)
+ DISP_FUNCTION(CMfcControlCtrl, "inObject", inObject, VT_DISPATCH, VTS_DISPATCH)
+ DISP_FUNCTION(CMfcControlCtrl, "outShort", outShort, VT_EMPTY, VTS_PI2)
+ DISP_FUNCTION(CMfcControlCtrl, "outLong", outLong, VT_EMPTY, VTS_PI4)
+ DISP_FUNCTION(CMfcControlCtrl, "outString", outString, VT_EMPTY, VTS_PBSTR)
+ DISP_FUNCTION(CMfcControlCtrl, "outFloat", outFloat, VT_EMPTY, VTS_PR4)
+ DISP_FUNCTION(CMfcControlCtrl, "outDouble", outDouble, VT_EMPTY, VTS_PR8)
+ DISP_FUNCTION(CMfcControlCtrl, "outVariant", outVariant, VT_EMPTY, VTS_PVARIANT)
+ DISP_FUNCTION(CMfcControlCtrl, "outObject", outObject, VT_EMPTY, VTS_PDISPATCH)
+ //}}AFX_DISPATCH_MAP
+END_DISPATCH_MAP()
+
+
+/////////////////////////////////////////////////////////////////////////////
+// Event map
+
+BEGIN_EVENT_MAP(CMfcControlCtrl, COleControl)
+ //{{AFX_EVENT_MAP(CMfcControlCtrl)
+ // NOTE - ClassWizard will add and remove event map entries
+ // DO NOT EDIT what you see in these blocks of generated code !
+ //}}AFX_EVENT_MAP
+END_EVENT_MAP()
+
+
+/////////////////////////////////////////////////////////////////////////////
+// Property pages
+
+// TODO: Add more property pages as needed. Remember to increase the count!
+BEGIN_PROPPAGEIDS(CMfcControlCtrl, 1)
+ PROPPAGEID(CMfcControlPropPage::guid)
+END_PROPPAGEIDS(CMfcControlCtrl)
+
+
+/////////////////////////////////////////////////////////////////////////////
+// Initialize class factory and guid
+
+IMPLEMENT_OLECREATE_EX(CMfcControlCtrl, "MFCCONTROL.MfcControlCtrl.1",
+ 0xac221fb6, 0xa0d8, 0x11d4, 0x83, 0x3b, 0, 0x50, 0x4, 0x52, 0x6a, 0xb4)
+
+
+/////////////////////////////////////////////////////////////////////////////
+// Type library ID and version
+
+IMPLEMENT_OLETYPELIB(CMfcControlCtrl, _tlid, _wVerMajor, _wVerMinor)
+
+
+/////////////////////////////////////////////////////////////////////////////
+// Interface IDs
+
+const IID BASED_CODE IID_DMfcControl =
+ { 0xac221fb4, 0xa0d8, 0x11d4, { 0x83, 0x3b, 0, 0x50, 0x4, 0x52, 0x6a, 0xb4 } };
+const IID BASED_CODE IID_DMfcControlEvents =
+ { 0xac221fb5, 0xa0d8, 0x11d4, { 0x83, 0x3b, 0, 0x50, 0x4, 0x52, 0x6a, 0xb4 } };
+
+
+/////////////////////////////////////////////////////////////////////////////
+// Control type information
+
+static const DWORD BASED_CODE _dwMfcControlOleMisc =
+ OLEMISC_ACTIVATEWHENVISIBLE |
+ OLEMISC_SETCLIENTSITEFIRST |
+ OLEMISC_INSIDEOUT |
+ OLEMISC_CANTLINKINSIDE |
+ OLEMISC_RECOMPOSEONRESIZE;
+
+IMPLEMENT_OLECTLTYPE(CMfcControlCtrl, IDS_MFCCONTROL, _dwMfcControlOleMisc)
+
+
+/////////////////////////////////////////////////////////////////////////////
+// CMfcControlCtrl::CMfcControlCtrlFactory::UpdateRegistry -
+// Adds or removes system registry entries for CMfcControlCtrl
+
+BOOL CMfcControlCtrl::CMfcControlCtrlFactory::UpdateRegistry(BOOL bRegister)
+{
+ // TODO: Verify that your control follows apartment-model threading rules.
+ // Refer to MFC TechNote 64 for more information.
+ // If your control does not conform to the apartment-model rules, then
+ // you must modify the code below, changing the 6th parameter from
+ // afxRegApartmentThreading to 0.
+
+ if (bRegister)
+ return AfxOleRegisterControlClass(
+ AfxGetInstanceHandle(),
+ m_clsid,
+ m_lpszProgID,
+ IDS_MFCCONTROL,
+ IDB_MFCCONTROL,
+ afxRegApartmentThreading,
+ _dwMfcControlOleMisc,
+ _tlid,
+ _wVerMajor,
+ _wVerMinor);
+ else
+ return AfxOleUnregisterClass(m_clsid, m_lpszProgID);
+}
+
+
+/////////////////////////////////////////////////////////////////////////////
+// CMfcControlCtrl::CMfcControlCtrl - Constructor
+
+CMfcControlCtrl::CMfcControlCtrl()
+{
+ InitializeIIDs(&IID_DMfcControl, &IID_DMfcControlEvents);
+
+ // TODO: Initialize your control's instance data here.
+}
+
+
+/////////////////////////////////////////////////////////////////////////////
+// CMfcControlCtrl::~CMfcControlCtrl - Destructor
+
+CMfcControlCtrl::~CMfcControlCtrl()
+{
+ // TODO: Cleanup your control's instance data here.
+}
+
+
+/////////////////////////////////////////////////////////////////////////////
+// CMfcControlCtrl::OnDraw - Drawing function
+
+void CMfcControlCtrl::OnDraw(
+ CDC* pdc, const CRect& rcBounds, const CRect& rcInvalid)
+{
+ // TODO: Replace the following code with your own drawing code.
+ pdc->FillRect(rcBounds, CBrush::FromHandle((HBRUSH)GetStockObject(WHITE_BRUSH)));
+ pdc->Ellipse(rcBounds);
+}
+
+
+/////////////////////////////////////////////////////////////////////////////
+// CMfcControlCtrl::DoPropExchange - Persistence support
+
+void CMfcControlCtrl::DoPropExchange(CPropExchange* pPX)
+{
+ ExchangeVersion(pPX, MAKELONG(_wVerMinor, _wVerMajor));
+ COleControl::DoPropExchange(pPX);
+
+ // TODO: Call PX_ functions for each persistent custom property.
+
+}
+
+
+/////////////////////////////////////////////////////////////////////////////
+// CMfcControlCtrl::OnResetState - Reset control to default state
+
+void CMfcControlCtrl::OnResetState()
+{
+ COleControl::OnResetState(); // Resets defaults found in DoPropExchange
+
+ // TODO: Reset any other control state here.
+}
+
+
+/////////////////////////////////////////////////////////////////////////////
+// CMfcControlCtrl message handlers
+
+
+short CMfcControlCtrl::inShort(short val)
+{
+ char buf[256];
+ sprintf( buf, "inByte: value= %d", val);
+ ::MessageBoxA( NULL, buf, "MFCCONTROL.MfcControl", MB_OK);
+ return val+1;
+}
+
+long CMfcControlCtrl::inLong(long val)
+{
+ char buf[256];
+ sprintf( buf, "inLong: value= %d", val);
+ ::MessageBoxA( NULL, buf, "MFCCONTROL.MfcControl", MB_OK);
+ return val+1;
+}
+
+BSTR CMfcControlCtrl::inString(BSTR* val)
+{
+ CString strResult;
+ strResult= *val;
+ char buf[256];
+ sprintf( buf, "inString: value= %S", *val);
+ ::MessageBoxA( NULL, buf, "MFCCONTROL.MfcControl", MB_OK);
+ strResult += L" an appended string";
+ return strResult.AllocSysString();
+}
+
+float CMfcControlCtrl::inFloat(float val)
+{
+ char buf[256];
+ sprintf( buf, "inFloat: value= %f", val);
+ ::MessageBoxA( NULL, buf, "MFCCONTROL.MfcControl", MB_OK);
+ return val+1;
+}
+
+double CMfcControlCtrl::inDouble(double val)
+{
+ char buf[256];
+ sprintf( buf, "inDouble: value= %g", val);
+ ::MessageBoxA( NULL, buf, "MFCCONTROL.MfcControl", MB_OK);
+ return val+1;
+}
+
+VARIANT CMfcControlCtrl::inVariant(const VARIANT FAR& val)
+{
+ VARIANT vaResult;
+ VariantInit(&vaResult);
+ VariantCopyInd( &vaResult, const_cast<VARIANT*>(&val));
+ if( vaResult.vt == VT_BSTR)
+ {
+ char buf[256];
+ sprintf( buf, "inVariant: value= %S", vaResult.bstrVal);
+ ::MessageBoxA( NULL, buf, "MFCCONTROL.MfcControl", MB_OK);
+
+ }
+ return _variant_t( L" a string from CMfcControlCtrl::inVariant");
+}
+
+LPDISPATCH CMfcControlCtrl::inObject(LPDISPATCH val)
+{
+ char buf[256];
+ _bstr_t bstr;
+ HRESULT hr= S_OK;
+ COleVariant var;
+ DISPID id;
+ OLECHAR* name=L"prpString";
+ if( SUCCEEDED(hr= val->GetIDsOfNames( IID_NULL, &name, 1, LOCALE_USER_DEFAULT, &id)))
+ {
+ DISPPARAMS params={0,0,0,0};
+ hr= val->Invoke( id, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_PROPERTYGET, &params, &var,0,0);
+
+ }
+
+ if( var.vt== VT_BSTR)
+ bstr= var.bstrVal;
+ sprintf( buf, "inObject: value= %S", (wchar_t*)bstr);
+ ::MessageBoxA( NULL, buf, "MFCCONTROL.MfcControl", MB_OK);
+
+ return NULL;
+}
+
+
+void CMfcControlCtrl::outShort(short* val)
+{
+ *val= 123;
+}
+
+void CMfcControlCtrl::outLong(long* val)
+{
+ *val= 1234;
+}
+
+void CMfcControlCtrl::outString(BSTR FAR* val)
+{
+ *val= SysAllocString(L"A string from CMfcControlCtrl::outString ");
+}
+
+void CMfcControlCtrl::outFloat(float* val)
+{
+ *val= 3.14f;
+}
+
+void CMfcControlCtrl::outDouble(double* val)
+{
+ *val= 3.145;
+}
+
+void CMfcControlCtrl::outVariant(VARIANT FAR* val)
+{
+ VariantInit( val);
+ val->vt= VT_BSTR;
+ val->bstrVal= SysAllocString( L"a string in a VARIANT");
+}
+
+void CMfcControlCtrl::outObject(LPDISPATCH FAR* val)
+{
+ //{BFE10EBE-8584-11D4-005004526AB4}
+ HRESULT hr= S_OK;
+ CLSID clsTestControl;
+ hr= CLSIDFromProgID( L"AxTestComponents.Basic", &clsTestControl);
+
+ IDispatch* pDisp= NULL;
+ hr= CoCreateInstance( clsTestControl, NULL, CLSCTX_ALL, __uuidof(IDispatch), (void**)&pDisp);
+
+ if( SUCCEEDED( hr) && val)
+ {
+ COleVariant var;
+ DISPID id;
+ OLECHAR* name=L"prpString";
+ if( SUCCEEDED(hr= pDisp->GetIDsOfNames( IID_NULL, &name, 1, LOCALE_USER_DEFAULT, &id)))
+ {
+ COleVariant vaParam1(_T("this is property prpString of AxTestComponents.Basic"));
+ DISPID dispidPut= DISPID_PROPERTYPUT;
+ DISPPARAMS params;
+ params.cArgs= 1;
+ params.cNamedArgs= 1;
+ params.rgdispidNamedArgs= &dispidPut;
+ params.rgvarg= &vaParam1;
+
+ hr= pDisp->Invoke( id, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_PROPERTYPUT, &params, &var,0,0);
+ *val= pDisp;
+ }
+
+ }
+
+}
+// VT_I1
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/test/ole/MfcControl/MfcControlCtl.h b/extensions/test/ole/MfcControl/MfcControlCtl.h
new file mode 100644
index 000000000000..f6d4379658b9
--- /dev/null
+++ b/extensions/test/ole/MfcControl/MfcControlCtl.h
@@ -0,0 +1,99 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+#if !defined(AFX_MFCCONTROLCTL_H__AC221FC3_A0D8_11D4_833B_005004526AB4__INCLUDED_)
+#define AFX_MFCCONTROLCTL_H__AC221FC3_A0D8_11D4_833B_005004526AB4__INCLUDED_
+
+#if _MSC_VER > 1000
+#pragma once
+#endif // _MSC_VER > 1000
+
+// MfcControlCtl.h : Declaration of the CMfcControlCtrl ActiveX Control class.
+
+/////////////////////////////////////////////////////////////////////////////
+// CMfcControlCtrl : See MfcControlCtl.cpp for implementation.
+
+class CMfcControlCtrl : public COleControl
+{
+ DECLARE_DYNCREATE(CMfcControlCtrl)
+
+// Constructor
+public:
+ CMfcControlCtrl();
+
+// Overrides
+ // ClassWizard generated virtual function overrides
+ //{{AFX_VIRTUAL(CMfcControlCtrl)
+ public:
+ virtual void OnDraw(CDC* pdc, const CRect& rcBounds, const CRect& rcInvalid);
+ virtual void DoPropExchange(CPropExchange* pPX);
+ virtual void OnResetState();
+ //}}AFX_VIRTUAL
+
+// Implementation
+protected:
+ ~CMfcControlCtrl();
+
+ DECLARE_OLECREATE_EX(CMfcControlCtrl) // Class factory and guid
+ DECLARE_OLETYPELIB(CMfcControlCtrl) // GetTypeInfo
+ DECLARE_PROPPAGEIDS(CMfcControlCtrl) // Property page IDs
+ DECLARE_OLECTLTYPE(CMfcControlCtrl) // Type name and misc status
+
+// Message maps
+ //{{AFX_MSG(CMfcControlCtrl)
+ // NOTE - ClassWizard will add and remove member functions here.
+ // DO NOT EDIT what you see in these blocks of generated code !
+ //}}AFX_MSG
+ DECLARE_MESSAGE_MAP()
+
+// Dispatch maps
+ //{{AFX_DISPATCH(CMfcControlCtrl)
+ afx_msg short inShort(short val);
+ afx_msg long inLong(long val);
+ afx_msg BSTR inString(BSTR* val);
+ afx_msg float inFloat(float val);
+ afx_msg double inDouble(double val);
+ afx_msg VARIANT inVariant(const VARIANT FAR& val);
+ afx_msg LPDISPATCH inObject(LPDISPATCH val);
+ afx_msg void outShort(short* val);
+ afx_msg void outLong(long* val);
+ afx_msg void outString(BSTR FAR* val);
+ afx_msg void outFloat(float* val);
+ afx_msg void outDouble(double* val);
+ afx_msg void outVariant(VARIANT FAR* val);
+ afx_msg void outObject(LPDISPATCH FAR* val);
+ //}}AFX_DISPATCH
+ DECLARE_DISPATCH_MAP()
+
+// Event maps
+ //{{AFX_EVENT(CMfcControlCtrl)
+ //}}AFX_EVENT
+ DECLARE_EVENT_MAP()
+
+// Dispatch and event IDs
+public:
+ enum {
+ //{{AFX_DISP_ID(CMfcControlCtrl)
+ dispidInShort = 1L,
+ dispidInLong = 2L,
+ dispidInString = 3L,
+ dispidInFloat = 4L,
+ dispidInDouble = 5L,
+ dispidInVariant = 6L,
+ dispidInObject = 7L,
+ dispidOutShort = 8L,
+ dispidOutLong = 9L,
+ dispidOutString = 10L,
+ dispidOutFloat = 11L,
+ dispidOutDouble = 12L,
+ dispidOutVariant = 13L,
+ dispidOutObject = 14L,
+ //}}AFX_DISP_ID
+ };
+};
+
+//{{AFX_INSERT_LOCATION}}
+// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
+
+#endif // !defined(AFX_MFCCONTROLCTL_H__AC221FC3_A0D8_11D4_833B_005004526AB4__INCLUDED)
+// BYTE
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/test/ole/MfcControl/MfcControlCtl.png b/extensions/test/ole/MfcControl/MfcControlCtl.png
new file mode 100644
index 000000000000..77c4758c1a10
--- /dev/null
+++ b/extensions/test/ole/MfcControl/MfcControlCtl.png
Binary files differ
diff --git a/extensions/test/ole/MfcControl/MfcControlPpg.cpp b/extensions/test/ole/MfcControl/MfcControlPpg.cpp
new file mode 100644
index 000000000000..66a098ba0384
--- /dev/null
+++ b/extensions/test/ole/MfcControl/MfcControlPpg.cpp
@@ -0,0 +1,79 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+// MfcControlPpg.cpp : Implementation of the CMfcControlPropPage property page class.
+
+#include "stdafx.h"
+#include "MfcControl.h"
+#include "MfcControlPpg.h"
+
+#ifdef _DEBUG
+#define new DEBUG_NEW
+#undef THIS_FILE
+static char THIS_FILE[] = __FILE__;
+#endif
+
+
+IMPLEMENT_DYNCREATE(CMfcControlPropPage, COlePropertyPage)
+
+
+/////////////////////////////////////////////////////////////////////////////
+// Message map
+
+BEGIN_MESSAGE_MAP(CMfcControlPropPage, COlePropertyPage)
+ //{{AFX_MSG_MAP(CMfcControlPropPage)
+ // NOTE - ClassWizard will add and remove message map entries
+ // DO NOT EDIT what you see in these blocks of generated code !
+ //}}AFX_MSG_MAP
+END_MESSAGE_MAP()
+
+
+/////////////////////////////////////////////////////////////////////////////
+// Initialize class factory and guid
+
+IMPLEMENT_OLECREATE_EX(CMfcControlPropPage, "MFCCONTROL.MfcControlPropPage.1",
+ 0xac221fb7, 0xa0d8, 0x11d4, 0x83, 0x3b, 0, 0x50, 0x4, 0x52, 0x6a, 0xb4)
+
+
+/////////////////////////////////////////////////////////////////////////////
+// CMfcControlPropPage::CMfcControlPropPageFactory::UpdateRegistry -
+// Adds or removes system registry entries for CMfcControlPropPage
+
+BOOL CMfcControlPropPage::CMfcControlPropPageFactory::UpdateRegistry(BOOL bRegister)
+{
+ if (bRegister)
+ return AfxOleRegisterPropertyPageClass(AfxGetInstanceHandle(),
+ m_clsid, IDS_MFCCONTROL_PPG);
+ else
+ return AfxOleUnregisterClass(m_clsid, NULL);
+}
+
+
+/////////////////////////////////////////////////////////////////////////////
+// CMfcControlPropPage::CMfcControlPropPage - Constructor
+
+CMfcControlPropPage::CMfcControlPropPage() :
+ COlePropertyPage(IDD, IDS_MFCCONTROL_PPG_CAPTION)
+{
+ //{{AFX_DATA_INIT(CMfcControlPropPage)
+ // NOTE: ClassWizard will add member initialization here
+ // DO NOT EDIT what you see in these blocks of generated code !
+ //}}AFX_DATA_INIT
+}
+
+
+/////////////////////////////////////////////////////////////////////////////
+// CMfcControlPropPage::DoDataExchange - Moves data between page and properties
+
+void CMfcControlPropPage::DoDataExchange(CDataExchange* pDX)
+{
+ //{{AFX_DATA_MAP(CMfcControlPropPage)
+ // NOTE: ClassWizard will add DDP, DDX, and DDV calls here
+ // DO NOT EDIT what you see in these blocks of generated code !
+ //}}AFX_DATA_MAP
+ DDP_PostProcessing(pDX);
+}
+
+
+/////////////////////////////////////////////////////////////////////////////
+// CMfcControlPropPage message handlers
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/test/ole/MfcControl/MfcControlPpg.h b/extensions/test/ole/MfcControl/MfcControlPpg.h
new file mode 100644
index 000000000000..33f564c52ad4
--- /dev/null
+++ b/extensions/test/ole/MfcControl/MfcControlPpg.h
@@ -0,0 +1,49 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+#if !defined(AFX_MFCCONTROLPPG_H__AC221FC5_A0D8_11D4_833B_005004526AB4__INCLUDED_)
+#define AFX_MFCCONTROLPPG_H__AC221FC5_A0D8_11D4_833B_005004526AB4__INCLUDED_
+
+#if _MSC_VER > 1000
+#pragma once
+#endif // _MSC_VER > 1000
+
+// MfcControlPpg.h : Declaration of the CMfcControlPropPage property page class.
+
+////////////////////////////////////////////////////////////////////////////
+// CMfcControlPropPage : See MfcControlPpg.cpp.cpp for implementation.
+
+class CMfcControlPropPage : public COlePropertyPage
+{
+ DECLARE_DYNCREATE(CMfcControlPropPage)
+ DECLARE_OLECREATE_EX(CMfcControlPropPage)
+
+// Constructor
+public:
+ CMfcControlPropPage();
+
+// Dialog Data
+ //{{AFX_DATA(CMfcControlPropPage)
+ enum { IDD = IDD_PROPPAGE_MFCCONTROL };
+ // NOTE - ClassWizard will add data members here.
+ // DO NOT EDIT what you see in these blocks of generated code !
+ //}}AFX_DATA
+
+// Implementation
+protected:
+ virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
+
+// Message maps
+protected:
+ //{{AFX_MSG(CMfcControlPropPage)
+ // NOTE - ClassWizard will add and remove member functions here.
+ // DO NOT EDIT what you see in these blocks of generated code !
+ //}}AFX_MSG
+ DECLARE_MESSAGE_MAP()
+
+};
+
+//{{AFX_INSERT_LOCATION}}
+// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
+
+#endif // !defined(AFX_MFCCONTROLPPG_H__AC221FC5_A0D8_11D4_833B_005004526AB4__INCLUDED)
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/test/ole/MfcControl/Resource.h b/extensions/test/ole/MfcControl/Resource.h
new file mode 100644
index 000000000000..9cd92613f1fd
--- /dev/null
+++ b/extensions/test/ole/MfcControl/Resource.h
@@ -0,0 +1,23 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+//{{NO_DEPENDENCIES}}
+// Microsoft Visual C++ generated include file.
+// Used by MfcControl.rc
+//
+
+#define IDS_MFCCONTROL 1
+#define IDS_MFCCONTROL_PPG 2
+
+#define IDS_MFCCONTROL_PPG_CAPTION 200
+
+#define IDD_PROPPAGE_MFCCONTROL 200
+
+
+#define IDB_MFCCONTROL 1
+
+
+#define _APS_NEXT_RESOURCE_VALUE 201
+#define _APS_NEXT_CONTROL_VALUE 201
+#define _APS_NEXT_SYMED_VALUE 101
+#define _APS_NEXT_COMMAND_VALUE 32768
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/test/ole/MfcControl/StdAfx.cpp b/extensions/test/ole/MfcControl/StdAfx.cpp
new file mode 100644
index 000000000000..b45da9a8edc8
--- /dev/null
+++ b/extensions/test/ole/MfcControl/StdAfx.cpp
@@ -0,0 +1,8 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+// stdafx.cpp : source file that includes just the standard includes
+// stdafx.pch will be the pre-compiled header
+// stdafx.obj will contain the pre-compiled type information
+
+#include "stdafx.h"
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/test/ole/MfcControl/StdAfx.h b/extensions/test/ole/MfcControl/StdAfx.h
new file mode 100644
index 000000000000..4df599c412e3
--- /dev/null
+++ b/extensions/test/ole/MfcControl/StdAfx.h
@@ -0,0 +1,33 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+#if !defined(AFX_STDAFX_H__AC221FBA_A0D8_11D4_833B_005004526AB4__INCLUDED_)
+#define AFX_STDAFX_H__AC221FBA_A0D8_11D4_833B_005004526AB4__INCLUDED_
+
+#if _MSC_VER > 1000
+#pragma once
+#endif // _MSC_VER > 1000
+
+// stdafx.h : include file for standard system include files,
+// or project specific include files that are used frequently,
+// but are changed infrequently
+
+#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers
+
+#include <afxctl.h> // MFC support for ActiveX Controls
+#include <afxext.h> // MFC extensions
+#include <afxdtctl.h> // MFC support for Internet Explorer 4 Comon Controls
+#ifndef _AFX_NO_AFXCMN_SUPPORT
+#include <afxcmn.h> // MFC support for Windows Common Controls
+#endif // _AFX_NO_AFXCMN_SUPPORT
+
+// Delete the two includes below if you do not wish to use the MFC
+// database classes
+#include <afxdb.h> // MFC database classes
+#include <afxdao.h> // MFC DAO database classes
+
+//{{AFX_INSERT_LOCATION}}
+// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
+
+#include <comdef.h>
+#endif // !defined(AFX_STDAFX_H__AC221FBA_A0D8_11D4_833B_005004526AB4__INCLUDED_)
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/test/ole/OleClient/OleClient.ini b/extensions/test/ole/OleClient/OleClient.ini
new file mode 100644
index 000000000000..fa1ac118f05e
--- /dev/null
+++ b/extensions/test/ole/OleClient/OleClient.ini
@@ -0,0 +1,5 @@
+[Bootstrap]
+UNO_TYPES=types.rdb
+UNO_SERVICES=services.rdb
+
+
diff --git a/extensions/test/ole/OleClient/axhost.cxx b/extensions/test/ole/OleClient/axhost.cxx
new file mode 100644
index 000000000000..93d5721b3b49
--- /dev/null
+++ b/extensions/test/ole/OleClient/axhost.cxx
@@ -0,0 +1,58 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+
+
+#include "axhost.hxx"
+
+HostWin::HostWin(LPWSTR progid)
+{
+ controlName= progid;
+ RECT rcPos={0,0,200,200};
+ Create(0, rcPos, _T("HostWin"));
+}
+HostWin::~HostWin()
+{
+ DestroyWindow();
+}
+
+
+LRESULT HostWin::OnCreate(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
+{
+ CAxWindow wnd(m_hWnd);
+
+ HRESULT hr= wnd.CreateControlEx( controlName, NULL, NULL,&spControl.p);
+
+ return 0;
+}
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/test/ole/OleClient/axhost.hxx b/extensions/test/ole/OleClient/axhost.hxx
new file mode 100644
index 000000000000..88b870f849c5
--- /dev/null
+++ b/extensions/test/ole/OleClient/axhost.hxx
@@ -0,0 +1,62 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef __AXHOST_HXX
+#define __AXHOST_HXX
+
+#include <atlbase.h>
+extern CComModule _Module;
+#include <atlcom.h>
+#include <atlhost.h>
+
+
+class HostWin: public CWindowImpl<HostWin, CWindow,
+ CWinTraits< WS_CAPTION|WS_POPUPWINDOW|WS_VISIBLE, 0> >
+{
+ CComBSTR controlName;
+ CComPtr<IUnknown> spControl;
+public:
+ HostWin(LPWSTR progid);
+
+ ~HostWin();
+
+
+ BEGIN_MSG_MAP(HostWin)
+ MESSAGE_HANDLER( WM_CREATE, OnCreate)
+ END_MSG_MAP()
+
+ IUnknown* GetHostedControl(){
+ return spControl;
+ }
+
+ LRESULT OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
+};
+#endif
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/test/ole/OleClient/clientTest.cxx b/extensions/test/ole/OleClient/clientTest.cxx
new file mode 100644
index 000000000000..4a79eead82df
--- /dev/null
+++ b/extensions/test/ole/OleClient/clientTest.cxx
@@ -0,0 +1,1326 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+
+#include <atlbase.h>
+
+CComModule _Module;
+#include<atlcom.h>
+#include <comdef.h>
+
+#include "axhost.hxx"
+
+#include <stdio.h>
+#include "typelib/typedescription.hxx"
+#include <com/sun/star/bridge/oleautomation/Date.hpp>
+#include <com/sun/star/bridge/oleautomation/Currency.hpp>
+#include <com/sun/star/bridge/oleautomation/Decimal.hpp>
+#include <com/sun/star/bridge/oleautomation/SCode.hpp>
+#include <com/sun/star/bridge/oleautomation/NamedArgument.hpp>
+#include <com/sun/star/bridge/oleautomation/PropertyPutArgument.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/script/XInvocation.hpp>
+#include <com/sun/star/uno/Reference.h>
+#include <cppuhelper/servicefactory.hxx>
+#include <rtl/string.h>
+
+#define OUSTR(x) ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(x) )
+BEGIN_OBJECT_MAP(ObjectMap)
+END_OBJECT_MAP()
+
+using namespace com::sun::star::lang;
+using namespace com::sun::star::uno;
+using namespace com::sun::star::script;
+using namespace com::sun::star::bridge::oleautomation;
+using namespace cppu;
+using namespace rtl;
+
+
+
+Reference<XInvocation> convertComObject( IUnknown* pUnk);
+Reference<XInvocation> getComObject( OUString progId);
+bool checkOutArgs(const Sequence<Any> & outArgs,
+ const Sequence<sal_Int16> & indices, const Sequence<Any> & values);
+
+bool doSimpleTest(const Reference<XInvocation> & inv);
+bool doSimpleSequenceTest(const Reference<XInvocation> & inv);
+bool doParameterTest(const Reference<XInvocation> & inv);
+bool doPropertyWithArgumentTest(const Reference<XInvocation> & inv);
+bool equalSequences(const Any& orig, const Any& returned);
+HRESULT doTest();
+HRESULT doTest2( Reference<XInvocation> &);
+Reference<XInvocation> getComObject(OUString& );
+
+HRESULT InitializeParameter();
+void printResultVariantArray( VARIANT & var);
+void printVariant( VARIANT & var);
+void printSequence( Sequence<Any>& val);
+
+extern "C" int __cdecl main( int , char **)
+{
+ HRESULT hr;
+ if( FAILED( hr=CoInitialize(NULL)))
+ {
+ _tprintf(_T("CoInitialize failed \n"));
+ return -1;
+ }
+
+
+ _Module.Init( ObjectMap, GetModuleHandle( NULL));
+
+ if( FAILED(hr=doTest()))
+ {
+ _com_error err( hr);
+ const TCHAR * errMsg= err.ErrorMessage();
+ MessageBox( NULL, errMsg, "Test failed", MB_ICONERROR);
+ }
+ else
+ {
+ MessageBox( NULL,NULL , "Test succeeded", MB_ICONINFORMATION);
+ }
+
+
+ _Module.Term();
+ CoUninitialize();
+ return 0;
+}
+//Also supports named args
+
+bool doParameterTest(const Reference<XInvocation> & inv)
+{
+ Sequence< sal_Int16> seqIndices;
+ Sequence<Any> seqOut;
+
+ Any arArgs[2];
+ Any arValue[2];
+ Any arArgs1[4];
+
+ NamedArgument arg1(OUString(L"val1"), makeAny((sal_Int32) 123));
+ NamedArgument arg2(OUString(L"val2"), makeAny((sal_Int32) 456));
+ NamedArgument arg3(OUString(L"val3"), makeAny((sal_Int32) 0xff));
+ NamedArgument arg4(OUString(L"val4"), makeAny((sal_Int32) 0xffff));
+
+ NamedArgument argOut1(OUString(L"val1"), Any());
+ NamedArgument argOut2(OUString(L"val2"), Any());
+ Sequence<Any> seqNoArgs;
+ arArgs[0] <<= (sal_Int32) 0;
+ arArgs[1] <<= (sal_Int32) 0;
+ Sequence<Any> seqPositional0(arArgs, 2);
+
+
+ arArgs[0] <<= arg1;
+ arArgs[1] <<= arg2;
+ Sequence<Any> seqNamed(arArgs, 2);
+ arArgs[0] <<= arg2;
+ arArgs[1] <<= arg1;
+ Sequence<Any> seqNamed2(arArgs, 2);
+ arArgs[0] <<= argOut1;
+ arArgs[1] <<= argOut2;
+ Sequence<Any> seqNamed3(arArgs, 2);
+ arArgs[0] <<= argOut2;
+ arArgs[1] <<= argOut1;
+ Sequence<Any> seqNamed4(arArgs, 2);
+
+ arArgs[0] <<= arg1;
+ Sequence<Any> seqNamed5(arArgs, 1);
+ arArgs[0] <<= arg2;
+ Sequence<Any> seqNamed6(arArgs, 1);
+
+ arArgs[0] <<= (sal_Int32) 123;
+ arArgs[1] <<= (sal_Int32) 456;
+ Sequence<Any> seqPositional(arArgs, 2);
+ arArgs[0] <<= (sal_Int32) 123;
+ Sequence<Any> seqPositional2(arArgs, 1);
+
+ arArgs[0] <<= Any();
+ arArgs[1] <<= Any();
+ Sequence<Any> seqPositional3(arArgs, 2);
+
+ arArgs[0] <<= (sal_Int32) 123;
+ arArgs[1] <<= SCode(DISP_E_PARAMNOTFOUND);
+ Sequence<Any> seqOutOpt1(arArgs, 2);
+
+ arArgs[0] <<= SCode(DISP_E_PARAMNOTFOUND);
+ arArgs[1] <<= SCode(DISP_E_PARAMNOTFOUND);
+ Sequence<Any> seqOutOpt2(arArgs, 2);
+
+ arArgs[0] <<= SCode(DISP_E_PARAMNOTFOUND);
+ arArgs[1] <<= (sal_Int32) 456;
+ Sequence<Any> seqOutOpt3(arArgs, 2);
+
+ arArgs1[0] <<= (sal_Int32) 0;
+ arArgs1[1] <<= (sal_Int32) 0;
+ arArgs1[2] <<= (sal_Int32) 0;
+ arArgs1[3] <<= (sal_Int32) 0;
+ Sequence<Any> seqMix0(arArgs1, 4);
+
+ arArgs1[0] <<= (sal_Int32) 123;
+ arArgs1[1] <<= (sal_Int32) 456;
+ arArgs1[2] <<= arg3;
+ arArgs1[3] <<= arg4;
+ Sequence<Any> seqMix(arArgs1, 4);
+
+ arArgs1[0] <<= Any();
+ arArgs1[1] <<= (sal_Int32) 456;
+ arArgs1[2] <<= arg4;
+ Sequence<Any> seqMix2(arArgs1, 3);
+
+ arArgs1[0] <<= SCode(DISP_E_PARAMNOTFOUND);
+ arArgs1[1] <<= (sal_Int32) 456;
+ arArgs1[2] <<= SCode(DISP_E_PARAMNOTFOUND);
+ arArgs1[3] <<= arg4.Value;
+ Sequence<Any> seqMixOut(arArgs1, 4);
+
+ arArgs1[0] <<= SCode(DISP_E_PARAMNOTFOUND);
+ arArgs1[1] <<= Any();
+ arArgs1[2] <<= arg4;
+ Sequence<Any> seqMix2Out(arArgs1, 3);
+
+
+
+ //in args + out, optional, positional-----------------------------------------
+ //first general test
+ seqIndices.realloc(0);
+ seqOut.realloc(0);
+ inv->invoke(OUString(L"optional3"), seqPositional, seqIndices, seqOut);
+ seqIndices.realloc(0);
+ seqOut.realloc(0);
+ inv->invoke(OUString(L"optional5"), seqPositional, seqIndices, seqOut);
+ if ( ! checkOutArgs(seqOut, seqIndices, seqPositional))
+ return false;
+
+ //2 optional args, 1 provided
+ seqIndices.realloc(0);
+ seqOut.realloc(0);
+ inv->invoke(OUString(L"optional3"), seqPositional0, seqIndices, seqOut);
+ seqIndices.realloc(0);
+ seqOut.realloc(0);
+ inv->invoke(OUString(L"optional3"), seqPositional2, seqIndices, seqOut);
+ seqIndices.realloc(0);
+ seqOut.realloc(0);
+ inv->invoke(OUString(L"optional5"), seqPositional, seqIndices, seqOut);
+ if ( ! checkOutArgs(seqOut, seqIndices, seqOutOpt1))
+ return false;
+
+ //2 optional args, 0 provided
+ seqIndices.realloc(0);
+ seqOut.realloc(0);
+ inv->invoke(OUString(L"optional3"), seqPositional0, seqIndices, seqOut);
+ seqIndices.realloc(0);
+ seqOut.realloc(0);
+ inv->invoke(OUString(L"optional3"), seqNoArgs, seqIndices, seqOut);
+ seqIndices.realloc(0);
+ seqOut.realloc(0);
+ inv->invoke(OUString(L"optional5"), seqPositional3, seqIndices, seqOut);
+ if ( ! checkOutArgs(seqOut, seqIndices, seqOutOpt2))
+ return false;
+
+ //named args --------------------------------------------
+
+ // 2 named args, correct position
+ seqIndices.realloc(0);
+ seqOut.realloc(0);
+ inv->invoke(OUString(L"optional3"), seqPositional0, seqIndices, seqOut);
+ seqIndices.realloc(0);
+ seqOut.realloc(0);
+ inv->invoke(OUString(L"optional3"), seqNamed, seqIndices, seqOut);
+ seqIndices.realloc(0);
+ seqOut.realloc(0);
+ inv->invoke(OUString(L"optional5"), seqPositional0, seqIndices, seqOut);
+ if ( ! checkOutArgs(seqOut, seqIndices, seqPositional))
+ return false;
+
+ // 2named args, position differs
+ seqIndices.realloc(0);
+ seqOut.realloc(0);
+ inv->invoke(OUString(L"optional3"), seqPositional0, seqIndices, seqOut);
+ seqIndices.realloc(0);
+ seqOut.realloc(0);
+ inv->invoke(OUString(L"optional3"), seqNamed2, seqIndices, seqOut);
+ seqIndices.realloc(0);
+ seqOut.realloc(0);
+ inv->invoke(OUString(L"optional5"), seqPositional, seqIndices, seqOut);
+ if ( ! checkOutArgs(seqOut, seqIndices, seqPositional))
+ return false;
+
+ //named out args, 2 named args with correct position
+ seqIndices.realloc(0);
+ seqOut.realloc(0);
+ inv->invoke(OUString(L"optional3"), seqNamed, seqIndices, seqOut);
+ seqIndices.realloc(0);
+ seqIndices.realloc(0);
+ inv->invoke(OUString(L"optional5"), seqNamed3, seqIndices, seqOut);
+ if ( ! checkOutArgs(seqOut, seqIndices, seqNamed ))
+ return false;
+
+ //named out args, 2 named args with different position
+ seqIndices.realloc(0);
+ seqOut.realloc(0);
+ inv->invoke(OUString(L"optional3"), seqNamed, seqIndices, seqOut);
+ seqIndices.realloc(0);
+ seqIndices.realloc(0);
+ inv->invoke(OUString(L"optional5"), seqNamed4, seqIndices, seqOut);
+ if ( ! checkOutArgs(seqOut, seqIndices, seqNamed2 ))
+ return false;
+
+
+ //2 args, 1 provided (correct order)
+ seqIndices.realloc(0);
+ seqOut.realloc(0);
+ inv->invoke(OUString(L"optional3"), seqPositional0, seqIndices, seqOut);
+ seqIndices.realloc(0);
+ seqOut.realloc(0);
+ inv->invoke(OUString(L"optional3"), seqNamed5, seqIndices, seqOut);
+ seqIndices.realloc(0);
+ seqOut.realloc(0);
+ inv->invoke(OUString(L"optional5"), seqPositional, seqIndices, seqOut);
+ if ( ! checkOutArgs(seqOut, seqIndices, seqOutOpt1))
+ return false;
+ //2 args, 1 provided (incorrect order)
+ seqIndices.realloc(0);
+ seqOut.realloc(0);
+ inv->invoke(OUString(L"optional3"), seqPositional0, seqIndices, seqOut);
+ seqIndices.realloc(0);
+ seqOut.realloc(0);
+ inv->invoke(OUString(L"optional3"), seqNamed6, seqIndices, seqOut);
+ seqIndices.realloc(0);
+ seqOut.realloc(0);
+ inv->invoke(OUString(L"optional5"), seqPositional, seqIndices, seqOut);
+ if ( ! checkOutArgs(seqOut, seqIndices, seqOutOpt3))
+ return false;
+
+ //2position + 2 2named args, correct order
+ seqIndices.realloc(0);
+ seqOut.realloc(0);
+ inv->invoke(OUString(L"optional6"), seqMix0, seqIndices, seqOut);
+ seqIndices.realloc(0);
+ seqOut.realloc(0);
+ inv->invoke(OUString(L"optional6"), seqMix, seqIndices, seqOut);
+ seqIndices.realloc(0);
+ seqOut.realloc(0);
+ inv->invoke(OUString(L"optional7"), seqMix, seqIndices, seqOut);
+ if ( ! checkOutArgs(seqOut, seqIndices, seqMix))
+ return false;
+
+ // 4 in args, 1 positional, 1 named, 1 positional omitted
+ seqIndices.realloc(0);
+ seqOut.realloc(0);
+ inv->invoke(OUString(L"optional6"), seqMix0, seqIndices, seqOut);
+ seqIndices.realloc(0);
+ seqOut.realloc(0);
+ inv->invoke(OUString(L"optional6"), seqMix2, seqIndices, seqOut);
+ seqIndices.realloc(0);
+ seqOut.realloc(0);
+ inv->invoke(OUString(L"optional7"), seqMix0, seqIndices, seqOut);
+ if ( ! checkOutArgs(seqOut, seqIndices, seqMixOut))
+ return false;
+
+ // 4 out args, 1 positional, 1 named, 1 positional omitted
+ seqIndices.realloc(0);
+ seqOut.realloc(0);
+ inv->invoke(OUString(L"optional6"), seqMix2, seqIndices, seqOut);
+ seqIndices.realloc(0);
+ seqOut.realloc(0);
+ inv->invoke(OUString(L"optional7"), seqMix2Out, seqIndices, seqOut);
+ if ( ! checkOutArgs(seqOut, seqIndices, seqMix2Out))
+ return false;
+
+
+ return true;
+}
+bool doPropertyTest(const Reference<XInvocation> & inv)
+{
+ Sequence< sal_Int16> seqIndices;
+ Sequence<Any> seqOut;
+
+ Any inBool, outBool;
+ Any inByte, outByte;
+ Any inShort, outShort;
+ Any inLong, outLong;
+ Any inString, outString;
+ Any inFloat, outFloat;
+ Any inDouble, outDouble;
+ Any inVariant, outVariant;
+ Any inObject, outObject;
+ Any inUnknown, outUnknown;
+ Any inCY, outCY;
+ Any inDate, outDate;
+ Any inDecimal, outDecimal;
+ Any inSCode, outSCode;
+ Any inrefLong, outrefLong;
+ Any inrefVariant, outrefVariant;
+ Any inrefDecimal, outrefDecimal;
+ Any inParamsLong, outParamsLong;
+ Reference<XInterface> xintUnknown(getComObject(L"AxTestComponents.Foo"));
+
+ inBool <<= (sal_Bool) sal_True;
+ inv->setValue(OUString(L"prpBool"), inBool);
+ outBool = inv->getValue(OUString(L"prpBool"));
+
+ inByte <<= (sal_Int8) 100;
+ inv->setValue(OUString(L"prpByte"), inByte);
+ outByte = inv->getValue(OUString(L"prpByte"));
+
+ inShort <<= static_cast<sal_Int16>( -1);
+ inv->setValue(OUString(L"prpShort"), inShort);
+ outShort = inv->getValue(OUString(L"prpShort"));
+
+ inLong <<= ( sal_Int32) 1234567;
+ inv->setValue(OUString(L"prpLong"), inLong // TODO: Add your implementation code here
+);
+ outLong = inv->getValue(OUString(L"prpLong"));
+
+ inString <<= OUString(L" this is clientTest.exe");
+ inv->setValue(OUString(L"prpString"), inString);
+ outString = inv->getValue(OUString(L"prpString"));
+
+ inFloat <<= 3.14f;
+ inv->setValue(OUString(L"prpFloat"), inFloat);
+ outFloat = inv->getValue(OUString(L"prpFloat"));
+
+ inDouble <<= ( double) 3.145;
+ inv->setValue(OUString(L"prpDouble"), inDouble);
+ outDouble = inv->getValue(OUString(L"prpDouble"));
+
+ inVariant <<= OUString(L"A string in an any");
+ inv->setValue(OUString(L"prpVariant"), inVariant);
+ outVariant = inv->getValue(OUString(L"prpVariant"));
+
+ inObject <<= inv;
+ inv->setValue(OUString(L"prpObject"), inObject);
+ outObject = inv->getValue(OUString(L"prpObject"));
+
+ inUnknown <<= xintUnknown;
+ inv->setValue(OUString(L"prpUnknown"), inUnknown);
+ outUnknown = inv->getValue(OUString(L"prpUnknown"));
+
+ Currency cur(99999);
+ inCY <<= cur;
+ inv->setValue(OUString(L"prpCurrency"), inCY);
+ outCY = inv->getValue(OUString(L"prpCurrency"));
+
+ Date d(37889.0);
+ inDate <<= d;
+ inv->setValue(OUString(L"prpDate"), inDate);
+ outDate = inv->getValue(OUString(L"prpDate"));
+
+ Decimal dec(20, 0, 0xffffffff, 0xffffffff, 0x0fffffff);
+ inDecimal <<= dec;
+ inv->setValue(OUString(L"prpDecimal"), inDecimal);
+ outDecimal = inv->getValue(OUString(L"prpDecimal"));
+
+ SCode code(DISP_E_BADVARTYPE);
+ inSCode <<= code;
+ inv->setValue(OUString(L"prpSCode"), inSCode);
+ outSCode = inv->getValue(OUString(L"prpSCode"));
+
+ inrefLong <<= (sal_Int32) 123456;
+ inv->setValue(OUString(L"prprefLong"), inrefLong);
+ outrefLong = inv->getValue(OUString(L"prprefLong"));
+
+ inrefVariant <<= OUString(L"A string in an any");
+ inv->setValue(OUString(L"prprefVariant"), inrefVariant);
+ outrefVariant = inv->getValue(OUString(L"prprefVariant"));
+
+ Decimal decref(20, 0, 0xffffffff, 0xffffffff, 0x0fffffff);
+ inrefDecimal <<= decref;
+ inv->setValue(OUString(L"prprefDecimal"), inrefDecimal);
+ outrefDecimal = inv->getValue(OUString(L"prprefDecimal"));
+
+ if (inBool != outBool || inByte != outByte || inShort != outShort || inLong != outLong
+ || inFloat != outFloat || inDouble != outDouble || inString != outString
+ || inVariant != outVariant || inObject != outObject
+ || inUnknown != outUnknown || inCY != outCY
+ || inDate != outDate || inDecimal != outDecimal || inSCode != outSCode
+ || inrefLong != outrefLong ||inrefVariant != outrefVariant
+ || inrefDecimal != outrefDecimal)
+ return false;
+ return true;
+}
+
+bool doPropertyWithArgumentTest(const Reference<XInvocation> & inv)
+{
+ Sequence< sal_Int16> seqIndices;
+ Sequence<Any> seqOut;
+
+ Any arMultiArgs[3];
+ arMultiArgs[0] <<= makeAny((sal_Int32) 0);
+ arMultiArgs[1] <<= makeAny((sal_Int32) 0);
+ arMultiArgs[2] <<= PropertyPutArgument(makeAny((sal_Int32) 0));
+ Sequence<Any> seqMultiArgPut0(arMultiArgs, 3);
+
+ arMultiArgs[0] <<= makeAny((sal_Int32) 1);
+ arMultiArgs[1] <<= makeAny((sal_Int32) 2);
+ arMultiArgs[2] <<= PropertyPutArgument(makeAny((sal_Int32) 3));
+ Sequence<Any> seqMultiArgPut1(arMultiArgs, 3);
+
+ arMultiArgs[0] <<= makeAny((sal_Int32) 1);
+ arMultiArgs[1] <<= PropertyPutArgument(makeAny((sal_Int32) 3));
+ Sequence<Any> seqMultiArgPut2(arMultiArgs, 2);
+
+ arMultiArgs[0] <<= NamedArgument(OUString(L"val2"), makeAny((sal_Int32) 1));
+ arMultiArgs[1] <<= PropertyPutArgument(makeAny((sal_Int32) 3));
+ Sequence<Any> seqMultiArgPut3(arMultiArgs, 2);
+
+ arMultiArgs[0] <<= NamedArgument(OUString(L"val2"), makeAny((sal_Int32) 1));
+ arMultiArgs[1] <<= NamedArgument(OUString(L"val3"), makeAny((sal_Int32) 3));
+ Sequence<Any> seqMultiArgPut4(arMultiArgs, 2);
+
+ arMultiArgs[0] <<= makeAny((sal_Int32) 0);
+ arMultiArgs[1] <<= makeAny((sal_Int32) 0);
+ Sequence<Any> seqMultiArgGet0(arMultiArgs, 2);
+
+ arMultiArgs[0] <<= makeAny((sal_Int32) 1);
+ arMultiArgs[1] <<= makeAny((sal_Int32) 2);
+ Sequence<Any> seqMultiArgGet1(arMultiArgs, 2);
+ Sequence<Any> seqMultiArgGet2(arMultiArgs, 1);
+
+
+ arMultiArgs[0] <<= makeAny((sal_Int32) 0);
+ arMultiArgs[1] <<= PropertyPutArgument(makeAny((sal_Int32) 0));
+ Sequence<Any> seqMultiArgPut5(arMultiArgs, 2);
+
+ arMultiArgs[0] <<= makeAny((sal_Int32) 1);
+ arMultiArgs[1] <<= PropertyPutArgument(makeAny((sal_Int32) 2));
+ Sequence<Any> seqMultiArgPut6(arMultiArgs, 2);
+
+ arMultiArgs[0] <<= Any();
+ arMultiArgs[1] <<= Any();
+ Sequence<Any> seqMultiVoid(arMultiArgs, 2);
+
+ arMultiArgs[0] = makeAny((sal_Int32) 0);
+ arMultiArgs[1] = makeAny((sal_Int32) 0);
+ Sequence<Any> seqMultiVoid2(arMultiArgs, 2);
+
+ //[propput, ...] HRESULT prpMultiArg1([in,out,optional] VARIANT* val1, [in,out,optional] VARIANT* val2, [in] VARIANT* newVal);
+ //[propget, ...] HRESULT prpMultiArg1([in,out,optional] VARIANT* val1, [in,out,optional] VARIANT* val2, [out, optional, retval] VARIANT* pVal);
+ seqIndices.realloc( 0);
+ seqOut.realloc(0);
+ inv->invoke(OUString(L"prpMultiArg1"), seqMultiArgPut0, seqIndices, seqOut);
+ seqIndices.realloc( 0);
+ seqOut.realloc(0);
+ inv->invoke(OUString(L"prpMultiArg1"), seqMultiArgPut1, seqIndices, seqOut);
+ //check in/out args
+ seqIndices.realloc( 0);
+ seqOut.realloc(0);
+ Any anyRet = inv->invoke(OUString(L"prpMultiArg1"), seqMultiArgGet0,
+ seqIndices, seqOut);
+
+ if (anyRet != ((PropertyPutArgument const *)seqMultiArgPut1[2].getValue())->Value
+ || ! checkOutArgs(seqOut, seqIndices, Sequence<Any>(seqMultiArgPut1.getArray(), 2)))
+ {
+ return false;
+ }
+ // test optional (one arg omitted
+ seqIndices.realloc( 0);
+ seqOut.realloc(0);
+ inv->invoke(OUString(L"prpMultiArg1"), seqMultiArgPut0, seqIndices, seqOut);
+ seqIndices.realloc( 0);
+ seqOut.realloc(0);
+ inv->invoke(OUString(L"prpMultiArg1"), seqMultiArgPut2, seqIndices, seqOut);
+ seqIndices.realloc( 0);
+ seqOut.realloc(0);
+ anyRet = inv->invoke(OUString(L"prpMultiArg1"), seqMultiArgGet0,
+ seqIndices, seqOut);
+
+ arMultiArgs[0] = makeAny((sal_Int32) 1);
+ arMultiArgs[1] = makeAny((SCode(DISP_E_PARAMNOTFOUND)));
+
+ if (anyRet != ((PropertyPutArgument const *) seqMultiArgPut2[1].getValue())->Value
+ || ! checkOutArgs(seqOut, seqIndices, Sequence<Any>(arMultiArgs, 2)))
+ {
+ return false;
+ }
+
+ //test one named arg and one omitted
+ seqIndices.realloc( 0);
+ seqOut.realloc(0);
+ inv->invoke(OUString(L"prpMultiArg1"), seqMultiArgPut0, seqIndices, seqOut);
+ seqIndices.realloc( 0);
+ seqOut.realloc(0);
+ inv->invoke(OUString(L"prpMultiArg1"), seqMultiArgPut3, seqIndices, seqOut);
+ seqIndices.realloc( 0);
+ seqOut.realloc(0);
+ anyRet = inv->invoke(OUString(L"prpMultiArg1"), seqMultiArgGet0,
+ seqIndices, seqOut);
+
+ arMultiArgs[0] = makeAny((SCode(DISP_E_PARAMNOTFOUND)));
+ arMultiArgs[1] = ((NamedArgument const*) seqMultiArgPut3[0].getValue())->Value;
+ if (anyRet != ((PropertyPutArgument const*) seqMultiArgPut3[1].getValue())->Value
+ || ! checkOutArgs(seqOut, seqIndices, Sequence<Any>(arMultiArgs, 2)))
+ {
+ return false;
+ }
+
+// [propget,...] HRESULT prpMultiArg2([in] VARIANT val1, [out, retval] VARIANT* pVal);
+// [propput,...] HRESULT prpMultiArg2([in] VARIANT val1, [in] VARIANT newVal);
+ seqIndices.realloc( 0);
+ seqOut.realloc(0);
+ inv->invoke(OUString(L"prpMultiArg2"), seqMultiArgPut5, seqIndices, seqOut);
+ seqIndices.realloc( 0);
+ seqOut.realloc(0);
+ inv->invoke(OUString(L"prpMultiArg2GetValues"), seqMultiVoid, seqIndices, seqOut);
+
+ if ( ! checkOutArgs(seqOut, seqIndices, seqMultiVoid2))
+ return false;
+ seqIndices.realloc( 0);
+ seqOut.realloc(0);
+ anyRet = inv->invoke(OUString(L"prpMultiArg2"), seqMultiArgPut6,
+ seqIndices, seqOut);
+ seqIndices.realloc( 0);
+ seqOut.realloc(0);
+ anyRet = inv->invoke(OUString(L"prpMultiArg2GetValues"), seqMultiVoid,
+ seqIndices, seqOut);
+
+// [propget,...] HRESULT prpMultiArg3([in,out] LONG* val1, [out, retval] LONG* pVal);
+// [propput,...] HRESULT prpMultiArg3([in,out] LONG* val1, [in] LONG newVal);
+
+ if ( ! checkOutArgs(seqOut, seqIndices, seqMultiArgGet1 ))
+ return false;
+ seqIndices.realloc( 0);
+ seqOut.realloc(0);
+ inv->invoke(OUString(L"prpMultiArg3"), seqMultiArgPut5, seqIndices, seqOut);
+ seqIndices.realloc( 0);
+ seqOut.realloc(0);
+ inv->invoke(OUString(L"prpMultiArg3"), seqMultiArgPut6, seqIndices, seqOut);
+ seqIndices.realloc( 0);
+ seqOut.realloc(0);
+ anyRet = inv->invoke(OUString(L"prpMultiArg3"), seqMultiArgGet2, seqIndices, seqOut);
+
+ if ( anyRet != ((PropertyPutArgument const*) seqMultiArgPut6[1].getValue())->Value
+ || !checkOutArgs(seqOut, seqIndices, seqMultiArgGet2))
+ return false;
+
+
+ //hasProperty, hasMethod
+ if (inv->hasProperty(OUSTR("prpMultiArg1")))
+ return false;
+ if ( ! inv->hasMethod(OUSTR("prpMultiArg1")))
+ return false;
+ if ( ! inv->hasProperty(OUSTR("prprefLong")))
+ return false;
+ if (inv->hasMethod(OUSTR("prprefLong")))
+ return false;
+ if ( ! inv->hasMethod(OUSTR("inLong")))
+ return false;
+
+ return true;
+}
+bool doSimpleTest(const Reference<XInvocation> & inv)
+{
+ Sequence< sal_Int16> seqIndices;
+ Sequence<Any> seqOut;
+
+ Any inBool, outBool;
+ Any inByte, outByte;
+ Any inShort, outShort;
+ Any inLong, outLong;
+ Any inString, outString;
+ Any inFloat, outFloat;
+ Any inDouble, outDouble;
+ Any inVariant, outVariant;
+ Any inObject, outObject;
+ Any inUnknown, outUnknown;
+ Any inCY, outCY;
+ Any inDate, outDate;
+ Any inDecimal, outDecimal;
+ Any inSCode, outSCode;
+ Any inrefLong, outrefLong;
+ Any inrefVariant, outrefVariant;
+ Any inrefDecimal, outrefDecimal;
+
+ Reference<XInterface> xIntFoo(getComObject(L"AxTestComponents.Foo"));
+ //###################################################################################
+ // in and out parameter
+ //###################################################################################
+ sal_Bool aBool = sal_True;
+ inBool.setValue(&aBool, getCppuBooleanType());
+ inv->invoke(OUString(L"inBool"), Sequence< Any > ( &inBool, 1), seqIndices, seqOut);
+ seqIndices.realloc(0);
+ seqOut.realloc(0);
+ inv->invoke(OUString(L"outBool"), Sequence< Any > ( & outBool, 1), seqIndices, seqOut);
+ outBool <<= seqOut[0];
+
+ inByte <<= (sal_Int8) 127;
+ inv->invoke(OUString(L"inByte"), Sequence< Any > ( & inByte, 1), seqIndices, seqOut);
+ seqIndices.realloc( 0);
+ seqOut.realloc(0);
+ inv->invoke(OUString(L"outByte"), Sequence< Any > ( & outByte, 1), seqIndices, seqOut);
+ outByte <<= seqOut[0];
+
+ inShort <<= static_cast<sal_Int16>(-1);
+ inv->invoke(OUString(L"inShort"), Sequence< Any > ( & inShort, 1), seqIndices, seqOut);
+ seqIndices.realloc( 0);
+ seqOut.realloc(0);
+ inv->invoke(OUString(L"outShort"), Sequence< Any > ( & outShort, 1), seqIndices, seqOut);
+ outShort <<= seqOut[0];
+
+ inLong <<= ( sal_Int32) 1234567;
+ inv->invoke(OUString(L"inLong"), Sequence< Any > ( & inLong, 1), seqIndices, seqOut);
+ seqIndices.realloc( 0);
+ seqOut.realloc(0);
+ inv->invoke(OUString(L"outLong"), Sequence< Any > ( & outLong, 1 ), seqIndices, seqOut);
+ outLong <<= seqOut[0];
+
+ inString <<= OUString(L" this is clientTest.exe");
+ inv->invoke(OUString(L"inString"), Sequence< Any > ( & inString, 1), seqIndices, seqOut);
+ seqIndices.realloc( 0);
+ seqOut.realloc(0);
+ inv->invoke(OUString(L"outString"), Sequence< Any > ( & outString, 1 ), seqIndices, seqOut);
+ outString <<= seqOut[0];
+
+ inFloat <<= 3.14f;
+ inv->invoke(OUString(L"inFloat"), Sequence< Any > ( & inFloat, 1), seqIndices, seqOut);
+ seqIndices.realloc( 0);
+ seqOut.realloc(0);
+ inv->invoke(OUString(L"outFloat"), Sequence< Any > ( & outFloat, 1 ), seqIndices, seqOut);
+ outFloat <<= seqOut[0];
+
+ inDouble <<= ( double) 3.145;
+ inv->invoke(OUString(L"inDouble"), Sequence< Any > ( & inDouble, 1), seqIndices, seqOut);
+ seqIndices.realloc( 0);
+ seqOut.realloc(0);
+ inv->invoke(OUString(L"outDouble"), Sequence< Any > ( & outDouble, 1 ), seqIndices, seqOut);
+ outDouble <<= seqOut[0];
+
+ inVariant <<= OUString(L" A string in an any");
+ inv->invoke(OUString(L"inVariant"), Sequence< Any > ( & inVariant, 1), seqIndices, seqOut);
+ seqIndices.realloc( 0);
+ seqOut.realloc(0);
+ inv->invoke(OUString(L"outVariant"), Sequence< Any > (&outVariant, 1), seqIndices, seqOut);
+ outVariant <<= seqOut[0];
+
+ inObject <<= inv;
+ inv->invoke(OUString(L"inObject"), Sequence< Any > ( & inObject, 1), seqIndices, seqOut);
+ seqIndices.realloc( 0);
+ seqOut.realloc(0);
+ inv->invoke(OUString(L"outObject"), Sequence< Any > (& outObject, 1), seqIndices, seqOut);
+ outObject <<= seqOut[0];
+
+ inUnknown <<= xIntFoo;
+ inv->invoke(OUString(L"inUnknown"), Sequence< Any > ( & inUnknown, 1), seqIndices, seqOut);
+ seqIndices.realloc( 0);
+ seqOut.realloc(0);
+ inv->invoke(OUString(L"outUnknown"), Sequence< Any > (& outUnknown, 1), seqIndices, seqOut);
+ outUnknown <<= seqOut[0];
+
+ Currency cur(999999);
+ inCY <<= cur;
+ inv->invoke(OUString(L"inCurrency"), Sequence<Any>( & inCY, 1), seqIndices, seqOut);
+ seqIndices.realloc( 0);
+ seqOut.realloc(0);
+ inv->invoke(OUString(L"outCurrency"), Sequence< Any > (& outCY, 1), seqIndices, seqOut);
+ outCY <<= seqOut[0];
+
+ Date dDate(37889.0);
+ inDate <<= dDate;
+ inv->invoke(OUString(L"inDate"), Sequence<Any>( & inDate, 1), seqIndices, seqOut);
+ seqIndices.realloc( 0);
+ seqOut.realloc(0);
+ inv->invoke(OUString(L"outDate"), Sequence< Any > (& outDate, 1), seqIndices, seqOut);
+ outDate <<= seqOut[0];
+
+ Decimal dec(3, 0, 0xffffffff, 0xffffffff, 0xfffffff0);
+ inDecimal <<= dec;
+ inv->invoke(OUString(L"inDecimal"), Sequence<Any>( & inDecimal, 1), seqIndices, seqOut);
+ seqIndices.realloc( 0);
+ seqOut.realloc(0);
+ inv->invoke(OUString(L"outDecimal"), Sequence< Any > (& outDecimal, 1), seqIndices, seqOut);
+ outDecimal <<= seqOut[0];
+
+ SCode code(DISP_E_BADVARTYPE);
+ inSCode <<= code;
+ inv->invoke(OUString(L"inSCode"), Sequence<Any>( & inSCode, 1), seqIndices, seqOut);
+ seqIndices.realloc( 0);
+ seqOut.realloc(0);
+ inv->invoke(OUString(L"outSCode"), Sequence< Any > (& outSCode, 1), seqIndices, seqOut);
+ outSCode <<= seqOut[0];
+
+ if (inBool != outBool || inByte != outByte || inShort != outShort || inLong != outLong
+ || inFloat != outFloat || inDouble != outDouble || inString != outString
+ || inVariant != outVariant || inObject != outObject || inUnknown != outUnknown
+ || inCY != outCY
+ || inDate != outDate || inDecimal != outDecimal || inSCode != outSCode)
+ return false;
+ //###################################################################################
+ // in/out parameter
+ //###################################################################################
+ outBool = Any();
+ seqIndices.realloc( 0);
+ seqOut.realloc(0);
+ inv->invoke(OUString(L"inoutBool"), Sequence< Any > ( & inBool, 1), seqIndices, seqOut);
+ outBool <<= seqOut[0];
+
+ outByte = Any();
+ seqIndices.realloc( 0);
+ seqOut.realloc(0);
+ inv->invoke(OUString(L"inoutByte"), Sequence< Any > ( & inByte, 1), seqIndices, seqOut);
+ outByte <<= seqOut[0];
+
+ outShort = Any();
+ seqIndices.realloc( 0);
+ seqOut.realloc(0);
+ inv->invoke(OUString(L"inoutShort"), Sequence< Any > ( & inShort, 1), seqIndices, seqOut);
+ outShort <<= seqOut[0];
+
+ outLong = Any();
+ seqIndices.realloc( 0);
+ seqOut.realloc(0);
+ inv->invoke(OUString(L"inoutLong"), Sequence< Any > ( & inLong, 1), seqIndices, seqOut);
+ outLong <<= seqOut[0];
+
+ outString = Any();
+ seqIndices.realloc( 0);
+ seqOut.realloc(0);
+ inv->invoke(OUString(L"inoutString"), Sequence< Any > ( & inString, 1), seqIndices, seqOut);
+ outString <<= seqOut[0];
+
+ outFloat = Any();
+ seqIndices.realloc( 0);
+ seqOut.realloc(0);
+ inv->invoke(OUString(L"inoutFloat"), Sequence< Any > ( & inFloat, 1), seqIndices, seqOut);
+ outFloat <<= seqOut[0];
+
+ outDouble = Any();
+ seqIndices.realloc( 0);
+ seqOut.realloc(0);
+ inv->invoke(OUString(L"inoutDouble"), Sequence< Any > ( &inDouble, 1), seqIndices, seqOut);
+ outDouble <<= seqOut[0];
+
+ outVariant = Any();
+ seqIndices.realloc( 0);
+ seqOut.realloc(0);
+ inv->invoke(OUString(L"inoutVariant"), Sequence< Any > ( & inVariant, 1), seqIndices, seqOut);
+ outVariant <<= seqOut[0];
+
+ outObject = Any();
+ seqIndices.realloc( 0);
+ seqOut.realloc(0);
+ inv->invoke(OUString(L"inoutObject"), Sequence< Any > ( & inObject, 1), seqIndices, seqOut);
+ outObject <<= seqOut[0];
+
+ outCY = Any();
+ seqIndices.realloc( 0);
+ seqOut.realloc(0);
+ inv->invoke(OUString(L"inoutCurrency"), Sequence< Any > ( & inCY, 1), seqIndices, seqOut);
+ outCY <<= seqOut[0];
+
+ outDate = Any();
+ seqIndices.realloc( 0);
+ seqOut.realloc(0);
+ inv->invoke(OUString(L"inoutDate"), Sequence< Any > ( & inDate, 1), seqIndices, seqOut);
+ outDate <<= seqOut[0];
+
+ outDecimal = Any();
+ seqIndices.realloc( 0);
+ seqOut.realloc(0);
+ inv->invoke(OUString(L"inoutDecimal"), Sequence< Any > (& inDecimal, 1), seqIndices, seqOut);
+ outDecimal <<= seqOut[0];
+
+ outSCode = Any();
+ seqIndices.realloc(0);
+ seqOut.realloc(0);
+ inv->invoke(OUString(L"inoutSCode"), Sequence< Any > (& inSCode, 1), seqIndices, seqOut);
+ outSCode <<= seqOut[0];
+
+ if (inBool != outBool || inByte != outByte || inShort != outShort || inLong != outLong
+ || inFloat != outFloat || inDouble != outDouble || inString != outString
+ || inVariant != outVariant || inObject != outObject || inCY != outCY
+ || inDate != outDate || inDecimal != outDecimal || inSCode != outSCode)
+ return false;
+
+ //###################################################################################
+ // in byref parameters
+ //###################################################################################
+
+ inrefLong <<= (sal_Int32) 1234;
+ inv->invoke(OUString(L"inrefLong"), Sequence<Any>( & inrefLong, 1), seqIndices, seqOut);
+ seqIndices.realloc( 0);
+ seqOut.realloc(0);
+ inv->invoke(OUString(L"outLong"), Sequence< Any > (& outrefLong, 1), seqIndices, seqOut);
+ outrefLong <<= seqOut[0];
+
+ inrefVariant <<= OUString(L" A string in an any");
+ inv->invoke(OUString(L"inrefVariant"), Sequence< Any > ( & inrefVariant, 1), seqIndices, seqOut);
+ seqIndices.realloc( 0);
+ seqOut.realloc(0);
+ inv->invoke(OUString(L"outVariant"), Sequence< Any > (&outrefVariant, 1), seqIndices, seqOut);
+ outrefVariant <<= seqOut[0];
+
+ Decimal refdec(5, 1, 0xffff, 0xff, 0x1);
+ inrefDecimal <<= refdec;
+ inv->invoke(OUString(L"inrefDecimal"), Sequence< Any > ( & inrefDecimal, 1), seqIndices, seqOut);
+ seqIndices.realloc( 0);
+ seqOut.realloc(0);
+ inv->invoke(OUString(L"outDecimal"), Sequence< Any > (&outrefDecimal, 1), seqIndices, seqOut);
+ outrefDecimal <<= seqOut[0];
+
+ if (inrefLong != outrefLong || inrefVariant != outrefVariant
+ || inrefDecimal != outrefDecimal)
+ return false;
+
+
+ //###################################################################################
+ // mixed parameter
+ //###################################################################################
+ // mixed1
+ seqIndices.realloc( 0);
+ seqOut.realloc(0);
+ Any param[3];
+ param[0] = inByte;
+ param[1] = inFloat;
+ param[2] = inVariant;
+ inv->invoke(OUString(L"mixed1"), Sequence< Any >(param, 3), seqIndices, seqOut);
+
+ if (seqOut.getLength() != 3 || inByte != seqOut[0] || inFloat != seqOut[1]
+ || inVariant != seqOut[2])
+ return false;
+ return true;
+}
+
+bool doSimpleSequenceTest(const Reference<XInvocation> & inv)
+{
+ bool ret = true;
+ Sequence<sal_Int16> seqIndices;
+ Sequence<Any> seqOut;
+ Any voidAny;
+ Any inArAny;
+ Any outArray;
+ Any inArBool, outArBool;
+ Any inArByte, outArByte;
+ Any inArShort, outArShort;
+ Any inArLong, outArLong;
+ Any inArString, outArString;
+ Any inArFloat, outArFloat;
+ Any inArDouble, outArDouble;
+ Any inArObject, outArObject;
+ Any outVariant;
+
+ //Initialize arrays
+ OUString arStr[]= {L"string0", L"string1", L"string2"};
+ Sequence<OUString> seq( arStr, 3);
+ inArString <<= seq;
+
+ Any arAnyStrTmp[3];
+ arAnyStrTmp[0]<<= arStr[0];
+ arAnyStrTmp[1]<<= arStr[1];
+ arAnyStrTmp[2]<<= arStr[2];
+ Sequence<Any> seq_1( arAnyStrTmp, 3);
+ inArAny <<= seq_1;
+ //###################################################################################
+ // in, out Sequences
+ //###################################################################################
+ //Test sequence containing Anys of Strings
+ inv->invoke(OUString(L"inArray"), Sequence< Any > ( & inArAny, 1), seqIndices, seqOut);
+ seqIndices.realloc(0);
+ seqOut.realloc(0);
+ inv->invoke(OUString(L"outArray"), Sequence<Any>( & voidAny, 1), seqIndices, seqOut);
+ if (inArAny != seqOut[0])
+ return false;
+
+ seqIndices.realloc(0);
+ seqOut.realloc(0);
+ inv->invoke(OUString(L"inArray"), Sequence< Any >( & inArString, 1), seqIndices, seqOut);
+ inv->invoke(OUString(L"outArray"), Sequence< Any >( & voidAny, 1), seqIndices, seqOut);
+ outArray <<= seqOut[0];
+
+ sal_Int8 arByte[]={1,2,3};
+ Sequence<sal_Int8> seqByte(arByte, 3);
+ inArByte <<= seqByte;
+ inv->invoke(OUString(L"inSequenceByte"),Sequence<Any>( & inArByte, 1), seqIndices, seqOut);
+ seqIndices.realloc(0);
+ seqOut.realloc(0);
+ inv->invoke(OUString(L"outSequenceByte"), Sequence< Any >( & voidAny, 1), seqIndices, seqOut);
+ outArByte <<= seqOut[0];
+
+ sal_Int16 arShort[]={4,5,6};
+ Sequence<sal_Int16> seqShort(arShort, 3);
+ inArShort<<= seqShort;
+ inv->invoke(OUString(L"inSequenceShort"),Sequence< Any >( & inArShort, 1), seqIndices, seqOut);
+ seqIndices.realloc(0);
+ seqOut.realloc(0);
+ inv->invoke(OUString(L"outSequenceShort"), Sequence< Any >( & voidAny, 1), seqIndices, seqOut);
+ outArShort <<= seqOut[0];
+
+ sal_Int32 arLong[] = {7,8,9};
+ Sequence<sal_Int32> seqLong(arLong, 3);
+ inArLong <<= seqLong;
+ inv->invoke(OUString(L"inSequenceLong"),Sequence< Any > ( & inArLong, 1), seqIndices, seqOut);
+ seqIndices.realloc(0);
+ seqOut.realloc(0);
+ inv->invoke(OUString(L"outSequenceLong"), Sequence< Any >( & voidAny, 1), seqIndices, seqOut);
+ outArLong <<= seqOut[0];
+
+ inv->invoke(OUString(L"inSequenceLong"),Sequence< Any > ( & inArLong, 1), seqIndices, seqOut);
+ seqIndices.realloc(0);
+ seqOut.realloc(0);
+ inv->invoke(OUString(L"outSequenceLong"), Sequence< Any >( & voidAny, 1), seqIndices, seqOut);
+ outArLong <<= seqOut[0];
+
+ inv->invoke( OUString(L"inSequenceString"),Sequence< Any > ( & inArString, 1), seqIndices, seqOut);
+ seqIndices.realloc(0);
+ seqOut.realloc(0);
+ inv->invoke(OUString(L"outSequenceString"), Sequence< Any >( & voidAny, 1), seqIndices, seqOut);
+ outArString <<= seqOut[0];
+
+ float arFloat[]={3.14f, 31.4f, 314.f};
+ Sequence<float> seqFloat( arFloat, 3);
+ inArFloat <<= seqFloat;
+ inv->invoke( OUString(L"inSequenceFloat"),Sequence< Any > ( & inArFloat, 1), seqIndices, seqOut);
+ seqIndices.realloc(0);
+ seqOut.realloc(0);
+ inv->invoke(OUString(L"outSequenceFloat"), Sequence< Any >( & voidAny, 1), seqIndices, seqOut);
+ outArFloat <<= seqOut[0];
+
+ double arDouble[]={3.145, 31.45, 3145.};
+ Sequence<double> seqDouble( arDouble, 3);
+ inArDouble <<= seqDouble;
+ inv->invoke(OUString(L"inSequenceDouble"),Sequence< Any >( & inArDouble, 1), seqIndices, seqOut);
+ seqIndices.realloc(0);
+ seqOut.realloc(0);
+ inv->invoke(OUString(L"outSequenceDouble"), Sequence< Any >( & voidAny, 1), seqIndices, seqOut);
+ outArDouble <<= seqOut[0];
+
+ Sequence<Reference<XInvocation> > seqObj(2);
+ seqObj[0]= getComObject(L"AxTestComponents.Basic");
+ seqObj[1]= getComObject(L"AxTestComponents.Basic");
+ inArObject <<= seqObj;
+ inv->invoke(OUString(L"inSequenceObject"),Sequence< Any >( & inArObject, 1), seqIndices, seqOut);
+ seqIndices.realloc(0);
+ seqOut.realloc(0);
+ inv->invoke(OUString(L"outSequenceObject"), Sequence< Any >( & voidAny, 1), seqIndices, seqOut);
+ outArObject <<= seqOut[0];
+
+ if ( ! equalSequences(inArByte, outArByte) || ! equalSequences(inArShort, outArShort)
+ || ! equalSequences(inArLong, outArLong) || ! equalSequences(inArString, outArray)
+ || ! equalSequences(inArFloat, outArFloat) || ! equalSequences(inArDouble, outArDouble)
+ || ! equalSequences(inArString, outArString) || ! equalSequences(inArObject, outArObject))
+ return false;
+
+ //###################################################################################
+ // in/out Sequences
+ //###################################################################################
+ seqIndices.realloc(0);
+ seqOut.realloc(0);
+ inv->invoke(OUString(L"inoutArray"), Sequence< Any >( & inArString, 1), seqIndices, seqOut);
+ inv->invoke(OUString(L"inoutArray"), Sequence< Any >( & inArString, 1), seqIndices, seqOut);
+ outArray <<= seqOut[0];
+
+ inv->invoke(OUString(L"inoutSequenceByte"), Sequence<Any>( & inArByte, 1), seqIndices, seqOut);
+ inv->invoke(OUString(L"inoutSequenceByte"), Sequence<Any>( & inArByte, 1), seqIndices, seqOut);
+ outArByte <<= seqOut[0];
+
+ inv->invoke(OUString(L"inoutSequenceShort"), Sequence<Any>( & inArShort, 1), seqIndices, seqOut);
+ inv->invoke(OUString(L"inoutSequenceShort"), Sequence<Any>( & inArShort, 1), seqIndices, seqOut);
+ outArShort <<= seqOut[0];
+
+ inv->invoke(OUString(L"inoutSequenceLong"), Sequence<Any>( & inArLong, 1), seqIndices, seqOut);
+ inv->invoke(OUString(L"inoutSequenceLong"), Sequence< Any >( & inArLong, 1), seqIndices, seqOut);
+ outArLong <<= seqOut[0];
+
+ inv->invoke(OUString(L"inoutSequenceString"), Sequence<Any>( & inArString, 1), seqIndices, seqOut);
+ inv->invoke(OUString(L"inoutSequenceString"), Sequence<Any>( & inArString, 1), seqIndices, seqOut);
+ outArString <<= seqOut[0];
+
+ inv->invoke(OUString(L"inoutSequenceFloat"), Sequence<Any>( & inArFloat, 1), seqIndices, seqOut);
+ inv->invoke(OUString(L"inoutSequenceFloat"), Sequence<Any>( & inArFloat, 1), seqIndices, seqOut);
+ outArFloat <<= seqOut[0];
+
+ inv->invoke(OUString(L"inoutSequenceDouble"), Sequence<Any>( & inArDouble, 1), seqIndices, seqOut);
+ inv->invoke(OUString(L"inoutSequenceDouble"), Sequence<Any>( & inArDouble, 1), seqIndices, seqOut);
+ outArDouble <<= seqOut[0];
+
+ inv->invoke(OUString(L"inoutSequenceObject"), Sequence<Any>( & inArObject, 1), seqIndices, seqOut);
+ inv->invoke(OUString(L"inoutSequenceObject"), Sequence<Any>( & inArObject, 1), seqIndices, seqOut);
+ outArObject <<= seqOut[0];
+
+ if ( ! equalSequences(inArByte, outArByte) || ! equalSequences(inArShort, outArShort)
+ || ! equalSequences(inArLong, outArLong) || ! equalSequences(inArString, outArray)
+ || ! equalSequences(inArFloat, outArFloat) || ! equalSequences(inArDouble, outArDouble)
+ || ! equalSequences(inArString, outArString) || ! equalSequences(inArObject, outArObject))
+ return false;
+
+ return ret;
+}
+
+HRESULT doTest()
+{
+ HRESULT hr= S_OK;
+ USES_CONVERSION;
+ Reference<XInvocation> inv= getComObject( L"AxTestComponents.Basic");
+
+ HostWin* pWin= new HostWin( L"MFCCONTROL.MfcControlCtrl.1");
+ CComPtr<IUnknown> spUnk= pWin->GetHostedControl();
+ Reference<XInvocation> invMfc= convertComObject( spUnk.p);
+
+ Sequence< sal_Int16> seqIndices;
+ Sequence<Any> seqOut;
+
+ Any aAny;
+ Any anyOut;
+ char buff[1024];
+ Any seqAny;
+
+ if (! doSimpleTest(inv))
+ {
+ fprintf(stdout, "### Test failed!\n");
+ return E_FAIL;
+ }
+
+ if (! doPropertyTest(inv))
+ {
+ fprintf(stdout, "### Test failed!\n");
+ return E_FAIL;
+ }
+
+ if ( ! doSimpleSequenceTest(inv))
+ {
+ fprintf(stdout, "### Test failed! \n");
+ return E_FAIL;
+ }
+
+ if ( ! doParameterTest(inv))
+ {
+ fprintf(stdout, "### Test failed! \n");
+ return E_FAIL;
+ }
+
+ if ( ! doPropertyWithArgumentTest(inv))
+ {
+ fprintf(stdout, "### Test failed! \n");
+ return E_FAIL;
+ }
+
+
+
+
+
+//
+// //###################################################################################
+// // in multi Sequences
+// //###################################################################################
+// // inMulDimArrayLong
+ sal_Int32 arLongi[]={1,2,3};
+ sal_Int32 arLongi2[]={4,5,6,7};
+ sal_Int32 arLongi3[]={8,9,10,11,12};
+
+ Sequence<sal_Int32> seqLongi1( arLongi, 3);
+ Sequence<sal_Int32> seqLongi2( arLongi2, 4);
+ Sequence<sal_Int32> seqLongi3( arLongi3, 5);
+
+ Sequence< Sequence< sal_Int32 > > seq2i(3);
+ seq2i[0]= seqLongi1;
+ seq2i[1]= seqLongi2;
+ seq2i[2]= seqLongi3;
+ seqAny<<= seq2i;
+ // dimension length 3,5
+ inv->invoke( OUString(L"inMulDimArrayLong"),Sequence< Any > ( &seqAny, 1), seqIndices, seqOut);
+//
+ //inMulDimArrayVariant
+ inv->invoke( OUString(L"inMulDimArrayVariant"),Sequence< Any > ( &seqAny, 1), seqIndices, seqOut);
+
+ //inMulDimArrayLong2
+ sal_Int32 arLongii1[]={1,2,3};
+ sal_Int32 arLongii2[]={4,5,6,7};
+ sal_Int32 arLongii3[]={8,9,10,11,12};
+ sal_Int32 arLongii4[]={13,14,15,16};
+ sal_Int32 arLongii5[]={17,18,19};
+
+ Sequence<sal_Int32> seqLongii1( arLongii1, 3);
+ Sequence<sal_Int32> seqLongii2( arLongii2, 4);
+ Sequence<sal_Int32> seqLongii3( arLongii3, 5);
+ Sequence<sal_Int32> seqLongii4( arLongii4, 4);
+ Sequence<sal_Int32> seqLongii5( arLongii5, 3);
+
+ Sequence< Sequence< sal_Int32 > > seq2ii(3);
+ Sequence< Sequence< sal_Int32> > seq2ii2(2);
+ seq2ii[0]= seqLongii1;
+ seq2ii[1]= seqLongii2;
+ seq2ii[2]= seqLongii3;
+
+ seq2ii2[0]= seqLongii4;
+ seq2ii2[1]= seqLongii5;
+
+ Sequence< Sequence< Sequence< sal_Int32> > > seq3ii(2);
+ seq3ii[0]=seq2ii;
+ seq3ii[1]=seq2ii2;
+ seqAny<<= seq3ii;
+ inv->invoke( OUString(L"inMulDimArrayLong2"),Sequence< Any > ( &seqAny, 1), seqIndices, seqOut);
+
+ // inMulDimArrayByte2
+ sal_Int8 arByteii1[]={1,2,3};
+ sal_Int8 arByteii2[]={4,5,6,7};
+ sal_Int8 arByteii3[]={8,9,10,11,12};
+ sal_Int8 arByteii4[]={13,14,15,16};
+ sal_Int8 arByteii5[]={17,18,19};
+
+ Sequence<sal_Int8> seqByteii1( arByteii1, 3);
+ Sequence<sal_Int8> seqByteii2( arByteii2, 4);
+ Sequence<sal_Int8> seqByteii3( arByteii3, 5);
+ Sequence<sal_Int8> seqByteii4( arByteii4, 4);
+ Sequence<sal_Int8> seqByteii5( arByteii5, 3);
+
+ Sequence< Sequence< sal_Int8 > > seq2Byteii(3);
+ Sequence< Sequence< sal_Int8> > seq2Byteii2(2);
+ seq2Byteii[0]= seqByteii1;
+ seq2Byteii[1]= seqByteii2;
+ seq2Byteii[2]= seqByteii3;
+
+ seq2Byteii2[0]= seqByteii4;
+ seq2Byteii2[1]= seqByteii5;
+
+ Sequence< Sequence< Sequence< sal_Int8> > > seq3Byteii(2);
+ seq3Byteii[0]=seq2Byteii;
+ seq3Byteii[1]=seq2Byteii2;
+ seqAny<<= seq3Byteii;
+ inv->invoke( OUString(L"inMulDimArrayByte2"),Sequence< Any > ( &seqAny, 1), seqIndices, seqOut);
+
+
+
+ //###################################################################################
+ //###################################################################################
+ //###################################################################################
+ // Tests with a MFC ActiveX control, ( pure dispinterface)
+ //###################################################################################
+
+ //###################################################################################
+ // in parameter MFC ActiveX
+ //###################################################################################
+ // unsigned char is not supported by MFC
+ // aAny <<= ( sal_Int8) 127;
+ // invMfc->invoke( OUString(L"inByte"), Sequence< Any > ( &aAny, 1), seqIndices, seqOut);
+ if ( ! invMfc.is())
+ return hr;
+ aAny <<= static_cast<sal_Int16>(-1);
+ aAny= invMfc->invoke( OUString(L"inShort"), Sequence< Any > ( &aAny, 1), seqIndices, seqOut);
+
+//
+ aAny <<= ( sal_Int32) 1234567;
+ aAny=invMfc->invoke( OUString(L"inLong"), Sequence< Any > ( &aAny, 1), seqIndices, seqOut);
+ sal_Int32 retLong= *(sal_Int32*)aAny.getValue();
+
+ OUString str_1(L" this is clientTest.exe");
+ aAny <<= str_1;
+ aAny=invMfc->invoke( OUString(L"inString"), Sequence< Any > ( &aAny, 1), seqIndices, seqOut);
+ aAny>>= str_1;
+
+ aAny <<= ( float) 3.14;
+ aAny=invMfc->invoke( OUString(L"inFloat"), Sequence< Any > ( &aAny, 1), seqIndices, seqOut);
+
+ aAny <<= ( double) 3.145;
+ aAny=invMfc->invoke( OUString(L"inDouble"), Sequence< Any > ( &aAny, 1), seqIndices, seqOut);
+
+ aAny <<= OUString( L" A string in an any");
+ aAny=invMfc->invoke( OUString(L"inVariant"), Sequence< Any > ( &aAny, 1), seqIndices, seqOut);
+
+ // Tests with Sequences later.
+ // OUString arStr4[]= {L"string0", L"string1", L"string2"};
+ // Sequence<OUString> seqStr4( arStr4, 3);
+ // aAny <<= seqStr4;
+ // invMfc->invoke( OUString(L"inArray"), Sequence< Any > ( &aAny, 1), seqIndices, seqOut);
+
+
+ Reference < XInvocation > inv5= getComObject(L"AxTestComponents.Basic");
+ Any anyVal4;
+ anyVal4 <<= OUString(L"this is the value of prpString");
+ inv5->setValue( OUString(L"prpString"), anyVal4);
+ aAny <<= inv5;
+ aAny=invMfc->invoke( OUString(L"inObject"), Sequence< Any > ( &aAny, 1), seqIndices, seqOut);
+//
+// //###################################################################################
+// // out parameter MFC ActiveX
+// //###################################################################################
+//
+// // outShort
+ aAny= invMfc->invoke( OUString(L"outShort"), Sequence< Any > ( &aAny, 1), seqIndices, seqOut);
+ anyOut<<= seqOut[0];
+ sprintf(buff, "MFC outShort %d", *(sal_Int16*)anyOut.getValue());
+ MessageBox( NULL, buff, _T("clientTest"), MB_OK);
+
+ // outLong
+ aAny= invMfc->invoke( OUString(L"outLong"), Sequence< Any > ( &aAny, 1), seqIndices, seqOut);
+ anyOut<<= seqOut[0];
+ sprintf(buff, "MFC outLong %d", *(sal_Int32*)anyOut.getValue());
+ MessageBox( NULL, buff, _T("clientTest"), MB_OK);
+
+ // outString
+ aAny= invMfc->invoke( OUString(L"outString"), Sequence< Any > ( &aAny, 1), seqIndices, seqOut);
+ anyOut<<= seqOut[0];
+ sprintf(buff, "MFC outString %S", ((OUString*)anyOut.getValue())->getStr());
+ MessageBox( NULL, buff, _T("clientTest"), MB_OK);
+
+ // outFloat
+ aAny= invMfc->invoke( OUString(L"outFloat"), Sequence< Any > ( &aAny, 1), seqIndices, seqOut);
+ anyOut<<= seqOut[0];
+ sprintf(buff, "MFC outFloat %f", *(float*)anyOut.getValue());
+ MessageBox( NULL, buff, _T("clientTest"), MB_OK);
+
+ // outDouble
+ aAny= invMfc->invoke( OUString(L"outDouble"), Sequence< Any > ( &aAny, 1), seqIndices, seqOut);
+ anyOut<<= seqOut[0];
+ sprintf(buff, "MFC outFloat %f", *(double*)anyOut.getValue());
+ MessageBox( NULL, buff, _T("clientTest"), MB_OK);
+
+ // outVariant
+ // we expect a string!! ( VT_BSTR)
+ aAny= invMfc->invoke( OUString(L"outVariant"), Sequence< Any > ( &aAny, 1), seqIndices, seqOut);
+ anyOut<<= seqOut[0];
+ sprintf(buff, "MFC outVariant %S", ((OUString*)anyOut.getValue())->getStr());
+ MessageBox( NULL, buff, _T("clientTest"), MB_OK);
+
+ // outDouble
+ aAny= invMfc->invoke( OUString(L"outObject"), Sequence< Any > ( &aAny, 1), seqIndices, seqOut);
+ Reference<XInvocation> invOut5;
+ seqOut[0]>>= invOut5;
+ // we assume that an object of AxTestControls.Basic is being returned.
+ anyOut= invOut5->getValue( OUString(L"prpString"));
+ OUString tmpStr;
+ anyOut>>=tmpStr;
+ sprintf(buff, "MFC outObject, property: %S", tmpStr.getStr());
+ MessageBox( NULL, buff, _T("clientTest"), MB_OK);
+
+
+ //###################################################################################
+ // Sequence parameter MFC ActiveX
+ //###################################################################################
+ // Sequences are not directly supported.
+
+
+ delete pWin;
+ return hr;
+
+}
+
+
+
+//VARIANT_TRUE VT_UI1
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/test/ole/OleClient/funcs.cxx b/extensions/test/ole/OleClient/funcs.cxx
new file mode 100644
index 000000000000..665814341d3e
--- /dev/null
+++ b/extensions/test/ole/OleClient/funcs.cxx
@@ -0,0 +1,357 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+
+#include <atlbase.h>
+#include <stdio.h>
+#include "cppuhelper/bootstrap.hxx"
+#include "rtl/process.h"
+#include "typelib/typedescription.hxx"
+
+#include "com/sun/star/bridge/ModelDependent.hpp"
+#include "com/sun/star/bridge/XBridgeSupplier2.hpp"
+#include "com/sun/star/uno/TypeClass.hpp"
+#include "com/sun/star/script/XInvocation.hpp"
+#include "com/sun/star/lang/XMultiServiceFactory.hpp"
+#include "com/sun/star/uno/XComponentContext.hpp"
+#include <com/sun/star/bridge/oleautomation/NamedArgument.hpp>
+#include "rtl/ustring.hxx"
+
+using namespace com::sun::star::bridge;
+using namespace com::sun::star::bridge::ModelDependent;
+using namespace com::sun::star::uno;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::script;
+using namespace com::sun::star::bridge::oleautomation;
+using namespace rtl;
+using namespace cppu;
+
+template< class T >
+bool equalSequences(const Sequence<T>& seqIn, const Sequence<Any> & returned);
+
+
+Reference< XMultiServiceFactory > objectFactory;//
+
+
+Reference<XMultiServiceFactory> getMultiServiceFactory()
+{
+ static Reference< XMultiServiceFactory > factory;
+ if( ! objectFactory.is() )
+ {
+ Reference<XComponentContext> context = defaultBootstrap_InitialComponentContext();
+ factory = Reference<XMultiServiceFactory>( context->getServiceManager(), UNO_QUERY);
+
+ }
+ return factory;
+}
+
+Reference<XInvocation> getComObject( OUString progId)
+{
+ HRESULT hr= S_OK;
+ Reference< XInvocation > ret;
+// Reference<XMultiServiceFactory> fac;
+ if( ! objectFactory.is())
+ { Reference<XMultiServiceFactory> mgr= getMultiServiceFactory();
+ Reference<XInterface> xInt= mgr->createInstance(
+ OUString(L"com.sun.star.bridge.oleautomation.Factory"));
+ objectFactory= Reference<XMultiServiceFactory>::query( xInt);
+ }
+
+ if( objectFactory.is())
+ {
+ Reference<XInterface> xIntAx= objectFactory->createInstance( progId.getStr());
+ if( xIntAx.is() )
+ {
+ Reference< XInvocation > xInv( xIntAx, UNO_QUERY);
+ ret= xInv;
+ }
+ }
+ return ret;
+}
+
+Reference<XInvocation> convertComObject( IUnknown* pUnk)
+{
+ Reference< XMultiServiceFactory > mgr= getMultiServiceFactory();
+ Reference< XInterface > xIntSupplier= mgr->createInstance(OUString(L"com.sun.star.bridge.OleBridgeSupplier2"));
+ Reference< XBridgeSupplier2 > xSuppl( xIntSupplier, UNO_QUERY);
+
+ Any any;
+ CComVariant var( pUnk);
+ any <<= ( sal_uInt32)&var;
+ sal_uInt8 arId[16];
+ rtl_getGlobalProcessId( arId);
+ Any target= xSuppl->createBridge( any, Sequence<sal_Int8>( (sal_Int8*)arId, 16), OLE, UNO );
+
+ Reference<XInvocation> ret;
+ target>>= ret;
+ return ret;
+}
+
+/*
+ Parameter values contains the expected return values. The value at index 0
+ correspond to parameter 0 (left - most). For parameters which are not out or
+ in/out the value must be a void any.
+
+ The number of items in value must be the
+ same as the number of provided parameter during the call on the method.
+
+ The parameter outArgs, indices correspond to the sequences which are
+ arguments to XInvocation::invoke
+ */
+bool checkOutArgs(const Sequence<Any> & outArgs,
+ const Sequence<sal_Int16> & indices, const Sequence<Any> & values)
+{
+ if (values.getLength() != outArgs.getLength())
+ return false;
+ //iterate over all parameters. i represents the parameter index
+ for (int i = 0; i < values.getLength(); i++)
+ {
+ if (values[i].getValueType() == getVoidCppuType())
+ continue;
+ //out parameter
+ //Based on the parameter index find the correspondent out value
+ int indexOutSeq = -1;
+ for (int iIndices = indices.getLength() - 1; iIndices >= 0; iIndices --)
+ {
+ if (indices[iIndices] == i)
+ {
+ indexOutSeq = iIndices;
+ break;
+ }
+ }
+ if (indexOutSeq == -1)
+ return false;
+
+ Any value;
+ Any out;
+ values[i] >>= value;
+ outArgs[indexOutSeq] >>=out;
+ NamedArgument naVal;
+ NamedArgument naOut;
+ value >>= naVal;
+ out >>= naOut;
+ if (values[i].getValueType() == getCppuType((NamedArgument *) 0))
+ {
+ NamedArgument inNamed;
+ values[i] >>= inNamed;
+ value <<= inNamed.Value;
+ }
+ if (value != outArgs[indexOutSeq])
+ return false;
+ }
+ return true;
+}
+
+/* The returned sequence always contains Any elements
+*/
+bool equalSequences(const Any& orig, const Any& returned)
+{
+ if (orig.getValueTypeClass() != TypeClass_SEQUENCE)
+ {
+ OSL_ASSERT(0);
+ return false;
+ }
+ TypeDescription td(orig.getValueTypeRef());
+ typelib_IndirectTypeDescription * indirect_td = (typelib_IndirectTypeDescription *) td.get();
+
+ switch (indirect_td->pType->eTypeClass)
+ {
+ case TypeClass_CHAR:
+ {
+ Sequence<sal_Unicode> seq;
+ orig >>= seq;
+ Sequence<Any> seq2;
+ returned >>= seq2;
+ return equalSequences(seq, seq2);
+ }
+ case TypeClass_BOOLEAN:
+ {
+ Sequence<sal_Bool> seq;
+ orig >>= seq;
+ Sequence<Any> seq2;
+ returned >>= seq2;
+ return equalSequences(seq, seq2);
+ }
+ case TypeClass_BYTE:
+ {
+ Sequence<sal_Int8> seq;
+ orig >>= seq;
+ Sequence<Any> seq2;
+ returned >>= seq2;
+ return equalSequences(seq, seq2);
+ }
+ case TypeClass_SHORT:
+ {
+ Sequence<sal_Int16> seq;
+ orig >>= seq;
+ Sequence<Any> seq2;
+ returned >>= seq2;
+ return equalSequences(seq, seq2);
+ }
+ case TypeClass_LONG:
+ {
+ Sequence<sal_Int32> seq;
+ orig >>= seq;
+ Sequence<Any> seq2;
+ returned >>= seq2;
+ return equalSequences(seq, seq2);
+ }
+ case TypeClass_FLOAT:
+ {
+ Sequence<float> seq;
+ orig >>= seq;
+ Sequence<Any> seq2;
+ returned >>= seq2;
+ return equalSequences(seq, seq2);
+ }
+ case TypeClass_DOUBLE:
+ {
+ Sequence<double> seq;
+ orig >>= seq;
+ Sequence<Any> seq2;
+ returned >>= seq2;
+ return equalSequences(seq, seq2);
+ }
+ case TypeClass_STRING:
+ {
+ Sequence<OUString> seq;
+ orig >>= seq;
+ Sequence<Any> seq2;
+ returned >>= seq2;
+ return equalSequences(seq, seq2);
+ }
+ case TypeClass_ANY:
+ {
+ Sequence<Any> seq;
+ orig >>= seq;
+ Sequence<Any> seq2;
+ returned >>= seq2;
+ return equalSequences(seq, seq2);
+ }
+ case TypeClass_SEQUENCE:
+ {
+ //Sequence<sal_Unicode> seq;
+ //orig >>= seq;
+ //Sequence<Any> seq2;
+ //returned >>= seq2;
+ //return equalSequences(seq, seq2);
+ break;
+ }
+ case TypeClass_INTERFACE:
+ {
+ Sequence<Reference<XInvocation> > seq;
+ orig >>= seq;
+ Sequence<Any> seq2;
+ returned >>= seq2;
+ return equalSequences(seq, seq2);
+ }
+ default:
+ return false;
+ }
+ return false;
+}
+
+template< class T >
+bool equalSequences(const Sequence<T>& seqIn, const Sequence<Any> & seqOut)
+{
+ if (seqIn.getLength() != seqOut.getLength())
+ return false;
+ int len = seqIn.getLength();
+ for (int i = 0; i < len; i++)
+ {
+ Any anyIn;
+ anyIn <<= seqIn[i];
+ Any anyOut = seqOut[i];
+ if (anyIn != anyOut)
+ return false;
+ }
+
+ return true;
+}
+
+void printSequence( Sequence<Any>& val)
+{
+
+// typelib_TypeDescription* desc;
+// val.getValueTypeDescription( &desc);
+// typelib_typedescription_release( desc);
+
+ USES_CONVERSION;
+ char buff[1024];
+ buff[0]=0;
+ char tmpBuf[1024];
+ tmpBuf[0]=0;
+ sal_Int32 i;
+
+ for( i=0; i< val.getLength(); i++)
+ {
+ Any& elem= val[i];
+ switch ( elem.getValueTypeClass())
+ {
+ case TypeClass_BYTE:
+ sprintf( tmpBuf, "sal_Int8 %d \n", *(sal_Int8*)elem.getValue());
+ break;
+ case TypeClass_SHORT:
+ sprintf( tmpBuf, "sal_Int16 %d \n", *(sal_Int16*)elem.getValue());
+ break;
+ case TypeClass_LONG:
+ sprintf( tmpBuf, "sal_Int32 %d \n", *(sal_Int32*)elem.getValue());
+ break;
+ case TypeClass_DOUBLE:
+ sprintf( tmpBuf, "double %f \n", *(double*)elem.getValue());
+ break;
+ case TypeClass_FLOAT:
+ sprintf( tmpBuf, "float %f \n", *(float*)elem.getValue());
+ break;
+ case TypeClass_STRING:
+ sprintf( tmpBuf, "%S \n", (*(OUString*)elem.getValue()).getStr());
+ break;
+ case TypeClass_INTERFACE:
+ {
+ // we assume that the interface is XInvocation of a AxTestControls.Basic component.
+ Reference<XInvocation> inv;
+ elem>>= inv;
+ if( inv.is())
+ {
+ Any prpVal= inv->getValue( OUString( L"prpString"));
+ sprintf( tmpBuf, "Property prpString: %S \n", (*(OUString*)prpVal.getValue()).getStr());
+ }
+ break;
+ }
+ default:break;
+ }
+ strcat( buff, tmpBuf);
+
+ }
+
+ MessageBox( NULL, A2T(buff), _T("clientTest: printing Sequence elements"), MB_OK);
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/test/ole/OleClient/makefile.mk b/extensions/test/ole/OleClient/makefile.mk
new file mode 100644
index 000000000000..0587038d05f7
--- /dev/null
+++ b/extensions/test/ole/OleClient/makefile.mk
@@ -0,0 +1,72 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ=..$/..$/..$/
+
+PRJNAME=extensions
+TARGET=clientTest
+TARGETTYPE=CUI
+LIBTARGET=NO
+
+ENABLE_EXCEPTIONS=TRUE
+
+# --- Settings ---
+
+.INCLUDE : settings.mk
+
+# --- Files ---
+
+INCPRE+= $(OUT)$/inc -I$(ATL_INCLUDE)
+
+
+
+APP1TARGET= $(TARGET)
+APP1OBJS= \
+ $(OBJ)$/clientTest.obj \
+ $(OBJ)$/axhost.obj \
+ $(OBJ)$/funcs.obj
+
+APP1STDLIBS= \
+ $(SALLIB) \
+ $(CPPUHELPERLIB) \
+ $(CPPULIB) \
+ $(USER32LIB) \
+ $(COMPATH)$/atlmfc$/lib$/atls.lib \
+ $(KERNEL32LIB) \
+ $(OLE32LIB) \
+ $(OLEAUT32LIB) \
+ $(UUIDLIB) \
+ $(GDI32LIB) \
+ $(ADVAPI32LIB)
+
+APP1DEF= $(MISC)\$(APP1TARGET).def
+
+# --- Targets ---
+
+.INCLUDE : target.mk
+
+
diff --git a/extensions/test/ole/OleClient/readme.txt b/extensions/test/ole/OleClient/readme.txt
new file mode 100644
index 000000000000..96181e44db9b
--- /dev/null
+++ b/extensions/test/ole/OleClient/readme.txt
@@ -0,0 +1,10 @@
+The program tests the OleObjectFactory service which enables to use COM components
+through XInvocation.
+
+Requirements:
+
+types.rdb and services.rdb and OleClient.ini have to be next to the executable.
+COM component: XCallback_Impl.Simple ( extensions/test/ole/unotocomcalls/XCallback_Impl )
+ActiveX controls: AxTestComponent.Basic ( extensions/test/ole/AxTestComponents)
+ MFCCONTROL.MfcControlCtrl.1 (extensions/test/ole/MfcControl)
+
diff --git a/extensions/test/ole/OleConverterVar1/convTest.cxx b/extensions/test/ole/OleConverterVar1/convTest.cxx
new file mode 100644
index 000000000000..7e89e660d40b
--- /dev/null
+++ b/extensions/test/ole/OleConverterVar1/convTest.cxx
@@ -0,0 +1,658 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+
+#pragma warning (disable: 4917)
+#include <windows.h>
+#include <comdef.h>
+#include <tchar.h>
+#include <atlbase.h>
+extern CComModule _Module;
+#include<atlcom.h>
+
+#include <stdio.h>
+#include <com/sun/star/bridge/ModelDependent.hpp>
+#include <com/sun/star/bridge/XBridgeSupplier2.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/uno/XComponentContext.hpp>
+#include <com/sun/star/lang/XMultiComponentFactory.hpp>
+
+#include <oletest/XTestSequence.hpp>
+#include <rtl/process.h>
+#include <com/sun/star/uno/Reference.h>
+#include <cppuhelper/servicefactory.hxx>
+#include <cppuhelper/bootstrap.hxx>
+#include <rtl/string.h>
+
+
+CComModule _Module;
+BEGIN_OBJECT_MAP(ObjectMap)
+END_OBJECT_MAP()
+
+#include "smartarray.h"
+using namespace com::sun::star::bridge;
+using namespace com::sun::star::bridge::ModelDependent;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::uno;
+using namespace oletest;
+using namespace cppu;
+using namespace rtl;
+HRESULT doTest();
+HRESULT InitializeParameter();
+void printResultVariantArray( VARIANT & var);
+void printVariant( VARIANT & var);
+
+
+
+
+int __cdecl _tmain( int argc, _TCHAR * argv[] )
+{
+ HRESULT hr;
+ if( FAILED( hr=CoInitialize(NULL)))
+ {
+ _tprintf(_T("CoInitialize failed \n"));
+ return -1;
+ }
+
+
+ _Module.Init( ObjectMap, GetModuleHandle( NULL));
+
+ if( FAILED(hr=doTest()))
+ {
+ _com_error err( hr);
+ const TCHAR * errMsg= err.ErrorMessage();
+ MessageBox( NULL, errMsg, "Test failed", MB_ICONERROR);
+ }
+
+
+ _Module.Term();
+ CoUninitialize();
+ return 0;
+}
+char _c[]={ 1,2,3,4,5};
+short _short[]={0xffff, 1, 11 ,111, 1111 };
+unsigned short _ushort[]={0xffff, 1, 11 ,111, 1111 };
+long _long[]= { 0xffffffff, 11, 111 ,1111, 1111 };
+unsigned long _ulong[]= { 0xffffffff, 11, 111 ,1111, 1111 };
+float _float[]= { 12345.f, 1234.5f, 123.45f, 12.345f, 1.2345f};
+double _double[]= {12345, 1234.5, 123.45, 12.345, 1.2345};
+
+CComVariant _variant[]= {L"variant 1", L"variant2", L"variant3"};
+wchar_t _wchar[]= {L'1', L'2', L'3', L'A', L' '};
+BSTR _bstr[]={L"Ich", L"bin", L"ein", L"Hamburger", L"Jung"};
+SmartArray<char> arByte( _c, 5, VT_I1);
+SmartArray< short> arShort( _short, 5, VT_I2);
+//SmartArray< unsigned short> arUShort( _ushort, 5, VT_UI2);
+SmartArray< long> arLong( _long, 5, VT_I4);
+//SmartArray< unsigned long> arULong( _ulong, 5, VT_UI4);
+//SmartArray< float> arFloat( _float, 5, VT_R4 );
+SmartArray< double> arDouble( _double, 5, VT_R8 );
+//SmartArray< unsigned short> arWChar( _wchar, 5, VT_UI2 );
+SmartArray< wchar_t* > arString( _bstr, 5, VT_BSTR);
+SmartArray< VARIANT > arVariant( _variant, 3, VT_VARIANT);
+
+
+HRESULT doTest()
+{
+ HRESULT hr;
+ USES_CONVERSION;
+ CComPtr<IUnknown> spUnkMgr;
+
+ putenv("UNO_TYPES=types.rdb");
+ putenv("UNO_SERVICES=services.rdb");
+ Reference<XComponentContext> xContext = defaultBootstrap_InitialComponentContext();
+
+ Reference< XMultiComponentFactory > mgr = xContext->getServiceManager();//createRegistryServiceFactory( OUString(L"services.rdb"));
+ Reference< XInterface > xIntSupplier= mgr->createInstanceWithContext(
+ OUString(L"com.sun.star.bridge.OleBridgeSupplierVar1"), xContext);
+ Reference< XBridgeSupplier2 > xSuppl( xIntSupplier, UNO_QUERY);
+ Reference <XInterface> xOletest= mgr->createInstanceWithContext(
+ OUString(L"oletest.OleTest"), xContext);
+ Any any;
+ any <<= xOletest;
+ sal_uInt8 arId[16];
+ rtl_getGlobalProcessId( arId);
+ Any target= xSuppl->createBridge( any, Sequence<sal_Int8>( (sal_Int8*)arId, 16), UNO, OLE);
+ CComDispatchDriver oletest;
+ if (target.getValueTypeClass() == getCppuType((sal_uInt32*) 0).getTypeClass())
+ {
+ VARIANT* pVariant = *(VARIANT**)target.getValue();
+
+ oletest= pVariant->pdispVal;
+
+ VariantClear(pVariant);
+ CoTaskMemFree(pVariant);
+ }
+
+ CComVariant varRet;
+ CComVariant varParam1;
+ CComVariant varParam2;
+ CComVariant varParam3;
+ CComVariant varParam4;
+
+ long value= 100;
+ varParam1.vt= VT_I1 | VT_BYREF;
+ varParam1.plVal= &value;
+
+ // Testing the caching of DISPIDs and the process of aquiring member information
+ // on demand in IDispatch::Invoke
+ // Step through the corresponding IDispatch implementation of the ole bridge
+ hr= oletest.Invoke1(static_cast<LPCOLESTR>(L"testinout_methodByte"), &varParam1, &varRet);
+ hr= oletest.Invoke1(static_cast<LPCOLESTR>(L"testinout_methodByte"), &varParam1, &varRet);
+ // Name ok but different case
+ hr= oletest.Invoke1(static_cast<LPCOLESTR>(L"Testinout_methodByte"), &varParam1, &varRet);
+ hr= oletest.Invoke1(static_cast<LPCOLESTR>(L"Testinout_methodByte"), &varParam1, &varRet);
+ // not existing member
+ hr= oletest.Invoke1(static_cast<LPCOLESTR>(L"Testinout"), &varParam1, &varRet);
+ hr= oletest.Invoke1(static_cast<LPCOLESTR>(L"Testinout"), &varParam1, &varRet);
+
+ // Property
+ varParam1.vt= VT_ARRAY | VT_I1;
+ varParam1.parray= (SAFEARRAY*)arByte;
+ hr= oletest.PutPropertyByName( static_cast<LPCOLESTR>(L"AttrByte"), &varParam1);
+ hr= oletest.PutPropertyByName( static_cast<LPCOLESTR>(L"AttrByte"), &varParam1);
+ // Name ok but different case
+ hr= oletest.PutPropertyByName( static_cast<LPCOLESTR>(L"attrByte"), &varParam1);
+ hr= oletest.PutPropertyByName( static_cast<LPCOLESTR>(L"attrByte"), &varParam1);
+ // not existing member
+ hr= oletest.PutPropertyByName( static_cast<LPCOLESTR>(L"attr"), &varParam1);
+ hr= oletest.PutPropertyByName( static_cast<LPCOLESTR>(L"attr"), &varParam1);
+
+ // PropertyGet
+ hr= oletest.GetPropertyByName( static_cast<LPCOLESTR>(L"AttrByte"), &varRet);
+
+ hr= oletest.GetPropertyByName( static_cast<LPCOLESTR>(L"attrByte"), &varRet);
+ hr= oletest.GetPropertyByName( static_cast<LPCOLESTR>(L"attrByte"), &varRet);
+ //not existing member
+ hr= oletest.GetPropertyByName( static_cast<LPCOLESTR>(L"attrBy"), &varRet);
+ hr= oletest.GetPropertyByName( static_cast<LPCOLESTR>(L"attrBy"), &varRet);
+
+ DISPID dispid;
+ LPOLESTR method= L"methodByte";
+ hr = oletest.p->GetIDsOfNames(IID_NULL, &method, 1, LOCALE_USER_DEFAULT, &dispid);
+
+
+ CComVariant arg[1];
+ arg[0].vt= VT_ARRAY | VT_I1;
+ arg[0].parray= (SAFEARRAY*)arByte;
+ DISPPARAMS params={ arg,0,1,0};
+
+ hr = oletest.p->Invoke(dispid, IID_NULL, LOCALE_USER_DEFAULT,
+ DISPATCH_METHOD | DISPATCH_PROPERTYPUT, &params, &varRet, NULL, NULL);
+
+ hr = oletest.p->Invoke(dispid, IID_NULL, LOCALE_USER_DEFAULT,
+ DISPATCH_METHOD | DISPATCH_PROPERTYPUT, &params, &varRet, NULL, NULL);
+
+ // different case
+ LPOLESTR method2= L"MEthodByte";
+ hr = oletest.p->GetIDsOfNames(IID_NULL, &method2, 1, LOCALE_USER_DEFAULT, &dispid);
+
+ hr = oletest.p->Invoke(dispid, IID_NULL, LOCALE_USER_DEFAULT,
+ DISPATCH_METHOD | DISPATCH_PROPERTYPUT, &params, &varRet, NULL, NULL);
+
+ hr = oletest.p->Invoke(dispid, IID_NULL, LOCALE_USER_DEFAULT,
+ DISPATCH_METHOD | DISPATCH_PROPERTYPUT, &params, &varRet, NULL, NULL);
+
+ LPOLESTR attrib= L"AttrByte";
+ hr = oletest.p->GetIDsOfNames(IID_NULL, &attrib, 1, LOCALE_USER_DEFAULT, &dispid);
+
+ hr = oletest.p->Invoke( dispid, IID_NULL, LOCALE_USER_DEFAULT,
+ DISPATCH_METHOD | DISPATCH_PROPERTYPUTREF, &params, &varRet, NULL, NULL);
+
+ hr = oletest.p->Invoke( dispid, IID_NULL, LOCALE_USER_DEFAULT,
+ DISPATCH_METHOD | DISPATCH_PROPERTYGET, &params, &varRet, NULL, NULL);
+
+
+
+ CComVariant varByteArray;
+ varByteArray.vt= VT_ARRAY | VT_I1;
+ varByteArray.parray= (SAFEARRAY*)arByte;
+ CComVariant varShortArray;
+ varShortArray.vt= VT_ARRAY | VT_I2;
+ varShortArray.parray= (SAFEARRAY*)arShort;
+ CComVariant varLongArray;
+ varLongArray.vt= VT_ARRAY | VT_I4;
+ varLongArray.parray= (SAFEARRAY*)arLong;
+ CComVariant varDoubleArray;
+ varDoubleArray.vt= VT_ARRAY | VT_R8;
+ varDoubleArray.parray= (SAFEARRAY*)arDouble;
+ CComVariant varStringArray;
+ varStringArray.vt= VT_ARRAY | VT_BSTR;
+ varStringArray.parray= (SAFEARRAY*)arString;
+ CComVariant varArray;
+ varArray.vt= VT_ARRAY | VT_VARIANT;
+ varArray.parray= (SAFEARRAY*)arVariant;
+
+ FONTDESC fd={ sizeof( fd), L"ARIAL", 10, FW_NORMAL, 0, 0, 0, 0};
+
+
+ CComPtr< IUnknown > unk1;
+ CComPtr< IUnknown > unk2;
+ CComPtr< IUnknown > unk3;
+
+ IUnknown* _unknown[3];
+ hr= OleCreateFontIndirect( &fd, __uuidof( IUnknown), (void**)&unk1.p);
+ hr= OleCreateFontIndirect( &fd, __uuidof( IUnknown), (void**)&unk2.p);
+ hr= OleCreateFontIndirect( &fd, __uuidof( IUnknown), (void**)&unk3.p);
+ _unknown[0]= unk1;
+ _unknown[1]= unk2;
+ _unknown[2]= unk3;
+ SmartArray<IUnknown*> arUnknown( _unknown, 3, VT_UNKNOWN);
+
+ CComVariant varUnkArray;
+ varUnkArray.vt= VT_ARRAY | VT_UNKNOWN;
+ varUnkArray.parray= (SAFEARRAY*)arUnknown;
+
+ // preparing out parameter;
+ char byteOut;
+ CComVariant varOutByte; //###
+ varOutByte.vt= VT_BYREF | VT_UI1;
+ V_I1REF(&varOutByte)= &byteOut;
+ short shortOut;
+ CComVariant varOutShort; //###
+ varOutShort.vt= VT_BYREF | VT_I2;
+ V_I2REF( &varOutShort)= &shortOut;
+ long longOut;
+ CComVariant varOutLong; //###
+ varOutLong.vt= VT_BYREF | VT_I4;
+ V_I4REF( &varOutLong)= &longOut;
+ double doubleOut;
+ CComVariant varOutDouble; //###
+ varOutDouble.vt= VT_BYREF | VT_R8;
+ V_R8REF( &varOutDouble)= &doubleOut;
+ BSTR bstrOut= NULL;
+ CComVariant varOutString; //###
+ varOutString.vt= VT_BYREF | VT_BSTR;
+ V_BSTRREF(&varOutString)= &bstrOut;
+ CComVariant variantOut;
+ CComVariant varOutAny; //###
+ varOutAny.vt= VT_BYREF | VT_VARIANT;
+ V_VARIANTREF(&varOutAny)= &variantOut;
+
+ CComPtr<IDispatch> dispOut;
+ CComVariant varOutXInterface; //###
+ varOutXInterface.vt= VT_BYREF |VT_DISPATCH;
+ V_DISPATCHREF(&varOutXInterface)= &dispOut.p;
+
+ // In Parameter ( all of type Sequence ###########################################################
+ OutputDebugString( _T("In parameter of type Sequence ###########################################\n"
+ "The functions return the Sequence parameter \n\n"));
+
+ OutputDebugStringA("methodByte | Params: \n");
+ printVariant( varByteArray);
+ hr= oletest.Invoke1(static_cast<LPCOLESTR>(L"methodByte"), &varByteArray, &varRet);
+ OutputDebugStringA("methodByte | return value \n");
+ printVariant( varRet);
+
+ OutputDebugStringA("methodShort | Params: \n");
+ printVariant( varShortArray);
+ hr= oletest.Invoke1(static_cast<LPCOLESTR>(L"methodShort"), &varShortArray, &varRet);
+ OutputDebugStringA("methodShort | return value \n");
+ printVariant( varRet);
+
+ OutputDebugStringA("methodLong | Params: \n");
+ printVariant( varLongArray);
+ hr= oletest.Invoke1(static_cast<LPCOLESTR>(L"methodLong"), &varLongArray, &varRet);
+ OutputDebugStringA("methodLong | return value \n");
+ printVariant( varRet);
+
+ OutputDebugStringA("methodDouble | Params: \n");
+ printVariant( varDoubleArray);
+ hr= oletest.Invoke1(static_cast<LPCOLESTR>(L"methodDouble"), &varDoubleArray, &varRet);
+ OutputDebugStringA("methodDouble | return value \n");
+ printVariant( varRet);
+
+ OutputDebugStringA("methodString | Params: \n");
+ printVariant( varStringArray);
+ hr= oletest.Invoke1(static_cast<LPCOLESTR>(L"methodString"), &varStringArray, &varRet);
+ OutputDebugStringA("methodString | return value \n");
+ printVariant( varRet);
+
+ OutputDebugStringA("methodAny | Params: \n");
+ printVariant( varArray);
+ hr= oletest.Invoke1(static_cast<LPCOLESTR>(L"methodAny"), &varArray, &varRet);
+ OutputDebugStringA("methodAny | return value \n");
+ printVariant( varRet);
+
+ OutputDebugStringA("methodXInterface | Params: \n");
+ printVariant( varUnkArray);
+ hr= oletest.Invoke1(static_cast<LPCOLESTR>(L"methodXInterface"), &varUnkArray, &varRet);
+ OutputDebugStringA("methodAny | return value \n");
+ printVariant( varRet);
+
+ // Out Parameter ###########################################################################
+ OutputDebugString( _T("Out parameter ###########################################\n\n"));
+
+ OutputDebugString(_T("testout_methodByte \n"));
+ hr= oletest.InvokeN(static_cast<LPCOLESTR>(L"testout_methodByte"), &varOutByte, 1, &varRet);
+ OutputDebugString(_T("testout_methodByte | out value: \n"));
+ printVariant( varOutByte);
+
+ OutputDebugString(_T("testout_methodShort \n"));
+ hr= oletest.Invoke1(static_cast<LPCOLESTR>(L"testout_methodShort"), &varOutShort, &varRet);
+ OutputDebugString(_T("testout_methodShort | out value: \n"));
+ printVariant( varOutShort);
+
+ OutputDebugString(_T("testout_methodLong \n"));
+ hr= oletest.Invoke1(static_cast<LPCOLESTR>(L"testout_methodLong"), &varOutLong, &varRet);
+ OutputDebugString(_T("testout_methodLong | out value: \n"));
+ printVariant( varOutLong);
+
+ OutputDebugString(_T("testout_methodDouble \n"));
+ hr= oletest.Invoke1(static_cast<LPCOLESTR>(L"testout_methodDouble"), &varOutDouble, &varRet);
+ OutputDebugString(_T("testout_methodDouble | out value: \n"));
+ printVariant( varOutDouble);
+
+ OutputDebugString(_T("testout_methodString \n"));
+ hr= oletest.Invoke1(static_cast<LPCOLESTR>(L"testout_methodString"), &varOutString, &varRet);
+ OutputDebugString(_T("testout_methodString | out value: \n"));
+ printVariant( varOutString);
+
+ OutputDebugString(_T("testout_methodAny \n"));
+ hr= oletest.Invoke1(static_cast<LPCOLESTR>(L"testout_methodAny"), &varOutAny, &varRet);
+ OutputDebugString(_T("methodAny | out value: \n"));
+ printVariant( varOutAny);
+
+ OutputDebugString(_T("testout_methodXInterface \n"));
+ hr= oletest.Invoke1(static_cast<LPCOLESTR>(L"testout_methodXInterface"), &varOutXInterface, &varRet);
+ OutputDebugString(_T("methodAny | out value: \n"));
+ printVariant( varOutXInterface);
+ CComDispatchDriver outDisp( *varOutXInterface.ppdispVal);
+ CComVariant varAttr3;
+ outDisp.GetPropertyByName(L"AttrAny2", &varAttr3);
+ ATLTRACE("property OleTest.AttrAny2: %s", W2T(varAttr3.bstrVal));
+
+ OutputDebugString(_T("testout_methodMulParams1 ( 2 out Parameter) \n"));
+ long longOut2=0;
+ CComVariant _params[2];
+ longOut=0;
+ _params[0]= varOutLong;
+ _params[1].vt= VT_BYREF | VT_I4;
+ V_I4REF(& _params[1])= &longOut2;
+ hr= oletest.InvokeN( static_cast<LPCOLESTR>(L"testout_methodMulParams1"), (VARIANT*)&_params, 2);
+ OutputDebugString(_T("testout_methodMulParams1 | out values: \n"));
+ printVariant( _params[1]);
+ printVariant( _params[0]);
+
+ OutputDebugString(_T("testout_methodMulParams2 ( 3 out Parameter) \n"));
+ CComVariant _params2[3];
+ _params2[2]= varOutLong;
+ _params2[1].vt= VT_BYREF | VT_I4;
+ V_I4REF(& _params2[1])= &longOut2;
+ _params2[0]= varOutString;
+ hr= oletest.InvokeN( static_cast<LPCOLESTR>( L"testout_methodMulParams2"), (VARIANT*)&_params2, 3);
+ OutputDebugString(_T("testout_methodMulParams2 | out values: \n"));
+ printVariant( _params2[2]);
+ printVariant( _params2[1]);
+ printVariant( _params2[0]);
+
+ OutputDebugString(_T("testout_methodMulParams3 ( 1 in and 1 out Parameter) \n"));
+ CComVariant _params3[2];
+ _params3[1]= CComBSTR(L" In string");
+ _params3[0]= varOutString;
+ hr= oletest.InvokeN( static_cast<LPCOLESTR>( L"testout_methodMulParams3"), (VARIANT*)&_params3, 2);
+ OutputDebugString(_T("testout_methodMulParams3 | out values: \n"));
+ printVariant( _params3[1]);
+ printVariant( _params3[0]);
+
+ //In Out Parameter ###########################################################################
+ OutputDebugString( _T("In Out parameter ###########################################\n\n"));
+
+ *V_I1REF(&varOutByte)= 5;
+ ATLTRACE(_T("testinout_methodByte | in value: %d \n"), *V_I1REF(&varOutByte));
+ hr= oletest.InvokeN(static_cast<LPCOLESTR>(L"testinout_methodByte"), &varOutByte, 1, &varRet);
+ OutputDebugString(_T("testinout_methodByte | out value: \n"));
+ printVariant( varOutByte);
+
+ OutputDebugString(_T("testinout_methodShort | in value= 1000 \n"));
+ *V_UI2REF(&varOutShort)= 1000;
+ hr= oletest.Invoke1(static_cast<LPCOLESTR>(L"testinout_methodShort"), &varOutShort, &varRet);
+ OutputDebugString(_T("testinout_methodShort | out value: \n"));
+ printVariant( varOutShort);
+
+ OutputDebugString(_T("testinout_methodLong | in value= 10000 \n"));
+ *V_UI4REF(&varOutLong)= 10000;
+ hr= oletest.Invoke1(static_cast<LPCOLESTR>(L"testinout_methodLong"), &varOutLong, &varRet);
+ OutputDebugString(_T("testinout_methodLong | out value: \n"));
+ printVariant( varOutLong);
+
+ *V_R8REF(&varOutDouble)= 3.14;
+ ATLTRACE(_T("testinou_methodDouble in value: %f \n"),*V_R8REF(&varOutDouble));
+ hr= oletest.Invoke1(static_cast<LPCOLESTR>(L"testinout_methodDouble"), &varOutDouble, &varRet);
+ OutputDebugString(_T("testinout_methodDouble | out value: \n"));
+ printVariant( varOutDouble);
+
+ SysFreeString( *V_BSTRREF(&varOutString));
+ *V_BSTRREF(&varOutString)= SysAllocString( L"this is a in string");
+ ATLTRACE(_T("testinout_methodString | value: %s \n"), W2T(*V_BSTRREF(&varOutString)));
+ hr= oletest.Invoke1(static_cast<LPCOLESTR>(L"testinout_methodString"), &varOutString, &varRet);
+ OutputDebugString(_T("testinout_methodString | out value: \n"));
+ printVariant( varOutString);
+
+ CComVariant var1(CComBSTR(L" this is a string in a VARIANT"));
+ CComVariant outVar1;
+ outVar1.vt= VT_BYREF | VT_VARIANT;
+ outVar1.pvarVal= &var1;
+ ATLTRACE(_T("testinout_methodAny | parameter: %s\n"), W2T(var1.bstrVal));
+ hr= oletest.Invoke1(static_cast<LPCOLESTR>(L"testinout_methodAny"), &varOutAny, &varRet);
+ OutputDebugString(_T("testinout_methodAny | out value: \n"));
+ printVariant( varOutAny);
+
+ CComPtr< IUnknown > objectIn = unk1;
+ CComVariant varOutIFace;
+ varOutIFace.vt= VT_BYREF | VT_UNKNOWN;
+ varOutIFace.ppunkVal= &objectIn.p;
+ (*varOutIFace.ppunkVal)->AddRef();
+ OutputDebugString(_T("testinout_methodXInterface | in value: \n"));
+ printVariant(varOutIFace);
+ hr= oletest.Invoke1(static_cast<LPCOLESTR>(L"testinout_methodXInterface"), &varOutIFace, &varRet);
+ OutputDebugString(_T("testinout_methodXInterface | out value: \n"));
+ printVariant( varOutIFace);
+
+ // Properties ######################################################################
+ OutputDebugString( _T(" Properties ###########################################\n\n"));
+
+ OutputDebugString(_T("set property \"AttrByte\" | value"));
+ //CComVariant propArByte;
+ //propArByte.vt= VT_ARRAY | VT_I1;
+ varParam1.parray= (SAFEARRAY*)arByte;
+ printVariant( varParam1);
+ hr= oletest.PutPropertyByName( static_cast<LPCOLESTR>(L"AttrByte"), &varParam1);
+ OutputDebugString(_T("get property \"AttrByte\" | value:"));
+ varRet.Clear();
+ hr= oletest.GetPropertyByName( static_cast<LPCOLESTR>(L"AttrByte"), &varRet);
+ printVariant( varRet);
+
+
+ return S_OK;
+
+
+}
+
+
+void printVariant( VARIANT & _var)
+{
+ HRESULT hr;
+ USES_CONVERSION;
+ CComVariant var;
+ hr= VariantCopyInd( &var, &_var);
+ if( var.vt & VT_ARRAY)
+ {
+ VARTYPE type= var.vt ^ VT_ARRAY;
+ SAFEARRAY * sarray= var.parray;
+ long lbound;
+ long ubound;
+ hr= SafeArrayGetLBound( sarray, 1, &lbound);
+ hr= SafeArrayGetUBound( sarray, 1, &ubound);
+ long count= ubound - lbound + 1;
+ char charValue;
+ BYTE byteValue;
+ short shortValue;
+ long longValue;
+ double doubleValue;
+ IUnknown* unkValue;
+ BSTR bstrValue;
+ OutputDebugString( _T("# Array \n"));
+ for( long i= 0; i < count; i++)
+ {
+// CComVariant variantValue;
+ TCHAR *buf[256];
+ wsprintf( (TCHAR*)buf, _T("%d : "), i);
+ OutputDebugString( (TCHAR*)buf);
+ VARIANT varTemp;
+ VariantInit( &varTemp);
+ VARIANT variantValue;
+ VariantInit( &variantValue);
+ switch( type)
+ {
+ case VT_UI1:
+ hr= SafeArrayGetElement( sarray, &i, &byteValue);
+ varTemp.vt= VT_UI1;
+ V_UI1( &varTemp)= byteValue;
+ printVariant( varTemp);
+ break;
+ case VT_I1:
+ hr= SafeArrayGetElement( sarray, &i, &charValue);
+ varTemp.vt= VT_I1;
+ V_I1( &varTemp)= charValue;
+ printVariant( varTemp);
+ break;
+ case VT_I2:
+ hr= SafeArrayGetElement( sarray, &i, &shortValue);
+ varTemp.vt= VT_I2;
+ V_I2( &varTemp)= shortValue;
+ printVariant( varTemp);
+ break;
+
+ case VT_UI2:
+ case VT_I4:
+ hr= SafeArrayGetElement( sarray, &i, &longValue);
+ varTemp.vt= VT_I4;
+ V_I4( &varTemp)= longValue;
+ printVariant( varTemp);
+ break;
+ case VT_R8:
+ hr= SafeArrayGetElement( sarray, &i, &doubleValue);
+ varTemp.vt= VT_R8;
+ V_R8( &varTemp)= doubleValue;
+ printVariant( varTemp);
+ break;
+ case VT_BSTR:
+ hr= SafeArrayGetElement( sarray, &i, &bstrValue);
+ varTemp.vt= VT_BSTR;
+ varTemp.bstrVal= bstrValue;
+ printVariant( varTemp);
+ break;
+ case VT_VARIANT:
+ hr= SafeArrayGetElement( sarray, &i, &varTemp);
+ printVariant( varTemp);
+ break;
+
+ case VT_UNKNOWN:
+ hr= SafeArrayGetElement( sarray, &i, &unkValue);
+ varTemp.vt= VT_UNKNOWN;
+ varTemp.punkVal= unkValue;
+ printVariant( varTemp);
+ break;
+ }
+
+ VariantClear( &varTemp);
+ VariantClear( &variantValue);
+ }
+
+ }
+ else
+ {
+ TCHAR buf[256];
+ switch (var.vt)
+ {
+ case VT_I1: wsprintf( (TCHAR*)buf, _T(" VT_I1: %d \n"), V_I1( &var) );
+ break;
+ case VT_UI1: wsprintf( (TCHAR*)buf, _T(" VT_UI1: %d \n"), V_I1( &var) );
+ break;
+
+ case VT_I2: wsprintf( (TCHAR*)buf, _T(" VT_I2: %d \n"), V_I2( &var) );
+ break;
+ case VT_I4: wsprintf( (TCHAR*)buf, _T(" VT_I4: %d \n"), V_I4( &var) );
+ break;
+ case VT_R8:
+ {
+
+// int decimal, sign;
+// char *buffer;
+// int precision = 14;
+// double source = 3.1415926535;
+
+// buffer = _ecvt( V_R8(&var), precision, &decimal, &sign );
+ sprintf( (TCHAR*)buf, _T(" VT_R8: %f \n"),V_R8( &var) );
+ break;
+ }
+ case VT_UNKNOWN:
+ // The object implement IFont
+ {
+ CComDispatchDriver disp( var.punkVal);
+ CComVariant ret;
+ hr= disp.GetPropertyByName( static_cast<LPCOLESTR>(L"Name"), &ret);
+ wsprintf( (TCHAR*)buf, _T(" VT_UNKNOWN: property \"Name\": %s \n"), W2T(ret.bstrVal));
+ break;
+ }
+ case VT_DISPATCH:
+ // The object implement IFont
+ {
+ CComDispatchDriver disp( var.punkVal);
+ CComVariant ret;
+ if( SUCCEEDED( hr= disp.GetPropertyByName( static_cast<LPCOLESTR>(L"Name"), &ret)))
+ wsprintf( (TCHAR*)buf, _T(" VT_DISPATCH: property \"Name\": %s \n"), W2T(ret.bstrVal));
+ else
+ wsprintf( (TCHAR*)buf, _T(" VT_DISPATCH \n"));
+
+ break;
+ }
+
+
+ case VT_BSTR:
+ {
+ TCHAR* str= W2T( var.bstrVal);
+ wsprintf( (TCHAR*)buf, _T(" VT_BSTR: %s \n"), str);
+ }
+ break;
+ default:
+ wsprintf( (TCHAR*)buf, _T("\n"));
+
+ }
+
+ OutputDebugString( (TCHAR*) buf);
+ }
+
+ return;
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/test/ole/OleConverterVar1/makefile.mk b/extensions/test/ole/OleConverterVar1/makefile.mk
new file mode 100644
index 000000000000..a36c342dbd72
--- /dev/null
+++ b/extensions/test/ole/OleConverterVar1/makefile.mk
@@ -0,0 +1,66 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ=..$/..$/..
+
+PRJNAME=extensions
+TARGET=convTest
+TARGETTYPE=CUI
+LIBTARGET=NO
+
+ENABLE_EXCEPTIONS=TRUE
+
+# --- Settings ---
+
+.INCLUDE : settings.mk
+
+# --- Files ---
+
+INCPRE+=-I$(ATL_INCLUDE)
+
+
+APP1TARGET= $(TARGET)
+APP1OBJS= $(OBJ)$/convTest.obj
+
+
+APP1STDLIBS= \
+ $(SALLIB) \
+ $(CPPUHELPERLIB) \
+ $(CPPULIB) \
+ $(USER32LIB) \
+ $(KERNEL32LIB) \
+ $(OLE32LIB) \
+ $(OLEAUT32LIB) \
+ $(UUIDLIB) \
+ $(COMDLG32LIB) \
+ $(COMPATH)$/atlmfc$/lib$/atls.lib \
+ $(ADVAPI32LIB)
+
+APP1DEF= $(MISC)\$(APP1TARGET).def
+
+# --- Targets ---
+.INCLUDE : target.mk
diff --git a/extensions/test/ole/OleConverterVar1/readme.txt b/extensions/test/ole/OleConverterVar1/readme.txt
new file mode 100644
index 000000000000..148bab04c147
--- /dev/null
+++ b/extensions/test/ole/OleConverterVar1/readme.txt
@@ -0,0 +1,10 @@
+Currently broken!!
+
+The program test the Service com.sun.star.bridge.OleBridgeSupplierVar1.
+While running in debug mode it writes infos to the debug - output.
+
+The executable needs a services.rdb present with the registered services
+com.sun.star.bridge.OleBridgeSupplierVar1, oletest.OleTest. The OleTest
+component resides in extensions/test/ole/cpnt. The build creates an
+oletest.rdb file that must be merged with the types.rdb and OleTest
+must be registered to the services.rdb.
diff --git a/extensions/test/ole/OleConverterVar1/smartarray.h b/extensions/test/ole/OleConverterVar1/smartarray.h
new file mode 100644
index 000000000000..f38c93d88cd2
--- /dev/null
+++ b/extensions/test/ole/OleConverterVar1/smartarray.h
@@ -0,0 +1,236 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef _SMARTARRAY_H
+#define _SMARTARRAY_H
+
+
+template< class sourceType>
+class SmartArray
+{
+ SAFEARRAY *m_array;
+public:
+
+ SmartArray( sourceType * parParams, int count, VARTYPE destVartype): m_array(NULL)
+ {
+ HRESULT hr= S_OK;
+ SAFEARRAYBOUND rgsabound[1];
+ rgsabound[0].cElements= count;
+ rgsabound[0].lLbound= 0;
+ m_array= SafeArrayCreate( destVartype, 1, rgsabound);
+ SafeArrayLock( m_array);
+
+ void* pData;
+ if( m_array && (SUCCEEDED( SafeArrayAccessData( m_array, (void**)&pData)) ) )
+ {
+
+ for( int i=0; i< count; i++)
+ {
+ CComVariant varSource( parParams[i]);
+ switch (destVartype)
+ {
+ case VT_I1:
+ {
+ char* p= (char*) pData;
+ if( SUCCEEDED( hr= varSource.ChangeType( destVartype)))
+ p[i]= V_I1( &varSource);
+ break;
+ }
+ case VT_I2:
+ {
+ short* p= (short*) pData;
+ if( SUCCEEDED( hr=varSource.ChangeType( destVartype)))
+ p[i]= V_I2( &varSource);
+ break;
+ }
+ case VT_UI2:
+ {
+ unsigned short* p= (unsigned short*) pData;
+ if( SUCCEEDED( hr=varSource.ChangeType( destVartype)))
+ p[i]= V_UI2( &varSource);
+ break;
+ }
+ case VT_I4:
+ {
+ long* p= (long*)pData;
+ if( SUCCEEDED( hr=varSource.ChangeType( destVartype)))
+ p[i]= V_I4( &varSource);
+ break;
+ }
+ case VT_UI4:
+ {
+ unsigned long* p= (unsigned long*)pData;
+ if( SUCCEEDED( hr=varSource.ChangeType( destVartype)))
+ p[i]= V_UI4( &varSource);
+ break;
+ }
+ case VT_R4:
+ {
+ float* p= (float*)pData;
+ if( SUCCEEDED( hr=varSource.ChangeType( destVartype)))
+ p[i]= V_R4( &varSource);
+ break;
+ }
+ case VT_R8:
+ {
+ double* p= (double*)pData;
+ if( SUCCEEDED( hr=varSource.ChangeType( destVartype)))
+ p[i]= V_R8( &varSource);
+ break;
+ }
+ case VT_BOOL:
+ {
+ VARIANT_BOOL* p= (VARIANT_BOOL*)pData;
+ if( SUCCEEDED( hr=varSource.ChangeType( destVartype)))
+ p[i]= V_BOOL( &varSource);
+ break;
+ }
+ case VT_BSTR:
+ {
+ BSTR* pBstr= ( BSTR*)pData;
+ if( SUCCEEDED( hr=varSource.ChangeType( destVartype)))
+ pBstr[i]= SysAllocString(V_BSTR( &varSource));
+ break;
+ }
+ case VT_VARIANT:
+ {
+ VARIANT *pVariant= (VARIANT*)pData;
+ hr= VariantCopy( &pVariant[i], &varSource); break;
+ }
+// case VT_UNKNOWN:
+// {
+// long* pUnk= (long*)pData;
+// pUnk[i]= reinterpret_cast<long>(parParams[i]);
+// ((IUnknown*)pUnk[i])->AddRef(); break;
+// }
+// case VT_DISPATCH:
+// {
+// long* pDisp= (long*)pData;
+// pDisp[i]= (long)parParams[i];
+// ((IDispatch*)pDisp[i])->AddRef(); break;
+// }
+ default:
+ hr= E_FAIL;
+ }
+ }
+ if( FAILED( hr))
+ {
+ SafeArrayDestroy( m_array);
+ m_array= NULL;
+ }
+ }
+ SafeArrayUnaccessData( m_array);
+ }
+ ~SmartArray(){
+ SafeArrayUnlock( m_array);
+ SafeArrayDestroy( m_array );
+ }
+
+ operator bool (){ return m_array == NULL ? false : true; }
+
+ operator SAFEARRAY* (){ return m_array;}
+
+};
+
+template<>
+class SmartArray<IUnknown*>
+{
+ SAFEARRAY *m_array;
+public:
+
+ SmartArray( sourceType * parParams, int count, VARTYPE destVartype);
+// {
+// ATLTRACE("SmartArray<IUnknown>");
+// HRESULT hr= S_OK;
+// SAFEARRAYBOUND rgsabound[1];
+// rgsabound[0].cElements= count;
+// rgsabound[0].lLbound= 0;
+// m_array= SafeArrayCreateVector( VT_UNKNOWN, 0, count);
+// SafeArrayLock( m_array);
+//
+// IUnknown* *pData;
+// if( m_array && (SUCCEEDED( SafeArrayAccessData( m_array, (void**)&pData)) ) )
+// {
+//
+// for( int i=0; i< count; i++)
+// {
+// CComVariant varSource( parParams[i]);
+// switch (destVartype)
+// {
+//
+// case VT_UNKNOWN:
+// {
+// pData[i]= parParams[i];
+// pData[i]->AddRef();
+// }
+// default:
+// hr= E_FAIL;
+// }
+// }
+// if( FAILED( hr))
+// {
+// SafeArrayDestroy( m_array);
+// m_array= NULL;
+// }
+// }
+// SafeArrayUnaccessData( m_array);
+// }
+ ~SmartArray(){
+ SafeArrayUnlock( m_array);
+ SafeArrayDestroy( m_array );
+ }
+
+ operator bool (){ return m_array == NULL ? false : true; }
+
+ operator SAFEARRAY* (){ return m_array;}
+
+};
+
+template <> SmartArray <IUnknown*>::SmartArray(sourceType * parParams, int count, VARTYPE destVartype):m_array(NULL)
+{
+ ATLTRACE("SmartArray<IUnknown>");
+ HRESULT hr= S_OK;
+ SAFEARRAYBOUND rgsabound[1];
+ rgsabound[0].cElements= count;
+ rgsabound[0].lLbound= 0;
+ m_array= SafeArrayCreateVector( VT_UNKNOWN, 0, count);
+ SafeArrayLock( m_array);
+
+ IUnknown* *pData;
+ if( m_array && (SUCCEEDED( SafeArrayAccessData( m_array, (void**)&pData)) ) )
+ {
+ for( int i=0; i< count; i++)
+ {
+ pData[i]= parParams[i];
+ pData[i]->AddRef();
+ }
+ }
+ SafeArrayUnaccessData( m_array);
+};
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/test/ole/OleTest.htm b/extensions/test/ole/OleTest.htm
new file mode 100644
index 000000000000..93d0fdc4ee52
--- /dev/null
+++ b/extensions/test/ole/OleTest.htm
@@ -0,0 +1,1063 @@
+<HTML>
+<HEAD>
+<META NAME="GENERATOR" Content="Microsoft Developer Studio">
+<META HTTP-EQUIV="Content-Type" content="text/html; charset=iso-8859-1">
+<TITLE>Document Title</TITLE>
+</HEAD>
+<BODY id=theBody>
+
+<script language="JScript">
+// XEventListener implementation in JScript --------------------------------------------------
+function XEventListener_Impl()
+{
+ this._environment= "JScript";
+ this._implementedInterfaces= new Array( "com.sun.star.lang.XEventListener");
+
+ //XEventListener
+ this.disposing= XEventListener_disposing;
+
+ this.bdisposingCalled= false;
+ this.bQuiet= true;
+ this.resetDisposing= XEventListener_resetDisposing;
+ this.disposingCalled= XEventListener_disposingCalled;
+}
+
+function XEventListener_disposing( source)
+{
+ if( !this.bQuiet)
+ alert("JScript Event Listener \n disposing is being called");
+ this.bdisposingCalled= true;
+}
+
+function XEventListener_resetDisposing()
+{
+ this.bdisposingCalled= false;
+}
+
+function XEventListener_disposingCalled()
+{
+ return this.bdisposingCalled;
+}
+
+//--------------------------------------------------------------------------------------------
+function callOleTest( id)
+{
+ var factory= new ActiveXObject("com.sun.star.ServiceManager");
+ var oletest= factory.createInstance("oletest.OleTest");
+// alert(oletest);
+
+ var arr= new Array( 1, 2, 3, 4, 0);
+ var arrDouble= new Array( 1.2345, 12.345, 123,45, 1234.5, 12345);
+ var arrBool= new Array( 1, 0, 2, 0, 3);
+ var arrChar= new Array( '1', 'A', "1", "A", ' ', 55, 56);
+ var arrString= new Array("hamburger","cheeseburger", "chicken nuggets", "chicken wings" , "pizza");
+ var arrAny= new Array( 100, 100.1235,"hallo");
+ var arrSeq= new Array( arr, arr, arr);
+ var arrSeq2= new Array( arrSeq, arrSeq, arrSeq)
+
+
+ var arrout1= new Array();
+ var arrout2= new Array();
+ var arrout3= new Array();
+
+ var ret, i;
+ var sfarray, sfarray1, sfarray2, sfarray3;
+ var arEventListener= new Array( new XEventListener_Impl(), new XEventListener_Impl(),
+ new XEventListener_Impl());
+ var arEventListener2= new Array( new XEventListener_Impl(), new XEventListener_Impl(),
+ new XEventListener_Impl());
+ var arArEventListener= new Array( arEventListener, arEventListener2);
+ switch( id)
+ {
+ // Array in-params
+ case 1: ret= oletest.methodByte( arr);
+ sfarray= new VBArray( ret);
+ document.writeln( "Param: " + arr.toString() + "<br>");
+ document.writeln( "Returns a Sequence&lt BYTE &gt <br>" + sfarray.toArray()) ; break;
+
+ case 2: ret= oletest.methodDouble( arrDouble);
+ sfarray= new VBArray( ret);
+ document.writeln( "Param: " + arrDouble.toString() +"<br>");
+ document.writeln( "Returns a Sequence&lt double &gt <br>" + sfarray.toArray()) ; break;
+
+ case 3: ret= oletest.methodBool( arrBool);
+ sfarray= new VBArray( ret);
+ document.writeln( "Param: " + arrBool.toString() +"<br>");
+ document.writeln( "Returns a Sequence&lt BOOL &gt <br>" + sfarray.toArray()) ; break;
+
+ case 4: ret= oletest.methodShort( arr);
+ sfarray= new VBArray( ret);
+ document.writeln( "Param: " + arr.toString() +"<br>");
+ document.writeln( "Returns a Sequence&lt SHORT &gt <br>" + sfarray.toArray()) ; break;
+
+ case 5: ret= oletest.methodUShort( arr);
+ sfarray= new VBArray( ret);
+ document.writeln( "Param: " + arr.toString() +"<br>");
+ document.writeln( "Returns a Sequence&lt unsigned SHORT &gt <br>" + sfarray.toArray()) ; break;
+
+ case 6: ret= oletest.methodLong( arr);
+ sfarray= new VBArray( ret);
+ document.writeln( "Param: " + arr.toString() +"<br>");
+ document.writeln( "Returns a Sequence&lt LONG &gt <br>" + sfarray.toArray()) ; break;
+
+ case 7: ret= oletest.methodULong( arr);
+ sfarray= new VBArray( ret);
+ document.writeln( "Param: " + arr.toString() +"<br>");
+ document.writeln( "Returns a Sequence&lt unsigned LONG &gt <br>" + sfarray.toArray()) ; break;
+
+ case 8: ret= oletest.methodChar( arrChar);
+ sfarray= new VBArray( ret);
+ document.writeln( "Param: " + arrChar.toString() +"<br>");
+ document.writeln( "Returns a Sequence&lt wchar_t &gt <br>" + sfarray.toArray()) ; break;
+
+ case 9: ret= oletest.methodString( arrString);
+ sfarray= new VBArray( ret);
+ document.writeln( "Param: " + arrString.toString() +"<br>");
+ document.writeln( "Returns a Sequence&lt UString &gt <br>" + sfarray.toArray()) ; break;
+
+ case 10: ret= oletest.methodAny( arrAny);
+ sfarray= new VBArray( ret);
+ document.writeln( "Param: " + arrAny.toString() +"<br>");
+ document.writeln( "Returns a Sequence&lt UsrAny &gt <br>" + sfarray.toArray() ) ; break;
+
+ case 11: ret= oletest.methodSequence( arrSeq);
+ sfarray= new VBArray( ret);
+ document.writeln( "Param: " + arrSeq.toString() +"<br>");
+ document.writeln("Returns a Sequence&lt Sequence &lt long &gt&gt <br>") ;
+ var arr1= new Array();
+ arr1= sfarray.toArray();
+ for( i=0; i < arr1.length; i++)
+ {
+ sfarray2= new VBArray( arr1[i]);
+ var arr2= new Array();
+ arr2= sfarray2.toArray();
+ document.writeln( arr2.toString() + "<br>" );
+ }
+ break;
+
+ case 12: ret= oletest.methodSequence2( arrSeq2);
+ document.writeln( "Param: " + arrSeq2.toString() +"<br>");
+ sfarray1= new VBArray( ret);
+ arr1= sfarray1.toArray();
+ for( i=0; i < arr1.length; i++)
+ {
+ sfarray2= new VBArray( arr1[i]);
+ arr2= sfarray2.toArray();
+
+ for ( j=0; j < arr2.length; j++)
+ {
+ sfarray3= new VBArray( arr2[j]);
+ arr3= sfarray3.toArray();
+ document.write( i+ " ");
+ document.writeln(j + ": "+ arr3.toString() + "<br>" );
+ }
+
+ }
+ break;
+
+ case 13:
+ var ar= new Array();
+ for( i=0; i< 3; i++)
+ {
+ var ob= new Object();
+ ob.value= "A JScript object!";
+ ar[i]= ob;
+ }
+
+ ret = oletest.methodXInterface( ar);
+ sfarray= new VBArray( ret);
+ var arRet= sfarray.toArray();
+
+ document.writeln( "Params : Array containing objects ")
+ for( index in ar)
+ {
+ document.writeln( "object " + index + ": " + ar[index].value +" ");
+ }
+ document.writeln( "<br>" ) ;
+ document.writeln("Return: <br>");
+ for( index in arRet)
+ {
+ document.writeln( "object " + index + ": " + arRet[index].value + " ");
+ }
+ break;
+
+ case 14: ret= oletest.methodFloat( arrDouble);
+ sfarray= new VBArray( ret);
+ document.writeln( "Param: " + arrDouble.toString() +"<br>");
+ document.writeln( "Returns a Sequence&lt float&gt <br>" + sfarray.toArray()) ; break;
+
+ case 15:
+ ret= oletest.methodXEventListeners( arEventListener);
+ sfarray= new VBArray(ret);
+ _ret= sfarray.toArray();
+ for ( key in _ret)
+ {
+ if( ! _ret[key].disposingCalled())
+ alert("Error! oletest.methodXEventListeners")
+ }
+ break;
+ case 16:
+ ret= oletest.methodXEventListenersMul( arArEventListener);
+ sfarray= new VBArray(ret);
+ _ret= sfarray.toArray();
+ for( key in _ret)
+ {
+ sfarray2= new VBArray(_ret[key]);
+ _ret2= sfarray2.toArray();
+ for( key2 in _ret2)
+ {
+ if( ! _ret2[key2].disposingCalled())
+ alert("Error! oletest.methodXEventListeners")
+ }
+ }
+ break;
+
+
+
+ // Properties: setting and getting values
+ case 200: oletest.AttrByte = arr;
+ ret= oletest.AttrByte;
+ document.writeln("Setting AttrByte: " + arr.toString() + "<p>");
+ document.writeln("Getting AttrByte: " + arr.toString()); break;
+
+ case 201: oletest.AttrDouble= arrDouble;
+ ret= oletest.AttrDouble;
+ document.writeln("Setting AttrDouble: " + arrDouble.toString() + "<p>");
+ document.writeln("Getting AttrDouble: " + arrDouble.toString()); break;
+
+ case 202: oletest.AttrBool= arrBool;
+ ret= oletest.AttrBool;
+ document.writeln("Setting AttrBool: " + arrBool.toString() + "<p>");
+ document.writeln("Getting AttrBool: " + arrBool.toString()); break;
+
+ case 203: oletest.AttrShort= arr;
+ ret= oletest.AttrShort;
+ document.writeln("Setting AttrShort: " + arr.toString() + "<p>");
+ document.writeln("Getting AttrShort: " + arr.toString()); break;
+
+ case 204: oletest.AttrUShort= arr;
+ ret= oletest.AttrUShort;
+ document.writeln("Setting AttrUShort: " + arr.toString() + "<p>");
+ document.writeln("Getting AttrUShort: " + arr.toString()); break;
+
+ case 205: oletest.AttrLong= arr;
+ ret= oletest.AttrLong;
+ document.writeln("Setting AttrLong: " + arr.toString() + "<p>");
+ document.writeln("Getting AttrLong: " + arr.toString()); break;
+
+ case 206: oletest.AttrULong= arr;
+ ret= oletest.AttrULong;
+ document.writeln("Setting AttrULong: " + arr.toString() + "<p>");
+ document.writeln("Getting AttrULong: " + arr.toString()); break;
+
+ case 207: oletest.AttrChar= arrChar;
+ ret= oletest.AttrChar;
+ document.writeln("Setting AttrChar: " + arrChar.toString() + "<p>");
+ document.writeln("Getting AttrChar: " + arrChar.toString()); break;
+
+ case 208: oletest.AttrString= arrString;
+ ret= oletest.AttrString;
+ document.writeln("Setting AttrString: " + arrString.toString() + "<p>");
+ document.writeln("Getting AttrString: " + arrString.toString()); break;
+
+ case 209: oletest.AttrAny= arrAny;
+ ret= oletest.AttrAny;
+ document.writeln("Setting AttrAny: " + arrAny.toString() + "<p>");
+ document.writeln("Getting AttrAny: " + arrAny.toString()); break;
+
+ case 210: oletest.AttrSequence= arrSeq;
+ ret= oletest.AttrSequence;
+ document.writeln("Setting AttrSequence: " + arrSeq.toString() + "<p>");
+ document.writeln("Getting AttrSequence: " + arrSeq.toString()); break;
+
+ case 211: oletest.AttrSequence2= arrSeq2;
+ ret= oletest.AttrSequence2;
+ document.writeln("Setting AttrSequence2: " + arrSeq2.toString() + "<p>");
+ document.writeln("Getting AttrSequence2: " + arrSeq2.toString()); break;
+
+ case 212: oletest.AttrFloat= arrDouble;
+ ret= oletest.AttrFloat;
+ document.writeln("Setting AttrFloat: " + arrDouble.toString() + "<p>");
+ document.writeln("Getting AttrFloat: " + arrDouble.toString()); break;
+
+
+
+ // Out-parameter ------------------------------------------------------------
+ case (2000):
+ oletest.testout_methodByte( arrout1 );
+ alert("byte: " + arrout1[0] ); break;
+ case (2001):
+ oletest.testout_methodDouble( arrout1 );
+ alert( "double: " + arrout1[0] ); break;
+ case (2002):
+ oletest.testout_methodBool( arrout1 );
+ alert( "boolean: " + arrout1[0] ); break;
+ case (2003):
+ oletest.testout_methodShort( arrout1 );
+ alert( "short: " + arrout1[0] ); break;
+ case (2004):
+ oletest.testout_methodUShort( arrout1 );
+ alert( "unsigned short: " + arrout1[0] ); break;
+ case (2005):
+ oletest.testout_methodLong( arrout1 );
+ alert( "long: " + arrout1[0] ); break;
+ case (2006):
+ oletest.testout_methodULong( arrout1 );
+ alert( "unsigned long: " + arrout1[0] ); break;
+ case (2007):
+ oletest.testout_methodChar( arrout1 );
+ alert( "char: " + arrout1[0] ); break;
+ case (2008):
+ oletest.testout_methodString( arrout1 );
+ alert( "string: " + arrout1[0] ); break;
+ case (2009):
+ oletest.testout_methodAny( arrout1 );
+ alert( "any: " + arrout1[0] ); break;
+ case (2010):
+ oletest.testout_methodSequence( arrout1 );
+ var sfarray= new VBArray( arrout1[0]);
+ arr= sfarray.toArray();
+ document.writeln("use the browser's back arrow to go to the previous page <p>");
+ document.writeln( arr.toString());
+ break;
+ case (2011):
+ oletest.testout_methodSequence2( arrout1 );
+ var sfarray= new VBArray( arrout1[0]);
+ arr= sfarray.toArray();
+ var i;
+ for( i=0; i < arr.length; i++)
+ {
+ var sfarray= new VBArray( arr[i]);
+ var arr2= new Array();
+ arr2= sfarray.toArray();
+ document.writeln( arr2.toString() + "<br>" );
+ }
+ break;
+ case (2012):
+ oletest.testout_methodMulParams1( arrout1, arrout2 );
+ document.writeln( "int : " + arrout1[0] + " int :" + arrout2[0] ); break;
+ case (2013):
+ oletest.testout_methodMulParams2( arrout1, arrout2, arrout3 );
+ document.writeln( "int: " + arrout1[0] + " int: " + arrout2[0] + " string: " + arrout3[0] ); break;
+ case (2014):
+ oletest.testout_methodMulParams3( "hallo", arrout1 );
+ document.writeln( "string: " + arrout1[0] ); break;
+ case (2015):
+ oletest.testout_methodXInterface( arrout1 );
+ var outVal= arrout1[0];
+ alert( outVal.AttrAny2);
+ document.writeln( "string: " + arrout1[0].AttrAny2); break;
+ case (2016):
+ oletest.testout_methodFloat( arrout1 );
+ alert( "float: " + arrout1[0] ); break;
+ case (2017):
+ var in1= 3.14;
+ var in2= 1111;
+ var in3= -2222;
+ oletest.testout_methodMulParams4( in1, arrout1, in2, arrout2, in3 );
+ document.write("param1 [in] float: " + in1 + " param2 [out] float: " + arrout1[0] +
+ " param3 [in] long: " + in2 + " param4 [out] long: " + arrout2[0] +
+ " param5 [in] long: " + in3);
+ break;
+
+
+ // INOUT - Parameter -------------------------------------------------------------------------------
+ // The in value has to be placed on index 0 of the passed in array
+ case (500):
+ arrout1[0]= 100;
+ oletest.testinout_methodByte( arrout1 );
+ alert("byte: " + arrout1[0] ); break;
+ case (501):
+ arrout1[0]= 3.14;
+ oletest.testinout_methodDouble( arrout1 );
+ alert( "double: " + arrout1[0] ); break;
+ case (502):
+ arrout1[0]= false;
+ oletest.testinout_methodBool( arrout1 );
+ alert( "boolean: " + arrout1[0] ); break;
+ case (503):
+ arrout1[0]= 200;
+ oletest.testinout_methodShort( arrout1 );
+ alert( "short: " + arrout1[0] ); break;
+ case (504):
+ arrout1[0]= 300;
+ oletest.testinout_methodUShort( arrout1 );
+ alert( "unsigned short: " + arrout1[0] ); break;
+ case (505):
+ arrout1[0]= 400;
+ oletest.testinout_methodLong( arrout1 );
+ alert( "long: " + arrout1[0] ); break;
+ case (506):
+ arrout1[0]= 500;
+ oletest.testinout_methodULong( arrout1 );
+ alert( "unsigned long: " + arrout1[0] ); break;
+ case (507):
+ arrout1[0]= "A";
+ oletest.testinout_methodChar( arrout1 );
+ alert( "char: " + arrout1[0] ); break;
+ case (508):
+ arrout1[0]= "I am a string";
+ oletest.testinout_methodString( arrout1 );
+ alert( "string: " + arrout1[0] ); break;
+ case (509):
+ arrout1[0]= arr;
+ oletest.testinout_methodAny( arrout1 ); // the method simply returns the argument
+ sfarray= new VBArray( arrout1[0]);
+ arr= sfarray.toArray();
+ alert( "any: " + arr.toString() ); break;
+ case (510):
+ arrout1[0]= arr;
+ oletest.testinout_methodSequence( arrout1 );
+ var sfarray= new VBArray( arrout1[0]);
+ arr= sfarray.toArray();
+ document.writeln("use the browser's back arrow to go to the previous page <p>");
+ document.writeln( arr.toString());
+ break;
+ case (511):
+ arrout1[0]= arrSeq;
+ oletest.testinout_methodSequence2( arrout1 );
+ var sfarray= new VBArray( arrout1[0]);
+ arr= sfarray.toArray();
+ var i;
+ for( i=0; i < arr.length; i++)
+ {
+ var sfarray= new VBArray( arr[i]);
+ var arr2= new Array();
+ arr2= sfarray.toArray();
+ document.writeln( arr2.toString() + "<br>" );
+ }
+ break;
+ case 512:
+ var ob= new Object();
+ ob.value= "this is a string";
+
+ arrout1[0]= ob;
+ alert (arrout1[0].value);
+ oletest.testinout_methodXInterface( arrout1);
+ alert (arrout1[0].value);
+ var outValue= arrout1[0];
+ for ( key in outValue)
+ {
+ document.write( outValue[key] );
+ }
+ document.write("Out value: " + outValue );
+ document.write("Out 1 value: " + arrout1[1]);
+ break;
+
+// var ob= new Object();
+// ob.value= "this is a string";
+// inoutValue.Set( "object", ob);
+// oletest.testinout_methodXInterface( inoutValue);
+// document.write("Out value: " + inoutValue.Get().value );
+// break;
+
+ case (513):
+ arrout1[0]= 3.14;
+ oletest.testinout_methodFloat( arrout1 );
+ alert( "float: " + arrout1[0] ); break;
+
+
+
+ // Test ANY
+ // Methods
+ case 1000:
+ i= 100;
+ ret= oletest.methodAnyTest1( i);
+ document.writeln( "in: " + i + " ret: " + ret);
+ break;
+ case 1001:
+ i= 3.14;
+ ret= oletest.methodAnyTest1( i);
+ document.writeln( "in: " + i + " ret: " + ret);
+ break;
+ case 1002:
+ i= "Hallo"
+ ret= oletest.methodAnyTest1( i);
+ document.writeln( "in: " + i + " ret: " + ret);
+ break;
+ case 1003:
+ i= arr;
+ ret= oletest.methodAnyTest1( i);
+ sfarray= new VBArray( ret);
+ document.writeln( "in: " + i + " ret: " + sfarray.toArray());
+ break;
+ case 1004:
+ var obj= new Object();
+ obj[1]= "This is index 0";
+ ret= oletest.methodAnyTest1( obj);
+ document.writeln( "in: " + obj + " ret: " + ret);
+ break;
+
+
+ // Test ANY property
+ case 1010:
+ i= 100;
+ oletest.AttrAny2= i;
+ ret= oletest.AttrAny2;
+ document.writeln( "set: " + i + " get: " + ret);
+ break;
+ case 1011:
+ i= 3.14;
+ oletest.AttrAny2= i;
+ ret= oletest.AttrAny2;
+ document.writeln( "set: " + i + " get: " + ret);
+ break;
+ case 1012:
+ i= "Hallo"
+ oletest.AttrAny2= i;
+ ret= oletest.AttrAny2;
+ document.writeln( "set: " + i + " get: " + ret);
+ break;
+ case 1013:
+ i= arr;
+ oletest.AttrAny2= i;
+ ret= oletest.AttrAny2;
+ sfarray= new VBArray( ret);
+ document.writeln( "set: " + i + " get: " + sfarray.toArray());
+ break;
+ case 1014:
+ var obj= new Object();
+ obj[1]= "This is index 0";
+ oletest.AttrAny2= obj;
+ ret= oletest.AttrAny2;
+ document.writeln( "set: " + obj + " get: " + ret);
+ break;
+
+ // Structs ----------------------------------------------
+ case 1020:
+ var struct= oletest._GetStruct("com.sun.star.beans.Property");
+ struct.Attributes= 1;
+ struct.Handle= 2;
+ struct.Name= "some Property"
+ oletest.methodStruct( struct);
+ break;
+ case 1021:
+ var struct= oletest.retMethodStruct();
+ alert( "Property::Attributes : " + struct.Attributes + " \nProperty::Handle : "
+ + struct.Handle + "\n Property::Name : " + struct.Name);
+ break;
+ case 1022:
+ var struct= oletest._GetStruct("com.sun.star.beans.Property");
+ struct.Attributes= 1;
+ struct.Handle= 2;
+ struct.Name= "some Property"
+ oletest.AttrStruct= struct;
+
+ var struct2= oletest.AttrStruct;
+ alert( "property get: \n Property::Attributes : " + struct2.Attributes + " \nProperty::Handle : "
+ + struct2.Handle + "\n Property::Name : " + struct2.Name);
+ break;
+
+ case 2100:
+ alert("2100");
+ var ret= oletest.retMethodByte();
+ var sfarray= VBArray( ret);
+ document.writeln( sfarray.toArray() );
+ break;
+
+
+
+ }
+
+}
+
+function funcOut( out)
+{
+ out["du"]= 0xffff;
+}
+
+</script>
+
+<script language="VBScript">
+
+sub callBasic(id)
+
+ Dim factory
+ Set factory= GetObject("", "com.sun.star.ServiceManager")
+
+ Set oletest= factory.createInstance("oletest.OleTest")
+
+
+ arrInt= Array(1,2,3,4,5)
+ arrInt2= Array( -1, -2, 127, 128, 0)
+ arrDouble= Array(1.1, 2.2, 3.3, 4.4, 5.5)
+ arrBool= Array(0,1,0,2,0)
+ arrLong= Array( &Hff, &Hffff, &Hffffff, &Hffffffff)
+ arrString= Array("Chicken Wings", "Cheeseburger", "Hamburger")
+ arrChar= Array("a",65, "M")
+ arrAny= Array("Mickey", 3.14, 100, "A")
+
+ Dim arrDim2Int(1,1)
+ For i= 0 To 1
+ For j= 0 To 1
+ arrDim2Int(i,j) = i*2 + j
+ Next
+ Next
+
+ Dim arrDim3Int(1,1,1)
+ For i= 0 To 1
+ For j= 0 To 1
+ For k=0 To 1
+ arrDim3Int(i,j,k) = i*2 + j*2 + k
+ Next
+ Next
+ Next
+
+
+ select case id
+ case 0
+ document.writeln "param: "
+ printArray arrInt
+ ret= oletest.methodByte(arrInt)
+ document.writeln "<br> return value: "
+ printArray ret
+ case 1
+ document.writeln "param: "
+ printArray arrDouble
+ ret= oletest.methodDouble(arrDouble)
+ document.writeln "<br> return value: "
+ printArray ret
+ case 2
+ document.writeln "param: "
+ printArray arrBool
+ ret= oletest.methodBool(arrBool)
+ document.writeln "<br> return value: "
+ printArray ret
+ case 3
+ document.writeln "param: "
+ printArray arrInt2
+ ret= oletest.methodShort(arrInt2)
+ document.writeln "<br> return value: "
+ printArray ret
+ case 4
+ document.writeln "param: "
+ printArray arrInt
+ ret= oletest.methodUShort(arrInt)
+ document.writeln "<br> return value: "
+ printArray ret
+ case 5
+ document.writeln "param: "
+ printArray arrLong
+ ret= oletest.methodLong(arrLong)
+ document.writeln "<br> return value: "
+ printArray ret
+ case 6
+ document.writeln "param: "
+ printArray arrInt
+ ret= oletest.methodULong(arrInt)
+ document.writeln "<br> return value: "
+ printArray ret
+ case 7
+ document.writeln "param: "
+ printArray arrString
+ ret= oletest.methodString(arrString)
+ document.writeln "<br> return value: "
+ printArray ret
+ case 8
+ document.writeln "param: "
+ printArray arrChar
+ ret= oletest.methodChar(arrChar)
+ document.writeln "<br> return value: "
+ printArray ret
+ case 9
+ document.writeln "param: "
+ printArray arrAny
+ ret= oletest.methodAny(arrAny)
+ document.writeln "<br> return value: "
+ printArray ret
+ case 10
+ document.writeln "param: "
+ printArray2 arrDim2Int
+ ret= oletest.methodSequence(arrDim2Int)
+ document.writeln "<br> return value: "
+ for each val in ret
+ document.write "<br> array: "
+ for each val2 in val
+ document.write val2
+ next
+ next
+
+ // Out Parameter
+ case 150
+ dim rOut
+ oletest.testout_methodByte rOut
+ MsgBox rOut
+// void testout_methodFloat( [out] float rOut);
+// void testout_methodDouble( [out] double rOut);
+// void testout_methodBool( [out] boolean rOut);
+// void testout_methodShort( [out] short rOut);
+// void testout_methodUShort( [out] unsigned short rOut);
+// void testout_methodLong( [out] long rOut);
+// void testout_methodULong( [out] unsigned long rOut);
+
+
+ // In Out Parameter --------------------------------------------------
+ case 100
+ a= 100
+ document.write "param: " & CStr( a) & "<br>"
+ oletest.testinout_methodByte a
+ document.write a
+ case 101
+ a= 1.11
+ document.write "param: " & CStr( a) & "<br>"
+ oletest.testinout_methodDouble a
+ document.write a
+ case 102
+ a= 5
+ document.write "param: "& CStr( a) & "<br>"
+ oletest.testinout_methodBool a
+ document.write a
+ case 103
+ a= -10
+ document.write "param: "& CStr( a) & "<br>"
+ oletest.testinout_methodShort a
+ document.write a
+ case 104
+ a= 128
+ document.write "param: "& CStr( a) & "<br>"
+ oletest.testinout_methodUShort a
+ document.write a
+ case 105
+ a= 65556
+ document.write "param: "& CStr( a) & "<br>"
+ oletest.testinout_methodLong a
+ document.write a
+ case 106
+ a= 65556
+ document.write "param: "& CStr( a) & "<br>"
+ oletest.testinout_methodULong a
+ document.write a
+ case 107
+ a= "ein test string"
+ document.write "param: "& CStr( a) & "<br>"
+ oletest.testinout_methodString a
+ document.write a
+ case 108
+ a= "W"
+ document.write "param: "& CStr( a) & "<br>"
+ oletest.testinout_methodChar a
+ document.write a
+ case 109
+ a= "Ein String im Any"
+ document.write "param: "& CStr( a) & "<br>"
+ oletest.other_methodAnyIn a
+ document.write a
+
+ case 150
+ dim a
+ document.write "param: "& CStr( a) & "<br>"
+ oletest.testout_methodByte( a)
+ document.write a
+// Attributes -----------------------------------------------------------------
+ case 200
+ document.write "set: "
+ printArray arrInt
+ oletest.AttrByte= arrInt
+ b= oletest.AttrByte
+ call printArrayEx( "<br> get: ", "<br>", b)
+ case 201
+ document.write "set: "
+ printArray arrDouble
+ oletest.AttrDouble= arrDouble
+ b= oletest.AttrDouble
+ call printArrayEx( "<br> get: ", "<br>", b)
+ case 202
+ document.write "set: "
+ printArray arrBool :
+ oletest.AttrBool= arrBool
+ b= oletest.AttrBool
+ call printArrayEx( "<br> get: ", "<br>", b)
+ case 203
+ document.write "set: "
+ printArray arrInt2 :
+ oletest.AttrShort= arrInt2
+ b= oletest.AttrShort
+ call printArrayEx( "<br> get: ", "<br>", b)
+ case 204
+ document.write "set: "
+ printArray arrInt
+ oletest.AttrUShort= arrInt
+ b= oletest.AttrUShort
+ call printArrayEx( "<br> get: ", "<br>", b)
+ case 205
+ document.write "set: "
+ printArray arrInt2
+ oletest.AttrLong= arrInt2
+ b= oletest.AttrLong
+ call printArrayEx( "<br> get: ", "<br>", b)
+ case 206
+ document.write "set: "
+ printArray arrInt
+ oletest.AttrULong= arrInt
+ b= oletest.AttrULong
+ call printArrayEx( "<br> get: ", "<br>", b)
+ case 207
+ document.write "set: "
+ printArray arrString
+ oletest.AttrString= arrString
+ b= oletest.AttrString
+ call printArrayEx( "<br> get: ", "<br>", b)
+ case 208
+ document.write "set: "
+ printArray arrChar
+ oletest.AttrChar= arrChar
+ b= oletest.AttrChar
+ call printArrayEx( "<br> get: ", "<br>", b)
+ case 209
+ document.write "set: "
+ printArray arrAny
+ oletest.AttrAny= arrAny
+ b= oletest.AttrAny
+ call printArrayEx( "<br> get: ", "<br>", b)
+
+ case 210
+ document.write "set: <br>"
+ printArray2 arrDim2Int :
+ oletest.AttrSequence= arrDim2Int
+ ret= oletest.AttrSequence
+ document.write "get: "
+ for each val in ret
+ document.write "<br> array: "
+ for each val2 in val
+ document.write val2
+ next
+ next
+
+ case 300
+ dim aByte
+ aByte= 100
+ call oletest.testinout_methodByte( aByte)
+ MsgBox aByte
+
+
+ case 400
+
+ set struct= oletest.Bridge_GetStruct("com.sun.star.beans.Property")
+ struct.Attributes= 1
+ struct.Handle= 2
+ struct.Name= "some Property"
+ oletest.methodStruct struct
+
+ case 401
+ set struct= oletest.retMethodStruct()
+ alert( "Property::Attributes : " & struct.Attributes & vblf & " Property::Handle : " _
+ & struct.Handle & vblf & " Property::Name : " & struct.Name)
+
+ case 402
+ set struct= oletest.Bridge_GetStruct("com.sun.star.beans.Property")
+ struct.Attributes= 1
+ struct.Handle= 2
+ struct.Name= "some Property"
+ oletest.AttrStruct= struct
+
+ set struct2= oletest.AttrStruct
+ alert( "property get: " & vblf & "Property::Attributes : " & struct2.Attributes & _
+ vblf & " Property::Handle : " & struct2.Handle & vblf & " Property::Name : " _
+ & struct2.Name)
+ end select
+end sub
+
+sub printArray( arr)
+ document.write "array: "
+ For Each val In arr
+ document.write CStr(val) & " "
+ Next
+end sub
+
+// print a 2 dimensional Array
+
+sub printArray2( arr)
+ elements1= UBound( arr, 1) - LBound( arr, 1) +1
+ elements2= UBound( arr, 2) - LBound( arr, 2) +1
+
+ For i=0 To elements1 -1
+ document.write( "array " & CStr( i) & ": " )
+ For j=0 To elements2 -1
+ document.write CStr( arr(i,j))
+ Next
+ document.write( "<br>")
+ Next
+end sub
+
+sub printArrayEx( pre, post, array)
+ document.write pre
+ printArray array
+ document.write post
+end sub
+</script>
+
+<div id=out> </div>
+
+<!-- Insert HTML here -->
+
+<h2> JScript </h2>
+Tests Array/Sequence conversion.<br>
+All methods receive a Sequence as Parameter. The element type of the Sequence is written on the buttons.
+<br>
+<button onclick='callOleTest( 1)'>byte</Button>
+<button onclick='callOleTest( 14)'>float</Button>
+<button onclick='callOleTest( 2)'>double</Button>
+<button onclick='callOleTest( 3)'>boolean</Button>
+<button onclick='callOleTest( 4)'>short</Button>
+<button onclick='callOleTest( 5)'>unsigned short</Button>
+<button onclick='callOleTest( 6)'>long</Button>
+<button onclick='callOleTest( 7)'>unsigned long</Button>
+<button onclick='callOleTest( 8)'>char</Button>
+<button onclick='callOleTest( 9)'>string</Button>
+<button onclick='callOleTest( 10)'>any</Button>
+<button onclick='callOleTest( 11)'>sequence&lt;long&gt; </Button>
+<button onclick='callOleTest( 12)'>sequence&lt;sequence&lt;long&gt; &gt; </Button>
+<button onclick='callOleTest( 13)' id=button2 name=button2>XInterface</Button>
+<button onclick='callOleTest( 15)'>XEventListener</Button>
+<button onclick='callOleTest( 16)'>sequence&lt;XEventListener&gt;</Button>
+<p>
+
+<p>
+Out Parameter <br>
+<button onclick='callOleTest( 2000)'>byte </Button>
+<button onclick='callOleTest( 2016)'>float</Button>
+<button onclick='callOleTest( 2001)'>double</Button>
+<button onclick='callOleTest( 2002)'>boolean</Button>
+<button onclick='callOleTest( 2003)'>short</Button>
+<button onclick='callOleTest( 2004)'>unsigned short</Button>
+<button onclick='callOleTest( 2005)'>long</Button>
+<button onclick='callOleTest( 2006)'>unsigned long</Button>
+<button onclick='callOleTest( 2007)'>char</Button>
+<button onclick='callOleTest( 2008)'>string</Button>
+<button onclick='callOleTest( 2009)'>any</Button>
+<button onclick='callOleTest( 2010)'>sequence&ltlong&gt </Button>
+<button onclick='callOleTest( 2011)'>sequence&ltsequence&ltlong&gt &gt </Button>
+<button onclick='callOleTest( 2012)'>2 out </Button>
+<button onclick='callOleTest( 2013)'>3 out </Button>
+<button onclick='callOleTest( 2014)'>1 in & 1 out </Button>
+<button onclick='callOleTest( 2015)'>XInterface </Button>
+<button onclick='callOleTest( 2017)'>mixed out and in </Button>
+
+
+<p>
+In Out Parameter <br>
+<button onclick='callOleTest( 500)'>byte </Button>
+<button onclick='callOleTest( 513)'>float</Button>
+<button onclick='callOleTest( 501)'>double</Button>
+<button onclick='callOleTest( 502)'>boolean</Button>
+<button onclick='callOleTest( 503)'>short</Button>
+<button onclick='callOleTest( 504)'>unsigned short</Button>
+<button onclick='callOleTest( 505)'>long</Button>
+<button onclick='callOleTest( 506)'>unsigned long</Button>
+<button onclick='callOleTest( 507)'>char</Button>
+<button onclick='callOleTest( 508)'>string</Button>
+<button onclick='callOleTest( 509)'>any</Button>
+<button onclick='callOleTest( 510)'>sequence&ltlong&gt </Button>
+<button onclick='callOleTest( 511)'>sequence&ltsequence&ltlong&gt &gt </Button>
+<button onclick='callOleTest( 512)'>XInterface </Button>
+<p>
+
+Tests Array/Sequence conversion with Attributes. All params are of type Sequence and
+ the element type of the Sequence is written on the buttons. <br>
+<button onclick='callOleTest( 200)'>byte </Button>
+<button onclick='callOleTest( 212)'>float</Button>
+<button onclick='callOleTest( 201)'>double</Button>
+<button onclick='callOleTest( 202)'>boolean</Button>
+<button onclick='callOleTest( 203)'>short</Button>
+<button onclick='callOleTest( 204)'>unsigned short</Button>
+<button onclick='callOleTest( 205)'>long</Button>
+<button onclick='callOleTest( 206)'>unsigned long</Button>
+<button onclick='callOleTest( 207)'>char</Button>
+<button onclick='callOleTest( 208)'>string</Button>
+<button onclick='callOleTest( 209)'>any</Button>
+<button onclick='callOleTest( 210)'>sequence&ltlong&gt </Button>
+<button onclick='callOleTest( 211)'>sequence&ltsequence&ltlong&gt &gt </Button>
+<p>
+
+Test of Any parameter in a method. Any contains:<br>
+<button onclick='callOleTest( 1000)'>integer </Button>
+<button onclick='callOleTest( 1001)'>double </Button>
+<button onclick='callOleTest( 1002)'>string</Button>
+<button onclick='callOleTest( 1003)'>array</Button>
+<button onclick='callOleTest( 1004)'>object</Button>
+<p>
+Test of Any parameter in a property. Any contains:<br>
+<button onclick='callOleTest( 1010)'>integer </Button>
+<button onclick='callOleTest( 1011)'>double </Button>
+<button onclick='callOleTest( 1012)'>string</Button>
+<button onclick='callOleTest( 1013)'>array</Button>
+<button onclick='callOleTest( 1014)'>object</Button>
+<P>
+Test of Struct conversions<br>
+<button onclick='callOleTest( 1020)'>methodStruct </Button>
+<button onclick='callOleTest( 1021)'>return struct</Button>
+<button onclick='callOleTest( 1022)'>struct attribute</Button>
+
+
+
+
+<p>
+
+
+<h2> Visual Basic Tests </h2>
+Test array /Sequence conversion and return value<br>
+Template: <b> Sequence &lt type &gt method( Sequence&lt type &gt ) </b> <br>
+<!--<font color= red>Multi dimensional arrays are not processed by VBSript</font> <br> -->
+<button onclick='callBasic(0)'>byte</button>
+<button onclick='callBasic(1)'>double</button>
+<button onclick='callBasic(2)'>boolean</button>
+<button onclick='callBasic(3)'>short</button>
+<button onclick='callBasic(4)'>u short</button>
+<button onclick='callBasic(5)'>long</button>
+<button onclick='callBasic(6)'>u long</button>
+<button onclick='callBasic(7)'>string</button>
+<button onclick='callBasic(8)'>char</button>
+<button onclick='callBasic(9)'>any</button> <br>
+<button onclick='callBasic(10)'>Seq &lt int &gt</button> <br>
+
+
+IN/Out parameter <br>
+Template: <b> void method(type ) </b> <br>
+<button onclick='callBasic(100)'>byte</button>
+<button onclick='callBasic(101)'>double</button>
+<button onclick='callBasic(102)'>boolean</button>
+<button onclick='callBasic(103)'>short</button>
+<button onclick='callBasic(104)'>u short</button>
+<button onclick='callBasic(105)'>long</button>
+<button onclick='callBasic(106)'>u long</button>
+<button onclick='callBasic(107)'>string</button>
+<button onclick='callBasic(108)'>char</button>
+<button onclick='callBasic(109)'>any</button> <br>
+
+Simple out parameter<br>
+<button onclick='callBasic(150)'>byte</button>
+<!--<button onclick='callBasic(151)'>double</button>
+<button onclick='callBasic(152)'>boolean</button>
+<button onclick='callBasic(153)'>short</button>
+<button onclick='callBasic(155)'>long</button>
+<button onclick='callBasic(157)'>string</button>
+<button onclick='callBasic(158)'>char</button>
+<button onclick='callBasic(159)'>any</button> <br>
+//-->
+<br>
+
+
+Tests Array/Sequence conversion with <b>Attributes</b>. All params are of type Sequence and
+ the element type of the Sequence is written on the buttons. <br>
+<button onclick='callBasic( 200)'>byte </Button>
+<button onclick='callBasic( 201)'>double</Button>
+<button onclick='callBasic( 202)'>boolean</Button>
+<button onclick='callBasic( 203)'>short</Button>
+<button onclick='callBasic( 204)'>unsigned short</Button>
+<button onclick='callBasic( 205)'>long</Button>
+<button onclick='callBasic( 206)'>unsigned long</Button>
+<button onclick='callBasic( 207)'>string</Button>
+<button onclick='callBasic( 208)'>char</Button>
+<button onclick='callBasic( 209)'>any</Button>
+<button onclick='callBasic( 210)'>sequence&ltlong&gt </Button> <br>
+
+In Out parameter <br>
+<button onclick='callBasic( 300)'>byte</Button>
+<p>
+Structs <br>
+<button onclick='callBasic(400)'>methodStruct</button>
+<button onclick='callBasic(401)'>return Struct</button>
+<button onclick='callBasic(402)'>struct attribute</button>
+
+
+
diff --git a/extensions/test/ole/ScriptTest.html b/extensions/test/ole/ScriptTest.html
new file mode 100644
index 000000000000..71e11145766a
--- /dev/null
+++ b/extensions/test/ole/ScriptTest.html
@@ -0,0 +1,1555 @@
+<HTML>
+<HEAD>
+<META NAME="GENERATOR" Content="Microsoft Developer Studio">
+<META HTTP-EQUIV="Content-Type" content="text/html; charset=iso-8859-1">
+<TITLE>Document Title</TITLE>
+</HEAD>
+<BODY id=theBody>
+
+<script language="JScript">
+
+function runJScriptTest( Log)
+{
+document.writeln("================================================================================<br>");
+document.writeln("JScript<br>");
+document.writeln("================================================================================<p>");
+
+//var name : String = "Fred";
+//print(name);
+var arr= new Array( 1, 2, 3, 4, 0);
+var arrInt= new Array( 1,2,3,4,5);
+var arrDouble= new Array( 1.2345, 12.345, 123.45, 1234.5, 12345);
+var arrBool= new Array( true, false, true, false, true);
+var arrChar= new Array( '1', 'A'," ", 55);
+
+var arrString= new Array("hamburger","cheeseburger", "chicken nuggets", "chicken wings" , "pizza");
+var arrAny= new Array( 100, 100.1235,"hallo");
+var arrSeq= new Array( arr, arr, arr);
+var arrSeq2= new Array( );
+
+var arEventListener= new Array( new XEventListener_Impl(), new XEventListener_Impl(),
+ new XEventListener_Impl());
+var arEventListener2= new Array( new XEventListener_Impl(), new XEventListener_Impl(),
+ new XEventListener_Impl());
+var arArEventListener= new Array( arEventListener, arEventListener2);
+
+var arObj= new Array();
+for( i=0; i< 3; i++)
+{
+ arObj[i]= new Object();
+}
+var outVal= new Array();
+var outVal2= new Array();
+var outVal3= new Array();
+
+for( i=0; i < 3; i++)
+{
+ arrSeq2[i]= new Array();
+ for( j= 0; j < 3; j++)
+ {
+ arrSeq2[i][j]= new Array();
+ for( k= 0; k < 5; k++)
+ {
+ arrSeq2[i][j][k]= (i * 3 * 5) + (j * 5) + k;
+// document.write(arrSeq2[i][j][k] + " ");
+ }
+// document.write("<br>");
+ }
+}
+
+
+ret= oletest.methodByte( arr);
+_ret= new VBArray( ret).toArray();
+Log.print( isEqualAr( arr, _ret), "methodByte");
+
+ret= oletest.methodFloat( arrDouble);
+_ret= new VBArray( ret).toArray();
+bOk= false;
+if( (arrDouble.length == _ret.length)
+ && (_ret[0] > 1.2344 && _ret[0] < 1.2346)
+ && (_ret[1] > 12.344 && _ret[1] < 12.346)
+ && (_ret[2] > 123.44 && _ret[2] < 123.46)
+ && (_ret[3] > 1234.4 && _ret[3] < 1234.6)
+ && (_ret[4] > 12344 && _ret[4] < 12346))
+ bOk= true;
+Log.print( bOk, "methodFloat");
+
+ret= oletest.methodDouble( arrDouble);
+_ret= new VBArray( ret).toArray();
+Log.print( isEqualAr( arrDouble, _ret), "methodDouble");
+
+ret= oletest.methodBool( arrBool);
+_ret= new VBArray( ret).toArray();
+Log.print( isEqualAr( arrBool, _ret), "methodBool");
+
+ret= oletest.methodShort( arr);
+_ret= new VBArray( ret).toArray();
+Log.print( isEqualAr( arr, _ret), "methodShort");
+
+ret= oletest.methodUShort( arr);
+_ret= new VBArray( ret).toArray();
+Log.print( isEqualAr( arr, _ret), "methodUShort");
+
+ret= oletest.methodLong( arr);
+_ret= new VBArray( ret).toArray();
+Log.print( isEqualAr( arr, _ret), "methodLong");
+
+ret= oletest.methodULong( arr);
+_ret= new VBArray( ret).toArray();
+Log.print( isEqualAr( arr, _ret), "methodULong");
+
+ret= oletest.methodChar( arrChar);
+_ret= new VBArray( ret).toArray();
+bOk= false;
+if( _ret.length == arrChar.length && _ret[0] == 49 && _ret[1] == 65 && _ret[2] == 32 && _ret[3] == 55)
+ bOk= true;
+Log.print( bOk, "methodChar");
+
+ret= oletest.methodString( arrString);
+_ret= new VBArray( ret).toArray();
+Log.print( isEqualAr( arrString, _ret), "methodString");
+
+ret= oletest.methodAny( arrAny);
+_ret= new VBArray( ret).toArray();
+Log.print( isEqualAr( arrAny, _ret), "methodAny");
+
+ret= oletest.methodSequence( arrSeq);
+_ret= new VBArray( ret).toArray();
+for( i=0; i < _ret.length; i++)
+{
+ sfarray2= new VBArray( _ret[i]);
+ var arr2= sfarray2.toArray();
+ if( ! isEqualAr(arrSeq[i], arr2))
+ {
+ bOk= false;
+ break;
+ }
+}
+Log.print( bOk, "methodSequence");
+
+ret= oletest.methodSequence2( arrSeq2);
+arr1= new VBArray( ret).toArray();
+for( i=0; i < arr1.length; i++)
+{
+ var ar2Dim= arrSeq2[i];
+ sfarray2= new VBArray( arr1[i]);
+ arr2= sfarray2.toArray();
+ for ( j=0; j < arr2.length; j++)
+ {
+ var ar1Dim= ar2Dim[j];
+ sfarray3= new VBArray( arr2[j]);
+ arr3= sfarray3.toArray();
+// document.write(arr3[j].toString());
+ if( ! isEqualAr( arrSeq2[i][j], arr3))
+ {
+ bOk= false;
+ break;
+ }
+ }
+}
+Log.print( bOk, "methodSequence2");
+
+ret= oletest.methodXInterface( arObj);
+_ret= new VBArray( ret).toArray();
+bOk= true;
+for(i in _ret)
+{
+ if( _ret[i] !== arObj[i])
+ {
+ bOk= false;
+ break;
+ }
+}
+Log.print( bOk, "methodXInterface");
+
+
+ret= oletest.methodXEventListeners( arEventListener);
+_ret= new VBArray(ret).toArray();
+bOk= true;
+for ( key in _ret)
+{
+ if( ! _ret[key].disposingCalled())
+ {
+ bOk= false;
+ break;
+ }
+}
+Log.print( bOk, "methodXEventListeners");
+
+ret= oletest.methodXEventListenersMul( arArEventListener);
+_ret= new VBArray(ret).toArray();
+bOk= true;
+for( key in _ret)
+{
+ _ret2= new VBArray(_ret[key]).toArray();
+ for( key2 in _ret2)
+ {
+ if( ! _ret2[key2].disposingCalled())
+ {
+ bOk= false;
+ break;
+ }
+ }
+}
+Log.print( bOk, "methodXEventListenersMul");
+
+document.writeln("<br>");
+oletest.AttrByte = arr;
+ret= oletest.AttrByte;
+_ret= new VBArray( ret).toArray();
+Log.print( isEqualAr( arr, _ret), "AttrByte");
+
+oletest.AttrFloat= arrDouble;
+ret= oletest.AttrFloat;
+_ret= new VBArray( ret).toArray();
+bOk= false;
+if( (arrDouble.length == _ret.length)
+ && (_ret[0] > 1.2344 && _ret[0] < 1.2346)
+ && (_ret[1] > 12.344 && _ret[1] < 12.346)
+ && (_ret[2] > 123.44 && _ret[2] < 123.46)
+ && (_ret[3] > 1234.4 && _ret[3] < 1234.6)
+ && (_ret[4] > 12344 && _ret[4] < 12346))
+ bOk= true;
+Log.print( bOk, "AttrFloat");
+
+oletest.AttrDouble= arrDouble;
+ret= oletest.AttrDouble;
+_ret= new VBArray( ret).toArray();
+Log.print( isEqualAr( arrDouble, _ret), "AttrDouble");
+
+oletest.AttrBool= arrBool;
+ret= oletest.AttrBool;
+_ret= new VBArray( ret).toArray();
+Log.print( isEqualAr( arrBool, _ret), "AttrBool");
+
+oletest.AttrShort= arr;
+ret= oletest.AttrShort;
+_ret= new VBArray( ret).toArray();
+Log.print( isEqualAr( arr, _ret), "AttrShort");
+
+oletest.AttrUShort= arr;
+ret= oletest.AttrUShort;
+_ret= new VBArray( ret).toArray();
+Log.print( isEqualAr( arr, _ret), "AttrUShort");
+
+oletest.AttrLong= arr;
+ret= oletest.AttrLong;
+_ret= new VBArray( ret).toArray();
+Log.print( isEqualAr( arr, _ret), "AttrLong");
+
+oletest.AttrULong= arr;
+ret= oletest.AttrULong;
+_ret= new VBArray( ret).toArray();
+Log.print( isEqualAr( arr, _ret), "AttrULong");
+
+oletest.AttrChar= arrChar;
+ret= oletest.AttrChar;
+_ret= new VBArray(ret).toArray();
+bOk= false;
+if( _ret.length == arrChar.length && _ret[0] == 49 && _ret[1] == 65 && _ret[2] == 32 && _ret[3] == 55)
+ bOk= true;
+Log.print( bOk, "AttrChar");
+
+oletest.AttrString= arrString;
+ret= oletest.AttrString;
+_ret= new VBArray( ret).toArray();
+Log.print( isEqualAr( arrString, _ret), "AttrString");
+
+oletest.AttrAny= arrAny;
+ret= oletest.AttrAny;
+_ret= new VBArray( ret).toArray();
+Log.print( isEqualAr( arrAny, _ret), "AttrAny");
+
+oletest.AttrSequence= arrSeq;
+ret= oletest.AttrSequence;
+_ret= new VBArray( ret).toArray();
+for( i=0; i < _ret.length; i++)
+{
+ sfarray2= new VBArray( _ret[i]);
+ var arr2= sfarray2.toArray();
+ if( ! isEqualAr(arrSeq[i], arr2))
+ {
+ bOk= false;
+ break;
+ }
+}
+Log.print( bOk, "AttrSequence");
+
+oletest.AttrSequence2= arrSeq2;
+ret= oletest.AttrSequence2;
+arr1= new VBArray( ret).toArray();
+for( i=0; i < arr1.length; i++)
+{
+ var ar2Dim= arrSeq2[i];
+ sfarray2= new VBArray( arr1[i]);
+ arr2= sfarray2.toArray();
+ for ( j=0; j < arr2.length; j++)
+ {
+ var ar1Dim= ar2Dim[j];
+ sfarray3= new VBArray( arr2[j]);
+ arr3= sfarray3.toArray();
+ if( ! isEqualAr( arrSeq2[i][j], arr3))
+ {
+ bOk= false;
+ break;
+ }
+ }
+}
+Log.print( bOk, "AttrSequence2");
+
+oletest.AttrXInterface= arObj;
+ret= oletest.AttrXInterface;
+_ret= new VBArray( ret).toArray();
+bOk= true;
+for(i in _ret)
+{
+ if( _ret[i] !== arObj[i])
+ {
+ bOk= false;
+ break;
+ }
+}
+Log.print( bOk, "AttrXInterface");
+
+ret= oletest.methodXInterface( arObj);
+_ret= new VBArray( ret);
+_ret= _ret.toArray();
+bOk= true;
+for(i in _ret)
+{
+ if( _ret[i] !== arObj[i])
+ {
+ bOk= false;
+ break;
+ }
+}
+Log.print( bOk, "methodXInterface");
+//======================================================================================
+document.writeln("<br>");
+var inVal, outVal, retVal;
+outVal = new Array();
+
+inVal = 77;
+retVal = oletest.in_methodByte(inVal)
+oletest.testout_methodByte( outVal );
+Log.print( retVal == inVal, "in_methodByte");
+Log.print( outVal[0] == inVal, "testout_methodByte");
+
+inVal = 3.14
+retVal = oletest.in_methodFloat(inVal);
+oletest.testout_methodFloat( outVal );
+Log.print( retVal > 3.14 && retVal < 3.15, "in_methodFloat");
+Log.print( outVal[0] > 3.13 && outVal[0] < 3.15, "testout_methodFloat");
+//Log.print( outVal[0] == inVal, "testout_methodFloat");
+
+retVal = oletest.in_methodDouble(inVal)
+oletest.testout_methodDouble( outVal );
+Log.print( retVal == inVal, "in_methodDouble");
+Log.print( outVal[0] == 3.14, "testout_methodDouble" );
+
+inVal = true;
+retVal = oletest.in_methodBool(inVal);
+oletest.testout_methodBool( outVal );
+Log.print(retVal == inVal, "in_methodBool");
+Log.print( outVal[0] == true, "testout_methodBool");
+
+inVal = 111
+retVal = oletest.in_methodShort(inVal);
+oletest.testout_methodShort( outVal );
+Log.print(retVal == inVal, "in_methodShort");
+Log.print( outVal[0] == inVal, "testout_methodShort");
+
+retVal = oletest.in_methodUShort(inVal);
+oletest.testout_methodUShort( outVal );
+Log.print(retVal == inVal, "in_methodUShort");
+Log.print( outVal[0] == inVal, "testout_methodUShort");
+
+retVal = oletest.in_methodLong(inVal);
+oletest.testout_methodLong( outVal );
+Log.print(retVal == inVal, "in_methodLong");
+Log.print( outVal[0] == inVal, "testout_methodLong");
+
+retVal = oletest.in_methodULong(inVal);
+oletest.testout_methodULong( outVal );
+Log.print(retVal == inVal, "in_methodULong");
+Log.print( outVal[0] == inVal, "testout_methodULong");
+
+retVal = oletest.in_methodChar(inVal);
+oletest.testout_methodChar( outVal );
+Log.print(retVal == inVal, "in_methodChar");
+Log.print( outVal[0] == inVal, "testout_methodChar");
+
+inVal = "Hello World";
+retVal = oletest.in_methodString(inVal);
+oletest.testout_methodString( outVal );
+Log.print(retVal == inVal, "in_methodString");
+Log.print( outVal[0] == inVal, "testout_methodString");
+
+retVal = oletest.in_methodAny(inVal);
+oletest.testout_methodAny( outVal );
+Log.print(retVal == inVal, "in_methodAny");
+Log.print( outVal[0] == inVal, "testout_methodAny");
+
+inVal = new Object();
+retVal = oletest.in_methodXInterface(inVal);
+oletest.testout_methodXInterface(outVal);
+Log.print(retVal === inVal, "in_methodXInterface");
+Log.print(outVal[0] === inVal, "testout_methodXInterface");
+
+inVal = oletest;
+retVal = oletest.in_methodXInterface(inVal);
+oletest.testout_methodXInterface(outVal);
+Log.print(retVal === inVal, "in_methodXInterface");
+Log.print(outVal[0] === inVal, "testout_methodXInterface");
+
+
+oletest.testout_methodSequence( outVal );
+var arr= new VBArray( outVal[0]).toArray();
+Log.print( isEqualAr(arr, new Array( 0,1,2,3,4,5,6,7,8,9)), "testout_methodSequence");
+
+oletest.testout_methodSequence2( outVal );
+var arr= new VBArray( outVal[0]).toArray();
+bOk= true;
+if( arr.length= 10)
+{
+ for( i=0; i < arr.length; i++)
+ {
+ var arr2= new VBArray( arr[i]).toArray();
+ if( ! isEqualAr( arr2, new Array( 0,1,2,3,4,5,6,7,8,9)))
+ {
+ bOk= false;
+ break;
+ }
+ }
+}
+Log.print( bOk, "testout_methodSequence2");
+
+oletest.testout_methodMulParams1( outVal, outVal2 );
+Log.print( outVal[0] == 999 && outVal2[0] == 1111, "testout_methodMulParams1");
+
+oletest.testout_methodMulParams2( outVal, outVal2, outVal3 );
+Log.print( outVal[0] == 1111 && outVal2[0] == 1222 && outVal3[0] == " another string",
+ "testout_methodMulParams2");
+
+oletest.testout_methodMulParams3( "hallo", outVal );
+Log.print( outVal[0] == "Out Hallo!", "testout_methodMulParams3");
+
+var in1= 3.14;
+var in2= 1111;
+var in3= -2222;
+oletest.testout_methodMulParams4( in1, outVal, in2, outVal2, in3 );
+Log.print( (outVal[0] > 4.13 && outVal[0] < 4.15) && (outVal2[0] == 1112), "testout_methodMulParams4");
+
+document.writeln("<p>");
+
+inVal = 100;
+outVal[0]= inVal;
+oletest.testinout_methodByte( outVal );
+oletest.testinout_methodByte( outVal );
+Log.print( outVal[0] == inVal, "testinout_methodByte");
+
+inVal = 3.14;
+outVal[0]= inVal;
+oletest.testinout_methodFloat( outVal );
+oletest.testinout_methodFloat( outVal );
+Log.print( outVal[0] > 3.13 && outVal[0] < 3.15, "testinout_methodFloat");
+
+inVal = 3.14
+outVal[0]= inVal;
+oletest.testinout_methodDouble( outVal );
+oletest.testinout_methodDouble( outVal );
+Log.print( outVal[0] == inVal, "testinout_methodDouble");
+
+inVal = true;
+outVal[0]= inVal;
+oletest.testinout_methodBool( outVal );
+oletest.testinout_methodBool( outVal );
+Log.print( outVal[0] == inVal, "testinout_methodBool");
+
+inVal = 200;
+outVal[0]= inVal;
+oletest.testinout_methodShort( outVal );
+oletest.testinout_methodShort( outVal );
+Log.print( outVal[0] == inVal, "testinout_methodShort");
+
+inVal = 300;
+outVal[0]= inVal;
+oletest.testinout_methodUShort( outVal );
+oletest.testinout_methodUShort( outVal );
+Log.print( outVal[0] == inVal, "testinout_methodUShort");
+
+inVal = 400
+outVal[0]= inVal;
+oletest.testinout_methodLong( outVal );
+oletest.testinout_methodLong( outVal );
+Log.print( outVal[0] == inVal, "testinout_methodLong");
+
+inVal = 500;
+outVal[0]= inVal;
+oletest.testinout_methodULong( outVal );
+oletest.testinout_methodULong( outVal );
+Log.print( outVal[0] == inVal, "testinout_methodULong");
+
+inVal = "B";
+outVal[0]= inVal;
+oletest.testinout_methodChar( outVal );
+oletest.testinout_methodChar( outVal );
+
+Log.print( outVal[0] == 66, "testinout_methodChar");
+
+inVal = "Hello World 2!";
+outVal[0]= inVal;
+oletest.testinout_methodString( outVal );
+oletest.testinout_methodString( outVal );
+Log.print( outVal[0] == inVal, "testinout_methodString");
+
+inVal = new Object();
+outVal[0]= inVal;
+oletest.testinout_methodAny( outVal );
+oletest.testinout_methodAny( outVal );
+Log.print( outVal[0] === inVal, "testinout_methodAny");
+
+inVal = arrInt;
+outVal[0] = inVal;
+oletest.testinout_methodSequence( outVal );
+oletest.testinout_methodSequence( outVal );
+retVal = new VBArray(outVal[0]).toArray();
+
+Log.print( isEqualAr(retVal, new Array(3,4,5,6,7)), "testinout_methodSequence");
+
+
+outVal[0]= arrSeq;
+oletest.testinout_methodSequence2( outVal );
+var arr= new VBArray( outVal[0]).toArray();
+var i;
+bOk= true;
+if( arr.length == 3)
+{
+ var tmpArr= new Array(2,4,6,8,0);
+ for( i=0; i < arr.length; i++)
+ {
+ var arr2= new VBArray( arr[i]).toArray();
+ if( ! isEqualAr( arr2, tmpArr))
+ {
+ bOk= false;
+ break;
+ }
+ }
+}
+Log.print( bOk, "testinout_methodSequence2");
+
+
+var ob= new Object();
+var sInVal= "this is a string"
+ob.value= sInVal;
+outVal[0]= ob;
+oletest.testinout_methodXInterface( outVal);
+Log.print( outVal[0].value == "out", "testinout_methodXInterface");
+document.writeln("<p>");
+
+i= 100;
+ret= oletest.methodAnyTest1( i);
+Log.print( i == ret, "methodAnyTest1");
+
+i= 3.14;
+ret= oletest.methodAnyTest1( i);
+Log.print( i == ret, "methodAnyTest1");
+
+i= "Hallo"
+ret= oletest.methodAnyTest1( i);
+Log.print( i == ret, "methodAnyTest1");
+
+i= arrInt;
+ret= oletest.methodAnyTest1( i);
+var arr= new VBArray( ret).toArray();
+Log.print( isEqualAr(arr, arrInt), "methodAnyTest1");
+
+var obj= new Object();
+ret= oletest.methodAnyTest1( obj);
+Log.print( obj == ret, "methodAnyTest1");
+
+
+document.writeln("<p>");
+
+i= 100;
+oletest.AttrAny2= i;
+ret= oletest.AttrAny2;
+Log.print( i == ret, "AttrAny2");
+
+i= 3.14;
+oletest.AttrAny2= i;
+ret= oletest.AttrAny2;
+Log.print( i == ret, "AttrAny2");
+
+i= "Hallo"
+oletest.AttrAny2= i;
+ret= oletest.AttrAny2;
+Log.print( i == ret, "AttrAny2");
+
+i= arrInt;
+oletest.AttrAny2= i;
+ret= oletest.AttrAny2;
+var arr= new VBArray( ret).toArray();
+Log.print( isEqualAr(arr, arrInt), "AttrAny2");
+
+var obj= new Object();
+oletest.AttrAny2= obj;
+ret= oletest.AttrAny2;
+Log.print( obj == ret, "AttrAny2");
+
+
+document.writeln("<p>");
+// Structs ----------------------------------------------
+
+/* var struct= oletest._GetStruct("com.sun.star.beans.Property"); */
+/* struct.Attributes= 1; */
+/* struct.Handle= 2; */
+/* struct.Name= "some Property" */
+/* oletest.methodStruct( struct); */
+
+var ret= oletest.retMethodStruct();
+Log.print( ret.Attributes == 127 && ret.Handle == 255 && ret.Name == "OleTest_Property", "retMethodStruct");
+
+var astruct= oletest._GetStruct("com.sun.star.beans.Property");
+astruct.Attributes= 1;
+astruct.Handle= 2;
+astruct.Name= "some Property"
+oletest.AttrStruct= astruct;
+
+var ret= oletest.AttrStruct;
+Log.print( ret.Attributes == 127 && ret.Handle == 255 && ret.Name == "OleTest_Property", "AttrStruct");
+
+// The function returns the struct. Since structs are passed by value the returned struct
+// will be wrapped in another IDispatch object
+astruct.Attributes= 1;
+astruct.Handle= 2;
+astruct.Name= "Property";
+ret= oletest.methodStruct2( astruct);
+Log.print( ret.Attributes == 1 && ret.Handle == 2 && ret.Name == "Property", "methodStruct2");
+
+
+document.writeln("<p>");
+// Test Identity from COM objects in UNO
+var listener1= new XEventListener_Impl();
+oletest.setObject(listener1);
+ret= oletest.isSame(listener1);
+Log.print2( ret, "Ok Testing identity of COM objects<br>","Failed Testing identity of COM objects<br>");
+
+var oletest2= oletest.getThis();
+ret= oletest === oletest2;
+Log.print2(ret, "Ok Testing identity of UNO objects<br>","Failed Testing identity of UNO objects<br>");
+}
+
+
+
+
+function isEqualAr( ar1, ar2)
+{
+ var bOk= false;
+ if( ar1.length == ar2.length)
+ {
+ bOk= true;
+ for( x in ar1)
+ {
+// document.writeln( ar1[x] + " ");
+// document.writeln( ar2[x] + " ");
+ if( ar1[x] != ar2[x])
+ {
+ bOk= false;
+ break;
+ }
+ }
+ }
+ return bOk;
+}
+
+/* function isEqualAr2( ar1, ar2) */
+/* { */
+
+/* var bOk= false; */
+/* if( ar1.length == ar2.length) */
+/* { */
+/* bOk= true; */
+/* for( x in ar1) */
+/* { */
+/* document.write( ar1[x]); */
+/* document.write( ar2[x]); */
+/* if( ! isEqualAr( ar1[x], ar2[x])) */
+/* { */
+/* bOk= false; */
+/* break; */
+/* } */
+/* } */
+/* } */
+/* return bOk; */
+
+/* } */
+
+function XEventListener_Impl()
+{
+ this._environment= "JScript";
+ this._implementedInterfaces= new Array( "com.sun.star.lang.XEventListener");
+
+ //XEventListener
+ this.disposing= XEventListener_disposing;
+
+ this.bdisposingCalled= false;
+ this.bQuiet= true;
+ this.resetDisposing= XEventListener_resetDisposing;
+ this.disposingCalled= XEventListener_disposingCalled;
+}
+
+function XEventListener_disposing( source)
+{
+ if( !this.bQuiet)
+ alert("JScript Event Listener \n disposing is being called");
+ this.bdisposingCalled= true;
+}
+
+function XEventListener_resetDisposing()
+{
+ this.bdisposingCalled= false;
+}
+
+function XEventListener_disposingCalled()
+{
+ return this.bdisposingCalled;
+}
+</script>
+
+<script language="VBScript">
+Function runVBTest( Log)
+document.writeln("================================================================================<br>")
+document.writeln("VB Script<br>")
+document.writeln("================================================================================<p>")
+
+Dim arrInt
+arrInt= Array(1,2,3,-4,-5, 0)
+arrUInt= Array(1,2,3,4,5)
+arrDouble= Array( 1.2345, 12.345, 123.45, 1234.5, 12345)
+arrBool= Array( true, false, true, false, true)
+arrChar= Array("A","B",67)
+arrString= Array("hamburger","cheeseburger", "chicken nuggets", "chicken wings" , "pizza")
+arrAny= Array( 100, 100.1235,"hallo")
+
+
+Dim arrDim2Int(2,1)
+Dim i,j,k
+For i= 0 To 1
+ For j= 0 To 2
+ arrDim2Int(j,i) = i*3 + j
+ Next
+Next
+
+
+Dim arrDim3Int(3,2,1)
+For i= 0 To 1
+ For j= 0 To 2
+ For k= 0 To 3
+ arrDim3Int(k,j,i)= i* 3 + j* 4 + k
+ Next
+ Next
+Next
+
+Dim arrXEvent(2)
+For i= 0 To 2
+ Set arrXEvent(i)= new VBEventListener
+Next
+
+Dim arrXEvent2(2,1)
+For i= 0 To 1
+ For j= 0 To 2
+ Set arrXEvent2(j,i)= new VBEventListener
+ Next
+Next
+
+
+
+ret= oletest.methodByte( arrUInt)
+Log.print isEqualVBAr( ret, arrUInt), "methodByte"
+
+ret= oletest.methodFloat( arrDouble)
+Log.print isEqualVBAr( ret, arrDouble), "methodFloat"
+
+ret= oletest.methodDouble( arrDouble)
+Log.print isEqualVBAr( ret, arrDouble), "methodDouble"
+
+ret= oletest.methodBool( arrBool)
+Log.print isEqualVBAr( ret, arrBool), "methodBool"
+
+ret= oletest.methodShort( arrInt)
+Log.print isEqualVBAr( ret, arrInt), "methodShort"
+
+ret= oletest.methodUShort( arrUInt)
+Log.print isEqualVBAr( ret, arrUInt), "methodUShort"
+
+ret= oletest.methodLong( arrInt)
+Log.print isEqualVBAr( ret, arrInt), "methodLong"
+
+ret= oletest.methodULong( arrUInt)
+Log.print isEqualVBAr( ret, arrUInt), "methodULong"
+
+ret= oletest.methodChar( arrChar)
+bOk= false
+if ret(0) = 65 AND ret(1) = 66 AND ret(2) = 67 then
+ bOk= true
+end if
+Log.print bOk, "methodChar"
+
+ret= oletest.methodString( arrString)
+Log.print isEqualVBAr( ret, arrString), "methodString"
+
+ret= oletest.methodAny( arrAny)
+Log.print isEqualVBAr( ret, arrAny), "methodAny"
+
+
+ret= oletest.methodSequence( arrDim2Int)
+bOk= true
+
+For i= 0 To 1
+ Dim arr1
+ arr1= ret(i)
+ For j= 0 To 2
+ if arr1(j) <> arrDim2Int(j,i) then
+ bOk= false
+ exit for
+ end if
+ Next
+Next
+Log.print bOk, "methodSequence"
+
+ret= oletest.methodSequence2( arrDim3Int)
+'arrDim3Int(3,2,1)
+bOk= true
+For i= 0 To 1
+ arr1= ret(i)
+ For j= 0 To 2
+ arr2= arr1(j)
+ For k= 0 To 3
+ If arr2(k) <> arrDim3Int(k,j,i) then
+ bOk= false
+ exit for
+ End If
+ Next
+ Next
+Next
+Log.print bOk, "methodSequence2"
+
+ret= oletest.methodXInterface(arrXEvent)
+bOk= true
+numArg= UBound( arrXEvent) - LBound( arrXEvent) + 1
+numRet= UBound( ret) - LBound( ret) + 1
+If numArg = numRet then
+ For i= 0 To numArg - 1
+ If NOT (arrXEvent(i) Is ret(i)) then
+ bOk= false
+ Exit For
+ End if
+ Next
+End If
+Log.print bOk, "methodXInterface"
+
+ret= oletest.methodXEventListeners( arrXEvent)
+bOk= true
+For i= 0 To 2
+ If arrXEvent(i).disposingCalled = false then
+ bOk= false
+ Exit For
+ End If
+Next
+Log.print bOk, "methodXEventListeners"
+
+ret= oletest.methodXEventListenersMul(arrXEvent2)
+bOk= true
+For i= 0 To 1
+ For j= 0 To 2
+ If arrXEvent2(j,i).disposingCalled = false then
+ bOk= false
+ Exit For
+ End If
+ Next
+Next
+Log.print bOk, "methodXEventListenersMul"
+
+' Attributes ------------------------------------------------------
+document.writeln( "<br>" )
+oletest.AttrByte= arrUInt
+ret= oletest.AttrByte
+Log.print isEqualVBAr( arrUInt, ret), "AttrByte"
+
+oletest.AttrFloat= arrDouble
+ret= oletest.AttrFloat
+Log.print isEqualVBAr( arrDouble, ret), "AttrFloat"
+
+oletest.AttrDouble= arrDouble
+ret= oletest.AttrDouble
+Log.print isEqualVBAr( arrDouble, ret), "AttrDouble"
+
+oletest.AttrBool= arrBool
+ret= oletest.AttrBool
+Log.print isEqualVBAr( arrBool, ret), "AttrBool"
+
+oletest.AttrShort= arrInt
+ret= oletest.AttrShort
+Log.print isEqualVBAr( arrInt, ret), "AttrShort"
+
+oletest.AttrUShort= arrUInt
+ret= oletest.AttrUShort
+Log.print isEqualVBAr( arrUInt, ret), "AttrUShort"
+
+oletest.AttrLong= arrInt
+ret= oletest.AttrLong
+Log.print isEqualVBAr( arrInt, ret), "AttrLong"
+
+oletest.AttrULong= arrUInt
+ret= oletest.AttrULong
+Log.print isEqualVBAr( arrUInt, ret), "AttrULong"
+
+oletest.AttrChar= arrChar
+ret= oletest.AttrChar
+bOk= false
+if ret(0) = 65 AND ret(1) = 66 AND ret(2) = 67 then
+ bOk= true
+end if
+Log.print bOk, "AttrChar"
+
+oletest.AttrString= arrString
+ret= oletest.AttrString
+Log.print isEqualVBAr( arrString, ret), "AttrString"
+
+oletest.AttrSequence= arrDim2Int
+ret= oletest.AttrSequence
+bOk= true
+For i= 0 To 1
+ arr1= ret(i)
+ For j= 0 To 2
+ if arr1(j) <> arrDim2Int(j,i) then
+ bOk= false
+ exit for
+ end if
+ Next
+Next
+Log.print bOk, "AttrSequence"
+
+oletest.AttrSequence2= arrDim3Int
+ret= oletest.AttrSequence2
+'arrDim3Int(3,2,1)
+bOk= true
+For i= 0 To 1
+ arr1= ret(i)
+ For j= 0 To 2
+ arr2= arr1(j)
+ For k= 0 To 3
+ If arr2(k) <> arrDim3Int(k,j,i) then
+ bOk= false
+ exit for
+ End If
+ Next
+ Next
+Next
+Log.print bOk, "AttrSequence2"
+
+oletest.AttrXInterface= arrXEvent
+ret= oletest.AttrXInterface
+bOk= true
+numArg= UBound( arrXEvent) - LBound( arrXEvent) + 1
+numRet= UBound( ret) - LBound( ret) + 1
+If numArg = numRet then
+ For i= 0 To numArg - 1
+ If NOT (arrXEvent(i) Is ret(i)) then
+ bOk= false
+ Exit For
+ End if
+ Next
+End If
+Log.print bOk, "AttrXInterface"
+
+'out params ================================================================================
+document.writeln("<p>")
+Dim inVal, outVal, retVal
+
+inVal = 111
+retVal = oletest.in_methodByte(inVal)
+oletest.testout_methodByte outVal
+Log.print inVal = retVal, "in_methodByte"
+Log.print outVal = inVal, "testout_methodByte"
+
+inVal = 3.14
+retVal = oletest.in_methodFloat(inVal)
+oletest.testout_methodFloat outVal
+Log.print inVal = retVal, "in_methodFloat"
+Log.print outVal > 3.13 AND outVal < 3.15, "testout_methodFloat"
+
+inVal = 3.14
+retVal = oletest.in_methodDouble(inVal)
+oletest.testout_methodDouble outVal
+Log.print inVal = retVal, "in_methodDouble"
+Log.print outVal = 3.14, "testout_methodDouble"
+
+inVal = true
+retVal = oletest.in_methodBool(inVal)
+oletest.testout_methodBool outVal
+Log.print inVal = retVal, "in_methodBool"
+Log.print outVal = inVal, "testout_methodBool"
+
+inVal = 222
+retVal = oletest.in_methodShort(inVal)
+oletest.testout_methodShort outVal
+Log.print inVal = retVal, "in_methodShort"
+Log.print outVal = inVAl, "testout_methodShort"
+
+inVal = 333
+retVal = oletest.in_methodUShort(inVal)
+oletest.testout_methodUShort outVal
+Log.print inVal = retVal, "in_methodUShort"
+Log.print outVal = inVal, "testout_methodUShort"
+
+inVal = 4444
+retVal = oletest.in_methodLong(inVal)
+oletest.testout_methodLong outVal
+Log.print inVal = retVal, "in_methodLong"
+Log.print outVal = inVal, "testout_methodLong"
+
+inVal = 5555
+retVal = oletest.in_methodULong(inVal)
+oletest.testout_methodULong outVal
+Log.print inVal = retVal, "in_methodULong"
+Log.print outVal = inVal, "testout_methodULong"
+
+inVal = 65
+retVal = oletest.in_methodChar(inVal)
+oletest.testout_methodChar outVal
+Log.print inVal = retVal, "in_methodChar"
+Log.print outVal = 65, "testout_methodChar"
+
+inVal = "Hello World 3!"
+retVal = oletest.in_methodString(inVal)
+oletest.testout_methodString outVal
+Log.print inVal = retVal, "in_methodString"
+Log.print outVal = inVal, "testout_methodString"
+
+inVal = "Hello World 4!"
+retVal = oletest.in_methodAny(inVal)
+oletest.testout_methodAny outVal
+Log.print outVal = inVal, "testout_methodAny"
+
+oletest.testout_methodSequence outVal
+Log.print isEqualVBAr(outVal, Array( 0,1,2,3,4,5,6,7,8,9)), "testout_methodSequence"
+
+oletest.testout_methodSequence2 outVal
+count= UBound( outVal) - LBound( outVal) + 1
+ret= False
+If count = 10 Then
+ For Each ar In outVal
+ ret= isEqualVBAr(ar, Array( 0,1,2,3,4,5,6,7,8,9))
+ If ret = false Then
+ Exit For
+ End If
+ Next
+End If
+Log.print ret, "testout_methodSequence2"
+
+outVal= Empty
+outVal2= Empty
+oletest.testout_methodMulParams1 outVal, outVal2
+ret= false
+If outVal = 999 AND outVal2 = 1111 Then
+ ret= true
+End If
+Log.print ret, "testout_methodMulParams1"
+
+outVal= Empty
+outVal2= Empty
+outVal3= Empty
+oletest.testout_methodMulParams2 outVal, outVal2, outVal3
+ret = false
+If outVal = 1111 AND outVal2 = 1222 AND outVal3 = " another string" Then
+ ret= true
+End If
+Log.print ret, "testout_methodMulParams2"
+
+document.writeln("missing: testout_methodMulParams3 <br>")
+document.writeln("missing: testout_methodMulParams4 <br>")
+
+outVal= Empty
+oletest.testout_methodXInterface outVal
+ret= false
+If outVal Is oletest Then
+ ret= true
+End If
+Log.print ret, "testout_methodXInterface"
+
+Set outVal= Nothing
+document.writeln("missing: testout_methodXInterface <br>")
+
+inVal = 1
+outVal= inVal
+oletest.testinout_methodByte outVal
+oletest.testinout_methodByte outVal
+Log.print inVal = outVal, "testinout_methodByte"
+
+
+document.writeln("missing: testinout_methodFloat <br>")
+document.writeln("missing: testinout_methodDouble <br>")
+document.writeln("missing: testinout_methodBool <br>")
+document.writeln("missing: testinout_methodShort <br>")
+document.writeln("missing: testinout_methodUShort <br>")
+document.writeln("missing: testinout_methodLong <br>")
+document.writeln("missing: testinout_methodULong <br>")
+document.writeln("missing: testinout_methodChar <br>")
+document.writeln("missing: testinout_methodString <br>")
+document.writeln("missing: testinout_methodAny <br>")
+document.writeln("missing: testinout_methodSequence <br>")
+document.writeln("missing: testinout_methodSequence2 <br>")
+document.writeln("missing: testinout_methodXInterface <br>")
+document.writeln("missing: methodAnyTest1 <br>")
+document.writeln("missing: methodAnyTest1 <br>")
+document.writeln("missing: methodAnyTest1 <br>")
+document.writeln("missing: methodAnyTest1 <br>")
+document.writeln("missing: methodAnyTest1 <br>")
+document.writeln("missing: AttrAny2 <br>")
+document.writeln("missing: methodAnyTest1 <br>")
+document.writeln("missing: methodAnyTest1 <br>")
+document.writeln("missing: methodAnyTest1 <br>")
+document.writeln("missing: methodAnyTest1 <br>")
+document.writeln("missing: methodAnyTest1 <br>")
+document.writeln("missing: retMethodStruct <br>")
+document.writeln("missing: AttrStruct <br>")
+document.writeln("missing: methodStruct2 <br>")
+
+' Test Identity from COM objects in UNO
+Dim listener1
+Set listener1= new VBEventListener
+call oletest.setObject( listener1)
+ret= oletest.isSame(listener1)
+Log.print2 ret, "Ok Testing identity of COM objects <br>","Failed Testing identity of COM objects<br>"
+' Test identity of UNO objects
+
+set oletest2= oletest.getThis()
+ret= oletest Is oletest2
+Log.print2 ret, "Ok Testing identity of UNO objects<br>","Failed Testing identity of UNO objects<br>"
+
+End Function
+
+
+Function isEqualVBAr( arr1, arr2)
+ ret = false
+ s1= UBound( arr1) - LBound( arr1) + 1
+ s2= UBound( arr2) - LBound( arr2) + 1
+
+ if s1 = s2 then
+ ret= true
+ Dim i
+ for i= 0 To s1 - 1
+ if arr1(i) <> arr2(i) then
+ ret= false
+ exit for
+ end if
+ next
+ end if
+ isEqualVBar= ret
+End Function
+
+
+'The listener object
+
+Class VBEventListener
+ Dim Bridge_ImplementedInterfaces(0)
+ Dim bDisposingCalled
+
+'XEventListener::disposing
+ Function disposing( source)
+ bDisposingCalled= true
+ End Function
+
+ Sub Class_Initialize()
+ bDisposingCalled= false
+ Bridge_ImplementedInterfaces(0)= "com.sun.star.lang.XEventListener"
+ End Sub
+
+ Function resetDisposing()
+ bDisposingCalled= false
+ End Function
+
+ Function disposingCalled()
+ disposingCalled= bDisposingCalled
+ End Function
+End Class
+
+
+sub callBasic(id)
+
+ Dim factory
+ Set factory= GetObject("", "com.sun.star.ServiceManager")
+
+ Set oletest= factory.createInstance("oletest.OleTest")
+
+
+ arrInt= Array(1,2,3,4,5)
+ arrInt2= Array( -1, -2, 127, 128, 0)
+ arrDouble= Array(1.1, 2.2, 3.3, 4.4, 5.5)
+ arrBool= Array(0,1,0,2,0)
+ arrLong= Array( &Hff, &Hffff, &Hffffff, &Hffffffff)
+ arrString= Array("Chicken Wings", "Cheeseburger", "Hamburger")
+ arrChar= Array("a",65, "M")
+ arrAny= Array("Mickey", 3.14, 100, "A")
+
+ Dim arrDim2Int(1,2)
+ For i= 0 To 1
+ For j= 0 To 1
+ arrDim2Int(i,j) = i*2 + j
+ Next
+ Next
+
+ Dim arrDim3Int(1,1,1)
+ For i= 0 To 1
+ For j= 0 To 1
+ For k=0 To 1
+ arrDim3Int(i,j,k) = i*2 + j*2 + k
+ Next
+ Next
+ Next
+
+
+ select case id
+
+ // Out Parameter
+
+
+
+ // In Out Parameter --------------------------------------------------
+ case 100
+ a= 100
+ document.write "param: " & CStr( a) & "<br>"
+ oletest.testinout_methodByte a
+ document.write a
+ case 101
+ a= 1.11
+ document.write "param: " & CStr( a) & "<br>"
+ oletest.testinout_methodDouble a
+ document.write a
+ case 102
+ a= 5
+ document.write "param: "& CStr( a) & "<br>"
+ oletest.testinout_methodBool a
+ document.write a
+ case 103
+ a= -10
+ document.write "param: "& CStr( a) & "<br>"
+ oletest.testinout_methodShort a
+ document.write a
+ case 104
+ a= 128
+ document.write "param: "& CStr( a) & "<br>"
+ oletest.testinout_methodUShort a
+ document.write a
+ case 105
+ a= 65556
+ document.write "param: "& CStr( a) & "<br>"
+ oletest.testinout_methodLong a
+ document.write a
+ case 106
+ a= 65556
+ document.write "param: "& CStr( a) & "<br>"
+ oletest.testinout_methodULong a
+ document.write a
+ case 107
+ a= "ein test string"
+ document.write "param: "& CStr( a) & "<br>"
+ oletest.testinout_methodString a
+ document.write a
+ case 108
+ a= "W"
+ document.write "param: "& CStr( a) & "<br>"
+ oletest.testinout_methodChar a
+ document.write a
+ case 109
+ a= "Ein String im Any"
+ document.write "param: "& CStr( a) & "<br>"
+ oletest.other_methodAnyIn a
+ document.write a
+
+ case 150
+ dim a
+ document.write "param: "& CStr( a) & "<br>"
+ oletest.testout_methodByte( a)
+ document.write a
+// Attributes -----------------------------------------------------------------
+ case 200
+ document.write "set: "
+ printArray arrInt
+ oletest.AttrByte= arrInt
+ b= oletest.AttrByte
+ call printArrayEx( "<br> get: ", "<br>", b)
+ case 201
+ document.write "set: "
+ printArray arrDouble
+ oletest.AttrDouble= arrDouble
+ b= oletest.AttrDouble
+ call printArrayEx( "<br> get: ", "<br>", b)
+ case 202
+ document.write "set: "
+ printArray arrBool :
+ oletest.AttrBool= arrBool
+ b= oletest.AttrBool
+ call printArrayEx( "<br> get: ", "<br>", b)
+ case 203
+ document.write "set: "
+ printArray arrInt2 :
+ oletest.AttrShort= arrInt2
+ b= oletest.AttrShort
+ call printArrayEx( "<br> get: ", "<br>", b)
+ case 204
+ document.write "set: "
+ printArray arrInt
+ oletest.AttrUShort= arrInt
+ b= oletest.AttrUShort
+ call printArrayEx( "<br> get: ", "<br>", b)
+ case 205
+ document.write "set: "
+ printArray arrInt2
+ oletest.AttrLong= arrInt2
+ b= oletest.AttrLong
+ call printArrayEx( "<br> get: ", "<br>", b)
+ case 206
+ document.write "set: "
+ printArray arrInt
+ oletest.AttrULong= arrInt
+ b= oletest.AttrULong
+ call printArrayEx( "<br> get: ", "<br>", b)
+ case 207
+ document.write "set: "
+ printArray arrString
+ oletest.AttrString= arrString
+ b= oletest.AttrString
+ call printArrayEx( "<br> get: ", "<br>", b)
+ case 208
+ document.write "set: "
+ printArray arrChar
+ oletest.AttrChar= arrChar
+ b= oletest.AttrChar
+ call printArrayEx( "<br> get: ", "<br>", b)
+ case 209
+ document.write "set: "
+ printArray arrAny
+ oletest.AttrAny= arrAny
+ b= oletest.AttrAny
+ call printArrayEx( "<br> get: ", "<br>", b)
+
+ case 210
+ document.write "set: <br>"
+ printArray2 arrDim2Int :
+ oletest.AttrSequence= arrDim2Int
+ ret= oletest.AttrSequence
+ document.write "get: "
+ for each val in ret
+ document.write "<br> array: "
+ for each val2 in val
+ document.write val2
+ next
+ next
+
+ case 300
+ dim aByte
+ aByte= 100
+ call oletest.testinout_methodByte( aByte)
+ MsgBox aByte
+
+
+ case 400
+
+ set struct= oletest.Bridge_GetStruct("com.sun.star.beans.Property")
+ struct.Attributes= 1
+ struct.Handle= 2
+ struct.Name= "some Property"
+ oletest.methodStruct struct
+
+ case 401
+ set struct= oletest.retMethodStruct()
+ alert( "Property::Attributes : " & struct.Attributes & vblf & " Property::Handle : " _
+ & struct.Handle & vblf & " Property::Name : " & struct.Name)
+
+ case 402
+ set struct= oletest.Bridge_GetStruct("com.sun.star.beans.Property")
+ struct.Attributes= 1
+ struct.Handle= 2
+ struct.Name= "some Property"
+ oletest.AttrStruct= struct
+
+ set struct2= oletest.AttrStruct
+ alert( "property get: " & vblf & "Property::Attributes : " & struct2.Attributes & _
+ vblf & " Property::Handle : " & struct2.Handle & vblf & " Property::Name : " _
+ & struct2.Name)
+ end select
+end sub
+
+sub printArray( arr)
+ document.write "array: "
+ For Each val In arr
+ document.write CStr(val) & " "
+ Next
+end sub
+
+// print a 2 dimensional Array
+
+sub printArray2( arr)
+ elements1= UBound( arr, 1) - LBound( arr, 1) +1
+ elements2= UBound( arr, 2) - LBound( arr, 2) +1
+
+ For i=0 To elements1 -1
+ document.write( "array " & CStr( i) & ": " )
+ For j=0 To elements2 -1
+ document.write CStr( arr(i,j))
+ Next
+ document.write( "<br>")
+ Next
+end sub
+
+sub printArrayEx( pre, post, array)
+ document.write pre
+ printArray array
+ document.write post
+end sub
+</script>
+
+<script language="JScript">
+var arFunctions= new Array();
+arFunctions["methodByte"]= "sequence&lt;byte&gt; methodByte( [in] sequence&lt;byte&gt; aSeq )";
+arFunctions["methodFloat"]= "sequence&lt;float&gt; methodFloat( [in] sequence&lt;float&gt; aSeq)";
+arFunctions["methodDouble"]= "sequence&lt;double&gt; methodDouble( [in] sequence&lt;double&gt; aSeq)";
+arFunctions["methodBool"]= "sequence&lt;boolean&gt; methodBool( [in] sequence&lt;boolean&gt; aSeq)";
+arFunctions["methodShort"]= "sequence&lt;short&gt; methodShort( [in] sequence&lt;short&gt; aSeq)";
+arFunctions["methodUShort"]= "sequence&lt;unsigned short&gt; methodUShort( [in] sequence&lt;unsigned short&gt; aSeq)";
+arFunctions["methodLong"]= "sequence&lt;long&gt; methodLong( [in] sequence&lt;long&gt; aSeq)";
+arFunctions["methodULong"]= "sequence&lt;unsigned long&gt; methodULong( [in] sequence&lt;unsigned long&gt; aSeq)";
+arFunctions["methodString"]= "sequence&lt;string&gt; methodString( [in] sequence&lt;string&gt; aSeq)";
+arFunctions["methodChar"]= "sequence&lt;char&gt; methodChar( [in] sequence&lt;char&gt; aSeq)";
+arFunctions["methodAny"]= "sequence&lt;any&gt; methodAny ( [in] sequence&lt;any&gt; aSeq)";
+arFunctions["methodXInterface"]= "sequence&lt;XInterface&gt; methodXInterface ( [in] sequence&lt;XInterface&gt; aSeq)";
+arFunctions["methodSequence"]= "sequence&lt; sequence &lt;long&gt; &gt; methodSequence( [in] sequence&lt; sequence&lt; long &gt; &gt; aSeq)";
+arFunctions["methodSequence2"]= "sequence&lt; sequence &lt;sequence &lt;long&gt; &gt; &gt; methodSequence2( [in] sequence&lt; sequence&lt; sequence&lt;long&gt; &gt; &gt; aSeq)";
+arFunctions["methodXEventListeners"]= "sequence&lt; com::sun::star::lang::XEventListener &gt; methodXEventListeners( [in] sequence&lt;com::sun::star::lang::XEventListener&gt; aSeq)";
+arFunctions["methodXEventListenersMul"]= "sequence&lt; sequence&lt; com::sun::star::lang::XEventListener &gt; &gt; methodXEventListenersMul( [in] sequence&lt; sequence&lt; com::sun::star::lang::XEventListener&gt; &gt; aSeq)";
+arFunctions["AttrByte"]="[attribute] sequence<byte> AttrByte";
+arFunctions["AttrFloat"]="[attribute] sequence<float> AttrFloat";
+arFunctions["AttrDouble"]="[attribute] sequence<double> AttrDouble";
+arFunctions["AttrBool"]="[attribute] sequence<boolean> AttrBool";
+arFunctions["AttrShort"]="[attribute] sequence<short> AttrShort";
+arFunctions["AttrUShort"]="[attribute] sequence<unsigned short> AttrUShort";
+arFunctions["AttrLong"]="[attribute] sequence<long> AttrLong";
+arFunctions["AttrULong"]="[attribute] sequence<unsigned long> AttrULong";
+arFunctions["AttrString"]="[attribute] sequence<string> AttrString";
+arFunctions["AttrChar"]="[attribute] sequence<char> AttrChar";
+arFunctions["AttrAny"]="[attribute] sequence<any> AttrAny";
+arFunctions["AttrSequence"]="[attribute] sequence< sequence<long> > AttrSequence";
+arFunctions["AttrSequence2"]="[attribute] sequence< sequence< sequence <long> > > AttrSequence2";
+arFunctions["AttrXInterface"]="[attribute] sequence< com::sun::star::uno::XInterface > AttrXInterface";
+
+arFunctions["testout_methodByte"]= " void testout_methodByte( [out] byte rOut )";
+arFunctions["testout_methodFloat"]= "void testout_methodFloat( [out] float rOut)";
+arFunctions["testout_methodDouble"]= "void testout_methodDouble( [out] double rOut)";
+arFunctions["testout_methodBool"]= "void testout_methodBool( [out] boolean rOut)";
+arFunctions["testout_methodShort"]= "void testout_methodShort( [out] short rOut)";
+arFunctions["testout_methodUShort"]= "void testout_methodUShort( [out] unsigned short rOut)";
+arFunctions["testout_methodLong"]= "void testout_methodLong( [out] long rOut)";
+arFunctions["testout_methodULong"]= "void testout_methodULong( [out] unsigned long rOut)";
+arFunctions["testout_methodString"]= "void testout_methodString( [out] string rOut)";
+arFunctions["testout_methodChar"]= "void testout_methodChar( [out] char rOut)";
+arFunctions["testout_methodAny"]= "void testout_methodAny( [out] any rOut)";
+arFunctions["testout_methodSequence"]= "void testout_methodSequence( [out] sequence< long > rOut)";
+arFunctions["testout_methodSequence2"]= "void testout_methodSequence2( [out] sequence < sequence< long > > rOut)";
+arFunctions["testout_methodXInterface"]= "void testout_methodXInterface( [out] com::sun::star::uno::XInterface rOut)";
+arFunctions["testout_methodMulParams1"]= "void testout_methodMulParams1( [out] long rout1, [out] long rout2)";
+arFunctions["testout_methodMulParams2"]= "void testout_methodMulParams2( [out] long rout1, [out] long rout2, [out] string rout3)";
+arFunctions["testout_methodMulParams3"]= "void testout_methodMulParams3( [in] string sin, [out] string sout)";
+arFunctions["testout_methodMulParams4"]= "void testout_methodMulParams4( [in] float in1, [out] float out1, [in] long in2, [out] long out2, [in] long in3)";
+arFunctions["testinout_methodByte"]="void testinout_methodByte( [inout] byte rOut )";
+arFunctions["testinout_methodFloat"]="void testinout_methodFloat( [inout] float rOut)";
+arFunctions["testinout_methodDouble"]="void testinout_methodDouble( [inout] double rOut)";
+arFunctions["testinout_methodBool"]="void testinout_methodBool( [inout] boolean rOut)";
+arFunctions["testinout_methodShort"]="void testinout_methodShort( [inout] short rOut)";
+arFunctions["testinout_methodUShort"]="void testinout_methodUShort( [inout] unsigned short rOut)";
+arFunctions["testinout_methodLong"]="void testinout_methodLong( [inout] long rOut)";
+arFunctions["testinout_methodULong"]="void testinout_methodULong( [inout] unsigned long rOut)";
+arFunctions["testinout_methodString"]="void testinout_methodString( [inout] string rOut)";
+arFunctions["testinout_methodChar"]="void testinout_methodChar( [inout] char rOut)";
+arFunctions["testinout_methodAny"]="void testinout_methodAny( [inout] any rOut)";
+arFunctions["testinout_methodSequence"]="void testinout_methodSequence( [inout] sequence< long > rOut)";
+arFunctions["testinout_methodSequence2"]="void testinout_methodSequence2( [inout] sequence < sequence< long > > rOut)";
+arFunctions["testinout_methodXInterface"]="void testinout_methodXInterface( [inout] com::sun::star::script::XInvocation rOut)";
+arFunctions["testinout_methodXInterface2"]="void testinout_methodXInterface2( [inout] com::sun::star::uno::XInterface rOut)";
+
+arFunctions["in_methodByte"]= "byte in_methodByte( [in] byte rIn )";
+arFunctions["in_methodFloat"]= "float in_methodFloat( [in] float rIn);"
+arFunctions["in_methodDouble"]= "double in_methodDouble( [in] double rIn)";
+arFunctions["in_methodBool"]= "boolean in_methodBool( [in] boolean rIn)";
+arFunctions["in_methodShort"]= "short in_methodShort( [in] short rIn)";
+arFunctions["in_methodUShort"]= "unsigned short in_methodUShort( [in] unsigned short rIn)";
+arFunctions["in_methodLong"]= "long in_methodLong( [in] long rIn)";
+arFunctions["in_methodULong"]= "unsigned long in_methodULong( [in] unsigned long rIn)";
+arFunctions["in_methodHyper"]= "hyper in_methodHyper( [in] hyper rIn)";
+arFunctions["in_methodUHyper"]= "unsigned hyper in_methodHyper( [in] unsigned hyper rIn)";
+arFunctions["in_methodString"]= "string in_methodString( [in] string rIn)";
+arFunctions["in_methodChar"]= "char in_methodChar( [in] char rIn)";
+arFunctions["in_methodAny"]= "any in_methodAny ( [in] any rIn)";
+arFunctions["in_methodXInterface"]= "XInterface in_methodXInterface([in] XInterface rIn)";
+
+
+arFunctions["methodAnyTest1"]="any methodAnyTest1( [in] any rIn)";
+arFunctions["AttrAny2"]= "[attribute] any AttrAny2";
+arFunctions["retMethodStruct"]= "com::sun::star::beans::Property retMethodStruct()";
+arFunctions["AttrStruct"]= "[attribute] com::sun::star::beans::Property AttrStruct";
+arFunctions["methodStruct2"]= "com::sun::star::beans::Property methodStruct2( [in] com::sun::star::beans::Property aProp)";
+
+
+var factory= new ActiveXObject("com.sun.star.ServiceManager");
+var oletest= factory.createInstance("oletest.OleTest");
+
+Log= new Logger();
+
+
+runJScriptTest(Log);
+runVBTest(Log);
+Log.summarize();
+
+
+function Logger()
+{
+ this.print= logger_print;
+ this.print2= logger_print2;
+ this.summarize= logger_summarize;
+ this.bAllOk= true;
+}
+function logger_print( bool, method)
+{
+ this.print2(bool, "Ok &nbsp;&nbsp;&nbsp;&nbsp;" + arFunctions[method] + "<br>",
+ "Failed &nbsp;&nbsp;&nbsp;&nbsp;" + arFunctions[method] + "<br>");
+}
+
+function logger_print2( bool, okString, failedString)
+{
+ if( bool)
+ document.writeln( okString);
+ else
+ {
+ document.writeln( failedString);
+ this.bAllOk= this.bAllOk && false;
+ }
+}
+
+function logger_summarize()
+{
+ document.writeln("<p> ==============================================================================<br>");
+ if(this.bAllOk)
+ document.writeln("No errors <br>");
+ else
+ document.writeln("Error ! The test failed! <br>");
+}
+
+
+</script>
+
+</body>
+</html>
+
+
diff --git a/extensions/test/ole/StarBasic_OleClient/oleclient.bas b/extensions/test/ole/StarBasic_OleClient/oleclient.bas
new file mode 100644
index 000000000000..7ba324660dfe
--- /dev/null
+++ b/extensions/test/ole/StarBasic_OleClient/oleclient.bas
@@ -0,0 +1,609 @@
+REM ***** BASIC *****
+
+
+OPTION EXPLICIT
+OPTION COMPATIBLE
+
+Sub Main
+COMPATIBILITYMODE(true)
+
+If runtest = -1 Then
+ MsgBox "Test Failed!!!"
+Else
+ MsgBox "Test Succeeded"
+End If
+
+End Sub
+
+Function runtest() As Integer
+Dim inBool As Boolean, inBool2 As Boolean, outBool As Boolean
+Dim inByte As Integer, inByte2 As Integer
+Dim inShort As Integer, inShort2 As Integer
+Dim inLong As Long, inLong2 As Long, inLong3 As Long, inLong4 As Long
+Dim inString As String, inString2 As String
+Dim inFloat As Single, inFloat2 As Single
+Dim inDouble As Double, inDouble2 As Double
+Dim inVariant, inVariant2
+Dim inAr, inAr2
+Dim inDate As Date,inDate2 As Date, outDate As Date
+Dim inCurrency As Currency, inCurrency2 As Currency, outCurrency As Currency
+Dim inSCode As New com.sun.star.bridge.oleautomation.SCode
+Dim inSCode2 As New com.sun.star.bridge.oleautomation.SCode
+Dim inDecimal As Variant, inDecimal2 As Variant, outDecimal As Variant
+Dim inrefDecimal As Variant, outrefDecimal As Variant
+Dim outSCode As New com.sun.star.bridge.oleautomation.SCode
+Dim outByte As Integer
+Dim outShort As Integer
+Dim outLong, outLong2 As Long
+Dim outString As String
+Dim outFloat As Single
+Dim outDouble As Double
+Dim outVariant
+'bug #109936 causes an errOr when outObject is used As out param
+Dim inObject As Object, inObject2 As Object, outObject As Object
+Dim objNOTHING As Object
+Dim inUnknown As Object, inUnknown2 As Object, outUnknown As Object
+
+Dim inArray, outArray, outArray2
+Dim len1, len2
+Dim arString(1) As String
+arString(0)= "String one"
+arString(1)= "String two"
+
+Dim factory As Object
+factory= createUnoService("com.sun.star.bridge.OleObjectFactory")
+Dim obj As Object
+obj= factory.createInstance("AxTestComponents.Basic")
+
+Dim objFoo As Object
+objFoo = factory.createInstance("AxTestComponents.Foo")
+
+
+'in parameter -------------------------------------------------------------------
+inBool = true
+inByte = 10
+inShort = 11
+inLong = 111
+inString = "Hello World"
+inFloat = 3.14
+inDouble = 3.145
+inVariant = "bla"
+inDate = NOW()
+inCurrency = 12345.6789
+inSCode.Value = &h80020004
+inDecimal = CDec("-9223372036854775808") 'lowest int64
+
+obj.inBool(inBool)
+obj.inByte(inByte)
+obj.inShort(inShort)
+obj.inLong(inLong)
+obj.inString(inString)
+obj.inFloat(inFloat)
+obj.inDouble(inDouble)
+obj.inVariant(inVariant)
+'obj.prpString= "a string property"
+obj.inObject(obj)
+obj.inArray(arString())
+obj.inDate(inDate)
+obj.inCurrency(inCurrency)
+obj.inSCode(inSCode)
+obj.inUnknown(objFoo)
+obj.inDecimal(inDecimal)
+
+'out parameter -------------------------------------------------------------------------
+outBool = false
+obj.outBool(outBool)
+outByte = 0
+obj.outByte(outByte)
+outShort = 0
+obj.outShort(outShort)
+outLong = 0
+obj.outLong(outLong)
+outFloat = 0
+obj.outFloat(outFloat)
+outDouble = 0
+obj.outDouble(outDouble)
+outString = ""
+obj.outString(outString)
+outVariant = 0
+obj.outVariant(outVariant)
+outObject = NOTHING
+obj.outObject(outObject)
+outArray = 0
+obj.outArray(outArray)
+obj.outDate(outDate)
+obj.outCurrency(outCurrency)
+obj.outSCode(outSCode)
+obj.outUnknown(outUnknown)
+obj.outDecimal(outDecimal)
+
+
+If inBool <> outBool Or inByte <> outByte Or inShort <> outShort Or inLong <> outLong Or _
+ inFloat <> outFloat Or inDouble <> outDouble Or inString <> outString Or _
+ inVariant <> outVariant Or NOT equalUnoObjects(obj, outObject) Or NOT _
+ equalArrays(arString(), outArray()) Or inDate <> outDate Or inCurrency <> outCurrency Or _
+ inSCode.Value <> outSCode.Value Or Not equalUnoObjects(objFoo, outUnknown) Or _
+ inDecimal <> outDecimal Then
+ runtest = -1
+ exit Function
+End If
+
+
+'in-out parameter -------------------------------------------------------------
+'implementation of inout methods returns the previously set value in out param
+inBool = true
+inBool2 = inBool
+obj.inoutBool(inBool2)
+outBool = false
+obj.inoutBool(outBool)
+inByte = 10
+inByte2 = inByte
+obj.inoutByte(inByte2)
+outByte = 0
+obj.inoutByte(outByte)
+inShort = 10
+inShort2 = inShort
+obj.inShort(inShort2)
+outShort = 0
+obj.inoutShort(outShort)
+inLong = 10
+inLong2 = inLong
+obj.inoutLong(inLong2)
+outLong = 0
+obj.inoutLong(outLong)
+inFloat = 3.14
+inFloat2 = inFloat
+obj.inoutFloat(inFloat2)
+outFloat = 0
+obj.inoutFloat(outFloat)
+inDouble= 3.14
+inDouble2 = inDouble
+obj.inoutDouble(inDouble2)
+outDouble = 0
+obj.inoutDouble(outDouble)
+inString = "in"
+inString2 = inString
+obj.inoutString(inString2)
+outString = ""
+obj.inoutString(outString)
+inVariant = "in"
+inVariant2 = inVariant
+obj.inoutVariant(inVariant2)
+outVariant = 0
+obj.inoutVariant(outVariant)
+inObject = factory.createInstance("AxTestComponents.Basic")
+inObject2 = inObject
+obj.inoutObject(inObject2)
+outObject = NOTHING
+obj.inoutObject(outObject)
+inAr = arString()
+inAr2 = inAr
+obj.inoutArray(inAr2)
+outArray = 0
+obj.outArray(outArray())
+inDate = NOW()
+inDate2 = inDate
+obj.inoutDate(inDate2)
+outDate = 0
+obj.inoutDate(outDate)
+inCurrency = 1234.5678
+inCurrency2 = inCurrency
+obj.inoutCurrency(inCurrency2)
+outCurrency = 0
+obj.inoutCurrency(outCurrency)
+inSCode.Value = &h80020004
+inSCode2 = inSCode
+obj.inoutSCode(inSCode2)
+outSCode.Value = 0
+obj.inoutSCode(outSCode)
+inUnknown = objFoo
+inUnknown2 = inUnknown
+obj.inoutUnknown(inUnknown2)
+outUnknown = Nothing
+obj.inoutUnknown(outUnknown)
+inDecimal = CDec("18446744073709551615") 'highest positiv value of unsigne int64
+inDecimal2 = inDecimal
+obj.inoutDecimal(inDecimal2)
+outDecimal = 0
+obj.inoutDecimal(outDecimal)
+
+If inBool <> outBool Or inByte <> outByte Or inShort <> outShort Or inLong <> outLong Or _
+ inFloat <> outFloat Or inDouble <> outDouble Or inString <> outString Or _
+ inVariant <> outVariant Or NOT equalUnoObjects(inObject, outObject) Or _
+ NOT equalArrays(inAr, outArray) Or inDate <> outDate Or inCurrency <> outCurrency Or _
+ inSCode.Value <> outSCode.Value Or Not equalUnoObjects(inUnknown, outUnknown) Or _
+ inDecimal <> outDecimal Then
+ runtest = -1
+ Exit Function
+End If
+
+'properties -------------------------------------------------------------------------
+inBool = false
+outBool = true
+obj.prpBool = inBool
+outBool = obj.prpBool
+inByte = 11
+outByte = 0
+obj.prpByte = inByte
+outByte= obj.prpByte
+inShort = 127
+outShort = 0
+obj.prpShort= inShort
+outShort= obj.prpShort
+inLong = 1000
+outLong = 0
+obj.prpLong = inLong
+outLong= obj.prpLong
+inFloat = 3.14
+outFloat = 0
+obj.prpFloat = inFloat
+outFloat= obj.prpFloat
+inDouble = 3.123
+outDouble = 0
+obj.prpDouble = inDouble
+outDouble= obj.prpDouble
+inString = "bla"
+outString = ""
+obj.prpString = inString
+outString = obj.prpString
+inObject = obj
+outObject = objNOTHING
+obj.prpObject = inObject
+outObject = obj.prpObject
+inVariant = "bla"
+outVariant = 0
+obj.prpVariant = inVariant
+outVariant= obj.prpVariant
+inArray = arString()
+outArray = 0
+obj.prpArray = inArray()
+outArray= obj.prpArray
+inDate = NOW()
+outDate = 0
+obj.prpDate = inDate
+outDate = obj.prpDate
+inCurrency = 1234.5678
+outCurrency = 0
+obj.prpCurrency = inCurrency
+outCurrency = obj.prpCurrency
+inSCode.Value = &h80020004
+outSCode.Value = 0
+obj.prpSCode = inSCode
+outSCode = obj.prpSCode
+inUnknown = objFoo
+outUnknown= Nothing
+obj.prpUnknown = inUnknown
+outUnknown = obj.prpUnknown
+inDecimal = CDec("18446744073709551615")' highest unsigned int64
+outDecimal = 0
+obj.prpDecimal = inDecimal
+outDecimal = obj.prpDecimal
+
+If inBool <> outBool Or inByte <> outByte Or inShort <> outShort Or inLong <> outLong Or _
+ inFloat <> outFloat Or inDouble <> outDouble Or inString <> outString Or _
+ inVariant <> outVariant Or NOT equalUnoObjects(inObject, outObject) Or _
+ NOT equalArrays(inArray, outArray) Or inDate <> outDate Or inCurrency <> outCurrency Or _
+ inSCode.Value <> outSCode.Value Or Not equalUnoObjects(inUnknown, outUnknown) Or _
+ inDecimal <> outDecimal Then
+ runtest = -1
+ Exit Function
+End If
+
+' ref parameter ------------------------------------------------------------------------
+obj.inLong(0)
+inLong = 123
+outLong = 0
+obj.inLong(0)
+obj.inrefLong(inLong)
+obj.outLong(outLong)
+inVariant = "bla"
+outVariant = 0
+obj.inVariant(0)
+obj.inrefVariant(inVariant)
+obj.outVariant(outVariant)
+If inLong <> outLong Or inVariant <> outVariant Then
+ runtest = -1
+ Exit Function
+End If
+
+outLong = 0
+obj.prprefLong = inLong
+outLong = obj.prprefLong
+outVariant = 0
+obj.prprefVariant = inVariant
+outVariant = obj.prprefVariant
+If inLong <> outLong Or inVariant <> outVariant Then
+ runtest = -1
+ Exit Function
+End If
+
+
+'vararg --------------------------------------------------------------------------------
+inLong=1
+inLong2 = 2
+inLong3 = 3
+obj.varargfunc1(inLong)
+outArray = 0
+outLong = 0
+obj.varargfunc2(outLong, outArray)
+If inLong <> outLong Then
+ runtest = -1
+ Exit Function
+End If
+len1 = UBound(outArray) - LBound(outArray) +1
+If len1 <> 0 Then
+ runtest = -1
+ Exit Function
+End If
+outArray = 0
+obj.varargfunc1(inLong, inLong2, inLong3)
+obj.varargfunc2(outLong, outArray)
+len1 = UBound(outArray) - LBound(outArray) +1
+If len1 <> 2 Or outArray(0) <> inLong2 Or outArray(1) <> inLong3 Then
+ runtest = -1
+ Exit Function
+End If
+
+
+'defaultvalue ---------------------------------------------------------------------------
+inLong = 0
+inFloat = 0
+inVariant = 0
+inVariant2 = 0
+'defaults are: 1, 2, 4
+'The third parameter is a VARIANT with a default value of 4. COM gives it the type BSTR
+obj.defaultvalue1()
+obj.defaultvalue2(inLong, inFloat, inVariant)
+If inLong <> 1 Or inFloat <> 2 Or inVariant <> "4" Then
+ runtest = -1
+ Exit Function
+End If
+inLong = 10
+inFloat = 11
+inLong2 = inLong
+inFloat2 = inFloat
+inVariant = 0
+inVariant = 0
+obj.defaultvalue1(inLong, inFloat)
+obj.defaultvalue2(inLong, inFloat, inVariant)
+If inLong <> inLong2 Or inFloat <> inFloat2 Or inVariant <> "4" Then
+ runtest = -1
+ Exit Function
+End If
+
+'optional parameters ----------------------------------------------------------------
+inLong = 100
+outLong = 0
+obj.optional1(inLong)
+obj.optional2(outLong)
+If inLong <> outLong Then
+ runtest = -1
+ Exit Function
+End If
+
+inLong2 = 101
+outLong2 = 0
+obj.optional1(inLong, inLong2)
+obj.optional2(outLong, outLong2)
+If inLong <> outLong AND inLong2 <> outLong2 Then
+ runtest = -1
+ Exit Function
+End If
+
+inLong2 = 101
+outLong2 = 0
+obj.optional1(inLong, inLong2)
+obj.optional1(inLong)
+obj.optional2(outLong, outLong2)
+If inLong <> outLong AND inLong2 <> outLong2 Then
+ runtest = -1
+ Exit Function
+End If
+
+inLong = 10
+inLong2 = 100
+outLong = 5
+outLong2 = 6
+obj.optional3()
+obj.optional3(inLong, inLong2)
+obj.optional4(outLong, outLong2) 'outLong = 10, outLong2 = 100
+If inLong <> outLong AND inLong2 <> outLong2 Then
+ runtest = -1
+ Exit Function
+End If
+inLong = 10
+inLong2 = 100
+inLong3 = inLong
+inLong4 = inLong2
+obj.optional4(inLong, inLong)
+outLong = 0
+outLong2 = 0
+obj.optional5(outLong, outLong2)
+If inLong3 <> outLong AND inLong4 <> outLong2 Then
+ runtest = -1
+ Exit Function
+End If
+
+inLong = 10
+outLong = 5
+obj.optional3(inLong)
+obj.optional4(outLong)
+If inLong <> outLong Then
+ runtest = -1
+ Exit Function
+End If
+inLong = 10
+inLong2 = inLong
+outLong = 0
+obj.optional4(inLong)
+obj.optional5(outLong)
+If inLong2 <> outLong Then
+ runtest = -1
+ Exit Function
+End If
+
+'named arguments-------------------------------------------------------------------------
+'all args As named args, different order
+obj.optional6(0, 0, 0, 0)
+inLong = 1
+inLong2 = 2
+inLong3 = 3
+inLong4 = 4
+obj.optional6(val4:= inLong4, val3:=inLong3, val2:=inLong2, val1:= inLong)
+Dim outLong3 As Long
+Dim outLong4 As Long
+outLong = 0
+outLong2 = 0
+outLong3 = 0
+outLong4 = 0
+obj.optional7(outLong, outLong2, outLong3, outLong4)
+If inLong <> outLong Or inLong2 <> outLong2 _
+ Or inLong3 <> outLong3 Or inLong4 <> outLong4 Then
+ runtest = -1
+ Exit Function
+End If
+
+'mixed positional and named args with omitted args
+Dim scode_paramNotFound As New com.sun.star.bridge.oleautomation.SCode
+scode_paramNotFound.Value = &h80020004
+
+obj.optional6(0, 0, 0, 0)
+'val1 and val3 will be DISP_E_PARAMNOTFOUND
+obj.optional6(, inLong2, val4:=inLong4)
+Dim outSCode1, outSCode2
+obj.optional7(outSCode, outLong2, outSCode2, outLong4)
+If outSCode.Value <> scode_paramNotFound.Value Or inLong2 <> outLong2 _
+ Or outSCode2.Value <> scode_paramNotFound.Value Or inLong4 <> outLong4 Then
+ runtest = -1
+ Exit Function
+End If
+
+'mixed positional and named args with ommitted args as out -args
+inLong = 1
+inLong2 = 2
+inLong3 = 3
+inLong4 = 4
+obj.optional6(inLong, inLong2, inLong3, inLong4)
+outLong2 = 0
+outLong3 = 0
+obj.optional7(,outLong2, val3:= outLong3)
+If inLong2 <> outLong2 Or inLong3 <> outLong3 Then
+ runtest = -1
+ Exit Function
+End If
+
+'test properties with additional arguments ------------------------------------
+inLong = 10
+inLong2 = 20
+inLong3 = 30
+outLong = 0
+outLong2 = 0
+outLong3 = 0
+obj.prpMultiArg1(0,0) = 0
+'obj.prpMultiArg1 = 0
+obj.prpMultiArg1(inLong,inLong2) = inLong3
+outLong3 = obj.prpMultiArg1(outLong, outLong2)
+If outLong <> 10 Or outLong2 <> 02 Or outLong3 <> 30 Then
+ runtest = -1
+ Exit Function
+End If
+
+outLong = 0
+outLong2 = 0
+obj.prpMultiArg1(0,0) = 0
+obj.prpMultiArg1(1) = 3
+outLong2 = obj.prpMultiArg1(outLong)
+If outLong <> 1 Or outLong2 <> 3 Then
+ runtest = -1
+ Exit Function
+End If
+
+outLong = 0
+outLong2 = 0
+obj.prpMultiArg1(0,0) = 0
+obj.prpMultiArg1(val2:= 1) = 3
+outLong2 = obj.prpMultiArg1(val2:=outLong)
+If outLong <> 1 Or outLong2 <> 3 Then
+ runtest = -1
+ Exit Function
+End If
+
+outLong = -1
+outLong2 = -1
+obj.prpMultiArg2(0) = 0
+outLong = obj.prpMultiArg2GetValues(outLong, outLong2)
+If outLong <> 0 Or outLong2 <> 0 Then
+ runtest = -1
+ Exit Function
+End If
+
+
+outLong = 0
+outLong2 = 0
+obj.prpMultiArg2(1) = 2
+obj.prpMultiArg2GetValues(outLong, outLong2)
+If outLong <> 1 Or outLong2 <> 2 Then
+ runtest = -1
+ Exit Function
+End If
+
+
+
+' other tests ------------------------------------------------------------------
+obj.inObject(NOTHING)
+outObject = NOTHING
+'bridge should return an XInterface any with null pointer
+'A basic errOr should occur if this is not the case
+obj.outObject(outObject)
+
+If Not IsNull(outObject) Then
+ runtest = -1
+ Exit Function
+End If
+'Decimal passed by reference
+inrefDecimal = CDec("9223372036854775807") 'highest positiv value of int64
+obj.inrefDecimal(inrefDecimal)
+outrefDecimal = 0
+obj.outDecimal(outrefDecimal)
+If inrefDecimal <> outrefDecimal Then
+ runtest = -1
+ Exit Function
+End If
+
+' Test Automation object with dual interfaces ------------------------------------
+dim dispatcher as object
+dim oExplorer as object
+dispatcher = createUnoService("com.sun.star.bridge.OleObjectFactory")
+oExplorer = dispatcher.createInstance("InternetExplorer.Application")
+If Not IsNull(oExplorer) Then
+ oExplorer.visible = true
+ oExplorer.Navigate2("http://www.openoffice.org")
+Else
+ MsgBox("Could not perform test with Internet Explorer!")
+End If
+
+
+End Function
+
+'One dimensional arrays with simple types.
+'lower bound must be 0
+Function equalArrays(ar1, ar2)
+Dim len1
+Dim len2
+len1 = UBound(ar1) - LBound(ar1) + 1
+len2 = UBound(ar2) - LBound(ar2) + 1
+If len1 <> len2 Then
+ equalArrays = false
+ Exit Function
+End If
+Dim counter
+FOr counter = 0 To len1 - 1
+ If ar1(counter) <> ar2(counter) Then
+ equalArrays = false
+ Exit Function
+ End If
+Next
+equalArrays = true
+End Function
+
+
diff --git a/extensions/test/ole/StarBasic_OleClient/readme.txt b/extensions/test/ole/StarBasic_OleClient/readme.txt
new file mode 100644
index 000000000000..2eca8aac3272
--- /dev/null
+++ b/extensions/test/ole/StarBasic_OleClient/readme.txt
@@ -0,0 +1,10 @@
+oleclient.bas is a StarBasic script that uses the
+"com.sun.star.bridge.OleObjectFactory" service to instantiate
+the ActiveX component "AxTestComponents.Basic" and calls
+functions on it.
+
+------------------------------------------------------------
+Requirements:
+
+ActiveX component: AxTestComponent.Basic must be registered.
+It is contained in extensions/test/ole/AxTestComponents
diff --git a/extensions/test/ole/VisualBasic/AssemblyInfo.vb b/extensions/test/ole/VisualBasic/AssemblyInfo.vb
new file mode 100644
index 000000000000..e663aa549ebe
--- /dev/null
+++ b/extensions/test/ole/VisualBasic/AssemblyInfo.vb
@@ -0,0 +1,33 @@
+Imports System.Reflection
+Imports System.Runtime.CompilerServices
+Imports System.Runtime.InteropServices
+
+' General Information about an assembly is controlled through the following
+' set of attributes. Change these attribute values to modify the information
+' associated with an assembly.
+
+
+' TODO: Review the values of the assembly attributes
+
+
+<Assembly: AssemblyTitle("")>
+<Assembly: AssemblyDescription("")>
+<Assembly: AssemblyCompany("StarOffice")>
+<Assembly: AssemblyProduct("")>
+<Assembly: AssemblyCopyright("")>
+<Assembly: AssemblyTrademark("")>
+<Assembly: AssemblyCulture("")>
+
+' Version information for an assembly consists of the following four values:
+
+' Major version
+' Minor Version
+' Build Number
+' Revision
+
+' You can specify all the values or you can default the Build and Revision Numbers
+' by using the '*' as shown below:
+
+<Assembly: AssemblyVersion("1.0.*")>
+
+
diff --git a/extensions/test/ole/VisualBasic/Module1.vb b/extensions/test/ole/VisualBasic/Module1.vb
new file mode 100644
index 000000000000..364af636585f
--- /dev/null
+++ b/extensions/test/ole/VisualBasic/Module1.vb
@@ -0,0 +1,853 @@
+Option Strict Off
+Option Explicit On
+Module Module1
+
+Private objServiceManager As Object
+Private objCoreReflection As Object
+Private objOleTest As Object
+Private objEventListener As Object
+'General counter
+Dim i As Integer
+Dim j As Integer
+Dim sError As String
+Dim outHyper, inHyper, retHyper As Object
+
+Public Sub Main()
+ objServiceManager = CreateObject("com.sun.star.ServiceManager")
+ objCoreReflection = objServiceManager.createInstance("com.sun.star.reflection.CoreReflection")
+ ' extensions/test/ole/cpnt
+ objOleTest = objServiceManager.createInstance("oletest.OleTest")
+ ' extensions/test/ole/EventListenerSample/VBEventListener
+ objEventListener = CreateObject("VBasicEventListener.VBEventListener")
+ Debug.Print(TypeName(objOleTest))
+
+
+ testBasics()
+ testHyper()
+ testAny()
+ testObjects()
+ testGetStruct()
+ ''dispose not working i103353
+ 'testImplementedInterfaces()
+ testGetValueObject()
+ testArrays()
+ testProps()
+
+ End Sub
+ Function testProps() As Object
+
+ Dim aToolbarItemProp1 As Object
+ aToolbarItemProp1 = objOleTest.Bridge_GetStruct("com.sun.star.beans.PropertyValue")
+ Dim aToolbarItemProp2 As Object
+ aToolbarItemProp2 = objOleTest.Bridge_GetStruct("com.sun.star.beans.PropertyValue")
+ Dim aToolbarItemProp3 As Object
+ aToolbarItemProp3 = objOleTest.Bridge_GetStruct("com.sun.star.beans.PropertyValue")
+ Dim properties(2) As Object
+
+ aToolbarItemProp1.Name = "CommandURL"
+ aToolbarItemProp1.Value = "macro:///standard.module1.TestIt"
+ aToolbarItemProp2.Name = "Label"
+ aToolbarItemProp2.Value = "Test"
+ aToolbarItemProp3.Name = "Type"
+ aToolbarItemProp3.Value = 0
+
+ properties(0) = aToolbarItemProp1
+ properties(1) = aToolbarItemProp2
+ properties(2) = aToolbarItemProp3
+
+
+ Dim dummy(-1) As Object
+
+ Dim Desktop As Object
+ Desktop = objServiceManager.createInstance("com.sun.star.frame.Desktop")
+ Dim Doc As Object
+ Doc = Desktop.loadComponentFromURL("private:factory/swriter", "_blank", 2, dummy)
+ Dim LayoutManager As Object
+ LayoutManager = Doc.currentController.Frame.LayoutManager
+
+ LayoutManager.createElement("private:resource/toolbar/user_toolbar1")
+ LayoutManager.showElement("private:resource/toolbar/user_toolbar1")
+ Dim ToolBar As Object
+ ToolBar = LayoutManager.getElement("private:resource/toolbar/user_toolbar1")
+ Dim settings As Object
+ settings = ToolBar.getSettings(True)
+
+ 'the changes are here:
+ Dim aany As Object
+ aany = objServiceManager.Bridge_GetValueObject()
+ Call aany.Set("[]com.sun.star.beans.PropertyValue", properties)
+ Call settings.insertByIndex(0, aany)
+ Call ToolBar.setSettings(settings)
+
+
+ End Function
+
+
+ Function testBasics() As Object
+ ' In Parameter, simple types
+ '============================================
+ Dim tmpVar As Object
+ Dim ret As Object
+ Dim outByte, inByte, retByte As Byte
+ Dim outBool, inBool, retBool As Boolean
+ Dim outShort, inShort, retShort As Short
+ Dim outUShort, inUShort, retUShort As Short
+ Dim outLong, inLong, retLong As Integer
+ Dim outULong, inULong, retULong As Integer
+ Dim outHyper, inHyper, retHyper As Object
+ Dim outUHyper, inUHyper, retUHyper As Object
+ Dim outFloat, inFloat, retFloat As Single
+ Dim outDouble, inDouble, retDouble As Double
+ Dim outString, inString, retString As String
+ Dim retChar, inChar, outChar, retChar2 As Short
+ Dim outCharAsString, inCharAsString, retCharAsString As String
+ Dim outAny, inAny, retAny As Object
+ Dim outType, inType, retType As Object
+ Dim outXInterface, inXInterface, retXInterface As Object
+ Dim outXInterface2, inXInterface2, retXInterface2 As Object
+
+
+ Dim outVarByte As Object
+ Dim outVarBool As Object
+ Dim outVarShort As Object
+ Dim outVarUShort As Object
+ Dim outVarLong As Object
+ Dim outVarULong As Object
+ Dim outVarFloat As Object
+ Dim outVarDouble As Object
+ Dim outVarString As Object
+ Dim outVarChar As Object
+ Dim outVarAny As Object
+ Dim outVarType As Object
+
+ inByte = 10
+ inBool = True
+ inShort = -10
+ inUShort = -100
+ inLong = -1000
+ inHyper = CDec("-9223372036854775808") 'lowest int64
+ inUHyper = CDec("18446744073709551615") ' highest unsigned int64
+ inULong = 10000
+ inFloat = 3.14
+ inDouble = 3.14
+ inString = "Hello World!"
+ inChar = 65
+ inCharAsString = "A"
+ inAny = "Hello World"
+ inType = objServiceManager.Bridge_CreateType("[]long")
+ inXInterface = objCoreReflection
+ inXInterface2 = objEventListener
+
+ retByte = objOleTest.in_methodByte(inByte)
+ retBool = objOleTest.in_methodBool(inBool)
+ retShort = objOleTest.in_methodShort(inShort)
+ retUShort = objOleTest.in_methodUShort(inUShort)
+ retLong = objOleTest.in_methodLong(inLong)
+ retULong = objOleTest.in_methodULong(inULong)
+ retHyper = objOleTest.in_methodHyper(inHyper)
+ retUHyper = objOleTest.in_methodUHyper(inUHyper)
+ retFloat = objOleTest.in_methodFloat(inFloat)
+ retDouble = objOleTest.in_methodDouble(inDouble)
+ retString = objOleTest.in_methodString(inString)
+ retChar = objOleTest.in_methodChar(inChar)
+ retChar2 = objOleTest.in_methodChar(inCharAsString)
+ retAny = objOleTest.in_methodAny(inAny)
+ retType = objOleTest.in_methodType(inType)
+ retXInterface = objOleTest.in_methodXInterface(inXInterface) ' UNO object
+ retXInterface2 = objOleTest.in_methodXInterface(inXInterface2)
+
+ If retByte <> inByte Or retBool <> inBool Or retShort <> inShort Or retUShort <> inUShort _
+ Or retLong <> inLong Or retULong <> inULong Or retHyper <> inHyper _
+ Or retUHyper <> inUHyper Or retFloat <> inFloat Or retDouble <> inDouble _
+ Or retString <> inString Or retChar <> inChar Or retChar2 <> Asc(inCharAsString) _
+ Or retAny <> inAny Or Not (retType.Name = inType.Name) _
+ Or inXInterface IsNot retXInterface Or inXInterface2 IsNot retXInterface2 Then
+ sError = "in - parameter and return value test failed"
+ MsgBox(sError)
+
+ End If
+
+ 'Out Parameter simple types
+ '================================================
+
+
+ objOleTest.testout_methodByte(outByte)
+ objOleTest.testout_methodFloat(outFloat)
+ objOleTest.testout_methodDouble(outDouble)
+ objOleTest.testout_methodBool(outBool)
+ objOleTest.testout_methodShort(outShort)
+ objOleTest.testout_methodUShort(outUShort)
+ objOleTest.testout_methodLong(outLong)
+ objOleTest.testout_methodULong(outULong)
+ objOleTest.testout_methodHyper(outHyper)
+ objOleTest.testout_methodUHyper(outUHyper)
+ objOleTest.testout_methodString(outString)
+ objOleTest.testout_methodChar(outChar)
+ 'outCharAsString is a string. Therfore the returned sal_Unicode value of 65 will be converted
+ 'to a string "65"
+ objOleTest.testout_methodChar(outCharAsString)
+ objOleTest.testout_methodAny(outAny)
+ objOleTest.testout_methodType(outType)
+ 'objOleTest.in_methodXInterface (inXInterface) ' UNO object
+ Call objOleTest.in_methodXInterface(inXInterface) ' UNO object
+ objOleTest.testout_methodXInterface(outXInterface)
+ Call objOleTest.in_methodXInterface(inXInterface2) ' COM object
+ objOleTest.testout_methodXInterface(outXInterface2)
+
+ If outByte <> inByte Or outFloat <> inFloat Or outDouble <> inDouble _
+ Or outBool <> inBool Or outShort <> inShort Or outUShort <> inUShort _
+ Or outLong <> inLong Or outULong <> inULong Or outHyper <> inHyper _
+ Or outUHyper <> inUHyper Or outString <> inString Or outChar <> inChar _
+ Or Not (outCharAsString = "65") Or outAny <> inAny _
+ Or Not (outType.Name = inType.Name) Or inXInterface IsNot outXInterface _
+ Or inXInterface2 IsNot outXInterface2 Then
+
+ sError = "out - parameter test failed!"
+ MsgBox(sError)
+ End If
+
+ 'Out Parameter simple types (VARIANT var)
+ '====================================================
+ objOleTest.testout_methodByte(outVarByte)
+ objOleTest.testout_methodBool(outVarBool)
+ objOleTest.testout_methodChar(outVarChar)
+ objOleTest.testout_methodShort(outVarShort)
+ objOleTest.testout_methodUShort(outVarUShort)
+ objOleTest.testout_methodLong(outVarLong)
+ objOleTest.testout_methodULong(outVarULong)
+ objOleTest.testout_methodString(outVarString)
+ objOleTest.testout_methodFloat(outVarFloat)
+ objOleTest.testout_methodDouble(outVarDouble)
+ objOleTest.testout_methodAny(outVarAny)
+ objOleTest.testout_methodType(outVarType)
+
+ If outVarByte <> inByte Or outVarBool <> inBool Or outVarChar <> inChar _
+ Or outVarShort <> inShort Or outVarUShort <> inUShort _
+ Or outVarLong <> inLong Or outVarULong <> inULong Or outVarString <> inString _
+ Or outVarFloat <> inFloat Or outVarDouble <> inDouble Or outVarAny <> inAny _
+ Or Not (outVarType.Name = inType.Name) Then
+ sError = "out - parameter (VARIANT) test failed!"
+ MsgBox(sError)
+ End If
+
+ 'In/Out simple types
+ '============================================
+ objOleTest.in_methodByte(0)
+ objOleTest.in_methodBool(False)
+ objOleTest.in_methodShort(0)
+ objOleTest.in_methodUShort(0)
+ objOleTest.in_methodLong(0)
+ objOleTest.in_methodULong(0)
+ objOleTest.in_methodHyper(0)
+ objOleTest.in_methodUHyper(0)
+ objOleTest.in_methodFloat(0)
+ objOleTest.in_methodDouble(0)
+ objOleTest.in_methodString(0)
+ objOleTest.in_methodChar(0)
+ objOleTest.in_methodAny(0)
+ objOleTest.in_methodType(objServiceManager.Bridge_CreateType("boolean"))
+ outXInterface = Nothing
+ Call objOleTest.in_methodXInterface(outXInterface)
+
+ outByte = 10
+ retByte = outByte
+ objOleTest.testinout_methodByte(retByte)
+ objOleTest.testinout_methodByte(retByte)
+ outBool = True
+ retBool = outBool
+ objOleTest.testinout_methodBool(retBool)
+ objOleTest.testinout_methodBool(retBool)
+ outShort = 10
+ retShort = outShort
+ objOleTest.testinout_methodShort(retShort)
+ objOleTest.testinout_methodShort(retShort)
+ outUShort = 20
+ retUShort = outUShort
+ objOleTest.testinout_methodUShort(retUShort)
+ objOleTest.testinout_methodUShort(retUShort)
+ outLong = 30
+ retLong = outLong
+ objOleTest.testinout_methodLong(retLong)
+ objOleTest.testinout_methodLong(retLong)
+ outULong = 40
+ retULong = outULong
+ objOleTest.testinout_methodULong(retLong)
+ objOleTest.testinout_methodULong(retLong)
+ outHyper = CDec("9223372036854775807") 'highest positiv value of int64
+ retHyper = outHyper
+ objOleTest.testinout_methodHyper(retHyper)
+ objOleTest.testinout_methodHyper(retHyper)
+ outUHyper = CDec("18446744073709551615") 'highest value of unsigned int64
+ retUHyper = outUHyper
+ objOleTest.testinout_methodUHyper(retUHyper)
+ objOleTest.testinout_methodUHyper(retUHyper)
+ outFloat = 3.14
+ retFloat = outFloat
+ objOleTest.testinout_methodFloat(retFloat)
+ objOleTest.testinout_methodFloat(retFloat)
+ outDouble = 4.14
+ retDouble = outDouble
+ objOleTest.testinout_methodDouble(retDouble)
+ objOleTest.testinout_methodDouble(retDouble)
+ outString = "Hello World!"
+ retString = outString
+ objOleTest.testinout_methodString(retString)
+ objOleTest.testinout_methodString(retString)
+ outChar = 66
+ retChar = outChar
+ objOleTest.testinout_methodChar(retChar)
+ objOleTest.testinout_methodChar(retChar)
+ outCharAsString = "H"
+ retCharAsString = outCharAsString
+ objOleTest.testinout_methodChar(retCharAsString)
+ objOleTest.testinout_methodChar(retCharAsString)
+ outAny = "Hello World 2!"
+ retAny = outAny
+ objOleTest.testinout_methodAny(retAny)
+ objOleTest.testinout_methodAny(retAny)
+ outType = objServiceManager.Bridge_CreateType("long")
+ retType = outType
+ objOleTest.testinout_methodType(retType)
+ objOleTest.testinout_methodType(retType)
+
+ outXInterface = objCoreReflection
+ retXInterface = outXInterface
+ objOleTest.testinout_methodXInterface2(retXInterface)
+
+ If outByte <> retByte Or outBool <> retBool Or outShort <> retShort _
+ Or outUShort <> retUShort Or outLong <> retLong Or outULong <> retULong _
+ Or outHyper <> retHyper Or outUHyper <> outUHyper _
+ Or outFloat <> retFloat Or outDouble <> retDouble _
+ Or outString <> retString Or outChar <> retChar _
+ Or outCharAsString <> retCharAsString _
+ Or outAny <> retAny Or Not (outType.Name = retType.Name) _
+ Or outXInterface IsNot retXInterface Then
+ sError = "in/out - parameter test failed!"
+ MsgBox(sError)
+ End If
+
+ 'Attributes
+ objOleTest.AByte = inByte
+ retByte = 0
+ retByte = objOleTest.AByte
+ objOleTest.AFloat = inFloat
+ retFloat = 0
+ retFloat = objOleTest.AFloat
+ objOleTest.AType = inType
+ retType = Nothing
+
+ retType = objOleTest.AType
+
+ If inByte <> retByte Or inFloat <> retFloat Or Not (inType.Name = retType.Name) Then
+ sError = "Attributes - test failed!"
+ MsgBox(sError)
+ End If
+
+ End Function
+ Function testHyper() As Object
+
+ '======================================================================
+ ' Other Hyper tests
+ Dim emptyVar As Object
+ Dim retAny As Object
+
+ retAny = emptyVar
+ inHyper = CDec("9223372036854775807") 'highest positiv value of int64
+ retAny = objOleTest.in_methodAny(inHyper)
+ sError = "hyper test failed"
+ If inHyper <> retAny Then
+ MsgBox(sError)
+ End If
+ inHyper = CDec("-9223372036854775808") 'lowest negativ value of int64
+ retAny = objOleTest.in_methodAny(inHyper)
+
+ If inHyper <> retAny Then
+ MsgBox(sError)
+ End If
+ inHyper = CDec("18446744073709551615") 'highest positiv value of unsigne int64
+ retAny = objOleTest.in_methodAny(inHyper)
+
+ If inHyper <> retAny Then
+ MsgBox(sError)
+ End If
+ inHyper = CDec(-1)
+ retAny = objOleTest.in_methodAny(inHyper)
+ If inHyper <> retAny Then
+ MsgBox(sError)
+ End If
+ inHyper = CDec(0)
+ retAny = objOleTest.in_methodAny(inHyper)
+ If inHyper <> retAny Then
+ MsgBox(sError)
+ End If
+
+ '==============================================================================
+
+
+ End Function
+ Function testAny() As Object
+ Dim outVAr As Object
+
+ 'Any test. We pass in an any as value object. If it is not correct converted
+ 'then the target component throws a RuntimeException
+ Dim lengthInAny As Integer
+
+ lengthInAny = 10
+ Dim seqLongInAny(10) As Integer
+ For i = 0 To lengthInAny - 1
+ seqLongInAny(i) = i + 10
+ Next
+ Dim anySeqLong As Object
+ anySeqLong = objOleTest.Bridge_GetValueObject()
+ anySeqLong.Set("[]long", seqLongInAny)
+ Dim anySeqRet As Object
+ Err.Clear()
+ On Error Resume Next
+ anySeqRet = objOleTest.other_methodAny(anySeqLong, "[]long")
+
+ If Err.Number <> 0 Then
+ MsgBox("error")
+ End If
+ End Function
+
+ Function testObjects() As Object
+ ' COM obj
+ Dim outVAr As Object
+ Dim retObj As Object
+ 'OleTest receives a COM object that implements XEventListener
+ 'OleTest then calls a disposing on the object. The object then will be
+ 'asked if it has been called
+ objEventListener.setQuiet(True)
+ objEventListener.resetDisposing()
+ retObj = objOleTest.in_methodInvocation(objEventListener)
+ Dim ret As Object
+ ret = objEventListener.disposingCalled
+ If ret = False Then
+ MsgBox("Error")
+ End If
+
+ 'The returned object should be objEventListener, test it by calling disposing
+ ' takes an IDispatch as Param ( EventObject).To provide a TypeMismatch
+ 'we put in another IDispatch
+ retObj.resetDisposing()
+ retObj.disposing(objEventListener)
+ If retObj.disposingCalled = False Then
+ MsgBox("Error")
+ End If
+
+ ' out param gives out the OleTestComponent
+ 'objOleTest.testout_methodXInterface retObj
+ 'outVAr = Null
+ 'retObj.testout_methodAny outVAr
+ 'Debug.Print "test out Interface " & CStr(outVAr)
+ 'If outVAr <> "I am a string in an any" Then
+ ' MsgBox "error"
+ 'End If
+
+
+ 'in out
+ ' in: UNO object, the same is expected as out param
+ ' the function expects OleTest as parameter and sets a value
+
+ Dim myAny As Object
+
+
+
+ Dim objOleTest2 As Object
+ objOleTest2 = objServiceManager.createInstance("oletest.OleTest")
+ 'Set a value
+ objOleTest2.AttrAny2 = "VBString "
+
+ 'testinout_methodXInterfaces substitutes the argument with the object set in in_methodXInterface
+ objOleTest.AttrAny2 = "VBString this string was written in the UNO component to the inout pararmeter"
+ objOleTest.in_methodXInterface(objOleTest)
+ objOleTest.testinout_methodXInterface2(objOleTest2)
+ Dim tmpVar As Object
+ tmpVar = System.DBNull.Value
+ tmpVar = objOleTest2.AttrAny2
+ Debug.Print("in: Uno out: the same object // " & CStr(tmpVar))
+ If tmpVar <> "VBString this string was written in the UNO component to the inout pararmeter" Then
+ MsgBox("error")
+ End If
+
+
+ 'create a struct
+ Dim structClass As Object
+ structClass = objCoreReflection.forName("oletest.SimpleStruct")
+ Dim structInstance As Object
+ structClass.CreateObject(structInstance)
+ structInstance.message = "Now we are in VB"
+ Debug.Print("struct out " & structInstance.message)
+ If structInstance.message <> "Now we are in VB" Then
+ MsgBox("error")
+ End If
+
+ 'put the struct into OleTest. The same struct will be returned with an added String
+ Dim structRet As Object
+ structRet = objOleTest.in_methodStruct(structInstance)
+ Debug.Print("struct in - return " & structRet.message)
+ If structRet.message <> "Now we are in VBThis string was set in OleTest" Then
+ MsgBox("error")
+ End If
+
+
+ End Function
+ Function testGetStruct() As Object
+ 'Bridge_GetStruct
+ '========================================================
+ Dim objDocument As Object
+ objDocument = createHiddenDocument()
+ 'dispose not working i103353
+ 'objDocument.dispose()
+ objDocument.close(True)
+ End Function
+
+ Function testImplementedInterfaces() As Object
+ 'Bridge_ImplementedInterfaces
+ '=================================================
+ ' call an UNO function that takes an XEventListener interface
+ 'We provide a COM implementation (IDispatch) as EventListener
+ 'Open a new empty writer document
+
+ Dim objDocument As Object
+ objDocument = createHiddenDocument()
+ objEventListener.resetDisposing()
+ objDocument.addEventListener(objEventListener)
+ objDocument.dispose()
+ If objEventListener.disposingCalled = False Then
+ MsgBox("Error")
+ End If
+ End Function
+
+ Function testGetValueObject() As Object
+ 'Bridge_GetValueObject
+ '==================================================
+ Dim objVal As Object
+ objVal = objOleTest.Bridge_GetValueObject()
+ Dim arrByte(9) As Byte
+ Dim countvar As Integer
+ For countvar = 0 To 9
+ arrByte(countvar) = countvar
+ Next countvar
+
+ objVal.Set("[]byte", arrByte)
+ Dim ret As Object
+ ret = 0
+ ret = objOleTest.methodByte(objVal)
+ 'Test if ret is the same array
+
+ Dim key As Object
+ key = 0
+ For Each key In ret
+ If ret(key) <> arrByte(key) Then
+ MsgBox("Error")
+ End If
+ Debug.Print(ret(key))
+ Next key
+
+ Dim outByte As Byte
+ outByte = 77
+ Dim retByte As Byte
+ retByte = outByte
+ objVal.InitInOutParam("byte", retByte)
+ objOleTest.testinout_methodByte(objVal)
+ objVal.InitInOutParam("byte", retByte)
+ objOleTest.testinout_methodByte(objVal)
+
+ ret = 0
+ ret = objVal.Get()
+ Debug.Print(ret)
+ If ret <> outByte Then
+ MsgBox("error")
+ End If
+
+ objVal.InitOutParam()
+ Dim inChar As Short
+ inChar = 65
+ objOleTest.in_methodChar(inChar)
+ objOleTest.testout_methodChar(objVal) 'Returns 'A' (65)
+ ret = 0
+ ret = objVal.Get()
+ Debug.Print(ret)
+ If ret <> inChar Then
+ MsgBox("error")
+ End If
+
+ End Function
+
+ Function testArrays() As Object
+ 'Arrays
+ '========================================
+ Dim arrLong(2) As Integer
+ Dim arrObj(2) As Object
+ Dim countvar As Integer
+ For countvar = 0 To 2
+ arrLong(countvar) = countvar + 10
+ Debug.Print(countvar)
+ arrObj(countvar) = CreateObject("VBasicEventListener.VBEventListener")
+ arrObj(countvar).setQuiet(True)
+ Next
+
+ 'Arrays always contain VARIANTS
+ Dim seq() As Object
+ seq = objOleTest.methodLong(arrLong)
+
+ For countvar = 0 To 2
+ Debug.Print(CStr(seq(countvar)))
+ If arrLong(countvar) <> seq(countvar) Then
+ MsgBox("error")
+ End If
+ Next
+ seq = objOleTest.methodXInterface(arrObj)
+ Dim tmp As Object
+ For countvar = 0 To 2
+ seq(countvar).resetDisposing()
+ seq(countvar).disposing(CObj(tmp))
+ If seq(countvar).disposingCalled = False Then
+ MsgBox("Error")
+ End If
+ Next
+
+ 'Array containing interfaces (element type is VT_DISPATCH)
+ Dim arEventListener(2) As Object
+ For countvar = 0 To 2
+ arEventListener(countvar) = CreateObject("VBasicEventListener.VBEventListener")
+ arEventListener(countvar).setQuiet(True)
+ Next
+
+ 'The function calls disposing on the listeners
+ seq = objOleTest.methodXEventListeners(arEventListener)
+ Dim count As Object
+ For countvar = 0 To 2
+ If arEventListener(countvar).disposingCalled = False Then
+ MsgBox("Error")
+ End If
+ Next
+ 'Array containing interfaces (element type is VT_VARIANT which contains VT_DISPATCH
+ Dim arEventListener2(2) As Object
+ For countvar = 0 To 2
+ arEventListener2(countvar) = CreateObject("VBasicEventListener.VBEventListener")
+ arEventListener2(countvar).setQuiet(True)
+ Next
+ seq = objOleTest.methodXEventListeners(arEventListener2)
+ For countvar = 0 To 2
+ If arEventListener2(countvar).disposingCalled = False Then
+ MsgBox("Error")
+ End If
+ Next
+
+ 'Variant containing Array containing interfaces (element type is VT_VARIANT which contains VT_DISPATCH
+ Dim arEventListener3(2) As Object
+ Dim var As Object
+ For countvar = 0 To 2
+ arEventListener3(countvar) = CreateObject("VBasicEventListener.VBEventListener")
+ arEventListener3(countvar).setQuiet(True)
+ Next
+ Dim varContAr As Object
+ varContAr = VB6.CopyArray(arEventListener3)
+ seq = objOleTest.methodXEventListeners(varContAr)
+ For countvar = 0 To 2
+ If arEventListener3(countvar).disposingCalled = False Then
+ MsgBox("Error")
+ End If
+ Next
+
+ 'Get a sequence created in UNO, out param is Variant ( VT_BYREF|VT_VARIANT)
+ Dim seqX As Object
+
+ objOleTest.testout_methodSequence(seqX)
+ Dim key As Object
+ For Each key In seqX
+ Debug.Print(CStr(seqX(key)))
+ If seqX(key) <> key Then
+ MsgBox("error")
+ End If
+ Next key
+ 'Get a sequence created in UNO, out param is array Variant ( VT_BYREF|VT_VARIANT|VT_ARRAY)
+ Dim seqX2() As Object
+ objOleTest.testout_methodSequence(seqX2)
+
+ For Each key In seqX2
+ Debug.Print(CStr(seqX2(key)))
+ Next key
+
+ 'pass it to UNO and get it back
+ Dim seq7() As Object
+ seq7 = objOleTest.methodLong(seqX)
+ Dim key2 As Object
+ For Each key2 In seq7
+ Debug.Print(CStr(seq7(key2)))
+ If seqX2(key) <> key Then
+ MsgBox("error")
+ End If
+ Next key2
+
+ 'array with starting index != 0
+ Dim seqIndex(2) As Integer
+ Dim seq8() As Object
+ Dim longVal1, longVal2 As Integer
+ longVal1 = 1
+ longVal2 = 2
+ seqIndex(1) = longVal1
+ seqIndex(2) = longVal2
+ 'The bridge returns a Safearray of Variants. It does not yet convert to an _
+ 'array of a particular type!
+ 'Comparing of elements from seq8 (Object) with long values worked without _
+ 'explicit cast as is necessary in VS 2008. Also arrays in VS 2008 start at _
+ 'index 0
+ seq8 = objOleTest.methodLong(seqIndex)
+ If longVal1 <> CInt(seq8(1)) And longVal2 <> CInt(seq8(2)) Then
+ MsgBox("error")
+ End If
+
+ 'in out Array
+ ' arrLong is Long Array
+ Dim inoutVar(2) As Object
+
+ For countvar = 0 To 2
+ inoutVar(countvar) = countvar + 10
+ Next
+
+ objOleTest.testinout_methodSequence(inoutVar)
+
+ countvar = 0
+ For countvar = 0 To 2
+ Debug.Print(CStr(inoutVar(countvar)))
+ If inoutVar(countvar) <> countvar + 11 Then
+ MsgBox("error")
+ End If
+ Next
+
+ 'Multidimensional array
+ '============================================================
+ ' Sequence< Sequence<long> > methodSequence( Sequence< Sequence long> >)
+ ' Real multidimensional array Array
+ ' 9 is Dim 1 (least significant) with C API
+ Dim mulAr(9, 1) As Integer
+ For i = 0 To 1
+ For j = 0 To 9
+ mulAr(j, i) = i * 10 + j
+ Next j
+ Next i
+
+ Dim resMul As Object
+ resMul = objOleTest.methodSequence(mulAr)
+
+ Dim countDim1 As Integer
+ Dim countDim2 As Integer
+ Dim arr As Object
+ For countDim2 = 0 To 1
+ arr = resMul(countDim2)
+ For countDim1 = 0 To 9
+ Debug.Print(arr(countDim1))
+ If arr(countDim1) <> mulAr(countDim1, countDim2) Then
+ MsgBox("Error Multidimensional Array")
+ End If
+ Next countDim1
+ Next countDim2
+ IsArray(resMul)
+
+ 'Array of VARIANTs containing arrays
+ Dim mulAr2(1) As Object
+ Dim arr2(9) As Integer
+ For i = 0 To 1
+ ' Dim arr(9) As Long
+ For j = 0 To 9
+ arr2(j) = i * 10 + j
+ Next j
+ mulAr2(i) = VB6.CopyArray(arr2)
+ Next i
+
+ resMul = 0
+ resMul = objOleTest.methodSequence(mulAr2)
+ arr = 0
+ Dim tmpVar As Object
+ For countDim2 = 0 To 1
+ arr = resMul(countDim2)
+ tmpVar = mulAr2(countDim2)
+ For countDim1 = 0 To 9
+ Debug.Print(arr(countDim1))
+ If arr(countDim1) <> tmpVar(countDim1) Then
+ MsgBox("Error Multidimensional Array")
+ End If
+ Next countDim1
+ Next countDim2
+
+ 'Array containing interfaces (element type is VT_DISPATCH)
+ Dim arArEventListener(1, 2) As Object
+ For i = 0 To 1
+ For j = 0 To 2
+ arArEventListener(i, j) = CreateObject("VBasicEventListener.VBEventListener")
+ arArEventListener(i, j).setQuiet(True)
+ Next
+ Next
+ 'The function calls disposing on the listeners
+ seq = objOleTest.methodXEventListenersMul(arArEventListener)
+ For i = 0 To 1
+ For j = 0 To 2
+ If arArEventListener(i, j).disposingCalled = False Then
+ MsgBox("Error")
+ End If
+ Next
+ Next
+
+ 'Array containing interfaces (element type is VT_VARIANT containing VT_DISPATCH)
+ Dim arArEventListener2(1, 2) As Object
+ For i = 0 To 1
+ For j = 0 To 2
+ arArEventListener2(i, j) = CreateObject("VBasicEventListener.VBEventListener")
+ arArEventListener2(i, j).setQuiet(True)
+ Next
+ Next
+ 'The function calls disposing on the listeners
+ seq = objOleTest.methodXEventListenersMul(arArEventListener2)
+ For i = 0 To 1
+ For j = 0 To 2
+ If arArEventListener2(i, j).disposingCalled = False Then
+ MsgBox("Error")
+ End If
+ Next
+ Next
+
+ ' SAFEARRAY of VARIANTS containing SAFEARRAYs
+ 'The ultimate element type is VT_DISPATCH ( XEventListener)
+ Dim arEventListener4(1) As Object
+ Dim seq1(2) As Object
+ Dim seq2(2) As Object
+ For i = 0 To 2
+ seq1(i) = CreateObject("VBasicEventListener.VBEventListener")
+ seq2(i) = CreateObject("VBasicEventListener.VBEventListener")
+ seq1(i).setQuiet(True)
+ seq2(i).setQuiet(True)
+ Next
+ arEventListener4(0) = VB6.CopyArray(seq1)
+ arEventListener4(1) = VB6.CopyArray(seq2)
+ 'The function calls disposing on the listeners
+ seq = objOleTest.methodXEventListenersMul(arEventListener4)
+ For i = 0 To 2
+ If seq1(i).disposingCalled = False Or seq2(i).disposingCalled = False Then
+ MsgBox("Error")
+ End If
+ Next
+
+ End Function
+
+ Function createHiddenDocument() As Object
+ 'Try to create a hidden document
+ Dim objPropValue As Object
+ objPropValue = objOleTest.Bridge_GetStruct("com.sun.star.beans.PropertyValue")
+ 'Set the members. If this fails then there is an Error
+ objPropValue.Name = "Hidden"
+ objPropValue.Handle = -1
+ objPropValue.Value = True
+
+ 'create a hidden document
+ 'Create the Desktop
+ Dim objDesktop As Object
+ objDesktop = objServiceManager.createInstance("com.sun.star.frame.Desktop")
+ 'Open a new empty writer document
+ Dim args(0) As Object
+ args(0) = objPropValue
+ createHiddenDocument = objDesktop.loadComponentFromURL("private:factory/swriter", "_blank", 0, args)
+ End Function
+End Module
diff --git a/extensions/test/ole/VisualBasic/Project1.sln b/extensions/test/ole/VisualBasic/Project1.sln
new file mode 100644
index 000000000000..ffff24e8d5d5
--- /dev/null
+++ b/extensions/test/ole/VisualBasic/Project1.sln
@@ -0,0 +1,20 @@
+
+Microsoft Visual Studio Solution File, Format Version 10.00
+# Visual Studio 2008
+Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "Project1", "Project1.vbproj", "{F62D440E-8976-4A6D-91A8-89F09701074F}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {F62D440E-8976-4A6D-91A8-89F09701074F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {F62D440E-8976-4A6D-91A8-89F09701074F}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {F62D440E-8976-4A6D-91A8-89F09701074F}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {F62D440E-8976-4A6D-91A8-89F09701074F}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
diff --git a/extensions/test/ole/VisualBasic/Project1.vbproj b/extensions/test/ole/VisualBasic/Project1.vbproj
new file mode 100644
index 000000000000..213d5928ca97
--- /dev/null
+++ b/extensions/test/ole/VisualBasic/Project1.vbproj
@@ -0,0 +1,90 @@
+<Project DefaultTargets="Build" ToolsVersion="3.5" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <ProjectType>Local</ProjectType>
+ <MyType>WindowsFormsWithCustomSubMain</MyType>
+ <ProductVersion>9.0.21022</ProductVersion>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{F62D440E-8976-4A6D-91A8-89F09701074F}</ProjectGuid>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <AssemblyName>Project1</AssemblyName>
+ <OutputType>WinExe</OutputType>
+ <StartupObject>Project1.Module1</StartupObject>
+ <AssemblyMajorVersion>1</AssemblyMajorVersion>
+ <AssemblyMinorVersion>0</AssemblyMinorVersion>
+ <AssemblyRevisionNumber>0</AssemblyRevisionNumber>
+ <GenerateRevisionNumber>False</GenerateRevisionNumber>
+ <AssemblyCompanyName>StarOffice</AssemblyCompanyName>
+ <RootNamespace>Project1</RootNamespace>
+ <FileUpgradeFlags>
+ </FileUpgradeFlags>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <OutputPath>.\bin\</OutputPath>
+ <DocumentationFile>Project1.xml</DocumentationFile>
+ <DebugSymbols>True</DebugSymbols>
+ <DefineDebug>True</DefineDebug>
+ <DefineTrace>True</DefineTrace>
+ <DefineConstants>Win32=True</DefineConstants>
+ <PlatformTarget>x86</PlatformTarget>
+ <NoWarn>42016,42017,42018,42019,42032</NoWarn>
+ <DebugType>full</DebugType>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <OutputPath>.\bin\</OutputPath>
+ <DocumentationFile>Project1.xml</DocumentationFile>
+ <DebugSymbols>False</DebugSymbols>
+ <DefineDebug>False</DefineDebug>
+ <DefineTrace>True</DefineTrace>
+ <DefineConstants>Win32=True</DefineConstants>
+ <PlatformTarget>x86</PlatformTarget>
+ <NoWarn>42016,42017,42018,42019,42032</NoWarn>
+ <DebugType>none</DebugType>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="Microsoft.VisualBasic.Compatibility">
+ <Name>Microsoft.VisualBasic.Compatibility</Name>
+ </Reference>
+ <Reference Include="System">
+ <Name>System</Name>
+ </Reference>
+ <Reference Include="System.Data">
+ <Name>System.Data</Name>
+ </Reference>
+ <Reference Include="System.Drawing">
+ <Name>System.Drawing</Name>
+ </Reference>
+ <Reference Include="System.Windows.Forms">
+ <Name>System.Windows.Forms</Name>
+ </Reference>
+ <Reference Include="System.XML">
+ <Name>System.XML</Name>
+ </Reference>
+ </ItemGroup>
+ <ItemGroup>
+ <Import Include="Microsoft.VisualBasic" />
+ <Import Include="Microsoft.VisualBasic.Compatibility" />
+ <Import Include="System" />
+ <Import Include="System.Collections" />
+ <Import Include="System.Data" />
+ <Import Include="System.Diagnostics" />
+ <Import Include="System.Drawing" />
+ <Import Include="System.Windows.Forms" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="AssemblyInfo.vb" />
+ <Compile Include="Module1.vb">
+ <SubType>Code</SubType>
+ </Compile>
+ </ItemGroup>
+ <ItemGroup>
+ <Folder Include="My Project\" />
+ </ItemGroup>
+ <Import Project="$(MSBuildBinPath)\Microsoft.VisualBasic.targets" />
+ <PropertyGroup>
+ <PreBuildEvent>
+ </PreBuildEvent>
+ <PostBuildEvent>
+ </PostBuildEvent>
+ </PropertyGroup>
+</Project> \ No newline at end of file
diff --git a/extensions/test/ole/VisualBasic/readme.txt b/extensions/test/ole/VisualBasic/readme.txt
new file mode 100644
index 000000000000..0b18430fca7e
--- /dev/null
+++ b/extensions/test/ole/VisualBasic/readme.txt
@@ -0,0 +1,18 @@
+Runs a test written in VisualBasic. If no error message appears then the test was ok.
+
+Requirements:
+Installed office
+Component oletest.Oletest (extensions/test/ole/cpnt)
+Component VBasicEventListener.VBEventListener (extensions/test/ole/EventListenerSample/VBEventListener
+
+
+OleTest is a UNO component. It needs to be registered with the office rdb. Also there are additional
+types (oletest.rdb in wntmsci7/bin/) which must be merged with the rdb.
+VBEventListener is an ActiveX component. The directory contains a Visual Basic Project and also
+the binary VBasicEventListener.dll. This is necessary because the dll contains the type library
+which is needed by VB. Otherwise VB would generate a new CLSID on a new build.
+The dll must be registered on the system. This is done by
+regsvr32 VBasicEventListener.dll
+or
+by a rebuild of the project.
+
diff --git a/extensions/test/ole/callUnoToJava.htm b/extensions/test/ole/callUnoToJava.htm
new file mode 100644
index 000000000000..fdc690d7ebfb
--- /dev/null
+++ b/extensions/test/ole/callUnoToJava.htm
@@ -0,0 +1,538 @@
+<HTML>
+<HEAD>
+<META NAME="GENERATOR" Content="Microsoft Developer Studio">
+<META HTTP-EQUIV="Content-Type" content="text/html; charset=iso-8859-1">
+<TITLE>Document Title</TITLE>
+</HEAD>
+<BODY id=theBody>
+
+<script language="JScript">
+function callOleTest( id)
+{
+ var factory= new ActiveXObject("com.sun.star.ServiceManager");
+ var oletest= factory.createInstance("oletest.OleTest");
+// alert(oletest);
+
+ switch( id)
+ {
+ case 1: // Test simple call of JScript object function from UNO
+ oletest.testInterface( new XCallback_Impl, 1);
+ break;
+
+ case 2:
+ // return value is the parameter object
+ oletest.testInterface( new XCallback_Impl, 2);
+ break;
+ //##################################################
+ // OUT parameter
+ //##################################################
+ case 3: // Test out parameter of type interface
+ oletest.testInterface( new XCallback_Impl, 3);
+ break;
+ case 4: // Test out parameter of type struct
+ oletest.testInterface( new XCallback_Impl, 4);
+ break;
+ case 5: // Test out parameter of type enum
+ oletest.testInterface( new XCallback_Impl, 5);
+ break;
+ case 6: // Test out parameter of type sequence<any>
+ oletest.testInterface( new XCallback_Impl, 6);
+ break;
+ case 7: // Test out parameter of type any
+ oletest.testInterface( new XCallback_Impl, 7);
+ break;
+ case 8: // Test out parameter of type bool
+ oletest.testInterface( new XCallback_Impl, 8);
+ break;
+ case 9: // Test out parameter of type char
+ oletest.testInterface( new XCallback_Impl, 9);
+ break;
+ case 10: // Test out parameter of type string
+ oletest.testInterface( new XCallback_Impl, 10);
+ break;
+ case 11: // Test out parameter of type float
+ oletest.testInterface( new XCallback_Impl, 11);
+ break;
+ case 12: // Test out parameter of type double
+ oletest.testInterface( new XCallback_Impl, 12);
+ break;
+ case 13: // Test out parameter of type byte
+ oletest.testInterface( new XCallback_Impl, 13);
+ break;
+ case 14: // Test out parameter of type short
+ oletest.testInterface( new XCallback_Impl, 14);
+ break;
+ case 15: // Test out parameter of type long
+ oletest.testInterface( new XCallback_Impl, 15);
+ break;
+ case 30: // outValuesMixed
+ oletest.testInterface( new XCallback_Impl, 30);
+ break;
+ case 31: // outValuesAll
+ oletest.testInterface( new XCallback_Impl, 31);
+ break;
+ //##################################################
+ // IN/OUT parameter
+ //##################################################
+
+ case 100: // inoutInterface
+ oletest.testInterface( new XCallback_Impl, 100);
+ break;
+ case 101: // inoutStruct
+ oletest.testInterface( new XCallback_Impl, 101);
+ break;
+ case 102: // inoutEnum
+ oletest.testInterface( new XCallback_Impl, 102);
+ break;
+ case 103: // inoutSeqAny
+ oletest.testInterface( new XCallback_Impl, 103);
+ break;
+ case 104: // inoutAny
+ oletest.testInterface( new XCallback_Impl, 104);
+ break;
+ case 105: // inoutBool
+ oletest.testInterface( new XCallback_Impl, 105);
+ break;
+ case 106: // inoutChar
+ oletest.testInterface( new XCallback_Impl, 106);
+ break;
+ case 107: // inoutString
+ oletest.testInterface( new XCallback_Impl, 107);
+ break;
+ case 108: // inoutFloat
+ oletest.testInterface( new XCallback_Impl, 108);
+ break;
+ case 109: // inoutDouble
+ oletest.testInterface( new XCallback_Impl, 109);
+ break;
+ case 110: // inoutByte
+ oletest.testInterface( new XCallback_Impl, 110);
+ break;
+ case 111: // inoutShort
+ oletest.testInterface( new XCallback_Impl, 111);
+ break;
+ case 112: // inoutLong
+ oletest.testInterface( new XCallback_Impl, 112);
+ break;
+ case 120: // inoutValuesAll
+ oletest.testInterface( new XCallback_Impl, 120);
+ break;
+ case 200: // inValues
+ oletest.testInterface( new XCallback_Impl, 200);
+ break;
+
+ // Call a COM object that has not been passed as parameter to a UNO component and
+ // hence no type information are available in the COM wrapper
+// case 300:
+ //##################################################
+ // Attributes
+ //##################################################
+ case 400:
+ oletest.testInterface( new XCallback_Impl, 400);
+ break;
+
+ case 1000:
+ oletest.testInterface2(new MultiInterface(), 0);
+ break;
+ }
+
+}
+
+
+
+// The class --------------------------------------------
+
+function XCallback_Impl()
+{
+
+ // XCallback
+ this._environment= "JScript";
+
+ this.func1= XCallback_Impl_func1;
+ this.returnInterface= XCallback_Impl_returnInterface;
+ // #################################################
+ // OUT parameter
+ //###################################################
+ this.outInterface= XCallback_Impl_outInterface;
+ this.outStruct= XCallback_Impl_outStruct;
+ this.outEnum= XCallback_Impl_outEnum;
+ this.outSeqAny= XCallback_Impl_outSeqAny;
+ this.outAny= XCallback_Impl_outAny;
+ this.outBool= XCallback_Impl_outBool;
+ this.outChar= XCallback_Impl_outChar;
+ this.outString= XCallback_Impl_outString;
+ this.outFloat= XCallback_Impl_outFloat;
+ this.outDouble= XCallback_Impl_outDouble;
+ this.outByte= XCallback_Impl_outByte;
+ this.outShort= XCallback_Impl_outShort;
+ this.outLong= XCallback_Impl_outLong;
+ this.outValuesMixed= XCallback_Impl_outValuesMixed;
+ this.outValuesAll= XCallback_Impl_outValuesAll;
+ // #################################################
+ // IN/ OUT parameter
+ //###################################################
+ this.inoutInterface= XCallback_Impl_inoutInterface;
+ this.inoutStruct= XCallback_Impl_inoutStruct;
+ this.inoutEnum= XCallback_Impl_inoutEnum;
+ this.inoutSeqAny= XCallback_Impl_inoutSeqAny;
+ this.inoutAny= XCallback_Impl_inoutAny;
+ this.inoutBool= XCallback_Impl_inoutBool;
+ this.inoutChar= XCallback_Impl_inoutChar;
+ this.inoutString= XCallback_Impl_inoutString;
+ this.inoutFloat= XCallback_Impl_inoutFloat;
+ this.inoutDouble= XCallback_Impl_inoutDouble;
+ this.inoutByte= XCallback_Impl_inoutByte;
+ this.inoutShort= XCallback_Impl_inoutShort;
+ this.inoutLong= XCallback_Impl_inoutLong;
+ this.inoutValuesAll= XCallback_Impl_inoutValuesAll;
+ // #################################################
+ // IN parameter
+ //##################################################
+ this.inValues= XCallback_Impl_inValues;
+
+ // #################################################
+ // Attributes
+ //##################################################
+ this.simple= new XSimple_Impl();
+
+
+}
+
+
+function XCallback_Impl_func1()
+{
+ alert("XCallback_Impl_func1");
+}
+function XCallback_Impl_returnInterface()
+{
+ alert("XCallback::returnInterface called");
+ return new XSimple_Impl();
+}
+
+function XCallback_Impl_outInterface( outVal)
+{
+ outVal[0]= new XSimple_Impl();
+}
+
+function XCallback_Impl_outLong( outVal)
+{
+ alert("outLong");
+}
+function XCallback_Impl_outStruct( outVal)
+{
+ var factory= new ActiveXObject("com.sun.star.ServiceManager");
+ var starCoreReflection = factory.createInstance("com.sun.star.reflection.CoreReflection");
+ var structClass = starCoreReflection.forName("oletest.SimpleStruct");
+ var outParam= new Array();
+ structClass.createObject(outParam);
+ var aStruct= outParam[0];
+ aStruct.message= "a Struct created in JScript";
+ outVal[0]= aStruct;
+
+}
+function XCallback_Impl_outEnum( outVal)
+{
+ outVal[0]= 2;
+}
+function XCallback_Impl_outSeqAny( outVal)
+{
+ var ar= new Array(1,2,3);
+ outVal[0]= ar;
+}
+function XCallback_Impl_outAny( outVal)
+{
+ outVal[0]= "this is an Any";
+}
+function XCallback_Impl_outBool( outVal)
+{
+ outVal[0]= true;
+}
+function XCallback_Impl_outChar( outVal)
+{
+ outVal[0]= "a";
+}
+function XCallback_Impl_outString( outVal)
+{
+ outVal[0]= "This string was created in JScript";
+}
+function XCallback_Impl_outFloat( outVal)
+{
+ outVal[0]= 3.14;
+}
+function XCallback_Impl_outDouble( outVal)
+{
+ outVal[0]= 3.145;
+}
+function XCallback_Impl_outByte( outVal)
+{
+ outVal[0]= 100;
+}
+function XCallback_Impl_outShort( outVal)
+{
+ outVal[0]= 1000;
+}
+function XCallback_Impl_outLong( outVal)
+{
+ outVal[0]= 1000000;
+}
+function XCallback_Impl_outValuesMixed( inLong, outLong, inString)
+{
+ alert("inVal long: " + inLong +" inString:" + inString);
+ outLong[0]= inLong + 1;
+}
+function XCallback_Impl_outValuesAll( xSimple, aSimpleStruct, aSimpleEnum, seqAny, aAny, aBool,
+ aChar, aString, aFloat, aDouble, aByte, aShort, aLong)
+{
+ this.outInterface( xSimple);
+ this.outStruct( aSimpleStruct);
+ this.outEnum( aSimpleEnum);
+ this.outSeqAny( seqAny);
+ this.outAny( aAny);
+ this.outBool( aBool);
+ this.outChar( aChar);
+ this.outString( aString);
+ this.outFloat( aFloat);
+ this.outDouble( aDouble);
+ this.outByte( aByte);
+ this.outShort( aShort);
+ this.outLong( aLong);
+}
+
+function XCallback_Impl_inoutInterface( val)
+{
+ val[0].func("calling on in parameter");
+ val[0]= new XSimple_Impl();
+}
+function XCallback_Impl_inoutStruct( val)
+{
+ alert( val[0].message);
+ val[0].message= "property message changed in JScript";
+}
+function XCallback_Impl_inoutEnum(val)
+{
+ alert("enum value +" + val);
+ val[0]= 2;
+}
+function XCallback_Impl_inoutSeqAny( val)
+{
+ var vbar = new VBArray(val[0]);
+ var seq= vbar.toArray();
+ alert( seq[0] +" "+seq[1] +" " +seq[2]);
+ val[0]= new Array("jscript1", "jscript2","jscript3");
+}
+function XCallback_Impl_inoutAny(val)
+{
+ alert( "JScript in any: " + val[0]);
+ val[0]= "a string from JScript";
+}
+function XCallback_Impl_inoutBool(val)
+{
+ alert( "JScript in bool: " + val[0]);
+ val[0]= true;
+}
+function XCallback_Impl_inoutChar(val)
+{
+ alert( "JScript in char: " + val[0]);
+ val[0]= 'b';
+}
+function XCallback_Impl_inoutString(val)
+{
+ alert( "JScript in string: " + val[0]);
+ val[0]= " a JScript string";
+}
+function XCallback_Impl_inoutFloat(val)
+{
+ alert( "JScript in float: " + val[0]);
+ val[0]= 4.14;
+}
+function XCallback_Impl_inoutDouble(val)
+{
+ alert( "JScript in double: " + val[0]);
+ val[0]= 4.145;
+}
+
+function XCallback_Impl_inoutByte(val)
+{
+ alert( "JScript in byte: " + val[0]);
+ val[0]= 100;
+}
+function XCallback_Impl_inoutShort(val)
+{
+ alert( "JScript in short: " + val[0]);
+ val[0]= 1000;
+}
+function XCallback_Impl_inoutLong(val)
+{
+ alert( "JScript in long: " + val[0]);
+ val[0]= 100000;
+}
+function XCallback_Impl_inoutValuesAll(aXSimple, aStruct, aEnum, aSeq,
+ aAny, aBool, aChar, aString, aFloat, aDouble,
+ aByte, aShort, aLong )
+{
+ this.inoutInterface( aXSimple);
+ this.inoutStruct( aStruct);
+ this.inoutEnum( aEnum);
+ this.inoutSeqAny( aSeq);
+ this.inoutAny( aAny);
+ this.inoutBool( aBool);
+ this.inoutChar( aChar);
+ this.inoutString( aString);
+ this.inoutFloat( aFloat);
+ this.inoutDouble( aDouble);
+ this.inoutByte( aByte);
+ this.inoutShort( aShort);
+ this.inoutLong( aLong);
+}
+
+function XCallback_Impl_inValues( aChar, aLong, aString)
+{
+ alert( "char : " + aChar + " long: " + aLong + " string: " + aString);
+}
+
+
+//################################################################
+// class MultiInterface implements XSimple, XSimple2, XSimple3
+//################################################################
+function MultiInterface()
+{
+ this._environment= "JScript";
+ this._implementedInterfaces= new Array( "oletest.XSimple", "oletest.XSimple2", "oletest.XSimple3");
+ // XSimple ---------------
+ this.getName= MultiInterface_getName;
+ this.func= MultiInterface_func;
+ this.func2= MultiInterface_func2;
+ this.func3= MultiInterface_func3;
+ // XSimple2
+ this.getName2= MultiInterface_getName2;
+ // XSimple3
+ this.getName3= MultiInterface_getName3;
+}
+
+
+function MultiInterface_getName()
+{
+ return "JScript XSimple called";
+}
+function MultiInterface_func( message)
+{
+ alert("JScript object (XSimple)-- " + message);
+}
+
+function MultiInterface_getName2()
+{
+ return "JScript XSimple2 called";
+}
+function MultiInterface_func2( message)
+{
+ alert("JScript object (XSimple2) -- " + message);
+}
+
+function MultiInterface_getName3()
+{
+ return "JScript XSimple3 called";
+}
+function MultiInterface_func3( message)
+{
+ alert("JScript object (XSimple3) -- " + message);
+}
+
+
+
+
+//XCallback_Impl_outValuesMixed( val1, outval, val2)
+//{
+//}
+//XCallback_Impl_outValuesAll( xSimple, aSimpleStruct, aSimpleEnum, seqAny, aAny, aBool,
+// aChar, aString, aFloat, aDouble, aByte, aShort, aLong, aUShort, aULong)
+//{
+//
+//}
+
+
+
+// class XSimple_Impl----------------------------------------------------------------------
+function XSimple_Impl()
+{
+ //XSimple
+ this.func= XSimple_Impl_func;
+}
+function XSimple_Impl_func( message)
+{
+ alert( "XSimple called." + message);
+}
+
+
+</script>
+
+
+
+<h2> Object in JScript</h2>
+
+This test passes a XCallback to an UNO function of the UNO test control.
+XCallback is implemented by the JScript class XCallback_Impl. The function
+XCallback::func1 is then called from the UNO test control.
+<br>
+<button onclick='callOleTest( 1)'>go</Button>
+<br>
+On the UNO object the function testInterface is called which takes
+a XCallback as parameter. XCallback is implemented in a JScript object.The function
+returns a XSimple Interface. Then the UNO object calls XSimple::notify. This test shall
+verify the correct conversion of the return value( IDispatch JScript object) to an XSimple object.<br>
+<button onclick='callOleTest( 2)'>go</Button>
+<br>
+<h1> out parameter </h1>
+The a JScript object of class XCallback_Impl is passed to the UNO OleTest Control as parameter.
+According to the buttons the OleTest object calls a function on XCallback_Impl that has appropriate type
+as out parameter.<br>
+<button onclick='callOleTest( 3)'>interface</Button>
+<button onclick='callOleTest( 4)'>struct</Button>
+<button onclick='callOleTest( 5)'>enum</Button>
+<button onclick='callOleTest( 6)'>sequence&lt;any&gt;</Button>
+<button onclick='callOleTest( 7)'>any</Button>
+<button onclick='callOleTest( 8)'>bool</Button>
+<button onclick='callOleTest( 9)'>char</Button>
+<button onclick='callOleTest( 10)'>string</Button>
+<button onclick='callOleTest( 11)'>float</Button>
+<button onclick='callOleTest( 12)'>double</Button>
+<button onclick='callOleTest( 13)'>byte</Button>
+<button onclick='callOleTest( 14)'>short</Button>
+<button onclick='callOleTest( 15)'>long</Button>
+<br>
+Other test with out parameters <br>
+<button onclick='callOleTest( 30)'>outValuesMixed</Button>
+<button onclick='callOleTest( 31)'>outValuesAll</Button>
+<h1> in out parameter </h1>
+<button onclick='callOleTest( 100)'>interface</Button>
+<button onclick='callOleTest( 101)'>struct</Button>
+<button onclick='callOleTest( 102)'>enum</Button>
+<button onclick='callOleTest( 103)'>seqence&lt;any&gt;</Button>
+<button onclick='callOleTest( 104)'>any</Button>
+<button onclick='callOleTest( 105)'>bool</Button>
+<button onclick='callOleTest( 106)'>char</Button>
+<button onclick='callOleTest( 107)'>string</Button>
+<button onclick='callOleTest( 108)'>float</Button>
+<button onclick='callOleTest( 109)'>double</Button>
+<button onclick='callOleTest( 110)'>byte</Button>
+<button onclick='callOleTest( 111)'>short</Button>
+<button onclick='callOleTest( 112)'>long</Button>
+<br>
+<h1> Attributes </h1>
+<button onclick='callOleTest( 400)'>getting XSimple</Button>
+<br>
+
+Other tests with inout parameters <br>
+<button onclick='callOleTest( 120)'>inoutValuesAll</Button>
+<h1>in parameters </h1>
+<button onclick='callOleTest( 200)'>inValues</Button>
+
+<h1> JScript object implements several interfaces </h1>
+<button onclick='callOleTest( 1000)'>go</Button>
+
+
+
+
+</body>
+</html>
+
+
diff --git a/extensions/test/ole/cpnt/cpnt.cxx b/extensions/test/ole/cpnt/cpnt.cxx
new file mode 100644
index 000000000000..589d27f438c2
--- /dev/null
+++ b/extensions/test/ole/cpnt/cpnt.cxx
@@ -0,0 +1,2126 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+#include <windows.h>
+#include <atlbase.h>
+#include <stdio.h>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/registry/XRegistryKey.hpp>
+#include <osl/diagnose.h>
+#include <uno/environment.h>
+#include <cppuhelper/factory.hxx>
+// OPTIONAL is a constant in com.sun.star.beans.PropertyAttributes but it must be
+// undef'd in some header files
+#define OPTIONAL OPTIONAL
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+#include <com/sun/star/script/XInvocation.hpp>
+#include <com/sun/star/reflection/XIdlReflection.hpp>
+#include <com/sun/star/lang/XEventListener.hpp>
+
+#include <cppuhelper/implbase7.hxx>
+#include <cppuhelper/implbase1.hxx>
+#include <com/sun/star/uno/Reference.h>
+#include <rtl/ustring.h>
+#include <com/sun/star/uno/Reference.hxx>
+#include <oletest/XTestSequence.hpp>
+#include <oletest/XTestStruct.hpp>
+#include <oletest/XTestOther.hpp>
+#include <oletest/XTestInterfaces.hpp>
+#include <oletest/XSimple.hpp>
+#include <oletest/XSimple2.hpp>
+#include <oletest/XSimple3.hpp>
+#include <oletest/XTestInParameters.hpp>
+#include <oletest/XIdentity.hpp>
+#include <com/sun/star/beans/Property.hpp>
+using namespace cppu;
+using namespace osl;
+using namespace oletest;
+using namespace rtl;
+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::script;
+using namespace com::sun::star::reflection;
+
+
+#define IMPL_NAME L"oletest.OleTestImpl" // oletest.OleTestImpl in applicat.rdb
+#define SERVICE_NAME L"oletest.OleTest"
+#define KEY1 L"/oletest.OleTestImpl/UNO/SERVICES"
+#define KEY2 L"oletest.OleTest"
+
+class OComponent : public WeakImplHelper7<
+ XTestSequence, XTestStruct, XTestOther, XTestInterfaces,
+ XSimple, XTestInParameters, XIdentity >
+{
+ Reference<XInterface> m_xIntIdentity;
+ sal_Int32 m_arrayConstructor;
+ Reference<XMultiServiceFactory> m_rFactory;
+
+ Sequence<sal_Int8> m_seqByte;
+ Sequence<float> m_seqFloat;
+ Sequence<double> m_seqDouble;
+ Sequence<sal_Bool> m_seqBool;
+ Sequence<sal_Int16> m_seqShort;
+ Sequence<sal_uInt16> m_seqUShort;
+ Sequence<sal_Int32> m_seqLong;
+ Sequence<sal_uInt32> m_seqULong;
+ Sequence<sal_Unicode> m_seqChar;
+ Sequence<OUString> m_seqString;
+ Sequence<Any> m_seqAny;
+ Sequence<Type> m_seqType;
+ Sequence<Sequence< sal_Int32> > m_seq1;
+ Sequence<Sequence< Sequence< sal_Int32> > > m_seq2;
+ Any m_any;
+ Type m_type;
+ Sequence<Reference< XInterface > > m_seqxInterface;
+
+ sal_Int8 m_int8;
+ sal_uInt8 m_uint8;
+ sal_Int16 m_int16;
+ sal_uInt16 m_uint16;
+ sal_Int32 m_int32;
+ sal_uInt32 m_uint32;
+ sal_Int64 m_int64;
+ sal_uInt64 m_uint64;
+ float m_float;
+ double m_double;
+ OUString m_string;
+ sal_Unicode m_char;
+ sal_Bool m_bool;
+ Reference<XInterface> m_xinterface;
+
+ sal_Int8 m_attr_int8;
+ sal_uInt8 m_attr_uint8;
+ sal_Int16 m_attr_int16;
+ sal_uInt16 m_attr_uint16;
+ sal_Int32 m_attr_int32;
+ sal_uInt32 m_attr_uint32;
+ sal_Int64 m_attr_int64;
+ sal_uInt64 m_attr_uint64;
+ float m_attr_float;
+ double m_attr_double;
+ OUString m_attr_string;
+ sal_Unicode m_attr_char;
+ sal_Bool m_attr_bool;
+ Any m_attr_any;
+ Type m_attr_type;
+ Reference<XInterface> m_attr_xinterface;
+ Reference<XInvocation> m_attr_xinvocation;
+
+public:
+ OComponent( const Reference<XMultiServiceFactory> & rFactory ) :
+ m_rFactory( rFactory ), m_arrayConstructor(0) {}
+ ~OComponent();
+public: // XTestSequence
+ virtual Sequence<sal_Int8> SAL_CALL methodByte(const Sequence< sal_Int8 >& aSeq) throw( RuntimeException );
+ virtual Sequence<float> SAL_CALL methodFloat(const Sequence< float >& aSeq) throw( RuntimeException );
+ virtual Sequence< double > SAL_CALL methodDouble(const Sequence< double >& aSeq) throw( RuntimeException);
+ virtual Sequence< sal_Bool > SAL_CALL methodBool(const Sequence< sal_Bool >& aSeq) throw( RuntimeException );
+ virtual Sequence< sal_Int16 > SAL_CALL methodShort(const Sequence< sal_Int16 >& aSeq) throw( RuntimeException );
+ virtual Sequence< sal_uInt16 > SAL_CALL methodUShort(const Sequence< sal_uInt16 >& aSeq) throw( RuntimeException );
+ virtual Sequence< sal_Int32 > SAL_CALL methodLong(const Sequence< sal_Int32 >& aSeq) throw( RuntimeException) ;
+ virtual Sequence< sal_uInt32 > SAL_CALL methodULong(const Sequence< sal_uInt32 >& aSeq) throw( RuntimeException );
+ virtual Sequence< OUString > SAL_CALL methodString(const Sequence< OUString >& aSeq) throw( RuntimeException );
+ virtual Sequence< sal_Unicode > SAL_CALL methodChar(const Sequence< sal_Unicode >& aSeq) throw( RuntimeException );
+ virtual Sequence< Any > SAL_CALL methodAny(const Sequence< Any >& aSeq) throw( RuntimeException );
+ virtual Sequence< Type > SAL_CALL methodType(const Sequence< Type >& aSeq) throw( RuntimeException );
+ virtual Sequence< Reference< XInterface > > SAL_CALL methodXInterface( const Sequence< Reference< XInterface > >& aSeq ) throw(RuntimeException) ;
+ virtual Sequence< Sequence< sal_Int32 > > SAL_CALL methodSequence(const Sequence< Sequence< sal_Int32 > >& aSeq) throw( RuntimeException );
+ virtual Sequence< Sequence< Sequence< sal_Int32 > > > SAL_CALL methodSequence2(const Sequence< Sequence< Sequence< sal_Int32 > > >& aSeq) throw( RuntimeException );
+ virtual Sequence< Reference<XEventListener> > SAL_CALL methodXEventListeners( const Sequence<Reference<XEventListener> >& aSeq) throw( RuntimeException);
+ virtual Sequence< Sequence<Reference<XEventListener > > > SAL_CALL methodXEventListenersMul( const Sequence<Sequence<Reference<XEventListener > > >& aSeq ) throw (RuntimeException);
+
+ virtual Sequence< sal_Int8 > SAL_CALL getAttrByte(void) throw( RuntimeException );
+ virtual void SAL_CALL setAttrByte(const Sequence< sal_Int8 >& AttrByte_) throw( RuntimeException );
+ virtual Sequence< float > SAL_CALL getAttrFloat(void) throw( RuntimeException) ;
+ virtual void SAL_CALL setAttrFloat(const Sequence< float >& AttrFloat_) throw( RuntimeException );
+ virtual Sequence< double > SAL_CALL getAttrDouble(void) throw( RuntimeException) ;
+ virtual void SAL_CALL setAttrDouble(const Sequence< double >& AttrDouble_) throw( RuntimeException );
+ virtual Sequence< sal_Bool > SAL_CALL getAttrBool(void) throw( RuntimeException );
+ virtual void SAL_CALL setAttrBool(const Sequence< sal_Bool >& AttrBool_) throw( RuntimeException );
+ virtual Sequence< sal_Int16 > SAL_CALL getAttrShort(void) throw( RuntimeException );
+ virtual void SAL_CALL setAttrShort(const Sequence< sal_Int16 >& AttrShort_) throw( RuntimeException );
+ virtual Sequence< sal_uInt16 > SAL_CALL getAttrUShort(void) throw( RuntimeException );
+ virtual void SAL_CALL setAttrUShort(const Sequence< sal_uInt16 >& AttrUShort_) throw( RuntimeException );
+ virtual Sequence< sal_Int32 > SAL_CALL getAttrLong(void) throw( RuntimeException );
+ virtual void SAL_CALL setAttrLong(const Sequence< sal_Int32 >& AttrLong_) throw( RuntimeException );
+ virtual Sequence< sal_uInt32 > SAL_CALL getAttrULong(void) throw( RuntimeException );
+ virtual void SAL_CALL setAttrULong(const Sequence< sal_uInt32 >& AttrULong_) throw( RuntimeException );
+ virtual Sequence< OUString > SAL_CALL getAttrString(void) throw(RuntimeException );
+ virtual void SAL_CALL setAttrString(const Sequence< OUString >& AttrString_) throw( RuntimeException );
+ virtual Sequence< sal_Unicode > SAL_CALL getAttrChar(void) throw( RuntimeException );
+ virtual void SAL_CALL setAttrChar(const Sequence< sal_Unicode >& AttrChar_) throw( RuntimeException );
+ virtual Sequence< Any > SAL_CALL getAttrAny(void) throw( RuntimeException );
+ virtual void SAL_CALL setAttrAny(const Sequence< Any >& AttrAny_) throw( RuntimeException );
+ virtual Sequence< Type > SAL_CALL getAttrType(void) throw( RuntimeException );
+ virtual void SAL_CALL setAttrType( const Sequence< Type >& _attrtype ) throw (RuntimeException);
+ virtual Sequence< Sequence< sal_Int32 > > SAL_CALL getAttrSequence(void) throw( RuntimeException );
+ virtual void SAL_CALL setAttrSequence(const Sequence< Sequence< sal_Int32 > >& AttrSequence_) throw( RuntimeException );
+ virtual Sequence< Sequence< Sequence< sal_Int32 > > > SAL_CALL getAttrSequence2(void) throw( RuntimeException );
+ virtual void SAL_CALL setAttrSequence2(const Sequence< Sequence< Sequence< sal_Int32 > > >& AttrSequence2_) throw ( RuntimeException );
+ virtual Sequence< Reference< XInterface > > SAL_CALL getAttrXInterface() throw(RuntimeException);
+ virtual void SAL_CALL setAttrXInterface( const Sequence< Reference< XInterface > >& _attrxinterface ) throw(RuntimeException);
+
+ virtual ::sal_Int8 SAL_CALL getAByte() throw (RuntimeException);
+ virtual void SAL_CALL setAByte( ::sal_Int8 _abyte ) throw (RuntimeException);
+ virtual float SAL_CALL getAFloat() throw (RuntimeException);
+ virtual void SAL_CALL setAFloat( float _afloat ) throw (RuntimeException);
+ virtual double SAL_CALL getADouble() throw (RuntimeException);
+ virtual void SAL_CALL setADouble( double _adouble ) throw (RuntimeException);
+ virtual ::sal_Bool SAL_CALL getABool() throw (RuntimeException);
+ virtual void SAL_CALL setABool( ::sal_Bool _abool ) throw (RuntimeException);
+ virtual ::sal_Int16 SAL_CALL getAShort() throw (RuntimeException);
+ virtual void SAL_CALL setAShort( ::sal_Int16 _ashort ) throw (RuntimeException);
+ virtual ::sal_uInt16 SAL_CALL getAUShort() throw (RuntimeException);
+ virtual void SAL_CALL setAUShort( ::sal_uInt16 _aushort ) throw (RuntimeException);
+ virtual ::sal_Int32 SAL_CALL getALong() throw (RuntimeException);
+ virtual void SAL_CALL setALong( ::sal_Int32 _along ) throw (RuntimeException);
+ virtual ::sal_uInt32 SAL_CALL getAULong() throw (RuntimeException);
+ virtual void SAL_CALL setAULong( ::sal_uInt32 _aulong ) throw (RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getAString() throw (RuntimeException);
+ virtual void SAL_CALL setAString( const ::rtl::OUString& _astring ) throw (RuntimeException);
+ virtual ::sal_Unicode SAL_CALL getAChar() throw (RuntimeException);
+ virtual void SAL_CALL setAChar( ::sal_Unicode _achar ) throw (RuntimeException);
+ virtual Any SAL_CALL getAAny() throw (RuntimeException);
+ virtual void SAL_CALL setAAny( const Any& _aany ) throw (RuntimeException);
+ virtual Type SAL_CALL getAType() throw (RuntimeException);
+ virtual void SAL_CALL setAType( const Type& _atype ) throw (RuntimeException);
+ virtual Reference< XInterface > SAL_CALL getAXInterface() throw (RuntimeException);
+ virtual void SAL_CALL setAXInterface( const Reference<XInterface >& _axinterface ) throw (RuntimeException);
+ virtual Reference<XInvocation > SAL_CALL getAXInvocation() throw (RuntimeException);
+ virtual void SAL_CALL setAXInvocation( const Reference< XInvocation >& _axinvocation ) throw (RuntimeException);
+
+ virtual void SAL_CALL testout_methodByte(sal_Int8& rOut) throw( RuntimeException );
+ virtual void SAL_CALL testout_methodFloat(float& rOut) throw( RuntimeException );
+ virtual void SAL_CALL testout_methodDouble(double& rOut) throw( RuntimeException );
+ virtual void SAL_CALL testout_methodBool(sal_Bool& rOut) throw( RuntimeException );
+ virtual void SAL_CALL testout_methodShort(sal_Int16& rOut) throw( RuntimeException );
+ virtual void SAL_CALL testout_methodUShort(sal_uInt16& rOut) throw( RuntimeException );
+ virtual void SAL_CALL testout_methodLong(sal_Int32& rOut) throw( RuntimeException );
+ virtual void SAL_CALL testout_methodULong(sal_uInt32& rOut) throw( RuntimeException );
+ virtual void SAL_CALL testout_methodHyper(sal_Int64& rOut) throw( RuntimeException );
+ virtual void SAL_CALL testout_methodUHyper(sal_uInt64& rOut) throw( RuntimeException );
+ virtual void SAL_CALL testout_methodString(OUString& rOut) throw( RuntimeException );
+ virtual void SAL_CALL testout_methodChar(sal_Unicode& rOut) throw( RuntimeException );
+ virtual void SAL_CALL testout_methodAny(Any& rOut) throw( RuntimeException );
+ virtual void SAL_CALL testout_methodType(Type& rOut) throw( RuntimeException );
+ virtual void SAL_CALL testout_methodSequence(Sequence< sal_Int32 >& rOut) throw( RuntimeException );
+ virtual void SAL_CALL testout_methodSequence2(Sequence< Sequence< sal_Int32 > >& rOut) throw( RuntimeException );
+ virtual void SAL_CALL testout_methodMulParams1(sal_Int32& rout1, sal_Int32& rout2) throw( RuntimeException );
+ virtual void SAL_CALL testout_methodMulParams2(sal_Int32& rout1, sal_Int32& rout2, OUString& rout3) throw( RuntimeException );
+ virtual void SAL_CALL testout_methodMulParams3(const OUString& sin, OUString& sout) throw( RuntimeException );
+ virtual void SAL_CALL testout_methodMulParams4( float in1, float& out1, sal_Int32 in2, sal_Int32& out2, sal_Int32 in3 ) throw(RuntimeException);
+ virtual void SAL_CALL testout_methodXInterface( Reference< XInterface >& rOut ) throw(RuntimeException);
+
+ virtual void SAL_CALL testinout_methodByte(sal_Int8& rOut) throw( RuntimeException );
+ virtual void SAL_CALL testinout_methodFloat(float& rOut) throw( RuntimeException );
+ virtual void SAL_CALL testinout_methodDouble(double& rOut) throw( RuntimeException );
+ virtual void SAL_CALL testinout_methodBool(sal_Bool& rOut) throw( RuntimeException );
+ virtual void SAL_CALL testinout_methodShort(sal_Int16& rOut) throw( RuntimeException );
+ virtual void SAL_CALL testinout_methodUShort(sal_uInt16& rOut) throw( RuntimeException );
+ virtual void SAL_CALL testinout_methodLong(sal_Int32& rOut) throw( RuntimeException );
+ virtual void SAL_CALL testinout_methodULong(sal_uInt32& rOut) throw( RuntimeException );
+ virtual void SAL_CALL testinout_methodHyper(sal_Int64& rOut) throw( RuntimeException );
+ virtual void SAL_CALL testinout_methodUHyper(sal_uInt64& rOut) throw( RuntimeException );
+ virtual void SAL_CALL testinout_methodString(OUString& rOut) throw( RuntimeException );
+ virtual void SAL_CALL testinout_methodChar(sal_Unicode& rOut) throw( RuntimeException );
+ virtual void SAL_CALL testinout_methodAny(Any& rOut) throw( RuntimeException );
+ virtual void SAL_CALL testinout_methodType(Type& rOut) throw( RuntimeException );
+ virtual void SAL_CALL testinout_methodSequence(Sequence< sal_Int32 >& rOut) throw( RuntimeException );
+ virtual void SAL_CALL testinout_methodSequence2(Sequence< Sequence< sal_Int32 > >& rOut) throw( RuntimeException );
+ virtual void SAL_CALL testinout_methodXInterface( Reference< XInvocation >& rOut ) throw(RuntimeException);
+ virtual void SAL_CALL testinout_methodXInterface2( Reference< XInterface > & rOut) throw( RuntimeException);
+ virtual Any SAL_CALL methodAnyTest1(const Any& rIn) throw( RuntimeException ) ;
+ virtual Any SAL_CALL getAttrAny2(void) throw( RuntimeException ) ;
+ virtual void SAL_CALL setAttrAny2(const Any& AttrAny2_) throw( RuntimeException ) ;
+
+
+ // XTestStruct
+ virtual void SAL_CALL methodStruct(const Property& aProp) throw( RuntimeException );
+
+ virtual Property SAL_CALL retMethodStruct(void) throw( RuntimeException );
+
+ virtual Property SAL_CALL getAttrStruct(void) throw( RuntimeException );
+ virtual void SAL_CALL setAttrStruct(const Property& AttrStruct_) throw( RuntimeException );
+ virtual Property SAL_CALL methodStruct2( const Property& aProp ) throw (RuntimeException);
+
+ // XTestOther
+ virtual void SAL_CALL other_methodAnyIn(const Any& rAny) throw( RuntimeException );
+ virtual void SAL_CALL other_methodAnyOut(Any& rAny) throw( RuntimeException );
+ virtual Any SAL_CALL other_methodAnyRet(void) throw( RuntimeException );
+ virtual void SAL_CALL in_float( float val) throw ( RuntimeException);
+ virtual Any SAL_CALL other_methodAny( const Any& rAny, const OUString& typeInAny )
+ throw (RuntimeException);
+
+
+ // XTestOutParameters ------------------------------------------------------------------------
+// virtual void SAL_CALL out_test(sal_Int8 rIn) throw( RuntimeException );
+
+// virtual void SAL_CALL out_methodByte(sal_Int8& rOut) throw( RuntimeException );
+// virtual void SAL_CALL out_methodFloat(float& rOut) throw( RuntimeException );
+// virtual void SAL_CALL out_methodDouble(double& rOut) throw( RuntimeException );
+// virtual void SAL_CALL out_methodBool(sal_Bool& rOut) throw( RuntimeException );
+// virtual void SAL_CALL out_methodShort(sal_Int16& rOut) throw( RuntimeException );
+// virtual void SAL_CALL out_methodUShort(sal_uInt16& rOut) throw( RuntimeException );
+// virtual void SAL_CALL out_methodLong(sal_Int32& rOut) throw( RuntimeException );
+// virtual void SAL_CALL out_methodULong(sal_uInt32& rOut) throw( RuntimeException );
+// virtual void SAL_CALL out_methodHyper(sal_Int64& rOut) throw( RuntimeException );
+// virtual void SAL_CALL out_methodUHyper(sal_uInt64& rOut) throw( RuntimeException );
+// virtual void SAL_CALL out_methodString(OUString& rOut) throw( RuntimeException );
+// virtual void SAL_CALL out_methodChar(sal_Unicode& rOut) throw( RuntimeException );
+// virtual void SAL_CALL out_methodAny(Any& rOut) throw( RuntimeException );
+// virtual void SAL_CALL out_methodSequence(Sequence< sal_Int32 >& rOut) throw( RuntimeException );
+// virtual void SAL_CALL out_methodSequence2(Sequence< Sequence< sal_Int32 > >& rOut) throw( RuntimeException );
+// virtual void SAL_CALL out_methodMulParams1(sal_Int32& rout1, sal_Int32& rout2) throw( RuntimeException );
+// virtual void SAL_CALL out_methodMulParams2(sal_Int32& rout1, sal_Int32& rout2, OUString& rout3) throw( RuntimeException );
+// virtual void SAL_CALL out_methodMulParams3(const OUString& sin, OUString& sout) throw( RuntimeException );
+
+ // XTestInParameters
+ virtual sal_Int8 SAL_CALL in_methodByte( sal_Int8 rIn ) throw (RuntimeException);
+ virtual float SAL_CALL in_methodFloat( float rIn ) throw (RuntimeException);
+ virtual double SAL_CALL in_methodDouble( double rIn ) throw (RuntimeException);
+ virtual sal_Bool SAL_CALL in_methodBool( sal_Bool rIn ) throw (RuntimeException);
+ virtual sal_Int16 SAL_CALL in_methodShort( sal_Int16 rIn ) throw (RuntimeException);
+ virtual sal_uInt16 SAL_CALL in_methodUShort( sal_uInt16 rIn ) throw (RuntimeException);
+ virtual sal_Int32 SAL_CALL in_methodLong( sal_Int32 rIn ) throw (RuntimeException);
+ virtual sal_uInt32 SAL_CALL in_methodULong( sal_uInt32 rIn ) throw (RuntimeException);
+ virtual sal_Int64 SAL_CALL in_methodHyper( sal_Int64 rIn ) throw (RuntimeException);
+ virtual sal_uInt64 SAL_CALL in_methodUHyper( sal_uInt64 rIn ) throw (RuntimeException);
+ virtual OUString SAL_CALL in_methodString( const OUString& rIn ) throw (RuntimeException);
+ virtual sal_Unicode SAL_CALL in_methodChar( sal_Unicode rIn ) throw (RuntimeException);
+ virtual Any SAL_CALL in_methodAny( const Any& rIn ) throw (RuntimeException);
+ virtual Type SAL_CALL in_methodType( const Type& rIn ) throw (RuntimeException);
+ virtual Reference<XInterface> SAL_CALL in_methodXInterface( const Reference< XInterface >& rIn ) throw (RuntimeException);
+ virtual Reference<XInvocation > SAL_CALL in_methodInvocation( const Reference< XInvocation >& inv ) throw (RuntimeException);
+ virtual SimpleStruct SAL_CALL in_methodStruct( const SimpleStruct& aStruct ) throw (RuntimeException);
+ virtual void SAL_CALL in_methodAll( sal_Int8 b, float f, double d, sal_Bool boo, sal_Int16 sh, sal_uInt16 us, sal_Int32 l, sal_uInt32 ul, const OUString& s, sal_Unicode c, const Any& a, const Type& t, const Reference<XInvocation>& inv ) throw (RuntimeException);
+
+ // XTestInterfaces --------------------------------------------------------------------------
+ virtual void SAL_CALL testInterface( const Reference< XCallback >& xCallback, sal_Int32 mode ) throw(RuntimeException);
+ virtual void SAL_CALL testInterface2( const Reference< XSimple >& xSimple, sal_Int32 mode ) throw(RuntimeException);
+ // XSimple --------------------------------------------------------------------------
+ void SAL_CALL func( const OUString &message) throw(::com::sun::star::uno::RuntimeException);
+ OUString SAL_CALL getName() throw(::com::sun::star::uno::RuntimeException);
+
+ // XIdentity
+ virtual void SAL_CALL setObject( const Reference< XInterface >& val ) throw (RuntimeException);
+ virtual sal_Bool SAL_CALL isSame( const Reference< XInterface >& val ) throw (RuntimeException);
+ virtual Reference< XInterface > SAL_CALL getThis( ) throw (RuntimeException);
+};
+
+class EventListener: public WeakImplHelper1<XEventListener>
+{
+public:
+ EventListener::EventListener(): bCalled( sal_False)
+ {}
+ virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw (RuntimeException);
+
+ sal_Bool bCalled;
+};
+
+
+OComponent::~OComponent()
+{
+}
+
+
+// Funktions ==============================================================================
+
+Reference<XInterface> SAL_CALL OComponent_CreateInstance( const Reference<XMultiServiceFactory> & rSMgr ) throw(RuntimeException)
+{
+// Reference<XInterface> xService(static_cast<XWeak*>(new OComponent( rSMgr )), UNO_QUERY);
+ OComponent* o= new OComponent( rSMgr );
+ Reference<XInterface> xService(static_cast<XIdentity*>(o), UNO_QUERY);
+ return xService;
+}
+
+Sequence<OUString> OComponent_getSupportedServiceNames(void)
+{
+ Sequence<OUString> aRet(1);
+ aRet.getArray()[0] = SERVICE_NAME;//ODataInputStream_getImplementationName();
+
+ return aRet;
+}
+
+
+extern "C" sal_Bool SAL_CALL component_writeInfo( void * /*pServiceManager*/, void * pRegistryKey )
+{
+ if(pRegistryKey)
+ {
+ try
+ {
+ Reference<XRegistryKey> xNewKey =
+ reinterpret_cast<XRegistryKey*>( pRegistryKey)->createKey(KEY1);
+ xNewKey->createKey( KEY2);
+ return sal_True;
+
+ }
+ catch(InvalidRegistryException &)
+ {
+ OSL_ENSURE( sal_False, "### InvalidRegistryException!\n");
+ }
+ }
+ return sal_False;
+}
+
+extern "C" void * SAL_CALL component_getFactory(
+ const sal_Char * pImplName, void * pServiceManager, void * /*pRegistryKey*/ )
+{
+ static void * pRet= NULL;
+ if( ! pRet)
+ {
+ OUString aImplName( OUString::createFromAscii( pImplName ) );
+ if (pServiceManager && aImplName.equals( IMPL_NAME ))
+ {
+ Reference<XMultiServiceFactory> xMulFac(
+ reinterpret_cast< XMultiServiceFactory*>(pServiceManager));
+
+ Sequence<OUString> seqServiceNames;
+ Reference<XSingleServiceFactory> xFactory = createOneInstanceFactory( xMulFac, SERVICE_NAME,
+ OComponent_CreateInstance, seqServiceNames);
+
+ if (xFactory.is())
+ {
+ xFactory->acquire();
+ pRet = xFactory.get();
+ }
+ }
+ }
+ return pRet;
+}
+
+extern "C" void SAL_CALL component_getImplementationEnvironment(
+ const sal_Char ** ppEnvTypeName, uno_Environment ** )
+{
+ *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
+}
+
+
+// XTestSequence ============================================================================
+Sequence<sal_Int8> SAL_CALL OComponent::methodByte(const Sequence< sal_Int8 >& aSeq) throw( RuntimeException )
+{
+ sal_Int8 _x;
+ for( sal_Int16 i= 0; i < aSeq.getLength(); i++){
+ _x= aSeq.getConstArray()[i];
+ }
+ return aSeq;
+}
+Sequence<float> SAL_CALL OComponent::methodFloat(const Sequence< float>& aSeq) throw( RuntimeException )
+{
+ float _x;
+ for( sal_Int16 i= 0; i < aSeq.getLength(); i++){
+ _x= aSeq.getConstArray()[i];
+ }
+ return aSeq;
+}
+Sequence<double> SAL_CALL OComponent::methodDouble(const Sequence< double >& aSeq) throw( RuntimeException)
+{
+ double _x;
+ for( sal_Int16 i= 0; i < aSeq.getLength(); i++){
+ _x= aSeq.getConstArray()[i];
+ }
+ return aSeq;
+}
+Sequence< sal_Bool > SAL_CALL OComponent::methodBool(const Sequence< sal_Bool >& aSeq) throw( RuntimeException)
+{
+ sal_Bool _x;
+ for( sal_Int16 i= 0; i < aSeq.getLength(); i++){
+ _x= aSeq.getConstArray()[i];
+ }
+ return aSeq;
+}
+Sequence< sal_Int16 > SAL_CALL OComponent::methodShort(const Sequence< sal_Int16 >& aSeq) throw( RuntimeException )
+{
+ sal_Int16 _x;
+ for( sal_Int16 i= 0; i < aSeq.getLength(); i++){
+ _x= aSeq.getConstArray()[i];
+ }
+ return aSeq;
+}
+Sequence< sal_uInt16 > SAL_CALL OComponent::methodUShort(const Sequence< sal_uInt16 >& aSeq) throw( RuntimeException )
+{
+ sal_uInt16 _x;
+ for( sal_Int16 i= 0; i < aSeq.getLength(); i++){
+ _x= aSeq.getConstArray()[i];
+ }
+ return aSeq;
+}
+Sequence< sal_Int32 > SAL_CALL OComponent::methodLong(const Sequence< sal_Int32 >& aSeq) throw( RuntimeException)
+{
+ sal_Int32 _x;
+ for( sal_Int16 i= 0; i < aSeq.getLength(); i++) {
+ _x= aSeq.getConstArray()[i];
+ }
+ return aSeq;
+}
+Sequence< sal_uInt32 > SAL_CALL OComponent::methodULong(const Sequence< sal_uInt32 >& aSeq) throw( RuntimeException)
+{
+ sal_uInt32 _x;
+ for( sal_Int16 i= 0; i < aSeq.getLength(); i++){
+ _x= aSeq.getConstArray()[i];
+ }
+ return aSeq;
+}
+Sequence< OUString > SAL_CALL OComponent::methodString(const Sequence< OUString >& aSeq) throw( RuntimeException)
+{
+ OUString _x;
+ for( sal_Int16 i= 0; i < aSeq.getLength(); i++) {
+ _x= aSeq.getConstArray()[i];
+ }
+ return aSeq;
+}
+Sequence< sal_Unicode > SAL_CALL OComponent::methodChar(const Sequence< sal_Unicode >& aSeq) throw( RuntimeException)
+{
+ sal_Unicode _x;
+ for( sal_Int16 i= 0; i < aSeq.getLength(); i++){
+ _x= aSeq.getConstArray()[i];
+ }
+ return aSeq;
+}
+Sequence< Any > SAL_CALL OComponent::methodAny(const Sequence< Any >& aSeq) throw( RuntimeException)
+{
+ Any _x;
+ for( sal_Int16 i= 0; i < aSeq.getLength(); i++){
+ _x= aSeq.getConstArray()[i];
+ TypeClass _t= _x.getValueTypeClass();
+ if( _t== TypeClass_STRING)
+ OUString s(* (rtl_uString**)_x.getValue());
+ }
+ return aSeq;
+
+}
+
+Sequence< Type > SAL_CALL OComponent::methodType(const Sequence< Type >& aSeq) throw( RuntimeException )
+{
+ Type _x;
+ for( sal_Int16 i= 0; i < aSeq.getLength(); i++){
+ _x= aSeq.getConstArray()[i];
+ }
+ return aSeq;
+}
+//Sequence< Reference< XInterface> > SAL_CALL methodXInterface ( const Sequence< Reference < XInterface> >& aSeq)
+// throw (RuntimeException)
+Sequence< Reference< XInterface > > SAL_CALL OComponent::methodXInterface( const Sequence< Reference< XInterface > >& aSeq ) throw(RuntimeException)
+{
+ for( sal_Int32 i= 0; i < aSeq.getLength(); i++)
+ {
+ Reference<XInterface> xInt= aSeq[i];
+ Reference<XEventListener> xList( xInt, UNO_QUERY);
+ if( xList.is())
+ xList->disposing( EventObject());
+ }
+ return aSeq;
+}
+
+Sequence< Sequence< sal_Int32 > > SAL_CALL OComponent::methodSequence(const Sequence< Sequence< sal_Int32 > >& aSeq) throw( RuntimeException)
+{
+ sal_Int32 value;
+ for( sal_Int16 i= 0; i < aSeq.getLength(); i++){
+ const Sequence<sal_Int32>& rseq2= aSeq.getConstArray()[i];
+ for (sal_Int16 j= 0; j < rseq2.getLength(); j++){
+ value= rseq2.getConstArray()[j];
+ }
+ }
+ return aSeq;
+}
+Sequence< Sequence< Sequence< sal_Int32 > > > SAL_CALL OComponent::methodSequence2(const Sequence< Sequence< Sequence< sal_Int32 > > >& aSeq)
+ throw( RuntimeException )
+{
+ sal_Int32 value;
+ sal_Int32 len= aSeq.getLength();
+ for( sal_Int16 i= 0; i < aSeq.getLength(); i++){
+ const Sequence< Sequence<sal_Int32> >& rseq2= aSeq.getConstArray()[i];
+ len= rseq2.getLength();
+
+ for (sal_Int16 j= 0; j < rseq2.getLength(); j++){
+ const Sequence<sal_Int32> & rseq3= rseq2.getConstArray()[j];
+ len= rseq3.getLength();
+
+ for (sal_Int16 k= 0; k < rseq3.getLength(); k++)
+ value= rseq3.getConstArray()[k];
+ }
+ }
+ return aSeq;
+}
+
+Sequence< Reference< XEventListener> > SAL_CALL OComponent::methodXEventListeners( const Sequence< Reference <XEventListener> >& aSeq) throw( RuntimeException)
+{
+ Reference<XEventListener> listener;
+ for( int i= 0; i < aSeq.getLength(); i++)
+ {
+ listener= aSeq[i];
+
+ listener->disposing( EventObject() );
+ }
+
+ return aSeq;
+}
+
+Sequence< Sequence<Reference<XEventListener > > > SAL_CALL OComponent::methodXEventListenersMul( const Sequence<Sequence<Reference<XEventListener > > >& aSeq ) throw (RuntimeException)
+{
+ Reference<XEventListener> listener;
+ for( int i= 0; i < aSeq.getLength(); i++)
+ {
+ Sequence<Reference<XEventListener> > seqInner= aSeq[i];
+ for( int j= 0; j < seqInner.getLength(); j++)
+ {
+ listener= seqInner[j];
+ listener->disposing( EventObject() );
+ }
+ }
+ return aSeq;
+}
+
+//---------------------------------------------------------------------------------------------
+
+Sequence< sal_Int8 > SAL_CALL OComponent::getAttrByte(void) throw( RuntimeException)
+{
+ return m_seqByte;
+}
+void SAL_CALL OComponent::setAttrByte(const Sequence< sal_Int8 >& AttrByte_) throw( RuntimeException )
+{
+ m_seqByte= AttrByte_;
+}
+Sequence< float > SAL_CALL OComponent::getAttrFloat(void) throw( RuntimeException )
+{
+ return m_seqFloat;
+}
+void SAL_CALL OComponent::setAttrFloat(const Sequence< float >& AttrFloat_) throw( RuntimeException )
+{
+ m_seqFloat= AttrFloat_;
+}
+
+Sequence< double > SAL_CALL OComponent::getAttrDouble(void) throw( RuntimeException )
+{
+ return m_seqDouble;
+}
+void SAL_CALL OComponent::setAttrDouble(const Sequence< double >& AttrDouble_) throw( RuntimeException )
+{
+ m_seqDouble= AttrDouble_;
+}
+
+Sequence< sal_Bool > SAL_CALL OComponent::getAttrBool(void) throw( RuntimeException)
+{
+ return m_seqBool;
+}
+
+void SAL_CALL OComponent::setAttrBool(const Sequence< sal_Bool >& AttrBool_) throw (RuntimeException )
+{
+ m_seqBool= AttrBool_;
+}
+
+Sequence< sal_Int16 > SAL_CALL OComponent::getAttrShort(void) throw( RuntimeException)
+{
+ return m_seqShort;
+}
+void SAL_CALL OComponent::setAttrShort(const Sequence< sal_Int16 >& AttrShort_) throw( RuntimeException )
+{
+ m_seqShort= AttrShort_;
+}
+
+Sequence< sal_uInt16 > SAL_CALL OComponent::getAttrUShort(void) throw( RuntimeException )
+{
+ return m_seqUShort;
+}
+void SAL_CALL OComponent::setAttrUShort(const Sequence< sal_uInt16 >& AttrUShort_) throw( RuntimeException )
+{
+ m_seqUShort= AttrUShort_;
+}
+
+Sequence< sal_Int32 > SAL_CALL OComponent::getAttrLong(void) throw( RuntimeException)
+{
+ return m_seqLong;
+}
+void SAL_CALL OComponent::setAttrLong(const Sequence< sal_Int32 >& AttrLong_) throw( RuntimeException )
+{
+ m_seqLong= AttrLong_;
+}
+
+Sequence< sal_uInt32 > SAL_CALL OComponent::getAttrULong(void) throw( RuntimeException )
+{
+ return m_seqULong;
+}
+void SAL_CALL OComponent::setAttrULong(const Sequence< sal_uInt32 >& AttrULong_) throw( RuntimeException )
+{
+ m_seqULong= AttrULong_;
+}
+
+Sequence< OUString > SAL_CALL OComponent::getAttrString(void) throw( RuntimeException )
+{
+ return m_seqString;
+}
+void SAL_CALL OComponent::setAttrString(const Sequence< OUString >& AttrString_) throw( RuntimeException )
+{
+ m_seqString= AttrString_;
+}
+
+Sequence< sal_Unicode > SAL_CALL OComponent::getAttrChar(void) throw( RuntimeException )
+{
+ return m_seqChar;
+}
+void SAL_CALL OComponent::setAttrChar(const Sequence< sal_Unicode >& AttrChar_) throw( RuntimeException)
+{
+ m_seqChar= AttrChar_;
+}
+
+Sequence< Any > SAL_CALL OComponent::getAttrAny(void) throw( RuntimeException)
+{
+ return m_seqAny;
+}
+void SAL_CALL OComponent::setAttrAny(const Sequence< Any >& AttrAny_) throw( RuntimeException )
+{
+ m_seqAny= AttrAny_;
+}
+
+Sequence< Type > SAL_CALL OComponent::getAttrType(void) throw( RuntimeException )
+{
+ return m_seqType;
+}
+
+void SAL_CALL OComponent::setAttrType( const Sequence< Type >& AttrType_) throw( RuntimeException )
+{
+ m_seqType = AttrType_;
+}
+
+
+Sequence< Sequence< sal_Int32 > > SAL_CALL OComponent::getAttrSequence(void) throw( RuntimeException)
+{
+ return m_seq1;
+}
+void SAL_CALL OComponent::setAttrSequence(const Sequence< Sequence< sal_Int32 > >& AttrSequence) throw(RuntimeException )
+{
+ sal_Int32 x= 0;
+ for( sal_Int32 i=0; i < AttrSequence.getLength(); i++)
+ {
+ Sequence< sal_Int32 > seq= AttrSequence[i];
+
+ for ( sal_Int32 j=0; j < seq.getLength(); j++)
+ {
+ x= seq[j];
+ }
+ }
+
+ m_seq1= AttrSequence;
+}
+
+Sequence< Sequence< Sequence< sal_Int32 > > > SAL_CALL OComponent::getAttrSequence2(void) throw( RuntimeException )
+{
+ return m_seq2;
+}
+void SAL_CALL OComponent::setAttrSequence2(const Sequence< Sequence< Sequence< sal_Int32 > > >& AttrSequence2_)
+ throw( RuntimeException )
+{
+ m_seq2= AttrSequence2_;
+}
+
+Sequence< Reference< XInterface > > SAL_CALL OComponent::getAttrXInterface() throw(RuntimeException)
+{
+ return m_seqxInterface;
+}
+void SAL_CALL OComponent::setAttrXInterface( const Sequence< Reference< XInterface > >& _attrxinterface ) throw(RuntimeException)
+{
+ m_seqxInterface= _attrxinterface;
+}
+
+// ----------------------------------------------------------------------------
+
+::sal_Int8 SAL_CALL OComponent::getAByte() throw (RuntimeException)
+{
+ return m_attr_int8;
+}
+
+void SAL_CALL OComponent::setAByte( ::sal_Int8 _abyte ) throw (RuntimeException)
+{
+ m_attr_int8 = _abyte;
+}
+
+float SAL_CALL OComponent::getAFloat() throw (RuntimeException)
+{
+ return m_attr_float;
+}
+
+void SAL_CALL OComponent::setAFloat( float _afloat ) throw (RuntimeException)
+{
+ m_attr_float = _afloat;
+}
+
+double SAL_CALL OComponent::getADouble() throw (RuntimeException)
+{
+ return m_attr_double;
+}
+
+void SAL_CALL OComponent::setADouble( double _adouble ) throw (RuntimeException)
+{
+ m_attr_double = _adouble;
+}
+
+::sal_Bool SAL_CALL OComponent::getABool() throw (RuntimeException)
+{
+ return m_attr_bool;
+}
+
+void SAL_CALL OComponent::setABool( ::sal_Bool _abool ) throw (RuntimeException)
+{
+ m_attr_bool = _abool;
+}
+
+::sal_Int16 SAL_CALL OComponent::getAShort() throw (RuntimeException)
+{
+ return m_attr_int16;
+}
+
+void SAL_CALL OComponent::setAShort( ::sal_Int16 _ashort ) throw (RuntimeException)
+{
+ m_attr_int16 = _ashort;
+}
+
+::sal_uInt16 SAL_CALL OComponent::getAUShort() throw (RuntimeException)
+{
+ return m_attr_uint16;
+}
+
+void SAL_CALL OComponent::setAUShort( ::sal_uInt16 _aushort ) throw (RuntimeException)
+{
+ m_attr_uint16 = _aushort;
+}
+
+::sal_Int32 SAL_CALL OComponent::getALong() throw (RuntimeException)
+{
+ return m_attr_int32;
+}
+
+void SAL_CALL OComponent::setALong( ::sal_Int32 _along ) throw (RuntimeException)
+{
+ m_attr_int32 = _along;
+}
+
+::sal_uInt32 SAL_CALL OComponent::getAULong() throw (RuntimeException)
+{
+ return m_attr_uint32;;
+}
+
+void SAL_CALL OComponent::setAULong( ::sal_uInt32 _aulong ) throw (RuntimeException)
+{
+ m_attr_uint32 = _aulong;
+}
+
+::rtl::OUString SAL_CALL OComponent::getAString() throw (RuntimeException)
+{
+ return m_attr_string;
+}
+
+void SAL_CALL OComponent::setAString( const ::rtl::OUString& _astring ) throw (RuntimeException)
+{
+ m_attr_string = _astring;
+}
+
+::sal_Unicode SAL_CALL OComponent::getAChar() throw (RuntimeException)
+{
+ return m_attr_char;
+}
+
+void SAL_CALL OComponent::setAChar( ::sal_Unicode _achar ) throw (RuntimeException)
+{
+ m_attr_char = _achar;
+}
+
+Any SAL_CALL OComponent::getAAny() throw (RuntimeException)
+{
+ return m_attr_any;
+}
+
+void SAL_CALL OComponent::setAAny( const Any& _aany ) throw (RuntimeException)
+{
+ m_attr_any = _aany;
+}
+
+Type SAL_CALL OComponent::getAType() throw (RuntimeException)
+{
+ return m_attr_type;
+}
+
+void SAL_CALL OComponent::setAType( const Type& _atype ) throw (RuntimeException)
+{
+ m_attr_type = _atype;
+}
+
+Reference< XInterface > SAL_CALL OComponent::getAXInterface() throw (RuntimeException)
+{
+ return m_attr_xinterface;
+}
+
+void SAL_CALL OComponent::setAXInterface( const Reference<XInterface >& _axinterface ) throw (RuntimeException)
+{
+ m_attr_xinterface = _axinterface;
+}
+
+Reference<XInvocation > SAL_CALL OComponent::getAXInvocation() throw (RuntimeException)
+{
+ return m_attr_xinvocation;
+}
+
+void SAL_CALL OComponent::setAXInvocation( const Reference< XInvocation >& _axinvocation ) throw (RuntimeException)
+{
+ m_attr_xinvocation = _axinvocation;
+}
+//-----------------------------------------------------------------------------------
+void SAL_CALL OComponent::testout_methodByte(sal_Int8& rOut) throw( RuntimeException )
+{
+ rOut= m_int8;
+}
+void SAL_CALL OComponent::testout_methodFloat(float& rOut) throw( RuntimeException )
+{
+ rOut= m_float;
+}
+void SAL_CALL OComponent::testout_methodDouble(double& rOut) throw( RuntimeException )
+{
+ rOut= m_double;
+}
+
+void SAL_CALL OComponent::testout_methodBool(sal_Bool& rOut) throw( RuntimeException )
+{
+ rOut= m_bool;
+}
+void SAL_CALL OComponent::testout_methodShort(sal_Int16& rOut) throw( RuntimeException )
+{
+ rOut= m_int16;
+}
+void SAL_CALL OComponent::testout_methodUShort(sal_uInt16& rOut) throw( RuntimeException )
+{
+ rOut= m_uint16;
+}
+void SAL_CALL OComponent::testout_methodLong(sal_Int32& rOut) throw( RuntimeException )
+{
+ rOut = m_int32;
+}
+void SAL_CALL OComponent::testout_methodULong(sal_uInt32& rOut) throw( RuntimeException )
+{
+ rOut= m_uint32;
+}
+void SAL_CALL OComponent::testout_methodHyper(sal_Int64& rOut) throw( RuntimeException )
+{
+ rOut = m_int64;
+}
+
+void SAL_CALL OComponent::testout_methodUHyper(sal_uInt64& rOut) throw( RuntimeException )
+{
+ rOut = m_uint64;
+}
+
+void SAL_CALL OComponent::testout_methodString(OUString& rOut) throw( RuntimeException )
+{
+ rOut= m_string;
+}
+void SAL_CALL OComponent::testout_methodChar(sal_Unicode& rOut) throw( RuntimeException )
+{
+ rOut= m_char;
+}
+void SAL_CALL OComponent::testout_methodAny(Any& rOut) throw( RuntimeException)
+{
+ rOut = m_any;
+}
+
+void SAL_CALL OComponent::testout_methodType(Type& rOut) throw( RuntimeException )
+{
+ rOut = m_type;
+}
+
+void SAL_CALL OComponent::testout_methodSequence(Sequence< sal_Int32 >& rOut) throw( RuntimeException)
+{
+ rOut.realloc(10);
+ for( sal_Int16 i= 0; i < rOut.getLength(); i++) rOut.getArray()[i]= i;
+}
+void SAL_CALL OComponent::testout_methodSequence2(Sequence< Sequence< sal_Int32 > >& rOut) throw( RuntimeException )
+{
+ rOut.realloc( 10);
+ for( sal_Int16 i= 0; i < rOut.getLength(); i++){
+ Sequence<sal_Int32>& rseq2= rOut.getArray()[i];
+ rseq2.realloc( 10);
+ for (sal_Int16 j= 0; j < rseq2.getLength(); j++){
+ rseq2.getArray()[j]= j;
+ }
+ }
+}
+void SAL_CALL OComponent::testout_methodMulParams1(sal_Int32& rout1, sal_Int32& rout2) throw( RuntimeException )
+{
+ rout1= 999;
+ rout2= 1111;
+}
+void SAL_CALL OComponent::testout_methodMulParams2(sal_Int32& rout1, sal_Int32& rout2, OUString& rout3) throw( RuntimeException )
+{
+ rout1= 1111;
+ rout2= 1222;
+ rout3= L" another string";
+}
+void SAL_CALL OComponent::testout_methodMulParams3(const OUString&, OUString& sout) throw( RuntimeException )
+{
+ sout= L"Out Hallo!";
+}
+void SAL_CALL OComponent::testout_methodMulParams4( float in1, float& out1, sal_Int32 in2, sal_Int32& out2, sal_Int32 ) throw(RuntimeException)
+{
+ out1= in1 + 1;
+ out2= in2 + 1;
+}
+
+void SAL_CALL OComponent::testout_methodXInterface( Reference< XInterface >& rOut ) throw(RuntimeException)
+{
+ rOut = m_xinterface;
+// OUString string( L"Property Any");
+// m_any <<= string;
+// rOut= Reference<XInterface> (static_cast<XTestSequence*>(this), UNO_QUERY);
+}
+
+// XTestInParameters ------------------------------------------------------------
+sal_Int8 SAL_CALL OComponent::in_methodByte( sal_Int8 rIn ) throw (RuntimeException)
+{
+ m_int8 = rIn;
+ return rIn;
+}
+float SAL_CALL OComponent::in_methodFloat( float rIn ) throw (RuntimeException)
+{
+ m_float = rIn;
+ return rIn;
+}
+double SAL_CALL OComponent::in_methodDouble( double rIn ) throw (RuntimeException)
+{
+ m_double = rIn;
+ return rIn;
+}
+sal_Bool SAL_CALL OComponent::in_methodBool( sal_Bool rIn ) throw (RuntimeException)
+{
+ m_bool = rIn;
+ return rIn;
+}
+sal_Int16 SAL_CALL OComponent::in_methodShort( sal_Int16 rIn ) throw (RuntimeException)
+{
+ m_int16 = rIn;
+ return rIn;
+}
+sal_uInt16 SAL_CALL OComponent::in_methodUShort( sal_uInt16 rIn ) throw (RuntimeException)
+{
+ m_uint16 = rIn;
+ return rIn;
+}
+sal_Int32 SAL_CALL OComponent::in_methodLong( sal_Int32 rIn ) throw (RuntimeException)
+{
+ m_int32 = rIn;
+ return rIn;
+}
+sal_uInt32 SAL_CALL OComponent::in_methodULong( sal_uInt32 rIn ) throw (RuntimeException)
+{
+ m_uint32 = rIn;
+ return rIn;
+}
+sal_Int64 SAL_CALL OComponent::in_methodHyper( sal_Int64 rIn ) throw (RuntimeException)
+{
+ m_int64 = rIn;
+ return rIn;
+}
+
+sal_uInt64 SAL_CALL OComponent::in_methodUHyper( sal_uInt64 rIn ) throw (RuntimeException)
+{
+ m_uint64 = rIn;
+ return rIn;
+}
+
+OUString SAL_CALL OComponent::in_methodString( const OUString& rIn ) throw (RuntimeException)
+{
+ m_string = rIn;
+ return rIn;
+}
+sal_Unicode SAL_CALL OComponent::in_methodChar( sal_Unicode rIn ) throw (RuntimeException)
+{
+ m_char = rIn;
+ return rIn;
+}
+Any SAL_CALL OComponent::in_methodAny( const Any& rIn ) throw (RuntimeException)
+{
+ m_any = rIn;
+ return rIn;
+}
+
+Type SAL_CALL OComponent::in_methodType( const Type& rIn ) throw (RuntimeException)
+{
+ m_type = rIn;
+ return rIn;
+}
+
+Reference<XInvocation > SAL_CALL OComponent::in_methodInvocation( const Reference< XInvocation >& inv )
+ throw (RuntimeException)
+{
+ //We expect the invocation results from a conversion of VBasicEventListener.VBEventListener
+//which implements XEventListener
+ // extensions/test/ole/EventListenerSample
+ EventObject event( Reference<XInterface>(static_cast<XTestInParameters*>(this),UNO_QUERY));
+ Any anyParam;
+ anyParam <<= event;
+ Sequence<Any> params( &anyParam, 1);
+ Sequence<sal_Int16> outIndex;
+ Sequence<Any> outParams;
+ try{
+ inv->invoke( OUString(RTL_CONSTASCII_USTRINGPARAM("disposing")),
+ params, outIndex, outParams);
+ }catch(IllegalArgumentException &) {
+ }
+ catch(CannotConvertException &){
+ }
+ catch(InvocationTargetException&) {
+ }
+ return inv;
+}
+Reference<XInterface> SAL_CALL OComponent::in_methodXInterface( const Reference<XInterface >& rIn ) throw (RuntimeException)
+{
+ m_xinterface = rIn;
+ return rIn;
+}
+
+SimpleStruct SAL_CALL OComponent::in_methodStruct( const SimpleStruct& aStruct )
+ throw (RuntimeException)
+{
+ SimpleStruct& s= const_cast<SimpleStruct&>(aStruct);
+ s.message= s.message + OUString(RTL_CONSTASCII_USTRINGPARAM(
+ "This string was set in OleTest"));
+ return aStruct;
+}
+void SAL_CALL OComponent::in_methodAll(
+ sal_Int8, float, double, sal_Bool, sal_Int16, sal_uInt16,
+ sal_Int32, sal_uInt32, const OUString&, sal_Unicode,
+ const Any&, const Type&, const Reference<XInvocation>&) throw (RuntimeException)
+{
+}
+
+// INOUT -----------------------------------------------------------------------------------
+void SAL_CALL OComponent::testinout_methodByte(sal_Int8& rOut) throw( RuntimeException )
+{
+ sal_Int8 tmp = rOut;
+ rOut = m_int8;
+ m_int8 = tmp;
+}
+void SAL_CALL OComponent::testinout_methodFloat(float& rOut) throw( RuntimeException )
+{
+ float tmp = rOut;
+ rOut = m_float;
+ m_float = tmp;
+}
+
+void SAL_CALL OComponent::testinout_methodDouble(double& rOut) throw( RuntimeException )
+{
+ double tmp = rOut;
+ rOut = m_double;
+ m_double = tmp;
+}
+void SAL_CALL OComponent::testinout_methodBool(sal_Bool& rOut) throw( RuntimeException )
+{
+ sal_Bool tmp = rOut;
+ rOut = m_bool;
+ m_bool = tmp;
+}
+void SAL_CALL OComponent::testinout_methodShort(sal_Int16& rOut) throw( RuntimeException )
+{
+ sal_Int16 tmp= rOut;
+ rOut = m_int16;
+ m_int16 = tmp;
+}
+void SAL_CALL OComponent::testinout_methodUShort(sal_uInt16& rOut) throw( RuntimeException )
+{
+ sal_uInt16 tmp = rOut;
+ rOut = m_uint16;
+ m_uint16 = tmp;
+}
+void SAL_CALL OComponent::testinout_methodLong(sal_Int32& rOut) throw( RuntimeException )
+{
+ sal_Int32 tmp = rOut;
+ rOut = m_int32;
+ m_int32 = tmp;
+}
+void SAL_CALL OComponent::testinout_methodULong(sal_uInt32& rOut) throw( RuntimeException )
+{
+ sal_uInt32 tmp = rOut;
+ rOut = m_uint32;
+ m_uint32 = tmp;
+}
+void SAL_CALL OComponent::testinout_methodHyper(sal_Int64& rOut) throw( RuntimeException )
+{
+ sal_Int64 tmp = rOut;
+ rOut = m_int64;
+ m_int64 = tmp;
+}
+
+void SAL_CALL OComponent::testinout_methodUHyper(sal_uInt64& rOut) throw( RuntimeException )
+{
+ sal_uInt64 tmp = rOut;
+ rOut = m_uint64;
+ m_uint64 = tmp;
+}
+
+void SAL_CALL OComponent::testinout_methodString(OUString& rOut) throw( RuntimeException )
+{
+ OUString tmp = rOut;
+ rOut = m_string;
+ m_string = tmp;
+}
+void SAL_CALL OComponent::testinout_methodChar(sal_Unicode& rOut) throw( RuntimeException)
+{
+ sal_Unicode tmp = rOut;
+ rOut = m_char;
+ m_char = tmp;
+}
+void SAL_CALL OComponent::testinout_methodAny(Any& rOut) throw( RuntimeException)
+{
+ Any tmp = rOut;
+ rOut = m_any;
+ m_any = tmp;
+}
+void SAL_CALL OComponent::testinout_methodType(Type& rOut) throw( RuntimeException)
+{
+ Type tmp = rOut;
+ rOut = m_type;
+ m_type = tmp;
+}
+
+
+void SAL_CALL OComponent::testinout_methodSequence(Sequence< sal_Int32 >& rOut) throw( RuntimeException)
+{
+
+ sal_Int32* arr= rOut.getArray();
+ for ( sal_Int32 i=0; i < rOut.getLength(); i++)
+ {
+ rOut.getArray()[i] += 1;
+ }
+}
+void SAL_CALL OComponent::testinout_methodSequence2(Sequence< Sequence< sal_Int32 > >& rOut) throw( RuntimeException )
+{
+ for( sal_Int32 i=0; i < rOut.getLength(); i++)
+ {
+ Sequence< sal_Int32 >& seq= rOut.getArray()[i];
+
+ for ( sal_Int32 j=0; j < seq.getLength(); j++)
+ {
+ seq.getArray()[j] += seq.getArray()[j];
+ }
+ }
+}
+
+// The parameter should implement XInvocation and a Property "value"
+void SAL_CALL OComponent::testinout_methodXInterface( Reference< XInvocation >& rOut ) throw(RuntimeException)
+{
+ Any any;
+ any= rOut->getValue( OUString( L"value"));
+ OUString _s;
+ any >>= _s;
+ OUString string(L"out");
+ any <<= string;
+ rOut->setValue( OUString(L"value"), any);
+
+ any= rOut->getValue( OUString( L"value"));
+ any >>= _s;
+
+}
+
+void SAL_CALL OComponent::testinout_methodXInterface2( Reference< XInterface > & rOut) throw( RuntimeException)
+{
+ Reference<XInterface> tmp = rOut;
+ rOut = m_xinterface;
+ m_xinterface = tmp;
+// Reference<XTestSequence> xTest( rOut, UNO_QUERY);
+// if( xTest.is())
+// {
+// Any any= xTest->getAttrAny2();
+// OUString _s;
+// any >>= _s;
+// OUString string= _s + OUString((L" this string was written in the UNO component to the inout pararmeter"));
+// any <<= string;
+// xTest->setAttrAny2( any);
+// }
+
+}
+Any SAL_CALL OComponent::methodAnyTest1(const Any& rIn) throw( RuntimeException )
+{
+ return rIn;
+}
+Any SAL_CALL OComponent::getAttrAny2(void) throw( RuntimeException )
+{
+ return m_any;
+}
+void SAL_CALL OComponent::setAttrAny2(const Any& AttrAny2_) throw( RuntimeException )
+{
+ m_any= AttrAny2_;
+}
+
+
+
+// XTestStruct =======================================================================================
+
+void SAL_CALL OComponent::methodStruct(const Property& aProp) throw( RuntimeException )
+{
+ char buff[1024];
+ buff[0]= 0;
+ sprintf( buff,"Property::Attribute : %d \n Property::Handle : %d \n Property::Name : %S",
+ aProp.Attributes, aProp.Handle, (const sal_Unicode*)aProp.Name);
+ MessageBox( NULL, A2T(buff), _T("OleTest: methodStruct"), MB_OK);
+}
+
+Property SAL_CALL OComponent::retMethodStruct(void) throw( RuntimeException )
+{
+ Property a(L"OleTest_Property", 255, getCppuType( (Reference<XInterface>*)0), PropertyAttribute::MAYBEVOID |
+ PropertyAttribute::BOUND | PropertyAttribute::CONSTRAINED |
+ PropertyAttribute::TRANSIENT | PropertyAttribute::READONLY |
+ PropertyAttribute::MAYBEAMBIGUOUS | PropertyAttribute::MAYBEDEFAULT );
+ return a;
+}
+
+Property SAL_CALL OComponent::getAttrStruct(void) throw( RuntimeException)
+{
+ Property a(L"OleTest_Property", 255, getCppuType( (Reference<XInterface>*)0), PropertyAttribute::MAYBEVOID |
+ PropertyAttribute::BOUND | PropertyAttribute::CONSTRAINED |
+ PropertyAttribute::TRANSIENT | PropertyAttribute::READONLY |
+ PropertyAttribute::MAYBEAMBIGUOUS | PropertyAttribute::MAYBEDEFAULT );
+ return a;
+
+}
+
+void SAL_CALL OComponent::setAttrStruct(const Property& AttrStruct_) throw( RuntimeException )
+{
+ char buff[1024];
+ buff[0]= 0;
+ sprintf( buff,"Property::Attribute : %d \n Property::Handle : %d \n Property::Name : %S",
+ AttrStruct_.Attributes, AttrStruct_.Handle, (const sal_Unicode*)AttrStruct_.Name);
+// MessageBox( NULL, A2T(buff), _T("OleTest: setAttrStruct"), MB_OK);
+}
+
+Property SAL_CALL OComponent::methodStruct2( const Property& aProp ) throw (RuntimeException)
+{
+ return aProp;
+}
+
+// XTestOther ==================================================================================
+void SAL_CALL OComponent::other_methodAnyIn(const Any& ) throw( RuntimeException )
+{
+}
+void SAL_CALL OComponent::other_methodAnyOut(Any& rAny) throw( RuntimeException )
+{
+ rAny <<= OUString(L"Ein Any");
+}
+
+Any SAL_CALL OComponent::other_methodAnyRet(void) throw(RuntimeException )
+{
+ Any a;
+ a <<= OUString(L"Ein Any");
+ return a;
+}
+void SAL_CALL OComponent::in_float( float val) throw ( RuntimeException)
+{
+ USES_CONVERSION;
+ char buff[256];
+ sprintf( buff, "parameter : %f", val);
+ MessageBox( NULL, A2T(buff), _T("OleTest"), MB_OK);
+}
+Any SAL_CALL OComponent::other_methodAny( const Any& rAny, const OUString& typeInAny )
+ throw (RuntimeException)
+{
+ Type expectedType;
+ typelib_TypeDescription * pDesc= NULL;
+ typelib_typedescription_getByName( &pDesc, typeInAny.pData );
+ if( pDesc)
+ {
+ expectedType = Type( pDesc->pWeakRef );
+ typelib_typedescription_release( pDesc);
+ }
+ if (rAny.getValueType() != expectedType)
+ throw RuntimeException();
+
+ return rAny;
+}
+
+// XTestOutParameters ============================================================================
+// void SAL_CALL OComponent::out_test(sal_Int8 rIn) throw( RuntimeException )
+// {
+// }
+
+// void SAL_CALL OComponent::out_methodByte(sal_Int8& rOut) throw( RuntimeException )
+// {
+// rOut= 100;
+// }
+
+// void SAL_CALL OComponent::out_methodDouble(double& rOut) throw( RuntimeException )
+// {
+// rOut= 3.14;
+// }
+// void SAL_CALL OComponent::out_methodFloat(float& rOut) throw( RuntimeException )
+// {
+// rOut= 3.14;
+// }
+// void SAL_CALL OComponent::out_methodBool(sal_Bool& rOut) throw( RuntimeException )
+// {
+// rOut= sal_True;
+// }
+// void SAL_CALL OComponent::out_methodShort(sal_Int16& rOut) throw( RuntimeException )
+// {
+// rOut= -100;
+// }
+// void SAL_CALL OComponent::out_methodUShort(sal_uInt16& rOut) throw( RuntimeException )
+// {
+// rOut= 100;
+// }
+// void SAL_CALL OComponent::out_methodLong(sal_Int32& rOut) throw( RuntimeException )
+// {
+// rOut= -100;
+// }
+
+// void SAL_CALL OComponent::out_methodULong(sal_uInt32& rOut) throw( RuntimeException )
+// {
+// rOut= 100;
+// }
+// void SAL_CALL OComponent::out_methodHyper(sal_Int64& rOut) throw( RuntimeException )
+// {
+
+// }
+
+// void SAL_CALL OComponent::out_methodUHyper(sal_uInt64& rOut) throw( RuntimeException )
+// {
+// }
+
+// void SAL_CALL OComponent::out_methodString(OUString& rOut) throw( RuntimeException )
+// {
+// rOut= L"I'm a string";
+// }
+// void SAL_CALL OComponent::out_methodChar(sal_Unicode& rOut) throw( RuntimeException )
+// {
+// rOut= 'A';
+// }
+// void SAL_CALL OComponent::out_methodAny(Any& rOut) throw( RuntimeException)
+// {
+// Any a;
+// a <<= OUString( L"Hi");
+// rOut= a;
+// }
+// void SAL_CALL OComponent::out_methodSequence(Sequence< sal_Int32 >& rOut) throw( RuntimeException )
+// {
+// Sequence< sal_Int32 > aseq(10);
+// for( sal_Int16 i= 0; i < aseq.getLength(); i++) aseq.getArray()[i]= i;
+// rOut= aseq;
+// }
+// void SAL_CALL OComponent::out_methodSequence2(Sequence< Sequence< sal_Int32 > >& rOut) throw( RuntimeException )
+// {
+// rOut= Sequence< Sequence< sal_Int32 > >();
+// }
+// void SAL_CALL OComponent::out_methodMulParams1(sal_Int32& rout1, sal_Int32& rout2) throw( RuntimeException )
+// {
+// rout1= 111;
+// rout2= 222;
+// }
+// void SAL_CALL OComponent::out_methodMulParams2(sal_Int32& rout1, sal_Int32& rout2, OUString& rout3) throw( RuntimeException )
+// {
+// rout1= 111;
+// rout2= 222;
+// rout3= L"this is a neet little string";
+// }
+// void SAL_CALL OComponent::out_methodMulParams3(const OUString& sin, OUString& sout) throw( RuntimeException )
+// {
+// sout= L"this is a neet little string";
+// }
+
+// XTestInterfaces -------------------------------------------------------------------------------------
+void SAL_CALL OComponent::testInterface( const Reference< XCallback >& xCallback, sal_Int32 mode ) throw(RuntimeException)
+{
+ USES_CONVERSION;
+ sal_Int32 i=0;
+ OUString aString;
+ char buff[1024];
+
+ Reference<XSimple> xSimple;
+ SimpleStruct aSimpleStruct;
+ SimpleEnum aSimpleEnum;
+ Sequence<Any> seqAny;
+ Sequence< sal_Int8 > seqByte;
+ Any outAny;
+ sal_Bool aBool;
+ sal_Unicode aChar;
+ float aFloat;
+ double aDouble;
+ sal_Int8 aByte;
+ sal_Int16 aShort;
+ sal_Int32 aLong;
+// sal_uInt16 aUShort;
+// sal_uInt32 aULong;
+
+ switch( mode)
+ {
+ case 1:
+ xCallback->func1(); break;
+ case 2:
+ xSimple= xCallback->returnInterface();
+ xSimple->func(L"XCallback::returnInterface");
+ break;
+
+
+ case 3:
+ xCallback->outInterface( xSimple);
+ sprintf( buff, "XCallback::outInterface, value: %x", xSimple.get());
+ MessageBox( NULL, A2T(buff), _T("OleTest out parameter"), MB_OK);
+ xSimple->func(L"XCallback::outInterface works");
+ break;
+ case 4:
+ xCallback->outStruct( aSimpleStruct);
+ sprintf( buff,"XCallback::outStruct, SimpleStruct::message: %s", OLE2A( aSimpleStruct.message));
+ MessageBox( NULL, A2T(buff), _T("OleTest out parameter"), MB_OK);
+ break;
+ case 5:
+ xCallback->outEnum( aSimpleEnum);
+ sprintf( buff,"XCallback::outEnum, SimpleEnum: %d", aSimpleEnum);
+ MessageBox( NULL, A2T(buff), _T("OleTest out parameter"), MB_OK);
+ break;
+ case 6:
+ xCallback->outSeqAny( seqAny);
+ sprintf( buff,"XCallback::outSeqAny, length: %d )", seqAny.getLength());
+ MessageBox( NULL, A2T(buff), _T("OleTest out parameter"), MB_OK);
+ for( i=0; i < seqAny.getLength(); i++)
+ {
+ Any any= seqAny[i];
+ if( any.getValueTypeClass() == TypeClass_STRING)
+ {
+ any >>= aString;
+ OutputDebugStringW( aString);
+ }
+
+ }
+ break;
+ case 7:
+ xCallback->outAny( outAny);
+ if( outAny.getValueTypeClass() == TypeClass_STRING)
+ outAny >>= aString;
+ sprintf( buff,"XCallback::outAny, Any : %s", W2A( aString));
+ MessageBox( NULL, A2T(buff), _T("OleTest out parameter"), MB_OK);
+ break;
+ case 8:
+ xCallback->outBool( aBool);
+ sprintf( buff,"XCallback::outBool, value: %d", aBool);
+ MessageBox( NULL, A2T(buff), _T("OleTest out parameter"), MB_OK);
+ break;
+ case 9:
+ xCallback->outChar( aChar);
+ sprintf( buff,"XCallback::outChar, value: %C", aChar);
+ MessageBox( NULL, A2T(buff), _T("OleTest out parameter"), MB_OK);
+ break;
+ case 10:
+ xCallback->outString( aString);
+ sprintf( buff,"XCallback::outString, value: %s", W2A( aString));
+ MessageBox( NULL, A2T(buff), _T("OleTest out parameter"), MB_OK);
+ break;
+ case 11:
+ xCallback->outFloat( aFloat);
+ sprintf( buff,"XCallback::outFloat, value: %f", aFloat);
+ MessageBox( NULL, A2T(buff), _T("OleTest out parameter"), MB_OK);
+ break;
+ case 12:
+ xCallback->outDouble( aDouble);
+ sprintf( buff,"XCallback::outDouble, value: %f", aDouble);
+ MessageBox( NULL, A2T(buff), _T("OleTest out parameter"), MB_OK);
+ break;
+ case 13:
+ xCallback->outByte( aByte);
+ sprintf( buff,"XCallback::outByte, value: %d", aByte);
+ MessageBox( NULL, A2T(buff), _T("OleTest out parameter"), MB_OK);
+ break;
+ case 14:
+ xCallback->outShort( aShort);
+ sprintf( buff,"XCallback::outShort, value: %d", aShort);
+ MessageBox( NULL, A2T(buff), _T("OleTest out parameter"), MB_OK);
+ break;
+ case 15:
+ xCallback->outLong( aLong);
+ sprintf( buff,"XCallback::outLong, value: %d", aLong);
+ MessageBox( NULL, A2T(buff), _T("OleTest out parameter"), MB_OK);
+ break;
+ case 18:
+ case 19:
+ case 30:
+ {
+
+ long outLong= 0;
+ xCallback->outValuesMixed( 1111, outLong, OUString( L"in string") );
+
+ sprintf( buff, "oletest.testInterface: outValue: %d", outLong);
+ MessageBox( NULL, A2T(buff), _T("OleTest"), MB_OK);
+ break;
+ }
+
+ case 31:
+ {
+ Reference< XSimple > xSimple;
+ SimpleStruct aSimpleStruct;
+ SimpleEnum aSimpleEnum;
+ Sequence<Any> seqAny;
+ Any aAny;
+ sal_Bool aBool;
+ sal_Unicode aChar;
+ OUString aString;
+ float aFloat;
+ double aDouble;
+ sal_Int8 aByte;
+ sal_Int16 aShort;
+ sal_Int32 aLong;
+// sal_uInt16 aUShort;
+// sal_uInt32 aULong;
+ xCallback->outValuesAll( xSimple, aSimpleStruct, aSimpleEnum, seqAny, aAny, aBool,
+ aChar, aString,
+ aFloat, aDouble,
+ aByte,
+ aShort, aLong);
+
+ MessageBox( NULL, _T("XCallback::outValuesAll returned"), _T("OleTest::testInterface"), MB_OK);
+ break;
+ }
+ case 32:
+ {
+
+ xCallback->outSeqByte( seqByte);
+ sprintf( buff,"XCallback::outSeqAny, length: %d )", seqAny.getLength());
+ MessageBox( NULL, A2T(buff), _T("OleTest out parameter"), MB_OK);
+ for( i=0; i < seqAny.getLength(); i++)
+ {
+ Any any= seqAny[i];
+ if( any.getValueTypeClass() == TypeClass_STRING)
+ {
+ any >>= aString;
+ OutputDebugStringW( aString);
+ }
+ }
+ break;
+ }
+ // ############################################################################
+ // IN OUT parameter
+ // ############################################################################
+ case 100:
+ {
+ Reference<XSimple> xSimple= static_cast<XSimple*>(this);
+ xCallback->inoutInterface( xSimple);
+ xSimple->func(L"XSimple called from OleTest");
+ break;
+ }
+ case 101:
+ {
+ Reference<XIdlReflection> xRefl( m_rFactory->createInstance(L"com.sun.star.reflection.CoreReflection"), UNO_QUERY);
+ if( xRefl.is())
+ {
+ Reference<XIdlClass> xClass= xRefl->forName(L"oletest.SimpleStruct");
+ Any any;
+ if( xClass.is())
+ xClass->createObject( any);
+
+ if( any.getValueTypeClass() == TypeClass_STRUCT)
+ {
+ SimpleStruct* pStruct= ( SimpleStruct*) any.getValue();
+ pStruct->message= OUString::createFromAscii("This struct was created in OleTest");
+
+ SimpleStruct aStruct;
+ any >>= aStruct;
+ xCallback->inoutStruct( aStruct);
+ // a Struct should now contain a different message
+ MessageBox( NULL, W2T(aStruct.message), _T("OleTest in out parameter"), MB_OK);
+ }
+
+ }
+ break;
+ }
+ case 102:
+ {
+ SimpleEnum aEnum= SimpleEnum_B;
+ xCallback->inoutEnum( aEnum);
+ char buff[1024];
+ sprintf( buff, "Enum: %d", aEnum);
+ MessageBox( NULL, A2T(buff), _T("OleTest in out parameter"), MB_OK);
+ break;
+ }
+ case 103:
+ {
+ Any arAny[3];
+ arAny[0] <<= OUString( L"string 0");
+ arAny[1] <<= OUString( L"string 1");
+ arAny[2] <<= OUString( L"string 2");
+
+ Sequence< Any >seqAny( arAny, 3);
+ xCallback->inoutSeqAny( seqAny);
+ char buff[1023];
+ sprintf( buff, "Sequence length: %d", seqAny.getLength());
+ MessageBox( NULL,A2T(buff) , _T("OleTest in out parameter"), MB_OK);
+
+ for( int i=0; i < seqAny.getLength(); i++)
+ {
+ Any any;
+ any <<= seqAny[i];
+ if(any.getValueTypeClass() == TypeClass_STRING)
+ {
+ OUString str;
+ any >>= str;
+
+ }
+ }
+
+ break;
+ }
+ case 104:
+ {
+ Any any;
+ OUString s(L" OleTest");
+ any <<= s;
+ xCallback->inoutAny(any);
+ if( any.getValueTypeClass() == TypeClass_STRING)
+ {
+ OUString s= *( rtl_uString**) any.getValue();
+ MessageBox( NULL, W2T( s), _T("OleTest: inout value any"), MB_OK);
+ }
+ break;
+ }
+ case 105:
+ {
+ sal_Bool b= sal_True;
+ xCallback->inoutBool( b);
+ char buff[1024];
+ sprintf( buff, "out value bool: %d", b);
+ MessageBox( NULL, A2T( buff), _T("OleTest in out parameter"), MB_OK);
+ break;
+ }
+ case 106:
+ {
+ sal_Unicode uc= L'A';
+ xCallback->inoutChar( uc);
+ char buff[1024];
+ sprintf( buff, "out value sal_Unicode: %C", uc);
+ MessageBox( NULL, A2T( buff), _T("OleTest in out parameter"), MB_OK);
+ break;
+ }
+ case 107:
+ {
+ OUString s(L"OleTest");
+ xCallback->inoutString( s);
+ char buff[1024];
+ sprintf( buff, "out value string: %S", s.getStr());
+ MessageBox( NULL, A2T( buff), _T("OleTest in out parameter"), MB_OK);
+ break;
+ }
+ case 108:
+ {
+ float f= 3.14f;
+ xCallback->inoutFloat(f);
+ char buff[1024];
+ sprintf( buff, "out value float: %f", f);
+ MessageBox( NULL, A2T( buff), _T("OleTest in out parameter"), MB_OK);
+ break;
+ }
+ case 109:
+ {
+ double f= 3.145;
+ xCallback->inoutDouble( f);
+ char buff[1024];
+ sprintf( buff, "out value double: %g", f);
+ MessageBox( NULL, A2T( buff), _T("OleTest in out parameter"), MB_OK);
+ break;
+ }
+ case 110:
+ {
+ sal_Int8 aByte= 0xf;
+ xCallback->inoutByte( aByte);
+ char buff[1024];
+ sprintf( buff, "out value sal_Int8: %d", aByte);
+ MessageBox( NULL, A2T( buff), _T("OleTest in out parameter"), MB_OK);
+ break;
+ }
+ case 111:
+ {
+ sal_Int16 aShort= 0xff;
+ xCallback->inoutShort( aShort);
+ char buff[1024];
+ sprintf( buff, "out value sal_Int16: %d", aShort);
+ MessageBox( NULL, A2T( buff), _T("OleTest in out parameter"), MB_OK);
+ break;
+ }
+ case 112:
+ {
+ sal_Int32 aLong= 0xfffe;
+ xCallback->inoutLong( aLong);
+ char buff[1024];
+ sprintf( buff, "out value sal_Int32: %d", aLong);
+ MessageBox( NULL, A2T( buff), _T("OleTest in out parameter"), MB_OK);
+ break;
+ }
+ case 120:
+ {
+ Reference<XSimple> aXSimple= static_cast<XSimple*>(this);
+
+ SimpleStruct aStruct;
+ Reference<XIdlReflection> xRefl( m_rFactory->createInstance(L"com.sun.star.reflection.CoreReflection"), UNO_QUERY);
+ if( xRefl.is())
+ {
+ Reference<XIdlClass> xClass= xRefl->forName(L"oletest.SimpleStruct");
+ Any any;
+ if( xClass.is())
+ xClass->createObject( any);
+
+ if( any.getValueTypeClass() == TypeClass_STRUCT)
+ {
+ SimpleStruct* pStruct= ( SimpleStruct*) any.getValue();
+ pStruct->message= OUString::createFromAscii("This struct was created in OleTest");
+ any >>= aStruct;
+ }
+ }
+
+ SimpleEnum aEnum= SimpleEnum_B;
+
+ Sequence< Any > aSeq;
+ Any arAny[3];
+ arAny[0] <<= OUString( L"string 0");
+ arAny[1] <<= OUString( L"string 1");
+ arAny[2] <<= OUString( L"string 2");
+ aSeq = Sequence< Any >( arAny, 3);
+
+ Any aAny;
+ OUString s(L" OleTest");
+ aAny <<= s;
+
+ sal_Bool aBool= sal_True;
+ sal_Unicode aChar= L'A';
+ OUString aString( L"OleTest");
+ float aFloat=3.14f;
+ double aDouble= 3.145;
+ sal_Int8 aByte= 0xf;
+ sal_Int16 aShort= 0xff;
+ sal_Int32 aLong= 0xffe;
+
+ xCallback->inoutValuesAll( aXSimple, aStruct, aEnum, aSeq,
+ aAny, aBool, aChar, aString, aFloat, aDouble,
+ aByte, aShort, aLong );
+
+ aXSimple->func(L"XSimple called from OleTest");
+ MessageBox( NULL, W2T(aStruct.message), _T("OleTest"), MB_OK);
+
+ for( int i=0; i < aSeq.getLength(); i++)
+ {
+ Any any;
+ any <<= aSeq[i];
+ if(any.getValueTypeClass() == TypeClass_STRING)
+ {
+ OUString str;
+ any >>= str;
+
+ }
+ }
+ break;
+ }
+
+ // ############################################################################
+ // IN parameter
+ // ############################################################################
+
+ case 200:
+
+ xCallback->inValues( L'a', 0xffffL, OUString(L" a string from OleTest"));
+ break;
+ case 201:
+ {
+ sal_Int8 arbyte[3]= { 1,2,3};
+ Sequence< sal_Int8 > seq( arbyte, 3);
+ xCallback->inSeqByte( seq);
+ break;
+ }
+ case 202:
+ {
+ const int LISTENERS= 3;
+ Reference<XEventListener> arListeners[LISTENERS];
+ EventObject arEvents[LISTENERS];
+
+ for( int i= 0; i < LISTENERS; i++)
+ {
+ Reference<XInterface> aList= static_cast<XWeak*>( new EventListener());
+ arListeners[i]= Reference<XEventListener>( aList, UNO_QUERY);
+ }
+
+ xCallback->inSeqXEventListener(Sequence<Reference<XEventListener> > (arListeners, LISTENERS),
+ Sequence<EventObject>(arEvents, LISTENERS));
+ break;
+ }
+
+ // ############################################################################
+ // Call a COM object that has not been passed as parameter to a UNO component and
+ // hence no type information are available in the COM wrapper
+ // ############################################################################
+ case 300:
+ {
+ Reference<XInterface> xIntFact = m_rFactory->createInstance(L"com.sun.star.bridge.oleautomation.Factory");
+
+ Reference<XMultiServiceFactory> oleFact(xIntFact, UNO_QUERY);
+
+ Reference<XInterface> xIntCallback= oleFact->createInstance(L"XCallback_Impl.Callback");
+ Reference<XInvocation> xInv( xIntCallback, UNO_QUERY);
+//Any SAL_CALL invoke( const OUString& aFunctionName, const Sequence<Any >& aParams,Sequence< sal_Int16 >& aOutParamIndex,
+// Sequence<Any >& aOutParam );
+ Sequence<sal_Int16> seqIndizes;
+ Sequence<Any> seqOutParams;
+ xInv->invoke( OUString( L"outValuesAll"), Sequence<Any>(), seqIndizes, seqOutParams);
+
+// void outValuesAll( [out] oletest::XSimple outInterface,
+// [out] SimpleStruct outStruct ,
+// [out] SimpleEnum outEnum,
+// [out] sequence<any> outSeqAny,
+// [out] any outAny,
+// [out] boolean outBool,
+// [out] char outChar,
+// [out] string outString,
+// [out] float outFloat,
+// [out] double outDouble,
+// [out] byte outByte,
+// [out] short outShort,
+// [out] long outLong);
+ if( seqOutParams.getLength() == 12)
+ {
+ Reference<XSimple> xSimple= *(XSimple**)seqOutParams[0].getValue();
+ xSimple->func( L"Call from OleTest on XSimple");
+ SimpleStruct aStruct;
+ seqOutParams[1] >>= aStruct;
+ SimpleEnum aEnum= *(SimpleEnum*)seqOutParams[2].getValue();
+
+ Sequence<Any> seqAny;
+ seqOutParams[3] >>= seqAny;
+ for( int i=0; i<seqAny.getLength(); i++)
+ {
+ OUString _s;
+ seqAny[i] >>= _s;
+ }
+
+ Any _any= *(Any*)seqOutParams[4].getValue();
+ sal_Bool _bool= *(sal_Bool*)seqOutParams[5].getValue();
+ sal_Unicode _char= *( sal_Unicode*) seqOutParams[6].getValue();
+ OUString _str= *( rtl_uString**)seqOutParams[7].getValue();
+
+ float _f= *( float*)seqOutParams[8].getValue();
+ double _d= *( double*) seqOutParams[9].getValue();
+ sal_Int8 _byte= *( sal_Int8*) seqOutParams[10].getValue();
+ sal_Int16 _short= *( sal_Int16*) seqOutParams[11].getValue();
+
+ sal_Int32 _long= *( sal_Int32*) seqOutParams[12].getValue();
+
+ }
+ break;
+ }
+ case 301:
+ // in / out parameter
+ {
+ Reference<XInterface> xIntFact = m_rFactory->createInstance(L"com.sun.star.bridge.oleautomation.Factory");
+
+ Reference<XMultiServiceFactory> oleFact(xIntFact, UNO_QUERY);
+
+ Reference<XInterface> xIntCallback= oleFact->createInstance(L"XCallback_Impl.Callback");
+ Reference<XInvocation> xInv( xIntCallback, UNO_QUERY);
+ Sequence<sal_Int16> seqIndizes;
+ Sequence<Any> seqOutParams;
+
+
+ Any arAny[13];
+ Reference<XSimple> xSimple= static_cast<XSimple*>( this);
+
+ arAny[0] <<= xSimple;
+ SimpleStruct aStruct;
+ Reference<XIdlReflection> xRefl( m_rFactory->createInstance(L"com.sun.star.reflection.CoreReflection"), UNO_QUERY);
+ if( xRefl.is())
+ {
+ Reference<XIdlClass> xClass= xRefl->forName(L"oletest.SimpleStruct");
+ Any any;
+ if( xClass.is())
+ xClass->createObject( any);
+
+ if( any.getValueTypeClass() == TypeClass_STRUCT)
+ {
+ SimpleStruct* pStruct= ( SimpleStruct*) any.getValue();
+ pStruct->message= OUString::createFromAscii("This struct was created in OleTest");
+ any >>= aStruct;
+ }
+ }
+ arAny[1] <<= aStruct;
+ arAny[2] <<= SimpleEnum_C;
+
+ Any arSeqAny[3];
+ arSeqAny[0] <<= OUString( L"string 0");
+ arSeqAny[1] <<= OUString( L"string 1");
+ arSeqAny[2] <<= OUString( L"string 2");
+
+ arAny[3] <<= Sequence< Any >( arAny, 3);
+
+ OUString str(L" Ein Any param");
+ arAny[4] <<= str;
+ arAny[5] <<= sal_False;
+ arAny[6] <<= L'B';
+ OUString stringParam(L" a string parameter");
+ arAny[7] <<= stringParam;
+ float _float= 3.14f;
+ arAny[8] <<= _float;
+ double _double= 3.145;
+ arAny[9] <<= _double;
+ sal_Int8 _byte= -1;
+ arAny[10] <<= _byte;
+ sal_Int16 _short= -1;
+ arAny[11] <<= _short;
+ sal_Int32 _long= -1;
+ arAny[12] <<= _long;
+//
+ Sequence<Any> params( arAny, 13);
+
+ xInv->invoke( OUString( L"inoutValuesAll"), params, seqIndizes, seqOutParams);
+
+ if( seqOutParams.getLength() == 12)
+ {
+ Reference<XSimple> xSimple= *(XSimple**)seqOutParams[0].getValue();
+ xSimple->func( L"Call from OleTest on XSimple");
+ SimpleStruct aStruct;
+ seqOutParams[1] >>= aStruct;
+ SimpleEnum aEnum= *(SimpleEnum*)seqOutParams[2].getValue();
+
+ Sequence<Any> seqAny;
+ seqOutParams[3] >>= seqAny;
+ for( int i=0; i<seqAny.getLength(); i++)
+ {
+ OUString _s;
+ seqAny[i] >>= _s;
+ }
+
+ Any _any= *(Any*)seqOutParams[4].getValue();
+ sal_Bool _bool= *(sal_Bool*)seqOutParams[5].getValue();
+ sal_Unicode _char= *( sal_Unicode*) seqOutParams[6].getValue();
+ OUString _str= *( rtl_uString**)seqOutParams[7].getValue();
+
+ float _f= *( float*)seqOutParams[8].getValue();
+ double _d= *( double*) seqOutParams[9].getValue();
+ sal_Int8 _byte= *( sal_Int8*) seqOutParams[10].getValue();
+ sal_Int16 _short= *( sal_Int16*) seqOutParams[11].getValue();
+
+ sal_Int32 _long= *( sal_Int32*) seqOutParams[12].getValue();
+
+ }
+ break;
+ }
+ case 303:
+ // in parameter
+// void inValues( [in] char aChar, [in] long aLong, [in] string aString);
+ {
+ Reference<XInterface> xIntFact = m_rFactory->createInstance(
+ L"com.sun.star.bridge.oleautomation.Factory");
+
+ Reference<XMultiServiceFactory> oleFact(xIntFact, UNO_QUERY);
+
+ Reference<XInterface> xIntCallback= oleFact->createInstance(L"XCallback_Impl.Callback");
+ Reference<XInvocation> xInv( xIntCallback, UNO_QUERY);
+ Sequence<sal_Int16> seqIndizes;
+ Sequence<Any> seqOutParams;
+
+ Any arAny[3];
+ sal_Unicode aChar=L'a';
+ arAny[0] <<= aChar;
+ sal_Int32 aLong= 0xffffffff;
+ arAny[1] <<= aLong;
+ OUString aString(L" a string parameter");
+ arAny[2] <<= aString;
+
+ xInv->invoke( OUString( L"inValues"), Sequence<Any>(arAny,3), seqIndizes, seqOutParams);
+
+ break;
+ }
+ // ############################################################################
+ // Attributes
+ // ############################################################################
+
+ case 400:
+ Reference<XSimple> simple= xCallback->getsimple();
+ simple->func(L"OleTest calls on XSimple");
+ break;
+
+
+
+
+ }
+
+}
+
+void SAL_CALL OComponent::setObject( const Reference< XInterface >& val ) throw (RuntimeException)
+{
+ m_xIntIdentity= val;
+}
+
+sal_Bool SAL_CALL OComponent::isSame( const Reference< XInterface >& val ) throw (RuntimeException)
+{
+ if( m_xIntIdentity == val)
+ return sal_True;
+ else
+ return sal_False;
+}
+
+Reference< XInterface > SAL_CALL OComponent::getThis( ) throw (RuntimeException)
+{
+// return Reference<XInterface>(static_cast<XIdentity*>(this), UNO_QUERY);
+ Reference<XInterface> ret(static_cast<XIdentity*>(this), UNO_QUERY);
+ return ret;
+}
+
+void SAL_CALL EventListener::disposing( const ::com::sun::star::lang::EventObject& ) throw (RuntimeException)
+{
+ bCalled= sal_True;
+}
+
+// XSimple --------------------------------------------------------------------------
+void SAL_CALL OComponent::func( const OUString &message)throw(::com::sun::star::uno::RuntimeException)
+{
+ USES_CONVERSION;
+
+ MessageBox( NULL, W2T( message.getStr()), _T("OleTest: XSimple::func"), MB_OK);
+}
+// XSimple --------------------------------------------------------------------------
+OUString SAL_CALL OComponent::getName()throw(::com::sun::star::uno::RuntimeException)
+{
+ return L"XSimple";
+}
+void SAL_CALL OComponent::testInterface2( const Reference< XSimple >& xSimple, sal_Int32 mode ) throw(RuntimeException)
+{
+ switch( mode)
+ {
+ case 0:
+ {
+ xSimple->func( L"OleTest is calling XSimple");
+ Reference<XSimple2> xSimple2( xSimple, UNO_QUERY);
+ if( xSimple2.is())
+ xSimple2->func2( L"OleTest is calling XSimple2");
+ Reference<XSimple3> xSimple3( xSimple, UNO_QUERY);
+ if( xSimple3.is())
+ xSimple3->func3( L"OleTest is calling XSimple3");
+
+ break;
+ }
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/test/ole/cpnt/exports.dxp b/extensions/test/ole/cpnt/exports.dxp
new file mode 100644
index 000000000000..a265aeec0b7f
--- /dev/null
+++ b/extensions/test/ole/cpnt/exports.dxp
@@ -0,0 +1,3 @@
+component_writeInfo
+component_getFactory
+component_getImplementationEnvironment \ No newline at end of file
diff --git a/extensions/test/ole/cpnt/makefile.mk b/extensions/test/ole/cpnt/makefile.mk
new file mode 100644
index 000000000000..53d3cc321c49
--- /dev/null
+++ b/extensions/test/ole/cpnt/makefile.mk
@@ -0,0 +1,102 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+PRJ=..$/..$/..
+
+PRJNAME= extensions
+TARGET= oletest
+ENABLE_EXCEPTIONS=TRUE
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+
+# --- Files --------------------------------------------------------
+#UNOUCRDEP= $(SOLARBINDIR)$/types.rdb $(BIN)$/oletest.rdb
+#UNOUCRRDB= $(SOLARBINDIR)$/types.rdb $(BIN)$/oletest.rdb
+
+#UNOUCROUT= $(OUT)$/inc
+
+#UNOTYPES= oletest.XTestSequence \
+# oletest.XTestStruct \
+# oletest.XTestOther \
+# oletest.XTestInterfaces \
+# oletest.XSimple \
+# oletest.XSimple2 \
+# oletest.XSimple3 \
+# oletest.XTestInParameters \
+# oletest.XIdentity
+
+INCPRE+= -I$(ATL_INCLUDE)
+
+SLOFILES= \
+ $(SLO)$/cpnt.obj
+
+SHL1TARGET= $(TARGET)
+
+SHL1STDLIBS= \
+ $(SALLIB) \
+ $(CPPULIB) \
+ $(CPPUHELPERLIB)
+
+#.IF "$(COMEX)"=="8" || "$(COMEX)"=="10"
+# SHL1STDLIBS+= $(COMPATH)$/atlmfc$/lib$/atls.lib
+#.ENDIF
+
+.IF "$(COMEX)"=="8" || "$(COMEX)"=="10"
+.IF "$(USE_STLP_DEBUG)" != ""
+ SHL1STDLIBS+= $(ATL_LIB)$/atlsd.lib
+.ELSE
+ SHL1STDLIBS+= $(ATL_LIB)$/atls.lib
+.ENDIF
+.ENDIF
+
+
+SHL1DEPN=
+SHL1IMPLIB= i$(TARGET)
+SHL1LIBS= $(SLB)$/$(TARGET).lib
+SHL1DEF= $(MISC)$/$(SHL1TARGET).def
+
+DEF1NAME= $(SHL1TARGET)
+DEF1EXPORTFILE= exports.dxp
+
+
+ALLTAR : $(MISC)$/$(TARGET).cppumaker.done
+
+
+.INCLUDE : target.mk
+
+ALLIDLFILES:= ..$/idl$/oletest.idl
+
+$(BIN)$/oletest.rdb: $(ALLIDLFILES)
+ idlc -I$(PRJ) -I$(SOLARIDLDIR) -O$(BIN) $?
+ regmerge $@ /UCR $(BIN)$/{$(?:f:s/.idl/.urd/)}
+ touch $@
+
+$(MISC)$/$(TARGET).cppumaker.done: $(BIN)$/oletest.rdb
+ $(CPPUMAKER) -O$(INCCOM) -BUCR $< -X$(SOLARBINDIR)/types.rdb
+ $(TOUCH) $@
+
diff --git a/extensions/test/ole/cpnt/readme.txt b/extensions/test/ole/cpnt/readme.txt
new file mode 100644
index 000000000000..46d525efb285
--- /dev/null
+++ b/extensions/test/ole/cpnt/readme.txt
@@ -0,0 +1,21 @@
+cpnt.cxx contains a uno component that is uses to test the olebridge within a
+JavaScript context. In particular it has functions using out, in/out and
+sequence parameter that have to be specifically treated in JScript because they
+are represented by IDispatch objects. Other clients, such as VBScript, VB and
+C++ applications can also use this component for testing.
+The service name is oletest.OleTest.
+The uno types are also build in this folder. The idl file is in ..\idl. The
+types rdb is in wntmscixx.pro\bin\oletest.rdb
+
+The service is used by:
+OleTest.htm
+JScriptNewStyle.htm
+ScriptTest.html
+
+
+Prerequisites:
+
+The oletest.dll must be registered, for example in the services.rdb, using
+regcomp. Then the uno types contained in oletest.rdb (wntmscixx/bin) must be merged
+for example in the offapi.rdb. This is done with regmerge.
+
diff --git a/extensions/test/ole/cppToUno/makefile.mk b/extensions/test/ole/cppToUno/makefile.mk
new file mode 100644
index 000000000000..19942030b27c
--- /dev/null
+++ b/extensions/test/ole/cppToUno/makefile.mk
@@ -0,0 +1,65 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ=..$/..$/..
+
+PRJNAME=extensions
+TARGET=testcppuno
+TARGETTYPE=CUI
+LIBTARGET=NO
+
+ENABLE_EXCEPTIONS=TRUE
+
+# --- Settings ---
+
+.INCLUDE : settings.mk
+
+# --- Files ---
+
+INCPRE+=-I$(ATL_INCLUDE)
+
+
+
+APP1TARGET= $(TARGET)
+APP1OBJS= $(OBJ)$/testcppuno.obj
+
+APP1STDLIBS= \
+ $(SALLIB) \
+ $(CPPUHELPERLIB) \
+ $(CPPULIB) \
+ $(USER32LIB) \
+ $(KERNEL32LIB) \
+ $(OLE32LIB) \
+ $(OLEAUT32LIB) \
+ $(UUIDLIB) \
+ $(COMDLG32LIB) \
+ $(GDI32LIB)
+
+APP1DEF= $(MISC)$/$(APP1TARGET).def
+
+# --- Targets ---
+.INCLUDE : target.mk
diff --git a/extensions/test/ole/cppToUno/readme.txt b/extensions/test/ole/cppToUno/readme.txt
new file mode 100644
index 000000000000..1a57d8524451
--- /dev/null
+++ b/extensions/test/ole/cppToUno/readme.txt
@@ -0,0 +1,9 @@
+testcppuno.exe currently tests the conversion of SAFEARRAYs. There is
+no output from the program. Just step through the code.
+
+To run the test, the service oletest.OleTest ( extensions/test/ole/cpnt)
+must be in the same directory as the office dlls and it must be registered
+at the applicat.rdb. Also the type information must have been merged with
+applicat.rdb. The program requires an office to be present. Put testcppuno
+into the Office/program folder and run it there.
+ \ No newline at end of file
diff --git a/extensions/test/ole/cppToUno/testcppuno.cxx b/extensions/test/ole/cppToUno/testcppuno.cxx
new file mode 100644
index 000000000000..d1606c343d73
--- /dev/null
+++ b/extensions/test/ole/cppToUno/testcppuno.cxx
@@ -0,0 +1,222 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+
+#pragma warning(disable: 4917)
+#include <windows.h>
+#include <comdef.h>
+#include <tchar.h>
+#include <atlbase.h>
+#include<atlcom.h>
+#include <stdio.h>
+#include <com/sun/star/bridge/ModelDependent.hpp>
+#include <com/sun/star/bridge/XBridgeSupplier2.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/script/XInvocation.hpp>
+#include <oletest/XCallback.hpp>
+#include <rtl/process.h>
+#include <com/sun/star/uno/Reference.h>
+#include <cppuhelper/servicefactory.hxx>
+#include <rtl/string.h>
+
+
+
+using namespace com::sun::star::lang;
+using namespace com::sun::star::uno;
+using namespace com::sun::star::script;
+using namespace com::sun::star::bridge;
+using namespace com::sun::star::bridge::ModelDependent;
+using namespace cppu;
+using namespace rtl;
+HRESULT doTest();
+bool incrementMultidimensionalIndex(
+ sal_Int32 dimensions,
+ const sal_Int32 * parDimensionLengths,
+ sal_Int32 * parMultidimensionalIndex);
+
+int __cdecl _tmain( int /*argc*/, _TCHAR * /*argv[]*/ )
+{
+ HRESULT hr;
+ if( FAILED( hr=CoInitialize(NULL)))
+ {
+ _tprintf(_T("CoInitialize failed \n"));
+ return -1;
+ }
+
+
+ if( FAILED(hr=doTest()))
+ {
+ _com_error err( hr);
+ const TCHAR * errMsg= err.ErrorMessage();
+ MessageBox( NULL, errMsg, "Test failed", MB_ICONERROR);
+ }
+
+ CoUninitialize();
+ return 0;
+}
+
+
+
+
+HRESULT doTest()
+{
+ HRESULT hr= S_OK;
+ long j = 0;
+ SAFEARRAY* par;
+ CComDispatchDriver disp;
+ CComVariant result;
+ CComVariant param1;
+ CComPtr<IUnknown> spUnkFactory;
+ if( SUCCEEDED( spUnkFactory.CoCreateInstance(L"com.sun.star.ServiceManager")))
+ {
+ disp= spUnkFactory;
+ param1= L"oletest.OleTest";
+ disp.Invoke1( L"createInstance", &param1, &result);
+
+ disp= result.pdispVal;
+
+ // disp contains now oletest.OleTest
+
+ // one dimensional array
+ par= SafeArrayCreateVector( VT_UI1, 0, 5);
+ unsigned char arbyte[]= { 1,2,3,4,5};
+ for(long i= 0; i < 5;i++)
+ hr= SafeArrayPutElement( par, &i, &arbyte[i]);
+
+ result.Clear();
+ param1.vt= VT_ARRAY| VT_UI1;
+ param1.byref= par;
+ disp.Invoke1(L"methodByte", &param1, &result);
+ SafeArrayDestroy( par);
+
+
+ // two dimensional array
+ SAFEARRAYBOUND bounds[2];
+ // least significant dimension first, Dimension 1
+ bounds[0].cElements= 3;
+ bounds[0].lLbound= 0;
+ // Dimension 2
+ bounds[1].cElements= 2;
+ bounds[1].lLbound= 0;
+ par= SafeArrayCreate( VT_I4, 2, bounds );
+
+ long uBound1;
+ long uBound2;
+ hr= SafeArrayGetUBound( par, 1, &uBound1);
+ hr= SafeArrayGetUBound( par, 2, &uBound2);
+
+ long index2[2];
+ memset( index2, 0, 2 * sizeof( long) );
+ long dimLengths[]={3,2};
+
+ long data;
+ do
+ {
+ data= index2[1] * 3 + index2[0] +1;
+ hr= SafeArrayPutElement( par, index2, &data);
+ }while( incrementMultidimensionalIndex( 2, dimLengths, index2) );
+
+ long* pdata;
+ long (*dataL)[2][3];
+ hr= SafeArrayAccessData( par, (void**)&pdata);
+ dataL= (long(*)[2][3])pdata;
+
+ for (long i= 0; i < 2; i ++)
+ {
+ for(long j= 0; j < 3; j++)
+ data= (*dataL)[i][j];
+ }
+ hr= SafeArrayUnaccessData(par);
+
+ result.Clear();
+ param1.vt= VT_ARRAY | VT_I4;
+ param1.byref= par;
+ disp.Invoke1(L"methodSequence", &param1, &result);
+
+ SAFEARRAY* arRet= result.parray;
+
+ for(long i= 0; i < 2 ; i++)
+ {
+ CComVariant varx;
+ varx.Clear();
+ hr= SafeArrayGetElement( arRet, &i, &varx);
+ SAFEARRAY* ari= varx.parray;
+
+ for( j= 0; j < 3; j++)
+ {
+ CComVariant varj;
+ varj.Clear();
+ hr= SafeArrayGetElement( ari, &j, &varj);
+ }
+
+
+
+ }
+ SafeArrayDestroy( par);
+ }
+
+ return hr;
+}
+
+// left index is least significant
+bool incrementMultidimensionalIndex(
+ sal_Int32 dimensions,
+ const sal_Int32 * parDimensionLengths,
+ sal_Int32 * parMultidimensionalIndex)
+{
+ if( dimensions < 1)
+ return sal_False;
+
+ bool ret= sal_True;
+ bool carry= sal_True; // to get into the while loop
+
+ sal_Int32 currentDimension= 0; //most significant is 1
+ while( carry)
+ {
+ parMultidimensionalIndex[ currentDimension ]++;
+ // if carryover, set index to 0 and handle carry on a level above
+ if( parMultidimensionalIndex[ currentDimension] > (parDimensionLengths[ currentDimension] - 1))
+ parMultidimensionalIndex[ currentDimension]= 0;
+ else
+ carry= sal_False;
+
+ currentDimension ++;
+ // if dimensions drops below 1 and carry is set than then all indices are 0 again
+ // this is signalled by returning sal_False
+ if( currentDimension > dimensions - 1 && carry)
+ {
+ carry= sal_False;
+ ret= sal_False;
+ }
+ }
+ return ret;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/test/ole/cpptest/cpptest.cxx b/extensions/test/ole/cpptest/cpptest.cxx
new file mode 100644
index 000000000000..9582415dfdfe
--- /dev/null
+++ b/extensions/test/ole/cpptest/cpptest.cxx
@@ -0,0 +1,116 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+// cpptest.cpp : Defines the entry point for the console application.
+//
+
+#if _MSC_VER > 1000
+#pragma once
+#endif // _MSC_VER > 1000
+#pragma warning(disable: 4917)
+#include <comdef.h>
+#include <tchar.h>
+#include<atlbase.h>
+#include<atlcom.h>
+
+HRESULT doTest();
+
+int main(int /*argc*/, char** /*argv*/)
+{
+ HRESULT hr;
+ if( FAILED( hr=CoInitialize(NULL)))
+ {
+ _tprintf(_T("CoInitialize failed \n"));
+ return -1;
+ }
+
+ if( FAILED(hr=doTest()))
+ {
+ _com_error err( hr);
+ const TCHAR * errMsg= err.ErrorMessage();
+ MessageBox( NULL, errMsg, "Test failed", MB_ICONERROR);
+ }
+
+ CoUninitialize();
+ return 0;
+}
+
+HRESULT doTest()
+{
+ HRESULT hr;
+ CComPtr<IUnknown> spUnkMgr;
+
+
+ if( FAILED(hr= spUnkMgr.CoCreateInstance(L"com.sun.star.ServiceManager")))
+ return hr;
+
+ IDispatchPtr starManager;
+ // var starManager=new ActiveXObject("com.sun.star.ServiceManager");
+ if (FAILED(hr= starManager.CreateInstance(_T("com.sun.star.ServiceManager"))))
+ {
+ fprintf(stderr, "creating ServiceManager failed\n");
+ return hr;
+ }
+ // var starDesktop=starManager.createInstance("com.sun.star.frame.Desktop");
+ _variant_t varP1(L"com.sun.star.frame.Desktop");
+ _variant_t varRet;
+ CComDispatchDriver dispMgr(starManager);
+ if (FAILED(hr= dispMgr.Invoke1(L"createInstance", &varP1, &varRet)))
+ {
+ fprintf(stderr,"createInstance of Desktop failed\n");
+ return hr;
+ }
+ CComDispatchDriver dispDesk(varRet.pdispVal);
+ varP1.Clear();
+ varRet.Clear();
+ // var bOK=new Boolean(true);
+
+ // var noArgs=new Array();
+ // var oDoc=starDesktop.loadComponentFromURL("private:factory/swriter", "Test", 40, noArgs);
+ IDispatchPtr oDoc;
+ SAFEARRAY* ar= SafeArrayCreateVector(VT_DISPATCH, 0, 0);
+ _variant_t args[4];
+ args[3]= _variant_t(L"private:factory/swriter");
+ args[2]= _variant_t(L"Test");
+ args[1]= _variant_t((long) 40);
+ args[0].vt= VT_ARRAY | VT_DISPATCH;;
+ args[0].parray= ar;
+ if (FAILED(hr= dispDesk.InvokeN(L"loadComponentFromURL", args, 4, &varRet)))
+ {
+ fprintf(stderr,"loadComponentFromURL failed\n");
+ return hr;
+ }
+ CComDispatchDriver dispDoc(varRet.pdispVal);
+ varRet.Clear();
+ return S_OK;
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/test/ole/cpptest/makefile.mk b/extensions/test/ole/cpptest/makefile.mk
new file mode 100644
index 000000000000..af97b63c7c9d
--- /dev/null
+++ b/extensions/test/ole/cpptest/makefile.mk
@@ -0,0 +1,64 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ=..$/..$/..
+
+PRJNAME=extensions
+TARGET=cppTest
+TARGETTYPE=CUI
+LIBTARGET=NO
+
+ENABLE_EXCEPTIONS=TRUE
+
+# --- Settings ---
+
+.INCLUDE : settings.mk
+
+# --- Files ---
+
+INCPRE+=-I$(ATL_INCLUDE)
+
+
+APP1TARGET= $(TARGET)
+APP1OBJS= $(OBJ)$/cppTest.obj
+
+APP1STDLIBS= \
+ $(SALLIB) \
+ $(CPPUHELPERLIB) \
+ $(CPPULIB) \
+ $(USER32LIB) \
+ $(KERNEL32LIB) \
+ $(OLE32LIB) \
+ $(OLEAUT32LIB) \
+ $(UUIDLIB) \
+ $(COMDLG32LIB) \
+ comsupp.lib
+
+APP1DEF= $(MISC)\$(APP1TARGET).def
+
+# --- Targets ---
+.INCLUDE : target.mk
diff --git a/extensions/test/ole/cpptest/readme.txt b/extensions/test/ole/cpptest/readme.txt
new file mode 100644
index 000000000000..4af8cfee39af
--- /dev/null
+++ b/extensions/test/ole/cpptest/readme.txt
@@ -0,0 +1,6 @@
+Creates the com.sun.star.ServiceManager with CoCreateInstance in a cpp program.
+This little program can be used as starting point for further tests.
+
+
+It needs uwinapi.dll, which is in the program folder of OOo (URE\bin in
+OOo 3.0)
diff --git a/extensions/test/ole/idl/oletest.idl b/extensions/test/ole/idl/oletest.idl
new file mode 100644
index 000000000000..c62c236de052
--- /dev/null
+++ b/extensions/test/ole/idl/oletest.idl
@@ -0,0 +1,308 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include <com/sun/star/uno/XInterface.idl>
+#include <com/sun/star/script/XInvocation.idl>
+#include <com/sun/star/beans/XPropertySet.idl>
+#include <com/sun/star/lang/XEventListener.idl>
+
+
+module oletest
+{
+
+interface XTestSequence: com::sun::star::uno::XInterface
+{
+ sequence<byte> methodByte( [in] sequence<byte> aSeq );
+ sequence<float> methodFloat( [in] sequence<float> aSeq);
+ sequence<double> methodDouble( [in] sequence<double> aSeq);
+ sequence<boolean> methodBool( [in] sequence<boolean> aSeq);
+ sequence<short> methodShort( [in] sequence<short> aSeq);
+ sequence<unsigned short> methodUShort( [in] sequence<unsigned short> aSeq);
+ sequence<long> methodLong( [in] sequence<long> aSeq);
+ sequence<unsigned long> methodULong( [in] sequence<unsigned long> aSeq);
+ sequence<string> methodString( [in] sequence<string> aSeq);
+ sequence<char> methodChar( [in] sequence<char> aSeq);
+ sequence<any> methodAny ( [in] sequence<any> aSeq);
+ sequence<type> methodType ( [in] sequence<type> aSeq);
+ sequence<com::sun::star::uno::XInterface> methodXInterface ( [in] sequence<com::sun::star::uno::XInterface> aSeq);
+ sequence< sequence <long> > methodSequence( [in] sequence< sequence< long > > aSeq);
+ sequence< sequence <sequence <long> > > methodSequence2( [in] sequence< sequence< sequence<long> > > aSeq);
+ sequence< com::sun::star::lang::XEventListener > methodXEventListeners( [in] sequence<com::sun::star::lang::XEventListener> aSeq);
+ sequence< sequence< com::sun::star::lang::XEventListener > > methodXEventListenersMul( [in] sequence< sequence< com::sun::star::lang::XEventListener> > aSeq);
+
+ [attribute] sequence<byte> AttrByte;
+ [attribute] sequence<float> AttrFloat;
+ [attribute] sequence<double> AttrDouble;
+ [attribute] sequence<boolean> AttrBool;
+ [attribute] sequence<short> AttrShort;
+ [attribute] sequence<unsigned short> AttrUShort;
+ [attribute] sequence<long> AttrLong;
+ [attribute] sequence<unsigned long> AttrULong;
+ [attribute] sequence<string> AttrString;
+ [attribute] sequence<char> AttrChar;
+ [attribute] sequence<any> AttrAny;
+ [attribute] sequence<type> AttrType;
+ [attribute] sequence< sequence<long> > AttrSequence;
+ [attribute] sequence< sequence< sequence <long> > > AttrSequence2;
+ [attribute] sequence< com::sun::star::uno::XInterface > AttrXInterface;
+
+ [attribute] byte AByte;
+ [attribute] float AFloat;
+ [attribute] double ADouble;
+ [attribute] boolean ABool;
+ [attribute] short AShort;
+ [attribute] unsigned short AUShort;
+ [attribute] long ALong;
+ [attribute] unsigned long AULong;
+ [attribute] string AString;
+ [attribute] char AChar;
+ [attribute] any AAny;
+ [attribute] type AType;
+ [attribute] com::sun::star::uno::XInterface AXInterface;
+ [attribute] com::sun::star::script::XInvocation AXInvocation;
+
+ void testout_methodByte( [out] byte rOut );
+ void testout_methodFloat( [out] float rOut);
+ void testout_methodDouble( [out] double rOut);
+ void testout_methodBool( [out] boolean rOut);
+ void testout_methodShort( [out] short rOut);
+ void testout_methodUShort( [out] unsigned short rOut);
+ void testout_methodLong( [out] long rOut);
+ void testout_methodULong( [out] unsigned long rOut);
+ void testout_methodHyper( [out] hyper rOut);
+ void testout_methodUHyper( [out] unsigned hyper rOut);
+ void testout_methodString( [out] string rOut);
+ void testout_methodChar( [out] char rOut);
+ void testout_methodAny ( [out] any rOut);
+ void testout_methodType ( [out] type rOut);
+ void testout_methodSequence( [out] sequence< long > rOut);
+ void testout_methodSequence2( [out] sequence < sequence< long > > rOut);
+ void testout_methodXInterface( [out] com::sun::star::uno::XInterface rOut);
+
+ void testout_methodMulParams1( [out] long rout1, [out] long rout2);
+ void testout_methodMulParams2( [out] long rout1, [out] long rout2, [out] string rout3);
+ void testout_methodMulParams3( [in] string sin, [out] string sout);
+ void testout_methodMulParams4( [in] float in1, [out] float out1, [in] long in2, [out] long out2, [in] long in3);
+
+ void testinout_methodByte( [inout] byte rOut );
+ void testinout_methodFloat( [inout] float rOut);
+ void testinout_methodDouble( [inout] double rOut);
+ void testinout_methodBool( [inout] boolean rOut);
+ void testinout_methodShort( [inout] short rOut);
+ void testinout_methodUShort( [inout] unsigned short rOut);
+ void testinout_methodLong( [inout] long rOut);
+ void testinout_methodULong( [inout] unsigned long rOut);
+ void testinout_methodHyper( [inout] hyper rOut);
+ void testinout_methodUHyper( [inout] unsigned hyper rOut);
+ void testinout_methodString( [inout] string rOut);
+ void testinout_methodChar( [inout] char rOut);
+ void testinout_methodAny ( [inout] any rOut);
+ void testinout_methodType ( [inout] type rOut);
+ void testinout_methodSequence( [inout] sequence< long > rOut);
+ void testinout_methodSequence2( [inout] sequence < sequence< long > > rOut);
+ void testinout_methodXInterface( [inout] com::sun::star::script::XInvocation rOut);
+ void testinout_methodXInterface2( [inout] com::sun::star::uno::XInterface rOut);
+
+ any methodAnyTest1( [in] any rIn);
+ [attribute] any AttrAny2;
+
+};
+interface XTestStruct: com::sun::star::uno::XInterface
+{
+// Method taking structs as arguments
+ void methodStruct( [in] com::sun::star::beans::Property aProp);
+// Methods returning structs
+ com::sun::star::beans::Property retMethodStruct();
+// Attributes as structs
+ [attribute] com::sun::star::beans::Property AttrStruct;
+
+ com::sun::star::beans::Property methodStruct2( [in] com::sun::star::beans::Property aProp);
+};
+
+
+struct SimpleStruct
+{
+ string message;
+};
+
+interface XTestInParameters: com::sun::star::uno::XInterface
+{
+ byte in_methodByte( [in] byte rIn );
+ float in_methodFloat( [in] float rIn);
+ double in_methodDouble( [in] double rIn);
+ boolean in_methodBool( [in] boolean rIn);
+ short in_methodShort( [in] short rIn);
+ unsigned short in_methodUShort( [in] unsigned short rIn);
+ long in_methodLong( [in] long rIn);
+ unsigned long in_methodULong( [in] unsigned long rIn);
+ hyper in_methodHyper( [in] hyper rIn);
+ unsigned hyper in_methodUHyper( [in] unsigned hyper rIn);
+ string in_methodString( [in] string rIn);
+ char in_methodChar( [in] char rIn);
+ any in_methodAny ( [in] any rIn);
+ type in_methodType ( [in] type rIn);
+ com::sun::star::uno::XInterface in_methodXInterface([in] com::sun::star::uno::XInterface rIn);
+ com::sun::star::script::XInvocation in_methodInvocation( [in] com::sun::star::script::XInvocation inv);
+ SimpleStruct in_methodStruct( [in] SimpleStruct aStruct);
+ void in_methodAll( [in] byte b, [in] float f, [in] double d, [in] boolean abool, [in]short sh,
+ [in] unsigned short us, [in] long l, [in] unsigned long ul,
+ [in] string s, [in] char c, [in] any a, [in] type t, [in] com::sun::star::script::XInvocation inv);
+};
+
+
+enum SimpleEnum
+{
+ A,
+ B,
+ C
+};
+
+interface XTestOther: com::sun::star::uno::XInterface
+{
+ // Any test
+ void other_methodAnyIn( [in] any rAny);
+ void other_methodAnyOut( [out] any rAny);
+ any other_methodAnyRet();
+ void in_float( [in] float val);
+ //typeInAny determines what type must be in rAny. If rAny contains
+ //a different type then an exception is being thrown
+ any other_methodAny([in] any rAny, [in] string typeInAny);
+};
+
+
+interface XSimple: com::sun::star::uno::XInterface
+{
+ void func( [in] string message);
+ string getName();
+};
+
+interface XSimple2: com::sun::star::uno::XInterface
+{
+ void func2( [in] string message);
+ string getName2();
+};
+
+interface XSimple3: com::sun::star::uno::XInterface
+{
+ void func3( [in] string message);
+ string getName3();
+};
+
+
+interface XCallback: com::sun::star::uno::XInterface
+{
+ void func1();
+ oletest::XSimple returnInterface();
+ void outInterface( [out] oletest::XSimple outInterface);
+ void outStruct( [out] oletest::SimpleStruct outStruct);
+ void outEnum( [out] oletest::SimpleEnum outEnum);
+ void outSeqAny( [out] sequence<any> outSeqAny);
+ void outSeqByte( [out] sequence<byte> outVal);
+ void outAny( [out] any outAny);
+ void outBool( [out] boolean outBool);
+ void outChar( [out] char outChar);
+ void outString( [out] string outString);
+ void outFloat( [out] float outFloat);
+ void outDouble( [out] double outDouble);
+ void outByte( [out] byte outByte);
+ void outShort( [out] short outShort);
+ void outLong( [out] long outLong);
+ void outValuesMixed( [in] long lval, [out] long outval, [in] string sval);
+ void outValuesAll( [out] oletest::XSimple outInterface,
+ [out] SimpleStruct outStruct ,
+ [out] SimpleEnum outEnum,
+ [out] sequence<any> outSeqAny,
+ [out] any outAny,
+ [out] boolean outBool,
+ [out] char outChar,
+ [out] string outString,
+ [out] float outFloat,
+ [out] double outDouble,
+ [out] byte outByte,
+ [out] short outShort,
+ [out] long outLong);
+// IN OUT parameters
+ void inoutInterface( [inout] oletest::XSimple inoutVal);
+ void inoutStruct( [inout] oletest::SimpleStruct inoutVal);
+ void inoutEnum( [inout] oletest::SimpleEnum inoutVal);
+ void inoutSeqAny( [inout] sequence<any> inoutVal);
+ void inoutAny( [inout] any inoutVal);
+ void inoutBool( [inout] boolean inoutVal);
+ void inoutChar( [inout] char inoutVal);
+ void inoutString( [inout] string inoutVal);
+ void inoutFloat( [inout] float inoutVal);
+ void inoutDouble( [inout] double inoutVal);
+ void inoutByte( [inout] byte inoutVal);
+ void inoutShort( [inout] short inoutVal);
+ void inoutLong( [inout] long inoutVal);
+
+ void inoutValuesAll( [inout] oletest::XSimple aXSimple,
+ [inout] oletest::SimpleStruct aStruct,
+ [inout] oletest::SimpleEnum aEnum,
+ [inout] sequence<any> aSeq,
+ [inout] any aAny,
+ [inout] boolean aBool,
+ [inout] char aChar,
+ [inout] string aString,
+ [inout] float aFloat,
+ [inout] double aDouble,
+ [inout] byte aByte,
+ [inout] short aShort,
+ [inout] long aLong);
+
+ // IN parameter
+
+ void inValues( [in] char aChar, [in] long aLong, [in] string aString);
+ void inSeqByte( [in] sequence<byte> val);
+ void inSeqXEventListener( [in] sequence<com::sun::star::lang::XEventListener> listener, [in]
+ sequence<com::sun::star::lang::EventObject> events);
+
+ // Attributes
+ [attribute] oletest::XSimple simple;
+
+
+
+
+};
+
+interface XTestInterfaces: com::sun::star::uno::XInterface
+{
+ // Any test
+ void testInterface( [in] oletest::XCallback xCallback, [in] long mode);
+ void testInterface2( [in] oletest::XSimple xSimple, [in] long mode);
+};
+
+interface XIdentity: com::sun::star::uno::XInterface
+{
+ void setObject([in] com::sun::star::uno::XInterface val);
+ boolean isSame( [in] com::sun::star::uno::XInterface val);
+
+ com::sun::star::uno::XInterface getThis();
+};
+
+}; // oletest
+
diff --git a/extensions/test/ole/unloading/makefile.mk b/extensions/test/ole/unloading/makefile.mk
new file mode 100644
index 000000000000..c45163813c27
--- /dev/null
+++ b/extensions/test/ole/unloading/makefile.mk
@@ -0,0 +1,70 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+PRJ=..$/..$/..
+
+PRJNAME= extensions
+TARGET= unloadtest
+TARGETTYPE=CUI
+COMP1TYPELIST=$(TARGET1)
+
+ENABLE_EXCEPTIONS=TRUE
+
+USE_DEFFILE= TRUE
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+
+# ------------------------------------------------------------------
+
+APP1NOSAL=TRUE
+
+APP1TARGET= $(TARGET)
+
+APP1OBJS= $(OBJ)$/unloadTest.obj
+
+APP1STDLIBS= \
+ $(SALLIB) \
+ $(CPPUHELPERLIB) \
+ $(CPPULIB)
+
+# all: \
+# $(BINDIR) \
+# $(BINDIR)$/test.ini \
+# ALLTAR
+
+# $(BINDIR) :
+# @@-$(MKDIR) $(BINDIR)
+
+# $(BINDIR)$/test.ini : .$/unloadtest.ini
+# -$(GNUCOPY) .$/unloadtest.ini $(BINDIR)
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : target.mk
+
+
diff --git a/extensions/test/ole/unloading/readme.txt b/extensions/test/ole/unloading/readme.txt
new file mode 100644
index 000000000000..d8b467ddfc8a
--- /dev/null
+++ b/extensions/test/ole/unloading/readme.txt
@@ -0,0 +1,6 @@
+This project builds a unloadtest.exe.
+
+Function: Tests if the unloading mechanism works with the olebrdg.dll.
+In several tests, all services are created and destroyed and rtl_unloadUnusedModules is called.
+
+Usage: copy into the <Office>\program directory and run there.
diff --git a/extensions/test/ole/unloading/unloadTest.cxx b/extensions/test/ole/unloading/unloadTest.cxx
new file mode 100644
index 000000000000..ccedf0bd2f74
--- /dev/null
+++ b/extensions/test/ole/unloading/unloadTest.cxx
@@ -0,0 +1,229 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+
+#include<osl/module.hxx>
+#include <osl/time.h>
+#include <rtl/ustring.hxx>
+#include <stdio.h>
+#include <cppuhelper/factory.hxx>
+#include <cppuhelper/servicefactory.hxx>
+#include <cppuhelper/bootstrap.hxx>
+#include <com/sun/star/lang/XMultiComponentFactory.hpp>
+#include <com/sun/star/lang/XSingleServiceFactory.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/lang/XComponent.hpp>
+#include <com/sun/star/uno/XComponentContext.hpp>
+#include <com/sun/star/registry/XSimpleRegistry.hpp>
+
+#include <stdio.h>
+using namespace ::rtl;
+using namespace ::osl;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::lang;
+using namespace ::cppu;
+using namespace ::com::sun::star::registry;
+
+
+sal_Bool test1();
+sal_Bool test2();
+sal_Bool test3();
+sal_Bool test4();
+
+int main(int, char**)
+{
+ sal_Bool bTest1= test1();
+ sal_Bool bTest2= test2();
+ sal_Bool bTest3= test3();
+ sal_Bool bTest4= test4();
+
+ if( bTest1 && bTest2 && bTest3 && bTest4)
+ printf("\n#########################\n Test was successful\n#######################\n");
+
+ return 0;
+}
+
+sal_Bool test1()
+{
+ printf("\n Test1: com.sun.star.bridge.oleautomation.BridgeSupplier\n");
+ Reference<XSimpleRegistry> xreg= createSimpleRegistry();
+ xreg->open( OUString( RTL_CONSTASCII_USTRINGPARAM("services.rdb")),
+ sal_False, sal_False );
+
+ Reference< XComponentContext > context= bootstrap_InitialComponentContext(xreg);
+ Reference<XMultiComponentFactory> fac= context->getServiceManager();
+ OUString sService1( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.bridge.oleautomation.BridgeSupplier"));
+ Reference<XInterface> xint1= fac->createInstanceWithContext( sService1, context);
+
+ OUString sModule(
+ RTL_CONSTASCII_USTRINGPARAM("oleautobridge.uno" SAL_DLLEXTENSION));
+ oslModule hMod= osl_loadModule( sModule.pData, 0);
+ osl_unloadModule( hMod);
+
+ rtl_unloadUnusedModules( NULL);
+
+ OUString sFactoryFunc( RTL_CONSTASCII_USTRINGPARAM("component_getFactory"));
+ void* pSymbol= osl_getSymbol( hMod,sFactoryFunc.pData);
+ // true, instance alive
+ sal_Bool bTest1= pSymbol ? sal_True : sal_False;
+
+ xint1=0;
+ rtl_unloadUnusedModules( NULL);
+ pSymbol= osl_getSymbol( hMod,sFactoryFunc.pData);
+ sal_Bool bTest2= pSymbol ? sal_False : sal_True;
+
+ Reference<XComponent> xcomp( context, UNO_QUERY);
+ xcomp->dispose();
+
+ return bTest2 && bTest1;
+}
+
+sal_Bool test2()
+{
+ printf("Test2: com.sun.star.bridge.OleBridgeSupplierVar1\n");
+ Reference<XSimpleRegistry> xreg= createSimpleRegistry();
+ xreg->open( OUString( RTL_CONSTASCII_USTRINGPARAM("services.rdb")),
+ sal_False, sal_False );
+
+ Reference< XComponentContext > context= bootstrap_InitialComponentContext(xreg);
+ Reference<XMultiComponentFactory> fac= context->getServiceManager();
+ OUString sService2( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.bridge.OleBridgeSupplierVar1"));
+ Reference<XInterface> xint= fac->createInstanceWithContext( sService2, context);
+
+ OUString sModule(
+ RTL_CONSTASCII_USTRINGPARAM("oleautobridge.uno" SAL_DLLEXTENSION));
+ oslModule hMod= osl_loadModule( sModule.pData, 0);
+ osl_unloadModule( hMod);
+
+ rtl_unloadUnusedModules( NULL);
+ OUString sFactoryFunc( RTL_CONSTASCII_USTRINGPARAM("component_getFactory"));
+ void* pSymbol= osl_getSymbol( hMod,sFactoryFunc.pData);
+ // true, instance alive
+ sal_Bool bTest1= pSymbol ? sal_True : sal_False;
+
+ xint=0;
+ rtl_unloadUnusedModules( NULL);
+ pSymbol= osl_getSymbol( hMod,sFactoryFunc.pData);
+ sal_Bool bTest2= pSymbol ? sal_False : sal_True;
+
+ Reference<XComponent> xcomp( context, UNO_QUERY);
+ xcomp->dispose();
+ return bTest1 && bTest2;
+}
+
+sal_Bool test3()
+{
+ printf("Test3: com.sun.star.bridge.oleautomation.Factory\n");
+ Reference<XSimpleRegistry> xreg= createSimpleRegistry();
+ xreg->open( OUString( RTL_CONSTASCII_USTRINGPARAM("services.rdb")),
+ sal_False, sal_False );
+
+ Reference< XComponentContext > context= bootstrap_InitialComponentContext(xreg);
+
+ Reference<XMultiComponentFactory> fac= context->getServiceManager();
+ OUString sService( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.bridge.oleautomation.Factory"));
+ Reference<XInterface> xint= fac->createInstanceWithContext( sService, context);
+
+
+ OUString sModule(
+ RTL_CONSTASCII_USTRINGPARAM("oleautobridge.uno" SAL_DLLEXTENSION));
+ oslModule hMod= osl_loadModule( sModule.pData, 0);
+ osl_unloadModule( hMod);
+
+ rtl_unloadUnusedModules( NULL);
+ OUString sFactoryFunc( RTL_CONSTASCII_USTRINGPARAM("component_getFactory"));
+ void* pSymbol= osl_getSymbol( hMod,sFactoryFunc.pData);
+ // true, instance alive
+ sal_Bool bTest1= pSymbol ? sal_True : sal_False;
+
+ xint=0;
+ rtl_unloadUnusedModules( NULL);
+ pSymbol= osl_getSymbol( hMod,sFactoryFunc.pData);
+ sal_Bool bTest2= pSymbol ? sal_False : sal_True;
+
+ Reference<XComponent> xcomp( context, UNO_QUERY);
+ xcomp->dispose();
+
+// for (int i=0; i < 10; i++)
+// {
+// Reference<XSimpleRegistry> xreg= createSimpleRegistry();
+// xreg->open( OUString( RTL_CONSTASCII_USTRINGPARAM("applicat.rdb")),
+// sal_False, sal_False );
+// Reference< XComponentContext > context= bootstrap_InitialComponentContext(xreg);
+// Reference<XComponent> xcomp( context, UNO_QUERY);
+// xcomp->dispose();
+//
+// }
+
+// return sal_True;
+ return bTest1 && bTest2;
+}
+
+sal_Bool test4()
+{
+ void* pSymbol= NULL;
+ sal_Bool bTest1= sal_False;
+ sal_Bool bTest2= sal_False;
+ oslModule hMod= NULL;
+ OUString sModule(
+ RTL_CONSTASCII_USTRINGPARAM("oleautobridge.uno" SAL_DLLEXTENSION));
+ OUString sFactoryFunc( RTL_CONSTASCII_USTRINGPARAM("component_getFactory"));
+ {
+ printf("Test4: com.sun.star.bridge.oleautomation.ApplicationRegistration\n");
+ Reference<XSimpleRegistry> xreg= createSimpleRegistry();
+ xreg->open( OUString( RTL_CONSTASCII_USTRINGPARAM("services.rdb")),
+ sal_False, sal_False );
+
+ Reference< XComponentContext > context= bootstrap_InitialComponentContext(xreg);
+ Reference<XMultiComponentFactory> fac= context->getServiceManager();
+ OUString sService4( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.bridge.oleautomation.ApplicationRegistration"));
+ Reference<XInterface> xint= fac->createInstanceWithContext( sService4, context);
+
+ hMod= osl_loadModule( sModule.pData, 0);
+ osl_unloadModule( hMod);
+
+ rtl_unloadUnusedModules( NULL);
+ void* pSymbol= osl_getSymbol( hMod,sFactoryFunc.pData);
+ // true, instance alive
+ bTest1= pSymbol ? sal_True : sal_False;
+ // ApplicationRegistration is a one-instance-service, therefore kill service manager first
+ Reference<XComponent> xcomp( context, UNO_QUERY);
+ xcomp->dispose();
+
+ }
+ rtl_unloadUnusedModules( NULL);
+ pSymbol= osl_getSymbol( hMod,sFactoryFunc.pData);
+ bTest2= pSymbol ? sal_False : sal_True;
+
+ return bTest1 && bTest2;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/test/ole/unoTocomCalls/Test/StdAfx.cpp b/extensions/test/ole/unoTocomCalls/Test/StdAfx.cpp
new file mode 100644
index 000000000000..36ed10eddb1a
--- /dev/null
+++ b/extensions/test/ole/unoTocomCalls/Test/StdAfx.cpp
@@ -0,0 +1,37 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+// stdafx.cpp : source file that includes just the standard includes
+// Test.pch will be the pre-compiled header
+// stdafx.obj will contain the pre-compiled type information
+
+#include "stdafx.h"
+
+// TODO: reference any additional headers you need in STDAFX.H
+// and not in this file
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/test/ole/unoTocomCalls/Test/StdAfx.h b/extensions/test/ole/unoTocomCalls/Test/StdAfx.h
new file mode 100644
index 000000000000..65fffc04cffe
--- /dev/null
+++ b/extensions/test/ole/unoTocomCalls/Test/StdAfx.h
@@ -0,0 +1,58 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+// stdafx.h : include file for standard system include files,
+// or project specific include files that are used frequently, but
+// are changed infrequently
+//
+
+#if !defined(AFX_STDAFX_H__180FF568_6F5C_11D4_8330_005004526AB4__INCLUDED_)
+#define AFX_STDAFX_H__180FF568_6F5C_11D4_8330_005004526AB4__INCLUDED_
+
+#if _MSC_VER > 1000
+#pragma once
+#endif // _MSC_VER > 1000
+
+#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
+
+#include <stdio.h>
+#include <windows.h>
+#include <comdef.h>
+#include <tchar.h>
+#include <atlbase.h>
+extern CComModule _Module;
+#include<atlcom.h>
+#include<atlimpl.cpp>
+
+// TODO: reference additional headers your program requires here
+
+//{{AFX_INSERT_LOCATION}}
+// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
+
+#endif // !defined(AFX_STDAFX_H__180FF568_6F5C_11D4_8330_005004526AB4__INCLUDED_)
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/test/ole/unoTocomCalls/Test/Test.cpp b/extensions/test/ole/unoTocomCalls/Test/Test.cpp
new file mode 100644
index 000000000000..fcb121be6b2a
--- /dev/null
+++ b/extensions/test/ole/unoTocomCalls/Test/Test.cpp
@@ -0,0 +1,249 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+// Test.cpp : Defines the entry point for the console application.
+//
+
+#include "stdafx.h"
+#include "../XCallback_Impl/XCallback_Impl.h"
+#include "../XCallback_Impl/XCallback_Impl_i.c"
+
+CComModule _Module;
+BEGIN_OBJECT_MAP(ObjectMap)
+END_OBJECT_MAP()
+
+HRESULT doTest();
+
+int main(int argc, char* argv[])
+{
+ HRESULT hr;
+ if( FAILED( hr=CoInitialize(NULL)))
+ {
+ _tprintf(_T("CoInitialize failed \n"));
+ return -1;
+ }
+
+
+ _Module.Init( ObjectMap, GetModuleHandle( NULL));
+
+ if( FAILED(hr=doTest()))
+ {
+ _com_error err( hr);
+ const TCHAR * errMsg= err.ErrorMessage();
+ MessageBox( NULL, errMsg, "Test failed", MB_ICONERROR);
+ }
+
+
+ _Module.Term();
+ CoUninitialize();
+
+
+ return 0;
+}
+
+
+HRESULT doTest()
+{
+ HRESULT hr= S_OK;
+
+ CComPtr<IUnknown> spUnk;
+ hr= spUnk.CoCreateInstance(L"com.sun.star.ServiceManager");
+ if( FAILED( hr))
+ return hr;
+
+ CComDispatchDriver manager( spUnk);
+ CComVariant param( L"oletest.OleTest");
+ CComVariant retVal;
+ hr= manager.Invoke1((LPCOLESTR)L"createInstance", &param, &retVal );
+
+ CComDispatchDriver oletest( retVal.punkVal);
+
+ spUnk.Release();
+
+ hr= spUnk.CoCreateInstance(L"XCallback_Impl.Callback");
+ if( FAILED( hr))
+ return hr;
+
+ CComQIPtr<IDispatch> paramDisp(spUnk);
+
+
+ //######################################################################
+ // out parameters
+ //######################################################################
+ CComVariant param1( paramDisp);
+ CComVariant param2(1);
+
+ // oletest calls XCallback::func1
+ hr= oletest.Invoke2(L"testInterface", &param1, &param2);
+ // XCallback::returnInterface
+ param2= 2;
+ hr= oletest.Invoke2(L"testInterface", &param1, &param2);
+ // XCallback::outInterface
+ param2= 3;
+ hr= oletest.Invoke2(L"testInterface", &param1, &param2);
+ // XCallback::outStruct
+ param2= 4;
+ hr= oletest.Invoke2(L"testInterface", &param1, &param2);
+ // XCallback::outEnum
+ param2= 5;
+ hr= oletest.Invoke2(L"testInterface", &param1, &param2);
+ // XCallback::outSeqAny
+ param2= 6;
+ hr= oletest.Invoke2(L"testInterface", &param1, &param2);
+ // XCallback::outAny
+ param2= 7;
+ hr= oletest.Invoke2(L"testInterface", &param1, &param2);
+ // XCallback::outBool
+ param2= 8;
+ hr= oletest.Invoke2(L"testInterface", &param1, &param2);
+ // XCallback::outChar
+ param2= 9;
+ hr= oletest.Invoke2(L"testInterface", &param1, &param2);
+ // XCallback::outString
+ param2= 10;
+ hr= oletest.Invoke2(L"testInterface", &param1, &param2);
+ // XCallback::outFloat
+ param2= 11;
+ hr= oletest.Invoke2(L"testInterface", &param1, &param2);
+ // XCallback::outDouble
+ param2= 12;
+ hr= oletest.Invoke2(L"testInterface", &param1, &param2);
+ // XCallback::outByte
+ param2= 13;
+ hr= oletest.Invoke2(L"testInterface", &param1, &param2);
+ // XCallback::outShort
+ param2= 14;
+ hr= oletest.Invoke2(L"testInterface", &param1, &param2);
+ // XCallback::outLong
+ param2= 15;
+ hr= oletest.Invoke2(L"testInterface", &param1, &param2);
+ // XCallback::outValuesMixed
+ param2= 30;
+ hr= oletest.Invoke2(L"testInterface", &param1, &param2);
+ // XCallback::outValuesAll
+ param2= 31;
+ hr= oletest.Invoke2(L"testInterface", &param1, &param2);
+
+ // XCallback::outSeqByte
+ // Does not work currently because Sequences are always converted to
+ // SAFEARRAY( VARIANT)
+ // param2= 32;
+ // hr= oletest.Invoke2(L"testInterface", &param1, &param2);
+
+ //######################################################################
+ // in / out parameters
+ //######################################################################
+ // XCallback::inoutInterface
+ param2= 100;
+ hr= oletest.Invoke2(L"testInterface", &param1, &param2);
+ // XCallback::inoutStruct
+ param2= 101;
+ hr= oletest.Invoke2(L"testInterface", &param1, &param2);
+ // XCallback::inoutEnum
+ param2= 102;
+ hr= oletest.Invoke2(L"testInterface", &param1, &param2);
+ // XCallback::inoutSeqAny
+ param2= 103;
+ hr= oletest.Invoke2(L"testInterface", &param1, &param2);
+ // XCallback::inoutAny
+ param2= 104;
+ hr= oletest.Invoke2(L"testInterface", &param1, &param2);
+ // XCallback::inoutBool
+ param2= 105;
+ hr= oletest.Invoke2(L"testInterface", &param1, &param2);
+ // XCallback::inoutChar
+ param2= 106;
+ hr= oletest.Invoke2(L"testInterface", &param1, &param2);
+ // XCallback::inoutString
+ param2= 107;
+ hr= oletest.Invoke2(L"testInterface", &param1, &param2);
+ // XCallback::inoutFloat
+ param2= 108;
+ hr= oletest.Invoke2(L"testInterface", &param1, &param2);
+ // XCallback::inoutDouble
+ param2= 109;
+ hr= oletest.Invoke2(L"testInterface", &param1, &param2);
+ // XCallback::inoutByte
+ param2= 110;
+ hr= oletest.Invoke2(L"testInterface", &param1, &param2);
+ // XCallback::inoutShort
+ param2= 111;
+ hr= oletest.Invoke2(L"testInterface", &param1, &param2);
+ // XCallback::inoutLong
+ param2= 112;
+ hr= oletest.Invoke2(L"testInterface", &param1, &param2);
+ // XCallback::inoutValuesAll
+ param2=120;
+ hr= oletest.Invoke2(L"testInterface", &param1, &param2);
+ //######################################################################
+ // in parameters
+ //######################################################################
+ // XCallback::inValues
+ param2= 200;
+ hr= oletest.Invoke2(L"testInterface", &param1, &param2);
+ // XCallback::inSeqByte
+ // SAFEARRAY( VARIANT)
+ param2= 201;
+ hr= oletest.Invoke2(L"testInterface", &param1, &param2);
+ //XCallback::inSeqXEventListener
+ param2= 202;
+ hr= oletest.Invoke2(L"testInterface", &param1, &param2);
+ //######################################################################
+ // The UNO test component OleTest calls on XCallback_Impl.Callback directly
+ // that is the COM object has not been past a parameter but rather OleTest
+ // creates the COM object itself
+ //######################################################################
+ // XCallback::outValuesAll
+ // does not work currently
+ param2= 300;
+ hr= oletest.Invoke2(L"testInterface", &param1, &param2);
+ // XCallback::inoutValuesAll
+ param2= 301;
+ hr= oletest.Invoke2(L"testInterface", &param1, &param2);
+ // XCallback::inoutValues
+ param2= 302;
+ hr= oletest.Invoke2(L"testInterface", &param1, &param2);
+
+ // XCallback::inValues
+ param2= 303;
+ hr= oletest.Invoke2(L"testInterface", &param1, &param2);
+ //######################################################################
+ // Test a COM object which implements several interfaces.
+ //######################################################################
+
+ CComQIPtr<IDispatch> dispSimple;
+ hr= dispSimple.CoCreateInstance(L"XCallback_Impl.Simple");
+ CComVariant varSimple( dispSimple);
+ param2= 0;
+ hr= oletest.Invoke2(L"testInterface2", &varSimple, &param2);
+
+ return hr;
+}
+// VARIANT CComVariant VT_UNKNOWN VT_DISPATCH V_UI1 CComDispatchDriver WINAPI
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/test/ole/unoTocomCalls/Test/Test.dsp b/extensions/test/ole/unoTocomCalls/Test/Test.dsp
new file mode 100644
index 000000000000..d9ef4e865c52
--- /dev/null
+++ b/extensions/test/ole/unoTocomCalls/Test/Test.dsp
@@ -0,0 +1,114 @@
+# Microsoft Developer Studio Project File - Name="Test" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Console Application" 0x0103
+
+CFG=Test - Win32 Debug
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE
+!MESSAGE NMAKE /f "Test.mak".
+!MESSAGE
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE
+!MESSAGE NMAKE /f "Test.mak" CFG="Test - Win32 Debug"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "Test - Win32 Release" (based on "Win32 (x86) Console Application")
+!MESSAGE "Test - Win32 Debug" (based on "Win32 (x86) Console Application")
+!MESSAGE
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=cl.exe
+RSC=rc.exe
+
+!IF "$(CFG)" == "Test - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release"
+# PROP BASE Intermediate_Dir "Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Release"
+# PROP Intermediate_Dir "Release"
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /Yu"stdafx.h" /FD /c
+# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /Yu"stdafx.h" /FD /c
+# ADD BASE RSC /l 0x409 /d "NDEBUG"
+# ADD RSC /l 0x409 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
+
+!ELSEIF "$(CFG)" == "Test - Win32 Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "Debug"
+# PROP BASE Intermediate_Dir "Debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "Debug"
+# PROP Intermediate_Dir "Debug"
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /Yu"stdafx.h" /FD /GZ /c
+# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FR /Yu"stdafx.h" /FD /GZ /c
+# ADD BASE RSC /l 0x409 /d "_DEBUG"
+# ADD RSC /l 0x409 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
+
+!ENDIF
+
+# Begin Target
+
+# Name "Test - Win32 Release"
+# Name "Test - Win32 Debug"
+# Begin Group "Source Files"
+
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+# Begin Source File
+
+SOURCE=.\StdAfx.cpp
+# ADD CPP /Yc"stdafx.h"
+# End Source File
+# Begin Source File
+
+SOURCE=.\Test.cpp
+# End Source File
+# End Group
+# Begin Group "Header Files"
+
+# PROP Default_Filter "h;hpp;hxx;hm;inl"
+# Begin Source File
+
+SOURCE=.\StdAfx.h
+# End Source File
+# End Group
+# Begin Group "Resource Files"
+
+# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
+# End Group
+# Begin Source File
+
+SOURCE=.\ReadMe.txt
+# End Source File
+# End Target
+# End Project
+
diff --git a/extensions/test/ole/unoTocomCalls/Test/Test.sln b/extensions/test/ole/unoTocomCalls/Test/Test.sln
new file mode 100644
index 000000000000..428b736251d9
--- /dev/null
+++ b/extensions/test/ole/unoTocomCalls/Test/Test.sln
@@ -0,0 +1,19 @@
+Microsoft Visual Studio Solution File, Format Version 10.00
+# Visual Studio 2008
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Test", "Test.vcproj", "{13AE4BE8-2467-4B35-800F-154379D54C24}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Win32 = Debug|Win32
+ Release|Win32 = Release|Win32
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {13AE4BE8-2467-4B35-800F-154379D54C24}.Debug|Win32.ActiveCfg = Debug|Win32
+ {13AE4BE8-2467-4B35-800F-154379D54C24}.Debug|Win32.Build.0 = Debug|Win32
+ {13AE4BE8-2467-4B35-800F-154379D54C24}.Release|Win32.ActiveCfg = Release|Win32
+ {13AE4BE8-2467-4B35-800F-154379D54C24}.Release|Win32.Build.0 = Release|Win32
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
diff --git a/extensions/test/ole/unoTocomCalls/Test/Test.vcproj b/extensions/test/ole/unoTocomCalls/Test/Test.vcproj
new file mode 100644
index 000000000000..f31d1ffc4eaa
--- /dev/null
+++ b/extensions/test/ole/unoTocomCalls/Test/Test.vcproj
@@ -0,0 +1,247 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="9,00"
+ Name="Test"
+ ProjectGUID="{13AE4BE8-2467-4B35-800F-154379D54C24}"
+ TargetFrameworkVersion="131072"
+ >
+ <Platforms>
+ <Platform
+ Name="Win32"
+ />
+ </Platforms>
+ <ToolFiles>
+ </ToolFiles>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory=".\Debug"
+ IntermediateDirectory=".\Debug"
+ ConfigurationType="1"
+ InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC70.vsprops"
+ UseOfMFC="0"
+ ATLMinimizesCRunTimeLibraryUsage="false"
+ CharacterSet="2"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ TypeLibraryName=".\Debug/Test.tlb"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions="WIN32,_DEBUG,_CONSOLE"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="1"
+ UsePrecompiledHeader="2"
+ PrecompiledHeaderThrough="stdafx.h"
+ PrecompiledHeaderFile=".\Debug/Test.pch"
+ AssemblerListingLocation=".\Debug/"
+ ObjectFile=".\Debug/"
+ ProgramDataBaseFileName=".\Debug/"
+ BrowseInformation="1"
+ WarningLevel="3"
+ SuppressStartupBanner="true"
+ DebugInformationFormat="4"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ PreprocessorDefinitions="_DEBUG"
+ Culture="1033"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalOptions="/MACHINE:I386"
+ AdditionalDependencies="odbc32.lib odbccp32.lib"
+ OutputFile=".\Debug/Test.exe"
+ LinkIncremental="2"
+ SuppressStartupBanner="true"
+ GenerateDebugInformation="true"
+ ProgramDatabaseFile=".\Debug/Test.pdb"
+ SubSystem="1"
+ RandomizedBaseAddress="1"
+ DataExecutionPrevention="0"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory=".\Release"
+ IntermediateDirectory=".\Release"
+ ConfigurationType="1"
+ InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC70.vsprops"
+ UseOfMFC="0"
+ ATLMinimizesCRunTimeLibraryUsage="false"
+ CharacterSet="2"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ TypeLibraryName=".\Release/Test.tlb"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ InlineFunctionExpansion="1"
+ PreprocessorDefinitions="WIN32,NDEBUG,_CONSOLE"
+ StringPooling="true"
+ RuntimeLibrary="0"
+ EnableFunctionLevelLinking="true"
+ UsePrecompiledHeader="2"
+ PrecompiledHeaderThrough="stdafx.h"
+ PrecompiledHeaderFile=".\Release/Test.pch"
+ AssemblerListingLocation=".\Release/"
+ ObjectFile=".\Release/"
+ ProgramDataBaseFileName=".\Release/"
+ WarningLevel="3"
+ SuppressStartupBanner="true"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ PreprocessorDefinitions="NDEBUG"
+ Culture="1033"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalOptions="/MACHINE:I386"
+ AdditionalDependencies="odbc32.lib odbccp32.lib"
+ OutputFile=".\Release/Test.exe"
+ LinkIncremental="1"
+ SuppressStartupBanner="true"
+ ProgramDatabaseFile=".\Release/Test.pdb"
+ SubSystem="1"
+ RandomizedBaseAddress="1"
+ DataExecutionPrevention="0"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Name="Source Files"
+ Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+ >
+ <File
+ RelativePath=".\StdAfx.cpp"
+ >
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ UsePrecompiledHeader="1"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ UsePrecompiledHeader="1"
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath=".\Test.cpp"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="Header Files"
+ Filter="h;hpp;hxx;hm;inl"
+ >
+ <File
+ RelativePath=".\StdAfx.h"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="Resource Files"
+ Filter="ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
+ >
+ </Filter>
+ <File
+ RelativePath=".\ReadMe.txt"
+ >
+ </File>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
diff --git a/extensions/test/ole/unoTocomCalls/XCallback_Impl/Basic.rgs b/extensions/test/ole/unoTocomCalls/XCallback_Impl/Basic.rgs
new file mode 100644
index 000000000000..bc1525d7eb60
--- /dev/null
+++ b/extensions/test/ole/unoTocomCalls/XCallback_Impl/Basic.rgs
@@ -0,0 +1,27 @@
+HKCR
+{
+ XCallback_Impl.Basic.1 = s 'Basic Class'
+ {
+ CLSID = s '{A0F04CB7-8494-11D4-8335-005004526AB4}'
+ }
+ XCallback_Impl.Basic = s 'Basic Class'
+ {
+ CLSID = s '{A0F04CB7-8494-11D4-8335-005004526AB4}'
+ CurVer = s 'XCallback_Impl.Basic.1'
+ }
+ NoRemove CLSID
+ {
+ ForceRemove {A0F04CB7-8494-11D4-8335-005004526AB4} = s 'Basic Class'
+ {
+ ProgID = s 'XCallback_Impl.Basic.1'
+ VersionIndependentProgID = s 'XCallback_Impl.Basic'
+ ForceRemove 'Programmable'
+ InprocServer32 = s '%MODULE%'
+ {
+ val ThreadingModel = s 'Apartment'
+ }
+ 'TypeLib' = s '{180FF553-6F5C-11D4-8330-005004526AB4}'
+ }
+ }
+}
+
diff --git a/extensions/test/ole/unoTocomCalls/XCallback_Impl/BasicTest.rgs b/extensions/test/ole/unoTocomCalls/XCallback_Impl/BasicTest.rgs
new file mode 100644
index 000000000000..ee718304daad
--- /dev/null
+++ b/extensions/test/ole/unoTocomCalls/XCallback_Impl/BasicTest.rgs
@@ -0,0 +1,27 @@
+HKCR
+{
+ XCallback_Impl.BasicTest.1 = s 'BasicTest Class'
+ {
+ CLSID = s '{A0F04CBD-8494-11D4-8335-005004526AB4}'
+ }
+ XCallback_Impl.BasicTest = s 'BasicTest Class'
+ {
+ CLSID = s '{A0F04CBD-8494-11D4-8335-005004526AB4}'
+ CurVer = s 'XCallback_Impl.BasicTest.1'
+ }
+ NoRemove CLSID
+ {
+ ForceRemove {A0F04CBD-8494-11D4-8335-005004526AB4} = s 'BasicTest Class'
+ {
+ ProgID = s 'XCallback_Impl.BasicTest.1'
+ VersionIndependentProgID = s 'XCallback_Impl.BasicTest'
+ ForceRemove 'Programmable'
+ InprocServer32 = s '%MODULE%'
+ {
+ val ThreadingModel = s 'Apartment'
+ }
+ 'TypeLib' = s '{180FF553-6F5C-11D4-8330-005004526AB4}'
+ }
+ }
+}
+
diff --git a/extensions/test/ole/unoTocomCalls/XCallback_Impl/Callback.cpp b/extensions/test/ole/unoTocomCalls/XCallback_Impl/Callback.cpp
new file mode 100644
index 000000000000..ea21a969552e
--- /dev/null
+++ b/extensions/test/ole/unoTocomCalls/XCallback_Impl/Callback.cpp
@@ -0,0 +1,514 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+// Callback.cpp : Implementation of CCallback
+#include "stdafx.h"
+#include "XCallback_Impl.h"
+#include "Callback.h"
+
+/////////////////////////////////////////////////////////////////////////////
+// CCallback
+
+
+STDMETHODIMP CCallback::func1()
+{
+ MessageBox( NULL, _T("Callback::func1 called"),_T(""), MB_OK);
+ return S_OK;
+}
+
+STDMETHODIMP CCallback::returnInterface(IDispatch **ppdisp)
+{
+ if( ! ppdisp)
+ return E_POINTER;
+ CComPtr<IDispatch> spDisp;
+ spDisp.CoCreateInstance( L"XCallback_Impl.Simple");
+ *ppdisp= spDisp;
+ (*ppdisp)->AddRef();
+ return S_OK;
+}
+
+STDMETHODIMP CCallback::outInterface(IDispatch **ppdisp)
+{
+// return S_OK;
+ if( ! ppdisp)
+ return E_POINTER;
+ CComPtr<IDispatch> spDisp;
+ spDisp.CoCreateInstance( L"XCallback_Impl.Simple");
+ *ppdisp= spDisp;
+ (*ppdisp)->AddRef();
+
+// MessageBox( NULL, _T("CCallback::outInterface"), _T(""), MB_OK);
+ return S_OK;
+}
+
+STDMETHODIMP CCallback::outValuesMixed(long val, long *pval, BSTR string)
+{
+ USES_CONVERSION;
+ char buff[1024];
+ *pval = val+1;
+ sprintf( buff, "param1: %d, param2 out: %d, param3: %S", val, *pval, string);
+ MessageBox( NULL, A2T(buff), A2T("XCallback_Impl.Callback"), MB_OK);
+ return S_OK;
+}
+
+
+STDMETHODIMP CCallback::outValuesAll(
+ /* [out] */ IDispatch __RPC_FAR *__RPC_FAR *ppdisp,
+ /* [out] */ IDispatch __RPC_FAR *__RPC_FAR *ppSimpleStruct,
+ /* [out] */ long __RPC_FAR *aSimpleEnum,
+ /* [out] */ SAFEARRAY __RPC_FAR * __RPC_FAR *outSeq,
+ /* [out] */ VARIANT __RPC_FAR *varAny,
+ /* [out] */ VARIANT_BOOL __RPC_FAR *aBool,
+ /* [out] */ short __RPC_FAR *aChar,
+ /* [out] */ BSTR __RPC_FAR *aString,
+ /* [out] */ float __RPC_FAR *aFloat,
+ /* [out] */ double __RPC_FAR *aDouble,
+ /* [out] */ unsigned char __RPC_FAR *aByte,
+ /* [out] */ short __RPC_FAR *aShort,
+ /* [out] */ long __RPC_FAR *aLong)
+//)
+{
+// if( ! ppdisp || ! ppSimpleStruct || ! aSimpleEnum ||
+// ! outSeq || !varAny ||! aBool || ! aChar ||
+// ! aString || ! aFloat || ! aDouble || ! aByte ||
+// ! aShort || ! aLong || ! aUShort || ! aULong)
+// return E_POINTER;
+
+ HRESULT hr=S_OK;
+ hr= outInterface( ppdisp);
+ hr= outStruct( ppSimpleStruct);
+ hr= outEnum( aSimpleEnum);
+ hr= outSeqAny( outSeq);
+ hr= outAny( varAny);
+ hr= outBool( aBool);
+ hr= outChar( aChar);
+ hr= outString( aString);
+ hr= outFloat( aFloat);
+ hr= outDouble( aDouble);
+ hr= outByte( aByte);
+ hr= outShort( aShort);
+ hr= outLong( aLong);
+ return hr;
+}
+
+STDMETHODIMP CCallback::outStruct(IDispatch **outStruct)
+{
+// return S_OK;
+ if( !outStruct)
+ return E_POINTER;
+ HRESULT hr= E_FAIL;
+// MessageBox( NULL, _T("CCallback::outStruct"), _T(""), MB_OK);
+
+ CComPtr<IDispatch> _dispMgr;
+ if( SUCCEEDED(hr= _dispMgr.CoCreateInstance(L"com.sun.star.ServiceManager")))
+ {
+ CComDispatchDriver manager( _dispMgr);
+ CComVariant param1(L"com.sun.star.reflection.CoreReflection");
+ CComVariant varRet;
+ hr= manager.Invoke1( L"createInstance", &param1, &varRet);
+
+ CComDispatchDriver reflection( varRet.pdispVal);
+ param1= L"oletest.SimpleStruct";
+ varRet.Clear();
+ hr= reflection.Invoke1( L"forName", &param1, &varRet);
+
+ CComDispatchDriver classSimpleStruct( varRet.pdispVal);
+
+ CComPtr<IDispatch> dispStruct;
+ param1.vt= VT_DISPATCH | VT_BYREF;
+ param1.ppdispVal= &dispStruct;
+ if( SUCCEEDED( hr= classSimpleStruct.Invoke1(L"createObject", &param1)))
+ {
+ // Set the value
+ CComDispatchDriver simpleStruct( dispStruct);
+ param1=L" this is a property string";
+ hr= simpleStruct.PutPropertyByName(L"message", &param1);
+ *outStruct= dispStruct;
+ (*outStruct)->AddRef();
+ hr= S_OK;
+ }
+ }
+ return hr;
+}
+
+STDMETHODIMP CCallback::outEnum(long *outEnum)
+{
+ if( !outEnum)
+ return E_POINTER;
+ *outEnum= 1;
+ return S_OK;
+}
+
+STDMETHODIMP CCallback::outSeqAny(LPSAFEARRAY* outSeq)
+{
+// _CrtDbgBreak();
+ SAFEARRAY* pArr= SafeArrayCreateVector( VT_VARIANT, 0, 3);
+ CComVariant var[3];
+ var[0]=L" variant 0";
+ var[1]=L" variant 1";
+ var[2]=L"variant 2";
+ for( long i=0; i<3; i++)
+ {
+ SafeArrayPutElement( pArr, &i, (void*)&var[i]);
+ }
+
+ *outSeq= pArr;
+ return S_OK;
+}
+
+// ATLASSERT //VT_EMPTY
+
+
+STDMETHODIMP CCallback::outAny(VARIANT *outAny)
+{
+ if( ! outAny)
+ return E_POINTER;
+ outAny->vt= VT_BSTR;
+ outAny->bstrVal= SysAllocString( L"This is a string in a VARIANT");
+
+ return S_OK;
+}
+
+STDMETHODIMP CCallback::outBool(VARIANT_BOOL *outBool)
+{
+ if( ! outBool)
+ return E_POINTER;
+ *outBool= VARIANT_TRUE;
+ return S_OK;
+}
+
+STDMETHODIMP CCallback::outChar(short *outChar)
+{
+ if( !outChar)
+ return E_POINTER;
+ *outChar= (short)L'A';
+ return S_OK;
+}
+
+STDMETHODIMP CCallback::outString(BSTR *outString)
+{
+ if( !outString)
+ return E_POINTER;
+ *outString= SysAllocString(L"This is a BSTR");
+ return S_OK;
+}
+
+STDMETHODIMP CCallback::outFloat(float *outFloat)
+{
+ if( !outFloat)
+ return E_POINTER;
+ *outFloat= 3.14f;
+ return S_OK;
+}
+
+STDMETHODIMP CCallback::outDouble(double *outDouble)
+{
+ if(!outDouble)
+ return E_POINTER;
+
+ *outDouble= 3.145;
+ return S_OK;
+}
+
+
+
+STDMETHODIMP CCallback::outShort(short *outShort)
+{
+ if(!outShort)
+ return E_POINTER;
+ *outShort= -1;
+ return S_OK;
+}
+
+STDMETHODIMP CCallback::outLong(long *outLong)
+{
+ if(!outLong)
+ return E_POINTER;
+ *outLong= 0xffffffff;
+ return S_OK;
+}
+
+
+
+STDMETHODIMP CCallback::outByte(unsigned char* outByte)
+{
+ if(!outByte)
+ return E_POINTER;
+ *outByte= 0xff;
+ return S_OK;
+}
+
+STDMETHODIMP CCallback::inoutInterface(IDispatch **ppdisp)
+{
+ if( !ppdisp)
+ return E_POINTER;
+ CComDispatchDriver disp( *ppdisp);
+ CComVariant param1(L"");
+ disp.Invoke1(L"func", &param1);
+
+ (*ppdisp)->Release();
+
+ CComPtr<IDispatch> outDisp;
+ outDisp.CoCreateInstance( L"XCallback_Impl.Simple");
+ *ppdisp= outDisp;
+ (*ppdisp)->AddRef();
+
+ return S_OK;
+}
+
+STDMETHODIMP CCallback::inoutStruct(IDispatch **inoutVal)
+{
+ if( !inoutVal)
+ return E_POINTER;
+ HRESULT hr= S_OK;
+ USES_CONVERSION;
+ CComVariant var;
+ CComDispatchDriver disp( *inoutVal);
+
+ hr= disp.GetPropertyByName(L"message", &var);
+ MessageBox( NULL, W2T(var.bstrVal), _T("XCallback_Impl.Callback"), MB_OK);
+
+ (*inoutVal)->Release();
+
+ CComDispatchDriver dispStruct;
+ hr= outStruct( &dispStruct.p);
+ var.Clear();
+ var= L"This struct was created in XCallback_Imp.Callback";
+ hr= dispStruct.PutPropertyByName(L"message", &var);
+
+ *inoutVal= dispStruct;
+ (*inoutVal)->AddRef();
+ return hr;
+}
+
+STDMETHODIMP CCallback::inoutEnum(long *inoutVal)
+{
+ if( !inoutVal)
+ return E_POINTER;
+ *inoutVal= *inoutVal+1;
+
+ return S_OK;
+}
+
+STDMETHODIMP CCallback::inoutSeqAny(LPSAFEARRAY *pArray)
+{
+ if( !pArray)
+ return E_POINTER;
+ HRESULT hr= S_OK;
+ long lbound=0;
+ long ubound=0;
+ hr= SafeArrayGetLBound( *pArray, 1, &lbound);
+ hr= SafeArrayGetUBound( *pArray, 1, &ubound);
+ long count= ubound - lbound + 1;
+
+ // the Array is supposet to contain variants
+ CComVariant var;
+ for( long i=0; i<count; i++)
+ {
+ var.Clear();
+ hr= SafeArrayGetElement( *pArray, &i, (void*)&var);
+ }
+
+ SafeArrayDestroy( *pArray);
+
+ outSeqAny( pArray);
+ return S_OK;
+}
+
+STDMETHODIMP CCallback::inoutAny(VARIANT *inoutVal)
+{
+ if( !inoutVal)
+ return E_POINTER;
+ USES_CONVERSION;
+ if( inoutVal->vt= VT_BSTR)
+ MessageBox( NULL, W2T( inoutVal->bstrVal), _T("XCallback_Impl.Callback"), MB_OK);
+
+ VariantClear( inoutVal);
+ inoutVal->vt= VT_BSTR;
+ inoutVal->bstrVal=SysAllocString( L" [string] XCallback_Impl.Callback inoutAny");
+ return S_OK;
+}
+
+STDMETHODIMP CCallback::inoutBool(VARIANT_BOOL *inoutVal)
+{
+ if( !inoutVal)
+ return E_POINTER;
+
+ *inoutVal= *inoutVal == VARIANT_TRUE ? VARIANT_FALSE : VARIANT_TRUE;
+ return S_OK;
+}
+
+STDMETHODIMP CCallback::inoutChar(short *inoutVal)
+{
+ if( !inoutVal)
+ return E_POINTER;
+ USES_CONVERSION;
+ char buff[256];
+ sprintf( buff, "character value: %C", *inoutVal);
+ MessageBox( NULL, A2T(buff), _T("XCallback_Impl.Callback"), MB_OK);
+ *inoutVal= L'B';
+ return S_OK;
+}
+
+STDMETHODIMP CCallback::inoutString(BSTR *inoutVal)
+{
+ if( !inoutVal)
+ return E_POINTER;
+ USES_CONVERSION;
+ MessageBox( NULL, W2T(*inoutVal), _T("XCallback_Impl.Callback"), MB_OK);
+ SysFreeString(*inoutVal);
+ *inoutVal= SysAllocString(L"a string from XCallback_Impl.Callback");
+
+ return S_OK;
+}
+
+STDMETHODIMP CCallback::inoutFloat(float *inoutVal)
+{
+ if( !inoutVal)
+ return E_POINTER;
+ *inoutVal = *inoutVal+1;
+ return S_OK;
+}
+
+STDMETHODIMP CCallback::inoutDouble(double *inoutVal)
+{
+ if( !inoutVal)
+ return E_POINTER;
+ *inoutVal= *inoutVal+1;
+ return S_OK;
+}
+
+STDMETHODIMP CCallback::inoutByte(unsigned char *inoutVal)
+{
+ if( !inoutVal)
+ return E_POINTER;
+ *inoutVal= 0xff;
+ return S_OK;
+}
+
+STDMETHODIMP CCallback::inoutShort(short *inoutVal)
+{
+ if( !inoutVal)
+ return E_POINTER;
+ *inoutVal= -1;
+ return S_OK;
+}
+
+STDMETHODIMP CCallback::inoutLong(long* inoutVal)
+{
+ if( !inoutVal)
+ return E_POINTER;
+ *inoutVal= 0xffffffff;
+ return S_OK;
+}
+
+STDMETHODIMP CCallback::inoutValuesAll(
+ /* [out][in] */ IDispatch __RPC_FAR *__RPC_FAR *aXSimple,
+ /* [out][in] */ IDispatch __RPC_FAR *__RPC_FAR *aStruct,
+ /* [out][in] */ long __RPC_FAR *aEnum,
+ /* [out][in] */ SAFEARRAY __RPC_FAR * __RPC_FAR *aSeq,
+ /* [out][in] */ VARIANT __RPC_FAR *aAny,
+ /* [out][in] */ VARIANT_BOOL __RPC_FAR *aBool,
+ /* [out][in] */ short __RPC_FAR *aChar,
+ /* [out][in] */ BSTR __RPC_FAR *aString,
+ /* [out][in] */ float __RPC_FAR *aFloat,
+ /* [out][in] */ double __RPC_FAR *aDouble,
+ /* [out][in] */ unsigned char __RPC_FAR *aByte,
+ /* [out][in] */ short __RPC_FAR *aShort,
+ /* [out][in] */ long __RPC_FAR *aLong)
+{
+ inoutInterface( aXSimple);
+ inoutStruct( aStruct);
+ inoutEnum( aEnum);
+ inoutSeqAny( aSeq);
+ inoutAny( aAny);
+ inoutBool( aBool);
+ inoutChar( aChar);
+ inoutString( aString);
+ inoutFloat( aFloat);
+ inoutDouble( aDouble);
+ inoutByte( aByte);
+ inoutShort( aShort);
+ inoutLong( aLong);
+
+ return S_OK;
+}
+
+
+STDMETHODIMP CCallback::inValues(short aChar, long aLong, BSTR aString)
+{
+ USES_CONVERSION;
+ wchar_t _char= (wchar_t) aChar;
+ char buff[1024];
+ sprintf( buff, "Parameters: char= %C, long= %d, string= %s", _char, aLong, W2A(aString));
+ MessageBox( NULL, A2T(buff), _T("XCallback_Impl.Callback"), MB_OK);
+ return S_OK;
+}
+
+STDMETHODIMP CCallback::outSeqByte(LPSAFEARRAY * outVal)
+{
+ // TODO: Add your implementation code here
+
+ return S_OK;
+}
+
+STDMETHODIMP CCallback::inSeqByte( LPSAFEARRAY listeners)
+{
+
+ return S_OK;
+}
+
+STDMETHODIMP CCallback::inSeqXEventListener( LPSAFEARRAY listeners, LPSAFEARRAY events)
+{
+ HRESULT hr= S_OK;
+ long ubound= 0;
+ long lbound= 0;
+ long count= 0;
+ hr= SafeArrayGetUBound( listeners, 1, &ubound);
+ hr= SafeArrayGetLBound( listeners, 1, &lbound);
+ count= ubound - lbound +1;
+
+ // We assume thate the count of EventObjects in events is the same
+ for( long i = 0; i < count; i++)
+ {
+ CComVariant varListener;
+ CComVariant varEvent;
+ hr= SafeArrayGetElement( listeners, &i, &varListener);
+ hr= SafeArrayGetElement( events, &i, &varEvent);
+ if( varListener.vt == VT_DISPATCH && varEvent.vt == VT_DISPATCH)
+ {
+ CComDispatchDriver disp( varListener.pdispVal);
+ hr= disp.Invoke1(L"disposing", &varEvent);
+ }
+
+ }
+
+ return S_OK;
+}
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/test/ole/unoTocomCalls/XCallback_Impl/Callback.h b/extensions/test/ole/unoTocomCalls/XCallback_Impl/Callback.h
new file mode 100644
index 000000000000..02cb6cff483f
--- /dev/null
+++ b/extensions/test/ole/unoTocomCalls/XCallback_Impl/Callback.h
@@ -0,0 +1,138 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+// Callback.h : Declaration of the CCallback
+
+#ifndef __CALLBACK_H_
+#define __CALLBACK_H_
+
+#include "resource.h" // main symbols
+
+/////////////////////////////////////////////////////////////////////////////
+// CCallback
+class ATL_NO_VTABLE CCallback :
+ public CComObjectRootEx<CComSingleThreadModel>,
+ public CComCoClass<CCallback, &CLSID_Callback>,
+ public IDispatchImpl<ICallback, &IID_ICallback, &LIBID_XCALLBACK_IMPLLib>
+{
+public:
+ CCallback()
+ {
+ }
+
+DECLARE_REGISTRY_RESOURCEID(IDR_CALLBACK)
+
+DECLARE_PROTECT_FINAL_CONSTRUCT()
+
+BEGIN_COM_MAP(CCallback)
+ COM_INTERFACE_ENTRY(ICallback)
+ COM_INTERFACE_ENTRY(IDispatch)
+END_COM_MAP()
+
+// ICallback
+public:
+ STDMETHOD(inSeqByte)(/*[in]*/ LPSAFEARRAY val);
+ STDMETHOD(inSeqXEventListener)(/*[in]*/ LPSAFEARRAY listener, LPSAFEARRAY event);
+ STDMETHOD(outSeqByte)(/*[out]*/ LPSAFEARRAY* outVal);
+ STDMETHOD(inValues)(/*[in]*/short aChar, /*[in]*/ long aLong, /*[in]*/ BSTR aString);
+ STDMETHOD(inoutLong)(/*[in,out]*/ long* inoutVal);
+ STDMETHOD(inoutShort)(/*[in,out]*/ short* inoutVal);
+ STDMETHOD(inoutByte)(/*[in,out]*/ unsigned char* inoutVal);
+ STDMETHOD(inoutDouble)(/*[in,out]*/ double* inoutVal);
+ STDMETHOD(inoutFloat)(/*[in,out]*/ float* inoutVal);
+ STDMETHOD(inoutString)(/*[in,out]*/ BSTR *inoutVal);
+ STDMETHOD(inoutChar)(/*[in,out]*/ short* inoutVal);
+ STDMETHOD(inoutBool)(/*[in,out]*/ VARIANT_BOOL * inoutVal);
+ STDMETHOD(inoutAny)(/*[in,out]*/ VARIANT* inoutVal);
+ STDMETHOD(inoutSeqAny)(/*[in,out]*/ LPSAFEARRAY* pArray);
+ STDMETHOD(inoutEnum)(/*[in,out]*/ long * inoutVal);
+ STDMETHOD(inoutStruct)(/*[in,out]*/ IDispatch** inoutVal);
+ STDMETHOD(inoutInterface)(/*[in,out]*/ IDispatch** ppdisp);
+ STDMETHOD(inoutValuesAll)(
+ /* [out][in] */ IDispatch __RPC_FAR *__RPC_FAR *aXSimple,
+ /* [out][in] */ IDispatch __RPC_FAR *__RPC_FAR *aStruct,
+ /* [out][in] */ long __RPC_FAR *aEnum,
+ /* [out][in] */ SAFEARRAY __RPC_FAR * __RPC_FAR *aSeq,
+ /* [out][in] */ VARIANT __RPC_FAR *aAny,
+ /* [out][in] */ VARIANT_BOOL __RPC_FAR *aBool,
+ /* [out][in] */ short __RPC_FAR *aChar,
+ /* [out][in] */ BSTR __RPC_FAR *aString,
+ /* [out][in] */ float __RPC_FAR *aFloat,
+ /* [out][in] */ double __RPC_FAR *aDouble,
+ /* [out][in] */ unsigned char __RPC_FAR *aByte,
+ /* [out][in] */ short __RPC_FAR *aShort,
+ /* [out][in] */ long __RPC_FAR *aLong);
+
+ STDMETHOD(outByte)( unsigned char* outByte);
+ STDMETHOD(outLong)(/*[out]*/ long* outLong);
+ STDMETHOD(outShort)(/*[out]*/ short *outShort);
+ STDMETHOD(outDouble)(/*[out]*/ double* outDouble);
+ STDMETHOD(outFloat)(/*[out]*/ float* outFloat);
+ STDMETHOD(outString)(/*[out]*/ BSTR * outString);
+ STDMETHOD(outChar)(short* outChar);
+ STDMETHOD(outBool)(VARIANT_BOOL* outBool);
+ STDMETHOD(outAny)(VARIANT* outAny);
+ STDMETHOD(outSeqAny)(/*[out]*/LPSAFEARRAY* outSeq);
+ STDMETHOD(outEnum)(/*[out]*/ long* outEnum);
+ STDMETHOD(outStruct)(/*[out]*/ IDispatch** outStruct);
+ virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE outValuesAll(
+ /* [out] */ IDispatch __RPC_FAR *__RPC_FAR *ppdisp,
+ /* [out] */ IDispatch __RPC_FAR *__RPC_FAR *ppSimpleStruct,
+ /* [out] */ long __RPC_FAR *aSimpleEnum,
+ /* [out] */ LPSAFEARRAY* outSeq,
+ /* [out] */ VARIANT __RPC_FAR *varAny,
+ /* [out] */ VARIANT_BOOL __RPC_FAR *aBool,
+ /* [out] */ short __RPC_FAR *aChar,
+ /* [out] */ BSTR __RPC_FAR *aString,
+ /* [out] */ float __RPC_FAR *aFloat,
+ /* [out] */ double __RPC_FAR *aDouble,
+ /* [out] */ unsigned char __RPC_FAR *aByte,
+ /* [out] */ short __RPC_FAR *aShort,
+ /* [out] */ long __RPC_FAR *aLong);
+// );
+//
+// STDMETHOD(outValuesAll)(
+// /*[out]*/ IDispatch** ppdisp,
+// /*[out]*/ IUnknown** ppSimpleStruct,
+// /*[out]*/ long* aSimpleEnum,
+// /*[out]*/ VARIANT* ArrayAny,
+// /*[out]*/ VARIANT* varAny,
+// /*[out]*/ VARIANT_BOOL * aBool,
+// /*[out]*/ unsigned short* aChar,
+// /*[out]*/ BSTR* aString, /*[out]*/ float* aFloat,
+// /*[out]*/ double* aDouble,
+// /*[out]*/ signed char* aByte, /*[out]*/ short* aShort, /*[out]*/long* aLong, /*[out]*/ unsigned short* aUShort, /*[out]*/ unsigned long* aULong);
+ STDMETHOD(outValuesMixed)(/*[in]*/ long val, /*[out]*/ long* pval, /*[in]*/ BSTR string);
+ STDMETHOD(outInterface)(/*[out]*/ IDispatch** ppdisp);
+ STDMETHOD(returnInterface)(/*[out, retval]*/ IDispatch** ppdisp);
+ STDMETHOD(func1)();
+};
+
+#endif //__CALLBACK_H_
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/test/ole/unoTocomCalls/XCallback_Impl/Callback.rgs b/extensions/test/ole/unoTocomCalls/XCallback_Impl/Callback.rgs
new file mode 100644
index 000000000000..b3f9e071b8c9
--- /dev/null
+++ b/extensions/test/ole/unoTocomCalls/XCallback_Impl/Callback.rgs
@@ -0,0 +1,27 @@
+HKCR
+{
+ XCallback_Impl.Callback.1 = s 'Callback Class'
+ {
+ CLSID = s '{180FF560-6F5C-11D4-8330-005004526AB4}'
+ }
+ XCallback_Impl.Callback = s 'Callback Class'
+ {
+ CLSID = s '{180FF560-6F5C-11D4-8330-005004526AB4}'
+ CurVer = s 'XCallback_Impl.Callback.1'
+ }
+ NoRemove CLSID
+ {
+ ForceRemove {180FF560-6F5C-11D4-8330-005004526AB4} = s 'Callback Class'
+ {
+ ProgID = s 'XCallback_Impl.Callback.1'
+ VersionIndependentProgID = s 'XCallback_Impl.Callback'
+ ForceRemove 'Programmable'
+ InprocServer32 = s '%MODULE%'
+ {
+ val ThreadingModel = s 'Apartment'
+ }
+ 'TypeLib' = s '{180FF553-6F5C-11D4-8330-005004526AB4}'
+ }
+ }
+}
+
diff --git a/extensions/test/ole/unoTocomCalls/XCallback_Impl/Simple.cpp b/extensions/test/ole/unoTocomCalls/XCallback_Impl/Simple.cpp
new file mode 100644
index 000000000000..34a5075db803
--- /dev/null
+++ b/extensions/test/ole/unoTocomCalls/XCallback_Impl/Simple.cpp
@@ -0,0 +1,82 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+// Simple.cpp : Implementation of CSimple
+#include "stdafx.h"
+#include "XCallback_Impl.h"
+#include "Simple.h"
+
+/////////////////////////////////////////////////////////////////////////////
+// CSimple
+
+
+STDMETHODIMP CSimple::func(BSTR message)
+{
+ USES_CONVERSION;
+ MessageBox( NULL, W2T( message), _T("XCallback_Impl.Simple"), MB_OK);
+ return S_OK;
+}
+
+
+STDMETHODIMP CSimple::func2(BSTR message)
+{
+ USES_CONVERSION;
+ MessageBox( NULL, W2T( message), _T("XCallback_Impl.Simple"), MB_OK);
+ return S_OK;
+}
+
+STDMETHODIMP CSimple::func3(BSTR message)
+{
+ USES_CONVERSION;
+ MessageBox( NULL, W2T( message), _T("XCallback_Impl.Simple"), MB_OK);
+ return S_OK;
+}
+
+
+STDMETHODIMP CSimple::get__implementedInterfaces(LPSAFEARRAY *pVal)
+{
+ HRESULT hr= S_OK;
+ SAFEARRAY *pArr= SafeArrayCreateVector( VT_BSTR, 0, 3);
+ if( pArr)
+ { long index=0;
+ BSTR name1= SysAllocString(L"oletest.XSimple");
+ BSTR name2= SysAllocString(L"oletest.XSimple2");
+ BSTR name3= SysAllocString(L"oletest.XSimple3");
+
+ hr= SafeArrayPutElement( pArr, & index, name1);
+ index++;
+ hr= SafeArrayPutElement( pArr, &index, name2);
+ index++;
+ hr= SafeArrayPutElement( pArr, &index, name3);
+ *pVal= pArr;
+
+ }
+ *pVal= pArr;
+ return S_OK;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/test/ole/unoTocomCalls/XCallback_Impl/Simple.h b/extensions/test/ole/unoTocomCalls/XCallback_Impl/Simple.h
new file mode 100644
index 000000000000..e76795925573
--- /dev/null
+++ b/extensions/test/ole/unoTocomCalls/XCallback_Impl/Simple.h
@@ -0,0 +1,67 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+// Simple.h : Declaration of the CSimple
+
+#ifndef __SIMPLE_H_
+#define __SIMPLE_H_
+
+#include "resource.h" // main symbols
+
+/////////////////////////////////////////////////////////////////////////////
+// CSimple
+class ATL_NO_VTABLE CSimple :
+ public CComObjectRootEx<CComSingleThreadModel>,
+ public CComCoClass<CSimple, &CLSID_Simple>,
+ public IDispatchImpl<ISimple, &IID_ISimple, &LIBID_XCALLBACK_IMPLLib>
+{
+public:
+ CSimple()
+ {
+ }
+
+DECLARE_REGISTRY_RESOURCEID(IDR_SIMPLE)
+
+DECLARE_PROTECT_FINAL_CONSTRUCT()
+
+BEGIN_COM_MAP(CSimple)
+ COM_INTERFACE_ENTRY(ISimple)
+ COM_INTERFACE_ENTRY(IDispatch)
+END_COM_MAP()
+
+// ISimple
+public:
+
+ STDMETHOD(get__implementedInterfaces)(/*[out, retval]*/ LPSAFEARRAY *pVal);
+ STDMETHOD(func3)(/*[in]*/ BSTR message);
+ STDMETHOD(func2)(/*[in]*/ BSTR message);
+ STDMETHOD(func)( BSTR message);
+};
+
+#endif //__SIMPLE_H_
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/test/ole/unoTocomCalls/XCallback_Impl/Simple.rgs b/extensions/test/ole/unoTocomCalls/XCallback_Impl/Simple.rgs
new file mode 100644
index 000000000000..19237bf3621a
--- /dev/null
+++ b/extensions/test/ole/unoTocomCalls/XCallback_Impl/Simple.rgs
@@ -0,0 +1,27 @@
+HKCR
+{
+ XCallback_Impl.Simple.1 = s 'Simple Class'
+ {
+ CLSID = s '{180FF565-6F5C-11D4-8330-005004526AB4}'
+ }
+ XCallback_Impl.Simple = s 'Simple Class'
+ {
+ CLSID = s '{180FF565-6F5C-11D4-8330-005004526AB4}'
+ CurVer = s 'XCallback_Impl.Simple.1'
+ }
+ NoRemove CLSID
+ {
+ ForceRemove {180FF565-6F5C-11D4-8330-005004526AB4} = s 'Simple Class'
+ {
+ ProgID = s 'XCallback_Impl.Simple.1'
+ VersionIndependentProgID = s 'XCallback_Impl.Simple'
+ ForceRemove 'Programmable'
+ InprocServer32 = s '%MODULE%'
+ {
+ val ThreadingModel = s 'Apartment'
+ }
+ 'TypeLib' = s '{180FF553-6F5C-11D4-8330-005004526AB4}'
+ }
+ }
+}
+
diff --git a/extensions/test/ole/unoTocomCalls/XCallback_Impl/StdAfx.cpp b/extensions/test/ole/unoTocomCalls/XCallback_Impl/StdAfx.cpp
new file mode 100644
index 000000000000..902524bdf104
--- /dev/null
+++ b/extensions/test/ole/unoTocomCalls/XCallback_Impl/StdAfx.cpp
@@ -0,0 +1,41 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+// stdafx.cpp : source file that includes just the standard includes
+// stdafx.pch will be the pre-compiled header
+// stdafx.obj will contain the pre-compiled type information
+
+#include "stdafx.h"
+
+#ifdef _ATL_STATIC_REGISTRY
+#include <statreg.h>
+#include <statreg.cpp>
+#endif
+
+#include <atlimpl.cpp>
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/test/ole/unoTocomCalls/XCallback_Impl/StdAfx.h b/extensions/test/ole/unoTocomCalls/XCallback_Impl/StdAfx.h
new file mode 100644
index 000000000000..f692fae959e7
--- /dev/null
+++ b/extensions/test/ole/unoTocomCalls/XCallback_Impl/StdAfx.h
@@ -0,0 +1,59 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+// stdafx.h : include file for standard system include files,
+// or project specific include files that are used frequently,
+// but are changed infrequently
+
+#if !defined(AFX_STDAFX_H__180FF556_6F5C_11D4_8330_005004526AB4__INCLUDED_)
+#define AFX_STDAFX_H__180FF556_6F5C_11D4_8330_005004526AB4__INCLUDED_
+
+#if _MSC_VER > 1000
+#pragma once
+#endif // _MSC_VER > 1000
+
+#define STRICT
+#ifndef _WIN32_WINNT
+#define _WIN32_WINNT 0x0400
+#endif
+#define _ATL_APARTMENT_THREADED
+
+#include <stdio.h>
+#include <atlbase.h>
+//You may derive a class from CComModule and use it if you want to override
+//something, but do not change the name of _Module
+extern CComModule _Module;
+#include <atlcom.h>
+#include <stdio.h>
+#include <tchar.h>
+
+//{{AFX_INSERT_LOCATION}}
+// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
+
+#endif // !defined(AFX_STDAFX_H__180FF556_6F5C_11D4_8330_005004526AB4__INCLUDED)
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/test/ole/unoTocomCalls/XCallback_Impl/XCallback_Impl.cpp b/extensions/test/ole/unoTocomCalls/XCallback_Impl/XCallback_Impl.cpp
new file mode 100644
index 000000000000..78585a01bc83
--- /dev/null
+++ b/extensions/test/ole/unoTocomCalls/XCallback_Impl/XCallback_Impl.cpp
@@ -0,0 +1,103 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+// XCallback_Impl.cpp : Implementation of DLL Exports.
+
+
+// Note: Proxy/Stub Information
+// To build a separate proxy/stub DLL,
+// run nmake -f XCallback_Implps.mk in the project directory.
+
+#include "stdafx.h"
+#include "resource.h"
+#include <initguid.h>
+#include "XCallback_Impl.h"
+
+#include "XCallback_Impl_i.c"
+#include "Callback.h"
+#include "Simple.h"
+
+
+CComModule _Module;
+
+BEGIN_OBJECT_MAP(ObjectMap)
+OBJECT_ENTRY(CLSID_Callback, CCallback)
+OBJECT_ENTRY(CLSID_Simple, CSimple)
+END_OBJECT_MAP()
+
+/////////////////////////////////////////////////////////////////////////////
+// DLL Entry Point
+
+extern "C"
+BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/)
+{
+ if (dwReason == DLL_PROCESS_ATTACH)
+ {
+ _Module.Init(ObjectMap, hInstance, &LIBID_XCALLBACK_IMPLLib);
+ DisableThreadLibraryCalls(hInstance);
+ }
+ else if (dwReason == DLL_PROCESS_DETACH)
+ _Module.Term();
+ return TRUE; // ok
+}
+
+/////////////////////////////////////////////////////////////////////////////
+// Used to determine whether the DLL can be unloaded by OLE
+
+STDAPI DllCanUnloadNow(void)
+{
+ return (_Module.GetLockCount()==0) ? S_OK : S_FALSE;
+}
+
+/////////////////////////////////////////////////////////////////////////////
+// Returns a class factory to create an object of the requested type
+
+STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv)
+{
+ return _Module.GetClassObject(rclsid, riid, ppv);
+}
+
+/////////////////////////////////////////////////////////////////////////////
+// DllRegisterServer - Adds entries to the system registry
+
+STDAPI DllRegisterServer(void)
+{
+ // registers object, typelib and all interfaces in typelib
+ return _Module.RegisterServer(TRUE);
+}
+
+/////////////////////////////////////////////////////////////////////////////
+// DllUnregisterServer - Removes entries from the system registry
+
+STDAPI DllUnregisterServer(void)
+{
+ return _Module.UnregisterServer(TRUE);
+}
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/test/ole/unoTocomCalls/XCallback_Impl/XCallback_Impl.def b/extensions/test/ole/unoTocomCalls/XCallback_Impl/XCallback_Impl.def
new file mode 100644
index 000000000000..b2d5e9627f4c
--- /dev/null
+++ b/extensions/test/ole/unoTocomCalls/XCallback_Impl/XCallback_Impl.def
@@ -0,0 +1,10 @@
+; XCallback_Impl.def : Declares the module parameters.
+
+LIBRARY "XCallback_Impl.DLL"
+
+EXPORTS
+ DllCanUnloadNow PRIVATE
+ DllGetClassObject PRIVATE
+ DllRegisterServer PRIVATE
+ DllUnregisterServer PRIVATE
+
diff --git a/extensions/test/ole/unoTocomCalls/XCallback_Impl/XCallback_Impl.dsp b/extensions/test/ole/unoTocomCalls/XCallback_Impl/XCallback_Impl.dsp
new file mode 100644
index 000000000000..6897d0d81e3e
--- /dev/null
+++ b/extensions/test/ole/unoTocomCalls/XCallback_Impl/XCallback_Impl.dsp
@@ -0,0 +1,337 @@
+# Microsoft Developer Studio Project File - Name="XCallback_Impl" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
+
+CFG=XCallback_Impl - Win32 Debug
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE
+!MESSAGE NMAKE /f "XCallback_Impl.mak".
+!MESSAGE
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE
+!MESSAGE NMAKE /f "XCallback_Impl.mak" CFG="XCallback_Impl - Win32 Debug"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "XCallback_Impl - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE "XCallback_Impl - Win32 Unicode Debug" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE "XCallback_Impl - Win32 Release MinSize" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE "XCallback_Impl - Win32 Release MinDependency" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE "XCallback_Impl - Win32 Unicode Release MinSize" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE "XCallback_Impl - Win32 Unicode Release MinDependency" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=cl.exe
+MTL=midl.exe
+RSC=rc.exe
+
+!IF "$(CFG)" == "XCallback_Impl - Win32 Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "Debug"
+# PROP BASE Intermediate_Dir "Debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "Debug"
+# PROP Intermediate_Dir "Debug"
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MTd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /Yu"stdafx.h" /FD /GZ /c
+# ADD CPP /nologo /MTd /W3 /Gm /ZI /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /FR /Yu"stdafx.h" /FD /GZ /c
+# ADD BASE RSC /l 0x409 /d "_DEBUG"
+# ADD RSC /l 0x409 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386 /pdbtype:sept
+# Begin Custom Build - Performing registration
+OutDir=.\Debug
+TargetPath=.\Debug\XCallback_Impl.dll
+InputPath=.\Debug\XCallback_Impl.dll
+SOURCE="$(InputPath)"
+
+"$(OutDir)\regsvr32.trg" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ regsvr32 /s /c "$(TargetPath)"
+ echo regsvr32 exec. time > "$(OutDir)\regsvr32.trg"
+
+# End Custom Build
+
+!ELSEIF "$(CFG)" == "XCallback_Impl - Win32 Unicode Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "DebugU"
+# PROP BASE Intermediate_Dir "DebugU"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "DebugU"
+# PROP Intermediate_Dir "DebugU"
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MTd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_USRDLL" /D "_UNICODE" /Yu"stdafx.h" /FD /GZ /c
+# ADD CPP /nologo /MTd /W3 /Gm /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_USRDLL" /D "_UNICODE" /Yu"stdafx.h" /FD /GZ /c
+# ADD BASE RSC /l 0x409 /d "_DEBUG"
+# ADD RSC /l 0x409 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386 /pdbtype:sept
+# Begin Custom Build - Performing registration
+OutDir=.\DebugU
+TargetPath=.\DebugU\XCallback_Impl.dll
+InputPath=.\DebugU\XCallback_Impl.dll
+SOURCE="$(InputPath)"
+
+"$(OutDir)\regsvr32.trg" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ if "%OS%"=="" goto NOTNT
+ if not "%OS%"=="Windows_NT" goto NOTNT
+ regsvr32 /s /c "$(TargetPath)"
+ echo regsvr32 exec. time > "$(OutDir)\regsvr32.trg"
+ goto end
+ :NOTNT
+ echo Warning : Cannot register Unicode DLL on Windows 95
+ :end
+
+# End Custom Build
+
+!ELSEIF "$(CFG)" == "XCallback_Impl - Win32 Release MinSize"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "ReleaseMinSize"
+# PROP BASE Intermediate_Dir "ReleaseMinSize"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "ReleaseMinSize"
+# PROP Intermediate_Dir "ReleaseMinSize"
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MT /W3 /O1 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "_ATL_DLL" /D "_ATL_MIN_CRT" /Yu"stdafx.h" /FD /c
+# ADD CPP /nologo /MT /W3 /O1 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "_ATL_DLL" /D "_ATL_MIN_CRT" /Yu"stdafx.h" /FD /c
+# ADD BASE RSC /l 0x409 /d "NDEBUG"
+# ADD RSC /l 0x409 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386
+# Begin Custom Build - Performing registration
+OutDir=.\ReleaseMinSize
+TargetPath=.\ReleaseMinSize\XCallback_Impl.dll
+InputPath=.\ReleaseMinSize\XCallback_Impl.dll
+SOURCE="$(InputPath)"
+
+"$(OutDir)\regsvr32.trg" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ regsvr32 /s /c "$(TargetPath)"
+ echo regsvr32 exec. time > "$(OutDir)\regsvr32.trg"
+
+# End Custom Build
+
+!ELSEIF "$(CFG)" == "XCallback_Impl - Win32 Release MinDependency"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "ReleaseMinDependency"
+# PROP BASE Intermediate_Dir "ReleaseMinDependency"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "ReleaseMinDependency"
+# PROP Intermediate_Dir "ReleaseMinDependency"
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MT /W3 /O1 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "_ATL_STATIC_REGISTRY" /D "_ATL_MIN_CRT" /Yu"stdafx.h" /FD /c
+# ADD CPP /nologo /MT /W3 /O1 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "_ATL_STATIC_REGISTRY" /D "_ATL_MIN_CRT" /Yu"stdafx.h" /FD /c
+# ADD BASE RSC /l 0x409 /d "NDEBUG"
+# ADD RSC /l 0x409 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386
+# Begin Custom Build - Performing registration
+OutDir=.\ReleaseMinDependency
+TargetPath=.\ReleaseMinDependency\XCallback_Impl.dll
+InputPath=.\ReleaseMinDependency\XCallback_Impl.dll
+SOURCE="$(InputPath)"
+
+"$(OutDir)\regsvr32.trg" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ regsvr32 /s /c "$(TargetPath)"
+ echo regsvr32 exec. time > "$(OutDir)\regsvr32.trg"
+
+# End Custom Build
+
+!ELSEIF "$(CFG)" == "XCallback_Impl - Win32 Unicode Release MinSize"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "ReleaseUMinSize"
+# PROP BASE Intermediate_Dir "ReleaseUMinSize"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "ReleaseUMinSize"
+# PROP Intermediate_Dir "ReleaseUMinSize"
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MT /W3 /O1 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_USRDLL" /D "_UNICODE" /D "_ATL_DLL" /D "_ATL_MIN_CRT" /Yu"stdafx.h" /FD /c
+# ADD CPP /nologo /MT /W3 /O1 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_USRDLL" /D "_UNICODE" /D "_ATL_DLL" /D "_ATL_MIN_CRT" /Yu"stdafx.h" /FD /c
+# ADD BASE RSC /l 0x409 /d "NDEBUG"
+# ADD RSC /l 0x409 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386
+# Begin Custom Build - Performing registration
+OutDir=.\ReleaseUMinSize
+TargetPath=.\ReleaseUMinSize\XCallback_Impl.dll
+InputPath=.\ReleaseUMinSize\XCallback_Impl.dll
+SOURCE="$(InputPath)"
+
+"$(OutDir)\regsvr32.trg" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ if "%OS%"=="" goto NOTNT
+ if not "%OS%"=="Windows_NT" goto NOTNT
+ regsvr32 /s /c "$(TargetPath)"
+ echo regsvr32 exec. time > "$(OutDir)\regsvr32.trg"
+ goto end
+ :NOTNT
+ echo Warning : Cannot register Unicode DLL on Windows 95
+ :end
+
+# End Custom Build
+
+!ELSEIF "$(CFG)" == "XCallback_Impl - Win32 Unicode Release MinDependency"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "ReleaseUMinDependency"
+# PROP BASE Intermediate_Dir "ReleaseUMinDependency"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "ReleaseUMinDependency"
+# PROP Intermediate_Dir "ReleaseUMinDependency"
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MT /W3 /O1 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_USRDLL" /D "_UNICODE" /D "_ATL_STATIC_REGISTRY" /D "_ATL_MIN_CRT" /Yu"stdafx.h" /FD /c
+# ADD CPP /nologo /MT /W3 /O1 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_USRDLL" /D "_UNICODE" /D "_ATL_STATIC_REGISTRY" /Yu"stdafx.h" /FD /c
+# ADD BASE RSC /l 0x409 /d "NDEBUG"
+# ADD RSC /l 0x409 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386
+# Begin Custom Build - Performing registration
+OutDir=.\ReleaseUMinDependency
+TargetPath=.\ReleaseUMinDependency\XCallback_Impl.dll
+InputPath=.\ReleaseUMinDependency\XCallback_Impl.dll
+SOURCE="$(InputPath)"
+
+"$(OutDir)\regsvr32.trg" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ if "%OS%"=="" goto NOTNT
+ if not "%OS%"=="Windows_NT" goto NOTNT
+ regsvr32 /s /c "$(TargetPath)"
+ echo regsvr32 exec. time > "$(OutDir)\regsvr32.trg"
+ goto end
+ :NOTNT
+ echo Warning : Cannot register Unicode DLL on Windows 95
+ :end
+
+# End Custom Build
+
+!ENDIF
+
+# Begin Target
+
+# Name "XCallback_Impl - Win32 Debug"
+# Name "XCallback_Impl - Win32 Unicode Debug"
+# Name "XCallback_Impl - Win32 Release MinSize"
+# Name "XCallback_Impl - Win32 Release MinDependency"
+# Name "XCallback_Impl - Win32 Unicode Release MinSize"
+# Name "XCallback_Impl - Win32 Unicode Release MinDependency"
+# Begin Group "Source Files"
+
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+# Begin Source File
+
+SOURCE=.\Callback.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\Simple.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\StdAfx.cpp
+# ADD CPP /Yc"stdafx.h"
+# End Source File
+# Begin Source File
+
+SOURCE=.\XCallback_Impl.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\XCallback_Impl.def
+# End Source File
+# Begin Source File
+
+SOURCE=.\XCallback_Impl.idl
+# ADD MTL /tlb ".\XCallback_Impl.tlb" /h "XCallback_Impl.h" /iid "XCallback_Impl_i.c" /Oicf
+# End Source File
+# Begin Source File
+
+SOURCE=.\XCallback_Impl.rc
+# End Source File
+# End Group
+# Begin Group "Header Files"
+
+# PROP Default_Filter "h;hpp;hxx;hm;inl"
+# Begin Source File
+
+SOURCE=.\Callback.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\Resource.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\Simple.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\StdAfx.h
+# End Source File
+# End Group
+# Begin Group "Resource Files"
+
+# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
+# Begin Source File
+
+SOURCE=.\Callback.rgs
+# End Source File
+# Begin Source File
+
+SOURCE=.\Simple.rgs
+# End Source File
+# End Group
+# End Target
+# End Project
+
+
diff --git a/extensions/test/ole/unoTocomCalls/XCallback_Impl/XCallback_Impl.idl b/extensions/test/ole/unoTocomCalls/XCallback_Impl/XCallback_Impl.idl
new file mode 100644
index 000000000000..5532432130c8
--- /dev/null
+++ b/extensions/test/ole/unoTocomCalls/XCallback_Impl/XCallback_Impl.idl
@@ -0,0 +1,151 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+// XCallback_Impl.idl : IDL source for XCallback_Impl.dll
+//
+
+// This file will be processed by the MIDL tool to
+// produce the type library (XCallback_Impl.tlb) and marshalling code.
+
+import "oaidl.idl";
+import "ocidl.idl";
+ [
+ object,
+ uuid(180FF55F-6F5C-11D4-8330-005004526AB4),
+ dual,
+ helpstring("ICallback Interface"),
+ pointer_default(unique)
+ ]
+ interface ICallback : IDispatch
+ {
+ [id(1), helpstring("method func1")] HRESULT func1();
+ [id(2), helpstring("method returnInterface")] HRESULT returnInterface([out, retval] IDispatch** ppdisp);
+ [id(3), helpstring("method outInterface")] HRESULT outInterface([out] IDispatch** ppdisp);
+ [id(4), helpstring("method outValuesMixed")] HRESULT outValuesMixed([in] long val, [out] long* pval, [in] BSTR string);
+ [id(5), helpstring("method outValuesAll")] HRESULT outValuesAll([out] IDispatch** ppdisp, [out] IDispatch** ppSimpleStruct, [out] long* aSimpleEnum,
+ [out] SAFEARRAY( VARIANT)* outSeq,
+ [out] VARIANT* varAny,
+ [out] VARIANT_BOOL * aBool,
+ [out] short* aChar,
+ [out] BSTR* aString ,
+ [out] float* aFloat,
+ [out] double* aDouble,
+ [out] unsigned char* aByte,
+ [out] short* aShort,
+ [out]long* aLong);
+// );
+ [id(6), helpstring("method outStruct")] HRESULT outStruct([out] IDispatch** outStruct);
+ [id(7), helpstring("method outEnum")] HRESULT outEnum([out] long* outEnum);
+ [id(8), helpstring("method outSeqAny")] HRESULT outSeqAny([out] SAFEARRAY( VARIANT)* outSeq);
+ [id(9), helpstring("method outAny")] HRESULT outAny([out] VARIANT* outAny);
+ [id(10), helpstring("method outBool")] HRESULT outBool([out]VARIANT_BOOL* outBool);
+ [id(11), helpstring("method outChar")] HRESULT outChar([out] short* outChar);
+ [id(12), helpstring("method outString")] HRESULT outString([out] BSTR * outString);
+ [id(13), helpstring("method outFloat")] HRESULT outFloat([out] float* outFloat);
+ [id(14), helpstring("method outDouble")] HRESULT outDouble([out] double* outDouble);
+ [id(16), helpstring("method outShort")] HRESULT outShort([out] short *outShort);
+ [id(17), helpstring("method outLong")] HRESULT outLong([out] long* outLong);
+ [id(20), helpstring("method outByte")] HRESULT outByte([out] unsigned char* outByte);
+ [id(21), helpstring("method inoutInterface")] HRESULT inoutInterface([in,out] IDispatch** ppdisp);
+ [id(22), helpstring("method inoutStruct")] HRESULT inoutStruct([in,out] IDispatch** inoutVal);
+ [id(23), helpstring("method inoutEnum")] HRESULT inoutEnum([in,out] long * inoutVal);
+ [id(24), helpstring("method inoutSeqAny")] HRESULT inoutSeqAny([in,out] SAFEARRAY(VARIANT)* pArray);
+ [id(25), helpstring("method inoutAny")] HRESULT inoutAny([in,out] VARIANT* inoutVal);
+ [id(26), helpstring("method inoutBool")] HRESULT inoutBool([in,out] VARIANT_BOOL * inoutVal);
+ [id(27), helpstring("method inoutChar")] HRESULT inoutChar([in,out] short* inoutVal);
+ [id(28), helpstring("method inoutString")] HRESULT inoutString([in,out] BSTR *inoutVal);
+ [id(29), helpstring("method inoutFloat")] HRESULT inoutFloat([in,out] float* inoutVal);
+ [id(30), helpstring("method inoutDouble")] HRESULT inoutDouble([in,out] double* inoutVal);
+ [id(31), helpstring("method inoutByte")] HRESULT inoutByte([in,out] unsigned char* inoutVal);
+ [id(32), helpstring("method inoutShort")] HRESULT inoutShort([in,out] short* inoutVal);
+ [id(33), helpstring("method inoutLong")] HRESULT inoutLong([in,out] long* inoutVal);
+ [id(34), helpstring("method inoutValueAll")] HRESULT inoutValuesAll(
+ [in,out] IDispatch** aXSimple,
+ [in,out] IDispatch** aStruct,
+ [in,out] long* aEnum,
+ [in,out] SAFEARRAY( VARIANT)* aSeq,
+ [in,out] VARIANT* aAny,
+ [in,out] VARIANT_BOOL* aBool,
+ [in,out] short* aChar,
+ [in,out] BSTR* aString,
+ [in,out] float* aFloat,
+ [in,out] double* aDouble,
+ [in,out] unsigned char* aByte,
+ [in,out] short* aShort,
+ [in,out] long* aLong);
+ [id(35), helpstring("method inValues")] HRESULT inValues([in]short aChar, [in] long aLong, [in] BSTR aString);
+ [id(36), helpstring("method outSeqByte")] HRESULT outSeqByte([out] SAFEARRAY(unsigned char)* outVal);
+ [id(37), helpstring("method inSeqByte")] HRESULT inSeqByte([in] SAFEARRAY(VARIANT) val);
+ [id(38), helpstring("method inSeqXEventListener")] HRESULT inSeqXEventListener([in] SAFEARRAY(VARIANT) listener,
+ [in] SAFEARRAY(VARIANT) event);
+
+ };
+ [
+ object,
+ uuid(180FF564-6F5C-11D4-8330-005004526AB4),
+ dual,
+ helpstring("ISimple Interface"),
+ pointer_default(unique)
+ ]
+ interface ISimple : IDispatch
+ {
+ [id(1), helpstring("method func")] HRESULT func( [in] BSTR message);
+ [id(2), helpstring("method func2")] HRESULT func2([in] BSTR message);
+ [id(3), helpstring("method func3")] HRESULT func3([in] BSTR message);
+ [propget, id(4), helpstring("property _implementedInterfaces")] HRESULT _implementedInterfaces([out, retval] SAFEARRAY(BSTR) *pVal);
+ };
+
+
+
+[
+ uuid(180FF553-6F5C-11D4-8330-005004526AB4),
+ version(1.0),
+ helpstring("XCallback_Impl 1.0 Type Library")
+]
+library XCALLBACK_IMPLLib
+{
+ importlib("stdole32.tlb");
+ importlib("stdole2.tlb");
+
+ [
+ uuid(180FF560-6F5C-11D4-8330-005004526AB4),
+ helpstring("Callback Class")
+ ]
+ coclass Callback
+ {
+ [default] interface ICallback;
+ };
+ [
+ uuid(180FF565-6F5C-11D4-8330-005004526AB4),
+ helpstring("Simple Class")
+ ]
+ coclass Simple
+ {
+ [default] interface ISimple;
+ };
+};
+
+
diff --git a/extensions/test/ole/unoTocomCalls/XCallback_Impl/XCallback_Impl.rc b/extensions/test/ole/unoTocomCalls/XCallback_Impl/XCallback_Impl.rc
new file mode 100644
index 000000000000..32b4852338b5
--- /dev/null
+++ b/extensions/test/ole/unoTocomCalls/XCallback_Impl/XCallback_Impl.rc
@@ -0,0 +1,163 @@
+/*************************************************************************
+*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+**************************************************************************/
+
+#include "resource.h"
+
+#define APSTUDIO_READONLY_SYMBOLS
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 2 resource.
+//
+#include "winres.h"
+
+/////////////////////////////////////////////////////////////////////////////
+#undef APSTUDIO_READONLY_SYMBOLS
+
+/////////////////////////////////////////////////////////////////////////////
+// German (Germany) resources
+
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_DEU)
+#ifdef _WIN32
+LANGUAGE LANG_GERMAN, SUBLANG_GERMAN
+#pragma code_page(1252)
+#endif //_WIN32
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// REGISTRY
+//
+
+IDR_CALLBACK REGISTRY DISCARDABLE "Callback.rgs"
+IDR_SIMPLE REGISTRY DISCARDABLE "Simple.rgs"
+#endif // German (Germany) resources
+/////////////////////////////////////////////////////////////////////////////
+
+
+/////////////////////////////////////////////////////////////////////////////
+// English (U.S.) resources
+
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
+#ifdef _WIN32
+LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
+#pragma code_page(1252)
+#endif //_WIN32
+
+#ifdef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// TEXTINCLUDE
+//
+
+1 TEXTINCLUDE DISCARDABLE
+BEGIN
+ "resource.h\0"
+END
+
+2 TEXTINCLUDE DISCARDABLE
+BEGIN
+ "#include ""winres.h""\r\n"
+ "\0"
+END
+
+3 TEXTINCLUDE DISCARDABLE
+BEGIN
+ "1 TYPELIB ""XCallback_Impl.tlb""\r\n"
+ "\0"
+END
+
+#endif // APSTUDIO_INVOKED
+
+
+#ifndef _MAC
+/////////////////////////////////////////////////////////////////////////////
+//
+// Version
+//
+
+VS_VERSION_INFO VERSIONINFO
+ FILEVERSION 1,0,0,1
+ PRODUCTVERSION 1,0,0,1
+ FILEFLAGSMASK 0x3fL
+#ifdef _DEBUG
+ FILEFLAGS 0x1L
+#else
+ FILEFLAGS 0x0L
+#endif
+ FILEOS 0x4L
+ FILETYPE 0x2L
+ FILESUBTYPE 0x0L
+BEGIN
+ BLOCK "StringFileInfo"
+ BEGIN
+ BLOCK "040904B0"
+ BEGIN
+ VALUE "CompanyName", "\0"
+ VALUE "FileDescription", "XCallback_Impl Module\0"
+ VALUE "FileVersion", "1, 0, 0, 1\0"
+ VALUE "InternalName", "XCallback_Impl\0"
+ VALUE "LegalCopyright", "Copyright 2000\0"
+ VALUE "OriginalFilename", "XCallback_Impl.DLL\0"
+ VALUE "ProductName", "XCallback_Impl Module\0"
+ VALUE "ProductVersion", "1, 0, 0, 1\0"
+ VALUE "OLESelfRegister", "\0"
+ END
+ END
+ BLOCK "VarFileInfo"
+ BEGIN
+ VALUE "Translation", 0x409, 1200
+ END
+END
+
+#endif // !_MAC
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// String Table
+//
+
+STRINGTABLE DISCARDABLE
+BEGIN
+ IDS_PROJNAME "XCallback_Impl"
+END
+
+#endif // English (U.S.) resources
+/////////////////////////////////////////////////////////////////////////////
+
+
+
+#ifndef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 3 resource.
+//
+1 TYPELIB "XCallback_Impl.tlb"
+
+/////////////////////////////////////////////////////////////////////////////
+#endif // not APSTUDIO_INVOKED
+
+
diff --git a/extensions/test/ole/unoTocomCalls/XCallback_Impl/XCallback_Impl.sln b/extensions/test/ole/unoTocomCalls/XCallback_Impl/XCallback_Impl.sln
new file mode 100644
index 000000000000..62b109fe4afe
--- /dev/null
+++ b/extensions/test/ole/unoTocomCalls/XCallback_Impl/XCallback_Impl.sln
@@ -0,0 +1,31 @@
+Microsoft Visual Studio Solution File, Format Version 10.00
+# Visual Studio 2008
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "XCallback_Impl", "XCallback_Impl.vcproj", "{92A6B531-401E-4900-8217-169A96F4168D}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Win32 = Debug|Win32
+ Release MinDependency|Win32 = Release MinDependency|Win32
+ Release MinSize|Win32 = Release MinSize|Win32
+ Unicode Debug|Win32 = Unicode Debug|Win32
+ Unicode Release MinDependency|Win32 = Unicode Release MinDependency|Win32
+ Unicode Release MinSize|Win32 = Unicode Release MinSize|Win32
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {92A6B531-401E-4900-8217-169A96F4168D}.Debug|Win32.ActiveCfg = Debug|Win32
+ {92A6B531-401E-4900-8217-169A96F4168D}.Debug|Win32.Build.0 = Debug|Win32
+ {92A6B531-401E-4900-8217-169A96F4168D}.Release MinDependency|Win32.ActiveCfg = Release MinDependency|Win32
+ {92A6B531-401E-4900-8217-169A96F4168D}.Release MinDependency|Win32.Build.0 = Release MinDependency|Win32
+ {92A6B531-401E-4900-8217-169A96F4168D}.Release MinSize|Win32.ActiveCfg = Release MinSize|Win32
+ {92A6B531-401E-4900-8217-169A96F4168D}.Release MinSize|Win32.Build.0 = Release MinSize|Win32
+ {92A6B531-401E-4900-8217-169A96F4168D}.Unicode Debug|Win32.ActiveCfg = Unicode Debug|Win32
+ {92A6B531-401E-4900-8217-169A96F4168D}.Unicode Debug|Win32.Build.0 = Unicode Debug|Win32
+ {92A6B531-401E-4900-8217-169A96F4168D}.Unicode Release MinDependency|Win32.ActiveCfg = Unicode Release MinDependency|Win32
+ {92A6B531-401E-4900-8217-169A96F4168D}.Unicode Release MinDependency|Win32.Build.0 = Unicode Release MinDependency|Win32
+ {92A6B531-401E-4900-8217-169A96F4168D}.Unicode Release MinSize|Win32.ActiveCfg = Unicode Release MinSize|Win32
+ {92A6B531-401E-4900-8217-169A96F4168D}.Unicode Release MinSize|Win32.Build.0 = Unicode Release MinSize|Win32
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
diff --git a/extensions/test/ole/unoTocomCalls/XCallback_Impl/XCallback_Impl.vcproj b/extensions/test/ole/unoTocomCalls/XCallback_Impl/XCallback_Impl.vcproj
new file mode 100644
index 000000000000..1a9068d31482
--- /dev/null
+++ b/extensions/test/ole/unoTocomCalls/XCallback_Impl/XCallback_Impl.vcproj
@@ -0,0 +1,816 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="9,00"
+ Name="XCallback_Impl"
+ ProjectGUID="{92A6B531-401E-4900-8217-169A96F4168D}"
+ RootNamespace="XCallback_Impl"
+ Keyword="AtlProj"
+ TargetFrameworkVersion="131072"
+ >
+ <Platforms>
+ <Platform
+ Name="Win32"
+ />
+ </Platforms>
+ <ToolFiles>
+ </ToolFiles>
+ <Configurations>
+ <Configuration
+ Name="Unicode Release MinSize|Win32"
+ OutputDirectory=".\ReleaseUMinSize"
+ IntermediateDirectory=".\ReleaseUMinSize"
+ ConfigurationType="2"
+ InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC70.vsprops"
+ UseOfMFC="0"
+ UseOfATL="2"
+ ATLMinimizesCRunTimeLibraryUsage="false"
+ CharacterSet="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ Description="Performing registration"
+ CommandLine="if &quot;%OS%&quot;==&quot;&quot; goto NOTNT&#x0D;&#x0A;if not &quot;%OS%&quot;==&quot;Windows_NT&quot; goto NOTNT&#x0D;&#x0A;regsvr32 /s /c &quot;$(TargetPath)&quot;&#x0D;&#x0A;echo regsvr32 exec. time &gt; &quot;$(OutDir)\regsvr32.trg&quot;&#x0D;&#x0A;goto end&#x0D;&#x0A;:NOTNT&#x0D;&#x0A;echo Warning : Cannot register Unicode DLL on Windows 95&#x0D;&#x0A;:end&#x0D;&#x0A;"
+ Outputs="$(OutDir)\regsvr32.trg"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ TypeLibraryName=".\ReleaseUMinSize/XCallback_Impl.tlb"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ InlineFunctionExpansion="1"
+ PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL"
+ StringPooling="true"
+ RuntimeLibrary="0"
+ EnableFunctionLevelLinking="true"
+ UsePrecompiledHeader="2"
+ PrecompiledHeaderThrough="stdafx.h"
+ PrecompiledHeaderFile=".\ReleaseUMinSize/XCallback_Impl.pch"
+ AssemblerListingLocation=".\ReleaseUMinSize/"
+ ObjectFile=".\ReleaseUMinSize/"
+ ProgramDataBaseFileName=".\ReleaseUMinSize/"
+ WarningLevel="3"
+ SuppressStartupBanner="true"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ PreprocessorDefinitions="NDEBUG"
+ Culture="1033"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalOptions="/MACHINE:I386"
+ AdditionalDependencies="odbc32.lib odbccp32.lib"
+ OutputFile=".\ReleaseUMinSize/XCallback_Impl.dll"
+ LinkIncremental="1"
+ SuppressStartupBanner="true"
+ ModuleDefinitionFile=".\XCallback_Impl.def"
+ ProgramDatabaseFile=".\ReleaseUMinSize/XCallback_Impl.pdb"
+ SubSystem="2"
+ RandomizedBaseAddress="1"
+ DataExecutionPrevention="0"
+ ImportLibrary=".\ReleaseUMinSize/XCallback_Impl.lib"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release MinSize|Win32"
+ OutputDirectory=".\ReleaseMinSize"
+ IntermediateDirectory=".\ReleaseMinSize"
+ ConfigurationType="2"
+ InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC70.vsprops"
+ UseOfMFC="0"
+ UseOfATL="2"
+ ATLMinimizesCRunTimeLibraryUsage="false"
+ CharacterSet="2"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ Description="Performing registration"
+ CommandLine="regsvr32 /s /c &quot;$(TargetPath)&quot;&#x0D;&#x0A;echo regsvr32 exec. time &gt; &quot;$(OutDir)\regsvr32.trg&quot;&#x0D;&#x0A;"
+ Outputs="$(OutDir)\regsvr32.trg"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ TypeLibraryName=".\ReleaseMinSize/XCallback_Impl.tlb"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ InlineFunctionExpansion="1"
+ PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL"
+ StringPooling="true"
+ RuntimeLibrary="0"
+ EnableFunctionLevelLinking="true"
+ UsePrecompiledHeader="2"
+ PrecompiledHeaderThrough="stdafx.h"
+ PrecompiledHeaderFile=".\ReleaseMinSize/XCallback_Impl.pch"
+ AssemblerListingLocation=".\ReleaseMinSize/"
+ ObjectFile=".\ReleaseMinSize/"
+ ProgramDataBaseFileName=".\ReleaseMinSize/"
+ WarningLevel="3"
+ SuppressStartupBanner="true"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ PreprocessorDefinitions="NDEBUG"
+ Culture="1033"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalOptions="/MACHINE:I386"
+ AdditionalDependencies="odbc32.lib odbccp32.lib"
+ OutputFile=".\ReleaseMinSize/XCallback_Impl.dll"
+ LinkIncremental="1"
+ SuppressStartupBanner="true"
+ ModuleDefinitionFile=".\XCallback_Impl.def"
+ ProgramDatabaseFile=".\ReleaseMinSize/XCallback_Impl.pdb"
+ SubSystem="2"
+ RandomizedBaseAddress="1"
+ DataExecutionPrevention="0"
+ ImportLibrary=".\ReleaseMinSize/XCallback_Impl.lib"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Unicode Release MinDependency|Win32"
+ OutputDirectory=".\ReleaseUMinDependency"
+ IntermediateDirectory=".\ReleaseUMinDependency"
+ ConfigurationType="2"
+ InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC70.vsprops"
+ UseOfMFC="0"
+ UseOfATL="1"
+ ATLMinimizesCRunTimeLibraryUsage="false"
+ CharacterSet="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ Description="Performing registration"
+ CommandLine="if &quot;%OS%&quot;==&quot;&quot; goto NOTNT&#x0D;&#x0A;if not &quot;%OS%&quot;==&quot;Windows_NT&quot; goto NOTNT&#x0D;&#x0A;regsvr32 /s /c &quot;$(TargetPath)&quot;&#x0D;&#x0A;echo regsvr32 exec. time &gt; &quot;$(OutDir)\regsvr32.trg&quot;&#x0D;&#x0A;goto end&#x0D;&#x0A;:NOTNT&#x0D;&#x0A;echo Warning : Cannot register Unicode DLL on Windows 95&#x0D;&#x0A;:end&#x0D;&#x0A;"
+ Outputs="$(OutDir)\regsvr32.trg"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ TypeLibraryName=".\ReleaseUMinDependency/XCallback_Impl.tlb"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="1"
+ InlineFunctionExpansion="1"
+ PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL"
+ StringPooling="true"
+ RuntimeLibrary="0"
+ EnableFunctionLevelLinking="true"
+ UsePrecompiledHeader="2"
+ PrecompiledHeaderThrough="stdafx.h"
+ PrecompiledHeaderFile=".\ReleaseUMinDependency/XCallback_Impl.pch"
+ AssemblerListingLocation=".\ReleaseUMinDependency/"
+ ObjectFile=".\ReleaseUMinDependency/"
+ ProgramDataBaseFileName=".\ReleaseUMinDependency/"
+ WarningLevel="3"
+ SuppressStartupBanner="true"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ PreprocessorDefinitions="NDEBUG"
+ Culture="1033"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalOptions="/MACHINE:I386"
+ AdditionalDependencies="odbc32.lib odbccp32.lib"
+ OutputFile=".\ReleaseUMinDependency/XCallback_Impl.dll"
+ LinkIncremental="1"
+ SuppressStartupBanner="true"
+ ModuleDefinitionFile=".\XCallback_Impl.def"
+ ProgramDatabaseFile=".\ReleaseUMinDependency/XCallback_Impl.pdb"
+ SubSystem="2"
+ RandomizedBaseAddress="1"
+ DataExecutionPrevention="0"
+ ImportLibrary=".\ReleaseUMinDependency/XCallback_Impl.lib"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release MinDependency|Win32"
+ OutputDirectory=".\ReleaseMinDependency"
+ IntermediateDirectory=".\ReleaseMinDependency"
+ ConfigurationType="2"
+ InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC70.vsprops"
+ UseOfMFC="0"
+ UseOfATL="1"
+ ATLMinimizesCRunTimeLibraryUsage="false"
+ CharacterSet="2"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ Description="Performing registration"
+ CommandLine="regsvr32 /s /c &quot;$(TargetPath)&quot;&#x0D;&#x0A;echo regsvr32 exec. time &gt; &quot;$(OutDir)\regsvr32.trg&quot;&#x0D;&#x0A;"
+ Outputs="$(OutDir)\regsvr32.trg"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ TypeLibraryName=".\ReleaseMinDependency/XCallback_Impl.tlb"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ InlineFunctionExpansion="1"
+ PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL"
+ StringPooling="true"
+ RuntimeLibrary="0"
+ EnableFunctionLevelLinking="true"
+ UsePrecompiledHeader="2"
+ PrecompiledHeaderThrough="stdafx.h"
+ PrecompiledHeaderFile=".\ReleaseMinDependency/XCallback_Impl.pch"
+ AssemblerListingLocation=".\ReleaseMinDependency/"
+ ObjectFile=".\ReleaseMinDependency/"
+ ProgramDataBaseFileName=".\ReleaseMinDependency/"
+ WarningLevel="3"
+ SuppressStartupBanner="true"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ PreprocessorDefinitions="NDEBUG"
+ Culture="1033"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalOptions="/MACHINE:I386"
+ AdditionalDependencies="odbc32.lib odbccp32.lib"
+ OutputFile=".\ReleaseMinDependency/XCallback_Impl.dll"
+ LinkIncremental="1"
+ SuppressStartupBanner="true"
+ ModuleDefinitionFile=".\XCallback_Impl.def"
+ ProgramDatabaseFile=".\ReleaseMinDependency/XCallback_Impl.pdb"
+ SubSystem="2"
+ RandomizedBaseAddress="1"
+ DataExecutionPrevention="0"
+ ImportLibrary=".\ReleaseMinDependency/XCallback_Impl.lib"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Unicode Debug|Win32"
+ OutputDirectory=".\DebugU"
+ IntermediateDirectory=".\DebugU"
+ ConfigurationType="2"
+ InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC70.vsprops"
+ UseOfMFC="0"
+ ATLMinimizesCRunTimeLibraryUsage="false"
+ CharacterSet="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ Description="Performing registration"
+ CommandLine="if &quot;%OS%&quot;==&quot;&quot; goto NOTNT&#x0D;&#x0A;if not &quot;%OS%&quot;==&quot;Windows_NT&quot; goto NOTNT&#x0D;&#x0A;regsvr32 /s /c &quot;$(TargetPath)&quot;&#x0D;&#x0A;echo regsvr32 exec. time &gt; &quot;$(OutDir)\regsvr32.trg&quot;&#x0D;&#x0A;goto end&#x0D;&#x0A;:NOTNT&#x0D;&#x0A;echo Warning : Cannot register Unicode DLL on Windows 95&#x0D;&#x0A;:end&#x0D;&#x0A;"
+ Outputs="$(OutDir)\regsvr32.trg"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ TypeLibraryName=".\DebugU/XCallback_Impl.tlb"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="1"
+ UsePrecompiledHeader="2"
+ PrecompiledHeaderThrough="stdafx.h"
+ PrecompiledHeaderFile=".\DebugU/XCallback_Impl.pch"
+ AssemblerListingLocation=".\DebugU/"
+ ObjectFile=".\DebugU/"
+ ProgramDataBaseFileName=".\DebugU/"
+ WarningLevel="3"
+ SuppressStartupBanner="true"
+ DebugInformationFormat="4"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ PreprocessorDefinitions="_DEBUG"
+ Culture="1033"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalOptions="/MACHINE:I386"
+ AdditionalDependencies="odbc32.lib odbccp32.lib"
+ OutputFile=".\DebugU/XCallback_Impl.dll"
+ LinkIncremental="2"
+ SuppressStartupBanner="true"
+ ModuleDefinitionFile=".\XCallback_Impl.def"
+ GenerateDebugInformation="true"
+ ProgramDatabaseFile=".\DebugU/XCallback_Impl.pdb"
+ SubSystem="2"
+ RandomizedBaseAddress="1"
+ DataExecutionPrevention="0"
+ ImportLibrary=".\DebugU/XCallback_Impl.lib"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory=".\Debug"
+ IntermediateDirectory=".\Debug"
+ ConfigurationType="2"
+ InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC70.vsprops"
+ UseOfMFC="0"
+ ATLMinimizesCRunTimeLibraryUsage="false"
+ CharacterSet="2"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ Description="Performing registration"
+ CommandLine="regsvr32 /s /c &quot;$(TargetPath)&quot;&#x0D;&#x0A;echo regsvr32 exec. time &gt; &quot;$(OutDir)\regsvr32.trg&quot;&#x0D;&#x0A;"
+ Outputs="$(OutDir)\regsvr32.trg"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ TypeLibraryName=".\Debug/XCallback_Impl.tlb"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalOptions="/D_CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES"
+ Optimization="0"
+ PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="1"
+ UsePrecompiledHeader="2"
+ PrecompiledHeaderThrough="stdafx.h"
+ PrecompiledHeaderFile=".\Debug/XCallback_Impl.pch"
+ AssemblerListingLocation=".\Debug/"
+ ObjectFile=".\Debug/"
+ ProgramDataBaseFileName=".\Debug/"
+ BrowseInformation="1"
+ WarningLevel="3"
+ SuppressStartupBanner="true"
+ DebugInformationFormat="4"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ PreprocessorDefinitions="_DEBUG"
+ Culture="1033"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalOptions="/MACHINE:I386"
+ AdditionalDependencies="odbc32.lib odbccp32.lib"
+ OutputFile=".\Debug/XCallback_Impl.dll"
+ LinkIncremental="2"
+ SuppressStartupBanner="true"
+ ModuleDefinitionFile=".\XCallback_Impl.def"
+ GenerateDebugInformation="true"
+ ProgramDatabaseFile=".\Debug/XCallback_Impl.pdb"
+ SubSystem="2"
+ RandomizedBaseAddress="1"
+ DataExecutionPrevention="0"
+ ImportLibrary=".\Debug/XCallback_Impl.lib"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Name="Source Files"
+ Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+ >
+ <File
+ RelativePath=".\Callback.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\Simple.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\StdAfx.cpp"
+ >
+ <FileConfiguration
+ Name="Unicode Release MinSize|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ UsePrecompiledHeader="1"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release MinSize|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ UsePrecompiledHeader="1"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Unicode Release MinDependency|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ UsePrecompiledHeader="1"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release MinDependency|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ UsePrecompiledHeader="1"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Unicode Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ UsePrecompiledHeader="1"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ UsePrecompiledHeader="1"
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath=".\XCallback_Impl.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\XCallback_Impl.def"
+ >
+ </File>
+ <File
+ RelativePath=".\XCallback_Impl.idl"
+ >
+ <FileConfiguration
+ Name="Unicode Release MinSize|Win32"
+ >
+ <Tool
+ Name="VCMIDLTool"
+ GenerateStublessProxies="true"
+ TypeLibraryName=".\XCallback_Impl.tlb"
+ HeaderFileName="XCallback_Impl.h"
+ InterfaceIdentifierFileName="XCallback_Impl_i.c"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release MinSize|Win32"
+ >
+ <Tool
+ Name="VCMIDLTool"
+ GenerateStublessProxies="true"
+ TypeLibraryName=".\XCallback_Impl.tlb"
+ HeaderFileName="XCallback_Impl.h"
+ InterfaceIdentifierFileName="XCallback_Impl_i.c"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Unicode Release MinDependency|Win32"
+ >
+ <Tool
+ Name="VCMIDLTool"
+ GenerateStublessProxies="true"
+ TypeLibraryName=".\XCallback_Impl.tlb"
+ HeaderFileName="XCallback_Impl.h"
+ InterfaceIdentifierFileName="XCallback_Impl_i.c"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release MinDependency|Win32"
+ >
+ <Tool
+ Name="VCMIDLTool"
+ GenerateStublessProxies="true"
+ TypeLibraryName=".\XCallback_Impl.tlb"
+ HeaderFileName="XCallback_Impl.h"
+ InterfaceIdentifierFileName="XCallback_Impl_i.c"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Unicode Debug|Win32"
+ >
+ <Tool
+ Name="VCMIDLTool"
+ GenerateStublessProxies="true"
+ TypeLibraryName=".\XCallback_Impl.tlb"
+ HeaderFileName="XCallback_Impl.h"
+ InterfaceIdentifierFileName="XCallback_Impl_i.c"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCMIDLTool"
+ GenerateStublessProxies="true"
+ TypeLibraryName=".\XCallback_Impl.tlb"
+ HeaderFileName="XCallback_Impl.h"
+ InterfaceIdentifierFileName="XCallback_Impl_i.c"
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath=".\XCallback_Impl.rc"
+ >
+ <FileConfiguration
+ Name="Unicode Release MinSize|Win32"
+ >
+ <Tool
+ Name="VCResourceCompilerTool"
+ AdditionalIncludeDirectories="$(OUTDIR);$(NoInherit)"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release MinSize|Win32"
+ >
+ <Tool
+ Name="VCResourceCompilerTool"
+ AdditionalIncludeDirectories="$(OUTDIR);$(NoInherit)"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Unicode Release MinDependency|Win32"
+ >
+ <Tool
+ Name="VCResourceCompilerTool"
+ AdditionalIncludeDirectories="$(OUTDIR);$(NoInherit)"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release MinDependency|Win32"
+ >
+ <Tool
+ Name="VCResourceCompilerTool"
+ AdditionalIncludeDirectories="$(OUTDIR);$(NoInherit)"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Unicode Debug|Win32"
+ >
+ <Tool
+ Name="VCResourceCompilerTool"
+ AdditionalIncludeDirectories="$(OUTDIR);$(NoInherit)"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCResourceCompilerTool"
+ AdditionalIncludeDirectories="$(OUTDIR);$(NoInherit)"
+ />
+ </FileConfiguration>
+ </File>
+ </Filter>
+ <Filter
+ Name="Header Files"
+ Filter="h;hpp;hxx;hm;inl"
+ >
+ <File
+ RelativePath=".\Callback.h"
+ >
+ </File>
+ <File
+ RelativePath=".\Resource.h"
+ >
+ </File>
+ <File
+ RelativePath=".\Simple.h"
+ >
+ </File>
+ <File
+ RelativePath=".\StdAfx.h"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="Resource Files"
+ Filter="ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
+ >
+ <File
+ RelativePath=".\Callback.rgs"
+ >
+ </File>
+ <File
+ RelativePath=".\Simple.rgs"
+ >
+ </File>
+ </Filter>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
diff --git a/extensions/test/ole/unoTocomCalls/XCallback_Impl/resource.h b/extensions/test/ole/unoTocomCalls/XCallback_Impl/resource.h
new file mode 100644
index 000000000000..d041b3790555
--- /dev/null
+++ b/extensions/test/ole/unoTocomCalls/XCallback_Impl/resource.h
@@ -0,0 +1,48 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+//{{NO_DEPENDENCIES}}
+// Microsoft Developer Studio generated include file.
+// Used by XCallback_Impl.rc
+//
+#define IDS_PROJNAME 100
+#define IDR_CALLBACK 101
+#define IDR_SIMPLE 102
+#define IDR_SIMPLESTRUCT 103
+
+// Next default values for new objects
+//
+#ifdef APSTUDIO_INVOKED
+#ifndef APSTUDIO_READONLY_SYMBOLS
+#define _APS_NEXT_RESOURCE_VALUE 201
+#define _APS_NEXT_COMMAND_VALUE 32768
+#define _APS_NEXT_CONTROL_VALUE 201
+#define _APS_NEXT_SYMED_VALUE 104
+#endif
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/test/ole/unoTocomCalls/readme.txt b/extensions/test/ole/unoTocomCalls/readme.txt
new file mode 100644
index 000000000000..40841cb0e8f6
--- /dev/null
+++ b/extensions/test/ole/unoTocomCalls/readme.txt
@@ -0,0 +1,9 @@
+The directory XCallback_Impl contains a MSDEV project that
+creates a dll containing the ActiveX components
+XCallback_Impl.Simple and XCallback_Impl.Callback
+Callback implements functions defined in oletest.XCallback
+and Simple implements functions defined in oletest.XSimple.
+These interfaces are build in extensions/test/ole/cpnt
+
+The projects in unoToComCalls test the functionality of COM
+and JScript object which implement UNO interfaces.
diff --git a/extensions/test/pgp/TestPGP.java b/extensions/test/pgp/TestPGP.java
new file mode 100644
index 000000000000..41f21f3b767a
--- /dev/null
+++ b/extensions/test/pgp/TestPGP.java
@@ -0,0 +1,146 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+
+import java.io.IOException;
+
+import com.sun.star.beans.PropertyValue;
+import com.sun.star.beans.PropertyState;
+
+import com.sun.star.bridge.XBridge;
+
+// import com.sun.star.comp.bootstrap.Bootstrap;
+
+import com.sun.star.connection.XConnector;
+import com.sun.star.connection.XConnection;
+
+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;
+import com.sun.star.container.*;
+import com.sun.star.lang.*;
+
+import com.sun.star.pgp.*;
+
+
+
+public class TestPGP {
+
+
+ static void doSomething(Object r) throws com.sun.star.uno.Exception, IOException, Exception {
+ 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 !");
+ }
+
+ XSet set= (XSet)UnoRuntime.queryInterface(XSet.class, rSmgr);
+ if( set == null) {
+ System.err.println(" couldn't get XSet from ServiceFactory");
+ return;
+ }
+// try{
+ SimplePGPMailerFactoryReg mailerReg= new SimplePGPMailerFactoryReg();
+ XSingleServiceFactory factory= mailerReg.getServiceFactory(
+ "com.sun.star.pgp.SimplePGPMailerImpl", rSmgr, null, null);
+
+ if( factory == null) {
+ System.err.println("couldn't create PGP factory !");
+ return;
+ }
+ set.insert(factory );
+ System.err.println("PGP factory inserted into service manager");
+
+// }catch(Exception e ){
+// System.err.println( "exception caught in TestPGP");
+// }
+
+ }
+ }
+
+
+
+ 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.connections.Acceptor"
+ };
+
+ public static void main(String argv[]) throws Exception {
+ if(argv.length != 1) {
+ System.err.println("usage : testoffice protocol:host:port");
+ System.exit(-1);
+ }
+
+// try {
+ com.sun.star.comp.servicemanager.ServiceManager smgr = new com.sun.star.comp.servicemanager.ServiceManager();
+ smgr.addFactories(neededServices, null);
+
+ XConnector xConnector = (XConnector)smgr.createInstance("com.sun.star.connection.Connector");
+ XConnection xConnection = xConnector.connect(argv[0]);
+
+ String rootOid = "classic_uno";
+ IBridge iBridge = UnoRuntime.getBridgeByName("java", null, "remote", null, new Object[]{"iiop", xConnection, null});
+
+ Object rInitialObject = iBridge.mapInterfaceFrom(rootOid, XInterface.class);
+// Object rInitialObject = xBridge.getInstance("NamingService");
+
+ if(rInitialObject != null) {
+ System.err.println("got the remote object");
+ doSomething(rInitialObject);
+ }
+// }
+// catch (Exception exception) {
+// System.err.println("Exception thrown:" + exception);
+// }
+ }
+}
+
diff --git a/extensions/test/pgp/makefile.mk b/extensions/test/pgp/makefile.mk
new file mode 100644
index 000000000000..9fe20937d2b7
--- /dev/null
+++ b/extensions/test/pgp/makefile.mk
@@ -0,0 +1,124 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+
+
+PRJ=..$/..
+
+PRJNAME := extensions
+#PACKAGE := com$/sun$/star$/pgp
+PACKAGE :=
+TARGET := test_com_sun_star_pgp
+
+
+# --- Settings -----------------------------------------------------
+.INCLUDE : settings.mk
+
+
+# Files --------------------------------------------------------
+
+
+APPLICATRDB := $(SOLARBINDIR)$/applicat.rdb
+RDB := $(APPLICATRDB)
+
+JARFILES= jurt.jar
+
+GENJAVACLASSFILES= \
+ $(CLASSDIR)$/com$/sun$/star$/beans$/PropertyValue.class \
+ $(CLASSDIR)$/com$/sun$/star$/beans$/PropertyState.class \
+ $(CLASSDIR)$/com$/sun$/star$/container$/XSet.class \
+
+
+#$(CLASSDIR)$/com$/sun$/star$/awt$/FocusEvent.class
+
+# $(CLASSDIR)$/com$/sun$/star$/awt$/InputEvent.class \
+# $(CLASSDIR)$/com$/sun$/star$/awt$/KeyEvent.class \
+# $(CLASSDIR)$/com$/sun$/star$/awt$/MouseEvent.class \
+# $(CLASSDIR)$/com$/sun$/star$/awt$/WindowEvent.class \
+# $(CLASSDIR)$/com$/sun$/star$/awt$/PaintEvent.class \
+# $(CLASSDIR)$/com$/sun$/star$/awt$/Rectangle.class \
+# $(CLASSDIR)$/com$/sun$/star$/awt$/XFocusListener.class \
+# $(CLASSDIR)$/com$/sun$/star$/awt$/XKeyListener.class \
+# $(CLASSDIR)$/com$/sun$/star$/awt$/XMouseListener.class \
+# $(CLASSDIR)$/com$/sun$/star$/awt$/XMouseMotionListener.class \
+# $(CLASSDIR)$/com$/sun$/star$/awt$/XWindow.class \
+# $(CLASSDIR)$/com$/sun$/star$/awt$/XWindowListener.class \
+# $(CLASSDIR)$/com$/sun$/star$/awt$/XPaintListener.class \
+# $(CLASSDIR)$/com$/sun$/star$/bridge$/XBridge.class \
+# $(CLASSDIR)$/com$/sun$/star$/container$/XIndexAccess.class \
+# $(CLASSDIR)$/com$/sun$/star$/frame$/FrameAction.class \
+# $(CLASSDIR)$/com$/sun$/star$/frame$/FrameActionEvent.class \
+# $(CLASSDIR)$/com$/sun$/star$/frame$/XComponentLoader.class \
+# $(CLASSDIR)$/com$/sun$/star$/frame$/XController.class \
+# $(CLASSDIR)$/com$/sun$/star$/frame$/XFrame.class \
+# $(CLASSDIR)$/com$/sun$/star$/frame$/XFrameActionListener.class \
+# $(CLASSDIR)$/com$/sun$/star$/frame$/XFrames.class \
+# $(CLASSDIR)$/com$/sun$/star$/frame$/XFramesSupplier.class \
+# $(CLASSDIR)$/com$/sun$/star$/frame$/XModel.class \
+# $(CLASSDIR)$/com$/sun$/star$/io$/BufferSizeExceededException.class \
+# $(CLASSDIR)$/com$/sun$/star$/io$/NotConnectedException.class \
+# $(CLASSDIR)$/com$/sun$/star$/io$/XInputStream.class \
+# $(CLASSDIR)$/com$/sun$/star$/io$/XOutputStream.class \
+# $(CLASSDIR)$/com$/sun$/star$/lang$/IndexOutOfBoundsException.class \
+# $(CLASSDIR)$/com$/sun$/star$/lang$/XComponent.class \
+# $(CLASSDIR)$/com$/sun$/star$/lang$/XMultiServiceFactory.class \
+# $(CLASSDIR)$/com$/sun$/star$/lang$/XServiceInfo.class \
+# $(CLASSDIR)$/com$/sun$/star$/text$/XSimpleText.class \
+# $(CLASSDIR)$/com$/sun$/star$/text$/XText.class \
+# $(CLASSDIR)$/com$/sun$/star$/text$/XTextContent.class \
+# $(CLASSDIR)$/com$/sun$/star$/text$/XTextCursor.class \
+# $(CLASSDIR)$/com$/sun$/star$/text$/XTextDocument.class \
+# $(CLASSDIR)$/com$/sun$/star$/text$/XTextRange.class \
+# $(CLASSDIR)$/com$/sun$/star$/uno$/XNamingService.class \
+# $(CLASSDIR)$/com$/sun$/star$/uno$/Enum.class
+
+
+JAVACLASSFILES= \
+ $(CLASSDIR)$/$(PACKAGE)$/TestPGP.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 ------------------------------------------------------
+
+
+.IF "$(depend)" == ""
+ALL : $(GENJAVAFILES) ALLTAR
+.ELSE
+ALL: ALLDEP
+.ENDIF
+
+.INCLUDE : target.mk
+
+$(GENJAVAFILES) : $(RDB)
+# javamaker -BUCR -O$(OUT) $(TYPES) $(RDB)
+ javamaker @$(mktmp -BUCR -O$(OUT) $(TYPES) $(RDB))
+
+$(JAVACLASSFILES) : $(GENJAVAFILES)
diff --git a/extensions/test/pgp/readme.txt b/extensions/test/pgp/readme.txt
new file mode 100644
index 000000000000..899e3377fe65
--- /dev/null
+++ b/extensions/test/pgp/readme.txt
@@ -0,0 +1,33 @@
+The program TestPGP instantiates a SimplePGPMailerFactory and adds
+ it to the ServiceManager obtained from a running StarOffice.
+Then PGP can be used from within StarOffice.
+
+Prerequisites:
+StarOffice needs an entry in Office/user/sofficerc under the Common
+ section:
+
+ Port2=socket:hamburg-11070:1111 // old style
+as of 569 m
+Connection=socket,hamburg-11070,port=1111;iiop;
+
+Please note the semicolons!
+
+ hamburg-11070 is the host running the office and 1111 is a
+ freely choosable port number.
+
+
+ For the program to run make sure that the office has access
+ to classes.zip, unoil.jar, jurt.jar, pgp.jar and swingall.jar.
+
+ Therefore do the necessary entries in
+ Office/user/config/javarc
+ under SystemClasspath.
+
+There is a bug with jdk1.1.8, therfore use 1.2 instead.
+
+The TestPGP is called without ;iiop; :
+
+java TestPGP "socket,host=localhost,port=1111"
+
+
+
diff --git a/extensions/test/sax/exports.dxp b/extensions/test/sax/exports.dxp
new file mode 100644
index 000000000000..e4bc69d23003
--- /dev/null
+++ b/extensions/test/sax/exports.dxp
@@ -0,0 +1,2 @@
+exService_writeRegEntry
+exService_getFactory
diff --git a/extensions/test/sax/factory.hxx b/extensions/test/sax/factory.hxx
new file mode 100644
index 000000000000..a2d22acdade5
--- /dev/null
+++ b/extensions/test/sax/factory.hxx
@@ -0,0 +1,33 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+XInterfaceRef OSaxWriterTest_CreateInstance( const XMultiServiceFactoryRef & rSMgr ) THROWS((Exception));
+UString OSaxWriterTest_getServiceName( ) THROWS( () );
+UString OSaxWriterTest_getImplementationName( ) THROWS( () );
+Sequence<UString> OSaxWriterTest_getSupportedServiceNames( ) THROWS( () );
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/test/sax/makefile.mk b/extensions/test/sax/makefile.mk
new file mode 100644
index 000000000000..62e2706dd1e7
--- /dev/null
+++ b/extensions/test/sax/makefile.mk
@@ -0,0 +1,64 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+PRJ=..$/..
+
+PRJNAME=extensions
+TARGET=testsax
+USE_DEFFILE=TRUE
+ENABLE_EXCEPTIONS=TRUE
+# --- Settings -----------------------------------------------------
+.INCLUDE : $(PRJ)$/util$/makefile.pmk
+
+# --- Files --------------------------------------------------------
+
+
+
+OBJFILES = $(SLO)$/testsax.obj $(SLO)$/testwriter.obj
+
+LIB1TARGET= $(SLB)$/$(TARGET).lib
+LIB1OBJFILES= $(OBJFILES)
+
+
+SHL1TARGET= $(TARGET)$(DLLPOSTFIX)
+
+SHL1STDLIBS= \
+ $(SALLIB) \
+ $(TOOLSLIB)
+
+SHL1LIBS= $(LIB1TARGET)
+SHL1IMPLIB= i$(TARGET)
+SHL1DEPN= makefile.mk $(SHL1LIBS)
+SHL1DEF= $(MISC)$/$(SHL1TARGET).def
+
+DEF1NAME= $(SHL1TARGET)
+DEF1EXPORTFILE= exports.dxp
+
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : target.mk
+.INCLUDE : $(PRJ)$/util$/target.pmk
diff --git a/extensions/test/sax/testsax.cxx b/extensions/test/sax/testsax.cxx
new file mode 100644
index 000000000000..74a947dd34dc
--- /dev/null
+++ b/extensions/test/sax/testsax.cxx
@@ -0,0 +1,910 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+
+#include <stdio.h>
+#include <string.h>
+#include <smart/com/sun/star/test/XSimpleTest.hxx>
+
+#include <rtl/wstring.hxx>
+#include <osl/time.h>
+#include <usr/weak.hxx>
+#include <tools/string.hxx>
+#include <osl/conditn.hxx>
+
+#include <smart/com/sun/star/io/XOutputStream.hxx>
+#include <smart/com/sun/star/xml/sax/SAXParseException.hxx>
+#include <smart/com/sun/star/xml/sax/XParser.hxx>
+#include <smart/com/sun/star/xml/sax/XExtendedDocumentHandler.hxx>
+
+#include <smart/com/sun/star/lang/XMultiServiceFactory.hxx> // for the multiservice-factories
+#include <usr/factoryhlp.hxx>
+
+#include <usr/reflserv.hxx> // for EXTERN_SERVICE_CALLTYPE
+
+#include "factory.hxx"
+
+using namespace rtl;
+using namespace usr;
+
+
+#define BUILD_ERROR(expr, Message)\
+ {\
+ m_seqErrors.realloc( m_seqErrors.getLen() + 1 ); \
+ m_seqExceptions.realloc( m_seqExceptions.getLen() + 1 ); \
+ String str; \
+ str += __FILE__;\
+ str += " "; \
+ str += "(" ; \
+ str += __LINE__ ;\
+ str += ")\n";\
+ str += "[ " ; \
+ str += #expr; \
+ str += " ] : " ; \
+ str += Message; \
+ m_seqErrors.getArray()[ m_seqErrors.getLen()-1] = StringToUString( str , CHARSET_SYSTEM ); \
+ }\
+ ((void)0)
+
+
+#define WARNING_ASSERT(expr, Message) \
+ if( ! (expr) ) { \
+ m_seqWarnings.realloc( m_seqErrors.getLen() +1 ); \
+ String str;\
+ str += __FILE__;\
+ str += " "; \
+ str += "(" ; \
+ str += __LINE__ ;\
+ str += ")\n";\
+ str += "[ " ; \
+ str += #expr; \
+ str += " ] : " ; \
+ str += Message; \
+ m_seqWarnings.getArray()[ m_seqWarnings.getLen()-1] = StringToUString( str , CHARSET_SYSTEM ); \
+ return; \
+ }\
+ ((void)0)
+
+#define ERROR_ASSERT(expr, Message) \
+ if( ! (expr) ) { \
+ BUILD_ERROR(expr, Message );\
+ return; \
+ }\
+ ((void)0)
+
+#define ERROR_EXCEPTION_ASSERT(expr, Message, Exception) \
+ if( !(expr)) { \
+ BUILD_ERROR(expr,Message);\
+ m_seqExceptions.getArray()[ m_seqExceptions.getLen()-1] = UsrAny( Exception );\
+ return; \
+ } \
+ ((void)0)
+
+/****
+* test szenarios :
+*
+*
+*
+****/
+
+
+
+class OSaxParserTest :
+ public XSimpleTest,
+ public OWeakObject
+{
+public:
+ OSaxParserTest( const XMultiServiceFactoryRef & rFactory ) : m_rFactory( rFactory )
+ {
+
+ }
+
+public: // refcounting
+ BOOL queryInterface( Uik aUik, XInterfaceRef & rOut );
+ void acquire() { OWeakObject::acquire(); }
+ void release() { OWeakObject::release(); }
+ void* getImplementation(Reflection *p) { return OWeakObject::getImplementation(p); }
+
+public:
+ virtual void testInvariant(const UString& TestName, const XInterfaceRef& TestObject)
+ THROWS( ( IllegalArgumentException,
+ UsrSystemException) );
+
+ virtual INT32 test( const UString& TestName,
+ const XInterfaceRef& TestObject,
+ INT32 hTestHandle) THROWS( ( IllegalArgumentException,
+ UsrSystemException) );
+
+ virtual BOOL testPassed(void) THROWS( ( UsrSystemException) );
+ virtual Sequence< UString > getErrors(void) THROWS( (UsrSystemException) );
+ virtual Sequence< UsrAny > getErrorExceptions(void) THROWS( (UsrSystemException) );
+ virtual Sequence< UString > getWarnings(void) THROWS( (UsrSystemException) );
+
+private:
+ void testSimple( const XParserRef &r );
+ void testNamespaces( const XParserRef &r );
+ void testFile( const XParserRef &r );
+ void testEncoding( const XParserRef &rParser );
+ void testPerformance( const XParserRef &rParser );
+
+private:
+ Sequence<UsrAny> m_seqExceptions;
+ Sequence<UString> m_seqErrors;
+ Sequence<UString> m_seqWarnings;
+ XMultiServiceFactoryRef m_rFactory;
+};
+
+
+
+/**
+* for external binding
+*
+*
+**/
+XInterfaceRef OSaxParserTest_CreateInstance( const XMultiServiceFactoryRef & rSMgr ) THROWS((Exception))
+{
+ OSaxParserTest *p = new OSaxParserTest( rSMgr );
+ XInterfaceRef xService = *p;
+ return xService;
+}
+
+
+UString OSaxParserTest_getServiceName( ) THROWS( () )
+{
+ return L"test.com.sun.star.xml.sax.Parser";
+}
+
+UString OSaxParserTest_getImplementationName( ) THROWS( () )
+{
+ return L"test.extensions.xml.sax.Parser";
+}
+
+Sequence<UString> OSaxParserTest_getSupportedServiceNames( ) THROWS( () )
+{
+ Sequence<UString> aRet(1);
+
+ aRet.getArray()[0] = OSaxParserTest_getImplementationName( );
+
+ return aRet;
+}
+
+
+BOOL OSaxParserTest::queryInterface( Uik uik , XInterfaceRef &rOut )
+{
+ if( XSimpleTest::getSmartUik() == uik ) {
+ rOut = (XSimpleTest *) this;
+ }
+ else {
+ return OWeakObject::queryInterface( uik , rOut );
+ }
+ return TRUE;
+}
+
+
+void OSaxParserTest::testInvariant( const UString& TestName, const XInterfaceRef& TestObject )
+ THROWS( ( IllegalArgumentException,
+ UsrSystemException) )
+{
+ if( L"com.sun.star.xml.sax.Parser" == TestName ) {
+ XParserRef parser( TestObject , USR_QUERY );
+
+ ERROR_ASSERT( parser.is() , "XDataInputStream cannot be queried" );
+ }
+}
+
+
+INT32 OSaxParserTest::test( const UString& TestName,
+ const XInterfaceRef& TestObject,
+ INT32 hTestHandle) THROWS( ( IllegalArgumentException,
+ UsrSystemException) )
+{
+ if( L"com.sun.star.xml.sax.Parser" == TestName ) {
+ try {
+ if( 0 == hTestHandle ) {
+ testInvariant( TestName , TestObject );
+ }
+ else {
+
+ XParserRef parser( TestObject , USR_QUERY );
+
+ if( 1 == hTestHandle ) {
+ testSimple( parser );
+ }
+ else if( 2 == hTestHandle ) {
+ testNamespaces( parser );
+ }
+ else if( 3 == hTestHandle ) {
+ testEncoding( parser );
+ }
+ else if( 4 == hTestHandle ) {
+ testFile( parser );
+ }
+ else if( 5 == hTestHandle ) {
+ testPerformance( parser );
+ }
+ }
+ }
+ catch( Exception& e ) {
+ BUILD_ERROR( 0 , UStringToString( e.getName() , CHARSET_SYSTEM ).GetCharStr() );
+ }
+ catch(...) {
+ BUILD_ERROR( 0 , "unknown exception (Exception is not base class)" );
+ }
+
+ hTestHandle ++;
+
+ if( hTestHandle >= 6) {
+ // all tests finished.
+ hTestHandle = -1;
+ }
+ }
+ else {
+ BUILD_ERROR( 0 , "service not supported by test." );
+ }
+ return hTestHandle;
+}
+
+
+
+BOOL OSaxParserTest::testPassed(void) THROWS( (UsrSystemException) )
+{
+ return m_seqErrors.getLen() == 0;
+}
+
+
+Sequence< UString > OSaxParserTest::getErrors(void) THROWS( (UsrSystemException) )
+{
+ return m_seqErrors;
+}
+
+
+Sequence< UsrAny > OSaxParserTest::getErrorExceptions(void) THROWS( (UsrSystemException) )
+{
+ return m_seqExceptions;
+}
+
+
+Sequence< UString > OSaxParserTest::getWarnings(void) THROWS( (UsrSystemException) )
+{
+ return m_seqWarnings;
+}
+
+XInputStreamRef createStreamFromSequence( const Sequence<BYTE> seqBytes , XMultiServiceFactoryRef &xSMgr )
+{
+ XInterfaceRef xOutStreamService = xSMgr->createInstance( L"com.sun.star.io.Pipe" );
+ OSL_ASSERT( xOutStreamService.is() );
+ XOutputStreamRef rOutStream( xOutStreamService , USR_QUERY );
+ OSL_ASSERT( rOutStream.is() );
+
+ XInputStreamRef rInStream( xOutStreamService , USR_QUERY );
+ OSL_ASSERT( rInStream.is() );
+
+ rOutStream->writeBytes( seqBytes );
+ rOutStream->flush();
+ rOutStream->closeOutput();
+
+ return rInStream;
+}
+
+XInputStreamRef createStreamFromFile( const char *pcFile , XMultiServiceFactoryRef &xSMgr )
+{
+ FILE *f = fopen( pcFile , "rb" );
+ XInputStreamRef r;
+
+ if( f ) {
+ fseek( f , 0 , SEEK_END );
+ int nLength = ftell( f );
+ fseek( f , 0 , SEEK_SET );
+
+ Sequence<BYTE> seqIn(nLength);
+ fread( seqIn.getArray() , nLength , 1 , f );
+
+ r = createStreamFromSequence( seqIn , xSMgr );
+ fclose( f );
+ }
+ return r;
+}
+
+
+
+
+
+
+
+
+
+#define PCHAR_TO_USTRING(x) StringToUString(String(x),CHARSET_PC_1252)
+#define USTRING_TO_PCHAR(x) UStringToString(x,CHARSET_PC_437).GetStr()
+
+
+
+class TestDocumentHandler :
+ public XExtendedDocumentHandler,
+ public XEntityResolver,
+ public XErrorHandler,
+ public OWeakObject
+{
+public:
+ TestDocumentHandler( XMultiServiceFactoryRef &r , BOOL bPrint )
+ {
+ m_xSMgr = r;
+ m_bPrint = bPrint;
+ }
+
+
+public:
+ BOOL queryInterface( Uik aUik, XInterfaceRef & rOut );
+ void acquire() { OWeakObject::acquire(); }
+ void release() { OWeakObject::release(); }
+ void* getImplementation(Reflection *p) { return OWeakObject::getImplementation(p); }
+
+
+public: // Error handler
+ virtual void error(const UsrAny& aSAXParseException) THROWS( (SAXException, UsrSystemException) )
+ {
+ printf( "Error !\n" );
+ THROW( SAXException( L"error from error handler" , XInterfaceRef() , aSAXParseException ) );
+ }
+ virtual void fatalError(const UsrAny& aSAXParseException) THROWS( (SAXException, UsrSystemException) )
+ {
+ printf( "Fatal Error !\n" );
+ }
+ virtual void warning(const UsrAny& aSAXParseException) THROWS( (SAXException, UsrSystemException) )
+ {
+ printf( "Warning !\n" );
+ }
+
+
+public: // ExtendedDocumentHandler
+
+ virtual void startDocument(void) THROWS( (SAXException, UsrSystemException) )
+ {
+ m_iLevel = 0;
+ m_iElementCount = 0;
+ m_iAttributeCount = 0;
+ m_iWhitespaceCount =0;
+ m_iCharCount=0;
+ if( m_bPrint ) {
+ printf( "document started\n" );
+ }
+ }
+ virtual void endDocument(void) THROWS( (SAXException, UsrSystemException) )
+ {
+ if( m_bPrint ) {
+ printf( "document finished\n" );
+ printf( "(ElementCount %d),(AttributeCount %d),(WhitespaceCount %d),(CharCount %d)\n",
+ m_iElementCount, m_iAttributeCount, m_iWhitespaceCount , m_iCharCount );
+ }
+ }
+ virtual void startElement(const UString& aName, const XAttributeListRef& xAttribs)
+ THROWS( (SAXException,UsrSystemException) )
+ {
+
+ if( m_rLocator.is() ) {
+ if( m_bPrint )
+ printf( "%s(%d):" , USTRING_TO_PCHAR( m_rLocator->getSystemId() ) ,
+ m_rLocator->getLineNumber() );
+ }
+ if( m_bPrint ) {
+ int i;
+ for( i = 0; i < m_iLevel ; i ++ ) {
+ printf( " " );
+ }
+ printf( "<%s> " , USTRING_TO_PCHAR( aName ) );
+
+ for( i = 0 ; i < xAttribs->getLength() ; i ++ ) {
+ printf( "(%s,%s,'%s')" , USTRING_TO_PCHAR( xAttribs->getNameByIndex( i ) ) ,
+ USTRING_TO_PCHAR( xAttribs->getTypeByIndex( i ) ) ,
+ USTRING_TO_PCHAR( xAttribs->getValueByIndex( i ) ) );
+ }
+ printf( "\n" );
+ }
+ m_iLevel ++;
+ m_iElementCount ++;
+ m_iAttributeCount += xAttribs->getLength();
+ }
+ virtual void endElement(const UString& aName) THROWS( (SAXException,UsrSystemException) )
+ {
+ OSL_ASSERT( m_iLevel );
+ m_iLevel --;
+ if( m_bPrint ) {
+ int i;
+ for( i = 0; i < m_iLevel ; i ++ ) {
+ printf( " " );
+ }
+ printf( "</%s>\n" , USTRING_TO_PCHAR( aName ) );
+ }
+ }
+
+ virtual void characters(const UString& aChars) THROWS( (SAXException,UsrSystemException) )
+ {
+ if( m_bPrint ) {
+ int i;
+ for( i = 0; i < m_iLevel ; i ++ ) {
+ printf( " " );
+ }
+ printf( "%s\n" , USTRING_TO_PCHAR( aChars ) );
+ }
+ m_iCharCount += aChars.len();
+ }
+ virtual void ignorableWhitespace(const UString& aWhitespaces) THROWS( (SAXException,UsrSystemException) )
+ {
+ m_iWhitespaceCount += aWhitespaces.len();
+ }
+
+ virtual void processingInstruction(const UString& aTarget, const UString& aData) THROWS( (SAXException,UsrSystemException) )
+ {
+ if( m_bPrint )
+ printf( "PI : %s,%s\n" , USTRING_TO_PCHAR( aTarget ) , USTRING_TO_PCHAR( aData ) );
+ }
+
+ virtual void setDocumentLocator(const XLocatorRef& xLocator) THROWS( (SAXException,UsrSystemException) )
+ {
+ m_rLocator = xLocator;
+ }
+
+ virtual InputSource resolveEntity(const UString& sPublicId, const UString& sSystemId)
+ THROWS( (SAXException,UsrSystemException) )
+ {
+ InputSource source;
+ source.sSystemId = sSystemId;
+ source.sPublicId = sPublicId;
+ source.aInputStream = createStreamFromFile( USTRING_TO_PCHAR( sSystemId ) , m_xSMgr );
+
+ return source;
+ }
+
+ virtual void startCDATA(void) THROWS( (SAXException,UsrSystemException) )
+ {
+ if( m_bPrint ) {
+ printf( "CDataStart :\n" );
+ }
+ }
+ virtual void endCDATA(void) THROWS( (SAXException,UsrSystemException) )
+ {
+ if( m_bPrint ) {
+ printf( "CEndStart :\n" );
+ }
+ }
+ virtual void comment(const UString& sComment) THROWS( (SAXException,UsrSystemException) )
+ {
+ if( m_bPrint ) {
+ printf( "<!--%s-->\n" , USTRING_TO_PCHAR( sComment ) );
+ }
+ }
+ virtual void unknown(const UString& sString) THROWS( (SAXException,UsrSystemException) )
+ {
+ if( m_bPrint ) {
+ printf( "UNKNOWN : {%s}\n" , USTRING_TO_PCHAR( sString ) );
+ }
+ }
+
+ virtual void allowLineBreak( void) THROWS( (SAXException, UsrSystemException ) )
+ {
+
+ }
+
+
+public:
+ int m_iLevel;
+ int m_iElementCount;
+ int m_iAttributeCount;
+ int m_iWhitespaceCount;
+ int m_iCharCount;
+ BOOL m_bPrint;
+
+ XMultiServiceFactoryRef m_xSMgr;
+ XLocatorRef m_rLocator;
+};
+
+BOOL TestDocumentHandler::queryInterface( Uik aUik , XInterfaceRef & rOut )
+{
+ if( aUik == XDocumentHandler::getSmartUik() ) {
+ rOut = (XDocumentHandler * )this;
+ }
+ else if ( aUik == XExtendedDocumentHandler::getSmartUik() ) {
+ rOut = (XExtendedDocumentHandler *) this;
+ }
+ else if ( aUik == XEntityResolver::getSmartUik() ) {
+ rOut = (XEntityResolver *) this;
+ }
+ else if ( aUik == XErrorHandler::getSmartUik() ) {
+ rOut = (XErrorHandler * ) this;
+ }
+ else {
+ return OWeakObject::queryInterface( aUik , rOut );
+ }
+ return TRUE;
+}
+
+
+
+
+void OSaxParserTest::testSimple( const XParserRef &rParser )
+{
+
+ char TestString[] =
+ "<!DOCTYPE personnel [\n"
+ "<!ENTITY testInternal \"internal Test!\">\n"
+ "<!ENTITY test SYSTEM \"external_entity.xml\">\n"
+ "]>\n"
+
+ "<personnel>\n"
+ "<person> fjklsfdklsdfkl\n"
+ "fjklsfdklsdfkl\n"
+ "<?testpi pidata?>\n"
+ "&testInternal;\n"
+ "<HUHU x='5' y='kjfd'> blahuhu\n"
+ "<HI> blahi\n"
+ " <![CDATA[<greeting>Hello, '+1+12world!</greeting>]]>\n"
+ " <!-- huhu <jdk> -->\n"
+ "<?testpi pidata?>\n"
+ "</HI>\n"
+ "aus XMLTest\n"
+ "</HUHU>\n"
+ "</person>\n"
+ "</personnel>\n\n\n";
+
+ Sequence<BYTE> seqBytes( strlen( TestString ) );
+ memcpy( seqBytes.getArray() , TestString , strlen( TestString ) );
+
+
+ XInputStreamRef rInStream;
+ UString sInput;
+ rInStream = createStreamFromSequence( seqBytes , m_rFactory );
+ sInput = UString( L"internal" );
+
+ if( rParser.is() ) {
+ InputSource source;
+
+ source.aInputStream = rInStream;
+ source.sSystemId = sInput;
+
+ TestDocumentHandler *pDocHandler = new TestDocumentHandler( m_rFactory , FALSE );
+ XDocumentHandlerRef rDocHandler( (XDocumentHandler *) pDocHandler , USR_QUERY );
+ XEntityResolverRef rEntityResolver( (XEntityResolver *) pDocHandler , USR_QUERY );
+
+ rParser->setDocumentHandler( rDocHandler );
+ rParser->setEntityResolver( rEntityResolver );
+
+ try {
+ rParser->parseStream( source );
+ ERROR_ASSERT( pDocHandler->m_iElementCount == 4 , "wrong element count" );
+ ERROR_ASSERT( pDocHandler->m_iAttributeCount == 2 , "wrong attribut count" );
+ ERROR_ASSERT( pDocHandler->m_iCharCount == 130 , "wrong char count" );
+ ERROR_ASSERT( pDocHandler->m_iWhitespaceCount == 0, "wrong whitespace count" );
+ }
+ catch( SAXParseException& e ) {
+ BUILD_ERROR( 1 , USTRING_TO_PCHAR( e.Message ) );
+ }
+ catch( SAXException& e ) {
+ BUILD_ERROR( 1 , USTRING_TO_PCHAR( e.Message ) );
+
+ }
+ catch( Exception& e ) {
+ BUILD_ERROR( 1 , USTRING_TO_PCHAR( e.Message ) );
+ }
+ catch(...) {
+ BUILD_ERROR( 1 , "unknown exception" );
+ }
+
+ }
+
+
+}
+
+void OSaxParserTest::testNamespaces( const XParserRef &rParser )
+{
+
+ char TestString[] =
+ "<?xml version='1.0'?>\n"
+ "<!-- all elements here are explicitly in the HTML namespace -->\n"
+ "<html:html xmlns:html='http://www.w3.org/TR/REC-html40'>\n"
+ "<html:head><html:title>Frobnostication</html:title></html:head>\n"
+ "<html:body><html:p>Moved to \n"
+ "<html:a href='http://frob.com'>here.</html:a></html:p></html:body>\n"
+ "</html:html>\n";
+
+ Sequence<BYTE> seqBytes( strlen( TestString ) );
+ memcpy( seqBytes.getArray() , TestString , strlen( TestString ) );
+
+
+ XInputStreamRef rInStream;
+ UString sInput;
+
+ rInStream = createStreamFromSequence( seqBytes , m_rFactory );
+ sInput = UString( L"internal" );
+
+ if( rParser.is() ) {
+ InputSource source;
+
+ source.aInputStream = rInStream;
+ source.sSystemId = sInput;
+
+ TestDocumentHandler *pDocHandler = new TestDocumentHandler( m_rFactory , FALSE );
+ XDocumentHandlerRef rDocHandler( (XDocumentHandler *) pDocHandler , USR_QUERY );
+ XEntityResolverRef rEntityResolver( (XEntityResolver *) pDocHandler , USR_QUERY );
+
+ rParser->setDocumentHandler( rDocHandler );
+ rParser->setEntityResolver( rEntityResolver );
+
+ try {
+ rParser->parseStream( source );
+ ERROR_ASSERT( pDocHandler->m_iElementCount == 6 , "wrong element count" );
+ ERROR_ASSERT( pDocHandler->m_iAttributeCount == 2 , "wrong attribut count" );
+ ERROR_ASSERT( pDocHandler->m_iCharCount == 33, "wrong char count" );
+ ERROR_ASSERT( pDocHandler->m_iWhitespaceCount == 0 , "wrong whitespace count" );
+ }
+ catch( SAXParseException& e ) {
+ BUILD_ERROR( 1 , USTRING_TO_PCHAR( e.Message ) );
+ }
+ catch( SAXException& e ) {
+ BUILD_ERROR( 1 , USTRING_TO_PCHAR( e.Message ) );
+
+ }
+ catch( Exception& e ) {
+ BUILD_ERROR( 1 , USTRING_TO_PCHAR( e.Message ) );
+ }
+ catch(...) {
+ BUILD_ERROR( 1 , "unknown exception" );
+ }
+ }
+}
+
+void OSaxParserTest::testEncoding( const XParserRef &rParser )
+{
+ char TestString[] =
+ "<?xml version='1.0' encoding=\"iso-8859-1\"?>\n"
+ "<!-- all elements here are explicitly in the HTML namespace -->\n"
+ "<html:html xmlns:html='http://www.w3.org/TR/REC-html40'>\n"
+ "<html:head><html:title>Frobnostication</html:title></html:head>\n"
+ "<html:body><html:p>Moved to ß\n"
+ "<html:a href='http://frob.com'>here.</html:a></html:p></html:body>\n"
+ "</html:html>\n";
+
+ Sequence<BYTE> seqBytes( strlen( TestString ) );
+ memcpy( seqBytes.getArray() , TestString , strlen( TestString ) );
+
+
+ XInputStreamRef rInStream;
+ UString sInput;
+
+ rInStream = createStreamFromSequence( seqBytes , m_rFactory );
+ sInput = UString( L"internal" );
+
+ if( rParser.is() ) {
+ InputSource source;
+
+ source.aInputStream = rInStream;
+ source.sSystemId = sInput;
+
+ TestDocumentHandler *pDocHandler = new TestDocumentHandler( m_rFactory , FALSE );
+ XDocumentHandlerRef rDocHandler( (XDocumentHandler *) pDocHandler , USR_QUERY );
+ XEntityResolverRef rEntityResolver( (XEntityResolver *) pDocHandler , USR_QUERY );
+
+ rParser->setDocumentHandler( rDocHandler );
+ rParser->setEntityResolver( rEntityResolver );
+ try {
+ rParser->parseStream( source );
+ }
+ catch( SAXParseException& e ) {
+ BUILD_ERROR( 1 , USTRING_TO_PCHAR( e.Message ) );
+ }
+ catch( SAXException& e ) {
+ BUILD_ERROR( 1 , USTRING_TO_PCHAR( e.Message ) );
+
+ }
+ catch( Exception& e ) {
+ BUILD_ERROR( 1 , USTRING_TO_PCHAR( e.Message ) );
+ }
+ catch(...) {
+ BUILD_ERROR( 1 , "unknown exception" );
+ }
+
+ }
+
+}
+
+void OSaxParserTest::testFile( const XParserRef & rParser )
+{
+
+ XInputStreamRef rInStream = createStreamFromFile( "testsax.xml" , m_rFactory );
+ UString sInput = UString( PCHAR_TO_USTRING( "testsax.xml" ) );
+
+
+ if( rParser.is() && rInStream.is() ) {
+ InputSource source;
+
+ source.aInputStream = rInStream;
+ source.sSystemId = sInput;
+
+ TestDocumentHandler *pDocHandler = new TestDocumentHandler( m_rFactory , TRUE );
+ XDocumentHandlerRef rDocHandler( (XDocumentHandler *) pDocHandler , USR_QUERY );
+ XEntityResolverRef rEntityResolver( (XEntityResolver *) pDocHandler , USR_QUERY );
+ XErrorHandlerRef rErrorHandler( ( XErrorHandler * )pDocHandler , USR_QUERY );
+
+ rParser->setDocumentHandler( rDocHandler );
+ rParser->setEntityResolver( rEntityResolver );
+ rParser->setErrorHandler( rErrorHandler );
+
+ try {
+ rParser->parseStream( source );
+ }
+ catch( SAXParseException& e ) {
+ UsrAny any;
+ any.set( &e , SAXParseException_getReflection() );
+ while(TRUE) {
+ SAXParseException *pEx;
+ if( any.getReflection() == SAXParseException_getReflection() ) {
+ pEx = ( SAXParseException * ) any.get();
+ printf( "%s\n" , UStringToString( pEx->Message , CHARSET_SYSTEM ).GetStr() );
+ any = pEx->WrappedException;
+ }
+ else {
+ break;
+ }
+ }
+ }
+ catch( SAXException& e ) {
+ printf( "%s\n" , UStringToString( e.Message , CHARSET_SYSTEM ).GetStr() );
+
+ }
+ catch( Exception& e ) {
+ printf( "normal exception ! %s\n", e.getName() );
+ }
+ catch(...) {
+ printf( "any exception !!!!\n" );
+ }
+ }
+}
+
+void OSaxParserTest::testPerformance( const XParserRef & rParser )
+{
+
+ XInputStreamRef rInStream = createStreamFromFile( "testPerformance.xml" , m_rFactory );
+ UString sInput = UString( PCHAR_TO_USTRING( "testperformance.xml" ) );
+
+ if( rParser.is() && rInStream.is() ) {
+ InputSource source;
+
+ source.aInputStream = rInStream;
+ source.sSystemId = sInput;
+
+ TestDocumentHandler *pDocHandler = new TestDocumentHandler( m_rFactory , FALSE );
+ XDocumentHandlerRef rDocHandler( (XDocumentHandler *) pDocHandler , USR_QUERY );
+ XEntityResolverRef rEntityResolver( (XEntityResolver *) pDocHandler , USR_QUERY );
+ XErrorHandlerRef rErrorHandler( ( XErrorHandler * )pDocHandler , USR_QUERY );
+
+ rParser->setDocumentHandler( rDocHandler );
+ rParser->setEntityResolver( rEntityResolver );
+ rParser->setErrorHandler( rErrorHandler );
+
+ try {
+ TimeValue aStartTime, aEndTime;
+ osl_getSystemTime( &aStartTime );
+ rParser->parseStream( source );
+ osl_getSystemTime( &aEndTime );
+
+ double fStart = (double)aStartTime.Seconds + ((double)aStartTime.Nanosec / 1000000000.0);
+ double fEnd = (double)aEndTime.Seconds + ((double)aEndTime.Nanosec / 1000000000.0);
+
+ printf( "Performance reading : %g s\n" , fEnd - fStart );
+
+ }
+ catch( SAXParseException& e ) {
+ UsrAny any;
+ any.set( &e , SAXParseException_getReflection() );
+ while(TRUE) {
+ SAXParseException *pEx;
+ if( any.getReflection() == SAXParseException_getReflection() ) {
+ pEx = ( SAXParseException * ) any.get();
+ printf( "%s\n" , UStringToString( pEx->Message , CHARSET_SYSTEM ).GetStr() );
+ any = pEx->WrappedException;
+ }
+ else {
+ break;
+ }
+ }
+ }
+ catch( SAXException& e ) {
+ printf( "%s\n" , UStringToString( e.Message , CHARSET_SYSTEM ).GetStr() );
+
+ }
+ catch( Exception& e ) {
+ printf( "normal exception ! %s\n", e.getName() );
+ }
+ catch(...) {
+ printf( "any exception !!!!\n" );
+ }
+ }
+
+}
+
+
+extern "C"
+{
+BOOL EXTERN_SERVICE_CALLTYPE exService_writeRegEntry(
+ const UNO_INTERFACE(XRegistryKey)* xUnoKey)
+
+{
+ XRegistryKeyRef xKey;
+ uno2smart(xKey, *xUnoKey);
+
+ UString str = UString( L"/" ) + OSaxParserTest_getImplementationName() + UString( L"/UNO/SERVICES" );
+ XRegistryKeyRef xNewKey = xKey->createKey( str );
+ xNewKey->createKey( OSaxParserTest_getServiceName() );
+
+ str = UString( L"/" ) + OSaxWriterTest_getImplementationName() + UString( L"/UNO/SERVICES" );
+ xNewKey = xKey->createKey( str );
+ xNewKey->createKey( OSaxWriterTest_getServiceName() );
+
+ return TRUE;
+}
+
+
+UNO_INTERFACE(XInterface) EXTERN_SERVICE_CALLTYPE exService_getFactory
+(
+ const wchar_t* implementationName,
+ const UNO_INTERFACE(XMultiServiceFactory)* xUnoFact,
+ const UNO_INTERFACE(XRegistryKey)*
+)
+{
+ UNO_INTERFACE(XInterface) xUnoRet = {0, 0};
+
+ XInterfaceRef xRet;
+ XMultiServiceFactoryRef xSMgr;
+ UString aImplementationName(implementationName);
+
+ uno2smart(xSMgr, *xUnoFact);
+
+ if (aImplementationName == OSaxWriterTest_getImplementationName() )
+ {
+ xRet = createSingleFactory( xSMgr, implementationName,
+ OSaxWriterTest_CreateInstance,
+ OSaxWriterTest_getSupportedServiceNames() );
+ }
+ else if (aImplementationName == OSaxParserTest_getImplementationName() )
+ {
+ xRet = createSingleFactory( xSMgr, implementationName,
+ OSaxParserTest_CreateInstance,
+ OSaxParserTest_getSupportedServiceNames() );
+ }
+ if (xRet.is())
+ {
+ smart2uno(xRet, xUnoRet);
+ }
+
+ return xUnoRet;
+}
+
+}
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/test/sax/testwriter.cxx b/extensions/test/sax/testwriter.cxx
new file mode 100644
index 000000000000..f4930dfec5fa
--- /dev/null
+++ b/extensions/test/sax/testwriter.cxx
@@ -0,0 +1,772 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+
+#include <vector>
+#include <smart/com/sun/star/test/XSimpleTest.hxx>
+#include <smart/com/sun/star/lang/XMultiServiceFactory.hxx> // for the multiservice-factories
+
+#include <stdio.h>
+
+#include <smart/com/sun/star/io/XActiveDataSource.hxx>
+#include <smart/com/sun/star/io/XOutputStream.hxx>
+#include <smart/com/sun/star/xml/sax/SAXParseException.hxx>
+#include <smart/com/sun/star/xml/sax/XParser.hxx>
+#include <smart/com/sun/star/xml/sax/XExtendedDocumentHandler.hxx>
+
+#include <rtl/wstring.hxx>
+#include <osl/time.h>
+#include <usr/weak.hxx>
+#include <tools/string.hxx>
+
+#include <usr/factoryhlp.hxx>
+
+#include <usr/reflserv.hxx> // for EXTERN_SERVICE_CALLTYPE
+
+using namespace std;
+using namespace rtl;
+using namespace usr;
+
+#define BUILD_ERROR(expr, Message)\
+ {\
+ m_seqErrors.realloc( m_seqErrors.getLen() + 1 ); \
+ m_seqExceptions.realloc( m_seqExceptions.getLen() + 1 ); \
+ String str; \
+ str += __FILE__;\
+ str += " "; \
+ str += "(" ; \
+ str += __LINE__ ;\
+ str += ")\n";\
+ str += "[ " ; \
+ str += #expr; \
+ str += " ] : " ; \
+ str += Message; \
+ m_seqErrors.getArray()[ m_seqErrors.getLen()-1] = StringToUString( str , CHARSET_SYSTEM ); \
+ }\
+ ((void)0)
+
+
+#define WARNING_ASSERT(expr, Message) \
+ if( ! (expr) ) { \
+ m_seqWarnings.realloc( m_seqErrors.getLen() +1 ); \
+ String str;\
+ str += __FILE__;\
+ str += " "; \
+ str += "(" ; \
+ str += __LINE__ ;\
+ str += ")\n";\
+ str += "[ " ; \
+ str += #expr; \
+ str += " ] : " ; \
+ str += Message; \
+ m_seqWarnings.getArray()[ m_seqWarnings.getLen()-1] = StringToUString( str , CHARSET_SYSTEM ); \
+ return; \
+ }\
+ ((void)0)
+
+#define ERROR_ASSERT(expr, Message) \
+ if( ! (expr) ) { \
+ BUILD_ERROR(expr, Message );\
+ return; \
+ }\
+ ((void)0)
+
+#define ERROR_EXCEPTION_ASSERT(expr, Message, Exception) \
+ if( !(expr)) { \
+ BUILD_ERROR(expr,Message);\
+ m_seqExceptions.getArray()[ m_seqExceptions.getLen()-1] = UsrAny( Exception );\
+ return; \
+ } \
+ ((void)0)
+
+/****
+* test szenarios :
+*
+*
+*
+****/
+
+
+class OFileWriter :
+ public XOutputStream,
+ public OWeakObject
+{
+public:
+ OFileWriter( char *pcFile ) { strcpy( m_pcFile , pcFile ); m_f = 0; }
+
+
+public: // refcounting
+ BOOL queryInterface( Uik aUik, XInterfaceRef & rOut )
+ {
+ if( XOutputStream::getSmartUik() == aUik ) {
+ rOut = (XOutputStream *) this;
+ }
+ else return OWeakObject::queryInterface( aUik , rOut );
+
+ return TRUE;
+ }
+ void acquire() { OWeakObject::acquire(); }
+ void release() { OWeakObject::release(); }
+ void* getImplementation(Reflection *p) { return OWeakObject::getImplementation(p); }
+
+public:
+ virtual void writeBytes(const Sequence< BYTE >& aData)
+ THROWS( (NotConnectedException, BufferSizeExceededException, UsrSystemException) );
+ virtual void flush(void)
+ THROWS( (NotConnectedException, BufferSizeExceededException, UsrSystemException) );
+ virtual void closeOutput(void)
+ THROWS( (NotConnectedException, BufferSizeExceededException, UsrSystemException) );
+
+
+private:
+ char m_pcFile[256];
+ FILE *m_f;
+};
+
+
+void OFileWriter::writeBytes(const Sequence< BYTE >& aData)
+ THROWS( (NotConnectedException, BufferSizeExceededException, UsrSystemException) )
+{
+ if( ! m_f ) {
+ m_f = fopen( m_pcFile , "w" );
+ }
+
+ fwrite( aData.getConstArray() , 1 , aData.getLen() , m_f );
+
+}
+
+
+void OFileWriter::flush(void)
+ THROWS( (NotConnectedException, BufferSizeExceededException, UsrSystemException) )
+{
+ fflush( m_f );
+}
+
+void OFileWriter::closeOutput(void)
+ THROWS( (NotConnectedException, BufferSizeExceededException, UsrSystemException) )
+{
+ fclose( m_f );
+ m_f = 0;
+}
+
+
+class OSaxWriterTest :
+ public XSimpleTest,
+ public OWeakObject
+{
+public:
+ OSaxWriterTest( const XMultiServiceFactoryRef & rFactory ) : m_rFactory( rFactory )
+ {
+
+ }
+ ~OSaxWriterTest() {}
+
+public: // refcounting
+ BOOL queryInterface( Uik aUik, XInterfaceRef & rOut );
+ void acquire() { OWeakObject::acquire(); }
+ void release() { OWeakObject::release(); }
+ void* getImplementation(Reflection *p) { return OWeakObject::getImplementation(p); }
+
+public:
+ virtual void testInvariant(const UString& TestName, const XInterfaceRef& TestObject)
+ THROWS( ( IllegalArgumentException,
+ UsrSystemException) );
+
+ virtual INT32 test( const UString& TestName,
+ const XInterfaceRef& TestObject,
+ INT32 hTestHandle) THROWS( ( IllegalArgumentException,
+ UsrSystemException) );
+
+ virtual BOOL testPassed(void) THROWS( ( UsrSystemException) );
+ virtual Sequence< UString > getErrors(void) THROWS( (UsrSystemException) );
+ virtual Sequence< UsrAny > getErrorExceptions(void) THROWS( (UsrSystemException) );
+ virtual Sequence< UString > getWarnings(void) THROWS( (UsrSystemException) );
+
+private:
+ void testSimple( const XExtendedDocumentHandlerRef &r );
+ void testExceptions( const XExtendedDocumentHandlerRef &r );
+ void testDTD( const XExtendedDocumentHandlerRef &r );
+ void testPerformance( const XExtendedDocumentHandlerRef &r );
+ void writeParagraph( const XExtendedDocumentHandlerRef &r , const UString & s);
+
+private:
+ Sequence<UsrAny> m_seqExceptions;
+ Sequence<UString> m_seqErrors;
+ Sequence<UString> m_seqWarnings;
+ XMultiServiceFactoryRef m_rFactory;
+
+};
+
+
+
+/*----------------------------------------
+*
+* Attributlist implementation
+*
+*----------------------------------------*/
+struct AttributeListImpl_impl;
+class AttributeListImpl :
+ public XAttributeList,
+ public OWeakObject
+{
+public:
+ AttributeListImpl();
+ AttributeListImpl( const AttributeListImpl & );
+ ~AttributeListImpl();
+
+public:
+ BOOL queryInterface( Uik aUik, XInterfaceRef & rOut );
+ void acquire() { OWeakObject::acquire(); }
+ void release() { OWeakObject::release(); }
+ void* getImplementation(Reflection *p) { return OWeakObject::getImplementation(p); }
+
+public:
+ virtual INT16 getLength(void) THROWS( (UsrSystemException) );
+ virtual UString getNameByIndex(INT16 i) THROWS( (UsrSystemException) );
+ virtual UString getTypeByIndex(INT16 i) THROWS( (UsrSystemException) );
+ virtual UString getTypeByName(const UString& aName) THROWS( (UsrSystemException) );
+ virtual UString getValueByIndex(INT16 i) THROWS( (UsrSystemException) );
+ virtual UString getValueByName(const UString& aName) THROWS( (UsrSystemException) );
+
+public:
+ void addAttribute( const UString &sName , const UString &sType , const UString &sValue );
+ void clear();
+
+private:
+ struct AttributeListImpl_impl *m_pImpl;
+};
+
+
+struct TagAttribute
+{
+ TagAttribute(){}
+ TagAttribute( const UString &sName, const UString &sType , const UString &sValue )
+ {
+ this->sName = sName;
+ this->sType = sType;
+ this->sValue = sValue;
+ }
+
+ UString sName;
+ UString sType;
+ UString sValue;
+};
+
+struct AttributeListImpl_impl
+{
+ AttributeListImpl_impl()
+ {
+ // performance improvement during adding
+ vecAttribute.reserve(20);
+ }
+ vector<struct TagAttribute> vecAttribute;
+};
+
+
+
+INT16 AttributeListImpl::getLength(void) THROWS( (UsrSystemException) )
+{
+ return m_pImpl->vecAttribute.size();
+}
+
+
+AttributeListImpl::AttributeListImpl( const AttributeListImpl &r )
+{
+ m_pImpl = new AttributeListImpl_impl;
+ *m_pImpl = *(r.m_pImpl);
+}
+
+UString AttributeListImpl::getNameByIndex(INT16 i) THROWS( (UsrSystemException) )
+{
+ if( i < m_pImpl->vecAttribute.size() ) {
+ return m_pImpl->vecAttribute[i].sName;
+ }
+ return UString();
+}
+
+
+UString AttributeListImpl::getTypeByIndex(INT16 i) THROWS( (UsrSystemException) )
+{
+ if( i < m_pImpl->vecAttribute.size() ) {
+ return m_pImpl->vecAttribute[i].sType;
+ }
+ return UString();
+}
+
+UString AttributeListImpl::getValueByIndex(INT16 i) THROWS( (UsrSystemException) )
+{
+ if( i < m_pImpl->vecAttribute.size() ) {
+ return m_pImpl->vecAttribute[i].sValue;
+ }
+ return UString();
+
+}
+
+UString AttributeListImpl::getTypeByName( const UString& sName ) THROWS( (UsrSystemException) )
+{
+ vector<struct TagAttribute>::iterator ii = m_pImpl->vecAttribute.begin();
+
+ for( ; ii != m_pImpl->vecAttribute.end() ; ii ++ ) {
+ if( (*ii).sName == sName ) {
+ return (*ii).sType;
+ }
+ }
+ return UString();
+}
+
+UString AttributeListImpl::getValueByName(const UString& sName) THROWS( (UsrSystemException) )
+{
+ vector<struct TagAttribute>::iterator ii = m_pImpl->vecAttribute.begin();
+
+ for( ; ii != m_pImpl->vecAttribute.end() ; ii ++ ) {
+ if( (*ii).sName == sName ) {
+ return (*ii).sValue;
+ }
+ }
+ return UString();
+}
+
+
+BOOL AttributeListImpl::queryInterface( Uik aUik, XInterfaceRef & rOut )
+{
+ if( aUik == XAttributeList::getSmartUik() ) {
+ rOut = (XAttributeList * )this;
+ }
+ else {
+ return OWeakObject::queryInterface( aUik , rOut );
+ }
+ return TRUE;
+}
+
+
+AttributeListImpl::AttributeListImpl()
+{
+ m_pImpl = new AttributeListImpl_impl;
+}
+
+
+
+AttributeListImpl::~AttributeListImpl()
+{
+ delete m_pImpl;
+}
+
+
+void AttributeListImpl::addAttribute( const UString &sName ,
+ const UString &sType ,
+ const UString &sValue )
+{
+ m_pImpl->vecAttribute.push_back( TagAttribute( sName , sType , sValue ) );
+}
+
+void AttributeListImpl::clear()
+{
+ vector<struct TagAttribute> dummy;
+ m_pImpl->vecAttribute.swap( dummy );
+
+ OSL_ASSERT( ! getLength() );
+}
+
+
+
+
+
+
+
+
+
+
+
+/**
+* for external binding
+*
+*
+**/
+XInterfaceRef OSaxWriterTest_CreateInstance( const XMultiServiceFactoryRef & rSMgr ) THROWS((Exception))
+{
+ OSaxWriterTest *p = new OSaxWriterTest( rSMgr );
+ XInterfaceRef xService = *p;
+ return xService;
+}
+
+UString OSaxWriterTest_getServiceName( ) THROWS( () )
+{
+ return L"test.com.sun.star.xml.sax.Writer";
+}
+
+UString OSaxWriterTest_getImplementationName( ) THROWS( () )
+{
+ return L"test.extensions.xml.sax.Writer";
+}
+
+Sequence<UString> OSaxWriterTest_getSupportedServiceNames( ) THROWS( () )
+{
+ Sequence<UString> aRet(1);
+
+ aRet.getArray()[0] = OSaxWriterTest_getImplementationName( );
+
+ return aRet;
+}
+
+
+BOOL OSaxWriterTest::queryInterface( Uik uik , XInterfaceRef &rOut )
+{
+ if( XSimpleTest::getSmartUik() == uik ) {
+ rOut = (XSimpleTest *) this;
+ }
+ else {
+ return OWeakObject::queryInterface( uik , rOut );
+ }
+ return TRUE;
+}
+
+
+void OSaxWriterTest::testInvariant( const UString& TestName, const XInterfaceRef& TestObject )
+ THROWS( ( IllegalArgumentException,
+ UsrSystemException) )
+{
+ if( L"com.sun.star.xml.sax.Writer" == TestName ) {
+ XDocumentHandlerRef doc( TestObject , USR_QUERY );
+ XExtendedDocumentHandlerRef ext( TestObject , USR_QUERY );
+ XActiveDataSourceRef source( TestObject , USR_QUERY );
+
+ ERROR_ASSERT( doc.is() , "XDocumentHandler cannot be queried" );
+ ERROR_ASSERT( ext.is() , "XExtendedDocumentHandler cannot be queried" );
+ ERROR_ASSERT( source.is() , "XActiveDataSource cannot be queried" );
+ }
+ else {
+ BUILD_ERROR( 0 , "wrong test" );
+ }
+}
+
+
+INT32 OSaxWriterTest::test( const UString& TestName,
+ const XInterfaceRef& TestObject,
+ INT32 hTestHandle) THROWS( ( IllegalArgumentException,
+ UsrSystemException) )
+{
+ if( L"com.sun.star.xml.sax.Writer" == TestName ) {
+ try {
+ if( 0 == hTestHandle ) {
+ testInvariant( TestName , TestObject );
+ }
+ else {
+
+ XExtendedDocumentHandlerRef writer( TestObject , USR_QUERY );
+
+ if( 1 == hTestHandle ) {
+ testSimple( writer );
+ }
+ else if( 2 == hTestHandle ) {
+ testExceptions( writer );
+ }
+ else if( 3 == hTestHandle ) {
+ testDTD( writer );
+ }
+ else if( 4 == hTestHandle ) {
+ testPerformance( writer );
+ }
+ }
+ }
+ catch( Exception& e ) {
+ BUILD_ERROR( 0 , UStringToString( e.getName() , CHARSET_SYSTEM ).GetCharStr() );
+ }
+ catch(...) {
+ BUILD_ERROR( 0 , "unknown exception (Exception is not base class)" );
+ }
+
+ hTestHandle ++;
+
+ if( hTestHandle >= 5) {
+ // all tests finished.
+ hTestHandle = -1;
+ }
+ }
+ else {
+ BUILD_ERROR( 0 , "service not supported by test." );
+ }
+ return hTestHandle;
+}
+
+
+
+BOOL OSaxWriterTest::testPassed(void) THROWS( (UsrSystemException) )
+{
+ return m_seqErrors.getLen() == 0;
+}
+
+
+Sequence< UString > OSaxWriterTest::getErrors(void) THROWS( (UsrSystemException) )
+{
+ return m_seqErrors;
+}
+
+
+Sequence< UsrAny > OSaxWriterTest::getErrorExceptions(void) THROWS( (UsrSystemException) )
+{
+ return m_seqExceptions;
+}
+
+
+Sequence< UString > OSaxWriterTest::getWarnings(void) THROWS( (UsrSystemException) )
+{
+ return m_seqWarnings;
+}
+
+void OSaxWriterTest::writeParagraph( const XExtendedDocumentHandlerRef &r , const UString & s)
+{
+ int nMax = s.len();
+ int nStart = 0;
+
+ Sequence<UINT16> seq( s.len() );
+ memcpy( seq.getArray() , s.getStr() , s.len() * sizeof( UINT16 ) );
+
+ for( int n = 1 ; n < nMax ; n++ ){
+ if( 32 == seq.getArray()[n] ) {
+ r->allowLineBreak();
+ r->characters( s.copy( nStart , n - nStart ) );
+ nStart = n;
+ }
+ }
+ r->allowLineBreak();
+ r->characters( s.copy( nStart , n - nStart ) );
+
+
+}
+
+
+
+void OSaxWriterTest::testSimple( const XExtendedDocumentHandlerRef &r )
+{
+ UString testParagraph = L"Dies ist ein bloeder Test um zu uberpruefen, ob der SAXWriter "
+ L"wohl Zeilenumbrueche halbwegs richtig macht oder ob er die Zeile "
+ L"bis zum bitteren Ende schreibt.";
+
+ OFileWriter *pw = new OFileWriter("output.xml");
+ AttributeListImpl *pList = new AttributeListImpl;
+
+ XAttributeListRef rList( (XAttributeList *) pList , USR_QUERY );
+ XOutputStreamRef ref( ( XOutputStream * ) pw , USR_QUERY );
+
+ XActiveDataSourceRef source( r , USR_QUERY );
+
+ ERROR_ASSERT( ref.is() , "no output stream" );
+ ERROR_ASSERT( source.is() , "no active data source" );
+
+ source->setOutputStream( ref );
+
+ r->startDocument();
+
+ pList->addAttribute( L"Arg1" , L"CDATA" , L"bla\n u" );
+ pList->addAttribute( L"Arg2" , L"CDATA" , L"blub" );
+
+ r->startElement( L"tag1" , rList );
+ r->ignorableWhitespace( L"" );
+
+ r->characters( L"huhu" );
+ r->ignorableWhitespace( L"" );
+
+ r->startElement( L"hi" , rList );
+ r->ignorableWhitespace( L"" );
+
+ // the enpassant must be converted & -> &amp;
+ r->characters( L"&#252;" );
+
+ // Test added for mib. Tests if errors during conversions occurs
+ r->ignorableWhitespace( UString() );
+ sal_Char array[256];
+ for( sal_Int32 n = 32 ; n < 254 ; n ++ ) {
+ array[n-32] = n;
+ }
+ array[254-32] = 0;
+ r->characters(
+ StringToUString( array , RTL_TEXTENCODING_SYMBOL )
+ );
+ r->ignorableWhitespace( UString() );
+
+ // '>' must not be converted
+ r->startCDATA();
+ r->characters( L">fsfsdf<" );
+ r->endCDATA();
+ r->ignorableWhitespace( UString() );
+
+ writeParagraph( r , testParagraph );
+
+
+ r->ignorableWhitespace( UString() );
+ r->comment( L"Dies ist ein Kommentar !" );
+ r->ignorableWhitespace( UString() );
+
+ r->startElement( L"emptytagtest" , rList );
+ r->endElement( L"emptytagtest" );
+
+ r->endElement( L"hi" );
+ r->ignorableWhitespace( L"" );
+
+ r->endElement( L"tag1" );
+ r->endDocument();
+
+}
+
+void OSaxWriterTest::testExceptions( const XExtendedDocumentHandlerRef & r )
+{
+
+ OFileWriter *pw = new OFileWriter("output2.xml");
+ AttributeListImpl *pList = new AttributeListImpl;
+
+ XAttributeListRef rList( (XAttributeList *) pList , USR_QUERY );
+ XOutputStreamRef ref( ( XOutputStream * ) pw , USR_QUERY );
+
+ XActiveDataSourceRef source( r , USR_QUERY );
+
+ ERROR_ASSERT( ref.is() , "no output stream" );
+ ERROR_ASSERT( source.is() , "no active data source" );
+
+ source->setOutputStream( ref );
+
+ { // startDocument must be called before start element
+ BOOL bException = TRUE;
+ try {
+ r->startElement( L"huhu" , rList );
+ bException = FALSE;
+ }
+ catch( SAXException& e ) {
+
+ }
+ ERROR_ASSERT( bException , "expected exception not thrown !" );
+ }
+
+ r->startDocument();
+
+ r->startElement( L"huhu" , rList );
+ r->startCDATA();
+
+ {
+ BOOL bException = TRUE;
+ try {
+ r->startElement( L"huhu" , rList );
+ bException = FALSE;
+ }
+ catch( SAXException& e ) {
+
+ }
+ ERROR_ASSERT( bException , "expected exception not thrown !" );
+ }
+
+ r->endCDATA();
+ r->endElement( L"hi" );
+
+ r->endDocument();
+}
+
+
+void OSaxWriterTest::testDTD(const XExtendedDocumentHandlerRef &r )
+{
+ OFileWriter *pw = new OFileWriter("outputDTD.xml");
+ AttributeListImpl *pList = new AttributeListImpl;
+
+ XAttributeListRef rList( (XAttributeList *) pList , USR_QUERY );
+ XOutputStreamRef ref( ( XOutputStream * ) pw , USR_QUERY );
+
+ XActiveDataSourceRef source( r , USR_QUERY );
+
+ ERROR_ASSERT( ref.is() , "no output stream" );
+ ERROR_ASSERT( source.is() , "no active data source" );
+
+ source->setOutputStream( ref );
+
+
+ r->startDocument();
+ r->unknown( L"<!DOCTYPE iCalendar >\n" );
+ r->startElement( L"huhu" , rList );
+
+ r->endElement( L"huhu" );
+ r->endDocument();
+}
+
+void OSaxWriterTest::testPerformance(const XExtendedDocumentHandlerRef &r )
+{
+ OFileWriter *pw = new OFileWriter("testPerformance.xml");
+ AttributeListImpl *pList = new AttributeListImpl;
+
+ UString testParagraph = L"Dies ist ein bloeder Test um zu uberpruefen, ob der SAXWriter "
+ L"wohl > Zeilenumbrueche halbwegs richtig macht oder ob er die Zeile "
+ L"bis zum bitteren Ende schreibt.";
+
+
+ XAttributeListRef rList( (XAttributeList *) pList , USR_QUERY );
+ XOutputStreamRef ref( ( XOutputStream * ) pw , USR_QUERY );
+
+ XActiveDataSourceRef source( r , USR_QUERY );
+
+ ERROR_ASSERT( ref.is() , "no output stream" );
+ ERROR_ASSERT( source.is() , "no active data source" );
+
+ source->setOutputStream( ref );
+
+ TimeValue aStartTime, aEndTime;
+ osl_getSystemTime( &aStartTime );
+
+
+ r->startDocument();
+ // just write a bunch of xml tags !
+ // for performance testing
+ sal_Int32 i2;
+ for( i2 = 0 ; i2 < 15 ; i2 ++ )
+ {
+ r->startElement( UString( L"tag" ) + UString::valueOf( i2 ), rList );
+ for( sal_Int32 i = 0 ; i < 450 ; i ++ )
+ {
+ r->ignorableWhitespace( L"");
+ r->startElement( L"huhu" , rList );
+ r->characters( testParagraph );
+// writeParagraph( r , testParagraph );
+
+ r->ignorableWhitespace( L"");
+ r->endElement( L"huhu" );
+ }
+ }
+ for( i2 = 14 ; i2 >= 0 ; i2-- )
+ {
+ r->ignorableWhitespace( L"");
+ r->endElement( UString( L"tag" ) + UString::valueOf( i2 ) );
+ }
+
+ r->endDocument();
+
+ osl_getSystemTime( &aEndTime );
+
+ double fStart = (double)aStartTime.Seconds + ((double)aStartTime.Nanosec / 1000000000.0);
+ double fEnd = (double)aEndTime.Seconds + ((double)aEndTime.Nanosec / 1000000000.0);
+
+ printf( "Performance writing : %g s\n" , fEnd - fStart );
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/test/stm/datatest.cxx b/extensions/test/stm/datatest.cxx
new file mode 100644
index 000000000000..7fb7bde49b00
--- /dev/null
+++ b/extensions/test/stm/datatest.cxx
@@ -0,0 +1,1073 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+#include <smart/com/sun/star/test/XSimpleTest.hxx>
+#include <smart/com/sun/star/io/XObjectOutputStream.hxx>
+#include <smart/com/sun/star/io/XObjectInputStream.hxx>
+#include <smart/com/sun/star/io/XActiveDataSink.hxx>
+#include <smart/com/sun/star/io/XActiveDataSource.hxx>
+#include <smart/com/sun/star/io/XConnectable.hxx>
+#include <smart/com/sun/star/io/XMarkableStream.hxx>
+
+#include <smart/com/sun/star/lang/XServiceInfo.hxx>
+
+#include <smart/com/sun/star/beans/XPropertySet.hxx>
+
+#include <usr/services.hxx>
+#include <usr/factoryhlp.hxx>
+
+#include <usr/reflserv.hxx> // for EXTERN_SERVICE_CALLTYPE
+#include <usr/weak.hxx> // OWeakObject
+
+#include <osl/conditn.hxx>
+#include <osl/mutex.hxx>
+#include <osl/thread.hxx>
+
+#include <string.h>
+
+#include "testfactreg.hxx"
+
+#ifndef _VOS_NO_NAMESPACE
+using namespace usr;
+#endif
+
+#define DATASTREAM_TEST_MAX_HANDLE 1
+
+/****
+* The following test class tests XDataInputStream and XDataOutputStream at equal terms,
+* so when errors occur, it may be in either one implementation.
+* The class also uses stardiv.uno.io.pipe. If problems occur, make sure to run also the
+* pipe test routines ( test.com.sun.star.io.pipe ).
+*
+*
+*****/
+
+class ODataStreamTest :
+ public XSimpleTest,
+ public OWeakObject
+{
+public:
+ ODataStreamTest( const XMultiServiceFactoryRef & rFactory ) : m_rFactory( rFactory ){}
+
+public: // refcounting
+ BOOL queryInterface( Uik aUik, XInterfaceRef & rOut );
+ void acquire() { OWeakObject::acquire(); }
+ void release() { OWeakObject::release(); }
+ void* getImplementation(Reflection *p) { return OWeakObject::getImplementation(p); }
+
+public:
+ virtual void testInvariant(const UString& TestName, const XInterfaceRef& TestObject)
+ THROWS( ( IllegalArgumentException,
+ UsrSystemException) );
+
+ virtual INT32 test( const UString& TestName,
+ const XInterfaceRef& TestObject,
+ INT32 hTestHandle) THROWS( ( IllegalArgumentException,
+ UsrSystemException) );
+
+ virtual BOOL testPassed(void) THROWS( ( UsrSystemException) );
+ virtual Sequence< UString > getErrors(void) THROWS( (UsrSystemException) );
+ virtual Sequence< UsrAny > getErrorExceptions(void) THROWS( (UsrSystemException) );
+ virtual Sequence< UString > getWarnings(void) THROWS( (UsrSystemException) );
+
+private:
+ void testSimple( const XDataInputStreamRef & , const XDataOutputStreamRef &);
+
+protected:
+ Sequence<UsrAny> m_seqExceptions;
+ Sequence<UString> m_seqErrors;
+ Sequence<UString> m_seqWarnings;
+
+ XMultiServiceFactoryRef m_rFactory;
+};
+
+
+BOOL ODataStreamTest::queryInterface( Uik uik , XInterfaceRef &rOut )
+{
+ if( XSimpleTest::getSmartUik() == uik ) {
+ rOut = (XSimpleTest *) this;
+ }
+ else {
+ return OWeakObject::queryInterface( uik , rOut );
+ }
+ return TRUE;
+}
+
+
+void ODataStreamTest::testInvariant( const UString& TestName, const XInterfaceRef& TestObject )
+ THROWS( ( IllegalArgumentException,
+ UsrSystemException) )
+{
+ if( L"com.sun.star.io.DataInputStream" == TestName ) {
+ XConnectableRef connect( TestObject , USR_QUERY );
+ XActiveDataSinkRef active( TestObject , USR_QUERY );
+ XInputStreamRef input( TestObject , USR_QUERY );
+ XDataInputStreamRef dataInput( TestObject , USR_QUERY );
+
+ WARNING_ASSERT( connect.is(), "XConnectable cannot be queried" );
+ WARNING_ASSERT( active.is() , "XActiveDataSink cannot be queried" );
+ ERROR_ASSERT( input.is() , "XInputStream cannot be queried" );
+ ERROR_ASSERT( dataInput.is() , "XDataInputStream cannot be queried" );
+
+
+ }
+ else if( L"com.sun.star.io.DataInputStream" == TestName ) {
+ XConnectableRef connect( TestObject , USR_QUERY );
+ XActiveDataSourceRef active( TestObject , USR_QUERY );
+ XOutputStreamRef output( TestObject , USR_QUERY );
+ XDataOutputStreamRef dataOutput( TestObject , USR_QUERY );
+
+ WARNING_ASSERT( connect.is(), "XConnectable cannot be queried" );
+ WARNING_ASSERT( active.is() , "XActiveDataSink cannot be queried" );
+ ERROR_ASSERT( output.is() , "XInputStream cannot be queried" );
+ ERROR_ASSERT( dataOutput.is(), "XDataInputStream cannot be queried" );
+
+ }
+
+ XServiceInfoRef info( TestObject, USR_QUERY );
+ ERROR_ASSERT( info.is() , "XServiceInfo not supported !" );
+ if( info.is() )
+ {
+ ERROR_ASSERT( info->supportsService( TestName ), "XServiceInfo test failed" );
+ ERROR_ASSERT( ! info->supportsService( L"bla bluzb" ) , "XServiceInfo test failed" );
+ }
+
+}
+
+
+INT32 ODataStreamTest::test( const UString& TestName,
+ const XInterfaceRef& TestObject,
+ INT32 hTestHandle) THROWS( ( IllegalArgumentException,
+ UsrSystemException) )
+{
+ if( L"com.sun.star.io.DataInputStream" == TestName ||
+ L"com.sun.star.io.DataOutputStream" == TestName ) {
+
+ try {
+ if( 0 == hTestHandle ) {
+ testInvariant( TestName , TestObject );
+ }
+ else {
+ XActiveDataSinkRef rSink( TestObject, USR_QUERY );
+ XActiveDataSourceRef rSource( TestObject , USR_QUERY );
+
+ XDataInputStreamRef rInput( TestObject , USR_QUERY );
+ XDataOutputStreamRef rOutput( TestObject , USR_QUERY );
+
+
+ XInterfaceRef x = m_rFactory->createInstance( L"com.sun.star.io.Pipe");
+
+ XInputStreamRef rPipeInput( x , USR_QUERY );
+ XOutputStreamRef rPipeOutput( x , USR_QUERY );
+
+ if( ! rSink.is() ) {
+ x = m_rFactory->createInstance( L"com.sun.star.io.DataInputStream" );
+ x->queryInterface( XDataInputStream::getSmartUik() , rInput );
+ x->queryInterface( XActiveDataSink::getSmartUik() , rSink );
+ }
+ else if ( !rSource.is() ) {
+
+ x = m_rFactory->createInstance( L"com.sun.star.io.DataOutputStream" );
+ x->queryInterface( XDataOutputStream::getSmartUik() , rOutput );
+ x->queryInterface( XActiveDataSource::getSmartUik() , rSource );
+ }
+
+ OSL_ASSERT( rPipeInput.is() );
+ OSL_ASSERT( rPipeOutput.is() );
+ rSink->setInputStream( rPipeInput );
+ rSource->setOutputStream( rPipeOutput );
+
+ OSL_ASSERT( rSink->getInputStream().is() );
+ OSL_ASSERT( rSource->getOutputStream().is() );
+
+ if( 1 == hTestHandle ) {
+ testSimple( rInput , rOutput );
+ }
+ }
+ }
+ catch( Exception& e ) {
+ BUILD_ERROR( 0 , UStringToString( e.getName() , CHARSET_SYSTEM ).GetCharStr() );
+ }
+ catch(...) {
+ BUILD_ERROR( 0 , "unknown exception (Exception is not base class)" );
+ }
+
+ hTestHandle ++;
+
+ if( hTestHandle >= 2) {
+ // all tests finished.
+ hTestHandle = -1;
+ }
+ }
+ else {
+ BUILD_ERROR( 0 , "service not supported by test." );
+ }
+ return hTestHandle;
+}
+
+
+
+BOOL ODataStreamTest::testPassed(void) THROWS( (UsrSystemException) )
+{
+ return m_seqErrors.getLen() == 0;
+}
+
+
+Sequence< UString > ODataStreamTest::getErrors(void) THROWS( (UsrSystemException) )
+{
+ return m_seqErrors;
+}
+
+
+Sequence< UsrAny > ODataStreamTest::getErrorExceptions(void) THROWS( (UsrSystemException) )
+{
+ return m_seqExceptions;
+}
+
+
+Sequence< UString > ODataStreamTest::getWarnings(void) THROWS( (UsrSystemException) )
+{
+ return m_seqWarnings;
+}
+
+void ODataStreamTest::testSimple( const XDataInputStreamRef &rInput,
+ const XDataOutputStreamRef &rOutput )
+{
+ rOutput->writeLong( 0x34ff3c );
+ rOutput->writeLong( 0x34ff3d );
+
+ ERROR_ASSERT( 0x34ff3c == rInput->readLong() , "long read/write mismatch" );
+ ERROR_ASSERT( 0x34ff3d == rInput->readLong() , "long read/write mismatch" );
+
+ rOutput->writeByte( 0x87 );
+ ERROR_ASSERT( 0x87 == rInput->readByte() , "byte read/write mismatch" );
+
+ rOutput->writeBoolean( 25 );
+ ERROR_ASSERT( rInput->readBoolean() , "boolean read/write mismatch" );
+
+ rOutput->writeBoolean( FALSE );
+ ERROR_ASSERT( ! rInput->readBoolean() , "boolean read/write mismatch" );
+
+ rOutput->writeFloat( (float) 42.42 );
+ ERROR_ASSERT( rInput->readFloat() == ((float)42.42) , "float read/write mismatch" );
+
+ rOutput->writeDouble( (double) 42.42 );
+ ERROR_ASSERT( rInput->readDouble() == 42.42 , "double read/write mismatch" );
+
+ rOutput->writeUTF( L"Live long and prosper !" );
+ ERROR_ASSERT( rInput->readUTF() == L"Live long and prosper !" ,
+ "UTF read/write mismatch" );
+
+ Sequence<wchar_t> wc(0x10001);
+ for( int i = 0 ; i < 0x10000 ; i ++ ) {
+ wc.getArray()[i] = L'c';
+ }
+ wc.getArray()[0x10000] = 0;
+ UString str( wc.getArray() , 0x10000 );
+ rOutput->writeUTF( str );
+ ERROR_ASSERT( rInput->readUTF() == str , "error reading 64k block" );
+
+ rOutput->closeOutput();
+ try {
+ rInput->readLong();
+ ERROR_ASSERT( 0 , "eof-exception does not occur !" );
+ }
+ catch ( IOException& e ){
+ //ok
+ e.getName();
+ }
+ catch(...) {
+ ERROR_ASSERT( 0 , "wrong exception after reading beyond eof" );
+ }
+
+ ERROR_ASSERT( ! rInput->readBytes( Sequence<BYTE> (1) , 1 ),
+ "stream must be on eof !" );
+
+ rInput->closeInput();
+
+ try {
+ rOutput->writeByte( 1 );
+ ERROR_ASSERT( 0 , "writing still possible though chain must be interrupted" );
+ }
+ catch( IOException& e )
+ {
+ e.getName();
+ // ok
+ }
+ catch( ... ) {
+ ERROR_ASSERT( 0 , "IOException expected, but another exception was thrown" );
+ }
+
+}
+
+
+
+/**
+* for external binding
+*
+*
+**/
+XInterfaceRef ODataStreamTest_CreateInstance( const XMultiServiceFactoryRef & rSMgr ) THROWS((Exception))
+{
+ ODataStreamTest *p = new ODataStreamTest( rSMgr );
+ XInterfaceRef xService = *p;
+ return xService;
+}
+
+Sequence<UString> ODataStreamTest_getSupportedServiceNames( int i) THROWS( () )
+{
+ Sequence<UString> aRet(1);
+
+ aRet.getArray()[0] = ODataStreamTest_getImplementationName( i);
+
+
+ return aRet;
+}
+
+UString ODataStreamTest_getServiceName( int i) THROWS( () )
+{
+ if( 1 == i ) {
+ return L"test.com.sun.star.io.DataInputStream";
+ }
+ else {
+ return L"test.com.sun.star.io.DataOutputStream";
+ }
+}
+
+UString ODataStreamTest_getImplementationName( int i) THROWS( () )
+{
+ if( 1 == i ) {
+ return L"test.com.sun.star.comp.extensions.stm.DataInputStream";
+ }
+ else {
+ return L"test.com.sun.star.comp.extensions.stm.DataOutputStream";
+ }
+}
+
+
+/**------------------------------------------------------
+*
+*
+*
+*
+*
+*------------------------------------------------------*/
+class MyPersistObject :
+ public XPersistObject,
+ public XPropertySet,
+ public OWeakObject
+{
+public:
+ MyPersistObject( ) : m_sServiceName( OMyPersistObject_getServiceName() )
+ {}
+ MyPersistObject( const UString & sServiceName ) : m_sServiceName( sServiceName )
+ {}
+ ~MyPersistObject()
+ {}
+
+public:
+ BOOL queryInterface( Uik aUik, XInterfaceRef & rOut );
+ void acquire() { OWeakObject::acquire(); }
+ void release() { OWeakObject::release(); }
+ void* getImplementation(Reflection *p) { return OWeakObject::getImplementation(p); }
+
+public:
+ virtual UString getServiceName(void) const THROWS( (UsrSystemException) );
+ virtual void write(const XObjectOutputStreamRef& OutStream) THROWS( (IOException, UsrSystemException) );
+ virtual void read(const XObjectInputStreamRef& InStream) THROWS( (IOException, UsrSystemException) );
+
+public:
+
+ virtual XPropertySetInfoRef getPropertySetInfo(void) const THROWS( (UsrSystemException) );
+ virtual void setPropertyValue(const UString& aPropertyName, const UsrAny& aValue)
+ THROWS( ( UnknownPropertyException,
+ PropertyVetoException,
+ IllegalArgumentException,
+ WrappedTargetException,
+ UsrSystemException) );
+ virtual UsrAny getPropertyValue(const UString& PropertyName) const
+ THROWS( ( UnknownPropertyException,
+ WrappedTargetException,
+ UsrSystemException) );
+ virtual void addPropertyChangeListener( const UString& aPropertyName,
+ const XPropertyChangeListenerRef& xListener)
+ THROWS( ( UnknownPropertyException,
+ WrappedTargetException,
+ UsrSystemException) );
+ virtual void removePropertyChangeListener( const UString& aPropertyName,
+ const XPropertyChangeListenerRef& aListener)
+ THROWS( ( UnknownPropertyException,
+ WrappedTargetException,
+ UsrSystemException) );
+ virtual void addVetoableChangeListener( const UString& PropertyName,
+ const XVetoableChangeListenerRef& aListener)
+ THROWS( ( UnknownPropertyException,
+ WrappedTargetException,
+ UsrSystemException) );
+ virtual void removeVetoableChangeListener( const UString& PropertyName,
+ const XVetoableChangeListenerRef& aListener)
+ THROWS( ( UnknownPropertyException,
+ WrappedTargetException,
+ UsrSystemException) );
+
+public:
+ INT32 m_l;
+ float m_f;
+ double m_d;
+ BOOL m_b;
+ BYTE m_byte;
+ wchar_t m_c;
+ UString m_s;
+ XPersistObjectRef m_ref;
+ UString m_sServiceName;
+};
+
+
+
+XPropertySetInfoRef MyPersistObject::getPropertySetInfo(void) const THROWS( (UsrSystemException) )
+{
+ return XPropertySetInfoRef();
+}
+
+void MyPersistObject::setPropertyValue(const UString& aPropertyName, const UsrAny& aValue)
+ THROWS( ( UnknownPropertyException,
+ PropertyVetoException,
+ IllegalArgumentException,
+ WrappedTargetException,
+ UsrSystemException) )
+{
+ if( L"long" == aPropertyName ) {
+ m_l = aValue.getINT32();
+ }
+ else if ( L"float" == aPropertyName ) {
+ m_f = aValue.getFloat();
+ }
+ else if( L"double" == aPropertyName ) {
+ m_d = aValue.getDouble();
+ }
+ else if( L"bool" == aPropertyName ) {
+ m_b = aValue.getBOOL();
+ }
+ else if( L"byte" == aPropertyName ) {
+ m_byte = aValue.getBYTE();
+ }
+ else if( L"char" == aPropertyName ) {
+ m_c = aValue.getChar();
+ }
+ else if( L"string" == aPropertyName ) {
+ m_s = aValue.getString();
+ }
+ else if( L"object" == aPropertyName ) {
+ if( aValue.getReflection() == XPersistObject_getReflection() ) {
+ XPersistObjectRef *pRef = (XPersistObjectRef*) aValue.get();
+ if( pRef ) {
+ m_ref = *pRef;
+ }
+ else {
+ m_ref = 0;
+ }
+ }
+ else
+ {
+ m_ref = 0;
+ }
+ }
+}
+
+
+UsrAny MyPersistObject::getPropertyValue(const UString& aPropertyName) const
+ THROWS( ( UnknownPropertyException,
+ WrappedTargetException,
+ UsrSystemException) )
+{
+ UsrAny aValue;
+ if( L"long" == aPropertyName ) {
+ aValue.setINT32( m_l );
+ }
+ else if ( L"float" == aPropertyName ) {
+ aValue.setFloat( m_f );
+ }
+ else if( L"double" == aPropertyName ) {
+ aValue.setDouble( m_d );
+ }
+ else if( L"bool" == aPropertyName ) {
+ aValue.setBOOL( m_b );
+ }
+ else if( L"byte" == aPropertyName ) {
+ aValue.setBYTE( m_byte );
+ }
+ else if( L"char" == aPropertyName ) {
+ aValue.setChar( m_c );
+ }
+ else if( L"string" == aPropertyName ) {
+ aValue.setString( m_s );
+ }
+ else if( L"object" == aPropertyName ) {
+ aValue.set( &m_ref , XPersistObject_getReflection() );
+ }
+ return aValue;
+}
+
+
+void MyPersistObject::addPropertyChangeListener( const UString& aPropertyName,
+ const XPropertyChangeListenerRef& xListener)
+ THROWS( ( UnknownPropertyException,
+ WrappedTargetException,
+ UsrSystemException) )
+{
+
+}
+
+void MyPersistObject::removePropertyChangeListener( const UString& aPropertyName,
+ const XPropertyChangeListenerRef& aListener)
+ THROWS( ( UnknownPropertyException,
+ WrappedTargetException,
+ UsrSystemException) )
+{
+}
+void MyPersistObject::addVetoableChangeListener(const UString& PropertyName,
+ const XVetoableChangeListenerRef& aListener)
+ THROWS( ( UnknownPropertyException,
+ WrappedTargetException,
+ UsrSystemException) )
+{
+
+}
+
+void MyPersistObject::removeVetoableChangeListener( const UString& PropertyName,
+ const XVetoableChangeListenerRef& aListener)
+ THROWS( ( UnknownPropertyException,
+ WrappedTargetException,
+ UsrSystemException) )
+{
+
+}
+
+
+
+BOOL MyPersistObject::queryInterface( Uik aUik , XInterfaceRef &rOut )
+{
+ if( XPersistObject::getSmartUik() == aUik ) {
+ rOut = ( XPersistObject * ) this;
+ }
+ else if( XPropertySet::getSmartUik() == aUik ) {
+ rOut = ( XPropertySet * ) this;
+ }
+ else
+ return OWeakObject::queryInterface( aUik , rOut );
+
+ return TRUE;
+}
+
+UString MyPersistObject::getServiceName() const THROWS( (UsrSystemException) )
+{
+ return m_sServiceName;
+}
+
+void MyPersistObject::write( const XObjectOutputStreamRef & rOut )
+ THROWS( (IOException,UsrSystemException))
+{
+ rOut->writeLong( m_l);
+ rOut->writeFloat( m_f );
+ rOut->writeDouble( m_d );
+ rOut->writeBoolean( m_b );
+ rOut->writeByte( m_byte );
+ rOut->writeChar( m_c );
+ rOut->writeUTF( m_s );
+ rOut->writeObject( m_ref );
+}
+
+
+void MyPersistObject::read( const XObjectInputStreamRef & rIn )
+ THROWS( (IOException, UsrSystemException) )
+{
+ m_l = rIn->readLong();
+ m_f = rIn->readFloat();
+ m_d = rIn->readDouble();
+ m_b = rIn->readBoolean();
+ m_byte = rIn->readByte();
+ m_c = rIn->readChar();
+ m_s = rIn->readUTF();
+ m_ref = rIn->readObject();
+}
+
+XInterfaceRef OMyPersistObject_CreateInstance( const XMultiServiceFactoryRef & rSMgr )
+ THROWS((Exception))
+{
+ MyPersistObject *p = new MyPersistObject( );
+ XInterfaceRef xService = *p;
+ return xService;
+}
+
+Sequence<UString> OMyPersistObject_getSupportedServiceNames( ) THROWS( () )
+{
+ Sequence<UString> aRet(1);
+ aRet.getArray()[0] = OMyPersistObject_getImplementationName();
+ return aRet;
+}
+
+UString OMyPersistObject_getServiceName( ) THROWS( () )
+{
+ return L"test.com.sun.star.io.PersistTest";
+}
+
+UString OMyPersistObject_getImplementationName( ) THROWS( () )
+{
+ return L"test.com.sun.star.io.PersistTest";
+}
+
+
+// ---------------------------------------------
+// -----------------------------------------------
+class OObjectStreamTest :
+ public ODataStreamTest
+{
+public:
+ OObjectStreamTest( const XMultiServiceFactoryRef &r) : ODataStreamTest(r) {}
+public: // refcounting
+ BOOL queryInterface( Uik aUik, XInterfaceRef & rOut );
+
+public:
+ virtual void testInvariant(const UString& TestName, const XInterfaceRef& TestObject)
+ THROWS( ( IllegalArgumentException,
+ UsrSystemException) );
+
+ virtual INT32 test( const UString& TestName,
+ const XInterfaceRef& TestObject,
+ INT32 hTestHandle) THROWS( ( IllegalArgumentException,
+ UsrSystemException) );
+
+
+private:
+ void OObjectStreamTest::testObject( const XObjectOutputStreamRef &rOut,
+ const XObjectInputStreamRef &rIn );
+
+private:
+};
+
+
+
+
+BOOL OObjectStreamTest::queryInterface( Uik uik , XInterfaceRef &rOut )
+{
+ if( XSimpleTest::getSmartUik() == uik ) {
+ rOut = (XSimpleTest *) this;
+ }
+ else {
+ return ODataStreamTest::queryInterface( uik , rOut );
+ }
+ return TRUE;
+}
+
+
+void OObjectStreamTest::testInvariant( const UString& TestName, const XInterfaceRef& TestObject )
+ THROWS( ( IllegalArgumentException,
+ UsrSystemException) )
+{
+
+
+ if( L"com.sun.star.io.ObjectInputStream" == TestName ) {
+ ODataStreamTest::testInvariant( TestName , TestObject );
+ XObjectInputStreamRef dataInput( TestObject , USR_QUERY );
+ XMarkableStreamRef markable( TestObject , USR_QUERY );
+ ERROR_ASSERT( dataInput.is() , "XObjectInputStream cannot be queried" );
+ ERROR_ASSERT( markable.is() , "XMarkableStream cannot be queried" );
+ }
+ else if( L"com.sun.star.io.ObjectOutputStream" == TestName ) {
+ ODataStreamTest::testInvariant( TestName , TestObject );
+ XMarkableStreamRef markable( TestObject , USR_QUERY );
+ XObjectOutputStreamRef dataOutput( TestObject , USR_QUERY );
+ ERROR_ASSERT( dataOutput.is(), "XObjectOutputStream cannot be queried" );
+ ERROR_ASSERT( markable.is() , "XMarkableStream cannot be queried" );
+ }
+
+ XServiceInfoRef info( TestObject, USR_QUERY );
+ ERROR_ASSERT( info.is() , "XServiceInfo not supported !" );
+ if( info.is() )
+ {
+ ERROR_ASSERT( info->supportsService( TestName ), "XServiceInfo test failed" );
+ ERROR_ASSERT( ! info->supportsService( L"bla bluzb" ) , "XServiceInfo test failed" );
+ }
+
+}
+
+INT32 OObjectStreamTest::test( const UString& TestName,
+ const XInterfaceRef& TestObject,
+ INT32 hTestHandle) THROWS( ( IllegalArgumentException,
+ UsrSystemException) )
+{
+ if( L"com.sun.star.io.ObjectInputStream" == TestName ||
+ L"com.sun.star.io.ObjectOutputStream" == TestName ) {
+
+ try {
+ if( 0 == hTestHandle ) {
+ testInvariant( TestName , TestObject );
+ }
+ else if( DATASTREAM_TEST_MAX_HANDLE >= hTestHandle ) {
+ INT32 hOldHandle = hTestHandle;
+ hTestHandle = ODataStreamTest::test( L"com.sun.star.io.DataInputStream" ,
+ TestObject , hTestHandle );
+ if( hTestHandle == -1 ){
+ hTestHandle = hOldHandle;
+ }
+ }
+ else {
+
+ XActiveDataSinkRef rSink( TestObject, USR_QUERY );
+ XActiveDataSourceRef rSource( TestObject , USR_QUERY );
+
+ XObjectInputStreamRef rInput( TestObject , USR_QUERY );
+ XObjectOutputStreamRef rOutput( TestObject , USR_QUERY );
+
+
+ XInterfaceRef x = m_rFactory->createInstance( L"com.sun.star.io.Pipe");
+
+ XInputStreamRef rPipeInput( x , USR_QUERY );
+ XOutputStreamRef rPipeOutput( x , USR_QUERY );
+
+ x = m_rFactory->createInstance( L"com.sun.star.io.MarkableInputStream" );
+ XInputStreamRef markableInput( x , USR_QUERY );
+ XActiveDataSinkRef markableSink( x , USR_QUERY );
+
+ x = m_rFactory->createInstance( L"com.sun.star.io.MarkableOutputStream" );
+ XOutputStreamRef markableOutput( x , USR_QUERY );
+ XActiveDataSourceRef markableSource( x , USR_QUERY );
+
+ OSL_ASSERT( markableInput.is() );
+ OSL_ASSERT( markableOutput.is() );
+ OSL_ASSERT( markableSink.is() );
+ OSL_ASSERT( markableSource.is() );
+
+ markableSink->setInputStream( rPipeInput );
+ markableSource->setOutputStream( rPipeOutput );
+
+ if( ! rSink.is() ) {
+ x = m_rFactory->createInstance( L"com.sun.star.io.ObjectInputStream" );
+ x->queryInterface( XObjectInputStream::getSmartUik() , rInput );
+ x->queryInterface( XActiveDataSink::getSmartUik() , rSink );
+ }
+ else if ( !rSource.is() ) {
+ x = m_rFactory->createInstance( L"com.sun.star.io.ObjectOutputStream" );
+ x->queryInterface( XObjectOutputStream::getSmartUik() , rOutput );
+ x->queryInterface( XActiveDataSource::getSmartUik() , rSource );
+ }
+
+ OSL_ASSERT( rPipeInput.is() );
+ OSL_ASSERT( rPipeOutput.is() );
+
+ rSink->setInputStream( markableInput );
+ rSource->setOutputStream( markableOutput );
+
+ OSL_ASSERT( rSink->getInputStream().is() );
+ OSL_ASSERT( rSource->getOutputStream().is() );
+
+ if( 1 + DATASTREAM_TEST_MAX_HANDLE == hTestHandle ) {
+ testObject( rOutput , rInput);
+ }
+ rInput->closeInput();
+ rOutput->closeOutput();
+
+ }
+ }
+ catch( Exception& e ) {
+ BUILD_ERROR( 0 , UStringToString( e.getName() , CHARSET_SYSTEM ).GetCharStr() );
+ }
+ catch(...) {
+ BUILD_ERROR( 0 , "unknown exception (Exception is not base class)" );
+ }
+
+ hTestHandle ++;
+
+ if( hTestHandle > 1 +DATASTREAM_TEST_MAX_HANDLE ) {
+ // all tests finished.
+ hTestHandle = -1;
+ }
+ }
+ else {
+ BUILD_ERROR( 0 , "service not supported by test." );
+ }
+ return hTestHandle;
+}
+
+
+BOOL compareMyPropertySet( XPropertySetRef &r1 , XPropertySetRef &r2 )
+{
+ BOOL b = TRUE;
+
+ if( r1->getPropertyValue( L"long" ).getReflection() == Void_getReflection() ||
+ r2->getPropertyValue( L"long" ).getReflection() == Void_getReflection() ) {
+
+ // one of the objects is not the correct propertyset !
+ return FALSE;
+ }
+
+ b = b && ( r1->getPropertyValue( L"long" ).getINT32() ==
+ r2->getPropertyValue( L"long" ).getINT32() );
+
+ b = b && ( r1->getPropertyValue( L"float" ).getFloat() ==
+ r2->getPropertyValue( L"float" ).getFloat() );
+
+ b = b && ( r1->getPropertyValue( L"double" ).getDouble() ==
+ r2->getPropertyValue( L"double" ).getDouble() );
+
+ b = b && ( r1->getPropertyValue( L"bool" ).getBOOL() ==
+ r2->getPropertyValue( L"bool" ).getBOOL() );
+
+ b = b && ( r1->getPropertyValue( L"byte" ).getBYTE() ==
+ r2->getPropertyValue( L"byte" ).getBYTE() );
+
+ b = b && ( r1->getPropertyValue( L"char" ).getChar() ==
+ r2->getPropertyValue( L"char" ).getChar() );
+
+ b = b && ( r1->getPropertyValue( L"string" ).getString() ==
+ r2->getPropertyValue( L"string" ).getString() );
+
+ UsrAny o1 = r1->getPropertyValue( L"object" );
+ UsrAny o2 = r2->getPropertyValue( L"object" );
+
+ if( o1.getReflection() == XPersistObject_getReflection() ) {
+
+ if( o2.getReflection() == XPersistObject_getReflection() ) {
+ XPersistObjectRef rPersist1 = *((XPersistObjectRef*) o1.get());
+ XPersistObjectRef rPersist2 = *((XPersistObjectRef*) o2.get());
+ XPropertySetRef rProp1( rPersist1 , USR_QUERY );
+ XPropertySetRef rProp2( rPersist2 , USR_QUERY );
+
+ if( rProp1.is() && rProp2.is() && ! ( rProp1 == rProp2 )
+ &&( rProp1 != r1 )) {
+ compareMyPropertySet( rProp1 , rProp2 );
+ }
+ }
+ else {
+ b = FALSE;
+ }
+ }
+ else {
+ if( o2.getReflection() == XPersistObject_getReflection() ) {
+ b = FALSE;
+ }
+ }
+
+ return b;
+}
+
+void OObjectStreamTest::testObject( const XObjectOutputStreamRef &rOut,
+ const XObjectInputStreamRef &rIn )
+{
+ ERROR_ASSERT( rOut.is() , "no objectOutputStream" );
+ ERROR_ASSERT( rIn.is() , "no objectInputStream" );
+
+ XMultiServiceFactoryRef xProv = getProcessServiceManager();
+ ERROR_ASSERT( xProv.is() , "no global service manager" );
+
+
+ // tests, if saving an object with an unknown service name allows
+ // reading the data behind the object !
+ {
+ XInterfaceRef x = * new MyPersistObject( L"bla blubs" );
+
+ XPersistObjectRef persistRef( x , USR_QUERY );
+ ERROR_ASSERT( persistRef.is() , "couldn't instantiate PersistTest object" );
+
+ rOut->writeObject( persistRef );
+ rOut->writeLong( (INT32) 0xdeadbeef );
+
+ ERROR_ASSERT( 0 != rIn->available() , "no data arrived at input" );
+
+ try
+ {
+ XPersistObjectRef xReadPersistRef = rIn->readObject();
+ ERROR_ASSERT( 0 , "expected exception not thrown" );
+ }
+ catch( IOException& e )
+ {
+ // all is ok
+ }
+
+ ERROR_ASSERT( (INT32) 0xdeadbeef == rIn->readLong() ,
+ "wrong data after object with unknown service name." );
+ }
+
+ {
+ XInterfaceRef x = xProv->createInstance(L"test.com.sun.star.io.PersistTest");
+ XPersistObjectRef persistRef( x , USR_QUERY );
+
+ ERROR_ASSERT( persistRef.is() , "couldn't instantiate PersistTest object" );
+
+ XPropertySetRef rProp( persistRef , USR_QUERY );
+ ERROR_ASSERT( rProp.is() , "test object is no property set " );
+
+ UsrAny any;
+ any.setINT32( 0x83482 );
+ rProp->setPropertyValue( L"long" , any );
+
+ any.setFloat( 42.23 );
+ rProp->setPropertyValue( L"float" , any );
+
+ any.setDouble( 233.321412 );
+ rProp->setPropertyValue( L"double" , any );
+
+ any.setBOOL( TRUE );
+ rProp->setPropertyValue( L"bool" , any );
+
+ any.setBYTE( 130 );
+ rProp->setPropertyValue( L"byte" , any );
+
+ any.setChar( 'h' );
+ rProp->setPropertyValue( L"char" , any );
+
+ any.setString( L"hi du !" );
+ rProp->setPropertyValue( L"string" , any );
+
+ any.set( &persistRef, XPersistObject_getReflection() ); // try a self reference
+ rProp->setPropertyValue( L"object" , any );
+
+ // do read and write
+ rOut->writeObject( persistRef );
+ ERROR_ASSERT( 0 != rIn->available() , "no data arrived at input" );
+ XPersistObjectRef xReadPersistRef = rIn->readObject( );
+
+ XPropertySetRef rPropRead( xReadPersistRef , USR_QUERY );
+ ERROR_ASSERT( compareMyPropertySet( rProp , rPropRead ) , "objects has not been read properly !" );
+
+ // destroy selfreferences
+ rProp->setPropertyValue( L"object", UsrAny() );
+ rPropRead->setPropertyValue( L"object", UsrAny() );
+ }
+
+ {
+ XMarkableStreamRef markableOut( rOut , USR_QUERY );
+ ERROR_ASSERT( markableOut.is() , "markable stream cannot be queried" );
+
+ // do the same thing multiple times to check if
+ // buffering and marks work correctly
+ for( int i = 0 ; i < 2000 ; i ++ ) {
+
+ XInterfaceRef x = xProv->createInstance(L"test.com.sun.star.io.PersistTest");
+ XPersistObjectRef persistRef( x , USR_QUERY );
+
+ XPropertySetRef rProp( persistRef , USR_QUERY );
+ ERROR_ASSERT( rProp.is() , "test object is no property set " );
+
+ UsrAny any;
+ any.setINT32( 0x83482 );
+ rProp->setPropertyValue( L"long" , any );
+
+ any.setFloat( 42.23 );
+ rProp->setPropertyValue( L"float" , any );
+
+ any.setDouble( 233.321412 );
+ rProp->setPropertyValue( L"double" , any );
+
+ any.setBOOL( TRUE );
+ rProp->setPropertyValue( L"bool" , any );
+
+ any.setBYTE( 130 );
+ rProp->setPropertyValue( L"byte" , any );
+
+ any.setChar( 'h' );
+ rProp->setPropertyValue( L"char" , any );
+
+ any.setString( L"hi du !" );
+ rProp->setPropertyValue( L"string" , any );
+
+
+ x = xProv->createInstance(L"test.com.sun.star.io.PersistTest");
+ XPersistObjectRef persist2ndRef( x , USR_QUERY );
+
+
+ // Note : persist2ndRef contains coincident values, but also coincident values must be
+ // saved properly !
+ any.set( &persist2ndRef, XPersistObject_getReflection() ); // try a self reference
+ rProp->setPropertyValue( L"object" , any );
+
+ // simply test, if markable operations and object operations do not interfere
+ INT32 nMark = markableOut->createMark();
+
+ // do read and write
+ rOut->writeObject( persistRef );
+
+ // further markable tests !
+ INT32 nOffset = markableOut->offsetToMark( nMark );
+ markableOut->jumpToMark( nMark );
+ markableOut->deleteMark( nMark );
+ markableOut->jumpToFurthest();
+
+
+
+
+
+ ERROR_ASSERT( 0 != rIn->available() , "no data arrived at input" );
+ XPersistObjectRef xReadPersistRef = rIn->readObject( );
+
+ XPropertySetRef rProp1( persistRef , USR_QUERY );
+ XPropertySetRef rProp2( xReadPersistRef , USR_QUERY );
+ ERROR_ASSERT( compareMyPropertySet( rProp1, rProp2) , "objects has not been read properly !" );
+ }
+ }
+}
+
+
+XInterfaceRef OObjectStreamTest_CreateInstance( const XMultiServiceFactoryRef & rSMgr ) THROWS((Exception))
+{
+ OObjectStreamTest *p = new OObjectStreamTest( rSMgr );
+ XInterfaceRef xService = *p;
+ return xService;
+}
+
+Sequence<UString> OObjectStreamTest_getSupportedServiceNames( int i) THROWS( () )
+{
+ Sequence<UString> aRet(1);
+ aRet.getArray()[0] = OObjectStreamTest_getImplementationName( i);
+ return aRet;
+}
+
+UString OObjectStreamTest_getServiceName( int i) THROWS( () )
+{
+ if( 1 == i ) {
+ return L"test.com.sun.star.io.ObjectInputStream";
+ }
+ else {
+ return L"test.com.sun.star.io.ObjectOutputStream";
+ }
+}
+
+UString OObjectStreamTest_getImplementationName( int i) THROWS( () )
+{
+ if( 1 == i ) {
+ return L"test.com.sun.star.comp.extensions.stm.ObjectInputStream";
+ }
+ else {
+ return L"test.com.sun.star.comp.extensions.stm.ObjectOutputStream";
+ }
+}
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/test/stm/exports.dxp b/extensions/test/stm/exports.dxp
new file mode 100644
index 000000000000..e4bc69d23003
--- /dev/null
+++ b/extensions/test/stm/exports.dxp
@@ -0,0 +1,2 @@
+exService_writeRegEntry
+exService_getFactory
diff --git a/extensions/test/stm/makefile.mk b/extensions/test/stm/makefile.mk
new file mode 100644
index 000000000000..ac31f76fb805
--- /dev/null
+++ b/extensions/test/stm/makefile.mk
@@ -0,0 +1,61 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+PRJ=..$/..
+
+PRJNAME=extensions
+TARGET=teststm
+USE_DEFFILE=TRUE
+ENABLE_EXCEPTIONS=TRUE
+
+# --- Settings -----------------------------------------------------
+.INCLUDE : $(PRJ)$/util$/makefile.pmk
+
+# --- Files --------------------------------------------------------
+OBJFILES= $(SLO)$/pipetest.obj $(SLO)$/testfactreg.obj $(SLO)$/datatest.obj \
+ $(SLO)$/marktest.obj
+
+SHL1TARGET= $(TARGET)$(DLLPOSTFIX)
+LIB1TARGET= $(SLB)$/$(TARGET).lib
+
+SHL1STDLIBS= \
+ $(SALLIB) \
+ $(TOOLSLIB)
+
+LIB1OBJFILES= $(OBJFILES)
+SHL1LIBS= $(LIB1TARGET)
+SHL1IMPLIB= i$(TARGET)
+SHL1DEPN= makefile.mk $(SHL1LIBS)
+SHL1DEF= $(MISC)$/$(SHL1TARGET).def
+
+DEF1NAME= $(SHL1TARGET)
+DEF1EXPORTFILE= exports.dxp
+
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : target.mk
+.INCLUDE : $(PRJ)$/util$/target.pmk
diff --git a/extensions/test/stm/marktest.cxx b/extensions/test/stm/marktest.cxx
new file mode 100644
index 000000000000..1c3c5a0f9d01
--- /dev/null
+++ b/extensions/test/stm/marktest.cxx
@@ -0,0 +1,685 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+#include <smart/com/sun/star/test/XSimpleTest.hxx>
+#include <smart/com/sun/star/io/XMarkableStream.hxx>
+#include <smart/com/sun/star/io/XActiveDataSink.hxx>
+#include <smart/com/sun/star/io/XActiveDataSource.hxx>
+#include <smart/com/sun/star/io/XConnectable.hxx>
+
+#include <smart/com/sun/star/lang/XServiceInfo.hxx>
+
+
+#include <usr/factoryhlp.hxx>
+
+#include <usr/reflserv.hxx> // for EXTERN_SERVICE_CALLTYPE
+#include <usr/weak.hxx> // OWeakObject
+
+#include <osl/conditn.hxx>
+#include <osl/mutex.hxx>
+#include <osl/thread.hxx>
+
+#include <string.h>
+
+#include "testfactreg.hxx"
+
+
+#ifndef _VOS_NO_NAMESPACE
+using namespace usr;
+#endif
+
+
+
+class OMarkableOutputStreamTest :
+ public XSimpleTest,
+ public OWeakObject
+{
+public:
+ OMarkableOutputStreamTest( const XMultiServiceFactoryRef & rFactory );
+ ~OMarkableOutputStreamTest();
+
+public: // refcounting
+ BOOL queryInterface( Uik aUik, XInterfaceRef & rOut );
+ void acquire() { OWeakObject::acquire(); }
+ void release() { OWeakObject::release(); }
+ void* getImplementation(Reflection *p) { return OWeakObject::getImplementation(p); }
+
+public: // implementation names
+ static Sequence< UString > getSupportedServiceNames_Static(void) THROWS( () );
+ static UString getImplementationName_Static() THROWS( () );
+
+public:
+ virtual void testInvariant(const UString& TestName, const XInterfaceRef& TestObject)
+ THROWS( ( IllegalArgumentException,
+ UsrSystemException) );
+
+ virtual INT32 test( const UString& TestName,
+ const XInterfaceRef& TestObject,
+ INT32 hTestHandle) THROWS( ( IllegalArgumentException,
+ UsrSystemException) );
+
+ virtual BOOL testPassed(void) THROWS( ( UsrSystemException) );
+ virtual Sequence< UString > getErrors(void) THROWS( (UsrSystemException) );
+ virtual Sequence< UsrAny > getErrorExceptions(void) THROWS( (UsrSystemException) );
+ virtual Sequence< UString > getWarnings(void) THROWS( (UsrSystemException) );
+
+private:
+ void testSimple( const XOutputStreamRef &r, const XInputStreamRef &rInput );
+
+private:
+ Sequence<UsrAny> m_seqExceptions;
+ Sequence<UString> m_seqErrors;
+ Sequence<UString> m_seqWarnings;
+ XMultiServiceFactoryRef m_rFactory;
+
+};
+
+OMarkableOutputStreamTest::OMarkableOutputStreamTest( const XMultiServiceFactoryRef &rFactory )
+ : m_rFactory( rFactory )
+{
+
+}
+
+OMarkableOutputStreamTest::~OMarkableOutputStreamTest()
+{
+
+}
+
+
+BOOL OMarkableOutputStreamTest::queryInterface( Uik uik , XInterfaceRef &rOut )
+{
+ if( XSimpleTest::getSmartUik() == uik ) {
+ rOut = (XSimpleTest *) this;
+ }
+ else {
+ return OWeakObject::queryInterface( uik , rOut );
+ }
+ return TRUE;
+}
+
+
+void OMarkableOutputStreamTest::testInvariant( const UString& TestName, const XInterfaceRef& TestObject )
+ THROWS( ( IllegalArgumentException,
+ UsrSystemException) )
+{
+ XServiceInfoRef info( TestObject, USR_QUERY );
+ ERROR_ASSERT( info.is() , "XServiceInfo not supported !" );
+ if( info.is() )
+ {
+ ERROR_ASSERT( info->supportsService( TestName ), "XServiceInfo test failed" );
+ ERROR_ASSERT( ! info->supportsService( L"bla bluzb" ) , "XServiceInfo test failed" );
+ }
+}
+
+
+INT32 OMarkableOutputStreamTest::test( const UString& TestName,
+ const XInterfaceRef& TestObject,
+ INT32 hTestHandle) THROWS( ( IllegalArgumentException,
+ UsrSystemException) )
+{
+ if( L"com.sun.star.io.MarkableOutputStream" == TestName ) {
+ try {
+ if( 0 == hTestHandle ) {
+ testInvariant( TestName , TestObject );
+ }
+ else {
+ XInterfaceRef x = m_rFactory->createInstance( L"com.sun.star.io.Pipe");
+ XOutputStreamRef rPipeOutput( x , USR_QUERY );
+ XInputStreamRef rPipeInput( x , USR_QUERY );
+
+ XActiveDataSourceRef source( TestObject , USR_QUERY );
+ source->setOutputStream( rPipeOutput );
+
+ XOutputStreamRef rOutput( TestObject , USR_QUERY );
+
+ OSL_ASSERT( rPipeInput.is() );
+ OSL_ASSERT( rOutput.is() );
+ if( 1 == hTestHandle ) {
+ // checks usual streaming
+ testSimple( rOutput , rPipeInput );
+ }
+ }
+
+ }
+ catch( Exception& e ) {
+ BUILD_ERROR( 0 , UStringToString( e.getName() , CHARSET_SYSTEM ).GetCharStr() );
+ }
+ catch(...) {
+ BUILD_ERROR( 0 , "unknown exception (Exception is not base class)" );
+ }
+
+ hTestHandle ++;
+
+ if( 2 == hTestHandle ) {
+ // all tests finished.
+ hTestHandle = -1;
+ }
+ }
+ else {
+ THROW( IllegalArgumentException() );
+ }
+ return hTestHandle;
+}
+
+
+
+BOOL OMarkableOutputStreamTest::testPassed(void) THROWS( (UsrSystemException) )
+{
+ return m_seqErrors.getLen() == 0;
+}
+
+
+Sequence< UString > OMarkableOutputStreamTest::getErrors(void) THROWS( (UsrSystemException) )
+{
+ return m_seqErrors;
+}
+
+
+Sequence< UsrAny > OMarkableOutputStreamTest::getErrorExceptions(void) THROWS( (UsrSystemException) )
+{
+ return m_seqExceptions;
+}
+
+
+Sequence< UString > OMarkableOutputStreamTest::getWarnings(void) THROWS( (UsrSystemException) )
+{
+ return m_seqWarnings;
+}
+
+
+void OMarkableOutputStreamTest::testSimple( const XOutputStreamRef &rOutput ,
+ const XInputStreamRef &rInput )
+{
+ XMarkableStreamRef rMarkable( rOutput , USR_QUERY );
+
+ ERROR_ASSERT( rMarkable.is() , "no MarkableStream implemented" );
+
+ // first check normal input/output facility
+ char pcStr[] = "Live long and prosper !";
+
+ Sequence<BYTE> seqWrite( strlen( pcStr )+1 );
+ memcpy( seqWrite.getArray() , pcStr , seqWrite.getLen() );
+
+ Sequence<BYTE> seqRead( seqWrite.getLen() );
+
+ int nMax = 10,i;
+
+ for( i = 0 ; i < nMax ; i ++ ) {
+ rOutput->writeBytes( seqWrite );
+ rInput->readBytes( seqRead , rInput->available() );
+ ERROR_ASSERT( ! strcmp( (char *) seqWrite.getArray() , (char * )seqRead.getArray() ) ,
+ "error during read/write/skip" );
+ }
+
+ // Check buffer resizing
+ nMax = 3000;
+ for( i = 0 ; i < nMax ; i ++ ) {
+ rOutput->writeBytes( seqWrite );
+ }
+
+ for( i = 0 ; i < nMax ; i ++ ) {
+ rInput->readBytes( seqRead , seqWrite.getLen() );
+ ERROR_ASSERT( ! strcmp( (char *) seqWrite.getArray() , (char * )seqRead.getArray() ) ,
+ "error during read/write" );
+ }
+
+ // Check creating marks !
+ INT32 nMark = rMarkable->createMark();
+
+ for( i = 0 ; i < nMax ; i ++ ) {
+ rOutput->writeBytes( seqWrite );
+ }
+
+ ERROR_ASSERT( 0 == rInput->available() , "bytes available though mark is holded" );
+
+ ERROR_ASSERT( nMax*seqWrite.getLen() == rMarkable->offsetToMark( nMark ) ,
+ "offsetToMark failure" );
+
+ rMarkable->deleteMark( nMark );
+ ERROR_ASSERT( nMax*seqWrite.getLen() == rInput->available(),"bytes are not available though mark has been deleted" );
+
+ rInput->skipBytes( nMax*seqWrite.getLen() );
+ ERROR_ASSERT( 0 == rInput->available(), "skip bytes failure" );
+
+ try {
+ rMarkable->jumpToMark( nMark );
+ ERROR_ASSERT( 0 , "jump to non existing mark possible !" );
+ }
+ catch ( IllegalArgumentException& e )
+ {
+ e;// ok, exception was thrown
+ }
+
+ // test putting marks not at the end of the stream!
+ ERROR_ASSERT( 0 == rInput->available(), "stream isn't clean" );
+ {
+ Sequence< BYTE > aByte(256);
+
+ for( i = 0 ; i < 256 ; i ++ )
+ {
+ aByte.getArray()[i] = i;
+ }
+ INT32 nMark1 = rMarkable->createMark();
+
+ rOutput->writeBytes( aByte );
+ rMarkable->jumpToMark( nMark1 );
+ aByte.realloc( 10 );
+ rOutput->writeBytes( aByte );
+
+ INT32 nMark2 = rMarkable->createMark( );
+
+ for( i = 0 ; i < 10 ; i ++ )
+ {
+ aByte.getArray()[i] = i+10;
+ }
+
+ rOutput->writeBytes( aByte );
+
+ // allow the bytes to be written !
+ rMarkable->jumpToFurthest();
+ rMarkable->deleteMark( nMark1 );
+ rMarkable->deleteMark( nMark2 );
+
+ ERROR_ASSERT( 256 == rInput->available(), "in between mark failure" );
+ rInput->readBytes( aByte ,256);
+ for( i = 0 ; i < 256 ; i ++ )
+ {
+ ERROR_ASSERT( i == aByte.getArray()[i] , "in between mark failure" );
+ }
+ }
+
+ {
+ // now a more extensive mark test !
+ Sequence<BYTE> as[4];
+ INT32 an[4];
+
+ for( i = 0 ; i < 4 ; i ++ ) {
+ as[i].realloc(1);
+ as[i].getArray()[0] = i;
+ an[i] = rMarkable->createMark();
+ rOutput->writeBytes( as[i] );
+ }
+
+ // check offset to mark
+ for( i = 0 ; i < 4 ; i ++ ) {
+ ERROR_ASSERT( rMarkable->offsetToMark( an[i] ) == 4-i , "offsetToMark failure" );
+ }
+
+ rMarkable->jumpToMark( an[1] );
+ ERROR_ASSERT( rMarkable->offsetToMark( an[3] ) == -2 , "offsetToMark failure" );
+
+ rMarkable->jumpToFurthest( );
+ ERROR_ASSERT( rMarkable->offsetToMark( an[0] ) == 4 , "offsetToMark failure" );
+
+ // now do a rewrite !
+ for( i = 0 ; i < 4 ; i ++ ) {
+ rMarkable->jumpToMark( an[3-i] );
+ rOutput->writeBytes( as[i] );
+ }
+ // NOTE : CursorPos 1
+
+ // now delete the marks !
+ for( i = 0 ; i < 4 ; i ++ ) {
+ rMarkable->deleteMark( an[i] );
+ }
+ ERROR_ASSERT( rInput->available() == 1 , "wrong number of bytes flushed" );
+
+ rMarkable->jumpToFurthest();
+
+ ERROR_ASSERT( rInput->available() == 4 , "wrong number of bytes flushed" );
+
+ rInput->readBytes( seqRead , 4 );
+
+ ERROR_ASSERT( 3 == seqRead.getArray()[0] , "rewrite didn't work" );
+ ERROR_ASSERT( 2 == seqRead.getArray()[1] , "rewrite didn't work" );
+ ERROR_ASSERT( 1 == seqRead.getArray()[2] , "rewrite didn't work" );
+ ERROR_ASSERT( 0 == seqRead.getArray()[3] , "rewrite didn't work" );
+
+ rOutput->closeOutput();
+ rInput->closeInput();
+ }
+
+}
+
+/***
+* the test methods
+*
+****/
+
+
+
+
+
+/**
+* for external binding
+*
+*
+**/
+XInterfaceRef OMarkableOutputStreamTest_CreateInstance( const XMultiServiceFactoryRef & rSMgr ) THROWS((Exception))
+{
+ OMarkableOutputStreamTest *p = new OMarkableOutputStreamTest( rSMgr );
+ XInterfaceRef xService = *p;
+ return xService;
+}
+
+
+
+Sequence<UString> OMarkableOutputStreamTest_getSupportedServiceNames(void) THROWS( () )
+{
+ Sequence<UString> aRet(1);
+ aRet.getArray()[0] = OMarkableOutputStreamTest_getImplementationName();
+
+ return aRet;
+}
+
+UString OMarkableOutputStreamTest_getServiceName() THROWS( () )
+{
+ return L"test.com.sun.star.io.MarkableOutputStream";
+}
+
+UString OMarkableOutputStreamTest_getImplementationName() THROWS( () )
+{
+ return L"test.com.sun.starextensions.stm.MarkableOutputStream";
+}
+
+
+
+
+
+
+
+//-----------------------------------------------------
+// Input stream
+
+
+class OMarkableInputStreamTest :
+ public XSimpleTest,
+ public OWeakObject
+{
+public:
+ OMarkableInputStreamTest( const XMultiServiceFactoryRef & rFactory );
+ ~OMarkableInputStreamTest();
+
+public: // refcounting
+ BOOL queryInterface( Uik aUik, XInterfaceRef & rOut );
+ void acquire() { OWeakObject::acquire(); }
+ void release() { OWeakObject::release(); }
+ void* getImplementation(Reflection *p) { return OWeakObject::getImplementation(p); }
+
+public: // implementation names
+ static Sequence< UString > getSupportedServiceNames_Static(void) THROWS( () );
+ static UString getImplementationName_Static() THROWS( () );
+
+public:
+ virtual void testInvariant(const UString& TestName, const XInterfaceRef& TestObject)
+ THROWS( ( IllegalArgumentException,
+ UsrSystemException) );
+
+ virtual INT32 test( const UString& TestName,
+ const XInterfaceRef& TestObject,
+ INT32 hTestHandle) THROWS( ( IllegalArgumentException,
+ UsrSystemException) );
+
+ virtual BOOL testPassed(void) THROWS( ( UsrSystemException) );
+ virtual Sequence< UString > getErrors(void) THROWS( (UsrSystemException) );
+ virtual Sequence< UsrAny > getErrorExceptions(void) THROWS( (UsrSystemException) );
+ virtual Sequence< UString > getWarnings(void) THROWS( (UsrSystemException) );
+
+private:
+ void testSimple( const XOutputStreamRef &r, const XInputStreamRef &rInput );
+
+private:
+ Sequence<UsrAny> m_seqExceptions;
+ Sequence<UString> m_seqErrors;
+ Sequence<UString> m_seqWarnings;
+ XMultiServiceFactoryRef m_rFactory;
+
+};
+
+OMarkableInputStreamTest::OMarkableInputStreamTest( const XMultiServiceFactoryRef &rFactory )
+ : m_rFactory( rFactory )
+{
+
+}
+
+OMarkableInputStreamTest::~OMarkableInputStreamTest()
+{
+
+}
+
+
+BOOL OMarkableInputStreamTest::queryInterface( Uik uik , XInterfaceRef &rOut )
+{
+ if( XSimpleTest::getSmartUik() == uik ) {
+ rOut = (XSimpleTest *) this;
+ }
+ else {
+ return OWeakObject::queryInterface( uik , rOut );
+ }
+ return TRUE;
+}
+
+
+void OMarkableInputStreamTest::testInvariant( const UString& TestName, const XInterfaceRef& TestObject )
+ THROWS( ( IllegalArgumentException,
+ UsrSystemException) )
+{
+ if( L"com.sun.star.io.MarkableInputStream" == TestName ) {
+ XServiceInfoRef info( TestObject, USR_QUERY );
+ ERROR_ASSERT( info.is() , "XServiceInfo not supported !" );
+ if( info.is() )
+ {
+ ERROR_ASSERT( info->supportsService( TestName ), "XServiceInfo test failed" );
+ ERROR_ASSERT( ! info->supportsService( L"bla bluzb" ) , "XServiceInfo test failed" );
+ }
+ }
+ else {
+ THROW( IllegalArgumentException() );
+ }
+}
+
+
+INT32 OMarkableInputStreamTest::test( const UString& TestName,
+ const XInterfaceRef& TestObject,
+ INT32 hTestHandle) THROWS( ( IllegalArgumentException,
+ UsrSystemException) )
+{
+ if( L"com.sun.star.io.MarkableInputStream" == TestName ) {
+ try {
+ if( 0 == hTestHandle ) {
+ testInvariant( TestName , TestObject );
+ }
+ else {
+ XInterfaceRef x = m_rFactory->createInstance( L"com.sun.star.io.Pipe");
+ XOutputStreamRef rPipeOutput( x , USR_QUERY );
+ XInputStreamRef rPipeInput( x , USR_QUERY );
+
+ XActiveDataSinkRef sink( TestObject , USR_QUERY );
+ sink->setInputStream( rPipeInput );
+
+ XInputStreamRef rInput( TestObject , USR_QUERY );
+
+ OSL_ASSERT( rPipeOutput.is() );
+ OSL_ASSERT( rInput.is() );
+ if( 1 == hTestHandle ) {
+ // checks usual streaming
+ testSimple( rPipeOutput , rInput );
+ }
+ }
+
+ }
+ catch( Exception& e ) {
+ BUILD_ERROR( 0 , UStringToString( e.getName() , CHARSET_SYSTEM ).GetCharStr() );
+ }
+ catch(...) {
+ BUILD_ERROR( 0 , "unknown exception (Exception is not base class)" );
+ }
+
+ hTestHandle ++;
+
+ if( 2 == hTestHandle ) {
+ // all tests finished.
+ hTestHandle = -1;
+ }
+ }
+ else {
+ THROW( IllegalArgumentException() );
+ }
+ return hTestHandle;
+}
+
+
+
+BOOL OMarkableInputStreamTest::testPassed(void) THROWS( (UsrSystemException) )
+{
+ return m_seqErrors.getLen() == 0;
+}
+
+
+Sequence< UString > OMarkableInputStreamTest::getErrors(void) THROWS( (UsrSystemException) )
+{
+ return m_seqErrors;
+}
+
+
+Sequence< UsrAny > OMarkableInputStreamTest::getErrorExceptions(void) THROWS( (UsrSystemException) )
+{
+ return m_seqExceptions;
+}
+
+
+Sequence< UString > OMarkableInputStreamTest::getWarnings(void) THROWS( (UsrSystemException) )
+{
+ return m_seqWarnings;
+}
+
+
+void OMarkableInputStreamTest::testSimple( const XOutputStreamRef &rOutput ,
+ const XInputStreamRef &rInput )
+{
+ XMarkableStreamRef rMarkable( rInput , USR_QUERY );
+
+ Sequence<BYTE> seqWrite( 256 );
+ Sequence<BYTE> seqRead(10);
+
+ for( int i = 0 ; i < 256 ; i ++ )
+ {
+ seqWrite.getArray()[i] = i;
+ }
+
+ rOutput->writeBytes( seqWrite );
+ ERROR_ASSERT( 256 == rInput->available() , "basic read/write failure" );
+
+ rInput->readBytes( seqRead , 10 );
+ ERROR_ASSERT( 9 == seqRead.getArray()[9] , "basic read/write failure" );
+
+ INT32 nMark = rMarkable->createMark();
+
+ rInput->skipBytes( 50 );
+ ERROR_ASSERT( 256-10-50 == rInput->available() , "marking error" );
+ ERROR_ASSERT( 50 == rMarkable->offsetToMark( nMark ) , "marking error" );
+
+ rMarkable->jumpToMark( nMark );
+ ERROR_ASSERT( 256-10 == rInput->available() , "marking error" );
+
+ rInput->readBytes( seqRead , 10 );
+ ERROR_ASSERT( 10 == seqRead.getArray()[0] , "marking error" );
+
+ // pos 20
+ {
+ INT32 nInBetweenMark = rMarkable->createMark( );
+ rMarkable->jumpToMark( nMark );
+ rMarkable->jumpToMark( nInBetweenMark );
+
+ rInput->readBytes( seqRead , 10 );
+ ERROR_ASSERT( 20 == seqRead.getArray()[0] , "Inbetween mark failed!\n" );
+
+ rMarkable->deleteMark( nMark );
+
+ // Check if releasing the first bytes works correct.
+ rMarkable->jumpToMark( nInBetweenMark);
+ rInput->readBytes( seqRead , 10 );
+ ERROR_ASSERT( 20 == seqRead.getArray()[0] , "Inbetween mark failed!\n" );
+
+ rMarkable->deleteMark( nInBetweenMark );
+ }
+
+ rMarkable->jumpToFurthest();
+ ERROR_ASSERT( 256-10-50 == rInput->available() , "marking error" );
+
+
+ ERROR_ASSERT( 100 == rInput->readSomeBytes( seqRead , 100 ) , "wrong results using readSomeBytes" );
+ ERROR_ASSERT( 96 == rInput->readSomeBytes( seqRead , 1000) , "wrong results using readSomeBytes" );
+ rOutput->closeOutput();
+ rInput->closeInput();
+}
+
+/***
+* the test methods
+*
+****/
+
+
+
+
+
+/**
+* for external binding
+*
+*
+**/
+XInterfaceRef OMarkableInputStreamTest_CreateInstance( const XMultiServiceFactoryRef & rSMgr ) THROWS((Exception))
+{
+ OMarkableInputStreamTest *p = new OMarkableInputStreamTest( rSMgr );
+ XInterfaceRef xService = *p;
+ return xService;
+}
+
+
+
+Sequence<UString> OMarkableInputStreamTest_getSupportedServiceNames(void) THROWS( () )
+{
+ Sequence<UString> aRet(1);
+ aRet.getArray()[0] = OMarkableInputStreamTest_getImplementationName();
+
+ return aRet;
+}
+
+UString OMarkableInputStreamTest_getServiceName() THROWS( () )
+{
+ return L"test.com.sun.star.io.MarkableInputStream";
+}
+
+UString OMarkableInputStreamTest_getImplementationName() THROWS( () )
+{
+ return L"test.com.sun.star.extensions.stm.MarkableInputStream";
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/test/stm/pipetest.cxx b/extensions/test/stm/pipetest.cxx
new file mode 100644
index 000000000000..d3de76bd9766
--- /dev/null
+++ b/extensions/test/stm/pipetest.cxx
@@ -0,0 +1,450 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+#include <smart/com/sun/star/test/XSimpleTest.hxx>
+#include <smart/com/sun/star/io/XOutputStream.hxx>
+#include <smart/com/sun/star/io/XInputStream.hxx>
+
+#include <smart/com/sun/star/lang/XServiceInfo.hxx>
+
+#include <usr/factoryhlp.hxx>
+
+#include <usr/reflserv.hxx> // for EXTERN_SERVICE_CALLTYPE
+#include <usr/weak.hxx> // OWeakObject
+
+#include <osl/conditn.hxx>
+#include <osl/mutex.hxx>
+#include <osl/thread.hxx>
+
+#include <string.h>
+
+#include "testfactreg.hxx"
+#define IMPLEMENTATION_NAME L"test.com.sun.star.comp.extensions.stm.Pipe"
+#define SERVICE_NAME L"test.com.sun.star.io.Pipe"
+
+#ifndef _VOS_NO_NAMESPACE
+using namespace usr;
+#endif
+
+class WriteToStreamThread :
+ public osl::Thread
+{
+
+public:
+
+ WriteToStreamThread( XOutputStreamRef xOutput , int iMax )
+ {
+ m_output = xOutput;
+ m_iMax = iMax;
+ }
+
+ virtual ~WriteToStreamThread() {}
+
+
+protected:
+
+ /// Working method which should be overridden.
+ virtual void run() {
+ for( int i = 0 ; i < m_iMax ; i ++ ) {
+ m_output->writeBytes( createIntSeq(i) );
+ }
+ m_output->closeOutput();
+ }
+
+ /** Called when run() is done.
+ * You might want to override it to do some cleanup.
+ */
+ virtual void onTerminated()
+ {
+ delete this;
+ }
+
+
+private:
+
+ XOutputStreamRef m_output;
+ int m_iMax;
+};
+
+
+
+class OPipeTest :
+ public XSimpleTest,
+ public OWeakObject
+{
+public:
+ OPipeTest( const XMultiServiceFactoryRef & rFactory );
+ ~OPipeTest();
+
+public: // refcounting
+ BOOL queryInterface( Uik aUik, XInterfaceRef & rOut );
+ void acquire() { OWeakObject::acquire(); }
+ void release() { OWeakObject::release(); }
+ void* getImplementation(Reflection *p) { return OWeakObject::getImplementation(p); }
+
+public: // implementation names
+ static Sequence< UString > getSupportedServiceNames_Static(void) THROWS( () );
+ static UString getImplementationName_Static() THROWS( () );
+
+public:
+ virtual void testInvariant(const UString& TestName, const XInterfaceRef& TestObject)
+ THROWS( ( IllegalArgumentException,
+ UsrSystemException) );
+
+ virtual INT32 test( const UString& TestName,
+ const XInterfaceRef& TestObject,
+ INT32 hTestHandle) THROWS( ( IllegalArgumentException,
+ UsrSystemException) );
+
+ virtual BOOL testPassed(void) THROWS( ( UsrSystemException) );
+ virtual Sequence< UString > getErrors(void) THROWS( (UsrSystemException) );
+ virtual Sequence< UsrAny > getErrorExceptions(void) THROWS( (UsrSystemException) );
+ virtual Sequence< UString > getWarnings(void) THROWS( (UsrSystemException) );
+
+private:
+ void testSimple( const XInterfaceRef & );
+ void testBufferResizing( const XInterfaceRef & );
+ void testMultithreading( const XInterfaceRef & );
+
+private:
+ Sequence<UsrAny> m_seqExceptions;
+ Sequence<UString> m_seqErrors;
+ Sequence<UString> m_seqWarnings;
+
+};
+
+
+
+OPipeTest::OPipeTest( const XMultiServiceFactoryRef &rFactory )
+{
+
+}
+
+OPipeTest::~OPipeTest()
+{
+
+}
+
+
+BOOL OPipeTest::queryInterface( Uik uik , XInterfaceRef &rOut )
+{
+ if( XSimpleTest::getSmartUik() == uik ) {
+ rOut = (XSimpleTest *) this;
+ }
+ else {
+ return OWeakObject::queryInterface( uik , rOut );
+ }
+ return TRUE;
+}
+
+
+void OPipeTest::testInvariant( const UString& TestName, const XInterfaceRef& TestObject )
+ THROWS( ( IllegalArgumentException,
+ UsrSystemException) )
+{
+ XServiceInfoRef info( TestObject, USR_QUERY );
+ ERROR_ASSERT( info.is() , "XServiceInfo not supported !" );
+ if( info.is() )
+ {
+ ERROR_ASSERT( info->supportsService( TestName ), "XServiceInfo test failed" );
+ ERROR_ASSERT( ! info->supportsService( L"bla bluzb" ) , "XServiceInfo test failed" );
+ }
+
+}
+
+
+INT32 OPipeTest::test( const UString& TestName,
+ const XInterfaceRef& TestObject,
+ INT32 hTestHandle) THROWS( ( IllegalArgumentException,
+ UsrSystemException) )
+{
+ if( L"com.sun.star.io.Pipe" == TestName ) {
+ try {
+ if( 0 == hTestHandle ) {
+ testInvariant( TestName , TestObject );
+ }
+ else if( 1 == hTestHandle ) {
+ testSimple( TestObject );
+ }
+ else if( 2 == hTestHandle ) {
+ testBufferResizing( TestObject );
+ }
+ else if( 3 == hTestHandle ) {
+ testMultithreading( TestObject );
+ }
+ }
+ catch( Exception& e ) {
+ BUILD_ERROR( 0 , UStringToString( e.getName() , CHARSET_SYSTEM ).GetCharStr() );
+ }
+ catch(...) {
+ BUILD_ERROR( 0 , "unknown exception (Exception is not base class)" );
+ }
+
+ hTestHandle ++;
+
+ if( 4 == hTestHandle ) {
+ // all tests finished.
+ hTestHandle = -1;
+ }
+ }
+ else {
+ THROW( IllegalArgumentException() );
+ }
+ return hTestHandle;
+}
+
+
+
+BOOL OPipeTest::testPassed(void) THROWS( (UsrSystemException) )
+{
+ return m_seqErrors.getLen() == 0;
+}
+
+
+Sequence< UString > OPipeTest::getErrors(void) THROWS( (UsrSystemException) )
+{
+ return m_seqErrors;
+}
+
+
+Sequence< UsrAny > OPipeTest::getErrorExceptions(void) THROWS( (UsrSystemException) )
+{
+ return m_seqExceptions;
+}
+
+
+Sequence< UString > OPipeTest::getWarnings(void) THROWS( (UsrSystemException) )
+{
+ return m_seqWarnings;
+}
+
+
+/***
+* the test methods
+*
+****/
+
+
+void OPipeTest::testSimple( const XInterfaceRef &r )
+{
+
+ XInputStreamRef input( r , USR_QUERY );
+ XOutputStreamRef output( r , USR_QUERY );
+
+ ERROR_ASSERT( input.is() , "queryInterface on XInputStream failed" );
+ ERROR_ASSERT( output.is() , "queryInterface onXOutputStream failed" );
+
+ // basic read/write
+ Sequence<BYTE> seqWrite = createSeq( "Hallo, du Ei !" );
+
+ Sequence<BYTE> seqRead;
+ for( int i = 0 ; i < 5000 ; i ++ ) {
+ output->writeBytes( seqWrite );
+ input->readBytes( seqRead , input->available() );
+
+ ERROR_ASSERT( ! strcmp( (char *) seqWrite.getArray() , (char * )seqRead.getArray() ) ,
+ "error during read/write/skip" );
+ ERROR_ASSERT( 0 == input->available() ,
+ "error during read/write/skip" );
+
+ // available shouldn't return a negative value
+ input->skipBytes( seqWrite.getLen() - 5 );
+ ERROR_ASSERT( 0 == input->available() , "wrong available after skip" );
+
+ // 5 bytes should be available
+ output->writeBytes( seqWrite );
+ ERROR_ASSERT( 5 == input->available() , "wrong available after skip/write " );
+
+ input->readBytes( seqRead , 5 );
+ ERROR_ASSERT( ! strcmp( (char*) seqRead.getArray() ,
+ (char*) &( seqWrite.getArray()[seqWrite.getLen()-5] ) ),
+ "write/read mismatich" );
+
+ }
+
+ output->writeBytes( seqWrite );
+ ERROR_ASSERT( seqWrite.getLen() == input->available(), "wrong available() after write" );
+
+ ERROR_ASSERT( 10 == input->readSomeBytes( seqRead , 10 ) , "maximal number of bytes ignored" );
+ ERROR_ASSERT( seqWrite.getLen() -10 == input->readSomeBytes( seqRead , 100 ) ,
+ "something wrong with readSomeBytes" );
+
+
+ output->closeOutput();
+ try {
+ output->writeBytes( Sequence<BYTE> (100) );
+ ERROR_ASSERT( 0 , "writing on a closed stream does not cause an exception" );
+ }
+ catch (IOException& e ) {
+ e; // just to suppress warning during compile
+ }
+
+ ERROR_ASSERT(! input->readBytes( seqRead , 1 ), "eof not found !" );
+
+ input->closeInput();
+ try {
+ input->readBytes( seqRead , 1 );
+ ERROR_ASSERT( 0 , "reading from a closed stream does not cause an exception" );
+ }
+ catch( IOException& e ) {
+ e; // just to suppress warning during compile
+ }
+
+}
+
+void OPipeTest::testBufferResizing( const XInterfaceRef &r )
+{
+
+ int iMax = 20000;
+ XInputStreamRef input( r , USR_QUERY );
+ XOutputStreamRef output( r , USR_QUERY );
+
+ ERROR_ASSERT( input.is() , "queryInterface on XInputStream failed" );
+ ERROR_ASSERT( output.is() , "queryInterface on XOutputStream failed" );
+
+ Sequence<BYTE> seqRead;
+
+ // this is just to better check the
+ // internal buffers
+ output->writeBytes( Sequence<BYTE>(100) );
+ input->readBytes( Sequence<BYTE>() , 100);
+
+ for( int i = 0 ; i < iMax ; i ++ ) {
+ output->writeBytes( createIntSeq( i ) );
+ }
+
+ for( i = 0 ; i < iMax ; i ++ ) {
+ input->readBytes( seqRead, createIntSeq(i).getLen() );
+ ERROR_ASSERT( ! strcmp( (char*) seqRead.getArray() ,
+ (char*) createIntSeq(i).getArray() ) ,
+ "written/read mismatch\n" );
+ }
+
+ output->closeOutput();
+ ERROR_ASSERT( ! input->readBytes( seqRead , 1 ) , "eof not reached !" );
+ input->closeInput();
+}
+
+
+
+void OPipeTest::testMultithreading( const XInterfaceRef &r )
+{
+
+
+ int iMax = 30000;
+
+ XInputStreamRef input( r , USR_QUERY );
+ XOutputStreamRef output( r , USR_QUERY );
+
+ ERROR_ASSERT( input.is() , "queryInterface on XInputStream failed" );
+ ERROR_ASSERT( output.is() , "queryInterface on XOutputStream failed" );
+
+ Sequence<BYTE> seqRead;
+
+ // deletes itself
+ osl::Thread *p = new WriteToStreamThread( output, iMax );
+
+ ERROR_ASSERT( p , "couldn't create thread for testing !\n" );
+
+ p->create();
+
+ for(int i = 0 ; TRUE ; i ++ ) {
+ if( 0 == input->readBytes( seqRead, createIntSeq(i).getLen() ) ) {
+ // eof reached !
+ break;
+ }
+
+ ERROR_ASSERT( ! strcmp( (char*) seqRead.getArray() ,
+ (char*) createIntSeq(i).getArray() ) ,
+ "written/read mismatch\n" );
+ }
+
+ ERROR_ASSERT( i == iMax , "less elements read than written !");
+ input->closeInput();
+}
+
+/* {
+ try {
+ XInterfaceRef x = xSMgr->createInstance( strService );
+
+ XInputStreamRef input( x , USR_QUERY );
+ XOutputStreamRef output( x , USR_QUERY );
+
+ OSL_ASSERT( output.is() );
+ while( TRUE ) {
+ // basic read/write
+ Sequence<BYTE> seqWrite( 500 );
+ output->writeBytes( seqWrite );
+
+ }
+ }
+ catch( IOException& e ) {
+ printf( "%s %s\n" , UStringToString( e.getName() , CHARSET_SYSTEM ).GetCharStr() ,
+ UStringToString( e.Message , CHARSET_SYSTEM ).GetCharStr() );
+ }
+ }
+*/
+
+
+
+
+/**
+* for external binding
+*
+*
+**/
+XInterfaceRef OPipeTest_CreateInstance( const XMultiServiceFactoryRef & rSMgr ) THROWS((Exception))
+{
+ OPipeTest *p = new OPipeTest( rSMgr );
+ XInterfaceRef xService = *p;
+ return xService;
+}
+
+
+
+Sequence<UString> OPipeTest_getSupportedServiceNames(void) THROWS( () )
+{
+ Sequence<UString> aRet(1);
+ aRet.getArray()[0] = OPipeTest_getImplementationName();
+
+ return aRet;
+}
+
+UString OPipeTest_getServiceName() THROWS( () )
+{
+ return SERVICE_NAME;
+}
+
+UString OPipeTest_getImplementationName() THROWS( () )
+{
+ return IMPLEMENTATION_NAME;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/test/stm/testfactreg.cxx b/extensions/test/stm/testfactreg.cxx
new file mode 100644
index 000000000000..0ebfa87c57d1
--- /dev/null
+++ b/extensions/test/stm/testfactreg.cxx
@@ -0,0 +1,173 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+#include <string.h>
+
+#include <usr/reflserv.hxx> // for EXTERN_SERVICE_CALLTYPE
+
+#include <usr/factoryhlp.hxx>
+#include "testfactreg.hxx"
+
+
+#ifndef _VOS_NO_NAMESPACE
+using namespace usr;
+#endif
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+BOOL EXTERN_SERVICE_CALLTYPE exService_writeRegEntry(
+ const UNO_INTERFACE(XRegistryKey)* xUnoKey)
+
+{
+ XRegistryKeyRef xKey;
+ uno2smart(xKey, *xUnoKey);
+
+ UString str = UString( L"/" ) + OPipeTest_getImplementationName() + UString( L"/UNO/SERVICES" );
+ XRegistryKeyRef xNewKey = xKey->createKey( str );
+ xNewKey->createKey( OPipeTest_getServiceName() );
+
+ str = UString( L"/" ) + ODataStreamTest_getImplementationName(1) + UString( L"/UNO/SERVICES" );
+ xNewKey = xKey->createKey( str );
+ xNewKey->createKey( ODataStreamTest_getServiceName(1) );
+
+ str = UString( L"/" ) + ODataStreamTest_getImplementationName(2) + UString( L"/UNO/SERVICES" );
+ xNewKey = xKey->createKey( str );
+ xNewKey->createKey( ODataStreamTest_getServiceName(2) );
+
+ str = UString( L"/" ) + OObjectStreamTest_getImplementationName(1) + UString( L"/UNO/SERVICES" );
+ xNewKey = xKey->createKey( str );
+ xNewKey->createKey( OObjectStreamTest_getServiceName(1) );
+
+ str = UString( L"/" ) + OObjectStreamTest_getImplementationName(2) + UString( L"/UNO/SERVICES" );
+ xNewKey = xKey->createKey( str );
+ xNewKey->createKey( OObjectStreamTest_getServiceName(2) );
+
+ str = UString( L"/" ) + OMarkableOutputStreamTest_getImplementationName() + UString( L"/UNO/SERVICES" );
+ xNewKey = xKey->createKey( str );
+ xNewKey->createKey( OMarkableOutputStreamTest_getServiceName() );
+
+ str = UString( L"/" ) + OMarkableInputStreamTest_getImplementationName() + UString( L"/UNO/SERVICES" );
+ xNewKey = xKey->createKey( str );
+ xNewKey->createKey( OMarkableInputStreamTest_getServiceName() );
+
+ str = UString( L"/" ) + OMyPersistObject_getImplementationName() + UString( L"/UNO/SERVICES" );
+ xNewKey = xKey->createKey( str );
+ xNewKey->createKey( OMyPersistObject_getServiceName() );
+
+ return TRUE;
+}
+
+
+UNO_INTERFACE(XInterface) EXTERN_SERVICE_CALLTYPE exService_getFactory
+(
+ const wchar_t* implementationName,
+ const UNO_INTERFACE(XMultiServiceFactory)* xUnoFact,
+ const UNO_INTERFACE(XRegistryKey)*
+)
+{
+ UNO_INTERFACE(XInterface) xUnoRet = {0, 0};
+
+ XInterfaceRef xRet;
+ XMultiServiceFactoryRef xSMgr;
+ UString aImplementationName(implementationName);
+
+ uno2smart(xSMgr, *xUnoFact);
+
+ if (aImplementationName == OPipeTest_getImplementationName() )
+ {
+ xRet = createSingleFactory( xSMgr, implementationName,
+ OPipeTest_CreateInstance,
+ OPipeTest_getSupportedServiceNames() );
+ }
+ else if( aImplementationName == ODataStreamTest_getImplementationName(1) ) {
+ xRet = createSingleFactory( xSMgr , implementationName,
+ ODataStreamTest_CreateInstance,
+ ODataStreamTest_getSupportedServiceNames(1) );
+ }
+ else if( aImplementationName == ODataStreamTest_getImplementationName(2) ) {
+ xRet = createSingleFactory( xSMgr , implementationName,
+ ODataStreamTest_CreateInstance,
+ ODataStreamTest_getSupportedServiceNames(2) );
+ }
+ else if( aImplementationName == OObjectStreamTest_getImplementationName(1) ) {
+ xRet = createSingleFactory( xSMgr , implementationName,
+ OObjectStreamTest_CreateInstance,
+ OObjectStreamTest_getSupportedServiceNames(1) );
+ }
+ else if( aImplementationName == OObjectStreamTest_getImplementationName(2) ) {
+ xRet = createSingleFactory( xSMgr , implementationName,
+ OObjectStreamTest_CreateInstance,
+ OObjectStreamTest_getSupportedServiceNames(2) );
+ }
+ else if( aImplementationName == OMarkableOutputStreamTest_getImplementationName() ) {
+ xRet = createSingleFactory( xSMgr , implementationName,
+ OMarkableOutputStreamTest_CreateInstance,
+ OMarkableOutputStreamTest_getSupportedServiceNames() );
+ }
+ else if( aImplementationName == OMarkableInputStreamTest_getImplementationName() ) {
+ xRet = createSingleFactory( xSMgr , implementationName,
+ OMarkableInputStreamTest_CreateInstance,
+ OMarkableInputStreamTest_getSupportedServiceNames() );
+ }
+ else if( aImplementationName == OMyPersistObject_getImplementationName() ) {
+ xRet = createSingleFactory( xSMgr , implementationName,
+ OMyPersistObject_CreateInstance,
+ OMyPersistObject_getSupportedServiceNames() );
+ }
+ if (xRet.is())
+ {
+ smart2uno(xRet, xUnoRet);
+ }
+
+ return xUnoRet;
+}
+
+#ifdef __cplusplus
+}
+#endif
+
+Sequence<BYTE> createSeq( char * p )
+{
+ Sequence<BYTE> seq( strlen( p )+1 );
+ strcpy( (char * ) seq.getArray() , p );
+ return seq;
+}
+
+Sequence<BYTE> createIntSeq( INT32 i )
+{
+ char pcCount[20];
+ sprintf( pcCount , "%d" , i );
+ return createSeq( pcCount );
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/test/stm/testfactreg.hxx b/extensions/test/stm/testfactreg.hxx
new file mode 100644
index 000000000000..07e192a94071
--- /dev/null
+++ b/extensions/test/stm/testfactreg.hxx
@@ -0,0 +1,113 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+XInterfaceRef OPipeTest_CreateInstance( const XMultiServiceFactoryRef & rSMgr ) THROWS((Exception));
+Sequence<UString> OPipeTest_getSupportedServiceNames(void) THROWS( () );
+UString OPipeTest_getServiceName() THROWS( () );
+UString OPipeTest_getImplementationName() THROWS( () );
+
+XInterfaceRef ODataStreamTest_CreateInstance( const XMultiServiceFactoryRef & rSMgr ) THROWS((Exception));
+Sequence<UString> ODataStreamTest_getSupportedServiceNames( int i) THROWS( () );
+UString ODataStreamTest_getServiceName( int i) THROWS( ( ) );
+UString ODataStreamTest_getImplementationName( int i) THROWS( () );
+
+XInterfaceRef OMarkableOutputStreamTest_CreateInstance( const XMultiServiceFactoryRef & rSMgr ) THROWS((Exception));
+Sequence<UString> OMarkableOutputStreamTest_getSupportedServiceNames(void) THROWS( () );
+UString OMarkableOutputStreamTest_getServiceName() THROWS( () );
+UString OMarkableOutputStreamTest_getImplementationName() THROWS( () );
+
+XInterfaceRef OMarkableInputStreamTest_CreateInstance( const XMultiServiceFactoryRef & rSMgr ) THROWS((Exception));
+Sequence<UString> OMarkableInputStreamTest_getSupportedServiceNames(void) THROWS( () );
+UString OMarkableInputStreamTest_getServiceName() THROWS( () );
+UString OMarkableInputStreamTest_getImplementationName() THROWS( () );
+
+XInterfaceRef OObjectStreamTest_CreateInstance( const XMultiServiceFactoryRef & rSMgr ) THROWS((Exception));
+Sequence<UString> OObjectStreamTest_getSupportedServiceNames( int i) THROWS( () );
+UString OObjectStreamTest_getServiceName( int i) THROWS( () );
+UString OObjectStreamTest_getImplementationName( int i) THROWS( () );
+
+XInterfaceRef OMyPersistObject_CreateInstance( const XMultiServiceFactoryRef & rSMgr ) THROWS((Exception));
+Sequence<UString> OMyPersistObject_getSupportedServiceNames( ) THROWS( () );
+UString OMyPersistObject_getServiceName( ) THROWS( () );
+UString OMyPersistObject_getImplementationName( ) THROWS( () );
+
+Sequence<BYTE> createSeq( char * p );
+Sequence<BYTE> createIntSeq( INT32 i );
+
+#define BUILD_ERROR(expr, Message)\
+ {\
+ m_seqErrors.realloc( m_seqErrors.getLen() + 1 ); \
+ m_seqExceptions.realloc( m_seqExceptions.getLen() + 1 ); \
+ String str; \
+ str += __FILE__;\
+ str += " "; \
+ str += "(" ; \
+ str += __LINE__ ;\
+ str += ")\n";\
+ str += "[ " ; \
+ str += #expr; \
+ str += " ] : " ; \
+ str += Message; \
+ m_seqErrors.getArray()[ m_seqErrors.getLen()-1] = StringToOUString( str , CHARSET_SYSTEM ); \
+ }\
+ ((void)0)
+
+
+#define WARNING_ASSERT(expr, Message) \
+ if( ! (expr) ) { \
+ m_seqWarnings.realloc( m_seqErrors.getLen() +1 ); \
+ String str;\
+ str += __FILE__;\
+ str += " "; \
+ str += "(" ; \
+ str += __LINE__ ;\
+ str += ")\n";\
+ str += "[ " ; \
+ str += #expr; \
+ str += " ] : " ; \
+ str += Message; \
+ m_seqWarnings.getArray()[ m_seqWarnings.getLen()-1] = StringToOUString( str , CHARSET_SYSTEM ); \
+ return; \
+ }\
+ ((void)0)
+
+#define ERROR_ASSERT(expr, Message) \
+ if( ! (expr) ) { \
+ BUILD_ERROR(expr, Message );\
+ return; \
+ }\
+ ((void)0)
+
+#define ERROR_EXCEPTION_ASSERT(expr, Message, Exception) \
+ if( !(expr)) { \
+ BUILD_ERROR(expr,Message);\
+ m_seqExceptions.getArray()[ m_seqExceptions.getLen()-1] = UsrAny( Exception );\
+ return; \
+ } \
+ ((void)0)
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/util/hidother.src b/extensions/util/hidother.src
new file mode 100644
index 000000000000..48f2e8ec8aba
--- /dev/null
+++ b/extensions/util/hidother.src
@@ -0,0 +1,428 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "../inc/abpilot.hrc"
+#include "../inc/bibliography.hrc"
+#include "../inc/dbpilots.hrc"
+#include "../inc/propctrlr.hrc"
+#include "../inc/update.hrc"
+
+hidspecial HID_ABSPILOT { HelpId = HID_ABSPILOT; }
+hidspecial HID_ABSPILOT_CANCEL { HelpId = HID_ABSPILOT_CANCEL; }
+hidspecial HID_ABSPILOT_FINISH { HelpId = HID_ABSPILOT_FINISH; }
+hidspecial HID_ABSPILOT_NEXT { HelpId = HID_ABSPILOT_NEXT; }
+hidspecial HID_ABSPILOT_PREVIOUS { HelpId = HID_ABSPILOT_PREVIOUS; }
+
+hidspecial HID_BIB_ADDRESS_POS { HelpId = HID_BIB_ADDRESS_POS; }
+hidspecial HID_BIB_ANNOTE_POS { HelpId = HID_BIB_ANNOTE_POS; }
+hidspecial HID_BIB_AUTHORITYTYPE_POS { HelpId = HID_BIB_AUTHORITYTYPE_POS; }
+hidspecial HID_BIB_AUTHOR_POS { HelpId = HID_BIB_AUTHOR_POS; }
+hidspecial HID_BIB_BOOKTITLE_POS { HelpId = HID_BIB_BOOKTITLE_POS; }
+hidspecial HID_BIB_CHANGESOURCE { HelpId = HID_BIB_CHANGESOURCE; }
+hidspecial HID_BIB_CHAPTER_POS { HelpId = HID_BIB_CHAPTER_POS; }
+hidspecial HID_BIB_CONTROL_PAGE { HelpId = HID_BIB_CONTROL_PAGE; }
+hidspecial HID_BIB_CONTROL_PARENT { HelpId = HID_BIB_CONTROL_PARENT; }
+hidspecial HID_BIB_CUSTOM1_POS { HelpId = HID_BIB_CUSTOM1_POS; }
+hidspecial HID_BIB_CUSTOM2_POS { HelpId = HID_BIB_CUSTOM2_POS; }
+hidspecial HID_BIB_CUSTOM3_POS { HelpId = HID_BIB_CUSTOM3_POS; }
+hidspecial HID_BIB_CUSTOM4_POS { HelpId = HID_BIB_CUSTOM4_POS; }
+hidspecial HID_BIB_CUSTOM5_POS { HelpId = HID_BIB_CUSTOM5_POS; }
+hidspecial HID_BIB_DB_GRIDCTRL { HelpId = HID_BIB_DB_GRIDCTRL; }
+hidspecial HID_BIB_DB_TBX { HelpId = HID_BIB_DB_TBX; }
+hidspecial HID_BIB_DELETE_RECORD { HelpId = HID_BIB_DELETE_RECORD; }
+hidspecial HID_BIB_EDITION_POS { HelpId = HID_BIB_EDITION_POS; }
+hidspecial HID_BIB_EDITOR_POS { HelpId = HID_BIB_EDITOR_POS; }
+hidspecial HID_BIB_HOWPUBLISHED_POS { HelpId = HID_BIB_HOWPUBLISHED_POS; }
+hidspecial HID_BIB_IDENTIFIER_POS { HelpId = HID_BIB_IDENTIFIER_POS; }
+hidspecial HID_BIB_INSERT_RECORD { HelpId = HID_BIB_INSERT_RECORD; }
+hidspecial HID_BIB_INSTITUTION_POS { HelpId = HID_BIB_INSTITUTION_POS; }
+hidspecial HID_BIB_ISBN_POS { HelpId = HID_BIB_ISBN_POS; }
+hidspecial HID_BIB_JOURNAL_POS { HelpId = HID_BIB_JOURNAL_POS; }
+hidspecial HID_BIB_MAPPINGDLG { HelpId = HID_BIB_MAPPINGDLG; }
+hidspecial HID_BIB_MONTH_POS { HelpId = HID_BIB_MONTH_POS; }
+hidspecial HID_BIB_NOTE_POS { HelpId = HID_BIB_NOTE_POS; }
+hidspecial HID_BIB_NUMBER_POS { HelpId = HID_BIB_NUMBER_POS; }
+hidspecial HID_BIB_ORGANIZATIONS_POS { HelpId = HID_BIB_ORGANIZATIONS_POS; }
+hidspecial HID_BIB_PAGES_POS { HelpId = HID_BIB_PAGES_POS; }
+hidspecial HID_BIB_PUBLISHER_POS { HelpId = HID_BIB_PUBLISHER_POS; }
+hidspecial HID_BIB_REPORTTYPE_POS { HelpId = HID_BIB_REPORTTYPE_POS; }
+hidspecial HID_BIB_SCHOOL_POS { HelpId = HID_BIB_SCHOOL_POS; }
+hidspecial HID_BIB_SERIES_POS { HelpId = HID_BIB_SERIES_POS; }
+hidspecial HID_BIB_TBX_AUTOFILTER { HelpId = HID_BIB_TBX_AUTOFILTER; }
+hidspecial HID_BIB_TBX_SEARCH { HelpId = HID_BIB_TBX_SEARCH; }
+hidspecial HID_BIB_TBX_TABLE { HelpId = HID_BIB_TBX_TABLE; }
+hidspecial HID_BIB_TITLE_POS { HelpId = HID_BIB_TITLE_POS; }
+hidspecial HID_BIB_URL_POS { HelpId = HID_BIB_URL_POS; }
+hidspecial HID_BIB_VOLUME_POS { HelpId = HID_BIB_VOLUME_POS; }
+hidspecial HID_BIB_YEAR_POS { HelpId = HID_BIB_YEAR_POS; }
+
+hidspecial HID_CHECK_FOR_UPD_CANCEL { HelpId = HID_CHECK_FOR_UPD_CANCEL; }
+hidspecial HID_CHECK_FOR_UPD_CLOSE { HelpId = HID_CHECK_FOR_UPD_CLOSE; }
+hidspecial HID_CHECK_FOR_UPD_DESCRIPTION { HelpId = HID_CHECK_FOR_UPD_DESCRIPTION; }
+hidspecial HID_CHECK_FOR_UPD_DLG { HelpId = HID_CHECK_FOR_UPD_DLG; }
+hidspecial HID_CHECK_FOR_UPD_DOWNLOAD { HelpId = HID_CHECK_FOR_UPD_DOWNLOAD; }
+hidspecial HID_CHECK_FOR_UPD_DOWNLOAD2 { HelpId = HID_CHECK_FOR_UPD_DOWNLOAD2; }
+hidspecial HID_CHECK_FOR_UPD_INSTALL { HelpId = HID_CHECK_FOR_UPD_INSTALL; }
+hidspecial HID_CHECK_FOR_UPD_PAUSE { HelpId = HID_CHECK_FOR_UPD_PAUSE; }
+hidspecial HID_CHECK_FOR_UPD_RESUME { HelpId = HID_CHECK_FOR_UPD_RESUME; }
+hidspecial HID_CHECK_FOR_UPD_STATUS { HelpId = HID_CHECK_FOR_UPD_STATUS; }
+
+hidspecial HID_DLG_DBCHANGE { HelpId = HID_DLG_DBCHANGE; }
+hidspecial HID_DLG_MAPPING { HelpId = HID_DLG_MAPPING; }
+
+hidspecial HID_EVT_ACTIONPERFORMED { HelpId = HID_EVT_ACTIONPERFORMED; }
+hidspecial HID_EVT_ADJUSTMENTVALUECHANGED { HelpId = HID_EVT_ADJUSTMENTVALUECHANGED; }
+hidspecial HID_EVT_AFTERUPDATE { HelpId = HID_EVT_AFTERUPDATE; }
+hidspecial HID_EVT_APPROVEACTIONPERFORMED { HelpId = HID_EVT_APPROVEACTIONPERFORMED; }
+hidspecial HID_EVT_APPROVEPARAMETER { HelpId = HID_EVT_APPROVEPARAMETER; }
+hidspecial HID_EVT_APPROVERESETTED { HelpId = HID_EVT_APPROVERESETTED; }
+hidspecial HID_EVT_APPROVEROWCHANGE { HelpId = HID_EVT_APPROVEROWCHANGE; }
+hidspecial HID_EVT_BEFOREUPDATE { HelpId = HID_EVT_BEFOREUPDATE; }
+hidspecial HID_EVT_CHANGED { HelpId = HID_EVT_CHANGED; }
+hidspecial HID_EVT_CONFIRMDELETE { HelpId = HID_EVT_CONFIRMDELETE; }
+hidspecial HID_EVT_ERROROCCURED { HelpId = HID_EVT_ERROROCCURED; }
+hidspecial HID_EVT_FOCUSGAINED { HelpId = HID_EVT_FOCUSGAINED; }
+hidspecial HID_EVT_FOCUSLOST { HelpId = HID_EVT_FOCUSLOST; }
+hidspecial HID_EVT_ITEMSTATECHANGED { HelpId = HID_EVT_ITEMSTATECHANGED; }
+hidspecial HID_EVT_KEYTYPED { HelpId = HID_EVT_KEYTYPED; }
+hidspecial HID_EVT_KEYUP { HelpId = HID_EVT_KEYUP; }
+hidspecial HID_EVT_LOADED { HelpId = HID_EVT_LOADED; }
+hidspecial HID_EVT_MOUSEDRAGGED { HelpId = HID_EVT_MOUSEDRAGGED; }
+hidspecial HID_EVT_MOUSEENTERED { HelpId = HID_EVT_MOUSEENTERED; }
+hidspecial HID_EVT_MOUSEEXITED { HelpId = HID_EVT_MOUSEEXITED; }
+hidspecial HID_EVT_MOUSEMOVED { HelpId = HID_EVT_MOUSEMOVED; }
+hidspecial HID_EVT_MOUSEPRESSED { HelpId = HID_EVT_MOUSEPRESSED; }
+hidspecial HID_EVT_MOUSERELEASED { HelpId = HID_EVT_MOUSERELEASED; }
+hidspecial HID_EVT_POSITIONED { HelpId = HID_EVT_POSITIONED; }
+hidspecial HID_EVT_POSITIONING { HelpId = HID_EVT_POSITIONING; }
+hidspecial HID_EVT_RELOADED { HelpId = HID_EVT_RELOADED; }
+hidspecial HID_EVT_RELOADING { HelpId = HID_EVT_RELOADING; }
+hidspecial HID_EVT_RESETTED { HelpId = HID_EVT_RESETTED; }
+hidspecial HID_EVT_ROWCHANGE { HelpId = HID_EVT_ROWCHANGE; }
+hidspecial HID_EVT_SUBMITTED { HelpId = HID_EVT_SUBMITTED; }
+hidspecial HID_EVT_TEXTCHANGED { HelpId = HID_EVT_TEXTCHANGED; }
+hidspecial HID_EVT_UNLOADED { HelpId = HID_EVT_UNLOADED; }
+hidspecial HID_EVT_UNLOADING { HelpId = HID_EVT_UNLOADING; }
+
+hidspecial HID_FIELDLINK_DETAIL_COLUMN { HelpId = HID_FIELDLINK_DETAIL_COLUMN; }
+hidspecial HID_FIELDLINK_MASTER_COLUMN { HelpId = HID_FIELDLINK_MASTER_COLUMN; }
+
+hidspecial HID_GRIDWIZARD_CANCEL { HelpId = HID_GRIDWIZARD_CANCEL; }
+hidspecial HID_GRIDWIZARD_FINISH { HelpId = HID_GRIDWIZARD_FINISH; }
+hidspecial HID_GRIDWIZARD_NEXT { HelpId = HID_GRIDWIZARD_NEXT; }
+hidspecial HID_GRIDWIZARD_PREVIOUS { HelpId = HID_GRIDWIZARD_PREVIOUS; };
+hidspecial HID_GROUPWIZARD_CANCEL { HelpId = HID_GROUPWIZARD_CANCEL; }
+hidspecial HID_GROUPWIZARD_FINISH { HelpId = HID_GROUPWIZARD_FINISH; }
+hidspecial HID_GROUPWIZARD_NEXT { HelpId = HID_GROUPWIZARD_NEXT; }
+hidspecial HID_GROUPWIZARD_PREVIOUS { HelpId = HID_GROUPWIZARD_PREVIOUS; }
+
+hidspecial HID_LISTWIZARD_CANCEL { HelpId = HID_LISTWIZARD_CANCEL; }
+hidspecial HID_LISTWIZARD_FINISH { HelpId = HID_LISTWIZARD_FINISH; }
+hidspecial HID_LISTWIZARD_NEXT { HelpId = HID_LISTWIZARD_NEXT; }
+hidspecial HID_LISTWIZARD_PREVIOUS { HelpId = HID_LISTWIZARD_PREVIOUS; }
+
+hidspecial HID_PROP_ALIGN { HelpId = HID_PROP_ALIGN; }
+hidspecial HID_PROP_ALLOW_ADDITIONS { HelpId = HID_PROP_ALLOW_ADDITIONS; }
+hidspecial HID_PROP_ALLOW_DELETIONS { HelpId = HID_PROP_ALLOW_DELETIONS; }
+hidspecial HID_PROP_ALLOW_EDITS { HelpId = HID_PROP_ALLOW_EDITS; }
+hidspecial HID_PROP_ANCHOR_TYPE { HelpId = HID_PROP_ANCHOR_TYPE; }
+hidspecial HID_PROP_AUTOCOMPLETE { HelpId = HID_PROP_AUTOCOMPLETE; }
+hidspecial HID_PROP_AUTOLINEBREAK { HelpId = HID_PROP_AUTOLINEBREAK; }
+hidspecial HID_PROP_BACKGROUNDCOLOR { HelpId = HID_PROP_BACKGROUNDCOLOR; }
+hidspecial HID_PROP_BINDING_NAME { HelpId = HID_PROP_BINDING_NAME; }
+hidspecial HID_PROP_BIND_EXPRESSION { HelpId = HID_PROP_BIND_EXPRESSION; }
+hidspecial HID_PROP_BLOCKINCREMENT { HelpId = HID_PROP_BLOCKINCREMENT; }
+hidspecial HID_PROP_BORDER { HelpId = HID_PROP_BORDER; }
+hidspecial HID_PROP_BORDERCOLOR { HelpId = HID_PROP_BORDERCOLOR; }
+hidspecial HID_PROP_BOUNDCOLUMN { HelpId = HID_PROP_BOUNDCOLUMN; }
+hidspecial HID_PROP_BOUND_CELL { HelpId = HID_PROP_BOUND_CELL; }
+hidspecial HID_PROP_BUTTONTYPE { HelpId = HID_PROP_BUTTONTYPE; }
+hidspecial HID_PROP_CELL_EXCHANGE_TYPE { HelpId = HID_PROP_CELL_EXCHANGE_TYPE; }
+hidspecial HID_PROP_CLASSID { HelpId = HID_PROP_CLASSID; }
+hidspecial HID_PROP_CONTROLLABEL { HelpId = HID_PROP_CONTROLLABEL; }
+hidspecial HID_PROP_CONTROLSOURCE { HelpId = HID_PROP_CONTROLSOURCE; }
+hidspecial HID_PROP_CURRENCYSYMBOL { HelpId = HID_PROP_CURRENCYSYMBOL; }
+hidspecial HID_PROP_CURRSYM_POSITION { HelpId = HID_PROP_CURRSYM_POSITION; }
+hidspecial HID_PROP_CURSORSOURCE { HelpId = HID_PROP_CURSORSOURCE; }
+hidspecial HID_PROP_CURSORSOURCETYPE { HelpId = HID_PROP_CURSORSOURCETYPE; }
+hidspecial HID_PROP_CURSORTYPE { HelpId = HID_PROP_CURSORTYPE; }
+hidspecial HID_PROP_CYCLE { HelpId = HID_PROP_CYCLE; }
+hidspecial HID_PROP_DATAENTRY { HelpId = HID_PROP_DATAENTRY; }
+hidspecial HID_PROP_DATASOURCE { HelpId = HID_PROP_DATASOURCE; }
+hidspecial HID_PROP_DATE { HelpId = HID_PROP_DATE; }
+hidspecial HID_PROP_DATEFORMAT { HelpId = HID_PROP_DATEFORMAT; }
+hidspecial HID_PROP_DATEMAX { HelpId = HID_PROP_DATEMAX; }
+hidspecial HID_PROP_DATEMIN { HelpId = HID_PROP_DATEMIN; }
+hidspecial HID_PROP_DECIMAL_ACCURACY { HelpId = HID_PROP_DECIMAL_ACCURACY; }
+hidspecial HID_PROP_DECORATION { HelpId = HID_PROP_DECORATION; }
+hidspecial HID_PROP_DEFAULTVALUE { HelpId = HID_PROP_DEFAULTVALUE; }
+hidspecial HID_PROP_DEFAULT_BUTTON { HelpId = HID_PROP_DEFAULT_BUTTON; }
+hidspecial HID_PROP_DEFAULT_DATE { HelpId = HID_PROP_DEFAULT_DATE; }
+hidspecial HID_PROP_DEFAULT_LONG_VALUE { HelpId = HID_PROP_DEFAULT_LONG_VALUE; }
+hidspecial HID_PROP_DEFAULT_SCROLLVALUE { HelpId = HID_PROP_DEFAULT_SCROLLVALUE; }
+hidspecial HID_PROP_DEFAULT_SELECT_SEQ { HelpId = HID_PROP_DEFAULT_SELECT_SEQ; }
+hidspecial HID_PROP_DEFAULT_SPINVALUE { HelpId = HID_PROP_DEFAULT_SPINVALUE; }
+hidspecial HID_PROP_DEFAULT_STATE { HelpId = HID_PROP_DEFAULT_STATE; }
+hidspecial HID_PROP_DEFAULT_TIME { HelpId = HID_PROP_DEFAULT_TIME; }
+hidspecial HID_PROP_DIRTY { HelpId = HID_PROP_DIRTY; }
+hidspecial HID_PROP_DROPDOWN { HelpId = HID_PROP_DROPDOWN; }
+hidspecial HID_PROP_ECHO_CHAR { HelpId = HID_PROP_ECHO_CHAR; }
+hidspecial HID_PROP_EDITABLE { HelpId = HID_PROP_EDITABLE; }
+hidspecial HID_PROP_EDITMASK { HelpId = HID_PROP_EDITMASK; }
+hidspecial HID_PROP_EFFECTIVEDEFAULT { HelpId = HID_PROP_EFFECTIVEDEFAULT; }
+hidspecial HID_PROP_EFFECTIVEMAX { HelpId = HID_PROP_EFFECTIVEMAX; }
+hidspecial HID_PROP_EFFECTIVEMIN { HelpId = HID_PROP_EFFECTIVEMIN; }
+hidspecial HID_PROP_EMPTY_IS_NULL { HelpId = HID_PROP_EMPTY_IS_NULL; }
+hidspecial HID_PROP_ENABLED { HelpId = HID_PROP_ENABLED; }
+hidspecial HID_PROP_ENABLE_VISIBLE { HelpId = HID_PROP_ENABLE_VISIBLE; }
+hidspecial HID_PROP_ESCAPE_PROCESSING { HelpId = HID_PROP_ESCAPE_PROCESSING; }
+hidspecial HID_PROP_FILLCOLOR { HelpId = HID_PROP_FILLCOLOR; }
+hidspecial HID_PROP_FILTER { HelpId = HID_PROP_FILTER; }
+hidspecial HID_PROP_FILTERPROPOSAL { HelpId = HID_PROP_FILTERPROPOSAL; }
+hidspecial HID_PROP_FOCUSONCLICK { HelpId = HID_PROP_FOCUSONCLICK; }
+hidspecial HID_PROP_FONT { HelpId = HID_PROP_FONT; }
+hidspecial HID_PROP_FORMATKEY { HelpId = HID_PROP_FORMATKEY; }
+hidspecial HID_PROP_GROUPBOX { HelpId = HID_PROP_GROUPBOX; }
+hidspecial HID_PROP_GROUP_NAME { HelpId = HID_PROP_GROUP_NAME; }
+hidspecial HID_PROP_HEIGHT { HelpId = HID_PROP_HEIGHT; }
+hidspecial HID_PROP_HELPTEXT { HelpId = HID_PROP_HELPTEXT; }
+hidspecial HID_PROP_HELPURL { HelpId = HID_PROP_HELPURL; }
+hidspecial HID_PROP_HIDDEN_VALUE { HelpId = HID_PROP_HIDDEN_VALUE; }
+hidspecial HID_PROP_HIDEINACTIVESELECTION { HelpId = HID_PROP_HIDEINACTIVESELECTION; }
+hidspecial HID_PROP_HSCROLL { HelpId = HID_PROP_HSCROLL; }
+hidspecial HID_PROP_ICONSIZE { HelpId = HID_PROP_ICONSIZE; }
+hidspecial HID_PROP_IMAGEPOSITION { HelpId = HID_PROP_IMAGEPOSITION; }
+hidspecial HID_PROP_IMAGE_URL { HelpId = HID_PROP_IMAGE_URL; }
+hidspecial HID_PROP_INPUT_REQUIRED { HelpId = HID_PROP_INPUT_REQUIRED; }
+hidspecial HID_PROP_INVOKES_STOP_NOT_EDITING { HelpId = HID_PROP_INVOKES_STOP_NOT_EDITING; }
+hidspecial HID_PROP_LABEL { HelpId = HID_PROP_LABEL; }
+hidspecial HID_PROP_LEFT { HelpId = HID_PROP_LEFT; }
+hidspecial HID_PROP_LINECOLOR { HelpId = HID_PROP_LINECOLOR; }
+hidspecial HID_PROP_LINECOUNT { HelpId = HID_PROP_LINECOUNT; }
+hidspecial HID_PROP_LINEEND_FORMAT { HelpId = HID_PROP_LINEEND_FORMAT; }
+hidspecial HID_PROP_LINEINCREMENT { HelpId = HID_PROP_LINEINCREMENT; }
+hidspecial HID_PROP_LISTINDEX { HelpId = HID_PROP_LISTINDEX; }
+hidspecial HID_PROP_LISTSOURCE { HelpId = HID_PROP_LISTSOURCE; }
+hidspecial HID_PROP_LISTSOURCETYPE { HelpId = HID_PROP_LISTSOURCETYPE; }
+hidspecial HID_PROP_LIST_BINDING { HelpId = HID_PROP_LIST_BINDING; }
+hidspecial HID_PROP_LIST_CELL_RANGE { HelpId = HID_PROP_LIST_CELL_RANGE; }
+hidspecial HID_PROP_LITERALMASK { HelpId = HID_PROP_LITERALMASK; }
+hidspecial HID_PROP_LOCKED { HelpId = HID_PROP_LOCKED; }
+hidspecial HID_PROP_MASTERFIELDS { HelpId = HID_PROP_MASTERFIELDS; }
+hidspecial HID_PROP_MAXTEXTLEN { HelpId = HID_PROP_MAXTEXTLEN; }
+hidspecial HID_PROP_MULTILINE { HelpId = HID_PROP_MULTILINE; }
+hidspecial HID_PROP_MULTISELECTION { HelpId = HID_PROP_MULTISELECTION; }
+hidspecial HID_PROP_NAME { HelpId = HID_PROP_NAME; }
+hidspecial HID_PROP_NAVIGATION { HelpId = HID_PROP_NAVIGATION; }
+hidspecial HID_PROP_NAVIGATIONBAR { HelpId = HID_PROP_NAVIGATIONBAR; }
+hidspecial HID_PROP_NOLABEL { HelpId = HID_PROP_NOLABEL; }
+hidspecial HID_PROP_OLDVALUE { HelpId = HID_PROP_OLDVALUE; }
+hidspecial HID_PROP_ORIENTATION { HelpId = HID_PROP_ORIENTATION; }
+hidspecial HID_PROP_POSITIONX { HelpId = HID_PROP_POSITIONX; }
+hidspecial HID_PROP_POSITIONY { HelpId = HID_PROP_POSITIONY; }
+hidspecial HID_PROP_PRINTABLE { HelpId = HID_PROP_PRINTABLE; }
+hidspecial HID_PROP_PROGRESSVALUE { HelpId = HID_PROP_PROGRESSVALUE; }
+hidspecial HID_PROP_PROGRESSVALUE_MAX { HelpId = HID_PROP_PROGRESSVALUE_MAX; }
+hidspecial HID_PROP_PROGRESSVALUE_MIN { HelpId = HID_PROP_PROGRESSVALUE_MIN; }
+hidspecial HID_PROP_PUSHBUTTONTYPE { HelpId = HID_PROP_PUSHBUTTONTYPE; }
+hidspecial HID_PROP_READONLY { HelpId = HID_PROP_READONLY; }
+hidspecial HID_PROP_RECORDMARKER { HelpId = HID_PROP_RECORDMARKER; }
+hidspecial HID_PROP_REFVALUE { HelpId = HID_PROP_REFVALUE; }
+hidspecial HID_PROP_REPEAT { HelpId = HID_PROP_REPEAT; }
+hidspecial HID_PROP_REPEAT_DELAY { HelpId = HID_PROP_REPEAT_DELAY; }
+hidspecial HID_PROP_REQUIRED { HelpId = HID_PROP_REQUIRED; }
+hidspecial HID_PROP_RIGHT { HelpId = HID_PROP_RIGHT; }
+hidspecial HID_PROP_ROOT_DISPLAYED { HelpId = HID_PROP_ROOT_DISPLAYED; }
+hidspecial HID_PROP_ROWHEIGHT { HelpId = HID_PROP_ROWHEIGHT; }
+hidspecial HID_PROP_ROW_HEIGHT { HelpId = HID_PROP_ROW_HEIGHT; }
+hidspecial HID_PROP_SCALEIMAGE { HelpId = HID_PROP_SCALEIMAGE; }
+hidspecial HID_PROP_SCROLLVALUE { HelpId = HID_PROP_SCROLLVALUE; }
+hidspecial HID_PROP_SCROLLVALUEMIN { HelpId = HID_PROP_SCROLLVALUE_MIN; }
+hidspecial HID_PROP_SCROLLVALUE_MAX { HelpId = HID_PROP_SCROLLVALUE_MAX; }
+hidspecial HID_PROP_SCROLLVALUE_MIN { HelpId = HID_PROP_SCROLLVALUE_MIN; }
+hidspecial HID_PROP_SEARCHING { HelpId = HID_PROP_SEARCHING; }
+hidspecial HID_PROP_SELECTEDITEMS { HelpId = HID_PROP_SELECTEDITEMS; }
+hidspecial HID_PROP_SELECTION_TYPE { HelpId = HID_PROP_SELECTION_TYPE; }
+hidspecial HID_PROP_SHOWS_HANDLES { HelpId = HID_PROP_SHOWS_HANDLES; }
+hidspecial HID_PROP_SHOWS_ROOT_HANDLES { HelpId = HID_PROP_SHOWS_ROOT_HANDLES; }
+hidspecial HID_PROP_SHOWTHOUSANDSEP { HelpId = HID_PROP_SHOWTHOUSANDSEP; }
+hidspecial HID_PROP_SHOW_FILTERSORT { HelpId = HID_PROP_SHOW_FILTERSORT; }
+hidspecial HID_PROP_SHOW_NAVIGATION { HelpId = HID_PROP_SHOW_NAVIGATION; }
+hidspecial HID_PROP_SHOW_POSITION { HelpId = HID_PROP_SHOW_POSITION; }
+hidspecial HID_PROP_SHOW_RECORDACTIONS { HelpId = HID_PROP_SHOW_RECORDACTIONS; }
+hidspecial HID_PROP_SHOW_SCROLLBARS { HelpId = HID_PROP_SHOW_SCROLLBARS; }
+hidspecial HID_PROP_SLAVEFIELDS { HelpId = HID_PROP_SLAVEFIELDS; }
+hidspecial HID_PROP_SORT_CRITERIA { HelpId = HID_PROP_SORT_CRITERIA; }
+hidspecial HID_PROP_SPIN { HelpId = HID_PROP_SPIN; }
+hidspecial HID_PROP_SPININCREMENT { HelpId = HID_PROP_SPININCREMENT; }
+hidspecial HID_PROP_SPINVALUE { HelpId = HID_PROP_SPINVALUE; }
+hidspecial HID_PROP_SPINVALUE_MAX { HelpId = HID_PROP_SPINVALUE_MAX; }
+hidspecial HID_PROP_SPINVALUE_MIN { HelpId = HID_PROP_SPINVALUE_MIN; }
+hidspecial HID_PROP_STATE { HelpId = HID_PROP_STATE; }
+hidspecial HID_PROP_STEP { HelpId = HID_PROP_STEP; }
+hidspecial HID_PROP_STRICTFORMAT { HelpId = HID_PROP_STRICTFORMAT; }
+hidspecial HID_PROP_STRINGITEMLIST { HelpId = HID_PROP_STRINGITEMLIST; }
+hidspecial HID_PROP_SUBMISSION_ID { HelpId = HID_PROP_SUBMISSION_ID; }
+hidspecial HID_PROP_SUBMIT_ACTION { HelpId = HID_PROP_SUBMIT_ACTION; }
+hidspecial HID_PROP_SUBMIT_ENCODING { HelpId = HID_PROP_SUBMIT_ENCODING; }
+hidspecial HID_PROP_SUBMIT_METHOD { HelpId = HID_PROP_SUBMIT_METHOD; }
+hidspecial HID_PROP_SUBMIT_TARGET { HelpId = HID_PROP_SUBMIT_TARGET; }
+hidspecial HID_PROP_SYMBOLCOLOR { HelpId = HID_PROP_SYMBOLCOLOR; }
+hidspecial HID_PROP_TABINDEX { HelpId = HID_PROP_TABINDEX; }
+hidspecial HID_PROP_TABORDER_CONTROLS { HelpId = HID_PROP_TABORDER_CONTROLS; }
+hidspecial HID_PROP_TABSTOP { HelpId = HID_PROP_TABSTOP; }
+hidspecial HID_PROP_TAG { HelpId = HID_PROP_TAG; }
+hidspecial HID_PROP_TARGET_FRAME { HelpId = HID_PROP_TARGET_FRAME; }
+hidspecial HID_PROP_TARGET_URL { HelpId = HID_PROP_TARGET_URL; }
+hidspecial HID_PROP_TEXT { HelpId = HID_PROP_TEXT; }
+hidspecial HID_PROP_TEXTTYPE { HelpId = HID_PROP_TEXTTYPE; }
+hidspecial HID_PROP_TIME { HelpId = HID_PROP_TIME; }
+hidspecial HID_PROP_TIMEFORMAT { HelpId = HID_PROP_TIMEFORMAT; }
+hidspecial HID_PROP_TIMEMAX { HelpId = HID_PROP_TIMEMAX; }
+hidspecial HID_PROP_TIMEMIN { HelpId = HID_PROP_TIMEMIN; }
+hidspecial HID_PROP_TITLE { HelpId = HID_PROP_TITLE; }
+hidspecial HID_PROP_TOGGLE { HelpId = HID_PROP_TOGGLE; }
+hidspecial HID_PROP_TRISTATE { HelpId = HID_PROP_TRISTATE; }
+hidspecial HID_PROP_UNCHECKEDREFVALUE { HelpId = HID_PROP_UNCHECKEDREFVALUE; }
+hidspecial HID_PROP_UNIQUE { HelpId = HID_PROP_UNIQUE; }
+hidspecial HID_PROP_VALUE { HelpId = HID_PROP_VALUE; }
+hidspecial HID_PROP_VALUEMAX { HelpId = HID_PROP_VALUEMAX; }
+hidspecial HID_PROP_VALUEMIN { HelpId = HID_PROP_VALUEMIN; }
+hidspecial HID_PROP_VALUESTEP { HelpId = HID_PROP_VALUESTEP; }
+hidspecial HID_PROP_VERTICAL_ALIGN { HelpId = HID_PROP_VERTICAL_ALIGN; }
+hidspecial HID_PROP_VISIBLESIZE { HelpId = HID_PROP_VISIBLESIZE; }
+hidspecial HID_PROP_VISUALEFFECT { HelpId = HID_PROP_VISUALEFFECT; }
+hidspecial HID_PROP_VSCROLL { HelpId = HID_PROP_VSCROLL; }
+hidspecial HID_PROP_WHEEL_BEHAVIOR { HelpId = HID_PROP_WHEEL_BEHAVIOR; }
+hidspecial HID_PROP_WIDTH { HelpId = HID_PROP_WIDTH; }
+hidspecial HID_PROP_WORDBREAK { HelpId = HID_PROP_WORDBREAK; }
+hidspecial HID_PROP_WRITING_MODE { HelpId = HID_PROP_WRITING_MODE; }
+hidspecial HID_PROP_XML_DATA_MODEL { HelpId = HID_PROP_XML_DATA_MODEL; }
+hidspecial HID_PROP_XSD_CALCULATION { HelpId = HID_PROP_XSD_CALCULATION; }
+hidspecial HID_PROP_XSD_CONSTRAINT { HelpId = HID_PROP_XSD_CONSTRAINT; }
+hidspecial HID_PROP_XSD_DATA_TYPE { HelpId = HID_PROP_XSD_DATA_TYPE; }
+hidspecial HID_PROP_XSD_FRACTION_DIGITS { HelpId = HID_PROP_XSD_FRACTION_DIGITS; }
+hidspecial HID_PROP_XSD_LENGTH { HelpId = HID_PROP_XSD_LENGTH; }
+hidspecial HID_PROP_XSD_MAX_EXCLUSIVE { HelpId = HID_PROP_XSD_MAX_EXCLUSIVE; }
+hidspecial HID_PROP_XSD_MAX_INCLUSIVE { HelpId = HID_PROP_XSD_MAX_INCLUSIVE; }
+hidspecial HID_PROP_XSD_MAX_LENGTH { HelpId = HID_PROP_XSD_MAX_LENGTH; }
+hidspecial HID_PROP_XSD_MIN_EXCLUSIVE { HelpId = HID_PROP_XSD_MIN_EXCLUSIVE; }
+hidspecial HID_PROP_XSD_MIN_INCLUSIVE { HelpId = HID_PROP_XSD_MIN_INCLUSIVE; }
+hidspecial HID_PROP_XSD_MIN_LENGTH { HelpId = HID_PROP_XSD_MIN_LENGTH; }
+hidspecial HID_PROP_XSD_PATTERN { HelpId = HID_PROP_XSD_PATTERN; }
+hidspecial HID_PROP_XSD_READONLY { HelpId = HID_PROP_XSD_READONLY; }
+hidspecial HID_PROP_XSD_RELEVANT { HelpId = HID_PROP_XSD_RELEVANT; }
+hidspecial HID_PROP_XSD_REQUIRED { HelpId = HID_PROP_XSD_REQUIRED; }
+hidspecial HID_PROP_XSD_TOTAL_DIGITS { HelpId = HID_PROP_XSD_TOTAL_DIGITS; }
+hidspecial HID_PROP_XSD_WHITESPACES { HelpId = HID_PROP_XSD_WHITESPACES; }
+
+hidspecial HID_SELECTION_TLB { HelpId = HID_SELECTION_TLB; }
+
+hidspecial UID_ABSPILOT_HELP { HelpId = UID_ABSPILOT_HELP; }
+hidspecial UID_BIB_FRAME_WINDOW { HelpId = UID_BIB_FRAME_WINDOW;}
+
+hidspecial UID_BRWEVT_ACTIONPERFORMED { HelpId = UID_BRWEVT_ACTIONPERFORMED; }
+hidspecial UID_BRWEVT_ADJUSTMENTVALUECHANGED { HelpId = UID_BRWEVT_ADJUSTMENTVALUECHANGED; }
+hidspecial UID_BRWEVT_AFTERUPDATE { HelpId = UID_BRWEVT_AFTERUPDATE; }
+hidspecial UID_BRWEVT_APPROVEACTIONPERFORMED { HelpId = UID_BRWEVT_APPROVEACTIONPERFORMED; }
+hidspecial UID_BRWEVT_APPROVEPARAMETER { HelpId = UID_BRWEVT_APPROVEPARAMETER; }
+hidspecial UID_BRWEVT_APPROVERESETTED { HelpId = UID_BRWEVT_APPROVERESETTED; }
+hidspecial UID_BRWEVT_APPROVEROWCHANGE { HelpId = UID_BRWEVT_APPROVEROWCHANGE; }
+hidspecial UID_BRWEVT_BEFOREUPDATE { HelpId = UID_BRWEVT_BEFOREUPDATE; }
+hidspecial UID_BRWEVT_CHANGED { HelpId = UID_BRWEVT_CHANGED; }
+hidspecial UID_BRWEVT_CONFIRMDELETE { HelpId = UID_BRWEVT_CONFIRMDELETE; }
+hidspecial UID_BRWEVT_ERROROCCURED { HelpId = UID_BRWEVT_ERROROCCURED; }
+hidspecial UID_BRWEVT_FOCUSGAINED { HelpId = UID_BRWEVT_FOCUSGAINED; }
+hidspecial UID_BRWEVT_FOCUSLOST { HelpId = UID_BRWEVT_FOCUSLOST; }
+hidspecial UID_BRWEVT_ITEMSTATECHANGED { HelpId = UID_BRWEVT_ITEMSTATECHANGED; }
+hidspecial UID_BRWEVT_KEYTYPED { HelpId = UID_BRWEVT_KEYTYPED; }
+hidspecial UID_BRWEVT_KEYUP { HelpId = UID_BRWEVT_KEYUP; }
+hidspecial UID_BRWEVT_LOADED { HelpId = UID_BRWEVT_LOADED; }
+hidspecial UID_BRWEVT_MOUSEDRAGGED { HelpId = UID_BRWEVT_MOUSEDRAGGED; }
+hidspecial UID_BRWEVT_MOUSEENTERED { HelpId = UID_BRWEVT_MOUSEENTERED; }
+hidspecial UID_BRWEVT_MOUSEEXITED { HelpId = UID_BRWEVT_MOUSEEXITED; }
+hidspecial UID_BRWEVT_MOUSEMOVED { HelpId = UID_BRWEVT_MOUSEMOVED; }
+hidspecial UID_BRWEVT_MOUSEPRESSED { HelpId = UID_BRWEVT_MOUSEPRESSED; }
+hidspecial UID_BRWEVT_MOUSERELEASED { HelpId = UID_BRWEVT_MOUSERELEASED; }
+hidspecial UID_BRWEVT_POSITIONED { HelpId = UID_BRWEVT_POSITIONED; }
+hidspecial UID_BRWEVT_POSITIONING { HelpId = UID_BRWEVT_POSITIONING; }
+hidspecial UID_BRWEVT_RELOADED { HelpId = UID_BRWEVT_RELOADED; }
+hidspecial UID_BRWEVT_RELOADING { HelpId = UID_BRWEVT_RELOADING; }
+hidspecial UID_BRWEVT_RESETTED { HelpId = UID_BRWEVT_RESETTED; }
+hidspecial UID_BRWEVT_ROWCHANGE { HelpId = UID_BRWEVT_ROWCHANGE; }
+hidspecial UID_BRWEVT_SUBMITTED { HelpId = UID_BRWEVT_SUBMITTED; }
+hidspecial UID_BRWEVT_TEXTCHANGED { HelpId = UID_BRWEVT_TEXTCHANGED; }
+hidspecial UID_BRWEVT_UNLOADED { HelpId = UID_BRWEVT_UNLOADED; }
+hidspecial UID_BRWEVT_UNLOADING { HelpId = UID_BRWEVT_UNLOADING; }
+
+hidspecial UID_EVT_MACRODLG { HelpId = UID_EVT_MACRODLG; }
+
+hidspecial UID_FIELDLINK_DETAIL1 { HelpId = UID_FIELDLINK_DETAIL1; }
+hidspecial UID_FIELDLINK_DETAIL2 { HelpId = UID_FIELDLINK_DETAIL2; }
+hidspecial UID_FIELDLINK_DETAIL3 { HelpId = UID_FIELDLINK_DETAIL3; }
+hidspecial UID_FIELDLINK_DETAIL4 { HelpId = UID_FIELDLINK_DETAIL4; }
+hidspecial UID_FIELDLINK_MASTER1 { HelpId = UID_FIELDLINK_MASTER1; }
+hidspecial UID_FIELDLINK_MASTER2 { HelpId = UID_FIELDLINK_MASTER2; }
+hidspecial UID_FIELDLINK_MASTER3 { HelpId = UID_FIELDLINK_MASTER3; }
+hidspecial UID_FIELDLINK_MASTER4 { HelpId = UID_FIELDLINK_MASTER4; }
+
+hidspecial UID_PROP_ADD_DATA_TYPE { HelpId = UID_PROP_ADD_DATA_TYPE; }
+hidspecial UID_PROP_DLG_ATTR_DATASOURCE { HelpId = UID_PROP_DLG_ATTR_DATASOURCE; }
+hidspecial UID_PROP_DLG_ATTR_DATASOURCE { HelpId = UID_PROP_DLG_ATTR_DATASOURCE; }
+hidspecial UID_PROP_DLG_ATTR_TARGET_URL { HelpId = UID_PROP_DLG_ATTR_TARGET_URL; }
+hidspecial UID_PROP_DLG_ATTR_TARGET_URL { HelpId = UID_PROP_DLG_ATTR_TARGET_URL; }
+hidspecial UID_PROP_DLG_BACKGROUNDCOLOR { HelpId = UID_PROP_DLG_BACKGROUNDCOLOR; }
+hidspecial UID_PROP_DLG_BACKGROUNDCOLOR { HelpId = UID_PROP_DLG_BACKGROUNDCOLOR; }
+hidspecial UID_PROP_DLG_BIND_EXPRESSION { HelpId = UID_PROP_DLG_BIND_EXPRESSION; }
+hidspecial UID_PROP_DLG_BORDERCOLOR { HelpId = UID_PROP_DLG_BORDERCOLOR; }
+hidspecial UID_PROP_DLG_CONTROLLABEL { HelpId = UID_PROP_DLG_CONTROLLABEL; }
+hidspecial UID_PROP_DLG_CONTROLLABEL { HelpId = UID_PROP_DLG_CONTROLLABEL; }
+hidspecial UID_PROP_DLG_FILLCOLOR { HelpId = UID_PROP_DLG_FILLCOLOR; }
+hidspecial UID_PROP_DLG_FILLCOLOR { HelpId = UID_PROP_DLG_FILLCOLOR; }
+hidspecial UID_PROP_DLG_FILTER { HelpId = UID_PROP_DLG_FILTER; }
+hidspecial UID_PROP_DLG_FONT_TYPE { HelpId = UID_PROP_DLG_FONT_TYPE; }
+hidspecial UID_PROP_DLG_FONT_TYPE { HelpId = UID_PROP_DLG_FONT_TYPE; }
+hidspecial UID_PROP_DLG_FORMLINKFIELDS { HelpId = UID_PROP_DLG_FORMLINKFIELDS; }
+hidspecial UID_PROP_DLG_IMAGE_URL { HelpId = UID_PROP_DLG_IMAGE_URL; }
+hidspecial UID_PROP_DLG_IMAGE_URL { HelpId = UID_PROP_DLG_IMAGE_URL; }
+hidspecial UID_PROP_DLG_NUMBER_FORMAT { HelpId = UID_PROP_DLG_NUMBER_FORMAT; }
+hidspecial UID_PROP_DLG_NUMBER_FORMAT { HelpId = UID_PROP_DLG_NUMBER_FORMAT; }
+hidspecial UID_PROP_DLG_ORDER { HelpId = UID_PROP_DLG_ORDER; }
+hidspecial UID_PROP_DLG_SELECTION { HelpId = UID_PROP_DLG_SELECTION; }
+hidspecial UID_PROP_DLG_SQLCOMMAND { HelpId = UID_PROP_DLG_SQLCOMMAND; }
+hidspecial UID_PROP_DLG_SYMBOLCOLOR { HelpId = UID_PROP_DLG_SYMBOLCOLOR; }
+hidspecial UID_PROP_DLG_TABINDEX { HelpId = UID_PROP_DLG_TABINDEX; }
+hidspecial UID_PROP_DLG_XSD_CALCULATION { HelpId = UID_PROP_DLG_XSD_CALCULATION; }
+hidspecial UID_PROP_DLG_XSD_CONSTRAINT { HelpId = UID_PROP_DLG_XSD_CONSTRAINT; }
+hidspecial UID_PROP_DLG_XSD_READONLY { HelpId = UID_PROP_DLG_XSD_READONLY; }
+hidspecial UID_PROP_DLG_XSD_RELEVANT { HelpId = UID_PROP_DLG_XSD_RELEVANT; }
+hidspecial UID_PROP_DLG_XSD_REQUIRED { HelpId = UID_PROP_DLG_XSD_REQUIRED; }
+hidspecial UID_PROP_REMOVE_DATA_TYPE { HelpId = UID_PROP_REMOVE_DATA_TYPE; }
+hidspecial HID_FM_PROPDLG_TABCTR { HelpId = HID_FM_PROPDLG_TABCTR; }
+hidspecial HID_FM_PROPDLG_TAB_GENERAL { HelpId = HID_FM_PROPDLG_TAB_GENERAL; }
+hidspecial HID_FM_PROPDLG_TAB_DATA { HelpId = HID_FM_PROPDLG_TAB_DATA; }
+hidspecial HID_FM_PROPDLG_TAB_EVT { HelpId = HID_FM_PROPDLG_TAB_EVT; }
diff --git a/extensions/util/makefile.mk b/extensions/util/makefile.mk
new file mode 100644
index 000000000000..af6b1ec8c600
--- /dev/null
+++ b/extensions/util/makefile.mk
@@ -0,0 +1,39 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ=..
+PRJNAME=extensions
+TARGET=ext
+GEN_HID=TRUE
+GEN_HID_OTHER=TRUE
+
+# --- Settings ----------------------------------
+
+.INCLUDE : settings.mk
+
+.INCLUDE : target.mk
+
diff --git a/extensions/util/makefile.pmk b/extensions/util/makefile.pmk
new file mode 100644
index 000000000000..b80a9c7bd3c2
--- /dev/null
+++ b/extensions/util/makefile.pmk
@@ -0,0 +1,29 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+.INCLUDE : settings.mk
+
diff --git a/extensions/util/target.pmk b/extensions/util/target.pmk
new file mode 100644
index 000000000000..c7c1de9c2563
--- /dev/null
+++ b/extensions/util/target.pmk
@@ -0,0 +1,35 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+ALLSLO: $(SLOFILES)
+
+SOSHL: $(SHL1TARGETN)
+
+WHOLEPRJ:
+ cd $(PRJ)$/prj
+ make debug linkinc prjpch compinc
+ @echo "READY"
+
diff --git a/extensions/workben/makefile.mk b/extensions/workben/makefile.mk
new file mode 100644
index 000000000000..ca25cfa51312
--- /dev/null
+++ b/extensions/workben/makefile.mk
@@ -0,0 +1,170 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ=..
+
+PRJNAME=extensions
+TARGET=workben
+LIBTARGET=NO
+
+TESTAPP=testpgp
+#TESTAPP=testcomponent
+#TESTAPP=pythontest
+#TESTAPP=pythonautotest
+#TESTAPP=testresource
+#TESTAPP=testframecontrol
+
+.IF "$(TESTAPP)" == "testresource" || "$(TESTAPP)" == "testframecontrol"
+TARGETTYPE=GUI
+.ELSE
+TARGETTYPE=CUI
+.ENDIF
+
+JVM_TARGET=jvmtest
+
+ENABLE_EXCEPTIONS=TRUE
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+
+UNOUCROUT=$(OUT)$/inc$/$(PRJNAME)$/$(TARGET)
+INCPRE+=$(UNOUCROUT)
+
+# --- Files --------------------------------------------------------
+
+#
+# testpgp.
+#
+.IF "$(TESTAPP)" == "testpgp"
+
+UNOTYPES= \
+ com.sun.star.lang.XMultiServiceFactory \
+ com.sun.star.io.XInputStream \
+ com.sun.star.io.XOutputStream \
+ com.sun.star.pgp.RecipientsEvent \
+ com.sun.star.pgp.SignatureEvent \
+ com.sun.star.pgp.XPGPDecoder \
+ com.sun.star.pgp.XPGPDecoderListener \
+ com.sun.star.pgp.XPGPEncoder \
+ com.sun.star.pgp.XPGPPreferences \
+ com.sun.star.uno.TypeClass \
+ com.sun.star.uno.XInterface \
+ com.sun.star.uno.XWeak
+
+OBJFILES= $(OBJ)$/testpgp.obj
+
+APP1TARGET= testpgp
+APP1OBJS= $(OBJFILES)
+APP1STDLIBS= \
+ $(CPPUHELPERLIB)\
+ $(CPPULIB) \
+ $(SALLIB)
+
+.ENDIF # testpgp
+
+#
+# std testcomponent
+#
+.IF "$(TESTAPP)" == "testcomponent"
+
+OBJFILES= $(OBJ)$/testcomponent.obj
+
+APP2TARGET = testcomponent
+APP2OBJS = $(OBJ)$/testcomponent.obj
+APP2STDLIBS = \
+ $(TOOLSLIB) \
+ $(SALLIB)
+
+.ENDIF # testcomponent
+
+#
+# test python.
+#
+.IF "$(TESTAPP)" == "phytontest"
+
+OBJFILES= $(OBJ)$/pythontest.obj
+
+#APP4TARGET= pythontest
+#APP4OBJS= $(OBJ)$/pythontest.obj
+#APP4STDLIBS=$(TOOLSLIB)
+#
+
+.ENDIF # phytontest
+
+#
+# python auto test
+#
+.IF "$(TESTAPP)" == "phytonautotest"
+
+OBJFILES= $(OBJ)$/pythonautotest.obj
+
+#APP5TARGET= pythonautotest
+#APP5OBJS = $(OBJ)$/pythonautotest.obj
+#APP5STDLIBS=$(TOOLSLIB)
+
+.ENDIF # phytonautotest
+
+#
+# testresource.
+#
+.IF "$(TESTAPP)" == "testresource"
+
+OBJFILES= $(OBJ)$/testresource.obj
+
+SRS2NAME = testresource
+SRC2FILES= testresource.src
+RESLIB2SRSFILES= $(SRS)$/testresource.srs
+RESLIB2NAME= testresource
+
+APP2TARGET= testresource
+APP2OBJS= $(OBJ)$/testresource.obj
+APP2STDLIBS=$(TOOLSLIB) \
+ $(VCLLIB) \
+ $(SALLIB)
+
+.ENDIF # testresource
+
+#
+# testframecontrol.
+#
+.IF "$(TESTAPP)" == "testframecontrol"
+
+OBJFILES= $(OBJ)$/testframecontrol.obj
+
+APP3TARGET= testframecontrol
+APP3OBJS= $(OBJ)$/testframecontrol.obj
+APP3STDLIBS=$(TOOLSLIB) \
+ $(SVTOOLLIB) \
+ $(VCLLIB)
+
+.ENDIF # testframecontrol
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : target.mk
+
diff --git a/extensions/workben/pythonautotest.cxx b/extensions/workben/pythonautotest.cxx
new file mode 100644
index 000000000000..1b44b17ef392
--- /dev/null
+++ b/extensions/workben/pythonautotest.cxx
@@ -0,0 +1,623 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+#include <stdio.h>
+#include <stardiv/uno/repos/implementationregistration.hxx>
+#include <stardiv/uno/script/script.hxx>
+#include <stardiv/uno/beans/exactname.hxx>
+
+#include <rtl/ustring.hxx>
+#include <osl/diagnose.h>
+#include <usr/services.hxx>
+#include <vcl/svapp.hxx>
+#include <usr/ustring.hxx>
+#include <usr/weak.hxx>
+#include <tools/string.hxx>
+#include <osl/conditn.hxx>
+
+using namespace rtl;
+using namespace usr;
+
+#define PCHAR_TO_USTRING(x) StringToOUString(String(x),CHARSET_SYSTEM)
+#define USTRING_TO_PCHAR(x) OUStringToString(x , CHARSET_DONTKNOW ).GetCharStr()
+
+
+
+
+
+/*****
+*
+* A Test root object !
+*
+*****/
+class MyPythonRoot :
+ public XInvokation,
+ public OWeakObject
+{
+public:
+ MyPythonRoot() { m_iTestValue = 15; }
+ BOOL queryInterface( Uik aUik, XInterfaceRef & rOut );
+ void acquire() { OWeakObject::acquire(); }
+ void release() { OWeakObject::release(); }
+ void* getImplementation(Reflection *p) { return OWeakObject::getImplementation(p); }
+
+public:
+ XIntrospectionAccessRef getIntrospection(void) const THROWS( (UsrSystemException) )
+ { return XIntrospectionAccessRef(); }
+
+ UsrAny invoke( const UString& FunctionName,
+ const Sequence< UsrAny >& Params,
+ Sequence< INT16 >& OutParamIndex,
+ Sequence< UsrAny >& OutParam)
+ THROWS( ( IllegalArgumentException,
+ CannotConvertException,
+ InvocationTargetException,
+ UsrSystemException) );
+ void setValue(const UString& PropertyName, const UsrAny& Value)
+ THROWS( ( UnknownPropertyException,
+ CannotConvertException,
+ InvocationTargetException,
+ UsrSystemException) );
+
+ UsrAny getValue(const UString& PropertyName)
+ THROWS( ( UnknownPropertyException,
+ UsrSystemException) );
+ BOOL hasMethod(const UString& Name) const THROWS( (UsrSystemException) );
+ BOOL hasProperty(const UString& Name) const THROWS( (UsrSystemException) );
+
+
+ void getTestValueViaInout( int &inout )
+ { inout = m_iTestValue; }
+
+ INT32 getTestValue() const
+ { return m_iTestValue; }
+
+ void setTestValue( INT32 i )
+ { m_iTestValue = i; }
+
+ void printTestValue()
+ { fprintf( stderr, "TestValue : %d\n" , getTestValue() ); }
+
+ void addTestValue( INT32 i )
+ { m_iTestValue += i; }
+
+private:
+
+ INT32 m_iTestValue;
+};
+
+BOOL MyPythonRoot::queryInterface( Uik aUik, XInterfaceRef &rOut )
+{
+ if( aUik == XInvokation::getSmartUik() ) {
+ rOut = ( XInvokation * ) this;
+ }
+ else {
+ return OWeakObject::queryInterface( aUik , rOut );
+ }
+ return TRUE;
+
+}
+
+UsrAny MyPythonRoot::invoke( const UString& FunctionName,
+ const Sequence< UsrAny >& Params,
+ Sequence< INT16 >& OutParamIndex,
+ Sequence< UsrAny >& OutParam)
+ THROWS( ( IllegalArgumentException,
+ CannotConvertException,
+ InvocationTargetException,
+ UsrSystemException) )
+{
+ if( L"printTestValue" == FunctionName ) {
+ printTestValue();
+ }
+ else if( L"addTestValue" == FunctionName ) {
+ addTestValue( Params.getConstArray()[0].getINT32() );
+ }
+ else if( L"getTestValueViaInout" == FunctionName ) {
+ int i = Params.getConstArray()[0].getINT32();
+ getTestValueViaInout( i );
+ OutParam.getArray()[0].setINT32( i );
+ }
+ else {
+ THROW( InvocationTargetException() );
+ }
+
+ return UsrAny();
+}
+
+void MyPythonRoot::setValue(const UString& PropertyName, const UsrAny& Value)
+ THROWS( ( UnknownPropertyException,
+ CannotConvertException,
+ InvocationTargetException,
+ UsrSystemException) )
+{
+ if( L"TestValue" == PropertyName ) {
+ setTestValue( Value.getINT32() );
+ }
+ else {
+ THROW( UnknownPropertyException() );
+ }
+}
+
+UsrAny MyPythonRoot::getValue(const UString& PropertyName)
+ THROWS( ( UnknownPropertyException,
+ UsrSystemException) )
+{
+ UsrAny aRet;
+
+ if( L"TestValue" == PropertyName ) {
+ aRet.setINT32( getTestValue() );
+ }
+ else {
+ THROW( UnknownPropertyException() );
+ }
+
+ return aRet;
+}
+
+
+BOOL MyPythonRoot::hasMethod(const UString& Name) const THROWS( (UsrSystemException) )
+{
+ if( L"printTestValue" == Name ) {
+ return TRUE;
+ }
+ else if( L"addTestValue" == Name ) {
+ return TRUE;
+ }
+ else if( L"getTestValueViaInout" == Name ) {
+ return TRUE;
+ }
+ return FALSE;
+}
+
+
+BOOL MyPythonRoot::hasProperty(const UString& Name) const THROWS( (UsrSystemException) )
+{
+ if( L"TestValue" == Name ) {
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+
+/*****
+*
+* A test engine listener to check the debug interface
+*
+*****/
+class TestListener :
+ public XEngineListener,
+ public OWeakObject
+{
+public:
+
+ TestListener()
+ {
+ m_pDebuggingRef = 0;
+ }
+
+
+ TestListener( XDebuggingRef *p )
+ {
+ attach( p );
+ }
+
+ ~TestListener()
+ {
+ if( m_pDebuggingRef ) {
+ detach();
+ }
+ }
+
+ BOOL queryInterface( Uik aUik, XInterfaceRef & rOut );
+ void acquire() { OWeakObject::acquire(); }
+ void release() { OWeakObject::release(); }
+ void* getImplementation(Reflection *p) { return OWeakObject::getImplementation(p); }
+
+
+ void attach( XDebuggingRef *p )
+ {
+ m_pDebuggingRef = p;
+ }
+
+ void detach( );
+
+
+ virtual void disposing( const EventObject &o )
+ {
+ if( m_pDebuggingRef ) {
+ detach();
+ }
+ }
+ virtual void interrupt(const InterruptEngineEvent& Evt) THROWS( (UsrSystemException) )
+ {
+ }
+
+ virtual void running(const EventObject& Evt) THROWS( (UsrSystemException) )
+ {
+ (*m_pDebuggingRef)->stop();
+
+ m_aDebugCondition.set();
+ }
+
+ virtual void finished(const FinishEngineEvent& Evt) THROWS( (UsrSystemException) )
+ {
+ m_aDebugCondition.set();
+ }
+
+
+ void cmdLine();
+protected:
+
+ osl::Condition m_aDebugCondition;
+ XDebuggingRef *m_pDebuggingRef;
+};
+
+
+
+void TestListener::cmdLine()
+{
+ // Condition is set by running listener
+ m_aDebugCondition.wait();
+ m_aDebugCondition.reset();
+ (*m_pDebuggingRef)->doContinue();
+ m_aDebugCondition.wait();
+}
+
+void TestListener::detach()
+{
+ OSL_ASSERT( m_pDebuggingRef );
+
+ m_pDebuggingRef = 0;
+}
+
+BOOL TestListener::queryInterface( Uik aUik, XInterfaceRef & rOut )
+{
+ if( aUik == XEngineListener::getSmartUik() )
+ rOut = (XEngineListener*)this;
+ else
+ return OWeakObject::queryInterface( aUik, rOut );
+ return TRUE;
+}
+
+
+void checkInvokation( const XInvokationRef &xInvoke )
+{
+ UsrAny anyList;
+
+ // check exporting an object as an invokation
+ OSL_ASSERT( xInvoke->hasProperty( L"list" ) );
+ anyList = xInvoke->getValue( L"list" );
+
+ OSL_ASSERT( anyList.getReflection() == XInvokation_getReflection() );
+ XInvokationRef *pRef = ( XInvokationRef * ) anyList.get();
+ OSL_ASSERT( (*pRef).is() );
+
+ OSL_ASSERT( (*pRef)->hasMethod( L"append" ) );
+ OSL_ASSERT( (*pRef)->hasMethod( L"count" ) );
+
+ Sequence<UsrAny> seq(1);
+ UsrAny any( (INT32) 1);
+ (seq.getArray())[0] = any;
+
+ any = (*pRef)->invoke( L"count" , seq , Sequence<INT16>(), Sequence<UsrAny>() );
+ int nOldSize = any.getINT32();
+
+ any = (*pRef)->invoke( L"append" , seq , Sequence<INT16>(), Sequence<UsrAny>() );
+ any = (*pRef)->invoke( L"count" , seq , Sequence<INT16>(), Sequence<UsrAny>() );
+
+ OSL_ASSERT( nOldSize + 1 == any.getINT32() );
+}
+
+// just for testing !
+class PythonCodeLibrary :
+ public XLibraryAccess,
+ public OWeakObject
+{
+
+ BOOL queryInterface( Uik aUik, XInterfaceRef & rOut );
+ void acquire() { OWeakObject::acquire(); }
+ void release() { OWeakObject::release(); }
+ void* getImplementation(Reflection *p) { return OWeakObject::getImplementation(p); }
+
+
+ virtual BOOL isFunction(const UString& FunctionName) THROWS( (UsrSystemException) )
+ {
+ return FALSE;
+ }
+
+ virtual BOOL isValidPath(const UString& PathName) THROWS( (UsrSystemException) )
+ {
+ return FALSE;
+ }
+
+ virtual Sequence< UString > getModuleNames(void) THROWS( (UsrSystemException) )
+ {
+ return Sequence<UString> ();
+ }
+
+ virtual UString getModuleSource(const UString& ModulName) THROWS( (UsrSystemException) )
+ {
+ if( ModulName == L"testmodul" ) {
+ return UString( L"def testmethod():\n"
+ L" return 42\n");
+ }
+ return UString();
+ }
+
+ virtual Sequence< BYTE > getModuleCode(const UString& ModuleName) THROWS( (UsrSystemException) )
+ {
+ return Sequence< BYTE > ();
+ }
+
+ virtual UString getFunctionSource(const UString& FunctionName) THROWS( (UsrSystemException) )
+ {
+ return UString();
+ }
+ virtual Sequence< BYTE > getFunctionCode(const UString& FunctionName) THROWS( (UsrSystemException) )
+ {
+ return Sequence< BYTE > ();
+ }
+};
+
+BOOL PythonCodeLibrary::queryInterface( Uik aUik, XInterfaceRef & rOut )
+{
+ if( XLibraryAccess::getSmartUik() == aUik ) {
+ rOut = (XLibraryAccess* ) this;
+ }
+ else {
+ return OWeakObject::queryInterface( aUik , rOut );
+ }
+
+ return TRUE;
+}
+
+
+
+/*
+ * main.
+ */
+int __LOADONCALLAPI main (int argc, char **argv)
+{
+ // necessary startup code
+ XMultiServiceFactoryRef xSMgr = createRegistryServiceManager();
+ registerUsrServices( xSMgr );
+ setProcessServiceManager( xSMgr );
+
+ XInterfaceRef x = xSMgr->createInstance( L"stardiv.uno.repos.ImplementationRegistration" );
+ XImplementationRegistrationRef xReg( x, USR_QUERY );
+ sal_Char szBuf[1024];
+
+ ORealDynamicLoader::computeModuleName( "pythonengine", szBuf, 1024 );
+ UString aDllName( StringToOUString( szBuf, CHARSET_SYSTEM ) );
+ xReg->registerImplementation( L"stardiv.loader.SharedLibrary", aDllName, XSimpleRegistryRef() );
+
+ x = xSMgr->createInstance( L"stardiv.script.Python" );
+ XEngineRef xEngine( x, USR_QUERY );
+ XInvokationRef xInvoke( x, USR_QUERY );
+ XDebuggingRef xDebug( x , USR_QUERY );
+
+ XInterfaceRef rRoot( (XInvokation * )new MyPythonRoot , USR_QUERY );
+ xEngine->setRoot( rRoot );
+
+
+ // execute a simple script
+ xEngine->run( L"nIntTest = 5\n"
+ L"list = [2,3,4]\n" , XInterfaceRef(), Sequence<UsrAny> () );
+
+ /****
+ *
+ * Xinvokation - Test
+ *
+ *****/
+ // get/set an int !
+ {
+ OSL_ASSERT( xInvoke->hasProperty( L"nIntTest" ) );
+ UsrAny any = xInvoke->getValue( L"nIntTest" );
+
+ OSL_ASSERT( any.getReflection()->getTypeClass() == TypeClass_LONG );
+ OSL_ASSERT( any.getINT32() == 5 );
+
+ // simple test: set an int !
+ xInvoke->setValue( L"nIntTest" , UsrAny( (INT32) 10 ) );
+ any = xInvoke->getValue( L"nIntTest" );
+
+ OSL_ASSERT( any.getReflection()->getTypeClass() == TypeClass_LONG );
+ OSL_ASSERT( any.getINT32() == 10 );
+ }
+
+ // call a python method !
+ {
+ xEngine->run( L"def foo():\n"
+ L" return 'this is foo'\n" , XInterfaceRef() , Sequence<UsrAny> () );
+ OSL_ASSERT( xInvoke->hasMethod( L"foo" ) );
+ UsrAny any = xInvoke->invoke( L"foo" ,
+ Sequence<UsrAny>(),
+ Sequence<INT16>() ,
+ Sequence<UsrAny> () );
+ OSL_ASSERT( any.getString() == L"this is foo" );
+ }
+
+
+ // check exception handling !
+ {
+ try {
+ xInvoke->invoke( L"foo" , Sequence<UsrAny>(1) , Sequence<INT16>(), Sequence<UsrAny> () );
+ // wrong number of arguments
+ OSL_ASSERT( 0 );
+ }
+ catch ( IllegalArgumentException& e ) {
+ }
+ catch ( InvocationTargetException& e ) {
+ }
+ catch ( CannotConvertException& e ) {
+ // empty any cannot be converted
+ }
+ }
+
+ // check InOut-Parameter
+ checkInvokation( xInvoke );
+
+ /*******
+ *
+ * Check Introspection Access
+ *
+ *******/
+ {
+ XIntrospectionAccessRef xIntrospection = xInvoke->getIntrospection();
+ OSL_ASSERT( xIntrospection.is() );
+
+ // no further test, simply call them
+ xIntrospection->getMethods(0);
+ xIntrospection->getProperties(0);
+
+ OSL_ASSERT( xIntrospection->getSuppliedMethodConcepts() == 0 );
+ OSL_ASSERT( xIntrospection->getSuppliedPropertyConcepts() == 0 );
+
+ Property prop = xIntrospection->getProperty( L"nIntTest" ,0 );
+ OSL_ASSERT( prop.Name == L"nIntTest" );
+ OSL_ASSERT( prop.Type->getTypeClass() == TypeClass_LONG );
+
+ XIdlMethodRef method = xIntrospection->getMethod( L"foo" , 0 );
+ OSL_ASSERT( method->getName() == L"foo" );
+ }
+
+
+ /******
+ *
+ * Multithreading test
+ *
+ *******/
+
+ /******
+ *
+ * XDebuggingTest
+ *
+ ******/
+ // stop/doContinue + runAsync listener
+ {
+ // test hangs, if something is wrong
+
+ TestListener *pListener = new TestListener( &xDebug );
+ XEngineListenerRef ref( (XEngineListener * ) pListener , USR_QUERY );
+
+ // single listener check !
+ xEngine->runAsync( L"pass\n"
+ , XInterfaceRef() , Sequence<UsrAny> () , ref );
+ pListener->cmdLine();
+ }
+
+ // ListenerAdministration check !
+ {
+ // test hangs, if something is wrong
+
+ TestListener *pListener = new TestListener( &xDebug );
+ XEngineListenerRef ref( (XEngineListener * ) pListener , USR_QUERY );
+
+ // engine listener check !
+ xEngine->addEngineListener( ref );
+ xEngine->runAsync( L"pass\n"
+ , XInterfaceRef() , Sequence<UsrAny> () , XEngineListenerRef() );
+ pListener->cmdLine();
+ xEngine->removeEngineListener( ref);
+
+ }
+
+ // check the import mechanism
+ {
+ XLibraryAccessRef xLibrary( ( XLibraryAccess * ) new PythonCodeLibrary , USR_QUERY );
+ xEngine->setLibraryAccess( xLibrary );
+
+ xEngine->run( L"import testmodul\n"
+ L"x = testmodul.testmethod()\n" , XInterfaceRef() , Sequence<UsrAny>() );
+ UsrAny any = xInvoke->getValue( L"x" );
+ OSL_ASSERT( any.getReflection()->getTypeClass() == TypeClass_LONG );
+ OSL_ASSERT( any.getINT32() == 42 );
+ }
+
+ // check other imports
+ {
+ // Check, if the libraries are available at run time
+ xEngine->run( L"import math\n"
+ L"dMathTest = math.exp(0)\n" , XInterfaceRef() , Sequence<UsrAny> () );
+
+ OSL_ASSERT( xInvoke->hasProperty( L"dMathTest" ) );
+ UsrAny any = xInvoke->getValue( L"dMathTest" );
+
+ OSL_ASSERT( any.getReflection()->getTypeClass() == TypeClass_DOUBLE );
+ OSL_ASSERT( any.getDouble() == 1. );
+ }
+
+ // Test connection to root object !
+ {
+ xEngine->run( L"x = stardiv.root.TestValue\n"
+ L"y = stardiv.inout(5)\n"
+ L"stardiv.root.getTestValueViaInout(y)\n"
+ L"z = y.value\n" , XInterfaceRef() , Sequence<UsrAny> () );
+
+ UsrAny any = xInvoke->getValue( L"x" );
+ OSL_ASSERT( any.getReflection()->getTypeClass() == TypeClass_LONG );
+ OSL_ASSERT( any.getINT32() == 15 );
+
+ any = xInvoke->getValue( L"z" );
+ OSL_ASSERT( any.getReflection()->getTypeClass() == TypeClass_LONG );
+ OSL_ASSERT( any.getINT32() == 15 );
+ }
+
+ // Test exactName interface
+ {
+ UsrAny any = xInvoke->getValue( L"__builtins__" );
+ OSL_ASSERT( any.getReflection()->getTypeClass() == TypeClass_INTERFACE );
+
+ XInvokationRef rInv( *((XInterfaceRef *) any.get() ), USR_QUERY );
+ OSL_ASSERT( rInv.is() );
+
+ XExactNameRef rName( *((XInterfaceRef*) any.get() ), USR_QUERY );
+ OSL_ASSERT( rName.is() );
+
+ UString str = rName->getExactName( L"SYNTAXERROR" );
+ OSL_ASSERT( str.len() );
+ }
+
+
+ // Test exactName interface of the engine itself
+ {
+ XExactNameRef rName( xInvoke , USR_QUERY );
+ OSL_ASSERT( rName.is() );
+ UString str = rName->getExactName( L"STARDIV" );
+ OSL_ASSERT( str.len() );
+ }
+
+
+ return 0;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/workben/pythontest.cxx b/extensions/workben/pythontest.cxx
new file mode 100644
index 000000000000..85a99532a698
--- /dev/null
+++ b/extensions/workben/pythontest.cxx
@@ -0,0 +1,557 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+
+#include <stdio.h>
+#include <stardiv/uno/repos/implementationregistration.hxx>
+#include <stardiv/uno/script/script.hxx>
+#include <stardiv/uno/beans/exactname.hxx>
+
+#include <rtl/ustring.hxx>
+#include <osl/diagnose.h>
+#include <usr/services.hxx>
+#include <vcl/svapp.hxx>
+#include <usr/ustring.hxx>
+#include <usr/weak.hxx>
+#include <tools/string.hxx>
+#include <osl/conditn.hxx>
+
+using namespace rtl;
+using namespace usr;
+
+#define PCHAR_TO_USTRING(x) StringToOUString(String(x),CHARSET_SYSTEM)
+
+
+
+class NullEngineListenerRef : public XEngineListenerRef
+{
+ virtual void interrupt(const InterruptEngineEvent& Evt) THROWS( (UsrSystemException) ) {}
+ virtual void running(const EventObject& Evt) THROWS( (UsrSystemException) ) {}
+ virtual void finished(const FinishEngineEvent& Evt) THROWS( (UsrSystemException) ) {}
+};
+
+#define USTRING_TO_PCHAR(x) OUStringToString(x , CHARSET_DONTKNOW ).GetCharStr()
+
+class CmdDebugger :
+ public XEngineListener,
+ public OWeakObject
+{
+public:
+
+ CmdDebugger()
+ {
+ m_pDebuggingRef = 0;
+ m_pEngineRef = 0;
+ m_bIsTerminating = FALSE;
+ m_bIsRunning = FALSE;
+ }
+
+
+ CmdDebugger( XDebuggingRef *p, XEngineRef *pEngine , XInvokationRef *pInvokation)
+ {
+ attach( p , pEngine , pInvokation );
+ }
+
+ ~CmdDebugger()
+ {
+ if( m_pDebuggingRef ) {
+ detach();
+ }
+ }
+
+ BOOL queryInterface( Uik aUik, XInterfaceRef & rOut );
+ void acquire() { OWeakObject::acquire(); }
+ void release() { OWeakObject::release(); }
+ void* getImplementation(Reflection *p) { return OWeakObject::getImplementation(p); }
+
+
+ void attach( XDebuggingRef *p , XEngineRef *pEngine , XInvokationRef *pInvokation )
+ {
+ m_pDebuggingRef = p;
+ m_pEngineRef = pEngine;
+ m_pInvokationRef = pInvokation;
+ m_bIsRunning = FALSE;
+ m_bIsTerminating = FALSE;
+ }
+
+ void detach( );
+
+
+ virtual void disposing( const EventObject &o )
+ {
+ if( m_pDebuggingRef ) {
+ detach();
+ }
+ }
+ virtual void interrupt(const InterruptEngineEvent& Evt) THROWS( (UsrSystemException) )
+ {
+ if( m_pDebuggingRef && ! m_bIsTerminating ) {
+ (*m_pDebuggingRef)->stop();
+ fprintf( stderr, "%s\n" , USTRING_TO_PCHAR(Evt.ErrorMessage ) );
+ fprintf( stderr, "%s.%s (%d)\n", USTRING_TO_PCHAR(Evt.SourceCode),
+ USTRING_TO_PCHAR(Evt.Name ),
+ Evt.StartLine );
+ m_aDebugCondition.set();
+ m_bIsRunning = TRUE;
+ }
+ }
+
+ virtual void running(const EventObject& Evt) THROWS( (UsrSystemException) )
+ {
+ if( m_pDebuggingRef && ! m_bIsTerminating ) {
+ (*m_pDebuggingRef)->stop();
+
+ m_aDebugCondition.set();
+ m_bIsRunning = TRUE;
+ fprintf( stderr, "%s\n" , "Script starts\n" );
+ }
+ }
+
+ virtual void finished(const FinishEngineEvent& Evt) THROWS( (UsrSystemException) )
+ {
+ if( m_pDebuggingRef && ! m_bIsTerminating ) {
+ m_aDebugCondition.set();
+ m_bIsRunning = FALSE;
+ fprintf( stderr , "%s\n", USTRING_TO_PCHAR( Evt.ErrorMessage ) );
+ }
+ }
+
+ void dumpIntrospectionToStream( const XIntrospectionAccessRef &, FILE *f );
+ void dumpVarToStream( const char *pcName, const UsrAny &any, FILE *f );
+
+
+ void cmdLine();
+protected:
+
+ osl::Condition m_aDebugCondition;
+ XDebuggingRef *m_pDebuggingRef;
+ XEngineRef *m_pEngineRef;
+ XInvokationRef *m_pInvokationRef;
+ int m_bIsRunning;
+ int m_bIsTerminating; // The listeners ignore everything when set
+};
+
+
+
+void CmdDebugger::cmdLine()
+{
+ char pcLine[80];
+ fprintf( stderr, "entering debugger\n" );
+ while( TRUE ) {
+
+ m_aDebugCondition.wait();
+
+ fprintf( stderr , "(debug %d) : " , m_bIsRunning );
+ fflush( stderr);
+ fgets( pcLine , 79 , stdin );
+
+ if( strlen( pcLine) ) pcLine[strlen(pcLine)-1] =0;
+ String sLine( pcLine );
+
+ if( ! strcmp( pcLine , "g" ) ) {
+ if( m_bIsRunning ) {
+ m_aDebugCondition.reset();
+ (*m_pDebuggingRef)->doContinue();
+ }
+ else fprintf( stderr,"no script running !\n" );
+ }
+ else if( ! strcmp( pcLine , "s" ) ) {
+ if( m_bIsRunning ) {
+ m_aDebugCondition.reset();
+ (*m_pDebuggingRef)->stepOver();
+ }
+ else fprintf(stderr, "no script running !\n" );
+ }
+ else if( ! strcmp( pcLine , "so" ) ) {
+ if( m_bIsRunning ) {
+ m_aDebugCondition.reset();
+ (*m_pDebuggingRef)->stepOut();
+ }
+ else fprintf(stderr, "no script running !\n" );
+ }
+ else if( ! strcmp( pcLine , "si" ) ) {
+ if( m_bIsRunning ) {
+ m_aDebugCondition.reset();
+ (*m_pDebuggingRef)->stepIn();
+ }
+ else fprintf(stderr, "no script running !\n" );
+ }
+ else if( ! strncmp( pcLine , "sbp" , 3 ) ){
+ if( m_bIsRunning ) {
+ (*m_pDebuggingRef)->setBreakPoint( UString( L"<string>" ),
+ atoi(&pcLine[3]) , TRUE );
+ }
+ }
+ else if( ! strncmp( pcLine , "rbp" , 3 ) ){
+ if( m_bIsRunning ) {
+ (*m_pDebuggingRef)->setBreakPoint( UString( L"<string>" ),
+ atoi(&pcLine[3]) , FALSE );
+ }
+ }
+ else if( ! strncmp( pcLine , "dv " , 3 ) ) {
+ if( m_bIsRunning ) {
+ int nCallstack = 0;
+ if( sLine.GetQuotedTokenCount( String("''"),' ' ) == 3 ) {
+ nCallstack = atoi( sLine.GetQuotedToken( 3 , String("''"), ' ' ).GetCharStr() );
+ }
+
+ UString str = (*m_pDebuggingRef)->dumpVariable(
+ PCHAR_TO_USTRING( &pcLine[3]),nCallstack);
+ fprintf( stderr, "%s\n" , USTRING_TO_PCHAR( str ) );
+ }
+ }
+ else if( ! strncmp( pcLine , "sv " , 3 ) ) {
+ int nCallstack = 0;
+ if( sLine.GetQuotedTokenCount( String("''"),' ' ) == 3 ) {
+ nCallstack = atoi( sLine.GetQuotedToken( 3 , String("''"), ' ' ).GetCharStr() );
+ }
+ (*m_pDebuggingRef)->setVariable(
+ StringToOUString( sLine.GetQuotedToken( 1 , String("''"), ' ' ), CHARSET_SYSTEM ),
+ StringToOUString( sLine.GetQuotedToken( 2 , String("''"), ' ' ), CHARSET_SYSTEM ),
+ nCallstack );
+
+ }
+ else if( ! strncmp( pcLine , "ci" ,2 ) ) {
+ if( m_bIsRunning ) {
+ UString *aUString ;
+ ContextInformation ci = (*m_pDebuggingRef)->getContextInformation(atoi(&pcLine[2]));
+ int i,iMax;
+
+ fprintf( stderr, "File %s (%d)\n", USTRING_TO_PCHAR(ci.Name),
+ ci.StartLine );
+ fprintf( stderr, "Available variables : \n" );
+ aUString = ci.LocalVariableNames.getArray();
+ iMax = ci.LocalVariableNames.getLen();
+
+ for( i = 0 ; i < iMax ; i++ ) {
+ fprintf( stderr, " %s\n" , USTRING_TO_PCHAR( aUString[i]) );
+ }
+ }
+ }
+ else if ( !strcmp( pcLine , "d" ) ) {
+ if( m_bIsRunning ) {
+ UString * aUString ;
+ Sequence<UString> seq = (*m_pDebuggingRef)->getStackTrace();
+
+ aUString = seq.getArray();
+ int iMax = seq.getLen();
+ for( int i = 0; i < iMax ; i++ ) {
+ fprintf( stderr , "%s\n" , USTRING_TO_PCHAR( aUString[i] ) );
+ }
+ }
+ }
+ else if( !strcmp( pcLine , "c" ) ) {
+ if( m_bIsRunning ) {
+ (*m_pEngineRef)->cancel();
+ m_aDebugCondition.reset();
+ }
+ else fprintf( stderr,"no script running !\n" );
+ }
+ else if( !strcmp( pcLine , "q" ) ) {
+ if( m_bIsRunning ) {
+ m_aDebugCondition.reset();
+ (*m_pEngineRef)->cancel();
+ }
+ else {
+ m_bIsTerminating = TRUE;
+ fprintf(stderr, "Debugger terminates\n" );
+ break;
+ }
+ }
+ else if( ! strcmp( pcLine , "id" ) ) {
+
+ XIntrospectionAccessRef ref = (*m_pInvokationRef)->getIntrospection();
+
+ dumpIntrospectionToStream( ref , stderr );
+
+
+ }
+ else if( ! strncmp( pcLine , "idv" , 3) ) {
+ try {
+ UsrAny any = (*m_pInvokationRef)->getValue( PCHAR_TO_USTRING( &(pcLine[4]) ) );
+ dumpVarToStream( &(pcLine[4]) , any , stderr );
+ }
+ catch(UnknownPropertyException& e ) {
+ fprintf( stderr, "UnknownPropertyException\n" );
+ }
+ catch(IllegalArgumentException& e ) {
+ fprintf( stderr, "IllegalArgumentException\n" );
+ }
+ }
+ else if( !strcmp( pcLine , "t" ) ) {
+ }
+ else if( !strcmp( pcLine , "h" ) ) {
+ fprintf( stderr , "\nvalid commands :\n"
+ "Go : g\n"
+ "StepOver : s\n"
+ "StepIn : si\n"
+ "StepOut : so\n"
+ "Set BreakPoint : sbp Line [ModuleName]\n"
+ "Remove BreakPoint : rbp [Line] [ModuleName]\n"
+ "via XDebugging Interface :\n"
+ " dump Variable : dv varname [CallStack]\n"
+ " set Variable : sv varname value [CallStack]\n"
+ "globals via XInvokation Interface :\n"
+ " dump Global vars : id\n"
+ " dump Variable : idv varname\n"
+ " set Variable : isv varname value\n"
+ "ContextInformation : ci\n"
+ "Dump callstack : d\n"
+ "Cancel : c (stops actual script)\n"
+ "Quit : q (exits debugger)\n"
+ );
+ }
+ else if( ! strlen( pcLine ) ) {
+ }
+ else {
+ fprintf( stderr , "unknown command %s\n" , pcLine );
+ }
+ }
+}
+
+void CmdDebugger::dumpIntrospectionToStream( const XIntrospectionAccessRef &ref, FILE *f )
+{
+ int i,iMax;
+ fprintf( stderr, "Callable Attributes (Methods) :\n" );
+ Sequence<XIdlMethodRef> seq = ref->getMethods( 0 );
+ iMax = seq.getLen();
+ XIdlMethodRef *aRef = seq.getArray();
+ for( i = 0; i < iMax ; i++ ) {
+ fprintf( f, " %s\n" , USTRING_TO_PCHAR( aRef[i]->getName( ) ) );
+ }
+
+ fprintf( stderr, "Other attributes\n" );
+ Sequence<Property> seqProp = ref->getProperties( 0 );
+ iMax = seqProp.getLen();
+ Property *aProp = seqProp.getArray();
+ for( i = 0; i < iMax ; i ++ ) {
+ fprintf( f, " %s %s\n" , USTRING_TO_PCHAR( aProp[i].Type->getName() ),
+ USTRING_TO_PCHAR( aProp[i].Name ) );
+ }
+
+}
+
+void CmdDebugger::dumpVarToStream( const char *pc , const UsrAny &aValue, FILE *f )
+{
+ TypeClass type = aValue.getReflection()->getTypeClass();
+
+ if( TypeClass_INT == type ) {
+ fprintf( f, "INT32 %s : %d\n" , pc , aValue.getINT32() );
+ }
+ else if( TypeClass_ENUM == type ) {
+ fprintf( f, "ENUM %s : %d\n", pc , aValue.getEnumAsINT32() );
+ }
+ else if( TypeClass_STRING == type ) {
+ fprintf( f, "STRING %s : %s\n" , pc , USTRING_TO_PCHAR( aValue.getString()) );
+ }
+ else if( TypeClass_BOOLEAN == type ) {
+ fprintf( f, "BOOL %s : %d\n", pc , aValue.getBOOL() );
+ }
+ else if( TypeClass_CHAR == type ) {
+ fprintf( f, "char %s : %d\n", pc , ( INT32) aValue.getChar() );
+ }
+ else if( TypeClass_SHORT == type ) {
+ fprintf( f, "INT16 %s : %d\n", pc , (INT32) aValue.getINT16());
+ }
+ else if( TypeClass_LONG == type ) {
+ fprintf( f, "LONG %s : %d\n", pc , (INT32) aValue.getINT32());
+ }
+ else if( TypeClass_UNSIGNED_SHORT == type ) {
+ fprintf( f, "UINT16 %s : %d\n", pc , (INT32) aValue.getUINT16() );
+ }
+ else if( TypeClass_UNSIGNED_BYTE == type ) {
+ fprintf( f, "Byte %s : %d\n", pc , (INT32) aValue.getBYTE() );
+ }
+ else if( TypeClass_UNSIGNED_INT == type ) {
+ fprintf( f, "UINT32 %s : %d\n", pc , aValue.getUINT32() );
+ }
+ else if( TypeClass_FLOAT == type ) {
+ fprintf( f, "float %s : %f\n" , pc , aValue.getFloat() );
+ }
+ else if( TypeClass_DOUBLE == type ) {
+ fprintf( f, "double %s : %f\n" , pc , aValue.getDouble() );
+ }
+ else if( TypeClass_VOID == type ) {
+ fprintf( f, "void %s :\n" , pc );
+ }
+ else if( TypeClass_INTERFACE == type ) {
+ // Check, what has been put in
+ if( aValue.getReflection() == XPropertySet_getReflection() ) {
+ // XPropertySet !
+ XPropertySetRef *pRef = ( XPropertySetRef * ) aValue.get();
+ XPropertySetInfoRef refInfo = (*pRef)->getPropertySetInfo();
+ Sequence< Property > seq = refInfo->getProperties();
+ int i,iMax = seq.getLen();
+
+ Property *pArray;
+ pArray = seq.getArray();
+ fprintf( stderr, "Property List :\n" );
+ for( i = 0; i < iMax ; i ++ ) {
+ fprintf( f, "%s\t %s\n" , USTRING_TO_PCHAR(pArray[i].Type->getName()),
+ USTRING_TO_PCHAR( pArray[i].Name ) );
+ }
+ }
+ else if( aValue.getReflection() == XInvokation_getReflection() ) {
+ XInvokationRef *pRef = ( XInvokationRef * ) aValue.get();
+ XIntrospectionAccessRef refIntro = (*pRef)->getIntrospection();
+
+ dumpIntrospectionToStream( refIntro, stderr );
+ }
+ }
+ else if( TypeClass_SEQUENCE == type ) {
+ fprintf( f , "%s Sequence \n" , pc );
+ String s( " " );
+ s += pc;
+ SequenceReflection *pSeqRefl = ( SequenceReflection * ) aValue.getReflection();
+
+ int i,iMax = pSeqRefl->getLen( aValue );
+
+ for( i = 0 ; i < iMax ; i ++ ) {
+ dumpVarToStream( s.GetCharStr() , pSeqRefl->get( aValue , i ) , stderr );
+ }
+ }
+ else {
+ fprintf( f, "%s : unknown %d\n" , pc , type );
+ }
+
+}
+
+void CmdDebugger::detach()
+{
+ OSL_ASSERT( m_pDebuggingRef );
+
+ m_bIsRunning = FALSE;
+ m_pDebuggingRef = 0;
+ m_pEngineRef = 0;
+ m_pInvokationRef = 0;
+}
+
+// Methoden von XInterface
+BOOL CmdDebugger::queryInterface( Uik aUik, XInterfaceRef & rOut )
+{
+ if( aUik == XEngineListener::getSmartUik() )
+ rOut = (XEngineListener*)this;
+ else
+ return OWeakObject::queryInterface( aUik, rOut );
+ return TRUE;
+}
+
+
+
+
+
+
+/*
+ * main.
+ */
+int __LOADONCALLAPI main (int argc, char **argv)
+{
+ XMultiServiceFactoryRef xSMgr = createRegistryServiceManager();
+ registerUsrServices( xSMgr );
+ setProcessServiceManager( xSMgr );
+
+ XInterfaceRef x = xSMgr->createInstance( L"stardiv.uno.repos.ImplementationRegistration" );
+ XImplementationRegistrationRef xReg( x, USR_QUERY );
+ sal_Char szBuf[1024];
+
+ ORealDynamicLoader::computeModuleName( "pythonengine", szBuf, 1024 );
+ UString aDllName( StringToOUString( szBuf, CHARSET_SYSTEM ) );
+ xReg->registerImplementation( L"stardiv.loader.SharedLibrary", aDllName, XSimpleRegistryRef() );
+
+ ORealDynamicLoader::computeModuleName( "aps", szBuf, 1024 );
+ aDllName = UString( StringToOUString( szBuf, CHARSET_SYSTEM ) );
+ xReg->registerImplementation( L"stardiv.loader.SharedLibrary", aDllName, XSimpleRegistryRef() );
+
+ XInterfaceRef y = xSMgr->createInstance( L"stardiv.script.Python" );
+ XEngineRef yEngine( y, USR_QUERY );
+
+ x = xSMgr->createInstance( L"stardiv.script.Python" );
+ XEngineRef xEngine( x, USR_QUERY );
+
+
+ UString Script;
+
+ Sequence<UsrAny> args(3);
+ UsrAny *pArray = args.getArray();
+ pArray[0].setString( L"Arg_0" );
+ pArray[1].setString( L"Arg_1" );
+ pArray[2].setString( L"Arg_2" );
+
+ if( argc > 2) {
+ Script = StringToOUString( String( argv[2] ) , CHARSET_DONTKNOW );
+ }
+
+ XInvokationRef xInvokation( x , USR_QUERY );
+ XDebuggingRef xDebug( x , USR_QUERY );
+
+ CmdDebugger *pDbg = new CmdDebugger( &xDebug , &xEngine , &xInvokation );
+
+ XEngineListenerRef xDebugRef( (XEngineListener *) pDbg , USR_QUERY);
+ xEngine->addEngineListener( xDebugRef );
+
+
+ if( argc >1 && ! strcmp( argv[1] , "1" ) ) {
+ fprintf( stderr, "one thread only\n" );
+ Script = UString( L"print 'Hello World'\n" );
+ xEngine->runAsync( Script , XInterfaceRef(), args , XEngineListenerRef() );
+ }
+ else if( argc >1 && ! strcmp( argv[1] , "2" ) ) {
+
+ xEngine->runAsync( UString( L"x=1\nprint 1\n") , XInterfaceRef(), args , XEngineListenerRef() );
+ xEngine->runAsync( UString( L"x=x+1\nprint 2\n") , XInterfaceRef(), args , XEngineListenerRef() );
+ xEngine->runAsync( UString( L"x=x+1\nprint 3\n") , XInterfaceRef(), args , XEngineListenerRef());
+ xEngine->runAsync( UString( L"x=x+1\nprint 4\n") , XInterfaceRef(), args , XEngineListenerRef() );
+
+
+
+ }
+ else if( argc >1 && ! strcmp( argv[1] , "3" ) ) {
+
+ fprintf( stderr , "1st thread in engine y, next 5 threads in engine x\n" );
+ yEngine->runAsync( UString( L"print 1\n") , XInterfaceRef(), args , XEngineListenerRef() );
+ xEngine->runAsync( UString( L"print 2\n") , XInterfaceRef(), args , XEngineListenerRef() );
+ xEngine->runAsync( UString( L"print 3\n") , XInterfaceRef(), args , XEngineListenerRef() );
+ xEngine->runAsync( UString( L"print 4\n") , XInterfaceRef(), args , XEngineListenerRef());
+ xEngine->runAsync( UString( L"print 5\n") , XInterfaceRef(), args , XEngineListenerRef());
+ xEngine->runAsync( UString( L"print 6\n") , XInterfaceRef(), args , XEngineListenerRef());
+
+
+ }
+ pDbg->cmdLine();
+
+ xEngine->removeEngineListener( xDebugRef );
+
+ xReg->revokeImplementation( aDllName, XSimpleRegistryRef() );
+
+ fprintf( stderr, "main terminates\n" );
+ return 0;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/workben/testcomponent.cxx b/extensions/workben/testcomponent.cxx
new file mode 100644
index 000000000000..e32a53769830
--- /dev/null
+++ b/extensions/workben/testcomponent.cxx
@@ -0,0 +1,222 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+
+//------------------------------------------------------
+// testcomponent - Loads a service and its testcomponent from dlls performs a test.
+// Expands the dll-names depending on the actual environment.
+// Example : testcomponent stardiv.uno.io.Pipe stm
+//
+// Therefor the testcode must exist in teststm and the testservice must be named test.stardiv.uno.io.Pipe
+//
+
+#include <stdio.h>
+#include <smart/com/sun/star/registry/XImplementationRegistration.hxx>
+#include <smart/com/sun/star/lang/XComponent.hxx>
+
+#include <osl/diagnose.h>
+#include <usr/services.hxx>
+#include <vcl/svapp.hxx>
+#include <usr/ustring.hxx>
+#include <tools/string.hxx>
+#include <osl/conditn.hxx>
+
+#include <smart/com/sun/star/test/XSimpleTest.hxx>
+
+using namespace rtl;
+using namespace usr;
+
+
+// Needed to switch on solaris threads
+#ifdef SOLARIS
+extern "C" void ChangeGlobalInit();
+#endif
+
+int __LOADONCALLAPI main (int argc, char **argv)
+{
+
+ if( argc < 3) {
+ printf( "usage : testcomponent service dll [additional dlls]\n" );
+ exit( 0 );
+ }
+#ifdef SOLARIS
+ // switch on threads in solaris
+ ChangeGlobalInit();
+#endif
+
+ // create service manager
+// XMultiServiceFactoryRef xSMgr = getProcessServiceManager();
+ XMultiServiceFactoryRef xSMgr = createRegistryServiceManager();
+ OSL_ASSERT( xSMgr.is() );
+ registerUsrServices( xSMgr );
+ setProcessServiceManager( xSMgr );
+
+ XImplementationRegistrationRef xReg;
+ XSimpleRegistryRef xSimpleReg;
+
+ try {
+ // Create registration service
+ XInterfaceRef x = xSMgr->createInstance(
+ UString::createFromAscii( "com.sun.star.registry.ImplementationRegistration" ) );
+ x->queryInterface( XImplementationRegistration::getSmartUik() , xReg );
+
+/* x = xSMgr->createInstance( L"stardiv.uno.repos.SimpleRegistry" );
+ OSL_ASSERT( x.is() );
+ x->queryInterface( XSimpleRegistry::getSmartUik() , xSimpleReg );
+ OSL_ASSERT( xSimpleReg.is() );
+ xSimpleReg->open( L"testcomp.rdb" , FALSE , TRUE );
+*/ }
+ catch( Exception& e ) {
+ printf( "%s\n" , OWStringToOString( e.getName() , CHARSET_SYSTEM ).getStr() );
+ exit(1);
+ }
+
+ sal_Char szBuf[1024];
+ OString sTestName;
+
+ try {
+ // Load dll for the tested component
+ for( int n = 2 ; n <argc ; n ++ ) {
+ ORealDynamicLoader::computeModuleName( argv[n] , szBuf, 1024 );
+ UString aDllName( OStringToOWString( szBuf, CHARSET_SYSTEM ) );
+
+ xReg->registerImplementation(
+ UString::createFromAscii( "com.sun.star.loader.SharedLibrary" ),
+ aDllName,
+ xSimpleReg );
+ }
+ }
+ catch( Exception& e ) {
+ printf( "Couldn't reach dll %s\n" , szBuf );
+ printf( "%s\n" , OWStringToOString( e.getName() , CHARSET_SYSTEM ).getStr() );
+
+ exit(1);
+ }
+
+
+ try {
+ // Load dll for the test component
+ sTestName = "test";
+ sTestName += argv[2];
+
+ ORealDynamicLoader::computeModuleName( sTestName.getStr() , szBuf, 1024 );
+ UString aDllName = OStringToOWString( szBuf, CHARSET_SYSTEM );
+ xReg->registerImplementation(
+ UString::createFromAscii( "com.sun.star.loader.SharedLibrary" ) ,
+ aDllName,
+ xSimpleReg );
+ }
+ catch( Exception& e ) {
+ printf( "Couldn't reach dll %s\n" , szBuf );
+ printf( "%s\n" , OWStringToOString( e.getName() , CHARSET_SYSTEM ).getStr() );
+ exit(1);
+ }
+
+
+ // Instantiate test service
+ sTestName = "test.";
+ sTestName += argv[1];
+
+ XInterfaceRef xIntTest = xSMgr->createInstance( OStringToOWString( sTestName , CHARSET_SYSTEM ) );
+ XSimpleTestRef xTest( xIntTest , USR_QUERY );
+
+ if( ! xTest.is() ) {
+ printf( "Couldn't instantiate test service \n" );
+ exit( 1 );
+ }
+
+
+ INT32 nHandle = 0;
+ INT32 nNewHandle;
+ INT32 nErrorCount = 0;
+ INT32 nWarningCount = 0;
+
+ // loop until all test are performed
+ while( nHandle != -1 ) {
+
+ // Instantiate serivce
+ XInterfaceRef x = xSMgr->createInstance( OStringToOWString( argv[1] , CHARSET_SYSTEM ) );
+ if( ! x.is() ) {
+ printf( "Couldn't instantiate service !\n" );
+ exit( 1 );
+ }
+
+ // do the test
+ try {
+ nNewHandle = xTest->test( OStringToOWString( argv[1] , CHARSET_SYSTEM ) , x , nHandle );
+ }
+ catch ( Exception& e ) {
+ printf( "testcomponent : uncaught exception %s\n" ,
+ OWStringToOString( e.getName(), CHARSET_SYSTEM ).getStr() );
+ exit(1);
+ }
+ catch(...) {
+ printf( "testcomponent : uncaught unknown exception\n" );
+ exit(1);
+ }
+
+
+ // print errors and warning
+ Sequence<UString> seqErrors = xTest->getErrors();
+ Sequence<UString> seqWarnings = xTest->getWarnings();
+ if( seqWarnings.getLen() > nWarningCount ) {
+ printf( "Warnings during test %d!\n" , nHandle );
+ for( ; nWarningCount < seqWarnings.getLen() ; nWarningCount ++ ) {
+ printf( "Warning\n%s\n---------\n" ,
+ OWStringToOString( seqWarnings.getArray()[nWarningCount], CHARSET_SYSTEM ).getStr() );
+ }
+ }
+
+
+ if( seqErrors.getLen() > nErrorCount ) {
+ printf( "Errors during test %d!\n" , nHandle );
+ for( ; nErrorCount < seqErrors.getLen() ; nErrorCount ++ ) {
+ printf( "%s\n" ,
+ OWStringToOString(
+ seqErrors.getArray()[nErrorCount], CHARSET_SYSTEM ).getStr() );
+ }
+ }
+
+ nHandle = nNewHandle;
+ }
+
+ if( xTest->testPassed() ) {
+ printf( "Test passed !\n" );
+ }
+ else {
+ printf( "Test failed !\n" );
+ }
+
+ XComponentRef rComp( xSMgr , USR_QUERY );
+ rComp->dispose();
+ return 0;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/workben/testframecontrol.cxx b/extensions/workben/testframecontrol.cxx
new file mode 100644
index 000000000000..ba5d53de11c3
--- /dev/null
+++ b/extensions/workben/testframecontrol.cxx
@@ -0,0 +1,319 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+
+#include <vcl/wrkwin.hxx>
+#include <vcl/svapp.hxx>
+
+#include <stardiv/uno/repos/implementationregistration.hxx>
+#include <stardiv/uno/repos/serinfo.hxx>
+#include <stardiv/uno/awt/vcllstnr.hxx>
+#include <stardiv/uno/awt/device.hxx>
+#include <stardiv/uno/awt/graphics.hxx>
+#include <stardiv/uno/awt/vclwin.hxx>
+
+#include <usr/services.hxx>
+
+#include <svtools/unoiface.hxx>
+
+using namespace usr;
+
+//==================================================================================================
+class Listener_Impl
+ : public UsrObject
+ , public XMouseListener
+ , public XMouseMotionListener
+ , public XKeyListener
+ , public XWindowListener
+ , public XFocusListener
+ , public XPaintListener
+{
+public:
+ SMART_UNO_DECLARATION( Listener_Impl, UsrObject );
+
+ virtual BOOL queryInterface( Uik aUik, XInterfaceRef& rOut );
+
+ // XMouseListener
+ virtual void mousePressed( const VclMouseEvent& evt );
+ virtual void mouseReleased( const VclMouseEvent& evt );
+ virtual void mouseEntered( const VclMouseEvent& evt );
+ virtual void mouseExited( const VclMouseEvent& evt );
+
+ // XMouseMotionListener
+ virtual void mouseDragged( const VclMouseEvent& evt );
+ virtual void mouseMoved( const VclMouseEvent& evt );
+
+ // XKeyListener
+ virtual void keyPressed( const VclKeyEvent& evt );
+ virtual void keyReleased( const VclKeyEvent& evt );
+
+ // XFocusListener
+ virtual void focusGained( const FocusEvent& evt );
+ virtual void focusLost( const FocusEvent& evt );
+
+ // XWindowListener
+ virtual void windowResized( const WindowEvent& evt );
+ virtual void windowMoved( const WindowEvent& evt );
+ virtual void windowShown( const EventObject& evt );
+ virtual void windowHidden( const EventObject& evt );
+
+ // XPaintListener
+ virtual void windowPaint( const PaintEvent& evt );
+
+ // XEventListener
+ virtual void disposing( const EventObject& evt );
+
+public:
+ void addAllListeners( const XControlRef& xControl );
+ void removeAllListeners( const XControlRef& xControl );
+};
+
+//--------------------------------------------------------------------------------------------------
+void Listener_Impl::addAllListeners( const XControlRef& xControl )
+{
+ XWindowRef xWindow( xControl, USR_QUERY );
+
+ xWindow->addMouseListener( (XMouseListener*)this );
+ xWindow->addMouseMotionListener( (XMouseMotionListener*)this );
+ xWindow->addKeyListener( (XKeyListener*)this );
+ xWindow->addFocusListener( (XFocusListener*)this );
+ xWindow->addWindowListener( (XWindowListener*)this );
+ xWindow->addPaintListener( (XPaintListener*)this );
+ // cast due to ambiguities
+ xControl->addEventListener( (XEventListener*)(XPaintListener*)this );
+}
+
+//--------------------------------------------------------------------------------------------------
+void Listener_Impl::removeAllListeners( const XControlRef& xControl )
+{
+ XWindowRef xWindow( xControl, USR_QUERY );
+
+ xWindow->removeMouseListener( (XMouseListener*)this );
+ xWindow->removeMouseMotionListener( (XMouseMotionListener*)this );
+ xWindow->removeKeyListener( (XKeyListener*)this );
+ xWindow->removeFocusListener( (XFocusListener*)this );
+ xWindow->removeWindowListener( (XWindowListener*)this );
+ xWindow->removePaintListener( (XPaintListener*)this );
+ // cast due to ambiguities
+ xControl->removeEventListener( (XEventListener*)(XPaintListener*)this );
+}
+
+//--------------------------------------------------------------------------------------------------
+SMART_UNO_IMPLEMENTATION( Listener_Impl, UsrObject );
+
+//--------------------------------------------------------------------------------------------------
+BOOL Listener_Impl::queryInterface( Uik aUik, XInterfaceRef& rOut )
+{
+ if (aUik == XMouseListener::getSmartUik())
+ rOut = (XMouseListener*)this;
+ else if (aUik == XMouseMotionListener::getSmartUik())
+ rOut = (XMouseMotionListener*)this;
+ else if (aUik == XWindowListener::getSmartUik())
+ rOut = (XWindowListener*)this;
+ else if (aUik == XFocusListener::getSmartUik())
+ rOut = (XFocusListener*)this;
+ else if (aUik == XKeyListener::getSmartUik())
+ rOut = (XKeyListener*)this;
+ else if (aUik == XPaintListener::getSmartUik())
+ rOut = (XPaintListener*)this;
+ else if (aUik == ((XEventListener*)NULL)->getSmartUik())
+ rOut = (XEventListener*)(XMouseListener*)this;
+ else
+ return UsrObject::queryInterface( aUik, rOut );
+
+ return TRUE;
+}
+
+//--------------------------------------------------------------------------------------------------
+// XMouseListener
+void Listener_Impl::mousePressed( const VclMouseEvent& evt ) {}
+void Listener_Impl::mouseReleased( const VclMouseEvent& evt ) {}
+void Listener_Impl::mouseEntered( const VclMouseEvent& evt ) {}
+void Listener_Impl::mouseExited( const VclMouseEvent& evt ) {}
+
+// XMouseMotionListener
+void Listener_Impl::mouseDragged( const VclMouseEvent& evt ) {}
+void Listener_Impl::mouseMoved( const VclMouseEvent& evt ) {}
+
+// XKeyListener
+void Listener_Impl::keyPressed( const VclKeyEvent& evt ) {}
+void Listener_Impl::keyReleased( const VclKeyEvent& evt ) {}
+
+// XFocusListener
+void Listener_Impl::focusGained( const FocusEvent& evt ) {}
+void Listener_Impl::focusLost( const FocusEvent& evt ) {}
+
+// XWindowListener
+void Listener_Impl::windowResized( const WindowEvent& evt ) {}
+void Listener_Impl::windowMoved( const WindowEvent& evt ) {}
+void Listener_Impl::windowShown( const EventObject& evt ) {}
+void Listener_Impl::windowHidden( const EventObject& evt ) {}
+
+// XPaintListener
+void Listener_Impl::windowPaint( const PaintEvent& evt )
+{
+ if (evt.Source.is())
+ {
+ XControlRef xControl( evt.Source, USR_QUERY );
+ if (xControl.is())
+ {
+ XDeviceRef xDev( xControl->getPeer(), USR_QUERY );
+ XGraphicsRef xGraphics = xDev->createGraphics();
+ xGraphics->drawLine( 0, 0, 200, 200 );
+ xGraphics->drawLine( 200, 0, 0, 200 );
+ }
+ }
+}
+
+// XEventListener
+void Listener_Impl::disposing( const EventObject& evt ) {}
+
+
+//==================================================================================================
+class FrameControlApplication
+ : public Application
+{
+public:
+ virtual void Main();
+ virtual void ShowStatusText( const XubString& rText );
+
+public:
+ FrameControlApplication() {}
+
+private:
+ void init();
+ void deinit();
+
+private:
+ Listener_Impl* _pListener;
+ XControlRef _xControl;
+
+ WorkWindow* _pWorkWin;
+};
+
+FrameControlApplication g_App;
+
+#ifdef __MWERKS__
+Application* pApp = &g_App;
+#endif
+
+
+//--------------------------------------------------------------------------------------------------
+void FrameControlApplication::init()
+{
+ XMultiServiceFactoryRef xMgr = createRegistryServiceManager( L"test.rdb" );
+ registerUsrServices( xMgr );
+ setProcessServiceManager( xMgr );
+ InitExtVclToolkit();
+ Application::RegisterUnoServices();
+
+ XServiceRegistryRef xRegMgr(xMgr, USR_QUERY);
+
+ XImplementationRegistrationRef xIR( xMgr->createInstance(L"stardiv.uno.repos.ImplementationRegistration"), USR_QUERY );
+ try
+ {
+ char szDllName[_MAX_PATH]="";
+
+ ORealDynamicLoader::computeModuleName("fc", szDllName, _MAX_PATH);
+ UString aFCDllName = StringToOUString(szDllName, CHARSET_SYSTEM);
+ xIR->registerImplementation(L"stardiv.loader.SharedLibrary", aFCDllName, XSimpleRegistryRef() );
+ }
+ catch( CannotRegisterImplementationException& e )
+ {
+ }
+
+
+
+ // ...
+
+ XInterfaceRef xInst = xMgr->createInstance( L"stardiv.one.frame.FrameControl" );
+ if (xInst->queryInterface( XControl::getSmartUik(), _xControl ))
+ {
+ _pWorkWin = new WorkWindow( NULL, WB_APP | WB_STDWORK );
+ _pWorkWin->Show();
+ XWindowPeerRef xParent( _pWorkWin->GetComponentInterface() );
+
+ XToolkitRef xToolkit( xMgr->createInstance( L"stardiv.vcl.VclToolkit" ), USR_QUERY );
+ //xToolkit = XToolkitRef( xMgr->createInstance( L"stardiv.uno.awt.Toolkit" ), USR_QUERY );
+ _xControl->createPeer( xToolkit, xParent );
+ XWindowRef xWin( _xControl, USR_QUERY );
+ xWin->setPosSize( 50, 50, 400, 400, PosSize_POSSIZE );
+ xWin->setVisible( TRUE );
+
+ _pListener = new Listener_Impl();
+ _pListener->acquire();
+ _pListener->addAllListeners( _xControl );
+ // ... on paint a cross should be drawn
+ }
+}
+
+//--------------------------------------------------------------------------------------------------
+void FrameControlApplication::deinit()
+{
+ if (_pListener)
+ {
+
+ _pListener->removeAllListeners( _xControl );
+ _xControl->dispose(); // disposing event should occur
+ _pListener->release();
+ _pListener = NULL;
+
+ _xControl = XControlRef();
+ }
+
+ _pWorkWin->Hide();
+ delete _pWorkWin;
+}
+
+
+//--------------------------------------------------------------------------------------------------
+void FrameControlApplication::Main()
+{
+// void TestErrcodes();
+// TestErrcodes();
+
+ EnterMultiThread();
+ SetAppName( "RadioActiveControl-Demo" );
+ EnableSVLook();
+
+ init();
+
+ Execute();
+
+ deinit();
+}
+
+//--------------------------------------------------------------------------------------------------
+void FrameControlApplication::ShowStatusText( const XubString& rStatus )
+{
+ Application::GetAppWindow()->SetText( rStatus );
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/workben/testpgp.cxx b/extensions/workben/testpgp.cxx
new file mode 100644
index 000000000000..1a7902c618db
--- /dev/null
+++ b/extensions/workben/testpgp.cxx
@@ -0,0 +1,842 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+#include <sal/types.h>
+#include <rtl/memory.h>
+#ifndef _RTL_WSTRING_
+#include <rtl/wstring>
+#endif
+
+#include <usr/smartservices.hxx>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/io/XInputStream.hpp>
+#include <com/sun/star/io/XOutputStream.hpp>
+#include <com/sun/star/pgp/RecipientsEvent.hpp>
+#include <com/sun/star/pgp/SignatureEvent.hpp>
+#include <com/sun/star/pgp/XPGPDecoder.hpp>
+#include <com/sun/star/pgp/XPGPDecoderListener.hpp>
+#include <com/sun/star/pgp/XPGPEncoder.hpp>
+#include <com/sun/star/pgp/XPGPPreferences.hpp>
+#include <com/sun/star/uno/XInterface.hpp>
+#include <com/sun/star/uno/Any.h>
+#include <com/sun/star/uno/Reference.h>
+#include <com/sun/star/uno/Sequence.hxx>
+#include <cppuhelper/weak.hxx>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <fcntl.h>
+#include <io.h>
+
+using namespace com::sun::star::lang;
+using namespace com::sun::star::io;
+using namespace com::sun::star::pgp;
+using namespace com::sun::star::uno;
+
+/*========================================================================
+ *
+ * DataSource_Impl interface.
+ *
+ *======================================================================*/
+class DataSource_Impl :
+ public OWeakObject,
+ public XInputStream
+{
+ Sequence<sal_Int8> m_buffer;
+ sal_Int32 m_position;
+ int m_fd;
+
+public:
+ DataSource_Impl (int fd = 0);
+ virtual ~DataSource_Impl (void);
+
+ void setBuffer (const Sequence<sal_Int8> &rBuffer);
+
+ /** XInterface.
+ */
+ virtual sal_Bool SAL_CALL queryInterface (
+ const Uik &rUik, Any &rIfc) throw(RuntimeException);
+
+ virtual void SAL_CALL acquire (void) throw(RuntimeException);
+
+ virtual void SAL_CALL release (void) throw(RuntimeException);
+
+ /** XInputStream.
+ */
+ virtual sal_Int32 SAL_CALL readBytes (
+ Sequence<sal_Int8> &rData, sal_Int32 nBytesToRead)
+ throw (NotConnectedException,
+ BufferSizeExceededException,
+ IOException);
+
+ virtual sal_Int32 SAL_CALL readSomeBytes (
+ Sequence<sal_Int8> &rData, sal_Int32 nMaxBytesToRead)
+ throw (NotConnectedException,
+ BufferSizeExceededException,
+ IOException);
+
+ virtual void SAL_CALL skipBytes (sal_Int32 nBytesToSkip)
+ throw (NotConnectedException,
+ BufferSizeExceededException,
+ IOException);
+
+ virtual sal_Int32 SAL_CALL available (void)
+ throw (NotConnectedException, IOException);
+
+ virtual void SAL_CALL closeInput (void)
+ throw (NotConnectedException, IOException);
+};
+
+/*========================================================================
+ *
+ * DataSink_Impl interface.
+ *
+ *======================================================================*/
+class DataSink_Impl :
+ public OWeakObject,
+ public XOutputStream
+{
+ Sequence<sal_Int8> m_buffer;
+
+public:
+ DataSink_Impl (void);
+ virtual ~DataSink_Impl (void);
+
+ const Sequence<sal_Int8>& getBuffer (void) const { return m_buffer; }
+
+ /** XInterface.
+ */
+ virtual sal_Bool SAL_CALL queryInterface (
+ const Uik &rUik, Any &rIfc) throw(RuntimeException);
+
+ virtual void SAL_CALL acquire (void) throw(RuntimeException);
+ virtual void SAL_CALL release (void) throw(RuntimeException);
+
+ /** XOutputStream.
+ */
+ virtual void SAL_CALL writeBytes (
+ const Sequence<sal_Int8> &rBuffer)
+ throw (NotConnectedException,
+ BufferSizeExceededException,
+ IOException);
+
+ virtual void SAL_CALL flush (void)
+ throw (NotConnectedException,
+ BufferSizeExceededException,
+ IOException);
+
+ virtual void SAL_CALL closeOutput (void)
+ throw (NotConnectedException,
+ BufferSizeExceededException,
+ IOException);
+};
+
+/*========================================================================
+ *
+ * DecoderListener_Impl interface.
+ *
+ *======================================================================*/
+class DecoderListener_Impl :
+ public OWeakObject,
+ public XPGPDecoderListener
+{
+public:
+ DecoderListener_Impl (void);
+ virtual ~DecoderListener_Impl (void);
+
+ /** XInterface.
+ */
+ virtual sal_Bool SAL_CALL queryInterface (
+ const Uik &rUik, Any &rIfc) throw(RuntimeException);
+
+ virtual void SAL_CALL acquire (void) throw(RuntimeException);
+
+ virtual void SAL_CALL release (void) throw(RuntimeException);
+
+ /** XEventListener.
+ */
+ virtual void SAL_CALL disposing (const EventObject &rSource);
+
+ /** XPGPDecoderListener.
+ */
+ virtual void SAL_CALL decrypted (const RecipientsEvent &rEvent);
+ virtual void SAL_CALL verified (const SignatureEvent &rEvent);
+};
+
+/*========================================================================
+ *
+ * DataSource_Impl implementation.
+ *
+ *======================================================================*/
+/*
+ * DataSource_Impl.
+ */
+DataSource_Impl::DataSource_Impl (int fd)
+ : m_fd (fd), m_position (0)
+{
+}
+
+/*
+ * ~DataSource_Impl.
+ */
+DataSource_Impl::~DataSource_Impl (void)
+{
+}
+
+/*
+ * DataSource_Impl: setBuffer.
+ */
+void DataSource_Impl::setBuffer (const Sequence<sal_Int8> &rBuffer)
+{
+ m_buffer = rBuffer;
+ if (!m_buffer.getLength())
+ {
+ // Fill buffer from file descriptor.
+ char buffer[1024];
+ rtl_zeroMemory (buffer, sizeof(buffer));
+
+ int k = read (m_fd, buffer, sizeof(buffer));
+ while (k > 0)
+ {
+ sal_Int32 n = m_buffer.getLength();
+ m_buffer.realloc (n + k);
+
+ rtl_copyMemory (m_buffer.getArray() + n, buffer, k);
+ n += k;
+
+ rtl_zeroMemory (buffer, k);
+ k = read (m_fd, buffer, sizeof(buffer));
+ }
+ }
+ m_position = 0;
+}
+
+/*
+ * XInterface: queryInterface.
+ */
+sal_Bool SAL_CALL DataSource_Impl::queryInterface (
+ const Uik &rUik, Any &rIfc) throw(RuntimeException)
+{
+ if (com::sun::star::uno::queryInterface (
+ rUik, rIfc,
+ SAL_STATIC_CAST (XInputStream*, this)))
+ return sal_True;
+ else
+ return OWeakObject::queryInterface (rUik, rIfc);
+}
+
+/*
+ * XInterface: acquire.
+ */
+void SAL_CALL DataSource_Impl::acquire (void) throw(RuntimeException)
+{
+ OWeakObject::acquire();
+}
+
+/*
+ * XInterface: release.
+ */
+void SAL_CALL DataSource_Impl::release (void) throw(RuntimeException)
+{
+ OWeakObject::release();
+}
+
+/*
+ * XInputStream: readBytes.
+ */
+sal_Int32 SAL_CALL DataSource_Impl::readBytes (
+ Sequence<sal_Int8> &rData, sal_Int32 nBytesToRead)
+ throw (NotConnectedException, BufferSizeExceededException, IOException)
+{
+ if (nBytesToRead < 0)
+ throw IOException();
+
+ sal_Int32 k = m_buffer.getLength() - m_position;
+ k = SAL_BOUND(k, 0, nBytesToRead);
+ if (k > 0)
+ {
+ rData.realloc(k);
+ rtl_copyMemory (
+ rData.getArray(), m_buffer.getConstArray() + m_position, k);
+ m_position += k;
+ }
+ return k;
+}
+
+/*
+ * XInputStream: readSomeBytes.
+ */
+sal_Int32 SAL_CALL DataSource_Impl::readSomeBytes (
+ Sequence<sal_Int8> &rData, sal_Int32 nMaxBytesToRead)
+ throw (NotConnectedException, BufferSizeExceededException, IOException)
+{
+ return readBytes (rData, nMaxBytesToRead);
+}
+
+/*
+ * XInputStream: skipBytes.
+ */
+void SAL_CALL DataSource_Impl::skipBytes (sal_Int32 nBytesToSkip)
+ throw (NotConnectedException, BufferSizeExceededException, IOException)
+{
+ if (nBytesToSkip < 0)
+ throw IOException();
+
+ m_position += nBytesToSkip;
+}
+
+/*
+ * XInputStream: available.
+ */
+sal_Int32 SAL_CALL DataSource_Impl::available (void)
+ throw (NotConnectedException, IOException)
+{
+ sal_Int32 k = m_buffer.getLength() - m_position;
+ return ((k > 0) ? k : 0);
+}
+
+/*
+ * XInputStream: closeInput.
+ */
+void SAL_CALL DataSource_Impl::closeInput (void)
+ throw (NotConnectedException, IOException)
+{
+}
+
+/*========================================================================
+ *
+ * DataSink_Impl implementation.
+ *
+ *======================================================================*/
+/*
+ * DataSink_Impl.
+ */
+DataSink_Impl::DataSink_Impl (void)
+{
+}
+
+/*
+ * ~DataSink_Impl.
+ */
+DataSink_Impl::~DataSink_Impl (void)
+{
+}
+
+/*
+ * XInterface: queryInterface.
+ */
+sal_Bool SAL_CALL DataSink_Impl::queryInterface (
+ const Uik &rUik, Any &rIfc) throw(RuntimeException)
+{
+ if (com::sun::star::uno::queryInterface (
+ rUik, rIfc,
+ SAL_STATIC_CAST (XOutputStream*, this)))
+ return sal_True;
+ else
+ return OWeakObject::queryInterface (rUik, rIfc);
+}
+
+/*
+ * XInterface: acquire.
+ */
+void SAL_CALL DataSink_Impl::acquire (void) throw(RuntimeException)
+{
+ OWeakObject::acquire();
+}
+
+/*
+ * XInterface: release.
+ */
+void SAL_CALL DataSink_Impl::release (void) throw(RuntimeException)
+{
+ OWeakObject::release();
+}
+
+/*
+ * XOutputStream: writeBytes.
+ */
+void SAL_CALL DataSink_Impl::writeBytes (const Sequence<sal_Int8> &rBuffer)
+ throw (NotConnectedException, BufferSizeExceededException, IOException)
+{
+ if (rBuffer.getLength())
+ {
+ sal_Int32 n = m_buffer.getLength();
+ m_buffer.realloc (n + rBuffer.getLength());
+
+ rtl_copyMemory (
+ m_buffer.getArray() + n,
+ rBuffer.getConstArray(),
+ rBuffer.getLength());
+ }
+}
+
+/*
+ * XOutputStream: flush.
+ */
+void SAL_CALL DataSink_Impl::flush (void)
+ throw (NotConnectedException, BufferSizeExceededException, IOException)
+{
+ if (m_buffer.getLength())
+ {
+ // Write data to stdout.
+ const sal_Int8 *pData = m_buffer.getConstArray();
+ sal_Int32 nData = m_buffer.getLength();
+
+ int prev = ::setmode (1, O_BINARY);
+ if (!(prev < 0))
+ {
+ int k = ::write (1, pData, nData);
+ if (k > 0)
+ ::write (1, "\n", 1);
+ ::setmode (1, prev);
+ }
+ }
+}
+
+/*
+ * XOutputStream: closeOutput.
+ */
+void SAL_CALL DataSink_Impl::closeOutput (void)
+ throw (NotConnectedException, BufferSizeExceededException, IOException)
+{
+ flush();
+}
+
+/*========================================================================
+ *
+ * DecoderListener_Impl implementation.
+ *
+ *======================================================================*/
+/*
+ * DecoderListener_Impl.
+ */
+DecoderListener_Impl::DecoderListener_Impl (void)
+{
+}
+
+/*
+ * ~DecoderListener_Impl.
+ */
+DecoderListener_Impl::~DecoderListener_Impl (void)
+{
+}
+
+/*
+ * XInterface: queryInterface.
+ */
+sal_Bool SAL_CALL DecoderListener_Impl::queryInterface (
+ const Uik &rUik, Any &rIfc) throw(RuntimeException)
+{
+ if (com::sun::star::uno::queryInterface (
+ rUik, rIfc,
+ SAL_STATIC_CAST (XEventListener*, this),
+ SAL_STATIC_CAST (XPGPDecoderListener*, this)))
+ return sal_True;
+ else
+ return OWeakObject::queryInterface (rUik, rIfc);
+}
+
+/*
+ * XInterface: acquire.
+ */
+void SAL_CALL DecoderListener_Impl::acquire (void) throw(RuntimeException)
+{
+ OWeakObject::acquire();
+}
+
+/*
+ * XInterface: release.
+ */
+void SAL_CALL DecoderListener_Impl::release (void) throw(RuntimeException)
+{
+ OWeakObject::release();
+}
+
+/*
+ * XEventListener: disposing.
+ */
+void SAL_CALL DecoderListener_Impl::disposing (const EventObject &rSource)
+{
+}
+
+/*
+ * XPGPDecoderListener: decrypted.
+ */
+void SAL_CALL DecoderListener_Impl::decrypted (const RecipientsEvent &rEvent)
+{
+}
+
+/*
+ * XPGPDecoderListener: verified.
+ */
+void SAL_CALL DecoderListener_Impl::verified (const SignatureEvent &rEvent)
+{
+}
+
+/*========================================================================
+ *
+ * Main.
+ *
+ *======================================================================*/
+inline rtl::OWString S2U (const sal_Char *ascii)
+{
+ return rtl::OWString::createFromAscii (ascii);
+}
+
+#if 0 /* OLD */
+
+/*
+ * queryModuleActivator.
+ */
+BOOL queryModuleActivator (
+ const XServiceManagerRef &rxManager,
+ XServiceActivatorRef &rxActivator)
+{
+ XServiceProviderRef xProv;
+ XInterfaceRef xProvInst;
+
+ xProv = rxManager->queryServiceProvider (
+ L"stardiv.uno.ServiceActivator.module");
+ if (!xProv.is())
+ {
+ printf ("Error: no ServiceActivator service.\n");
+ return FALSE;
+ }
+
+ xProvInst = xProv->createInstance();
+ if (!xProvInst.is())
+ {
+ printf ("Error: no ServiceActivator instance.\n");
+ return FALSE;
+ }
+
+ return xProvInst->queryInterface (
+ XServiceActivator::getSmartUik(), rxActivator);
+}
+
+/*
+ * install.
+ */
+BOOL install (
+ const XServiceActivatorRef &rxActivator,
+ const char *prefix)
+{
+ String aModule ("module://");
+ char pBuffer[1024];
+
+ vos:ORealDynamicLoader::computeModuleName (
+ prefix, pBuffer, sizeof(pBuffer));
+ aModule += pBuffer;
+
+ return rxActivator->install (
+ StringToUString (aModule, CHARSET_SYSTEM));
+}
+
+/*
+ * uninstall.
+ */
+BOOL uninstall (
+ const XServiceActivatorRef &rxActivator,
+ const char *prefix)
+{
+ String aModule ("module://");
+ char pBuffer[1024];
+
+ vos::ORealDynamicLoader::computeModuleName (
+ prefix, pBuffer, sizeof(pBuffer));
+ aModule += pBuffer;
+
+ return rxActivator->deinstall (
+ StringToUString (aModule, CHARSET_SYSTEM));
+}
+
+#endif /* OLD */
+
+/*
+ * main.
+ */
+int SAL_CALL main (int argc, char **argv)
+{
+ enum Option
+ {
+ OPTION_INSTALL = 0x01,
+ OPTION_UNINSTALL = 0x02,
+
+ OPTION_DECRYPT = 0x04,
+ OPTION_ENCRYPT = 0x08,
+ OPTION_SIGN = 0x10,
+
+ OPTION_FILE = 0x20,
+ OPTION_HELP = 0x40
+ };
+
+ int fd = 0;
+ unsigned long nOptions = 0;
+
+ for (int i = 1; i < argc; i++)
+ {
+ const char *opt = argv[i];
+ if (opt[0] == '-')
+ {
+ switch (opt[1])
+ {
+ case 'i':
+ nOptions |= OPTION_INSTALL;
+ break;
+
+ case 'u':
+ nOptions |= OPTION_UNINSTALL;
+ break;
+
+ case 'd':
+ nOptions |= OPTION_DECRYPT;
+ break;
+
+ case 'e':
+ nOptions |= OPTION_ENCRYPT;
+ break;
+
+ case 's':
+ nOptions |= OPTION_SIGN;
+ break;
+
+ case 'f':
+ nOptions |= OPTION_FILE;
+ break;
+
+ case 'h':
+ default:
+ nOptions |= OPTION_HELP;
+ break;
+ }
+ }
+ else
+ {
+ if (nOptions & OPTION_FILE)
+ {
+ if ((fd = open (argv[i], O_RDONLY | O_BINARY)) < 0)
+ {
+ printf ("Error: can't open file: %s\n", argv[i]);
+ exit (0);
+ }
+ }
+ }
+ }
+
+ if ((nOptions == 0) || (nOptions & OPTION_HELP))
+ {
+ printf ("Options:\n");
+ printf ("-i\tinstall module\n");
+ printf ("-u\tuninstall module\n");
+ printf ("-d\tdecrypt and verify\n");
+ printf ("-e\tencrypt test pattern\n");
+ printf ("-s\tsign test pattern\n");
+ printf ("-h\thelp\n");
+ exit (0);
+ }
+
+ Reference<XMultiServiceFactory> xManager (
+ usr::createDefaultSmartRegistryServiceFactory());
+ if (!xManager.is())
+ {
+ printf ("Error: no ProcessServiceManager.\n");
+ exit (1);
+ }
+ usr::setProcessServiceFactory (xManager);
+
+ if (nOptions & OPTION_INSTALL)
+ {
+#if 0 /* OLD */
+ XServiceActivatorRef xActivator;
+ if (queryModuleActivator (xManager, xActivator))
+ {
+ if (install (xActivator, "pgp"))
+ printf ("Module PGP installed.\n");
+ else
+ printf ("Error: module PGP not installed.\n");
+ }
+ nOptions &= ~OPTION_INSTALL;
+#endif /* OLD */
+ }
+
+ if (nOptions & (OPTION_DECRYPT | OPTION_ENCRYPT | OPTION_SIGN))
+ {
+ Reference<XMultiServiceFactory> xProv (
+ xManager->createInstance (
+ S2U("com.sun.star.pgp.PGPFactory")),
+ UNO_QUERY);
+ if (!xProv.is())
+ {
+ printf ("Error: no PGPFactory service.\n");
+ exit (1);
+ }
+
+ Reference<XInterface> xProvInst (
+ xProv->createInstance (
+ S2U("com.sun.star.pgp.SimplePGPMailer")));
+ if (!xProvInst.is())
+ {
+ printf ("Error: no SimplePGPMailer service.\n");
+ exit (2);
+ }
+
+ Reference<XPGPPreferences> xPrefs (xProvInst, UNO_QUERY);
+ if (xPrefs.is())
+ {
+ unsigned long nDefaults = 0;
+
+ if (xPrefs->getEncryptByDefault())
+ nDefaults |= OPTION_ENCRYPT;
+ if (xPrefs->getSignByDefault())
+ nDefaults |= OPTION_SIGN;
+ if (xPrefs->getAutoDecrypt())
+ nDefaults |= OPTION_DECRYPT;
+
+ if (nDefaults)
+ {
+ }
+ }
+
+ static const sal_Int8 pData[] = "" /* "Hello PGP World." */;
+ Sequence<sal_Int8> buffer (pData, sizeof (pData) - 1);
+
+ if (nOptions & (OPTION_ENCRYPT | OPTION_SIGN))
+ {
+ Reference<XPGPEncoder> xEncoder (xProvInst, UNO_QUERY);
+ if (!xEncoder.is())
+ {
+ printf ("Error: no PGPEncoder interface.\n");
+ exit (4);
+ }
+
+ DataSource_Impl *source = new DataSource_Impl (fd);
+ source->setBuffer (buffer);
+
+ DataSink_Impl *sink = new DataSink_Impl;
+
+ Reference<XInputStream> xPlainText (source);
+ Reference<XOutputStream> xCipherText (sink);
+
+ if (nOptions & OPTION_ENCRYPT)
+ {
+ rtl::OWString aRecipients[] =
+ {
+ S2U("er@stardiv.de"),
+ // L"mhu@stardivision.de",
+ S2U("mhu@rabbit")
+ };
+
+ sal_Int32 nRecipients = SAL_N_ELEMENTS(aRecipients);
+
+ if (nOptions & OPTION_SIGN)
+ {
+ xEncoder->encryptAndSign (
+ Sequence<rtl::OWString>(aRecipients, nRecipients),
+ xPlainText,
+ xCipherText);
+ nOptions &= ~OPTION_SIGN;
+ }
+ else
+ {
+ xEncoder->encrypt (
+ Sequence<rtl::OWString>(aRecipients, nRecipients),
+ xPlainText,
+ xCipherText);
+ }
+ nOptions &= ~OPTION_ENCRYPT;
+ }
+
+ if (nOptions & OPTION_SIGN)
+ {
+ sal_Bool bDataIsAscii = (fd == 0); // stdin.
+
+ xEncoder->sign (
+ bDataIsAscii,
+ xPlainText,
+ xCipherText);
+ nOptions &= ~OPTION_SIGN;
+ }
+
+ buffer = sink->getBuffer();
+ }
+
+ if (nOptions & OPTION_DECRYPT)
+ {
+ Reference<XPGPDecoder> xDecoder (xProvInst, UNO_QUERY);
+ if (!xDecoder.is())
+ {
+ printf ("Error: no PGPDecoder interface.\n");
+ exit (5);
+ }
+
+ DataSource_Impl *source = new DataSource_Impl;
+ source->setBuffer (buffer);
+
+ DataSink_Impl *sink = new DataSink_Impl;
+
+ Reference<XInputStream> xCipherText (source);
+ Reference<XOutputStream> xPlainText (sink);
+
+ Reference<XPGPDecoderListener> xListener (
+ new DecoderListener_Impl);
+ xDecoder->addDecoderListener (xListener);
+
+ xDecoder->decryptAndVerify (
+ xCipherText,
+ xPlainText);
+ nOptions &= ~OPTION_DECRYPT;
+
+ xDecoder->removeDecoderListener (xListener);
+
+ buffer = sink->getBuffer();
+ }
+ }
+
+ if (nOptions & OPTION_UNINSTALL)
+ {
+#if 0 /* OLD */
+ XServiceActivatorRef xActivator;
+ if (queryModuleActivator (xManager, xActivator))
+ {
+ if (uninstall (xActivator, "pgp"))
+ printf ("Module PGP uninstalled.\n");
+ else
+ printf ("Error: module PGP not uninstalled.\n");
+ }
+ nOptions &= ~OPTION_UNINSTALL;
+#endif /* OLD */
+ }
+
+ return 0;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/workben/testresource.cxx b/extensions/workben/testresource.cxx
new file mode 100644
index 000000000000..73852cfc12e0
--- /dev/null
+++ b/extensions/workben/testresource.cxx
@@ -0,0 +1,92 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_extensions.hxx"
+
+#include <smart/com/sun/star/registry/XImplementationRegistration.hxx>
+#include <smart/com/sun/star/script/XInvocation.hxx>
+
+#include <rtl/ustring.hxx>
+#include <osl/diagnose.h>
+#include <usr/services.hxx>
+#include <vcl/svapp.hxx>
+
+using namespace rtl;
+using namespace usr;
+
+class MyApp : public Application
+{
+public:
+ void Main();
+};
+
+MyApp aMyApp;
+
+// -----------------------------------------------------------------------
+
+void MyApp::Main()
+{
+ XMultiServiceFactoryRef xSMgr = createRegistryServiceManager();
+ registerUsrServices( xSMgr );
+ setProcessServiceManager( xSMgr );
+
+ XInterfaceRef x = xSMgr->createInstance( L"com.sun.star.registry.ImplementationRegistration" );
+ XImplementationRegistrationRef xReg( x, USR_QUERY );
+ sal_Char szBuf[1024];
+ ORealDynamicLoader::computeModuleName( "res", szBuf, 1024 );
+ UString aDllName( StringToOUString( szBuf, CHARSET_SYSTEM ) );
+ xReg->registerImplementation( L"com.sun.star.loader.SharedLibrary", aDllName, XSimpleRegistryRef() );
+
+ x = xSMgr->createInstance( L"com.sun.star.resource.VclStringResourceLoader" );
+ XInvocationRef xResLoader( x, USR_QUERY );
+ XIntrospectionAccessRef xIntrospection = xResLoader->getIntrospection();
+ UString aFileName( L"TestResource" );
+ UsrAny aVal;
+ aVal.setString( aFileName );
+ xResLoader->setValue( L"FileName", aVal );
+
+ Sequence< UsrAny > Args( 1 );
+ Sequence< INT16 > OutPos;
+ Sequence< UsrAny > OutArgs;
+ Args.getArray()[0].setINT32( 1000 );
+
+ BOOL b = xResLoader->invoke( L"hasString", Args, OutPos, OutArgs ).getBOOL();
+ OSL_ENSURE( b, "hasString" );
+
+ UString aStr = xResLoader->invoke( L"getString", Args, OutPos, OutArgs ).getString();
+ OSL_ENSURE( aStr == L"Hello", "getString" );
+
+ Args.getArray()[0].setINT32( 1001 );
+ b = xResLoader->invoke( L"hasString", Args, OutPos, OutArgs ).getBOOL();
+ OSL_ENSURE( !b, "!hasString" );
+
+ xReg->revokeImplementation( aDllName, XSimpleRegistryRef() );
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/workben/testresource.src b/extensions/workben/testresource.src
new file mode 100644
index 000000000000..5a9fc3a8a607
--- /dev/null
+++ b/extensions/workben/testresource.src
@@ -0,0 +1,30 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+String 1000
+{
+ Text = "Hello";
+};