summaryrefslogtreecommitdiffstats
path: root/odk/examples/DevelopersGuide
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:06:44 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:06:44 +0000
commited5640d8b587fbcfed7dd7967f3de04b37a76f26 (patch)
tree7a5f7c6c9d02226d7471cb3cc8fbbf631b415303 /odk/examples/DevelopersGuide
parentInitial commit. (diff)
downloadlibreoffice-upstream.tar.xz
libreoffice-upstream.zip
Adding upstream version 4:7.4.7.upstream/4%7.4.7upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--odk/examples/DevelopersGuide/BasicAndDialogs/CreatingDialogs/CreatingDialogs.odtbin0 -> 8654 bytes
-rw-r--r--odk/examples/DevelopersGuide/BasicAndDialogs/CreatingDialogs/Makefile138
-rw-r--r--odk/examples/DevelopersGuide/BasicAndDialogs/CreatingDialogs/SampleDialog.java278
-rw-r--r--odk/examples/DevelopersGuide/BasicAndDialogs/FirstStepsBasic.odtbin0 -> 18560 bytes
-rw-r--r--odk/examples/DevelopersGuide/BasicAndDialogs/ToolkitControls/Makefile125
-rw-r--r--odk/examples/DevelopersGuide/BasicAndDialogs/ToolkitControls/ToolkitControls.odtbin0 -> 7793 bytes
-rw-r--r--odk/examples/DevelopersGuide/BasicAndDialogs/ToolkitControls/ToolkitControls/FileDialog.xba90
-rw-r--r--odk/examples/DevelopersGuide/BasicAndDialogs/ToolkitControls/ToolkitControls/FileDialogDlg.xdl29
-rw-r--r--odk/examples/DevelopersGuide/BasicAndDialogs/ToolkitControls/ToolkitControls/MultiPage.xba303
-rw-r--r--odk/examples/DevelopersGuide/BasicAndDialogs/ToolkitControls/ToolkitControls/MultiPageDlg.xdl92
-rw-r--r--odk/examples/DevelopersGuide/BasicAndDialogs/ToolkitControls/ToolkitControls/ProgressBar.xba93
-rw-r--r--odk/examples/DevelopersGuide/BasicAndDialogs/ToolkitControls/ToolkitControls/ProgressBarDlg.xdl28
-rw-r--r--odk/examples/DevelopersGuide/BasicAndDialogs/ToolkitControls/ToolkitControls/ScrollBar.xba103
-rw-r--r--odk/examples/DevelopersGuide/BasicAndDialogs/ToolkitControls/ToolkitControls/ScrollBarDlg.xdl30
-rw-r--r--odk/examples/DevelopersGuide/BasicAndDialogs/ToolkitControls/ToolkitControls/dialog.xlb8
-rw-r--r--odk/examples/DevelopersGuide/BasicAndDialogs/ToolkitControls/ToolkitControls/script.xlb8
-rw-r--r--odk/examples/DevelopersGuide/Charts/AddInChart.odsbin0 -> 18045 bytes
-rw-r--r--odk/examples/DevelopersGuide/Charts/CalcHelper.java396
-rw-r--r--odk/examples/DevelopersGuide/Charts/ChartHelper.java244
-rw-r--r--odk/examples/DevelopersGuide/Charts/ChartInCalc.java417
-rw-r--r--odk/examples/DevelopersGuide/Charts/ChartInDraw.java294
-rw-r--r--odk/examples/DevelopersGuide/Charts/ChartInWriter.java163
-rw-r--r--odk/examples/DevelopersGuide/Charts/Helper.java141
-rw-r--r--odk/examples/DevelopersGuide/Charts/JavaSampleChartAddIn.components10
-rw-r--r--odk/examples/DevelopersGuide/Charts/JavaSampleChartAddIn.java449
-rw-r--r--odk/examples/DevelopersGuide/Charts/ListenAtCalcRangeInDraw.java193
-rw-r--r--odk/examples/DevelopersGuide/Charts/Makefile199
-rw-r--r--odk/examples/DevelopersGuide/Charts/SelectionChangeListener.java220
-rw-r--r--odk/examples/DevelopersGuide/Charts/bullet.gifbin0 -> 335 bytes
-rw-r--r--odk/examples/DevelopersGuide/Components/Addons/JobsAddon/Addons.xcu83
-rw-r--r--odk/examples/DevelopersGuide/Components/Addons/JobsAddon/AsyncJob.components8
-rw-r--r--odk/examples/DevelopersGuide/Components/Addons/JobsAddon/AsyncJob.java425
-rw-r--r--odk/examples/DevelopersGuide/Components/Addons/JobsAddon/Jobs.xcu44
-rw-r--r--odk/examples/DevelopersGuide/Components/Addons/JobsAddon/Makefile136
-rw-r--r--odk/examples/DevelopersGuide/Components/Addons/ProtocolHandlerAddon_cpp/Addons.xcu207
-rw-r--r--odk/examples/DevelopersGuide/Components/Addons/ProtocolHandlerAddon_cpp/Makefile153
-rw-r--r--odk/examples/DevelopersGuide/Components/Addons/ProtocolHandlerAddon_cpp/ProtocolHandler.xcu27
-rw-r--r--odk/examples/DevelopersGuide/Components/Addons/ProtocolHandlerAddon_cpp/addon.cxx230
-rw-r--r--odk/examples/DevelopersGuide/Components/Addons/ProtocolHandlerAddon_cpp/addon.hxx121
-rw-r--r--odk/examples/DevelopersGuide/Components/Addons/ProtocolHandlerAddon_cpp/component.cxx92
-rw-r--r--odk/examples/DevelopersGuide/Components/Addons/ProtocolHandlerAddon_java/Addons.xcu207
-rw-r--r--odk/examples/DevelopersGuide/Components/Addons/ProtocolHandlerAddon_java/Makefile138
-rw-r--r--odk/examples/DevelopersGuide/Components/Addons/ProtocolHandlerAddon_java/ProtocolHandler.xcu27
-rw-r--r--odk/examples/DevelopersGuide/Components/Addons/ProtocolHandlerAddon_java/ProtocolHandlerAddon.java254
-rw-r--r--odk/examples/DevelopersGuide/Components/Addons/ProtocolHandlerAddon_java/ProtocolHandlerAddon_java.components8
-rw-r--r--odk/examples/DevelopersGuide/Components/CppComponent/Makefile228
-rw-r--r--odk/examples/DevelopersGuide/Components/CppComponent/SimpleComponent.odtbin0 -> 8841 bytes
-rw-r--r--odk/examples/DevelopersGuide/Components/CppComponent/TestCppComponent.cxx93
-rw-r--r--odk/examples/DevelopersGuide/Components/CppComponent/description.xml15
-rw-r--r--odk/examples/DevelopersGuide/Components/CppComponent/service1_impl.cxx211
-rw-r--r--odk/examples/DevelopersGuide/Components/CppComponent/service2_impl.cxx203
-rw-r--r--odk/examples/DevelopersGuide/Components/CppComponent/some.idl57
-rw-r--r--odk/examples/DevelopersGuide/Components/JavaComponent/JavaComponent.components11
-rw-r--r--odk/examples/DevelopersGuide/Components/JavaComponent/Makefile199
-rw-r--r--odk/examples/DevelopersGuide/Components/JavaComponent/TestComponentA.java69
-rw-r--r--odk/examples/DevelopersGuide/Components/JavaComponent/TestComponentB.java92
-rw-r--r--odk/examples/DevelopersGuide/Components/JavaComponent/TestJavaComponent.java144
-rw-r--r--odk/examples/DevelopersGuide/Components/JavaComponent/TestServiceProvider.java61
-rw-r--r--odk/examples/DevelopersGuide/Components/JavaComponent/com/sun/star/test/SomethingA.idl48
-rw-r--r--odk/examples/DevelopersGuide/Components/JavaComponent/com/sun/star/test/SomethingB.idl48
-rw-r--r--odk/examples/DevelopersGuide/Components/JavaComponent/com/sun/star/test/XSomethingA.idl50
-rw-r--r--odk/examples/DevelopersGuide/Components/JavaComponent/com/sun/star/test/XSomethingB.idl50
-rw-r--r--odk/examples/DevelopersGuide/Components/JavaComponent/description.xml15
-rw-r--r--odk/examples/DevelopersGuide/Components/SimpleLicense/LicenseTest.components8
-rw-r--r--odk/examples/DevelopersGuide/Components/SimpleLicense/LicenseTest.idl53
-rw-r--r--odk/examples/DevelopersGuide/Components/SimpleLicense/LicenseTest.java129
-rw-r--r--odk/examples/DevelopersGuide/Components/SimpleLicense/Makefile166
-rw-r--r--odk/examples/DevelopersGuide/Components/SimpleLicense/description.xml34
-rw-r--r--odk/examples/DevelopersGuide/Components/SimpleLicense/registration/license_de.txt1
-rw-r--r--odk/examples/DevelopersGuide/Components/SimpleLicense/registration/license_en_US.txt1
-rw-r--r--odk/examples/DevelopersGuide/Components/Thumbs/Makefile82
-rw-r--r--odk/examples/DevelopersGuide/Components/Thumbs/org/openoffice/comp/test/ImageShrink.components8
-rw-r--r--odk/examples/DevelopersGuide/Components/Thumbs/org/openoffice/comp/test/ImageShrink.java129
-rw-r--r--odk/examples/DevelopersGuide/Components/Thumbs/org/openoffice/comp/test/Makefile128
-rw-r--r--odk/examples/DevelopersGuide/Components/Thumbs/org/openoffice/comp/test/Thumbs.java79
-rw-r--r--odk/examples/DevelopersGuide/Components/Thumbs/org/openoffice/comp/test/description.xml15
-rw-r--r--odk/examples/DevelopersGuide/Components/Thumbs/org/openoffice/test/ImageShrink.idl49
-rw-r--r--odk/examples/DevelopersGuide/Components/Thumbs/org/openoffice/test/Makefile68
-rw-r--r--odk/examples/DevelopersGuide/Components/Thumbs/org/openoffice/test/XImageShrink.idl56
-rw-r--r--odk/examples/DevelopersGuide/Components/Thumbs/org/openoffice/test/XImageShrinkFilter.idl53
-rw-r--r--odk/examples/DevelopersGuide/Components/Thumbs/thumbs.mk45
-rw-r--r--odk/examples/DevelopersGuide/Components/dialogcomponent/DialogComponent.components8
-rw-r--r--odk/examples/DevelopersGuide/Components/dialogcomponent/DialogComponent.java294
-rw-r--r--odk/examples/DevelopersGuide/Components/dialogcomponent/DialogComponent.odtbin0 -> 11902 bytes
-rw-r--r--odk/examples/DevelopersGuide/Components/dialogcomponent/Makefile171
-rw-r--r--odk/examples/DevelopersGuide/Components/dialogcomponent/com/sun/star/test/TestDialogHandler.idl49
-rw-r--r--odk/examples/DevelopersGuide/Components/dialogcomponent/com/sun/star/test/XTestDialogHandler.idl56
-rw-r--r--odk/examples/DevelopersGuide/Components/dialogcomponent/description.xml15
-rw-r--r--odk/examples/DevelopersGuide/Config/ConfigExamples.java1102
-rw-r--r--odk/examples/DevelopersGuide/Config/Makefile98
-rw-r--r--odk/examples/DevelopersGuide/Database/CodeSamples.java322
-rw-r--r--odk/examples/DevelopersGuide/Database/DriverSkeleton/How_to_write_my_own_driver.txt43
-rw-r--r--odk/examples/DevelopersGuide/Database/DriverSkeleton/Makefile156
-rw-r--r--odk/examples/DevelopersGuide/Database/DriverSkeleton/OSubComponent.hxx242
-rw-r--r--odk/examples/DevelopersGuide/Database/DriverSkeleton/OTypeInfo.hxx100
-rw-r--r--odk/examples/DevelopersGuide/Database/DriverSkeleton/SConnection.cxx401
-rw-r--r--odk/examples/DevelopersGuide/Database/DriverSkeleton/SConnection.hxx158
-rw-r--r--odk/examples/DevelopersGuide/Database/DriverSkeleton/SDatabaseMetaData.cxx887
-rw-r--r--odk/examples/DevelopersGuide/Database/DriverSkeleton/SDatabaseMetaData.hxx218
-rw-r--r--odk/examples/DevelopersGuide/Database/DriverSkeleton/SDriver.cxx200
-rw-r--r--odk/examples/DevelopersGuide/Database/DriverSkeleton/SDriver.hxx92
-rw-r--r--odk/examples/DevelopersGuide/Database/DriverSkeleton/SPreparedStatement.cxx385
-rw-r--r--odk/examples/DevelopersGuide/Database/DriverSkeleton/SPreparedStatement.hxx150
-rw-r--r--odk/examples/DevelopersGuide/Database/DriverSkeleton/SResultSet.cxx867
-rw-r--r--odk/examples/DevelopersGuide/Database/DriverSkeleton/SResultSet.hxx220
-rw-r--r--odk/examples/DevelopersGuide/Database/DriverSkeleton/SResultSetMetaData.cxx170
-rw-r--r--odk/examples/DevelopersGuide/Database/DriverSkeleton/SResultSetMetaData.hxx91
-rw-r--r--odk/examples/DevelopersGuide/Database/DriverSkeleton/SServices.cxx153
-rw-r--r--odk/examples/DevelopersGuide/Database/DriverSkeleton/SStatement.cxx376
-rw-r--r--odk/examples/DevelopersGuide/Database/DriverSkeleton/SStatement.hxx175
-rw-r--r--odk/examples/DevelopersGuide/Database/DriverSkeleton/propertyids.cxx184
-rw-r--r--odk/examples/DevelopersGuide/Database/DriverSkeleton/propertyids.hxx145
-rw-r--r--odk/examples/DevelopersGuide/Database/Makefile133
-rw-r--r--odk/examples/DevelopersGuide/Database/OpenQuery.java143
-rw-r--r--odk/examples/DevelopersGuide/Database/RowSet.java225
-rw-r--r--odk/examples/DevelopersGuide/Database/RowSetEventListener.java80
-rw-r--r--odk/examples/DevelopersGuide/Database/Sales.java130
-rw-r--r--odk/examples/DevelopersGuide/Database/SalesMan.java137
-rw-r--r--odk/examples/DevelopersGuide/Database/sdbcx.java420
-rw-r--r--odk/examples/DevelopersGuide/Drawing/ChangeOrderDemo.java113
-rw-r--r--odk/examples/DevelopersGuide/Drawing/ControlAndSelectDemo.java144
-rw-r--r--odk/examples/DevelopersGuide/Drawing/CustomShowDemo.java169
-rw-r--r--odk/examples/DevelopersGuide/Drawing/DrawViewDemo.java142
-rw-r--r--odk/examples/DevelopersGuide/Drawing/DrawingDemo.java419
-rw-r--r--odk/examples/DevelopersGuide/Drawing/FillAndLineStyleDemo.java132
-rw-r--r--odk/examples/DevelopersGuide/Drawing/GluePointDemo.java182
-rw-r--r--odk/examples/DevelopersGuide/Drawing/GraphicExportDemo.java148
-rw-r--r--odk/examples/DevelopersGuide/Drawing/Helper.java89
-rw-r--r--odk/examples/DevelopersGuide/Drawing/LayerDemo.java152
-rw-r--r--odk/examples/DevelopersGuide/Drawing/Makefile174
-rw-r--r--odk/examples/DevelopersGuide/Drawing/ObjectTransformationDemo.java131
-rw-r--r--odk/examples/DevelopersGuide/Drawing/Organigram.java176
-rw-r--r--odk/examples/DevelopersGuide/Drawing/PageHelper.java199
-rw-r--r--odk/examples/DevelopersGuide/Drawing/PresentationDemo.java232
-rw-r--r--odk/examples/DevelopersGuide/Drawing/ShapeHelper.java142
-rw-r--r--odk/examples/DevelopersGuide/Drawing/SimplePresentation.odpbin0 -> 74753 bytes
-rw-r--r--odk/examples/DevelopersGuide/Drawing/StyleDemo.java164
-rw-r--r--odk/examples/DevelopersGuide/Drawing/TextDemo.java153
-rw-r--r--odk/examples/DevelopersGuide/Extensions/DialogWithHelp/Addons.xcu65
-rw-r--r--odk/examples/DevelopersGuide/Extensions/DialogWithHelp/DialogWithHelp/Dialog1.xdl27
-rw-r--r--odk/examples/DevelopersGuide/Extensions/DialogWithHelp/DialogWithHelp/Module1.xba33
-rw-r--r--odk/examples/DevelopersGuide/Extensions/DialogWithHelp/DialogWithHelp/dialog.xlb5
-rw-r--r--odk/examples/DevelopersGuide/Extensions/DialogWithHelp/DialogWithHelp/script.xlb5
-rw-r--r--odk/examples/DevelopersGuide/Extensions/DialogWithHelp/META-INF/manifest.xml23
-rw-r--r--odk/examples/DevelopersGuide/Extensions/DialogWithHelp/Makefile117
-rw-r--r--odk/examples/DevelopersGuide/Extensions/DialogWithHelp/description.xml25
-rw-r--r--odk/examples/DevelopersGuide/Extensions/DialogWithHelp/help/de/com.foocorp.foo-ext/page1.xhp90
-rw-r--r--odk/examples/DevelopersGuide/Extensions/DialogWithHelp/help/de/com.foocorp.foo-ext/page2.xhp44
-rw-r--r--odk/examples/DevelopersGuide/Extensions/DialogWithHelp/help/de/com.foocorp.foo-ext/subfolder/anotherpage.xhp117
-rw-r--r--odk/examples/DevelopersGuide/Extensions/DialogWithHelp/help/en/com.foocorp.foo-ext/page1.xhp90
-rw-r--r--odk/examples/DevelopersGuide/Extensions/DialogWithHelp/help/en/com.foocorp.foo-ext/page2.xhp43
-rw-r--r--odk/examples/DevelopersGuide/Extensions/DialogWithHelp/help/en/com.foocorp.foo-ext/subfolder/anotherpage.xhp117
-rw-r--r--odk/examples/DevelopersGuide/FirstSteps/FirstLoadComponent.java162
-rw-r--r--odk/examples/DevelopersGuide/FirstSteps/FirstUnoContact.java61
-rw-r--r--odk/examples/DevelopersGuide/FirstSteps/FirstUnoContact.py24
-rw-r--r--odk/examples/DevelopersGuide/FirstSteps/HelloTextTableShape.java439
-rw-r--r--odk/examples/DevelopersGuide/FirstSteps/Makefile100
-rw-r--r--odk/examples/DevelopersGuide/FirstSteps/build_FirstUnoContact.xml80
-rw-r--r--odk/examples/DevelopersGuide/FirstSteps/cxx/FirstUnoContact.cxx35
-rw-r--r--odk/examples/DevelopersGuide/FirstSteps/cxx/Makefile100
-rw-r--r--odk/examples/DevelopersGuide/Forms/BooleanValidator.java84
-rw-r--r--odk/examples/DevelopersGuide/Forms/ButtonOperator.java219
-rw-r--r--odk/examples/DevelopersGuide/Forms/ComponentTreeTraversal.java92
-rw-r--r--odk/examples/DevelopersGuide/Forms/ControlLock.java223
-rw-r--r--odk/examples/DevelopersGuide/Forms/ControlValidation.java85
-rw-r--r--odk/examples/DevelopersGuide/Forms/ControlValidator.java52
-rw-r--r--odk/examples/DevelopersGuide/Forms/DataAwareness.java940
-rw-r--r--odk/examples/DevelopersGuide/Forms/DateValidator.java91
-rw-r--r--odk/examples/DevelopersGuide/Forms/DocumentBasedExample.java219
-rw-r--r--odk/examples/DevelopersGuide/Forms/DocumentHelper.java306
-rw-r--r--odk/examples/DevelopersGuide/Forms/DocumentType.java40
-rw-r--r--odk/examples/DevelopersGuide/Forms/DocumentViewHelper.java215
-rw-r--r--odk/examples/DevelopersGuide/Forms/FLTools.java216
-rw-r--r--odk/examples/DevelopersGuide/Forms/FormLayer.java272
-rw-r--r--odk/examples/DevelopersGuide/Forms/GridFieldValidator.java174
-rw-r--r--odk/examples/DevelopersGuide/Forms/HsqlDatabase.java184
-rw-r--r--odk/examples/DevelopersGuide/Forms/InteractionRequest.java71
-rw-r--r--odk/examples/DevelopersGuide/Forms/KeyGenerator.java434
-rw-r--r--odk/examples/DevelopersGuide/Forms/ListSelectionValidator.java59
-rw-r--r--odk/examples/DevelopersGuide/Forms/Makefile196
-rw-r--r--odk/examples/DevelopersGuide/Forms/NumericValidator.java77
-rw-r--r--odk/examples/DevelopersGuide/Forms/ProgrammaticScriptAssignment.odtbin0 -> 19198 bytes
-rw-r--r--odk/examples/DevelopersGuide/Forms/RowSet.java283
-rw-r--r--odk/examples/DevelopersGuide/Forms/SalesFilter.java510
-rw-r--r--odk/examples/DevelopersGuide/Forms/SingleControlValidation.java171
-rw-r--r--odk/examples/DevelopersGuide/Forms/SpreadsheetDocument.java120
-rw-r--r--odk/examples/DevelopersGuide/Forms/SpreadsheetValueBinding.java125
-rw-r--r--odk/examples/DevelopersGuide/Forms/SpreadsheetView.java35
-rw-r--r--odk/examples/DevelopersGuide/Forms/TableCellTextBinding.java199
-rw-r--r--odk/examples/DevelopersGuide/Forms/TextValidator.java78
-rw-r--r--odk/examples/DevelopersGuide/Forms/TimeValidator.java83
-rw-r--r--odk/examples/DevelopersGuide/Forms/UNO.java89
-rw-r--r--odk/examples/DevelopersGuide/Forms/URLHelper.java65
-rw-r--r--odk/examples/DevelopersGuide/Forms/ValueBinding.java82
-rw-r--r--odk/examples/DevelopersGuide/Forms/WaitForInput.java58
-rw-r--r--odk/examples/DevelopersGuide/GUI/DialogDocument.java146
-rw-r--r--odk/examples/DevelopersGuide/GUI/ImageControlSample.java166
-rw-r--r--odk/examples/DevelopersGuide/GUI/Makefile141
-rw-r--r--odk/examples/DevelopersGuide/GUI/MessageBox.java237
-rw-r--r--odk/examples/DevelopersGuide/GUI/RoadmapItemStateChangeListener.java69
-rw-r--r--odk/examples/DevelopersGuide/GUI/SystemDialog.java188
-rw-r--r--odk/examples/DevelopersGuide/GUI/UnoDialogSample.java1373
-rw-r--r--odk/examples/DevelopersGuide/GUI/UnoDialogSample2.java263
-rw-r--r--odk/examples/DevelopersGuide/GUI/UnoMenu.java186
-rw-r--r--odk/examples/DevelopersGuide/GUI/UnoMenu2.java120
-rw-r--r--odk/examples/DevelopersGuide/GUI/oologo.gifbin0 -> 2563 bytes
-rw-r--r--odk/examples/DevelopersGuide/OfficeBean/Makefile90
-rw-r--r--odk/examples/DevelopersGuide/OfficeBean/OOoBeanViewer.java410
-rw-r--r--odk/examples/DevelopersGuide/OfficeBean/OfficeIconColor16.jpgbin0 -> 321 bytes
-rw-r--r--odk/examples/DevelopersGuide/OfficeBean/OfficeIconColor32.jpgbin0 -> 569 bytes
-rw-r--r--odk/examples/DevelopersGuide/OfficeBean/OfficeIconMono16.jpgbin0 -> 321 bytes
-rw-r--r--odk/examples/DevelopersGuide/OfficeBean/OfficeIconMono32.jpgbin0 -> 569 bytes
-rw-r--r--odk/examples/DevelopersGuide/OfficeDev/Clipboard/Clipboard.java212
-rw-r--r--odk/examples/DevelopersGuide/OfficeDev/Clipboard/ClipboardListener.java58
-rw-r--r--odk/examples/DevelopersGuide/OfficeDev/Clipboard/ClipboardOwner.java63
-rw-r--r--odk/examples/DevelopersGuide/OfficeDev/Clipboard/Makefile98
-rw-r--r--odk/examples/DevelopersGuide/OfficeDev/Clipboard/TextTransferable.java88
-rw-r--r--odk/examples/DevelopersGuide/OfficeDev/ContextMenuInterceptor.java253
-rw-r--r--odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/CustomizeView.java285
-rw-r--r--odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/Desk.java93
-rw-r--r--odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/DocumentView.java428
-rw-r--r--odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/FunctionHelper.java939
-rw-r--r--odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/IOnewayLink.java71
-rw-r--r--odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/IShutdownListener.java48
-rw-r--r--odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/Install.txt10
-rw-r--r--odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/Interceptor.java655
-rw-r--r--odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/JavaWindowPeerFake.java109
-rw-r--r--odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/Makefile131
-rw-r--r--odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/NativeView.java186
-rw-r--r--odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/OfficeConnect.java127
-rw-r--r--odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/OnewayExecutor.java189
-rw-r--r--odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/StatusListener.java469
-rw-r--r--odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/StatusView.java264
-rw-r--r--odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/ViewContainer.java260
-rw-r--r--odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/nativelib/unix/Makefile72
-rw-r--r--odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/nativelib/unix/nativeview.c112
-rw-r--r--odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/nativelib/unix/nativeview.h64
-rw-r--r--odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/nativelib/windows/Makefile77
-rw-r--r--odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/nativelib/windows/nativeview.c181
-rw-r--r--odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/nativelib/windows/nativeview.def3
-rw-r--r--odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/nativelib/windows/nativeview.h64
-rw-r--r--odk/examples/DevelopersGuide/OfficeDev/DisableCommands/DisableCommandsTest.java397
-rw-r--r--odk/examples/DevelopersGuide/OfficeDev/DisableCommands/Makefile91
-rw-r--r--odk/examples/DevelopersGuide/OfficeDev/FilterDevelopment/AsciiFilter/AsciiReplaceFilter.java702
-rw-r--r--odk/examples/DevelopersGuide/OfficeDev/FilterDevelopment/AsciiFilter/FilterOptions.java225
-rw-r--r--odk/examples/DevelopersGuide/OfficeDev/FilterDevelopment/AsciiFilter/Makefile139
-rw-r--r--odk/examples/DevelopersGuide/OfficeDev/FilterDevelopment/AsciiFilter/SampleFilter.components10
-rw-r--r--odk/examples/DevelopersGuide/OfficeDev/FilterDevelopment/AsciiFilter/TypeDetection.xcu46
-rw-r--r--odk/examples/DevelopersGuide/OfficeDev/FilterDevelopment/FlatXmlFilterDetection/FlatXmlTypeDetection.xcu88
-rw-r--r--odk/examples/DevelopersGuide/OfficeDev/FilterDevelopment/FlatXmlFilterDetection/Makefile155
-rw-r--r--odk/examples/DevelopersGuide/OfficeDev/FilterDevelopment/FlatXmlFilterDetection/fdcomp.cxx84
-rw-r--r--odk/examples/DevelopersGuide/OfficeDev/FilterDevelopment/FlatXmlFilterDetection/filterdetect.cxx239
-rw-r--r--odk/examples/DevelopersGuide/OfficeDev/FilterDevelopment/FlatXmlFilterDetection/filterdetect.hxx111
-rw-r--r--odk/examples/DevelopersGuide/OfficeDev/FilterDevelopment/FlatXmlFilter_cpp/FlatXml.cxx331
-rw-r--r--odk/examples/DevelopersGuide/OfficeDev/FilterDevelopment/FlatXmlFilter_cpp/FlatXmlFilter_cpp.xcu103
-rw-r--r--odk/examples/DevelopersGuide/OfficeDev/FilterDevelopment/FlatXmlFilter_cpp/Makefile153
-rw-r--r--odk/examples/DevelopersGuide/OfficeDev/FilterDevelopment/FlatXmlFilter_java/FlatXml.java267
-rw-r--r--odk/examples/DevelopersGuide/OfficeDev/FilterDevelopment/FlatXmlFilter_java/FlatXmlFilter_java.components8
-rw-r--r--odk/examples/DevelopersGuide/OfficeDev/FilterDevelopment/FlatXmlFilter_java/FlatXmlFilter_java.xcu103
-rw-r--r--odk/examples/DevelopersGuide/OfficeDev/FilterDevelopment/FlatXmlFilter_java/Makefile142
-rw-r--r--odk/examples/DevelopersGuide/OfficeDev/Linguistic/LinguisticExamples.java360
-rw-r--r--odk/examples/DevelopersGuide/OfficeDev/Linguistic/Makefile231
-rw-r--r--odk/examples/DevelopersGuide/OfficeDev/Linguistic/OneInstanceFactory.java155
-rw-r--r--odk/examples/DevelopersGuide/OfficeDev/Linguistic/PropChgHelper.java193
-rw-r--r--odk/examples/DevelopersGuide/OfficeDev/Linguistic/PropChgHelper_Hyph.java81
-rw-r--r--odk/examples/DevelopersGuide/OfficeDev/Linguistic/PropChgHelper_Spell.java105
-rw-r--r--odk/examples/DevelopersGuide/OfficeDev/Linguistic/SampleHyphenator.components8
-rw-r--r--odk/examples/DevelopersGuide/OfficeDev/Linguistic/SampleHyphenator.java514
-rw-r--r--odk/examples/DevelopersGuide/OfficeDev/Linguistic/SampleSpellChecker.components8
-rw-r--r--odk/examples/DevelopersGuide/OfficeDev/Linguistic/SampleSpellChecker.java457
-rw-r--r--odk/examples/DevelopersGuide/OfficeDev/Linguistic/SampleThesaurus.components8
-rw-r--r--odk/examples/DevelopersGuide/OfficeDev/Linguistic/SampleThesaurus.java293
-rw-r--r--odk/examples/DevelopersGuide/OfficeDev/Linguistic/XHyphenatedWord_impl.java100
-rw-r--r--odk/examples/DevelopersGuide/OfficeDev/Linguistic/XMeaning_impl.java71
-rw-r--r--odk/examples/DevelopersGuide/OfficeDev/Linguistic/XPossibleHyphens_impl.java92
-rw-r--r--odk/examples/DevelopersGuide/OfficeDev/Linguistic/XSpellAlternatives_impl.java94
-rw-r--r--odk/examples/DevelopersGuide/OfficeDev/Makefile105
-rw-r--r--odk/examples/DevelopersGuide/OfficeDev/MenuElement.java58
-rw-r--r--odk/examples/DevelopersGuide/OfficeDev/Number_Formats.java245
-rw-r--r--odk/examples/DevelopersGuide/OfficeDev/OfficeConnect.java140
-rw-r--r--odk/examples/DevelopersGuide/OfficeDev/PathSettings/Makefile91
-rw-r--r--odk/examples/DevelopersGuide/OfficeDev/PathSettings/PathSettingsTest.java164
-rw-r--r--odk/examples/DevelopersGuide/OfficeDev/PathSubstitution/Makefile91
-rw-r--r--odk/examples/DevelopersGuide/OfficeDev/PathSubstitution/PathSubstitutionTest.java116
-rw-r--r--odk/examples/DevelopersGuide/OfficeDev/TerminationTest/Makefile96
-rw-r--r--odk/examples/DevelopersGuide/OfficeDev/TerminationTest/TerminateListener.java59
-rw-r--r--odk/examples/DevelopersGuide/OfficeDev/TerminationTest/TerminationTest.java100
-rw-r--r--odk/examples/DevelopersGuide/ProfUNO/CppBinding/Makefile117
-rw-r--r--odk/examples/DevelopersGuide/ProfUNO/CppBinding/office_connect.cxx110
-rw-r--r--odk/examples/DevelopersGuide/ProfUNO/CppBinding/string_samples.cxx85
-rw-r--r--odk/examples/DevelopersGuide/ProfUNO/InterprocessConn/ConnectionAwareClient.java255
-rw-r--r--odk/examples/DevelopersGuide/ProfUNO/InterprocessConn/Makefile85
-rw-r--r--odk/examples/DevelopersGuide/ProfUNO/InterprocessConn/UrlResolver.java112
-rw-r--r--odk/examples/DevelopersGuide/ProfUNO/Lifetime/Makefile112
-rw-r--r--odk/examples/DevelopersGuide/ProfUNO/Lifetime/MyUnoObject.java63
-rw-r--r--odk/examples/DevelopersGuide/ProfUNO/Lifetime/object_lifetime.cxx69
-rw-r--r--odk/examples/DevelopersGuide/ProfUNO/SimpleBootstrap_cpp/Makefile100
-rw-r--r--odk/examples/DevelopersGuide/ProfUNO/SimpleBootstrap_cpp/SimpleBootstrap_cpp.cxx104
-rw-r--r--odk/examples/DevelopersGuide/ProfUNO/SimpleBootstrap_java/Makefile90
-rw-r--r--odk/examples/DevelopersGuide/ProfUNO/SimpleBootstrap_java/SimpleBootstrap_java.java77
-rw-r--r--odk/examples/DevelopersGuide/ProfUNO/SimpleBootstrap_java/manifest.mf4
-rw-r--r--odk/examples/DevelopersGuide/ScriptingFramework/SayHello/META-INF/manifest.xml5
-rw-r--r--odk/examples/DevelopersGuide/ScriptingFramework/SayHello/Makefile128
-rw-r--r--odk/examples/DevelopersGuide/ScriptingFramework/SayHello/SayHello.odtbin0 -> 8874 bytes
-rw-r--r--odk/examples/DevelopersGuide/ScriptingFramework/SayHello/SayHello/SayHello.java65
-rw-r--r--odk/examples/DevelopersGuide/ScriptingFramework/SayHello/SayHello/parcel-descriptor.xml33
-rw-r--r--odk/examples/DevelopersGuide/ScriptingFramework/SayHello/build.xml96
-rw-r--r--odk/examples/DevelopersGuide/ScriptingFramework/ScriptSelector/META-INF/manifest.xml5
-rw-r--r--odk/examples/DevelopersGuide/ScriptingFramework/ScriptSelector/Makefile130
-rw-r--r--odk/examples/DevelopersGuide/ScriptingFramework/ScriptSelector/ScriptSelector.odtbin0 -> 8921 bytes
-rw-r--r--odk/examples/DevelopersGuide/ScriptingFramework/ScriptSelector/ScriptSelector/ScriptSelector.java353
-rw-r--r--odk/examples/DevelopersGuide/ScriptingFramework/ScriptSelector/ScriptSelector/container.gifbin0 -> 164 bytes
-rw-r--r--odk/examples/DevelopersGuide/ScriptingFramework/ScriptSelector/ScriptSelector/parcel-descriptor.xml33
-rw-r--r--odk/examples/DevelopersGuide/ScriptingFramework/ScriptSelector/ScriptSelector/script.gifbin0 -> 187 bytes
-rw-r--r--odk/examples/DevelopersGuide/ScriptingFramework/ScriptSelector/ScriptSelector/soffice.gifbin0 -> 136 bytes
-rw-r--r--odk/examples/DevelopersGuide/ScriptingFramework/ScriptSelector/build.xml96
-rw-r--r--odk/examples/DevelopersGuide/Spreadsheet/DataPilotReadme.txt48
-rw-r--r--odk/examples/DevelopersGuide/Spreadsheet/ExampleAddIn.components9
-rw-r--r--odk/examples/DevelopersGuide/Spreadsheet/ExampleAddIn.java304
-rw-r--r--odk/examples/DevelopersGuide/Spreadsheet/ExampleAddIn.odsbin0 -> 8961 bytes
-rw-r--r--odk/examples/DevelopersGuide/Spreadsheet/ExampleDataPilotSource.components8
-rw-r--r--odk/examples/DevelopersGuide/Spreadsheet/ExampleDataPilotSource.java990
-rw-r--r--odk/examples/DevelopersGuide/Spreadsheet/GeneralTableSample.java231
-rw-r--r--odk/examples/DevelopersGuide/Spreadsheet/Makefile304
-rw-r--r--odk/examples/DevelopersGuide/Spreadsheet/SpreadsheetDocHelper.java388
-rw-r--r--odk/examples/DevelopersGuide/Spreadsheet/SpreadsheetSample.java1347
-rw-r--r--odk/examples/DevelopersGuide/Spreadsheet/ViewSample.java164
-rw-r--r--odk/examples/DevelopersGuide/Spreadsheet/XExampleAddIn.idl62
-rw-r--r--odk/examples/DevelopersGuide/Spreadsheet/description.xml15
-rw-r--r--odk/examples/DevelopersGuide/Text/Makefile95
-rw-r--r--odk/examples/DevelopersGuide/Text/PrintDemo.odtbin0 -> 6909 bytes
-rw-r--r--odk/examples/DevelopersGuide/Text/TextDocuments.java1724
-rw-r--r--odk/examples/DevelopersGuide/Text/TextTemplateWithUserFields.odtbin0 -> 6641 bytes
-rw-r--r--odk/examples/DevelopersGuide/UCB/ChildrenRetriever.java338
-rw-r--r--odk/examples/DevelopersGuide/UCB/DataStreamComposer.java246
-rw-r--r--odk/examples/DevelopersGuide/UCB/DataStreamRetriever.java227
-rw-r--r--odk/examples/DevelopersGuide/UCB/Helper.java242
-rw-r--r--odk/examples/DevelopersGuide/UCB/Makefile155
-rw-r--r--odk/examples/DevelopersGuide/UCB/MyActiveDataSink.java74
-rw-r--r--odk/examples/DevelopersGuide/UCB/MyInputStream.java180
-rw-r--r--odk/examples/DevelopersGuide/UCB/PropertiesComposer.java289
-rw-r--r--odk/examples/DevelopersGuide/UCB/PropertiesRetriever.java245
-rw-r--r--odk/examples/DevelopersGuide/UCB/ResourceCreator.java304
-rw-r--r--odk/examples/DevelopersGuide/UCB/ResourceManager.java280
-rw-r--r--odk/examples/DevelopersGuide/UCB/ResourceRemover.java175
-rw-r--r--odk/examples/DevelopersGuide/UCB/data/data.txt1
-rw-r--r--odk/examples/DevelopersGuide/examples.html2879
347 files changed, 58793 insertions, 0 deletions
diff --git a/odk/examples/DevelopersGuide/BasicAndDialogs/CreatingDialogs/CreatingDialogs.odt b/odk/examples/DevelopersGuide/BasicAndDialogs/CreatingDialogs/CreatingDialogs.odt
new file mode 100644
index 000000000..dd55f9076
--- /dev/null
+++ b/odk/examples/DevelopersGuide/BasicAndDialogs/CreatingDialogs/CreatingDialogs.odt
Binary files differ
diff --git a/odk/examples/DevelopersGuide/BasicAndDialogs/CreatingDialogs/Makefile b/odk/examples/DevelopersGuide/BasicAndDialogs/CreatingDialogs/Makefile
new file mode 100644
index 000000000..3af249f9d
--- /dev/null
+++ b/odk/examples/DevelopersGuide/BasicAndDialogs/CreatingDialogs/Makefile
@@ -0,0 +1,138 @@
+#*************************************************************************
+#
+# The Contents of this file are made available subject to the terms of
+# the BSD license.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+# 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+# contributors may be used to endorse or promote products derived
+# from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+# TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+# USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+#**************************************************************************
+
+# Builds the CreatingDialogs example of the Developers Guide.
+
+PRJ=../../../..
+SETTINGS=$(PRJ)/settings
+
+include $(SETTINGS)/settings.mk
+include $(SETTINGS)/std.mk
+
+# Define non-platform/compiler specific settings
+EXAMPLE_NAME=BaDCreatingDialogsExample
+OUT_COMP_CLASS = $(OUT_CLASS)/$(EXAMPLE_NAME)
+
+COMPONENT_NAME=SampleDialog
+COMPONENT_PACKAGE = $(OUT_BIN)/$(COMPONENT_NAME).$(UNOOXT_EXT)
+COMPONENT_PACKAGE_URL = $(subst \\,\,"$(COMP_PACKAGE_DIR)$(PS)$(COMPONENT_NAME).$(UNOOXT_EXT)")
+COMPONENT_JAR_NAME = $(COMPONENT_NAME).uno.jar
+COMPONENT_JAR = $(OUT_CLASS)/$(COMPONENT_JAR_NAME)
+COMPONENT_MANIFESTFILE = $(OUT_COMP_CLASS)/$(COMPONENT_NAME).uno.Manifest
+COMPONENT_UNOPKG_MANIFEST = $(OUT_COMP_CLASS)/$(COMPONENT_NAME)/META-INF/manifest.xml
+REGISTERFLAG = $(OUT_MISC)/devguide_basicanddialogs_creatingdialogs_register_component.flag
+
+# often the java files are structured in a hierarchy similar to the package,
+# for the example we know the package
+PACKAGE = com.sun.star.comp.sdk.examples
+
+JAVAFILES = \
+ SampleDialog.java
+
+CLASSFILES = $(patsubst %.java,$(OUT_COMP_CLASS)/%.class,$(JAVAFILES))
+
+$(COMPONENT_NAME)_CLASSFILES = SampleDialog.class \
+
+SDK_CLASSPATH = $(subst $(EMPTYSTRING) $(PATH_SEPARATOR),$(PATH_SEPARATOR),$(CLASSPATH)\
+ $(PATH_SEPARATOR)$(OUT_COMP_CLASS))
+
+
+# Targets
+.PHONY: ALL
+ALL: $(EXAMPLE_NAME)
+
+include $(SETTINGS)/stdtarget.mk
+
+$(OUT_COMP_CLASS)/%.Manifest :
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ @echo RegistrationClassName: $(PACKAGE).$(basename $(basename $(@F)))> $@
+
+$(OUT_COMP_CLASS)/%.class : %.java
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ $(SDK_JAVAC) $(JAVAC_FLAGS) -classpath "$(SDK_CLASSPATH)" -d $(OUT_COMP_CLASS) $<
+
+# rule for component jar file
+$(COMPONENT_JAR) : $(COMPONENT_MANIFESTFILE) $(CLASSFILES)
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ $(SDK_JAR) cvfm $@ $< -C $(OUT_COMP_CLASS) .
+
+# rule for component package manifest
+$(OUT_COMP_CLASS)/%/manifest.xml :
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ @echo $(OSEP)?xml version="$(QM)1.0$(QM)" encoding="$(QM)UTF-8$(QM)"?$(CSEP) > $@
+ @echo $(OSEP)!DOCTYPE manifest:manifest PUBLIC "$(QM)-//OpenOffice.org//DTD Manifest 1.0//EN$(QM)" "$(QM)Manifest.dtd$(QM)"$(CSEP) >> $@
+ @echo $(OSEP)manifest:manifest xmlns:manifest="$(QM)http://openoffice.org/2001/manifest$(QM)"$(CSEP) >> $@
+ @echo $(SQM) $(SQM)$(OSEP)manifest:file-entry manifest:media-type="$(QM)application/vnd.sun.star.uno-component;type=Java$(QM)" >> $@
+ @echo $(SQM) $(SQM)manifest:full-path="$(QM)$(subst /META-INF,,$(subst $(OUT_COMP_CLASS)/,,$(@D))).uno.jar$(QM)"/$(CSEP) >> $@
+ @echo $(OSEP)/manifest:manifest$(CSEP) >> $@
+
+# rule for component package file
+$(COMPONENT_PACKAGE) : $(COMPONENT_JAR) $(COMPONENT_UNOPKG_MANIFEST)
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ cd $(subst /,$(PS),$(OUT_CLASS)) && $(SDK_ZIP) ../bin/$(@F) $(<F)
+ cd $(subst /,$(PS),$(OUT_COMP_CLASS)/$(subst .$(UNOOXT_EXT),,$(@F))) && $(SDK_ZIP) -u ../../../bin/$(@F) META-INF/manifest.xml
+
+$(REGISTERFLAG) : $(COMPONENT_PACKAGE)
+ifeq "$(SDK_AUTO_DEPLOYMENT)" "YES"
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ $(DEPLOYTOOL) $(COMPONENT_PACKAGE_URL)
+ @echo flagged > $(subst /,$(PS),$@)
+else
+ @echo --------------------------------------------------------------------------------
+ @echo If you want to install your component automatically, please set the environment
+ @echo variable SDK_AUTO_DEPLOYMENT = YES. But note that auto deployment is only
+ @echo possible if no office instance is running.
+ @echo --------------------------------------------------------------------------------
+endif
+
+$(EXAMPLE_NAME) : $(REGISTERFLAG)
+ @echo --------------------------------------------------------------------------------
+ @echo The SampleDialog Java component was installed if SDK_AUTO_DEPLOYMENT = YES.
+ @echo Please load the "$(QM)CreatingDialogs.odt$(QM)" document to use the component or use it
+ @echo by yourself in your office installation, see the example description.
+ @echo -
+ @echo $(MAKE) CreatingDialogs.odt.load
+ @echo --------------------------------------------------------------------------------
+
+CreatingDialogs.odt.load : $(REGISTERFLAG)
+ "$(OFFICE_PROGRAM_PATH)$(PS)soffice" $(basename $@)
+
+.PHONY: clean
+clean :
+ -$(DELRECURSIVE) $(subst /,$(PS),$(OUT_COMP_CLASS))
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$(COMPONENT_PACKAGE_URL)))
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$(REGISTERFLAG)))
diff --git a/odk/examples/DevelopersGuide/BasicAndDialogs/CreatingDialogs/SampleDialog.java b/odk/examples/DevelopersGuide/BasicAndDialogs/CreatingDialogs/SampleDialog.java
new file mode 100644
index 000000000..d5a976c59
--- /dev/null
+++ b/odk/examples/DevelopersGuide/BasicAndDialogs/CreatingDialogs/SampleDialog.java
@@ -0,0 +1,278 @@
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+package com.sun.star.comp.sdk.examples;
+
+import com.sun.star.awt.ActionEvent;
+import com.sun.star.awt.XActionListener;
+import com.sun.star.awt.XButton;
+import com.sun.star.lang.XComponent;
+import com.sun.star.awt.XControl;
+import com.sun.star.awt.XControlModel;
+import com.sun.star.awt.XControlContainer;
+import com.sun.star.awt.XDialog;
+import com.sun.star.awt.XFixedText;
+import com.sun.star.awt.XToolkit;
+import com.sun.star.awt.XWindow;
+import com.sun.star.beans.XPropertySet;
+import com.sun.star.comp.loader.FactoryHelper;
+import com.sun.star.container.XNameContainer;
+import com.sun.star.lang.EventObject;
+import com.sun.star.lang.XMultiComponentFactory;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.lang.XSingleServiceFactory;
+import com.sun.star.lang.XTypeProvider;
+import com.sun.star.lang.XServiceInfo;
+import com.sun.star.lib.uno.helper.WeakBase;
+import com.sun.star.registry.XRegistryKey;
+import com.sun.star.task.XJobExecutor;
+import com.sun.star.uno.Type;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.XComponentContext;
+
+
+/** example of a Java component which creates a dialog at runtime
+
+ This component can be tested by the following StarOffice Basic code:
+ Sub Main
+ Dim oJobExecutor
+ oJobExecutor = CreateUnoService( "com.sun.star.examples.SampleDialog" )
+ oJobExecutor.trigger( "execute" )
+ End Sub
+*/
+
+public class SampleDialog extends WeakBase implements XServiceInfo, XJobExecutor {
+
+ static final String __serviceName = "com.sun.star.examples.SampleDialog";
+
+ private static final String _buttonName = "Button1";
+ private static final String _cancelButtonName = "CancelButton";
+ private static final String _labelName = "Label1";
+ private static final String _labelPrefix = "Number of button clicks: ";
+
+ private XComponentContext _xComponentContext;
+
+ public SampleDialog( XComponentContext xComponentContext ) {
+ _xComponentContext = xComponentContext;
+ }
+
+ // static component operations
+ public static XSingleServiceFactory __getServiceFactory( String implName,
+ XMultiServiceFactory multiFactory,
+ XRegistryKey regKey ) {
+ XSingleServiceFactory xSingleServiceFactory = null;
+ if ( implName.equals( SampleDialog.class.getName() ) ) {
+ xSingleServiceFactory = FactoryHelper.getServiceFactory(
+ SampleDialog.class, SampleDialog.__serviceName, multiFactory, regKey );
+ }
+ return xSingleServiceFactory;
+ }
+
+ public static boolean __writeRegistryServiceInfo( XRegistryKey regKey ) {
+ return FactoryHelper.writeRegistryServiceInfo(
+ SampleDialog.class.getName(), SampleDialog.__serviceName, regKey );
+ }
+
+ // XServiceInfo
+ public String getImplementationName( ) {
+ return getClass().getName();
+ }
+
+ // XServiceInfo
+ public boolean supportsService( /*IN*/String serviceName ) {
+ if ( serviceName.equals( __serviceName))
+ return true;
+ return false;
+ }
+
+ // XServiceInfo
+ public String[] getSupportedServiceNames( ) {
+ String[] retValue= new String[0];
+ retValue[0] = __serviceName;
+ return retValue;
+ }
+
+ // XJobExecutor
+ public void trigger(String sEvent) {
+ if ( sEvent.equals( "execute" ) ) {
+ try {
+ createDialog();
+ }
+ catch ( Exception e ) {
+ throw new com.sun.star.lang.WrappedTargetRuntimeException( e, e.getMessage(), this, e );
+ }
+ }
+ }
+
+ /** method for creating a dialog at runtime
+ */
+ private void createDialog() throws com.sun.star.uno.Exception {
+
+ // get the service manager from the component context
+ XMultiComponentFactory xMultiComponentFactory = _xComponentContext.getServiceManager();
+
+ // create the dialog model and set the properties
+ Object dialogModel = xMultiComponentFactory.createInstanceWithContext(
+ "com.sun.star.awt.UnoControlDialogModel", _xComponentContext );
+ XPropertySet xPSetDialog = ( XPropertySet )UnoRuntime.queryInterface(
+ XPropertySet.class, dialogModel );
+ xPSetDialog.setPropertyValue( "PositionX", Integer.valueOf( 100 ) );
+ xPSetDialog.setPropertyValue( "PositionY", Integer.valueOf( 100 ) );
+ xPSetDialog.setPropertyValue( "Width", Integer.valueOf( 150 ) );
+ xPSetDialog.setPropertyValue( "Height", Integer.valueOf( 100 ) );
+ xPSetDialog.setPropertyValue( "Title", "Runtime Dialog Demo" );
+
+ // get the service manager from the dialog model
+ XMultiServiceFactory xMultiServiceFactory = ( XMultiServiceFactory )UnoRuntime.queryInterface(
+ XMultiServiceFactory.class, dialogModel );
+
+ // create the button model and set the properties
+ Object buttonModel = xMultiServiceFactory.createInstance(
+ "com.sun.star.awt.UnoControlButtonModel" );
+ XPropertySet xPSetButton = ( XPropertySet )UnoRuntime.queryInterface(
+ XPropertySet.class, buttonModel );
+ xPSetButton.setPropertyValue( "PositionX", Integer.valueOf( 20 ) );
+ xPSetButton.setPropertyValue( "PositionY", Integer.valueOf( 70 ) );
+ xPSetButton.setPropertyValue( "Width", Integer.valueOf( 50 ) );
+ xPSetButton.setPropertyValue( "Height", Integer.valueOf( 14 ) );
+ xPSetButton.setPropertyValue( "Name", _buttonName );
+ xPSetButton.setPropertyValue( "TabIndex", Short.valueOf( (short)0 ) );
+ xPSetButton.setPropertyValue( "Label", "Click Me" );
+
+ // create the label model and set the properties
+ Object labelModel = xMultiServiceFactory.createInstance(
+ "com.sun.star.awt.UnoControlFixedTextModel" );
+ XPropertySet xPSetLabel = ( XPropertySet )UnoRuntime.queryInterface(
+ XPropertySet.class, labelModel );
+ xPSetLabel.setPropertyValue( "PositionX", Integer.valueOf( 40 ) );
+ xPSetLabel.setPropertyValue( "PositionY", Integer.valueOf( 30 ) );
+ xPSetLabel.setPropertyValue( "Width", Integer.valueOf( 100 ) );
+ xPSetLabel.setPropertyValue( "Height", Integer.valueOf( 14 ) );
+ xPSetLabel.setPropertyValue( "Name", _labelName );
+ xPSetLabel.setPropertyValue( "TabIndex", Short.valueOf( (short)1 ) );
+ xPSetLabel.setPropertyValue( "Label", _labelPrefix );
+
+ // create a Cancel button model and set the properties
+ Object cancelButtonModel = xMultiServiceFactory.createInstance(
+ "com.sun.star.awt.UnoControlButtonModel" );
+ XPropertySet xPSetCancelButton = ( XPropertySet )UnoRuntime.queryInterface(
+ XPropertySet.class, cancelButtonModel );
+ xPSetCancelButton.setPropertyValue( "PositionX", Integer.valueOf( 80 ) );
+ xPSetCancelButton.setPropertyValue( "PositionY", Integer.valueOf( 70 ) );
+ xPSetCancelButton.setPropertyValue( "Width", Integer.valueOf( 50 ) );
+ xPSetCancelButton.setPropertyValue( "Height", Integer.valueOf( 14 ) );
+ xPSetCancelButton.setPropertyValue( "Name", _cancelButtonName );
+ xPSetCancelButton.setPropertyValue( "TabIndex", Short.valueOf( (short)2 ) );
+ xPSetCancelButton.setPropertyValue( "PushButtonType", Short.valueOf( (short)2 ) );
+ xPSetCancelButton.setPropertyValue( "Label", "Cancel" );
+
+ // insert the control models into the dialog model
+ XNameContainer xNameCont = ( XNameContainer )UnoRuntime.queryInterface(
+ XNameContainer.class, dialogModel );
+ xNameCont.insertByName( _buttonName, buttonModel );
+ xNameCont.insertByName( _labelName, labelModel );
+ xNameCont.insertByName( _cancelButtonName, cancelButtonModel );
+
+ // create the dialog control and set the model
+ Object dialog = xMultiComponentFactory.createInstanceWithContext(
+ "com.sun.star.awt.UnoControlDialog", _xComponentContext );
+ XControl xControl = ( XControl )UnoRuntime.queryInterface(
+ XControl.class, dialog );
+ XControlModel xControlModel = ( XControlModel )UnoRuntime.queryInterface(
+ XControlModel.class, dialogModel );
+ xControl.setModel( xControlModel );
+
+ // add an action listener to the button control
+ XControlContainer xControlCont = ( XControlContainer )UnoRuntime.queryInterface(
+ XControlContainer.class, dialog );
+ Object objectButton = xControlCont.getControl( "Button1" );
+ XButton xButton = ( XButton )UnoRuntime.queryInterface(
+ XButton.class, objectButton );
+ xButton.addActionListener( new ActionListenerImpl( xControlCont ) );
+
+ // create a peer
+ Object toolkit = xMultiComponentFactory.createInstanceWithContext(
+ "com.sun.star.awt.ExtToolkit", _xComponentContext );
+ XToolkit xToolkit = ( XToolkit )UnoRuntime.queryInterface(
+ XToolkit.class, toolkit );
+ XWindow xWindow = ( XWindow )UnoRuntime.queryInterface(
+ XWindow.class, xControl );
+ xWindow.setVisible( false );
+ xControl.createPeer( xToolkit, null );
+
+ // execute the dialog
+ XDialog xDialog = ( XDialog )UnoRuntime.queryInterface(
+ XDialog.class, dialog );
+ xDialog.execute();
+
+ // dispose the dialog
+ XComponent xComponent = ( XComponent )UnoRuntime.queryInterface(
+ XComponent.class, dialog );
+ xComponent.dispose();
+ }
+
+ /** action listener
+ */
+ public class ActionListenerImpl implements com.sun.star.awt.XActionListener {
+
+ private int _nCounts = 0;
+
+ private XControlContainer _xControlCont;
+
+ public ActionListenerImpl( XControlContainer xControlCont ) {
+ _xControlCont = xControlCont;
+ }
+
+ // XEventListener
+ public void disposing( EventObject eventObject ) {
+ _xControlCont = null;
+ }
+
+ // XActionListener
+ public void actionPerformed( ActionEvent actionEvent ) {
+
+ // increase click counter
+ _nCounts++;
+
+ // set label text
+ Object label = _xControlCont.getControl( "Label1" );
+ XFixedText xLabel = ( XFixedText )UnoRuntime.queryInterface(
+ XFixedText.class, label );
+ xLabel.setText( _labelPrefix + _nCounts );
+ }
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/BasicAndDialogs/FirstStepsBasic.odt b/odk/examples/DevelopersGuide/BasicAndDialogs/FirstStepsBasic.odt
new file mode 100644
index 000000000..4024740f1
--- /dev/null
+++ b/odk/examples/DevelopersGuide/BasicAndDialogs/FirstStepsBasic.odt
Binary files differ
diff --git a/odk/examples/DevelopersGuide/BasicAndDialogs/ToolkitControls/Makefile b/odk/examples/DevelopersGuide/BasicAndDialogs/ToolkitControls/Makefile
new file mode 100644
index 000000000..bd3a43444
--- /dev/null
+++ b/odk/examples/DevelopersGuide/BasicAndDialogs/ToolkitControls/Makefile
@@ -0,0 +1,125 @@
+#*************************************************************************
+#
+# The Contents of this file are made available subject to the terms of
+# the BSD license.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+# 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+# contributors may be used to endorse or promote products derived
+# from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+# TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+# USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+#**************************************************************************
+
+# Builds the CreatingDialogs example of the Developers Guide.
+
+PRJ=../../../..
+SETTINGS=$(PRJ)/settings
+
+include $(SETTINGS)/settings.mk
+include $(SETTINGS)/std.mk
+
+# Define non-platform/compiler specific settings
+SAMPLE_NAME=BaDToolkitControls
+SAMPLE_GEN_OUT=$(OUT_MISC)/$(SAMPLE_NAME)
+
+COMP_NAME=ToolkitControls
+COMP_GEN_OUT=$(SAMPLE_GEN_OUT)/$(COMP_NAME)
+COMP_PACKAGE = $(OUT_BIN)/$(COMP_NAME).$(UNOOXT_EXT)
+COMP_PACKAGE_URL = $(subst \\,\,"$(COMP_PACKAGE_DIR)$(PS)$(COMP_NAME).$(UNOOXT_EXT)")
+COMP_UNOPKG_MANIFEST = $(COMP_GEN_OUT)/META-INF/manifest.xml
+COMP_REGISTERFLAG=$(COMP_GEN_OUT)$(PS)devguide_basic_$(COMP_NAME)_register_component.flag
+
+COMP_LIBRARY_FILES=\
+ ToolkitControls/dialog.xlb\
+ ToolkitControls/FileDialog.xba\
+ ToolkitControls/FileDialogDlg.xdl\
+ ToolkitControls/MultiPage.xba\
+ ToolkitControls/MultiPageDlg.xdl\
+ ToolkitControls/ProgressBar.xba\
+ ToolkitControls/ProgressBarDlg.xdl\
+ ToolkitControls/script.xlb\
+ ToolkitControls/ScrollBar.xba\
+ ToolkitControls/ScrollBarDlg.xdl
+
+# Targets
+.PHONY: ALL
+ALL : $(SAMPLE_NAME)
+
+include $(SETTINGS)/stdtarget.mk
+
+# rule for component package manifest
+$(COMP_GEN_OUT)/%/manifest.xml :
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ @echo $(OSEP)?xml version="$(QM)1.0$(QM)" encoding="$(QM)UTF-8$(QM)"?$(CSEP) > $@
+ @echo $(OSEP)!DOCTYPE manifest:manifest PUBLIC "$(QM)-//OpenOffice.org//DTD Manifest 1.0//EN$(QM)" "$(QM)Manifest.dtd$(QM)"$(CSEP) >> $@
+ @echo $(OSEP)manifest:manifest xmlns:manifest="$(QM)http://openoffice.org/2001/manifest$(QM)"$(CSEP) >> $@
+ @echo $(SQM) $(SQM)$(OSEP)manifest:file-entry manifest:media-type="$(QM)application/vnd.sun.star.basic-library$(QM)" >> $@
+ @echo $(SQM) $(SQM)manifest:full-path="$(QM)$(COMP_NAME)$(QM)"/$(CSEP) >> $@
+ @echo $(OSEP)/manifest:manifest$(CSEP) >> $@
+
+# rule for component package file
+$(COMP_PACKAGE) : $(COMP_UNOPKG_MANIFEST) $(COMP_LIBRARY_FILES)
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ $(SDK_ZIP) $@ ToolkitControls/dialog.xlb \
+ ToolkitControls/FileDialog.xba ToolkitControls/FileDialogDlg.xdl \
+ ToolkitControls/MultiPage.xba ToolkitControls/MultiPageDlg.xdl \
+ ToolkitControls/ProgressBar.xba ToolkitControls/ProgressBarDlg.xdl \
+ ToolkitControls/script.xlb ToolkitControls/ScrollBar.xba \
+ ToolkitControls/ScrollBarDlg.xdl
+ cd $(subst /,$(PS),$(COMP_GEN_OUT)) && $(SDK_ZIP) -u ../../../bin/$(@F) META-INF/manifest.xml
+
+$(COMP_REGISTERFLAG) : $(COMP_PACKAGE)
+ifeq "$(SDK_AUTO_DEPLOYMENT)" "YES"
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ $(DEPLOYTOOL) $(COMP_PACKAGE_URL)
+ @echo flagged > $(subst /,$(PS),$@)
+else
+ @echo --------------------------------------------------------------------------------
+ @echo If you want to install your component automatically, please set the environment
+ @echo variable SDK_AUTO_DEPLOYMENT = YES. But note that auto deployment is only
+ @echo possible if no office instance is running.
+ @echo --------------------------------------------------------------------------------
+endif
+
+$(SAMPLE_NAME) : $(COMP_REGISTERFLAG)
+ @echo --------------------------------------------------------------------------------
+ @echo The "$(QM)ToolkitControls$(QM)" library was installed in your office installation
+ @echo if SDK_AUTO_DEPLOYMENT = YES. You can use it in the BASIC IDE as a normal
+ @echo Basic library.
+ @echo You can also load the document "$(QM)$(COMP_NAME).odt$(QM)" and press a button
+ @echo to run one of the example macros.
+ @echo -
+ @echo $(MAKE) $(COMP_NAME).odt.load
+ @echo --------------------------------------------------------------------------------
+
+$(COMP_NAME).odt.load : $(COMP_REGISTERFLAG)
+ "$(OFFICE_PROGRAM_PATH)$(PS)soffice" $(basename $@)
+
+.PHONY: clean
+clean :
+ -$(DELRECURSIVE) $(subst /,$(PS),$(COMP_GEN_OUT))
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$(COMP_PACKAGE_URL)))
diff --git a/odk/examples/DevelopersGuide/BasicAndDialogs/ToolkitControls/ToolkitControls.odt b/odk/examples/DevelopersGuide/BasicAndDialogs/ToolkitControls/ToolkitControls.odt
new file mode 100644
index 000000000..ffedaa756
--- /dev/null
+++ b/odk/examples/DevelopersGuide/BasicAndDialogs/ToolkitControls/ToolkitControls.odt
Binary files differ
diff --git a/odk/examples/DevelopersGuide/BasicAndDialogs/ToolkitControls/ToolkitControls/FileDialog.xba b/odk/examples/DevelopersGuide/BasicAndDialogs/ToolkitControls/ToolkitControls/FileDialog.xba
new file mode 100644
index 000000000..60f6a491f
--- /dev/null
+++ b/odk/examples/DevelopersGuide/BasicAndDialogs/ToolkitControls/ToolkitControls/FileDialog.xba
@@ -0,0 +1,90 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+-->
+<!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd">
+<script:module xmlns:script="http://openoffice.org/2000/script" script:name="FileDialog" script:language="StarBasic">REM ***** BASIC *****
+
+Dim oDialog As Object
+
+Sub Main()
+
+ Dim oLibContainer As Object, oLib As Object
+ Dim oInputStreamProvider As Object
+
+ Const sLibName = &quot;ToolkitControls&quot;
+ Const sDialogName = &quot;FileDialogDlg&quot;
+
+ REM load/get library and input stream provider
+ oLibContainer = DialogLibraries
+ oLibContainer.loadLibrary( sLibName )
+ oLib = oLibContainer.getByName( sLibName )
+ oInputStreamProvider = oLib.getByName( sDialogName )
+
+ REM create dialog control
+ oDialog = CreateUnoDialog( oInputStreamProvider )
+
+ REM show the dialog
+ oDialog.execute()
+
+End Sub
+
+Sub OpenFileDialog()
+
+ Dim oFilePicker As Object, oSimpleFileAccess As Object
+ Dim oPathSettings As Object
+ Dim oTextField As Object, oTextFieldModel As Object
+ Dim sFileURL As String
+ Dim sFiles As Variant
+
+ REM file dialog
+ oFilePicker = CreateUnoService( &quot;com.sun.star.ui.dialogs.FilePicker&quot; )
+
+ REM set filter
+ oFilePicker.AppendFilter( &quot;All files&quot;, &quot;*.*&quot; )
+ oFilePicker.AppendFilter( &quot;StarOffice 6.0 Text Text Document&quot;, &quot;*.sxw&quot; )
+ oFilePicker.AppendFilter( &quot;StarOffice 6.0 Spreadsheet&quot;, &quot;*.sxc&quot; )
+ oFilePicker.SetCurrentFilter( &quot;All files&quot; )
+
+ REM if no file URL is set, get path settings from configuration
+ oTextFieldModel = oDialog.Model.TextField1
+ sFileURL = ConvertToURL( oTextFieldModel.Text )
+ If sFileURL = &quot;&quot; Then
+ oSettings = CreateUnoService( &quot;com.sun.star.frame.Settings&quot; )
+ oPathSettings = CreateUnoService( &quot;com.sun.star.util.PathSettings&quot; )
+ sFileURL = oPathSettings.getPropertyValue( &quot;Work&quot; )
+ End If
+
+ REM set display directory
+ oSimpleFileAccess = CreateUnoService( &quot;com.sun.star.ucb.SimpleFileAccess&quot; )
+ If oSimpleFileAccess.exists( sFileURL ) And oSimpleFileAccess.isFolder( sFileURL ) Then
+ oFilePicker.setDisplayDirectory( sFileURL )
+ End If
+
+ REM execute file dialog
+ If oFilePicker.execute() Then
+ sFiles = oFilePicker.getFiles()
+ sFileURL = sFiles(0)
+ If oSimpleFileAccess.exists( sFileURL ) Then
+ REM set file path in text field
+ oTextField = oDialog.GetControl(&quot;TextField1&quot;)
+ oTextField.SetText( ConvertFromURL( sFileURL ) )
+ End If
+ End If
+
+End Sub
+</script:module> \ No newline at end of file
diff --git a/odk/examples/DevelopersGuide/BasicAndDialogs/ToolkitControls/ToolkitControls/FileDialogDlg.xdl b/odk/examples/DevelopersGuide/BasicAndDialogs/ToolkitControls/ToolkitControls/FileDialogDlg.xdl
new file mode 100644
index 000000000..ec99f7b48
--- /dev/null
+++ b/odk/examples/DevelopersGuide/BasicAndDialogs/ToolkitControls/ToolkitControls/FileDialogDlg.xdl
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+-->
+<!DOCTYPE dlg:window PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "dialog.dtd">
+<dlg:window xmlns:dlg="http://openoffice.org/2000/dialog" xmlns:script="http://openoffice.org/2000/script" dlg:id="FileDialogDlg" dlg:title="File Dialog Demo" dlg:left="138" dlg:top="80" dlg:width="203" dlg:height="157">
+ <dlg:bulletinboard>
+ <dlg:textfield dlg:id="TextField1" dlg:tab-index="0" dlg:left="6" dlg:top="35" dlg:width="168" dlg:height="12"/>
+ <dlg:button dlg:id="CommandButton1" dlg:tab-index="1" dlg:left="180" dlg:top="35" dlg:width="14" dlg:height="14" dlg:value="...">
+ <script:event script:event-name="on-performaction" script:location="application" script:macro-name="ToolkitControls.FileDialog.OpenFileDialog" script:language="StarBasic"/>
+ </dlg:button>
+ <dlg:text dlg:id="Label1" dlg:tab-index="2" dlg:left="6" dlg:top="20" dlg:width="80" dlg:height="10" dlg:value="Enter File Path"/>
+ <dlg:button dlg:id="CommandButton2" dlg:tab-index="3" dlg:left="8" dlg:top="116" dlg:width="44" dlg:height="16" dlg:value="Cancel" dlg:button-type="cancel"/>
+ </dlg:bulletinboard>
+</dlg:window> \ No newline at end of file
diff --git a/odk/examples/DevelopersGuide/BasicAndDialogs/ToolkitControls/ToolkitControls/MultiPage.xba b/odk/examples/DevelopersGuide/BasicAndDialogs/ToolkitControls/ToolkitControls/MultiPage.xba
new file mode 100644
index 000000000..65f160614
--- /dev/null
+++ b/odk/examples/DevelopersGuide/BasicAndDialogs/ToolkitControls/ToolkitControls/MultiPage.xba
@@ -0,0 +1,303 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+-->
+<!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd">
+<script:module xmlns:script="http://openoffice.org/2000/script" script:name="MultiPage" script:language="StarBasic">REM ***** BASIC *****
+
+Dim oDialog As Object
+
+Sub Main()
+
+ Dim oLibContainer As Object, oLib As Object
+ Dim oInputStreamProvider As Object
+ Dim oDialogModel As Object
+
+ Const sLibName = &quot;ToolkitControls&quot;
+ Const sDialogName = &quot;MultiPageDlg&quot;
+
+ REM load/get library and input stream provider
+ oLibContainer = DialogLibraries
+ oLibContainer.loadLibrary( sLibName )
+ oLib = oLibContainer.getByName( sLibName )
+ oInputStreamProvider = oLib.getByName( sDialogName )
+
+ REM create dialog control
+ oDialog = CreateUnoDialog( oInputStreamProvider )
+
+ REM initialize dialog and controls
+ Initialize()
+
+ REM show the dialog
+ oDialog.execute()
+
+End Sub
+
+
+Sub Initialize()
+
+ Dim oDialogModel As Object
+ Dim oNextButton As Object, oNextButtonModel As Object
+ Dim oListBox As Object
+ Dim oCheckBoxModel As Object
+ Dim oOptionButtonModel As Object
+ Dim oCurrencyFieldModel As Object
+ Dim oNumericFieldModel As Object
+ Dim oComboBox As Object, oComboBoxModel As Object
+ Dim i As Integer
+ Dim sName As String
+ Dim sPizzas As Variant, sToppings As Variant
+ Dim sCreditCards As Variant
+ Dim sMonths As Variant
+ Dim iCount As Integer
+
+ REM dialog properties
+ oDialogModel = oDialog.Model
+ oDialogModel.Step = 1
+
+ REM next button properties
+ oNextButtonModel = oDialogModel.NextButton
+ oNextButtonModel.DefaultButton = True
+ oNextButton = oDialog.getControl(&quot;NextButton&quot;)
+ oNextButton.setFocus()
+
+ REM enable/disable back button, set label of next button
+ PageChanged()
+
+ REM set control properties on dialog page 1
+
+ REM pizzas in list box
+ oListBox = oDialog.getControl(&quot;ListBox1&quot;)
+ sPizzas = Array(&quot;Margarita&quot;,&quot;Vegetarian&quot;,&quot;Ham &amp; Pineapple&quot;,&quot;Mexican&quot;,&quot;Seafood&quot;)
+ oListBox.addItems( sPizzas, 0 )
+ oListBox.selectItem( sPizzas(0), True )
+
+ REM extra toppings
+ sToppings = Array(&quot;Extra Cheese&quot;,&quot;Corn&quot;,&quot;Onions&quot;,&quot;Olives&quot;)
+ For i = 0 To 3
+ sName = &quot;CheckBox&quot; + i
+ oCheckBoxModel = oDialogModel.getByName( sName )
+ oCheckBoxModel.Label = sToppings( i )
+ Next i
+
+ REM default pizza size
+ oOptionButtonModel = oDialogModel.OptionButton2
+ oOptionButtonModel.State = True
+
+ REM currency field properties
+ oCurrencyFieldModel = oDialogModel.CurrencyField1
+ oCurrencyFieldModel.ReadOnly = True
+ oCurrencyFieldModel.DecimalAccuracy = 2
+ oCurrencyFieldModel.CurrencySymbol = &quot;€&quot;
+ oCurrencyFieldModel.PrependCurrencySymbol = True
+
+ REM calculate prize for default settings
+ CalculatePrize()
+
+ REM set control properties on dialog page 2
+
+ REM numeric field properties
+ oNumericFieldModel = oDialogModel.NumericField1
+ oNumericFieldModel.DecimalAccuracy = 0
+
+ REM set control properties on dialog page 3
+
+ REM default payment method
+ oOptionButtonModel = oDialogModel.OptionButton4
+ oOptionButtonModel.State = True
+
+ REM credit cards in combo box
+ oComboBox = oDialog.getControl(&quot;ComboBox1&quot;)
+ sCreditCards = Array(&quot;Visa&quot;,&quot;Master/EuroCard&quot;,&quot;American Express&quot;)
+ oComboBox.addItems( sCreditCards, 0 )
+ oComboBoxModel = oDialogModel.ComboBox1
+ oComboBoxModel.Text = sCreditCards(0)
+
+ REM expiration month
+ oListBox = oDialog.getControl(&quot;ListBox2&quot;)
+ sMonths = Array(&quot;01&quot;,&quot;02&quot;,&quot;03&quot;,&quot;04&quot;,&quot;05&quot;,&quot;06&quot;,&quot;07&quot;,&quot;08&quot;,&quot;09&quot;,&quot;10&quot;,&quot;11&quot;,&quot;12&quot;)
+ oListBox.addItems( sMonths, 0 )
+ oListBox.selectItemPos( Month(Date())-1, True )
+
+ REM expiration year
+ oListBox = oDialog.getControl(&quot;ListBox3&quot;)
+ For i = Year(Date()) To Year(Date()) + 4
+ iCount = oListBox.getItemCount()
+ oListBox.addItem( Str( i ), iCount )
+ Next i
+ oListBox.selectItemPos( 0, True )
+
+End Sub
+
+
+Sub CalculatePrize()
+
+ Dim oDialogModel As Object
+ Dim oListBox As Object
+ Dim oCheckBoxModel As Object
+ Dim oCurrencyFieldModel As Object
+ Dim Position As Integer
+ Dim sName As String
+ Dim i As Integer, nChecked As Integer
+ Dim Prizes As Variant
+ Dim Prize As Double
+
+ REM prizes for medium size pizzas
+ Prizes = Array( 4, 5, 6, 6, 7 )
+
+ REM get the position of the currently selected pizza
+ oListBox = oDialog.getControl(&quot;ListBox1&quot;)
+ Position = oListBox.getSelectedItemPos()
+ Prize = Prizes( Position )
+
+ REM small pizzas are 1€ cheaper, large pizzas are 1€ more expensive
+ oDialogModel = oDialog.Model
+ If oDialogModel.OptionButton1.State = 1 Then
+ Prize = Prize - 1
+ ElseIf oDialogModel.OptionButton3.State = 1 Then
+ Prize = Prize + 1
+ End If
+
+ REM get the number of extra toppings (0.5€ per extra topping)
+ For i = 0 To 3
+ sName = &quot;CheckBox&quot; + i
+ oCheckBoxModel = oDialogModel.getByName( sName )
+ If oCheckBoxModel.State = 1 Then
+ nChecked = nChecked + 1
+ End If
+ Next i
+ Prize = Prize + nChecked * 0.5
+
+ REM set the value of the currency field
+ oCurrencyFieldModel = oDialogModel.CurrencyField1
+ oCurrencyFieldModel.Value = Prize
+
+End Sub
+
+
+Sub PaymentMethodChanged()
+
+ Dim oDialogModel As Object
+ Dim bEnabled As Boolean
+
+ REM get dialog model
+ oDialogModel = oDialog.getModel()
+
+ If oDialogModel.OptionButton4.State = 1 Then
+ REM enable controls for payment by credit card
+ bEnabled = True
+ ElseIf oDialogModel.OptionButton5.State = 1 Then
+ REM disable controls for payment by check
+ bEnabled = False
+ End If
+
+ REM enable/disable controls
+ With oDialogModel
+ .Label11.Enabled = bEnabled
+ .Label12.Enabled = bEnabled
+ .Label13.Enabled = bEnabled
+ .ComboBox1.Enabled = bEnabled
+ .TextField6.Enabled = bEnabled
+ .ListBox2.Enabled = bEnabled
+ .ListBox3.Enabled = bEnabled
+ .TextField7.Enabled = bEnabled
+ End With
+
+End Sub
+
+
+Sub NextPage()
+
+ Dim oDialogModel As Object
+
+ REM get dialog model
+ oDialogModel = oDialog.getModel()
+
+ If oDialogModel.Step &lt; 3 Then
+ REM next page
+ oDialogModel.Step = oDialogModel.Step + 1
+ REM enable/disable back button, set label of next button
+ PageChanged()
+ ElseIf oDialogModel.Step = 3 Then
+ REM submit order
+ SubmitOrder()
+ REM hide dialog
+ oDialog.endExecute()
+ End If
+
+End Sub
+
+
+Sub PreviousPage()
+
+ Dim oDialogModel As Object
+
+ REM get dialog model
+ oDialogModel = oDialog.getModel()
+
+ If oDialogModel.Step &gt; 1 Then
+ REM previous page
+ oDialogModel.Step = oDialogModel.Step - 1
+ REM enable/disable back button, set label of next button
+ PageChanged()
+ End If
+
+End Sub
+
+
+Sub PageChanged()
+
+ Dim oDialogModel As Object
+ Dim oBackButtonModel As Object
+ Dim oNextButtonModel As Object
+
+ Const sLabelNext = &quot;Next &gt;&gt;&quot;
+ Const sLabelSubmit = &quot;Submit&quot;
+
+ REM get dialog model
+ oDialogModel = oDialog.getModel()
+
+ REM get back button model
+ oBackButtonModel = oDialogModel.getByName(&quot;BackButton&quot;)
+
+ REM enable/disable back button
+ If oDialogModel.Step = 1 Then
+ oBackButtonModel.Enabled = False
+ Else
+ oBackButtonModel.Enabled = True
+ End If
+
+ REM get next button model
+ oNextButtonModel = oDialogModel.getByName(&quot;NextButton&quot;)
+
+ REM set label of next button
+ If oDialogModel.Step = 3 Then
+ oNextButtonModel.Label = sLabelSubmit
+ Else
+ oNextButtonModel.Label = sLabelNext
+ End If
+
+End Sub
+
+
+Sub SubmitOrder()
+
+ MsgBox &quot;Your pizza will be delivered in 45 minutes.&quot;
+
+End Sub
+
+</script:module>
diff --git a/odk/examples/DevelopersGuide/BasicAndDialogs/ToolkitControls/ToolkitControls/MultiPageDlg.xdl b/odk/examples/DevelopersGuide/BasicAndDialogs/ToolkitControls/ToolkitControls/MultiPageDlg.xdl
new file mode 100644
index 000000000..f7b28aa33
--- /dev/null
+++ b/odk/examples/DevelopersGuide/BasicAndDialogs/ToolkitControls/ToolkitControls/MultiPageDlg.xdl
@@ -0,0 +1,92 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+-->
+<!DOCTYPE dlg:window PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "dialog.dtd">
+<dlg:window xmlns:dlg="http://openoffice.org/2000/dialog" xmlns:script="http://openoffice.org/2000/script" dlg:id="MultiPageDlg" dlg:title="Multi Page Dialog Demo" dlg:left="138" dlg:top="80" dlg:width="203" dlg:height="157" dlg:page="1">
+ <dlg:bulletinboard>
+ <dlg:button dlg:id="CancelButton" dlg:tab-index="0" dlg:left="6" dlg:top="135" dlg:width="50" dlg:height="14" dlg:value="Cancel" dlg:button-type="cancel"/>
+ <dlg:button dlg:id="BackButton" dlg:tab-index="1" dlg:left="76" dlg:top="135" dlg:width="50" dlg:height="14" dlg:value="&lt; Back">
+ <script:event script:event-name="on-performaction" script:location="application" script:macro-name="ToolkitControls.MultiPage.PreviousPage" script:language="StarBasic"/>
+ </dlg:button>
+ <dlg:button dlg:id="NextButton" dlg:tab-index="2" dlg:left="147" dlg:top="135" dlg:width="50" dlg:height="14" dlg:value="Next &gt;">
+ <script:event script:event-name="on-performaction" script:location="application" script:macro-name="ToolkitControls.MultiPage.NextPage" script:language="StarBasic"/>
+ </dlg:button>
+ <dlg:fixedline dlg:id="FixedLine1" dlg:tab-index="3" dlg:left="6" dlg:top="6" dlg:width="185" dlg:height="9" dlg:page="1" dlg:value="Select a Pizza"/>
+ <dlg:text dlg:id="Label1" dlg:tab-index="4" dlg:left="11" dlg:top="22" dlg:width="57" dlg:height="9" dlg:page="1" dlg:value="~Pizza"/>
+ <dlg:menulist dlg:id="ListBox1" dlg:tab-index="5" dlg:left="11" dlg:top="35" dlg:width="60" dlg:height="12" dlg:page="1" dlg:spin="true">
+ <script:event script:event-name="on-itemstatechange" script:location="application" script:macro-name="ToolkitControls.MultiPage.CalculatePrize" script:language="StarBasic"/>
+ </dlg:menulist>
+ <dlg:text dlg:id="Label2" dlg:tab-index="6" dlg:left="11" dlg:top="61" dlg:width="60" dlg:height="11" dlg:page="1" dlg:value="Extra Toppings"/>
+ <dlg:checkbox dlg:id="CheckBox0" dlg:tab-index="7" dlg:left="11" dlg:top="75" dlg:width="60" dlg:height="9" dlg:page="1" dlg:value="CheckBox0" dlg:checked="false">
+ <script:event script:event-name="on-itemstatechange" script:location="application" script:macro-name="ToolkitControls.MultiPage.CalculatePrize" script:language="StarBasic"/>
+ </dlg:checkbox>
+ <dlg:checkbox dlg:id="CheckBox1" dlg:tab-index="8" dlg:left="11" dlg:top="88" dlg:width="60" dlg:height="9" dlg:page="1" dlg:value="CheckBox1" dlg:checked="false">
+ <script:event script:event-name="on-itemstatechange" script:location="application" script:macro-name="ToolkitControls.MultiPage.CalculatePrize" script:language="StarBasic"/>
+ </dlg:checkbox>
+ <dlg:checkbox dlg:id="CheckBox2" dlg:tab-index="9" dlg:left="11" dlg:top="101" dlg:width="60" dlg:height="9" dlg:page="1" dlg:value="CheckBox2" dlg:checked="false">
+ <script:event script:event-name="on-itemstatechange" script:location="application" script:macro-name="ToolkitControls.MultiPage.CalculatePrize" script:language="StarBasic"/>
+ </dlg:checkbox>
+ <dlg:checkbox dlg:id="CheckBox3" dlg:tab-index="10" dlg:left="11" dlg:top="114" dlg:width="60" dlg:height="9" dlg:page="1" dlg:value="CheckBox3" dlg:checked="false">
+ <script:event script:event-name="on-itemstatechange" script:location="application" script:macro-name="ToolkitControls.MultiPage.CalculatePrize" script:language="StarBasic"/>
+ </dlg:checkbox>
+ <dlg:fixedline dlg:id="FixedLine2" dlg:tab-index="11" dlg:left="96" dlg:top="22" dlg:width="9" dlg:height="106" dlg:page="1" dlg:align="vertical"/>
+ <dlg:text dlg:id="Label3" dlg:tab-index="12" dlg:left="120" dlg:top="22" dlg:width="60" dlg:height="9" dlg:page="1" dlg:value="Size"/>
+ <dlg:radiogroup>
+ <dlg:radio dlg:id="OptionButton1" dlg:tab-index="13" dlg:left="120" dlg:top="36" dlg:width="60" dlg:height="9" dlg:page="1" dlg:value="Small">
+ <script:event script:event-name="on-itemstatechange" script:location="application" script:macro-name="ToolkitControls.MultiPage.CalculatePrize" script:language="StarBasic"/>
+ </dlg:radio>
+ <dlg:radio dlg:id="OptionButton2" dlg:tab-index="14" dlg:left="120" dlg:top="49" dlg:width="60" dlg:height="9" dlg:page="1" dlg:value="Medium">
+ <script:event script:event-name="on-itemstatechange" script:location="application" script:macro-name="ToolkitControls.MultiPage.CalculatePrize" script:language="StarBasic"/>
+ </dlg:radio>
+ <dlg:radio dlg:id="OptionButton3" dlg:tab-index="15" dlg:left="120" dlg:top="62" dlg:width="60" dlg:height="9" dlg:page="1" dlg:value="Large">
+ <script:event script:event-name="on-itemstatechange" script:location="application" script:macro-name="ToolkitControls.MultiPage.CalculatePrize" script:language="StarBasic"/>
+ </dlg:radio>
+ </dlg:radiogroup>
+ <dlg:text dlg:id="Label4" dlg:tab-index="16" dlg:left="120" dlg:top="114" dlg:width="25" dlg:height="9" dlg:page="1" dlg:value="Prize"/>
+ <dlg:currencyfield dlg:id="CurrencyField1" dlg:tab-index="17" dlg:left="150" dlg:top="113" dlg:width="30" dlg:height="12" dlg:page="1"/>
+ <dlg:fixedline dlg:id="FixedLine3" dlg:tab-index="18" dlg:left="6" dlg:top="6" dlg:width="185" dlg:height="9" dlg:page="2" dlg:value="Enter the Delivery Address"/>
+ <dlg:text dlg:id="Label5" dlg:tab-index="19" dlg:left="11" dlg:top="27" dlg:width="50" dlg:height="9" dlg:page="2" dlg:value="Full Name"/>
+ <dlg:textfield dlg:id="TextField2" dlg:tab-index="20" dlg:left="70" dlg:top="25" dlg:width="110" dlg:height="12" dlg:page="2"/>
+ <dlg:text dlg:id="Label6" dlg:tab-index="21" dlg:left="11" dlg:top="47" dlg:width="50" dlg:height="9" dlg:page="2" dlg:value="Address"/>
+ <dlg:textfield dlg:id="TextField3" dlg:tab-index="22" dlg:left="70" dlg:top="45" dlg:width="110" dlg:height="12" dlg:page="2"/>
+ <dlg:text dlg:id="Label7" dlg:tab-index="23" dlg:left="11" dlg:top="67" dlg:width="50" dlg:height="9" dlg:page="2" dlg:value="City"/>
+ <dlg:textfield dlg:id="TextField4" dlg:tab-index="24" dlg:left="70" dlg:top="65" dlg:width="80" dlg:height="12" dlg:page="2"/>
+ <dlg:text dlg:id="Label8" dlg:tab-index="25" dlg:left="11" dlg:top="87" dlg:width="50" dlg:height="9" dlg:page="2" dlg:value="ZIP / Postal Code"/>
+ <dlg:numericfield dlg:id="NumericField1" dlg:tab-index="26" dlg:left="70" dlg:top="85" dlg:width="50" dlg:height="12" dlg:page="2"/>
+ <dlg:text dlg:id="Label9" dlg:tab-index="27" dlg:left="11" dlg:top="107" dlg:width="50" dlg:height="9" dlg:page="2" dlg:value="Phone Number"/>
+ <dlg:textfield dlg:id="TextField5" dlg:tab-index="28" dlg:left="70" dlg:top="105" dlg:width="80" dlg:height="12" dlg:page="2"/>
+ <dlg:fixedline dlg:id="FixedLine4" dlg:tab-index="29" dlg:left="6" dlg:top="6" dlg:width="185" dlg:height="9" dlg:page="3" dlg:value="Select a Payment Method"/>
+ <dlg:radiogroup>
+ <dlg:radio dlg:id="OptionButton4" dlg:tab-index="30" dlg:left="12" dlg:top="26" dlg:width="40" dlg:height="9" dlg:page="3" dlg:value="Credit Card">
+ <script:event script:event-name="on-itemstatechange" script:location="application" script:macro-name="ToolkitControls.MultiPage.PaymentMethodChanged" script:language="StarBasic"/>
+ </dlg:radio>
+ <dlg:radio dlg:id="OptionButton5" dlg:tab-index="31" dlg:left="12" dlg:top="110" dlg:width="40" dlg:height="9" dlg:page="3" dlg:value="Check">
+ <script:event script:event-name="on-itemstatechange" script:location="application" script:macro-name="ToolkitControls.MultiPage.PaymentMethodChanged" script:language="StarBasic"/>
+ </dlg:radio>
+ </dlg:radiogroup>
+ <dlg:combobox dlg:id="ComboBox1" dlg:tab-index="32" dlg:left="76" dlg:top="25" dlg:width="70" dlg:height="12" dlg:page="3" dlg:spin="true"/>
+ <dlg:text dlg:id="Label11" dlg:tab-index="33" dlg:left="21" dlg:top="46" dlg:width="50" dlg:height="9" dlg:page="3" dlg:value="Credit Card No."/>
+ <dlg:textfield dlg:id="TextField6" dlg:tab-index="34" dlg:left="76" dlg:top="45" dlg:width="70" dlg:height="12" dlg:page="3"/>
+ <dlg:text dlg:id="Label12" dlg:tab-index="35" dlg:left="21" dlg:top="66" dlg:width="50" dlg:height="9" dlg:page="3" dlg:value="Expiration Date"/>
+ <dlg:menulist dlg:id="ListBox2" dlg:tab-index="36" dlg:left="76" dlg:top="65" dlg:width="20" dlg:height="12" dlg:page="3" dlg:spin="true"/>
+ <dlg:menulist dlg:id="ListBox3" dlg:tab-index="37" dlg:left="100" dlg:top="65" dlg:width="27" dlg:height="12" dlg:page="3" dlg:spin="true"/>
+ <dlg:text dlg:id="Label13" dlg:tab-index="38" dlg:left="21" dlg:top="86" dlg:width="50" dlg:height="9" dlg:page="3" dlg:value="Cardholder&apos;s Name"/>
+ <dlg:textfield dlg:id="TextField7" dlg:tab-index="39" dlg:left="76" dlg:top="85" dlg:width="70" dlg:height="12" dlg:page="3"/>
+ <dlg:textfield dlg:id="TextField1" dlg:tab-index="40" dlg:left="-47" dlg:top="46" dlg:width="0" dlg:height="2" dlg:page="3"/>
+ </dlg:bulletinboard>
+</dlg:window>
diff --git a/odk/examples/DevelopersGuide/BasicAndDialogs/ToolkitControls/ToolkitControls/ProgressBar.xba b/odk/examples/DevelopersGuide/BasicAndDialogs/ToolkitControls/ToolkitControls/ProgressBar.xba
new file mode 100644
index 000000000..8b34f0cc3
--- /dev/null
+++ b/odk/examples/DevelopersGuide/BasicAndDialogs/ToolkitControls/ToolkitControls/ProgressBar.xba
@@ -0,0 +1,93 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+-->
+<!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd">
+<script:module xmlns:script="http://openoffice.org/2000/script" script:name="ProgressBar" script:language="StarBasic">REM ***** BASIC *****
+
+Dim oDialog As Object
+
+Sub Main()
+
+ Dim oLibContainer As Object, oLib As Object
+ Dim oInputStreamProvider As Object
+ Dim oProgressBar As Object
+
+ Const sLibName = &quot;ToolkitControls&quot;
+ Const sDialogName = &quot;ProgressBarDlg&quot;
+
+ REM load/get library and input stream provider
+ oLibContainer = DialogLibraries
+ oLibContainer.loadLibrary( sLibName )
+ oLib = oLibContainer.getByName( sLibName )
+ oInputStreamProvider = oLib.getByName( sDialogName )
+
+ REM create dialog control
+ oDialog = CreateUnoDialog( oInputStreamProvider )
+
+ REM hide progress bar
+ oProgressBar = oDialog.getControl(&quot;ProgressBar1&quot;)
+ oProgressBar.setVisible( False )
+
+ REM show the dialog
+ oDialog.execute()
+
+End Sub
+
+Sub ProgressBarDemo()
+
+ Dim oProgressBar As Object, oProgressBarModel As Object
+ Dim oCancelButtonModel As Object
+ Dim oStartButtonModel As Object
+ Dim ProgressValue As Long
+
+ REM progress bar settings
+ Const ProgressValueMin = 0
+ Const ProgressValueMax = 50
+ Const ProgressStep = 1
+
+ REM set minimum and maximum progress value
+ oProgressBarModel = oDialog.Model.ProgressBar1
+ oProgressBarModel.ProgressValueMin = ProgressValueMin
+ oProgressBarModel.ProgressValueMax = ProgressValueMax
+
+ REM disable cancel and start button
+ oCancelButtonModel = oDialog.Model.CommandButton1
+ oCancelButtonModel.Enabled = False
+ oStartButtonModel = oDialog.Model.CommandButton2
+ oStartButtonModel.Enabled = False
+
+ REM show progress bar
+ oProgressBar = oDialog.getControl(&quot;ProgressBar1&quot;)
+ oProgressBar.setVisible( True )
+
+ REM increase progress value every second
+ For ProgressValue = ProgressValueMin To ProgressValueMax Step ProgressStep
+ oProgressBarModel.ProgressValue = ProgressValue
+ Wait 40
+ Next ProgressValue
+
+ REM hide progress bar
+ oProgressBar.setVisible( False )
+
+ REM enable cancel and start button
+ oCancelButtonModel.Enabled = True
+ oStartButtonModel.Enabled = True
+
+End Sub
+
+</script:module> \ No newline at end of file
diff --git a/odk/examples/DevelopersGuide/BasicAndDialogs/ToolkitControls/ToolkitControls/ProgressBarDlg.xdl b/odk/examples/DevelopersGuide/BasicAndDialogs/ToolkitControls/ToolkitControls/ProgressBarDlg.xdl
new file mode 100644
index 000000000..4a5803273
--- /dev/null
+++ b/odk/examples/DevelopersGuide/BasicAndDialogs/ToolkitControls/ToolkitControls/ProgressBarDlg.xdl
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+-->
+<!DOCTYPE dlg:window PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "dialog.dtd">
+<dlg:window xmlns:dlg="http://openoffice.org/2000/dialog" xmlns:script="http://openoffice.org/2000/script" dlg:id="ProgressBarDlg" dlg:title="Progress Bar Demo" dlg:left="138" dlg:top="80" dlg:width="203" dlg:height="157">
+ <dlg:bulletinboard>
+ <dlg:progressmeter dlg:id="ProgressBar1" dlg:tab-index="0" dlg:left="6" dlg:top="70" dlg:width="190" dlg:height="9" dlg:value="0"/>
+ <dlg:button dlg:id="CommandButton1" dlg:tab-index="1" dlg:left="6" dlg:top="135" dlg:width="50" dlg:height="14" dlg:value="Cancel" dlg:button-type="cancel"/>
+ <dlg:button dlg:id="CommandButton2" dlg:tab-index="2" dlg:left="147" dlg:top="135" dlg:width="50" dlg:height="14" dlg:value="Start Demo">
+ <script:event script:event-name="on-performaction" script:location="application" script:macro-name="ToolkitControls.ProgressBar.ProgressBarDemo" script:language="StarBasic"/>
+ </dlg:button>
+ </dlg:bulletinboard>
+</dlg:window> \ No newline at end of file
diff --git a/odk/examples/DevelopersGuide/BasicAndDialogs/ToolkitControls/ToolkitControls/ScrollBar.xba b/odk/examples/DevelopersGuide/BasicAndDialogs/ToolkitControls/ToolkitControls/ScrollBar.xba
new file mode 100644
index 000000000..db2dd7cdd
--- /dev/null
+++ b/odk/examples/DevelopersGuide/BasicAndDialogs/ToolkitControls/ToolkitControls/ScrollBar.xba
@@ -0,0 +1,103 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+-->
+<!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd">
+<script:module xmlns:script="http://openoffice.org/2000/script" script:name="ScrollBar" script:language="StarBasic">REM ***** BASIC *****
+
+Dim oDialog As Object
+Const Border = 5
+
+Sub Main()
+
+ Dim oLibContainer As Object, oLib As Object
+ Dim oInputStreamProvider As Object
+ Dim oDialogModel As Object
+ Dim oScrollBarModel As Object
+ Dim oLabelModel As Object
+ Dim sLabel As String
+ Dim VisibleSize As Double
+
+ Const sLibName = &quot;ToolkitControls&quot;
+ Const sDialogName = &quot;ScrollBarDlg&quot;
+
+ REM load/get library and input stream provider
+ oLibContainer = DialogLibraries
+ oLibContainer.loadLibrary( sLibName )
+ oLib = oLibContainer.getByName( sLibName )
+ oInputStreamProvider = oLib.getByName( sDialogName )
+
+ REM create dialog control
+ oDialog = CreateUnoDialog( oInputStreamProvider )
+
+ REM set the label
+ sLabel = &quot;This Text exceeds the visible area of the dialog and can be&quot;
+ sLabel = sLabel + &quot; scrolled horizontally by clicking on the scroll bar.&quot;
+ oDialogModel = oDialog.Model
+ oLabelModel = oDialogModel.Label1
+ oLabelModel.Label = sLabel
+
+ REM scroll bar settings
+ oScrollBarModel = oDialog.Model.ScrollBar1
+ oScrollBarModel.ScrollValueMax = 100
+ VisibleSize = (oDialogModel.Width - Border - oLabelModel.PositionX) / oLabelModel.Width
+ VisibleSize = VisibleSize * oScrollBarModel.ScrollValueMax
+ oScrollBarModel.VisibleSize = VisibleSize
+ oScrollBarModel.BlockIncrement = oScrollBarModel.VisibleSize
+ oScrollBarModel.LineIncrement = oScrollBarModel.BlockIncrement / 20
+
+ REM show the dialog
+ oDialog.execute()
+
+End Sub
+
+Sub AdjustmentHandler()
+
+ Dim oLabelModel As Object
+ Dim oScrollBarModel As Object
+ Dim ScrollValue As Long, ScrollValueMax As Long
+ Dim VisibleSize As Long
+ Dim Factor As Double
+
+ Static bInit As Boolean
+ Static PositionX0 As Long
+ Static Offset As Long
+
+ REM get the model of the label control
+ oLabelModel = oDialog.Model.Label1
+
+ REM on initialization remember the position of the label control and calculate offset
+ If bInit = False Then
+ bInit = True
+ PositionX0 = oLabelModel.PositionX
+ OffSet = PositionX0 + oLabelModel.Width - (oDialog.Model.Width - Border)
+ End If
+
+ REM get the model of the scroll bar control
+ oScrollBarModel = oDialog.Model.ScrollBar1
+
+ REM get the actual scroll value
+ ScrollValue = oScrollBarModel.ScrollValue
+
+ REM calculate and set new position of the label control
+ ScrollValueMax = oScrollBarModel.ScrollValueMax
+ VisibleSize = oScrollBarModel.VisibleSize
+ Factor = Offset / (ScrollValueMax - VisibleSize)
+ oLabelModel.PositionX = PositionX0 - Factor * ScrollValue
+
+End Sub
+</script:module> \ No newline at end of file
diff --git a/odk/examples/DevelopersGuide/BasicAndDialogs/ToolkitControls/ToolkitControls/ScrollBarDlg.xdl b/odk/examples/DevelopersGuide/BasicAndDialogs/ToolkitControls/ToolkitControls/ScrollBarDlg.xdl
new file mode 100644
index 000000000..ae36d0000
--- /dev/null
+++ b/odk/examples/DevelopersGuide/BasicAndDialogs/ToolkitControls/ToolkitControls/ScrollBarDlg.xdl
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+-->
+<!DOCTYPE dlg:window PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "dialog.dtd">
+<dlg:window xmlns:dlg="http://openoffice.org/2000/dialog" xmlns:script="http://openoffice.org/2000/script" dlg:id="ScrollBarDlg" dlg:title="Scroll Bar Demo" dlg:left="138" dlg:top="80" dlg:width="200" dlg:height="157">
+ <dlg:styles>
+ <dlg:style dlg:style-id="0" dlg:font-height="18"/>
+ </dlg:styles>
+ <dlg:bulletinboard>
+ <dlg:scrollbar dlg:id="ScrollBar1" dlg:tab-index="0" dlg:left="5" dlg:top="137" dlg:width="190" dlg:height="15">
+ <script:event script:event-name="on-adjustmentvaluechange" script:location="application" script:macro-name="ToolkitControls.ScrollBar.AdjustmentHandler" script:language="StarBasic"/>
+ </dlg:scrollbar>
+ <dlg:text dlg:style-id="0" dlg:id="Label1" dlg:tab-index="1" dlg:left="5" dlg:top="39" dlg:width="600" dlg:height="17" dlg:value="Label1"/>
+ </dlg:bulletinboard>
+</dlg:window> \ No newline at end of file
diff --git a/odk/examples/DevelopersGuide/BasicAndDialogs/ToolkitControls/ToolkitControls/dialog.xlb b/odk/examples/DevelopersGuide/BasicAndDialogs/ToolkitControls/ToolkitControls/dialog.xlb
new file mode 100644
index 000000000..a74e020a1
--- /dev/null
+++ b/odk/examples/DevelopersGuide/BasicAndDialogs/ToolkitControls/ToolkitControls/dialog.xlb
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE library:library PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "library.dtd">
+<library:library xmlns:library="http://openoffice.org/2000/library" library:name="ToolkitControls" library:readonly="false" library:passwordprotected="false">
+ <library:element library:name="FileDialogDlg"/>
+ <library:element library:name="ProgressBarDlg"/>
+ <library:element library:name="ScrollBarDlg"/>
+ <library:element library:name="MultiPageDlg"/>
+</library:library> \ No newline at end of file
diff --git a/odk/examples/DevelopersGuide/BasicAndDialogs/ToolkitControls/ToolkitControls/script.xlb b/odk/examples/DevelopersGuide/BasicAndDialogs/ToolkitControls/ToolkitControls/script.xlb
new file mode 100644
index 000000000..03741ae35
--- /dev/null
+++ b/odk/examples/DevelopersGuide/BasicAndDialogs/ToolkitControls/ToolkitControls/script.xlb
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE library:library PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "library.dtd">
+<library:library xmlns:library="http://openoffice.org/2000/library" library:name="ToolkitControls" library:readonly="false" library:passwordprotected="false">
+ <library:element library:name="FileDialog"/>
+ <library:element library:name="ProgressBar"/>
+ <library:element library:name="ScrollBar"/>
+ <library:element library:name="MultiPage"/>
+</library:library> \ No newline at end of file
diff --git a/odk/examples/DevelopersGuide/Charts/AddInChart.ods b/odk/examples/DevelopersGuide/Charts/AddInChart.ods
new file mode 100644
index 000000000..01708ed7b
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Charts/AddInChart.ods
Binary files differ
diff --git a/odk/examples/DevelopersGuide/Charts/CalcHelper.java b/odk/examples/DevelopersGuide/Charts/CalcHelper.java
new file mode 100644
index 000000000..d7d932282
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Charts/CalcHelper.java
@@ -0,0 +1,396 @@
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+// __________ Imports __________
+
+import java.util.Random;
+
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.lang.XMultiServiceFactory;
+// container access
+import com.sun.star.container.*;
+
+// application specific classes
+import com.sun.star.sheet.*;
+import com.sun.star.table.*;
+import com.sun.star.chart.*;
+import com.sun.star.text.XText;
+
+import com.sun.star.document.XEmbeddedObjectSupplier;
+import com.sun.star.frame.XModel;
+// base graphics things
+import com.sun.star.awt.Point;
+import com.sun.star.awt.Size;
+import com.sun.star.awt.Rectangle;
+
+// Exceptions
+import com.sun.star.uno.RuntimeException;
+import com.sun.star.container.NoSuchElementException;
+
+// __________ Implementation __________
+
+// Helper for accessing a calc document
+
+public class CalcHelper
+{
+ public CalcHelper( XSpreadsheetDocument aDoc )
+ {
+ maSpreadSheetDoc = aDoc;
+ initSpreadSheet();
+ }
+
+
+
+ public XSpreadsheet getChartSheet() throws RuntimeException
+ {
+ XNameAccess aSheetsNA = UnoRuntime.queryInterface(
+ XNameAccess.class, maSpreadSheetDoc.getSheets() );
+
+ XSpreadsheet aSheet = null;
+ try
+ {
+ aSheet = UnoRuntime.queryInterface(
+ XSpreadsheet.class, aSheetsNA.getByName( msChartSheetName ) );
+ }
+ catch( NoSuchElementException ex )
+ {
+ System.out.println( "Couldn't find sheet with name " + msChartSheetName + ": " + ex );
+ }
+ catch( Exception ex )
+ {}
+
+ return aSheet;
+ }
+
+
+
+ public XSpreadsheet getDataSheet() throws RuntimeException
+ {
+ XNameAccess aSheetsNA = UnoRuntime.queryInterface(
+ XNameAccess.class, maSpreadSheetDoc.getSheets() );
+
+ XSpreadsheet aSheet = null;
+ if( aSheetsNA != null )
+ {
+ try
+ {
+ aSheet = UnoRuntime.queryInterface(
+ XSpreadsheet.class, aSheetsNA.getByName( msDataSheetName ) );
+ }
+ catch( NoSuchElementException ex )
+ {
+ System.out.println( "Couldn't find sheet with name " + msDataSheetName + ": " + ex );
+ }
+ catch( Exception ex )
+ {}
+ }
+
+ return aSheet;
+ }
+
+
+
+ /** Insert a chart using the given name as name of the OLE object and the range as corresponding
+ range of data to be used for rendering. The chart is placed in the sheet for charts at
+ position aUpperLeft extending as large as given in aExtent.
+
+ The service name must be the name of a diagram service that can be instantiated via the
+ factory of the chart document
+ */
+ public XChartDocument insertChart(
+ String sChartName,
+ CellRangeAddress aRange,
+ Point aUpperLeft,
+ Size aExtent,
+ String sChartServiceName )
+ {
+ XChartDocument aResult = null;
+ XTableChartsSupplier aSheet;
+
+ // get the sheet to insert the chart
+ try
+ {
+ aSheet = UnoRuntime.queryInterface(
+ XTableChartsSupplier.class, getChartSheet() );
+ }
+ catch( Exception ex )
+ {
+ System.out.println( "Sheet not found" + ex );
+ return aResult;
+ }
+
+ XTableCharts aChartCollection = aSheet.getCharts();
+ XNameAccess aChartCollectionNA = UnoRuntime.queryInterface(
+ XNameAccess.class, aChartCollection );
+
+ if( aChartCollectionNA != null &&
+ ! aChartCollectionNA.hasByName( sChartName ) )
+ {
+ Rectangle aRect = new Rectangle( aUpperLeft.X, aUpperLeft.Y, aExtent.Width, aExtent.Height );
+
+ CellRangeAddress[] aAddresses = new CellRangeAddress[ 1 ];
+ aAddresses[ 0 ] = aRange;
+
+ // first bool: ColumnHeaders
+ // second bool: RowHeaders
+ aChartCollection.addNewByName( sChartName, aRect, aAddresses, true, false );
+
+ try
+ {
+ XTableChart aTableChart = UnoRuntime.queryInterface(
+ XTableChart.class, aChartCollectionNA.getByName( sChartName ));
+
+ // the table chart is an embedded object which contains the chart document
+ aResult = UnoRuntime.queryInterface(
+ XChartDocument.class,
+ UnoRuntime.queryInterface(
+ XEmbeddedObjectSupplier.class,
+ aTableChart ).getEmbeddedObject());
+
+ // create a diagram via the factory and set this as new diagram
+ aResult.setDiagram(
+ UnoRuntime.queryInterface(
+ XDiagram.class,
+ UnoRuntime.queryInterface(
+ XMultiServiceFactory.class,
+ aResult ).createInstance( sChartServiceName )));
+ }
+ catch( NoSuchElementException ex )
+ {
+ System.out.println( "Couldn't find chart with name " + sChartName + ": " + ex );
+ }
+ catch( Exception ex )
+ {}
+ }
+
+ return aResult;
+ }
+
+
+
+ /** Fill a rectangular range with random numbers.
+ The first column has increasing values
+ */
+ public XCellRange insertRandomRange( int nColumnCount, int nRowCount )
+ {
+ XCellRange aRange = null;
+
+ // get the sheet to insert the chart
+ try
+ {
+ XSpreadsheet aSheet = getDataSheet();
+ XCellRange aSheetRange = UnoRuntime.queryInterface( XCellRange.class, aSheet );
+
+ aRange = aSheetRange.getCellRangeByPosition(
+ 0, 0,
+ nColumnCount - 1, nRowCount - 1 );
+
+ int nCol, nRow;
+ double fBase = 0.0;
+ double fRange = 10.0;
+ double fValue;
+ Random aGenerator = new Random();
+
+
+ for( nCol = 0; nCol < nColumnCount; nCol++ )
+ {
+ if( 0 == nCol )
+ {
+ (aSheet.getCellByPosition( nCol, 0 )).setFormula( "X" );
+ }
+ else
+ {
+ (aSheet.getCellByPosition( nCol, 0 )).setFormula( "Random " + nCol );
+ }
+
+ for( nRow = 1; nRow < nRowCount; nRow++ )
+ {
+ if( 0 == nCol )
+ {
+ // x values: ascending numbers
+ fValue = nRow + aGenerator.nextDouble();
+ }
+ else
+ {
+ fValue = fBase + ( aGenerator.nextGaussian() * fRange );
+ }
+
+ // put value into cell
+
+ // note: getCellByPosition is a method at ...table.XCellRange which
+ // the XSpreadsheet inherits via ...sheet.XSheetCellRange
+ (aSheet.getCellByPosition( nCol, nRow )).setValue( fValue );
+ }
+ }
+
+ }
+ catch( Exception ex )
+ {
+ System.out.println( "Sheet not found" + ex );
+ }
+
+ return aRange;
+ }
+
+
+
+ public XCellRange insertFormulaRange( int nColumnCount, int nRowCount )
+ {
+ XCellRange aRange = null;
+
+ // get the sheet to insert the chart
+ try
+ {
+ XSpreadsheet aSheet = getDataSheet();
+ XCellRange aSheetRange = UnoRuntime.queryInterface( XCellRange.class, aSheet );
+
+ aRange = aSheetRange.getCellRangeByPosition(
+ 0, 0,
+ nColumnCount - 1, nRowCount - 1 );
+
+ int nCol, nRow;
+ double fValue;
+ double fFactor = 2.0 * Math.PI / (nRowCount - 1);
+ String aFormula;
+
+ // set variable factor for cos formula
+ int nFactorCol = nColumnCount + 2;
+ (aSheet.getCellByPosition( nFactorCol - 1, 0 )).setValue( 0.2 );
+
+ XText xCellText = UnoRuntime.queryInterface( XText.class, aSheet.getCellByPosition( nFactorCol - 1, 1 ) );
+ xCellText.setString( "Change the factor above and\nwatch the changes in the chart" );
+
+ for( nCol = 0; nCol < nColumnCount; nCol++ )
+ {
+ for( nRow = 0; nRow < nRowCount; nRow++ )
+ {
+ if( 0 == nCol )
+ {
+ // x values: ascending numbers
+ fValue = nRow * fFactor;
+ (aSheet.getCellByPosition( nCol, nRow )).setValue( fValue );
+ }
+ else
+ {
+ aFormula = "=";
+ if( nCol % 2 == 0 )
+ aFormula += "SIN";
+ else
+ aFormula += "COS";
+ aFormula += "(INDIRECT(ADDRESS(" + (nRow + 1) + ";1)))+RAND()*INDIRECT(ADDRESS(1;" + nFactorCol + "))";
+ (aSheet.getCellByPosition( nCol, nRow )).setFormula( aFormula );
+ }
+ }
+ }
+
+ }
+ catch( Exception ex )
+ {
+ System.out.println( "Sheet not found" + ex );
+ }
+
+ return aRange;
+ }
+
+
+
+ /** Bring the sheet containing charts visually to the foreground
+ */
+ public void raiseChartSheet()
+ {
+ UnoRuntime.queryInterface(
+ XSpreadsheetView.class,
+ UnoRuntime.queryInterface(
+ XModel.class,
+ maSpreadSheetDoc ).getCurrentController()).setActiveSheet( getChartSheet() );
+ }
+
+
+ // __________ private members and methods __________
+
+ private static final String msDataSheetName = "Data";
+ private static final String msChartSheetName = "Chart";
+
+ private final XSpreadsheetDocument maSpreadSheetDoc;
+
+
+
+
+ /** create two sheets, one for data and one for charts in the document
+ */
+ private void initSpreadSheet()
+ {
+ if( maSpreadSheetDoc != null )
+ {
+ XSpreadsheets aSheets = maSpreadSheetDoc.getSheets();
+ XNameContainer aSheetsNC = UnoRuntime.queryInterface(
+ XNameContainer.class, aSheets );
+ XIndexAccess aSheetsIA = UnoRuntime.queryInterface(
+ XIndexAccess.class, aSheets );
+
+ if( aSheets != null &&
+ aSheetsNC != null &&
+ aSheetsIA != null )
+ {
+ try
+ {
+ // remove all sheets except one
+ for( int i = aSheetsIA.getCount() - 1; i > 0; i-- )
+ {
+ aSheetsNC.removeByName(
+ UnoRuntime.queryInterface(
+ XNamed.class, aSheetsIA.getByIndex( i ) ).getName() );
+ }
+
+ XNamed aFirstSheet = UnoRuntime.queryInterface(
+ XNamed.class,
+ aSheetsIA.getByIndex( 0 ));
+
+ // first sheet becomes data sheet
+ aFirstSheet.setName( msDataSheetName );
+
+ // second sheet becomes chart sheet
+ aSheets.insertNewByName( msChartSheetName, (short)1 );
+ }
+ catch( Exception ex )
+ {
+ System.out.println( "Couldn't initialize Spreadsheet Document: " + ex );
+ }
+ }
+ }
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/Charts/ChartHelper.java b/odk/examples/DevelopersGuide/Charts/ChartHelper.java
new file mode 100644
index 000000000..7263ea7ad
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Charts/ChartHelper.java
@@ -0,0 +1,244 @@
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+// __________ Imports __________
+
+
+// base graphics things
+import com.sun.star.awt.Point;
+import com.sun.star.awt.Size;
+import com.sun.star.beans.XPropertySet;
+// application specific classes
+import com.sun.star.chart.XChartDocument;
+import com.sun.star.chart.XDiagram;
+import com.sun.star.drawing.XDrawPageSupplier;
+import com.sun.star.drawing.XDrawPagesSupplier;
+import com.sun.star.drawing.XShape;
+import com.sun.star.drawing.XShapes;
+import com.sun.star.frame.XModel;
+// factory for creating components
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.text.XText;
+import com.sun.star.text.XTextContent;
+import com.sun.star.text.XTextCursor;
+import com.sun.star.text.XTextDocument;
+import com.sun.star.uno.Any;
+import com.sun.star.uno.Type;
+import com.sun.star.uno.UnoRuntime;
+
+// __________ Implementation __________
+
+// Helper for creating an OLE chart
+
+public class ChartHelper
+{
+ public ChartHelper( XModel aContainerDoc )
+ {
+ maContainerDocument = aContainerDoc;
+ }
+
+ public XChartDocument insertOLEChartInWriter(
+ Point aUpperLeft,
+ Size aExtent,
+ String sChartServiceName )
+ {
+ XChartDocument aResult = null;
+
+ XMultiServiceFactory aFact = UnoRuntime.queryInterface(XMultiServiceFactory.class,
+ maContainerDocument );
+
+ if( aFact != null )
+ {
+ try
+ {
+ XTextContent xTextContent = UnoRuntime.queryInterface(
+ XTextContent.class,
+ aFact.createInstance("com.sun.star.text.TextEmbeddedObject"));
+
+ if ( xTextContent != null )
+ {
+ XPropertySet xPropSet = UnoRuntime.queryInterface(
+ XPropertySet.class, xTextContent);
+
+ Any aAny = new Any(new Type(String.class), msChartClassID);
+ xPropSet.setPropertyValue("CLSID", aAny );
+
+ XTextDocument xTextDoc = UnoRuntime.queryInterface(XTextDocument.class,
+ maContainerDocument);
+ XText xText = xTextDoc.getText();
+ XTextCursor xCursor = xText.createTextCursor();
+
+ //insert embedded object in text -> object will be created
+ xText.insertTextContent( xCursor, xTextContent, true );
+
+ // set size and position
+ XShape xShape = UnoRuntime.queryInterface(
+ XShape.class, xTextContent);
+ xShape.setSize( aExtent );
+
+ aAny = new Any(new Type(Short.class),
+ Short.valueOf(com.sun.star.text.VertOrientation.NONE));
+ xPropSet.setPropertyValue("VertOrient", aAny );
+ aAny = new Any(new Type(Short.class),
+ Short.valueOf(com.sun.star.text.HoriOrientation.NONE));
+ xPropSet.setPropertyValue("HoriOrient", aAny );
+ aAny = new Any(new Type(Integer.class), Integer.valueOf(aUpperLeft.Y));
+ xPropSet.setPropertyValue("VertOrientPosition", aAny );
+ aAny = new Any(new Type(Integer.class), Integer.valueOf(aUpperLeft.X));
+ xPropSet.setPropertyValue("HoriOrientPosition", aAny );
+
+ // retrieve the chart document as model of the OLE shape
+ aResult = UnoRuntime.queryInterface(
+ XChartDocument.class,
+ xPropSet.getPropertyValue( "Model" ));
+
+ // create a diagram via the factory and set this as
+ // new diagram
+ aResult.setDiagram(
+ UnoRuntime.queryInterface(
+ XDiagram.class,
+ UnoRuntime.queryInterface(
+ XMultiServiceFactory.class,
+ aResult ).createInstance(sChartServiceName )));
+ }
+ } catch( Exception ex)
+ {
+ System.out.println( "caught exception: " + ex );
+ }
+ }
+
+ return aResult;
+ }
+
+ public XChartDocument insertOLEChartInDraw(
+ Point aUpperLeft,
+ Size aExtent,
+ String sChartServiceName )
+ {
+ XChartDocument aResult = null;
+
+ XShapes aPage = null;
+
+ // try interface for multiple pages in a document
+ XDrawPagesSupplier aSupplier = UnoRuntime.queryInterface(XDrawPagesSupplier.class,
+ maContainerDocument );
+
+ if( aSupplier != null )
+ {
+ try
+ {
+ // get first page
+ aPage = UnoRuntime.queryInterface(
+ XShapes.class, aSupplier.getDrawPages().getByIndex( 0 ) );
+ }
+ catch( Exception ex )
+ {
+ System.out.println( "First page not found in shape collection: " +
+ ex );
+ }
+ }
+ else
+ {
+ // try interface for single draw page (e.g. spreadsheet)
+ XDrawPageSupplier aOnePageSupplier = UnoRuntime.queryInterface(XDrawPageSupplier.class,
+ maContainerDocument );
+
+ if( aOnePageSupplier != null )
+ {
+ aPage = UnoRuntime.queryInterface(
+ XShapes.class, aOnePageSupplier.getDrawPage());
+ }
+ }
+
+ if( aPage != null )
+ {
+ XMultiServiceFactory aFact = UnoRuntime.queryInterface(XMultiServiceFactory.class,
+ maContainerDocument );
+
+ if( aFact != null )
+ {
+ try
+ {
+ // create an OLE shape
+ XShape aShape = UnoRuntime.queryInterface(
+ XShape.class,
+ aFact.createInstance( "com.sun.star.drawing.OLE2Shape" ));
+
+ // insert the shape into the page
+ aPage.add( aShape );
+ aShape.setPosition( aUpperLeft );
+ aShape.setSize( aExtent );
+
+ // make the OLE shape a chart
+ XPropertySet aShapeProp = UnoRuntime.queryInterface(XPropertySet.class, aShape );
+ if( aShapeProp != null )
+ {
+ // set the class id for charts
+ aShapeProp.setPropertyValue( "CLSID", msChartClassID );
+
+ // retrieve the chart document as model of the OLE shape
+ aResult = UnoRuntime.queryInterface(
+ XChartDocument.class,
+ aShapeProp.getPropertyValue( "Model" ));
+
+ // create a diagram via the factory and set this as
+ // new diagram
+ aResult.setDiagram(
+ UnoRuntime.queryInterface(
+ XDiagram.class,
+ UnoRuntime.queryInterface(
+ XMultiServiceFactory.class,
+ aResult ).createInstance(sChartServiceName )));
+ }
+ }
+ catch( Exception ex )
+ {
+ System.out.println( "Couldn't change the OLE shape into a chart: " + ex );
+ }
+ }
+ }
+
+ return aResult;
+ }
+
+
+ // __________ private members and methods __________
+
+ private static final String msChartClassID = "12dcae26-281f-416f-a234-c3086127382e";
+
+ private final XModel maContainerDocument;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/Charts/ChartInCalc.java b/odk/examples/DevelopersGuide/Charts/ChartInCalc.java
new file mode 100644
index 000000000..d974d6e45
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Charts/ChartInCalc.java
@@ -0,0 +1,417 @@
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+// __________ Imports __________
+
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.lang.*;
+
+// property access
+import com.sun.star.beans.*;
+
+// application specific classes
+import com.sun.star.chart.*;
+import com.sun.star.drawing.*;
+
+import com.sun.star.table.CellRangeAddress;
+import com.sun.star.table.XCellRange;
+import com.sun.star.sheet.XCellRangeAddressable;
+
+import com.sun.star.frame.XModel;
+import com.sun.star.util.XNumberFormatsSupplier;
+import com.sun.star.util.XNumberFormats;
+
+// base graphics things
+import com.sun.star.awt.Point;
+import com.sun.star.awt.Size;
+import com.sun.star.awt.FontWeight;
+// Exceptions
+import com.sun.star.uno.Exception;
+import com.sun.star.uno.RuntimeException;
+import com.sun.star.beans.UnknownPropertyException;
+import com.sun.star.lang.IndexOutOfBoundsException;
+import com.sun.star.util.MalformedNumberFormatException;
+
+
+// __________ Implementation __________
+
+// Create a spreadsheet add some data and add a chart
+
+public class ChartInCalc
+{
+
+
+ public static void main( String args[] )
+ {
+ Helper aHelper = new Helper( args );
+
+ CalcHelper aCalcHelper = new CalcHelper( aHelper.createSpreadsheetDocument() );
+
+ // insert a cell range with 4 columns and 24 rows filled with random numbers
+ XCellRange aRange = aCalcHelper.insertRandomRange( 4, 24 );
+ CellRangeAddress aRangeAddress = UnoRuntime.queryInterface(
+ XCellRangeAddressable.class, aRange).getRangeAddress();
+
+ // change view to sheet containing the chart
+ aCalcHelper.raiseChartSheet();
+
+ // the unit for measures is 1/100th of a millimeter
+ // position at (1cm, 1cm)
+ Point aPos = new Point( 1000, 1000 );
+
+ // size of the chart is 15cm x 9.271cm
+ Size aExtent = new Size( 15000, 9271 );
+
+ // insert a new chart into the "Chart" sheet of the
+ // spreadsheet document
+ XChartDocument aChartDoc = aCalcHelper.insertChart(
+ "ScatterChart",
+ aRangeAddress,
+ aPos,
+ aExtent,
+ "com.sun.star.chart.XYDiagram" );
+
+ // instantiate test class with newly created chart
+ ChartInCalc aTest = new ChartInCalc( aChartDoc );
+
+ try
+ {
+ aTest.lockControllers();
+
+ aTest.testDiagram();
+ aTest.testArea();
+ aTest.testWall();
+ aTest.testTitle();
+ aTest.testAxis();
+ aTest.testGrid();
+
+ // show an intermediate state, ...
+ aTest.unlockControllers();
+ aTest.lockControllers();
+
+ // ..., because the following takes a while:
+ // an internet URL has to be resolved
+ aTest.testDataRowProperties();
+ aTest.testDataPointProperties();
+
+ aTest.unlockControllers();
+ }
+ catch( Exception ex )
+ {
+ System.out.println( "UNO Exception caught: " + ex );
+ System.out.println( "Message: " + ex.getMessage() );
+ }
+
+ System.exit( 0 );
+ }
+
+
+
+
+ public ChartInCalc( XChartDocument aChartDoc )
+ {
+ maChartDocument = aChartDoc;
+ maDiagram = maChartDocument.getDiagram();
+ }
+
+
+
+ public void lockControllers()
+ throws RuntimeException
+ {
+ UnoRuntime.queryInterface( XModel.class, maChartDocument ).lockControllers();
+ }
+
+
+
+ public void unlockControllers()
+ throws RuntimeException
+ {
+ UnoRuntime.queryInterface( XModel.class, maChartDocument ).unlockControllers();
+ }
+
+
+
+ public void testDiagram()
+ throws RuntimeException, UnknownPropertyException, PropertyVetoException,
+ com.sun.star.lang.IllegalArgumentException, WrappedTargetException
+ {
+ XPropertySet aDiaProp = UnoRuntime.queryInterface( XPropertySet.class, maDiagram );
+
+ if( aDiaProp != null )
+ {
+ // change chart type
+ aDiaProp.setPropertyValue( "Lines", Boolean.TRUE);
+
+ // change attributes for all series
+ // set line width to 0.5mm
+ aDiaProp.setPropertyValue( "LineWidth", Integer.valueOf( 50 ));
+ }
+ }
+
+
+
+ public void testDataRowProperties()
+ throws RuntimeException, UnknownPropertyException, PropertyVetoException,
+ com.sun.star.lang.IllegalArgumentException, WrappedTargetException
+ {
+ // change properties of the data series
+ try
+ {
+ XPropertySet aSeriesProp;
+ for( int i = 1; i <= 3; i++ )
+ {
+ aSeriesProp = maDiagram.getDataRowProperties( i );
+ aSeriesProp.setPropertyValue( "LineColor", Integer.valueOf(
+ 0x400000 * i +
+ 0x005000 * i +
+ 0x0000ff - 0x40 * i ));
+ if( 1 == i )
+ {
+ StringBuffer sUrl = new StringBuffer("file:///");
+ try {
+ /* for use without net it's easier to load a local graphic */
+ java.io.File sourceFile = new java.io.File("bullet.gif");
+ sUrl.append(sourceFile.getCanonicalPath().replace('\\', '/'));
+ } catch (java.io.IOException e) {
+ sUrl = new StringBuffer("http://graphics.openoffice.org/chart/bullet1.gif");
+ }
+
+ // set a bitmap via URL as symbol for the first series
+ aSeriesProp.setPropertyValue( "SymbolType", Integer.valueOf( ChartSymbolType.BITMAPURL ));
+ aSeriesProp.setPropertyValue( "SymbolBitmapURL", sUrl.toString() );
+ }
+ else
+ {
+ aSeriesProp.setPropertyValue( "SymbolType", Integer.valueOf( ChartSymbolType.SYMBOL1 ));
+ aSeriesProp.setPropertyValue( "SymbolSize", new Size( 250, 250 ));
+ }
+ }
+ }
+ catch( IndexOutOfBoundsException ex )
+ {
+ System.out.println( "Oops, there not enough series for setting properties: " + ex );
+ }
+ }
+
+
+
+ public void testDataPointProperties()
+ throws RuntimeException, UnknownPropertyException, PropertyVetoException,
+ com.sun.star.lang.IllegalArgumentException, WrappedTargetException
+ {
+ // set properties for a single data point
+ try
+ {
+ // determine the maximum value of the first series
+
+ XChartDataArray aDataArray = UnoRuntime.queryInterface(
+ XChartDataArray.class, maChartDocument.getData());
+ double aData[][] = aDataArray.getData();
+
+ int i;
+ double fMax = aData[ 0 ][ 1 ];
+ for( i = 1; i < aData.length; i++ )
+ {
+ if( aData[ i ][ 1 ] > fMax )
+ {
+ fMax = aData[ i ][ 1 ];
+ }
+ }
+
+ // first parameter is the index of the point, the second one is the series
+ XPropertySet aPointProp = maDiagram.getDataPointProperties( 0, 1 );
+
+ // set a different, larger symbol
+ aPointProp.setPropertyValue( "SymbolType", Integer.valueOf( ChartSymbolType.SYMBOL6 ));
+ aPointProp.setPropertyValue( "SymbolSize", new Size( 600, 600 ));
+
+ // add a label text with bold font, bordeaux red 14pt
+ aPointProp.setPropertyValue( "DataCaption", Integer.valueOf( ChartDataCaption.VALUE ));
+ aPointProp.setPropertyValue( "CharHeight", new Float( 14.0 ));
+ aPointProp.setPropertyValue( "CharColor", Integer.valueOf( 0x993366 ));
+ aPointProp.setPropertyValue( "CharWeight", new Float( FontWeight.BOLD ));
+ }
+ catch( IndexOutOfBoundsException ex )
+ {
+ System.out.println( "Oops, there not enough data points or series for setting properties: " + ex );
+ }
+ }
+
+
+
+ public void testArea()
+ throws RuntimeException, UnknownPropertyException, PropertyVetoException,
+ com.sun.star.lang.IllegalArgumentException, WrappedTargetException
+ {
+ XPropertySet aArea = maChartDocument.getArea();
+
+ if( aArea != null )
+ {
+ // change background color of entire chart
+ aArea.setPropertyValue( "FillStyle", FillStyle.SOLID );
+ aArea.setPropertyValue( "FillColor", Integer.valueOf( 0xeeeeee ));
+ }
+ }
+
+
+
+ public void testWall()
+ throws RuntimeException, UnknownPropertyException, PropertyVetoException,
+ com.sun.star.lang.IllegalArgumentException, WrappedTargetException
+ {
+ XPropertySet aWall = UnoRuntime.queryInterface(
+ X3DDisplay.class, maDiagram ).getWall();
+
+ // change background color of area
+ aWall.setPropertyValue( "FillStyle", FillStyle.SOLID );
+ aWall.setPropertyValue( "FillColor", Integer.valueOf( 0xcccccc ));
+ }
+
+
+
+ public void testTitle()
+ throws RuntimeException, UnknownPropertyException, PropertyVetoException,
+ com.sun.star.lang.IllegalArgumentException, WrappedTargetException
+ {
+ // change main title
+ XPropertySet aDocProp = UnoRuntime.queryInterface(
+ XPropertySet.class, maChartDocument );
+ aDocProp.setPropertyValue( "HasMainTitle", Boolean.TRUE);
+
+ XShape aTitle = maChartDocument.getTitle();
+ XPropertySet aTitleProp = UnoRuntime.queryInterface( XPropertySet.class, aTitle );
+
+ // set new text
+ if( aTitleProp != null )
+ {
+ aTitleProp.setPropertyValue( "String", "Random Scatter Chart" );
+ aTitleProp.setPropertyValue( "CharHeight", new Float(14.0) );
+ }
+
+ // align title with y axis
+ XShape aAxis = UnoRuntime.queryInterface(
+ XShape.class, UnoRuntime.queryInterface(
+ XAxisYSupplier.class, maDiagram ).getYAxis() );
+
+ if( aAxis != null &&
+ aTitle != null )
+ {
+ Point aPos = aTitle.getPosition();
+ aPos.X = ( aAxis.getPosition() ).X;
+ aTitle.setPosition( aPos );
+ }
+ }
+
+
+
+ public void testAxis()
+ throws RuntimeException, UnknownPropertyException, PropertyVetoException,
+ com.sun.star.lang.IllegalArgumentException, WrappedTargetException,
+ MalformedNumberFormatException
+ {
+ // x axis
+ XPropertySet aAxisProp = UnoRuntime.queryInterface(
+ XAxisXSupplier.class, maDiagram ).getXAxis();
+ if( aAxisProp != null )
+ {
+ aAxisProp.setPropertyValue( "Max", Integer.valueOf( 24 ));
+ aAxisProp.setPropertyValue( "StepMain", Integer.valueOf( 3 ));
+ }
+
+ // change number format for y axis
+ aAxisProp = UnoRuntime.queryInterface(
+ XAxisYSupplier.class, maDiagram ).getYAxis();
+
+ // add a new custom number format and get the new key
+ int nNewNumberFormat = 0;
+ XNumberFormatsSupplier aNumFmtSupp = UnoRuntime.queryInterface(
+ XNumberFormatsSupplier.class, maChartDocument );
+
+ if( aNumFmtSupp != null )
+ {
+ XNumberFormats aFormats = aNumFmtSupp.getNumberFormats();
+ Locale aLocale = new Locale( "de", "DE", "de" );
+
+ String aFormatStr = aFormats.generateFormat( nNewNumberFormat, aLocale, true, true, (short)3, (short)1 );
+ nNewNumberFormat = aFormats.addNew( aFormatStr, aLocale );
+ }
+
+ if( aAxisProp != null )
+ {
+ aAxisProp.setPropertyValue( "NumberFormat", Integer.valueOf( nNewNumberFormat ));
+ }
+ }
+
+
+
+ public void testGrid()
+ throws RuntimeException, UnknownPropertyException, PropertyVetoException,
+ com.sun.star.lang.IllegalArgumentException, WrappedTargetException
+ {
+ // y major grid
+ XPropertySet aGridProp = UnoRuntime.queryInterface(
+ XPropertySet.class,
+ UnoRuntime.queryInterface(
+ XAxisYSupplier.class, maDiagram ).getYMainGrid());
+
+ if( aGridProp != null )
+ {
+ LineDash aDash = new LineDash();
+ aDash.Style = DashStyle.ROUND;
+ aDash.Dots = 2;
+ aDash.DotLen = 10;
+ aDash.Dashes = 1;
+ aDash.DashLen = 200;
+ aDash.Distance = 100;
+
+ aGridProp.setPropertyValue( "LineColor", Integer.valueOf( 0x999999 ));
+ aGridProp.setPropertyValue( "LineStyle", LineStyle.DASH );
+ aGridProp.setPropertyValue( "LineDash", aDash );
+ aGridProp.setPropertyValue( "LineWidth", Integer.valueOf( 30 ));
+ }
+ }
+
+
+
+
+ // private members
+
+
+ private final XChartDocument maChartDocument;
+ private final XDiagram maDiagram;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/Charts/ChartInDraw.java b/odk/examples/DevelopersGuide/Charts/ChartInDraw.java
new file mode 100644
index 000000000..d13b6d07f
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Charts/ChartInDraw.java
@@ -0,0 +1,294 @@
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+// __________ Imports __________
+
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.lang.*;
+
+// property access
+import com.sun.star.beans.*;
+
+// application specific classes
+import com.sun.star.chart.*;
+import com.sun.star.drawing.*;
+
+import com.sun.star.frame.XModel;
+// base graphics things
+import com.sun.star.awt.Point;
+import com.sun.star.awt.Size;
+// Exceptions
+import com.sun.star.uno.Exception;
+import com.sun.star.uno.RuntimeException;
+import com.sun.star.beans.UnknownPropertyException;
+
+
+// __________ Implementation __________
+
+// Create a spreadsheet add some data and add a chart
+
+public class ChartInDraw
+{
+
+
+ public static void main( String args[] )
+ {
+ Helper aHelper = new Helper( args );
+
+ ChartHelper aChartHelper = new ChartHelper( aHelper.createDrawingDocument());
+
+ // the unit for measures is 1/100th of a millimeter
+ // position at (1cm, 1cm)
+ Point aPos = new Point( 1000, 1000 );
+
+ // size of the chart is 15cm x 12cm
+ Size aExtent = new Size( 15000, 13000 );
+
+ // insert a new chart into the "Chart" sheet of the
+ // spreadsheet document
+ XChartDocument aChartDoc = aChartHelper.insertOLEChartInDraw(
+ aPos,
+ aExtent,
+ "com.sun.star.chart.BarDiagram" );
+
+ // instantiate test class with newly created chart
+ ChartInDraw aTest = new ChartInDraw( aChartDoc );
+
+ try
+ {
+ aTest.lockControllers();
+
+ aTest.testArea();
+ aTest.testWall();
+ aTest.testTitle();
+ aTest.testLegend();
+ aTest.testThreeD();
+
+ aTest.unlockControllers();
+ }
+ catch( Exception ex )
+ {
+ System.out.println( "UNO Exception caught: " + ex );
+ System.out.println( "Message: " + ex.getMessage() );
+ }
+
+ System.exit( 0 );
+ }
+
+
+
+
+ public ChartInDraw( XChartDocument aChartDoc )
+ {
+ maChartDocument = aChartDoc;
+ maDiagram = maChartDocument.getDiagram();
+ }
+
+
+
+ public void lockControllers()
+ throws RuntimeException
+ {
+ UnoRuntime.queryInterface( XModel.class, maChartDocument ).lockControllers();
+ }
+
+
+
+ public void unlockControllers()
+ throws RuntimeException
+ {
+ UnoRuntime.queryInterface( XModel.class, maChartDocument ).unlockControllers();
+ }
+
+
+
+ public void testArea()
+ throws RuntimeException, UnknownPropertyException, PropertyVetoException,
+ com.sun.star.lang.IllegalArgumentException, WrappedTargetException
+ {
+ XPropertySet aArea = maChartDocument.getArea();
+
+ if( aArea != null )
+ {
+ // change background color of entire chart
+ aArea.setPropertyValue( "FillStyle", FillStyle.SOLID );
+ aArea.setPropertyValue( "FillColor", Integer.valueOf( 0xeeeeee ));
+ }
+ }
+
+
+
+ public void testWall()
+ throws RuntimeException, UnknownPropertyException, PropertyVetoException,
+ com.sun.star.lang.IllegalArgumentException, WrappedTargetException
+ {
+ XPropertySet aWall = UnoRuntime.queryInterface(
+ X3DDisplay.class, maDiagram ).getWall();
+
+ // change background color of area
+ aWall.setPropertyValue( "FillColor", Integer.valueOf( 0xcccccc ));
+ aWall.setPropertyValue( "FillStyle", FillStyle.SOLID );
+ }
+
+
+
+ public void testTitle()
+ throws RuntimeException, UnknownPropertyException, PropertyVetoException,
+ com.sun.star.lang.IllegalArgumentException, WrappedTargetException
+ {
+ // change main title
+ XPropertySet aDocProp = UnoRuntime.queryInterface(
+ XPropertySet.class, maChartDocument );
+ aDocProp.setPropertyValue( "HasMainTitle", Boolean.TRUE);
+
+ XShape aTitle = maChartDocument.getTitle();
+ XPropertySet aTitleProp = UnoRuntime.queryInterface( XPropertySet.class, aTitle );
+
+ // set new text
+ if( aTitleProp != null )
+ {
+ aTitleProp.setPropertyValue( "String", "Bar Chart in a Draw Document" );
+ }
+ }
+
+
+
+ public void testLegend()
+ throws RuntimeException, UnknownPropertyException, PropertyVetoException,
+ com.sun.star.lang.IllegalArgumentException, WrappedTargetException
+ {
+ XShape aLegend = maChartDocument.getLegend();
+ XPropertySet aLegendProp = UnoRuntime.queryInterface( XPropertySet.class, aLegend );
+
+ aLegendProp.setPropertyValue( "Alignment", ChartLegendPosition.LEFT );
+ aLegendProp.setPropertyValue( "FillStyle", FillStyle.SOLID );
+ aLegendProp.setPropertyValue( "FillColor", Integer.valueOf( 0xeeddee ));
+ }
+
+
+
+ public void testThreeD()
+ throws RuntimeException, UnknownPropertyException, PropertyVetoException,
+ com.sun.star.lang.IllegalArgumentException, WrappedTargetException
+ {
+ XPropertySet aDiaProp = UnoRuntime.queryInterface( XPropertySet.class, maDiagram );
+ Boolean aTrue = Boolean.TRUE;
+
+ aDiaProp.setPropertyValue( "Dim3D", aTrue );
+ aDiaProp.setPropertyValue( "Deep", aTrue );
+ // from Chart3DBarProperties:
+ aDiaProp.setPropertyValue( "SolidType", Integer.valueOf( ChartSolidType.CYLINDER ));
+
+ // change floor color to Magenta6
+ XPropertySet aFloor = UnoRuntime.queryInterface(
+ X3DDisplay.class, maDiagram ).getFloor();
+ aFloor.setPropertyValue( "FillColor", Integer.valueOf( 0x6b2394 ));
+
+ // apply changes to get a 3d scene
+ unlockControllers();
+ lockControllers();
+
+
+ // rotate scene to a different angle
+ HomogenMatrix aMatrix = new HomogenMatrix();
+ HomogenMatrixLine aLines[] = new HomogenMatrixLine[]
+ {
+ new HomogenMatrixLine( 1.0, 0.0, 0.0, 0.0 ),
+ new HomogenMatrixLine( 0.0, 1.0, 0.0, 0.0 ),
+ new HomogenMatrixLine( 0.0, 0.0, 1.0, 0.0 ),
+ new HomogenMatrixLine( 0.0, 0.0, 0.0, 1.0 )
+ };
+
+ aMatrix.Line1 = aLines[ 0 ];
+ aMatrix.Line2 = aLines[ 1 ];
+ aMatrix.Line3 = aLines[ 2 ];
+ aMatrix.Line4 = aLines[ 3 ];
+
+ // rotate 10 degrees along the x axis
+ double fAngle = 10.0;
+ double fCosX = Math.cos( Math.PI / 180.0 * fAngle );
+ double fSinX = Math.sin( Math.PI / 180.0 * fAngle );
+
+ // rotate -20 degrees along the y axis
+ fAngle = -20.0;
+ double fCosY = Math.cos( Math.PI / 180.0 * fAngle );
+ double fSinY = Math.sin( Math.PI / 180.0 * fAngle );
+
+ // rotate -5 degrees along the z axis
+ fAngle = -5.0;
+ double fCosZ = Math.cos( Math.PI / 180.0 * fAngle );
+ double fSinZ = Math.sin( Math.PI / 180.0 * fAngle );
+
+ aMatrix.Line1.Column1 = fCosY * fCosZ;
+ aMatrix.Line1.Column2 = fCosY * -fSinZ;
+ aMatrix.Line1.Column3 = fSinY;
+
+ aMatrix.Line2.Column1 = fSinX * fSinY * fCosZ + fCosX * fSinZ;
+ aMatrix.Line2.Column2 = -fSinX * fSinY * fSinZ + fCosX * fCosZ;
+ aMatrix.Line2.Column3 = -fSinX * fCosY;
+
+ aMatrix.Line3.Column1 = -fCosX * fSinY * fCosZ + fSinX * fSinZ;
+ aMatrix.Line3.Column2 = fCosX * fSinY * fSinZ + fSinX * fCosZ;
+ aMatrix.Line3.Column3 = fCosX * fCosY;
+
+ aDiaProp.setPropertyValue( "D3DTransformMatrix", aMatrix );
+
+ // add a red light source
+
+ // in a chart by default only the second (non-specular) light source is switched on
+ // light source 1 is a specular light source
+ aDiaProp.setPropertyValue( "D3DSceneLightColor1", Integer.valueOf( 0xff3333 ));
+
+ // set direction
+ com.sun.star.drawing.Direction3D aDirection = new com.sun.star.drawing.Direction3D();
+
+ aDirection.DirectionX = -0.75;
+ aDirection.DirectionY = 0.5;
+ aDirection.DirectionZ = 0.5;
+
+ aDiaProp.setPropertyValue( "D3DSceneLightDirection1", aDirection );
+ aDiaProp.setPropertyValue( "D3DSceneLightOn1", Boolean.TRUE);
+ }
+
+
+
+ // private members
+
+
+ private final XChartDocument maChartDocument;
+ private final XDiagram maDiagram;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/Charts/ChartInWriter.java b/odk/examples/DevelopersGuide/Charts/ChartInWriter.java
new file mode 100644
index 000000000..b84404d8b
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Charts/ChartInWriter.java
@@ -0,0 +1,163 @@
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+// __________ Imports __________
+
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.lang.*;
+
+// property access
+import com.sun.star.beans.*;
+
+// application specific classes
+import com.sun.star.chart.*;
+import com.sun.star.drawing.*;
+import com.sun.star.frame.XModel;
+// base graphics things
+import com.sun.star.awt.Point;
+import com.sun.star.awt.Size;
+// Exceptions
+import com.sun.star.uno.Exception;
+import com.sun.star.uno.RuntimeException;
+import com.sun.star.beans.UnknownPropertyException;
+
+
+// __________ Implementation __________
+
+/** Test to create a writer document and insert an OLE Chart.
+
+ Be careful! This does not really work. The Writer currently has no
+ interface for dealing with OLE objects. You can add an OLE shape to the
+ Writer's drawing layer, but it is not treated correctly as OLE object.
+ Thus, you can not activate the chart by double-clicking. The office may
+ also crash when the document is closed!
+
+ */
+public class ChartInWriter
+{
+
+
+ public static void main( String args[] )
+ {
+ Helper aHelper = new Helper( args );
+
+ ChartHelper aChartHelper = new ChartHelper(
+ UnoRuntime.queryInterface( XModel.class,
+ aHelper.createTextDocument()));
+
+ // the unit for measures is 1/100th of a millimeter
+ // position at (1cm, 1cm)
+ Point aPos = new Point( 1000, 1000 );
+
+ // size of the chart is 15cm x 12cm
+ Size aExtent = new Size( 15000, 13000 );
+
+ // insert a new chart into the "Chart" sheet of the
+ // spreadsheet document
+ XChartDocument aChartDoc = aChartHelper.insertOLEChartInWriter(
+ aPos,
+ aExtent,
+ "com.sun.star.chart.AreaDiagram" );
+
+ // instantiate test class with newly created chart
+ ChartInWriter aTest = new ChartInWriter( aChartDoc );
+
+ try
+ {
+ aTest.lockControllers();
+
+ // do tests here
+ aTest.testWall();
+
+ aTest.unlockControllers();
+ }
+ catch( Exception ex )
+ {
+ System.out.println( "UNO Exception caught: " + ex );
+ System.out.println( "Message: " + ex.getMessage() );
+ }
+
+ System.exit( 0 );
+ }
+
+
+
+
+ public ChartInWriter( XChartDocument aChartDoc )
+ {
+ maChartDocument = aChartDoc;
+ maDiagram = maChartDocument.getDiagram();
+ }
+
+
+
+ public void lockControllers()
+ throws RuntimeException
+ {
+ UnoRuntime.queryInterface( XModel.class, maChartDocument ).lockControllers();
+ }
+
+
+
+ public void unlockControllers()
+ throws RuntimeException
+ {
+ UnoRuntime.queryInterface( XModel.class, maChartDocument ).unlockControllers();
+ }
+
+
+
+ public void testWall()
+ throws RuntimeException, UnknownPropertyException, PropertyVetoException,
+ com.sun.star.lang.IllegalArgumentException, WrappedTargetException
+ {
+ XPropertySet aWall = UnoRuntime.queryInterface(
+ X3DDisplay.class, maDiagram ).getWall();
+
+ // change background color of area
+ aWall.setPropertyValue( "FillColor", Integer.valueOf( 0xeecc99 ));
+ aWall.setPropertyValue( "FillStyle", FillStyle.SOLID );
+ }
+
+
+
+ // private members
+
+
+ private final XChartDocument maChartDocument;
+ private final XDiagram maDiagram;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/Charts/Helper.java b/odk/examples/DevelopersGuide/Charts/Helper.java
new file mode 100644
index 000000000..ef1faccbc
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Charts/Helper.java
@@ -0,0 +1,141 @@
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+// __________ Imports __________
+
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.XComponentContext;
+import com.sun.star.lang.*;
+
+import com.sun.star.frame.XComponentLoader;
+
+// property access
+import com.sun.star.beans.*;
+
+// application specific classes
+import com.sun.star.sheet.XSpreadsheetDocument;
+import com.sun.star.frame.XModel;
+
+// __________ Implementation __________
+
+// Helper for creating a calc document adding cell values and charts
+
+public class Helper
+{
+ public Helper( String[] args )
+ {
+ // connect to a running office and get the ServiceManager
+ try {
+ // get the remote office component context
+ maContext = com.sun.star.comp.helper.Bootstrap.bootstrap();
+ System.out.println("Connected to a running office ...");
+
+ // get the remote office service manager
+ maMCFactory = maContext.getServiceManager();
+ }
+ catch( Exception e) {
+ System.out.println( "Couldn't get ServiceManager: " + e );
+ e.printStackTrace();
+ System.exit(1);
+ }
+ }
+
+
+
+ public XSpreadsheetDocument createSpreadsheetDocument()
+ {
+ return UnoRuntime.queryInterface(
+ XSpreadsheetDocument.class, createDocument( "scalc" ));
+ }
+
+
+
+
+
+
+
+ public XModel createDrawingDocument()
+ {
+ return createDocument( "sdraw" );
+ }
+
+
+
+ public XModel createTextDocument()
+ {
+ return createDocument( "swriter" );
+ }
+
+
+
+ private XModel createDocument( String sDocType )
+ {
+ XModel aResult = null;
+ try
+ {
+ XComponentLoader aLoader = UnoRuntime.queryInterface(XComponentLoader.class,
+ maMCFactory.createInstanceWithContext("com.sun.star.frame.Desktop",
+ maContext) );
+
+ aResult = UnoRuntime.queryInterface(
+ XModel.class,
+ aLoader.loadComponentFromURL( "private:factory/" + sDocType,
+ "_blank",
+ 0,
+ new PropertyValue[ 0 ] ) );
+ }
+ catch( Exception e )
+ {
+ System.err.println("Couldn't create Document of type "+ sDocType +": "+e);
+ e.printStackTrace();
+ System.exit( 0 );
+ }
+
+ return aResult;
+ }
+
+ public XComponentContext getComponentContext(){
+ return maContext;
+
+ }
+
+ // __________ private members and methods __________
+
+
+ private XComponentContext maContext;
+ private XMultiComponentFactory maMCFactory;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/Charts/JavaSampleChartAddIn.components b/odk/examples/DevelopersGuide/Charts/JavaSampleChartAddIn.components
new file mode 100644
index 000000000..e9a7baa48
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Charts/JavaSampleChartAddIn.components
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<components xmlns="http://openoffice.org/2010/uno-components">
+ <component loader="com.sun.star.loader.Java2" uri="JavaSampleChartAddIn.uno.jar">
+ <implementation name="JavaSampleChartAddIn">
+ <service name="com.sun.star.comp.Chart.JavaSampleChartAddIn"/>
+ <service name="com.sun.star.chart.Diagram"/>
+ <service name="com.sun.star.chart.ChartAxisYSupplier"/>
+ </implementation>
+ </component>
+</components>
diff --git a/odk/examples/DevelopersGuide/Charts/JavaSampleChartAddIn.java b/odk/examples/DevelopersGuide/Charts/JavaSampleChartAddIn.java
new file mode 100644
index 000000000..54a39d172
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Charts/JavaSampleChartAddIn.java
@@ -0,0 +1,449 @@
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.container.XIndexAccess;
+import com.sun.star.lib.uno.helper.WeakBase;
+
+// factories
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.lang.XSingleServiceFactory;
+
+// graphics stuff
+import com.sun.star.drawing.*;
+import com.sun.star.awt.Point;
+import com.sun.star.awt.Size;
+
+// chart stuff
+import com.sun.star.chart.*;
+
+// property access
+import com.sun.star.beans.*;
+
+// Add-In stuff
+import com.sun.star.lang.XInitialization;
+import com.sun.star.util.XRefreshable;
+import com.sun.star.lang.XServiceName;
+import com.sun.star.lang.XServiceInfo;
+// Exceptions
+import com.sun.star.uno.Exception;
+import com.sun.star.uno.RuntimeException;
+
+import javax.swing.JOptionPane;
+
+public class JavaSampleChartAddIn extends WeakBase implements
+ XInitialization,
+ XRefreshable,
+ XDiagram,
+ XServiceName,
+ XServiceInfo
+{
+
+ // __________ interface methods __________
+
+ // XInitialization
+ public void initialize( Object[] aArguments )
+ throws Exception, RuntimeException
+ {
+ if( aArguments.length > 0 )
+ {
+ maChartDocument = UnoRuntime.queryInterface(
+ XChartDocument.class, aArguments[ 0 ]);
+
+ XPropertySet aDocProp = UnoRuntime.queryInterface(
+ XPropertySet.class, maChartDocument );
+ if( aDocProp != null )
+ {
+ // set base diagram which will be extended in refresh()
+ aDocProp.setPropertyValue( "BaseDiagram", "com.sun.star.chart.XYDiagram" );
+ }
+
+ // get the draw page
+ XDrawPageSupplier aPageSupp = UnoRuntime.queryInterface(
+ XDrawPageSupplier.class, maChartDocument );
+ if( aPageSupp != null )
+ maDrawPage = UnoRuntime.queryInterface(
+ XDrawPage.class, aPageSupp.getDrawPage() );
+
+ // get a factory for creating shapes
+ maShapeFactory = UnoRuntime.queryInterface(
+ XMultiServiceFactory.class, maChartDocument );
+ }
+ }
+
+ // XRefreshable
+ public void refresh() throws RuntimeException
+ {
+ // recycle shapes in first call, if document was loaded
+ if( maBottomLine == null ||
+ maTopLine == null )
+ {
+ // try to recycle loaded shapes
+ XPropertySet aDocProp = UnoRuntime.queryInterface(
+ XPropertySet.class, maChartDocument );
+ if( aDocProp != null )
+ {
+ try
+ {
+ XIndexAccess aShapesIA = UnoRuntime.queryInterface(
+ XIndexAccess.class, aDocProp.getPropertyValue( "AdditionalShapes" ));
+ if( aShapesIA != null &&
+ aShapesIA.getCount() > 0 )
+ {
+ XShape aShape;
+ String aName;
+ for( int i = aShapesIA.getCount() - 1; i >= 0; --i )
+ {
+ aShape = UnoRuntime.queryInterface(
+ XShape.class, aShapesIA.getByIndex( i ));
+ if( aShape != null )
+ {
+ XPropertySet aProp = UnoRuntime.queryInterface(
+ XPropertySet.class, aShape );
+ aName = (String) aProp.getPropertyValue( "Name" );
+
+ if( aName.equals( "top" ))
+ {
+ maTopLine = aShape;
+ }
+ else if( aName.equals( "bottom" ))
+ {
+ maBottomLine = aShape;
+ }
+ }
+ }
+ }
+ }
+ catch( Exception ex )
+ {
+ JOptionPane.showMessageDialog( null, ex, "Exception caught", JOptionPane.WARNING_MESSAGE );
+ }
+ }
+ }
+
+ // create top line if it does not yet exist
+ try
+ {
+ if( maTopLine == null )
+ {
+ maTopLine = UnoRuntime.queryInterface(
+ XShape.class, maShapeFactory.createInstance( "com.sun.star.drawing.LineShape" ));
+ maDrawPage.add( maTopLine );
+
+ // make line red and thicker
+ XPropertySet aShapeProp = UnoRuntime.queryInterface(
+ XPropertySet.class, maTopLine );
+
+ aShapeProp.setPropertyValue( "LineColor", Integer.valueOf( 0xe01010 ));
+ aShapeProp.setPropertyValue( "LineWidth", Integer.valueOf( 50 ));
+ aShapeProp.setPropertyValue( "Name", "top" );
+ }
+ }
+ catch( Exception ex )
+ {
+ JOptionPane.showMessageDialog( null, ex, "Exception caught", JOptionPane.WARNING_MESSAGE );
+ }
+
+ // create bottom line if it does not yet exist
+ try
+ {
+ if( maBottomLine == null )
+ {
+ maBottomLine = UnoRuntime.queryInterface(
+ XShape.class, maShapeFactory.createInstance( "com.sun.star.drawing.LineShape" ));
+ maDrawPage.add( maBottomLine );
+
+ // make line green and thicker
+ XPropertySet aShapeProp = UnoRuntime.queryInterface(
+ XPropertySet.class, maBottomLine );
+
+ aShapeProp.setPropertyValue( "LineColor", Integer.valueOf( 0x10e010 ));
+ aShapeProp.setPropertyValue( "LineWidth", Integer.valueOf( 50 ));
+ aShapeProp.setPropertyValue( "Name", "bottom" );
+ }
+ }
+ catch( Exception ex )
+ {
+ JOptionPane.showMessageDialog( null, ex, "Exception caught", JOptionPane.WARNING_MESSAGE );
+ }
+
+ if( maTopLine == null ||
+ maBottomLine == null )
+ {
+ JOptionPane.showMessageDialog( null, "One of the lines is still null", "Assertion", JOptionPane.WARNING_MESSAGE );
+ return;
+ }
+
+ // position lines
+
+
+ // get data
+ XChartDataArray aDataArray = UnoRuntime.queryInterface(
+ XChartDataArray.class, maChartDocument.getData());
+ double aData[][] = aDataArray.getData();
+
+ // get axes
+ XDiagram aDiagram = maChartDocument.getDiagram();
+ XShape aXAxis = UnoRuntime.queryInterface(
+ XShape.class, UnoRuntime.queryInterface(
+ XAxisXSupplier.class, aDiagram ).getXAxis() );
+ XShape aYAxis = UnoRuntime.queryInterface(
+ XShape.class, UnoRuntime.queryInterface(
+ XAxisYSupplier.class, aDiagram ).getYAxis() );
+
+ // calculate points for hull
+ final int nLength = aData.length;
+ int i, j;
+ double fMax, fMin;
+
+ Point aMaxPtSeq[][] = new Point[ 1 ][];
+ aMaxPtSeq[ 0 ] = new Point[ nLength ];
+ Point aMinPtSeq[][] = new Point[ 1 ][];
+ aMinPtSeq[ 0 ] = new Point[ nLength ];
+
+ for( i = 0; i < nLength; i++ )
+ {
+ fMin = fMax = aData[ i ][ 1 ];
+ for( j = 1; j < aData[ i ].length; j++ )
+ {
+ if( aData[ i ][ j ] > fMax )
+ fMax = aData[ i ][ j ];
+ else if( aData[ i ][ j ] < fMin )
+ fMin = aData[ i ][ j ];
+ }
+ aMaxPtSeq[ 0 ][ i ] = new Point( getAxisPosition( aXAxis, aData[ i ][ 0 ], false ),
+ getAxisPosition( aYAxis, fMax, true ));
+ aMinPtSeq[ 0 ][ i ] = new Point( getAxisPosition( aXAxis, aData[ i ][ 0 ], false ),
+ getAxisPosition( aYAxis, fMin, true ));
+ }
+
+ // apply point sequences to lines
+ try
+ {
+ XPropertySet aShapeProp = UnoRuntime.queryInterface(
+ XPropertySet.class, maTopLine );
+ aShapeProp.setPropertyValue( "PolyPolygon", aMaxPtSeq );
+
+ aShapeProp = UnoRuntime.queryInterface(
+ XPropertySet.class, maBottomLine );
+ aShapeProp.setPropertyValue( "PolyPolygon", aMinPtSeq );
+ }
+ catch( Exception ex )
+ {
+ JOptionPane.showMessageDialog( null, ex, "Exception caught", JOptionPane.WARNING_MESSAGE );
+ }
+ }
+
+ public void addRefreshListener( com.sun.star.util.XRefreshListener aListener )
+ throws RuntimeException
+ {
+ // we don't want this but we have to implement the interface
+ }
+
+ public void removeRefreshListener( com.sun.star.util.XRefreshListener aListener )
+ throws RuntimeException
+ {
+ // we don't want this but we have to implement the interface
+ }
+
+
+ // XServiceName
+ public String getServiceName() throws RuntimeException
+ {
+ return smServiceName;
+ }
+
+ // XServiceInfo
+ public boolean supportsService( String aServiceName )
+ {
+ String[] aServices = getSupportedServiceNames_Static();
+ int i, nLength = aServices.length;
+ boolean bResult = false;
+
+ for( i = 0; !bResult && i < nLength; ++i )
+ bResult = aServiceName.equals( aServices[ i ] );
+
+ return bResult;
+ }
+
+ public String getImplementationName()
+ {
+ return( JavaSampleChartAddIn.class.getName() );
+ }
+
+ public String[] getSupportedServiceNames()
+ {
+ return getSupportedServiceNames_Static();
+ }
+
+ // XDiagram
+ public String getDiagramType() throws RuntimeException
+ {
+ return smServiceName;
+ }
+
+ public XPropertySet getDataRowProperties( int nRow )
+ throws com.sun.star.lang.IndexOutOfBoundsException, RuntimeException
+ {
+ return maChartDocument.getDiagram().getDataRowProperties( nRow );
+ }
+
+ public XPropertySet getDataPointProperties( int nCol, int nRow )
+ throws com.sun.star.lang.IndexOutOfBoundsException, RuntimeException
+ {
+ return maChartDocument.getDiagram().getDataPointProperties( nCol, nRow );
+ }
+
+ // XShape : XDiagram
+ public Size getSize() throws RuntimeException
+ {
+ return UnoRuntime.queryInterface( XShape.class, maChartDocument.getDiagram()).getSize();
+ }
+ public void setSize( Size aSize ) throws RuntimeException, PropertyVetoException
+ {
+ UnoRuntime.queryInterface( XShape.class, maChartDocument.getDiagram()).setSize( aSize );
+ }
+
+ public Point getPosition() throws RuntimeException
+ {
+ return UnoRuntime.queryInterface( XShape.class, maChartDocument.getDiagram()).getPosition();
+ }
+ public void setPosition( Point aPos ) throws RuntimeException
+ {
+ UnoRuntime.queryInterface( XShape.class, maChartDocument.getDiagram()).setPosition( aPos );
+ }
+
+ // XShapeDescriptor : XShape : XDiagram
+ public String getShapeType() throws RuntimeException
+ {
+ return "com.sun.star.comp.Chart.JavaSampleDiagramShape";
+ }
+
+
+ // __________ private members __________
+ private com.sun.star.chart.XChartDocument maChartDocument;
+ private com.sun.star.drawing.XDrawPage maDrawPage;
+ private com.sun.star.lang.XMultiServiceFactory maShapeFactory;
+
+ // shapes added by add-in
+ private com.sun.star.drawing.XShape maTopLine;
+ private com.sun.star.drawing.XShape maBottomLine;
+
+ // __________ private methods __________
+
+ private int getAxisPosition( XShape aAxis, double fValue, boolean bVertical )
+ {
+ int nResult = 0;
+
+ if( aAxis != null )
+ {
+ XPropertySet aAxisProp = UnoRuntime.queryInterface(
+ XPropertySet.class, aAxis );
+
+ try
+ {
+ double fMin, fMax;
+ fMin = ((Double) aAxisProp.getPropertyValue( "Min" )).doubleValue();
+ fMax = ((Double) aAxisProp.getPropertyValue( "Max" )).doubleValue();
+ double fRange = fMax - fMin;
+
+ if( fMin <= fValue && fValue <= fMax &&
+ fRange != 0 )
+ {
+ if( bVertical )
+ {
+ nResult = aAxis.getPosition().Y +
+ (int)((aAxis.getSize().Height) *
+ (1.0 - (( fValue - fMin ) / fRange )));
+ }
+ else
+ {
+ nResult = aAxis.getPosition().X +
+ (int)((aAxis.getSize().Width) *
+ (( fValue - fMin ) / fRange ));
+ }
+ }
+ }
+ catch( Exception ex )
+ {
+ JOptionPane.showMessageDialog( null, ex, "Exception caught", JOptionPane.WARNING_MESSAGE );
+ }
+ }
+ return nResult;
+ }
+
+ // __________ static things __________
+
+ private static final String smServiceName = "com.sun.star.comp.Chart.JavaSampleChartAddIn";
+
+ public static String[] getSupportedServiceNames_Static()
+ {
+ String[] aResult = { smServiceName,
+ "com.sun.star.chart.Diagram",
+ "com.sun.star.chart.ChartAxisYSupplier" };
+ return aResult;
+ }
+
+
+ /**
+ * Returns a factory for creating the service.
+ * This method is called by the <code>JavaLoader</code>
+ * <p>
+ * @return returns a <code>XSingleServiceFactory</code> for creating the component
+ * @param implName the name of the implementation for which a service is desired
+ * @param multiFactory the service manager to be used if needed
+ * @param regKey the registryKey
+ * @see com.sun.star.comp.loader.JavaLoader
+ */
+ public static XSingleServiceFactory __getServiceFactory(
+ String implName,
+ XMultiServiceFactory multiFactory,
+ com.sun.star.registry.XRegistryKey regKey )
+ {
+ XSingleServiceFactory xSingleServiceFactory = null;
+
+ if( implName.equals( JavaSampleChartAddIn.class.getName()) )
+ {
+ xSingleServiceFactory = com.sun.star.comp.loader.FactoryHelper.getServiceFactory(
+ JavaSampleChartAddIn.class, smServiceName,
+ multiFactory, regKey );
+ }
+
+ return xSingleServiceFactory;
+ }
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/Charts/ListenAtCalcRangeInDraw.java b/odk/examples/DevelopersGuide/Charts/ListenAtCalcRangeInDraw.java
new file mode 100644
index 000000000..76808b4ae
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Charts/ListenAtCalcRangeInDraw.java
@@ -0,0 +1,193 @@
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+// __________ Imports __________
+
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.lang.*;
+
+// property access
+import com.sun.star.beans.*;
+
+// application specific classes
+import com.sun.star.chart.*;
+import com.sun.star.table.XCellRange;
+import com.sun.star.sheet.XSpreadsheetDocument;
+
+import com.sun.star.frame.XModel;
+// base graphics things
+import com.sun.star.awt.Point;
+import com.sun.star.awt.Size;
+// Exceptions
+import com.sun.star.uno.Exception;
+
+
+// __________ Implementation __________
+
+/** Create a spreadsheet add some data.
+ Create a presentation and add a chart.
+ Connect the chart to a calc range via a listener
+ */
+public class ListenAtCalcRangeInDraw implements XChartDataChangeEventListener
+{
+ public static void main( String args[] )
+ {
+ ListenAtCalcRangeInDraw aMySelf = new ListenAtCalcRangeInDraw( args );
+
+ aMySelf.run();
+ }
+
+ public ListenAtCalcRangeInDraw( String args[] )
+ {
+ Helper aHelper = new Helper( args );
+
+ maSheetDoc = aHelper.createSpreadsheetDocument();
+ XModel aDrawDoc = aHelper.createDrawingDocument();
+ CalcHelper aCalcHelper = new CalcHelper( maSheetDoc );
+ ChartHelper aChartHelper = new ChartHelper( aDrawDoc );
+
+ XCellRange aRange = aCalcHelper.insertFormulaRange( 3, 30 );
+
+ // the unit for measures is 1/100th of a millimeter
+ // position at (1cm, 1cm)
+ Point aPos = new Point( 1000, 1000 );
+
+ // size of the chart is 15cm x 9.271cm
+ Size aExtent = new Size( 15000, 9271 );
+
+ // insert a new chart into the "Chart" sheet of the
+ // spreadsheet document
+ maChartDocument = aChartHelper.insertOLEChartInDraw(
+ aPos,
+ aExtent,
+ "com.sun.star.chart.XYDiagram" );
+
+ // attach the data coming from the cell range to the chart
+ maChartData = UnoRuntime.queryInterface( XChartData.class, aRange );
+ maChartDocument.attachData( maChartData );
+ }
+
+
+
+ public void run()
+ {
+ try
+ {
+ UnoRuntime.queryInterface(
+ XPropertySet.class, maChartDocument ).setPropertyValue(
+ "HasSubTitle", Boolean.TRUE);
+
+ // start listening for death of spreadsheet
+ UnoRuntime.queryInterface(
+ XComponent.class, maSheetDoc ).addEventListener( this );
+
+ // start listening for death of chart
+ UnoRuntime.queryInterface(
+ XComponent.class, maChartDocument ).addEventListener( this );
+
+ //start listening for change of data
+ maChartData.addChartDataChangeEventListener( this );
+ }
+ catch( Exception ex )
+ {
+ System.out.println( "Oops: " + ex );
+ }
+
+ // call listener
+ ChartDataChangeEvent aEvent = new ChartDataChangeEvent();
+ aEvent.Type = ChartDataChangeType.ALL;
+ chartDataChanged( aEvent );
+ }
+
+
+
+ // XEventListener (base of XChartDataChangeEventListener)
+ public void disposing( EventObject aSourceObj )
+ {
+ if( UnoRuntime.queryInterface( XChartDocument.class, aSourceObj.Source ) != null )
+ System.out.println( "Disconnecting Listener because Chart was shut down" );
+
+ if( UnoRuntime.queryInterface( XSpreadsheetDocument.class, aSourceObj.Source ) != null )
+ System.out.println( "Disconnecting Listener because Spreadsheet was shut down" );
+
+ // remove data change listener
+ maChartData.removeChartDataChangeEventListener( this );
+
+ // remove dispose listeners
+ UnoRuntime.queryInterface(
+ XComponent.class, maSheetDoc ).removeEventListener( this );
+ UnoRuntime.queryInterface(
+ XComponent.class, maChartDocument ).removeEventListener( this );
+
+ System.exit( 0 );
+ }
+
+
+
+ // XChartDataChangeEventListener
+ public void chartDataChanged( ChartDataChangeEvent aEvent )
+ {
+ // update subtitle
+ String aTitle = "Last Update: " + new java.util.Date();
+
+ try
+ {
+ XPropertySet aDocProp = UnoRuntime.queryInterface(
+ XPropertySet.class, maChartDocument );
+ aDocProp.setPropertyValue( "HasMainTitle", Boolean.TRUE);
+
+ UnoRuntime.queryInterface(
+ XPropertySet.class, maChartDocument.getSubTitle()).setPropertyValue(
+ "String", aTitle );
+
+ maChartDocument.attachData( maChartData );
+ }
+ catch( Exception ex )
+ {
+ System.out.println( "Oops: " + ex );
+ }
+
+ System.out.println( "Data has changed" );
+ }
+
+
+ // __________ private __________
+
+ private final XSpreadsheetDocument maSheetDoc;
+ private final XChartDocument maChartDocument;
+ private final XChartData maChartData;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/Charts/Makefile b/odk/examples/DevelopersGuide/Charts/Makefile
new file mode 100644
index 000000000..dbb55d51c
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Charts/Makefile
@@ -0,0 +1,199 @@
+#*************************************************************************
+#
+# The Contents of this file are made available subject to the terms of
+# the BSD license.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+# 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+# contributors may be used to endorse or promote products derived
+# from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+# TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+# USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+#**************************************************************************
+
+# Builds the Charts examples of the Developers Guide.
+
+PRJ=../../..
+SETTINGS=$(PRJ)/settings
+
+include $(SETTINGS)/settings.mk
+include $(SETTINGS)/std.mk
+
+# Define non-platform/compiler specific settings
+SAMPLE_NAME=DevGuideChartExample
+SAMPLE_CLASS_OUT = $(OUT_CLASS)/$(SAMPLE_NAME)
+SAMPLE_GEN_OUT = $(OUT_MISC)/$(SAMPLE_NAME)
+
+APP1_NAME=ChartInCalc
+APP1_JAR=$(SAMPLE_CLASS_OUT)/$(APP1_NAME).jar
+APP2_NAME=ChartInDraw
+APP2_JAR=$(SAMPLE_CLASS_OUT)/$(APP2_NAME).jar
+APP3_NAME=ChartInWriter
+APP3_JAR=$(SAMPLE_CLASS_OUT)/$(APP3_NAME).jar
+APP4_NAME=ListenAtCalcRangeInDraw
+APP4_JAR=$(SAMPLE_CLASS_OUT)/$(APP4_NAME).jar
+APP5_NAME=SelectionChangeListener
+APP5_JAR=$(SAMPLE_CLASS_OUT)/$(APP5_NAME).jar
+
+COMP_NAME=JavaSampleChartAddIn
+COMP_PACKAGE = $(OUT_BIN)/$(COMP_NAME).$(UNOOXT_EXT)
+COMP_PACKAGE_URL = $(subst \\,\,"$(COMP_PACKAGE_DIR)$(PS)$(COMP_NAME).$(UNOOXT_EXT)")
+COMP_JAR_NAME = $(COMP_NAME).uno.jar
+COMP_JAR = $(SAMPLE_CLASS_OUT)/$(COMP_JAR_NAME)
+COMP_MANIFESTFILE = $(SAMPLE_CLASS_OUT)/$(COMP_NAME).uno.Manifest
+COMP_UNOPKG_MANIFEST = $(SAMPLE_CLASS_OUT)/$(COMP_NAME)/META-INF/manifest.xml
+COMP_REGISTERFLAG = $(SAMPLE_GEN_OUT)/devguide_$(COMP_NAME)_register_component.flag
+COMP_COMPONENTS=$(COMP_NAME).components
+
+COMPJAVAFILES = \
+ JavaSampleChartAddIn.java
+
+APP_JAVAFILES = \
+ Helper.java \
+ CalcHelper.java \
+ ChartHelper.java
+
+COMPCLASSFILES= $(patsubst %.java,$(SAMPLE_CLASS_OUT)/%.class,$(COMPJAVAFILES))
+
+APP_CLASSFILES= $(patsubst %.java,$(SAMPLE_CLASS_OUT)/%.class,$(APP_JAVAFILES))
+APP_CLASSNAMES= $(patsubst %.java,%.class,$(APP_JAVAFILES))
+
+$(COMP_NAME)_CLASSFILES = $(COMP_NAME).class
+
+SDK_CLASSPATH = $(subst $(EMPTYSTRING) $(PATH_SEPARATOR),$(PATH_SEPARATOR),$(CLASSPATH)\
+ $(PATH_SEPARATOR)$(SAMPLE_CLASS_OUT))
+
+
+# Targets
+.PHONY: ALL
+ALL : $(SAMPLE_NAME)
+
+include $(SETTINGS)/stdtarget.mk
+
+$(SAMPLE_CLASS_OUT)/%.Manifest :
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ @echo RegistrationClassName: $(basename $(basename $(@F)))> $@
+
+# rule for client/example application class files, explicit dependencies to common
+# java files which are used in all examples.
+$(SAMPLE_CLASS_OUT)/%.class : %.java $(APP_JAVAFILES)
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ $(SDK_JAVAC) $(JAVAC_FLAGS) -classpath "$(SDK_CLASSPATH)" -d $(SAMPLE_CLASS_OUT) $< $(APP_JAVAFILES)
+
+$(COMPCLASSFILES) : $(JAVAFILES)
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ $(SDK_JAVAC) $(JAVAC_FLAGS) -classpath "$(SDK_CLASSPATH)" -d $(SAMPLE_CLASS_OUT) $(COMPJAVAFILES)
+
+# rule for client/example application manifest file
+$(SAMPLE_CLASS_OUT)/%.mf :
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ @echo Main-Class: com.sun.star.lib.loader.Loader> $@
+ $(ECHOLINE)>> $@
+ @echo Name: com/sun/star/lib/loader/Loader.class>> $@
+ @echo Application-Class: $*>> $@
+
+# rule for client/example application jar file
+$(SAMPLE_CLASS_OUT)/%.jar : $(SAMPLE_CLASS_OUT)/%.mf $(SAMPLE_CLASS_OUT)/%.class
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ +cd $(subst /,$(PS),$(SAMPLE_CLASS_OUT)) && $(SDK_JAR) cvfm $(@F) $*.mf $**.class $(APP_CLASSNAMES)
+
+ +$(SDK_JAR) uvf $@ $(SDK_JAVA_UNO_BOOTSTRAP_FILES)
+
+# rule for component jar file
+$(COMP_JAR) : $(COMP_MANIFESTFILE) $(COMPCLASSFILES)
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ cd $(subst /,$(PS),$(SAMPLE_CLASS_OUT)) && $(SDK_JAR) cvfm $(@F) $(<F) $($(basename $(basename $(@F)))_CLASSFILES)
+
+# rule for component package manifest
+$(SAMPLE_CLASS_OUT)/%/manifest.xml :
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ @echo $(OSEP)?xml version="$(QM)1.0$(QM)" encoding="$(QM)UTF-8$(QM)"?$(CSEP) > $@
+ @echo $(OSEP)!DOCTYPE manifest:manifest PUBLIC "$(QM)-//OpenOffice.org//DTD Manifest 1.0//EN$(QM)" "$(QM)Manifest.dtd$(QM)"$(CSEP) >> $@
+ @echo $(OSEP)manifest:manifest xmlns:manifest="$(QM)http://openoffice.org/2001/manifest$(QM)"$(CSEP) >> $@
+ @echo $(SQM) $(SQM)$(OSEP)manifest:file-entry manifest:media-type="$(QM)application/vnd.sun.star.uno-components$(QM)">> $@
+ @echo $(SQM) $(SQM)manifest:full-path="$(QM)$(COMP_COMPONENTS)$(QM)"/$(CSEP)>> $@
+ @echo $(OSEP)/manifest:manifest$(CSEP) >> $@
+
+# rule for component package file
+$(COMP_PACKAGE) : $(COMP_JAR) $(COMP_UNOPKG_MANIFEST) $(COMP_COMPONENTS)
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ $(SDK_ZIP) $@ $(COMP_COMPONENTS)
+ cd $(subst /,$(PS),$(SAMPLE_CLASS_OUT)) && $(SDK_ZIP) ../../bin/$(@F) -u $(<F)
+ cd $(subst /,$(PS),$(SAMPLE_CLASS_OUT)/$(subst .$(UNOOXT_EXT),,$(@F))) && $(SDK_ZIP) ../../../bin/$(@F) -u META-INF/manifest.xml
+
+$(COMP_REGISTERFLAG) : $(COMP_PACKAGE)
+ifeq "$(SDK_AUTO_DEPLOYMENT)" "YES"
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ $(DEPLOYTOOL) $(COMP_PACKAGE_URL)
+ @echo flagged > $(subst /,$(PS),$@)
+else
+ @echo --------------------------------------------------------------------------------
+ @echo If you want to install your component automatically, please set the environment
+ @echo variable SDK_AUTO_DEPLOYMENT = YES. But note that auto deployment is only
+ @echo possible if no office instance is running.
+ @echo --------------------------------------------------------------------------------
+endif
+
+$(APP1_JAR) : $(SAMPLE_CLASS_OUT)/$(APP1_NAME).mf $(SAMPLE_CLASS_OUT)/$(APP1_NAME).class
+$(APP2_JAR) : $(SAMPLE_CLASS_OUT)/$(APP2_NAME).mf $(SAMPLE_CLASS_OUT)/$(APP2_NAME).class
+$(APP3_JAR) : $(SAMPLE_CLASS_OUT)/$(APP3_NAME).mf $(SAMPLE_CLASS_OUT)/$(APP3_NAME).class
+$(APP4_JAR) : $(SAMPLE_CLASS_OUT)/$(APP4_NAME).mf $(SAMPLE_CLASS_OUT)/$(APP4_NAME).class
+$(APP5_JAR) : $(SAMPLE_CLASS_OUT)/$(APP5_NAME).mf $(SAMPLE_CLASS_OUT)/$(APP5_NAME).class
+
+$(SAMPLE_NAME) : $(COMP_REGISTERFLAG) $(APP1_JAR) $(APP2_JAR) $(APP3_JAR) $(APP4_JAR) $(APP5_JAR)
+ @echo --------------------------------------------------------------------------------
+ @echo When you run the "$(QM)$(APP5_NAME)$(QM)" example please select the
+ @echo legend or the title to add a $(APP5_NAME). The example terminates
+ @echo when the document is closed.
+ @echo -
+ @echo Please use the following commands to execute the examples!
+ @echo -
+ @echo $(MAKE) $(APP1_NAME).run
+ @echo $(MAKE) $(APP2_NAME).run
+ @echo $(MAKE) $(APP3_NAME).run
+ @echo $(MAKE) $(APP4_NAME).run
+ @echo $(MAKE) $(APP5_NAME).run
+ @echo --------
+ @echo The Chart add-in component was installed if SDK_AUTO_DEPLOYMENT = YES.
+ @echo Load the "$(QM)AddInChart.ods$(QM)" document in your office to see the new chart type,
+ @echo and see the example description.
+ @echo -
+ @echo $(MAKE) AddInChart.ods.load
+ @echo --------------------------------------------------------------------------------
+
+%.run: $(SAMPLE_CLASS_OUT)/%.jar
+ $(SDK_JAVA) -Dcom.sun.star.lib.loader.unopath="$(OFFICE_PROGRAM_PATH)" -jar $<
+
+AddInChart.ods.load : $(REGISTERFLAG)
+ "$(OFFICE_PROGRAM_PATH)$(PS)soffice" $(basename $@)
+
+.PHONY: clean
+clean :
+ -$(DELRECURSIVE) $(subst /,$(PS),$(SAMPLE_CLASS_OUT))
+ -$(DELRECURSIVE) $(subst /,$(PS),$(SAMPLE_GEN_OUT))
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$(COMP_PACKAGE_URL)))
diff --git a/odk/examples/DevelopersGuide/Charts/SelectionChangeListener.java b/odk/examples/DevelopersGuide/Charts/SelectionChangeListener.java
new file mode 100644
index 000000000..e9ba0581c
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Charts/SelectionChangeListener.java
@@ -0,0 +1,220 @@
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+import com.sun.star.awt.XMessageBox;
+import com.sun.star.awt.XWindowPeer;
+import com.sun.star.frame.XDesktop;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.lang.*;
+import com.sun.star.frame.XModel;
+import com.sun.star.frame.XController;
+
+// application specific classes
+import com.sun.star.chart.*;
+import com.sun.star.uno.XComponentContext;
+import com.sun.star.uno.XInterface;
+
+import com.sun.star.view.XSelectionChangeListener;
+import com.sun.star.view.XSelectionSupplier;
+
+import com.sun.star.table.CellRangeAddress;
+import com.sun.star.table.XCellRange;
+import com.sun.star.sheet.XCellRangeAddressable;
+
+import com.sun.star.awt.Point;
+import com.sun.star.awt.Size;
+import com.sun.star.awt.XMessageBoxFactory;
+import com.sun.star.awt.MessageBoxType;
+import com.sun.star.awt.XWindow;
+
+// __________ Implementation __________
+
+/** Create a spreadsheet add some data.
+ * Create a presentation and add a chart.
+ * Connect the chart to a calc range via a listener
+ *
+ * Note: This example does not work in StarOffice 6.0. It will be available
+ * in the StarOffice Accessibility release.
+ */
+public class SelectionChangeListener implements XSelectionChangeListener {
+ public static void main( String args[] ) {
+ SelectionChangeListener aMySelf = new SelectionChangeListener( args );
+
+ aMySelf.run();
+ }
+
+ public SelectionChangeListener( String args[] ) {
+ Helper aHelper = new Helper( args );
+
+ maContext = aHelper.getComponentContext();
+
+ CalcHelper aCalcHelper = new CalcHelper( aHelper.createSpreadsheetDocument() );
+
+ // insert a cell range with 4 columns and 12 rows filled with random numbers
+ XCellRange aRange = aCalcHelper.insertRandomRange( 4, 12 );
+ CellRangeAddress aRangeAddress = UnoRuntime.queryInterface(
+ XCellRangeAddressable.class, aRange).getRangeAddress();
+
+ // change view to sheet containing the chart
+ aCalcHelper.raiseChartSheet();
+
+ // the unit for measures is 1/100th of a millimeter
+ // position at (1cm, 1cm)
+ Point aPos = new Point( 1000, 1000 );
+
+ // size of the chart is 15cm x 9.271cm
+ Size aExtent = new Size( 15000, 9271 );
+
+ // insert a new chart into the "Chart" sheet of the
+ // spreadsheet document
+ maChartDocument = aCalcHelper.insertChart(
+ "SampleChart",
+ aRangeAddress,
+ aPos,
+ aExtent,
+ "com.sun.star.chart.XYDiagram" );
+ }
+
+
+
+ public void run() {
+ boolean bTrying = true;
+
+ while( bTrying ) {
+ // start listening for selection changes
+ XSelectionSupplier aSelSupp = UnoRuntime.queryInterface(
+ XSelectionSupplier.class,
+ (UnoRuntime.queryInterface(
+ XModel.class, maChartDocument ).getCurrentController()) );
+ if( aSelSupp != null ) {
+ aSelSupp.addSelectionChangeListener( this );
+ System.out.println( "Successfully attached as selection change listener" );
+ bTrying = false;
+ }
+
+ // start listening for death of Controller
+ XComponent aComp = UnoRuntime.queryInterface( XComponent.class, aSelSupp );
+ if( aComp != null ) {
+ aComp.addEventListener( this );
+ System.out.println( "Successfully attached as dispose listener" );
+ }
+
+ try {
+ Thread.sleep( 500 );
+ } catch( InterruptedException ex ) {
+ }
+ }
+ }
+
+
+
+ // XEventListener (base of XSelectionChangeListener)
+ public void disposing( EventObject aSourceObj ) {
+ System.out.println( "disposing called. detaching as listener" );
+
+ // stop listening for selection changes
+ XSelectionSupplier aCtrl = UnoRuntime.queryInterface(
+ XSelectionSupplier.class, aSourceObj );
+ if( aCtrl != null )
+ aCtrl.removeSelectionChangeListener( this );
+
+ // remove as dispose listener
+ XComponent aComp = UnoRuntime.queryInterface( XComponent.class, aSourceObj );
+ if( aComp != null )
+ aComp.removeEventListener( this );
+
+ // bail out
+ System.exit( 0 );
+ }
+
+
+
+ // XSelectionChangeListener
+ public void selectionChanged( EventObject aEvent ) {
+ XController aCtrl = UnoRuntime.queryInterface( XController.class, aEvent.Source );
+ if( aCtrl != null ) {
+ XMultiComponentFactory mMCF = maContext.getServiceManager();
+
+ MyMessageBox aMsgBox = new MyMessageBox(mMCF);
+
+ aMsgBox.start();
+
+ System.out.println("Listener finished");
+ }
+ }
+
+ // __________ private __________
+
+ private class MyMessageBox extends Thread{
+ private final XMultiComponentFactory mMCF;
+
+ public MyMessageBox(XMultiComponentFactory xMCF){
+ mMCF = xMCF;
+ }
+
+ @Override
+ public void run() {
+ XDesktop aDesktop = null;
+ XInterface aToolKit = null;
+ try {
+ Thread.sleep(1000);
+ } catch (InterruptedException ex) {
+ ex.printStackTrace();
+ }
+ try {
+ Object oDesktop = mMCF.createInstanceWithContext("com.sun.star.frame.Desktop", maContext);
+ Object oToolKit = mMCF.createInstanceWithContext("com.sun.star.awt.Toolkit", maContext);
+
+ aDesktop = UnoRuntime.queryInterface(XDesktop.class, oDesktop);
+ aToolKit = UnoRuntime.queryInterface(XInterface.class, oToolKit);
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ }
+
+ XWindow xWin = aDesktop.getCurrentFrame().getContainerWindow();
+ XWindowPeer aWinPeer = UnoRuntime.queryInterface(XWindowPeer.class, xWin);
+
+ int button = com.sun.star.awt.MessageBoxButtons.BUTTONS_OK;
+ XMessageBoxFactory aMBF = UnoRuntime.queryInterface(XMessageBoxFactory.class, aToolKit);
+ XMessageBox xMB = aMBF.createMessageBox(aWinPeer, MessageBoxType.INFOBOX, button, "Event-Notify", "Listener was called, selection has changed");
+ xMB.execute();
+ }
+ }
+
+ private final XChartDocument maChartDocument;
+ private final XComponentContext maContext;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/Charts/bullet.gif b/odk/examples/DevelopersGuide/Charts/bullet.gif
new file mode 100644
index 000000000..0f8efd140
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Charts/bullet.gif
Binary files differ
diff --git a/odk/examples/DevelopersGuide/Components/Addons/JobsAddon/Addons.xcu b/odk/examples/DevelopersGuide/Components/Addons/JobsAddon/Addons.xcu
new file mode 100644
index 000000000..2568a7c4f
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Components/Addons/JobsAddon/Addons.xcu
@@ -0,0 +1,83 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!--
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+-->
+<oor:component-data xmlns:oor="http://openoffice.org/2001/registry" xmlns:xs="http://www.w3.org/2001/XMLSchema" oor:name="Addons" oor:package="org.openoffice.Office">
+ <node oor:name="AddonUI">
+
+ <node oor:name="AddonMenu">
+
+ <node oor:name="myAsyncJobAlias" oor:op="replace">
+
+ <prop oor:name="URL" oor:type="xs:string">
+
+ <value>vnd.sun.star.job:alias=AsyncJob</value>
+
+ </prop>
+
+ <prop oor:name="Title" oor:type="xs:string">
+ <!-- The x-no-translate entry is a marker to prevent l10n tooling from translation. If it is not necessary. -->
+ <value xml:lang="x-no-translate"></value>
+ <value xml:lang="en-US">AsyncJob (ALIAS)...</value>
+ <value xml:lang="de">AsyncJob (ALIAS) ...</value>
+ </prop>
+ <prop oor:name="Target" oor:type="xs:string">
+ <value>_self</value>
+ </prop>
+ </node>
+
+ <node oor:name="myAsyncJobEvent" oor:op="replace">
+
+ <prop oor:name="URL" oor:type="xs:string">
+
+ <value>vnd.sun.star.job:event=onMyOwnJobEvent</value>
+
+ </prop>
+
+ <prop oor:name="Title" oor:type="xs:string">
+ <!-- The x-no-translate entry is a marker to prevent l10n tooling from translation. If it is not necessary. -->
+ <value xml:lang="x-no-translate"></value>
+ <value xml:lang="en-US">AsyncJob (EVENT)...</value>
+ <value xml:lang="de">AsyncJob (EVENT) ...</value>
+ </prop>
+ <prop oor:name="Target" oor:type="xs:string">
+ <value>_self</value>
+ </prop>
+ </node>
+
+ <node oor:name="myAsyncJobService" oor:op="replace">
+
+ <prop oor:name="URL" oor:type="xs:string">
+
+ <value>vnd.sun.star.job:service=com.sun.star.comp.framework.java.services.AsyncJob</value>
+
+ </prop>
+
+ <prop oor:name="Title" oor:type="xs:string">
+ <!-- The x-no-translate entry is a marker to prevent l10n tooling from translation. If it is not necessary. -->
+ <value xml:lang="x-no-translate"></value>
+ <value xml:lang="en-US">AsyncJob (SERVICE)...</value>
+ <value xml:lang="de">AsyncJob (SERVICE) ...</value>
+ </prop>
+ <prop oor:name="Target" oor:type="xs:string">
+ <value>_self</value>
+ </prop>
+ </node>
+ </node>
+ </node>
+</oor:component-data>
+
diff --git a/odk/examples/DevelopersGuide/Components/Addons/JobsAddon/AsyncJob.components b/odk/examples/DevelopersGuide/Components/Addons/JobsAddon/AsyncJob.components
new file mode 100644
index 000000000..c47f26b01
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Components/Addons/JobsAddon/AsyncJob.components
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<components xmlns="http://openoffice.org/2010/uno-components">
+ <component loader="com.sun.star.loader.Java2" uri="AsyncJob.uno.jar">
+ <implementation name="com.sun.star.comp.framework.java.services.AsyncJob">
+ <service name="com.sun.star.task.AsyncJob"/>
+ </implementation>
+ </component>
+</components>
diff --git a/odk/examples/DevelopersGuide/Components/Addons/JobsAddon/AsyncJob.java b/odk/examples/DevelopersGuide/Components/Addons/JobsAddon/AsyncJob.java
new file mode 100644
index 000000000..9b55929d8
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Components/Addons/JobsAddon/AsyncJob.java
@@ -0,0 +1,425 @@
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+import com.sun.star.uno.XComponentContext;
+import com.sun.star.lib.uno.helper.Factory;
+import com.sun.star.lib.uno.helper.WeakBase;
+import com.sun.star.lang.XServiceInfo;
+import com.sun.star.task.*;
+import com.sun.star.uno.*;
+
+/** it implements a simple job component.
+ *
+ * Such jobs are executable in different ways:
+ * <ul>
+ * <li>registered for a special URL schema "vnd.sun.star.jobs:*" and used from the generic dispatch framework</li>
+ * <li>the global com.sun.star.task.JobExecutor service and registered for special events.</li>
+ * </ul>
+ */
+public class AsyncJob extends WeakBase implements XServiceInfo, XAsyncJob
+{
+ public final XComponentContext m_xCmpCtx;
+
+ /** the const list of supported uno service names. */
+ public static final String[] SERVICENAMES = {"com.sun.star.task.AsyncJob"};
+
+ /** the const uno implementation name.
+ * It must be a unique value! The best naming schema seems to use
+ * a registered domain in reverse order ...
+ */
+ public static final String IMPLEMENTATIONNAME = "com.sun.star.comp.framework.java.services.AsyncJob";
+
+
+ // interface
+
+ /** initialize a new instance of this class with default values. */
+ public AsyncJob( XComponentContext xCompContext )
+ {
+ m_xCmpCtx = xCompContext;
+ }
+
+
+
+ /** starts execution of this job.
+ *
+ * @param lArgs
+ * list which contains:
+ * <ul>
+ * <li>generic job configuration data</li>
+ * <li>job specific configuration data</li>
+ * <li>some environment information</li>
+ * <li>may optional arguments of a corresponding dispatch request</li>
+ * </ul>
+ *
+ * @params xListener
+ * callback to the executor of this job, which control our life time
+ *
+ * @throws com.sun.star.lang.IllegalArgumentException
+ * if given argument list seems to be wrong
+ */
+ public synchronized void executeAsync(com.sun.star.beans.NamedValue[] lArgs ,
+ com.sun.star.task.XJobListener xListener)
+ throws com.sun.star.lang.IllegalArgumentException
+ {
+ // For asynchronous jobs a valid listener reference is guaranteed normally ...
+ if (xListener == null)
+ throw new com.sun.star.lang.IllegalArgumentException("invalid listener");
+
+ // extract all possible sub list of given argument list
+ com.sun.star.beans.NamedValue[] lGenericConfig = null;
+ com.sun.star.beans.NamedValue[] lJobConfig = null;
+ com.sun.star.beans.NamedValue[] lEnvironment = null;
+ com.sun.star.beans.NamedValue[] lDynamicData = null;
+
+ int c = lArgs.length;
+ for (int i=0; i<c; ++i)
+ {
+ if (lArgs[i].Name.equals("Config"))
+ lGenericConfig = (com.sun.star.beans.NamedValue[])com.sun.star.uno.AnyConverter.toArray(lArgs[i].Value);
+ else
+ if (lArgs[i].Name.equals("JobConfig"))
+ lJobConfig = (com.sun.star.beans.NamedValue[])com.sun.star.uno.AnyConverter.toArray(lArgs[i].Value);
+ else
+ if (lArgs[i].Name.equals("Environment"))
+ lEnvironment = (com.sun.star.beans.NamedValue[])com.sun.star.uno.AnyConverter.toArray(lArgs[i].Value);
+ else
+ if (lArgs[i].Name.equals("DynamicData"))
+ lDynamicData = (com.sun.star.beans.NamedValue[])com.sun.star.uno.AnyConverter.toArray(lArgs[i].Value);
+ }
+
+ // Analyze the environment info. This sub list is the only guaranteed one!
+ if (lEnvironment == null)
+ throw new com.sun.star.lang.IllegalArgumentException("no environment");
+
+ String sEnvType = null;
+ String sEventName = null;
+ com.sun.star.frame.XFrame xFrame = null;
+ c = lEnvironment.length;
+ for (int i=0; i<c; ++i)
+ {
+ if (lEnvironment[i].Name.equals("EnvType"))
+ sEnvType = com.sun.star.uno.AnyConverter.toString(lEnvironment[i].Value);
+ else
+ if (lEnvironment[i].Name.equals("EventName"))
+ sEventName = com.sun.star.uno.AnyConverter.toString(lEnvironment[i].Value);
+ else
+ if (lEnvironment[i].Name.equals("Frame"))
+ xFrame = (com.sun.star.frame.XFrame)com.sun.star.uno.AnyConverter.toObject(
+ new com.sun.star.uno.Type(com.sun.star.frame.XFrame.class),
+ lEnvironment[i].Value);
+ }
+
+ // Further the environment property "EnvType" is required as minimum.
+ if (
+ (sEnvType==null) ||
+ (
+ (!sEnvType.equals("EXECUTOR")) &&
+ (!sEnvType.equals("DISPATCH"))
+ )
+ )
+ {
+ String sMessage = "\"" + sEnvType + "\" isn't a valid value for EnvType";
+ throw new com.sun.star.lang.IllegalArgumentException(sMessage);
+ }
+
+ // Analyze the set of shared config data.
+ if (lGenericConfig!=null)
+ {
+ c = lGenericConfig.length;
+ for (int i=0; i<c; ++i)
+ {
+ if (lGenericConfig[i].Name.equals("Alias"))
+ com.sun.star.uno.AnyConverter.toString(lGenericConfig[i].Value);
+ }
+ }
+
+ // do your job ...
+ // Here we print out all found arguments.
+ String sOut = formatOutArgs(lGenericConfig, lJobConfig, lEnvironment, lDynamicData);
+ if (xFrame != null)
+ showInfoModal(xFrame.getContainerWindow(), "Arguments of AsyncJob initialization ...", sOut);
+ else
+ showInfoNonModal("Arguments of AsyncJob initialization ...", sOut);
+
+ // use return value to start different actions
+ // But look for the right environment. Some options make no sense inside the wrong env.
+ com.sun.star.beans.NamedValue aDeactivation = null;
+ com.sun.star.beans.NamedValue aDispatchResult = null;
+ com.sun.star.beans.NamedValue aSaveRequest = null;
+
+ // SaveArguments will be made everytimes!
+ c = 1;
+
+ if (lJobConfig==null)
+ lJobConfig = new com.sun.star.beans.NamedValue[1];
+ lJobConfig[0] = new com.sun.star.beans.NamedValue();
+ lJobConfig[0].Name = "arg_1";
+ lJobConfig[0].Value = "val_1";
+
+ aSaveRequest = new com.sun.star.beans.NamedValue();
+ aSaveRequest.Name = "SaveArguments";
+ aSaveRequest.Value = lJobConfig;
+
+ // Deactivation is useful inside EXECUTOR environment only
+ if (sEnvType.equals("EXECUTOR"))
+ {
+ ++c;
+ aDeactivation = new com.sun.star.beans.NamedValue();
+ aDeactivation.Name = "Deactivate";
+ aDeactivation.Value = java.lang.Boolean.TRUE;
+ }
+
+ // Sending of result events is useful inside DISPATCH environment only
+ if (sEnvType.equals("DISPATCH"))
+ {
+ ++c;
+ aDispatchResult = new com.sun.star.beans.NamedValue();
+ aDispatchResult.Name = "SendDispatchResult";
+ aDispatchResult.Value = new com.sun.star.frame.DispatchResultEvent(this, com.sun.star.frame.DispatchResultState.SUCCESS, null);
+ }
+
+ // pack it together for return
+ int i=0;
+ com.sun.star.beans.NamedValue[] lReturn = new com.sun.star.beans.NamedValue[c];
+ lReturn[i++] = aSaveRequest;
+ if (aDeactivation!=null)
+ lReturn[i++] = aDeactivation;
+ if (aDispatchResult!=null)
+ lReturn[i++] = aDispatchResult;
+
+ xListener.jobFinished(this, lReturn);
+ }
+
+
+
+ /** show an info box with the UNO based toolkit.
+ *
+ * It tries to use the container window of a may well know
+ * office frame as parent. If such parent window could be located,
+ * the info box can be shown in modal mode. If a parent is missing
+ * (because this job is called inside an EXECUTOR environment, which
+ * does not set any frame context here) the info box can't be created!
+ * Because the toolkit needs parents for non top level windows...
+ * In that case the only way is to implement this info box
+ * native or make it non modal using java dialogs inside its own thread...
+ * (see showInfoNonModal() too)
+ *
+ * @param xParent
+ * used as parent window of the shown info box.
+ *
+ * @param sTitle
+ * is shown as title of the info box.
+ *
+ * @param sMessage
+ * included the message body, which is shown as info.
+ */
+
+ private void showInfoModal( com.sun.star.awt.XWindow xParent ,
+ String sTitle ,
+ String sMessage )
+ {
+ try
+ {
+ // get access to the office toolkit environment
+ com.sun.star.awt.XToolkit xKit = UnoRuntime.queryInterface(
+ com.sun.star.awt.XToolkit.class,
+ m_xCmpCtx.getServiceManager().createInstanceWithContext("com.sun.star.awt.Toolkit",
+ m_xCmpCtx));
+
+ // describe the info box ini its parameters
+ com.sun.star.awt.WindowDescriptor aDescriptor = new com.sun.star.awt.WindowDescriptor();
+ aDescriptor.WindowServiceName = "infobox";
+ aDescriptor.Bounds = new com.sun.star.awt.Rectangle(0,0,300,200);
+ aDescriptor.WindowAttributes = com.sun.star.awt.WindowAttribute.BORDER |
+ com.sun.star.awt.WindowAttribute.MOVEABLE |
+ com.sun.star.awt.WindowAttribute.CLOSEABLE;
+ aDescriptor.Type = com.sun.star.awt.WindowClass.MODALTOP;
+ aDescriptor.ParentIndex = 1;
+ aDescriptor.Parent = UnoRuntime.queryInterface(
+ com.sun.star.awt.XWindowPeer.class,
+ xParent);
+
+ // create the info box window
+ com.sun.star.awt.XWindowPeer xPeer = xKit.createWindow(aDescriptor);
+ com.sun.star.awt.XMessageBox xInfoBox = UnoRuntime.queryInterface(
+ com.sun.star.awt.XMessageBox.class,
+ xPeer);
+ if (xInfoBox == null)
+ return;
+
+ // fill it with all given information and show it
+ xInfoBox.setCaptionText(sTitle);
+ xInfoBox.setMessageText(sMessage);
+ xInfoBox.execute();
+ }
+ catch(java.lang.Throwable exIgnore)
+ {
+ // ignore any problem, which can occur here.
+ // It's not really a bug for this example job, if
+ // it's message could not be printed out!
+ }
+ }
+
+
+
+ private void showInfoNonModal( String sTitle ,
+ String sMessage )
+ {
+ // Couldn't be implemented really using the toolkit...
+ // Because we need a parent anytime.
+ // And showing e.g. a Java dialog can make some trouble
+ // inside office... but we have no chance here.
+ final String sFinalTitle = sTitle;
+ final String sFinalMessage = sMessage;
+
+ // On macOS, AWT/Swing must not be accessed from the AppKit thread, so call
+ // SwingUtilities.invokeLater always on a fresh thread to avoid that problem
+ // (also, the current thread must not wait for that fresh thread to terminate,
+ // as that would cause a deadlock if this thread is the AppKit thread):
+ final Runnable doRun = new Runnable() {
+ public void run() {
+ javax.swing.JOptionPane.showMessageDialog(null, sFinalMessage, sFinalTitle, javax.swing.JOptionPane.INFORMATION_MESSAGE);
+ }
+ };
+
+ new Thread( doRun ) {
+ @Override
+ public void run() { javax.swing.SwingUtilities.invokeLater(doRun); }
+ }.start();
+ }
+
+
+
+ /** helper to print out the given argument list.
+ *
+ * @param lGenericConfig
+ * contains all shared configuration items for a job
+ *
+ * @param lJobConfig
+ * contains all job specific configuration items
+ *
+ * @param lEnvironment
+ * contains some environment information
+ *
+ * @param lDynamicData
+ * contains optional data of a might corresponding dispatch() request
+ */
+
+ private String formatOutArgs(com.sun.star.beans.NamedValue[] lGenericConfig,
+ com.sun.star.beans.NamedValue[] lJobConfig ,
+ com.sun.star.beans.NamedValue[] lEnvironment ,
+ com.sun.star.beans.NamedValue[] lDynamicData )
+ {
+ StringBuffer sOut = new StringBuffer(1024);
+
+ sOut.append("list \"Config\": ");
+ if (lGenericConfig==null)
+ sOut.append("0 items\n");
+ else
+ {
+ int c = lGenericConfig.length;
+ sOut.append(c+" items\n");
+ for (int i=0; i<c; ++i)
+ sOut.append("\t["+i+"] \""+lGenericConfig[i].Name+"\" = {"+lGenericConfig[i].Value+"}\n");
+ }
+ sOut.append("list \"JobConfig\": ");
+ if (lJobConfig==null)
+ sOut.append("0 items\n");
+ else
+ {
+ int c = lJobConfig.length;
+ sOut.append(c+" items\n");
+ for (int i=0; i<c; ++i)
+ sOut.append("\t["+i+"] \""+lJobConfig[i].Name+"\" = {"+lJobConfig[i].Value+"}\n");
+ }
+ sOut.append("list \"Environment\": ");
+ if (lEnvironment==null)
+ sOut.append("0 items\n");
+ else
+ {
+ int c = lEnvironment.length;
+ sOut.append(c+" items\n");
+ for (int i=0; i<c; ++i)
+ sOut.append("\t["+i+"] \""+lEnvironment[i].Name+"\" = {"+lEnvironment[i].Value+"}\n");
+ }
+ sOut.append("list \"DynamicData\": ");
+ if (lDynamicData==null)
+ sOut.append("0 items\n");
+ else
+ {
+ int c = lDynamicData.length;
+ sOut.append(c+" items\n");
+ for (int i=0; i<c; ++i)
+ sOut.append("\t["+i+"] \""+lDynamicData[i].Name+"\" = {"+lDynamicData[i].Value+"}\n");
+ }
+
+ return sOut.toString();
+ }
+
+ public String[] getSupportedServiceNames() {
+ return SERVICENAMES;
+ }
+
+ public boolean supportsService( String sService ) {
+ int len = SERVICENAMES.length;
+
+ for( int i=0; i < len; i++) {
+ if ( sService.equals( SERVICENAMES[i] ) )
+ return true;
+ }
+
+ return false;
+ }
+
+ public String getImplementationName() {
+ return( AsyncJob.class.getName() );
+ }
+
+
+
+
+ public synchronized static com.sun.star.lang.XSingleComponentFactory __getComponentFactory(String sImplName)
+ {
+ com.sun.star.lang.XSingleComponentFactory xFactory = null;
+ if (sImplName.equals(AsyncJob.IMPLEMENTATIONNAME))
+ xFactory = Factory.createComponentFactory(AsyncJob.class, SERVICENAMES);
+
+ return xFactory;
+ }
+
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/Components/Addons/JobsAddon/Jobs.xcu b/odk/examples/DevelopersGuide/Components/Addons/JobsAddon/Jobs.xcu
new file mode 100644
index 000000000..f97f202c6
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Components/Addons/JobsAddon/Jobs.xcu
@@ -0,0 +1,44 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!--
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+-->
+<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="AsyncJob" oor:op="replace">
+ <prop oor:name="Service" oor:type="xs:string">
+ <value>com.sun.star.comp.framework.java.services.AsyncJob</value>
+ </prop>
+ <node oor:name="Arguments">
+ <prop oor:name="arg_1" oor:op="replace" oor:type="xs:string">
+ <value>val_1</value>
+ </prop>
+ </node>
+ </node>
+ </node>
+ <node oor:name="Events">
+ <node oor:name="onFirstVisibleTask" oor:op="modify">
+ <node oor:name="JobList">
+ <node oor:name="AsyncJob" oor:op="replace"/>
+ </node>
+ </node>
+ <node oor:name="onMyOwnJobEvent" oor:op="replace">
+ <node oor:name="JobList">
+ <node oor:name="AsyncJob" oor:op="replace"/>
+ </node>
+ </node>
+ </node>
+</oor:component-data>
diff --git a/odk/examples/DevelopersGuide/Components/Addons/JobsAddon/Makefile b/odk/examples/DevelopersGuide/Components/Addons/JobsAddon/Makefile
new file mode 100644
index 000000000..6ee3481fc
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Components/Addons/JobsAddon/Makefile
@@ -0,0 +1,136 @@
+#*************************************************************************
+#
+# The Contents of this file are made available subject to the terms of
+# the BSD license.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+# 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+# contributors may be used to endorse or promote products derived
+# from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+# TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+# USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+#**************************************************************************
+
+# Builds the DevGuide Jobs Addon component example of the SDK.
+
+PRJ=../../../../..
+SETTINGS=$(PRJ)/settings
+
+include $(SETTINGS)/settings.mk
+include $(SETTINGS)/std.mk
+
+# Define non-platform/compiler specific settings
+COMP_NAME=AsyncJob
+OUT_COMP_CLASS=$(OUT_CLASS)/$(COMP_NAME)
+OUT_COMP_MISC=$(OUT_MISC)/$(COMP_NAME)
+COMP_PACKAGE=$(OUT_BIN)/$(COMP_NAME).$(UNOOXT_EXT)
+COMP_PACKAGE_URL=$(subst \\,\,"$(COMP_PACKAGE_DIR)$(PS)$(COMP_NAME).$(UNOOXT_EXT)")
+COMP_JAR_NAME=$(COMP_NAME).uno.jar
+COMP_JAR=$(OUT_CLASS)/$(COMP_JAR_NAME)
+COMP_MANIFESTFILE=$(OUT_COMP_CLASS)/$(COMP_NAME).uno.Manifest
+COMP_UNOPKG_MANIFEST = $(OUT_COMP_CLASS)/$(COMP_NAME)/META-INF/manifest.xml
+REGISTERFLAG=$(OUT_COMP_MISC)$(PS)java_$(COMP_NAME)_register_component.flag
+COMP_COMPONENTS=$(COMP_NAME).components
+
+JAVAFILES = AsyncJob.java
+
+CLASSFILES = $(patsubst %.java,$(OUT_COMP_CLASS)/%.class,$(JAVAFILES))
+
+SDK_CLASSPATH = $(subst $(EMPTYSTRING) $(PATH_SEPARATOR),$(PATH_SEPARATOR),$(CLASSPATH)\
+ $(PATH_SEPARATOR)$(OUT_COMP_CLASS))
+
+
+# Targets
+.PHONY: ALL
+ALL : DevGuideJobsAddon
+
+include $(SETTINGS)/stdtarget.mk
+
+$(OUT_COMP_CLASS)/%.Manifest :
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ @echo RegistrationClassName: $(basename $(basename $(@F)))> $@
+
+$(CLASSFILES) : $(JAVAFILES)
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ $(SDK_JAVAC) $(JAVAC_FLAGS) -classpath "$(SDK_CLASSPATH)" -d $(OUT_COMP_CLASS) $(JAVAFILES)
+
+# rule for component jar file
+$(COMP_JAR) : $(COMP_MANIFESTFILE) $(CLASSFILES)
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ $(SDK_JAR) cvfm $@ $< -C $(OUT_COMP_CLASS) .
+
+# rule for component package manifest
+$(OUT_COMP_CLASS)/%/manifest.xml :
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ @echo $(OSEP)?xml version="$(QM)1.0$(QM)" encoding="$(QM)UTF-8$(QM)"?$(CSEP) > $@
+ @echo $(OSEP)!DOCTYPE manifest:manifest PUBLIC "$(QM)-//OpenOffice.org//DTD Manifest 1.0//EN$(QM)" "$(QM)Manifest.dtd$(QM)"$(CSEP) >> $@
+ @echo $(OSEP)manifest:manifest xmlns:manifest="$(QM)http://openoffice.org/2001/manifest$(QM)"$(CSEP) >> $@
+ @echo $(SQM) $(SQM)$(OSEP)manifest:file-entry manifest:media-type="$(QM)application/vnd.sun.star.configuration-data$(QM)" >> $@
+ @echo $(SQM) $(SQM)manifest:full-path="$(QM)Addons.xcu$(QM)"/$(CSEP) >> $@
+ @echo $(SQM) $(SQM)$(OSEP)manifest:file-entry manifest:media-type="$(QM)application/vnd.sun.star.configuration-data$(QM)" >> $@
+ @echo $(SQM) $(SQM)manifest:full-path="$(QM)Jobs.xcu$(QM)"/$(CSEP) >> $@
+ @echo $(SQM) $(SQM)$(OSEP)manifest:file-entry manifest:media-type="$(QM)application/vnd.sun.star.uno-components$(QM)">> $@
+ @echo $(SQM) $(SQM)manifest:full-path="$(QM)$(COMP_COMPONENTS)$(QM)"/$(CSEP)>> $@
+ @echo $(OSEP)/manifest:manifest$(CSEP) >> $@
+
+# rule for component package file
+$(COMP_PACKAGE) : $(COMP_JAR) Addons.xcu Jobs.xcu $(COMP_UNOPKG_MANIFEST) $(COMP_COMPONENTS)
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ cd $(subst /,$(PS),$(OUT_CLASS)) && $(SDK_ZIP) ../bin/$(@F) $(<F)
+ $(SDK_ZIP) -u $@ Addons.xcu Jobs.xcu $(COMP_COMPONENTS)
+ cd $(subst /,$(PS),$(OUT_COMP_CLASS)/$(subst .$(UNOOXT_EXT),,$(@F))) && $(SDK_ZIP) -u ../../../bin/$(@F) META-INF/manifest.xml
+
+
+$(REGISTERFLAG) : $(COMP_PACKAGE)
+ifeq "$(SDK_AUTO_DEPLOYMENT)" "YES"
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ $(DEPLOYTOOL) $(COMP_PACKAGE_URL)
+ @echo flagged > $(subst /,$(PS),$@)
+else
+ @echo --------------------------------------------------------------------------------
+ @echo If you want to install your component automatically, please set the environment
+ @echo variable SDK_AUTO_DEPLOYMENT = YES. But note that auto deployment is only
+ @echo possible if no office instance is running.
+ @echo --------------------------------------------------------------------------------
+endif
+
+DevGuideJobsAddon : $(REGISTERFLAG)
+ @echo --------------------------------------------------------------------------------
+ @echo The "$(QM)AsyncJob$(QM)" addon component was installed if SDK_AUTO_DEPLOYMENT = YES.
+ @echo You can use this component inside your office installation, see the example
+ @echo description.
+ @echo --------------------------------------------------------------------------------
+
+%.run: $(OUT_COMP_CLASS)/%.class
+ $(SDK_JAVA) -classpath "$(SDK_CLASSPATH)" $(basename $@)
+
+.PHONY: clean
+clean :
+ -$(DELRECURSIVE) $(subst /,$(PS),$(OUT_COMP_CLASS))
+ -$(DELRECURSIVE) $(subst /,$(PS),$(OUT_COMP_MISC))
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$(COMP_PACKAGE_URL)))
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$(COMP_JAR)))
diff --git a/odk/examples/DevelopersGuide/Components/Addons/ProtocolHandlerAddon_cpp/Addons.xcu b/odk/examples/DevelopersGuide/Components/Addons/ProtocolHandlerAddon_cpp/Addons.xcu
new file mode 100644
index 000000000..77aae07c4
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Components/Addons/ProtocolHandlerAddon_cpp/Addons.xcu
@@ -0,0 +1,207 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!--
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+-->
+<oor:component-data xmlns:oor="http://openoffice.org/2001/registry" xmlns:xs="http://www.w3.org/2001/XMLSchema" oor:name="Addons" oor:package="org.openoffice.Office">
+ <node oor:name="AddonUI">
+ <node oor:name="AddonMenu">
+ <node oor:name="org.openoffice.Office.addon.example.function" oor:op="replace">
+ <prop oor:name="Title" oor:type="xs:string">
+ <value xml:lang="en-US">Add-On example</value>
+ </prop>
+ <prop oor:name="Context" oor:type="xs:string">
+ <value>com.sun.star.text.TextDocument</value>
+ </prop>
+ <node oor:name="Submenu">
+ <node oor:name="m1" oor:op="replace">
+ <prop oor:name="URL" oor:type="xs:string">
+ <value>org.openoffice.Office.addon.example:Function1</value>
+ </prop>
+ <prop oor:name="Title" oor:type="xs:string">
+ <value/>
+ <value xml:lang="en-US">Add-On Function 1</value>
+ </prop>
+ <prop oor:name="Target" oor:type="xs:string">
+ <value>_self</value>
+ </prop>
+ </node>
+ <node oor:name="m2" oor:op="replace">
+ <prop oor:name="URL" oor:type="xs:string">
+ <value>org.openoffice.Office.addon.example:Function2</value>
+ </prop>
+ <prop oor:name="Title" oor:type="xs:string">
+ <value/>
+ <value xml:lang="en-US">Add-On Function 2</value>
+ </prop>
+ <prop oor:name="Target" oor:type="xs:string">
+ <value>_self</value>
+ </prop>
+ </node>
+ </node>
+ </node>
+ </node>
+ <node oor:name="OfficeMenuBar">
+ <node oor:name="org.openoffice.Office.addon.example" oor:op="replace">
+ <prop oor:name="Title" oor:type="xs:string">
+ <value/>
+ <value xml:lang="en-US">Add-On example</value>
+ </prop>
+ <node oor:name="Submenu">
+ <node oor:name="m1" oor:op="replace">
+ <prop oor:name="URL" oor:type="xs:string">
+ <value>org.openoffice.Office.addon.example:Function1</value>
+ </prop>
+ <prop oor:name="Title" oor:type="xs:string">
+ <value/>
+ <value xml:lang="en-US">Add-On Function 1</value>
+ </prop>
+ <prop oor:name="Target" oor:type="xs:string">
+ <value>_self</value>
+ </prop>
+ <prop oor:name="Context" oor:type="xs:string">
+ <value>com.sun.star.text.TextDocument</value>
+ </prop>
+ </node>
+ <node oor:name="m2" oor:op="replace">
+ <prop oor:name="URL" oor:type="xs:string">
+ <value>private:separator</value>
+ </prop>
+ </node>
+ <node oor:name="m3" oor:op="replace">
+ <prop oor:name="URL" oor:type="xs:string">
+ <value/>
+ </prop>
+ <prop oor:name="Title" oor:type="xs:string">
+ <value/>
+ <value xml:lang="en-US">Add-On sub menu</value>
+ </prop>
+ <prop oor:name="Target" oor:type="xs:string">
+ <value>_self</value>
+ </prop>
+ <node oor:name="Submenu">
+ <node oor:name="submenu1" oor:op="replace">
+ <prop oor:name="URL" oor:type="xs:string">
+ <value>org.openoffice.Office.addon.example:Function2</value>
+ </prop>
+ <prop oor:name="Title" oor:type="xs:string">
+ <value/>
+ <value xml:lang="en-US">Add-On Function 2</value>
+ </prop>
+ <prop oor:name="Target" oor:type="xs:string">
+ <value>_self</value>
+ </prop>
+ <prop oor:name="Context" oor:type="xs:string">
+ <value>com.sun.star.sheet.SpreadsheetDocument</value>
+ </prop>
+ </node>
+ </node>
+ </node>
+ </node>
+ </node>
+ </node>
+ <node oor:name="OfficeToolBar">
+ <node oor:name="org.openoffice.Office.addon.example" oor:op="replace">
+ <node oor:name="m1" oor:op="replace">
+ <prop oor:name="URL" oor:type="xs:string">
+ <value>org.openoffice.Office.addon.example:Function1</value>
+ </prop>
+ <prop oor:name="Title" oor:type="xs:string">
+ <value/>
+ <value xml:lang="en-US">Function 1</value>
+ </prop>
+ <prop oor:name="Target" oor:type="xs:string">
+ <value>_self</value>
+ </prop>
+ <prop oor:name="Context" oor:type="xs:string">
+ <value>com.sun.star.text.TextDocument</value>
+ </prop>
+ </node>
+ <node oor:name="m2" oor:op="replace">
+ <prop oor:name="URL" oor:type="xs:string">
+ <value>org.openoffice.Office.addon.example:Function2</value>
+ </prop>
+ <prop oor:name="Title" oor:type="xs:string">
+ <value/>
+ <value xml:lang="en-US">Function 2</value>
+ </prop>
+ <prop oor:name="Target" oor:type="xs:string">
+ <value>_self</value>
+ </prop>
+ <prop oor:name="Context" oor:type="xs:string">
+ <value>com.sun.star.text.TextDocument</value>
+ </prop>
+ </node>
+ </node>
+ </node>
+ <node oor:name="Images">
+ <node oor:name="com.sun.star.comp.framework.addon.image1" oor:op="replace">
+ <prop oor:name="URL">
+ <value>org.openoffice.Office.addon.example:Function1</value>
+ </prop>
+ <node oor:name="UserDefinedImages">
+ <prop oor:name="ImageSmall" oor:type="xs:hexBinary">
+ <value>424df80000000000000076000000280000001000000010000000010004000000000000000000120b0000120b000000000000000000000000ff0000ffff0000ff0000ffff0000ff000000ff00ff00ffffff00c0c0c0008080800000000000000080000080800000800000808000008000000080008000cccccccccccccccc2c266b181b666c2c5cc66b818b6665c555566b181b66655555566b818b66655555566b181b6665555a8666bbb6668a55a0a866666668a0a5000a8666668a000a6000a86668a000a556000a868a000a55556000a8a000a5555556000a000a55555555600000a55555555556000a55555555555560a55555550000</value>
+ </prop>
+ <prop oor:name="ImageBig" oor:type="xs:hexBinary">
+ <value>424d180200000000000076000000280000001a0000001a000000010004000000000000000000120b0000120b000000000000000000000000ff0000ffff0000ff0000ffff0000ff000000ff00ff00ffffff00c0c0c000808080000000000000008000008080000080000080800000800000008000800055555555555555555555555555999990cccccccccccccccccccccccccc9055552cc2c6666b18181b6666c2cc2c99ccccc2ccc6666b81818b66668c2cc5902cc25c2586666b18181b66668ccc5590c2cc555586666b81818b6666855555995c25555586666b18181b6666855555995555555586666b81818b6666855555005555555586666b18181b666685555590555555a5866666b181b6666685a5550955555a0a8666666bbb6666668a0a559955a5a000a866666666666668a000a5995a0a00000a8666666666668a00000a90a000600000a86666666668a00000a50900005600000a866666668a00000a5599600055600000a8666668a00000a555095600555600000a86668a00000a55559955605555600000a868a00000a5555599555655555600000a8a00000a555555005555555555600000a00000a555555590555555555556000000000a555555550955555555555560000000a555555555995555555555555600000a555555555590555555555555556000a555555555550055555555555555560a555555555555905555555555555555555555555555559055550000</value>
+ </prop>
+ <prop oor:name="ImageSmallHC" oor:type="xs:hexBinary">
+ <value>424df60000000000000076000000280000001000000010000000010004000000000080000000120b0000120b000000000000000000000000ff0000ffff0000ff0000ffff0000ff000000ff00ff00ffffff00c0c0c00080808000000000000000800000808000008000008080000080000000800080002222222222222222222996969699922252299669669995255559969696999555555996696699955555599696969995555969996669996955969699999996969566696999996966699666969996966695596669696966695555966696966695555559666966695555555596666695555555555966695555555555559695555555</value>
+ </prop>
+ <prop oor:name="ImageBigHC" oor:type="xs:hexBinary">
+ <value/>
+ </prop>
+ </node>
+ </node>
+ <node oor:name="com.sun.star.comp.framework.addon.image2" oor:op="replace">
+ <prop oor:name="URL">
+ <value>org.openoffice.Office.addon.example:Help</value>
+ </prop>
+ <node oor:name="UserDefinedImages">
+ <prop oor:name="ImageSmall" oor:type="xs:hexBinary">
+ <value>424d36030000000000003600000028000000100000001000000001001800000000000003000000000000000000000000000000000000ff00ffff00ffff00ffff00fff0eeee6c5f602512133c2b2c2b1719594a4bdcd8d8ff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ff5443453a2525d0c5bdffffffffffffffffffe6e7e8493c3c5e514eb7b1b0ff00ffff00ffff00ffff00ffff00ff5c4a4dc0bbbcfffffffbeadee7bca8e7bcabdfb4a2f1c4b0fffffad0d0cd584a4dc5bbb8ff00ffff00ffff00ffddd9d9514449ffffffd49578b7511eb5582ed29d85ce8b6db54513ba5f32eeccb8fffffffffffbd3cfcfff00ffff00ffd9cdc5e0d9dadc9270ba4613bf511dc99076edeae7f2dcced27b54bc4811ba5724d3ad96ffffff402d30ff00ffefeae6e9e0daeabba4ba4308cb5b28cb5f2ecc7046d99979db8f66ce6635cc5d2dbf4e1ab85225ffeee5726361b1aaaad8cbc2ffffffbf4911c65b21cf6532cc5d2bcc764edbae97dfa284ce6a3bcc5b2bcc602ebb4310d28259ffffff332124d7cbc2fffffebb2600d0703bcc612ecb5b2bca7a56dfd3cdf5f4f1e1a686cd6333ce622dc95e2abe3901ffffff2b1a1dd8cdc4ffffffbe2f00d36f40cb602dcb5928c95a29ce8666e9ded7f1dcd2d77e56cd612acc6530c43a00ffffff312125d5c8beffffffcf3f00d66e3dcc632fc95d2ccb5522c44f19cf8c6becd4ccde9b81d06435d05b26c65619ffffff251317d9cdc5fefffff09361e87437da794ad29a7edfa68ad56f3bd5835bedd5cbe3b399d36939db6126e9b395ffffff3f3033f5f2f0ded6d1fff1e4f9a36ff28b52e3b39beeefedf3e5d9f2e7def4f0eaeba87ee66d2fee9e72fffffcb28d89c7c6c6ff00ffcbb6aaffffffffebdcfec08ff6b584edcebbeddaddf3dfdff5cab3f79c66fbaa7dfce8dcffffffb99e9bff00ffff00ffdccbc3e0d6cef2f2f2fffffcfff2d1fadca3f6cf91fac588fdc68bffe4c5fffefaffffffe2d4c8f2efeeff00ffff00ffff00fff0ebe6dfd0c9dbcac2f8f7f4fffffffffffffffffffdf8f2e3d9d1cfbfb4ebe3ddff00ffff00ffff00ffff00ffff00ffff00ffff00fffafaf9e1d6ced5c2b9d9c9c2d5c6beddcfc8f4f0efff00ffff00ffff00ffff00ffff00ff</value>
+ </prop>
+ <prop oor:name="ImageBig" oor:type="xs:hexBinary">
+ <value>424d560800000000000036000000280000001a0000001a00000001001800000000002008000000000000000000000000000000000000ff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ff0000ff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ff524142524142524142524142524142524142524142524142ff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ff0000ff00ffff00ffff00ffff00ffff00ffff00ff524142524142bda69cd6c7bddecfc6ded7d6e7dfd6e7d7cebdbebdb59694524142524142ff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ff0000ff00ffff00ffff00ffff00ffff00ff524142fffffffffffffffffffffffffffffffffffffffffff7f7f7ffffffffffffffefefbdb6ad524142524142ff00ffff00ffff00ffff00ffff00ffff00ff0000ff00ffff00ffff00ffff00ff524142ffffffffffffffffffefefefdedfdebdb6adc6a694d6a68cdebeade7d7ceefefeff7f7f7ffffffefe7deefe7de524142ff00ffff00ffff00ffff00ffff00ff0000ff00ffff00ffff00ffbda69cffffffffffffffffffefe7ded6a68cbd6139bd5929ce6942c6795abd5929bd5931ce8663debeadefefeffffffffff7f7efe7de524142ff00ffff00ffff00ffff00ff0000ff00ffff00ffff00ffbda69cffffffffffffe7cfc6ce7142bd5929bd5929bd6139d6c7bdffffffd69e84bd5929bd5929bd5929d69e7befefefffffffffefef524142ff00ffff00ffff00ffff00ff0000ff00ffff00ffdecfc6ffffffffffffe7cfc6c66139bd5929c66131ce6131bd7152dedfdeffffffe7c7bdce6131ce6131bd5929bd5929ce8e6befefefffffffdecfc6524142ff00ffff00ffff00ff0000ff00ffff00ffdecfc6ffffffefe7e7ce7142c66131ce6131ce6131ce6131c66131d6a68cefcfbdd68652ce6131ce6131ce6131c66131bd5929d6a68cffffffffffff524142ff00ffff00ffff00ff0000ff00ffdecfc6fff7f7ffffffdeae94bd5929ce6131ce6931ce6131ce6131ce6131ce6939d67142ce6131ce6131ce6131ce6131ce6131bd5929c66139f7dfd6ffffffdecfc6524142ff00ffff00ff0000ff00ffdecfc6fffffff7efefd6714ac66131ce6931ce6931ce6131ce6131c66939debeadffefe7de966bc66131ce6131ce6131ce6131ce6131bd5929deae94ffffffffefe7524142ff00ffff00ff0000ff00ffdecfc6ffffffefd7cece6131ce6931ce6931ce6131ce6131ce6131c66939d6d7d6ffffffdeb69cce6131ce6131ce6131ce6131ce6131bd5929ce8e63f7f7f7ffffff524142ff00ffff00ff0000ff00ffdecfc6ffffffefc7adce6131ce6939ce6931ce6131ce6131ce6131ce6131c6a694f7f7f7fff7efd68e63ce6131ce6131ce6131ce6931ce6131d6714af7efefffffff524142ff00ffff00ff0000ff00ffdecfc6ffffffefc7adce6131d66939ce6931ce6131ce6131ce6131ce6131c66139debeadfffffffff7efd68e63ce6131ce6931ce6931ce6131d6714af7efefffffff524142ff00ffff00ff0000ff00ffdecfc6ffffffffcfb5d67139d67142d66939ce6131ce6131ce6131ce6131ce6131c66939d6c7bdffffffffefefd6714ace6131d66939ce6931d68652fff7f7ffffff524142ff00ffff00ff0000ff00ffdecfc6ffffffffe7dee7794ade7142d67139ce6931ce6131ce6131ce6131ce6131ce6131ce7142f7efefffffffe7ae94ce6131d66939d66939d69673ffffffffffff524142ff00ffff00ff0000ff00ffdecfc6ffffffffffffefa67bef8652de7142d6714adebeadefdfcede9e7bce6131ce6131ce6131f7dfd6ffffffefc7add66939de7142d66939efc7b5ffffffffefef524142ff00ffff00ff0000ff00ffdecfc6f7f7f7ffffffffdfc6f7965af78e5ade794acecfceffffffffefe7d68652ce6131d69e84ffffffffffffdeae94d67139de7142ef9663fff7f7ffffffd6c7bd524142ff00ffff00ff0000ff00ffff00ffdecfc6fffffffffffff7c7adff9e6bf7965ad69e84efefeffffffffffff7ffefdeffffffffffffefe7e7ef9663e7864aef8652f7dfceffffffffffffb59694ff00ffff00ffff00ff0000ff00ffff00ffdecfc6f7f7efffffffffffffffd7adffb684ffa673efb69cdedfdeefefefefefefefefefefe7deefae8cf7965aff9663ffcfb5ffffffffffffdecfc6b59694ff00ffff00ffff00ff0000ff00ffff00ffff00ffdecfc6ffffffffffffffffffffefd6ffdfadffc794ffc794efb69cefb69cffbe9cffb684ffae7bffb68cffe7d6fffffffffffff7efe7bdb6adff00ffff00ffff00ffff00ff0000ff00ffff00ffff00ffff00ffdecfc6fffffffffffffffffffffff7ffffe7ffffd6ffefb5ffefb5ffdfadffdfadffefd6fffff7fffffffffffffff7efdecfc6ff00ffff00ffff00ffff00ffff00ff0000ff00ffff00ffff00ffff00ffff00ffdecfc6fff7efffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffdecfc6decfc6ff00ffff00ffff00ffff00ffff00ffff00ff0000ff00ffff00ffff00ffff00ffff00ffff00ffdecfc6decfc6fff7effffffffffffffffffffffffffffffffffffffffff7decfc6decfc6ff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ff0000ff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffdecfc6decfc6decfc6decfc6decfc6decfc6decfc6decfc6ff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ff0000ff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ff0000</value>
+ </prop>
+ <prop oor:name="ImageSmallHC" oor:type="xs:hexBinary">
+ <value>424d36030000000000003600000028000000100000001000000001001800000000000003000000000000000000000000000000000000ff00ffff00ffff00ffff00fff0eeee6c5f602512133c2b2c2b1719594a4bdcd8d8ff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ff5443453a2525d0c5bdffffffffffffffffffe6e7e8493c3c5e514eb7b1b0ff00ffff00ffff00ffff00ffff00ff5c4a4dc0bbbcffffffffffffffffffffffffffffffffffffffffffd0d0cd584a4dc5bbb8ff00ffff00ffff00ffddd9d9514449ffffffffffffffffffffffff251317251317fffffffffffffffffffffffffffffbd3cfcfff00ffff00ffd9cdc5e0d9daffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff402d30ff00ffefeae6e9e0daffffffffffffffffffffffffffffff251317251317ffffffffffffffffffffffffffffff726361b1aaaad8cbc2ffffffffffffffffffffffffffffffffffff251317251317ffffffffffffffffffffffffffffffffffff332124d7cbc2fffffeffffffffffffffffffffffffffffff251317251317000000ffffffffffffffffffffffffffffff2b1a1dd8cdc4ffffffffffffffffffffffffffffffffffffffffff251317251317ffffffffffffffffffffffffffffff312125d5c8beffffffffffffffffffffffffffffffffffffffffffffffff251317251317ffffffffffffffffffffffff251317d9cdc5feffffffffffffffffffffff000000000000ffffffffffff251317251317ffffffffffffffffffffffff3f3033f5f2f0ded6d1ffffffffffffffffff000000251317251317251317251317000000ffffffffffffffffffb28d89c7c6c6ff00ffcbb6aaffffffffffffffffffffffff000000251317251317000000ffffffffffffffffffffffffb99e9bff00ffff00ffdccbc3e0d6cef2f2f2fffffffffffffffffffffffffffffffffffffffffffffefaffffffe2d4c8f2efeeff00ffff00ffff00fff0ebe6dfd0c9dbcac2f8f7f4fffffffffffffffffffdf8f2e3d9d1cfbfb4ebe3ddff00ffff00ffff00ffff00ffff00ffff00ffff00fffafaf9e1d6ced5c2b9d9c9c2d5c6beddcfc8f4f0efff00ffff00ffff00ffff00ffff00ff</value>
+ </prop>
+ <prop oor:name="ImageBigHC" oor:type="xs:hexBinary">
+ <value/>
+ </prop>
+ </node>
+ </node>
+ </node>
+ <node oor:name="OfficeHelp">
+ <node oor:name="com.sun.star.comp.framework.addon" oor:op="replace">
+ <prop oor:name="URL" oor:type="xs:string">
+ <value>org.openoffice.Office.addon.example:Help</value>
+ </prop>
+ <prop oor:name="Title" oor:type="xs:string">
+ <!-- The x-no-translate entry is a marker to prevent l10n tooling from translation. If it is not necessary. -->
+ <value xml:lang="x-no-translate"></value> <value xml:lang="x-no-translate"></value>
+ <value xml:lang="de">Über Add-On Beispiel</value>
+ <value xml:lang="en-US">About Add-On Example</value>
+ </prop>
+ <prop oor:name="Target" oor:type="xs:string">
+ <value>_self</value>
+ </prop>
+ </node>
+ </node>
+ </node>
+</oor:component-data>
diff --git a/odk/examples/DevelopersGuide/Components/Addons/ProtocolHandlerAddon_cpp/Makefile b/odk/examples/DevelopersGuide/Components/Addons/ProtocolHandlerAddon_cpp/Makefile
new file mode 100644
index 000000000..239b7e283
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Components/Addons/ProtocolHandlerAddon_cpp/Makefile
@@ -0,0 +1,153 @@
+#*************************************************************************
+#
+# The Contents of this file are made available subject to the terms of
+# the BSD license.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+# 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+# contributors may be used to endorse or promote products derived
+# from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+# TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+# USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+#**************************************************************************
+
+# Builds the ProtocolHandlerAddon C++ component example of the SDK.
+
+PRJ=../../../../..
+SETTINGS=$(PRJ)/settings
+
+include $(SETTINGS)/settings.mk
+include $(SETTINGS)/std.mk
+
+# Define non-platform/compiler specific settings
+COMP_NAME=ProtocolHandlerAddon_cpp
+COMP_IMPL_NAME=$(COMP_NAME).uno.$(SHAREDLIB_EXT)
+OUT_COMP_INC=$(OUT_INC)/$(COMP_NAME)
+OUT_COMP_GEN=$(OUT_MISC)/$(COMP_NAME)
+OUT_COMP_SLO=$(OUT_SLO)/$(COMP_NAME)
+COMP_PACKAGE = $(OUT_BIN)/$(COMP_NAME).$(UNOOXT_EXT)
+COMP_PACKAGE_URL = $(subst \\,\,"$(COMP_PACKAGE_DIR)$(PS)$(COMP_NAME).$(UNOOXT_EXT)")
+COMP_UNOPKG_MANIFEST = $(OUT_COMP_GEN)/$(COMP_NAME)/META-INF/manifest.xml
+COMP_COMPONENTS = $(OUT_COMP_GEN)/$(COMP_NAME).components
+
+REGISTERFLAG = $(OUT_MISC)/cpp_$(COMP_NAME)_register_component.flag
+
+CXXFILES = component.cxx \
+ addon.cxx
+
+SLOFILES = $(patsubst %.cxx,$(OUT_COMP_SLO)/%.$(OBJ_EXT),$(CXXFILES))
+
+# Targets
+.PHONY: ALL
+ALL : \
+ Example
+
+include $(SETTINGS)/stdtarget.mk
+
+$(OUT_COMP_SLO)/%.$(OBJ_EXT) : %.cxx $(SDKTYPEFLAG)
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ $(CC) $(CC_FLAGS) $(CC_INCLUDES) -I$(OUT_COMP_INC) $(CC_DEFINES) $(CC_OUTPUT_SWITCH)$(subst /,$(PS),$@) $<
+
+ifeq "$(OS)" "WIN"
+$(SHAREDLIB_OUT)/%.$(SHAREDLIB_EXT) : $(SLOFILES)
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ -$(MKDIR) $(subst /,$(PS),$(OUT_COMP_GEN))
+ $(LINK) $(COMP_LINK_FLAGS) /OUT:$@ \
+ /MAP:$(OUT_COMP_GEN)/$(subst $(SHAREDLIB_EXT),map,$(@F)) $(SLOFILES) \
+ $(CPPUHELPERLIB) $(CPPULIB) $(SALLIB) msvcprt.lib $(LIBO_SDK_LDFLAGS_STDLIBS)
+ $(LINK_MANIFEST)
+else
+$(SHAREDLIB_OUT)/%.$(SHAREDLIB_EXT) : $(SLOFILES)
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ $(LINK) $(COMP_LINK_FLAGS) $(LINK_LIBS) -o $@ $(SLOFILES) \
+ $(CPPUHELPERLIB) $(CPPULIB) $(SALLIB) $(STC++LIB)
+ifeq "$(OS)" "MACOSX"
+ $(INSTALL_NAME_URELIBS) $@
+endif
+endif
+
+# rule for component package manifest
+$(OUT_COMP_GEN)/%/manifest.xml :
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ @echo $(OSEP)?xml version="$(QM)1.0$(QM)" encoding="$(QM)UTF-8$(QM)"?$(CSEP) > $@
+ @echo $(OSEP)!DOCTYPE manifest:manifest PUBLIC "$(QM)-//OpenOffice.org//DTD Manifest 1.0//EN$(QM)" "$(QM)Manifest.dtd$(QM)"$(CSEP) >> $@
+ @echo $(OSEP)manifest:manifest xmlns:manifest="$(QM)http://openoffice.org/2001/manifest$(QM)"$(CSEP) >> $@
+ @echo $(SQM) $(SQM)$(OSEP)manifest:file-entry manifest:media-type="$(QM)application/vnd.sun.star.configuration-data$(QM)" >> $@
+ @echo $(SQM) $(SQM)manifest:full-path="$(QM)Addons.xcu$(QM)"/$(CSEP) >> $@
+ @echo $(SQM) $(SQM)$(OSEP)manifest:file-entry manifest:media-type="$(QM)application/vnd.sun.star.configuration-data$(QM)" >> $@
+ @echo $(SQM) $(SQM)manifest:full-path="$(QM)ProtocolHandler.xcu$(QM)"/$(CSEP) >> $@
+ @echo $(SQM) $(SQM)$(OSEP)manifest:file-entry manifest:media-type="$(QM)application/vnd.sun.star.uno-components;platform=$(UNOPKG_PLATFORM)$(QM)">> $@
+ @echo $(SQM) $(SQM)manifest:full-path="$(QM)$(COMP_NAME).components$(QM)"/$(CSEP)>> $@
+ @echo $(OSEP)/manifest:manifest$(CSEP) >> $@
+
+$(COMP_COMPONENTS) :
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ @echo $(OSEP)?xml version="$(QM)1.0$(QM)" encoding="$(QM)UTF-8$(QM)"?$(CSEP) > $@
+ @echo $(OSEP)components xmlns="$(QM)http://openoffice.org/2010/uno-components$(QM)"$(CSEP) >> $@
+ @echo $(SQM) $(SQM)$(OSEP)component loader="$(QM)com.sun.star.loader.SharedLibrary$(QM)" uri="$(QM)$(UNOPKG_PLATFORM)/$(COMP_IMPL_NAME)$(QM)"$(CSEP) >> $@
+ @echo $(SQM) $(SQM)$(OSEP)implementation name="$(QM)org.openoffice.Office.addon.example$(QM)"$(CSEP) >> $@
+ @echo $(SQM) $(SQM)$(OSEP)service name="$(QM)com.sun.star.frame.ProtocolHandler$(QM)"/$(CSEP) >> $@
+ @echo $(SQM) $(SQM)$(OSEP)/implementation$(CSEP) >> $@
+ @echo $(SQM) $(SQM)$(OSEP)/component$(CSEP) >> $@
+ @echo $(OSEP)/components$(CSEP) >> $@
+
+# rule for component package file
+$(COMP_PACKAGE) : $(SHAREDLIB_OUT)/$(COMP_IMPL_NAME) Addons.xcu ProtocolHandler.xcu $(COMP_UNOPKG_MANIFEST) $(COMP_COMPONENTS)
+ -$(MKDIR) $(subst /,$(PS),$(@D)) && $(DEL) $(subst \\,\,$(subst /,$(PS),$@))
+ -$(MKDIR) $(subst /,$(PS),$(OUT_COMP_GEN)/$(UNOPKG_PLATFORM))
+ $(COPY) $(subst /,$(PS),$<) $(subst /,$(PS),$(OUT_COMP_GEN)/$(UNOPKG_PLATFORM))
+ cd $(subst /,$(PS),$(OUT_COMP_GEN)) && $(SDK_ZIP) ../../bin/$(@F) $(COMP_NAME).components
+ cd $(subst /,$(PS),$(OUT_COMP_GEN)) && $(SDK_ZIP) -u ../../bin/$(@F) $(UNOPKG_PLATFORM)/$(<F)
+ $(SDK_ZIP) -u $@ Addons.xcu ProtocolHandler.xcu
+ cd $(subst /,$(PS),$(OUT_COMP_GEN)/$(subst .$(UNOOXT_EXT),,$(@F))) && $(SDK_ZIP) -u ../../../bin/$(@F) META-INF/manifest.xml
+
+$(REGISTERFLAG) : $(COMP_PACKAGE)
+ifeq "$(SDK_AUTO_DEPLOYMENT)" "YES"
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
+ $(DEPLOYTOOL) $(COMP_PACKAGE_URL)
+ @echo flagged > $(subst /,$(PS),$@)
+else
+ @echo --------------------------------------------------------------------------------
+ @echo If you want to install your component automatically, please set the environment
+ @echo variable SDK_AUTO_DEPLOYMENT = YES. But note that auto deployment is only
+ @echo possible if no office instance is running.
+ @echo --------------------------------------------------------------------------------
+endif
+
+Example : $(REGISTERFLAG)
+ @echo --------------------------------------------------------------------------------
+ @echo The "$(QM)ProtocolHandler$(QM)" addon component was installed if SDK_AUTO_DEPLOYMENT = YES.
+ @echo You can use this component inside your office installation, see the example
+ @echo description.
+ @echo --------------------------------------------------------------------------------
+
+.PHONY: clean
+clean :
+ -$(DELRECURSIVE) $(subst /,$(PS),$(OUT_COMP_INC))
+ -$(DELRECURSIVE) $(subst /,$(PS),$(OUT_COMP_GEN))
+ -$(DELRECURSIVE) $(subst /,$(PS),$(OUT_COMP_SLO))
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$(COMP_PACKAGE_URL)))
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$(COMP_COMPONENTS)))
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$(REGISTERFLAG)))
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$(SHAREDLIB_OUT)/$(COMP_NAME).*))
diff --git a/odk/examples/DevelopersGuide/Components/Addons/ProtocolHandlerAddon_cpp/ProtocolHandler.xcu b/odk/examples/DevelopersGuide/Components/Addons/ProtocolHandlerAddon_cpp/ProtocolHandler.xcu
new file mode 100644
index 000000000..eecd51fcf
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Components/Addons/ProtocolHandlerAddon_cpp/ProtocolHandler.xcu
@@ -0,0 +1,27 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!--
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+-->
+<oor:component-data oor:name="ProtocolHandler" 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="HandlerSet">
+ <node oor:name="org.openoffice.Office.addon.example" oor:op="replace">
+ <prop oor:name="Protocols" oor:type="oor:string-list">
+ <value>org.openoffice.Office.addon.example:*</value>
+ </prop>
+ </node>
+ </node>
+</oor:component-data>
diff --git a/odk/examples/DevelopersGuide/Components/Addons/ProtocolHandlerAddon_cpp/addon.cxx b/odk/examples/DevelopersGuide/Components/Addons/ProtocolHandlerAddon_cpp/addon.cxx
new file mode 100644
index 000000000..426caaf36
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Components/Addons/ProtocolHandlerAddon_cpp/addon.cxx
@@ -0,0 +1,230 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+#include <addon.hxx>
+#include <com/sun/star/beans/PropertyValue.hpp>
+#include <com/sun/star/frame/XFrame.hpp>
+#include <com/sun/star/frame/XController.hpp>
+#include <com/sun/star/awt/Toolkit.hpp>
+#include <com/sun/star/awt/XWindowPeer.hpp>
+#include <com/sun/star/awt/WindowAttribute.hpp>
+#include <com/sun/star/awt/XMessageBox.hpp>
+#include <com/sun/star/uno/XComponentContext.hpp>
+#include <cppuhelper/supportsservice.hxx>
+#include <rtl/ustring.hxx>
+
+using rtl::OUString;
+using namespace com::sun::star::uno;
+using namespace com::sun::star::frame;
+using namespace com::sun::star::awt;
+using com::sun::star::beans::PropertyValue;
+using com::sun::star::util::URL;
+
+// This is the service name an Add-On has to implement
+#define SERVICE_NAME "com.sun.star.frame.ProtocolHandler"
+
+
+/**
+ * Show a message box with the UNO based toolkit
+ */
+static void ShowMessageBox( const Reference< XToolkit >& rToolkit, const Reference< XFrame >& rFrame, const OUString& aTitle, const OUString& aMsgText )
+{
+ if ( rFrame.is() && rToolkit.is() )
+ {
+ // describe window properties.
+ WindowDescriptor aDescriptor;
+ aDescriptor.Type = WindowClass_MODALTOP;
+ aDescriptor.WindowServiceName = "infobox";
+ aDescriptor.ParentIndex = -1;
+ aDescriptor.Parent = Reference< XWindowPeer >( rFrame->getContainerWindow(), UNO_QUERY );
+ aDescriptor.Bounds = Rectangle(0,0,300,200);
+ aDescriptor.WindowAttributes = WindowAttribute::BORDER |
+WindowAttribute::MOVEABLE |
+WindowAttribute::CLOSEABLE;
+
+ Reference< XWindowPeer > xPeer = rToolkit->createWindow( aDescriptor );
+ if ( xPeer.is() )
+ {
+ Reference< XMessageBox > xMsgBox( xPeer, UNO_QUERY );
+ if ( xMsgBox.is() )
+ {
+ xMsgBox->setCaptionText( aTitle );
+ xMsgBox->setMessageText( aMsgText );
+ xMsgBox->execute();
+ }
+ }
+ }
+}
+
+/**
+ * Called by the Office framework.
+ * One-time initialization. We have to store the context information
+ * given, like the frame we are bound to, into our members.
+ */
+void SAL_CALL Addon::initialize( const Sequence< Any >& aArguments )
+{
+ Reference < XFrame > xFrame;
+ if ( aArguments.getLength() )
+ {
+ aArguments[0] >>= xFrame;
+ mxFrame = xFrame;
+ }
+
+ // Create the toolkit to have access to it later
+ mxToolkit = Reference< XToolkit >( Toolkit::create(mxContext), UNO_QUERY_THROW );
+}
+
+/**
+ * Called by the Office framework.
+ * We are ask to query the given URL and return a dispatch object if the URL
+ * contains an Add-On command.
+ */
+Reference< XDispatch > SAL_CALL Addon::queryDispatch( const URL& aURL, const ::rtl::OUString& sTargetFrameName, sal_Int32 nSearchFlags )
+{
+ Reference < XDispatch > xRet;
+ if ( aURL.Protocol.equalsAscii("org.openoffice.Office.addon.example:") )
+ {
+ if ( aURL.Path.equalsAscii( "Function1" ) )
+ xRet = this;
+ else if ( aURL.Path.equalsAscii( "Function2" ) )
+ xRet = this;
+ else if ( aURL.Path.equalsAscii( "Help" ) )
+ xRet = this;
+ }
+
+ return xRet;
+}
+
+/**
+ * Called by the Office framework.
+ * We are ask to execute the given Add-On command URL.
+ */
+void SAL_CALL Addon::dispatch( const URL& aURL, const Sequence < PropertyValue >& lArgs )
+{
+ if ( aURL.Protocol.equalsAscii("org.openoffice.Office.addon.example:") )
+ {
+ if ( aURL.Path.equalsAscii( "Function1" ) )
+ {
+ ShowMessageBox( mxToolkit, mxFrame,
+ OUString( "SDK Add-On example" ),
+ OUString( "Function 1 activated" ) );
+ }
+ else if ( aURL.Path.equalsAscii( "Function2" ) )
+ {
+ ShowMessageBox( mxToolkit, mxFrame,
+ OUString( "SDK Add-On example" ),
+ OUString( "Function 2 activated" ) );
+ }
+ else if ( aURL.Path.equalsAscii( "Help" ) )
+ {
+ // Show info box
+ ShowMessageBox( mxToolkit, mxFrame,
+ OUString( "About SDK Add-On example" ),
+ OUString( "This is the SDK Add-On example" ) );
+ }
+ }
+}
+
+/**
+ * Called by the Office framework.
+ * We are ask to query the given sequence of URLs and return dispatch objects if the URLs
+ * contain Add-On commands.
+ */
+Sequence < Reference< XDispatch > > SAL_CALL Addon::queryDispatches( const Sequence < DispatchDescriptor >& seqDescripts )
+{
+ sal_Int32 nCount = seqDescripts.getLength();
+ Sequence < Reference < XDispatch > > lDispatcher( nCount );
+
+ for( sal_Int32 i=0; i<nCount; ++i )
+ lDispatcher[i] = queryDispatch( seqDescripts[i].FeatureURL, seqDescripts[i].FrameName, seqDescripts[i].SearchFlags );
+
+ return lDispatcher;
+}
+
+/**
+ * Called by the Office framework.
+ * We are ask to query the given sequence of URLs and return dispatch objects if the URLs
+ * contain Add-On commands.
+ */
+void SAL_CALL Addon::addStatusListener( const Reference< XStatusListener >& xControl, const URL& aURL )
+{
+}
+
+/**
+ * Called by the Office framework.
+ * We are ask to query the given sequence of URLs and return dispatch objects if the URLs
+ * contain Add-On commands.
+ */
+void SAL_CALL Addon::removeStatusListener( const Reference< XStatusListener >& xControl, const URL& aURL )
+{
+}
+
+// Helper functions for the implementation of UNO component interfaces.
+OUString Addon_getImplementationName()
+{
+ return OUString ( IMPLEMENTATION_NAME );
+}
+
+Sequence< ::rtl::OUString > SAL_CALL Addon_getSupportedServiceNames()
+{
+ Sequence < ::rtl::OUString > aRet(1);
+ ::rtl::OUString* pArray = aRet.getArray();
+ pArray[0] = OUString ( SERVICE_NAME );
+ return aRet;
+}
+
+Reference< XInterface > SAL_CALL Addon_createInstance( const Reference< XComponentContext > & rContext)
+{
+ return (cppu::OWeakObject*) new Addon( rContext );
+}
+
+// Implementation of the recommended/mandatory interfaces of a UNO component.
+// XServiceInfo
+::rtl::OUString SAL_CALL Addon::getImplementationName( )
+{
+ return Addon_getImplementationName();
+}
+
+sal_Bool SAL_CALL Addon::supportsService( const ::rtl::OUString& rServiceName )
+{
+ return cppu::supportsService(this, rServiceName);
+}
+
+Sequence< ::rtl::OUString > SAL_CALL Addon::getSupportedServiceNames( )
+{
+ return Addon_getSupportedServiceNames();
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/Components/Addons/ProtocolHandlerAddon_cpp/addon.hxx b/odk/examples/DevelopersGuide/Components/Addons/ProtocolHandlerAddon_cpp/addon.hxx
new file mode 100644
index 000000000..427b47b2a
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Components/Addons/ProtocolHandlerAddon_cpp/addon.hxx
@@ -0,0 +1,121 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+#ifndef INCLUDED_EXAMPLES_COMPONENTS_ADDONS_PROTOCOLHANDLERADDON_CPP_ADDON_HXX
+#define INCLUDED_EXAMPLES_COMPONENTS_ADDONS_PROTOCOLHANDLERADDON_CPP_ADDON_HXX
+
+#include <com/sun/star/lang/XInitialization.hpp>
+#include <com/sun/star/frame/XDispatchProvider.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <cppuhelper/implbase4.hxx>
+
+#define IMPLEMENTATION_NAME "org.openoffice.Office.addon.example"
+
+namespace com
+{
+ namespace sun
+ {
+ namespace star
+ {
+ namespace frame
+ {
+ class XFrame;
+ }
+ namespace awt
+ {
+ class XToolkit;
+ }
+ namespace uno
+ {
+ class XComponentContext;
+ }
+ }
+ }
+}
+
+class Addon : public cppu::WeakImplHelper4
+<
+ com::sun::star::frame::XDispatchProvider,
+ com::sun::star::frame::XDispatch,
+ com::sun::star::lang::XInitialization,
+ com::sun::star::lang::XServiceInfo
+>
+{
+private:
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > mxContext;
+ ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > mxFrame;
+ ::com::sun::star::uno::Reference< ::com::sun::star::awt::XToolkit > mxToolkit;
+
+public:
+ Addon( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > &rxContext)
+ : mxContext( rxContext ) {}
+
+ // 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& sTargetFrameName, sal_Int32 nSearchFlags );
+ 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 >& seqDescriptor );
+
+ // XDispatch
+ virtual void SAL_CALL dispatch( const ::com::sun::star::util::URL& aURL,
+ const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& lArgs );
+ virtual void SAL_CALL addStatusListener( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XStatusListener >& xControl,
+ const ::com::sun::star::util::URL& aURL );
+ virtual void SAL_CALL removeStatusListener( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XStatusListener >& xControl,
+ const ::com::sun::star::util::URL& aURL );
+
+ // XInitialization
+ virtual void SAL_CALL initialize( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments );
+
+ // XServiceInfo
+ virtual ::rtl::OUString SAL_CALL getImplementationName( );
+ virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName );
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( );
+};
+
+::rtl::OUString Addon_getImplementationName();
+
+sal_Bool SAL_CALL Addon_supportsService( const ::rtl::OUString& ServiceName );
+
+::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL Addon_getSupportedServiceNames( );
+
+::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >
+SAL_CALL Addon_createInstance( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > & rContext);
+
+#endif // INCLUDED_EXAMPLES_COMPONENTS_ADDONS_PROTOCOLHANDLERADDON_CPP_ADDON_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/Components/Addons/ProtocolHandlerAddon_cpp/component.cxx b/odk/examples/DevelopersGuide/Components/Addons/ProtocolHandlerAddon_cpp/component.cxx
new file mode 100644
index 000000000..4d34b5521
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Components/Addons/ProtocolHandlerAddon_cpp/component.cxx
@@ -0,0 +1,92 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+#include <stdio.h>
+#include <rtl/ustring.hxx>
+#include <uno/lbnames.h>
+#include <cppuhelper/queryinterface.hxx>
+#include <cppuhelper/factory.hxx>
+// generated c++ interfaces
+#include <com/sun/star/lang/XSingleComponentFactory.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/registry/XRegistryKey.hpp>
+
+// include our specific addon header to get access to functions and definitions
+#include <addon.hxx>
+
+using namespace ::rtl;
+using namespace ::osl;
+using namespace ::cppu;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::registry;
+
+/**
+ * This function is called to get service factories for an implementation.
+ *
+ * @param pImplName name of implementation
+ * @param pServiceManager a service manager, need for component creation
+ * @param pRegistryKey the registry key for this component, need for persistent data
+ * @return a component factory
+ */
+extern "C" SAL_DLLPUBLIC_EXPORT void * SAL_CALL component_getFactory(const char * pImplName, void * /*pServiceManager*/, void * pRegistryKey)
+{
+ void * pRet = 0;
+
+ if (rtl_str_compare( pImplName, IMPLEMENTATION_NAME ) == 0)
+ {
+ Reference< XSingleComponentFactory > xFactory( createSingleComponentFactory(
+ Addon_createInstance,
+ OUString( IMPLEMENTATION_NAME ),
+ Addon_getSupportedServiceNames() ) );
+
+ if (xFactory.is())
+ {
+ xFactory->acquire();
+ pRet = xFactory.get();
+ }
+ }
+
+ return pRet;
+}
+
+extern "C" SAL_DLLPUBLIC_EXPORT void SAL_CALL
+component_getImplementationEnvironment(
+ char const ** ppEnvTypeName, uno_Environment **)
+{
+ *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/Components/Addons/ProtocolHandlerAddon_java/Addons.xcu b/odk/examples/DevelopersGuide/Components/Addons/ProtocolHandlerAddon_java/Addons.xcu
new file mode 100644
index 000000000..8f302612c
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Components/Addons/ProtocolHandlerAddon_java/Addons.xcu
@@ -0,0 +1,207 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!--
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+-->
+<oor:component-data xmlns:oor="http://openoffice.org/2001/registry" xmlns:xs="http://www.w3.org/2001/XMLSchema" oor:name="Addons" oor:package="org.openoffice.Office">
+ <node oor:name="AddonUI">
+ <node oor:name="AddonMenu">
+ <node oor:name="org.openoffice.Office.addon.example.function" oor:op="replace">
+ <prop oor:name="Title" oor:type="xs:string">
+ <value xml:lang="en-US">Add-On example</value>
+ </prop>
+ <prop oor:name="Context" oor:type="xs:string">
+ <value>com.sun.star.text.TextDocument</value>
+ </prop>
+ <node oor:name="Submenu">
+ <node oor:name="m1" oor:op="replace">
+ <prop oor:name="URL" oor:type="xs:string">
+ <value>org.openoffice.Office.addon.example:Function1</value>
+ </prop>
+ <prop oor:name="Title" oor:type="xs:string">
+ <value/>
+ <value xml:lang="en-US">Add-On Function 1</value>
+ </prop>
+ <prop oor:name="Target" oor:type="xs:string">
+ <value>_self</value>
+ </prop>
+ </node>
+ <node oor:name="m2" oor:op="replace">
+ <prop oor:name="URL" oor:type="xs:string">
+ <value>org.openoffice.Office.addon.example:Function2</value>
+ </prop>
+ <prop oor:name="Title" oor:type="xs:string">
+ <value/>
+ <value xml:lang="en-US">Add-On Function 2</value>
+ </prop>
+ <prop oor:name="Target" oor:type="xs:string">
+ <value>_self</value>
+ </prop>
+ </node>
+ </node>
+ </node>
+ </node>
+ <node oor:name="OfficeMenuBar">
+ <node oor:name="org.openoffice.Office.addon.example" oor:op="replace">
+ <prop oor:name="Title" oor:type="xs:string">
+ <value/>
+ <value xml:lang="en-US">Add-On example</value>
+ </prop>
+ <node oor:name="Submenu">
+ <node oor:name="m1" oor:op="replace">
+ <prop oor:name="URL" oor:type="xs:string">
+ <value>org.openoffice.Office.addon.example:Function1</value>
+ </prop>
+ <prop oor:name="Title" oor:type="xs:string">
+ <value/>
+ <value xml:lang="en-US">Add-On Function 1</value>
+ </prop>
+ <prop oor:name="Target" oor:type="xs:string">
+ <value>_self</value>
+ </prop>
+ <prop oor:name="Context" oor:type="xs:string">
+ <value>com.sun.star.text.TextDocument</value>
+ </prop>
+ </node>
+ <node oor:name="m2" oor:op="replace">
+ <prop oor:name="URL" oor:type="xs:string">
+ <value>private:separator</value>
+ </prop>
+ </node>
+ <node oor:name="m3" oor:op="replace">
+ <prop oor:name="URL" oor:type="xs:string">
+ <value/>
+ </prop>
+ <prop oor:name="Title" oor:type="xs:string">
+ <value/>
+ <value xml:lang="en-US">Add-On sub menu</value>
+ </prop>
+ <prop oor:name="Target" oor:type="xs:string">
+ <value>_self</value>
+ </prop>
+ <node oor:name="Submenu">
+ <node oor:name="submenu1" oor:op="replace">
+ <prop oor:name="URL" oor:type="xs:string">
+ <value>org.openoffice.Office.addon.example:Function2</value>
+ </prop>
+ <prop oor:name="Title" oor:type="xs:string">
+ <value/>
+ <value xml:lang="en-US">Add-On Function 2</value>
+ </prop>
+ <prop oor:name="Target" oor:type="xs:string">
+ <value>_self</value>
+ </prop>
+ <prop oor:name="Context" oor:type="xs:string">
+ <value>com.sun.star.sheet.SpreadsheetDocument</value>
+ </prop>
+ </node>
+ </node>
+ </node>
+ </node>
+ </node>
+ </node>
+ <node oor:name="OfficeToolBar">
+ <node oor:name="org.openoffice.Office.addon.example" oor:op="replace">
+ <node oor:name="m1" oor:op="replace">
+ <prop oor:name="URL" oor:type="xs:string">
+ <value>org.openoffice.Office.addon.example:Function1</value>
+ </prop>
+ <prop oor:name="Title" oor:type="xs:string">
+ <value/>
+ <value xml:lang="en-US">Function 1</value>
+ </prop>
+ <prop oor:name="Target" oor:type="xs:string">
+ <value>_self</value>
+ </prop>
+ <prop oor:name="Context" oor:type="xs:string">
+ <value>com.sun.star.text.TextDocument</value>
+ </prop>
+ </node>
+ <node oor:name="m2" oor:op="replace">
+ <prop oor:name="URL" oor:type="xs:string">
+ <value>org.openoffice.Office.addon.example:Function2</value>
+ </prop>
+ <prop oor:name="Title" oor:type="xs:string">
+ <value/>
+ <value xml:lang="en-US">Function 2</value>
+ </prop>
+ <prop oor:name="Target" oor:type="xs:string">
+ <value>_self</value>
+ </prop>
+ <prop oor:name="Context" oor:type="xs:string">
+ <value>com.sun.star.text.TextDocument</value>
+ </prop>
+ </node>
+ </node>
+ </node>
+ <node oor:name="Images">
+ <node oor:name="com.sun.star.comp.framework.addon.image1" oor:op="replace">
+ <prop oor:name="URL">
+ <value>org.openoffice.Office.addon.example:Function1</value>
+ </prop>
+ <node oor:name="UserDefinedImages">
+ <prop oor:name="ImageSmall" oor:type="xs:hexBinary">
+ <value>424df80000000000000076000000280000001000000010000000010004000000000000000000120b0000120b000000000000000000000000ff0000ffff0000ff0000ffff0000ff000000ff00ff00ffffff00c0c0c0008080800000000000000080000080800000800000808000008000000080008000cccccccccccccccc2c266b181b666c2c5cc66b818b6665c555566b181b66655555566b818b66655555566b181b6665555a8666bbb6668a55a0a866666668a0a5000a8666668a000a6000a86668a000a556000a868a000a55556000a8a000a5555556000a000a55555555600000a55555555556000a55555555555560a55555550000</value>
+ </prop>
+ <prop oor:name="ImageBig" oor:type="xs:hexBinary">
+ <value>424d180200000000000076000000280000001a0000001a000000010004000000000000000000120b0000120b000000000000000000000000ff0000ffff0000ff0000ffff0000ff000000ff00ff00ffffff00c0c0c000808080000000000000008000008080000080000080800000800000008000800055555555555555555555555555999990cccccccccccccccccccccccccc9055552cc2c6666b18181b6666c2cc2c99ccccc2ccc6666b81818b66668c2cc5902cc25c2586666b18181b66668ccc5590c2cc555586666b81818b6666855555995c25555586666b18181b6666855555995555555586666b81818b6666855555005555555586666b18181b666685555590555555a5866666b181b6666685a5550955555a0a8666666bbb6666668a0a559955a5a000a866666666666668a000a5995a0a00000a8666666666668a00000a90a000600000a86666666668a00000a50900005600000a866666668a00000a5599600055600000a8666668a00000a555095600555600000a86668a00000a55559955605555600000a868a00000a5555599555655555600000a8a00000a555555005555555555600000a00000a555555590555555555556000000000a555555550955555555555560000000a555555555995555555555555600000a555555555590555555555555556000a555555555550055555555555555560a555555555555905555555555555555555555555555559055550000</value>
+ </prop>
+ <prop oor:name="ImageSmallHC" oor:type="xs:hexBinary">
+ <value>424df60000000000000076000000280000001000000010000000010004000000000080000000120b0000120b000000000000000000000000ff0000ffff0000ff0000ffff0000ff000000ff00ff00ffffff00c0c0c00080808000000000000000800000808000008000008080000080000000800080002222222222222222222996969699922252299669669995255559969696999555555996696699955555599696969995555969996669996955969699999996969566696999996966699666969996966695596669696966695555966696966695555559666966695555555596666695555555555966695555555555559695555555</value>
+ </prop>
+ <prop oor:name="ImageBigHC" oor:type="xs:hexBinary">
+ <value/>
+ </prop>
+ </node>
+ </node>
+ <node oor:name="com.sun.star.comp.framework.addon.image2" oor:op="replace">
+ <prop oor:name="URL">
+ <value>org.openoffice.Office.addon.example:Help</value>
+ </prop>
+ <node oor:name="UserDefinedImages">
+ <prop oor:name="ImageSmall" oor:type="xs:hexBinary">
+ <value>424d36030000000000003600000028000000100000001000000001001800000000000003000000000000000000000000000000000000ff00ffff00ffff00ffff00fff0eeee6c5f602512133c2b2c2b1719594a4bdcd8d8ff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ff5443453a2525d0c5bdffffffffffffffffffe6e7e8493c3c5e514eb7b1b0ff00ffff00ffff00ffff00ffff00ff5c4a4dc0bbbcfffffffbeadee7bca8e7bcabdfb4a2f1c4b0fffffad0d0cd584a4dc5bbb8ff00ffff00ffff00ffddd9d9514449ffffffd49578b7511eb5582ed29d85ce8b6db54513ba5f32eeccb8fffffffffffbd3cfcfff00ffff00ffd9cdc5e0d9dadc9270ba4613bf511dc99076edeae7f2dcced27b54bc4811ba5724d3ad96ffffff402d30ff00ffefeae6e9e0daeabba4ba4308cb5b28cb5f2ecc7046d99979db8f66ce6635cc5d2dbf4e1ab85225ffeee5726361b1aaaad8cbc2ffffffbf4911c65b21cf6532cc5d2bcc764edbae97dfa284ce6a3bcc5b2bcc602ebb4310d28259ffffff332124d7cbc2fffffebb2600d0703bcc612ecb5b2bca7a56dfd3cdf5f4f1e1a686cd6333ce622dc95e2abe3901ffffff2b1a1dd8cdc4ffffffbe2f00d36f40cb602dcb5928c95a29ce8666e9ded7f1dcd2d77e56cd612acc6530c43a00ffffff312125d5c8beffffffcf3f00d66e3dcc632fc95d2ccb5522c44f19cf8c6becd4ccde9b81d06435d05b26c65619ffffff251317d9cdc5fefffff09361e87437da794ad29a7edfa68ad56f3bd5835bedd5cbe3b399d36939db6126e9b395ffffff3f3033f5f2f0ded6d1fff1e4f9a36ff28b52e3b39beeefedf3e5d9f2e7def4f0eaeba87ee66d2fee9e72fffffcb28d89c7c6c6ff00ffcbb6aaffffffffebdcfec08ff6b584edcebbeddaddf3dfdff5cab3f79c66fbaa7dfce8dcffffffb99e9bff00ffff00ffdccbc3e0d6cef2f2f2fffffcfff2d1fadca3f6cf91fac588fdc68bffe4c5fffefaffffffe2d4c8f2efeeff00ffff00ffff00fff0ebe6dfd0c9dbcac2f8f7f4fffffffffffffffffffdf8f2e3d9d1cfbfb4ebe3ddff00ffff00ffff00ffff00ffff00ffff00ffff00fffafaf9e1d6ced5c2b9d9c9c2d5c6beddcfc8f4f0efff00ffff00ffff00ffff00ffff00ff</value>
+ </prop>
+ <prop oor:name="ImageBig" oor:type="xs:hexBinary">
+ <value>424d560800000000000036000000280000001a0000001a00000001001800000000002008000000000000000000000000000000000000ff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ff0000ff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ff524142524142524142524142524142524142524142524142ff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ff0000ff00ffff00ffff00ffff00ffff00ffff00ff524142524142bda69cd6c7bddecfc6ded7d6e7dfd6e7d7cebdbebdb59694524142524142ff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ff0000ff00ffff00ffff00ffff00ffff00ff524142fffffffffffffffffffffffffffffffffffffffffff7f7f7ffffffffffffffefefbdb6ad524142524142ff00ffff00ffff00ffff00ffff00ffff00ff0000ff00ffff00ffff00ffff00ff524142ffffffffffffffffffefefefdedfdebdb6adc6a694d6a68cdebeade7d7ceefefeff7f7f7ffffffefe7deefe7de524142ff00ffff00ffff00ffff00ffff00ff0000ff00ffff00ffff00ffbda69cffffffffffffffffffefe7ded6a68cbd6139bd5929ce6942c6795abd5929bd5931ce8663debeadefefeffffffffff7f7efe7de524142ff00ffff00ffff00ffff00ff0000ff00ffff00ffff00ffbda69cffffffffffffe7cfc6ce7142bd5929bd5929bd6139d6c7bdffffffd69e84bd5929bd5929bd5929d69e7befefefffffffffefef524142ff00ffff00ffff00ffff00ff0000ff00ffff00ffdecfc6ffffffffffffe7cfc6c66139bd5929c66131ce6131bd7152dedfdeffffffe7c7bdce6131ce6131bd5929bd5929ce8e6befefefffffffdecfc6524142ff00ffff00ffff00ff0000ff00ffff00ffdecfc6ffffffefe7e7ce7142c66131ce6131ce6131ce6131c66131d6a68cefcfbdd68652ce6131ce6131ce6131c66131bd5929d6a68cffffffffffff524142ff00ffff00ffff00ff0000ff00ffdecfc6fff7f7ffffffdeae94bd5929ce6131ce6931ce6131ce6131ce6131ce6939d67142ce6131ce6131ce6131ce6131ce6131bd5929c66139f7dfd6ffffffdecfc6524142ff00ffff00ff0000ff00ffdecfc6fffffff7efefd6714ac66131ce6931ce6931ce6131ce6131c66939debeadffefe7de966bc66131ce6131ce6131ce6131ce6131bd5929deae94ffffffffefe7524142ff00ffff00ff0000ff00ffdecfc6ffffffefd7cece6131ce6931ce6931ce6131ce6131ce6131c66939d6d7d6ffffffdeb69cce6131ce6131ce6131ce6131ce6131bd5929ce8e63f7f7f7ffffff524142ff00ffff00ff0000ff00ffdecfc6ffffffefc7adce6131ce6939ce6931ce6131ce6131ce6131ce6131c6a694f7f7f7fff7efd68e63ce6131ce6131ce6131ce6931ce6131d6714af7efefffffff524142ff00ffff00ff0000ff00ffdecfc6ffffffefc7adce6131d66939ce6931ce6131ce6131ce6131ce6131c66139debeadfffffffff7efd68e63ce6131ce6931ce6931ce6131d6714af7efefffffff524142ff00ffff00ff0000ff00ffdecfc6ffffffffcfb5d67139d67142d66939ce6131ce6131ce6131ce6131ce6131c66939d6c7bdffffffffefefd6714ace6131d66939ce6931d68652fff7f7ffffff524142ff00ffff00ff0000ff00ffdecfc6ffffffffe7dee7794ade7142d67139ce6931ce6131ce6131ce6131ce6131ce6131ce7142f7efefffffffe7ae94ce6131d66939d66939d69673ffffffffffff524142ff00ffff00ff0000ff00ffdecfc6ffffffffffffefa67bef8652de7142d6714adebeadefdfcede9e7bce6131ce6131ce6131f7dfd6ffffffefc7add66939de7142d66939efc7b5ffffffffefef524142ff00ffff00ff0000ff00ffdecfc6f7f7f7ffffffffdfc6f7965af78e5ade794acecfceffffffffefe7d68652ce6131d69e84ffffffffffffdeae94d67139de7142ef9663fff7f7ffffffd6c7bd524142ff00ffff00ff0000ff00ffff00ffdecfc6fffffffffffff7c7adff9e6bf7965ad69e84efefeffffffffffff7ffefdeffffffffffffefe7e7ef9663e7864aef8652f7dfceffffffffffffb59694ff00ffff00ffff00ff0000ff00ffff00ffdecfc6f7f7efffffffffffffffd7adffb684ffa673efb69cdedfdeefefefefefefefefefefe7deefae8cf7965aff9663ffcfb5ffffffffffffdecfc6b59694ff00ffff00ffff00ff0000ff00ffff00ffff00ffdecfc6ffffffffffffffffffffefd6ffdfadffc794ffc794efb69cefb69cffbe9cffb684ffae7bffb68cffe7d6fffffffffffff7efe7bdb6adff00ffff00ffff00ffff00ff0000ff00ffff00ffff00ffff00ffdecfc6fffffffffffffffffffffff7ffffe7ffffd6ffefb5ffefb5ffdfadffdfadffefd6fffff7fffffffffffffff7efdecfc6ff00ffff00ffff00ffff00ffff00ff0000ff00ffff00ffff00ffff00ffff00ffdecfc6fff7efffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffdecfc6decfc6ff00ffff00ffff00ffff00ffff00ffff00ff0000ff00ffff00ffff00ffff00ffff00ffff00ffdecfc6decfc6fff7effffffffffffffffffffffffffffffffffffffffff7decfc6decfc6ff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ff0000ff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffdecfc6decfc6decfc6decfc6decfc6decfc6decfc6decfc6ff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ff0000ff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ff0000</value>
+ </prop>
+ <prop oor:name="ImageSmallHC" oor:type="xs:hexBinary">
+ <value>424d36030000000000003600000028000000100000001000000001001800000000000003000000000000000000000000000000000000ff00ffff00ffff00ffff00fff0eeee6c5f602512133c2b2c2b1719594a4bdcd8d8ff00ffff00ffff00ffff00ffff00ffff00ffff00ffff00ff5443453a2525d0c5bdffffffffffffffffffe6e7e8493c3c5e514eb7b1b0ff00ffff00ffff00ffff00ffff00ff5c4a4dc0bbbcffffffffffffffffffffffffffffffffffffffffffd0d0cd584a4dc5bbb8ff00ffff00ffff00ffddd9d9514449ffffffffffffffffffffffff251317251317fffffffffffffffffffffffffffffbd3cfcfff00ffff00ffd9cdc5e0d9daffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff402d30ff00ffefeae6e9e0daffffffffffffffffffffffffffffff251317251317ffffffffffffffffffffffffffffff726361b1aaaad8cbc2ffffffffffffffffffffffffffffffffffff251317251317ffffffffffffffffffffffffffffffffffff332124d7cbc2fffffeffffffffffffffffffffffffffffff251317251317000000ffffffffffffffffffffffffffffff2b1a1dd8cdc4ffffffffffffffffffffffffffffffffffffffffff251317251317ffffffffffffffffffffffffffffff312125d5c8beffffffffffffffffffffffffffffffffffffffffffffffff251317251317ffffffffffffffffffffffff251317d9cdc5feffffffffffffffffffffff000000000000ffffffffffff251317251317ffffffffffffffffffffffff3f3033f5f2f0ded6d1ffffffffffffffffff000000251317251317251317251317000000ffffffffffffffffffb28d89c7c6c6ff00ffcbb6aaffffffffffffffffffffffff000000251317251317000000ffffffffffffffffffffffffb99e9bff00ffff00ffdccbc3e0d6cef2f2f2fffffffffffffffffffffffffffffffffffffffffffffefaffffffe2d4c8f2efeeff00ffff00ffff00fff0ebe6dfd0c9dbcac2f8f7f4fffffffffffffffffffdf8f2e3d9d1cfbfb4ebe3ddff00ffff00ffff00ffff00ffff00ffff00ffff00fffafaf9e1d6ced5c2b9d9c9c2d5c6beddcfc8f4f0efff00ffff00ffff00ffff00ffff00ff</value>
+ </prop>
+ <prop oor:name="ImageBigHC" oor:type="xs:hexBinary">
+ <value/>
+ </prop>
+ </node>
+ </node>
+ </node>
+ <node oor:name="OfficeHelp">
+ <node oor:name="com.sun.star.comp.framework.addon" oor:op="replace">
+ <prop oor:name="URL" oor:type="xs:string">
+ <value>org.openoffice.Office.addon.example:Help</value>
+ </prop>
+ <prop oor:name="Title" oor:type="xs:string">
+ <!-- The x-no-translate entry is a marker to prevent l10n tooling from translation. If it is not necessary. -->
+ <value xml:lang="x-no-translate"></value>
+ <value xml:lang="de">Über Add-On Beispiel</value>
+ <value xml:lang="en-US">About Add-On Example</value>
+ </prop>
+ <prop oor:name="Target" oor:type="xs:string">
+ <value>_self</value>
+ </prop>
+ </node>
+ </node>
+ </node>
+</oor:component-data>
diff --git a/odk/examples/DevelopersGuide/Components/Addons/ProtocolHandlerAddon_java/Makefile b/odk/examples/DevelopersGuide/Components/Addons/ProtocolHandlerAddon_java/Makefile
new file mode 100644
index 000000000..fb1edb6b8
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Components/Addons/ProtocolHandlerAddon_java/Makefile
@@ -0,0 +1,138 @@
+#*************************************************************************
+#
+# The Contents of this file are made available subject to the terms of
+# the BSD license.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+# 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+# contributors may be used to endorse or promote products derived
+# from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+# TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+# USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+#**************************************************************************
+
+# Builds the ProtocolHandlerAddon Java component example of the SDK.
+
+PRJ=../../../../..
+SETTINGS=$(PRJ)/settings
+
+include $(SETTINGS)/settings.mk
+include $(SETTINGS)/std.mk
+
+# Define non-platform/compiler specific settings
+COMP_NAME=ProtocolHandlerAddon_java
+OUT_COMP_CLASS=$(OUT_CLASS)/$(COMP_NAME)
+OUT_COMP_MISC=$(OUT_MISC)/$(COMP_NAME)
+COMP_PACKAGE=$(OUT_BIN)/$(COMP_NAME).$(UNOOXT_EXT)
+COMP_PACKAGE_URL=$(subst \\,\,"$(COMP_PACKAGE_DIR)$(PS)$(COMP_NAME).$(UNOOXT_EXT)")
+COMP_JAR_NAME=$(COMP_NAME).uno.jar
+COMP_JAR=$(OUT_CLASS)/$(COMP_JAR_NAME)
+COMP_MANIFESTFILE=$(OUT_COMP_CLASS)/$(COMP_NAME).uno.Manifest
+COMP_UNOPKG_MANIFEST = $(OUT_COMP_CLASS)/$(COMP_NAME)/META-INF/manifest.xml
+COMP_COMPONENTS=$(COMP_NAME).components
+
+REGISTERFLAG=$(OUT_COMP_MISC)$(PS)java_$(COMP_NAME)_register_component.flag
+
+JAVAFILES = ProtocolHandlerAddon.java
+
+CLASSFILES = $(patsubst %.java,$(OUT_COMP_CLASS)/%.class,$(JAVAFILES))
+
+SDK_CLASSPATH = $(subst $(EMPTYSTRING) $(PATH_SEPARATOR),$(PATH_SEPARATOR),$(CLASSPATH)\
+ $(PATH_SEPARATOR)$(OUT_COMP_CLASS))
+
+
+# Targets
+.PHONY: ALL
+ALL : DevGuideProtocolHandlerAddon
+
+include $(SETTINGS)/stdtarget.mk
+
+$(OUT_COMP_CLASS)/%.Manifest :
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ @echo RegistrationClassName: ProtocolHandlerAddon> $@
+
+$(CLASSFILES) : $(JAVAFILES)
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ $(SDK_JAVAC) $(JAVAC_FLAGS) -classpath "$(SDK_CLASSPATH)" -d $(OUT_COMP_CLASS) $(JAVAFILES)
+
+# rule for component jar file
+$(COMP_JAR) : $(COMP_MANIFESTFILE) $(CLASSFILES)
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ $(SDK_JAR) cvfm $@ $< -C $(OUT_COMP_CLASS) .
+
+# rule for component package manifest
+$(OUT_COMP_CLASS)/%/manifest.xml :
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ @echo $(OSEP)?xml version="$(QM)1.0$(QM)" encoding="$(QM)UTF-8$(QM)"?$(CSEP) > $@
+ @echo $(OSEP)!DOCTYPE manifest:manifest PUBLIC "$(QM)-//OpenOffice.org//DTD Manifest 1.0//EN$(QM)" "$(QM)Manifest.dtd$(QM)"$(CSEP) >> $@
+ @echo $(OSEP)manifest:manifest xmlns:manifest="$(QM)http://openoffice.org/2001/manifest$(QM)"$(CSEP) >> $@
+ @echo $(SQM) $(SQM)$(OSEP)manifest:file-entry manifest:media-type="$(QM)application/vnd.sun.star.configuration-data$(QM)" >> $@
+ @echo $(SQM) $(SQM)manifest:full-path="$(QM)Addons.xcu$(QM)"/$(CSEP) >> $@
+ @echo $(SQM) $(SQM)$(OSEP)manifest:file-entry manifest:media-type="$(QM)application/vnd.sun.star.configuration-data$(QM)" >> $@
+ @echo $(SQM) $(SQM)manifest:full-path="$(QM)ProtocolHandler.xcu$(QM)"/$(CSEP) >> $@
+ @echo $(SQM) $(SQM)$(OSEP)manifest:file-entry manifest:media-type="$(QM)application/vnd.sun.star.uno-components$(QM)">> $@
+ @echo $(SQM) $(SQM)manifest:full-path="$(QM)$(COMP_COMPONENTS)$(QM)"/$(CSEP)>> $@
+ @echo $(OSEP)/manifest:manifest$(CSEP) >> $@
+
+# rule for component package file
+$(COMP_PACKAGE) : $(COMP_JAR) Addons.xcu ProtocolHandler.xcu $(COMP_UNOPKG_MANIFEST) $(COMP_COMPONENTS)
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ -$(MKDIR) $(subst /,$(PS),$(OUT_COMP_MISC))
+ $(COPY) $(subst /,$(PS),$<) $(subst /,$(PS),$(OUT_COMP_MISC))
+ cd $(subst /,$(PS),$(OUT_COMP_MISC)) && $(SDK_ZIP) ../../bin/$(@F) $(<F)
+ $(SDK_ZIP) -u $@ Addons.xcu ProtocolHandler.xcu $(COMP_COMPONENTS)
+ cd $(subst /,$(PS),$(OUT_COMP_CLASS)/$(subst .$(UNOOXT_EXT),,$(@F))) && $(SDK_ZIP) -u ../../../bin/$(@F) META-INF/manifest.xml
+
+$(REGISTERFLAG) : $(COMP_PACKAGE)
+ifeq "$(SDK_AUTO_DEPLOYMENT)" "YES"
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ $(DEPLOYTOOL) $(COMP_PACKAGE_URL)
+ @echo flagged > $(subst /,$(PS),$@)
+else
+ @echo --------------------------------------------------------------------------------
+ @echo If you want to install your component automatically, please set the environment
+ @echo variable SDK_AUTO_DEPLOYMENT = YES. But note that auto deployment is only
+ @echo possible if no office instance is running.
+ @echo --------------------------------------------------------------------------------
+endif
+
+DevGuideProtocolHandlerAddon : $(REGISTERFLAG)
+ @echo --------------------------------------------------------------------------------
+ @echo The "$(QM)ProtocolHandler$(QM)" addon component was installed if SDK_AUTO_DEPLOYMENT = YES.
+ @echo You can use this component inside your office installation, see the example
+ @echo description.
+ @echo --------------------------------------------------------------------------------
+
+%.run: $(OUT_COMP_CLASS)/%.class
+ $SDJ_JAVA) -classpath "$(SDK_CLASSPATH)" $(basename $@)
+
+.PHONY: clean
+clean :
+ -$(DELRECURSIVE) $(subst /,$(PS),$(OUT_COMP_CLASS))
+ -$(DELRECURSIVE) $(subst /,$(PS),$(OUT_COMP_MISC))
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$(COMP_PACKAGE_URL)))
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$(COMP_JAR)))
diff --git a/odk/examples/DevelopersGuide/Components/Addons/ProtocolHandlerAddon_java/ProtocolHandler.xcu b/odk/examples/DevelopersGuide/Components/Addons/ProtocolHandlerAddon_java/ProtocolHandler.xcu
new file mode 100644
index 000000000..7974c3e95
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Components/Addons/ProtocolHandlerAddon_java/ProtocolHandler.xcu
@@ -0,0 +1,27 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!--
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+-->
+<oor:component-data oor:name="ProtocolHandler" 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="HandlerSet">
+ <node oor:name="ProtocolHandlerAddon$ProtocolHandlerAddonImpl" oor:op="replace">
+ <prop oor:name="Protocols" oor:type="oor:string-list">
+ <value>org.openoffice.Office.addon.example:*</value>
+ </prop>
+ </node>
+ </node>
+</oor:component-data>
diff --git a/odk/examples/DevelopersGuide/Components/Addons/ProtocolHandlerAddon_java/ProtocolHandlerAddon.java b/odk/examples/DevelopersGuide/Components/Addons/ProtocolHandlerAddon_java/ProtocolHandlerAddon.java
new file mode 100644
index 000000000..c12c69288
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Components/Addons/ProtocolHandlerAddon_java/ProtocolHandlerAddon.java
@@ -0,0 +1,254 @@
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+import com.sun.star.uno.XComponentContext;
+import com.sun.star.lib.uno.helper.Factory;
+import com.sun.star.lang.XSingleComponentFactory;
+import com.sun.star.lib.uno.helper.WeakBase;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.lang.XInitialization;
+import com.sun.star.lang.XServiceInfo;
+import com.sun.star.frame.XStatusListener;
+import com.sun.star.frame.XDispatchProvider;
+import com.sun.star.frame.XDispatch;
+import com.sun.star.frame.XFrame;
+import com.sun.star.frame.DispatchDescriptor;
+import com.sun.star.awt.XToolkit;
+import com.sun.star.awt.XWindowPeer;
+import com.sun.star.awt.XMessageBox;
+import com.sun.star.awt.WindowAttribute;
+import com.sun.star.awt.WindowClass;
+import com.sun.star.awt.WindowDescriptor;
+import com.sun.star.awt.Rectangle;
+
+public class ProtocolHandlerAddon {
+ /** This class implements the component. At least the interfaces XServiceInfo,
+ * XTypeProvider, and XInitialization should be provided by the service.
+ */
+ public static class ProtocolHandlerAddonImpl extends WeakBase implements
+ XDispatchProvider,
+ XDispatch,
+ XInitialization,
+ XServiceInfo {
+
+ /** The service name, that must be used to get an instance of this service.
+ */
+ private static final String[] m_serviceNames = { "com.sun.star.frame.ProtocolHandler" };
+
+ /** The component context, that gives access to the service manager and all registered services.
+ */
+ private final XComponentContext m_xCmpCtx;
+
+ /** The toolkit, that we can create UNO dialogs.
+ */
+ private XToolkit m_xToolkit;
+
+ /** The frame where the addon depends on.
+ */
+ private XFrame m_xFrame;
+
+
+ /** The constructor of the inner class has a XMultiServiceFactory parameter.
+ * @param xComponentContext A special service factory
+ * could be introduced while initializing.
+ */
+ public ProtocolHandlerAddonImpl( XComponentContext xComponentContext ) {
+ m_xCmpCtx = xComponentContext;
+ }
+
+ /** This method is a member of the interface for initializing an object
+ * directly after its creation.
+ * @param object This array of arbitrary objects will be passed to the
+ * component after its creation.
+ * @throws com.sun.star.uno.Exception Every exception will not be handled, but will be
+ * passed to the caller.
+ */
+ public void initialize( Object[] object )
+ throws com.sun.star.uno.Exception {
+
+ if ( object.length > 0 )
+ {
+ m_xFrame = UnoRuntime.queryInterface(
+ XFrame.class, object[ 0 ] );
+ }
+
+ // Create the toolkit to have access to it later
+ m_xToolkit = UnoRuntime.queryInterface(
+ XToolkit.class,
+ m_xCmpCtx.getServiceManager().createInstanceWithContext("com.sun.star.awt.Toolkit",
+ m_xCmpCtx));
+ }
+
+ /** This method returns an array of all supported service names.
+ * @return Array of supported service names.
+ */
+ public String[] getSupportedServiceNames() {
+ return getServiceNames();
+ }
+
+ public static String[] getServiceNames() {
+ return m_serviceNames;
+ }
+
+ /** This method returns true, if the given service will be
+ * supported by the component.
+ * @return True, if the given service name will be supported.
+ */
+ public boolean supportsService( String sService ) {
+ int len = m_serviceNames.length;
+
+ for( int i=0; i < len; i++) {
+ if ( sService.equals( m_serviceNames[i] ) )
+ return true;
+ }
+
+ return false;
+ }
+
+ /** Return the class name of the component.
+ * @return Class name of the component.
+ */
+ public String getImplementationName() {
+ return ProtocolHandlerAddonImpl.class.getName();
+ }
+
+ // XDispatchProvider
+ public XDispatch queryDispatch( /*IN*/com.sun.star.util.URL aURL,
+ /*IN*/String sTargetFrameName,
+ /*IN*/int iSearchFlags ) {
+ XDispatch xRet = null;
+ if ( aURL.Protocol.equals("org.openoffice.Office.addon.example:") ) {
+ if ( aURL.Path.equals( "Function1" ) )
+ xRet = this;
+ if ( aURL.Path.equals( "Function2" ) )
+ xRet = this;
+ if ( aURL.Path.equals( "Help" ) )
+ xRet = this;
+ }
+ return xRet;
+ }
+
+ public XDispatch[] queryDispatches( /*IN*/DispatchDescriptor[] seqDescripts ) {
+ int nCount = seqDescripts.length;
+ XDispatch[] lDispatcher = new XDispatch[nCount];
+
+ for( int i=0; i<nCount; ++i )
+ lDispatcher[i] = queryDispatch( seqDescripts[i].FeatureURL,
+ seqDescripts[i].FrameName,
+ seqDescripts[i].SearchFlags );
+
+ return lDispatcher;
+ }
+
+ // XDispatch
+ public void dispatch( /*IN*/com.sun.star.util.URL aURL,
+ /*IN*/com.sun.star.beans.PropertyValue[] aArguments ) {
+
+ if ( aURL.Protocol.equals("org.openoffice.Office.addon.example:") )
+ {
+ if ( aURL.Path.equals( "Function1" ) )
+ {
+ showMessageBox("SDK DevGuide Add-On example", "Function 1 activated");
+ }
+ if ( aURL.Path.equals( "Function2" ) )
+ {
+ showMessageBox("SDK DevGuide Add-On example", "Function 2 activated");
+ }
+ if ( aURL.Path.equals( "Help" ) )
+ {
+ showMessageBox("About SDK DevGuide Add-On example", "This is the SDK Add-On example");
+ }
+ }
+ }
+
+ public void addStatusListener( /*IN*/XStatusListener xControl,
+ /*IN*/com.sun.star.util.URL aURL ) {
+ }
+
+ public void removeStatusListener( /*IN*/XStatusListener xControl,
+ /*IN*/com.sun.star.util.URL aURL ) {
+ }
+
+ public void showMessageBox(String sTitle, String sMessage) {
+ if ( null == m_xFrame || null == m_xToolkit ) {
+ return;
+ }
+ // describe window properties.
+ WindowDescriptor aDescriptor = new WindowDescriptor();
+ aDescriptor.Type = WindowClass.MODALTOP;
+ aDescriptor.WindowServiceName = "infobox";
+ aDescriptor.ParentIndex = -1;
+ aDescriptor.Parent = UnoRuntime.queryInterface(
+ XWindowPeer.class, m_xFrame.getContainerWindow());
+ aDescriptor.Bounds = new Rectangle(0,0,300,200);
+ aDescriptor.WindowAttributes = WindowAttribute.BORDER |
+ WindowAttribute.MOVEABLE |
+ WindowAttribute.CLOSEABLE;
+
+ XWindowPeer xPeer = m_xToolkit.createWindow( aDescriptor );
+ if ( null != xPeer ) {
+ XMessageBox xMsgBox = UnoRuntime.queryInterface(
+ XMessageBox.class, xPeer);
+ if ( null != xMsgBox )
+ {
+ xMsgBox.setCaptionText( sTitle );
+ xMsgBox.setMessageText( sMessage );
+ xMsgBox.execute();
+ }
+ }
+ }
+ }
+
+
+ /** Gives a factory for creating the service.
+ * This method is called by the <code>JavaLoader</code>
+ * <p>
+ * @return Returns a <code>XSingleServiceFactory</code> for creating the
+ * component.
+ * @see com.sun.star.comp.loader.JavaLoader
+ * @param sImplementationName The implementation name of the component.
+ */
+ public static XSingleComponentFactory __getComponentFactory( String sImplementationName ) {
+ XSingleComponentFactory xFactory = null;
+
+ if ( sImplementationName.equals( ProtocolHandlerAddonImpl.class.getName() ) )
+ xFactory = Factory.createComponentFactory(ProtocolHandlerAddonImpl.class,
+ ProtocolHandlerAddonImpl.getServiceNames());
+
+ return xFactory;
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/Components/Addons/ProtocolHandlerAddon_java/ProtocolHandlerAddon_java.components b/odk/examples/DevelopersGuide/Components/Addons/ProtocolHandlerAddon_java/ProtocolHandlerAddon_java.components
new file mode 100644
index 000000000..13665ebbc
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Components/Addons/ProtocolHandlerAddon_java/ProtocolHandlerAddon_java.components
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<components xmlns="http://openoffice.org/2010/uno-components">
+ <component loader="com.sun.star.loader.Java2" uri="ProtocolHandlerAddon_java.uno.jar">
+ <implementation name="ProtocolHandlerAddon$ProtocolHandlerAddonImpl">
+ <service name="com.sun.star.frame.ProtocolHandler"/>
+ </implementation>
+ </component>
+</components>
diff --git a/odk/examples/DevelopersGuide/Components/CppComponent/Makefile b/odk/examples/DevelopersGuide/Components/CppComponent/Makefile
new file mode 100644
index 000000000..2a5b876a4
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Components/CppComponent/Makefile
@@ -0,0 +1,228 @@
+#*************************************************************************
+#
+# The Contents of this file are made available subject to the terms of
+# the BSD license.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+# 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+# contributors may be used to endorse or promote products derived
+# from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+# TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+# USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+#**************************************************************************
+
+# Builds the C++ component example of the Developers Guide.
+
+PRJ=../../../..
+SETTINGS=$(PRJ)/settings
+
+include $(SETTINGS)/settings.mk
+include $(SETTINGS)/std.mk
+
+# Define non-platform/compiler specific settings
+SAMPLE_NAME=CppComponentSample
+SAMPLE_INC_OUT=$(OUT_INC)/$(SAMPLE_NAME)
+SAMPLE_GEN_OUT=$(OUT_MISC)/$(SAMPLE_NAME)
+SAMPLE_SLO_OUT=$(OUT_SLO)/$(SAMPLE_NAME)
+SAMPLE_OBJ_OUT=$(OUT_OBJ)/$(SAMPLE_NAME)
+
+COMP_NAME=CppComponent
+COMP_IMPL_NAME=$(COMP_NAME).uno.$(SHAREDLIB_EXT)
+
+APP1_NAME= TestCppComponent
+APP1_BINARY= $(OUT_BIN)/$(APP1_NAME)$(EXE_EXT)
+
+COMP_RDB_NAME = $(COMP_NAME).uno.rdb
+COMP_RDB = $(SAMPLE_GEN_OUT)/$(COMP_RDB_NAME)
+COMP_PACKAGE = $(OUT_BIN)/$(COMP_NAME).$(UNOOXT_EXT)
+COMP_PACKAGE_URL = $(subst \\,\,"$(COMP_PACKAGE_DIR)$(PS)$(COMP_NAME).$(UNOOXT_EXT)")
+COMP_UNOPKG_MANIFEST = $(SAMPLE_GEN_OUT)/$(COMP_NAME)/META-INF/manifest.xml
+COMP_COMPONENTS = $(SAMPLE_GEN_OUT)/$(COMP_NAME).components
+COMP_DESCRIPTION = $(SAMPLE_GEN_OUT)/description.xml
+
+COMP_REGISTERFLAG = $(SAMPLE_GEN_OUT)/devguide_$(COMP_NAME)_register_component.flag
+COMP_TYPEFLAG = $(SAMPLE_GEN_OUT)/devguide_$(COMP_NAME)_types.flag
+
+IDLFILES = some.idl
+
+CXXFILES = service1_impl.cxx \
+ service2_impl.cxx
+
+SLOFILES = $(patsubst %.cxx,$(SAMPLE_SLO_OUT)/%.$(OBJ_EXT),$(CXXFILES))
+
+TYPESLIST=-Tmymodule.XSomething \
+ -Tmymodule.MyService1 \
+ -Tmymodule.MyService2
+
+# Targets
+.PHONY: ALL
+ALL : \
+ $(SAMPLE_NAME)
+
+include $(SETTINGS)/stdtarget.mk
+
+$(SAMPLE_GEN_OUT)/%.rdb : $(IDLFILES)
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ $(UNOIDLWRITE) $(URE_TYPES) $(OFFICE_TYPES) $< $@
+
+$(COMP_TYPEFLAG) : $(COMP_RDB) $(SDKTYPEFLAG)
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ $(CPPUMAKER) -Gc -O$(SAMPLE_INC_OUT) $(TYPESLIST) $(COMP_RDB) -X$(URE_TYPES) -X$(OFFICE_TYPES)
+ echo flagged > $@
+
+$(SAMPLE_SLO_OUT)/%.$(OBJ_EXT) : %.cxx $(COMP_TYPEFLAG)
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ $(CC) $(CC_FLAGS) $(CC_INCLUDES) -I$(SAMPLE_INC_OUT) $(CC_DEFINES) $(CC_OUTPUT_SWITCH)$(subst /,$(PS),$@) $<
+
+ifeq "$(OS)" "WIN"
+$(SHAREDLIB_OUT)/%.$(SHAREDLIB_EXT) : $(SLOFILES)
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ -$(MKDIR) $(subst /,$(PS),$(SAMPLE_GEN_OUT))
+ $(LINK) $(COMP_LINK_FLAGS) /OUT:$@ \
+ /MAP:$(SAMPLE_GEN_OUT)/$(subst $(SHAREDLIB_EXT),map,$(@F)) $(SLOFILES) \
+ $(CPPUHELPERLIB) $(CPPULIB) $(SALLIB) msvcprt.lib $(LIBO_SDK_LDFLAGS_STDLIBS)
+ $(LINK_MANIFEST)
+else
+$(SHAREDLIB_OUT)/%.$(SHAREDLIB_EXT) : $(SLOFILES)
+ -$(MKDIR) $(subst /,$(PS),$(@D)) && $(DEL) $(subst \\,\,$(subst /,$(PS),$@))
+ $(LINK) $(COMP_LINK_FLAGS) $(LINK_LIBS) -o $@ $(SLOFILES) \
+ $(CPPUHELPERLIB) $(CPPULIB) $(SALLIB) $(STC++LIB)
+ifeq "$(OS)" "MACOSX"
+ $(INSTALL_NAME_URELIBS) $@
+endif
+endif
+
+# rule for component package manifest
+$(SAMPLE_GEN_OUT)/%/manifest.xml :
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ @echo $(OSEP)?xml version="$(QM)1.0$(QM)" encoding="$(QM)UTF-8$(QM)"?$(CSEP) > $@
+ @echo $(OSEP)!DOCTYPE manifest:manifest PUBLIC "$(QM)-//OpenOffice.org//DTD Manifest 1.0//EN$(QM)" "$(QM)Manifest.dtd$(QM)"$(CSEP) >> $@
+ @echo $(OSEP)manifest:manifest xmlns:manifest="$(QM)http://openoffice.org/2001/manifest$(QM)"$(CSEP) >> $@
+ @echo $(SQM) $(SQM)$(OSEP)manifest:file-entry manifest:media-type="$(QM)application/vnd.sun.star.uno-typelibrary;type=RDB$(QM)" >> $@
+ @echo $(SQM) $(SQM)manifest:full-path="$(QM)$(subst /META-INF,,$(subst $(SAMPLE_GEN_OUT)/,,$(@D))).uno.rdb$(QM)"/$(CSEP) >> $@
+ @echo $(SQM) $(SQM)$(OSEP)manifest:file-entry manifest:media-type="$(QM)application/vnd.sun.star.uno-components;platform=$(UNOPKG_PLATFORM)$(QM)">> $@
+ @echo $(SQM) $(SQM)manifest:full-path="$(QM)$(COMP_NAME).components$(QM)"/$(CSEP)>> $@
+ @echo $(OSEP)/manifest:manifest$(CSEP) >> $@
+
+$(COMP_COMPONENTS) :
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ @echo $(OSEP)?xml version="$(QM)1.0$(QM)" encoding="$(QM)UTF-8$(QM)"?$(CSEP) > $@
+ @echo $(OSEP)components xmlns="$(QM)http://openoffice.org/2010/uno-components$(QM)"$(CSEP) >> $@
+ @echo $(SQM) $(SQM)$(OSEP)component loader="$(QM)com.sun.star.loader.SharedLibrary$(QM)" uri="$(QM)$(UNOPKG_PLATFORM)/$(COMP_IMPL_NAME)$(QM)"$(CSEP) >> $@
+ @echo $(SQM) $(SQM)$(OSEP)implementation name="$(QM)mymodule.my_sc_implementation.MyService1$(QM)"$(CSEP) >> $@
+ @echo $(SQM) $(SQM)$(OSEP)service name="$(QM)mymodule.MyService1$(QM)"/$(CSEP) >> $@
+ @echo $(SQM) $(SQM)$(OSEP)/implementation$(CSEP) >> $@
+ @echo $(SQM) $(SQM)$(OSEP)implementation name="$(QM)mymodule.my_sc_implementation.MyService2$(QM)"$(CSEP) >> $@
+ @echo $(SQM) $(SQM)$(OSEP)service name="$(QM)mymodule.MyService2$(QM)"/$(CSEP) >> $@
+ @echo $(SQM) $(SQM)$(OSEP)/implementation$(CSEP) >> $@
+ @echo $(SQM) $(SQM)$(OSEP)/component$(CSEP) >> $@
+ @echo $(OSEP)/components$(CSEP) >> $@
+
+$(COMP_DESCRIPTION) : description.xml
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ cp $^ $@
+
+$(COMP_PACKAGE) : $(SHAREDLIB_OUT)/$(COMP_IMPL_NAME) $(COMP_RDB) $(COMP_UNOPKG_MANIFEST) $(COMP_COMPONENTS) $(COMP_DESCRIPTION)
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ -$(MKDIR) $(subst /,$(PS),$(SAMPLE_GEN_OUT)/$(UNOPKG_PLATFORM))
+ $(COPY) $(subst /,$(PS),$<) $(subst /,$(PS),$(SAMPLE_GEN_OUT)/$(UNOPKG_PLATFORM))
+ cd $(subst /,$(PS),$(SAMPLE_GEN_OUT)) && $(SDK_ZIP) ../../bin/$(@F) $(COMP_NAME).components description.xml
+ cd $(subst /,$(PS),$(SAMPLE_GEN_OUT)) && $(SDK_ZIP) -u ../../bin/$(@F) $(COMP_RDB_NAME) $(UNOPKG_PLATFORM)/$(<F)
+ cd $(subst /,$(PS),$(SAMPLE_GEN_OUT)/$(subst .$(UNOOXT_EXT),,$(@F))) && $(SDK_ZIP) -u ../../../bin/$(@F) META-INF/manifest.xml
+
+
+$(COMP_REGISTERFLAG) : $(COMP_PACKAGE)
+ifeq "$(SDK_AUTO_DEPLOYMENT)" "YES"
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ $(DEPLOYTOOL) $(COMP_PACKAGE_URL)
+ @echo flagged > $(subst /,$(PS),$@)
+else
+ @echo --------------------------------------------------------------------------------
+ @echo If you want to install your component automatically, please set the environment
+ @echo variable SDK_AUTO_DEPLOYMENT = YES. But note that auto deployment is only
+ @echo possible if no office instance is running.
+ @echo --------------------------------------------------------------------------------
+endif
+
+$(SAMPLE_OBJ_OUT)/$(APP1_NAME).$(OBJ_EXT) : $(APP1_NAME).cxx $(COMP_TYPEFLAG)
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ $(CC) $(CC_FLAGS) $(CC_INCLUDES) -I$(SAMPLE_INC_OUT) $(CC_DEFINES) $(CC_OUTPUT_SWITCH)$(subst /,$(PS),$@) $<
+
+$(OUT_BIN)/_$(APP1_NAME)$(EXE_EXT) : $(SAMPLE_OBJ_OUT)/$(APP1_NAME).$(OBJ_EXT)
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ -$(MKDIR) $(subst /,$(PS),$(SAMPLE_GEN_OUT))
+ifeq "$(OS)" "WIN"
+ $(LINK) $(EXE_LINK_FLAGS) /OUT:$@ /MAP:$(SAMPLE_GEN_OUT)/$(basename $(@F)).map \
+ $< $(CPPUHELPERLIB) $(CPPULIB) $(SALHELPERLIB) $(SALLIB)
+else
+ $(LINK) $(EXE_LINK_FLAGS) $(LINK_LIBS) -o $@ $< \
+ $(CPPUHELPERLIB) $(CPPULIB) $(SALHELPERLIB) $(SALLIB) $(STDC++LIB)
+ifeq "$(OS)" "MACOSX"
+ $(INSTALL_NAME_URELIBS_BIN) $@
+endif
+endif
+
+$(OUT_BIN)/$(APP1_NAME)$(EXE_EXT) : $(OUT_BIN)/_$(APP1_NAME)$(EXE_EXT)
+ $(COPY) $(subst /,$(PS),$(BIN_DIR)/unoapploader$(EXE_EXT)) $(subst /,$(PS),$@)
+# touch the target to renew the date for correct dependencies.
+# Note: no touch under windows! The unoapploader.exe is copied always.
+ifneq "$(OS)" "WIN"
+ touch $@
+endif
+
+$(SAMPLE_NAME) : $(COMP_REGISTERFLAG) $(APP1_BINARY)
+ @echo --------------------------------------------------------------------------------
+ @echo Please use the following command to execute the example!
+ @echo -
+ @echo $(MAKE) $(APP1_NAME).run
+ @echo --------
+ @echo The simple C++ component was installed if SDK_AUTO_DEPLOYMENT = YES.
+ @echo You can use this component inside your office installation, see the example
+ @echo description. You can also load the "$(QM)SimpleComponent.odt$(QM)" document containing
+ @echo a StarBasic macro which uses this component.
+ @echo -
+ @echo $(MAKE) SimpleComponent.odt.load
+ @echo --------------------------------------------------------------------------------
+
+%.run: $(OUT_BIN)/%$(EXE_EXT)
+ $(subst /,$(PS),$(OUT_BIN))$(PS)$(basename $@)
+# cd $(subst /,$(PS),$(OUT_BIN)) && $(basename $@)
+
+SimpleComponent.odt.load : $(COMP_REGISTERFLAG)
+ "$(OFFICE_PROGRAM_PATH)$(PS)soffice" $(basename $@)
+
+.PHONY: clean
+clean :
+ -$(DELRECURSIVE) $(subst /,$(PS),$(SAMPLE_INC_OUT))
+ -$(DELRECURSIVE) $(subst /,$(PS),$(SAMPLE_GEN_OUT))
+ -$(DELRECURSIVE) $(subst /,$(PS),$(SAMPLE_SLO_OUT))
+ -$(DELRECURSIVE) $(subst /,$(PS),$(SAMPLE_OBJ_OUT))
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$(COMP_COMPONENTS)))
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$(COMP_DESCRIPTION)))
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$(OUT_BIN)/$(COMP_NAME)*))
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$(OUT_BIN)/*$(APP1_NAME)*))
diff --git a/odk/examples/DevelopersGuide/Components/CppComponent/SimpleComponent.odt b/odk/examples/DevelopersGuide/Components/CppComponent/SimpleComponent.odt
new file mode 100644
index 000000000..e8d7e9133
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Components/CppComponent/SimpleComponent.odt
Binary files differ
diff --git a/odk/examples/DevelopersGuide/Components/CppComponent/TestCppComponent.cxx b/odk/examples/DevelopersGuide/Components/CppComponent/TestCppComponent.cxx
new file mode 100644
index 000000000..95d46dd2b
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Components/CppComponent/TestCppComponent.cxx
@@ -0,0 +1,93 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+#include <stdio.h>
+#include <sal/main.h>
+#include <cppuhelper/bootstrap.hxx>
+#include <com/sun/star/bridge/XUnoUrlResolver.hpp>
+#include <com/sun/star/frame/XComponentLoader.hpp>
+#include <mymodule/MyService1.hpp>
+#include <mymodule/MyService2.hpp>
+
+using namespace com::sun::star::uno;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::frame;
+
+using ::rtl::OUString;
+using ::rtl::OUStringToOString;
+
+SAL_IMPLEMENT_MAIN()
+{
+ try
+ {
+ // get the remote office component context
+ Reference< XComponentContext > xContext( ::cppu::bootstrap() );
+ fprintf(stdout, "\nconnected to a running office...\n");
+
+ // create a new instance of MyService1
+ Reference<mymodule::XSomething> xSomething =
+ mymodule::MyService1::create(xContext);
+
+ // call methodOne and print the return value on stdout
+ OUString s = xSomething->methodOne(OUString("Hello World!"));
+ fprintf(stdout,"\nCreate new instance of MyService1\nCall of XSomething.methOne at MyService1 = %s", OUStringToOString( s, RTL_TEXTENCODING_ASCII_US ).getStr());
+
+ // create a new instance of MyService2 with the specified string argument
+ xSomething = mymodule::MyService2::create(xContext, OUString("Hello My World!"));
+
+ // call methodTwo and print the return value of methodTwo
+ s = xSomething->methodTwo();
+ fprintf(stdout, "\n\nCreate new instance of MyService2 with argument\nCall of XSomething.methTwo at MyService2 = %s", OUStringToOString( s, RTL_TEXTENCODING_ASCII_US ).getStr());
+
+ fprintf(stdout, "\n\nPlease press 'return' to finish the example!\n");
+ getchar();
+ }
+ catch ( ::cppu::BootstrapException & e )
+ {
+ fprintf(stderr, "\ncaught BootstrapException: %s\n",
+ OUStringToOString( e.getMessage(), RTL_TEXTENCODING_ASCII_US ).getStr());
+ return 1;
+ }
+ catch ( Exception & e )
+ {
+ fprintf(stderr, "\ncaught UNO exception: %s\n",
+ OUStringToOString( e.Message, RTL_TEXTENCODING_ASCII_US ).getStr());
+ return 1;
+ }
+
+ return 0;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/Components/CppComponent/description.xml b/odk/examples/DevelopersGuide/Components/CppComponent/description.xml
new file mode 100644
index 000000000..6c4e2396b
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Components/CppComponent/description.xml
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+-->
+<d:description xmlns:d="http://openoffice.org/extensions/description/2006">
+ <d:dependencies>
+ <l:LibreOffice-minimal-version value="4.1" d:name="LibreOffice 4.1"
+ xmlns:l="http://libreoffice.org/extensions/description/2011"/>
+ </d:dependencies>
+</d:description>
diff --git a/odk/examples/DevelopersGuide/Components/CppComponent/service1_impl.cxx b/odk/examples/DevelopersGuide/Components/CppComponent/service1_impl.cxx
new file mode 100644
index 000000000..11320c252
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Components/CppComponent/service1_impl.cxx
@@ -0,0 +1,211 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+#include <osl/interlck.h>
+#include <osl/mutex.hxx>
+#include <cppuhelper/factory.hxx>
+#include <cppuhelper/supportsservice.hxx>
+
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/lang/XTypeProvider.hpp>
+#include <mymodule/XSomething.hpp>
+
+
+using namespace ::rtl; // for OUString
+using namespace ::com::sun::star; // for odk interfaces
+using namespace ::com::sun::star::uno; // for basic types
+
+namespace my_sc_impl
+{
+
+Sequence< OUString > SAL_CALL getSupportedServiceNames_MyService1Impl()
+{
+ Sequence< OUString > names(1);
+ names[0] = "mymodule.MyService1";
+ return names;
+}
+
+OUString SAL_CALL getImplementationName_MyService1Impl()
+{
+ return OUString("mymodule.my_sc_implementation.MyService1");
+}
+
+
+class MyService1Impl
+ : public ::mymodule::XSomething
+ , public lang::XServiceInfo
+ , public lang::XTypeProvider
+{
+ oslInterlockedCount m_refcount;
+ OUString m_sData;
+ // it's good practice to store the context for further use when you use
+ // other UNO API's in your implementation
+ Reference< XComponentContext > m_xContext;
+public:
+ inline MyService1Impl(Reference< XComponentContext > const & xContext) throw ()
+ : m_refcount( 0 ),
+ m_xContext(xContext)
+ {}
+
+ virtual ~MyService1Impl() {}
+
+ // XInterface
+ virtual Any SAL_CALL queryInterface( Type const & type );
+ virtual void SAL_CALL acquire()
+ throw ();
+ virtual void SAL_CALL release()
+ throw ();
+ // XTypeProvider
+ virtual Sequence< Type > SAL_CALL getTypes();
+ virtual Sequence< sal_Int8 > SAL_CALL getImplementationId();
+ // XSomething
+ virtual OUString SAL_CALL methodOne( OUString const & str );
+ virtual OUString SAL_CALL methodTwo( );
+ // XServiceInfo
+ virtual OUString SAL_CALL getImplementationName();
+ virtual sal_Bool SAL_CALL supportsService( OUString const & serviceName );
+ virtual Sequence< OUString > SAL_CALL getSupportedServiceNames();
+};
+
+// XInterface implementation
+Any MyService1Impl::queryInterface( Type const & type )
+{
+ if (type.equals(::cppu::UnoType<XInterface>::get()))
+ {
+ // return XInterface interface
+ // (resolve ambiguity by casting to lang::XTypeProvider)
+ Reference< XInterface > x(
+ static_cast< lang::XTypeProvider * >( this ) );
+ return makeAny( x );
+ }
+ if (type.equals(::cppu::UnoType<lang::XTypeProvider>::get()))
+ {
+ // return XInterface interface
+ Reference< XInterface > x(
+ static_cast< lang::XTypeProvider * >( this ) );
+ return makeAny( x );
+ }
+ if (type.equals(::cppu::UnoType<lang::XServiceInfo>::get()))
+ {
+ // return XServiceInfo interface
+ Reference< lang::XServiceInfo > x(
+ static_cast< lang::XServiceInfo * >( this ) );
+ return makeAny( x );
+ }
+ if (type.equals(::cppu::UnoType<mymodule::XSomething>::get()))
+ {
+ // return sample interface
+ Reference< ::mymodule::XSomething > x(
+ static_cast< ::mymodule::XSomething * >( this ) );
+ return makeAny( x );
+ }
+ // querying for unsupported type
+ return Any();
+}
+
+void MyService1Impl::acquire()
+ throw ()
+{
+ // thread-safe incrementation of reference count
+ ::osl_atomic_increment( &m_refcount );
+}
+
+void MyService1Impl::release()
+ throw ()
+{
+ // thread-safe decrementation of reference count
+ if (0 == ::osl_atomic_decrement( &m_refcount ))
+ {
+ delete this; // shutdown this object
+ }
+}
+
+// XTypeProvider implementation
+Sequence< Type > MyService1Impl::getTypes()
+{
+ Sequence< Type > seq( 3 );
+ seq[ 0 ] = ::cppu::UnoType<lang::XTypeProvider>::get();
+ seq[ 1 ] = ::cppu::UnoType<lang::XServiceInfo>::get();
+ seq[ 2 ] = ::cppu::UnoType<mymodule::XSomething>::get();
+ return seq;
+}
+
+Sequence< sal_Int8 > MyService1Impl::getImplementationId()
+{
+ return css::uno::Sequence<sal_Int8>();
+}
+
+// XSomething implementation
+OUString MyService1Impl::methodOne( OUString const & str )
+{
+ m_sData = str;
+ return OUString( "called methodOne() of MyService1 implementation: " ) + m_sData;
+}
+
+OUString MyService1Impl::methodTwo( )
+{
+ return OUString( "called methodTwo() of MyService1 implementation: " ) + m_sData;
+}
+
+// XServiceInfo implementation
+OUString MyService1Impl::getImplementationName()
+{
+ // unique implementation name
+ return OUString("mymodule.my_sc_implementation.MyService1");
+}
+sal_Bool MyService1Impl::supportsService( OUString const & serviceName )
+{
+ return cppu::supportsService(this, serviceName);
+}
+Sequence< OUString > MyService1Impl::getSupportedServiceNames()
+{
+ // this object only supports one service
+ OUString serviceName("mymodule.MyService1");
+ return Sequence< OUString >( &serviceName, 1 );
+}
+
+Reference< XInterface > SAL_CALL create_MyService1Impl(
+ Reference< XComponentContext > const & xContext )
+{
+ return static_cast< lang::XTypeProvider * >( new MyService1Impl( xContext) );
+}
+
+// forward decl: implemented in service2_impl.cxx
+Reference< XInterface > SAL_CALL create_MyService2Impl(
+ Reference< XComponentContext > const & );
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/Components/CppComponent/service2_impl.cxx b/odk/examples/DevelopersGuide/Components/CppComponent/service2_impl.cxx
new file mode 100644
index 000000000..eecaec5a3
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Components/CppComponent/service2_impl.cxx
@@ -0,0 +1,203 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+#include <cppuhelper/implbase3.hxx>
+#include <cppuhelper/factory.hxx>
+#include <cppuhelper/implementationentry.hxx>
+#include <cppuhelper/supportsservice.hxx>
+#include <uno/lbnames.h>
+
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/lang/XInitialization.hpp>
+#include <com/sun/star/lang/IllegalArgumentException.hpp>
+#include <mymodule/XSomething.hpp>
+
+
+using namespace ::rtl; // for OUString
+using namespace ::com::sun::star; // for odk interfaces
+using namespace ::com::sun::star::uno; // for basic types
+
+
+namespace my_sc_impl
+{
+
+extern Sequence< OUString > SAL_CALL getSupportedServiceNames_MyService1Impl();
+extern OUString SAL_CALL getImplementationName_MyService1Impl();
+extern Reference< XInterface > SAL_CALL create_MyService1Impl(
+ Reference< XComponentContext > const & xContext );
+
+static Sequence< OUString > getSupportedServiceNames_MyService2Impl()
+{
+ Sequence<OUString> names(1);
+ names[0] = "mymodule.MyService2";
+ return names;
+}
+
+static OUString getImplementationName_MyService2Impl()
+{
+ return OUString("mymodule.my_sc_implementation.MyService2");
+}
+
+class MyService2Impl : public ::cppu::WeakImplHelper3<
+ ::mymodule::XSomething, lang::XServiceInfo, lang::XInitialization >
+{
+ OUString m_sData;
+ // it's good practice to store the context for further use when you use
+ // other UNO API's in your implementation
+ Reference< XComponentContext > m_xContext;
+public:
+ inline MyService2Impl(Reference< XComponentContext > const & xContext) throw ()
+ : m_xContext(xContext)
+ {}
+
+ virtual ~MyService2Impl() {}
+
+ // focus on three given interfaces,
+ // no need to implement XInterface, XTypeProvider, XWeak
+
+ // XInitialization will be called upon
+ // createInstanceWithArguments[AndContext]()
+ virtual void SAL_CALL initialize( Sequence< Any > const & args );
+ // XSomething
+ virtual OUString SAL_CALL methodOne( OUString const & str );
+ virtual OUString SAL_CALL methodTwo( );
+ // XServiceInfo
+ virtual OUString SAL_CALL getImplementationName();
+ virtual sal_Bool SAL_CALL supportsService( OUString const & serviceName );
+ virtual Sequence< OUString > SAL_CALL getSupportedServiceNames();
+};
+
+// XInitialization implementation
+void MyService2Impl::initialize( Sequence< Any > const & args )
+{
+ if (args.getLength() != 1)
+ {
+ throw lang::IllegalArgumentException(
+ OUString(
+ "give a string instantiating this component!"),
+ // resolve to XInterface reference:
+ static_cast< ::cppu::OWeakObject * >(this),
+ 0 ); // argument pos
+ }
+ if (! (args[ 0 ] >>= m_sData))
+ {
+ throw lang::IllegalArgumentException(
+ OUString(
+ "no string given as argument!"),
+ // resolve to XInterface reference:
+ static_cast< ::cppu::OWeakObject * >(this),
+ 0 ); // argument pos
+ }
+}
+
+// XSomething implementation
+OUString MyService2Impl::methodOne( OUString const & str )
+{
+ m_sData = str;
+ return OUString( "called methodOne() of MyService2 implementation: " ) + m_sData;
+}
+
+OUString MyService2Impl::methodTwo( )
+{
+ return OUString( "called methodTwo() of MyService2 implementation: " ) + m_sData;
+}
+
+// XServiceInfo implementation
+OUString MyService2Impl::getImplementationName()
+{
+ // unique implementation name
+ return OUString("mymodule.my_sc_implementation.MyService2");
+}
+
+sal_Bool MyService2Impl::supportsService( OUString const & serviceName )
+{
+ return cppu::supportsService(this, serviceName);
+}
+
+Sequence< OUString > MyService2Impl::getSupportedServiceNames()
+{
+ return getSupportedServiceNames_MyService2Impl();
+}
+
+Reference< XInterface > SAL_CALL create_MyService2Impl(
+ Reference< XComponentContext > const & xContext )
+{
+ return static_cast< ::cppu::OWeakObject * >( new MyService2Impl( xContext ) );
+}
+
+}
+
+/* shared lib exports implemented without helpers in service_impl1.cxx */
+namespace my_sc_impl
+{
+static const struct ::cppu::ImplementationEntry s_component_entries [] =
+{
+ {
+ create_MyService1Impl, getImplementationName_MyService1Impl,
+ getSupportedServiceNames_MyService1Impl,
+ ::cppu::createSingleComponentFactory,
+ 0, 0
+ },
+ {
+ create_MyService2Impl, getImplementationName_MyService2Impl,
+ getSupportedServiceNames_MyService2Impl,
+ ::cppu::createSingleComponentFactory,
+ 0, 0
+ },
+ { 0, 0, 0, 0, 0, 0 }
+};
+}
+
+extern "C"
+{
+
+SAL_DLLPUBLIC_EXPORT void * SAL_CALL component_getFactory(
+ char const * implName, lang::XMultiServiceFactory * xMgr,
+ registry::XRegistryKey * xRegistry )
+{
+ return ::cppu::component_getFactoryHelper(
+ implName, xMgr, xRegistry, ::my_sc_impl::s_component_entries );
+}
+
+SAL_DLLPUBLIC_EXPORT void SAL_CALL component_getImplementationEnvironment(
+ char const ** ppEnvTypeName, uno_Environment **)
+{
+ *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
+}
+
+}
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/Components/CppComponent/some.idl b/odk/examples/DevelopersGuide/Components/CppComponent/some.idl
new file mode 100644
index 000000000..18e3395a1
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Components/CppComponent/some.idl
@@ -0,0 +1,57 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+#include <com/sun/star/uno/XInterface.idl>
+#include <com/sun/star/lang/IllegalArgumentException.idl>
+
+module mymodule
+{
+
+ interface XSomething
+ {
+ string methodOne( [in] string val );
+ string methodTwo();
+ };
+
+ service MyService1 : XSomething;
+
+ service MyService2 : XSomething
+ {
+ create([in]string sArgument)
+ raises (::com::sun::star::lang::IllegalArgumentException);
+ };
+};
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/Components/JavaComponent/JavaComponent.components b/odk/examples/DevelopersGuide/Components/JavaComponent/JavaComponent.components
new file mode 100644
index 000000000..67ac8696d
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Components/JavaComponent/JavaComponent.components
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<components xmlns="http://openoffice.org/2010/uno-components">
+ <component loader="com.sun.star.loader.Java2" uri="JavaComponent.uno.jar">
+ <implementation name="TestComponentA">
+ <service name="com.sun.star.test.SomethingA"/>
+ </implementation>
+ <implementation name="TestComponentB">
+ <service name="com.sun.star.test.SomethingB"/>
+ </implementation>
+ </component>
+</components>
diff --git a/odk/examples/DevelopersGuide/Components/JavaComponent/Makefile b/odk/examples/DevelopersGuide/Components/JavaComponent/Makefile
new file mode 100644
index 000000000..a20c5f444
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Components/JavaComponent/Makefile
@@ -0,0 +1,199 @@
+#*************************************************************************
+#
+# The Contents of this file are made available subject to the terms of
+# the BSD license.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+# 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+# contributors may be used to endorse or promote products derived
+# from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+# TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+# USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+#**************************************************************************
+
+# Builds the SpreadSheet examples of the Developers Guide.
+
+PRJ=../../../..
+SETTINGS=$(PRJ)/settings
+
+include $(SETTINGS)/settings.mk
+include $(SETTINGS)/std.mk
+
+# Define non-platform/compiler specific settings
+
+COMP_NAME=JavaComponent
+OUT_COMP_CLASS = $(OUT_CLASS)/$(COMP_NAME)
+OUT_COMP_GEN = $(OUT_MISC)/$(COMP_NAME)
+COMP_RDB_NAME = $(COMP_NAME).uno.rdb
+COMP_RDB = $(OUT_COMP_GEN)/$(COMP_RDB_NAME)
+COMP_PACKAGE = $(OUT_BIN)/$(COMP_NAME).$(UNOOXT_EXT)
+COMP_PACKAGE_URL = $(subst \\,\,"$(COMP_PACKAGE_DIR)$(PS)$(COMP_NAME).$(UNOOXT_EXT)")
+COMP_JAR_NAME = $(COMP_NAME).uno.jar
+COMP_JAR = $(OUT_COMP_CLASS)/$(COMP_JAR_NAME)
+COMP_MANIFESTFILE = $(OUT_COMP_CLASS)/$(COMP_NAME).uno.Manifest
+COMP_UNOPKG_MANIFEST = $(OUT_COMP_CLASS)/$(COMP_NAME)/META-INF/manifest.xml
+COMP_COMPONENTS=$(COMP_NAME).components
+
+APP1_NAME=TestJavaComponent
+APP1_JAR=$(OUT_COMP_CLASS)/$(APP1_NAME).jar
+
+REGISTERFLAG = $(OUT_MISC)$(PS)devguide_$(COMP_NAME)_register_component.flag
+
+IDLFILES = XSomethingA.idl \
+ XSomethingB.idl \
+ SomethingA.idl \
+ SomethingB.idl
+
+PACKAGE = com/sun/star/test
+
+COMPJAVAFILES = \
+ TestComponentA.java \
+ TestComponentB.java \
+ TestServiceProvider.java
+
+GENCLASSFILES = $(patsubst %.idl,$(OUT_COMP_CLASS)/$(PACKAGE)/%.class,$(IDLFILES))
+GENCLASSNAMES = $(patsubst %.idl,$(PACKAGE)/%.class,$(IDLFILES))
+GENTYPELIST = $(subst /,.,$(patsubst %.idl,-T$(PACKAGE)/% ,$(IDLFILES)))
+
+COMPCLASSFILES = $(patsubst %.java,$(OUT_COMP_CLASS)/%.class,$(COMPJAVAFILES))
+
+$(COMP_NAME)_CLASSFILES = $(patsubst %.java,%.class,$(COMPJAVAFILES))
+
+$(COMP_NAME)_CLASSFILES += $(subst $(OUT_COMP_CLASS)/,,$(GENCLASSFILES))
+
+SDK_CLASSPATH = $(subst $(EMPTYSTRING) $(PATH_SEPARATOR),$(PATH_SEPARATOR),$(CLASSPATH)\
+ $(PATH_SEPARATOR)$(OUT_COMP_CLASS))
+
+
+# Targets
+.PHONY: ALL
+ALL : \
+ JavaComponentExample
+
+include $(SETTINGS)/stdtarget.mk
+
+$(OUT_COMP_CLASS)/%.Manifest :
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ @echo UNO-Type-Path: $(basename $(notdir $*)).uno.jar> $@
+ @echo RegistrationClassName: TestServiceProvider>> $@
+
+$(OUT_COMP_GEN)/%.rdb : $(patsubst %,$(PACKAGE)/%,$(IDLFILES))
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ $(UNOIDLWRITE) $(URE_TYPES) $(OFFICE_TYPES) . $@
+
+$(OUT_COMP_CLASS)/$(PACKAGE)/%.class : $(COMP_RDB)
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ $(JAVAMAKER) -nD $(GENTYPELIST) -O$(OUT_COMP_CLASS) $(COMP_RDB) -X$(URE_TYPES) -X$(OFFICE_TYPES)
+
+$(OUT_COMP_CLASS)/%.class : %.java $(GENCLASSFILES)
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ $(SDK_JAVAC) $(JAVAC_FLAGS) -classpath "$(SDK_CLASSPATH)" -d $(OUT_COMP_CLASS) $<
+
+$(COMPCLASSFILES) : $(COMPJAVAFILES) $(GENCLASSFILES)
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ $(SDK_JAVAC) $(JAVAC_FLAGS) -classpath "$(SDK_CLASSPATH)" -d $(OUT_COMP_CLASS) $(COMPJAVAFILES)
+
+# rule for client/example application manifest file
+$(OUT_COMP_CLASS)/%.mf :
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ @echo Main-Class: com.sun.star.lib.loader.Loader> $@
+ $(ECHOLINE)>> $@
+ @echo Name: com/sun/star/lib/loader/Loader.class>> $@
+ @echo Application-Class: $*>> $@
+
+# rule for client/example application jar file
+# Note that the example needs the component files as well for local usage
+$(APP1_JAR) : $(OUT_COMP_CLASS)/$(APP1_NAME).mf $(OUT_COMP_CLASS)/$(APP1_NAME).class $(COMPCLASSFILES) $(GENCLASSFILES)
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ +cd $(subst /,$(PS),$(OUT_COMP_CLASS)) && $(SDK_JAR) cvfm $(@F) $(basename $(@F)).mf $(basename $(@F)).class $($(COMP_NAME)_CLASSFILES)
+ +$(SDK_JAR) uvf $@ $(SDK_JAVA_UNO_BOOTSTRAP_FILES)
+
+# rule for component jar file
+$(COMP_JAR) : $(COMP_MANIFESTFILE) $(COMPCLASSFILES)
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ cd $(subst /,$(PS),$(OUT_COMP_CLASS)) && $(SDK_JAR) cvfm $(@F) $(<F) $($(basename $(basename $(@F)))_CLASSFILES)
+
+# rule for component package manifest
+$(OUT_COMP_CLASS)/%/manifest.xml :
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ @echo $(OSEP)?xml version="$(QM)1.0$(QM)" encoding="$(QM)UTF-8$(QM)"?$(CSEP) > $@
+ @echo $(OSEP)!DOCTYPE manifest:manifest PUBLIC "$(QM)-//OpenOffice.org//DTD Manifest 1.0//EN$(QM)" "$(QM)Manifest.dtd$(QM)"$(CSEP) >> $@
+ @echo $(OSEP)manifest:manifest xmlns:manifest="$(QM)http://openoffice.org/2001/manifest$(QM)"$(CSEP) >> $@
+ @echo $(SQM) $(SQM)$(OSEP)manifest:file-entry manifest:media-type="$(QM)application/vnd.sun.star.uno-typelibrary;type=RDB$(QM)" >> $@
+ @echo $(SQM) $(SQM)manifest:full-path="$(QM)$(subst /META-INF,,$(subst $(OUT_COMP_CLASS)/,,$(@D))).uno.rdb$(QM)"/$(CSEP) >> $@
+ @echo $(SQM) $(SQM)$(OSEP)manifest:file-entry manifest:media-type="$(QM)application/vnd.sun.star.uno-components$(QM)">> $@
+ @echo $(SQM) $(SQM)manifest:full-path="$(QM)$(COMP_COMPONENTS)$(QM)"/$(CSEP)>> $@
+ @echo $(OSEP)/manifest:manifest$(CSEP) >> $@
+
+# rule for component package file
+$(COMP_PACKAGE) : $(COMP_RDB) $(COMP_JAR) $(COMP_UNOPKG_MANIFEST) $(COMP_COMPONENTS) description.xml
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ $(COPY) $(subst /,$(PS),$(COMP_RDB)) $(subst /,$(PS),$(OUT_COMP_CLASS))
+ $(SDK_ZIP) $@ $(COMP_COMPONENTS) description.xml
+ cd $(subst /,$(PS),$(OUT_COMP_CLASS)) && $(SDK_ZIP) -u ../../bin/$(@F) $(COMP_RDB_NAME) $(COMP_JAR_NAME)
+ cd $(subst /,$(PS),$(OUT_COMP_CLASS)/$(subst .$(UNOOXT_EXT),,$(@F))) && $(SDK_ZIP) -u ../../../bin/$(@F) META-INF/manifest.xml
+ $(DEL) $(subst \\,\,$(subst /,$(PS),$(OUT_COMP_CLASS)/$(COMP_RDB_NAME)))
+
+$(REGISTERFLAG) : $(COMP_PACKAGE)
+ifeq "$(SDK_AUTO_DEPLOYMENT)" "YES"
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ $(DEPLOYTOOL) $(COMP_PACKAGE_URL)
+ @echo flagged > $(subst /,$(PS),$@)
+else
+ @echo --------------------------------------------------------------------------------
+ @echo If you want to install your component automatically, please set the environment
+ @echo variable SDK_AUTO_DEPLOYMENT = YES. But note that auto deployment is only
+ @echo possible if no office instance is running.
+ @echo --------------------------------------------------------------------------------
+endif
+
+JavaComponentExample : $(REGISTERFLAG) $(APP1_JAR)
+ @echo --------------------------------------------------------------------------------
+ @echo Please use one of the following commands to execute the examples!
+ @echo -
+ @echo $(MAKE) $(APP1_NAME).run
+ @echo $(MAKE) $(APP1_NAME).local
+ @echo --------
+ @echo The Java components were installed if SDK_AUTO_DEPLOYMENT = YES.
+ @echo You can use this component inside your office installation, see the
+ @echo example description.
+ @echo --------------------------------------------------------------------------------
+
+%.run: $(OUT_COMP_CLASS)/%.jar
+ $(SDK_JAVA) -Dcom.sun.star.lib.loader.unopath="$(OFFICE_PROGRAM_PATH)" -jar $<
+
+%.local: $(OUT_COMP_CLASS)/%.jar
+ $(SDK_JAVA) -Dcom.sun.star.lib.loader.unopath="$(OFFICE_PROGRAM_PATH)" -jar $< local
+
+.PHONY: clean
+clean :
+ -$(DELRECURSIVE) $(subst /,$(PS),$(OUT_COMP_CLASS))
+ -$(DELRECURSIVE) $(subst /,$(PS),$(OUT_COMP_GEN))
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$(COMP_PACKAGE_URL)))
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$(REGISTERFLAG)))
diff --git a/odk/examples/DevelopersGuide/Components/JavaComponent/TestComponentA.java b/odk/examples/DevelopersGuide/Components/JavaComponent/TestComponentA.java
new file mode 100644
index 000000000..5427a3081
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Components/JavaComponent/TestComponentA.java
@@ -0,0 +1,69 @@
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+import com.sun.star.lib.uno.helper.WeakBase;
+import com.sun.star.lang.XServiceInfo;
+import com.sun.star.test.XSomethingA;
+
+// TestComponentA use the implementation helper WeakBase
+public class TestComponentA extends WeakBase implements XServiceInfo, XSomethingA {
+ static final String __serviceName= "com.sun.star.test.SomethingA";
+
+ static byte[] _implementationId;
+
+ // XSomethingA
+ public String methodOne(String val) {
+ return val;
+ }
+
+ //XServiceInfo
+ public String getImplementationName( ) {
+ return getClass().getName();
+ }
+ // XServiceInfo
+ public boolean supportsService( /*IN*/String serviceName ) {
+ if ( serviceName.equals( __serviceName))
+ return true;
+ return false;
+ }
+ //XServiceInfo
+ public String[] getSupportedServiceNames( ) {
+ String[] retValue= new String[0];
+ retValue[0]= __serviceName;
+ return retValue;
+ }
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/Components/JavaComponent/TestComponentB.java b/odk/examples/DevelopersGuide/Components/JavaComponent/TestComponentB.java
new file mode 100644
index 000000000..c8f6def18
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Components/JavaComponent/TestComponentB.java
@@ -0,0 +1,92 @@
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+import com.sun.star.uno.XComponentContext;
+import com.sun.star.lang.XTypeProvider;
+import com.sun.star.lang.XServiceInfo;
+import com.sun.star.test.XSomethingB;
+import com.sun.star.uno.Type;
+
+// TestComponentB implements all necessary interfaces self, this is only
+// for demonstration. More convenient is to use the implementation WeakBase or
+// ComponentBase, see implementation of TestComponentA.
+public class TestComponentB implements XTypeProvider, XServiceInfo, XSomethingB {
+ static final String __serviceName= "com.sun.star.test.SomethingB";
+
+ private final Object[] args;
+
+ public TestComponentB(XComponentContext context, Object[] args) {
+ this.args= args;
+ }
+
+ // XSomethingB
+ public String methodTwo(String val) {
+ if (args.length > 0 && args[0] instanceof String )
+ return (String) args[0];
+ return val;
+ }
+
+ //XTypeProvider
+ public com.sun.star.uno.Type[] getTypes( ) {
+ Type[] retValue= new Type[3];
+ retValue[0]= new Type( XServiceInfo.class);
+ retValue[1]= new Type( XTypeProvider.class);
+ retValue[2]= new Type( XSomethingB.class);
+ return retValue;
+ }
+ //XTypeProvider
+ public byte[] getImplementationId( ) {
+ return new byte[0];
+ }
+
+ //XServiceInfo
+ public String getImplementationName( ) {
+ return getClass().getName();
+ }
+
+ // XServiceInfo
+ public boolean supportsService( /*IN*/String serviceName ) {
+ if ( serviceName.equals( __serviceName))
+ return true;
+ return false;
+ }
+ //XServiceInfo
+ public String[] getSupportedServiceNames( ) {
+ String[] retValue= new String[0];
+ retValue[0]= __serviceName;
+ return retValue;
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/Components/JavaComponent/TestJavaComponent.java b/odk/examples/DevelopersGuide/Components/JavaComponent/TestJavaComponent.java
new file mode 100644
index 000000000..cea18aebc
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Components/JavaComponent/TestJavaComponent.java
@@ -0,0 +1,144 @@
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+import com.sun.star.uno.XComponentContext;
+import com.sun.star.comp.helper.Bootstrap;
+import com.sun.star.lang.XMultiComponentFactory;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.test.XSomethingB;
+import com.sun.star.test.SomethingB;
+import com.sun.star.container.XSet;
+
+// sample starbasic code, you can execute it after you have connected to the office.
+// Sub Main
+// o = createUnoService( "com.sun.star.test.SomethingB" )
+// msgbox o.methodOne( "from the office !" )
+// End Sub
+
+public class TestJavaComponent
+{
+
+ public static void insertIntoServiceManager(
+ XMultiComponentFactory serviceManager, Object singleFactory )
+ throws com.sun.star.uno.Exception
+ {
+ XSet set = UnoRuntime.queryInterface( XSet.class, serviceManager );
+ set.insert( singleFactory );
+ }
+
+ public static void removeFromServiceManager(
+ XMultiComponentFactory serviceManager, Object singleFactory )
+ throws com.sun.star.uno.Exception
+ {
+ XSet set = UnoRuntime.queryInterface( XSet.class, serviceManager );
+ set.remove( singleFactory );
+
+ }
+
+ public static void main(String[] args) throws java.lang.Exception
+ {
+ try {
+ boolean bLocal = false;
+
+ XMultiComponentFactory xUsedServiceManager = null;
+ XComponentContext xUsedComponentContext = null;
+
+ if( args.length == 1 && args[0].equals( "local" ))
+ {
+ XComponentContext xLocalComponentContext =
+ Bootstrap.createInitialComponentContext( null );
+
+ // initial serviceManager
+ XMultiComponentFactory xLocalServiceManager =
+ xLocalComponentContext.getServiceManager();
+
+ bLocal = true;
+ xUsedServiceManager = xLocalServiceManager;
+ xUsedComponentContext = xLocalComponentContext;
+
+ System.out.println( "Using local servicemanager" );
+ } else {
+ // get the remote office component context
+ xUsedComponentContext =
+ com.sun.star.comp.helper.Bootstrap.bootstrap();
+ System.out.println("Connected to a running office ...");
+
+ xUsedServiceManager = xUsedComponentContext.getServiceManager();
+ System.out.println( "Using remote servicemanager" );
+ }
+
+ if ( xUsedServiceManager == null )
+ {
+ System.out.println( "ERROR: no service manager" );
+ System.exit(0);
+ }
+
+ Object factory = new Object();
+ if ( bLocal )
+ {
+ // retrieve the factory for the component implementation
+ factory = TestServiceProvider.__getServiceFactory(
+ "TestComponentB", null, null);
+
+ // insert the factory into the local servicemanager
+ // From now on, the service can be instantiated !
+ insertIntoServiceManager( xUsedServiceManager, factory );
+ }
+
+ XSomethingB xSomethingB = SomethingB.create(xUsedComponentContext);
+
+ // and call the test method.
+ String s= xSomethingB.methodTwo("Hello World!");
+ System.out.println(s);
+
+ if ( bLocal )
+ {
+ // remove it again from the servicemanager,
+ removeFromServiceManager( xUsedServiceManager, factory );
+ }
+
+ }
+ catch ( Exception e )
+ {
+ System.out.println( "UNO Exception caught: " + e );
+ System.out.println( "Message: " + e.getMessage() );
+ e.printStackTrace(System.err);
+ }
+
+ // quit, even when a remote bridge is running
+ System.exit(0);
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/Components/JavaComponent/TestServiceProvider.java b/odk/examples/DevelopersGuide/Components/JavaComponent/TestServiceProvider.java
new file mode 100644
index 000000000..fde48e894
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Components/JavaComponent/TestServiceProvider.java
@@ -0,0 +1,61 @@
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.lang.XSingleServiceFactory;
+import com.sun.star.registry.XRegistryKey;
+import com.sun.star.comp.loader.FactoryHelper;
+
+public class TestServiceProvider
+{
+ public static XSingleServiceFactory __getServiceFactory(
+ String implName,
+ XMultiServiceFactory multiFactory,
+ XRegistryKey regKey) {
+ XSingleServiceFactory xSingleServiceFactory = null;
+
+ if (implName.equals( TestComponentA.class.getName()) )
+ xSingleServiceFactory = FactoryHelper.getServiceFactory(
+ TestComponentA.class, TestComponentA.__serviceName,
+ multiFactory, regKey);
+ else if (implName.equals(TestComponentB.class.getName()))
+ xSingleServiceFactory= FactoryHelper.getServiceFactory(
+ TestComponentB.class, TestComponentB.__serviceName,
+ multiFactory, regKey);
+ return xSingleServiceFactory;
+ }
+}
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/Components/JavaComponent/com/sun/star/test/SomethingA.idl b/odk/examples/DevelopersGuide/Components/JavaComponent/com/sun/star/test/SomethingA.idl
new file mode 100644
index 000000000..e609ad461
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Components/JavaComponent/com/sun/star/test/SomethingA.idl
@@ -0,0 +1,48 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+#ifndef INCLUDED_COM_SUN_STAR_TEST_SOMETHINGA_IDL
+#define INCLUDED_COM_SUN_STAR_TEST_SOMETHINGA_IDL
+
+#include <XSomethingA.idl>
+
+module com { module sun { module star { module test {
+ service SomethingA: XSomethingA;
+}; }; }; };
+
+#endif
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/Components/JavaComponent/com/sun/star/test/SomethingB.idl b/odk/examples/DevelopersGuide/Components/JavaComponent/com/sun/star/test/SomethingB.idl
new file mode 100644
index 000000000..5f458aa88
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Components/JavaComponent/com/sun/star/test/SomethingB.idl
@@ -0,0 +1,48 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+#ifndef INCLUDED_COM_SUN_STAR_TEST_SOMETHINGB_IDL
+#define INCLUDED_COM_SUN_STAR_TEST_SOMETHINGB_IDL
+
+#include <XSomethingB.idl>
+
+module com { module sun { module star { module test {
+ service SomethingB : XSomethingB;
+}; }; }; };
+
+#endif
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/Components/JavaComponent/com/sun/star/test/XSomethingA.idl b/odk/examples/DevelopersGuide/Components/JavaComponent/com/sun/star/test/XSomethingA.idl
new file mode 100644
index 000000000..61b501229
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Components/JavaComponent/com/sun/star/test/XSomethingA.idl
@@ -0,0 +1,50 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+#ifndef INCLUDED_COM_SUN_STAR_TEST_XSOMETHINGA_IDL
+#define INCLUDED_COM_SUN_STAR_TEST_XSOMETHINGA_IDL
+
+#include <com/sun/star/uno/XInterface.idl>
+
+module com { module sun { module star { module test {
+ interface XSomethingA {
+ string methodOne([in]string value);
+ };
+}; }; }; };
+
+#endif
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/Components/JavaComponent/com/sun/star/test/XSomethingB.idl b/odk/examples/DevelopersGuide/Components/JavaComponent/com/sun/star/test/XSomethingB.idl
new file mode 100644
index 000000000..92d0bd19e
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Components/JavaComponent/com/sun/star/test/XSomethingB.idl
@@ -0,0 +1,50 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+#ifndef INCLUDED_COM_SUN_STAR_TEST_XSOMETHINGB_IDL
+#define INCLUDED_COM_SUN_STAR_TEST_XSOMETHINGB_IDL
+
+#include <com/sun/star/uno/XInterface.idl>
+
+module com { module sun { module star { module test {
+ interface XSomethingB {
+ string methodTwo([in]string value);
+ };
+}; }; }; };
+
+#endif
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/Components/JavaComponent/description.xml b/odk/examples/DevelopersGuide/Components/JavaComponent/description.xml
new file mode 100644
index 000000000..6c4e2396b
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Components/JavaComponent/description.xml
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+-->
+<d:description xmlns:d="http://openoffice.org/extensions/description/2006">
+ <d:dependencies>
+ <l:LibreOffice-minimal-version value="4.1" d:name="LibreOffice 4.1"
+ xmlns:l="http://libreoffice.org/extensions/description/2011"/>
+ </d:dependencies>
+</d:description>
diff --git a/odk/examples/DevelopersGuide/Components/SimpleLicense/LicenseTest.components b/odk/examples/DevelopersGuide/Components/SimpleLicense/LicenseTest.components
new file mode 100644
index 000000000..94a4848c0
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Components/SimpleLicense/LicenseTest.components
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<components xmlns="http://openoffice.org/2010/uno-components">
+ <component loader="com.sun.star.loader.Java2" uri="LicenseTest.uno.jar">
+ <implementation name="LicenseTest$_LicenseTest">
+ <service name="org.openoffice.LicenseTest"/>
+ </implementation>
+ </component>
+</components>
diff --git a/odk/examples/DevelopersGuide/Components/SimpleLicense/LicenseTest.idl b/odk/examples/DevelopersGuide/Components/SimpleLicense/LicenseTest.idl
new file mode 100644
index 000000000..68eab80ee
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Components/SimpleLicense/LicenseTest.idl
@@ -0,0 +1,53 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+#ifndef _org_openoffice_LicenseTest_idl_
+#define _org_openoffice_LicenseTest_idl_
+
+#include <com/sun/star/lang/XServiceInfo.idl>
+
+// org
+module org {
+ // openoffice
+ module openoffice {
+ // example service, XServiceInfo is implemented here for demonstration
+ // issues. XServiceInfo must be implemented by all components.
+ service LicenseTest: ::com::sun::star::lang::XServiceInfo;
+ };
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/Components/SimpleLicense/LicenseTest.java b/odk/examples/DevelopersGuide/Components/SimpleLicense/LicenseTest.java
new file mode 100644
index 000000000..b47aa7008
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Components/SimpleLicense/LicenseTest.java
@@ -0,0 +1,129 @@
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+import com.sun.star.lib.uno.helper.Factory;
+import com.sun.star.lang.XSingleComponentFactory;
+import com.sun.star.lib.uno.helper.WeakBase;
+import com.sun.star.lang.XServiceInfo;
+
+/** This class capsulates the class, that implements the minimal component, a
+ * factory for creating the service (<CODE>__getComponentFactory</CODE>) and a
+ * method, that writes the information into the given registry key
+ * (<CODE>__writeRegistryServiceInfo</CODE>).
+ */
+public class LicenseTest {
+ /** This class implements the component. At least the interfaces XServiceInfo,
+ * XTypeProvider, and XInitialization should be provided by the service.
+ */
+ public static class _LicenseTest extends WeakBase
+ implements XServiceInfo {
+ /** The service name, that must be used to get an instance of this service.
+ */
+ private static final String __serviceName =
+ "org.openoffice.LicenseTest";
+
+ /** This method returns an array of all supported service names.
+ * @return Array of supported service names.
+ */
+ public String[] getSupportedServiceNames() {
+ return getServiceNames();
+ }
+
+ /** This method is a simple helper function to used in the
+ * static component initialisation functions as well as in
+ * getSupportedServiceNames.
+ */
+ public static String[] getServiceNames() {
+ String[] sSupportedServiceNames = { __serviceName };
+ return sSupportedServiceNames;
+ }
+
+ /** This method returns true, if the given service will be
+ * supported by the component.
+ * @param sServiceName Service name.
+ * @return True, if the given service name will be supported.
+ */
+ public boolean supportsService( String sServiceName ) {
+ return sServiceName.equals( __serviceName );
+ }
+
+ /** Return the class name of the component.
+ * @return Class name of the component.
+ */
+ public String getImplementationName() {
+ return _LicenseTest.class.getName();
+ }
+ }
+
+
+ /**
+ * Gives a factory for creating the service.
+ * This method is called by the <code>JavaLoader</code>
+ * <p>
+ * @return returns a <code>XSingleComponentFactory</code> for creating
+ * the component
+ * @param sImplName the name of the implementation for which a
+ * service is desired
+ * @see com.sun.star.comp.loader.JavaLoader
+ */
+ public static XSingleComponentFactory __getComponentFactory(String sImplName)
+ {
+ XSingleComponentFactory xFactory = null;
+
+ if ( sImplName.equals( _LicenseTest.class.getName() ) )
+ xFactory = Factory.createComponentFactory(_LicenseTest.class,
+ _LicenseTest.getServiceNames());
+
+ return xFactory;
+ }
+
+ /** This method is a member of the interface for initializing an object
+ * directly after its creation.
+ * @param object This array of arbitrary objects will be passed to the
+ * component after its creation.
+ * @throws com.sun.star.uno.Exception Every exception will not be handled, but will be
+ * passed to the caller.
+ */
+ public void initialize( Object[] object )
+ throws com.sun.star.uno.Exception {
+ /* The component describes what arguments are expected and in which
+ * order! At this point you can read the objects and initialize
+ * your component using these objects.
+ */
+ }
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/Components/SimpleLicense/Makefile b/odk/examples/DevelopersGuide/Components/SimpleLicense/Makefile
new file mode 100644
index 000000000..5ee470fb0
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Components/SimpleLicense/Makefile
@@ -0,0 +1,166 @@
+#*************************************************************************
+#
+# The Contents of this file are made available subject to the terms of
+# the BSD license.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+# 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+# contributors may be used to endorse or promote products derived
+# from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+# TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+# USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+#**************************************************************************
+
+# Builds the License Test component example of the SDK.
+
+PRJ=../../../..
+SETTINGS=$(PRJ)/settings
+
+include $(SETTINGS)/settings.mk
+include $(SETTINGS)/std.mk
+
+# Define non-platform/compiler specific settings
+
+# we use the sample directory name for separating this example
+# from others in the output directory
+SAMPLE_NAME=LicenseTest
+SAMPLE_CLASS_OUT=$(OUT_CLASS)/$(SAMPLE_NAME)
+SAMPLE_GEN_OUT=$(OUT_MISC)/$(SAMPLE_NAME)
+
+COMP_NAME=LicenseTest
+COMP_CLASS_OUT=$(SAMPLE_CLASS_OUT)/$(COMP_NAME)
+COMP_GEN_OUT=$(SAMPLE_GEN_OUT)/$(COMP_NAME)
+COMP_RDB_NAME=$(COMP_NAME).uno.rdb
+COMP_RDB=$(COMP_GEN_OUT)/$(COMP_RDB_NAME)
+COMP_PACKAGE=$(OUT_BIN)/$(COMP_NAME).$(UNOOXT_EXT)
+COMP_PACKAGE_URL=$(subst \\,\,"$(COMP_PACKAGE_DIR)$(PS)$(COMP_NAME).$(UNOOXT_EXT)")
+COMP_JAR_NAME=$(COMP_NAME).uno.jar
+COMP_JAR=$(SAMPLE_CLASS_OUT)/$(COMP_JAR_NAME)
+COMP_JAR_MANIFEST=$(COMP_GEN_OUT)/$(COMP_NAME).uno.Manifest
+COMP_UNOPKG_MANIFEST = $(COMP_GEN_OUT)/META-INF/manifest.xml
+COMP_REGISTERFLAG=$(COMP_GEN_OUT)$(PS)java_$(COMP_NAME)_register_component.flag
+COMP_LOCAL_FILES = description.xml registration/license_de.txt registration/license_en_US.txt
+COMP_COMPONENTS=$(COMP_NAME).components
+
+IDLFILES = LicenseTest.idl
+
+# normally the idl file should be stored in a directory tree fitting the module structure,
+# for the example we know the module structure
+PACKAGE = org/openoffice
+
+COMP_JAVAFILES = LicenseTest.java
+COMP_CLASSFILES = $(patsubst %.java,$(COMP_CLASS_OUT)/%.class,$(COMP_JAVAFILES))
+
+GEN_CLASSFILES = $(patsubst %.idl,$(SAMPLE_CLASS_OUT)/$(PACKAGE)/%.class,$(IDLFILES))
+GEN_TYPELIST = $(subst /,.,$(patsubst %.idl,-T$(PACKAGE)/% ,$(IDLFILES)))
+
+# the generated types are necessary for the component and the application jar
+GEN_CLASSFILENAMES = $(subst $(SAMPLE_CLASS_OUT)/,,$(GEN_CLASSFILES))
+
+SDK_CLASSPATH = $(subst $(EMPTYSTRING) $(PATH_SEPARATOR),$(PATH_SEPARATOR),$(CLASSPATH)\
+ $(PATH_SEPARATOR)$(SAMPLE_CLASS_OUT)\
+ $(PATH_SEPARATOR)$(COMP_CLASS_OUT)\
+ $(PATH_SEPARATOR)$(APP1_CLASS_OUT))
+
+
+# Targets
+.PHONY: ALL
+ALL : JavaLicenseTestExample
+
+include $(SETTINGS)/stdtarget.mk
+
+$(COMP_GEN_OUT)/%.Manifest :
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ @echo UNO-Type-Path: $(basename $(notdir $*)).uno.jar> $@
+ @echo RegistrationClassName: $(basename $*)>> $@
+
+$(COMP_GEN_OUT)/%.rdb : $(IDLFILES)
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ $(UNOIDLWRITE) $(URE_TYPES) $(OFFICE_TYPES) $< $@
+
+$(GEN_CLASSFILES) : $(COMP_RDB)
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ $(JAVAMAKER) -nD $(GEN_TYPELIST) -O$(SAMPLE_CLASS_OUT) $(COMP_RDB) -X$(URE_TYPES) -X$(OFFICE_TYPES)
+
+# component as well as application are dependent from the generated types
+# rule for component class files
+$(COMP_CLASS_OUT)/%.class : %.java $(GEN_CLASSFILES)
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ $(SDK_JAVAC) $(JAVAC_FLAGS) -classpath "$(SDK_CLASSPATH)" -d $(COMP_CLASS_OUT) $<
+
+# rule for component jar file
+$(COMP_JAR) : $(COMP_JAR_MANIFEST) $(COMP_CLASSFILES)
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ $(SDK_JAR) cvfm $@ $< -C $(COMP_CLASS_OUT) .
+ +cd $(subst /,$(PS),$(SAMPLE_CLASS_OUT)) && $(SDK_JAR) uvf $(@F) $(GEN_CLASSFILENAMES)
+
+# rule for component package manifest
+$(COMP_GEN_OUT)/%/manifest.xml :
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ @echo $(OSEP)?xml version="$(QM)1.0$(QM)" encoding="$(QM)UTF-8$(QM)"?$(CSEP) > $@
+ @echo $(OSEP)!DOCTYPE manifest:manifest PUBLIC "$(QM)-//OpenOffice.org//DTD Manifest 1.0//EN$(QM)" "$(QM)Manifest.dtd$(QM)"$(CSEP) >> $@
+ @echo $(OSEP)manifest:manifest xmlns:manifest="$(QM)http://openoffice.org/2001/manifest$(QM)"$(CSEP) >> $@
+ @echo $(SQM) $(SQM)$(OSEP)manifest:file-entry manifest:media-type="$(QM)application/vnd.sun.star.uno-typelibrary;type=RDB$(QM)" >> $@
+ @echo $(SQM) $(SQM)manifest:full-path="$(QM)$(subst /META-INF,,$(subst $(SAMPLE_GEN_OUT)/,,$(@D))).uno.rdb$(QM)"/$(CSEP) >> $@
+ @echo $(SQM) $(SQM)$(OSEP)manifest:file-entry manifest:media-type="$(QM)application/vnd.sun.star.uno-components$(QM)">> $@
+ @echo $(SQM) $(SQM)manifest:full-path="$(QM)$(COMP_COMPONENTS)$(QM)"/$(CSEP)>> $@
+ @echo $(OSEP)/manifest:manifest$(CSEP) >> $@
+
+# rule for component package file
+$(COMP_PACKAGE) : $(COMP_RDB) $(COMP_JAR) $(COMP_UNOPKG_MANIFEST) $(COMP_LOCAL_FILES) $(COMP_COMPONENTS)
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ $(SDK_ZIP) $@ $(COMP_COMPONENTS)
+ cd $(subst /,$(PS),$(COMP_GEN_OUT)) && $(SDK_ZIP) -u ../../../bin/$(@F) $(COMP_RDB_NAME)
+ cd $(subst /,$(PS),$(SAMPLE_CLASS_OUT)) && $(SDK_ZIP) -u ../../bin/$(@F) $(COMP_JAR_NAME)
+ cd $(subst /,$(PS),$(COMP_GEN_OUT)) && $(SDK_ZIP) -u ../../../bin/$(@F) META-INF/manifest.xml
+ $(SDK_ZIP) -u $@ $(COMP_LOCAL_FILES)
+
+$(COMP_REGISTERFLAG) : $(COMP_PACKAGE)
+ifeq "$(SDK_AUTO_DEPLOYMENT)" "YES"
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ $(DEPLOYTOOL) $(COMP_PACKAGE_URL)
+ @echo flagged > $(subst /,$(PS),$@)
+else
+ @echo --------------------------------------------------------------------------------
+ @echo If you want to install your component automatically, please set the environment
+ @echo variable SDK_AUTO_DEPLOYMENT = YES. But note that auto deployment is only
+ @echo possible if no office instance is running.
+ @echo --------------------------------------------------------------------------------
+endif
+
+JavaLicenseTestExample : $(COMP_REGISTERFLAG)
+ @echo --------------------------------------------------------------------------------
+ @echo The $(COMP_NAME) component was installed if SDK_AUTO_DEPLOYMENT = YES.
+ @echo This extension demonstrates the $(QM)Simple License$(QM) feature.
+ @echo --------------------------------------------------------------------------------
+
+.PHONY: clean
+clean :
+ -$(DELRECURSIVE) $(subst /,$(PS),$(SAMPLE_CLASS_OUT))
+ -$(DELRECURSIVE) $(subst /,$(PS),$(SAMPLE_GEN_OUT))
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$(COMP_PACKAGE_URL)))
diff --git a/odk/examples/DevelopersGuide/Components/SimpleLicense/description.xml b/odk/examples/DevelopersGuide/Components/SimpleLicense/description.xml
new file mode 100644
index 000000000..e36a90b92
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Components/SimpleLicense/description.xml
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+-->
+<description xmlns="http://openoffice.org/extensions/description/2006"
+ xmlns:xlink="http://www.w3.org/1999/xlink">
+
+ <dependencies>
+ <l:LibreOffice-minimal-version value="4.1" d:name="LibreOffice 4.1"
+ xmlns:d="http://openoffice.org/extensions/description/2006"
+ xmlns:l="http://libreoffice.org/extensions/description/2011"/>
+ </dependencies>
+ <registration>
+ <simple-license accept-by="admin" default-license-id="de">
+ <license-text xlink:href="registration/license_de.txt" lang="de" license-id="de" />
+ <license-text xlink:href="registration/license_en_US.txt" lang="en-US" />
+ </simple-license>
+ </registration>
+</description>
+
diff --git a/odk/examples/DevelopersGuide/Components/SimpleLicense/registration/license_de.txt b/odk/examples/DevelopersGuide/Components/SimpleLicense/registration/license_de.txt
new file mode 100644
index 000000000..6deedf8b4
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Components/SimpleLicense/registration/license_de.txt
@@ -0,0 +1 @@
+Eine ganz kurze Lizenz. \ No newline at end of file
diff --git a/odk/examples/DevelopersGuide/Components/SimpleLicense/registration/license_en_US.txt b/odk/examples/DevelopersGuide/Components/SimpleLicense/registration/license_en_US.txt
new file mode 100644
index 000000000..127a4569b
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Components/SimpleLicense/registration/license_en_US.txt
@@ -0,0 +1 @@
+A very short license. \ No newline at end of file
diff --git a/odk/examples/DevelopersGuide/Components/Thumbs/Makefile b/odk/examples/DevelopersGuide/Components/Thumbs/Makefile
new file mode 100644
index 000000000..7a7ac34f7
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Components/Thumbs/Makefile
@@ -0,0 +1,82 @@
+#*************************************************************************
+#
+# The Contents of this file are made available subject to the terms of
+# the BSD license.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+# 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+# contributors may be used to endorse or promote products derived
+# from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+# TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+# USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+#**************************************************************************
+
+# Builds the Component Thumbs of the Developers Guide.
+
+PRJ=../../../..
+SETTINGS=$(PRJ)/settings
+
+include $(SETTINGS)/settings.mk
+include $(SETTINGS)/std.mk
+
+include thumbs.mk
+
+SUBDIRS= org/openoffice/test org/openoffice/comp/test
+
+# Targets
+.PHONY: ALL
+ALL : \
+ $(SUBDIRS) \
+ ComponentsThumbsExample
+
+include $(SETTINGS)/stdtarget.mk
+
+.PHONY : $(SUBDIRS)
+$(SUBDIRS) :
+ $(MAKE) -C $@
+
+org/openoffice/comp/test : org/openoffice/test
+
+$(COMP_PACKAGE): org/openoffice/comp/test
+
+ComponentsThumbsExample : $(COMP_PACKAGE)
+ @echo --------------------------------------------------------------------------------
+ @echo Please use one of the following command to execute the example!
+ @echo -
+ @echo $(MAKE) $(APP1_NAME).run
+ @echo --------
+ @echo The ImageShrink Java component was installed if SDK_AUTO_DEPLOYMENT = YES.
+ @echo You can use this component inside your office installation, see the example
+ @echo description.
+ @echo --------------------------------------------------------------------------------
+
+%.run: $(OUT_COMP_CLASS)/%.jar
+ $(SDK_JAVA) -Dcom.sun.star.lib.loader.unopath="$(OFFICE_PROGRAM_PATH)" -jar $<
+
+.PHONY: clean
+clean :
+ $(MAKE) -C org/openoffice/test clean
+ $(MAKE) -C org/openoffice/comp/test clean
+ -$(DELRECURSIVE) $(subst /,$(PS),$(OUT_COMP_CLASS))
+ -$(DELRECURSIVE) $(subst /,$(PS),$(OUT_COMP_GEN))
diff --git a/odk/examples/DevelopersGuide/Components/Thumbs/org/openoffice/comp/test/ImageShrink.components b/odk/examples/DevelopersGuide/Components/Thumbs/org/openoffice/comp/test/ImageShrink.components
new file mode 100644
index 000000000..11d958fe8
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Components/Thumbs/org/openoffice/comp/test/ImageShrink.components
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<components xmlns="http://openoffice.org/2010/uno-components">
+ <component loader="com.sun.star.loader.Java2" uri="ImageShrink.uno.jar">
+ <implementation name="org.openoffice.comp.test.ImageShrink">
+ <service name="org.openoffice.test.ImageShrink"/>
+ </implementation>
+ </component>
+</components>
diff --git a/odk/examples/DevelopersGuide/Components/Thumbs/org/openoffice/comp/test/ImageShrink.java b/odk/examples/DevelopersGuide/Components/Thumbs/org/openoffice/comp/test/ImageShrink.java
new file mode 100644
index 000000000..7022f5c32
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Components/Thumbs/org/openoffice/comp/test/ImageShrink.java
@@ -0,0 +1,129 @@
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+package org.openoffice.comp.test;
+
+import com.sun.star.lang.XSingleServiceFactory;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.comp.loader.FactoryHelper;
+import com.sun.star.lib.uno.helper.WeakBase;
+
+public class ImageShrink extends WeakBase
+ implements com.sun.star.lang.XServiceInfo,
+ org.openoffice.test.XImageShrinkFilter {
+
+ com.sun.star.uno.XComponentContext xComponentContext = null;
+
+ // hold the service name in a private static member variable of the class
+ protected static final String __serviceName = "org.openoffice.test.ImageShrink";
+
+
+ String destDir = "";
+ String sourceDir = "";
+ boolean cancel = false;
+ com.sun.star.awt.Size dimension = new com.sun.star.awt.Size();
+
+ // static __getServiceFactory() Implementation
+ public static XSingleServiceFactory __getServiceFactory(String implName,
+ XMultiServiceFactory multiFactory,
+ com.sun.star.registry.XRegistryKey regKey) {
+
+ com.sun.star.lang.XSingleServiceFactory xSingleServiceFactory = null;
+ if (implName.equals( ImageShrink.class.getName()) )
+ xSingleServiceFactory = FactoryHelper.getServiceFactory( ImageShrink.class,
+ ImageShrink.__serviceName,
+ multiFactory,
+ regKey);
+
+ return xSingleServiceFactory;
+ }
+
+ // XFilter implementation (a sub-interface of XImageShrinkFilter)
+ public void cancel() {
+ cancel = true;
+ }
+
+ public boolean filter(com.sun.star.beans.PropertyValue[] propertyValue) {
+ // while cancel = false,
+ // scale images found in sourceDir according to dimension and
+ // write them to destDir, using the image file format given in
+
+
+ // []propertyValue
+ return true;
+ }
+
+ // XImageShrink implementation (a sub-interface of XImageShrinkFilter)
+ public String getDestinationDirectory() {
+ return destDir;
+ }
+
+ public com.sun.star.awt.Size getDimension() {
+ return dimension;
+ }
+
+ public String getSourceDirectory() {
+ return sourceDir;
+ }
+
+ public void setDestinationDirectory(String str) {
+ destDir = str;
+ }
+
+ public void setDimension(com.sun.star.awt.Size size) {
+ dimension = size;
+ }
+
+ public void setSourceDirectory(String str) {
+ sourceDir = str;
+ }
+
+ //XServiceInfo implementation
+ public String getImplementationName( ) {
+ return getClass().getName();
+ }
+
+ public boolean supportsService(String serviceName) {
+ if ( serviceName.equals( __serviceName))
+ return true;
+ return false;
+ }
+
+ public String[] getSupportedServiceNames( ) {
+ return new String[] { __serviceName };
+ }
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/Components/Thumbs/org/openoffice/comp/test/Makefile b/odk/examples/DevelopersGuide/Components/Thumbs/org/openoffice/comp/test/Makefile
new file mode 100644
index 000000000..8792173e6
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Components/Thumbs/org/openoffice/comp/test/Makefile
@@ -0,0 +1,128 @@
+#*************************************************************************
+#
+# The Contents of this file are made available subject to the terms of
+# the BSD license.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+# 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+# contributors may be used to endorse or promote products derived
+# from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+# TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+# USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+#**************************************************************************
+
+# Builds the SpreadSheet examples of the Developers Guide.
+
+PRJ=../../../../../../../..
+SETTINGS=$(PRJ)/settings
+
+include $(SETTINGS)/settings.mk
+include $(SETTINGS)/std.mk
+
+include ../../../../thumbs.mk
+
+# Define non-platform/compiler specific settings
+PACKAGE = org/openoffice/comp/test
+
+SDK_CLASSPATH = $(subst $(EMPTYSTRING) $(PATH_SEPARATOR),$(PATH_SEPARATOR),$(CLASSPATH)\
+ $(PATH_SEPARATOR)$(OUT_COMP_CLASS))
+
+
+# Targets
+.PHONY: ALL
+ALL : $(REGISTERFLAG) \
+ $(APP1_JAR)
+
+include $(SETTINGS)/stdtarget.mk
+
+$(OUT_COMP_CLASS)/%.Manifest :
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ @echo UNO-Type-Path: $(basename $(notdir $*)).uno.jar> $@
+ @echo RegistrationClassName: $(subst /,.,$(PACKAGE)).$(basename $(basename $(@F)))>> $@
+
+$(OUT_COMP_CLASS)/$(PACKAGE)/%.class : %.java
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ $(SDK_JAVAC) $(JAVAC_FLAGS) -classpath "$(SDK_CLASSPATH)" -d $(OUT_COMP_CLASS) $<
+
+$(OUT_COMP_CLASS)/%.mf :
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ @echo Main-Class: com.sun.star.lib.loader.Loader> $@
+ $(ECHOLINE)>> $@
+ @echo Name: com/sun/star/lib/loader/Loader.class>> $@
+ @echo Application-Class: $(subst /,.,$(PACKAGE)).$*>> $@
+
+# rule for component jar file
+$(COMP_JAR) : $(COMP_MANIFESTFILE) $(OUT_COMP_CLASS)/$(PACKAGE)/$(COMP_NAME).class
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ $(SDK_JAR) cvfm $@ $< -C $(OUT_COMP_CLASS) $(PACKAGE)/$(basename $(basename $(@F))).class $(patsubst %.class,-C $(OUT_COMP_CLASS) %.class,$(GENCLASSNAMES))
+
+# rule for component package manifest
+$(OUT_COMP_CLASS)/%/manifest.xml :
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ @echo $(OSEP)?xml version="$(QM)1.0$(QM)" encoding="$(QM)UTF-8$(QM)"?$(CSEP) > $@
+ @echo $(OSEP)!DOCTYPE manifest:manifest PUBLIC "$(QM)-//OpenOffice.org//DTD Manifest 1.0//EN$(QM)" "$(QM)Manifest.dtd$(QM)"$(CSEP) >> $@
+ @echo $(OSEP)manifest:manifest xmlns:manifest="$(QM)http://openoffice.org/2001/manifest$(QM)"$(CSEP) >> $@
+ @echo $(SQM) $(SQM)$(OSEP)manifest:file-entry manifest:media-type="$(QM)application/vnd.sun.star.uno-typelibrary;type=RDB$(QM)" >> $@
+ @echo $(SQM) $(SQM)manifest:full-path="$(QM)$(subst /META-INF,,$(subst $(OUT_COMP_CLASS)/,,$(@D))).uno.rdb$(QM)"/$(CSEP) >> $@
+ @echo $(SQM) $(SQM)$(OSEP)manifest:file-entry manifest:media-type="$(QM)application/vnd.sun.star.uno-components$(QM)">> $@
+ @echo $(SQM) $(SQM)manifest:full-path="$(QM)$(COMP_COMPONENTS)$(QM)"/$(CSEP)>> $@
+ @echo $(OSEP)/manifest:manifest$(CSEP) >> $@
+
+# rule for component package file
+$(COMP_PACKAGE) : $(COMP_RDB) $(COMP_JAR) $(COMP_UNOPKG_MANIFEST) $(COMP_COMPONENTS) description.xml
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ $(COPY) $(subst /,$(PS),$(COMP_RDB)) $(subst /,$(PS),$(OUT_COMP_CLASS))
+ $(SDK_ZIP) $@ $(COMP_COMPONENTS) description.xml
+ cd $(subst /,$(PS),$(OUT_COMP_CLASS)) && $(SDK_ZIP) -u ../../bin/$(@F) $(COMP_RDB_NAME) $(COMP_JAR_NAME)
+ cd $(subst /,$(PS),$(OUT_COMP_CLASS)/$(subst .$(UNOOXT_EXT),,$(@F))) && $(SDK_ZIP) -u ../../../bin/$(@F) META-INF/manifest.xml
+ $(DEL) $(subst \\,\,$(subst /,$(PS),$(OUT_CLASS)/$(COMP_RDB_NAME)))
+
+$(APP1_JAR) : $(OUT_COMP_CLASS)/$(APP1_NAME).mf $(OUT_COMP_CLASS)/$(PACKAGE)/$(APP1_NAME).class
+ -$(MKDIR) $(subst /,$(PS),$(@D)) && $(DEL) $(subst \\,\,$(subst /,$(PS),$@))
+ $(SDK_JAR) cvfm $@ $< -C $(OUT_COMP_CLASS) $(PACKAGE)/$(basename $(@F)).class $(patsubst %.class,-C $(OUT_COMP_CLASS) %.class,$(GENCLASSNAMES))
+ +$(SDK_JAR) uvf $@ $(SDK_JAVA_UNO_BOOTSTRAP_FILES)
+
+
+$(REGISTERFLAG) : $(COMP_PACKAGE)
+ifeq "$(SDK_AUTO_DEPLOYMENT)" "YES"
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ $(DEPLOYTOOL) $(COMP_PACKAGE_URL)
+ @echo flagged > $(subst /,$(PS),$@)
+else
+ @echo --------------------------------------------------------------------------------
+ @echo If you want to install your component automatically, please set the environment
+ @echo variable SDK_AUTO_DEPLOYMENT = YES. But note that auto deployment is only
+ @echo possible if no office instance is running.
+ @echo --------------------------------------------------------------------------------
+endif
+
+.PHONY: clean
+clean :
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$(COMP_PACKAGE_URL)))
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$(COMP_JAR)))
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$(REGISTERFLAG)))
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$(APP1_JAR)))
diff --git a/odk/examples/DevelopersGuide/Components/Thumbs/org/openoffice/comp/test/Thumbs.java b/odk/examples/DevelopersGuide/Components/Thumbs/org/openoffice/comp/test/Thumbs.java
new file mode 100644
index 000000000..a43c4da87
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Components/Thumbs/org/openoffice/comp/test/Thumbs.java
@@ -0,0 +1,79 @@
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+package org.openoffice.comp.test;
+
+
+/**
+ * Test class for testing the ImageShrink service skeleton.
+ * Note: the image shrink functionality is not implemented
+ */
+public class Thumbs {
+
+ /**
+ * @param args the command line arguments
+ */
+ public static void main(String[] args) {
+ try {
+ // get the remote office component context
+ com.sun.star.uno.XComponentContext xRemoteContext =
+ com.sun.star.comp.helper.Bootstrap.bootstrap();
+
+ System.out.println("Connected to a running office ...");
+
+ // use the generated default create method to instantiate a
+ // new ImageShrink object
+ org.openoffice.test.XImageShrinkFilter xImageShrinkFilter =
+ org.openoffice.test.ImageShrink.create(xRemoteContext);
+
+ System.out.println("ImageShrink component successfully instantiated");
+
+ java.io.File f = new java.io.File(".");
+ System.out.println("set SourceDirectory...");
+ xImageShrinkFilter.setSourceDirectory(f.getCanonicalPath());
+
+ System.out.println("source Directory = "
+ + xImageShrinkFilter.getSourceDirectory());
+ }
+ catch (java.lang.Exception e){
+ System.err.println("Error: " + e);
+ e.printStackTrace();
+ }
+ finally {
+ System.exit(0);
+ }
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/Components/Thumbs/org/openoffice/comp/test/description.xml b/odk/examples/DevelopersGuide/Components/Thumbs/org/openoffice/comp/test/description.xml
new file mode 100644
index 000000000..6c4e2396b
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Components/Thumbs/org/openoffice/comp/test/description.xml
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+-->
+<d:description xmlns:d="http://openoffice.org/extensions/description/2006">
+ <d:dependencies>
+ <l:LibreOffice-minimal-version value="4.1" d:name="LibreOffice 4.1"
+ xmlns:l="http://libreoffice.org/extensions/description/2011"/>
+ </d:dependencies>
+</d:description>
diff --git a/odk/examples/DevelopersGuide/Components/Thumbs/org/openoffice/test/ImageShrink.idl b/odk/examples/DevelopersGuide/Components/Thumbs/org/openoffice/test/ImageShrink.idl
new file mode 100644
index 000000000..29741ffeb
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Components/Thumbs/org/openoffice/test/ImageShrink.idl
@@ -0,0 +1,49 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+#ifndef _org_openoffice_test_ImageShrink_idl_
+#define _org_openoffice_test_ImageShrink_idl_
+
+#include <org/openoffice/test/XImageShrinkFilter.idl>
+
+module org { module openoffice { module test {
+
+ service ImageShrink : XImageShrinkFilter;
+
+}; }; };
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/Components/Thumbs/org/openoffice/test/Makefile b/odk/examples/DevelopersGuide/Components/Thumbs/org/openoffice/test/Makefile
new file mode 100644
index 000000000..b2622e9e6
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Components/Thumbs/org/openoffice/test/Makefile
@@ -0,0 +1,68 @@
+#*************************************************************************
+#
+# The Contents of this file are made available subject to the terms of
+# the BSD license.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+# 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+# contributors may be used to endorse or promote products derived
+# from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+# TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+# USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+#**************************************************************************
+
+# Builds the SpreadSheet examples of the Developers Guide.
+
+PRJ=../../../../../../..
+SETTINGS=$(PRJ)/settings
+
+include $(SETTINGS)/settings.mk
+include $(SETTINGS)/std.mk
+
+include ../../../thumbs.mk
+
+PACKAGE = org/openoffice/test
+
+SDK_CLASSPATH = $(subst $(EMPTYSTRING) $(PATH_SEPARATOR),$(PATH_SEPARATOR),$(CLASSPATH)\
+ $(PATH_SEPARATOR)$(OUT_COMP_CLASS))
+
+# Targets
+.PHONY: ALL
+ALL : \
+ $(GENCLASSFILES)
+
+include $(SETTINGS)/stdtarget.mk
+
+$(OUT_COMP_GEN)/%.rdb : $(IDLFILES)
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ $(UNOIDLWRITE) $(URE_TYPES) $(OFFICE_TYPES) ../../.. $@
+
+$(OUT_COMP_CLASS)/%.class : $(COMP_RDB)
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ $(JAVAMAKER) -nD $(GENTYPELIST) -O$(OUT_COMP_CLASS) $(COMP_RDB) -X$(URE_TYPES) -X$(OFFICE_TYPES)
+
+.PHONY: clean
+clean :
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$(GENCLASSFILES)))
diff --git a/odk/examples/DevelopersGuide/Components/Thumbs/org/openoffice/test/XImageShrink.idl b/odk/examples/DevelopersGuide/Components/Thumbs/org/openoffice/test/XImageShrink.idl
new file mode 100644
index 000000000..c6097925f
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Components/Thumbs/org/openoffice/test/XImageShrink.idl
@@ -0,0 +1,56 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+#ifndef _org_openoffice_test_XImageShrink_idl_
+#define _org_openoffice_test_XImageShrink_idl_
+
+#include <com/sun/star/uno/XInterface.idl>
+#include <com/sun/star/awt/Size.idl>
+
+module org { module openoffice { module test {
+
+interface XImageShrink {
+
+ [attribute] string SourceDirectory;
+ [attribute] string DestinationDirectory;
+ [attribute] com::sun::star::awt::Size Dimension;
+
+};
+
+}; }; };
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/Components/Thumbs/org/openoffice/test/XImageShrinkFilter.idl b/odk/examples/DevelopersGuide/Components/Thumbs/org/openoffice/test/XImageShrinkFilter.idl
new file mode 100644
index 000000000..6388e0aa3
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Components/Thumbs/org/openoffice/test/XImageShrinkFilter.idl
@@ -0,0 +1,53 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+#ifndef _org_openoffice_test_XImageShrinkFilter_idl_
+#define _org_openoffice_test_XImageShrinkFilter_idl_
+
+#include <com/sun/star/document/XFilter.idl>
+#include <org/openoffice/test/XImageShrink.idl>
+
+module org { module openoffice { module test {
+
+interface XImageShrinkFilter {
+ interface XImageShrink;
+ interface com::sun::star::document::XFilter;
+};
+
+}; }; };
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/Components/Thumbs/thumbs.mk b/odk/examples/DevelopersGuide/Components/Thumbs/thumbs.mk
new file mode 100644
index 000000000..07f9bfea9
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Components/Thumbs/thumbs.mk
@@ -0,0 +1,45 @@
+#
+# This file is part of the LibreOffice project.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+# This file incorporates work covered by the following license notice:
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed
+# with this work for additional information regarding copyright
+# ownership. The ASF licenses this file to you under the Apache
+# License, Version 2.0 (the "License"); you may not use this file
+# except in compliance with the License. You may obtain a copy of
+# the License at http://www.apache.org/licenses/LICENSE-2.0 .
+#
+
+OUT_COMP_CLASS = $(OUT_CLASS)/ComponentThumbsExample
+OUT_COMP_GEN = $(OUT_MISC)/ComponentThumbsExample
+
+COMP_NAME=ImageShrink
+COMP_RDB_NAME = $(COMP_NAME).uno.rdb
+COMP_RDB = $(OUT_COMP_GEN)/$(COMP_RDB_NAME)
+COMP_PACKAGE = $(OUT_BIN)/$(COMP_NAME).$(UNOOXT_EXT)
+COMP_PACKAGE_URL = $(subst \\,\,"$(COMP_PACKAGE_DIR)$(PS)$(COMP_NAME).$(UNOOXT_EXT)")
+COMP_JAR_NAME = $(COMP_NAME).uno.jar
+COMP_JAR = $(OUT_COMP_CLASS)/$(COMP_JAR_NAME)
+COMP_MANIFESTFILE = $(OUT_COMP_CLASS)/$(COMP_NAME).uno.Manifest
+COMP_UNOPKG_MANIFEST = $(OUT_COMP_CLASS)/$(COMP_NAME)/META-INF/manifest.xml
+REGISTERFLAG = $(OUT_MISC)$(PS)devguide_$(COMP_NAME)_register_component.flag
+COMP_COMPONENTS=$(COMP_NAME).components
+
+IDL_PACKAGE=org/openoffice/test
+
+IDLFILES = XImageShrink.idl \
+ XImageShrinkFilter.idl \
+ ImageShrink.idl
+
+GENCLASSFILES = $(patsubst %.idl,$(OUT_COMP_CLASS)/$(IDL_PACKAGE)/%.class,$(IDLFILES))
+GENCLASSNAMES = $(patsubst %.idl,$(IDL_PACKAGE)/%.class,$(IDLFILES))
+GENTYPELIST = $(subst /,.,$(patsubst %.idl,-T$(IDL_PACKAGE)/% ,$(IDLFILES)))
+
+APP1_NAME=Thumbs
+APP1_JAR=$(OUT_COMP_CLASS)/$(APP1_NAME).jar
diff --git a/odk/examples/DevelopersGuide/Components/dialogcomponent/DialogComponent.components b/odk/examples/DevelopersGuide/Components/dialogcomponent/DialogComponent.components
new file mode 100644
index 000000000..56d7c8eb8
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Components/dialogcomponent/DialogComponent.components
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<components xmlns="http://openoffice.org/2010/uno-components">
+ <component loader="com.sun.star.loader.Java2" uri="DialogComponent.uno.jar">
+ <implementation name="DialogComponent$_DialogComponent">
+ <service name="com.sun.star.test.TestDialogHandler"/>
+ </implementation>
+ </component>
+</components>
diff --git a/odk/examples/DevelopersGuide/Components/dialogcomponent/DialogComponent.java b/odk/examples/DevelopersGuide/Components/dialogcomponent/DialogComponent.java
new file mode 100644
index 000000000..643dcda64
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Components/dialogcomponent/DialogComponent.java
@@ -0,0 +1,294 @@
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+import com.sun.star.beans.XPropertySet;
+import com.sun.star.uno.Type;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.XComponentContext;
+import com.sun.star.lang.XMultiComponentFactory;
+import com.sun.star.lang.XTypeProvider;
+import com.sun.star.lang.XServiceInfo;
+import com.sun.star.lang.XSingleComponentFactory;
+import com.sun.star.lib.uno.helper.Factory;
+import com.sun.star.awt.XControl;
+import com.sun.star.awt.XControlContainer;
+import com.sun.star.awt.XControlModel;
+import com.sun.star.awt.XDialog;
+import com.sun.star.awt.XDialogEventHandler;
+import com.sun.star.awt.XDialogProvider2;
+import com.sun.star.frame.XFrame;
+import com.sun.star.frame.XModel;
+
+import com.sun.star.awt.XToolkit;
+import com.sun.star.awt.XWindowPeer;
+import com.sun.star.awt.XMessageBox;
+import com.sun.star.awt.WindowAttribute;
+import com.sun.star.awt.WindowClass;
+import com.sun.star.awt.WindowDescriptor;
+import com.sun.star.awt.Rectangle;
+
+import com.sun.star.test.XTestDialogHandler;
+
+// DialogComponent implements all necessary interfaces self, this is only
+// for demonstration. More convenient is to use the implementation WeakBase or
+// ComponentBase, see implementation of TestComponentA.
+public class DialogComponent {
+
+ public static class _DialogComponent
+ implements XTypeProvider, XServiceInfo, XTestDialogHandler, XDialogEventHandler {
+
+ private static final String __serviceName= "com.sun.star.test.TestDialogHandler";
+
+
+ private final XComponentContext m_xCmpCtx;
+
+ private XFrame m_xFrame;
+ private XToolkit m_xToolkit;
+
+ public _DialogComponent(XComponentContext context) {
+ m_xCmpCtx= context;
+
+ try {
+ // Create the toolkit to have access to it later
+ m_xToolkit = UnoRuntime.queryInterface(
+ XToolkit.class,
+ m_xCmpCtx.getServiceManager().createInstanceWithContext("com.sun.star.awt.Toolkit",
+ m_xCmpCtx));
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ // XTestDialogHandler
+ public String createDialog( String DialogURL, XModel xModel, XFrame xFrame ) {
+ m_xFrame = xFrame;
+
+ try {
+ XMultiComponentFactory xMCF = m_xCmpCtx.getServiceManager();
+ Object obj;
+
+ // If valid we must pass the XModel when creating a DialogProvider object
+ if( xModel != null ) {
+ Object[] args = new Object[1];
+ args[0] = xModel;
+
+ obj = xMCF.createInstanceWithArgumentsAndContext(
+ "com.sun.star.awt.DialogProvider2", args, m_xCmpCtx );
+ }
+ else {
+ obj = xMCF.createInstanceWithContext(
+ "com.sun.star.awt.DialogProvider2", m_xCmpCtx );
+ }
+
+ XDialogProvider2 xDialogProvider = UnoRuntime.queryInterface( XDialogProvider2.class, obj );
+
+ XDialog xDialog = xDialogProvider.createDialogWithHandler( DialogURL, this );
+ if( xDialog != null )
+ xDialog.execute();
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ }
+ return "Created dialog \"" + DialogURL + "\"";
+ }
+
+ public void copyText( XDialog xDialog, Object aEventObject ) {
+ XControlContainer xControlContainer = UnoRuntime.queryInterface(
+ XControlContainer.class, xDialog );
+ String aTextPropertyStr = "Text";
+ String aText = "";
+ XControl xTextField1Control = xControlContainer.getControl( "TextField1" );
+ XControlModel xControlModel1 = xTextField1Control.getModel();
+ XPropertySet xPropertySet1 = UnoRuntime.queryInterface(
+ XPropertySet.class, xControlModel1 );
+ try
+ {
+ aText = (String)xPropertySet1.getPropertyValue( aTextPropertyStr );
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ XControl xTextField2Control = xControlContainer.getControl( "TextField2" );
+ XControlModel xControlModel2 = xTextField2Control.getModel();
+ XPropertySet xPropertySet2 = UnoRuntime.queryInterface(
+ XPropertySet.class, xControlModel2 );
+ try
+ {
+ xPropertySet2.setPropertyValue( aTextPropertyStr, aText );
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ showMessageBox( "DialogComponent", "copyText() called" );
+ }
+
+ public void handleEvent() {
+ showMessageBox( "DialogComponent", "handleEvent() called" );
+ }
+
+ public void handleEventWithArguments( XDialog xDialog, Object aEventObject ) {
+ showMessageBox( "DialogComponent", "handleEventWithArguments() called\n\n" +
+ "Event Object = " + aEventObject );
+ }
+
+ private static final String aHandlerMethod1 = "doit1";
+ private static final String aHandlerMethod2 = "doit2";
+ private static final String aHandlerMethod3 = "doit3";
+
+ //XDialogEventHandler
+ public boolean callHandlerMethod( /*IN*/XDialog xDialog, /*IN*/Object EventObject, /*IN*/String MethodName ) {
+ if ( MethodName.equals( aHandlerMethod1 ) )
+ {
+ showMessageBox( "DialogComponent", "callHandlerMethod() handled \"" + aHandlerMethod1 + "\"" );
+ return true;
+ }
+ else if ( MethodName.equals( aHandlerMethod2 ) )
+ {
+ showMessageBox( "DialogComponent", "callHandlerMethod() handled \"" + aHandlerMethod2 + "\"" );
+ return true;
+ }
+ else if ( MethodName.equals( aHandlerMethod3 ) )
+ {
+ showMessageBox( "DialogComponent", "callHandlerMethod() handled \"" + aHandlerMethod3 + "\"" );
+ return true;
+ }
+ return false;
+ }
+
+ public String[] getSupportedMethodNames() {
+ String[] retValue= new String[] {
+ aHandlerMethod1,
+ aHandlerMethod2,
+ aHandlerMethod3 };
+ return retValue;
+ }
+
+
+ //XTypeProvider
+ public com.sun.star.uno.Type[] getTypes( ) {
+ Type[] retValue= new Type[4];
+ retValue[0]= new Type( XServiceInfo.class);
+ retValue[1]= new Type( XTypeProvider.class);
+ retValue[2]= new Type( XTestDialogHandler.class);
+ retValue[3]= new Type( XDialogEventHandler.class);
+ return retValue;
+ }
+ //XTypeProvider
+ public byte[] getImplementationId( ) {
+ return new byte[0];
+ }
+
+
+
+ /** This method is a simple helper function to used in the
+ * static component initialisation functions as well as in
+ * getSupportedServiceNames.
+ */
+ private static String[] getServiceNames() {
+ String[] sSupportedServiceNames = { __serviceName };
+ return sSupportedServiceNames;
+ }
+
+ //XServiceInfo
+ public String[] getSupportedServiceNames() {
+ return getServiceNames();
+ }
+
+ //XServiceInfo
+ public boolean supportsService( String sServiceName ) {
+ return sServiceName.equals( __serviceName );
+ }
+
+ //XServiceInfo
+ public String getImplementationName() {
+ return _DialogComponent.class.getName();
+ }
+
+ private void showMessageBox(String sTitle, String sMessage) {
+ if ( null != m_xFrame && null != m_xToolkit ) {
+
+ // describe window properties.
+ WindowDescriptor aDescriptor = new WindowDescriptor();
+ aDescriptor.Type = WindowClass.MODALTOP;
+ aDescriptor.WindowServiceName = "infobox";
+ aDescriptor.ParentIndex = -1;
+ aDescriptor.Parent = UnoRuntime.queryInterface(
+ XWindowPeer.class, m_xFrame.getContainerWindow());
+ aDescriptor.Bounds = new Rectangle(0,0,300,200);
+ aDescriptor.WindowAttributes = WindowAttribute.BORDER |
+ WindowAttribute.MOVEABLE |
+ WindowAttribute.CLOSEABLE;
+
+ XWindowPeer xPeer = m_xToolkit.createWindow( aDescriptor );
+ if ( null != xPeer ) {
+ XMessageBox xMsgBox = UnoRuntime.queryInterface(
+ XMessageBox.class, xPeer);
+ if ( null != xMsgBox )
+ {
+ xMsgBox.setCaptionText( sTitle );
+ xMsgBox.setMessageText( sMessage );
+ xMsgBox.execute();
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * Gives a factory for creating the service.
+ * This method is called by the <code>JavaLoader</code>
+ * <p>
+ * @return returns a <code>XSingleComponentFactory</code> for creating
+ * the component
+ * @param sImplName the name of the implementation for which a
+ * service is desired
+ * @see com.sun.star.comp.loader.JavaLoader
+ */
+ public static XSingleComponentFactory __getComponentFactory(String sImplName)
+ {
+ XSingleComponentFactory xFactory = null;
+
+ if ( sImplName.equals( _DialogComponent.class.getName() ) )
+ xFactory = Factory.createComponentFactory(_DialogComponent.class,
+ _DialogComponent.getServiceNames());
+
+ return xFactory;
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/Components/dialogcomponent/DialogComponent.odt b/odk/examples/DevelopersGuide/Components/dialogcomponent/DialogComponent.odt
new file mode 100644
index 000000000..bd6a9b40f
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Components/dialogcomponent/DialogComponent.odt
Binary files differ
diff --git a/odk/examples/DevelopersGuide/Components/dialogcomponent/Makefile b/odk/examples/DevelopersGuide/Components/dialogcomponent/Makefile
new file mode 100644
index 000000000..84d489e18
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Components/dialogcomponent/Makefile
@@ -0,0 +1,171 @@
+#*************************************************************************
+#
+# The Contents of this file are made available subject to the terms of
+# the BSD license.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+# 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+# contributors may be used to endorse or promote products derived
+# from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+# TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+# USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+#**************************************************************************
+
+# Builds the Java dialog component example of the SDK.
+
+PRJ=../../../..
+SETTINGS=$(PRJ)/settings
+
+include $(SETTINGS)/settings.mk
+include $(SETTINGS)/std.mk
+
+# Define non-platform/compiler specific settings
+
+# we use the sample directory name for separating this example
+# from others in the output directory
+SAMPLE_NAME=DialogComponentSample
+SAMPLE_CLASS_OUT=$(OUT_CLASS)/$(SAMPLE_NAME)
+SAMPLE_GEN_OUT=$(OUT_MISC)/$(SAMPLE_NAME)
+
+COMP_NAME=DialogComponent
+COMP_CLASS_OUT=$(SAMPLE_CLASS_OUT)/$(COMP_NAME)
+COMP_GEN_OUT=$(SAMPLE_GEN_OUT)/$(COMP_NAME)
+COMP_RDB_NAME=$(COMP_NAME).uno.rdb
+COMP_RDB=$(COMP_GEN_OUT)/$(COMP_RDB_NAME)
+COMP_PACKAGE=$(OUT_BIN)/$(COMP_NAME).$(UNOOXT_EXT)
+COMP_PACKAGE_URL=$(subst \\,\,"$(COMP_PACKAGE_DIR)$(PS)$(COMP_NAME).$(UNOOXT_EXT)")
+COMP_JAR_NAME=$(COMP_NAME).uno.jar
+COMP_JAR=$(SAMPLE_CLASS_OUT)/$(COMP_JAR_NAME)
+COMP_JAR_MANIFEST=$(COMP_GEN_OUT)/$(COMP_NAME).uno.Manifest
+COMP_UNOPKG_MANIFEST = $(COMP_GEN_OUT)/META-INF/manifest.xml
+COMP_REGISTERFLAG=$(COMP_GEN_OUT)$(PS)java_$(COMP_NAME)_register_component.flag
+COMP_COMPONENTS=$(COMP_NAME).components
+
+IDLFILES = XTestDialogHandler.idl \
+ TestDialogHandler.idl
+
+PACKAGE = com/sun/star/test
+#PACKAGE = org/openoffice
+
+COMP_JAVAFILES = DialogComponent.java
+COMP_CLASSFILES = $(patsubst %.java,$(COMP_CLASS_OUT)/%.class,$(COMP_JAVAFILES))
+
+GEN_CLASSFILES = $(patsubst %.idl,$(SAMPLE_CLASS_OUT)/$(PACKAGE)/%.class,$(IDLFILES))
+GEN_TYPELIST = $(subst /,.,$(patsubst %.idl,-T$(PACKAGE)/% ,$(IDLFILES)))
+
+# the generated types are necessary for the component and the application jar
+GEN_CLASSFILENAMES = $(subst $(SAMPLE_CLASS_OUT)/,,$(GEN_CLASSFILES))
+
+SDK_CLASSPATH = $(subst $(EMPTYSTRING) $(PATH_SEPARATOR),$(PATH_SEPARATOR),$(CLASSPATH)\
+ $(PATH_SEPARATOR)$(SAMPLE_CLASS_OUT)\
+ $(PATH_SEPARATOR)$(COMP_CLASS_OUT)\
+ $(PATH_SEPARATOR)$(APP1_CLASS_OUT))
+
+
+# Targets
+.PHONY: ALL
+ALL : DialogComponentExample
+
+include $(SETTINGS)/stdtarget.mk
+
+$(COMP_GEN_OUT)/%.Manifest :
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ @echo UNO-Type-Path: $(basename $(notdir $*)).uno.jar> $@
+ @echo RegistrationClassName: $(basename $*)>> $@
+
+$(COMP_GEN_OUT)/%.rdb : $(patsubst %,$(PACKAGE)/%,$(IDLFILES))
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ $(UNOIDLWRITE) $(URE_TYPES) $(OFFICE_TYPES) . $@
+
+$(GEN_CLASSFILES) : $(COMP_RDB)
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ $(JAVAMAKER) -nD $(GEN_TYPELIST) -O$(SAMPLE_CLASS_OUT) $(COMP_RDB) -X$(URE_TYPES) -X$(OFFICE_TYPES)
+
+# component as well as application are dependent from the generated types
+# rule for component class files
+$(COMP_CLASS_OUT)/%.class : %.java $(GEN_CLASSFILES)
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ $(SDK_JAVAC) $(JAVAC_FLAGS) -classpath "$(SDK_CLASSPATH)" -d $(COMP_CLASS_OUT) $<
+
+# rule for component jar file
+$(COMP_JAR) : $(COMP_JAR_MANIFEST) $(COMP_CLASSFILES)
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ $(SDK_JAR) cvfm $@ $< -C $(COMP_CLASS_OUT) .
+ +cd $(subst /,$(PS),$(SAMPLE_CLASS_OUT)) && $(SDK_JAR) uvf $(@F) $(GEN_CLASSFILENAMES)
+
+# rule for component package manifest
+$(COMP_GEN_OUT)/%/manifest.xml :
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ @echo $(OSEP)?xml version="$(QM)1.0$(QM)" encoding="$(QM)UTF-8$(QM)"?$(CSEP) > $@
+ @echo $(OSEP)!DOCTYPE manifest:manifest PUBLIC "$(QM)-//OpenOffice.org//DTD Manifest 1.0//EN$(QM)" "$(QM)Manifest.dtd$(QM)"$(CSEP) >> $@
+ @echo $(OSEP)manifest:manifest xmlns:manifest="$(QM)http://openoffice.org/2001/manifest$(QM)"$(CSEP) >> $@
+ @echo $(SQM) $(SQM)$(OSEP)manifest:file-entry manifest:media-type="$(QM)application/vnd.sun.star.uno-typelibrary;type=RDB$(QM)" >> $@
+ @echo $(SQM) $(SQM)manifest:full-path="$(QM)$(subst /META-INF,,$(subst $(SAMPLE_GEN_OUT)/,,$(@D))).uno.rdb$(QM)"/$(CSEP) >> $@
+ @echo $(SQM) $(SQM)$(OSEP)manifest:file-entry manifest:media-type="$(QM)application/vnd.sun.star.uno-components$(QM)">> $@
+ @echo $(SQM) $(SQM)manifest:full-path="$(QM)$(COMP_COMPONENTS)$(QM)"/$(CSEP)>> $@
+ @echo $(OSEP)/manifest:manifest$(CSEP) >> $@
+
+# rule for component package file
+$(COMP_PACKAGE) : $(COMP_RDB) $(COMP_JAR) $(COMP_UNOPKG_MANIFEST) $(COMP_COMPONENTS) description.xml
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ $(SDK_ZIP) $@ $(COMP_COMPONENTS) description.xml
+ cd $(subst /,$(PS),$(COMP_GEN_OUT)) && $(SDK_ZIP) -u ../../../bin/$(@F) $(COMP_RDB_NAME)
+ cd $(subst /,$(PS),$(SAMPLE_CLASS_OUT)) && $(SDK_ZIP) -u ../../bin/$(@F) $(COMP_JAR_NAME)
+ cd $(subst /,$(PS),$(COMP_GEN_OUT)) && $(SDK_ZIP) -u ../../../bin/$(@F) META-INF/manifest.xml
+
+$(COMP_REGISTERFLAG) : $(COMP_PACKAGE)
+ifeq "$(SDK_AUTO_DEPLOYMENT)" "YES"
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ $(DEPLOYTOOL) $(COMP_PACKAGE_URL)
+ @echo flagged > $(subst /,$(PS),$@)
+else
+ @echo --------------------------------------------------------------------------------
+ @echo If you want to install your component automatically, please set the environment
+ @echo variable SDK_AUTO_DEPLOYMENT = YES. But note that auto deployment is only
+ @echo possible if no office instance is running.
+ @echo --------------------------------------------------------------------------------
+endif
+
+DialogComponentExample : $(COMP_REGISTERFLAG)
+# TODO: adapt
+ @echo --------------------------------------------------------------------------------
+ @echo The PropTest was installed if SDK_AUTO_DEPLOYMENT = YES.
+ @echo Load the "$(QM)PropertySet.odt$(QM)" document to see how this component works. You can
+ @echo use this component inside your office installation, see the example description.
+ @echo -
+ @echo $(MAKE) DialogComponent.odt.load
+ @echo --------------------------------------------------------------------------------
+
+DialogComponent.odt.load : $(COMP_REGISTERFLAG)
+ "$(OFFICE_PROGRAM_PATH)$(PS)soffice" $(basename $@)
+
+.PHONY: clean
+clean :
+ -$(DELRECURSIVE) $(subst /,$(PS),$(SAMPLE_CLASS_OUT))
+ -$(DELRECURSIVE) $(subst /,$(PS),$(SAMPLE_GEN_OUT))
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$(COMP_PACKAGE_URL)))
diff --git a/odk/examples/DevelopersGuide/Components/dialogcomponent/com/sun/star/test/TestDialogHandler.idl b/odk/examples/DevelopersGuide/Components/dialogcomponent/com/sun/star/test/TestDialogHandler.idl
new file mode 100644
index 000000000..1c5e8ad4c
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Components/dialogcomponent/com/sun/star/test/TestDialogHandler.idl
@@ -0,0 +1,49 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+#ifndef INCLUDED_COM_SUN_STAR_TEST_TESTDIALOGHANDLER_IDL
+#define INCLUDED_COM_SUN_STAR_TEST_TESTDIALOGHANDLER_IDL
+
+#include <XTestDialogHandler.idl>
+
+module com { module sun { module star { module test {
+ service TestDialogHandler : XTestDialogHandler;
+}; }; }; };
+
+#endif
+
+
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/Components/dialogcomponent/com/sun/star/test/XTestDialogHandler.idl b/odk/examples/DevelopersGuide/Components/dialogcomponent/com/sun/star/test/XTestDialogHandler.idl
new file mode 100644
index 000000000..b7c680f36
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Components/dialogcomponent/com/sun/star/test/XTestDialogHandler.idl
@@ -0,0 +1,56 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+#ifndef INCLUDED_COM_SUN_STAR_TEST_XTESTDIALOGHANDLER_IDL
+#define INCLUDED_COM_SUN_STAR_TEST_XTESTDIALOGHANDLER_IDL
+
+#include <com/sun/star/uno/XInterface.idl>
+#include <com/sun/star/awt/XDialog.idl>
+#include <com/sun/star/frame/XModel.idl>
+#include <com/sun/star/frame/XFrame.idl>
+
+module com { module sun { module star { module test {
+ interface XTestDialogHandler {
+ string createDialog( [in] string DialogURL, [in] ::com::sun::star::frame::XModel xModel,
+ [in] ::com::sun::star::frame::XFrame xFrame );
+ void copyText( [in] ::com::sun::star::awt::XDialog xDialog, [in] any aEventObject );
+ void handleEvent();
+ void handleEventWithArguments( [in] ::com::sun::star::awt::XDialog xDialog, [in] any aEventObject );
+ };
+}; }; }; };
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/Components/dialogcomponent/description.xml b/odk/examples/DevelopersGuide/Components/dialogcomponent/description.xml
new file mode 100644
index 000000000..6c4e2396b
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Components/dialogcomponent/description.xml
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+-->
+<d:description xmlns:d="http://openoffice.org/extensions/description/2006">
+ <d:dependencies>
+ <l:LibreOffice-minimal-version value="4.1" d:name="LibreOffice 4.1"
+ xmlns:l="http://libreoffice.org/extensions/description/2011"/>
+ </d:dependencies>
+</d:description>
diff --git a/odk/examples/DevelopersGuide/Config/ConfigExamples.java b/odk/examples/DevelopersGuide/Config/ConfigExamples.java
new file mode 100644
index 000000000..b74d24f7d
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Config/ConfigExamples.java
@@ -0,0 +1,1102 @@
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+// Import everything we use
+
+import com.sun.star.beans.XPropertySet;
+import com.sun.star.beans.XMultiPropertySet;
+import com.sun.star.beans.XHierarchicalPropertySet;
+import com.sun.star.beans.XMultiHierarchicalPropertySet;
+import com.sun.star.beans.XPropertyState;
+import com.sun.star.beans.XMultiPropertyStates;
+
+import com.sun.star.configuration.XTemplateInstance;
+
+import com.sun.star.container.XNameAccess;
+import com.sun.star.container.XNameReplace;
+import com.sun.star.container.XNameContainer;
+import com.sun.star.container.XNamed;
+import com.sun.star.container.XChild;
+import com.sun.star.container.XHierarchicalNameAccess;
+import com.sun.star.container.XHierarchicalName;
+
+import com.sun.star.lang.XComponent;
+import com.sun.star.lang.XMultiComponentFactory;
+import com.sun.star.lang.XSingleServiceFactory;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.lang.XServiceInfo;
+import com.sun.star.lang.EventObject;
+
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.XComponentContext;
+import com.sun.star.uno.XInterface;
+import com.sun.star.uno.AnyConverter;
+
+import com.sun.star.util.XChangesBatch;
+import com.sun.star.util.XChangesNotifier;
+import com.sun.star.util.XChangesListener;
+import com.sun.star.util.ChangesEvent;
+// Config examples
+
+/* These examples show how to use the following features of the Config API:
+
+ o Accessing data
+ o Updating data
+ o Updating properties in groups
+ o Adding and removing items in sets
+ o Resetting data to their defaults
+
+ Each example is in a separate method call.
+*/
+public class ConfigExamples
+{
+ // The ComponentContext interface of the remote component context
+ private final XComponentContext mxContext;
+
+ // The MultiComponentFactory interface of the ServiceManager
+ private final XMultiComponentFactory mxServiceManager;
+
+ // The MultiServiceFactory interface of the ConfigurationProvider
+ private XMultiServiceFactory mxProvider = null;
+
+ public static void main( String args[] )
+ {
+ try {
+ // get the remote office component context
+ com.sun.star.uno.XComponentContext xContext =
+ com.sun.star.comp.helper.Bootstrap.bootstrap();
+
+ if( xContext != null )
+ System.out.println("Connected to a running office ...");
+ else
+ System.out.println( "ERROR: Cannot connect - no remote component context available." );
+
+ // Create an instance of the class and call its run method
+ ConfigExamples aExample = new ConfigExamples(xContext);
+ aExample.run( );
+
+ // if you own the service manager dispose it here
+ // to ensure that the default provider is properly disposed and flushed
+ System.exit(0);
+ }
+ catch( Exception e )
+ {
+ e.printStackTrace();
+ System.exit(-1);
+ }
+ }
+
+ /** Create a ConfigExamples instance supplying a service factory
+ */
+ public ConfigExamples(XComponentContext xContext)
+ {
+ mxContext = xContext;
+ mxServiceManager = xContext.getServiceManager();
+ }
+
+ /** Run the examples with a default ConfigurationProvider
+ */
+ public void run()
+ throws com.sun.star.uno.Exception
+ {
+ mxProvider = createProvider();
+
+ runExamples( );
+
+ // we are using the default ConfigurationProvider, so we must not dispose it
+ mxProvider = null;
+ }
+
+ /** Run the examples with a given ConfigurationProvider
+ */
+ public void runExamples( )
+ {
+ if (checkProvider(mxProvider))
+ {
+ System.out.println("\nStarting examples.");
+
+ readDataExample();
+
+ browseDataExample();
+
+ updateGroupExample();
+
+ resetGroupExample();
+
+ updateSetExample();
+
+ System.out.println("\nAll Examples completed.");
+ }
+ else
+ System.out.println("ERROR: Cannot run examples without ConfigurationProvider.");
+
+ }
+
+ /** Do some simple checks, if there is a valid ConfigurationProvider
+ */
+ public static boolean checkProvider(XMultiServiceFactory xProvider)
+ {
+ // check the provider we have
+ if (xProvider == null)
+ {
+ System.out.println("No provider available. Cannot access configuration data.");
+ return false;
+
+ }
+
+ try
+ {
+ // check the provider implementation
+ XServiceInfo xProviderServices =
+ UnoRuntime.queryInterface( XServiceInfo.class, xProvider );
+
+ if (xProviderServices == null ||
+ !xProviderServices.supportsService("com.sun.star.configuration.ConfigurationProvider"))
+ {
+ System.out.println("WARNING: The provider is not a com.sun.star.configuration.ConfigurationProvider");
+ }
+
+ if (xProviderServices != null)
+ {
+ System.out.println("Using provider implementation: " + xProviderServices.getImplementationName());
+ }
+
+ return true;
+ }
+ catch (com.sun.star.uno.RuntimeException e)
+ {
+ System.err.println("ERROR: Failure while checking the provider services.");
+ e.printStackTrace();
+ return false;
+ }
+ }
+
+ /** Get the provider we have
+ */
+ public XMultiServiceFactory getProvider( )
+ {
+ return mxProvider;
+ }
+
+ /** Create a default configuration provider
+ */
+ public XMultiServiceFactory createProvider( )
+ throws com.sun.star.uno.Exception
+ {
+ final String sProviderService = "com.sun.star.configuration.ConfigurationProvider";
+
+ // create the provider and return it as a XMultiServiceFactory
+ XMultiServiceFactory xProvider = UnoRuntime.queryInterface(XMultiServiceFactory.class,
+ mxServiceManager.createInstanceWithContext(sProviderService,
+ mxContext));
+
+ return xProvider;
+ }
+
+ /** Create a specified read-only configuration view
+ */
+ public Object createConfigurationView( String sPath )
+ throws com.sun.star.uno.Exception
+ {
+ XMultiServiceFactory xProvider = getProvider();
+
+ // The service name: Need only read access:
+ final String sReadOnlyView = "com.sun.star.configuration.ConfigurationAccess";
+
+ // creation arguments: nodepath
+ com.sun.star.beans.PropertyValue aPathArgument = new com.sun.star.beans.PropertyValue();
+ aPathArgument.Name = "nodepath";
+ aPathArgument.Value = sPath;
+
+ Object[] aArguments = new Object[1];
+ aArguments[0] = aPathArgument;
+
+ // create the view
+ Object xViewRoot = xProvider.createInstanceWithArguments(sReadOnlyView, aArguments);
+
+ return xViewRoot;
+ }
+
+ /** Create a specified updatable configuration view
+ */
+ Object createUpdatableView( String sPath )
+ throws com.sun.star.uno.Exception
+ {
+ XMultiServiceFactory xProvider = getProvider();
+
+ // The service name: Need update access:
+ final String cUpdatableView = "com.sun.star.configuration.ConfigurationUpdateAccess";
+
+ // creation arguments: nodepath
+ com.sun.star.beans.PropertyValue aPathArgument = new com.sun.star.beans.PropertyValue();
+ aPathArgument.Name = "nodepath";
+ aPathArgument.Value = sPath;
+
+ Object[] aArguments = new Object[1];
+ aArguments[0] = aPathArgument;
+
+ // create the view
+ Object xViewRoot = xProvider.createInstanceWithArguments(cUpdatableView, aArguments);
+
+ return xViewRoot;
+ }
+
+ /** This method demonstrates read access to data
+ */
+ protected void readDataExample ()
+ {
+ try
+ {
+ System.out.println("\n--- starting example: read grid option settings --------------------");
+ Object aData = readGridConfiguration( );
+ System.out.println("Read grid options: " + aData);
+
+ }
+ catch ( Exception e )
+ {
+ e.printStackTrace();
+ }
+ }
+
+ /** This method demonstrates browsing access to data
+ */
+ protected void browseDataExample ()
+ {
+ try
+ {
+ System.out.println("\n--- starting example: browse filter configuration ------------------");
+ printRegisteredFilters( );
+ }
+ catch ( Exception e )
+ {
+ e.printStackTrace();
+ }
+ }
+
+ /** This method demonstrates update access to group data
+ */
+ protected void updateGroupExample ()
+ {
+ try
+ {
+ System.out.println("\n--- starting example: update group data --------------");
+ editGridOptions( );
+ }
+ catch ( Exception e )
+ {
+ e.printStackTrace();
+ }
+ }
+
+ /** This method demonstrates resetting data to its default state
+ */
+ protected void resetGroupExample ()
+ {
+ try
+ {
+ System.out.println("\n--- starting example: reset group data -----------------------------");
+ Object aOldData = readGridConfiguration( );
+ resetGridConfiguration( );
+ Object aNewData = readGridConfiguration( );
+ System.out.println("Before reset: user grid options: " + aOldData);
+ System.out.println("After reset: default grid options: " + aNewData);
+ }
+ catch ( Exception e )
+ {
+ e.printStackTrace();
+ }
+ }
+
+ /** This method demonstrates update access to set data
+ */
+ protected void updateSetExample ()
+ {
+ try
+ {
+ System.out.println("\n--- starting example: update set data ---------------");
+ storeSampleDataSource( );
+ }
+ catch ( Exception e )
+ {
+ e.printStackTrace();
+ }
+ }
+
+// READ example
+ /// class to hold information about grid settings
+ private static class GridOptions
+ {
+ private boolean visible;
+ private int resolution_x;
+ private int resolution_y;
+ private int subdivision_x;
+ private int subdivision_y;
+
+ @Override
+ public String toString() {
+ StringBuffer aBuffer = new StringBuffer();
+ aBuffer.append("[ Grid is "); aBuffer.append(visible ? "VISIBLE" : "HIDDEN");
+ aBuffer.append("; resolution = (" + resolution_x + "," + resolution_y + ")");
+ aBuffer.append("; subdivision = (" + subdivision_x + "," + subdivision_y + ")");
+ aBuffer.append(" ]");
+ return aBuffer.toString();
+ }
+ }
+
+ /// This method reads information about grid settings
+ protected GridOptions readGridConfiguration()
+ throws com.sun.star.uno.Exception
+ {
+ // The path to the root element
+ final String cGridOptionsPath = "/org.openoffice.Office.Calc/Grid";
+
+ // create the view
+ Object xViewRoot = createConfigurationView(cGridOptionsPath);
+
+ // the result structure
+ GridOptions options = new GridOptions();
+
+ // accessing a single nested value
+ XHierarchicalPropertySet xProperties =
+ UnoRuntime.queryInterface(XHierarchicalPropertySet.class, xViewRoot);
+
+ Object aVisible = xProperties.getHierarchicalPropertyValue("Option/VisibleGrid");
+ options.visible = ((Boolean) aVisible).booleanValue();
+
+ // accessing a nested object and its subproperties
+ Object xSubdivision = xProperties.getHierarchicalPropertyValue("Subdivision");
+
+ XMultiPropertySet xSubdivProperties =
+ UnoRuntime.queryInterface(XMultiPropertySet.class, xSubdivision);
+
+ // variables for multi-element access
+ String[] aElementNames = new String[] { "XAxis", "YAxis" };
+
+ Object[] aElementValues = xSubdivProperties.getPropertyValues(aElementNames);
+
+ options.subdivision_x = ((Integer) aElementValues[0]).intValue();
+ options.subdivision_y = ((Integer) aElementValues[1]).intValue();
+
+ // accessing deeply nested subproperties
+ Object xResolution = xProperties.getHierarchicalPropertyValue("Resolution");
+
+ XMultiHierarchicalPropertySet xResolutionProperties =
+ UnoRuntime.queryInterface(XMultiHierarchicalPropertySet.class, xResolution);
+
+ aElementNames[0] = "XAxis/Metric";
+ aElementNames[1] = "YAxis/Metric";
+
+ aElementValues = xResolutionProperties.getHierarchicalPropertyValues(aElementNames);
+
+ options.resolution_x = ((Integer) aElementValues[0]).intValue();
+ options.resolution_y = ((Integer) aElementValues[1]).intValue();
+
+ // all options have been retrieved - clean up and return
+ // we are done with the view - dispose it
+
+ UnoRuntime.queryInterface(XComponent.class, xViewRoot).dispose();
+
+ return options;
+ }
+
+// BROWSE example
+ /// Interface to process information when browsing the configuration tree
+ public interface IConfigurationProcessor
+ {
+ /// process a value item
+ void processValueElement( String sPath_, Object aValue_ );
+ /// process a structural item
+ void processStructuralElement( String sPath_, XInterface xElement_);
+ }
+
+ /// Internal method to recursively browse a structural element in preorder
+ public void browseElementRecursively( XInterface xElement, IConfigurationProcessor aProcessor )
+ throws com.sun.star.uno.Exception
+ {
+ // First process this as an element (preorder traversal)
+ XHierarchicalName xElementPath =
+ UnoRuntime.queryInterface(XHierarchicalName.class, xElement);
+
+ String sPath = xElementPath.getHierarchicalName();
+
+ aProcessor.processStructuralElement( sPath, xElement);
+
+ // now process this as a container
+ XNameAccess xChildAccess =
+ UnoRuntime.queryInterface(XNameAccess.class, xElement);
+
+ // get a list of child elements
+ String[] aElementNames = xChildAccess.getElementNames();
+
+ // and process them one by one
+ for(int i=0; i< aElementNames.length; ++i)
+ {
+ Object aChild = xChildAccess.getByName( aElementNames[i] );
+ // is it a structural element (object) ...
+ if ( AnyConverter.isObject(aChild) && !AnyConverter.isArray(aChild) )
+ {
+ // then get an interface
+ XInterface xChildElement = UnoRuntime.queryInterface(XInterface.class, aChild);
+
+ // and continue processing child elements recursively
+ browseElementRecursively( xChildElement, aProcessor );
+ }
+ // ... or is it a simple value
+ else
+ {
+ // Build the path to it from the path of
+ // the element and the name of the child
+ String sChildPath;
+ sChildPath =
+ xElementPath.composeHierarchicalName(aElementNames[i]);
+
+ // and process the value
+ aProcessor.processValueElement( sChildPath, aChild );
+ }
+ }
+ }
+
+ /** Method to browse the part rooted at sRootPath
+ of the configuration that the Provider provides.
+
+ All nodes will be processed by the IConfigurationProcessor passed.
+ */
+ public void browseConfiguration( String sRootPath, IConfigurationProcessor aProcessor )
+ throws com.sun.star.uno.Exception
+ {
+ // create the root element
+ XInterface xViewRoot = (XInterface)createConfigurationView( sRootPath );
+
+ // now do the processing
+ browseElementRecursively( xViewRoot, aProcessor );
+
+ // we are done with the view - dispose it
+ // This assumes that the processor
+ // does not keep a reference to the elements in processStructuralElement
+
+ UnoRuntime.queryInterface(XComponent.class,xViewRoot).dispose();
+ xViewRoot = null;
+ }
+
+ /** Method to browse the filter configuration.
+
+ Information about installed filters will be printed.
+ */
+ public void printRegisteredFilters()
+ throws com.sun.star.uno.Exception
+ {
+ final String sFilterKey = "/org.openoffice.TypeDetection.Filter/Filters";
+
+ // browse the configuration, dumping filter information
+ browseConfiguration( sFilterKey,
+ new IConfigurationProcessor () {
+ /// prints Path and Value of properties
+ public void processValueElement( String sPath_, Object aValue_ ) {
+ if (AnyConverter.isArray(aValue_))
+ {
+ final Object [] aArray = (Object [])aValue_;
+
+ System.out.print("\tValue: " + sPath_ + " = { ");
+ for (int i=0; i<aArray.length; ++i)
+ {
+ if (i != 0) System.out.print(", ");
+ System.out.print(aArray[i]);
+ }
+ System.out.println(" }");
+ }
+ else
+ System.out.println("\tValue: " + sPath_ + " = " + aValue_);
+ }
+
+ /// prints the Filter entries
+ public void processStructuralElement( String sPath_, XInterface xElement_) {
+ // get template information, to detect instances of the 'Filter' template
+ XTemplateInstance xInstance =
+ UnoRuntime.queryInterface( XTemplateInstance .class,xElement_);
+
+ // only select the Filter entries
+ if (xInstance != null && xInstance.getTemplateName().endsWith("Filter")) {
+ XNamed xNamed = UnoRuntime.queryInterface(XNamed.class,xElement_);
+ System.out.println("Filter " + xNamed.getName() + " (" + sPath_ + ")");
+ }
+ }
+ } );
+ }
+
+// GROUP UPDATE example
+
+ /** This method simulates editing configuration data using a GridEditor dialog class
+ */
+ public void editGridOptions( )
+ throws com.sun.star.uno.Exception
+ {
+ // The path to the root element
+ final String cGridOptionsPath = "/org.openoffice.Office.Calc/Grid";
+
+ // create the view
+ Object xViewRoot = createUpdatableView( cGridOptionsPath );
+
+ // the 'editor'
+ GridOptionsEditor dialog = new GridOptionsEditor();
+
+ // set up the initial values and register listeners
+ // get a data access interface, to supply the view with a model
+ XMultiHierarchicalPropertySet xProperties =
+ UnoRuntime.queryInterface(XMultiHierarchicalPropertySet.class, xViewRoot);
+
+ dialog.setModel( xProperties );
+
+ // get a listener object (probably an adapter) that notifies
+ // the dialog of external changes to its model
+ XChangesListener xListener = dialog.createChangesListener( );
+
+ XChangesNotifier xNotifier =
+ UnoRuntime.queryInterface(XChangesNotifier.class, xViewRoot);
+
+ xNotifier.addChangesListener( xListener );
+
+ // trigger the listener
+ changeSomeData( cGridOptionsPath + "/Subdivision" );
+
+ if (dialog.execute() == GridOptionsEditor.SAVE_SETTINGS)
+ {
+ // changes have been applied to the view here
+ XChangesBatch xUpdateControl =
+ UnoRuntime.queryInterface(XChangesBatch.class,xViewRoot);
+
+ try
+ {
+ xUpdateControl.commitChanges();
+ }
+ catch (Exception e)
+ {
+ dialog.informUserOfError( e );
+ }
+ }
+
+ // all changes have been handled - clean up and return
+ // listener is done now
+ xNotifier.removeChangesListener( xListener );
+
+ // we are done with the view - dispose it
+ UnoRuntime.queryInterface(XComponent.class, xViewRoot).dispose();
+ }
+
+ /** A class that changes some grid options settings
+
+ The interface of this class is chose to resemble a possible UI dialog class
+ */
+ private class GridOptionsEditor {
+ /// the data this editor edits
+ XMultiHierarchicalPropertySet mxModel;
+
+ public static final int CANCELED = 0;
+ public static final int SAVE_SETTINGS = 1;
+
+ // sets a model and updates the display
+ public void setModel(XMultiHierarchicalPropertySet xModel) {
+ mxModel = xModel;
+ updateDisplay();
+ }
+
+ // this method 'runs' the 'dialog'
+ public int execute() {
+ try
+ {
+ System.out.println("-- GridEditor executing --");
+ // simulate a user action changing some data
+ toggleVisibility();
+ System.out.println("-- GridEditor done --");
+ return SAVE_SETTINGS;
+ }
+ catch (Exception e)
+ {
+ informUserOfError(e);
+ return CANCELED;
+ }
+ }
+
+ // this method is called to report an error during dialog execution to the user
+ public void informUserOfError(Exception e) {
+ System.err.println("ERROR in GridEditor:");
+ e.printStackTrace();
+ }
+
+ /// this method is called to allow the dialog to get feedback about changes occurring elsewhere
+ public XChangesListener createChangesListener() {
+ if (mxModel == null) return null;
+
+ return (new XChangesListener () {
+ public void changesOccurred( ChangesEvent event ) {
+ System.out.println("GridEditor - Listener received changes event containing " +
+ event.Changes.length + " change(s).");
+ updateDisplay();
+ }
+
+ public void disposing(EventObject event) {
+ System.out.println("GridEditor - Listener received disposed event: releasing model");
+ setModel(null);
+ }
+ });
+ }
+ /// this method is called when data has changed to display the updated data
+ private void updateDisplay() {
+ if (mxModel != null)
+ System.out.println("Grid options editor: data=" + readModel());
+ else
+ System.out.println("Grid options editor: no model set");
+ }
+
+ // this method is used to read all relevant data from the model
+ private GridOptions readModel()
+ {
+ try
+ {
+ String [] aOptionNames = new String [5];
+ aOptionNames[0] = "Option/VisibleGrid";
+ aOptionNames[1] = "Subdivision/XAxis";
+ aOptionNames[2] = "Subdivision/YAxis";
+ aOptionNames[3] = "Resolution/XAxis/Metric";
+ aOptionNames[4] = "Resolution/YAxis/Metric";
+
+ Object [] aValues = mxModel.getHierarchicalPropertyValues(aOptionNames);
+
+ GridOptions result = new GridOptions();
+ result.visible = ((Boolean)aValues[0]).booleanValue();
+ result.subdivision_x = ((Integer)aValues[1]).intValue();
+ result.subdivision_y = ((Integer)aValues[2]).intValue();
+ result.resolution_x = ((Integer)aValues[3]).intValue();
+ result.resolution_y = ((Integer)aValues[4]).intValue();
+
+ return result;
+ }
+ catch (Exception e)
+ {
+ informUserOfError(e);
+ return null;
+ }
+ }
+
+ // this method executes an edit
+ private void toggleVisibility()
+ {
+ try
+ {
+ XHierarchicalPropertySet xHPS =
+ UnoRuntime.queryInterface(XHierarchicalPropertySet.class, mxModel);
+
+ final String sSetting = "Option/VisibleGrid";
+
+ System.out.println("GridEditor: toggling Visibility");
+
+ Boolean bOldValue = (Boolean)xHPS.getHierarchicalPropertyValue(sSetting);
+
+ Boolean bNewValue = Boolean.valueOf( ! bOldValue.booleanValue() );
+
+ xHPS.setHierarchicalPropertyValue(sSetting,bNewValue);
+ }
+ catch (Exception e)
+ {
+ informUserOfError(e);
+ }
+ }
+ }
+
+ /** This method creates an extra updatable view to change some data
+ and trigger the listener of the GridEditor
+ */
+ void changeSomeData(String xKey)
+ {
+ try
+ {
+ Object xOtherViewRoot = createUpdatableView(xKey);
+
+ XNameReplace aReplace = UnoRuntime.queryInterface(XNameReplace.class, xOtherViewRoot);
+
+ String aItemNames [] = aReplace.getElementNames();
+ for (int i=0; i < aItemNames.length; ++i) {
+ Object aItem = aReplace.getByName( aItemNames [i] );
+ // replace integers by a 'complement' value
+ if ( AnyConverter.isInt(aItem) )
+ {
+ int nOld = AnyConverter.toInt(aItem);
+ int nNew = 9999 - nOld;
+
+ System.out.println("Replacing integer value: " + aItemNames [i]);
+ aReplace.replaceByName( aItemNames [i], Integer.valueOf( nNew ) );
+ }
+
+ // and booleans by their negated value
+ else if ( AnyConverter.isBoolean(aItem) )
+ {
+ boolean bOld = AnyConverter.toBoolean(aItem);
+ boolean bNew = ! bOld;
+
+ System.out.println("Replacing boolean value: " + aItemNames [i]);
+ aReplace.replaceByName( aItemNames [i], Boolean.valueOf( bNew ) );
+ }
+ }
+
+ // commit the changes
+ XChangesBatch xUpdateControl =
+ UnoRuntime.queryInterface(XChangesBatch.class,xOtherViewRoot);
+
+ xUpdateControl.commitChanges();
+
+ // we are done with the view - dispose it
+ UnoRuntime.queryInterface(XComponent.class, xOtherViewRoot).dispose();
+ }
+ catch (Exception e)
+ {
+ System.err.println("Could not change some data in a different view. An exception occurred:");
+ e.printStackTrace();
+ }
+ }
+
+// GROUP RESET EXAMPLE
+ /// This method resets the grid settings to their default values
+ protected void resetGridConfiguration()
+ throws com.sun.star.uno.Exception
+ {
+ // The path to the root element
+ final String cGridOptionsPath = "/org.openoffice.Office.Calc/Grid";
+
+ // create the view
+ Object xViewRoot = createUpdatableView(cGridOptionsPath);
+
+ // resetting a single nested value
+ XHierarchicalNameAccess xHierarchicalAccess =
+ UnoRuntime.queryInterface(XHierarchicalNameAccess.class, xViewRoot);
+
+ // get using absolute name
+ Object xOptions = xHierarchicalAccess.getByHierarchicalName(cGridOptionsPath + "/Option");
+
+ XPropertyState xOptionState =
+ UnoRuntime.queryInterface(XPropertyState.class, xOptions);
+
+ xOptionState.setPropertyToDefault("VisibleGrid");
+
+ // resetting more deeply nested values
+ Object xResolutionX = xHierarchicalAccess.getByHierarchicalName("Resolution/XAxis");
+ Object xResolutionY = xHierarchicalAccess.getByHierarchicalName("Resolution/YAxis");
+
+ XPropertyState xResolutionStateX =
+ UnoRuntime.queryInterface(XPropertyState.class, xResolutionX);
+ XPropertyState xResolutionStateY =
+ UnoRuntime.queryInterface(XPropertyState.class, xResolutionY);
+
+ xResolutionStateX.setPropertyToDefault("Metric");
+ xResolutionStateY.setPropertyToDefault("Metric");
+
+ // resetting multiple sibling values
+ Object xSubdivision = xHierarchicalAccess.getByHierarchicalName("Subdivision");
+
+ XMultiPropertyStates xSubdivisionStates =
+ UnoRuntime.queryInterface(XMultiPropertyStates.class, xSubdivision);
+
+ xSubdivisionStates.setAllPropertiesToDefault();
+
+ // commit the changes
+ XChangesBatch xUpdateControl =
+ UnoRuntime.queryInterface(XChangesBatch.class,xViewRoot);
+
+ xUpdateControl.commitChanges();
+
+ // we are done with the view - dispose it
+ UnoRuntime.queryInterface(XComponent.class, xViewRoot).dispose();
+ }
+
+
+// SET UPDATE EXAMPLE
+ private static boolean SET_EXAMPLE_BROKEN_IN_THIS_RELEASE = true;
+
+ /** This method stores a sample data source given some connection data.
+
+ ATTENTION: This example requires an older version of the
+ org.openoffice.Office.DataAccess schema.
+ It does not work with the current schema.
+ Because of this, the method currently does nothing.
+ You can still use the techniques shown in the example code.
+ */
+ void storeSampleDataSource()
+ throws com.sun.star.uno.Exception
+ {
+ if (SET_EXAMPLE_BROKEN_IN_THIS_RELEASE)
+ {
+ System.out.println("- DISABLED: (the existing example does not work with this version) -");
+ return; // this function does not work
+ }
+
+ String sSampleDataSourceName = "SampleTextDatabase";
+
+ String sSampleDataSourceURL = "sdbc:flat:$(userurl)/database/SampleTextDatabase";
+
+ com.sun.star.beans.NamedValue [] aSettings = new com.sun.star.beans.NamedValue [2];
+ aSettings[0] = new com.sun.star.beans.NamedValue("HeaderLine",Boolean.TRUE);
+ aSettings[1] = new com.sun.star.beans.NamedValue("FieldDelimiter",";");
+
+ String [] aTableFilter = new String[] { "table.txt", "othertable.txt" };
+
+ storeDataSource(sSampleDataSourceName,sSampleDataSourceURL,"",false,0,aSettings,aTableFilter);
+ }
+
+ /// This method stores a data source given some connection data
+ void storeDataSource(
+ String sDataSourceName,
+ String sDataSourceURL,
+ String sUser,
+ boolean bNeedsPassword,
+ int nTimeout,
+ com.sun.star.beans.NamedValue [] aDriverSettings,
+ String [] aTableFilter
+ )
+ throws com.sun.star.uno.Exception
+ {
+ // create the view and get the data source element
+ Object xDataSource = createDataSourceDescription(getProvider(),sDataSourceName);
+
+ // set the values
+ XPropertySet xDataSourceProperties =
+ UnoRuntime.queryInterface(XPropertySet.class, xDataSource);
+
+ xDataSourceProperties.setPropertyValue("URL", sDataSourceURL );
+ xDataSourceProperties.setPropertyValue("User", sUser );
+ xDataSourceProperties.setPropertyValue("IsPasswordRequired", Boolean.valueOf( bNeedsPassword ) );
+ xDataSourceProperties.setPropertyValue("LoginTimeout", Integer.valueOf( nTimeout ) );
+
+ if ( aTableFilter != null )
+ xDataSourceProperties.setPropertyValue("TableFilter", aTableFilter );
+
+ // store the driver-specific settings
+ if (aDriverSettings != null)
+ {
+ Object xSettingsSet = xDataSourceProperties.getPropertyValue("DataSourceSettings");
+ storeSettings( xSettingsSet, aDriverSettings);
+ }
+
+ // save the data and dispose the view
+ // recover the view root
+ Object xViewRoot = getViewRoot(xDataSource);
+
+ // commit the changes
+ XChangesBatch xUpdateControl =
+ UnoRuntime.queryInterface(XChangesBatch.class,xViewRoot);
+
+ xUpdateControl.commitChanges();
+
+ // now clean up
+ UnoRuntime.queryInterface(XComponent.class, xViewRoot).dispose();
+ }
+
+ /** This method gets the DataSourceDescription for a data source.
+ It either gets the existing entry or creates a new instance.
+ */
+ Object createDataSourceDescription(XMultiServiceFactory xProvider, String sDataSourceName )
+ throws com.sun.star.uno.Exception
+ {
+ // The service name: Need an update access:
+ final String cUpdatableView = "com.sun.star.configuration.ConfigurationUpdateAccess";
+
+ // The path to the DataSources set node
+ final String cDataSourcesPath = "/org.openoffice.Office.DataAccess/DataSources";
+
+ // creation arguments: nodepath
+ com.sun.star.beans.PropertyValue aPathArgument = new com.sun.star.beans.PropertyValue();
+ aPathArgument.Name = "nodepath";
+ aPathArgument.Value = cDataSourcesPath ;
+
+ Object[] aArguments = new Object[1];
+ aArguments[0] = aPathArgument;
+
+ // create the view
+ Object xViewRoot =
+ xProvider.createInstanceWithArguments(cUpdatableView, aArguments);
+
+ XNameAccess xSetOfDataSources =
+ UnoRuntime.queryInterface(XNameAccess.class,xViewRoot);
+
+ Object xDataSourceDescriptor = null; // the result
+ if ( xSetOfDataSources .hasByName( sDataSourceName ))
+ {
+ // the element is there
+ try
+ {
+ // the view should point to the element directly, so we need to extend the path
+ XHierarchicalName xComposePath = UnoRuntime.queryInterface(XHierarchicalName.class, xSetOfDataSources );
+
+ String sElementPath = xComposePath.composeHierarchicalName( sDataSourceName );
+
+ // use the name of the element now
+ aPathArgument.Value = sElementPath;
+
+ // create another view now
+ Object[] aDeepArguments = new Object[1];
+ aDeepArguments[0] = aPathArgument;
+
+ // create the view
+ xDataSourceDescriptor =
+ xProvider.createInstanceWithArguments(cUpdatableView, aDeepArguments);
+
+ if ( xDataSourceDescriptor != null) // all went fine
+ {
+ // dispose the other view
+ UnoRuntime.queryInterface(XComponent.class, xViewRoot).dispose();
+ xViewRoot = null;
+ }
+ }
+ catch (Exception e)
+ {
+ // something went wrong, we retry with a new element
+ System.err.println("WARNING: An exception occurred while creating a view for an existing data source: " + e);
+ xDataSourceDescriptor = null;
+ }
+ }
+
+ // do we have a result element yet ?
+ if ( xDataSourceDescriptor == null)
+ {
+ // get the container
+ XNameContainer xSetUpdate =
+ UnoRuntime.queryInterface(XNameContainer.class, xViewRoot);
+
+ // create a new detached set element (instance of DataSourceDescription)
+ XSingleServiceFactory xElementFactory =
+ UnoRuntime.queryInterface(XSingleServiceFactory.class, xSetUpdate);
+
+ // the new element is the result !
+ xDataSourceDescriptor = xElementFactory.createInstance();
+
+ // insert it - this also names the element
+ xSetUpdate.insertByName( sDataSourceName , xDataSourceDescriptor );
+ }
+
+ return xDataSourceDescriptor ;
+ }
+
+ /// this method stores a number of settings in a set node containing DataSourceSetting objects
+ void storeSettings(Object xSettingsSet, com.sun.star.beans.NamedValue [] aSettings )
+ throws com.sun.star.uno.Exception
+ {
+ if (aSettings == null)
+ return;
+
+ // get the settings set as a container
+ XNameContainer xSettingsContainer =
+ UnoRuntime.queryInterface( XNameContainer.class, xSettingsSet);
+
+ // and get a factory interface for creating the entries
+ XSingleServiceFactory xSettingsFactory =
+ UnoRuntime.queryInterface(XSingleServiceFactory.class, xSettingsSet);
+
+ // now insert the individual settings
+ for (int i = 0; i < aSettings.length; ++i) {
+ // create a DataSourceSetting object
+ XPropertySet xSetting = UnoRuntime.queryInterface( XPropertySet.class, xSettingsFactory.createInstance() );
+
+ // can set the value before inserting
+ xSetting.setPropertyValue( "Value", aSettings[i].Value );
+
+ // and now insert or replace as appropriate
+ if (xSettingsContainer.hasByName( aSettings[i].Name ))
+ xSettingsContainer.replaceByName( aSettings[i].Name, xSetting );
+ else
+ xSettingsContainer.insertByName( aSettings[i].Name, xSetting );
+ }
+ }
+
+// HELPER FUNCTIONS
+
+ /// This method get the view root node given an interface to any node in the view
+ public static Object getViewRoot(Object xElement)
+ {
+ Object xResult = xElement;
+
+ // set the result to its parent until that would be null
+ Object xParent;
+ do
+ {
+ XChild xParentAccess =
+ UnoRuntime.queryInterface(XChild.class,xResult);
+
+ if (xParentAccess != null)
+ xParent = xParentAccess.getParent();
+ else
+ xParent = null;
+
+ if (xParent != null)
+ xResult = xParent;
+ }
+ while (xParent != null);
+
+ return xResult;
+ }
+
+// workaround methods for unimplemented functionality
+
+ /// WORKAROUND: does the same as xNamedItem.setName(sNewName) should do
+ void renameSetItem(XNamed xNamedItem, String sNewName)
+ throws com.sun.star.uno.Exception
+ {
+ XChild xChildItem = UnoRuntime.queryInterface(XChild.class, xNamedItem);
+
+ XNameContainer xParentSet = UnoRuntime.queryInterface( XNameContainer.class, xChildItem.getParent() );
+
+ String sOldName = xNamedItem.getName();
+
+ // now rename the item
+ xParentSet.removeByName(sOldName);
+ xParentSet.insertByName(sNewName,xNamedItem);
+ }
+
+ /// WORKAROUND: does the same as xChildItem.setParent( xNewParent ) should do
+ void moveSetItem(XChild xChildItem, XNameContainer xNewParent)
+ throws com.sun.star.uno.Exception
+ {
+ XNamed xNamedItem = UnoRuntime.queryInterface(XNamed.class, xChildItem);
+
+ XNameContainer xOldParent = UnoRuntime.queryInterface( XNameContainer.class, xChildItem.getParent() );
+
+ String sItemName = xNamedItem.getName();
+
+ // now rename the item
+ xOldParent.removeByName(sItemName);
+ xNewParent.insertByName(sItemName,xChildItem);
+ }
+
+
+// ------- the end -----------
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/Config/Makefile b/odk/examples/DevelopersGuide/Config/Makefile
new file mode 100644
index 000000000..b334e8cfb
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Config/Makefile
@@ -0,0 +1,98 @@
+#*************************************************************************
+#
+# The Contents of this file are made available subject to the terms of
+# the BSD license.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+# 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+# contributors may be used to endorse or promote products derived
+# from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+# TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+# USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+#**************************************************************************
+
+# Builds the Configuration example of the Developers Guide.
+
+PRJ=../../..
+SETTINGS=$(PRJ)/settings
+
+include $(SETTINGS)/settings.mk
+include $(SETTINGS)/std.mk
+
+# Define non-platform/compiler specific settings
+SAMPLE_NAME=DevGuideConfigExamples
+SAMPLE_CLASS_OUT = $(OUT_CLASS)/$(SAMPLE_NAME)
+SAMPLE_GEN_OUT = $(OUT_MISC)/$(SAMPLE_NAME)
+
+# some special macro names for separating the example jar stuff
+APP1_NAME=ConfigExamples
+APP1_CLASS_OUT=$(SAMPLE_CLASS_OUT)/$(APP1_NAME)
+APP1_GEN_OUT=$(SAMPLE_GEN_OUT)/$(APP1_NAME)
+APP1_JAR=$(SAMPLE_CLASS_OUT)/$(APP1_NAME).jar
+APP1_JAR_MANIFEST=$(APP1_GEN_OUT)/$(APP1_NAME).mf
+
+SDK_CLASSPATH = $(subst $(EMPTYSTRING) $(PATH_SEPARATOR),$(PATH_SEPARATOR),$(CLASSPATH)\
+ $(PATH_SEPARATOR)$(SAMPLE_CLASS_OUT)\
+ $(PATH_SEPARATOR)$(APP1_CLASS_OUT))
+
+# Targets
+.PHONY: ALL
+ALL : $(SAMPLE_NAME)
+
+include $(SETTINGS)/stdtarget.mk
+
+# rule for example application class files
+$(APP1_CLASS_OUT)/%.class : %.java
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ $(SDK_JAVAC) $(JAVAC_FLAGS) -classpath "$(SDK_CLASSPATH)" -d $(APP1_CLASS_OUT) $<
+
+# rule for client/example application manifest file
+$(APP1_GEN_OUT)/%.mf :
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ @echo Main-Class: com.sun.star.lib.loader.Loader> $@
+ $(ECHOLINE)>> $@
+ @echo Name: com/sun/star/lib/loader/Loader.class>> $@
+ @echo Application-Class: $*>> $@
+
+# rule for client/example application jar file
+$(APP1_JAR) : $(APP1_JAR_MANIFEST) $(APP1_CLASS_OUT)/$(APP1_NAME).class
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ $(SDK_JAR) cvfm $@ $< -C $(APP1_CLASS_OUT) .
+ +$(SDK_JAR) uvf $@ $(SDK_JAVA_UNO_BOOTSTRAP_FILES)
+
+$(SAMPLE_NAME) : $(APP1_JAR)
+ @echo --------------------------------------------------------------------------------
+ @echo Please use the following command to execute the example!
+ @echo -
+ @echo $(MAKE) $(APP1_NAME).run
+ @echo --------------------------------------------------------------------------------
+
+%.run: $(SAMPLE_CLASS_OUT)/%.jar
+ $(SDK_JAVA) -Dcom.sun.star.lib.loader.unopath="$(OFFICE_PROGRAM_PATH)" -jar $<
+
+.PHONY: clean
+clean :
+ -$(DELRECURSIVE) $(subst /,$(PS),$(SAMPLE_CLASS_OUT))
+ -$(DELRECURSIVE) $(subst /,$(PS),$(SAMPLE_GEN_OUT))
diff --git a/odk/examples/DevelopersGuide/Database/CodeSamples.java b/odk/examples/DevelopersGuide/Database/CodeSamples.java
new file mode 100644
index 000000000..094901feb
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Database/CodeSamples.java
@@ -0,0 +1,322 @@
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+import com.sun.star.lang.XMultiComponentFactory;
+import com.sun.star.lang.XSingleServiceFactory;
+import com.sun.star.lang.XComponent;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.XComponentContext;
+import com.sun.star.beans.XPropertySet;
+import com.sun.star.container.XNameAccess;
+import com.sun.star.container.XNameContainer;
+import com.sun.star.sdbc.*;
+import com.sun.star.sdb.*;
+import com.sun.star.sdbcx.*;
+import com.sun.star.frame.*;
+
+public class CodeSamples
+{
+ public static XComponentContext xContext;
+ public static XMultiComponentFactory xMCF;
+
+ public static void main(String argv[]) throws java.lang.Exception
+ {
+ try {
+ // get the remote office component context
+ xContext = com.sun.star.comp.helper.Bootstrap.bootstrap();
+ System.out.println("Connected to a running office ...");
+ xMCF = xContext.getServiceManager();
+ }
+ catch(Exception e) {
+ System.err.println("ERROR: can't get a component context from a running office ...");
+ e.printStackTrace();
+ System.exit(1);
+ }
+
+ try{
+ createQuerydefinition( );
+ printQueryColumnNames( );
+
+ XConnection con = openConnectionWithDriverManager();
+ if ( con != null ) {
+ {
+ SalesMan sm = new SalesMan( con );
+
+ try {
+ sm.dropSalesManTable( ); // doesn't matter here
+ }
+ catch(com.sun.star.uno.Exception e)
+ {
+ }
+ sm.createSalesManTable( );
+ sm.insertDataIntoSalesMan( );
+ sm.updateSalesMan( );
+ sm.retrieveSalesManData( );
+ }
+
+ {
+ Sales sm = new Sales( con );
+
+ try {
+ sm.dropSalesTable( ); // doesn't matter here
+ }
+ catch(com.sun.star.uno.Exception e)
+ {
+ }
+ sm.createSalesTable( );
+ sm.insertDataIntoSales( );
+ sm.updateSales( );
+ sm.retrieveSalesData( );
+ sm.displayColumnNames( );
+ }
+ displayTableStructure( con );
+ }
+ }
+ catch(Exception e)
+ {
+ System.err.println(e);
+ e.printStackTrace();
+ }
+ System.exit(0);
+ }
+
+ // check if the connection is not null and dispose it later on.
+ public static void checkConnection(XConnection con)
+ {
+ if(con != null)
+ {
+ System.out.println("Connection was created!");
+ // now we dispose the connection to close it
+ XComponent xComponent = UnoRuntime.queryInterface(XComponent.class,con);
+ if(xComponent != null)
+ {
+ // connections must be disposed
+ xComponent.dispose();
+ System.out.println("Connection disposed!");
+ }
+ }
+ else
+ System.out.println("Connection could not be created!");
+ }
+
+ // uses the driver manager to create a new connection and dispose it.
+ public static XConnection openConnectionWithDriverManager() throws com.sun.star.uno.Exception
+ {
+ XConnection con = null;
+ // create the DriverManager
+ Object driverManager =
+ xMCF.createInstanceWithContext("com.sun.star.sdbc.DriverManager",
+ xContext);
+ // query for the interface
+ com.sun.star.sdbc.XDriverManager xDriverManager;
+ xDriverManager = UnoRuntime.queryInterface(XDriverManager.class,driverManager);
+ if(xDriverManager != null)
+ {
+ // first create the needed url
+ String url = "jdbc:mysql://localhost:3306/TestTables";
+ // second create the necessary properties
+ com.sun.star.beans.PropertyValue [] props = new com.sun.star.beans.PropertyValue[]
+ {
+ new com.sun.star.beans.PropertyValue("user",0,"test1",com.sun.star.beans.PropertyState.DIRECT_VALUE),
+ new com.sun.star.beans.PropertyValue("password",0,"test1",com.sun.star.beans.PropertyState.DIRECT_VALUE),
+ new com.sun.star.beans.PropertyValue("JavaDriverClass",0,"org.gjt.mm.mysql.Driver",com.sun.star.beans.PropertyState.DIRECT_VALUE)
+ };
+ // now create a connection to mysql
+ con = xDriverManager.getConnectionWithInfo(url,props);
+ }
+ return con;
+ }
+
+ // uses the driver directly to create a new connection and dispose it.
+ public static XConnection openConnectionWithDriver() throws com.sun.star.uno.Exception
+ {
+ XConnection con = null;
+ // create the Driver with the implementation name
+ Object aDriver =
+ xMCF.createInstanceWithContext("org.openoffice.comp.drivers.MySQL.Driver",
+ xContext);
+ // query for the interface
+ com.sun.star.sdbc.XDriver xDriver;
+ xDriver = UnoRuntime.queryInterface(XDriver.class,aDriver);
+ if(xDriver != null)
+ {
+ // first create the needed url
+ String url = "jdbc:mysql://localhost:3306/TestTables";
+ // second create the necessary properties
+ com.sun.star.beans.PropertyValue [] props = new com.sun.star.beans.PropertyValue[]
+ {
+ new com.sun.star.beans.PropertyValue("user",0,"test1",com.sun.star.beans.PropertyState.DIRECT_VALUE),
+ new com.sun.star.beans.PropertyValue("password",0,"test1",com.sun.star.beans.PropertyState.DIRECT_VALUE),
+ new com.sun.star.beans.PropertyValue("JavaDriverClass",0,"org.gjt.mm.mysql.Driver",com.sun.star.beans.PropertyState.DIRECT_VALUE)
+ };
+ // now create a connection to mysql
+ con = xDriver.connect(url,props);
+ }
+ return con;
+ }
+
+ // print all available datasources
+ public static void printDataSources() throws com.sun.star.uno.Exception
+ {
+ // create a DatabaseContext and print all DataSource names
+ XNameAccess xNameAccess = UnoRuntime.queryInterface(
+ XNameAccess.class,
+ xMCF.createInstanceWithContext("com.sun.star.sdb.DatabaseContext",
+ xContext));
+ String aNames [] = xNameAccess.getElementNames();
+ for(int i=0;i<aNames.length;++i)
+ System.out.println(aNames[i]);
+ }
+
+ // displays the structure of the first table
+ public static void displayTableStructure(XConnection con) throws com.sun.star.uno.Exception
+ {
+ XDatabaseMetaData dm = con.getMetaData();
+ XResultSet rsTables = dm.getTables(null,"%","SALES",null);
+ XRow rowTB = UnoRuntime.queryInterface(XRow.class, rsTables);
+ while ( rsTables.next() )
+ {
+ String catalog = rowTB.getString( 1 );
+ if ( rowTB.wasNull() )
+ catalog = null;
+
+ String schema = rowTB.getString( 2 );
+ if ( rowTB.wasNull() )
+ schema = null;
+
+ String table = rowTB.getString( 3 );
+ String type = rowTB.getString( 4 );
+ System.out.println("Catalog: " + catalog + " Schema: " + schema + " Table: " + table + " Type: " + type);
+ System.out.println("------------------ Columns ------------------");
+ XResultSet rsColumns = dm.getColumns(catalog,schema,table,"%");
+ XRow rowCL = UnoRuntime.queryInterface(XRow.class, rsColumns);
+ while ( rsColumns.next() )
+ {
+ System.out.println("Column: " + rowCL.getString( 4 ) + " Type: " + rowCL.getInt( 5 ) + " TypeName: " + rowCL.getString( 6 ) );
+ }
+
+ }
+ }
+
+ // quote the given name
+ public static String quoteTableName(XConnection con, String sCatalog, String sSchema, String sTable) throws com.sun.star.uno.Exception
+ {
+ XDatabaseMetaData dbmd = con.getMetaData();
+ String sQuoteString = dbmd.getIdentifierQuoteString();
+ String sSeparator = ".";
+ String sComposedName = "";
+ String sCatalogSep = dbmd.getCatalogSeparator();
+ if (0 != sCatalog.length() && dbmd.isCatalogAtStart() && 0 != sCatalogSep.length())
+ {
+ sComposedName += sCatalog;
+ sComposedName += dbmd.getCatalogSeparator();
+ }
+ if (0 != sSchema.length())
+ {
+ sComposedName += sSchema;
+ sComposedName += sSeparator;
+ sComposedName += sTable;
+ }
+ else
+ {
+ sComposedName += sTable;
+ }
+ if (0 != sCatalog.length() && !dbmd.isCatalogAtStart() && 0 != sCatalogSep.length())
+ {
+ sComposedName += dbmd.getCatalogSeparator();
+ sComposedName += sCatalog;
+ }
+ return sComposedName;
+ }
+
+ // creates a new query definition
+ public static void createQuerydefinition() throws com.sun.star.uno.Exception
+ {
+ XNameAccess xNameAccess = UnoRuntime.queryInterface(
+ XNameAccess.class,
+ xMCF.createInstanceWithContext("com.sun.star.sdb.DatabaseContext",
+ xContext));
+ // we use the first datasource
+ XQueryDefinitionsSupplier xQuerySup = UnoRuntime.queryInterface(XQueryDefinitionsSupplier.class,
+ xNameAccess.getByName( "Bibliography" ));
+ XNameAccess xQDefs = xQuerySup.getQueryDefinitions();
+ // create new query definition
+ XSingleServiceFactory xSingleFac = UnoRuntime.queryInterface(XSingleServiceFactory.class, xQDefs);
+
+ XPropertySet xProp = UnoRuntime.queryInterface(
+ XPropertySet.class,xSingleFac.createInstance());
+ xProp.setPropertyValue("Command","SELECT * FROM biblio");
+ xProp.setPropertyValue("EscapeProcessing",Boolean.TRUE);
+
+ XNameContainer xCont = UnoRuntime.queryInterface(XNameContainer.class, xQDefs);
+ try
+ {
+ if ( xCont.hasByName("Query1") )
+ xCont.removeByName("Query1");
+ }
+ catch(com.sun.star.uno.Exception e)
+ {}
+ xCont.insertByName("Query1",xProp);
+ XDocumentDataSource xDs = UnoRuntime.queryInterface(XDocumentDataSource.class, xQuerySup);
+
+ XStorable xStore = UnoRuntime.queryInterface(XStorable.class,xDs.getDatabaseDocument());
+ xStore.store();
+ }
+
+ // prints all column names from Query1
+ public static void printQueryColumnNames() throws com.sun.star.uno.Exception
+ {
+ XNameAccess xNameAccess = UnoRuntime.queryInterface(
+ XNameAccess.class,
+ xMCF.createInstanceWithContext("com.sun.star.sdb.DatabaseContext",
+ xContext));
+ // we use the first datasource
+ XDataSource xDS = UnoRuntime.queryInterface(
+ XDataSource.class, xNameAccess.getByName( "Bibliography" ));
+ XConnection con = xDS.getConnection("","");
+ XQueriesSupplier xQuerySup = UnoRuntime.queryInterface(XQueriesSupplier.class, con);
+
+ XNameAccess xQDefs = xQuerySup.getQueries();
+
+ XColumnsSupplier xColsSup = UnoRuntime.queryInterface(
+ XColumnsSupplier.class,xQDefs.getByName("Query1"));
+ XNameAccess xCols = xColsSup.getColumns();
+ String aNames [] = xCols.getElementNames();
+ for(int i=0;i<aNames.length;++i)
+ System.out.println(aNames[i]);
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/Database/DriverSkeleton/How_to_write_my_own_driver.txt b/odk/examples/DevelopersGuide/Database/DriverSkeleton/How_to_write_my_own_driver.txt
new file mode 100644
index 000000000..99507d202
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Database/DriverSkeleton/How_to_write_my_own_driver.txt
@@ -0,0 +1,43 @@
+#
+# This file is part of the LibreOffice project.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+# This file incorporates work covered by the following license notice:
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed
+# with this work for additional information regarding copyright
+# ownership. The ASF licenses this file to you under the Apache
+# License, Version 2.0 (the "License"); you may not use this file
+# except in compliance with the License. You may obtain a copy of
+# the License at http://www.apache.org/licenses/LICENSE-2.0 .
+#
+
+How to write my own sdbc driver
+
+Pre implementation steps
+- search all occurrences of skeleton and replace them to a name which you prefer
+
+1. Implement a class called driver or modify the existing skeleton -> have a look at SDriver.?xx
+2. Implement a class called connection -> have a look at SConnection.?xx
+3. Have a look at the DatabaseMetaData -> see SDatabaseMetaData.cxx
+ The methods which should be implemented at least are
+ - getTableTypes
+ - getTables
+ - getTypeInfo
+ - getColumns
+
+4. You need a statement to show/access some data -> have a look at SStatement.cxx
+ -> especially executeQuery()
+
+5. The ResultSet: without you see nothing -> look at SResultSet.cxx
+6. The ResultSetMetaData needed to get some information about what are waiting for us
+ -> look at SResultSetMetaData.cxx
+
+7. The prepared statement is the last class we have to implement now
+ -> you have to allow statements like "SELECT * FROM table WHERE id = ?"
+
+8. congratulations you have now implement your own driver :-)
diff --git a/odk/examples/DevelopersGuide/Database/DriverSkeleton/Makefile b/odk/examples/DevelopersGuide/Database/DriverSkeleton/Makefile
new file mode 100644
index 000000000..567ba1149
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Database/DriverSkeleton/Makefile
@@ -0,0 +1,156 @@
+#*************************************************************************
+#
+# The Contents of this file are made available subject to the terms of
+# the BSD license.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+# 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+# contributors may be used to endorse or promote products derived
+# from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+# TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+# USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+#**************************************************************************
+
+# Builds the Database SDBC driver skeleton example of the Developers Guide.
+
+PRJ=../../../..
+SETTINGS=$(PRJ)/settings
+
+include $(SETTINGS)/settings.mk
+include $(SETTINGS)/std.mk
+
+# Define non-platform/compiler specific settings
+COMP_NAME=DatabaseSDBCDriverSkeleton
+COMP_IMPL_NAME=$(COMP_NAME).uno.$(SHAREDLIB_EXT)
+COMP_LIBRARY=$(SHAREDLIB_OUT)/$(COMP_IMPL_NAME)
+OUT_COMP_INC=$(OUT_INC)/$(COMP_NAME)
+OUT_COMP_MISC=$(OUT_MISC)/$(COMP_NAME)
+OUT_COMP_SLO=$(OUT_SLO)/$(COMP_NAME)
+COMP_PACKAGE = $(OUT_BIN)/$(COMP_NAME).$(UNOOXT_EXT)
+COMP_PACKAGE_URL = $(subst \\,\,"$(COMP_PACKAGE_DIR)$(PS)$(COMP_NAME).$(UNOOXT_EXT)")
+COMP_UNOPKG_MANIFEST = $(OUT_COMP_MISC)/$(COMP_NAME)/META-INF/manifest.xml
+COMP_COMPONENTS = $(OUT_COMP_MISC)/$(COMP_NAME).components
+
+COMP_REGISTERFLAG = $(OUT_COMP_MISC)/devguide_$(COMP_NAME)_register_component.flag
+
+CXXFILES = SConnection.cxx \
+ SDatabaseMetaData.cxx \
+ propertyids.cxx \
+ SDriver.cxx \
+ SPreparedStatement.cxx \
+ SResultSet.cxx \
+ SResultSetMetaData.cxx \
+ SServices.cxx \
+ SStatement.cxx
+
+SLOFILES = $(patsubst %.cxx,$(OUT_COMP_SLO)/%.$(OBJ_EXT),$(CXXFILES))
+
+# Targets
+.PHONY: ALL
+ALL : \
+ DatabaseSDBCDriverSkeletonExample
+
+include $(SETTINGS)/stdtarget.mk
+
+$(OUT_COMP_SLO)/%.$(OBJ_EXT) : %.cxx $(SDKTYPEFLAG)
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ $(CC) $(CC_FLAGS) $(CC_INCLUDES) $(STL_INCLUDES) -I$(OUT_COMP_INC) $(CC_DEFINES) $(CC_OUTPUT_SWITCH)$(subst /,$(PS),$@) $<
+
+ifeq "$(OS)" "WIN"
+$(SHAREDLIB_OUT)/%.$(SHAREDLIB_EXT) : $(SLOFILES)
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ -$(MKDIR) $(subst /,$(PS),$(OUT_COMP_MISC))
+ $(LINK) $(COMP_LINK_FLAGS) /OUT:$@ \
+ /MAP:$(OUT_COMP_MISC)/$(COMP_NAME).map $(SLOFILES) \
+ $(CPPUHELPERLIB) $(CPPULIB) $(SALLIB) msvcprt.lib $(LIBO_SDK_LDFLAGS_STDLIBS)
+ $(LINK_MANIFEST)
+else
+$(SHAREDLIB_OUT)/%.$(SHAREDLIB_EXT) : $(SLOFILES)
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ $(LINK) $(COMP_LINK_FLAGS) $(LINK_LIBS) -o $@ $(SLOFILES) \
+ $(CPPUHELPERLIB) $(CPPULIB) $(SALLIB) $(STC++LIB)
+ifeq "$(OS)" "MACOSX"
+ $(INSTALL_NAME_URELIBS) $@
+endif
+endif
+
+# rule for component package manifest
+$(OUT_COMP_MISC)/%/manifest.xml :
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ @echo $(OSEP)?xml version="$(QM)1.0$(QM)" encoding="$(QM)UTF-8$(QM)"?$(CSEP) > $@
+ @echo $(OSEP)!DOCTYPE manifest:manifest PUBLIC "$(QM)-//OpenOffice.org//DTD Manifest 1.0//EN$(QM)" "$(QM)Manifest.dtd$(QM)"$(CSEP) >> $@
+ @echo $(OSEP)manifest:manifest xmlns:manifest="$(QM)http://openoffice.org/2001/manifest$(QM)"$(CSEP) >> $@
+ @echo $(SQM) $(SQM)$(OSEP)manifest:file-entry manifest:media-type="$(QM)application/vnd.sun.star.uno-components;platform=$(UNOPKG_PLATFORM)$(QM)">> $@
+ @echo $(SQM) $(SQM)manifest:full-path="$(QM)$(COMP_NAME).components$(QM)"/$(CSEP)>> $@
+ @echo $(OSEP)/manifest:manifest$(CSEP) >> $@
+
+$(COMP_COMPONENTS) :
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ @echo $(OSEP)?xml version="$(QM)1.0$(QM)" encoding="$(QM)UTF-8$(QM)"?$(CSEP) > $@
+ @echo $(OSEP)components xmlns="$(QM)http://openoffice.org/2010/uno-components$(QM)"$(CSEP) >> $@
+ @echo $(SQM) $(SQM)$(OSEP)component loader="$(QM)com.sun.star.loader.SharedLibrary$(QM)" uri="$(QM)$(UNOPKG_PLATFORM)/$(COMP_IMPL_NAME)$(QM)"$(CSEP) >> $@
+ @echo $(SQM) $(SQM)$(OSEP)implementation name="$(QM)com.sun.star.comp.sdbc.SkeletonDriver$(QM)"$(CSEP) >> $@
+ @echo $(SQM) $(SQM)$(OSEP)service name="$(QM)com.sun.star.sdbc.Driver$(QM)"/$(CSEP) >> $@
+ @echo $(SQM) $(SQM)$(OSEP)/implementation$(CSEP) >> $@
+ @echo $(SQM) $(SQM)$(OSEP)/component$(CSEP) >> $@
+ @echo $(OSEP)/components$(CSEP) >> $@
+
+$(COMP_PACKAGE) : $(COMP_LIBRARY) $(COMP_UNOPKG_MANIFEST) $(COMP_COMPONENTS)
+ -$(MKDIR) $(subst /,$(PS),$(@D)) && $(DEL) $(subst \\,\,$(subst /,$(PS),$@))
+ -$(MKDIR) $(subst /,$(PS),$(OUT_COMP_MISC)/$(UNOPKG_PLATFORM))
+ $(COPY) $(subst /,$(PS),$<) $(subst /,$(PS),$(OUT_COMP_MISC)/$(UNOPKG_PLATFORM))
+ cd $(subst /,$(PS),$(OUT_COMP_MISC)) && $(SDK_ZIP) ../../bin/$(@F) $(COMP_NAME).components
+ cd $(subst /,$(PS),$(OUT_COMP_MISC)) && $(SDK_ZIP) -u ../../bin/$(@F) $(UNOPKG_PLATFORM)/$(<F)
+ cd $(subst /,$(PS),$(OUT_COMP_MISC)/$(subst .$(UNOOXT_EXT),,$(@F))) && $(SDK_ZIP) -u ../../../bin/$(@F) META-INF/manifest.xml
+
+$(COMP_REGISTERFLAG) : $(COMP_PACKAGE)
+ifeq "$(SDK_AUTO_DEPLOYMENT)" "YES"
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
+ $(DEPLOYTOOL) $(COMP_PACKAGE_URL)
+ @echo flagged > $(subst /,$(PS),$@)
+else
+ @echo --------------------------------------------------------------------------------
+ @echo If you want to install your component automatically, please set the environment
+ @echo variable SDK_AUTO_DEPLOYMENT = YES. But note that auto deployment is only
+ @echo possible if no office instance is running.
+ @echo --------------------------------------------------------------------------------
+endif
+
+DatabaseSDBCDriverSkeletonExample : $(COMP_REGISTERFLAG)
+ @echo --------------------------------------------------------------------------------
+ @echo The Database SDBC skeleton driver component was installed if SDK_AUTO_DEPLOYMENT = YES.
+ @echo You can use this component inside your office installation, see the example
+ @echo description and the howto of implementing a sdbc driver.
+ @echo --------------------------------------------------------------------------------
+
+.PHONY: clean
+clean :
+ -$(DELRECURSIVE) $(subst /,$(PS),$(OUT_COMP_INC))
+ -$(DELRECURSIVE) $(subst /,$(PS),$(OUT_COMP_MISC))
+ -$(DELRECURSIVE) $(subst /,$(PS),$(OUT_COMP_SLO))
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$(COMP_LIBRARY)))
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$(COMP_COMPONENTS)))
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$(COMP_REGISTERFLAG)))
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$(COMP_PACKAGE_URL)))
diff --git a/odk/examples/DevelopersGuide/Database/DriverSkeleton/OSubComponent.hxx b/odk/examples/DevelopersGuide/Database/DriverSkeleton/OSubComponent.hxx
new file mode 100644
index 000000000..d1113ad8e
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Database/DriverSkeleton/OSubComponent.hxx
@@ -0,0 +1,242 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+#ifndef INCLUDED_EXAMPLES_DATABASE_DRIVERSKELETON_OSUBCOMPONENT_HXX
+#define INCLUDED_EXAMPLES_DATABASE_DRIVERSKELETON_OSUBCOMPONENT_HXX
+
+#include <com/sun/star/lang/DisposedException.hpp>
+#include <cppuhelper/interfacecontainer.h>
+#include <cppuhelper/propshlp.hxx>
+#include <cppuhelper/supportsservice.hxx>
+#include <cppuhelper/weak.hxx>
+#include <osl/mutex.hxx>
+#include <osl/diagnose.h>
+
+namespace cppu {
+ class IPropertyArrayHelper;
+}
+
+namespace com
+{
+ namespace sun
+ {
+ namespace star
+ {
+ namespace lang
+ {
+ class XComponent;
+ }
+ }
+ }
+}
+
+namespace connectivity
+{
+
+ namespace skeleton
+ {
+ void release(oslInterlockedCount& _refCount,
+ ::cppu::OBroadcastHelper& rBHelper,
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _xInterface,
+ ::com::sun::star::lang::XComponent* _pObject);
+
+ void checkDisposed(sal_Bool _bThrow);
+
+ template <class SELF, class WEAK> class OSubComponent
+ {
+ protected:
+ // the parent must support the tunnel implementation
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > m_xParent;
+ SELF* m_pDerivedImplementation;
+
+ public:
+ OSubComponent(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _xParent,
+ SELF* _pDerivedImplementation)
+ :m_xParent(_xParent)
+ ,m_pDerivedImplementation(_pDerivedImplementation)
+ {
+ }
+
+ protected:
+ void dispose_ChildImpl()
+ {
+ ::osl::MutexGuard aGuard( m_pDerivedImplementation->rBHelper.rMutex );
+ m_xParent = NULL;
+ }
+ void release_ChildImpl()
+ {
+ release(m_pDerivedImplementation->m_refCount,
+ m_pDerivedImplementation->rBHelper,
+ m_xParent,
+ m_pDerivedImplementation);
+
+ m_pDerivedImplementation->WEAK::release();
+ }
+ };
+
+ template <class TYPE>
+ class OPropertyArrayUsageHelper
+ {
+ protected:
+ static sal_Int32 s_nRefCount;
+ static ::cppu::IPropertyArrayHelper* s_pProps;
+ static ::osl::Mutex s_aMutex;
+
+ public:
+ OPropertyArrayUsageHelper();
+ virtual ~OPropertyArrayUsageHelper();
+
+ /** call this in the getInfoHelper method of your derived class. The method returns the array helper of the
+ class, which is created if necessary.
+ */
+ ::cppu::IPropertyArrayHelper* getArrayHelper();
+
+ protected:
+ /** used to implement the creation of the array helper which is shared amongst all instances of the class.
+ This method needs to be implemented in derived classes.
+ <BR>
+ The method gets called with s_aMutex acquired.
+ @return a pointer to the newly created array helper. Must not be NULL.
+ */
+ virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const = 0;
+ };
+
+ template<class TYPE>
+ sal_Int32 OPropertyArrayUsageHelper< TYPE >::s_nRefCount = 0;
+
+ template<class TYPE>
+ ::cppu::IPropertyArrayHelper* OPropertyArrayUsageHelper< TYPE >::s_pProps = NULL;
+
+ template<class TYPE>
+ ::osl::Mutex OPropertyArrayUsageHelper< TYPE >::s_aMutex;
+
+ template <class TYPE>
+ OPropertyArrayUsageHelper<TYPE>::OPropertyArrayUsageHelper()
+ {
+ ::osl::MutexGuard aGuard(s_aMutex);
+ ++s_nRefCount;
+ }
+
+ template <class TYPE>
+ OPropertyArrayUsageHelper<TYPE>::~OPropertyArrayUsageHelper()
+ {
+ ::osl::MutexGuard aGuard(s_aMutex);
+ OSL_ENSURE(s_nRefCount > 0, "OPropertyArrayUsageHelper::~OPropertyArrayUsageHelper : suspicious call : have a refcount of 0 !");
+ if (!--s_nRefCount)
+ {
+ delete s_pProps;
+ s_pProps = NULL;
+ }
+ }
+
+ template <class TYPE>
+ ::cppu::IPropertyArrayHelper* OPropertyArrayUsageHelper<TYPE>::getArrayHelper()
+ {
+ OSL_ENSURE(s_nRefCount, "OPropertyArrayUsageHelper::getArrayHelper : suspicious call : have a refcount of 0 !");
+ if (!s_pProps)
+ {
+ ::osl::MutexGuard aGuard(s_aMutex);
+ if (!s_pProps)
+ {
+ s_pProps = createArrayHelper();
+ OSL_ENSURE(s_pProps, "OPropertyArrayUsageHelper::getArrayHelper : createArrayHelper returned nonsense !");
+ }
+ }
+ return s_pProps;
+ }
+
+ class OBase_Mutex
+ {
+ public:
+ ::osl::Mutex m_aMutex;
+ };
+
+ namespace internal
+ {
+ template <class T>
+ void implCopySequence(const T* _pSource, T*& _pDest, sal_Int32 _nSourceLen)
+ {
+ for (sal_Int32 i=0; i<_nSourceLen; ++i, ++_pSource, ++_pDest)
+ *_pDest = *_pSource;
+ }
+ }
+
+ /// concat two sequences
+ template <class T>
+ ::com::sun::star::uno::Sequence<T> concatSequences(const ::com::sun::star::uno::Sequence<T>& _rLeft, const ::com::sun::star::uno::Sequence<T>& _rRight)
+ {
+ sal_Int32 nLeft(_rLeft.getLength()), nRight(_rRight.getLength());
+ const T* pLeft = _rLeft.getConstArray();
+ const T* pRight = _rRight.getConstArray();
+
+ sal_Int32 nReturnLen(nLeft + nRight);
+ ::com::sun::star::uno::Sequence<T> aReturn(nReturnLen);
+ T* pReturn = aReturn.getArray();
+
+ internal::implCopySequence(pLeft, pReturn, nLeft);
+ internal::implCopySequence(pRight, pReturn, nRight);
+
+ return aReturn;
+ }
+
+
+#define DECLARE_SERVICE_INFO() \
+ virtual ::rtl::OUString SAL_CALL getImplementationName( ); \
+ virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) ; \
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) \
+
+#define IMPLEMENT_SERVICE_INFO(classname, implasciiname, serviceasciiname) \
+ ::rtl::OUString SAL_CALL classname::getImplementationName( ) \
+ { \
+ return ::rtl::OUString::createFromAscii(implasciiname); \
+ } \
+ ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL classname::getSupportedServiceNames( ) \
+ { \
+ ::com::sun::star::uno::Sequence< ::rtl::OUString > aSupported(1); \
+ aSupported[0] = ::rtl::OUString::createFromAscii(serviceasciiname); \
+ return aSupported; \
+ } \
+ sal_Bool SAL_CALL classname::supportsService( const ::rtl::OUString& _rServiceName ) \
+ { \
+ return cppu::supportsService(this, _rServiceName); \
+ }
+
+ }
+}
+
+#endif // INCLUDED_EXAMPLES_DATABASE_DRIVERSKELETON_OSUBCOMPONENT_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/Database/DriverSkeleton/OTypeInfo.hxx b/odk/examples/DevelopersGuide/Database/DriverSkeleton/OTypeInfo.hxx
new file mode 100644
index 000000000..610bb4062
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Database/DriverSkeleton/OTypeInfo.hxx
@@ -0,0 +1,100 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+#ifndef INCLUDED_EXAMPLES_DATABASE_DRIVERSKELETON_OTYPEINFO_HXX
+#define INCLUDED_EXAMPLES_DATABASE_DRIVERSKELETON_OTYPEINFO_HXX
+
+#include <com/sun/star/sdbc/ColumnSearch.hpp>
+#include <com/sun/star/sdbc/DataType.hpp>
+
+namespace connectivity
+{
+ struct OTypeInfo
+ {
+ ::rtl::OUString aTypeName; // Name of the type in the database
+ ::rtl::OUString aLiteralPrefix; // Prefix for literals
+ ::rtl::OUString aLiteralSuffix; // Suffix for literals
+ ::rtl::OUString aCreateParams; // Parameters to create
+ ::rtl::OUString aLocalTypeName;
+
+ sal_Int32 nPrecision; // Length of the types
+
+ sal_Int16 nMaximumScale; // Decimal places (precision)
+ sal_Int16 nMinimumScale; // Min decimal places (precision)
+
+ sal_Int16 nType; // Database type
+ sal_Int16 nSearchType; // Can search for the type
+ sal_Int16 nNumPrecRadix; // indicating the radix, which is usually 2 or 10
+
+ sal_Bool bCurrency : 1, // Currency
+ bAutoIncrement : 1, // Is this field auto incrementing?
+ bNullable : 1, // Can this field assume a NULL value?
+ bCaseSensitive : 1, // Is this type case-sensitive?
+ bUnsigned : 1, // Is this type unsigned?
+ bEmpty_1 : 1, // for later use
+ bEmpty_2 : 1;
+
+ OTypeInfo()
+ :bCurrency(sal_False)
+ ,bAutoIncrement(sal_False)
+ ,bNullable(sal_True)
+ ,bCaseSensitive(sal_False)
+ ,bUnsigned(sal_False)
+ ,nMaximumScale(0)
+ ,nMinimumScale(0)
+ ,nType( ::com::sun::star::sdbc::DataType::OTHER)
+ ,nPrecision(0)
+ ,nSearchType( ::com::sun::star::sdbc::ColumnSearch::FULL)
+ {}
+
+ inline static void * SAL_CALL operator new( size_t nSize )
+ { return ::rtl_allocateMemory( nSize ); }
+ inline static void * SAL_CALL operator new( size_t nSize,void* _pHint )
+ { return _pHint; }
+ inline static void SAL_CALL operator delete( void * pMem )
+ { ::rtl_freeMemory( pMem ); }
+ inline static void SAL_CALL operator delete( void * pMem,void* _pHint )
+ { }
+
+ sal_Bool operator == (const OTypeInfo& lh) const { return lh.nType == nType; }
+ sal_Bool operator != (const OTypeInfo& lh) const { return lh.nType != nType; }
+
+ inline ::rtl::OUString getDBName() const { return aTypeName; }
+ };
+}
+
+#endif // INCLUDED_EXAMPLES_DATABASE_DRIVERSKELETON_OTYPEINFO_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/Database/DriverSkeleton/SConnection.cxx b/odk/examples/DevelopersGuide/Database/DriverSkeleton/SConnection.cxx
new file mode 100644
index 000000000..a52cb0c86
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Database/DriverSkeleton/SConnection.cxx
@@ -0,0 +1,401 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+#include "SConnection.hxx"
+
+#include "SDatabaseMetaData.hxx"
+#include "SDriver.hxx"
+#include "SStatement.hxx"
+#include "SPreparedStatement.hxx"
+#include <com/sun/star/sdbc/ColumnValue.hpp>
+#include <com/sun/star/sdbc/XRow.hpp>
+#include <com/sun/star/sdbc/TransactionIsolation.hpp>
+#include <com/sun/star/lang/DisposedException.hpp>
+
+using namespace connectivity::skeleton;
+
+
+using namespace com::sun::star::uno;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::beans;
+using namespace com::sun::star::sdbc;
+
+OConnection::OConnection(SkeletonDriver* _pDriver)
+ : OSubComponent<OConnection, OConnection_BASE>((::cppu::OWeakObject*)_pDriver, this),
+ OMetaConnection_BASE(m_aMutex),
+ m_pDriver(_pDriver),
+ m_bClosed(sal_False),
+ m_xMetaData(NULL),
+ m_bUseCatalog(sal_False),
+ m_bUseOldDateFormat(sal_False)
+{
+ m_pDriver->acquire();
+}
+
+OConnection::~OConnection()
+{
+ if(!isClosed())
+ close();
+ m_pDriver->release();
+ m_pDriver = NULL;
+}
+
+void SAL_CALL OConnection::release() throw()
+{
+ release_ChildImpl();
+}
+
+
+void OConnection::construct(const ::rtl::OUString& url,const Sequence< PropertyValue >& info)
+{
+ osl_atomic_increment( &m_refCount );
+
+ // some example code how to get the information out of the sequence
+
+ sal_Int32 nLen = url.indexOf(':');
+ nLen = url.indexOf(':',nLen+1);
+ ::rtl::OUString aDSN("DSN="), aUID, aPWD, aSysDrvSettings;
+ aDSN += url.copy(nLen+1);
+
+ const char* pUser = "user";
+ const char* pTimeout = "Timeout";
+ const char* pSilent = "Silent";
+ const char* pPwd = "password";
+ const char* pUseCatalog = "UseCatalog";
+ const char* pSysDrv = "SystemDriverSettings";
+
+ sal_Int32 nTimeout = 20;
+ sal_Bool bSilent = sal_True;
+ const PropertyValue *pBegin = info.getConstArray();
+ const PropertyValue *pEnd = pBegin + info.getLength();
+ for(;pBegin != pEnd;++pBegin)
+ {
+ if(pBegin->Name.equalsAscii(pTimeout))
+ pBegin->Value >>= nTimeout;
+ else if(pBegin->Name.equalsAscii(pSilent))
+ pBegin->Value >>= bSilent;
+ else if(pBegin->Name.equalsAscii(pUser))
+ {
+ pBegin->Value >>= aUID;
+ aDSN += ";UID=" + aUID;
+ }
+ else if(pBegin->Name.equalsAscii(pPwd))
+ {
+ pBegin->Value >>= aPWD;
+ aDSN += ";PWD=" + aPWD;
+ }
+ else if(pBegin->Name.equalsAscii(pUseCatalog))
+ {
+ pBegin->Value >>= m_bUseCatalog;
+ }
+ else if(pBegin->Name.equalsAscii(pSysDrv))
+ {
+ pBegin->Value >>= aSysDrvSettings;
+ aDSN += ";";
+ aDSN += aSysDrvSettings;
+ }
+ }
+ m_sUser = aUID;
+
+ osl_atomic_decrement( &m_refCount );
+}
+// XServiceInfo
+
+IMPLEMENT_SERVICE_INFO(OConnection, "com.sun.star.sdbc.drivers.skeleton.OConnection", "com.sun.star.sdbc.Connection")
+
+
+Reference< XStatement > SAL_CALL OConnection::createStatement( )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OConnection_BASE::rBHelper.bDisposed);
+
+ // create a statement
+ // the statement can only be executed once
+ Reference< XStatement > xReturn = new OStatement(this);
+ m_aStatements.push_back(WeakReferenceHelper(xReturn));
+ return xReturn;
+}
+
+Reference< XPreparedStatement > SAL_CALL OConnection::prepareStatement( const ::rtl::OUString& _sSql )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OConnection_BASE::rBHelper.bDisposed);
+
+ // the pre
+ if(m_aTypeInfo.empty())
+ buildTypeInfo();
+
+ // create a statement
+ // the statement can only be executed more than once
+ Reference< XPreparedStatement > xReturn = new OPreparedStatement(this,m_aTypeInfo,_sSql);
+ m_aStatements.push_back(WeakReferenceHelper(xReturn));
+ return xReturn;
+}
+
+Reference< XPreparedStatement > SAL_CALL OConnection::prepareCall( const ::rtl::OUString& _sSql )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OConnection_BASE::rBHelper.bDisposed);
+
+ // not implemented yet :-) a task to do
+ return NULL;
+}
+
+::rtl::OUString SAL_CALL OConnection::nativeSQL( const ::rtl::OUString& _sSql )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ // when you need to transform SQL92 to you driver specific you can do it here
+
+ return _sSql;
+}
+
+void SAL_CALL OConnection::setAutoCommit( sal_Bool autoCommit )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OConnection_BASE::rBHelper.bDisposed);
+ // here you have to set your commit mode please have a look at the jdbc documentation to get a clear explanation
+}
+
+sal_Bool SAL_CALL OConnection::getAutoCommit( )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OConnection_BASE::rBHelper.bDisposed);
+ // you have to distinguish which if you are in autocommit mode or not
+ // at normal case true should be fine here
+
+ return sal_True;
+}
+
+void SAL_CALL OConnection::commit( )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OConnection_BASE::rBHelper.bDisposed);
+
+ // when your database does support transactions you should commit here
+}
+
+void SAL_CALL OConnection::rollback( )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OConnection_BASE::rBHelper.bDisposed);
+
+
+ // same as commit but for the other case
+}
+
+sal_Bool SAL_CALL OConnection::isClosed( )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ // just simple -> we are close when we are disposed that means someone called dispose(); (XComponent)
+ return OConnection_BASE::rBHelper.bDisposed;
+}
+
+Reference< XDatabaseMetaData > SAL_CALL OConnection::getMetaData( )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OConnection_BASE::rBHelper.bDisposed);
+
+ // here we have to create the class with biggest interface
+ // The answer is 42 :-)
+ Reference< XDatabaseMetaData > xMetaData = m_xMetaData;
+ if(!xMetaData.is())
+ {
+ xMetaData = new ODatabaseMetaData(this); // need the connection because it can return it
+ m_xMetaData = xMetaData;
+ }
+
+ return xMetaData;
+}
+
+void SAL_CALL OConnection::setReadOnly( sal_Bool readOnly )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OConnection_BASE::rBHelper.bDisposed);
+
+ // set you connection to readonly
+}
+
+sal_Bool SAL_CALL OConnection::isReadOnly( )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OConnection_BASE::rBHelper.bDisposed);
+
+ // return if your connection to readonly
+ return sal_False;
+}
+
+void SAL_CALL OConnection::setCatalog( const ::rtl::OUString& catalog )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OConnection_BASE::rBHelper.bDisposed);
+
+ // if your database doesn't work with catalogs you go to next method otherwise you know what to do
+}
+
+::rtl::OUString SAL_CALL OConnection::getCatalog( )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OConnection_BASE::rBHelper.bDisposed);
+
+
+ // return your current catalog
+ return ::rtl::OUString();
+}
+
+void SAL_CALL OConnection::setTransactionIsolation( sal_Int32 level )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OConnection_BASE::rBHelper.bDisposed);
+
+ /// set your isolation level
+ /// please have a look at @see com.sun.star.sdbc.TransactionIsolation
+}
+
+sal_Int32 SAL_CALL OConnection::getTransactionIsolation( )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OConnection_BASE::rBHelper.bDisposed);
+
+
+ // please have a look at @see com.sun.star.sdbc.TransactionIsolation
+ return TransactionIsolation::NONE;
+}
+
+Reference< ::com::sun::star::container::XNameAccess > SAL_CALL OConnection::getTypeMap( )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OConnection_BASE::rBHelper.bDisposed);
+
+ // if your driver has special database types you can return it here
+
+ return NULL;
+}
+
+void SAL_CALL OConnection::setTypeMap( const Reference< ::com::sun::star::container::XNameAccess >& typeMap )
+{
+ // the other way around
+}
+
+// XCloseable
+void SAL_CALL OConnection::close( )
+{
+ // we just dispose us
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OConnection_BASE::rBHelper.bDisposed);
+
+ }
+ dispose();
+}
+
+// XWarningsSupplier
+Any SAL_CALL OConnection::getWarnings( )
+{
+ // when you collected some warnings -> return it
+ return Any();
+}
+
+void SAL_CALL OConnection::clearWarnings( )
+{
+ // you should clear your collected warnings here
+}
+
+void OConnection::buildTypeInfo()
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ Reference< XResultSet> xRs = getMetaData ()->getTypeInfo ();
+ Reference< XRow> xRow(xRs,UNO_QUERY);
+ // Information for a single SQL type
+
+ // Loop on the result set until we reach end of file
+
+ while (xRs->next ())
+ {
+ OTypeInfo aInfo;
+ aInfo.aTypeName = xRow->getString (1);
+ aInfo.nType = xRow->getShort (2);
+ aInfo.nPrecision = xRow->getInt (3);
+ aInfo.aLiteralPrefix = xRow->getString (4);
+ aInfo.aLiteralSuffix = xRow->getString (5);
+ aInfo.aCreateParams = xRow->getString (6);
+ aInfo.bNullable = xRow->getBoolean (7);
+ aInfo.bCaseSensitive = xRow->getBoolean (8);
+ aInfo.nSearchType = xRow->getShort (9);
+ aInfo.bUnsigned = xRow->getBoolean (10);
+ aInfo.bCurrency = xRow->getBoolean (11);
+ aInfo.bAutoIncrement = xRow->getBoolean (12);
+ aInfo.aLocalTypeName = xRow->getString (13);
+ aInfo.nMinimumScale = xRow->getShort (14);
+ aInfo.nMaximumScale = xRow->getShort (15);
+ aInfo.nNumPrecRadix = (sal_Int16)xRow->getInt(18);
+
+
+ // Now that we have the type info, save it
+ // in the Hashtable if we don't already have an
+ // entry for this SQL type.
+
+ m_aTypeInfo.push_back(aInfo);
+ }
+
+ // Close the result set/statement.
+
+ Reference< XCloseable> xClose(xRs,UNO_QUERY);
+ xClose->close();
+}
+
+void OConnection::disposing()
+{
+ // we noticed that we should be destroyed in near future so we have to dispose our statements
+ ::osl::MutexGuard aGuard(m_aMutex);
+
+ for (OWeakRefArray::iterator i = m_aStatements.begin(); m_aStatements.end() != i; ++i)
+ {
+ Reference< XComponent > xComp(i->get(), UNO_QUERY);
+ if (xComp.is())
+ xComp->dispose();
+ }
+ m_aStatements.clear();
+
+ m_bClosed = sal_True;
+ m_xMetaData = ::com::sun::star::uno::WeakReference< ::com::sun::star::sdbc::XDatabaseMetaData>();
+
+ dispose_ChildImpl();
+ OConnection_BASE::disposing();
+}
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/Database/DriverSkeleton/SConnection.hxx b/odk/examples/DevelopersGuide/Database/DriverSkeleton/SConnection.hxx
new file mode 100644
index 000000000..b837cd3bc
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Database/DriverSkeleton/SConnection.hxx
@@ -0,0 +1,158 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+#ifndef INCLUDED_EXAMPLES_DATABASE_DRIVERSKELETON_SCONNECTION_HXX
+#define INCLUDED_EXAMPLES_DATABASE_DRIVERSKELETON_SCONNECTION_HXX
+
+#include <com/sun/star/sdbc/SQLWarning.hpp>
+#include <com/sun/star/beans/PropertyValue.hpp>
+#include "OSubComponent.hxx"
+#include "OTypeInfo.hxx"
+#include <com/sun/star/lang/DisposedException.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/lang/XUnoTunnel.hpp>
+#include <com/sun/star/sdbc/XWarningsSupplier.hpp>
+#include <com/sun/star/sdbc/XConnection.hpp>
+#include <cppuhelper/compbase3.hxx>
+#include <cppuhelper/weakref.hxx>
+
+#include <map>
+
+namespace connectivity
+{
+ namespace skeleton
+ {
+
+ typedef ::cppu::WeakComponentImplHelper3< ::com::sun::star::sdbc::XConnection,
+ ::com::sun::star::sdbc::XWarningsSupplier,
+ ::com::sun::star::lang::XServiceInfo
+ > OMetaConnection_BASE;
+
+ class OStatement_Base;
+ class SkeletonDriver;
+ class ODatabaseMetaData;
+
+ typedef OMetaConnection_BASE OConnection_BASE; // implements basics and text encoding
+ typedef ::std::vector< ::connectivity::OTypeInfo> TTypeInfoVector;
+ typedef std::vector< ::com::sun::star::uno::WeakReferenceHelper > OWeakRefArray;
+
+ class OConnection : public OBase_Mutex,
+ public OConnection_BASE,
+ public connectivity::skeleton::OSubComponent<OConnection, OConnection_BASE>
+ {
+ friend class connectivity::skeleton::OSubComponent<OConnection, OConnection_BASE>;
+
+ protected:
+
+ rtl_TextEncoding m_nTextEncoding; // the encoding which is used for all text conversions
+
+ // Data attributes
+
+ TTypeInfoVector m_aTypeInfo; // vector containing an entry
+ // for each row returned by
+ // DatabaseMetaData.getTypeInfo.
+ ::com::sun::star::uno::WeakReference< ::com::sun::star::sdbc::XDatabaseMetaData > m_xMetaData;
+
+ OWeakRefArray m_aStatements; // vector containing a list
+ // of all the Statement objects
+ // for this Connection
+
+ ::com::sun::star::sdbc::SQLWarning m_aLastWarning; // Last SQLWarning generated by
+ // an operation
+ ::rtl::OUString m_aURL; // URL of connection
+ ::rtl::OUString m_sUser; // the user name
+ SkeletonDriver* m_pDriver; // Pointer to the owning
+ // driver object
+
+ sal_Bool m_bClosed;
+ sal_Bool m_bUseCatalog; // should we use the catalog on filebased databases
+ sal_Bool m_bUseOldDateFormat;
+
+
+ void buildTypeInfo();
+
+ public:
+ virtual void construct( const ::rtl::OUString& url,const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& info);
+
+ OConnection(SkeletonDriver* _pDriver);
+ virtual ~OConnection();
+
+ void closeAllStatements ();
+
+ // OComponentHelper
+ virtual void SAL_CALL disposing();
+ // XInterface
+ virtual void SAL_CALL release() throw();
+
+ // XServiceInfo
+ DECLARE_SERVICE_INFO();
+ // XConnection
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XStatement > SAL_CALL createStatement( );
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XPreparedStatement > SAL_CALL prepareStatement( const ::rtl::OUString& sql );
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XPreparedStatement > SAL_CALL prepareCall( const ::rtl::OUString& sql );
+ virtual ::rtl::OUString SAL_CALL nativeSQL( const ::rtl::OUString& sql );
+ virtual void SAL_CALL setAutoCommit( sal_Bool autoCommit );
+ virtual sal_Bool SAL_CALL getAutoCommit( );
+ virtual void SAL_CALL commit( );
+ virtual void SAL_CALL rollback( );
+ virtual sal_Bool SAL_CALL isClosed( );
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData > SAL_CALL getMetaData( );
+ virtual void SAL_CALL setReadOnly( sal_Bool readOnly );
+ virtual sal_Bool SAL_CALL isReadOnly( );
+ virtual void SAL_CALL setCatalog( const ::rtl::OUString& catalog );
+ virtual ::rtl::OUString SAL_CALL getCatalog( );
+ virtual void SAL_CALL setTransactionIsolation( sal_Int32 level );
+ virtual sal_Int32 SAL_CALL getTransactionIsolation( );
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > SAL_CALL getTypeMap( );
+ virtual void SAL_CALL setTypeMap( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& typeMap );
+ // XCloseable
+ virtual void SAL_CALL close( );
+ // XWarningsSupplier
+ virtual ::com::sun::star::uno::Any SAL_CALL getWarnings( );
+ virtual void SAL_CALL clearWarnings( );
+
+
+ // should we use the catalog on filebased databases
+ inline sal_Bool isCatalogUsed() const { return m_bUseCatalog; }
+ inline ::rtl::OUString getUserName() const { return m_sUser; }
+ inline SkeletonDriver* getDriver() const { return m_pDriver;}
+ inline rtl_TextEncoding getTextEncoding() const { return m_nTextEncoding; }
+ };
+ }
+}
+
+#endif // INCLUDED_EXAMPLES_DATABASE_DRIVERSKELETON_SCONNECTION_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/Database/DriverSkeleton/SDatabaseMetaData.cxx b/odk/examples/DevelopersGuide/Database/DriverSkeleton/SDatabaseMetaData.cxx
new file mode 100644
index 000000000..7bba5be08
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Database/DriverSkeleton/SDatabaseMetaData.cxx
@@ -0,0 +1,887 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+#include "SDatabaseMetaData.hxx"
+#include <com/sun/star/sdbc/DataType.hpp>
+#include <com/sun/star/sdbc/ResultSetType.hpp>
+#include <com/sun/star/sdbc/ResultSetConcurrency.hpp>
+#include <com/sun/star/sdbc/TransactionIsolation.hpp>
+
+using namespace connectivity::skeleton;
+using namespace com::sun::star::uno;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::beans;
+using namespace com::sun::star::sdbc;
+
+ODatabaseMetaData::ODatabaseMetaData(OConnection* _pCon)
+: m_pConnection(_pCon)
+, m_bUseCatalog(sal_True)
+{
+ OSL_ENSURE(m_pConnection,"ODatabaseMetaData::ODatabaseMetaData: No connection set!");
+ if(!m_pConnection->isCatalogUsed())
+ {
+ osl_atomic_increment( &m_refCount );
+ m_bUseCatalog = !(usesLocalFiles() || usesLocalFilePerTable());
+ osl_atomic_decrement( &m_refCount );
+ }
+}
+
+ODatabaseMetaData::~ODatabaseMetaData()
+{
+}
+
+::rtl::OUString SAL_CALL ODatabaseMetaData::getCatalogSeparator( )
+{
+ ::rtl::OUString aVal;
+ if(m_bUseCatalog)
+ { // do some special here for you database
+ }
+
+ return aVal;
+}
+
+sal_Int32 SAL_CALL ODatabaseMetaData::getMaxBinaryLiteralLength( )
+{
+ sal_Int32 nValue = 0; // 0 means no limit
+ return nValue;
+}
+
+sal_Int32 SAL_CALL ODatabaseMetaData::getMaxRowSize( )
+{
+ sal_Int32 nValue = 0; // 0 means no limit
+ return nValue;
+}
+
+sal_Int32 SAL_CALL ODatabaseMetaData::getMaxCatalogNameLength( )
+{
+ sal_Int32 nValue = 0; // 0 means no limit
+ return nValue;
+}
+
+sal_Int32 SAL_CALL ODatabaseMetaData::getMaxCharLiteralLength( )
+{
+ sal_Int32 nValue = 0; // 0 means no limit
+ return nValue;
+}
+
+sal_Int32 SAL_CALL ODatabaseMetaData::getMaxColumnNameLength( )
+{
+ sal_Int32 nValue = 0; // 0 means no limit
+ return nValue;
+}
+
+sal_Int32 SAL_CALL ODatabaseMetaData::getMaxColumnsInIndex( )
+{
+ sal_Int32 nValue = 0; // 0 means no limit
+ return nValue;
+}
+
+sal_Int32 SAL_CALL ODatabaseMetaData::getMaxCursorNameLength( )
+{
+ sal_Int32 nValue = 0; // 0 means no limit
+ return nValue;
+}
+
+sal_Int32 SAL_CALL ODatabaseMetaData::getMaxConnections( )
+{
+ sal_Int32 nValue = 0; // 0 means no limit
+ return nValue;
+}
+
+sal_Int32 SAL_CALL ODatabaseMetaData::getMaxColumnsInTable( )
+{
+ sal_Int32 nValue = 0; // 0 means no limit
+ return nValue;
+}
+
+sal_Int32 SAL_CALL ODatabaseMetaData::getMaxStatementLength( )
+{
+ sal_Int32 nValue = 0; // 0 means no limit
+ return nValue;
+}
+
+sal_Int32 SAL_CALL ODatabaseMetaData::getMaxTableNameLength( )
+{
+ sal_Int32 nValue = 0; // 0 means no limit
+ return nValue;
+}
+
+sal_Int32 SAL_CALL ODatabaseMetaData::getMaxTablesInSelect( )
+{
+ sal_Int32 nValue = 0; // 0 means no limit
+ return nValue;
+}
+
+
+sal_Bool SAL_CALL ODatabaseMetaData::doesMaxRowSizeIncludeBlobs( )
+{
+ return sal_False;
+}
+
+sal_Bool SAL_CALL ODatabaseMetaData::storesLowerCaseQuotedIdentifiers( )
+{
+ return sal_False;
+}
+
+sal_Bool SAL_CALL ODatabaseMetaData::storesLowerCaseIdentifiers( )
+{
+ return sal_False;
+}
+
+sal_Bool SAL_CALL ODatabaseMetaData::storesMixedCaseQuotedIdentifiers( )
+{
+ return sal_False;
+}
+
+sal_Bool SAL_CALL ODatabaseMetaData::storesMixedCaseIdentifiers( )
+{
+ return sal_False;
+}
+
+sal_Bool SAL_CALL ODatabaseMetaData::storesUpperCaseQuotedIdentifiers( )
+{
+ return sal_False;
+}
+
+sal_Bool SAL_CALL ODatabaseMetaData::storesUpperCaseIdentifiers( )
+{
+ return sal_False;
+}
+
+sal_Bool SAL_CALL ODatabaseMetaData::supportsAlterTableWithAddColumn( )
+{
+ return sal_False;
+}
+
+sal_Bool SAL_CALL ODatabaseMetaData::supportsAlterTableWithDropColumn( )
+{
+ return sal_False;
+}
+
+sal_Int32 SAL_CALL ODatabaseMetaData::getMaxIndexLength( )
+{
+ sal_Int32 nValue = 0; // 0 means no limit
+ return nValue;
+}
+
+sal_Bool SAL_CALL ODatabaseMetaData::supportsNonNullableColumns( )
+{
+ return sal_False;
+}
+
+::rtl::OUString SAL_CALL ODatabaseMetaData::getCatalogTerm( )
+{
+ ::rtl::OUString aVal;
+ if(m_bUseCatalog)
+ {
+ }
+ return aVal;
+}
+
+::rtl::OUString SAL_CALL ODatabaseMetaData::getIdentifierQuoteString( )
+{
+ // normally this is "
+ ::rtl::OUString aVal("\"");
+ return aVal;
+}
+
+::rtl::OUString SAL_CALL ODatabaseMetaData::getExtraNameCharacters( )
+{
+ ::rtl::OUString aVal;
+ return aVal;
+}
+
+sal_Bool SAL_CALL ODatabaseMetaData::supportsDifferentTableCorrelationNames( )
+{
+ return sal_False;
+}
+
+sal_Bool SAL_CALL ODatabaseMetaData::isCatalogAtStart( )
+{
+ sal_Bool bValue = sal_False;
+ if(m_bUseCatalog)
+ {
+ }
+ return bValue;
+}
+
+sal_Bool SAL_CALL ODatabaseMetaData::dataDefinitionIgnoredInTransactions( )
+{
+ return sal_True;
+}
+
+sal_Bool SAL_CALL ODatabaseMetaData::dataDefinitionCausesTransactionCommit( )
+{
+ return sal_True;
+}
+
+sal_Bool SAL_CALL ODatabaseMetaData::supportsDataManipulationTransactionsOnly( )
+{
+ return sal_True;
+}
+
+sal_Bool SAL_CALL ODatabaseMetaData::supportsDataDefinitionAndDataManipulationTransactions( )
+{
+ return sal_True;
+}
+
+sal_Bool SAL_CALL ODatabaseMetaData::supportsPositionedDelete( )
+{
+ return sal_False;
+}
+
+sal_Bool SAL_CALL ODatabaseMetaData::supportsPositionedUpdate( )
+{
+ return sal_False;
+}
+
+sal_Bool SAL_CALL ODatabaseMetaData::supportsOpenStatementsAcrossRollback( )
+{
+ return sal_False;
+}
+
+sal_Bool SAL_CALL ODatabaseMetaData::supportsOpenStatementsAcrossCommit( )
+{
+ return sal_False;
+}
+
+sal_Bool SAL_CALL ODatabaseMetaData::supportsOpenCursorsAcrossCommit( )
+{
+ return sal_False;
+}
+
+sal_Bool SAL_CALL ODatabaseMetaData::supportsOpenCursorsAcrossRollback( )
+{
+ return sal_False;
+}
+
+sal_Bool SAL_CALL ODatabaseMetaData::supportsTransactionIsolationLevel( sal_Int32 level )
+{
+ return sal_False;
+}
+
+sal_Bool SAL_CALL ODatabaseMetaData::supportsSchemasInDataManipulation( )
+{
+ return sal_False;
+}
+
+sal_Bool SAL_CALL ODatabaseMetaData::supportsANSI92FullSQL( )
+{
+ return sal_False;
+}
+
+sal_Bool SAL_CALL ODatabaseMetaData::supportsANSI92EntryLevelSQL( )
+{
+ return sal_True; // should be supported at least
+}
+
+sal_Bool SAL_CALL ODatabaseMetaData::supportsIntegrityEnhancementFacility( )
+{
+ return sal_False;
+}
+
+sal_Bool SAL_CALL ODatabaseMetaData::supportsSchemasInIndexDefinitions( )
+{
+ return sal_False;
+}
+
+sal_Bool SAL_CALL ODatabaseMetaData::supportsSchemasInTableDefinitions( )
+{
+ return sal_False;
+}
+
+sal_Bool SAL_CALL ODatabaseMetaData::supportsCatalogsInTableDefinitions( )
+{
+ return sal_False;
+}
+
+sal_Bool SAL_CALL ODatabaseMetaData::supportsCatalogsInIndexDefinitions( )
+{
+ return sal_False;
+}
+
+sal_Bool SAL_CALL ODatabaseMetaData::supportsCatalogsInDataManipulation( )
+{
+ return sal_False;
+}
+
+sal_Bool SAL_CALL ODatabaseMetaData::supportsOuterJoins( )
+{
+ return sal_False;
+}
+
+sal_Int32 SAL_CALL ODatabaseMetaData::getMaxStatements( )
+{
+ sal_Int32 nValue = 0; // 0 means no limit
+ return nValue;
+}
+
+sal_Int32 SAL_CALL ODatabaseMetaData::getMaxProcedureNameLength( )
+{
+ sal_Int32 nValue = 0; // 0 means no limit
+ return nValue;
+}
+
+sal_Int32 SAL_CALL ODatabaseMetaData::getMaxSchemaNameLength( )
+{
+ sal_Int32 nValue = 0; // 0 means no limit
+ return nValue;
+}
+
+sal_Bool SAL_CALL ODatabaseMetaData::supportsTransactions( )
+{
+ return sal_False;
+}
+
+sal_Bool SAL_CALL ODatabaseMetaData::allProceduresAreCallable( )
+{
+ return sal_False;
+}
+
+sal_Bool SAL_CALL ODatabaseMetaData::supportsStoredProcedures( )
+{
+ return sal_False;
+}
+
+sal_Bool SAL_CALL ODatabaseMetaData::supportsSelectForUpdate( )
+{
+ return sal_False;
+}
+
+sal_Bool SAL_CALL ODatabaseMetaData::allTablesAreSelectable( )
+{
+ return sal_False;
+}
+
+sal_Bool SAL_CALL ODatabaseMetaData::isReadOnly( )
+{
+ return sal_False;
+}
+
+sal_Bool SAL_CALL ODatabaseMetaData::usesLocalFiles( )
+{
+ return sal_False;
+}
+
+sal_Bool SAL_CALL ODatabaseMetaData::usesLocalFilePerTable( )
+{
+ return sal_False;
+}
+
+sal_Bool SAL_CALL ODatabaseMetaData::supportsTypeConversion( )
+{
+ return sal_False;
+}
+
+sal_Bool SAL_CALL ODatabaseMetaData::nullPlusNonNullIsNull( )
+{
+ return sal_False;
+}
+
+sal_Bool SAL_CALL ODatabaseMetaData::supportsColumnAliasing( )
+{
+ return sal_False;
+}
+
+sal_Bool SAL_CALL ODatabaseMetaData::supportsTableCorrelationNames( )
+{
+ return sal_False;
+}
+
+sal_Bool SAL_CALL ODatabaseMetaData::supportsConvert( sal_Int32 fromType, sal_Int32 toType )
+{
+ return sal_False;
+}
+
+sal_Bool SAL_CALL ODatabaseMetaData::supportsExpressionsInOrderBy( )
+{
+ return sal_False;
+}
+
+sal_Bool SAL_CALL ODatabaseMetaData::supportsGroupBy( )
+{
+ return sal_False;
+}
+
+sal_Bool SAL_CALL ODatabaseMetaData::supportsGroupByBeyondSelect( )
+{
+ return sal_False;
+}
+
+sal_Bool SAL_CALL ODatabaseMetaData::supportsGroupByUnrelated( )
+{
+ return sal_False;
+}
+
+sal_Bool SAL_CALL ODatabaseMetaData::supportsMultipleTransactions( )
+{
+ return sal_False;
+}
+
+sal_Bool SAL_CALL ODatabaseMetaData::supportsMultipleResultSets( )
+{
+ return sal_False;
+}
+
+sal_Bool SAL_CALL ODatabaseMetaData::supportsLikeEscapeClause( )
+{
+ return sal_False;
+}
+
+sal_Bool SAL_CALL ODatabaseMetaData::supportsOrderByUnrelated( )
+{
+ return sal_False;
+}
+
+sal_Bool SAL_CALL ODatabaseMetaData::supportsUnion( )
+{
+ return sal_False;
+}
+
+sal_Bool SAL_CALL ODatabaseMetaData::supportsUnionAll( )
+{
+ return sal_False;
+}
+
+sal_Bool SAL_CALL ODatabaseMetaData::supportsMixedCaseIdentifiers( )
+{
+ return sal_False;
+}
+
+sal_Bool SAL_CALL ODatabaseMetaData::supportsMixedCaseQuotedIdentifiers( )
+{
+ return sal_False;
+}
+
+sal_Bool SAL_CALL ODatabaseMetaData::nullsAreSortedAtEnd( )
+{
+ return sal_False;
+}
+
+sal_Bool SAL_CALL ODatabaseMetaData::nullsAreSortedAtStart( )
+{
+ return sal_False;
+}
+
+sal_Bool SAL_CALL ODatabaseMetaData::nullsAreSortedHigh( )
+{
+ return sal_False;
+}
+
+sal_Bool SAL_CALL ODatabaseMetaData::nullsAreSortedLow( )
+{
+ return sal_False;
+}
+
+sal_Bool SAL_CALL ODatabaseMetaData::supportsSchemasInProcedureCalls( )
+{
+ return sal_False;
+}
+
+sal_Bool SAL_CALL ODatabaseMetaData::supportsSchemasInPrivilegeDefinitions( )
+{
+ return sal_False;
+}
+
+sal_Bool SAL_CALL ODatabaseMetaData::supportsCatalogsInProcedureCalls( )
+{
+ return sal_False;
+}
+
+sal_Bool SAL_CALL ODatabaseMetaData::supportsCatalogsInPrivilegeDefinitions( )
+{
+ return sal_False;
+}
+
+sal_Bool SAL_CALL ODatabaseMetaData::supportsCorrelatedSubqueries( )
+{
+ return sal_False;
+}
+
+sal_Bool SAL_CALL ODatabaseMetaData::supportsSubqueriesInComparisons( )
+{
+ return sal_False;
+}
+
+sal_Bool SAL_CALL ODatabaseMetaData::supportsSubqueriesInExists( )
+{
+ return sal_False;
+}
+
+sal_Bool SAL_CALL ODatabaseMetaData::supportsSubqueriesInIns( )
+{
+ return sal_False;
+}
+
+sal_Bool SAL_CALL ODatabaseMetaData::supportsSubqueriesInQuantifieds( )
+{
+ return sal_False;
+}
+
+sal_Bool SAL_CALL ODatabaseMetaData::supportsANSI92IntermediateSQL( )
+{
+ return sal_False;
+}
+
+::rtl::OUString SAL_CALL ODatabaseMetaData::getURL( )
+{
+ ::rtl::OUString aValue("sdbc:skeleton:");
+ return aValue;
+}
+
+::rtl::OUString SAL_CALL ODatabaseMetaData::getUserName( )
+{
+ ::rtl::OUString aValue;
+ return aValue;
+}
+
+::rtl::OUString SAL_CALL ODatabaseMetaData::getDriverName( )
+{
+ ::rtl::OUString aValue;
+ return aValue;
+}
+
+::rtl::OUString SAL_CALL ODatabaseMetaData::getDriverVersion()
+{
+ ::rtl::OUString aValue;
+ return aValue;
+}
+
+::rtl::OUString SAL_CALL ODatabaseMetaData::getDatabaseProductVersion( )
+{
+ ::rtl::OUString aValue;
+ return aValue;
+}
+
+::rtl::OUString SAL_CALL ODatabaseMetaData::getDatabaseProductName( )
+{
+ ::rtl::OUString aValue;
+ return aValue;
+}
+
+::rtl::OUString SAL_CALL ODatabaseMetaData::getProcedureTerm( )
+{
+ ::rtl::OUString aValue;
+ return aValue;
+}
+
+::rtl::OUString SAL_CALL ODatabaseMetaData::getSchemaTerm( )
+{
+ ::rtl::OUString aValue;
+ return aValue;
+}
+
+sal_Int32 SAL_CALL ODatabaseMetaData::getDriverMajorVersion( )
+{
+ return 1;
+}
+
+sal_Int32 SAL_CALL ODatabaseMetaData::getDefaultTransactionIsolation( )
+{
+ return TransactionIsolation::NONE;
+}
+
+sal_Int32 SAL_CALL ODatabaseMetaData::getDriverMinorVersion( )
+{
+ return 0;
+}
+
+::rtl::OUString SAL_CALL ODatabaseMetaData::getSQLKeywords( )
+{
+ ::rtl::OUString aValue;
+ return aValue;
+}
+
+::rtl::OUString SAL_CALL ODatabaseMetaData::getSearchStringEscape( )
+{
+ ::rtl::OUString aValue;
+ return aValue;
+}
+
+::rtl::OUString SAL_CALL ODatabaseMetaData::getStringFunctions( )
+{
+ return ::rtl::OUString();
+}
+
+::rtl::OUString SAL_CALL ODatabaseMetaData::getTimeDateFunctions( )
+{
+ return ::rtl::OUString();
+}
+
+::rtl::OUString SAL_CALL ODatabaseMetaData::getSystemFunctions( )
+{
+ return ::rtl::OUString();
+}
+
+::rtl::OUString SAL_CALL ODatabaseMetaData::getNumericFunctions( )
+{
+ return ::rtl::OUString();
+}
+
+sal_Bool SAL_CALL ODatabaseMetaData::supportsExtendedSQLGrammar( )
+{
+ return sal_False;
+}
+
+sal_Bool SAL_CALL ODatabaseMetaData::supportsCoreSQLGrammar( )
+{
+ return sal_False;
+}
+
+sal_Bool SAL_CALL ODatabaseMetaData::supportsMinimumSQLGrammar( )
+{
+ return sal_True;
+}
+
+sal_Bool SAL_CALL ODatabaseMetaData::supportsFullOuterJoins( )
+{
+ return sal_False;
+}
+
+sal_Bool SAL_CALL ODatabaseMetaData::supportsLimitedOuterJoins( )
+{
+ return sal_False;
+}
+
+sal_Int32 SAL_CALL ODatabaseMetaData::getMaxColumnsInGroupBy( )
+{
+ sal_Int32 nValue = 0; // 0 means no limit
+ return nValue;
+}
+
+sal_Int32 SAL_CALL ODatabaseMetaData::getMaxColumnsInOrderBy( )
+{
+ sal_Int32 nValue = 0; // 0 means no limit
+ return nValue;
+}
+
+sal_Int32 SAL_CALL ODatabaseMetaData::getMaxColumnsInSelect( )
+{
+ sal_Int32 nValue = 0; // 0 means no limit
+ return nValue;
+}
+
+sal_Int32 SAL_CALL ODatabaseMetaData::getMaxUserNameLength( )
+{
+ sal_Int32 nValue = 0; // 0 means no limit
+ return nValue;
+}
+
+sal_Bool SAL_CALL ODatabaseMetaData::supportsResultSetType( sal_Int32 setType )
+{
+ return sal_False;
+}
+
+sal_Bool SAL_CALL ODatabaseMetaData::supportsResultSetConcurrency( sal_Int32 setType, sal_Int32 concurrency )
+{
+ return sal_False;
+}
+
+sal_Bool SAL_CALL ODatabaseMetaData::ownUpdatesAreVisible( sal_Int32 setType )
+{
+ return sal_False;
+}
+
+sal_Bool SAL_CALL ODatabaseMetaData::ownDeletesAreVisible( sal_Int32 setType )
+{
+ return sal_False;
+}
+
+sal_Bool SAL_CALL ODatabaseMetaData::ownInsertsAreVisible( sal_Int32 setType )
+{
+ return sal_False;
+}
+
+sal_Bool SAL_CALL ODatabaseMetaData::othersUpdatesAreVisible( sal_Int32 setType )
+{
+ return sal_False;
+}
+
+sal_Bool SAL_CALL ODatabaseMetaData::othersDeletesAreVisible( sal_Int32 setType )
+{
+ return sal_False;
+}
+
+sal_Bool SAL_CALL ODatabaseMetaData::othersInsertsAreVisible( sal_Int32 setType )
+{
+ return sal_False;
+}
+
+sal_Bool SAL_CALL ODatabaseMetaData::updatesAreDetected( sal_Int32 setType )
+{
+ return sal_False;
+}
+
+sal_Bool SAL_CALL ODatabaseMetaData::deletesAreDetected( sal_Int32 setType )
+{
+ return sal_False;
+}
+
+sal_Bool SAL_CALL ODatabaseMetaData::insertsAreDetected( sal_Int32 setType )
+{
+ return sal_False;
+}
+
+sal_Bool SAL_CALL ODatabaseMetaData::supportsBatchUpdates( )
+{
+ return sal_False;
+}
+
+Reference< XConnection > SAL_CALL ODatabaseMetaData::getConnection( )
+{
+ return (Reference< XConnection >)m_pConnection;//new OConnection(m_aConnectionHandle);
+}
+
+// here follow all methods which return a resultset
+// the first methods is an example implementation how to use this resultset
+// of course you could implement it on your and you should do this because
+// the general way is more memory expensive
+
+Reference< XResultSet > SAL_CALL ODatabaseMetaData::getTableTypes( )
+{
+ return NULL;
+}
+
+Reference< XResultSet > SAL_CALL ODatabaseMetaData::getTypeInfo( )
+{
+ return NULL;
+}
+
+Reference< XResultSet > SAL_CALL ODatabaseMetaData::getCatalogs( )
+{
+ return NULL;
+}
+
+Reference< XResultSet > SAL_CALL ODatabaseMetaData::getSchemas( )
+{
+ return NULL;
+}
+
+Reference< XResultSet > SAL_CALL ODatabaseMetaData::getColumnPrivileges(
+ const Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table,
+ const ::rtl::OUString& columnNamePattern )
+{
+ return NULL;
+}
+
+Reference< XResultSet > SAL_CALL ODatabaseMetaData::getColumns(
+ const Any& catalog, const ::rtl::OUString& schemaPattern, const ::rtl::OUString& tableNamePattern,
+ const ::rtl::OUString& columnNamePattern )
+{
+ return NULL;
+}
+
+Reference< XResultSet > SAL_CALL ODatabaseMetaData::getTables(
+ const Any& catalog, const ::rtl::OUString& schemaPattern,
+ const ::rtl::OUString& tableNamePattern, const Sequence< ::rtl::OUString >& types )
+{
+ return NULL;
+}
+
+Reference< XResultSet > SAL_CALL ODatabaseMetaData::getProcedureColumns(
+ const Any& catalog, const ::rtl::OUString& schemaPattern,
+ const ::rtl::OUString& procedureNamePattern, const ::rtl::OUString& columnNamePattern )
+{
+ return NULL;
+}
+
+Reference< XResultSet > SAL_CALL ODatabaseMetaData::getProcedures(
+ const Any& catalog, const ::rtl::OUString& schemaPattern,
+ const ::rtl::OUString& procedureNamePattern )
+{
+ return NULL;
+}
+
+Reference< XResultSet > SAL_CALL ODatabaseMetaData::getVersionColumns(
+ const Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table )
+{
+ return NULL;
+}
+
+Reference< XResultSet > SAL_CALL ODatabaseMetaData::getExportedKeys(
+ const Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table )
+{
+ return NULL;
+}
+
+Reference< XResultSet > SAL_CALL ODatabaseMetaData::getImportedKeys(
+ const Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table )
+{
+ return NULL;
+}
+
+Reference< XResultSet > SAL_CALL ODatabaseMetaData::getPrimaryKeys(
+ const Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table )
+{
+ return NULL;
+}
+
+Reference< XResultSet > SAL_CALL ODatabaseMetaData::getIndexInfo(
+ const Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table,
+ sal_Bool unique, sal_Bool approximate )
+{
+ return NULL;
+}
+
+Reference< XResultSet > SAL_CALL ODatabaseMetaData::getBestRowIdentifier(
+ const Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table, sal_Int32 scope,
+ sal_Bool nullable )
+{
+ return NULL;
+}
+
+Reference< XResultSet > SAL_CALL ODatabaseMetaData::getTablePrivileges(
+ const Any& catalog, const ::rtl::OUString& schemaPattern, const ::rtl::OUString& tableNamePattern )
+{
+ return NULL;
+}
+
+Reference< XResultSet > SAL_CALL ODatabaseMetaData::getCrossReference(
+ const Any& primaryCatalog, const ::rtl::OUString& primarySchema,
+ const ::rtl::OUString& primaryTable, const Any& foreignCatalog,
+ const ::rtl::OUString& foreignSchema, const ::rtl::OUString& foreignTable )
+{
+ return NULL;
+}
+
+Reference< XResultSet > SAL_CALL ODatabaseMetaData::getUDTs( const Any& catalog, const ::rtl::OUString& schemaPattern, const ::rtl::OUString& typeNamePattern, const Sequence< sal_Int32 >& types )
+{
+ OSL_FAIL("Not implemented yet!");
+ throw SQLException();
+ return NULL;
+}
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/Database/DriverSkeleton/SDatabaseMetaData.hxx b/odk/examples/DevelopersGuide/Database/DriverSkeleton/SDatabaseMetaData.hxx
new file mode 100644
index 000000000..a81cbfc47
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Database/DriverSkeleton/SDatabaseMetaData.hxx
@@ -0,0 +1,218 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+#ifndef INCLUDED_EXAMPLES_DATABASE_DRIVERSKELETON_SDATABASEMETADATA_HXX
+#define INCLUDED_EXAMPLES_DATABASE_DRIVERSKELETON_SDATABASEMETADATA_HXX
+
+#include "SConnection.hxx"
+#include <com/sun/star/sdbc/XDatabaseMetaData.hpp>
+#include <cppuhelper/implbase1.hxx>
+
+namespace connectivity
+{
+ namespace skeleton
+ {
+
+ typedef ::cppu::WeakImplHelper1< ::com::sun::star::sdbc::XDatabaseMetaData> ODatabaseMetaData_BASE;
+
+ class ODatabaseMetaData : public ODatabaseMetaData_BASE
+ {
+ OConnection* m_pConnection;
+ sal_Bool m_bUseCatalog;
+ public:
+
+ inline OConnection* getOwnConnection() const { return m_pConnection; }
+
+ ODatabaseMetaData(OConnection* _pCon);
+ virtual ~ODatabaseMetaData();
+
+ // as I mentioned before this interface is really BIG
+ // XDatabaseMetaData
+ virtual sal_Bool SAL_CALL allProceduresAreCallable( );
+ virtual sal_Bool SAL_CALL allTablesAreSelectable( );
+ virtual ::rtl::OUString SAL_CALL getURL( );
+ virtual ::rtl::OUString SAL_CALL getUserName( );
+ virtual sal_Bool SAL_CALL isReadOnly( );
+ virtual sal_Bool SAL_CALL nullsAreSortedHigh( );
+ virtual sal_Bool SAL_CALL nullsAreSortedLow( );
+ virtual sal_Bool SAL_CALL nullsAreSortedAtStart( );
+ virtual sal_Bool SAL_CALL nullsAreSortedAtEnd( );
+ virtual ::rtl::OUString SAL_CALL getDatabaseProductName( );
+ virtual ::rtl::OUString SAL_CALL getDatabaseProductVersion( );
+ virtual ::rtl::OUString SAL_CALL getDriverName( );
+ virtual ::rtl::OUString SAL_CALL getDriverVersion( );
+ virtual sal_Int32 SAL_CALL getDriverMajorVersion( );
+ virtual sal_Int32 SAL_CALL getDriverMinorVersion( );
+ virtual sal_Bool SAL_CALL usesLocalFiles( );
+ virtual sal_Bool SAL_CALL usesLocalFilePerTable( );
+ virtual sal_Bool SAL_CALL supportsMixedCaseIdentifiers( );
+ virtual sal_Bool SAL_CALL storesUpperCaseIdentifiers( );
+ virtual sal_Bool SAL_CALL storesLowerCaseIdentifiers( );
+ virtual sal_Bool SAL_CALL storesMixedCaseIdentifiers( );
+ virtual sal_Bool SAL_CALL supportsMixedCaseQuotedIdentifiers( );
+ virtual sal_Bool SAL_CALL storesUpperCaseQuotedIdentifiers( );
+ virtual sal_Bool SAL_CALL storesLowerCaseQuotedIdentifiers( );
+ virtual sal_Bool SAL_CALL storesMixedCaseQuotedIdentifiers( );
+ virtual ::rtl::OUString SAL_CALL getIdentifierQuoteString( );
+ virtual ::rtl::OUString SAL_CALL getSQLKeywords( );
+ virtual ::rtl::OUString SAL_CALL getNumericFunctions( );
+ virtual ::rtl::OUString SAL_CALL getStringFunctions( );
+ virtual ::rtl::OUString SAL_CALL getSystemFunctions( );
+ virtual ::rtl::OUString SAL_CALL getTimeDateFunctions( );
+ virtual ::rtl::OUString SAL_CALL getSearchStringEscape( );
+ virtual ::rtl::OUString SAL_CALL getExtraNameCharacters( );
+ virtual sal_Bool SAL_CALL supportsAlterTableWithAddColumn( );
+ virtual sal_Bool SAL_CALL supportsAlterTableWithDropColumn( );
+ virtual sal_Bool SAL_CALL supportsColumnAliasing( );
+ virtual sal_Bool SAL_CALL nullPlusNonNullIsNull( );
+ virtual sal_Bool SAL_CALL supportsTypeConversion( );
+ virtual sal_Bool SAL_CALL supportsConvert( sal_Int32 fromType, sal_Int32 toType );
+ virtual sal_Bool SAL_CALL supportsTableCorrelationNames( );
+ virtual sal_Bool SAL_CALL supportsDifferentTableCorrelationNames( );
+ virtual sal_Bool SAL_CALL supportsExpressionsInOrderBy( );
+ virtual sal_Bool SAL_CALL supportsOrderByUnrelated( );
+ virtual sal_Bool SAL_CALL supportsGroupBy( );
+ virtual sal_Bool SAL_CALL supportsGroupByUnrelated( );
+ virtual sal_Bool SAL_CALL supportsGroupByBeyondSelect( );
+ virtual sal_Bool SAL_CALL supportsLikeEscapeClause( );
+ virtual sal_Bool SAL_CALL supportsMultipleResultSets( );
+ virtual sal_Bool SAL_CALL supportsMultipleTransactions( );
+ virtual sal_Bool SAL_CALL supportsNonNullableColumns( );
+ virtual sal_Bool SAL_CALL supportsMinimumSQLGrammar( );
+ virtual sal_Bool SAL_CALL supportsCoreSQLGrammar( );
+ virtual sal_Bool SAL_CALL supportsExtendedSQLGrammar( );
+ virtual sal_Bool SAL_CALL supportsANSI92EntryLevelSQL( );
+ virtual sal_Bool SAL_CALL supportsANSI92IntermediateSQL( );
+ virtual sal_Bool SAL_CALL supportsANSI92FullSQL( );
+ virtual sal_Bool SAL_CALL supportsIntegrityEnhancementFacility( );
+ virtual sal_Bool SAL_CALL supportsOuterJoins( );
+ virtual sal_Bool SAL_CALL supportsFullOuterJoins( );
+ virtual sal_Bool SAL_CALL supportsLimitedOuterJoins( );
+ virtual ::rtl::OUString SAL_CALL getSchemaTerm( );
+ virtual ::rtl::OUString SAL_CALL getProcedureTerm( );
+ virtual ::rtl::OUString SAL_CALL getCatalogTerm( );
+ virtual sal_Bool SAL_CALL isCatalogAtStart( );
+ virtual ::rtl::OUString SAL_CALL getCatalogSeparator( );
+ virtual sal_Bool SAL_CALL supportsSchemasInDataManipulation( );
+ virtual sal_Bool SAL_CALL supportsSchemasInProcedureCalls( );
+ virtual sal_Bool SAL_CALL supportsSchemasInTableDefinitions( );
+ virtual sal_Bool SAL_CALL supportsSchemasInIndexDefinitions( );
+ virtual sal_Bool SAL_CALL supportsSchemasInPrivilegeDefinitions( );
+ virtual sal_Bool SAL_CALL supportsCatalogsInDataManipulation( );
+ virtual sal_Bool SAL_CALL supportsCatalogsInProcedureCalls( );
+ virtual sal_Bool SAL_CALL supportsCatalogsInTableDefinitions( );
+ virtual sal_Bool SAL_CALL supportsCatalogsInIndexDefinitions( );
+ virtual sal_Bool SAL_CALL supportsCatalogsInPrivilegeDefinitions( );
+ virtual sal_Bool SAL_CALL supportsPositionedDelete( );
+ virtual sal_Bool SAL_CALL supportsPositionedUpdate( );
+ virtual sal_Bool SAL_CALL supportsSelectForUpdate( );
+ virtual sal_Bool SAL_CALL supportsStoredProcedures( );
+ virtual sal_Bool SAL_CALL supportsSubqueriesInComparisons( );
+ virtual sal_Bool SAL_CALL supportsSubqueriesInExists( );
+ virtual sal_Bool SAL_CALL supportsSubqueriesInIns( );
+ virtual sal_Bool SAL_CALL supportsSubqueriesInQuantifieds( );
+ virtual sal_Bool SAL_CALL supportsCorrelatedSubqueries( );
+ virtual sal_Bool SAL_CALL supportsUnion( );
+ virtual sal_Bool SAL_CALL supportsUnionAll( );
+ virtual sal_Bool SAL_CALL supportsOpenCursorsAcrossCommit( );
+ virtual sal_Bool SAL_CALL supportsOpenCursorsAcrossRollback( );
+ virtual sal_Bool SAL_CALL supportsOpenStatementsAcrossCommit( );
+ virtual sal_Bool SAL_CALL supportsOpenStatementsAcrossRollback( );
+ virtual sal_Int32 SAL_CALL getMaxBinaryLiteralLength( );
+ virtual sal_Int32 SAL_CALL getMaxCharLiteralLength( );
+ virtual sal_Int32 SAL_CALL getMaxColumnNameLength( );
+ virtual sal_Int32 SAL_CALL getMaxColumnsInGroupBy( );
+ virtual sal_Int32 SAL_CALL getMaxColumnsInIndex( );
+ virtual sal_Int32 SAL_CALL getMaxColumnsInOrderBy( );
+ virtual sal_Int32 SAL_CALL getMaxColumnsInSelect( );
+ virtual sal_Int32 SAL_CALL getMaxColumnsInTable( );
+ virtual sal_Int32 SAL_CALL getMaxConnections( );
+ virtual sal_Int32 SAL_CALL getMaxCursorNameLength( );
+ virtual sal_Int32 SAL_CALL getMaxIndexLength( );
+ virtual sal_Int32 SAL_CALL getMaxSchemaNameLength( );
+ virtual sal_Int32 SAL_CALL getMaxProcedureNameLength( );
+ virtual sal_Int32 SAL_CALL getMaxCatalogNameLength( );
+ virtual sal_Int32 SAL_CALL getMaxRowSize( );
+ virtual sal_Bool SAL_CALL doesMaxRowSizeIncludeBlobs( );
+ virtual sal_Int32 SAL_CALL getMaxStatementLength( );
+ virtual sal_Int32 SAL_CALL getMaxStatements( );
+ virtual sal_Int32 SAL_CALL getMaxTableNameLength( );
+ virtual sal_Int32 SAL_CALL getMaxTablesInSelect( );
+ virtual sal_Int32 SAL_CALL getMaxUserNameLength( );
+ virtual sal_Int32 SAL_CALL getDefaultTransactionIsolation( );
+ virtual sal_Bool SAL_CALL supportsTransactions( );
+ virtual sal_Bool SAL_CALL supportsTransactionIsolationLevel( sal_Int32 level );
+ virtual sal_Bool SAL_CALL supportsDataDefinitionAndDataManipulationTransactions( );
+ virtual sal_Bool SAL_CALL supportsDataManipulationTransactionsOnly( );
+ virtual sal_Bool SAL_CALL dataDefinitionCausesTransactionCommit( );
+ virtual sal_Bool SAL_CALL dataDefinitionIgnoredInTransactions( );
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getProcedures( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schemaPattern, const ::rtl::OUString& procedureNamePattern );
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getProcedureColumns( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schemaPattern, const ::rtl::OUString& procedureNamePattern, const ::rtl::OUString& columnNamePattern );
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getTables( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schemaPattern, const ::rtl::OUString& tableNamePattern, const ::com::sun::star::uno::Sequence< ::rtl::OUString >& types );
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getSchemas( );
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getCatalogs( );
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getTableTypes( );
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getColumns( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schemaPattern, const ::rtl::OUString& tableNamePattern, const ::rtl::OUString& columnNamePattern );
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getColumnPrivileges( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table, const ::rtl::OUString& columnNamePattern );
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getTablePrivileges( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schemaPattern, const ::rtl::OUString& tableNamePattern );
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getBestRowIdentifier( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table, sal_Int32 scope, sal_Bool nullable );
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getVersionColumns( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table );
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getPrimaryKeys( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table );
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getImportedKeys( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table );
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getExportedKeys( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table );
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getCrossReference( const ::com::sun::star::uno::Any& primaryCatalog, const ::rtl::OUString& primarySchema, const ::rtl::OUString& primaryTable, const ::com::sun::star::uno::Any& foreignCatalog, const ::rtl::OUString& foreignSchema, const ::rtl::OUString& foreignTable );
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getTypeInfo( );
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getIndexInfo( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table, sal_Bool unique, sal_Bool approximate );
+ virtual sal_Bool SAL_CALL supportsResultSetType( sal_Int32 setType );
+ virtual sal_Bool SAL_CALL supportsResultSetConcurrency( sal_Int32 setType, sal_Int32 concurrency );
+ virtual sal_Bool SAL_CALL ownUpdatesAreVisible( sal_Int32 setType );
+ virtual sal_Bool SAL_CALL ownDeletesAreVisible( sal_Int32 setType );
+ virtual sal_Bool SAL_CALL ownInsertsAreVisible( sal_Int32 setType );
+ virtual sal_Bool SAL_CALL othersUpdatesAreVisible( sal_Int32 setType );
+ virtual sal_Bool SAL_CALL othersDeletesAreVisible( sal_Int32 setType );
+ virtual sal_Bool SAL_CALL othersInsertsAreVisible( sal_Int32 setType );
+ virtual sal_Bool SAL_CALL updatesAreDetected( sal_Int32 setType );
+ virtual sal_Bool SAL_CALL deletesAreDetected( sal_Int32 setType );
+ virtual sal_Bool SAL_CALL insertsAreDetected( sal_Int32 setType );
+ virtual sal_Bool SAL_CALL supportsBatchUpdates( );
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getUDTs( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schemaPattern, const ::rtl::OUString& typeNamePattern, const ::com::sun::star::uno::Sequence< sal_Int32 >& types );
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > SAL_CALL getConnection( );
+ };
+ }
+}
+
+#endif // INCLUDED_EXAMPLES_DATABASE_DRIVERSKELETON_SDATABASEMETADATA_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/Database/DriverSkeleton/SDriver.cxx b/odk/examples/DevelopersGuide/Database/DriverSkeleton/SDriver.cxx
new file mode 100644
index 000000000..cac95caa9
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Database/DriverSkeleton/SDriver.cxx
@@ -0,0 +1,200 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+#include <cppuhelper/supportsservice.hxx>
+#include "SDriver.hxx"
+#include "SConnection.hxx"
+
+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 connectivity::skeleton;
+
+namespace connectivity
+{
+ namespace skeleton
+ {
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL SkeletonDriver_CreateInstance(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory)
+ {
+ return *(new SkeletonDriver());
+ }
+ }
+}
+
+SkeletonDriver::SkeletonDriver()
+ : ODriver_BASE(m_aMutex)
+{
+}
+
+void SkeletonDriver::disposing()
+{
+ ::osl::MutexGuard aGuard(m_aMutex);
+
+ // when driver will be destroyed so all our connections have to be destroyed as well
+ for (OWeakRefArray::iterator i = m_xConnections.begin(); m_xConnections.end() != i; ++i)
+ {
+ Reference< XComponent > xComp(i->get(), UNO_QUERY);
+ if (xComp.is())
+ xComp->dispose();
+ }
+ m_xConnections.clear();
+
+ ODriver_BASE::disposing();
+}
+
+// static ServiceInfo
+
+rtl::OUString SkeletonDriver::getImplementationName_Static( )
+{
+ return rtl::OUString("com.sun.star.comp.sdbc.SkeletonDriver");
+ // this name is referenced in the configuration and in the skeleton.xml
+ // Please take care when changing it.
+}
+
+Sequence< ::rtl::OUString > SkeletonDriver::getSupportedServiceNames_Static( )
+{
+ /// which service is supported
+ /// for more information @see com.sun.star.sdbc.Driver
+ Sequence< ::rtl::OUString > aSNS( 1 );
+ aSNS[0] = ::rtl::OUString("com.sun.star.sdbc.Driver");
+ return aSNS;
+}
+
+::rtl::OUString SAL_CALL SkeletonDriver::getImplementationName( )
+{
+ return getImplementationName_Static();
+}
+
+sal_Bool SAL_CALL SkeletonDriver::supportsService( const ::rtl::OUString& _rServiceName )
+{
+ return cppu::supportsService(this, _rServiceName);
+}
+
+Sequence< ::rtl::OUString > SAL_CALL SkeletonDriver::getSupportedServiceNames( )
+{
+ return getSupportedServiceNames_Static();
+}
+
+Reference< XConnection > SAL_CALL SkeletonDriver::connect( const ::rtl::OUString& url, const Sequence< PropertyValue >& info )
+{
+ // create a new connection with the given properties and append it to our vector
+ OConnection* pCon = new OConnection(this);
+ Reference< XConnection > xCon = pCon; // important here because otherwise the connection could be deleted inside (refcount goes -> 0)
+ pCon->construct(url,info); // late constructor call which can throw exception and allows a correct dtor call when so
+ m_xConnections.push_back(WeakReferenceHelper(*pCon));
+
+ return xCon;
+}
+
+sal_Bool SAL_CALL SkeletonDriver::acceptsURL( const ::rtl::OUString& url )
+{
+ // here we have to look if we support this url format
+ // change the URL format to your needs, but please aware that the first on who accepts the URl wins.
+ return url.startsWith("sdbc:skeleton:");
+}
+
+Sequence< DriverPropertyInfo > SAL_CALL SkeletonDriver::getPropertyInfo( const ::rtl::OUString& url, const Sequence< PropertyValue >& info )
+{
+ // if you have something special to say, return it here :-)
+ return Sequence< DriverPropertyInfo >();
+}
+
+sal_Int32 SAL_CALL SkeletonDriver::getMajorVersion( )
+{
+ return 0; // depends on you
+}
+
+sal_Int32 SAL_CALL SkeletonDriver::getMinorVersion( )
+{
+ return 1; // depends on you
+}
+
+
+namespace connectivity
+{
+ namespace skeleton
+ {
+
+
+void release(oslInterlockedCount& _refCount,
+ ::cppu::OBroadcastHelper& rBHelper,
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _xInterface,
+ ::com::sun::star::lang::XComponent* _pObject)
+{
+ if (osl_atomic_decrement( &_refCount ) == 0)
+ {
+ osl_atomic_increment( &_refCount );
+
+ if (!rBHelper.bDisposed && !rBHelper.bInDispose)
+ {
+ // remember the parent
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > xParent;
+ {
+ ::osl::MutexGuard aGuard( rBHelper.rMutex );
+ xParent = _xInterface;
+ _xInterface = NULL;
+ }
+
+ // First dispose
+ _pObject->dispose();
+
+ // only the alive ref holds the object
+ OSL_ASSERT( _refCount == 1 );
+
+ // release the parent in the ~
+ if (xParent.is())
+ {
+ ::osl::MutexGuard aGuard( rBHelper.rMutex );
+ _xInterface = xParent;
+ }
+ }
+ }
+ else
+ osl_atomic_increment( &_refCount );
+}
+
+void checkDisposed(sal_Bool _bThrow)
+{
+ if (_bThrow)
+ throw DisposedException();
+
+}
+
+ }
+}
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/Database/DriverSkeleton/SDriver.hxx b/odk/examples/DevelopersGuide/Database/DriverSkeleton/SDriver.hxx
new file mode 100644
index 000000000..099d6cd8d
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Database/DriverSkeleton/SDriver.hxx
@@ -0,0 +1,92 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+#ifndef INCLUDED_EXAMPLES_DATABASE_DRIVERSKELETON_SDRIVER_HXX
+#define INCLUDED_EXAMPLES_DATABASE_DRIVERSKELETON_SDRIVER_HXX
+
+#include <com/sun/star/sdbc/XDriver.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <cppuhelper/compbase2.hxx>
+#include "SConnection.hxx"
+
+namespace com { namespace sun { namespace star { namespace lang {
+ class XMultiServiceFactory;
+} } } }
+
+namespace connectivity
+{
+ namespace skeleton
+ {
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL SkeletonDriver_CreateInstance(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory);
+
+ typedef ::cppu::WeakComponentImplHelper2< ::com::sun::star::sdbc::XDriver,
+ ::com::sun::star::lang::XServiceInfo > ODriver_BASE;
+
+ class SkeletonDriver : public ODriver_BASE
+ {
+ protected:
+ ::osl::Mutex m_aMutex; // mutex is need to control member access
+ OWeakRefArray m_xConnections; // vector containing a list
+ // of all the Connection objects
+ // for this Driver
+ public:
+
+ SkeletonDriver();
+
+ // OComponentHelper
+ virtual void SAL_CALL disposing();
+ // XInterface
+ static ::rtl::OUString getImplementationName_Static( );
+ static ::com::sun::star::uno::Sequence< ::rtl::OUString > getSupportedServiceNames_Static( );
+
+ // XServiceInfo
+ virtual ::rtl::OUString SAL_CALL getImplementationName( );
+ virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName );
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( );
+
+ // XDriver
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > SAL_CALL connect( const ::rtl::OUString& url, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& info );
+ virtual sal_Bool SAL_CALL acceptsURL( const ::rtl::OUString& url );
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::sdbc::DriverPropertyInfo > SAL_CALL getPropertyInfo( const ::rtl::OUString& url, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& info );
+ virtual sal_Int32 SAL_CALL getMajorVersion( );
+ virtual sal_Int32 SAL_CALL getMinorVersion( );
+ };
+ }
+
+}
+
+#endif // INCLUDED_EXAMPLES_DATABASE_DRIVERSKELETON_SDRIVER_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/Database/DriverSkeleton/SPreparedStatement.cxx b/odk/examples/DevelopersGuide/Database/DriverSkeleton/SPreparedStatement.cxx
new file mode 100644
index 000000000..c2c0df340
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Database/DriverSkeleton/SPreparedStatement.cxx
@@ -0,0 +1,385 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+#include <stdio.h>
+#include "SPreparedStatement.hxx"
+#include <com/sun/star/sdbc/DataType.hpp>
+#include "SResultSetMetaData.hxx"
+#include <cppuhelper/typeprovider.hxx>
+#include <com/sun/star/lang/DisposedException.hpp>
+#include "propertyids.hxx"
+
+using namespace connectivity::skeleton;
+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::io;
+using namespace com::sun::star::util;
+
+IMPLEMENT_SERVICE_INFO(OPreparedStatement,"com.sun.star.sdbcx.skeleton.PreparedStatement","com.sun.star.sdbc.PreparedStatement");
+
+
+OPreparedStatement::OPreparedStatement( OConnection* _pConnection,const TTypeInfoVector& _TypeInfo,const ::rtl::OUString& sql)
+ :OStatement_BASE2(_pConnection)
+ ,m_aTypeInfo(_TypeInfo)
+ ,m_bPrepared(sal_False)
+ ,m_sSqlStatement(sql)
+ ,m_nNumParams(0)
+{
+}
+
+OPreparedStatement::~OPreparedStatement()
+{
+}
+
+void SAL_CALL OPreparedStatement::acquire() throw()
+{
+ OStatement_BASE2::acquire();
+}
+
+void SAL_CALL OPreparedStatement::release() throw()
+{
+ OStatement_BASE2::release();
+}
+
+Any SAL_CALL OPreparedStatement::queryInterface( const Type & rType )
+{
+ Any aRet = OStatement_BASE2::queryInterface(rType);
+ if(!aRet.hasValue())
+ aRet = OPreparedStatement_BASE::queryInterface(rType);
+ return aRet;
+}
+
+::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL OPreparedStatement::getTypes( )
+{
+ return concatSequences(OPreparedStatement_BASE::getTypes(),OStatement_BASE2::getTypes());
+}
+
+
+Reference< XResultSetMetaData > SAL_CALL OPreparedStatement::getMetaData( )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OStatement_BASE::rBHelper.bDisposed);
+
+ if(!m_xMetaData.is())
+ m_xMetaData = new OResultSetMetaData(getOwnConnection());
+ return m_xMetaData;
+}
+
+
+void SAL_CALL OPreparedStatement::close( )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OStatement_BASE::rBHelper.bDisposed);
+
+
+ // Reset last warning message
+
+ try {
+ clearWarnings ();
+ OStatement_BASE2::close();
+ }
+ catch (SQLException &) {
+ // If we get an error, ignore
+ }
+
+ // Remove this Statement object from the Connection object's
+ // list
+}
+
+
+sal_Bool SAL_CALL OPreparedStatement::execute( )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OStatement_BASE::rBHelper.bDisposed);
+
+
+ // same as in statement with the difference that this statement also can contain parameter
+ return sal_False;
+}
+
+
+sal_Int32 SAL_CALL OPreparedStatement::executeUpdate( )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OStatement_BASE::rBHelper.bDisposed);
+
+ // same as in statement with the difference that this statement also can contain parameter
+ return 0;
+}
+
+
+void SAL_CALL OPreparedStatement::setString( sal_Int32 parameterIndex, const ::rtl::OUString& x )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OStatement_BASE::rBHelper.bDisposed);
+}
+
+
+Reference< XConnection > SAL_CALL OPreparedStatement::getConnection( )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OStatement_BASE::rBHelper.bDisposed);
+
+ return (Reference< XConnection >)m_pConnection;
+}
+
+
+Reference< XResultSet > SAL_CALL OPreparedStatement::executeQuery( )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OStatement_BASE::rBHelper.bDisposed);
+
+ Reference< XResultSet > rs = NULL;
+
+
+ return rs;
+}
+
+
+void SAL_CALL OPreparedStatement::setBoolean( sal_Int32 parameterIndex, sal_Bool x )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OStatement_BASE::rBHelper.bDisposed);
+
+}
+
+void SAL_CALL OPreparedStatement::setByte( sal_Int32 parameterIndex, sal_Int8 x )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OStatement_BASE::rBHelper.bDisposed);
+
+
+}
+
+
+void SAL_CALL OPreparedStatement::setDate( sal_Int32 parameterIndex, const Date& aData )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OStatement_BASE::rBHelper.bDisposed);
+
+}
+
+
+void SAL_CALL OPreparedStatement::setTime( sal_Int32 parameterIndex, const css::util::Time& aVal )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OStatement_BASE::rBHelper.bDisposed);
+
+}
+
+
+void SAL_CALL OPreparedStatement::setTimestamp( sal_Int32 parameterIndex, const DateTime& aVal )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OStatement_BASE::rBHelper.bDisposed);
+
+}
+
+
+void SAL_CALL OPreparedStatement::setDouble( sal_Int32 parameterIndex, double x )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OStatement_BASE::rBHelper.bDisposed);
+
+}
+
+
+void SAL_CALL OPreparedStatement::setFloat( sal_Int32 parameterIndex, float x )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OStatement_BASE::rBHelper.bDisposed);
+
+}
+
+
+void SAL_CALL OPreparedStatement::setInt( sal_Int32 parameterIndex, sal_Int32 x )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OStatement_BASE::rBHelper.bDisposed);
+
+}
+
+
+void SAL_CALL OPreparedStatement::setLong( sal_Int32 parameterIndex, sal_Int64 aVal )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OStatement_BASE::rBHelper.bDisposed);
+
+}
+
+
+void SAL_CALL OPreparedStatement::setNull( sal_Int32 parameterIndex, sal_Int32 sqlType )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OStatement_BASE::rBHelper.bDisposed);
+
+}
+
+
+void SAL_CALL OPreparedStatement::setClob( sal_Int32 parameterIndex, const Reference< XClob >& x )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OStatement_BASE::rBHelper.bDisposed);
+
+}
+
+
+void SAL_CALL OPreparedStatement::setBlob( sal_Int32 parameterIndex, const Reference< XBlob >& x )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OStatement_BASE::rBHelper.bDisposed);
+
+}
+
+
+void SAL_CALL OPreparedStatement::setArray( sal_Int32 parameterIndex, const Reference< XArray >& x )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OStatement_BASE::rBHelper.bDisposed);
+
+}
+
+
+void SAL_CALL OPreparedStatement::setRef( sal_Int32 parameterIndex, const Reference< XRef >& x )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OStatement_BASE::rBHelper.bDisposed);
+
+}
+
+
+void SAL_CALL OPreparedStatement::setObjectWithInfo( sal_Int32 parameterIndex, const Any& x, sal_Int32 sqlType, sal_Int32 scale )
+{
+ checkDisposed(OStatement_BASE::rBHelper.bDisposed);
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+}
+
+
+void SAL_CALL OPreparedStatement::setObjectNull( sal_Int32 parameterIndex, sal_Int32 sqlType, const ::rtl::OUString& typeName )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OStatement_BASE::rBHelper.bDisposed);
+
+}
+
+
+void SAL_CALL OPreparedStatement::setObject( sal_Int32 parameterIndex, const Any& x )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OStatement_BASE::rBHelper.bDisposed);
+
+}
+
+
+void SAL_CALL OPreparedStatement::setShort( sal_Int32 parameterIndex, sal_Int16 x )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OStatement_BASE::rBHelper.bDisposed);
+
+}
+
+
+void SAL_CALL OPreparedStatement::setBytes( sal_Int32 parameterIndex, const Sequence< sal_Int8 >& x )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OStatement_BASE::rBHelper.bDisposed);
+
+}
+
+
+void SAL_CALL OPreparedStatement::setCharacterStream( sal_Int32 parameterIndex, const Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OStatement_BASE::rBHelper.bDisposed);
+
+}
+
+
+void SAL_CALL OPreparedStatement::setBinaryStream( sal_Int32 parameterIndex, const Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OStatement_BASE::rBHelper.bDisposed);
+
+}
+
+
+void SAL_CALL OPreparedStatement::clearParameters( )
+{
+}
+
+void SAL_CALL OPreparedStatement::clearBatch( )
+{
+}
+
+
+void SAL_CALL OPreparedStatement::addBatch( )
+{
+}
+
+
+Sequence< sal_Int32 > SAL_CALL OPreparedStatement::executeBatch( )
+{
+ return Sequence< sal_Int32 > ();
+}
+
+void OPreparedStatement::setFastPropertyValue_NoBroadcast(sal_Int32 nHandle,const Any& rValue)
+{
+ switch(nHandle)
+ {
+ case PROPERTY_ID_RESULTSETCONCURRENCY:
+ break;
+ case PROPERTY_ID_RESULTSETTYPE:
+ break;
+ case PROPERTY_ID_FETCHDIRECTION:
+ break;
+ case PROPERTY_ID_USEBOOKMARKS:
+ break;
+ default:
+ OStatement_Base::setFastPropertyValue_NoBroadcast(nHandle,rValue);
+ }
+}
+
+void OPreparedStatement::checkParameterIndex(sal_Int32 _parameterIndex)
+{
+ if( !_parameterIndex || _parameterIndex > m_nNumParams)
+ throw SQLException();
+}
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/Database/DriverSkeleton/SPreparedStatement.hxx b/odk/examples/DevelopersGuide/Database/DriverSkeleton/SPreparedStatement.hxx
new file mode 100644
index 000000000..f0a2f205b
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Database/DriverSkeleton/SPreparedStatement.hxx
@@ -0,0 +1,150 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+#ifndef INCLUDED_EXAMPLES_DATABASE_DRIVERSKELETON_SPREPAREDSTATEMENT_HXX
+#define INCLUDED_EXAMPLES_DATABASE_DRIVERSKELETON_SPREPAREDSTATEMENT_HXX
+
+#include "SStatement.hxx"
+#include <com/sun/star/sdbc/XPreparedStatement.hpp>
+#include <com/sun/star/sdbc/XParameters.hpp>
+#include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp>
+#include <com/sun/star/sdbc/XPreparedBatchExecution.hpp>
+#include <com/sun/star/io/XInputStream.hpp>
+
+namespace connectivity
+{
+ namespace skeleton
+ {
+
+ class OBoundParam;
+ typedef ::cppu::ImplHelper5< ::com::sun::star::sdbc::XPreparedStatement,
+ ::com::sun::star::sdbc::XParameters,
+ ::com::sun::star::sdbc::XPreparedBatchExecution,
+ ::com::sun::star::sdbc::XResultSetMetaDataSupplier,
+ ::com::sun::star::lang::XServiceInfo> OPreparedStatement_BASE;
+
+ class OPreparedStatement : public OStatement_BASE2,
+ public OPreparedStatement_BASE
+ {
+ protected:
+ struct Parameter
+ {
+ ::com::sun::star::uno::Any aValue;
+ sal_Int32 nDataType;
+
+ Parameter(const ::com::sun::star::uno::Any& rValue,
+ sal_Int32 rDataType) : aValue(rValue),nDataType(rDataType)
+ {
+ }
+
+ };
+
+ ::std::vector< Parameter> m_aParameters;
+
+ // Data attributes
+
+ TTypeInfoVector m_aTypeInfo; // Hashtable containing an entry
+ // for each row returned by
+ // DatabaseMetaData.getTypeInfo.
+
+ sal_Int32 m_nNumParams; // Number of parameter markers
+ // for the prepared statement
+
+ ::rtl::OUString m_sSqlStatement;
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSetMetaData > m_xMetaData;
+ sal_Bool m_bPrepared;
+
+ void checkParameterIndex(sal_Int32 _parameterIndex);
+
+ protected:
+ virtual void SAL_CALL setFastPropertyValue_NoBroadcast(sal_Int32 nHandle,
+ const ::com::sun::star::uno::Any& rValue);
+ virtual ~OPreparedStatement();
+ public:
+ DECLARE_SERVICE_INFO();
+ // a constructor, which is required for returning objects:
+ OPreparedStatement( OConnection* _pConnection,const TTypeInfoVector& _TypeInfo,const ::rtl::OUString& sql);
+
+ //XInterface
+ virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType );
+ 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( );
+
+ // XPreparedStatement
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL executeQuery( );
+ virtual sal_Int32 SAL_CALL executeUpdate( );
+ virtual sal_Bool SAL_CALL execute( );
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > SAL_CALL getConnection( );
+ // XParameters
+ virtual void SAL_CALL setNull( sal_Int32 parameterIndex, sal_Int32 sqlType );
+ virtual void SAL_CALL setObjectNull( sal_Int32 parameterIndex, sal_Int32 sqlType, const ::rtl::OUString& typeName );
+ virtual void SAL_CALL setBoolean( sal_Int32 parameterIndex, sal_Bool x );
+ virtual void SAL_CALL setByte( sal_Int32 parameterIndex, sal_Int8 x );
+ virtual void SAL_CALL setShort( sal_Int32 parameterIndex, sal_Int16 x );
+ virtual void SAL_CALL setInt( sal_Int32 parameterIndex, sal_Int32 x );
+ virtual void SAL_CALL setLong( sal_Int32 parameterIndex, sal_Int64 x );
+ virtual void SAL_CALL setFloat( sal_Int32 parameterIndex, float x );
+ virtual void SAL_CALL setDouble( sal_Int32 parameterIndex, double x );
+ virtual void SAL_CALL setString( sal_Int32 parameterIndex, const ::rtl::OUString& x );
+ virtual void SAL_CALL setBytes( sal_Int32 parameterIndex, const ::com::sun::star::uno::Sequence< sal_Int8 >& x );
+ virtual void SAL_CALL setDate( sal_Int32 parameterIndex, const ::com::sun::star::util::Date& x );
+ virtual void SAL_CALL setTime( sal_Int32 parameterIndex, const ::com::sun::star::util::Time& x );
+ virtual void SAL_CALL setTimestamp( sal_Int32 parameterIndex, const ::com::sun::star::util::DateTime& x );
+ virtual void SAL_CALL setBinaryStream( sal_Int32 parameterIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length );
+ virtual void SAL_CALL setCharacterStream( sal_Int32 parameterIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length );
+ virtual void SAL_CALL setObject( sal_Int32 parameterIndex, const ::com::sun::star::uno::Any& x );
+ virtual void SAL_CALL setObjectWithInfo( sal_Int32 parameterIndex, const ::com::sun::star::uno::Any& x, sal_Int32 targetSqlType, sal_Int32 scale );
+ virtual void SAL_CALL setRef( sal_Int32 parameterIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRef >& x );
+ virtual void SAL_CALL setBlob( sal_Int32 parameterIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XBlob >& x );
+ virtual void SAL_CALL setClob( sal_Int32 parameterIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XClob >& x );
+ virtual void SAL_CALL setArray( sal_Int32 parameterIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XArray >& x );
+ virtual void SAL_CALL clearParameters( );
+ // XPreparedBatchExecution
+ virtual void SAL_CALL addBatch( );
+ virtual void SAL_CALL clearBatch( );
+ virtual ::com::sun::star::uno::Sequence< sal_Int32 > SAL_CALL executeBatch( );
+ // XCloseable
+ virtual void SAL_CALL close( );
+ // XResultSetMetaDataSupplier
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSetMetaData > SAL_CALL getMetaData( );
+ };
+ }
+}
+
+#endif // INCLUDED_EXAMPLES_DATABASE_DRIVERSKELETON_SPREPAREDSTATEMENT_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/Database/DriverSkeleton/SResultSet.cxx b/odk/examples/DevelopersGuide/Database/DriverSkeleton/SResultSet.cxx
new file mode 100644
index 000000000..97bcca3b7
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Database/DriverSkeleton/SResultSet.cxx
@@ -0,0 +1,867 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+#include "SResultSet.hxx"
+#include "SResultSetMetaData.hxx"
+#include <com/sun/star/sdbc/DataType.hpp>
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+#include <com/sun/star/sdbcx/CompareBookmark.hpp>
+#include <cppuhelper/typeprovider.hxx>
+#include <cppuhelper/supportsservice.hxx>
+#include <com/sun/star/lang/DisposedException.hpp>
+#include "propertyids.hxx"
+
+using namespace connectivity::skeleton;
+using namespace cppu;
+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::io;
+using namespace com::sun::star::util;
+
+// IMPLEMENT_SERVICE_INFO(OResultSet,"com.sun.star.sdbcx.OResultSet","com.sun.star.sdbc.ResultSet");
+::rtl::OUString SAL_CALL OResultSet::getImplementationName( )
+{
+ return ::rtl::OUString("com.sun.star.sdbcx.skeleton.ResultSet");
+}
+
+ Sequence< ::rtl::OUString > SAL_CALL OResultSet::getSupportedServiceNames( )
+{
+ Sequence< ::rtl::OUString > aSupported(2);
+ aSupported[0] = ::rtl::OUString("com.sun.star.sdbc.ResultSet");
+ aSupported[1] = ::rtl::OUString("com.sun.star.sdbcx.ResultSet");
+ return aSupported;
+}
+
+sal_Bool SAL_CALL OResultSet::supportsService( const ::rtl::OUString& _rServiceName )
+{
+ return cppu::supportsService(this, _rServiceName);
+}
+
+OResultSet::OResultSet(OStatement_Base* pStmt)
+ : OResultSet_BASE(m_aMutex)
+ ,OPropertySetHelper(OResultSet_BASE::rBHelper)
+ ,m_aStatement((OWeakObject*)pStmt)
+ ,m_xMetaData(NULL)
+ ,m_nTextEncoding(pStmt->getOwnConnection()->getTextEncoding())
+ ,m_pStatement(pStmt)
+ ,m_bWasNull(sal_True)
+{
+}
+
+OResultSet::~OResultSet()
+{
+}
+
+void OResultSet::disposing()
+{
+ OPropertySetHelper::disposing();
+
+ ::osl::MutexGuard aGuard(m_aMutex);
+
+ m_aStatement = NULL;
+ m_xMetaData = NULL;
+}
+
+Any SAL_CALL OResultSet::queryInterface( const Type & rType )
+{
+ Any aRet = OPropertySetHelper::queryInterface(rType);
+ if(!aRet.hasValue())
+ aRet = OResultSet_BASE::queryInterface(rType);
+ return aRet;
+}
+
+ Sequence< Type > SAL_CALL OResultSet::getTypes( )
+{
+ OTypeCollection aTypes(
+ ::cppu::UnoType<css::beans::XMultiPropertySet>::get(),
+ ::cppu::UnoType<css::beans::XFastPropertySet>::get(),
+ ::cppu::UnoType<css::beans::XPropertySet>::get());
+
+ return concatSequences(aTypes.getTypes(),OResultSet_BASE::getTypes());
+}
+
+
+sal_Int32 SAL_CALL OResultSet::findColumn( const ::rtl::OUString& columnName )
+{
+
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+ // find the first column with the name columnName
+
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ Reference< XResultSetMetaData > xMeta = getMetaData();
+ sal_Int32 nLen = xMeta->getColumnCount();
+ sal_Int32 i = 1;
+ for(;i<=nLen;++i)
+ if(xMeta->isCaseSensitive(i) ? columnName == xMeta->getColumnName(i) :
+ columnName.equalsIgnoreAsciiCase(xMeta->getColumnName(i)))
+ break;
+ return i;
+}
+
+Reference< XInputStream > SAL_CALL OResultSet::getBinaryStream( sal_Int32 columnIndex )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+
+ return NULL;
+}
+
+Reference< XInputStream > SAL_CALL OResultSet::getCharacterStream( sal_Int32 columnIndex )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+
+ return NULL;
+}
+
+
+sal_Bool SAL_CALL OResultSet::getBoolean( sal_Int32 columnIndex )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+ return sal_False;
+}
+
+
+sal_Int8 SAL_CALL OResultSet::getByte( sal_Int32 columnIndex )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+
+ sal_Int8 nRet = 0;
+ return nRet;
+}
+
+
+Sequence< sal_Int8 > SAL_CALL OResultSet::getBytes( sal_Int32 columnIndex )
+{
+
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ return Sequence< sal_Int8 >();
+}
+
+
+Date SAL_CALL OResultSet::getDate( sal_Int32 columnIndex )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+
+ Date nRet;
+ return nRet;
+}
+
+
+double SAL_CALL OResultSet::getDouble( sal_Int32 columnIndex )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+
+ double nRet = 0;
+ return nRet;
+}
+
+
+float SAL_CALL OResultSet::getFloat( sal_Int32 columnIndex )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+
+ float nVal(0);
+ return nVal;
+}
+
+
+sal_Int32 SAL_CALL OResultSet::getInt( sal_Int32 columnIndex )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+ sal_Int32 nRet=0;
+ return nRet;
+}
+
+
+sal_Int32 SAL_CALL OResultSet::getRow( )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+ sal_Int32 nValue = 0;
+ return nValue;
+}
+
+
+sal_Int64 SAL_CALL OResultSet::getLong( sal_Int32 columnIndex )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+ return sal_Int64();
+}
+
+
+Reference< XResultSetMetaData > SAL_CALL OResultSet::getMetaData( )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+
+ if(!m_xMetaData.is())
+ m_xMetaData = new OResultSetMetaData(m_pStatement->getOwnConnection());
+ return m_xMetaData;
+}
+
+Reference< XArray > SAL_CALL OResultSet::getArray( sal_Int32 columnIndex )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+ return NULL;
+}
+
+
+Reference< XClob > SAL_CALL OResultSet::getClob( sal_Int32 columnIndex )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+ return NULL;
+}
+
+Reference< XBlob > SAL_CALL OResultSet::getBlob( sal_Int32 columnIndex )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+ return NULL;
+}
+
+
+Reference< XRef > SAL_CALL OResultSet::getRef( sal_Int32 columnIndex )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+ return NULL;
+}
+
+
+Any SAL_CALL OResultSet::getObject( sal_Int32 columnIndex, const Reference< ::com::sun::star::container::XNameAccess >& typeMap )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+ return Any();
+}
+
+
+sal_Int16 SAL_CALL OResultSet::getShort( sal_Int32 columnIndex )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+
+ sal_Int16 nRet=0;
+ return nRet;
+}
+
+
+::rtl::OUString SAL_CALL OResultSet::getString( sal_Int32 columnIndex )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+
+ ::rtl::OUString nRet;
+ return nRet;
+}
+
+
+css::util::Time SAL_CALL OResultSet::getTime( sal_Int32 columnIndex )
+{
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ css::util::Time nRet;
+ return nRet;
+}
+
+
+DateTime SAL_CALL OResultSet::getTimestamp( sal_Int32 columnIndex )
+{
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ DateTime nRet;
+ return nRet;
+}
+
+
+sal_Bool SAL_CALL OResultSet::isBeforeFirst( )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+
+ // here you have to implement your movements
+ // return true means there is no data
+ return sal_True;
+}
+
+sal_Bool SAL_CALL OResultSet::isAfterLast( )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+ return sal_True;
+}
+
+sal_Bool SAL_CALL OResultSet::isFirst( )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+
+ return sal_False;
+}
+
+sal_Bool SAL_CALL OResultSet::isLast( )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+
+ return sal_False;
+}
+
+void SAL_CALL OResultSet::beforeFirst( )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+ // move before the first row so that isBeforeFirst returns false
+ // the same for other movement methods
+}
+
+void SAL_CALL OResultSet::afterLast( )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+}
+
+
+void SAL_CALL OResultSet::close( )
+{
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+ }
+ dispose();
+}
+
+
+sal_Bool SAL_CALL OResultSet::first( )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+ return sal_False;
+}
+
+
+sal_Bool SAL_CALL OResultSet::last( )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+ return sal_False;
+}
+
+sal_Bool SAL_CALL OResultSet::absolute( sal_Int32 row )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+ return sal_False;
+}
+
+sal_Bool SAL_CALL OResultSet::relative( sal_Int32 row )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+ return sal_False;
+}
+
+sal_Bool SAL_CALL OResultSet::previous( )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+ return sal_False;
+}
+
+Reference< XInterface > SAL_CALL OResultSet::getStatement( )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+
+ return m_aStatement.get();
+}
+
+
+sal_Bool SAL_CALL OResultSet::rowDeleted( )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+
+ return sal_False;
+}
+
+sal_Bool SAL_CALL OResultSet::rowInserted( )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+
+ return sal_False;
+}
+
+sal_Bool SAL_CALL OResultSet::rowUpdated( )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+
+ return sal_False;
+}
+
+
+sal_Bool SAL_CALL OResultSet::next( )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+
+ return sal_False;
+}
+
+
+sal_Bool SAL_CALL OResultSet::wasNull( )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+
+ return m_bWasNull;
+}
+
+
+void SAL_CALL OResultSet::cancel( )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+}
+
+void SAL_CALL OResultSet::clearWarnings( )
+{
+}
+
+Any SAL_CALL OResultSet::getWarnings( )
+{
+ return Any();
+}
+
+void SAL_CALL OResultSet::insertRow( )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+ // you only have to implement this if you want to insert new rows
+}
+
+void SAL_CALL OResultSet::updateRow( )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+
+ // only when you allow updates
+}
+
+void SAL_CALL OResultSet::deleteRow( )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+}
+
+
+void SAL_CALL OResultSet::cancelRowUpdates( )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+}
+
+
+void SAL_CALL OResultSet::moveToInsertRow( )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+
+ // only when you allow insert's
+}
+
+
+void SAL_CALL OResultSet::moveToCurrentRow( )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+}
+
+
+void SAL_CALL OResultSet::updateNull( sal_Int32 columnIndex )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+}
+
+
+void SAL_CALL OResultSet::updateBoolean( sal_Int32 columnIndex, sal_Bool x )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+}
+
+void SAL_CALL OResultSet::updateByte( sal_Int32 columnIndex, sal_Int8 x )
+{
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+}
+
+
+void SAL_CALL OResultSet::updateShort( sal_Int32 columnIndex, sal_Int16 x )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+}
+
+void SAL_CALL OResultSet::updateInt( sal_Int32 columnIndex, sal_Int32 x )
+{
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+}
+
+void SAL_CALL OResultSet::updateLong( sal_Int32 columnIndex, sal_Int64 x )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+}
+
+void SAL_CALL OResultSet::updateFloat( sal_Int32 columnIndex, float x )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+}
+
+
+void SAL_CALL OResultSet::updateDouble( sal_Int32 columnIndex, double x )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+}
+
+void SAL_CALL OResultSet::updateString( sal_Int32 columnIndex, const ::rtl::OUString& x )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+}
+
+void SAL_CALL OResultSet::updateBytes( sal_Int32 columnIndex, const Sequence< sal_Int8 >& x )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+}
+
+void SAL_CALL OResultSet::updateDate( sal_Int32 columnIndex, const Date& x )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+}
+
+
+void SAL_CALL OResultSet::updateTime( sal_Int32 columnIndex, const css::util::Time& x )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+}
+
+
+void SAL_CALL OResultSet::updateTimestamp( sal_Int32 columnIndex, const DateTime& x )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+}
+
+
+void SAL_CALL OResultSet::updateBinaryStream( sal_Int32 columnIndex, const Reference< XInputStream >& x, sal_Int32 length )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+}
+
+void SAL_CALL OResultSet::updateCharacterStream( sal_Int32 columnIndex, const Reference< XInputStream >& x, sal_Int32 length )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+}
+
+void SAL_CALL OResultSet::refreshRow( )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+}
+
+void SAL_CALL OResultSet::updateObject( sal_Int32 columnIndex, const Any& x )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+}
+
+
+void SAL_CALL OResultSet::updateNumericObject( sal_Int32 columnIndex, const Any& x, sal_Int32 scale )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+}
+
+// XRowLocate
+Any SAL_CALL OResultSet::getBookmark( )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+ // if you don't want to support bookmark you must remove the XRowLocate interface
+
+ return Any();
+}
+
+sal_Bool SAL_CALL OResultSet::moveToBookmark( const Any& bookmark )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+ return sal_False;
+}
+
+sal_Bool SAL_CALL OResultSet::moveRelativeToBookmark( const Any& bookmark, sal_Int32 rows )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+ return sal_False;
+}
+
+sal_Int32 SAL_CALL OResultSet::compareBookmarks( const Any& first, const Any& second )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+
+ return CompareBookmark::NOT_EQUAL;
+}
+
+sal_Bool SAL_CALL OResultSet::hasOrderedBookmarks( )
+{
+ return sal_False;
+}
+
+sal_Int32 SAL_CALL OResultSet::hashBookmark( const Any& bookmark )
+{
+ throw SQLException();
+}
+
+// XDeleteRows
+Sequence< sal_Int32 > SAL_CALL OResultSet::deleteRows( const Sequence< Any >& rows )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+ return Sequence< sal_Int32 >();
+}
+
+IPropertyArrayHelper* OResultSet::createArrayHelper( ) const
+{
+ Sequence< Property > aProps(6);
+ Property* pProperties = aProps.getArray();
+ sal_Int32 nPos = 0;
+ pProperties[nPos++] = ::com::sun::star::beans::Property(OPropertyMap::getPropMap().getNameByIndex(PROPERTY_ID_CURSORNAME),
+ PROPERTY_ID_CURSORNAME, ::cppu::UnoType<rtl::OUString>::get(), PropertyAttribute::READONLY);
+ pProperties[nPos++] = ::com::sun::star::beans::Property(OPropertyMap::getPropMap().getNameByIndex(PROPERTY_ID_FETCHDIRECTION),
+ PROPERTY_ID_FETCHDIRECTION, ::cppu::UnoType<sal_Int32>::get(), 0);
+ pProperties[nPos++] = ::com::sun::star::beans::Property(OPropertyMap::getPropMap().getNameByIndex(PROPERTY_ID_FETCHSIZE),
+ PROPERTY_ID_FETCHSIZE, ::cppu::UnoType<sal_Int32>::get(), 0);
+ pProperties[nPos++] = ::com::sun::star::beans::Property(OPropertyMap::getPropMap().getNameByIndex(PROPERTY_ID_ISBOOKMARKABLE),
+ PROPERTY_ID_ISBOOKMARKABLE, cppu::UnoType<bool>::get(), PropertyAttribute::READONLY);
+ pProperties[nPos++] = ::com::sun::star::beans::Property(OPropertyMap::getPropMap().getNameByIndex(PROPERTY_ID_RESULTSETCONCURRENCY),
+ PROPERTY_ID_RESULTSETCONCURRENCY, ::cppu::UnoType<sal_Int32>::get(), PropertyAttribute::READONLY);
+ pProperties[nPos++] = ::com::sun::star::beans::Property(OPropertyMap::getPropMap().getNameByIndex(PROPERTY_ID_RESULTSETTYPE),
+ PROPERTY_ID_RESULTSETTYPE, ::cppu::UnoType<sal_Int32>::get(), PropertyAttribute::READONLY);
+
+ return new OPropertyArrayHelper(aProps);
+}
+
+IPropertyArrayHelper & OResultSet::getInfoHelper()
+{
+ return *const_cast<OResultSet*>(this)->getArrayHelper();
+}
+
+sal_Bool OResultSet::convertFastPropertyValue(
+ Any & rConvertedValue,
+ Any & rOldValue,
+ sal_Int32 nHandle,
+ const Any& rValue )
+{
+ switch(nHandle)
+ {
+ case PROPERTY_ID_ISBOOKMARKABLE:
+ case PROPERTY_ID_CURSORNAME:
+ case PROPERTY_ID_RESULTSETCONCURRENCY:
+ case PROPERTY_ID_RESULTSETTYPE:
+ throw ::com::sun::star::lang::IllegalArgumentException();
+ break;
+ case PROPERTY_ID_FETCHDIRECTION:
+ case PROPERTY_ID_FETCHSIZE:
+ default:
+ ;
+ }
+ return sal_False;
+}
+
+void OResultSet::setFastPropertyValue_NoBroadcast(
+ sal_Int32 nHandle,
+ const Any& rValue
+ )
+{
+ switch(nHandle)
+ {
+ case PROPERTY_ID_ISBOOKMARKABLE:
+ case PROPERTY_ID_CURSORNAME:
+ case PROPERTY_ID_RESULTSETCONCURRENCY:
+ case PROPERTY_ID_RESULTSETTYPE:
+ throw Exception();
+ break;
+ case PROPERTY_ID_FETCHDIRECTION:
+ break;
+ case PROPERTY_ID_FETCHSIZE:
+ break;
+ default:
+ ;
+ }
+}
+
+void OResultSet::getFastPropertyValue(
+ Any& rValue,
+ sal_Int32 nHandle
+ ) const
+{
+ switch(nHandle)
+ {
+ case PROPERTY_ID_ISBOOKMARKABLE:
+ case PROPERTY_ID_CURSORNAME:
+ case PROPERTY_ID_RESULTSETCONCURRENCY:
+ case PROPERTY_ID_RESULTSETTYPE:
+ case PROPERTY_ID_FETCHDIRECTION:
+ case PROPERTY_ID_FETCHSIZE:
+ ;
+ }
+}
+
+void SAL_CALL OResultSet::acquire() throw()
+{
+ OResultSet_BASE::acquire();
+}
+
+void SAL_CALL OResultSet::release() throw()
+{
+ OResultSet_BASE::release();
+}
+
+::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL OResultSet::getPropertySetInfo( )
+{
+ return ::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper());
+}
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/Database/DriverSkeleton/SResultSet.hxx b/odk/examples/DevelopersGuide/Database/DriverSkeleton/SResultSet.hxx
new file mode 100644
index 000000000..a0fba2b44
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Database/DriverSkeleton/SResultSet.hxx
@@ -0,0 +1,220 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+#ifndef INCLUDED_EXAMPLES_DATABASE_DRIVERSKELETON_SRESULTSET_HXX
+#define INCLUDED_EXAMPLES_DATABASE_DRIVERSKELETON_SRESULTSET_HXX
+
+#include <com/sun/star/sdbc/XResultSet.hpp>
+#include <com/sun/star/sdbc/XRow.hpp>
+#include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp>
+#include <com/sun/star/sdbc/XCloseable.hpp>
+#include <com/sun/star/sdbc/XColumnLocate.hpp>
+#include <com/sun/star/util/XCancellable.hpp>
+#include <com/sun/star/sdbc/XWarningsSupplier.hpp>
+#include <com/sun/star/sdbc/XResultSetUpdate.hpp>
+#include <com/sun/star/sdbc/XRowUpdate.hpp>
+#include <com/sun/star/sdbcx/XRowLocate.hpp>
+#include <com/sun/star/sdbcx/XDeleteRows.hpp>
+#include <cppuhelper/compbase12.hxx>
+#include "SStatement.hxx"
+#include "OSubComponent.hxx"
+
+namespace connectivity
+{
+ namespace skeleton
+ {
+
+ /*
+ ** OResultSet
+ */
+ typedef ::cppu::WeakComponentImplHelper12< ::com::sun::star::sdbc::XResultSet,
+ ::com::sun::star::sdbc::XRow,
+ ::com::sun::star::sdbc::XResultSetMetaDataSupplier,
+ ::com::sun::star::util::XCancellable,
+ ::com::sun::star::sdbc::XWarningsSupplier,
+ ::com::sun::star::sdbc::XResultSetUpdate,
+ ::com::sun::star::sdbc::XRowUpdate,
+ ::com::sun::star::sdbcx::XRowLocate,
+ ::com::sun::star::sdbcx::XDeleteRows,
+ ::com::sun::star::sdbc::XCloseable,
+ ::com::sun::star::sdbc::XColumnLocate,
+ ::com::sun::star::lang::XServiceInfo> OResultSet_BASE;
+
+ class OResultSet : public OBase_Mutex,
+ public OResultSet_BASE,
+ public ::cppu::OPropertySetHelper,
+ public OPropertyArrayUsageHelper<OResultSet>
+ {
+ protected:
+ OStatement_Base* m_pStatement;
+ ::com::sun::star::uno::WeakReferenceHelper m_aStatement;
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSetMetaData> m_xMetaData;
+ rtl_TextEncoding m_nTextEncoding;
+ sal_Bool m_bWasNull;
+
+ // OPropertyArrayUsageHelper
+ virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const;
+ // OPropertySetHelper
+ 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 );
+ virtual void SAL_CALL setFastPropertyValue_NoBroadcast(
+ sal_Int32 nHandle,
+ const ::com::sun::star::uno::Any& rValue
+ );
+ virtual void SAL_CALL getFastPropertyValue(
+ ::com::sun::star::uno::Any& rValue,
+ sal_Int32 nHandle
+ ) const;
+
+ // you can't delete objects of this type
+ virtual ~OResultSet();
+ public:
+ DECLARE_SERVICE_INFO();
+
+ OResultSet( OStatement_Base* pStmt);
+
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > operator *()
+ {
+ return ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >(*(OResultSet_BASE*)this);
+ }
+
+ // ::cppu::OComponentHelper
+ virtual void SAL_CALL disposing();
+ // XInterface
+ virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType );
+ 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( );
+ // XPropertySet
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( );
+ // XResultSet
+ virtual sal_Bool SAL_CALL next( );
+ virtual sal_Bool SAL_CALL isBeforeFirst( );
+ virtual sal_Bool SAL_CALL isAfterLast( );
+ virtual sal_Bool SAL_CALL isFirst( );
+ virtual sal_Bool SAL_CALL isLast( );
+ virtual void SAL_CALL beforeFirst( );
+ virtual void SAL_CALL afterLast( );
+ virtual sal_Bool SAL_CALL first( );
+ virtual sal_Bool SAL_CALL last( );
+ virtual sal_Int32 SAL_CALL getRow( );
+ virtual sal_Bool SAL_CALL absolute( sal_Int32 row );
+ virtual sal_Bool SAL_CALL relative( sal_Int32 rows );
+ virtual sal_Bool SAL_CALL previous( );
+ virtual void SAL_CALL refreshRow( );
+ virtual sal_Bool SAL_CALL rowUpdated( );
+ virtual sal_Bool SAL_CALL rowInserted( );
+ virtual sal_Bool SAL_CALL rowDeleted( );
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL getStatement( );
+ // XRow
+ virtual sal_Bool SAL_CALL wasNull( );
+ virtual ::rtl::OUString SAL_CALL getString( sal_Int32 columnIndex );
+ virtual sal_Bool SAL_CALL getBoolean( sal_Int32 columnIndex );
+ virtual sal_Int8 SAL_CALL getByte( sal_Int32 columnIndex );
+ virtual sal_Int16 SAL_CALL getShort( sal_Int32 columnIndex );
+ virtual sal_Int32 SAL_CALL getInt( sal_Int32 columnIndex );
+ virtual sal_Int64 SAL_CALL getLong( sal_Int32 columnIndex );
+ virtual float SAL_CALL getFloat( sal_Int32 columnIndex );
+ virtual double SAL_CALL getDouble( sal_Int32 columnIndex );
+ virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getBytes( sal_Int32 columnIndex );
+ virtual ::com::sun::star::util::Date SAL_CALL getDate( sal_Int32 columnIndex );
+ virtual ::com::sun::star::util::Time SAL_CALL getTime( sal_Int32 columnIndex );
+ virtual ::com::sun::star::util::DateTime SAL_CALL getTimestamp( sal_Int32 columnIndex );
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > SAL_CALL getBinaryStream( sal_Int32 columnIndex );
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > SAL_CALL getCharacterStream( sal_Int32 columnIndex );
+ virtual ::com::sun::star::uno::Any SAL_CALL getObject( sal_Int32 columnIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& typeMap );
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRef > SAL_CALL getRef( sal_Int32 columnIndex );
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XBlob > SAL_CALL getBlob( sal_Int32 columnIndex );
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XClob > SAL_CALL getClob( sal_Int32 columnIndex );
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XArray > SAL_CALL getArray( sal_Int32 columnIndex );
+ // XResultSetMetaDataSupplier
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSetMetaData > SAL_CALL getMetaData( );
+ // XCancellable
+ virtual void SAL_CALL cancel( );
+ // XCloseable
+ virtual void SAL_CALL close( );
+ // XWarningsSupplier
+ virtual ::com::sun::star::uno::Any SAL_CALL getWarnings( );
+ virtual void SAL_CALL clearWarnings( );
+ // XResultSetUpdate
+ virtual void SAL_CALL insertRow( );
+ virtual void SAL_CALL updateRow( );
+ virtual void SAL_CALL deleteRow( );
+ virtual void SAL_CALL cancelRowUpdates( );
+ virtual void SAL_CALL moveToInsertRow( );
+ virtual void SAL_CALL moveToCurrentRow( );
+ // XRowUpdate
+ virtual void SAL_CALL updateNull( sal_Int32 columnIndex );
+ virtual void SAL_CALL updateBoolean( sal_Int32 columnIndex, sal_Bool x );
+ virtual void SAL_CALL updateByte( sal_Int32 columnIndex, sal_Int8 x );
+ virtual void SAL_CALL updateShort( sal_Int32 columnIndex, sal_Int16 x );
+ virtual void SAL_CALL updateInt( sal_Int32 columnIndex, sal_Int32 x );
+ virtual void SAL_CALL updateLong( sal_Int32 columnIndex, sal_Int64 x );
+ virtual void SAL_CALL updateFloat( sal_Int32 columnIndex, float x );
+ virtual void SAL_CALL updateDouble( sal_Int32 columnIndex, double x );
+ virtual void SAL_CALL updateString( sal_Int32 columnIndex, const ::rtl::OUString& x );
+ virtual void SAL_CALL updateBytes( sal_Int32 columnIndex, const ::com::sun::star::uno::Sequence< sal_Int8 >& x );
+ virtual void SAL_CALL updateDate( sal_Int32 columnIndex, const ::com::sun::star::util::Date& x );
+ virtual void SAL_CALL updateTime( sal_Int32 columnIndex, const ::com::sun::star::util::Time& x );
+ virtual void SAL_CALL updateTimestamp( sal_Int32 columnIndex, const ::com::sun::star::util::DateTime& x );
+ virtual void SAL_CALL updateBinaryStream( sal_Int32 columnIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length );
+ virtual void SAL_CALL updateCharacterStream( sal_Int32 columnIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length );
+ virtual void SAL_CALL updateObject( sal_Int32 columnIndex, const ::com::sun::star::uno::Any& x );
+ virtual void SAL_CALL updateNumericObject( sal_Int32 columnIndex, const ::com::sun::star::uno::Any& x, sal_Int32 scale );
+ // XColumnLocate
+ virtual sal_Int32 SAL_CALL findColumn( const ::rtl::OUString& columnName );
+ // XRowLocate
+ virtual ::com::sun::star::uno::Any SAL_CALL getBookmark( );
+ virtual sal_Bool SAL_CALL moveToBookmark( const ::com::sun::star::uno::Any& bookmark );
+ virtual sal_Bool SAL_CALL moveRelativeToBookmark( const ::com::sun::star::uno::Any& bookmark, sal_Int32 rows );
+ virtual sal_Int32 SAL_CALL compareBookmarks( const ::com::sun::star::uno::Any& first, const ::com::sun::star::uno::Any& second );
+ virtual sal_Bool SAL_CALL hasOrderedBookmarks( );
+ virtual sal_Int32 SAL_CALL hashBookmark( const ::com::sun::star::uno::Any& bookmark );
+ // XDeleteRows
+ virtual ::com::sun::star::uno::Sequence< sal_Int32 > SAL_CALL deleteRows( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& rows );
+ };
+ }
+}
+
+#endif // INCLUDED_EXAMPLES_DATABASE_DRIVERSKELETON_SRESULTSET_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/Database/DriverSkeleton/SResultSetMetaData.cxx b/odk/examples/DevelopersGuide/Database/DriverSkeleton/SResultSetMetaData.cxx
new file mode 100644
index 000000000..32e8dc0f4
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Database/DriverSkeleton/SResultSetMetaData.cxx
@@ -0,0 +1,170 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+#include "SResultSetMetaData.hxx"
+
+using namespace connectivity::skeleton;
+using namespace com::sun::star::uno;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::sdbc;
+
+
+OResultSetMetaData::~OResultSetMetaData()
+{
+}
+
+
+sal_Int32 SAL_CALL OResultSetMetaData::getColumnDisplaySize( sal_Int32 column )
+{
+ return 50;
+}
+
+
+sal_Int32 SAL_CALL OResultSetMetaData::getColumnType( sal_Int32 column )
+{
+ sal_Int32 nType = 0;
+ return nType;
+}
+
+
+sal_Int32 SAL_CALL OResultSetMetaData::getColumnCount( )
+{
+ // this makes no sense here so you have to change this
+ return 0;
+}
+
+
+sal_Bool SAL_CALL OResultSetMetaData::isCaseSensitive( sal_Int32 column )
+{
+ return sal_True;
+}
+
+
+::rtl::OUString SAL_CALL OResultSetMetaData::getSchemaName( sal_Int32 column )
+{
+ return ::rtl::OUString();
+}
+
+
+::rtl::OUString SAL_CALL OResultSetMetaData::getColumnName( sal_Int32 column )
+{
+ return ::rtl::OUString("Column") + ::rtl::OUString::number(column);
+}
+
+::rtl::OUString SAL_CALL OResultSetMetaData::getTableName( sal_Int32 column )
+{
+ return ::rtl::OUString();
+}
+
+::rtl::OUString SAL_CALL OResultSetMetaData::getCatalogName( sal_Int32 column )
+{
+ return ::rtl::OUString();
+}
+
+::rtl::OUString SAL_CALL OResultSetMetaData::getColumnTypeName( sal_Int32 column )
+{
+ return ::rtl::OUString();
+}
+
+::rtl::OUString SAL_CALL OResultSetMetaData::getColumnLabel( sal_Int32 column )
+{
+ return ::rtl::OUString();
+}
+
+::rtl::OUString SAL_CALL OResultSetMetaData::getColumnServiceName( sal_Int32 column )
+{
+ return ::rtl::OUString();
+}
+
+
+sal_Bool SAL_CALL OResultSetMetaData::isCurrency( sal_Int32 column )
+{
+ return sal_False;
+}
+
+
+sal_Bool SAL_CALL OResultSetMetaData::isAutoIncrement( sal_Int32 column )
+{
+ return sal_False;
+}
+
+
+sal_Bool SAL_CALL OResultSetMetaData::isSigned( sal_Int32 column )
+{
+ return sal_False;
+}
+
+sal_Int32 SAL_CALL OResultSetMetaData::getPrecision( sal_Int32 column )
+{
+ return 0;
+}
+
+sal_Int32 SAL_CALL OResultSetMetaData::getScale( sal_Int32 column )
+{
+ return 0;
+}
+
+
+sal_Int32 SAL_CALL OResultSetMetaData::isNullable( sal_Int32 column )
+{
+ return 0;
+}
+
+
+sal_Bool SAL_CALL OResultSetMetaData::isSearchable( sal_Int32 column )
+{
+ return sal_True;
+}
+
+
+sal_Bool SAL_CALL OResultSetMetaData::isReadOnly( sal_Int32 column )
+{
+ return sal_True;
+}
+
+
+sal_Bool SAL_CALL OResultSetMetaData::isDefinitelyWritable( sal_Int32 column )
+{
+ return sal_False;
+;
+}
+
+sal_Bool SAL_CALL OResultSetMetaData::isWritable( sal_Int32 column )
+{
+ return sal_False;
+}
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/Database/DriverSkeleton/SResultSetMetaData.hxx b/odk/examples/DevelopersGuide/Database/DriverSkeleton/SResultSetMetaData.hxx
new file mode 100644
index 000000000..bee89f0ec
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Database/DriverSkeleton/SResultSetMetaData.hxx
@@ -0,0 +1,91 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+#ifndef INCLUDED_EXAMPLES_DATABASE_DRIVERSKELETON_SRESULTSETMETADATA_HXX
+#define INCLUDED_EXAMPLES_DATABASE_DRIVERSKELETON_SRESULTSETMETADATA_HXX
+
+#include <com/sun/star/sdbc/XResultSetMetaData.hpp>
+#include <cppuhelper/implbase1.hxx>
+#include "SConnection.hxx"
+
+namespace connectivity
+{
+ namespace skeleton
+ {
+
+ typedef ::cppu::WeakImplHelper1< ::com::sun::star::sdbc::XResultSetMetaData> OResultSetMetaData_BASE;
+
+ class OResultSetMetaData : public OResultSetMetaData_BASE
+ {
+ OConnection* m_pConnection;
+
+ protected:
+ virtual ~OResultSetMetaData();
+ public:
+ // a constructor, which is required for returning objects:
+ OResultSetMetaData(OConnection* _pConnection) : m_pConnection(_pConnection){}
+
+ /// Avoid ambiguous cast error from the compiler.
+ inline operator ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSetMetaData > () throw()
+ { return this; }
+
+ virtual sal_Int32 SAL_CALL getColumnCount( );
+ virtual sal_Bool SAL_CALL isAutoIncrement( sal_Int32 column );
+ virtual sal_Bool SAL_CALL isCaseSensitive( sal_Int32 column );
+ virtual sal_Bool SAL_CALL isSearchable( sal_Int32 column );
+ virtual sal_Bool SAL_CALL isCurrency( sal_Int32 column );
+ virtual sal_Int32 SAL_CALL isNullable( sal_Int32 column );
+ virtual sal_Bool SAL_CALL isSigned( sal_Int32 column );
+ virtual sal_Int32 SAL_CALL getColumnDisplaySize( sal_Int32 column );
+ virtual ::rtl::OUString SAL_CALL getColumnLabel( sal_Int32 column );
+ virtual ::rtl::OUString SAL_CALL getColumnName( sal_Int32 column );
+ virtual ::rtl::OUString SAL_CALL getSchemaName( sal_Int32 column );
+ virtual sal_Int32 SAL_CALL getPrecision( sal_Int32 column );
+ virtual sal_Int32 SAL_CALL getScale( sal_Int32 column );
+ virtual ::rtl::OUString SAL_CALL getTableName( sal_Int32 column );
+ virtual ::rtl::OUString SAL_CALL getCatalogName( sal_Int32 column );
+ virtual sal_Int32 SAL_CALL getColumnType( sal_Int32 column );
+ virtual ::rtl::OUString SAL_CALL getColumnTypeName( sal_Int32 column );
+ virtual sal_Bool SAL_CALL isReadOnly( sal_Int32 column );
+ virtual sal_Bool SAL_CALL isWritable( sal_Int32 column );
+ virtual sal_Bool SAL_CALL isDefinitelyWritable( sal_Int32 column );
+ virtual ::rtl::OUString SAL_CALL getColumnServiceName( sal_Int32 column );
+ };
+ }
+}
+
+#endif // INCLUDED_EXAMPLES_DATABASE_DRIVERSKELETON_SRESULTSETMETADATA_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/Database/DriverSkeleton/SServices.cxx b/odk/examples/DevelopersGuide/Database/DriverSkeleton/SServices.cxx
new file mode 100644
index 000000000..b04963d05
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Database/DriverSkeleton/SServices.cxx
@@ -0,0 +1,153 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+#include <sal/types.h>
+#include "SDriver.hxx"
+#include <cppuhelper/factory.hxx>
+#include <osl/diagnose.h>
+#include <uno/lbnames.h>
+#include <com/sun/star/registry/XRegistryKey.hpp>
+#include <com/sun/star/lang/XSingleServiceFactory.hpp>
+
+using namespace connectivity::skeleton;
+using ::rtl::OUString;
+using ::com::sun::star::uno::Reference;
+using ::com::sun::star::uno::Sequence;
+using ::com::sun::star::registry::XRegistryKey;
+using ::com::sun::star::lang::XSingleServiceFactory;
+using ::com::sun::star::lang::XMultiServiceFactory;
+
+typedef Reference< XSingleServiceFactory > (SAL_CALL *createFactoryFunc)
+ (
+ const Reference< XMultiServiceFactory > & rServiceManager,
+ const OUString & rComponentName,
+ ::cppu::ComponentInstantiation pCreateFunction,
+ const Sequence< OUString > & rServiceNames,
+ rtl_ModuleCount*
+ );
+
+
+// The required C-Api must be provided!
+// It contains of 3 special functions that have to be exported.
+
+
+void REGISTER_PROVIDER(
+ const OUString& aServiceImplName,
+ const Sequence< OUString>& Services,
+ const Reference< ::com::sun::star::registry::XRegistryKey > & xKey)
+{
+ OUString aMainKeyName("/");
+ aMainKeyName += aServiceImplName;
+ aMainKeyName += "/UNO/SERVICES";
+
+ Reference< ::com::sun::star::registry::XRegistryKey > xNewKey( xKey->createKey(aMainKeyName) );
+ OSL_ENSURE(xNewKey.is(), "SKELETON::component_writeInfo : could not create a registry key !");
+
+ for (sal_uInt32 i=0; i<Services.getLength(); ++i)
+ xNewKey->createKey(Services[i]);
+}
+
+
+struct ProviderRequest
+{
+ Reference< XSingleServiceFactory > xRet;
+ Reference< XMultiServiceFactory > const xServiceManager;
+ OUString const sImplementationName;
+
+ ProviderRequest(
+ void* pServiceManager,
+ char const* pImplementationName
+ )
+ : xServiceManager(reinterpret_cast<XMultiServiceFactory*>(pServiceManager))
+ , sImplementationName(OUString::createFromAscii(pImplementationName))
+ {
+ }
+
+ inline
+ sal_Bool CREATE_PROVIDER(
+ const OUString& Implname,
+ const Sequence< OUString > & Services,
+ ::cppu::ComponentInstantiation Factory,
+ createFactoryFunc creator
+ )
+ {
+ if (!xRet.is() && (Implname == sImplementationName))
+ try
+ {
+ xRet = creator( xServiceManager, sImplementationName,Factory, Services,0);
+ }
+ catch(...)
+ {
+ }
+ return xRet.is();
+ }
+
+ void* getProvider() const { return xRet.get(); }
+};
+
+
+extern "C" SAL_DLLPUBLIC_EXPORT void* SAL_CALL component_getFactory(
+ const char* pImplementationName,
+ void* pServiceManager,
+ void* pRegistryKey)
+{
+ void* pRet = 0;
+ if (pServiceManager)
+ {
+ ProviderRequest aReq(pServiceManager,pImplementationName);
+
+ aReq.CREATE_PROVIDER(
+ SkeletonDriver::getImplementationName_Static(),
+ SkeletonDriver::getSupportedServiceNames_Static(),
+ SkeletonDriver_CreateInstance, ::cppu::createSingleFactory)
+ ;
+
+ if(aReq.xRet.is())
+ aReq.xRet->acquire();
+
+ pRet = aReq.getProvider();
+ }
+
+ return pRet;
+};
+
+extern "C" SAL_DLLPUBLIC_EXPORT void SAL_CALL
+component_getImplementationEnvironment(
+ char const ** ppEnvTypeName, uno_Environment **)
+{
+ *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/Database/DriverSkeleton/SStatement.cxx b/odk/examples/DevelopersGuide/Database/DriverSkeleton/SStatement.cxx
new file mode 100644
index 000000000..f2156bc46
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Database/DriverSkeleton/SStatement.cxx
@@ -0,0 +1,376 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+#include <stdio.h>
+#include "SStatement.hxx"
+#include "SConnection.hxx"
+#include "SResultSet.hxx"
+#include <osl/thread.h>
+#include <com/sun/star/sdbc/ResultSetConcurrency.hpp>
+#include <com/sun/star/sdbc/ResultSetType.hpp>
+#include <com/sun/star/sdbc/FetchDirection.hpp>
+#include <com/sun/star/lang/DisposedException.hpp>
+#include <cppuhelper/typeprovider.hxx>
+#include <cppuhelper/queryinterface.hxx>
+#include "propertyids.hxx"
+
+using namespace connectivity::skeleton;
+
+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::io;
+using namespace com::sun::star::util;
+
+OStatement_Base::OStatement_Base(OConnection* _pConnection )
+ : OStatement_BASE(m_aMutex),
+ OPropertySetHelper(OStatement_BASE::rBHelper),
+ rBHelper(OStatement_BASE::rBHelper),
+ m_pConnection(_pConnection)
+{
+ m_pConnection->acquire();
+}
+
+OStatement_Base::~OStatement_Base()
+{
+}
+
+void OStatement_Base::disposeResultSet()
+{
+ // free the cursor if alive
+ Reference< XComponent > xComp(m_xResultSet.get(), UNO_QUERY);
+ if (xComp.is())
+ xComp->dispose();
+ m_xResultSet.clear();
+}
+
+void OStatement_BASE2::disposing()
+{
+ ::osl::MutexGuard aGuard(m_aMutex);
+
+ disposeResultSet();
+
+ if (m_pConnection)
+ m_pConnection->release();
+ m_pConnection = NULL;
+
+ dispose_ChildImpl();
+ OStatement_Base::disposing();
+}
+
+void SAL_CALL OStatement_BASE2::release() throw()
+{
+ release_ChildImpl();
+}
+
+Any SAL_CALL OStatement_Base::queryInterface( const Type & rType )
+{
+ Any aRet = OStatement_BASE::queryInterface(rType);
+ if(!aRet.hasValue())
+ aRet = OPropertySetHelper::queryInterface(rType);
+ return aRet;
+}
+
+Sequence< Type > SAL_CALL OStatement_Base::getTypes( )
+{
+ ::cppu::OTypeCollection aTypes(
+ ::cppu::UnoType<XMultiPropertySet>::get(),
+ ::cppu::UnoType<XFastPropertySet>::get(),
+ ::cppu::UnoType<XPropertySet>::get());
+
+ return concatSequences(aTypes.getTypes(),OStatement_BASE::getTypes());
+}
+
+
+void SAL_CALL OStatement_Base::cancel( )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OStatement_BASE::rBHelper.bDisposed);
+ // cancel the current sql statement
+}
+
+
+void SAL_CALL OStatement_Base::close( )
+{
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OStatement_BASE::rBHelper.bDisposed);
+
+ }
+ dispose();
+}
+
+
+void SAL_CALL OStatement::clearBatch( )
+{
+ // if you support batches clear it here
+}
+
+sal_Bool SAL_CALL OStatement_Base::execute( const ::rtl::OUString& sql )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OStatement_BASE::rBHelper.bDisposed);
+
+ // returns true when a resultset is available
+ return sal_False;
+}
+
+
+Reference< XResultSet > SAL_CALL OStatement_Base::executeQuery( const ::rtl::OUString& sql )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OStatement_BASE::rBHelper.bDisposed);
+
+
+ Reference< XResultSet > xRS = NULL;
+ // create a resultset as result of executing the sql statement
+ // you have to here something :-)
+ m_xResultSet = xRS; // we need a reference to it for later use
+ return xRS;
+}
+
+
+Reference< XConnection > SAL_CALL OStatement_Base::getConnection( )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OStatement_BASE::rBHelper.bDisposed);
+
+ // just return our connection here
+ return (Reference< XConnection >)m_pConnection;
+}
+
+sal_Int32 SAL_CALL OStatement_Base::getUpdateCount( )
+{
+ return 0;
+}
+
+
+Any SAL_CALL OStatement::queryInterface( const Type & rType )
+{
+ Any aRet = ::cppu::queryInterface(rType,static_cast< XBatchExecution*> (this));
+ if(!aRet.hasValue())
+ aRet = OStatement_Base::queryInterface(rType);
+ return aRet;
+}
+
+
+void SAL_CALL OStatement::addBatch( const ::rtl::OUString& sql )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OStatement_BASE::rBHelper.bDisposed);
+
+
+ m_aBatchVector.push_back(sql);
+}
+
+Sequence< sal_Int32 > SAL_CALL OStatement::executeBatch( )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OStatement_BASE::rBHelper.bDisposed);
+
+ return Sequence< sal_Int32 >();
+}
+
+
+sal_Int32 SAL_CALL OStatement_Base::executeUpdate( const ::rtl::OUString& sql )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OStatement_BASE::rBHelper.bDisposed);
+
+ // the return values gives information about how many rows are affected by executing the sql statement
+ return 0;
+
+}
+
+
+Reference< XResultSet > SAL_CALL OStatement_Base::getResultSet( )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OStatement_BASE::rBHelper.bDisposed);
+
+// return our save resultset here
+ return m_xResultSet;
+}
+
+
+sal_Bool SAL_CALL OStatement_Base::getMoreResults( )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OStatement_BASE::rBHelper.bDisposed);
+
+ // if your driver supports more than only one resultset
+ // and has one more at this moment return true
+ return sal_False;
+}
+
+
+Any SAL_CALL OStatement_Base::getWarnings( )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OStatement_BASE::rBHelper.bDisposed);
+
+
+ return makeAny(m_aLastWarning);
+}
+
+
+void SAL_CALL OStatement_Base::clearWarnings( )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OStatement_BASE::rBHelper.bDisposed);
+
+
+ m_aLastWarning = SQLWarning();
+}
+
+::cppu::IPropertyArrayHelper* OStatement_Base::createArrayHelper( ) const
+{
+ // this properties are define by the service statement
+ // they must in alphabetic order
+ Sequence< Property > aProps(10);
+ Property* pProperties = aProps.getArray();
+ sal_Int32 nPos = 0;
+ pProperties[nPos++] = ::com::sun::star::beans::Property(OPropertyMap::getPropMap().getNameByIndex(PROPERTY_ID_CURSORNAME),
+ PROPERTY_ID_CURSORNAME, ::cppu::UnoType<rtl::OUString>::get(), 0);
+ pProperties[nPos++] = ::com::sun::star::beans::Property(OPropertyMap::getPropMap().getNameByIndex(PROPERTY_ID_ESCAPEPROCESSING),
+ PROPERTY_ID_ESCAPEPROCESSING, cppu::UnoType<bool>::get(), 0);
+ pProperties[nPos++] = ::com::sun::star::beans::Property(OPropertyMap::getPropMap().getNameByIndex(PROPERTY_ID_FETCHDIRECTION),
+ PROPERTY_ID_FETCHDIRECTION, ::cppu::UnoType<sal_Int32>::get(), 0);
+ pProperties[nPos++] = ::com::sun::star::beans::Property(OPropertyMap::getPropMap().getNameByIndex(PROPERTY_ID_FETCHSIZE),
+ PROPERTY_ID_FETCHSIZE, ::cppu::UnoType<sal_Int32>::get(), 0);
+ pProperties[nPos++] = ::com::sun::star::beans::Property(OPropertyMap::getPropMap().getNameByIndex(PROPERTY_ID_MAXFIELDSIZE),
+ PROPERTY_ID_MAXFIELDSIZE, ::cppu::UnoType<sal_Int32>::get(), 0);
+ pProperties[nPos++] = ::com::sun::star::beans::Property(OPropertyMap::getPropMap().getNameByIndex(PROPERTY_ID_MAXROWS),
+ PROPERTY_ID_MAXROWS, ::cppu::UnoType<sal_Int32>::get(), 0);
+ pProperties[nPos++] = ::com::sun::star::beans::Property(OPropertyMap::getPropMap().getNameByIndex(PROPERTY_ID_QUERYTIMEOUT),
+ PROPERTY_ID_QUERYTIMEOUT, ::cppu::UnoType<sal_Int32>::get(), 0);
+ pProperties[nPos++] = ::com::sun::star::beans::Property(OPropertyMap::getPropMap().getNameByIndex(PROPERTY_ID_RESULTSETCONCURRENCY),
+ PROPERTY_ID_RESULTSETCONCURRENCY, ::cppu::UnoType<sal_Int32>::get(), 0);
+ pProperties[nPos++] = ::com::sun::star::beans::Property(OPropertyMap::getPropMap().getNameByIndex(PROPERTY_ID_RESULTSETTYPE),
+ PROPERTY_ID_RESULTSETTYPE, ::cppu::UnoType<sal_Int32>::get(), 0);
+ pProperties[nPos++] = ::com::sun::star::beans::Property(OPropertyMap::getPropMap().getNameByIndex(PROPERTY_ID_USEBOOKMARKS),
+ PROPERTY_ID_USEBOOKMARKS, cppu::UnoType<bool>::get(), 0);
+
+ return new ::cppu::OPropertyArrayHelper(aProps);
+}
+
+
+::cppu::IPropertyArrayHelper & OStatement_Base::getInfoHelper()
+{
+ return *const_cast<OStatement_Base*>(this)->getArrayHelper();
+}
+
+sal_Bool OStatement_Base::convertFastPropertyValue(
+ Any & rConvertedValue,
+ Any & rOldValue,
+ sal_Int32 nHandle,
+ const Any& rValue )
+{
+ sal_Bool bConverted = sal_False;
+ // here we have to try to convert
+ return bConverted;
+}
+
+void OStatement_Base::setFastPropertyValue_NoBroadcast(sal_Int32 nHandle,const Any& rValue)
+{
+ // set the value to whatever is necessary
+ switch(nHandle)
+ {
+ case PROPERTY_ID_QUERYTIMEOUT:
+ case PROPERTY_ID_MAXFIELDSIZE:
+ case PROPERTY_ID_MAXROWS:
+ case PROPERTY_ID_CURSORNAME:
+ case PROPERTY_ID_RESULTSETCONCURRENCY:
+ case PROPERTY_ID_RESULTSETTYPE:
+ case PROPERTY_ID_FETCHDIRECTION:
+ case PROPERTY_ID_FETCHSIZE:
+ case PROPERTY_ID_ESCAPEPROCESSING:
+ case PROPERTY_ID_USEBOOKMARKS:
+ default:
+ ;
+ }
+}
+
+void OStatement_Base::getFastPropertyValue(Any& rValue,sal_Int32 nHandle) const
+{
+ switch(nHandle)
+ {
+ case PROPERTY_ID_QUERYTIMEOUT:
+ case PROPERTY_ID_MAXFIELDSIZE:
+ case PROPERTY_ID_MAXROWS:
+ case PROPERTY_ID_CURSORNAME:
+ case PROPERTY_ID_RESULTSETCONCURRENCY:
+ case PROPERTY_ID_RESULTSETTYPE:
+ case PROPERTY_ID_FETCHDIRECTION:
+ case PROPERTY_ID_FETCHSIZE:
+ case PROPERTY_ID_ESCAPEPROCESSING:
+ case PROPERTY_ID_USEBOOKMARKS:
+ default:
+ ;
+ }
+}
+
+IMPLEMENT_SERVICE_INFO(OStatement,"com.sun.star.sdbcx.OStatement","com.sun.star.sdbc.Statement");
+
+void SAL_CALL OStatement_Base::acquire() throw()
+{
+ OStatement_BASE::acquire();
+}
+
+void SAL_CALL OStatement_Base::release() throw()
+{
+ OStatement_BASE::release();
+}
+
+void SAL_CALL OStatement::acquire() throw()
+{
+ OStatement_BASE2::acquire();
+}
+
+void SAL_CALL OStatement::release() throw()
+{
+ OStatement_BASE2::release();
+}
+
+Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL OStatement_Base::getPropertySetInfo( )
+{
+ return ::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper());
+}
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/Database/DriverSkeleton/SStatement.hxx b/odk/examples/DevelopersGuide/Database/DriverSkeleton/SStatement.hxx
new file mode 100644
index 000000000..878187075
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Database/DriverSkeleton/SStatement.hxx
@@ -0,0 +1,175 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+#ifndef INCLUDED_EXAMPLES_DATABASE_DRIVERSKELETON_SSTATEMENT_HXX
+#define INCLUDED_EXAMPLES_DATABASE_DRIVERSKELETON_SSTATEMENT_HXX
+
+#include <com/sun/star/sdbc/XStatement.hpp>
+#include <com/sun/star/sdbc/XWarningsSupplier.hpp>
+#include <com/sun/star/sdbc/XMultipleResults.hpp>
+#include <com/sun/star/sdbc/XBatchExecution.hpp>
+#include <com/sun/star/sdbc/XCloseable.hpp>
+#include <com/sun/star/sdbc/SQLWarning.hpp>
+#include <com/sun/star/util/XCancellable.hpp>
+#include <cppuhelper/compbase5.hxx>
+#include "SConnection.hxx"
+#include <vector>
+#include "OSubComponent.hxx"
+#include <com/sun/star/lang/XServiceInfo.hpp>
+
+namespace connectivity
+{
+ namespace skeleton
+ {
+
+ typedef ::cppu::WeakComponentImplHelper5< ::com::sun::star::sdbc::XStatement,
+ ::com::sun::star::sdbc::XWarningsSupplier,
+ ::com::sun::star::util::XCancellable,
+ ::com::sun::star::sdbc::XCloseable,
+ ::com::sun::star::sdbc::XMultipleResults> OStatement_BASE;
+
+ // A base class for the normal statement and for the prepared statement
+ class OStatement_Base : public OBase_Mutex,
+ public OStatement_BASE,
+ public ::cppu::OPropertySetHelper,
+ public OPropertyArrayUsageHelper<OStatement_Base>
+
+ {
+ ::com::sun::star::sdbc::SQLWarning m_aLastWarning;
+ protected:
+ ::com::sun::star::uno::WeakReference< ::com::sun::star::sdbc::XResultSet> m_xResultSet; // The last ResultSet created
+ // for this Statement
+
+ ::std::vector< ::rtl::OUString> m_aBatchVector;
+
+ OConnection* m_pConnection; // The owning Connection object
+ protected:
+
+ void disposeResultSet();
+
+ // OPropertyArrayUsageHelper
+ virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const;
+ // OPropertySetHelper
+ 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 );
+ virtual void SAL_CALL setFastPropertyValue_NoBroadcast(
+ sal_Int32 nHandle,
+ const ::com::sun::star::uno::Any& rValue);
+ virtual void SAL_CALL getFastPropertyValue(
+ ::com::sun::star::uno::Any& rValue,
+ sal_Int32 nHandle) const;
+ virtual ~OStatement_Base();
+
+ public:
+ ::cppu::OBroadcastHelper& rBHelper;
+ OStatement_Base(OConnection* _pConnection );
+ using OStatement_BASE::operator ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >;
+
+ // OComponentHelper
+ virtual void SAL_CALL disposing(){OStatement_BASE::disposing();}
+ // XInterface
+ virtual void SAL_CALL release() throw();
+ virtual void SAL_CALL acquire() throw();
+ // XInterface
+ virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType );
+ //XTypeProvider
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes( );
+
+ // XPropertySet
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( );
+ // XStatement
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL executeQuery( const ::rtl::OUString& sql ) ;
+ virtual sal_Int32 SAL_CALL executeUpdate( const ::rtl::OUString& sql ) ;
+ virtual sal_Bool SAL_CALL execute( const ::rtl::OUString& sql ) ;
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > SAL_CALL getConnection( ) ;
+ // XWarningsSupplier
+ virtual ::com::sun::star::uno::Any SAL_CALL getWarnings( );
+ virtual void SAL_CALL clearWarnings( );
+ // XCancellable
+ virtual void SAL_CALL cancel( );
+ // XCloseable
+ virtual void SAL_CALL close( );
+ // XMultipleResults
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getResultSet( );
+ virtual sal_Int32 SAL_CALL getUpdateCount( );
+ virtual sal_Bool SAL_CALL getMoreResults( );
+
+ // other methods
+ OConnection* getOwnConnection() const { return m_pConnection;}
+ };
+
+ class OStatement_BASE2 :public OStatement_Base
+ ,public OSubComponent<OStatement_BASE2, OStatement_BASE>
+
+ {
+ friend class OSubComponent<OStatement_BASE2, OStatement_BASE>;
+ public:
+ OStatement_BASE2(OConnection* _pConnection ) : OStatement_Base(_pConnection ),
+ OSubComponent<OStatement_BASE2, OStatement_BASE>((::cppu::OWeakObject*)_pConnection, this){}
+ // OComponentHelper
+ virtual void SAL_CALL disposing();
+ // XInterface
+ virtual void SAL_CALL release() throw();
+ };
+
+ class OStatement : public OStatement_BASE2,
+ public ::com::sun::star::sdbc::XBatchExecution,
+ public ::com::sun::star::lang::XServiceInfo
+ {
+ protected:
+ virtual ~OStatement(){}
+ public:
+ // a constructor, which is required for returning objects:
+ OStatement( OConnection* _pConnection) : OStatement_BASE2( _pConnection){}
+ DECLARE_SERVICE_INFO();
+
+ virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType );
+ virtual void SAL_CALL acquire() throw();
+ virtual void SAL_CALL release() throw();
+ // XBatchExecution
+ virtual void SAL_CALL addBatch( const ::rtl::OUString& sql );
+ virtual void SAL_CALL clearBatch( );
+ virtual ::com::sun::star::uno::Sequence< sal_Int32 > SAL_CALL executeBatch( );
+ };
+ }
+}
+
+#endif // INCLUDED_EXAMPLES_DATABASE_DRIVERSKELETON_SSTATEMENT_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/Database/DriverSkeleton/propertyids.cxx b/odk/examples/DevelopersGuide/Database/DriverSkeleton/propertyids.cxx
new file mode 100644
index 000000000..cbbe29bd1
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Database/DriverSkeleton/propertyids.cxx
@@ -0,0 +1,184 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+#include "propertyids.hxx"
+namespace connectivity
+{
+namespace skeleton
+{
+ const char* getPROPERTY_QUERYTIMEOUT() { return "QueryTimeOut"; }
+ const char* getPROPERTY_MAXFIELDSIZE() { return "MaxFieldSize"; }
+ const char* getPROPERTY_MAXROWS() { return "MaxRows"; }
+ const char* getPROPERTY_CURSORNAME() { return "CursorName"; }
+ const char* getPROPERTY_RESULTSETCONCURRENCY() { return "ResultSetConcurrency"; }
+ const char* getPROPERTY_RESULTSETTYPE() { return "ResultSetType"; }
+ const char* getPROPERTY_FETCHDIRECTION() { return "FetchDirection"; }
+ const char* getPROPERTY_FETCHSIZE() { return "FetchSize"; }
+ const char* getPROPERTY_ESCAPEPROCESSING() { return "EscapeProcessing"; }
+ const char* getPROPERTY_USEBOOKMARKS() { return "UseBookmarks"; }
+
+ const char* getPROPERTY_NAME() { return "Name"; }
+ const char* getPROPERTY_TYPE() { return "Type"; }
+ const char* getPROPERTY_TYPENAME() { return "TypeName"; }
+ const char* getPROPERTY_PRECISION() { return "Precision"; }
+ const char* getPROPERTY_SCALE() { return "Scale"; }
+ const char* getPROPERTY_ISNULLABLE() { return "IsNullable"; }
+ const char* getPROPERTY_ISAUTOINCREMENT() { return "IsAutoIncrement"; }
+ const char* getPROPERTY_ISROWVERSION() { return "IsRowVersion"; }
+ const char* getPROPERTY_DESCRIPTION() { return "Description"; }
+ const char* getPROPERTY_DEFAULTVALUE() { return "DefaultValue"; }
+
+ const char* getPROPERTY_REFERENCEDTABLE() { return "ReferencedTable"; }
+ const char* getPROPERTY_UPDATERULE() { return "UpdateRule"; }
+ const char* getPROPERTY_DELETERULE() { return "DeleteRule"; }
+ const char* getPROPERTY_CATALOG() { return "Catalog"; }
+ const char* getPROPERTY_ISUNIQUE() { return "IsUnique"; }
+ const char* getPROPERTY_ISPRIMARYKEYINDEX() { return "IsPrimaryKeyIndex"; }
+ const char* getPROPERTY_ISCLUSTERED() { return "IsClustered"; }
+ const char* getPROPERTY_ISASCENDING() { return "IsAscending"; }
+ const char* getPROPERTY_SCHEMANAME() { return "SchemaName"; }
+ const char* getPROPERTY_CATALOGNAME() { return "CatalogName"; }
+ const char* getPROPERTY_COMMAND() { return "Command"; }
+ const char* getPROPERTY_CHECKOPTION() { return "CheckOption"; }
+ const char* getPROPERTY_PASSWORD() { return "Password"; }
+ const char* getPROPERTY_RELATEDCOLUMN() { return "RelatedColumn"; }
+
+ const char* getSTAT_INVALID_INDEX() { return "Invalid descriptor index"; }
+
+ const char* getPROPERTY_FUNCTION() { return "Function"; }
+ const char* getPROPERTY_TABLENAME() { return "TableName"; }
+ const char* getPROPERTY_REALNAME() { return "RealName"; }
+ const char* getPROPERTY_DBASEPRECISIONCHANGED() { return "DbasePrecisionChanged"; }
+ const char* getPROPERTY_ISCURRENCY() { return "IsCurrency"; }
+ const char* getPROPERTY_ISBOOKMARKABLE() { return "IsBookmarkable"; }
+
+ const char* getPROPERTY_FORMATKEY() { return "FormatKey"; }
+ const char* getPROPERTY_LOCALE() { return "Locale"; }
+
+ const char* getPROPERTY_AUTOINCREMENTCREATION() { return "AutoIncrementCreation"; }
+ const char* getPROPERTY_PRIVILEGES() { return "Privileges"; }
+
+ //= error messages
+
+ const char* getERRORMSG_SEQUENCE() { return "Function sequence error"; }
+ const char* getSQLSTATE_SEQUENCE() { return "HY010"; }
+ const char* getSQLSTATE_GENERAL() { return "HY0000"; }
+ const char* getSTR_DELIMITER() { return "/"; }
+
+ OPropertyMap::~OPropertyMap()
+ {
+ ::std::map<sal_Int32 , rtl_uString*>::iterator aIter = m_aPropertyMap.begin();
+ for(;aIter != m_aPropertyMap.end();++aIter)
+ if(aIter->second)
+ rtl_uString_release(aIter->second);
+ }
+
+ ::rtl::OUString OPropertyMap::getNameByIndex(sal_Int32 _nIndex) const
+ {
+ ::rtl::OUString sRet;
+ ::std::map<sal_Int32 , rtl_uString*>::const_iterator aIter = m_aPropertyMap.find(_nIndex);
+ if(aIter == m_aPropertyMap.end())
+ sRet = const_cast<OPropertyMap*>(this)->fillValue(_nIndex);
+ else
+ sRet = aIter->second;
+ return sRet;
+ }
+
+ ::rtl::OUString OPropertyMap::fillValue(sal_Int32 _nIndex)
+ {
+ rtl_uString* pStr = NULL;
+ switch(_nIndex)
+ {
+ case PROPERTY_ID_QUERYTIMEOUT: { rtl_uString_newFromAscii(&pStr,getPROPERTY_QUERYTIMEOUT() ); break; }
+ case PROPERTY_ID_MAXFIELDSIZE: { rtl_uString_newFromAscii(&pStr,getPROPERTY_MAXFIELDSIZE() ); break; }
+ case PROPERTY_ID_MAXROWS: { rtl_uString_newFromAscii(&pStr,getPROPERTY_MAXROWS() ); break; }
+ case PROPERTY_ID_CURSORNAME: { rtl_uString_newFromAscii(&pStr,getPROPERTY_CURSORNAME() ); break; }
+ case PROPERTY_ID_RESULTSETCONCURRENCY: { rtl_uString_newFromAscii(&pStr,getPROPERTY_RESULTSETCONCURRENCY() ); break; }
+ case PROPERTY_ID_RESULTSETTYPE: { rtl_uString_newFromAscii(&pStr,getPROPERTY_RESULTSETTYPE() ); break; }
+ case PROPERTY_ID_FETCHDIRECTION: { rtl_uString_newFromAscii(&pStr,getPROPERTY_FETCHDIRECTION() ); break; }
+ case PROPERTY_ID_FETCHSIZE: { rtl_uString_newFromAscii(&pStr,getPROPERTY_FETCHSIZE() ); break; }
+ case PROPERTY_ID_ESCAPEPROCESSING: { rtl_uString_newFromAscii(&pStr,getPROPERTY_ESCAPEPROCESSING() ); break; }
+ case PROPERTY_ID_USEBOOKMARKS: { rtl_uString_newFromAscii(&pStr,getPROPERTY_USEBOOKMARKS() ); break; }
+ // Column
+ case PROPERTY_ID_NAME: { rtl_uString_newFromAscii(&pStr,getPROPERTY_NAME() ); break; }
+ case PROPERTY_ID_TYPE: { rtl_uString_newFromAscii(&pStr,getPROPERTY_TYPE() ); break; }
+ case PROPERTY_ID_TYPENAME: { rtl_uString_newFromAscii(&pStr,getPROPERTY_TYPENAME() ); break; }
+ case PROPERTY_ID_PRECISION: { rtl_uString_newFromAscii(&pStr,getPROPERTY_PRECISION() ); break; }
+ case PROPERTY_ID_SCALE: { rtl_uString_newFromAscii(&pStr,getPROPERTY_SCALE() ); break; }
+ case PROPERTY_ID_ISNULLABLE: { rtl_uString_newFromAscii(&pStr,getPROPERTY_ISNULLABLE() ); break; }
+ case PROPERTY_ID_ISAUTOINCREMENT: { rtl_uString_newFromAscii(&pStr,getPROPERTY_ISAUTOINCREMENT() ); break; }
+ case PROPERTY_ID_ISROWVERSION: { rtl_uString_newFromAscii(&pStr,getPROPERTY_ISROWVERSION() ); break; }
+ case PROPERTY_ID_DESCRIPTION: { rtl_uString_newFromAscii(&pStr,getPROPERTY_DESCRIPTION() ); break; }
+ case PROPERTY_ID_DEFAULTVALUE: { rtl_uString_newFromAscii(&pStr,getPROPERTY_DEFAULTVALUE() ); break; }
+
+ case PROPERTY_ID_REFERENCEDTABLE: { rtl_uString_newFromAscii(&pStr,getPROPERTY_REFERENCEDTABLE() ); break; }
+ case PROPERTY_ID_UPDATERULE: { rtl_uString_newFromAscii(&pStr,getPROPERTY_UPDATERULE() ); break; }
+ case PROPERTY_ID_DELETERULE: { rtl_uString_newFromAscii(&pStr,getPROPERTY_DELETERULE() ); break; }
+ case PROPERTY_ID_CATALOG: { rtl_uString_newFromAscii(&pStr,getPROPERTY_CATALOG() ); break; }
+ case PROPERTY_ID_ISUNIQUE: { rtl_uString_newFromAscii(&pStr,getPROPERTY_ISUNIQUE() ); break; }
+ case PROPERTY_ID_ISPRIMARYKEYINDEX: { rtl_uString_newFromAscii(&pStr,getPROPERTY_ISPRIMARYKEYINDEX() ); break; }
+ case PROPERTY_ID_ISCLUSTERED: { rtl_uString_newFromAscii(&pStr,getPROPERTY_ISCLUSTERED() ); break; }
+ case PROPERTY_ID_ISASCENDING: { rtl_uString_newFromAscii(&pStr,getPROPERTY_ISASCENDING() ); break; }
+ case PROPERTY_ID_SCHEMANAME: { rtl_uString_newFromAscii(&pStr,getPROPERTY_SCHEMANAME() ); break; }
+ case PROPERTY_ID_CATALOGNAME: { rtl_uString_newFromAscii(&pStr,getPROPERTY_CATALOGNAME() ); break; }
+
+ case PROPERTY_ID_COMMAND: { rtl_uString_newFromAscii(&pStr,getPROPERTY_COMMAND() ); break; }
+ case PROPERTY_ID_CHECKOPTION: { rtl_uString_newFromAscii(&pStr,getPROPERTY_CHECKOPTION() ); break; }
+ case PROPERTY_ID_PASSWORD: { rtl_uString_newFromAscii(&pStr,getPROPERTY_PASSWORD() ); break; }
+ case PROPERTY_ID_RELATEDCOLUMN: { rtl_uString_newFromAscii(&pStr,getPROPERTY_RELATEDCOLUMN() ); break; }
+
+ case PROPERTY_ID_FUNCTION: { rtl_uString_newFromAscii(&pStr,getPROPERTY_FUNCTION() ); break; }
+ case PROPERTY_ID_TABLENAME: { rtl_uString_newFromAscii(&pStr,getPROPERTY_TABLENAME() ); break; }
+ case PROPERTY_ID_REALNAME: { rtl_uString_newFromAscii(&pStr,getPROPERTY_REALNAME() ); break; }
+ case PROPERTY_ID_DBASEPRECISIONCHANGED: { rtl_uString_newFromAscii(&pStr,getPROPERTY_DBASEPRECISIONCHANGED() ); break; }
+ case PROPERTY_ID_ISCURRENCY: { rtl_uString_newFromAscii(&pStr,getPROPERTY_ISCURRENCY() ); break; }
+ case PROPERTY_ID_ISBOOKMARKABLE: { rtl_uString_newFromAscii(&pStr,getPROPERTY_ISBOOKMARKABLE() ); break; }
+ case PROPERTY_ID_INVALID_INDEX: { rtl_uString_newFromAscii(&pStr,getSTAT_INVALID_INDEX() ); break; }
+ case PROPERTY_ID_ERRORMSG_SEQUENCE: { rtl_uString_newFromAscii(&pStr,getERRORMSG_SEQUENCE() ); break; }
+ case PROPERTY_ID_HY010: { rtl_uString_newFromAscii(&pStr,getSQLSTATE_SEQUENCE() ); break; }
+ case PROPERTY_ID_HY0000: { rtl_uString_newFromAscii(&pStr,getSQLSTATE_GENERAL() ); break; }
+ case PROPERTY_ID_DELIMITER: { rtl_uString_newFromAscii(&pStr,getSTR_DELIMITER() ); break; }
+ case PROPERTY_ID_FORMATKEY: { rtl_uString_newFromAscii(&pStr,getPROPERTY_FORMATKEY() ); break; }
+ case PROPERTY_ID_LOCALE: { rtl_uString_newFromAscii(&pStr,getPROPERTY_LOCALE() ); break; }
+ case PROPERTY_ID_AUTOINCREMENTCREATION: { rtl_uString_newFromAscii(&pStr,getPROPERTY_AUTOINCREMENTCREATION() ); break; }
+ case PROPERTY_ID_PRIVILEGES: { rtl_uString_newFromAscii(&pStr,getPROPERTY_PRIVILEGES() ); break; }
+ }
+ m_aPropertyMap[_nIndex] = pStr;
+ return pStr;
+ }
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/Database/DriverSkeleton/propertyids.hxx b/odk/examples/DevelopersGuide/Database/DriverSkeleton/propertyids.hxx
new file mode 100644
index 000000000..bc8e20d7a
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Database/DriverSkeleton/propertyids.hxx
@@ -0,0 +1,145 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+#ifndef INCLUDED_EXAMPLES_DATABASE_DRIVERSKELETON_PROPERTYIDS_HXX
+#define INCLUDED_EXAMPLES_DATABASE_DRIVERSKELETON_PROPERTYIDS_HXX
+
+// this define has to be set to split the names into different dll's or so's
+// every dll has his own set of property names
+#include <rtl/ustring.hxx>
+#include <map>
+
+namespace connectivity
+{
+namespace skeleton
+{
+ class OPropertyMap
+ {
+ ::std::map<sal_Int32 , rtl_uString*> m_aPropertyMap;
+
+ ::rtl::OUString fillValue(sal_Int32 _nIndex);
+ public:
+ OPropertyMap()
+ {
+ }
+ ~OPropertyMap();
+ ::rtl::OUString getNameByIndex(sal_Int32 _nIndex) const;
+
+ static OPropertyMap& getPropMap()
+ {
+ static OPropertyMap s_aPropMap;
+ return s_aPropMap;
+ }
+ };
+
+
+ typedef const char* (*PVFN)();
+
+ struct UStringDescription
+ {
+ const char* pZeroTerminatedName;
+ sal_Int32 nLength;
+
+ UStringDescription(PVFN _fCharFkt);
+ operator ::rtl::OUString() const { return ::rtl::OUString(pZeroTerminatedName,nLength,RTL_TEXTENCODING_ASCII_US); }
+ ~UStringDescription();
+ private:
+ UStringDescription();
+ };
+ }
+}
+
+
+#define PROPERTY_ID_QUERYTIMEOUT 1
+#define PROPERTY_ID_MAXFIELDSIZE 2
+#define PROPERTY_ID_MAXROWS 3
+#define PROPERTY_ID_CURSORNAME 4
+#define PROPERTY_ID_RESULTSETCONCURRENCY 5
+#define PROPERTY_ID_RESULTSETTYPE 6
+#define PROPERTY_ID_FETCHDIRECTION 7
+#define PROPERTY_ID_FETCHSIZE 8
+#define PROPERTY_ID_ESCAPEPROCESSING 9
+#define PROPERTY_ID_USEBOOKMARKS 10
+// Column
+#define PROPERTY_ID_NAME 11
+#define PROPERTY_ID_TYPE 12
+#define PROPERTY_ID_TYPENAME 13
+#define PROPERTY_ID_PRECISION 14
+#define PROPERTY_ID_SCALE 15
+#define PROPERTY_ID_ISNULLABLE 16
+#define PROPERTY_ID_ISAUTOINCREMENT 17
+#define PROPERTY_ID_ISROWVERSION 18
+#define PROPERTY_ID_DESCRIPTION 19
+#define PROPERTY_ID_DEFAULTVALUE 20
+
+#define PROPERTY_ID_REFERENCEDTABLE 21
+#define PROPERTY_ID_UPDATERULE 22
+#define PROPERTY_ID_DELETERULE 23
+#define PROPERTY_ID_CATALOG 24
+#define PROPERTY_ID_ISUNIQUE 25
+#define PROPERTY_ID_ISPRIMARYKEYINDEX 26
+#define PROPERTY_ID_ISCLUSTERED 27
+#define PROPERTY_ID_ISASCENDING 28
+#define PROPERTY_ID_SCHEMANAME 29
+#define PROPERTY_ID_CATALOGNAME 30
+
+#define PROPERTY_ID_COMMAND 31
+#define PROPERTY_ID_CHECKOPTION 32
+#define PROPERTY_ID_PASSWORD 33
+#define PROPERTY_ID_RELATEDCOLUMN 34
+
+#define PROPERTY_ID_FUNCTION 35
+#define PROPERTY_ID_TABLENAME 36
+#define PROPERTY_ID_REALNAME 37
+#define PROPERTY_ID_DBASEPRECISIONCHANGED 38
+#define PROPERTY_ID_ISCURRENCY 39
+#define PROPERTY_ID_ISBOOKMARKABLE 40
+
+#define PROPERTY_ID_INVALID_INDEX 41
+#define PROPERTY_ID_ERRORMSG_SEQUENCE 42
+#define PROPERTY_ID_HY010 43
+#define PROPERTY_ID_HY0000 44
+#define PROPERTY_ID_DELIMITER 45
+#define PROPERTY_ID_FORMATKEY 46
+#define PROPERTY_ID_LOCALE 47
+#define PROPERTY_ID_IM001 48
+
+#define PROPERTY_ID_AUTOINCREMENTCREATION 49
+
+#define PROPERTY_ID_PRIVILEGES 50
+
+#endif // INCLUDED_EXAMPLES_DATABASE_DRIVERSKELETON_PROPERTYIDS_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/Database/Makefile b/odk/examples/DevelopersGuide/Database/Makefile
new file mode 100644
index 000000000..a155fcaf5
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Database/Makefile
@@ -0,0 +1,133 @@
+#*************************************************************************
+#
+# The Contents of this file are made available subject to the terms of
+# the BSD license.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+# 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+# contributors may be used to endorse or promote products derived
+# from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+# TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+# USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+#**************************************************************************
+
+# Builds the Database examples of the Developers Guide.
+
+PRJ=../../..
+SETTINGS=$(PRJ)/settings
+
+include $(SETTINGS)/settings.mk
+include $(SETTINGS)/std.mk
+
+# Define non-platform/compiler specific settings
+EXAMPLE_NAME=DataBaseExamples
+OUT_APP_CLASS = $(OUT_CLASS)/$(EXAMPLE_NAME)
+
+APP1_NAME=CodeSamples
+APP1_JAR=$(OUT_APP_CLASS)/$(APP1_NAME).jar
+APP2_NAME=OpenQuery
+APP2_JAR=$(OUT_APP_CLASS)/$(APP2_NAME).jar
+APP3_NAME=RowSet
+APP3_JAR=$(OUT_APP_CLASS)/$(APP3_NAME).jar
+
+APP1_JAVAFILES = \
+ Sales.java \
+ SalesMan.java \
+ CodeSamples.java \
+ sdbcx.java
+
+APP3_JAVAFILES = \
+ RowSetEventListener.java \
+ RowSet.java
+
+APP1_CLASSFILES = $(patsubst %.java,$(OUT_APP_CLASS)/%.class,$(APP1_JAVAFILES))
+APP1_CLASSNAMES = $(patsubst %.java,%.class,$(APP1_JAVAFILES))
+
+APP3_CLASSFILES = $(patsubst %.java,$(OUT_APP_CLASS)/%.class,$(APP3_JAVAFILES))
+APP3_CLASSNAMES = $(patsubst %.java,%.class,$(APP3_JAVAFILES))
+
+SDK_CLASSPATH = $(subst $(EMPTYSTRING) $(PATH_SEPARATOR),$(PATH_SEPARATOR),$(CLASSPATH)\
+ $(PATH_SEPARATOR)$(OUT_APP_CLASS))
+
+# Targets
+.PHONY: ALL
+ALL : \
+ $(EXAMPLE_NAME)
+
+include $(SETTINGS)/stdtarget.mk
+
+$(APP1_CLASSFILES) : $(APP1_JAVAFILES)
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ $(SDK_JAVAC) $(JAVAC_FLAGS) -classpath "$(SDK_CLASSPATH)" -d $(OUT_APP_CLASS) $(APP1_JAVAFILES)
+
+$(APP3_CLASSFILES) : $(APP3_JAVAFILES)
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ $(SDK_JAVAC) $(JAVAC_FLAGS) -classpath "$(SDK_CLASSPATH)" -d $(OUT_APP_CLASS) $(APP3_JAVAFILES)
+
+$(OUT_APP_CLASS)/%.class : %.java
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ $(SDK_JAVAC) $(JAVAC_FLAGS) -classpath "$(SDK_CLASSPATH)" -d $(OUT_APP_CLASS) $<
+
+$(OUT_APP_CLASS)/%.mf :
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ @echo Main-Class: com.sun.star.lib.loader.Loader> $@
+ $(ECHOLINE)>> $@
+ @echo Name: com/sun/star/lib/loader/Loader.class>> $@
+ @echo Application-Class: $*>> $@
+
+$(APP1_JAR) : $(OUT_APP_CLASS)/$(APP1_NAME).mf $(APP1_CLASSFILES)
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ +cd $(subst /,$(PS),$(OUT_APP_CLASS)) && $(SDK_JAR) cvfm $(@F) $(basename $(@F)).mf $(APP1_CLASSNAMES)
+ +$(SDK_JAR) uvf $@ $(SDK_JAVA_UNO_BOOTSTRAP_FILES)
+
+$(APP2_JAR) : $(OUT_APP_CLASS)/$(APP2_NAME).mf $(OUT_APP_CLASS)/$(APP2_NAME).class
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ +cd $(subst /,$(PS),$(OUT_APP_CLASS)) && $(SDK_JAR) cvfm $(@F) $(basename $(@F)).mf $(basename $(@F)).class
+ +$(SDK_JAR) uvf $@ $(SDK_JAVA_UNO_BOOTSTRAP_FILES)
+
+$(APP3_JAR) : $(OUT_APP_CLASS)/$(APP3_NAME).mf $(APP3_CLASSFILES)
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ +cd $(subst /,$(PS),$(OUT_APP_CLASS)) && $(SDK_JAR) cvfm $(@F) $(basename $(@F)).mf $(APP3_CLASSNAMES)
+ +$(SDK_JAR) uvf $@ $(SDK_JAVA_UNO_BOOTSTRAP_FILES)
+
+$(EXAMPLE_NAME) : $(APP1_JAR) $(APP2_JAR) $(APP3_JAR)
+ @echo --------------------------------------------------------------------------------
+ @echo This examples needs a running database with name "$(QM)MYDB0$(QM)". Make sure that you
+ @echo have created such a database and have established a connection to it.
+ @echo Please use one of the following commands to execute the examples!
+ @echo -
+ @echo $(MAKE) CodeSamples.run
+ @echo $(MAKE) OpenQuery.run
+ @echo $(MAKE) RowSet.run
+ @echo --------------------------------------------------------------------------------
+
+%.run: $(OUT_APP_CLASS)/%.jar
+ $(SDK_JAVA) -Dcom.sun.star.lib.loader.unopath="$(OFFICE_PROGRAM_PATH)" -jar $<
+
+.PHONY: clean
+clean :
+ -$(DELRECURSIVE) $(subst /,$(PS),$(OUT_APP_CLASS))
diff --git a/odk/examples/DevelopersGuide/Database/OpenQuery.java b/odk/examples/DevelopersGuide/Database/OpenQuery.java
new file mode 100644
index 000000000..fffae8a2f
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Database/OpenQuery.java
@@ -0,0 +1,143 @@
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.XComponentContext;
+import com.sun.star.lang.XMultiComponentFactory;
+import com.sun.star.beans.XPropertySet;
+
+public class OpenQuery {
+
+ /**
+ * @param args the command line arguments
+ */
+ public static void main(String[] args) {
+ OpenQuery openQuery1 = new OpenQuery();
+ try {
+ openQuery1.openQuery();
+ }
+ catch (java.lang.Exception e){
+ e.printStackTrace();
+ }
+ finally {
+ System.exit(0);
+ }
+ }
+
+ protected void openQuery() throws com.sun.star.uno.Exception, java.lang.Exception {
+ XComponentContext xContext = null;
+ XMultiComponentFactory xMCF = null;
+ try {
+ // get the remote office component context
+ xContext = com.sun.star.comp.helper.Bootstrap.bootstrap();
+ System.out.println("Connected to a running office ...");
+ xMCF = xContext.getServiceManager();
+ }
+ catch( Exception e) {
+ System.err.println("ERROR: can't get a component context from a running office ...");
+ e.printStackTrace();
+ System.exit(1);
+ }
+
+ // first we create our RowSet object and get its XRowSet interface
+ Object rowSet = xMCF.createInstanceWithContext(
+ "com.sun.star.sdb.RowSet", xContext);
+
+ com.sun.star.sdbc.XRowSet xRowSet = UnoRuntime.queryInterface(com.sun.star.sdbc.XRowSet.class, rowSet);
+
+ // set the properties needed to connect to a database
+ XPropertySet xProp = UnoRuntime.queryInterface(XPropertySet.class, xRowSet);
+
+ // the DataSourceName can be a data source registered with [PRODUCTNAME], among other possibilities
+ xProp.setPropertyValue("DataSourceName","Bibliography");
+
+ // the CommandType must be TABLE, QUERY or COMMAND, here we use COMMAND
+ xProp.setPropertyValue("CommandType",Integer.valueOf(com.sun.star.sdb.CommandType.COMMAND));
+
+ // the Command could be a table or query name or a SQL command, depending on the CommandType
+ xProp.setPropertyValue("Command","SELECT IDENTIFIER, AUTHOR FROM biblio ORDER BY IDENTIFIER");
+
+ // if your database requires logon, you can use the properties User and Password
+ // xProp.setPropertyValue("User", "JohnDoe");
+ // xProp.setPropertyValue("Password", "mysecret");
+
+ xRowSet.execute();
+
+ // prepare the XRow and XColumnLocate interface for column access
+ // XRow gets column values
+ com.sun.star.sdbc.XRow xRow = UnoRuntime.queryInterface(
+ com.sun.star.sdbc.XRow.class, xRowSet);
+ // XColumnLocate finds columns by name
+ com.sun.star.sdbc.XColumnLocate xLoc = UnoRuntime.queryInterface(
+ com.sun.star.sdbc.XColumnLocate.class, xRowSet);
+
+ // print output header
+ System.out.println("Identifier\tAuthor");
+ System.out.println("----------\t------");
+
+ // output result rows
+ while ( xRowSet.next() ) {
+ String ident = xRow.getString(xLoc.findColumn("IDENTIFIER"));
+ String author = xRow.getString(xLoc.findColumn("AUTHOR"));
+ System.out.println(ident + "\t\t" + author);
+ }
+
+ // XResultSetUpdate for insertRow handling
+ com.sun.star.sdbc.XResultSetUpdate xResultSetUpdate = UnoRuntime.queryInterface(
+ com.sun.star.sdbc.XResultSetUpdate.class, xRowSet);
+
+ // XRowUpdate for row updates
+ com.sun.star.sdbc.XRowUpdate xRowUpdate = UnoRuntime.queryInterface(
+ com.sun.star.sdbc.XRowUpdate.class, xRowSet);
+
+ // move to insertRow buffer
+ xResultSetUpdate.moveToInsertRow();
+
+ // edit insertRow buffer
+ xRowUpdate.updateString(xLoc.findColumn("IDENTIFIER"), "GOF95");
+ xRowUpdate.updateString(xLoc.findColumn("AUTHOR"), "Gamma, Helm, Johnson, Vlissides");
+
+ // write buffer to database
+ xResultSetUpdate.insertRow();
+
+ // throw away the row set
+ com.sun.star.lang.XComponent xComp = UnoRuntime.queryInterface(
+ com.sun.star.lang.XComponent.class, xRowSet);
+ xComp.dispose();
+ }
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/Database/RowSet.java b/odk/examples/DevelopersGuide/Database/RowSet.java
new file mode 100644
index 000000000..e053dabb9
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Database/RowSet.java
@@ -0,0 +1,225 @@
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+import com.sun.star.lang.XMultiComponentFactory;
+import com.sun.star.lang.XComponent;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.XComponentContext;
+import com.sun.star.beans.XPropertySet;
+import com.sun.star.sdbc.*;
+import com.sun.star.sdbcx.Privilege;
+import com.sun.star.sdb.XRowSetApproveBroadcaster;
+
+public class RowSet
+{
+ private static XComponentContext xContext = null;
+ private static XMultiComponentFactory xMCF = null;
+ public static void main(String argv[]) throws java.lang.Exception
+ {
+ try {
+ // get the remote office component context
+ xContext = com.sun.star.comp.helper.Bootstrap.bootstrap();
+ System.out.println("Connected to a running office ...");
+ xMCF = xContext.getServiceManager();
+ }
+ catch( Exception e) {
+ System.err.println("ERROR: can't get a component context from a running office ...");
+ e.printStackTrace(System.err);
+ System.exit(1);
+ }
+
+ try{
+ showRowSetEvents();
+ showRowSetRowCount();
+ showRowSetPrivileges();
+ useRowSet();
+ }
+ catch(com.sun.star.uno.Exception e)
+ {
+ System.err.println(e);
+ e.printStackTrace();
+ }
+ System.exit(0);
+ }
+
+
+
+ private static void useRowSet() throws com.sun.star.uno.Exception
+ {
+ // first we create our RowSet object
+ XRowSet xRowRes = UnoRuntime.queryInterface(
+ XRowSet.class,
+ xMCF.createInstanceWithContext("com.sun.star.sdb.RowSet", xContext));
+
+ System.out.println("RowSet created!");
+ // set the properties needed to connect to a database
+ XPropertySet xProp = UnoRuntime.queryInterface(XPropertySet.class,xRowRes);
+ xProp.setPropertyValue("DataSourceName","Bibliography");
+ xProp.setPropertyValue("Command","biblio");
+ xProp.setPropertyValue("CommandType",Integer.valueOf(com.sun.star.sdb.CommandType.TABLE));
+
+ xRowRes.execute();
+ System.out.println("RowSet executed!");
+
+
+ XComponent xComp = UnoRuntime.queryInterface(XComponent.class,xRowRes);
+ xComp.dispose();
+ System.out.println("RowSet destroyed!");
+ }
+
+ private static void showRowSetPrivileges() throws com.sun.star.uno.Exception
+ {
+ // first we create our RowSet object
+ XRowSet xRowRes = UnoRuntime.queryInterface(
+ XRowSet.class,
+ xMCF.createInstanceWithContext("com.sun.star.sdb.RowSet", xContext));
+
+ System.out.println("RowSet created!");
+ // set the properties needed to connect to a database
+ XPropertySet xProp = UnoRuntime.queryInterface(XPropertySet.class,xRowRes);
+ xProp.setPropertyValue("DataSourceName","Bibliography");
+ xProp.setPropertyValue("Command","biblio");
+ xProp.setPropertyValue("CommandType",Integer.valueOf(com.sun.star.sdb.CommandType.TABLE));
+
+ xRowRes.execute();
+ System.out.println("RowSet executed!");
+
+ Integer aPriv = (Integer)xProp.getPropertyValue("Privileges");
+ int nPriv = aPriv.intValue();
+ if( (nPriv & Privilege.SELECT) == Privilege.SELECT)
+ System.out.println("SELECT");
+ if( (nPriv & Privilege.INSERT) == Privilege.INSERT)
+ System.out.println("INSERT");
+ if( (nPriv & Privilege.UPDATE) == Privilege.UPDATE)
+ System.out.println("UPDATE");
+ if( (nPriv & Privilege.DELETE) == Privilege.DELETE)
+ System.out.println("DELETE");
+
+ // now destroy the RowSet
+ XComponent xComp = UnoRuntime.queryInterface(XComponent.class,xRowRes);
+ xComp.dispose();
+ System.out.println("RowSet destroyed!");
+ }
+
+ private static void showRowSetRowCount() throws com.sun.star.uno.Exception
+ {
+ // first we create our RowSet object
+ XRowSet xRowRes = UnoRuntime.queryInterface(
+ XRowSet.class,
+ xMCF.createInstanceWithContext("com.sun.star.sdb.RowSet", xContext));
+
+ System.out.println("RowSet created!");
+ // set the properties needed to connect to a database
+ XPropertySet xProp = UnoRuntime.queryInterface(XPropertySet.class,xRowRes);
+ xProp.setPropertyValue("DataSourceName","Bibliography");
+ xProp.setPropertyValue("Command","biblio");
+ xProp.setPropertyValue("CommandType",Integer.valueOf(com.sun.star.sdb.CommandType.TABLE));
+
+ xRowRes.execute();
+ System.out.println("RowSet executed!");
+
+ // now look if the RowCount is already final
+ System.out.println("The RowCount is final: " + xProp.getPropertyValue("IsRowCountFinal"));
+
+ XResultSet xRes = UnoRuntime.queryInterface(XResultSet.class,xRowRes);
+ xRes.last();
+
+ System.out.println("The RowCount is final: " + xProp.getPropertyValue("IsRowCountFinal"));
+ System.out.println("There are " + xProp.getPropertyValue("RowCount") + " rows!");
+
+ // now destroy the RowSet
+ XComponent xComp = UnoRuntime.queryInterface(XComponent.class,xRowRes);
+ xComp.dispose();
+ System.out.println("RowSet destroyed!");
+ }
+
+ private static void showRowSetEvents() throws com.sun.star.uno.Exception
+ {
+ // first we create our RowSet object
+ XRowSet xRowRes = UnoRuntime.queryInterface(
+ XRowSet.class,
+ xMCF.createInstanceWithContext("com.sun.star.sdb.RowSet", xContext));
+
+ System.out.println("RowSet created!");
+ // add our Listener
+ System.out.println("Append our Listener!");
+ RowSetEventListener pRow = new RowSetEventListener();
+ XRowSetApproveBroadcaster xApBroad = UnoRuntime.queryInterface(XRowSetApproveBroadcaster.class,xRowRes);
+ xApBroad.addRowSetApproveListener(pRow);
+ xRowRes.addRowSetListener(pRow);
+
+ // set the properties needed to connect to a database
+ XPropertySet xProp = UnoRuntime.queryInterface(XPropertySet.class,xRowRes);
+ xProp.setPropertyValue("DataSourceName","Bibliography");
+ xProp.setPropertyValue("Command","biblio");
+ xProp.setPropertyValue("CommandType",Integer.valueOf(com.sun.star.sdb.CommandType.TABLE));
+
+ xRowRes.execute();
+ System.out.println("RowSet executed!");
+
+ // do some movements to check if we got all notifications
+ XResultSet xRes = UnoRuntime.queryInterface(XResultSet.class,xRowRes);
+ System.out.println("beforeFirst");
+ xRes.beforeFirst();
+ // this should lead to no notifications because
+ // we should stand before the first row at the beginning
+ System.out.println("We stand before the first row: " + xRes.isBeforeFirst());
+
+ System.out.println("next");
+ xRes.next();
+ System.out.println("next");
+ xRes.next();
+ System.out.println("last");
+ xRes.last();
+ System.out.println("next");
+ xRes.next();
+ System.out.println("We stand after the last row: " + xRes.isAfterLast());
+ System.out.println("first");
+ xRes.first();
+ System.out.println("previous");
+ xRes.previous();
+ System.out.println("We stand before the first row: " + xRes.isBeforeFirst());
+ System.out.println("afterLast");
+ xRes.afterLast();
+ System.out.println("We stand after the last row: " + xRes.isAfterLast());
+
+ // now destroy the RowSet
+ XComponent xComp = UnoRuntime.queryInterface(XComponent.class,xRowRes);
+ xComp.dispose();
+ System.out.println("RowSet destroyed!");
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/Database/RowSetEventListener.java b/odk/examples/DevelopersGuide/Database/RowSetEventListener.java
new file mode 100644
index 000000000..785164d25
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Database/RowSetEventListener.java
@@ -0,0 +1,80 @@
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+import com.sun.star.sdb.XRowSetApproveListener;
+import com.sun.star.sdbc.XRowSetListener;
+import com.sun.star.sdb.RowChangeEvent;
+import com.sun.star.lang.EventObject;
+
+public class RowSetEventListener implements XRowSetApproveListener,XRowSetListener
+{
+ // XEventListener
+ public void disposing(com.sun.star.lang.EventObject event)
+ {
+ System.out.println("RowSet will be destroyed!");
+ }
+ // XRowSetApproveBroadcaster
+ public boolean approveCursorMove(EventObject event)
+ {
+ System.out.println("Before CursorMove!");
+ return true;
+ }
+ public boolean approveRowChange(RowChangeEvent event)
+ {
+ System.out.println("Before row change!");
+ return true;
+ }
+ public boolean approveRowSetChange(EventObject event)
+ {
+ System.out.println("Before RowSet change!");
+ return true;
+ }
+
+ // XRowSetListener
+ public void cursorMoved(com.sun.star.lang.EventObject event)
+ {
+ System.out.println("Cursor moved!");
+ }
+ public void rowChanged(com.sun.star.lang.EventObject event)
+ {
+ System.out.println("Row changed!");
+ }
+ public void rowSetChanged(com.sun.star.lang.EventObject event)
+ {
+ System.out.println("RowSet changed!");
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/Database/Sales.java b/odk/examples/DevelopersGuide/Database/Sales.java
new file mode 100644
index 000000000..f50e21595
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Database/Sales.java
@@ -0,0 +1,130 @@
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+import com.sun.star.uno.*;
+import com.sun.star.beans.XPropertySet;
+import com.sun.star.sdbc.*;
+
+public class Sales
+{
+ private final XConnection con;
+
+ public Sales(XConnection connection )
+ {
+ con = connection;
+ }
+ // create the table sales.
+ public void createSalesTable() throws com.sun.star.uno.Exception
+ {
+ String createTableSales = "CREATE TABLE SALES " +
+ "(SALENR INTEGER NOT NULL, " +
+ " COS_NR INTEGER, " +
+ " SNR INTEGER, " +
+ " NAME VARCHAR(50)," +
+ " SALEDATE DATE," +
+ " PRICE FLOAT(10), " +
+ " PRIMARY KEY(SALENR)" +
+ " )";
+ XStatement stmt = con.createStatement();
+ stmt.executeUpdate( createTableSales );
+ }
+
+ // drop the table sales.
+ public void dropSalesTable() throws com.sun.star.uno.Exception
+ {
+ String createTableSalesman = "DROP TABLE SALES ";
+ XStatement stmt = con.createStatement();
+ stmt.executeUpdate( createTableSalesman );
+ }
+
+ // insert data into the table sales.
+ public void insertDataIntoSales() throws com.sun.star.uno.Exception
+ {
+ XStatement stmt = con.createStatement();
+ stmt.executeUpdate("INSERT INTO SALES " +
+ "VALUES (1, '100', '1','Linux','2001-02-12',15)");
+ stmt.executeUpdate("INSERT INTO SALES " +
+ "VALUES (2, '101', '2','Beef','2001-10-18',15.78)");
+ stmt.executeUpdate("INSERT INTO SALES " +
+ "VALUES (3, '104', '4','orange juice','2001-08-09',1.5)");
+ }
+
+ // update the table sales with a prepared statement.
+ public void updateSales() throws com.sun.star.uno.Exception
+ {
+ XStatement stmt = con.createStatement();
+ String updateString = "UPDATE SALES " +
+ "SET PRICE = 30 " +
+ "WHERE SALENR = 1";
+ stmt.executeUpdate(updateString);
+ }
+
+ // retrieve the data of the table sales.
+ public void retrieveSalesData() throws com.sun.star.uno.Exception
+ {
+ XStatement stmt = con.createStatement();
+ String query = "SELECT NAME, PRICE FROM SALES " +
+ "WHERE SALENR = 1";
+ XResultSet rs = stmt.executeQuery(query);
+ XRow row = UnoRuntime.queryInterface(XRow.class, rs);
+ while (rs.next()) {
+ String s = row.getString(1);
+ float n = row.getFloat(2);
+ System.out.println("The current price for " + s + " is: $" + n + ".");
+ }
+ }
+
+
+
+ // displays the column names
+ public void displayColumnNames() throws com.sun.star.uno.Exception
+ {
+ XStatement stmt = con.createStatement();
+ XPropertySet xProp = UnoRuntime.queryInterface(XPropertySet.class,stmt);
+ xProp.setPropertyValue("ResultSetType", Integer.valueOf(ResultSetType.SCROLL_INSENSITIVE));
+ xProp.setPropertyValue("ResultSetConcurrency", Integer.valueOf(ResultSetConcurrency.READ_ONLY));
+ XResultSet rs = stmt.executeQuery("SELECT NAME, PRICE FROM SALES");
+ XResultSetMetaDataSupplier xRsMetaSup = UnoRuntime.queryInterface(XResultSetMetaDataSupplier.class,rs);
+ XResultSetMetaData xRsMetaData = xRsMetaSup.getMetaData();
+ int nColumnCount = xRsMetaData.getColumnCount();
+ for(int i=1 ; i <= nColumnCount ; ++i)
+ {
+ System.out.println("Name: " + xRsMetaData.getColumnName(i) + " Type: " +
+ xRsMetaData.getColumnType(i));
+ }
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/Database/SalesMan.java b/odk/examples/DevelopersGuide/Database/SalesMan.java
new file mode 100644
index 000000000..db00ef75a
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Database/SalesMan.java
@@ -0,0 +1,137 @@
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+import com.sun.star.uno.*;
+import com.sun.star.util.Date;
+import com.sun.star.sdbc.*;
+
+public class SalesMan
+{
+ private final XConnection con;
+
+ public SalesMan(XConnection connection )
+ {
+ con = connection;
+ }
+ // create the table salesman.
+ public void createSalesManTable() throws com.sun.star.uno.Exception
+ {
+ String createTableSalesman = "CREATE TABLE SALESMAN " +
+ "(SNR INTEGER NOT NULL, "+
+ " FIRSTNAME VARCHAR(50)," +
+ " LASTNAME VARCHAR(100)," +
+ " STREET VARCHAR(50)," +
+ " STATE VARCHAR(50)," +
+ " ZIP INTEGER," +
+ " BIRTHDATE DATE," +
+ " PRIMARY KEY(SNR)" +
+ " )";
+ XStatement stmt = con.createStatement();
+ stmt.executeUpdate( createTableSalesman );
+ }
+
+ // drop the table salesman
+ public void dropSalesManTable() throws com.sun.star.uno.Exception
+ {
+ String createTableSalesman = "DROP TABLE SALESMAN ";
+ XStatement stmt = con.createStatement();
+ stmt.executeUpdate( createTableSalesman );
+ }
+
+ // insert data into the table salesman
+ public void insertDataIntoSalesMan() throws com.sun.star.uno.Exception
+ {
+ XStatement stmt = con.createStatement();
+ stmt.executeUpdate("INSERT INTO SALESMAN " +
+ "VALUES (1, 'Joseph', 'Smith','Bond Street','CA',95460,"
+ + "'1946-07-02')");
+ stmt.executeUpdate("INSERT INTO SALESMAN " +
+ "VALUES (2, 'Frank', 'Jones','Lake Silver','CA',95460,"
+ + "'1963-12-24')");
+ stmt.executeUpdate("INSERT INTO SALESMAN " +
+ "VALUES (3, 'Jane', 'Esperansa','23 Hollywood drive','CA',95460,"
+ + "'1972-04-01')");
+ stmt.executeUpdate("INSERT INTO SALESMAN " +
+ "VALUES (4, 'George', 'Flint','12 Washington street','CA',95460,"
+ + "'1953-02-13')");
+ stmt.executeUpdate("INSERT INTO SALESMAN " +
+ "VALUES (5, 'Bob', 'Meyers','2 Moon way','CA',95460,"
+ + "'1949-09-07')");
+ }
+
+ // update the table sales man with a prepared statement.
+ public void updateSalesMan() throws com.sun.star.uno.Exception
+ {
+ XPreparedStatement updateStreet = con.prepareStatement(
+ "UPDATE SALESMAN SET STREET = ? WHERE SNR = ?");
+ XParameters setPara = UnoRuntime.queryInterface(XParameters.class,updateStreet);
+ setPara.setString(1, "34 Main Road");
+ setPara.setInt(2, 1);
+ updateStreet.executeUpdate();
+
+ setPara.setString(1, "Marryland");
+ setPara.setInt(2, 4);
+ updateStreet.executeUpdate();
+ // changes STREET column of salesman George to Marryland
+ setPara.setString(1, "Michigan road");
+ updateStreet.executeUpdate();
+ // changes again STREET column of salesman George to
+ // Michigan road
+ // parameter 2 stayed 4, and the first parameter was reset
+ // to "Michigan road")
+
+ setPara.setString(1, "Bond Street");
+ setPara.setInt(2, 3);
+ int n = updateStreet.executeUpdate();
+ System.out.println("executeUpdate returns: " + n);
+ // n = 1 because one row had a change in it
+ }
+
+ // retrieve the data of the table salesman
+ public void retrieveSalesManData() throws com.sun.star.uno.Exception
+ {
+ XStatement stmt = con.createStatement();
+ XResultSet rs = stmt.executeQuery("SELECT FIRSTNAME, LASTNAME, BIRTHDATE FROM SALESMAN");
+ XRow row = UnoRuntime.queryInterface(XRow.class,rs);
+ while ( rs != null && rs.next() ) {
+ String fn = row.getString( 1 );
+ String ln = row.getString( 2 );
+ Date dt = row.getDate( 3 );
+ System.out.println(fn + " " + ln + " " + dt.Month + "/" + dt.Day + "/" + dt.Year);
+ }
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/Database/sdbcx.java b/odk/examples/DevelopersGuide/Database/sdbcx.java
new file mode 100644
index 000000000..8d7bcab93
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Database/sdbcx.java
@@ -0,0 +1,420 @@
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+import com.sun.star.lang.XComponent;
+import com.sun.star.uno.*;
+import com.sun.star.bridge.XUnoUrlResolver;
+import com.sun.star.beans.XPropertySet;
+import com.sun.star.container.XNameAccess;
+import com.sun.star.container.XIndexAccess;
+import com.sun.star.sdbc.*;
+import com.sun.star.sdbcx.*;
+import com.sun.star.lang.XMultiServiceFactory;
+
+public class sdbcx
+{
+ private final XMultiServiceFactory xORB;
+ private static XConnection con;
+ private XTablesSupplier xTabSup;
+
+ public static XMultiServiceFactory rSmgr;
+
+ public static void main(String argv[]) throws java.lang.Exception
+ {
+ try{
+ rSmgr = connect("socket,host=localhost,port=8100");
+ sdbcx test = new sdbcx(rSmgr);
+ test.createConnection();
+ test.displayTableProperties();
+ // now we dispose the connection to close it
+ XComponent xComponent = UnoRuntime.queryInterface(XComponent.class,con);
+ if(xComponent != null)
+ {
+ xComponent.dispose();
+ System.out.println("Connection disposed!");
+ }
+ }
+ catch(com.sun.star.uno.Exception e)
+ {
+ System.out.println(e);
+ e.printStackTrace();
+ }
+ System.exit(0);
+ }
+ public static XMultiServiceFactory connect( String connectStr )
+ throws com.sun.star.uno.Exception,
+ com.sun.star.uno.RuntimeException, java.lang.Exception
+ {
+ // initial serviceManager
+ XMultiServiceFactory xLocalServiceManager =
+ com.sun.star.comp.helper.Bootstrap.createSimpleServiceManager();
+
+ // create a connector, so that it can contact the office
+ Object xUrlResolver = xLocalServiceManager.createInstance( "com.sun.star.bridge.UnoUrlResolver" );
+ XUnoUrlResolver urlResolver = UnoRuntime.queryInterface(
+ XUnoUrlResolver.class, xUrlResolver );
+
+ Object rInitialObject = urlResolver.resolve( "uno:" + connectStr + ";urp;StarOffice.NamingService" );
+
+ XNamingService rName = UnoRuntime.queryInterface(
+ XNamingService.class, rInitialObject );
+
+ XMultiServiceFactory xMSF = null;
+ if( rName != null ) {
+ System.err.println( "got the remote naming service !" );
+ Object rXsmgr = rName.getRegisteredObject("StarOffice.ServiceManager" );
+
+ xMSF = UnoRuntime.queryInterface( XMultiServiceFactory.class, rXsmgr );
+ }
+
+ return xMSF;
+ }
+
+
+ public sdbcx(XMultiServiceFactory rSmgr )
+ {
+ xORB = rSmgr;
+ }
+
+ public void createConnection() throws com.sun.star.uno.Exception
+ {
+ // create the Driver with the implementation name
+ Object aDriver = xORB.createInstance("org.openoffice.comp.connectivity.pq.Driver.noext");
+ // query for the interface
+ com.sun.star.sdbc.XDriver xDriver;
+ xDriver = UnoRuntime.queryInterface(XDriver.class,aDriver);
+ if(xDriver != null)
+ {
+ // first create the needed url
+ String URL = "sdbc:postgresql:dbname=MYDB0";
+ // second create the necessary properties
+ com.sun.star.beans.PropertyValue [] Props = new com.sun.star.beans.PropertyValue[]
+ {
+ new com.sun.star.beans.PropertyValue("user",0,"test1",com.sun.star.beans.PropertyState.DIRECT_VALUE),
+ new com.sun.star.beans.PropertyValue("password",0,"test1",com.sun.star.beans.PropertyState.DIRECT_VALUE)
+ };
+
+ // now create a connection to the database
+ con = xDriver.connect(URL, Props);
+ if(con != null)
+ {
+ System.out.println("Connection could be created!");
+ // with the XDatabaseDefinitionSupplier interface from the driver to get the XTablesSupplier
+ XDataDefinitionSupplier xDDSup = UnoRuntime.queryInterface(
+ XDataDefinitionSupplier.class,xDriver);
+ if(xDDSup != null)
+ {
+ xTabSup = xDDSup.getDataDefinitionByConnection(con);
+ if(xTabSup != null)
+ {
+ XNameAccess xTables = xTabSup.getTables();
+ // now print all table names
+ System.out.println("Tables available:");
+ String [] aTableNames = xTables.getElementNames();
+ for ( int i =0; i<= aTableNames.length-1; i++)
+ System.out.println(aTableNames[i]);
+ }
+ }
+ else
+ System.out.println("The driver is not a SDBCX capable!");
+ }
+ else
+ System.out.println("Connection could not be created!");
+ }
+ }
+
+ public void displayTableProperties() throws com.sun.star.uno.Exception
+ {
+ XNameAccess xTables = xTabSup.getTables();
+ String [] aTableNames = xTables.getElementNames();
+ if(0 != aTableNames.length)
+ {
+ Object table = xTables.getByName(aTableNames[0]);
+ XPropertySet xProp = UnoRuntime.queryInterface(XPropertySet.class,table);
+ System.out.println("Name: " + xProp.getPropertyValue("Name"));
+ System.out.println("CatalogName: " + xProp.getPropertyValue("CatalogName"));
+ System.out.println("SchemaName: " + xProp.getPropertyValue("SchemaName"));
+ System.out.println("Description: " + xProp.getPropertyValue("Description"));
+ // the following property is optional so we first must check if it exists
+ if(xProp.getPropertySetInfo().hasPropertyByName("Type"))
+ System.out.println("Type: " + xProp.getPropertyValue("Type"));
+ }
+ }
+
+
+ // 15. example
+ // print all columns of a XColumnsSupplier
+
+ public static void printColumns(XColumnsSupplier xColumnsSup)
+ {
+ System.out.println("Example printColumns");
+ // the table must be at least support a XColumnsSupplier interface
+ System.out.println("--- Columns ---");
+ XNameAccess xColumns = xColumnsSup.getColumns();
+ String [] aColumnNames = xColumns.getElementNames();
+ for ( int i =0; i<= aColumnNames.length-1; i++)
+ System.out.println(" " + aColumnNames[i]);
+ }
+
+ // 16. example
+ // print all keys inclusive the columns of a key
+
+ public static void printKeys(XColumnsSupplier xColumnsSup) throws com.sun.star.uno.Exception
+ {
+ System.out.println("Example printKeys");
+ XKeysSupplier xKeysSup = UnoRuntime.queryInterface(XKeysSupplier.class,xColumnsSup);
+ if(xKeysSup != null)
+ {
+ System.out.println("--- Keys ---");
+ XIndexAccess xKeys = xKeysSup.getKeys();
+ for ( int i =0; i < xKeys.getCount(); i++)
+ {
+ Object key = xKeys.getByIndex(i);
+ XPropertySet xProp = UnoRuntime.queryInterface(XPropertySet.class,key);
+ System.out.println(" " + xProp.getPropertyValue("Name"));
+ XColumnsSupplier xKeyColumnsSup = UnoRuntime.queryInterface(XColumnsSupplier.class,xProp);
+ printColumns(xKeyColumnsSup);
+ }
+ }
+ }
+
+ // 17. example
+ // print all keys inclusive the columns of a key
+
+ public static void printIndexes(XColumnsSupplier xColumnsSup) throws com.sun.star.uno.Exception
+ {
+ System.out.println("Example printIndexes");
+ XIndexesSupplier xIndexesSup = UnoRuntime.queryInterface(XIndexesSupplier.class,xColumnsSup);
+ if(xIndexesSup != null)
+ {
+ System.out.println("--- Indexes ---");
+ XNameAccess xIndexs = xIndexesSup.getIndexes();
+ String [] aIndexNames = xIndexs.getElementNames();
+ for ( int i =0; i<= aIndexNames.length-1; i++)
+ {
+ System.out.println(" " + aIndexNames[i]);
+ Object index = xIndexs.getByName(aIndexNames[i]);
+ XColumnsSupplier xIndexColumnsSup = UnoRuntime.queryInterface(XColumnsSupplier.class,index);
+ printColumns(xIndexColumnsSup);
+ }
+ }
+ }
+
+
+ // 18. example
+ // column properties
+
+ public static void printColumnProperties(Object column) throws com.sun.star.uno.Exception
+ {
+ System.out.println("Example printColumnProperties");
+ XPropertySet xProp = UnoRuntime.queryInterface(XPropertySet.class,column);
+ System.out.println("Name: " + xProp.getPropertyValue("Name"));
+ System.out.println("Type: " + xProp.getPropertyValue("Type"));
+ System.out.println("TypeName: " + xProp.getPropertyValue("TypeName"));
+ System.out.println("Precision: " + xProp.getPropertyValue("Precision"));
+ System.out.println("Scale: " + xProp.getPropertyValue("Scale"));
+ System.out.println("IsNullable: " + xProp.getPropertyValue("IsNullable"));
+ System.out.println("IsAutoIncrement: " + xProp.getPropertyValue("IsAutoIncrement"));
+ System.out.println("IsCurrency: " + xProp.getPropertyValue("IsCurrency"));
+ // the following property is optional so we first must check if it exists
+ if(xProp.getPropertySetInfo().hasPropertyByName("IsRowVersion"))
+ System.out.println("IsRowVersion: " + xProp.getPropertyValue("IsRowVersion"));
+ if(xProp.getPropertySetInfo().hasPropertyByName("Description"))
+ System.out.println("Description: " + xProp.getPropertyValue("Description"));
+ if(xProp.getPropertySetInfo().hasPropertyByName("DefaultValue"))
+ System.out.println("DefaultValue: " + xProp.getPropertyValue("DefaultValue"));
+ }
+
+
+ // 19. example
+ // index properties
+
+ public static void printIndexProperties(Object index) throws com.sun.star.uno.Exception
+ {
+ System.out.println("Example printIndexProperties");
+ XPropertySet xProp = UnoRuntime.queryInterface(XPropertySet.class,index);
+ System.out.println("Name: " + xProp.getPropertyValue("Name"));
+ System.out.println("Catalog: " + xProp.getPropertyValue("Catalog"));
+ System.out.println("IsUnique: " + xProp.getPropertyValue("IsUnique"));
+ System.out.println("IsPrimaryKeyIndex: " + xProp.getPropertyValue("IsPrimaryKeyIndex"));
+ System.out.println("IsClustered: " + xProp.getPropertyValue("IsClustered"));
+ }
+
+
+ // 20. example
+ // key properties
+
+ public static void printKeyProperties(Object key) throws com.sun.star.uno.Exception
+ {
+ System.out.println("Example printKeyProperties");
+ XPropertySet xProp = UnoRuntime.queryInterface(XPropertySet.class,key);
+ System.out.println("Name: " + xProp.getPropertyValue("Name"));
+ System.out.println("Type: " + xProp.getPropertyValue("Type"));
+ System.out.println("ReferencedTable: " + xProp.getPropertyValue("ReferencedTable"));
+ System.out.println("UpdateRule: " + xProp.getPropertyValue("UpdateRule"));
+ System.out.println("DeleteRule: " + xProp.getPropertyValue("DeleteRule"));
+ }
+
+
+ // 21. example
+ // print all groups and the users with their privileges who belong to this group
+
+ public static void printGroups(XTablesSupplier xTabSup) throws com.sun.star.uno.Exception,SQLException
+ {
+ System.out.println("Example printGroups");
+ XGroupsSupplier xGroupsSup = UnoRuntime.queryInterface(XGroupsSupplier.class,xTabSup);
+ if(xGroupsSup != null)
+ {
+ // the table must be at least support a XColumnsSupplier interface
+ System.out.println("--- Groups ---");
+ XNameAccess xGroups = xGroupsSup.getGroups();
+ String [] aGroupNames = xGroups.getElementNames();
+ for ( int i =0; i < aGroupNames.length; i++)
+ {
+ System.out.println(" " + aGroupNames[i]);
+ XUsersSupplier xUsersSup = UnoRuntime.queryInterface(XUsersSupplier.class,xGroups.getByName(aGroupNames[i]));
+ if(xUsersSup != null)
+ {
+ XAuthorizable xAuth = UnoRuntime.queryInterface(XAuthorizable.class,xUsersSup);
+ // the table must be at least support a XColumnsSupplier interface
+ System.out.println("\t--- Users ---");
+ XNameAccess xUsers = xUsersSup.getUsers();
+ String [] aUserNames = xUsers.getElementNames();
+ for ( int j =0; j < aUserNames.length; j++)
+ {
+ System.out.println("\t " + aUserNames[j] + " Privileges: " + xAuth.getPrivileges(aUserNames[j],PrivilegeObject.TABLE));
+ }
+ }
+ }
+ }
+ }
+
+
+ // 22. example
+ // create the table salesmen
+
+ public static void createTableSalesMen(XNameAccess xTables) throws com.sun.star.uno.Exception,SQLException
+ {
+ System.out.println("Example createTableSalesMen");
+ XDataDescriptorFactory xTabFac = UnoRuntime.queryInterface(XDataDescriptorFactory.class,xTables);
+ if(xTabFac != null)
+ {
+ // create the new table
+ XPropertySet xTable = xTabFac.createDataDescriptor();
+ // set the name of the new table
+ xTable.setPropertyValue("Name","SALESMAN");
+ // append the columns
+ XColumnsSupplier xColumSup = UnoRuntime.queryInterface(XColumnsSupplier.class,xTable);
+ XDataDescriptorFactory xColFac = UnoRuntime.queryInterface(XDataDescriptorFactory.class,xColumSup.getColumns());
+ XAppend xAppend = UnoRuntime.queryInterface(XAppend.class,xColFac);
+ // we only need one descriptor
+ XPropertySet xCol = xColFac.createDataDescriptor();
+ // create first column and append
+ xCol.setPropertyValue("Name","SNR");
+ xCol.setPropertyValue("Type",Integer.valueOf(DataType.INTEGER));
+ xCol.setPropertyValue("IsNullable",Integer.valueOf(ColumnValue.NO_NULLS));
+ xAppend.appendByDescriptor(xCol);
+ // 2nd only set the properties which differs
+ xCol.setPropertyValue("Name","FIRSTNAME");
+ xCol.setPropertyValue("Type",Integer.valueOf(DataType.VARCHAR));
+ xCol.setPropertyValue("IsNullable",Integer.valueOf(ColumnValue.NULLABLE));
+ xCol.setPropertyValue("Precision",Integer.valueOf(50));
+ xAppend.appendByDescriptor(xCol);
+ // 3nd only set the properties which differs
+ xCol.setPropertyValue("Name","LASTNAME");
+ xCol.setPropertyValue("Precision",Integer.valueOf(100));
+ xAppend.appendByDescriptor(xCol);
+ // 4nd only set the properties which differs
+ xCol.setPropertyValue("Name","STREET");
+ xCol.setPropertyValue("Precision",Integer.valueOf(50));
+ xAppend.appendByDescriptor(xCol);
+ // 5nd only set the properties which differs
+ xCol.setPropertyValue("Name","STATE");
+ xAppend.appendByDescriptor(xCol);
+ // 6nd only set the properties which differs
+ xCol.setPropertyValue("Name","ZIP");
+ xCol.setPropertyValue("Type",Integer.valueOf(DataType.INTEGER));
+ xCol.setPropertyValue("Precision",Integer.valueOf(10)); // default value integer
+ xAppend.appendByDescriptor(xCol);
+ // 7nd only set the properties which differs
+ xCol.setPropertyValue("Name","BIRTHDATE");
+ xCol.setPropertyValue("Type",Integer.valueOf(DataType.DATE));
+ xCol.setPropertyValue("Precision",Integer.valueOf(10)); // default value integer
+ xAppend.appendByDescriptor(xCol);
+ // now we create the primary key
+ XKeysSupplier xKeySup = UnoRuntime.queryInterface(XKeysSupplier.class,xTable);
+ XDataDescriptorFactory xKeyFac = UnoRuntime.queryInterface(XDataDescriptorFactory.class,xKeySup.getKeys());
+ XAppend xKeyAppend = UnoRuntime.queryInterface(XAppend.class,xKeyFac);
+ XPropertySet xKey = xKeyFac.createDataDescriptor();
+ xKey.setPropertyValue("Type",Integer.valueOf(KeyType.PRIMARY));
+ // now append the columns to key
+ XColumnsSupplier xKeyColumSup = UnoRuntime.queryInterface(XColumnsSupplier.class,xKey);
+ XDataDescriptorFactory xKeyColFac = UnoRuntime.queryInterface(XDataDescriptorFactory.class,xKeyColumSup.getColumns());
+ XAppend xKeyColAppend = UnoRuntime.queryInterface(XAppend.class,xKeyColFac);
+ // we only need one descriptor
+ XPropertySet xKeyCol = xKeyColFac.createDataDescriptor();
+ xKeyCol.setPropertyValue("Name","SNR");
+ // append the key column
+ xKeyColAppend.appendByDescriptor(xKeyCol);
+ // append the key
+ xKeyAppend.appendByDescriptor(xKey);
+ // the last step is to append the new table to the tables collection
+ XAppend xTableAppend = UnoRuntime.queryInterface(XAppend.class,xTabFac);
+ xTableAppend.appendByDescriptor(xTable);
+ }
+ }
+
+
+ // 23. example
+ // create a user
+
+ public static void createUser(XNameAccess xUsers) throws com.sun.star.uno.Exception,SQLException
+ {
+ System.out.println("Example createUser");
+ XDataDescriptorFactory xUserFac = UnoRuntime.queryInterface(XDataDescriptorFactory.class,xUsers);
+ if(xUserFac != null)
+ {
+ // create the new table
+ XPropertySet xUser = xUserFac.createDataDescriptor();
+ // set the name of the new table
+ xUser.setPropertyValue("Name","BOSS");
+ xUser.setPropertyValue("Password","BOSSWIFENAME");
+ XAppend xAppend = UnoRuntime.queryInterface(XAppend.class,xUserFac);
+ xAppend.appendByDescriptor(xUser);
+ }
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/Drawing/ChangeOrderDemo.java b/odk/examples/DevelopersGuide/Drawing/ChangeOrderDemo.java
new file mode 100644
index 000000000..6a5de2c7d
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Drawing/ChangeOrderDemo.java
@@ -0,0 +1,113 @@
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+// __________ Imports __________
+
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.lang.XComponent;
+
+import com.sun.star.awt.Point;
+import com.sun.star.awt.Size;
+
+import com.sun.star.beans.PropertyValue;
+import com.sun.star.beans.XPropertySet;
+
+import com.sun.star.drawing.XShape;
+import com.sun.star.drawing.XShapes;
+import com.sun.star.drawing.XDrawPage;
+
+
+
+// __________ Implementation __________
+
+// ChangeOrderDemo
+
+public class ChangeOrderDemo
+{
+ public static void main( String args[] )
+ {
+ XComponent xDrawDoc = null;
+ try
+ {
+ // get the remote office context of a running office (a new office
+ // instance is started if necessary)
+ com.sun.star.uno.XComponentContext xOfficeContext = Helper.connect();
+
+ // suppress Presentation Autopilot when opening the document
+ // properties are the same as described for
+ // com.sun.star.document.MediaDescriptor
+ PropertyValue[] pPropValues = new PropertyValue[ 1 ];
+ pPropValues[ 0 ] = new PropertyValue();
+ pPropValues[ 0 ].Name = "Silent";
+ pPropValues[ 0 ].Value = Boolean.TRUE;
+
+ xDrawDoc = Helper.createDocument( xOfficeContext,
+ "private:factory/sdraw", "_blank", 0, pPropValues );
+
+ // create two rectangles
+ XDrawPage xPage = PageHelper.getDrawPageByIndex( xDrawDoc, 0 );
+ XShapes xShapes = UnoRuntime.queryInterface( XShapes.class, xPage );
+
+ XShape xShape1 = ShapeHelper.createShape( xDrawDoc,
+ new Point( 1000, 1000 ), new Size( 5000, 5000 ),
+ "com.sun.star.drawing.RectangleShape" );
+
+ XShape xShape2 = ShapeHelper.createShape( xDrawDoc,
+ new Point( 2000, 2000 ), new Size( 5000, 5000 ),
+ "com.sun.star.drawing.EllipseShape" );
+
+ xShapes.add( xShape1 );
+ ShapeHelper.addPortion( xShape1, " this shape was inserted first", false );
+ ShapeHelper.addPortion( xShape1, "by changing the ZOrder it lie now on top", true );
+ xShapes.add( xShape2 );
+
+ XPropertySet xPropSet1 = UnoRuntime.queryInterface( XPropertySet.class, xShape1 );
+ XPropertySet xPropSet2 = UnoRuntime.queryInterface( XPropertySet.class, xShape2 );
+
+ int nOrderOfShape1 = ((Integer)xPropSet1.getPropertyValue( "ZOrder" )).intValue();
+ int nOrderOfShape2 = ((Integer)xPropSet2.getPropertyValue( "ZOrder" )).intValue();
+
+ xPropSet1.setPropertyValue( "ZOrder", Integer.valueOf( nOrderOfShape2 ) );
+ xPropSet2.setPropertyValue( "ZOrder", Integer.valueOf( nOrderOfShape1 ) );
+ }
+ catch( Exception ex )
+ {
+ System.out.println( ex );
+ }
+ System.exit( 0 );
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/Drawing/ControlAndSelectDemo.java b/odk/examples/DevelopersGuide/Drawing/ControlAndSelectDemo.java
new file mode 100644
index 000000000..5061a4b36
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Drawing/ControlAndSelectDemo.java
@@ -0,0 +1,144 @@
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+// __________ Imports __________
+
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.lang.XComponent;
+import com.sun.star.lang.XMultiServiceFactory;
+
+import com.sun.star.awt.Point;
+import com.sun.star.awt.Size;
+import com.sun.star.awt.XControlModel;
+
+import com.sun.star.beans.PropertyValue;
+
+import com.sun.star.drawing.XShape;
+import com.sun.star.drawing.XShapes;
+import com.sun.star.drawing.XControlShape;
+import com.sun.star.drawing.XDrawPage;
+import com.sun.star.drawing.XDrawPages;
+import com.sun.star.drawing.XDrawPagesSupplier;
+
+import com.sun.star.frame.XModel;
+import com.sun.star.frame.XController;
+
+import com.sun.star.view.XSelectionSupplier;
+
+
+// __________ Implementation __________
+
+/** ControlAndSelectDemo
+
+ A (GroupBox) ControlShape will be created.
+ Finally the ControlShape will be inserted into a selection.
+*/
+
+public class ControlAndSelectDemo
+{
+ public static void main( String args[] )
+ {
+ XComponent xComponent = null;
+ try
+ {
+ // get the remote office context of a running office (a new office
+ // instance is started if necessary)
+ com.sun.star.uno.XComponentContext xOfficeContext = Helper.connect();
+
+ // suppress Presentation Autopilot when opening the document
+ // properties are the same as described for
+ // com.sun.star.document.MediaDescriptor
+ PropertyValue[] pPropValues = new PropertyValue[ 1 ];
+ pPropValues[ 0 ] = new PropertyValue();
+ pPropValues[ 0 ].Name = "Silent";
+ pPropValues[ 0 ].Value = Boolean.TRUE;
+
+ xComponent = Helper.createDocument( xOfficeContext,
+ "private:factory/sdraw", "_blank", 0, pPropValues );
+
+ XMultiServiceFactory xFactory =
+ UnoRuntime.queryInterface(
+ XMultiServiceFactory.class, xComponent );
+
+ XDrawPagesSupplier xDrawPagesSupplier =
+ UnoRuntime.queryInterface(
+ XDrawPagesSupplier.class, xComponent );
+ XDrawPages xDrawPages = xDrawPagesSupplier.getDrawPages();
+ XDrawPage xDrawPage = UnoRuntime.queryInterface(
+ XDrawPage.class, xDrawPages.getByIndex( 0 ));
+ XShapes xShapes = UnoRuntime.queryInterface(XShapes.class,
+ xDrawPage );
+
+
+ // create and insert the ControlShape
+ Object xObj = xFactory.createInstance(
+ "com.sun.star.drawing.ControlShape" );
+ XShape xShape = UnoRuntime.queryInterface( XShape.class, xObj );
+ xShape.setPosition( new Point( 1000, 1000 ) );
+ xShape.setSize( new Size( 2000, 2000 ) );
+ xShapes.add( xShape );
+
+ // create and set the control
+ XControlModel xControlModel = UnoRuntime.queryInterface(
+ XControlModel.class,
+ xFactory.createInstance( "com.sun.star.form.component.GroupBox" ) );
+ XControlShape xControlShape = UnoRuntime.queryInterface(
+ XControlShape.class, xShape );
+ xControlShape.setControl( xControlModel );
+
+
+ // the following code will demonstrate how to
+ // make a selection that contains our new created ControlShape
+ XModel xModel = UnoRuntime.queryInterface( XModel.class,
+ xComponent );
+ XController xController = xModel.getCurrentController();
+ XSelectionSupplier xSelectionSupplier =UnoRuntime.queryInterface( XSelectionSupplier.class, xController );
+ // take care to use the global service factory only and not the one
+ // that is provided by the component if you create the ShapeCollection
+ XShapes xSelection = UnoRuntime.queryInterface( XShapes.class,
+ xOfficeContext.getServiceManager().createInstanceWithContext(
+ "com.sun.star.drawing.ShapeCollection", xOfficeContext ) );
+ xSelection.add( xShape );
+ xSelectionSupplier.select( xSelection );
+ }
+ catch( java.lang.Exception ex )
+ {
+ System.out.println( ex );
+ }
+ System.exit( 0 );
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/Drawing/CustomShowDemo.java b/odk/examples/DevelopersGuide/Drawing/CustomShowDemo.java
new file mode 100644
index 000000000..7dcf1d71d
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Drawing/CustomShowDemo.java
@@ -0,0 +1,169 @@
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+// __________ Imports __________
+
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.lang.XComponent;
+import com.sun.star.lang.XSingleServiceFactory;
+
+import com.sun.star.awt.Point;
+import com.sun.star.awt.Size;
+
+import com.sun.star.beans.PropertyValue;
+import com.sun.star.beans.XPropertySet;
+
+import com.sun.star.container.XNamed;
+import com.sun.star.container.XNameContainer;
+import com.sun.star.container.XIndexContainer;
+
+import com.sun.star.drawing.XShape;
+import com.sun.star.drawing.XShapes;
+import com.sun.star.drawing.XDrawPage;
+import com.sun.star.drawing.XDrawPages;
+import com.sun.star.drawing.XDrawPagesSupplier;
+
+import com.sun.star.presentation.XPresentation;
+import com.sun.star.presentation.XPresentationSupplier;
+import com.sun.star.presentation.XCustomPresentationSupplier;
+
+
+// __________ Implementation __________
+
+// presentation demo
+
+// This demo will demonstrate how to create a CustomShow
+
+// The first parameter describes the connection that is to use. If there is no parameter
+// "uno:socket,host=localhost,port=2083;urp;StarOffice.ServiceManager" is used.
+
+
+public class CustomShowDemo
+{
+ public static void main( String args[] )
+ {
+ XComponent xDrawDoc = null;
+ try
+ {
+ // get the remote office context of a running office (a new office
+ // instance is started if necessary)
+ com.sun.star.uno.XComponentContext xOfficeContext = Helper.connect();
+
+ // suppress Presentation Autopilot when opening the document
+ // properties are the same as described for
+ // com.sun.star.document.MediaDescriptor
+ PropertyValue[] pPropValues = new PropertyValue[ 1 ];
+ pPropValues[ 0 ] = new PropertyValue();
+ pPropValues[ 0 ].Name = "Silent";
+ pPropValues[ 0 ].Value = Boolean.TRUE;
+
+ xDrawDoc = Helper.createDocument( xOfficeContext,
+ "private:factory/simpress", "_blank", 0, pPropValues );
+
+ XDrawPagesSupplier xDrawPagesSupplier =
+ UnoRuntime.queryInterface(
+ XDrawPagesSupplier.class, xDrawDoc );
+ XDrawPages xDrawPages = xDrawPagesSupplier.getDrawPages();
+
+ // take care that this document has ten pages
+ while ( xDrawPages.getCount() < 10 )
+ xDrawPages.insertNewByIndex( 0 );
+
+ // assign a name to each page and also insert a text object including the name of the page
+ String aNameArray[] = { "Introduction", "page one", "page two", "page three", "page four",
+ "page five", "page six", "page seven", "page eight", "page nine" };
+ int i;
+ for ( i = 0; i < 10; i++ )
+ {
+ XDrawPage xDrawPage = UnoRuntime.queryInterface(
+ XDrawPage.class, xDrawPages.getByIndex( i ));
+ XNamed xPageName = UnoRuntime.queryInterface(
+ XNamed.class, xDrawPage );
+ xPageName.setName( aNameArray[ i ] );
+
+ // now we will create and insert the text object
+ XShape xTextObj = ShapeHelper.createShape( xDrawDoc, new Point( 10000, 9000 ),
+ new Size( 10000, 5000 ),
+ "com.sun.star.drawing.TextShape" );
+ XShapes xShapes = UnoRuntime.queryInterface( XShapes.class, xDrawPage );
+ xShapes.add( xTextObj );
+ ShapeHelper.addPortion( xTextObj, aNameArray[ i ], true );
+ }
+
+ /* create two custom shows, one will play slide 6 to 10 and is named "ShortVersion"
+ the other one will play slide 2 til 10 and is named "LongVersion" */
+ XCustomPresentationSupplier xCustPresSupplier = UnoRuntime.queryInterface( XCustomPresentationSupplier.class, xDrawDoc );
+
+ /* the following container is a container for further container
+ which concludes the list of pages that are to play within a custom show */
+ XNameContainer xNameContainer = xCustPresSupplier.getCustomPresentations();
+ XSingleServiceFactory xFactory = UnoRuntime.queryInterface( XSingleServiceFactory.class, xNameContainer );
+
+ Object xObj;
+ XIndexContainer xContainer;
+
+ /* instantiate an IndexContainer that will take
+ a list of draw pages for the first custom show */
+ xObj = xFactory.createInstance();
+ xContainer = UnoRuntime.queryInterface( XIndexContainer.class, xObj );
+ for ( i = 5; i < 10; i++ )
+ xContainer.insertByIndex( xContainer.getCount(), xDrawPages.getByIndex( i ) );
+ xNameContainer.insertByName( "ShortVersion", xContainer );
+
+ /* instantiate an IndexContainer that will take
+ a list of draw page for the second custom show */
+ xObj = xFactory.createInstance();
+ xContainer = UnoRuntime.queryInterface( XIndexContainer.class, xObj );
+ for ( i = 1; i < 10; i++ )
+ xContainer.insertByIndex( xContainer.getCount(), xDrawPages.getByIndex( i ) );
+ xNameContainer.insertByName( "LongVersion", xContainer );
+
+ /* which custom show is to use
+ can been set in the presentation settings */
+
+ XPresentationSupplier xPresSupplier = UnoRuntime.queryInterface( XPresentationSupplier.class, xDrawDoc );
+ XPresentation xPresentation = xPresSupplier.getPresentation();
+ XPropertySet xPresPropSet = UnoRuntime.queryInterface( XPropertySet.class, xPresentation );
+ xPresPropSet.setPropertyValue( "CustomShow", "ShortVersion" );
+ }
+ catch( Exception ex )
+ {
+ System.out.println( ex );
+ }
+ System.exit( 0 );
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/Drawing/DrawViewDemo.java b/odk/examples/DevelopersGuide/Drawing/DrawViewDemo.java
new file mode 100644
index 000000000..111915366
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Drawing/DrawViewDemo.java
@@ -0,0 +1,142 @@
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+// __________ Imports __________
+
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.lang.XComponent;
+
+import com.sun.star.beans.Property;
+import com.sun.star.beans.PropertyValue;
+import com.sun.star.beans.XPropertySet;
+import com.sun.star.beans.XPropertySetInfo;
+
+import com.sun.star.container.XIndexAccess;
+
+import com.sun.star.document.XViewDataSupplier;
+
+import com.sun.star.frame.XModel;
+import com.sun.star.frame.XController;
+
+
+
+// __________ Implementation __________
+
+// text demo
+
+public class DrawViewDemo
+{
+ public static void main( String args[] )
+ {
+ if ( args.length < 1 )
+ {
+ System.out.println( "usage: DrawViewDemo SourceURL" );
+ System.exit(1);
+ }
+
+ XComponent xComponent = null;
+ try
+ {
+ // get the remote office context of a running office (a new office
+ // instance is started if necessary)
+ com.sun.star.uno.XComponentContext xOfficeContext = Helper.connect();
+
+ // suppress Presentation Autopilot when opening the document
+ // properties are the same as described for
+ // com.sun.star.document.MediaDescriptor
+ PropertyValue[] pPropValues = new PropertyValue[ 1 ];
+ pPropValues[ 0 ] = new PropertyValue();
+ pPropValues[ 0 ].Name = "Silent";
+ pPropValues[ 0 ].Value = Boolean.TRUE;
+
+ java.io.File sourceFile = new java.io.File(args[0]);
+ StringBuffer sUrl = new StringBuffer("file:///");
+ sUrl.append(sourceFile.getCanonicalPath().replace('\\', '/'));
+
+ xComponent = Helper.createDocument( xOfficeContext,
+ sUrl.toString(), "_blank", 0,
+ pPropValues );
+ XModel xModel =
+ UnoRuntime.queryInterface(
+ XModel.class, xComponent );
+
+
+ // print all available properties of first view
+ System.out.println("*** print all available properties of first view");
+ XViewDataSupplier xViewDataSupplier =
+ UnoRuntime.queryInterface(
+ XViewDataSupplier.class, xModel );
+ XIndexAccess xIndexAccess = xViewDataSupplier.getViewData();
+ if ( xIndexAccess.getCount() != 0 )
+ {
+ PropertyValue[] aPropSeq = (PropertyValue[])
+ xIndexAccess.getByIndex( 0 );
+
+ for( int i = 0; i < aPropSeq.length; i++ )
+ {
+ System.out.println( aPropSeq[ i ].Name + " = " +
+ aPropSeq[ i ].Value );
+ }
+ }
+
+
+ // print all properties that are supported by the controller
+ // and change into masterpage mode
+ System.out.println("*** print all properties that are supported by the controller");
+ XController xController = xModel.getCurrentController();
+ XPropertySet xPropSet =
+ UnoRuntime.queryInterface(
+ XPropertySet.class, xController );
+ XPropertySetInfo xPropSetInfo = xPropSet.getPropertySetInfo();
+ Property[] aPropSeq = xPropSetInfo.getProperties();
+ for( int i = 0; i < aPropSeq.length; i++ )
+ {
+ System.out.println( aPropSeq[ i ].Name );
+ }
+ System.out.println("*** change into masterpage mode");
+ xPropSet.setPropertyValue( "IsMasterPageMode", Boolean.TRUE );
+
+ }
+ catch( Exception ex )
+ {
+ System.out.println( ex.getMessage() );
+ ex.printStackTrace(System.err);
+ }
+
+ System.exit( 0 );
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/Drawing/DrawingDemo.java b/odk/examples/DevelopersGuide/Drawing/DrawingDemo.java
new file mode 100644
index 000000000..f71197cf6
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Drawing/DrawingDemo.java
@@ -0,0 +1,419 @@
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+// __________ Imports __________
+
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.lang.XComponent;
+
+import com.sun.star.awt.Point;
+import com.sun.star.awt.Size;
+
+import com.sun.star.beans.PropertyValue;
+import com.sun.star.beans.XPropertySet;
+
+import com.sun.star.container.XNamed;
+
+import com.sun.star.drawing.PolygonFlags;
+import com.sun.star.drawing.PolyPolygonBezierCoords;
+import com.sun.star.drawing.XShape;
+import com.sun.star.drawing.XShapes;
+import com.sun.star.drawing.XShapeGrouper;
+import com.sun.star.drawing.XDrawPage;
+
+import java.util.Random;
+
+
+// __________ Implementation __________
+
+// drawing demo
+
+// This drawing demo will create/load a document, and show how to
+// handle pages and shapes using the Office API,
+
+// Calling this demo two parameter can be used. The first parameter
+// describes if a document is to create or load: "draw" creates a
+// draw document, "impress" creates an impress document, any other
+// parameter is interpreted as URL and loads the corresponding
+// document. ( example for a URL is: "file:///c:/test.odp" )
+// The second parameter is the connection that is to use. If no parameter
+// is given a standard impress document is created by using following
+// connection: "uno:socket,host=localhost,port=2083;urp;StarOffice.ServiceManager";
+
+public class DrawingDemo
+{
+ public static void main( String args[] )
+ {
+ XComponent xDrawDoc = null;
+ try
+ {
+ // get the remote office context of a running office (a new office
+ // instance is started if necessary)
+ com.sun.star.uno.XComponentContext xOfficeContext = Helper.connect();
+
+ String sURL;
+ if ( args.length == 0 )
+ sURL = "impress";
+ else
+ sURL = args[ 0 ];
+
+ if ( sURL.equals( "draw" ) )
+ sURL = "private:factory/sdraw";
+ else if ( sURL.equals( "impress" ) )
+ sURL = "private:factory/simpress";
+
+ // suppress Presentation Autopilot when opening the document
+ // properties are the same as described for
+ // com.sun.star.document.MediaDescriptor
+ PropertyValue[] pPropValues = new PropertyValue[ 1 ];
+ pPropValues[ 0 ] = new PropertyValue();
+ pPropValues[ 0 ].Name = "Silent";
+ pPropValues[ 0 ].Value = Boolean.TRUE;
+
+ xDrawDoc = Helper.createDocument( xOfficeContext,
+ sURL, "_blank", 0, pPropValues );
+ }
+ catch( Exception ex )
+ {
+ System.out.println( ex );
+ System.exit( 0 );
+ }
+
+
+ Demo_PageCreation( xDrawDoc, 10 );
+ Demo_PageNaming( xDrawDoc, "this page is called: LastPage" );
+ Demo_ShapeCreation( xDrawDoc );
+ Demo_PolyPolygonBezier( xDrawDoc );
+ Demo_Group1( xDrawDoc );
+ Demo_Group2( xDrawDoc );
+ System.exit( 0 );
+ }
+
+ // This method appends draw pages to the document, so that a
+ // minimum of n draw pages will be available.
+ // For each second draw page also a new master page is created.
+ public static void Demo_PageCreation( XComponent xDrawDoc, int n )
+ {
+ try
+ {
+ // If the document has less than n draw pages, append them,
+ // a minimum of n draw pages will be available
+ int i, nDrawPages;
+ for ( nDrawPages = PageHelper.getDrawPageCount( xDrawDoc );
+ nDrawPages < n; nDrawPages++ )
+ PageHelper.insertNewDrawPageByIndex( xDrawDoc, nDrawPages );
+ // Create a master page for each second drawpage
+ int nMasterPages;
+ for ( nMasterPages = PageHelper.getMasterPageCount( xDrawDoc );
+ nMasterPages < ( ( nDrawPages + 1 ) / 2 ); nMasterPages++ )
+ PageHelper.insertNewMasterPageByIndex( xDrawDoc, nMasterPages );
+
+ // Now connect master page 1 to draw page 1 and 2,
+ // master page 2 to draw page 3 and 4 and so on.
+ for ( i = 0; i < nDrawPages; i++ )
+ {
+ XDrawPage xDrawPage = PageHelper.getDrawPageByIndex( xDrawDoc, i );
+ XDrawPage xMasterPage = PageHelper.getMasterPageByIndex(
+ xDrawDoc, i / 2 );
+ PageHelper.setMasterPage( xDrawPage, xMasterPage );
+ }
+ }
+ catch( Exception ex )
+ {
+ System.out.println("Demo_PageCreation: I have a page creation problem");
+ }
+ }
+
+ // this method shows how to name a page, this is exemplary
+ // be done for the last draw page
+ public static void Demo_PageNaming(
+ XComponent xDrawDoc, String sLastPageName )
+ {
+ try
+ {
+ XDrawPage xLastPage = PageHelper.getDrawPageByIndex( xDrawDoc,
+ PageHelper.getDrawPageCount( xDrawDoc ) - 1 );
+
+ // each drawpage is supporting an XNamed interface
+ XNamed xNamed = UnoRuntime.queryInterface(
+ XNamed.class, xLastPage );
+
+ // beware, the page must have a unique name
+ xNamed.setName( sLastPageName );
+ }
+ catch( Exception ex )
+ {
+ System.out.println( "Demo_PageNaming: can't set page name" );
+ }
+ }
+
+ // This method will add one rectangle shape into the lower left quarter of
+ // every page that is available,
+ public static void Demo_ShapeCreation( XComponent xDrawDoc )
+ {
+ try
+ {
+ boolean bIsImpressDocument = PageHelper.isImpressDocument( xDrawDoc );
+
+ int nDrawingPages = PageHelper.getDrawPageCount( xDrawDoc );
+ int nMasterPages = PageHelper.getMasterPageCount( xDrawDoc );
+ int nGlobalPageCount = nDrawingPages + nMasterPages;
+
+ if ( bIsImpressDocument )
+ {
+ // in impress each draw page also has a notes page
+ nGlobalPageCount += nDrawingPages;
+ // for each drawing master is also a notes master available
+ nGlobalPageCount += nMasterPages;
+ // one handout is existing
+ nGlobalPageCount += 1;
+ }
+
+ // create and fill a container with all draw pages
+ XDrawPage[] pPages = new XDrawPage[ nGlobalPageCount ];
+ int i, nCurrentPageIndex = 0;
+
+ // insert handout page
+ if ( bIsImpressDocument )
+ pPages[ nCurrentPageIndex++ ] = PageHelper.getHandoutMasterPage(
+ xDrawDoc );
+
+ // inserting all master pages
+ for( i = 0; i < nMasterPages; i++ )
+ {
+ XDrawPage xMasterPage = PageHelper.getMasterPageByIndex(
+ xDrawDoc, i );
+ pPages[ nCurrentPageIndex++ ] = xMasterPage;
+
+ // if the document is an impress, get the corresponding notes
+ // master page
+ if ( bIsImpressDocument )
+ pPages[ nCurrentPageIndex++ ] = PageHelper.getNotesPage(
+ xMasterPage );
+ }
+ for ( i = 0; i < nDrawingPages; i++ )
+ {
+ XDrawPage xDrawPage = PageHelper.getDrawPageByIndex( xDrawDoc, i );
+ pPages[ nCurrentPageIndex++ ] = xDrawPage;
+
+ // if the document is an impress, get the corresponding notes page
+ if ( bIsImpressDocument )
+ pPages[ nCurrentPageIndex++ ] = PageHelper.getNotesPage(
+ xDrawPage );
+ }
+
+ // Now a complete list of pages is available in pPages.
+ // The following code will insert a rectangle into each page.
+ for ( i = 0; i < nGlobalPageCount; i++ )
+ {
+ Size aPageSize = PageHelper.getPageSize( pPages[ i ] );
+ int nHalfWidth = aPageSize.Width / 2;
+ int nHalfHeight = aPageSize.Height / 2;
+
+ Random aRndGen = new Random();
+ int nRndObjWidth = aRndGen.nextInt( nHalfWidth );
+ int nRndObjHeight = aRndGen.nextInt( nHalfHeight );
+
+ int nRndObjPosX = aRndGen.nextInt( nHalfWidth - nRndObjWidth );
+ int nRndObjPosY = aRndGen.nextInt( nHalfHeight - nRndObjHeight )
+ + nHalfHeight;
+
+ XShapes xShapes = UnoRuntime.queryInterface( XShapes.class, pPages[ i ] );
+ ShapeHelper.createAndInsertShape( xDrawDoc, xShapes,
+ new Point( nRndObjPosX, nRndObjPosY ),
+ new Size( nRndObjWidth, nRndObjHeight ),
+ "com.sun.star.drawing.RectangleShape" );
+ }
+ }
+ catch( Exception ex )
+ {
+ System.out.println( "Demo_ShapeCreation:" + ex );
+ }
+ }
+
+ // This method will show how to create a PolyPolygonBezier that lies is in the
+ // topleft quarter of the page and positioned at the back
+ public static void Demo_PolyPolygonBezier( XComponent xDrawDoc )
+ {
+ try
+ {
+ XShape xPolyPolygonBezier = ShapeHelper.createShape( xDrawDoc,
+ new Point( 0, 0 ),
+ new Size( 0, 0 ),
+ "com.sun.star.drawing.ClosedBezierShape" );
+
+ // the fact that the shape must have been added to the page before
+ // it is possible to apply changes to the PropertySet, it is a good
+ // proceeding to add the shape as soon as possible
+ XDrawPage xDrawPage;
+ // if possible insert our new shape in the master page
+ if ( PageHelper.isImpressDocument( xDrawDoc ) )
+ xDrawPage = PageHelper.getMasterPageByIndex( xDrawDoc, 0 );
+ else
+ xDrawPage = PageHelper.getDrawPageByIndex( xDrawDoc, 0 );
+ XShapes xShapes = UnoRuntime.queryInterface( XShapes.class, xDrawPage );
+ xShapes.add( xPolyPolygonBezier );
+
+ XPropertySet xShapeProperties = UnoRuntime.queryInterface( XPropertySet.class, xPolyPolygonBezier );
+
+ // get pagesize
+ XPropertySet xPageProperties = UnoRuntime.queryInterface( XPropertySet.class, xDrawPage );
+ int nPageWidth = ((Integer)xPageProperties.getPropertyValue( "Width" )).intValue() / 2;
+ int nPageHeight = ((Integer)xPageProperties.getPropertyValue( "Height" )).intValue() / 2;
+
+ PolyPolygonBezierCoords aCoords = new PolyPolygonBezierCoords();
+ // allocating the outer sequence
+ int nPolygonCount = 50;
+ aCoords.Coordinates = new Point[ nPolygonCount ][ ];
+ aCoords.Flags = new PolygonFlags[ nPolygonCount ][ ];
+ int i, n, nY;
+ // fill the inner point sequence now
+ for ( nY = 0, i = 0; i < nPolygonCount; i++, nY += nPageHeight / nPolygonCount )
+ {
+ // create a polygon using two normal and two control points
+ // allocating the inner sequence
+ int nPointCount = 8;
+ Point[] pPolyPoints = new Point[ nPointCount ];
+ PolygonFlags[] pPolyFlags = new PolygonFlags[ nPointCount ];
+
+ for ( n = 0; n < nPointCount; n++ )
+ pPolyPoints[ n ] = new Point();
+
+ pPolyPoints[ 0 ].X = 0;
+ pPolyPoints[ 0 ].Y = nY;
+ pPolyFlags[ 0 ] = PolygonFlags.NORMAL;
+ pPolyPoints[ 1 ].X = nPageWidth / 2;
+ pPolyPoints[ 1 ].Y = nPageHeight;
+ pPolyFlags[ 1 ] = PolygonFlags.CONTROL;
+ pPolyPoints[ 2 ].X = nPageWidth / 2;
+ pPolyPoints[ 2 ].Y = nPageHeight;
+ pPolyFlags[ 2 ] = PolygonFlags.CONTROL;
+ pPolyPoints[ 3 ].X = nPageWidth;
+ pPolyPoints[ 3 ].Y = nY;
+ pPolyFlags[ 3 ] = PolygonFlags.NORMAL;
+
+ pPolyPoints[ 4 ].X = nPageWidth - 1000;
+ pPolyPoints[ 4 ].Y = nY;
+ pPolyFlags[ 4 ] = PolygonFlags.NORMAL;
+ pPolyPoints[ 5 ].X = nPageWidth / 2;
+ pPolyPoints[ 5 ].Y = nPageHeight / 2;
+ pPolyFlags[ 5 ] = PolygonFlags.CONTROL;
+ pPolyPoints[ 6 ].X = nPageWidth / 2;
+ pPolyPoints[ 6 ].Y = nPageHeight / 2;
+ pPolyFlags[ 6 ] = PolygonFlags.CONTROL;
+ pPolyPoints[ 7 ].X = 1000;
+ pPolyPoints[ 7 ].Y = nY;
+ pPolyFlags[ 7 ] = PolygonFlags.NORMAL;
+
+ aCoords.Coordinates[ i ]= pPolyPoints;
+ aCoords.Flags[ i ] = pPolyFlags;
+ }
+ xShapeProperties.setPropertyValue( "PolyPolygonBezier", aCoords );
+
+ // move the shape to the back by changing the ZOrder
+ xShapeProperties.setPropertyValue( "ZOrder", Integer.valueOf( 1 ) );
+ }
+ catch ( Exception ex )
+ {
+ System.out.println( "Demo_PolyPolygonBezier:" + ex );
+ }
+ }
+
+ // This method will create a group containing two ellipses
+ // the shapes will be added into the top right corner of the first
+ // draw page
+ public static void Demo_Group1( XComponent xDrawDoc )
+ {
+ try
+ {
+ XShape xGroup = ShapeHelper.createShape( xDrawDoc,
+ new Point( 0, 0 ),
+ new Size( 0, 0 ),
+ "com.sun.star.drawing.GroupShape" );
+
+ // before it is possible to insert shapes,
+ // the group must have been added to the page
+ XDrawPage xDrawPage = PageHelper.getDrawPageByIndex( xDrawDoc, 0 );
+ XShapes xShapes = UnoRuntime.queryInterface( XShapes.class, xDrawPage );
+ xShapes.add( xGroup );
+
+ XShapes xShapesGroup = UnoRuntime.queryInterface( XShapes.class, xGroup );
+
+ Size aPageSize = PageHelper.getPageSize( xDrawPage );
+
+ int nWidth = 4000;
+ int nHeight = 2000;
+ int nPosX = ( aPageSize.Width * 3 ) / 4 - nWidth / 2;
+ int nPosY1 = 2000;
+ int nPosY2 = aPageSize.Height / 2 - ( nPosY1 + nHeight );
+ XShape xRect1 = ShapeHelper.createShape( xDrawDoc,
+ new Point( nPosX, nPosY1 ),
+ new Size( nWidth, nHeight ),
+ "com.sun.star.drawing.EllipseShape" );
+ XShape xRect2 = ShapeHelper.createShape( xDrawDoc,
+ new Point( nPosX, nPosY2 ),
+ new Size( nWidth, nHeight ),
+ "com.sun.star.drawing.EllipseShape" );
+
+ xShapesGroup.add( xRect1 );
+ xShapesGroup.add( xRect2 );
+ }
+ catch ( Exception ex )
+ {
+ System.out.println( "Demo_Group1:" + ex );
+ }
+ }
+
+ // This method will group all available objects on the
+ // first page.
+ public static void Demo_Group2( XComponent xDrawDoc )
+ {
+ try
+ {
+ XDrawPage xDrawPage = PageHelper.getDrawPageByIndex( xDrawDoc, 0 );
+ XShapeGrouper xShapeGrouper = UnoRuntime.queryInterface( XShapeGrouper.class, xDrawPage );
+
+ XShapes xShapesPage = UnoRuntime.queryInterface( XShapes.class, xDrawPage );
+
+ xShapeGrouper.group( xShapesPage );
+ }
+ catch ( Exception ex )
+ {
+ System.out.println( "Demo_Group2:" + ex );
+ }
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/Drawing/FillAndLineStyleDemo.java b/odk/examples/DevelopersGuide/Drawing/FillAndLineStyleDemo.java
new file mode 100644
index 000000000..1f678b307
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Drawing/FillAndLineStyleDemo.java
@@ -0,0 +1,132 @@
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+// __________ Imports __________
+
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.lang.XComponent;
+
+import com.sun.star.beans.PropertyValue;
+import com.sun.star.beans.XPropertySet;
+
+import com.sun.star.drawing.LineDash;
+import com.sun.star.drawing.XShape;
+import com.sun.star.drawing.XShapes;
+import com.sun.star.drawing.XDrawPage;
+
+import com.sun.star.awt.Gradient;
+import com.sun.star.awt.GradientStyle;
+import com.sun.star.awt.Point;
+import com.sun.star.awt.Size;
+
+
+// __________ Implementation __________
+
+// FillStyle and LineStyle demo
+
+public class FillAndLineStyleDemo
+{
+ public static void main( String args[] )
+ {
+ XComponent xDrawDoc = null;
+ try
+ {
+ // get the remote office context of a running office (a new office
+ // instance is started if necessary)
+ com.sun.star.uno.XComponentContext xOfficeContext = Helper.connect();
+
+ // suppress Presentation Autopilot when opening the document
+ // properties are the same as described for
+ // com.sun.star.document.MediaDescriptor
+ PropertyValue[] pPropValues = new PropertyValue[ 1 ];
+ pPropValues[ 0 ] = new PropertyValue();
+ pPropValues[ 0 ].Name = "Silent";
+ pPropValues[ 0 ].Value = Boolean.TRUE;
+
+ xDrawDoc = Helper.createDocument( xOfficeContext,
+ "private:factory/sdraw", "_blank", 0, pPropValues );
+
+ XDrawPage xPage = PageHelper.getDrawPageByIndex( xDrawDoc, 0 );
+
+ XShape xRectangle = ShapeHelper.createShape( xDrawDoc,
+ new Point( 0, 0 ),
+ new Size( 15000, 12000 ),
+ "com.sun.star.drawing.RectangleShape" );
+
+ XShapes xShapes = UnoRuntime.queryInterface( XShapes.class, xPage );
+ xShapes.add( xRectangle );
+
+ XPropertySet xPropSet = UnoRuntime.queryInterface( XPropertySet.class, xRectangle );
+
+ /* apply a gradient fill style that goes from top left to bottom
+ right and is changing its color from green to yellow */
+ xPropSet.setPropertyValue( "FillStyle",
+ com.sun.star.drawing.FillStyle.GRADIENT );
+ Gradient aGradient = new Gradient();
+ aGradient.Style = GradientStyle.LINEAR;
+ aGradient.StartColor = 0x00ff00;
+ aGradient.EndColor = 0xffff00;
+ aGradient.Angle = 450;
+ aGradient.Border = 0;
+ aGradient.XOffset = 0;
+ aGradient.YOffset = 0;
+ aGradient.StartIntensity = 100;
+ aGradient.EndIntensity = 100;
+ aGradient.StepCount = 10;
+ xPropSet.setPropertyValue( "FillGradient", aGradient );
+
+ /* create a blue line with dashes and dots */
+ xPropSet.setPropertyValue( "LineStyle",
+ com.sun.star.drawing.LineStyle.DASH );
+ LineDash aLineDash = new LineDash();
+ aLineDash.Dots = 3;
+ aLineDash.DotLen = 150;
+ aLineDash.Dashes = 3;
+ aLineDash.DashLen = 300;
+ aLineDash.Distance = 150;
+ xPropSet.setPropertyValue( "LineDash", aLineDash );
+ xPropSet.setPropertyValue( "LineColor", Integer.valueOf( 0x0000ff ) );
+ xPropSet.setPropertyValue( "LineWidth", Integer.valueOf( 200 ) );
+
+ }
+ catch( Exception ex )
+ {
+ System.out.println( ex );
+ }
+ System.exit( 0 );
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/Drawing/GluePointDemo.java b/odk/examples/DevelopersGuide/Drawing/GluePointDemo.java
new file mode 100644
index 000000000..0778216ae
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Drawing/GluePointDemo.java
@@ -0,0 +1,182 @@
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+// __________ Imports __________
+
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.lang.XComponent;
+
+import com.sun.star.awt.Point;
+import com.sun.star.awt.Size;
+
+import com.sun.star.beans.PropertyValue;
+import com.sun.star.beans.XPropertySet;
+
+import com.sun.star.container.XIndexContainer;
+import com.sun.star.container.XIdentifierContainer;
+
+import com.sun.star.drawing.Alignment;
+import com.sun.star.drawing.EscapeDirection;
+import com.sun.star.drawing.GluePoint2;
+import com.sun.star.drawing.XShape;
+import com.sun.star.drawing.XShapes;
+import com.sun.star.drawing.XDrawPage;
+import com.sun.star.drawing.XGluePointsSupplier;
+
+
+
+// __________ Implementation __________
+
+// GluePointDemo
+
+public class GluePointDemo
+{
+ public static void main( String args[] )
+ {
+ XComponent xDrawDoc = null;
+ try
+ {
+ // get the remote office context of a running office (a new office
+ // instance is started if necessary)
+ com.sun.star.uno.XComponentContext xOfficeContext = Helper.connect();
+
+ // suppress Presentation Autopilot when opening the document
+ // properties are the same as described for
+ // com.sun.star.document.MediaDescriptor
+ PropertyValue[] pPropValues = new PropertyValue[ 1 ];
+ pPropValues[ 0 ] = new PropertyValue();
+ pPropValues[ 0 ].Name = "Silent";
+ pPropValues[ 0 ].Value = Boolean.TRUE;
+
+ xDrawDoc = Helper.createDocument( xOfficeContext,
+ "private:factory/sdraw", "_blank", 0, pPropValues );
+
+
+ XDrawPage xPage = PageHelper.getDrawPageByIndex( xDrawDoc, 0 );
+ XShapes xShapes = UnoRuntime.queryInterface( XShapes.class, xPage );
+
+ // create two rectangles
+ XShape xShape1 = ShapeHelper.createShape( xDrawDoc,
+ new Point( 15000, 1000 ), new Size( 5000, 5000 ),
+ "com.sun.star.drawing.RectangleShape" );
+
+ XShape xShape2 = ShapeHelper.createShape( xDrawDoc,
+ new Point( 2000, 15000 ), new Size( 5000, 5000 ),
+ "com.sun.star.drawing.EllipseShape" );
+
+ // and a connector
+ XShape xConnector = ShapeHelper.createShape( xDrawDoc,
+ new Point( 0, 0 ),
+ new Size( 0, 0 ),
+ "com.sun.star.drawing.ConnectorShape" );
+
+ xShapes.add( xShape1 );
+ xShapes.add( xShape2 );
+ xShapes.add( xConnector );
+
+ XPropertySet xConnectorPropSet = UnoRuntime.queryInterface( XPropertySet.class, xConnector );
+
+// Index value of 0 : the shape is connected at the top
+// Index value of 1 : the shape is connected at the left
+// Index value of 2 : the shape is connected at the bottom
+// Index value of 3 : the shape is connected at the right
+
+ int nStartIndex = 3;
+ int nEndIndex = 1;
+
+ // the "StartPosition" or "EndPosition" property needs not to be set
+ // if there is a shape to connect
+ xConnectorPropSet.setPropertyValue( "StartShape", xShape1 );
+ xConnectorPropSet.setPropertyValue( "StartGluePointIndex",
+ Integer.valueOf( nStartIndex ) );
+
+ xConnectorPropSet.setPropertyValue( "EndShape", xShape2 );
+ xConnectorPropSet.setPropertyValue( "EndGluePointIndex",
+ Integer.valueOf( nEndIndex ) );
+
+ XGluePointsSupplier xGluePointsSupplier;
+ XIndexContainer xIndexContainer;
+ XIdentifierContainer xIdentifierContainer;
+
+ GluePoint2 aGluePoint = new GluePoint2();
+ aGluePoint.IsRelative = false;
+ aGluePoint.PositionAlignment = Alignment.CENTER;
+ aGluePoint.Escape = EscapeDirection.SMART;
+ aGluePoint.IsUserDefined = true;
+ aGluePoint.Position.X = 0;
+ aGluePoint.Position.Y = 0;
+
+ // create and insert a gluepoint at shape1
+ xGluePointsSupplier = UnoRuntime.queryInterface( XGluePointsSupplier.class, xShape1 );
+ xIndexContainer = xGluePointsSupplier.getGluePoints();
+ xIdentifierContainer = UnoRuntime.queryInterface( XIdentifierContainer.class,
+ xIndexContainer );
+ int nIndexOfGluePoint1 = xIdentifierContainer.insert( aGluePoint );
+
+ // create and insert a gluepoint at shape2
+ xGluePointsSupplier = UnoRuntime.queryInterface( XGluePointsSupplier.class, xShape2 );
+ xIndexContainer = xGluePointsSupplier.getGluePoints();
+ xIdentifierContainer = UnoRuntime.queryInterface( XIdentifierContainer.class,
+ xIndexContainer );
+ int nIndexOfGluePoint2 = xIdentifierContainer.insert( aGluePoint );
+
+ // create and add a connector
+ XShape xConnector2 = ShapeHelper.createShape( xDrawDoc,
+ new Point( 0, 0 ),
+ new Size( 0, 0 ),
+ "com.sun.star.drawing.ConnectorShape" );
+ xShapes.add( xConnector2 );
+
+ XPropertySet xConnector2PropSet = UnoRuntime.queryInterface( XPropertySet.class, xConnector2 );
+
+ xConnector2PropSet.setPropertyValue( "StartShape", xShape1 );
+ xConnector2PropSet.setPropertyValue( "StartGluePointIndex",
+ Integer.valueOf( nIndexOfGluePoint1 ) );
+
+ xConnector2PropSet.setPropertyValue( "EndShape", xShape2 );
+ xConnector2PropSet.setPropertyValue( "EndGluePointIndex",
+ Integer.valueOf( nIndexOfGluePoint2 ) );
+
+
+ }
+ catch( Exception ex )
+ {
+ System.out.println( ex );
+ }
+ System.exit( 0 );
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/Drawing/GraphicExportDemo.java b/odk/examples/DevelopersGuide/Drawing/GraphicExportDemo.java
new file mode 100644
index 000000000..2b8ad77de
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Drawing/GraphicExportDemo.java
@@ -0,0 +1,148 @@
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+// __________ Imports __________
+
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.lang.XComponent;
+
+import com.sun.star.beans.PropertyValue;
+
+import com.sun.star.document.XExporter;
+import com.sun.star.document.XFilter;
+
+import com.sun.star.drawing.XDrawPage;
+
+// __________ Implementation __________
+
+// text demo
+
+public class GraphicExportDemo
+{
+ public static void main( String args[] )
+ {
+ if ( args.length < 3 )
+ {
+ System.out.println( "usage: GraphicExportDemo SourceURL DestinationURL PageIndexToExport" );
+ System.exit(1);
+ }
+
+ XComponent xComponent = null;
+ try
+ {
+ // get the remote office context of a running office (a new office
+ // instance is started if necessary)
+ com.sun.star.uno.XComponentContext xOfficeContext = Helper.connect();
+
+ // suppress Presentation Autopilot when opening the document
+ // properties are the same as described for
+ // com.sun.star.document.MediaDescriptor
+ PropertyValue[] pPropValues = new PropertyValue[ 1 ];
+ pPropValues[ 0 ] = new PropertyValue();
+ pPropValues[ 0 ].Name = "Silent";
+ pPropValues[ 0 ].Value = Boolean.TRUE;
+
+ java.io.File sourceFile = new java.io.File(args[0]);
+ StringBuffer sUrl = new StringBuffer("file:///");
+ sUrl.append(sourceFile.getCanonicalPath().replace('\\', '/'));
+
+ xComponent = Helper.createDocument( xOfficeContext,
+ sUrl.toString(), "_blank", 0,
+ pPropValues );
+
+ Object GraphicExportFilter =
+ xOfficeContext.getServiceManager().createInstanceWithContext(
+ "com.sun.star.drawing.GraphicExportFilter", xOfficeContext);
+ XExporter xExporter = UnoRuntime.queryInterface( XExporter.class, GraphicExportFilter );
+
+ PropertyValue aProps[] = new PropertyValue[2];
+ aProps[0] = new PropertyValue();
+ aProps[0].Name = "MediaType";
+ aProps[0].Value = "image/gif";
+
+ /* some graphics e.g. the Windows Metafile does not have a Media Type,
+ for this case
+ aProps[0].Name = "FilterName"; // it is possible to set a FilterName
+ aProps[0].Value = "WMF";
+ */
+ java.io.File destFile = new java.io.File(args[1]);
+ java.net.URL destUrl = destFile.toURI().toURL();
+
+ aProps[1] = new PropertyValue();
+ aProps[1].Name = "URL";
+ aProps[1].Value = destUrl.toString();//args[ 1 ];
+
+ int nPageIndex = Integer.parseInt( args[ 2 ] );
+ if ( nPageIndex < PageHelper.getDrawPageCount( xComponent ) &&
+ nPageIndex > 1 )
+ {
+ XDrawPage xPage = PageHelper.getDrawPageByIndex( xComponent,
+ nPageIndex );
+ XComponent xComp = UnoRuntime.queryInterface( XComponent.class, xPage );
+ xExporter.setSourceDocument( xComp );
+ XFilter xFilter = UnoRuntime.queryInterface( XFilter.class, xExporter );
+ xFilter.filter( aProps );
+ System.out.println( "*** graphics on page \"" + nPageIndex
+ + "\" from file \"" + args[0]
+ + "\" exported under the name \""
+ + args[1] + "\" in the local directory" );
+ } else
+ {
+ System.out.println( "page index not in range" );
+ }
+
+
+ // close the document
+ com.sun.star.util.XCloseable xCloseable = UnoRuntime.queryInterface(com.sun.star.util.XCloseable.class,
+ xComponent);
+
+ if (xCloseable != null )
+ xCloseable.close(false);
+ else
+ xComponent.dispose();
+
+ System.out.println("*** document closed!");
+
+ }
+ catch( Exception ex )
+ {
+ System.out.println( ex );
+ }
+
+ System.exit( 0 );
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/Drawing/Helper.java b/odk/examples/DevelopersGuide/Drawing/Helper.java
new file mode 100644
index 000000000..5e5c52d1f
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Drawing/Helper.java
@@ -0,0 +1,89 @@
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+// __________ Imports __________
+
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.XComponentContext;
+import com.sun.star.lang.XComponent;
+import com.sun.star.frame.XComponentLoader;
+
+public class Helper
+{
+ // __________ static helper methods __________
+
+ /** Connect to an office, if no office is running a new instance is started.
+ * A new connection is established and the service manager from the running
+ * office is returned.
+ */
+ public static XComponentContext connect()
+ throws Exception
+ {
+ // get the remote office component context
+ XComponentContext xOfficeContext =
+ com.sun.star.comp.helper.Bootstrap.bootstrap();
+
+ // if connection fails an exception is thrown
+ System.out.println("Connected to a running office ...");
+
+ return xOfficeContext;
+ }
+
+ /** creates and instantiates new document
+ */
+ public static com.sun.star.lang.XComponent createDocument(
+ com.sun.star.uno.XComponentContext xOfficeContext,
+ String sURL, String sTargetFrame, int nSearchFlags,
+ com.sun.star.beans.PropertyValue[] aArgs )
+ throws Exception
+ {
+ XComponentLoader aLoader =
+ UnoRuntime.queryInterface(
+ XComponentLoader.class,
+ xOfficeContext.getServiceManager().createInstanceWithContext(
+ "com.sun.star.frame.Desktop", xOfficeContext));
+
+ XComponent xComponent =
+ UnoRuntime.queryInterface(
+ XComponent.class, aLoader.loadComponentFromURL(
+ sURL, sTargetFrame, nSearchFlags, aArgs ) );
+
+ if ( xComponent == null )
+ throw new Exception( "could not create document: " + sURL );
+ return xComponent;
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/Drawing/LayerDemo.java b/odk/examples/DevelopersGuide/Drawing/LayerDemo.java
new file mode 100644
index 000000000..4687cdc54
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Drawing/LayerDemo.java
@@ -0,0 +1,152 @@
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+// __________ Imports __________
+
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.lang.XComponent;
+
+import com.sun.star.awt.Point;
+import com.sun.star.awt.Size;
+
+import com.sun.star.beans.PropertyValue;
+import com.sun.star.beans.XPropertySet;
+
+import com.sun.star.container.XNameAccess;
+
+import com.sun.star.style.ParagraphAdjust;
+
+import com.sun.star.drawing.XShape;
+import com.sun.star.drawing.XShapes;
+import com.sun.star.drawing.XDrawPage;
+import com.sun.star.drawing.XLayer;
+import com.sun.star.drawing.XLayerManager;
+import com.sun.star.drawing.XLayerSupplier;
+
+
+// __________ Implementation __________
+
+// LayerDemo
+
+public class LayerDemo
+{
+ public static void main( String args[] )
+ {
+ XComponent xDrawDoc = null;
+ try
+ {
+ // get the remote office context of a running office (a new office
+ // instance is started if necessary)
+ com.sun.star.uno.XComponentContext xOfficeContext = Helper.connect();
+
+ // suppress Presentation Autopilot when opening the document
+ // properties are the same as described for
+ // com.sun.star.document.MediaDescriptor
+ PropertyValue[] pPropValues = new PropertyValue[ 1 ];
+ pPropValues[ 0 ] = new PropertyValue();
+ pPropValues[ 0 ].Name = "Silent";
+ pPropValues[ 0 ].Value = Boolean.TRUE;
+
+ xDrawDoc = Helper.createDocument( xOfficeContext,
+ "private:factory/sdraw", "_blank", 0, pPropValues );
+
+
+ // create two rectangles
+ XDrawPage xPage = PageHelper.getDrawPageByIndex( xDrawDoc, 0 );
+ XShapes xShapes = UnoRuntime.queryInterface( XShapes.class, xPage );
+
+ XShape xRect1 = ShapeHelper.createShape( xDrawDoc,
+ new Point( 1000, 1000 ), new Size( 5000, 5000 ),
+ "com.sun.star.drawing.RectangleShape" );
+
+ XShape xRect2 = ShapeHelper.createShape( xDrawDoc,
+ new Point( 1000, 7000 ), new Size( 5000, 5000 ),
+ "com.sun.star.drawing.RectangleShape" );
+
+ xShapes.add( xRect1 );
+ xShapes.add( xRect2 );
+ XPropertySet xTextProp = ShapeHelper.addPortion( xRect2,
+ "this shape is locked",
+ false );
+ xTextProp.setPropertyValue( "ParaAdjust", ParagraphAdjust.CENTER );
+ ShapeHelper.addPortion( xRect2, "and the shape above is not visible",
+ true );
+ ShapeHelper.addPortion( xRect2,
+ "(switch to the layer view to gain access)",
+ true );
+
+
+ // query for the XLayerManager
+ XLayerSupplier xLayerSupplier = UnoRuntime.queryInterface(
+ XLayerSupplier.class, xDrawDoc );
+ XNameAccess xNameAccess = xLayerSupplier.getLayerManager();
+ XLayerManager xLayerManager = UnoRuntime.queryInterface(
+ XLayerManager.class, xNameAccess );
+
+ // create a layer and set its properties
+ XPropertySet xLayerPropSet;
+ XLayer xNotVisibleAndEditable = xLayerManager.insertNewByIndex(
+ xLayerManager.getCount() );
+
+ xLayerPropSet = UnoRuntime.queryInterface(
+ XPropertySet.class, xNotVisibleAndEditable );
+ xLayerPropSet.setPropertyValue( "Name", "NotVisibleAndEditable" );
+ xLayerPropSet.setPropertyValue( "IsVisible", Boolean.FALSE );
+ xLayerPropSet.setPropertyValue( "IsLocked", Boolean.TRUE );
+
+ // create a second layer
+ XLayer xNotEditable = xLayerManager.insertNewByIndex(
+ xLayerManager.getCount() );
+
+ xLayerPropSet = UnoRuntime.queryInterface(
+ XPropertySet.class, xNotEditable );
+ xLayerPropSet.setPropertyValue( "Name", "NotEditable" );
+ xLayerPropSet.setPropertyValue( "IsVisible", Boolean.TRUE );
+ xLayerPropSet.setPropertyValue( "IsLocked", Boolean.TRUE );
+
+ // attach the layer to the rectangles
+ xLayerManager.attachShapeToLayer( xRect1, xNotVisibleAndEditable );
+ xLayerManager.attachShapeToLayer( xRect2, xNotEditable );
+
+ }
+ catch( Exception ex )
+ {
+ System.out.println( ex );
+ }
+ System.exit( 0 );
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/Drawing/Makefile b/odk/examples/DevelopersGuide/Drawing/Makefile
new file mode 100644
index 000000000..e5bbf1bf1
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Drawing/Makefile
@@ -0,0 +1,174 @@
+#*************************************************************************
+#
+# The Contents of this file are made available subject to the terms of
+# the BSD license.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+# 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+# contributors may be used to endorse or promote products derived
+# from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+# TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+# USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+#**************************************************************************
+
+# Builds the Drawing examples of the Developers Guide.
+
+PRJ=../../..
+SETTINGS=$(PRJ)/settings
+
+include $(SETTINGS)/settings.mk
+include $(SETTINGS)/std.mk
+
+# Define non-platform/compiler specific settings
+SAMPLE_NAME=DrawingExamples
+SAMPLE_CLASS_OUT = $(OUT_CLASS)/$(SAMPLE_NAME)
+SAMPLE_GEN_OUT = $(OUT_MISC)/$(SAMPLE_NAME)
+
+APP1_NAME=ChangeOrderDemo
+APP1_JAR=$(SAMPLE_CLASS_OUT)/$(APP1_NAME).jar
+APP2_NAME=ControlAndSelectDemo
+APP2_JAR=$(SAMPLE_CLASS_OUT)/$(APP2_NAME).jar
+APP3_NAME=CustomShowDemo
+APP3_JAR=$(SAMPLE_CLASS_OUT)/$(APP3_NAME).jar
+APP4_NAME=DrawingDemo
+APP4_JAR=$(SAMPLE_CLASS_OUT)/$(APP4_NAME).jar
+APP5_NAME=DrawViewDemo
+APP5_JAR=$(SAMPLE_CLASS_OUT)/$(APP5_NAME).jar
+APP6_NAME=FillAndLineStyleDemo
+APP6_JAR=$(SAMPLE_CLASS_OUT)/$(APP6_NAME).jar
+APP7_NAME=GluePointDemo
+APP7_JAR=$(SAMPLE_CLASS_OUT)/$(APP7_NAME).jar
+APP8_NAME=GraphicExportDemo
+APP8_JAR=$(SAMPLE_CLASS_OUT)/$(APP8_NAME).jar
+APP9_NAME=LayerDemo
+APP9_JAR=$(SAMPLE_CLASS_OUT)/$(APP9_NAME).jar
+APP10_NAME=ObjectTransformationDemo
+APP10_JAR=$(SAMPLE_CLASS_OUT)/$(APP10_NAME).jar
+APP11_NAME=Organigram
+APP11_JAR=$(SAMPLE_CLASS_OUT)/$(APP11_NAME).jar
+APP12_NAME=PresentationDemo
+APP12_JAR=$(SAMPLE_CLASS_OUT)/$(APP12_NAME).jar
+APP13_NAME=StyleDemo
+APP13_JAR=$(SAMPLE_CLASS_OUT)/$(APP13_NAME).jar
+APP14_NAME=TextDemo
+APP14_JAR=$(SAMPLE_CLASS_OUT)/$(APP14_NAME).jar
+
+APP_JAVAFILES = \
+ Helper.java \
+ PageHelper.java \
+ ShapeHelper.java
+
+APP_CLASSFILES = $(patsubst %.java,$(SAMPLE_CLASS_OUT)/%.class,$(APP_JAVAFILES))
+APP_CLASSNAMES = $(patsubst %.java,%.class,$(APP_JAVAFILES))
+
+SDK_CLASSPATH = $(subst $(EMPTYSTRING) $(PATH_SEPARATOR),$(PATH_SEPARATOR),$(CLASSPATH)\
+ $(PATH_SEPARATOR)$(SAMPLE_CLASS_OUT))
+
+
+# Targets
+.PHONY: ALL
+ALL : \
+ DrawingExamples
+
+include $(SETTINGS)/stdtarget.mk
+
+$(APP_CLASSFILES) : $(APP_JAVAFILES)
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ $(SDK_JAVAC) $(JAVAC_FLAGS) -classpath "$(SDK_CLASSPATH)" -d $(SAMPLE_CLASS_OUT) $(APP_JAVAFILES)
+
+$(SAMPLE_CLASS_OUT)/%.class : %.java $(APP_CLASSFILES)
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ $(SDK_JAVAC) $(JAVAC_FLAGS) -classpath "$(SDK_CLASSPATH)" -d $(SAMPLE_CLASS_OUT) $<
+
+$(SAMPLE_CLASS_OUT)/%.mf :
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ @echo Main-Class: com.sun.star.lib.loader.Loader> $@
+ $(ECHOLINE)>> $@
+ @echo Name: com/sun/star/lib/loader/Loader.class>> $@
+ @echo Application-Class: $*>> $@
+
+$(SAMPLE_CLASS_OUT)/%.jar : $(SAMPLE_CLASS_OUT)/%.mf $(SAMPLE_CLASS_OUT)/%.class $(APP_CLASSFILES)
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ +cd $(subst /,$(PS),$(SAMPLE_CLASS_OUT)) && $(SDK_JAR) cvfm $(@F) $*.mf $*.class $(APP_CLASSNAMES)
+ +$(SDK_JAR) uvf $@ $(SDK_JAVA_UNO_BOOTSTRAP_FILES)
+
+$(APP1_JAR) : $(SAMPLE_CLASS_OUT)/$(APP1_NAME).mf $(SAMPLE_CLASS_OUT)/$(APP1_NAME).class
+$(APP2_JAR) : $(SAMPLE_CLASS_OUT)/$(APP2_NAME).mf $(SAMPLE_CLASS_OUT)/$(APP2_NAME).class
+$(APP3_JAR) : $(SAMPLE_CLASS_OUT)/$(APP3_NAME).mf $(SAMPLE_CLASS_OUT)/$(APP3_NAME).class
+$(APP4_JAR) : $(SAMPLE_CLASS_OUT)/$(APP4_NAME).mf $(SAMPLE_CLASS_OUT)/$(APP4_NAME).class
+$(APP5_JAR) : $(SAMPLE_CLASS_OUT)/$(APP5_NAME).mf $(SAMPLE_CLASS_OUT)/$(APP5_NAME).class
+$(APP6_JAR) : $(SAMPLE_CLASS_OUT)/$(APP6_NAME).mf $(SAMPLE_CLASS_OUT)/$(APP6_NAME).class
+$(APP7_JAR) : $(SAMPLE_CLASS_OUT)/$(APP7_NAME).mf $(SAMPLE_CLASS_OUT)/$(APP7_NAME).class
+$(APP8_JAR) : $(SAMPLE_CLASS_OUT)/$(APP8_NAME).mf $(SAMPLE_CLASS_OUT)/$(APP8_NAME).class
+$(APP9_JAR) : $(SAMPLE_CLASS_OUT)/$(APP9_NAME).mf $(SAMPLE_CLASS_OUT)/$(APP9_NAME).class
+$(APP10_JAR) : $(SAMPLE_CLASS_OUT)/$(APP10_NAME).mf $(SAMPLE_CLASS_OUT)/$(APP10_NAME).class
+$(APP11_JAR) : $(SAMPLE_CLASS_OUT)/$(APP11_NAME).mf $(SAMPLE_CLASS_OUT)/$(APP11_NAME).class
+$(APP12_JAR) : $(SAMPLE_CLASS_OUT)/$(APP12_NAME).mf $(SAMPLE_CLASS_OUT)/$(APP12_NAME).class
+$(APP13_JAR) : $(SAMPLE_CLASS_OUT)/$(APP13_NAME).mf $(SAMPLE_CLASS_OUT)/$(APP13_NAME).class
+$(APP14_JAR) : $(SAMPLE_CLASS_OUT)/$(APP14_NAME).mf $(SAMPLE_CLASS_OUT)/$(APP14_NAME).class
+
+DrawingExamples : $(APP1_JAR) $(APP2_JAR) $(APP3_JAR) $(APP4_JAR) $(APP5_JAR) $(APP6_JAR) $(APP7_JAR) $(APP8_JAR) $(APP9_JAR) $(APP10_JAR) $(APP11_JAR) $(APP12_JAR) $(APP13_JAR) $(APP14_JAR)
+ @echo --------------------------------------------------------------------------------
+ @echo Please use one of the following commands to execute the examples!
+ @echo -
+ @echo $(MAKE) $(APP1_NAME).run
+ @echo $(MAKE) $(APP2_NAME).run
+ @echo $(MAKE) $(APP3_NAME).run
+ @echo $(MAKE) $(APP4_NAME).run
+ @echo $(MAKE) $(APP5_NAME).run
+ @echo $(MAKE) $(APP6_NAME).run
+ @echo $(MAKE) $(APP7_NAME).run
+ @echo $(MAKE) $(APP8_NAME).run
+ @echo $(MAKE) $(APP9_NAME).run
+ @echo $(MAKE) $(APP10_NAME).run
+ @echo $(MAKE) $(APP11_NAME).run
+ @echo $(MAKE) $(APP12_NAME).run
+ @echo $(MAKE) $(APP13_NAME).run
+ @echo $(MAKE) $(APP14_NAME).run
+ @echo --------
+ @echo The $(APP5_NAME) and the $(APP8_NAME) needs parameters. Please use the
+ @echo following command to start the demo if you do not want the default parameters
+ @echo specified in the this makefile:
+ @echo --- $(APP5_NAME) ---
+ @echo java -Dcom.sun.star.lib.loader.unopath="$(QM)$(OFFICE_PROGRAM_PATH)$(QM)" -jar $(APP5_NAME).jar "$(QM)SourceUrl$(QM)"
+ @echo --- $(APP8_NAME) ---
+ @echo java -Dcom.sun.star.lib.loader.unopath="$(QM)$(OFFICE_PROGRAM_PATH)$(QM)" -jar $(APP8_NAME).jar "$(QM)SourceUrl$(QM)" "$(QM)DestinationUrl$(QM)" "$(QM)index$(QM)"
+ @echo --------------------------------------------------------------------------------
+
+%.run: $(SAMPLE_CLASS_OUT)/%.jar
+ $(SDK_JAVA) -Dcom.sun.star.lib.loader.unopath="$(OFFICE_PROGRAM_PATH)" -jar $<
+
+$(APP5_NAME).run: $(APP5_JAR)
+ $(SDK_JAVA) -Dcom.sun.star.lib.loader.unopath="$(OFFICE_PROGRAM_PATH)" -jar $< SimplePresentation.odp
+
+$(APP8_NAME).run: $(APP8_JAR)
+ -$(MKDIR) $(subst /,$(PS),$(SAMPLE_GEN_OUT)/export)
+ $(SDK_JAVA) -Dcom.sun.star.lib.loader.unopath="$(OFFICE_PROGRAM_PATH)" -jar $< SimplePresentation.odp "$(SAMPLE_GEN_OUT)/export/MyTestExport.gif" 2
+
+
+.PHONY: clean
+clean :
+ -$(DELRECURSIVE) $(subst /,$(PS),$(SAMPLE_CLASS_OUT))
+ -$(DELRECURSIVE) $(subst /,$(PS),$(SAMPLE_GEN_OUT))
diff --git a/odk/examples/DevelopersGuide/Drawing/ObjectTransformationDemo.java b/odk/examples/DevelopersGuide/Drawing/ObjectTransformationDemo.java
new file mode 100644
index 000000000..5bf81e577
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Drawing/ObjectTransformationDemo.java
@@ -0,0 +1,131 @@
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+// __________ Imports __________
+
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.lang.XComponent;
+
+import com.sun.star.awt.Point;
+import com.sun.star.awt.Size;
+
+import com.sun.star.beans.PropertyValue;
+import com.sun.star.beans.XPropertySet;
+
+import com.sun.star.drawing.XShape;
+import com.sun.star.drawing.XShapes;
+import com.sun.star.drawing.XDrawPage;
+import com.sun.star.drawing.HomogenMatrix3;
+
+import java.awt.geom.AffineTransform;
+
+// __________ Implementation __________
+
+// ObjectTransformationDemo
+
+public class ObjectTransformationDemo
+{
+ public static void main( String args[] )
+ {
+ XComponent xDrawDoc = null;
+ try
+ {
+ // get the remote office context of a running office (a new office
+ // instance is started if necessary)
+ com.sun.star.uno.XComponentContext xOfficeContext = Helper.connect();
+
+ // suppress Presentation Autopilot when opening the document
+ // properties are the same as described for
+ // com.sun.star.document.MediaDescriptor
+ PropertyValue[] pPropValues = new PropertyValue[ 1 ];
+ pPropValues[ 0 ] = new PropertyValue();
+ pPropValues[ 0 ].Name = "Silent";
+ pPropValues[ 0 ].Value = Boolean.TRUE;
+
+ xDrawDoc = Helper.createDocument( xOfficeContext,
+ "private:factory/simpress", "_blank", 0, pPropValues );
+
+ XDrawPage xPage = PageHelper.getDrawPageByIndex( xDrawDoc, 0 );
+ XPropertySet xPagePropSet= UnoRuntime.queryInterface( XPropertySet.class, xPage );
+
+ XShapes xShapes = UnoRuntime.queryInterface( XShapes.class, xPage );
+
+
+ XShape xShape = ShapeHelper.createShape( xDrawDoc,
+ new Point( 0, 0 ), new Size( 10000, 2500 ),
+ "com.sun.star.drawing.RectangleShape" );
+ xShapes.add( xShape );
+
+ XPropertySet xPropSet = UnoRuntime.queryInterface( XPropertySet.class, xShape );
+
+ HomogenMatrix3 aHomogenMatrix3 = (HomogenMatrix3)
+ xPropSet.getPropertyValue( "Transformation" );
+
+ java.awt.geom.AffineTransform aOriginalMatrix =
+ new java.awt.geom.AffineTransform(
+ aHomogenMatrix3.Line1.Column1, aHomogenMatrix3.Line2.Column1,
+ aHomogenMatrix3.Line1.Column2, aHomogenMatrix3.Line2.Column2,
+ aHomogenMatrix3.Line1.Column3, aHomogenMatrix3.Line2.Column3 );
+
+
+ AffineTransform aNewMatrix1 = new AffineTransform();
+ aNewMatrix1.setToRotation( Math.PI /180 * 15 );
+ aNewMatrix1.concatenate( aOriginalMatrix );
+
+ AffineTransform aNewMatrix2 = new AffineTransform();
+ aNewMatrix2.setToTranslation( 2000, 2000 );
+ aNewMatrix2.concatenate( aNewMatrix1 );
+
+ double aFlatMatrix[] = new double[ 6 ];
+ aNewMatrix2.getMatrix( aFlatMatrix );
+ aHomogenMatrix3.Line1.Column1 = aFlatMatrix[ 0 ];
+ aHomogenMatrix3.Line2.Column1 = aFlatMatrix[ 1 ];
+ aHomogenMatrix3.Line1.Column2 = aFlatMatrix[ 2 ];
+ aHomogenMatrix3.Line2.Column2 = aFlatMatrix[ 3 ];
+ aHomogenMatrix3.Line1.Column3 = aFlatMatrix[ 4 ];
+ aHomogenMatrix3.Line2.Column3 = aFlatMatrix[ 5 ];
+ xPropSet.setPropertyValue( "Transformation", aHomogenMatrix3 );
+
+
+ }
+ catch( Exception ex )
+ {
+ System.out.println( ex );
+ }
+ System.exit( 0 );
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/Drawing/Organigram.java b/odk/examples/DevelopersGuide/Drawing/Organigram.java
new file mode 100644
index 000000000..f87fb4cf9
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Drawing/Organigram.java
@@ -0,0 +1,176 @@
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+import com.sun.star.beans.PropertyValue;
+import com.sun.star.frame.XComponentLoader;
+
+import com.sun.star.lang.XComponent;
+import com.sun.star.lang.XMultiComponentFactory;
+
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.AnyConverter;
+import com.sun.star.uno.XComponentContext;
+
+
+public class Organigram {
+
+ private XComponentContext xRemoteContext = null;
+ private XMultiComponentFactory xRemoteServiceManager = null;
+
+ /** Creates a new instance of OpenQuery */
+ public Organigram() {
+ }
+
+ /**
+ * @param args the command line arguments
+ */
+ public static void main(String[] args) {
+ Organigram organigram1 = new Organigram();
+ try {
+ organigram1.drawOrganigram();
+ }
+ catch (java.lang.Exception e){
+ e.printStackTrace();
+ }
+ finally {
+ System.exit(0);
+ }
+ }
+ public void drawOrganigram() throws java.lang.Exception {
+ // get the remote office component context
+ xRemoteContext = com.sun.star.comp.helper.Bootstrap.bootstrap();
+ System.out.println("Connected to a running office ...");
+ // get the remote service manager
+ xRemoteServiceManager = xRemoteContext.getServiceManager();
+
+ Object desktop = xRemoteServiceManager.createInstanceWithContext(
+ "com.sun.star.frame.Desktop", xRemoteContext);
+ XComponentLoader xComponentLoader = UnoRuntime.queryInterface(XComponentLoader.class, desktop);
+
+ PropertyValue[] loadProps = new PropertyValue[0];
+ XComponent xDrawComponent = xComponentLoader.loadComponentFromURL(
+ "private:factory/sdraw", "_blank", 0, loadProps);
+
+ // get draw page by index
+ com.sun.star.drawing.XDrawPagesSupplier xDrawPagesSupplier =
+ UnoRuntime.queryInterface(
+ com.sun.star.drawing.XDrawPagesSupplier.class, xDrawComponent );
+ com.sun.star.drawing.XDrawPages xDrawPages =
+ xDrawPagesSupplier.getDrawPages();
+ Object drawPage = xDrawPages.getByIndex(0);
+ com.sun.star.drawing.XDrawPage xDrawPage = UnoRuntime.queryInterface(com.sun.star.drawing.XDrawPage.class,
+ drawPage);
+
+ com.sun.star.lang.XMultiServiceFactory xDocumentFactory =
+ UnoRuntime.queryInterface(
+ com.sun.star.lang.XMultiServiceFactory.class, xDrawComponent);
+
+ com.sun.star.beans.XPropertySet xPageProps =
+ UnoRuntime.queryInterface(
+ com.sun.star.beans.XPropertySet.class, xDrawPage);
+
+ int pageWidth = AnyConverter.toInt(xPageProps.getPropertyValue("Width"));
+ int pageHeight = AnyConverter.toInt(xPageProps.getPropertyValue("Height"));
+ int pageBorderTop = AnyConverter.toInt(xPageProps.getPropertyValue("BorderTop"));
+ int pageBorderLeft = AnyConverter.toInt(xPageProps.getPropertyValue("BorderLeft"));
+ int pageBorderRight = AnyConverter.toInt(xPageProps.getPropertyValue("BorderRight"));
+ int drawWidth = pageWidth - pageBorderLeft - pageBorderRight;
+ int horCenter = pageBorderLeft + drawWidth / 2;
+
+ String[][] orgUnits = new String[2][4];
+ orgUnits[0][0] = "Management";
+ orgUnits[1][0] = "Production";
+ orgUnits[1][1] = "Purchasing";
+ orgUnits[1][2] = "IT Services";
+ orgUnits[1][3] = "Sales";
+ int[] levelCount = {1, 4};
+
+ int horSpace = 300;
+ int verSpace = 3000;
+
+ int shapeWidth = (drawWidth - (levelCount[1] - 1) * horSpace) / levelCount[1];
+ int shapeHeight = pageHeight / 20;
+ int shapeX = pageWidth / 2 - shapeWidth / 2;
+ int shapeY = pageBorderTop;
+
+ int levelY;
+ int levelX;
+
+ com.sun.star.drawing.XShape xStartShape = null;
+
+ for (int level = 0; level <= 1; level++) {
+ levelY = pageBorderTop + 2000 + level * (shapeHeight + verSpace);
+ for (int i = levelCount[level] - 1; i > -1; i--) {
+ shapeX = horCenter - (levelCount[level] * shapeWidth +
+ (levelCount[level] - 1) * horSpace) / 2
+ + i * shapeWidth + i * horSpace;
+ Object shape = xDocumentFactory.createInstance("com.sun.star.drawing.RectangleShape");
+ com.sun.star.drawing.XShape xShape = UnoRuntime.queryInterface(
+ com.sun.star.drawing.XShape.class, shape);
+ xShape.setPosition(new com.sun.star.awt.Point(shapeX, levelY));
+ xShape.setSize(new com.sun.star.awt.Size(shapeWidth, shapeHeight));
+ xDrawPage.add(xShape);
+
+ com.sun.star.text.XText xText = UnoRuntime.queryInterface(
+ com.sun.star.text.XText.class, xShape);
+
+ xText.setString(orgUnits[level][i]);
+
+ // memorize the root shape
+ if (level == 0 && i == 0)
+ xStartShape = xShape;
+
+ if (level == 1) {
+ Object connector = xDocumentFactory.createInstance("com.sun.star.drawing.ConnectorShape");
+ com.sun.star.beans.XPropertySet xConnectorProps =
+ UnoRuntime.queryInterface(
+ com.sun.star.beans.XPropertySet.class, connector);
+ com.sun.star.drawing.XShape xConnector =
+ UnoRuntime.queryInterface(
+ com.sun.star.drawing.XShape.class, connector);
+ xDrawPage.add(xConnector);
+ xConnectorProps.setPropertyValue("StartShape", xStartShape);
+ xConnectorProps.setPropertyValue("EndShape", xShape);
+ xConnectorProps.setPropertyValue("StartGluePointIndex",
+ Integer.valueOf(2)); // 2 = bottom gluepoint
+ xConnectorProps.setPropertyValue("EndGluePointIndex",
+ Integer.valueOf(0)); // 0 = top gluepoint
+ }
+ }
+ }
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/Drawing/PageHelper.java b/odk/examples/DevelopersGuide/Drawing/PageHelper.java
new file mode 100644
index 000000000..9e8cfa295
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Drawing/PageHelper.java
@@ -0,0 +1,199 @@
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+// __________ Imports __________
+
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.lang.XComponent;
+import com.sun.star.lang.XServiceInfo;
+
+import com.sun.star.awt.Size;
+
+import com.sun.star.beans.XPropertySet;
+
+import com.sun.star.drawing.XDrawPage;
+import com.sun.star.drawing.XDrawPages;
+import com.sun.star.drawing.XDrawPagesSupplier;
+import com.sun.star.drawing.XMasterPageTarget;
+import com.sun.star.drawing.XMasterPagesSupplier;
+
+import com.sun.star.presentation.XPresentationPage;
+import com.sun.star.presentation.XHandoutMasterSupplier;
+
+
+public class PageHelper
+{
+ // __________ static helper methods __________
+
+ // __________ draw pages __________
+
+ /** get the page count for standard pages
+ */
+ public static int getDrawPageCount( XComponent xComponent )
+ {
+ XDrawPagesSupplier xDrawPagesSupplier =
+ UnoRuntime.queryInterface(
+ XDrawPagesSupplier.class, xComponent );
+ XDrawPages xDrawPages = xDrawPagesSupplier.getDrawPages();
+ return xDrawPages.getCount();
+ }
+
+ /** get draw page by index
+ */
+ public static XDrawPage getDrawPageByIndex( XComponent xComponent, int nIndex )
+ throws com.sun.star.lang.IndexOutOfBoundsException,
+ com.sun.star.lang.WrappedTargetException
+ {
+ XDrawPagesSupplier xDrawPagesSupplier =
+ UnoRuntime.queryInterface(
+ XDrawPagesSupplier.class, xComponent );
+ XDrawPages xDrawPages = xDrawPagesSupplier.getDrawPages();
+ return UnoRuntime.queryInterface(XDrawPage.class, xDrawPages.getByIndex( nIndex ));
+ }
+
+ /** creates and inserts a draw page into the giving position,
+ the method returns the new created page
+ */
+ public static XDrawPage insertNewDrawPageByIndex( XComponent xComponent, int nIndex )
+ throws Exception
+ {
+ XDrawPagesSupplier xDrawPagesSupplier =
+ UnoRuntime.queryInterface(
+ XDrawPagesSupplier.class, xComponent );
+ XDrawPages xDrawPages = xDrawPagesSupplier.getDrawPages();
+ return xDrawPages.insertNewByIndex( nIndex );
+ }
+
+
+
+ /** get size of the given page
+ */
+ public static Size getPageSize( XDrawPage xDrawPage )
+ throws com.sun.star.beans.UnknownPropertyException,
+ com.sun.star.lang.WrappedTargetException
+ {
+ XPropertySet xPageProperties = UnoRuntime.queryInterface( XPropertySet.class, xDrawPage );
+ return new Size(
+ ((Integer)xPageProperties.getPropertyValue( "Width" )).intValue(),
+ ((Integer)xPageProperties.getPropertyValue( "Height" )).intValue() );
+ }
+
+ // __________ master pages __________
+
+ /** get the page count for master pages
+ */
+ public static int getMasterPageCount( XComponent xComponent )
+ {
+ XMasterPagesSupplier xMasterPagesSupplier =
+ UnoRuntime.queryInterface(
+ XMasterPagesSupplier.class, xComponent );
+ XDrawPages xDrawPages = xMasterPagesSupplier.getMasterPages();
+ return xDrawPages.getCount();
+ }
+
+ /** get master page by index
+ */
+ public static XDrawPage getMasterPageByIndex( XComponent xComponent, int nIndex )
+ throws com.sun.star.lang.IndexOutOfBoundsException,
+ com.sun.star.lang.WrappedTargetException
+ {
+ XMasterPagesSupplier xMasterPagesSupplier =
+ UnoRuntime.queryInterface(
+ XMasterPagesSupplier.class, xComponent );
+ XDrawPages xDrawPages = xMasterPagesSupplier.getMasterPages();
+ return UnoRuntime.queryInterface(XDrawPage.class, xDrawPages.getByIndex( nIndex ));
+ }
+
+ /** creates and inserts a new master page into the giving position,
+ the method returns the new created page
+ */
+ public static XDrawPage insertNewMasterPageByIndex( XComponent xComponent, int nIndex )
+ {
+ XMasterPagesSupplier xMasterPagesSupplier =
+ UnoRuntime.queryInterface(
+ XMasterPagesSupplier.class, xComponent );
+ XDrawPages xDrawPages = xMasterPagesSupplier.getMasterPages();
+ return xDrawPages.insertNewByIndex( nIndex );
+ }
+
+
+
+
+
+ /** sets given masterpage at the drawpage
+ */
+ public static void setMasterPage( XDrawPage xDrawPage, XDrawPage xMasterPage )
+ {
+ XMasterPageTarget xMasterPageTarget =
+ UnoRuntime.queryInterface(
+ XMasterPageTarget.class, xDrawPage );
+ xMasterPageTarget.setMasterPage( xMasterPage );
+ }
+
+ // __________ presentation pages __________
+
+ /** test if a Presentation Document is supported.
+ This is important, because only presentation documents
+ have notes and handout pages
+ */
+ public static boolean isImpressDocument( XComponent xComponent )
+ {
+ XServiceInfo xInfo = UnoRuntime.queryInterface(
+ XServiceInfo.class, xComponent );
+ return xInfo.supportsService( "com.sun.star.presentation.PresentationDocument" );
+ }
+
+ /** in impress documents each normal draw page has a corresponding notes page
+ */
+ public static XDrawPage getNotesPage( XDrawPage xDrawPage )
+ {
+ XPresentationPage aPresentationPage =
+ UnoRuntime.queryInterface(
+ XPresentationPage.class, xDrawPage );
+ return aPresentationPage.getNotesPage();
+ }
+
+ /** in impress each documents has one handout page
+ */
+ public static XDrawPage getHandoutMasterPage( XComponent xComponent )
+ {
+ XHandoutMasterSupplier aHandoutMasterSupplier =
+ UnoRuntime.queryInterface(
+ XHandoutMasterSupplier.class, xComponent );
+ return aHandoutMasterSupplier.getHandoutMasterPage();
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/Drawing/PresentationDemo.java b/odk/examples/DevelopersGuide/Drawing/PresentationDemo.java
new file mode 100644
index 000000000..06b5bc4b1
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Drawing/PresentationDemo.java
@@ -0,0 +1,232 @@
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+// __________ Imports __________
+
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.lang.XComponent;
+import com.sun.star.lang.XServiceInfo;
+
+import com.sun.star.awt.Point;
+import com.sun.star.awt.Size;
+
+import com.sun.star.beans.PropertyValue;
+import com.sun.star.beans.XPropertySet;
+
+import com.sun.star.container.XNamed;
+
+import com.sun.star.drawing.XShape;
+import com.sun.star.drawing.XShapes;
+import com.sun.star.drawing.XDrawPage;
+
+import com.sun.star.presentation.XPresentation;
+import com.sun.star.presentation.XPresentationSupplier;
+
+
+
+// __________ Implementation __________
+
+// presentation demo
+
+// This demo will demonstrate how to create a presentation using the Office API
+
+// The first parameter describes the connection that is to use. If there is no parameter
+// "uno:socket,host=localhost,port=2083;urp;StarOffice.ServiceManager" is used.
+
+
+public class PresentationDemo
+{
+ public static void main( String args[] )
+ {
+ XComponent xDrawDoc = null;
+ try
+ {
+ // get the remote office context of a running office (a new office
+ // instance is started if necessary)
+ com.sun.star.uno.XComponentContext xOfficeContext = Helper.connect();
+
+ // suppress Presentation Autopilot when opening the document
+ // properties are the same as described for
+ // com.sun.star.document.MediaDescriptor
+ PropertyValue[] pPropValues = new PropertyValue[ 1 ];
+ pPropValues[ 0 ] = new PropertyValue();
+ pPropValues[ 0 ].Name = "Silent";
+ pPropValues[ 0 ].Value = Boolean.TRUE;
+
+ xDrawDoc = Helper.createDocument( xOfficeContext,
+ "private:factory/simpress", "_blank", 0, pPropValues );
+
+
+ XDrawPage xPage;
+ XShapes xShapes;
+ XPropertySet xShapePropSet;
+
+ // create pages, so that three are available
+ while ( PageHelper.getDrawPageCount( xDrawDoc ) < 3 )
+ PageHelper.insertNewDrawPageByIndex( xDrawDoc, 0 );
+
+
+ // set the slide transition for the first page
+ xPage = PageHelper.getDrawPageByIndex( xDrawDoc, 0 );
+ xShapes = UnoRuntime.queryInterface( XShapes.class, xPage );
+ // set slide transition effect
+ setSlideTransition( xPage,
+ com.sun.star.presentation.FadeEffect.FADE_FROM_RIGHT,
+ com.sun.star.presentation.AnimationSpeed.FAST,
+ 1, 0 ); // automatic object and slide transition
+
+ // create a rectangle that is placed on the top left of the page
+ xShapePropSet = ShapeHelper.createAndInsertShape( xDrawDoc,
+ xShapes,new Point( 1000, 1000 ), new Size( 5000, 5000 ),
+ "com.sun.star.drawing.RectangleShape" );
+ xShapePropSet.setPropertyValue("Effect",
+ com.sun.star.presentation.AnimationEffect.WAVYLINE_FROM_BOTTOM );
+
+ /* the following three properties provokes that the shape is dimmed
+ to red
+ after the animation has been finished */
+ xShapePropSet.setPropertyValue( "DimHide", Boolean.FALSE );
+ xShapePropSet.setPropertyValue( "DimPrevious", Boolean.TRUE );
+ xShapePropSet.setPropertyValue( "DimColor", Integer.valueOf( 0xff0000 ) );
+
+
+ // set the slide transition for the second page
+ xPage = PageHelper.getDrawPageByIndex( xDrawDoc, 1 );
+ xShapes = UnoRuntime.queryInterface( XShapes.class, xPage );
+ setSlideTransition( xPage,
+ com.sun.star.presentation.FadeEffect.FADE_FROM_RIGHT,
+ com.sun.star.presentation.AnimationSpeed.SLOW,
+ 1, 0 ); // automatic object and slide transition
+
+ // create an ellipse that is placed on the bottom right of second page
+ xShapePropSet = ShapeHelper.createAndInsertShape( xDrawDoc,
+ xShapes, new Point( 21000, 15000 ), new Size( 5000, 5000 ),
+ "com.sun.star.drawing.EllipseShape" );
+ xShapePropSet.setPropertyValue(
+ "Effect", com.sun.star.presentation.AnimationEffect.HIDE );
+
+
+ // create two objects for the third page
+ // clicking the first object lets the presentation jump
+ // to page one by using ClickAction.FIRSTPAGE,
+ // the second object lets the presentation jump to page two
+ // by using a ClickAction.BOOKMARK;
+ xPage = PageHelper.getDrawPageByIndex( xDrawDoc, 2 );
+ xShapes = UnoRuntime.queryInterface( XShapes.class, xPage );
+ setSlideTransition( xPage,
+ com.sun.star.presentation.FadeEffect.ROLL_FROM_LEFT,
+ com.sun.star.presentation.AnimationSpeed.MEDIUM,
+ 2, 0 );
+ XShape xShape = ShapeHelper.createShape( xDrawDoc,
+ new Point( 1000, 8000 ), new Size( 5000, 5000 ),
+ "com.sun.star.drawing.EllipseShape" );
+ xShapes.add( xShape );
+ ShapeHelper.addPortion( xShape, "click to go", false );
+ ShapeHelper.addPortion( xShape, "to first page", true );
+ xShapePropSet = UnoRuntime.queryInterface( XPropertySet.class, xShape );
+ xShapePropSet.setPropertyValue("Effect",
+ com.sun.star.presentation.AnimationEffect.FADE_FROM_BOTTOM );
+ xShapePropSet.setPropertyValue(
+ "OnClick", com.sun.star.presentation.ClickAction.FIRSTPAGE );
+
+
+ xShape = ShapeHelper.createShape( xDrawDoc,
+ new Point( 22000, 8000 ), new Size( 5000, 5000 ),
+ "com.sun.star.drawing.RectangleShape" );
+ xShapes.add( xShape );
+ ShapeHelper.addPortion( xShape, "click to go", false );
+ ShapeHelper.addPortion( xShape, "to the second page", true );
+ xShapePropSet = UnoRuntime.queryInterface( XPropertySet.class, xShape );
+ xShapePropSet.setPropertyValue("Effect",
+ com.sun.star.presentation.AnimationEffect.FADE_FROM_BOTTOM );
+
+ xShapePropSet.setPropertyValue(
+ "OnClick", com.sun.star.presentation.ClickAction.BOOKMARK );
+ // set the name of page two, and use it with the bookmark action
+ XNamed xPageName = UnoRuntime.queryInterface(
+ XNamed.class, PageHelper.getDrawPageByIndex( xDrawDoc, 1 ) );
+ xPageName.setName( "page two" );
+ xShapePropSet.setPropertyValue(
+ "Bookmark", xPageName.getName() );
+
+
+ /* start an endless presentation which is displayed in
+ full-screen mode and placed on top */
+
+ XPresentationSupplier xPresSupplier = UnoRuntime.queryInterface( XPresentationSupplier.class, xDrawDoc );
+ XPresentation xPresentation = xPresSupplier.getPresentation();
+ XPropertySet xPresPropSet = UnoRuntime.queryInterface( XPropertySet.class, xPresentation );
+ xPresPropSet.setPropertyValue( "IsEndless", Boolean.TRUE );
+ xPresPropSet.setPropertyValue( "IsAlwaysOnTop", Boolean.TRUE );
+ xPresPropSet.setPropertyValue( "Pause", Integer.valueOf( 0 ) );
+ xPresentation.start();
+ }
+ catch( Exception ex )
+ {
+ System.out.println( ex );
+ }
+ System.exit( 0 );
+ }
+
+ // this simple method applies the slide transition to a page
+ public static void setSlideTransition( XDrawPage xPage,
+ com.sun.star.presentation.FadeEffect eEffect,
+ com.sun.star.presentation.AnimationSpeed eSpeed,
+ int nChange,
+ int nDuration )
+ {
+ // the following test is only sensible if you do not exactly know
+ // what type of page xPage is, for this purpose it can been tested
+ // if the com.sun.star.presentation.DrawPage service is supported
+ XServiceInfo xInfo = UnoRuntime.queryInterface(
+ XServiceInfo.class, xPage );
+ if ( xInfo.supportsService( "com.sun.star.presentation.DrawPage" ) )
+ {
+ try
+ {
+ XPropertySet xPropSet = UnoRuntime.queryInterface( XPropertySet.class, xPage );
+ xPropSet.setPropertyValue( "Effect", eEffect );
+ xPropSet.setPropertyValue( "Speed", eSpeed );
+ xPropSet.setPropertyValue( "Change", Integer.valueOf( nChange ) );
+ xPropSet.setPropertyValue( "Duration", Integer.valueOf( nDuration ) );
+ }
+ catch( Exception ex )
+ {
+ }
+ }
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/Drawing/ShapeHelper.java b/odk/examples/DevelopersGuide/Drawing/ShapeHelper.java
new file mode 100644
index 000000000..44b9b28a7
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Drawing/ShapeHelper.java
@@ -0,0 +1,142 @@
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+// __________ Imports __________
+
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.lang.XComponent;
+import com.sun.star.lang.XMultiServiceFactory;
+
+import com.sun.star.awt.Point;
+import com.sun.star.awt.Size;
+
+import com.sun.star.beans.XPropertySet;
+
+import com.sun.star.container.XEnumeration;
+import com.sun.star.container.XEnumerationAccess;
+
+import com.sun.star.drawing.XShape;
+import com.sun.star.drawing.XShapes;
+
+import com.sun.star.text.ControlCharacter;
+import com.sun.star.text.XText;
+import com.sun.star.text.XTextCursor;
+import com.sun.star.text.XTextContent;
+import com.sun.star.text.XTextRange;
+
+
+public class ShapeHelper
+{
+ // __________ static helper methods __________
+
+ public static XPropertySet createAndInsertShape( XComponent xDrawDoc,
+ XShapes xShapes, Point aPos, Size aSize, String sShapeType )
+ throws java.lang.Exception
+ {
+ XShape xShape = createShape( xDrawDoc, aPos, aSize, sShapeType );
+ xShapes.add( xShape );
+ XPropertySet xPropSet = UnoRuntime.queryInterface( XPropertySet.class, xShape );
+ return xPropSet;
+ }
+
+ /** create a Shape
+ */
+ public static XShape createShape( XComponent xDrawDoc,
+ Point aPos, Size aSize, String sShapeType )
+ throws java.lang.Exception
+ {
+ XShape xShape = null;
+ XMultiServiceFactory xFactory =
+ UnoRuntime.queryInterface(
+ XMultiServiceFactory.class, xDrawDoc );
+ Object xObj = xFactory.createInstance( sShapeType );
+ xShape = UnoRuntime.queryInterface(
+ XShape.class, xObj );
+ xShape.setPosition( aPos );
+ xShape.setSize( aSize );
+ return xShape;
+ }
+
+ /**
+ add text to a shape. the return value is the PropertySet
+ of the text range that has been added
+ */
+ public static XPropertySet addPortion( XShape xShape, String sText, boolean bNewParagraph )
+ throws com.sun.star.lang.IllegalArgumentException
+ {
+ XText xText = UnoRuntime.queryInterface( XText.class, xShape );
+
+ XTextCursor xTextCursor = xText.createTextCursor();
+ xTextCursor.gotoEnd( false );
+ if ( bNewParagraph == true )
+ {
+ xText.insertControlCharacter( xTextCursor, ControlCharacter.PARAGRAPH_BREAK, false );
+ xTextCursor.gotoEnd( false );
+ }
+ XTextRange xTextRange = UnoRuntime.queryInterface( XTextRange.class, xTextCursor );
+ xTextRange.setString( sText );
+ xTextCursor.gotoEnd( true );
+ XPropertySet xPropSet = UnoRuntime.queryInterface( XPropertySet.class, xTextRange );
+ return xPropSet;
+ }
+
+ public static void setPropertyForLastParagraph( XShape xText, String sPropName,
+ Object aValue )
+ throws com.sun.star.beans.UnknownPropertyException,
+ com.sun.star.beans.PropertyVetoException,
+ com.sun.star.lang.IllegalArgumentException,
+ com.sun.star.lang.WrappedTargetException,
+ com.sun.star.container.NoSuchElementException
+ {
+ XEnumerationAccess xEnumerationAccess = UnoRuntime.queryInterface( XEnumerationAccess.class, xText );
+ if ( xEnumerationAccess.hasElements() )
+ {
+ XEnumeration xEnumeration = xEnumerationAccess.createEnumeration();
+ while( xEnumeration.hasMoreElements () )
+ {
+ Object xObj = xEnumeration.nextElement();
+ if ( xEnumeration.hasMoreElements() == false )
+ {
+ XTextContent xTextContent = UnoRuntime.queryInterface(
+ XTextContent.class, xObj );
+ XPropertySet xParaPropSet = UnoRuntime.queryInterface( XPropertySet.class, xTextContent );
+ xParaPropSet.setPropertyValue( sPropName, aValue );
+ }
+ }
+ }
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/Drawing/SimplePresentation.odp b/odk/examples/DevelopersGuide/Drawing/SimplePresentation.odp
new file mode 100644
index 000000000..3f40f7660
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Drawing/SimplePresentation.odp
Binary files differ
diff --git a/odk/examples/DevelopersGuide/Drawing/StyleDemo.java b/odk/examples/DevelopersGuide/Drawing/StyleDemo.java
new file mode 100644
index 000000000..3f9b083be
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Drawing/StyleDemo.java
@@ -0,0 +1,164 @@
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+// __________ Imports __________
+
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.lang.XComponent;
+
+import com.sun.star.awt.Point;
+import com.sun.star.awt.Size;
+
+import com.sun.star.beans.PropertyValue;
+import com.sun.star.beans.XPropertySet;
+import com.sun.star.beans.XPropertySetInfo;
+
+import com.sun.star.drawing.XShape;
+import com.sun.star.drawing.XShapes;
+import com.sun.star.drawing.XDrawPage;
+import com.sun.star.drawing.XDrawPages;
+import com.sun.star.drawing.XDrawPagesSupplier;
+
+import com.sun.star.frame.XModel;
+
+
+
+// __________ Implementation __________
+
+// StyleDemo
+
+public class StyleDemo
+{
+ public static void main( String args[] )
+ {
+ XComponent xComponent = null;
+ try
+ {
+ // get the remote office context of a running office (a new office
+ // instance is started if necessary)
+ com.sun.star.uno.XComponentContext xOfficeContext = Helper.connect();
+
+ // suppress Presentation Autopilot when opening the document
+ // properties are the same as described for
+ // com.sun.star.document.MediaDescriptor
+ PropertyValue[] pPropValues = new PropertyValue[ 1 ];
+ pPropValues[ 0 ] = new PropertyValue();
+ pPropValues[ 0 ].Name = "Silent";
+ pPropValues[ 0 ].Value = Boolean.TRUE;
+
+ xComponent = Helper.createDocument( xOfficeContext,
+ "private:factory/simpress", "_blank", 0, pPropValues );
+
+
+
+
+ /* The first part of this demo will set each "CharColor" Property
+ that is available within the styles of the document to red. It
+ will also print each family and style name to the standard output */
+ XModel xModel =
+ UnoRuntime.queryInterface(
+ XModel.class, xComponent );
+ com.sun.star.style.XStyleFamiliesSupplier xSFS =
+ UnoRuntime.queryInterface(
+ com.sun.star.style.XStyleFamiliesSupplier.class, xModel );
+
+ com.sun.star.container.XNameAccess xFamilies = xSFS.getStyleFamilies();
+
+ // the element should now contain at least two Styles. The first is
+ // "graphics" and the other one is the name of the Master page
+ String[] Families = xFamilies.getElementNames();
+ for ( int i = 0; i < Families.length; i++ )
+ {
+ // this is the family
+ System.out.println( "\n" + Families[ i ] );
+
+ // and now all available styles
+ Object aFamilyObj = xFamilies.getByName( Families[ i ] );
+ com.sun.star.container.XNameAccess xStyles =
+ UnoRuntime.queryInterface(
+ com.sun.star.container.XNameAccess.class, aFamilyObj );
+ String[] Styles = xStyles.getElementNames();
+ for( int j = 0; j < Styles.length; j++ )
+ {
+ System.out.println( " " + Styles[ j ] );
+ Object aStyleObj = xStyles.getByName( Styles[ j ] );
+ com.sun.star.style.XStyle xStyle = UnoRuntime.queryInterface(
+ com.sun.star.style.XStyle.class, aStyleObj );
+ // now we have the XStyle Interface and the CharColor for
+ // all styles is exemplary be set to red.
+ XPropertySet xStylePropSet = UnoRuntime.queryInterface( XPropertySet.class, xStyle );
+ XPropertySetInfo xStylePropSetInfo =
+ xStylePropSet.getPropertySetInfo();
+ if ( xStylePropSetInfo.hasPropertyByName( "CharColor" ) )
+ {
+ xStylePropSet.setPropertyValue( "CharColor",
+ Integer.valueOf( 0xff0000 ) );
+ }
+ }
+ }
+
+
+
+ /* now create a rectangle and apply the "title1" style of
+ the "graphics" family */
+
+ Object obj = xFamilies.getByName( "graphics" );
+ com.sun.star.container.XNameAccess xStyles = UnoRuntime.queryInterface(com.sun.star.container.XNameAccess.class,
+ obj );
+ obj = xStyles.getByName( "title1" );
+ com.sun.star.style.XStyle xTitle1Style = UnoRuntime.queryInterface( com.sun.star.style.XStyle.class, obj );
+
+ XDrawPagesSupplier xDrawPagesSupplier = UnoRuntime.queryInterface( XDrawPagesSupplier.class, xComponent );
+ XDrawPages xDrawPages = xDrawPagesSupplier.getDrawPages();
+ XDrawPage xDrawPage = UnoRuntime.queryInterface(
+ XDrawPage.class, xDrawPages.getByIndex( 0 ));
+ XShapes xShapes = UnoRuntime.queryInterface(XShapes.class,
+ xDrawPage );
+ XShape xShape = ShapeHelper.createShape( xComponent, new Point( 0, 0 ),
+ new Size( 5000, 5000 ), "com.sun.star.drawing.RectangleShape" );
+ xShapes.add( xShape );
+ XPropertySet xPropSet = UnoRuntime.queryInterface( XPropertySet.class, xShape );
+ xPropSet.setPropertyValue( "Style", xTitle1Style );
+
+ }
+ catch( Exception ex )
+ {
+ System.out.println( ex );
+ }
+ System.exit( 0 );
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/Drawing/TextDemo.java b/odk/examples/DevelopersGuide/Drawing/TextDemo.java
new file mode 100644
index 000000000..c03075c7d
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Drawing/TextDemo.java
@@ -0,0 +1,153 @@
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+// __________ Imports __________
+
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.lang.XComponent;
+
+import com.sun.star.awt.Point;
+import com.sun.star.awt.Size;
+
+import com.sun.star.beans.PropertyValue;
+import com.sun.star.beans.XPropertySet;
+
+import com.sun.star.drawing.XShape;
+import com.sun.star.drawing.XShapes;
+import com.sun.star.drawing.XDrawPage;
+import com.sun.star.drawing.TextFitToSizeType;
+
+import com.sun.star.style.LineSpacing;
+import com.sun.star.style.LineSpacingMode;
+import com.sun.star.style.ParagraphAdjust;
+
+
+
+// __________ Implementation __________
+
+// text demo
+
+public class TextDemo
+{
+ public static void main( String args[] )
+ {
+ XComponent xDrawDoc = null;
+ try
+ {
+ // get the remote office context of a running office (a new office
+ // instance is started if necessary)
+ com.sun.star.uno.XComponentContext xOfficeContext = Helper.connect();
+
+ // suppress Presentation Autopilot when opening the document
+ // properties are the same as described for
+ // com.sun.star.document.MediaDescriptor
+ PropertyValue[] pPropValues = new PropertyValue[ 1 ];
+ pPropValues[ 0 ] = new PropertyValue();
+ pPropValues[ 0 ].Name = "Silent";
+ pPropValues[ 0 ].Value = Boolean.TRUE;
+
+ xDrawDoc = Helper.createDocument( xOfficeContext,
+ "private:factory/sdraw", "_blank", 0, pPropValues );
+
+ XDrawPage xPage = PageHelper.getDrawPageByIndex( xDrawDoc, 0 );
+ XShapes xShapes = UnoRuntime.queryInterface( XShapes.class, xPage );
+
+
+ XShape xRectangle;
+ XPropertySet xTextPropSet, xShapePropSet;
+ LineSpacing aLineSpacing = new LineSpacing();
+ aLineSpacing.Mode = LineSpacingMode.PROP;
+
+
+
+ // first shape
+ xRectangle = ShapeHelper.createShape( xDrawDoc,
+ new Point( 0, 0 ),
+ new Size( 15000, 7500 ),
+ "com.sun.star.drawing.RectangleShape" );
+ xShapes.add( xRectangle );
+ xShapePropSet = UnoRuntime.queryInterface( XPropertySet.class, xRectangle );
+
+
+ // first paragraph
+ xTextPropSet = ShapeHelper.addPortion( xRectangle, "Portion1", false );
+ xTextPropSet.setPropertyValue( "CharColor", Integer.valueOf( 0xff0000 ) );
+ xTextPropSet = ShapeHelper.addPortion( xRectangle, "Portion2", false );
+ xTextPropSet.setPropertyValue( "CharColor", Integer.valueOf( 0x8080ff ) );
+ aLineSpacing.Height = 100;
+ ShapeHelper.setPropertyForLastParagraph( xRectangle, "ParaLineSpacing",
+ aLineSpacing );
+
+ // second paragraph
+ xTextPropSet = ShapeHelper.addPortion( xRectangle, "Portion3", true );
+ xTextPropSet.setPropertyValue( "CharColor", Integer.valueOf( 0xff ) );
+ aLineSpacing.Height = 200;
+ ShapeHelper.setPropertyForLastParagraph( xRectangle, "ParaLineSpacing",
+ aLineSpacing );
+
+
+
+ // second shape
+ xRectangle = ShapeHelper.createShape( xDrawDoc,
+ new Point( 0, 10000 ),
+ new Size( 21000, 12500 ),
+ "com.sun.star.drawing.RectangleShape" );
+ xShapes.add( xRectangle );
+ xShapePropSet = UnoRuntime.queryInterface( XPropertySet.class, xRectangle );
+ xShapePropSet.setPropertyValue( "TextFitToSize",
+ TextFitToSizeType.PROPORTIONAL );
+ xShapePropSet.setPropertyValue( "TextLeftDistance", Integer.valueOf(2500));
+ xShapePropSet.setPropertyValue( "TextRightDistance", Integer.valueOf(2500));
+ xShapePropSet.setPropertyValue( "TextUpperDistance", Integer.valueOf(2500));
+ xShapePropSet.setPropertyValue( "TextLowerDistance", Integer.valueOf(2500));
+ xTextPropSet = ShapeHelper.addPortion( xRectangle,
+ "using TextFitToSize", false );
+ xTextPropSet.setPropertyValue( "ParaAdjust", ParagraphAdjust.CENTER );
+ xTextPropSet.setPropertyValue( "CharColor", Integer.valueOf(0xff00));
+ xTextPropSet = ShapeHelper.addPortion(xRectangle,
+ "and a Border distance of 2,5 cm",
+ true );
+ xTextPropSet.setPropertyValue( "CharColor", Integer.valueOf( 0xff0000 ) );
+
+ }
+ catch( Exception ex )
+ {
+ System.out.println( ex );
+ }
+ System.exit( 0 );
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/Extensions/DialogWithHelp/Addons.xcu b/odk/examples/DevelopersGuide/Extensions/DialogWithHelp/Addons.xcu
new file mode 100644
index 000000000..c2d4a967d
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Extensions/DialogWithHelp/Addons.xcu
@@ -0,0 +1,65 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!--
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+-->
+<oor:component-data xmlns:oor="http://openoffice.org/2001/registry" xmlns:xs="http://www.w3.org/2001/XMLSchema" oor:name="Addons" oor:package="org.openoffice.Office">
+ <node oor:name="AddonUI">
+ <node oor:name="OfficeMenuBar">
+ <node oor:name="com.foocorp.foo-ext:Menu" oor:op="replace">
+ <prop oor:name="Title" oor:type="xs:string">
+ <value/>
+ <value xml:lang="en">Foo E~xtension</value>
+ </prop>
+ <node oor:name="Submenu">
+ <node oor:name="m1" oor:op="replace">
+ <prop oor:name="URL" oor:type="xs:string">
+ <value>vnd.sun.star.script:DialogWithHelp.Module1.main?language=Basic&amp;location=application</value>
+ </prop>
+ <prop oor:name="Target" oor:type="xs:string">
+ <value>_self</value>
+ </prop>
+ <prop oor:name="Title" oor:type="xs:string">
+ <value/>
+ <value xml:lang="en">Start Foo Dialog...</value>
+ </prop>
+ </node>
+ <node oor:name="m3" oor:op="replace">
+ </node>
+ </node>
+ </node>
+ </node>
+ <node oor:name="OfficeToolBar">
+ <node oor:name="com.foocorp.foo-ext:ToolbarItem1" oor:op="replace">
+ <node oor:name="m1" oor:op="replace">
+ <prop oor:name="URL">
+ <value>vnd.sun.star.script:DialogWithHelp.Module1.main?language=Basic&amp;location=application</value>
+ </prop>
+ <prop oor:name="Title">
+ <value xml:lang="en-US">Foo Toolbar Item</value>
+ <value xml:lang="de">Foo Toolbar Eintrag</value>
+ </prop>
+ <prop oor:name="Target" oor:type="xs:string">
+ <value>_self</value>
+ </prop>
+ <prop oor:name="Context" oor:type="xs:string">
+ <value>com.sun.star.text.TextDocument</value>
+ </prop>
+ </node>
+ </node>
+ </node>
+ </node>
+</oor:component-data>
diff --git a/odk/examples/DevelopersGuide/Extensions/DialogWithHelp/DialogWithHelp/Dialog1.xdl b/odk/examples/DevelopersGuide/Extensions/DialogWithHelp/DialogWithHelp/Dialog1.xdl
new file mode 100644
index 000000000..90fc473ad
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Extensions/DialogWithHelp/DialogWithHelp/Dialog1.xdl
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+-->
+<!DOCTYPE dlg:window PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "dialog.dtd">
+<dlg:window xmlns:dlg="http://openoffice.org/2000/dialog" xmlns:script="http://openoffice.org/2000/script" dlg:id="Dialog1" dlg:left="244" dlg:top="200" dlg:width="201" dlg:height="169" dlg:help-url="com.foocorp.foo-ext:FooDialog" dlg:closeable="true" dlg:moveable="true" dlg:title="Foo Dialog">
+ <dlg:bulletinboard>
+ <dlg:button dlg:id="CommandButton1" dlg:tab-index="0" dlg:left="26" dlg:top="26" dlg:width="75" dlg:height="35" dlg:help-url="com.foocorp.foo-ext:FooDialogButton" dlg:value="Do it !">
+ <script:event script:event-name="on-performaction" script:macro-name="vnd.sun.star.script:DialogWithHelp.Module1.HandleDoIt?language=Basic&amp;location=application" script:language="Script"/>
+ </dlg:button>
+ <dlg:button dlg:id="CommandButton2" dlg:tab-index="1" dlg:left="88" dlg:top="100" dlg:width="87" dlg:height="38" dlg:value="Dummy Button, no help"/>
+ </dlg:bulletinboard>
+</dlg:window>
diff --git a/odk/examples/DevelopersGuide/Extensions/DialogWithHelp/DialogWithHelp/Module1.xba b/odk/examples/DevelopersGuide/Extensions/DialogWithHelp/DialogWithHelp/Module1.xba
new file mode 100644
index 000000000..976a0e59f
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Extensions/DialogWithHelp/DialogWithHelp/Module1.xba
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+-->
+<!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd">
+<script:module xmlns:script="http://openoffice.org/2000/script" script:name="Module1" script:language="StarBasic">REM ***** BASIC *****
+
+Sub Main
+ DialogLibraries.loadLibrary( &quot;DialogWithHelp&quot; )
+ oDlg = CreateUnoDialog( DialogLibraries.DialogWithHelp.Dialog1 )
+ oDlg.execute()
+End Sub
+
+Sub HandleDoIt
+ msgbox &quot;I did it!&quot;
+End Sub
+
+
+</script:module> \ No newline at end of file
diff --git a/odk/examples/DevelopersGuide/Extensions/DialogWithHelp/DialogWithHelp/dialog.xlb b/odk/examples/DevelopersGuide/Extensions/DialogWithHelp/DialogWithHelp/dialog.xlb
new file mode 100644
index 000000000..bd7d00efd
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Extensions/DialogWithHelp/DialogWithHelp/dialog.xlb
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE library:library PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "library.dtd">
+<library:library xmlns:library="http://openoffice.org/2000/library" library:name="DialogWithHelp" library:readonly="false" library:passwordprotected="false">
+ <library:element library:name="Dialog1"/>
+</library:library> \ No newline at end of file
diff --git a/odk/examples/DevelopersGuide/Extensions/DialogWithHelp/DialogWithHelp/script.xlb b/odk/examples/DevelopersGuide/Extensions/DialogWithHelp/DialogWithHelp/script.xlb
new file mode 100644
index 000000000..423177601
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Extensions/DialogWithHelp/DialogWithHelp/script.xlb
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE library:library PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "library.dtd">
+<library:library xmlns:library="http://openoffice.org/2000/library" library:name="DialogWithHelp" library:readonly="false" library:passwordprotected="false">
+ <library:element library:name="Module1"/>
+</library:library> \ No newline at end of file
diff --git a/odk/examples/DevelopersGuide/Extensions/DialogWithHelp/META-INF/manifest.xml b/odk/examples/DevelopersGuide/Extensions/DialogWithHelp/META-INF/manifest.xml
new file mode 100644
index 000000000..bdf108308
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Extensions/DialogWithHelp/META-INF/manifest.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+-->
+<manifest:manifest xmlns:manifest="http://openoffice.org/2001/manifest">
+ <manifest:file-entry manifest:full-path="DialogWithHelp/" manifest:media-type="application/vnd.sun.star.basic-library"/>
+ <manifest:file-entry manifest:media-type="application/vnd.sun.star.help" manifest:full-path="help"/>
+ <manifest:file-entry manifest:media-type="application/vnd.sun.star.configuration-data" manifest:full-path="Addons.xcu"/>
+</manifest:manifest>
diff --git a/odk/examples/DevelopersGuide/Extensions/DialogWithHelp/Makefile b/odk/examples/DevelopersGuide/Extensions/DialogWithHelp/Makefile
new file mode 100644
index 000000000..171dd5393
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Extensions/DialogWithHelp/Makefile
@@ -0,0 +1,117 @@
+#*************************************************************************
+#
+# The Contents of this file are made available subject to the terms of
+# the BSD license.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+# 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+# contributors may be used to endorse or promote products derived
+# from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+# TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+# USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+#**************************************************************************
+
+# Builds the DialogWithHelp example of the Developers Guide.
+
+PRJ=../../../..
+SETTINGS=$(PRJ)/settings
+
+include $(SETTINGS)/settings.mk
+include $(SETTINGS)/std.mk
+
+# Define non-platform/compiler specific settings
+SAMPLE_NAME=ExtDialogWithHelp
+SAMPLE_GEN_OUT=$(OUT_MISC)/$(SAMPLE_NAME)
+
+COMP_NAME=DialogWithHelp
+COMP_GEN_OUT=$(SAMPLE_GEN_OUT)/$(COMP_NAME)
+COMP_PACKAGE = $(OUT_BIN)/$(COMP_NAME).$(UNOOXT_EXT)
+COMP_PACKAGE_URL = $(subst \\,\,"$(COMP_PACKAGE_DIR)$(PS)$(COMP_NAME).$(UNOOXT_EXT)")
+COMP_UNOPKG_MANIFEST = $(COMP_GEN_OUT)/META-INF/manifest.xml
+COMP_REGISTERFLAG=$(COMP_GEN_OUT)$(PS)devguide_basic_$(COMP_NAME)_register_component.flag
+
+COMP_LIBRARY_FILES=\
+ DialogWithHelp/dialog.xlb\
+ DialogWithHelp/script.xlb\
+ DialogWithHelp/Module1.xba\
+ DialogWithHelp/Dialog1.xdl
+
+COMP_MISC_FILES=\
+ META-INF/manifest.xml\
+ Addons.xcu\
+ description.xml
+
+COMP_HELP_FILES=\
+ help/de/com.foocorp.foo-ext/page1.xhp\
+ help/de/com.foocorp.foo-ext/page2.xhp\
+ help/de/com.foocorp.foo-ext/subfolder/anotherpage.xhp\
+ help/en/com.foocorp.foo-ext/page1.xhp\
+ help/en/com.foocorp.foo-ext/page2.xhp\
+ help/en/com.foocorp.foo-ext/subfolder/anotherpage.xhp\
+
+# Targets
+.PHONY: ALL
+ALL : $(SAMPLE_NAME)
+
+include $(SETTINGS)/stdtarget.mk
+
+# rule for component package file
+$(COMP_PACKAGE) : $(COMP_LIBRARY_FILES) $(COMP_MISC_FILES) $(COMP_HELP_FILES)
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ $(SDK_ZIP) $@ $(COMP_LIBRARY_FILES)
+ $(SDK_ZIP) $@ $(COMP_MISC_FILES)
+ $(SDK_ZIP) $@ $(COMP_HELP_FILES)
+
+$(COMP_REGISTERFLAG) : $(COMP_PACKAGE)
+ifeq "$(SDK_AUTO_DEPLOYMENT)" "YES"
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ $(DEPLOYTOOL) $(COMP_PACKAGE_URL)
+ @echo flagged > $(subst /,$(PS),$@)
+else
+ @echo --------------------------------------------------------------------------------
+ @echo If you want to install your component automatically, please set the environment
+ @echo variable SDK_AUTO_DEPLOYMENT = YES. But note that auto deployment is only
+ @echo possible if no office instance is running.
+ @echo --------------------------------------------------------------------------------
+endif
+
+$(SAMPLE_NAME) : $(COMP_REGISTERFLAG)
+ @echo --------------------------------------------------------------------------------
+ @echo The "$(QM)DialogWithHelp$(QM)" library was installed in your office installation
+ @echo if SDK_AUTO_DEPLOYMENT = YES. You can use it in the BASIC IDE as a normal
+ @echo Basic library. You also will find a new top level menu "$(QM)Foo Extension$(QM)"
+ @echo with one menu entry "$(QM)Start Foo Dialog$(QM)" to start it directly. If a
+ @echo document is active there is also a "$(QM)Foo Toolbar Item$(QM)" doing the same.
+ @echo All help index entries provided by the help content start with Foo.
+ @echo --------------------------------------------------------------------------------
+
+$(COMP_NAME).odt.load : $(COMP_REGISTERFLAG)
+ "$(OFFICE_PROGRAM_PATH)$(PS)soffice" $(basename $@)
+
+.PHONY: clean
+clean :
+ -$(DELRECURSIVE) $(subst /,$(PS),$(COMP_GEN_OUT))
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$(COMP_PACKAGE_URL)))
diff --git a/odk/examples/DevelopersGuide/Extensions/DialogWithHelp/description.xml b/odk/examples/DevelopersGuide/Extensions/DialogWithHelp/description.xml
new file mode 100644
index 000000000..f5540bb2b
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Extensions/DialogWithHelp/description.xml
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+-->
+<description xmlns="http://openoffice.org/extensions/description/2006" xmlns:d="http://openoffice.org/extensions/description/2006" xmlns:xlink="http://www.w3.org/1999/xlink">
+ <version value="1.0" />
+ <identifier value="com.foocorp.foo-ext"/>
+ <dependencies/>
+ <update-information/>
+ <registration/>
+</description>
diff --git a/odk/examples/DevelopersGuide/Extensions/DialogWithHelp/help/de/com.foocorp.foo-ext/page1.xhp b/odk/examples/DevelopersGuide/Extensions/DialogWithHelp/help/de/com.foocorp.foo-ext/page1.xhp
new file mode 100644
index 000000000..d5ec9d530
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Extensions/DialogWithHelp/help/de/com.foocorp.foo-ext/page1.xhp
@@ -0,0 +1,90 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+-->
+<helpdocument version="1.0">
+<meta>
+<topic id="comfoocorpfooextpage1" indexer="include" status="PUBLISH">
+<title id="tit" xml-lang="de">DE Extension foo page1 DE</title>
+<filename>/com.foocorp.foo-ext/page1.xhp</filename>
+</topic>
+</meta>
+<body>
+<bookmark xml-lang="de" branch="index" id="bm_id0001">
+<bookmark_value>Foo Einzel-Eintrag für page1</bookmark_value>
+<bookmark_value>Foo Alle Seiten;page1</bookmark_value>
+</bookmark>
+<bookmark xml-lang="de" branch="index" id="bm_id0002_swriter_sdraw">
+<bookmark_value>Foo Einzel-Eintrag page1, nur swriter/sdraw</bookmark_value>
+</bookmark>
+<paragraph role="heading" id="hd_id0001" xml-lang="de" level="1">DE Extension foo page1 DE</paragraph>
+<paragraph role="paragraph" id="par_id0001" xml-lang="de">Dies ist "page1" der Extension foo Hilfe.
+<comment>Kommentar am Ende des Paragraphen</comment></paragraph>
+<comment>Einige Links...</comment>
+<paragraph role="heading" id="hd_id0002" xml-lang="de" level="2">Einige Links...</paragraph>
+<paragraph role="paragraph" id="par_id0002" xml-lang="de">
+<link href="com.foocorp.foo-ext/page2.xhp">Dies</link> ist ein Link zu "page2" der Extension foo Hilfe.</paragraph>
+<paragraph role="paragraph" id="par_id0003" xml-lang="de">
+<link href="com.foocorp.foo-ext/page1.xhp#target">Dies</link> ist ein Link zu einer Sektion innerhalb einer Hilfe-Datei (unten in dieser Datei, kann aber auch in einer anderen Datei sein).</paragraph>
+<paragraph role="paragraph" id="par_id0004" xml-lang="de">
+<link href="text/shared/guide/main.xhp">Dies</link> ist ein Link zu einer Hilfe-Seite in der installierten Hilfe.</paragraph>
+<paragraph role="heading" id="hd_id0003" xml-lang="de" level="2">Etwas Füll-Text</paragraph>
+<paragraph role="paragraph" id="par_id0005" xml-lang="de">Ich mag Füll-Text. Ich mag Füll-Text. Ich mag Füll-Text.</paragraph>
+<paragraph role="paragraph" id="par_id0006" xml-lang="de">Ich mag Füll-Text. Ich mag Füll-Text. Ich mag Füll-Text.</paragraph>
+<paragraph role="paragraph" id="par_id0007" xml-lang="de">Ich mag Füll-Text. Ich mag Füll-Text. Ich mag Füll-Text.</paragraph>
+<paragraph role="paragraph" id="par_id0008" xml-lang="de">Ich mag Füll-Text. Ich mag Füll-Text. Ich mag Füll-Text.</paragraph>
+<paragraph role="paragraph" id="par_id0009" xml-lang="de">Ich mag Füll-Text. Ich mag Füll-Text. Ich mag Füll-Text.</paragraph>
+<paragraph role="paragraph" id="par_id0010" xml-lang="de">Ich mag Füll-Text. Ich mag Füll-Text. Ich mag Füll-Text.</paragraph>
+<section id="target">
+<paragraph role="heading" id="hd_id0004" xml-lang="de" level="2">Section "target"</paragraph>
+<paragraph role="paragraph" id="par_id0011" xml-lang="de">
+This is a section within the file page1.xhp. The section has the name "target".
+</paragraph>
+</section>
+<paragraph role="heading" id="hd_id0005" xml-lang="de" level="2">Noch mehr Füll-Text</paragraph>
+<paragraph role="paragraph" id="par_id0012" xml-lang="de" >Dieser Text füllt die Seite um die Section "target" oben anzeigen zu können.</paragraph>
+<paragraph role="paragraph" id="par_id0013" xml-lang="de" >Dieser Text füllt die Seite um die Section "target" oben anzeigen zu können.</paragraph>
+<paragraph role="paragraph" id="par_id0014" xml-lang="de" >Dieser Text füllt die Seite um die Section "target" oben anzeigen zu können.</paragraph>
+<paragraph role="paragraph" id="par_id0015" xml-lang="de" >Dieser Text füllt die Seite um die Section "target" oben anzeigen zu können.</paragraph>
+<paragraph role="paragraph" id="par_id0016" xml-lang="de" >Dieser Text füllt die Seite um die Section "target" oben anzeigen zu können.</paragraph>
+<paragraph role="paragraph" id="par_id0017" xml-lang="de" >Dieser Text füllt die Seite um die Section "target" oben anzeigen zu können.</paragraph>
+<paragraph role="paragraph" id="par_id0018" xml-lang="de" >Dieser Text füllt die Seite um die Section "target" oben anzeigen zu können.</paragraph>
+<paragraph role="paragraph" id="par_id0019" xml-lang="de" >Dieser Text füllt die Seite um die Section "target" oben anzeigen zu können.</paragraph>
+<paragraph role="paragraph" id="par_id0020" xml-lang="de" >Dieser Text füllt die Seite um die Section "target" oben anzeigen zu können.</paragraph>
+<paragraph role="paragraph" id="par_id0021" xml-lang="de" >Dieser Text füllt die Seite um die Section "target" oben anzeigen zu können.</paragraph>
+<paragraph role="paragraph" id="par_id0022" xml-lang="de" >Dieser Text füllt die Seite um die Section "target" oben anzeigen zu können.</paragraph>
+<paragraph role="paragraph" id="par_id0023" xml-lang="de" >Dieser Text füllt die Seite um die Section "target" oben anzeigen zu können.</paragraph>
+<paragraph role="paragraph" id="par_id0024" xml-lang="de" >Dieser Text füllt die Seite um die Section "target" oben anzeigen zu können.</paragraph>
+<paragraph role="paragraph" id="par_id0025" xml-lang="de" >Dieser Text füllt die Seite um die Section "target" oben anzeigen zu können.</paragraph>
+<paragraph role="paragraph" id="par_id0026" xml-lang="de" >Dieser Text füllt die Seite um die Section "target" oben anzeigen zu können.</paragraph>
+<paragraph role="paragraph" id="par_id0027" xml-lang="de" >Dieser Text füllt die Seite um die Section "target" oben anzeigen zu können.</paragraph>
+<paragraph role="paragraph" id="par_id0028" xml-lang="de" >Dieser Text füllt die Seite um die Section "target" oben anzeigen zu können.</paragraph>
+<paragraph role="paragraph" id="par_id0029" xml-lang="de" >Dieser Text füllt die Seite um die Section "target" oben anzeigen zu können.</paragraph>
+<paragraph role="paragraph" id="par_id0030" xml-lang="de" >Dieser Text füllt die Seite um die Section "target" oben anzeigen zu können.</paragraph>
+<paragraph role="paragraph" id="par_id0031" xml-lang="de" >Dieser Text füllt die Seite um die Section "target" oben anzeigen zu können.</paragraph>
+<paragraph role="paragraph" id="par_id0032" xml-lang="de" >Dieser Text füllt die Seite um die Section "target" oben anzeigen zu können.</paragraph>
+<paragraph role="paragraph" id="par_id0033" xml-lang="de" >Dieser Text füllt die Seite um die Section "target" oben anzeigen zu können.</paragraph>
+<paragraph role="paragraph" id="par_id0034" xml-lang="de" >Dieser Text füllt die Seite um die Section "target" oben anzeigen zu können.</paragraph>
+<paragraph role="paragraph" id="par_id0035" xml-lang="de" >Dieser Text füllt die Seite um die Section "target" oben anzeigen zu können.</paragraph>
+<paragraph role="paragraph" id="par_id0036" xml-lang="de" >Dieser Text füllt die Seite um die Section "target" oben anzeigen zu können.</paragraph>
+<section id="relatedtopics">
+<paragraph role="paragraph" id="par_id0037" xml-lang="de">
+Diese Section zeigt einen Link der durch Einfügen der "linkvar" Variable aus subfolder/anotherpage.xhp erzeugt wurde.</paragraph>
+<embed href="com.foocorp.foo-ext/subfolder/anotherpage.xhp#linkvar"/>
+</section>
+</body>
+</helpdocument>
diff --git a/odk/examples/DevelopersGuide/Extensions/DialogWithHelp/help/de/com.foocorp.foo-ext/page2.xhp b/odk/examples/DevelopersGuide/Extensions/DialogWithHelp/help/de/com.foocorp.foo-ext/page2.xhp
new file mode 100644
index 000000000..9cafd0aaa
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Extensions/DialogWithHelp/help/de/com.foocorp.foo-ext/page2.xhp
@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+-->
+<helpdocument version="1.0">
+<meta>
+<topic id="comfoocorpfooextpage2" indexer="include" status="PUBLISH">
+<title id="tit" xml-lang="de">DE Extension foo page2 DE</title>
+<filename>/com.foocorp.foo-ext/page2.xhp</filename>
+</topic>
+</meta>
+<body>
+<bookmark xml-lang="de" branch="index" id="bm_id0001">
+<bookmark_value>Foo Alle Seiten;page2</bookmark_value>
+</bookmark>
+<paragraph role="heading" id="hd_id0001" xml-lang="de" level="1">DE Extension foo page2 DE</paragraph>
+<paragraph role="paragraph" id="par_id0001" xml-lang="de">Dies ist "page2" der Extension foo Hilfe.</paragraph>
+<paragraph role="heading" id="hd_id0002" xml-lang="de" level="2">Einige Links...</paragraph>
+<paragraph role="paragraph" id="par_id0002" xml-lang="de">
+<link href="com.foocorp.foo-ext/page1.xhp#target">Dies</link> ist ein Link zu einer Sektion in "page1".</paragraph>
+<paragraph role="paragraph" id="par_id0003" xml-lang="de">
+<link href="text/shared/guide/main.xhp">Dies</link> ist ein Link zu einer Hilfe-Seite in der installierten Hilfe.</paragraph>
+<section id="relatedtopics">
+<paragraph role="paragraph" id="par_id0004" xml-lang="de">
+Diese Section zeigt einen Link der durch Einfügen der "linkvar" Variable aus subfolder/anotherpage.xhp erzeugt wurde.
+</paragraph>
+<embed href="com.foocorp.foo-ext/subfolder/anotherpage.xhp#linkvar"/>
+</section>
+</body>
+</helpdocument>
diff --git a/odk/examples/DevelopersGuide/Extensions/DialogWithHelp/help/de/com.foocorp.foo-ext/subfolder/anotherpage.xhp b/odk/examples/DevelopersGuide/Extensions/DialogWithHelp/help/de/com.foocorp.foo-ext/subfolder/anotherpage.xhp
new file mode 100644
index 000000000..1a8c29f4d
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Extensions/DialogWithHelp/help/de/com.foocorp.foo-ext/subfolder/anotherpage.xhp
@@ -0,0 +1,117 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+-->
+<helpdocument version="1.0">
+<meta>
+<topic id="comfoocorpfooextsubfolder/anotherpage" indexer="include" status="PUBLISH">
+<title id="tit" xml-lang="de">DE Extension foo subfolder/anotherpage DE</title>
+<filename>/com.foocorp.foo-ext/subfolder/anotherpage.xhp</filename>
+</topic>
+</meta>
+<body>
+<bookmark xml-lang="de" branch="index" id="bm_id0001">
+<bookmark_value>Foo Alle Seiten;subfolder/anotherpage</bookmark_value>
+</bookmark>
+<paragraph role="heading" id="hd_id0001" xml-lang="de" level="1">DE Extension foo subfolder/anotherpage DE</paragraph>
+<paragraph role="paragraph" id="par_id0001" xml-lang="de">Dies ist subfolder/anotherpage der Extension foo Hilfe.
+<comment>Comment at end of paragraph</comment></paragraph>
+<bookmark xml-lang="de" branch="hid/vnd.sun.star.script:DialogWithHelp.Module1.main?language=Basic&amp;location=application" id="bm_id0002" localize="false"/>
+<paragraph role="paragraph" id="hd_id0002" xml-lang="de"><ahelp hid="hid/vnd.sun.star.script:DialogWithHelp.Module1.main?language=Basic&amp;location=application" visibility="hidden">
+Hier klicken, um den eindrucksvollen Foo Dialog zu öffnen</ahelp></paragraph>
+<bookmark xml-lang="de" branch="hid/com.foocorp.foo-ext:FooDialog" id="bm_id0003" localize="false"/>
+<paragraph role="heading" id="hd_id0002" xml-lang="de" level="2">Hilfe für den Foo Dialog</paragraph>
+<paragraph role="paragraph" id="hd_id0003" xml-lang="de">Der Foo Dialog ist ein sehr wichtiger Dialog, der...</paragraph>
+<bookmark xml-lang="de" branch="hid/com.foocorp.foo-ext:FooDialogButton" id="bm_id0004" localize="false"/>
+<paragraph role="paragraph" id="hd_id0004" xml-lang="de">
+<ahelp hid="hid/com.foocorp.foo-ext:FooDialogButton" visibility="hidden">
+Dieser Knopf bringt es!</ahelp></paragraph>
+<paragraph role="heading" id="hd_id0003" xml-lang="de" level="2">Hilfe für den "Do It !" Knopf</paragraph>
+<paragraph role="paragraph" id="hd_id0005" xml-lang="de">Der "Do It !" Knopf tut es!</paragraph>
+<paragraph role="heading" id="hd_id0004" xml-lang="de" level="2">Etwas fülltext</paragraph>
+<paragraph role="paragraph" id="par_id0006" xml-lang="de">Dieser Text füllt die Seite.</paragraph>
+<paragraph role="paragraph" id="par_id0007" xml-lang="de">Dieser Text füllt die Seite.</paragraph>
+<paragraph role="paragraph" id="par_id0008" xml-lang="de">Dieser Text füllt die Seite.</paragraph>
+<paragraph role="paragraph" id="par_id0009" xml-lang="de">Dieser Text füllt die Seite.</paragraph>
+<paragraph role="paragraph" id="par_id0010" xml-lang="de">Dieser Text füllt die Seite.</paragraph>
+<paragraph role="paragraph" id="par_id0011" xml-lang="de">Dieser Text füllt die Seite.</paragraph>
+<paragraph role="paragraph" id="par_id0012" xml-lang="de">Dieser Text füllt die Seite.</paragraph>
+<paragraph role="paragraph" id="par_id0013" xml-lang="de">Dieser Text füllt die Seite.</paragraph>
+<paragraph role="paragraph" id="par_id0014" xml-lang="de">Dieser Text füllt die Seite.</paragraph>
+<paragraph role="paragraph" id="par_id0015" xml-lang="de">Dieser Text füllt die Seite.</paragraph>
+<paragraph role="paragraph" id="par_id0016" xml-lang="de">Dieser Text füllt die Seite.</paragraph>
+<paragraph role="paragraph" id="par_id0017" xml-lang="de">Dieser Text füllt die Seite.</paragraph>
+<paragraph role="paragraph" id="par_id0018" xml-lang="de">Dieser Text füllt die Seite.</paragraph>
+<paragraph role="paragraph" id="par_id0019" xml-lang="de">Dieser Text füllt die Seite.</paragraph>
+<paragraph role="paragraph" id="par_id0020" xml-lang="de">Dieser Text füllt die Seite.</paragraph>
+<paragraph role="paragraph" id="par_id0021" xml-lang="de">Dieser Text füllt die Seite.</paragraph>
+<paragraph role="paragraph" id="par_id0022" xml-lang="de">Dieser Text füllt die Seite.</paragraph>
+<paragraph role="paragraph" id="par_id0023" xml-lang="de">Dieser Text füllt die Seite.</paragraph>
+<paragraph role="paragraph" id="par_id0024" xml-lang="de">Dieser Text füllt die Seite.</paragraph>
+<paragraph role="paragraph" id="par_id0025" xml-lang="de">Dieser Text füllt die Seite.</paragraph>
+<paragraph role="paragraph" id="par_id0026" xml-lang="de">Dieser Text füllt die Seite.</paragraph>
+<paragraph role="paragraph" id="par_id0027" xml-lang="de">Dieser Text füllt die Seite.</paragraph>
+<paragraph role="paragraph" id="par_id0028" xml-lang="de">Dieser Text füllt die Seite.</paragraph>
+<paragraph role="paragraph" id="par_id0029" xml-lang="de">Dieser Text füllt die Seite.</paragraph>
+<paragraph role="paragraph" id="par_id0030" xml-lang="de">Dieser Text füllt die Seite.</paragraph>
+<paragraph role="paragraph" id="par_id0031" xml-lang="de">Dieser Text füllt die Seite.</paragraph>
+<paragraph role="paragraph" id="par_id0032" xml-lang="de">Dieser Text füllt die Seite.</paragraph>
+<paragraph role="paragraph" id="par_id0033" xml-lang="de">Dieser Text füllt die Seite.</paragraph>
+<paragraph role="paragraph" id="par_id0034" xml-lang="de">Dieser Text füllt die Seite.</paragraph>
+<paragraph role="paragraph" id="par_id0035" xml-lang="de">Dieser Text füllt die Seite.</paragraph>
+<paragraph role="paragraph" id="par_id0036" xml-lang="de">Dieser Text füllt die Seite.</paragraph>
+<paragraph role="paragraph" id="par_id0037" xml-lang="de">Dieser Text füllt die Seite.</paragraph>
+<paragraph role="paragraph" id="par_id0038" xml-lang="de">Dieser Text füllt die Seite.</paragraph>
+<paragraph role="paragraph" id="par_id0039" xml-lang="de">Dieser Text füllt die Seite.</paragraph>
+<paragraph role="paragraph" id="par_id0040" xml-lang="de">Dieser Text füllt die Seite.</paragraph>
+<paragraph role="paragraph" id="par_id0041" xml-lang="de">Dieser Text füllt die Seite.</paragraph>
+<paragraph role="paragraph" id="par_id0042" xml-lang="de">Dieser Text füllt die Seite.</paragraph>
+<paragraph role="paragraph" id="par_id0043" xml-lang="de">Dieser Text füllt die Seite.</paragraph>
+<paragraph role="paragraph" id="par_id0044" xml-lang="de">Dieser Text füllt die Seite.</paragraph>
+<paragraph role="paragraph" id="par_id0045" xml-lang="de">Dieser Text füllt die Seite.</paragraph>
+<paragraph role="paragraph" id="par_id0046" xml-lang="de">Dieser Text füllt die Seite.</paragraph>
+<paragraph role="paragraph" id="par_id0047" xml-lang="de">Dieser Text füllt die Seite.</paragraph>
+<paragraph role="paragraph" id="par_id0048" xml-lang="de">Dieser Text füllt die Seite.</paragraph>
+<paragraph role="paragraph" id="par_id0049" xml-lang="de">Dieser Text füllt die Seite.</paragraph>
+<paragraph role="paragraph" id="par_id0050" xml-lang="de">Dieser Text füllt die Seite.</paragraph>
+<paragraph role="paragraph" id="par_id0051" xml-lang="de">Dieser Text füllt die Seite.</paragraph>
+<paragraph role="paragraph" id="par_id0052" xml-lang="de">Dieser Text füllt die Seite.</paragraph>
+<paragraph role="paragraph" id="par_id0053" xml-lang="de">Dieser Text füllt die Seite.</paragraph>
+<paragraph role="paragraph" id="par_id0054" xml-lang="de">Dieser Text füllt die Seite.</paragraph>
+<paragraph role="paragraph" id="par_id0055" xml-lang="de">Dieser Text füllt die Seite.</paragraph>
+<paragraph role="paragraph" id="par_id0056" xml-lang="de">Dieser Text füllt die Seite.</paragraph>
+<paragraph role="paragraph" id="par_id0057" xml-lang="de">Dieser Text füllt die Seite.</paragraph>
+<paragraph role="paragraph" id="par_id0058" xml-lang="de">Dieser Text füllt die Seite.</paragraph>
+<paragraph role="paragraph" id="par_id0059" xml-lang="de">Dieser Text füllt die Seite.</paragraph>
+<paragraph role="paragraph" id="par_id0060" xml-lang="de">Dieser Text füllt die Seite.</paragraph>
+<paragraph role="paragraph" id="par_id0061" xml-lang="de">Dieser Text füllt die Seite.</paragraph>
+<paragraph role="paragraph" id="par_id0062" xml-lang="de">Dieser Text füllt die Seite.</paragraph>
+<paragraph role="paragraph" id="par_id0063" xml-lang="de">Dieser Text füllt die Seite.</paragraph>
+<paragraph role="paragraph" id="par_id0064" xml-lang="de">Dieser Text füllt die Seite.</paragraph>
+<paragraph role="paragraph" id="par_id0065" xml-lang="de">Dieser Text füllt die Seite.</paragraph>
+<paragraph role="paragraph" id="par_id0066" xml-lang="de">Dieser Text füllt die Seite.</paragraph>
+<paragraph role="paragraph" id="par_id0067" xml-lang="de">Dieser Text füllt die Seite.</paragraph>
+<paragraph role="paragraph" id="par_id0068" xml-lang="de">Dieser Text füllt die Seite.</paragraph>
+<paragraph role="paragraph" id="par_id0069" xml-lang="de">Dieser Text füllt die Seite.</paragraph>
+<paragraph role="heading" id="hd_id0005" xml-lang="de" level="2">Variable, die einen Link definiert</paragraph>
+<paragraph role="paragraph" id="par_id0070" xml-lang="de">
+<variable id="linkvar">
+<link href="com.foocorp.foo-ext/page2.xhp" name="linkvar page2">Link zu page2, definert als variable in subfolder/anotherpage.xhp</link>
+</variable>
+</paragraph>
+</body>
+</helpdocument>
diff --git a/odk/examples/DevelopersGuide/Extensions/DialogWithHelp/help/en/com.foocorp.foo-ext/page1.xhp b/odk/examples/DevelopersGuide/Extensions/DialogWithHelp/help/en/com.foocorp.foo-ext/page1.xhp
new file mode 100644
index 000000000..5cbaf7cce
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Extensions/DialogWithHelp/help/en/com.foocorp.foo-ext/page1.xhp
@@ -0,0 +1,90 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+-->
+<helpdocument version="1.0">
+<meta>
+<topic id="comfoocorpfooextpage1" indexer="include" status="PUBLISH">
+<title id="tit" xml-lang="en-US">Extension foo page1</title>
+<filename>/com.foocorp.foo-ext/page1.xhp</filename>
+</topic>
+</meta>
+<body>
+<bookmark xml-lang="en-US" branch="index" id="bm_id0001">
+<bookmark_value>Foo Single level entry page1</bookmark_value>
+<bookmark_value>Foo All Pages;page1</bookmark_value>
+</bookmark>
+<bookmark xml-lang="en-US" branch="index" id="bm_id0002_swriter_sdraw">
+<bookmark_value>Foo Single level entry page1, swriter/sdraw only</bookmark_value>
+</bookmark>
+<paragraph role="heading" id="hd_id0001" xml-lang="en-US" level="1">Extension foo page1</paragraph>
+<paragraph role="paragraph" id="par_id0001" xml-lang="en-US">This is "page1" of extension foo help.
+<comment>Comment at end of paragraph</comment></paragraph>
+<comment>Some links...</comment>
+<paragraph role="heading" id="hd_id0002" xml-lang="en-US" level="2">Some links...</paragraph>
+<paragraph role="paragraph" id="par_id0002" xml-lang="en-US">
+<link href="com.foocorp.foo-ext/page2.xhp">This</link> is a link to "page2" of extension foo help.</paragraph>
+<paragraph role="paragraph" id="par_id0003" xml-lang="en-US">
+<link href="com.foocorp.foo-ext/page1.xhp#target">This</link> is a link to a section within a help file (down in this file, but can be in another file as well).</paragraph>
+<paragraph role="paragraph" id="par_id0004" xml-lang="en-US">
+<link href="text/shared/guide/main.xhp">This</link> is a link to a help page in the installed help.</paragraph>
+<paragraph role="heading" id="hd_id0003" xml-lang="en-US" level="2">Some fill text</paragraph>
+<paragraph role="paragraph" id="par_id0005" xml-lang="en-US">I like fill text. I like fill text. I like fill text.</paragraph>
+<paragraph role="paragraph" id="par_id0006" xml-lang="en-US">I like fill text. I like fill text. I like fill text.</paragraph>
+<paragraph role="paragraph" id="par_id0007" xml-lang="en-US">I like fill text. I like fill text. I like fill text.</paragraph>
+<paragraph role="paragraph" id="par_id0008" xml-lang="en-US">I like fill text. I like fill text. I like fill text.</paragraph>
+<paragraph role="paragraph" id="par_id0009" xml-lang="en-US">I like fill text. I like fill text. I like fill text.</paragraph>
+<paragraph role="paragraph" id="par_id0010" xml-lang="en-US">I like fill text. I like fill text. I like fill text.</paragraph>
+<section id="target">
+<paragraph role="heading" id="hd_id0004" xml-lang="en-US" level="2">Section "target"</paragraph>
+<paragraph role="paragraph" id="par_id0011" xml-lang="en-US">
+This is a section within the file page1.xhp. The section has the name "target".
+</paragraph>
+</section>
+<paragraph role="heading" id="hd_id0005" xml-lang="en-US" level="2">Some more fill text</paragraph>
+<paragraph role="paragraph" id="par_id0012" xml-lang="en-US">This text fills the page allowing to show section "target" at the top.</paragraph>
+<paragraph role="paragraph" id="par_id0013" xml-lang="en-US">This text fills the page allowing to show section "target" at the top.</paragraph>
+<paragraph role="paragraph" id="par_id0014" xml-lang="en-US">This text fills the page allowing to show section "target" at the top.</paragraph>
+<paragraph role="paragraph" id="par_id0015" xml-lang="en-US">This text fills the page allowing to show section "target" at the top.</paragraph>
+<paragraph role="paragraph" id="par_id0016" xml-lang="en-US">This text fills the page allowing to show section "target" at the top.</paragraph>
+<paragraph role="paragraph" id="par_id0017" xml-lang="en-US">This text fills the page allowing to show section "target" at the top.</paragraph>
+<paragraph role="paragraph" id="par_id0018" xml-lang="en-US">This text fills the page allowing to show section "target" at the top.</paragraph>
+<paragraph role="paragraph" id="par_id0019" xml-lang="en-US">This text fills the page allowing to show section "target" at the top.</paragraph>
+<paragraph role="paragraph" id="par_id0020" xml-lang="en-US">This text fills the page allowing to show section "target" at the top.</paragraph>
+<paragraph role="paragraph" id="par_id0021" xml-lang="en-US">This text fills the page allowing to show section "target" at the top.</paragraph>
+<paragraph role="paragraph" id="par_id0022" xml-lang="en-US">This text fills the page allowing to show section "target" at the top.</paragraph>
+<paragraph role="paragraph" id="par_id0023" xml-lang="en-US">This text fills the page allowing to show section "target" at the top.</paragraph>
+<paragraph role="paragraph" id="par_id0024" xml-lang="en-US">This text fills the page allowing to show section "target" at the top.</paragraph>
+<paragraph role="paragraph" id="par_id0025" xml-lang="en-US">This text fills the page allowing to show section "target" at the top.</paragraph>
+<paragraph role="paragraph" id="par_id0026" xml-lang="en-US">This text fills the page allowing to show section "target" at the top.</paragraph>
+<paragraph role="paragraph" id="par_id0027" xml-lang="en-US">This text fills the page allowing to show section "target" at the top.</paragraph>
+<paragraph role="paragraph" id="par_id0028" xml-lang="en-US">This text fills the page allowing to show section "target" at the top.</paragraph>
+<paragraph role="paragraph" id="par_id0029" xml-lang="en-US">This text fills the page allowing to show section "target" at the top.</paragraph>
+<paragraph role="paragraph" id="par_id0030" xml-lang="en-US">This text fills the page allowing to show section "target" at the top.</paragraph>
+<paragraph role="paragraph" id="par_id0031" xml-lang="en-US">This text fills the page allowing to show section "target" at the top.</paragraph>
+<paragraph role="paragraph" id="par_id0032" xml-lang="en-US">This text fills the page allowing to show section "target" at the top.</paragraph>
+<paragraph role="paragraph" id="par_id0033" xml-lang="en-US">This text fills the page allowing to show section "target" at the top.</paragraph>
+<paragraph role="paragraph" id="par_id0034" xml-lang="en-US">This text fills the page allowing to show section "target" at the top.</paragraph>
+<paragraph role="paragraph" id="par_id0035" xml-lang="en-US">This text fills the page allowing to show section "target" at the top.</paragraph>
+<paragraph role="paragraph" id="par_id0036" xml-lang="en-US">This text fills the page allowing to show section "target" at the top.</paragraph>
+<section id="relatedtopics">
+<paragraph role="paragraph" id="par_id0037" xml-lang="en-US">
+This section shows a link created by embedding the "linkvar" variable defined in subfolder/anotherpage.xhp.</paragraph>
+<embed href="com.foocorp.foo-ext/subfolder/anotherpage.xhp#linkvar"/>
+</section>
+</body>
+</helpdocument>
diff --git a/odk/examples/DevelopersGuide/Extensions/DialogWithHelp/help/en/com.foocorp.foo-ext/page2.xhp b/odk/examples/DevelopersGuide/Extensions/DialogWithHelp/help/en/com.foocorp.foo-ext/page2.xhp
new file mode 100644
index 000000000..66b3156de
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Extensions/DialogWithHelp/help/en/com.foocorp.foo-ext/page2.xhp
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+-->
+<helpdocument version="1.0">
+<meta>
+<topic id="comfoocorpfooextpage2" indexer="include" status="PUBLISH">
+<title id="tit" xml-lang="en-US">Extension foo page2</title>
+<filename>/com.foocorp.foo-ext/page2.xhp</filename>
+</topic>
+</meta>
+<body>
+<bookmark xml-lang="en-US" branch="index" id="bm_id0001">
+<bookmark_value>Foo All Pages;page2</bookmark_value>
+</bookmark>
+<paragraph role="heading" id="hd_id0001" xml-lang="en-US" level="1">Extension foo page2</paragraph>
+<paragraph role="paragraph" id="par_id0001" xml-lang="en-US">This is "page2" of extension foo help.</paragraph>
+<paragraph role="heading" id="hd_id0002" xml-lang="en-US" level="2">Some links...</paragraph>
+<paragraph role="paragraph" id="par_id0002" xml-lang="en-US">
+<link href="com.foocorp.foo-ext/page1.xhp#target">This</link> is a link to a section within page1.</paragraph>
+<paragraph role="paragraph" id="par_id0003" xml-lang="en-US">
+<link href="text/shared/guide/main.xhp">This</link> is a link to a file of the already installed help.</paragraph>
+<section id="relatedtopics">
+<paragraph role="paragraph" id="par_id0004" xml-lang="en-US">
+This section shows a link created by embedding the "linkvar" variable defined in subfolder/anotherpage.xhp.</paragraph>
+<embed href="com.foocorp.foo-ext/subfolder/anotherpage.xhp#linkvar"/>
+</section>
+</body>
+</helpdocument>
diff --git a/odk/examples/DevelopersGuide/Extensions/DialogWithHelp/help/en/com.foocorp.foo-ext/subfolder/anotherpage.xhp b/odk/examples/DevelopersGuide/Extensions/DialogWithHelp/help/en/com.foocorp.foo-ext/subfolder/anotherpage.xhp
new file mode 100644
index 000000000..30a31a720
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Extensions/DialogWithHelp/help/en/com.foocorp.foo-ext/subfolder/anotherpage.xhp
@@ -0,0 +1,117 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+-->
+<helpdocument version="1.0">
+<meta>
+<topic id="comfoocorpfooextsubfolder/anotherpage" indexer="include" status="PUBLISH">
+<title id="tit" xml-lang="en-US">Extension foo subfolder/anotherpage</title>
+<filename>/com.foocorp.foo-ext/subfolder/anotherpage.xhp</filename>
+</topic>
+</meta>
+<body>
+<bookmark xml-lang="en-US" branch="index" id="bm_id0001">
+<bookmark_value>Foo All Pages;subfolder/anotherpage</bookmark_value>
+</bookmark>
+<paragraph role="heading" id="hd_id0001" xml-lang="en-US" level="1">Extension foo subfolder/anotherpage</paragraph>
+<paragraph role="paragraph" id="par_id0001" xml-lang="en-US">This is subfolder/anotherpage of extension foo help.
+<comment>Comment at end of paragraph</comment></paragraph>
+<bookmark xml-lang="en-US" branch="hid/vnd.sun.star.script:DialogWithHelp.Module1.main?language=Basic&amp;location=application" id="bm_id0002" localize="false"/>
+<paragraph role="paragraph" id="hd_id0002" xml-lang="en-US"><ahelp hid="hid/vnd.sun.star.script:DialogWithHelp.Module1.main?language=Basic&amp;location=application" visibility="hidden">
+Click here to open the impressing Foo Dialog</ahelp></paragraph>
+<bookmark xml-lang="en-US" branch="hid/com.foocorp.foo-ext:FooDialog" id="bm_id0003" localize="false"/>
+<paragraph role="heading" id="hd_id0002" xml-lang="en-US" level="2">Help for the Foo Dialog</paragraph>
+<paragraph role="paragraph" id="hd_id0003" xml-lang="en-US">The Foo Dialog is a very important dialog that...</paragraph>
+<bookmark xml-lang="en-US" branch="hid/com.foocorp.foo-ext:FooDialogButton" id="bm_id0004" localize="false"/>
+<paragraph role="paragraph" id="hd_id0004" xml-lang="en-US">
+<ahelp hid="hid/com.foocorp.foo-ext:FooDialogButton" visibility="hidden">
+This button really does it!!</ahelp></paragraph>
+<paragraph role="heading" id="hd_id0003" xml-lang="en-US" level="2">Help for the "Do It !" button</paragraph>
+<paragraph role="paragraph" id="hd_id0005" xml-lang="en-US">The "Do It !" button does it!</paragraph>
+<paragraph role="heading" id="hd_id0004" xml-lang="en-US" level="2">Some fill text</paragraph>
+<paragraph role="paragraph" id="par_id0006" xml-lang="en-US">This text fills the page.</paragraph>
+<paragraph role="paragraph" id="par_id0007" xml-lang="en-US">This text fills the page.</paragraph>
+<paragraph role="paragraph" id="par_id0008" xml-lang="en-US">This text fills the page.</paragraph>
+<paragraph role="paragraph" id="par_id0009" xml-lang="en-US">This text fills the page.</paragraph>
+<paragraph role="paragraph" id="par_id0010" xml-lang="en-US">This text fills the page.</paragraph>
+<paragraph role="paragraph" id="par_id0011" xml-lang="en-US">This text fills the page.</paragraph>
+<paragraph role="paragraph" id="par_id0012" xml-lang="en-US">This text fills the page.</paragraph>
+<paragraph role="paragraph" id="par_id0013" xml-lang="en-US">This text fills the page.</paragraph>
+<paragraph role="paragraph" id="par_id0014" xml-lang="en-US">This text fills the page.</paragraph>
+<paragraph role="paragraph" id="par_id0015" xml-lang="en-US">This text fills the page.</paragraph>
+<paragraph role="paragraph" id="par_id0016" xml-lang="en-US">This text fills the page.</paragraph>
+<paragraph role="paragraph" id="par_id0017" xml-lang="en-US">This text fills the page.</paragraph>
+<paragraph role="paragraph" id="par_id0018" xml-lang="en-US">This text fills the page.</paragraph>
+<paragraph role="paragraph" id="par_id0019" xml-lang="en-US">This text fills the page.</paragraph>
+<paragraph role="paragraph" id="par_id0020" xml-lang="en-US">This text fills the page.</paragraph>
+<paragraph role="paragraph" id="par_id0021" xml-lang="en-US">This text fills the page.</paragraph>
+<paragraph role="paragraph" id="par_id0022" xml-lang="en-US">This text fills the page.</paragraph>
+<paragraph role="paragraph" id="par_id0023" xml-lang="en-US">This text fills the page.</paragraph>
+<paragraph role="paragraph" id="par_id0024" xml-lang="en-US">This text fills the page.</paragraph>
+<paragraph role="paragraph" id="par_id0025" xml-lang="en-US">This text fills the page.</paragraph>
+<paragraph role="paragraph" id="par_id0026" xml-lang="en-US">This text fills the page.</paragraph>
+<paragraph role="paragraph" id="par_id0027" xml-lang="en-US">This text fills the page.</paragraph>
+<paragraph role="paragraph" id="par_id0028" xml-lang="en-US">This text fills the page.</paragraph>
+<paragraph role="paragraph" id="par_id0029" xml-lang="en-US">This text fills the page.</paragraph>
+<paragraph role="paragraph" id="par_id0030" xml-lang="en-US">This text fills the page.</paragraph>
+<paragraph role="paragraph" id="par_id0031" xml-lang="en-US">This text fills the page.</paragraph>
+<paragraph role="paragraph" id="par_id0032" xml-lang="en-US">This text fills the page.</paragraph>
+<paragraph role="paragraph" id="par_id0033" xml-lang="en-US">This text fills the page.</paragraph>
+<paragraph role="paragraph" id="par_id0034" xml-lang="en-US">This text fills the page.</paragraph>
+<paragraph role="paragraph" id="par_id0035" xml-lang="en-US">This text fills the page.</paragraph>
+<paragraph role="paragraph" id="par_id0036" xml-lang="en-US">This text fills the page.</paragraph>
+<paragraph role="paragraph" id="par_id0037" xml-lang="en-US">This text fills the page.</paragraph>
+<paragraph role="paragraph" id="par_id0038" xml-lang="en-US">This text fills the page.</paragraph>
+<paragraph role="paragraph" id="par_id0039" xml-lang="en-US">This text fills the page.</paragraph>
+<paragraph role="paragraph" id="par_id0040" xml-lang="en-US">This text fills the page.</paragraph>
+<paragraph role="paragraph" id="par_id0041" xml-lang="en-US">This text fills the page.</paragraph>
+<paragraph role="paragraph" id="par_id0042" xml-lang="en-US">This text fills the page.</paragraph>
+<paragraph role="paragraph" id="par_id0043" xml-lang="en-US">This text fills the page.</paragraph>
+<paragraph role="paragraph" id="par_id0044" xml-lang="en-US">This text fills the page.</paragraph>
+<paragraph role="paragraph" id="par_id0045" xml-lang="en-US">This text fills the page.</paragraph>
+<paragraph role="paragraph" id="par_id0046" xml-lang="en-US">This text fills the page.</paragraph>
+<paragraph role="paragraph" id="par_id0047" xml-lang="en-US">This text fills the page.</paragraph>
+<paragraph role="paragraph" id="par_id0048" xml-lang="en-US">This text fills the page.</paragraph>
+<paragraph role="paragraph" id="par_id0049" xml-lang="en-US">This text fills the page.</paragraph>
+<paragraph role="paragraph" id="par_id0050" xml-lang="en-US">This text fills the page.</paragraph>
+<paragraph role="paragraph" id="par_id0051" xml-lang="en-US">This text fills the page.</paragraph>
+<paragraph role="paragraph" id="par_id0052" xml-lang="en-US">This text fills the page.</paragraph>
+<paragraph role="paragraph" id="par_id0053" xml-lang="en-US">This text fills the page.</paragraph>
+<paragraph role="paragraph" id="par_id0054" xml-lang="en-US">This text fills the page.</paragraph>
+<paragraph role="paragraph" id="par_id0055" xml-lang="en-US">This text fills the page.</paragraph>
+<paragraph role="paragraph" id="par_id0056" xml-lang="en-US">This text fills the page.</paragraph>
+<paragraph role="paragraph" id="par_id0057" xml-lang="en-US">This text fills the page.</paragraph>
+<paragraph role="paragraph" id="par_id0058" xml-lang="en-US">This text fills the page.</paragraph>
+<paragraph role="paragraph" id="par_id0059" xml-lang="en-US">This text fills the page.</paragraph>
+<paragraph role="paragraph" id="par_id0060" xml-lang="en-US">This text fills the page.</paragraph>
+<paragraph role="paragraph" id="par_id0061" xml-lang="en-US">This text fills the page.</paragraph>
+<paragraph role="paragraph" id="par_id0062" xml-lang="en-US">This text fills the page.</paragraph>
+<paragraph role="paragraph" id="par_id0063" xml-lang="en-US">This text fills the page.</paragraph>
+<paragraph role="paragraph" id="par_id0064" xml-lang="en-US">This text fills the page.</paragraph>
+<paragraph role="paragraph" id="par_id0065" xml-lang="en-US">This text fills the page.</paragraph>
+<paragraph role="paragraph" id="par_id0066" xml-lang="en-US">This text fills the page.</paragraph>
+<paragraph role="paragraph" id="par_id0067" xml-lang="en-US">This text fills the page.</paragraph>
+<paragraph role="paragraph" id="par_id0068" xml-lang="en-US">This text fills the page.</paragraph>
+<paragraph role="paragraph" id="par_id0069" xml-lang="en-US">This text fills the page.</paragraph>
+<paragraph role="heading" id="hd_id0005" xml-lang="en-US" level="2">Variable defining a link</paragraph>
+<paragraph role="paragraph" id="par_id0070" xml-lang="en-US">
+<variable id="linkvar">
+<link href="com.foocorp.foo-ext/page2.xhp" name="linkvar page2">Link to page2 defined as variable in subfolder/anotherpage.xhp</link>
+</variable>
+</paragraph>
+</body>
+</helpdocument>
diff --git a/odk/examples/DevelopersGuide/FirstSteps/FirstLoadComponent.java b/odk/examples/DevelopersGuide/FirstSteps/FirstLoadComponent.java
new file mode 100644
index 000000000..70e531df3
--- /dev/null
+++ b/odk/examples/DevelopersGuide/FirstSteps/FirstLoadComponent.java
@@ -0,0 +1,162 @@
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+import com.sun.star.beans.PropertyValue;
+import com.sun.star.beans.XPropertySet;
+import com.sun.star.uno.XComponentContext;
+import com.sun.star.comp.helper.Bootstrap;
+import com.sun.star.container.XEnumeration;
+import com.sun.star.container.XEnumerationAccess;
+import com.sun.star.frame.XComponentLoader;
+import com.sun.star.frame.XController;
+import com.sun.star.frame.XModel;
+import com.sun.star.lang.XComponent;
+import com.sun.star.lang.XMultiComponentFactory;
+import com.sun.star.sheet.XCellAddressable;
+import com.sun.star.sheet.XCellRangesQuery;
+import com.sun.star.sheet.XSheetCellRanges;
+import com.sun.star.sheet.XSpreadsheet;
+import com.sun.star.sheet.XSpreadsheetDocument;
+import com.sun.star.sheet.XSpreadsheetView;
+import com.sun.star.sheet.XSpreadsheets;
+import com.sun.star.table.XCell;
+import com.sun.star.uno.UnoRuntime;
+
+public class FirstLoadComponent {
+
+ /**
+ * @param args the command line arguments
+ */
+ public static void main(String[] args) {
+ try {
+ // get the remote office component context
+ XComponentContext xRemoteContext = Bootstrap.bootstrap();
+ if (xRemoteContext == null) {
+ System.err.println("ERROR: Could not bootstrap default Office.");
+ }
+
+ XMultiComponentFactory xRemoteServiceManager = xRemoteContext.getServiceManager();
+
+ Object desktop = xRemoteServiceManager.createInstanceWithContext(
+ "com.sun.star.frame.Desktop", xRemoteContext);
+ XComponentLoader xComponentLoader = UnoRuntime.queryInterface(XComponentLoader.class, desktop);
+
+ PropertyValue[] loadProps = new PropertyValue[0];
+ XComponent xSpreadsheetComponent = xComponentLoader.loadComponentFromURL("private:factory/scalc", "_blank", 0, loadProps);
+
+ XSpreadsheetDocument xSpreadsheetDocument = UnoRuntime.queryInterface(XSpreadsheetDocument.class,
+ xSpreadsheetComponent);
+
+ XSpreadsheets xSpreadsheets = xSpreadsheetDocument.getSheets();
+ xSpreadsheets.insertNewByName("MySheet", (short)0);
+ com.sun.star.uno.Type elemType = xSpreadsheets.getElementType();
+
+ System.out.println(elemType.getTypeName());
+ Object sheet = xSpreadsheets.getByName("MySheet");
+ XSpreadsheet xSpreadsheet = UnoRuntime.queryInterface(
+ XSpreadsheet.class, sheet);
+
+ XCell xCell = xSpreadsheet.getCellByPosition(0, 0);
+ xCell.setValue(21);
+ xCell = xSpreadsheet.getCellByPosition(0, 1);
+ xCell.setValue(21);
+ xCell = xSpreadsheet.getCellByPosition(0, 2);
+ xCell.setFormula("=sum(A1:A2)");
+
+ XPropertySet xCellProps = UnoRuntime.queryInterface(
+ XPropertySet.class, xCell);
+ xCellProps.setPropertyValue("CellStyle", "Result");
+
+ XModel xSpreadsheetModel = UnoRuntime.queryInterface(
+ XModel.class, xSpreadsheetComponent);
+ XController xSpreadsheetController = xSpreadsheetModel.getCurrentController();
+ XSpreadsheetView xSpreadsheetView = UnoRuntime.queryInterface(XSpreadsheetView.class,
+ xSpreadsheetController);
+ xSpreadsheetView.setActiveSheet(xSpreadsheet);
+
+ // *********************************************************
+ // example for use of enum types
+ xCellProps.setPropertyValue("VertJustify",
+ com.sun.star.table.CellVertJustify.TOP);
+
+
+ // *********************************************************
+ // example for a sequence of PropertyValue structs
+ // create an array with one PropertyValue struct, it contains
+ // references only
+ loadProps = new PropertyValue[1];
+
+ // instantiate PropertyValue struct and set its member fields
+ PropertyValue asTemplate = new PropertyValue();
+ asTemplate.Name = "AsTemplate";
+ asTemplate.Value = Boolean.TRUE;
+
+ // assign PropertyValue struct to array of references for PropertyValue
+ // structs
+ loadProps[0] = asTemplate;
+
+ // load calc file as template
+ //xSpreadsheetComponent = xComponentLoader.loadComponentFromURL(
+ // "file:///c:/temp/DataAnalysys.ods", "_blank", 0, loadProps);
+
+ // *********************************************************
+ // example for use of XEnumerationAccess
+ XCellRangesQuery xCellQuery = UnoRuntime.queryInterface(XCellRangesQuery.class, sheet);
+ XSheetCellRanges xFormulaCells = xCellQuery.queryContentCells(
+ (short)com.sun.star.sheet.CellFlags.FORMULA);
+ XEnumerationAccess xFormulas = xFormulaCells.getCells();
+ XEnumeration xFormulaEnum = xFormulas.createEnumeration();
+
+ while (xFormulaEnum.hasMoreElements()) {
+ Object formulaCell = xFormulaEnum.nextElement();
+ xCell = UnoRuntime.queryInterface(XCell.class, formulaCell);
+ XCellAddressable xCellAddress = UnoRuntime.queryInterface(XCellAddressable.class, xCell);
+ System.out.println("Formula cell in column " +
+ xCellAddress.getCellAddress().Column
+ + ", row " + xCellAddress.getCellAddress().Row
+ + " contains " + xCell.getFormula());
+ }
+
+ }
+ catch (java.lang.Exception e){
+ e.printStackTrace();
+ }
+ finally {
+ System.exit( 0 );
+ }
+ }
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/FirstSteps/FirstUnoContact.java b/odk/examples/DevelopersGuide/FirstSteps/FirstUnoContact.java
new file mode 100644
index 000000000..9f4de1a6e
--- /dev/null
+++ b/odk/examples/DevelopersGuide/FirstSteps/FirstUnoContact.java
@@ -0,0 +1,61 @@
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+public class FirstUnoContact {
+
+ public static void main(String[] args) {
+ try {
+ // get the remote office component context
+ com.sun.star.uno.XComponentContext xContext =
+ com.sun.star.comp.helper.Bootstrap.bootstrap();
+
+ System.out.println("Connected to a running office ...");
+
+ com.sun.star.lang.XMultiComponentFactory xMCF =
+ xContext.getServiceManager();
+
+ String available = (xMCF != null ? "available" : "not available");
+ System.out.println( "remote ServiceManager is " + available );
+ }
+ catch (java.lang.Exception e){
+ e.printStackTrace();
+ }
+ finally {
+ System.exit(0);
+ }
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/FirstSteps/FirstUnoContact.py b/odk/examples/DevelopersGuide/FirstSteps/FirstUnoContact.py
new file mode 100644
index 000000000..06cd0bc5a
--- /dev/null
+++ b/odk/examples/DevelopersGuide/FirstSteps/FirstUnoContact.py
@@ -0,0 +1,24 @@
+# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*-
+#
+# This file is part of the LibreOffice project.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+
+import uno
+import officehelper
+
+try:
+ xContext = officehelper.bootstrap()
+ print("Connected to a running office ...")
+ xMCF = xContext.getServiceManager()
+ available = "not available" if xMCF is None else "available"
+ print("remote ServiceManager is " + available)
+
+except Exception as e:
+ print(e)
+
+# vim: set shiftwidth=4 softtabstop=4 expandtab:
+
diff --git a/odk/examples/DevelopersGuide/FirstSteps/HelloTextTableShape.java b/odk/examples/DevelopersGuide/FirstSteps/HelloTextTableShape.java
new file mode 100644
index 000000000..2dd4e9c0e
--- /dev/null
+++ b/odk/examples/DevelopersGuide/FirstSteps/HelloTextTableShape.java
@@ -0,0 +1,439 @@
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+import com.sun.star.lang.XComponent;
+import com.sun.star.uno.XComponentContext;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.frame.XComponentLoader;
+import com.sun.star.lang.XMultiComponentFactory;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.lang.XServiceInfo;
+import com.sun.star.beans.XPropertySet;
+import com.sun.star.beans.PropertyValue;
+import com.sun.star.text.XTextDocument;
+import com.sun.star.text.XText;
+import com.sun.star.text.XTextCursor;
+import com.sun.star.text.XTextContent;
+import com.sun.star.table.XCellRange;
+import com.sun.star.table.XCell;
+import com.sun.star.table.TableBorder;
+import com.sun.star.table.BorderLine;
+import com.sun.star.drawing.XShape;
+import com.sun.star.awt.Size;
+import com.sun.star.awt.Point;
+import com.sun.star.sheet.XSpreadsheetDocument;
+import com.sun.star.container.XIndexAccess;
+import com.sun.star.drawing.XDrawPagesSupplier;
+import com.sun.star.drawing.XDrawPageSupplier;
+import com.sun.star.drawing.XDrawPage;
+
+public class HelloTextTableShape {
+
+ private XComponentContext xRemoteContext = null;
+ private XMultiComponentFactory xRemoteServiceManager = null;
+
+ /**
+ * @param args the command line arguments
+ */
+ public static void main(String[] args) {
+ HelloTextTableShape helloTextTableShape1 = new HelloTextTableShape();
+ try {
+ helloTextTableShape1.useDocuments();
+ }
+ catch (java.lang.Exception e){
+ System.err.println(e.getMessage());
+ e.printStackTrace();
+ }
+ finally {
+ System.exit(0);
+ }
+
+ }
+
+ protected void useDocuments() throws java.lang.Exception {
+ useWriter();
+ useCalc();
+ useDraw();
+ }
+
+ protected void useWriter() throws java.lang.Exception {
+ try {
+ // create new writer document and get text, then manipulate text
+ XComponent xWriterComponent = newDocComponent("swriter");
+ XTextDocument xTextDocument = UnoRuntime.queryInterface(
+ XTextDocument.class, xWriterComponent);
+ XText xText = xTextDocument.getText();
+
+ manipulateText(xText);
+
+ // get internal service factory of the document
+ XMultiServiceFactory xWriterFactory = UnoRuntime.queryInterface(
+ XMultiServiceFactory.class, xWriterComponent);
+
+ // insert TextTable and get cell text, then manipulate text in cell
+ Object table = xWriterFactory.createInstance("com.sun.star.text.TextTable");
+ XTextContent xTextContentTable = UnoRuntime.queryInterface(
+ XTextContent.class, table);
+
+ xText.insertTextContent(xText.getEnd(), xTextContentTable, false);
+
+ XCellRange xCellRange = UnoRuntime.queryInterface(
+ XCellRange.class, table);
+ XCell xCell = xCellRange.getCellByPosition(0, 1);
+ XText xCellText = UnoRuntime.queryInterface(XText.class, xCell);
+
+ manipulateText(xCellText);
+ manipulateTable(xCellRange);
+
+ // insert RectangleShape and get shape text, then manipulate text
+ Object writerShape = xWriterFactory.createInstance(
+ "com.sun.star.drawing.RectangleShape");
+ XShape xWriterShape = UnoRuntime.queryInterface(
+ XShape.class, writerShape);
+ xWriterShape.setSize(new Size(10000, 10000));
+ XTextContent xTextContentShape = UnoRuntime.queryInterface(
+ XTextContent.class, writerShape);
+
+ xText.insertTextContent(xText.getEnd(), xTextContentShape, false);
+
+ XPropertySet xShapeProps = UnoRuntime.queryInterface(
+ XPropertySet.class, writerShape);
+ // wrap text inside shape
+ xShapeProps.setPropertyValue("TextContourFrame", Boolean.TRUE);
+
+
+ XText xShapeText = UnoRuntime.queryInterface(XText.class, writerShape);
+
+ manipulateText(xShapeText);
+ manipulateShape(xWriterShape);
+
+/* more code snippets used in the manual:
+
+ Object bookmark = xWriterFactory.createInstance ( "com.sun.star.text.Bookmark" );
+ // name the bookmark
+ XNamed xNamed = (XNamed) UnoRuntime.queryInterface (
+ XNamed.class, bookmark );
+ xNamed.setName("MyUniqueBookmarkName");
+
+ // get XTextContent interface and insert it at the end of the document
+ XTextContent xTextContent = (XTextContent) UnoRuntime.queryInterface (
+ XTextContent.class, bookmark );
+ //mxDocText.insertTextContent ( mxDocText.getEnd(), xTextContent, false );
+ xText.insertTextContent ( xText.getEnd(), xTextContent, false );
+
+ //query BookmarksSupplier
+ XBookmarksSupplier xBookmarksSupplier = (XBookmarksSupplier)UnoRuntime.queryInterface(
+ XBookmarksSupplier.class, xWriterComponent);
+ XNameAccess xNamedBookmarks = xBookmarksSupplier.getBookmarks();
+ Object foundBookmark = xNamedBookmarks.getByName("MyUniqueBookmarkName");
+ XTextContent xFoundBookmark = (XTextContent)UnoRuntime.queryInterface(XTextContent.class, foundBookmark);
+ XTextRange xFound = xFoundBookmark.getAnchor();
+ xFound.setString(" The throat mike, glued to her neck, "
+ + "looked as much as possible like an analgesic dermadisk.");
+
+
+
+
+ // first query the XTextTablesSupplier interface from our document
+ XTextTablesSupplier xTablesSupplier = (XTextTablesSupplier) UnoRuntime.queryInterface(
+ XTextTablesSupplier.class, xWriterComponent);
+ // get the tables collection
+ XNameAccess xNamedTables = xTablesSupplier.getTextTables();
+
+ // now query the XIndexAccess from the tables collection
+ XIndexAccess xIndexedTables = (XIndexAccess) UnoRuntime.queryInterface(
+ XIndexAccess.class, xNamedTables);
+
+ // we need properties
+ XPropertySet xTableProps = null;
+
+ // get the tables
+ for (int i = 0; i < xIndexedTables.getCount(); i++) {
+ //Object table = xIndexedTables.getByIndex(i);
+ table = xIndexedTables.getByIndex(i);
+ xTableProps = (XPropertySet) UnoRuntime.queryInterface(
+ XPropertySet.class, table);
+ xTableProps.setPropertyValue("BackColor", Integer.valueOf(0xC8FFB9));
+ }
+ */
+ }
+ catch( com.sun.star.lang.DisposedException e ) { //works from Patch 1
+ xRemoteContext = null;
+ throw e;
+ }
+
+ }
+
+ protected void useCalc() throws java.lang.Exception {
+ try {
+ // create new calc document and manipulate cell text
+ XComponent xCalcComponent = newDocComponent("scalc");
+ XSpreadsheetDocument xSpreadsheetDocument =
+ UnoRuntime.queryInterface(
+ XSpreadsheetDocument .class, xCalcComponent);
+ Object sheets = xSpreadsheetDocument.getSheets();
+ XIndexAccess xIndexedSheets = UnoRuntime.queryInterface(
+ XIndexAccess.class, sheets);
+ Object sheet = xIndexedSheets.getByIndex(0);
+
+ //get cell A2 in first sheet
+ XCellRange xSpreadsheetCells = UnoRuntime.queryInterface(
+ XCellRange.class, sheet);
+ XCell xCell = xSpreadsheetCells.getCellByPosition(0,1);
+ XPropertySet xCellProps = UnoRuntime.queryInterface(
+ XPropertySet.class, xCell);
+ xCellProps.setPropertyValue("IsTextWrapped", Boolean.TRUE);
+
+ XText xCellText = UnoRuntime.queryInterface(XText.class, xCell);
+
+ manipulateText(xCellText);
+ manipulateTable(xSpreadsheetCells);
+
+ // get internal service factory of the document
+ XMultiServiceFactory xCalcFactory = UnoRuntime.queryInterface(
+ XMultiServiceFactory.class, xCalcComponent);
+ // get Drawpage
+ XDrawPageSupplier xDrawPageSupplier = UnoRuntime.queryInterface(XDrawPageSupplier.class, sheet);
+ XDrawPage xDrawPage = xDrawPageSupplier.getDrawPage();
+
+ // create and insert RectangleShape and get shape text, then manipulate text
+ Object calcShape = xCalcFactory.createInstance(
+ "com.sun.star.drawing.RectangleShape");
+ XShape xCalcShape = UnoRuntime.queryInterface(
+ XShape.class, calcShape);
+ xCalcShape.setSize(new Size(10000, 10000));
+ xCalcShape.setPosition(new Point(7000, 3000));
+
+ xDrawPage.add(xCalcShape);
+
+ XPropertySet xShapeProps = UnoRuntime.queryInterface(
+ XPropertySet.class, calcShape);
+ // wrap text inside shape
+ xShapeProps.setPropertyValue("TextContourFrame", Boolean.TRUE);
+
+
+ XText xShapeText = UnoRuntime.queryInterface(XText.class, calcShape);
+
+ manipulateText(xShapeText);
+ manipulateShape(xCalcShape);
+
+ }
+ catch( com.sun.star.lang.DisposedException e ) { //works from Patch 1
+ xRemoteContext = null;
+ throw e;
+ }
+
+ }
+
+ protected void useDraw() throws java.lang.Exception {
+ try {
+ //create new draw document and insert ractangle shape
+ XComponent xDrawComponent = newDocComponent("sdraw");
+ XDrawPagesSupplier xDrawPagesSupplier =
+ UnoRuntime.queryInterface(
+ XDrawPagesSupplier.class, xDrawComponent);
+
+ Object drawPages = xDrawPagesSupplier.getDrawPages();
+ XIndexAccess xIndexedDrawPages = UnoRuntime.queryInterface(
+ XIndexAccess.class, drawPages);
+ Object drawPage = xIndexedDrawPages.getByIndex(0);
+ XDrawPage xDrawPage = UnoRuntime.queryInterface(XDrawPage.class, drawPage);
+
+ // get internal service factory of the document
+ XMultiServiceFactory xDrawFactory =
+ UnoRuntime.queryInterface(
+ XMultiServiceFactory.class, xDrawComponent);
+
+ Object drawShape = xDrawFactory.createInstance(
+ "com.sun.star.drawing.RectangleShape");
+ XShape xDrawShape = UnoRuntime.queryInterface(XShape.class, drawShape);
+ xDrawShape.setSize(new Size(10000, 20000));
+ xDrawShape.setPosition(new Point(5000, 5000));
+ xDrawPage.add(xDrawShape);
+
+ XText xShapeText = UnoRuntime.queryInterface(XText.class, drawShape);
+ XPropertySet xShapeProps = UnoRuntime.queryInterface(
+ XPropertySet.class, drawShape);
+
+ // wrap text inside shape
+ xShapeProps.setPropertyValue("TextContourFrame", Boolean.TRUE);
+
+ manipulateText(xShapeText);
+ manipulateShape(xDrawShape);
+ }
+ catch( com.sun.star.lang.DisposedException e ) { //works from Patch 1
+ xRemoteContext = null;
+ throw e;
+ }
+
+
+ }
+
+ protected void manipulateText(XText xText) throws com.sun.star.uno.Exception {
+ // simply set whole text as one string
+ xText.setString("He lay flat on the brown, pine-needled floor of the forest, "
+ + "his chin on his folded arms, and high overhead the wind blew in the tops "
+ + "of the pine trees.");
+
+ // create text cursor for selecting and formatting
+ XTextCursor xTextCursor = xText.createTextCursor();
+ XPropertySet xCursorProps = UnoRuntime.queryInterface(
+ XPropertySet.class, xTextCursor);
+
+ // use cursor to select "He lay" and apply bold italic
+ xTextCursor.gotoStart(false);
+ xTextCursor.goRight((short)6, true);
+ // from CharacterProperties
+ xCursorProps.setPropertyValue("CharPosture",
+ com.sun.star.awt.FontSlant.ITALIC);
+ xCursorProps.setPropertyValue("CharWeight",
+ new Float(com.sun.star.awt.FontWeight.BOLD));
+
+ // add more text at the end of the text using insertString
+ xTextCursor.gotoEnd(false);
+ xText.insertString(xTextCursor, " The mountainside sloped gently where he lay; "
+ + "but below it was steep and he could see the dark of the oiled road "
+ + "winding through the pass. There was a stream alongside the road "
+ + "and far down the pass he saw a mill beside the stream and the falling water "
+ + "of the dam, white in the summer sunlight.", false);
+ // after insertString the cursor is behind the inserted text, insert more text
+ xText.insertString(xTextCursor, "\n \"Is that the mill?\" he asked.", false);
+ }
+
+ protected void manipulateTable(XCellRange xCellRange) throws com.sun.star.uno.Exception {
+
+ String backColorPropertyName = "";
+ XPropertySet xTableProps = null;
+
+ // enter column titles and a cell value
+ XCell xCell = xCellRange.getCellByPosition(0,0);
+ XText xCellText = UnoRuntime.queryInterface(XText.class, xCell);
+ xCellText.setString("Quotation");
+ xCell = xCellRange.getCellByPosition(1,0);
+ xCellText = UnoRuntime.queryInterface(XText.class, xCell);
+ xCellText.setString("Year");
+ xCell = xCellRange.getCellByPosition(1,1);
+ xCell.setValue(1940);
+ XCellRange xSelectedCells = xCellRange.getCellRangeByName("A1:B1");
+ XPropertySet xCellProps = UnoRuntime.queryInterface(
+ XPropertySet.class, xSelectedCells);
+
+ // format table headers and table borders
+ // we need to distinguish text and sheet tables:
+ // property name for cell colors is different in text and sheet cells
+ // we want to apply TableBorder to whole text table, but only to sheet cells with content
+ XServiceInfo xServiceInfo = UnoRuntime.queryInterface(
+ XServiceInfo.class, xCellRange);
+ if (xServiceInfo.supportsService("com.sun.star.sheet.Spreadsheet")) {
+ backColorPropertyName = "CellBackColor";
+ xSelectedCells = xCellRange.getCellRangeByName("A1:B2");
+ xTableProps = UnoRuntime.queryInterface(
+ XPropertySet.class, xSelectedCells);
+ }
+ else if (xServiceInfo.supportsService("com.sun.star.text.TextTable")) {
+ backColorPropertyName = "BackColor";
+ xTableProps = UnoRuntime.queryInterface(
+ XPropertySet.class, xCellRange);
+ }
+ // set cell background color
+ xCellProps.setPropertyValue(backColorPropertyName, Integer.valueOf(0x99CCFF));
+
+ // set table borders
+ // create description for blue line, width 10
+ BorderLine theLine = new BorderLine();
+ theLine.Color = 0x000099;
+ theLine.OuterLineWidth = 10;
+ // apply line description to all border lines and make them valid
+ TableBorder bord = new TableBorder();
+ bord.VerticalLine = bord.HorizontalLine =
+ bord.LeftLine = bord.RightLine =
+ bord.TopLine = bord.BottomLine =
+ theLine;
+ bord.IsVerticalLineValid = bord.IsHorizontalLineValid =
+ bord.IsLeftLineValid = bord.IsRightLineValid =
+ bord.IsTopLineValid = bord.IsBottomLineValid =
+ true;
+
+ xTableProps.setPropertyValue("TableBorder", bord);
+
+ bord = (TableBorder)xTableProps.getPropertyValue("TableBorder");
+ theLine = bord.TopLine;
+ int col = theLine.Color;
+ System.out.println(col);
+ }
+
+ protected void manipulateShape(XShape xShape) throws com.sun.star.uno.Exception {
+ XPropertySet xShapeProps = UnoRuntime.queryInterface(XPropertySet.class, xShape);
+ xShapeProps.setPropertyValue("FillColor", Integer.valueOf(0x99CCFF));
+ xShapeProps.setPropertyValue("LineColor", Integer.valueOf(0x000099));
+ xShapeProps.setPropertyValue("RotateAngle", Integer.valueOf(3000));
+
+ xShapeProps.setPropertyValue("TextLeftDistance", Integer.valueOf(0));
+ xShapeProps.setPropertyValue("TextRightDistance", Integer.valueOf(0));
+ xShapeProps.setPropertyValue("TextUpperDistance", Integer.valueOf(0));
+ xShapeProps.setPropertyValue("TextLowerDistance", Integer.valueOf(0));
+ }
+
+
+ protected XComponent newDocComponent(String docType) throws java.lang.Exception {
+ String loadUrl = "private:factory/" + docType;
+ xRemoteServiceManager = this.getRemoteServiceManager();
+ Object desktop = xRemoteServiceManager.createInstanceWithContext(
+ "com.sun.star.frame.Desktop", xRemoteContext);
+ XComponentLoader xComponentLoader = UnoRuntime.queryInterface(
+ XComponentLoader.class, desktop);
+ PropertyValue[] loadProps = new PropertyValue[0];
+ return xComponentLoader.loadComponentFromURL(loadUrl, "_blank", 0, loadProps);
+ }
+
+ protected XMultiComponentFactory getRemoteServiceManager() throws java.lang.Exception {
+ if (xRemoteContext == null && xRemoteServiceManager == null) {
+ try {
+ // First step: get the remote office component context
+ xRemoteContext = com.sun.star.comp.helper.Bootstrap.bootstrap();
+ System.out.println("Connected to a running office ...");
+
+ xRemoteServiceManager = xRemoteContext.getServiceManager();
+ }
+ catch( Exception e) {
+ e.printStackTrace();
+ System.exit(1);
+ }
+ }
+ return xRemoteServiceManager;
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/FirstSteps/Makefile b/odk/examples/DevelopersGuide/FirstSteps/Makefile
new file mode 100644
index 000000000..53077d093
--- /dev/null
+++ b/odk/examples/DevelopersGuide/FirstSteps/Makefile
@@ -0,0 +1,100 @@
+#*************************************************************************
+#
+# The Contents of this file are made available subject to the terms of
+# the BSD license.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+# 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+# contributors may be used to endorse or promote products derived
+# from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+# TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+# USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+#**************************************************************************
+
+# Builds the FirstSteps examples of the Developers Guide.
+
+PRJ=../../..
+SETTINGS=$(PRJ)/settings
+
+include $(SETTINGS)/settings.mk
+include $(SETTINGS)/std.mk
+
+# Define non-platform/compiler specific settings
+EXAMPLE_NAME=FirstStepsExamples
+OUT_APP_CLASS = $(OUT_CLASS)/$(EXAMPLE_NAME)
+
+APP1_NAME=FirstUnoContact
+APP1_JAR=$(OUT_APP_CLASS)/$(APP1_NAME).jar
+APP2_NAME=FirstLoadComponent
+APP2_JAR=$(OUT_APP_CLASS)/$(APP2_NAME).jar
+APP3_NAME=HelloTextTableShape
+APP3_JAR=$(OUT_APP_CLASS)/$(APP3_NAME).jar
+
+SDK_CLASSPATH = $(subst $(EMPTYSTRING) $(PATH_SEPARATOR),$(PATH_SEPARATOR),$(CLASSPATH)\
+ $(PATH_SEPARATOR)$(OUT_APP_CLASS))
+
+
+# Targets
+.PHONY: ALL
+ALL : \
+ $(EXAMPLE_NAME)
+
+include $(SETTINGS)/stdtarget.mk
+
+$(OUT_APP_CLASS)/%.class : %.java
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ $(SDK_JAVAC) $(JAVAC_FLAGS) -classpath "$(SDK_CLASSPATH)" -d $(OUT_APP_CLASS) $<
+
+$(OUT_APP_CLASS)/%.mf :
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ @echo Main-Class: com.sun.star.lib.loader.Loader> $@
+ $(ECHOLINE)>> $@
+ @echo Name: com/sun/star/lib/loader/Loader.class>> $@
+ @echo Application-Class: $*>> $@
+
+$(OUT_APP_CLASS)/%.jar : $(OUT_APP_CLASS)/%.mf $(OUT_APP_CLASS)/%.class
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ +cd $(subst /,$(PS),$(OUT_APP_CLASS)) && $(SDK_JAR) cvfm $(@F) $*.mf $*.class
+ +$(SDK_JAR) uvf $@ $(SDK_JAVA_UNO_BOOTSTRAP_FILES)
+
+$(APP1_JAR) : $(OUT_APP_CLASS)/$(APP1_NAME).mf $(OUT_APP_CLASS)/$(APP1_NAME).class
+$(APP2_JAR) : $(OUT_APP_CLASS)/$(APP2_NAME).mf $(OUT_APP_CLASS)/$(APP2_NAME).class
+$(APP3_JAR) : $(OUT_APP_CLASS)/$(APP3_NAME).mf $(OUT_APP_CLASS)/$(APP3_NAME).class
+
+$(EXAMPLE_NAME) : $(APP1_JAR) $(APP2_JAR) $(APP3_JAR)
+ @echo --------------------------------------------------------------------------------
+ @echo Please use one of the following commands to execute the examples!
+ @echo -
+ @echo $(MAKE) $(APP1_NAME).run
+ @echo $(MAKE) $(APP2_NAME).run
+ @echo $(MAKE) $(APP3_NAME).run
+ @echo --------------------------------------------------------------------------------
+
+%.run: $(OUT_APP_CLASS)/%.jar
+ $(SDK_JAVA) -Dcom.sun.star.lib.loader.unopath="$(OFFICE_PROGRAM_PATH)" -jar $<
+
+.PHONY: clean
+clean :
+ -$(DELRECURSIVE) $(subst /,$(PS),$(OUT_APP_CLASS))
diff --git a/odk/examples/DevelopersGuide/FirstSteps/build_FirstUnoContact.xml b/odk/examples/DevelopersGuide/FirstSteps/build_FirstUnoContact.xml
new file mode 100644
index 000000000..ec0eba70a
--- /dev/null
+++ b/odk/examples/DevelopersGuide/FirstSteps/build_FirstUnoContact.xml
@@ -0,0 +1,80 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+-->
+<project basedir="." default="all" name="FirstUnoContact">
+
+ <property environment="env"/>
+ <property name="OFFICE_HOME" value="${env.OFFICE_HOME}"/>
+ <property name="OO_SDK_HOME" value="${env.OO_SDK_HOME}"/>
+
+ <target name="init">
+ <property name="OUTDIR" value="${OO_SDK_HOME}/WINExample.out/class/FirstUnoContact"/>
+ </target>
+
+ <path id="office.class.path">
+ <filelist dir="${OFFICE_HOME}/program/classes"
+ files="libreoffice.jar"/>
+ </path>
+
+ <fileset id="bootstrap.glue.code" dir="${OO_SDK_HOME}/classes">
+ <patternset>
+ <include name="com/sun/star/lib/loader/*.class"/>
+ </patternset>
+ </fileset>
+
+ <target name="compile" depends="init">
+ <mkdir dir="${OUTDIR}"/>
+ <javac debug="true" deprecation="true" destdir="${OUTDIR}" srcdir=".">
+ <classpath refid="office.class.path"/>
+ </javac>
+ </target>
+
+ <target name="jar" depends="init,compile">
+ <jar basedir="${OUTDIR}" compress="true"
+ jarfile="${OUTDIR}/FirstUnoContact.jar">
+ <exclude name="**/*.java"/>
+ <exclude name="*.jar"/>
+ <fileset refid="bootstrap.glue.code"/>
+ <manifest>
+ <attribute name="Main-Class" value="com.sun.star.lib.loader.Loader"/>
+ <section name="com/sun/star/lib/loader/Loader.class">
+ <attribute name="Application-Class" value="FirstUnoContact"/>
+ </section>
+ </manifest>
+ </jar>
+ </target>
+
+ <target name="all" description="Build everything." depends="init,compile,jar">
+ <echo message="Application built. FirstUnoContact!"/>
+ </target>
+
+ <target name="run" description="Try running it." depends="init,all">
+ <java jar="${OUTDIR}/FirstUnoContact.jar" failonerror="true" fork="true">
+ </java>
+ </target>
+
+ <target name="clean" description="Clean all build products." depends="init">
+ <delete>
+ <fileset dir="${OUTDIR}">
+ <include name="**/*.class"/>
+ </fileset>
+ </delete>
+ <delete file="${OUTDIR}/FirstUnoContact.jar"/>
+ </target>
+
+</project>
diff --git a/odk/examples/DevelopersGuide/FirstSteps/cxx/FirstUnoContact.cxx b/odk/examples/DevelopersGuide/FirstSteps/cxx/FirstUnoContact.cxx
new file mode 100644
index 000000000..bdcac76be
--- /dev/null
+++ b/odk/examples/DevelopersGuide/FirstSteps/cxx/FirstUnoContact.cxx
@@ -0,0 +1,35 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4;
+ * fill-column: 100 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <com/sun/star/lang/XMultiComponentFactory.hpp>
+#include <cppuhelper/bootstrap.hxx>
+#include <iostream>
+#include <sal/main.h>
+
+SAL_IMPLEMENT_MAIN()
+{
+ try
+ {
+ css::uno::Reference<css::uno::XComponentContext> xContext(cppu::bootstrap());
+ std::cout << "Connected to a running office ..." << std::endl;
+ css::uno::Reference<css::lang::XMultiComponentFactory> xMCF = xContext->getServiceManager();
+ std::string available = xMCF != nullptr ? "available" : "not available";
+ std::cout << "remote ServiceManager is " + available << std::endl;
+ }
+ catch (css::uno::Exception& e)
+ {
+ std::cout << e.Message << std::endl;
+ return 1;
+ }
+ return 0;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s
+ * cinkeys+=0=break: */
diff --git a/odk/examples/DevelopersGuide/FirstSteps/cxx/Makefile b/odk/examples/DevelopersGuide/FirstSteps/cxx/Makefile
new file mode 100644
index 000000000..0ba2928e8
--- /dev/null
+++ b/odk/examples/DevelopersGuide/FirstSteps/cxx/Makefile
@@ -0,0 +1,100 @@
+#*************************************************************************
+#
+# The Contents of this file are made available subject to the terms of
+# the BSD license.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+# 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+# contributors may be used to endorse or promote products derived
+# from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+# TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+# USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+#**************************************************************************
+
+# Builds the FirstUnoContact example of the SDK.
+
+PRJ=../../../..
+SETTINGS=$(PRJ)/settings
+
+include $(SETTINGS)/settings.mk
+include $(SETTINGS)/std.mk
+
+# Define non-platform/compiler specific settings
+APP_NAME=FirstUnoContact
+
+OUT_APP_INC = $(OUT_INC)/$(APP_NAME)
+OUT_APP_GEN = $(OUT_MISC)/$(APP_NAME)
+OUT_APP_OBJ=$(OUT_OBJ)/$(APP_NAME)
+
+CXXFILES = FirstUnoContact.cxx
+
+OBJFILES = $(patsubst %.cxx,$(OUT_SLO_COMP)/%.$(OBJ_EXT),$(CXXFILES))
+
+# Targets
+.PHONY: ALL
+ALL : \
+ FirstUnoContact
+
+include $(SETTINGS)/stdtarget.mk
+
+$(OUT_APP_OBJ)/%.$(OBJ_EXT) : %.cxx $(SDKTYPEFLAG)
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ $(CC) $(CC_FLAGS) $(CC_INCLUDES) -I$(OUT_APP_INC) $(CC_DEFINES) $(CC_OUTPUT_SWITCH)$(subst /,$(PS),$@) $<
+
+$(OUT_BIN)/_$(APP_NAME)$(EXE_EXT) : $(OUT_APP_OBJ)/$(APP_NAME).$(OBJ_EXT)
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ -$(MKDIR) $(subst /,$(PS),$(OUT_APP_GEN))
+ifeq "$(OS)" "WIN"
+ $(LINK) $(EXE_LINK_FLAGS) /OUT:$@ /MAP:$(OUT_APP_GEN)/$(basename $(@F)).map \
+ $< $(CPPUHELPERLIB) $(CPPULIB) $(SALHELPERLIB) $(SALLIB)
+else
+ $(LINK) $(EXE_LINK_FLAGS) $(LINK_LIBS) -o $@ $< \
+ $(CPPUHELPERLIB) $(CPPULIB) $(SALHELPERLIB) $(SALLIB) $(STDC++LIB)
+ifeq "$(OS)" "MACOSX"
+ $(INSTALL_NAME_URELIBS_BIN) $@
+endif
+endif
+
+$(OUT_BIN)/$(APP_NAME)$(EXE_EXT) : $(OUT_BIN)/_$(APP_NAME)$(EXE_EXT)
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ $(COPY) $(subst /,$(PS),$(BIN_DIR)/unoapploader$(EXE_EXT)) $(subst /,$(PS),$@)
+# workaround for touch problem under Windows with full qualified paths
+ make -t $@
+
+FirstUnoContact : $(OUT_BIN)/$(APP_NAME)$(EXE_EXT)
+ @echo --------------------------------------------------------------------------------
+ @echo Please use the following command to execute the example!
+ @echo -
+ @echo $(MAKE) FirstUnoContact.run
+ @echo --------------------------------------------------------------------------------
+
+%.run: $(OUT_BIN)/FirstUnoContact$(EXE_EXT)
+ cd $(subst /,$(PS),$(OUT_BIN)) && $(basename $@)
+
+.PHONY: clean
+clean :
+ -$(DELRECURSIVE) $(subst /,$(PS),$(OUT_APP_INC))
+ -$(DELRECURSIVE) $(subst /,$(PS),$(OUT_APP_GEN))
+ -$(DELRECURSIVE) $(subst /,$(PS),$(OUT_APP_OBJ))
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$(OUT_BIN)/*SimpleBootstrap*))
diff --git a/odk/examples/DevelopersGuide/Forms/BooleanValidator.java b/odk/examples/DevelopersGuide/Forms/BooleanValidator.java
new file mode 100644
index 000000000..eb8851c2a
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Forms/BooleanValidator.java
@@ -0,0 +1,84 @@
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+import com.sun.star.uno.AnyConverter;
+
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+public class BooleanValidator extends ControlValidator
+{
+ private boolean m_preventChecked;
+
+ /** Creates a new instance of BooleanValidator */
+ public BooleanValidator( boolean preventChecked )
+ {
+ m_preventChecked = preventChecked;
+ }
+
+ public String explainInvalid( Object Value )
+ {
+ try
+ {
+ if ( AnyConverter.isVoid( Value ) )
+ return "'indetermined' is not an allowed state";
+ boolean value = ((Boolean)Value).booleanValue();
+ if ( m_preventChecked && ( value == true ) )
+ return "no no no. Don't check it.";
+ }
+ catch( java.lang.Exception e )
+ {
+ return "ooops. Unknown error";
+ }
+ return "";
+ }
+
+ public boolean isValid( Object Value )
+ {
+ try
+ {
+ if ( AnyConverter.isVoid( Value ) )
+ return false;
+
+ boolean value = ((Boolean)Value).booleanValue();
+ if ( m_preventChecked && ( value == true ) )
+ return false;
+ return true;
+ }
+ catch( java.lang.Exception e )
+ {
+ }
+ return false;
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/Forms/ButtonOperator.java b/odk/examples/DevelopersGuide/Forms/ButtonOperator.java
new file mode 100644
index 000000000..890ea7251
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Forms/ButtonOperator.java
@@ -0,0 +1,219 @@
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+// java base stuff
+import java.util.ArrayList;
+
+import com.sun.star.awt.ActionEvent;
+import com.sun.star.awt.XActionListener;
+import com.sun.star.awt.XButton;
+import com.sun.star.beans.XPropertySet;
+import com.sun.star.form.runtime.FormOperations;
+import com.sun.star.form.runtime.XFeatureInvalidation;
+import com.sun.star.form.runtime.XFormOperations;
+import com.sun.star.lang.EventObject;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.XComponentContext;
+
+
+/**************************************************************************/
+/** a helper class for operating the buttons
+*/
+public class ButtonOperator implements XActionListener, XFeatureInvalidation
+{
+ private XComponentContext m_componentContext;
+ private DocumentHelper m_aDocument;
+ private XPropertySet m_form;
+ private XFormOperations m_formOperations;
+
+ private ArrayList<XPropertySet> m_aButtons;
+
+ /* ------------------------------------------------------------------ */
+ /** ctor
+ */
+ public ButtonOperator( XComponentContext xCtx, DocumentHelper aDocument, XPropertySet _form )
+ {
+ m_componentContext = xCtx;
+ m_aDocument = aDocument;
+ m_form = _form;
+ m_aButtons = new ArrayList<XPropertySet>();
+ }
+
+ /* ------------------------------------------------------------------ */
+ private short getAssociatedFormFeature( XPropertySet _buttonModel )
+ {
+ short formFeature = -1;
+ try
+ {
+ formFeature = Short.valueOf( (String)_buttonModel.getPropertyValue( "Tag" ) );
+ }
+ catch( com.sun.star.uno.Exception e )
+ {
+ }
+ return formFeature;
+ }
+
+ /* ------------------------------------------------------------------ */
+ /** gets the button which we operate and which is responsible for a given URL
+ */
+ private XPropertySet getButton( short _formFeature )
+ {
+ for ( int i=0; i < m_aButtons.size(); ++i )
+ {
+ XPropertySet button = m_aButtons.get( i );
+ if ( _formFeature == getAssociatedFormFeature( button ) )
+ return button;
+ }
+ return null;
+ }
+
+ /* ------------------------------------------------------------------ */
+ /** announces a button which the operator should be responsible for
+ */
+ private int getButtonIndex( XPropertySet xButton )
+ {
+ int nPos = -1;
+ for ( int i=0; ( i < m_aButtons.size() ) && ( -1 == nPos ); ++i )
+ {
+ if ( xButton.equals( m_aButtons.get( i ) ) )
+ nPos = i;
+ }
+ return nPos;
+ }
+
+ /* ------------------------------------------------------------------ */
+ /** announces a button which the operator should be responsible for
+ */
+ public void addButton( XPropertySet _buttonModel, short _formFeature ) throws java.lang.Exception
+ {
+ // the current view to the document
+ DocumentViewHelper aCurrentView = m_aDocument.getCurrentView();
+
+ // add a listener so we get noticed if the user presses the button
+ XButton xButtonControl = UnoRuntime.queryInterface( XButton.class,
+ aCurrentView.getFormControl( _buttonModel ) );
+ xButtonControl.addActionListener( this );
+
+ _buttonModel.setPropertyValue( "Tag", String.valueOf( _formFeature ) );
+
+ // remember the button
+ m_aButtons.add( _buttonModel );
+ }
+
+ /* ------------------------------------------------------------------ */
+ public void revokeButton( XPropertySet xButtonModel )
+ {
+ int nPos = getButtonIndex( xButtonModel );
+ if ( -1 < nPos )
+ {
+ m_aButtons.remove( nPos );
+ }
+ }
+
+ /* ==================================================================
+ = XActionListener
+ ================================================================== */
+ /* ------------------------------------------------------------------ */
+ /* called when a button has been pressed
+ */
+ public void actionPerformed( ActionEvent aEvent ) throws com.sun.star.uno.RuntimeException
+ {
+ // get the model's name
+ XPropertySet buttonModel = FLTools.getModel( aEvent.Source, XPropertySet.class );
+ try
+ {
+ short formFeature = getAssociatedFormFeature( buttonModel );
+ if ( formFeature != -1 )
+ m_formOperations.execute( formFeature );
+ }
+ catch( final com.sun.star.uno.Exception e )
+ {
+ }
+ }
+
+ /* ------------------------------------------------------------------ */
+ /* (to be) called when the form layer has been switched to alive mode
+ * @todo
+ * register as listener somewhere ...
+ */
+ public void onFormsAlive()
+ {
+ m_formOperations = FormOperations.createWithFormController(
+ m_componentContext, m_aDocument.getCurrentView().getFormController( m_form ) );
+ m_formOperations.setFeatureInvalidation( this );
+ invalidateAllFeatures();
+ }
+
+ /* ==================================================================
+ = XEventListener
+ ================================================================== */
+ public void disposing( EventObject aEvent )
+ {
+ // not interested in
+ }
+
+ /* ==================================================================
+ = XFeatureInvalidation
+ ================================================================== */
+ private void updateButtonState( XPropertySet _buttonModel, short _formFeature )
+ {
+ try
+ {
+ _buttonModel.setPropertyValue( "Enabled", m_formOperations.isEnabled( _formFeature ) );
+ }
+ catch( com.sun.star.uno.Exception e )
+ {
+ }
+ }
+
+ public void invalidateFeatures( short[] _features ) throws com.sun.star.uno.RuntimeException
+ {
+ for ( int i=0; i<_features.length; ++i )
+ {
+ XPropertySet buttonModel = getButton( _features[i] );
+ if ( buttonModel != null )
+ updateButtonState( buttonModel, _features[i] );
+ }
+ }
+
+ public void invalidateAllFeatures() throws com.sun.star.uno.RuntimeException
+ {
+ for ( XPropertySet buttonModel : m_aButtons )
+ {
+ updateButtonState( buttonModel, getAssociatedFormFeature( buttonModel ) );
+ }
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/Forms/ComponentTreeTraversal.java b/odk/examples/DevelopersGuide/Forms/ComponentTreeTraversal.java
new file mode 100644
index 000000000..be9bc22fb
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Forms/ComponentTreeTraversal.java
@@ -0,0 +1,92 @@
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+import com.sun.star.container.*;
+import com.sun.star.lang.*;
+
+/**************************************************************************/
+/** an abstract interface for components doing an action on a form component
+*/
+interface IFormComponentAction
+{
+ public abstract void handle( Object aFormComponent ) throws java.lang.Exception;
+}
+
+/**************************************************************************/
+/** a helper class for travelling a form component tree
+*/
+class ComponentTreeTraversal implements IFormComponentAction
+{
+ /* ------------------------------------------------------------------ */
+ /** Indicator method to decide whether to step down the tree.
+
+ <p>The default implementation checks if the container given is a grid
+ control model or a <service scope="com.sun.star.form">FormComponents</service>
+ instance.</p>
+ */
+ protected boolean shouldStepInto( XIndexContainer xContainer )
+ {
+ // step down the tree, if possible
+ XServiceInfo xSI = UNO.queryServiceInfo( xContainer );
+ if ( null != xSI
+ && ( xSI.supportsService( "com.sun.star.form.FormComponents" )
+ || xSI.supportsService( "com.sun.star.form.component.GridControl" )
+ )
+ )
+ {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+ /* ------------------------------------------------------------------ */
+ public void handle( Object aFormComponent ) throws com.sun.star.uno.Exception
+ {
+ XIndexContainer xCont = UNO.queryIndexContainer( aFormComponent );
+ if ( ( null != xCont )
+ && shouldStepInto( xCont )
+ )
+ {
+ for ( int i=0; i<xCont.getCount(); ++i )
+ {
+ handle( xCont.getByIndex( i ) );
+ }
+ }
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/Forms/ControlLock.java b/odk/examples/DevelopersGuide/Forms/ControlLock.java
new file mode 100644
index 000000000..6895f73f9
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Forms/ControlLock.java
@@ -0,0 +1,223 @@
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+import com.sun.star.uno.*;
+import com.sun.star.lang.*;
+import com.sun.star.container.*;
+import com.sun.star.beans.*;
+import com.sun.star.form.*;
+import com.sun.star.sdbc.*;
+
+
+/**************************************************************************/
+/** A helper class for recursively locking control models which are bound
+ to a specific field
+*/
+
+class LockControlModels extends ComponentTreeTraversal
+{
+ private String m_sDataField;
+ private Boolean m_aLockIt;
+ private int m_nLevel; // nesting level relative to the form we started with
+
+ /* ------------------------------------------------------------------ */
+ public LockControlModels( String sDataField, boolean bLockIt )
+ {
+ m_sDataField = sDataField;
+ m_aLockIt = Boolean.valueOf( bLockIt );
+ m_nLevel = 0;
+ }
+
+ /* ------------------------------------------------------------------ */
+ @Override
+ protected boolean shouldStepInto( XIndexContainer xContainer )
+ {
+ if ( !super.shouldStepInto( xContainer ) )
+ return false; // don't try to be more clever than our base class
+
+ XForm xForm = UnoRuntime.queryInterface( XForm.class, xContainer );
+ if ( ( null != xForm ) && ( m_nLevel > 1 ) )
+ // don't step into sub forms - we only handle the form we were originally
+ // applied to
+ return false;
+
+ return true;
+ }
+
+ /* ------------------------------------------------------------------ */
+ @Override
+ public void handle( Object aFormComponent ) throws com.sun.star.uno.Exception
+ {
+ // entering this nesting level
+ ++m_nLevel;
+
+ // check if the component has a DataField property
+ XPropertySet xCompProps = UNO.queryPropertySet( aFormComponent );
+ XPropertySetInfo xPSI = null;
+ if ( null != xCompProps )
+ xPSI = xCompProps.getPropertySetInfo();
+
+ if ( ( null != xPSI ) && xPSI.hasPropertyByName( "DataField" ) )
+ { // indeed it has...
+ String sDataField = (String)xCompProps.getPropertyValue( "DataField" );
+ if ( sDataField.equals( m_sDataField ) )
+ { // we found a control model which is bound to what we're looking for
+ xCompProps.setPropertyValue( "ReadOnly", m_aLockIt );
+ }
+ }
+
+ // allow the super class to step down, if possible
+ super.handle( aFormComponent );
+
+ // leaving this nesting level
+ --m_nLevel;
+ }
+}
+
+/**************************************************************************/
+/** a class which automatically handles control locking.
+ <p>The class has to be bound to a form. Upon every movement of the form,
+ all controls which are bound to a (to be specified) field are locked
+ on existing and unlocked on new records.</p>
+*/
+class ControlLock implements XRowSetListener
+{
+ private XPropertySet m_xForm;
+ private String m_sDataField;
+ private boolean m_bLockingEnabled;
+ private boolean m_bPreviousRoundLock;
+
+ /* ------------------------------------------------------------------ */
+ ControlLock( XPropertySet xForm, String sBoundDataField )
+ {
+ m_xForm = xForm;
+ m_sDataField = sBoundDataField;
+ m_bLockingEnabled = false;
+ m_bPreviousRoundLock = false;
+ }
+
+ /* ------------------------------------------------------------------ */
+ /** updates the locks on the affected controls
+ */
+ private void updateLocks( )
+ {
+ try
+ {
+ // first determine if we need to lock
+ Boolean aIsNewRecord = (Boolean)m_xForm.getPropertyValue( "IsNew" );
+
+ boolean bNeedLock = m_bLockingEnabled && !aIsNewRecord.booleanValue();
+
+ if ( m_bPreviousRoundLock != bNeedLock )
+ {
+ LockControlModels aLocker = new LockControlModels( m_sDataField, bNeedLock );
+ aLocker.handle( m_xForm );
+ m_bPreviousRoundLock = bNeedLock;
+ }
+
+ // please note that we choose the expensive way here: We always loop through
+ // _all_ control models belonging to the form. This clearly slows down the
+ // whole process.
+ // A better solution would be to cache the affected control models. Then we
+ // could either rely on the fact that the model hierarchy is static, or we
+ // could add ourself as container listener to the form.
+ }
+ catch(com.sun.star.uno.Exception e)
+ {
+ System.out.println(e);
+ e.printStackTrace();
+ }
+ }
+
+ /* ------------------------------------------------------------------ */
+ /** enables the locking in general
+ <p>If the control models are really locked depends on the current
+ record of the form: on the insert row, controls are never locked.</p>
+ */
+ public void enableLock( boolean bLock )
+ {
+ // remember this new setting
+ m_bLockingEnabled = bLock;
+
+ // add or remove ourself as listener to get notified of cursor moves
+ XRowSet xRowSet = UnoRuntime.queryInterface(
+ XRowSet.class, m_xForm );
+ if ( m_bLockingEnabled )
+ {
+ xRowSet.addRowSetListener( this );
+ }
+ else
+ {
+ xRowSet.removeRowSetListener( this );
+ }
+
+ // update the locks
+ updateLocks();
+ }
+
+ /* ==================================================================
+ = UNO callbacks
+ ================================================================== */
+
+ /* ------------------------------------------------------------------ */
+ // XResetListener overridables
+ /* ------------------------------------------------------------------ */
+ public void cursorMoved( EventObject aEvent ) throws com.sun.star.uno.RuntimeException
+ {
+ updateLocks( );
+ }
+
+ /* ------------------------------------------------------------------ */
+ public void rowChanged( EventObject aEvent ) throws com.sun.star.uno.RuntimeException
+ {
+ // not interested in
+ }
+
+ /* ------------------------------------------------------------------ */
+ public void rowSetChanged( EventObject aEvent ) throws com.sun.star.uno.RuntimeException
+ {
+ // not interested in
+ }
+
+ /* ------------------------------------------------------------------ */
+ // XEventListener overridables
+ /* ------------------------------------------------------------------ */
+ public void disposing( EventObject aEvent )
+ {
+ // not interested in
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/Forms/ControlValidation.java b/odk/examples/DevelopersGuide/Forms/ControlValidation.java
new file mode 100644
index 000000000..4b176a371
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Forms/ControlValidation.java
@@ -0,0 +1,85 @@
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+import com.sun.star.beans.*;
+
+public class ControlValidation extends DocumentBasedExample
+{
+ /** Creates a new instance of ControlValidation */
+ public ControlValidation()
+ {
+ super( DocumentType.WRITER );
+ }
+
+ /* ------------------------------------------------------------------ */
+ /* public test methods */
+ /* ------------------------------------------------------------------ */
+ @Override
+ protected void prepareDocument() throws com.sun.star.uno.Exception, java.lang.Exception
+ {
+ super.prepareDocument();
+
+ SingleControlValidation validation;
+ XPropertySet focusField;
+
+ validation = new SingleControlValidation( m_document, 5, 5, "DatabaseFormattedField", new NumericValidator() );
+ focusField = validation.getInputField();
+ validation.setExplanatoryText( "Please enter a number between 0 and 100, with at most 1 decimal digit" );
+
+ validation = new SingleControlValidation( m_document, 90, 5, "DatabaseTextField", new TextValidator() );
+ validation.setExplanatoryText( "Please enter a text whose length is a multiple of 3, and which does not contain the letter 'Z'" );
+
+ validation = new SingleControlValidation( m_document, 5, 55, "DatabaseDateField", new DateValidator() );
+ validation.setExplanatoryText( "Please enter a date in the current month" );
+ validation.getInputField().setPropertyValue( "Dropdown", Boolean.TRUE );
+
+ validation = new SingleControlValidation( m_document, 90, 55, "DatabaseTimeField", new TimeValidator() );
+ validation.setExplanatoryText( "Please enter a time. Valid values are all full hours." );
+
+ validation = new SingleControlValidation( m_document, 5, 110, "DatabaseCheckBox", new BooleanValidator( false ) );
+ validation.setExplanatoryText( "Please check (well, or uncheck) the box. Don't leave it in indetermined state." );
+ validation.getInputField().setPropertyValue( "TriState", Boolean.TRUE );
+
+ validation = new SingleControlValidation( m_document, 90, 110, "DatabaseRadioButton", new BooleanValidator( true ), 3, 0 );
+ validation.setExplanatoryText( "Please check any but the first button" );
+
+ validation = new SingleControlValidation( m_document, 5, 165, "DatabaseListBox", new ListSelectionValidator( ), 1, 24 );
+ validation.setExplanatoryText( "Please select not more than two entries." );
+ validation.getInputField().setPropertyValue( "MultiSelection", Boolean.TRUE );
+ validation.getInputField().setPropertyValue( "StringItemList", new String[] { "first", "second", "third", "forth", "fivth" } );
+
+ // switch to alive mode
+ m_document.getCurrentView( ).toggleFormDesignMode( );
+ m_document.getCurrentView( ).grabControlFocus( focusField );
+
+ // wait for the user telling us to exit
+ waitForUserInput();
+ }
+
+ /* ------------------------------------------------------------------ */
+ /** class entry point
+ */
+ public static void main(String argv[]) throws java.lang.Exception
+ {
+ ControlValidation aSample = new ControlValidation();
+ aSample.run( argv );
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/Forms/ControlValidator.java b/odk/examples/DevelopersGuide/Forms/ControlValidator.java
new file mode 100644
index 000000000..c29dec558
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Forms/ControlValidator.java
@@ -0,0 +1,52 @@
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+// base class for components validating the content of form controls
+
+public abstract class ControlValidator implements com.sun.star.form.validation.XValidator
+{
+
+ /** Creates a new instance of ControlValidator */
+ public ControlValidator()
+ {
+ }
+
+ public void addValidityConstraintListener(com.sun.star.form.validation.XValidityConstraintListener xValidityConstraintListener)
+ {
+ }
+
+ public void removeValidityConstraintListener(com.sun.star.form.validation.XValidityConstraintListener xValidityConstraintListener)
+ {
+ }
+
+ protected boolean isVoid( Object Value )
+ {
+ try
+ {
+ return ( com.sun.star.uno.AnyConverter.getType(Value).getTypeClass()
+ == com.sun.star.uno.TypeClass.VOID );
+ }
+ catch( java.lang.ClassCastException e )
+ {
+ }
+ return false;
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/Forms/DataAwareness.java b/odk/examples/DevelopersGuide/Forms/DataAwareness.java
new file mode 100644
index 000000000..fbb3b7fe5
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Forms/DataAwareness.java
@@ -0,0 +1,940 @@
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+import com.sun.star.beans.PropertyChangeEvent;
+import com.sun.star.beans.XPropertyChangeListener;
+import com.sun.star.beans.XPropertySet;
+
+
+// __________ Imports __________
+import com.sun.star.beans.XPropertySetInfo;
+
+// base classes
+import com.sun.star.container.XIndexContainer;
+import com.sun.star.container.XNameAccess;
+import com.sun.star.container.XNamed;
+import com.sun.star.form.FormComponentType;
+import com.sun.star.form.ListSourceType;
+import com.sun.star.form.XGridColumnFactory;
+import com.sun.star.form.XReset;
+import com.sun.star.form.XResetListener;
+import com.sun.star.form.runtime.FormFeature;
+import com.sun.star.lang.EventObject;
+import com.sun.star.lang.XComponent;
+import com.sun.star.sdb.CommandType;
+import com.sun.star.sdb.XColumnUpdate;
+import com.sun.star.sdbc.ResultSetConcurrency;
+import com.sun.star.sdbc.XConnection;
+import com.sun.star.sdbc.XDataSource;
+import com.sun.star.sdbc.XStatement;
+import com.sun.star.sdbcx.XColumnsSupplier;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.XInterface;
+
+/**************************************************************************/
+/** a class for enumerating a form component tree
+*/
+class PrintComponentTree extends ComponentTreeTraversal
+{
+ private String m_sPrefix;
+
+ public PrintComponentTree()
+ {
+ m_sPrefix = "";
+ }
+
+ @Override
+ public void handle( Object aFormComponent ) throws com.sun.star.uno.Exception
+ {
+ // the name of the child
+ XNamed xName = UnoRuntime.queryInterface( XNamed.class, aFormComponent );
+
+ // if it's a form control model, check it's type
+ XPropertySet xProps = UNO.queryPropertySet( aFormComponent );
+ String sTypeName = FLTools.classifyFormComponentType( xProps );
+
+ String sName;
+ if ( null == xName )
+ sName = "<unnamed>";
+ else
+ sName = xName.getName();
+
+ // print the component's name
+ if ( 0 != sTypeName.length() )
+ {
+ System.out.println( m_sPrefix + sName + " (" + sTypeName + ")" );
+ }
+ else
+ {
+ System.out.println( m_sPrefix + sName );
+ }
+
+ // let the super class step down the tree
+ m_sPrefix = m_sPrefix + " ";
+ super.handle( aFormComponent );
+ m_sPrefix = m_sPrefix.substring( 0, m_sPrefix.length() - 1 );
+ }
+}
+
+/**************************************************************************/
+/** a class revoking button models from a ButtonOperator instance
+*/
+class RevokeButtons extends ComponentTreeTraversal
+{
+ private ButtonOperator m_aOperator;
+
+ public RevokeButtons( ButtonOperator aOperator )
+ {
+ m_aOperator = aOperator;
+ }
+
+ @Override
+ public void handle( Object aFormComponent ) throws com.sun.star.uno.Exception
+ {
+ // check if it's a button
+ XPropertySet xProps = UNO.queryPropertySet( aFormComponent );
+ XPropertySetInfo xPI = null;
+ if ( null != xProps )
+ xPI = xProps.getPropertySetInfo();
+ if ( ( null != xPI ) && xPI.hasPropertyByName( "ClassId" ) )
+ {
+ Short nClassId = (Short)xProps.getPropertyValue( "ClassId" );
+ if ( FormComponentType.COMMANDBUTTON == nClassId.shortValue() )
+ {
+ // yes, it is
+ m_aOperator.revokeButton( xProps );
+ }
+ }
+
+ // let the super class step down the tree (if possible)
+ super.handle( aFormComponent );
+ }
+}
+
+/**************************************************************************/
+public class DataAwareness extends DocumentBasedExample implements XPropertyChangeListener, XResetListener
+{
+ /* ================================================================== */
+ private HsqlDatabase m_database;
+
+ private static final String s_tableNameSalesmen = "SALESMEN";
+ private static final String s_tableNameCustomers = "CUSTOMERS";
+ private static final String s_tableNameSales = "SALES";
+
+ private XPropertySet m_xMasterForm;
+ private ButtonOperator m_aOperator;
+
+ private KeyGenerator m_aSalesmanKeyGenerator;
+ private KeyGenerator m_aSalesKeyGenerator;
+ private ControlLock m_aSalesmenLocker;
+ private ControlLock m_aSalesLocker;
+ private GridFieldValidator m_aSalesNameValidator;
+
+ private boolean m_bDefaultSalesDate;
+ private boolean m_bProtectKeyFields;
+ private boolean m_bAllowEmptySales;
+
+ /* ------------------------------------------------------------------ */
+ public DataAwareness()
+ {
+ super( DocumentType.WRITER );
+ m_bDefaultSalesDate = false;
+ m_bProtectKeyFields = false;
+ m_bAllowEmptySales = false;
+ }
+
+ /* ==================================================================
+ = form components
+ ================================================================== */
+
+ /* ------------------------------------------------------------------ */
+ /** enumerates and prints all the elements in the given container, together with the container itself
+ */
+ protected void enumFormComponents( XNameAccess xContainer ) throws java.lang.Exception
+ {
+ String sObjectName;
+
+ XNamed xNameAcc = UnoRuntime.queryInterface( XNamed.class, xContainer );
+ if ( null == xNameAcc )
+ sObjectName = "<unnamed>";
+ else
+ sObjectName = xNameAcc.getName();
+ System.out.println( "enumerating the container named \"" + sObjectName +
+ "\"\n" );
+
+ PrintComponentTree aPrinter = new PrintComponentTree();
+ aPrinter.handle( xContainer );
+ }
+
+ /* ------------------------------------------------------------------ */
+ /** enumerates and prints all form elements in the document
+ */
+ protected void enumFormComponents( ) throws java.lang.Exception
+ {
+ enumFormComponents( m_document.getFormComponentTreeRoot() );
+ }
+
+ /* ==================================================================
+ = UNO callbacks
+ ================================================================== */
+
+ /* ------------------------------------------------------------------ */
+ // XResetListener overridables
+ /* ------------------------------------------------------------------ */
+ public boolean approveReset( EventObject aEvent ) throws com.sun.star.uno.RuntimeException
+ {
+ // not interested in vetoing this
+ return true;
+ }
+
+ /* ------------------------------------------------------------------ */
+ public void resetted( EventObject aEvent ) throws com.sun.star.uno.RuntimeException
+ {
+ // check if this reset occurred because we're on a new record
+ XPropertySet xFormProps = UNO.queryPropertySet( aEvent.Source );
+ try
+ {
+ Boolean aIsNew = (Boolean)xFormProps.getPropertyValue( "IsNew" );
+ if ( aIsNew.booleanValue() )
+ { // yepp
+
+ if ( !m_bDefaultSalesDate )
+ { // we're interested to do all this only if the user told us to default the sales date
+ // to "today"
+ // As date fields do this defaulting automatically, the semantics is inverted here:
+ // If we're told to default, we must do nothing, if we should not default, we must
+ // reset the value which the date field set automatically.
+
+ Integer aConcurrency = (Integer)xFormProps.getPropertyValue( "ResultSetConcurrency" );
+ if ( ResultSetConcurrency.READ_ONLY != aConcurrency.intValue() )
+ {
+ // we're going to modify the record, though after that, to the user, it should look
+ // like it has not been modified
+ // So we need to ensure that we do not change the IsModified property with whatever we do
+ Object aModifiedFlag = xFormProps.getPropertyValue( "IsModified" );
+
+
+ // get the columns of our master form
+ XColumnsSupplier xSuppCols = UnoRuntime.queryInterface(
+ XColumnsSupplier.class, xFormProps );
+ XNameAccess xCols = xSuppCols.getColumns();
+
+ // and update the date column with a NULL value
+ XColumnUpdate xDateColumn = UnoRuntime.queryInterface(
+ XColumnUpdate.class, xCols.getByName( "SALEDATE" ) );
+ xDateColumn.updateNull();
+
+
+ // then restore the flag
+ xFormProps.setPropertyValue( "IsModified", aModifiedFlag );
+ }
+ }
+ }
+ }
+ catch( com.sun.star.uno.Exception e )
+ {
+ System.out.println(e);
+ e.printStackTrace();
+ }
+ }
+
+ /* ------------------------------------------------------------------ */
+ // XPropertyChangeListener overridables
+ /* ------------------------------------------------------------------ */
+ public void propertyChange( PropertyChangeEvent aEvent ) throws com.sun.star.uno.RuntimeException
+ {
+ try
+ {
+ // did it come from a radio button or checkbox?
+ if ( aEvent.PropertyName.equals( "State" ) )
+ { // yep
+ Short aNewState = (Short)aEvent.NewValue;
+
+ XPropertySet xModel = UNO.queryPropertySet( aEvent.Source );
+ String sName = (String)xModel.getPropertyValue( "Name" );
+
+ Short aClassId = (Short)xModel.getPropertyValue( "ClassId" );
+ if ( FormComponentType.RADIOBUTTON == aClassId.shortValue() )
+ {
+ String sRefValue = (String)xModel.getPropertyValue( "RefValue" );
+
+ short nNewValue = ((Short)aEvent.NewValue).shortValue();
+ if ( sName.equals( "KeyGen" ) )
+ {
+ // it's one of the options for key generation
+ if ( sRefValue.equals( "none" ) )
+ { // no automatic generation at all
+ m_aSalesmanKeyGenerator.stopGenerator( );
+ m_aSalesKeyGenerator.stopGenerator( );
+ }
+ else
+ {
+ boolean bGenerateOnReset = true;
+ if ( sRefValue.equals( "update" ) )
+ { // generate on update
+ bGenerateOnReset = ( 0 == nNewValue );
+ }
+ else if ( sRefValue.equals( "reset" ) )
+ { // generate on reset
+ bGenerateOnReset = ( 0 != nNewValue );
+ }
+ m_aSalesmanKeyGenerator.activateKeyGenerator( bGenerateOnReset );
+ m_aSalesKeyGenerator.activateKeyGenerator( bGenerateOnReset );
+ }
+ }
+ }
+ else if ( FormComponentType.CHECKBOX == aClassId.shortValue() )
+ {
+ boolean bEnabled = ( 0 != aNewState.shortValue() );
+ if ( sName.equals( "defaultdate" ) )
+ {
+ m_bDefaultSalesDate = bEnabled;
+ }
+ else if ( sName.equals( "protectkeys" ) )
+ {
+ m_bProtectKeyFields = bEnabled;
+ m_aSalesmenLocker.enableLock( m_bProtectKeyFields );
+ m_aSalesLocker.enableLock( m_bProtectKeyFields );
+ }
+ else if ( sName.equals( "emptysales" ) )
+ {
+ m_bAllowEmptySales = bEnabled;
+ m_aSalesNameValidator.enableColumnWatch( m_bAllowEmptySales );
+ }
+ }
+ }
+ }
+ catch(com.sun.star.uno.Exception e)
+ {
+ System.out.println(e);
+ e.printStackTrace();
+ }
+ }
+
+ /* ------------------------------------------------------------------ */
+ // XEventListener overridables
+ /* ------------------------------------------------------------------ */
+ @Override
+ public void disposing( EventObject aEvent )
+ {
+ // simply disambiguate
+ super.disposing( aEvent );
+ }
+
+ /* ==================================================================
+ = miscellaneous
+ ================================================================== */
+
+ /* ------------------------------------------------------------------ */
+ /** skips line feeds in the input stream
+
+ @returns
+ the first character which does not belong to a line feed
+ */
+ protected int skipLineFeeds( java.io.InputStream aInput ) throws java.io.IOException
+ {
+ // read characters, until we encounter something which is not a line feed character
+ int nChar = aInput.read( );
+ while ( ( 13 == nChar ) || ( 10 == nChar ) )
+ nChar = aInput.read( );
+
+ // now read everything which is behind this single character we are interested in
+ while ( 0 < aInput.available() )
+ aInput.read( );
+
+ return nChar;
+ }
+
+ /* ==================================================================
+ = table handling
+ ================================================================== */
+ /* ------------------------------------------------------------------ */
+ /** checks if a given table exists.
+
+ <p>The check is made using a SELECT statement, so even if the connection
+ is a n SDB-level connection, which may filter tables in its table
+ supplier, the result may be reliable...</p>
+ */
+ protected boolean existsInvisibleTable( XConnection xConn, String sTableName ) throws java.lang.Exception
+ {
+ String sStatement = "SELECT * FROM ";
+ sStatement += sTableName;
+ sStatement += " WHERE 0=1";
+
+ boolean bSuccess = false;
+ try
+ {
+ XStatement xStatement = xConn.createStatement();
+ xStatement.execute( sStatement );
+ // if we reached this point, the table probably exists
+ bSuccess = true;
+ }
+ catch(com.sun.star.sdbc.SQLException e)
+ {
+ }
+ return bSuccess;
+ }
+
+ /* ------------------------------------------------------------------ */
+ /** add a specified table name to the table filter of the given data source.
+ */
+ protected void makeTableVisible( XDataSource xDS, String sTableName ) throws java.lang.Exception
+ {
+ // get the table filter
+ XPropertySet xDSP = UNO.queryPropertySet( xDS );
+ String[] aCurrentFilter = (String[])xDSP.getPropertyValue( "TableFilter" );
+
+ // check if the table name is already part of it
+ String sAllTables = "*"; // all tables
+
+ for ( int i=0; i<aCurrentFilter.length; ++i )
+ {
+ String sCurrentTableFilter = aCurrentFilter[i];
+
+ if ( sCurrentTableFilter.equals( sTableName ) )
+ return;
+ if ( sCurrentTableFilter.equals( sAllTables ) )
+ return;
+ }
+
+ // if we are here, we have to add our table to the filter sequence
+ String[] aNewFilter = new String[ aCurrentFilter.length + 1 ];
+ // copy the existent filter entries
+ for ( int i=0; i<aCurrentFilter.length; ++i )
+ aNewFilter[i] = aCurrentFilter[i];
+ // add our table
+ aNewFilter[ aCurrentFilter.length ] = sTableName;
+
+ xDSP.setPropertyValue( "TableFilter", aNewFilter );
+ }
+
+ /* ------------------------------------------------------------------ */
+ /** executes the given statement on the given connection
+ */
+ protected boolean implExecuteStatement( XConnection xConn, String sStatement ) throws java.lang.Exception
+ {
+ try
+ {
+ XStatement xStatement = xConn.createStatement( );
+ xStatement.execute( sStatement );
+ }
+ catch(com.sun.star.sdbc.SQLException e)
+ {
+ System.err.println( e );
+ return false;
+ }
+
+ return true;
+ }
+
+ /* ------------------------------------------------------------------ */
+ /** creates the table with the given name, using the given statement
+ */
+ protected boolean implCreateTable( XConnection xConn, String sCreateStatement, String sTableName ) throws java.lang.Exception
+ {
+ if ( !implExecuteStatement( xConn, sCreateStatement ) )
+ {
+ System.out.println( " could not create the table " + sTableName + "." );
+ System.out.println( );
+ return false;
+ }
+
+ return true;
+ }
+
+ /* ------------------------------------------------------------------ */
+ /** creates the table SALESMEN
+
+ @return
+ <TRUE/> if and only if the creation succeeded
+ */
+ protected boolean createTableSalesman( XConnection xConn ) throws java.lang.Exception
+ {
+ String sCreateStatement = "CREATE TABLE " + s_tableNameSalesmen + " ";
+ sCreateStatement += "(SNR INTEGER NOT NULL, ";
+ sCreateStatement += "FIRSTNAME VARCHAR(50), ";
+ sCreateStatement += "LASTNAME VARCHAR(100), ";
+ sCreateStatement += "STREET VARCHAR(50), ";
+ sCreateStatement += "STATE VARCHAR(50), ";
+ sCreateStatement += "ZIP INTEGER, ";
+ sCreateStatement += "BIRTHDATE DATE, ";
+ sCreateStatement += "PRIMARY KEY(SNR))";
+
+ if ( implCreateTable( xConn, sCreateStatement, s_tableNameSalesmen) )
+ {
+ String sInsertionPrefix = "INSERT INTO " + s_tableNameSalesmen + " VALUES ";
+
+ implExecuteStatement( xConn, sInsertionPrefix + "(1, 'Joseph', 'Smith', 'Bond Street', 'CA', 95460, '1946-07-02')" );
+ implExecuteStatement( xConn, sInsertionPrefix + "(2, 'Frank', 'Jones', 'Lake silver', 'CA', 95460, '1963-12-24')" );
+ implExecuteStatement( xConn, sInsertionPrefix + "(3, 'Jane', 'Esperansa', '23 Hollywood driver', 'CA', 95460, '1972-04-01')" );
+
+ return true;
+ }
+ return false;
+ }
+
+ /* ------------------------------------------------------------------ */
+ /** creates the table CUSTOMERS
+
+ @return
+ <TRUE/> if and only if the creation succeeded
+ */
+ protected boolean createTableCustomer( XConnection xConn ) throws java.lang.Exception
+ {
+ String sCreateStatement = "CREATE TABLE " + s_tableNameCustomers + " ";
+ sCreateStatement += "(COS_NR INTEGER NOT NULL, ";
+ sCreateStatement += "LASTNAME VARCHAR(100), ";
+ sCreateStatement += "STREET VARCHAR(50), ";
+ sCreateStatement += "CITY VARCHAR(50), ";
+ sCreateStatement += "STATE VARCHAR(50), ";
+ sCreateStatement += "ZIP INTEGER, ";
+ sCreateStatement += "PRIMARY KEY(COS_NR))";
+
+ if ( implCreateTable( xConn, sCreateStatement, s_tableNameCustomers ) )
+ {
+ String sInsertionPrefix = "INSERT INTO " + s_tableNameCustomers + " VALUES ";
+
+ implExecuteStatement( xConn, sInsertionPrefix + "(100, 'Acme, Inc.', '99 Market Street', 'Groundsville', 'CA', 95199)" );
+ implExecuteStatement( xConn, sInsertionPrefix + "(101, 'Superior BugSoft', '1 Party Place', 'Mendocino', 'CA', 95460)");
+ implExecuteStatement( xConn, sInsertionPrefix + "(102, 'WeKnowAll, Inc.', '100 Coffee Lane', 'Meadows', 'CA', 93699)");
+
+ return true;
+ }
+ return false;
+ }
+
+ /* ------------------------------------------------------------------ */
+ /** creates the table SALES
+
+ @return
+ <TRUE/> if and only if the creation succeeded
+ */
+ protected boolean createTableSales( XConnection xConn ) throws java.lang.Exception
+ {
+ String sCreateStatement = "CREATE TABLE " + s_tableNameSales + " ";
+ sCreateStatement += "(SALENR INTEGER NOT NULL, ";
+ sCreateStatement += "COS_NR INTEGER NOT NULL, ";
+ sCreateStatement += "SNR INTEGER NOT NULL, ";
+ sCreateStatement += "NAME VARCHAR(50), ";
+ sCreateStatement += "SALEDATE DATE, ";
+ sCreateStatement += "PRICE DECIMAL(8,2), ";
+ sCreateStatement += "PRIMARY KEY(SALENR))";
+
+ if ( implCreateTable( xConn, sCreateStatement, s_tableNameSales ) )
+ {
+ String sInsertionPrefix = "INSERT INTO " + s_tableNameSales + " VALUES ";
+
+ implExecuteStatement( xConn, sInsertionPrefix + "(1, 100, 1, 'Fruits', '2005-02-12', 39.99)" );
+ implExecuteStatement( xConn, sInsertionPrefix + "(2, 101, 3, 'Beef', '2005-10-18', 15.78)" );
+ implExecuteStatement( xConn, sInsertionPrefix + "(3, 102, 3, 'Orange Juice', '2005-09-08', 25.63)" );
+ implExecuteStatement( xConn, sInsertionPrefix + "(4, 101, 2, 'Oil', '2005-03-01', 12.30)" );
+
+ return true;
+ }
+
+ return false;
+ }
+
+ /* ------------------------------------------------------------------ */
+ /** ensures that the tables we need for our example exist
+ */
+ protected void ensureTables() throws java.lang.Exception
+ {
+ // get the data source
+ XDataSource xDS = m_database.getDataSource();
+ XPropertySet xDSProps = UNO.queryPropertySet( xDS );
+
+ // connect to this data source
+ XConnection xConn = xDS.getConnection( "", "" );
+ XComponent xConnComp = UNO.queryComponent( xConn );
+
+ createTableSalesman( xConn );
+ createTableCustomer( xConn );
+ createTableSales( xConn );
+
+ // free the resources acquired by the connection
+ xConnComp.dispose();
+ }
+
+ /* ==================================================================
+ = sample document handling
+ ================================================================== */
+
+ /* ------------------------------------------------------------------ */
+ /** creates the button used for demonstrating (amongst others) event handling
+ @param nXPos
+ x-position of the to be inserted shape
+ @param nYPos
+ y-position of the to be inserted shape
+ @param nXSize
+ width of the to be inserted shape
+ @param sName
+ the name of the model in the form component hierarchy
+ @param sLabel
+ the label of the button control
+ @param sActionURL
+ the URL of the action which should be triggered by the button
+ @return
+ the model of the newly created button
+ */
+ protected XPropertySet createButton( int nXPos, int nYPos, int nXSize, String sName, String sLabel, short _formFeature ) throws java.lang.Exception
+ {
+ XPropertySet xButton = m_formLayer.createControlAndShape( "CommandButton", nXPos, nYPos, nXSize, 6 );
+ // the name for referring to it later:
+ xButton.setPropertyValue( "Name", sName );
+ // the label
+ xButton.setPropertyValue( "Label", sLabel );
+ // use the name as help text
+ xButton.setPropertyValue( "HelpText", sName );
+ // don't want buttons to be accessible by the "tab" key - this would be uncomfortable when traveling
+ // with records with "tab"
+ xButton.setPropertyValue( "Tabstop", Boolean.FALSE );
+ // similar, they should not steal the focus when clicked
+ xButton.setPropertyValue( "FocusOnClick", Boolean.FALSE );
+
+ m_aOperator.addButton( xButton, _formFeature );
+
+ return xButton;
+ }
+
+ /* ------------------------------------------------------------------ */
+ /** creates a column in a grid
+ @param xGridModel
+ specifies the model of the grid where the new column should be inserted
+ @param sColumnService
+ specifies the service name of the column to create (e.g. "NumericField")
+ @param sDataField
+ specifies the database field to which the column should be bound
+ @param nWidth
+ specifies the column width (in mm). If 0, no width is set.
+ @return
+ the newly created column
+ */
+ XPropertySet createGridColumn( Object aGridModel, String sColumnService, String sDataField, int nWidth )
+ throws com.sun.star.uno.Exception
+ {
+ // the container to insert columns into
+ XIndexContainer xColumnContainer = UNO.queryIndexContainer( aGridModel );
+ // the factory for creating column models
+ XGridColumnFactory xColumnFactory = UnoRuntime.queryInterface(
+ XGridColumnFactory.class, aGridModel );
+
+ // (let) create the new col
+ XInterface xNewCol = xColumnFactory.createColumn( sColumnService );
+ XPropertySet xColProps = UNO.queryPropertySet( xNewCol );
+
+ // some props
+ // the field the column is bound to
+ xColProps.setPropertyValue( "DataField", sDataField );
+ // the "display name" of the column
+ xColProps.setPropertyValue( "Label", sDataField );
+ // the name of the column within its parent
+ xColProps.setPropertyValue( "Name", sDataField );
+
+ if ( nWidth > 0 )
+ xColProps.setPropertyValue( "Width", Integer.valueOf( nWidth * 10 ) );
+
+ // insert
+ xColumnContainer.insertByIndex( xColumnContainer.getCount(), xNewCol );
+
+ // outta here
+ return xColProps;
+ }
+
+ /* ------------------------------------------------------------------ */
+ /** creates a column in a grid
+ */
+ XPropertySet createGridColumn( Object aGridModel, String sColumnService, String sDataField )
+ throws com.sun.star.uno.Exception
+ {
+ return createGridColumn( aGridModel, sColumnService, sDataField );
+ }
+
+ /* ------------------------------------------------------------------ */
+ /** creates our sample document
+ */
+ @Override
+ protected void prepareDocument() throws com.sun.star.uno.Exception, java.lang.Exception
+ {
+ super.prepareDocument();
+
+ m_database = new HsqlDatabase( m_xCtx );
+
+ // ensure that we have the tables needed for our example
+ ensureTables();
+
+
+ /* create some shapes */
+ XPropertySet xSNRField = m_formLayer.insertControlLine( "NumericField", "SNR", "", 3 );
+ m_formLayer.insertControlLine( "TextField", "FIRSTNAME", "", 11);
+ m_formLayer.insertControlLine( "TextField", "LASTNAME", "", 19 );
+ m_formLayer.insertControlLine( "TextField", "STREET", "", 27 );
+ m_formLayer.insertControlLine( "TextField", "STATE", "", 35 );
+ XPropertySet xZipField = m_formLayer.insertControlLine( "NumericField", "ZIP", "", 43 );
+ m_formLayer.insertControlLine( "FormattedField", "BIRTHDATE", "", 51 );
+
+ // for the salesman number / zip code, we don't want to have decimal places:
+ xSNRField.setPropertyValue( "DecimalAccuracy", Short.valueOf( (short)0 ) );
+ xZipField.setPropertyValue( "DecimalAccuracy", Short.valueOf( (short)0 ) );
+
+
+ /** need the form the control models belong to
+ for this, we simply obtain the parent for any of the control models we have
+
+ Note that this involves knowledge about the implementation: If a control shape is
+ inserted into a document, where the control model does not belong to the form component
+ hierarchy, yet, it is automatically inserted into the first form, which is created
+ if necessary.
+ */
+ m_xMasterForm = FLTools.getParent( xZipField );
+
+ // set the data source signature at the form
+ m_xMasterForm.setPropertyValue( "DataSourceName", m_database.getDocumentURL() );
+ m_xMasterForm.setPropertyValue( "CommandType", Integer.valueOf( CommandType.TABLE ) );
+ m_xMasterForm.setPropertyValue( "Command", "SALESMEN" );
+
+
+ // insert the buttons
+ // create our button operator, if necessary
+ m_aOperator = new ButtonOperator( m_xCtx, m_document, m_xMasterForm );
+
+ createButton( 2, 63, 8, "first", "<<", FormFeature.MoveToFirst );
+ createButton( 12, 63, 8, "prev", "<", FormFeature.MoveToPrevious );
+ createButton( 22, 63, 8, "next", ">", FormFeature.MoveToNext );
+ createButton( 32, 63, 8, "last", ">>", FormFeature.MoveToLast );
+ createButton( 42, 63, 8, "new", ">*", FormFeature.MoveToInsertRow );
+ createButton( 58, 63, 13, "reload", "reload", FormFeature.ReloadForm );
+
+
+ // create a sub form for the sales
+
+ // for this, first create a sub form and bind it to the SALES table
+ XIndexContainer xSalesForm = m_document.createSubForm( m_xMasterForm, "Sales" );
+ XPropertySet xSalesFormProps = UNO.queryPropertySet( xSalesForm );
+
+ xSalesFormProps.setPropertyValue( "DataSourceName", m_database.getDocumentURL() );
+ xSalesFormProps.setPropertyValue( "CommandType", Integer.valueOf( CommandType.COMMAND ) );
+
+ String sCommand = "SELECT * FROM ";
+ sCommand += s_tableNameSales;
+ sCommand += " WHERE " + s_tableNameSales + ".SNR = :salesmen";
+ xSalesFormProps.setPropertyValue( "Command", sCommand );
+
+ // the master-details connection
+ String[] aMasterFields = new String[] { "SNR" }; // the field in the master form
+ String[] aDetailFields = new String[] { "salesmen" }; // the name in the detail form
+ xSalesFormProps.setPropertyValue( "MasterFields", aMasterFields );
+ xSalesFormProps.setPropertyValue( "DetailFields", aDetailFields );
+
+ // the create thr grid model
+ XPropertySet xSalesGridModel = m_formLayer.createControlAndShape( "GridControl", 2, 80, 162, 40, xSalesForm );
+ xSalesGridModel.setPropertyValue( "Name", "SalesTable" );
+ XPropertySet xKeyColumn = createGridColumn( xSalesGridModel, "NumericField", "SALENR", 12 );
+ XPropertySet xCustomerColumn = createGridColumn( xSalesGridModel, "ListBox", "COS_NR", 40 );
+ XPropertySet xSalesNameColumn = createGridColumn( xSalesGridModel, "TextField", "NAME", 25 );
+ createGridColumn( xSalesGridModel, "DateField", "SALEDATE", 24 );
+ createGridColumn( xSalesGridModel, "CurrencyField", "PRICE", 16 );
+
+ // please note that a better solution for the SALEDATE field would have been to use
+ // a FormattedField. But we want to demonstrate some effects with DateFields here ...
+
+ m_aSalesNameValidator = new GridFieldValidator( m_xCtx, xSalesNameColumn );
+ m_aSalesNameValidator.enableColumnWatch( m_bAllowEmptySales );
+
+ xKeyColumn.setPropertyValue( "DecimalAccuracy", Short.valueOf( (short)0 ) );
+
+ // init the list box which is for choosing the customer a sale belongs to
+ xCustomerColumn.setPropertyValue( "BoundColumn", Short.valueOf( (short)1 ) );
+ xCustomerColumn.setPropertyValue( "Label", "Customer" );
+ xCustomerColumn.setPropertyValue( "ListSourceType", ListSourceType.SQL );
+
+ String sListSource = "SELECT LASTNAME, COS_NR FROM ";
+ sListSource += s_tableNameCustomers;
+ String[] aListSource = new String[] { sListSource };
+ xCustomerColumn.setPropertyValue( "ListSource", aListSource );
+
+ // We want to demonstrate how to reset fields to NULL, we do this with the SALEDATE field
+ // above. For this, we add as reset listener to the form
+ XReset xFormReset = UNO.queryReset( xSalesForm );
+ xFormReset.addResetListener( this );
+
+
+
+ // the option for filtering the sales form
+ XIndexContainer xSalesFilterForm = m_document.createSiblingForm( xSalesForm, "SalesFilter" );
+ XPropertySet xSFFProps = UNO.queryPropertySet( xSalesFilterForm );
+ XPropertySet xLabel = m_formLayer.createControlAndShape( "FixedText", 2, 125, 35, 6, xSalesFilterForm );
+ xLabel.setPropertyValue( "Label", "show only sales since" );
+ xLabel.setPropertyValue( "Name", "FilterLabel" );
+
+ XPropertySet xFilterSelection = m_formLayer.createControlAndShape( "ListBox", 40, 125, 59, 6, xSalesFilterForm );
+ xFilterSelection.setPropertyValue( "Name", "FilterList" );
+ xFilterSelection.setPropertyValue( "LabelControl", xLabel );
+ XPropertySet xManualFilter = m_formLayer.createControlAndShape( "DateField", 104, 125, 30, 6, xSalesFilterForm );
+ xManualFilter.setPropertyValue( "Name", "ManualFilter" );
+ XPropertySet xApplyFilter = m_formLayer.createControlAndShape( "CommandButton", 139, 125, 25, 6, xSalesFilterForm );
+ xApplyFilter.setPropertyValue( "Name", "ApplyFilter" );
+ xApplyFilter.setPropertyValue( "DefaultButton", Boolean.TRUE );
+ new SalesFilter( m_document, xSalesFormProps, xFilterSelection,
+ xManualFilter, xApplyFilter );
+
+
+
+ // the options section
+ // for this, we need a form which is a sibling of our master form (don't want to interfere
+ // the controls which represent options only with the controls which are used for data access)
+
+ XIndexContainer xOptionsForm = m_document.createSiblingForm( m_xMasterForm, "Options" );
+
+ xLabel = m_formLayer.createControlAndShape( "GroupBox", 98, 0, 66, 62, xOptionsForm );
+ xLabel.setPropertyValue( "Name", "Options" );
+ xLabel.setPropertyValue( "Label", "Options" );
+
+ // radio buttons which controls how we generate unique keys
+ xLabel = m_formLayer.createControlAndShape( "GroupBox", 103, 5, 56, 25, xOptionsForm );
+ xLabel.setPropertyValue( "Label", "key generation" );
+ xLabel.setPropertyValue( "Name", "KeyGeneration" );
+ XPropertySet xKeyGen = m_formLayer.createControlAndShape( "RadioButton", 106, 11, 50, 6, xOptionsForm );
+ xKeyGen.setPropertyValue( "Name", "KeyGen" );
+ xKeyGen.setPropertyValue( "Label", "no automatic generation" );
+ xKeyGen.setPropertyValue( "RefValue", "none" );
+ xKeyGen.addPropertyChangeListener( "State", this );
+
+ xKeyGen = m_formLayer.createControlAndShape( "RadioButton", 106, 17, 50, 6, xOptionsForm );
+ xKeyGen.setPropertyValue( "Name", "KeyGen" );
+ xKeyGen.setPropertyValue( "Label", "before inserting a record" );
+ xKeyGen.setPropertyValue( "RefValue", "update" );
+ xKeyGen.addPropertyChangeListener( "State", this );
+
+ xKeyGen = m_formLayer.createControlAndShape( "RadioButton", 106, 23, 50, 6, xOptionsForm );
+ xKeyGen.setPropertyValue( "Name", "KeyGen" );
+ xKeyGen.setPropertyValue( "Label", "when moving to a new record" );
+ xKeyGen.setPropertyValue( "RefValue", "reset" );
+ xKeyGen.addPropertyChangeListener( "State", this );
+
+ // initialize listeners
+ // master form - key generation
+ m_aSalesmanKeyGenerator = new KeyGenerator( m_xMasterForm, "SNR", m_xCtx );
+ m_aSalesmanKeyGenerator.activateKeyGenerator( true );
+ // master form - control locking
+ m_aSalesmenLocker = new ControlLock( m_xMasterForm, "SNR" );
+ m_aSalesmenLocker.enableLock( m_bProtectKeyFields );
+
+ // details form - key generation
+ m_aSalesKeyGenerator = new KeyGenerator( xSalesFormProps, "SALENR", m_xCtx );
+ m_aSalesKeyGenerator.activateKeyGenerator( true );
+
+ // details form - control locking
+ m_aSalesLocker = new ControlLock( xSalesFormProps, "SALENR" );
+ m_aSalesLocker.enableLock( m_bProtectKeyFields );
+
+ // initially, we want to generate keys when moving to a new record
+ xKeyGen.setPropertyValue( "DefaultState", Short.valueOf( (short)1 ) );
+
+
+ // second options block
+ xLabel = m_formLayer.createControlAndShape( "GroupBox", 103, 33, 56, 25, xOptionsForm );
+ xLabel.setPropertyValue( "Name", "Misc" );
+ xLabel.setPropertyValue( "Label", "Miscellaneous" );
+
+ XPropertySet xCheck = m_formLayer.createControlAndShape( "CheckBox", 106, 39, 60, 6, xOptionsForm );
+ xCheck.setPropertyValue( "Name", "defaultdate" );
+ xCheck.setPropertyValue( "Label", "default sales date to \"today\"" );
+ xCheck.setPropertyValue( "HelpText", "When checked, newly entered sales records are pre-filled with today's date, else left empty." );
+ xCheck.addPropertyChangeListener( "State", this );
+
+ xCheck = m_formLayer.createControlAndShape( "CheckBox", 106, 45, 60, 6, xOptionsForm );
+ xCheck.setPropertyValue( "Name", "protectkeys" );
+ xCheck.setPropertyValue( "Label", "protect key fields from editing" );
+ xCheck.setPropertyValue( "HelpText", "When checked, you cannot modify the values in the table's key fields (SNR and SALENR)" );
+ xCheck.addPropertyChangeListener( "State", this );
+
+ xCheck = m_formLayer.createControlAndShape( "CheckBox", 106, 51, 60, 6, xOptionsForm );
+ xCheck.setPropertyValue( "Name", "emptysales" );
+ xCheck.setPropertyValue( "Label", "check for empty sales names" );
+ xCheck.setPropertyValue( "HelpText", "When checked, you cannot enter empty values into the NAME column of the 'Sales' table." );
+ xCheck.addPropertyChangeListener( "State", this );
+
+ // dump the form component tree
+ enumFormComponents( );
+ }
+
+ /* ------------------------------------------------------------------ */
+ @Override
+ protected void onFormsAlive()
+ {
+ m_aOperator.onFormsAlive();
+ }
+
+ /* ------------------------------------------------------------------ */
+ /** performs any cleanup before exiting the program
+ */
+ @Override
+ protected void cleanUp( ) throws java.lang.Exception
+ {
+ // remove the listeners at the buttons
+ RevokeButtons aRevoke = new RevokeButtons( m_aOperator );
+ aRevoke.handle( m_document.getFormComponentTreeRoot( ) );
+
+ // remove the key generator listeners from the form
+ m_aSalesmanKeyGenerator.stopGenerator( );
+ m_aSalesKeyGenerator.stopGenerator( );
+
+ // and the control lockers
+ m_aSalesmenLocker.enableLock( false );
+ m_aSalesLocker.enableLock( false );
+
+ // the validator for the grid column
+ m_aSalesNameValidator.enableColumnWatch( false );
+
+ // remove our own reset listener from the form
+ XNameAccess xMasterAsNames = UnoRuntime.queryInterface(
+ XNameAccess.class, m_xMasterForm );
+ XReset xFormReset = UNO.queryReset( xMasterAsNames.getByName( "Sales" ) );
+ xFormReset.removeResetListener( this );
+
+ super.cleanUp();
+ }
+
+ /* ------------------------------------------------------------------ */
+ /** class entry point
+ */
+ public static void main(String argv[]) throws java.lang.Exception
+ {
+ DataAwareness aSample = new DataAwareness();
+ aSample.run( argv );
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/Forms/DateValidator.java b/odk/examples/DevelopersGuide/Forms/DateValidator.java
new file mode 100644
index 000000000..646dfac79
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Forms/DateValidator.java
@@ -0,0 +1,91 @@
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+
+public class DateValidator extends ControlValidator
+{
+
+ /** Creates a new instance of NumericValidator */
+ public DateValidator( )
+ {
+ }
+
+ public String explainInvalid( Object Value )
+ {
+ try
+ {
+ if ( isVoid( Value ) )
+ return "empty input";
+
+ com.sun.star.util.Date dateValue = (com.sun.star.util.Date)Value;
+ if ( isDedicatedInvalidDate( dateValue ) )
+ return "this is no valid date";
+
+ if ( !isNextMonthsDate( dateValue ) )
+ return "date must denote a day in the current month";
+ }
+ catch( java.lang.Exception e )
+ {
+ return "oops. What did you enter for this to happen?";
+ }
+ return "";
+ }
+
+ public boolean isValid( Object Value )
+ {
+ try
+ {
+ if ( isVoid( Value ) )
+ return false;
+
+ com.sun.star.util.Date dateValue = (com.sun.star.util.Date)
+ com.sun.star.uno.AnyConverter.toObject(
+ com.sun.star.util.Date.class, Value);
+ if ( isDedicatedInvalidDate( dateValue ) )
+ return false;
+
+ if ( !isNextMonthsDate( dateValue ) )
+ return false;
+ return true;
+ }
+ catch( java.lang.Exception e )
+ {
+ e.printStackTrace( System.err );
+ }
+ return false;
+ }
+
+ private boolean isDedicatedInvalidDate( com.sun.star.util.Date dateValue )
+ {
+ return ( dateValue.Day == 0 ) && ( dateValue.Month == 0 ) && ( dateValue.Year == 0 );
+ }
+
+ private boolean isNextMonthsDate( com.sun.star.util.Date dateValue )
+ {
+ int overallMonth = dateValue.Year * 12 + dateValue.Month - 1;
+
+ int todaysMonth = new java.util.Date().getMonth();
+ int todaysYear = new java.util.Date().getYear() + 1900;
+ int todaysOverallMonth = todaysYear * 12 + todaysMonth;
+
+ return overallMonth == todaysOverallMonth;
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/Forms/DocumentBasedExample.java b/odk/examples/DevelopersGuide/Forms/DocumentBasedExample.java
new file mode 100644
index 000000000..34735221f
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Forms/DocumentBasedExample.java
@@ -0,0 +1,219 @@
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.XComponentContext;
+import com.sun.star.util.XCloseable;
+
+public abstract class DocumentBasedExample implements com.sun.star.lang.XEventListener
+{
+ /// the initial remote context from the office
+ protected XComponentContext m_xCtx;
+ /// our current test document
+ protected DocumentHelper m_document;
+ protected FormLayer m_formLayer;
+ private DocumentType m_documentType;
+
+ /** Creates a new instance of DocumentBasedExample */
+ public DocumentBasedExample( DocumentType documentType )
+ {
+ bootstrapUNO();
+ m_documentType = documentType;
+ }
+
+ /* ------------------------------------------------------------------ */
+ private void bootstrapUNO()
+ {
+ try
+ {
+ /*
+ final XComponentContext componentContext = com.sun.star.comp.helper.Bootstrap.
+ createInitialComponentContext( null );
+ final XMultiComponentFactory localServiceManager = componentContext.getServiceManager();
+
+ final XUnoUrlResolver urlResolver = (XUnoUrlResolver) UnoRuntime.queryInterface(
+ XUnoUrlResolver.class, localServiceManager.createInstanceWithContext(
+ "com.sun.star.bridge.UnoUrlResolver", componentContext) );
+
+ final String connectStr = "uno:pipe,name=<pipename>;urp;StarOffice.ComponentContext";
+ final Object initialObject = urlResolver.resolve( connectStr );
+
+ m_xCtx = (XComponentContext)UnoRuntime.queryInterface( XComponentContext.class,
+ initialObject );
+ */
+
+ // get the remote office component context
+ m_xCtx = com.sun.star.comp.helper.Bootstrap.bootstrap();
+ System.out.println("Connected to a running office ...");
+ }
+ catch (java.lang.Exception e)
+ {
+ e.printStackTrace( System.err );
+ System.exit(1);
+ }
+ }
+
+ /* ------------------------------------------------------------------ */
+ /** main method for running the sample
+ */
+ public void run( String argv[] )
+ {
+ try
+ {
+ // collect whatever parameters were given
+ collectParameters( argv );
+
+ // prepare our sample document
+ prepareDocument();
+
+ // switch the document view's form layer to alive mode
+ m_document.getCurrentView().toggleFormDesignMode();
+ onFormsAlive();
+
+ // grab the focus to the first control
+ m_document.getCurrentView().grabControlFocus();
+
+
+ // wait for the user to confirm that we can exit
+ if ( waitForUserInput() )
+ {
+ // clean up
+ cleanUp();
+ }
+
+ // if waitForUserInput returns false, the user closed the document manually - no need to do a clean up
+ // then
+ }
+ catch(com.sun.star.uno.Exception e)
+ {
+ System.out.println(e);
+ e.printStackTrace();
+ }
+ catch(java.lang.Exception e)
+ {
+ System.out.println(e);
+ e.printStackTrace();
+ }
+
+ System.exit(0);
+ }
+
+ /* ------------------------------------------------------------------ */
+ /** collect the RuntimeArguments
+ */
+ private void collectParameters(String argv[])
+ {
+ // not interested in. Derived classes may want to use it.
+ }
+
+ /* ------------------------------------------------------------------ */
+ /** prepares a new document to work with
+ */
+ protected void prepareDocument() throws com.sun.star.uno.Exception, java.lang.Exception
+ {
+ m_document = DocumentHelper.blankDocument(m_xCtx, m_documentType);
+ m_document.getDocument( ).addEventListener( this );
+ m_formLayer = new FormLayer( m_document );
+ }
+
+ /* ------------------------------------------------------------------ */
+ /** called when the form layer has been switched to alive mode
+ */
+ protected void onFormsAlive()
+ {
+ }
+
+ /* ------------------------------------------------------------------ */
+ /** performs any cleanup before exiting the program
+ */
+ protected void cleanUp( ) throws java.lang.Exception
+ {
+ // do not listen at the document any longer
+ m_document.getDocument().removeEventListener( this );
+
+ // close the document
+ closeDocument();
+ }
+
+ /* ------------------------------------------------------------------ */
+ /** closes our document, if we have an open one
+ */
+ private void closeDocument()
+ {
+ try
+ {
+ // close our document
+ if ( m_document != null )
+ {
+ XCloseable closeDoc = UnoRuntime.queryInterface( XCloseable.class,
+ m_document.getDocument() );
+ if (closeDoc != null)
+ closeDoc.close( true );
+ else
+ m_document.getDocument().dispose();
+ }
+ }
+ catch ( com.sun.star.uno.Exception e )
+ {
+ e.printStackTrace( System.err );
+ }
+ }
+
+ /* ------------------------------------------------------------------ */
+ /* internal methods */
+ /* ------------------------------------------------------------------ */
+ /** waits for the user to press a key (on the console where she started
+ the java program) or the document to be closed by the user.
+
+ @return <TRUE/> if the user pressed a key on the console,
+ <FALSE/> if she closed the document
+ */
+ protected boolean waitForUserInput() throws java.lang.Exception
+ {
+ synchronized (this)
+ {
+ WaitForInput aWait = new WaitForInput( this );
+ aWait.start();
+ wait();
+
+ // if the waiter thread is done, the user pressed enter
+ boolean bKeyPressed = aWait.isDone();
+ if ( !bKeyPressed )
+ aWait.interrupt();
+
+ return bKeyPressed;
+ }
+ }
+
+ /* ------------------------------------------------------------------ */
+ /* XEventListener overridables */
+ /* ------------------------------------------------------------------ */
+ public void disposing( com.sun.star.lang.EventObject eventObject )
+ {
+ if ( m_document.getDocument().equals( eventObject.Source ) )
+ {
+ // notify ourself that we can stop waiting for user input
+ synchronized (this)
+ {
+ notify();
+ }
+ }
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/Forms/DocumentHelper.java b/odk/examples/DevelopersGuide/Forms/DocumentHelper.java
new file mode 100644
index 000000000..abfda37c4
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Forms/DocumentHelper.java
@@ -0,0 +1,306 @@
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+/**************************************************************************/
+import com.sun.star.uno.*;
+import com.sun.star.lang.*;
+import com.sun.star.drawing.*;
+import com.sun.star.frame.*;
+import com.sun.star.form.*;
+import com.sun.star.beans.*;
+import com.sun.star.container.*;
+
+/**************************************************************************/
+/** provides a small wrapper around a document
+*/
+public class DocumentHelper
+{
+ /// the remote office context
+ private XComponentContext m_remoteContext;
+ /// the remote service manager
+ private XMultiServiceFactory m_orb;
+ protected XComponent m_documentComponent;
+
+ /* ------------------------------------------------------------------ */
+ public XComponent getDocument( )
+ {
+ return m_documentComponent;
+ }
+
+ /* ------------------------------------------------------------------ */
+ public XComponentContext getContext( )
+ {
+ return m_remoteContext;
+ }
+
+ /* ------------------------------------------------------------------ */
+ public XMultiServiceFactory getOrb( )
+ {
+ return m_orb;
+ }
+
+ /* ------------------------------------------------------------------ */
+ public DocumentHelper( XComponentContext xContext, XComponent document )
+ {
+ m_remoteContext = xContext;
+ m_orb = UnoRuntime.queryInterface(
+ XMultiServiceFactory.class, m_remoteContext.getServiceManager());
+ m_documentComponent = document;
+ }
+
+ /* ------------------------------------------------------------------ */
+ protected static XComponent implCreateBlankDocument( XComponentContext xCtx, String factoryURL ) throws com.sun.star.uno.Exception
+ {
+ XComponentLoader aLoader = UnoRuntime.queryInterface(
+ XComponentLoader.class,
+ xCtx.getServiceManager().createInstanceWithContext(
+ "com.sun.star.frame.Desktop", xCtx ));
+
+ return UNO.queryComponent(
+ aLoader.loadComponentFromURL( factoryURL, "_blank", 0, new PropertyValue[ 0 ] )
+ );
+ }
+
+
+
+ /* ------------------------------------------------------------------ */
+ public static DocumentHelper blankDocument( XComponentContext xCtx, DocumentType eType ) throws com.sun.star.uno.Exception
+ {
+ XComponent document = implCreateBlankDocument( xCtx, getDocumentFactoryURL( eType ) );
+ if ( eType == DocumentType.CALC )
+ return new SpreadsheetDocument( xCtx, document );
+
+ return new DocumentHelper( xCtx, document );
+ }
+
+ /* ------------------------------------------------------------------ */
+ /** retrieves the current view of the document
+ @return
+ the view component, queried for the interface described by aInterfaceClass
+ */
+ public DocumentViewHelper getCurrentView( )
+ {
+ // get the model interface for the document
+ XModel xDocModel = UnoRuntime.queryInterface(XModel.class, m_documentComponent );
+ // get the current controller for the document - as a controller is tied to a view,
+ // this gives us the currently active view for the document.
+ XController xController = xDocModel.getCurrentController();
+
+ if ( classify() == DocumentType.CALC )
+ return new SpreadsheetView( m_orb, this, xController );
+
+ return new DocumentViewHelper( m_orb, this, xController );
+ }
+
+ /* ------------------------------------------------------------------ */
+ /** creates a new form which is a child of the given form components container
+
+ @param xParentContainer
+ The parent container for the new form
+ @param sInitialName
+ The initial name of the form. May be null, in this case the default (which
+ is an implementation detail) applies.
+ */
+ private XIndexContainer createSubForm( XIndexContainer xParentContainer, String sInitialName )
+ throws com.sun.star.uno.Exception
+ {
+ // create a new form
+ Object xNewForm = m_orb.createInstance( "com.sun.star.form.component.DataForm" );
+
+ // insert
+ xParentContainer.insertByIndex( xParentContainer.getCount(), xNewForm );
+
+ // set the name if necessary
+ if ( null != sInitialName )
+ {
+ XPropertySet xFormProps = UNO.queryPropertySet( xNewForm );
+ xFormProps.setPropertyValue( "Name", sInitialName );
+ }
+
+ // outta here
+ return UnoRuntime.queryInterface( XIndexContainer.class, xNewForm );
+ }
+
+ /* ------------------------------------------------------------------ */
+ /** creates a new form which is a child of the given form components container
+
+ @param aParentContainer
+ The parent container for the new form
+ @param sInitialName
+ The initial name of the form. May be null, in this case the default (which
+ is an implementation detail) applies.
+ */
+ public XIndexContainer createSubForm( Object aParentContainer, String sInitialName )
+ throws com.sun.star.uno.Exception
+ {
+ XIndexContainer xParentContainer = UnoRuntime.queryInterface(
+ XIndexContainer.class, aParentContainer );
+ return createSubForm( xParentContainer, sInitialName );
+ }
+
+ /* ------------------------------------------------------------------ */
+ /** creates a form which is a sibling of the given form
+ @param aForm
+ A sinbling of the to be created form.
+
+ @param sInitialName
+ The initial name of the form. May be null, in this case the default (which
+ is an implementation detail) applies.
+ */
+ public XIndexContainer createSiblingForm( Object aForm, String sInitialName ) throws com.sun.star.uno.Exception
+ {
+ // get the parent
+ XChild xAsChild = UnoRuntime.queryInterface( XChild.class, aForm );
+ XIndexContainer xContainer = UnoRuntime.queryInterface(
+ XIndexContainer.class, xAsChild.getParent() );
+ // append a new form to this parent container
+ return createSubForm( xContainer, sInitialName );
+ }
+
+ /* ------------------------------------------------------------------ */
+ /** retrieves the document model which a given form component belongs to
+ */
+ public static DocumentHelper getDocumentForComponent( Object aFormComponent, XComponentContext xCtx )
+ {
+ XChild xChild = UnoRuntime.queryInterface( XChild.class, aFormComponent );
+ XModel xModel = null;
+ while ( ( null != xChild ) && ( null == xModel ) )
+ {
+ XInterface xParent = (XInterface)xChild.getParent();
+ xModel = UnoRuntime.queryInterface( XModel.class, xParent );
+ xChild = UnoRuntime.queryInterface( XChild.class, xParent );
+ }
+
+ return new DocumentHelper( xCtx, xModel );
+ }
+
+ /* ------------------------------------------------------------------ */
+ /** returns a URL which can be used to create a document of a certain type
+ */
+ private static String getDocumentFactoryURL( DocumentType eType )
+ {
+ if ( eType == DocumentType.WRITER )
+ return "private:factory/swriter";
+ if ( eType == DocumentType.CALC )
+ return "private:factory/scalc";
+ if ( eType == DocumentType.DRAWING )
+ return "private:factory/sdraw";
+ return "private:factory/swriter";
+ }
+
+ /* ------------------------------------------------------------------ */
+ /** classifies a document
+ */
+ public DocumentType classify( )
+ {
+ XServiceInfo xSI = UnoRuntime.queryInterface(
+ XServiceInfo.class, m_documentComponent );
+
+ if ( xSI.supportsService( "com.sun.star.text.TextDocument" ) )
+ return DocumentType.WRITER;
+ else if ( xSI.supportsService( "com.sun.star.sheet.SpreadsheetDocument" ) )
+ return DocumentType.CALC;
+ else if ( xSI.supportsService( "com.sun.star.drawing.DrawingDocument" ) )
+ return DocumentType.DRAWING;
+
+ return DocumentType.UNKNOWN;
+ }
+ /* ------------------------------------------------------------------ */
+ /** retrieves a com.sun.star.drawing.DrawPage of the document, denoted by index
+ * @param index
+ * the index of the draw page<br>
+ * @throws
+ * com.sun.star.lang.IndexOutOfBoundsException
+ * com.sun.star.lang.WrappedTargetException
+ */
+ protected XDrawPage getDrawPage( int index ) throws com.sun.star.lang.IndexOutOfBoundsException, com.sun.star.lang.WrappedTargetException
+ {
+ XDrawPagesSupplier xSuppPages = UnoRuntime.queryInterface(
+ XDrawPagesSupplier.class, getDocument() );
+ XDrawPages xPages = xSuppPages.getDrawPages();
+
+ return UnoRuntime.queryInterface( XDrawPage.class, xPages.getByIndex( index ) );
+ }
+
+ /* ------------------------------------------------------------------ */
+ /** retrieves the <type scope="com.sun.star.drawing">DrawPage</type> of the document
+ */
+ protected XDrawPage getMainDrawPage( ) throws com.sun.star.uno.Exception
+ {
+ XDrawPage xReturn;
+
+ // in case of a Writer document, this is rather easy: simply ask the XDrawPageSupplier
+ XDrawPageSupplier xSuppPage = UnoRuntime.queryInterface(
+ XDrawPageSupplier.class, getDocument() );
+ if ( null != xSuppPage )
+ xReturn = xSuppPage.getDrawPage();
+ else
+ { // the model itself is no draw page supplier - okay, it may be a Writer or Calc document
+ // (or any other multi-page document)
+ XDrawPagesSupplier xSuppPages = UnoRuntime.queryInterface(
+ XDrawPagesSupplier.class, getDocument() );
+ XDrawPages xPages = xSuppPages.getDrawPages();
+
+ xReturn = UnoRuntime.queryInterface( XDrawPage.class, xPages.getByIndex( 0 ) );
+
+ // Note that this is no really error-proof code: If the document model does not support the
+ // XDrawPagesSupplier interface, or if the pages collection returned is empty, this will break.
+ }
+
+ return xReturn;
+ }
+
+ /* ------------------------------------------------------------------ */
+ /** retrieves the root of the hierarchy of form components
+ */
+ protected XNameContainer getFormComponentTreeRoot( ) throws com.sun.star.uno.Exception
+ {
+ XFormsSupplier xSuppForms = UnoRuntime.queryInterface(
+ XFormsSupplier.class, getMainDrawPage( ) );
+
+ XNameContainer xFormsCollection = null;
+ if ( null != xSuppForms )
+ {
+ xFormsCollection = xSuppForms.getForms();
+ }
+ return xFormsCollection;
+ }
+
+ /* ------------------------------------------------------------------ */
+ /** creates a component at the service factory provided by the document
+ */
+ public XInterface createInstance( String serviceSpecifier ) throws com.sun.star.uno.Exception
+ {
+ XMultiServiceFactory xORB = UnoRuntime.queryInterface( XMultiServiceFactory.class,
+ m_documentComponent );
+ return (XInterface)xORB.createInstance( serviceSpecifier );
+ }
+
+ /* ------------------------------------------------------------------ */
+ /** creates a component at the service factory provided by the document
+ */
+ public XInterface createInstanceWithArguments( String serviceSpecifier, Object[] arguments ) throws com.sun.star.uno.Exception
+ {
+ XMultiServiceFactory xORB = UnoRuntime.queryInterface( XMultiServiceFactory.class,
+ m_documentComponent );
+ return (XInterface) xORB.createInstanceWithArguments( serviceSpecifier, arguments );
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/Forms/DocumentType.java b/odk/examples/DevelopersGuide/Forms/DocumentType.java
new file mode 100644
index 000000000..3a8e83beb
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Forms/DocumentType.java
@@ -0,0 +1,40 @@
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+
+/** a helper "enumeration class" for classifying a document type
+*/
+public class DocumentType extends com.sun.star.uno.Enum
+{
+ private DocumentType( int value )
+ {
+ super( value );
+ }
+
+
+
+ public static final DocumentType WRITER = new DocumentType(0);
+ public static final DocumentType CALC = new DocumentType(1);
+ public static final DocumentType DRAWING = new DocumentType(2);
+ public static final DocumentType UNKNOWN = new DocumentType(-1);
+
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/Forms/DocumentViewHelper.java b/odk/examples/DevelopersGuide/Forms/DocumentViewHelper.java
new file mode 100644
index 000000000..771b22784
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Forms/DocumentViewHelper.java
@@ -0,0 +1,215 @@
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+import com.sun.star.awt.XControl;
+import com.sun.star.awt.XControlModel;
+import com.sun.star.awt.XWindow;
+import com.sun.star.beans.PropertyValue;
+import com.sun.star.beans.XPropertySet;
+import com.sun.star.container.XIndexContainer;
+import com.sun.star.form.FormComponentType;
+import com.sun.star.form.XForm;
+import com.sun.star.form.runtime.XFormController;
+import com.sun.star.frame.XController;
+import com.sun.star.frame.XDispatch;
+import com.sun.star.frame.XDispatchProvider;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.util.URL;
+import com.sun.star.util.XURLTransformer;
+import com.sun.star.view.XControlAccess;
+import com.sun.star.view.XFormLayerAccess;
+
+
+/**************************************************************************/
+/** provides a small wrapper around a document view
+*/
+class DocumentViewHelper
+{
+ private XMultiServiceFactory m_orb;
+ private XController m_controller;
+ private DocumentHelper m_document;
+
+ /* ------------------------------------------------------------------ */
+ final protected XController getController()
+ {
+ return m_controller;
+ }
+
+ /* ------------------------------------------------------------------ */
+ final protected DocumentHelper getDocument()
+ {
+ return m_document;
+ }
+
+ /* ------------------------------------------------------------------ */
+ public DocumentViewHelper( XMultiServiceFactory orb, DocumentHelper document, XController controller )
+ {
+ m_orb = orb;
+ m_document = document;
+ m_controller = controller;
+ }
+
+ /* ------------------------------------------------------------------ */
+ /** Quick access to a given interface of the view
+ @param aInterfaceClass
+ the class of the interface which shall be returned
+ */
+ private <T> T get( Class<T> aInterfaceClass )
+ {
+ return UnoRuntime.queryInterface( aInterfaceClass, m_controller );
+ }
+
+ /* ------------------------------------------------------------------ */
+ /** retrieves a dispatcher for the given URL, obtained at the current view of the document
+ @param aURL
+ a one-element array. The first element must contain a valid
+ <member scope="com.sun.star.util">URL::Complete</member> value. Upon return, the URL is correctly
+ parsed.
+ @return
+ the dispatcher for the URL in question
+ */
+ private XDispatch getDispatcher( URL[] aURL ) throws java.lang.Exception
+ {
+ XDispatch xReturn = null;
+
+ // go get the current view
+ XController xController = get( XController.class );
+ // go get the dispatch provider of its frame
+ XDispatchProvider xProvider = UnoRuntime.queryInterface(
+ XDispatchProvider.class, xController.getFrame() );
+ if ( null != xProvider )
+ {
+ // need a URLTransformer
+ XURLTransformer xTransformer = UnoRuntime.queryInterface(
+ XURLTransformer.class, m_orb.createInstance( "com.sun.star.util.URLTransformer" ) );
+ xTransformer.parseStrict( aURL );
+
+ xReturn = xProvider.queryDispatch( aURL[0], "", 0 );
+ }
+ return xReturn;
+ }
+
+
+
+ /* ------------------------------------------------------------------ */
+ /* retrieves the form controller belonging to a given logical form
+ */
+ public XFormController getFormController( Object _form )
+ {
+ XFormLayerAccess formLayer = get( XFormLayerAccess.class );
+ return formLayer.getFormController( UnoRuntime.queryInterface( XForm.class, _form ) );
+ }
+
+ /* ------------------------------------------------------------------ */
+ /** retrieves a control within the current view of a document
+ @param xModel
+ specifies the control model whose control should be located
+ @return
+ the control tied to the model
+ */
+ private XControl getFormControl( XControlModel xModel ) throws com.sun.star.uno.Exception
+ {
+ // the current view of the document
+ XControlAccess xCtrlAcc = get( XControlAccess.class );
+ // delegate the task of looking for the control
+ return xCtrlAcc.getControl( xModel );
+ }
+
+ /* ------------------------------------------------------------------ */
+ public XControl getFormControl( Object aModel ) throws com.sun.star.uno.Exception
+ {
+ XControlModel xModel = UnoRuntime.queryInterface( XControlModel.class, aModel );
+ return getFormControl( xModel );
+ }
+
+ /* ------------------------------------------------------------------ */
+ public <T> T getFormControl( Object aModel, Class<T> aInterfaceClass ) throws com.sun.star.uno.Exception
+ {
+ XControlModel xModel = UnoRuntime.queryInterface( XControlModel.class, aModel );
+ return UnoRuntime.queryInterface( aInterfaceClass, getFormControl( xModel ) );
+ }
+
+ /* ------------------------------------------------------------------ */
+ /** toggles the design mode of the form layer of active view of our sample document
+ */
+ protected void toggleFormDesignMode( ) throws java.lang.Exception
+ {
+ // get a dispatcher for the toggle URL
+ URL[] aToggleURL = new URL[] { new URL() };
+ aToggleURL[0].Complete = ".uno:SwitchControlDesignMode";
+ XDispatch xDispatcher = getDispatcher( aToggleURL );
+
+ // dispatch the URL - this will result in toggling the mode
+ PropertyValue[] aDummyArgs = new PropertyValue[] { };
+ xDispatcher.dispatch( aToggleURL[0], aDummyArgs );
+ }
+
+ /* ------------------------------------------------------------------ */
+ /** sets the focus to a specific control
+ @param xModel
+ a control model. The focus is set to that control which is part of our view
+ and associated with the given model.
+ */
+ public void grabControlFocus( Object xModel ) throws com.sun.star.uno.Exception
+ {
+ // look for the control from the current view which belongs to the model
+ XControl xControl = getFormControl( xModel );
+
+ // the focus can be set to an XWindow only
+ XWindow xControlWindow = UnoRuntime.queryInterface( XWindow.class,
+ xControl );
+
+ // grab the focus
+ xControlWindow.setFocus();
+ }
+
+ /* ------------------------------------------------------------------ */
+ /** sets the focus to the first control
+ */
+ protected void grabControlFocus( ) throws java.lang.Exception
+ {
+ // the forms container of our document
+ XIndexContainer xForms = UNO.queryIndexContainer( m_document.getFormComponentTreeRoot( ) );
+ // the first form
+ XIndexContainer xForm = UNO.queryIndexContainer( xForms.getByIndex( 0 ) );
+
+ // the first control model which is no FixedText (FixedText's can't have the focus)
+ for ( int i = 0; i<xForm.getCount(); ++i )
+ {
+ XPropertySet xControlProps = UNO.queryPropertySet( xForm.getByIndex( i ) );
+ if ( FormComponentType.FIXEDTEXT != ((Short)xControlProps.getPropertyValue( "ClassId" )).shortValue() )
+ {
+ XControlModel xControlModel = UnoRuntime.queryInterface(
+ XControlModel.class, xControlProps );
+ // set the focus to this control
+ grabControlFocus( xControlModel );
+ // outta here
+ break;
+ }
+ }
+
+ // Note that we simply took the first control model from the hierarchy. This does state nothing
+ // about the location of the respective control in the view. A control model is tied to a control
+ // shape, and the shapes are where the geometry information such as position and size is hung up.
+ // So you could easily have a document where the first control model is bound to a shape which
+ // has a greater ordinate than any other control model.
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/Forms/FLTools.java b/odk/examples/DevelopersGuide/Forms/FLTools.java
new file mode 100644
index 000000000..ea1467b52
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Forms/FLTools.java
@@ -0,0 +1,216 @@
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+import com.sun.star.uno.*;
+import com.sun.star.lang.*;
+import com.sun.star.beans.*;
+import com.sun.star.container.*;
+import com.sun.star.awt.*;
+import com.sun.star.form.*;
+
+
+/** provides global helpers
+*/
+public class FLTools
+{
+
+
+
+
+ /* ------------------------------------------------------------------ */
+ /** returns the name of the given form component
+ */
+ private static String getName( Object aFormComponent )
+ {
+ XNamed xNamed = UnoRuntime.queryInterface( XNamed.class,
+ aFormComponent );
+ String sName = "";
+ if ( null != xNamed )
+ sName = xNamed.getName();
+ return sName;
+ }
+
+ /* ------------------------------------------------------------------ */
+ /** returns the label of the given form component
+ */
+ public static String getLabel( Object aFormComponent ) throws com.sun.star.uno.Exception
+ {
+ String sLabel = "";
+
+ XPropertySet xProps = UNO.queryPropertySet( aFormComponent );
+ XPropertySetInfo xPSI = ( null != xProps ) ? xProps.getPropertySetInfo() : null;
+ if ( null == xPSI )
+ { // no property set or no property set info
+ // can't do anything except falling back to the name
+ return getName( aFormComponent );
+ }
+
+ // first check if the component has a LabelControl
+ if ( xPSI.hasPropertyByName( "LabelControl" ) )
+ sLabel = getLabel( xProps.getPropertyValue( "LabelControl" ) );
+
+ // no LabelControl or no label at the LabelControl
+ if ( 0 == sLabel.length() )
+ {
+ // a "Label" property?
+ if ( xPSI.hasPropertyByName( "Label" ) )
+ sLabel = (String)xProps.getPropertyValue( "Label" );
+
+ if ( 0 == sLabel.length() )
+ { // no Label property or no label set
+ // -> fallback to the component name
+ sLabel = getName( aFormComponent );
+ }
+ }
+
+ return sLabel;
+ }
+
+
+
+ /* ------------------------------------------------------------------ */
+ /** retrieves the parent of the given object
+ */
+ private static <T> T getParent( Object aComponent, Class<T> aInterfaceClass )
+ {
+ XChild xAsChild = UnoRuntime.queryInterface( XChild.class, aComponent );
+
+ return UnoRuntime.queryInterface( aInterfaceClass, xAsChild.getParent() );
+ }
+
+ /* ------------------------------------------------------------------ */
+ /** retrieves the parent of the given object
+ */
+ static XPropertySet getParent( Object aComponent )
+ {
+ return getParent( aComponent, XPropertySet.class );
+ }
+
+ /* ------------------------------------------------------------------ */
+ /** disposes the component given
+ */
+ public static void disposeComponent( Object xComp ) throws java.lang.RuntimeException
+ {
+ XComponent xComponent = UnoRuntime.queryInterface( XComponent.class,
+ xComp );
+ if ( null != xComponent )
+ xComponent.dispose();
+ }
+
+ /* ------------------------------------------------------------------ */
+ /** gets the XControlModel for a control
+ */
+ public static <T> T getModel( Object aControl, Class<T> aInterfaceClass )
+ {
+ XControl xControl = UnoRuntime.queryInterface(
+ XControl.class, aControl );
+ XControlModel xModel = null;
+ if ( null != xControl )
+ xModel = xControl.getModel();
+
+ return UnoRuntime.queryInterface( aInterfaceClass, xModel );
+ }
+
+ /* ------------------------------------------------------------------ */
+ /** retrieves the type of a form component.
+ <p>Speaking strictly, the function recognizes more than form components. Especially,
+ it survives a null argument. which means it can be safely applied to the a top-level
+ forms container; and it is able to classify grid columns (which are no form components)
+ as well.</p>
+ */
+ public static String classifyFormComponentType( XPropertySet xComponent ) throws com.sun.star.uno.Exception
+ {
+ String sType = "<unknown component>";
+
+ XServiceInfo xSI = UNO.queryServiceInfo( xComponent );
+
+ XPropertySetInfo xPSI = null;
+ if ( null != xComponent )
+ xPSI = xComponent.getPropertySetInfo();
+
+ if ( ( null != xPSI ) && xPSI.hasPropertyByName( "ClassId" ) )
+ {
+ // get the ClassId property
+ XPropertySet xCompProps = UNO.queryPropertySet( xComponent );
+
+ Short nClassId = (Short)xCompProps.getPropertyValue( "ClassId" );
+ switch ( nClassId.intValue() )
+ {
+ case FormComponentType.COMMANDBUTTON: sType = "Command button"; break;
+ case FormComponentType.RADIOBUTTON : sType = "Radio button"; break;
+ case FormComponentType.IMAGEBUTTON : sType = "Image button"; break;
+ case FormComponentType.CHECKBOX : sType = "Check Box"; break;
+ case FormComponentType.LISTBOX : sType = "List Box"; break;
+ case FormComponentType.COMBOBOX : sType = "Combo Box"; break;
+ case FormComponentType.GROUPBOX : sType = "Group Box"; break;
+ case FormComponentType.FIXEDTEXT : sType = "Fixed Text"; break;
+ case FormComponentType.GRIDCONTROL : sType = "Grid Control"; break;
+ case FormComponentType.FILECONTROL : sType = "File Control"; break;
+ case FormComponentType.HIDDENCONTROL: sType = "Hidden Control"; break;
+ case FormComponentType.IMAGECONTROL : sType = "Image Control"; break;
+ case FormComponentType.DATEFIELD : sType = "Date Field"; break;
+ case FormComponentType.TIMEFIELD : sType = "Time Field"; break;
+ case FormComponentType.NUMERICFIELD : sType = "Numeric Field"; break;
+ case FormComponentType.CURRENCYFIELD: sType = "Currency Field"; break;
+ case FormComponentType.PATTERNFIELD : sType = "Pattern Field"; break;
+
+ case FormComponentType.TEXTFIELD :
+ // there are two known services with this class id: the usual text field,
+ // and the formatted field
+ sType = "Text Field";
+ if ( ( null != xSI ) && xSI.supportsService( "com.sun.star.form.component.FormattedField" ) )
+ {
+ sType = "Formatted Field";
+ }
+ break;
+
+ default:
+ break;
+ }
+ }
+ else
+ {
+ if ( ( null != xSI ) && xSI.supportsService( "com.sun.star.form.component.DataForm" ) )
+ {
+ sType = "Form";
+ }
+ }
+
+ return sType;
+ }
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/Forms/FormLayer.java b/odk/examples/DevelopersGuide/Forms/FormLayer.java
new file mode 100644
index 000000000..11a9ce952
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Forms/FormLayer.java
@@ -0,0 +1,272 @@
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+import com.sun.star.uno.UnoRuntime;
+
+import com.sun.star.beans.XPropertySet;
+import com.sun.star.beans.XPropertySetInfo;
+import com.sun.star.container.XIndexContainer;
+import com.sun.star.container.XIndexAccess;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.drawing.XControlShape;
+import com.sun.star.drawing.XShapes;
+import com.sun.star.awt.Size;
+import com.sun.star.awt.Point;
+import com.sun.star.awt.XControlModel;
+import com.sun.star.text.TextContentAnchorType;
+import com.sun.star.drawing.XDrawPage;
+
+public class FormLayer
+{
+ private DocumentHelper m_document;
+ private int m_insertPage;
+
+ /* ------------------------------------------------------------------ */
+ /** Creates a new instance of FormLayer */
+ public FormLayer( DocumentHelper _document )
+ {
+ m_document = _document;
+ m_insertPage = -1;
+ }
+
+
+
+
+
+ /* ------------------------------------------------------------------ */
+ /** creates a control in the document
+
+ <p>Note that <em>control<em> here is an incorrect terminology. What the method really does is
+ it creates a control shape, together with a control model, and inserts them into the document model.
+ This will result in every view to this document creating a control described by the model-shape pair.
+ </p>
+
+ @param sFormComponentService
+ the service name of the form component to create, e.g. "TextField"
+ @param nXPos
+ the abscissa of the position of the newly inserted shape
+ @param nXPos
+ the ordinate of the position of the newly inserted shape
+ @param nWidth
+ the width of the newly inserted shape
+ @param nHeight
+ the height of the newly inserted shape
+ @param xParentForm
+ the form to use as parent for the newly create form component. May be null, in this case
+ a default parent is chosen by the implementation
+ @return
+ the property access to the control's model
+ */
+ protected XPropertySet createControlAndShape( String sFormComponentService, int nXPos,
+ int nYPos, int nWidth, int nHeight, XIndexContainer xParentForm ) throws java.lang.Exception
+ {
+ // let the document create a shape
+ XMultiServiceFactory xDocAsFactory = UnoRuntime.queryInterface(
+ XMultiServiceFactory.class, m_document.getDocument() );
+ XControlShape xShape = UnoRuntime.queryInterface( XControlShape.class,
+ xDocAsFactory.createInstance( "com.sun.star.drawing.ControlShape" ) );
+
+ // position and size of the shape
+ xShape.setSize( new Size( nWidth * 100, nHeight * 100 ) );
+ xShape.setPosition( new Point( nXPos * 100, nYPos * 100 ) );
+
+ // adjust the anchor so that the control is tied to the page
+ XPropertySet xShapeProps = UNO.queryPropertySet( xShape );
+ TextContentAnchorType eAnchorType = TextContentAnchorType.AT_PARAGRAPH;
+ xShapeProps.setPropertyValue( "AnchorType", eAnchorType );
+
+ // create the form component (the model of a form control)
+ String sQualifiedComponentName = "com.sun.star.form.component." + sFormComponentService;
+ XControlModel xModel = UnoRuntime.queryInterface( XControlModel.class,
+ m_document.getOrb().createInstance( sQualifiedComponentName ) );
+
+ // insert the model into the form component hierarchy, if the caller gave us a location
+ if ( null != xParentForm )
+ {
+ xParentForm.insertByIndex( xParentForm.getCount(), xModel );
+ }
+
+ // knitt them
+ xShape.setControl( xModel );
+
+ // add the shape to the shapes collection of the document
+ XDrawPage pageWhereToInsert = ( m_insertPage != -1 ) ? m_document.getDrawPage( m_insertPage ) : m_document.getMainDrawPage();
+
+ XShapes xDocShapes = UnoRuntime.queryInterface( XShapes.class, pageWhereToInsert );
+ xDocShapes.add( xShape );
+
+ // some initializations which are the same for all controls
+ XPropertySet xModelProps = UNO.queryPropertySet( xModel );
+ try
+ {
+ XPropertySetInfo xPSI = xModelProps.getPropertySetInfo();
+ if ( xPSI.hasPropertyByName( "Border" ) )
+ {
+ if ( ((Short)xModelProps.getPropertyValue( "Border" )).shortValue() == com.sun.star.awt.VisualEffect.LOOK3D )
+ xModelProps.setPropertyValue( "Border", Short.valueOf( com.sun.star.awt.VisualEffect.FLAT ) );
+ }
+ if ( xPSI.hasPropertyByName( "VisualEffect" ) )
+ xModelProps.setPropertyValue( "VisualEffect", Short.valueOf( com.sun.star.awt.VisualEffect.FLAT ) );
+ if ( m_document.classify() != DocumentType.CALC )
+ if ( xPSI.hasPropertyByName( "BorderColor" ) )
+ xModelProps.setPropertyValue( "BorderColor", Integer.valueOf( 0x00C0C0C0 ) );
+ }
+ catch( com.sun.star.uno.Exception e )
+ {
+ System.err.println(e);
+ e.printStackTrace( System.err );
+ }
+ return xModelProps;
+ }
+
+ /* ------------------------------------------------------------------ */
+ /** creates a control in the document
+
+ <p>Note that <em>control<em> here is an incorrect terminology. What the method really does is
+ it creates a control shape, together with a control model, and inserts them into the document model.
+ This will result in every view to this document creating a control described by the model-shape pair.
+ </p>
+
+ @param sFormComponentService
+ the service name of the form component to create, e.g. "TextField"
+ @param nXPos
+ the abscissa of the position of the newly inserted shape
+ @param nXPos
+ the ordinate of the position of the newly inserted shape
+ @param nWidth
+ the width of the newly inserted shape
+ @param nHeight
+ the height of the newly inserted shape
+ @return
+ the property access to the control's model
+ */
+ protected XPropertySet createControlAndShape( String sFormComponentService, int nXPos,
+ int nYPos, int nWidth, int nHeight ) throws java.lang.Exception
+ {
+ return createControlAndShape( sFormComponentService, nXPos, nYPos, nWidth, nHeight, null );
+ }
+
+ /* ------------------------------------------------------------------ */
+ /** creates a line of controls, consisting of a label and a field for data input.
+
+ <p>In opposite to the second form of this method, here the height of the field,
+ as well as the abscissa of the label, are under the control of the caller.</p>
+
+ @param sControlType
+ specifies the type of the data input control
+ @param sFieldName
+ specifies the field name the text field should be bound to
+ @param sControlNamePostfix
+ specifies a postfix to append to the logical control names
+ @param nYPos
+ specifies the Y position of the line to start at
+ @param nHeight
+ the height of the field
+ @return
+ the control model of the created data input field
+ */
+ protected XPropertySet insertControlLine( String sControlType, String sFieldName, String sControlNamePostfix, int nXPos, int nYPos, int nHeight )
+ throws java.lang.Exception
+ {
+ // insert the label control
+ XPropertySet xLabelModel = createControlAndShape( "FixedText", nXPos, nYPos, 25, 6 );
+ xLabelModel.setPropertyValue( "Label", sFieldName );
+
+ // insert the text field control
+ XPropertySet xFieldModel = createControlAndShape( sControlType, nXPos + 26, nYPos, 40, nHeight );
+ xFieldModel.setPropertyValue( "DataField", sFieldName );
+ // knit it to its label component
+ xFieldModel.setPropertyValue( "LabelControl", xLabelModel );
+
+ // some names, so later on we can find them
+ xLabelModel.setPropertyValue( "Name", sFieldName + sControlNamePostfix + "_Label" );
+ xFieldModel.setPropertyValue( "Name", sFieldName + sControlNamePostfix );
+
+ return xFieldModel;
+ }
+
+ /* ------------------------------------------------------------------ */
+ /** creates a line of controls, consisting of a label and a field for data input.
+
+ @param sControlType
+ specifies the type of the data input control
+ @param sFieldName
+ specifies the field name the text field should be bound to
+ @param nYPos
+ specifies the Y position of the line to start at
+ @return
+ the control model of the created data input field
+ */
+ protected XPropertySet insertControlLine( String sControlType, String sFieldName, String sControlNamePostfix, int nYPos )
+ throws java.lang.Exception
+ {
+ return insertControlLine( sControlType, sFieldName, sControlNamePostfix, 2, nYPos, 6 );
+ }
+
+ /* ------------------------------------------------------------------ */
+ /** retrieves the radio button model with the given name and the given ref value
+ * @param form
+ * the parent form of the radio button model to find
+ * @param name
+ * the name of the radio button
+ * @param refValue
+ * the reference value of the radio button
+ */
+ public XPropertySet getRadioModelByRefValue( XPropertySet form, String name, String refValue ) throws com.sun.star.uno.Exception, java.lang.Exception
+ {
+ XIndexAccess indexAccess = UnoRuntime.queryInterface( XIndexAccess.class,
+ form );
+
+ for ( int i=0; i<indexAccess.getCount(); ++i )
+ {
+ XPropertySet control = UNO.queryPropertySet( indexAccess.getByIndex( i ) );
+
+ if ( ((String)control.getPropertyValue( "Name" )).equals( name ) )
+ if ( ((String)control.getPropertyValue( "RefValue" )).equals( refValue ) )
+ return control;
+ }
+ return null;
+ }
+
+ /* ------------------------------------------------------------------ */
+ /** retrieves the radio button model with the given name and the given tag
+ * @param form
+ * the parent form of the radio button model to find
+ * @param name
+ * the name of the radio button
+ * @param tag
+ * the tag of the radio button
+ */
+ public XPropertySet getRadioModelByTag( XPropertySet form, String name, String tag ) throws com.sun.star.uno.Exception, java.lang.Exception
+ {
+ XIndexAccess indexAccess = UnoRuntime.queryInterface( XIndexAccess.class,
+ form );
+
+ for ( int i=0; i<indexAccess.getCount(); ++i )
+ {
+ XPropertySet control = UNO.queryPropertySet( indexAccess.getByIndex( i ) );
+
+ if ( ((String)control.getPropertyValue( "Name" )).equals( name ) )
+ if ( ((String)control.getPropertyValue( "Tag" )).equals( tag ) )
+ return control;
+ }
+ return null;
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/Forms/GridFieldValidator.java b/odk/examples/DevelopersGuide/Forms/GridFieldValidator.java
new file mode 100644
index 000000000..8bf0aef63
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Forms/GridFieldValidator.java
@@ -0,0 +1,174 @@
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+/**************************************************************************/
+import com.sun.star.uno.*;
+import com.sun.star.beans.*;
+import com.sun.star.form.*;
+import com.sun.star.lang.*;
+import com.sun.star.sdb.*;
+import com.sun.star.task.*;
+
+/**************************************************************************/
+/** helper class for validating a grid field before it is updated
+
+ <p>Actually, the mechanism for validating the field is not restricted to
+ grid control fields. Instead, it can be used for any bound controls.</p>
+*/
+class GridFieldValidator implements XUpdateListener
+{
+ private XComponentContext m_xCtx;
+ private XPropertySet m_xWatchedColumn;
+
+ private boolean m_bWatching;
+
+ /* ------------------------------------------------------------------ */
+ public GridFieldValidator( XComponentContext xCtx, XPropertySet xWatchedGridColumn )
+ {
+ // remember
+ m_xCtx = xCtx;
+ m_xWatchedColumn = xWatchedGridColumn;
+ DocumentHelper.getDocumentForComponent(xWatchedGridColumn,
+ xCtx);
+
+ m_bWatching = false;
+ }
+
+ /* ------------------------------------------------------------------ */
+ public void enableColumnWatch( boolean bEnable )
+ {
+ if ( bEnable == m_bWatching )
+ return;
+
+ XUpdateBroadcaster xUpdate = UnoRuntime.queryInterface(
+ XUpdateBroadcaster.class, m_xWatchedColumn );
+
+ if ( bEnable )
+ xUpdate.addUpdateListener( this );
+ else
+ xUpdate.removeUpdateListener( this );
+
+ m_bWatching = bEnable;
+ }
+
+ /* ------------------------------------------------------------------ */
+ /** shows a message that we can't do several things due to an implementation error
+ */
+ private void showInvalidValueMessage( )
+ {
+ try
+ {
+ // build the message we want to show
+ String sMessage = "The column \"";
+ sMessage += FLTools.getLabel( m_xWatchedColumn );
+ sMessage += "\" is not allowed to contain empty strings.";
+
+ SQLContext aError = new SQLContext(
+ "Invalid Value Entered",
+ null,
+ "S1000",
+ 0,
+ new Any( new Type(), null ),
+ sMessage
+ );
+
+ // instantiate an interaction handler who can handle SQLExceptions
+ XInteractionHandler xHandler = UnoRuntime.queryInterface(
+ XInteractionHandler.class,
+ m_xCtx.getServiceManager().createInstanceWithContext(
+ "com.sun.star.task.InteractionHandler", m_xCtx ) );
+
+ // create a new request and execute it
+ InteractionRequest aRequest = new InteractionRequest( aError );
+ xHandler.handle( aRequest );
+ }
+ catch( com.sun.star.uno.Exception e )
+ {
+ System.out.println(e);
+ e.printStackTrace();
+ }
+ }
+
+ /* ------------------------------------------------------------------ */
+ // XUpdateListener overridables
+ /* ------------------------------------------------------------------ */
+ public boolean approveUpdate( EventObject aEvent ) throws com.sun.star.uno.RuntimeException
+ {
+ boolean bApproved = true;
+ try
+ {
+ // the control model which fired the event
+ XPropertySet xSourceProps = UNO.queryPropertySet( aEvent.Source );
+
+ String sNewText = (String)xSourceProps.getPropertyValue( "Text" );
+ if ( 0 == sNewText.length() )
+ {
+ // say that the value is invalid
+ showInvalidValueMessage( );
+ bApproved = false;
+
+ // reset the control value
+ // for this, we take the current value from the row set field the control
+ // is bound to, and forward it to the control model
+ XColumn xBoundColumn = UNO.queryColumn( xSourceProps.getPropertyValue( "BoundField" ) );
+ if ( null != xBoundColumn )
+ {
+ xSourceProps.setPropertyValue( "Text", xBoundColumn.getString() );
+ }
+ }
+ }
+ catch( com.sun.star.uno.Exception e )
+ {
+ System.out.println(e);
+ e.printStackTrace();
+ }
+ return bApproved;
+ }
+
+ /* ------------------------------------------------------------------ */
+ public void updated( EventObject aEvent ) throws com.sun.star.uno.RuntimeException
+ {
+ }
+
+ /* ------------------------------------------------------------------ */
+ // XEventListener overridables
+ /* ------------------------------------------------------------------ */
+ public void disposing( EventObject aEvent )
+ {
+ // not interested in
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/Forms/HsqlDatabase.java b/odk/examples/DevelopersGuide/Forms/HsqlDatabase.java
new file mode 100644
index 000000000..fd2cd6ccf
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Forms/HsqlDatabase.java
@@ -0,0 +1,184 @@
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+import com.sun.star.beans.PropertyValue;
+import com.sun.star.beans.XPropertySet;
+import com.sun.star.container.XNameAccess;
+import com.sun.star.frame.XStorable;
+import com.sun.star.sdb.XOfficeDatabaseDocument;
+import com.sun.star.sdbc.SQLException;
+import com.sun.star.sdbc.XCloseable;
+import com.sun.star.sdbc.XConnection;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.sdb.XDocumentDataSource;
+import com.sun.star.sdbc.XDataSource;
+import com.sun.star.uno.XComponentContext;
+import java.io.File;
+
+import com.sun.star.util.CloseVetoException;
+
+public class HsqlDatabase
+{
+ private XComponentContext m_context;
+ // the URL of the temporary file used for the database document
+ private String m_databaseDocumentFile;
+ // the database document
+ private XOfficeDatabaseDocument m_databaseDocument;
+ // the data source belonging to the database document
+ // the default connection
+ private XConnection m_connection;
+
+
+ public HsqlDatabase( XComponentContext _context ) throws Exception
+ {
+ m_context = _context;
+ createDBDocument();
+ }
+
+
+ public HsqlDatabase( XComponentContext _context, String _existingDocumentURL ) throws Exception
+ {
+ m_context = _context;
+ createDBDocument( _existingDocumentURL );
+ }
+
+
+ private void createDBDocument( String _docURL ) throws Exception
+ {
+ m_databaseDocumentFile = _docURL;
+
+ XNameAccess dbContext = UnoRuntime.queryInterface( XNameAccess.class,
+ m_context.getServiceManager().createInstanceWithContext( "com.sun.star.sdb.DatabaseContext", m_context ) );
+ XDocumentDataSource dataSource = UnoRuntime.queryInterface( XDocumentDataSource.class,
+ dbContext.getByName( _docURL ) );
+
+ m_databaseDocument = dataSource.getDatabaseDocument();
+ }
+
+ /** creates an empty database document in a temporary location
+ */
+ private void createDBDocument() throws Exception
+ {
+ File documentFile = File.createTempFile("testdb",".odb");
+ documentFile.deleteOnExit();
+ m_databaseDocumentFile = URLHelper.getFileURLFromSystemPath( documentFile );
+
+ m_databaseDocument = UnoRuntime.queryInterface(
+ XOfficeDatabaseDocument.class, m_context.getServiceManager().createInstanceWithContext(
+ "com.sun.star.sdb.OfficeDatabaseDocument", m_context ) );
+
+ XPropertySet dsProperties = UnoRuntime.queryInterface( XPropertySet.class, m_databaseDocument.getDataSource() );
+ dsProperties.setPropertyValue("URL", "sdbc:embedded:hsqldb");
+
+ XStorable storable = UnoRuntime.queryInterface( XStorable.class, m_databaseDocument );
+ storable.storeAsURL( m_databaseDocumentFile, new PropertyValue[]{} );
+ }
+
+ /** closes the database document
+ *
+ * Any CloseVetoExceptions fired by third parties are ignored, and any reference to the
+ * database document is released.
+ */
+ private void close()
+ {
+ // close connection
+ XCloseable closeConn = UnoRuntime.queryInterface( XCloseable.class,
+ m_connection );
+ if ( closeConn != null )
+ {
+ try
+ {
+ closeConn.close();
+ }
+ catch( SQLException e )
+ {
+ }
+ }
+ m_connection = null;
+
+ // close document
+ com.sun.star.util.XCloseable closeDoc = UnoRuntime.queryInterface(
+ com.sun.star.util.XCloseable.class, m_databaseDocument );
+ if ( closeDoc != null )
+ {
+ try
+ {
+ closeDoc.close( true );
+ }
+ catch( CloseVetoException e )
+ {
+ }
+ }
+ m_databaseDocument = null;
+ }
+
+ /** closes the document, and deletes the underlying file
+ */
+ private void closeAndDelete()
+ {
+ close();
+
+ if ( m_databaseDocumentFile != null )
+ {
+ try
+ {
+ File file = new File(m_databaseDocumentFile);
+ file.delete();
+ }
+ catch(Exception e)
+ {
+ }
+ m_databaseDocumentFile = null;
+ }
+ }
+
+ /** returns the underlying database document
+ */
+ public XOfficeDatabaseDocument getDatabaseDocument()
+ {
+ return m_databaseDocument;
+ }
+
+ /** returns the associated data source
+ */
+ public XDataSource getDataSource()
+ {
+ return m_databaseDocument.getDataSource();
+ }
+
+
+
+ /** returns the URL of the ODB document represented by this instance
+ */
+ public String getDocumentURL()
+ {
+ return m_databaseDocumentFile;
+ }
+
+
+
+ @Override
+ protected void finalize() throws Throwable
+ {
+ closeAndDelete();
+ super.finalize();
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/Forms/InteractionRequest.java b/odk/examples/DevelopersGuide/Forms/InteractionRequest.java
new file mode 100644
index 000000000..52ec3b8ef
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Forms/InteractionRequest.java
@@ -0,0 +1,71 @@
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+import java.util.ArrayList;
+
+import com.sun.star.task.XInteractionContinuation;
+import com.sun.star.task.XInteractionRequest;
+
+/**************************************************************************/
+/** helper class for implementing an interaction request.
+*/
+class InteractionRequest implements XInteractionRequest
+{
+ private Object m_aRequest;
+ private ArrayList<XInteractionContinuation> m_aContinuations;
+
+ /* ------------------------------------------------------------------ */
+ public InteractionRequest( Object aRequest )
+ {
+ m_aRequest = aRequest;
+ m_aContinuations = new ArrayList<XInteractionContinuation>();
+ }
+
+
+
+ /* ------------------------------------------------------------------ */
+ public Object getRequest( )
+ {
+ return m_aRequest;
+ }
+
+ /* ------------------------------------------------------------------ */
+ public XInteractionContinuation[] getContinuations( )
+ {
+ return m_aContinuations.toArray( new XInteractionContinuation[ m_aContinuations.size() ] );
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/Forms/KeyGenerator.java b/odk/examples/DevelopersGuide/Forms/KeyGenerator.java
new file mode 100644
index 000000000..43e5acdfa
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Forms/KeyGenerator.java
@@ -0,0 +1,434 @@
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+import com.sun.star.uno.*;
+import com.sun.star.beans.*;
+import com.sun.star.form.*;
+import com.sun.star.lang.*;
+import com.sun.star.sdb.*;
+import com.sun.star.sdbc.*;
+import com.sun.star.sdbcx.*;
+import com.sun.star.container.*;
+import com.sun.star.awt.*;
+
+/**************************************************************************/
+/** base class for helpers dealing with unique column values
+*/
+class UniqueColumnValue
+{
+ /* ------------------------------------------------------------------ */
+ /** extracts the name of the table a form is based on.
+
+ <p>This method works for forms based directly on tables, and for forms based on statements, which
+ themself are based on one table.<br>
+ Everything else (especially forms based on queries) is not yet implemented.</p>
+ */
+ private String extractTableName( XPropertySet xForm ) throws com.sun.star.uno.Exception
+ {
+ String sReturn;
+
+ Integer aCommandType = (Integer)xForm.getPropertyValue( "CommandType" );
+ String sCommand = (String)xForm.getPropertyValue( "Command" );
+
+ if ( CommandType.COMMAND == aCommandType.intValue() )
+ {
+ // get the connection from the form
+ XConnection xFormConn = UnoRuntime.queryInterface( XConnection.class,
+ xForm.getPropertyValue( "ActiveConnection" ) );
+ // and let it create a composer for us
+ XSQLQueryComposerFactory xComposerFac =
+ UnoRuntime.queryInterface(
+ XSQLQueryComposerFactory.class, xFormConn );
+ XSQLQueryComposer xComposer = xComposerFac.createQueryComposer( );
+
+ // let this composer analyze the command
+ xComposer.setQuery( sCommand );
+
+ // and ask it for the table(s)
+ XTablesSupplier xSuppTables = UnoRuntime.queryInterface(
+ XTablesSupplier.class, xComposer );
+ XNameAccess xTables = xSuppTables.getTables();
+
+ // simply take the first table name
+ String[] aNames = xTables.getElementNames( );
+ sCommand = aNames[0];
+ }
+
+ return sCommand;
+ }
+
+ /* ------------------------------------------------------------------ */
+ /** generates a statement which can be used to create a unique (in all conscience) value
+ for the column given.
+ <p>Currently, the implementation uses a very simple approach - it just determines the maximum of currently
+ existing values in the column. If your concrete data source supports a more sophisticated approach of generating
+ unique values, you probably want to adjust the <code>SELECT</code> statement below accordingly.</p>
+
+ @returns
+ a String which can be used as statement to retrieve a unique value for the given column.
+ The result set resulting from such an execution contains the value in its first column.
+ */
+ private String composeUniqueyKeyStatement( XPropertySet xForm, String sFieldName ) throws com.sun.star.uno.Exception
+ {
+ String sStatement = "SELECT MAX( ";
+ sStatement += sFieldName;
+ sStatement += ") + 1 FROM ";
+ // the table name is a property of the form
+ sStatement += extractTableName( xForm );
+
+ // note that the implementation is imperfect (besides the problem that MAX is not a really good solution
+ // for a database with more that one client):
+ // It does not quote the field and the table name. This needs to be done if the database is intolerant
+ // against such things - the XDatabaseMetaData, obtained from the connection, would be needed then
+ // Unfortunately, there is no UNO service doing this - it would need to be implemented manually.
+
+ return sStatement;
+ }
+
+ /* ------------------------------------------------------------------ */
+ /** generates a unique (in all conscience) key into the column given
+ @param xForm
+ the form which contains the column in question
+ @param sFieldName
+ the name of the column
+ */
+ private int generatePrimaryKey( XPropertySet xForm, String sFieldName ) throws com.sun.star.uno.Exception
+ {
+ // get the current connection of the form
+ XConnection xConn = UnoRuntime.queryInterface(
+ XConnection.class, xForm.getPropertyValue( "ActiveConnection" ) );
+ // let it create a new statement
+ XStatement xStatement = xConn.createStatement();
+
+ // build the query string to determine a free value
+ String sStatement = composeUniqueyKeyStatement( xForm, sFieldName );
+
+ // execute the query
+ XResultSet xResults = xStatement.executeQuery( sStatement );
+
+ // move the result set to the first record
+ xResults.next( );
+
+ // get the value
+ XRow xRow = UnoRuntime.queryInterface( XRow.class, xResults );
+ int nFreeValue = xRow.getInt( 1 );
+
+ // dispose the temporary objects
+ FLTools.disposeComponent( xStatement );
+ // this should get rid of the result set, too
+
+ return nFreeValue;
+ }
+
+ /* ------------------------------------------------------------------ */
+ /** inserts a unique (in all conscience) key into the column given
+ @param xForm
+ the form which contains the column in question
+ @param sFieldName
+ the name of the column
+ */
+ public void insertPrimaryKey( XPropertySet xForm, String sFieldName ) throws com.sun.star.uno.Exception
+ {
+ // check the privileges
+ Integer aConcurrency = (Integer)xForm.getPropertyValue( "ResultSetConcurrency" );
+ if ( ResultSetConcurrency.READ_ONLY != aConcurrency.intValue() )
+ {
+ // get the column object
+ XColumnsSupplier xSuppCols = UnoRuntime.queryInterface(
+ XColumnsSupplier.class, xForm );
+ XNameAccess xCols = xSuppCols.getColumns();
+ XColumnUpdate xCol = UnoRuntime.queryInterface(
+ XColumnUpdate.class, xCols.getByName( sFieldName ) );
+
+ xCol.updateInt( generatePrimaryKey( xForm, sFieldName ) );
+ }
+ }
+}
+
+/**************************************************************************/
+/** base class for helpers dealing with unique column values
+*/
+class KeyGeneratorForReset extends UniqueColumnValue implements XResetListener
+{
+ /* ------------------------------------------------------------------ */
+ private DocumentViewHelper m_aView;
+ private String m_sFieldName;
+
+ /* ------------------------------------------------------------------ */
+ /** ctor
+ @param aView
+ the view which shall be used to focus controls
+ @param sFieldName
+ the name of the field for which keys should be generated
+ */
+ public KeyGeneratorForReset( String sFieldName, DocumentViewHelper aView )
+ {
+ m_sFieldName = sFieldName;
+ m_aView = aView;
+ }
+
+ /* ------------------------------------------------------------------ */
+ /** sets the focus to the first control which is no fixed text, and not the
+ one we're defaulting
+ */
+ private void defaultNewRecordFocus( XPropertySet xForm ) throws com.sun.star.uno.Exception
+ {
+ XIndexAccess xFormAsContainer = UnoRuntime.queryInterface(
+ XIndexAccess.class, xForm );
+ for ( int i = 0; i<xFormAsContainer.getCount(); ++i )
+ {
+ // the model
+ XPropertySet xModel = UNO.queryPropertySet( xFormAsContainer.getByIndex( i ) );
+
+ // check if it's a valid leaf (no sub form or such)
+ XPropertySetInfo xPSI = xModel.getPropertySetInfo( );
+ if ( ( null == xPSI ) || !xPSI.hasPropertyByName( "ClassId" ) )
+ continue;
+
+ // check if it's a fixed text
+ Short nClassId = (Short)xModel.getPropertyValue( "ClassId" );
+ if ( FormComponentType.FIXEDTEXT == nClassId.shortValue() )
+ continue;
+
+ // check if it is bound to the field we are responsible for
+ if ( !xPSI.hasPropertyByName( "DataField" ) )
+ continue;
+
+ String sFieldDataSource = (String)xModel.getPropertyValue( "DataField" );
+ if ( sFieldDataSource.equals( m_sFieldName ) )
+ continue;
+
+ // both conditions do not apply
+ // -> set the focus into the respective control
+ XControlModel xCM = UNO.queryControlModel( xModel );
+ m_aView.grabControlFocus( xCM);
+ break;
+ }
+ }
+
+ /* ------------------------------------------------------------------ */
+ // XResetListener overridables
+ /* ------------------------------------------------------------------ */
+ public boolean approveReset( com.sun.star.lang.EventObject rEvent ) throws com.sun.star.uno.RuntimeException
+ {
+ // not interested in vetoing this
+ return true;
+ }
+
+ /* ------------------------------------------------------------------ */
+ public void resetted( com.sun.star.lang.EventObject aEvent ) throws com.sun.star.uno.RuntimeException
+ {
+ // check if this reset occurred because we're on a new record
+ XPropertySet xFormProps = UNO.queryPropertySet( aEvent.Source );
+ try
+ {
+ Boolean aIsNew = (Boolean)xFormProps.getPropertyValue( "IsNew" );
+ if ( aIsNew.booleanValue() )
+ { // yepp
+
+ // we're going to modify the record, though after that, to the user, it should look
+ // like it has not been modified
+ // So we need to ensure that we do not change the IsModified property with whatever we do
+ Object aModifiedFlag = xFormProps.getPropertyValue( "IsModified" );
+
+ // now set the value
+ insertPrimaryKey( xFormProps, m_sFieldName );
+
+ // then restore the flag
+ xFormProps.setPropertyValue( "IsModified", aModifiedFlag );
+
+ // still one thing ... would be nice to have the focus in a control which is
+ // the one which's value we just defaulted
+ defaultNewRecordFocus( xFormProps );
+ }
+ }
+ catch( com.sun.star.uno.Exception e )
+ {
+ System.out.println(e);
+ e.printStackTrace();
+ }
+ }
+ /* ------------------------------------------------------------------ */
+ // XEventListener overridables
+ /* ------------------------------------------------------------------ */
+ public void disposing( EventObject aEvent )
+ {
+ // not interested in
+ }
+}
+
+
+/**************************************************************************/
+/** base class for helpers dealing with unique column values
+*/
+class KeyGeneratorForUpdate extends UniqueColumnValue implements XRowSetApproveListener
+{
+ /* ------------------------------------------------------------------ */
+ private String m_sFieldName;
+
+ /* ------------------------------------------------------------------ */
+ public KeyGeneratorForUpdate( String sFieldName )
+ {
+ m_sFieldName = sFieldName;
+ }
+
+ /* ------------------------------------------------------------------ */
+ // XRowSetApproveListener overridables
+ /* ------------------------------------------------------------------ */
+ public boolean approveCursorMove( com.sun.star.lang.EventObject aEvent ) throws com.sun.star.uno.RuntimeException
+ {
+ // not interested in vetoing moves
+ return true;
+ }
+
+ /* ------------------------------------------------------------------ */
+ public boolean approveRowChange( RowChangeEvent aEvent ) throws com.sun.star.uno.RuntimeException
+ {
+ if ( RowChangeAction.INSERT == aEvent.Action )
+ {
+ try
+ {
+ // the affected form
+ XPropertySet xFormProps = UNO.queryPropertySet( aEvent.Source );
+ // insert a new unique value
+ insertPrimaryKey( xFormProps, m_sFieldName );
+ }
+ catch( com.sun.star.uno.Exception e )
+ {
+ System.out.println(e);
+ e.printStackTrace();
+ }
+ }
+ return true;
+ }
+
+ /* ------------------------------------------------------------------ */
+ public boolean approveRowSetChange( com.sun.star.lang.EventObject aEvent ) throws com.sun.star.uno.RuntimeException
+ {
+ // not interested in vetoing executions of the row set
+ return true;
+ }
+ /* ------------------------------------------------------------------ */
+ // XEventListener overridables
+ /* ------------------------------------------------------------------ */
+ public void disposing( EventObject aEvent )
+ {
+ // not interested in
+ }
+}
+
+/**************************************************************************/
+/** allows to generate unique keys for a field of a Form
+*/
+public class KeyGenerator
+{
+ /* ------------------------------------------------------------------ */
+ private KeyGeneratorForReset m_aResetKeyGenerator;
+ private KeyGeneratorForUpdate m_aUpdateKeyGenerator;
+ private boolean m_bResetListening;
+ private boolean m_bUpdateListening;
+
+ private XPropertySet m_xForm;
+
+ /* ------------------------------------------------------------------ */
+ /** ctor
+ @param xForm
+ specified the form to operate on
+ @param sFieldName
+ specifies the field which's value should be manipulated
+ */
+ public KeyGenerator( XPropertySet xForm, String sFieldName,
+ XComponentContext xCtx )
+ {
+ m_xForm = xForm;
+
+ DocumentHelper aDocument = DocumentHelper.getDocumentForComponent( xForm, xCtx );
+
+ m_aResetKeyGenerator = new KeyGeneratorForReset( sFieldName, aDocument.getCurrentView() );
+ m_aUpdateKeyGenerator = new KeyGeneratorForUpdate( sFieldName );
+
+ m_bResetListening = m_bUpdateListening = false;
+ }
+
+ /* ------------------------------------------------------------------ */
+ /** stops any actions on the form
+ */
+ public void stopGenerator( )
+ {
+ XReset xFormReset = UNO.queryReset( m_xForm );
+ xFormReset.removeResetListener( m_aResetKeyGenerator );
+
+ XRowSetApproveBroadcaster xFormBroadcaster = UnoRuntime.queryInterface(
+ XRowSetApproveBroadcaster.class, m_xForm );
+ xFormBroadcaster.removeRowSetApproveListener( m_aUpdateKeyGenerator );
+
+ m_bUpdateListening = m_bResetListening = false;
+ }
+
+ /* ------------------------------------------------------------------ */
+ /** activates one of our two key generators
+ */
+ public void activateKeyGenerator( boolean bGenerateOnReset )
+ {
+ // for resets
+ XReset xFormReset = UNO.queryReset( m_xForm );
+ // for approving actions
+ XRowSetApproveBroadcaster xFormBroadcaster = UnoRuntime.queryInterface(
+ XRowSetApproveBroadcaster.class, m_xForm );
+
+ if ( bGenerateOnReset )
+ {
+ if ( !m_bResetListening )
+ xFormReset.addResetListener( m_aResetKeyGenerator );
+ if ( m_bUpdateListening )
+ xFormBroadcaster.removeRowSetApproveListener( m_aUpdateKeyGenerator );
+
+ m_bUpdateListening = false;
+ m_bResetListening = true;
+ }
+ else
+ {
+ if ( m_bResetListening )
+ xFormReset.removeResetListener( m_aResetKeyGenerator );
+ if ( !m_bUpdateListening )
+ xFormBroadcaster.addRowSetApproveListener( m_aUpdateKeyGenerator );
+
+ m_bResetListening = false;
+ m_bUpdateListening = true;
+ }
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/Forms/ListSelectionValidator.java b/odk/examples/DevelopersGuide/Forms/ListSelectionValidator.java
new file mode 100644
index 000000000..8a8909390
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Forms/ListSelectionValidator.java
@@ -0,0 +1,59 @@
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+public class ListSelectionValidator extends ControlValidator
+{
+ /** Creates a new instance of ListSelectionValidator */
+ public ListSelectionValidator()
+ {
+ }
+
+ public String explainInvalid( Object Value )
+ {
+ try
+ {
+ short[] selectionIndexes = (short[])Value;
+ if ( selectionIndexes.length > 2 )
+ return "please 2 entries, at most";
+ }
+ catch( java.lang.Exception e )
+ {
+ return "oops. What's this?";
+ }
+ return "";
+ }
+
+ public boolean isValid( Object Value )
+ {
+ try
+ {
+ short[] selectionIndexes = (short[])Value;
+ if ( selectionIndexes.length > 2 )
+ return false;
+ return true;
+ }
+ catch( java.lang.Exception e )
+ {
+ }
+ return false;
+ }
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/Forms/Makefile b/odk/examples/DevelopersGuide/Forms/Makefile
new file mode 100644
index 000000000..54cf7aad9
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Forms/Makefile
@@ -0,0 +1,196 @@
+#*************************************************************************
+#
+# The Contents of this file are made available subject to the terms of
+# the BSD license.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+# 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+# contributors may be used to endorse or promote products derived
+# from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+# TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+# USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+#**************************************************************************
+
+# Builds the Forms example of the Developers Guide.
+
+PRJ=../../..
+SETTINGS=$(PRJ)/settings
+
+include $(SETTINGS)/settings.mk
+include $(SETTINGS)/std.mk
+
+# Define non-platform/compiler specific settings
+SAMPLE_NAME=FormsExamples
+SAMPLE_CLASS_OUT=$(OUT_CLASS)/$(SAMPLE_NAME)
+SAMPLE_GEN_OUT=$(OUT_MISC)/$(SAMPLE_NAME)
+
+APP1_NAME=DataAwareness
+APP1_CLASS_OUT=$(SAMPLE_CLASS_OUT)/$(APP1_NAME)
+APP1_JAR=$(SAMPLE_CLASS_OUT)/$(APP1_NAME).jar
+APP2_NAME=ValueBinding
+APP2_CLASS_OUT=$(SAMPLE_CLASS_OUT)/$(APP2_NAME)
+APP2_JAR=$(SAMPLE_CLASS_OUT)/$(APP2_NAME).jar
+APP3_NAME=SpreadsheetValueBinding
+APP3_CLASS_OUT=$(SAMPLE_CLASS_OUT)/$(APP3_NAME)
+APP3_JAR=$(SAMPLE_CLASS_OUT)/$(APP3_NAME).jar
+APP4_NAME=ControlValidation
+APP4_CLASS_OUT=$(SAMPLE_CLASS_OUT)/$(APP4_NAME)
+APP4_JAR=$(SAMPLE_CLASS_OUT)/$(APP4_NAME).jar
+
+COMMON_CLASS_OUT = $(SAMPLE_CLASS_OUT)/common
+COMMON_JAVAFILES = \
+ ButtonOperator.java \
+ ComponentTreeTraversal.java \
+ ControlLock.java \
+ DocumentHelper.java \
+ DocumentType.java \
+ DocumentViewHelper.java \
+ FLTools.java \
+ FormLayer.java \
+ GridFieldValidator.java \
+ InteractionRequest.java \
+ KeyGenerator.java \
+ SalesFilter.java \
+ UNO.java \
+ SpreadsheetView.java \
+ WaitForInput.java \
+ DocumentBasedExample.java \
+ TableCellTextBinding.java \
+ SpreadsheetDocument.java \
+ NumericValidator.java \
+ TextValidator.java \
+ BooleanValidator.java \
+ ListSelectionValidator.java \
+ DateValidator.java \
+ TimeValidator.java \
+ ControlValidator.java \
+ SingleControlValidation.java \
+ HsqlDatabase.java \
+ RowSet.java \
+ URLHelper.java
+
+COMMON_CLASSFILES = $(patsubst %.java,$(COMMON_CLASS_OUT)/%.class,$(COMMON_JAVAFILES))
+
+SDK_CLASSPATH = $(subst $(EMPTYSTRING) $(PATH_SEPARATOR),$(PATH_SEPARATOR),$(CLASSPATH)\
+ $(PATH_SEPARATOR)$(SAMPLE_CLASS_OUT)\
+ $(PATH_SEPARATOR)$(COMMON_CLASS_OUT))
+
+
+# Targets
+.PHONY: ALL
+ALL : \
+ FormsExample
+
+include $(SETTINGS)/stdtarget.mk
+
+$(COMMON_CLASSFILES) : $(COMMON_JAVAFILES)
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ $(SDK_JAVAC) $(JAVAC_FLAGS) -classpath "$(SDK_CLASSPATH)" -d $(COMMON_CLASS_OUT) $^
+
+# rule for client/example application manifest file
+$(SAMPLE_GEN_OUT)/%.mf :
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ @echo Main-Class: com.sun.star.lib.loader.Loader> $@
+ $(ECHOLINE)>> $@
+ @echo Name: com/sun/star/lib/loader/Loader.class>> $@
+ @echo Application-Class: $*>> $@
+
+$(APP1_CLASS_OUT)/$(APP1_NAME).class : $(APP1_NAME).java $(COMMON_CLASSFILES)
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ $(SDK_JAVAC) $(JAVAC_FLAGS) -classpath "$(SDK_CLASSPATH)" -d $(APP1_CLASS_OUT) $<
+
+$(APP2_CLASS_OUT)/$(APP2_NAME).class : $(APP2_NAME).java $(COMMON_CLASSFILES)
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ $(SDK_JAVAC) $(JAVAC_FLAGS) -classpath "$(SDK_CLASSPATH)" -d $(APP2_CLASS_OUT) $<
+
+$(APP3_CLASS_OUT)/$(APP3_NAME).class : $(APP3_NAME).java $(COMMON_CLASSFILES)
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ $(SDK_JAVAC) $(JAVAC_FLAGS) -classpath "$(SDK_CLASSPATH)" -d $(APP3_CLASS_OUT) $<
+
+$(APP4_CLASS_OUT)/$(APP4_NAME).class : $(APP4_NAME).java $(COMMON_CLASSFILES)
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ $(SDK_JAVAC) $(JAVAC_FLAGS) -classpath "$(SDK_CLASSPATH)" -d $(APP4_CLASS_OUT) $<
+
+$(APP1_JAR) : $(SAMPLE_GEN_OUT)/$(APP1_NAME).mf $(APP1_CLASS_OUT)/$(APP1_NAME).class $(COMMON_CLASSFILES)
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ +$(SDK_JAR) cvfm $@ $< -C $(APP1_CLASS_OUT) .
+ +$(SDK_JAR) uvf $@ -C $(COMMON_CLASS_OUT) .
+ +$(SDK_JAR) uvf $@ $(SDK_JAVA_UNO_BOOTSTRAP_FILES)
+
+$(APP2_JAR) : $(SAMPLE_GEN_OUT)/$(APP2_NAME).mf $(APP2_CLASS_OUT)/$(APP2_NAME).class $(COMMON_CLASSFILES)
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ +$(SDK_JAR) cvfm $@ $< -C $(APP2_CLASS_OUT) .
+ +$(SDK_JAR) uvf $@ -C $(COMMON_CLASS_OUT) .
+ +$(SDK_JAR) uvf $@ $(SDK_JAVA_UNO_BOOTSTRAP_FILES)
+
+$(APP3_JAR) : $(SAMPLE_GEN_OUT)/$(APP3_NAME).mf $(APP3_CLASS_OUT)/$(APP3_NAME).class $(COMMON_CLASSFILES)
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ +$(SDK_JAR) cvfm $@ $< -C $(APP3_CLASS_OUT) .
+ +$(SDK_JAR) uvf $@ -C $(COMMON_CLASS_OUT) .
+ +$(SDK_JAR) uvf $@ $(SDK_JAVA_UNO_BOOTSTRAP_FILES)
+
+$(APP4_JAR) : $(SAMPLE_GEN_OUT)/$(APP4_NAME).mf $(APP4_CLASS_OUT)/$(APP4_NAME).class $(COMMON_CLASSFILES)
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ +$(SDK_JAR) cvfm $@ $< -C $(APP4_CLASS_OUT) .
+ +$(SDK_JAR) uvf $@ -C $(COMMON_CLASS_OUT) .
+ +$(SDK_JAR) uvf $@ $(SDK_JAVA_UNO_BOOTSTRAP_FILES)
+
+FormsExample : $(APP1_JAR) $(APP2_JAR) $(APP3_JAR) $(APP4_JAR)
+ @echo --------------------------------------------------------------------------------
+ @echo "$(QM)$(APP1_NAME)$(QM)" demonstrates various things around data aware controls.
+ @echo "$(QM)$(APP2_NAME)$(QM)" demonstrates the use of value bindings for form controls.
+ @echo "$(QM)$(APP3_NAME)$(QM)" demonstrates the usage of the com.sun.star.table.CellValueBinding service
+ @echo "$(QM)$(APP4_NAME)$(QM)" demonstrates the form control validation API
+
+ @echo Please use one of the following commands to run an example:
+ @echo -
+ @echo $(MAKE) $(APP1_NAME).run
+ @echo $(MAKE) $(APP2_NAME).run
+ @echo $(MAKE) $(APP3_NAME).run
+ @echo $(MAKE) $(APP4_NAME).run
+ @echo -
+ @echo Note: The data awareness example needs a running data source with name
+ @echo $(SQM) $(SQM)"$(QM)OO_SDK_Demo_DB$(QM)". Make sure that you have created such a data source,
+ @echo -
+ @echo The document "$(QM)ProgrammaticScriptAssignment.odt$(QM)" demonstrates
+ @echo how you can programmatically create form controls, and associated
+ @echo scripts with certain events.
+ @echo -
+ @echo $(MAKE) ProgrammaticScriptAssignment.odt.load
+ @echo --------------------------------------------------------------------------------
+
+ProgrammaticScriptAssignment.odt.load : $(COMP_REGISTERFLAG)
+ "$(OFFICE_PROGRAM_PATH)$(PS)soffice" $(basename $@)
+
+%.run: $(SAMPLE_CLASS_OUT)/%.jar
+ $(SDK_JAVA) -Dcom.sun.star.lib.loader.unopath="$(OFFICE_PROGRAM_PATH)" -jar $<
+
+.PHONY: clean
+clean :
+ -$(DELRECURSIVE) $(subst /,$(PS),$(SAMPLE_CLASS_OUT))
+ -$(DELRECURSIVE) $(subst /,$(PS),$(SAMPLE_GEN_OUT))
diff --git a/odk/examples/DevelopersGuide/Forms/NumericValidator.java b/odk/examples/DevelopersGuide/Forms/NumericValidator.java
new file mode 100644
index 000000000..4df77af20
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Forms/NumericValidator.java
@@ -0,0 +1,77 @@
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+public class NumericValidator extends ControlValidator
+{
+
+ /** Creates a new instance of NumericValidator */
+ public NumericValidator( )
+ {
+ }
+
+ public String explainInvalid( Object Value )
+ {
+ try
+ {
+ double value = ((Double)Value).doubleValue();
+ if ( Double.compare( Double.NaN, value ) == 0 )
+ return "This is NotANumber";
+ if ( !isProperRange( value ) )
+ return "The value must be between 0 and 100";
+ if ( !isProperDigitCount( value ) )
+ return "The value must have at most one decimal digit";
+ }
+ catch( java.lang.Exception e )
+ {
+ return "This is no valid number";
+ }
+ return "";
+ }
+
+ public boolean isValid( Object Value )
+ {
+ try
+ {
+ double value = ((Double)Value).doubleValue();
+ if ( Double.compare( Double.NaN, value ) == 0 )
+ return false;
+ if ( !isProperRange( value ) )
+ return false;
+ if ( !isProperDigitCount( value ) )
+ return false;
+ return true;
+ }
+ catch( java.lang.Exception e )
+ {
+ }
+ return false;
+ }
+
+ private boolean isProperRange( double value)
+ {
+ return ( value >= 0 ) && ( value <= 100 );
+ }
+
+ private boolean isProperDigitCount( double value)
+ {
+ return ( Math.floor( value * 10 ) == value * 10 );
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/Forms/ProgrammaticScriptAssignment.odt b/odk/examples/DevelopersGuide/Forms/ProgrammaticScriptAssignment.odt
new file mode 100644
index 000000000..40b952d94
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Forms/ProgrammaticScriptAssignment.odt
Binary files differ
diff --git a/odk/examples/DevelopersGuide/Forms/RowSet.java b/odk/examples/DevelopersGuide/Forms/RowSet.java
new file mode 100644
index 000000000..93e62cacf
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Forms/RowSet.java
@@ -0,0 +1,283 @@
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+import com.sun.star.beans.XPropertySet;
+import com.sun.star.container.XIndexAccess;
+import com.sun.star.container.XNameAccess;
+import com.sun.star.io.XInputStream;
+import com.sun.star.sdbc.SQLException;
+import com.sun.star.sdbc.XArray;
+import com.sun.star.sdbc.XBlob;
+import com.sun.star.sdbc.XClob;
+import com.sun.star.sdbc.XRef;
+import com.sun.star.sdbc.XRow;
+import com.sun.star.sdbc.XRowSet;
+import com.sun.star.sdbc.XRowSetListener;
+import com.sun.star.sdbcx.XColumnsSupplier;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.XComponentContext;
+import com.sun.star.util.Date;
+import com.sun.star.util.DateTime;
+import com.sun.star.util.Time;
+
+public class RowSet implements XRowSet, XRow
+{
+ private XRowSet m_rowSet;
+ private XRow m_row;
+ private XPropertySet m_rowSetProps;
+
+ public RowSet( XComponentContext _context, String _dataSource, int _commandType, String _command )
+ {
+ try
+ {
+ m_rowSetProps = UnoRuntime.queryInterface(
+ XPropertySet.class, _context.getServiceManager().createInstanceWithContext( "com.sun.star.sdb.RowSet", _context ) );
+ m_rowSetProps.setPropertyValue( "DataSourceName", _dataSource );
+ m_rowSetProps.setPropertyValue( "CommandType", Integer.valueOf( _commandType ) );
+ m_rowSetProps.setPropertyValue( "Command", _command );
+
+ m_rowSet = UnoRuntime.queryInterface( XRowSet.class, m_rowSetProps );
+ m_row = UnoRuntime.queryInterface( XRow.class, m_rowSetProps );
+ }
+ catch ( Exception e )
+ {
+ e.printStackTrace(System.err);
+ throw new java.lang.InstantiationError();
+ }
+ }
+
+ // misc
+ public int getColumnCount()
+ {
+ XColumnsSupplier suppCols = UnoRuntime.queryInterface(
+ XColumnsSupplier.class, m_rowSet );
+ XIndexAccess columns = UnoRuntime.queryInterface(
+ XIndexAccess.class, suppCols.getColumns() );
+ return columns.getCount();
+ }
+
+ // XRowSet
+ public void execute() throws SQLException
+ {
+ m_rowSet.execute();
+ }
+
+ public void addRowSetListener( XRowSetListener _listener )
+ {
+ m_rowSet.addRowSetListener( _listener );
+ }
+
+ public void removeRowSetListener( XRowSetListener _listener )
+ {
+ m_rowSet.removeRowSetListener( _listener );
+ }
+
+ public boolean next() throws SQLException
+ {
+ return m_rowSet.next();
+ }
+
+ public boolean isBeforeFirst() throws SQLException
+ {
+ return m_rowSet.isBeforeFirst();
+ }
+
+ public boolean isAfterLast() throws SQLException
+ {
+ return m_rowSet.isAfterLast();
+ }
+
+ public boolean isFirst() throws SQLException
+ {
+ return m_rowSet.isFirst();
+ }
+
+ public boolean isLast() throws SQLException
+ {
+ return m_rowSet.isLast();
+ }
+
+ public void beforeFirst() throws SQLException
+ {
+ m_rowSet.beforeFirst();
+ }
+
+ public void afterLast() throws SQLException
+ {
+ m_rowSet.afterLast();
+ }
+
+ public boolean first() throws SQLException
+ {
+ return m_rowSet.first();
+ }
+
+ public boolean last() throws SQLException
+ {
+ return m_rowSet.last();
+ }
+
+ public int getRow() throws SQLException
+ {
+ return m_rowSet.getRow();
+ }
+
+ public boolean absolute(int i) throws SQLException
+ {
+ return m_rowSet.absolute(i);
+ }
+
+ public boolean relative(int i) throws SQLException
+ {
+ return m_rowSet.relative(i);
+ }
+
+ public boolean previous() throws SQLException
+ {
+ return m_rowSet.previous();
+ }
+
+ public void refreshRow() throws SQLException
+ {
+ m_rowSet.refreshRow();
+ }
+
+ public boolean rowUpdated() throws SQLException
+ {
+ return m_rowSet.rowUpdated();
+ }
+
+ public boolean rowInserted() throws SQLException
+ {
+ return m_rowSet.rowInserted();
+ }
+
+ public boolean rowDeleted() throws SQLException
+ {
+ return m_rowSet.rowDeleted();
+ }
+
+ // XRow
+ public Object getStatement() throws SQLException
+ {
+ return m_rowSet.getStatement();
+ }
+
+ public boolean wasNull() throws SQLException
+ {
+ return m_row.wasNull();
+ }
+
+ public String getString(int i) throws SQLException
+ {
+ return m_row.getString(i);
+ }
+
+ public boolean getBoolean(int i) throws SQLException
+ {
+ return m_row.getBoolean(i);
+ }
+
+ public byte getByte(int i) throws SQLException
+ {
+ return m_row.getByte(i);
+ }
+
+ public short getShort(int i) throws SQLException
+ {
+ return m_row.getShort(i);
+ }
+
+ public int getInt(int i) throws SQLException
+ {
+ return m_row.getInt(i);
+ }
+
+ public long getLong(int i) throws SQLException
+ {
+ return m_row.getLong(i);
+ }
+
+ public float getFloat(int i) throws SQLException
+ {
+ return m_row.getFloat(i);
+ }
+
+ public double getDouble(int i) throws SQLException
+ {
+ return m_row.getDouble(i);
+ }
+
+ public byte[] getBytes(int i) throws SQLException
+ {
+ return m_row.getBytes(i);
+ }
+
+ public Date getDate(int i) throws SQLException
+ {
+ return m_row.getDate(i);
+ }
+
+ public Time getTime(int i) throws SQLException
+ {
+ return m_row.getTime(i);
+ }
+
+ public DateTime getTimestamp(int i) throws SQLException
+ {
+ return m_row.getTimestamp(i);
+ }
+
+ public XInputStream getBinaryStream(int i) throws SQLException
+ {
+ return m_row.getBinaryStream(i);
+ }
+
+ public XInputStream getCharacterStream(int i) throws SQLException
+ {
+ return m_row.getCharacterStream(i);
+ }
+
+ public Object getObject(int i, XNameAccess xNameAccess) throws SQLException
+ {
+ return m_row.getObject(i, xNameAccess);
+ }
+
+ public XRef getRef(int i) throws SQLException
+ {
+ return m_row.getRef(i);
+ }
+
+ public XBlob getBlob(int i) throws SQLException
+ {
+ return m_row.getBlob(i);
+ }
+
+ public XClob getClob(int i) throws SQLException
+ {
+ return m_row.getClob(i);
+ }
+
+ public XArray getArray(int i) throws SQLException
+ {
+ return m_row.getArray(i);
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/Forms/SalesFilter.java b/odk/examples/DevelopersGuide/Forms/SalesFilter.java
new file mode 100644
index 000000000..753135bd3
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Forms/SalesFilter.java
@@ -0,0 +1,510 @@
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+import com.sun.star.uno.*;
+import com.sun.star.beans.*;
+import com.sun.star.form.*;
+import com.sun.star.lang.*;
+import com.sun.star.awt.*;
+
+import java.util.Calendar;
+import java.util.GregorianCalendar;
+
+/**************************************************************************/
+/** helper class for filtering the sales form
+*/
+class SalesFilter implements XActionListener, XPropertyChangeListener, XResetListener
+{
+ private DocumentHelper m_aDocument;
+ private XPropertySet m_xSalesForm;
+
+ private XPropertySet m_xFilterList;
+ private XPropertySet m_xManualFilter;
+ private XPropertySet m_xApplyFilter;
+
+ private boolean m_bSettingsDirty;
+ private boolean m_bSettingDate;
+ private boolean m_bAdjustingFilterList;
+ private short m_nPreviousFilterIndex;
+ private java.util.ArrayList m_aFilterDates;
+
+ /* ------------------------------------------------------------------ */
+ public SalesFilter( DocumentHelper aDocument, XPropertySet xSalesForm,
+ XPropertySet xFilterListBox, XPropertySet xManualFilterEdit, XPropertySet xStartFilterButton )
+ {
+ m_aFilterDates = new java.util.ArrayList();
+ m_bSettingsDirty = false;
+ m_bSettingDate = false;
+ m_bAdjustingFilterList = false;
+ m_nPreviousFilterIndex = -1;
+ initFilterDates();
+
+
+ // remember the components
+ m_aDocument = aDocument;
+ m_xSalesForm = xSalesForm;
+
+ m_xFilterList = xFilterListBox;
+ m_xManualFilter = xManualFilterEdit;
+ m_xApplyFilter = xStartFilterButton;
+
+ try
+ {
+
+ // init control models
+ m_xFilterList.setPropertyValue( "Dropdown", Boolean.TRUE );
+ m_xFilterList.setPropertyValue( "LineCount", Short.valueOf( (short)11 ) );
+ m_xFilterList.setPropertyValue( "StringItemList", new String[] { "ever (means no filter)", "this morning", "1 week ago", "1 month ago", "1 year ago", "<other>" } );
+ m_xFilterList.setPropertyValue( "DefaultSelection", new short[] { (short)0 } );
+
+ m_xApplyFilter.setPropertyValue( "Label", "Apply Filter" );
+
+ updateFilterControl();
+ updateApplyButton();
+
+
+ // add as listener to the events which require action
+
+ // want to know about changed selection
+ m_xFilterList.addPropertyChangeListener( "SelectedItems", this );
+ m_xManualFilter.addPropertyChangeListener( "Date", this );
+
+ // want to know about the date field being reset
+ XReset xReset = UNO.queryReset( m_xManualFilter );
+ xReset.addResetListener( this );
+
+ // for the button, we can add to the control only, not to the model
+ // - clicking a button is something which happens on the _control_.
+ DocumentViewHelper aView = m_aDocument.getCurrentView();
+ XButton xButton = aView.getFormControl( m_xApplyFilter, XButton.class );
+ xButton.addActionListener( this );
+ }
+ catch ( com.sun.star.uno.Exception e )
+ {
+ System.out.println(e);
+ e.printStackTrace();
+ }
+ }
+
+ /* ==================================================================
+ = helper
+ ================================================================== */
+ /* ------------------------------------------------------------------ */
+ private void initFilterDates()
+ {
+ m_aFilterDates.clear();
+ java.util.Date aNowAndHere = new java.util.Date();
+ aNowAndHere.setHours( 0 );
+ aNowAndHere.setMinutes( 0 );
+ aNowAndHere.setSeconds( 0 );
+
+ // for every list entry, we add a java.util.Date to m_aFilterDates indicating
+ // since when the sales should be listed
+
+ // ever
+ m_aFilterDates.add( null );
+
+ // this morning
+ m_aFilterDates.add( aNowAndHere );
+
+ // one week ago
+ GregorianCalendar aCalendar = new GregorianCalendar( );
+ aCalendar.setTime( aNowAndHere );
+ aCalendar.add( Calendar.DATE, -7 );
+ m_aFilterDates.add( aCalendar.getTime() );
+
+ // one month ago
+ aCalendar.setTime( aNowAndHere );
+ aCalendar.add( Calendar.MONTH, -1 );
+ m_aFilterDates.add( aCalendar.getTime() );
+
+ // one year ago
+ aCalendar.setTime( aNowAndHere );
+ aCalendar.add( Calendar.YEAR, -1 );
+ m_aFilterDates.add( aCalendar.getTime() );
+
+ // the custom date
+ m_aFilterDates.add( null );
+ }
+
+ /* ------------------------------------------------------------------ */
+ /** translates a date from the AWT Toolkit format to a java.util.date, or
+ vice versa.
+ */
+ private Object translateDate( Object aDate ) throws java.lang.Exception
+ {
+ Object aReturn = null;
+
+ GregorianCalendar aCalDate = new GregorianCalendar();
+ if ( aDate.getClass().equals( Class.forName( "java.util.Date" ) ) )
+ {
+ aCalDate.setTime( (java.util.Date)aDate );
+
+ int nDate = aCalDate.get( Calendar.YEAR );
+ nDate = nDate * 100 + aCalDate.get( Calendar.MONTH ) + 1;
+ nDate = nDate * 100 + aCalDate.get( Calendar.DAY_OF_MONTH );
+
+ aReturn = Integer.valueOf( nDate );
+ }
+ else if ( aDate.getClass().equals( Class.forName( "java.lang.Integer" ) ) )
+ {
+ int nToolkitDate = ((Integer)aDate).intValue();
+ aCalDate.set( Calendar.DAY_OF_MONTH, ( nToolkitDate % 100 ) );
+ nToolkitDate /= 100;
+ aCalDate.set( Calendar.MONTH, ( nToolkitDate % 100 ) - 1 );
+ nToolkitDate /= 100;
+ aCalDate.set( Calendar.YEAR, ( nToolkitDate % 10000 ) );
+
+ // default the time
+ aCalDate.set( Calendar.HOUR_OF_DAY, 0 );
+ aCalDate.set( Calendar.MINUTE, 0 );
+ aCalDate.set( Calendar.SECOND, 0 );
+
+ aReturn = aCalDate.getTime();
+ }
+
+ return aReturn;
+ }
+
+ /* ------------------------------------------------------------------ */
+ /** translates the given date into the ODBC date notation, which then can be used
+ for setting a filter at a row set
+ */
+ private String getOdbcDate( Object aDate ) throws java.lang.Exception
+ {
+ String sOdbcDate = "";
+ if ( null != aDate )
+ {
+ if ( !aDate.getClass().equals( Class.forName( "java.util.Date" ) ) )
+ aDate = translateDate( aDate );
+
+ if ( aDate.getClass().equals( Class.forName( "java.util.Date" ) ) )
+ {
+ GregorianCalendar aCal = new GregorianCalendar();
+ aCal.setTime( (java.util.Date)aDate );
+
+ sOdbcDate += "{D '";
+ sOdbcDate += (Integer.valueOf( aCal.get( Calendar.YEAR ) ) ).toString();
+ sOdbcDate += "-";
+
+ int nMonth = aCal.get( Calendar.MONTH ) + 1;
+ if ( nMonth < 10 )
+ sOdbcDate += "0";
+ sOdbcDate += (Integer.valueOf( nMonth ) ).toString();
+ sOdbcDate += "-";
+
+ int nDay = aCal.get( Calendar.DAY_OF_MONTH );
+ if ( nDay < 10 )
+ sOdbcDate += "0";
+ sOdbcDate += (Integer.valueOf( nDay ) ).toString();
+ sOdbcDate += "'}";
+ }
+ }
+ return sOdbcDate;
+ }
+
+ /* ------------------------------------------------------------------ */
+ private void updateApplyButton()
+ {
+ try
+ {
+ m_xApplyFilter.setPropertyValue( "Enabled", Boolean.valueOf( m_bSettingsDirty ) );
+ }
+ catch ( com.sun.star.uno.Exception e )
+ {
+ System.out.println(e);
+ e.printStackTrace();
+ }
+ }
+
+ /* ------------------------------------------------------------------ */
+ /** creates a normalized calendar object from the given java.util.Date
+ */
+ private GregorianCalendar getCalendarObject( java.util.Date aDate )
+ {
+ // the date part
+ GregorianCalendar aReturn = null;
+ if ( null != aDate )
+ {
+ aReturn = new GregorianCalendar( );
+ aReturn.setTime( aDate );
+
+ // normalize the time part
+ aReturn.set( Calendar.HOUR_OF_DAY, 0 );
+ aReturn.set( Calendar.MINUTE, 0 );
+ aReturn.set( Calendar.SECOND, 0 );
+ }
+
+ return aReturn;
+ }
+
+ /* ------------------------------------------------------------------ */
+ final private short getCurrentSelectedFilter( ) throws com.sun.star.uno.Exception
+ {
+ short[] aSelected = (short[])m_xFilterList.getPropertyValue( "SelectedItems" );
+ if ( 0 < aSelected.length )
+ return aSelected[0];
+ return -1;
+ }
+
+ /* ------------------------------------------------------------------ */
+ /** checks if the given filter index refers to the "<other>" entry which
+ allows the user to manually enter a date
+ */
+ final private boolean isManualFilter( short nFilterIndex )
+ {
+ return ( 5 == nFilterIndex );
+ }
+
+ /* ------------------------------------------------------------------ */
+ private void updateFilterControl()
+ {
+ try
+ {
+ if ( isManualFilter( m_nPreviousFilterIndex ) )
+ { // previously, the "custom" filter date was selected
+ // -> remember the date entered
+ Object aDate = translateDate( m_xManualFilter.getPropertyValue( "Date" ) );
+ m_aFilterDates.set( m_nPreviousFilterIndex, aDate );
+ }
+
+ // check the current selection
+ if ( !m_bAdjustingFilterList )
+ {
+ m_nPreviousFilterIndex = getCurrentSelectedFilter( );
+
+ // custom filter?
+ boolean bCustomFilter = isManualFilter( m_nPreviousFilterIndex );
+ m_xManualFilter.setPropertyValue( "Enabled", Boolean.valueOf( bCustomFilter ) );
+ if ( bCustomFilter )
+ m_aDocument.getCurrentView().grabControlFocus( m_xManualFilter );
+
+ m_bSettingDate = true;
+ Object aSelectedDateLimit = m_aFilterDates.get( m_nPreviousFilterIndex );
+ if ( null != aSelectedDateLimit )
+ {
+ // translate this date into one the AWT Toolkit understands
+ Integer aTKDate = (Integer)translateDate( aSelectedDateLimit );
+ m_xManualFilter.setPropertyValue( "Date", aTKDate );
+ }
+ else
+ m_xManualFilter.setPropertyValue( "Date", new Any( new Type(), null ) );
+ m_bSettingDate = false;
+ }
+ }
+ catch ( java.lang.Exception e )
+ {
+ System.out.println(e);
+ e.printStackTrace();
+ }
+ }
+
+ /* ------------------------------------------------------------------ */
+ /** compares the date part of two calendars
+ <p>For some strange reason I do not understand, GregorianCalendar.equals( GregorianCalendar )
+ seems to always return false, as well as . Thus here is a method which compare two calendars,
+ restricted to their date part</p>
+ */
+ private boolean equalDate( Calendar aLHS, Calendar aRHS )
+ {
+ if ( ( null == aLHS ) != ( null == aRHS ) )
+ // only one of them is null
+ return false;
+
+ if ( null == aLHS )
+ // both are null
+ return true;
+
+ return ( aLHS.get( Calendar.YEAR ) == aRHS.get( Calendar.YEAR ) )
+ && ( aLHS.get( Calendar.MONTH ) == aRHS.get( Calendar.MONTH ) )
+ && ( aLHS.get( Calendar.DAY_OF_MONTH ) == aRHS.get( Calendar.DAY_OF_MONTH ) );
+ }
+
+ /* ------------------------------------------------------------------ */
+ /** adds the current user filter to the list of date filters
+ @return
+ the index of the newly added date filter in the filter list
+ */
+ private short addCurrentFilter( ) throws java.lang.Exception
+ {
+ // the current string items
+ String[] aOldFilterItems = (String[])m_xFilterList.getPropertyValue( "StringItemList" );
+
+ // translate this into a vector - much more comfort to work with a vector than with an array...
+ java.util.ArrayList aFilterItems = new java.util.ArrayList();
+ for ( int i=0; i<aOldFilterItems.length; ++i )
+ aFilterItems.add( aOldFilterItems[i] );
+
+ // the currently entered user defined filter date
+ Object aDate = translateDate( m_xManualFilter.getPropertyValue( "Date" ) );
+ GregorianCalendar aDateCal = getCalendarObject( (java.util.Date)aDate );
+ // check if this date is already present in the list of user defined dates
+ for ( int i=0; i<m_aFilterDates.size(); ++i )
+ {
+ if ( !isManualFilter( (short)i ) ) // do not compare with the manual filter
+ {
+ GregorianCalendar aCheckCal = getCalendarObject( (java.util.Date)m_aFilterDates.get( i ) );
+ if ( equalDate( aDateCal, aCheckCal ) )
+ return (short)i;
+ }
+ }
+ System.out.println( );
+
+ if ( aFilterItems.size() > 10 ) // (6 standard items + 5 user defined items)
+ {
+ // the first (and thus oldest) user defined item
+ aFilterItems.remove( 6 );
+ // keep our date vector synchron
+ m_aFilterDates.remove( 6 );
+ }
+
+ // add the current user defined filter
+ aFilterItems.add( aDate.toString() );
+ m_aFilterDates.add( aDate );
+
+ // write back the string item list
+ m_bAdjustingFilterList = true;
+ String[] aNewFilterItems = new String[ aFilterItems.size() ];
+ for ( int i=0; i<aFilterItems.size(); ++i )
+ aNewFilterItems[i] = (String)aFilterItems.get( i );
+ m_xFilterList.setPropertyValue( "StringItemList", aNewFilterItems );
+ m_bAdjustingFilterList = false;
+
+ return (short)(aNewFilterItems.length - 1 );
+ }
+
+ /* ------------------------------------------------------------------ */
+ private void executeCurrentFilter()
+ {
+ try
+ {
+ // we keep the date field consistent with whatever the user chooses in the
+ // list box, so just ask the field
+ Object aDate = translateDate( m_xManualFilter.getPropertyValue( "Date" ) );
+ String sOdbcDate = getOdbcDate( aDate );
+
+ // if this filter was a manually entered filter, we add it to the filter list
+ // box to allow quick-select it later on.
+ if ( isManualFilter( getCurrentSelectedFilter() ) )
+ {
+ short nNewUserDefinedFilterPos = addCurrentFilter();
+ m_xFilterList.setPropertyValue( "SelectedItems", new short[] { nNewUserDefinedFilterPos } );
+ }
+
+ // set this as filter on the form
+ String sCompleteFilter = "";
+ if ( ( null != sOdbcDate ) && ( 0 != sOdbcDate.length() ) )
+ {
+ sCompleteFilter = "SALEDATE >= ";
+ sCompleteFilter += sOdbcDate;
+ }
+ m_xSalesForm.setPropertyValue( "Filter", sCompleteFilter );
+ m_xSalesForm.setPropertyValue( "ApplyFilter", Boolean.TRUE );
+
+ // and reload the form
+ XLoadable xLoad = UnoRuntime.queryInterface(
+ XLoadable.class, m_xSalesForm );
+ xLoad.reload();
+
+ m_aDocument.getCurrentView().grabControlFocus( m_xFilterList );
+ }
+ catch ( java.lang.Exception e )
+ {
+ System.out.println(e);
+ e.printStackTrace();
+ }
+ }
+
+ /* ==================================================================
+ = UNO callbacks
+ ================================================================== */
+ /* ------------------------------------------------------------------ */
+ // XActionListener overridables
+ /* ------------------------------------------------------------------ */
+ public boolean approveReset( EventObject aEvent ) throws com.sun.star.uno.RuntimeException
+ {
+ return false;
+ // do not allow the date field to be reset - it would set its content
+ // to the current date
+ // Note that another possible solution would be to wait for the reset
+ // event and correct the value there
+ }
+
+ /* ------------------------------------------------------------------ */
+ public void resetted( EventObject aEvent ) throws com.sun.star.uno.RuntimeException
+ {
+ }
+
+ /* ------------------------------------------------------------------ */
+ // XActionListener overridables
+ /* ------------------------------------------------------------------ */
+ public void actionPerformed( ActionEvent aEvent ) throws com.sun.star.uno.RuntimeException
+ {
+ executeCurrentFilter();
+
+ m_bSettingsDirty = false;
+ updateApplyButton();
+ }
+
+ /* ------------------------------------------------------------------ */
+ // XItemListener overridables
+ /* ------------------------------------------------------------------ */
+ public void propertyChange( PropertyChangeEvent aEvent ) throws com.sun.star.uno.RuntimeException
+ {
+ if ( aEvent.PropertyName.equals( "SelectedItems" ) )
+ {
+ updateFilterControl();
+
+ m_bSettingsDirty = true;
+ updateApplyButton();
+ }
+ else if ( aEvent.PropertyName.equals( "Date" ) && !m_bSettingDate )
+ {
+ m_bSettingsDirty = true;
+ updateApplyButton();
+ }
+ }
+
+ /* ------------------------------------------------------------------ */
+ // XEventListener overridables
+ /* ------------------------------------------------------------------ */
+ public void disposing( EventObject aEvent )
+ {
+ // not interested in
+ }
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/Forms/SingleControlValidation.java b/odk/examples/DevelopersGuide/Forms/SingleControlValidation.java
new file mode 100644
index 000000000..719670031
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Forms/SingleControlValidation.java
@@ -0,0 +1,171 @@
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+import com.sun.star.uno.*;
+import com.sun.star.beans.*;
+import com.sun.star.form.validation.*;
+
+public class SingleControlValidation implements XFormComponentValidityListener
+{
+ private DocumentHelper m_document; /// our current test document
+ private FormLayer m_formLayer; /// quick access to the form layer
+
+ private XPropertySet m_inputField;
+ private XPropertySet m_inputLabel;
+ private XPropertySet m_statusField;
+ private XPropertySet m_explanationField;
+ private XValidator m_validator;
+
+ /* ------------------------------------------------------------------ */
+ public SingleControlValidation( DocumentHelper document, int columnPos, int rowPos, String formComponentService, XValidator validator )
+ {
+ m_document = document;
+ m_validator = validator;
+ m_formLayer = new FormLayer( m_document );
+ createControls( columnPos, rowPos, formComponentService, 1, 0 );
+ }
+
+ /* ------------------------------------------------------------------ */
+ public SingleControlValidation( DocumentHelper document, int columnPos, int rowPos, String formComponentService, XValidator validator, int controlCount, int controlHeight )
+ {
+ m_document = document;
+ m_validator = validator;
+ m_formLayer = new FormLayer( m_document );
+ createControls( columnPos, rowPos, formComponentService, controlCount, controlHeight );
+ }
+
+ /* ------------------------------------------------------------------ */
+ public XPropertySet getInputField()
+ {
+ return m_inputField;
+ }
+
+ /* ------------------------------------------------------------------ */
+ public void setExplanatoryText( String text )
+ {
+ try
+ {
+ m_inputLabel.setPropertyValue( "Label", text );
+ }
+ catch( com.sun.star.uno.Exception e )
+ {
+ e.printStackTrace( System.err );
+ }
+ }
+
+ /* ------------------------------------------------------------------ */
+ private void createControls( int columnPos, int rowPos, String formComponentService, int controlCount, int controlHeight )
+ {
+ try
+ {
+ m_inputLabel = m_formLayer.createControlAndShape( "FixedText", columnPos, rowPos, 70, 12, null );
+ m_inputLabel.setPropertyValue( "MultiLine", Boolean.TRUE );
+
+ com.sun.star.awt.FontDescriptor font = (com.sun.star.awt.FontDescriptor)m_inputLabel.getPropertyValue( "FontDescriptor" );
+ font.Weight = com.sun.star.awt.FontWeight.BOLD;
+ m_inputLabel.setPropertyValue( "FontDescriptor", font );
+
+ if ( controlHeight == 0 )
+ controlHeight = 6;
+
+ int controlPos = rowPos + 12;
+ XPropertySet[] controls = new XPropertySet[ controlCount ];
+ for ( int i = 0; i < controlCount; ++i, controlPos += controlHeight )
+ {
+ controls[ i ] = m_formLayer.createControlAndShape( formComponentService, columnPos, controlPos, 25, controlHeight, null );
+ controls[ i ].setPropertyValue( "Name", formComponentService );
+ controls[ i ].setPropertyValue( "Tag", String.valueOf( i ) );
+
+ if ( controls[ i ].getPropertySetInfo().hasPropertyByName( "Border" ) )
+ controls[ i ].setPropertyValue( "Border", Short.valueOf( (short)2 ) );
+
+ XValidatableFormComponent xComp = UnoRuntime.queryInterface( XValidatableFormComponent.class,
+ controls[ i ] );
+ xComp.addFormComponentValidityListener( this );
+ }
+ m_inputField = controls[ 0 ];
+
+
+ controlPos += 4;
+ XPropertySet xLabel = m_formLayer.createControlAndShape( "FixedText", columnPos, controlPos, 70, 4, null );
+ xLabel.setPropertyValue( "Label", "Status:" );
+ controlPos += 4;
+ m_statusField = m_formLayer.createControlAndShape( "FixedText", columnPos, controlPos, 70, 4, null );
+ m_statusField.setPropertyValue( "Label", "" );
+
+
+ controlPos += 6;
+ xLabel = m_formLayer.createControlAndShape( "FixedText", columnPos, controlPos, 70, 4, null );
+ xLabel.setPropertyValue( "Label", "Explanation for invalidity:" );
+ controlPos += 4;
+ m_explanationField = m_formLayer.createControlAndShape( "FixedText", columnPos, controlPos, 70, 4, null );
+ m_explanationField.setPropertyValue( "Label", "" );
+
+ XValidatable xValidatable = UnoRuntime.queryInterface( XValidatable.class, m_inputField );
+ xValidatable.setValidator( m_validator );
+ }
+ catch( java.lang.Exception e )
+ {
+ e.printStackTrace( System.err );
+ }
+ }
+
+ /* ------------------------------------------------------------------ */
+ /* XEventListener overridables */
+ /* ------------------------------------------------------------------ */
+ public void disposing( com.sun.star.lang.EventObject eventObject )
+ {
+ // not interested in
+ }
+
+ /* ------------------------------------------------------------------ */
+ /* XFormComponentValidityListener overridables */
+ /* ------------------------------------------------------------------ */
+ public void componentValidityChanged( com.sun.star.lang.EventObject eventObject )
+ {
+ try
+ {
+ if ( m_inputField.equals( eventObject.Source ) )
+ {
+ XValidatableFormComponent xComp = UnoRuntime.queryInterface( XValidatableFormComponent.class,
+ eventObject.Source );
+ // the current value
+ Object value = xComp.getCurrentValue();
+
+ // the current validity flag
+ boolean isValid = xComp.isValid();
+
+ m_statusField.setPropertyValue("Label", isValid ? "valid" : "invalid" );
+ m_statusField.setPropertyValue( "TextColor", Integer.valueOf( isValid ? 0x008000 : 0x800000 ) );
+
+ String validityMessage = "";
+ if ( !isValid )
+ validityMessage = m_validator.explainInvalid( value );
+ m_explanationField.setPropertyValue( "Label", validityMessage );
+ }
+ }
+ catch( com.sun.star.uno.Exception e )
+ {
+ e.printStackTrace( System.err );
+ }
+ }
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/Forms/SpreadsheetDocument.java b/odk/examples/DevelopersGuide/Forms/SpreadsheetDocument.java
new file mode 100644
index 000000000..b227b2d5f
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Forms/SpreadsheetDocument.java
@@ -0,0 +1,120 @@
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+import com.sun.star.uno.*;
+import com.sun.star.lang.XComponent;
+import com.sun.star.table.XCellRange;
+import com.sun.star.table.CellAddress;
+import com.sun.star.table.CellRangeAddress;
+import com.sun.star.container.XIndexAccess;
+import com.sun.star.sheet.XSpreadsheetDocument;
+import com.sun.star.beans.NamedValue;
+
+public class SpreadsheetDocument extends DocumentHelper
+{
+ /** Creates a new blank spreadsheet document */
+ public SpreadsheetDocument( XComponentContext xCtx ) throws com.sun.star.uno.Exception
+ {
+ super( xCtx, implCreateBlankDocument( xCtx, "private:factory/scalc" ) );
+ }
+
+ public SpreadsheetDocument( XComponentContext xCtx, XComponent document )
+ {
+ super( xCtx, document );
+ }
+
+ public XCellRange getSheet( int index ) throws com.sun.star.uno.Exception
+ {
+ XSpreadsheetDocument spreadsheetDoc = UnoRuntime.queryInterface( XSpreadsheetDocument.class,
+ m_documentComponent
+ );
+ XIndexAccess sheets = UnoRuntime.queryInterface( XIndexAccess.class,
+ spreadsheetDoc.getSheets()
+ );
+ return UnoRuntime.queryInterface( XCellRange.class,
+ sheets.getByIndex( index )
+ );
+ }
+
+ /** creates a value binding for a given cell
+ */
+ public com.sun.star.form.binding.XValueBinding createCellBinding( short sheet, short column, short row )
+ {
+ return createCellBinding( sheet, column, row, false );
+ }
+
+ /** creates a value binding which can be used to exchange a list box selection <em>index</em> with a cell
+ */
+ public com.sun.star.form.binding.XValueBinding createListIndexBinding( short sheet, short column, short row )
+ {
+ return createCellBinding( sheet, column, row, true );
+ }
+
+ /** creates a value binding for a given cell, with or without support for integer value exchange
+ */
+ private com.sun.star.form.binding.XValueBinding createCellBinding( short sheet, short column, short row, boolean supportIntegerValues )
+ {
+ com.sun.star.form.binding.XValueBinding cellBinding = null;
+ try
+ {
+ CellAddress address = new CellAddress( sheet, column, row );
+ Object[] initParam = new Object[] { new NamedValue( "BoundCell", address ) };
+ cellBinding = UnoRuntime.queryInterface(
+ com.sun.star.form.binding.XValueBinding.class,
+ createInstanceWithArguments(
+ supportIntegerValues ? "com.sun.star.table.ListPositionCellBinding"
+ : "com.sun.star.table.CellValueBinding",
+ initParam
+ )
+ );
+ }
+ catch( com.sun.star.uno.Exception e )
+ {
+ System.err.println( e );
+ e.printStackTrace( System.err );
+ }
+ return cellBinding;
+ }
+
+ /** creates a source of list entries associated with a (one-column) cell range
+ */
+ public com.sun.star.form.binding.XListEntrySource createListEntrySource( short sheet, short column,
+ short topRow, short bottomRow )
+ {
+ com.sun.star.form.binding.XListEntrySource entrySource = null;
+ try
+ {
+ CellRangeAddress rangeAddress = new CellRangeAddress( sheet, column,
+ topRow, column, bottomRow );
+ Object[] initParam = new Object[] { new NamedValue( "CellRange", rangeAddress ) };
+ entrySource = UnoRuntime.queryInterface(
+ com.sun.star.form.binding.XListEntrySource.class,
+ createInstanceWithArguments(
+ "com.sun.star.table.CellRangeListSource", initParam ) );
+ }
+ catch( com.sun.star.uno.Exception e )
+ {
+ System.err.println( e );
+ e.printStackTrace( System.err );
+ }
+ return entrySource;
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/Forms/SpreadsheetValueBinding.java b/odk/examples/DevelopersGuide/Forms/SpreadsheetValueBinding.java
new file mode 100644
index 000000000..1f08f2e7e
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Forms/SpreadsheetValueBinding.java
@@ -0,0 +1,125 @@
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+import com.sun.star.uno.UnoRuntime;
+
+import com.sun.star.beans.XPropertySet;
+import com.sun.star.table.XCellRange;
+import com.sun.star.text.XTextRange;
+import com.sun.star.form.binding.XValueBinding;
+import com.sun.star.form.binding.XBindableValue;
+import com.sun.star.form.binding.XListEntrySource;
+import com.sun.star.form.binding.XListEntrySink;
+
+public class SpreadsheetValueBinding extends DocumentBasedExample
+{
+ /** Creates a new instance of SpreadsheetValueBinding */
+ public SpreadsheetValueBinding()
+ {
+ super( DocumentType.CALC );
+ }
+
+ /* ------------------------------------------------------------------ */
+ @Override
+ protected void prepareDocument() throws com.sun.star.uno.Exception, java.lang.Exception
+ {
+ super.prepareDocument();
+
+ SpreadsheetDocument document = (SpreadsheetDocument)m_document;
+
+ final short sheet = (short)0;
+ final short exchangeColumn = (short)1; // B
+ final short exchangeRow = (short)1; // 2
+ final Integer backColor = Integer.valueOf( 0x00E0E0E0 );
+
+
+ // a numeric control
+ XPropertySet numericControl = m_formLayer.insertControlLine( "NumericField",
+ "enter a value", "", 30 );
+ numericControl.setPropertyValue( "ValueMin", Short.valueOf( (short)1 ) );
+ numericControl.setPropertyValue( "ValueMax", Short.valueOf( (short)5 ) );
+ numericControl.setPropertyValue( "Value", Short.valueOf( (short)1 ) );
+ numericControl.setPropertyValue( "DecimalAccuracy", Short.valueOf( (short)0 ) );
+ numericControl.setPropertyValue( "Spin", Boolean.TRUE );
+
+ // bind the control model to cell B2
+ implBind( numericControl, document.createCellBinding( sheet, exchangeColumn, exchangeRow ) );
+
+
+ // insert a list box
+ XPropertySet listBox = m_formLayer.insertControlLine( "ListBox",
+ "select an entry", "", 2, 40, 20 );
+ listBox.setPropertyValue( "Dropdown", Boolean.FALSE );
+
+ // a list binding for cell range C1-C5
+ final short listSourceSheet = (short)1;
+ final short column = (short)0;
+ final short topRow = (short)0;
+ final short bottomRow = (short)4;
+ XListEntrySource entrySource = document.createListEntrySource(
+ listSourceSheet, column, topRow, bottomRow );
+
+ // bind it to the list box
+ XListEntrySink consumer = UnoRuntime.queryInterface(
+ XListEntrySink.class, listBox );
+ consumer.setListEntrySource( entrySource );
+
+ // and also put the list selection index into cell B2
+ implBind( listBox, document.createListIndexBinding( sheet, exchangeColumn, exchangeRow ) );
+
+
+ // fill the cells which we just bound the listbox to
+ XCellRange exchangeSheet = document.getSheet( listSourceSheet );
+ String[] listContent = new String[] { "first", "second", "third", "forth", "fivth" };
+ for ( short row = topRow; row <= bottomRow; ++row )
+ {
+ XTextRange cellText = UnoRuntime.queryInterface(
+ XTextRange.class, exchangeSheet.getCellByPosition( column, row ) );
+ cellText.setString( listContent[row] );
+ }
+
+ // some coloring
+ XPropertySet exchangeCell = UNO.queryPropertySet(
+ document.getSheet( sheet ).getCellByPosition( exchangeColumn, exchangeRow )
+ );
+ exchangeCell.setPropertyValue( "CellBackColor", backColor );
+ numericControl.setPropertyValue( "BackgroundColor", backColor );
+ listBox.setPropertyValue( "BackgroundColor", backColor );
+ }
+
+ /* ------------------------------------------------------------------ */
+ private void implBind( XPropertySet controlModel, XValueBinding binding ) throws com.sun.star.form.binding.IncompatibleTypesException
+ {
+ XBindableValue bindable = UnoRuntime.queryInterface(
+ XBindableValue.class, controlModel
+ );
+ bindable.setValueBinding( binding );
+ }
+
+ /* ------------------------------------------------------------------ */
+ /** class entry point
+ */
+ public static void main(String argv[]) throws java.lang.Exception
+ {
+ SpreadsheetValueBinding aSample = new SpreadsheetValueBinding();
+ aSample.run( argv );
+ }
+ }
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/Forms/SpreadsheetView.java b/odk/examples/DevelopersGuide/Forms/SpreadsheetView.java
new file mode 100644
index 000000000..63a8e6a98
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Forms/SpreadsheetView.java
@@ -0,0 +1,35 @@
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+import com.sun.star.lang.*;
+import com.sun.star.frame.*;
+
+public class SpreadsheetView extends DocumentViewHelper
+{
+
+ /** Creates a new instance of SpreadsheetView */
+ public SpreadsheetView( XMultiServiceFactory orb, DocumentHelper document, XController controller )
+ {
+ super( orb, document, controller );
+ }
+
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/Forms/TableCellTextBinding.java b/odk/examples/DevelopersGuide/Forms/TableCellTextBinding.java
new file mode 100644
index 000000000..23a9e4226
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Forms/TableCellTextBinding.java
@@ -0,0 +1,199 @@
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+import com.sun.star.uno.Type;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.table.XCell;
+import com.sun.star.util.XModifyListener;
+import com.sun.star.text.XTextRange;
+
+/** a value binding to be connected to a form control
+
+ This binding synchronizes the text contained in a table cell (which you must
+ pass upon construction) to the text in an XBindableValue.
+
+ Well, in real it does not synchronize both directions. The ValueBinding
+ service has not much room for own activity: It allows notification of changes
+ in the own value, and it allows external instances to set the current value.
+
+ Note that we implement this binding as a separate thread, which is (more or
+ less permanently) polling for a new text at the cell. This is unfortunate, but
+ sadly the Writer table cells do not support actively notifying changes in their
+ content to other interested parties.
+*/
+public class TableCellTextBinding
+ extends java.lang.Thread
+ implements com.sun.star.form.binding.XValueBinding,
+ com.sun.star.util.XModifyBroadcaster
+{
+ private XTextRange m_cellText;
+ private Object m_writeSignal;
+ private String m_newCellText;
+ private String m_lastKnownCellText;
+ private boolean m_haveNewCellText;
+ private java.util.List<XModifyListener> m_listeners;
+
+ /** Creates a new instance of TableCellTextBinding */
+ public TableCellTextBinding( XCell cell )
+ {
+ m_cellText = UnoRuntime.queryInterface( XTextRange.class, cell );
+
+ m_newCellText = "";
+ m_listeners = new java.util.LinkedList<XModifyListener>();
+
+ start();
+ }
+
+ /** retrieves the list of data types which this binding can exchange
+ */
+ public com.sun.star.uno.Type[] getSupportedValueTypes()
+ {
+ try
+ {
+ // well, only strings here ...
+ return new Type[] {
+ getStringType()
+ };
+ }
+ catch( java.lang.Exception e )
+ {
+ }
+ return new Type[] { };
+ }
+
+ /** retrieves the current value
+ */
+ public Object getValue(com.sun.star.uno.Type type) throws com.sun.star.form.binding.IncompatibleTypesException
+ {
+ if ( !type.equals( getStringType() ) )
+ throw new com.sun.star.form.binding.IncompatibleTypesException();
+
+ return m_cellText.getString();
+ }
+
+ /** sets a new value
+ */
+ public void setValue(Object obj) throws com.sun.star.form.binding.IncompatibleTypesException
+ {
+ String text;
+ try
+ {
+ text = (String)obj;
+ }
+ catch( java.lang.ClassCastException e )
+ {
+ throw new com.sun.star.form.binding.IncompatibleTypesException();
+ }
+ // remember the new text
+ synchronized( m_newCellText )
+ {
+ m_newCellText = text;
+ m_haveNewCellText = true;
+ }
+ // and wake up the thread which is waiting for it
+ synchronized( m_writeSignal )
+ {
+ m_writeSignal.notify();
+ }
+ }
+
+ /** determines whether a given value type is supported
+ */
+ public boolean supportsType(com.sun.star.uno.Type type)
+ {
+ return type.equals( getStringType() );
+ }
+
+ /** retrieves the UNO type for the string class
+ */
+ private static final Type getStringType()
+ {
+ return new com.sun.star.uno.Type( String.class );
+ }
+
+ /** runs the thread
+ */
+ @Override
+ public void run()
+ {
+ try
+ {
+ m_writeSignal = new Object();
+ while ( true )
+ {
+ // go sleep a while
+ synchronized( m_writeSignal )
+ {
+ m_writeSignal.wait( 200 );
+ }
+
+ // if there's new text in the control, propagate it to the cell
+ synchronized ( m_newCellText )
+ {
+ if ( m_haveNewCellText )
+ {
+ m_cellText.setString( m_newCellText );
+ m_lastKnownCellText = m_newCellText;
+ }
+ m_haveNewCellText = false;
+ }
+
+ // if there's new text in the cell, propagate it to the control
+ String currentCellText = m_cellText.getString();
+ if ( !currentCellText.equals( m_lastKnownCellText ) )
+ {
+ m_lastKnownCellText = currentCellText;
+ // notify the modification
+ synchronized( m_listeners )
+ {
+ com.sun.star.lang.EventObject eventSource = new com.sun.star.lang.EventObject( this );
+
+ java.util.Iterator<XModifyListener> loop = m_listeners.iterator();
+ while ( loop.hasNext() )
+ {
+ loop.next().modified( eventSource );
+ }
+ }
+ }
+ }
+ }
+ catch( java.lang.Exception e )
+ {
+ e.printStackTrace(System.err);
+ }
+ }
+
+ public void addModifyListener(com.sun.star.util.XModifyListener xModifyListener)
+ {
+ synchronized( m_listeners )
+ {
+ m_listeners.add( xModifyListener );
+ }
+ }
+
+ public void removeModifyListener(com.sun.star.util.XModifyListener xModifyListener)
+ {
+ synchronized( m_listeners )
+ {
+ m_listeners.remove( xModifyListener );
+ }
+ }
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/Forms/TextValidator.java b/odk/examples/DevelopersGuide/Forms/TextValidator.java
new file mode 100644
index 000000000..241bd8778
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Forms/TextValidator.java
@@ -0,0 +1,78 @@
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+
+public class TextValidator extends ControlValidator
+{
+
+ /** Creates a new instance of NumericValidator */
+ public TextValidator( )
+ {
+ }
+
+ public String explainInvalid( Object Value )
+ {
+ try
+ {
+ String value = (String)Value;
+ if ( containsZs( value ) )
+ return "No Z's allowed here";
+ if ( !isProperChunks( value ) )
+ return "Need 3 * n characters";
+ }
+ catch( java.lang.Exception e )
+ {
+ return "ooops. Unknown error";
+ }
+ return "";
+ }
+
+ public boolean isValid( Object Value )
+ {
+ try
+ {
+ String value = (String)Value;
+ if ( containsZs( value ) )
+ return false;
+ if ( !isProperChunks( value ) )
+ return false;
+ return true;
+ }
+ catch( java.lang.Exception e )
+ {
+ }
+ return false;
+ }
+
+ private boolean isProperChunks( String value )
+ {
+ return ( value.length() % 3 ) == 0;
+ }
+
+ private boolean containsZs( String value )
+ {
+ if ( ( value.indexOf( 'Z' ) != -1 )
+ || ( value.indexOf( 'z' ) != -1 )
+ )
+ return true;
+ return false;
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/Forms/TimeValidator.java b/odk/examples/DevelopersGuide/Forms/TimeValidator.java
new file mode 100644
index 000000000..d5f1503d8
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Forms/TimeValidator.java
@@ -0,0 +1,83 @@
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+
+public class TimeValidator extends ControlValidator
+{
+
+ /** Creates a new instance of NumericValidator */
+ public TimeValidator( )
+ {
+ }
+
+ public String explainInvalid( Object Value )
+ {
+ try
+ {
+ if ( isVoid( Value ) )
+ return "empty input";
+
+ com.sun.star.util.Time timeValue = (com.sun.star.util.Time)Value;
+ if ( isInvalidTime( timeValue ) )
+ return "this is no valid time";
+ if ( !isFullHour( timeValue ) )
+ return "time must denote a full hour";
+ }
+ catch( java.lang.Exception e )
+ {
+ return "this is no valid time";
+ }
+ return "";
+ }
+
+ public boolean isValid( Object Value )
+ {
+ try
+ {
+ if ( isVoid( Value ) )
+ return false;
+
+ com.sun.star.util.Time timeValue = (com.sun.star.util.Time)
+ com.sun.star.uno.AnyConverter.toObject(
+ com.sun.star.util.Time.class, Value);
+ if ( isInvalidTime( timeValue ) )
+ return false;
+ if ( !isFullHour( timeValue ) )
+ return false;
+ return true;
+ }
+ catch( java.lang.Exception e )
+ {
+ e.printStackTrace( System.err );
+ }
+ return false;
+ }
+
+ private boolean isInvalidTime( com.sun.star.util.Time timeValue )
+ {
+ return ( timeValue.Hours == -1 ) && ( timeValue.Minutes == -1 ) && ( timeValue.Seconds == -1 ) && ( timeValue.NanoSeconds == -1 );
+ }
+
+ private boolean isFullHour( com.sun.star.util.Time timeValue )
+ {
+ return ( timeValue.Minutes == 0 ) && ( timeValue.Seconds == 0 ) && ( timeValue.NanoSeconds == 0 );
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/Forms/UNO.java b/odk/examples/DevelopersGuide/Forms/UNO.java
new file mode 100644
index 000000000..f2e6fc611
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Forms/UNO.java
@@ -0,0 +1,89 @@
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+import com.sun.star.uno.*;
+import com.sun.star.beans.*;
+import com.sun.star.awt.*;
+import com.sun.star.container.*;
+import com.sun.star.form.*;
+import com.sun.star.lang.*;
+import com.sun.star.sdb.*;
+
+public class UNO
+{
+ public static XPropertySet queryPropertySet( Object aObject )
+ {
+ return UnoRuntime.queryInterface( XPropertySet.class, aObject );
+ }
+ public static XControlModel queryControlModel( Object aObject )
+ {
+ return UnoRuntime.queryInterface( XControlModel.class, aObject );
+ }
+ public static XIndexContainer queryIndexContainer( Object aObject )
+ {
+ return UnoRuntime.queryInterface( XIndexContainer.class, aObject );
+ }
+ public static XReset queryReset( Object aObject )
+ {
+ return UnoRuntime.queryInterface( XReset.class, aObject );
+ }
+ public static XServiceInfo queryServiceInfo( Object aObject )
+ {
+ return UnoRuntime.queryInterface( XServiceInfo.class, aObject );
+ }
+ public static XColumn queryColumn( Object aObject )
+ {
+ return UnoRuntime.queryInterface( XColumn.class, aObject );
+ }
+
+ public static XComponent queryComponent( Object aObject )
+ {
+ return UnoRuntime.queryInterface( XComponent.class, aObject );
+ }
+
+
+
+/* replace Foo with the identifier of your choice.
+
+ Why does Java not have templates?
+
+ public static XFoo queryFoo( Object aObject )
+ {
+ return (XFoo)UnoRuntime.queryInterface( XFoo.class, aObject );
+ }
+*/
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/Forms/URLHelper.java b/odk/examples/DevelopersGuide/Forms/URLHelper.java
new file mode 100644
index 000000000..d1d361676
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Forms/URLHelper.java
@@ -0,0 +1,65 @@
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+import java.io.File;
+import java.net.MalformedURLException;
+
+public class URLHelper
+{
+ /**
+ * Because the office need URLs for loading/saving documents
+ * we must convert used system paths.
+ * And java use another notation for file URLs ... correct it.
+ *
+ * @param aSystemPath
+ * represent the file in system notation
+ *
+ * @return [String]
+ * a file url which represent the given system path
+ */
+ public static String getFileURLFromSystemPath( File aSystemPath )
+ {
+ String sFileURL = null;
+ try
+ {
+ sFileURL = aSystemPath.toURI().toURL().toString();
+ }
+ catch( MalformedURLException exWrong )
+ {
+ sFileURL = null;
+ }
+
+ // problem of java: file URL's are coded with 1 slash instead of 2 or 3 ones!
+ // => correct this problem first, otherwise office can't use these URL's
+ if(
+ (sFileURL != null ) &&
+ (sFileURL.startsWith("file:/") == true ) &&
+ (sFileURL.startsWith("file://") == false)
+ )
+ {
+ StringBuffer sWorkBuffer = new StringBuffer(sFileURL);
+ sWorkBuffer.insert(6,"//");
+ sFileURL = sWorkBuffer.toString();
+ }
+
+ return sFileURL;
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/Forms/ValueBinding.java b/odk/examples/DevelopersGuide/Forms/ValueBinding.java
new file mode 100644
index 000000000..273f04cda
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Forms/ValueBinding.java
@@ -0,0 +1,82 @@
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+import com.sun.star.uno.UnoRuntime;
+
+import com.sun.star.beans.XPropertySet;
+import com.sun.star.text.XTextDocument;
+import com.sun.star.text.XText;
+import com.sun.star.text.XTextTable;
+import com.sun.star.text.XTextCursor;
+import com.sun.star.form.binding.XValueBinding;
+import com.sun.star.form.binding.XBindableValue;
+
+public class ValueBinding extends DocumentBasedExample
+{
+ /** Creates a new instance of ValueBinding */
+ public ValueBinding()
+ {
+ super( DocumentType.WRITER );
+ }
+
+ /* ------------------------------------------------------------------ */
+ @Override
+ protected void prepareDocument() throws com.sun.star.uno.Exception, java.lang.Exception
+ {
+ super.prepareDocument();
+
+ // insert a table with exactly one cell. The content of this table will be synced with
+ // the content of a form control
+ XTextDocument textDoc = UnoRuntime.queryInterface( XTextDocument.class, m_document.getDocument() );
+ XText documentText = textDoc.getText();
+ XTextCursor textCursor = documentText.createTextCursor();
+ documentText.insertString( textCursor, "Below, there's a table cell, and a text field. ", false );
+ documentText.insertString( textCursor, "Both are linked via an external value binding.\n", false );
+ documentText.insertString( textCursor, "That means that anything you insert into the table cell is reflected in the ", false );
+ documentText.insertString( textCursor, "text field, and vice versa.\n", false );
+
+ XTextTable table = UnoRuntime.queryInterface( XTextTable.class,
+ m_document.createInstance( "com.sun.star.text.TextTable" )
+ );
+ table.initialize( 1, 1 );
+ documentText.insertTextContent( textCursor, table, false );
+
+ // insert our sample control
+ XPropertySet textControl = m_formLayer.insertControlLine( "DatabaseTextField", "enter some text", "", 30 );
+
+ // create a value binding for the first cell of the table
+ XValueBinding cellBinding = new TableCellTextBinding( table.getCellByName( "A1" ) );
+ // and bind it to the control
+ XBindableValue bindable = UnoRuntime.queryInterface(
+ XBindableValue.class, textControl
+ );
+ bindable.setValueBinding( cellBinding );
+ }
+
+ /* ------------------------------------------------------------------ */
+ /** class entry point
+ */
+ public static void main(String argv[]) throws java.lang.Exception
+ {
+ ValueBinding aSample = new ValueBinding();
+ aSample.run( argv );
+ }
+ }
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/Forms/WaitForInput.java b/odk/examples/DevelopersGuide/Forms/WaitForInput.java
new file mode 100644
index 000000000..e5891ada4
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Forms/WaitForInput.java
@@ -0,0 +1,58 @@
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+class WaitForInput extends java.lang.Thread
+{
+ private Object m_aToNotify;
+ private boolean m_bDone;
+
+ public WaitForInput( Object aToNotify )
+ {
+ m_aToNotify = aToNotify;
+ m_bDone = false;
+ }
+
+ public boolean isDone()
+ {
+ return m_bDone;
+ }
+
+ @Override
+ public void run()
+ {
+ try
+ {
+ System.out.println( "\npress 'enter' to exit demo" );
+ System.in.read();
+
+ m_bDone = true;
+ // notify that the user pressed the key
+ synchronized (m_aToNotify)
+ {
+ m_aToNotify.notify();
+ }
+ }
+ catch( java.lang.Exception e )
+ {
+ // not really interested in
+ System.err.println( e );
+ }
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/GUI/DialogDocument.java b/odk/examples/DevelopersGuide/GUI/DialogDocument.java
new file mode 100644
index 000000000..4b535534d
--- /dev/null
+++ b/odk/examples/DevelopersGuide/GUI/DialogDocument.java
@@ -0,0 +1,146 @@
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+import com.sun.star.awt.PushButtonType;
+import com.sun.star.awt.Rectangle;
+import com.sun.star.awt.VclWindowPeerAttribute;
+import com.sun.star.awt.WindowAttribute;
+import com.sun.star.awt.WindowClass;
+import com.sun.star.awt.XToolkit;
+import com.sun.star.awt.XView;
+import com.sun.star.awt.XWindow;
+import com.sun.star.awt.XWindowPeer;
+import com.sun.star.beans.PropertyValue;
+import com.sun.star.beans.XMultiPropertySet;
+import com.sun.star.frame.XComponentLoader;
+import com.sun.star.frame.XFrame;
+import com.sun.star.lang.XMultiComponentFactory;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.XComponentContext;
+
+
+public class DialogDocument extends UnoDialogSample {
+
+ public DialogDocument(XComponentContext _xContext, XMultiComponentFactory _xMCF) {
+ super(_xContext, _xMCF);
+ }
+
+ public static void main(String args[]){
+ DialogDocument oDialogDocument = null;
+ try {
+ XComponentContext xContext = com.sun.star.comp.helper.Bootstrap.bootstrap();
+ if(xContext != null )
+ System.out.println("Connected to a running office ...");
+ XMultiComponentFactory xMCF = xContext.getServiceManager();
+ oDialogDocument = new DialogDocument(xContext, xMCF);
+ oDialogDocument.initialize( new String[] {"Height", "Moveable", "Name","PositionX","PositionY", "Step", "TabIndex","Title","Width"},
+ new Object[] { Integer.valueOf(400), Boolean.TRUE, "Dialog1", Integer.valueOf(102),Integer.valueOf(41), Integer.valueOf(1), Short.valueOf((short) 0), "Document-Dialog", Integer.valueOf(300)});
+ oDialogDocument.createWindowPeer();
+ Object oFTHeaderModel = oDialogDocument.m_xMSFDialogModel.createInstance("com.sun.star.awt.UnoControlFixedTextModel");
+ XMultiPropertySet xFTHeaderModelMPSet = UnoRuntime.queryInterface(XMultiPropertySet.class, oFTHeaderModel);
+ xFTHeaderModelMPSet.setPropertyValues(
+ new String[] {"Height", "Label", "Name", "PositionX", "PositionY", "Width"},
+ new Object[] { Integer.valueOf(8), "This code-sample demonstrates how to display an office document in a dialog window", "HeaderLabel", Integer.valueOf(6), Integer.valueOf(6), Integer.valueOf(300)});
+ // add the model to the NameContainer of the dialog model
+ oDialogDocument.m_xDlgModelNameContainer.insertByName("Headerlabel", oFTHeaderModel);
+ oDialogDocument.showDocumentinDialogWindow(oDialogDocument.m_xWindowPeer, new Rectangle(40, 50, 420, 550), "private:factory/swriter");
+
+ oDialogDocument.insertButton(oDialogDocument, 126, 370, 50, "~Close dialog", (short) PushButtonType.OK_value);
+ oDialogDocument.executeDialog();
+ }catch( Exception ex ) {
+ ex.printStackTrace(System.err);
+ } finally{
+ //make sure always to dispose the component and free the memory!
+ if (oDialogDocument != null){
+ if (oDialogDocument.m_xComponent != null) {
+ oDialogDocument.m_xComponent.dispose();
+ }
+ }
+ }
+
+ System.exit( 0 );
+ }
+
+ public void showDocumentinDialogWindow(XWindowPeer _xParentWindowPeer, Rectangle _aRectangle, String _sUrl){
+ try {
+ // The Toolkit is the creator of all windows...
+ Object oToolkit = m_xMCF.createInstanceWithContext("com.sun.star.awt.Toolkit", m_xContext);
+ XToolkit xToolkit = UnoRuntime.queryInterface(XToolkit.class, oToolkit);
+
+ // set up a window description and create the window. A parent window is always necessary for this...
+ com.sun.star.awt.WindowDescriptor aWindowDescriptor = new com.sun.star.awt.WindowDescriptor();
+ // a simple window is enough for this purpose...
+ aWindowDescriptor.Type = WindowClass.SIMPLE;
+ aWindowDescriptor.WindowServiceName = "dockingwindow";
+ // assign the parent window peer as described in the idl description...
+ aWindowDescriptor.Parent = _xParentWindowPeer;
+ aWindowDescriptor.ParentIndex = 1;
+ aWindowDescriptor.Bounds = _aRectangle;
+
+ // set the window attributes...
+ // The attribute CLIPCHILDREN causes the parent to not repaint the areas of the children...
+ aWindowDescriptor.WindowAttributes = VclWindowPeerAttribute.CLIPCHILDREN + WindowAttribute.BORDER + WindowAttribute.SHOW;
+ XWindowPeer xWindowPeer = xToolkit.createWindow(aWindowDescriptor);
+ XWindow xWindow = UnoRuntime.queryInterface(XWindow.class, xWindowPeer);
+ XView xView = UnoRuntime.queryInterface(XView.class, xWindow);
+
+ // create a frame and initialize it with the created window...
+ Object oFrame = m_xMCF.createInstanceWithContext("com.sun.star.frame.Frame", m_xContext);
+ // The frame should be of global scope because it's within the responsibility to dispose it after usage
+ m_xFrame = UnoRuntime.queryInterface(XFrame.class, oFrame);
+ m_xFrame.initialize(xWindow);
+
+ // load the document and open it in preview mode
+ XComponentLoader xComponentLoader = UnoRuntime.queryInterface(XComponentLoader.class, m_xFrame);
+ PropertyValue[] aPropertyValues = new PropertyValue[2];
+ PropertyValue aPropertyValue = new PropertyValue();
+ aPropertyValue.Name = "Preview";
+ aPropertyValue.Value = Boolean.TRUE;
+ aPropertyValues[0] = aPropertyValue;
+ aPropertyValue = new PropertyValue();
+ aPropertyValue.Name = "ReadOnly";
+ aPropertyValue.Value = Boolean.TRUE;
+ aPropertyValues[1] = aPropertyValue;
+ xComponentLoader.loadComponentFromURL(_sUrl, "_self", 0, aPropertyValues);
+ } catch (com.sun.star.lang.IllegalArgumentException ex) {
+ throw new java.lang.RuntimeException("cannot happen...", ex);
+ } catch (com.sun.star.uno.Exception ex) {
+ throw new java.lang.RuntimeException("cannot happen...", ex);
+ }
+ }
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/GUI/ImageControlSample.java b/odk/examples/DevelopersGuide/GUI/ImageControlSample.java
new file mode 100644
index 000000000..060b5e681
--- /dev/null
+++ b/odk/examples/DevelopersGuide/GUI/ImageControlSample.java
@@ -0,0 +1,166 @@
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+import com.sun.star.awt.PushButtonType;
+import com.sun.star.awt.XDialog;
+import com.sun.star.beans.PropertyValue;
+import com.sun.star.beans.XMultiPropertySet;
+import com.sun.star.beans.XPropertySet;
+import com.sun.star.graphic.XGraphic;
+import com.sun.star.graphic.XGraphicProvider;
+import com.sun.star.lang.XMultiComponentFactory;
+import com.sun.star.ucb.XFileIdentifierConverter;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.XComponentContext;
+
+
+public class ImageControlSample extends UnoDialogSample{
+ /**
+ * Creates a new instance of ImageControlSample
+ */
+ public ImageControlSample(XComponentContext _xContext, XMultiComponentFactory _xMCF){
+ super(_xContext, _xMCF);
+ super.createDialog(_xMCF);
+ }
+
+ // to start this script pass a parameter denoting the system path to a graphic to be displayed
+ public static void main(String args[]) {
+ ImageControlSample oImageControlSample = null;
+ try {
+ if (args.length == 0) {
+ System.out.println("Please pass a parameter denoting the system path to your graphic!");
+ return;
+ }
+ XComponentContext xContext = com.sun.star.comp.helper.Bootstrap.bootstrap();
+ if(xContext != null ){
+ System.out.println("Connected to a running office ...");
+ }
+ XMultiComponentFactory xMCF = xContext.getServiceManager();
+ oImageControlSample = new ImageControlSample(xContext, xMCF);
+ oImageControlSample.initialize( new String[] {"Height", "Moveable", "Name","PositionX","PositionY", "Step", "TabIndex","Title","Width"},
+ new Object[] { Integer.valueOf(100), Boolean.TRUE, "MyTestDialog", Integer.valueOf(102),Integer.valueOf(41), Integer.valueOf(0), Short.valueOf((short) 0), "OpenOffice", Integer.valueOf(230)});
+ Object oFTHeaderModel = oImageControlSample.m_xMSFDialogModel.createInstance("com.sun.star.awt.UnoControlFixedTextModel");
+ XMultiPropertySet xFTHeaderModelMPSet = UnoRuntime.queryInterface(XMultiPropertySet.class, oFTHeaderModel);
+ xFTHeaderModelMPSet.setPropertyValues(
+ new String[] {"Height", "Label", "MultiLine", "Name", "PositionX", "PositionY", "Width"},
+ new Object[] { Integer.valueOf(16), "This code-sample demonstrates how to create an ImageControlSample within a dialog", Boolean.TRUE, "HeaderLabel", Integer.valueOf(6), Integer.valueOf(6), Integer.valueOf(210)});
+ // add the model to the NameContainer of the dialog model
+ oImageControlSample.m_xDlgModelNameContainer.insertByName("Headerlabel", oFTHeaderModel);
+ XPropertySet xICModelPropertySet = oImageControlSample.insertImageControl(68, 30, 32, 90);
+ oImageControlSample.insertButton(oImageControlSample, 90, 75, 50, "~Close dialog", (short) PushButtonType.OK_value);
+ oImageControlSample.createWindowPeer();
+ // note: due to issue i76718 ("Setting graphic at a controlmodel required dialog peer") the graphic of the image control
+ // may not be set before the peer of the dialog has been created.
+ XGraphic xGraphic = oImageControlSample.getGraphic(oImageControlSample.m_xMCF, args[0]);
+ xICModelPropertySet.setPropertyValue("Graphic", xGraphic);
+ oImageControlSample.xDialog = UnoRuntime.queryInterface(XDialog.class, oImageControlSample.m_xDialogControl);
+ oImageControlSample.executeDialog();
+ }catch( Exception e ) {
+ System.err.println( e + e.getMessage());
+ e.printStackTrace();
+ } finally{
+ //make sure always to dispose the component and free the memory!
+ if (oImageControlSample != null){
+ if (oImageControlSample.m_xComponent != null){
+ oImageControlSample.m_xComponent.dispose();
+ }
+ }
+ }
+ System.exit( 0 );
+ }
+
+
+ public XPropertySet insertImageControl(int _nPosX, int _nPosY, int _nHeight, int _nWidth){
+ XPropertySet xICModelPropertySet = null;
+ try{
+ // create a unique name by means of an own implementation...
+ String sName = createUniqueName(m_xDlgModelNameContainer, "ImageControl");
+ // convert the system path to the image to a FileUrl
+
+ // create a controlmodel at the multiservicefactory of the dialog model...
+ Object oICModel = m_xMSFDialogModel.createInstance("com.sun.star.awt.UnoControlImageControlModel");
+ XMultiPropertySet xICModelMPSet = UnoRuntime.queryInterface(XMultiPropertySet.class, oICModel);
+ xICModelPropertySet =UnoRuntime.queryInterface(XPropertySet.class, oICModel);
+ // Set the properties at the model - keep in mind to pass the property names in alphabetical order!
+ // The image is not scaled
+ xICModelMPSet.setPropertyValues(
+ new String[] {"Border", "Height", "Name", "PositionX", "PositionY", "ScaleImage", "Width"},
+ new Object[] { Short.valueOf((short) 1), Integer.valueOf(_nHeight), sName, Integer.valueOf(_nPosX), Integer.valueOf(_nPosY), Boolean.FALSE, Integer.valueOf(_nWidth)});
+
+ // The controlmodel is not really available until inserted to the Dialog container
+ m_xDlgModelNameContainer.insertByName(sName, oICModel);
+ }catch (com.sun.star.uno.Exception ex){
+ /* perform individual exception handling here.
+ * Possible exception types are:
+ * com.sun.star.lang.IllegalArgumentException,
+ * com.sun.star.lang.WrappedTargetException,
+ * com.sun.star.container.ElementExistException,
+ * com.sun.star.beans.PropertyVetoException,
+ * com.sun.star.beans.UnknownPropertyException,
+ * com.sun.star.uno.Exception
+ */
+ ex.printStackTrace(System.err);
+ }
+ return xICModelPropertySet;
+ }
+
+
+// creates a UNO graphic object that can be used to be assigned
+// to the property "Graphic" of a controlmodel
+ public XGraphic getGraphic(XMultiComponentFactory _xMCF, String _sImageSystemPath){
+ XGraphic xGraphic = null;
+ try{
+ java.io.File oFile = new java.io.File(_sImageSystemPath);
+ Object oFCProvider = _xMCF.createInstanceWithContext("com.sun.star.ucb.FileContentProvider", this.m_xContext);
+ XFileIdentifierConverter xFileIdentifierConverter = UnoRuntime.queryInterface(XFileIdentifierConverter.class, oFCProvider);
+ String sImageUrl = xFileIdentifierConverter.getFileURLFromSystemPath(_sImageSystemPath, oFile.getAbsolutePath());
+
+ // create a GraphicProvider at the global service manager...
+ Object oGraphicProvider = m_xMCF.createInstanceWithContext("com.sun.star.graphic.GraphicProvider", m_xContext);
+ XGraphicProvider xGraphicProvider = UnoRuntime.queryInterface(XGraphicProvider.class, oGraphicProvider);
+ // create the graphic object
+ PropertyValue[] aPropertyValues = new PropertyValue[1];
+ PropertyValue aPropertyValue = new PropertyValue();
+ aPropertyValue.Name = "URL";
+ aPropertyValue.Value = sImageUrl;
+ aPropertyValues[0] = aPropertyValue;
+ xGraphic = xGraphicProvider.queryGraphic(aPropertyValues);
+ return xGraphic;
+ }catch (com.sun.star.uno.Exception ex){
+ throw new java.lang.RuntimeException("cannot happen...", ex);
+ }}
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/GUI/Makefile b/odk/examples/DevelopersGuide/GUI/Makefile
new file mode 100644
index 000000000..6eb18efdc
--- /dev/null
+++ b/odk/examples/DevelopersGuide/GUI/Makefile
@@ -0,0 +1,141 @@
+#*************************************************************************
+#
+# The Contents of this file are made available subject to the terms of
+# the BSD license.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+# 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+# contributors may be used to endorse or promote products derived
+# from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+# TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+# USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+#**************************************************************************
+
+# Builds the GUI examples of the Developers Guide.
+
+PRJ=../../..
+SETTINGS=$(PRJ)/settings
+
+include $(SETTINGS)/settings.mk
+include $(SETTINGS)/std.mk
+
+# Define non-platform/compiler specific settings
+SAMPLE_NAME=GUIExamples
+SAMPLE_CLASS_OUT = $(OUT_CLASS)/$(SAMPLE_NAME)
+SAMPLE_GEN_OUT = $(OUT_MISC)/$(SAMPLE_NAME)
+
+
+APP1_NAME=DialogDocument
+APP1_JAR=$(SAMPLE_CLASS_OUT)/$(APP1_NAME).jar
+APP2_NAME=MessageBox
+APP2_JAR=$(SAMPLE_CLASS_OUT)/$(APP2_NAME).jar
+APP3_NAME=UnoDialogSample
+APP3_JAR=$(SAMPLE_CLASS_OUT)/$(APP3_NAME).jar
+APP4_NAME=UnoDialogSample2
+APP4_JAR=$(SAMPLE_CLASS_OUT)/$(APP4_NAME).jar
+APP5_NAME=UnoMenu
+APP5_JAR=$(SAMPLE_CLASS_OUT)/$(APP5_NAME).jar
+APP6_NAME=UnoMenu2
+APP6_JAR=$(SAMPLE_CLASS_OUT)/$(APP6_NAME).jar
+APP7_NAME=ImageControlSample
+APP7_JAR=$(SAMPLE_CLASS_OUT)/$(APP7_NAME).jar
+
+APP_JAVAFILES = \
+ RoadmapItemStateChangeListener.java \
+ UnoDialogSample.java \
+ UnoMenu.java
+
+APP_CLASSFILES = $(patsubst %.java,$(SAMPLE_CLASS_OUT)/%.class,$(APP_JAVAFILES))
+# $(SAMPLE_CLASS_OUT)/UnoDialogSample\&RoadmapItemStateChangeListener.class
+
+APP_CLASSNAMES = $(patsubst %.java,%.class,$(APP_JAVAFILES))
+#APP_CLASSNAMES = $(patsubst $(SAMPLE_CLASS_OUT)/%.class,%.class,$(APP_CLASSFILES))
+
+
+SDK_CLASSPATH = $(subst $(EMPTYSTRING) $(PATH_SEPARATOR),$(PATH_SEPARATOR),$(CLASSPATH)\
+ $(PATH_SEPARATOR)$(SAMPLE_CLASS_OUT))
+
+
+# Targets
+.PHONY: ALL
+ALL : \
+ GUIExamples
+
+
+include $(SETTINGS)/stdtarget.mk
+
+
+$(APP_CLASSFILES) : $(APP_JAVAFILES)
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ $(SDK_JAVAC) $(JAVAC_FLAGS) -classpath "$(SDK_CLASSPATH)" -d $(SAMPLE_CLASS_OUT) $(APP_JAVAFILES)
+
+$(SAMPLE_CLASS_OUT)/%.class : %.java $(APP_CLASSFILES)
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ $(SDK_JAVAC) $(JAVAC_FLAGS) -classpath "$(SDK_CLASSPATH)" -d $(SAMPLE_CLASS_OUT) $<
+
+$(SAMPLE_CLASS_OUT)/%.mf :
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ @echo Main-Class: com.sun.star.lib.loader.Loader> $@
+ $(ECHOLINE)>> $@
+ @echo Name: com/sun/star/lib/loader/Loader.class>> $@
+ @echo Application-Class: $*>> $@
+
+$(SAMPLE_CLASS_OUT)/%.jar : $(SAMPLE_CLASS_OUT)/%.mf $(SAMPLE_CLASS_OUT)/%.class $(APP_CLASSFILES)
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ +cd $(subst /,$(PS),$(SAMPLE_CLASS_OUT)) && $(SDK_JAR) cvfm $(@F) $*.mf $*.class $(APP_CLASSNAMES)
+ +$(SDK_JAR) uvf $@ $(SDK_JAVA_UNO_BOOTSTRAP_FILES)
+
+$(APP1_JAR) : $(SAMPLE_CLASS_OUT)/$(APP1_NAME).mf $(SAMPLE_CLASS_OUT)/$(APP1_NAME).class
+$(APP2_JAR) : $(SAMPLE_CLASS_OUT)/$(APP2_NAME).mf $(SAMPLE_CLASS_OUT)/$(APP2_NAME).class
+$(APP3_JAR) : $(SAMPLE_CLASS_OUT)/$(APP3_NAME).mf $(SAMPLE_CLASS_OUT)/$(APP3_NAME).class
+$(APP4_JAR) : $(SAMPLE_CLASS_OUT)/$(APP4_NAME).mf $(SAMPLE_CLASS_OUT)/$(APP4_NAME).class
+$(APP5_JAR) : $(SAMPLE_CLASS_OUT)/$(APP5_NAME).mf $(SAMPLE_CLASS_OUT)/$(APP5_NAME).class
+$(APP6_JAR) : $(SAMPLE_CLASS_OUT)/$(APP6_NAME).mf $(SAMPLE_CLASS_OUT)/$(APP6_NAME).class
+$(APP7_JAR) : $(SAMPLE_CLASS_OUT)/$(APP7_NAME).mf $(SAMPLE_CLASS_OUT)/$(APP7_NAME).class
+
+GUIExamples : $(APP1_JAR) $(APP2_JAR) $(APP3_JAR) $(APP4_JAR) $(APP5_JAR) $(APP6_JAR) $(APP7_JAR)
+ @echo --------------------------------------------------------------------------------
+ @echo Please use one of the following commands to execute the examples!
+ @echo -
+ @echo $(MAKE) $(APP1_NAME).run
+ @echo $(MAKE) $(APP2_NAME).run
+ @echo $(MAKE) $(APP3_NAME).run
+ @echo $(MAKE) $(APP4_NAME).run
+ @echo $(MAKE) $(APP5_NAME).run
+ @echo $(MAKE) $(APP6_NAME).run
+ @echo $(MAKE) $(APP7_NAME).run
+ @echo --------
+
+%.run: $(SAMPLE_CLASS_OUT)/%.jar
+ $(SDK_JAVA) -Dcom.sun.star.lib.loader.unopath="$(OFFICE_PROGRAM_PATH)" -jar $<
+
+$(APP7_NAME).run: $(SAMPLE_CLASS_OUT)/$(APP7_NAME).jar
+ $(SDK_JAVA) -Dcom.sun.star.lib.loader.unopath="$(OFFICE_PROGRAM_PATH)" -jar $< .$(PS)oologo.gif
+
+
+.PHONY: clean
+clean :
+ -$(DELRECURSIVE) $(subst /,$(PS),$(SAMPLE_CLASS_OUT))
+ -$(DELRECURSIVE) $(subst /,$(PS),$(SAMPLE_GEN_OUT))
diff --git a/odk/examples/DevelopersGuide/GUI/MessageBox.java b/odk/examples/DevelopersGuide/GUI/MessageBox.java
new file mode 100644
index 000000000..cff15262d
--- /dev/null
+++ b/odk/examples/DevelopersGuide/GUI/MessageBox.java
@@ -0,0 +1,237 @@
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+import com.sun.star.awt.MessageBoxType;
+import com.sun.star.awt.XMessageBox;
+import com.sun.star.awt.XMessageBoxFactory;
+import com.sun.star.awt.XVclWindowPeer;
+import com.sun.star.awt.XWindow;
+import com.sun.star.awt.XWindowPeer;
+import com.sun.star.frame.XFrame;
+import com.sun.star.frame.XModel;
+import com.sun.star.util.XCloseable;
+import com.sun.star.frame.XFramesSupplier;
+import com.sun.star.lang.IllegalArgumentException;
+import com.sun.star.lang.XComponent;
+import com.sun.star.lang.XMultiComponentFactory;
+import com.sun.star.uno.AnyConverter;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.XComponentContext;
+
+
+
+public class MessageBox {
+
+ protected XComponentContext m_xContext = null;
+ protected com.sun.star.lang.XMultiComponentFactory m_xMCF;
+
+ /** Creates a new instance of MessageBox */
+ public MessageBox(XComponentContext _xContext, XMultiComponentFactory _xMCF){
+ m_xContext = _xContext;
+ m_xMCF = _xMCF;
+ }
+
+ public static void main(String args[]) {
+ XComponent xComp = null;
+ try {
+ XComponentContext xContext = com.sun.star.comp.helper.Bootstrap.bootstrap();
+ if(xContext != null )
+ System.out.println("Connected to a running office ...");
+ XMultiComponentFactory xMCF = xContext.getServiceManager();
+
+ MessageBox oMessageBox = new MessageBox(xContext, xMCF);
+
+ //load default text document to get an active frame
+ xComp = oMessageBox.createDefaultTextDocument();
+
+ XWindowPeer xWindowPeer = oMessageBox.getWindowPeerOfFrame(xComp);
+ if (xWindowPeer != null) {
+ XVclWindowPeer xVclWindowPeer = UnoRuntime.queryInterface(XVclWindowPeer.class, xWindowPeer);
+ boolean bisHighContrast = oMessageBox.isHighContrastModeActivated(xVclWindowPeer);
+ oMessageBox.showErrorMessageBox(xWindowPeer, "My Sampletitle", "HighContrastMode is enabled: " + bisHighContrast);
+ } else{
+ System.out.println("Could not retrieve current frame");
+ }
+
+ } catch( Exception e ) {
+ System.err.println( e + e.getMessage());
+ e.printStackTrace();
+ } finally {
+ if (xComp != null) {
+ try {
+ XCloseable xClose = UnoRuntime.queryInterface(XCloseable.class, xComp);
+ if (xClose != null) {
+ xClose.close(false);
+ } else {
+ xComp.dispose();
+ }
+ } catch (com.sun.star.util.CloseVetoException e) {
+ System.err.println( e + e.getMessage());
+ e.printStackTrace();
+ }
+ }
+ }
+
+ System.exit( 0 );
+ }
+
+ // helper method to get the window peer of a document or if no
+ // document is specified it tries to get the active frame
+ // which is potentially dangerous
+ public XWindowPeer getWindowPeerOfFrame(XComponent xComp) {
+ try {
+ XFrame xFrame = null;
+
+ if (xComp != null) {
+ XModel xModel = UnoRuntime.queryInterface(XModel.class, xComp);
+ xFrame = xModel.getCurrentController().getFrame();
+
+ } else {
+ // Note: This method is potentially dangerous and should only be used for debugging
+ // purposes as it relies on the platform dependent window handler...
+ Object oDesktop = m_xMCF.createInstanceWithContext("com.sun.star.frame.Desktop", m_xContext);
+ XFramesSupplier xFramesSupplier = UnoRuntime.queryInterface(XFramesSupplier.class, oDesktop);
+ xFrame = xFramesSupplier.getActiveFrame();
+ }
+
+ if (xFrame != null){
+ XWindow xWindow = xFrame.getContainerWindow();
+ if (xWindow != null){
+ XWindowPeer xWindowPeer = UnoRuntime.queryInterface(XWindowPeer.class, xWindow);
+ return xWindowPeer;
+ }
+ }
+ } catch (com.sun.star.uno.Exception ex) {
+ ex.printStackTrace();
+ }
+ return null;
+ }
+
+ XComponent createDefaultTextDocument() {
+
+ XComponent xComp = null;
+ try {
+ Object oDesktop = m_xMCF.createInstanceWithContext(
+ "com.sun.star.frame.Desktop", m_xContext);
+
+ // get the component laoder from the desktop to create a new
+ // text document
+ com.sun.star.frame.XComponentLoader xCLoader =UnoRuntime.queryInterface(com.sun.star.frame.XComponentLoader.class,oDesktop);
+
+ com.sun.star.beans.PropertyValue[] args = new com.sun.star.beans.PropertyValue [1];
+ args[0] = new com.sun.star.beans.PropertyValue();
+ args[0].Name = "Hidden";
+ args[0].Value = Boolean.TRUE;
+ String strDoc = "private:factory/swriter";
+
+ xComp = xCLoader.loadComponentFromURL(strDoc, "_blank", 0, args);
+
+ } catch(com.sun.star.uno.Exception ex) {
+ ex.printStackTrace();
+ }
+ return xComp;
+ }
+
+ /** shows an error messagebox
+ * @param _xParentWindowPeer the windowpeer of the parent window
+ * @param _sTitle the title of the messagebox
+ * @param _sMessage the message of the messagebox
+ */
+ public void showErrorMessageBox(XWindowPeer _xParentWindowPeer, String _sTitle, String _sMessage) {
+ XComponent xComponent = null;
+ try {
+ Object oToolkit = m_xMCF.createInstanceWithContext("com.sun.star.awt.Toolkit", m_xContext);
+ XMessageBoxFactory xMessageBoxFactory = UnoRuntime.queryInterface(XMessageBoxFactory.class, oToolkit);
+ XMessageBox xMessageBox = xMessageBoxFactory.createMessageBox(_xParentWindowPeer, MessageBoxType.ERRORBOX, com.sun.star.awt.MessageBoxButtons.BUTTONS_OK, _sTitle, _sMessage);
+ xComponent = UnoRuntime.queryInterface(XComponent.class, xMessageBox);
+ if (xMessageBox != null){
+ xMessageBox.execute();
+ }
+ } catch (com.sun.star.uno.Exception ex) {
+ ex.printStackTrace(System.err);
+ } finally{
+ //make sure always to dispose the component and free the memory!
+ if (xComponent != null){
+ xComponent.dispose();
+ }
+ }
+ }
+
+
+ /** @param _xVclWindowPeer the windowpeer of a dialog control or the dialog itself
+ * @return true if HighContrastMode is activated or false if HighContrastMode is deactivated
+ */
+ public boolean isHighContrastModeActivated(XVclWindowPeer _xVclWindowPeer) {
+ boolean bIsActivated = false;
+
+ try {
+ if (_xVclWindowPeer != null){
+ int nUIColor = AnyConverter.toInt(_xVclWindowPeer.getProperty("DisplayBackgroundColor"));
+ int nRed = getRedColorShare(nUIColor);
+ int nGreen = getGreenColorShare(nUIColor);
+ int nBlue = getBlueColorShare(nUIColor);
+ int nLuminance = (( nBlue*28 + nGreen*151 + nRed*77 ) / 256 );
+ boolean bisactivated = (nLuminance <= 25);
+ return bisactivated;
+ } else{
+ return false;
+ }
+ } catch (IllegalArgumentException e) {
+ e.printStackTrace(System.err);
+ }
+ return bIsActivated;
+ }
+
+ public static int getRedColorShare(int _nColor) {
+ int nRed = _nColor/65536;
+ return nRed;
+ }
+
+ public static int getGreenColorShare(int _nColor) {
+ int nRedModulo = _nColor % 65536;
+ int nGreen = nRedModulo / 256;
+ return nGreen;
+ }
+
+ public static int getBlueColorShare(int _nColor) {
+ int nRedModulo = _nColor % 65536;
+ int nGreenModulo = (nRedModulo % 256);
+ int nBlue = nGreenModulo;
+ return nBlue;
+ }
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/GUI/RoadmapItemStateChangeListener.java b/odk/examples/DevelopersGuide/GUI/RoadmapItemStateChangeListener.java
new file mode 100644
index 000000000..9a9db63cd
--- /dev/null
+++ b/odk/examples/DevelopersGuide/GUI/RoadmapItemStateChangeListener.java
@@ -0,0 +1,69 @@
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+import com.sun.star.awt.XItemListener;
+import com.sun.star.lang.EventObject;
+import com.sun.star.beans.XPropertySet;
+import com.sun.star.uno.UnoRuntime;
+
+
+public class RoadmapItemStateChangeListener implements XItemListener {
+ private final com.sun.star.lang.XMultiServiceFactory m_xMSFDialogModel;
+
+ public RoadmapItemStateChangeListener(com.sun.star.lang.XMultiServiceFactory xMSFDialogModel) {
+ m_xMSFDialogModel = xMSFDialogModel;
+ }
+
+ public void itemStateChanged(com.sun.star.awt.ItemEvent itemEvent) {
+ try {
+ // get the new ID of the roadmap that is supposed to refer to the new step of the dialogmodel
+ int nNewID = itemEvent.ItemId;
+ XPropertySet xDialogModelPropertySet = UnoRuntime.queryInterface(XPropertySet.class, m_xMSFDialogModel);
+ int nOldStep = ((Integer) xDialogModelPropertySet.getPropertyValue("Step")).intValue();
+ // in the following line "ID" and "Step" are mixed together.
+ // In fact in this case they denote the same
+ if (nNewID != nOldStep){
+ xDialogModelPropertySet.setPropertyValue("Step", Integer.valueOf(nNewID));
+ }
+ } catch (com.sun.star.uno.Exception exception) {
+ exception.printStackTrace(System.err);
+ }
+ }
+
+ public void disposing(EventObject eventObject) {
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/GUI/SystemDialog.java b/odk/examples/DevelopersGuide/GUI/SystemDialog.java
new file mode 100644
index 000000000..62c6e3e03
--- /dev/null
+++ b/odk/examples/DevelopersGuide/GUI/SystemDialog.java
@@ -0,0 +1,188 @@
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+import com.sun.star.beans.XPropertySet;
+import com.sun.star.lang.XComponent;
+import com.sun.star.lang.XInitialization;
+import com.sun.star.lang.XMultiComponentFactory;
+import com.sun.star.ui.dialogs.XExecutableDialog;
+import com.sun.star.ui.dialogs.XFilePicker;
+import com.sun.star.ui.dialogs.XFilePickerControlAccess;
+import com.sun.star.ui.dialogs.XFilterManager;
+import com.sun.star.ui.dialogs.XFolderPicker2;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.XComponentContext;
+import com.sun.star.util.thePathSettings;
+
+
+public class SystemDialog {
+
+ protected XComponentContext m_xContext = null;
+ protected com.sun.star.lang.XMultiComponentFactory m_xMCF;
+
+ /** Creates a new instance of MessageBox */
+ public SystemDialog(XComponentContext _xContext, XMultiComponentFactory _xMCF){
+ m_xContext = _xContext;
+ m_xMCF = _xMCF;
+ }
+
+ public static void main(String args[]){
+ try {
+ XComponentContext xContext = com.sun.star.comp.helper.Bootstrap.bootstrap();
+ if(xContext != null )
+ System.out.println("Connected to a running office ...");
+ XMultiComponentFactory xMCF = xContext.getServiceManager();
+ SystemDialog oSystemDialog = new SystemDialog(xContext, xMCF);
+ oSystemDialog.raiseSaveAsDialog();
+ oSystemDialog.raiseFolderPicker(oSystemDialog.getWorkPath(), "My Title");
+ }catch( Exception e ) {
+ System.err.println( e + e.getMessage());
+ e.printStackTrace();
+ }
+
+ System.exit( 0 );
+ }
+
+
+ public String raiseSaveAsDialog() {
+ String sStorePath = "";
+ XComponent xComponent = null;
+ try {
+ // the filepicker is instantiated with the global Multicomponentfactory...
+ Object oFilePicker = m_xMCF.createInstanceWithContext("com.sun.star.ui.dialogs.FilePicker", m_xContext);
+ XFilePicker xFilePicker = UnoRuntime.queryInterface(XFilePicker.class, oFilePicker);
+
+ // the defaultname is the initially proposed filename...
+ xFilePicker.setDefaultName("MyExampleDocument");
+
+ // set the initial displaydirectory. In this example the user template directory is used
+ Object oPathSettings = thePathSettings.get(m_xContext);
+ XPropertySet xPropertySet = com.sun.star.uno.UnoRuntime.queryInterface(XPropertySet.class, oPathSettings);
+ String sTemplateUrl = (String) xPropertySet.getPropertyValue("Template_writable");
+ xFilePicker.setDisplayDirectory(sTemplateUrl);
+
+ // set the filters of the dialog. The filternames may be retrieved from
+ // http://wiki.openoffice.org/wiki/Framework/Article/Filter
+ XFilterManager xFilterManager = UnoRuntime.queryInterface(XFilterManager.class, xFilePicker);
+ xFilterManager.appendFilter("OpenDocument Text Template", "writer8_template");
+ xFilterManager.appendFilter("OpenDocument Text", "writer8");
+
+ // choose the template that defines the capabilities of the filepicker dialog
+ XInitialization xInitialize = UnoRuntime.queryInterface(XInitialization.class, xFilePicker);
+ short[] listAny = new short[] { com.sun.star.ui.dialogs.TemplateDescription.FILESAVE_AUTOEXTENSION };
+ xInitialize.initialize(listAny);
+
+ // add a control to the dialog to add the extension automatically to the filename...
+ XFilePickerControlAccess xFilePickerControlAccess = UnoRuntime.queryInterface(XFilePickerControlAccess.class, xFilePicker);
+ xFilePickerControlAccess.setValue(com.sun.star.ui.dialogs.ExtendedFilePickerElementIds.CHECKBOX_AUTOEXTENSION, (short) 0, Boolean.TRUE);
+
+ xComponent = UnoRuntime.queryInterface(XComponent.class, xFilePicker);
+
+ // execute the dialog...
+ XExecutableDialog xExecutable = UnoRuntime.queryInterface(XExecutableDialog.class, xFilePicker);
+ short nResult = xExecutable.execute();
+
+ // query the resulting path of the dialog...
+ if (nResult == com.sun.star.ui.dialogs.ExecutableDialogResults.OK){
+ String[] sPathList = xFilePicker.getFiles();
+ if (sPathList.length > 0){
+ sStorePath = sPathList[0];
+ }
+ }
+ } catch (com.sun.star.uno.Exception exception) {
+ exception.printStackTrace();
+ } finally{
+ //make sure always to dispose the component and free the memory!
+ if (xComponent != null){
+ xComponent.dispose();
+ }
+ }
+ return sStorePath;
+ }
+
+ public String getWorkPath(){
+ String sWorkUrl = "";
+ try{
+ // retrieve the configured Work path...
+ Object oPathSettings = thePathSettings.get(m_xContext);
+ XPropertySet xPropertySet = com.sun.star.uno.UnoRuntime.queryInterface(XPropertySet.class, oPathSettings);
+ sWorkUrl = (String) xPropertySet.getPropertyValue("Work");
+ } catch (com.sun.star.uno.Exception exception) {
+ exception.printStackTrace();
+ }
+ return sWorkUrl;
+ }
+
+ /** raises a folderpicker in which the user can browse and select a path
+ * @param _sDisplayDirectory the path to the directory that is initially displayed
+ * @param _sTitle the title of the folderpicker
+ * @return the path to the folder that the user has selected. if the user has closed
+ * the folderpicker by clicking the "Cancel" button
+ * an empty string is returned
+ * @see com.sun.star.ui.dialogs.FolderPicker
+ */
+ public String raiseFolderPicker(String _sDisplayDirectory, String _sTitle) {
+ String sReturnFolder = "";
+ XComponent xComponent = null;
+ try {
+ // instantiate the folder picker and retrieve the necessary interfaces...
+ Object oFolderPicker = m_xMCF.createInstanceWithContext("com.sun.star.ui.dialogs.FolderPicker", m_xContext);
+ XFolderPicker2 xFolderPicker = UnoRuntime.queryInterface(XFolderPicker2.class, oFolderPicker);
+ XExecutableDialog xExecutable = UnoRuntime.queryInterface(XExecutableDialog.class, oFolderPicker);
+ xComponent = UnoRuntime.queryInterface(XComponent.class, oFolderPicker);
+ xFolderPicker.setDisplayDirectory(_sDisplayDirectory);
+ // set the dialog title...
+ xFolderPicker.setTitle(_sTitle);
+ // show the dialog...
+ short nResult = xExecutable.execute();
+
+ // User has clicked "Select" button...
+ if (nResult == com.sun.star.ui.dialogs.ExecutableDialogResults.OK){
+ sReturnFolder = xFolderPicker.getDirectory();
+ }
+
+ }catch( Exception exception ) {
+ exception.printStackTrace(System.err);
+ } finally{
+ //make sure always to dispose the component and free the memory!
+ if (xComponent != null){
+ xComponent.dispose();
+ }
+ }
+ // return the selected path. If the user has clicked cancel an empty string is
+ return sReturnFolder;
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/GUI/UnoDialogSample.java b/odk/examples/DevelopersGuide/GUI/UnoDialogSample.java
new file mode 100644
index 000000000..c49dbfd77
--- /dev/null
+++ b/odk/examples/DevelopersGuide/GUI/UnoDialogSample.java
@@ -0,0 +1,1373 @@
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+import com.sun.star.awt.ActionEvent;
+import com.sun.star.awt.AdjustmentEvent;
+import com.sun.star.awt.AdjustmentType;
+import com.sun.star.awt.FocusChangeReason;
+import com.sun.star.awt.FocusEvent;
+import com.sun.star.awt.ItemEvent;
+import com.sun.star.awt.KeyEvent;
+import com.sun.star.awt.MouseEvent;
+import com.sun.star.awt.PushButtonType;
+import com.sun.star.awt.SpinEvent;
+import com.sun.star.awt.TextEvent;
+import com.sun.star.awt.XActionListener;
+import com.sun.star.awt.XAdjustmentListener;
+import com.sun.star.awt.XButton;
+import com.sun.star.awt.XCheckBox;
+import com.sun.star.awt.XComboBox;
+import com.sun.star.awt.XControl;
+import com.sun.star.awt.XControlContainer;
+import com.sun.star.awt.XControlModel;
+import com.sun.star.awt.XDialog;
+import com.sun.star.awt.XFixedText;
+import com.sun.star.awt.XFocusListener;
+import com.sun.star.awt.XItemEventBroadcaster;
+import com.sun.star.awt.XItemListener;
+import com.sun.star.awt.XKeyListener;
+import com.sun.star.awt.XListBox;
+import com.sun.star.awt.XMouseListener;
+import com.sun.star.awt.XPointer;
+import com.sun.star.awt.XReschedule;
+import com.sun.star.awt.XScrollBar;
+import com.sun.star.awt.XSpinField;
+import com.sun.star.awt.XSpinListener;
+import com.sun.star.awt.XTextComponent;
+import com.sun.star.awt.XTextListener;
+import com.sun.star.awt.XToolkit;
+import com.sun.star.awt.XTopWindow;
+import com.sun.star.awt.XWindow;
+import com.sun.star.awt.XWindowPeer;
+import com.sun.star.beans.XMultiPropertySet;
+import com.sun.star.beans.XPropertySet;
+import com.sun.star.container.XIndexContainer;
+import com.sun.star.container.XNameAccess;
+import com.sun.star.container.XNameContainer;
+import com.sun.star.frame.XDesktop;
+import com.sun.star.frame.XFrame;
+import com.sun.star.frame.XModel;
+import com.sun.star.lang.EventObject;
+import com.sun.star.lang.XComponent;
+import com.sun.star.lang.XMultiComponentFactory;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.lang.XSingleServiceFactory;
+import com.sun.star.ucb.XFileIdentifierConverter;
+import com.sun.star.uno.AnyConverter;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.XComponentContext;
+import com.sun.star.util.XNumberFormats;
+import com.sun.star.util.XNumberFormatsSupplier;
+import com.sun.star.util.Date;
+import com.sun.star.util.Time;
+import com.sun.star.util.thePathSettings;
+
+
+// Suggestion: hand the position and width over as parameters
+
+public class UnoDialogSample implements XTextListener, XSpinListener, XActionListener, XFocusListener, XMouseListener, XItemListener, XAdjustmentListener, XKeyListener {
+ protected XComponentContext m_xContext = null;
+ protected com.sun.star.lang.XMultiComponentFactory m_xMCF;
+ protected XMultiServiceFactory m_xMSFDialogModel;
+ private XModel m_xModel;
+ protected XNameContainer m_xDlgModelNameContainer;
+ protected XControlContainer m_xDlgContainer;
+// protected XNameAccess m_xDlgModelNameAccess;
+ protected XControl m_xDialogControl;
+ protected XDialog xDialog;
+
+ protected XWindowPeer m_xWindowPeer = null;
+
+ protected XFrame m_xFrame = null;
+ protected XComponent m_xComponent = null;
+
+
+ /**
+ * Creates a new instance of UnoDialogSample
+ */
+ public UnoDialogSample(XComponentContext _xContext, XMultiComponentFactory _xMCF) {
+ m_xContext = _xContext;
+ m_xMCF = _xMCF;
+ createDialog(m_xMCF);
+ }
+
+
+ public static void main(String args[]) {
+ UnoDialogSample oUnoDialogSample = null;
+
+ try {
+ XComponentContext xContext = com.sun.star.comp.helper.Bootstrap.bootstrap();
+ if(xContext != null )
+ System.out.println("Connected to a running office ...");
+ XMultiComponentFactory xMCF = xContext.getServiceManager();
+ oUnoDialogSample = new UnoDialogSample(xContext, xMCF);
+ oUnoDialogSample.initialize( new String[] {"Height", "Moveable", "Name","PositionX","PositionY", "Step", "TabIndex","Title","Width"},
+ new Object[] { Integer.valueOf(380), Boolean.TRUE, "MyTestDialog", Integer.valueOf(102),Integer.valueOf(41), Integer.valueOf(0), Short.valueOf((short) 0), "OpenOffice", Integer.valueOf(380)});
+ Object oFTHeaderModel = oUnoDialogSample.m_xMSFDialogModel.createInstance("com.sun.star.awt.UnoControlFixedTextModel");
+ XMultiPropertySet xFTHeaderModelMPSet = UnoRuntime.queryInterface(XMultiPropertySet.class, oFTHeaderModel);
+ xFTHeaderModelMPSet.setPropertyValues(
+ new String[] {"Height", "Label", "Name", "PositionX", "PositionY", "Width"},
+ new Object[] { Integer.valueOf(8), "This code-sample demonstrates how to create various controls in a dialog", "HeaderLabel", Integer.valueOf(106), Integer.valueOf(6), Integer.valueOf(300)});
+ // add the model to the NameContainer of the dialog model
+ oUnoDialogSample.m_xDlgModelNameContainer.insertByName("Headerlabel", oFTHeaderModel);
+ oUnoDialogSample.insertFixedText(oUnoDialogSample, 106, 18, 100, 0, "My ~Label");
+ oUnoDialogSample.insertCurrencyField(oUnoDialogSample, 106, 30, 60);
+ oUnoDialogSample.insertProgressBar(106, 44, 100, 100);
+ oUnoDialogSample.insertHorizontalFixedLine(106, 58, 100, "My FixedLine");
+ oUnoDialogSample.insertEditField(oUnoDialogSample, oUnoDialogSample, 106, 72, 60);
+ oUnoDialogSample.insertTimeField(106, 96, 50, new Time(0,(short)0,(short)0,(short)10,false), new Time((short)0,(short)0,(short)0,(short)0,false), new Time((short)0,(short)0,(short)0,(short)17,false));
+ oUnoDialogSample.insertDateField(oUnoDialogSample, 166, 96, 50);
+ oUnoDialogSample.insertGroupBox(102, 124, 70, 100);
+ oUnoDialogSample.insertPatternField(106, 136, 50);
+ oUnoDialogSample.insertNumericField(106, 152, 50, 0.0, 1000.0, 500.0, 100.0, (short) 1);
+ oUnoDialogSample.insertCheckBox(oUnoDialogSample, 106, 168, 150);
+ oUnoDialogSample.insertRadioButtonGroup((short) 50, 130, 200, 150);
+ oUnoDialogSample.insertListBox(106, 230, 50, 0, new String[]{"First Item", "Second Item"});
+ oUnoDialogSample.insertComboBox(106, 250, 50);
+ oUnoDialogSample.insertFormattedField(oUnoDialogSample, 106, 270, 100);
+ oUnoDialogSample.insertVerticalScrollBar(oUnoDialogSample, 230, 230, 52);
+ oUnoDialogSample.insertFileControl(oUnoDialogSample, 106, 290, 200 );
+ oUnoDialogSample.insertButton(oUnoDialogSample, 106, 320, 50, "~Close dialog", (short) PushButtonType.OK_value);
+ oUnoDialogSample.createWindowPeer();
+ oUnoDialogSample.addRoadmap();
+ oUnoDialogSample.insertRoadmapItem(0, true, "Introduction", 1);
+ oUnoDialogSample.insertRoadmapItem(1, true, "Documents", 2);
+ oUnoDialogSample.xDialog = UnoRuntime.queryInterface(XDialog.class, oUnoDialogSample.m_xDialogControl);
+ oUnoDialogSample.executeDialog();
+ }catch( Exception e ) {
+ System.err.println( e + e.getMessage());
+ e.printStackTrace();
+ } finally{
+ //make sure always to dispose the component and free the memory!
+ if (oUnoDialogSample != null){
+ if (oUnoDialogSample.m_xComponent != null){
+ oUnoDialogSample.m_xComponent.dispose();
+ }
+ }
+ }
+
+ System.exit( 0 );
+ }
+
+
+ protected void createDialog(XMultiComponentFactory _xMCF) {
+ try {
+ Object oDialogModel = _xMCF.createInstanceWithContext("com.sun.star.awt.UnoControlDialogModel", m_xContext);
+
+ // The XMultiServiceFactory of the dialogmodel is needed to instantiate the controls...
+ m_xMSFDialogModel = UnoRuntime.queryInterface(XMultiServiceFactory.class, oDialogModel);
+
+ // The named container is used to insert the created controls into...
+ m_xDlgModelNameContainer = UnoRuntime.queryInterface(XNameContainer.class, oDialogModel);
+
+ // create the dialog...
+ Object oUnoDialog = _xMCF.createInstanceWithContext("com.sun.star.awt.UnoControlDialog", m_xContext);
+ m_xDialogControl = UnoRuntime.queryInterface(XControl.class, oUnoDialog);
+
+ // The scope of the control container is public...
+ m_xDlgContainer = UnoRuntime.queryInterface(XControlContainer.class, oUnoDialog);
+
+ UnoRuntime.queryInterface(XTopWindow.class, m_xDlgContainer);
+
+ // link the dialog and its model...
+ XControlModel xControlModel = UnoRuntime.queryInterface(XControlModel.class, oDialogModel);
+ m_xDialogControl.setModel(xControlModel);
+ } catch (com.sun.star.uno.Exception exception) {
+ exception.printStackTrace(System.err);
+ }
+ }
+
+
+
+
+
+
+ public short executeDialog() {
+ if (m_xWindowPeer == null) {
+ createWindowPeer();
+ }
+ xDialog = UnoRuntime.queryInterface(XDialog.class, m_xDialogControl);
+ m_xComponent = UnoRuntime.queryInterface(XComponent.class, m_xDialogControl);
+ return xDialog.execute();
+ }
+
+
+
+
+ public XItemListener getRoadmapItemStateChangeListener(){
+ return new RoadmapItemStateChangeListener(m_xMSFDialogModel);
+ }
+
+
+ public void initialize(String[] PropertyNames, Object[] PropertyValues) {
+ try{
+ XMultiPropertySet xMultiPropertySet = UnoRuntime.queryInterface(XMultiPropertySet.class, m_xDlgModelNameContainer);
+ xMultiPropertySet.setPropertyValues(PropertyNames, PropertyValues);
+ } catch (com.sun.star.uno.Exception ex) {
+ ex.printStackTrace(System.err);
+ }}
+
+
+
+ /**
+ * create a peer for this
+ * dialog, using the given
+ * peer as a parent.
+ */
+ private XWindowPeer createWindowPeer(XWindowPeer _xWindowParentPeer) {
+ try{
+ if (_xWindowParentPeer == null){
+ XWindow xWindow = UnoRuntime.queryInterface(XWindow.class, m_xDlgContainer);
+ xWindow.setVisible(false);
+ Object tk = m_xMCF.createInstanceWithContext("com.sun.star.awt.Toolkit", m_xContext);
+ XToolkit xToolkit = UnoRuntime.queryInterface(XToolkit.class, tk);
+ UnoRuntime.queryInterface(XReschedule.class, xToolkit);
+ m_xDialogControl.createPeer(xToolkit, _xWindowParentPeer);
+ m_xWindowPeer = m_xDialogControl.getPeer();
+ return m_xWindowPeer;
+ }
+ } catch (com.sun.star.uno.Exception exception) {
+ exception.printStackTrace(System.err);
+ }
+ return null;
+ }
+
+
+
+
+
+
+ /**
+ * Creates a peer for this
+ * dialog, using the active OO frame
+ * as the parent window.
+ */
+ public XWindowPeer createWindowPeer() {
+ return createWindowPeer(null);
+ }
+
+
+
+
+
+
+
+ private XFixedText insertFixedText(XMouseListener _xMouseListener, int _nPosX, int _nPosY, int _nWidth, int _nStep, String _sLabel){
+ XFixedText xFixedText = null;
+ try{
+ // create a unique name by means of an own implementation...
+ String sName = createUniqueName(m_xDlgModelNameContainer, "Label");
+
+ // create a controlmodel at the multiservicefactory of the dialog model...
+ Object oFTModel = m_xMSFDialogModel.createInstance("com.sun.star.awt.UnoControlFixedTextModel");
+ XMultiPropertySet xFTModelMPSet = UnoRuntime.queryInterface(XMultiPropertySet.class, oFTModel);
+ // Set the properties at the model - keep in mind to pass the property names in alphabetical order!
+
+ xFTModelMPSet.setPropertyValues(
+ new String[] {"Height", "Name", "PositionX", "PositionY", "Step", "Width"},
+ new Object[] { Integer.valueOf(8), sName, Integer.valueOf(_nPosX), Integer.valueOf(_nPosY), Integer.valueOf(_nStep), Integer.valueOf(_nWidth)});
+ // add the model to the NameContainer of the dialog model
+ m_xDlgModelNameContainer.insertByName(sName, oFTModel);
+
+ // The following property may also be set with XMultiPropertySet but we
+ // use the XPropertySet interface merely for reasons of demonstration
+ XPropertySet xFTPSet = UnoRuntime.queryInterface(XPropertySet.class, oFTModel);
+ xFTPSet.setPropertyValue("Label", _sLabel);
+
+ // reference the control by the Name
+ XControl xFTControl = m_xDlgContainer.getControl(sName);
+ xFixedText = UnoRuntime.queryInterface(XFixedText.class, xFTControl);
+ XWindow xWindow = UnoRuntime.queryInterface(XWindow.class, xFTControl);
+ xWindow.addMouseListener(_xMouseListener);
+ } catch (com.sun.star.uno.Exception ex) {
+ /* perform individual exception handling here.
+ * Possible exception types are:
+ * com.sun.star.lang.IllegalArgumentException,
+ * com.sun.star.lang.WrappedTargetException,
+ * com.sun.star.container.ElementExistException,
+ * com.sun.star.beans.PropertyVetoException,
+ * com.sun.star.beans.UnknownPropertyException,
+ * com.sun.star.uno.Exception
+ */
+ ex.printStackTrace(System.err);
+ }
+ return xFixedText;
+ }
+
+
+ private XTextComponent insertCurrencyField(XTextListener _xTextListener, int _nPositionX, int _nPositionY, int _nWidth){
+ XTextComponent xTextComponent = null;
+ try{
+ // create a unique name by means of an own implementation...
+ String sName = createUniqueName(m_xDlgModelNameContainer, "CurrencyField");
+
+ // create a controlmodel at the multiservicefactory of the dialog model...
+ Object oCFModel = m_xMSFDialogModel.createInstance("com.sun.star.awt.UnoControlCurrencyFieldModel");
+ XMultiPropertySet xCFModelMPSet = UnoRuntime.queryInterface(XMultiPropertySet.class, oCFModel);
+
+ // Set the properties at the model - keep in mind to pass the property names in alphabetical order!
+ xCFModelMPSet.setPropertyValues(
+ new String[] {"Height", "Name", "PositionX", "PositionY", "Width"},
+ new Object[] { Integer.valueOf(12), sName, Integer.valueOf(_nPositionX), Integer.valueOf(_nPositionY), Integer.valueOf(_nWidth)});
+
+ // The controlmodel is not really available until inserted to the Dialog container
+ m_xDlgModelNameContainer.insertByName(sName, oCFModel);
+ XPropertySet xCFModelPSet = UnoRuntime.queryInterface(XPropertySet.class, oCFModel);
+
+ // The following properties may also be set with XMultiPropertySet but we
+ // use the XPropertySet interface merely for reasons of demonstration
+ xCFModelPSet.setPropertyValue("PrependCurrencySymbol", Boolean.TRUE);
+ xCFModelPSet.setPropertyValue("CurrencySymbol", "$");
+ xCFModelPSet.setPropertyValue("Value", new Double(2.93));
+
+ // add a textlistener that is notified on each change of the controlvalue...
+ Object oCFControl = m_xDlgContainer.getControl(sName);
+ xTextComponent = UnoRuntime.queryInterface(XTextComponent.class, oCFControl);
+ xTextComponent.addTextListener(_xTextListener);
+ } catch (com.sun.star.uno.Exception ex) {
+ /* perform individual exception handling here.
+ * Possible exception types are:
+ * com.sun.star.lang.IllegalArgumentException,
+ * com.sun.star.lang.WrappedTargetException,
+ * com.sun.star.container.ElementExistException,
+ * com.sun.star.beans.PropertyVetoException,
+ * com.sun.star.beans.UnknownPropertyException,
+ * com.sun.star.uno.Exception
+ */
+ ex.printStackTrace(System.err);
+ }
+ return xTextComponent;
+ }
+
+
+
+ private XPropertySet insertProgressBar(int _nPosX, int _nPosY, int _nWidth, int _nProgressMax){
+ XPropertySet xPBModelPSet = null;
+ try{
+ // create a unique name by means of an own implementation...
+ String sName = createUniqueName(m_xDlgModelNameContainer, "ProgressBar");
+
+ // create a controlmodel at the multiservicefactory of the dialog model...
+ Object oPBModel = m_xMSFDialogModel.createInstance("com.sun.star.awt.UnoControlProgressBarModel");
+
+ XMultiPropertySet xPBModelMPSet = UnoRuntime.queryInterface(XMultiPropertySet.class, oPBModel);
+ // Set the properties at the model - keep in mind to pass the property names in alphabetical order!
+ xPBModelMPSet.setPropertyValues(
+ new String[] {"Height", "Name", "PositionX", "PositionY", "Width"},
+ new Object[] { Integer.valueOf(8), sName, Integer.valueOf(_nPosX), Integer.valueOf(_nPosY), Integer.valueOf(_nWidth)});
+
+ // The controlmodel is not really available until inserted to the Dialog container
+ m_xDlgModelNameContainer.insertByName(sName, oPBModel);
+ xPBModelPSet = UnoRuntime.queryInterface(XPropertySet.class, oPBModel);
+
+ // The following properties may also be set with XMultiPropertySet but we
+ // use the XPropertySet interface merely for reasons of demonstration
+ xPBModelPSet.setPropertyValue("ProgressValueMin", Integer.valueOf(0));
+ xPBModelPSet.setPropertyValue("ProgressValueMax", Integer.valueOf(_nProgressMax));
+ } catch (com.sun.star.uno.Exception ex) {
+ /* perform individual exception handling here.
+ * Possible exception types are:
+ * com.sun.star.lang.IllegalArgumentException,
+ * com.sun.star.lang.WrappedTargetException,
+ * com.sun.star.container.ElementExistException,
+ * com.sun.star.beans.PropertyVetoException,
+ * com.sun.star.beans.UnknownPropertyException,
+ * com.sun.star.uno.Exception
+ */
+ ex.printStackTrace(System.err);
+ }
+ return xPBModelPSet;
+ }
+
+
+
+ public void insertHorizontalFixedLine(int _nPosX, int _nPosY, int _nWidth, String _sLabel){
+ try{
+ // create a unique name by means of an own implementation...
+ String sName = createUniqueName(m_xDlgModelNameContainer, "FixedLine");
+
+ // create a controlmodel at the multiservicefactory of the dialog model...
+ Object oFLModel = m_xMSFDialogModel.createInstance("com.sun.star.awt.UnoControlFixedLineModel");
+ XMultiPropertySet xFLModelMPSet = UnoRuntime.queryInterface(XMultiPropertySet.class, oFLModel);
+
+ // Set the properties at the model - keep in mind to pass the property names in alphabetical order!
+ xFLModelMPSet.setPropertyValues(
+ new String[] {"Height", "Name", "Orientation", "PositionX", "PositionY", "Width"},
+ new Object[] { Integer.valueOf(8), sName, Integer.valueOf(0), Integer.valueOf(_nPosX), Integer.valueOf(_nPosY), Integer.valueOf(_nWidth)});
+
+ // The controlmodel is not really available until inserted to the Dialog container
+ m_xDlgModelNameContainer.insertByName(sName, oFLModel);
+
+ // The following property may also be set with XMultiPropertySet but we
+ // use the XPropertySet interface merely for reasons of demonstration
+ XPropertySet xFLPSet = UnoRuntime.queryInterface(XPropertySet.class, oFLModel);
+ xFLPSet.setPropertyValue("Label", _sLabel);
+ } catch (com.sun.star.uno.Exception ex) {
+ /* perform individual exception handling here.
+ * Possible exception types are:
+ * com.sun.star.lang.IllegalArgumentException,
+ * com.sun.star.lang.WrappedTargetException,
+ * com.sun.star.container.ElementExistException,
+ * com.sun.star.beans.PropertyVetoException,
+ * com.sun.star.beans.UnknownPropertyException,
+ * com.sun.star.uno.Exception
+ */
+ ex.printStackTrace(System.err);
+ }
+ }
+
+
+
+ private void insertGroupBox(int _nPosX, int _nPosY, int _nHeight, int _nWidth){
+ try{
+ // create a unique name by means of an own implementation...
+ String sName = createUniqueName(m_xDlgModelNameContainer, "FrameControl");
+
+ // create a controlmodel at the multiservicefactory of the dialog model...
+ Object oGBModel = m_xMSFDialogModel.createInstance("com.sun.star.awt.UnoControlGroupBoxModel");
+ XMultiPropertySet xGBModelMPSet = UnoRuntime.queryInterface(XMultiPropertySet.class, oGBModel);
+
+ // Set the properties at the model - keep in mind to pass the property names in alphabetical order!
+ xGBModelMPSet.setPropertyValues(
+ new String[] {"Height", "Name", "PositionX", "PositionY", "Width"},
+ new Object[] { Integer.valueOf(_nHeight), sName, Integer.valueOf(_nPosX), Integer.valueOf(_nPosY), Integer.valueOf(_nWidth)});
+
+ // The controlmodel is not really available until inserted to the Dialog container
+ m_xDlgModelNameContainer.insertByName(sName, oGBModel);
+
+ // The following property may also be set with XMultiPropertySet but we
+ // use the XPropertySet interface merely for reasons of demonstration
+ XPropertySet xGBPSet = UnoRuntime.queryInterface(XPropertySet.class, oGBModel);
+ xGBPSet.setPropertyValue("Label", "~My GroupBox");
+ } catch (com.sun.star.uno.Exception ex) {
+ /* perform individual exception handling here.
+ * Possible exception types are:
+ * com.sun.star.lang.IllegalArgumentException,
+ * com.sun.star.lang.WrappedTargetException,
+ * com.sun.star.container.ElementExistException,
+ * com.sun.star.beans.PropertyVetoException,
+ * com.sun.star.beans.UnknownPropertyException,
+ * com.sun.star.uno.Exception
+ */
+ ex.printStackTrace(System.err);
+ }
+ }
+
+
+
+ private XTextComponent insertEditField(XTextListener _xTextListener, XFocusListener _xFocusListener, int _nPosX, int _nPosY, int _nWidth){
+ XTextComponent xTextComponent = null;
+ try{
+ // create a unique name by means of an own implementation...
+ String sName = createUniqueName(m_xDlgModelNameContainer, "TextField");
+
+ // create a controlmodel at the multiservicefactory of the dialog model...
+ Object oTFModel = m_xMSFDialogModel.createInstance("com.sun.star.awt.UnoControlEditModel");
+ XMultiPropertySet xTFModelMPSet = UnoRuntime.queryInterface(XMultiPropertySet.class, oTFModel);
+
+ // Set the properties at the model - keep in mind to pass the property names in alphabetical order!
+ xTFModelMPSet.setPropertyValues(
+ new String[] {"Height", "Name", "PositionX", "PositionY", "Text", "Width"},
+ new Object[] { Integer.valueOf(12), sName, Integer.valueOf(_nPosX), Integer.valueOf(_nPosY), "MyText", Integer.valueOf(_nWidth)});
+
+ // The controlmodel is not really available until inserted to the Dialog container
+ m_xDlgModelNameContainer.insertByName(sName, oTFModel);
+ XPropertySet xTFModelPSet = UnoRuntime.queryInterface(XPropertySet.class, oTFModel);
+
+ // The following property may also be set with XMultiPropertySet but we
+ // use the XPropertySet interface merely for reasons of demonstration
+ xTFModelPSet.setPropertyValue("EchoChar", Short.valueOf((short) '*'));
+ XControl xTFControl = m_xDlgContainer.getControl(sName);
+
+ // add a textlistener that is notified on each change of the controlvalue...
+ xTextComponent = UnoRuntime.queryInterface(XTextComponent.class, xTFControl);
+ XWindow xTFWindow = UnoRuntime.queryInterface(XWindow.class, xTFControl);
+ xTFWindow.addFocusListener(_xFocusListener);
+ xTextComponent.addTextListener(_xTextListener);
+ xTFWindow.addKeyListener(this);
+ } catch (com.sun.star.uno.Exception ex) {
+ /* perform individual exception handling here.
+ * Possible exception types are:
+ * com.sun.star.lang.IllegalArgumentException,
+ * com.sun.star.lang.WrappedTargetException,
+ * com.sun.star.container.ElementExistException,
+ * com.sun.star.beans.PropertyVetoException,
+ * com.sun.star.beans.UnknownPropertyException,
+ * com.sun.star.uno.Exception
+ */
+ ex.printStackTrace(System.err);
+ }
+ return xTextComponent;
+ }
+
+ private XPropertySet insertTimeField(int _nPosX, int _nPosY, int _nWidth, Time _aTime, Time _aTimeMin, Time _aTimeMax){
+ XPropertySet xTFModelPSet = null;
+ try{
+ // create a unique name by means of an own implementation...
+ String sName = createUniqueName(m_xDlgModelNameContainer, "TimeField");
+
+ // create a controlmodel at the multiservicefactory of the dialog model...
+ Object oTFModel = m_xMSFDialogModel.createInstance("com.sun.star.awt.UnoControlTimeFieldModel");
+ XMultiPropertySet xTFModelMPSet = UnoRuntime.queryInterface(XMultiPropertySet.class, oTFModel);
+
+ // Set the properties at the model - keep in mind to pass the property names in alphabetical order!
+ xTFModelMPSet.setPropertyValues(
+ new String[] {"Height", "Name", "PositionX", "PositionY", "Spin", "Width"},
+ new Object[] { Integer.valueOf(12), sName, Integer.valueOf(_nPosX), Integer.valueOf(_nPosY), Boolean.TRUE, Integer.valueOf(_nWidth)});
+
+ // The controlmodel is not really available until inserted to the Dialog container
+ m_xDlgModelNameContainer.insertByName(sName, oTFModel);
+ xTFModelPSet = UnoRuntime.queryInterface(XPropertySet.class, oTFModel);
+
+ // The following properties may also be set with XMultiPropertySet but we
+ // use the XPropertySet interface merely for reasons of demonstration
+ xTFModelPSet.setPropertyValue("TimeFormat", Short.valueOf((short) 5));
+ xTFModelPSet.setPropertyValue("TimeMin", _aTimeMin);
+ xTFModelPSet.setPropertyValue("TimeMax", _aTimeMax);
+ xTFModelPSet.setPropertyValue("Time", _aTime);
+ } catch (com.sun.star.uno.Exception ex) {
+ /* perform individual exception handling here.
+ * Possible exception types are:
+ * com.sun.star.lang.IllegalArgumentException,
+ * com.sun.star.lang.WrappedTargetException,
+ * com.sun.star.container.ElementExistException,
+ * com.sun.star.beans.PropertyVetoException,
+ * com.sun.star.beans.UnknownPropertyException,
+ * com.sun.star.uno.Exception
+ */
+ ex.printStackTrace(System.err);
+ }
+ return xTFModelPSet;
+ }
+
+
+
+ private XPropertySet insertDateField(XSpinListener _xSpinListener, int _nPosX, int _nPosY, int _nWidth){
+ XPropertySet xDFModelPSet = null;
+ try{
+ // create a unique name by means of an own implementation...
+ String sName = createUniqueName(m_xDlgModelNameContainer, "DateField");
+
+ // create a controlmodel at the multiservicefactory of the dialog model...
+ Object oDFModel = m_xMSFDialogModel.createInstance("com.sun.star.awt.UnoControlDateFieldModel");
+ XMultiPropertySet xDFModelMPSet = UnoRuntime.queryInterface(XMultiPropertySet.class, oDFModel);
+
+ // Set the properties at the model - keep in mind to pass the property names in alphabetical order!
+ xDFModelMPSet.setPropertyValues(
+ new String[] {"Dropdown", "Height", "Name", "PositionX", "PositionY", "Width"},
+ new Object[] {Boolean.TRUE, Integer.valueOf(12), sName, Integer.valueOf(_nPosX), Integer.valueOf(_nPosY), Integer.valueOf(_nWidth)});
+
+ // The controlmodel is not really available until inserted to the Dialog container
+ m_xDlgModelNameContainer.insertByName(sName, oDFModel);
+ xDFModelPSet = UnoRuntime.queryInterface(XPropertySet.class, oDFModel);
+
+ // The following properties may also be set with XMultiPropertySet but we
+ // use the XPropertySet interface merely for reasons of demonstration
+ xDFModelPSet.setPropertyValue("DateFormat", Short.valueOf((short) 7));
+ xDFModelPSet.setPropertyValue("DateMin", new Date((short)1, (short)4, (short)2007));
+ xDFModelPSet.setPropertyValue("DateMax", new Date((short)1, (short)5, (short)2007));
+ xDFModelPSet.setPropertyValue("Date", new Date((short)15, (short)4, (short)2000));
+ Object oDFControl = m_xDlgContainer.getControl(sName);
+
+ // add a SpinListener that is notified on each change of the controlvalue...
+ XSpinField xSpinField = UnoRuntime.queryInterface(XSpinField.class, oDFControl);
+ xSpinField.addSpinListener(_xSpinListener);
+ } catch (com.sun.star.uno.Exception ex) {
+ /* perform individual exception handling here.
+ * Possible exception types are:
+ * com.sun.star.lang.IllegalArgumentException,
+ * com.sun.star.lang.WrappedTargetException,
+ * com.sun.star.container.ElementExistException,
+ * com.sun.star.beans.PropertyVetoException,
+ * com.sun.star.beans.UnknownPropertyException,
+ * com.sun.star.uno.Exception
+ */
+ ex.printStackTrace(System.err);
+ }
+ return xDFModelPSet;
+ }
+
+
+ private XPropertySet insertPatternField(int _nPosX, int _nPosY, int _nWidth){
+ XPropertySet xPFModelPSet = null;
+ try{
+ // create a unique name by means of an own implementation...
+ String sName = createUniqueName(m_xDlgModelNameContainer, "PatternField");
+
+ // create a controlmodel at the multiservicefactory of the dialog model...
+ Object oPFModel = m_xMSFDialogModel.createInstance("com.sun.star.awt.UnoControlPatternFieldModel");
+ XMultiPropertySet xPFModelMPSet = UnoRuntime.queryInterface(XMultiPropertySet.class, oPFModel);
+
+ // Set the properties at the model - keep in mind to pass the property names in alphabetical order!
+ xPFModelMPSet.setPropertyValues(
+ new String[] {"Height", "Name", "PositionX", "PositionY", "Width"},
+ new Object[] { Integer.valueOf(12), sName, Integer.valueOf(_nPosX), Integer.valueOf(_nPosY), Integer.valueOf(_nWidth)});
+
+ // The controlmodel is not really available until inserted to the Dialog container
+ m_xDlgModelNameContainer.insertByName(sName, oPFModel);
+ xPFModelPSet = UnoRuntime.queryInterface(XPropertySet.class, oPFModel);
+
+ // The following properties may also be set with XMultiPropertySet but we
+ // use the XPropertySet interface merely for reasons of demonstration
+ xPFModelPSet.setPropertyValue("LiteralMask", "__.05.2007");
+ // Allow only numbers for the first two digits...
+ xPFModelPSet.setPropertyValue("EditMask", "NNLLLLLLLL");
+ // verify the user input immediately...
+ xPFModelPSet.setPropertyValue("StrictFormat", Boolean.TRUE);
+ } catch (com.sun.star.uno.Exception ex) {
+ /* perform individual exception handling here.
+ * Possible exception types are:
+ * com.sun.star.lang.IllegalArgumentException,
+ * com.sun.star.lang.WrappedTargetException,
+ * com.sun.star.container.ElementExistException,
+ * com.sun.star.beans.PropertyVetoException,
+ * com.sun.star.beans.UnknownPropertyException,
+ * com.sun.star.uno.Exception
+ */
+ ex.printStackTrace(System.err);
+ }
+ return xPFModelPSet;
+ }
+
+
+ private XPropertySet insertNumericField( int _nPosX, int _nPosY, int _nWidth,
+ double _fValueMin, double _fValueMax, double _fValue,
+ double _fValueStep, short _nDecimalAccuracy){
+ XPropertySet xNFModelPSet = null;
+ try{
+ // create a unique name by means of an own implementation...
+ String sName = createUniqueName(m_xDlgModelNameContainer, "NumericField");
+
+ // create a controlmodel at the multiservicefactory of the dialog model...
+ Object oNFModel = m_xMSFDialogModel.createInstance("com.sun.star.awt.UnoControlNumericFieldModel");
+ XMultiPropertySet xNFModelMPSet = UnoRuntime.queryInterface(XMultiPropertySet.class, oNFModel);
+ // Set the properties at the model - keep in mind to pass the property names in alphabetical order!
+ xNFModelMPSet.setPropertyValues(
+ new String[] {"Height", "Name", "PositionX", "PositionY", "Spin", "StrictFormat", "Width"},
+ new Object[] { Integer.valueOf(12), sName, Integer.valueOf(_nPosX), Integer.valueOf(_nPosY), Boolean.TRUE, Boolean.TRUE, Integer.valueOf(_nWidth)});
+
+ // The controlmodel is not really available until inserted to the Dialog container
+ m_xDlgModelNameContainer.insertByName(sName, oNFModel);
+ xNFModelPSet = UnoRuntime.queryInterface(XPropertySet.class, oNFModel);
+ // The following properties may also be set with XMultiPropertySet but we
+ // use the XPropertySet interface merely for reasons of demonstration
+ xNFModelPSet.setPropertyValue("ValueMin", new Double(_fValueMin));
+ xNFModelPSet.setPropertyValue("ValueMax", new Double(_fValueMax));
+ xNFModelPSet.setPropertyValue("Value", new Double(_fValue));
+ xNFModelPSet.setPropertyValue("ValueStep", new Double(_fValueStep));
+ xNFModelPSet.setPropertyValue("ShowThousandsSeparator", Boolean.TRUE);
+ xNFModelPSet.setPropertyValue("DecimalAccuracy", Short.valueOf(_nDecimalAccuracy));
+ } catch (com.sun.star.uno.Exception ex) {
+ /* perform individual exception handling here.
+ * Possible exception types are:
+ * com.sun.star.lang.IllegalArgumentException,
+ * com.sun.star.lang.WrappedTargetException,
+ * com.sun.star.container.ElementExistException,
+ * com.sun.star.beans.PropertyVetoException,
+ * com.sun.star.beans.UnknownPropertyException,
+ * com.sun.star.uno.Exception
+ */
+ ex.printStackTrace(System.err);
+ }
+ return xNFModelPSet;
+ }
+
+
+
+ private XPropertySet insertVerticalScrollBar(XAdjustmentListener _xAdjustmentListener, int _nPosX, int _nPosY, int _nHeight){
+ XPropertySet xSBModelPSet = null;
+ try{
+ // create a unique name by means of an own implementation...
+ String sName = createUniqueName(m_xDlgModelNameContainer, "ScrollBar");
+
+ Integer NOrientation = Integer.valueOf(com.sun.star.awt.ScrollBarOrientation.VERTICAL);
+
+ // create a controlmodel at the multiservicefactory of the dialog model...
+ Object oSBModel = m_xMSFDialogModel.createInstance("com.sun.star.awt.UnoControlScrollBarModel");
+ XMultiPropertySet xSBModelMPSet = UnoRuntime.queryInterface(XMultiPropertySet.class, oSBModel);
+ // Set the properties at the model - keep in mind to pass the property names in alphabetical order!
+ xSBModelMPSet.setPropertyValues(
+ new String[] {"Height", "Name", "Orientation", "PositionX", "PositionY", "Width"},
+ new Object[] { Integer.valueOf(_nHeight), sName, NOrientation, Integer.valueOf(_nPosX), Integer.valueOf(_nPosY), Integer.valueOf(8)});
+
+ // The controlmodel is not really available until inserted to the Dialog container
+ m_xDlgModelNameContainer.insertByName(sName, oSBModel);
+
+ xSBModelPSet = UnoRuntime.queryInterface(XPropertySet.class, oSBModel);
+ // The following properties may also be set with XMultiPropertySet but we
+ // use the XPropertySet interface merely for reasons of demonstration
+ xSBModelPSet.setPropertyValue("ScrollValueMin", Integer.valueOf(0));
+ xSBModelPSet.setPropertyValue("ScrollValueMax", Integer.valueOf(100));
+ xSBModelPSet.setPropertyValue("ScrollValue", Integer.valueOf(5));
+ xSBModelPSet.setPropertyValue("LineIncrement", Integer.valueOf(2));
+ xSBModelPSet.setPropertyValue("BlockIncrement", Integer.valueOf(10));
+
+ // Add an Adjustment that will listen to changes of the scrollbar...
+ XControl xSBControl = m_xDlgContainer.getControl(sName);
+ XScrollBar xScrollBar = UnoRuntime.queryInterface(XScrollBar.class, xSBControl);
+ xScrollBar.addAdjustmentListener(_xAdjustmentListener);
+ } catch (com.sun.star.uno.Exception ex) {
+ /* perform individual exception handling here.
+ * Possible exception types are:
+ * com.sun.star.lang.IllegalArgumentException,
+ * com.sun.star.lang.WrappedTargetException,
+ * com.sun.star.container.ElementExistException,
+ * com.sun.star.beans.PropertyVetoException,
+ * com.sun.star.beans.UnknownPropertyException,
+ * com.sun.star.uno.Exception
+ */
+ ex.printStackTrace(System.err);
+ }
+ return xSBModelPSet;
+ }
+
+
+ /** makes a String unique by appending a numerical suffix
+ * @param _xElementContainer the com.sun.star.container.XNameAccess container
+ * that the new Element is going to be inserted to
+ * @param _sElementName the StemName of the Element
+ */
+ public static String createUniqueName(XNameAccess _xElementContainer, String _sElementName) {
+ boolean bElementexists = true;
+ int i = 1;
+ String BaseName = _sElementName;
+ while (bElementexists) {
+ bElementexists = _xElementContainer.hasByName(_sElementName);
+ if (bElementexists) {
+ i += 1;
+ _sElementName = BaseName + Integer.toString(i);
+ }
+ }
+ return _sElementName;
+ }
+
+
+ private XCheckBox insertCheckBox(XItemListener _xItemListener, int _nPosX, int _nPosY, int _nWidth){
+ XCheckBox xCheckBox = null;
+ try{
+ // create a unique name by means of an own implementation...
+ String sName = createUniqueName(m_xDlgModelNameContainer, "CheckBox");
+
+ // create a controlmodel at the multiservicefactory of the dialog model...
+ Object oCBModel = m_xMSFDialogModel.createInstance("com.sun.star.awt.UnoControlCheckBoxModel");
+
+ // Set the properties at the model - keep in mind to pass the property names in alphabetical order!
+ XMultiPropertySet xCBMPSet = UnoRuntime.queryInterface(XMultiPropertySet.class, oCBModel);
+ xCBMPSet.setPropertyValues(
+ new String[] {"Height", "Label", "Name", "PositionX", "PositionY", "Width" } ,
+ new Object[] {Integer.valueOf(8), "~Include page number", sName, Integer.valueOf(_nPosX), Integer.valueOf(_nPosY), Integer.valueOf(_nWidth)});
+
+ // The following property may also be set with XMultiPropertySet but we
+ // use the XPropertySet interface merely for reasons of demonstration
+ XPropertySet xCBModelPSet = UnoRuntime.queryInterface(XPropertySet.class, xCBMPSet);
+ xCBModelPSet.setPropertyValue("TriState", Boolean.TRUE);
+ xCBModelPSet.setPropertyValue("State", Short.valueOf((short) 1));
+
+ // add the model to the NameContainer of the dialog model
+ m_xDlgModelNameContainer.insertByName(sName, oCBModel);
+ XControl xCBControl = m_xDlgContainer.getControl(sName);
+ xCheckBox = UnoRuntime.queryInterface(XCheckBox.class, xCBControl);
+ // An ActionListener will be notified on the activation of the button...
+ xCheckBox.addItemListener(_xItemListener);
+ } catch (com.sun.star.uno.Exception ex) {
+ /* perform individual exception handling here.
+ * Possible exception types are:
+ * com.sun.star.lang.IllegalArgumentException,
+ * com.sun.star.lang.WrappedTargetException,
+ * com.sun.star.container.ElementExistException,
+ * com.sun.star.beans.PropertyVetoException,
+ * com.sun.star.beans.UnknownPropertyException,
+ * com.sun.star.uno.Exception
+ */
+ ex.printStackTrace(System.err);
+ }
+ return xCheckBox;
+ }
+
+
+
+
+ private void insertRadioButtonGroup(short _nTabIndex, int _nPosX, int _nPosY, int _nWidth){
+ try{
+ // create a unique name by means of an own implementation...
+ String sName = createUniqueName(m_xDlgModelNameContainer, "OptionButton");
+
+ // create a controlmodel at the multiservicefactory of the dialog model...
+ Object oRBModel = m_xMSFDialogModel.createInstance("com.sun.star.awt.UnoControlRadioButtonModel");
+ XMultiPropertySet xRBMPSet = UnoRuntime.queryInterface(XMultiPropertySet.class, oRBModel);
+ // Set the properties at the model - keep in mind to pass the property names in alphabetical order!
+ xRBMPSet.setPropertyValues(
+ new String[] {"Height", "Label", "Name", "PositionX", "PositionY", "State", "TabIndex", "Width" } ,
+ new Object[] {Integer.valueOf(8), "~First Option", sName, Integer.valueOf(_nPosX), Integer.valueOf(_nPosY), Short.valueOf((short) 1), Short.valueOf(_nTabIndex++),Integer.valueOf(_nWidth)});
+ // add the model to the NameContainer of the dialog model
+ m_xDlgModelNameContainer.insertByName(sName, oRBModel);
+
+ // create a unique name by means of an own implementation...
+ sName = createUniqueName(m_xDlgModelNameContainer, "OptionButton");
+
+ oRBModel = m_xMSFDialogModel.createInstance("com.sun.star.awt.UnoControlRadioButtonModel");
+ xRBMPSet = UnoRuntime.queryInterface(XMultiPropertySet.class, oRBModel);
+ // Set the properties at the model - keep in mind to pass the property names in alphabetical order!
+ xRBMPSet.setPropertyValues(
+ new String[] {"Height", "Label", "Name", "PositionX", "PositionY", "TabIndex", "Width" } ,
+ new Object[] {Integer.valueOf(8), "~Second Option", sName, Integer.valueOf(130), Integer.valueOf(214), Short.valueOf(_nTabIndex), Integer.valueOf(150)});
+ // add the model to the NameContainer of the dialog model
+ m_xDlgModelNameContainer.insertByName(sName, oRBModel);
+ } catch (com.sun.star.uno.Exception ex) {
+ /* perform individual exception handling here.
+ * Possible exception types are:
+ * com.sun.star.lang.IllegalArgumentException,
+ * com.sun.star.lang.WrappedTargetException,
+ * com.sun.star.container.ElementExistException,
+ * com.sun.star.beans.PropertyVetoException,
+ * com.sun.star.beans.UnknownPropertyException,
+ * com.sun.star.uno.Exception
+ */
+ ex.printStackTrace(System.err);
+ }
+ }
+
+
+ private XListBox insertListBox(int _nPosX, int _nPosY, int _nWidth, int _nStep, String[] _sStringItemList){
+ XListBox xListBox = null;
+ try{
+ // create a unique name by means of an own implementation...
+ String sName = createUniqueName(m_xDlgModelNameContainer, "ListBox");
+
+ // create a controlmodel at the multiservicefactory of the dialog model...
+ Object oListBoxModel = m_xMSFDialogModel.createInstance("com.sun.star.awt.UnoControlListBoxModel");
+ XMultiPropertySet xLBModelMPSet = UnoRuntime.queryInterface(XMultiPropertySet.class, oListBoxModel);
+ // Set the properties at the model - keep in mind to pass the property names in alphabetical order!
+ xLBModelMPSet.setPropertyValues(
+ new String[] {"Dropdown", "Height", "Name", "PositionX", "PositionY", "Step", "StringItemList", "Width" } ,
+ new Object[] {Boolean.TRUE, Integer.valueOf(12), sName, Integer.valueOf(_nPosX), Integer.valueOf(_nPosY), Integer.valueOf(_nStep), _sStringItemList, Integer.valueOf(_nWidth)});
+ // The following property may also be set with XMultiPropertySet but we
+ // use the XPropertySet interface merely for reasons of demonstration
+ XPropertySet xLBModelPSet = UnoRuntime.queryInterface(XPropertySet.class, xLBModelMPSet);
+ xLBModelPSet.setPropertyValue("MultiSelection", Boolean.TRUE);
+ short[] nSelItems = new short[] {(short) 1, (short) 3};
+ xLBModelPSet.setPropertyValue("SelectedItems", nSelItems);
+ // add the model to the NameContainer of the dialog model
+ m_xDlgModelNameContainer.insertByName(sName, xLBModelMPSet);
+ XControl xControl = m_xDlgContainer.getControl(sName);
+ // retrieve a ListBox that is more convenient to work with than the Model of the ListBox...
+ xListBox = UnoRuntime.queryInterface(XListBox.class, xControl);
+ } catch (com.sun.star.uno.Exception ex) {
+ /* perform individual exception handling here.
+ * Possible exception types are:
+ * com.sun.star.lang.IllegalArgumentException,
+ * com.sun.star.lang.WrappedTargetException,
+ * com.sun.star.container.ElementExistException,
+ * com.sun.star.beans.PropertyVetoException,
+ * com.sun.star.beans.UnknownPropertyException,
+ * com.sun.star.uno.Exception
+ */
+ ex.printStackTrace(System.err);
+ }
+ return xListBox;
+ }
+
+
+ private XComboBox insertComboBox(int _nPosX, int _nPosY, int _nWidth){
+ XComboBox xComboBox = null;
+ try{
+ // create a unique name by means of an own implementation...
+ String sName = createUniqueName(m_xDlgModelNameContainer, "ComboBox");
+
+ String[] sStringItemList = new String[]{"First Entry", "Second Entry", "Third Entry", "Fourth Entry"};
+
+ // create a controlmodel at the multiservicefactory of the dialog model...
+ Object oComboBoxModel = m_xMSFDialogModel.createInstance("com.sun.star.awt.UnoControlComboBoxModel");
+ XMultiPropertySet xCbBModelMPSet = UnoRuntime.queryInterface(XMultiPropertySet.class, oComboBoxModel);
+ // Set the properties at the model - keep in mind to pass the property names in alphabetical order!
+ xCbBModelMPSet.setPropertyValues(
+ new String[] {"Dropdown", "Height", "Name", "PositionX", "PositionY", "StringItemList", "Width" } ,
+ new Object[] {Boolean.TRUE, Integer.valueOf(12), sName, Integer.valueOf(_nPosX), Integer.valueOf(_nPosY), sStringItemList, Integer.valueOf(_nWidth)});
+
+ // The following property may also be set with XMultiPropertySet but we
+ // use the XPropertySet interface merely for reasons of demonstration
+ XPropertySet xCbBModelPSet = UnoRuntime.queryInterface(XPropertySet.class, xCbBModelMPSet);
+ xCbBModelPSet.setPropertyValue("MaxTextLen", Short.valueOf((short) 10));
+ xCbBModelPSet.setPropertyValue("ReadOnly", Boolean.FALSE);
+
+ // add the model to the NameContainer of the dialog model
+ m_xDlgModelNameContainer.insertByName(sName, xCbBModelMPSet);
+ XControl xControl = m_xDlgContainer.getControl(sName);
+
+ // retrieve a ListBox that is more convenient to work with than the Model of the ListBox...
+ xComboBox = UnoRuntime.queryInterface(XComboBox.class, xControl);
+ } catch (com.sun.star.uno.Exception ex) {
+ /* perform individual exception handling here.
+ * Possible exception types are:
+ * com.sun.star.lang.IllegalArgumentException,
+ * com.sun.star.lang.WrappedTargetException,
+ * com.sun.star.container.ElementExistException,
+ * com.sun.star.beans.PropertyVetoException,
+ * com.sun.star.beans.UnknownPropertyException,
+ * com.sun.star.uno.Exception
+ */
+ ex.printStackTrace(System.err);
+ }
+ return xComboBox;
+ }
+
+
+
+ private XPropertySet insertFormattedField(XSpinListener _xSpinListener, int _nPosX, int _nPosY, int _nWidth){
+ XPropertySet xFFModelPSet = null;
+ try{
+ // create a unique name by means of an own implementation...
+ String sName = createUniqueName(m_xDlgModelNameContainer, "FormattedField");
+
+ // create a controlmodel at the multiservicefactory of the dialog model...
+ Object oFFModel = m_xMSFDialogModel.createInstance("com.sun.star.awt.UnoControlFormattedFieldModel");
+ XMultiPropertySet xFFModelMPSet = UnoRuntime.queryInterface(XMultiPropertySet.class, oFFModel);
+ // Set the properties at the model - keep in mind to pass the property names in alphabetical order!
+ xFFModelMPSet.setPropertyValues(
+ new String[] {"EffectiveValue", "Height", "Name", "PositionX", "PositionY", "StrictFormat", "Spin", "Width"},
+ new Object[] { new Double(12348), Integer.valueOf(12), sName, Integer.valueOf(_nPosX), Integer.valueOf(_nPosY), Boolean.TRUE, Boolean.TRUE, Integer.valueOf(_nWidth)});
+
+ xFFModelPSet = UnoRuntime.queryInterface(XPropertySet.class, oFFModel);
+ // to define a numberformat you always need a locale...
+ com.sun.star.lang.Locale aLocale = new com.sun.star.lang.Locale();
+ aLocale.Country = "US";
+ aLocale.Language = "en";
+ // this Format is only compliant to the english locale!
+ String sFormatString = "NNNNMMMM DD, YYYY";
+
+ // a NumberFormatsSupplier has to be created first "in the open countryside"...
+ Object oNumberFormatsSupplier = m_xMCF.createInstanceWithContext("com.sun.star.util.NumberFormatsSupplier", m_xContext);
+ XNumberFormatsSupplier xNumberFormatsSupplier = UnoRuntime.queryInterface(XNumberFormatsSupplier.class, oNumberFormatsSupplier);
+ XNumberFormats xNumberFormats = xNumberFormatsSupplier.getNumberFormats();
+ // is the numberformat already defined?
+ int nFormatKey = xNumberFormats.queryKey(sFormatString, aLocale, true);
+ if (nFormatKey == -1){
+ // if not then add it to the NumberFormatsSupplier
+ nFormatKey = xNumberFormats.addNew(sFormatString, aLocale);
+ }
+
+ // The following property may also be set with XMultiPropertySet but we
+ // use the XPropertySet interface merely for reasons of demonstration
+ xFFModelPSet.setPropertyValue("FormatsSupplier", xNumberFormatsSupplier);
+ xFFModelPSet.setPropertyValue("FormatKey", Integer.valueOf(nFormatKey));
+
+ // The controlmodel is not really available until inserted to the Dialog container
+ m_xDlgModelNameContainer.insertByName(sName, oFFModel);
+
+ // finally we add a Spin-Listener to the control
+ XControl xFFControl = m_xDlgContainer.getControl(sName);
+ // add a SpinListener that is notified on each change of the controlvalue...
+ XSpinField xSpinField = UnoRuntime.queryInterface(XSpinField.class, xFFControl);
+ xSpinField.addSpinListener(_xSpinListener);
+
+ } catch (com.sun.star.uno.Exception ex) {
+ /* perform individual exception handling here.
+ * Possible exception types are:
+ * com.sun.star.lang.IllegalArgumentException,
+ * com.sun.star.lang.WrappedTargetException,
+ * com.sun.star.container.ElementExistException,
+ * com.sun.star.beans.PropertyVetoException,
+ * com.sun.star.beans.UnknownPropertyException,
+ * com.sun.star.uno.Exception
+ */
+ ex.printStackTrace(System.err);
+ }
+ return xFFModelPSet;
+ }
+
+
+
+
+ private XTextComponent insertFileControl(XTextListener _xTextListener, int _nPosX, int _nPosY, int _nWidth){
+ XTextComponent xTextComponent = null;
+ try{
+ // create a unique name by means of an own implementation...
+ String sName = createUniqueName(m_xDlgModelNameContainer, "FileControl");
+
+ // retrieve the configured Work path...
+ Object oPathSettings = thePathSettings.get(m_xContext);
+ XPropertySet xPropertySet = com.sun.star.uno.UnoRuntime.queryInterface(XPropertySet.class, oPathSettings);
+ String sWorkUrl = (String) xPropertySet.getPropertyValue("Work");
+
+ // convert the Url to a system path that is "human readable"...
+ Object oFCProvider = m_xMCF.createInstanceWithContext("com.sun.star.ucb.FileContentProvider", m_xContext);
+ XFileIdentifierConverter xFileIdentifierConverter = UnoRuntime.queryInterface(XFileIdentifierConverter.class, oFCProvider);
+ String sSystemWorkPath = xFileIdentifierConverter.getSystemPathFromFileURL(sWorkUrl);
+
+ // create a controlmodel at the multiservicefactory of the dialog model...
+ Object oFCModel = m_xMSFDialogModel.createInstance("com.sun.star.awt.UnoControlFileControlModel");
+
+ // Set the properties at the model - keep in mind to pass the property names in alphabetical order!
+ XMultiPropertySet xFCModelMPSet = UnoRuntime.queryInterface(XMultiPropertySet.class, oFCModel);
+ xFCModelMPSet.setPropertyValues(
+ new String[] {"Height", "Name", "PositionX", "PositionY", "Text", "Width"},
+ new Object[] { Integer.valueOf(14), sName, Integer.valueOf(_nPosX), Integer.valueOf(_nPosY), sSystemWorkPath, Integer.valueOf(_nWidth)});
+
+ // The controlmodel is not really available until inserted to the Dialog container
+ m_xDlgModelNameContainer.insertByName(sName, oFCModel);
+ XPropertySet xFCModelPSet = UnoRuntime.queryInterface(XPropertySet.class, oFCModel);
+
+ // add a textlistener that is notified on each change of the controlvalue...
+ XControl xFCControl = m_xDlgContainer.getControl(sName);
+ xTextComponent = UnoRuntime.queryInterface(XTextComponent.class, xFCControl);
+ XWindow xFCWindow = UnoRuntime.queryInterface(XWindow.class, xFCControl);
+ xTextComponent.addTextListener(_xTextListener);
+ } catch (com.sun.star.uno.Exception ex) {
+ /* perform individual exception handling here.
+ * Possible exception types are:
+ * com.sun.star.lang.IllegalArgumentException,
+ * com.sun.star.lang.WrappedTargetException,
+ * com.sun.star.container.ElementExistException,
+ * com.sun.star.beans.PropertyVetoException,
+ * com.sun.star.beans.UnknownPropertyException,
+ * com.sun.star.uno.Exception
+ */
+ ex.printStackTrace(System.err);
+ }
+ return xTextComponent;
+ }
+
+
+ public XButton insertButton(XActionListener _xActionListener, int _nPosX, int _nPosY, int _nWidth, String _sLabel, short _nPushButtonType){
+ XButton xButton = null;
+ try{
+ // create a unique name by means of an own implementation...
+ String sName = createUniqueName(m_xDlgModelNameContainer, "CommandButton");
+
+ // create a controlmodel at the multiservicefactory of the dialog model...
+ Object oButtonModel = m_xMSFDialogModel.createInstance("com.sun.star.awt.UnoControlButtonModel");
+ XMultiPropertySet xButtonMPSet = UnoRuntime.queryInterface(XMultiPropertySet.class, oButtonModel);
+ // Set the properties at the model - keep in mind to pass the property names in alphabetical order!
+ xButtonMPSet.setPropertyValues(
+ new String[] {"Height", "Label", "Name", "PositionX", "PositionY", "PushButtonType", "Width" } ,
+ new Object[] {Integer.valueOf(14), _sLabel, sName, Integer.valueOf(_nPosX), Integer.valueOf(_nPosY), Short.valueOf(_nPushButtonType), Integer.valueOf(_nWidth)});
+
+ // add the model to the NameContainer of the dialog model
+ m_xDlgModelNameContainer.insertByName(sName, oButtonModel);
+ XControl xButtonControl = m_xDlgContainer.getControl(sName);
+ xButton = UnoRuntime.queryInterface(XButton.class, xButtonControl);
+ // An ActionListener will be notified on the activation of the button...
+ xButton.addActionListener(_xActionListener);
+ } catch (com.sun.star.uno.Exception ex) {
+ /* perform individual exception handling here.
+ * Possible exception types are:
+ * com.sun.star.lang.IllegalArgumentException,
+ * com.sun.star.lang.WrappedTargetException,
+ * com.sun.star.container.ElementExistException,
+ * com.sun.star.beans.PropertyVetoException,
+ * com.sun.star.beans.UnknownPropertyException,
+ * com.sun.star.uno.Exception
+ */
+ ex.printStackTrace(System.err);
+ }
+ return xButton;
+ }
+
+
+
+ public XFrame getCurrentFrame(){
+ XFrame xRetFrame = null;
+ try {
+ Object oDesktop = m_xMCF.createInstanceWithContext("com.sun.star.frame.Desktop", m_xContext);
+ XDesktop xDesktop = UnoRuntime.queryInterface(XDesktop.class, oDesktop);
+ xRetFrame = xDesktop.getCurrentFrame();
+ } catch (com.sun.star.uno.Exception ex) {
+ ex.printStackTrace();
+ }
+ return xRetFrame;
+ }
+
+
+ public void textChanged(TextEvent textEvent) {
+ try {
+ // get the control that has fired the event,
+ XControl xControl = UnoRuntime.queryInterface(XControl.class, textEvent.Source);
+ XControlModel xControlModel = xControl.getModel();
+ XPropertySet xPSet = UnoRuntime.queryInterface(XPropertySet.class, xControlModel);
+ String sName = (String) xPSet.getPropertyValue("Name");
+ // just in case the listener has been added to several controls,
+ // we make sure we refer to the right one
+ if (sName.equals("TextField1")){
+ String sText = (String) xPSet.getPropertyValue("Text");
+ System.out.println(sText);
+ // insert your code here to validate the text of the control...
+ }
+ }catch (com.sun.star.uno.Exception ex){
+ /* perform individual exception handling here.
+ * Possible exception types are:
+ * com.sun.star.lang.WrappedTargetException,
+ * com.sun.star.beans.UnknownPropertyException,
+ * com.sun.star.uno.Exception
+ */
+ ex.printStackTrace(System.err);
+ }
+ }
+
+
+
+ public void up(SpinEvent spinEvent) {
+ try {
+ // get the control that has fired the event,
+ XControl xControl = UnoRuntime.queryInterface(XControl.class, spinEvent.Source);
+ XControlModel xControlModel = xControl.getModel();
+ XPropertySet xPSet = UnoRuntime.queryInterface(XPropertySet.class, xControlModel);
+ String sName = (String) xPSet.getPropertyValue("Name");
+ // just in case the listener has been added to several controls,
+ // we make sure we refer to the right one
+ if (sName.equals("FormattedField1")){
+ double fvalue = AnyConverter.toDouble(xPSet.getPropertyValue("EffectiveValue"));
+ System.out.println("Controlvalue: " + fvalue);
+ // insert your code here to validate the value of the control...
+ }
+ }catch (com.sun.star.uno.Exception ex){
+ /* perform individual exception handling here.
+ * Possible exception types are:
+ * com.sun.star.lang.WrappedTargetException,
+ * com.sun.star.beans.UnknownPropertyException,
+ * com.sun.star.uno.Exception
+ */
+ ex.printStackTrace(System.err);
+ }
+ }
+
+
+ public void down(SpinEvent spinEvent) {
+ }
+
+ public void last(SpinEvent spinEvent) {
+ }
+
+ public void first(SpinEvent spinEvent) {
+ }
+
+ public void disposing(EventObject rEventObject) {
+ }
+
+
+ public void actionPerformed(ActionEvent rEvent) {
+ try{
+ // get the control that has fired the event,
+ XControl xControl = UnoRuntime.queryInterface(XControl.class, rEvent.Source);
+ XControlModel xControlModel = xControl.getModel();
+ XPropertySet xPSet = UnoRuntime.queryInterface(XPropertySet.class, xControlModel);
+ String sName = (String) xPSet.getPropertyValue("Name");
+ // just in case the listener has been added to several controls,
+ // we make sure we refer to the right one
+ if (sName.equals("CommandButton1")) {
+
+ }
+ }catch (com.sun.star.uno.Exception ex){
+ /* perform individual exception handling here.
+ * Possible exception types are:
+ * com.sun.star.lang.WrappedTargetException,
+ * com.sun.star.beans.UnknownPropertyException,
+ * com.sun.star.uno.Exception
+ */
+ ex.printStackTrace(System.err);
+ }
+ }
+
+
+ public void focusLost(FocusEvent _focusEvent) {
+ short nFocusFlags = _focusEvent.FocusFlags;
+ int nFocusChangeReason = nFocusFlags & FocusChangeReason.TAB;
+ if (nFocusChangeReason == FocusChangeReason.TAB) {
+ // get the window of the Window that has gained the Focus...
+ // Note that the xWindow is just a representation of the controlwindow
+ // but not of the control itself
+ XWindow xWindow = UnoRuntime.queryInterface(XWindow.class, _focusEvent.NextFocus);
+ }
+ }
+
+
+ public void focusGained(FocusEvent focusEvent) {
+ }
+
+ public void mouseReleased(MouseEvent mouseEvent) {
+ }
+
+ public void mousePressed(MouseEvent mouseEvent) {
+ }
+
+ public void mouseExited(MouseEvent mouseEvent) {
+ }
+
+ public void mouseEntered(MouseEvent _mouseEvent) {
+ try {
+ // retrieve the control that the event has been invoked at...
+ XControl xControl = UnoRuntime.queryInterface(XControl.class, _mouseEvent.Source);
+ Object tk = m_xMCF.createInstanceWithContext("com.sun.star.awt.Toolkit", m_xContext);
+ XToolkit xToolkit = UnoRuntime.queryInterface(XToolkit.class, tk);
+ // create the peer of the control by passing the windowpeer of the parent
+ // in this case the windowpeer of the control
+ xControl.createPeer(xToolkit, m_xWindowPeer);
+ // create a pointer object "in the open countryside" and set the type accordingly...
+ Object oPointer = this.m_xMCF.createInstanceWithContext("com.sun.star.awt.Pointer", this.m_xContext);
+ XPointer xPointer = UnoRuntime.queryInterface(XPointer.class, oPointer);
+ xPointer.setType(com.sun.star.awt.SystemPointer.REFHAND);
+ // finally set the created pointer at the windowpeer of the control
+ xControl.getPeer().setPointer(xPointer);
+ } catch (com.sun.star.uno.Exception ex) {
+ throw new java.lang.RuntimeException("cannot happen...", ex);
+ }
+ }
+
+
+
+ public void itemStateChanged(ItemEvent itemEvent) {
+ try{
+ // retrieve the control that the event has been invoked at...
+ XCheckBox xCheckBox = UnoRuntime.queryInterface(XCheckBox.class, itemEvent.Source);
+ // retrieve the control that we want to disable or enable
+ XControl xControl = UnoRuntime.queryInterface(XControl.class, m_xDlgContainer.getControl("CommandButton1"));
+ XPropertySet xModelPropertySet = UnoRuntime.queryInterface(XPropertySet.class, xControl.getModel());
+ short nState = xCheckBox.getState();
+ boolean bdoEnable = true;
+ switch (nState){
+ case 1: // checked
+ bdoEnable = true;
+ break;
+ case 0: // not checked
+ case 2: // don't know
+ bdoEnable = false;
+ break;
+ }
+ // Alternatively we could have done it also this way:
+ // bdoEnable = (nState == 1);
+ xModelPropertySet.setPropertyValue("Enabled", Boolean.valueOf(bdoEnable));
+ }catch (com.sun.star.uno.Exception ex){
+ /* perform individual exception handling here.
+ * Possible exception types are:
+ * com.sun.star.lang.IllegalArgumentException
+ * com.sun.star.lang.WrappedTargetException,
+ * com.sun.star.beans.UnknownPropertyException,
+ * com.sun.star.beans.PropertyVetoException
+ * com.sun.star.uno.Exception
+ */
+ ex.printStackTrace(System.err);
+ }
+ }
+
+
+ public void adjustmentValueChanged(AdjustmentEvent _adjustmentEvent) {
+ switch (_adjustmentEvent.Type.getValue()){
+ case AdjustmentType.ADJUST_ABS_value:
+ System.out.println( "The event has been triggered by dragging the thumb..." );
+ break;
+ case AdjustmentType.ADJUST_LINE_value:
+ System.out.println( "The event has been triggered by a single line move.." );
+ break;
+ case AdjustmentType.ADJUST_PAGE_value:
+ System.out.println( "The event has been triggered by a block move..." );
+ break;
+ }
+ System.out.println( "The value of the scrollbar is: " + _adjustmentEvent.Value);
+ }
+
+
+
+// Globally available object variables of the roadmapmodel
+ XPropertySet m_xRMPSet;
+ private XSingleServiceFactory m_xSSFRoadmap;
+ private XIndexContainer m_xRMIndexCont;
+
+ public void addRoadmap() {
+ XPropertySet xDialogModelPropertySet = null;
+ try {
+ // create a unique name by means of an own implementation...
+ String sRoadmapName = createUniqueName(m_xDlgModelNameContainer, "Roadmap");
+
+ xDialogModelPropertySet = UnoRuntime.queryInterface(XPropertySet.class, m_xMSFDialogModel);
+ // Similar to the office assistants the roadmap is adjusted to the height of the dialog
+ // where a certain space is left at the bottom for the buttons...
+ int nDialogHeight = ((Integer) xDialogModelPropertySet.getPropertyValue("Height")).intValue();
+
+ // instantiate the roadmapmodel...
+ Object oRoadmapModel = m_xMSFDialogModel.createInstance("com.sun.star.awt.UnoControlRoadmapModel");
+
+ // define the properties of the roadmapmodel
+ XMultiPropertySet xRMMPSet = UnoRuntime.queryInterface(XMultiPropertySet.class, oRoadmapModel);
+ xRMMPSet.setPropertyValues( new String[] {"Complete", "Height", "Name", "PositionX", "PositionY", "Text", "Width" },
+ new Object[] {Boolean.FALSE, Integer.valueOf(nDialogHeight - 26), sRoadmapName, Integer.valueOf(0), Integer.valueOf(0), "Steps", Integer.valueOf(85)});
+ m_xRMPSet = UnoRuntime.queryInterface(XPropertySet.class, oRoadmapModel);
+
+ // add the roadmapmodel to the dialog container...
+ m_xDlgModelNameContainer.insertByName(sRoadmapName, oRoadmapModel);
+
+ // the roadmapmodel is a SingleServiceFactory to instantiate the roadmapitems...
+ m_xSSFRoadmap = UnoRuntime.queryInterface(XSingleServiceFactory.class, oRoadmapModel);
+ m_xRMIndexCont = UnoRuntime.queryInterface(XIndexContainer.class, oRoadmapModel);
+
+ // add the itemlistener to the control...
+ XControl xRMControl = this.m_xDlgContainer.getControl(sRoadmapName);
+ XItemEventBroadcaster xRMBroadcaster = UnoRuntime.queryInterface(XItemEventBroadcaster.class, xRMControl);
+ xRMBroadcaster.addItemListener( getRoadmapItemStateChangeListener() );
+ } catch (java.lang.Exception jexception) {
+ jexception.printStackTrace(System.err);
+ }
+ }
+
+ /*
+ * To fully understand the example one has to be aware that the passed ???Index??? parameter
+ * refers to the position of the roadmap item in the roadmapmodel container
+ * whereas the variable ???_ID??? directly references to a certain step of dialog.
+ */
+ public void insertRoadmapItem(int Index, boolean _bEnabled, String _sLabel, int _ID) {
+ try {
+ // a roadmap is a SingleServiceFactory that can only create roadmapitems that are the only possible
+ // element types of the container
+ Object oRoadmapItem = m_xSSFRoadmap.createInstance();
+ XPropertySet xRMItemPSet = UnoRuntime.queryInterface(XPropertySet.class, oRoadmapItem);
+ xRMItemPSet.setPropertyValue("Label", _sLabel);
+ // sometimes steps are supposed to be set disabled depending on the program logic...
+ xRMItemPSet.setPropertyValue("Enabled", Boolean.valueOf(_bEnabled));
+ // in this context the "ID" is meant to refer to a step of the dialog
+ xRMItemPSet.setPropertyValue("ID", Integer.valueOf(_ID));
+ m_xRMIndexCont.insertByIndex(Index, oRoadmapItem);
+ } catch (com.sun.star.uno.Exception exception) {
+ exception.printStackTrace(System.err);
+ }
+ }
+
+
+ public void keyReleased(KeyEvent keyEvent) {
+ }
+
+ public void keyPressed(KeyEvent keyEvent) {
+ }
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/GUI/UnoDialogSample2.java b/odk/examples/DevelopersGuide/GUI/UnoDialogSample2.java
new file mode 100644
index 000000000..3e38886a1
--- /dev/null
+++ b/odk/examples/DevelopersGuide/GUI/UnoDialogSample2.java
@@ -0,0 +1,263 @@
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+import com.sun.star.awt.PushButtonType;
+import com.sun.star.awt.XDialog;
+import com.sun.star.awt.XListBox;
+import com.sun.star.beans.MethodConcept;
+import com.sun.star.beans.Property;
+import com.sun.star.beans.PropertyValue;
+import com.sun.star.beans.XIntrospection;
+import com.sun.star.beans.XIntrospectionAccess;
+import com.sun.star.beans.XMultiPropertySet;
+import com.sun.star.frame.XComponentLoader;
+import com.sun.star.lang.XMultiComponentFactory;
+import com.sun.star.lang.XServiceInfo;
+import com.sun.star.lang.XTypeProvider;
+import com.sun.star.reflection.XIdlMethod;
+import com.sun.star.uno.Type;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.XComponentContext;
+
+public class UnoDialogSample2 extends UnoDialogSample {
+ XIntrospectionAccess m_xIntrospectionAccess = null;
+ Object m_oUnoObject = null;
+ // define some constants used to set positions and sizes
+ // of controls. For further information see
+ // http://ui.openoffice.org/knowledge/DialogSpecificationandGuidelines.odt
+ static final int nFixedTextHeight = 8;
+ static final int nControlMargin = 6;
+ static final int nDialogWidth = 250;
+ static final int nDialogHeight = 140;
+ // the default roadmap width == 80 MAPs
+ static final int nRoadmapWidth = 80;
+ static final int nButtonHeight = 14;
+ static final int nButtonWidth = 50;
+
+
+ public UnoDialogSample2(XComponentContext _xContext, XMultiComponentFactory _xMCF, Object _oUnoObject) {
+ super(_xContext, _xMCF);
+ try {
+ m_oUnoObject = _oUnoObject;
+ Object o = m_xMCF.createInstanceWithContext("com.sun.star.beans.Introspection", m_xContext);
+ XIntrospection xIntrospection = UnoRuntime.queryInterface(XIntrospection.class, o );
+ // the variable m_xIntrospectionAccess offers functionality to access all methods and properties
+ // of a variable
+ m_xIntrospectionAccess = xIntrospection.inspect(_oUnoObject);
+ } catch (com.sun.star.uno.Exception ex) {
+ ex.printStackTrace();
+ }
+ }
+
+ public static void main(String args[]) {
+ UnoDialogSample2 oUnoDialogSample2 = null;
+ try {
+ XComponentContext xContext = com.sun.star.comp.helper.Bootstrap.bootstrap();
+ if(xContext != null )
+ System.out.println("Connected to a running office ...");
+ XMultiComponentFactory xMCF = xContext.getServiceManager();
+ PropertyValue[] aPropertyValues = new PropertyValue[]{};
+ // create an arbitrary Uno-Object - in this case an empty writer document...
+ Object oDesktop =xMCF.createInstanceWithContext("com.sun.star.frame.Desktop", xContext);
+ XComponentLoader xComponentLoader = UnoRuntime.queryInterface(XComponentLoader.class, oDesktop);
+ Object oUnoObject = xComponentLoader.loadComponentFromURL("private:factory/swriter", "_default", 0, aPropertyValues);
+
+ // define some coordinates where to position the controls
+ final int nButtonPosX = (nDialogWidth/2) - (nButtonWidth/2);
+ final int nButtonPosY = nDialogHeight - nButtonHeight - nControlMargin;
+ final int nControlPosX = nRoadmapWidth + 2*nControlMargin;
+ final int nControlWidth = nDialogWidth - 3*nControlMargin - nRoadmapWidth;
+ final int nListBoxHeight = nDialogHeight - 4*nControlMargin - nButtonHeight;
+ oUnoDialogSample2 = new UnoDialogSample2(xContext, xMCF, oUnoObject);
+ oUnoDialogSample2.initialize( new String[] {"Height", "Moveable", "Name","PositionX","PositionY", "Step", "TabIndex","Title","Width"},
+ new Object[] { Integer.valueOf(nDialogHeight), Boolean.TRUE, "Dialog1", Integer.valueOf(102),Integer.valueOf(41), Integer.valueOf(1), Short.valueOf((short) 0), "Inspect a Uno-Object", Integer.valueOf(nDialogWidth)});
+ String sIntroLabel = "This Dialog lists information about a given Uno-Object.\nIt offers a view to inspect all supported servicenames, exported interfaces, methods and properties.";
+ oUnoDialogSample2.insertMultiLineFixedText(nControlPosX, 27, nControlWidth, 4, 1, sIntroLabel);
+ // get the data from the UNO object...
+ String[] sSupportedServiceNames = oUnoDialogSample2.getSupportedServiceNames();
+ String[] sInterfaceNames = oUnoDialogSample2.getExportedInterfaceNames();
+ String[] sMethodNames = oUnoDialogSample2.getMethodNames();
+ String[] sPropertyNames = oUnoDialogSample2.getPropertyNames();
+ // add controls to the dialog...
+ oUnoDialogSample2.insertListBox(nControlPosX, nControlMargin, nListBoxHeight, nControlWidth, 2, sSupportedServiceNames);
+ oUnoDialogSample2.insertListBox(nControlPosX, nControlMargin, nListBoxHeight, nControlWidth, 3, sInterfaceNames);
+ oUnoDialogSample2.insertListBox(nControlPosX, nControlMargin, nListBoxHeight, nControlWidth, 4, sMethodNames);
+ oUnoDialogSample2.insertListBox(nControlPosX, nControlMargin, nListBoxHeight, nControlWidth, 5, sPropertyNames);
+ oUnoDialogSample2.insertButton(oUnoDialogSample2, nButtonPosX, nButtonPosY, nButtonWidth, "~Close", (short) PushButtonType.OK_value);
+ oUnoDialogSample2.insertHorizontalFixedLine(0, nButtonPosY - nControlMargin - 4, nDialogWidth, "");
+ // create the windowpeer;
+ // it must be kept in mind that it must be created after the insertion of the controls
+ // (see http://qa.openoffice.org/issues/show_bug.cgi?id=75129)
+ oUnoDialogSample2.createWindowPeer();
+ // add the roadmap control. Note that the roadmap may not be created before the windowpeer of the dialog exists
+ // (see http://qa.openoffice.org/issues/show_bug.cgi?id=67369)
+ oUnoDialogSample2.addRoadmap();
+ oUnoDialogSample2.insertRoadmapItem(0, true, "Introduction", 1);
+ oUnoDialogSample2.insertRoadmapItem(1, true, "Supported Services", 2);
+ oUnoDialogSample2.insertRoadmapItem(2, true, "Interfaces", 3);
+ oUnoDialogSample2.insertRoadmapItem(3, true, "Methods", 4);
+ oUnoDialogSample2.insertRoadmapItem(4, true, "Properties", 5);
+ oUnoDialogSample2.m_xRMPSet.setPropertyValue("CurrentItemID", Short.valueOf((short) 1));
+ oUnoDialogSample2.m_xRMPSet.setPropertyValue("Complete", Boolean.TRUE);
+ oUnoDialogSample2.xDialog = UnoRuntime.queryInterface(XDialog.class, oUnoDialogSample2.m_xDialogControl);
+ oUnoDialogSample2.xDialog.execute();
+ }catch( Exception ex ) {
+ ex.printStackTrace(System.err);
+ }
+ finally{
+ //make sure always to dispose the component and free the memory!
+ if (oUnoDialogSample2 != null){
+ if (oUnoDialogSample2.m_xComponent != null){
+ oUnoDialogSample2.m_xComponent.dispose();
+ }
+ }
+ }
+
+ System.exit( 0 );
+ }
+
+
+ public String[] getMethodNames() {
+ String[] sMethodNames = new String[]{};
+ try {
+ XIdlMethod[] xIdlMethods = m_xIntrospectionAccess.getMethods(MethodConcept.ALL);
+ sMethodNames = new String[xIdlMethods.length];
+ for (int i = 0; i < xIdlMethods.length; i++){
+ sMethodNames[i] = xIdlMethods[i].getName();
+ }
+ }
+ catch( Exception e ) {
+ System.err.println( e );
+ }
+ return sMethodNames;
+ }
+
+ // returns the names of all supported servicenames of a UNO object
+ public String[] getSupportedServiceNames() {
+ String[] sSupportedServiceNames = new String[]{};
+ // If the Uno-Object supports "com.sun.star.lang.XServiceInfo"
+ // this will give access to all supported servicenames
+ XServiceInfo xServiceInfo = UnoRuntime.queryInterface( XServiceInfo.class, m_oUnoObject);
+ if ( xServiceInfo != null ) {
+ sSupportedServiceNames = xServiceInfo.getSupportedServiceNames();
+ }
+ return sSupportedServiceNames;
+ }
+
+ // returns the names of all properties of a UNO object
+ protected String[] getPropertyNames() {
+ String[] sPropertyNames = new String[]{};
+ try {
+ Property[] aProperties = m_xIntrospectionAccess.getProperties(com.sun.star.beans.PropertyConcept.ATTRIBUTES + com.sun.star.beans.PropertyConcept.PROPERTYSET);
+ sPropertyNames = new String[aProperties.length];
+ for (int i = 0; i < aProperties.length; i++){
+ sPropertyNames[i] = aProperties[i].Name;
+ }
+ }
+ catch( Exception e ) {
+ System.err.println( e );
+ }
+ return sPropertyNames;
+ }
+
+
+ // returns the names of all exported interfaces of a UNO object
+ protected String[] getExportedInterfaceNames(){
+ Type[] aTypes = new Type[]{};
+ String[] sTypeNames = new String[]{};
+ // The XTypeProvider interfaces offers access to all exported interfaces
+ XTypeProvider xTypeProvider = UnoRuntime.queryInterface( XTypeProvider.class, m_oUnoObject);
+ if ( xTypeProvider != null ) {
+ aTypes = xTypeProvider.getTypes();
+ sTypeNames = new String[aTypes.length];
+ for (int i = 0; i < aTypes.length - 1; i++){
+ sTypeNames[i] = aTypes[i].getTypeName();
+ }
+ }
+ return sTypeNames;
+ }
+
+
+
+ public XListBox insertListBox(int _nPosX, int _nPosY, int _nHeight, int _nWidth, int _nStep, String[] _sStringItemList) {
+ XListBox xListBox = null;
+ try{
+ // create a unique name by means of an own implementation...
+ String sName = createUniqueName(m_xDlgModelNameContainer, "ListBox");
+ // create a controlmodel at the multiservicefactory of the dialog model...
+ Object oListBoxModel = m_xMSFDialogModel.createInstance("com.sun.star.awt.UnoControlListBoxModel");
+ XMultiPropertySet xLBModelMPSet = UnoRuntime.queryInterface(XMultiPropertySet.class, oListBoxModel);
+ // Set the properties at the model - keep in mind to pass the property names in alphabetical order!
+ xLBModelMPSet.setPropertyValues(
+ new String[] {"Dropdown", "Height", "Name", "PositionX", "PositionY", "ReadOnly", "Step", "StringItemList", "Width" } ,
+ new Object[] {Boolean.FALSE, Integer.valueOf(_nHeight), sName, Integer.valueOf(_nPosX), Integer.valueOf(_nPosY), Boolean.TRUE, Integer.valueOf(_nStep), _sStringItemList, Integer.valueOf(_nWidth)});
+ m_xDlgModelNameContainer.insertByName(sName, xLBModelMPSet);
+ }catch (com.sun.star.uno.Exception ex) {
+ throw new java.lang.RuntimeException("cannot happen...", ex);
+ }
+ return xListBox;
+ }
+
+
+ public void insertMultiLineFixedText(int _nPosX, int _nPosY, int _nWidth, int _nLineCount, int _nStep, String _sLabel) {
+ try {
+ // create a unique name by means of an own implementation...
+ String sName = createUniqueName(m_xDlgModelNameContainer, "Label");
+ int nHeight = _nLineCount * nFixedTextHeight;
+ // create a controlmodel at the multiservicefactory of the dialog model...
+ Object oFTModel = m_xMSFDialogModel.createInstance("com.sun.star.awt.UnoControlFixedTextModel");
+ XMultiPropertySet xFTModelMPSet = UnoRuntime.queryInterface(XMultiPropertySet.class, oFTModel);
+ // Set the properties at the model - keep in mind to pass the property names in alphabetical order!
+ xFTModelMPSet.setPropertyValues(
+ new String[] {"Height", "Label", "MultiLine", "Name", "PositionX", "PositionY", "Step", "Width"},
+ new Object[] { Integer.valueOf(nHeight), _sLabel, Boolean.TRUE, sName, Integer.valueOf(_nPosX), Integer.valueOf(_nPosY), Integer.valueOf(_nStep), Integer.valueOf(_nWidth)});
+ // add the model to the NameContainer of the dialog model
+ m_xDlgModelNameContainer.insertByName(sName, oFTModel);
+ }catch (com.sun.star.uno.Exception ex){
+ /* perform individual exception handling here.
+ * Possible exception types are:
+ * com.sun.star.lang.IllegalArgumentException,
+ * com.sun.star.lang.WrappedTargetException,
+ * com.sun.star.container.ElementExistException,
+ * com.sun.star.beans.PropertyVetoException,
+ * com.sun.star.beans.UnknownPropertyException,
+ * com.sun.star.uno.Exception
+ */
+ ex.printStackTrace(System.err);
+ }
+ }
+
+}// end of class
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/GUI/UnoMenu.java b/odk/examples/DevelopersGuide/GUI/UnoMenu.java
new file mode 100644
index 000000000..10d89c837
--- /dev/null
+++ b/odk/examples/DevelopersGuide/GUI/UnoMenu.java
@@ -0,0 +1,186 @@
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+import com.sun.star.awt.MenuEvent;
+import com.sun.star.awt.MenuItemStyle;
+import com.sun.star.awt.Rectangle;
+import com.sun.star.awt.WindowAttribute;
+import com.sun.star.awt.WindowClass;
+import com.sun.star.awt.XMenuBar;
+import com.sun.star.awt.XMenuListener;
+import com.sun.star.awt.XPopupMenu;
+import com.sun.star.awt.XToolkit;
+import com.sun.star.awt.XTopWindow;
+import com.sun.star.awt.XWindow;
+import com.sun.star.awt.XWindowPeer;
+import com.sun.star.frame.XFrame;
+import com.sun.star.frame.XFramesSupplier;
+import com.sun.star.lang.XComponent;
+import com.sun.star.lang.XMultiComponentFactory;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.XComponentContext;
+
+public class UnoMenu extends UnoDialogSample implements XMenuListener {
+private XTopWindow mxTopWindow = null;
+
+public UnoMenu(XComponentContext _xContext, XMultiComponentFactory _xMCF) {
+ super(_xContext, _xMCF);
+}
+
+ public static void main(String args[]){
+ UnoMenu oUnoMenu = null;
+ try {
+ XComponentContext xContext = com.sun.star.comp.helper.Bootstrap.bootstrap();
+ if(xContext != null )
+ System.out.println("Connected to a running office ...");
+ XMultiComponentFactory xMCF = xContext.getServiceManager();
+ oUnoMenu = new UnoMenu(xContext, xMCF);
+ oUnoMenu.mxTopWindow = oUnoMenu.showTopWindow( new Rectangle(100, 100, 500, 500)); //oUnoDialogSample.m_xWindowPeer,
+ oUnoMenu.addMenuBar(oUnoMenu.mxTopWindow, oUnoMenu);
+ }catch( Exception ex ) {
+ ex.printStackTrace(System.err);
+ }
+ }
+
+
+ public XPopupMenu getPopupMenu(){
+ XPopupMenu xPopupMenu = null;
+ try{
+ // create a popup menu
+ Object oPopupMenu = m_xMCF.createInstanceWithContext("com.sun.star.awt.PopupMenu", m_xContext);
+ xPopupMenu = UnoRuntime.queryInterface(XPopupMenu.class, oPopupMenu);
+
+ // ID must start be > 0
+ short nId = 1;
+ short nPos = 0;
+
+ xPopupMenu.insertItem(nId++, "First Entry", MenuItemStyle.AUTOCHECK, nPos++);
+ xPopupMenu.insertItem(nId++, "First Radio Entry", (short) (MenuItemStyle.RADIOCHECK + MenuItemStyle.AUTOCHECK), nPos++);
+ xPopupMenu.insertItem(nId++, "Second Radio Entry", (short) (MenuItemStyle.RADIOCHECK + MenuItemStyle.AUTOCHECK), nPos++);
+ xPopupMenu.insertItem(nId++, "Third RadioEntry",(short) (MenuItemStyle.RADIOCHECK + MenuItemStyle.AUTOCHECK), nPos++);
+ xPopupMenu.insertSeparator(nPos++);
+ xPopupMenu.insertItem(nId++, "Fifth Entry", (short) (MenuItemStyle.CHECKABLE + MenuItemStyle.AUTOCHECK), nPos++);
+ xPopupMenu.insertItem(nId++, "Fourth Entry", (short) (MenuItemStyle.CHECKABLE + MenuItemStyle.AUTOCHECK), nPos++);
+ xPopupMenu.insertItem(nId++, "Sixth Entry", (short) 0, nPos++);
+ xPopupMenu.insertItem(nId++, "Close Dialog", (short) 0, nPos++);
+
+ xPopupMenu.enableItem((short) 2, false);
+ xPopupMenu.checkItem((short) 3, true);
+
+ xPopupMenu.addMenuListener(this);
+ }catch( Exception e ) {
+ throw new java.lang.RuntimeException("cannot happen...", e);
+ }
+ return xPopupMenu;
+ }
+
+
+ private void addMenuBar(XTopWindow _xTopWindow, XMenuListener _xMenuListener){
+ try{
+ // create a menubar at the global MultiComponentFactory...
+ Object oMenuBar = m_xMCF.createInstanceWithContext("com.sun.star.awt.MenuBar", m_xContext);
+ // add the menu items...
+ XMenuBar xMenuBar = UnoRuntime.queryInterface(XMenuBar.class, oMenuBar);
+ xMenuBar.insertItem((short) 1, "~First MenuBar Item", com.sun.star.awt.MenuItemStyle.AUTOCHECK, (short) 0);
+ xMenuBar.insertItem((short) 2, "~Second MenuBar Item", com.sun.star.awt.MenuItemStyle.AUTOCHECK, (short) 1);
+ xMenuBar.setPopupMenu((short) 1, getPopupMenu());
+ xMenuBar.addMenuListener(_xMenuListener);
+ _xTopWindow.setMenuBar(xMenuBar);
+ }catch( Exception e ) {
+ throw new java.lang.RuntimeException("cannot happen...", e);
+ }}
+
+ protected void closeDialog(){
+ XComponent xComponent = UnoRuntime.queryInterface(XComponent.class, mxTopWindow);
+ if (xComponent != null){
+ xComponent.dispose();
+ }
+
+ // to ensure that the Java application terminates
+ System.exit( 0 );
+ }
+
+ private XTopWindow showTopWindow( Rectangle _aRectangle){
+ XTopWindow xTopWindow = null;
+ try {
+ // The Toolkit is the creator of all windows...
+ Object oToolkit = m_xMCF.createInstanceWithContext("com.sun.star.awt.Toolkit", m_xContext);
+ XToolkit xToolkit = UnoRuntime.queryInterface(XToolkit.class, oToolkit);
+
+ // set up a window description and create the window. A parent window is always necessary for this...
+ com.sun.star.awt.WindowDescriptor aWindowDescriptor = new com.sun.star.awt.WindowDescriptor();
+ // a TopWindow is contains a title bar and is able to include menus...
+ aWindowDescriptor.Type = WindowClass.TOP;
+ // specify the position and height of the window on the parent window
+ aWindowDescriptor.Bounds = _aRectangle;
+ // set the window attributes...
+ aWindowDescriptor.WindowAttributes = WindowAttribute.SHOW + WindowAttribute.MOVEABLE + WindowAttribute.SIZEABLE + WindowAttribute.CLOSEABLE;
+
+ // create the window...
+ XWindowPeer xWindowPeer = xToolkit.createWindow(aWindowDescriptor);
+ XWindow xWindow = UnoRuntime.queryInterface(XWindow.class, xWindowPeer);
+
+ // create a frame and initialize it with the created window...
+ Object oFrame = m_xMCF.createInstanceWithContext("com.sun.star.frame.Frame", m_xContext);
+ m_xFrame = UnoRuntime.queryInterface(XFrame.class, oFrame);
+
+ Object oDesktop = m_xMCF.createInstanceWithContext("com.sun.star.frame.Desktop", m_xContext);
+ XFramesSupplier xFramesSupplier = UnoRuntime.queryInterface(XFramesSupplier.class, oDesktop);
+ m_xFrame.setCreator(xFramesSupplier);
+ // get the XTopWindow interface...
+ xTopWindow = UnoRuntime.queryInterface(XTopWindow.class, xWindow);
+ } catch (com.sun.star.lang.IllegalArgumentException ex) {
+ ex.printStackTrace();
+ } catch (com.sun.star.uno.Exception ex) {
+ ex.printStackTrace();
+ }
+ return xTopWindow;
+ }
+
+
+
+ public void itemSelected(MenuEvent menuEvent){
+ // find out which menu item has been triggered,
+ // by getting the menu-id...
+ switch (menuEvent.MenuId){
+ case 1:
+ // add your menu-item-specific code here:
+ break;
+ case 2:
+ // add your menu-item-specific code here:
+ break;
+ case 8:
+ closeDialog();
+ default:
+
+ }
+ }
+
+ public void itemHighlighted(MenuEvent menuEvent) {
+ }
+
+ public void itemDeactivated(MenuEvent menuEvent) {
+ }
+
+ public void itemActivated(MenuEvent menuEvent) {
+ }
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/GUI/UnoMenu2.java b/odk/examples/DevelopersGuide/GUI/UnoMenu2.java
new file mode 100644
index 000000000..8658fb66a
--- /dev/null
+++ b/odk/examples/DevelopersGuide/GUI/UnoMenu2.java
@@ -0,0 +1,120 @@
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+import com.sun.star.awt.MouseEvent;
+import com.sun.star.awt.Rectangle;
+import com.sun.star.awt.XControl;
+import com.sun.star.awt.XWindow;
+import com.sun.star.beans.XMultiPropertySet;
+import com.sun.star.lang.EventObject;
+import com.sun.star.lang.XMultiComponentFactory;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.XComponentContext;
+
+
+public class UnoMenu2 extends UnoMenu {
+
+public UnoMenu2(XComponentContext _xContext, XMultiComponentFactory _xMCF) {
+ super(_xContext, _xMCF);
+}
+
+ public static void main(String args[]){
+ UnoMenu2 oUnoMenu2 = null;
+ try {
+ XComponentContext xContext = com.sun.star.comp.helper.Bootstrap.bootstrap();
+ if(xContext != null )
+ System.out.println("Connected to a running office ...");
+ XMultiComponentFactory xMCF = xContext.getServiceManager();
+ oUnoMenu2 = new UnoMenu2(xContext, xMCF);
+ oUnoMenu2.initialize( new String[] {"Height", "Moveable", "Name","PositionX","PositionY", "Step", "TabIndex","Title","Width"},
+ new Object[] { Integer.valueOf(140), Boolean.TRUE, "Dialog1", Integer.valueOf(102),Integer.valueOf(41), Integer.valueOf(1), Short.valueOf((short) 0), "Menu-Dialog", Integer.valueOf(200)});
+
+ Object oFTHeaderModel = oUnoMenu2.m_xMSFDialogModel.createInstance("com.sun.star.awt.UnoControlFixedTextModel");
+ XMultiPropertySet xFTHeaderModelMPSet = UnoRuntime.queryInterface(XMultiPropertySet.class, oFTHeaderModel);
+ xFTHeaderModelMPSet.setPropertyValues(
+ new String[] {"Height", "Label", "Name", "PositionX", "PositionY", "Width"},
+ new Object[] { Integer.valueOf(8), "This code-sample demonstrates the creation of a popup-menu", "HeaderLabel", Integer.valueOf(6), Integer.valueOf(6), Integer.valueOf(200)});
+ // add the model to the NameContainer of the dialog model
+ oUnoMenu2.m_xDlgModelNameContainer.insertByName("Headerlabel", oFTHeaderModel);
+ oUnoMenu2.addLabelForPopupMenu();
+ oUnoMenu2.executeDialog();
+ }catch( Exception ex ) {
+ ex.printStackTrace(System.err);
+ }
+ finally{
+ //make sure always to dispose the component and free the memory!
+ if (oUnoMenu2 != null) {
+ if (oUnoMenu2.m_xComponent != null){
+ oUnoMenu2.m_xComponent.dispose();
+ }
+ }
+ System.exit( 0 );
+ }}
+
+
+ public void addLabelForPopupMenu(){
+ try{
+ String sName = "lblPopup";
+ Object oFTModel = m_xMSFDialogModel.createInstance("com.sun.star.awt.UnoControlFixedTextModel");
+ XMultiPropertySet xFTModelMPSet = UnoRuntime.queryInterface(XMultiPropertySet.class, oFTModel);
+ // Set the properties at the model - keep in mind to pass the property names in alphabetical order!
+ xFTModelMPSet.setPropertyValues(
+ new String[] {"Height", "Label", "Name", "PositionX", "PositionY", "Width"},
+ new Object[] { Integer.valueOf(8), "Right-click here", sName, Integer.valueOf(50), Integer.valueOf(50), Integer.valueOf(100)});
+ // add the model to the NameContainer of the dialog model
+ m_xDlgModelNameContainer.insertByName(sName, oFTModel);
+ XWindow xWindow = UnoRuntime.queryInterface(XWindow.class, m_xDlgContainer.getControl(sName));
+ xWindow.addMouseListener(this);
+ }catch( Exception e ) {
+ System.err.println( e + e.getMessage());
+ e.printStackTrace();
+ }}
+
+ @Override
+ protected void closeDialog(){
+ xDialog.endExecute();
+ }
+
+ @Override
+ public void mouseReleased(MouseEvent mouseEvent) {
+ }
+
+ @Override
+ public void mousePressed(MouseEvent mouseEvent) {
+ if (mouseEvent.PopupTrigger){
+ Rectangle aPos = new Rectangle(mouseEvent.X, mouseEvent.Y, 0, 0);
+ XControl xControl = UnoRuntime.queryInterface(XControl.class, mouseEvent.Source);
+ getPopupMenu().execute( xControl.getPeer(), aPos, com.sun.star.awt.PopupMenuDirection.EXECUTE_DEFAULT);
+ }
+ }
+
+ @Override
+ public void mouseExited(MouseEvent mouseEvent) {
+ }
+
+ @Override
+ public void mouseEntered(MouseEvent mouseEvent) {
+ }
+
+ @Override
+ public void disposing(EventObject eventObject) {
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/GUI/oologo.gif b/odk/examples/DevelopersGuide/GUI/oologo.gif
new file mode 100644
index 000000000..eb5e679c0
--- /dev/null
+++ b/odk/examples/DevelopersGuide/GUI/oologo.gif
Binary files differ
diff --git a/odk/examples/DevelopersGuide/OfficeBean/Makefile b/odk/examples/DevelopersGuide/OfficeBean/Makefile
new file mode 100644
index 000000000..09c10d05d
--- /dev/null
+++ b/odk/examples/DevelopersGuide/OfficeBean/Makefile
@@ -0,0 +1,90 @@
+#*************************************************************************
+#
+# The Contents of this file are made available subject to the terms of
+# the BSD license.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+# 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+# contributors may be used to endorse or promote products derived
+# from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+# TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+# USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+#**************************************************************************
+
+# Builds the OOoBean of the Developers Guide
+
+PRJ=../../..
+SETTINGS=$(PRJ)/settings
+
+include $(SETTINGS)/settings.mk
+include $(SETTINGS)/std.mk
+
+# Define non-platform/compiler specific settings
+OUT_COMP_CLASS = $(OUT_CLASS)/OOoBeanViewer
+
+PACKAGE = org/libreoffice/sdk/examples/developers_guide/office_bean
+
+JAVAFILES = \
+ OOoBeanViewer.java \
+
+CLASSFILES = $(patsubst %.java,$(OUT_COMP_CLASS)/$(PACKAGE)/%.class,$(JAVAFILES))
+
+SDK_CLASSPATH = $(subst $(EMPTYSTRING) $(PATH_SEPARATOR),$(PATH_SEPARATOR),\
+ $(PATH_SEPARATOR)$(URE_CLASSES_DIR)/libreoffice.jar\
+ $(PATH_SEPARATOR)$(OFFICE_CLASSES_DIR)/officebean.jar\
+ $(PATH_SEPARATOR)$(OUT_COMP_CLASS))
+
+# Targets
+.PHONY: ALL
+ifeq "$(OS)" "MACOSX"
+ALL :
+ @printf 'This example does not work on macOS\n'
+else
+ALL : \
+ OOoBeanViewer
+endif
+
+include $(SETTINGS)/stdtarget.mk
+
+$(CLASSFILES) : $(JAVAFILES)
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ javac $(JAVAC_FLAGS) -classpath "$(SDK_CLASSPATH)" -d $(OUT_COMP_CLASS) $(JAVAFILES)
+
+OOoBeanViewer: $(CLASSFILES)
+ @echo --------------------------------------------------------------------------------
+ @echo Please use the following command to execute the example!
+ @echo -
+ @echo $(MAKE) OOoBeanViewer.run
+ @echo --------------------------------------------------------------------------------
+
+%.run: $(CLASSFILES)
+ $(SDK_JAVA) -classpath "$(SDK_CLASSPATH)" $(subst /,.,$(PACKAGE)).$(basename $@)
+
+%.dbg: $(JAR1_JAR)
+ jdb -classpath "$(SDK_CLASSPATH)" $(subst /,.,$(PACKAGE)).$(basename $@)
+
+.PHONY: clean
+clean :
+ -$(DELRECURSIVE) $(subst /,$(PS),$(OUT_COMP_CLASS))
+
diff --git a/odk/examples/DevelopersGuide/OfficeBean/OOoBeanViewer.java b/odk/examples/DevelopersGuide/OfficeBean/OOoBeanViewer.java
new file mode 100644
index 000000000..f87eb3678
--- /dev/null
+++ b/odk/examples/DevelopersGuide/OfficeBean/OOoBeanViewer.java
@@ -0,0 +1,410 @@
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+package org.libreoffice.sdk.examples.developers_guide.office_bean;
+
+import com.sun.star.comp.beans.OOoBean;
+import javax.swing.filechooser.*;
+import javax.swing.*;
+import java.io.*;
+
+/* A simple Applet that contains the SimpleBean.
+ *
+ * This applet is a sample implementation of the
+ * OpenOffice.org bean.
+ * When initially loaded the applet has two buttons
+ * one for opening an existent file and one to open
+ * a blank document of a given type supported by
+ * OpenOffice.org eg. Writer, Calc, Impress, ...
+ *
+ */
+
+public class OOoBeanViewer extends java.applet.Applet
+{
+
+ /**
+ * Private variables declaration - GUI components
+ */
+ private java.awt.Panel rightPanel;
+ private java.awt.Panel bottomPanel;
+ private javax.swing.JButton closeButton;
+ private javax.swing.JButton terminateButton;
+ private javax.swing.JButton newDocumentButton;
+ private javax.swing.JPopupMenu documentTypePopUp;
+ private javax.swing.JCheckBox menuBarButton;
+ private javax.swing.JCheckBox mainBarButton;
+ private javax.swing.JCheckBox toolBarButton;
+ private javax.swing.JCheckBox statusBarButton;
+ private javax.swing.JButton storeDocumentButton;
+ private javax.swing.JButton loadDocumentButton;
+ private javax.swing.JButton syswinButton;
+ private JTextField documentURLTextField;
+ private JMenuItem item;
+ private JFileChooser fileChooser;
+ private byte buffer[];
+
+ /**
+ * Private variables declaration - SimpleBean variables
+ */
+ private OOoBean aBean;
+
+ /**
+ * Initialize the Applet
+ */
+ public void init()
+ {
+ //The aBean needs to be initialized to add it to the applet
+ aBean = new OOoBean();
+
+ //Initialize GUI components
+ rightPanel = new java.awt.Panel();
+ bottomPanel = new java.awt.Panel();
+ closeButton = new javax.swing.JButton("close");
+ terminateButton = new javax.swing.JButton("terminate");
+ newDocumentButton = new javax.swing.JButton("new document...");
+ documentTypePopUp = new javax.swing.JPopupMenu();
+ storeDocumentButton = new javax.swing.JButton("store to buffer");
+ loadDocumentButton = new javax.swing.JButton("load from buffer");
+ syswinButton = new javax.swing.JButton("release/acquire");
+
+ menuBarButton = new javax.swing.JCheckBox("MenuBar");
+ menuBarButton.setSelected( aBean.isMenuBarVisible() );
+
+ mainBarButton = new javax.swing.JCheckBox("MainBar");
+ mainBarButton.setSelected( aBean.isStandardBarVisible() );
+
+ toolBarButton = new javax.swing.JCheckBox("ToolBar");
+ toolBarButton.setSelected( aBean.isToolBarVisible() );
+
+ statusBarButton = new javax.swing.JCheckBox("StatusBar");
+ statusBarButton.setSelected( aBean.isStatusBarVisible() );
+
+ documentURLTextField = new javax.swing.JTextField();
+
+ //Set up the Popup Menu to create a blank document
+ documentTypePopUp.setToolTipText("Create an empty document");
+
+ item = documentTypePopUp.add("Text Document");
+ item.addActionListener(new java.awt.event.ActionListener()
+ {
+ public void actionPerformed(java.awt.event.ActionEvent evt)
+ {
+ createBlankDoc("private:factory/swriter",
+ "New text document");
+ }
+ });
+
+ item = documentTypePopUp.add("Presentation Document");
+ item.addActionListener(new java.awt.event.ActionListener()
+ {
+ public void actionPerformed(java.awt.event.ActionEvent evt)
+ {
+ createBlankDoc("private:factory/simpress",
+ "New presentation document");
+ }
+ });
+
+ item = documentTypePopUp.add("Drawing Document");
+ item.addActionListener(new java.awt.event.ActionListener()
+ {
+ public void actionPerformed(java.awt.event.ActionEvent evt)
+ {
+ createBlankDoc("private:factory/sdraw",
+ "New drawing document");
+ }
+ });
+
+ item = documentTypePopUp.add("Formula Document");
+ item.addActionListener(new java.awt.event.ActionListener()
+ {
+ public void actionPerformed(java.awt.event.ActionEvent evt)
+ {
+ createBlankDoc("private:factory/smath",
+ "New formula document");
+ }
+ });
+
+ item = documentTypePopUp.add("Spreadsheet Document");
+ item.addActionListener(new java.awt.event.ActionListener()
+ {
+ public void actionPerformed(java.awt.event.ActionEvent evt)
+ {
+ createBlankDoc("private:factory/scalc",
+ "New spreadsheet document");
+ }
+ });
+
+ syswinButton.addActionListener(
+ new java.awt.event.ActionListener()
+ {
+ public void actionPerformed(java.awt.event.ActionEvent evt)
+ {
+ try
+ {
+ aBean.releaseSystemWindow();
+ aBean.aquireSystemWindow();
+ }
+ catch ( com.sun.star.comp.beans.NoConnectionException aExc )
+ {}
+ catch ( com.sun.star.comp.beans.SystemWindowException aExc )
+ {}
+ }
+ });
+
+ storeDocumentButton.addActionListener(
+ new java.awt.event.ActionListener()
+ {
+ public void actionPerformed(java.awt.event.ActionEvent evt)
+ {
+ try
+ {
+ buffer = aBean.storeToByteArray( null, null );
+ }
+ catch ( Throwable aExc )
+ {
+ System.err.println( "storeToBuffer failed: " + aExc );
+ aExc.printStackTrace( System.err );
+ }
+ }
+ });
+
+ loadDocumentButton.addActionListener(
+ new java.awt.event.ActionListener()
+ {
+ public void actionPerformed(java.awt.event.ActionEvent evt)
+ {
+ try
+ {
+ aBean.loadFromByteArray( buffer, null );
+ }
+ catch ( Throwable aExc )
+ {
+ System.err.println( "loadFromBuffer failed: " + aExc );
+ aExc.printStackTrace( System.err );
+ }
+ }
+ });
+
+ closeButton.addActionListener(new java.awt.event.ActionListener()
+ {
+ public void actionPerformed(java.awt.event.ActionEvent evt)
+ {
+ close();
+ }
+ });
+
+ terminateButton.addActionListener(new java.awt.event.ActionListener()
+ {
+ public void actionPerformed(java.awt.event.ActionEvent evt)
+ {
+ terminate();
+ }
+ });
+
+ newDocumentButton.addActionListener(new java.awt.event.ActionListener()
+ {
+ public void actionPerformed(java.awt.event.ActionEvent evt)
+ {
+ documentTypePopUp.show((java.awt.Component)evt.getSource(), 0,0);
+ }
+ });
+
+ menuBarButton.addActionListener(new java.awt.event.ActionListener()
+ {
+ public void actionPerformed(java.awt.event.ActionEvent evt)
+ {
+ aBean.setMenuBarVisible( !aBean.isMenuBarVisible() );
+ }
+ });
+
+ mainBarButton.addActionListener(new java.awt.event.ActionListener()
+ {
+ public void actionPerformed(java.awt.event.ActionEvent evt)
+ {
+ aBean.setStandardBarVisible( !aBean.isStandardBarVisible() );
+ }
+ });
+
+ toolBarButton.addActionListener(new java.awt.event.ActionListener()
+ {
+ public void actionPerformed(java.awt.event.ActionEvent evt)
+ {
+ aBean.setToolBarVisible( !aBean.isToolBarVisible() );
+ }
+ });
+
+ statusBarButton.addActionListener(new java.awt.event.ActionListener()
+ {
+ public void actionPerformed(java.awt.event.ActionEvent evt)
+ {
+ aBean.setStatusBarVisible( !aBean.isStatusBarVisible() );
+ }
+ });
+
+ documentURLTextField.setEditable(false);
+ documentURLTextField.setPreferredSize(new java.awt.Dimension(200, 30));
+
+ rightPanel.setLayout( new java.awt.GridLayout(10,1) );
+ rightPanel.add(closeButton);
+ rightPanel.add(terminateButton);
+ rightPanel.add(newDocumentButton);
+ rightPanel.add(storeDocumentButton);
+ rightPanel.add(loadDocumentButton);
+ rightPanel.add(syswinButton);
+ rightPanel.add(menuBarButton);
+ rightPanel.add(mainBarButton);
+ rightPanel.add(toolBarButton);
+ rightPanel.add(statusBarButton);
+
+ //bottomPanel.setLayout( new java.awt.GridLayout(1,1) );
+ bottomPanel.setLayout( new java.awt.BorderLayout() );
+ bottomPanel.add(documentURLTextField);
+
+ setLayout(new java.awt.BorderLayout());
+
+ add(aBean, java.awt.BorderLayout.CENTER);
+ add(rightPanel, java.awt.BorderLayout.EAST);
+ add(bottomPanel, java.awt.BorderLayout.SOUTH);
+ }
+
+ /**
+ * Create a blank document of type <code>desc</code>
+ *
+ * @param url The private internal URL of the OpenOffice.org
+ * document describing the document
+ * @param desc A description of the document to be created
+ */
+ private void createBlankDoc(String url, String desc)
+ {
+ //Create a blank document
+ try
+ {
+ documentURLTextField.setText(desc);
+ //Get the office process to load the URL
+ aBean.loadFromURL( url, null );
+
+ aBean.aquireSystemWindow();
+ }
+ catch ( com.sun.star.comp.beans.SystemWindowException aExc )
+ {
+ System.err.println( "OOoBeanViewer.1:" );
+ aExc.printStackTrace();
+ }
+ catch ( com.sun.star.comp.beans.NoConnectionException aExc )
+ {
+ System.err.println( "OOoBeanViewer.2:" );
+ aExc.printStackTrace();
+ }
+ catch ( Exception aExc )
+ {
+ System.err.println( "OOoBeanViewer.3:" );
+ aExc.printStackTrace();
+ //return;
+ }
+ }
+
+ /** closes the bean viewer, leaves OOo running.
+ */
+ private void close()
+ {
+ setVisible(false);
+ aBean.stopOOoConnection();
+ stop();
+ System.exit(0);
+ }
+
+ /** closes the bean viewer and tries to terminate OOo.
+ */
+ private void terminate()
+ {
+ setVisible(false);
+ com.sun.star.frame.XDesktop xDesktop = null;
+ try {
+ xDesktop = aBean.getOOoDesktop();
+ }
+ catch ( com.sun.star.comp.beans.NoConnectionException aExc ) {} // ignore
+ aBean.stopOOoConnection();
+ stop();
+ if ( xDesktop != null )
+ xDesktop.terminate();
+ System.exit(0);
+ }
+
+ /**
+ * An ExitListener listening for windowClosing events
+ */
+ private class ExitListener extends java.awt.event.WindowAdapter
+ {
+ /**
+ * windowClosed
+ *
+ * @param e A WindowEvent for a closed Window event
+ */
+ public void windowClosed( java.awt.event.WindowEvent e)
+ {
+ close();
+ }
+
+ /**
+ * windowClosing for a closing window event
+ *
+ * @param e A WindowEvent for a closing window event
+ */
+ public void windowClosing( java.awt.event.WindowEvent e)
+ {
+ ((java.awt.Window)e.getSource()).dispose();
+ }
+ }
+
+ public static void main(String args[])
+ {
+ java.awt.Frame frame = new java.awt.Frame("OpenOffice.org Demo");
+ OOoBeanViewer aViewer = new OOoBeanViewer();
+
+ frame.setLayout(new java.awt.BorderLayout());
+
+ frame.addWindowListener( aViewer.new ExitListener() );
+
+ aViewer.init();
+ aViewer.start();
+
+ frame.add(aViewer);
+ frame.setLocation( 200, 200 );
+ frame.setSize( 800, 480 );
+ frame.show();
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/OfficeBean/OfficeIconColor16.jpg b/odk/examples/DevelopersGuide/OfficeBean/OfficeIconColor16.jpg
new file mode 100644
index 000000000..cd9c5a602
--- /dev/null
+++ b/odk/examples/DevelopersGuide/OfficeBean/OfficeIconColor16.jpg
Binary files differ
diff --git a/odk/examples/DevelopersGuide/OfficeBean/OfficeIconColor32.jpg b/odk/examples/DevelopersGuide/OfficeBean/OfficeIconColor32.jpg
new file mode 100644
index 000000000..ccab06b51
--- /dev/null
+++ b/odk/examples/DevelopersGuide/OfficeBean/OfficeIconColor32.jpg
Binary files differ
diff --git a/odk/examples/DevelopersGuide/OfficeBean/OfficeIconMono16.jpg b/odk/examples/DevelopersGuide/OfficeBean/OfficeIconMono16.jpg
new file mode 100644
index 000000000..cd9c5a602
--- /dev/null
+++ b/odk/examples/DevelopersGuide/OfficeBean/OfficeIconMono16.jpg
Binary files differ
diff --git a/odk/examples/DevelopersGuide/OfficeBean/OfficeIconMono32.jpg b/odk/examples/DevelopersGuide/OfficeBean/OfficeIconMono32.jpg
new file mode 100644
index 000000000..ccab06b51
--- /dev/null
+++ b/odk/examples/DevelopersGuide/OfficeBean/OfficeIconMono32.jpg
Binary files differ
diff --git a/odk/examples/DevelopersGuide/OfficeDev/Clipboard/Clipboard.java b/odk/examples/DevelopersGuide/OfficeDev/Clipboard/Clipboard.java
new file mode 100644
index 000000000..742fed8ed
--- /dev/null
+++ b/odk/examples/DevelopersGuide/OfficeDev/Clipboard/Clipboard.java
@@ -0,0 +1,212 @@
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+import com.sun.star.uno.XComponentContext;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.frame.Desktop;
+import com.sun.star.frame.XDesktop2;
+import com.sun.star.datatransfer.DataFlavor;
+import com.sun.star.datatransfer.UnsupportedFlavorException;
+import com.sun.star.datatransfer.XTransferable;
+import com.sun.star.datatransfer.clipboard.XClipboard;
+import com.sun.star.datatransfer.clipboard.SystemClipboard;
+import com.sun.star.datatransfer.clipboard.XSystemClipboard;
+import com.sun.star.text.XTextDocument;
+import com.sun.star.uno.AnyConverter;
+
+
+// Demonstrates the usage of the clipboard service
+
+
+public class Clipboard
+{
+ public static void main(String[] args)
+ {
+ try
+ {
+ // get the remote office context. If necessary a new office
+ // process is started
+ XComponentContext xOfficeContext =
+ com.sun.star.comp.helper.Bootstrap.bootstrap();
+ System.out.println("Connected to a running office ...");
+
+ // create a new test document
+ XDesktop2 xDesktop = Desktop.create(xOfficeContext);
+ com.sun.star.lang.XComponent xComponent =
+ xDesktop.loadComponentFromURL("private:factory/swriter",
+ "_blank", 0, new com.sun.star.beans.PropertyValue[0]);
+ {
+ XTextDocument xDoc =UnoRuntime.queryInterface(XTextDocument.class, xComponent);
+ xDoc.getText().setString("In the first step, paste the current content of the clipboard in the document!\nThe text \"Hello world!\" shall be insert at the current cursor position below.\n\nIn the second step, please select some words and put it into the clipboard! ...\n\nCurrent clipboard content = ");
+
+ // ensure that the document content is optimal visible
+ com.sun.star.frame.XModel xModel =
+ UnoRuntime.queryInterface(
+ com.sun.star.frame.XModel.class, xDoc);
+ // get the frame for later usage
+ com.sun.star.frame.XFrame xFrame =
+ xModel.getCurrentController().getFrame();
+
+ com.sun.star.view.XViewSettingsSupplier xViewSettings =
+ UnoRuntime.queryInterface(
+ com.sun.star.view.XViewSettingsSupplier.class,
+ xModel.getCurrentController());
+ xViewSettings.getViewSettings().setPropertyValue(
+ "ZoomType", Short.valueOf((short)0));
+ }
+ // test document will be closed later
+
+ XSystemClipboard xClipboard = SystemClipboard.create(xOfficeContext);
+
+
+ // registering as clipboard listener
+
+
+ ClipboardListener aClipListener= new ClipboardListener();
+
+ xClipboard.addClipboardListener(aClipListener);
+
+ // Read ClipBoard
+ readClipBoard(xClipboard);
+
+
+ // becoming a clipboard owner
+
+
+ System.out.println("Becoming a clipboard owner...");
+ System.out.println("");
+
+ ClipboardOwner aClipOwner = new ClipboardOwner();
+ xClipboard.setContents(new TextTransferable("Hello World!"), aClipOwner);
+ int iFirst = 0;
+
+ while (aClipOwner.isClipboardOwner())
+ {
+ if (iFirst != 2) {
+ if (iFirst == 1) {
+ System.out.println("Change clipboard ownership by putting something into the clipboard!\n");
+ System.out.print("Still clipboard owner...");
+ } else {
+ System.out.println("Still clipboard owner...");
+ }
+ ++iFirst;
+ } else {
+ System.out.print(".");
+ }
+ Thread.sleep(1000);
+ }
+
+ // Read ClipBoard again
+ readClipBoard(xClipboard);
+
+
+ // unregistering as clipboard listener
+
+ xClipboard.removeClipboardListener(aClipListener);
+
+ // close test document
+ com.sun.star.util.XCloseable xCloseable = UnoRuntime.queryInterface(com.sun.star.util.XCloseable.class,
+ xComponent );
+
+ if (xCloseable != null ) {
+ xCloseable.close(false);
+ } else
+ {
+ xComponent.dispose();
+ }
+
+ System.exit(0);
+ }
+ catch( Exception ex )
+ {
+ ex.printStackTrace();
+ }
+ }
+
+ public static void readClipBoard(XClipboard xClipboard)
+ throws java.lang.Exception
+ {
+
+ // get a list of formats currently on the clipboard
+
+
+ XTransferable xTransferable = xClipboard.getContents();
+
+ DataFlavor[] aDflvArr = xTransferable.getTransferDataFlavors();
+
+ // print all available formats
+
+ System.out.println("Reading the clipboard...");
+ System.out.println("Available clipboard formats:");
+
+ DataFlavor aUniFlv = null;
+
+ for (int i=0;i<aDflvArr.length;i++)
+ {
+ System.out.println( "MimeType: " +
+ aDflvArr[i].MimeType +
+ " HumanPresentableName: " +
+ aDflvArr[i].HumanPresentableName );
+
+ // if there is the format unicode text on the clipboard save the
+ // corresponding DataFlavor so that we can later output the string
+
+ if ( aDflvArr[i].MimeType.equals("text/plain;charset=utf-16") )
+ {
+ aUniFlv = aDflvArr[i];
+ }
+ }
+
+ System.out.println("");
+
+ try
+ {
+ if (aUniFlv != null)
+ {
+ System.out.print("Unicode text on the clipboard ...\nYour selected text \"");
+ Object aData = xTransferable.getTransferData(aUniFlv);
+ System.out.println(AnyConverter.toString(aData)
+ + "\" is now in the clipboard.\n");
+ }
+ }
+ catch( UnsupportedFlavorException ex )
+ {
+ System.err.println( "Requested format is not available on the clipboard!" );
+ ex.printStackTrace();
+ }
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/OfficeDev/Clipboard/ClipboardListener.java b/odk/examples/DevelopersGuide/OfficeDev/Clipboard/ClipboardListener.java
new file mode 100644
index 000000000..b6af51602
--- /dev/null
+++ b/odk/examples/DevelopersGuide/OfficeDev/Clipboard/ClipboardListener.java
@@ -0,0 +1,58 @@
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+import com.sun.star.lang.EventObject;
+import com.sun.star.datatransfer.clipboard.ClipboardEvent;
+import com.sun.star.datatransfer.clipboard.XClipboardListener;
+
+
+// A simple clipboard listener
+
+
+public class ClipboardListener implements XClipboardListener
+{
+ public void disposing(EventObject event)
+ {
+ }
+
+ public void changedContents(ClipboardEvent event)
+ {
+ System.out.println("");
+ System.out.println("Clipboard content has changed!");
+ System.out.println("");
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/OfficeDev/Clipboard/ClipboardOwner.java b/odk/examples/DevelopersGuide/OfficeDev/Clipboard/ClipboardOwner.java
new file mode 100644
index 000000000..f3b3c8087
--- /dev/null
+++ b/odk/examples/DevelopersGuide/OfficeDev/Clipboard/ClipboardOwner.java
@@ -0,0 +1,63 @@
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+import com.sun.star.datatransfer.XTransferable;
+import com.sun.star.datatransfer.clipboard.XClipboard;
+import com.sun.star.datatransfer.clipboard.XClipboardOwner;
+
+
+// A simple clipboard owner
+
+
+public class ClipboardOwner implements XClipboardOwner
+{
+ public void lostOwnership( XClipboard xClipboard, XTransferable xTransferable )
+ {
+ System.out.println("");
+ System.out.println( "Lost clipboard ownership..." );
+ System.out.println("");
+
+ isowner = false;
+ }
+
+ public boolean isClipboardOwner()
+ {
+ return isowner;
+ }
+
+ private boolean isowner = true;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/OfficeDev/Clipboard/Makefile b/odk/examples/DevelopersGuide/OfficeDev/Clipboard/Makefile
new file mode 100644
index 000000000..90884f2f4
--- /dev/null
+++ b/odk/examples/DevelopersGuide/OfficeDev/Clipboard/Makefile
@@ -0,0 +1,98 @@
+#*************************************************************************
+#
+# The Contents of this file are made available subject to the terms of
+# the BSD license.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+# 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+# contributors may be used to endorse or promote products derived
+# from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+# TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+# USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+#**************************************************************************
+
+# Builds the OfficeDevClipboard example of the Developers Guide.
+
+PRJ=../../../..
+SETTINGS=$(PRJ)/settings
+
+include $(SETTINGS)/settings.mk
+include $(SETTINGS)/std.mk
+
+# Define non-platform/compiler specific settings
+EXAMPLE_NAME=OfficeDevClipboardExample
+OUT_APP_CLASS = $(OUT_CLASS)/$(EXAMPLE_NAME)
+
+APP1_NAME=Clipboard
+APP1_JAR=$(OUT_APP_CLASS)/$(APP1_NAME).jar
+
+APP1_JAVAFILES = \
+ Clipboard.java \
+ ClipboardListener.java \
+ ClipboardOwner.java \
+ TextTransferable.java
+
+APP1_CLASSFILES = $(patsubst %.java,$(OUT_APP_CLASS)/%.class,$(APP1_JAVAFILES))
+APP1_CLASSNAMES = $(patsubst %.java,%.class,$(APP1_JAVAFILES))
+
+SDK_CLASSPATH = $(subst $(EMPTYSTRING) $(PATH_SEPARATOR),$(PATH_SEPARATOR),$(CLASSPATH)\
+ $(PATH_SEPARATOR)$(OUT_APP_CLASS))
+
+
+# Targets
+.PHONY: ALL
+ALL : $(EXAMPLE_NAME)
+
+include $(SETTINGS)/stdtarget.mk
+
+$(APP1_CLASSFILES) : $(APP1_JAVAFILES)
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ $(SDK_JAVAC) $(JAVAC_FLAGS) -classpath "$(SDK_CLASSPATH)" -d $(OUT_APP_CLASS) $^
+
+$(OUT_APP_CLASS)/%.mf :
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ @echo Main-Class: com.sun.star.lib.loader.Loader> $@
+ $(ECHOLINE)>> $@
+ @echo Name: com/sun/star/lib/loader/Loader.class>> $@
+ @echo Application-Class: $*>> $@
+
+$(APP1_JAR) : $(OUT_APP_CLASS)/$(APP1_NAME).mf $(APP1_CLASSFILES)
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ +cd $(subst /,$(PS),$(OUT_APP_CLASS)) && $(SDK_JAR) cvfm $(@F) $(basename $(@F)).mf $(APP1_CLASSNAMES)
+ +$(SDK_JAR) uvf $@ $(SDK_JAVA_UNO_BOOTSTRAP_FILES)
+
+$(EXAMPLE_NAME) : $(APP1_JAR)
+ @echo --------------------------------------------------------------------------------
+ @echo Please use the following command to execute the example!
+ @echo -
+ @echo $(MAKE) $(APP1_NAME).run
+ @echo --------------------------------------------------------------------------------
+
+%.run: $(OUT_APP_CLASS)/%.jar
+ $(SDK_JAVA) -Dcom.sun.star.lib.loader.unopath="$(OFFICE_PROGRAM_PATH)" -jar $<
+
+.PHONY: clean
+clean :
+ -$(DELRECURSIVE) $(subst /,$(PS),$(OUT_APP_CLASS))
diff --git a/odk/examples/DevelopersGuide/OfficeDev/Clipboard/TextTransferable.java b/odk/examples/DevelopersGuide/OfficeDev/Clipboard/TextTransferable.java
new file mode 100644
index 000000000..82a2b316a
--- /dev/null
+++ b/odk/examples/DevelopersGuide/OfficeDev/Clipboard/TextTransferable.java
@@ -0,0 +1,88 @@
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+import com.sun.star.datatransfer.DataFlavor;
+import com.sun.star.datatransfer.UnsupportedFlavorException;
+import com.sun.star.datatransfer.XTransferable;
+import com.sun.star.uno.Type;
+
+
+// A simple transferable containing only
+// one format, unicode text
+
+
+public class TextTransferable implements XTransferable
+{
+ public TextTransferable(String aText)
+ {
+ text = aText;
+ }
+
+ // XTransferable methods
+
+ public Object getTransferData(DataFlavor aFlavor) throws UnsupportedFlavorException
+ {
+ if ( !aFlavor.MimeType.equalsIgnoreCase( UNICODE_CONTENT_TYPE ) )
+ throw new UnsupportedFlavorException();
+
+ return text;
+ }
+
+ public DataFlavor[] getTransferDataFlavors()
+ {
+ DataFlavor[] adf = new DataFlavor[1];
+
+ DataFlavor uniflv = new DataFlavor(
+ UNICODE_CONTENT_TYPE,
+ "Unicode Text",
+ new Type(String.class) );
+
+ adf[0] = uniflv;
+
+ return adf;
+ }
+
+ public boolean isDataFlavorSupported(DataFlavor aFlavor)
+ {
+ return aFlavor.MimeType.equalsIgnoreCase(UNICODE_CONTENT_TYPE);
+ }
+
+// members
+
+ private final String text;
+ private static final String UNICODE_CONTENT_TYPE = "text/plain;charset=utf-16";
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/OfficeDev/ContextMenuInterceptor.java b/odk/examples/DevelopersGuide/OfficeDev/ContextMenuInterceptor.java
new file mode 100644
index 000000000..d73554972
--- /dev/null
+++ b/odk/examples/DevelopersGuide/OfficeDev/ContextMenuInterceptor.java
@@ -0,0 +1,253 @@
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+import com.sun.star.beans.XPropertySet;
+import com.sun.star.ui.ActionTriggerSeparatorType;
+import com.sun.star.ui.ContextMenuInterceptorAction;
+import com.sun.star.ui.XContextMenuInterceptor;
+import com.sun.star.uno.UnoRuntime;
+
+public class ContextMenuInterceptor implements XContextMenuInterceptor {
+
+ /**
+ *Description of the Method
+ *
+ *@param args Description of Parameter
+ */
+ public static void main(String args[])
+ {
+ try {
+ OfficeConnect aConnect = OfficeConnect.createConnection();
+
+ com.sun.star.frame.XDesktop xDesktop =
+ aConnect.createRemoteInstance(
+ com.sun.star.frame.XDesktop.class,"com.sun.star.frame.Desktop");
+
+ // create a new test document
+ com.sun.star.frame.XComponentLoader xCompLoader =
+ UnoRuntime.queryInterface(
+ com.sun.star.frame.XComponentLoader.class, xDesktop);
+
+ com.sun.star.lang.XComponent xComponent =
+ xCompLoader.loadComponentFromURL("private:factory/swriter",
+ "_blank", 0, new com.sun.star.beans.PropertyValue[0]);
+
+ // initialize the test document
+ com.sun.star.frame.XFrame xFrame = null;
+ {
+ com.sun.star.text.XTextDocument xDoc =UnoRuntime.queryInterface(com.sun.star.text.XTextDocument.class,
+ xComponent);
+
+ String infoMsg = "All context menus of the created document frame contains now a 'Help' entry with the submenus 'Content', 'Help on Help' and 'Tips'.\n\nPress 'Return' in the shell to remove the context menu interceptor and finish the example!";
+ xDoc.getText().setString(infoMsg);
+
+ // ensure that the document content is optimal visible
+ com.sun.star.frame.XModel xModel =
+ UnoRuntime.queryInterface(
+ com.sun.star.frame.XModel.class, xDoc);
+ // get the frame for later usage
+ xFrame = xModel.getCurrentController().getFrame();
+
+ com.sun.star.view.XViewSettingsSupplier xViewSettings =
+ UnoRuntime.queryInterface(
+ com.sun.star.view.XViewSettingsSupplier.class, xModel.getCurrentController());
+ xViewSettings.getViewSettings().setPropertyValue(
+ "ZoomType", Short.valueOf((short)0));
+ }
+ // test document will be closed later
+
+ // reuse the frame
+ com.sun.star.frame.XController xController = xFrame.getController();
+ if ( xController != null ) {
+ com.sun.star.ui.XContextMenuInterception xContextMenuInterception =
+ UnoRuntime.queryInterface(
+ com.sun.star.ui.XContextMenuInterception.class, xController );
+ if( xContextMenuInterception != null ) {
+ ContextMenuInterceptor aContextMenuInterceptor = new ContextMenuInterceptor();
+ com.sun.star.ui.XContextMenuInterceptor xContextMenuInterceptor =
+ UnoRuntime.queryInterface(
+ com.sun.star.ui.XContextMenuInterceptor.class, aContextMenuInterceptor );
+ xContextMenuInterception.registerContextMenuInterceptor( xContextMenuInterceptor );
+
+ System.out.println( "\n ... all context menus of the created document frame contains now a 'Help' entry with the\n submenus 'Content', 'Help on Help' and 'Tips'.\n\nPress 'Return' to remove the context menu interceptor and finish the example!");
+
+ java.io.BufferedReader reader
+ = new java.io.BufferedReader(new java.io.InputStreamReader(System.in));
+ reader.read();
+
+ xContextMenuInterception.releaseContextMenuInterceptor(
+ xContextMenuInterceptor );
+ System.out.println( " ... context menu interceptor removed!" );
+ }
+ }
+
+ // close test document
+ com.sun.star.util.XCloseable xCloseable = UnoRuntime.queryInterface(com.sun.star.util.XCloseable.class,
+ xComponent );
+
+ if (xCloseable != null ) {
+ xCloseable.close(false);
+ } else
+ {
+ xComponent.dispose();
+ }
+ }
+ catch ( com.sun.star.uno.RuntimeException ex ) {
+ // something strange has happened!
+ System.out.println( " Sample caught exception! " + ex );
+ System.exit(1);
+ }
+ catch ( java.lang.Exception ex ) {
+ // catch java exceptions and do something useful
+ System.out.println( " Sample caught exception! " + ex );
+ System.exit(1);
+ }
+
+ System.out.println(" ... exit!\n");
+ System.exit( 0 );
+ }
+
+ /**
+ *Description of the Method
+ */
+ public ContextMenuInterceptorAction notifyContextMenuExecute(
+ com.sun.star.ui.ContextMenuExecuteEvent aEvent ) throws RuntimeException {
+
+ try {
+
+ // Retrieve context menu container and query for service factory to
+ // create sub menus, menu entries and separators
+ com.sun.star.container.XIndexContainer xContextMenu = aEvent.ActionTriggerContainer;
+ com.sun.star.lang.XMultiServiceFactory xMenuElementFactory =
+ UnoRuntime.queryInterface(
+ com.sun.star.lang.XMultiServiceFactory.class, xContextMenu );
+ if ( xMenuElementFactory != null ) {
+ // create root menu entry and sub menu
+ com.sun.star.beans.XPropertySet xRootMenuEntry =
+ UnoRuntime.queryInterface(
+ com.sun.star.beans.XPropertySet.class,
+ xMenuElementFactory.createInstance( "com.sun.star.ui.ActionTrigger" ));
+
+ // create a line separator for our new help sub menu
+ com.sun.star.beans.XPropertySet xSeparator =
+ UnoRuntime.queryInterface(
+ com.sun.star.beans.XPropertySet.class,
+ xMenuElementFactory.createInstance( "com.sun.star.ui.ActionTriggerSeparator" ));
+
+ Short aSeparatorType = Short.valueOf( ActionTriggerSeparatorType.LINE );
+ xSeparator.setPropertyValue( "SeparatorType", aSeparatorType );
+
+ // query sub menu for index container to get access
+ com.sun.star.container.XIndexContainer xSubMenuContainer =
+ UnoRuntime.queryInterface(
+ com.sun.star.container.XIndexContainer.class,
+ xMenuElementFactory.createInstance(
+ "com.sun.star.ui.ActionTriggerContainer" ));
+
+ // initialize root menu entry
+ xRootMenuEntry.setPropertyValue( "Text", "Help");
+ xRootMenuEntry.setPropertyValue( "CommandURL", "slot:5410");
+ xRootMenuEntry.setPropertyValue( "HelpURL", "5410");
+ xRootMenuEntry.setPropertyValue( "SubContainer", xSubMenuContainer );
+
+ // create menu entries for the new sub menu
+
+ // initialize help/content menu entry
+ XPropertySet xMenuEntry = UnoRuntime.queryInterface(
+ XPropertySet.class, xMenuElementFactory.createInstance(
+ "com.sun.star.ui.ActionTrigger" ));
+
+ xMenuEntry.setPropertyValue( "Text", "Content" );
+ xMenuEntry.setPropertyValue( "CommandURL", "slot:5401" );
+ xMenuEntry.setPropertyValue( "HelpURL", "5401" );
+
+ // insert menu entry to sub menu
+ xSubMenuContainer.insertByIndex( 0, xMenuEntry );
+
+ // initialize help/help on help
+ xMenuEntry = UnoRuntime.queryInterface(
+ com.sun.star.beans.XPropertySet.class,
+ xMenuElementFactory.createInstance(
+ "com.sun.star.ui.ActionTrigger" ));
+ xMenuEntry.setPropertyValue("Text", "Help on Help");
+ xMenuEntry.setPropertyValue("CommandURL", "slot:5400");
+ xMenuEntry.setPropertyValue("HelpURL", "5400");
+
+ // insert menu entry to sub menu
+ xSubMenuContainer.insertByIndex( 1, xMenuEntry );
+
+ // initialize help/tips
+ xMenuEntry = UnoRuntime.queryInterface(
+ com.sun.star.beans.XPropertySet.class,
+ xMenuElementFactory.createInstance(
+ "com.sun.star.ui.ActionTrigger" ));
+ xMenuEntry.setPropertyValue( "Text", "Tips" );
+ xMenuEntry.setPropertyValue( "CommandURL", "slot:5404" );
+ xMenuEntry.setPropertyValue( "HelpURL", "5404" );
+
+ // insert menu entry to sub menu
+ xSubMenuContainer.insertByIndex( 2, xMenuEntry );
+
+ // add separator into the given context menu
+ xContextMenu.insertByIndex( 0, xSeparator );
+
+ // add new sub menu into the given context menu
+ xContextMenu.insertByIndex( 0, xRootMenuEntry );
+
+ // The controller should execute the modified context menu and stop notifying other
+ // interceptors.
+ return com.sun.star.ui.ContextMenuInterceptorAction.EXECUTE_MODIFIED;
+ }
+ }
+ catch ( com.sun.star.beans.UnknownPropertyException ex ) {
+ // do something useful
+ // we used an unknown property
+ }
+ catch ( com.sun.star.lang.IndexOutOfBoundsException ex ) {
+ // do something useful
+ // we used an invalid index for accessing a container
+ }
+ catch ( com.sun.star.uno.Exception ex ) {
+ // something strange has happened!
+ }
+ catch ( java.lang.Exception ex ) {
+ // catch java exceptions and something useful
+ }
+
+ return com.sun.star.ui.ContextMenuInterceptorAction.IGNORED;
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/CustomizeView.java b/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/CustomizeView.java
new file mode 100644
index 000000000..f19429585
--- /dev/null
+++ b/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/CustomizeView.java
@@ -0,0 +1,285 @@
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+import java.awt.*;
+import javax.swing.*;
+import java.awt.event.*;
+
+/**
+ * Makes it possible to change some states of currently loaded
+ * document (e.g. enable/disable menubar, toolbar, objectbar)
+ *
+ */
+public class CustomizeView extends JPanel
+ implements IShutdownListener
+{
+ /**
+ * These const URL's describe feature for toggling some properties of loaded document.
+ * Dispatch it with the corresponding parameter to the frame.
+ */
+ private static final String FEATUREURL_MENUBAR = "slot:6661" ;
+ private static final String FEATUREURL_TOOLBAR = "slot:5909" ;
+ private static final String FEATUREURL_OBJECTBAR = "slot:5905" ;
+
+ private static final String FEATUREPROP_MENUBAR = "MenuBarVisible" ;
+ private static final String FEATUREPROP_TOOLBAR = "ToolBarVisible" ;
+ private static final String FEATUREPROP_OBJECTBAR = "ObjectBarVisible" ;
+
+ private static final String ACTION_MENUBAR = "toggle_menu" ;
+ private static final String ACTION_TOOLBAR = "toggle_toolbar" ;
+ private static final String ACTION_OBJECTBAR = "toggle_objectbar" ;
+
+ private static final String MENUBAR_ON = "menubar on" ;
+ private static final String TOOLBAR_ON = "toolbar on" ;
+ private static final String OBJECTBAR_ON = "objectbar on" ;
+
+ private static final String MENUBAR_OFF = "menubar off" ;
+ private static final String TOOLBAR_OFF = "toolbar off" ;
+ private static final String OBJECTBAR_OFF = "objectbar off" ;
+
+
+ // member
+
+ /**
+ * @member m_cbMenuBar reference to checkbox for toggling menubar
+ * @member m_cbToolBar reference to checkbox for toggling toolbar
+ * @member m_cbObjectBar reference to checkbox for toggling objectbar
+ *
+ * @member m_aMenuBarListener listener for status events of the menu bar
+ * @member m_aToolBarListener listener for status events of the tool bar
+ * @member m_aObjectBarListener listener for status events of the object bar
+ */
+ private final JCheckBox m_cbMenuBar ;
+ private final JCheckBox m_cbToolBar ;
+ private final JCheckBox m_cbObjectBar ;
+
+ private StatusListener m_aMenuBarListener ;
+ private StatusListener m_aToolBarListener ;
+ private StatusListener m_aObjectBarListener;
+
+
+
+ /**
+ * ctor
+ * Create view controls on startup and initialize it.
+ * We don't start listening here. see setFrame()!
+ */
+ CustomizeView()
+ {
+ this.setLayout(new GridLayout(3,0));
+
+ m_cbMenuBar = new JCheckBox(MENUBAR_OFF , false);
+ m_cbToolBar = new JCheckBox(TOOLBAR_OFF , false);
+ m_cbObjectBar = new JCheckBox(OBJECTBAR_OFF, false);
+
+ m_cbMenuBar.setEnabled (false);
+ m_cbToolBar.setEnabled (false);
+ m_cbObjectBar.setEnabled(false);
+
+ m_cbMenuBar.setActionCommand (ACTION_MENUBAR );
+ m_cbToolBar.setActionCommand (ACTION_TOOLBAR );
+ m_cbObjectBar.setActionCommand(ACTION_OBJECTBAR);
+
+ this.add(m_cbMenuBar );
+ this.add(m_cbToolBar );
+ this.add(m_cbObjectBar);
+ }
+
+
+
+ /**
+ * set new frame for this view
+ * We start listening for frame action/status and click events instandly.
+ * If an event occurs, we use it to synchronize our controls
+ * with states of a (maybe) new document view of this frame.
+ *
+ * @param xFrame
+ * the reference to the frame, which provides the
+ * possibility to get the required status information
+ *
+ * Attention: We don't accept new frames here.
+ * We get one after startup and work with it.
+ * That's it!
+ */
+ public void setFrame(com.sun.star.frame.XFrame xFrame)
+ {
+ if (xFrame==null)
+ return;
+
+ // be listener for click events
+ // They will toggle the UI controls.
+ ClickListener aMenuBarHandler = new ClickListener(FEATUREURL_MENUBAR ,FEATUREPROP_MENUBAR ,xFrame);
+ ClickListener aToolBarHandler = new ClickListener(FEATUREURL_TOOLBAR ,FEATUREPROP_TOOLBAR ,xFrame);
+ ClickListener aObjectBarHandler = new ClickListener(FEATUREURL_OBJECTBAR,FEATUREPROP_OBJECTBAR,xFrame);
+
+ m_cbMenuBar.addActionListener (aMenuBarHandler );
+ m_cbToolBar.addActionListener (aToolBarHandler );
+ m_cbObjectBar.addActionListener(aObjectBarHandler);
+
+ // be frame action listener
+ // The callback will update listener connections
+ // for status updates automatically!
+ m_aMenuBarListener = new StatusListener(m_cbMenuBar ,MENUBAR_ON ,MENUBAR_OFF ,xFrame, FEATUREURL_MENUBAR );
+ m_aToolBarListener = new StatusListener(m_cbToolBar ,TOOLBAR_ON ,TOOLBAR_OFF ,xFrame, FEATUREURL_TOOLBAR );
+ m_aObjectBarListener = new StatusListener(m_cbObjectBar,OBJECTBAR_ON,OBJECTBAR_OFF,xFrame, FEATUREURL_OBJECTBAR);
+
+ m_aMenuBarListener.startListening();
+ m_aToolBarListener.startListening();
+ m_aObjectBarListener.startListening();
+ }
+
+
+
+ /*
+ * react for click events of the used check boxes
+ * We use our internal set dispatch objects to
+ * call it. This calls toggle the menu/object- or toolbar.
+ * Note: Because we are listener status events too - hopefully
+ * we get a notification, if toggling was successfully or not.
+ * We use this information to update our check boxes again.
+ * But such update doesn't force (hopefully) an action event. Otherwise
+ * we can produce a never ending recursion!
+ */
+ private class ClickListener implements ActionListener,
+ com.sun.star.lang.XEventListener
+ {
+ /// URL, to toggle the requested UI item
+ private final String m_sURL;
+ /// name of the property which must be used in combination with the URL
+ private final String m_sProp;
+ /// we must use this frame to dispatch a request
+ private com.sun.star.frame.XFrame m_xFrame;
+
+
+
+ /**
+ * ctor
+ * It initialize an instance of this class only.
+ */
+ private ClickListener( String sURL ,
+ String sProp ,
+ com.sun.star.frame.XFrame xFrame )
+ {
+ m_sURL = sURL ;
+ m_sProp = sProp ;
+ m_xFrame = xFrame;
+ }
+
+
+
+ /**
+ * callback for action events
+ * Such events occur, if someone clicked the
+ * JCheckBox control, on which we are registered.
+ * Such events do not occur, if we set it programmatically
+ * (e.g. if we get status events to -> see class StatusListener too)
+ *
+ * @param aEvent
+ * describes the check box and its state
+ * we can use to toggle the requested office
+ * resource.
+ */
+ public void actionPerformed(ActionEvent aEvent)
+ {
+ synchronized(this)
+ {
+ if (m_xFrame==null)
+ return;
+ }
+
+ // define parameters for following dispatch
+ boolean bState = ((JCheckBox)aEvent.getSource()).isSelected();
+
+ // prepare the dispatch
+ com.sun.star.util.URL aURL = FunctionHelper.parseURL(m_sURL);
+ if (aURL==null)
+ return;
+
+ com.sun.star.beans.PropertyValue[] lProperties = new com.sun.star.beans.PropertyValue[1];
+ lProperties[0] = new com.sun.star.beans.PropertyValue();
+ lProperties[0].Name = m_sProp;
+ lProperties[0].Value = Boolean.valueOf(bState);
+
+ // execute (dispatch) it into the frame
+ if (m_xFrame==null)
+ return;
+ FunctionHelper.execute(m_xFrame,aURL,lProperties,null);
+ }
+
+
+
+ /**
+ * callback for disposing events
+ * Internally we save a reference to an office frame.
+ * Of course he can die and inform us then. We should react
+ * and forget his reference.
+ *
+ * @param aEvent
+ * describes the source which fire this event
+ * Must be our internal saved frame. Otherwise
+ * somewhere know us without a registration ...
+ */
+ public void disposing(com.sun.star.lang.EventObject aEvent)
+ {
+ synchronized(this)
+ {
+ m_xFrame = null;
+ }
+ }
+ }
+
+
+
+ /**
+ * If this java application shutdown - we must cancel all current existing
+ * listener connections. Otherwise the office will run into some
+ * DisposedExceptions if it tries to use these forgotten listener references.
+ * And of course it can die doing that.
+ * We are registered at a central object to be informed if the VM will exit.
+ * So we can react.
+ */
+ public void shutdown()
+ {
+ m_aMenuBarListener.shutdown();
+ m_aToolBarListener.shutdown();
+ m_aObjectBarListener.shutdown();
+
+ m_aMenuBarListener = null;
+ m_aToolBarListener = null;
+ m_aObjectBarListener = null;
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/Desk.java b/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/Desk.java
new file mode 100644
index 000000000..7ce2682fe
--- /dev/null
+++ b/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/Desk.java
@@ -0,0 +1,93 @@
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+// __________ Imports __________
+
+// __________ Implementation __________
+
+/**
+ * TODO
+ *
+ */
+public class Desk
+{
+
+
+ /**
+ * main
+ * Establish connection to a remote office and starts the demo application.
+ * User can overwrite some of necessary start options by using command line parameters.
+ *
+ * syntax: Desk [mode={inplace|outplace}] [file=<filename>]
+ *
+ * @param lArguments command line arguments
+ * mode describe using mode of document view {inplace/outplace}
+ * default=inplace
+ * file name of first file which should be open
+ * default="private:factory/swriter" to open empty writer document
+ */
+ public static void main(String[] lArguments)
+ {
+ // Analyze command line parameters.
+ String sMode = "inplace";
+ String sFile = "private:factory/swriter";
+
+ for(int i=0; i<lArguments.length; ++i)
+ {
+ lArguments[i] = lArguments[i].toLowerCase();
+ if(lArguments[i].startsWith("mode="))
+ sMode = lArguments[i].substring(5);
+ else
+ if(lArguments[i].startsWith("file="))
+ sFile = lArguments[i].substring(5);
+ }
+
+ ViewContainer.mbInplace = sMode.equals("inplace");
+
+ // Connect to remote office.
+ OfficeConnect.createConnection();
+
+ // Create first document view.
+ // This one will register himself at the global
+ // ViewContainer. Further views will be open
+ // automatically started from this first one.
+ DocumentView aView = new DocumentView();
+ aView.setVisible(true);
+ aView.createFrame();
+ aView.load(sFile);
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/DocumentView.java b/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/DocumentView.java
new file mode 100644
index 000000000..57ac4e779
--- /dev/null
+++ b/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/DocumentView.java
@@ -0,0 +1,428 @@
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+// __________ Imports __________
+
+import com.sun.star.uno.UnoRuntime;
+
+import java.awt.*;
+import java.awt.event.*;
+import javax.swing.*;
+import javax.swing.border.*;
+import java.awt.AWTEvent;
+import java.awt.event.WindowEvent;
+
+// __________ Implementation __________
+
+/**
+ * This implement a java frame which contains
+ * an office document, shows some status information
+ * about that, provides simple functionality on it
+ * (e.g. toggle menubar, save document) and
+ * react for different situations independent
+ * (e.g. closing the document from outside).
+ * Every instance of this class will be a member
+ * inside the global "ViewContainer" of this java
+ * demo application which holds all opened views alive.
+ *
+ */
+public class DocumentView extends JFrame
+ implements com.sun.star.lang.XEventListener, // react for Frame::disposing()
+ IShutdownListener // react for System.exit()
+{
+
+
+ /**
+ * const
+ * These command strings are used to identify a received action
+ * of buttons on which we listen for action events.
+ */
+ private static final String COMMAND_OPEN = "open" ;
+ private static final String COMMAND_SAVE = "save" ;
+ private static final String COMMAND_EXPORT = "export" ;
+ private static final String COMMAND_EXIT = "exit" ;
+
+
+
+ /**
+ * @member mxFrame office frame which contains the document of this view
+ *
+ * @member maStatusView special panel which shows available status information of currently loaded document
+ * @member maDocumentView use JNI mechanism to plug an office window into our own java UI container (used for inplace mode only!)
+ * @member maCustomizeView special panel makes it possible to toggle menubar/toolbar or objectbar of loaded document
+ * @member maInterceptor interceptor thread which intercept "new" menu of office frame to open new frames inside this java application
+ *
+ * @member msName unique name of this view (returned by the global ViewContainer during registration)
+ *
+ * @member mbOpen button to open documents
+ * @member mbSave button to save currently loaded document
+ * @member mbExport button to save currently loaded document in HTML format (if it is possible!)
+ * @member mbExit button to exit this demo
+ *
+ * @member maInterception we try to intercept the file->new menu to open new document inside this java application
+ */
+ private com.sun.star.frame.XFrame mxFrame ;
+
+ private StatusView maStatusView ;
+ private NativeView maDocumentView ;
+ private CustomizeView maCustomizeView ;
+ private Interceptor maInterceptor ;
+
+ private final String msName;
+
+ private final JButton mbtSave;
+ private final JButton mbtExport;
+
+ private boolean mbDead ;
+
+
+
+ /**
+ * ctor
+ * Create view controls on startup and initialize it with default values.
+ */
+ DocumentView()
+ {
+ this.setSize( new Dimension(800,600) );
+
+ JPanel paMainPanel = (JPanel)this.getContentPane();
+
+ // create and add command buttons to a panel
+ // it will be a sub panel of later layouted UI
+ JButton mbtOpen = new JButton("Open ..." );
+ mbtSave = new JButton("Save" );
+ mbtExport = new JButton("Save as HTML ...");
+ JButton mbtExit = new JButton("Exit" );
+
+ mbtOpen.setEnabled (true );
+ mbtSave.setEnabled (false);
+ mbtExport.setEnabled(false);
+ mbtExit.setEnabled (true );
+
+ mbtOpen.setActionCommand (COMMAND_OPEN );
+ mbtSave.setActionCommand (COMMAND_SAVE );
+ mbtExport.setActionCommand(COMMAND_EXPORT);
+ mbtExit.setActionCommand (COMMAND_EXIT );
+
+ Reactor aListener = new Reactor();
+ mbtOpen.addActionListener (aListener);
+ mbtSave.addActionListener (aListener);
+ mbtExport.addActionListener(aListener);
+ mbtExit.addActionListener (aListener);
+
+ JPanel paCommands = new JPanel( new GridLayout(4,0) );
+ paCommands.add(mbtOpen);
+ paCommands.add(mbtSave);
+ paCommands.add(mbtExport);
+ paCommands.add(mbtExit);
+
+ // create view to show status information of opened file
+ maStatusView = new StatusView();
+
+ // create view for toggle different bar's of document
+ maCustomizeView = new CustomizeView();
+
+ paCommands.setBorder ( new TitledBorder(BorderFactory.createEtchedBorder(),"Commands") );
+ maStatusView.setBorder ( new TitledBorder(BorderFactory.createEtchedBorder(),"Status Information") );
+ maCustomizeView.setBorder( new TitledBorder(BorderFactory.createEtchedBorder(),"Customize Document View") );
+
+ // layout the whole UI
+ JPanel paTest = new JPanel(new GridLayout(3,0));
+ paTest.add(paCommands );
+ paTest.add(maStatusView );
+ paTest.add(maCustomizeView);
+ JScrollPane paScroll = new JScrollPane();
+ paScroll.getViewport().add(paTest,null);
+
+ if(ViewContainer.mbInplace)
+ {
+ // create view to show opened documents
+ // This special view is necessary for inplace mode only!
+ maDocumentView = new NativeView();
+
+ JSplitPane paSplit = new JSplitPane();
+ paSplit.setOneTouchExpandable( true );
+
+ paSplit.setLeftComponent (maDocumentView);
+ paSplit.setRightComponent(paScroll );
+
+ paMainPanel.add(paSplit);
+ }
+ else
+ {
+ paMainPanel.add(paScroll);
+ }
+
+ // Register this new view on our global view container.
+ msName = FunctionHelper.getUniqueFrameName();
+ this.setTitle(msName);
+ ViewContainer.getGlobalContainer().addView(this);
+ ViewContainer.getGlobalContainer().addListener(this);
+ // be listener for closing the application
+ this.enableEvents(AWTEvent.WINDOW_EVENT_MASK);
+ }
+
+
+
+ /**
+ * Create the view frame for showing the office documents on demand.
+ * Depending on given command line parameter we create
+ * an office XFrame and initialize it with a window. This
+ * window can be a pure toolkit window (means toolkit of office!)
+ * or a plugged java canvas - office window combination.
+ */
+ public void createFrame()
+ {
+ // create view frame (as a XFrame!) here
+ // Look for right view mode set by user command line parameter.
+ // First try to get a new unambiguous frame name from our global ViewContainer.
+ if(ViewContainer.mbInplace)
+ {
+ // inplace document view can't be initialized without a visible parent window hierarchy!
+ // So make sure that we are visible in every case!
+ this.setVisible(true);
+ mxFrame = FunctionHelper.createViewFrame(msName,maDocumentView);
+ }
+ else
+ mxFrame = FunctionHelper.createViewFrame(msName,null);
+
+ if(mxFrame!=null)
+ {
+ // start interception
+ maInterceptor = new Interceptor(mxFrame);
+ maInterceptor.startListening();
+
+ // start listening for status events and actualization
+ // of our status view
+ // (of course for our CustomizeView too)
+ maStatusView.setFrame (mxFrame);
+ maCustomizeView.setFrame(mxFrame);
+
+ // be listener for closing the remote target view frame
+ com.sun.star.lang.XComponent xBroadcaster = UnoRuntime.queryInterface(
+ com.sun.star.lang.XComponent.class,
+ mxFrame);
+
+ if(xBroadcaster!=null)
+ xBroadcaster.addEventListener(this);
+ }
+ }
+
+
+
+ /**
+ * Different ways to load any URL from outside (may be by the command line)
+ * into this document view or to save it.
+ */
+ public void load(String sURL)
+ {
+ load(sURL,new com.sun.star.beans.PropertyValue[0]);
+ }
+
+
+
+ public void load(String sURL, com.sun.star.beans.PropertyValue[] lArguments)
+ {
+ com.sun.star.lang.XComponent xDocument = FunctionHelper.loadDocument(mxFrame,sURL,lArguments);
+ if(xDocument!=null)
+ {
+ mbtSave.setEnabled (true);
+ mbtExport.setEnabled(true);
+ }
+ else
+ {
+ mbtSave.setEnabled (false);
+ mbtExport.setEnabled(false);
+ }
+ }
+
+
+
+ private void save()
+ {
+ com.sun.star.frame.XController xController = mxFrame.getController();
+ if (xController==null)
+ return;
+ com.sun.star.frame.XModel xDocument = xController.getModel();
+ if (xDocument==null)
+ return;
+ FunctionHelper.saveDocument(xDocument);
+ }
+
+
+
+ private void exportHTML(String sURL)
+ {
+ com.sun.star.frame.XController xController = mxFrame.getController();
+ if (xController==null)
+ return;
+ com.sun.star.frame.XModel xDocument = xController.getModel();
+ if (xDocument==null)
+ return;
+ FunctionHelper.saveAsHTML(xDocument,sURL);
+ }
+
+
+
+ /**
+ * Overridden so we can react for window closing of this view.
+ */
+ @Override
+ protected void processWindowEvent(WindowEvent aEvent)
+ {
+ if (aEvent.getID()!=WindowEvent.WINDOW_CLOSING)
+ {
+ super.processWindowEvent(aEvent);
+ }
+ else
+ if (FunctionHelper.closeFrame(mxFrame))
+ {
+ mxFrame = null;
+ shutdown();
+ super.processWindowEvent(aEvent);
+ }
+ }
+
+
+
+ /**
+ * Here we can react for System.exit() normally.
+ * But we use it for disposing() or windowClosing() too.
+ */
+ public void shutdown()
+ {
+ if (mbDead)
+ return;
+ mbDead=true;
+
+ // force these sub view to release her remote
+ // references too!
+ maStatusView.shutdown();
+ maCustomizeView.shutdown();
+
+ maStatusView = null;
+ maCustomizeView = null;
+
+ // disable all interceptions
+ maInterceptor.shutdown();
+ maInterceptor = null;
+
+ // close the frame and his document
+ // Releasing of our listener connections for disposing()
+ // will be forced automatically then. Because the frame
+ // will call us back ...
+ if (mxFrame!=null)
+ FunctionHelper.closeFrame(mxFrame);
+
+ // deregister this view in the global container
+ // Normally we should die afterwards by garbage collection ...
+ // In cease this was the last view - it force a system.exit().
+ // But then we are no longer a member of the global container
+ // of possible shutdown listener ... and this method should be
+ // called again.
+ ViewContainer.getGlobalContainer().removeView(this);
+ }
+
+
+
+ /**
+ * callback from our internal saved frame
+ * which wishes to die. It's not necessary to remove listener connections
+ * here. Because the broadcaster do it automatically.
+ * We have to release all references to him only.
+ *
+ * @param aSource
+ * describe the broadcaster of this event
+ * Must be our internal saved frame.
+ */
+ public void disposing(com.sun.star.lang.EventObject aSource)
+ {
+ mxFrame = null;
+ }
+
+
+
+ /**
+ * This inner class is used to react for events of our own UI controls.
+ * So we can start different actions then.
+ */
+ private class Reactor implements ActionListener
+ {
+
+
+ /**
+ * This method react for pressed buttons or selected check boxes.
+ */
+ public void actionPerformed(ActionEvent aEvent)
+ {
+ String sCommand = aEvent.getActionCommand();
+
+ // open any file from disk
+ if( sCommand.equals(COMMAND_OPEN) )
+ {
+ String sURL = FunctionHelper.askUserForFileURL(DocumentView.this,true);
+ if(sURL!=null)
+ DocumentView.this.load(sURL);
+ }
+ else
+
+ // save current document
+ if( sCommand.equals(COMMAND_SAVE) )
+ {
+ DocumentView.this.save();
+ }
+ else
+
+ // export current document to html
+ if( sCommand.equals(COMMAND_EXPORT))
+ {
+ String sURL = FunctionHelper.askUserForFileURL(DocumentView.this,false);
+ if(sURL!=null)
+ DocumentView.this.exportHTML(sURL);
+ }
+ else
+
+ // exit application
+ if( sCommand.equals(COMMAND_EXIT) )
+ {
+ // This will force deleting of this and
+ // all other currently opened views automatically!
+ System.exit(0);
+ }
+ }
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/FunctionHelper.java b/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/FunctionHelper.java
new file mode 100644
index 000000000..fa24cde96
--- /dev/null
+++ b/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/FunctionHelper.java
@@ -0,0 +1,939 @@
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+// __________ Imports __________
+
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.AnyConverter;
+
+import java.awt.*;
+import javax.swing.*;
+import java.io.*;
+import java.net.*;
+
+// __________ Implementation __________
+
+/**
+ * Is a collection of basic features.
+ * This helper shows different functionality of framework api
+ * in an example manner. You can use the follow ones:
+ * (1) parse URL's
+ * (2) create frames (inside/outside a java application)
+ * (3) dispatches (with[out] notifications)
+ * (4) loading/saving documents
+ * (5) convert documents to HTML (if possible)
+ * (6) close documents (and her frames) correctly
+ *
+ * There exist some other helper functionality too, which
+ * doesn't use or demonstrate the office api:
+ * (a) getting file names by using a file chosser
+ */
+public class FunctionHelper
+{
+
+
+ /**
+ * This convert a URL (formatted as a string) to a struct com.sun.star.util.URL.
+ * It use a special service to do that: the URLTransformer.
+ * Because some API calls need it and it's not allowed to set "Complete"
+ * part of the util struct only. The URL must be parsed.
+ *
+ * @param sURL
+ * URL for parsing in string notation
+ *
+ * @return [com.sun.star.util.URL]
+ * URL in UNO struct notation
+ */
+ public static com.sun.star.util.URL parseURL(String sURL)
+ {
+ com.sun.star.util.URL aURL = null;
+
+ if (sURL==null || sURL.equals(""))
+ {
+ System.out.println("wrong using of URL parser");
+ return null;
+ }
+
+ try
+ {
+ com.sun.star.uno.XComponentContext xOfficeCtx =
+ OfficeConnect.getOfficeContext();
+
+ // Create special service for parsing of given URL.
+ com.sun.star.util.XURLTransformer xParser =
+ UnoRuntime.queryInterface(
+ com.sun.star.util.XURLTransformer.class,
+ xOfficeCtx.getServiceManager().createInstanceWithContext(
+ "com.sun.star.util.URLTransformer", xOfficeCtx));
+
+ // Because it's an in/out parameter we must use an array of URL objects.
+ com.sun.star.util.URL[] aParseURL = new com.sun.star.util.URL[1];
+ aParseURL[0] = new com.sun.star.util.URL();
+ aParseURL[0].Complete = sURL;
+
+ // Parse the URL
+ xParser.parseStrict(aParseURL);
+
+ aURL = aParseURL[0];
+ }
+ catch(com.sun.star.uno.RuntimeException exRuntime)
+ {
+ // Any UNO method of this scope can throw this exception.
+ // Reset the return value only.
+ }
+ catch(com.sun.star.uno.Exception exUno)
+ {
+ // "createInstance()" method of used service manager can throw it.
+ // Then it wasn't possible to get the URL transformer.
+ // Return default instead of really parsed URL.
+ }
+
+ return aURL;
+ }
+
+
+
+ /**
+ * create a new empty target frame
+ * Attention: Currently we must use special service com.sun.star.frame.Task instead of Frame.
+ * Because desktop environment accept this special frame type only as direct children.
+ * Note - This service will be deprecated and must be replaces by com.sun.star.frame.Frame in
+ * further versions. To feature prove we use both service names. If for new versions
+ * the deprecated one not exist we get an empty frame, we can try to use the new service.
+ *
+ * @param xSMGR
+ * we need the remote service manager to create this task/frame service
+ *
+ * @return [com.sun.star.frame.XFrame]
+ * the new created frame reference in case of success or null otherwise
+ */
+ private static com.sun.star.frame.XFrame impl_createEmptyFrame(
+ com.sun.star.uno.XComponentContext xCtx )
+ {
+ com.sun.star.frame.XFrame xFrame = null;
+
+ try{
+ xFrame = UnoRuntime.queryInterface(
+ com.sun.star.frame.XFrame.class,
+ xCtx.getServiceManager().createInstanceWithContext(
+ "com.sun.star.frame.Task", xCtx));
+ } catch(com.sun.star.uno.Exception ex1) {}
+
+ if (xFrame==null)
+ {
+ try{
+ xFrame = UnoRuntime.queryInterface(
+ com.sun.star.frame.XFrame.class,
+ xCtx.getServiceManager().createInstanceWithContext(
+ "com.sun.star.frame.Frame", xCtx));
+ } catch(com.sun.star.uno.Exception ex2) {}
+ }
+
+ return xFrame;
+ }
+
+
+
+ /**
+ * create a new window which can be used as container window of an office frame
+ * We know two modes for creation:
+ * - the office window will be a child of one of our java windows
+ * - the office will be a normal system window outside this java application
+ * This behaviour will be regulated by the second parameter of this operation.
+ * If a parentview is given the first mode will be activated - otherwise
+ * the second one.
+ *
+ * Note: First mode (creation of a child window) can be reached by two different
+ * ways.
+ * - pack the required window handle of our java window inside a UNO object
+ * to transport it to the remote office toolkit and get a child office
+ * window.
+ * This is the old way. It's better to use the second one - but to be
+ * future prove this old one should be tried too.
+ * - it's possible to pass the native window handle directly to the toolkit.
+ * A special interface method was enabled to accept that.
+ *
+ * The right way to create an office window should be then:
+ * - try to use second creation mode (directly using of the window handle)
+ * - if it failed ... use the old way by packing the handle inside an object
+ *
+ * @param xSMGR
+ * we need a service manager to be able to create remote office
+ * services
+ *
+ * @param aParentView
+ * the java window as parent for the office window if an inplace office
+ * is required. If it is set to null the created office window will be
+ * a normal system window outside of our java application.
+ *
+ * @return [com.sun.star.awt.XWindow]
+ * The new created office window which can be used to set it as
+ * a ContainerWindow on an empty office frame.
+ */
+ private static com.sun.star.awt.XWindow impl_createWindow(
+ com.sun.star.uno.XComponentContext xCtx, NativeView aParentView )
+ {
+ com.sun.star.awt.XWindow xWindow = null;
+ com.sun.star.awt.XWindowPeer xPeer = null;
+ com.sun.star.awt.XToolkit xToolkit = null;
+
+ // get access to toolkit of remote office to create the container window of
+ // new target frame
+ try{
+ xToolkit = UnoRuntime.queryInterface(
+ com.sun.star.awt.XToolkit.class,
+ xCtx.getServiceManager().createInstanceWithContext(
+ "com.sun.star.awt.Toolkit", xCtx));
+ }
+ catch(com.sun.star.uno.Exception ex)
+ {
+ return null;
+ }
+
+ // mode 1) create an external system window
+ if (aParentView==null)
+ {
+ // Describe the properties of the container window.
+ com.sun.star.awt.WindowDescriptor aDescriptor =
+ new com.sun.star.awt.WindowDescriptor();
+ aDescriptor.Type = com.sun.star.awt.WindowClass.TOP;
+ aDescriptor.WindowServiceName = "window";
+ aDescriptor.ParentIndex = -1;
+ aDescriptor.Parent = null;
+ aDescriptor.Bounds = new com.sun.star.awt.Rectangle(0,0,0,0);
+ aDescriptor.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;
+
+ try{
+ xPeer = xToolkit.createWindow( aDescriptor );
+ } catch(com.sun.star.lang.IllegalArgumentException exIllegal) {}
+ }
+ // mode 2) create an internal office window as child of our given java
+ // parent window
+ else
+ {
+ // try new version of creation first: directly using of the window
+ // handle. The old implementation of the corresponding toolkit method
+ // requires a process ID. If this id isn't the right one a null object
+ // is returned. But normally nobody outside the office knows this id.
+ // New version of this method ignore the id parameter and creation will
+ // work.
+ // Note: You must be sure if your window handle can be really used by
+ // the remote office. Means if this java client and the remote office
+ // use the same display!
+ com.sun.star.awt.XSystemChildFactory xChildFactory =
+ UnoRuntime.queryInterface(
+ com.sun.star.awt.XSystemChildFactory.class, xToolkit);
+
+ try
+ {
+ Integer nHandle = aParentView.getHWND();
+ short nSystem = (short)aParentView.getNativeWindowSystemType();
+ byte[] lProcID = new byte[0];
+
+ xPeer = xChildFactory.createSystemChild(nHandle,
+ lProcID, nSystem);
+
+ if (xPeer==null)
+ {
+ // mode 3) OK - new version doesn't work. It requires the
+ // process id which we don't have.
+ // So we must use the old way to get the right window peer.
+ // Pack the handle inside a wrapper object.
+ JavaWindowPeerFake aWrapper = new
+ JavaWindowPeerFake(aParentView);
+
+ com.sun.star.awt.XWindowPeer xParentPeer =
+ UnoRuntime.queryInterface(
+ com.sun.star.awt.XWindowPeer.class, aWrapper);
+
+ com.sun.star.awt.WindowDescriptor aDescriptor =
+ new com.sun.star.awt.WindowDescriptor();
+ aDescriptor.Type = com.sun.star.awt.WindowClass.TOP;
+ aDescriptor.WindowServiceName = "workwindow";
+ aDescriptor.ParentIndex = 1;
+ aDescriptor.Parent = xParentPeer;
+ aDescriptor.Bounds = new com.sun.star.awt.Rectangle(0,0,0,0);
+ if (nSystem == com.sun.star.lang.SystemDependent.SYSTEM_WIN32)
+ aDescriptor.WindowAttributes =
+ com.sun.star.awt.WindowAttribute.SHOW;
+ else
+ aDescriptor.WindowAttributes =
+ com.sun.star.awt.WindowAttribute.SYSTEMDEPENDENT;
+
+ try{
+ xPeer = xToolkit.createWindow( aDescriptor );
+ } catch(com.sun.star.lang.IllegalArgumentException exIllegal) {}
+ }
+ }
+ catch(java.lang.RuntimeException exJRun)
+ {
+ // This exception is thrown by the native JNI code if it try to get
+ // the systemw window handle. A possible reason can be an invisible
+ // java window. In this case it should be enough to set return
+ // values to null. All other resources (which was created before)
+ // will be freed automatically if scope will be leaved.
+ System.out.println("May be the NativeView object wasn't really visible at calling time of getNativeWindow()?");
+ xPeer = null;
+ xWindow = null;
+ }
+ }
+
+ // It doesn't matter which way was used to get the window peer.
+ // Cast it to the right return interface and return it.
+ xWindow = UnoRuntime.queryInterface(
+ com.sun.star.awt.XWindow.class,
+ xPeer);
+
+ return xWindow;
+ }
+
+
+
+ /**
+ * This method create a new empty child frame on desktop instance of remote office.
+ * It use a special JNI functionality to pass the office XWindow over a java window.
+ * This java window can be inserted into another java window container for complex layouting.
+ * If this parent java window isn't used, a top level system window will be created.
+ * The resulting office frame isn't plugged into this java application.
+ *
+ * @param sName
+ * name to set it on the new created frame
+ *
+ * @param aParentView
+ * java window which should be used as parent window of new created office frame window
+ * May be set to null.
+ *
+ * @return [com.sun.star.frame.XFrame]
+ * reference to the new created frame for success or null if it failed
+ */
+ public static com.sun.star.frame.XFrame createViewFrame(String sName, NativeView aParentView)
+ {
+ com.sun.star.frame.XFrame xFrame = null;
+
+ try
+ {
+ com.sun.star.uno.XComponentContext xCtx =
+ OfficeConnect.getOfficeContext();
+
+ // create an empty office frame first
+ xFrame = impl_createEmptyFrame(xCtx);
+
+ // create an office window then
+ // Depending from the given parameter aParentView it will be a child or a top level
+ // system window. (see impl method for further information)
+ // But before we call this helper - prepare the possible parent window: show it.
+ // JNI calls to get system window handle of java window can't work without that!
+ if (aParentView!=null)
+ aParentView.setVisible(true);
+ com.sun.star.awt.XWindow xWindow = impl_createWindow(xCtx, aParentView);
+
+ // pass the window the frame as his new container window.
+ // It's necessary to do it first - before you call anything else there.
+ // Otherwise the frame throws some exceptions for "uninitialized state".
+ xFrame.initialize( xWindow );
+
+ // Insert the new frame in desktop hierarchy.
+ // Use XFrames interface to do so. It provides access to the child frame container of that instance.
+ com.sun.star.frame.XFramesSupplier xTreeRoot = UnoRuntime.queryInterface(
+ com.sun.star.frame.XFramesSupplier.class,
+ xCtx.getServiceManager().createInstanceWithContext(
+ "com.sun.star.frame.Desktop", xCtx));
+ com.sun.star.frame.XFrames xChildContainer = xTreeRoot.getFrames();
+ xChildContainer.append(xFrame);
+
+ // Make some further initializations on frame and window.
+ xWindow.setVisible(true);
+ xFrame.setName(sName);
+ }
+ catch(com.sun.star.uno.RuntimeException exRuntime)
+ {
+ // Any UNO method of this scope can throw this exception.
+ // So the frame can be already created and he must be freed
+ // correctly. May be he was inserted into the desktop tree too ...
+ if(xFrame!=null)
+ {
+ // Try to dispose the frame. He should deregister himself at the desktop object
+ // and free all internal used resources (e.g. the container window) automatically.
+ // It's possible to do that here - because frame has no component inside yet.
+ // So nobody can disagree with that.
+ // After the dispose() call forget all references to this frame and let him die.
+ // If a new exception will occur ... no general solution exist then.
+ // Nobody can guarantee if next call will work or not.
+ com.sun.star.lang.XComponent xComponent = UnoRuntime.queryInterface(
+ com.sun.star.lang.XComponent.class,
+ xFrame);
+ xComponent.dispose();
+ xComponent = null;
+ xFrame = null;
+ }
+ }
+ catch(com.sun.star.uno.Exception exUno)
+ {
+ // "createInstance()" method of used service manager can throw it.
+ // If it occurred during creation of desktop service the frame already was created.
+ // Free it by decreasing his refcount. Changes on the desktop tree couldn't exist.
+ // Without the desktop service that wasn't possible. So no further rollbacks must follow.
+ if(xFrame!=null)
+ {
+ com.sun.star.lang.XComponent xComponent = UnoRuntime.queryInterface(
+ com.sun.star.lang.XComponent.class,
+ xFrame);
+ xComponent.dispose();
+ xComponent = null;
+ xFrame = null;
+ }
+ }
+
+ return xFrame;
+ }
+
+
+
+ /**
+ * Dispatch a URL to given frame.
+ * Caller can register himself for following status events for dispatched
+ * URL too. But nobody guarantee that such notifications will occur.
+ * (see dispatchWithNotification() if you interest on that)
+ * The returned dispatch object should be hold alive by caller
+ * till he doesn't need it any longer. Otherwise the dispatcher can(!)
+ * die by decreasing his refcount.
+ *
+ * @param xFrame frame which should be the target of this dispatch
+ * @param aURL full parsed and converted office URL for dispatch
+ * @param lProperties optional arguments for dispatch
+ * @param xListener optional listener which is registered automatically for status events
+ * (Note: Deregistration is part of this listener himself!)
+ *
+ * @return [XDispatch] It's the used dispatch object and can be used for deregistration of an optional listener.
+ * Otherwise caller can ignore it.
+ */
+ public static com.sun.star.frame.XDispatch execute(com.sun.star.frame.XFrame xFrame ,
+ com.sun.star.util.URL aURL ,
+ com.sun.star.beans.PropertyValue[] lProperties,
+ com.sun.star.frame.XStatusListener xListener )
+ {
+ com.sun.star.frame.XDispatch xDispatcher = null;
+
+ try
+ {
+ // Query the frame for right interface which provides access to all available dispatch objects.
+ com.sun.star.frame.XDispatchProvider xProvider = UnoRuntime.queryInterface(
+ com.sun.star.frame.XDispatchProvider.class,
+ xFrame);
+
+ // Ask him for right dispatch object for given URL.
+ // Force given frame as target for following dispatch by using "".
+ // It means the same like "_self".
+ xDispatcher = xProvider.queryDispatch(aURL,"",0);
+
+ // Dispatch the URL into the frame.
+ if(xDispatcher!=null)
+ {
+ if(xListener!=null)
+ xDispatcher.addStatusListener(xListener,aURL);
+
+ xDispatcher.dispatch(aURL,lProperties);
+ }
+ }
+ catch(com.sun.star.uno.RuntimeException exUno)
+ {
+ // Any UNO method of this scope can throw this exception.
+ // But there will be nothing to do then - because
+ // we haven't changed anything inside the remote objects
+ // except method "addStatusListener().
+ // But in this case the source of this exception has to
+ // rollback all his operations. There is no chance to
+ // make anything right then.
+ // Reset the return value to a default - that's it.
+ exUno.printStackTrace();
+ xDispatcher = null;
+ }
+
+ return xDispatcher;
+ }
+
+
+
+
+
+
+
+ /**
+ * Load document specified by a URL into given frame synchronously.
+ * The result of this operation will be the loaded document for success
+ * or null if loading failed.
+ *
+ * @param xFrame frame which should be the target of this load call
+ * @param sURL unparsed URL for loading
+ * @param lProperties optional arguments
+ *
+ * @return [XComponent] the loaded document for success or null if it's failed
+ */
+ public static com.sun.star.lang.XComponent loadDocument(
+ com.sun.star.frame.XFrame xFrame, String sURL,
+ com.sun.star.beans.PropertyValue[] lProperties)
+ {
+ com.sun.star.lang.XComponent xDocument = null;
+ String sOldName = null;
+
+ try
+ {
+ com.sun.star.uno.XComponentContext xCtx =
+ OfficeConnect.getOfficeContext();
+
+ // First prepare frame for loading
+ // We must address it inside the frame tree without any complications.
+ // So we set an unambiguous (we hope it) name and use it later.
+ // Don't forget to reset original name after that.
+ sOldName = xFrame.getName();
+ String sTarget = "odk_officedev_desk";
+ xFrame.setName(sTarget);
+
+ // Get access to the global component loader of the office
+ // for synchronous loading the document.
+ com.sun.star.frame.XComponentLoader xLoader =
+ UnoRuntime.queryInterface(
+ com.sun.star.frame.XComponentLoader.class,
+ xCtx.getServiceManager().createInstanceWithContext(
+ "com.sun.star.frame.Desktop", xCtx));
+
+ // Load the document into the target frame by using his name and
+ // special search flags.
+ xDocument = xLoader.loadComponentFromURL(
+ sURL,
+ sTarget,
+ com.sun.star.frame.FrameSearchFlag.CHILDREN,
+ lProperties);
+
+ // don't forget to restore old frame name...
+ xFrame.setName(sOldName);
+ }
+ catch(com.sun.star.io.IOException exIO)
+ {
+ // Can be thrown by "loadComponentFromURL()" call.
+ // The only thing we should do then is to reset changed frame name!
+ exIO.printStackTrace();
+ xDocument = null;
+ if(sOldName!=null)
+ xFrame.setName(sOldName);
+ }
+ catch(com.sun.star.lang.IllegalArgumentException exIllegal)
+ {
+ // Can be thrown by "loadComponentFromURL()" call.
+ // The only thing we should do then is to reset changed frame name!
+ exIllegal.printStackTrace();
+ xDocument = null;
+ if(sOldName!=null)
+ xFrame.setName(sOldName);
+ }
+ catch(com.sun.star.uno.RuntimeException exRuntime)
+ {
+ // Any UNO method of this scope can throw this exception.
+ // The only thing we can try(!) is to reset changed frame name.
+ exRuntime.printStackTrace();
+ xDocument = null;
+ if(sOldName!=null)
+ xFrame.setName(sOldName);
+ }
+ catch(com.sun.star.uno.Exception exUno)
+ {
+ // "createInstance()" method of used service manager can throw it.
+ // The only thing we should do then is to reset changed frame name!
+ exUno.printStackTrace();
+ xDocument = null;
+ if(sOldName!=null)
+ xFrame.setName(sOldName);
+ }
+
+ return xDocument;
+ }
+
+
+
+ /**
+ * Save currently loaded document of given frame.
+ *
+ * @param xDocument document for saving changes
+ */
+ public static void saveDocument(com.sun.star.lang.XComponent xDocument)
+ {
+ try
+ {
+ // Check for supported model functionality.
+ // Normally the application documents (text, spreadsheet ...) do so
+ // but some other ones (e.g. db components) doesn't do that.
+ // They can't be save then.
+ com.sun.star.frame.XModel xModel = UnoRuntime.queryInterface(
+ com.sun.star.frame.XModel.class,
+ xDocument);
+ if(xModel!=null)
+ {
+ // Check for modifications => break save process if there is nothing to do.
+ com.sun.star.util.XModifiable xModified = UnoRuntime.queryInterface(
+ com.sun.star.util.XModifiable.class,
+ xModel);
+ if(xModified.isModified())
+ {
+ com.sun.star.frame.XStorable xStore = UnoRuntime.queryInterface(
+ com.sun.star.frame.XStorable.class,
+ xModel);
+
+ xStore.store();
+ }
+ }
+ }
+ catch(com.sun.star.io.IOException exIO)
+ {
+ // Can be thrown by "store()" call.
+ // But there is nothing we can do then.
+ exIO.printStackTrace();
+ }
+ catch(com.sun.star.uno.RuntimeException exUno)
+ {
+ // Any UNO method of this scope can throw this exception.
+ // But there is nothing we can do then.
+ exUno.printStackTrace();
+ }
+ }
+
+
+
+ /**
+ * It try to export given document in HTML format.
+ * Current document will be converted to HTML and moved to new place on disk.
+ * A "new" file will be created by given URL (may be overwritten
+ * if it already exist). Right filter will be used automatically if factory of
+ * this document support it. If no valid filter can be found for export,
+ * nothing will be done here.
+ *
+ * @param xDocument document which should be exported
+ * @param sURL target URL for converted document
+ */
+ public static void saveAsHTML(com.sun.star.lang.XComponent xDocument,
+ String sURL )
+ {
+ try
+ {
+ // First detect factory of this document.
+ // Ask for the supported service name of this document.
+ // If information is available it can be used to find out which
+ // filter exist for HTML export. Normally this filter should be searched
+ // inside the filter configuration but this little demo doesn't do so.
+ // (see service com.sun.star.document.FilterFactory for further
+ // information too)
+ // Well known filter names are used directly. They must exist in current
+ // office installation. Otherwise this code will fail. But to prevent
+ // this code against missing filters it check for existing state of it.
+ com.sun.star.lang.XServiceInfo xInfo = UnoRuntime.queryInterface(com.sun.star.lang.XServiceInfo.class,
+ xDocument);
+
+ if(xInfo!=null)
+ {
+ // Find out possible filter name.
+ String sFilter = null;
+ if(xInfo.supportsService("com.sun.star.text.TextDocument"))
+ sFilter = "HTML (StarWriter)";
+ else
+ if(xInfo.supportsService("com.sun.star.text.WebDocument"))
+ sFilter = "HTML";
+ else
+ if(xInfo.supportsService("com.sun.star.sheet.SpreadsheetDocument"))
+ sFilter = "HTML (StarCalc)";
+
+ // Check for existing state of this filter.
+ if(sFilter!=null)
+ {
+ com.sun.star.uno.XComponentContext xCtx =
+ OfficeConnect.getOfficeContext();
+
+ com.sun.star.container.XNameAccess xFilterContainer =
+ UnoRuntime.queryInterface(
+ com.sun.star.container.XNameAccess.class,
+ xCtx.getServiceManager().createInstanceWithContext(
+ "com.sun.star.document.FilterFactory", xCtx));
+
+ if(!xFilterContainer.hasByName(sFilter))
+ sFilter=null;
+ }
+
+ // Use this filter for export.
+ if(sFilter!=null)
+ {
+ // Export can be forced by saving the document and using a
+ // special filter name which can write needed format. Build
+ // necessary argument list now.
+ // Use special flag "Overwrite" too, to prevent operation
+ // against possible exceptions, if file already exist.
+ com.sun.star.beans.PropertyValue[] lProperties =
+ new com.sun.star.beans.PropertyValue[2];
+ lProperties[0] = new com.sun.star.beans.PropertyValue();
+ lProperties[0].Name = "FilterName";
+ lProperties[0].Value = sFilter;
+ lProperties[1] = new com.sun.star.beans.PropertyValue();
+ lProperties[1].Name = "Overwrite";
+ lProperties[1].Value = Boolean.TRUE;
+
+ com.sun.star.frame.XStorable xStore =
+ UnoRuntime.queryInterface(
+ com.sun.star.frame.XStorable.class, xDocument);
+
+ xStore.storeAsURL(sURL,lProperties);
+ }
+ }
+ }
+ catch(com.sun.star.io.IOException exIO)
+ {
+ // Can be thrown by "store()" call.
+ // Do nothing then. Saving failed - that's it.
+ exIO.printStackTrace();
+ }
+ catch(com.sun.star.uno.RuntimeException exRuntime)
+ {
+ // Can be thrown by any uno call.
+ // Do nothing here. Saving failed - that's it.
+ exRuntime.printStackTrace();
+ }
+ catch(com.sun.star.uno.Exception exUno)
+ {
+ // Can be thrown by "createInstance()" call of service manager.
+ // Do nothing here. Saving failed - that's it.
+ exUno.printStackTrace();
+ }
+ }
+
+
+
+
+
+
+
+ /*
+ * Try to close the frame instead of the document.
+ * It shows the possible interface to do so.
+ *
+ * @param xFrame
+ * frame which should be closed
+ *
+ * @return <TRUE/> in case frame could be closed
+ * <FALSE/> otherwise
+ */
+ public static boolean closeFrame(com.sun.star.frame.XFrame xFrame)
+ {
+ boolean bClosed = false;
+
+ try
+ {
+ // first try the new way: use new interface XCloseable
+ // It replace the deprecated XTask::close() and should be preferred ...
+ // if it can be queried.
+ com.sun.star.util.XCloseable xCloseable =
+ UnoRuntime.queryInterface(
+ com.sun.star.util.XCloseable.class, xFrame);
+ if (xCloseable!=null)
+ {
+ // We deliver the ownership of this frame not to the (possible)
+ // source which throw a CloseVetoException. We wish to have it
+ // under our own control.
+ try
+ {
+ xCloseable.close(false);
+ bClosed = true;
+ }
+ catch( com.sun.star.util.CloseVetoException exVeto )
+ {
+ bClosed = false;
+ }
+ }
+ else
+ {
+ // OK: the new way isn't possible. Try the old one.
+ com.sun.star.frame.XTask xTask = UnoRuntime.queryInterface(com.sun.star.frame.XTask.class,
+ xFrame);
+ if (xTask!=null)
+ {
+ // return value doesn't interest here. Because
+ // we forget this task ...
+ bClosed = xTask.close();
+ }
+ }
+ }
+ catch (com.sun.star.lang.DisposedException exDisposed)
+ {
+ // Of course - this task can be already dead - means disposed.
+ // But for us it's not important. Because we tried to close it too.
+ // And "already disposed" or "closed" should be the same ...
+ bClosed = true;
+ }
+
+ return bClosed;
+ }
+
+
+
+ /**
+ * Try to find a unique frame name, which isn't currently used inside
+ * remote office instance. Because we create top level frames
+ * only, it's enough to check the names of existing child frames on the
+ * desktop only.
+ *
+ * should represent a unique frame name, which currently isn't
+ * used inside the remote office frame tree
+ * (Couldn't guaranteed for a real multithreaded environment.
+ * But we try it ...)
+ */
+ private static final String BASEFRAMENAME = "Desk View ";
+
+ public static String getUniqueFrameName()
+ {
+ String sName = null;
+
+ com.sun.star.uno.XComponentContext xCtx = OfficeConnect.getOfficeContext();
+
+ try
+ {
+ com.sun.star.frame.XFramesSupplier xSupplier =
+ UnoRuntime.queryInterface(
+ com.sun.star.frame.XFramesSupplier.class,
+ xCtx.getServiceManager().createInstanceWithContext(
+ "com.sun.star.frame.Desktop", xCtx));
+
+ com.sun.star.container.XIndexAccess xContainer =
+ UnoRuntime.queryInterface(
+ com.sun.star.container.XIndexAccess.class,
+ xSupplier.getFrames());
+
+ int nCount = xContainer.getCount();
+ for (int i=0; i<nCount; ++i )
+ {
+ com.sun.star.frame.XFrame xFrame = (com.sun.star.frame.XFrame)AnyConverter.toObject(new com.sun.star.uno.Type(com.sun.star.frame.XFrame.class), xContainer.getByIndex(i));
+ sName = BASEFRAMENAME+mnViewCount;
+ while(sName.equals(xFrame.getName()))
+ {
+ ++mnViewCount;
+ sName = BASEFRAMENAME+mnViewCount;
+ }
+ }
+ }
+ catch(com.sun.star.uno.Exception exCreateFailed)
+ {
+ sName = BASEFRAMENAME;
+ }
+
+ if (sName==null)
+ {
+ System.out.println("invalid name!");
+ sName = BASEFRAMENAME;
+ }
+
+ return sName;
+ }
+
+
+
+ /**
+ * helper to get a file URL selected by user
+ * This method doesn't show any API concepts...
+ * but is necessary for this demo application.
+ *
+ * @param aParent parent window of this dialog
+ * @param bOpen If it is set to true =>
+ * dialog is opened in "file open" mode -
+ * otherwise in "file save" mode.
+ */
+ public static String askUserForFileURL(Component aParent,boolean bOpen)
+ {
+ String sFileURL = null;
+ int nDecision = JFileChooser.CANCEL_OPTION;
+ JFileChooser aChooser = null;
+
+ // set last visited directory on new file chosser
+ // (if this information is available)
+ if( maLastDir==null )
+ aChooser = new JFileChooser();
+ else
+ aChooser = new JFileChooser(maLastDir);
+
+ // decide between file open/save dialog
+ if( bOpen )
+ nDecision = aChooser.showOpenDialog(aParent);
+ else
+ nDecision = aChooser.showSaveDialog(aParent);
+
+ // react for "OK" result only
+ if(nDecision == JFileChooser.APPROVE_OPTION)
+ {
+ // save current directory as last visited one
+ maLastDir = aChooser.getCurrentDirectory();
+ // get file URL from the dialog
+ try
+ {
+ sFileURL = aChooser.getSelectedFile().toURI().toURL().toExternalForm();
+ }
+ catch( MalformedURLException ex )
+ {
+ ex.printStackTrace();
+ sFileURL = null;
+ }
+ // problem of java: file URL's are coded with 1 slash instead of 3 ones!
+ // => correct this problem first, otherwise office can't use these URL's
+ if(
+ ( sFileURL !=null ) &&
+ ( sFileURL.startsWith("file:/") ) &&
+ ( !sFileURL.startsWith("file://") )
+ )
+ {
+ StringBuffer sWorkBuffer = new StringBuffer(sFileURL);
+ sWorkBuffer.insert(6,"//");
+ sFileURL = sWorkBuffer.toString();
+ }
+ }
+
+ return sFileURL;
+ }
+
+
+
+ /**
+ * @member maLastDir save the last visited directory of used file open/save dialog
+ * @member mnViewCount we try to set unique names on every frame we create (that's why we must count it)
+ */
+ private static File maLastDir = null;
+ private static int mnViewCount = 0 ;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/IOnewayLink.java b/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/IOnewayLink.java
new file mode 100644
index 000000000..c6732155d
--- /dev/null
+++ b/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/IOnewayLink.java
@@ -0,0 +1,71 @@
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+import java.util.ArrayList;
+
+// __________ Implementation __________
+
+/**
+ * We need a generic interface to forward any oneway uno interface method
+ * by using threads to the original object. Reason:
+ * It's not allowed to call synchronous back to the office if a java object
+ * was called in a oneway declared interface method. Then it must be
+ * executed asynchronous. To do so - a thread can be created which use this
+ * interface. It get the object, which has to be called back and the type and
+ * parameter of the original request.
+ *
+ */
+public interface IOnewayLink
+{
+
+
+ /**
+ * @param nRequest
+ * The two user of this callback can define a unique number,
+ * which identify the type of original interface method. So the called
+ * interface object can decide, which action will be necessary.
+ *
+ * @param lParams
+ * If the original method used parameters, they will be coded here in
+ * a generic way. Only the called interface object know (it depends
+ * from the original request - see nRequest too), how this list must
+ * be interpreted.
+ * Note: Atomic types (e.g. int, long) will be transported as objects
+ * too (Integer, Long)!
+ */
+ void execOneway( int nRequest, ArrayList<Object> lParams );
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/IShutdownListener.java b/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/IShutdownListener.java
new file mode 100644
index 000000000..753d364d0
--- /dev/null
+++ b/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/IShutdownListener.java
@@ -0,0 +1,48 @@
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+// __________ Implementation __________
+
+/**
+ * Listener interface to get information about application shutdown
+ * if java virtual machine dies.
+ *
+ */
+public interface IShutdownListener
+{
+ void shutdown();
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/Install.txt b/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/Install.txt
new file mode 100644
index 000000000..79a1ee2bf
--- /dev/null
+++ b/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/Install.txt
@@ -0,0 +1,10 @@
+(1) goto "./nativelib/<platform>" directory and build it
+(2) build this directory
+(3) expand your class path to include all jar files of an office installation
+ (means all files in path "<officeinst>/program/classes")
+(4) goto "api/<platform>/class"
+(5) copy from an existing java installation the runtime library "jawt" (e.g. jawt.dll for windows)
+ into this directory
+(6) copy "api/<platform>/bin/nativelib.dll" (for windows) to "api/<platform>/class"
+(7) start an office : "soffice --accept=socket,host=localhost,port=2083;urp;"
+(8) goto "api/<platform>/class" and start java applet: "java -jar desktop.jar"
diff --git a/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/Interceptor.java b/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/Interceptor.java
new file mode 100644
index 000000000..380f8da3c
--- /dev/null
+++ b/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/Interceptor.java
@@ -0,0 +1,655 @@
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+// Imports
+
+import java.util.ArrayList;
+
+import com.sun.star.frame.FrameActionEvent;
+import com.sun.star.uno.UnoRuntime;
+
+// Implementation
+
+/*
+ * This class can be used to intercept dispatched URL's
+ * on any frame used in this demo application.
+ * It intercept all URL's which try to create a new empty frame.
+ * (e.g. "private:factory/swriter")
+ * Nobody can guarantee that this interception will be really used -
+ * because another interceptor (registered at a later time then this one!)
+ * will be called before this one.
+ * Implementation is executed inside a new thread to prevent application
+ * against possible deadlocks. This deadlocks can occur if
+ * synchronous/asynchronous ... normal ones and oneway calls are mixed.
+ * Notifications of listener will be oneway mostly - her reactions can
+ * be synchronous then. => deadlocks are possible
+ */
+public class Interceptor implements com.sun.star.frame.XFrameActionListener,
+ com.sun.star.frame.XDispatchProviderInterceptor,
+ com.sun.star.frame.XDispatch,
+ com.sun.star.frame.XInterceptorInfo,
+ IShutdownListener,
+ IOnewayLink
+{
+
+
+ /**
+ * const
+ * All these URL's are intercepted by this implementation.
+ */
+ private static final String[] INTERCEPTED_URLS = { "private:factory/*" ,
+ ".uno:SaveAs" ,
+ "slot:5300" ,
+ ".uno:Quit" };
+
+
+
+ /*
+ * @member m_xMaster use this interceptor if he doesn't handle queried dispatch request
+ * @member m_xSlave we can forward all unhandled requests to this slave interceptor
+ * @member m_xFrame intercepted frame
+ * @member m_bDead there exist more than one way to finish an object of this class - we must know it sometimes
+ */
+ private com.sun.star.frame.XDispatchProvider m_xMaster ;
+ private com.sun.star.frame.XDispatchProvider m_xSlave ;
+ private com.sun.star.frame.XFrame m_xFrame ;
+ private boolean m_bIsActionListener ;
+ private boolean m_bIsRegistered ;
+ private boolean m_bDead ;
+
+
+
+ /*
+ * ctor
+ * Initialize the new interceptor. Given frame reference can be used to
+ * register this interceptor on it automatically later.
+ *
+ * @seealso startListening()
+ *
+ * @param xFrame
+ * this interceptor will register himself at this frame to intercept dispatched URLs
+ */
+ Interceptor(/*IN*/ com.sun.star.frame.XFrame xFrame)
+ {
+ m_xFrame = xFrame ;
+ m_xSlave = null ;
+ m_xMaster = null ;
+ m_bIsRegistered = false ;
+ m_bIsActionListener = false ;
+ m_bDead = false ;
+ }
+
+
+
+ /*
+ * start working as frame action listener really.
+ * We will be frame action listener here. In case
+ * we get a frame action which indicates, that we should
+ * update our interception. Because such using of an interceptor
+ * isn't guaranteed - in case a newer one was registered...
+ */
+ public void startListening()
+ {
+ com.sun.star.frame.XFrame xFrame = null;
+ synchronized(this)
+ {
+ if (m_bDead)
+ return;
+ if (m_xFrame==null)
+ return;
+ if (m_bIsActionListener)
+ return;
+ xFrame = m_xFrame;
+ }
+ m_xFrame.addFrameActionListener(this);
+ synchronized(this)
+ {
+ m_bIsActionListener=true;
+ }
+ }
+
+
+
+ /*
+ * In case we got a oneway listener callback - we had to use the office
+ * asynchronous then. This method is the callback from the started thread
+ * (started inside the original oneway method). We found all parameters of
+ * the original request packed inside a vector. Here we unpack it and
+ * call the right internal helper method, which implements the right
+ * functionality.
+ *
+ * @seealso frameAction()
+ * @seealso dispatch()
+ *
+ * @param nRequest
+ * indicates, which was the original request (identifies the
+ * original called method)
+ *
+ * @param lParams
+ * the vector with all packed parameters of the original request
+ */
+ public void execOneway(/*IN*/ int nRequest,/*IN*/ ArrayList<Object> lParams )
+ {
+ synchronized(this)
+ {
+ if (m_bDead)
+ return;
+ }
+
+ // was it frameAction()?
+ if (nRequest==OnewayExecutor.REQUEST_FRAMEACTION)
+ {
+ impl_frameAction((FrameActionEvent) lParams.get(0));
+ }
+ else
+ // was it dispatch()?
+ if (nRequest==OnewayExecutor.REQUEST_DISPATCH)
+ {
+ com.sun.star.util.URL[] lOutURL = new com.sun.star.util.URL[1];
+ com.sun.star.beans.PropertyValue[][] lOutProps = new com.sun.star.beans.PropertyValue[1][];
+
+ OnewayExecutor.decodeDispatch(
+ lParams ,
+ lOutURL ,
+ lOutProps );
+ impl_dispatch(lOutURL[0],lOutProps[0]);
+ }
+ }
+
+
+
+ /*
+ * callback for frame action events
+ * We use it to update our interception. Because if a new component was loaded into
+ * the frame or another interceptor was registered, we should refresh our connection
+ * to the frame. Otherwise we can't guarantee full functionality here.
+ *
+ * Note: Don't react synchronous in an asynchronous listener callback. So use a thread
+ * here to update anything.
+ *
+ * @seealso impl_frameAction()
+ *
+ * @param aEvent
+ * describes the action
+ */
+ public /*ONEWAY*/ void frameAction(/*IN*/ com.sun.star.frame.FrameActionEvent aEvent)
+ {
+ synchronized(this)
+ {
+ if (m_bDead)
+ return;
+ }
+
+ boolean bHandle = false;
+ switch(aEvent.Action.getValue())
+ {
+ case com.sun.star.frame.FrameAction.COMPONENT_ATTACHED_value : bHandle=true; break;
+ case com.sun.star.frame.FrameAction.COMPONENT_DETACHING_value : bHandle=true; break;
+ case com.sun.star.frame.FrameAction.COMPONENT_REATTACHED_value : bHandle=true; break;
+ // Don't react for CONTEXT_CHANGED here. Ok it indicates, that may another interceptor
+ // was registered at the frame ... but if we register ourself there - we get a context
+ // changed too :-( Best way to produce a never ending recursion ...
+ // May be that somewhere find a safe mechanism to detect own produced frame action events
+ // and ignore it.
+ case com.sun.star.frame.FrameAction.CONTEXT_CHANGED_value :
+ System.out.println("Time to update interception ... but may it will start a recursion. So I let it :-(");
+ bHandle=false;
+ break;
+ }
+
+ // ignore some events
+ if (! bHandle)
+ return;
+
+ // pack the event and start thread - which call us back later
+ ArrayList<Object> lOutParams = new ArrayList<Object>();
+ lOutParams.add(aEvent);
+
+ OnewayExecutor aExecutor = new OnewayExecutor( this ,
+ OnewayExecutor.REQUEST_FRAMEACTION ,
+ lOutParams );
+ aExecutor.start();
+ }
+
+
+
+ /*
+ * Indicates using of us as an interceptor.
+ * Now we have to react for the requests, we are registered.
+ * That means: load new empty documents - triggered by the new menu of the office.
+ * Because it's oneway - use thread for loading!
+ *
+ * @seealso impl_dispatch()
+ *
+ * @param aURL
+ * describes the document, which should be loaded
+ *
+ * @param lArguments
+ * optional parameters for loading
+ */
+ public /*ONEWAY*/ void dispatch(/*IN*/ com.sun.star.util.URL aURL,/*IN*/ com.sun.star.beans.PropertyValue[] lArguments)
+ {
+ synchronized(this)
+ {
+ if (m_bDead)
+ return;
+ }
+
+ com.sun.star.util.URL[] lInURL = new com.sun.star.util.URL[1];
+ com.sun.star.beans.PropertyValue[][] lInArguments = new com.sun.star.beans.PropertyValue[1][];
+ lInURL[0] = aURL ;
+ lInArguments[0] = lArguments;
+
+ ArrayList<Object> lOutParams = OnewayExecutor.encodeDispatch(
+ lInURL ,
+ lInArguments );
+ OnewayExecutor aExecutor = new OnewayExecutor( this ,
+ OnewayExecutor.REQUEST_DISPATCH ,
+ lOutParams );
+ aExecutor.start();
+ }
+
+
+
+
+ /*
+ * Internal callback for frame action events, triggered by the used
+ * OnewayExecutor thread we started in frameAction().
+ * We use it to update our interception on the internal saved frame.
+ *
+ * @param aEvent
+ * describes the action
+ */
+ private void impl_frameAction(/*IN*/ com.sun.star.frame.FrameActionEvent aEvent)
+ {
+ synchronized(this)
+ {
+ if (m_bDead)
+ return;
+ }
+
+ // deregistration will be done every time...
+ // But may it's not necessary to establish a new registration!
+ // Don't look for ignoring actions - it was done already inside original frameAction() call!
+ boolean bRegister = false;
+
+ // analyze the event and decide which reaction is useful
+ switch(aEvent.Action.getValue())
+ {
+ case com.sun.star.frame.FrameAction.COMPONENT_ATTACHED_value : bRegister = true ; break;
+ case com.sun.star.frame.FrameAction.COMPONENT_REATTACHED_value : bRegister = true ; break;
+ case com.sun.star.frame.FrameAction.COMPONENT_DETACHING_value : bRegister = false; break;
+ }
+
+ com.sun.star.frame.XFrame xFrame = null ;
+ boolean bIsRegistered = false;
+ synchronized(this)
+ {
+ bIsRegistered = m_bIsRegistered;
+ m_bIsRegistered = false;
+ xFrame = m_xFrame;
+ }
+
+ com.sun.star.frame.XDispatchProviderInterception xRegistration = UnoRuntime.queryInterface(
+ com.sun.star.frame.XDispatchProviderInterception.class,
+ xFrame);
+
+ if(xRegistration==null)
+ return;
+
+ if (bIsRegistered)
+ xRegistration.releaseDispatchProviderInterceptor(this);
+
+ if (! bRegister)
+ return;
+
+ xRegistration.registerDispatchProviderInterceptor(this);
+ synchronized(this)
+ {
+ m_bIsRegistered = true;
+ }
+ }
+
+
+
+ /*
+ * Implementation of interface XDispatchProviderInterceptor
+ * These functions are used to build a list of interceptor objects
+ * connected in both ways.
+ * Searching for a right interceptor is made by forwarding any request
+ * from toppest master to lowest slave of this hierarchy.
+ * If an interceptor wish to handle the request he can break that
+ * and return himself as a dispatcher.
+ */
+ public com.sun.star.frame.XDispatchProvider getSlaveDispatchProvider()
+ {
+ synchronized(this)
+ {
+ return m_xSlave;
+ }
+ }
+
+
+
+ public void setSlaveDispatchProvider(com.sun.star.frame.XDispatchProvider xSlave)
+ {
+ synchronized(this)
+ {
+ m_xSlave = xSlave;
+ }
+ }
+
+
+
+ public com.sun.star.frame.XDispatchProvider getMasterDispatchProvider()
+ {
+ synchronized(this)
+ {
+ return m_xMaster;
+ }
+ }
+
+
+
+ public void setMasterDispatchProvider(com.sun.star.frame.XDispatchProvider xMaster)
+ {
+ synchronized(this)
+ {
+ m_xMaster = xMaster;
+ }
+ }
+
+
+
+ /*
+ * Implementation of interface XDispatchProvider
+ * These functions are called from our master if he will not handle the outstanding request.
+ * Given parameter should be checked if they are right for us. If it's true, the returned
+ * dispatcher should be this implementation himself; otherwise call should be forwarded
+ * to the slave.
+ *
+ * @param aURL
+ * describes the request, which should be handled
+ *
+ * @param sTarget
+ * specifies the target frame for this request
+ *
+ * @param nSearchFlags
+ * optional search flags, if sTarget isn't a special one
+ *
+ * @return [XDispatch]
+ * a dispatch object, which can handle the given URL
+ * May be NULL!
+ */
+ public com.sun.star.frame.XDispatch queryDispatch(/*IN*/ com.sun.star.util.URL aURL,/*IN*/ String sTarget,/*IN*/ int nSearchFlags)
+ {
+ synchronized(this)
+ {
+ if (m_bDead)
+ return null;
+ }
+
+ // intercept loading empty documents into new created frames
+ if(
+ (sTarget.compareTo ("_blank" ) == 0 ) &&
+ (aURL.Complete.startsWith("private:factory"))
+ )
+ {
+ System.out.println("intercept private:factory");
+ return this;
+ }
+
+ // intercept opening the SaveAs dialog
+ if (aURL.Complete.startsWith(".uno:SaveAs"))
+ {
+ System.out.println("intercept SaveAs by returning null!");
+ return null;
+ }
+
+ // intercept "File->Exit" inside the menu
+ if (
+ (aURL.Complete.startsWith("slot:5300")) ||
+ (aURL.Complete.startsWith(".uno:Quit"))
+ )
+ {
+ System.out.println("intercept File->Exit");
+ return this;
+ }
+
+ synchronized(this)
+ {
+ if (m_xSlave!=null)
+ return m_xSlave.queryDispatch(aURL, sTarget, nSearchFlags);
+ }
+
+ return null;
+ }
+
+
+
+ public com.sun.star.frame.XDispatch[] queryDispatches(/*IN*/ com.sun.star.frame.DispatchDescriptor[] lDescriptor)
+ {
+ synchronized(this)
+ {
+ if (m_bDead)
+ return null;
+ }
+ // Resolve any request separately by using own "dispatch()" method.
+ // Note: Don't pack return list if "null" objects occur!
+ int nCount = lDescriptor.length;
+ com.sun.star.frame.XDispatch[] lDispatcher = new com.sun.star.frame.XDispatch[nCount];
+ for(int i=0; i<nCount; ++i)
+ {
+ lDispatcher[i] = queryDispatch(lDescriptor[i].FeatureURL ,
+ lDescriptor[i].FrameName ,
+ lDescriptor[i].SearchFlags);
+ }
+ return lDispatcher;
+ }
+
+
+
+ /*
+ * This method is called if this interceptor "wins the request".
+ * We intercepted creation of new frames and loading of empty documents.
+ * Do it now.
+ *
+ * @param aURL
+ * describes the document
+ *
+ * @param lArguments
+ * optional arguments for loading
+ */
+ private void impl_dispatch(/*IN*/ com.sun.star.util.URL aURL,/*IN*/ com.sun.star.beans.PropertyValue[] lArguments)
+ {
+ synchronized(this)
+ {
+ if (m_bDead)
+ return;
+ }
+
+ if (
+ (aURL.Complete.startsWith("slot:5300")) ||
+ (aURL.Complete.startsWith(".uno:Quit"))
+ )
+ {
+ System.exit(0);
+ }
+ else
+ if (aURL.Complete.startsWith("private:factory"))
+ {
+ // Create view frame for showing loaded documents on demand.
+ // The visible state is necessary for JNI functionality to get the HWND and plug office
+ // inside a java window hierarchy!
+ DocumentView aNewView = new DocumentView();
+ aNewView.setVisible(true);
+ aNewView.createFrame();
+ aNewView.load(aURL.Complete,lArguments);
+ }
+ }
+
+
+
+ /*
+ * Notification of status listener isn't guaranteed (instead of listener on XNotifyingDispatch interface).
+ * So this interceptor doesn't support that really...
+ */
+ public /*ONEWAY*/ void addStatusListener(/*IN*/ com.sun.star.frame.XStatusListener xListener,/*IN*/ com.sun.star.util.URL aURL)
+ {
+/* if (aURL.Complete.startsWith(".uno:SaveAs")==true)
+ {
+ com.sun.star.frame.FeatureStateEvent aEvent = new com.sun.star.frame.FeatureStateEvent(
+ this,
+ aURL,
+ "",
+ false,
+ false,
+ null);
+ if (xListener!=null)
+ {
+ System.out.println("interceptor disable SaveAs by listener notify");
+ xListener.statusChanged(aEvent);
+ }
+ }*/
+ }
+
+
+
+ public /*ONEWAY*/ void removeStatusListener(/*IN*/ com.sun.star.frame.XStatusListener xListener,/*IN*/ com.sun.star.util.URL aURL)
+ {
+ }
+
+
+
+ /*
+ * Implements (optional!) optimization for interceptor mechanism.
+ * Any interceptor which provides this special interface is called automatically
+ * at registration time on this method. Returned URL's will be used to
+ * call this interceptor directly without calling his masters before, IF(!)
+ * following rules will be true:
+ * (1) every master supports this optional interface too
+ * (2) nobody of these masters wish to intercept same URL then this one
+ * This interceptor wish to intercept creation of new documents.
+ */
+ public String[] getInterceptedURLs()
+ {
+ return INTERCEPTED_URLS;
+ }
+
+
+
+ /*
+ * This class listen on the intercepted frame to free all used resources on closing.
+ * We forget the reference to the frame only here. Deregistration
+ * isn't necessary here - because this frame dies and wish to be forgotten.
+ *
+ * @param aSource
+ * must be our internal saved frame, on which we listen for frame action events
+ */
+ public /*ONEAY*/ void disposing(/*IN*/ com.sun.star.lang.EventObject aSource)
+ {
+ synchronized(this)
+ {
+ if (m_bDead)
+ return;
+ if (m_xFrame!=null && UnoRuntime.areSame(aSource.Source,m_xFrame))
+ {
+ m_bIsActionListener = false;
+ m_xFrame = null ;
+ }
+ }
+ shutdown();
+ }
+
+
+
+ /*
+ * If this java application shutdown - we must cancel all current existing
+ * listener connections. Otherwise the office will run into some
+ * DisposedExceptions if it tries to use these forgotten listener references.
+ * And of course it can die doing that.
+ * We are registered at a central object to be informed if the VM will exit.
+ * So we can react.
+ */
+ public void shutdown()
+ {
+ com.sun.star.frame.XFrame xFrame = null ;
+ boolean bIsRegistered = false;
+ boolean bIsActionListener = false;
+ synchronized(this)
+ {
+ // don't react a second time here!
+ if (m_bDead)
+ return;
+ m_bDead = true;
+
+ bIsRegistered = m_bIsRegistered;
+ m_bIsRegistered = false;
+
+ bIsActionListener = m_bIsActionListener;
+ m_bIsActionListener = false;
+
+ xFrame = m_xFrame;
+ m_xFrame = null;
+ }
+
+ // it's a good idea to cancel listening for frame action events
+ // before(!) we deregister us as an interceptor.
+ // Because registration and deregistration of interceptor objects
+ // will force sending of frame action events...!
+ if (bIsActionListener)
+ xFrame.removeFrameActionListener(this);
+
+ if (bIsRegistered)
+ {
+ com.sun.star.frame.XDispatchProviderInterception xRegistration = UnoRuntime.queryInterface(
+ com.sun.star.frame.XDispatchProviderInterception.class,
+ xFrame);
+
+ if(xRegistration!=null)
+ xRegistration.releaseDispatchProviderInterceptor(this);
+ }
+
+ xFrame = null;
+
+ synchronized(this)
+ {
+ m_xMaster = null;
+ m_xSlave = null;
+ }
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/JavaWindowPeerFake.java b/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/JavaWindowPeerFake.java
new file mode 100644
index 000000000..25281ac5f
--- /dev/null
+++ b/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/JavaWindowPeerFake.java
@@ -0,0 +1,109 @@
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+
+
+
+/** <p>Class to pass the system window handle to the OpenOffice.org toolkit.</p>
+ */
+class JavaWindowPeerFake implements com.sun.star.awt.XSystemDependentWindowPeer,
+ com.sun.star.awt.XWindowPeer
+{
+ private final NativeView maView;
+
+ public JavaWindowPeerFake(NativeView aNative)
+ {
+ maView = aNative;
+ }
+
+
+ /**
+ * Implementation of XSystemDependentWindowPeer (that's all we really need).
+ * This method is called back from the Office toolkit to retrieve the system data.
+ */
+ public java.lang.Object getWindowHandle(byte[] aProcessId, short aSystem)
+ throws com.sun.star.uno.RuntimeException
+ {
+ Object aReturn = null;
+ if(aSystem==maView.maSystem)
+ aReturn = maView.maHandle;
+ return aReturn;
+ }
+
+ /** not really needed.
+ */
+ public com.sun.star.awt.XToolkit getToolkit()
+ throws com.sun.star.uno.RuntimeException
+ {
+ return null;
+ }
+
+ public void setPointer(com.sun.star.awt.XPointer xPointer)
+ throws com.sun.star.uno.RuntimeException
+ {
+ }
+
+ public void setBackground(int nColor)
+ throws com.sun.star.uno.RuntimeException
+ {
+ }
+
+ public void invalidate(short nFlags)
+ throws com.sun.star.uno.RuntimeException
+ {
+ }
+
+ public void invalidateRect(com.sun.star.awt.Rectangle aRect,short nFlags)
+ throws com.sun.star.uno.RuntimeException
+ {
+ }
+
+ public void dispose()
+ throws com.sun.star.uno.RuntimeException
+ {
+ }
+
+ public void addEventListener(com.sun.star.lang.XEventListener xListener)
+ throws com.sun.star.uno.RuntimeException
+ {
+ }
+
+ public void removeEventListener(com.sun.star.lang.XEventListener xListener)
+ throws com.sun.star.uno.RuntimeException
+ {
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/Makefile b/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/Makefile
new file mode 100644
index 000000000..5b0462b25
--- /dev/null
+++ b/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/Makefile
@@ -0,0 +1,131 @@
+#*************************************************************************
+#
+# The Contents of this file are made available subject to the terms of
+# the BSD license.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+# 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+# contributors may be used to endorse or promote products derived
+# from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+# TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+# USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+#**************************************************************************
+
+# Builds the OfficeDevDesktopEnvironment example of the Developers Guide.
+
+PRJ=../../../..
+SETTINGS=$(PRJ)/settings
+
+include $(SETTINGS)/settings.mk
+include $(SETTINGS)/std.mk
+
+# Define non-platform/compiler specific settings
+EXAMPLE_NAME=OfficeDevDesktopEnv
+OUT_APP_CLASS = $(OUT_CLASS)/$(EXAMPLE_NAME)
+
+APP1_NAME=DesktopExample
+APP1_JAR=$(OUT_APP_CLASS)/$(APP1_NAME).jar
+
+APP1_JAVAFILES = \
+ CustomizeView.java \
+ Desk.java \
+ DocumentView.java \
+ FunctionHelper.java \
+ Interceptor.java \
+ IOnewayLink.java \
+ IShutdownListener.java \
+ JavaWindowPeerFake.java \
+ NativeView.java \
+ OfficeConnect.java \
+ OnewayExecutor.java \
+ StatusListener.java \
+ StatusView.java \
+ ViewContainer.java
+
+APP1_CLASSFILES = $(patsubst %.java,$(OUT_APP_CLASS)/%.class,$(APP1_JAVAFILES))
+APP1_CLASSNAMES = $(patsubst %.java,%.class,$(APP1_JAVAFILES)) \
+ CustomizeView$(QUOTE)$$ClickListener.class \
+ DocumentView$(QUOTE)$$*.class
+
+
+SDK_CLASSPATH = $(subst $(EMPTYSTRING) $(PATH_SEPARATOR),$(PATH_SEPARATOR),$(CLASSPATH)\
+ $(PATH_SEPARATOR)$(OUT_APP_CLASS))
+
+ifeq "$(OS)" "WIN"
+SUBDIR= nativelib/windows
+else
+SUBDIR= nativelib/unix
+endif
+
+# Targets
+.PHONY: ALL
+ifeq "$(OS)" "MACOSX"
+ALL :
+ @printf 'This example does not work on macOS\n'
+else
+ALL : $(SUBDIR) \
+ $(EXAMPLE_NAME)
+endif
+
+include $(SETTINGS)/stdtarget.mk
+
+.PHONY : $(SUBDIR)
+$(SUBDIR) :
+ $(MAKE) -C $@
+
+$(APP1_CLASSFILES) : $(APP1_JAVAFILES)
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ $(SDK_JAVAC) $(JAVAC_FLAGS) -classpath "$(SDK_CLASSPATH)" -d $(OUT_APP_CLASS) $(APP1_JAVAFILES)
+
+$(OUT_APP_CLASS)/$(APP1_NAME).mf :
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ @echo Main-Class: com.sun.star.lib.loader.Loader> $@
+ $(ECHOLINE)>> $@
+ @echo Name: com/sun/star/lib/loader/Loader.class>> $@
+ @echo Application-Class: Desk>> $@
+
+$(APP1_JAR) : $(OUT_APP_CLASS)/$(APP1_NAME).mf $(APP1_CLASSFILES)
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ +cd $(subst /,$(PS),$(OUT_APP_CLASS)) && $(SDK_JAR) cvfm $(@F) $(basename $(@F)).mf $(APP1_CLASSNAMES)
+ +$(SDK_JAR) uvf $@ $(SDK_JAVA_UNO_BOOTSTRAP_FILES)
+
+$(EXAMPLE_NAME) : $(APP1_JAR)
+ @echo --------------------------------------------------------------------------------
+ @echo Please use the following command to execute the example!
+ @echo -
+ @echo $(MAKE) DesktopExample.run
+ @echo ------
+ @echo If you want to run the $(JAR1_JAR) file please set your
+ @echo CLASSPATH = $(SDK_CLASSPATH)
+ @echo Start the example with jar -jar $(JAR1_JAR)
+ @echo --------------------------------------------------------------------------------
+
+%.run: $(OUT_APP_CLASS)/%.jar
+ $(SDK_JAVA) -Dcom.sun.star.lib.loader.unopath="$(OFFICE_PROGRAM_PATH)" -jar $<
+
+.PHONY: clean
+clean :
+ $(MAKE) -C $(SUBDIR) clean
+ -$(DELRECURSIVE) $(subst /,$(PS),$(OUT_APP_CLASS))
diff --git a/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/NativeView.java b/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/NativeView.java
new file mode 100644
index 000000000..273290e55
--- /dev/null
+++ b/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/NativeView.java
@@ -0,0 +1,186 @@
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+// __________ Imports __________
+
+import java.awt.*;
+
+// __________ Implementation __________
+
+/**
+ * Class to pass the system window handle to the OpenOffice.org toolkit.
+ * It use special JNI methods to get the system handle of used java window.
+ *
+ * Attention!
+ * Use JNI functions on already visible canvas objects only!
+ * Otherwise they can make some trouble.
+ *
+ */
+
+public class NativeView extends java.awt.Canvas
+{
+
+
+ /**
+ * ctor
+ * Does nothing really.
+ * We can use our JNI mechanism for an already visible
+ * canvas only. So we override the method for showing ("setVisible()")
+ * and make our initialization there. But we try to show an empty clean
+ * window till there.
+ */
+ public NativeView()
+ {
+ maHandle = null;
+ maSystem = 0;
+ this.setBackground(Color.white);
+ }
+
+
+
+ /**
+ * Override this method to make necessary initializations here.
+ * (e.g. get the window handle and necessary system information)
+ *
+ * Why here?
+ * Because the handle seems to be available for already visible windows
+ * only. So it's the best place to get it. Special helper method
+ * can be called more than ones - but call native code one times only
+ * and safe the handle and the system type on our members maHandle/maSystem!
+ */
+ @Override
+ public void setVisible(boolean bState)
+ {
+ getHWND();
+ }
+
+
+
+ /**
+ * to guarantee right resize handling inside a swing container
+ * (e.g. JSplitPane) we must provide some information about our
+ * preferred/minimum and maximum size.
+ */
+ @Override
+ public Dimension getPreferredSize()
+ {
+ return new Dimension(500,300);
+ }
+
+ @Override
+ public Dimension getMaximumSize()
+ {
+ return new Dimension(1024,768);
+ }
+
+ @Override
+ public Dimension getMinimumSize()
+ {
+ return new Dimension(100,100);
+ }
+
+
+
+ /**
+ * Override paint routine to show provide against
+ * repaint errors if no office view is really plugged
+ * into this canvas.
+ * If handle is present - we shouldn't paint anything further.
+ * May the remote window is already plugged. In such case we
+ * shouldn't paint it over.
+ */
+ @Override
+ public void paint(Graphics aGraphic)
+ {
+ if(maHandle==null)
+ {
+ Dimension aSize = getSize();
+ aGraphic.clearRect(0,0,aSize.width,aSize.height);
+ }
+ }
+
+
+
+ /**
+ * JNI interface of this class
+ * These two methods are implemented by using JNI mechanismen.
+ * The will be used to get the platform dependent window handle
+ * of a java awt canvas. This handle can be used to create an office
+ * window as direct child of it. So it's possible to plug Office
+ * windows in a java UI container.
+ *
+ * Note:
+ * Native code for Windows registers a special function pointer to handle
+ * window messages... But if it doesn't check for an already-registered
+ * instance of this handler it will do it twice and produce a stack overflow
+ * because such method calls itself in a never-ending loop...
+ * So we try to use the JNI code one time only and save already-obtained
+ * information inside this class.
+ */
+ public native int getNativeWindowSystemType();
+ private native long getNativeWindow(); // private! => use getHWND() with cache mechanism!
+
+ public Integer getHWND()
+ {
+ if(maHandle==null)
+ {
+ maHandle = Integer.valueOf((int)getNativeWindow());
+ maSystem = getNativeWindowSystemType();
+ }
+ return maHandle;
+ }
+
+
+
+ /**
+ * for using of the JNI methods it's necessary to load
+ * system library which exports it.
+ */
+ static
+ {
+ System.loadLibrary("nativeview");
+ }
+
+
+
+ /**
+ * @member maHandle system window handle
+ * @member maSystem info about currently used platform
+ */
+ public Integer maHandle ;
+ public int maSystem ;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/OfficeConnect.java b/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/OfficeConnect.java
new file mode 100644
index 000000000..617e38047
--- /dev/null
+++ b/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/OfficeConnect.java
@@ -0,0 +1,127 @@
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+
+
+
+// __________ Implementation __________
+
+/**
+ * support ONE singleton uno connection to a running office installation!
+ * Can be used to open/use/close connection to uno environment of an office. If
+ * necessary a new office instance is started.
+ * ctor isn't available from outside. You should call static function
+ * "getConnection()" to open or use internal set connection which is created one
+ * times only.
+ *
+ */
+public class OfficeConnect
+{
+
+
+ /**
+ * At first call we create static connection object and open connection to an
+ * office - a new office instance is started if necessary
+ * Then - and for all further requests we return these static connection member.
+ */
+ public static synchronized void createConnection()
+ {
+ if (maConnection == null)
+ maConnection = new OfficeConnect();
+ }
+
+
+
+
+
+
+
+ /**
+ * ctor
+ * We try to open the connection in our ctor ... transparently for user.
+ * After it was successful you will find an internal set member
+ * m_xRemoteContext which means remote component context of the connected office.
+ * The context can be used to get the remote service manager from the office.
+ * We made it private to support singleton pattern of these implementation.
+ * see getConnection() for further information
+ */
+ private OfficeConnect()
+ {
+ try
+ {
+ // get the remote office context. If necessary a new office
+ // process is started
+ mxOfficeContext = com.sun.star.comp.helper.Bootstrap.bootstrap();
+ System.out.println("Connected to a running office ...");
+ mxServiceManager = mxOfficeContext.getServiceManager();
+ }
+ catch (java.lang.Exception ex)
+ {
+ System.err.println("connection failed" + ex);
+ ex.printStackTrace(System.err);
+ System.exit(1);
+
+ }
+ }
+
+
+
+
+
+
+
+ /**
+ * returns remote component context of the connected office
+ */
+ public static synchronized com.sun.star.uno.XComponentContext getOfficeContext()
+ {
+ return mxOfficeContext;
+ }
+
+
+
+ /**
+ * member
+ */
+ // singleton connection instance
+ private static OfficeConnect maConnection;
+
+ // reference to the office component context
+ private static com.sun.star.uno.XComponentContext mxOfficeContext;
+ // reference to remote service manager of singleton connection object
+ private static com.sun.star.lang.XMultiComponentFactory mxServiceManager;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/OnewayExecutor.java b/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/OnewayExecutor.java
new file mode 100644
index 000000000..4eb7f80a7
--- /dev/null
+++ b/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/OnewayExecutor.java
@@ -0,0 +1,189 @@
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+import java.util.ArrayList;
+
+// __________ Implementation __________
+
+/**
+ * It's not allowed to call synchronous back inside a oneway interface call.
+ * (see IOnewayLink too). So we start a thread (implemented by this class), which
+ * gets all necessary parameters from the original called object and
+ * call it back later inside his run() method. So the execution of such oneway call
+ * will be asynchronous. It works in a generic way and can be used or any type
+ * of oneway request. Because the source and the target of this call-link knows,
+ * which method was used and which parameters must be handled.
+ *
+ */
+class OnewayExecutor extends Thread
+{
+
+
+ /**
+ * const
+ * We define some request for some well known oneway interface
+ * calls here too. So they mustn't be declared more than ones.
+ * Of course it's not necessary to use it ... but why not :-)
+ */
+
+ public static final int REQUEST_FRAMEACTION = 1 ;
+
+
+
+ public static final int REQUEST_DISPATCH = 5 ;
+
+
+
+
+
+
+ /**
+ * @member m_rLink the object, which wishes to be called back by this thread
+ * @member m_nRequest describes the type of the original request (means the
+ * called oneway method)
+ * @member m_lParams list of parameters of the original request
+ */
+ private final IOnewayLink m_rLink ;
+ private final int m_nRequest ;
+ private final ArrayList<Object> m_lParams ;
+
+
+
+ /**
+ * ctor
+ * It's initialize this thread with all necessary parameters.
+ * It gets the object, which wishes to be called back and the type
+ * and parameters of the original request.
+ *
+ * @param nRequest
+ * The two user of this callback can define a unique number,
+ * which identify the type of original interface method.
+ * So the called interface object can decide, which action will be
+ * necessary.
+ *
+ * @param lParams
+ * If the original method used parameters, they will be coded here in
+ * a generic way. Only the called interface object know (it depends
+ * from the original request - see nRequest too), how this list must
+ * be interpreted.
+ * Note: Atomic types (e.g. int, long) will be transported as objects
+ * too (Integer, Long)!
+ */
+ public OnewayExecutor( IOnewayLink rLink ,
+ int nRequest ,
+ ArrayList<Object> lParams )
+ {
+ m_rLink = rLink ;
+ m_nRequest = nRequest;
+ m_lParams = lParams ;
+
+ if (m_rLink==null)
+ System.out.println("ctor ... m_rLink == null");
+ if (m_lParams==null)
+ System.out.println("ctor ... m_lParams == null");
+ }
+
+
+
+ /**
+ * implements the thread function
+ * Here we call the internal set link object back and
+ * give him all necessary parameters.
+ * After that we die by ourselves ...
+ */
+ @Override
+ public void run()
+ {
+ if (m_rLink==null)
+ System.out.println("run ... m_rLink == null");
+ if (m_lParams==null)
+ System.out.println("run ... m_lParams == null");
+
+ if (m_rLink!=null)
+ m_rLink.execOneway( m_nRequest, m_lParams );
+ }
+
+
+
+ /**
+ * static helper!
+ * To make conversion of the generic parameter list to the original
+ * one easier - you can use this helper methods. They know how such list
+ * must be coded. It's not a must to use it - but you can ...
+ */
+
+
+
+ public static ArrayList<Object> encodeDispatch(
+ com.sun.star.util.URL[] aURL,
+ com.sun.star.beans.PropertyValue[][] lArgs)
+ {
+ int nLength = lArgs.length+1;
+ int nPos = 0;
+ ArrayList<Object> lParams = new ArrayList<Object>(nLength);
+
+ lParams.add( aURL[0] );
+ --nLength;
+
+ while (nLength>0)
+ {
+ lParams.add( lArgs[0][nPos] );
+ --nLength;
+ ++nPos ;
+ }
+ return lParams;
+ }
+
+ public static void decodeDispatch(
+ ArrayList<Object> lParams,
+ com.sun.star.util.URL[] aURL,
+ com.sun.star.beans.PropertyValue[][] lArgs)
+ {
+ int nLength = lParams.size()-1;
+ int nPos = 0;
+
+ lArgs[0] = new com.sun.star.beans.PropertyValue[nLength];
+ aURL[0] = (com.sun.star.util.URL) lParams.get(0);
+
+ while (nPos<nLength)
+ {
+ lArgs[0][nPos] = (com.sun.star.beans.PropertyValue)
+ (lParams.get(nPos+1));
+ ++nPos;
+ }
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/StatusListener.java b/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/StatusListener.java
new file mode 100644
index 000000000..f037949b0
--- /dev/null
+++ b/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/StatusListener.java
@@ -0,0 +1,469 @@
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+// __________ Imports __________
+
+import java.awt.Component;
+import java.util.ArrayList;
+
+import javax.swing.JCheckBox;
+import javax.swing.JLabel;
+
+import com.sun.star.frame.FrameActionEvent;
+import com.sun.star.uno.UnoRuntime;
+
+// __________ Implementation __________
+
+/**
+ * reacts for status events we listen for
+ * We listen for status events to update our UI.
+ * To know which event must be used for which UI control
+ * we use a special class to do that. Otherwise we have
+ * to guess it ...
+ *
+ * Further we are frame action listener too.
+ * So we can update our status listener connections and
+ * internal holded dispatch object automatically.
+ *
+ * Another reason for such extra class for listening:
+ * Most listener callbacks are asynchronous [oneay] requests.
+ * And it's not allowed to call back synchronously there.
+ * So we must start threads for updating something internally.
+ *
+ */
+class StatusListener implements com.sun.star.frame.XStatusListener,
+ com.sun.star.frame.XFrameActionListener,
+ IShutdownListener,
+ IOnewayLink
+{
+
+
+ /**
+ * @member m_rControl reference to the UI control, which should be updated
+ * @member m_sTrueText this text will be shown at the used UI control as description for an enabled status
+ * @member m_sFalseText this text will be shown at the used UI control as description for an disabled status
+ * @member m_xDispatch if we listen for status events, we must hold the dispatch object alive!
+ * @member m_xFrame reference to the frame, which can provide new dispatch objects if it's necessary to update it
+ * @member m_aURL and of course we must be registered for a special URL
+ * @member m_bIsActionListener indicates if we are currently registered as a listener for frame action events or not
+ * @member m_bIsStatusListener indicates if we are currently registered as a listener for status events or not
+ * @member m_bDead there exist more than one way to finish an object of this class - we must know it sometimes
+ */
+ private final Component m_rControl ;
+ private final String m_sTrueText ;
+ private final String m_sFalseText ;
+ private com.sun.star.frame.XDispatch m_xDispatch ;
+ private com.sun.star.frame.XFrame m_xFrame ;
+ private com.sun.star.util.URL m_aURL ;
+ private boolean m_bIsActionListener;
+ private boolean m_bIsStatusListener;
+ private boolean m_bDead ;
+
+
+
+ /**
+ * ctor
+ * It initialize an instance of this class only.
+ * We set all necessary information on our internal member - that's it
+ */
+ StatusListener( /*IN*/ Component rControl ,
+ /*IN*/ String sTrueText ,
+ /*IN*/ String sFalseText ,
+ /*IN*/ com.sun.star.frame.XFrame xFrame ,
+ /*IN*/ String sURL )
+ {
+ m_rControl = rControl ;
+ m_sTrueText = sTrueText ;
+ m_sFalseText = sFalseText ;
+ m_xFrame = xFrame ;
+ m_bIsStatusListener = false ;
+ m_bIsActionListener = false ;
+ m_bDead = false ;
+ // to be perform - we parse the given URL one times only
+ // and use it till we die ...
+ m_aURL = FunctionHelper.parseURL(sURL);
+ }
+
+
+
+ /**
+ * start working as frame action listener really.
+ * In case we get such frame action, it indicates that we should
+ * update our internal saved dispatch object on which we listen
+ * for status events. So we can do it automatically. The outside code
+ * mustn't check such things. We can work with one frame,
+ * till it die. It doesn't matter if he will be used for different
+ * load/save or any other requests. We will be up to date every time.
+ */
+ public void startListening()
+ {
+ com.sun.star.frame.XFrame xFrame = null;
+ synchronized(this)
+ {
+ if (m_bDead)
+ return;
+ if (m_xFrame==null)
+ return;
+ if (m_bIsActionListener)
+ return;
+ xFrame = m_xFrame;
+ }
+ xFrame.addFrameActionListener(this);
+ synchronized(this)
+ {
+ m_bIsActionListener=true;
+ }
+ }
+
+
+
+ /**
+ * In case we got a oneway listener callback - we had to use the office
+ * asynchronous then. This method is the callback from the started thread
+ * (started inside the original oneway method). We found all parameters of
+ * the original request packed inside a vector. Here we unpack it and
+ * call the right internal helper method, which implements the right
+ * functionality.
+ *
+ * @seealso frameAction()
+ * @seealso statusChanged()
+ *
+ * @param nRequest
+ * indicates, which was the original request (identifies the
+ * original called method)
+ *
+ * @param lParams
+ * the vector with all packed parameters of the original request
+ */
+ public void execOneway(/*IN*/ int nRequest,/*IN*/ ArrayList<Object> lParams )
+ {
+ synchronized(this)
+ {
+ if (m_bDead)
+ return;
+ }
+ // was it frameAction()?
+ if (nRequest==OnewayExecutor.REQUEST_FRAMEACTION)
+ {
+ impl_frameAction((FrameActionEvent) lParams.get(0));
+ }
+ }
+
+
+
+ /**
+ * This is the callback method for such frame action events, we listen for.
+ * Because it's a oneway method we start a thread as reaction. This thread call
+ * us back and we can do necessary things there.
+ * But we shouldn't start such action - if it's not really necessary.
+ * So we check before, if we are interested on this event really.
+ *
+ * @see #impl_frameAction
+ *
+ * @param aEvent
+ * describes the action, which triggered this event
+ */
+ public /*ONEWAY*/ void frameAction(/*IN*/ com.sun.star.frame.FrameActionEvent aEvent)
+ {
+ synchronized(this)
+ {
+ if (m_bDead)
+ return;
+ }
+ boolean bHandle = false;
+ switch(aEvent.Action.getValue())
+ {
+ case com.sun.star.frame.FrameAction.COMPONENT_ATTACHED_value : bHandle=true; break;
+ case com.sun.star.frame.FrameAction.COMPONENT_DETACHING_value : bHandle=true; break;
+ case com.sun.star.frame.FrameAction.COMPONENT_REATTACHED_value : bHandle=true; break;
+ case com.sun.star.frame.FrameAction.CONTEXT_CHANGED_value : bHandle=true; break;
+ }
+
+ if (! bHandle)
+ return;
+
+ ArrayList<Object> lOutParams = new ArrayList<Object>();
+ lOutParams.add(aEvent);
+
+ OnewayExecutor aExecutor = new OnewayExecutor( this ,
+ OnewayExecutor.REQUEST_FRAMEACTION ,
+ lOutParams );
+ aExecutor.start();
+ }
+
+
+
+ /**
+ * This is the callback method for the status we listen for and wish to show it
+ * on our UI control. Of course it's a oneway method... but we don't call back
+ * to the office synchronously here. We update our UI only. So we don't leave this
+ * java process. In such case it's not necessary to use threads to decouple it.
+ * Do it here and now...
+ *
+ * @param aEvent
+ * describes the status, we can use to update our UI control
+ */
+ public /*ONEWAY*/ void statusChanged(/*IN*/ com.sun.star.frame.FeatureStateEvent aEvent)
+ {
+ synchronized(this)
+ {
+ if (m_bDead)
+ return;
+
+ // enable/disable the control.
+ // Means: if the feature isn't available currently - we can't show a status really here.
+ // Then we should colorize it gray...
+ m_rControl.setEnabled(aEvent.IsEnabled);
+
+ // Only if status is enabled we can look for his value!
+ if (aEvent.IsEnabled)
+ {
+ // look for the right type of the UI control
+ // Following actions depend on it.
+
+
+ // it's a check box
+ if (m_rControl instanceof JCheckBox)
+ {
+ JCheckBox aBox = (JCheckBox)m_rControl;
+
+ // State must be a boolean value too. Otherwise must
+ // ignore this event.
+ if ( ! (aEvent.State instanceof Boolean ) )
+ return;
+
+ boolean bState = ((Boolean)(aEvent.State)).booleanValue();
+ aBox.setSelected(bState);
+ if (bState)
+ aBox.setText(m_sTrueText);
+ else
+ aBox.setText(m_sFalseText);
+ }
+ else
+
+ // it's a label
+ if (m_rControl instanceof JLabel)
+ {
+ JLabel aLabel = (JLabel)m_rControl;
+
+ // Detect type of state value
+ // and set it on internal well known UI control
+ // But do it only, if value really change.
+ if(aEvent.State instanceof String)
+ {
+ String sState = (String)aEvent.State;
+ aLabel.setText(sState);
+ }
+ else
+ if(aEvent.State instanceof Boolean)
+ {
+ boolean bState = ((Boolean)aEvent.State).booleanValue();
+ if (bState)
+ aLabel.setText(m_sTrueText);
+ else
+ aLabel.setText(m_sFalseText);
+ }
+ else
+ if(aEvent.State instanceof Float)
+ {
+ String sState = ((Float)aEvent.State).toString();
+ aLabel.setText(sState);
+ }
+ }
+ }
+ }
+ }
+
+
+
+ /**
+ * Internal call back for frame action events, triggered by the used
+ * OnewayExecutor thread we started in frameAction().
+ * We use it to update internal saved dispatch object and the corresponding
+ * listener connection for status events.
+ *
+ * @param aEvent
+ * describes the action
+ */
+ private void impl_frameAction(/*IN*/ com.sun.star.frame.FrameActionEvent aEvent)
+ {
+ synchronized(this)
+ {
+ if (m_bDead)
+ return;
+ }
+ // Don't look for ignoring actions - it was done already inside original frameAction() call!
+ // deregistration as status listener will be done here every time - but registration only, if necessary!
+ boolean bRegister = false;
+ switch(aEvent.Action.getValue())
+ {
+ case com.sun.star.frame.FrameAction.COMPONENT_ATTACHED_value : bRegister=true ; break;
+ case com.sun.star.frame.FrameAction.COMPONENT_DETACHING_value : bRegister=false; break;
+ case com.sun.star.frame.FrameAction.COMPONENT_REATTACHED_value : bRegister=true ; break;
+ case com.sun.star.frame.FrameAction.CONTEXT_CHANGED_value : bRegister=true ; break;
+ }
+
+ boolean bIsStatusListener = false;
+ com.sun.star.frame.XFrame xFrame = null ;
+ com.sun.star.frame.XDispatch xDispatch = null ;
+ com.sun.star.util.URL aURL = null ;
+ synchronized(this)
+ {
+ bIsStatusListener = m_bIsStatusListener;
+ m_bIsStatusListener = false;
+
+ xDispatch = m_xDispatch;
+ m_xDispatch = null;
+
+ aURL = m_aURL;
+ xFrame = m_xFrame;
+ }
+
+ if (bIsStatusListener)
+ xDispatch.removeStatusListener(this,aURL);
+ xDispatch = null;
+
+ if (! bRegister)
+ return;
+
+ com.sun.star.frame.XDispatchProvider xProvider = UnoRuntime.queryInterface(
+ com.sun.star.frame.XDispatchProvider.class,
+ xFrame);
+
+ if (xProvider==null)
+ return;
+
+ xDispatch = xProvider.queryDispatch(aURL,"",0);
+
+ if (xDispatch==null)
+ return;
+
+ xDispatch.addStatusListener(this,aURL);
+ synchronized(this)
+ {
+ m_xDispatch = xDispatch;
+ m_bIsStatusListener = true;
+ }
+ }
+
+
+
+ /**
+ * callback for disposing events
+ * Our dispatch or frame object inform us about his following dead ...
+ * So we must forget his reference. But it's not necessary to
+ * remove listener connections here. Because the broadcaster
+ * forget us automatically. The only thing we have to do: release
+ * his reference and let him die!
+ *
+ * @param aEvent
+ * describes the source which fire this event
+ * Must be our internal saved dispatch or frame. Otherwise
+ * somewhere know us without a registration ...
+ */
+ public /*ONEWAY*/ void disposing(/*IN*/ com.sun.star.lang.EventObject aEvent)
+ {
+ synchronized(this)
+ {
+ if (m_bDead)
+ return;
+ if (m_xFrame!=null && UnoRuntime.areSame(aEvent.Source,m_xFrame))
+ {
+ m_bIsActionListener = false;
+ m_xFrame = null ;
+ }
+ else
+ if (m_xDispatch!=null && UnoRuntime.areSame(aEvent.Source,m_xDispatch))
+ {
+ m_bIsStatusListener = false;
+ m_xDispatch = null ;
+ m_aURL = null ;
+ }
+ }
+ shutdown();
+ }
+
+
+
+ /**
+ * If this java application shutdown - we must cancel all current existing
+ * listener connections. Otherwise the office will run into some
+ * DisposedExceptions if it tries to use these forgotten listener references.
+ * And of course it can die doing that.
+ * We are registered at a central object to be informed if the VM will exit.
+ * So we can react.
+ */
+ public void shutdown()
+ {
+ boolean bIsActionListener = false;
+ boolean bIsStatusListener = false;
+ com.sun.star.frame.XFrame xFrame = null ;
+ com.sun.star.frame.XDispatch xDispatch = null ;
+ com.sun.star.util.URL aURL = null ;
+ synchronized(this)
+ {
+ // don't react a second time here!
+ if (m_bDead)
+ return;
+ m_bDead = true;
+
+ bIsActionListener = m_bIsActionListener;
+ m_bIsActionListener = false;
+
+ bIsStatusListener = m_bIsStatusListener;
+ m_bIsStatusListener = false;
+
+ xFrame = m_xFrame;
+ m_xFrame = null;
+
+ xDispatch = m_xDispatch;
+ m_xDispatch = null;
+
+ aURL = m_aURL;
+ m_aURL = null;
+ }
+
+ if (bIsStatusListener)
+ xDispatch.removeStatusListener(this,aURL);
+ xDispatch = null ;
+ aURL = null ;
+
+ if (bIsActionListener)
+ xFrame.removeFrameActionListener(this);
+ xFrame = null ;
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/StatusView.java b/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/StatusView.java
new file mode 100644
index 000000000..92ae178ad
--- /dev/null
+++ b/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/StatusView.java
@@ -0,0 +1,264 @@
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+// __________ Imports __________
+
+import java.awt.*;
+import javax.swing.*;
+
+// __________ Implementation __________
+
+/**
+ * Implement a view to show status information
+ * of currently loaded document of a document view.
+ * It uses separate listener threads to get this information
+ * and actualize it automatically, if frame broadcast changes of
+ * his contained document.
+ * Threads are necessary to prevent this view against deadlocks.
+ * These deadlocks can occur if a listener will be notified
+ * by the office in an "oneway" method and try to call back
+ * to the office by using a synchronous method.
+ * UNO must guarantee order of all these calls ... and if
+ * the source of arrived event holds a mutex and our synchronous
+ * call needs this mutex too => a deadlock occurs.
+ * Why? UNO had created a new thread for our synchronous call
+ * inside the office process and so exist different threads
+ * for this constellation.
+ *
+ */
+public class StatusView extends JPanel
+ implements IShutdownListener
+{
+
+
+ /**
+ * const
+ * These URL's describe available feature states.
+ */
+ private static final String FEATUREURL_FONT = "slot:10007";
+ private static final String FEATUREURL_SIZE = "slot:10015";
+ private static final String FEATUREURL_BOLD = "slot:10009";
+ private static final String FEATUREURL_ITALIC = "slot:10008";
+ private static final String FEATUREURL_UNDERLINE = "slot:10014";
+
+
+
+ /**
+ * const
+ * These values are used to show current state of showed feature.
+ */
+ private static final String FONT_OFF = "unknown" ;
+ private static final String SIZE_OFF = "0.0" ;
+ private static final String BOLD_OFF = "-" ;
+ private static final String ITALIC_OFF = "-" ;
+ private static final String UNDERLINE_OFF = "-" ;
+
+ private static final String FONT_ON = "" ;
+ private static final String SIZE_ON = "" ;
+ private static final String BOLD_ON = "X" ;
+ private static final String ITALIC_ON = "X" ;
+ private static final String UNDERLINE_ON = "X" ;
+
+
+
+ /**
+ * @member mlaFontValue shows status of font name
+ * @member mlaSizeValue shows status of font size
+ * @member mlaBoldValue shows status of font style bold
+ * @member mlaUnderlineValue shows status of font style underline
+ * @member mlaItalicValue shows status of font style italic
+ *
+ * @member maFontListener threadsafe(!) helper to listen for status event which describe font name
+ * @member maSizeListener threadsafe(!) helper to listen for status event which describe font size
+ * @member maBoldListener threadsafe(!) helper to listen for status event which describe font style bold
+ * @member maUnderlineListener threadsafe(!) helper to listen for status event which describe font style underline
+ * @member maItalicListener threadsafe(!) helper to listen for status event which describe font style italic
+ */
+ private final JLabel m_laFontValue ;
+ private final JLabel m_laSizeValue ;
+ private final JLabel m_laBoldValue ;
+ private final JLabel m_laUnderlineValue ;
+ private final JLabel m_laItalicValue ;
+
+ private StatusListener m_aFontListener ;
+ private StatusListener m_aSizeListener ;
+ private StatusListener m_aBoldListener ;
+ private StatusListener m_aUnderlineListener ;
+ private StatusListener m_aItalicListener ;
+
+
+
+ /**
+ * ctor
+ * Create view controls on startup and initialize it with default values.
+ * Filling of view items can be done by special set-methods.
+ * We don't start listening here! see setFrame() for that ...
+ */
+ StatusView()
+ {
+ this.setLayout(new GridBagLayout());
+
+ GridBagConstraints aConstraint = new GridBagConstraints();
+ aConstraint.anchor = GridBagConstraints.NORTHWEST;
+ aConstraint.insets = new Insets(2,2,2,2);
+ aConstraint.gridy = 0;
+ aConstraint.gridx = 0;
+
+ JLabel laFont = new JLabel("Font" );
+ JLabel laSize = new JLabel("Size" );
+ JLabel laBold = new JLabel("Bold" );
+ JLabel laUnderline = new JLabel("Underline");
+ JLabel laItalic = new JLabel("Italic" );
+
+ m_laFontValue = new JLabel();
+ m_laSizeValue = new JLabel();
+ m_laBoldValue = new JLabel();
+ m_laUnderlineValue = new JLabel();
+ m_laItalicValue = new JLabel();
+
+ aConstraint.gridx = 0;
+ this.add( laFont, aConstraint );
+ aConstraint.gridx = 1;
+ this.add( m_laFontValue, aConstraint );
+
+ ++aConstraint.gridy;
+
+ aConstraint.gridx = 0;
+ this.add( laSize, aConstraint );
+ aConstraint.gridx = 1;
+ this.add( m_laSizeValue, aConstraint );
+
+ ++aConstraint.gridy;
+
+ aConstraint.gridx = 0;
+ this.add( laSize, aConstraint );
+ aConstraint.gridx = 1;
+ this.add( m_laSizeValue, aConstraint );
+
+ ++aConstraint.gridy;
+
+ aConstraint.gridx = 0;
+ this.add( laBold, aConstraint );
+ aConstraint.gridx = 1;
+ this.add( m_laBoldValue, aConstraint );
+
+ ++aConstraint.gridy;
+
+ aConstraint.gridx = 0;
+ this.add( laUnderline, aConstraint );
+ aConstraint.gridx = 1;
+ this.add( m_laUnderlineValue, aConstraint );
+
+ ++aConstraint.gridy;
+
+ aConstraint.gridx = 0;
+ this.add( laItalic, aConstraint );
+ aConstraint.gridx = 1;
+ this.add( m_laItalicValue, aConstraint );
+
+ m_laFontValue.setEnabled (false);
+ m_laSizeValue.setEnabled (false);
+ m_laBoldValue.setEnabled (false);
+ m_laItalicValue.setEnabled (false);
+ m_laUnderlineValue.setEnabled(false);
+
+ m_laFontValue.setText (FONT_OFF );
+ m_laSizeValue.setText (SIZE_OFF );
+ m_laBoldValue.setText (BOLD_OFF );
+ m_laItalicValue.setText (ITALIC_OFF );
+ m_laUnderlineValue.setText(UNDERLINE_OFF);
+ }
+
+
+
+ /*
+ * Set new frame for this view and start listening for events immediately.
+ * We create one status listener for every control we wish to update.
+ * And because the environment of the frame can be changed - these
+ * listener refresh himself internally for frame action events too.
+ * So we register it as such frame action listener only here.
+ * Rest is done automatically...
+ *
+ * @param xFrame
+ * will be used as source of possible status events
+ */
+ public void setFrame(com.sun.star.frame.XFrame xFrame)
+ {
+ if (xFrame==null)
+ return;
+
+ // create some listener on given frame for available status events
+ // Created listener instances will register themselves on this frame and
+ // show it received information automatically on set UI controls.
+ m_aFontListener = new StatusListener(m_laFontValue ,FONT_ON ,FONT_OFF ,xFrame, FEATUREURL_FONT );
+ m_aSizeListener = new StatusListener(m_laSizeValue ,SIZE_ON ,SIZE_OFF ,xFrame, FEATUREURL_SIZE );
+ m_aBoldListener = new StatusListener(m_laBoldValue ,BOLD_ON ,BOLD_OFF ,xFrame, FEATUREURL_BOLD );
+ m_aItalicListener = new StatusListener(m_laItalicValue ,ITALIC_ON ,ITALIC_OFF ,xFrame, FEATUREURL_ITALIC );
+ m_aUnderlineListener = new StatusListener(m_laUnderlineValue,UNDERLINE_ON,UNDERLINE_OFF,xFrame, FEATUREURL_UNDERLINE);
+
+ m_aFontListener.startListening();
+ m_aSizeListener.startListening();
+ m_aBoldListener.startListening();
+ m_aItalicListener.startListening();
+ m_aUnderlineListener.startListening();
+ }
+
+
+
+ /**
+ * If this java application shutdown - we must cancel all current existing
+ * listener connections. Otherwise the office will run into some
+ * DisposedExceptions if it tries to use these forgotten listener references.
+ * And of course it can die doing that.
+ * We are registered at a central object to be informed if the VM will exit.
+ * So we can react.
+ */
+ public void shutdown()
+ {
+ m_aFontListener.shutdown();
+ m_aSizeListener.shutdown();
+ m_aBoldListener.shutdown();
+ m_aItalicListener.shutdown();
+ m_aUnderlineListener.shutdown();
+
+ m_aFontListener = null;
+ m_aSizeListener = null;
+ m_aBoldListener = null;
+ m_aItalicListener = null;
+ m_aUnderlineListener = null;
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/ViewContainer.java b/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/ViewContainer.java
new file mode 100644
index 000000000..d859f2035
--- /dev/null
+++ b/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/ViewContainer.java
@@ -0,0 +1,260 @@
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+// __________ Imports __________
+
+import java.util.*;
+
+// __________ Implementation __________
+
+/**
+ * It's implement a static container which hold
+ * all opened documents and her views alive.
+ * It's possible to register/deregister such views,
+ * to get information about these and it provides
+ * some global functionality - like termination of
+ * this demo application.
+ *
+ */
+public class ViewContainer extends Thread
+{
+
+
+ /**
+ * provides a singleton view container
+ * Necessary for terminate(9 functionality to be able
+ * to call Runtime.runFinilization().
+ *
+ * @return a reference to the singleton ViewContainer instance
+ */
+ public static synchronized ViewContainer getGlobalContainer()
+ {
+ if (maSingleton==null)
+ maSingleton=new ViewContainer();
+ return maSingleton;
+ }
+
+
+
+ /**
+ * ctor
+ * It's private - because nobody should create any instance
+ * expect the only global one, which will be created by ourself!
+ */
+ private ViewContainer()
+ {
+ mlViews = new ArrayList<Object>();
+ mlListener = new ArrayList<IShutdownListener>();
+ mbShutdownActive = false ;
+ Runtime.getRuntime().addShutdownHook(this);
+ }
+
+
+
+ /**
+ * This register a new view inside this global container
+ * (if it doesn't already exist).
+ *
+ * @param aView view which wishes to be registered inside this container
+ */
+ public void addView(Object aView)
+ {
+ synchronized(mlViews)
+ {
+ if(!mlViews.contains(aView))
+ mlViews.add(aView);
+ }
+ }
+
+
+
+ /**
+ * This deregister a view from this global container.
+ * Normally it should be the last reference to the view
+ * and her finalize() method should be called.
+ * If last view will be closed here - we terminate these
+ * java application too. Because there is no further
+ * visible frame anymore.
+ *
+ * @param aView
+ * view object which wishes to be deregistered
+ */
+ public void removeView(Object aView)
+ {
+ int nViewCount = 0;
+ synchronized(mlViews)
+ {
+ if(mlViews.contains(aView))
+ mlViews.remove(aView);
+
+ nViewCount = mlViews.size();
+
+ if (nViewCount<1)
+ mlViews = null;
+ }
+ // If this view is a registered shutdown listener on this view container
+ // too, we must call his interface and forget him as possible listener.
+ // It's necessary to guarantee his dead ...
+ boolean bShutdownView = false;
+ synchronized(mlListener)
+ {
+ bShutdownView = mlListener.contains(aView);
+ if (bShutdownView)
+ mlListener.remove(aView);
+ }
+ if (bShutdownView)
+ ((IShutdownListener)aView).shutdown();
+
+ // We use a system.exit() to finish the whole application.
+ // And further we have registered THIS instance as a possible shutdown
+ // hook at the runtime class. So our run() method will be called.
+ // Our view container should be empty - but
+ // our listener container can include some references.
+ // These objects will be informed then and release e.g. some
+ // remote references.
+ if (nViewCount<1)
+ {
+ boolean bNecessary = false;
+ synchronized(this)
+ {
+ bNecessary = ! mbShutdownActive;
+ }
+ if (bNecessary)
+ {
+ System.out.println("call exit(0)!");
+ System.exit(0);
+ }
+ }
+ }
+
+
+
+ /**
+ * add/remove listener for possible shutdown events
+ */
+ public void addListener( IShutdownListener rListener )
+ {
+ synchronized(mlListener)
+ {
+ if ( ! mlListener.contains(rListener) )
+ mlListener.add(rListener);
+ }
+ }
+
+
+
+ private void removeListener( IShutdownListener rListener )
+ {
+ synchronized(mlListener)
+ {
+ if ( mlListener.contains(rListener) )
+ mlListener.remove(rListener);
+ }
+ }
+
+
+
+ /**
+ * Is called from current runtime system of the java machine
+ * on shutdown. We inform all current registered listener and
+ * views. They should deinitialize her internal things then.
+ */
+ @Override
+ public void run()
+ {
+ synchronized(this)
+ {
+ if (mbShutdownActive)
+ return;
+ mbShutdownActive=true;
+ }
+
+ while( true )
+ {
+ IShutdownListener aListener = null;
+ synchronized(mlListener)
+ {
+ if (!mlListener.isEmpty())
+ aListener = mlListener.get(0);
+ }
+ if (aListener==null)
+ break;
+
+ aListener.shutdown();
+ // May this listener has deregistered himself.
+ // But if not we must do it for him. Our own
+ // method "removeListener()" ignore requests for
+ // already gone listener objects.
+ removeListener(aListener);
+ }
+
+ if (mlViews!=null)
+ {
+ synchronized(mlViews)
+ {
+ mlViews.clear();
+ mlViews = null;
+ }
+ }
+
+ if (mlListener!=null)
+ {
+ synchronized(mlListener)
+ {
+ mlListener.clear();
+ mlListener = null;
+ }
+ }
+ }
+
+
+
+ /**
+ * @member mbInplace indicates using of inplace office frames instead of outplace ones
+ * @member maSingleton singleton instance of this view container
+ * @member mlViews list of all currently registered document views
+ * @member mlListener list of all currently registered shutdown listener
+ * @member mbShutdownActive if this shutdown hook already was started it's not a good idea to
+ * call System.exit() again for other conditions.
+ * We suppress it by using this variable!
+ */
+ public static boolean mbInplace = false ;
+ private static ViewContainer maSingleton = null ;
+ private ArrayList<Object> mlViews ;
+ private ArrayList<IShutdownListener> mlListener ;
+ private boolean mbShutdownActive ;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/nativelib/unix/Makefile b/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/nativelib/unix/Makefile
new file mode 100644
index 000000000..aa7a158b8
--- /dev/null
+++ b/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/nativelib/unix/Makefile
@@ -0,0 +1,72 @@
+#*************************************************************************
+#
+# The Contents of this file are made available subject to the terms of
+# the BSD license.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+# 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+# contributors may be used to endorse or promote products derived
+# from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+# TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+# USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+#**************************************************************************
+
+# Builds the OfficeDevDesktopEnvironment native library of the Developers Guide.
+
+PRJ=../../../../../..
+SETTINGS=$(PRJ)/settings
+
+include $(SETTINGS)/settings.mk
+include $(SETTINGS)/std.mk
+
+# Define non-platform/compiler specific settings
+SHL_NAME=nativeview
+SHL_LIBRARY=$(SHAREDLIB_OUT)/$(SHAREDLIB_PRE)$(SHL_NAME).$(SHAREDLIB_EXT)
+
+OUT_SHL_SLO=$(OUT_SLO)/nativeview
+
+CFILES = nativeview.c
+
+SLOFILES = $(patsubst %.c,$(OUT_SHL_SLO)/%.$(OBJ_EXT),$(CFILES))
+
+
+# Targets
+.PHONY: ALL
+ALL : $(SHL_LIBRARY)
+
+include $(SETTINGS)/stdtarget.mk
+
+$(OUT_SHL_SLO)/%.$(OBJ_EXT) : %.c
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ $(CC) $(CC_FLAGS_JNI) $(CC_INCLUDES) $(SDK_JAVA_INCLUDES) $(CC_DEFINES_JNI) $(CC_OUTPUT_SWITCH)$(subst /,$(PS),$@) $<
+
+$(SHAREDLIB_OUT)/$(SHAREDLIB_PRE)$(SHL_NAME).$(SHAREDLIB_EXT) : $(SLOFILES)
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ $(LINK) $(LIBRARY_LINK_FLAGS) $(LINK_LIBS) $(LINK_JAVA_LIBS) -o $@ $< \
+ -ljawt $(CPPUHELPERLIB) $(CPPULIB) $(SALLIB) $(STDC++LIB)
+
+.PHONY: clean
+clean :
+ -$(DELRECURSIVE) $(subst /,$(PS),$(OUT_SHL_SLO))
+ -$(DEL) $(subst /,$(PS),$(SHAREDLIB_OUT))$(PS)*$(SHL_NAME)*.*
diff --git a/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/nativelib/unix/nativeview.c b/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/nativelib/unix/nativeview.c
new file mode 100644
index 000000000..5343f85e9
--- /dev/null
+++ b/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/nativelib/unix/nativeview.c
@@ -0,0 +1,112 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+#include <X11/Xlib.h>
+#include <X11/Xutil.h>
+#include <X11/Intrinsic.h>
+
+#include "jawt.h"
+#include "jawt_md.h"
+#include "nativeview.h"
+
+#define MY_ASSERT(X,S) if (!X) { fprintf(stderr,S); return 0;}
+
+#define SYSTEM_WIN32 1
+#define SYSTEM_WIN16 2
+#define SYSTEM_JAVA 3
+#define SYSTEM_OS2 4
+#define SYSTEM_MAC 5
+#define SYSTEM_XWINDOW 6
+
+/*****************************************************************************/
+/*
+ * Class: NativeView
+ * Method: getNativeWindowSystemType
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL Java_NativeView_getNativeWindowSystemType
+ (JNIEnv * env, jobject obj_this)
+{
+ return SYSTEM_XWINDOW;
+}
+
+/*****************************************************************************/
+/*
+ * Class: NativeView
+ * Method: getNativeWindow
+ * Signature: ()J
+ */
+JNIEXPORT jlong JNICALL Java_NativeView_getNativeWindow
+ (JNIEnv * env, jobject obj_this)
+{
+ jboolean result ;
+ jint lock ;
+ JAWT awt ;
+ JAWT_DrawingSurface* ds ;
+ JAWT_DrawingSurfaceInfo* dsi ;
+ JAWT_X11DrawingSurfaceInfo* dsi_x11 ;
+ Drawable drawable;
+
+ /* Get the AWT */
+ awt.version = JAWT_VERSION_1_3;
+ result = JAWT_GetAWT(env, &awt);
+ MY_ASSERT(result != JNI_FALSE,"wrong jawt version");
+
+ /* Get the drawing surface */
+ if ((ds = awt.GetDrawingSurface(env, obj_this)) == NULL)
+ return 0;
+
+ /* Lock the drawing surface */
+ lock = ds->Lock(ds);
+ MY_ASSERT((lock & JAWT_LOCK_ERROR)==0,"can't lock the drawing surface");
+
+ /* Get the drawing surface info */
+ dsi = ds->GetDrawingSurfaceInfo(ds);
+
+ /* Get the platform-specific drawing info */
+ dsi_x11 = (JAWT_X11DrawingSurfaceInfo*)dsi->platformInfo;
+ drawable = dsi_x11->drawable;
+
+ /* Free the drawing surface info */
+ ds->FreeDrawingSurfaceInfo(dsi);
+ /* Unlock the drawing surface */
+ ds->Unlock(ds);
+ /* Free the drawing surface */
+ awt.FreeDrawingSurface(ds);
+
+ return (jlong)drawable;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/nativelib/unix/nativeview.h b/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/nativelib/unix/nativeview.h
new file mode 100644
index 000000000..99207192f
--- /dev/null
+++ b/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/nativelib/unix/nativeview.h
@@ -0,0 +1,64 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+/* DO NOT EDIT THIS FILE - it is machine generated */
+#include <jni.h>
+/* Header for class org_openoffice_OpenOffice */
+
+#ifndef _Included_NativeView
+#define _Included_NativeView
+#ifdef __cplusplus
+extern "C" {
+#endif
+/*
+ * Class: org_openoffice_OpenOffice
+ * Method: getNativeWindowSystemType
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL Java_NativeView_getNativeWindowSystemType(JNIEnv*, jobject);
+
+/*
+ * Class: org_openoffice_OpenOffice
+ * Method: getNativeWindow
+ * Signature: ()J
+ */
+JNIEXPORT jlong JNICALL Java_NativeView_getNativeWindow(JNIEnv*, jobject);
+
+#ifdef __cplusplus
+}
+#endif
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/nativelib/windows/Makefile b/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/nativelib/windows/Makefile
new file mode 100644
index 000000000..62980a2ee
--- /dev/null
+++ b/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/nativelib/windows/Makefile
@@ -0,0 +1,77 @@
+#*************************************************************************
+#
+# The Contents of this file are made available subject to the terms of
+# the BSD license.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+# 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+# contributors may be used to endorse or promote products derived
+# from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+# TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+# USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+#**************************************************************************
+
+# Builds the OfficeDevDesktopEnvironment native library of the Developers Guide.
+
+PRJ=../../../../../..
+SETTINGS=$(PRJ)/settings
+
+include $(SETTINGS)/settings.mk
+include $(SETTINGS)/std.mk
+
+# Define non-platform/compiler specific settings
+SHL_NAME=nativeview
+SHL_LIBRARY=$(SHAREDLIB_OUT)/$(SHAREDLIB_PRE)$(SHL_NAME).$(SHAREDLIB_EXT)
+
+OUT_SHL_SLO=$(OUT_SLO)/nativeview
+OUT_SHL_MISC=$(OUT_MISC)/nativeview
+
+CFILES = nativeview.c
+
+SLOFILES = $(patsubst %.c,$(OUT_SHL_SLO)/%.$(OBJ_EXT),$(CFILES))
+
+# Targets
+.PHONY: ALL
+ALL : \
+ $(SHL_LIBRARY)
+
+include $(SETTINGS)/stdtarget.mk
+
+$(OUT_SHL_SLO)/%.$(OBJ_EXT) : %.c
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ $(CC) $(CC_FLAGS_JNI) $(CC_INCLUDES) $(SDK_JAVA_INCLUDES) $(CC_DEFINES_JNI) $(CC_OUTPUT_SWITCH)$(subst /,$(PS),$@) $<
+
+$(SHAREDLIB_OUT)/$(SHAREDLIB_PRE)$(SHL_NAME).$(SHAREDLIB_EXT) : $(SLOFILES) $(SHL_NAME).def
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ -$(MKDIR) $(subst /,$(PS),$(OUT_SHL_MISC))
+ $(LINK) $(LIBRARY_LINK_FLAGS) /DEF:$(SHL_NAME).def /OUT:$@ \
+ /MAP:$(OUT_SHL_MISC)/$(SHL_NAME).map $(LINK_JAVA_LIBS) \
+ $(SLOFILES) jawt.lib $(LIBO_SDK_LDFLAGS_STDLIBS) user32.lib
+ $(LINK_MANIFEST)
+
+.PHONY: clean
+clean :
+ -$(DELRECURSIVE) $(subst /,$(PS),$(OUT_SHL_SLO))
+ -$(DELRECURSIVE) $(subst /,$(PS),$(OUT_SHL_MISC))
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$(SHAREDLIB_OUT))$(PS)*$(SHL_NAME)*.*)
diff --git a/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/nativelib/windows/nativeview.c b/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/nativelib/windows/nativeview.c
new file mode 100644
index 000000000..2de998c69
--- /dev/null
+++ b/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/nativelib/windows/nativeview.c
@@ -0,0 +1,181 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+#include <windows.h>
+
+#include "jawt.h"
+#include "jawt_md.h"
+#include "NativeView.h"
+
+#define MY_ASSERT(X,S) if (!X) { fprintf(stderr,"%s\n",S); return 0;}
+
+#define SYSTEM_WIN32 1
+#define SYSTEM_WIN16 2
+#define SYSTEM_JAVA 3
+#define SYSTEM_OS2 4
+#define SYSTEM_MAC 5
+#define SYSTEM_XWINDOW 6
+
+// property name to register own window procedure on hwnd
+#define OLD_PROC_KEY "oldwindowproc"
+// signature of this window procedure
+static LRESULT APIENTRY NativeViewWndProc( HWND , UINT , WPARAM , LPARAM );
+
+/*****************************************************************************
+ *
+ * Class : NativeView
+ * Method : getNativeWindowSystemType
+ * Signature : ()I
+ * Description: returns an identifier for the current operating system
+ */
+JNIEXPORT jint JNICALL Java_NativeView_getNativeWindowSystemType
+ (JNIEnv * env, jobject obj_this)
+{
+ return SYSTEM_WIN32;
+}
+
+/*****************************************************************************
+ *
+ * Class : NativeView
+ * Method : getNativeWindow
+ * Signature : ()J
+ * Description: returns the native systemw window handle of this object
+ */
+JNIEXPORT jlong JNICALL Java_NativeView_getNativeWindow
+ (JNIEnv * env, jobject obj_this)
+{
+ jboolean result ;
+ jint lock ;
+ JAWT awt ;
+ JAWT_DrawingSurface* ds ;
+ JAWT_DrawingSurfaceInfo* dsi ;
+ JAWT_Win32DrawingSurfaceInfo* dsi_win ;
+ HDC hdc ;
+ HWND hWnd ;
+ LONG hFuncPtr;
+
+ /* Get the AWT */
+ awt.version = JAWT_VERSION_1_3;
+ result = JAWT_GetAWT(env, &awt);
+ MY_ASSERT(result!=JNI_FALSE,"wrong jawt version");
+
+ /* Get the drawing surface */
+ if ((ds = awt.GetDrawingSurface(env, obj_this)) == NULL)
+ return 0;
+
+ /* Lock the drawing surface */
+ lock = ds->Lock(ds);
+ MY_ASSERT((lock & JAWT_LOCK_ERROR)==0,"can't lock the drawing surface");
+
+ /* Get the drawing surface info */
+ dsi = ds->GetDrawingSurfaceInfo(ds);
+
+ /* Get the platform-specific drawing info */
+ dsi_win = (JAWT_Win32DrawingSurfaceInfo*)dsi->platformInfo;
+ hdc = dsi_win->hdc;
+ hWnd = dsi_win->hwnd;
+
+ /* Free the drawing surface info */
+ ds->FreeDrawingSurfaceInfo(dsi);
+ /* Unlock the drawing surface */
+ ds->Unlock(ds);
+ /* Free the drawing surface */
+ awt.FreeDrawingSurface(ds);
+
+ /* Register own window procedure
+ Do it one times only! Otherwise
+ multiple instances will be registered
+ and calls on such construct produce
+ a stack overflow.
+ */
+ if (GetProp( hWnd, OLD_PROC_KEY )==0)
+ {
+ hFuncPtr = SetWindowLongPtr( hWnd, GWLP_WNDPROC, (LONG_PTR)NativeViewWndProc );
+ SetProp( hWnd, OLD_PROC_KEY, (HANDLE)hFuncPtr );
+ }
+
+ return (jlong)hWnd;
+}
+
+/*****************************************************************************
+ *
+ * Class : -
+ * Method : NativeViewWndProc
+ * Signature : -
+ * Description: registered window handler to intercept window messages between
+ * java and office process
+ */
+static LRESULT APIENTRY NativeViewWndProc(
+ HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
+{
+ HANDLE hFuncPtr;
+
+ /* resize new created child window to fill out the java window complete */
+ if (uMsg==WM_PARENTNOTIFY)
+ {
+ if (wParam == WM_CREATE)
+ {
+ RECT rect;
+ HWND hChild = (HWND) lParam;
+
+ GetClientRect(hWnd, &rect);
+
+ SetWindowPos(hChild,
+ NULL,
+ rect.left,
+ rect.top,
+ rect.right - rect.left,
+ rect.bottom - rect.top,
+ SWP_NOZORDER);
+ }
+ }
+ /* handle normal resize events */
+ else if(uMsg==WM_SIZE)
+ {
+ WORD newHeight = HIWORD(lParam);
+ WORD newWidth = LOWORD(lParam);
+ HWND hChild = GetWindow(hWnd, GW_CHILD);
+
+ if (hChild != NULL)
+ SetWindowPos(hChild, NULL, 0, 0, newWidth, newHeight, SWP_NOZORDER);
+ }
+
+ /* forward request to original handler which is intercepted by this window procedure */
+ hFuncPtr = GetProp(hWnd, OLD_PROC_KEY);
+ MY_ASSERT(hFuncPtr,"lost original window proc handler");
+ return CallWindowProc( hFuncPtr, hWnd, uMsg, wParam, lParam);
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/nativelib/windows/nativeview.def b/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/nativelib/windows/nativeview.def
new file mode 100644
index 000000000..f9ba2a78b
--- /dev/null
+++ b/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/nativelib/windows/nativeview.def
@@ -0,0 +1,3 @@
+EXPORTS
+Java_NativeView_getNativeWindowSystemType
+Java_NativeView_getNativeWindow
diff --git a/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/nativelib/windows/nativeview.h b/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/nativelib/windows/nativeview.h
new file mode 100644
index 000000000..99207192f
--- /dev/null
+++ b/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/nativelib/windows/nativeview.h
@@ -0,0 +1,64 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+/* DO NOT EDIT THIS FILE - it is machine generated */
+#include <jni.h>
+/* Header for class org_openoffice_OpenOffice */
+
+#ifndef _Included_NativeView
+#define _Included_NativeView
+#ifdef __cplusplus
+extern "C" {
+#endif
+/*
+ * Class: org_openoffice_OpenOffice
+ * Method: getNativeWindowSystemType
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL Java_NativeView_getNativeWindowSystemType(JNIEnv*, jobject);
+
+/*
+ * Class: org_openoffice_OpenOffice
+ * Method: getNativeWindow
+ * Signature: ()J
+ */
+JNIEXPORT jlong JNICALL Java_NativeView_getNativeWindow(JNIEnv*, jobject);
+
+#ifdef __cplusplus
+}
+#endif
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/OfficeDev/DisableCommands/DisableCommandsTest.java b/odk/examples/DevelopersGuide/OfficeDev/DisableCommands/DisableCommandsTest.java
new file mode 100644
index 000000000..0d4b09bf0
--- /dev/null
+++ b/odk/examples/DevelopersGuide/OfficeDev/DisableCommands/DisableCommandsTest.java
@@ -0,0 +1,397 @@
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+import com.sun.star.configuration.theDefaultProvider;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.XComponentContext;
+import com.sun.star.lang.XMultiComponentFactory;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.util.XURLTransformer;
+import com.sun.star.frame.XComponentLoader;
+import com.sun.star.text.XTextDocument;
+
+/*
+ * Provides example code how to enable/disable
+ * commands.
+ */
+public class DisableCommandsTest {
+
+ /*
+ * A list of command names
+ */
+ final private static String[] aCommandURLTestSet =
+ {
+ "Open",
+ "About",
+ "SelectAll",
+ "Quit",
+ };
+
+ private static XComponentContext xRemoteContext = null;
+ private static XMultiComponentFactory xRemoteServiceManager = null;
+ private static XURLTransformer xTransformer = null;
+ private static XMultiServiceFactory xConfigProvider = null;
+
+ /*
+ * @param args the command line arguments
+ */
+ public static void main(String[] args) {
+
+ try {
+ // get the remote office context. If necessary a new office
+ // process is started
+ xRemoteContext = com.sun.star.comp.helper.Bootstrap.bootstrap();
+ System.out.println("Connected to a running office ...");
+ xRemoteServiceManager = xRemoteContext.getServiceManager();
+
+ Object transformer = xRemoteServiceManager.createInstanceWithContext(
+ "com.sun.star.util.URLTransformer", xRemoteContext );
+ xTransformer = UnoRuntime.queryInterface(com.sun.star.util.XURLTransformer.class,
+ transformer );
+
+ xConfigProvider = theDefaultProvider.get(xRemoteContext);
+
+ // create a new test document
+ Object oDesktop = xRemoteServiceManager.createInstanceWithContext(
+ "com.sun.star.frame.Desktop", xRemoteContext);
+
+ XComponentLoader xCompLoader =UnoRuntime.queryInterface(XComponentLoader.class, oDesktop);
+
+ com.sun.star.lang.XComponent xComponent =
+ xCompLoader.loadComponentFromURL("private:factory/swriter",
+ "_blank", 0, new com.sun.star.beans.PropertyValue[0]);
+ {
+ XTextDocument xDoc =UnoRuntime.queryInterface(XTextDocument.class, xComponent);
+ xDoc.getText().setString("You can now check the disabled commands. The "
+ +"following commands are disabled:\n\n"
+ +" Open...\n Exit\n Select All\n "
+ +"About StarOffice|OpenOffice\n\nPress "
+ + "\"return\" in the shell where you have "
+ + "started the example to enable the "
+ + "commands!\n\nCheck the commands again and "
+ + "press once more \"return\" to finish the "
+ + "example and close the document.");
+
+ // ensure that the document content is optimal visible
+ com.sun.star.frame.XModel xModel =
+ UnoRuntime.queryInterface(
+ com.sun.star.frame.XModel.class, xDoc);
+ // get the frame for later usage
+ com.sun.star.frame.XFrame xFrame =
+ xModel.getCurrentController().getFrame();
+
+ com.sun.star.view.XViewSettingsSupplier xViewSettings =
+ UnoRuntime.queryInterface(
+ com.sun.star.view.XViewSettingsSupplier.class,
+ xModel.getCurrentController());
+ xViewSettings.getViewSettings().setPropertyValue(
+ "ZoomType", Short.valueOf((short)0));
+ }
+ // test document will be closed later
+
+ // First we need a defined starting point. So we have to remove
+ // all commands from the disabled set!
+ enableCommands();
+
+ // Check if the commands are usable
+ testCommands( false );
+
+ // Disable the commands
+ disableCommands();
+
+ // Now the commands shouldn't be usable anymore
+ testCommands( true );
+
+ // you can now check the test document and see which commands are
+ // disabled
+ System.out.println("\nYou can now check the disabled commands.\n"
+ +"Please press 'return' to enable the commands!");
+ waitForUserInput();
+
+ // Remove disable commands to make Office usable again
+ enableCommands();
+
+ // you can check the test document again and see that the commands
+ // are enabled now
+ System.out.println("Check again the now enabled commands.\n"
+ +"Please press 'return' to finish the example and "
+ +"close the document!");
+ waitForUserInput();
+
+ // close test document
+ com.sun.star.util.XCloseable xCloseable = UnoRuntime.queryInterface(com.sun.star.util.XCloseable.class,
+ xComponent );
+
+ if (xCloseable != null ) {
+ xCloseable.close(false);
+ } else
+ {
+ xComponent.dispose();
+ }
+ }
+ catch (java.lang.Exception e){
+ e.printStackTrace();
+ }
+ finally {
+ System.exit(0);
+ }
+ }
+
+ /**
+ * Wait for user input -> until the user press 'return'
+ */
+ private static void waitForUserInput() throws java.io.IOException {
+
+ java.io.BufferedReader reader
+ = new java.io.BufferedReader(new java.io.InputStreamReader(System.in));
+
+ reader.read();
+ }
+
+ /**
+ * Test the commands that we enabled/disabled
+ */
+ private static void testCommands( boolean bDisabledCmds )
+ throws com.sun.star.uno.Exception
+ {
+ // We need the desktop to get access to the current frame
+ Object desktop = xRemoteServiceManager.createInstanceWithContext(
+ "com.sun.star.frame.Desktop", xRemoteContext );
+ com.sun.star.frame.XDesktop xDesktop = UnoRuntime.queryInterface(com.sun.star.frame.XDesktop.class, desktop );
+ com.sun.star.frame.XFrame xFrame = xDesktop.getCurrentFrame();
+ com.sun.star.frame.XDispatchProvider xDispatchProvider = null;
+ if ( xFrame != null )
+ {
+ // We have a frame. Now we need access to the dispatch provider.
+ xDispatchProvider =
+ UnoRuntime.queryInterface(
+ com.sun.star.frame.XDispatchProvider.class, xFrame );
+ if ( xDispatchProvider != null )
+ {
+ // As we have the dispatch provider we can now check if we get
+ // a dispatch object or not.
+ for ( int n = 0; n < aCommandURLTestSet.length; n++ )
+ {
+ // Prepare the URL
+ com.sun.star.util.URL[] aURL = new com.sun.star.util.URL[1];
+ aURL[0] = new com.sun.star.util.URL();
+ com.sun.star.frame.XDispatch xDispatch = null;
+
+ aURL[0].Complete = ".uno:" + aCommandURLTestSet[n];
+ xTransformer.parseSmart( aURL, ".uno:" );
+
+ // Try to get a dispatch object for our URL
+ xDispatch = xDispatchProvider.queryDispatch( aURL[0], "", 0 );
+
+ if ( xDispatch != null )
+ {
+ if ( bDisabledCmds )
+ System.out.println(
+ "Something is wrong, I got dispatch object for "
+ + aURL[0].Complete );
+ else
+ System.out.println( "Ok, dispatch object for "
+ + aURL[0].Complete );
+ }
+ else
+ {
+ if ( !bDisabledCmds )
+ System.out.println("Something is wrong, I cannot get dispatch object for " + aURL[0].Complete );
+ else
+ System.out.println( "Ok, no dispatch object for "
+ + aURL[0].Complete );
+ }
+ resetURL( aURL[0] );
+ }
+ }
+ else
+ System.out.println( "Couldn't get XDispatchProvider from Frame!" );
+ }
+ else
+ System.out.println( "Couldn't get current Frame from Desktop!" );
+ }
+
+ /**
+ * Ensure that there are no disabled commands in the user layer. The
+ * implementation removes all commands from the disabled set!
+ */
+ private static void enableCommands() {
+ // Set the root path for our configuration access
+ com.sun.star.beans.PropertyValue[] lParams =
+ new com.sun.star.beans.PropertyValue[1];
+
+ lParams[0] = new com.sun.star.beans.PropertyValue();
+ lParams[0].Name = "nodepath";
+ lParams[0].Value = "/org.openoffice.Office.Commands/Execute/Disabled";
+
+ try {
+ // Create configuration update access to have write access to the
+ // configuration
+ Object xAccess = xConfigProvider.createInstanceWithArguments(
+ "com.sun.star.configuration.ConfigurationUpdateAccess",
+ lParams );
+
+ com.sun.star.container.XNameAccess xNameAccess =
+ UnoRuntime.queryInterface(
+ com.sun.star.container.XNameAccess.class, xAccess );
+
+ if ( xNameAccess != null ) {
+ // We need the XNameContainer interface to remove the nodes by name
+ com.sun.star.container.XNameContainer xNameContainer =
+ UnoRuntime.queryInterface(
+ com.sun.star.container.XNameContainer.class, xAccess );
+
+ // Retrieves the names of all Disabled nodes
+ String[] aCommandsSeq = xNameAccess.getElementNames();
+ for ( int n = 0; n < aCommandsSeq.length; n++ ) {
+ try {
+ // remove the node
+ xNameContainer.removeByName( aCommandsSeq[n] );
+ }
+ catch ( com.sun.star.lang.WrappedTargetException e ) {
+ }
+ catch ( com.sun.star.container.NoSuchElementException e ) {
+ }
+ }
+ }
+
+ // Commit our changes
+ com.sun.star.util.XChangesBatch xFlush =
+ UnoRuntime.queryInterface(
+ com.sun.star.util.XChangesBatch.class, xAccess);
+
+ xFlush.commitChanges();
+ }
+ catch ( com.sun.star.uno.Exception e ) {
+ System.out.println( "Exception detected!" );
+ System.out.println( e );
+ }
+ }
+
+ /**
+ * Disable all commands defined in the aCommandURLTestSet array
+ */
+ private static void disableCommands() {
+ // Set the root path for our configuration access
+ com.sun.star.beans.PropertyValue[] lParams =
+ new com.sun.star.beans.PropertyValue[1];
+
+ lParams[0] = new com.sun.star.beans.PropertyValue();
+ lParams[0].Name = "nodepath";
+ lParams[0].Value = "/org.openoffice.Office.Commands/Execute/Disabled";
+
+ try {
+ // Create configuration update access to have write access to the
+ // configuration
+ Object xAccess = xConfigProvider.createInstanceWithArguments(
+ "com.sun.star.configuration.ConfigurationUpdateAccess",
+ lParams );
+
+ com.sun.star.lang.XSingleServiceFactory xSetElementFactory =
+ UnoRuntime.queryInterface(
+ com.sun.star.lang.XSingleServiceFactory.class, xAccess );
+
+ com.sun.star.container.XNameContainer xNameContainer =
+ UnoRuntime.queryInterface(
+ com.sun.star.container.XNameContainer.class, xAccess );
+
+ if ( xSetElementFactory != null && xNameContainer != null ) {
+ Object[] aArgs = new Object[0];
+
+ for ( int i = 0; i < aCommandURLTestSet.length; i++ ) {
+ // Create the nodes with the XSingleServiceFactory of the
+ // configuration
+ Object xNewElement =
+ xSetElementFactory.createInstanceWithArguments( aArgs );
+
+ if ( xNewElement != null ) {
+ // We have a new node. To set the properties of the node
+ // we need the XPropertySet interface.
+ com.sun.star.beans.XPropertySet xPropertySet =
+ UnoRuntime.queryInterface(
+ com.sun.star.beans.XPropertySet.class,
+ xNewElement );
+
+ if ( xPropertySet != null ) {
+ // Create a unique node name.
+ String aCmdNodeName = "Command-";
+ aCmdNodeName += i;
+
+ // Insert the node into the Disabled set
+ xPropertySet.setPropertyValue( "Command",
+ aCommandURLTestSet[i] );
+ xNameContainer.insertByName( aCmdNodeName,
+ xNewElement );
+ }
+ }
+ }
+
+ // Commit our changes
+ com.sun.star.util.XChangesBatch xFlush =
+ UnoRuntime.queryInterface(
+ com.sun.star.util.XChangesBatch.class, xAccess);
+ xFlush.commitChanges();
+ }
+ }
+ catch ( com.sun.star.uno.Exception e )
+ {
+ System.err.println( "Exception detected!" + e);
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * reset URL so it can be reused
+ *
+ * @param aURL
+ * the URL that should be reset
+ */
+ private static void resetURL( com.sun.star.util.URL aURL )
+ {
+ aURL.Protocol = "";
+ aURL.User = "";
+ aURL.Password = "";
+ aURL.Server = "";
+ aURL.Port = 0;
+ aURL.Path = "";
+ aURL.Name = "";
+ aURL.Arguments = "";
+ aURL.Mark = "";
+ aURL.Main = "";
+ aURL.Complete = "";
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/OfficeDev/DisableCommands/Makefile b/odk/examples/DevelopersGuide/OfficeDev/DisableCommands/Makefile
new file mode 100644
index 000000000..0d60cb414
--- /dev/null
+++ b/odk/examples/DevelopersGuide/OfficeDev/DisableCommands/Makefile
@@ -0,0 +1,91 @@
+#*************************************************************************
+#
+# The Contents of this file are made available subject to the terms of
+# the BSD license.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+# 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+# contributors may be used to endorse or promote products derived
+# from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+# TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+# USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+#**************************************************************************
+
+# Builds the OfficeDevDisableCommandsTest example of the Developers Guide.
+
+PRJ=../../../..
+SETTINGS=$(PRJ)/settings
+
+include $(SETTINGS)/settings.mk
+include $(SETTINGS)/std.mk
+
+# Define non-platform/compiler specific settings
+EXAMPLE_NAME=OfficeDevDisableCommandsTest
+OUT_APP_CLASS = $(OUT_CLASS)/$(EXAMPLE_NAME)
+
+APP1_NAME=DisableCommandsTest
+APP1_JAR=$(OUT_APP_CLASS)/$(APP1_NAME).jar
+
+SDK_CLASSPATH = $(subst $(EMPTYSTRING) $(PATH_SEPARATOR),$(PATH_SEPARATOR),$(CLASSPATH)\
+ $(PATH_SEPARATOR)$(OUT_APP_CLASS))
+
+
+# Targets
+.PHONY: ALL
+ALL : $(EXAMPLE_NAME)
+
+include $(SETTINGS)/stdtarget.mk
+
+$(OUT_APP_CLASS)/%.class : %.java
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ $(SDK_JAVAC) $(JAVAC_FLAGS) -classpath "$(SDK_CLASSPATH)" -d $(OUT_APP_CLASS) $<
+
+$(OUT_APP_CLASS)/%.mf :
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ @echo Main-Class: com.sun.star.lib.loader.Loader> $@
+ $(ECHOLINE)>> $@
+ @echo Name: com/sun/star/lib/loader/Loader.class>> $@
+ @echo Application-Class: $*>> $@
+
+$(OUT_APP_CLASS)/%.jar : $(OUT_APP_CLASS)/%.mf $(OUT_APP_CLASS)/%.class
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ +cd $(subst /,$(PS),$(OUT_APP_CLASS)) && $(SDK_JAR) cvfm $(@F) $*.mf $*.class
+ +$(SDK_JAR) uvf $@ $(SDK_JAVA_UNO_BOOTSTRAP_FILES)
+
+$(APP1_JAR) : $(OUT_APP_CLASS)/$(APP1_NAME).mf $(OUT_APP_CLASS)/$(APP1_NAME).class
+
+$(EXAMPLE_NAME) : $(APP1_JAR)
+ @echo --------------------------------------------------------------------------------
+ @echo Please use the following command to execute the example!
+ @echo -
+ @echo $(MAKE) $(APP1_NAME).run
+ @echo --------------------------------------------------------------------------------
+
+%.run: $(OUT_APP_CLASS)/%.jar
+ $(SDK_JAVA) -Dcom.sun.star.lib.loader.unopath="$(OFFICE_PROGRAM_PATH)" -jar $<
+
+.PHONY: clean
+clean :
+ -$(DELRECURSIVE) $(subst /,$(PS),$(OUT_APP_CLASS))
diff --git a/odk/examples/DevelopersGuide/OfficeDev/FilterDevelopment/AsciiFilter/AsciiReplaceFilter.java b/odk/examples/DevelopersGuide/OfficeDev/FilterDevelopment/AsciiFilter/AsciiReplaceFilter.java
new file mode 100644
index 000000000..5ab5fb3b1
--- /dev/null
+++ b/odk/examples/DevelopersGuide/OfficeDev/FilterDevelopment/AsciiFilter/AsciiReplaceFilter.java
@@ -0,0 +1,702 @@
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+package FilterDevelopment.AsciiFilter;
+
+import com.sun.star.lib.uno.helper.WeakBase;
+import com.sun.star.uno.XComponentContext;
+import com.sun.star.lang.XMultiComponentFactory;
+import com.sun.star.lang.XSingleComponentFactory;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.AnyConverter;
+import com.sun.star.lang.XInitialization;
+import com.sun.star.lang.XServiceInfo;
+import com.sun.star.container.XNamed;
+import com.sun.star.document.XImporter;
+import com.sun.star.document.XExporter;
+import com.sun.star.document.XFilter;
+
+/*-************************************************************************
+ @title implements a filter to import pure ascii text files
+ @description This filter can use an existing In/OutputStream of given
+ MediaDescriptor or use an existing URL instead of that
+ to open the file directly. But for second case the local
+ file system will be used only. There is no support for remote.
+
+ During import/export special functionality can be used to
+ e.g. to change some characters inside the file content
+ or replace some strings (no using of regular expressions!).
+ User can decide at runtime which functionality really should
+ be used by selecting it in an extra filter property dialog.
+
+ So we show how a filter works for import/export, use or create
+ streams and how a filter can offer properties for filtering
+ which can be edit by the user.
+ ************************************************************************-*/
+
+public class AsciiReplaceFilter
+{
+ public static class _AsciiReplaceFilter extends WeakBase
+ implements XInitialization ,
+ XServiceInfo ,
+ XNamed ,
+ XImporter ,
+ XExporter ,
+ XFilter
+ {
+
+
+ // the supported service names, the first one being the service name of the component itself
+ private static final String[] m_serviceNames = { "com.sun.star.comp.ansifilter.AsciiReplaceFilter" , "com.sun.star.document.ImportFilter", "com.sun.star.document.ExportFilter" };
+
+ // filterprocess states
+ private static final int FILTERPROC_RUNS = 0;
+ private static final int FILTERPROC_BREAK = 1;
+ private static final int FILTERPROC_STOPPED = 2;
+
+
+ // member
+
+
+ /// The initial component context, that gives access to the service manager, supported singletons, ...
+ private XComponentContext m_Ctx;
+ /// The service manager, that gives access to all registered services and which is passed to the FilterOptions class for instantiating a ucb service
+ private XMultiComponentFactory m_xMCF;
+ /// we must provide our name
+ private String m_sInternalName;
+ /// saved document reference for import or export (depends on other member m_bImport!)
+ private com.sun.star.text.XTextDocument m_xDocument;
+ /// because we implement an import AND an export filter, we must know which one is required
+ private boolean m_bImport;
+ // we need a flag to cancel any running filter operation
+ private int m_nFilterProcState;
+
+
+ // native interface
+ /**
+ * special debug helper to get an idea how expensive
+ * the implemented filter operations are really.
+ * May be useful for own purposes.
+ *
+ * To see the output inside an office environment
+ * use "soffice ...params... >output.txt"
+ */
+ private final long m_nStart;
+ private long m_nLast ;
+
+ private void measure( String sText )
+ {
+ long nNow = System.currentTimeMillis();
+ System.err.println(sText+"\t"+(nNow-m_nStart)+"\t"+(nNow-m_nLast));
+ m_nLast = nNow;
+ }
+
+
+ // native interface
+ /**
+ * The constructor to initialize every instance
+ *
+ * @param Context
+ * the component context of the office
+ */
+ public _AsciiReplaceFilter(XComponentContext Context )
+ {
+ measure("ctor started");
+ try
+ {
+ m_Ctx = Context ;
+ m_xMCF = m_Ctx.getServiceManager() ;
+ }
+ catch( Exception e )
+ {
+ e.printStackTrace();
+ }
+
+ // these are safe, thus no errorhandling needed:
+ m_sInternalName = "" ;
+ m_xDocument = null ;
+ m_bImport = true ;
+ m_nFilterProcState = FILTERPROC_STOPPED ;
+
+ m_nLast = System.currentTimeMillis();
+ m_nStart = m_nLast;
+ }
+
+
+ // interface XInitialization
+ /**
+ * used for initializing after creation
+ * If an instance of this service is created by UNO we will be called
+ * automatically after that to get optional parameters of this creation call.
+ * E.g.: The service com.sun.star.document.FilterFactory use such mechanism
+ * to pass our own configuration data to this instance.
+ *
+ * @param lArguments
+ * This array of arbitrary objects represent our own filter configuration
+ * and may optional given parameters of the createWithArguments() call.
+ *
+ * @throws com.sun.star.uno.Exception
+ * Every exception will not be handled, but will be
+ * passed to the caller.
+ */
+ public void initialize( Object[] lArguments ) throws com.sun.star.uno.Exception
+ {
+ measure("initialize {");
+
+ if (lArguments.length<1)
+ return;
+
+ // lArguments[0] = own configuration data
+ com.sun.star.beans.PropertyValue[] lConfig = (com.sun.star.beans.PropertyValue[])lArguments[0];
+
+ /*
+ // lArguments[1..n] = optional arguments of create request
+ for (int n=1; n<lArguments.length; ++n)
+ {
+ }
+ */
+
+ // analyze own configuration data for our own internal filter name!
+ // Important for generic filter services, which are registered more than once.
+ // They can use this information to find out, which specialization of it
+ // is required.
+ for (int i=0; i<lConfig.length; ++i)
+ {
+ if (lConfig[i].Name.equals("Name"))
+ {
+ synchronized(this)
+ {
+ try
+ {
+ m_sInternalName = AnyConverter.toString(lConfig[i].Value);
+ }
+ catch(com.sun.star.lang.IllegalArgumentException exConvert) {}
+ }
+ }
+ }
+
+ measure("} initialize");
+ }
+
+
+ // interface XNamed
+ /**
+ * For external user of us we must provide our internal filter name
+ * (which is registered inside configuration package TypeDetection).
+ * User will be able then to ask there for further information about us.
+ * Otherwise we must implement a full featured XPropertySet...
+ *
+ * @return our internal filter name of configuration
+ */
+ public String getName()
+ {
+ synchronized(this)
+ {
+ return m_sInternalName;
+ }
+ }
+
+ /**
+ * It's not allowed for us - neither very easy to change our internal
+ * name during runtime of an office. Because every filter name must
+ * be unambiguous...
+ * So we don't implement this method here.
+ */
+ public void setName( String sName )
+ {
+ }
+
+
+ // interface XImporter
+ /**
+ * This interface is used to tell us: "you will be used for importing a document".
+ * We must save the given model reference to use it inside our own filter request.
+ *
+ * @param xDocument
+ * the document model for importing
+ *
+ * @throw IllegalArgumentException
+ * if given document isn't the right one or seems to be corrupt
+ */
+ public void setTargetDocument( com.sun.star.lang.XComponent xDocument ) throws com.sun.star.lang.IllegalArgumentException
+ {
+ measure("setTargetDocument {");
+
+ if (xDocument==null)
+ throw new com.sun.star.lang.IllegalArgumentException("null reference detected");
+
+ com.sun.star.lang.XServiceInfo xInfo = UnoRuntime.queryInterface(
+ com.sun.star.lang.XServiceInfo.class, xDocument);
+ if ( ! xInfo.supportsService("com.sun.star.text.TextDocument") )
+ throw new com.sun.star.lang.IllegalArgumentException( "wrong document type" );
+
+ // safe it as target document for import
+ // Don't forget to mark this filter used for importing too
+ synchronized(this)
+ {
+ m_xDocument = UnoRuntime.queryInterface(
+ com.sun.star.text.XTextDocument.class, xDocument);
+ m_bImport = true;
+ }
+
+ measure("} setTargetDocument");
+ }
+
+
+ // interface XExporter
+ /**
+ * This interface is used to tell us: "you will be used for exporting a document".
+ * We must save the given model reference to use it inside our own filter request.
+ *
+ * @param xDocument
+ * the document model for exporting
+ *
+ * @throw IllegalArgumentException
+ * if given document isn't the right one or seems to be corrupt
+ */
+ public void setSourceDocument( com.sun.star.lang.XComponent xDocument ) throws com.sun.star.lang.IllegalArgumentException
+ {
+ measure("setSourceDocument {");
+
+ if (xDocument==null)
+ throw new com.sun.star.lang.IllegalArgumentException( "null reference given" );
+
+ com.sun.star.lang.XServiceInfo xInfo = UnoRuntime.queryInterface(
+ com.sun.star.lang.XServiceInfo.class, xDocument);
+ if ( ! xInfo.supportsService("com.sun.star.text.TextDocument") )
+ throw new com.sun.star.lang.IllegalArgumentException( "wrong document type" );
+
+ // safe it as source document for export
+ // Don't forget to mark this filter used for exporting too
+ synchronized(this)
+ {
+ m_xDocument = UnoRuntime.queryInterface(
+ com.sun.star.text.XTextDocument.class, xDocument);
+ m_bImport = false;
+ }
+
+ measure("} setSourceDocument");
+ }
+
+
+
+ // interface XFilter
+ /**
+ * Implements the real filter method. We detect if it must be an import or an export.
+ * Depends on that we use an existing stream (given inside the MediaDescriptor)
+ * or open it by using a URL (must be a part of the descriptor too).
+ *
+ * @param lDescriptor
+ * the MediaDescriptor which describes the document
+ *
+ * @return a bool value which describes if method was successful.
+ */
+
+ public boolean filter( com.sun.star.beans.PropertyValue[] lDescriptor )
+ {
+ measure("filter {");
+
+ // first get state of filter operation (import/export)
+ // and try to create or get corresponding streams
+ // Means: analyze given MediaDescriptor
+ // By the way: use synchronized section to get some copies of other
+ // internal states too.
+ FilterOptions aOptions = null ;
+ boolean bImport = false;
+ com.sun.star.text.XTextDocument xText = null ;
+ synchronized(this)
+ {
+ aOptions = new FilterOptions(m_xMCF, m_Ctx, m_bImport, lDescriptor);
+ bImport = m_bImport;
+ xText = m_xDocument;
+ }
+
+ measure("options analyzed");
+
+ if (!aOptions.isValid())
+ return false;
+
+ // start real filtering
+ boolean bState = false;
+ if (bImport)
+ bState = implts_import( xText, aOptions );
+ else
+ bState = implts_export( xText, aOptions );
+
+ measure("} filter");
+
+ return bState;
+ }
+
+ /**
+ * Makes the filter process breakable. To do so the outside code may use threads.
+ * We use an internal "condition" variable which is queried by the real filter method on
+ * every loop they do. So it's more a polling mechanism.
+ */
+ public void cancel()
+ {
+ measure("cancel {");
+
+ synchronized(this)
+ {
+ if (m_nFilterProcState==FILTERPROC_RUNS)
+ m_nFilterProcState=FILTERPROC_BREAK;
+ }
+
+ while (true)
+ {
+ synchronized(this)
+ {
+ if (m_nFilterProcState==FILTERPROC_STOPPED)
+ break;
+ }
+ }
+
+ measure("} cancel");
+ }
+
+
+ // private helper
+ /**
+ * This helper function imports a simple ascii text file into
+ * a text model. We copy every letter to the document.
+ * But if some optional filter options are given
+ * we make some changes: replace chars or complete strings.
+ *
+ * Note: It's not allowed for a filter to seek inside the stream.
+ * Because the outside frameloader has to set the stream position
+ * right and a filter must read till EOF occurs only.
+ *
+ * @param xTarget
+ * the target text model to put the data in
+ *
+ * @param aOptions
+ * capsulate all other necessary information for this filter request
+ * (streams, replace values ...)
+ *
+ * @return a bool value which describes if method was successful.
+ */
+ private boolean implts_import( com.sun.star.text.XTextDocument xTarget ,
+ FilterOptions aOptions )
+ {
+ measure("implts_import {");
+
+ com.sun.star.text.XSimpleText xText = UnoRuntime.queryInterface(
+ com.sun.star.text.XSimpleText.class,
+ xTarget.getText());
+
+ measure("cast XSimpleText");
+
+ boolean bBreaked = false;
+
+ try
+ {
+ StringBuffer sBuffer = new StringBuffer(100000);
+ byte[][] lData = new byte[1][];
+ int nRead = aOptions.m_xInput.readBytes( lData, 4096 );
+
+ measure("read first bytes");
+
+ while (nRead>0 && !bBreaked)
+ {
+ // copy data from stream to temp. buffer
+ sBuffer.append( new String(lData[0]) );
+ measure("buffer append ["+nRead+"]");
+
+ nRead = aOptions.m_xInput.readBytes( lData, 2048 );
+ measure("read next bytes");
+
+ // check for cancelled filter proc on every loop!
+ synchronized(this)
+ {
+ if (m_nFilterProcState==FILTERPROC_BREAK)
+ {
+ m_nFilterProcState = FILTERPROC_STOPPED;
+ return false;
+ }
+ }
+ measure("break check");
+ }
+
+ // Make some replacements inside the buffer.
+ String sText = implts_replace( sBuffer, aOptions );
+ measure("replace");
+
+ // copy current buffer to the document model.
+ // Create a new paragraph for every line inside original file.
+ // May not all data could be read - but that doesn't matter here.
+ // Reason: somewhere cancelled this function.
+ // But check for optional replace request before...
+ int nStart = 0;
+ int nEnd = -1;
+ int nLength = sText.length();
+
+ com.sun.star.text.XTextRange xCursor = UnoRuntime.queryInterface(
+ com.sun.star.text.XTextRange.class,
+ xText.createTextCursor());
+
+ while (true)
+ {
+ nEnd = sText.indexOf('\n',nStart);
+
+ if (nEnd==-1 && nStart<nLength)
+ nEnd = nLength;
+
+ if (nEnd==-1)
+ break;
+
+ String sLine = sText.substring(nStart,nEnd);
+ nStart = nEnd+1;
+
+ xText.insertString(xCursor,sLine,false);
+ xText.insertControlCharacter(xCursor,com.sun.star.text.ControlCharacter.PARAGRAPH_BREAK,false);
+
+ // check for cancelled filter proc on every loop!
+ synchronized(this)
+ {
+ if (m_nFilterProcState==FILTERPROC_BREAK)
+ {
+ m_nFilterProcState = FILTERPROC_STOPPED;
+ return false;
+ }
+ }
+ measure("break check");
+ }
+
+ measure("set on model");
+
+ // with refreshing the document we are on the safe-side, otherwise the first time the filter is used the document is not fully shown (flaw!).
+ com.sun.star.util.XRefreshable xRefresh = UnoRuntime.queryInterface(
+ com.sun.star.util.XRefreshable.class,
+ xTarget);
+ xRefresh.refresh();
+
+ // If we created used stream - we must close it too.
+ if (aOptions.m_bStreamOwner)
+ {
+ aOptions.m_xInput.closeInput();
+ measure("stream close");
+ }
+ }
+ catch(com.sun.star.lang.IllegalArgumentException exArgument ) { bBreaked = true; }
+ catch(com.sun.star.io.BufferSizeExceededException exExceed ) { bBreaked = true; }
+ catch(com.sun.star.io.NotConnectedException exConnect ) { bBreaked = true; }
+ catch(com.sun.star.io.IOException exIO ) { bBreaked = true; }
+
+
+
+ measure("} implts_import");
+
+ return !bBreaked;
+ }
+
+ /**
+ * This helper function exports a simple ansi text file from
+ * a text model. We copy every letter from the document.
+ * There are no checks.
+ *
+ * Note: It's not allowed for a filter to seek inside the stream.
+ * Because the outside frameloader has to set the stream position
+ * right and a filter must read till EOF occurs only.
+ *
+ * @param xSource
+ * the source text model to get the data from
+ *
+ * @param aOptions
+ * capsulate all other necessary information for this filter request
+ * (streams, replace values ...)
+ *
+ * @return a bool value which describes if method was successful.
+ */
+ private boolean implts_export( com.sun.star.text.XTextDocument xSource ,
+ FilterOptions aOptions)
+ {
+ measure("implts_export {");
+
+ com.sun.star.text.XTextRange xText = UnoRuntime.queryInterface(
+ com.sun.star.text.XSimpleText.class,
+ xSource.getText());
+
+ measure("cast XTextRange");
+
+ boolean bBreaked = false;
+
+ try
+ {
+ StringBuffer sBuffer = new StringBuffer(xText.getString());
+ String sText = implts_replace(sBuffer,aOptions);
+
+ measure("get text from model");
+
+ // Normally this function isn't really cancelable
+ // But we following operation can be very expensive. So
+ // this place is the last one to stop it.
+ synchronized(this)
+ {
+ if (m_nFilterProcState==FILTERPROC_BREAK)
+ {
+ m_nFilterProcState = FILTERPROC_STOPPED;
+ return false;
+ }
+ }
+
+ aOptions.m_xOutput.writeBytes(sText.getBytes());
+ aOptions.m_xOutput.flush();
+
+ measure("written to file");
+
+ // If we created used stream - we must close it too.
+ if (aOptions.m_bStreamOwner)
+ {
+ aOptions.m_xOutput.closeOutput();
+ measure("stream close");
+ }
+ }
+ catch(com.sun.star.io.BufferSizeExceededException exExceed ) { bBreaked = true; }
+ catch(com.sun.star.io.NotConnectedException exConnect ) { bBreaked = true; }
+ catch(com.sun.star.io.IOException exIO ) { bBreaked = true; }
+
+ measure("} implts_export");
+
+ return !bBreaked;
+ }
+
+ /**
+ * helper function to convert the used StringBuffer into a String value.
+ * And we use this chance to have a look on optional filter options
+ * which can invite replacing of strings.
+ */
+ private String implts_replace( StringBuffer rBuffer, FilterOptions aOptions )
+ {
+ // replace complete strings first
+ // Because its easier on a buffer then on a string
+ if ( ! aOptions.m_sOld.equals(aOptions.m_sNew) )
+ {
+ int nStart = rBuffer.indexOf(aOptions.m_sOld);
+ int nLength = aOptions.m_sNew.length();
+ int nEnd = nStart+nLength;
+ while (nStart!=-1)
+ {
+ rBuffer.replace(nStart,nEnd,aOptions.m_sNew);
+ nStart = rBuffer.indexOf(aOptions.m_sOld,nEnd);
+ nEnd = nStart+nLength;
+ }
+ }
+
+ // convert buffer into return format [string]
+ // and convert to lower or upper case if required.
+ String sResult = rBuffer.toString();
+ if (aOptions.m_bCaseChange)
+ {
+ if (aOptions.m_bLower)
+ sResult = sResult.toLowerCase();
+ else
+ sResult = sResult.toUpperCase();
+ }
+
+ return sResult;
+ }
+
+
+
+ // interface XServiceInfo
+ /**
+ * This method returns an array of all supported service names.
+ *
+ * @return Array of supported service names.
+ */
+ public String[] getSupportedServiceNames()
+ {
+ return m_serviceNames;
+ }
+
+ /**
+ * This method returns true, if the given service will be
+ * supported by this component.
+ *
+ * @param sService
+ * the requested service name
+ *
+ * @return True, if the given service name will be supported;
+ * False otherwise.
+ */
+ public boolean supportsService( String sService )
+ {
+ return (
+ sService.equals( m_serviceNames[0] ) ||
+ sService.equals( m_serviceNames[1] ) ||
+ sService.equals( m_serviceNames[2] )
+ );
+ }
+
+ /**
+ * Return the real class name of the component
+ *
+ * @return Class name of the component.
+ */
+ public String getImplementationName()
+ {
+ return _AsciiReplaceFilter.class.getName();
+ }
+
+
+ }
+ // end of inner class, the wrapper class just has the two methods required for registering the component
+
+ /**
+ * Gives a factory for creating the service.
+ * This method is called by the <code>JavaLoader</code>
+ *
+ * @param sImplName
+ * The implementation name of the component.
+ *
+ * @return Returns a <code>XSingleComponentFactory</code> for
+ * creating the component.
+ *
+ * @see com.sun.star.comp.loader.JavaLoader
+ */
+
+ public static XSingleComponentFactory __getComponentFactory(String sImplName)
+ {
+ XSingleComponentFactory xFactory = null;
+
+ if ( sImplName.equals( _AsciiReplaceFilter.class.getName() ) )
+ xFactory = com.sun.star.lib.uno.helper.Factory.createComponentFactory(_AsciiReplaceFilter.class,
+ _AsciiReplaceFilter.m_serviceNames);
+ return xFactory;
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/OfficeDev/FilterDevelopment/AsciiFilter/FilterOptions.java b/odk/examples/DevelopersGuide/OfficeDev/FilterDevelopment/AsciiFilter/FilterOptions.java
new file mode 100644
index 000000000..18c45da85
--- /dev/null
+++ b/odk/examples/DevelopersGuide/OfficeDev/FilterDevelopment/AsciiFilter/FilterOptions.java
@@ -0,0 +1,225 @@
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+package FilterDevelopment.AsciiFilter;
+
+import com.sun.star.uno.AnyConverter;
+import com.sun.star.uno.XComponentContext;
+import com.sun.star.lang.XMultiComponentFactory;
+import com.sun.star.uno.UnoRuntime;
+
+/*-************************************************************************
+ @title helper to analyze necessary option properties of our filter
+ @description Our filter needs some necessary properties for working:
+ - a stream for input or output
+ - or a URL for creating such streams
+ - information about required action on filtering
+
+ @attention This class mustn't be threadsafe - because instances of it
+ are used temp. only - not as members. So no concurrent access
+ should occur.
+ Another reason: it would be very difficult to safe every
+ access on our internal member. To do so - we must implement
+ special methods instead of allowing pure member access.
+ ************************************************************************-*/
+
+public class FilterOptions
+{
+
+ // public member to provide these options to our outside filter class
+ public com.sun.star.io.XInputStream m_xInput ;
+ public com.sun.star.io.XOutputStream m_xOutput ;
+ public boolean m_bStreamOwner ;
+ private String m_sURL ;
+ public String m_sOld ;
+ public String m_sNew ;
+ public boolean m_bCaseChange ;
+ public boolean m_bLower ;
+
+
+ // private members for internal things
+ private final XMultiComponentFactory m_xMCF;
+ private final XComponentContext m_Ctx;
+
+
+ // interface
+ /**
+ * creates a new instance of this class
+ * It use the given MediaDescriptor to find right
+ * properties for initialization of the internal members.
+ * To do so it use another interface method analyze()
+ * which can be used after creation of an object instance
+ * to set a new descriptor here.
+ *
+ * @param xMCF
+ * we need it to create special help service top open
+ * streams in case they are not already a part of given
+ * MediaDescriptor
+ *
+ * @param bImport
+ * we must know which stream member should be valid initialized
+ *
+ * @param lDescriptor
+ * the initial MediaDescriptor to set internal member from it
+ */
+ public FilterOptions( XMultiComponentFactory xMCF ,
+ XComponentContext Context ,
+ boolean bImport ,
+ com.sun.star.beans.PropertyValue[] lDescriptor )
+ {
+ m_xMCF = xMCF;
+ m_Ctx = Context;
+ analyze(bImport, lDescriptor);
+ }
+
+ /**
+ * analyze given MediaDescriptor to find values for our internal member
+ * It reset all members to defaults before - to prevent us against
+ * mixed descriptor values!
+ *
+ * @param bImport
+ * we must know which stream member should be valid initialized
+ *
+ * @param lDescriptor
+ * the new MediaDescriptor to set internal member from it
+ */
+ private void analyze( boolean bImport ,
+ com.sun.star.beans.PropertyValue[] lDescriptor )
+ {
+ m_xInput = null ;
+ m_xOutput = null ;
+ m_bStreamOwner = false ;
+ m_sURL = null ;
+ m_sOld = "";
+ m_sNew = "";
+ m_bCaseChange = false ;
+ m_bLower = false ;
+
+ for ( int i=0; i<lDescriptor.length; ++i )
+ {
+ try
+ {
+ if (lDescriptor[i].Name.equals("FileName"))
+ m_sURL = AnyConverter.toString(lDescriptor[i].Value);
+ else
+ if (lDescriptor[i].Name.equals("InputStream"))
+ m_xInput = (com.sun.star.io.XInputStream)AnyConverter.toObject(new com.sun.star.uno.Type(com.sun.star.io.XInputStream.class), lDescriptor[i].Value);
+ else
+ if (lDescriptor[i].Name.equals("OutputStream"))
+ m_xOutput = (com.sun.star.io.XOutputStream)AnyConverter.toObject(new com.sun.star.uno.Type(com.sun.star.io.XOutputStream.class), lDescriptor[i].Value);
+ else
+ if (lDescriptor[i].Name.equals("FilterData"))
+ {
+ com.sun.star.beans.PropertyValue[] lFilterProps = (com.sun.star.beans.PropertyValue[])AnyConverter.toArray(lDescriptor[i].Value);
+ int nCount = lFilterProps.length;
+ for (int p=0; p<nCount; ++p)
+ {
+ if (lFilterProps[p].Name.equals("OldString"))
+ m_sOld = AnyConverter.toString(lFilterProps[p].Value);
+ else
+ if (lFilterProps[p].Name.equals("NewString"))
+ m_sNew = AnyConverter.toString(lFilterProps[p].Value);
+ else
+ if (lFilterProps[p].Name.equals("LowerCase"))
+ {
+ m_bLower = AnyConverter.toBoolean(lFilterProps[p].Value);
+ m_bCaseChange = true; // Set it after m_bLower - because an exception can occur and we must use default values then!
+ }
+ }
+ }
+ }
+ catch(com.sun.star.lang.IllegalArgumentException exConvert)
+ {
+ // ONE argument has the wrong type
+ // But I think we mustn't react here - because we set
+ // default values for every necessary item we need.
+ // In case this exception occurs - this default exist
+ // and we can live with it.
+ }
+ }
+
+ // Decide if it's necessary AND possible to open streams.
+ // Outside user can check for valid FilterOptions by using
+ // corresponding method isValid(). So it's not necessary to
+ // handle this error here in any case.
+ if (m_xInput==null && m_xOutput==null && m_sURL!=null)
+ impl_openStreams(bImport);
+ }
+
+ /**
+ * with this method it's possible for the outside filter to decide
+ * if he can use this FilterOptions really or not.
+ * That means especially if necessary streams are available or not.
+ */
+ public boolean isValid()
+ {
+ return(m_xInput!=null || m_xOutput!=null);
+ }
+
+
+ // helper
+ /**
+ * In case we couldn't found any valid stream inside the given MediaDescriptor,
+ * we must create it. Then we use a special helper service in combination
+ * with an existing URL to open a stream for reading or writing. It depends
+ * from given parameter bImport.
+ *
+ * Note: This method doesn't check for a valid URL. It must be done before.
+ *
+ * @param bImport
+ * indicates which stream member must be valid as result of this call
+ */
+ private void impl_openStreams( boolean bImport )
+ {
+ try{
+ com.sun.star.ucb.XSimpleFileAccess xHelper = UnoRuntime.queryInterface(
+ com.sun.star.ucb.XSimpleFileAccess.class,
+ m_xMCF.createInstanceWithContext("com.sun.star.ucb.SimpleFileAccess", m_Ctx));
+ if (xHelper!=null)
+ {
+ if (bImport)
+ m_xInput = xHelper.openFileRead(m_sURL);
+ else
+ m_xOutput = xHelper.openFileWrite(m_sURL);
+ }
+
+ m_bStreamOwner = (m_xInput!=null || m_xOutput!=null);
+ }
+ catch(com.sun.star.ucb.CommandAbortedException exAborted) {}
+ catch(com.sun.star.uno.Exception exUno ) {}
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/OfficeDev/FilterDevelopment/AsciiFilter/Makefile b/odk/examples/DevelopersGuide/OfficeDev/FilterDevelopment/AsciiFilter/Makefile
new file mode 100644
index 000000000..507f6cac4
--- /dev/null
+++ b/odk/examples/DevelopersGuide/OfficeDev/FilterDevelopment/AsciiFilter/Makefile
@@ -0,0 +1,139 @@
+#*************************************************************************
+#
+# The Contents of this file are made available subject to the terms of
+# the BSD license.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+# 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+# contributors may be used to endorse or promote products derived
+# from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+# TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+# USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+#**************************************************************************
+
+# Builds the OfficeDevFilter example of the Developers Guide.
+
+PRJ=../../../../..
+SETTINGS=$(PRJ)/settings
+
+include $(SETTINGS)/settings.mk
+include $(SETTINGS)/std.mk
+
+# Define non-platform/compiler specific settings
+SAMPLE_NAME=OfficeDevAsciiFilterExample
+SAMPLE_CLASS_OUT = $(OUT_CLASS)/$(SAMPLE_NAME)
+SAMPLE_GEN_OUT = $(OUT_MISC)/$(SAMPLE_NAME)
+
+COMP_NAME=SampleFilter
+COMP_CLASS_OUT=$(SAMPLE_CLASS_OUT)/$(COMP_NAME)
+COMP_PACKAGE = $(OUT_BIN)/$(COMP_NAME).$(UNOOXT_EXT)
+COMP_PACKAGE_URL = $(subst \\,\,"$(COMP_PACKAGE_DIR)$(PS)$(COMP_NAME).$(UNOOXT_EXT)")
+COMP_JAR_NAME = $(COMP_NAME).uno.jar
+COMP_JAR = $(SAMPLE_CLASS_OUT)/$(COMP_JAR_NAME)
+COMP_MANIFESTFILE = $(SAMPLE_GEN_OUT)/$(COMP_NAME).uno.Manifest
+COMP_UNOPKG_MANIFEST = $(SAMPLE_GEN_OUT)/$(COMP_NAME)/META-INF/manifest.xml
+COMP_REGISTERFLAG = $(SAMPLE_GEN_OUT)/devguide_$(COMP_NAME)_component.flag
+COMP_COMPONENTS=$(COMP_NAME).components
+
+# often the java files are structured in a hierarchy similar to the package,
+# for the example we know the package
+PACKAGE = OfficeDev/samples/Filter
+
+COMP_JAVAFILES = \
+ FilterOptions.java \
+ AsciiReplaceFilter.java
+
+COMP_CLASSFILES = $(patsubst %.java,$(COMP_CLASS_OUT)/$(PACKAGE)/%.class,$(COMP_JAVAFILES))
+
+SDK_CLASSPATH = $(subst $(EMPTYSTRING) $(PATH_SEPARATOR),$(PATH_SEPARATOR),$(CLASSPATH)\
+ $(PATH_SEPARATOR)$(COMP_CLASS_OUT))
+
+
+# Targets
+.PHONY: ALL
+ALL : $(SAMPLE_NAME)
+
+include $(SETTINGS)/stdtarget.mk
+
+$(SAMPLE_GEN_OUT)/%.Manifest :
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ @echo RegistrationClassName: $(subst /,.,$(PACKAGE)).AsciiReplaceFilter> $@
+
+$(COMP_CLASSFILES) : $(COMP_JAVAFILES)
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ $(SDK_JAVAC) $(JAVAC_FLAGS) -classpath "$(SDK_CLASSPATH)" -d $(COMP_CLASS_OUT) $(COMP_JAVAFILES)
+
+# rule for component jar file
+$(COMP_JAR) : $(COMP_MANIFESTFILE) $(COMP_CLASSFILES)
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ $(SDK_JAR) cvfm $@ $< -C $(COMP_CLASS_OUT) .
+
+# rule for component package manifest
+$(SAMPLE_GEN_OUT)/%/manifest.xml :
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ @echo $(OSEP)?xml version="$(QM)1.0$(QM)" encoding="$(QM)UTF-8$(QM)"?$(CSEP) > $@
+ @echo $(OSEP)!DOCTYPE manifest:manifest PUBLIC "$(QM)-//OpenOffice.org//DTD Manifest 1.0//EN$(QM)" "$(QM)Manifest.dtd$(QM)"$(CSEP) >> $@
+ @echo $(OSEP)manifest:manifest xmlns:manifest="$(QM)http://openoffice.org/2001/manifest$(QM)"$(CSEP) >> $@
+ @echo $(SQM) $(SQM)$(OSEP)manifest:file-entry manifest:media-type="$(QM)application/vnd.sun.star.configuration-data$(QM)" >> $@
+ @echo $(SQM) $(SQM)manifest:full-path="$(QM)TypeDetection.xcu$(QM)"/$(CSEP) >> $@
+ @echo $(SQM) $(SQM)$(OSEP)manifest:file-entry manifest:media-type="$(QM)application/vnd.sun.star.uno-components$(QM)">> $@
+ @echo $(SQM) $(SQM)manifest:full-path="$(QM)$(COMP_COMPONENTS)$(QM)"/$(CSEP)>> $@
+ @echo $(OSEP)/manifest:manifest$(CSEP) >> $@
+
+# rule for component package file
+$(COMP_PACKAGE) : $(COMP_JAR) TypeDetection.xcu $(COMP_UNOPKG_MANIFEST) $(COMP_COMPONENTS)
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ $(SDK_ZIP) $@ TypeDetection.xcu
+ $(SDK_ZIP) -u $@ $(COMP_COMPONENTS)
+ cd $(subst /,$(PS),$(SAMPLE_CLASS_OUT)) && $(SDK_ZIP) -u ../../bin/$(@F) $(<F)
+ cd $(subst /,$(PS),$(SAMPLE_GEN_OUT)/$(subst .$(UNOOXT_EXT),,$(@F))) && $(SDK_ZIP) -u ../../../bin/$(@F) META-INF/manifest.xml
+
+$(COMP_REGISTERFLAG) : $(COMP_PACKAGE)
+ifeq "$(SDK_AUTO_DEPLOYMENT)" "YES"
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ $(DEPLOYTOOL) $(COMP_PACKAGE_URL)
+ @echo flagged > $(subst /,$(PS),$@)
+else
+ @echo --------------------------------------------------------------------------------
+ @echo If you want to install your component automatically, please set the environment
+ @echo variable SDK_AUTO_DEPLOYMENT = YES. But note that auto deployment is only
+ @echo possible if no office instance is running.
+ @echo --------------------------------------------------------------------------------
+endif
+
+$(SAMPLE_NAME) : $(COMP_REGISTERFLAG)
+ @echo --------------------------------------------------------------------------------
+ @echo The "$(QM)$(COMP_NAME)$(QM)" Java component was installed if SDK_AUTO_DEPLOYMENT = YES.
+ @echo You can use the "$(QM)ASCII Replace$(QM)" filter in your office installation, see the
+ @echo example description.
+ @echo --------------------------------------------------------------------------------
+
+.PHONY: clean
+clean :
+ -$(DELRECURSIVE) $(subst /,$(PS),$(SAMPLE_CLASS_OUT))
+ -$(DELRECURSIVE) $(subst /,$(PS),$(SAMPLE_GEN_OUT))
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$(COMP_PACKAGE_URL)))
diff --git a/odk/examples/DevelopersGuide/OfficeDev/FilterDevelopment/AsciiFilter/SampleFilter.components b/odk/examples/DevelopersGuide/OfficeDev/FilterDevelopment/AsciiFilter/SampleFilter.components
new file mode 100644
index 000000000..6b2545df9
--- /dev/null
+++ b/odk/examples/DevelopersGuide/OfficeDev/FilterDevelopment/AsciiFilter/SampleFilter.components
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<components xmlns="http://openoffice.org/2010/uno-components">
+ <component loader="com.sun.star.loader.Java2" uri="SampleFilter.uno.jar">
+ <implementation name="FilterDevelopment.AsciiFilter.AsciiReplaceFilter$_AsciiReplaceFilter">
+ <service name="com.sun.star.comp.ansifilter.AsciiReplaceFilter"/>
+ <service name="com.sun.star.document.ImportFilter"/>
+ <service name="com.sun.star.document.ExportFilter"/>
+ </implementation>
+ </component>
+</components>
diff --git a/odk/examples/DevelopersGuide/OfficeDev/FilterDevelopment/AsciiFilter/TypeDetection.xcu b/odk/examples/DevelopersGuide/OfficeDev/FilterDevelopment/AsciiFilter/TypeDetection.xcu
new file mode 100644
index 000000000..c2eb32ef2
--- /dev/null
+++ b/odk/examples/DevelopersGuide/OfficeDev/FilterDevelopment/AsciiFilter/TypeDetection.xcu
@@ -0,0 +1,46 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+-->
+<oor:component-data xmlns:oor="http://openoffice.org/2001/registry" xmlns:xs="http://www.w3.org/2001/XMLSchema" oor:name="TypeDetection" oor:package="org.openoffice.Office">
+ <node oor:name="Types">
+ <node oor:name="ascii" oor:op="replace">
+ <prop oor:name="Data" oor:type="xs:string">
+ <value>0,text/plain,,,txt,0</value>
+ </prop>
+ <prop oor:name="UIName" oor:type="xs:string">
+ <value xml:lang="en-US">ASCII</value>
+ </prop>
+ </node>
+ </node>
+ <node oor:name="Filters">
+ <node oor:name="Ascii_Replace" oor:op="replace">
+ <prop oor:name="Data" oor:type="xs:string">
+ <value>0,ascii,com.sun.star.text.TextDocument,com.sun.star.comp.ansifilter.AsciiReplaceFilter,268959747,,0,,</value>
+ </prop>
+ <prop oor:name="Installed" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ <prop oor:name="UIName" oor:type="xs:string">
+ <!-- The x-no-translate entry is a marker to prevent l10n tooling from translation. If it is not necessary. -->
+ <value xml:lang="x-no-translate"></value>
+ <value xml:lang="en-US">ASCII Replace</value>
+ <value xml:lang="de">ASCII Konvertierung</value>
+ </prop>
+ </node>
+ </node>
+</oor:component-data>
diff --git a/odk/examples/DevelopersGuide/OfficeDev/FilterDevelopment/FlatXmlFilterDetection/FlatXmlTypeDetection.xcu b/odk/examples/DevelopersGuide/OfficeDev/FilterDevelopment/FlatXmlFilterDetection/FlatXmlTypeDetection.xcu
new file mode 100644
index 000000000..2ac9a2440
--- /dev/null
+++ b/odk/examples/DevelopersGuide/OfficeDev/FilterDevelopment/FlatXmlFilterDetection/FlatXmlTypeDetection.xcu
@@ -0,0 +1,88 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+-->
+<!DOCTYPE oor:component-data SYSTEM "../../../../component-update.dtd">
+<oor:component-data xmlns:oor="http://openoffice.org/2001/registry" xmlns:xs="http://www.w3.org/2001/XMLSchema" oor:package="org.openoffice.TypeDetection" oor:name="Types">
+ <node oor:name="Types">
+ <node oor:name="devguide_FlatXMLType_Cpp_calc" oor:op="replace">
+ <prop oor:name="UIOrder"><value>0</value></prop>
+ <prop oor:name="DetectService"><value>devguide.officedev.samples.filter.FlatXmlDetect</value></prop>
+ <prop oor:name="URLPattern"/>
+ <prop oor:name="Extensions"><value>fods</value></prop>
+ <prop oor:name="MediaType"/>
+ <prop oor:name="Preferred"><value>false</value></prop>
+ <prop oor:name="PreferredFilter"><value>devguide_FlatXMLFilter_Cpp_calc</value></prop>
+ <prop oor:name="UIName">
+ <value xml:lang="en-US">DevGuide FlatXML Calc</value>
+ </prop>
+ <prop oor:name="ClipboardFormat"><value>doctype:office:document</value></prop>
+ </node>
+ <node oor:name="devguide_FlatXMLType_Cpp_draw" oor:op="replace">
+ <prop oor:name="UIOrder"><value>0</value></prop>
+ <prop oor:name="DetectService"><value>devguide.officedev.samples.filter.FlatXmlDetect</value></prop>
+ <prop oor:name="URLPattern"/>
+ <prop oor:name="Extensions"><value>fodg</value></prop>
+ <prop oor:name="MediaType"/>
+ <prop oor:name="Preferred"><value>false</value></prop>
+ <prop oor:name="PreferredFilter"><value>devguide_FlatXMLFilter_Cpp_draw</value></prop>
+ <prop oor:name="UIName">
+ <value xml:lang="en-US">DevGuide FlatXML Draw</value>
+ </prop>
+ <prop oor:name="ClipboardFormat"><value>doctype:office:document</value></prop>
+ </node>
+ <node oor:name="devguide_FlatXMLType_Cpp_impress" oor:op="replace">
+ <prop oor:name="UIOrder"><value>0</value></prop>
+ <prop oor:name="DetectService"><value>devguide.officedev.samples.filter.FlatXmlDetect</value></prop>
+ <prop oor:name="URLPattern"/>
+ <prop oor:name="Extensions"><value>fodp</value></prop>
+ <prop oor:name="MediaType"/>
+ <prop oor:name="Preferred"><value>false</value></prop>
+ <prop oor:name="PreferredFilter"><value>devguide_FlatXMLFilter_Cpp_impress</value></prop>
+ <prop oor:name="UIName">
+ <value xml:lang="en-US">DevGuide FlatXML Impress</value>
+ </prop>
+ <prop oor:name="ClipboardFormat"><value>doctype:office:document</value></prop>
+ </node>
+ <node oor:name="devguide_FlatXMLType_Cpp_writer" oor:op="replace">
+ <prop oor:name="UIOrder"><value>0</value></prop>
+ <prop oor:name="DetectService"><value>devguide.officedev.samples.filter.FlatXmlDetect</value></prop>
+ <prop oor:name="URLPattern"/>
+ <prop oor:name="Extensions"><value>fodt</value></prop>
+ <prop oor:name="MediaType"/>
+ <prop oor:name="Preferred"><value>false</value></prop>
+ <prop oor:name="PreferredFilter"><value>devguide_FlatXMLFilter_Cpp_writer</value></prop>
+ <prop oor:name="UIName">
+ <value xml:lang="en-US">DevGuide FlatXML Writer</value>
+ </prop>
+ <prop oor:name="ClipboardFormat"><value>doctype:office:document</value></prop>
+ </node>
+ <node oor:name="devguide_FlatXMLType_Cpp_master" oor:op="replace">
+ <prop oor:name="UIOrder"><value>0</value></prop>
+ <prop oor:name="DetectService"><value>devguide.officedev.samples.filter.FlatXmlDetect</value></prop>
+ <prop oor:name="URLPattern"/>
+ <prop oor:name="Extensions"><value>fodm</value></prop>
+ <prop oor:name="MediaType"/>
+ <prop oor:name="Preferred"><value>false</value></prop>
+ <prop oor:name="PreferredFilter"><value>devguide_FlatXMLFilter_Cpp_master</value></prop>
+ <prop oor:name="UIName">
+ <value xml:lang="en-US">DevGuide FlatXML Master</value>
+ </prop>
+ <prop oor:name="ClipboardFormat"><value>doctype:office:document</value></prop>
+ </node>
+ </node>
+</oor:component-data>
diff --git a/odk/examples/DevelopersGuide/OfficeDev/FilterDevelopment/FlatXmlFilterDetection/Makefile b/odk/examples/DevelopersGuide/OfficeDev/FilterDevelopment/FlatXmlFilterDetection/Makefile
new file mode 100644
index 000000000..2a9e24186
--- /dev/null
+++ b/odk/examples/DevelopersGuide/OfficeDev/FilterDevelopment/FlatXmlFilterDetection/Makefile
@@ -0,0 +1,155 @@
+#*************************************************************************
+#
+# The Contents of this file are made available subject to the terms of
+# the BSD license.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+# 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+# contributors may be used to endorse or promote products derived
+# from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+# TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+# USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+#**************************************************************************
+
+# Builds the filterdetection component for the FlatXmlFilter of the Developers Guide.
+
+PRJ=../../../../..
+SETTINGS=$(PRJ)/settings
+
+include $(SETTINGS)/settings.mk
+include $(SETTINGS)/std.mk
+
+# Define non-platform/compiler specific settings
+COMP_NAME=FlatXmlTypeDetection
+COMP_IMPL_NAME=$(COMP_NAME).uno.$(SHAREDLIB_EXT)
+OUT_COMP_INC = $(OUT_INC)/$(COMP_NAME)
+OUT_COMP_GEN = $(OUT_MISC)/$(COMP_NAME)
+OUT_COMP_SLO=$(OUT_SLO)/$(COMP_NAME)
+COMP_RDB_NAME = $(COMP_NAME).uno.rdb
+COMP_RDB = $(OUT_COMP_GEN)/$(COMP_RDB_NAME)
+COMP_PACKAGE = $(OUT_BIN)/$(COMP_NAME).$(UNOOXT_EXT)
+COMP_PACKAGE_URL = $(subst \\,\,"$(COMP_PACKAGE_DIR)$(PS)$(COMP_NAME).$(UNOOXT_EXT)")
+COMP_UNOPKG_MANIFEST = $(OUT_COMP_GEN)/$(COMP_NAME)/META-INF/manifest.xml
+COMP_COMPONENTS = $(OUT_COMP_GEN)/$(COMP_NAME).components
+
+REGISTERFLAG = $(OUT_MISC)/devguide_$(COMP_NAME)_register_component.flag
+
+CXXFILES = filterdetect.cxx \
+ fdcomp.cxx
+
+SLOFILES = $(patsubst %.cxx,$(OUT_COMP_SLO)/%.$(OBJ_EXT),$(CXXFILES))
+
+# Targets
+.PHONY: ALL
+ALL : \
+ XMLFilterDetect
+
+include $(SETTINGS)/stdtarget.mk
+
+$(OUT_COMP_SLO)/%.$(OBJ_EXT) : %.cxx $(SDKTYPEFLAG)
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ $(CC) $(CC_FLAGS) $(CC_INCLUDES) -I$(OUT_COMP_INC) $(CC_DEFINES) $(CC_OUTPUT_SWITCH)$(subst /,$(PS),$@) $<
+
+ifeq "$(OS)" "WIN"
+$(SHAREDLIB_OUT)/%.$(SHAREDLIB_EXT) : $(SLOFILES)
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ -$(MKDIR) $(subst /,$(PS),$(OUT_COMP_GEN))
+ $(LINK) $(COMP_LINK_FLAGS) /OUT:$@ \
+ /MAP:$(OUT_COMP_GEN)/$(subst $(SHAREDLIB_EXT),map,$(@F)) $(SLOFILES) \
+ $(CPPUHELPERLIB) $(CPPULIB) $(SALLIB) msvcprt.lib $(LIBO_SDK_LDFLAGS_STDLIBS)
+ $(LINK_MANIFEST)
+else
+$(SHAREDLIB_OUT)/%.$(SHAREDLIB_EXT) : $(SLOFILES)
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ $(LINK) $(COMP_LINK_FLAGS) $(LINK_LIBS) -o $@ $(SLOFILES) \
+ $(CPPUHELPERLIB) $(CPPULIB) $(SALLIB) $(STC++LIB)
+ifeq "$(OS)" "MACOSX"
+ $(INSTALL_NAME_URELIBS) $@
+endif
+endif
+
+# rule for component package manifest
+$(OUT_COMP_GEN)/%/manifest.xml :
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ @echo $(OSEP)?xml version="$(QM)1.0$(QM)" encoding="$(QM)UTF-8$(QM)"?$(CSEP) > $@
+ @echo $(OSEP)!DOCTYPE manifest:manifest PUBLIC "$(QM)-//OpenOffice.org//DTD Manifest 1.0//EN$(QM)" "$(QM)Manifest.dtd$(QM)"$(CSEP) >> $@
+ @echo $(OSEP)manifest:manifest xmlns:manifest="$(QM)http://openoffice.org/2001/manifest$(QM)"$(CSEP) >> $@
+ @echo $(SQM) $(SQM)$(OSEP)manifest:file-entry manifest:media-type="$(QM)application/vnd.sun.star.configuration-data$(QM)" >> $@
+ @echo $(SQM) $(SQM)manifest:full-path="$(QM)FlatXmlTypeDetection.xcu$(QM)"/$(CSEP) >> $@
+ @echo $(SQM) $(SQM)$(OSEP)manifest:file-entry manifest:media-type="$(QM)application/vnd.sun.star.uno-components;platform=$(UNOPKG_PLATFORM)$(QM)">> $@
+ @echo $(SQM) $(SQM)manifest:full-path="$(QM)$(COMP_NAME).components$(QM)"/$(CSEP)>> $@
+ @echo $(OSEP)/manifest:manifest$(CSEP) >> $@
+
+$(COMP_COMPONENTS) :
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ @echo $(OSEP)?xml version="$(QM)1.0$(QM)" encoding="$(QM)UTF-8$(QM)"?$(CSEP) > $@
+ @echo $(OSEP)components xmlns="$(QM)http://openoffice.org/2010/uno-components$(QM)"$(CSEP) >> $@
+ @echo $(SQM) $(SQM)$(OSEP)component loader="$(QM)com.sun.star.loader.SharedLibrary$(QM)" uri="$(QM)$(UNOPKG_PLATFORM)/$(COMP_IMPL_NAME)$(QM)"$(CSEP) >> $@
+ @echo $(SQM) $(SQM)$(OSEP)implementation name="$(QM)devguide.officedev.samples.filter.FlatXmlDetect$(QM)"$(CSEP) >> $@
+ @echo $(SQM) $(SQM)$(OSEP)service name="$(QM)com.sun.star.document.ExtendedTypeDetection$(QM)"/$(CSEP) >> $@
+ @echo $(SQM) $(SQM)$(OSEP)/implementation$(CSEP) >> $@
+ @echo $(SQM) $(SQM)$(OSEP)/component$(CSEP) >> $@
+ @echo $(OSEP)/components$(CSEP) >> $@
+
+# rule for component package file
+$(COMP_PACKAGE) : $(SHAREDLIB_OUT)/$(COMP_IMPL_NAME) FlatXmlTypeDetection.xcu $(COMP_UNOPKG_MANIFEST) $(COMP_COMPONENTS)
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ -$(MKDIR) $(subst /,$(PS),$(OUT_COMP_GEN)/$(UNOPKG_PLATFORM))
+ $(COPY) $(subst /,$(PS),$<) $(subst /,$(PS),$(OUT_COMP_GEN)/$(UNOPKG_PLATFORM))
+ $(SDK_ZIP) $@ FlatXmlTypeDetection.xcu
+ cd $(subst /,$(PS),$(OUT_COMP_GEN)) && $(SDK_ZIP) -u ../../bin/$(@F) $(COMP_NAME).components
+ cd $(subst /,$(PS),$(OUT_COMP_GEN)) && $(SDK_ZIP) -u ../../bin/$(@F) $(UNOPKG_PLATFORM)/$(<F)
+ cd $(subst /,$(PS),$(OUT_COMP_GEN)/$(subst .$(UNOOXT_EXT),,$(@F))) && $(SDK_ZIP) -u ../../../bin/$(@F) META-INF/manifest.xml
+
+$(REGISTERFLAG) : $(COMP_PACKAGE)
+ifeq "$(SDK_AUTO_DEPLOYMENT)" "YES"
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ $(DEPLOYTOOL) $(COMP_PACKAGE_URL)
+ @echo flagged > $(subst /,$(PS),$@)
+else
+ @echo --------------------------------------------------------------------------------
+ @echo If you want to install your component automatically, please set the environment
+ @echo variable SDK_AUTO_DEPLOYMENT = YES. But note that auto deployment is only
+ @echo possible if no office instance is running.
+ @echo --------------------------------------------------------------------------------
+endif
+
+XMLFilterDetect : $(REGISTERFLAG)
+ @echo --------------------------------------------------------------------------------
+ @echo The FlatXMLFilterDetection component is installed if SDK_AUTO_DEPLOYMENT = YES.
+ @echo You will use this component implicitly in your office installation when you have
+ @echo installed a FlatXMLFilter component C++ or Java.
+ @echo --------------------------------------------------------------------------------
+
+.PHONY: clean
+clean :
+ -$(DELRECURSIVE) $(subst /,$(PS),$(OUT_COMP_INC))
+ -$(DELRECURSIVE) $(subst /,$(PS),$(OUT_COMP_GEN))
+ -$(DELRECURSIVE) $(subst /,$(PS),$(OUT_COMP_SLO))
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$(COMP_PACKAGE_URL)))
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$(COMP_COMPONENTS))
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$(REGISTERFLAG)))
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$(SHAREDLIB_OUT)/$(COMP_NAME).*))
diff --git a/odk/examples/DevelopersGuide/OfficeDev/FilterDevelopment/FlatXmlFilterDetection/fdcomp.cxx b/odk/examples/DevelopersGuide/OfficeDev/FilterDevelopment/FlatXmlFilterDetection/fdcomp.cxx
new file mode 100644
index 000000000..37b7a9360
--- /dev/null
+++ b/odk/examples/DevelopersGuide/OfficeDev/FilterDevelopment/FlatXmlFilterDetection/fdcomp.cxx
@@ -0,0 +1,84 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+#include <stdio.h>
+
+#include <osl/mutex.hxx>
+#include <osl/thread.h>
+#include <uno/lbnames.h>
+#include <cppuhelper/factory.hxx>
+#include <com/sun/star/lang/XSingleComponentFactory.hpp>
+
+#include "filterdetect.hxx"
+
+using namespace ::rtl;
+using namespace ::cppu;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::registry;
+
+extern "C"
+{
+SAL_DLLPUBLIC_EXPORT void * SAL_CALL component_getFactory(
+ const char * pImplName, void * pServiceManager, void * pRegistryKey )
+{
+ void * pRet = 0;
+
+ OUString implName = OUString::createFromAscii( pImplName );
+ if ( pServiceManager && implName.equals(FilterDetect_getImplementationName()) )
+ {
+ Reference< XSingleComponentFactory > xFactory( createSingleComponentFactory(
+ FilterDetect_createInstance,
+ OUString::createFromAscii( pImplName ),
+ FilterDetect_getSupportedServiceNames() ) );
+
+ if (xFactory.is())
+ {
+ xFactory->acquire();
+ pRet = xFactory.get();
+ }
+ }
+ return pRet;
+}
+
+SAL_DLLPUBLIC_EXPORT void SAL_CALL component_getImplementationEnvironment(
+ char const ** ppEnvTypeName, uno_Environment **)
+{
+ *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
+}
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/OfficeDev/FilterDevelopment/FlatXmlFilterDetection/filterdetect.cxx b/odk/examples/DevelopersGuide/OfficeDev/FilterDevelopment/FlatXmlFilterDetection/filterdetect.cxx
new file mode 100644
index 000000000..f51e29941
--- /dev/null
+++ b/odk/examples/DevelopersGuide/OfficeDev/FilterDevelopment/FlatXmlFilterDetection/filterdetect.cxx
@@ -0,0 +1,239 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+#include "filterdetect.hxx"
+#include <com/sun/star/io/XActiveDataSource.hpp>
+#include <com/sun/star/io/XOutputStream.hpp>
+#include <com/sun/star/io/XInputStream.hpp>
+#include <com/sun/star/io/XSeekable.hpp>
+#include <com/sun/star/xml/sax/XDocumentHandler.hpp>
+#include <com/sun/star/xml/sax/InputSource.hpp>
+#include <com/sun/star/xml/sax/XParser.hpp>
+#include <com/sun/star/xml/XImportFilter.hpp>
+#include <com/sun/star/xml/XExportFilter.hpp>
+#include <com/sun/star/frame/XModel.hpp>
+#include <com/sun/star/frame/XController.hpp>
+#include <com/sun/star/task/XStatusIndicator.hpp>
+#include <com/sun/star/task/XStatusIndicatorFactory.hpp>
+#include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
+#include <com/sun/star/style/XStyleLoader.hpp>
+#include <com/sun/star/document/XExtendedFilterDetection.hpp>
+#include <com/sun/star/beans/PropertyState.hpp>
+#include <com/sun/star/ucb/SimpleFileAccess.hpp>
+#include <com/sun/star/uno/XComponentContext.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <cppuhelper/supportsservice.hxx>
+
+using namespace com::sun::star::uno;
+using namespace com::sun::star::document;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::io;
+using namespace com::sun::star::beans;
+using namespace com::sun::star::xml::sax;
+using namespace com::sun::star::xml;
+using namespace com::sun::star::task;
+using namespace com::sun::star::frame;
+using namespace com::sun::star::container;
+using namespace com::sun::star::ucb;
+
+using ::rtl::OUString;
+using ::rtl::OString;
+
+
+OUString SAL_CALL FilterDetect::detect(Sequence< PropertyValue >& aArguments )
+{
+ // type name to return
+ OUString sOriginalTypeName;
+ OUString sTypeName;
+ OUString sURL;
+ // stream of the document to be detected
+ Reference< XInputStream > xInStream;
+ for ( sal_Int32 i = 0 ; i < aArguments.getLength(); i++)
+ {
+ OUString aName = aArguments[i].Name;
+ if ( aName == "TypeName" )
+ aArguments[i].Value >>= sOriginalTypeName;
+ if ( aName == "URL" )
+ aArguments[i].Value >>= sURL;
+ if ( aName == "InputStream" )
+ aArguments[i].Value >>= xInStream;
+ }
+
+ if (!xInStream.is())
+ {
+ // open the stream if it was not supplied by the framework
+ Reference< XSimpleFileAccess3 > xSFI(SimpleFileAccess::create(mxContext));
+ if (sURL.getLength() > 0)
+ {
+ try
+ {
+ xInStream = xSFI->openFileRead( sURL);
+ }
+ catch( Exception& )
+ {
+ return sTypeName;
+ }
+ } else {
+ // failed to access UCB
+ return sTypeName;
+ }
+ }
+
+ // flatxml starts with an office:document element. this element
+ // contains a class="..." attribute by which we can deduct the
+ // type of document that is to be loaded
+
+ // WARNING:
+ // parsing the plain text of the document is an easy way to do this
+ // but not the purest solution, since namespaces and other xml details
+ // may lead to another syntactic expression of the same document.
+ // this example works for the way the office serializes its XML stream
+ // but might need extension for other data sources...
+ static OString aDocToken("office:document");
+ // static OString aClassToken("office:class=\"");
+ static OString aMimeTypeToken("office:mimetype=\"");
+
+ sal_Int32 nHeadSize = 4096;
+ Sequence< sal_Int8 > aHeadData(nHeadSize);
+
+ // rewind seekable stream
+ Reference< XSeekable > xSeek(xInStream, UNO_QUERY);
+ if (xSeek.is())
+ xSeek->seek(0);
+
+ long bytestRead = xInStream->readBytes(aHeadData, nHeadSize);
+
+ OString aHead = OString((const char *)aHeadData.getConstArray(), bytestRead).toAsciiLowerCase();
+
+ // check for document element of flatxml format
+ if (aHead.indexOf(aDocToken) >= 0)
+ {
+ // read document class
+ sal_Int32 n = aHead.indexOf(aMimeTypeToken);
+ if (n >= 0)
+ {
+ n += aMimeTypeToken.getLength();
+ OString aMimeType = aHead.copy(n, aHead.indexOf('\"', n) - n);
+ // return type for class found
+ if (aMimeType.equals("application/x-vnd.oasis.opendocument.text") ||
+ aMimeType.equals("application/vnd.oasis.opendocument.text"))
+ sTypeName = "devguide_FlatXMLType_Cpp_writer";
+ else if (aMimeType.equals("application/x-vnd.oasis.opendocument.text-master") ||
+ aMimeType.equals("application/vnd.oasis.opendocument.text-master"))
+ sTypeName = "devguide_FlatXMLType_Cpp_master";
+ else if (aMimeType.equals("application/x-vnd.oasis.openoffice.text-global") ||
+ aMimeType.equals("application/vnd.oasis.openoffice.text-global"))
+ sTypeName = "devguide_FlatXMLType_Cpp_master";
+ else if (aMimeType.equals("application/x-vnd.oasis.opendocument.spreadsheet") ||
+ aMimeType.equals("application/vnd.oasis.opendocument.spreadsheet"))
+ sTypeName = "devguide_FlatXMLType_Cpp_calc";
+ else if (aMimeType.equals("application/x-vnd.oasis.opendocument.drawing") ||
+ aMimeType.equals("application/vnd.oasis.opendocument.drawing"))
+ sTypeName = "devguide_FlatXMLType_Cpp_draw";
+ else if (aMimeType.equals("application/x-vnd.oasis.opendocument.presentation") ||
+ aMimeType.equals("application/vnd.oasis.opendocument.presentation"))
+ sTypeName = "devguide_FlatXMLType_Cpp_impress";
+ }
+ }
+ return sTypeName;
+}
+
+
+// XInitialization
+void SAL_CALL FilterDetect::initialize( const Sequence< Any >& aArguments )
+{
+ Sequence < PropertyValue > aAnySeq;
+ sal_Int32 nLength = aArguments.getLength();
+ if ( nLength && ( aArguments[0] >>= aAnySeq ) )
+ {
+ const PropertyValue * pValue = aAnySeq.getConstArray();
+ nLength = aAnySeq.getLength();
+ for ( sal_Int32 i = 0 ; i < nLength; i++)
+ {
+ if ( pValue[i].Name == "Type" )
+ {
+ pValue[i].Value >>= msFilterName;
+ }
+ else if ( pValue[i].Name == "UserData" )
+ {
+ pValue[i].Value >>= msUserData;
+ }
+ else if ( pValue[i].Name == "TemplateName" )
+ {
+ pValue[i].Value>>=msTemplateName;
+ }
+ }
+ }
+}
+
+OUString FilterDetect_getImplementationName ()
+{
+ return OUString( "devguide.officedev.samples.filter.FlatXmlDetect" );
+}
+
+#define SERVICE_NAME1 "com.sun.star.document.ExtendedTypeDetection"
+
+Sequence< OUString > SAL_CALL FilterDetect_getSupportedServiceNames( )
+{
+ Sequence < OUString > aRet(2);
+ OUString* pArray = aRet.getArray();
+ pArray[0] = OUString ( SERVICE_NAME1 );
+ return aRet;
+}
+#undef SERVICE_NAME1
+#undef SERVICE_NAME2
+
+Reference< XInterface > SAL_CALL FilterDetect_createInstance( const Reference< XComponentContext > & rContext)
+{
+ return (cppu::OWeakObject*) new FilterDetect( rContext );
+}
+
+// XServiceInfo
+OUString SAL_CALL FilterDetect::getImplementationName( )
+{
+ return FilterDetect_getImplementationName();
+}
+
+sal_Bool SAL_CALL FilterDetect::supportsService( const OUString& rServiceName )
+{
+ return cppu::supportsService(this, rServiceName);
+}
+
+Sequence< OUString > SAL_CALL FilterDetect::getSupportedServiceNames( )
+{
+ return FilterDetect_getSupportedServiceNames();
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/OfficeDev/FilterDevelopment/FlatXmlFilterDetection/filterdetect.hxx b/odk/examples/DevelopersGuide/OfficeDev/FilterDevelopment/FlatXmlFilterDetection/filterdetect.hxx
new file mode 100644
index 000000000..cf17157e7
--- /dev/null
+++ b/odk/examples/DevelopersGuide/OfficeDev/FilterDevelopment/FlatXmlFilterDetection/filterdetect.hxx
@@ -0,0 +1,111 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+#ifndef INCLUDED_EXAMPLES_OFFICEDEV_FILTERDEVELOPMENT_FLATXMLFILTERDETECTION_FILTERDETECT_HXX
+#define INCLUDED_EXAMPLES_OFFICEDEV_FILTERDEVELOPMENT_FLATXMLFILTERDETECTION_FILTERDETECT_HXX
+
+
+#include <com/sun/star/document/XFilter.hpp>
+#include <com/sun/star/document/XExporter.hpp>
+#include <com/sun/star/document/XExtendedFilterDetection.hpp>
+#include <com/sun/star/document/XImporter.hpp>
+#include <com/sun/star/lang/XInitialization.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <cppuhelper/implbase5.hxx>
+
+#include <cppuhelper/implbase3.hxx>
+
+namespace com { namespace sun { namespace star { namespace uno {
+ class XComponentContext;
+} } } }
+
+enum FilterType
+{
+ FILTER_IMPORT,
+ FILTER_EXPORT
+};
+
+/* This component will be instantiated for both import or export. Whether it calls
+ * setSourceDocument or setTargetDocument determines which Impl function the filter
+ * member calls */
+class FilterDetect : public cppu::WeakImplHelper3 <com::sun::star::document::XExtendedFilterDetection,
+ com::sun::star::lang::XInitialization,
+ com::sun::star::lang::XServiceInfo>
+{
+protected:
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > mxContext;
+ ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent > mxDoc;
+ ::rtl::OUString msFilterName;
+ ::com::sun::star::uno::Sequence< ::rtl::OUString > msUserData;
+ ::rtl::OUString msTemplateName;
+
+ sal_Bool SAL_CALL exportImpl( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& aDescriptor );
+
+ sal_Bool SAL_CALL importImpl( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& aDescriptor );
+
+public:
+ FilterDetect( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > &rxContext)
+ : mxContext( rxContext ) {}
+
+ virtual ~FilterDetect() {}
+
+ //XExtendedFilterDetection
+ virtual ::rtl::OUString SAL_CALL detect( com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue >& lDescriptor );
+
+ // XInitialization
+
+ virtual void SAL_CALL initialize( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments );
+
+ // XServiceInfo
+ virtual ::rtl::OUString SAL_CALL getImplementationName( );
+
+ virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName );
+
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( );
+};
+
+
+::rtl::OUString FilterDetect_getImplementationName();
+
+sal_Bool SAL_CALL FilterDetect_supportsService( const ::rtl::OUString& ServiceName );
+
+::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL FilterDetect_getSupportedServiceNames( );
+
+::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >
+SAL_CALL FilterDetect_createInstance( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > & rContext);
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/OfficeDev/FilterDevelopment/FlatXmlFilter_cpp/FlatXml.cxx b/odk/examples/DevelopersGuide/OfficeDev/FilterDevelopment/FlatXmlFilter_cpp/FlatXml.cxx
new file mode 100644
index 000000000..8b53c0ad7
--- /dev/null
+++ b/odk/examples/DevelopersGuide/OfficeDev/FilterDevelopment/FlatXmlFilter_cpp/FlatXml.cxx
@@ -0,0 +1,331 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+#include <cppuhelper/factory.hxx>
+#include <cppuhelper/implbase1.hxx>
+#include <cppuhelper/implbase2.hxx>
+#include <cppuhelper/implbase3.hxx>
+#include <osl/diagnose.h>
+#include <uno/lbnames.h>
+
+#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/beans/PropertyValue.hpp>
+
+#include <com/sun/star/xml/sax/XParser.hpp>
+#include <com/sun/star/xml/sax/InputSource.hpp>
+#include <com/sun/star/xml/sax/XDocumentHandler.hpp>
+#include <com/sun/star/xml/sax/XExtendedDocumentHandler.hpp>
+#include <com/sun/star/xml/sax/SAXException.hpp>
+#include <com/sun/star/xml/XImportFilter.hpp>
+#include <com/sun/star/xml/XExportFilter.hpp>
+
+#include <com/sun/star/io/XInputStream.hpp>
+#include <com/sun/star/io/XOutputStream.hpp>
+#include <com/sun/star/io/XActiveDataSource.hpp>
+#include <com/sun/star/io/XSeekable.hpp>
+
+using namespace ::rtl;
+using namespace ::cppu;
+using namespace ::osl;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::io;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::registry;
+using namespace ::com::sun::star::xml;
+using namespace ::com::sun::star::xml::sax;
+
+namespace XFlatXml {
+
+class XFlatXml : public WeakImplHelper3< XImportFilter, XExportFilter, XDocumentHandler>
+{
+private:
+ // the UNO ServiceFactory
+ Reference< XMultiServiceFactory > m_rServiceFactory;
+
+ // DocumentHandler interface of the css::xml::sax::Writer service
+ Reference < XExtendedDocumentHandler > m_rDocumentHandler;
+
+ // controls pretty-printing
+ sal_Bool m_bPrettyPrint;
+
+public:
+
+ // ctor...
+ XFlatXml( const Reference< XMultiServiceFactory > &r )
+ : m_rServiceFactory(r)
+ , m_bPrettyPrint(sal_True)
+ {}
+
+ // XImportFilter
+ virtual sal_Bool SAL_CALL importer(
+ const Sequence<PropertyValue>& aSourceData,
+ const Reference<XDocumentHandler>& xHandler,
+ const Sequence<OUString>& msUserData);
+
+ // XExportFilter
+ virtual sal_Bool SAL_CALL exporter(
+ const Sequence<PropertyValue>& aSourceData,
+ const Sequence<OUString>& msUserData);
+
+ // XDocumentHandler
+ virtual void SAL_CALL startDocument();
+ virtual void SAL_CALL endDocument();
+ virtual void SAL_CALL startElement(const OUString& str, const Reference<XAttributeList>& attriblist);
+ virtual void SAL_CALL endElement(const OUString& str);
+ virtual void SAL_CALL characters(const OUString& str);
+ virtual void SAL_CALL ignorableWhitespace(const OUString& str);
+ virtual void SAL_CALL processingInstruction(const OUString& str, const OUString& str2);
+ virtual void SAL_CALL setDocumentLocator(const Reference<XLocator>& doclocator);
+};
+
+sal_Bool XFlatXml::importer(
+ const Sequence<PropertyValue>& aSourceData,
+ const Reference<XDocumentHandler>& xHandler,
+ const Sequence<OUString>& msUserData)
+{
+ // get information from media descriptor
+ // the input stream that represents the imported file
+ // is most important here since we need to supply it to
+ // the sax parser that drives the supplied document handler
+ sal_Int32 nLength = aSourceData.getLength();
+ OUString aName, aFileName, aURL;
+ Reference< XInputStream > xInputStream;
+ for ( sal_Int32 i = 0 ; i < nLength; i++)
+ {
+ aName = aSourceData[i].Name;
+ if ( aName == "InputStream" )
+ aSourceData[i].Value >>= xInputStream;
+ else if ( aName == "FileName" )
+ aSourceData[i].Value >>= aFileName;
+ else if ( aName == "URL" )
+ aSourceData[i].Value >>= aURL;
+ }
+
+ // we need an input stream
+ OSL_ASSERT(xInputStream.is());
+ if (!xInputStream.is()) return sal_False;
+
+ // rewind seekable stream
+ Reference< XSeekable > xSeek(xInputStream, UNO_QUERY);
+ if (xSeek.is())
+ xSeek->seek(0);
+
+
+ // create SAX parser that will read the document file
+ // and provide events to xHandler passed to this call
+ Reference < XParser > xSaxParser( m_rServiceFactory->createInstance(
+ "com.sun.star.xml.sax.Parser"), UNO_QUERY );
+ OSL_ASSERT(xSaxParser.is());
+ if(!xSaxParser.is())return sal_False;
+
+ // let the parser try to send the sax event to the document handler
+ try
+ {
+ InputSource aInput;
+ aInput.sSystemId = aURL;
+ aInput.sPublicId = aURL;
+ aInput.aInputStream = xInputStream;
+ xSaxParser->setDocumentHandler(xHandler);
+ xSaxParser->parseStream(aInput);
+ }
+ catch( Exception &exc)
+ {
+ // something went wrong
+ OSL_FAIL(rtl::OUStringToOString(exc.Message,RTL_TEXTENCODING_UTF8).getStr());
+ return sal_False;
+ }
+
+ // done
+ return sal_True;
+}
+
+sal_Bool XFlatXml::exporter(
+ const Sequence<PropertyValue>& aSourceData,
+ const Sequence<OUString>& msUserData)
+{
+
+ // read source data
+ // we are especially interested in the output stream
+ // since that is where our xml-writer will push the data
+ // from its data-source interface
+ OUString aName, sURL;
+ Reference<XOutputStream> rOutputStream;
+ sal_Int32 nLength = aSourceData.getLength();
+ for ( sal_Int32 i = 0 ; i < nLength; i++)
+ {
+ aName = aSourceData[i].Name;
+ if ( aName == "OutputStream" )
+ aSourceData[i].Value >>= rOutputStream;
+ else if ( aName == "URL" )
+ aSourceData[i].Value >>= sURL;
+ }
+
+ if (!m_rDocumentHandler.is()) {
+ // get the document writer
+ m_rDocumentHandler = Reference<XExtendedDocumentHandler>(
+ m_rServiceFactory->createInstance("com.sun.star.xml.sax.Writer"),
+ UNO_QUERY);
+ OSL_ASSERT(m_rDocumentHandler.is());
+ if (!m_rDocumentHandler.is()) return sal_False;
+ }
+ // get data source interface ...
+ Reference< XActiveDataSource > rDataSource(m_rDocumentHandler, UNO_QUERY);
+ OSL_ASSERT(rDataSource.is());
+ if (!rDataSource.is()) return sal_False;
+ OSL_ASSERT(rOutputStream.is());
+ if (!rOutputStream.is()) return sal_False;
+ // ... and set output stream
+ rDataSource->setOutputStream(rOutputStream);
+
+ return sal_True;
+}
+
+// for the DocumentHandler implementation, we just proxy the
+// events to the XML writer that we created upon the output stream
+// that was provided by the XMLFilterAdapter
+void XFlatXml::startDocument(){
+ OSL_ASSERT(m_rDocumentHandler.is());
+ m_rDocumentHandler->startDocument();
+}
+
+void XFlatXml::endDocument(){
+ OSL_ASSERT(m_rDocumentHandler.is());
+ m_rDocumentHandler->endDocument();
+}
+
+void XFlatXml::startElement(const OUString& str, const Reference<XAttributeList>& attriblist)
+{
+ OSL_ASSERT(m_rDocumentHandler.is());
+ m_rDocumentHandler->startElement(str, attriblist);
+}
+
+void XFlatXml::endElement(const OUString& str)
+{
+ OSL_ASSERT(m_rDocumentHandler.is());
+ m_rDocumentHandler->endElement(str);
+}
+
+void XFlatXml::characters(const OUString& str)
+{
+ OSL_ASSERT(m_rDocumentHandler.is());
+ m_rDocumentHandler->characters(str);
+}
+
+void XFlatXml::ignorableWhitespace(const OUString& str)
+{
+ OSL_ASSERT(m_rDocumentHandler.is());
+ if (!m_bPrettyPrint) return;
+ m_rDocumentHandler->ignorableWhitespace(str);
+}
+
+void XFlatXml::processingInstruction(const OUString& str, const OUString& str2)
+{
+ OSL_ASSERT(m_rDocumentHandler.is());
+ m_rDocumentHandler->processingInstruction(str, str2);
+}
+
+void XFlatXml::setDocumentLocator(const Reference<XLocator>& doclocator)
+{
+ OSL_ASSERT(m_rDocumentHandler.is());
+ m_rDocumentHandler->setDocumentLocator(doclocator);
+}
+
+
+// Component management
+
+Reference< XInterface > SAL_CALL CreateInstance( const Reference< XMultiServiceFactory > &r)
+{
+ return Reference< XInterface >(( OWeakObject *)new XFlatXml(r));
+}
+
+Sequence< OUString > getSupportedServiceNames()
+{
+ static Sequence < OUString > *pNames = 0;
+ if( ! pNames )
+ {
+ MutexGuard guard( Mutex::getGlobalMutex() );
+ if( !pNames )
+ {
+ static Sequence< OUString > seqNames(1);
+ seqNames.getArray()[0] = OUString(
+ "devguide.officedev.samples.filter.FlatXmlCpp");
+ pNames = &seqNames;
+ }
+ }
+ return *pNames;
+}
+
+}
+
+using namespace XFlatXml;
+#define IMPLEMENTATION_NAME "devguide.officedev.samples.filter.FlatXmlCpp"
+
+
+extern "C"
+{
+SAL_DLLPUBLIC_EXPORT void * SAL_CALL component_getFactory(
+ const char * pImplName, void * pServiceManager, void * pRegistryKey )
+{
+ void * pRet = 0;
+
+ if (pServiceManager && rtl_str_compare( pImplName, IMPLEMENTATION_NAME ) == 0)
+ {
+ Reference< XSingleServiceFactory > xFactory( createSingleFactory(
+ reinterpret_cast< XMultiServiceFactory * >( pServiceManager ),
+ OUString::createFromAscii( pImplName ),
+ CreateInstance, getSupportedServiceNames() ) );
+
+ if (xFactory.is())
+ {
+ xFactory->acquire();
+ pRet = xFactory.get();
+ }
+ }
+ return pRet;
+}
+
+SAL_DLLPUBLIC_EXPORT void SAL_CALL component_getImplementationEnvironment(
+ char const ** ppEnvTypeName, uno_Environment **)
+{
+ *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
+}
+
+} // extern "C"
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/OfficeDev/FilterDevelopment/FlatXmlFilter_cpp/FlatXmlFilter_cpp.xcu b/odk/examples/DevelopersGuide/OfficeDev/FilterDevelopment/FlatXmlFilter_cpp/FlatXmlFilter_cpp.xcu
new file mode 100644
index 000000000..7113a16e1
--- /dev/null
+++ b/odk/examples/DevelopersGuide/OfficeDev/FilterDevelopment/FlatXmlFilter_cpp/FlatXmlFilter_cpp.xcu
@@ -0,0 +1,103 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+-->
+<!DOCTYPE oor:component-data SYSTEM "../../../../component-update.dtd">
+<oor:component-data xmlns:oor="http://openoffice.org/2001/registry" xmlns:xs="http://www.w3.org/2001/XMLSchema" oor:package="org.openoffice.TypeDetection" oor:name="Filter">
+ <node oor:name="Filters">
+ <node oor:name="devguide_FlatXMLFilter_Cpp_calc" oor:op="replace">
+ <prop oor:name="FileFormatVersion"><value>0</value></prop>
+ <prop oor:name="Type"><value>devguide_FlatXMLType_Cpp_calc</value></prop>
+ <prop oor:name="DocumentService"><value>com.sun.star.sheet.SpreadsheetDocument</value></prop>
+ <prop oor:name="UIComponent"/>
+ <prop oor:name="UserData"><value oor:separator=",">devguide.officedev.samples.filter.FlatXmlCpp, ,com.sun.star.comp.Calc.XMLOasisImporter,com.sun.star.comp.Calc.XMLOasisExporter</value></prop>
+ <prop oor:name="FilterService"><value>com.sun.star.comp.Writer.XmlFilterAdaptor</value></prop>
+ <prop oor:name="TemplateName"/>
+ <prop oor:name="UIName">
+ <!-- The x-no-translate entry is a marker to prevent l10n tooling from translation. If it is not necessary. -->
+ <value xml:lang="x-no-translate"></value>
+ <value xml:lang="de">DevGuide FlatXML Calc</value>
+ <value xml:lang="en-US">DevGuide FlatXML Calc</value>
+ </prop>
+ <prop oor:name="Flags"><value>IMPORT EXPORT ALIEN 3RDPARTYFILTER</value></prop>
+ </node>
+ <node oor:name="devguide_FlatXMLFilter_Cpp_draw" oor:op="replace">
+ <prop oor:name="FileFormatVersion"><value>0</value></prop>
+ <prop oor:name="Type"><value>devguide_FlatXMLType_Cpp_draw</value></prop>
+ <prop oor:name="DocumentService"><value>com.sun.star.drawing.DrawingDocument</value></prop>
+ <prop oor:name="UIComponent"/>
+ <prop oor:name="UserData"><value oor:separator=",">devguide.officedev.samples.filter.FlatXmlCpp, ,com.sun.star.comp.DrawingLayer.XMLOasisImporter,com.sun.star.comp.DrawingLayer.XMLOasisExporter</value></prop>
+ <prop oor:name="FilterService"><value>com.sun.star.comp.Writer.XmlFilterAdaptor</value></prop>
+ <prop oor:name="TemplateName"/>
+ <prop oor:name="UIName">
+ <!-- The x-no-translate entry is a marker to prevent l10n tooling from translation. If it is not necessary. -->
+ <value xml:lang="x-no-translate"></value>
+ <value xml:lang="de">DevGuide FlatXML Draw</value>
+ <value xml:lang="en-US">DevGuide FlatXML Draw</value>
+ </prop>
+ <prop oor:name="Flags"><value>IMPORT EXPORT ALIEN 3RDPARTYFILTER</value></prop>
+ </node>
+ <node oor:name="devguide_FlatXMLFilter_Cpp_impress" oor:op="replace">
+ <prop oor:name="FileFormatVersion"><value>0</value></prop>
+ <prop oor:name="Type"><value>devguide_FlatXMLType_Cpp_impress</value></prop>
+ <prop oor:name="DocumentService"><value>com.sun.star.presentation.PresentationDocument</value></prop>
+ <prop oor:name="UIComponent"/>
+ <prop oor:name="UserData"><value oor:separator=",">devguide.officedev.samples.filter.FlatXmlCpp, ,com.sun.star.comp.Impress.XMLOasisImporter,com.sun.star.comp.Impress.XMLOasisExporter</value></prop>
+ <prop oor:name="FilterService"><value>com.sun.star.comp.Writer.XmlFilterAdaptor</value></prop>
+ <prop oor:name="TemplateName"/>
+ <prop oor:name="UIName">
+ <!-- The x-no-translate entry is a marker to prevent l10n tooling from translation. If it is not necessary. -->
+ <value xml:lang="x-no-translate"></value>
+ <value xml:lang="de">DevGuide FlatXML Impress</value>
+ <value xml:lang="en-US">DevGuide FlatXML Impress</value>
+ </prop>
+ <prop oor:name="Flags"><value>IMPORT EXPORT ALIEN 3RDPARTYFILTER</value></prop>
+ </node>
+ <node oor:name="devguide_FlatXMLFilter_Cpp_writer" oor:op="replace">
+ <prop oor:name="FileFormatVersion"><value>0</value></prop>
+ <prop oor:name="Type"><value>devguide_FlatXMLType_Cpp_writer</value></prop>
+ <prop oor:name="DocumentService"><value>com.sun.star.text.TextDocument</value></prop>
+ <prop oor:name="UIComponent"/>
+ <prop oor:name="UserData"><value oor:separator=",">devguide.officedev.samples.filter.FlatXmlCpp, ,com.sun.star.comp.Writer.XMLOasisImporter,com.sun.star.comp.Writer.XMLOasisExporter</value></prop>
+ <prop oor:name="FilterService"><value>com.sun.star.comp.Writer.XmlFilterAdaptor</value></prop>
+ <prop oor:name="TemplateName"/>
+ <prop oor:name="UIName">
+ <!-- The x-no-translate entry is a marker to prevent l10n tooling from translation. If it is not necessary. -->
+ <value xml:lang="x-no-translate"></value>
+ <value xml:lang="de">DevGuide FlatXML Writer</value>
+ <value xml:lang="en-US">DevGuide FlatXML Writer</value>
+ </prop>
+ <prop oor:name="Flags"><value>IMPORT EXPORT ALIEN 3RDPARTYFILTER</value></prop>
+ </node>
+ <node oor:name="devguide_FlatXMLFilter_Cpp_master" oor:op="replace">
+ <prop oor:name="FileFormatVersion"><value>0</value></prop>
+ <prop oor:name="Type"><value>devguide_FlatXMLType_Cpp_master</value></prop>
+ <prop oor:name="DocumentService"><value>com.sun.star.text.GlobalDocument</value></prop>
+ <prop oor:name="UIComponent"/>
+ <prop oor:name="UserData"><value oor:separator=",">devguide.officedev.samples.filter.FlatXmlCpp, ,com.sun.star.comp.Writer.XMLOasisImporter,com.sun.star.comp.Writer.XMLOasisExporter</value></prop>
+ <prop oor:name="FilterService"><value>com.sun.star.comp.Writer.XmlFilterAdaptor</value></prop>
+ <prop oor:name="TemplateName"/>
+ <prop oor:name="UIName">
+ <!-- The x-no-translate entry is a marker to prevent l10n tooling from translation. If it is not necessary. -->
+ <value xml:lang="x-no-translate"></value>
+ <value xml:lang="de">DevGuide FlatXML Master</value>
+ <value xml:lang="en-US">DevGuide FlatXML Master</value>
+ </prop>
+ <prop oor:name="Flags"><value>IMPORT EXPORT ALIEN 3RDPARTYFILTER</value></prop>
+ </node>
+ </node>
+</oor:component-data>
diff --git a/odk/examples/DevelopersGuide/OfficeDev/FilterDevelopment/FlatXmlFilter_cpp/Makefile b/odk/examples/DevelopersGuide/OfficeDev/FilterDevelopment/FlatXmlFilter_cpp/Makefile
new file mode 100644
index 000000000..73e4b7e2a
--- /dev/null
+++ b/odk/examples/DevelopersGuide/OfficeDev/FilterDevelopment/FlatXmlFilter_cpp/Makefile
@@ -0,0 +1,153 @@
+#*************************************************************************
+#
+# The Contents of this file are made available subject to the terms of
+# the BSD license.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+# 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+# contributors may be used to endorse or promote products derived
+# from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+# TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+# USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+#**************************************************************************
+
+# Builds the C++ FlatXmlFilter component example of the Developers Guide.
+
+PRJ=../../../../..
+SETTINGS=$(PRJ)/settings
+
+include $(SETTINGS)/settings.mk
+include $(SETTINGS)/std.mk
+
+# Define non-platform/compiler specific settings
+COMP_NAME=FlatXmlFilter_cpp
+COMP_IMPL_NAME=$(COMP_NAME).uno.$(SHAREDLIB_EXT)
+OUT_COMP_INC = $(OUT_INC)/$(COMP_NAME)
+OUT_COMP_GEN = $(OUT_MISC)/$(COMP_NAME)
+OUT_COMP_SLO=$(OUT_SLO)/$(COMP_NAME)
+COMP_PACKAGE = $(OUT_BIN)/$(COMP_NAME).$(UNOOXT_EXT)
+COMP_PACKAGE_URL = $(subst \\,\,"$(COMP_PACKAGE_DIR)$(PS)$(COMP_NAME).$(UNOOXT_EXT)")
+COMP_UNOPKG_MANIFEST = $(OUT_COMP_GEN)/$(COMP_NAME)/META-INF/manifest.xml
+COMP_COMPONENTS = $(OUT_COMP_GEN)/$(COMP_NAME).components
+
+COMP_REGISTERFLAG = $(OUT_MISC)/devguide_$(COMP_NAME)_register_component.flag
+
+CXXFILES = FlatXml.cxx
+
+SLOFILES = $(patsubst %.cxx,$(OUT_COMP_SLO)/%.$(OBJ_EXT),$(CXXFILES))
+
+# Targets
+.PHONY: ALL
+ALL : \
+ FlatXmlFilterCppExample
+
+include $(SETTINGS)/stdtarget.mk
+
+$(OUT_COMP_SLO)/%.$(OBJ_EXT) : %.cxx $(SDKTYPEFLAG)
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ $(CC) $(CC_FLAGS) $(CC_INCLUDES) -I$(OUT_COMP_INC) $(CC_DEFINES) $(CC_OUTPUT_SWITCH)$(subst /,$(PS),$@) $<
+
+ifeq "$(OS)" "WIN"
+$(SHAREDLIB_OUT)/%.$(SHAREDLIB_EXT) : $(SLOFILES)
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ -$(MKDIR) $(subst /,$(PS),$(OUT_COMP_GEN))
+ $(LINK) $(COMP_LINK_FLAGS) /OUT:$@ \
+ /MAP:$(OUT_COMP_GEN)/$(subst $(SHAREDLIB_EXT),map,$(@F)) $(SLOFILES) \
+ $(CPPUHELPERLIB) $(CPPULIB) $(SALLIB) msvcprt.lib $(LIBO_SDK_LDFLAGS_STDLIBS)
+ $(LINK_MANIFEST)
+else
+$(SHAREDLIB_OUT)/%.$(SHAREDLIB_EXT) : $(SLOFILES)
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ $(LINK) $(COMP_LINK_FLAGS) $(LINK_LIBS) -o $@ $(SLOFILES) \
+ $(CPPUHELPERLIB) $(CPPULIB) $(SALLIB) $(STC++LIB)
+ifeq "$(OS)" "MACOSX"
+ $(INSTALL_NAME_URELIBS) $@
+endif
+endif
+
+# rule for component package manifest
+$(OUT_COMP_GEN)/%/manifest.xml :
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ @echo $(OSEP)?xml version="$(QM)1.0$(QM)" encoding="$(QM)UTF-8$(QM)"?$(CSEP) > $@
+ @echo $(OSEP)!DOCTYPE manifest:manifest PUBLIC "$(QM)-//OpenOffice.org//DTD Manifest 1.0//EN$(QM)" "$(QM)Manifest.dtd$(QM)"$(CSEP) >> $@
+ @echo $(OSEP)manifest:manifest xmlns:manifest="$(QM)http://openoffice.org/2001/manifest$(QM)"$(CSEP) >> $@
+ @echo $(SQM) $(SQM)$(OSEP)manifest:file-entry manifest:media-type="$(QM)application/vnd.sun.star.configuration-data$(QM)" >> $@
+ @echo $(SQM) $(SQM)manifest:full-path="$(QM)FlatXmlFilter_cpp.xcu$(QM)"/$(CSEP) >> $@
+ @echo $(SQM) $(SQM)$(OSEP)manifest:file-entry manifest:media-type="$(QM)application/vnd.sun.star.uno-components;platform=$(UNOPKG_PLATFORM)$(QM)">> $@
+ @echo $(SQM) $(SQM)manifest:full-path="$(QM)$(COMP_NAME).components$(QM)"/$(CSEP)>> $@
+ @echo $(OSEP)/manifest:manifest$(CSEP) >> $@
+
+$(COMP_COMPONENTS) :
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ @echo $(OSEP)?xml version="$(QM)1.0$(QM)" encoding="$(QM)UTF-8$(QM)"?$(CSEP) > $@
+ @echo $(OSEP)components xmlns="$(QM)http://openoffice.org/2010/uno-components$(QM)"$(CSEP) >> $@
+ @echo $(SQM) $(SQM)$(OSEP)component loader="$(QM)com.sun.star.loader.SharedLibrary$(QM)" uri="$(QM)$(UNOPKG_PLATFORM)/$(COMP_IMPL_NAME)$(QM)"$(CSEP) >> $@
+ @echo $(SQM) $(SQM)$(OSEP)implementation name="$(QM)devguide.officedev.samples.filter.FlatXmlCpp$(QM)"$(CSEP) >> $@
+ @echo $(SQM) $(SQM)$(OSEP)service name="$(QM)devguide.officedev.samples.filter.FlatXmlCpp$(QM)"/$(CSEP) >> $@
+ @echo $(SQM) $(SQM)$(OSEP)/implementation$(CSEP) >> $@
+ @echo $(SQM) $(SQM)$(OSEP)/component$(CSEP) >> $@
+ @echo $(OSEP)/components$(CSEP) >> $@
+
+# rule for component package file
+$(COMP_PACKAGE) : $(SHAREDLIB_OUT)/$(COMP_IMPL_NAME) FlatXmlFilter_cpp.xcu $(COMP_UNOPKG_MANIFEST) $(COMP_COMPONENTS)
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ -$(MKDIR) $(subst /,$(PS),$(OUT_COMP_GEN)/$(UNOPKG_PLATFORM))
+ $(COPY) $(subst /,$(PS),$<) $(subst /,$(PS),$(OUT_COMP_GEN)/$(UNOPKG_PLATFORM))
+ $(SDK_ZIP) $@ FlatXmlFilter_cpp.xcu
+ cd $(subst /,$(PS),$(OUT_COMP_GEN)) && $(SDK_ZIP) -u ../../bin/$(@F) $(COMP_NAME).components
+ cd $(subst /,$(PS),$(OUT_COMP_GEN)) && $(SDK_ZIP) -u ../../bin/$(@F) $(UNOPKG_PLATFORM)/$(<F)
+ cd $(subst /,$(PS),$(OUT_COMP_GEN)/$(subst .$(UNOOXT_EXT),,$(@F))) && $(SDK_ZIP) -u ../../../bin/$(@F) META-INF/manifest.xml
+
+$(COMP_REGISTERFLAG) : $(COMP_PACKAGE)
+ifeq "$(SDK_AUTO_DEPLOYMENT)" "YES"
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ $(DEPLOYTOOL) $(COMP_PACKAGE_URL)
+ @echo flagged > $(subst /,$(PS),$@)
+else
+ @echo --------------------------------------------------------------------------------
+ @echo If you want to install your component automatically, please set the environment
+ @echo variable SDK_AUTO_DEPLOYMENT = YES. But note that auto deployment is only
+ @echo possible if no office instance is running.
+ @echo --------------------------------------------------------------------------------
+endif
+
+FlatXmlFilterCppExample : $(COMP_REGISTERFLAG)
+ @echo --------------------------------------------------------------------------------
+ @echo The C++ FlatXmlFilter component is installed if SDK_AUTO_DEPLOYMENT = YES.
+ @echo You can use the filters "$(QM)DevGuide FlatXML ...$(QM)" inside your office installation
+ @echo after you have installed the "$(QM)FlatXmlTypeDetection.uno.pkg"$(QM) as well.
+ @echo --------------------------------------------------------------------------------
+
+.PHONY: clean
+clean :
+ -$(DELRECURSIVE) $(subst /,$(PS),$(OUT_COMP_INC))
+ -$(DELRECURSIVE) $(subst /,$(PS),$(OUT_COMP_GEN))
+ -$(DELRECURSIVE) $(subst /,$(PS),$(OUT_COMP_SLO))
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$(COMP_PACKAGE_URL)))
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$(COMP_COMPONENTS)))
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$(COMP_REGISTERFLAG)))
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$(COMP_TYPEFLAG)))
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$(SHAREDLIB_OUT)/$(COMP_NAME).*))
diff --git a/odk/examples/DevelopersGuide/OfficeDev/FilterDevelopment/FlatXmlFilter_java/FlatXml.java b/odk/examples/DevelopersGuide/OfficeDev/FilterDevelopment/FlatXmlFilter_java/FlatXml.java
new file mode 100644
index 000000000..6ba341977
--- /dev/null
+++ b/odk/examples/DevelopersGuide/OfficeDev/FilterDevelopment/FlatXmlFilter_java/FlatXml.java
@@ -0,0 +1,267 @@
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+import com.sun.star.uno.*;
+import com.sun.star.lang.*;
+import com.sun.star.beans.*;
+
+import com.sun.star.comp.loader.FactoryHelper;
+import com.sun.star.registry.XRegistryKey;
+
+import com.sun.star.xml.*;
+import com.sun.star.xml.sax.*;
+
+import com.sun.star.io.XInputStream;
+import com.sun.star.io.XOutputStream;
+import com.sun.star.io.XActiveDataSource;
+
+
+
+public class FlatXml implements XImportFilter, XExportFilter, XServiceName,
+ XServiceInfo, XDocumentHandler, XTypeProvider
+{
+
+ /*
+ * private data members
+ */
+ private final XMultiServiceFactory m_xServiceFactory;
+ private XExtendedDocumentHandler m_xHandler;
+ private static final boolean m_bPrettyPrint = true;
+
+ private static final String __serviceName = "devguide.officedev.samples.filter.FlatXmlJava";
+ private static final String __implName = "FlatXml";
+ private static final String[] __supportedServiceNames = {
+ "devguide.officedev.samples.filter.FlatXmlJava"
+ };
+
+ public FlatXml(XMultiServiceFactory f) {
+ m_xServiceFactory = f;
+ }
+
+ // --- XTypeProvider ---
+ public byte[] getImplementationId() {
+ return new byte[0];
+ }
+
+ // --- XServiceName ---
+ public String getServiceName() {
+ return __serviceName;
+ }
+
+ // --- XServiceInfo ---
+ public boolean supportsService(String sName) {
+ for (int i = 0; i < __supportedServiceNames.length; i++) {
+ if (__supportedServiceNames[i].equals(sName)) return true;
+ }
+ return false;
+ }
+ public String getImplementationName() {
+ return this.getClass().getName();
+ }
+ public String[] getSupportedServiceNames() {
+ return __supportedServiceNames;
+ }
+
+ public com.sun.star.uno.Type[] getTypes() {
+ Type[] typeReturn = {};
+ try {
+ typeReturn = new Type[] {
+ new Type( XTypeProvider.class ),
+ new Type( XExportFilter.class ),
+ new Type( XImportFilter.class ),
+ new Type( XServiceName.class ),
+ new Type( XServiceInfo.class )
+ };
+ } catch( java.lang.Exception exception ) {
+ return null;
+ }
+ return typeReturn;
+ }
+
+ public boolean importer(PropertyValue[] aSourceData, XDocumentHandler xDocHandler, String[] msUserData)
+ throws com.sun.star.uno.RuntimeException, com.sun.star.lang.IllegalArgumentException
+ {
+ String sName = null;
+ String sFileName = null;
+ String sURL = null;
+ com.sun.star.io.XInputStream xin = null;
+
+ try {
+
+ for (int i = 0 ; i < aSourceData.length; i++)
+ {
+ sName = aSourceData[i].Name;
+ if (sName.equals("InputStream"))
+ xin = (XInputStream)AnyConverter.toObject(XInputStream.class, aSourceData[i].Value);
+ if (sName.equals("URL"))
+ sURL=(String)AnyConverter.toObject(String.class, aSourceData[i].Value);
+ if (sName.equals("FileName"))
+ sFileName=(String)AnyConverter.toObject(String.class, aSourceData[i].Value);
+ }
+
+ Object tmpObj=m_xServiceFactory.createInstance("com.sun.star.xml.sax.Parser");
+ if (tmpObj == null) return false;
+
+ XParser xParser = UnoRuntime.queryInterface(XParser.class , tmpObj);
+ if (xParser == null) return false;
+
+ InputSource aInput = new InputSource();
+ aInput.sSystemId = sURL;
+ aInput.aInputStream =xin;
+ xParser.setDocumentHandler ( xDocHandler );
+ xParser.parseStream ( aInput );
+ } catch (com.sun.star.uno.Exception e){
+ e.printStackTrace();
+ return false;
+ }
+
+ // done...
+ return true;
+ }
+
+ public boolean exporter(PropertyValue[] aSourceData, String[] msUserData)
+ throws com.sun.star.uno.RuntimeException, com.sun.star.lang.IllegalArgumentException
+ {
+ try {
+ String sURL = null;
+ String sName = null;
+ XOutputStream xos = null;
+
+ // get interesting values from sourceData
+ for (int i = 0 ; i < aSourceData.length; i++)
+ {
+ sName = aSourceData[i].Name;
+ if (sName.equals("OutputStream"))
+ xos = (XOutputStream)AnyConverter.toObject(XOutputStream.class, aSourceData[i].Value);
+ if (sName.equals("URL"))
+ sURL=(String)AnyConverter.toObject(String.class, aSourceData[i].Value);
+ }
+
+ // prepare the XML writer
+ Object tmpObj = null;
+ if (m_xHandler == null)
+ {
+ tmpObj = m_xServiceFactory.createInstance("com.sun.star.xml.sax.Writer");
+ if (tmpObj != null)
+ m_xHandler = UnoRuntime.queryInterface(XExtendedDocumentHandler.class, tmpObj);
+ }
+ if (m_xHandler == null)
+ return false;
+
+ // Connect the provided output stream to the writer
+ XActiveDataSource xADSource = UnoRuntime.queryInterface(
+ XActiveDataSource.class, m_xHandler);
+
+ if (xADSource != null && xos != null)
+ xADSource.setOutputStream(xos);
+ else
+ return false;
+ } catch (com.sun.star.uno.Exception e){
+ return false;
+ }
+
+ // done ...
+ return true;
+ }
+
+ public void startDocument ()
+ throws com.sun.star.xml.sax.SAXException
+ {
+ m_xHandler.startDocument();
+ }
+
+ public void endDocument()
+ throws com.sun.star.xml.sax.SAXException
+ {
+ m_xHandler.endDocument();
+ }
+
+ public void startElement (String str, com.sun.star.xml.sax.XAttributeList xattribs)
+ throws com.sun.star.xml.sax.SAXException
+ {
+ m_xHandler.startElement(str, xattribs);
+ }
+
+ public void endElement(String str)
+ throws com.sun.star.xml.sax.SAXException
+ {
+ m_xHandler.endElement(str);
+ }
+
+ public void characters(String str)
+ throws com.sun.star.xml.sax.SAXException
+ {
+ m_xHandler.characters(str);
+ }
+
+ public void ignorableWhitespace(String str)
+ throws com.sun.star.xml.sax.SAXException
+ {
+ if (!m_bPrettyPrint) return;
+ else m_xHandler.ignorableWhitespace(str);
+ }
+
+ public void processingInstruction(String aTarget, String aData)
+ throws com.sun.star.xml.sax.SAXException
+ {
+ m_xHandler.processingInstruction(aTarget, aData);
+ }
+
+ public void setDocumentLocator(XLocator xLocator)
+ throws com.sun.star.xml.sax.SAXException
+ {
+ m_xHandler.setDocumentLocator(xLocator);
+ }
+
+
+ // component management
+
+ public static XSingleServiceFactory __getServiceFactory(String implName,
+ XMultiServiceFactory multiFactory, XRegistryKey regKey)
+ {
+ XSingleServiceFactory xSingleServiceFactory = null;
+ if (implName.equals(__implName) ) {
+ try {
+ xSingleServiceFactory = FactoryHelper.getServiceFactory(
+ Class.forName(implName), __serviceName, multiFactory, regKey);
+ } catch (java.lang.ClassNotFoundException e) {
+ return null;
+ }
+ }
+ return xSingleServiceFactory;
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/OfficeDev/FilterDevelopment/FlatXmlFilter_java/FlatXmlFilter_java.components b/odk/examples/DevelopersGuide/OfficeDev/FilterDevelopment/FlatXmlFilter_java/FlatXmlFilter_java.components
new file mode 100644
index 000000000..87359c3ec
--- /dev/null
+++ b/odk/examples/DevelopersGuide/OfficeDev/FilterDevelopment/FlatXmlFilter_java/FlatXmlFilter_java.components
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<components xmlns="http://openoffice.org/2010/uno-components">
+ <component loader="com.sun.star.loader.Java2" uri="FlatXmlFilter_java.uno.jar">
+ <implementation name="FlatXml">
+ <service name="devguide.officedev.samples.filter.FlatXmlJava"/>
+ </implementation>
+ </component>
+</components>
diff --git a/odk/examples/DevelopersGuide/OfficeDev/FilterDevelopment/FlatXmlFilter_java/FlatXmlFilter_java.xcu b/odk/examples/DevelopersGuide/OfficeDev/FilterDevelopment/FlatXmlFilter_java/FlatXmlFilter_java.xcu
new file mode 100644
index 000000000..8bb6e2350
--- /dev/null
+++ b/odk/examples/DevelopersGuide/OfficeDev/FilterDevelopment/FlatXmlFilter_java/FlatXmlFilter_java.xcu
@@ -0,0 +1,103 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+-->
+<!DOCTYPE oor:component-data SYSTEM "../../../../component-update.dtd">
+<oor:component-data xmlns:oor="http://openoffice.org/2001/registry" xmlns:xs="http://www.w3.org/2001/XMLSchema" oor:package="org.openoffice.TypeDetection" oor:name="Filter">
+ <node oor:name="Filters">
+ <node oor:name="devguide_FlatXMLFilter_Java_calc" oor:op="replace">
+ <prop oor:name="FileFormatVersion"><value>0</value></prop>
+ <prop oor:name="Type"><value>devguide_FlatXMLType_Cpp_calc</value></prop>
+ <prop oor:name="DocumentService"><value>com.sun.star.sheet.SpreadsheetDocument</value></prop>
+ <prop oor:name="UIComponent"/>
+ <prop oor:name="UserData"><value oor:separator=",">devguide.officedev.samples.filter.FlatXmlJava, ,com.sun.star.comp.Calc.XMLOasisImporter,com.sun.star.comp.Calc.XMLOasisExporter</value></prop>
+ <prop oor:name="FilterService"><value>com.sun.star.comp.Writer.XmlFilterAdaptor</value></prop>
+ <prop oor:name="TemplateName"/>
+ <prop oor:name="UIName">
+ <!-- The x-no-translate entry is a marker to prevent l10n tooling from translation. If it is not necessary. -->
+ <value xml:lang="x-no-translate"></value>
+ <value xml:lang="de">DevGuide FlatXML Calc</value>
+ <value xml:lang="en-US">DevGuide FlatXML Calc</value>
+ </prop>
+ <prop oor:name="Flags"><value>IMPORT EXPORT ALIEN 3RDPARTYFILTER</value></prop>
+ </node>
+ <node oor:name="devguide_FlatXMLFilter_Java_draw" oor:op="replace">
+ <prop oor:name="FileFormatVersion"><value>0</value></prop>
+ <prop oor:name="Type"><value>devguide_FlatXMLType_Cpp_draw</value></prop>
+ <prop oor:name="DocumentService"><value>com.sun.star.drawing.DrawingDocument</value></prop>
+ <prop oor:name="UIComponent"/>
+ <prop oor:name="UserData"><value oor:separator=",">devguide.officedev.samples.filter.FlatXmlJava, ,com.sun.star.comp.DrawingLayer.XMLOasisImporter,com.sun.star.comp.DrawingLayer.XMLOasisExporter</value></prop>
+ <prop oor:name="FilterService"><value>com.sun.star.comp.Writer.XmlFilterAdaptor</value></prop>
+ <prop oor:name="TemplateName"/>
+ <prop oor:name="UIName">
+ <!-- The x-no-translate entry is a marker to prevent l10n tooling from translation. If it is not necessary. -->
+ <value xml:lang="x-no-translate"></value>
+ <value xml:lang="de">DevGuide FlatXML Draw</value>
+ <value xml:lang="en-US">DevGuide FlatXML Draw</value>
+ </prop>
+ <prop oor:name="Flags"><value>IMPORT EXPORT ALIEN 3RDPARTYFILTER</value></prop>
+ </node>
+ <node oor:name="devguide_FlatXMLFilter_Java_impress" oor:op="replace">
+ <prop oor:name="FileFormatVersion"><value>0</value></prop>
+ <prop oor:name="Type"><value>devguide_FlatXMLType_Cpp_impress</value></prop>
+ <prop oor:name="DocumentService"><value>com.sun.star.presentation.PresentationDocument</value></prop>
+ <prop oor:name="UIComponent"/>
+ <prop oor:name="UserData"><value oor:separator=",">devguide.officedev.samples.filter.FlatXmlJava, ,com.sun.star.comp.Impress.XMLOasisImporter,com.sun.star.comp.Impress.XMLOasisExporter</value></prop>
+ <prop oor:name="FilterService"><value>com.sun.star.comp.Writer.XmlFilterAdaptor</value></prop>
+ <prop oor:name="TemplateName"/>
+ <prop oor:name="UIName">
+ <!-- The x-no-translate entry is a marker to prevent l10n tooling from translation. If it is not necessary. -->
+ <value xml:lang="x-no-translate"></value>
+ <value xml:lang="de">DevGuide FlatXML Impress</value>
+ <value xml:lang="en-US">DevGuide FlatXML Impress</value>
+ </prop>
+ <prop oor:name="Flags"><value>IMPORT EXPORT ALIEN 3RDPARTYFILTER</value></prop>
+ </node>
+ <node oor:name="devguide_FlatXMLFilter_Java_writer" oor:op="replace">
+ <prop oor:name="FileFormatVersion"><value>0</value></prop>
+ <prop oor:name="Type"><value>devguide_FlatXMLType_Cpp_writer</value></prop>
+ <prop oor:name="DocumentService"><value>com.sun.star.text.TextDocument</value></prop>
+ <prop oor:name="UIComponent"/>
+ <prop oor:name="UserData"><value oor:separator=",">devguide.officedev.samples.filter.FlatXmlJava, ,com.sun.star.comp.Writer.XMLOasisImporter,com.sun.star.comp.Writer.XMLOasisExporter</value></prop>
+ <prop oor:name="FilterService"><value>com.sun.star.comp.Writer.XmlFilterAdaptor</value></prop>
+ <prop oor:name="TemplateName"/>
+ <prop oor:name="UIName">
+ <!-- The x-no-translate entry is a marker to prevent l10n tooling from translation. If it is not necessary. -->
+ <value xml:lang="x-no-translate"></value>
+ <value xml:lang="de">DevGuide FlatXML Writer</value>
+ <value xml:lang="en-US">DevGuide FlatXML Writer</value>
+ </prop>
+ <prop oor:name="Flags"><value>IMPORT EXPORT ALIEN 3RDPARTYFILTER</value></prop>
+ </node>
+ <node oor:name="devguide_FlatXMLFilter_Java_master" oor:op="replace">
+ <prop oor:name="FileFormatVersion"><value>0</value></prop>
+ <prop oor:name="Type"><value>devguide_FlatXMLType_Cpp_master</value></prop>
+ <prop oor:name="DocumentService"><value>com.sun.star.text.GlobalDocument</value></prop>
+ <prop oor:name="UIComponent"/>
+ <prop oor:name="UserData"><value oor:separator=",">devguide.officedev.samples.filter.FlatXmlJava, ,com.sun.star.comp.Writer.XMLOasisImporter,com.sun.star.comp.Writer.XMLOasisExporter</value></prop>
+ <prop oor:name="FilterService"><value>com.sun.star.comp.Writer.XmlFilterAdaptor</value></prop>
+ <prop oor:name="TemplateName"/>
+ <prop oor:name="UIName">
+ <!-- The x-no-translate entry is a marker to prevent l10n tooling from translation. If it is not necessary. -->
+ <value xml:lang="x-no-translate"></value>
+ <value xml:lang="de">DevGuide FlatXML Master</value>
+ <value xml:lang="en-US">DevGuide FlatXML Master</value>
+ </prop>
+ <prop oor:name="Flags"><value>IMPORT EXPORT ALIEN 3RDPARTYFILTER</value></prop>
+ </node>
+ </node>
+</oor:component-data>
diff --git a/odk/examples/DevelopersGuide/OfficeDev/FilterDevelopment/FlatXmlFilter_java/Makefile b/odk/examples/DevelopersGuide/OfficeDev/FilterDevelopment/FlatXmlFilter_java/Makefile
new file mode 100644
index 000000000..58366b7d5
--- /dev/null
+++ b/odk/examples/DevelopersGuide/OfficeDev/FilterDevelopment/FlatXmlFilter_java/Makefile
@@ -0,0 +1,142 @@
+#*************************************************************************
+#
+# The Contents of this file are made available subject to the terms of
+# the BSD license.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+# 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+# contributors may be used to endorse or promote products derived
+# from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+# TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+# USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+#**************************************************************************
+
+# Builds the Java FlatXMLFilter component example of the Developers Guide.
+
+PRJ=../../../../..
+SETTINGS=$(PRJ)/settings
+
+include $(SETTINGS)/settings.mk
+include $(SETTINGS)/std.mk
+
+# Define non-platform/compiler specific settings
+COMP_NAME=FlatXmlFilter_java
+OUT_COMP_CLASS = $(OUT_CLASS)/$(COMP_NAME)
+COMP_PACKAGE = $(OUT_BIN)/$(COMP_NAME).$(UNOOXT_EXT)
+COMP_PACKAGE_URL = $(subst \\,\,"$(COMP_PACKAGE_DIR)$(PS)$(COMP_NAME).$(UNOOXT_EXT)")
+COMP_JAR_NAME = $(COMP_NAME).uno.jar
+COMP_JAR = $(OUT_COMP_CLASS)/$(COMP_JAR_NAME)
+COMP_MANIFESTFILE = $(OUT_COMP_CLASS)/$(COMP_NAME).uno.Manifest
+COMP_UNOPKG_MANIFEST = $(OUT_COMP_CLASS)/$(COMP_NAME)/META-INF/manifest.xml
+COMP_REGISTERFLAG = $(OUT_MISC)$(PS)devguide_$(COMP_NAME)_register_component.flag
+COMP_COMPONENTS=$(COMP_NAME).components
+
+JAVAFILES = \
+ FlatXml.java \
+
+CLASSFILES = $(patsubst %.java,$(OUT_COMP_CLASS)/%.class,$(JAVAFILES))
+
+
+#$(COMP_NAME)_CLASSFILES = FlatXml.class FlatXml$(dlr)_FlatXml.class
+
+$(COMP_NAME)_CLASSFILES = *.class
+
+SDK_CLASSPATH = $(subst $(EMPTYSTRING) $(PATH_SEPARATOR),$(PATH_SEPARATOR),$(CLASSPATH)\
+ $(PATH_SEPARATOR)$(OUT_COMP_CLASS))
+
+
+# Targets
+.PHONY: ALL
+ALL : \
+ FlatXmlFilterJavaExample
+
+include $(SETTINGS)/stdtarget.mk
+
+$(OUT_COMP_CLASS)/%.Manifest :
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ @echo RegistrationClassName: FlatXml> $@
+
+$(CLASSFILES) : $(JAVAFILES)
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ $(SDK_JAVAC) $(JAVAC_FLAGS) -classpath "$(SDK_CLASSPATH)" -d $(OUT_COMP_CLASS) $(JAVAFILES)
+
+# rule for component jar file
+$(COMP_JAR) : $(COMP_MANIFESTFILE) $(CLASSFILES)
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ cd $(subst /,$(PS),$(OUT_COMP_CLASS)) && $(SDK_JAR) cvfm $(@F) $(<F) $($(basename $(basename $(@F)))_CLASSFILES)
+
+# rule for component package manifest
+$(OUT_COMP_CLASS)/%/manifest.xml :
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ @echo $(OSEP)?xml version="$(QM)1.0$(QM)" encoding="$(QM)UTF-8$(QM)"?$(CSEP) > $@
+ @echo $(OSEP)!DOCTYPE manifest:manifest PUBLIC "$(QM)-//OpenOffice.org//DTD Manifest 1.0//EN$(QM)" "$(QM)Manifest.dtd$(QM)"$(CSEP) >> $@
+ @echo $(OSEP)manifest:manifest xmlns:manifest="$(QM)http://openoffice.org/2001/manifest$(QM)"$(CSEP) >> $@
+ @echo $(SQM) $(SQM)$(OSEP)manifest:file-entry manifest:media-type="$(QM)application/vnd.sun.star.configuration-data$(QM)" >> $@
+ @echo $(SQM) $(SQM)manifest:full-path="$(QM)FlatXmlFilter_java.xcu$(QM)"/$(CSEP) >> $@
+ @echo $(SQM) $(SQM)$(OSEP)manifest:file-entry manifest:media-type="$(QM)application/vnd.sun.star.uno-components$(QM)">> $@
+ @echo $(SQM) $(SQM)manifest:full-path="$(QM)$(COMP_COMPONENTS)$(QM)"/$(CSEP)>> $@
+ @echo $(OSEP)/manifest:manifest$(CSEP) >> $@
+
+# rule for component package file
+$(COMP_PACKAGE) : $(COMP_JAR) FlatXmlFilter_java.xcu $(COMP_UNOPKG_MANIFEST) $(COMP_COMPONENTS)
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ $(SDK_ZIP) $@ FlatXmlFilter_java.xcu
+ $(SDK_ZIP) -u $@ $(COMP_COMPONENTS)
+ cd $(subst /,$(PS),$(OUT_COMP_CLASS)) && $(SDK_ZIP) -u ../../bin/$(@F) $(<F)
+ cd $(subst /,$(PS),$(OUT_COMP_CLASS)/$(subst .$(UNOOXT_EXT),,$(@F))) && $(SDK_ZIP) -u ../../../bin/$(@F) META-INF/manifest.xml
+
+$(COMP_REGISTERFLAG) : $(COMP_PACKAGE)
+ifeq "$(SDK_AUTO_DEPLOYMENT)" "YES"
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ $(DEPLOYTOOL) $(COMP_PACKAGE_URL)
+ @echo flagged > $(subst /,$(PS),$@)
+else
+ @echo --------------------------------------------------------------------------------
+ @echo If you want to install your component automatically, please set the environment
+ @echo variable SDK_AUTO_DEPLOYMENT = YES. But note that auto deployment is only
+ @echo possible if no office instance is running.
+ @echo --------------------------------------------------------------------------------
+endif
+
+FlatXmlFilterJavaExample : $(COMP_REGISTERFLAG)
+ @echo --------------------------------------------------------------------------------
+ @echo The Java FlatXmlFilter component is installed if SDK_AUTO_DEPLOYMENT = YES.
+ @echo You can use the filters "$(QM)DevGuide FlatXML ...$(QM)" inside your office installation
+ @echo after you have installed the "$(QM)FlatXmlTypeDetection.uno.pkg"$(QM) as well.
+ @echo --------------------------------------------------------------------------------
+
+%.run: $(OUT_COMP_CLASS)/%.class
+ $(SDK_JAVA) -classpath "$(SDK_CLASSPATH)" $(basename $@)
+
+%.local: $(OUT_COMP_CLASS)/%.class
+ $(SDK_JAVA) -classpath "$(SDK_CLASSPATH)" $(basename $@) local
+
+.PHONY: clean
+clean :
+ -$(DELRECURSIVE) $(subst /,$(PS),$(OUT_COMP_CLASS))
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$(COMP_PACKAGE_URL)))
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$(COMP_REGISTERFLAG)))
diff --git a/odk/examples/DevelopersGuide/OfficeDev/Linguistic/LinguisticExamples.java b/odk/examples/DevelopersGuide/OfficeDev/Linguistic/LinguisticExamples.java
new file mode 100644
index 000000000..9cbd481cb
--- /dev/null
+++ b/odk/examples/DevelopersGuide/OfficeDev/Linguistic/LinguisticExamples.java
@@ -0,0 +1,360 @@
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+// used interfaces
+import com.sun.star.uno.XComponentContext;
+import com.sun.star.lang.XMultiComponentFactory;
+import com.sun.star.linguistic2.XLinguServiceManager;
+import com.sun.star.linguistic2.XSpellChecker;
+import com.sun.star.linguistic2.XHyphenator;
+import com.sun.star.linguistic2.XThesaurus;
+import com.sun.star.linguistic2.XSpellAlternatives;
+import com.sun.star.linguistic2.XHyphenatedWord;
+import com.sun.star.linguistic2.XPossibleHyphens;
+import com.sun.star.linguistic2.XMeaning;
+import com.sun.star.linguistic2.XSearchableDictionaryList;
+import com.sun.star.linguistic2.XLinguServiceEventListener;
+import com.sun.star.linguistic2.LinguServiceEvent;
+import com.sun.star.beans.XPropertySet;
+import com.sun.star.beans.PropertyValue;
+import com.sun.star.lang.EventObject;
+import com.sun.star.lang.Locale;
+import com.sun.star.uno.UnoRuntime;
+
+public class LinguisticExamples
+{
+ // The remote office context
+ protected XComponentContext mxRemoteContext = null;
+ // The MultiServiceFactory interface of the Office
+ protected XMultiComponentFactory mxRemoteServiceManager = null;
+
+ // The LinguServiceManager interface
+ protected XLinguServiceManager mxLinguSvcMgr = null;
+
+ // The SpellChecker interface
+ protected XSpellChecker mxSpell = null;
+
+ // The Hyphenator interface
+ protected XHyphenator mxHyph = null;
+
+ // The Thesaurus interface
+ protected XThesaurus mxThes = null;
+
+ // The DictionaryList interface
+ protected XSearchableDictionaryList mxDicList = null;
+
+ // The LinguProperties interface
+ protected XPropertySet mxLinguProps = null;
+
+
+ public static void main(String args[])
+ {
+ // Create an instance of the class and call its begin method
+ try {
+ LinguisticExamples aExample = new LinguisticExamples();
+ aExample.Connect();
+ aExample.Run();
+ } catch (Exception e) {
+ System.err.println("failed to run examples");
+ e.printStackTrace();
+ }
+ }
+
+
+ public void Connect()
+ throws java.lang.Exception
+ {
+ // get the remote office context. If necessary a new office
+ // process is started
+ mxRemoteContext = com.sun.star.comp.helper.Bootstrap.bootstrap();
+ System.out.println("Connected to a running office ...");
+ mxRemoteServiceManager = mxRemoteContext.getServiceManager();
+ }
+
+
+ /** Get the LinguServiceManager to be used. For example to access spell
+ checker, thesaurus and hyphenator, also the component may choose to
+ register itself as listener to it in order to get notified of relevant
+ events. */
+ public boolean GetLinguSvcMgr()
+ throws com.sun.star.uno.Exception
+ {
+ if (mxRemoteContext != null && mxRemoteServiceManager != null) {
+ Object aObj = mxRemoteServiceManager.createInstanceWithContext(
+ "com.sun.star.linguistic2.LinguServiceManager", mxRemoteContext );
+ mxLinguSvcMgr = UnoRuntime.queryInterface(XLinguServiceManager.class, aObj);
+ }
+ return mxLinguSvcMgr != null;
+ }
+
+
+ /** Get the SpellChecker to be used.
+ */
+ public boolean GetSpell()
+ throws com.sun.star.uno.RuntimeException
+ {
+ if (mxLinguSvcMgr != null)
+ mxSpell = mxLinguSvcMgr.getSpellChecker();
+ return mxSpell != null;
+ }
+
+ /** Get the Hyphenator to be used.
+ */
+ public boolean GetHyph()
+ throws com.sun.star.uno.RuntimeException
+ {
+ if (mxLinguSvcMgr != null)
+ mxHyph = mxLinguSvcMgr.getHyphenator();
+ return mxHyph != null;
+ }
+
+ /** Get the Thesaurus to be used.
+ */
+ public boolean GetThes()
+ throws com.sun.star.uno.RuntimeException
+ {
+ if (mxLinguSvcMgr != null)
+ mxThes = mxLinguSvcMgr.getThesaurus();
+ return mxThes != null;
+ }
+
+
+ public void Run()
+ throws Exception
+ {
+ GetLinguSvcMgr();
+
+
+ // list of property values to used in function calls below.
+ // Only properties with values different from the (default) values
+ // in the LinguProperties property set need to be supllied.
+ // Thus we may stay with an empty list in order to use the ones
+ // from the property set.
+ PropertyValue[] aEmptyProps = new PropertyValue[0];
+
+ // use american english as language
+ Locale aLocale = new Locale("en","US","");
+
+
+
+ // another list of property values to used in function calls below.
+ // Only properties with values different from the (default) values
+ // in the LinguProperties property set need to be supllied.
+ PropertyValue[] aProps = new PropertyValue[1];
+ aProps[0] = new PropertyValue();
+ aProps[0].Name = "IsGermanPreReform";
+ aProps[0].Value = Boolean.TRUE;
+
+
+ GetSpell();
+ if (mxSpell != null)
+ {
+ // test with correct word
+ String aWord = "horseback";
+ boolean bIsCorrect = mxSpell.isValid( aWord, aLocale, aEmptyProps );
+ System.out.println( aWord + ": " + bIsCorrect );
+
+ // test with incorrect word
+ aWord = "course";
+ bIsCorrect = mxSpell.isValid( aWord, aLocale , aEmptyProps );
+ System.out.println( aWord + ": " + bIsCorrect );
+
+
+ aWord = "house";
+ XSpellAlternatives xAlt = mxSpell.spell( aWord, aLocale, aEmptyProps );
+ if (xAlt == null)
+ System.out.println( aWord + " is correct." );
+ else
+ {
+ System.out.println( aWord + " is not correct. A list of proposals follows." );
+ String[] aAlternatives = xAlt.getAlternatives();
+ if (aAlternatives.length == 0)
+ System.out.println( "no proposal found." );
+ else
+ {
+ for (int i = 0; i < aAlternatives.length; ++i)
+ System.out.println( aAlternatives[i] );
+ }
+ }
+ }
+
+
+ GetHyph();
+ if (mxHyph != null)
+ {
+ // maximum number of characters to remain before the hyphen
+ // character in the resulting word of the hyphenation
+ short nMaxLeading = 6;
+
+ XHyphenatedWord xHyphWord = mxHyph.hyphenate( "waterfall",
+ aLocale, nMaxLeading ,
+ aEmptyProps );
+ if (xHyphWord == null)
+ System.out.println( "no valid hyphenation position found" );
+ else
+ {
+ System.out.println( "valid hyphenation pos found at "
+ + xHyphWord.getHyphenationPos()
+ + " in " + xHyphWord.getWord() );
+ System.out.println( "hyphenation char will be after char "
+ + xHyphWord.getHyphenPos()
+ + " in " + xHyphWord.getHyphenatedWord() );
+ }
+
+
+ //! Note: 'aProps' needs to have set 'IsGermanPreReform' to true!
+ xHyphWord = mxHyph.queryAlternativeSpelling( "Schiffahrt",
+ new Locale("de","DE",""), (short)4, aProps );
+ if (xHyphWord == null)
+ System.out.println( "no alternative spelling found at specified position." );
+ else
+ {
+ if (xHyphWord.isAlternativeSpelling())
+ System.out.println( "alternative spelling detected!" );
+ System.out.println( "valid hyphenation pos found at "
+ + xHyphWord.getHyphenationPos()
+ + " in " + xHyphWord.getWord() );
+ System.out.println( "hyphenation char will be after char "
+ + xHyphWord.getHyphenPos()
+ + " in " + xHyphWord.getHyphenatedWord() );
+ }
+
+
+ XPossibleHyphens xPossHyph = mxHyph.createPossibleHyphens("waterfall",
+ aLocale,
+ aEmptyProps );
+ if (xPossHyph == null)
+ System.out.println( "no hyphenation positions found." );
+ else
+ System.out.println( xPossHyph.getPossibleHyphens() );
+ }
+
+
+ GetThes();
+ if (mxThes != null)
+ {
+ XMeaning[] xMeanings = mxThes.queryMeanings("house", aLocale,
+ aEmptyProps );
+ if (xMeanings == null)
+ System.out.println( "nothing found." );
+ else
+ {
+ for (int i = 0; i < xMeanings.length; ++i)
+ {
+ System.out.println( "Meaning: " + xMeanings[i].getMeaning() );
+ String[] aSynonyms = xMeanings[i].querySynonyms();
+ for (int k = 0; k < aSynonyms.length; ++k)
+ System.out.println( " Synonym: " + aSynonyms[k] );
+ }
+ }
+ }
+
+
+
+ XLinguServiceEventListener aClient = new Client();
+
+ // get access to LinguProperties property set
+ Object aObj = mxRemoteServiceManager.createInstanceWithContext(
+ "com.sun.star.linguistic2.LinguProperties", mxRemoteContext);
+ XPropertySet aLinguProps = UnoRuntime.queryInterface(
+ XPropertySet.class,aObj);
+
+ // set a spellchecker and hyphenator property value to a defined state
+ try {
+ aLinguProps.setPropertyValue("IsGermanPreReform", Boolean.TRUE);
+ } catch (Exception e) {
+ }
+
+ // now add the client as listener to the service manager to
+ // get informed when spellchecking or hyphenation may produce
+ // different results then before.
+ mxLinguSvcMgr.addLinguServiceManagerListener(aClient);
+
+ // change that property value in order to trigger a property change
+ // event that eventually results in the listeners
+ // 'processLinguServiceEvent' function being called
+ try {
+ aLinguProps.setPropertyValue("IsGermanPreReform", Boolean.FALSE);
+ } catch (Exception e) {
+ }
+
+ //! keep the listener and the program alive until the event will
+ //! be launched.
+ //! There is a voluntary delay before launching the event!
+ // Of course this code would usually not be in a *real* client
+ // its
+ synchronized(this) {
+ try {
+ this.wait(4000);
+ } catch(Exception e) {
+
+ }
+ }
+
+ //! remove listener before program termination.
+ //! should not be omitted.
+ mxLinguSvcMgr.removeLinguServiceManagerListener(aClient);
+
+
+ System.exit(0);
+ }
+
+ /** simple sample implementation of a clients XLinguServiceEventListener
+ * interface implementation
+ */
+ private class Client
+ implements XLinguServiceEventListener
+ {
+ public void disposing ( EventObject aEventObj )
+ {
+ //! any references to the EventObjects source have to be
+ //! released here now!
+
+ System.out.println("object listened to will be disposed");
+ }
+
+ public void processLinguServiceEvent( LinguServiceEvent aServiceEvent )
+ {
+ //! do here whatever you think needs to be done depending
+ //! on the event received (e.g. trigger background spellchecking
+ //! or hyphenation again.)
+
+ System.out.println("Listener called");
+ }
+ }
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/OfficeDev/Linguistic/Makefile b/odk/examples/DevelopersGuide/OfficeDev/Linguistic/Makefile
new file mode 100644
index 000000000..95b6204c0
--- /dev/null
+++ b/odk/examples/DevelopersGuide/OfficeDev/Linguistic/Makefile
@@ -0,0 +1,231 @@
+#*************************************************************************
+#
+# The Contents of this file are made available subject to the terms of
+# the BSD license.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+# 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+# contributors may be used to endorse or promote products derived
+# from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+# TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+# USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+#**************************************************************************
+
+# Builds the OfficeDevLinguistic examples of the Developers Guide.
+
+PRJ=../../../..
+SETTINGS=$(PRJ)/settings
+
+include $(SETTINGS)/settings.mk
+include $(SETTINGS)/std.mk
+
+# Define non-platform/compiler specific settings
+EXAMPLE_NAME=OfficeDevLinguisticExample
+OUT_COMP_CLASS = $(OUT_CLASS)/$(EXAMPLE_NAME)
+
+COMP1_NAME=SampleHyphenator
+COMP1_PACKAGE = $(OUT_BIN)/$(COMP1_NAME).$(UNOOXT_EXT)
+COMP1_PACKAGE_URL = $(subst \\,\,"$(COMP_PACKAGE_DIR)$(PS)$(COMP1_NAME).$(UNOOXT_EXT)")
+COMP1_JAR_NAME = $(COMP1_NAME).uno.jar
+COMP1_JAR = $(OUT_COMP_CLASS)/$(COMP1_JAR_NAME)
+COMP1_MANIFESTFILE = $(OUT_COMP_CLASS)/$(COMP1_NAME).uno.Manifest
+COMP1_UNOPKG_MANIFEST = $(OUT_COMP_CLASS)/$(COMP1_NAME)/META-INF/manifest.xml
+COMP1_COMPONENTS=$(COMP1_NAME).components
+
+COMP2_NAME=SampleSpellChecker
+COMP2_PACKAGE = $(OUT_BIN)/$(COMP2_NAME).$(UNOOXT_EXT)
+COMP2_PACKAGE_URL = $(subst \\,\,"$(COMP_PACKAGE_DIR)$(PS)$(COMP2_NAME).$(UNOOXT_EXT)")
+COMP2_JAR_NAME = $(COMP2_NAME).uno.jar
+COMP2_JAR = $(OUT_COMP_CLASS)/$(COMP2_JAR_NAME)
+COMP2_MANIFESTFILE = $(OUT_COMP_CLASS)/$(COMP2_NAME).uno.Manifest
+COMP2_UNOPKG_MANIFEST = $(OUT_COMP_CLASS)/$(COMP2_NAME)/META-INF/manifest.xml
+COMP2_COMPONENTS=$(COMP2_NAME).components
+
+COMP3_NAME=SampleThesaurus
+COMP3_PACKAGE = $(OUT_BIN)/$(COMP3_NAME).$(UNOOXT_EXT)
+COMP3_PACKAGE_URL = $(subst \\,\,"$(COMP_PACKAGE_DIR)$(PS)$(COMP3_NAME).$(UNOOXT_EXT)")
+COMP3_JAR_NAME = $(COMP3_NAME).uno.jar
+COMP3_JAR = $(OUT_COMP_CLASS)/$(COMP3_JAR_NAME)
+COMP3_MANIFESTFILE = $(OUT_COMP_CLASS)/$(COMP3_NAME).uno.Manifest
+COMP3_UNOPKG_MANIFEST = $(OUT_COMP_CLASS)/$(COMP3_NAME)/META-INF/manifest.xml
+COMP3_COMPONENTS=$(COMP2_NAME).components
+
+APP1_NAME=LinguisticExamples
+APP1_JAR=$(OUT_COMP_CLASS)/$(APP1_NAME).jar
+
+REGISTERFLAG = $(OUT_MISC)/devguide_officedevlinguistic_register_component.flag
+
+JAVAFILES = \
+ OneInstanceFactory.java \
+ PropChgHelper.java \
+ PropChgHelper_Hyph.java \
+ PropChgHelper_Spell.java \
+ XHyphenatedWord_impl.java \
+ XMeaning_impl.java \
+ XPossibleHyphens_impl.java \
+ XSpellAlternatives_impl.java \
+ SampleHyphenator.java \
+ SampleSpellChecker.java \
+ SampleThesaurus.java
+
+CLASSFILES = $(patsubst %.java,$(OUT_COMP_CLASS)/%.class,$(JAVAFILES))
+
+$(COMP1_NAME)_CLASSFILES = XHyphenatedWord_impl.class \
+ XPossibleHyphens_impl.class \
+ PropChgHelper.class \
+ PropChgHelper_Hyph.class \
+ OneInstanceFactory.class \
+ $(COMP1_NAME).class
+
+$(COMP2_NAME)_CLASSFILES = XSpellAlternatives_impl.class \
+ PropChgHelper_Spell.class \
+ PropChgHelper.class \
+ OneInstanceFactory.class \
+ $(COMP2_NAME).class
+
+$(COMP3_NAME)_CLASSFILES = XMeaning_impl.class \
+ OneInstanceFactory.class \
+ $(COMP3_NAME).class
+
+SDK_CLASSPATH = $(subst $(EMPTYSTRING) $(PATH_SEPARATOR),$(PATH_SEPARATOR),$(CLASSPATH)\
+ $(PATH_SEPARATOR)$(OUT_COMP_CLASS))
+
+.PHONY: ALL
+ALL : $(EXAMPLE_NAME)
+
+include $(SETTINGS)/stdtarget.mk
+
+$(OUT_COMP_CLASS)/%.Manifest :
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ @echo RegistrationClassName: $(basename $(basename $(@F)))> $@
+
+$(CLASSFILES) : $(JAVAFILES)
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ $(SDK_JAVAC) $(JAVAC_FLAGS) -classpath "$(SDK_CLASSPATH)" -d $(OUT_COMP_CLASS) $(JAVAFILES)
+
+# NOTE: because of gnu make problems with full qualified paths, the pattern
+# rules for the component jars and the packages doesn't work proper and we
+# defined explicit rules
+
+# rule for component package manifest
+$(OUT_COMP_CLASS)/%/manifest.xml :
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ @echo $(OSEP)?xml version="$(QM)1.0$(QM)" encoding="$(QM)UTF-8$(QM)"?$(CSEP) > $@
+ @echo $(OSEP)!DOCTYPE manifest:manifest PUBLIC "$(QM)-//OpenOffice.org//DTD Manifest 1.0//EN$(QM)" "$(QM)Manifest.dtd$(QM)"$(CSEP) >> $@
+ @echo $(OSEP)manifest:manifest xmlns:manifest="$(QM)http://openoffice.org/2001/manifest$(QM)"$(CSEP) >> $@
+ @echo $(SQM) $(SQM)$(OSEP)manifest:file-entry manifest:media-type="$(QM)application/vnd.sun.star.uno-components$(QM)" >> $@
+ @echo $(SQM) $(SQM)manifest:full-path="$(QM)$(subst /META-INF,,$(subst $(OUT_COMP_CLASS)/,,$(@D))).components$(QM)"/$(CSEP) >> $@
+ @echo $(OSEP)/manifest:manifest$(CSEP) >> $@
+
+$(COMP1_JAR) : $(COMP1_MANIFESTFILE) $(CLASSFILES)
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ cd $(subst /,$(PS),$(OUT_COMP_CLASS)) && $(SDK_JAR) cvfm $(@F) $(<F) $($(basename $(basename $(@F)))_CLASSFILES)
+
+$(COMP1_PACKAGE) : $(COMP1_JAR) $(COMP1_UNOPKG_MANIFEST) $(COMP1_COMPONENTS)
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ $(SDK_ZIP) $@ $(COMP1_COMPONENTS)
+ cd $(subst /,$(PS),$(OUT_COMP_CLASS)) && $(SDK_ZIP) -u ../../bin/$(@F) $(<F)
+ cd $(subst /,$(PS),$(OUT_COMP_CLASS)/$(subst .$(UNOOXT_EXT),,$(@F))) && $(SDK_ZIP) -u ../../../bin/$(@F) META-INF/manifest.xml
+
+$(COMP2_JAR) : $(COMP2_MANIFESTFILE) $(CLASSFILES)
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ cd $(subst /,$(PS),$(OUT_COMP_CLASS)) && $(SDK_JAR) cvfm $(@F) $(<F) $($(basename $(basename $(@F)))_CLASSFILES)
+
+$(COMP2_PACKAGE) : $(COMP2_JAR) $(COMP2_UNOPKG_MANIFEST) $(COMP2_COMPONENTS)
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ $(SDK_ZIP) $@ $(COMP2_COMPONENTS)
+ cd $(subst /,$(PS),$(OUT_COMP_CLASS)) && $(SDK_ZIP) -u ../../bin/$(@F) $(<F)
+ cd $(subst /,$(PS),$(OUT_COMP_CLASS)/$(subst .$(UNOOXT_EXT),,$(@F))) && $(SDK_ZIP) -u ../../../bin/$(@F) META-INF/manifest.xml
+
+$(COMP3_JAR) : $(COMP3_MANIFESTFILE) $(CLASSFILES)
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ cd $(subst /,$(PS),$(OUT_COMP_CLASS)) && $(SDK_JAR) cvfm $(@F) $(<F) $($(basename $(basename $(@F)))_CLASSFILES)
+
+$(COMP3_PACKAGE) : $(COMP3_JAR) $(COMP3_UNOPKG_MANIFEST) $(COMP3_COMPONENTS)
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ $(SDK_ZIP) $@ $(COMP3_COMPONENTS)
+ cd $(subst /,$(PS),$(OUT_COMP_CLASS)) && $(SDK_ZIP) -u ../../bin/$(@F) $(<F)
+ cd $(subst /,$(PS),$(OUT_COMP_CLASS)/$(subst .$(UNOOXT_EXT),,$(@F))) && $(SDK_ZIP) -u ../../../bin/$(@F) META-INF/manifest.xml
+
+$(REGISTERFLAG) : $(COMP1_PACKAGE) $(COMP2_PACKAGE) $(COMP3_PACKAGE)
+ifeq "$(SDK_AUTO_DEPLOYMENT)" "YES"
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
+ $(DEPLOYTOOL) $(COMP1_PACKAGE_URL)
+ $(DEPLOYTOOL) $(COMP2_PACKAGE_URL)
+ $(DEPLOYTOOL) $(COMP3_PACKAGE_URL)
+ @echo flagged > $(subst /,$(PS),$@)
+else
+ @echo --------------------------------------------------------------------------------
+ @echo If you want to install your component automatically, please set the environment
+ @echo variable SDK_AUTO_DEPLOYMENT = YES. But note that auto deployment is only
+ @echo possible if no office instance is running.
+ @echo --------------------------------------------------------------------------------
+endif
+
+$(OUT_COMP_CLASS)/%.class : %.java
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ $(SDK_JAVAC) $(JAVAC_FLAGS) -classpath "$(SDK_CLASSPATH)" -d $(OUT_COMP_CLASS) $<
+
+$(OUT_COMP_CLASS)/%.mf :
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ @echo Main-Class: com.sun.star.lib.loader.Loader> $@
+ $(ECHOLINE)>> $@
+ @echo Name: com/sun/star/lib/loader/Loader.class>> $@
+ @echo Application-Class: $*>> $@
+
+$(APP1_JAR) : $(OUT_COMP_CLASS)/$(APP1_NAME).mf $(OUT_COMP_CLASS)/$(APP1_NAME).class
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ +cd $(subst /,$(PS),$(OUT_COMP_CLASS)) && $(SDK_JAR) cvfm $(@F) $(basename $(@F)).mf $(basename $(@F)).class $(basename $(@F))$(QUOTE)$$Client.class
+ +$(SDK_JAR) uvf $@ $(SDK_JAVA_UNO_BOOTSTRAP_FILES)
+
+
+$(EXAMPLE_NAME) : $(REGISTERFLAG) $(APP1_JAR)
+ @echo --------------------------------------------------------------------------------
+ @echo Please use the following command to execute the example!
+ @echo -
+ @echo $(MAKE) $(APP1_NAME).run
+ @echo --------
+ @echo Before you can run the examples the components "$(QM)$(COMP1_NAME)$(QM)",
+ @echo "$(QM)$(COMP2_NAME)$(QM)" and "$(QM)$(COMP3_NAME)$(QM)" must be deployed.
+ @echo The components will be automatically deployed if SDK_AUTO_DEPLOYMENT = YES.
+ @echo --------------------------------------------------------------------------------
+
+%.run: $(OUT_COMP_CLASS)/%.jar
+ $(SDK_JAVA) -Dcom.sun.star.lib.loader.unopath="$(OFFICE_PROGRAM_PATH)" -jar $<
+
+.PHONY: clean
+clean :
+ -$(DELRECURSIVE) $(subst /,$(PS),$(OUT_COMP_CLASS))
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$(COMP1_PACKAGE_URL)))
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$(COMP2_PACKAGE_URL)))
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$(COMP3_PACKAGE_URL)))
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$(REGISTERFLAG)))
diff --git a/odk/examples/DevelopersGuide/OfficeDev/Linguistic/OneInstanceFactory.java b/odk/examples/DevelopersGuide/OfficeDev/Linguistic/OneInstanceFactory.java
new file mode 100644
index 000000000..5e1fdd60b
--- /dev/null
+++ b/odk/examples/DevelopersGuide/OfficeDev/Linguistic/OneInstanceFactory.java
@@ -0,0 +1,155 @@
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+import com.sun.star.lang.XSingleComponentFactory;
+import com.sun.star.lang.XServiceInfo;
+import com.sun.star.lang.XInitialization;
+import com.sun.star.beans.XPropertySet;
+import com.sun.star.uno.XComponentContext;
+import com.sun.star.uno.XInterface;
+import com.sun.star.uno.UnoRuntime;
+
+import java.lang.reflect.Constructor;
+
+
+// purpose of this class is to provide a service factory that instantiates
+// the services only once (as long as this factory itself exists)
+// and returns only reference to that instance.
+
+
+public class OneInstanceFactory implements
+ XSingleComponentFactory,
+ XServiceInfo
+{
+ private final Class aMyClass;
+ private final String aSvcImplName;
+ private final String[] aSupportedSvcNames;
+ private XInterface xInstantiatedService;
+
+ public OneInstanceFactory(
+ Class aMyClass,
+ String aSvcImplName,
+ String[] aSupportedSvcNames )
+ {
+ this.aMyClass = aMyClass;
+ this.aSvcImplName = aSvcImplName;
+ this.aSupportedSvcNames = aSupportedSvcNames;
+ xInstantiatedService = null;
+ }
+
+
+ // XSingleComponentFactory
+
+ public Object createInstanceWithContext( XComponentContext context )
+ throws com.sun.star.uno.Exception,
+ com.sun.star.uno.RuntimeException
+ {
+ if (xInstantiatedService == null)
+ {
+ //!! the here used services all have exact one constructor!!
+ Constructor [] aCtor = aMyClass.getConstructors();
+ try {
+ xInstantiatedService = (XInterface) aCtor[0].newInstance( (Object[])null );
+ }
+ catch( Exception e ) {
+ }
+
+ //!! workaround for services not always being created
+ //!! via 'createInstanceWithArguments'
+ XInitialization xIni = UnoRuntime.queryInterface(
+ XInitialization.class, createInstanceWithContext(context));
+ if (xIni != null)
+ {
+ Object[] aArguments = new Object[]{ null, null };
+ if (context != null)
+ {
+ XPropertySet xPropSet = UnoRuntime.queryInterface(
+ XPropertySet.class,
+ context.getServiceManager().createInstanceWithContext(
+ "com.sun.star.linguistic2.LinguProperties",
+ context ) );
+ aArguments[0] = xPropSet;
+ }
+ xIni.initialize( aArguments );
+ }
+ }
+ return xInstantiatedService;
+ }
+
+ public Object createInstanceWithArgumentsAndContext( Object[] aArguments, XComponentContext context )
+ throws com.sun.star.uno.Exception,
+ com.sun.star.uno.RuntimeException
+ {
+ if (xInstantiatedService == null)
+ {
+ XInitialization xIni = UnoRuntime.queryInterface(
+ XInitialization.class, createInstanceWithContext( context ));
+ if (xIni != null)
+ xIni.initialize( aArguments );
+ }
+ return xInstantiatedService;
+ }
+
+
+
+ // XServiceInfo
+
+ public boolean supportsService( String aServiceName )
+ throws com.sun.star.uno.RuntimeException
+ {
+ boolean bFound = false;
+ int nCnt = aSupportedSvcNames.length;
+ for (int i = 0; i < nCnt && !bFound; ++i)
+ {
+ if (aServiceName.equals( aSupportedSvcNames[i] ))
+ bFound = true;
+ }
+ return bFound;
+ }
+
+ public String getImplementationName()
+ throws com.sun.star.uno.RuntimeException
+ {
+ return aSvcImplName;
+ }
+
+ public String[] getSupportedServiceNames()
+ throws com.sun.star.uno.RuntimeException
+ {
+ return aSupportedSvcNames;
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/OfficeDev/Linguistic/PropChgHelper.java b/odk/examples/DevelopersGuide/OfficeDev/Linguistic/PropChgHelper.java
new file mode 100644
index 000000000..46fcff061
--- /dev/null
+++ b/odk/examples/DevelopersGuide/OfficeDev/Linguistic/PropChgHelper.java
@@ -0,0 +1,193 @@
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+import com.sun.star.linguistic2.XLinguServiceEventBroadcaster;
+import com.sun.star.linguistic2.XLinguServiceEventListener;
+import com.sun.star.linguistic2.LinguServiceEvent;
+import com.sun.star.beans.XPropertySet;
+import com.sun.star.beans.XPropertyChangeListener;
+import com.sun.star.beans.PropertyChangeEvent;
+import com.sun.star.lang.EventObject;
+import com.sun.star.uno.XInterface;
+
+import java.util.ArrayList;
+
+public class PropChgHelper implements
+ XPropertyChangeListener,
+ XLinguServiceEventBroadcaster
+{
+ private final XInterface xEvtSource;
+ private final String[] aPropNames;
+ private XPropertySet xPropSet;
+ private final ArrayList<XLinguServiceEventListener> aLngSvcEvtListeners;
+
+ public PropChgHelper(
+ XInterface xEvtSource,
+ String[] aPropNames )
+ {
+ this.xEvtSource = xEvtSource;
+ this.aPropNames = aPropNames;
+ xPropSet = null;
+ aLngSvcEvtListeners = new ArrayList<XLinguServiceEventListener>();
+ }
+
+ public XInterface GetEvtSource()
+ {
+ return xEvtSource;
+ }
+
+ public XPropertySet GetPropSet()
+ {
+ return xPropSet;
+ }
+
+
+
+ public void LaunchEvent( LinguServiceEvent aEvt )
+ {
+ int nCnt = aLngSvcEvtListeners.size();
+ for (int i = 0; i < nCnt; ++i)
+ {
+ XLinguServiceEventListener xLstnr =
+ aLngSvcEvtListeners.get(i);
+ if (xLstnr != null)
+ xLstnr.processLinguServiceEvent( aEvt );
+ }
+ }
+
+ public void AddAsListenerTo( XPropertySet xPropertySet )
+ {
+ // do not listen any longer to the old property set (if any)
+ RemoveAsListener();
+
+ // set new property set to be used and register as listener to it
+ xPropSet = xPropertySet;
+ if (xPropSet != null)
+ {
+ int nLen = aPropNames.length;
+ for (int i = 0; i < nLen; ++i)
+ {
+ if (aPropNames[i].length() != 0)
+ {
+ try {
+ xPropSet.addPropertyChangeListener(
+ aPropNames[i], this );
+ }
+ catch( Exception e ) {
+ }
+ }
+ }
+ }
+ }
+
+ private void RemoveAsListener()
+ {
+ if (xPropSet != null)
+ {
+ int nLen = aPropNames.length;
+ for (int i = 0; i < nLen; ++i)
+ {
+ if (aPropNames[i].length() != 0)
+ {
+ try {
+ xPropSet.removePropertyChangeListener(
+ aPropNames[i], this );
+ }
+ catch( Exception e ) {
+ }
+ }
+ }
+
+ xPropSet = null;
+ }
+ }
+
+ // __________ interface methods __________
+
+
+ // XEventListener
+
+ public void disposing( EventObject aSource )
+ throws com.sun.star.uno.RuntimeException
+ {
+ if (aSource.Source == xPropSet)
+ {
+ RemoveAsListener();
+ }
+ }
+
+
+ // XPropertyChangeListener
+
+ public void propertyChange( PropertyChangeEvent aEvt )
+ throws com.sun.star.uno.RuntimeException
+ {
+ // will be overridden in derived classes
+ }
+
+
+ // XLinguServiceEventBroadcaster
+
+ public boolean addLinguServiceEventListener(
+ XLinguServiceEventListener xListener )
+ throws com.sun.star.uno.RuntimeException
+ {
+ boolean bRes = false;
+ if (xListener != null)
+ {
+ bRes = aLngSvcEvtListeners.add( xListener );
+ }
+ return bRes;
+ }
+
+ public boolean removeLinguServiceEventListener(
+ XLinguServiceEventListener xListener )
+ throws com.sun.star.uno.RuntimeException
+ {
+ boolean bRes = false;
+ if (xListener != null)
+ {
+ int nIdx = aLngSvcEvtListeners.indexOf( xListener );
+ if (nIdx != -1)
+ {
+ aLngSvcEvtListeners.remove( nIdx );
+ bRes = true;
+ }
+ }
+ return bRes;
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/OfficeDev/Linguistic/PropChgHelper_Hyph.java b/odk/examples/DevelopersGuide/OfficeDev/Linguistic/PropChgHelper_Hyph.java
new file mode 100644
index 000000000..0945e413f
--- /dev/null
+++ b/odk/examples/DevelopersGuide/OfficeDev/Linguistic/PropChgHelper_Hyph.java
@@ -0,0 +1,81 @@
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+import com.sun.star.linguistic2.LinguServiceEvent;
+import com.sun.star.linguistic2.LinguServiceEventFlags;
+import com.sun.star.beans.PropertyChangeEvent;
+import com.sun.star.uno.XInterface;
+
+public class PropChgHelper_Hyph extends PropChgHelper
+{
+ public PropChgHelper_Hyph(
+ XInterface xEvtSource,
+ String[] aPropNames )
+ {
+ super( xEvtSource, aPropNames );
+ }
+
+
+ // XPropertyChangeListener
+
+ @Override
+ public void propertyChange( PropertyChangeEvent aEvt )
+ throws com.sun.star.uno.RuntimeException
+ {
+ {
+ short nLngSvcFlags = 0;
+ if (aEvt.PropertyName.equals( "IsIgnoreControlCharacters" ))
+ {
+ // nothing to be done
+ }
+ else if (aEvt.PropertyName.equals( "IsUseDictionaryList" ) ||
+ aEvt.PropertyName.equals( "IsGermanPreReform" ) ||
+ aEvt.PropertyName.equals( "HyphMinLeading" ) ||
+ aEvt.PropertyName.equals( "HyphMinTrailing" ) ||
+ aEvt.PropertyName.equals( "HyphMinWordLength" ))
+ {
+ nLngSvcFlags = LinguServiceEventFlags.HYPHENATE_AGAIN;
+ }
+
+ if (nLngSvcFlags != 0)
+ {
+ LinguServiceEvent aEvent = new LinguServiceEvent( GetEvtSource(), nLngSvcFlags );
+ LaunchEvent( aEvent );
+ }
+ }
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/OfficeDev/Linguistic/PropChgHelper_Spell.java b/odk/examples/DevelopersGuide/OfficeDev/Linguistic/PropChgHelper_Spell.java
new file mode 100644
index 000000000..edd0498db
--- /dev/null
+++ b/odk/examples/DevelopersGuide/OfficeDev/Linguistic/PropChgHelper_Spell.java
@@ -0,0 +1,105 @@
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+import com.sun.star.linguistic2.LinguServiceEvent;
+import com.sun.star.linguistic2.LinguServiceEventFlags;
+import com.sun.star.beans.PropertyChangeEvent;
+import com.sun.star.uno.XInterface;
+
+public class PropChgHelper_Spell extends PropChgHelper
+{
+ public PropChgHelper_Spell(
+ XInterface xEvtSource,
+ String[] aPropNames )
+ {
+ super( xEvtSource, aPropNames );
+ }
+
+
+ // XPropertyChangeListener
+
+ @Override
+ public void propertyChange( PropertyChangeEvent aEvt )
+ throws com.sun.star.uno.RuntimeException
+ {
+ {
+ short nLngSvcFlags = 0;
+ boolean bSCWA = false; // SPELL_CORRECT_WORDS_AGAIN ?
+ boolean bSWWA = false; // SPELL_WRONG_WORDS_AGAIN ?
+
+ boolean bVal = ((Boolean) aEvt.NewValue).booleanValue();
+
+ if (aEvt.PropertyName.equals( "IsIgnoreControlCharacters" ))
+ {
+ // nothing to be done
+ }
+ else if (aEvt.PropertyName.equals( "IsGermanPreReform" ))
+ {
+ bSCWA = bSWWA = true;
+ }
+ else if (aEvt.PropertyName.equals( "IsUseDictionaryList" ))
+ {
+ bSCWA = bSWWA = true;
+ }
+ else if (aEvt.PropertyName.equals( "IsSpellUpperCase" ))
+ {
+ bSCWA = !bVal; // FALSE->TRUE change?
+ bSWWA = !bSCWA; // TRUE->FALSE change?
+ }
+ else if (aEvt.PropertyName.equals( "IsSpellWithDigits" ))
+ {
+ bSCWA = !bVal; // FALSE->TRUE change?
+ bSWWA = !bSCWA; // TRUE->FALSE change?
+ }
+ else if (aEvt.PropertyName.equals( "IsSpellCapitalization" ))
+ {
+ bSCWA = !bVal; // FALSE->TRUE change?
+ bSWWA = !bSCWA; // TRUE->FALSE change?
+ }
+
+ if (bSCWA)
+ nLngSvcFlags |= LinguServiceEventFlags.SPELL_CORRECT_WORDS_AGAIN;
+ if (bSWWA)
+ nLngSvcFlags |= LinguServiceEventFlags.SPELL_WRONG_WORDS_AGAIN;
+ if (nLngSvcFlags != 0)
+ {
+ LinguServiceEvent aEvent = new LinguServiceEvent( GetEvtSource(), nLngSvcFlags );
+ LaunchEvent( aEvent );
+ }
+ }
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/OfficeDev/Linguistic/SampleHyphenator.components b/odk/examples/DevelopersGuide/OfficeDev/Linguistic/SampleHyphenator.components
new file mode 100644
index 000000000..bf083b386
--- /dev/null
+++ b/odk/examples/DevelopersGuide/OfficeDev/Linguistic/SampleHyphenator.components
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<components xmlns="http://openoffice.org/2010/uno-components">
+ <component loader="com.sun.star.loader.Java2" uri="SampleHyphenator.uno.jar">
+ <implementation name="SampleHyphenator">
+ <service name="com.sun.star.linguistic2.Hyphenator"/>
+ </implementation>
+ </component>
+</components>
diff --git a/odk/examples/DevelopersGuide/OfficeDev/Linguistic/SampleHyphenator.java b/odk/examples/DevelopersGuide/OfficeDev/Linguistic/SampleHyphenator.java
new file mode 100644
index 000000000..930d42c32
--- /dev/null
+++ b/odk/examples/DevelopersGuide/OfficeDev/Linguistic/SampleHyphenator.java
@@ -0,0 +1,514 @@
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+// uno
+import com.sun.star.lib.uno.helper.ComponentBase;
+import com.sun.star.uno.UnoRuntime;
+
+// factories
+import com.sun.star.lang.XSingleComponentFactory;
+
+// supported Interfaces
+import com.sun.star.linguistic2.XHyphenator;
+import com.sun.star.linguistic2.XLinguServiceEventBroadcaster;
+import com.sun.star.lang.XInitialization;
+import com.sun.star.lang.XServiceInfo;
+import com.sun.star.lang.XServiceDisplayName;
+
+// Exceptions
+import com.sun.star.uno.Exception;
+import com.sun.star.lang.IllegalArgumentException;
+
+//used Interfaces
+import com.sun.star.linguistic2.XLinguServiceEventListener;
+import com.sun.star.linguistic2.XHyphenatedWord;
+import com.sun.star.linguistic2.XPossibleHyphens;
+import com.sun.star.lang.Locale;
+import com.sun.star.beans.XPropertySet;
+import com.sun.star.beans.PropertyValue;
+import com.sun.star.uno.AnyConverter;
+import java.util.ArrayList;
+
+public class SampleHyphenator extends ComponentBase implements
+ XHyphenator,
+ XLinguServiceEventBroadcaster,
+ XInitialization,
+ XServiceDisplayName,
+ XServiceInfo
+{
+ PropChgHelper_Hyph aPropChgHelper;
+ ArrayList<?> aEvtListeners;
+ boolean bDisposing;
+
+ public SampleHyphenator()
+ {
+ // names of relevant properties to be used
+ String[] aProps = new String[]
+ {
+ "IsIgnoreControlCharacters",
+ "IsUseDictionaryList",
+ "IsGermanPreReform",
+ "HyphMinLeading",
+ "HyphMinTrailing",
+ "HyphMinWordLength"
+ };
+ aPropChgHelper = new PropChgHelper_Hyph( this, aProps );
+ aEvtListeners = new ArrayList<Object>();
+ bDisposing = false;
+ }
+
+ private boolean IsEqual( Locale aLoc1, Locale aLoc2 )
+ {
+ return aLoc1.Language.equals( aLoc2.Language ) &&
+ aLoc1.Country .equals( aLoc2.Country ) &&
+ aLoc1.Variant .equals( aLoc2.Variant );
+ }
+
+ private boolean GetValueToUse(
+ String aPropName,
+ boolean bDefaultVal,
+ PropertyValue[] aProps )
+ {
+ boolean bRes = bDefaultVal;
+
+ try
+ {
+ // use temporary value if supplied
+ for (int i = 0; i < aProps.length; ++i)
+ {
+ if (aPropName.equals( aProps[i].Name ))
+ {
+ Object aObj = aProps[i].Value;
+ if (AnyConverter.isBoolean( aObj ))
+ {
+ bRes = AnyConverter.toBoolean( aObj );
+ return bRes;
+ }
+ }
+ }
+
+ // otherwise use value from property set (if available)
+ XPropertySet xPropSet = aPropChgHelper.GetPropSet();
+ if (xPropSet != null) // should always be the case
+ {
+ Object aObj = xPropSet.getPropertyValue( aPropName );
+ if (AnyConverter.isBoolean( aObj ))
+ bRes = AnyConverter.toBoolean( aObj );
+ }
+ }
+ catch (Exception e) {
+ bRes = bDefaultVal;
+ }
+
+ return bRes;
+ }
+
+ private short GetValueToUse(
+ String aPropName,
+ short nDefaultVal,
+ PropertyValue[] aProps )
+ {
+ short nRes = nDefaultVal;
+
+ try
+ {
+ // use temporary value if supplied
+ for (int i = 0; i < aProps.length; ++i)
+ {
+ if (aPropName.equals( aProps[i].Name ))
+ {
+ Object aObj = aProps[i].Value;
+ if (AnyConverter.isShort( aObj ))
+ {
+ nRes = AnyConverter.toShort( aObj );
+ return nRes;
+ }
+ }
+ }
+
+ // otherwise use value from property set (if available)
+ XPropertySet xPropSet = aPropChgHelper.GetPropSet();
+ if (xPropSet != null) // should always be the case
+ {
+ Object aObj = xPropSet.getPropertyValue( aPropName );
+ if (AnyConverter.isShort( aObj ))
+ nRes = AnyConverter.toShort( aObj );
+ }
+ }
+ catch (Exception e) {
+ nRes = nDefaultVal;
+ }
+
+ return nRes;
+ }
+
+ // __________ interface methods __________
+
+
+
+ //XSupportedLocales
+
+ public Locale[] getLocales()
+ throws com.sun.star.uno.RuntimeException
+ {
+ Locale aLocales[] =
+ {
+ new Locale( "de", "DE", "" ),
+ new Locale( "en", "US", "" )
+ };
+
+ return aLocales;
+ }
+
+ public boolean hasLocale( Locale aLocale )
+ throws com.sun.star.uno.RuntimeException
+ {
+ boolean bRes = false;
+ if ( IsEqual( aLocale, new Locale( "de", "DE", "" ) ) ||
+ IsEqual( aLocale, new Locale( "en", "US", "" ) ))
+ bRes = true;
+ return bRes;
+ }
+
+
+ //XHyphenator
+
+ public XHyphenatedWord hyphenate(
+ String aWord, Locale aLocale,
+ short nMaxLeading, PropertyValue[] aProperties )
+ throws com.sun.star.uno.RuntimeException,
+ IllegalArgumentException
+ {
+ if (IsEqual( aLocale, new Locale() ) || aWord.length() == 0)
+ return null;
+
+ // linguistic is currently not allowed to throw exceptions
+ // thus we return null fwhich means 'word cannot be hyphenated'
+ if (!hasLocale( aLocale ))
+ return null;
+
+ // get values of relevant properties that may be used.
+ //! The values for 'IsIgnoreControlCharacters' and 'IsUseDictionaryList'
+ //! are handled by the dispatcher! Thus there is no need to access
+ //! them here.
+ boolean bIsIgnoreControlCharacters = GetValueToUse( "IsIgnoreControlCharacters", true, aProperties );
+ boolean bIsUseDictionaryList = GetValueToUse( "IsUseDictionaryList", true, aProperties );
+ boolean bIsGermanPreReform = GetValueToUse( "IsGermanPreReform", false, aProperties );
+ short nHyphMinLeading = GetValueToUse( "HyphMinLeading", (short)2, aProperties );
+ short nHyphMinTrailing = GetValueToUse( "HyphMinTrailing", (short)2, aProperties );
+ short nHyphMinWordLen = GetValueToUse( "HyphMinWordLength", (short)5, aProperties );
+
+ XHyphenatedWord xRes = null;
+
+ if (aWord.length() >= nHyphMinWordLen)
+ {
+ String aHyphenatedWord = aWord;
+ short nHyphenationPos = -1;
+ short nHyphenPos = -1;
+
+ //!! This code needs to be replaced by code calling the actual
+ //!! implementation of your hyphenator
+ if (IsEqual( aLocale, new Locale( "de", "DE", "" ) ) )
+ {
+ if (bIsGermanPreReform && aWord.equals( "Schiffahrt" ))
+ {
+ // Note: there is only one position where the word
+ // can be hyphenated...
+
+ aHyphenatedWord = "Schifffahrt";
+ nHyphenationPos = 4;
+ nHyphenPos = 5;
+ }
+ else if (!bIsGermanPreReform && aWord.equals( "Schifffahrt" ))
+ {
+ nHyphenationPos = nHyphenPos = 5;
+ }
+ }
+ else if (IsEqual( aLocale, new Locale( "en", "US", "" ) ) )
+ {
+ int nLast = aWord.length() - 1 - nHyphMinTrailing;
+
+ if ( aWord.equals( "waterfall" ) )
+ {
+ if (4 <= nLast)
+ nHyphenationPos = nHyphenPos = 4;
+ else
+ nHyphenationPos = nHyphenPos = 1;
+ }
+ else if ( aWord.equals( "driving" ) )
+ {
+ nHyphenationPos = nHyphenPos = 3;
+ }
+ }
+
+ // check if hyphenation pos is valid,
+ // a value of -1 indicates that hyphenation is not possible
+ if ( nHyphenationPos != -1 &&
+ (nHyphenationPos > nHyphMinLeading) &&
+ (nHyphenationPos < aWord.length() - nHyphMinTrailing))
+ {
+ xRes = new XHyphenatedWord_impl(aWord, aLocale,
+ nHyphenationPos, aHyphenatedWord, nHyphenPos);
+ }
+ }
+ return xRes;
+ }
+
+ public XHyphenatedWord queryAlternativeSpelling(
+ String aWord, Locale aLocale,
+ short nIndex, PropertyValue[] aProperties )
+ throws com.sun.star.uno.RuntimeException,
+ IllegalArgumentException
+ {
+ if (IsEqual( aLocale, new Locale() ) || aWord.length() == 0)
+ return null;
+
+ // linguistic is currently not allowed to throw exceptions
+ // thus we return null which means 'word cannot be hyphenated'
+ if (!hasLocale( aLocale ))
+ return null;
+
+ // get values of relevant properties that may be used.
+ //! The values for 'IsIgnoreControlCharacters' and 'IsUseDictionaryList'
+ //! are handled by the dispatcher! Thus there is no need to access
+ //! them here.
+ boolean bIsIgnoreControlCharacters = GetValueToUse( "IsIgnoreControlCharacters", true, aProperties );
+ boolean bIsUseDictionaryList = GetValueToUse( "IsUseDictionaryList", true, aProperties );
+ boolean bIsGermanPreReform = GetValueToUse( "IsGermanPreReform", false, aProperties );
+ short nHyphMinLeading = GetValueToUse( "HyphMinLeading", (short)2, aProperties );
+ short nHyphMinTrailing = GetValueToUse( "HyphMinTrailing", (short)2, aProperties );
+ short nHyphMinWordLen = GetValueToUse( "HyphMinWordLength", (short)5, aProperties );
+
+ XHyphenatedWord xRes = null;
+
+ //!! This code needs to be replaced by code calling the actual
+ //!! implementation of your hyphenator
+ if ( IsEqual( aLocale, new Locale( "de", "DE", "" ) ) )
+ {
+ // there is an alternative spelling only when the
+ // word is hyphenated between the "ff" and old german spelling
+ // is set.
+ if (aWord.equals( "Schiffahrt" ) &&
+ bIsGermanPreReform && nIndex == 4)
+ {
+ xRes = new XHyphenatedWord_impl(aWord, aLocale,
+ (short)4, "Schifffahrt", (short)5 );
+ }
+ }
+ else if ( IsEqual( aLocale, new Locale( "en", "US", "" ) ) )
+ {
+ // There are no alternative spellings in the English language
+ }
+
+ return xRes;
+ }
+
+ public XPossibleHyphens createPossibleHyphens(
+ String aWord, Locale aLocale,
+ PropertyValue[] aProperties )
+ throws com.sun.star.uno.RuntimeException,
+ IllegalArgumentException
+ {
+ if (IsEqual( aLocale, new Locale() ) || aWord.length() == 0)
+ return null;
+
+ // linguistic is currently not allowed to throw exceptions
+ // thus we return null which means 'word cannot be hyphenated'
+ if (!hasLocale( aLocale ))
+ return null;
+
+ // get values of relevant properties that may be used.
+ //! The values for 'IsIgnoreControlCharacters' and 'IsUseDictionaryList'
+ //! are handled by the dispatcher! Thus there is no need to access
+ //! them here.
+ boolean bIsIgnoreControlCharacters = GetValueToUse( "IsIgnoreControlCharacters", true, aProperties );
+ boolean bIsUseDictionaryList = GetValueToUse( "IsUseDictionaryList", true, aProperties );
+ boolean bIsGermanPreReform = GetValueToUse( "IsGermanPreReform", false, aProperties );
+ short nHyphMinLeading = GetValueToUse( "HyphMinLeading", (short)2, aProperties );
+ short nHyphMinTrailing = GetValueToUse( "HyphMinTrailing", (short)2, aProperties );
+ short nHyphMinWordLen = GetValueToUse( "HyphMinWordLength", (short)5, aProperties );
+
+ XPossibleHyphens xRes = null;
+
+ //!! This code needs to be replaced by code calling the actual
+ //!! implementation of your hyphenator
+ if ( IsEqual( aLocale, new Locale( "de", "DE", "" ) ) )
+ {
+ if (bIsGermanPreReform && aWord.equals( "Schiffahrt" ))
+ {
+ short aPos[] = new short[] { (short) 4 };
+ xRes = new XPossibleHyphens_impl(aWord, aLocale,
+ "Schiff=fahrt", aPos);
+ }
+ else if (!bIsGermanPreReform && aWord.equals( "Schifffahrt" ))
+ {
+ short aPos[] = new short[] { (short) 5 };
+ xRes = new XPossibleHyphens_impl(aWord, aLocale,
+ "Schiff=fahrt", aPos);
+ }
+ }
+ else if ( IsEqual( aLocale, new Locale( "en", "US", "" ) ) )
+ {
+ if ( aWord.equals( "waterfall" ) )
+ {
+ short aPos[] = new short[]
+ { (short) 1, (short) 4 };
+ xRes = new XPossibleHyphens_impl(aWord, aLocale,
+ "wa=ter=fall", aPos);
+ }
+ else if ( aWord.equals( "driving" ) )
+ {
+ short aPos[] = new short[]
+ { (short) 3 };
+ xRes = new XPossibleHyphens_impl(aWord, aLocale,
+ "driv=ing", aPos);
+ }
+ }
+
+ return xRes;
+ }
+
+
+ //XLinguServiceEventBroadcaster
+
+ public boolean addLinguServiceEventListener (
+ XLinguServiceEventListener xLstnr )
+ throws com.sun.star.uno.RuntimeException
+ {
+ boolean bRes = false;
+ if (!bDisposing && xLstnr != null)
+ bRes = aPropChgHelper.addLinguServiceEventListener( xLstnr );
+ return bRes;
+ }
+
+ public boolean removeLinguServiceEventListener(
+ XLinguServiceEventListener xLstnr )
+ throws com.sun.star.uno.RuntimeException
+ {
+ boolean bRes = false;
+ if (!bDisposing && xLstnr != null)
+ bRes = aPropChgHelper.removeLinguServiceEventListener( xLstnr );
+ return bRes;
+ }
+
+
+ // XServiceDisplayName
+
+ public String getServiceDisplayName( Locale aLocale )
+ throws com.sun.star.uno.RuntimeException
+ {
+ return "Java Samples";
+ }
+
+
+ // XInitialization
+
+ public void initialize( Object[] aArguments )
+ throws com.sun.star.uno.Exception,
+ com.sun.star.uno.RuntimeException
+ {
+ int nLen = aArguments.length;
+ if (2 == nLen)
+ {
+ XPropertySet xPropSet = UnoRuntime.queryInterface(
+ XPropertySet.class, aArguments[0]);
+ // start listening to property changes
+ aPropChgHelper.AddAsListenerTo( xPropSet );
+ }
+ }
+
+
+
+ // XServiceInfo
+
+ public boolean supportsService( String aServiceName )
+ throws com.sun.star.uno.RuntimeException
+ {
+ String[] aServices = getSupportedServiceNames_Static();
+ int i, nLength = aServices.length;
+ boolean bResult = false;
+
+ for( i = 0; !bResult && i < nLength; ++i )
+ bResult = aServiceName.equals( aServices[ i ] );
+
+ return bResult;
+ }
+
+ public String getImplementationName()
+ throws com.sun.star.uno.RuntimeException
+ {
+ return _aSvcImplName;
+ }
+
+ public String[] getSupportedServiceNames()
+ throws com.sun.star.uno.RuntimeException
+ {
+ return getSupportedServiceNames_Static();
+ }
+
+ // __________ static things __________
+
+ public static String _aSvcImplName = SampleHyphenator.class.getName();
+
+ public static String[] getSupportedServiceNames_Static()
+ {
+ String[] aResult = { "com.sun.star.linguistic2.Hyphenator" };
+ return aResult;
+ }
+
+
+ /**
+ * Returns a factory for creating the service.
+ * This method is called by the <code>JavaLoader</code>
+ * <p>
+ * @return returns a <code>XComponentServiceFactory</code> for creating the component
+ * @param aImplName the name of the implementation for which a service is desired
+ * @see com.sun.star.comp.loader.JavaLoader
+ */
+ public static XSingleComponentFactory __getComponentFactory(
+ String aImplName )
+ {
+ XSingleComponentFactory xSingleComponentFactory = null;
+ if( aImplName.equals( _aSvcImplName ) )
+ {
+ xSingleComponentFactory = new OneInstanceFactory(
+ SampleHyphenator.class, _aSvcImplName,
+ getSupportedServiceNames_Static() );
+ }
+ return xSingleComponentFactory;
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/OfficeDev/Linguistic/SampleSpellChecker.components b/odk/examples/DevelopersGuide/OfficeDev/Linguistic/SampleSpellChecker.components
new file mode 100644
index 000000000..bb489918b
--- /dev/null
+++ b/odk/examples/DevelopersGuide/OfficeDev/Linguistic/SampleSpellChecker.components
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<components xmlns="http://openoffice.org/2010/uno-components">
+ <component loader="com.sun.star.loader.Java2" uri="SampleSpellChecker.uno.jar">
+ <implementation name="SampleSpellChecker">
+ <service name="com.sun.star.linguistic2.SpellChecker"/>
+ </implementation>
+ </component>
+</components>
diff --git a/odk/examples/DevelopersGuide/OfficeDev/Linguistic/SampleSpellChecker.java b/odk/examples/DevelopersGuide/OfficeDev/Linguistic/SampleSpellChecker.java
new file mode 100644
index 000000000..dc7ddfddd
--- /dev/null
+++ b/odk/examples/DevelopersGuide/OfficeDev/Linguistic/SampleSpellChecker.java
@@ -0,0 +1,457 @@
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+// uno
+import com.sun.star.lib.uno.helper.ComponentBase;
+import com.sun.star.uno.UnoRuntime;
+
+// factories
+import com.sun.star.lang.XSingleComponentFactory;
+
+// supported Interfaces
+import com.sun.star.linguistic2.XSpellChecker;
+import com.sun.star.linguistic2.XLinguServiceEventBroadcaster;
+import com.sun.star.lang.XInitialization;
+import com.sun.star.lang.XServiceInfo;
+import com.sun.star.lang.XServiceDisplayName;
+
+// Exceptions
+import com.sun.star.uno.Exception;
+import com.sun.star.lang.IllegalArgumentException;
+
+//used Interfaces
+import com.sun.star.linguistic2.XLinguServiceEventListener;
+import com.sun.star.linguistic2.XSpellAlternatives;
+import com.sun.star.linguistic2.SpellFailure;
+import com.sun.star.lang.Locale;
+import com.sun.star.beans.XPropertySet;
+import com.sun.star.beans.PropertyValue;
+import com.sun.star.uno.AnyConverter;
+import java.util.ArrayList;
+
+public class SampleSpellChecker extends ComponentBase implements
+ XSpellChecker,
+ XLinguServiceEventBroadcaster,
+ XInitialization,
+ XServiceDisplayName,
+ XServiceInfo
+{
+ PropChgHelper_Spell aPropChgHelper;
+ ArrayList<?> aEvtListeners;
+ boolean bDisposing;
+
+ public SampleSpellChecker()
+ {
+ // names of relevant properties to be used
+ String[] aProps = new String[]
+ {
+ "IsIgnoreControlCharacters",
+ "IsUseDictionaryList",
+ "IsGermanPreReform",
+ "IsSpellUpperCase",
+ "IsSpellWithDigits",
+ "IsSpellCapitalization"
+ };
+ aPropChgHelper = new PropChgHelper_Spell( this, aProps );
+ aEvtListeners = new ArrayList<Object>();
+ bDisposing = false;
+ }
+
+ private boolean IsEqual( Locale aLoc1, Locale aLoc2 )
+ {
+ return aLoc1.Language.equals( aLoc2.Language ) &&
+ aLoc1.Country .equals( aLoc2.Country ) &&
+ aLoc1.Variant .equals( aLoc2.Variant );
+ }
+
+ private boolean GetValueToUse(
+ String aPropName,
+ boolean bDefaultVal,
+ PropertyValue[] aProps )
+ {
+ boolean bRes = bDefaultVal;
+
+ try
+ {
+ // use temporary value if supplied
+ for (int i = 0; i < aProps.length; ++i)
+ {
+ if (aPropName.equals( aProps[i].Name ))
+ {
+ Object aObj = aProps[i].Value;
+ if (AnyConverter.isBoolean( aObj ))
+ {
+ bRes = AnyConverter.toBoolean( aObj );
+ return bRes;
+ }
+ }
+ }
+
+ // otherwise use value from property set (if available)
+ XPropertySet xPropSet = aPropChgHelper.GetPropSet();
+ if (xPropSet != null) // should always be the case
+ {
+ Object aObj = xPropSet.getPropertyValue( aPropName );
+ if (AnyConverter.isBoolean( aObj ))
+ bRes = AnyConverter.toBoolean( aObj );
+ }
+ }
+ catch (Exception e) {
+ bRes = bDefaultVal;
+ }
+
+ return bRes;
+ }
+
+ private boolean IsUpper( String aWord, Locale aLocale )
+ {
+ java.util.Locale aLang = new java.util.Locale(
+ aLocale.Language, aLocale.Country, aLocale.Variant );
+ return aWord.equals( aWord.toUpperCase( aLang ) );
+ }
+
+ private boolean HasDigits( String aWord )
+ {
+ int nLen = aWord.length();
+ for (int i = 0; i < nLen; ++i)
+ {
+ if (Character.isDigit( aWord.charAt(i) ))
+ return true;
+ }
+ return false;
+ }
+
+ private short GetSpellFailure(
+ String aWord,
+ Locale aLocale,
+ PropertyValue[] aProperties )
+ {
+ short nRes = -1;
+
+ //!! This code needs to be replaced by code calling the actual
+ //!! implementation of your spellchecker
+ boolean bIsGermanPreReform = GetValueToUse( "IsGermanPreReform", false, aProperties );
+ if (IsEqual( aLocale, new Locale( "de", "DE", "" ) ))
+ {
+ if (bIsGermanPreReform && aWord.equals( "Schifffahrt" ))
+ nRes = SpellFailure.SPELLING_ERROR;
+ else if (!bIsGermanPreReform && aWord.equals( "Schiffahrt" ))
+ nRes = SpellFailure.SPELLING_ERROR;
+ }
+ else if (IsEqual( aLocale, new Locale( "en", "US", "" ) ))
+ {
+ // words with 'u', 'U' and 'arizona' are defined to be incorrect
+ boolean bIsValid = !(aWord.indexOf( "u" ) != -1 || aWord.indexOf( "U" ) != -1)
+ && !aWord.equals( "arizona" );
+
+ if (!bIsValid)
+ {
+ // default value (no other SpellFailure type is applicable)
+ nRes = SpellFailure.SPELLING_ERROR;
+
+ if (aWord.equals( "arizona" ))
+ nRes = SpellFailure.CAPTION_ERROR;
+ else if (aWord.equals( "house" ))
+ nRes = SpellFailure.SPELLING_ERROR;
+ else if (aWord.equals( "course" ))
+ nRes = SpellFailure.IS_NEGATIVE_WORD;
+ }
+ }
+
+ return nRes;
+ }
+
+ private XSpellAlternatives GetProposals(
+ String aWord,
+ Locale aLocale,
+ PropertyValue[] aProperties )
+ {
+ short nType = SpellFailure.SPELLING_ERROR;
+ String[] aProposals = null;
+
+ // get values of relevant properties that may be used.
+ //! The values for 'IsIgnoreControlCharacters' and 'IsUseDictionaryList'
+ //! are handled by the dispatcher! Thus there is no need to access
+ //! them here.
+ boolean bIsGermanPreReform = GetValueToUse( "IsGermanPreReform", false, aProperties );
+ boolean bIsSpellWithDigits = GetValueToUse( "IsSpellWithDigits", false, aProperties );
+ boolean bIsSpellUpperCase = GetValueToUse( "IsSpellUpperCase", false, aProperties );
+ boolean bIsSpellCapitalization = GetValueToUse( "IsSpellCapitalization", true, aProperties );
+
+ //!! This code needs to be replaced by code calling the actual
+ //!! implementation of your spellchecker
+ if (IsEqual( aLocale, new Locale( "de", "DE", "" ) ))
+ {
+ if (bIsGermanPreReform && aWord.equals( "Schifffahrt" ))
+ {
+ nType = SpellFailure.SPELLING_ERROR;
+ aProposals = new String[]{ "Schiffahrt" };
+ }
+ else if (!bIsGermanPreReform && aWord.equals( "Schiffahrt" ))
+ {
+ nType = SpellFailure.SPELLING_ERROR;
+ aProposals = new String[]{ "Schifffahrt" };
+ }
+ }
+ else if (IsEqual( aLocale, new Locale( "en", "US", "" ) ))
+ {
+ if (aWord.equals( "arizona" ))
+ {
+ nType = SpellFailure.CAPTION_ERROR;
+ aProposals = new String[]{ "Arizona" };
+ }
+ else if (aWord.equals( "house" ))
+ {
+ nType = SpellFailure.SPELLING_ERROR;
+ aProposals = new String[]{ "horse", "home" };
+ }
+ else if (aWord.equals( "course" ))
+ {
+ nType = SpellFailure.IS_NEGATIVE_WORD;
+ aProposals = new String[]{ "line", "plan", "approach" };
+ }
+ }
+
+ // always return a result if word is incorrect,
+ // proposals may be empty though.
+ return new XSpellAlternatives_impl( aWord, aLocale,
+ nType, aProposals );
+ }
+
+ // __________ interface methods __________
+
+
+
+ //XSupportedLocales
+
+ public Locale[] getLocales()
+ throws com.sun.star.uno.RuntimeException
+ {
+ Locale aLocales[] =
+ {
+ new Locale( "de", "DE", "" ),
+ new Locale( "en", "US", "" )
+ };
+
+ return aLocales;
+ }
+
+ public boolean hasLocale( Locale aLocale )
+ throws com.sun.star.uno.RuntimeException
+ {
+ boolean bRes = false;
+ if ( IsEqual( aLocale, new Locale( "de", "DE", "" ) ) ||
+ IsEqual( aLocale, new Locale( "en", "US", "" ) ))
+ bRes = true;
+ return bRes;
+ }
+
+
+
+ //XSpellChecker
+
+ public boolean isValid(
+ String aWord, Locale aLocale,
+ PropertyValue[] aProperties )
+ throws com.sun.star.uno.RuntimeException,
+ IllegalArgumentException
+ {
+ if (IsEqual( aLocale, new Locale() ) || aWord.length() == 0)
+ return true;
+
+ // linguistic is currently not allowed to throw exceptions
+ // thus we return null which means 'word cannot be spelled'
+ if (!hasLocale( aLocale ))
+ return true;
+
+ // get values of relevant properties that may be used.
+ //! The values for 'IsIgnoreControlCharacters' and 'IsUseDictionaryList'
+ //! are handled by the dispatcher! Thus there is no need to access
+ //! them here.
+ boolean bIsGermanPreReform = GetValueToUse( "IsGermanPreReform", false, aProperties );
+ boolean bIsSpellWithDigits = GetValueToUse( "IsSpellWithDigits", false, aProperties );
+ boolean bIsSpellUpperCase = GetValueToUse( "IsSpellUpperCase", false, aProperties );
+ boolean bIsSpellCapitalization = GetValueToUse( "IsSpellCapitalization", true, aProperties );
+
+ short nFailure = GetSpellFailure( aWord, aLocale, aProperties );
+ if (nFailure != -1)
+ {
+ // postprocess result for errors that should be ignored
+ if ( (!bIsSpellUpperCase && IsUpper( aWord, aLocale ))
+ || (!bIsSpellWithDigits && HasDigits( aWord ))
+ || (!bIsSpellCapitalization
+ && nFailure == SpellFailure.CAPTION_ERROR)
+ )
+ nFailure = -1;
+ }
+
+ return nFailure == -1;
+ }
+
+
+ public XSpellAlternatives spell(
+ String aWord, Locale aLocale,
+ PropertyValue[] aProperties )
+ throws com.sun.star.uno.RuntimeException,
+ IllegalArgumentException
+ {
+ if (IsEqual( aLocale, new Locale() ) || aWord.length() == 0)
+ return null;
+
+ // linguistic is currently not allowed to throw exceptions
+ // thus we return null fwhich means 'word cannot be spelled'
+ if (!hasLocale( aLocale ))
+ return null;
+
+ XSpellAlternatives xRes = null;
+ if (!isValid( aWord, aLocale, aProperties ))
+ {
+ xRes = GetProposals( aWord, aLocale, aProperties );
+ }
+ return xRes;
+ }
+
+
+
+ //XLinguServiceEventBroadcaster
+
+ public boolean addLinguServiceEventListener (
+ XLinguServiceEventListener xLstnr )
+ throws com.sun.star.uno.RuntimeException
+ {
+ boolean bRes = false;
+ if (!bDisposing && xLstnr != null)
+ bRes = aPropChgHelper.addLinguServiceEventListener( xLstnr );
+ return bRes;
+ }
+
+ public boolean removeLinguServiceEventListener(
+ XLinguServiceEventListener xLstnr )
+ throws com.sun.star.uno.RuntimeException
+ {
+ boolean bRes = false;
+ if (!bDisposing && xLstnr != null)
+ bRes = aPropChgHelper.removeLinguServiceEventListener( xLstnr );
+ return bRes;
+ }
+
+
+ // XServiceDisplayName
+
+ public String getServiceDisplayName( Locale aLocale )
+ throws com.sun.star.uno.RuntimeException
+ {
+ return "Java Samples";
+ }
+
+
+ // XInitialization
+
+ public void initialize( Object[] aArguments )
+ throws com.sun.star.uno.Exception,
+ com.sun.star.uno.RuntimeException
+ {
+ int nLen = aArguments.length;
+ if (2 == nLen)
+ {
+ XPropertySet xPropSet = UnoRuntime.queryInterface(
+ XPropertySet.class, aArguments[0]);
+ // start listening to property changes
+ aPropChgHelper.AddAsListenerTo( xPropSet );
+ }
+ }
+
+
+ // XServiceInfo
+
+ public boolean supportsService( String aServiceName )
+ throws com.sun.star.uno.RuntimeException
+ {
+ String[] aServices = getSupportedServiceNames_Static();
+ int i, nLength = aServices.length;
+ boolean bResult = false;
+
+ for( i = 0; !bResult && i < nLength; ++i )
+ bResult = aServiceName.equals( aServices[ i ] );
+
+ return bResult;
+ }
+
+ public String getImplementationName()
+ throws com.sun.star.uno.RuntimeException
+ {
+ return _aSvcImplName;
+ }
+
+ public String[] getSupportedServiceNames()
+ throws com.sun.star.uno.RuntimeException
+ {
+ return getSupportedServiceNames_Static();
+ }
+
+ // __________ static things __________
+
+ public static String _aSvcImplName = SampleSpellChecker.class.getName();
+
+ public static String[] getSupportedServiceNames_Static()
+ {
+ String[] aResult = { "com.sun.star.linguistic2.SpellChecker" };
+ return aResult;
+ }
+
+
+ /**
+ * Returns a factory for creating the service.
+ * This method is called by the <code>JavaLoader</code>
+ * <p>
+ * @return returns a <code>XSingleComponentFactory</code> for creating the component
+ * @param aImplName the name of the implementation for which a service is desired
+ * @see com.sun.star.comp.loader.JavaLoader
+ */
+ public static XSingleComponentFactory __getComponentFactory(
+ String aImplName )
+ {
+ XSingleComponentFactory xSingleComponentFactory = null;
+ if( aImplName.equals( _aSvcImplName ) )
+ {
+ xSingleComponentFactory = new OneInstanceFactory(
+ SampleSpellChecker.class, _aSvcImplName,
+ getSupportedServiceNames_Static() );
+ }
+ return xSingleComponentFactory;
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/OfficeDev/Linguistic/SampleThesaurus.components b/odk/examples/DevelopersGuide/OfficeDev/Linguistic/SampleThesaurus.components
new file mode 100644
index 000000000..025f42451
--- /dev/null
+++ b/odk/examples/DevelopersGuide/OfficeDev/Linguistic/SampleThesaurus.components
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<components xmlns="http://openoffice.org/2010/uno-components">
+ <component loader="com.sun.star.loader.Java2" uri="SampleThesaurus.uno.jar">
+ <implementation name="SampleThesaurus">
+ <service name="com.sun.star.linguistic2.Thesaurus"/>
+ </implementation>
+ </component>
+</components>
diff --git a/odk/examples/DevelopersGuide/OfficeDev/Linguistic/SampleThesaurus.java b/odk/examples/DevelopersGuide/OfficeDev/Linguistic/SampleThesaurus.java
new file mode 100644
index 000000000..f5c437095
--- /dev/null
+++ b/odk/examples/DevelopersGuide/OfficeDev/Linguistic/SampleThesaurus.java
@@ -0,0 +1,293 @@
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+// uno
+import com.sun.star.lib.uno.helper.ComponentBase;
+import com.sun.star.uno.UnoRuntime;
+
+// factories
+import com.sun.star.lang.XSingleComponentFactory;
+
+// supported Interfaces
+import com.sun.star.linguistic2.XThesaurus;
+import com.sun.star.lang.XInitialization;
+import com.sun.star.lang.XServiceInfo;
+import com.sun.star.lang.XServiceDisplayName;
+
+// Exceptions
+import com.sun.star.uno.Exception;
+//used Interfaces
+import com.sun.star.linguistic2.XMeaning;
+import com.sun.star.lang.Locale;
+import com.sun.star.beans.XPropertySet;
+import com.sun.star.beans.PropertyValue;
+import com.sun.star.uno.AnyConverter;
+import java.util.ArrayList;
+
+public class SampleThesaurus extends ComponentBase implements
+ XThesaurus,
+ XInitialization,
+ XServiceDisplayName,
+ XServiceInfo
+{
+ PropChgHelper aPropChgHelper;
+ ArrayList<?> aEvtListeners;
+ boolean bDisposing;
+
+ public SampleThesaurus()
+ {
+ // names of relevant properties to be used
+ String[] aProps = new String[]
+ {
+ "IsIgnoreControlCharacters",
+ "IsUseDictionaryList",
+ "IsGermanPreReform",
+ };
+
+ // this service has no listeners thus we may use the base class,
+ // which is here basically used only to keep track of the
+ // property set (and its lifetime) since it gets used in the
+ // 'GetValueToUse' function
+ aPropChgHelper = new PropChgHelper( this, aProps );
+
+ aEvtListeners = new ArrayList<Object>();
+ bDisposing = false;
+ }
+
+ private boolean IsEqual( Locale aLoc1, Locale aLoc2 )
+ {
+ return aLoc1.Language.equals( aLoc2.Language ) &&
+ aLoc1.Country .equals( aLoc2.Country ) &&
+ aLoc1.Variant .equals( aLoc2.Variant );
+ }
+
+ private boolean GetValueToUse(
+ String aPropName,
+ boolean bDefaultVal,
+ PropertyValue[] aProps )
+ {
+ boolean bRes = bDefaultVal;
+
+ try
+ {
+ // use temporary value if supplied
+ for (int i = 0; i < aProps.length; ++i)
+ {
+ if (aPropName.equals( aProps[i].Name ))
+ {
+ Object aObj = aProps[i].Value;
+ if (AnyConverter.isBoolean( aObj ))
+ {
+ bRes = AnyConverter.toBoolean( aObj );
+ return bRes;
+ }
+ }
+ }
+
+ // otherwise use value from property set (if available)
+ XPropertySet xPropSet = aPropChgHelper.GetPropSet();
+ if (xPropSet != null) // should always be the case
+ {
+ Object aObj = xPropSet.getPropertyValue( aPropName );
+ if (AnyConverter.isBoolean( aObj ))
+ bRes = AnyConverter.toBoolean( aObj );
+ }
+ }
+ catch (Exception e) {
+ bRes = bDefaultVal;
+ }
+
+ return bRes;
+ }
+
+ // __________ interface methods __________
+
+
+
+ //XSupportedLocales
+
+ public Locale[] getLocales()
+ throws com.sun.star.uno.RuntimeException
+ {
+ Locale aLocales[] =
+ {
+ new Locale( "en", "US", "" )
+ };
+
+ return aLocales;
+ }
+
+ public boolean hasLocale( Locale aLocale )
+ throws com.sun.star.uno.RuntimeException
+ {
+ boolean bRes = false;
+ if (IsEqual( aLocale, new Locale( "en", "US", "" ) ))
+ bRes = true;
+ return bRes;
+ }
+
+
+ //XThesaurus
+
+ public XMeaning[] queryMeanings(
+ String aTerm, Locale aLocale,
+ PropertyValue[] aProperties )
+ throws com.sun.star.lang.IllegalArgumentException,
+ com.sun.star.uno.RuntimeException
+ {
+ if (IsEqual( aLocale, new Locale() ) || aTerm.length() == 0)
+ return null;
+
+ // linguistic is currently not allowed to throw exceptions
+ // thus we return null fwhich means 'word cannot be looked up'
+ if (!hasLocale( aLocale ))
+ return null;
+
+ // get values of relevant properties that may be used.
+ //! The values for 'IsIgnoreControlCharacters' and 'IsUseDictionaryList'
+ //! are handled by the dispatcher! Thus there is no need to access
+ //! them here.
+ boolean bIsGermanPreReform = GetValueToUse( "IsGermanPreReform", false, aProperties );
+
+ XMeaning[] aRes = null;
+
+ //!! This code needs to be replaced by code calling the actual
+ //!! implementation of your thesaurus
+ if (aTerm.equals( "house" ) &&
+ IsEqual( aLocale, new Locale( "en", "US", "" ) ) )
+ {
+ aRes = new XMeaning[]
+ {
+ new XMeaning_impl( "a building where one lives",
+ new String[]{ "home", "place", "dwelling" } ),
+ new XMeaning_impl( "a group of people sharing common ancestry",
+ new String[]{ "family", "clan", "kindred" } ),
+ new XMeaning_impl( "to provide with lodging",
+ new String[]{ "room", "board", "put up" } )
+ };
+ }
+
+ return aRes;
+ }
+
+
+
+ // XServiceDisplayName
+
+ public String getServiceDisplayName( Locale aLocale )
+ throws com.sun.star.uno.RuntimeException
+ {
+ return "Java Samples";
+ }
+
+
+ // XInitialization
+
+ public void initialize( Object[] aArguments )
+ throws com.sun.star.uno.Exception,
+ com.sun.star.uno.RuntimeException
+ {
+ int nLen = aArguments.length;
+ if (2 == nLen)
+ {
+ XPropertySet xPropSet = UnoRuntime.queryInterface(
+ XPropertySet.class, aArguments[0]);
+ // start listening to property changes
+ aPropChgHelper.AddAsListenerTo( xPropSet );
+ }
+ }
+
+
+ // XServiceInfo
+
+ public boolean supportsService( String aServiceName )
+ throws com.sun.star.uno.RuntimeException
+ {
+ String[] aServices = getSupportedServiceNames_Static();
+ int i, nLength = aServices.length;
+ boolean bResult = false;
+
+ for( i = 0; !bResult && i < nLength; ++i )
+ bResult = aServiceName.equals( aServices[ i ] );
+
+ return bResult;
+ }
+
+ public String getImplementationName()
+ throws com.sun.star.uno.RuntimeException
+ {
+ return _aSvcImplName;
+ }
+
+ public String[] getSupportedServiceNames()
+ throws com.sun.star.uno.RuntimeException
+ {
+ return getSupportedServiceNames_Static();
+ }
+
+ // __________ static things __________
+
+ public static String _aSvcImplName = SampleThesaurus.class.getName();
+
+ public static String[] getSupportedServiceNames_Static()
+ {
+ String[] aResult = { "com.sun.star.linguistic2.Thesaurus" };
+ return aResult;
+ }
+
+
+ /**
+ * Returns a factory for creating the service.
+ * This method is called by the <code>JavaLoader</code>
+ * <p>
+ * @return returns a <code>XSingleComponentFactory</code> for creating the component
+ * @param aImplName the name of the implementation for which a service is desired
+ * @see com.sun.star.comp.loader.JavaLoader
+ */
+ public static XSingleComponentFactory __getComponentFactory(
+ String aImplName )
+ {
+ XSingleComponentFactory xSingleComponentFactory = null;
+ if( aImplName.equals( _aSvcImplName ) )
+ {
+ xSingleComponentFactory = new OneInstanceFactory(
+ SampleThesaurus.class, _aSvcImplName,
+ getSupportedServiceNames_Static() );
+ }
+ return xSingleComponentFactory;
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/OfficeDev/Linguistic/XHyphenatedWord_impl.java b/odk/examples/DevelopersGuide/OfficeDev/Linguistic/XHyphenatedWord_impl.java
new file mode 100644
index 000000000..47963441b
--- /dev/null
+++ b/odk/examples/DevelopersGuide/OfficeDev/Linguistic/XHyphenatedWord_impl.java
@@ -0,0 +1,100 @@
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+import com.sun.star.lang.Locale;
+
+public class XHyphenatedWord_impl implements
+ com.sun.star.linguistic2.XHyphenatedWord
+{
+ private String aWord;
+ private String aHyphenatedWord;
+ private final short nHyphenPos;
+ private final short nHyphenationPos;
+ private Locale aLang;
+ private final boolean bIsAltSpelling;
+
+ public XHyphenatedWord_impl(
+ String aWord,
+ Locale aLang,
+ short nHyphenationPos,
+ String aHyphenatedWord,
+ short nHyphenPos )
+ {
+ this.aWord = aWord;
+ this.aLang = aLang;
+ this.nHyphenationPos = nHyphenationPos;
+ this.aHyphenatedWord = aHyphenatedWord;
+ this.nHyphenPos = nHyphenPos;
+ this.bIsAltSpelling = (aWord != aHyphenatedWord);
+
+ //!! none of these cases should ever occur!
+ //!! values provided only for safety
+ if (this.aWord == null)
+ this.aWord = "";
+ if (this.aLang == null)
+ this.aLang = new Locale();
+ if (this.aHyphenatedWord == null)
+ this.aHyphenatedWord = "";
+ }
+
+
+ // XHyphenatedWord
+ public String getWord() throws com.sun.star.uno.RuntimeException
+ {
+ return aWord;
+ }
+ public Locale getLocale() throws com.sun.star.uno.RuntimeException
+ {
+ return aLang;
+ }
+ public short getHyphenationPos() throws com.sun.star.uno.RuntimeException
+ {
+ return nHyphenationPos;
+ }
+ public String getHyphenatedWord() throws com.sun.star.uno.RuntimeException
+ {
+ return aHyphenatedWord;
+ }
+ public short getHyphenPos() throws com.sun.star.uno.RuntimeException
+ {
+ return nHyphenPos;
+ }
+ public boolean isAlternativeSpelling() throws com.sun.star.uno.RuntimeException
+ {
+ return bIsAltSpelling;
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/OfficeDev/Linguistic/XMeaning_impl.java b/odk/examples/DevelopersGuide/OfficeDev/Linguistic/XMeaning_impl.java
new file mode 100644
index 000000000..5e30ef22e
--- /dev/null
+++ b/odk/examples/DevelopersGuide/OfficeDev/Linguistic/XMeaning_impl.java
@@ -0,0 +1,71 @@
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+
+
+public class XMeaning_impl implements
+ com.sun.star.linguistic2.XMeaning
+{
+ private String aMeaning;
+ private String[] aSynonyms;
+
+ public XMeaning_impl ( String aMeaning, String[] aSynonyms )
+ {
+ this.aMeaning = aMeaning;
+ this.aSynonyms = aSynonyms;
+
+ //!! none of these cases should ever occur!
+ //!! values provided only for safety
+ if (this.aMeaning == null)
+ this.aMeaning = "";
+
+ // a meaning without synonyms may be OK though.
+ // still for safety an empty existing array has to be provided.
+ if (this.aSynonyms == null)
+ this.aSynonyms = new String[]{};
+ }
+
+ // XMeaning
+ public String getMeaning() throws com.sun.star.uno.RuntimeException
+ {
+ return aMeaning;
+ }
+ public String[] querySynonyms() throws com.sun.star.uno.RuntimeException
+ {
+ return aSynonyms;
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/OfficeDev/Linguistic/XPossibleHyphens_impl.java b/odk/examples/DevelopersGuide/OfficeDev/Linguistic/XPossibleHyphens_impl.java
new file mode 100644
index 000000000..e64752029
--- /dev/null
+++ b/odk/examples/DevelopersGuide/OfficeDev/Linguistic/XPossibleHyphens_impl.java
@@ -0,0 +1,92 @@
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+import com.sun.star.lang.Locale;
+
+public class XPossibleHyphens_impl implements
+ com.sun.star.linguistic2.XPossibleHyphens
+{
+ private String aWord;
+ private String aHyphWord;
+ private short[] aOrigHyphenPos;
+ private Locale aLang;
+
+ public XPossibleHyphens_impl(
+ String aWord,
+ Locale aLang,
+ String aHyphWord,
+ short[] aOrigHyphenPos)
+ {
+ this.aWord = aWord;
+ this.aLang = aLang;
+ this.aHyphWord = aHyphWord;
+ this.aOrigHyphenPos = aOrigHyphenPos;
+
+ //!! none of these cases should ever occur!
+ //!! values provided only for safety
+ if (this.aWord == null)
+ this.aWord = "";
+ if (this.aLang == null)
+ this.aLang = new Locale();
+ if (this.aHyphWord == null)
+ this.aHyphWord = "";
+
+ // having no hyphenation positions is OK though.
+ // still for safety an empty existing array has to be provided.
+ if (this.aOrigHyphenPos == null)
+ this.aOrigHyphenPos = new short[]{};
+ }
+
+ // XPossibleHyphens
+ public String getWord() throws com.sun.star.uno.RuntimeException
+ {
+ return aWord;
+ }
+
+ public Locale getLocale() throws com.sun.star.uno.RuntimeException
+ {
+ return aLang;
+ }
+ public String getPossibleHyphens() throws com.sun.star.uno.RuntimeException
+ {
+ return aHyphWord;
+ }
+ public short[] getHyphenationPositions() throws com.sun.star.uno.RuntimeException
+ {
+ return aOrigHyphenPos;
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/OfficeDev/Linguistic/XSpellAlternatives_impl.java b/odk/examples/DevelopersGuide/OfficeDev/Linguistic/XSpellAlternatives_impl.java
new file mode 100644
index 000000000..d2e9ecbea
--- /dev/null
+++ b/odk/examples/DevelopersGuide/OfficeDev/Linguistic/XSpellAlternatives_impl.java
@@ -0,0 +1,94 @@
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+import com.sun.star.lang.Locale;
+
+
+public class XSpellAlternatives_impl implements
+ com.sun.star.linguistic2.XSpellAlternatives
+{
+ private String aWord;
+ private Locale aLanguage;
+ private String[] aAlt; // list of alternatives, may be empty.
+ private final short nType; // type of failure
+
+ public XSpellAlternatives_impl(
+ String aWord,
+ Locale aLanguage,
+ short nFailureType,
+ String[] aAlt )
+ {
+ this.aWord = aWord;
+ this.aLanguage = aLanguage;
+ this.aAlt = aAlt;
+ this.nType = nFailureType;
+
+ //!! none of these cases should ever occur!
+ //!! values provided only for safety
+ if (this.aWord == null)
+ this.aWord = "";
+ if (this.aLanguage == null)
+ this.aLanguage = new Locale();
+
+ // having no alternatives is OK though.
+ // still for safety an empty existing array has to be provided.
+ if (this.aAlt == null)
+ this.aAlt = new String[]{};
+ }
+
+ // XSpellAlternatives
+ public String getWord() throws com.sun.star.uno.RuntimeException
+ {
+ return aWord;
+ }
+ public Locale getLocale() throws com.sun.star.uno.RuntimeException
+ {
+ return aLanguage;
+ }
+ public short getFailureType() throws com.sun.star.uno.RuntimeException
+ {
+ return nType;
+ }
+ public short getAlternativesCount() throws com.sun.star.uno.RuntimeException
+ {
+ return (short) aAlt.length;
+ }
+ public String[] getAlternatives() throws com.sun.star.uno.RuntimeException
+ {
+ return aAlt;
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/OfficeDev/Makefile b/odk/examples/DevelopersGuide/OfficeDev/Makefile
new file mode 100644
index 000000000..88c4df966
--- /dev/null
+++ b/odk/examples/DevelopersGuide/OfficeDev/Makefile
@@ -0,0 +1,105 @@
+#*************************************************************************
+#
+# The Contents of this file are made available subject to the terms of
+# the BSD license.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+# 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+# contributors may be used to endorse or promote products derived
+# from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+# TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+# USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+#**************************************************************************
+
+# Builds the OfficeDev examples of the Developers Guide.
+
+PRJ=../../..
+SETTINGS=$(PRJ)/settings
+
+include $(SETTINGS)/settings.mk
+include $(SETTINGS)/std.mk
+
+# Define non-platform/compiler specific settings
+EXAMPLE_NAME=OfficeDevExamples
+OUT_APP_CLASS = $(OUT_CLASS)/$(EXAMPLE_NAME)
+
+APP1_NAME=ContextMenuInterceptor
+APP1_JAR=$(OUT_APP_CLASS)/$(APP1_NAME).jar
+APP2_NAME=Number_Formats
+APP2_JAR=$(OUT_APP_CLASS)/$(APP2_NAME).jar
+
+APP1_JAVAFILES = \
+ MenuElement.java \
+ OfficeConnect.java \
+ ContextMenuInterceptor.java \
+
+APP1_CLASSFILES = $(patsubst %.java,$(OUT_APP_CLASS)/%.class,$(APP1_JAVAFILES))
+APP1_CLASSNAMES = $(patsubst %.java,%.class,$(APP1_JAVAFILES))
+
+SDK_CLASSPATH = $(subst $(EMPTYSTRING) $(PATH_SEPARATOR),$(PATH_SEPARATOR),$(CLASSPATH)\
+ $(PATH_SEPARATOR)$(OUT_APP_CLASS))
+
+
+# Targets
+.PHONY: ALL
+ALL : $(EXAMPLE_NAME)
+
+include $(SETTINGS)/stdtarget.mk
+
+$(OUT_APP_CLASS)/%.class : %.java
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ $(SDK_JAVAC) $(JAVAC_FLAGS) -classpath "$(SDK_CLASSPATH)" -d $(OUT_APP_CLASS) $<
+
+$(OUT_APP_CLASS)/%.mf :
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ @echo Main-Class: com.sun.star.lib.loader.Loader> $@
+ $(ECHOLINE)>> $@
+ @echo Name: com/sun/star/lib/loader/Loader.class>> $@
+ @echo Application-Class: $*>> $@
+
+$(APP1_JAR) : $(OUT_APP_CLASS)/$(APP1_NAME).mf $(APP1_CLASSFILES)
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ +cd $(subst /,$(PS),$(OUT_APP_CLASS)) && $(SDK_JAR) cvfm $(@F) $(basename $(@F)).mf $(APP1_CLASSNAMES)
+ +$(SDK_JAR) uvf $@ $(SDK_JAVA_UNO_BOOTSTRAP_FILES)
+
+$(APP2_JAR) : $(OUT_APP_CLASS)/$(APP2_NAME).mf $(OUT_APP_CLASS)/$(APP2_NAME).class
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ +cd $(subst /,$(PS),$(OUT_APP_CLASS)) && $(SDK_JAR) cvfm $(@F) $(basename $(@F)).mf $(basename $(@F)).class
+ +$(SDK_JAR) uvf $@ $(SDK_JAVA_UNO_BOOTSTRAP_FILES)
+
+
+$(EXAMPLE_NAME) : $(APP1_JAR) $(APP2_JAR)
+ @echo --------------------------------------------------------------------------------
+ @echo Please use the following commands to execute the examples!
+ @echo -
+ @echo $(MAKE) $(APP1_NAME).run
+ @echo $(MAKE) $(APP2_NAME).run
+ @echo --------------------------------------------------------------------------------
+
+%.run: $(OUT_APP_CLASS)/%.jar
+ $(SDK_JAVA) -Dcom.sun.star.lib.loader.unopath="$(OFFICE_PROGRAM_PATH)" -jar $<
+
+.PHONY: clean
+clean :
+ -$(DELRECURSIVE) $(subst /,$(PS),$(OUT_APP_CLASS))
diff --git a/odk/examples/DevelopersGuide/OfficeDev/MenuElement.java b/odk/examples/DevelopersGuide/OfficeDev/MenuElement.java
new file mode 100644
index 000000000..c3e8f751a
--- /dev/null
+++ b/odk/examples/DevelopersGuide/OfficeDev/MenuElement.java
@@ -0,0 +1,58 @@
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+import com.sun.star.uno.UnoRuntime;
+
+// A helper class to determine the menu element type
+public class MenuElement
+{
+ public static boolean IsMenuEntry( com.sun.star.beans.XPropertySet xMenuElement ) {
+ com.sun.star.lang.XServiceInfo xServiceInfo =
+ UnoRuntime.queryInterface(
+ com.sun.star.lang.XServiceInfo.class, xMenuElement );
+
+ return xServiceInfo.supportsService( "com.sun.star.ui.ActionTrigger" );
+ }
+
+ public static boolean IsMenuSeparator( com.sun.star.beans.XPropertySet xMenuElement ) {
+ com.sun.star.lang.XServiceInfo xServiceInfo =
+ UnoRuntime.queryInterface(
+ com.sun.star.lang.XServiceInfo.class, xMenuElement );
+
+ return xServiceInfo.supportsService( "com.sun.star.ui.ActionTriggerSeparator" );
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/OfficeDev/Number_Formats.java b/odk/examples/DevelopersGuide/OfficeDev/Number_Formats.java
new file mode 100644
index 000000000..dedd084e5
--- /dev/null
+++ b/odk/examples/DevelopersGuide/OfficeDev/Number_Formats.java
@@ -0,0 +1,245 @@
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+// __________ Imports __________
+
+import com.sun.star.beans.PropertyValue;
+import com.sun.star.container.XIndexAccess;
+import com.sun.star.frame.XComponentLoader;
+import com.sun.star.lang.XMultiComponentFactory;
+import com.sun.star.sheet.XSpreadsheet;
+import com.sun.star.sheet.XSpreadsheets;
+import com.sun.star.sheet.XSpreadsheetDocument;
+import com.sun.star.table.XCell;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.XComponentContext;
+
+
+// __________ Implementation __________
+
+/** Create a spreadsheet document and provide access to a sheet framework that
+ is then used to modify some number formats.
+ */
+public class Number_Formats
+{
+ // __________ public members and methods __________
+
+
+
+
+ public static void main( String args[] )
+ {
+ try
+ {
+ Number_Formats aSample = new Number_Formats( args );
+ aSample.doFunction();
+ }
+ catch( Exception ex )
+ {
+ System.err.println( "Sample caught exception! " + ex );
+ ex.printStackTrace();
+ System.exit(1);
+ }
+
+ System.out.println( "Sample done." );
+ System.exit(0);
+ }
+
+
+
+ public void doFunction() throws RuntimeException, Exception
+ {
+ // Assume:
+ // com.sun.star.sheet.XSpreadsheetDocument maSpreadsheetDoc;
+ // com.sun.star.sheet.XSpreadsheet maSheet;
+
+ // Query the number formats supplier of the spreadsheet document
+ com.sun.star.util.XNumberFormatsSupplier xNumberFormatsSupplier =
+ UnoRuntime.queryInterface(
+ com.sun.star.util.XNumberFormatsSupplier.class, maSpreadsheetDoc );
+
+ // Get the number formats from the supplier
+ com.sun.star.util.XNumberFormats xNumberFormats =
+ xNumberFormatsSupplier.getNumberFormats();
+
+ // Query the XNumberFormatTypes interface
+ com.sun.star.util.XNumberFormatTypes xNumberFormatTypes =
+ UnoRuntime.queryInterface(
+ com.sun.star.util.XNumberFormatTypes.class, xNumberFormats );
+
+ // Get the number format index key of the default currency format,
+ // note the empty locale for default locale
+ com.sun.star.lang.Locale aLocale = new com.sun.star.lang.Locale();
+ int nCurrencyKey = xNumberFormatTypes.getStandardFormat(
+ com.sun.star.util.NumberFormat.CURRENCY, aLocale );
+
+ // Get cell range B3:B11
+ com.sun.star.table.XCellRange xCellRange =
+ maSheet.getCellRangeByPosition( 1, 2, 1, 10 );
+
+ // Query the property set of the cell range
+ com.sun.star.beans.XPropertySet xCellProp =
+ UnoRuntime.queryInterface(
+ com.sun.star.beans.XPropertySet.class, xCellRange );
+
+ // Set number format to default currency
+ xCellProp.setPropertyValue( "NumberFormat", Integer.valueOf(nCurrencyKey) );
+
+ // Get cell B3
+ com.sun.star.table.XCell xCell = maSheet.getCellByPosition( 1, 2 );
+
+ // Query the property set of the cell
+ xCellProp = UnoRuntime.queryInterface(
+ com.sun.star.beans.XPropertySet.class, xCell );
+
+ // Get the number format index key of the cell's properties
+ int nIndexKey = ((Integer) xCellProp.getPropertyValue( "NumberFormat" )).intValue();
+ if ( nIndexKey != nCurrencyKey )
+ System.out.println( "Number format doesn't match!" );
+
+ // Get the properties of the number format
+ com.sun.star.beans.XPropertySet xProp = xNumberFormats.getByKey( nIndexKey );
+
+ // Get the format code string of the number format's properties
+ String aFormatCode = (String) xProp.getPropertyValue( "FormatString" );
+ System.out.println( "FormatString: `" + aFormatCode + "'" );
+
+ // Create an arbitrary format code
+ aFormatCode = "\"wonderful \"" + aFormatCode;
+
+ // Test if it's already present
+ nIndexKey = xNumberFormats.queryKey( aFormatCode, aLocale, false );
+
+ // If not, add to number formats collection
+ if ( nIndexKey == -1 )
+ {
+ try
+ {
+ nIndexKey = xNumberFormats.addNew( aFormatCode, aLocale );
+ }
+ catch( com.sun.star.util.MalformedNumberFormatException ex )
+ {
+ System.err.println( "Bad number format code: " + ex );
+ ex.printStackTrace();
+ nIndexKey = -1;
+ }
+ }
+
+ // Set the new format at the cell
+ if ( nIndexKey != -1 )
+ xCellProp.setPropertyValue( "NumberFormat", Integer.valueOf(nIndexKey) );
+
+
+ // Set column containing the example values to optimal width to show
+ // the new format of cell B3
+ com.sun.star.table.XColumnRowRange xColRowRange =
+ UnoRuntime.queryInterface(com.sun.star.table.XColumnRowRange.class,
+ maSheet);
+
+ com.sun.star.container.XIndexAccess xIndexAccess =
+ UnoRuntime.queryInterface(com.sun.star.container.XIndexAccess.class,
+ xColRowRange.getColumns());
+
+ com.sun.star.beans.XPropertySet xColPropSet =
+ UnoRuntime.queryInterface(com.sun.star.beans.XPropertySet.class,
+ xIndexAccess.getByIndex(1));
+
+ xColPropSet.setPropertyValue( "OptimalWidth", Boolean.TRUE );
+ }
+
+
+
+ public Number_Formats( String[] args ) throws java.lang.Exception
+ {
+ // get the remote office context. If necessary a new office
+ // process is started
+ XComponentContext aOfficeContext = com.sun.star.comp.helper.Bootstrap.bootstrap();
+ System.out.println("Connected to a running office ...");
+ XMultiComponentFactory aServiceManager = aOfficeContext.getServiceManager();
+
+ // create a new spreadsheet document
+ XComponentLoader aLoader = UnoRuntime.queryInterface(
+ XComponentLoader.class, aServiceManager.createInstanceWithContext(
+ "com.sun.star.frame.Desktop", aOfficeContext) );
+
+ maSpreadsheetDoc = UnoRuntime.queryInterface(
+ XSpreadsheetDocument.class,
+ aLoader.loadComponentFromURL( "private:factory/scalc",
+ "_blank",
+ 0,
+ new PropertyValue[ 0 ] ) );
+
+ if ( !initSpreadsheet() )
+ System.exit( 0 );
+ }
+
+
+ // __________ private members and methods __________
+
+ private final XSpreadsheetDocument maSpreadsheetDoc;
+ private XSpreadsheet maSheet; // the first sheet
+
+
+
+
+ /** init the first sheet
+ */
+ private boolean initSpreadsheet()
+ {
+ boolean bOk = true;
+ XSpreadsheets aSheets = maSpreadsheetDoc.getSheets();
+ try
+ {
+ XIndexAccess aSheetsIA = UnoRuntime.queryInterface( XIndexAccess.class, aSheets );
+ maSheet = UnoRuntime.queryInterface(XSpreadsheet.class, aSheetsIA.getByIndex( 0 ));
+
+ // enter some values in B3:B11
+ for( int iCounter=1; iCounter < 10; iCounter++ )
+ {
+ XCell aCell = maSheet.getCellByPosition( 1, 1 + iCounter );
+ aCell.setValue( iCounter );
+ }
+ }
+ catch( Exception ex )
+ {
+ System.err.println( "Couldn't initialize Spreadsheet Document: " + ex );
+ ex.printStackTrace();
+ bOk = false;
+ }
+ return bOk;
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/OfficeDev/OfficeConnect.java b/odk/examples/DevelopersGuide/OfficeDev/OfficeConnect.java
new file mode 100644
index 000000000..d8db72aad
--- /dev/null
+++ b/odk/examples/DevelopersGuide/OfficeDev/OfficeConnect.java
@@ -0,0 +1,140 @@
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+// __________ Imports __________
+
+import com.sun.star.uno.UnoRuntime;
+
+// __________ Implementation __________
+
+/**
+ * support ONE singleton uno connection to a running office installation!
+ * Can be used to open/use/close connection to uno environment of an already running office.
+ * ctor isn't available from outside. You should call static function "getConnection()"
+ * to open or use internal set connection which is created one times only.
+ *
+ */
+public class OfficeConnect
+{
+
+
+ /**
+ * At first call we create static connection object and get the remote office
+ * context and the remote office service manager. A new office process is
+ * started if necessary.
+ * Then - and for all further requests we return these static connection member.
+ */
+ public static synchronized OfficeConnect createConnection()
+ throws java.lang.Exception
+ {
+ if (maConnection == null)
+ {
+ maConnection = new OfficeConnect();
+ }
+ return maConnection;
+ }
+
+
+
+
+
+
+
+ /**
+ * ctor
+ * We try to open the connection in our ctor ... transparently for the user.
+ * We made it private to support singleton pattern of these implementation.
+ * see getConnection() for further information
+ */
+ private OfficeConnect() throws java.lang.Exception
+ {
+ // get the remote office context. If necessary a new office
+ // process is started
+ mxOfficeContext = com.sun.star.comp.helper.Bootstrap.bootstrap();
+ System.out.println("Connected to a running office ...");
+ mxServiceManager = mxOfficeContext.getServiceManager();
+ }
+
+
+
+ /**
+ * create uno components inside remote office process
+ * After connection of these process to a running office we have access to remote service manager of it.
+ * So we can use it to create all existing services. Use this method to create components by name and
+ * get her interface. Casting of it to right target interface is part of your implementation.
+ *
+ * @param aType describe class type of created service
+ * Returned object can be casted directly to this one.
+ * Uno query was done by this method automatically.
+ * @param sServiceSpecifier name of service which should be created
+ * @return Description of the Returned Value
+ */
+ public <T> T createRemoteInstance(Class<T> aType, String sServiceSpecifier)
+ {
+ T aResult = null;
+ try
+ {
+ aResult = UnoRuntime.queryInterface(
+ aType, mxServiceManager.createInstanceWithContext(
+ sServiceSpecifier, mxOfficeContext));
+ }
+ catch (com.sun.star.uno.Exception ex)
+ {
+ System.err.println("Couldn't create Service of type " + sServiceSpecifier + ": " + ex);
+ ex.printStackTrace();
+ System.exit(0);
+ }
+ return aResult;
+ }
+
+
+
+
+
+
+
+ /**
+ * member
+ */
+ // singleton connection instance
+ private static OfficeConnect maConnection;
+
+ // reference to remote office context
+ private final com.sun.star.uno.XComponentContext mxOfficeContext;
+ // reference to remote service manager
+ private final com.sun.star.lang.XMultiComponentFactory mxServiceManager;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/OfficeDev/PathSettings/Makefile b/odk/examples/DevelopersGuide/OfficeDev/PathSettings/Makefile
new file mode 100644
index 000000000..bc55266ef
--- /dev/null
+++ b/odk/examples/DevelopersGuide/OfficeDev/PathSettings/Makefile
@@ -0,0 +1,91 @@
+#*************************************************************************
+#
+# The Contents of this file are made available subject to the terms of
+# the BSD license.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+# 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+# contributors may be used to endorse or promote products derived
+# from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+# TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+# USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+#**************************************************************************
+
+# Builds the OfficeDevPathSettingsTest example of the Developers Guide.
+
+PRJ=../../../..
+SETTINGS=$(PRJ)/settings
+
+include $(SETTINGS)/settings.mk
+include $(SETTINGS)/std.mk
+
+# Define non-platform/compiler specific settings
+EXAMPLE_NAME=OfficeDevPathSettingsTest
+OUT_APP_CLASS = $(OUT_CLASS)/$(EXAMPLE_NAME)
+
+APP1_NAME=PathSettingsTest
+APP1_JAR=$(OUT_APP_CLASS)/$(APP1_NAME).jar
+
+SDK_CLASSPATH=$(subst $(EMPTYSTRING) $(PATH_SEPARATOR),$(PATH_SEPARATOR),$(CLASSPATH)\
+ $(PATH_SEPARATOR)$(OUT_APP_CLASS))
+
+
+# Targets
+.PHONY: ALL
+ALL : $(EXAMPLE_NAME)
+
+include $(SETTINGS)/stdtarget.mk
+
+$(OUT_APP_CLASS)/%.class : %.java
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ $(SDK_JAVAC) $(JAVAC_FLAGS) -classpath "$(SDK_CLASSPATH)" -d $(OUT_APP_CLASS) $<
+
+$(OUT_APP_CLASS)/%.mf :
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ @echo Main-Class: com.sun.star.lib.loader.Loader> $@
+ $(ECHOLINE)>> $@
+ @echo Name: com/sun/star/lib/loader/Loader.class>> $@
+ @echo Application-Class: $*>> $@
+
+$(OUT_APP_CLASS)/%.jar : $(OUT_APP_CLASS)/%.mf $(OUT_APP_CLASS)/%.class
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ +cd $(subst /,$(PS),$(OUT_APP_CLASS)) && $(SDK_JAR) cvfm $(@F) $*.mf $*.class
+ +$(SDK_JAR) uvf $@ $(SDK_JAVA_UNO_BOOTSTRAP_FILES)
+
+$(APP1_JAR) : $(OUT_APP_CLASS)/$(APP1_NAME).mf $(OUT_APP_CLASS)/$(APP1_NAME).class
+
+$(EXAMPLE_NAME) : $(APP1_JAR)
+ @echo --------------------------------------------------------------------------------
+ @echo Please use the following commands to execute the examples!
+ @echo -
+ @echo $(MAKE) $(APP1_NAME).run
+ @echo --------------------------------------------------------------------------------
+
+%.run: $(OUT_APP_CLASS)/%.jar
+ $(SDK_JAVA) -Dcom.sun.star.lib.loader.unopath="$(OFFICE_PROGRAM_PATH)" -jar $<
+
+.PHONY: clean
+clean :
+ -$(DELRECURSIVE) $(subst /,$(PS),$(OUT_APP_CLASS))
diff --git a/odk/examples/DevelopersGuide/OfficeDev/PathSettings/PathSettingsTest.java b/odk/examples/DevelopersGuide/OfficeDev/PathSettings/PathSettingsTest.java
new file mode 100644
index 000000000..f8a17a16b
--- /dev/null
+++ b/odk/examples/DevelopersGuide/OfficeDev/PathSettings/PathSettingsTest.java
@@ -0,0 +1,164 @@
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.XComponentContext;
+import com.sun.star.beans.XPropertySet;
+import com.sun.star.util.thePathSettings;
+
+/*
+ * Provides example code how to access and use the
+ * path pathsettings service.
+ */
+public class PathSettingsTest {
+
+ /*
+ * List of pre-defined path variables supported by
+ * the path settings service.
+ */
+ private static String[] predefinedPathProperties = {
+ "Addin",
+ "AutoCorrect",
+ "AutoText",
+ "Backup",
+ "Basic",
+ "Bitmap",
+ "Config",
+ "Dictionary",
+ "Favorite",
+ "Filter",
+ "Gallery",
+ "Graphic",
+ "Help",
+ "Linguistic",
+ "Module",
+ "Palette",
+ "Plugin",
+ "Storage",
+ "Temp",
+ "Template",
+ "UIConfig",
+ "UserConfig",
+ "UserDictionary",
+ "Work"
+ };
+
+ /*
+ * @param args the command line arguments
+ */
+ public static void main(String[] args) {
+
+ XComponentContext xRemoteContext = null;
+ XPropertySet xPathSettingsService = null;
+
+ try {
+ // get the remote office context. If necessary a new office
+ // process is started
+ xRemoteContext = com.sun.star.comp.helper.Bootstrap.bootstrap();
+ System.out.println("Connected to a running office ...");
+
+ Object pathSubst = thePathSettings.get( xRemoteContext );
+ xPathSettingsService = UnoRuntime.queryInterface(
+ XPropertySet.class, pathSubst);
+
+ /* Work with path settings */
+ workWithPathSettings( xPathSettingsService );
+ }
+ catch (java.lang.Exception e){
+ e.printStackTrace();
+ }
+ finally {
+ System.exit(0);
+ }
+ }
+
+ /*
+ * Retrieve and set path properties from path settings service
+ * @param xPathSettingsService the path settings service
+ */
+ public static void workWithPathSettings( XPropertySet xPathSettingsService )
+ {
+ if ( xPathSettingsService != null ) {
+ for ( int i=0; i<predefinedPathProperties.length; i++ ) {
+ try {
+ /* Retrieve values for path properties from path settings
+ * service*/
+ Object aValue = xPathSettingsService.getPropertyValue(
+ predefinedPathProperties[i] );
+
+ // getPropertyValue returns an Object, you have to cast
+ // it to type that you need
+ String aPath = (String)aValue;
+ System.out.println( "Property="+ predefinedPathProperties[i]
+ + " Path=" + aPath );
+ }
+ catch ( com.sun.star.beans.UnknownPropertyException e) {
+ System.err.println( "UnknownPropertyException has been thrown accessing "+predefinedPathProperties[i]);
+ }
+ catch ( com.sun.star.lang.WrappedTargetException e ) {
+ System.err.println( "WrappedTargetException has been thrown accessing "+predefinedPathProperties[i]);
+ }
+ }
+
+ // Try to modify the work path property. After running this example
+ // you should see the new value of "My Documents" in the path options
+ // tab page, accessible via "Tools - Options - [Star|Open]Office -
+ // Paths".
+ // If you want to revert the changes, you can also do it with the
+ // path tab page.
+ try {
+ xPathSettingsService.setPropertyValue( "Work", "$(temp)" );
+ String aValue = (String)xPathSettingsService.getPropertyValue( "Work" );
+ System.out.println( "\nNote: The example changes your current "
+ +"setting of the work path!\nThe work path "
+ +"should be now=" + aValue );
+ }
+ catch ( com.sun.star.beans.UnknownPropertyException e) {
+ System.err.println( "UnknownPropertyException has been thrown accessing PathSettings service");
+ }
+ catch ( com.sun.star.lang.WrappedTargetException e ) {
+ System.err.println( "WrappedTargetException has been thrown accessing PathSettings service");
+ }
+ catch ( com.sun.star.beans.PropertyVetoException e ) {
+ System.err.println( "PropertyVetoException has been thrown accessing PathSettings service");
+ }
+ catch ( com.sun.star.lang.IllegalArgumentException e ) {
+ System.err.println( "IllegalArgumentException has been thrown accessing PathSettings service");
+ }
+ }
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/OfficeDev/PathSubstitution/Makefile b/odk/examples/DevelopersGuide/OfficeDev/PathSubstitution/Makefile
new file mode 100644
index 000000000..20bb65687
--- /dev/null
+++ b/odk/examples/DevelopersGuide/OfficeDev/PathSubstitution/Makefile
@@ -0,0 +1,91 @@
+#*************************************************************************
+#
+# The Contents of this file are made available subject to the terms of
+# the BSD license.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+# 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+# contributors may be used to endorse or promote products derived
+# from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+# TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+# USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+#**************************************************************************
+
+# Builds the OfficeDevPathSettingsTest example of the Developers Guide.
+
+PRJ=../../../..
+SETTINGS=$(PRJ)/settings
+
+include $(SETTINGS)/settings.mk
+include $(SETTINGS)/std.mk
+
+# Define non-platform/compiler specific settings
+EXAMPLE_NAME=OfficeDevPathSubstitutionTest
+OUT_APP_CLASS = $(OUT_CLASS)/$(EXAMPLE_NAME)
+
+APP1_NAME=PathSubstitutionTest
+APP1_JAR=$(OUT_APP_CLASS)/$(APP1_NAME).jar
+
+SDK_CLASSPATH=$(subst $(EMPTYSTRING) $(PATH_SEPARATOR),$(PATH_SEPARATOR),$(CLASSPATH)\
+ $(PATH_SEPARATOR)$(OUT_APP_CLASS))
+
+
+# Targets
+.PHONY: ALL
+ALL : $(EXAMPLE_NAME)
+
+include $(SETTINGS)/stdtarget.mk
+
+$(OUT_APP_CLASS)/%.class : %.java
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ $(SDK_JAVAC) $(JAVAC_FLAGS) -classpath "$(SDK_CLASSPATH)" -d $(OUT_APP_CLASS) $<
+
+$(OUT_APP_CLASS)/%.mf :
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ @echo Main-Class: com.sun.star.lib.loader.Loader> $@
+ $(ECHOLINE)>> $@
+ @echo Name: com/sun/star/lib/loader/Loader.class>> $@
+ @echo Application-Class: $*>> $@
+
+$(OUT_APP_CLASS)/%.jar : $(OUT_APP_CLASS)/%.mf $(OUT_APP_CLASS)/%.class
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ +cd $(subst /,$(PS),$(OUT_APP_CLASS)) && $(SDK_JAR) cvfm $(@F) $*.mf $*.class
+ +$(SDK_JAR) uvf $@ $(SDK_JAVA_UNO_BOOTSTRAP_FILES)
+
+$(APP1_JAR) : $(OUT_APP_CLASS)/$(APP1_NAME).mf $(OUT_APP_CLASS)/$(APP1_NAME).class
+
+$(EXAMPLE_NAME) : $(APP1_JAR)
+ @echo --------------------------------------------------------------------------------
+ @echo Please use the following commands to execute the examples!
+ @echo -
+ @echo $(MAKE) $(APP1_NAME).run
+ @echo --------------------------------------------------------------------------------
+
+%.run: $(OUT_APP_CLASS)/%.jar
+ $(SDK_JAVA) -Dcom.sun.star.lib.loader.unopath="$(OFFICE_PROGRAM_PATH)" -jar $<
+
+.PHONY: clean
+clean :
+ -$(DELRECURSIVE) $(subst /,$(PS),$(OUT_APP_CLASS))
diff --git a/odk/examples/DevelopersGuide/OfficeDev/PathSubstitution/PathSubstitutionTest.java b/odk/examples/DevelopersGuide/OfficeDev/PathSubstitution/PathSubstitutionTest.java
new file mode 100644
index 000000000..98fd919c9
--- /dev/null
+++ b/odk/examples/DevelopersGuide/OfficeDev/PathSubstitution/PathSubstitutionTest.java
@@ -0,0 +1,116 @@
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.XComponentContext;
+import com.sun.star.lang.XMultiComponentFactory;
+import com.sun.star.util.XStringSubstitution;
+
+public class PathSubstitutionTest {
+
+ /*
+ * List of pre-defined path variables supported by
+ * the path substitution service.
+ */
+ private static String[] predefinedPathVariables = {
+ "$(home)","$(inst)","$(prog)","$(temp)","$(user)", "$(username)",
+ "$(work)","$(path)","$(langid)","$(vlang)"
+ };
+
+ /*
+ * @param args the command line arguments
+ */
+ public static void main(String[] args) {
+
+ XComponentContext xRemoteContext = null;
+ XMultiComponentFactory xRemoteServiceManager = null;
+ XStringSubstitution xPathSubstService = null;
+
+ try {
+ // get the remote office context. If necessary a new office
+ // process is started
+ xRemoteContext = com.sun.star.comp.helper.Bootstrap.bootstrap();
+ System.out.println("Connected to a running office ...");
+ xRemoteServiceManager = xRemoteContext.getServiceManager();
+
+ Object pathSubst = xRemoteServiceManager.createInstanceWithContext(
+ "com.sun.star.comp.framework.PathSubstitution", xRemoteContext );
+ xPathSubstService = UnoRuntime.queryInterface(
+ XStringSubstitution.class, pathSubst);
+
+ /* Work with path variables */
+ workWithPathVariables( xPathSubstService );
+ }
+ catch (java.lang.Exception e){
+ e.printStackTrace();
+ }
+ finally {
+ System.exit(0);
+ }
+ }
+
+ public static void workWithPathVariables( XStringSubstitution xPathSubstService )
+ {
+ if ( xPathSubstService != null ) {
+ for ( int i=0; i<predefinedPathVariables.length; i++ ) {
+ try {
+ /* Retrieve values for pre-defined path variables */
+ String aValue = xPathSubstService.getSubstituteVariableValue(
+ predefinedPathVariables[i] );
+ System.out.println( "Variable: "+ predefinedPathVariables[i] +
+ " value=" + aValue );
+ }
+ catch ( com.sun.star.container.NoSuchElementException e) {
+ System.err.println( "NoSuchElementException has been thrown accessing "+predefinedPathVariables[i]);
+ }
+ }
+
+ // Check the resubstitution function
+ try {
+ String aPath = xPathSubstService.getSubstituteVariableValue(
+ predefinedPathVariables[0] ); // Use $(home) as starting point
+ aPath += "/test"; // extend the path
+ System.out.println( "Path="+aPath );
+ String aResubstPath = xPathSubstService.reSubstituteVariables( aPath );
+ System.out.println( "Resubstituted path="+aResubstPath );
+ }
+ catch ( com.sun.star.container.NoSuchElementException e ) {
+ System.err.println( "NoSuchElementException has been thrown accessing "+predefinedPathVariables[0]);
+ }
+ }
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/OfficeDev/TerminationTest/Makefile b/odk/examples/DevelopersGuide/OfficeDev/TerminationTest/Makefile
new file mode 100644
index 000000000..ae3d607cf
--- /dev/null
+++ b/odk/examples/DevelopersGuide/OfficeDev/TerminationTest/Makefile
@@ -0,0 +1,96 @@
+#*************************************************************************
+#
+# The Contents of this file are made available subject to the terms of
+# the BSD license.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+# 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+# contributors may be used to endorse or promote products derived
+# from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+# TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+# USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+#**************************************************************************
+
+# Builds the OfficeDevClipboard example of the Developers Guide.
+
+PRJ=../../../..
+SETTINGS=$(PRJ)/settings
+
+include $(SETTINGS)/settings.mk
+include $(SETTINGS)/std.mk
+
+# Define non-platform/compiler specific settings
+EXAMPLE_NAME=OfficeDevTerminationTest
+OUT_APP_CLASS = $(OUT_CLASS)/$(EXAMPLE_NAME)
+
+APP1_NAME=TerminationTest
+APP1_JAR=$(OUT_APP_CLASS)/$(APP1_NAME).jar
+
+APP1_JAVAFILES = \
+ TerminateListener.java \
+ TerminationTest.java
+
+APP1_CLASSFILES = $(patsubst %.java,$(OUT_APP_CLASS)/%.class,$(APP1_JAVAFILES))
+APP1_CLASSNAMES = $(patsubst %.java,%.class,$(APP1_JAVAFILES))
+
+SDK_CLASSPATH = $(subst $(EMPTYSTRING) $(PATH_SEPARATOR),$(PATH_SEPARATOR),$(CLASSPATH)\
+ $(PATH_SEPARATOR)$(OUT_APP_CLASS))
+
+
+# Targets
+.PHONY: ALL
+ALL : $(EXAMPLE_NAME)
+
+include $(SETTINGS)/stdtarget.mk
+
+$(APP1_CLASSFILES) : $(APP1_JAVAFILES)
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ $(SDK_JAVAC) $(JAVAC_FLAGS) -classpath "$(SDK_CLASSPATH)" -d $(OUT_APP_CLASS) $^
+
+$(OUT_APP_CLASS)/%.mf :
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ @echo Main-Class: com.sun.star.lib.loader.Loader> $@
+ $(ECHOLINE)>> $@
+ @echo Name: com/sun/star/lib/loader/Loader.class>> $@
+ @echo Application-Class: $*>> $@
+
+$(APP1_JAR) : $(OUT_APP_CLASS)/$(APP1_NAME).mf $(APP1_CLASSFILES)
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ +cd $(subst /,$(PS),$(OUT_APP_CLASS)) && $(SDK_JAR) cvfm $(@F) $(basename $(@F)).mf $(APP1_CLASSNAMES)
+ +$(SDK_JAR) uvf $@ $(SDK_JAVA_UNO_BOOTSTRAP_FILES)
+
+$(EXAMPLE_NAME) : $(APP1_JAR)
+ @echo --------------------------------------------------------------------------------
+ @echo Please use the following command to execute the example!
+ @echo -
+ @echo $(MAKE) $(APP1_NAME).run
+ @echo --------------------------------------------------------------------------------
+
+%.run: $(OUT_APP_CLASS)/%.jar
+ $(SDK_JAVA) -Dcom.sun.star.lib.loader.unopath="$(OFFICE_PROGRAM_PATH)" -jar $<
+
+.PHONY: clean
+clean :
+ -$(DELRECURSIVE) $(subst /,$(PS),$(OUT_APP_CLASS))
diff --git a/odk/examples/DevelopersGuide/OfficeDev/TerminationTest/TerminateListener.java b/odk/examples/DevelopersGuide/OfficeDev/TerminationTest/TerminateListener.java
new file mode 100644
index 000000000..fd902daee
--- /dev/null
+++ b/odk/examples/DevelopersGuide/OfficeDev/TerminationTest/TerminateListener.java
@@ -0,0 +1,59 @@
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+import com.sun.star.frame.TerminationVetoException;
+import com.sun.star.frame.XTerminateListener;
+
+public class TerminateListener implements XTerminateListener {
+
+ public void notifyTermination(com.sun.star.lang.EventObject eventObject) {
+ System.out.println("about to terminate...");
+ }
+
+ public void queryTermination(com.sun.star.lang.EventObject eventObject)
+ throws TerminationVetoException {
+
+ // test if we can terminate now
+ if (TerminationTest.isAtWork()) {
+ System.out.println("Terminate while we are at work? You can't mean it serious ;-)!");
+ throw new TerminationVetoException();
+ }
+ }
+
+ public void disposing(com.sun.star.lang.EventObject eventObject) {
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/OfficeDev/TerminationTest/TerminationTest.java b/odk/examples/DevelopersGuide/OfficeDev/TerminationTest/TerminationTest.java
new file mode 100644
index 000000000..3d0fdde2e
--- /dev/null
+++ b/odk/examples/DevelopersGuide/OfficeDev/TerminationTest/TerminationTest.java
@@ -0,0 +1,100 @@
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.XComponentContext;
+import com.sun.star.lang.XMultiComponentFactory;
+import com.sun.star.frame.XDesktop;
+
+public class TerminationTest {
+
+ private static boolean atWork = false;
+ /**
+ * @param args the command line arguments
+ */
+ public static void main(String[] args) {
+
+ XComponentContext xRemoteContext = null;
+ XMultiComponentFactory xRemoteServiceManager = null;
+ XDesktop xDesktop = null;
+
+ try {
+ // get the remote office context. If necessary a new office
+ // process is started
+ xRemoteContext = com.sun.star.comp.helper.Bootstrap.bootstrap();
+ System.out.println("Connected to a running office ...");
+ xRemoteServiceManager = xRemoteContext.getServiceManager();
+
+ Object desktop = xRemoteServiceManager.createInstanceWithContext(
+ "com.sun.star.frame.Desktop", xRemoteContext);
+ xDesktop = UnoRuntime.queryInterface(XDesktop.class, desktop);
+
+ TerminateListener terminateListener = new TerminateListener();
+ xDesktop.addTerminateListener(terminateListener);
+
+ atWork = true;
+ // try to terminate while we are at work
+ boolean terminated = xDesktop.terminate();
+ System.out.println("The Office " +
+ (terminated ?
+ "has been terminated" :
+ "is still running, we are at work"));
+
+ // no longer at work
+ atWork = false;
+ // once more: try to terminate
+ terminated = xDesktop.terminate();
+ System.out.println("The Office " +
+ (terminated ?
+ "has been terminated" :
+ "is still running. Someone else prevents termination, " +
+ "e.g. the quickstarter"));
+ }
+ catch (java.lang.Exception e){
+ e.printStackTrace();
+ }
+ finally {
+ System.exit(0);
+ }
+
+
+ }
+ public static boolean isAtWork() {
+ return atWork;
+ }
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/ProfUNO/CppBinding/Makefile b/odk/examples/DevelopersGuide/ProfUNO/CppBinding/Makefile
new file mode 100644
index 000000000..5e4a06138
--- /dev/null
+++ b/odk/examples/DevelopersGuide/ProfUNO/CppBinding/Makefile
@@ -0,0 +1,117 @@
+#*************************************************************************
+#
+# The Contents of this file are made available subject to the terms of
+# the BSD license.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+# 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+# contributors may be used to endorse or promote products derived
+# from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+# TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+# USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+#**************************************************************************
+
+# Builds the ProfUNO cpp binding example of the Developers Guide
+
+PRJ=../../../..
+SETTINGS=$(PRJ)/settings
+
+include $(SETTINGS)/settings.mk
+include $(SETTINGS)/std.mk
+
+# Define non-platform/compiler specific settings
+SAMPLE_NAME=ProfUnoCppBinding
+SAMPLE_INC_OUT = $(OUT_INC)/$(SAMPLE_NAME)
+SAMPLE_GEN_OUT = $(OUT_MISC)/$(SAMPLE_NAME)
+SAMPLE_OBJ_OUT=$(OUT_OBJ)/$(SAMPLE_NAME)
+
+APP1_NAME=office_connect
+APP1_BINARY=$(OUT_BIN)/$(APP1_NAME)$(EXE_EXT)
+
+APP2_NAME=string_samples
+APP2_BINARY=$(OUT_BIN)/$(APP2_NAME)$(EXE_EXT)
+
+ENV_OFFICE_TYPES=-env:URE_MORE_TYPES=$(URLPREFIX)$(OFFICE_TYPES)
+
+CXXFILES = \
+ office_connect.cxx \
+ string_samples.cxx
+
+# Targets
+.PHONY: ALL
+ALL : \
+ ProUNOCppBindingExample
+
+include $(SETTINGS)/stdtarget.mk
+
+$(SAMPLE_OBJ_OUT)/%.$(OBJ_EXT) : %.cxx $(SDKTYPEFLAG)
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ $(CC) $(CC_FLAGS) $(CC_INCLUDES) -I$(SAMPLE_INC_OUT) $(CC_DEFINES) $(CC_OUTPUT_SWITCH)$(subst /,$(PS),$@) $<
+
+$(OUT_BIN)/%$(EXE_EXT) : $(SAMPLE_OBJ_OUT)/%.$(OBJ_EXT)
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ -$(MKDIR) $(subst /,$(PS),$(SAMPLE_GEN_OUT))
+ifeq "$(OS)" "WIN"
+ $(LINK) $(EXE_LINK_FLAGS) /OUT:$@ /MAP:$(SAMPLE_GEN_OUT)/$(subst $(EXE_EXT),.map,$(@F)) \
+ $< $(CPPUHELPERLIB) $(CPPULIB) $(SALHELPERLIB) $(SALLIB)
+else
+ $(LINK) $(EXE_LINK_FLAGS) $(LINK_LIBS) -o $@ $< \
+ $(CPPUHELPERLIB) $(CPPULIB) $(SALHELPERLIB) $(SALLIB) $(STDC++LIB)
+ifeq "$(OS)" "MACOSX"
+ $(INSTALL_NAME_URELIBS_BIN) $@
+endif
+endif
+
+$(OUT_BIN)/office_connect$(EXE_EXT) : $(SAMPLE_OBJ_OUT)/office_connect.$(OBJ_EXT)
+
+$(OUT_BIN)/string_samples$(EXE_EXT) : $(SAMPLE_OBJ_OUT)/string_samples.$(OBJ_EXT)
+
+ProUNOCppBindingExample : $(APP1_BINARY) $(APP2_BINARY)
+ @echo --------------------------------------------------------------------------------
+ @echo Note: For the "$(QM)$(APP1_NAME)$(QM)" example you need a running office listening
+ @echo $(SQM) $(SQM)on port 2083. The example use the defaultBootstrap_InitialComponentContext method and provides
+ @echo $(SQM) $(SQM)the additional office types via the UNO environment variable -env:URE_MORE_TYPES=...
+ @echo $(SQM) $(SQM)Before you can run this example you have to start your office in listening mode.
+ @echo -
+ @echo $(SQM) $(SQM)soffice "$(QM)--accept=socket,host=localhost,port=2083;urp;StarOffice.ServiceManager$(QM)"
+ @echo -----
+ @echo Please use one of the following commands to execute the examples!
+ @echo -
+ @echo $(MAKE) $(APP1_NAME).run
+ @echo $(MAKE) $(APP2_NAME).run
+ @echo --------------------------------------------------------------------------------
+
+%.run: $(OUT_BIN)/%$(EXE_EXT)
+ cd $(subst /,$(PS),$(OUT_BIN)) && $(basename $@)
+
+$(API1_NAME).run: $(API1_BINARY)
+ cd $(subst /,$(PS),$(OUT_BIN)) && $(basename $@) $(ENV_OFFICE_TYPES)
+
+.PHONY: clean
+clean :
+ -$(DELRECURSIVE) $(subst /,$(PS),$(SAMPLE_INC_OUT))
+ -$(DELRECURSIVE) $(subst /,$(PS),$(SAMPLE_GEN_OUT))
+ -$(DELRECURSIVE) $(subst /,$(PS),$(SAMPLE_OBJ_OUT))
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$(OUT_BIN)/$(APP1_NAME)*))
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$(OUT_BIN)/$(APP2_NAME)*))
diff --git a/odk/examples/DevelopersGuide/ProfUNO/CppBinding/office_connect.cxx b/odk/examples/DevelopersGuide/ProfUNO/CppBinding/office_connect.cxx
new file mode 100644
index 000000000..c51ca17f8
--- /dev/null
+++ b/odk/examples/DevelopersGuide/ProfUNO/CppBinding/office_connect.cxx
@@ -0,0 +1,110 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+#include <stdio.h>
+
+#include <sal/main.h>
+
+#include <cppuhelper/bootstrap.hxx>
+#include <com/sun/star/bridge/XUnoUrlResolver.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/lang/XMultiComponentFactory.hpp>
+
+using namespace com::sun::star::uno;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::bridge;
+using namespace cppu;
+
+using ::rtl::OString;
+using ::rtl::OUString;
+using ::rtl::OUStringToOString;
+
+SAL_IMPLEMENT_MAIN()
+{
+ // create the initial component context
+ Reference< XComponentContext > rComponentContext =
+ defaultBootstrap_InitialComponentContext();
+
+ // retrieve the servicemanager from the context
+ Reference< XMultiComponentFactory > rServiceManager =
+ rComponentContext->getServiceManager();
+
+ // instantiate a sample service with the servicemanager.
+ Reference< XInterface > rInstance =
+ rServiceManager->createInstanceWithContext(
+ "com.sun.star.bridge.UnoUrlResolver",
+ rComponentContext );
+
+ // Query for the XUnoUrlResolver interface
+ Reference< XUnoUrlResolver > rResolver( rInstance, UNO_QUERY );
+
+ if( ! rResolver.is() )
+ {
+ printf( "Error: Couldn't instantiate com.sun.star.bridge.UnoUrlResolver service\n" );
+ return 1;
+ }
+ try
+ {
+ // resolve the uno-url
+ rInstance = rResolver->resolve( OUString(
+ "uno:socket,host=localhost,port=2083;urp;StarOffice.ServiceManager" ) );
+
+ if( ! rInstance.is() )
+ {
+ printf( "StarOffice.ServiceManager is not exported from remote counterpart\n" );
+ return 1;
+ }
+
+ // query for the simpler XMultiServiceFactory interface, sufficient for scripting
+ Reference< XMultiServiceFactory > rOfficeServiceManager (rInstance, UNO_QUERY);
+
+ if( ! rInstance.is() )
+ {
+ printf( "XMultiServiceFactory interface is not exported for StarOffice.ServiceManager\n" );
+ return 1;
+ }
+
+ printf( "Connected successfully to the office\n" );
+ }
+ catch( Exception &e )
+ {
+ OString o = OUStringToOString( e.Message, RTL_TEXTENCODING_ASCII_US );
+ printf( "Error: %s\n", o.pData->buffer );
+ return 1;
+ }
+ return 0;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/ProfUNO/CppBinding/string_samples.cxx b/odk/examples/DevelopersGuide/ProfUNO/CppBinding/string_samples.cxx
new file mode 100644
index 000000000..f8bb34f97
--- /dev/null
+++ b/odk/examples/DevelopersGuide/ProfUNO/CppBinding/string_samples.cxx
@@ -0,0 +1,85 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+#include <stdio.h>
+#include <cmath>
+#include <sal/main.h>
+
+#include <rtl/ustrbuf.hxx>
+#include <rtl/string.hxx>
+
+using rtl::OUString;
+using rtl::OUStringBuffer;
+using rtl::OString;
+
+SAL_IMPLEMENT_MAIN()
+{
+ // string concatenation
+
+ sal_Int32 n = 42;
+
+ // give it an initial size, should be a good guess.
+ // stringbuffer extends if necessary
+ OUStringBuffer buf(128);
+
+ // append an ascii string
+ buf.append("pi ( here ");
+
+ // numbers can be simply appended
+ buf.append(M_PI);
+
+ // lets the compiler count the stringlength, so this is more efficient than
+ // the above appendAscii call, where length of the string must be calculated at
+ // runtime
+ buf.append(" ) multiplied with ");
+ buf.append(n);
+ buf.append(" gives ");
+ buf.append((double)(n * M_PI));
+ buf.append(".");
+
+ // now transfer the buffer into the string.
+ // afterwards buffer is empty and may be reused again !
+ OUString string = buf.makeStringAndClear();
+
+ // I could of course also used the OStringBuffer directly
+ OString oString = rtl::OUStringToOString(string, RTL_TEXTENCODING_ASCII_US);
+
+ // just to print something
+ printf("%s\n", oString.getStr());
+
+ return 0;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/ProfUNO/InterprocessConn/ConnectionAwareClient.java b/odk/examples/DevelopersGuide/ProfUNO/InterprocessConn/ConnectionAwareClient.java
new file mode 100644
index 000000000..136400544
--- /dev/null
+++ b/odk/examples/DevelopersGuide/ProfUNO/InterprocessConn/ConnectionAwareClient.java
@@ -0,0 +1,255 @@
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+import java.awt.*;
+import java.awt.event.*;
+
+import com.sun.star.uno.XComponentContext;
+import com.sun.star.lang.XMultiComponentFactory;
+import com.sun.star.frame.XComponentLoader;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.connection.XConnector;
+import com.sun.star.connection.XConnection;
+
+import com.sun.star.beans.XPropertySet;
+
+import com.sun.star.lang.XComponent;
+
+import com.sun.star.bridge.XBridgeFactory;
+import com.sun.star.bridge.XBridge;
+
+
+public class ConnectionAwareClient extends java.awt.Frame
+ implements ActionListener , com.sun.star.lang.XEventListener
+{
+ private final Button _btnWriter;
+ private final Label _txtLabel;
+ private final String _url;
+
+ private final XComponentContext _ctx;
+
+ private com.sun.star.frame.XComponentLoader _officeComponentLoader;
+
+ public ConnectionAwareClient( XComponentContext ctx , String url )
+ {
+ _url = url;
+ _ctx = ctx;
+
+ Panel p1 = new Panel();
+ _btnWriter = new Button("New writer");
+ Button _btnCalc = new Button("New calc");
+ _txtLabel = new Label( "disconnected" );
+
+ _btnWriter.addActionListener(this);
+ _btnCalc.addActionListener(this);
+ p1.add( _btnWriter );
+ p1.add( _btnCalc );
+ p1.add( _txtLabel );
+
+ addWindowListener(
+ new WindowAdapter()
+ {
+ @Override
+ public void windowClosing(WindowEvent event)
+ {
+ System.exit(0);
+ }
+ }
+ );
+
+ add( p1 );
+ }
+
+ public void disposing( com.sun.star.lang.EventObject event )
+ {
+ // remote bridge has gone down, because the office crashed or was terminated.
+ _officeComponentLoader = null;
+ _txtLabel.setText( "disconnected" );
+ }
+
+ public void actionPerformed( ActionEvent event )
+ {
+ try
+ {
+ String sUrl;
+ if( event.getSource() == _btnWriter )
+ {
+ sUrl = "private:factory/swriter";
+ }
+ else
+ {
+ sUrl = "private:factory/scalc";
+ }
+ getComponentLoader().loadComponentFromURL(
+ sUrl, "_blank", 0,new com.sun.star.beans.PropertyValue[0] );
+ _txtLabel.setText( "connected" );
+ }
+ catch ( com.sun.star.connection.NoConnectException exc )
+ {
+ _txtLabel.setText( exc.getMessage() );
+ }
+ catch ( com.sun.star.uno.Exception exc )
+ {
+ _txtLabel.setText( exc.getMessage() );
+ throw new java.lang.RuntimeException( exc );
+ }
+ }
+
+ /** separates the uno-url into 3 different parts.
+ */
+ protected static String[] parseUnoUrl( String url )
+ {
+ String [] aRet = new String [3];
+
+ if( ! url.startsWith( "uno:" ) )
+ {
+ return null;
+ }
+
+ int semicolon = url.indexOf( ';' );
+ if( semicolon == -1 )
+ return null;
+
+ aRet[0] = url.substring( 4 , semicolon );
+ int nextSemicolon = url.indexOf( ';' , semicolon+1);
+
+ if( semicolon == -1 )
+ return null;
+ aRet[1] = url.substring( semicolon+1, nextSemicolon );
+
+ aRet[2] = url.substring( nextSemicolon+1);
+ return aRet;
+ }
+
+
+
+ protected com.sun.star.frame.XComponentLoader getComponentLoader()
+ throws com.sun.star.uno.Exception
+ {
+ XComponentLoader officeComponentLoader = _officeComponentLoader;
+
+ if( officeComponentLoader == null )
+ {
+ // instantiate connector service
+ Object x = _ctx.getServiceManager().createInstanceWithContext(
+ "com.sun.star.connection.Connector", _ctx );
+
+ XConnector xConnector = UnoRuntime.queryInterface(XConnector.class, x);
+
+ String a[] = parseUnoUrl( _url );
+ if( null == a )
+ {
+ throw new com.sun.star.uno.Exception( "Couldn't parse uno-url "+ _url );
+ }
+
+ // connect using the connection string part of the uno-url only.
+ XConnection connection = xConnector.connect( a[0] );
+
+ x = _ctx.getServiceManager().createInstanceWithContext(
+ "com.sun.star.bridge.BridgeFactory", _ctx );
+
+ XBridgeFactory xBridgeFactory = UnoRuntime.queryInterface(
+ XBridgeFactory.class , x );
+
+ // create a nameless bridge with no instance provider
+ // using the middle part of the uno-url
+ XBridge bridge = xBridgeFactory.createBridge( "" , a[1] , connection , null );
+
+ // query for the XComponent interface and add this as event listener
+ XComponent xComponent = UnoRuntime.queryInterface(
+ XComponent.class, bridge );
+ xComponent.addEventListener( this );
+
+ // get the remote instance
+ x = bridge.getInstance( a[2] );
+
+ // Did the remote server export this object ?
+ if( null == x )
+ {
+ throw new com.sun.star.uno.Exception(
+ "Server didn't provide an instance for" + a[2], null );
+ }
+
+ // Query the initial object for its main factory interface
+ XMultiComponentFactory xOfficeMultiComponentFactory = UnoRuntime.queryInterface( XMultiComponentFactory.class, x );
+
+ // retrieve the component context (it's not yet exported from the office)
+ // Query for the XPropertySet interface.
+ XPropertySet xProperySet = UnoRuntime.queryInterface( XPropertySet.class, xOfficeMultiComponentFactory );
+
+ // Get the default context from the office server.
+ Object oDefaultContext =
+ xProperySet.getPropertyValue( "DefaultContext" );
+
+ // Query for the interface XComponentContext.
+ XComponentContext xOfficeComponentContext =
+ UnoRuntime.queryInterface(
+ XComponentContext.class, oDefaultContext );
+
+
+ // now create the desktop service
+ // NOTE: use the office component context here !
+ Object oDesktop = xOfficeMultiComponentFactory.createInstanceWithContext(
+ "com.sun.star.frame.Desktop", xOfficeComponentContext );
+
+ officeComponentLoader = UnoRuntime.queryInterface( XComponentLoader.class, oDesktop );
+
+ if( officeComponentLoader == null )
+ {
+ throw new com.sun.star.uno.Exception(
+ "Couldn't instantiate com.sun.star.frame.Desktop" , null );
+ }
+ _officeComponentLoader = officeComponentLoader;
+ }
+ return officeComponentLoader;
+ }
+
+ public static void main( String [] args ) throws java.lang.Exception
+ {
+ if( args.length != 1 )
+ {
+ System.out.println( "usage: ConnectionAwareClient uno-url" );
+ return;
+ }
+ XComponentContext ctx =
+ com.sun.star.comp.helper.Bootstrap.createInitialComponentContext( null );
+
+ ConnectionAwareClient connAware = new ConnectionAwareClient( ctx, args[0]);
+ connAware.pack();
+ connAware.setVisible( true );
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/ProfUNO/InterprocessConn/Makefile b/odk/examples/DevelopersGuide/ProfUNO/InterprocessConn/Makefile
new file mode 100644
index 000000000..84920642c
--- /dev/null
+++ b/odk/examples/DevelopersGuide/ProfUNO/InterprocessConn/Makefile
@@ -0,0 +1,85 @@
+#*************************************************************************
+#
+# The Contents of this file are made available subject to the terms of
+# the BSD license.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+# 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+# contributors may be used to endorse or promote products derived
+# from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+# TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+# USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+#**************************************************************************
+
+# Builds the ProfUNO interprocess example of the Developers Guide.
+
+PRJ=../../../..
+SETTINGS=$(PRJ)/settings
+
+include $(SETTINGS)/settings.mk
+include $(SETTINGS)/std.mk
+
+# Define non-platform/compiler specific settings
+EXAMPLE_NAME=ProfUNOInterprocessExamples
+OUT_APP_CLASS=$(OUT_CLASS)/$(EXAMPLE_NAME)
+
+JAVAFILES = \
+ ConnectionAwareClient.java \
+ UrlResolver.java
+
+CLASSFILES = $(patsubst %.java,$(OUT_APP_CLASS)/%.class,$(JAVAFILES))
+
+SDK_CLASSPATH = $(subst $(EMPTYSTRING) $(PATH_SEPARATOR),$(PATH_SEPARATOR),$(CLASSPATH)\
+ $(PATH_SEPARATOR)$(OUT_APP_CLASS))
+
+
+# Targets
+.PHONY: ALL
+ALL : $(EXAMPLE_NAME)
+
+include $(SETTINGS)/stdtarget.mk
+
+$(OUT_APP_CLASS)/%.class : %.java
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ $(SDK_JAVAC) $(JAVAC_FLAGS) -classpath "$(SDK_CLASSPATH)" -d $(OUT_APP_CLASS) $<
+
+$(EXAMPLE_NAME) : $(CLASSFILES)
+ @echo --------------------------------------------------------------------------------
+ @echo Note: For these examples you need a running office listening on port 2083.
+ @echo $(SQM) $(SQM)Before you run these examples you have to start your office with
+ @echo -
+ @echo $(SQM) $(SQM)soffice "$(QM)--accept=socket,host=localhost,port=2083;urp;StarOffice.ServiceManager$(QM)"
+ @echo -----
+ @echo Please use one of the following commands to execute the examples!
+ @echo -
+ @echo $(MAKE) ConnectionAwareClient.run
+ @echo $(MAKE) UrlResolver.run
+ @echo --------------------------------------------------------------------------------
+
+%.run: $(OUT_APP_CLASS)/%.class
+ $(SDK_JAVA) -classpath "$(SDK_CLASSPATH)" $(basename $@) "uno:socket,host=localhost,port=2083;urp;StarOffice.ServiceManager"
+
+.PHONY: clean
+clean :
+ -$(DELRECURSIVE) $(subst /,$(PS),$(OUT_APP_CLASS))
diff --git a/odk/examples/DevelopersGuide/ProfUNO/InterprocessConn/UrlResolver.java b/odk/examples/DevelopersGuide/ProfUNO/InterprocessConn/UrlResolver.java
new file mode 100644
index 000000000..b05c4b7b5
--- /dev/null
+++ b/odk/examples/DevelopersGuide/ProfUNO/InterprocessConn/UrlResolver.java
@@ -0,0 +1,112 @@
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+import com.sun.star.bridge.XUnoUrlResolver;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.XComponentContext;
+import com.sun.star.lang.XMultiComponentFactory;
+
+
+class UrlResolver
+{
+ public static void main( String [] args ) throws java.lang.Exception
+ {
+ if( args.length != 1 )
+ {
+ System.out.println( "usage: UrlResolver uno-url\n" +
+ " uno-url The uno-url identifying the object to\n" +
+ " be imported, for instance\n" +
+ " uno:socket,host=localhost,port=2083;urp;StarOffice.ServiceManager" +
+ " (use \" on unix shells to avoid ;-problems" );
+ System.exit( 1 );
+ }
+
+ // create default local component context
+ XComponentContext xLocalContext =
+ com.sun.star.comp.helper.Bootstrap.createInitialComponentContext(null);
+
+ // initial serviceManager
+ XMultiComponentFactory xLocalServiceManager = xLocalContext.getServiceManager();
+
+ // create a urlresolver
+ Object urlResolver = xLocalServiceManager.createInstanceWithContext(
+ "com.sun.star.bridge.UnoUrlResolver", xLocalContext );
+
+ // query for the XUnoUrlResolver interface
+ XUnoUrlResolver xUrlResolver =
+ UnoRuntime.queryInterface( XUnoUrlResolver.class, urlResolver );
+
+ try
+ {
+ // Import the object
+ Object rInitialObject = xUrlResolver.resolve( args[0] );
+
+ // XComponentContext
+ if( null != rInitialObject )
+ {
+ System.out.println( "initial object successfully retrieved" );
+ }
+ else
+ {
+ System.out.println( "given initial-object name unknown at server side" );
+ }
+ }
+ catch( com.sun.star.connection.NoConnectException e )
+ {
+ System.out.println( "Couldn't connect to remote server" );
+ System.out.println( e.getMessage() );
+ }
+ catch( com.sun.star.connection.ConnectionSetupException e )
+ {
+ System.out.println( "Couldn't access necessary local resource to establish the interprocess connection" );
+ System.out.println( e.getMessage() );
+ }
+ catch( com.sun.star.lang.IllegalArgumentException e )
+ {
+ System.out.println( "uno-url is syntactical illegal ( " + args[0] + " )" );
+ System.out.println( e.getMessage() );
+ }
+ catch( com.sun.star.uno.RuntimeException e )
+ {
+ System.out.println( "RuntimeException" );
+ System.out.println( e.getMessage() );
+ }
+ finally {
+ System.exit(0);
+ }
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/ProfUNO/Lifetime/Makefile b/odk/examples/DevelopersGuide/ProfUNO/Lifetime/Makefile
new file mode 100644
index 000000000..2b3347459
--- /dev/null
+++ b/odk/examples/DevelopersGuide/ProfUNO/Lifetime/Makefile
@@ -0,0 +1,112 @@
+#*************************************************************************
+#
+# The Contents of this file are made available subject to the terms of
+# the BSD license.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+# 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+# contributors may be used to endorse or promote products derived
+# from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+# TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+# USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+#**************************************************************************
+
+# Builds the ProfUNO lifetime example of the Developers Guide
+
+PRJ=../../../..
+SETTINGS=$(PRJ)/settings
+
+include $(SETTINGS)/settings.mk
+include $(SETTINGS)/std.mk
+
+# Define non-platform/compiler specific settings
+COMPONENT_NAME=ProfUnoLifetime
+OUT_COMP_CLASS=$(OUT_CLASS)/$(COMPONENT_NAME)
+OUT_COMP_INC=$(OUT_INC)/$(COMPONENT_NAME)
+OUT_COMP_GEN=$(OUT_MISC)/$(COMPONENT_NAME)
+OUT_COMP_OBJ=$(OUT_OBJ)/$(COMPONENT_NAME)
+
+JAVAFILES = \
+ MyUnoObject.java
+
+CLASSFILES = $(patsubst %.java,$(OUT_COMP_CLASS)/JavaComp/%.class,$(JAVAFILES))
+
+CXXFILES = object_lifetime.cxx
+
+OBJFILES = $(patsubst %.cxx,$(OUT_COMP_OBJ)/%.$(OBJ_EXT),$(CXXFILES))
+
+SDK_CLASSPATH = $(subst $(EMPTYSTRING) $(PATH_SEPARATOR),$(PATH_SEPARATOR),$(CLASSPATH)\
+ $(PATH_SEPARATOR)$(OUT_COMP_CLASS))
+
+
+# Targets
+.PHONY: ALL
+ALL : \
+ ProUNOLifetimeExamples
+
+include $(SETTINGS)/stdtarget.mk
+
+$(OUT_COMP_CLASS)/%.class : %.java
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ $(SDK_JAVAC) $(JAVAC_FLAGS) -classpath "$(SDK_CLASSPATH)" -d $(OUT_COMP_CLASS) $<
+
+$(OUT_COMP_OBJ)/%.$(OBJ_EXT) : %.cxx $(SDKTYPEFLAG)
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ $(CC) $(CC_FLAGS) $(CC_INCLUDES) -I$(OUT_COMP_INC) $(CC_DEFINES) $(CC_OUTPUT_SWITCH)$(subst /,$(PS),$@) $<
+
+$(OUT_BIN)/$(COMPONENT_NAME)$(EXE_EXT) : $(OBJFILES)
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ -$(MKDIR) $(subst /,$(PS),$(OUT_COMP_GEN))
+ifeq "$(OS)" "WIN"
+ $(LINK) $(EXE_LINK_FLAGS) /OUT:$@ /MAP:$(OUT_COMP_GEN)/$(subst $(EXE_EXT),.map,$(@F)) \
+ $(OBJFILES) $(CPPUHELPERLIB) $(CPPULIB) $(SALHELPERLIB) $(SALLIB)
+else
+ $(LINK) $(EXE_LINK_FLAGS) $(LINK_LIBS) -o $@ $(OBJFILES) \
+ $(CPPUHELPERLIB) $(CPPULIB) $(SALHELPERLIB) $(SALLIB) $(STDC++LIB)
+ifeq "$(OS)" "MACOSX"
+ $(INSTALL_NAME_URELIBS_BIN) $@
+endif
+endif
+
+ProUNOLifetimeExamples : $(OUT_BIN)/$(COMPONENT_NAME)$(EXE_EXT) $(OUT_COMP_CLASS)/MyUnoObject.class
+ @echo --------------------------------------------------------------------------------
+ @echo Please use one of the following commands to execute the examples!
+ @echo -
+ @echo $(MAKE) MyUnoObject.run
+ @echo $(MAKE) ProfUnoLifetime.runexe
+ @echo --------------------------------------------------------------------------------
+
+%.run: $(OUT_COMP_CLASS)/%.class
+ $(SDK_JAVA) -classpath "$(SDK_CLASSPATH)" $(basename $@)
+
+%.runexe: $(OUT_BIN)/%$(EXE_EXT)
+ cd $(subst /,$(PS),$(OUT_BIN)) && $(basename $@)
+
+.PHONY: clean
+clean :
+ -$(DELRECURSIVE) $(subst /,$(PS),$(OUT_COMP_INC))
+ -$(DELRECURSIVE) $(subst /,$(PS),$(OUT_COMP_CLASS))
+ -$(DELRECURSIVE) $(subst /,$(PS),$(OUT_COMP_GEN))
+ -$(DELRECURSIVE) $(subst /,$(PS),$(OUT_COMP_OBJ))
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$(OUT_BIN)/$(COMPONENT_NAME)$(EXE_EXT)))
diff --git a/odk/examples/DevelopersGuide/ProfUNO/Lifetime/MyUnoObject.java b/odk/examples/DevelopersGuide/ProfUNO/Lifetime/MyUnoObject.java
new file mode 100644
index 000000000..516481a8f
--- /dev/null
+++ b/odk/examples/DevelopersGuide/ProfUNO/Lifetime/MyUnoObject.java
@@ -0,0 +1,63 @@
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+class MyUnoObject implements com.sun.star.uno.XInterface
+{
+
+ @Override
+ protected void finalize() throws Throwable {
+ System.out.println( "finalizer called" );
+ super.finalize();
+ }
+
+ public static void main( String args[] ) throws InterruptedException
+ {
+ com.sun.star.uno.XInterface a = new MyUnoObject();
+ a = null;
+
+ // ask the garbage collector politely
+ System.gc();
+ synchronized( Thread.currentThread() )
+ {
+ // wait a second
+ Thread.currentThread().wait( 1000 );
+ }
+ System.out.println( "leaving" );
+
+ // It is java VM dependent, whether the finalizer was called or not
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/ProfUNO/Lifetime/object_lifetime.cxx b/odk/examples/DevelopersGuide/ProfUNO/Lifetime/object_lifetime.cxx
new file mode 100644
index 000000000..86cd5b356
--- /dev/null
+++ b/odk/examples/DevelopersGuide/ProfUNO/Lifetime/object_lifetime.cxx
@@ -0,0 +1,69 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+#include <stdio.h>
+
+#include <cppuhelper/weak.hxx>
+
+class MyOWeakObject : public ::cppu::OWeakObject
+{
+public:
+ MyOWeakObject() { fprintf(stdout, "constructed\n"); }
+ ~MyOWeakObject() { fprintf(stdout, "destructed\n"); }
+};
+
+void simple_object_creation_and_destruction()
+{
+ // create the UNO object
+ com::sun::star::uno::XInterface* p = new MyOWeakObject();
+
+ // acquire it, refcount becomes one
+ p->acquire();
+
+ fprintf(stdout, "before release\n");
+
+ // release it, refcount drops to zero
+ p->release();
+
+ fprintf(stdout, "after release\n");
+}
+
+int main()
+{
+ simple_object_creation_and_destruction();
+ return 0;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/ProfUNO/SimpleBootstrap_cpp/Makefile b/odk/examples/DevelopersGuide/ProfUNO/SimpleBootstrap_cpp/Makefile
new file mode 100644
index 000000000..de4604e82
--- /dev/null
+++ b/odk/examples/DevelopersGuide/ProfUNO/SimpleBootstrap_cpp/Makefile
@@ -0,0 +1,100 @@
+#*************************************************************************
+#
+# The Contents of this file are made available subject to the terms of
+# the BSD license.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+# 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+# contributors may be used to endorse or promote products derived
+# from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+# TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+# USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+#**************************************************************************
+
+# Builds the SimpleBootstrap_cpp example of the SDK.
+
+PRJ=../../../..
+SETTINGS=$(PRJ)/settings
+
+include $(SETTINGS)/settings.mk
+include $(SETTINGS)/std.mk
+
+# Define non-platform/compiler specific settings
+APP_NAME=SimpleBootstrap_cpp
+
+OUT_APP_INC = $(OUT_INC)/$(APP_NAME)
+OUT_APP_GEN = $(OUT_MISC)/$(APP_NAME)
+OUT_APP_OBJ=$(OUT_OBJ)/$(APP_NAME)
+
+CXXFILES = SimpleBootstrap_cpp.cxx
+
+OBJFILES = $(patsubst %.cxx,$(OUT_SLO_COMP)/%.$(OBJ_EXT),$(CXXFILES))
+
+# Targets
+.PHONY: ALL
+ALL : \
+ SimpleBootstrapCppExample
+
+include $(SETTINGS)/stdtarget.mk
+
+$(OUT_APP_OBJ)/%.$(OBJ_EXT) : %.cxx $(SDKTYPEFLAG)
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ $(CC) $(CC_FLAGS) $(CC_INCLUDES) -I$(OUT_APP_INC) $(CC_DEFINES) $(CC_OUTPUT_SWITCH)$(subst /,$(PS),$@) $<
+
+$(OUT_BIN)/_$(APP_NAME)$(EXE_EXT) : $(OUT_APP_OBJ)/$(APP_NAME).$(OBJ_EXT)
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ -$(MKDIR) $(subst /,$(PS),$(OUT_APP_GEN))
+ifeq "$(OS)" "WIN"
+ $(LINK) $(EXE_LINK_FLAGS) /OUT:$@ /MAP:$(OUT_APP_GEN)/$(basename $(@F)).map \
+ $< $(CPPUHELPERLIB) $(CPPULIB) $(SALHELPERLIB) $(SALLIB)
+else
+ $(LINK) $(EXE_LINK_FLAGS) $(LINK_LIBS) -o $@ $< \
+ $(CPPUHELPERLIB) $(CPPULIB) $(SALHELPERLIB) $(SALLIB) $(STDC++LIB)
+ifeq "$(OS)" "MACOSX"
+ $(INSTALL_NAME_URELIBS_BIN) $@
+endif
+endif
+
+$(OUT_BIN)/$(APP_NAME)$(EXE_EXT) : $(OUT_BIN)/_$(APP_NAME)$(EXE_EXT)
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ $(COPY) $(subst /,$(PS),$(BIN_DIR)/unoapploader$(EXE_EXT)) $(subst /,$(PS),$@)
+# workaround for touch problem under Windows with full qualified paths
+ make -t $@
+
+SimpleBootstrapCppExample : $(OUT_BIN)/$(APP_NAME)$(EXE_EXT)
+ @echo --------------------------------------------------------------------------------
+ @echo Please use the following command to execute the example!
+ @echo -
+ @echo $(MAKE) SimpleBootstrap_cpp.run
+ @echo --------------------------------------------------------------------------------
+
+%.run: $(OUT_BIN)/SimpleBootstrap_cpp$(EXE_EXT)
+ cd $(subst /,$(PS),$(OUT_BIN)) && $(basename $@)
+
+.PHONY: clean
+clean :
+ -$(DELRECURSIVE) $(subst /,$(PS),$(OUT_APP_INC))
+ -$(DELRECURSIVE) $(subst /,$(PS),$(OUT_APP_GEN))
+ -$(DELRECURSIVE) $(subst /,$(PS),$(OUT_APP_OBJ))
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$(OUT_BIN)/*SimpleBootstrap*))
diff --git a/odk/examples/DevelopersGuide/ProfUNO/SimpleBootstrap_cpp/SimpleBootstrap_cpp.cxx b/odk/examples/DevelopersGuide/ProfUNO/SimpleBootstrap_cpp/SimpleBootstrap_cpp.cxx
new file mode 100644
index 000000000..fe7354d48
--- /dev/null
+++ b/odk/examples/DevelopersGuide/ProfUNO/SimpleBootstrap_cpp/SimpleBootstrap_cpp.cxx
@@ -0,0 +1,104 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+#include <stdio.h>
+
+#include <sal/main.h>
+#include <cppuhelper/bootstrap.hxx>
+#include <com/sun/star/bridge/XUnoUrlResolver.hpp>
+#include <com/sun/star/frame/Desktop.hpp>
+#include <com/sun/star/frame/XComponentLoader.hpp>
+#include <com/sun/star/lang/XMultiComponentFactory.hpp>
+
+using namespace com::sun::star::uno;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::frame;
+
+using ::rtl::OUString;
+using ::rtl::OUStringToOString;
+
+SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv)
+{
+ try
+ {
+ // get the remote office component context
+ Reference< XComponentContext > xContext( ::cppu::bootstrap() );
+ if ( !xContext.is() )
+ {
+ fprintf(stderr, "no component context!\n");
+ return 1;
+ }
+
+ // get the remote office service manager
+ Reference< XMultiComponentFactory > xServiceManager(
+ xContext->getServiceManager() );
+ if ( !xServiceManager.is() )
+ {
+ fprintf(stderr, "no service manager!\n");
+ return 1;
+ }
+
+ // get an instance of the remote office desktop UNO service
+ // and query the XComponentLoader interface
+ Reference < XDesktop2 > xComponentLoader = Desktop::create(xContext);
+
+ // open a spreadsheet document
+ Reference< XComponent > xComponent( xComponentLoader->loadComponentFromURL(
+ OUString( "private:factory/scalc" ),
+ OUString( "_blank" ), 0,
+ Sequence < ::com::sun::star::beans::PropertyValue >() ) );
+ if ( !xComponent.is() )
+ {
+ fprintf(stderr, "opening spreadsheet document failed!\n");
+ return 1;
+ }
+ }
+ catch ( ::cppu::BootstrapException & e )
+ {
+ fprintf(stderr, "caught BootstrapException: %s\n",
+ OUStringToOString( e.getMessage(), RTL_TEXTENCODING_ASCII_US ).getStr());
+ return 1;
+ }
+ catch ( Exception & e )
+ {
+ fprintf(stderr, "caught UNO exception: %s\n",
+ OUStringToOString( e.Message, RTL_TEXTENCODING_ASCII_US ).getStr());
+ return 1;
+ }
+
+ return 0;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/ProfUNO/SimpleBootstrap_java/Makefile b/odk/examples/DevelopersGuide/ProfUNO/SimpleBootstrap_java/Makefile
new file mode 100644
index 000000000..819a61042
--- /dev/null
+++ b/odk/examples/DevelopersGuide/ProfUNO/SimpleBootstrap_java/Makefile
@@ -0,0 +1,90 @@
+#*************************************************************************
+#
+# The Contents of this file are made available subject to the terms of
+# the BSD license.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+# 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+# contributors may be used to endorse or promote products derived
+# from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+# TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+# USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+#**************************************************************************
+
+# Builds the SimpleBootstrap_java example.
+
+PRJ=../../../..
+SETTINGS=$(PRJ)/settings
+
+include $(SETTINGS)/settings.mk
+include $(SETTINGS)/std.mk
+
+# Define non-platform/compiler specific settings
+COMPONENT_NAME=SimpleBootstrap_java
+OUT_COMP_CLASS = $(OUT_CLASS)/$(COMPONENT_NAME)
+
+COMPONENT_JAR_NAME = $(COMPONENT_NAME).jar
+COMPONENT_JAR = $(OUT_CLASS)/$(COMPONENT_JAR_NAME)
+
+JAVAFILES = \
+ SimpleBootstrap_java.java
+
+CLASSFILES = $(patsubst %.java,$(OUT_COMP_CLASS)/%.class,$(JAVAFILES))
+
+SDK_CLASSPATH = $(subst $(EMPTYSTRING) $(PATH_SEPARATOR),$(PATH_SEPARATOR),$(CLASSPATH)\
+ $(PATH_SEPARATOR)$(OUT_COMP_CLASS))
+
+# Targets
+.PHONY: ALL
+ALL : \
+ SimpleBootstrapJavaExample
+
+include $(SETTINGS)/stdtarget.mk
+
+$(CLASSFILES) : $(JAVAFILES)
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ $(SDK_JAVAC) $(JAVAC_FLAGS) -classpath "$(SDK_CLASSPATH)" -d $(OUT_COMP_CLASS) $(JAVAFILES)
+
+$(OUT_CLASS)/%.jar : manifest.mf $(CLASSFILES)
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ $(SDK_JAR) cvfm $@ $< -C $(OUT_COMP_CLASS) .
+ $(SDK_JAR) uvf $@ $(SDK_JAVA_UNO_BOOTSTRAP_FILES)
+
+SimpleBootstrapJavaExample : $(COMPONENT_JAR)
+ @echo --------------------------------------------------------------------------------
+ @echo Please use the following command to execute the example!
+ @echo -
+ @echo $(MAKE) SimpleBootstrap_java.run
+ @echo --------------------------------------------------------------------------------
+
+# Setting the optional system property "com.sun.star.lib.loader.unopath" to the office
+# program path ensures that the configured SDK office is used. If the system property
+# is not specified, the default office installation is used.
+%.run: $(COMPONENT_JAR)
+ $(SDK_JAVA) -Dcom.sun.star.lib.loader.unopath="$(OFFICE_PROGRAM_PATH)" -jar $(COMPONENT_JAR)
+
+.PHONY: clean
+clean :
+ -$(DELRECURSIVE) $(subst /,$(PS),$(OUT_COMP_CLASS))
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$(COMPONENT_JAR)))
diff --git a/odk/examples/DevelopersGuide/ProfUNO/SimpleBootstrap_java/SimpleBootstrap_java.java b/odk/examples/DevelopersGuide/ProfUNO/SimpleBootstrap_java/SimpleBootstrap_java.java
new file mode 100644
index 000000000..0146dcb6d
--- /dev/null
+++ b/odk/examples/DevelopersGuide/ProfUNO/SimpleBootstrap_java/SimpleBootstrap_java.java
@@ -0,0 +1,77 @@
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+import com.sun.star.beans.PropertyValue;
+import com.sun.star.frame.XComponentLoader;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.XComponentContext;
+import com.sun.star.lang.XMultiComponentFactory;
+
+public class SimpleBootstrap_java {
+
+ public static void main(String[] args) {
+
+ try {
+ // get the remote office component context
+ XComponentContext xContext =
+ com.sun.star.comp.helper.Bootstrap.bootstrap();
+
+ // get the remote office service manager
+ XMultiComponentFactory xServiceManager =
+ xContext.getServiceManager();
+
+ // get an instance of the remote office desktop UNO service
+ Object desktop = xServiceManager.createInstanceWithContext(
+ "com.sun.star.frame.Desktop", xContext );
+
+ // query the XComponentLoader interface from the desktop
+ XComponentLoader xComponentLoader =
+ UnoRuntime.queryInterface(
+ XComponentLoader.class, desktop );
+
+ // load a spreadsheet document
+ String loadURL = "private:factory/scalc";
+ PropertyValue[] loadProps = new PropertyValue[0];
+ xComponentLoader.loadComponentFromURL(
+ loadURL, "_blank", 0, loadProps);
+ }
+ catch (java.lang.Exception e){
+ e.printStackTrace();
+ }
+ System.exit( 0 );
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/ProfUNO/SimpleBootstrap_java/manifest.mf b/odk/examples/DevelopersGuide/ProfUNO/SimpleBootstrap_java/manifest.mf
new file mode 100644
index 000000000..e1326fa0b
--- /dev/null
+++ b/odk/examples/DevelopersGuide/ProfUNO/SimpleBootstrap_java/manifest.mf
@@ -0,0 +1,4 @@
+Main-Class: com.sun.star.lib.loader.Loader
+
+Name: com/sun/star/lib/loader/Loader.class
+Application-Class: SimpleBootstrap_java
diff --git a/odk/examples/DevelopersGuide/ScriptingFramework/SayHello/META-INF/manifest.xml b/odk/examples/DevelopersGuide/ScriptingFramework/SayHello/META-INF/manifest.xml
new file mode 100644
index 000000000..e7bf06b4e
--- /dev/null
+++ b/odk/examples/DevelopersGuide/ScriptingFramework/SayHello/META-INF/manifest.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE manifest:manifest PUBLIC "-//OpenOffice.org//DTD Manifest 1.0//EN" "Manifest.dtd">
+<manifest:manifest xmlns:manifest="http://openoffice.org/2001/manifest">
+ <manifest:file-entry manifest:media-type="application/vnd.sun.star.framework-script" manifest:full-path="SayHello"/>
+</manifest:manifest>
diff --git a/odk/examples/DevelopersGuide/ScriptingFramework/SayHello/Makefile b/odk/examples/DevelopersGuide/ScriptingFramework/SayHello/Makefile
new file mode 100644
index 000000000..0df943224
--- /dev/null
+++ b/odk/examples/DevelopersGuide/ScriptingFramework/SayHello/Makefile
@@ -0,0 +1,128 @@
+#*************************************************************************
+#
+# The Contents of this file are made available subject to the terms of
+# the BSD license.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+# 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+# contributors may be used to endorse or promote products derived
+# from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+# TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+# USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+#**************************************************************************
+
+# Builds the OOoBean of the Developers Guide
+
+PRJ=../../../..
+SETTINGS=$(PRJ)/settings
+
+include $(SETTINGS)/settings.mk
+include $(SETTINGS)/std.mk
+
+# Define non-platform/compiler specific settings
+SAMPLE_NAME=SayHello
+SAMPLE_CLASS_OUT = $(OUT_CLASS)/ScriptingFramework/$(SAMPLE_NAME)
+SAMPLE_GEN_OUT = $(OUT_MISC)/ScriptingFramework
+
+SCRIPT_NAME=SayHello
+SCRIPT_CLASS_OUT=$(SAMPLE_CLASS_OUT)/$(SCRIPT_NAME)
+SCRIPT_GEN_OUT=$(SAMPLE_GEN_OUT)/$(SCRIPT_NAME)
+SCRIPT_JAR_NAME=$(SCRIPT_NAME).jar
+SCRIPT_JAR=$(SAMPLE_CLASS_OUT)/$(SCRIPT_JAR_NAME)
+SCRIPT_PACKAGE = $(OUT_BIN)/$(SCRIPT_NAME).$(UNOOXT_EXT)
+SCRIPT_PACKAGE_URL = $(subst \\,\,"$(COMP_PACKAGE_DIR)$(PS)$(SCRIPT_NAME).$(UNOOXT_EXT)")
+SCRIPT_REGISTERFLAG=$(SCRIPT_GEN_OUT)$(PS)devguide_scriptingframework_$(SCRIPT_NAME)_register_scriptpkg.flag
+
+JAVAFILES = \
+ SayHello/SayHello.java
+
+CLASSFILES = $(patsubst %.java,$(SCRIPT_CLASS_OUT)/%.class,$(subst $(SAMPLE_NAME)/,,$(JAVAFILES)))
+
+SDK_CLASSPATH = $(subst $(EMPTYSTRING) $(PATH_SEPARATOR),$(PATH_SEPARATOR),$(CLASSPATH)\
+ $(PATH_SEPARATOR)$(SAMPLE_CLASS_OUT))
+
+# Targets
+.PHONY: ALL
+ALL : \
+ SayHelloExample
+
+include $(SETTINGS)/stdtarget.mk
+
+$(CLASSFILES) : $(JAVAFILES)
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ $(SDK_JAVAC) $(JAVAC_FLAGS) -classpath "$(SDK_CLASSPATH)" -d $(SCRIPT_CLASS_OUT) $(JAVAFILES)
+
+$(SCRIPT_JAR) : $(CLASSFILES)
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ $(SDK_JAR) cvf $@ $(CLASSNAMES) -C $(SCRIPT_CLASS_OUT) .
+
+# rule for component package file
+$(SCRIPT_PACKAGE) : $(SCRIPT_JAR) META-INF/manifest.xml $(SCRIPT_NAME)/parcel-descriptor.xml
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ $(SDK_ZIP) $@ META-INF/manifest.xml $(SCRIPT_NAME)/parcel-descriptor.xml
+ cd $(subst /,$(PS),$(SAMPLE_CLASS_OUT)/..) && $(SDK_ZIP) -u ../../bin/$(@F) $(SAMPLE_NAME)/$(SCRIPT_JAR_NAME)
+
+$(SCRIPT_REGISTERFLAG) : $(SCRIPT_PACKAGE)
+ifeq "$(SDK_AUTO_DEPLOYMENT)" "YES"
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ $(DEPLOYTOOL) $(SCRIPT_PACKAGE_URL)
+ @echo flagged > $(subst /,$(PS),$@)
+else
+ @echo --------------------------------------------------------------------------------
+ @echo If you want to install your component automatically, please set the environment
+ @echo variable SDK_AUTO_DEPLOYMENT = YES. But note that auto deployment is only
+ @echo possible if no office instance is running.
+ @echo --------------------------------------------------------------------------------
+endif
+
+
+SayHelloExample : $(SCRIPT_REGISTERFLAG)
+ @echo --------------------------------------------------------------------------------
+ @echo The "$(QM)$(SCRIPT_NAME)$(QM)" scripting package was installed in your office installation
+ @echo if SDK_AUTO_DEPLOYMENT = YES. If you want to run the script, start the Office
+ @echo and use the Tools/Macros/Run Macro menu item.
+ @echo You can also load the document "$(QM)$(SCRIPT_NAME).odt$(QM)" and press the button to run the
+ @echo script.
+ @echo -
+ @echo $(MAKE) $(SCRIPT_NAME).odt.load
+ @echo --------------------------------------------------------------------------------
+
+$(SCRIPT_NAME).odt.load : $(SCRIPT_REGISTERFLAG)
+ "$(OFFICE_PROGRAM_PATH)$(PS)soffice" $(basename $@)
+
+%.run: $(CLASSFILES)
+ $(SDK_JAVA) -classpath "$(SDK_CLASSPATH)" $(subst /,.,$(PACKAGE)).$(basename $@)
+
+%.dbg: $(JAR1_JAR)
+ jdb -classpath "$(SDK_CLASSPATH)" $(subst /,.,$(PACKAGE)).$(basename $@)
+
+.PHONY: clean
+clean :
+ -$(DELRECURSIVE) $(subst /,$(PS),$(SAMPLE_CLASS_OUT))
+ -$(DELRECURSIVE) $(subst /,$(PS),$(SCRIPT_GEN_OUT))
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$(SCRIPT_PACKAGE_URL)))
+
diff --git a/odk/examples/DevelopersGuide/ScriptingFramework/SayHello/SayHello.odt b/odk/examples/DevelopersGuide/ScriptingFramework/SayHello/SayHello.odt
new file mode 100644
index 000000000..e18331915
--- /dev/null
+++ b/odk/examples/DevelopersGuide/ScriptingFramework/SayHello/SayHello.odt
Binary files differ
diff --git a/odk/examples/DevelopersGuide/ScriptingFramework/SayHello/SayHello/SayHello.java b/odk/examples/DevelopersGuide/ScriptingFramework/SayHello/SayHello/SayHello.java
new file mode 100644
index 000000000..22fd05188
--- /dev/null
+++ b/odk/examples/DevelopersGuide/ScriptingFramework/SayHello/SayHello/SayHello.java
@@ -0,0 +1,65 @@
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+import com.sun.star.script.provider.XScriptContext;
+
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.frame.XComponentLoader;
+import com.sun.star.lang.XComponent;
+import com.sun.star.text.XTextDocument;
+import com.sun.star.text.XTextRange;
+import com.sun.star.text.XText;
+import com.sun.star.beans.PropertyValue;
+import com.sun.star.awt.ActionEvent;
+
+public class SayHello
+{
+ public static void start(XScriptContext ctxt, ActionEvent e)
+ throws Exception
+ {
+ SayHello.start(ctxt);
+ }
+
+ public static void start(XScriptContext ctxt)
+ throws Exception
+ {
+ // getting the text document object
+ XTextDocument xTextDocument = createDocument(ctxt);
+
+ XText xText = xTextDocument.getText();
+ XTextRange xTextRange = xText.getEnd();
+ xTextRange.setString("Hello");
+ }
+
+ private static XTextDocument createDocument(XScriptContext ctxt)
+ throws Exception
+ {
+ XComponentLoader loader = UnoRuntime.queryInterface(
+ XComponentLoader.class, ctxt.getDesktop());
+
+ XComponent comp = loader.loadComponentFromURL(
+ "private:factory/swriter", "_blank", 4, new PropertyValue[0]);
+
+ XTextDocument doc = UnoRuntime.queryInterface( XTextDocument.class, comp);
+
+ return doc;
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/ScriptingFramework/SayHello/SayHello/parcel-descriptor.xml b/odk/examples/DevelopersGuide/ScriptingFramework/SayHello/SayHello/parcel-descriptor.xml
new file mode 100644
index 000000000..f1c395a3f
--- /dev/null
+++ b/odk/examples/DevelopersGuide/ScriptingFramework/SayHello/SayHello/parcel-descriptor.xml
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+-->
+<parcel language="Java" xmlns:parcel="scripting.dtd">
+ <script language="Java">
+ <locale lang="en">
+ <displayname value="SayHello"/>
+ <description>
+ Prints Hello in a Writer document
+ </description>
+ </locale>
+ <functionname value="SayHello.start"/>
+ <logicalname value="SayHello.start"/>
+ <languagedepprops>
+ <prop name="classpath" value="SayHello.jar"/>
+ </languagedepprops>
+ </script>
+</parcel>
diff --git a/odk/examples/DevelopersGuide/ScriptingFramework/SayHello/build.xml b/odk/examples/DevelopersGuide/ScriptingFramework/SayHello/build.xml
new file mode 100644
index 000000000..b79ac64ae
--- /dev/null
+++ b/odk/examples/DevelopersGuide/ScriptingFramework/SayHello/build.xml
@@ -0,0 +1,96 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+-->
+<project default="build">
+
+ <!-- =================== Global Properties ============================= -->
+ <property environment="env"/>
+ <property name="macroname" value="SayHello"/>
+ <property name="unopkgfile" value="${basedir}/${macroname}.uno.pkg"/>
+
+ <!-- ==================== initialise properties ========================= -->
+ <target name="checksdk">
+ <condition property="UsingSDK">
+ <available file="${env.OFFICE_PROGRAM_PATH}"/>
+ </condition>
+ </target>
+
+ <target name="initsdk" if="UsingSDK">
+ <property name="opp" value="${env.OFFICE_PROGRAM_PATH}"/>
+ </target>
+
+ <target name="initnosdk" unless="UsingSDK">
+ <fail unless="opp" message="Path to Office install not set"/>
+ </target>
+
+ <!-- ==================== classpath setting ============================ -->
+ <target name="init" depends="checksdk,initsdk,initnosdk">
+ <path id="scriptclasspath">
+ <pathelement location="${opp}/classes/libreoffice.jar"/>
+ <pathelement location="${opp}/classes/ScriptFramework.jar"/>
+ </path>
+ </target>
+
+ <!-- ====================== Clean Generated Files ===================== -->
+ <target name="clean">
+ <delete>
+ <fileset dir=".">
+ <include name="**/*.class"/>
+ <include name="**/*.jar"/>
+ <include name="**/*.uno.pkg"/>
+ </fileset>
+ </delete>
+ </target>
+
+ <!-- ===================== Compile the script ========================= -->
+ <target name="compile" depends="init">
+ <javac srcdir="${macroname}" destdir="${macroname}"
+ includes="**/*.java" classpathref="scriptclasspath"
+ debug="on" optimize="on" deprecation="on"/>
+ </target>
+
+ <!-- ====================== Build UNO Package ========================= -->
+ <target name="build" depends="compile">
+ <delete file="${unopkgfile}"/>
+
+ <jar jarfile="${macroname}/${macroname}.jar"
+ basedir="${macroname}" includes="*.class,*.gif">
+ </jar>
+
+ <zip zipfile="${unopkgfile}">
+ <fileset dir="${basedir}">
+ <include name="**/*.jar"/>
+ <include name="**/parcel-descriptor.xml"/>
+ <include name="**/manifest.xml"/>
+ </fileset>
+ </zip>
+ </target>
+
+ <!-- ====================== Deploy Generated Files ==================== -->
+ <target name="deploy" depends="build">
+ <exec executable="${opp}/unopkg">
+ <arg line="add"/>
+ <arg line="--force"/>
+ <arg path="${unopkgfile}"/>
+ </exec>
+ </target>
+
+ <!-- ========================= All In One Build ======================= -->
+ <target name="all" depends="clean,build,deploy"/>
+
+</project>
diff --git a/odk/examples/DevelopersGuide/ScriptingFramework/ScriptSelector/META-INF/manifest.xml b/odk/examples/DevelopersGuide/ScriptingFramework/ScriptSelector/META-INF/manifest.xml
new file mode 100644
index 000000000..0b86e92ad
--- /dev/null
+++ b/odk/examples/DevelopersGuide/ScriptingFramework/ScriptSelector/META-INF/manifest.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE manifest:manifest PUBLIC "-//OpenOffice.org//DTD Manifest 1.0//EN" "Manifest.dtd">
+<manifest:manifest xmlns:manifest="http://openoffice.org/2001/manifest">
+ <manifest:file-entry manifest:media-type="application/vnd.sun.star.framework-script" manifest:full-path="ScriptSelector"/>
+</manifest:manifest>
diff --git a/odk/examples/DevelopersGuide/ScriptingFramework/ScriptSelector/Makefile b/odk/examples/DevelopersGuide/ScriptingFramework/ScriptSelector/Makefile
new file mode 100644
index 000000000..6fa4046bd
--- /dev/null
+++ b/odk/examples/DevelopersGuide/ScriptingFramework/ScriptSelector/Makefile
@@ -0,0 +1,130 @@
+#*************************************************************************
+#
+# The Contents of this file are made available subject to the terms of
+# the BSD license.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+# 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+# contributors may be used to endorse or promote products derived
+# from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+# TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+# USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+#**************************************************************************
+
+# Builds the OOoBean of the Developers Guide
+
+PRJ=../../../..
+SETTINGS=$(PRJ)/settings
+
+include $(SETTINGS)/settings.mk
+include $(SETTINGS)/std.mk
+
+# Define non-platform/compiler specific settings
+SAMPLE_NAME=ScriptSelector
+SAMPLE_CLASS_OUT = $(OUT_CLASS)/ScriptingFramework/$(SAMPLE_NAME)
+SAMPLE_GEN_OUT = $(OUT_MISC)/ScriptingFramework
+
+SCRIPT_NAME=ScriptSelector
+SCRIPT_CLASS_OUT=$(SAMPLE_CLASS_OUT)/$(SCRIPT_NAME)
+SCRIPT_GEN_OUT=$(SAMPLE_GEN_OUT)/$(SCRIPT_NAME)
+SCRIPT_JAR_NAME=$(SCRIPT_NAME).jar
+SCRIPT_JAR=$(SAMPLE_CLASS_OUT)/$(SCRIPT_JAR_NAME)
+SCRIPT_PACKAGE = $(OUT_BIN)/$(SCRIPT_NAME).$(UNOOXT_EXT)
+SCRIPT_PACKAGE_URL = $(subst \\,\,"$(COMP_PACKAGE_DIR)$(PS)$(SCRIPT_NAME).$(UNOOXT_EXT)")
+SCRIPT_REGISTERFLAG=$(SCRIPT_GEN_OUT)$(PS)devguide_scriptingframework_$(SCRIPT_NAME)_register.flag
+
+JAVAFILES = \
+ ScriptSelector/ScriptSelector.java
+
+CLASSFILES = $(patsubst %.java,$(SCRIPT_CLASS_OUT)/%.class,$(subst $(SAMPLE_NAME)/,,$(JAVAFILES)))
+
+SDK_CLASSPATH = $(subst $(EMPTYSTRING) $(PATH_SEPARATOR),$(PATH_SEPARATOR),$(CLASSPATH)\
+ $(PATH_SEPARATOR)$(SAMPLE_CLASS_OUT))
+
+# Targets
+.PHONY: ALL
+ALL : ScriptSelectorExample
+
+include $(SETTINGS)/stdtarget.mk
+
+$(CLASSFILES) : $(JAVAFILES)
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ $(SDK_JAVAC) $(JAVAC_FLAGS) -classpath "$(SDK_CLASSPATH)" -d $(SCRIPT_CLASS_OUT) $(JAVAFILES)
+
+$(SCRIPT_JAR) : $(CLASSFILES) $(SCRIPT_NAME)/container.gif $(SCRIPT_NAME)/script.gif $(SCRIPT_NAME)/soffice.gif
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ $(COPY) $(subst /,$(PS),$(SCRIPT_NAME)/container.gif) $(subst /,$(PS),$(SCRIPT_CLASS_OUT))
+ $(COPY) $(subst /,$(PS),$(SCRIPT_NAME)/script.gif) $(subst /,$(PS),$(SCRIPT_CLASS_OUT))
+ $(COPY) $(subst /,$(PS),$(SCRIPT_NAME)/soffice.gif) $(subst /,$(PS),$(SCRIPT_CLASS_OUT))
+ $(SDK_JAR) cvf $@ -C $(SCRIPT_CLASS_OUT) .
+
+# rule for component package file
+$(SCRIPT_PACKAGE) : $(SCRIPT_JAR) META-INF/manifest.xml $(SCRIPT_NAME)/parcel-descriptor.xml
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ $(SDK_ZIP) $@ META-INF/manifest.xml $(SCRIPT_NAME)/parcel-descriptor.xml
+ cd $(subst /,$(PS),$(SAMPLE_CLASS_OUT)/..) && $(SDK_ZIP) -u ../../bin/$(@F) $(SAMPLE_NAME)/$(SCRIPT_JAR_NAME)
+
+$(SCRIPT_REGISTERFLAG) : $(SCRIPT_PACKAGE)
+ifeq "$(SDK_AUTO_DEPLOYMENT)" "YES"
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ $(DEPLOYTOOL) $(SCRIPT_PACKAGE_URL)
+ @echo flagged > $(subst /,$(PS),$@)
+else
+ @echo --------------------------------------------------------------------------------
+ @echo If you want to install your component automatically, please set the environment
+ @echo variable SDK_AUTO_DEPLOYMENT = YES. But note that auto deployment is only
+ @echo possible if no office instance is running.
+ @echo --------------------------------------------------------------------------------
+endif
+
+
+ScriptSelectorExample : $(SCRIPT_REGISTERFLAG)
+ @echo --------------------------------------------------------------------------------
+ @echo The "$(QM)$(SCRIPT_NAME)$(QM)" scripting package was installed in your office installation
+ @echo if SDK_AUTO_DEPLOYMENT = YES. If you want to run the script, start the Office
+ @echo and use the Tools/Macros/Run Macro menu item.
+ @echo You can also load the document "$(QM)$(SCRIPT_NAME).odt$(QM)" and press the button to run
+ @echo the script.
+ @echo -
+ @echo $(MAKE) $(SCRIPT_NAME).odt.load
+ @echo --------------------------------------------------------------------------------
+
+$(SCRIPT_NAME).odt.load : $(SCRIPT_REGISTERFLAG)
+ "$(OFFICE_PROGRAM_PATH)$(PS)soffice" $(basename $@)
+
+%.run: $(CLASSFILES)
+ $(SDK_JAVA) -classpath "$(SDK_CLASSPATH)" $(subst /,.,$(PACKAGE)).$(basename $@)
+
+%.dbg: $(JAR1_JAR)
+ jdb -classpath "$(SDK_CLASSPATH)" $(subst /,.,$(PACKAGE)).$(basename $@)
+
+.PHONY: clean
+clean :
+ -$(DELRECURSIVE) $(subst /,$(PS),$(SAMPLE_CLASS_OUT))
+ -$(DELRECURSIVE) $(subst /,$(PS),$(SCRIPT_GEN_OUT))
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$(SCRIPT_PACKAGE_URL)))
+
diff --git a/odk/examples/DevelopersGuide/ScriptingFramework/ScriptSelector/ScriptSelector.odt b/odk/examples/DevelopersGuide/ScriptingFramework/ScriptSelector/ScriptSelector.odt
new file mode 100644
index 000000000..323bb6edd
--- /dev/null
+++ b/odk/examples/DevelopersGuide/ScriptingFramework/ScriptSelector/ScriptSelector.odt
Binary files differ
diff --git a/odk/examples/DevelopersGuide/ScriptingFramework/ScriptSelector/ScriptSelector/ScriptSelector.java b/odk/examples/DevelopersGuide/ScriptingFramework/ScriptSelector/ScriptSelector/ScriptSelector.java
new file mode 100644
index 000000000..fcf01a4c9
--- /dev/null
+++ b/odk/examples/DevelopersGuide/ScriptingFramework/ScriptSelector/ScriptSelector/ScriptSelector.java
@@ -0,0 +1,353 @@
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+import javax.swing.*;
+import javax.swing.tree.*;
+import javax.swing.event.*;
+import javax.swing.border.*;
+import java.awt.*;
+import java.awt.event.*;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.Exception;
+import com.sun.star.uno.Any;
+import com.sun.star.uno.AnyConverter;
+import com.sun.star.uno.Type;
+import com.sun.star.uno.XComponentContext;
+
+import com.sun.star.beans.*;
+import com.sun.star.script.browse.XBrowseNode;
+import com.sun.star.script.browse.BrowseNodeTypes;
+import com.sun.star.script.browse.XBrowseNodeFactory;
+import com.sun.star.script.browse.BrowseNodeFactoryViewTypes;
+import com.sun.star.script.provider.XScriptContext;
+import com.sun.star.script.provider.XScript;
+import com.sun.star.script.provider.XScriptProvider;
+import com.sun.star.script.provider.XScriptProviderFactory;
+
+public class ScriptSelector {
+
+ private static final int BIG_GAP = 10;
+ private static final int MED_GAP = 5;
+
+ private static final String MSP_FACTORY =
+ "/singletons/com.sun.star.script.provider." +
+ "theMasterScriptProviderFactory";
+
+ private static final String BROWSE_FACTORY =
+ "/singletons/com.sun.star.script.browse.theBrowseNodeFactory";
+
+ private ScriptSelectorPanel selectorPanel;
+
+ public void show(final XScriptContext ctxt)
+ {
+ try {
+ XBrowseNode root = getRootNode(ctxt);
+
+ Object obj = ctxt.getComponentContext().getValueByName(MSP_FACTORY);
+
+ XScriptProviderFactory fac = UnoRuntime.queryInterface(XScriptProviderFactory.class, obj);
+
+ final XScriptProvider msp =
+ fac.createScriptProvider(new Any(new Type(), null));
+
+ final JFrame client = new JFrame("Script");
+
+ selectorPanel = new ScriptSelectorPanel(root);
+
+ final JButton runButton, closeButton;
+
+ runButton = new JButton("Run");
+ runButton.setEnabled(false);
+
+ closeButton = new JButton("Close");
+
+ JPanel northButtons =
+ new JPanel(new GridLayout(2, 1, MED_GAP, MED_GAP));
+
+ northButtons.add(runButton);
+ northButtons.add(closeButton);
+
+ JPanel southButtons =
+ new JPanel(new GridLayout(3, 1, MED_GAP, MED_GAP));
+
+ selectorPanel.tree.addTreeSelectionListener(
+ new TreeSelectionListener() {
+ public void valueChanged(TreeSelectionEvent e) {
+ XBrowseNode xbn = selectorPanel.getSelection();
+ XPropertySet props = UnoRuntime.queryInterface(XPropertySet.class, xbn);
+
+ if (xbn != null &&
+ xbn.getType() == BrowseNodeTypes.SCRIPT)
+ {
+ runButton.setEnabled(true);
+ }
+ else
+ {
+ runButton.setEnabled(false);
+ }
+ }
+ }
+ );
+
+ ActionListener listener = new ActionListener() {
+ public void actionPerformed(ActionEvent event) {
+ if (event.getSource() == runButton) {
+ String uri = selectorPanel.textField.getText();
+
+ try {
+ XScript script = msp.getScript(uri);
+
+ Object[][] out = new Object[1][0];
+ out[0] = new Object[0];
+
+ short[][] num = new short[1][0];
+ num[0] = new short[0];
+
+ script.invoke(new Object[0], num, out);
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ else if (event.getSource() == closeButton) {
+ client.dispose();
+ }
+ }
+ };
+
+ runButton.addActionListener(listener);
+ closeButton.addActionListener(listener);
+
+ JPanel buttonPanel = new JPanel(new BorderLayout());
+ buttonPanel.add(northButtons, BorderLayout.NORTH);
+ buttonPanel.add(southButtons, BorderLayout.SOUTH);
+
+ JPanel mainPanel = new JPanel(new BorderLayout(MED_GAP, MED_GAP));
+ mainPanel.setBorder(
+ new EmptyBorder(BIG_GAP, BIG_GAP, BIG_GAP, BIG_GAP));
+ mainPanel.add(selectorPanel, BorderLayout.CENTER);
+ mainPanel.add(buttonPanel, BorderLayout.EAST);
+
+ client.getContentPane().add(mainPanel);
+ client.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
+ client.setSize(500, 350);
+
+ // set the x and y locations so that the frame is in the
+ // centre of the screen
+ Dimension d = client.getToolkit().getScreenSize();
+
+ int x = (int)((d.getWidth() - client.getWidth()) / 2);
+ int y = (int)((d.getHeight() - client.getHeight()) / 2);
+
+ client.setLocation(x, y);
+
+ client.show();
+ }
+ catch (com.sun.star.uno.RuntimeException rue) {
+ rue.printStackTrace();
+ }
+ catch (java.lang.Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ public void show(final XScriptContext ctxt,
+ final com.sun.star.awt.MouseEvent e)
+ {
+ show(ctxt);
+ }
+
+ public void show(final XScriptContext ctxt,
+ final com.sun.star.awt.ActionEvent e)
+ {
+ show(ctxt);
+ }
+
+ private XBrowseNode getRootNode(XScriptContext ctxt) {
+
+ XBrowseNode result = null;
+
+ XComponentContext xcc = ctxt.getComponentContext();
+ XBrowseNodeFactory xBrowseFac = UnoRuntime.queryInterface(
+ XBrowseNodeFactory.class, xcc.getValueByName(BROWSE_FACTORY));
+
+ result = UnoRuntime.queryInterface(
+ XBrowseNode.class, xBrowseFac.createView(
+ BrowseNodeFactoryViewTypes.MACROSELECTOR ) );
+
+ return result;
+ }
+}
+
+class ScriptSelectorPanel extends JPanel {
+
+ private final XBrowseNode myrootnode;
+ public JTextField textField;
+ public JTree tree;
+
+ public ScriptSelectorPanel(XBrowseNode root)
+ {
+ this.myrootnode = root;
+ initUI();
+ }
+
+ public XBrowseNode getSelection() {
+ DefaultMutableTreeNode node = (DefaultMutableTreeNode)
+ tree.getLastSelectedPathComponent();
+
+ if (node == null) {
+ return null;
+ }
+
+ return (XBrowseNode)node.getUserObject();
+ }
+
+ private void initUI() {
+ setLayout(new BorderLayout());
+
+ DefaultMutableTreeNode top =
+ new DefaultMutableTreeNode(myrootnode) {
+ @Override
+ public String toString() {
+ return ((XBrowseNode)getUserObject()).getName();
+ }
+ };
+ initNodes(myrootnode, top);
+ DefaultTreeModel treeModel = new DefaultTreeModel(top);
+ tree = new JTree(treeModel);
+
+ tree.setCellRenderer(new ScriptTreeRenderer());
+
+ tree.getSelectionModel().setSelectionMode
+ (TreeSelectionModel.SINGLE_TREE_SELECTION);
+
+ tree.addTreeSelectionListener(new TreeSelectionListener() {
+ public void valueChanged(TreeSelectionEvent e) {
+ XBrowseNode xbn = getSelection();
+ XPropertySet props = UnoRuntime.queryInterface(
+ XPropertySet.class, xbn);
+
+ if (xbn == null) {
+ textField.setText("");
+ return;
+ }
+
+ String str = xbn.getName();
+ if (xbn.getType() == BrowseNodeTypes.SCRIPT && props != null)
+ {
+ try {
+ str = AnyConverter.toString(
+ props.getPropertyValue("URI"));
+ }
+ catch (Exception ignore) {
+ // default will be used
+ }
+ }
+ textField.setText(str);
+ }
+ });
+
+ JScrollPane scroller = new JScrollPane(tree);
+ add(scroller, BorderLayout.CENTER);
+
+ textField = new JTextField();
+ add(textField, BorderLayout.SOUTH);
+ }
+
+
+
+
+
+ private void initNodes(XBrowseNode parent, DefaultMutableTreeNode top) {
+ if ( parent == null || !parent.hasChildNodes() )
+ {
+ return;
+ }
+
+ XBrowseNode[] children = parent.getChildNodes();
+
+ try {
+ if (children != null) {
+ for (int i = 0; i < children.length; i++) {
+ if ( children[i] == null )
+ {
+ continue;
+ }
+ DefaultMutableTreeNode newNode =
+ new DefaultMutableTreeNode(children[i]) {
+ @Override
+ public String toString() {
+ return ((XBrowseNode)getUserObject()).getName();
+ }
+ };
+ top.add(newNode);
+ initNodes(children[i], newNode);
+ }
+ }
+ }
+ catch (java.lang.Exception e) {
+ e.printStackTrace();
+ }
+ }
+}
+
+class ScriptTreeRenderer extends DefaultTreeCellRenderer {
+
+ private final ImageIcon sofficeIcon;
+ private final ImageIcon scriptIcon;
+ private final ImageIcon containerIcon;
+
+ public ScriptTreeRenderer() {
+ sofficeIcon = new ImageIcon(getClass().getResource("soffice.gif"));
+ scriptIcon = new ImageIcon(getClass().getResource("script.gif"));
+ containerIcon = new ImageIcon(getClass().getResource("container.gif"));
+ }
+
+ @Override
+ public Component getTreeCellRendererComponent(
+ JTree tree,
+ Object value,
+ boolean sel,
+ boolean expanded,
+ boolean leaf,
+ int row,
+ boolean hasFocus) {
+
+ super.getTreeCellRendererComponent(
+ tree, value, sel,
+ expanded, leaf, row,
+ hasFocus);
+
+ DefaultMutableTreeNode node = (DefaultMutableTreeNode)value;
+ XBrowseNode xbn = (XBrowseNode)node.getUserObject();
+ if (xbn.getType() == BrowseNodeTypes.SCRIPT) {
+ setIcon(scriptIcon);
+ }
+ else if(xbn.getType() == BrowseNodeTypes.CONTAINER) {
+ setIcon(containerIcon);
+ }
+ else if(xbn.getType() == BrowseNodeTypes.ROOT) {
+ setIcon(sofficeIcon);
+ }
+
+ return this;
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/ScriptingFramework/ScriptSelector/ScriptSelector/container.gif b/odk/examples/DevelopersGuide/ScriptingFramework/ScriptSelector/ScriptSelector/container.gif
new file mode 100644
index 000000000..3a345f9bf
--- /dev/null
+++ b/odk/examples/DevelopersGuide/ScriptingFramework/ScriptSelector/ScriptSelector/container.gif
Binary files differ
diff --git a/odk/examples/DevelopersGuide/ScriptingFramework/ScriptSelector/ScriptSelector/parcel-descriptor.xml b/odk/examples/DevelopersGuide/ScriptingFramework/ScriptSelector/ScriptSelector/parcel-descriptor.xml
new file mode 100644
index 000000000..e5fc8a53d
--- /dev/null
+++ b/odk/examples/DevelopersGuide/ScriptingFramework/ScriptSelector/ScriptSelector/parcel-descriptor.xml
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+-->
+<parcel language="Java" xmlns:parcel="scripting.dtd">
+ <script language="Java">
+ <locale lang="en">
+ <displayname value="Script Selector"/>
+ <description>
+ Example Script Selector shows how XBrowseNode API works
+ </description>
+ </locale>
+ <functionname value="ScriptSelector.show"/>
+ <logicalname value="ScriptSelector.show"/>
+ <languagedepprops>
+ <prop name="classpath" value="ScriptSelector.jar"/>
+ </languagedepprops>
+ </script>
+</parcel>
diff --git a/odk/examples/DevelopersGuide/ScriptingFramework/ScriptSelector/ScriptSelector/script.gif b/odk/examples/DevelopersGuide/ScriptingFramework/ScriptSelector/ScriptSelector/script.gif
new file mode 100644
index 000000000..d3b3768ca
--- /dev/null
+++ b/odk/examples/DevelopersGuide/ScriptingFramework/ScriptSelector/ScriptSelector/script.gif
Binary files differ
diff --git a/odk/examples/DevelopersGuide/ScriptingFramework/ScriptSelector/ScriptSelector/soffice.gif b/odk/examples/DevelopersGuide/ScriptingFramework/ScriptSelector/ScriptSelector/soffice.gif
new file mode 100644
index 000000000..88124d87d
--- /dev/null
+++ b/odk/examples/DevelopersGuide/ScriptingFramework/ScriptSelector/ScriptSelector/soffice.gif
Binary files differ
diff --git a/odk/examples/DevelopersGuide/ScriptingFramework/ScriptSelector/build.xml b/odk/examples/DevelopersGuide/ScriptingFramework/ScriptSelector/build.xml
new file mode 100644
index 000000000..c29003046
--- /dev/null
+++ b/odk/examples/DevelopersGuide/ScriptingFramework/ScriptSelector/build.xml
@@ -0,0 +1,96 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+-->
+<project default="build">
+
+ <!-- =================== Global Properties ============================= -->
+ <property environment="env"/>
+ <property name="macroname" value="ScriptSelector"/>
+ <property name="unopkgfile" value="${basedir}/${macroname}.uno.pkg"/>
+
+ <!-- ==================== initialise properties ========================= -->
+ <target name="checksdk">
+ <condition property="UsingSDK">
+ <available file="${env.OFFICE_PROGRAM_PATH}"/>
+ </condition>
+ </target>
+
+ <target name="initsdk" if="UsingSDK">
+ <property name="opp" value="${env.OFFICE_PROGRAM_PATH}"/>
+ </target>
+
+ <target name="initnosdk" unless="UsingSDK">
+ <fail unless="opp" message="Path to Office install not set"/>
+ </target>
+
+ <!-- ==================== classpath setting ============================ -->
+ <target name="init" depends="checksdk,initsdk,initnosdk">
+ <path id="scriptclasspath">
+ <pathelement location="${opp}/classes/libreoffice.jar"/>
+ <pathelement location="${opp}/classes/ScriptFramework.jar"/>
+ </path>
+ </target>
+
+ <!-- ====================== Clean Generated Files ===================== -->
+ <target name="clean">
+ <delete>
+ <fileset dir=".">
+ <include name="**/*.class"/>
+ <include name="**/*.jar"/>
+ <include name="**/*.uno.pkg"/>
+ </fileset>
+ </delete>
+ </target>
+
+ <!-- ===================== Compile the script ========================= -->
+ <target name="compile" depends="init">
+ <javac srcdir="${macroname}" destdir="${macroname}"
+ includes="**/*.java" classpathref="scriptclasspath"
+ debug="on" optimize="on" deprecation="on"/>
+ </target>
+
+ <!-- ====================== Build UNO Package ========================= -->
+ <target name="build" depends="compile">
+ <delete file="${unopkgfile}"/>
+
+ <jar jarfile="${macroname}/${macroname}.jar"
+ basedir="${macroname}" includes="*.class,*.gif">
+ </jar>
+
+ <zip zipfile="${unopkgfile}">
+ <fileset dir="${basedir}">
+ <include name="**/*.jar"/>
+ <include name="**/parcel-descriptor.xml"/>
+ <include name="**/manifest.xml"/>
+ </fileset>
+ </zip>
+ </target>
+
+ <!-- ====================== Deploy Generated Files ==================== -->
+ <target name="deploy" depends="build">
+ <exec executable="${opp}/unopkg">
+ <arg line="add"/>
+ <arg line="--force"/>
+ <arg path="${unopkgfile}"/>
+ </exec>
+ </target>
+
+ <!-- ========================= All In One Build ======================= -->
+ <target name="all" depends="clean,build,deploy"/>
+
+</project>
diff --git a/odk/examples/DevelopersGuide/Spreadsheet/DataPilotReadme.txt b/odk/examples/DevelopersGuide/Spreadsheet/DataPilotReadme.txt
new file mode 100644
index 000000000..7876b6a33
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Spreadsheet/DataPilotReadme.txt
@@ -0,0 +1,48 @@
+#
+# This file is part of the LibreOffice project.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+# This file incorporates work covered by the following license notice:
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed
+# with this work for additional information regarding copyright
+# ownership. The ASF licenses this file to you under the Apache
+# License, Version 2.0 (the "License"); you may not use this file
+# except in compliance with the License. You may obtain a copy of
+# the License at http://www.apache.org/licenses/LICENSE-2.0 .
+#
+
+ExampleDataPilotSource
+======================
+
+This example shows how you can implement an external DataPilot
+component.
+
+Simple usage scenario:
+======================
+1. build and deploy the component
+2. open a new spreadsheet document
+3. select for example cell B:2
+4. start the DataPilot dialog
+ Data->DataPilot->Start...
+5. select "External source/interface -> Ok
+6. select the example DataPilot
+ Use the drop down list and select the service
+ "ExampleDataPilotSource" -> Ok
+7. Place some number fields in the field areas
+ For example:
+ - select the "ones" field and drop it in the "Row Fields" area
+ - repeat this step with the "tens" and "hundreds" field
+ - select the "thousands" field and drop it in the "Column Fields"
+ area.
+ -> press Ok
+8. you see a matrix with rows and columns for the selected fields
+ and a value area with a sum up of all fields valid for this
+ coordinate. For example cell F:21=1221 (ones=B:21=1, tens=c:21=2
+ hundreds=D:21=2 and thousands=F:3=1)
+
+
diff --git a/odk/examples/DevelopersGuide/Spreadsheet/ExampleAddIn.components b/odk/examples/DevelopersGuide/Spreadsheet/ExampleAddIn.components
new file mode 100644
index 000000000..6212c72d4
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Spreadsheet/ExampleAddIn.components
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<components xmlns="http://openoffice.org/2010/uno-components">
+ <component loader="com.sun.star.loader.Java2" uri="ExampleAddIn.uno.jar">
+ <implementation name="ExampleAddIn$_ExampleAddIn">
+ <service name="com.sun.star.sheet.AddIn"/>
+ <service name="org.openoffice.sheet.addin.ExampleAddIn"/>
+ </implementation>
+ </component>
+</components>
diff --git a/odk/examples/DevelopersGuide/Spreadsheet/ExampleAddIn.java b/odk/examples/DevelopersGuide/Spreadsheet/ExampleAddIn.java
new file mode 100644
index 000000000..59cac873f
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Spreadsheet/ExampleAddIn.java
@@ -0,0 +1,304 @@
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+import com.sun.star.sheet.XResultListener;
+
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+class ExampleAddInResult implements com.sun.star.sheet.XVolatileResult
+{
+ private final String aName;
+ private int nValue;
+ private final java.util.ArrayList<XResultListener> aListeners = new java.util.ArrayList<XResultListener>();
+
+ public ExampleAddInResult( String aNewName )
+ {
+ aName = aNewName;
+ }
+
+ private com.sun.star.sheet.ResultEvent getResult()
+ {
+ com.sun.star.sheet.ResultEvent aEvent =
+ new com.sun.star.sheet.ResultEvent();
+ aEvent.Value = aName + " " + nValue;
+ aEvent.Source = this;
+ return aEvent;
+ }
+
+ public void addResultListener(com.sun.star.sheet.XResultListener aListener)
+ {
+ aListeners.add( aListener );
+
+ // immediately notify of initial value
+ aListener.modified( getResult() );
+ }
+
+ public void removeResultListener(com.sun.star.sheet.XResultListener aListener)
+ {
+ aListeners.remove( aListener );
+ }
+
+ public void incrementValue()
+ {
+ ++nValue;
+ com.sun.star.sheet.ResultEvent aEvent = getResult();
+
+ for( XResultListener l : aListeners)
+ l.modified(aEvent);
+ }
+}
+
+class ExampleAddInThread extends Thread
+{
+ private final java.util.HashMap<String, ExampleAddInResult> aCounters;
+
+ public ExampleAddInThread( java.util.HashMap<String, ExampleAddInResult> aResults )
+ {
+ aCounters = aResults;
+ }
+
+ @Override
+ public void run()
+ {
+ while ( true )
+ {
+ try
+ {
+ sleep(1000);
+ }
+ catch( InterruptedException exception )
+ {
+ }
+
+ // increment all counters
+ for (ExampleAddInResult r : aCounters.values())
+ r.incrementValue();
+ }
+ }
+}
+
+public class ExampleAddIn
+{
+ public static class _ExampleAddIn extends com.sun.star.lib.uno.helper.WeakBase
+ implements org.openoffice.sheet.addin.XExampleAddIn,
+ com.sun.star.sheet.XAddIn,
+ com.sun.star.lang.XServiceName,
+ com.sun.star.lang.XServiceInfo
+ {
+ private static final String aExampleService = "org.openoffice.sheet.addin.ExampleAddIn";
+ private static final String aAddInService = "com.sun.star.sheet.AddIn";
+ private static final String aImplName = _ExampleAddIn.class.getName();
+
+ private static final short FUNCTION_INVALID = -1;
+
+ private static final String[] aFunctionNames =
+ {
+ "getIncremented",
+ "getCounter"
+ };
+ private static final String[] aDisplayFunctionNames =
+ {
+ "Increment",
+ "Counter"
+ };
+ private static final String[] aDescriptions =
+ {
+ "Increments a value",
+ "Returns a counter"
+ };
+ private static final String[] aFirstArgumentNames =
+ {
+ "Value",
+ "Name"
+ };
+ private static final String[] aFirstArgumentDescriptions =
+ {
+ "The value that is incremented",
+ "The name of the counter"
+ };
+
+ private com.sun.star.lang.Locale aFuncLocale;
+ private java.util.HashMap<String, ExampleAddInResult> aResults;
+
+ public _ExampleAddIn( com.sun.star.lang.XMultiServiceFactory xFactory )
+ {
+ }
+
+ private int getFunctionID( String aProgrammaticFunctionName )
+ {
+ for ( int i = 0; i < aFunctionNames.length; i++ )
+ if ( aProgrammaticFunctionName.equals(aFunctionNames[i]) )
+ return i;
+ return FUNCTION_INVALID;
+ }
+
+ // XExampleAddIn
+
+ public int getIncremented( int nValue )
+ {
+ return nValue + 1;
+ }
+
+ public com.sun.star.sheet.XVolatileResult getCounter(String aName)
+ {
+ if ( aResults == null )
+ {
+ // create the table of results, and start a thread to increment
+ // all counters
+ aResults = new java.util.HashMap<String, ExampleAddInResult>();
+ ExampleAddInThread aThread = new ExampleAddInThread( aResults );
+ aThread.start();
+ }
+
+ ExampleAddInResult aResult = aResults.get(aName);
+ if ( aResult == null )
+ {
+ aResult = new ExampleAddInResult(aName);
+ aResults.put( aName, aResult );
+ }
+ return aResult;
+ }
+
+ // XAddIn
+
+ public String getProgrammaticFuntionName(String aDisplayName)
+ {
+ for ( int i = 0; i < aFunctionNames.length; i++ )
+ if ( aDisplayName.equals(aDisplayFunctionNames[i]) )
+ return aFunctionNames[i];
+ return "";
+ }
+
+ public String getDisplayFunctionName(String aProgrammaticName)
+ {
+ int nFunction = getFunctionID( aProgrammaticName );
+ return ( nFunction == FUNCTION_INVALID ) ? "" :
+ aDisplayFunctionNames[nFunction];
+ }
+
+ public String getFunctionDescription(String aProgrammaticName)
+ {
+ int nFunction = getFunctionID( aProgrammaticName );
+ return ( nFunction == FUNCTION_INVALID ) ? "" :
+ aDescriptions[nFunction];
+ }
+
+ public String getDisplayArgumentName(String aProgrammaticFunctionName,
+ int nArgument)
+ {
+ // both functions in this example only have a first argument
+ int nFunction = getFunctionID( aProgrammaticFunctionName );
+ return ( nFunction == FUNCTION_INVALID || nArgument != 0) ? "" :
+ aFirstArgumentNames[nFunction];
+ }
+
+ public String getArgumentDescription(String aProgrammaticFunctionName,
+ int nArgument )
+ {
+ // both functions in this example only have a first argument
+ int nFunction = getFunctionID( aProgrammaticFunctionName );
+ return ( nFunction == FUNCTION_INVALID || nArgument != 0) ? "" :
+ aFirstArgumentDescriptions[nFunction];
+ }
+
+ public String getProgrammaticCategoryName(String aProgrammaticFunctionName)
+ {
+ return( "Add-In" );
+ }
+
+ public String getDisplayCategoryName(String aProgrammaticFunctionName)
+ {
+ return( "Add-In" );
+ }
+
+ // XLocalizable
+
+ public void setLocale( com.sun.star.lang.Locale aLocale )
+ {
+ // the locale is stored and used for getLocale, but otherwise
+ // ignored in this example
+ aFuncLocale = aLocale;
+ }
+
+ public com.sun.star.lang.Locale getLocale()
+ {
+ return aFuncLocale;
+ }
+
+ // XServiceName
+
+ public String getServiceName()
+ {
+ return aExampleService;
+ }
+
+ // XServiceInfo
+
+ public String getImplementationName()
+ {
+ return aImplName;
+ }
+
+ public String[] getSupportedServiceNames()
+ {
+ String [] aSupportedServices = new String[ 2 ];
+ aSupportedServices[ 0 ] = aExampleService;
+ aSupportedServices[ 1 ] = aAddInService;
+ return aSupportedServices;
+ }
+
+ public boolean supportsService( String aService )
+ {
+ return (aService.equals( aExampleService ) ||
+ aService.equals( aAddInService ) );
+ }
+
+ }
+
+
+ public static com.sun.star.lang.XSingleServiceFactory __getServiceFactory(
+ String implName,
+ com.sun.star.lang.XMultiServiceFactory multiFactory,
+ com.sun.star.registry.XRegistryKey regKey)
+ {
+ com.sun.star.lang.XSingleServiceFactory xSingleServiceFactory = null;
+ if ( implName.equals(_ExampleAddIn.aImplName) )
+ xSingleServiceFactory =
+ com.sun.star.comp.loader.FactoryHelper.getServiceFactory(
+ _ExampleAddIn.class, _ExampleAddIn.aExampleService,
+ multiFactory, regKey);
+ return xSingleServiceFactory;
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/Spreadsheet/ExampleAddIn.ods b/odk/examples/DevelopersGuide/Spreadsheet/ExampleAddIn.ods
new file mode 100644
index 000000000..b86f24915
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Spreadsheet/ExampleAddIn.ods
Binary files differ
diff --git a/odk/examples/DevelopersGuide/Spreadsheet/ExampleDataPilotSource.components b/odk/examples/DevelopersGuide/Spreadsheet/ExampleDataPilotSource.components
new file mode 100644
index 000000000..f0881c1f5
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Spreadsheet/ExampleDataPilotSource.components
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<components xmlns="http://openoffice.org/2010/uno-components">
+ <component loader="com.sun.star.loader.Java2" uri="ExampleDataPilotSource.uno.jar">
+ <implementation name="ExampleDataPilotSource$_ExampleDataPilotSource">
+ <service name="com.sun.star.sheet.DataPilotSource"/>
+ </implementation>
+ </component>
+</components>
diff --git a/odk/examples/DevelopersGuide/Spreadsheet/ExampleDataPilotSource.java b/odk/examples/DevelopersGuide/Spreadsheet/ExampleDataPilotSource.java
new file mode 100644
index 000000000..6b10da93c
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Spreadsheet/ExampleDataPilotSource.java
@@ -0,0 +1,990 @@
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+import com.sun.star.sheet.DataPilotFieldFilter;
+
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+// Example DataPilot source component
+
+// helper class to hold the settings
+
+class ExampleSettings
+{
+ public static final int nDimensionCount = 6;
+ public static final int nValueDimension = 4;
+ public static final int nDataDimension = 5;
+ public static final String [] aDimensionNames = {
+ "ones", "tens", "hundreds", "thousands", "value", "" };
+
+ public static final String getMemberName( int nMember )
+ {
+ return String.valueOf( nMember );
+ }
+
+ public int nMemberCount = 3;
+ public java.util.List<Integer> aColDimensions = new java.util.ArrayList<Integer>();
+ public java.util.List<Integer> aRowDimensions = new java.util.ArrayList<Integer>();
+}
+
+// XPropertySetInfo implementation for getPropertySetInfo
+
+class ExamplePropertySetInfo implements com.sun.star.beans.XPropertySetInfo
+{
+ private final com.sun.star.beans.Property[] aProperties;
+
+ public ExamplePropertySetInfo( com.sun.star.beans.Property[] aProps )
+ {
+ aProperties = aProps;
+ }
+
+ public com.sun.star.beans.Property[] getProperties()
+ {
+ return aProperties;
+ }
+
+ public com.sun.star.beans.Property getPropertyByName( String aName )
+ throws com.sun.star.beans.UnknownPropertyException
+ {
+ for ( int i=0; i<aProperties.length; i++ )
+ if ( aProperties[i].Name.equals( aName ) )
+ return aProperties[i];
+ throw new com.sun.star.beans.UnknownPropertyException();
+ }
+
+ public boolean hasPropertyByName( String aName )
+ {
+ for ( int i=0; i<aProperties.length; i++ )
+ if ( aProperties[i].Name.equals( aName ) )
+ return true;
+ return false;
+ }
+}
+
+// implementation of com.sun.star.sheet.DataPilotSourceMember
+
+class ExampleMember implements com.sun.star.container.XNamed,
+ com.sun.star.beans.XPropertySet
+{
+ private final int nMember;
+
+ public ExampleMember( int nMbr )
+ {
+ nMember = nMbr;
+ }
+
+ // XNamed
+
+ public String getName()
+ {
+ return ExampleSettings.getMemberName( nMember );
+ }
+
+ public void setName( String aName )
+ {
+ // ignored
+ }
+
+ // XPropertySet
+
+ public com.sun.star.beans.XPropertySetInfo getPropertySetInfo()
+ {
+ return new ExamplePropertySetInfo( new com.sun.star.beans.Property[] {
+ new com.sun.star.beans.Property( "IsVisible", -1,
+ new com.sun.star.uno.Type( Boolean.class ), (short) 0),
+ new com.sun.star.beans.Property( "ShowDetails", -1,
+ new com.sun.star.uno.Type( Boolean.class ), (short) 0) });
+ }
+
+ public void setPropertyValue( String aPropertyName, Object aValue )
+ throws com.sun.star.beans.UnknownPropertyException
+ {
+ if ( aPropertyName.equals( "IsVisible" ) ||
+ aPropertyName.equals( "ShowDetails" ) )
+ {
+ // ignored
+ }
+ else
+ throw new com.sun.star.beans.UnknownPropertyException();
+ }
+
+ public Object getPropertyValue( String aPropertyName )
+ throws com.sun.star.beans.UnknownPropertyException
+ {
+ if ( aPropertyName.equals( "IsVisible" ) ||
+ aPropertyName.equals( "ShowDetails" ) )
+ {
+ return Boolean.TRUE; // always true
+ }
+ else
+ throw new com.sun.star.beans.UnknownPropertyException();
+ }
+
+ public void addPropertyChangeListener(
+ String aPropertyName, com.sun.star.beans.XPropertyChangeListener xListener)
+ {
+ }
+ public void removePropertyChangeListener(
+ String aPropertyName, com.sun.star.beans.XPropertyChangeListener aListener)
+ {
+ }
+ public void addVetoableChangeListener(
+ String PropertyName, com.sun.star.beans.XVetoableChangeListener aListener)
+ {
+ }
+ public void removeVetoableChangeListener(
+ String PropertyName, com.sun.star.beans.XVetoableChangeListener aListener)
+ {
+ }
+}
+
+// implementation of com.sun.star.sheet.DataPilotSourceMembers
+
+class ExampleMembers implements com.sun.star.sheet.XMembersAccess
+{
+ private final ExampleSettings aSettings;
+ private ExampleMember[] aMembers;
+
+ public ExampleMembers( ExampleSettings aSet )
+ {
+ aSettings = aSet;
+ aMembers = new ExampleMember[ aSettings.nMemberCount ];
+ }
+
+ // XNameAccess
+
+ public com.sun.star.uno.Type getElementType()
+ {
+ return new com.sun.star.uno.Type( com.sun.star.container.XNamed.class );
+ }
+
+ public boolean hasElements()
+ {
+ return true; // always has elements
+ }
+
+ public Object getByName( String aName )
+ throws com.sun.star.container.NoSuchElementException
+ {
+ int nCount = aSettings.nMemberCount;
+ for ( int i=0; i<nCount; i++ )
+ if ( aName.equals( ExampleSettings.getMemberName( i ) ) )
+ {
+ if ( aMembers[i] == null )
+ aMembers[i] = new ExampleMember( i );
+ return aMembers[i];
+ }
+ throw new com.sun.star.container.NoSuchElementException();
+ }
+
+ public String[] getElementNames()
+ {
+ int nCount = aSettings.nMemberCount;
+ String [] aNames = new String[ nCount ];
+ for ( int i=0; i<nCount; i++ )
+ aNames[i] = ExampleSettings.getMemberName( i );
+ return aNames;
+ }
+
+ public boolean hasByName( String aName )
+ {
+ int nCount = aSettings.nMemberCount;
+ for ( int i=0; i<nCount; i++ )
+ if ( aName.equals( ExampleSettings.getMemberName( i ) ) )
+ return true;
+ return false;
+ }
+
+ // XMembersAccess
+
+ public String[] getLocaleIndependentElementNames()
+ {
+ return getElementNames();
+ }
+}
+
+// implementation of com.sun.star.sheet.DataPilotSourceLevel
+
+class ExampleLevel implements
+ com.sun.star.container.XNamed,
+ com.sun.star.sheet.XMembersSupplier,
+ com.sun.star.sheet.XDataPilotMemberResults,
+ com.sun.star.beans.XPropertySet
+{
+ private final ExampleSettings aSettings;
+ private final int nDimension;
+ private ExampleMembers aMembers;
+
+ public ExampleLevel( ExampleSettings aSet, int nDim )
+ {
+ aSettings = aSet;
+ nDimension = nDim;
+ }
+
+ // XNamed
+
+ public String getName()
+ {
+ return ExampleSettings.aDimensionNames[ nDimension ];
+ }
+
+ public void setName( String aName )
+ {
+ // ignored
+ }
+
+ // XMembersSupplier
+
+ public com.sun.star.sheet.XMembersAccess getMembers()
+ {
+ if ( aMembers == null )
+ aMembers = new ExampleMembers( aSettings );
+ return aMembers;
+ }
+
+ // XDataPilotMemberResults
+
+ public com.sun.star.sheet.MemberResult[] getResults()
+ {
+ int nDimensions = 0;
+ int nPosition = aSettings.aColDimensions.indexOf( Integer.valueOf(nDimension));
+ if ( nPosition >= 0 )
+ nDimensions = aSettings.aColDimensions.size();
+ else
+ {
+ nPosition = aSettings.aRowDimensions.indexOf( Integer.valueOf(nDimension));
+ if ( nPosition >= 0 )
+ nDimensions = aSettings.aRowDimensions.size();
+ }
+
+ if ( nPosition < 0 )
+ return new com.sun.star.sheet.MemberResult[0];
+
+ int nMembers = aSettings.nMemberCount;
+ int nRepeat = 1;
+ int nFill = 1;
+ for ( int i=0; i<nDimensions; i++ )
+ {
+ if ( i < nPosition )
+ nRepeat *= nMembers;
+ else if ( i > nPosition )
+ nFill *= nMembers;
+ }
+ int nSize = nRepeat * nMembers * nFill;
+
+ com.sun.star.sheet.MemberResult[] aResults =
+ new com.sun.star.sheet.MemberResult[nSize];
+ int nResultPos = 0;
+ for (int nOuter=0; nOuter<nRepeat; nOuter++)
+ {
+ for (int nMember=0; nMember<nMembers; nMember++)
+ {
+ aResults[nResultPos] = new com.sun.star.sheet.MemberResult();
+ aResults[nResultPos].Name = ExampleSettings.getMemberName(nMember);
+ aResults[nResultPos].Caption = aResults[nResultPos].Name;
+ aResults[nResultPos].Flags =
+ com.sun.star.sheet.MemberResultFlags.HASMEMBER;
+ ++nResultPos;
+
+ for (int nInner=1; nInner<nFill; nInner++)
+ {
+ aResults[nResultPos] = new com.sun.star.sheet.MemberResult();
+ aResults[nResultPos].Flags =
+ com.sun.star.sheet.MemberResultFlags.CONTINUE;
+ ++nResultPos;
+ }
+ }
+ }
+ return aResults;
+ }
+
+ // XPropertySet
+
+ public com.sun.star.beans.XPropertySetInfo getPropertySetInfo()
+ {
+ return new ExamplePropertySetInfo( new com.sun.star.beans.Property[] {
+ new com.sun.star.beans.Property( "SubTotals", -1,
+ new com.sun.star.uno.Type(
+ com.sun.star.sheet.GeneralFunction[].class ),
+ (short) 0 ),
+ new com.sun.star.beans.Property( "ShowEmpty", -1,
+ new com.sun.star.uno.Type( Boolean.class ),
+ (short) 0 ) } );
+ }
+
+ public void setPropertyValue( String aPropertyName, Object aValue )
+ throws com.sun.star.beans.UnknownPropertyException
+ {
+ if ( aPropertyName.equals( "SubTotals" ) ||
+ aPropertyName.equals( "ShowEmpty" ) )
+ {
+ // ignored
+ }
+ else
+ throw new com.sun.star.beans.UnknownPropertyException();
+ }
+
+ public Object getPropertyValue( String aPropertyName )
+ throws com.sun.star.beans.UnknownPropertyException
+ {
+ if ( aPropertyName.equals( "SubTotals" ) )
+ return new com.sun.star.sheet.GeneralFunction[0];
+ else if ( aPropertyName.equals( "ShowEmpty" ) )
+ return Boolean.TRUE;
+ else
+ throw new com.sun.star.beans.UnknownPropertyException();
+ }
+
+ public void addPropertyChangeListener(
+ String aPropertyName, com.sun.star.beans.XPropertyChangeListener xListener)
+ {
+ }
+ public void removePropertyChangeListener(
+ String aPropertyName, com.sun.star.beans.XPropertyChangeListener aListener)
+ {
+ }
+ public void addVetoableChangeListener(
+ String PropertyName, com.sun.star.beans.XVetoableChangeListener aListener)
+ {
+ }
+ public void removeVetoableChangeListener(
+ String PropertyName, com.sun.star.beans.XVetoableChangeListener aListener)
+ {
+ }
+}
+
+// implementation of com.sun.star.sheet.DataPilotSourceLevels
+
+class ExampleLevels implements com.sun.star.container.XNameAccess
+{
+ private final ExampleSettings aSettings;
+ private final int nDimension;
+ private ExampleLevel aLevel;
+
+ public ExampleLevels( ExampleSettings aSet, int nDim )
+ {
+ aSettings = aSet;
+ nDimension = nDim;
+ }
+
+ // XNameAccess
+
+ public com.sun.star.uno.Type getElementType()
+ {
+ return new com.sun.star.uno.Type( com.sun.star.container.XNamed.class );
+ }
+
+ public boolean hasElements()
+ {
+ return true; // always has elements
+ }
+
+ public Object getByName( String aName )
+ throws com.sun.star.container.NoSuchElementException
+ {
+ // there's only one level with the same name as the dimension / hierarchy
+ if ( aName.equals( ExampleSettings.aDimensionNames[nDimension] ) )
+ {
+ if ( aLevel == null )
+ aLevel = new ExampleLevel( aSettings, nDimension );
+ return aLevel;
+ }
+ throw new com.sun.star.container.NoSuchElementException();
+ }
+
+ public String[] getElementNames()
+ {
+ String [] aNames = new String[ 1 ];
+ aNames[0] = ExampleSettings.aDimensionNames[nDimension];
+ return aNames;
+ }
+
+ public boolean hasByName( String aName )
+ {
+ return aName.equals( ExampleSettings.aDimensionNames[nDimension] );
+ }
+}
+
+// implementation of com.sun.star.sheet.DataPilotSourceHierarchy
+
+class ExampleHierarchy implements com.sun.star.container.XNamed,
+ com.sun.star.sheet.XLevelsSupplier
+{
+ private final ExampleSettings aSettings;
+ private final int nDimension;
+ private ExampleLevels aLevels;
+
+ public ExampleHierarchy( ExampleSettings aSet, int nDim )
+ {
+ aSettings = aSet;
+ nDimension = nDim;
+ }
+
+ // XNamed
+
+ public String getName()
+ {
+ return ExampleSettings.aDimensionNames[ nDimension ];
+ }
+
+ public void setName( String aName )
+ {
+ // ignored
+ }
+
+ // XLevelsSupplier
+
+ public com.sun.star.container.XNameAccess getLevels()
+ {
+ if ( aLevels == null )
+ aLevels = new ExampleLevels( aSettings, nDimension );
+ return aLevels;
+ }
+}
+
+// implementation of com.sun.star.sheet.DataPilotSourceHierarchies
+
+class ExampleHierarchies implements com.sun.star.container.XNameAccess
+{
+ private final ExampleSettings aSettings;
+ private final int nDimension;
+ private ExampleHierarchy aHierarchy;
+
+ public ExampleHierarchies( ExampleSettings aSet, int nDim )
+ {
+ aSettings = aSet;
+ nDimension = nDim;
+ }
+
+ // XNameAccess
+
+ public com.sun.star.uno.Type getElementType()
+ {
+ return new com.sun.star.uno.Type( com.sun.star.container.XNamed.class );
+ }
+
+ public boolean hasElements()
+ {
+ return true; // always has elements
+ }
+
+ public Object getByName( String aName )
+ throws com.sun.star.container.NoSuchElementException
+ {
+ // there's only one hierarchy with the same name as the dimension
+ if ( aName.equals( ExampleSettings.aDimensionNames[nDimension] ) )
+ {
+ if ( aHierarchy == null )
+ aHierarchy = new ExampleHierarchy( aSettings, nDimension );
+ return aHierarchy;
+ }
+ throw new com.sun.star.container.NoSuchElementException();
+ }
+
+ public String[] getElementNames()
+ {
+ String [] aNames = new String[ 1 ];
+ aNames[0] = ExampleSettings.aDimensionNames[nDimension];
+ return aNames;
+ }
+
+ public boolean hasByName( String aName )
+ {
+ return aName.equals( ExampleSettings.aDimensionNames[nDimension] );
+ }
+}
+
+// implementation of com.sun.star.sheet.DataPilotSourceDimension
+
+class ExampleDimension implements
+ com.sun.star.container.XNamed,
+ com.sun.star.sheet.XHierarchiesSupplier,
+ com.sun.star.util.XCloneable,
+ com.sun.star.beans.XPropertySet
+{
+ private final ExampleSettings aSettings;
+ private final int nDimension;
+ private ExampleHierarchies aHierarchies;
+ private com.sun.star.sheet.DataPilotFieldOrientation eOrientation;
+
+ public ExampleDimension( ExampleSettings aSet, int nDim )
+ {
+ aSettings = aSet;
+ nDimension = nDim;
+ eOrientation = ( nDim == ExampleSettings.nValueDimension ) ?
+ com.sun.star.sheet.DataPilotFieldOrientation.DATA :
+ com.sun.star.sheet.DataPilotFieldOrientation.HIDDEN;
+ }
+
+ // XNamed
+
+ public String getName()
+ {
+ return ExampleSettings.aDimensionNames[ nDimension ];
+ }
+
+ public void setName( String aName )
+ {
+ // ignored
+ }
+
+ // XHierarchiesSupplier
+
+ public com.sun.star.container.XNameAccess getHierarchies()
+ {
+ if ( aHierarchies == null )
+ aHierarchies = new ExampleHierarchies( aSettings, nDimension );
+ return aHierarchies;
+ }
+
+ // XCloneable
+
+ public com.sun.star.util.XCloneable createClone()
+ {
+ return null; // not supported
+ }
+
+ // XPropertySet
+
+ public com.sun.star.beans.XPropertySetInfo getPropertySetInfo()
+ {
+ return new ExamplePropertySetInfo( new com.sun.star.beans.Property[] {
+ new com.sun.star.beans.Property( "Original", -1,
+ new com.sun.star.uno.Type( com.sun.star.container.XNamed.class),
+ com.sun.star.beans.PropertyAttribute.READONLY ),
+ new com.sun.star.beans.Property( "IsDataLayoutDimension", -1,
+ new com.sun.star.uno.Type( Boolean.class),
+ com.sun.star.beans.PropertyAttribute.READONLY ),
+ new com.sun.star.beans.Property( "Orientation", -1,
+ new com.sun.star.uno.Type(
+ com.sun.star.sheet.DataPilotFieldOrientation.class), (short) 0),
+ new com.sun.star.beans.Property( "Position", -1,
+ new com.sun.star.uno.Type( Integer.class ), (short) 0),
+ new com.sun.star.beans.Property( "Function", -1,
+ new com.sun.star.uno.Type(com.sun.star.sheet.GeneralFunction.class),
+ (short) 0 ),
+ new com.sun.star.beans.Property( "UsedHierarchy", -1,
+ new com.sun.star.uno.Type( Integer.class ), (short) 0 ),
+ new com.sun.star.beans.Property( "Filter", -1,
+ new com.sun.star.uno.Type(
+ com.sun.star.sheet.TableFilterField[].class), (short) 0) });
+ }
+
+ public void setPropertyValue( String aPropertyName, Object aValue )
+ throws com.sun.star.beans.UnknownPropertyException
+ {
+ if ( aPropertyName.equals( "Orientation" ) )
+ {
+ com.sun.star.sheet.DataPilotFieldOrientation eNewOrient =
+ (com.sun.star.sheet.DataPilotFieldOrientation) aValue;
+ if ( nDimension != ExampleSettings.nValueDimension &&
+ nDimension != ExampleSettings.nDataDimension &&
+ eNewOrient != com.sun.star.sheet.DataPilotFieldOrientation.DATA )
+ {
+ // remove from list for old orientation and add for new one
+ Integer aDimInt = Integer.valueOf(nDimension);
+ if ( eOrientation == com.sun.star.sheet.DataPilotFieldOrientation.COLUMN )
+ aSettings.aColDimensions.remove( aDimInt );
+ else if ( eOrientation == com.sun.star.sheet.DataPilotFieldOrientation.ROW )
+ aSettings.aRowDimensions.remove( aDimInt );
+ if ( eNewOrient == com.sun.star.sheet.DataPilotFieldOrientation.COLUMN )
+ aSettings.aColDimensions.add( aDimInt );
+ else if ( eNewOrient == com.sun.star.sheet.DataPilotFieldOrientation.ROW )
+ aSettings.aRowDimensions.add( aDimInt );
+
+ // change orientation
+ eOrientation = eNewOrient;
+ }
+ }
+ else if ( aPropertyName.equals( "Position" ) )
+ {
+ int nNewPos = ((Integer) aValue).intValue();
+ Integer aDimInt = Integer.valueOf(nDimension);
+ if ( eOrientation == com.sun.star.sheet.DataPilotFieldOrientation.COLUMN )
+ {
+ aSettings.aColDimensions.remove( aDimInt );
+ aSettings.aColDimensions.add( nNewPos, aDimInt );
+ }
+ else if ( eOrientation == com.sun.star.sheet.DataPilotFieldOrientation.ROW )
+ {
+ aSettings.aRowDimensions.remove( aDimInt );
+ aSettings.aRowDimensions.add( nNewPos, aDimInt );
+ }
+ }
+ else if ( aPropertyName.equals( "Function" ) || aPropertyName.equals( "UsedHierarchy" ) ||
+ aPropertyName.equals( "Filter" ) )
+ {
+ // ignored
+ }
+ else
+ throw new com.sun.star.beans.UnknownPropertyException();
+ }
+
+ public Object getPropertyValue( String aPropertyName )
+ throws com.sun.star.beans.UnknownPropertyException
+ {
+ if ( aPropertyName.equals( "Original" ) )
+ return null;
+ else if ( aPropertyName.equals( "IsDataLayoutDimension" ) )
+ return Boolean.valueOf( nDimension == ExampleSettings.nDataDimension );
+ else if ( aPropertyName.equals( "Orientation" ) )
+ return eOrientation;
+ else if ( aPropertyName.equals( "Position" ) )
+ {
+ int nPosition;
+ if ( eOrientation == com.sun.star.sheet.DataPilotFieldOrientation.COLUMN )
+ nPosition = aSettings.aColDimensions.indexOf( Integer.valueOf(nDimension) );
+ else if ( eOrientation == com.sun.star.sheet.DataPilotFieldOrientation.ROW )
+ nPosition = aSettings.aRowDimensions.indexOf( Integer.valueOf(nDimension) );
+ else
+ nPosition = nDimension;
+ return Integer.valueOf( nPosition );
+ }
+ else if ( aPropertyName.equals( "Function" ) )
+ return com.sun.star.sheet.GeneralFunction.SUM;
+ else if ( aPropertyName.equals( "UsedHierarchy" ) )
+ return Integer.valueOf(0);
+ else if ( aPropertyName.equals( "Filter" ) )
+ return new com.sun.star.sheet.TableFilterField[0];
+ else
+ throw new com.sun.star.beans.UnknownPropertyException();
+ }
+
+ public void addPropertyChangeListener(
+ String aPropertyName, com.sun.star.beans.XPropertyChangeListener xListener)
+ {
+ }
+ public void removePropertyChangeListener(
+ String aPropertyName, com.sun.star.beans.XPropertyChangeListener aListener)
+ {
+ }
+ public void addVetoableChangeListener(
+ String PropertyName, com.sun.star.beans.XVetoableChangeListener aListener)
+ {
+ }
+ public void removeVetoableChangeListener(
+ String PropertyName, com.sun.star.beans.XVetoableChangeListener aListener)
+ {
+ }
+}
+
+// implementation of com.sun.star.sheet.DataPilotSourceDimensions
+
+class ExampleDimensions implements com.sun.star.container.XNameAccess
+{
+ private final ExampleSettings aSettings;
+ private ExampleDimension[] aDimensions;
+
+ public ExampleDimensions( ExampleSettings aSet )
+ {
+ aSettings = aSet;
+ }
+
+ // XNameAccess
+
+ public com.sun.star.uno.Type getElementType()
+ {
+ return new com.sun.star.uno.Type( com.sun.star.container.XNamed.class );
+ }
+
+ public boolean hasElements()
+ {
+ return true; // always has elements
+ }
+
+ public Object getByName( String aName )
+ throws com.sun.star.container.NoSuchElementException
+ {
+ for (int i=0; i<ExampleSettings.nDimensionCount; i++)
+ if ( aName.equals( ExampleSettings.aDimensionNames[i] ) )
+ {
+ if ( aDimensions == null )
+ aDimensions = new ExampleDimension[ ExampleSettings.nDimensionCount ];
+ if ( aDimensions[i] == null )
+ aDimensions[i] = new ExampleDimension( aSettings, i );
+ return aDimensions[i];
+ }
+ throw new com.sun.star.container.NoSuchElementException();
+ }
+
+ public String[] getElementNames()
+ {
+ String [] aNames = new String[ ExampleSettings.nDimensionCount ];
+ for (int i=0; i<ExampleSettings.nDimensionCount; i++)
+ aNames[ i ] = ExampleSettings.aDimensionNames[i];
+ return aNames;
+ }
+
+ public boolean hasByName( String aName )
+ {
+ for (int i=0; i<ExampleSettings.nDimensionCount; i++)
+ if ( aName.equals( ExampleSettings.aDimensionNames[i] ) )
+ return true;
+ return false;
+ }
+}
+
+// outer class for service implementation
+
+public class ExampleDataPilotSource
+{
+ // implementation of com.sun.star.sheet.DataPilotSource
+
+ public static class _ExampleDataPilotSource implements
+ com.sun.star.sheet.XDimensionsSupplier,
+ com.sun.star.sheet.XDataPilotResults,
+ com.sun.star.util.XRefreshable,
+ com.sun.star.beans.XPropertySet,
+ com.sun.star.lang.XInitialization,
+ com.sun.star.lang.XServiceInfo
+ {
+ private static final String aServiceName = "com.sun.star.sheet.DataPilotSource";
+ private static final String aImplName = _ExampleDataPilotSource.class.getName();
+
+ private final ExampleSettings aSettings = new ExampleSettings();
+ private ExampleDimensions aDimensions;
+
+ public _ExampleDataPilotSource( com.sun.star.lang.XMultiServiceFactory xFactory )
+ {
+ }
+
+ // XInitialization
+
+ public void initialize( Object[] aArguments )
+ {
+ // If the first argument (Source) is a number between 2 and 10,
+ // use it as member count, otherwise keep the default value.
+ try
+ {
+ if ( aArguments.length >= 1 )
+ {
+ String aSource = com.sun.star.uno.AnyConverter.toString(aArguments[0]);
+ if ( aSource != null && aSource.length() > 0)
+ {
+ int nValue = Integer.parseInt( aSource );
+ if ( nValue >= 2 && nValue <= 10 )
+ aSettings.nMemberCount = nValue;
+ }
+ }
+ }
+ catch ( NumberFormatException e )
+ {
+ System.out.println( "Error: caught exception in " +
+ "ExampleDataPilotSource.initialize!\nException Message = "
+ + e.getMessage());
+ e.printStackTrace();
+ }
+ catch ( com.sun.star.lang.IllegalArgumentException e )
+ {
+ System.out.println( "Error: caught exception in " +
+ "ExampleDataPilotSource.initialize!\nException Message = "
+ + e.getMessage());
+ e.printStackTrace();
+ }
+ }
+
+ // XDataPilotResults
+
+ public com.sun.star.sheet.DataResult[][] getResults()
+ {
+ int[] nDigits = new int[ExampleSettings.nDimensionCount];
+ int nValue = 1;
+ for (int i=0; i<ExampleSettings.nDimensionCount; i++)
+ {
+ nDigits[i] = nValue;
+ nValue *= 10;
+ }
+
+ int nMemberCount = aSettings.nMemberCount;
+ int nRowDimCount = aSettings.aRowDimensions.size();
+ int nColDimCount = aSettings.aColDimensions.size();
+
+ int nRows = 1;
+ for (int i=0; i<nRowDimCount; i++)
+ nRows *= nMemberCount;
+ int nColumns = 1;
+ for (int i=0; i<nColDimCount; i++)
+ nColumns *= nMemberCount;
+
+ com.sun.star.sheet.DataResult[][] aResults = new com.sun.star.sheet.DataResult[nRows][];
+ for (int nRow=0; nRow<nRows; nRow++)
+ {
+ int nRowVal = nRow;
+ int nRowResult = 0;
+ for (int nRowDim=0; nRowDim<nRowDimCount; nRowDim++)
+ {
+ int nDim = aSettings.aRowDimensions.get(nRowDimCount-nRowDim-1).intValue();
+ nRowResult += ( nRowVal % nMemberCount ) * nDigits[nDim];
+ nRowVal /= nMemberCount;
+ }
+
+ aResults[nRow] = new com.sun.star.sheet.DataResult[nColumns];
+ for (int nCol=0; nCol<nColumns; nCol++)
+ {
+ int nColVal = nCol;
+ int nResult = nRowResult;
+ for (int nColDim=0; nColDim<nColDimCount; nColDim++)
+ {
+ int nDim = aSettings.aColDimensions.get(nColDimCount-nColDim-1).intValue();
+ nResult += ( nColVal % nMemberCount ) * nDigits[nDim];
+ nColVal /= nMemberCount;
+ }
+
+ aResults[nRow][nCol] = new com.sun.star.sheet.DataResult();
+ aResults[nRow][nCol].Flags = com.sun.star.sheet.DataResultFlags.HASDATA;
+ aResults[nRow][nCol].Value = nResult;
+ }
+ }
+ return aResults;
+ }
+
+ public double[] getFilteredResults(DataPilotFieldFilter[] aFilters) {
+ // FIXME
+ return new double[0];
+ }
+
+ // XDimensionsSupplier
+
+ public com.sun.star.container.XNameAccess getDimensions()
+ {
+ if ( aDimensions == null )
+ aDimensions = new ExampleDimensions( aSettings );
+ return aDimensions;
+ }
+
+ // XPropertySet
+
+ public com.sun.star.beans.XPropertySetInfo getPropertySetInfo()
+ {
+ return new ExamplePropertySetInfo( new com.sun.star.beans.Property[] {
+ new com.sun.star.beans.Property( "ColumnGrand", -1,
+ new com.sun.star.uno.Type( Boolean.class ), (short) 0),
+ new com.sun.star.beans.Property( "RowGrand", -1,
+ new com.sun.star.uno.Type( Boolean.class ), (short) 0) });
+ }
+
+ public void setPropertyValue( String aPropertyName, Object aValue )
+ throws com.sun.star.beans.UnknownPropertyException
+ {
+ if ( aPropertyName.equals( "ColumnGrand" ) ||
+ aPropertyName.equals( "RowGrand" ) )
+ {
+ // ignored
+ }
+ else
+ throw new com.sun.star.beans.UnknownPropertyException();
+ }
+
+ public Object getPropertyValue( String aPropertyName )
+ throws com.sun.star.beans.UnknownPropertyException
+ {
+ if ( aPropertyName.equals( "ColumnGrand" ) ||
+ aPropertyName.equals( "RowGrand" ) )
+ {
+ return Boolean.FALSE; // always false
+ }
+ else
+ throw new com.sun.star.beans.UnknownPropertyException();
+ }
+
+ public void addPropertyChangeListener(
+ String aPropertyName,
+ com.sun.star.beans.XPropertyChangeListener xListener )
+ {
+ }
+ public void removePropertyChangeListener(
+ String aPropertyName,
+ com.sun.star.beans.XPropertyChangeListener aListener )
+ {
+ }
+ public void addVetoableChangeListener(
+ String PropertyName,
+ com.sun.star.beans.XVetoableChangeListener aListener )
+ {
+ }
+ public void removeVetoableChangeListener(
+ String PropertyName,
+ com.sun.star.beans.XVetoableChangeListener aListener )
+ {
+ }
+
+ // XRefreshable
+
+ public void refresh()
+ {
+ }
+ public void addRefreshListener( com.sun.star.util.XRefreshListener l )
+ {
+ }
+ public void removeRefreshListener( com.sun.star.util.XRefreshListener l )
+ {
+ }
+
+ // XServiceInfo
+
+ public String getImplementationName()
+ {
+ return aImplName;
+ }
+
+ public String[] getSupportedServiceNames()
+ {
+ String [] aSupportedServices = new String[ 1 ];
+ aSupportedServices[ 0 ] = aServiceName;
+ return aSupportedServices;
+ }
+
+ public boolean supportsService( String aService )
+ {
+ return aService.equals( aServiceName );
+ }
+ }
+
+ public static com.sun.star.lang.XSingleServiceFactory __getServiceFactory(
+ String implName,
+ com.sun.star.lang.XMultiServiceFactory multiFactory,
+ com.sun.star.registry.XRegistryKey regKey)
+ {
+ com.sun.star.lang.XSingleServiceFactory xSingleServiceFactory = null;
+
+ if ( implName.equals(_ExampleDataPilotSource.aImplName) )
+ xSingleServiceFactory =
+ com.sun.star.comp.loader.FactoryHelper.getServiceFactory(
+ _ExampleDataPilotSource.class,
+ _ExampleDataPilotSource.aServiceName, multiFactory, regKey);
+
+ return xSingleServiceFactory;
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/Spreadsheet/GeneralTableSample.java b/odk/examples/DevelopersGuide/Spreadsheet/GeneralTableSample.java
new file mode 100644
index 000000000..655447eff
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Spreadsheet/GeneralTableSample.java
@@ -0,0 +1,231 @@
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.RuntimeException;
+
+
+// __________ implementation ____________________________________
+
+/** Create a spreadsheet document and provide access to table contents.
+ */
+public class GeneralTableSample extends SpreadsheetDocHelper
+{
+
+
+
+ public static void main( String args[] )
+ {
+ try
+ {
+ GeneralTableSample aSample = new GeneralTableSample( args );
+ aSample.doSampleFunction();
+ }
+ catch (Exception ex)
+ {
+ System.out.println( "Error: Sample caught exception!\nException Message = "
+ + ex.getMessage());
+ ex.printStackTrace();
+ System.exit( 1 );
+ }
+
+ System.out.println( "Sample done." );
+ System.exit( 0 );
+ }
+
+
+
+ /// This sample function modifies cells and cell ranges.
+ public void doSampleFunction() throws RuntimeException, Exception
+ {
+ // for common usage
+ com.sun.star.sheet.XSpreadsheet xSheet = getSpreadsheet( 0 );
+ com.sun.star.beans.XPropertySet xPropSet = null;
+ com.sun.star.table.XCell xCell = null;
+ com.sun.star.table.XCellRange xCellRange = null;
+
+ // *** Access and modify a VALUE CELL ***
+ System.out.println( "*** Sample for service table.Cell ***" );
+
+ xCell = xSheet.getCellByPosition( 0, 0 );
+ // Set cell value.
+ xCell.setValue( 1234 );
+
+ // Get cell value.
+ double nDblValue = xCell.getValue() * 2;
+ xSheet.getCellByPosition( 0, 1 ).setValue( nDblValue );
+
+ // *** Create a FORMULA CELL and query error type ***
+ xCell = xSheet.getCellByPosition( 0, 2 );
+ // Set formula string.
+ xCell.setFormula( "=1/0" );
+
+ // Get error type.
+ boolean bValid = (xCell.getError() == 0);
+ // Get formula string.
+ String aText = "The formula " + xCell.getFormula() + " is ";
+ aText += bValid ? "valid." : "erroneous.";
+
+ // *** Insert a TEXT CELL using the XText interface ***
+ xCell = xSheet.getCellByPosition( 0, 3 );
+ com.sun.star.text.XText xCellText = UnoRuntime.queryInterface( com.sun.star.text.XText.class, xCell );
+ com.sun.star.text.XTextCursor xTextCursor = xCellText.createTextCursor();
+ xCellText.insertString( xTextCursor, aText, false );
+
+ // *** Change cell properties ***
+ int nValue = bValid ? 0x00FF00 : 0xFF4040;
+ xPropSet = UnoRuntime.queryInterface( com.sun.star.beans.XPropertySet.class, xCell );
+ xPropSet.setPropertyValue( "CellBackColor", Integer.valueOf( nValue ) );
+
+
+ // *** Accessing a CELL RANGE ***
+ System.out.println( "*** Sample for service table.CellRange ***" );
+
+ // Accessing a cell range over its position.
+ xCellRange = xSheet.getCellRangeByPosition( 2, 0, 3, 1 );
+
+ // Change properties of the range.
+ xPropSet = UnoRuntime.queryInterface( com.sun.star.beans.XPropertySet.class, xCellRange );
+ xPropSet.setPropertyValue( "CellBackColor", Integer.valueOf( 0x8080FF ) );
+
+ // Accessing a cell range over its name.
+ xCellRange = xSheet.getCellRangeByName( "C4:D5" );
+
+ // Change properties of the range.
+ xPropSet = UnoRuntime.queryInterface( com.sun.star.beans.XPropertySet.class, xCellRange );
+ xPropSet.setPropertyValue( "CellBackColor", Integer.valueOf( 0xFFFF80 ) );
+
+
+ // *** Using the CELL CURSOR to add some data below of the filled area ***
+ System.out.println( "*** Sample for service table.CellCursor ***" );
+
+ // Create a cursor using the XSpreadsheet method createCursorByRange()
+ xCellRange = xSheet.getCellRangeByName( "A1" );
+ com.sun.star.sheet.XSheetCellRange xSheetCellRange = UnoRuntime.queryInterface( com.sun.star.sheet.XSheetCellRange.class, xCellRange );
+
+ com.sun.star.sheet.XSheetCellCursor xSheetCellCursor =
+ xSheet.createCursorByRange( xSheetCellRange );
+ com.sun.star.table.XCellCursor xCursor = UnoRuntime.queryInterface( com.sun.star.table.XCellCursor.class, xSheetCellCursor );
+
+ // Move to the last filled cell.
+ xCursor.gotoEnd();
+ // Move one row down.
+ xCursor.gotoOffset( 0, 1 );
+ xCursor.getCellByPosition( 0, 0 ).setFormula( "Beyond of the last filled cell." );
+
+
+ // *** Modifying COLUMNS and ROWS ***
+ System.out.println( "*** Sample for services table.TableRows and table.TableColumns ***" );
+
+ com.sun.star.table.XColumnRowRange xCRRange = UnoRuntime.queryInterface( com.sun.star.table.XColumnRowRange.class, xSheet );
+ com.sun.star.table.XTableColumns xColumns = xCRRange.getColumns();
+ com.sun.star.table.XTableRows xRows = xCRRange.getRows();
+
+ // Get column C by index (interface XIndexAccess).
+ Object aColumnObj = xColumns.getByIndex( 2 );
+ xPropSet = UnoRuntime.queryInterface( com.sun.star.beans.XPropertySet.class, aColumnObj );
+ xPropSet.setPropertyValue( "Width", Integer.valueOf( 5000 ) );
+
+ // Get the name of the column.
+ com.sun.star.container.XNamed xNamed = UnoRuntime.queryInterface( com.sun.star.container.XNamed.class, aColumnObj );
+ aText = "The name of this column is " + xNamed.getName() + ".";
+ xSheet.getCellByPosition( 2, 2 ).setFormula( aText );
+
+ // Get column D by name (interface XNameAccess).
+ com.sun.star.container.XNameAccess xColumnsName = UnoRuntime.queryInterface( com.sun.star.container.XNameAccess.class, xColumns );
+
+ aColumnObj = xColumnsName.getByName( "D" );
+ xPropSet = UnoRuntime.queryInterface( com.sun.star.beans.XPropertySet.class, aColumnObj );
+ xPropSet.setPropertyValue( "IsVisible", Boolean.FALSE );
+
+ // Get row 7 by index (interface XIndexAccess)
+ Object aRowObj = xRows.getByIndex( 6 );
+ xPropSet = UnoRuntime.queryInterface( com.sun.star.beans.XPropertySet.class, aRowObj );
+ xPropSet.setPropertyValue( "Height", Integer.valueOf( 5000 ) );
+
+ xSheet.getCellByPosition( 2, 6 ).setFormula( "What a big cell." );
+
+ // Create a cell series with the values 1 ... 7.
+ for (int nRow = 8; nRow < 15; ++nRow)
+ xSheet.getCellByPosition( 0, nRow ).setValue( nRow - 7 );
+ // Insert a row between 1 and 2
+ xRows.insertByIndex( 9, 1 );
+ // Delete the rows with the values 3 and 4.
+ xRows.removeByIndex( 11, 2 );
+
+ // *** Inserting CHARTS ***
+ System.out.println( "*** Sample for service table.TableCharts ***" );
+
+ com.sun.star.table.XTableChartsSupplier xChartsSupp =
+ UnoRuntime.queryInterface(
+ com.sun.star.table.XTableChartsSupplier.class, xSheet );
+ com.sun.star.table.XTableCharts xCharts = xChartsSupp.getCharts();
+
+ // The chart will base on the last cell series, initializing all values.
+ String aName = "newChart";
+ com.sun.star.awt.Rectangle aRect = new com.sun.star.awt.Rectangle();
+ aRect.X = 10000;
+ aRect.Y = 3000;
+ aRect.Width = aRect.Height = 5000;
+ com.sun.star.table.CellRangeAddress[] aRanges = new com.sun.star.table.CellRangeAddress[1];
+ aRanges[0] = createCellRangeAddress( xSheet, "A9:A14" );
+
+ // Create the chart.
+ xCharts.addNewByName( aName, aRect, aRanges, false, false );
+
+ // Get the chart by name.
+ Object aChartObj = xCharts.getByName( aName );
+ com.sun.star.table.XTableChart xChart = UnoRuntime.queryInterface( com.sun.star.table.XTableChart.class, aChartObj );
+
+ // Query the state of row and column headers.
+ aText = "Chart has column headers: ";
+ aText += xChart.getHasColumnHeaders() ? "yes" : "no";
+ xSheet.getCellByPosition( 2, 8 ).setFormula( aText );
+ aText = "Chart has row headers: ";
+ aText += xChart.getHasRowHeaders() ? "yes" : "no";
+ xSheet.getCellByPosition( 2, 9 ).setFormula( aText );
+ }
+
+
+
+ public GeneralTableSample( String[] args )
+ {
+ super( args );
+ }
+
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/Spreadsheet/Makefile b/odk/examples/DevelopersGuide/Spreadsheet/Makefile
new file mode 100644
index 000000000..e5b8401d6
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Spreadsheet/Makefile
@@ -0,0 +1,304 @@
+#*************************************************************************
+#
+# The Contents of this file are made available subject to the terms of
+# the BSD license.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+# 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+# contributors may be used to endorse or promote products derived
+# from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+# TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+# USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+#**************************************************************************
+
+# Builds the SpreadSheet examples of the Developers Guide.
+
+PRJ=../../..
+SETTINGS=$(PRJ)/settings
+
+include $(SETTINGS)/settings.mk
+include $(SETTINGS)/std.mk
+
+# Define non-platform/compiler specific settings
+SAMPLE_NAME=DevGuideSpreadsheetExamples
+SAMPLE_CLASS_OUT=$(OUT_CLASS)/$(SAMPLE_NAME)
+SAMPLE_GEN_OUT=$(OUT_MISC)/$(SAMPLE_NAME)
+
+# Example add-in component
+COMP1_NAME=ExampleAddIn
+COMP1_CLASS_OUT=$(SAMPLE_CLASS_OUT)/$(COMP1_NAME)
+COMP1_GEN_OUT=$(SAMPLE_GEN_OUT)/$(COMP1_NAME)
+COMP1_RDB_NAME=$(COMP1_NAME).uno.rdb
+COMP1_RDB=$(COMP1_GEN_OUT)/$(COMP1_RDB_NAME)
+COMP1_PACKAGE=$(OUT_BIN)/$(COMP1_NAME).$(UNOOXT_EXT)
+COMP1_PACKAGE_URL=$(subst \\,\,"$(COMP_PACKAGE_DIR)$(PS)$(COMP1_NAME).$(UNOOXT_EXT)")
+COMP1_JAR_NAME=$(COMP1_NAME).uno.jar
+COMP1_JAR=$(SAMPLE_CLASS_OUT)/$(COMP1_JAR_NAME)
+COMP1_MANIFESTFILE=$(COMP1_GEN_OUT)/$(COMP1_NAME).uno.Manifest
+COMP1_UNOPKG_MANIFEST=$(COMP1_GEN_OUT)/$(COMP1_NAME)/META-INF/manifest.xml
+COMP1_REGISTERFLAG=$(SAMPLE_GEN_OUT)/devguide_$(COMP1_NAME)_register_component.flag
+COMP1_COMPONENTS=$(COMP1_NAME).components
+
+# Example DataPilot component
+COMP2_NAME=ExampleDataPilotSource
+COMP2_CLASS_OUT=$(SAMPLE_CLASS_OUT)/$(COMP2_NAME)
+COMP2_GEN_OUT=$(SAMPLE_GEN_OUT)/$(COMP2_NAME)
+COMP2_PACKAGE=$(OUT_BIN)/$(COMP2_NAME).$(UNOOXT_EXT)
+COMP2_PACKAGE_URL=$(subst \\,\,"$(COMP_PACKAGE_DIR)$(PS)$(COMP2_NAME).$(UNOOXT_EXT)")
+COMP2_JAR_NAME=$(COMP2_NAME).uno.jar
+COMP2_JAR=$(SAMPLE_CLASS_OUT)/$(COMP2_JAR_NAME)
+COMP2_MANIFESTFILE=$(COMP2_GEN_OUT)/$(COMP2_NAME).uno.Manifest
+COMP2_UNOPKG_MANIFEST=$(COMP2_GEN_OUT)/$(COMP2_NAME)/META-INF/manifest.xml
+COMP2_REGISTERFLAG=$(SAMPLE_GEN_OUT)/devguide_$(COMP2_NAME)_register_component.flag
+COMP2_COMPONENTS=$(COMP2_NAME).components
+
+#REGISTERFLAG = $(OUT_MISC)$(PS)devguide_$(SAMPLE_NAME)_register_component.flag
+
+APP1_NAME=GeneralTableSample
+APP1_CLASS_OUT=$(SAMPLE_CLASS_OUT)/$(APP1_NAME)
+APP1_GEN_OUT=$(SAMPLE_GEN_OUT)/$(APP1_NAME)
+APP1_JAR=$(SAMPLE_CLASS_OUT)/$(APP1_NAME).jar
+
+APP2_NAME=SpreadsheetSample
+APP2_CLASS_OUT=$(SAMPLE_CLASS_OUT)/$(APP2_NAME)
+APP2_GEN_OUT=$(SAMPLE_GEN_OUT)/$(APP2_NAME)
+APP2_JAR=$(SAMPLE_CLASS_OUT)/$(APP2_NAME).jar
+
+APP3_NAME=ViewSample
+APP3_CLASS_OUT=$(SAMPLE_CLASS_OUT)/$(APP3_NAME)
+APP3_GEN_OUT=$(SAMPLE_GEN_OUT)/$(APP3_NAME)
+APP3_JAR=$(SAMPLE_CLASS_OUT)/$(APP3_NAME).jar
+
+
+COMP1_IDLFILES = XExampleAddIn.idl
+
+# normally the idl file should be stored in a directory tree fitting the
+# module structure, for the example we know the module structure
+PACKAGE = org/openoffice/sheet/addin
+
+COMP1_JAVAFILES = \
+ ExampleAddIn.java
+
+COMP2_JAVAFILES = \
+ ExampleDataPilotSource.java
+
+APP_JAVAFILES = \
+ SpreadsheetDocHelper.java
+
+APP_CLASSFILES = $(patsubst %.java,$(SAMPLE_CLASS_OUT)/%.class,$(APP_JAVAFILES))
+APP_CLASSNAMES = $(patsubst %.java,%.class,$(APP_JAVAFILES))
+
+COMP1_GENCLASSFILES = $(patsubst %.idl,$(COMP1_CLASS_OUT)/$(PACKAGE)/%.class,$(COMP1_IDLFILES))
+COMP1_GENTYPELIST = $(subst /,.,$(patsubst %.idl,-T$(PACKAGE)/% ,$(COMP1_IDLFILES)))
+
+COMP1_CLASSFILES = $(patsubst %.java,$(COMP1_CLASS_OUT)/%.class,$(COMP1_JAVAFILES))
+
+COMP2_CLASSFILES = $(patsubst %.java,$(COMP2_CLASS_OUT)/%.class,$(COMP2_JAVAFILES))
+
+
+SDK_CLASSPATH = $(subst $(EMPTYSTRING) $(PATH_SEPARATOR),$(PATH_SEPARATOR),$(CLASSPATH)\
+ $(PATH_SEPARATOR)$(SAMPLE_CLASS_OUT)\
+ $(PATH_SEPARATOR)$(COMP1_CLASS_OUT)\
+ $(PATH_SEPARATOR)$(COMP2_CLASS_OUT)\
+ $(PATH_SEPARATOR)$(APP1_CLASS_OUT)\
+ $(PATH_SEPARATOR)$(APP2_CLASS_OUT)\
+ $(PATH_SEPARATOR)$(APP3_CLASS_OUT))
+
+
+# Targets
+.PHONY: ALL
+ALL : $(SAMPLE_NAME)
+
+include $(SETTINGS)/stdtarget.mk
+
+$(SAMPLE_GEN_OUT)/%.Manifest :
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ @echo UNO-Type-Path: $(basename $(notdir $*)).uno.jar> $@
+ @echo RegistrationClassName: $(basename $(basename $(@F)))>> $@
+
+# IDLs only for component 1 relevant
+$(COMP1_RDB) : $(COMP1_IDLFILES)
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ $(UNOIDLWRITE) $(URE_TYPES) $(OFFICE_TYPES) $< $@
+
+$(COMP1_CLASS_OUT)/$(PACKAGE)/%.class : $(COMP1_RDB)
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ $(JAVAMAKER) -nD $(COMP1_GENTYPELIST) -O$(COMP1_CLASS_OUT) $(COMP1_RDB) -X$(URE_TYPES) -X$(OFFICE_TYPES)
+
+$(COMP1_CLASSFILES) : $(COMP1_JAVAFILES) $(COMP1_GENCLASSFILES)
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ $(SDK_JAVAC) $(JAVAC_FLAGS) -classpath "$(SDK_CLASSPATH)" -d $(COMP1_CLASS_OUT) $(COMP1_JAVAFILES)
+
+$(COMP2_CLASSFILES) : $(COMP2_JAVAFILES)
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ $(SDK_JAVAC) $(JAVAC_FLAGS) -classpath "$(SDK_CLASSPATH)" -d $(COMP2_CLASS_OUT) $^
+
+$(COMP1_JAR) : $(COMP1_MANIFESTFILE) $(COMP1_CLASSFILES)
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ $(SDK_JAR) cvfm $@ $< -C $(COMP1_CLASS_OUT) .
+
+$(COMP2_JAR) : $(COMP2_MANIFESTFILE) $(COMP2_CLASSFILES)
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ $(SDK_JAR) cvfm $@ $< -C $(COMP2_CLASS_OUT) .
+
+$(COMP1_UNOPKG_MANIFEST) :
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ @echo $(OSEP)?xml version="$(QM)1.0$(QM)" encoding="$(QM)UTF-8$(QM)"?$(CSEP) > $@
+ @echo $(OSEP)!DOCTYPE manifest:manifest PUBLIC "$(QM)-//OpenOffice.org//DTD Manifest 1.0//EN$(QM)" "$(QM)Manifest.dtd$(QM)"$(CSEP) >> $@
+ @echo $(OSEP)manifest:manifest xmlns:manifest="$(QM)http://openoffice.org/2001/manifest$(QM)"$(CSEP) >> $@
+ @echo $(SQM) $(SQM)$(OSEP)manifest:file-entry manifest:media-type="$(QM)application/vnd.sun.star.uno-typelibrary;type=RDB$(QM)" >> $@
+ @echo $(SQM) $(SQM)manifest:full-path="$(QM)$(subst /META-INF,,$(subst $(COMP1_GEN_OUT)/,,$(@D))).uno.rdb$(QM)"/$(CSEP) >> $@
+ @echo $(SQM) $(SQM)$(OSEP)manifest:file-entry manifest:media-type="$(QM)application/vnd.sun.star.uno-components$(QM)">> $@
+ @echo $(SQM) $(SQM)manifest:full-path="$(QM)$(COMP1_COMPONENTS)$(QM)"/$(CSEP)>> $@
+ @echo $(OSEP)/manifest:manifest$(CSEP) >> $@
+
+$(COMP2_UNOPKG_MANIFEST) :
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ @echo $(OSEP)?xml version="$(QM)1.0$(QM)" encoding="$(QM)UTF-8$(QM)"?$(CSEP) > $@
+ @echo $(OSEP)!DOCTYPE manifest:manifest PUBLIC "$(QM)-//OpenOffice.org//DTD Manifest 1.0//EN$(QM)" "$(QM)Manifest.dtd$(QM)"$(CSEP) >> $@
+ @echo $(OSEP)manifest:manifest xmlns:manifest="$(QM)http://openoffice.org/2001/manifest$(QM)"$(CSEP) >> $@
+ @echo $(SQM) $(SQM)$(OSEP)manifest:file-entry manifest:media-type="$(QM)application/vnd.sun.star.uno-components$(QM)">> $@
+ @echo $(SQM) $(SQM)manifest:full-path="$(QM)$(COMP2_COMPONENTS)$(QM)"/$(CSEP)>> $@
+ @echo $(OSEP)/manifest:manifest$(CSEP) >> $@
+
+$(COMP1_PACKAGE) : $(COMP1_RDB) $(COMP1_JAR) $(COMP1_UNOPKG_MANIFEST) $(COMP1_COMPONENTS) description.xml
+ echo "####" $(@)
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ $(SDK_ZIP) $@ $(COMP1_COMPONENTS) description.xml
+ cd $(subst /,$(PS),$(COMP1_GEN_OUT)) && $(SDK_ZIP) -u ../../../bin/$(@F) $(<F)
+ cd $(subst /,$(PS),$(SAMPLE_CLASS_OUT)) && $(SDK_ZIP) -u ../../bin/$(@F) $(COMP1_JAR_NAME)
+ cd $(subst /,$(PS),$(COMP1_GEN_OUT)/$(subst .$(UNOOXT_EXT),,$(@F))) && $(SDK_ZIP) -u ../../../../bin/$(@F) META-INF/manifest.xml
+
+$(COMP2_PACKAGE) : $(COMP2_JAR) $(COMP2_UNOPKG_MANIFEST) $(COMP2_COMPONENTS)
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ $(SDK_ZIP) $@ $(COMP2_COMPONENTS)
+ cd $(subst /,$(PS),$(SAMPLE_CLASS_OUT)) && $(SDK_ZIP) -u ../../bin/$(@F) $(<F)
+ cd $(subst /,$(PS),$(COMP2_GEN_OUT)/$(subst .$(UNOOXT_EXT),,$(@F))) && $(SDK_ZIP) -u ../../../../bin/$(@F) META-INF/manifest.xml
+
+$(SAMPLE_GEN_OUT)/devguide_$(COMP1_NAME)_register_component.flag : $(OUT_BIN)/$(COMP1_NAME).$(UNOOXT_EXT)
+ifeq "$(SDK_AUTO_DEPLOYMENT)" "YES"
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ $(DEPLOYTOOL) $(subst \\,\,"$(COMP_PACKAGE_DIR)$(PS)$(COMP1_NAME).$(UNOOXT_EXT)")
+ @echo flagged > $(subst /,$(PS),$@)
+else
+ @echo --------------------------------------------------------------------------------
+ @echo If you want to install your component automatically, please set the environment
+ @echo variable SDK_AUTO_DEPLOYMENT = YES. But note that auto deployment is only
+ @echo possible if no office instance is running.
+ @echo --------------------------------------------------------------------------------
+endif
+
+$(SAMPLE_GEN_OUT)/devguide_$(COMP2_NAME)_register_component.flag : $(OUT_BIN)/$(COMP2_NAME).$(UNOOXT_EXT)
+ifeq "$(SDK_AUTO_DEPLOYMENT)" "YES"
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ $(DEPLOYTOOL) $(subst \\,\,"$(COMP_PACKAGE_DIR)$(PS)$(COMP2_NAME).$(UNOOXT_EXT)")
+ @echo flagged > $(subst /,$(PS),$@)
+else
+ @echo --------------------------------------------------------------------------------
+ @echo If you want to install your component automatically, please set the environment
+ @echo variable SDK_AUTO_DEPLOYMENT = YES. But note that auto deployment is only
+ @echo possible if no office instance is running.
+ @echo --------------------------------------------------------------------------------
+endif
+
+$(APP_CLASSFILES) : $(APP_JAVAFILES)
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ $(SDK_JAVAC) $(JAVAC_FLAGS) -classpath "$(SDK_CLASSPATH)" -d $(SAMPLE_CLASS_OUT) $(APP_JAVAFILES)
+
+$(APP1_CLASS_OUT)/%.class : %.java $(APP_CLASSFILES)
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ $(SDK_JAVAC) $(JAVAC_FLAGS) -classpath "$(SDK_CLASSPATH)" -d $(APP1_CLASS_OUT) $<
+
+$(APP2_CLASS_OUT)/%.class : %.java $(APP_CLASSFILES)
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ $(SDK_JAVAC) $(JAVAC_FLAGS) -classpath "$(SDK_CLASSPATH)" -d $(APP2_CLASS_OUT) $<
+
+$(APP3_CLASS_OUT)/%.class : %.java $(APP_CLASSFILES)
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ $(SDK_JAVAC) $(JAVAC_FLAGS) -classpath "$(SDK_CLASSPATH)" -d $(APP3_CLASS_OUT) $<
+
+$(SAMPLE_GEN_OUT)/%.mf :
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ @echo Main-Class: com.sun.star.lib.loader.Loader> $@
+ $(ECHOLINE)>> $@
+ @echo Name: com/sun/star/lib/loader/Loader.class>> $@
+ @echo Application-Class: $(basename $(@F))>> $@
+
+$(APP1_JAR) : $(APP1_GEN_OUT)/$(APP1_NAME).mf $(APP1_CLASS_OUT)/$(APP1_NAME).class $(APP_CLASSFILES)
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ +$(SDK_JAR) cvfm $@ $< -C $(APP1_CLASS_OUT) .
+ +$(SDK_JAR) uvf $@ $(SDK_JAVA_UNO_BOOTSTRAP_FILES)
+ +cd $(subst /,$(PS),$(SAMPLE_CLASS_OUT)) && $(SDK_JAR) uvf $(@F) $(APP_CLASSNAMES)
+
+$(APP2_JAR) : $(APP2_GEN_OUT)/$(APP2_NAME).mf $(APP2_CLASS_OUT)/$(APP2_NAME).class $(APP_CLASSFILES)
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ +$(SDK_JAR) cvfm $@ $< -C $(APP2_CLASS_OUT) .
+ +$(SDK_JAR) uvf $@ $(SDK_JAVA_UNO_BOOTSTRAP_FILES)
+ +cd $(subst /,$(PS),$(SAMPLE_CLASS_OUT)) && $(SDK_JAR) uvf $(@F) $(APP_CLASSNAMES)
+
+$(APP3_JAR) : $(APP3_GEN_OUT)/$(APP3_NAME).mf $(APP3_CLASS_OUT)/$(APP3_NAME).class $(APP_CLASSFILES)
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ +$(SDK_JAR) cvfm $@ $< -C $(APP3_CLASS_OUT) .
+ +$(SDK_JAR) uvf $@ $(SDK_JAVA_UNO_BOOTSTRAP_FILES)
+ +cd $(subst /,$(PS),$(SAMPLE_CLASS_OUT)) && $(SDK_JAR) uvf $(@F) $(APP_CLASSNAMES)
+
+$(SAMPLE_NAME) : $(COMP1_REGISTERFLAG) $(COMP2_REGISTERFLAG) $(APP1_JAR) $(APP2_JAR) $(APP3_JAR)
+ @echo --------------------------------------------------------------------------------
+ @echo Please use one of the following commands to execute the examples!
+ @echo -
+ @echo $(MAKE) $(APP1_NAME).run
+ @echo $(MAKE) $(APP2_NAME).run
+ @echo $(MAKE) $(APP3_NAME).run
+ @echo --------
+ @echo The "$(QM)$(COMP1_NAME)$(QM)" and "$(QM)$(COMP2_NAME)$(QM)" component are installed if
+ @echo SDK_AUTO_DEPLOYMENT = YES. You can use this components inside your office
+ @echo installation, see the example descriptions. You can also load the "$(QM)ExampleAddIn.ods$(QM)"
+ @echo document to see how the add-in functions can be used. For more details about the
+ @echo "$(QM)$(COMP2_NAME)$(QM)" component see the "$(QM)DataPilotReadme.txt"$(QM).
+ @echo -
+ @echo $(MAKE) ExampleAddIn.ods.load
+ @echo --------------------------------------------------------------------------------
+
+%.run: $(SAMPLE_CLASS_OUT)/%.jar
+ $(SDK_JAVA) -Dcom.sun.star.lib.loader.unopath="$(OFFICE_PROGRAM_PATH)" -jar $<
+
+ExampleAddIn.ods.load : $(COMP1_REGISTERFLAG)
+ "$(OFFICE_PROGRAM_PATH)$(PS)soffice" $(basename $@)
+
+.PHONY: clean
+clean :
+ -$(DELRECURSIVE) $(subst /,$(PS),$(SAMPLE_CLASS_OUT))
+ -$(DELRECURSIVE) $(subst /,$(PS),$(SAMPLE_GEN_OUT))
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$(COMP1_PACKAGE_URL)))
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$(COMP2_PACKAGE_URL)))
diff --git a/odk/examples/DevelopersGuide/Spreadsheet/SpreadsheetDocHelper.java b/odk/examples/DevelopersGuide/Spreadsheet/SpreadsheetDocHelper.java
new file mode 100644
index 000000000..0696a866c
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Spreadsheet/SpreadsheetDocHelper.java
@@ -0,0 +1,388 @@
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+import com.sun.star.frame.XComponentLoader;
+import com.sun.star.lang.XComponent;
+
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.RuntimeException;
+
+// __________ implementation ____________________________________
+
+/** This is a helper class for the spreadsheet and table samples.
+ It connects to a running office and creates a spreadsheet document.
+ Additionally it contains various helper functions.
+ */
+public class SpreadsheetDocHelper
+{
+
+// __ private members ___________________________________________
+
+ private com.sun.star.uno.XComponentContext mxRemoteContext;
+ private com.sun.star.lang.XMultiComponentFactory mxRemoteServiceManager;
+ private com.sun.star.sheet.XSpreadsheetDocument mxDocument;
+
+
+
+ public SpreadsheetDocHelper( String[] args )
+ {
+ // Connect to a running office and get the service manager
+ connect();
+
+ // Create a new spreadsheet document
+ try
+ {
+ mxDocument = initDocument();
+ }
+ catch (Exception ex)
+ {
+ System.err.println( "Couldn't create document: " + ex );
+ System.err.println( "Error: Couldn't create Document\nException Message = "
+ + ex.getMessage());
+ ex.printStackTrace();
+ System.exit( 1 );
+ }
+ }
+
+// __ helper methods ____________________________________________
+
+ /** Returns the service manager of the connected office.
+ @return XMultiComponentFactory interface of the service manager. */
+ public com.sun.star.lang.XMultiComponentFactory getServiceManager()
+ {
+ return mxRemoteServiceManager;
+ }
+
+ /** Returns the component context of the connected office
+ @return XComponentContext interface of the context. */
+ public com.sun.star.uno.XComponentContext getContext()
+ {
+ return mxRemoteContext;
+ }
+
+ /** Returns the whole spreadsheet document.
+ @return XSpreadsheetDocument interface of the document. */
+ public com.sun.star.sheet.XSpreadsheetDocument getDocument()
+ {
+ return mxDocument;
+ }
+
+ /** Returns the spreadsheet with the specified index (0-based).
+ @param nIndex The index of the sheet.
+ @return XSpreadsheet interface of the sheet. */
+ public com.sun.star.sheet.XSpreadsheet getSpreadsheet( int nIndex )
+ {
+ // Collection of sheets
+ com.sun.star.sheet.XSpreadsheets xSheets = mxDocument.getSheets();
+ com.sun.star.sheet.XSpreadsheet xSheet = null;
+ try
+ {
+ com.sun.star.container.XIndexAccess xSheetsIA =
+ UnoRuntime.queryInterface(
+ com.sun.star.container.XIndexAccess.class, xSheets );
+ xSheet = UnoRuntime.queryInterface(
+ com.sun.star.sheet.XSpreadsheet.class, xSheetsIA.getByIndex(nIndex));
+ }
+ catch (Exception ex)
+ {
+ System.err.println( "Error: caught exception in getSpreadsheet()!\nException Message = "
+ + ex.getMessage());
+ ex.printStackTrace();
+ }
+ return xSheet;
+ }
+
+ /** Inserts a new empty spreadsheet with the specified name.
+ @param aName The name of the new sheet.
+ @param nIndex The insertion index.
+ @return The XSpreadsheet interface of the new sheet. */
+ public com.sun.star.sheet.XSpreadsheet insertSpreadsheet(
+ String aName, short nIndex )
+ {
+ // Collection of sheets
+ com.sun.star.sheet.XSpreadsheets xSheets = mxDocument.getSheets();
+ com.sun.star.sheet.XSpreadsheet xSheet = null;
+ try
+ {
+ xSheets.insertNewByName( aName, nIndex );
+ xSheet = UnoRuntime.queryInterface(com.sun.star.sheet.XSpreadsheet.class,
+ xSheets.getByName( aName ));
+ }
+ catch (Exception ex)
+ {
+ System.err.println( "Error: caught exception in insertSpreadsheet()!\nException Message = "
+ + ex.getMessage());
+ ex.printStackTrace();
+ }
+ return xSheet;
+ }
+
+
+// Methods to fill values into cells.
+
+ /** Writes a double value into a spreadsheet.
+ @param xSheet The XSpreadsheet interface of the spreadsheet.
+ @param aCellName The address of the cell (or a named range).
+ @param fValue The value to write into the cell. */
+ public void setValue(
+ com.sun.star.sheet.XSpreadsheet xSheet,
+ String aCellName,
+ double fValue ) throws RuntimeException, Exception
+ {
+ xSheet.getCellRangeByName( aCellName ).getCellByPosition( 0, 0 ).setValue( fValue );
+ }
+
+ /** Writes a formula into a spreadsheet.
+ @param xSheet The XSpreadsheet interface of the spreadsheet.
+ @param aCellName The address of the cell (or a named range).
+ @param aFormula The formula to write into the cell. */
+ public void setFormula(
+ com.sun.star.sheet.XSpreadsheet xSheet,
+ String aCellName,
+ String aFormula ) throws RuntimeException, Exception
+ {
+ xSheet.getCellRangeByName( aCellName ).getCellByPosition( 0, 0 ).setFormula( aFormula );
+ }
+
+ /** Writes a date with standard date format into a spreadsheet.
+ @param xSheet The XSpreadsheet interface of the spreadsheet.
+ @param aCellName The address of the cell (or a named range).
+ @param nDay The day of the date.
+ @param nMonth The month of the date.
+ @param nYear The year of the date. */
+ public void setDate(
+ com.sun.star.sheet.XSpreadsheet xSheet,
+ String aCellName,
+ int nDay, int nMonth, int nYear ) throws RuntimeException, Exception
+ {
+ // Set the date value.
+ com.sun.star.table.XCell xCell = xSheet.getCellRangeByName( aCellName ).getCellByPosition( 0, 0 );
+ String aDateStr = nMonth + "/" + nDay + "/" + nYear;
+ xCell.setFormula( aDateStr );
+
+ // Set standard date format.
+ com.sun.star.util.XNumberFormatsSupplier xFormatsSupplier =
+ UnoRuntime.queryInterface(
+ com.sun.star.util.XNumberFormatsSupplier.class, getDocument() );
+ com.sun.star.util.XNumberFormatTypes xFormatTypes =
+ UnoRuntime.queryInterface(
+ com.sun.star.util.XNumberFormatTypes.class, xFormatsSupplier.getNumberFormats() );
+ int nFormat = xFormatTypes.getStandardFormat(
+ com.sun.star.util.NumberFormat.DATE, new com.sun.star.lang.Locale() );
+
+ com.sun.star.beans.XPropertySet xPropSet = UnoRuntime.queryInterface( com.sun.star.beans.XPropertySet.class, xCell );
+ xPropSet.setPropertyValue( "NumberFormat", Integer.valueOf( nFormat ) );
+ }
+
+ /** Draws a colored border around the range and writes the headline in the
+ first cell.
+ @param xSheet The XSpreadsheet interface of the spreadsheet.
+ @param aRange The address of the cell range (or a named range).
+ @param aHeadline The headline text. */
+ public void prepareRange(
+ com.sun.star.sheet.XSpreadsheet xSheet,
+ String aRange, String aHeadline ) throws RuntimeException, Exception
+ {
+ com.sun.star.beans.XPropertySet xPropSet = null;
+ com.sun.star.table.XCellRange xCellRange = null;
+
+ // draw border
+ xCellRange = xSheet.getCellRangeByName( aRange );
+ xPropSet = UnoRuntime.queryInterface( com.sun.star.beans.XPropertySet.class, xCellRange );
+ com.sun.star.table.BorderLine aLine = new com.sun.star.table.BorderLine();
+ aLine.Color = 0x99CCFF;
+ aLine.InnerLineWidth = aLine.LineDistance = 0;
+ aLine.OuterLineWidth = 100;
+ com.sun.star.table.TableBorder aBorder = new com.sun.star.table.TableBorder();
+ aBorder.TopLine = aBorder.BottomLine = aBorder.LeftLine = aBorder.RightLine = aLine;
+ aBorder.IsTopLineValid = aBorder.IsBottomLineValid = true;
+ aBorder.IsLeftLineValid = aBorder.IsRightLineValid = true;
+ xPropSet.setPropertyValue( "TableBorder", aBorder );
+
+ // draw headline
+ com.sun.star.sheet.XCellRangeAddressable xAddr = UnoRuntime.queryInterface( com.sun.star.sheet.XCellRangeAddressable.class, xCellRange );
+ com.sun.star.table.CellRangeAddress aAddr = xAddr.getRangeAddress();
+
+ xCellRange = xSheet.getCellRangeByPosition(
+ aAddr.StartColumn, aAddr.StartRow, aAddr.EndColumn, aAddr.StartRow );
+ xPropSet = UnoRuntime.queryInterface( com.sun.star.beans.XPropertySet.class, xCellRange );
+ xPropSet.setPropertyValue( "CellBackColor", Integer.valueOf( 0x99CCFF ) );
+ // write headline
+ com.sun.star.table.XCell xCell = xCellRange.getCellByPosition( 0, 0 );
+ xCell.setFormula( aHeadline );
+ xPropSet = UnoRuntime.queryInterface( com.sun.star.beans.XPropertySet.class, xCell );
+ xPropSet.setPropertyValue( "CharColor", Integer.valueOf( 0x003399 ) );
+ xPropSet.setPropertyValue( "CharWeight", new Float( com.sun.star.awt.FontWeight.BOLD ) );
+ }
+
+
+// Methods to create cell addresses and range addresses.
+
+ /** Creates a com.sun.star.table.CellAddress and initializes it
+ with the given range.
+ @param xSheet The XSpreadsheet interface of the spreadsheet.
+ @param aCell The address of the cell (or a named cell). */
+ public com.sun.star.table.CellAddress createCellAddress(
+ com.sun.star.sheet.XSpreadsheet xSheet,
+ String aCell ) throws RuntimeException, Exception
+ {
+ com.sun.star.sheet.XCellAddressable xAddr = UnoRuntime.queryInterface( com.sun.star.sheet.XCellAddressable.class,
+ xSheet.getCellRangeByName( aCell ).getCellByPosition( 0, 0 ) );
+ return xAddr.getCellAddress();
+ }
+
+ /** Creates a com.sun.star.table.CellRangeAddress and initializes
+ it with the given range.
+ @param xSheet The XSpreadsheet interface of the spreadsheet.
+ @param aRange The address of the cell range (or a named range). */
+ public com.sun.star.table.CellRangeAddress createCellRangeAddress(
+ com.sun.star.sheet.XSpreadsheet xSheet, String aRange )
+ {
+ com.sun.star.sheet.XCellRangeAddressable xAddr = UnoRuntime.queryInterface( com.sun.star.sheet.XCellRangeAddressable.class,
+ xSheet.getCellRangeByName( aRange ) );
+ return xAddr.getRangeAddress();
+ }
+
+
+// Methods to convert cell addresses and range addresses to strings.
+
+ /** Returns the text address of the cell.
+ @param nColumn The column index.
+ @param nRow The row index.
+ @return A string containing the cell address. */
+ public String getCellAddressString( int nColumn, int nRow )
+ {
+ String aStr = "";
+ if (nColumn > 25)
+ aStr += (char) ('A' + nColumn / 26 - 1);
+ aStr += (char) ('A' + nColumn % 26);
+ aStr += (nRow + 1);
+ return aStr;
+ }
+
+ /** Returns the text address of the cell range.
+ @param aCellRange The cell range address.
+ @return A string containing the cell range address. */
+ public String getCellRangeAddressString(
+ com.sun.star.table.CellRangeAddress aCellRange )
+ {
+ return
+ getCellAddressString( aCellRange.StartColumn, aCellRange.StartRow )
+ + ":"
+ + getCellAddressString( aCellRange.EndColumn, aCellRange.EndRow );
+ }
+
+ /** Returns the text address of the cell range.
+ @param xCellRange The XSheetCellRange interface of the cell range.
+ @param bWithSheet true = Include sheet name.
+ @return A string containing the cell range address. */
+ public String getCellRangeAddressString(
+ com.sun.star.sheet.XSheetCellRange xCellRange,
+ boolean bWithSheet )
+ {
+ String aStr = "";
+ if (bWithSheet)
+ {
+ com.sun.star.sheet.XSpreadsheet xSheet = xCellRange.getSpreadsheet();
+ com.sun.star.container.XNamed xNamed = UnoRuntime.queryInterface( com.sun.star.container.XNamed.class, xSheet );
+ aStr += xNamed.getName() + ".";
+ }
+ com.sun.star.sheet.XCellRangeAddressable xAddr = UnoRuntime.queryInterface( com.sun.star.sheet.XCellRangeAddressable.class, xCellRange );
+ aStr += getCellRangeAddressString( xAddr.getRangeAddress() );
+ return aStr;
+ }
+
+ /** Returns a list of addresses of all cell ranges contained in the collection.
+ @param xRangesIA The XIndexAccess interface of the collection.
+ @return A string containing the cell range address list. */
+ public String getCellRangeListString(
+ com.sun.star.container.XIndexAccess xRangesIA ) throws RuntimeException, Exception
+ {
+ String aStr = "";
+ int nCount = xRangesIA.getCount();
+ for (int nIndex = 0; nIndex < nCount; ++nIndex)
+ {
+ if (nIndex > 0)
+ aStr += " ";
+ Object aRangeObj = xRangesIA.getByIndex( nIndex );
+ com.sun.star.sheet.XSheetCellRange xCellRange = UnoRuntime.queryInterface( com.sun.star.sheet.XSheetCellRange.class, aRangeObj );
+ aStr += getCellRangeAddressString( xCellRange, false );
+ }
+ return aStr;
+ }
+
+
+
+ // Connect to a running office that is accepting connections.
+ private void connect()
+ {
+ if (mxRemoteContext == null && mxRemoteServiceManager == null) {
+ try {
+ // First step: get the remote office component context
+ mxRemoteContext = com.sun.star.comp.helper.Bootstrap.bootstrap();
+ System.out.println("Connected to a running office ...");
+
+ mxRemoteServiceManager = mxRemoteContext.getServiceManager();
+ }
+ catch( Exception e) {
+ System.err.println("ERROR: can't get a component context from a running office ...");
+ e.printStackTrace();
+ System.exit(1);
+ }
+ }
+ }
+
+ /** Creates an empty spreadsheet document.
+ @return The XSpreadsheetDocument interface of the document. */
+ private com.sun.star.sheet.XSpreadsheetDocument initDocument()
+ throws RuntimeException, Exception
+ {
+ XComponentLoader aLoader = UnoRuntime.queryInterface(
+ XComponentLoader.class,
+ mxRemoteServiceManager.createInstanceWithContext(
+ "com.sun.star.frame.Desktop", mxRemoteContext));
+
+ XComponent xComponent = aLoader.loadComponentFromURL(
+ "private:factory/scalc", "_blank", 0,
+ new com.sun.star.beans.PropertyValue[0] );
+
+ return UnoRuntime.queryInterface(
+ com.sun.star.sheet.XSpreadsheetDocument.class, xComponent );
+ }
+
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/Spreadsheet/SpreadsheetSample.java b/odk/examples/DevelopersGuide/Spreadsheet/SpreadsheetSample.java
new file mode 100644
index 000000000..ce6555528
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Spreadsheet/SpreadsheetSample.java
@@ -0,0 +1,1347 @@
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.RuntimeException;
+import com.sun.star.uno.AnyConverter;
+
+// __________ implementation ____________________________________
+
+/** Create and modify a spreadsheet document.
+ */
+public class SpreadsheetSample extends SpreadsheetDocHelper
+{
+
+
+
+ public static void main( String args[] )
+ {
+ try
+ {
+ SpreadsheetSample aSample = new SpreadsheetSample( args );
+ aSample.doSampleFunction();
+ }
+ catch (Exception ex)
+ {
+ System.out.println( "Error: Sample caught exception!\nException Message = "
+ + ex.getMessage());
+ ex.printStackTrace();
+ System.exit( 1 );
+ }
+ System.out.println( "\nSamples done." );
+ System.exit( 0 );
+ }
+
+
+
+ public SpreadsheetSample( String[] args )
+ {
+ super( args );
+ }
+
+
+
+ /** This sample function performs all changes on the document. */
+ public void doSampleFunction()
+ {
+ try
+ {
+ doCellSamples();
+ }
+ catch (Exception ex)
+ {
+ System.out.println( "\nError: Cell sample caught exception!\nException Message = "
+ + ex.getMessage());
+ ex.printStackTrace();
+ }
+
+ try
+ {
+ doCellRangeSamples();
+ }
+ catch (Exception ex)
+ {
+ System.out.println( "\nError: Cell range sample caught exception!\nException Message = "
+ + ex.getMessage());
+ ex.printStackTrace();
+ }
+
+ try
+ {
+ doCellRangesSamples();
+ }
+ catch (Exception ex)
+ {
+ System.out.println( "\nError: Cell range container sample caught exception!\nException Message = "
+ + ex.getMessage());
+ ex.printStackTrace();
+ }
+
+ try
+ {
+ doCellCursorSamples();
+ }
+ catch (Exception ex)
+ {
+ System.out.println( "\nError: Cell cursor sample caught exception!\nException Message = "
+ + ex.getMessage());
+ ex.printStackTrace();
+ }
+
+ try
+ {
+ doFormattingSamples();
+ }
+ catch (Exception ex)
+ {
+ System.out.println( "\nError: Formatting sample caught exception!\nException Message = "
+ + ex.getMessage());
+ ex.printStackTrace();
+ }
+
+ try
+ {
+ doDocumentSamples();
+ }
+ catch (Exception ex)
+ {
+ System.out.println( "\nError: Document sample caught exception!\nException Message = "
+ + ex.getMessage());
+ ex.printStackTrace();
+ }
+
+ try
+ {
+ doDatabaseSamples();
+ }
+ catch( Exception ex )
+ {
+ System.out.println( "\nError: Database sample caught exception!\nException Message = "
+ + ex.getMessage());
+ ex.printStackTrace();
+ }
+
+ try
+ {
+ doDataPilotSamples();
+ }
+ catch (Exception ex)
+ {
+ System.out.println( "\nError: Data pilot sample caught exception!\nException Message = "
+ + ex.getMessage());
+ ex.printStackTrace();
+ }
+
+ try
+ {
+ doNamedRangesSamples();
+ }
+ catch( Exception ex )
+ {
+ System.out.println( "\nError: Named ranges sample caught exception!\nException Message = "
+ + ex.getMessage());
+ ex.printStackTrace();
+ }
+
+ try
+ {
+ doFunctionAccessSamples();
+ }
+ catch (Exception ex)
+ {
+ System.out.println( "\nError: Function access sample caught exception!\nException Message = "
+ + ex.getMessage());
+ ex.printStackTrace();
+ }
+
+ try
+ {
+ doApplicationSettingsSamples();
+ }
+ catch (Exception ex)
+ {
+ System.out.println( "\nError: Application settings sample caught exception!\nException Message = "
+ + ex.getMessage());
+ ex.printStackTrace();
+ }
+ }
+
+
+
+ /** All samples regarding the service com.sun.star.sheet.SheetCell. */
+ private void doCellSamples() throws RuntimeException, Exception
+ {
+ System.out.println( "\n*** Samples for service sheet.SheetCell ***\n" );
+ com.sun.star.sheet.XSpreadsheet xSheet = getSpreadsheet( 0 );
+ com.sun.star.table.XCell xCell = null;
+ com.sun.star.beans.XPropertySet xPropSet = null;
+ String aText;
+ prepareRange( xSheet, "A1:C7", "Cells and Cell Ranges" );
+
+ // --- Get cell B3 by position - (column, row) ---
+ xCell = xSheet.getCellByPosition( 1, 2 );
+
+
+ // --- Insert two text paragraphs into the cell. ---
+ com.sun.star.text.XText xText = UnoRuntime.queryInterface( com.sun.star.text.XText.class, xCell );
+ com.sun.star.text.XTextCursor xTextCursor = xText.createTextCursor();
+
+ xText.insertString( xTextCursor, "Text in first line.", false );
+ xText.insertControlCharacter( xTextCursor,
+ com.sun.star.text.ControlCharacter.PARAGRAPH_BREAK, false );
+ xText.insertString( xTextCursor, "And a ", false );
+
+ // create a hyperlink
+ com.sun.star.lang.XMultiServiceFactory xServiceMan = UnoRuntime.queryInterface( com.sun.star.lang.XMultiServiceFactory.class, getDocument() );
+ Object aHyperlinkObj = xServiceMan.createInstance( "com.sun.star.text.TextField.URL" );
+ xPropSet = UnoRuntime.queryInterface( com.sun.star.beans.XPropertySet.class, aHyperlinkObj );
+ xPropSet.setPropertyValue( "URL", "http://www.example.org" );
+ xPropSet.setPropertyValue( "Representation", "hyperlink" );
+ // ... and insert
+ com.sun.star.text.XTextContent xContent = UnoRuntime.queryInterface( com.sun.star.text.XTextContent.class, aHyperlinkObj );
+ xText.insertTextContent( xTextCursor, xContent, false );
+
+
+ // --- Query the separate paragraphs. ---
+ com.sun.star.container.XEnumerationAccess xParaEA =
+ UnoRuntime.queryInterface(
+ com.sun.star.container.XEnumerationAccess.class, xCell );
+ com.sun.star.container.XEnumeration xParaEnum = xParaEA.createEnumeration();
+ // Go through the paragraphs
+ while( xParaEnum.hasMoreElements() )
+ {
+ Object aPortionObj = xParaEnum.nextElement();
+ com.sun.star.container.XEnumerationAccess xPortionEA =
+ UnoRuntime.queryInterface(
+ com.sun.star.container.XEnumerationAccess.class, aPortionObj );
+ com.sun.star.container.XEnumeration xPortionEnum = xPortionEA.createEnumeration();
+ aText = "";
+ // Go through all text portions of a paragraph and construct string.
+ while( xPortionEnum.hasMoreElements() )
+ {
+ com.sun.star.text.XTextRange xRange = UnoRuntime.queryInterface(com.sun.star.text.XTextRange.class,
+ xPortionEnum.nextElement());
+ aText += xRange.getString();
+ }
+ System.out.println( "Paragraph text: " + aText );
+ }
+
+
+ // --- Change cell properties. ---
+ xPropSet = UnoRuntime.queryInterface( com.sun.star.beans.XPropertySet.class, xCell );
+ // from styles.CharacterProperties
+ xPropSet.setPropertyValue( "CharColor", Integer.valueOf( 0x003399 ) );
+ xPropSet.setPropertyValue( "CharHeight", new Float( 20.0 ) );
+ // from styles.ParagraphProperties
+ xPropSet.setPropertyValue( "ParaLeftMargin", Integer.valueOf( 500 ) );
+ // from table.CellProperties
+ xPropSet.setPropertyValue( "IsCellBackgroundTransparent", Boolean.FALSE );
+ xPropSet.setPropertyValue( "CellBackColor", Integer.valueOf( 0x99CCFF ) );
+
+
+ // --- Get cell address. ---
+ com.sun.star.sheet.XCellAddressable xCellAddr = UnoRuntime.queryInterface( com.sun.star.sheet.XCellAddressable.class, xCell );
+ com.sun.star.table.CellAddress aAddress = xCellAddr.getCellAddress();
+ aText = "Address of this cell: Column=" + aAddress.Column;
+ aText += "; Row=" + aAddress.Row;
+ aText += "; Sheet=" + aAddress.Sheet;
+ System.out.println( aText );
+
+
+ // --- Insert an annotation ---
+ com.sun.star.sheet.XSheetAnnotationsSupplier xAnnotationsSupp =
+ UnoRuntime.queryInterface(
+ com.sun.star.sheet.XSheetAnnotationsSupplier.class, xSheet );
+ com.sun.star.sheet.XSheetAnnotations xAnnotations = xAnnotationsSupp.getAnnotations();
+ xAnnotations.insertNew( aAddress, "This is an annotation" );
+
+ com.sun.star.sheet.XSheetAnnotationAnchor xAnnotAnchor = UnoRuntime.queryInterface( com.sun.star.sheet.XSheetAnnotationAnchor.class, xCell );
+ com.sun.star.sheet.XSheetAnnotation xAnnotation = xAnnotAnchor.getAnnotation();
+ xAnnotation.setIsVisible( true );
+ }
+
+
+
+ /** All samples regarding the service com.sun.star.sheet.SheetCellRange. */
+ private void doCellRangeSamples() throws RuntimeException, Exception
+ {
+ System.out.println( "\n*** Samples for service sheet.SheetCellRange ***\n" );
+ com.sun.star.sheet.XSpreadsheet xSheet = getSpreadsheet( 0 );
+ com.sun.star.table.XCellRange xCellRange = null;
+ com.sun.star.beans.XPropertySet xPropSet = null;
+ com.sun.star.table.CellRangeAddress aRangeAddress = null;
+
+ // Preparation
+ setFormula( xSheet, "B5", "First cell" );
+ setFormula( xSheet, "B6", "Second cell" );
+ // Get cell range B5:B6 by position - (column, row, column, row)
+ xCellRange = xSheet.getCellRangeByPosition( 1, 4, 1, 5 );
+
+
+ // --- Change cell range properties. ---
+ xPropSet = UnoRuntime.queryInterface( com.sun.star.beans.XPropertySet.class, xCellRange );
+ // from com.sun.star.styles.CharacterProperties
+ xPropSet.setPropertyValue( "CharColor", Integer.valueOf( 0x003399 ) );
+ xPropSet.setPropertyValue( "CharHeight", new Float( 20.0 ) );
+ // from com.sun.star.styles.ParagraphProperties
+ xPropSet.setPropertyValue( "ParaLeftMargin", Integer.valueOf( 500 ) );
+ // from com.sun.star.table.CellProperties
+ xPropSet.setPropertyValue( "IsCellBackgroundTransparent", Boolean.FALSE );
+ xPropSet.setPropertyValue( "CellBackColor", Integer.valueOf( 0x99CCFF ) );
+
+
+ // --- Replace text in all cells. ---
+ com.sun.star.util.XReplaceable xReplace = UnoRuntime.queryInterface( com.sun.star.util.XReplaceable.class, xCellRange );
+ com.sun.star.util.XReplaceDescriptor xReplaceDesc = xReplace.createReplaceDescriptor();
+ xReplaceDesc.setSearchString( "cell" );
+ xReplaceDesc.setReplaceString( "text" );
+ // property SearchWords searches for whole cells!
+ xReplaceDesc.setPropertyValue( "SearchWords", Boolean.FALSE );
+ int nCount = xReplace.replaceAll( xReplaceDesc );
+ System.out.println( "Search text replaced " + nCount + " times." );
+
+
+ // --- Merge cells. ---
+ xCellRange = xSheet.getCellRangeByName( "F3:G6" );
+ prepareRange( xSheet, "E1:H7", "XMergeable" );
+ com.sun.star.util.XMergeable xMerge = UnoRuntime.queryInterface( com.sun.star.util.XMergeable.class, xCellRange );
+ xMerge.merge( true );
+
+
+ // --- Change indentation. ---
+/* does not work (bug in XIndent implementation)
+ prepareRange( xSheet, "I20:I23", "XIndent" );
+ setValue( xSheet, "I21", 1 );
+ setValue( xSheet, "I22", 1 );
+ setValue( xSheet, "I23", 1 );
+
+ xCellRange = xSheet.getCellRangeByName( "I21:I22" );
+ com.sun.star.util.XIndent xIndent = (com.sun.star.util.XIndent)
+ UnoRuntime.queryInterface( com.sun.star.util.XIndent.class, xCellRange );
+ xIndent.incrementIndent();
+
+ xCellRange = xSheet.getCellRangeByName( "I22:I23" );
+ xIndent = (com.sun.star.util.XIndent)
+ UnoRuntime.queryInterface( com.sun.star.util.XIndent.class, xCellRange );
+ xIndent.incrementIndent();
+*/
+
+
+ // --- Column properties. ---
+ xCellRange = xSheet.getCellRangeByName( "B1" );
+ com.sun.star.table.XColumnRowRange xColRowRange = UnoRuntime.queryInterface( com.sun.star.table.XColumnRowRange.class, xCellRange );
+ com.sun.star.table.XTableColumns xColumns = xColRowRange.getColumns();
+
+ Object aColumnObj = xColumns.getByIndex( 0 );
+ xPropSet = UnoRuntime.queryInterface(
+ com.sun.star.beans.XPropertySet.class, aColumnObj );
+ xPropSet.setPropertyValue( "Width", Integer.valueOf( 6000 ) );
+
+ com.sun.star.container.XNamed xNamed = UnoRuntime.queryInterface( com.sun.star.container.XNamed.class, aColumnObj );
+ System.out.println( "The name of the wide column is " + xNamed.getName() + "." );
+
+
+ // --- Cell range data ---
+ prepareRange( xSheet, "A9:C30", "XCellRangeData" );
+
+ xCellRange = xSheet.getCellRangeByName( "A10:C30" );
+ com.sun.star.sheet.XCellRangeData xData = UnoRuntime.queryInterface( com.sun.star.sheet.XCellRangeData.class, xCellRange );
+ Object[][] aValues =
+ {
+ { "Name", "Fruit", "Quantity" },
+ { "Alice", "Apples", new Double( 3.0 ) },
+ { "Alice", "Oranges", new Double( 7.0 ) },
+ { "Bob", "Apples", new Double( 3.0 ) },
+ { "Alice", "Apples", new Double( 9.0 ) },
+ { "Bob", "Apples", new Double( 5.0 ) },
+ { "Bob", "Oranges", new Double( 6.0 ) },
+ { "Alice", "Oranges", new Double( 3.0 ) },
+ { "Alice", "Apples", new Double( 8.0 ) },
+ { "Alice", "Oranges", new Double( 1.0 ) },
+ { "Bob", "Oranges", new Double( 2.0 ) },
+ { "Bob", "Oranges", new Double( 7.0 ) },
+ { "Bob", "Apples", new Double( 1.0 ) },
+ { "Alice", "Apples", new Double( 8.0 ) },
+ { "Alice", "Oranges", new Double( 8.0 ) },
+ { "Alice", "Apples", new Double( 7.0 ) },
+ { "Bob", "Apples", new Double( 1.0 ) },
+ { "Bob", "Oranges", new Double( 9.0 ) },
+ { "Bob", "Oranges", new Double( 3.0 ) },
+ { "Alice", "Oranges", new Double( 4.0 ) },
+ { "Alice", "Apples", new Double( 9.0 ) }
+ };
+ xData.setDataArray( aValues );
+
+
+ // --- Get cell range address. ---
+ com.sun.star.sheet.XCellRangeAddressable xRangeAddr = UnoRuntime.queryInterface( com.sun.star.sheet.XCellRangeAddressable.class, xCellRange );
+ aRangeAddress = xRangeAddr.getRangeAddress();
+ System.out.println( "Address of this range: Sheet=" + aRangeAddress.Sheet );
+ System.out.println( "Start column=" + aRangeAddress.StartColumn + "; Start row=" + aRangeAddress.StartRow );
+ System.out.println( "End column =" + aRangeAddress.EndColumn + "; End row =" + aRangeAddress.EndRow );
+
+
+ // --- Sheet operation. ---
+ // uses the range filled with XCellRangeData
+ com.sun.star.sheet.XSheetOperation xSheetOp = UnoRuntime.queryInterface( com.sun.star.sheet.XSheetOperation.class, xData );
+ double fResult = xSheetOp.computeFunction( com.sun.star.sheet.GeneralFunction.AVERAGE );
+ System.out.println( "Average value of the data table A10:C30: " + fResult );
+
+
+ // --- Fill series ---
+ // Prepare the example
+ setValue( xSheet, "E10", 1 );
+ setValue( xSheet, "E11", 4 );
+ setDate( xSheet, "E12", 30, 1, 2002 );
+ setFormula( xSheet, "I13", "Text 10" );
+ setFormula( xSheet, "E14", "Jan" );
+ setValue( xSheet, "K14", 10 );
+ setValue( xSheet, "E16", 1 );
+ setValue( xSheet, "F16", 2 );
+ setDate( xSheet, "E17", 28, 2, 2002 );
+ setDate( xSheet, "F17", 28, 1, 2002 );
+ setValue( xSheet, "E18", 6 );
+ setValue( xSheet, "F18", 4 );
+
+ com.sun.star.sheet.XCellSeries xSeries = null;
+ // Fill 2 rows linear with end value -> 2nd series is not filled completely
+ xSeries = getCellSeries( xSheet, "E10:I11" );
+ xSeries.fillSeries( com.sun.star.sheet.FillDirection.TO_RIGHT, com.sun.star.sheet.FillMode.LINEAR,
+ com.sun.star.sheet.FillDateMode.FILL_DATE_DAY, 2, 9 );
+ // Add months to a date
+ xSeries = getCellSeries( xSheet, "E12:I12" );
+ xSeries.fillSeries( com.sun.star.sheet.FillDirection.TO_RIGHT, com.sun.star.sheet.FillMode.DATE,
+ com.sun.star.sheet.FillDateMode.FILL_DATE_MONTH, 1, 0x7FFFFFFF );
+ // Fill right to left with a text containing a value
+ xSeries = getCellSeries( xSheet, "E13:I13" );
+ xSeries.fillSeries( com.sun.star.sheet.FillDirection.TO_LEFT, com.sun.star.sheet.FillMode.LINEAR,
+ com.sun.star.sheet.FillDateMode.FILL_DATE_DAY, 10, 0x7FFFFFFF );
+ // Fill with an user defined list
+ xSeries = getCellSeries( xSheet, "E14:I14" );
+ xSeries.fillSeries( com.sun.star.sheet.FillDirection.TO_RIGHT, com.sun.star.sheet.FillMode.AUTO,
+ com.sun.star.sheet.FillDateMode.FILL_DATE_DAY, 1, 0x7FFFFFFF );
+ // Fill bottom to top with a geometric series
+ xSeries = getCellSeries( xSheet, "K10:K14" );
+ xSeries.fillSeries( com.sun.star.sheet.FillDirection.TO_TOP, com.sun.star.sheet.FillMode.GROWTH,
+ com.sun.star.sheet.FillDateMode.FILL_DATE_DAY, 2, 0x7FFFFFFF );
+ // Auto fill
+ xSeries = getCellSeries( xSheet, "E16:K18" );
+ xSeries.fillAuto( com.sun.star.sheet.FillDirection.TO_RIGHT, 2 );
+ // Fill series copies cell formats -> draw border here
+ prepareRange( xSheet, "E9:K18", "XCellSeries" );
+
+
+ // --- Array formulas ---
+ xCellRange = xSheet.getCellRangeByName( "E21:G23" );
+ prepareRange( xSheet, "E20:G23", "XArrayFormulaRange" );
+ com.sun.star.sheet.XArrayFormulaRange xArrayFormula = UnoRuntime.queryInterface( com.sun.star.sheet.XArrayFormulaRange.class, xCellRange );
+ // Insert a 3x3 unit matrix.
+ xArrayFormula.setArrayFormula( "=A10:C12" );
+ System.out.println( "Array formula is: " + xArrayFormula.getArrayFormula() );
+
+
+ // --- Multiple operations ---
+ setFormula( xSheet, "E26", "=E27^F26" );
+ setValue( xSheet, "E27", 1 );
+ setValue( xSheet, "F26", 1 );
+ getCellSeries( xSheet, "E27:E31" ).fillAuto( com.sun.star.sheet.FillDirection.TO_BOTTOM, 1 );
+ getCellSeries( xSheet, "F26:J26" ).fillAuto( com.sun.star.sheet.FillDirection.TO_RIGHT, 1 );
+ setFormula( xSheet, "F33", "=SIN(E33)" );
+ setFormula( xSheet, "G33", "=COS(E33)" );
+ setFormula( xSheet, "H33", "=TAN(E33)" );
+ setValue( xSheet, "E34", 0 );
+ setValue( xSheet, "E35", 0.2 );
+ getCellSeries( xSheet, "E34:E38" ).fillAuto( com.sun.star.sheet.FillDirection.TO_BOTTOM, 2 );
+ prepareRange( xSheet, "E25:J38", "XMultipleOperation" );
+
+ com.sun.star.table.CellRangeAddress aFormulaRange = createCellRangeAddress( xSheet, "E26" );
+ com.sun.star.table.CellAddress aColCell = createCellAddress( xSheet, "E27" );
+ com.sun.star.table.CellAddress aRowCell = createCellAddress( xSheet, "F26" );
+
+ xCellRange = xSheet.getCellRangeByName( "E26:J31" );
+ com.sun.star.sheet.XMultipleOperation xMultOp = UnoRuntime.queryInterface( com.sun.star.sheet.XMultipleOperation.class, xCellRange );
+ xMultOp.setTableOperation(
+ aFormulaRange, com.sun.star.sheet.TableOperationMode.BOTH, aColCell, aRowCell );
+
+ aFormulaRange = createCellRangeAddress( xSheet, "F33:H33" );
+ aColCell = createCellAddress( xSheet, "E33" );
+ // Row cell not needed
+
+ xCellRange = xSheet.getCellRangeByName( "E34:H38" );
+ xMultOp = UnoRuntime.queryInterface( com.sun.star.sheet.XMultipleOperation.class, xCellRange );
+ xMultOp.setTableOperation(
+ aFormulaRange, com.sun.star.sheet.TableOperationMode.COLUMN, aColCell, aRowCell );
+
+
+ // --- Cell Ranges Query ---
+ xCellRange = xSheet.getCellRangeByName( "A10:C30" );
+ com.sun.star.sheet.XCellRangesQuery xRangesQuery = UnoRuntime.queryInterface( com.sun.star.sheet.XCellRangesQuery.class, xCellRange );
+ com.sun.star.sheet.XSheetCellRanges xCellRanges =
+ xRangesQuery.queryContentCells( (short)com.sun.star.sheet.CellFlags.STRING );
+ System.out.println(
+ "Cells in A10:C30 containing text: "
+ + xCellRanges.getRangeAddressesAsString() );
+ }
+
+ /** Returns the XCellSeries interface of a cell range.
+ @param xSheet The spreadsheet containing the cell range.
+ @param aRange The address of the cell range.
+ @return The XCellSeries interface. */
+ private com.sun.star.sheet.XCellSeries getCellSeries(
+ com.sun.star.sheet.XSpreadsheet xSheet, String aRange )
+ {
+ return UnoRuntime.queryInterface(
+ com.sun.star.sheet.XCellSeries.class, xSheet.getCellRangeByName( aRange ) );
+ }
+
+
+
+ /** All samples regarding cell range collections. */
+ private void doCellRangesSamples() throws RuntimeException, Exception
+ {
+ System.out.println( "\n*** Samples for cell range collections ***\n" );
+
+ // Create a new cell range container
+ com.sun.star.lang.XMultiServiceFactory xDocFactory =
+ UnoRuntime.queryInterface(
+ com.sun.star.lang.XMultiServiceFactory.class, getDocument() );
+ com.sun.star.sheet.XSheetCellRangeContainer xRangeCont =
+ UnoRuntime.queryInterface(
+ com.sun.star.sheet.XSheetCellRangeContainer.class,
+ xDocFactory.createInstance( "com.sun.star.sheet.SheetCellRanges" ) );
+
+
+ // --- Insert ranges ---
+ insertRange( xRangeCont, 0, 0, 0, 0, 0, false ); // A1:A1
+ insertRange( xRangeCont, 0, 0, 1, 0, 2, true ); // A2:A3
+ insertRange( xRangeCont, 0, 1, 0, 1, 2, false ); // B1:B3
+
+
+ // --- Query the list of filled cells ---
+ System.out.print( "All filled cells: " );
+ com.sun.star.container.XEnumerationAccess xCellsEA = xRangeCont.getCells();
+ com.sun.star.container.XEnumeration xEnum = xCellsEA.createEnumeration();
+ while( xEnum.hasMoreElements() )
+ {
+ Object aCellObj = xEnum.nextElement();
+ com.sun.star.sheet.XCellAddressable xAddr = UnoRuntime.queryInterface( com.sun.star.sheet.XCellAddressable.class, aCellObj );
+ com.sun.star.table.CellAddress aAddr = xAddr.getCellAddress();
+ System.out.print( getCellAddressString( aAddr.Column, aAddr.Row ) + " " );
+ }
+ System.out.println();
+ }
+
+ /** Inserts a cell range address into a cell range container and prints
+ a message.
+ @param xContainer The com.sun.star.sheet.XSheetCellRangeContainer interface of the container.
+ @param nSheet Index of sheet of the range.
+ @param nStartCol Index of first column of the range.
+ @param nStartRow Index of first row of the range.
+ @param nEndCol Index of last column of the range.
+ @param nEndRow Index of last row of the range.
+ @param bMerge Determines whether the new range should be merged with the existing ranges. */
+ private void insertRange(
+ com.sun.star.sheet.XSheetCellRangeContainer xContainer,
+ int nSheet, int nStartCol, int nStartRow, int nEndCol, int nEndRow,
+ boolean bMerge ) throws RuntimeException, Exception
+ {
+ com.sun.star.table.CellRangeAddress aAddress = new com.sun.star.table.CellRangeAddress();
+ aAddress.Sheet = (short)nSheet;
+ aAddress.StartColumn = nStartCol;
+ aAddress.StartRow = nStartRow;
+ aAddress.EndColumn = nEndCol;
+ aAddress.EndRow = nEndRow;
+ xContainer.addRangeAddress( aAddress, bMerge );
+ System.out.println(
+ "Inserting " + getCellRangeAddressString( aAddress )
+ + " " + (bMerge ? " with" : "without") + " merge,"
+ + " resulting list: " + xContainer.getRangeAddressesAsString() );
+ }
+
+
+
+ /** All samples regarding cell cursors. */
+ private void doCellCursorSamples() throws RuntimeException, Exception
+ {
+ System.out.println( "\n*** Samples for cell cursor ***\n" );
+ com.sun.star.sheet.XSpreadsheet xSheet = getSpreadsheet( 0 );
+
+
+ // --- Find the array formula using a cell cursor ---
+ com.sun.star.table.XCellRange xRange = xSheet.getCellRangeByName( "F22" );
+ com.sun.star.sheet.XSheetCellRange xCellRange = UnoRuntime.queryInterface( com.sun.star.sheet.XSheetCellRange.class, xRange );
+ com.sun.star.sheet.XSheetCellCursor xCursor = xSheet.createCursorByRange( xCellRange );
+
+ xCursor.collapseToCurrentArray();
+ com.sun.star.sheet.XArrayFormulaRange xArray = UnoRuntime.queryInterface( com.sun.star.sheet.XArrayFormulaRange.class, xCursor );
+ System.out.println(
+ "Array formula in " + getCellRangeAddressString( xCursor, false )
+ + " contains formula " + xArray.getArrayFormula() );
+
+
+ // --- Find the used area ---
+ com.sun.star.sheet.XUsedAreaCursor xUsedCursor = UnoRuntime.queryInterface( com.sun.star.sheet.XUsedAreaCursor.class, xCursor );
+ xUsedCursor.gotoStartOfUsedArea( false );
+ xUsedCursor.gotoEndOfUsedArea( true );
+ // xUsedCursor and xCursor are interfaces of the same object -
+ // so modifying xUsedCursor takes effect on xCursor:
+ System.out.println( "The used area is: " + getCellRangeAddressString( xCursor, true ) );
+ }
+
+
+
+ /** All samples regarding the formatting of cells and ranges. */
+ private void doFormattingSamples() throws RuntimeException, Exception
+ {
+ System.out.println( "\n*** Formatting samples ***\n" );
+ com.sun.star.sheet.XSpreadsheet xSheet = getSpreadsheet( 1 );
+ com.sun.star.table.XCellRange xCellRange;
+ com.sun.star.beans.XPropertySet xPropSet = null;
+ com.sun.star.container.XIndexAccess xRangeIA = null;
+ com.sun.star.lang.XMultiServiceFactory xDocServiceManager;
+
+
+ // --- Cell styles ---
+ // get the cell style container
+ com.sun.star.style.XStyleFamiliesSupplier xFamiliesSupplier = UnoRuntime.queryInterface( com.sun.star.style.XStyleFamiliesSupplier.class, getDocument() );
+ com.sun.star.container.XNameAccess xFamiliesNA = xFamiliesSupplier.getStyleFamilies();
+ Object aCellStylesObj = xFamiliesNA.getByName( "CellStyles" );
+ com.sun.star.container.XNameContainer xCellStylesNA = UnoRuntime.queryInterface( com.sun.star.container.XNameContainer.class, aCellStylesObj );
+
+ // create a new cell style
+ xDocServiceManager = UnoRuntime.queryInterface( com.sun.star.lang.XMultiServiceFactory.class, getDocument() );
+ Object aCellStyle = xDocServiceManager.createInstance( "com.sun.star.style.CellStyle" );
+ String aStyleName = "MyNewCellStyle";
+ xCellStylesNA.insertByName( aStyleName, aCellStyle );
+
+ // modify properties of the new style
+ xPropSet = UnoRuntime.queryInterface( com.sun.star.beans.XPropertySet.class, aCellStyle );
+ xPropSet.setPropertyValue( "CellBackColor", Integer.valueOf( 0x888888 ) );
+ xPropSet.setPropertyValue( "IsCellBackgroundTransparent", Boolean.FALSE );
+
+
+
+ // --- Query equal-formatted cell ranges ---
+ // prepare example, use the new cell style
+ xCellRange = xSheet.getCellRangeByName( "D2:F2" );
+ xPropSet = UnoRuntime.queryInterface(
+ com.sun.star.beans.XPropertySet.class, xCellRange );
+ xPropSet.setPropertyValue( "CellStyle", aStyleName );
+
+ xCellRange = xSheet.getCellRangeByName( "A3:G3" );
+ xPropSet = UnoRuntime.queryInterface(
+ com.sun.star.beans.XPropertySet.class, xCellRange );
+ xPropSet.setPropertyValue( "CellStyle", aStyleName );
+
+ // All ranges in one container
+ xCellRange = xSheet.getCellRangeByName( "A1:G3" );
+ System.out.println( "Service CellFormatRanges:" );
+ com.sun.star.sheet.XCellFormatRangesSupplier xFormatSupp =
+ UnoRuntime.queryInterface(
+ com.sun.star.sheet.XCellFormatRangesSupplier.class, xCellRange );
+ xRangeIA = xFormatSupp.getCellFormatRanges();
+ System.out.println( getCellRangeListString( xRangeIA ) );
+
+ // Ranges sorted in SheetCellRanges containers
+ System.out.println( "\nService UniqueCellFormatRanges:" );
+ com.sun.star.sheet.XUniqueCellFormatRangesSupplier xUniqueFormatSupp =
+ UnoRuntime.queryInterface(
+ com.sun.star.sheet.XUniqueCellFormatRangesSupplier.class, xCellRange );
+ com.sun.star.container.XIndexAccess xRangesIA = xUniqueFormatSupp.getUniqueCellFormatRanges();
+ int nCount = xRangesIA.getCount();
+ for (int nIndex = 0; nIndex < nCount; ++nIndex)
+ {
+ Object aRangesObj = xRangesIA.getByIndex( nIndex );
+ xRangeIA = UnoRuntime.queryInterface(
+ com.sun.star.container.XIndexAccess.class, aRangesObj );
+ System.out.println(
+ "Container " + (nIndex + 1) + ": " + getCellRangeListString( xRangeIA ) );
+ }
+
+
+ // --- Table auto formats ---
+ // get the global collection of table auto formats, use global service
+ // manager
+ com.sun.star.lang.XMultiComponentFactory xServiceManager = getServiceManager();
+
+ Object aAutoFormatsObj = xServiceManager.createInstanceWithContext(
+ "com.sun.star.sheet.TableAutoFormats", getContext());
+ com.sun.star.container.XNameContainer xAutoFormatsNA =
+ UnoRuntime.queryInterface(
+ com.sun.star.container.XNameContainer.class, aAutoFormatsObj );
+
+ // create a new table auto format and insert into the container
+ String aAutoFormatName = "Temp_Example";
+ boolean bExistsAlready = xAutoFormatsNA.hasByName( aAutoFormatName );
+ Object aAutoFormatObj = null;
+ if (bExistsAlready)
+ // auto format already exists -> use it
+ aAutoFormatObj = xAutoFormatsNA.getByName( aAutoFormatName );
+ else
+ {
+ aAutoFormatObj = xDocServiceManager.createInstance(
+ "com.sun.star.sheet.TableAutoFormat" );
+ xAutoFormatsNA.insertByName( aAutoFormatName, aAutoFormatObj );
+ }
+ // index access to the auto format fields
+ com.sun.star.container.XIndexAccess xAutoFormatIA =
+ UnoRuntime.queryInterface(
+ com.sun.star.container.XIndexAccess.class, aAutoFormatObj );
+
+ // set properties of all auto format fields
+ for (int nRow = 0; nRow < 4; ++nRow)
+ {
+ int nRowColor = 0;
+ switch (nRow)
+ {
+ case 0: nRowColor = 0x999999; break;
+ case 1: nRowColor = 0xFFFFCC; break;
+ case 2: nRowColor = 0xEEEEEE; break;
+ case 3: nRowColor = 0x999999; break;
+ }
+
+ for (int nColumn = 0; nColumn < 4; ++nColumn)
+ {
+ int nColor = nRowColor;
+ if ((nColumn == 0) || (nColumn == 3))
+ nColor -= 0x333300;
+
+ // get the auto format field and apply properties
+ Object aFieldObj = xAutoFormatIA.getByIndex( 4 * nRow + nColumn );
+ xPropSet = UnoRuntime.queryInterface(
+ com.sun.star.beans.XPropertySet.class, aFieldObj );
+ xPropSet.setPropertyValue( "CellBackColor", Integer.valueOf( nColor ) );
+ }
+ }
+
+ // set the auto format to the spreadsheet
+ xCellRange = xSheet.getCellRangeByName( "A5:H25" );
+ com.sun.star.table.XAutoFormattable xAutoForm = UnoRuntime.queryInterface( com.sun.star.table.XAutoFormattable.class, xCellRange );
+ xAutoForm.autoFormat( aAutoFormatName );
+
+ // remove the auto format
+ if (!bExistsAlready)
+ xAutoFormatsNA.removeByName( aAutoFormatName );
+
+
+ // --- Conditional formats ---
+ xSheet = getSpreadsheet( 0 );
+ prepareRange( xSheet, "K20:K23", "Cond. Format" );
+ setValue( xSheet, "K21", 1 );
+ setValue( xSheet, "K22", 2 );
+ setValue( xSheet, "K23", 3 );
+
+ // get the conditional format object of the cell range
+ xCellRange = xSheet.getCellRangeByName( "K21:K23" );
+ xPropSet = UnoRuntime.queryInterface( com.sun.star.beans.XPropertySet.class, xCellRange );
+ com.sun.star.sheet.XSheetConditionalEntries xEntries =
+ UnoRuntime.queryInterface(
+ com.sun.star.sheet.XSheetConditionalEntries.class,
+ xPropSet.getPropertyValue( "ConditionalFormat" ));
+
+ // create a condition and apply it to the range
+ com.sun.star.beans.PropertyValue[] aCondition = new com.sun.star.beans.PropertyValue[3];
+ aCondition[0] = new com.sun.star.beans.PropertyValue();
+ aCondition[0].Name = "Operator";
+ aCondition[0].Value = com.sun.star.sheet.ConditionOperator.GREATER;
+ aCondition[1] = new com.sun.star.beans.PropertyValue();
+ aCondition[1].Name = "Formula1";
+ aCondition[1].Value = "1";
+ aCondition[2] = new com.sun.star.beans.PropertyValue();
+ aCondition[2].Name = "StyleName";
+ aCondition[2].Value = aStyleName;
+ xEntries.addNew( aCondition );
+ xPropSet.setPropertyValue( "ConditionalFormat", xEntries );
+ }
+
+
+
+ /** All samples regarding the spreadsheet document. */
+ private void doDocumentSamples() throws RuntimeException, Exception
+ {
+ System.out.println( "\n*** Samples for spreadsheet document ***\n" );
+
+
+ // --- Insert a new spreadsheet ---
+ com.sun.star.sheet.XSpreadsheet xSheet = insertSpreadsheet( "A new sheet", (short)0x7FFF );
+
+
+ // --- Copy a cell range ---
+ prepareRange( xSheet, "A1:B3", "Copy from" );
+ prepareRange( xSheet, "D1:E3", "To" );
+ setValue( xSheet, "A2", 123 );
+ setValue( xSheet, "B2", 345 );
+ setFormula( xSheet, "A3", "=SUM(A2:B2)" );
+ setFormula( xSheet, "B3", "=FORMULA(A3)" );
+
+ com.sun.star.sheet.XCellRangeMovement xMovement = UnoRuntime.queryInterface( com.sun.star.sheet.XCellRangeMovement.class, xSheet );
+ com.sun.star.table.CellRangeAddress aSourceRange = createCellRangeAddress( xSheet, "A2:B3" );
+ com.sun.star.table.CellAddress aDestCell = createCellAddress( xSheet, "D2" );
+ xMovement.copyRange( aDestCell, aSourceRange );
+
+
+ // --- Print automatic column page breaks ---
+ com.sun.star.sheet.XSheetPageBreak xPageBreak = UnoRuntime.queryInterface( com.sun.star.sheet.XSheetPageBreak.class, xSheet );
+ com.sun.star.sheet.TablePageBreakData[] aPageBreakArray = xPageBreak.getColumnPageBreaks();
+
+ System.out.print( "Automatic column page breaks:" );
+ for (int nIndex = 0; nIndex < aPageBreakArray.length; ++nIndex)
+ if (!aPageBreakArray[nIndex].ManualBreak)
+ System.out.print( " " + aPageBreakArray[nIndex].Position );
+ System.out.println();
+
+
+ // --- Document properties ---
+ com.sun.star.beans.XPropertySet xPropSet = UnoRuntime.queryInterface( com.sun.star.beans.XPropertySet.class, getDocument() );
+
+ String aText = "Value of property IsIterationEnabled: ";
+ aText += AnyConverter.toBoolean(xPropSet.getPropertyValue( "IsIterationEnabled" ));
+ System.out.println( aText );
+ aText = "Value of property IterationCount: ";
+ aText += AnyConverter.toInt(xPropSet.getPropertyValue( "IterationCount" ));
+ System.out.println( aText );
+ aText = "Value of property NullDate: ";
+ com.sun.star.util.Date aDate = (com.sun.star.util.Date)
+ AnyConverter.toObject(com.sun.star.util.Date.class, xPropSet.getPropertyValue( "NullDate" ));
+ aText += aDate.Year + "-" + aDate.Month + "-" + aDate.Day;
+ System.out.println( aText );
+
+
+ // --- Data validation ---
+ prepareRange( xSheet, "A5:C7", "Validation" );
+ setFormula( xSheet, "A6", "Insert values between 0.0 and 5.0 below:" );
+
+ com.sun.star.table.XCellRange xCellRange = xSheet.getCellRangeByName( "A7:C7" );
+ com.sun.star.beans.XPropertySet xCellPropSet = UnoRuntime.queryInterface( com.sun.star.beans.XPropertySet.class, xCellRange );
+ // validation properties
+ com.sun.star.beans.XPropertySet xValidPropSet = UnoRuntime.queryInterface(com.sun.star.beans.XPropertySet.class,
+ xCellPropSet.getPropertyValue( "Validation" ));
+ xValidPropSet.setPropertyValue( "Type", com.sun.star.sheet.ValidationType.DECIMAL );
+ xValidPropSet.setPropertyValue( "ShowErrorMessage", Boolean.TRUE );
+ xValidPropSet.setPropertyValue( "ErrorMessage", "This is an invalid value!" );
+ xValidPropSet.setPropertyValue( "ErrorAlertStyle", com.sun.star.sheet.ValidationAlertStyle.STOP );
+ // condition
+ com.sun.star.sheet.XSheetCondition xCondition = UnoRuntime.queryInterface( com.sun.star.sheet.XSheetCondition.class, xValidPropSet );
+ xCondition.setOperator( com.sun.star.sheet.ConditionOperator.BETWEEN );
+ xCondition.setFormula1( "0.0" );
+ xCondition.setFormula2( "5.0" );
+ // apply on cell range
+ xCellPropSet.setPropertyValue( "Validation", xValidPropSet );
+
+ // --- Scenarios ---
+ Object[][] aValues = new Object[2][2];
+
+ aValues[0][0] = new Double( 11 );
+ aValues[0][1] = new Double( 12 );
+ aValues[1][0] = "Test13";
+ aValues[1][1] = "Test14";
+ insertScenario( xSheet, "B10:C11", aValues, "First Scenario", "The first scenario." );
+
+ aValues[0][0] = "Test21";
+ aValues[0][1] = "Test22";
+ aValues[1][0] = new Double( 23 );
+ aValues[1][1] = new Double( 24 );
+ insertScenario( xSheet, "B10:C11", aValues, "Second Scenario", "The visible scenario." );
+
+ aValues[0][0] = new Double( 31 );
+ aValues[0][1] = new Double( 32 );
+ aValues[1][0] = "Test33";
+ aValues[1][1] = "Test34";
+ insertScenario( xSheet, "B10:C11", aValues, "Third Scenario", "The last scenario." );
+
+ // show second scenario
+ showScenario( xSheet, "Second Scenario" );
+ }
+
+ /** Inserts a scenario containing one cell range into a sheet and
+ applies the value array.
+ @param xSheet The XSpreadsheet interface of the spreadsheet.
+ @param aRange The range address for the scenario.
+ @param aValueArray The array of cell contents.
+ @param aScenarioName The name of the new scenario.
+ @param aScenarioComment The user comment for the scenario. */
+ private void insertScenario(
+ com.sun.star.sheet.XSpreadsheet xSheet,
+ String aRange,
+ Object[][] aValueArray,
+ String aScenarioName,
+ String aScenarioComment ) throws RuntimeException, Exception
+ {
+ // get the cell range with the given address
+ com.sun.star.table.XCellRange xCellRange = xSheet.getCellRangeByName( aRange );
+
+ // create the range address sequence
+ com.sun.star.sheet.XCellRangeAddressable xAddr = UnoRuntime.queryInterface( com.sun.star.sheet.XCellRangeAddressable.class, xCellRange );
+ com.sun.star.table.CellRangeAddress[] aRangesSeq = new com.sun.star.table.CellRangeAddress[1];
+ aRangesSeq[0] = xAddr.getRangeAddress();
+
+ // create the scenario
+ com.sun.star.sheet.XScenariosSupplier xScenSupp = UnoRuntime.queryInterface( com.sun.star.sheet.XScenariosSupplier.class, xSheet );
+ com.sun.star.sheet.XScenarios xScenarios = xScenSupp.getScenarios();
+ xScenarios.addNewByName( aScenarioName, aRangesSeq, aScenarioComment );
+
+ // insert the values into the range
+ com.sun.star.sheet.XCellRangeData xData = UnoRuntime.queryInterface( com.sun.star.sheet.XCellRangeData.class, xCellRange );
+ xData.setDataArray( aValueArray );
+ }
+
+ /** Activates a scenario.
+ @param xSheet The XSpreadsheet interface of the spreadsheet.
+ @param aScenarioName The name of the scenario. */
+ private void showScenario(
+ com.sun.star.sheet.XSpreadsheet xSheet,
+ String aScenarioName ) throws RuntimeException, Exception
+ {
+ // get the scenario set
+ com.sun.star.sheet.XScenariosSupplier xScenSupp = UnoRuntime.queryInterface( com.sun.star.sheet.XScenariosSupplier.class, xSheet );
+ com.sun.star.sheet.XScenarios xScenarios = xScenSupp.getScenarios();
+
+ // get the scenario and activate it
+ Object aScenarioObj = xScenarios.getByName( aScenarioName );
+ com.sun.star.sheet.XScenario xScenario = UnoRuntime.queryInterface( com.sun.star.sheet.XScenario.class, aScenarioObj );
+ xScenario.apply();
+ }
+
+
+
+ private void doNamedRangesSamples() throws RuntimeException, Exception
+ {
+ System.out.println( "\n*** Samples for named ranges ***\n" );
+ com.sun.star.sheet.XSpreadsheetDocument xDocument = getDocument();
+ com.sun.star.sheet.XSpreadsheet xSheet = getSpreadsheet( 0 );
+
+
+ // --- Named ranges ---
+ prepareRange( xSheet, "G42:H45", "Named ranges" );
+ xSheet.getCellByPosition( 6, 42 ).setValue( 1 );
+ xSheet.getCellByPosition( 6, 43 ).setValue( 2 );
+ xSheet.getCellByPosition( 7, 42 ).setValue( 3 );
+ xSheet.getCellByPosition( 7, 43 ).setValue( 4 );
+
+ // insert a named range
+ com.sun.star.beans.XPropertySet xDocProp = UnoRuntime.queryInterface( com.sun.star.beans.XPropertySet.class, xDocument );
+ Object aRangesObj = xDocProp.getPropertyValue( "NamedRanges" );
+ com.sun.star.sheet.XNamedRanges xNamedRanges = UnoRuntime.queryInterface( com.sun.star.sheet.XNamedRanges.class, aRangesObj );
+ com.sun.star.table.CellAddress aRefPos = new com.sun.star.table.CellAddress();
+ aRefPos.Sheet = 0;
+ aRefPos.Column = 6;
+ aRefPos.Row = 44;
+ xNamedRanges.addNewByName( "ExampleName", "SUM(G43:G44)", aRefPos, 0 );
+
+ // use the named range in formulas
+ xSheet.getCellByPosition( 6, 44 ).setFormula( "=ExampleName" );
+ xSheet.getCellByPosition( 7, 44 ).setFormula( "=ExampleName" );
+
+
+ // --- Label ranges ---
+ prepareRange( xSheet, "G47:I50", "Label ranges" );
+ com.sun.star.table.XCellRange xRange = xSheet.getCellRangeByPosition( 6, 47, 7, 49 );
+ com.sun.star.sheet.XCellRangeData xData = UnoRuntime.queryInterface( com.sun.star.sheet.XCellRangeData.class, xRange );
+ Object[][] aValues =
+ {
+ { "Apples", "Oranges" },
+ { new Double( 5 ), new Double( 7 ) },
+ { new Double( 6 ), new Double( 8 ) }
+ };
+ xData.setDataArray( aValues );
+
+ // insert a column label range
+ Object aLabelsObj = xDocProp.getPropertyValue( "ColumnLabelRanges" );
+ com.sun.star.sheet.XLabelRanges xLabelRanges = UnoRuntime.queryInterface( com.sun.star.sheet.XLabelRanges.class, aLabelsObj );
+ com.sun.star.table.CellRangeAddress aLabelArea = new com.sun.star.table.CellRangeAddress();
+ aLabelArea.Sheet = 0;
+ aLabelArea.StartColumn = 6;
+ aLabelArea.StartRow = 47;
+ aLabelArea.EndColumn = 7;
+ aLabelArea.EndRow = 47;
+ com.sun.star.table.CellRangeAddress aDataArea = new com.sun.star.table.CellRangeAddress();
+ aDataArea.Sheet = 0;
+ aDataArea.StartColumn = 6;
+ aDataArea.StartRow = 48;
+ aDataArea.EndColumn = 7;
+ aDataArea.EndRow = 49;
+ xLabelRanges.addNew( aLabelArea, aDataArea );
+
+ // use the label range in formulas
+ xSheet.getCellByPosition( 8, 48 ).setFormula( "=Apples+Oranges" );
+ xSheet.getCellByPosition( 8, 49 ).setFormula( "=Apples+Oranges" );
+ }
+
+
+
+ /** Helper for doDatabaseSamples: get name of first database. */
+ private String getFirstDatabaseName()
+ {
+ String aDatabase = null;
+ try
+ {
+ com.sun.star.lang.XMultiComponentFactory xServiceManager = getServiceManager();
+ com.sun.star.container.XNameAccess xContext =
+ UnoRuntime.queryInterface(
+ com.sun.star.container.XNameAccess.class,
+ xServiceManager.createInstanceWithContext(
+ "com.sun.star.sdb.DatabaseContext", getContext()) );
+ String[] aNames = xContext.getElementNames();
+ if ( aNames.length > 0 )
+ aDatabase = aNames[0];
+ }
+ catch ( Exception e )
+ {
+ System.out.println( "\nError: caught exception in getFirstDatabaseName()!\n" +
+ "Exception Message = "
+ + e.getMessage());
+ e.printStackTrace();
+ }
+ return aDatabase;
+ }
+
+ /** Helper for doDatabaseSamples: get name of first table in a database. */
+ private String getFirstTableName( String aDatabase )
+ {
+ if ( aDatabase == null )
+ return null;
+
+ String aTable = null;
+ try
+ {
+ com.sun.star.lang.XMultiComponentFactory xServiceManager = getServiceManager();
+ com.sun.star.container.XNameAccess xContext = UnoRuntime.queryInterface( com.sun.star.container.XNameAccess.class,
+ xServiceManager.createInstanceWithContext(
+ "com.sun.star.sdb.DatabaseContext", getContext()) );
+ com.sun.star.sdb.XCompletedConnection xSource =
+ UnoRuntime.queryInterface(
+ com.sun.star.sdb.XCompletedConnection.class,
+ xContext.getByName( aDatabase ) );
+ com.sun.star.task.XInteractionHandler xHandler =
+ UnoRuntime.queryInterface(
+ com.sun.star.task.XInteractionHandler.class,
+ xServiceManager.createInstanceWithContext(
+ "com.sun.star.task.InteractionHandler", getContext()) );
+ com.sun.star.sdbcx.XTablesSupplier xSupplier =
+ UnoRuntime.queryInterface(
+ com.sun.star.sdbcx.XTablesSupplier.class,
+ xSource.connectWithCompletion( xHandler ) );
+ com.sun.star.container.XNameAccess xTables = xSupplier.getTables();
+ String[] aNames = xTables.getElementNames();
+ if ( aNames.length > 0 )
+ aTable = aNames[0];
+ }
+ catch ( Exception e )
+ {
+ System.out.println( "\nError: caught exception in getFirstTableName()!\n" +
+ "Exception Message = "
+ + e.getMessage());
+ e.printStackTrace();
+ }
+ return aTable;
+ }
+
+ private void doDatabaseSamples() throws Exception
+ {
+ System.out.println( "\n*** Samples for database operations ***\n" );
+ com.sun.star.sheet.XSpreadsheet xSheet = getSpreadsheet( 2 );
+
+
+ // --- put some example data into the sheet ---
+ com.sun.star.table.XCellRange xRange = xSheet.getCellRangeByName( "B3:D24" );
+ com.sun.star.sheet.XCellRangeData xData = UnoRuntime.queryInterface( com.sun.star.sheet.XCellRangeData.class, xRange );
+ Object[][] aValues =
+ {
+ { "Name", "Year", "Sales" },
+ { "Alice", new Double( 2001 ), new Double( 4.0 ) },
+ { "Carol", new Double( 1997 ), new Double( 3.0 ) },
+ { "Carol", new Double( 1998 ), new Double( 8.0 ) },
+ { "Bob", new Double( 1997 ), new Double( 8.0 ) },
+ { "Alice", new Double( 2002 ), new Double( 9.0 ) },
+ { "Alice", new Double( 1999 ), new Double( 7.0 ) },
+ { "Alice", new Double( 1996 ), new Double( 3.0 ) },
+ { "Bob", new Double( 2000 ), new Double( 1.0 ) },
+ { "Carol", new Double( 1999 ), new Double( 5.0 ) },
+ { "Bob", new Double( 2002 ), new Double( 1.0 ) },
+ { "Carol", new Double( 2001 ), new Double( 5.0 ) },
+ { "Carol", new Double( 2000 ), new Double( 1.0 ) },
+ { "Carol", new Double( 1996 ), new Double( 8.0 ) },
+ { "Bob", new Double( 1996 ), new Double( 7.0 ) },
+ { "Alice", new Double( 1997 ), new Double( 3.0 ) },
+ { "Alice", new Double( 2000 ), new Double( 9.0 ) },
+ { "Bob", new Double( 1998 ), new Double( 1.0 ) },
+ { "Bob", new Double( 1999 ), new Double( 6.0 ) },
+ { "Carol", new Double( 2002 ), new Double( 8.0 ) },
+ { "Alice", new Double( 1998 ), new Double( 5.0 ) },
+ { "Bob", new Double( 2001 ), new Double( 6.0 ) }
+ };
+ xData.setDataArray( aValues );
+
+
+ // --- filter for second column >= 1998 ---
+ com.sun.star.sheet.XSheetFilterable xFilter = UnoRuntime.queryInterface( com.sun.star.sheet.XSheetFilterable.class, xRange );
+ com.sun.star.sheet.XSheetFilterDescriptor xFilterDesc =
+ xFilter.createFilterDescriptor( true );
+ com.sun.star.sheet.TableFilterField[] aFilterFields =
+ new com.sun.star.sheet.TableFilterField[1];
+ aFilterFields[0] = new com.sun.star.sheet.TableFilterField();
+ aFilterFields[0].Field = 1;
+ aFilterFields[0].IsNumeric = true;
+ aFilterFields[0].Operator = com.sun.star.sheet.FilterOperator.GREATER_EQUAL;
+ aFilterFields[0].NumericValue = 1998;
+ xFilterDesc.setFilterFields( aFilterFields );
+ com.sun.star.beans.XPropertySet xFilterProp = UnoRuntime.queryInterface( com.sun.star.beans.XPropertySet.class, xFilterDesc );
+ xFilterProp.setPropertyValue( "ContainsHeader", Boolean.TRUE );
+ xFilter.filter( xFilterDesc );
+
+
+ // --- do the same filter as above, using criteria from a cell range ---
+ com.sun.star.table.XCellRange xCritRange = xSheet.getCellRangeByName( "B27:B28" );
+ com.sun.star.sheet.XCellRangeData xCritData = UnoRuntime.queryInterface( com.sun.star.sheet.XCellRangeData.class, xCritRange );
+ Object[][] aCritValues =
+ {
+ { "Year" },
+ { ">= 1998" }
+ };
+ xCritData.setDataArray( aCritValues );
+ com.sun.star.sheet.XSheetFilterableEx xCriteria = UnoRuntime.queryInterface( com.sun.star.sheet.XSheetFilterableEx.class, xCritRange );
+ xFilterDesc = xCriteria.createFilterDescriptorByObject( xFilter );
+ if ( xFilterDesc != null )
+ xFilter.filter( xFilterDesc );
+
+
+ // --- sort by second column, ascending ---
+ com.sun.star.table.TableSortField[] aSortFields = new com.sun.star.table.TableSortField[1];
+ aSortFields[0] = new com.sun.star.table.TableSortField();
+ aSortFields[0].Field = 1;
+ aSortFields[0].IsAscending = false;
+ aSortFields[0].IsCaseSensitive = false;
+
+
+ com.sun.star.beans.PropertyValue[] aSortDesc = new com.sun.star.beans.PropertyValue[2];
+ aSortDesc[0] = new com.sun.star.beans.PropertyValue();
+ aSortDesc[0].Name = "SortFields";
+ aSortDesc[0].Value = aSortFields;
+ aSortDesc[1] = new com.sun.star.beans.PropertyValue();
+ aSortDesc[1].Name = "ContainsHeader";
+ aSortDesc[1].Value = Boolean.TRUE;
+
+ com.sun.star.util.XSortable xSort = UnoRuntime.queryInterface( com.sun.star.util.XSortable.class, xRange );
+ xSort.sort( aSortDesc );
+
+
+ // --- insert subtotals ---
+ com.sun.star.sheet.XSubTotalCalculatable xSub = UnoRuntime.queryInterface( com.sun.star.sheet.XSubTotalCalculatable.class, xRange );
+ com.sun.star.sheet.XSubTotalDescriptor xSubDesc = xSub.createSubTotalDescriptor( true );
+ com.sun.star.sheet.SubTotalColumn[] aColumns = new com.sun.star.sheet.SubTotalColumn[1];
+ // calculate sum of third column
+ aColumns[0] = new com.sun.star.sheet.SubTotalColumn();
+ aColumns[0].Column = 2;
+ aColumns[0].Function = com.sun.star.sheet.GeneralFunction.SUM;
+ // group by first column
+ xSubDesc.addNew( aColumns, 0 );
+ xSub.applySubTotals( xSubDesc, true );
+
+ String aDatabase = getFirstDatabaseName();
+ String aTableName = getFirstTableName( aDatabase );
+ if ( aDatabase != null && aTableName != null )
+ {
+ // --- import from database ---
+ com.sun.star.beans.PropertyValue[] aImportDesc = new com.sun.star.beans.PropertyValue[3];
+ aImportDesc[0] = new com.sun.star.beans.PropertyValue();
+ aImportDesc[0].Name = "DatabaseName";
+ aImportDesc[0].Value = aDatabase;
+ aImportDesc[1] = new com.sun.star.beans.PropertyValue();
+ aImportDesc[1].Name = "SourceType";
+ aImportDesc[1].Value = com.sun.star.sheet.DataImportMode.TABLE;
+ aImportDesc[2] = new com.sun.star.beans.PropertyValue();
+ aImportDesc[2].Name = "SourceObject";
+ aImportDesc[2].Value = aTableName;
+
+ com.sun.star.table.XCellRange xImportRange = xSheet.getCellRangeByName( "B35:B35" );
+ com.sun.star.util.XImportable xImport = UnoRuntime.queryInterface( com.sun.star.util.XImportable.class, xImportRange );
+ xImport.doImport( aImportDesc );
+
+
+ // --- use the temporary database range to find the imported data's size ---
+ com.sun.star.beans.XPropertySet xDocProp = UnoRuntime.queryInterface( com.sun.star.beans.XPropertySet.class, getDocument() );
+ Object aRangesObj = xDocProp.getPropertyValue( "DatabaseRanges" );
+ com.sun.star.container.XNameAccess xRanges =
+ UnoRuntime.queryInterface(
+ com.sun.star.container.XNameAccess.class, aRangesObj );
+ String[] aNames = xRanges.getElementNames();
+ for ( int i=0; i<aNames.length; i++ )
+ {
+ Object aRangeObj = xRanges.getByName( aNames[i] );
+ com.sun.star.beans.XPropertySet xRangeProp = UnoRuntime.queryInterface( com.sun.star.beans.XPropertySet.class, aRangeObj );
+ boolean bUser = AnyConverter.toBoolean(xRangeProp.getPropertyValue( "IsUserDefined" ));
+ if ( !bUser )
+ {
+ // this is the temporary database range - get the cell range and format it
+ com.sun.star.sheet.XCellRangeReferrer xRef = UnoRuntime.queryInterface( com.sun.star.sheet.XCellRangeReferrer.class, aRangeObj );
+ com.sun.star.table.XCellRange xResultRange = xRef.getReferredCells();
+ com.sun.star.beans.XPropertySet xResultProp = UnoRuntime.queryInterface( com.sun.star.beans.XPropertySet.class, xResultRange );
+ xResultProp.setPropertyValue( "IsCellBackgroundTransparent", Boolean.FALSE );
+ xResultProp.setPropertyValue( "CellBackColor", Integer.valueOf( 0xFFFFCC ) );
+ }
+ }
+ }
+ else
+ System.out.println("can't get database");
+ }
+
+
+
+ private void doDataPilotSamples() throws Exception
+ {
+ System.out.println( "\n*** Samples for Data Pilot ***\n" );
+ com.sun.star.sheet.XSpreadsheet xSheet = getSpreadsheet( 0 );
+
+
+ // --- Create a new DataPilot table ---
+ prepareRange( xSheet, "A38:C38", "Data Pilot" );
+ com.sun.star.sheet.XDataPilotTablesSupplier xDPSupp = UnoRuntime.queryInterface( com.sun.star.sheet.XDataPilotTablesSupplier.class, xSheet );
+ com.sun.star.sheet.XDataPilotTables xDPTables = xDPSupp.getDataPilotTables();
+ com.sun.star.sheet.XDataPilotDescriptor xDPDesc = xDPTables.createDataPilotDescriptor();
+ // set source range (use data range from CellRange test)
+ com.sun.star.table.CellRangeAddress aSourceAddress = createCellRangeAddress( xSheet, "A10:C30" );
+ xDPDesc.setSourceRange( aSourceAddress );
+ // settings for fields
+ com.sun.star.container.XIndexAccess xFields = xDPDesc.getDataPilotFields();
+ Object aFieldObj;
+ com.sun.star.beans.XPropertySet xFieldProp;
+ // use first column as column field
+ aFieldObj = xFields.getByIndex(0);
+ xFieldProp = UnoRuntime.queryInterface( com.sun.star.beans.XPropertySet.class, aFieldObj );
+ xFieldProp.setPropertyValue( "Orientation", com.sun.star.sheet.DataPilotFieldOrientation.COLUMN );
+ // use second column as row field
+ aFieldObj = xFields.getByIndex(1);
+ xFieldProp = UnoRuntime.queryInterface( com.sun.star.beans.XPropertySet.class, aFieldObj );
+ xFieldProp.setPropertyValue( "Orientation", com.sun.star.sheet.DataPilotFieldOrientation.ROW );
+ // use third column as data field, calculating the sum
+ aFieldObj = xFields.getByIndex(2);
+ xFieldProp = UnoRuntime.queryInterface( com.sun.star.beans.XPropertySet.class, aFieldObj );
+ xFieldProp.setPropertyValue( "Orientation", com.sun.star.sheet.DataPilotFieldOrientation.DATA );
+ xFieldProp.setPropertyValue( "Function", com.sun.star.sheet.GeneralFunction.SUM );
+ // select output position
+ com.sun.star.table.CellAddress aDestAddress = createCellAddress( xSheet, "A40" );
+ xDPTables.insertNewByName( "DataPilotExample", aDestAddress, xDPDesc );
+
+
+ // --- Modify the DataPilot table ---
+ Object aDPTableObj = xDPTables.getByName( "DataPilotExample" );
+ xDPDesc = UnoRuntime.queryInterface( com.sun.star.sheet.XDataPilotDescriptor.class, aDPTableObj );
+ xFields = xDPDesc.getDataPilotFields();
+ // add a second data field from the third column, calculating the average
+ aFieldObj = xFields.getByIndex(2);
+ xFieldProp = UnoRuntime.queryInterface( com.sun.star.beans.XPropertySet.class, aFieldObj );
+ xFieldProp.setPropertyValue( "Orientation", com.sun.star.sheet.DataPilotFieldOrientation.DATA );
+ xFieldProp.setPropertyValue( "Function", com.sun.star.sheet.GeneralFunction.AVERAGE );
+ }
+
+
+
+ private void doFunctionAccessSamples() throws RuntimeException, Exception
+ {
+ System.out.println( "\n*** Samples for function handling ***\n" );
+ com.sun.star.lang.XMultiComponentFactory xServiceManager = getServiceManager();
+
+
+ // --- Calculate a function ---
+ Object aFuncInst = xServiceManager.createInstanceWithContext(
+ "com.sun.star.sheet.FunctionAccess", getContext());
+ com.sun.star.sheet.XFunctionAccess xFuncAcc =
+ UnoRuntime.queryInterface(
+ com.sun.star.sheet.XFunctionAccess.class, aFuncInst );
+ // put the data in a two-dimensional array
+ double[][] aData = { { 1.0, 2.0, 3.0 } };
+ // construct the array of function arguments
+ Object[] aArgs = new Object[2];
+ aArgs[0] = aData;
+ aArgs[1] = new Double( 2.0 );
+ Object aResult = xFuncAcc.callFunction( "ZTEST", aArgs );
+ System.out.println("ZTEST result for data {1,2,3} and value 2 is "
+ + ((Double)aResult).doubleValue() );
+
+
+ // --- Get the list of recently used functions ---
+ Object aRecInst = xServiceManager.createInstanceWithContext(
+ "com.sun.star.sheet.RecentFunctions", getContext());
+ com.sun.star.sheet.XRecentFunctions xRecFunc =
+ UnoRuntime.queryInterface(
+ com.sun.star.sheet.XRecentFunctions.class, aRecInst );
+ int[] nRecentIds = xRecFunc.getRecentFunctionIds();
+
+
+ // --- Get the names for these functions ---
+ Object aDescInst = xServiceManager.createInstanceWithContext(
+ "com.sun.star.sheet.FunctionDescriptions", getContext());
+ com.sun.star.sheet.XFunctionDescriptions xFuncDesc =
+ UnoRuntime.queryInterface(
+ com.sun.star.sheet.XFunctionDescriptions.class, aDescInst );
+ System.out.print("Recently used functions: ");
+ for (int nFunction=0; nFunction<nRecentIds.length; nFunction++)
+ {
+ com.sun.star.beans.PropertyValue[] aProperties =
+ xFuncDesc.getById( nRecentIds[nFunction] );
+ for (int nProp=0; nProp<aProperties.length; nProp++)
+ if ( aProperties[nProp].Name.equals( "Name" ) )
+ System.out.print( aProperties[nProp].Value + " " );
+ }
+ System.out.println();
+ }
+
+
+
+ private void doApplicationSettingsSamples() throws RuntimeException, Exception
+ {
+ System.out.println( "\n*** Samples for application settings ***\n" );
+ com.sun.star.lang.XMultiComponentFactory xServiceManager = getServiceManager();
+
+
+ // --- Get the user defined sort lists ---
+ Object aSettings = xServiceManager.createInstanceWithContext(
+ "com.sun.star.sheet.GlobalSheetSettings", getContext());
+ com.sun.star.beans.XPropertySet xPropSet =
+ UnoRuntime.queryInterface(
+ com.sun.star.beans.XPropertySet.class, aSettings );
+ String[] aEntries = (String[])
+ AnyConverter.toObject(String[].class,
+ xPropSet.getPropertyValue( "UserLists" ));
+ System.out.println("User defined sort lists:");
+ for ( int i=0; i<aEntries.length; i++ )
+ System.out.println( aEntries[i] );
+ }
+
+
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/Spreadsheet/ViewSample.java b/odk/examples/DevelopersGuide/Spreadsheet/ViewSample.java
new file mode 100644
index 000000000..e1256f04c
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Spreadsheet/ViewSample.java
@@ -0,0 +1,164 @@
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+import com.sun.star.uno.UnoRuntime;
+
+// __________ implementation ____________________________________
+
+/** Create and modify a spreadsheet view.
+ */
+public class ViewSample extends SpreadsheetDocHelper
+{
+
+
+
+ public static void main( String args[] )
+ {
+ try
+ {
+ ViewSample aSample = new ViewSample( args );
+ aSample.doSampleFunction();
+ }
+ catch (Exception ex)
+ {
+ System.out.println( "Sample caught exception! " + ex );
+ System.exit( 1 );
+ }
+ System.out.println( "\nSamples done." );
+ System.exit( 0 );
+ }
+
+
+
+ public ViewSample( String[] args )
+ {
+ super( args );
+ }
+
+
+
+ /** This sample function performs all changes on the view. */
+ public void doSampleFunction() throws Exception
+ {
+ com.sun.star.sheet.XSpreadsheetDocument xDoc = getDocument();
+ com.sun.star.frame.XModel xModel = UnoRuntime.queryInterface( com.sun.star.frame.XModel.class, xDoc);
+ com.sun.star.frame.XController xController = xModel.getCurrentController();
+
+ // --- Spreadsheet view ---
+ // freeze the first column and first two rows
+ com.sun.star.sheet.XViewFreezable xFreeze = UnoRuntime.queryInterface( com.sun.star.sheet.XViewFreezable.class, xController );
+ if ( null != xFreeze )
+ System.out.println( "got xFreeze" );
+ xFreeze.freezeAtPosition( 1, 2 );
+
+ // --- View pane ---
+ // get the cell range shown in the second pane and assign a cell background to them
+ com.sun.star.container.XIndexAccess xIndex = UnoRuntime.queryInterface( com.sun.star.container.XIndexAccess.class, xController );
+ Object aPane = xIndex.getByIndex(1);
+ com.sun.star.sheet.XCellRangeReferrer xRefer = UnoRuntime.queryInterface( com.sun.star.sheet.XCellRangeReferrer.class, aPane );
+ com.sun.star.table.XCellRange xRange = xRefer.getReferredCells();
+ com.sun.star.beans.XPropertySet xRangeProp = UnoRuntime.queryInterface( com.sun.star.beans.XPropertySet.class, xRange );
+ xRangeProp.setPropertyValue( "IsCellBackgroundTransparent", Boolean.FALSE );
+ xRangeProp.setPropertyValue( "CellBackColor", Integer.valueOf( 0xFFFFCC ) );
+
+ // --- View settings ---
+ // change the view to display green grid lines
+ com.sun.star.beans.XPropertySet xProp = UnoRuntime.queryInterface( com.sun.star.beans.XPropertySet.class, xController );
+ xProp.setPropertyValue( "ShowGrid", Boolean.TRUE );
+ xProp.setPropertyValue( "GridColor", Integer.valueOf(0x00CC00) );
+
+ // --- Range selection ---
+ // let the user select a range and use it as the view's selection
+ com.sun.star.sheet.XRangeSelection xRngSel = UnoRuntime.queryInterface( com.sun.star.sheet.XRangeSelection.class, xController );
+ ExampleRangeListener aListener = new ExampleRangeListener();
+ xRngSel.addRangeSelectionListener( aListener );
+ com.sun.star.beans.PropertyValue[] aArguments = new com.sun.star.beans.PropertyValue[2];
+ aArguments[0] = new com.sun.star.beans.PropertyValue();
+ aArguments[0].Name = "Title";
+ aArguments[0].Value = "Please select a cell range (e.g. C4:E6)";
+ aArguments[1] = new com.sun.star.beans.PropertyValue();
+ aArguments[1].Name = "CloseOnMouseRelease";
+ aArguments[1].Value = Boolean.TRUE;
+ xRngSel.startRangeSelection( aArguments );
+ synchronized (aListener)
+ {
+ aListener.wait(); // wait until the selection is done
+ }
+ xRngSel.removeRangeSelectionListener( aListener );
+ if ( aListener.aResult != null && aListener.aResult.length() != 0 )
+ {
+ com.sun.star.view.XSelectionSupplier xSel = UnoRuntime.queryInterface( com.sun.star.view.XSelectionSupplier.class, xController );
+ com.sun.star.sheet.XSpreadsheetView xView = UnoRuntime.queryInterface( com.sun.star.sheet.XSpreadsheetView.class, xController );
+ com.sun.star.sheet.XSpreadsheet xSheet = xView.getActiveSheet();
+ com.sun.star.table.XCellRange xResultRange = xSheet.getCellRangeByName( aListener.aResult );
+ xSel.select( xResultRange );
+ }
+ }
+
+
+
+ // listener to react on finished selection
+
+ private class ExampleRangeListener implements com.sun.star.sheet.XRangeSelectionListener
+ {
+ public String aResult;
+
+ public void done( com.sun.star.sheet.RangeSelectionEvent aEvent )
+ {
+ aResult = aEvent.RangeDescriptor;
+ synchronized (this)
+ {
+ notify();
+ }
+ }
+
+ public void aborted( com.sun.star.sheet.RangeSelectionEvent aEvent )
+ {
+ synchronized (this)
+ {
+ notify();
+ }
+ }
+
+ public void disposing( com.sun.star.lang.EventObject aObj )
+ {
+ }
+ }
+
+
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/Spreadsheet/XExampleAddIn.idl b/odk/examples/DevelopersGuide/Spreadsheet/XExampleAddIn.idl
new file mode 100644
index 000000000..2d75f437b
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Spreadsheet/XExampleAddIn.idl
@@ -0,0 +1,62 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+#ifndef _ORG_OPENOFFICE_SHEET_ADDIN_XEXAMPLEADDIN_IDL_
+#define _ORG_OPENOFFICE_SHEET_ADDIN_XEXAMPLEADDIN_IDL_
+
+#include <com/sun/star/uno/XInterface.idl>
+#include <com/sun/star/sheet/XVolatileResult.idl>
+
+module org {
+ module openoffice {
+ module sheet {
+ module addin {
+ /// The interface that the example addin implements
+ interface XExampleAddIn : com::sun::star::uno::XInterface
+ {
+ /// Sample function that just increments a value.
+ long getIncremented( [in] long nValue );
+
+ /// Sample function that returns a volatile result.
+ com::sun::star::sheet::XVolatileResult getCounter( [in] string aName );
+ };
+ };
+ };
+ };
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/Spreadsheet/description.xml b/odk/examples/DevelopersGuide/Spreadsheet/description.xml
new file mode 100644
index 000000000..6c4e2396b
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Spreadsheet/description.xml
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+-->
+<d:description xmlns:d="http://openoffice.org/extensions/description/2006">
+ <d:dependencies>
+ <l:LibreOffice-minimal-version value="4.1" d:name="LibreOffice 4.1"
+ xmlns:l="http://libreoffice.org/extensions/description/2011"/>
+ </d:dependencies>
+</d:description>
diff --git a/odk/examples/DevelopersGuide/Text/Makefile b/odk/examples/DevelopersGuide/Text/Makefile
new file mode 100644
index 000000000..d27923b6f
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Text/Makefile
@@ -0,0 +1,95 @@
+#*************************************************************************
+#
+# The Contents of this file are made available subject to the terms of
+# the BSD license.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+# 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+# contributors may be used to endorse or promote products derived
+# from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+# TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+# USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+#**************************************************************************
+
+# Builds the Text example of the Developers Guide.
+
+PRJ=../../..
+SETTINGS=$(PRJ)/settings
+
+include $(SETTINGS)/settings.mk
+include $(SETTINGS)/std.mk
+
+# Define non-platform/compiler specific settings
+SAMPLE_NAME=TextExample
+SAMPLE_CLASS_OUT = $(OUT_CLASS)/$(SAMPLE_NAME)
+SAMPLE_GEN_OUT = $(OUT_MISC)/$(SAMPLE_NAME)
+
+APP1_NAME=TextDocuments
+APP1_JAR=$(SAMPLE_CLASS_OUT)/$(APP1_NAME).jar
+
+SDK_CLASSPATH = $(subst $(EMPTYSTRING) $(PATH_SEPARATOR),$(PATH_SEPARATOR),$(CLASSPATH)\
+ $(PATH_SEPARATOR)$(SAMPLE_CLASS_OUT))
+
+
+# Targets
+.PHONY: ALL
+ALL : \
+ $(SAMPLE_NAME)
+
+include $(SETTINGS)/stdtarget.mk
+
+$(SAMPLE_CLASS_OUT)/%.class : %.java
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ $(SDK_JAVAC) $(JAVAC_FLAGS) -classpath "$(SDK_CLASSPATH)" -d $(SAMPLE_CLASS_OUT) $<
+
+$(SAMPLE_CLASS_OUT)/%.mf :
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ @echo Main-Class: com.sun.star.lib.loader.Loader> $@
+ $(ECHOLINE)>> $@
+ @echo Name: com/sun/star/lib/loader/Loader.class>> $@
+ @echo Application-Class: $*>> $@
+
+$(SAMPLE_CLASS_OUT)/%.jar : $(SAMPLE_CLASS_OUT)/%.mf $(SAMPLE_CLASS_OUT)/%.class
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ +cd $(subst /,$(PS),$(SAMPLE_CLASS_OUT)) && $(SDK_JAR) cvfm $(@F) $*.mf $*.class
+ +$(SDK_JAR) uvf $@ $(SDK_JAVA_UNO_BOOTSTRAP_FILES)
+
+$(APP1_JAR) : $(SAMPLE_CLASS_OUT)/$(APP1_NAME).mf $(SAMPLE_CLASS_OUT)/$(APP1_NAME).class
+
+$(SAMPLE_NAME) : $(APP1_JAR)
+ @echo --------------------------------------------------------------------------------
+ @echo Please use the following command to execute the example!
+ @echo -
+ @echo $(MAKE) $(APP1_NAME).run
+ @echo --------------------------------------------------------------------------------
+
+%.run: $(SAMPLE_CLASS_OUT)/%.jar
+ -$(MKDIR) $(subst /,$(PS),$(SAMPLE_GEN_OUT)/savetest)
+ $(SDK_JAVA) -Dcom.sun.star.lib.loader.unopath="$(OFFICE_PROGRAM_PATH)" -jar $< "$(SAMPLE_GEN_OUT)/savetest"
+
+.PHONY: clean
+clean :
+ -$(DELRECURSIVE) $(subst /,$(PS),$(SAMPLE_CLASS_OUT))
+ -$(DELRECURSIVE) $(subst /,$(PS),$(SAMPLE_GEN_OUT))
diff --git a/odk/examples/DevelopersGuide/Text/PrintDemo.odt b/odk/examples/DevelopersGuide/Text/PrintDemo.odt
new file mode 100644
index 000000000..1b02d883a
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Text/PrintDemo.odt
Binary files differ
diff --git a/odk/examples/DevelopersGuide/Text/TextDocuments.java b/odk/examples/DevelopersGuide/Text/TextDocuments.java
new file mode 100644
index 000000000..1a1a82762
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Text/TextDocuments.java
@@ -0,0 +1,1724 @@
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Random;
+
+import com.sun.star.awt.Point;
+import com.sun.star.awt.Size;
+import com.sun.star.beans.PropertyValue;
+import com.sun.star.beans.XPropertySet;
+import com.sun.star.container.XEnumeration;
+import com.sun.star.container.XEnumerationAccess;
+import com.sun.star.container.XIndexAccess;
+import com.sun.star.container.XIndexReplace;
+import com.sun.star.container.XNameAccess;
+import com.sun.star.container.XNameContainer;
+import com.sun.star.container.XNamed;
+import com.sun.star.drawing.XDrawPageSupplier;
+import com.sun.star.drawing.XShape;
+import com.sun.star.drawing.XShapes;
+import com.sun.star.frame.XComponentLoader;
+import com.sun.star.frame.XController;
+import com.sun.star.frame.XDesktop;
+import com.sun.star.frame.XModel;
+import com.sun.star.frame.XStorable;
+import com.sun.star.lang.XComponent;
+import com.sun.star.lang.XMultiComponentFactory;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.lang.XServiceInfo;
+import com.sun.star.style.NumberingType;
+import com.sun.star.style.XStyle;
+import com.sun.star.style.XStyleFamiliesSupplier;
+import com.sun.star.text.ControlCharacter;
+import com.sun.star.text.ReferenceFieldPart;
+import com.sun.star.text.ReferenceFieldSource;
+import com.sun.star.text.TextColumn;
+import com.sun.star.text.TextContentAnchorType;
+import com.sun.star.text.XAutoTextEntry;
+import com.sun.star.text.XAutoTextGroup;
+import com.sun.star.text.XBookmarksSupplier;
+import com.sun.star.text.XDependentTextField;
+import com.sun.star.text.XDocumentIndex;
+import com.sun.star.text.XFootnote;
+import com.sun.star.text.XFootnotesSupplier;
+import com.sun.star.text.XPageCursor;
+import com.sun.star.text.XParagraphCursor;
+import com.sun.star.text.XReferenceMarksSupplier;
+import com.sun.star.text.XRelativeTextContentInsert;
+import com.sun.star.text.XSentenceCursor;
+import com.sun.star.text.XSimpleText;
+import com.sun.star.text.XText;
+import com.sun.star.text.XTextColumns;
+import com.sun.star.text.XTextContent;
+import com.sun.star.text.XTextCursor;
+import com.sun.star.text.XTextDocument;
+import com.sun.star.text.XTextField;
+import com.sun.star.text.XTextFieldsSupplier;
+import com.sun.star.text.XTextFrame;
+import com.sun.star.text.XTextRange;
+import com.sun.star.text.XTextTable;
+import com.sun.star.text.XTextTableCursor;
+import com.sun.star.text.XTextTablesSupplier;
+import com.sun.star.text.XTextViewCursor;
+import com.sun.star.text.XTextViewCursorSupplier;
+import com.sun.star.text.XWordCursor;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.XComponentContext;
+import com.sun.star.util.XRefreshable;
+import com.sun.star.view.XPrintable;
+
+
+public class TextDocuments {
+ // adjust these constant to your local printer!
+ private static String sOutputDir;
+
+ private static final String aPrinterName = "\\\\so-print\\xml3sof";
+
+ private XComponentContext mxRemoteContext = null;
+ private XMultiComponentFactory mxRemoteServiceManager = null;
+ private XTextDocument mxDoc = null;
+ private XMultiServiceFactory mxDocFactory = null;
+ private XMultiServiceFactory mxFactory = null;
+ private XText mxDocText = null;
+ private XTextCursor mxDocCursor = null;
+ private XTextContent mxFishSection = null;
+ private Random maRandom = null;
+
+ /**
+ * @param args the command line arguments
+ */
+ public static void main(String[] args) {
+ TextDocuments textDocuments1 = new TextDocuments();
+ try {
+ // output directory for store test;
+ sOutputDir = args[0];
+
+ textDocuments1.runDemo();
+ } catch (java.lang.Exception e) {
+ System.out.println(e.getMessage());
+ e.printStackTrace();
+ } finally {
+ System.exit(0);
+ }
+ }
+
+ protected void runDemo() throws java.lang.Exception {
+ storePrintExample(); // depends on printer name
+ templateExample();
+ viewCursorExample(); // makes changes to the current document,
+ // use with care
+ editingExample();
+ }
+
+ /** Sample for use of templates
+ * This sample uses the file TextTemplateWithUserFields.odt from the Samples
+ * folder. The file contains a number of User text fields (Variables - User)
+ * and a bookmark which we use to fill in various values
+ */
+ protected void templateExample() throws java.lang.Exception {
+ // create a small hashtable that simulates a rowset
+ HashMap<String,String> recipient = new HashMap<String,String>();
+ recipient.put("Company", "Manatee Books");
+ recipient.put("Contact", "Rod Martin");
+ recipient.put("ZIP", "34567");
+ recipient.put("City", "Fort Lauderdale");
+ recipient.put("State", "Florida");
+
+ // load template with User fields and bookmark
+ java.io.File sourceFile = new java.io.File("TextTemplateWithUserFields.odt");
+ StringBuffer sTemplateFileUrl = new StringBuffer("file:///");
+ sTemplateFileUrl.append(sourceFile.getCanonicalPath().replace('\\', '/'));
+
+ XComponent xTemplateComponent =
+ newDocComponentFromTemplate( sTemplateFileUrl.toString() );
+
+ // get XTextFieldsSupplier, XBookmarksSupplier interfaces
+ XTextFieldsSupplier xTextFieldsSupplier = UnoRuntime.queryInterface(XTextFieldsSupplier.class,
+ xTemplateComponent);
+ XBookmarksSupplier xBookmarksSupplier = UnoRuntime.queryInterface(XBookmarksSupplier.class, xTemplateComponent);
+
+ // access the TextFields and the TextFieldMasters collections
+ XNameAccess xNamedFieldMasters = xTextFieldsSupplier.getTextFieldMasters();
+ XEnumerationAccess xEnumeratedFields = xTextFieldsSupplier.getTextFields();
+
+ // iterate over hashtable and insert values into field masters
+ for(Iterator<String> iter = recipient.keySet().iterator(); iter.hasNext(); ) {
+ // get column name
+ String key = iter.next();
+
+ // access corresponding field master
+ Object fieldMaster = xNamedFieldMasters.getByName(
+ "com.sun.star.text.fieldmaster.User." + key);
+
+ // query the XPropertySet interface, we need to set the Content property
+ XPropertySet xPropertySet = UnoRuntime.queryInterface(
+ XPropertySet.class, fieldMaster);
+
+ // insert the column value into field master
+ xPropertySet.setPropertyValue("Content", recipient.get(key));
+ }
+ // afterwards we must refresh the textfields collection
+ XRefreshable xRefreshable = UnoRuntime.queryInterface(
+ XRefreshable.class, xEnumeratedFields);
+ xRefreshable.refresh();
+
+ // accessing the Bookmarks collection of the document
+ XNameAccess xNamedBookmarks = xBookmarksSupplier.getBookmarks();
+
+ // find the bookmark named "Subscription"
+ Object bookmark = xNamedBookmarks.getByName("Subscription");
+ // we need its XTextRange which is available from getAnchor(),
+ // so query for XTextContent
+ XTextContent xBookmarkContent = UnoRuntime.queryInterface(
+ XTextContent.class, bookmark);
+ // get the anchor of the bookmark (its XTextRange)
+ XTextRange xBookmarkRange = xBookmarkContent.getAnchor();
+ // set string at the bookmark position
+ xBookmarkRange.setString("subscription for the Manatee Journal");
+
+ }
+
+ /** Sample for document changes, starting at the current view cursor position
+ * The sample changes the paragraph style and the character style at the
+ * current view cursor selection Open the sample file ViewCursorExampleFile,
+ * select some text and run the example.
+ * The current paragraph will be set to Quotations paragraph style.
+ * The selected text will be set to Quotation character style.
+ */
+ private void viewCursorExample() throws java.lang.Exception {
+ // get the remote service manager
+ mxRemoteServiceManager = this.getRemoteServiceManager();
+ // get the Desktop service
+ Object desktop = mxRemoteServiceManager.createInstanceWithContext(
+ "com.sun.star.frame.Desktop", mxRemoteContext);
+ // query its XDesktop interface, we need the current component
+ XDesktop xDesktop = UnoRuntime.queryInterface(
+ XDesktop.class, desktop);
+ // retrieve the current component and access the controller
+ XComponent xCurrentComponent = xDesktop.getCurrentComponent();
+ XModel xModel = UnoRuntime.queryInterface(XModel.class,
+ xCurrentComponent);
+ XController xController = xModel.getCurrentController();
+ // the controller gives us the TextViewCursor
+ XTextViewCursorSupplier xViewCursorSupplier =
+ UnoRuntime.queryInterface(
+ XTextViewCursorSupplier.class, xController);
+ XTextViewCursor xViewCursor = xViewCursorSupplier.getViewCursor();
+
+ // query its XPropertySet interface, we want to set character and paragraph
+ // properties
+ XPropertySet xCursorPropertySet = UnoRuntime.queryInterface(
+ XPropertySet.class, xViewCursor);
+ // set the appropriate properties for character and paragraph style
+ xCursorPropertySet.setPropertyValue("CharStyleName", "Quotation");
+ xCursorPropertySet.setPropertyValue("ParaStyleName", "Quotations");
+ // print the current page number
+ XPageCursor xPageCursor = UnoRuntime.queryInterface(
+ XPageCursor.class, xViewCursor);
+ System.out.println("The current page number is " + xPageCursor.getPage());
+ // the model cursor is much more powerful, so
+ // we create a model cursor at the current view cursor position with the
+ // following steps:
+ // get the Text service from the TextViewCursor, it is an XTextRange:
+ XText xDocumentText = xViewCursor.getText();
+ // create a model cursor from the viewcursor
+ XTextCursor xModelCursor = xDocumentText.createTextCursorByRange(
+ xViewCursor.getStart());
+ // now we could query XWordCursor, XSentenceCursor and XParagraphCursor
+ // or XDocumentInsertable, XSortable or XContentEnumerationAccess
+ // and work with the properties of com.sun.star.text.TextCursor
+ // in this case we just go to the end of the paragraph and add some text.
+ XParagraphCursor xParagraphCursor = UnoRuntime.queryInterface(XParagraphCursor.class, xModelCursor);
+ // goto the end of the paragraph
+ xParagraphCursor.gotoEndOfParagraph(false);
+ xParagraphCursor.setString(" ***** Fin de semana! ******");
+ }
+
+
+ /** Sample for the various editing facilities described in the
+ * developer's manual
+ */
+ private void editingExample () throws java.lang.Exception {
+ // create empty swriter document
+ XComponent xEmptyWriterComponent = newDocComponent("swriter");
+ // query its XTextDocument interface to get the text
+ mxDoc = UnoRuntime.queryInterface(
+ XTextDocument.class, xEmptyWriterComponent);
+
+ // get a reference to the body text of the document
+ mxDocText = mxDoc.getText();
+
+ // Get a reference to the document's property set. This contains document
+ // information like the current word count
+ UnoRuntime.queryInterface(XPropertySet.class, mxDoc );
+
+ // Simple text insertion example
+ BodyTextExample ();
+ // Example using text ranges to insert strings at the beginning or end
+ // of a text range
+ TextRangeExample ();
+ // Create a document cursor and remember it, it will be used in most
+ // of the following examples
+ mxDocCursor = mxDocText.createTextCursor();
+ // Demonstrate some of the different cursor types (word, sentence)
+ TextCursorExample ();
+
+ // Access the text document's multi service factory, which we will need
+ // for most of the following examples
+ mxDocFactory = UnoRuntime.queryInterface(
+ XMultiServiceFactory.class, mxDoc );
+
+ // Examples of text fields, dependent text fields and field masters
+ TextFieldExample ();
+
+ // Example of using an XEnumerationAccess to iterate over paragraphs and
+ // set properties of each paragraph as we do so
+ ParagraphExample ();
+
+ // Example of creating and manipulating a text frame
+ TextFrameExample ();
+
+ // Example of creating and manipulating a text table, text table rows
+ // and text table cells get a new random generator
+ maRandom = new Random();
+ TextTableExample ();
+
+ // Example of creating, inserting and manipulating text sections, as
+ // well as an example of how to refresh the document
+ TextSectionExample ();
+
+ // Example of creating a text section over a block of text and formatting
+ // the text section into columns, as well as how to insert an empty
+ // paragraph using the XRelativeTextContentInsert
+ TextColumnsExample ();
+
+ // Example of creating the NumberingRules service and adjusting
+ // NumberingTypes and NumberingLevels
+ NumberingExample ();
+
+ // Example of how to use the XStyleFamiliesSupplier interface of the
+ // document and how to create, insert and apply styles
+ StylesExample ();
+ IndexExample ();
+
+ // Example of how to create and manipulate reference marks and GetReference
+ // text fields
+ ReferenceExample ();
+
+ // Example of how to create and insert Footnotes and how to use the
+ // XFootnotesSupplier interface of the document
+ FootnoteExample ();
+
+ // This method demonstrates how to create shapes from the document factory
+ // and how to access the draw page of the document using the
+ // XDrawPageSupplier interface
+ DrawPageExample ();
+
+ mxFactory = UnoRuntime.queryInterface(
+ XMultiServiceFactory.class, mxRemoteServiceManager);
+ // This example demonstrates the use of the AutoTextContainer,
+ // AutoTextGroup and AutoTextEntry services and shows how to create,
+ // insert and modify auto text blocks
+ AutoTextExample ();
+ }
+
+ protected void storePrintExample() throws java.lang.Exception {
+ // get the remote service manager
+ mxRemoteServiceManager = this.getRemoteServiceManager();
+ // retrieve the Desktop object, we need its XComponentLoader
+ Object desktop = mxRemoteServiceManager.createInstanceWithContext(
+ "com.sun.star.frame.Desktop", mxRemoteContext);
+ XComponentLoader xComponentLoader = UnoRuntime.queryInterface(XComponentLoader.class, desktop);
+ PropertyValue[] loadProps = new PropertyValue[0];
+
+ java.io.File sourceFile = new java.io.File("PrintDemo.odt");
+ StringBuffer sLoadFileUrl = new StringBuffer("file:///");
+ sLoadFileUrl.append(sourceFile.getCanonicalPath().replace('\\', '/'));
+
+ XComponent xDoc = xComponentLoader.loadComponentFromURL(
+ sLoadFileUrl.toString(), "_blank", 0, loadProps);
+
+ if ( xDoc != null ) {
+ sourceFile = new java.io.File(sOutputDir);
+ StringBuffer sStoreFileUrl = new StringBuffer();
+ sStoreFileUrl.append(sourceFile.toURI().toURL().toString());
+ sStoreFileUrl.append("somepopularfileformat.doc");
+
+ storeDocComponent(xDoc, sStoreFileUrl.toString() );
+ printDocComponent(xDoc);
+ }
+ }
+
+ private XMultiComponentFactory getRemoteServiceManager()
+ throws java.lang.Exception
+ {
+ if (mxRemoteContext == null && mxRemoteServiceManager == null) {
+ // get the remote office context. If necessary a new office
+ // process is started
+ mxRemoteContext = com.sun.star.comp.helper.Bootstrap.bootstrap();
+ System.out.println("Connected to a running office ...");
+ mxRemoteServiceManager = mxRemoteContext.getServiceManager();
+ }
+ return mxRemoteServiceManager;
+ }
+
+ protected XComponent newDocComponent(String docType)
+ throws java.lang.Exception
+ {
+ String loadUrl = "private:factory/" + docType;
+ mxRemoteServiceManager = this.getRemoteServiceManager();
+ Object desktop = mxRemoteServiceManager.createInstanceWithContext(
+ "com.sun.star.frame.Desktop", mxRemoteContext);
+ XComponentLoader xComponentLoader = UnoRuntime.queryInterface(XComponentLoader.class, desktop);
+ PropertyValue[] loadProps = new PropertyValue[0];
+ return xComponentLoader.loadComponentFromURL(loadUrl, "_blank",
+ 0, loadProps);
+ }
+
+ /** Load a document as template
+ */
+ protected XComponent newDocComponentFromTemplate(String loadUrl)
+ throws java.lang.Exception
+ {
+ // get the remote service manager
+ mxRemoteServiceManager = this.getRemoteServiceManager();
+ // retrieve the Desktop object, we need its XComponentLoader
+ Object desktop = mxRemoteServiceManager.createInstanceWithContext(
+ "com.sun.star.frame.Desktop", mxRemoteContext);
+ XComponentLoader xComponentLoader = UnoRuntime.queryInterface(XComponentLoader.class, desktop);
+
+ // define load properties according to com.sun.star.document.MediaDescriptor
+ // the boolean property AsTemplate tells the office to create a new document
+ // from the given file
+ PropertyValue[] loadProps = new PropertyValue[1];
+ loadProps[0] = new PropertyValue();
+ loadProps[0].Name = "AsTemplate";
+ loadProps[0].Value = Boolean.TRUE;
+ // load
+ return xComponentLoader.loadComponentFromURL(loadUrl, "_blank",
+ 0, loadProps);
+ }
+
+ /** Load a document with arguments (text purposes)
+ */
+ protected void storeDocComponent(XComponent xDoc, String storeUrl)
+ throws java.lang.Exception
+ {
+
+ XStorable xStorable = UnoRuntime.queryInterface(
+ XStorable.class, xDoc);
+ PropertyValue[] storeProps = new PropertyValue[1];
+ storeProps[0] = new PropertyValue();
+ storeProps[0].Name = "FilterName";
+ storeProps[0].Value = "MS Word 97";
+
+ System.out.println("... store \"PrintDemo.odt\" to \"" + storeUrl + "\".");
+ xStorable.storeAsURL(storeUrl, storeProps);
+ }
+
+ protected void printDocComponent(XComponent xDoc) throws java.lang.Exception {
+ XPrintable xPrintable = UnoRuntime.queryInterface(
+ XPrintable.class, xDoc);
+ PropertyValue[] printerDesc = new PropertyValue[1];
+ printerDesc[0] = new PropertyValue();
+ printerDesc[0].Name = "Name";
+ printerDesc[0].Value = aPrinterName;
+
+ xPrintable.setPrinter(printerDesc);
+
+ PropertyValue[] printOpts = new PropertyValue[1];
+ printOpts[0] = new PropertyValue();
+ printOpts[0].Name = "Pages";
+ printOpts[0].Value = "1";
+
+ xPrintable.print(printOpts);
+ }
+
+ // Setting the whole text of a document as one string
+ protected void BodyTextExample ()
+ {
+ // Body Text and TextDocument example
+ try
+ {
+ // demonstrate simple text insertion
+ mxDocText.setString ( "This is the new body text of the document."
+ + "\n\nThis is on the second line.\n\n" );
+ }
+ catch ( Exception e )
+ {
+ e.printStackTrace();
+ }
+ }
+
+ // Adding a string at the end or the beginning of text
+ protected void TextRangeExample ()
+ {
+ try
+ {
+ // Get a text range referring to the beginning of the text document
+ XTextRange xStart = mxDocText.getStart();
+ // use setString to insert text at the beginning
+ xStart.setString ( "This is text inserted at the beginning.\n\n" );
+ // Get a text range referring to the end of the text document
+ XTextRange xEnd = mxDocText.getEnd();
+ // use setString to insert text at the end
+ xEnd.setString ( "This is text inserted at the end.\n\n" );
+ }
+ catch ( Exception e )
+ {
+ e.printStackTrace();
+ }
+ }
+
+ /** moving a text cursor, selecting text and overwriting it
+ */
+ protected void TextCursorExample ()
+ {
+ try
+ {
+ // First, get the XSentenceCursor interface of our text cursor
+ XSentenceCursor xSentenceCursor = UnoRuntime.queryInterface(XSentenceCursor.class, mxDocCursor );
+ // Goto the next cursor, without selecting it
+ xSentenceCursor.gotoNextSentence( false );
+ // Get the XWordCursor interface of our text cursor
+ XWordCursor xWordCursor = UnoRuntime.queryInterface(
+ XWordCursor.class, mxDocCursor );
+ // Skip the first four words of this sentence and select the fifth
+ xWordCursor.gotoNextWord( false );
+ xWordCursor.gotoNextWord( false );
+ xWordCursor.gotoNextWord( false );
+ xWordCursor.gotoNextWord( false );
+ xWordCursor.gotoNextWord( true );
+ // Use the XSimpleText interface to insert a word at the current cursor
+ // location, over-writing the current selection (the fifth word
+ // selected above)
+ mxDocText.insertString ( xWordCursor, "old ", true );
+
+ // Access the property set of the cursor, and set the currently
+ // selected text (which is the string we just inserted) to be bold
+ XPropertySet xCursorProps = UnoRuntime.queryInterface(
+ XPropertySet.class, mxDocCursor );
+ xCursorProps.setPropertyValue ( "CharWeight",
+ new Float(com.sun.star.awt.FontWeight.BOLD) );
+
+ // replace the '.' at the end of the sentence with a new string
+ xSentenceCursor.gotoEndOfSentence( false );
+ xWordCursor.gotoPreviousWord( true );
+ mxDocText.insertString (xWordCursor,
+ ", which has been changed with text cursors!",
+ true);
+ }
+ catch ( Exception e )
+ {
+ e.printStackTrace();
+ }
+ }
+
+ /** This method inserts both a date field and a user field containing the
+ * number '42'
+ */
+ protected void TextFieldExample ()
+ {
+ try
+ {
+ // Use the text document's factory to create a DateTime text field,
+ // and access its XTextField interface
+ XTextField xDateField = UnoRuntime.queryInterface (
+ XTextField.class, mxDocFactory.createInstance (
+ "com.sun.star.text.TextField.DateTime" ) );
+
+ // Insert it at the end of the document
+ mxDocText.insertTextContent ( mxDocText.getEnd(), xDateField, false );
+
+ // Use the text document's factory to create a user text field,
+ // and access its XDependentTextField interface
+ XDependentTextField xUserField =
+ UnoRuntime.queryInterface (
+ XDependentTextField.class, mxDocFactory.createInstance (
+ "com.sun.star.text.TextField.User" ) );
+
+ // Create a fieldmaster for our newly created User Text field, and
+ // access its XPropertySet interface
+ XPropertySet xMasterPropSet = UnoRuntime.queryInterface(
+ XPropertySet.class, mxDocFactory.createInstance (
+ "com.sun.star.text.fieldmaster.User" ) );
+
+ // Set the name and value of the FieldMaster
+ xMasterPropSet.setPropertyValue ( "Name", "UserEmperor" );
+ xMasterPropSet.setPropertyValue ( "Value", Integer.valueOf( 42 ) );
+
+ // Attach the field master to the user field
+ xUserField.attachTextFieldMaster ( xMasterPropSet );
+
+ // Move the cursor to the end of the document
+ mxDocCursor.gotoEnd( false );
+ // insert a paragraph break using the XSimpleText interface
+ mxDocText.insertControlCharacter (
+ mxDocCursor, ControlCharacter.PARAGRAPH_BREAK, false );
+
+ // Insert the user field at the end of the document
+ mxDocText.insertTextContent ( mxDocText.getEnd(), xUserField, false );
+ }
+ catch ( Exception e )
+ {
+ e.printStackTrace();
+ }
+ }
+
+ /** This method demonstrates how to iterate over paragraphs
+ */
+ protected void ParagraphExample ()
+ {
+ try
+ {
+ // The service 'com.sun.star.text.Text' supports the XEnumerationAccess
+ // interface to provide an enumeration of the paragraphs contained by
+ // the text the service refers to.
+
+ // Here, we access this interface
+ XEnumerationAccess xParaAccess = UnoRuntime.queryInterface(XEnumerationAccess.class, mxDocText );
+ // Call the XEnumerationAccess's only method to access the actual
+ // Enumeration
+ XEnumeration xParaEnum = xParaAccess.createEnumeration();
+
+ // While there are paragraphs, do things to them
+ while ( xParaEnum.hasMoreElements() )
+ {
+ // Get a reference to the next paragraphs XServiceInfo interface.
+ // TextTables are also part of this enumeration access, so we ask
+ // the element if it is a TextTable, if it doesn't support the
+ // com.sun.star.text.TextTable service, then it is safe to assume
+ // that it really is a paragraph
+ XServiceInfo xInfo = UnoRuntime.queryInterface(
+ XServiceInfo.class, xParaEnum.nextElement() );
+ if ( !xInfo.supportsService ( "com.sun.star.text.TextTable" ) )
+ {
+ // Access the paragraph's property set...the properties in this
+ // property set are listed in:
+ // com.sun.star.style.ParagraphProperties
+ XPropertySet xSet = UnoRuntime.queryInterface(
+ XPropertySet.class, xInfo );
+ // Set the justification to be center justified
+ xSet.setPropertyValue ( "ParaAdjust",
+ com.sun.star.style.ParagraphAdjust.CENTER );
+ }
+ }
+ }
+ catch ( Exception e )
+ {
+ e.printStackTrace();
+ }
+ }
+
+ /** This method returns a random double which isn't too high or too low
+ */
+ protected double getRandomDouble ()
+ {
+ return ( ( maRandom.nextInt() % 1000 ) * maRandom.nextDouble () );
+ }
+
+ /** This method sets the text colour of the cell referred to by sCellName to
+ white and inserts the string sText in it
+ */
+ protected static void insertIntoCell(String sCellName, String sText,
+ XTextTable xTable)
+ {
+ // Access the XText interface of the cell referred to by sCellName
+ XText xCellText = UnoRuntime.queryInterface(
+ XText.class, xTable.getCellByName ( sCellName ) );
+
+ // create a text cursor from the cells XText interface
+ XTextCursor xCellCursor = xCellText.createTextCursor();
+ // Get the property set of the cell's TextCursor
+ XPropertySet xCellCursorProps = UnoRuntime.queryInterface(
+ XPropertySet.class, xCellCursor );
+
+ try
+ {
+ // Set the colour of the text to white
+ xCellCursorProps.setPropertyValue( "CharColor", Integer.valueOf(16777215));
+ }
+ catch ( Exception e)
+ {
+ e.printStackTrace();
+ }
+ // Set the text in the cell to sText
+ xCellText.setString( sText );
+ }
+
+ /** This method shows how to create and insert a text table, as well as insert
+ text and formulae into the cells of the table
+ */
+ protected void TextTableExample ()
+ {
+ try
+ {
+ // Create a new table from the document's factory
+ XTextTable xTable = UnoRuntime.queryInterface(
+ XTextTable.class, mxDocFactory .createInstance(
+ "com.sun.star.text.TextTable" ) );
+
+ // Specify that we want the table to have 4 rows and 4 columns
+ xTable.initialize( 4, 4 );
+
+ // Insert the table into the document
+ mxDocText.insertTextContent( mxDocCursor, xTable, false);
+ // Get an XIndexAccess of the table rows
+ XIndexAccess xRows = xTable.getRows();
+
+ // Access the property set of the first row (properties listed in
+ // service description: com.sun.star.text.TextTableRow)
+ XPropertySet xRow = UnoRuntime.queryInterface(
+ XPropertySet.class, xRows.getByIndex ( 0 ) );
+ // If BackTransparent is false, then the background color is visible
+ xRow.setPropertyValue( "BackTransparent", Boolean.FALSE);
+ // Specify the color of the background to be dark blue
+ xRow.setPropertyValue( "BackColor", Integer.valueOf(6710932));
+
+ // Access the property set of the whole table
+ XPropertySet xTableProps = UnoRuntime.queryInterface(
+ XPropertySet.class, xTable );
+ // We want visible background colors
+ xTableProps.setPropertyValue( "BackTransparent", Boolean.FALSE);
+ // Set the background colour to light blue
+ xTableProps.setPropertyValue( "BackColor", Integer.valueOf(13421823));
+
+ // set the text (and text colour) of all the cells in the first row
+ // of the table
+ insertIntoCell( "A1", "First Column", xTable );
+ insertIntoCell( "B1", "Second Column", xTable );
+ insertIntoCell( "C1", "Third Column", xTable );
+ insertIntoCell( "D1", "Results", xTable );
+
+ // Insert random numbers into the first this three cells of each
+ // remaining row
+ xTable.getCellByName( "A2" ).setValue( getRandomDouble() );
+ xTable.getCellByName( "B2" ).setValue( getRandomDouble() );
+ xTable.getCellByName( "C2" ).setValue( getRandomDouble() );
+
+ xTable.getCellByName( "A3" ).setValue( getRandomDouble() );
+ xTable.getCellByName( "B3" ).setValue( getRandomDouble() );
+ xTable.getCellByName( "C3" ).setValue( getRandomDouble() );
+
+ xTable.getCellByName( "A4" ).setValue( getRandomDouble() );
+ xTable.getCellByName( "B4" ).setValue( getRandomDouble() );
+ xTable.getCellByName( "C4" ).setValue( getRandomDouble() );
+
+ // Set the last cell in each row to be a formula that calculates
+ // the sum of the first three cells
+ xTable.getCellByName( "D2" ).setFormula( "sum <A2:C2>" );
+ xTable.getCellByName( "D3" ).setFormula( "sum <A3:C3>" );
+ xTable.getCellByName( "D4" ).setFormula( "sum <A4:C4>" );
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+ /** This method shows how to create and manipulate text frames
+ */
+ protected void TextFrameExample ()
+ {
+ try
+ {
+ // Use the document's factory to create a new text frame and
+ // immediately access its XTextFrame interface
+ XTextFrame xFrame = UnoRuntime.queryInterface (
+ XTextFrame.class, mxDocFactory.createInstance (
+ "com.sun.star.text.TextFrame" ) );
+
+ // Access the XShape interface of the TextFrame
+ XShape xShape = UnoRuntime.queryInterface(XShape.class, xFrame);
+ // Access the XPropertySet interface of the TextFrame
+ XPropertySet xFrameProps = UnoRuntime.queryInterface(
+ XPropertySet.class, xFrame );
+
+ // Set the size of the new Text Frame using the XShape's 'setSize'
+ // method
+ Size aSize = new Size();
+ aSize.Height = 400;
+ aSize.Width = 15000;
+ xShape.setSize(aSize);
+ // Set the AnchorType to
+ // com.sun.star.text.TextContentAnchorType.AS_CHARACTER
+ xFrameProps.setPropertyValue( "AnchorType",
+ TextContentAnchorType.AS_CHARACTER );
+ // Go to the end of the text document
+ mxDocCursor.gotoEnd( false );
+ // Insert a new paragraph
+ mxDocText.insertControlCharacter (
+ mxDocCursor, ControlCharacter.PARAGRAPH_BREAK, false );
+ // Then insert the new frame
+ mxDocText.insertTextContent(mxDocCursor, xFrame, false);
+
+ // Access the XText interface of the text contained within the frame
+ XText xFrameText = xFrame.getText();
+ // Create a TextCursor over the frame's contents
+ XTextCursor xFrameCursor = xFrameText.createTextCursor();
+ // Insert some text into the frame
+ xFrameText.insertString(
+ xFrameCursor, "The first line in the newly created text frame.",
+ false );
+ xFrameText.insertString(
+ xFrameCursor, "\nThe second line in the new text frame.", false );
+ // Insert a paragraph break into the document (not the frame)
+ mxDocText.insertControlCharacter (
+ mxDocCursor, ControlCharacter.PARAGRAPH_BREAK, false );
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ /** This example demonstrates the use of the AutoTextContainer, AutoTextGroup
+ and AutoTextEntry services and shows how to create, insert and modify
+ auto text blocks
+ */
+ protected void AutoTextExample ()
+ {
+ try
+ {
+ // Go to the end of the document
+ mxDocCursor.gotoEnd( false );
+ // Insert two paragraphs
+ mxDocText.insertControlCharacter ( mxDocCursor,
+ ControlCharacter.PARAGRAPH_BREAK, false );
+ mxDocText.insertControlCharacter ( mxDocCursor,
+ ControlCharacter.PARAGRAPH_BREAK, false );
+ // Position the cursor in the second paragraph
+ XParagraphCursor xParaCursor = UnoRuntime.queryInterface(XParagraphCursor.class, mxDocCursor );
+ xParaCursor.gotoPreviousParagraph ( false );
+
+ // Get an XNameAccess interface to all auto text groups from the
+ // document factory
+ XNameAccess xContainer = UnoRuntime.queryInterface(
+ XNameAccess.class, mxFactory.createInstance (
+ "com.sun.star.text.AutoTextContainer" ) );
+
+ // Create a new table at the document factory
+ XTextTable xTable = UnoRuntime.queryInterface(
+ XTextTable.class, mxDocFactory .createInstance(
+ "com.sun.star.text.TextTable" ) );
+
+ // Store the names of all auto text groups in an array of strings
+ String[] aGroupNames = xContainer.getElementNames();
+
+ // Make sure we have at least one group name
+ if ( aGroupNames.length > 0 )
+ {
+ // initialise the table to have a row for every autotext group
+ // in a single column + one additional row for a header
+ xTable.initialize( aGroupNames.length+1,1);
+
+ // Access the XPropertySet of the table
+ XPropertySet xTableProps = UnoRuntime.queryInterface(
+ XPropertySet.class, xTable );
+
+ // We want a visible background
+ xTableProps.setPropertyValue( "BackTransparent",
+ Boolean.FALSE);
+
+ // We want the background to be light blue
+ xTableProps.setPropertyValue( "BackColor", Integer.valueOf(13421823));
+
+ // Inser the table into the document
+ mxDocText.insertTextContent( mxDocCursor, xTable, false);
+
+ // Get an XIndexAccess to all table rows
+ XIndexAccess xRows = xTable.getRows();
+
+ // Get the first row in the table
+ XPropertySet xRow = UnoRuntime.queryInterface(
+ XPropertySet.class, xRows.getByIndex ( 0 ) );
+
+ // We want the background of the first row to be visible too
+ xRow.setPropertyValue( "BackTransparent", Boolean.FALSE);
+
+ // And let's make it dark blue
+ xRow.setPropertyValue( "BackColor", Integer.valueOf(6710932));
+
+ // Put a description of the table contents into the first cell
+ insertIntoCell( "A1", "AutoText Groups", xTable);
+
+ // Create a table cursor pointing at the second cell in the first
+ // column
+ XTextTableCursor xTableCursor = xTable.createCursorByCellName("A2");
+
+ // Loop over the group names
+ for ( int i = 0 ; i < aGroupNames.length ; i ++ )
+ {
+ // Get the name of the current cell
+ String sCellName = xTableCursor.getRangeName ();
+
+ // Get the XText interface of the current cell
+ XText xCellText = UnoRuntime.queryInterface (
+ XText.class, xTable.getCellByName ( sCellName ) );
+
+ // Set the cell contents of the current cell to be
+ //the name of the of an autotext group
+ xCellText.setString ( aGroupNames[i] );
+
+ // Access the autotext group with this name
+ XAutoTextGroup xGroup = UnoRuntime.queryInterface (XAutoTextGroup.class,
+ xContainer.getByName(aGroupNames[i]));
+
+ // Get the titles of each autotext block in this group
+ String [] aBlockNames = xGroup.getTitles();
+
+ // Make sure that the autotext group contains at least one block
+ if ( aBlockNames.length > 0 )
+ {
+ // Split the current cell vertically into two separate cells
+ xTableCursor.splitRange ( (short) 1, false );
+
+ // Put the cursor in the newly created right hand cell
+ // and select it
+ xTableCursor.goRight ( (short) 1, false );
+
+ // Split this cell horizontally to make a separate cell
+ // for each Autotext block
+ if ( ( aBlockNames.length -1 ) > 0 )
+ xTableCursor.splitRange (
+ (short) (aBlockNames.length - 1), true );
+
+ // loop over the block names
+ for ( int j = 0 ; j < aBlockNames.length ; j ++ )
+ {
+ // Get the XText interface of the current cell
+ xCellText = UnoRuntime.queryInterface (
+ XText.class, xTable.getCellByName (
+ xTableCursor.getRangeName() ) );
+
+ // Set the text contents of the current cell to the
+ // title of an Autotext block
+ xCellText.setString ( aBlockNames[j] );
+
+ // Move the cursor down one cell
+ xTableCursor.goDown( (short)1, false);
+ }
+ }
+ // Go back to the cell we originally split
+ xTableCursor.gotoCellByName ( sCellName, false );
+
+ // Go down one cell
+ xTableCursor.goDown( (short)1, false);
+ }
+
+ XAutoTextGroup xGroup;
+ String [] aBlockNames;
+
+ // Add a depth so that we only generate 200 numbers before giving up
+ // on finding a random autotext group that contains autotext blocks
+ int nDepth = 0;
+ do
+ {
+ // Generate a random, positive number which is lower than
+ // the number of autotext groups
+ int nRandom = Math.abs ( maRandom.nextInt() %
+ aGroupNames.length );
+
+ // Get the autotext group at this name
+ xGroup = UnoRuntime.queryInterface (
+ XAutoTextGroup.class, xContainer.getByName (
+ aGroupNames[ nRandom ] ) );
+
+ // Fill our string array with the names of all the blocks in
+ // this group
+ aBlockNames = xGroup.getElementNames();
+
+ // increment our depth counter
+ ++nDepth;
+ }
+ while ( nDepth < 200 && aBlockNames.length == 0 );
+ // If we managed to find a group containing blocks...
+ if ( aBlockNames.length > 0 )
+ {
+ // Pick a random block in this group and get its
+ // XAutoTextEntry interface
+ int nRandom = Math.abs ( maRandom.nextInt()
+ % aBlockNames.length );
+ XAutoTextEntry xEntry = UnoRuntime.queryInterface (
+ XAutoTextEntry.class, xGroup.getByName (
+ aBlockNames[ nRandom ] ) );
+ // insert the modified autotext block at the end of the document
+ xEntry.applyTo ( mxDocCursor );
+
+ // Get the titles of all text blocks in this AutoText group
+ String [] aBlockTitles = xGroup.getTitles();
+
+ // Get the XNamed interface of the autotext group
+ XNamed xGroupNamed = UnoRuntime.queryInterface (
+ XNamed.class, xGroup );
+
+ // Output the short cut and title of the random block
+ //and the name of the group it's from
+ System.out.println ( "Inserted the Autotext '" +
+ aBlockTitles[nRandom]
+ + "', shortcut '" + aBlockNames[nRandom]
+ + "' from group '"
+ + xGroupNamed.getName());
+ }
+ }
+
+ // Go to the end of the document
+ mxDocCursor.gotoEnd( false );
+ // Insert new paragraph
+ mxDocText.insertControlCharacter (
+ mxDocCursor, ControlCharacter.PARAGRAPH_BREAK, false );
+
+ // Position cursor in new paragraph
+ xParaCursor.gotoPreviousParagraph ( false );
+
+ // Insert a string in the new paragraph
+ mxDocText.insertString ( mxDocCursor,
+ "Some text for a new autotext block", false );
+
+ // Go to the end of the document
+ mxDocCursor.gotoEnd( false );
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ /** This method demonstrates how to insert indexes and index marks
+ */
+ protected void IndexExample ()
+ {
+ try
+ {
+ // Go to the end of the document
+ mxDocCursor.gotoEnd( false );
+ // Insert a new paragraph and position the cursor in it
+ mxDocText.insertControlCharacter ( mxDocCursor,
+ ControlCharacter.PARAGRAPH_BREAK, false );
+ XParagraphCursor xParaCursor = UnoRuntime.queryInterface( XParagraphCursor.class, mxDocCursor );
+ xParaCursor.gotoPreviousParagraph ( false );
+
+ // Create a new ContentIndexMark and get its XPropertySet interface
+ XPropertySet xEntry = UnoRuntime.queryInterface(
+ XPropertySet.class,
+ mxDocFactory.createInstance("com.sun.star.text.ContentIndexMark"));
+
+ // Set the text to be displayed in the index
+ xEntry.setPropertyValue(
+ "AlternativeText", "Big dogs! Falling on my head!");
+
+ // The Level property _must_ be set
+ xEntry.setPropertyValue ( "Level", Short.valueOf( (short) 1 ) );
+
+ // Create a ContentIndex and access its XPropertySet interface
+ XPropertySet xIndex = UnoRuntime.queryInterface(
+ XPropertySet.class,
+ mxDocFactory.createInstance ( "com.sun.star.text.ContentIndex" ) );
+
+ // Again, the Level property _must_ be set
+ xIndex.setPropertyValue ( "Level", Short.valueOf( (short) 10 ) );
+
+ // Access the XTextContent interfaces of both the Index and the
+ // IndexMark
+ XTextContent xIndexContent = UnoRuntime.queryInterface(
+ XTextContent.class, xIndex );
+ XTextContent xEntryContent = UnoRuntime.queryInterface(
+ XTextContent.class, xEntry );
+
+ // Insert both in the document
+ mxDocText.insertTextContent ( mxDocCursor, xEntryContent, false );
+ mxDocText.insertTextContent ( mxDocCursor, xIndexContent, false );
+
+ // Get the XDocumentIndex interface of the Index
+ XDocumentIndex xDocIndex = UnoRuntime.queryInterface(
+ XDocumentIndex.class, xIndex );
+
+ // And call its update method
+ xDocIndex.update();
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ /** This method demonstrates how to create and insert reference marks, and
+ * GetReference Text Fields
+ */
+ protected void ReferenceExample ()
+ {
+ try
+ {
+ // Go to the end of the document
+ mxDocCursor.gotoEnd( false );
+
+ // Insert a paragraph break
+ mxDocText.insertControlCharacter (
+ mxDocCursor, ControlCharacter.PARAGRAPH_BREAK, false );
+
+ // Get the Paragraph cursor
+ XParagraphCursor xParaCursor = UnoRuntime.queryInterface( XParagraphCursor.class, mxDocCursor );
+
+ // Move the cursor into the new paragraph
+ xParaCursor.gotoPreviousParagraph ( false );
+
+ // Create a new ReferenceMark and get its XNamed interface
+ XNamed xRefMark = UnoRuntime.queryInterface(XNamed.class,
+ mxDocFactory.createInstance ("com.sun.star.text.ReferenceMark"));
+
+ // Set the name to TableHeader
+ xRefMark.setName ( "TableHeader" );
+
+ // Get the TextTablesSupplier interface of the document
+ XTextTablesSupplier xTableSupplier = UnoRuntime.queryInterface(XTextTablesSupplier.class, mxDoc);
+
+ // Get an XIndexAccess of TextTables
+ XIndexAccess xTables = UnoRuntime.queryInterface(
+ XIndexAccess.class, xTableSupplier.getTextTables());
+
+ // We've only inserted one table, so get the first one from index zero
+ XTextTable xTable = UnoRuntime.queryInterface (
+ XTextTable.class, xTables.getByIndex( 0 ) );
+
+ // Get the first cell from the table
+ XText xTableText = UnoRuntime.queryInterface(
+ XText.class, xTable.getCellByName ( "A1" ) );
+
+ // Get a text cursor for the first cell
+ XTextCursor xTableCursor = xTableText.createTextCursor();
+
+ // Get the XTextContent interface of the reference mark so we can
+ // insert it
+ XTextContent xContent = UnoRuntime.queryInterface (
+ XTextContent.class, xRefMark );
+
+ // Insert the reference mark into the first cell of the table
+ xTableText.insertTextContent ( xTableCursor, xContent, false );
+
+ // Create a 'GetReference' text field to refer to the reference mark
+ // we just inserted, and get its XPropertySet interface
+ XPropertySet xFieldProps = UnoRuntime.queryInterface(
+ XPropertySet.class, mxDocFactory.createInstance (
+ "com.sun.star.text.TextField.GetReference" ) );
+
+ // Get the XReferenceMarksSupplier interface of the document
+ XReferenceMarksSupplier xRefSupplier = UnoRuntime.queryInterface( XReferenceMarksSupplier.class, mxDoc );
+
+ // Get an XNameAccess which refers to all inserted reference marks
+ XNameAccess xMarks = UnoRuntime.queryInterface (
+ XNameAccess.class, xRefSupplier.getReferenceMarks() );
+
+ // Put the names of each reference mark into an array of strings
+ String[] aNames = xMarks.getElementNames();
+
+ // Make sure that at least 1 reference mark actually exists
+ // (well, we just inserted one!)
+ if ( aNames.length > 0 )
+ {
+ // Output the name of the first reference mark ('TableHeader')
+ System.out.println (
+ "GetReference text field inserted for ReferenceMark : "
+ + aNames[0] );
+
+ // Set the SourceName of the GetReference text field to
+ // 'TableHeader'
+ xFieldProps.setPropertyValue ( "SourceName", aNames[0] );
+
+ // specify that the source is a reference mark (could also be a
+ // footnote, bookmark or sequence field )
+ xFieldProps.setPropertyValue ( "ReferenceFieldSource",
+ Short.valueOf(ReferenceFieldSource.REFERENCE_MARK));
+
+ // We want the reference displayed as 'above' or 'below'
+ xFieldProps.setPropertyValue ( "ReferenceFieldPart",
+ Short.valueOf(ReferenceFieldPart.UP_DOWN));
+
+
+ // Get the XTextContent interface of the GetReference text field
+ XTextContent xRefContent = UnoRuntime.queryInterface(
+ XTextContent.class, xFieldProps );
+
+ // Go to the end of the document
+ mxDocCursor.gotoEnd( false );
+
+ // Make some text to precede the reference
+ mxDocText.insertString(mxDocText.getEnd(), "The table ", false);
+
+ // Insert the text field
+ mxDocText.insertTextContent(mxDocText.getEnd(), xRefContent, false);
+
+ // And some text after the reference...
+ mxDocText.insertString(mxDocText.getEnd(),
+ " contains the sum of some random numbers.", false );
+
+ // Refresh the document
+ XRefreshable xRefresh = UnoRuntime.queryInterface(
+ XRefreshable.class, mxDoc );
+ xRefresh.refresh();
+ }
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ /** This method demonstrates how to create and insert footnotes, and how to
+ access the XFootnotesSupplier interface of the document
+ */
+ protected void FootnoteExample ()
+ {
+ try
+ {
+ // Create a new footnote from the document factory and get its
+ // XFootnote interface
+ XFootnote xFootnote = UnoRuntime.queryInterface(
+ XFootnote.class, mxDocFactory.createInstance (
+ "com.sun.star.text.Footnote" ) );
+
+ // Set the label to 'Numbers'
+ xFootnote.setLabel ( "Numbers" );
+
+ // Get the footnotes XTextContent interface so we can...
+ XTextContent xContent = UnoRuntime.queryInterface (
+ XTextContent.class, xFootnote );
+
+ // ...insert it into the document
+ mxDocText.insertTextContent ( mxDocCursor, xContent, false );
+
+ // Get the XFootnotesSupplier interface of the document
+ XFootnotesSupplier xFootnoteSupplier = UnoRuntime.queryInterface(XFootnotesSupplier.class, mxDoc );
+
+ // Get an XIndexAccess interface to all footnotes
+ XIndexAccess xFootnotes = UnoRuntime.queryInterface (
+ XIndexAccess.class, xFootnoteSupplier.getFootnotes() );
+
+ // Get the XFootnote interface to the first footnote inserted ('Numbers')
+ XFootnote xNumbers = UnoRuntime.queryInterface (
+ XFootnote.class, xFootnotes.getByIndex( 0 ) );
+
+ // Get the XSimpleText interface to the Footnote
+ XSimpleText xSimple = UnoRuntime.queryInterface (
+ XSimpleText.class, xNumbers );
+
+ // Create a text cursor for the foot note text
+ XTextRange xRange = UnoRuntime.queryInterface (
+ XTextRange.class, xSimple.createTextCursor() );
+
+ // And insert the actual text of the footnote.
+ xSimple.insertString (
+ xRange, " The numbers were generated by using java.util.Random", false );
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ /** This method demonstrates how to create and manipulate shapes, and how to
+ access the draw page of the document to insert shapes
+ */
+ protected void DrawPageExample ()
+ {
+ try
+ {
+ // Go to the end of the document
+ mxDocCursor.gotoEnd( false );
+ // Insert two new paragraphs
+ mxDocText.insertControlCharacter(mxDocCursor,
+ ControlCharacter.PARAGRAPH_BREAK, false);
+ mxDocText.insertControlCharacter(mxDocCursor,
+ ControlCharacter.PARAGRAPH_BREAK, false);
+
+ // Get the XParagraphCursor interface of our document cursor
+ XParagraphCursor xParaCursor = UnoRuntime.queryInterface( XParagraphCursor.class, mxDocCursor );
+
+ // Position the cursor in the 2nd paragraph
+ xParaCursor.gotoPreviousParagraph ( false );
+
+ // Create a RectangleShape using the document factory
+ XShape xRect = UnoRuntime.queryInterface(
+ XShape.class, mxDocFactory.createInstance (
+ "com.sun.star.drawing.RectangleShape" ) );
+
+ // Create an EllipseShape using the document factory
+ XShape xEllipse = UnoRuntime.queryInterface(
+ XShape.class, mxDocFactory.createInstance (
+ "com.sun.star.drawing.EllipseShape" ) );
+
+ // Set the size of both the ellipse and the rectangle
+ Size aSize = new Size();
+ aSize.Height = 4000;
+ aSize.Width = 10000;
+ xRect.setSize(aSize);
+ aSize.Height = 3000;
+ aSize.Width = 6000;
+ xEllipse.setSize ( aSize );
+
+ // Set the position of the Rectangle to the right of the ellipse
+ Point aPoint = new Point();
+ aPoint.X = 6100;
+ aPoint.Y = 0;
+ xRect.setPosition ( aPoint );
+
+ // Get the XPropertySet interfaces of both shapes
+ XPropertySet xRectProps = UnoRuntime.queryInterface(
+ XPropertySet.class, xRect );
+ XPropertySet xEllipseProps = UnoRuntime.queryInterface(
+ XPropertySet.class, xEllipse );
+
+ // And set the AnchorTypes of both shapes to 'AT_PARAGRAPH'
+ xRectProps.setPropertyValue ( "AnchorType",
+ TextContentAnchorType.AT_PARAGRAPH );
+ xEllipseProps.setPropertyValue ( "AnchorType",
+ TextContentAnchorType.AT_PARAGRAPH );
+
+ // Access the XDrawPageSupplier interface of the document
+ XDrawPageSupplier xDrawPageSupplier = UnoRuntime.queryInterface (XDrawPageSupplier.class, mxDoc );
+
+ // Get the XShapes interface of the draw page
+ XShapes xShapes = UnoRuntime.queryInterface (
+ XShapes.class, xDrawPageSupplier.getDrawPage () );
+
+ // Add both shapes
+ xShapes.add ( xEllipse );
+ xShapes.add ( xRect );
+
+ /*
+ This doesn't work, I am assured that FME and AMA are fixing it.
+
+ XShapes xGrouper = (XShapes) UnoRuntime.queryInterface(
+ XShapes.class, mxDocFactory.createInstance (
+ "com.sun.star.drawing.GroupShape" ) );
+
+ XShape xGrouperShape = (XShape) UnoRuntime.queryInterface(
+ XShape.class, xGrouper );
+ xShapes.add ( xGrouperShape );
+
+ xGrouper.add ( xRect );
+ xGrouper.add ( xEllipse );
+
+ XShapeGrouper xShapeGrouper = (XShapeGrouper)
+ UnoRuntime.queryInterface(XShapeGrouper.class, xShapes);
+ xShapeGrouper.group ( xGrouper );
+ */
+
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ /** This method demonstrates how to create, insert and apply styles
+ */
+ protected void StylesExample ()
+ {
+ try
+ {
+ // Go to the end of the document
+ mxDocCursor.gotoEnd( false );
+
+ // Insert two paragraph breaks
+ mxDocText.insertControlCharacter (
+ mxDocCursor, ControlCharacter.PARAGRAPH_BREAK, false );
+ mxDocText.insertControlCharacter (
+ mxDocCursor, ControlCharacter.PARAGRAPH_BREAK, false );
+
+ // Create a new style from the document's factory
+ XStyle xStyle = UnoRuntime.queryInterface(
+ XStyle.class, mxDocFactory.createInstance(
+ "com.sun.star.style.ParagraphStyle" ) );
+
+ // Access the XPropertySet interface of the new style
+ XPropertySet xStyleProps = UnoRuntime.queryInterface(
+ XPropertySet.class, xStyle );
+
+ // Give the new style a light blue background
+ xStyleProps.setPropertyValue ( "ParaBackColor", Integer.valueOf(13421823));
+
+ // Get the StyleFamiliesSupplier interface of the document
+ XStyleFamiliesSupplier xSupplier = UnoRuntime.queryInterface(XStyleFamiliesSupplier.class, mxDoc);
+
+ // Use the StyleFamiliesSupplier interface to get the XNameAccess
+ // interface of the actual style families
+ XNameAccess xFamilies = UnoRuntime.queryInterface (
+ XNameAccess.class, xSupplier.getStyleFamilies() );
+
+ // Access the 'ParagraphStyles' Family
+ XNameContainer xFamily = UnoRuntime.queryInterface (
+ XNameContainer.class,
+ xFamilies.getByName ( "ParagraphStyles" ) );
+
+ // Insert the newly created style into the ParagraphStyles family
+ xFamily.insertByName ( "All-Singing All-Dancing Style", xStyle );
+
+ // Get the XParagraphCursor interface of the document cursor
+ XParagraphCursor xParaCursor = UnoRuntime.queryInterface( XParagraphCursor.class, mxDocCursor );
+
+ // Select the first paragraph inserted
+ xParaCursor.gotoPreviousParagraph ( false );
+ xParaCursor.gotoPreviousParagraph ( true );
+
+ // Access the property set of the cursor selection
+ XPropertySet xCursorProps = UnoRuntime.queryInterface(
+ XPropertySet.class, mxDocCursor );
+
+ // Set the style of the cursor selection to our newly created style
+ xCursorProps.setPropertyValue ( "ParaStyleName",
+ "All-Singing All-Dancing Style" );
+
+ // Go back to the end
+ mxDocCursor.gotoEnd ( false );
+
+ // Select the last paragraph in the document
+ xParaCursor.gotoNextParagraph ( true );
+
+ // And reset its style to 'Standard' (the programmatic name for
+ // the default style)
+ xCursorProps.setPropertyValue ( "ParaStyleName", "Standard" );
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ /** This method demonstrates how to set numbering types and numbering levels
+ using the com.sun.star.text.NumberingRules service
+ */
+ protected void NumberingExample ()
+ {
+ try
+ {
+ // Go to the end of the document
+ mxDocCursor.gotoEnd( false );
+ // Get the RelativeTextContentInsert interface of the document
+ XRelativeTextContentInsert xRelative =
+ UnoRuntime.queryInterface (
+ XRelativeTextContentInsert.class, mxDocText );
+
+ // Use the document's factory to create the NumberingRules service,
+ // and get its XIndexAccess interface
+ XIndexAccess xNum = UnoRuntime.queryInterface(
+ XIndexAccess.class,
+ mxDocFactory.createInstance( "com.sun.star.text.NumberingRules" ) );
+
+ // Also get the NumberingRule's XIndexReplace interface
+ XIndexReplace xReplace = UnoRuntime.queryInterface(
+ XIndexReplace.class, xNum );
+
+ // Create an array of XPropertySets, one for each of the three
+ // paragraphs we're about to create
+ XPropertySet xParas[] = new XPropertySet [ 3 ];
+ for ( int i = 0 ; i < 3 ; ++ i )
+ {
+ // Create a new paragraph
+ XTextContent xNewPara = UnoRuntime.queryInterface(
+ XTextContent.class, mxDocFactory.createInstance(
+ "com.sun.star.text.Paragraph" ) );
+
+ // Get the XPropertySet interface of the new paragraph and put
+ // it in our array
+ xParas[i] = UnoRuntime.queryInterface(
+ XPropertySet.class, xNewPara );
+
+ // Insert the new paragraph into the document after the fish
+ // section. As it is an insert relative to the fish section, the
+ // first paragraph inserted will be below the next two
+ xRelative.insertTextContentAfter ( xNewPara, mxFishSection );
+
+ // Separate from the above, but also needs to be done three times
+
+ // Get the PropertyValue sequence for this numbering level
+ PropertyValue [] aProps = (PropertyValue [] ) xNum.getByIndex ( i );
+
+ // Iterate over the PropertyValue's for this numbering level,
+ // looking for the 'NumberingType' property
+ for ( int j = 0 ; j < aProps.length ; ++j )
+ {
+ if ( aProps[j].Name.equals ( "NumberingType" ) )
+ {
+ // Once we find it, set its value to a new type,
+ // dependent on which numbering level we're currently on
+ switch ( i )
+ {
+ case 0 : aProps[j].Value =
+ Short.valueOf(NumberingType.ROMAN_UPPER);
+ break;
+ case 1 : aProps[j].Value =
+ Short.valueOf(NumberingType.CHARS_UPPER_LETTER);
+ break;
+ case 2 : aProps[j].Value =
+ Short.valueOf(NumberingType.ARABIC);
+ break;
+ }
+ // Put the updated PropertyValue sequence back into the
+ // NumberingRules service
+ xReplace.replaceByIndex ( i, aProps );
+ break;
+ }
+ }
+ }
+ // Get the XParagraphCursor interface of our text cursor
+ XParagraphCursor xParaCursor = UnoRuntime.queryInterface( XParagraphCursor.class, mxDocCursor );
+ // Go to the end of the document, then select the preceding paragraphs
+ mxDocCursor.gotoEnd ( false );
+ xParaCursor.gotoPreviousParagraph ( false );
+ xParaCursor.gotoPreviousParagraph ( true );
+ xParaCursor.gotoPreviousParagraph ( true );
+
+ // Get the XPropertySet of the cursor's currently selected text
+ XPropertySet xCursorProps = UnoRuntime.queryInterface(
+ XPropertySet.class, mxDocCursor );
+
+ // Set the updated Numbering rules to the cursor's property set
+ xCursorProps.setPropertyValue ( "NumberingRules", xNum );
+ mxDocCursor.gotoEnd( false );
+
+ // Set the first paragraph that was inserted to a numbering level of
+ // 2 (thus it will have Arabic style numbering)
+ xParas[0].setPropertyValue ( "NumberingLevel", Short.valueOf((short) 2));
+
+ // Set the second paragraph that was inserted to a numbering level of
+ // 1 (thus it will have 'Chars Upper Letter' style numbering)
+ xParas[1].setPropertyValue ( "NumberingLevel", Short.valueOf((short) 1));
+
+ // Set the third paragraph that was inserted to a numbering level of
+ // 0 (thus it will have 'Chars Upper Letter' style numbering)
+ xParas[2].setPropertyValue ( "NumberingLevel", Short.valueOf((short) 0));
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ /** This method demonstrates how to create linked and unlinked sections
+ */
+ protected void TextSectionExample ()
+ {
+ try
+ {
+ // Go to the end of the document
+ mxDocCursor.gotoEnd( false );
+ // Insert two paragraph breaks
+ mxDocText.insertControlCharacter (
+ mxDocCursor, ControlCharacter.PARAGRAPH_BREAK, false );
+ mxDocText.insertControlCharacter (
+ mxDocCursor, ControlCharacter.PARAGRAPH_BREAK, true );
+
+ // Create a new TextSection from the document factory and access
+ // its XNamed interface
+ XNamed xChildNamed = UnoRuntime.queryInterface(
+ XNamed.class, mxDocFactory.createInstance(
+ "com.sun.star.text.TextSection" ) );
+ // Set the new sections name to 'Child_Section'
+ xChildNamed.setName ( "Child_Section" );
+
+ // Access the Child_Section's XTextContent interface and insert it
+ // into the document
+ XTextContent xChildSection = UnoRuntime.queryInterface(
+ XTextContent.class, xChildNamed );
+ mxDocText.insertTextContent ( mxDocCursor, xChildSection, false );
+
+ // Access the XParagraphCursor interface of our text cursor
+ XParagraphCursor xParaCursor = UnoRuntime.queryInterface(XParagraphCursor.class, mxDocCursor);
+
+ // Go back one paragraph (into Child_Section)
+ xParaCursor.gotoPreviousParagraph ( false );
+
+ // Insert a string into the Child_Section
+ mxDocText.insertString ( mxDocCursor, "This is a test", false );
+
+ // Go to the end of the document
+ mxDocCursor.gotoEnd( false );
+
+ // Go back two paragraphs
+ xParaCursor.gotoPreviousParagraph ( false );
+ xParaCursor.gotoPreviousParagraph ( false );
+ // Go to the end of the document, selecting the two paragraphs
+ mxDocCursor.gotoEnd ( true );
+
+ // Create another text section and access its XNamed interface
+ XNamed xParentNamed = UnoRuntime.queryInterface(XNamed.class,
+ mxDocFactory.createInstance("com.sun.star.text.TextSection"));
+
+ // Set this text section's name to Parent_Section
+ xParentNamed.setName ( "Parent_Section" );
+
+ // Access the Parent_Section's XTextContent interface ...
+ XTextContent xParentSection = UnoRuntime.queryInterface(
+ XTextContent.class, xParentNamed );
+ // ...and insert it into the document
+ mxDocText.insertTextContent ( mxDocCursor, xParentSection, false );
+
+ // Go to the end of the document
+ mxDocCursor.gotoEnd ( false );
+ // Insert a new paragraph
+ mxDocText.insertControlCharacter (
+ mxDocCursor, ControlCharacter.PARAGRAPH_BREAK, false );
+ // And select the new paragraph
+ xParaCursor.gotoPreviousParagraph ( true );
+
+ // Create a new Text Section and access its XNamed interface
+ XNamed xLinkNamed = UnoRuntime.queryInterface(XNamed.class,
+ mxDocFactory.createInstance("com.sun.star.text.TextSection"));
+ // Set the new text section's name to Linked_Section
+ xLinkNamed.setName ( "Linked_Section" );
+
+ // Access the Linked_Section's XTextContent interface
+ XTextContent xLinkedSection = UnoRuntime.queryInterface(
+ XTextContent.class, xLinkNamed );
+ // And insert the Linked_Section into the document
+ mxDocText.insertTextContent ( mxDocCursor, xLinkedSection, false );
+
+ // Access the Linked_Section's XPropertySet interface
+ XPropertySet xLinkProps = UnoRuntime.queryInterface(
+ XPropertySet.class, xLinkNamed );
+ // Set the linked section to be linked to the Child_Section
+ xLinkProps.setPropertyValue ( "LinkRegion", "Child_Section" );
+
+ // Access the XPropertySet interface of the Child_Section
+ XPropertySet xChildProps = UnoRuntime.queryInterface(
+ XPropertySet.class, xChildNamed );
+ // Set the Child_Section's background colour to blue
+ xChildProps.setPropertyValue( "BackColor", Integer.valueOf(13421823));
+
+ // Refresh the document, so the linked section matches the Child_Section
+ XRefreshable xRefresh = UnoRuntime.queryInterface(
+ XRefreshable.class, mxDoc );
+ xRefresh.refresh();
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ /** This method demonstrates the XTextColumns interface and how to insert a
+ blank paragraph using the XRelativeTextContentInsert interface
+ */
+ protected void TextColumnsExample ()
+ {
+ try
+ {
+ // Go to the end of the document
+ mxDocCursor.gotoEnd( false );
+ // insert a new paragraph
+ mxDocText.insertControlCharacter (
+ mxDocCursor, ControlCharacter.PARAGRAPH_BREAK, false );
+
+ // insert the string 'I am a fish.' 100 times
+ for ( int i = 0 ; i < 100 ; ++i )
+ {
+ mxDocText.insertString ( mxDocCursor, "I am a fish.", false );
+ }
+ // insert a paragraph break after the text
+ mxDocText.insertControlCharacter (
+ mxDocCursor, ControlCharacter.PARAGRAPH_BREAK, false );
+
+ // Get the XParagraphCursor interface of our text cursor
+ XParagraphCursor xParaCursor = UnoRuntime.queryInterface( XParagraphCursor.class, mxDocCursor );
+ // Jump back before all the text we just inserted
+ xParaCursor.gotoPreviousParagraph ( false );
+ xParaCursor.gotoPreviousParagraph ( false );
+
+ // Insert a string at the beginning of the block of text
+ mxDocText.insertString ( mxDocCursor, "Fish section begins:", false );
+
+ // Then select all of the text
+ xParaCursor.gotoNextParagraph ( true );
+ xParaCursor.gotoNextParagraph ( true );
+
+ // Create a new text section and get its XNamed interface
+ XNamed xSectionNamed = UnoRuntime.queryInterface(XNamed.class,
+ mxDocFactory.createInstance("com.sun.star.text.TextSection"));
+
+ // Set the name of our new section (appropriately) to 'Fish'
+ xSectionNamed.setName ( "Fish" );
+
+ // Create the TextColumns service and get its XTextColumns interface
+ XTextColumns xColumns = UnoRuntime.queryInterface(
+ XTextColumns.class,
+ mxDocFactory.createInstance ( "com.sun.star.text.TextColumns" ) );
+
+ // We want three columns
+ xColumns.setColumnCount ( (short) 3 );
+
+ // Get the TextColumns, and make the middle one narrow with a larger
+ // margin on the left than the right
+ TextColumn[] aSequence = xColumns.getColumns ();
+ aSequence[1].Width /= 2;
+ aSequence[1].LeftMargin = 350;
+ aSequence[1].RightMargin = 200;
+ // Set the updated TextColumns back to the XTextColumns
+ xColumns.setColumns ( aSequence );
+
+ // Get the property set interface of our 'Fish' section
+ XPropertySet xSectionProps = UnoRuntime.queryInterface(
+ XPropertySet.class, xSectionNamed );
+
+ // Set the columns to the Text Section
+ xSectionProps.setPropertyValue ( "TextColumns", xColumns );
+
+ // Get the XTextContent interface of our 'Fish' section
+ mxFishSection = UnoRuntime.queryInterface(
+ XTextContent.class, xSectionNamed );
+
+ // Insert the 'Fish' section over the currently selected text
+ mxDocText.insertTextContent ( mxDocCursor, mxFishSection, true );
+
+ // Get the wonderful XRelativeTextContentInsert interface
+ XRelativeTextContentInsert xRelative = UnoRuntime.queryInterface (
+ XRelativeTextContentInsert.class, mxDocText );
+
+ // Create a new empty paragraph and get its XTextContent interface
+ XTextContent xNewPara = UnoRuntime.queryInterface(
+ XTextContent.class,
+ mxDocFactory.createInstance("com.sun.star.text.Paragraph"));
+
+ // Insert the empty paragraph after the fish Text Section
+ xRelative.insertTextContentAfter ( xNewPara, mxFishSection );
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/Text/TextTemplateWithUserFields.odt b/odk/examples/DevelopersGuide/Text/TextTemplateWithUserFields.odt
new file mode 100644
index 000000000..7c6814039
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Text/TextTemplateWithUserFields.odt
Binary files differ
diff --git a/odk/examples/DevelopersGuide/UCB/ChildrenRetriever.java b/odk/examples/DevelopersGuide/UCB/ChildrenRetriever.java
new file mode 100644
index 000000000..102119dfc
--- /dev/null
+++ b/odk/examples/DevelopersGuide/UCB/ChildrenRetriever.java
@@ -0,0 +1,338 @@
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+import java.util.ArrayList;
+import java.util.StringTokenizer;
+
+import com.sun.star.beans.Property;
+import com.sun.star.sdbc.XResultSet;
+import com.sun.star.sdbc.XRow;
+import com.sun.star.ucb.OpenCommandArgument2;
+import com.sun.star.ucb.OpenMode;
+import com.sun.star.ucb.XContent;
+import com.sun.star.ucb.XContentAccess;
+import com.sun.star.ucb.XDynamicResultSet;
+import com.sun.star.uno.UnoRuntime;
+
+/**
+ * Retrieve the Children of a UCB Folder Content
+ */
+public class ChildrenRetriever {
+
+ /**
+ * Member properties
+ */
+ private Helper m_helper;
+ private XContent m_content;
+ private String m_contenturl = "";
+ private ArrayList<String> m_propnames = new ArrayList<String>();
+
+ /**
+ * Constructor. Create a new connection with the specific args to a running office
+ *
+ *@param args This constructor requires the arguments:
+ * -url=... (optional)
+ * -propNames=... (optional)
+ * See Help (method printCmdLineUsage()).
+ * Without the arguments a new connection to a
+ * running office cannot created.
+ */
+ public ChildrenRetriever( String args[] ) throws java.lang.Exception {
+
+ // Parse arguments
+ parseArguments( args );
+
+ // Init
+ m_helper = new Helper( getContentURL() );
+
+ // Create UCB content
+ m_content = m_helper.createUCBContent();
+ }
+
+ /**
+ * Open a folder content, get properties values.
+ * This method requires the main and the optional arguments to be set in order to work.
+ * See Constructor.
+ *
+ *@return Returns children properties values if values successfully retrieved,
+ * null otherwise
+ */
+ public ArrayList<ArrayList<Object>> getChildren()
+ throws com.sun.star.ucb.CommandAbortedException, com.sun.star.uno.Exception {
+ ArrayList<String> properties = getProperties();
+ return getChildren ( properties );
+ }
+
+ /**
+ * Open a folder content, get properties values for the properties.
+ *
+ *@return Returns children properties values if values successfully retrieved,
+ * null otherwise
+ */
+ public ArrayList<ArrayList<Object>> getChildren( ArrayList<String> properties )
+ throws com.sun.star.ucb.CommandAbortedException, com.sun.star.uno.Exception {
+
+ ArrayList<ArrayList<Object>> result = null;
+ if ( m_content != null ) {
+ int size = 0;
+ if ( properties != null && !properties.isEmpty()) {
+ size = properties.size();
+ }
+ // Fill info for the properties wanted.
+ Property[] props = new Property[ size ];
+ for ( int index = 0 ; index < size; index++ ) {
+
+ // Define property sequence.
+ Property prop = new Property();
+ prop.Name = properties.get( index );
+ prop.Handle = -1; // n/a
+ props[ index ] = prop;
+ }
+
+ // Fill argument structure...
+ OpenCommandArgument2 arg = new OpenCommandArgument2();
+ arg.Mode = OpenMode.ALL; // FOLDER, DOCUMENTS -> simple filter
+ arg.Priority = 32768; // static final for 32768
+ arg.Properties = props;
+
+ XDynamicResultSet set;
+
+ // Execute command "open".
+ set = UnoRuntime.queryInterface(
+ XDynamicResultSet.class, m_helper.executeCommand( m_content, "open", arg ));
+ XResultSet resultSet = set.getStaticResultSet();
+
+ result = new ArrayList<ArrayList<Object>>();
+
+
+ // Iterate over children, access children and property values...
+
+
+ // Move to begin.
+ if ( resultSet.first() ) {
+ XContentAccess contentAccess = UnoRuntime.queryInterface(
+ XContentAccess.class, resultSet );
+ XRow row = UnoRuntime.queryInterface( XRow.class, resultSet );
+
+ do {
+ ArrayList<Object> propsValues = new ArrayList<Object>();
+
+ // Obtain URL of child.
+ String id = contentAccess.queryContentIdentifierString();
+ propsValues.add( id );
+ for ( int i = 1; i <= size ; i++) {
+ Object propValue = row.getObject( i, null );
+ if ( !row.wasNull() && !(propValue instanceof com.sun.star.uno.Any )) {
+ propsValues.add( propValue );
+ } else {
+ propsValues.add( "[ Property not found ]" );
+ }
+ }
+ result.add( propsValues );
+ } while ( resultSet.next() ); // next child
+ }
+ }
+ return result;
+ }
+
+ /**
+ * Get connect URL.
+ *
+ *@return String That contains the connect URL
+ */
+ public String getContentURL() {
+ return m_contenturl;
+ }
+
+ /**
+ * Get the properties.
+ *
+ *@return String That contains the properties
+ */
+ public ArrayList<String> getProperties() {
+ return m_propnames;
+ }
+
+ /**
+ * Parse arguments
+ *
+ *@param args Arguments
+ */
+ public void parseArguments( String[] args ) throws java.lang.Exception {
+
+ for ( int i = 0; i < args.length; i++ ) {
+ if ( args[i].startsWith( "-url=" )) {
+ m_contenturl = args[i].substring( 5 );
+ } else if ( args[i].startsWith( "-propNames=" )) {
+ StringTokenizer tok
+ = new StringTokenizer( args[i].substring( 11 ), ";" );
+
+ while ( tok.hasMoreTokens() )
+ m_propnames.add( tok.nextToken() );
+
+ } else if ( args[i].startsWith( "-help" ) ||
+ args[i].startsWith( "-?" )) {
+ printCmdLineUsage();
+ System.exit( 0 );
+ }
+ }
+
+ if ( m_contenturl == null || m_contenturl.equals( "" )) {
+ m_contenturl = "file:///";
+ }
+
+ if ( m_propnames.size() == 0 ) {
+ m_propnames.add( "Title" );
+ m_propnames.add( "IsDocument" );
+ }
+ }
+
+ /**
+ * Print the commands options
+ */
+ public void printCmdLineUsage() {
+ System.out.println(
+ "Usage : ChildrenRetriever -url=... -propNames=..." );
+ System.out.println(
+ "Defaults: -url=file:/// -propNames=Title,IsDocument" );
+ System.out.println(
+ "\nExample : -url=file:///temp/ -propNames=Title;IsFolder;IsDocument" );
+ }
+
+ /**
+ * Print all properties out contained in vector .
+ */
+ public void printLine( ArrayList<Object> props ) {
+ int limit;
+ while ( !props.isEmpty() ) {
+ String print = "";
+ int size = props.size();
+ for ( int i = 0; i < size; i++ ) {
+ limit = 15;
+ Object obj = props.get( i );
+ if ( obj != null) {
+ String prop = obj.toString();
+ int leng = prop.length();
+ if ( leng < limit ) {
+ for ( int l = leng; l < limit; l++) {
+ prop += " ";
+ }
+ print+= prop + " ";
+ props.set( i, null );
+ } else {
+ String temp1 = prop.substring( 0, limit );
+ String temp2 = prop.substring( limit );
+ print+= temp1 + " ";
+ props.set( i, temp2 );
+ }
+ } else {
+ for ( int l = 0; l < limit; l++) {
+ print += " ";
+ }
+ print+= " ";
+ }
+ }
+ System.out.println( print );
+ boolean isEmpty = true;
+ for ( int i = 0; i < size; i++ ) {
+ Object obj = props.get( i );
+ if( obj != null )
+ isEmpty = false;
+ }
+ if( isEmpty )
+ props.clear();
+ }
+ }
+
+ /**
+ * Create a new connection with the specific args to a running office and
+ * access the children from a folder.
+ */
+ public static void main ( String args[] ) {
+
+ System.out.println( "\n" );
+ System.out.println(
+ "-----------------------------------------------------------------" );
+ System.out.println(
+ "ChildrenRetriever - obtains the children of a folder resource." );
+ System.out.println(
+ "-----------------------------------------------------------------" );
+
+ try {
+ ChildrenRetriever access = new ChildrenRetriever( args );
+
+ // Get the properties Title and IsFolder for the children.
+ ArrayList<ArrayList<Object>> result = access.getChildren();
+
+ String tempPrint = "\nChildren of resource " + access.getContentURL();
+ int size = tempPrint.length();
+ System.out.println( tempPrint );
+ tempPrint = "";
+ for( int i = 0; i < size; i++ ) {
+ tempPrint += "-";
+ }
+ System.out.println( tempPrint );
+
+ if ( result != null && !result.isEmpty() ) {
+
+ ArrayList<Object> cont = new ArrayList<Object>();
+ cont.add("URL:");
+ ArrayList<String> props = access.getProperties();
+ size = props.size();
+ for ( int i = 0; i < size; i++ ) {
+ Object obj = props.get( i );
+ String prop = obj.toString();
+ cont.add( prop + ":" );
+ }
+ access.printLine(cont);
+ System.out.println( "\n" );
+ for ( ArrayList<Object> propsV : result ) {
+ access.printLine( propsV );
+ }
+ }
+ } catch ( com.sun.star.ucb.ResultSetException e ) {
+ System.out.println( "Error: " + e );
+ } catch ( com.sun.star.ucb.CommandAbortedException e ) {
+ System.out.println( "Error: " + e );
+ } catch ( com.sun.star.uno.Exception e ) {
+ System.out.println( "Error: " + e );
+ } catch ( java.lang.Exception e ) {
+ System.out.println( "Error: " + e );
+ }
+ System.exit( 0 );
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/UCB/DataStreamComposer.java b/odk/examples/DevelopersGuide/UCB/DataStreamComposer.java
new file mode 100644
index 000000000..ce6edae31
--- /dev/null
+++ b/odk/examples/DevelopersGuide/UCB/DataStreamComposer.java
@@ -0,0 +1,246 @@
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+import com.sun.star.ucb.InsertCommandArgument;
+import com.sun.star.ucb.XContent;
+import com.sun.star.io.XInputStream;
+
+/**
+ * Setting (Storing) the Content Data Stream of a UCB Document Content.
+ */
+public class DataStreamComposer {
+
+ /**
+ * Member properties
+ */
+ private Helper m_helper;
+ private XContent m_content;
+ private String m_contenturl = "";
+ private String m_srcURL = "";
+
+
+ /**
+ * Constructor.
+ *
+ *@param args This constructor requires the arguments:
+ * -url=... (optional)
+ * -srcURL=... (optional)
+ * -workdir=... (optional)
+ * See Help (method printCmdLineUsage()).
+ * Without the arguments a new connection to a
+ * running office cannot created.
+ */
+ public DataStreamComposer( String args[] ) throws java.lang.Exception {
+
+ // Parse arguments
+ parseArguments( args );
+
+ // Init
+ m_helper = new Helper( getContentURL() );
+
+ // Create UCB content
+ m_content = m_helper.createUCBContent();
+ }
+
+ /**
+ * Write the document data stream of a document content.
+ * This method requires the main and the optional arguments to be set in order to work.
+ * See Constructor.
+ *
+ *@return boolean Result
+ */
+ public boolean setDataStream()
+ throws com.sun.star.ucb.CommandAbortedException,
+ com.sun.star.uno.Exception,
+ java.lang.Exception {
+
+ String sourceURL = getSourceURL();
+ return ( setDataStream( sourceURL ));
+ }
+
+ /**
+ * Write the document data stream of a document content.
+ *
+ *@param sourceURL Source URL
+ *@return true if data stream successfully seted, false otherwise
+ */
+ public boolean setDataStream( String sourceURL )
+ throws com.sun.star.ucb.CommandAbortedException,
+ com.sun.star.uno.Exception,
+ java.lang.Exception {
+
+ XInputStream stream;
+ if ( sourceURL == null || sourceURL.equals("") ) {
+ stream = new MyInputStream();
+ } else {
+ String[] args = new String[ 1 ];
+ args[ 0 ] = "-url=" + sourceURL;
+ DataStreamRetriever access = new DataStreamRetriever( args );
+ stream = access.getDataStream();
+ }
+ return ( setDataStream( stream ));
+ }
+
+ /**
+ * Write the document data stream of a document content...
+ *
+ *@return boolean Returns true if data stream successfully seted, false otherwise
+ */
+ public boolean setDataStream( XInputStream stream )
+ throws com.sun.star.ucb.CommandAbortedException, com.sun.star.uno.Exception {
+
+ boolean result = false;
+ XInputStream data = stream;
+ if ( data != null && m_content != null ) {
+
+ // Fill argument structure...
+ InsertCommandArgument arg = new InsertCommandArgument();
+ arg.Data = data;
+ arg.ReplaceExisting = true;
+
+ // Execute command "insert".
+ m_helper.executeCommand( m_content, "insert", arg );
+ result = true;
+ }
+ return result;
+ }
+
+ /**
+ * Get source URL.
+ *
+ *@return String That contains the source URL
+ */
+ public String getSourceURL() {
+ return m_srcURL;
+ }
+
+ /**
+ * Get connect URL.
+ *
+ *@return String That contains the connect URL
+ */
+ public String getContentURL() {
+ return m_contenturl;
+ }
+
+ /**
+ * Parse arguments
+ */
+ public void parseArguments( String[] args ) throws java.lang.Exception {
+
+ String workdir = "";
+
+ for ( int i = 0; i < args.length; i++ ) {
+ if ( args[i].startsWith( "-url=" )) {
+ m_contenturl = args[i].substring( 5 );
+ } else if ( args[i].startsWith( "-srcURL=" )) {
+ m_srcURL = args[i].substring( 9 );
+ } else if ( args[i].startsWith( "-workdir=" )) {
+ workdir = args[i].substring( 9 );
+ } else if ( args[i].startsWith( "-help" ) ||
+ args[i].startsWith( "-?" )) {
+ printCmdLineUsage();
+ System.exit( 0 );
+ }
+ }
+
+ if ( m_contenturl == null || m_contenturl.equals( "" )) {
+ m_contenturl = Helper.createTargetDataFile( workdir );
+ }
+
+ if ( m_srcURL == null || m_srcURL.equals( "" )) {
+ m_srcURL = Helper.prependCurrentDirAsAbsoluteFileURL( "data/data.txt" );
+ }
+ }
+
+ /**
+ * Print the commands options
+ */
+ public void printCmdLineUsage() {
+ System.out.println(
+ "Usage : DataStreamComposer -url=... -srcURL=... -workdir=..." );
+ System.out.println(
+ "Defaults: -url=<workdir>/resource-<uniquepostfix> -srcURL=<currentdir>/data/data.txt -workdir=<currentdir>" );
+ System.out.println(
+ "\nExample : -url=file:///temp/my.txt -srcURL=file:///temp/src.txt " );
+ }
+
+
+ /**
+ * Create a new connection with the specific args to a running office and
+ * set the Content Data Stream of a UCB Document Content.
+ */
+ public static void main ( String args[] ) {
+ System.out.println( "\n" );
+ System.out.println(
+ "-----------------------------------------------------------------" );
+ System.out.println(
+ "DataStreamComposer - sets the data stream of a document resource." );
+ System.out.println(
+ " The data stream is obtained from another (the source) document " );
+ System.out.println(
+ " resource before." );
+ System.out.println(
+ "-----------------------------------------------------------------" );
+ try {
+
+ DataStreamComposer dataStream = new DataStreamComposer( args );
+ String sourceURL = dataStream.getSourceURL();
+ boolean result = dataStream.setDataStream( sourceURL );
+ if ( result ) {
+ System.out.println(
+ "\nSetting data stream succeeded.\n Source URL: " +
+ dataStream.getSourceURL() +
+ "\n Target URL: " +
+ dataStream.getContentURL() );
+ } else {
+ System.out.println(
+ "\nSetting data stream failed. \n Source URL: " +
+ dataStream.getSourceURL() +
+ "\n Target URL: " +
+ dataStream.getContentURL() );
+ }
+ } catch ( com.sun.star.ucb.CommandAbortedException e ) {
+ System.out.println( "Error: " + e );
+ } catch ( com.sun.star.uno.Exception e ) {
+ System.out.println( "Error: " + e );
+ } catch ( java.lang.Exception e ) {
+ System.out.println( "Error: " + e );
+ }
+ System.exit( 0 );
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/UCB/DataStreamRetriever.java b/odk/examples/DevelopersGuide/UCB/DataStreamRetriever.java
new file mode 100644
index 000000000..5644af0c2
--- /dev/null
+++ b/odk/examples/DevelopersGuide/UCB/DataStreamRetriever.java
@@ -0,0 +1,227 @@
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+import com.sun.star.ucb.OpenCommandArgument2;
+import com.sun.star.ucb.OpenMode;
+import com.sun.star.ucb.XContent;
+import com.sun.star.io.XActiveDataSink;
+import com.sun.star.io.XInputStream;
+
+/**
+ * Accessing (Loading) the Content Data Stream of a UCB Document Content
+ */
+public class DataStreamRetriever {
+
+ /**
+ * Member properties
+ */
+ private Helper m_helper;
+ private XContent m_content;
+ private String m_contenturl = "";
+
+ /**
+ * Constructor.
+ *
+ *@param args This constructor requires the arguments:
+ * -url=... (optional)
+ * See Help (method printCmdLineUsage()).
+ * Without the arguments a new connection to a
+ * running office cannot created.
+ */
+ public DataStreamRetriever( String args[] ) throws java.lang.Exception {
+
+ // Parse arguments
+ parseArguments( args );
+
+ // Init
+ m_helper = new Helper( getContentURL() );
+
+ // Create UCB content
+ m_content = m_helper.createUCBContent();
+ }
+
+ /**
+ * Read the document data stream of a document content using a
+ * XActiveDataSink implementation as data sink...
+ *
+ *@return XInputStream Returns input stream if stream successfully retrieved,
+ * null otherwise
+ */
+ public XInputStream getDataStream()
+ throws com.sun.star.ucb.CommandAbortedException, com.sun.star.uno.Exception {
+
+ XInputStream data = null;
+ if ( m_content != null ) {
+
+ // Fill argument structure...
+ OpenCommandArgument2 arg = new OpenCommandArgument2();
+ arg.Mode = OpenMode.DOCUMENT;
+ arg.Priority = 32768; // static final for 32768
+
+ // Create data sink implementation object.
+ XActiveDataSink dataSink = new MyActiveDataSink();
+ arg.Sink = dataSink;
+
+ // Execute command "open". The implementation of the command will
+ // supply an XInputStream implementation to the data sink.
+ m_helper.executeCommand( m_content, "open", arg );
+
+ // Get input stream supplied by the open command implementation.
+ data = dataSink.getInputStream();
+ }
+ return data;
+ }
+
+ /**
+ * Get connect URL.
+ *
+ *@return String That contains the connect URL
+ */
+ public String getContentURL() {
+ return m_contenturl;
+ }
+
+ /**
+ * Parse arguments
+ *
+ *@param args Arguments
+ */
+ private void parseArguments( String[] args ) throws java.lang.Exception {
+
+ for ( int i = 0; i < args.length; i++ ) {
+ if ( args[i].startsWith( "-url=" )) {
+ m_contenturl = args[i].substring( 5 );
+ } else if ( args[i].startsWith( "-help" ) ||
+ args[i].startsWith( "-?" )) {
+ printCmdLineUsage();
+ System.exit( 0 );
+ }
+ }
+
+ if ( m_contenturl == null || m_contenturl.equals( "" )) {
+ m_contenturl = Helper.prependCurrentDirAsAbsoluteFileURL( "data/data.txt" );
+ }
+ }
+
+ /**
+ * Print the commands options
+ */
+ private void printCmdLineUsage() {
+ System.out.println(
+ "Usage : DataStreamRetriever -url=..." );
+ System.out.println(
+ "Defaults: -url=<currentdir>/data/data.txt" );
+ System.out.println(
+ "\nExample : -url=file:///temp/my.txt" );
+ }
+
+ /**
+ * Print Stream content.
+ */
+ private void printStream( XInputStream data )
+ throws com.sun.star.uno.Exception {
+
+
+ // Read data from input stream...65536
+
+
+ // Data buffer. Will be allocated by input stream implementation!
+ byte[][] buffer = new byte[ 1 ][ 65536 ];
+ int read = data.readSomeBytes( buffer, 65536 );
+ System.out.println( "Read bytes : " + read );
+ System.out.println( "Read data (only first 64K displayed): ");
+ while ( read > 0 ) {
+ byte[] bytes = new byte[ read ];
+ for( int i = 0; i < read; i++ ) {
+ bytes[ i ] = buffer[ 0 ][ i ];
+ }
+ System.out.println( new String(bytes) );
+
+ // Process data contained in buffer.
+ read = data.readSomeBytes( buffer, 65536 );
+ }
+ }
+
+ /**
+ * Create a new connection with the specific args to a running office and
+ * access (Load) the content data stream of a UCB document content.
+ */
+ public static void main ( String args[] ) {
+ System.out.println( "\n" );
+ System.out.println(
+ "-----------------------------------------------------------------------" );
+ System.out.println(
+ "DataStreamRetriever - obtains the data stream from a document resource." );
+ System.out.println(
+ "-----------------------------------------------------------------------" );
+
+ try {
+
+ DataStreamRetriever access = new DataStreamRetriever( args );
+ XInputStream data = access.getDataStream();
+ String url = access.getContentURL();
+ if ( data != null ) {
+ String tempPrint = "\nGetting data stream for resource " + url +
+ " succeeded.";
+ int size = tempPrint.length();
+ System.out.println( tempPrint );
+ tempPrint = "";
+ for( int i = 0; i < size; i++ ) {
+ tempPrint += "-";
+ }
+ System.out.println( tempPrint );
+ access.printStream( data );
+ } else {
+ System.out.println(
+ "Getting data stream for resource " + url + " failed." );
+ }
+ } catch ( com.sun.star.io.NotConnectedException e ) {
+ System.out.println( "Error: " + e );
+ } catch ( com.sun.star.io.BufferSizeExceededException e ) {
+ System.out.println( "Error: " + e );
+ } catch ( com.sun.star.io.IOException e ) {
+ System.out.println( "Error: " + e );
+ } catch ( com.sun.star.ucb.CommandAbortedException e ) {
+ System.out.println( "Error: " + e );
+ } catch ( com.sun.star.uno.Exception e ) {
+ System.out.println( "Error: " + e );
+ } catch ( java.lang.Exception e ) {
+ System.out.println( "Error: " + e );
+ }
+ System.exit( 0 );
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/UCB/Helper.java b/odk/examples/DevelopersGuide/UCB/Helper.java
new file mode 100644
index 000000000..846f942dd
--- /dev/null
+++ b/odk/examples/DevelopersGuide/UCB/Helper.java
@@ -0,0 +1,242 @@
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+import java.io.File;
+import java.io.FileOutputStream;
+
+import com.sun.star.ucb.Command;
+import com.sun.star.ucb.UniversalContentBroker;
+import com.sun.star.ucb.XContent;
+import com.sun.star.ucb.XContentProvider;
+import com.sun.star.ucb.XContentIdentifier;
+import com.sun.star.ucb.XContentIdentifierFactory;
+import com.sun.star.ucb.XCommandProcessor;
+
+import com.sun.star.uno.XInterface;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.XComponentContext;
+
+
+/**
+ * Helper for creating a new connection with the specific args to a running office.
+ */
+public class Helper {
+
+ /**
+ * Member properties
+ */
+ private XInterface m_ucb = null;
+ private String m_contenturl = null;
+ private static XComponentContext m_xContext = null;
+
+ /**
+ * Constructor, create a new instance of the ucb. UNO is bootstrapped and
+ * the remote office service manager is used to create the ucb. If necessary
+ * a new office process is started.
+ */
+ public Helper(String url) throws java.lang.Exception {
+ m_contenturl = url;
+
+ if (null == m_xContext ) {
+ // get the remote office component context
+ m_xContext = com.sun.star.comp.helper.Bootstrap.bootstrap();
+ System.out.println("Connected to a running office ...");
+ }
+
+ m_ucb = UnoRuntime.queryInterface(
+ XInterface.class, UniversalContentBroker.create(m_xContext));
+ }
+
+ /**
+ * Returns created identifier object for given URL...
+ *
+ *@return XContent Created identifier object for given URL
+ */
+ public XContent createUCBContent() throws java.lang.Exception {
+ return createUCBContent( getContentURL() );
+ }
+
+ /**
+ * Returned created identifier object for given URL.
+ *
+ *@param connectURL Connect URL. Example : -url=file:///
+ *@return Created identifier object for given URL
+ */
+ private XContent createUCBContent( String connectURL ) throws java.lang.Exception {
+ XContent content = null;
+ if ( connectURL != null && !connectURL.equals( "" )) {
+
+ // Obtain required UCB interfaces...
+ XContentIdentifierFactory idFactory
+ = UnoRuntime.queryInterface(
+ XContentIdentifierFactory.class, m_ucb );
+ XContentProvider provider
+ = UnoRuntime.queryInterface(
+ XContentProvider.class, m_ucb );
+
+ // Create identifier object for given URL.
+ XContentIdentifier id = idFactory.createContentIdentifier( connectURL );
+ content = provider.queryContent( id );
+ }
+ return content;
+ }
+
+ /**
+ * Get ucb instance.
+ *
+ *@return XInterface That contains the ucb instance
+ */
+ public XInterface getUCB() {
+ return m_ucb;
+ }
+
+ /**
+ * Get connect URL.
+ *
+ *@return String That contains the connect URL
+ */
+ public String getContentURL() {
+ return m_contenturl;
+ }
+
+ /**
+ * Executes a command.
+ *
+ *param XInterface
+ *param String
+ *param Object
+ *@return Object The result according to the specification of the command.
+ *@exception com.sun.star.ucb.CommandAbortedException
+ *@exception com.sun.star.uno.Exception
+ */
+ Object executeCommand( XInterface ifc, String commandName, Object argument )
+ throws com.sun.star.ucb.CommandAbortedException, com.sun.star.uno.Exception {
+
+
+ // Obtain command processor interface from given content.
+
+
+ XCommandProcessor cmdProcessor
+ = UnoRuntime.queryInterface(
+ XCommandProcessor.class, ifc );
+
+
+ // Assemble command to execute.
+
+
+ Command command = new Command();
+ command.Name = commandName;
+ command.Handle = -1; // not available
+ command.Argument = argument;
+
+ // Note: throws CommandAbortedException, Exception
+ return cmdProcessor.execute( command, 0, null );
+ }
+
+ public static String getAbsoluteFileURLFromSystemPath( String systemPath )
+ {
+ try
+ {
+ File file = new File( systemPath );
+ String url = file.toURI().toURL().toString();
+ if ( url.charAt( 6 ) != '/' ) { // file:/xxx vs. file:///xxxx
+ StringBuffer buf1 = new StringBuffer( "file:///" );
+ buf1.append( url.substring( 6 ) );
+ url = buf1.toString();
+ }
+ return url;
+ }
+ catch ( java.net.MalformedURLException e )
+ {
+ e.printStackTrace();
+ }
+ return "";
+ }
+
+ public static String prependCurrentDirAsAbsoluteFileURL( String relativeURL )
+ {
+ // get url of current dir.
+ String url = getAbsoluteFileURLFromSystemPath( "" );
+ StringBuffer buf = new StringBuffer( url );
+ if ( !url.endsWith( File.separator ) )
+ buf.append( File.separator );
+ buf.append( relativeURL );
+ return buf.toString();
+ }
+
+ public static String createTargetDataFile( String workDir )
+ {
+ try
+ {
+ StringBuffer buf = new StringBuffer();
+ if ( workDir != null && workDir.length() > 0 ) {
+ buf.append( workDir );
+ buf.append( File.separator );
+ }
+ buf.append( "resource-" );
+ buf.append( System.currentTimeMillis() );
+ File file = new File( buf.toString() );
+ String url = file.toURI().toURL().toString();
+ if ( url.charAt( 6 ) != '/' ) { // file:/xxx vs. file:///xxxx
+ StringBuffer buf1 = new StringBuffer( "file:///" );
+ buf1.append( url.substring( 6 ) );
+ url = buf1.toString();
+ }
+
+ try
+ {
+ file.createNewFile();
+ String content = "This is the content of a sample data file.";
+ FileOutputStream stream = new FileOutputStream( file );
+ stream.write( content.getBytes() );
+ stream.close();
+ }
+ catch ( java.io.IOException e )
+ {
+ e.printStackTrace();
+ }
+
+ return url;
+ }
+ catch ( java.net.MalformedURLException e )
+ {
+ e.printStackTrace();
+ }
+
+ return "";
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/UCB/Makefile b/odk/examples/DevelopersGuide/UCB/Makefile
new file mode 100644
index 000000000..22dd94bad
--- /dev/null
+++ b/odk/examples/DevelopersGuide/UCB/Makefile
@@ -0,0 +1,155 @@
+#*************************************************************************
+#
+# The Contents of this file are made available subject to the terms of
+# the BSD license.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+# 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+# contributors may be used to endorse or promote products derived
+# from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+# TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+# USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+#**************************************************************************
+# Builds the UCB examples of the Developers Guide.
+
+PRJ=../../..
+SETTINGS=$(PRJ)/settings
+
+include $(SETTINGS)/settings.mk
+include $(SETTINGS)/std.mk
+
+# Define non-platform/compiler specific settings
+EXAMPLE_NAME=UCBExamples
+OUT_APP_CLASS = $(OUT_CLASS)/$(EXAMPLE_NAME)
+OUT_APP_MISC = $(OUT_MISC)/$(EXAMPLE_NAME)
+
+APP1_NAME=ChildrenRetriever
+APP1_JAR=$(OUT_APP_CLASS)/$(APP1_NAME).jar
+APP2_NAME=DataStreamComposer
+APP2_JAR=$(OUT_APP_CLASS)/$(APP2_NAME).jar
+APP3_NAME=DataStreamRetriever
+APP3_JAR=$(OUT_APP_CLASS)/$(APP3_NAME).jar
+APP4_NAME=PropertiesComposer
+APP4_JAR=$(OUT_APP_CLASS)/$(APP4_NAME).jar
+APP5_NAME=PropertiesRetriever
+APP5_JAR=$(OUT_APP_CLASS)/$(APP5_NAME).jar
+APP6_NAME=ResourceCreator
+APP6_JAR=$(OUT_APP_CLASS)/$(APP6_NAME).jar
+APP7_NAME=ResourceManager
+APP7_JAR=$(OUT_APP_CLASS)/$(APP7_NAME).jar
+APP8_NAME=ResourceRemover
+APP8_JAR=$(OUT_APP_CLASS)/$(APP8_NAME).jar
+
+APP_JAVAFILES = \
+ Helper.java \
+ MyActiveDataSink.java \
+ MyInputStream.java
+
+APP_CLASSFILES = $(patsubst %.java,$(OUT_APP_CLASS)/%.class,$(APP_JAVAFILES))
+APP_CLASSNAMES = $(patsubst %.java,%.class,$(APP_JAVAFILES))
+
+SDK_CLASSPATH = $(subst $(EMPTYSTRING) $(PATH_SEPARATOR),$(PATH_SEPARATOR),$(CLASSPATH)\
+ $(PATH_SEPARATOR)$(OUT_APP_CLASS))
+
+OUT_APP_CLASS = $(OUT_CLASS)/$(EXAMPLE_NAME)
+
+# Targets
+.PHONY: ALL
+ALL : \
+ UCBExamples
+
+include $(SETTINGS)/stdtarget.mk
+
+$(APP_CLASSFILES) : $(APP_JAVAFILES)
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ $(SDK_JAVAC) $(JAVAC_FLAGS) -classpath "$(SDK_CLASSPATH)" -d $(OUT_APP_CLASS) $(APP_JAVAFILES)
+
+$(OUT_APP_CLASS)/%.class : %.java $(APP_CLASSFILES)
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ $(SDK_JAVAC) $(JAVAC_FLAGS) -classpath "$(SDK_CLASSPATH)" -d $(OUT_APP_CLASS) $<
+
+$(OUT_APP_CLASS)/$(APP2_NAME).class : $(APP2_NAME).java $(OUT_APP_CLASS)/DataStreamRetriever.class $(APP_CLASSFILES)
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ $(SDK_JAVAC) $(JAVAC_FLAGS) -classpath "$(SDK_CLASSPATH)" -d $(OUT_APP_CLASS) $<
+
+$(OUT_APP_CLASS)/$(APP6_NAME).class : $(APP6_NAME).java $(OUT_APP_CLASS)/DataStreamRetriever.class $(APP_CLASSFILES)
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ $(SDK_JAVAC) $(JAVAC_FLAGS) -classpath "$(SDK_CLASSPATH)" -d $(OUT_APP_CLASS) $<
+
+$(OUT_APP_CLASS)/%.mf :
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ @echo Main-Class: com.sun.star.lib.loader.Loader> $@
+ $(ECHOLINE)>> $@
+ @echo Name: com/sun/star/lib/loader/Loader.class>> $@
+ @echo Application-Class: $*>> $@
+
+$(OUT_APP_CLASS)/%.jar : $(OUT_APP_CLASS)/%.mf $(OUT_APP_CLASS)/%.class $(APP_CLASSFILES)
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ +cd $(subst /,$(PS),$(OUT_APP_CLASS)) && $(SDK_JAR) cvfm $(@F) $*.mf $*.class $(APP_CLASSNAMES)
+ +$(SDK_JAR) uvf $@ $(SDK_JAVA_UNO_BOOTSTRAP_FILES)
+
+$(APP2_JAR) : $(OUT_APP_CLASS)/$(APP2_NAME).mf $(OUT_APP_CLASS)/$(APP2_NAME).class $(OUT_APP_CLASS)/DataStreamRetriever.class $(APP_CLASSFILES)
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ +cd $(subst /,$(PS),$(OUT_APP_CLASS)) && $(SDK_JAR) cvfm $(@F) $(basename $(@F)).mf $(basename $(@F)).class DataStreamRetriever.class $(APP_CLASSNAMES)
+ +$(SDK_JAR) uvf $@ $(SDK_JAVA_UNO_BOOTSTRAP_FILES)
+
+$(APP6_JAR) : $(OUT_APP_CLASS)/$(APP6_NAME).mf $(OUT_APP_CLASS)/$(APP6_NAME).class $(OUT_APP_CLASS)/DataStreamRetriever.class $(APP_CLASSFILES)
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ +cd $(subst /,$(PS),$(OUT_APP_CLASS)) && $(SDK_JAR) cvfm $(@F) $(basename $(@F)).mf $(basename $(@F)).class DataStreamRetriever.class $(APP_CLASSNAMES)
+ +$(SDK_JAR) uvf $@ $(SDK_JAVA_UNO_BOOTSTRAP_FILES)
+
+
+$(APP1_JAR) : $(OUT_APP_CLASS)/$(APP1_NAME).mf $(OUT_APP_CLASS)/$(APP1_NAME).class
+$(APP2_JAR) : $(OUT_APP_CLASS)/$(APP2_NAME).mf $(OUT_APP_CLASS)/$(APP2_NAME).class
+$(APP3_JAR) : $(OUT_APP_CLASS)/$(APP3_NAME).mf $(OUT_APP_CLASS)/$(APP3_NAME).class
+$(APP4_JAR) : $(OUT_APP_CLASS)/$(APP4_NAME).mf $(OUT_APP_CLASS)/$(APP4_NAME).class
+$(APP5_JAR) : $(OUT_APP_CLASS)/$(APP5_NAME).mf $(OUT_APP_CLASS)/$(APP5_NAME).class
+$(APP6_JAR) : $(OUT_APP_CLASS)/$(APP6_NAME).mf $(OUT_APP_CLASS)/$(APP6_NAME).class
+$(APP7_JAR) : $(OUT_APP_CLASS)/$(APP7_NAME).mf $(OUT_APP_CLASS)/$(APP7_NAME).class
+$(APP8_JAR) : $(OUT_APP_CLASS)/$(APP8_NAME).mf $(OUT_APP_CLASS)/$(APP8_NAME).class
+
+UCBExamples : $(APP1_JAR) $(APP2_JAR) $(APP3_JAR) $(APP4_JAR) $(APP5_JAR) $(APP6_JAR) $(APP7_JAR) $(APP8_JAR)
+ @echo --------------------------------------------------------------------------------
+ @echo Please use one of the following commands to execute the examples!
+ @echo -
+ @echo $(MAKE) $(APP1_NAME).run
+ @echo $(MAKE) $(APP2_NAME).run
+ @echo $(MAKE) $(APP3_NAME).run
+ @echo $(MAKE) $(APP4_NAME).run
+ @echo $(MAKE) $(APP5_NAME).run
+ @echo $(MAKE) $(APP6_NAME).run
+ @echo $(MAKE) $(APP7_NAME).run
+ @echo $(MAKE) $(APP8_NAME).run
+ @echo --------------------------------------------------------------------------------
+
+%.run: $(OUT_APP_CLASS)/%.jar
+ -$(MKDIR) $(subst /,$(PS),$(OUT_APP_MISC))
+ $(SDK_JAVA) -Dcom.sun.star.lib.loader.unopath="$(OFFICE_PROGRAM_PATH)" -jar $< -workdir=$(OUT_APP_MISC)
+
+.PHONY: clean
+clean :
+ -$(DELRECURSIVE) $(subst /,$(PS),$(OUT_APP_CLASS))
diff --git a/odk/examples/DevelopersGuide/UCB/MyActiveDataSink.java b/odk/examples/DevelopersGuide/UCB/MyActiveDataSink.java
new file mode 100644
index 000000000..fcfadc7e4
--- /dev/null
+++ b/odk/examples/DevelopersGuide/UCB/MyActiveDataSink.java
@@ -0,0 +1,74 @@
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+import com.sun.star.io.XActiveDataSink;
+import com.sun.star.io.XInputStream;
+
+/**
+ * XActiveDataSink interface implementation. Makes it possible to read
+ * the corresponding object from an input stream.
+ */
+public class MyActiveDataSink implements XActiveDataSink {
+
+ /**
+ * Member properties
+ */
+ private XInputStream m_aStream = null;
+
+ /**
+ * Constructor
+ */
+ public MyActiveDataSink() {
+ super();
+ }
+
+ /**
+ * Plugs the input stream.
+ */
+ public void setInputStream( XInputStream aStream ) {
+ m_aStream = aStream;
+ }
+
+ /**
+ * Get the plugged stream.
+ *
+ *@return XInputStream The plugged stream
+ */
+ public XInputStream getInputStream() {
+ return m_aStream;
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/UCB/MyInputStream.java b/odk/examples/DevelopersGuide/UCB/MyInputStream.java
new file mode 100644
index 000000000..048f2950c
--- /dev/null
+++ b/odk/examples/DevelopersGuide/UCB/MyInputStream.java
@@ -0,0 +1,180 @@
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+import com.sun.star.io.BufferSizeExceededException;
+import com.sun.star.io.NotConnectedException;
+import com.sun.star.io.XInputStream;
+import com.sun.star.io.XSeekable;
+
+/**
+ * XInputStream interface implementation.
+ */
+public class MyInputStream implements XSeekable, XInputStream {
+
+ /**
+ * Member properties
+ */
+ private int offset = 0;
+ private int read = offset;
+ private byte[] bigbuffer;
+
+ /**
+ * Constructor
+ */
+ public MyInputStream() {
+ }
+
+ // XSeekable. Makes it possible to seek to a certain position within a stream.
+
+ /**
+ * Returns the length of the stream.
+ *
+ *@return long The length of the storage medium on which the stream works.
+ */
+ public synchronized long getLength()
+ throws com.sun.star.io.IOException,com.sun.star.uno.RuntimeException {
+ if ( bigbuffer != null ) {
+ return bigbuffer.length - offset;
+ } else {
+ return 0;
+ }
+ }
+
+ /**
+ * Returns the current offset of the stream.
+ *
+ *@return long The current offset in this stream.
+ */
+ public synchronized long getPosition()
+ throws com.sun.star.io.IOException,com.sun.star.uno.RuntimeException {
+ return read - offset ;
+ }
+
+ /**
+ * Changes the seek pointer to a new location relative to the beginning of the stream.
+ */
+ public synchronized void seek(long p0)
+ throws IllegalArgumentException, com.sun.star.io.IOException,
+ com.sun.star.uno.RuntimeException {
+ if( bigbuffer != null ) {
+ p0 +=offset;
+ read = ( int ) p0;
+ if( read < offset || read > bigbuffer.length )
+ throw new IllegalArgumentException();
+ }
+ }
+
+ // XInputStream. This is the basic interface to read data from a stream.
+
+ /**
+ * States how many bytes can be read or skipped without blocking.
+ *
+ *@return int If not available, then returned 0
+ */
+ public synchronized int available()
+ throws NotConnectedException, com.sun.star.io.IOException,
+ com.sun.star.uno.RuntimeException {
+ if( bigbuffer != null )
+ return ( bigbuffer.length - read );
+ else
+ return 0;
+ }
+
+ /**
+ * Closes the stream. .
+ */
+ public void closeInput()
+ throws NotConnectedException,com.sun.star.io.IOException,
+ com.sun.star.uno.RuntimeException {
+ read = -1;
+ }
+
+ /**
+ * Reads the specified number of bytes in the given sequence.
+ */
+ public synchronized int readBytes(byte[][] p0, int p1)
+ throws NotConnectedException, BufferSizeExceededException,
+ com.sun.star.io.IOException, com.sun.star.uno.RuntimeException {
+ if( bigbuffer != null ) {
+ if( read == -1 )
+ return 0;
+ int i = 0;
+ int available;
+ if ( p1 > bigbuffer.length - read )
+ available = bigbuffer.length - read;
+ else
+ available = p1;
+
+ p0[0] = new byte[p1];
+ while( available != 0 ) {
+ p0[0][i++] = bigbuffer[read++];
+ --available;
+ }
+ return i;
+ } else {
+ p0[0] = new byte[0];
+ return 0;
+ }
+ }
+
+ /**
+ * Reads the available number of bytes at maximum nMaxBytesToRead .
+ * This method blocks the thread until at least one byte is available.
+ */
+ public synchronized int readSomeBytes(byte[][] p0, int p1)
+ throws NotConnectedException,
+ BufferSizeExceededException,
+ com.sun.star.io.IOException,
+ com.sun.star.uno.RuntimeException {
+ return readBytes( p0,p1 );
+ }
+
+ /**
+ * Skips the next nBytesToSkip bytes (must be positive).
+ * It is up to the implementation whether this method is blocking the thread or not.
+ */
+ public synchronized void skipBytes(int p0)
+ throws NotConnectedException, BufferSizeExceededException,
+ com.sun.star.io.IOException, com.sun.star.uno.RuntimeException {
+ read += p0;
+ if( read > bigbuffer.length )
+ read = bigbuffer.length;
+
+ if( read < offset )
+ read = offset;
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/UCB/PropertiesComposer.java b/odk/examples/DevelopersGuide/UCB/PropertiesComposer.java
new file mode 100644
index 000000000..1ebc9cbaa
--- /dev/null
+++ b/odk/examples/DevelopersGuide/UCB/PropertiesComposer.java
@@ -0,0 +1,289 @@
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+import java.util.ArrayList;
+import java.util.StringTokenizer;
+
+import com.sun.star.beans.PropertyValue;
+import com.sun.star.ucb.XContent;
+
+/**
+ * Setting Property Values of a UCB Content
+ */
+public class PropertiesComposer {
+
+ /**
+ * Member properties
+ */
+ private Helper m_helper;
+ private XContent m_content;
+ private String m_contenturl = "";
+ private ArrayList<String> m_propNames = new ArrayList<String>();
+ private ArrayList<String> m_propValues = new ArrayList<String>();
+
+ /**
+ * Constructor.
+ *
+ *@param args This constructor requires the arguments:
+ * -url=... (optional)
+ * -propNames=... (optional)
+ * -propValues=... (optional)
+ * -workdir=... (optional)
+ * See Help (method printCmdLineUsage()).
+ * Without the arguments a new connection to a
+ * running office cannot created.
+ */
+ public PropertiesComposer( String args[] ) throws java.lang.Exception {
+
+ // Parse arguments
+ parseArguments( args );
+
+ // Init
+ m_helper = new Helper( getContentURL() );
+
+ // Create UCB content
+ m_content = m_helper.createUCBContent();
+ }
+
+ /**
+ * Set values of the properties.
+ * This method requires the main and the optional arguments to be set in order to work.
+ * See Constructor.
+ *
+ *@return Object[] Returns null or instance object of com.sun.star.uno.Any
+ * if values successfully seted, properties otherwise
+ */
+ public Object[] setProperties()
+ throws com.sun.star.ucb.CommandAbortedException, com.sun.star.uno.Exception {
+ ArrayList<String> properties = getProperties();
+ ArrayList<String> propertyValues = getPropertyValues();
+ return setProperties( properties, propertyValues );
+ }
+
+ /**
+ * Set values of the properties.
+ *
+ *@return Object[] Returns null or instance object of com.sun.star.uno.Any
+ * if values successfully seted, properties otherwise
+ */
+ public Object[] setProperties( ArrayList<String> properties, ArrayList<String> propertiesValues )
+ throws com.sun.star.ucb.CommandAbortedException, com.sun.star.uno.Exception {
+
+ Object[] result = null;
+ if ( m_content != null && !properties.isEmpty() &&
+ !propertiesValues.isEmpty() &&
+ properties.size() == propertiesValues.size() ) {
+
+ /*
+ **** This code is for unregistered properties. ****
+
+ XPropertyContainer xPropContainer
+ = (XPropertyContainer)UnoRuntime.queryInterface(
+ XPropertyContainer.class, m_content );
+
+ XPropertySetInfo xPropSetInfo = ( XPropertySetInfo )UnoRuntime.queryInterface(
+ XPropertySetInfo.class,
+ m_helper.executeCommand( m_content, "getPropertySetInfo", null ));
+ */
+
+ int size = properties.size();
+ PropertyValue[] props = new PropertyValue[ size ];
+ for ( int index = 0 ; index < size; index++ ) {
+ String propName = properties.get( index );
+ Object propValue = propertiesValues.get( index );
+
+ /*
+ **** This code is for unregistered properties. ****
+
+ if ( !xPropSetInfo.hasPropertyByName( propName )) {
+ xPropContainer.addProperty(
+ propName, PropertyAttribute.MAYBEVOID, propValue );
+ }
+ */
+
+ // Define property sequence.
+ PropertyValue prop = new PropertyValue();
+ prop.Name = propName;
+ prop.Handle = -1; // n/a
+ prop.Value = propValue;
+ props[ index ] = prop;
+ }
+
+ // Execute command "setPropertiesValues".
+ Object[] obj =
+ ( Object[] )m_helper.executeCommand( m_content, "setPropertyValues", props );
+ if ( obj.length == size )
+ result = obj;
+ }
+ return result;
+ }
+
+ /**
+ * Get properties names.
+ *
+ *@return Vector That contains the properties names
+ */
+ public ArrayList<String> getProperties() {
+ return m_propNames;
+ }
+
+ /**
+ * Get properties values.
+ *
+ *@return Vector That contains the properties values
+ */
+ public ArrayList<String> getPropertyValues() {
+ return m_propValues;
+ }
+
+ /**
+ * Get connect URL.
+ *
+ *@return String That contains the connect URL
+ */
+ public String getContentURL() {
+ return m_contenturl;
+ }
+
+ /**
+ * Parse arguments
+ */
+ public void parseArguments( String[] args ) throws java.lang.Exception {
+
+ String workdir = "";
+
+ for ( int i = 0; i < args.length; i++ ) {
+ if ( args[i].startsWith( "-url=" )) {
+ m_contenturl = args[i].substring( 5 );
+ } else if ( args[i].startsWith( "-propNames=" )) {
+ StringTokenizer tok
+ = new StringTokenizer( args[i].substring( 11 ), ";" );
+
+ while ( tok.hasMoreTokens() )
+ m_propNames.add( tok.nextToken() );
+
+ } else if ( args[i].startsWith( "-propValues=" )) {
+ StringTokenizer tok
+ = new StringTokenizer( args[i].substring( 12 ), ";" );
+
+ while ( tok.hasMoreTokens() )
+ m_propValues.add( tok.nextToken() );
+ } else if ( args[i].startsWith( "-workdir=" )) {
+ workdir = args[i].substring( 9 );
+ } else if ( args[i].startsWith( "-help" ) ||
+ args[i].startsWith( "-?" )) {
+ printCmdLineUsage();
+ System.exit( 0 );
+ }
+ }
+
+ if ( m_contenturl == null || m_contenturl.equals( "" )) {
+ m_contenturl = Helper.createTargetDataFile( workdir );
+ }
+
+ if ( m_propNames.size() == 0 ) {
+ m_propNames.add( "Title" );
+ }
+
+ if ( m_propValues.size() == 0 ) {
+ m_propValues.add(
+ "changed-" + m_contenturl.substring(
+ m_contenturl.lastIndexOf( "/" ) + 1 ) );
+ }
+ }
+
+ /**
+ * Print the commands options
+ */
+ public void printCmdLineUsage() {
+ System.out.println(
+ "Usage : PropertiesComposer -url=... -propNames=... -propValues=... -workdir=..." );
+ System.out.println(
+ "Defaults: -url=<workdir>/resource-<uniquepostfix> -propNames=Title -propValues=changed-<uniquepostfix> -workdir=<currentdir>" );
+ System.out.println(
+ "\nExample : -propNames=Title;Foo -propValues=MyRenamedFile.txt;bar" );
+ }
+
+ /**
+ * Create a new connection with the specific args to a running office and
+ * set properties of a resource.
+ */
+ public static void main ( String args[] ) {
+ System.out.println( "\n" );
+ System.out.println(
+ "--------------------------------------------------------" );
+ System.out.println(
+ "PropertiesComposer - sets property values of a resource." );
+ System.out.println(
+ "--------------------------------------------------------" );
+
+ try {
+
+ PropertiesComposer setProp = new PropertiesComposer( args );
+ ArrayList<String> properties = setProp.getProperties();
+ ArrayList<String> propertiesValues = setProp.getPropertyValues();
+ Object[] result = setProp.setProperties( properties, propertiesValues );
+
+ String tempPrint = "\nSetting properties of resource " + setProp.getContentURL();
+ int size = tempPrint.length();
+ System.out.println( tempPrint );
+ tempPrint = "";
+ for( int i = 0; i < size; i++ ) {
+ tempPrint += "-";
+ }
+ System.out.println( tempPrint );
+ if ( result != null ) {
+ for ( int index = 0; index < result.length; index++ ) {
+ Object obj = result[ index ];
+ if( obj == null || obj instanceof com.sun.star.uno.Any )
+ System.out.println(
+ "Setting property " + properties.get( index ) + " succeeded." );
+ else
+ System.out.println(
+ "Setting property " + properties.get( index ) + " failed." );
+ }
+ }
+ } catch ( com.sun.star.ucb.CommandAbortedException e ) {
+ System.out.println( "Error: " + e );
+ } catch ( com.sun.star.uno.Exception e ) {
+ System.out.println( "Error: " + e );
+ } catch ( java.lang.Exception e ) {
+ System.out.println( "Error: " + e );
+ }
+ System.exit( 0 );
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/UCB/PropertiesRetriever.java b/odk/examples/DevelopersGuide/UCB/PropertiesRetriever.java
new file mode 100644
index 000000000..641b1de86
--- /dev/null
+++ b/odk/examples/DevelopersGuide/UCB/PropertiesRetriever.java
@@ -0,0 +1,245 @@
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+import java.util.ArrayList;
+import java.util.StringTokenizer;
+
+import com.sun.star.beans.Property;
+import com.sun.star.sdbc.XRow;
+import com.sun.star.ucb.XContent;
+import com.sun.star.uno.UnoRuntime;
+
+
+/**
+ * Obtaining Property Values from a UCB Content
+ */
+public class PropertiesRetriever {
+
+ /**
+ * Member properties
+ */
+ private Helper m_helper;
+ private XContent m_content;
+ private String m_contenturl = "";
+ private ArrayList<String> m_propNames = new ArrayList<String>();
+
+ /**
+ * Constructor.
+ *
+ *@param args This constructor requires the arguments:
+ * -url=... (optional)
+ * -propNames=... (optional)
+ * See Help (method printCmdLineUsage()).
+ * Without the arguments a new connection to a
+ * running office cannot created.
+ */
+ public PropertiesRetriever( String args[] ) throws java.lang.Exception {
+
+ // Parse arguments
+ parseArguments( args );
+
+ // Init
+ m_helper = new Helper( getContentURL() );
+
+ // Create UCB content
+ m_content = m_helper.createUCBContent();
+ }
+
+ /**
+ * Get values of the properties.
+ * This method requires the main and the optional arguments to be set in order to work.
+ * See Constructor.
+ *
+ *@return Properties values if values successfully retrieved, null otherwise
+ */
+ public ArrayList<Object> getPropertyValues()
+ throws com.sun.star.ucb.CommandAbortedException, com.sun.star.uno.Exception {
+ ArrayList<String> properties = getProperties();
+ return getPropertyValues ( properties );
+ }
+
+ /**
+ * Get values of the properties.
+ *
+ *@return Properties values if values successfully retrieved, null otherwise
+ */
+ public ArrayList<Object> getPropertyValues( ArrayList<String> properties )
+ throws com.sun.star.ucb.CommandAbortedException, com.sun.star.uno.Exception {
+ ArrayList<Object> m_propValues = null;
+ if ( m_content != null && properties != null && !properties.isEmpty() ) {
+
+ int size = properties.size();
+
+ // Fill info for the properties wanted.
+ Property[] props = new Property[ size ];
+ for ( int index = 0 ; index < size; index++ ) {
+
+ // Define property sequence.
+ Property prop = new Property();
+ prop.Name = properties.get( index );
+ prop.Handle = -1; // n/a
+ props[ index ] = prop;
+ }
+
+ // Execute command "getPropertyValues".
+ XRow values =
+ UnoRuntime.queryInterface(
+ XRow.class, m_helper.executeCommand( m_content,"getPropertyValues", props ));
+
+ m_propValues = new ArrayList<Object>();
+
+ /*
+ Extract values from row object. Note that the
+ first column is 1, not 0.
+ Title: Obtain value of column 1 as string.*/
+ for ( int index = 1 ; index <= size; index++ ) {
+ Object propertyValue = values.getObject( index, null );
+ if ( !values.wasNull() && !(propertyValue instanceof com.sun.star.uno.Any ))
+ m_propValues.add( propertyValue );
+ else
+ m_propValues.add( "[ Property not found ]" );
+ }
+ }
+ return m_propValues;
+ }
+
+ /**
+ * Get connect URL.
+ *
+ *@return String That contains the connect URL
+ */
+ public String getContentURL() {
+ return m_contenturl;
+ }
+
+ /**
+ * Get the properties.
+ *
+ *@return Vector That contains the properties
+ */
+ public ArrayList<String> getProperties() {
+ return m_propNames;
+ }
+
+ /**
+ * Parse arguments
+ */
+ public void parseArguments( String[] args ) throws java.lang.Exception {
+
+ for ( int i = 0; i < args.length; i++ ) {
+ if ( args[i].startsWith( "-url=" )) {
+ m_contenturl = args[i].substring( 5 );
+ } else if ( args[i].startsWith( "-propNames=" )) {
+ StringTokenizer tok
+ = new StringTokenizer( args[i].substring( 11 ), ";" );
+
+ while ( tok.hasMoreTokens() )
+ m_propNames.add( tok.nextToken() );
+
+ } else if ( args[i].startsWith( "-help" ) ||
+ args[i].startsWith( "-?" )) {
+ printCmdLineUsage();
+ System.exit( 0 );
+ }
+ }
+
+ if ( m_contenturl == null || m_contenturl.equals( "" )) {
+ m_contenturl = Helper.prependCurrentDirAsAbsoluteFileURL( "data/data.txt" );
+ }
+
+ if ( m_propNames.size() == 0 ) {
+ m_propNames.add( "Title" );
+ m_propNames.add( "IsDocument" );
+ }
+ }
+
+ /**
+ * Print the commands options
+ */
+ public void printCmdLineUsage() {
+ System.out.println(
+ "Usage : PropertiesRetriever -url=... -propNames=..." );
+ System.out.println(
+ "Defaults: -url=<currentdir>/data/data.txt -propNames=Title;IsDocument" );
+ System.out.println(
+ "\nExample : -propNames=Title;IsFolder" );
+ }
+
+ /**
+ * Create a new connection with the specific args to a running office and
+ * get the properties values from a resource.
+ */
+ public static void main ( String args[] ) {
+ System.out.println( "\n" );
+ System.out.println(
+ "--------------------------------------------------------------" );
+ System.out.println(
+ "PropertiesRetriever - obtains property values from a resource." );
+ System.out.println(
+ "--------------------------------------------------------------" );
+ try {
+ PropertiesRetriever obtProperty = new PropertiesRetriever( args );
+ ArrayList<String> properties = obtProperty.getProperties();
+ ArrayList<Object> propertiesValues = obtProperty.getPropertyValues( properties );
+
+ String tempPrint = "\nProperties of resource " + obtProperty.getContentURL();
+ int size = tempPrint.length();
+ System.out.println( tempPrint );
+ tempPrint = "";
+ for( int i = 0; i < size; i++ ) {
+ tempPrint += "-";
+ }
+ System.out.println( tempPrint );
+
+ if ( properties != null && propertiesValues != null ) {
+ size = properties.size();
+ for (int index = 0; index < size ; index++ ) {
+ String property = properties.get( index );
+ Object propValue = propertiesValues.get( index );
+ System.out.println( property + " : " + propValue );
+ }
+ }
+ } catch ( com.sun.star.ucb.CommandAbortedException e ) {
+ System.out.println( "Error: " + e );
+ } catch ( com.sun.star.uno.Exception e ) {
+ System.out.println( "Error: " + e );
+ } catch ( java.lang.Exception e ) {
+ System.out.println( "Error: " + e );
+ }
+ System.exit( 0 );
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/UCB/ResourceCreator.java b/odk/examples/DevelopersGuide/UCB/ResourceCreator.java
new file mode 100644
index 000000000..0f7e2f200
--- /dev/null
+++ b/odk/examples/DevelopersGuide/UCB/ResourceCreator.java
@@ -0,0 +1,304 @@
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+import com.sun.star.beans.PropertyValue;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.ucb.ContentInfo;
+import com.sun.star.ucb.InsertCommandArgument;
+import com.sun.star.ucb.XContent;
+import com.sun.star.io.XInputStream;
+
+
+/**
+ * Creating a New Resource
+ */
+public class ResourceCreator {
+
+ /**
+ * Member properties
+ */
+ private Helper m_helper;
+ private XContent m_content;
+ private String m_contenturl = "";
+ private String m_name = "";
+ private String m_srcURL = "";
+
+ /**
+ * Constructor.
+ *
+ *@param args This constructor requires the arguments:
+ * -url=... (optional)
+ * -name=... (optional)
+ * -srcURL=... (optional)
+ * -workdir=... (optional)
+ * See Help (method printCmdLineUsage()).
+ * Without the arguments a new connection to a
+ * running office cannot created.
+ */
+ public ResourceCreator( String args[] ) throws java.lang.Exception {
+
+ // Parse arguments
+ parseArguments( args );
+ String url = getContentURL();
+
+ // Init
+ m_helper = new Helper( url );
+ if ( url.startsWith( "file:///" )) {
+
+ // Create UCB content
+ m_content = m_helper.createUCBContent();
+ } else {
+ throw new Exception(
+ "Create new resource : parameter 'url' must contain a File URL " +
+ "pointing to the file system folder in which the new resource " +
+ "shall be created. (Example: file:///tmp/)" );
+ }
+ }
+
+ /**
+ * Create a new resource.
+ * This method requires the main and the optional arguments to be set in order to work.
+ * See Constructor.
+ *
+ *@return boolean Returns true if resource successfully created, false otherwise
+ */
+ public boolean createNewResource()
+ throws com.sun.star.ucb.CommandAbortedException,
+ com.sun.star.uno.Exception,
+ java.lang.Exception {
+
+ String sourceURL = getSourceURL();
+ String name = getName();
+ return createNewResource( sourceURL, name );
+ }
+
+ /**
+ * Create a new resource.
+ *
+ *@param sourceURL Source resource URL
+ *@param name New resource name
+ *@return true if resource successfully created, false otherwise
+ */
+ public boolean createNewResource( String sourceURL, String name )
+ throws com.sun.star.ucb.CommandAbortedException,
+ com.sun.star.uno.Exception,
+ java.lang.Exception {
+
+ XInputStream stream = null;
+ if ( sourceURL == null || sourceURL.equals( "" )) {
+ stream = new MyInputStream();
+ } else {
+ String[] args = new String[ 1 ];
+ args[ 0 ] = "-url=" + sourceURL;
+ DataStreamRetriever access = new DataStreamRetriever( args );
+ stream = access.getDataStream();
+ }
+ return createNewResource( stream, name );
+ }
+
+ /**
+ * Create a new resource.
+ *
+ *@param stream Source resource stream
+ *@param name New resource name
+ *@return true if resource successfully created, false otherwise
+ */
+ public boolean createNewResource( XInputStream stream, String name )
+ throws com.sun.star.ucb.CommandAbortedException, com.sun.star.uno.Exception {
+
+ boolean result = false;
+ if ( stream != null && name != null && !name.equals( "" )) {
+
+ // Note: The data for info may have been obtained from
+ // property CreatableContentsInfo.
+ ContentInfo info = new ContentInfo();
+ info.Type = "application/vnd.sun.staroffice.fsys-file";
+ info.Attributes = 0;
+
+ // Create new, empty content (execute command "createNewContent").
+ XContent newContent = UnoRuntime.queryInterface(
+ XContent.class,
+ m_helper.executeCommand( m_content, "createNewContent", info ) );
+
+ if ( newContent != null ) {
+
+
+ // Set mandatory properties...
+
+
+ // Define property value sequence.
+ PropertyValue[] props = new PropertyValue[ 1 ];
+ PropertyValue prop = new PropertyValue();
+ prop.Name = "Title";
+ prop.Handle = -1; // n/a
+ prop.Value = name;
+ props[ 0 ] = prop;
+
+ // Execute command "setPropertyValues".
+ m_helper.executeCommand( newContent, "setPropertyValues", props );
+
+
+ // Write the new file to disk...
+
+
+ // Obtain document data for the new file.
+ XInputStream data = stream;
+
+ // Fill argument structure...
+ InsertCommandArgument arg = new InsertCommandArgument();
+ arg.Data = data;
+ arg.ReplaceExisting = false;
+
+ // Execute command "insert".
+ m_helper.executeCommand( newContent, "insert", arg );
+ result = true;
+ }
+ }
+ return result;
+ }
+
+ /**
+ * Get new resource name.
+ *
+ *@return String That contains the name
+ */
+ public String getName() {
+ return m_name;
+ }
+
+ /**
+ * Get source URL.
+ *
+ *@return String That contains the source URL
+ */
+ public String getSourceURL() {
+ return m_srcURL;
+ }
+
+ /**
+ * Get connect URL.
+ *
+ *@return String That contains the connect URL
+ */
+ public String getContentURL() {
+ return m_contenturl;
+ }
+
+ /**
+ * Parse arguments
+ */
+ public void parseArguments( String[] args ) throws java.lang.Exception {
+
+ String workdir = "";
+
+ for ( int i = 0; i < args.length; i++ ) {
+ if ( args[i].startsWith( "-url=" )) {
+ m_contenturl = args[i].substring( 5 );
+ } else if ( args[i].startsWith( "-name=" )) {
+ m_name = args[i].substring( 6 );
+ } else if ( args[i].startsWith( "-srcURL=" )) {
+ m_srcURL = args[i].substring( 8 );
+ } else if ( args[i].startsWith( "-workdir=" )) {
+ workdir = args[i].substring( 9 );
+ } else if ( args[i].startsWith( "-help" ) ||
+ args[i].startsWith( "-?" )) {
+ printCmdLineUsage();
+ System.exit( 0 );
+ }
+ }
+
+ if ( m_contenturl == null || m_contenturl.equals( "" )) {
+ m_contenturl = Helper.getAbsoluteFileURLFromSystemPath( workdir );
+ }
+
+ if ( m_name == null || m_name.equals( "" )) {
+ m_name = "created-resource-" + System.currentTimeMillis();
+ }
+
+ if ( m_srcURL == null || m_srcURL.equals( "" )) {
+ m_srcURL = Helper.prependCurrentDirAsAbsoluteFileURL( "data/data.txt" );
+ }
+ }
+
+ /**
+ * Print the commands options
+ */
+ public void printCmdLineUsage() {
+ System.out.println(
+ "Usage : ResourceCreator -url=... -name=... -srcURL=... -workdir=..." );
+ System.out.println(
+ "Defaults: -url=<workdir> -name=created-resource-<uniquepostfix> -srcURL=<currentdir>/data/data.txt> -workdir=<currentdir>" );
+ System.out.println(
+ "\nExample : -url=file:///home/kai/ -name=newfile.txt -srcURL=file:///home/kai/sourcefile.txt" );
+ }
+
+ /**
+ * Create a new connection with the specific args to a running office and
+ * create a new resource.
+ */
+ public static void main ( String args[] ) {
+ System.out.println( "\n" );
+ System.out.println(
+ "-----------------------------------------------------------------------" );
+ System.out.println(
+ "ResourceCreator - creates a new file in an existing file system folder." );
+ System.out.println(
+ " (Content for the new file can be retrieved from another file)." );
+ System.out.println(
+ "-----------------------------------------------------------------------" );
+ try {
+ ResourceCreator create = new ResourceCreator( args );
+ boolean result = create.createNewResource();
+ if ( result ) {
+ System.out.println(
+ "Creation of new resource " + create.getName() + " in folder: " +
+ create.getContentURL() + " succeeded." );
+ } else {
+ System.out.println(
+ "Creation of new resource " + create.getName() + " in folder: " +
+ create.getContentURL() + " failed." );
+ }
+ } catch ( com.sun.star.ucb.CommandAbortedException e ) {
+ System.out.println( "Error: " + e );
+ } catch ( com.sun.star.uno.Exception e ) {
+ System.out.println( "Error: " + e );
+ } catch ( java.lang.Exception e ) {
+ System.out.println( "Error: " + e );
+ }
+ System.exit( 0 );
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/UCB/ResourceManager.java b/odk/examples/DevelopersGuide/UCB/ResourceManager.java
new file mode 100644
index 000000000..61d64c8c0
--- /dev/null
+++ b/odk/examples/DevelopersGuide/UCB/ResourceManager.java
@@ -0,0 +1,280 @@
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+import com.sun.star.ucb.NameClash;
+import com.sun.star.ucb.TransferCommandOperation;
+import com.sun.star.ucb.GlobalTransferCommandArgument;
+import com.sun.star.uno.XInterface;
+
+/**
+ * Copying, Moving and Creating Links to a Resource
+ */
+public class ResourceManager {
+
+ /**
+ * Member properties
+ */
+ private Helper m_helper;
+ private XInterface m_ucb;
+ private String m_contenturl = "";
+ private String m_targetFolderURL = "";
+ private String m_newTitle = "";
+ private String m_transOperation = "";
+
+ /**
+ * Constructor.
+ *
+ *@param args This constructor requires the arguments:
+ * -url=... (optional)
+ * -targetFolderURL=... (optional)
+ * -newTitle=... (optional)
+ * -transOper=... (optional)
+ * -workdir=... (optional)
+ * See Help (method printCmdLineUsage()).
+ * Without the arguments a new connection to a
+ * running office cannot created.
+ */
+ public ResourceManager( String args[] ) throws java.lang.Exception {
+
+ // Parse arguments
+ parseArguments( args );
+
+ // Init
+ m_helper = new Helper( getContentURL() );
+
+ // Get xUCB
+ m_ucb = m_helper.getUCB();
+ }
+
+ /**
+ * Copy, move or create a link for a resource.
+ * This method requires the main and the optional arguments to be set in order to work.
+ * See Constructor.
+ *
+ *@return true if resource successfully transferred, false otherwise
+ */
+ public boolean transferResource()
+ throws com.sun.star.ucb.CommandAbortedException, com.sun.star.uno.Exception {
+ String sourceURL = getContentURL(); // URL of the source object
+ String targetFolderURL = getTargetFolderURL(); // URL of the target folder
+ String newTitle = getNewTitle(); // New name for the resource
+ String transOperation = getTransOperation();
+ return transferResource( sourceURL, targetFolderURL, newTitle, transOperation );
+ }
+
+ /**
+ * Copy, move or create a link for a resource.
+ *
+ *@param sourceURL Source URL
+ *@param targetFolderURL Target folder URL
+ *@param transOperation Transferring operation (copy, move, link)
+ *@return true if resource successfully transferred, false otherwise
+ */
+ public boolean transferResource(
+ String sourceURL, String targetFolderURL,
+ String newTitle, String transOperation )
+ throws com.sun.star.ucb.CommandAbortedException, com.sun.star.uno.Exception {
+
+ boolean result = false;
+ if ( m_ucb != null && sourceURL != null && !sourceURL.equals( "" ) &&
+ targetFolderURL != null && !targetFolderURL.equals( "" ) &&
+ newTitle != null && transOperation != null && !transOperation.equals( "" ) &&
+ ( transOperation.equals( "copy" ) || transOperation.equals( "move" ) ||
+ transOperation.equals( "link" ))) {
+
+
+ // Copy, move or create a link for a resource to another location...
+
+ GlobalTransferCommandArgument arg = new GlobalTransferCommandArgument();
+ if ( transOperation.equals( "copy" )) {
+ arg.Operation = TransferCommandOperation.COPY;
+ } else if ( transOperation.equals( "move" )) {
+ arg.Operation = TransferCommandOperation.MOVE;
+ } else if ( transOperation.equals( "link" )) {
+ arg.Operation = TransferCommandOperation.LINK;
+ }
+ arg.SourceURL = sourceURL;
+ arg.TargetURL = targetFolderURL;
+
+ // object get a new unique name
+ arg.NewTitle = newTitle;
+
+ // fail, if object with same name exists in target folder
+ arg.NameClash = NameClash.ERROR;
+
+ // Let UCB execute the command "globalTransfer".
+ m_helper.executeCommand( m_ucb, "globalTransfer", arg );
+ result = true;
+ }
+ return result;
+ }
+
+ /**
+ * Get connect URL.
+ *
+ *@return String That contains the connect URL
+ */
+ public String getContentURL() {
+ return m_contenturl;
+ }
+
+ /**
+ * Get transferring Operation.
+ *
+ *@return String That contains the transferring Operation
+ */
+ public String getTransOperation() {
+ return m_transOperation;
+ }
+
+ /**
+ * Get target folder URL.
+ *
+ *@return String That contains the target folder URL
+ */
+ public String getTargetFolderURL() {
+ return m_targetFolderURL;
+ }
+
+ /**
+ * Get new title for the resource to be transferred.
+ *
+ *@return String That contains a new title for the transferred
+ * resource. Can be empty. In this case resource
+ * will keep the title it has in the source folder.
+ */
+ public String getNewTitle() {
+ return m_newTitle;
+ }
+
+ /**
+ * Parse arguments
+ */
+ public void parseArguments( String[] args ) throws java.lang.Exception {
+
+ String workdir = "";
+
+ for ( int i = 0; i < args.length; i++ ) {
+ if ( args[i].startsWith( "-url=" )) {
+ m_contenturl = args[i].substring( 5 );
+ } else if ( args[i].startsWith( "-targetFolderURL=" )) {
+ m_targetFolderURL = args[i].substring( 17 );
+ } else if ( args[i].startsWith( "-newTitle=" )) {
+ m_newTitle = args[i].substring( 10 );
+ } else if ( args[i].startsWith( "-transOper=" )) {
+ m_transOperation = args[i].substring( 11 );
+ } else if ( args[i].startsWith( "-workdir=" )) {
+ workdir = args[i].substring( 9 );
+ } else if ( args[i].startsWith( "-help" ) ||
+ args[i].startsWith( "-?" )) {
+ printCmdLineUsage();
+ System.exit( 0 );
+ }
+ }
+
+ if ( m_contenturl == null || m_contenturl.equals( "" )) {
+ m_contenturl = Helper.prependCurrentDirAsAbsoluteFileURL( "data/data.txt" );
+ }
+
+ if ( m_targetFolderURL == null || m_targetFolderURL.equals( "" )) {
+ m_targetFolderURL = Helper.getAbsoluteFileURLFromSystemPath( workdir );
+ }
+
+ if ( m_newTitle == null || m_newTitle.equals( "" )) {
+ m_newTitle = "transferred-resource-" + System.currentTimeMillis();
+ }
+
+ if ( m_transOperation == null || m_transOperation.equals( "" )) {
+ m_transOperation = "copy";
+ }
+ }
+
+ /**
+ * Print the commands options
+ */
+ public void printCmdLineUsage() {
+ System.out.println(
+ "Usage: ResourceManager -url=... -targetFolderURL=... -newTitle=... -transOper=... -workdir=..." );
+ System.out.println(
+ "Defaults: -url=<currentdir>/data/data.txt> -targetFolderURL=<workdir> -newTitle=transferred-resource-<uniquepostfix> -transOper=copy -workdir=<currentdir>");
+ System.out.println(
+ "\nExample : -url=file:///temp/MyFile.txt -targetFolderURL=file:///test/ -newTitle=RenamedFile.txt -transOper=copy " );
+ }
+
+ /**
+ * Create a new connection with the specific args to a running office and
+ * copy, move or create links a resource.
+ */
+ public static void main ( String args[] ) {
+
+ System.out.println( "\n" );
+ System.out.println(
+ "-----------------------------------------------------------------" );
+ System.out.println(
+ "ResourceManager - copies/moves a resource." );
+ System.out.println(
+ "-----------------------------------------------------------------" );
+
+ try {
+ ResourceManager transResource = new ResourceManager( args );
+ String sourceURL = transResource.getContentURL();
+ String targetFolderURL = transResource.getTargetFolderURL();
+ String newTitle = transResource.getNewTitle();
+ String transOperation = transResource.getTransOperation();
+ boolean result = transResource.transferResource(
+ sourceURL, targetFolderURL, newTitle, transOperation );
+ if ( result )
+ System.out.println( "\nTransferring resource succeeded." );
+ else
+ System.out.println( "Transferring resource failed." );
+
+ System.out.println( " Source URL : " + sourceURL );
+ System.out.println( " Target Folder URL : " + targetFolderURL );
+ System.out.println( " New name : " + newTitle );
+ System.out.println( " Transfer Operation: " + transOperation );
+
+
+ } catch ( com.sun.star.ucb.CommandAbortedException e ) {
+ System.out.println( "Error: " + e );
+ } catch ( com.sun.star.uno.Exception e ) {
+ System.out.println( "Error: " + e );
+ } catch ( java.lang.Exception e ) {
+ System.out.println( "Error: " + e );
+ }
+ System.exit( 0 );
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/UCB/ResourceRemover.java b/odk/examples/DevelopersGuide/UCB/ResourceRemover.java
new file mode 100644
index 000000000..e6ac8fc1c
--- /dev/null
+++ b/odk/examples/DevelopersGuide/UCB/ResourceRemover.java
@@ -0,0 +1,175 @@
+/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * The Contents of this file are made available subject to the terms of
+ * the BSD license.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *************************************************************************/
+
+/**
+ * Deleting a resource
+ */
+public class ResourceRemover {
+
+ /**
+ * Member properties
+ */
+ private Helper m_helper;
+ private String m_contenturl = "";
+ private com.sun.star.ucb.XContent m_content;
+
+ /**
+ * Constructor.
+ *
+ *@param args This constructor requires the arguments:
+ * -url=... (optional)
+ * -workdir=... (optional)
+ * See Help (method printCmdLineUsage()).
+ * Without the arguments a new connection to a
+ * running office cannot created.
+ */
+ public ResourceRemover( String args[] ) throws java.lang.Exception {
+
+ // Parse arguments
+ parseArguments( args );
+
+ // Init
+ m_helper = new Helper( getContentURL() );
+
+ // Create UCB content
+ m_content = m_helper.createUCBContent();
+ }
+
+ /**
+ * Delete resource.
+ *
+ *@return true if resource successfully deleted, false otherwise
+ */
+ public boolean deleteResource()
+ throws com.sun.star.ucb.CommandAbortedException, com.sun.star.uno.Exception {
+
+ boolean result = false;
+ if ( m_content != null ) {
+
+
+ // Destroy a resource physically...
+
+
+ Boolean deletePhysically = Boolean.TRUE;
+
+ // Execute command "delete".
+ m_helper.executeCommand( m_content, "delete", deletePhysically );
+ result = true;
+ }
+ return result;
+ }
+
+ /**
+ * Get connect URL.
+ *
+ *@return String That contains the connect URL
+ */
+ public String getContentURL() {
+ return m_contenturl;
+ }
+
+ /**
+ * Parse arguments
+ */
+ public void parseArguments( String[] args ) throws java.lang.Exception {
+
+ String workdir = "";
+
+ for ( int i = 0; i < args.length; i++ ) {
+ if ( args[i].startsWith( "-url=" )) {
+ m_contenturl = args[i].substring( 5 );
+ } else if ( args[i].startsWith( "-workdir=" )) {
+ workdir = args[i].substring( 9 );
+ } else if ( args[i].startsWith( "-help" ) ||
+ args[i].startsWith( "-?" )) {
+ printCmdLineUsage();
+ System.exit( 0 );
+ }
+ }
+
+ if ( m_contenturl == null || m_contenturl.equals( "" )) {
+ m_contenturl = Helper.createTargetDataFile( workdir );
+ }
+ }
+
+ /**
+ * Print the commands options
+ */
+ public void printCmdLineUsage() {
+ System.out.println(
+ "Usage : ResourceRemover -url=... -workdir=..." );
+ System.out.println(
+ "Defaults: -url=<workdir>/resource-<uniquepostfix> -workdir=<currentdir>" );
+ System.out.println(
+ "\nExample : -url=file:///temp/MyFile.txt \n" );
+ }
+
+ /**
+ * Create a new connection with the specific args to a running office and
+ * delete a resource.
+ */
+ public static void main ( String args[] ) {
+
+ System.out.println( "\n" );
+ System.out.println(
+ "-----------------------------------------------------------------" );
+ System.out.println(
+ "ResourceRemover - destroys a resource." );
+ System.out.println(
+ "-----------------------------------------------------------------" );
+
+ try {
+ ResourceRemover delete = new ResourceRemover( args );
+ boolean result = delete.deleteResource();
+ String url = delete.getContentURL();
+ if ( result ) {
+ System.out.println(
+ "Delete of resource " + url + " succeeded." );
+ } else {
+ System.out.println(
+ "Delete of resource " + url + " failed." );
+ }
+ } catch ( com.sun.star.ucb.CommandAbortedException e ) {
+ System.out.println( "Error: " + e );
+ } catch ( com.sun.star.uno.Exception e ) {
+ System.out.println( "Error: " + e );
+ } catch ( java.lang.Exception e ) {
+ System.out.println( "Error: " + e );
+ }
+ System.exit( 0 );
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/odk/examples/DevelopersGuide/UCB/data/data.txt b/odk/examples/DevelopersGuide/UCB/data/data.txt
new file mode 100644
index 000000000..dd47db97d
--- /dev/null
+++ b/odk/examples/DevelopersGuide/UCB/data/data.txt
@@ -0,0 +1 @@
+sample sample sample sample sample sample sample sample EOF \ No newline at end of file
diff --git a/odk/examples/DevelopersGuide/examples.html b/odk/examples/DevelopersGuide/examples.html
new file mode 100644
index 000000000..7cb3fb42f
--- /dev/null
+++ b/odk/examples/DevelopersGuide/examples.html
@@ -0,0 +1,2879 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<!--
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+-->
+<html>
+<head>
+ <title>LibreOffice %PRODUCT_RELEASE% SDK - Developer's Guide Examples</title>
+ <link rel="stylesheet" type="text/css" href="../../docs/sdk_styles.css"/>
+ <meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
+</head>
+<body>
+ <a name="tools"></a>
+ <div id="BgContainer">
+ <div id="Container">
+ <div id="TopHeader">
+ <a id="Logo" href="http://www.libreoffice.org/" title="Go to the Home of LibreOffice and the LibreOffice Community page"></a>
+ <p id="HeaderTagLine">
+ Software Development Kit %PRODUCT_RELEASE%
+ </p>
+ </div>
+ <div class="clear">
+ </div>
+ <div id="Layout">
+ <div class="typography">
+ <h1>
+ Developer's Guide Examples
+ </h1>
+<table class="table1" cellpadding="0">
+ <tr>
+ <td colspan="3"><img class="nothing10"
+ src="../../docs/images/nada.gif"/></td>
+ </tr>
+<td colspan="3"><table class="table2">
+ <tr>
+ <td>
+ <table class="table3">
+ <tbody>
+ <tr>
+ <td colspan="3">
+ <p>The <a
+ href="https://wiki.documentfoundation.org/Documentation/DevGuide"
+ title="link to the Developer's Guide in the Wiki">Developer's Guide</a>
+comes with a wide range of examples from all application areas which
+shows the use of the API in the context of the different functional
+areas. Furthermore the examples can be used as a first starting point
+to modify an existing example to their own needs.</p>
+ <p>Some of the examples need a running office
+instance listening on a port. If this is necessary you will get further
+information in the makefiles.</p>
+ <p>All examples marked with a <img
+ src="../../docs/images/bluball.gif"/> are executable and be started
+using a run target in the makefile. The name of the binary (C++) can
+differ compared to the source file, please see the run target in the
+appropriate makefile. Some of the examples which create a component
+have no run target. In these cases a document is provided which
+instantiates and runs the component (see the makefile output). Also the
+Basic examples provide documents which use and shows the implemented
+functionality. The database and forms examples need a running database,
+please see the description below. But note that is not described in
+detail how to create a working data source (see the office help).</p>
+ </td>
+ </tr>
+ <tr>
+ <td><img class="line"
+ src="../../docs/images/sdk_line-1.gif"/></td>
+ </tr>
+ </tbody>
+ </table>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <table class="table3">
+ <tbody>
+ <tr valign="top">
+ <td class="content3"><img
+ src="../../docs/images/arrow-1.gif"/></td>
+ <td><a href="#FirstSteps"
+ title="link to the First Steps examples">First Steps</a></td>
+ <td class="content4"></td>
+ <td class="content3"><img
+ src="../../docs/images/arrow-1.gif"/></td>
+ <td><a href="#ProfessionalUNO"
+ title="link to the Professional UNO examples">Professional UNO</a></td>
+ <td class="content10"></td>
+ <td class="content3"><img
+ src="../../docs/images/arrow-1.gif"/></td>
+ <td><a href="#Components"
+ title="link to the Components examples">Writing UNO components</a></td>
+ </tr>
+ <tr valign="top">
+ <td class="content3"><img
+ src="../../docs/images/arrow-1.gif"/></td>
+ <td><a href="#OfficeDevelopment"
+ title="link to the Office Development examples">Office Development</a></td>
+ <td class="content4"></td>
+ <td class="content3"><img
+ src="../../docs/images/arrow-1.gif"/></td>
+ <td><a href="#Text" title="link to the Text examples">Text
+Documents</a></td>
+ <td class="content10"></td>
+ <td class="content3"><img
+ src="../../docs/images/arrow-1.gif"/></td>
+ <td><a href="#Spreadsheet"
+ title="link to the Spreadsheet examples">Spreadsheet Documents</a></td>
+ </tr>
+ <tr valign="top">
+ <td class="content3"><img
+ src="../../docs/images/arrow-1.gif"/></td>
+ <td><a href="#Drawing"
+ title="link to the Drawing And Presentation examples">Drawing and
+Presentation Documents</a></td>
+ <td class="content4"></td>
+ <td class="content3"><img
+ src="../../docs/images/arrow-1.gif"/></td>
+ <td><a href="#Charts"
+ title="link to the Charts examples">Charts</a></td>
+ <td class="content10"></td>
+ <td class="content3"><img
+ src="../../docs/images/arrow-1.gif"/></td>
+ <td><a href="#BasicandDialogs"
+ title="link to the Basic And Dialogs examples">LibreOffice %PRODUCT_RELEASE% Basic and
+Dialogs</a></td>
+ </tr>
+ <tr valign="top">
+ <td class="content3"><img
+ src="../../docs/images/arrow-1.gif"/></td>
+ <td><a href="#Database"
+ title="link to the Database examples">Database Access</a></td>
+ <td class="content4"></td>
+ <td class="content3"><img
+ src="../../docs/images/arrow-1.gif"/></td>
+ <td><a href="#Forms"
+ title="link to the Forms examples">Forms</a></td>
+ <td class="content10"></td>
+ <td class="content3"><img
+ src="../../docs/images/arrow-1.gif"/></td>
+ <td><a href="#UniversalContentBroker"
+ title="link to the Universal Content Broker examples">Universal
+Content Broker (UCB)</a></td>
+ </tr>
+ <tr valign="top">
+ <td class="content3"><img
+ src="../../docs/images/arrow-1.gif"/></td>
+ <td><a href="#Configuration"
+ title="link to the Configuration examples">Configuration Management</a></td>
+ <td class="content4"></td>
+ <td class="content3"><img
+ src="../../docs/images/arrow-1.gif"/></td>
+ <td><a href="#OfficeBean"
+ title="link to the OOoBean examples">Office Bean</a></td>
+ <td class="content10"></td>
+ </tr>
+ <tr valign="top">
+ <td class="content3"><img
+ src="../../docs/images/arrow-1.gif"/></td>
+ <td><a href="#ScriptingFramework" title="link to the Scripting Framework examples">Scripting Framework</a></td>
+ <td class="content4"></td>
+ <td class="content3"><img
+ src="../../docs/images/arrow-1.gif"/></td>
+ <td><a href="#GraphicalUserInterfaces" title="link to the Graphical UserInterfaces examples">Graphical User Interfaces</a></td>
+ <td class="content10"></td>
+ <td class="content3"></td>
+ <td></td>
+ </tr>
+ </tbody>
+ </table>
+ </td>
+ </tr>
+ </table>
+ </td>
+ <td class="content1"><img class="nothing8"
+ src="../../docs/images/nada.gif"/></td>
+ </tr>
+ <tr>
+ <td colspan="3"><img class="line"
+ src="../../docs/images/sdk_line-1.gif"/></td>
+ </tr>
+ <tr>
+ <td class="content1"><img class="nothing8"
+ src="../../docs/images/nada.gif"/></td>
+ <td>
+ <table class="table2">
+ <tbody>
+ <tr>
+ <td>
+ <table class="table3">
+ <tbody>
+ <tr>
+ <td colspan="2" class="head1"><a name="FirstSteps">FirstSteps
+examples</a></td>
+ <td align="right"> <a href="#examples"
+ title="link to the Developer's Guide examples overview"><img
+ class="navigate" src="../../docs/images/nav_up.png"/></a> <a
+ href="../../index.html" title="link to the SDK start page"><img
+ class="navigate" src="../../docs/images/nav_home.png"/></a> </td>
+ </tr>
+ </tbody>
+ </table>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <table class="table4">
+ <tbody>
+ <tr class="thead">
+ <td class="cell20">Text Document Examples</td>
+ <td class="cell80">Description</td>
+ </tr>
+ <tr>
+ <td class="cell20"><img
+ src="../../docs/images/bluball.gif"/> <a
+ href="./FirstSteps/FirstUnoContact.java"
+ title="link to FirstSteps/FirstUnoContact.java">FirstUnoContact</a></td>
+ <td class="cell80">Shows how to initialize UNO and
+get a remote office service manager from a running LibreOffice %PRODUCT_RELEASE% in a
+different process space.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><img
+ src="../../docs/images/bluball.gif"/> <a
+ href="./FirstSteps/FirstLoadComponent.java"
+ title="link to FirstSteps/FirstLoadComponent.java">FirstLoadComponent</a></td>
+ <td class="cell80">Demonstrates how to load a
+component into LibreOffice %PRODUCT_RELEASE% by a Java application.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><img
+ src="../../docs/images/bluball.gif"/> <a
+ href="./FirstSteps/HelloTextTableShape.java"
+ title="link to FirstSteps/HelloTextTableShape.java">HelloTextTableShape</a></td>
+ <td class="cell80">Performs some generic text and
+shape operations on a text document, a spreadsheet document and a
+drawing document.</td>
+ </tr>
+ </tbody>
+ </table>
+ </td>
+ </tr>
+ </tbody>
+ </table>
+ </td>
+ <td class="content1"><img class="nothing8"
+ src="../../docs/images/nada.gif"/></td>
+ </tr>
+ <tr>
+ <td colspan="3"><img class="line"
+ src="../../docs/images/sdk_line-1.gif"/></td>
+ </tr>
+ <tr>
+ <td class="content1"><img class="nothing8"
+ src="../../docs/images/nada.gif"/></td>
+ <td>
+ <table class="table2">
+ <tbody>
+ <tr>
+ <td>
+ <table class="table3">
+ <tbody>
+ <tr>
+ <td colspan="2" class="head1"><a
+ name="ProfessionalUNO">Professional UNO examples1</a></td>
+ <td align="right"> <a href="#examples"
+ title="link to the Developer's Guide examples overview"><img
+ class="navigate" src="../../docs/images/nav_up.png"/></a> <a
+ href="../../index.html" title="link to the SDK start page"><img
+ class="navigate" src="../../docs/images/nav_home.png"/></a> </td>
+ </tr>
+ </tbody>
+ </table>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <table class="table4">
+ <tbody>
+ <tr class="thead">
+ <td class="cell20">Lifetime Examples</td>
+ <td class="cell80">Description</td>
+ </tr>
+ <tr>
+ <td class="cell20"><img
+ src="../../docs/images/bluball.gif"/> <a
+ href="./ProfUNO/Lifetime/MyUnoObject.java"
+ title="link to ProfUNO/Lifetime/MyUnoObject.java">MyUnoObject</a></td>
+ <td class="cell80">Shows that it depends on the
+implementation of the Java VM whether finalize() will be called or not.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><img
+ src="../../docs/images/bluball.gif"/> <a
+ href="./ProfUNO/Lifetime/object_lifetime.cxx"
+ title="link to ProfUNO/Lifetime/object_lifetime.java">object_lifetime.cxx
+(ProfUnoLifetime)</a></td>
+ <td class="cell80">Shows the UNO reference counting
+mechanism in C++.</td>
+ </tr>
+ </tbody>
+ </table>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <table class="table4">
+ <tbody>
+ <tr class="thead">
+ <td class="cell20">Interprocess Connection Example</td>
+ <td class="cell80">Description</td>
+ </tr>
+ <tr>
+ <td class="cell20"><img
+ src="../../docs/images/bluball.gif"/> <a
+ href="./ProfUNO/InterprocessConn/ConnectionAwareClient.java"
+ title="link to ProfUNO/InterprocessConn/ConnectionAwareClient/.java">ConnectionAwareClient</a></td>
+ <td class="cell80">Implements a client which is aware
+of losing connection to LibreOffice %PRODUCT_RELEASE%.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><img
+ src="../../docs/images/bluball.gif"/> <a
+ href="./ProfUNO/InterprocessConn/UrlResolver.java"
+ title="link to ProfUNO/InterProcessConn/UrlResolver.java">UrlResolver</a></td>
+ <td class="cell80">Builds a connection to
+LibreOffice %PRODUCT_RELEASE% using the URL given on the command line. This example
+shows the usage of <a
+ href="%DOXYGEN_PREFIX2%/docs/idl/ref/interfacecom_1_1sun_1_1star_1_1bridge_1_1XUnoUrlResolver.html"
+ title="link to the reference documentation of com.sun.star.bridge.XUnoResolver"><code>XUnoUrlResolver</code></a>.</td>
+ </tr>
+ </tbody>
+ </table>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <table class="table4">
+ <tbody>
+ <tr class="thead">
+ <td class="cell20">C++ Binding Examples</td>
+ <td class="cell80">Description</td>
+ </tr>
+ <tr>
+ <td class="cell20"><img
+ src="../../docs/images/bluball.gif"/> <a
+ href="./ProfUNO/CppBinding/office_connect.cxx"
+ title="link to ProfUNO/CppBinding/office_connect.java">office_connect.cxx</a></td>
+ <td class="cell80">Builds a connection to
+LibreOffice %PRODUCT_RELEASE% using C++.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><img
+ src="../../docs/images/bluball.gif"/> <a
+ href="./ProfUNO/CppBinding/string_samples.cxx"
+ title="link to ProfUNO/Cppbinding/string_samples.java">string_samples.cxx</a></td>
+ <td class="cell80">Demonstrates usage of RTL string
+classes <a href="%DOXYGEN_PREFIX2%/docs/cpp/ref/names/rtl/c-OString.html"
+ title="link to the reference documentation of rtl::OString"><code>OString</code></a>,
+ <a href="%DOXYGEN_PREFIX2%/docs/cpp/ref/names/rtl/c-OUString.html"
+ title="link to the reference documentation of rtl::OUString"><code>OUString</code></a>
+and <a href="%DOXYGEN_PREFIX2%/docs/cpp/ref/names/rtl/c-OUStringBuffer.html"
+ title="link to the reference documentation of rtl::OUStringBuffer"><code>OUStringBuffer</code></a>.</td>
+ </tr>
+ </tbody>
+ </table>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <table class="table4">
+ <tbody>
+ <tr class="thead">
+ <td class="cell20">SimpleBootstrap Java Example</td>
+ <td class="cell80">Description</td>
+ </tr>
+ <tr>
+ <td class="cell20"><img
+ src="../../docs/images/bluball.gif"/> <a
+ href="./ProfUNO/SimpleBootstrap_java/SimpleBootstrap_java.java"
+ title="link to ProfUNO/SimpleBootstrap_java/SimpleBootstrap_java.java">SimpleBootstrap_java.java</a></td>
+ <td class="cell80">Shows the transparent use of
+office UNO components from Java. The remote office component context is
+obtained by using the <code>com.sun.star.comp.helper.Bootstrap.bootstrap()</code>
+method, which bootstraps the component context from a UNO installation.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a
+ href="./ProfUNO/SimpleBootstrap_java/manifest.mf"
+ title="link to ProfUNO/SimpleBootstrap_java/manifest.mf"> manifest.mf</a></td>
+ <td class="cell80">Contains the additional manifest
+file entries.</td>
+ </tr>
+ </tbody>
+ </table>
+ </td>
+ </tr>
+
+ <tr>
+ <td>
+ <table class="table4">
+ <tbody>
+ <tr class="thead">
+ <td class="cell20">SimpleBootstrap C++ Example</td>
+ <td class="cell80">Description</td>
+ </tr>
+ <tr>
+ <td class="cell20"><img
+ src="../../docs/images/bluball.gif"/> <a
+ href="./ProfUNO/SimpleBootstrap_cpp/SimpleBootstrap_cpp.cxx"
+ title="link to ProfUNO/SimpleBootstrap_cpp/SimpleBootstrap_cpp.cxx">SimpleBootstrap_cpp.cxx</a></td>
+ <td class="cell80">Shows the transparent use of
+office UNO components from C++. The remote office component context is
+obtained by using the <code>::cppu::bootstrap()</code> function, which
+bootstraps the component context from a UNO installation.</td>
+ </tr>
+ </tbody>
+ </table>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <table class="table4">
+ <tbody>
+ <tr class="thead">
+ <td class="cell20">Deployment Features</td>
+ <td class="cell80">Description</td>
+ </tr>
+ <tr>
+ <td class="cell20"> <a
+ href="./Components/SimpleLicense/description.xml"
+ title="link to Components/SimpleLicense/description.xml">description.xml</a></td>
+ <td class="cell80">Demonstrates how license files can be embedded, so that they are shown to the user during installation.</td>
+ </tr>
+ </tbody>
+ </table>
+ </td>
+ </tr>
+
+
+ </tbody>
+ </table>
+ </td>
+ <td class="content1"><img class="nothing8"
+ src="../../docs/images/nada.gif"/></td>
+ </tr>
+ <tr>
+ <td class="content1"><img class="nothing8"
+ src="../../docs/images/nada.gif"/></td>
+ <td>
+ <table class="table2">
+ <tbody>
+ <tr>
+ <td>
+ <table class="table3">
+ <tbody>
+ <tr>
+ <td colspan="2" class="head1"><a name="Components">Writing
+UNO components examples</a></td>
+ <td align="right"> <a href="#examples"
+ title="link to the Developer's Guide examples overview"><img
+ class="navigate" src="../../docs/images/nav_up.png"/></a> <a
+ href="../../index.html" title="link to the SDK start page"><img
+ class="navigate" src="../../docs/images/nav_home.png"/></a> </td>
+ </tr>
+ </tbody>
+ </table>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <table class="table4">
+ <tbody>
+ <tr class="thead">
+ <td class="cell20">Jobs Addon Example</td>
+ <td class="cell80">Description</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a
+ href="./Components/Addons/JobsAddon/AsyncJob.java"
+ title="link to Components/Addons/JobsAddon/AsyncJob.java">AsyncJob</a></td>
+ <td class="cell80">An java example showing how a job
+can analyze the given arguments and how the environment can be
+detected, in which the job is executed.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a
+ href="./Components/Addons/JobsAddon/Jobs.xcu"
+ title="link to Components/Addons/JobsAddon/Jobs.xcu">Jobs.xcu</a></td>
+ <td class="cell80">Contains the example job
+configuration.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a
+ href="./Components/Addons/JobsAddon/Addons.xcu"
+ title="link to Components/Addons/JobsAddon/Addons.xcu">Addons.xcu</a></td>
+ <td class="cell80">Contains the configuration entries
+for the Jobs addon where different entries are configured.</td>
+ </tr>
+ </tbody>
+ </table>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <table class="table4">
+ <tbody>
+ <tr class="thead">
+ <td class="cell20">ProtocolHandler Addon Java</td>
+ <td class="cell80">Description</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a
+ href="./Components/Addons/ProtocolHandlerAddon_java/ProtocolHandlerAddon.java"
+ title="link to Components/Addons/ProtocolHandlerAddon_java/ProtocolHandlerAddon.java">ProtocolHandlerAddon</a></td>
+ <td class="cell80">Implements a ProtocolHandler addon
+component in Java.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a
+ href="./Components/Addons/ProtocolHandlerAddon_cpp/ProtocolHandler.xcu"
+ title="link to Components/Addons/ProtocolHandlerAddon_cpp/ProtocolHandler.xcu">ProtocolHandler.xcu</a></td>
+ <td class="cell80">Contains the ProtocolHandler
+configuration.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a
+ href="./Components/Addons/ProtocolHandlerAddon_cpp/Addons.xcu"
+ title="link to Components/Addons/ProtocolHandlerAddon_cpp/Addons.xcu">Addons.xcu</a></td>
+ <td class="cell80">Contains the configuration entries
+for the ProtocolHandler addon where different entries are configured.</td>
+ </tr>
+ </tbody>
+ </table>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <table class="table4">
+ <tbody>
+ <tr class="thead">
+ <td class="cell20">ProtocolHandler Addon C++</td>
+ <td class="cell80">Description</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a
+ href="./Components/Addons/ProtocolHandlerAddon_cpp/addon.cxx"
+ title="link to Components/Addons/ProtocolHandlerAddon_cpp/addon.cxx">addon.cxx</a></td>
+ <td class="cell80">Implements a ProtocolHandler addon
+component in C++.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a
+ href="./Components/Addons/ProtocolHandlerAddon_cpp/addon.hxx"
+ title="link to Components/Addons/ProtocolHandlerAddon_cpp/addon.hxx">addon.hxx</a></td>
+ <td class="cell80">Contains the class definition of
+the c++ ProtocolHandler example.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a
+ href="./Components/Addons/ProtocolHandlerAddon_cpp/component.cxx"
+ title="link to Components/Addons/ProtocolHandlerAddon_cpp/component.cxx">component.cxx</a></td>
+ <td class="cell80">Implements the administrative
+component functions (component_writeInfo, component_getFactory, component_getImplementationEnvironment).</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a
+ href="./Components/Addons/ProtocolHandlerAddon_cpp/ProtocolHandler.xcu"
+ title="link to Components/Addons/ProtocolHandlerAddon_cpp/ProtocolHandler.xcu">ProtocolHandler.xcu</a></td>
+ <td class="cell80">Contains the ProtocolHandler
+configuration.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a
+ href="./Components/Addons/ProtocolHandlerAddon_cpp/Addons.xcu"
+ title="link to Components/Addons/ProtocolHandlerAddon_cpp/Addons.xcu">Addons.xcu</a></td>
+ <td class="cell80">Contains the configuration entries
+for the ProtocolHandler addon where different entries are configured.</td>
+ </tr>
+ </tbody>
+ </table>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <table class="table4">
+ <tbody>
+ <tr class="thead">
+ <td class="cell20">Java Component Example</td>
+ <td class="cell80">Description</td>
+ </tr>
+ <tr>
+ <td class="cell20"><img src="../../docs/images/bluball.gif"/> <a
+ href="./Components/JavaComponent/TestJavaComponent.java"
+ title="link to Components/JavaComponent/TestJavaComponent.java">TestJavaComponent</a></td>
+ <td class="cell80">Demonstrates how to extend the
+service provider with a new factory and instantiates the example
+components.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a
+ href="./Components/JavaComponent/TestComponentA.java"
+ title="link to Components/JavaComponent/TestComponentA.java">TestComponentA</a></td>
+ <td class="cell80">Shows a simple demo component
+which implements <a
+ href="%DOXYGEN_PREFIX2%/docs/idl/ref/interfacecom_1_1sun_1_1star_1_1lang_1_1XTypeProvider.html"
+ title="link to the reference documentation of com.sun.star.lang.XTypeProvider"><code>XTypeProvider</code></a>,
+ <a
+ href="%DOXYGEN_PREFIX2%/docs/idl/ref/interfacecom_1_1sun_1_1star_1_1lang_1_1XServiceInfo.html"
+ title="link to the reference documentation of com.sun.star.lang.XServicedInfo">
+ <code>XServiceInfo</code></a> and an own interface <code>XSomethingA</code>.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a
+ href="./Components/JavaComponent/TestComponentB.java"
+ title="link to Components/JavaComponent/TestComponentB.java">TestComponentB</a></td>
+ <td class="cell80">Shows a simple demo component
+which implements <a
+ href="%DOXYGEN_PREFIX2%/docs/idl/ref/interfacecom_1_1sun_1_1star_1_1lang_1_1XTypeProvider.html"
+ title="link to the reference documentation of com.sun.star.lang.XTypeProvider">
+ <code>XTypeProvider</code></a>, <a
+ href="%DOXYGEN_PREFIX2%/docs/idl/ref/interfacecom_1_1sun_1_1star_1_1lang_1_1XServiceInfo.html"
+ title="link to the reference documentation of com.sun.star.lang.XServiceInfo"><code>XServiceInfo</code></a>
+and an own interface <code>XSomethingB</code>.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a
+ href="./Components/JavaComponent/TestServiceProvider.java"
+ title="link to Components/JavaComponent/TestServiceProvider.java">TestServiceProvider</a></td>
+ <td class="cell80">Implements a factory (service
+provider) which can create the two test components.</td>
+ </tr>
+ </tbody>
+ </table>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <table class="table4">
+ <tbody>
+ <tr class="thead">
+ <td class="cell20">C++ Component Example</td>
+ <td class="cell80">Description</td>
+ </tr>
+ <tr>
+ <td class="cell20"><img src="../../docs/images/bluball.gif"/> <a
+ href="./Components/CppComponent/TestCppComponent.cxx"
+ title="link to Components/CppComponent/TestCppComponent.cxx">TestCppComponent.cxx</a></td>
+ <td class="cell80">Shows how to create new instances
+of the demo services and calls some methods of the demo interface.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a
+ href="./Components/CppComponent/service1_impl.cxx"
+ title="link to Components/CppComponent/service1_impl.cxx">service1_impl.cxx</a></td>
+ <td class="cell80">Implements a simple UNO service
+with an own interface in C++.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a
+ href="./Components/CppComponent/service2_impl.cxx"
+ title="link to Components/CppComponent/service2_impl.cxx">service2_impl.cxx</a></td>
+ <td class="cell80">Implements another simple UNO
+service in C++.</td>
+ </tr>
+ </tbody>
+ </table>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <table class="table4">
+ <tbody>
+ <tr class="thead">
+ <td class="cell20">Thumbs Example</td>
+ <td class="cell80">Description</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a
+ href="./Components/Thumbs/org/openoffice/comp/test/ImageShrink.java"
+ title="link to Components/Thumbs/org/openoffice/comp/test/ImageShrink.java">ImageShrink</a></td>
+ <td class="cell80">Contains a framework for a
+component which scales images in a directory and stores them to another
+directory. This code does not really do anything, it just contains the
+framework.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a
+ href="./Components/Thumbs/org/openoffice/comp/test/Thumbs.java"
+ title="link to Components/Thumbs/org/openoffice/comp/test/Thumbs.java">Thumbs</a></td>
+ <td class="cell80">This example registers a factory
+for the image shrink component and instantiates it.</td>
+ </tr>
+ </tbody>
+ </table>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <table class="table4">
+ <tbody>
+ <tr class="thead">
+ <td class="cell20">Dialog Component Example</td>
+ <td class="cell80">Description</td>
+ </tr>
+ <tr>
+ <td class="cell20"><img src="../../docs/images/bluball.gif"/> <a
+ href="./Components/DialogComponent/DialogComponent.java"
+ title="link to Components/DialogComponent/DialogComponent.java">DialogComponent.java</a></td>
+ <td class="cell80">Implements a component accessing a dialog created
+ with the LibreOffice %PRODUCT_RELEASE% Basic IDE. The component provides methods that
+ can be bound to dialog respectively control events .</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a
+ href="./Components/DialogComponent/XTestDialogHandler.idl"
+ title="link to Components/DialogComponent/XTestDialogHandler.idl">XTestDialogHandler.idl</a></td>
+ <td class="cell80">Interface implementing a createDialog method showing the
+ dialog and some methods to be used as event handler for the dialog.
+ </td>
+ </tr>
+ <tr>
+ <td class="cell20"><a
+ href="./Components/DialogComponent/TestDialogHandler.idl"
+ title="link to Components/DialogComponent/TestDialogHandler.idl">TestDialogHandler.idl</a></td>
+ <td class="cell80">
+ Service definition for the component implementing
+ its own interface <code>XTestDialogHandler</code>.
+ </td>
+ </tr>
+ <tr>
+ <td class="cell20"><a
+ href="./Components/DialogComponent/DialogComponent.odt"
+ title="link to Components/DialogComponent/DialogComponent.odt">DialogComponent.odt</a></td>
+ <td class="cell80">Document containing Basic code to
+ instantiate the Dialog Components and a Dialog containing
+ controls with events bound to methods supported by the
+ Dialog Component.</td>
+ </tr>
+ </tbody>
+ </table>
+ </td>
+ </tr>
+ </tbody>
+ </table>
+ </td>
+ <td class="content1"><img class="nothing8"
+ src="../../docs/images/nada.gif"/></td>
+ </tr>
+ <tr>
+ <td colspan="3"><img class="line"
+ src="../../docs/images/sdk_line-1.gif"/></td>
+ </tr>
+ <tr>
+ <td class="content1"><img class="nothing8"
+ src="../../docs/images/nada.gif"/></td>
+ <td>
+ <table class="table2">
+ <tbody>
+ <tr>
+ <td>
+ <table class="table3">
+ <tbody>
+ <tr>
+ <td colspan="2" class="head1"><a
+ name="OfficeDevelopment">Office Development examples</a></td>
+ <td align="right"> <a href="#examples"
+ title="link to the Developer's Guide examples overview"><img
+ class="navigate" src="../../docs/images/nav_up.png"/></a> <a
+ href="../../index.html" title="link to the SDK start page"><img
+ class="navigate" src="../../docs/images/nav_home.png"/></a> </td>
+ </tr>
+ </tbody>
+ </table>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <table class="table4">
+ <tbody>
+ <tr class="thead">
+ <td class="cell20">Ascii Filter Example</td>
+ <td class="cell80">Description</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a
+ href="./OfficeDev/FilterDevelopment/AsciiFilter/AsciiReplaceFilter.java"
+ title="link to OfficeDev/FilterDevelopment/AsciiFilter/AsciiReplaceFilter.java">AsciiReplaceFilter</a></td>
+ <td class="cell80">Implements an example for an
+import/export filter service.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a
+ href="./OfficeDev/FilterDevelopment/AsciiFilter/FilterOptions.java"
+ title="link to OfficeDev/FilterDevelopment/AsciiFilter/FilterOptions.java">FilterOptions</a></td>
+ <td class="cell80">Offers some helper methods to
+analyze and prepare the arguments of the filter method.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a
+ href="./OfficeDev/FilterDevelopment/AsciiFilter/TypeDetection.xcu"
+ title="link to OfficeDev/FilterDevelopment/AsciiFilter/TypeDetection.xcu">TypeDetection.xcu</a></td>
+ <td class="cell80">Contains the necessary
+configuration items for the AsciiReplaceFilter.</td>
+ </tr>
+ </tbody>
+ </table>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <table class="table4">
+ <tbody>
+ <tr class="thead">
+ <td class="cell20">FlatXmlFilter C++ Example</td>
+ <td class="cell80">Description</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a
+ href="./OfficeDev/FilterDevelopment/FlatXmlFilter_cpp/FlatXml.cxx"
+ title="link to OfficeDev/FilterDevelopment/FlatXmlFilter_cpp/FlatXml.cxx">FlatXml.cxx</a></td>
+ <td class="cell80">Implements an import/export filter
+storing the data in one xml stream instead of the normal three streams
+in for example an .odt file. The example is implemented in C++.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a
+ href="./OfficeDev/FilterDevelopment/FlatXmlFilter_cpp/FlatXmlFilter_cpp.xcu"
+ title="link to OfficeDev/FilterDevelopment/FlatXmlFilter_cpp/FlatXmlFilter_cpp.xcu">FlatXmlFilter_cpp.xcu</a></td>
+ <td class="cell80">Contains the necessary
+configuration items for the C++ flat xml filter.</td>
+ </tr>
+ </tbody>
+ </table>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <table class="table4">
+ <tbody>
+ <tr class="thead">
+ <td class="cell20">FlatXmlFilter Java Example</td>
+ <td class="cell80">Description</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a
+ href="./OfficeDev/FilterDevelopment/FlatXmlFilter_java/FlatXml.java"
+ title="link to OfficeDev/FilterDevelopment/FlatXmlFilter_java/FlatXml.java">FlatXml</a></td>
+ <td class="cell80">Implements an import/export filter
+storing the data in one xml stream instead of the normal three streams
+in for example an .odt file. The example is implemented in Java.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a
+ href="./OfficeDev/FilterDevelopment/FlatXmlFilter_java/FlatXmlFilter_java.xcu"
+ title="link to OfficeDev/FilterDevelopment/FlatXmlFilter_java/FlatXmlFilter_java.xcu">FlatXmlFilter_java.xcu</a></td>
+ <td class="cell80">Contains the necessary
+configuration items for the Java flat xml filter.</td>
+ </tr>
+ </tbody>
+ </table>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <table class="table4">
+ <tbody>
+ <tr class="thead">
+ <td class="cell20">FlatXml FilterDetection Example</td>
+ <td class="cell80">Description</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a
+ href="./OfficeDev/FilterDevelopment/FlatXmlFilterDetection/filterdetect.cxx"
+ title="link to OfficeDev/FilterDevelopment/FlatXmlFilterDetection/filterdetect.cxx">filterdetect.cxx</a></td>
+ <td class="cell80">Implements an example filter
+detection for the flat xml filter. The example is implemented in C++.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a
+ href="./OfficeDev/FilterDevelopment/FlatXmlFilterDetection/filterdetect.hxx"
+ title="link to OfficeDev/FilterDevelopment/FlatXmlFilterDetection/filterdetect.hxx">filterdetect.hxx</a></td>
+ <td class="cell80">Contains the class definition of
+the filter detection example.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a
+ href="./OfficeDev/FilterDevelopment/FlatXmlFilterDetection/fdcomp.cxx"
+ title="link to OfficeDev/FilterDevelopment/FlatXmlFilterDetection/fdcomp.cxx">fdcomp.cxx</a></td>
+ <td class="cell80">Implements the administrative
+component functions (component_writeInfo, component_getFactory, component_getImplementationEnvironment).</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a
+ href="./OfficeDev/FilterDevelopment/FlatXmlFilterDetection/FlatXmlTypeDetection.xcu"
+ title="link to OfficeDev/FilterDevelopment/FlatXmlFilterDetection/FlatXmlTypeDetection.xcu">FlatXmlTypeDetection.xcu</a></td>
+ <td class="cell80">Contains the necessary
+configuration items for the C++ flat xml type detection.</td>
+ </tr>
+ </tbody>
+ </table>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <table class="table4">
+ <tbody>
+ <tr class="thead">
+ <td class="cell20">Desktop Environment Example</td>
+ <td class="cell80">Description</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a
+ href="./OfficeDev/DesktopEnvironment/CustomizeView.java"
+ title="link to OfficeDev/DesktopEnvironment/CustomizeView.java">CustomizeView</a></td>
+ <td class="cell80">Offers a view which allows hiding
+and showing of the menubar, toolbar and objectbar of the related
+document component.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><img
+ src="../../docs/images/bluball.gif"/> <a
+ href="./OfficeDev/DesktopEnvironment/Desk.java"
+ title="link to OfficeDev/DesktopEnvironment/Desk.java">Desk</a></td>
+ <td class="cell80">This is the main part of a demo
+application based on the framework APIs. It mainly shows the mechanisms
+to load, store and convert documents, as well as dispatch and dispatch
+interception. It integrates windows from LibreOffice %PRODUCT_RELEASE% via system
+window handle. This is the same mechanism as used by the OOoBean, but
+the OOoBean itself is not used here, just the JNI window handle access.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a
+ href="./OfficeDev/DesktopEnvironment/DocumentView.java"
+ title="link to OfficeDev/DesktopEnvironment/DocumentView.java">DocumentView</a></td>
+ <td class="cell80">Deals with the application window
+and it's actions.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a
+ href="./OfficeDev/DesktopEnvironment/FunctionHelper.java"
+ title="link to OfficeDev/DesktopEnvironment/FunctionHelper.java">FunctionHelper</a></td>
+ <td class="cell80">This helper comprises all
+LibreOffice %PRODUCT_RELEASE% API calls. Thus it is possible to learn about these
+aspects separately from the rest of the application example.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a
+ href="./OfficeDev/DesktopEnvironment/IOnewayLink.java"
+ title="link to OfficeDev/DesktopEnvironment/IOnewayLink.java">IOnewayLink</a></td>
+ <td class="cell80">This is an interface to receive
+asynchronous events from UNO oneway calls.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a
+ href="./OfficeDev/DesktopEnvironment/IShutdownListener.java"
+ title="link to OfficeDev/DesktopEnvironment/IShutdownListener.java">IShutdownListener</a></td>
+ <td class="cell80">This is a listener interface to
+clean up on shutdown of LibreOffice %PRODUCT_RELEASE%.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a
+ href="./OfficeDev/DesktopEnvironment/Interceptor.java"
+ title="link to OfficeDev/DesktopEnvironment/Interceptor.java">Interceptor</a></td>
+ <td class="cell80">This implements a dispatch
+interceptor for a specific URL.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a
+ href="./OfficeDev/DesktopEnvironment/JavaWindowPeerFake.java"
+ title="link to OfficeDev/DesktopEnvironment/JavaWindowPeerFake.java">JavaWindowPeerFake</a></td>
+ <td class="cell80">Fakes an <a
+ href="%DOXYGEN_PREFIX2%/docs/idl/ref/interfacecom_1_1sun_1_1star_1_1awt_1_1XWindowPeer.html"
+ title=" link to the reference documentation of com.sun.star.awt.XWindowPeer"><code>XWindowPeer</code></a>
+for the Java native window handle to create a child window for the
+office frame.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a
+ href="./OfficeDev/DesktopEnvironment/NativeView.java"
+ title="link to OfficeDev/DesktopEnvironment/NativeView.java">NativeView</a></td>
+ <td class="cell80">Implements native JNI methods to
+get the window handle of the Java window.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a
+ href="./OfficeDev/DesktopEnvironment/OfficeConnect.java"
+ title=" link to OfficeDev/DesktopEnvironment/OfficeConnect.java">OfficeConnect</a></td>
+ <td class="cell80">Builds the remote bridge to
+LibreOffice %PRODUCT_RELEASE% and exports its UNO service manager for the Java side of
+the application.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a
+ href="./OfficeDev/DesktopEnvironment/OnewayExecutor.java"
+ title="link to OfficeDev/DesktopEnvironment/OnewayExecutor.java">OnewayExecutor</a></td>
+ <td class="cell80">Implements <code>IOnewayLink</code>
+to decouple asynchronous oneway calls in the Java process.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a
+ href="./OfficeDev/DesktopEnvironment/StatusListener.java"
+ title="link to OfficeDev/DesktopEnvironment/StatusListener.java">StatusListener</a></td>
+ <td class="cell80">Implements a listener for a <a
+ href="%DOXYGEN_PREFIX2%/docs/idl/ref/structcom_1_1sun_1_1star_1_1frame_1_1FeatureStateEvent.html"
+ title="link to the reference documentation of com.sun.star.frame.FeatureStateEvent">
+ <code>FeatureStateEvent</code></a>.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a
+ href="./OfficeDev/DesktopEnvironment/StatusView.java"
+ title="link to OfficeDev/DesktopEnvironment/StatusView.java">StatusView</a></td>
+ <td class="cell80">Shows the current status for which
+the application is registered as an event listener.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a
+ href="./OfficeDev/DesktopEnvironment/ViewContainer.java"
+ title="link to OfficeDev/DesktopEnvironment/ViewContainer.java">ViewContainer</a></td>
+ <td class="cell80">Performs a clean up on the Java
+side on LibreOffice %PRODUCT_RELEASE% shutdown.</td>
+ </tr>
+ </tbody>
+ </table>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <table class="table4">
+ <tbody>
+ <tr class="thead">
+ <td class="cell20">Office Development Examples</td>
+ <td class="cell80">Description</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a
+ href="./OfficeDev/OfficeConnect.java"
+ title="link to OfficeDev/OfficeConnect.java">OfficeConnect</a></td>
+ <td class="cell80">Builds the remote bridge to
+LibreOffice %PRODUCT_RELEASE% and exports its UNO service manager to the Java side.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><img
+ src="../../docs/images/bluball.gif"/> <a
+ href="./OfficeDev/ContextMenuInterceptor.java"
+ title="link to OfficeDev/ContextMenuInterceptor.java">ContextMenuInterceptor</a></td>
+ <td class="cell80">This example shows a context menu
+interceptor that creates a new menu entry that has a sub menu. This sub
+menu is in inserted into the context menu on the topmost position. It
+provides some helper functions to the user that are reachable through
+the menu Help.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a
+ href="./OfficeDev/MenuElement.java"
+ title="link to OfficeDev/MenuElement.java">MenuElement</a></td>
+ <td class="cell80">A helper class for the context
+menu interceptor example. It determines the menu element type.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><img
+ src="../../docs/images/bluball.gif"/> <a
+ href="./OfficeDev/Number_Formats.java"
+ title="link to OfficeDev/Number_Formats.java">Number_Formats</a></td>
+ <td class="cell80">Demonstrates the use of number
+formats in a spreadsheet document.</td>
+ </tr>
+ </tbody>
+ </table>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <table class="table4">
+ <tbody>
+ <tr class="thead">
+ <td class="cell20">Termination Test Example</td>
+ <td class="cell80">Description</td>
+ </tr>
+ <tr>
+ <td class="cell20"><img
+ src="../../docs/images/bluball.gif"/> <a
+ href="./OfficeDev/TerminationTest/TerminationTest.java"
+ title="link to OfficeDev/TerminationTest/TerminationTest.java">TerminationTest</a></td>
+ <td class="cell80">This example uses the
+TerminateListener and shows the use of them in a running program.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a
+ href="./OfficeDev/TerminationTest/TerminateListener.java"
+ title="link to OfficeDev/TerminationTest/TerminateListener.java">TerminateListener</a></td>
+ <td class="cell80">An example implementation of <a
+ href="%DOXYGEN_PREFIX2%/docs/idl/ref/interfacecom_1_1sun_1_1star_1_1frame_1_1XTerminateListener.html"
+ title="link to the reference documentation of com.sun.star.frame.XTerminationListener">
+ <code>XTerminateListener</code></a>. It is called
+when LibreOffice %PRODUCT_RELEASE% terminates.</td>
+ </tr>
+ </tbody>
+ </table>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <table class="table4">
+ <tbody>
+ <tr class="thead">
+ <td class="cell20">Clipboard Example</td>
+ <td class="cell80">Description</td>
+ </tr>
+ <tr>
+ <td class="cell20"><img
+ src="../../docs/images/bluball.gif"/> <a
+ href="./OfficeDev/Clipboard/Clipboard.java"
+ title="link to OfficeDev/Clipboard/Clipboard.java">Clipboard</a></td>
+ <td class="cell80">Demonstrates the usage of the
+clipboard service by registering a clipboard listener, getting a list
+of formats from the current clipboard content and copying some data to
+the clipboard.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a
+ href="./OfficeDev/Clipboard/ClipboardListener.java"
+ title="link to OfficeDev/Clipboard/ClipboardListener.java">ClipboardListener</a></td>
+ <td class="cell80">Implements a clipboard listener
+for the Clipboard example. In such a class, actions can be implemented
+which happen whenever the clipboard content changes.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a
+ href="./OfficeDev/Clipboard/ClipboardOwner.java"
+ title="link to OfficeDev/Clipboard/ClipboardOwner.java">ClipboardOwner</a></td>
+ <td class="cell80">Implements a clipboard owner for
+the Clipboard example. This class is notified when it loses ownership
+of the clipboard.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a
+ href="./OfficeDev/Clipboard/TextTransferable.java"
+ title="link to OfficeDev/Clipboard/TextTransferable.java">TextTransferable</a></td>
+ <td class="cell80">Implements a data object for the
+Clipboard example. Such classes supply clients with data in a variety
+of formats.</td>
+ </tr>
+ </tbody>
+ </table>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <table class="table4">
+ <tbody>
+ <tr class="thead">
+ <td class="cell20">Linguistic Example</td>
+ <td class="cell80">Description</td>
+ </tr>
+ <tr>
+ <td class="cell20"><img
+ src="../../docs/images/bluball.gif"/> <a
+ href="./OfficeDev/Linguistic/LinguisticExamples.java"
+ title="link to OfficeDev/Linguistic/LinguisticExamples.java">LinguisticExamples</a></td>
+ <td class="cell80">A short example that uses most of
+the functionality from the LibreOffice %PRODUCT_RELEASE% linguistic API.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a
+ href="./OfficeDev/Linguistic/OneInstanceFactory.java"
+ title="link to OfficeDev/Linguistic/OneInstanceFactory.java">OneInstanceFactory</a></td>
+ <td class="cell80">This class is used to provide a
+service factory for the linguistic services. It enforces that the
+actual implementations are only instantiated once.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a
+ href="./OfficeDev/Linguistic/PropChgHelper.java"
+ title="link to OfficeDev/Linguistic/PropChgHelper.java">PropChgHelper</a></td>
+ <td class="cell80">The base class for several
+property change helpers which are used to keep track of the changes of
+the service relevant linguistic properties. It is also used by the
+thesaurus directly.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a
+ href="./OfficeDev/Linguistic/PropChgHelper_Hyph.java"
+ title="link to OfficeDev/Linguistic/PropChgHelper_Hyph.java">PropChgHelper_Hyph</a></td>
+ <td class="cell80">The property change helper that is
+tracking the hyphenation relevant properties.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a
+ href="./OfficeDev/Linguistic/PropChgHelper_Spell.java"
+ title="link to OfficeDev/Linguistic/PropChgHelper_Spell.java">PropChgHelper_Spell</a></td>
+ <td class="cell80">The property change helper that is
+tracking the spell checking relevant properties.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a
+ href="./OfficeDev/Linguistic/SampleHyphenator.java"
+ title="link to OfficeDev/Linguistic/SampleHyphenator.java">SampleHyphenator</a></td>
+ <td class="cell80">A simple implementation for a <a
+ href="%DOXYGEN_PREFIX2%/docs/idl/ref/servicecom_1_1sun_1_1star_1_1linguistic2_1_1Hyphenator.html"
+ title="link to the reference documentation of com.sun.star.linguistic2.Hyphenator"><code>Hyphenator</code></a>
+service.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a
+ href="./OfficeDev/Linguistic/SampleSpellChecker.java"
+ title="link to OfficeDev/Linguistic/SampleSpellChecker.java">SampleSpellChecker</a></td>
+ <td class="cell80">A simple implementation for a <a
+ href="%DOXYGEN_PREFIX2%/docs/idl/ref/servicecom_1_1sun_1_1star_1_1linguistic2_1_1SpellChecker.html"
+ title="link to the reference documentation of com.sun.star.linguistic2.SpellChecker"><code>SpellChecker</code></a>
+service.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a
+ href="./OfficeDev/Linguistic/SampleThesaurus.java"
+ title="link to OfficeDev/Linguistic/SampleThesaurus.java">SampleThesaurus</a></td>
+ <td class="cell80">A simple implementation for a <a
+ href="%DOXYGEN_PREFIX2%/docs/idl/ref/servicecom_1_1sun_1_1star_1_1linguistic2_1_1Thesaurus.html"
+ title="link to the reference documentation of com.sun.star.linguistic2.Thesaurus"><code>Thesaurus</code></a>
+service.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a
+ href="./OfficeDev/Linguistic/XHyphenatedWord_impl.java"
+ title="link to OfficeDev/Linguistic/XHyphenatedWord_impl.java">XHyphenatedWord_impl</a></td>
+ <td class="cell80">An object implementing the <a
+ href="%DOXYGEN_PREFIX2%/docs/idl/ref/interfacecom_1_1sun_1_1star_1_1linguistic2_1_1XHyphenatedWord.html"
+ title="link to the reference documentation of com.sun.star.linguistic2/XHyphenatedWord"><code>XHyphenatedWord</code></a>
+interface. An instance of this type may be returned by the hyphenator.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a
+ href="./OfficeDev/Linguistic/XMeaning_impl.java"
+ title="link to OfficeDev/Linguistic/XMeaning_impl.java">XMeaning_impl</a></td>
+ <td class="cell80">An object implementing the <a
+ href="%DOXYGEN_PREFIX2%/docs/idl/ref/interfacecom_1_1sun_1_1star_1_1linguistic2_1_1XMeaning.html"
+ title="link to the reference documentation of com.sun.star.linguistic2.XMeaning"><code>XMeaning</code></a>
+interface. An instance of this type may be returned by the thesaurus.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a
+ href="./OfficeDev/Linguistic/XPossibleHyphens_impl.java"
+ title="link to OfficeDev/Linguistic/XPossibleHyphens_impl.java">XPossibleHyphens_impl</a></td>
+ <td class="cell80">An object implementing the <a
+ href="%DOXYGEN_PREFIX2%/docs/idl/ref/interfacecom_1_1sun_1_1star_1_1linguistic2_1_1XPossibleHyphens.html"
+ title="link to the reference documentation of com.sun.star.linguistic2.XPossibleHyphens">
+ <code>XPossibleHyphens</code></a> interface. An
+instance of this type may be returned by the hyphenator.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a
+ href="./OfficeDev/Linguistic/XSpellAlternatives_impl.java"
+ title="link to OfficeDev/Linguistic/XSpellAlternatives_impl.java">XSpellAlternatives_impl</a></td>
+ <td class="cell80">An object implementing the <a
+ href="%DOXYGEN_PREFIX2%/docs/idl/ref/interfacecom_1_1sun_1_1star_1_1linguistic2_1_1XSpellAlternatives.html"
+ title="link to the reference documentation of com.sun.star.linguistic2.XSpellAlternatives">
+ <code>XSpellAlternatives</code></a> interface. An
+instance of this type may be returned by the spell checker.</td>
+ </tr>
+ </tbody>
+ </table>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <table class="table4">
+ <tbody>
+ <tr class="thead">
+ <td class="cell20">Path Settings Example</td>
+ <td class="cell80">Description</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a
+ href="./OfficeDev/PathSettings/PathSettingsTest.java"
+ title="link to OfficeDev/PathSettings/PathSettingsTest.java">PathsettingsTest</a></td>
+ <td class="cell80">This code example creates the
+service <a
+ href="%DOXYGEN_PREFIX2%/docs/idl/ref/servicecom_1_1sun_1_1star_1_1util_1_1PathSettings.html"
+ title="link to the reference documentation of com.sun.star.util.PathSettings">
+ <code>com.sun.star.util.PathSettings</code></a> and
+retrieves all path properties from it. It shows how a developer can
+change the path properties using the <a
+ href="%DOXYGEN_PREFIX2%/docs/idl/ref/interfacecom_1_1sun_1_1star_1_1beans_1_1XPropertySet.html"
+ title="link to the reference documentation of com.sun.star.beans.XPropertySet"><code>XPropertySet</code></a>
+interface.</td>
+ </tr>
+ </tbody>
+ </table>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <table class="table4">
+ <tbody>
+ <tr class="thead">
+ <td class="cell20">Path Substitution Example</td>
+ <td class="cell80">Description</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a
+ href="./OfficeDev/PathSubstitution/PathSubstitutionTest.java"
+ title="link to OfficeDev/PathSubstitution/PathSubstitutionTest.java">PathSubstitutionTest</a></td>
+ <td class="cell80">This code example creates the path
+substitution service <a
+ href="%DOXYGEN_PREFIX2%/docs/idl/ref/servicecom_1_1sun_1_1star_1_1util_1_1PathSubstitution.html"
+ title="link to the reference documentation of com.sun.star.util.PathSubstitution">
+ <code>com.sun.star.util.PathSubstitution</code></a>
+and retrieves the pre-defined Office path variables. It shows the
+variable values on the screen. The reSubstiuteVariables function is
+used to show how the service exchanges parts of a path with a path
+variable supporting platform independent path usage.</td>
+ </tr>
+ </tbody>
+ </table>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <table class="table4">
+ <tbody>
+ <tr class="thead">
+ <td class="cell20">Disable Commands Example</td>
+ <td class="cell80">Description</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a
+ href="./OfficeDev/DisableCommands/DisableCommandsTest.java"
+ title="link to OfficeDev/DisableCommands/DisableCommandsTest.java">DisableCommandsTest</a></td>
+ <td class="cell80">Implements an example showing how
+a developer can use the configuration API to disable/enable commands at
+runtime.</td>
+ </tr>
+ </tbody>
+ </table>
+ </td>
+ </tr>
+ </tbody>
+ </table>
+ </td>
+ <td class="content1"><img class="nothing8"
+ src="../../docs/images/nada.gif"/></td>
+ </tr>
+ <tr>
+ <td colspan="3"><img class="line"
+ src="../../docs/images/sdk_line-1.gif"/></td>
+ </tr>
+ <tr>
+ <td class="content1"><img class="nothing8"
+ src="../../docs/images/nada.gif"/></td>
+ <td>
+ <table class="table2">
+ <tbody>
+ <tr>
+ <td>
+ <table class="table3">
+ <tbody>
+ <tr>
+ <td colspan="2" class="head1"><a name="Text">Text
+Documents examples</a></td>
+ <td align="right"> <a href="#examples"
+ title="link to the Developer's Guide examples overview"><img
+ class="navigate" src="../../docs/images/nav_up.png"/></a> <a
+ href="../../index.html" title="link to the SDK start page"><img
+ class="navigate" src="../../docs/images/nav_home.png"/></a> </td>
+ </tr>
+ </tbody>
+ </table>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <table class="table4">
+ <tbody>
+ <tr class="thead">
+ <td class="cell20"> Example</td>
+ <td class="cell80">Description</td>
+ </tr>
+ <tr>
+ <td class="cell20"><img
+ src="../../docs/images/bluball.gif"/> <a
+ href="./Text/TextDocuments.java"
+ title="link to Text/TextDocuments.java">TextDocuments</a></td>
+ <td class="cell80">
+ <p>Demonstrates a wide variety of API functions in
+text documents and text document views.</p>
+ <ul>
+ <li>use of templates</li>
+ <li>using the view cursor, including visible text
+selections</li>
+ <li>changing the paragraph style</li>
+ <li>using various editing facilities like text
+insertion</li>
+ <li>using various cursor interfaces</li>
+ <li>creating text contents, like tables, sections
+and frames, well as text fields and columns</li>
+ <li>using stylesheets</li>
+ <li>applying numbering styles</li>
+ <li>using references, indexes, footnotes and
+autotext</li>
+ <li>loading, storing and printing a text document</li>
+ </ul>
+ <p>Adjust the strings at the beginning of the class
+definition to match your installation!</p>
+ </td>
+ </tr>
+ </tbody>
+ </table>
+ </td>
+ </tr>
+ </tbody>
+ </table>
+ </td>
+ <td class="content1"><img class="nothing8"
+ src="../../docs/images/nada.gif"/></td>
+ </tr>
+ <tr>
+ <td colspan="3"><img class="line"
+ src="../../docs/images/sdk_line-1.gif"/></td>
+ </tr>
+ <tr>
+ <td class="content1"><img class="nothing8"
+ src="../../docs/images/nada.gif"/></td>
+ <td>
+ <table class="table2">
+ <tbody>
+ <tr>
+ <td>
+ <table class="table3">
+ <tbody>
+ <tr>
+ <td colspan="2" class="head1"><a name="Spreadsheet">Spreadsheet
+Documents examples</a></td>
+ <td align="right"> <a href="#examples"
+ title="link to the Developer's Guide examples overview"><img
+ class="navigate" src="../../docs/images/nav_up.png"/></a> <a
+ href="../../index.html" title="link to the SDK start page"><img
+ class="navigate" src="../../docs/images/nav_home.png"/></a> </td>
+ </tr>
+ </tbody>
+ </table>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <table class="table4">
+ <tbody>
+ <tr class="thead">
+ <td class="cell20"> Example</td>
+ <td class="cell80">Description</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a
+ href="./Spreadsheet/ExampleAddIn.java"
+ title="link to Spreadsheet/ExampleAddIn.java">ExampleAddIn</a></td>
+ <td class="cell80">Implements a simple add-in
+component for spreadsheet documents. This component needs to be
+deployed before it can be used.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a
+ href="./Spreadsheet/ExampleDataPilotSource.java"
+ title="link to Spreadsheet/ExampleDataPilotSource.java">ExampleDataPilotSource</a></td>
+ <td class="cell80">Shows usage of a wide variety of
+spreadsheet interfaces like <a
+ href="%DOXYGEN_PREFIX2%/docs/idl/ref/interfacecom_1_1sun_1_1star_1_1sheet_1_1XCellRangeData.html"
+ title="link to the reference documentation of com.sun.star.sheet.XCellRangeData">
+ <code>XCellRangeData</code></a>, <a
+ href="%DOXYGEN_PREFIX2%/docs/idl/ref/interfacecom_1_1sun_1_1star_1_1sheet_1_1XCellSeries.html"
+ title="link to the reference documentation of com.sun.star.sheet.XCellSeries"><code>XCellSeries</code></a>,
+ <a
+ href="%DOXYGEN_PREFIX2%/docs/idl/ref/interfacecom_1_1sun_1_1star_1_1sheet_1_1XArrayFormulaRange.html"
+ title="link to the reference documentation of com.sun.star.sheet.XArrayFormularRange"><code>XArrayFormulaRange</code></a>
+and <a
+ href="%DOXYGEN_PREFIX2%/docs/idl/ref/interfacecom_1_1sun_1_1star_1_1sheet_1_1XMultipleOperation.html"
+ title="link to the reference documentation of com.sun.star.sheet.XMultipleOperation"><code>XMultipleOperations</code></a>
+as well as named ranges, label ranges and data pilot.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><img
+ src="../../docs/images/bluball.gif"/> <a
+ href="./Spreadsheet/GeneralTableSample.java"
+ title="link to Spreadsheet/GeneralTableSample.java">GeneralTableSample</a></td>
+ <td class="cell80">Executes some examples working on
+generic tables.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a
+ href="./Spreadsheet/SpreadsheetDocHelper.java"
+ title="link to Spreadsheet/SpreadsheetDocHelper.java">SpreadsheetDocHelper</a></td>
+ <td class="cell80">Defines a helper class for the
+other examples to access spreadsheet documents, sheets and cells.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><img
+ src="../../docs/images/bluball.gif"/> <a
+ href="./Spreadsheet/SpreadsheetSample.java"
+ title="link to Spreadsheet/SpreadsheetSample.java">SpreadsheetSample</a></td>
+ <td class="cell80">Executes some examples working on
+a spreadsheet document.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><img
+ src="../../docs/images/bluball.gif"/> <a
+ href="./Spreadsheet/ViewSample.java"
+ title="link to Spreadsheet/ViewSample.java">ViewSample</a></td>
+ <td class="cell80">Shows how to manipulate view
+settings like splitting sheeting sheets and selecting cells.</td>
+ </tr>
+ </tbody>
+ </table>
+ </td>
+ </tr>
+ </tbody>
+ </table>
+ </td>
+ <td class="content1"><img class="nothing8"
+ src="../../docs/images/nada.gif"/></td>
+ </tr>
+ <tr>
+ <td colspan="3"><img class="line"
+ src="../../docs/images/sdk_line-1.gif"/></td>
+ </tr>
+ <tr>
+ <td class="content1"><img class="nothing8"
+ src="../../docs/images/nada.gif"/></td>
+ <td>
+ <table class="table2">
+ <tbody>
+ <tr>
+ <td>
+ <table class="table3">
+ <tbody>
+ <tr>
+ <td colspan="2" class="head1"><a name="Drawing">Drawing
+and Presentation Documents examples</a></td>
+ <td align="right"> <a href="#examples"
+ title="link to the Developer's Guide examples overview"><img
+ class="navigate" src="../../docs/images/nav_up.png"/></a> <a
+ href="../../index.html" title="link to the SDK start page"><img
+ class="navigate" src="../../docs/images/nav_home.png"/></a> </td>
+ </tr>
+ </tbody>
+ </table>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <table class="table4">
+ <tbody>
+ <tr class="thead">
+ <td class="cell20"> Example</td>
+ <td class="cell80">Description</td>
+ </tr>
+ <tr>
+ <td class="cell20"><img
+ src="../../docs/images/bluball.gif"/> <a
+ href="./Drawing/ChangeOrderDemo.java"
+ title="link to Drawing/ChangeOrderDemo.java">ChangeOrderDemo</a></td>
+ <td class="cell80">Shows how to change the painting
+order of shapes.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><img
+ src="../../docs/images/bluball.gif"/> <a
+ href="./Drawing/ControlAndSelectDemo.java"
+ title="link to Drawing/ControlAndSelectDemo.java">ControlAndSelectDemo</a></td>
+ <td class="cell80">Demonstrates the creation of a
+control shape and selects it in the current view.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><img
+ src="../../docs/images/bluball.gif"/> <a
+ href="./Drawing/CustomShowDemo.java"
+ title="link to Drawing/CustomShowDemo.java">CustomShowDemo</a></td>
+ <td class="cell80">Creates two custom shows and
+selects one of these.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><img
+ src="../../docs/images/bluball.gif"/> <a
+ href="./Drawing/DrawViewDemo.java"
+ title="link to Drawing/DrawViewDemo.java">DrawViewDemo</a></td>
+ <td class="cell80">Prints the view data properties
+and the controller properties of a drawing view and shows an example of
+setting such a property.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><img
+ src="../../docs/images/bluball.gif"/> <a
+ href="./Drawing/DrawingDemo.java"
+ title="link to Drawing/DrawingDemo.java">DrawingDemo</a></td>
+ <td class="cell80">Creates several shapes on several
+slides. Nice pattern included!</td>
+ </tr>
+ <tr>
+ <td class="cell20"><img
+ src="../../docs/images/bluball.gif"/> <a
+ href="./Drawing/FillAndLineStyleDemo.java"
+ title="link to Drawing/FillAndLineStyleDemo.java">FillAndLineStyleDemo</a></td>
+ <td class="cell80">Demonstrates usage of area fill
+and line style properties.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><img
+ src="../../docs/images/bluball.gif"/> <a
+ href="./Drawing/GluePointDemo.java"
+ title="link to Drawing/GluePointDemo.java">GluePointDemo</a></td>
+ <td class="cell80">Creates two shapes with glue
+points and connects them with two connectors.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><img
+ src="../../docs/images/bluball.gif"/> <a
+ href="./Drawing/GraphicExportDemo.java"
+ title="link to Drawing/GraphicExportDemo.java">GraphicExportDemo</a></td>
+ <td class="cell80">Loads a drawing document and
+exports it to a GIF file. Run this program with source URL, target URL
+and page index on the command line, where the URLs are fully qualified
+URLs.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a href="./Drawing/Helper.java"
+ title="link to Drawing/Helper.java">Helper</a></td>
+ <td class="cell80">Contains a helper class for the
+other examples to connect to LibreOffice %PRODUCT_RELEASE% and open or create a drawing
+document.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><img
+ src="../../docs/images/bluball.gif"/> <a
+ href="./Drawing/LayerDemo.java" title="link to Drawing/LayerDemo.java">LayerDemo</a></td>
+ <td class="cell80">Creates shapes in different layers
+to show how to protect shapes from modifications.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><img
+ src="../../docs/images/bluball.gif"/> <a
+ href="./Drawing/ObjectTransformationDemo.java"
+ title="link to Drawing/ObjectTransformationDemo.java">ObjectTransformationDemo</a></td>
+ <td class="cell80">Shows geometric transformations on
+a shape using a homogeneous matrix.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><img
+ src="../../docs/images/bluball.gif"/> <a
+ href="./Drawing/Organigram.java"
+ title="link to Drawing/Organigram.java">Organigram</a></td>
+ <td class="cell80">Demonstrates the creation of an
+organigram consisting of shapes and connectors.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a href="./Drawing/PageHelper.java"
+ title="link to Drawing/PageHelper.java">PageHelper</a></td>
+ <td class="cell80">Contains a helper class for
+accessing several kinds of draw pages in a presentation or drawing
+document.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><img
+ src="../../docs/images/bluball.gif"/> <a
+ href="./Drawing/PresentationDemo.java"
+ title="link to Drawing/PresentationDemo.java">PresentationDemo</a></td>
+ <td class="cell80">Creates a presentation and runs it
+with some user interaction.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a
+ href="./Drawing/ShapeHelper.java"
+ title="link to Drawing/ShapeHelper.java">ShapeHelper</a></td>
+ <td class="cell80">Contains a helper class for
+accessing and creating shapes for the other examples.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><img
+ src="../../docs/images/bluball.gif"/> <a
+ href="./Drawing/StyleDemo.java" title="link to Drawing/StyleDemo.java">StyleDemo</a></td>
+ <td class="cell80">Creates a shape and applies a
+predefined shape stylesheet.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><img
+ src="../../docs/images/bluball.gif"/> <a href="./Drawing/TextDemo.java"
+ title="link to Drawing/TextDemo.java">TextDemo</a></td>
+ <td class="cell80">Demonstrates usage of text and
+text styles in shapes.</td>
+ </tr>
+ </tbody>
+ </table>
+ </td>
+ </tr>
+ </tbody>
+ </table>
+ </td>
+ <td class="content1"><img class="nothing8"
+ src="../../docs/images/nada.gif"/></td>
+ </tr>
+ <tr>
+ <td colspan="3"><img class="line"
+ src="../../docs/images/sdk_line-1.gif"/></td>
+ </tr>
+ <tr>
+ <td class="content1"><img class="nothing8"
+ src="../../docs/images/nada.gif"/></td>
+ <td>
+ <table class="table2">
+ <tbody>
+ <tr>
+ <td>
+ <table class="table3">
+ <tbody>
+ <tr>
+ <td colspan="2" class="head1"><a name="Charts">Charts
+examples</a></td>
+ <td align="right"> <a href="#examples"
+ title="link to the Developer's Guide examples overview"><img
+ class="navigate" src="../../docs/images/nav_up.png"/></a> <a
+ href="../../index.html" title="link to the SDK start page"><img
+ class="navigate" src="../../docs/images/nav_home.png"/></a> </td>
+ </tr>
+ </tbody>
+ </table>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <table class="table4">
+ <tbody>
+ <tr class="thead">
+ <td class="cell20"> Example</td>
+ <td class="cell80">Description</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a href="./Charts/CalcHelper.java"
+ title="link to Charts/CalcHelper.java">CalcHelper</a></td>
+ <td class="cell80">Contains some helper methods for
+charts in spreadsheet documents, like accessing sheets by name,
+inserting a chart into a sheet, filling cell ranges with random numbers
+etc.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a href="./Charts/ChartHelper.java"
+ title="link to Charts/ChartHelper.java">ChartHelper</a></td>
+ <td class="cell80">Contains some helper methods for
+charts, like creating a chart as an embedded object.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><img
+ src="../../docs/images/bluball.gif"/> <a
+ href="./Charts/ChartInCalc.java"
+ title="link to Charts/ChartInCalc.java">ChartInCalc</a></td>
+ <td class="cell80">Demonstrates how to create an
+embedded chart object with a random scatter chart within a spreadsheet.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><img
+ src="../../docs/images/bluball.gif"/> <a
+ href="./Charts/ChartInDraw.java"
+ title="link to Charts/ChartInDraw.java">ChartInDraw</a></td>
+ <td class="cell80">Inserts a 3D-bar chart into a
+drawing document.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><img
+ src="../../docs/images/bluball.gif"/> <a
+ href="./Charts/ChartInWriter.java"
+ title="link to Charts/ChartInWriter.java">ChartInWriter</a></td>
+ <td class="cell80">Inserts an embedded chart object
+with a random bar chart in a text document. This example does not
+really work, because the API for embedding objects into text documents
+is not implemented. To be more precise.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a href="./Charts/Helper.java"
+ title="link to Charts/Helper.java">Helper</a></td>
+ <td class="cell80">Shows how to connect to
+LibreOffice %PRODUCT_RELEASE% and create text, drawing or spreadsheet document. This
+class is used as a helper class for the other examples.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a
+ href="./Charts/JavaSampleChartAddIn.java"
+ title="link to Charts/JavaSampleChartAddIn.java">JavaSampleChartAddIn</a></td>
+ <td class="cell80">Gives an example of how to
+implement chart add-ins to create new or specialized diagram types. The
+resulting component has to be deployed before it can be used.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><img
+ src="../../docs/images/bluball.gif"/> <a
+ href="./Charts/ListenAtCalcRangeInDraw.java"
+ title="link to Charts/ListenAtCalcRangeInDraw.java">ListenAtCalcRangeInDraw</a></td>
+ <td class="cell80">This helper class is used to build
+connection between an embedded chart object in a drawing document and a
+data range in a spreadsheet document.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><img
+ src="../../docs/images/bluball.gif"/> <a
+ href="./Charts/SelectionChangeListener.java"
+ title="link to Charts/SelectionChangeListener.java">SelectionChangeListener</a></td>
+ <td class="cell80">Shows how to register a handler
+which is called when the selection within an embedded chart object
+changes.</td>
+ </tr>
+ </tbody>
+ </table>
+ </td>
+ </tr>
+ </tbody>
+ </table>
+ </td>
+ <td class="content1"><img class="nothing8"
+ src="../../docs/images/nada.gif"/></td>
+ </tr>
+ <tr>
+ <td colspan="3"><img class="line"
+ src="../../docs/images/sdk_line-1.gif"/></td>
+ </tr>
+ <tr>
+ <td class="content1"><img class="nothing8"
+ src="../../docs/images/nada.gif"/></td>
+ <td>
+ <table class="table2">
+ <tbody>
+ <tr>
+ <td>
+ <table class="table3">
+ <tbody>
+ <tr>
+ <td colspan="2" class="head1"><a
+ name="BasicandDialogs">LibreOffice %PRODUCT_RELEASE% Basic and Dialogs examples</a></td>
+ <td align="right"> <a href="#examples"
+ title="link to the Developer's Guide examples overview"><img
+ class="navigate" src="../../docs/images/nav_up.png"/></a> <a
+ href="../../index.html" title="link to the SDK start page"><img
+ class="navigate" src="../../docs/images/nav_home.png"/></a> </td>
+ </tr>
+ </tbody>
+ </table>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <table class="table4">
+ <tbody>
+ <tr class="thead">
+ <td class="cell20">Example</td>
+ <td class="cell80">Description</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a
+ href="./BasicAndDialogs/FirstStepsBasic.odt"
+ title="link to BasicAndDialogs/FirstStepsBasic.odt">FirstStepsBasic.odt</a></td>
+ <td class="cell80">This StarBasic example shows how to
+create an own dialog which inserts a graphics object into a text
+document.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a
+ href="./BasicAndDialogs/CreatingDialogs/SampleDialog.java"
+ title="link to BasicAndDialogs/CreatingDialogs/SampleDialog.java">SampleDialog</a></td>
+ <td class="cell80">This example builds a Java
+component which creates a simple dialog.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a
+ href="./BasicAndDialogs/CreatingDialogs/CreatingDialogs.odt"
+ title="link to BasicAndDialogs/CreatingDialogs/CreatingDialogs.odt">CreatingDialogs.odt</a></td>
+ <td class="cell80">This document contains a simple
+Basic macro which loads the SampleDialog component. The macro will be
+executed by pressing a Push button.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a
+ href="./BasicAndDialogs/ToolkitControls/ToolkitControls"
+ title="link to BasicAndDialogs/ToolkitControls">ToolkitControls</a></td>
+ <td class="cell80">In this directory you find a Basic
+library which implements several examples using toolkit controls. You
+can easy pack this Basic library as a UNO package and can install it
+using the package manager (see the makefile output).<br/>
+After the installation you will find a new library "ToolkitControls" in
+the Basic IDE containing 4 modules and the necessary dialogs.<br/>
+ <p>Select one of the following modules and press the
+Run button: </p>
+ <ul>
+ <li>FileDialog = simple dialog which ask for a
+filename (nothing else) </li>
+ <li>MultiPage = a more complex dialog with several
+tab pages </li>
+ <li>ProgressBar = a dialog which shows a progress
+bar </li>
+ <li>ScrollBar = a dialog which shows a scroll bar </li>
+ </ul>
+ </td>
+ </tr>
+ </tbody>
+ </table>
+ </td>
+ </tr>
+ </tbody>
+ </table>
+ </td>
+ <td class="content1"><img class="nothing8"
+ src="../../docs/images/nada.gif"/></td>
+ </tr>
+ <tr>
+ <td colspan="3"><img class="line"
+ src="../../docs/images/sdk_line-1.gif"/></td>
+ </tr>
+ <tr>
+ <td class="content1"><img class="nothing8"
+ src="../../docs/images/nada.gif"/></td>
+ <td>
+ <table class="table2">
+ <tbody>
+ <tr>
+ <td>
+ <table class="table3">
+ <tbody>
+ <tr>
+ <td colspan="2" class="head1"><a name="Database">Database
+Access examples</a></td>
+ <td align="right"> <a href="#examples"
+ title="link to the Developer's Guide examples overview"><img
+ class="navigate" src="../../docs/images/nav_up.png"/></a> <a
+ href="../../index.html" title="link to the SDK start page"><img
+ class="navigate" src="../../docs/images/nav_home.png"/></a> </td>
+ </tr>
+ <tr>
+ <td colspan="3"> The Database examples use a SQL
+database named "MYDB0" with write access. Make sure that you have a
+data source operating on such a database in your office before you run
+the example. </td>
+ </tr>
+ </tbody>
+ </table>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <table class="table4">
+ <tbody>
+ <tr class="thead">
+ <td class="cell20">Database Examples</td>
+ <td class="cell80">Description</td>
+ </tr>
+ <tr>
+ <td class="cell20"><img
+ src="../../docs/images/bluball.gif"/> <a
+ href="./Database/CodeSamples.java"
+ title="link to Database/CodeSamples.java">CodeSamples</a></td>
+ <td class="cell80">Creates the connection to
+LibreOffice %PRODUCT_RELEASE% and executes the code SalesMan samples for database API.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><img
+ src="../../docs/images/bluball.gif"/> <a
+ href="./Database/OpenQuery.java"
+ title="link to Database/OpenQuery.java">OpenQuery</a></td>
+ <td class="cell80">Demonstrates the use of <a
+ href="%DOXYGEN_PREFIX2%/docs/idl/ref/interfacecom_1_1sun_1_1star_1_1sdbc_1_1XResultSetUpdate.html"
+ title="link to the reference documentation of com.sun.star.sdbc.XResultSetUpdate"><code>XResultSetUpdate</code></a>
+and <a href="%DOXYGEN_PREFIX2%/docs/idl/ref/interfacecom_1_1sun_1_1star_1_1sdbc_1_1XRowUpdate.html"
+ title="link to the reference documentation of com.sun.star.sdbc.XRowUpdate">
+ <code>XRowUpdate</code></a>.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><img
+ src="../../docs/images/bluball.gif"/> <a href="./Database/RowSet.java"
+ title="link to Database/RowSet.java">RowSet</a></td>
+ <td class="cell80">Demonstrates the usage of a row
+set.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a
+ href="./Database/RowSetEventListener.java"
+ title="link to Database/RowSetEventListener.java">RowSetEventListener</a></td>
+ <td class="cell80">Demonstrates how to define
+listener for the row set example.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a href="./Database/Sales.java"
+ title="link to Database/Sales.java">Sales</a></td>
+ <td class="cell80">Creates a simple database table.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a href="./Database/SalesMan.java"
+ title="link to Database/SalesMan.java">SalesMan</a></td>
+ <td class="cell80">Creates a simple database table.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a href="./Database/sdbcx.java"
+ title="link to Database/sdbcx.java">sdbcx</a></td>
+ <td class="cell80">Demonstrates the usage of the
+SDBCX layer services.</td>
+ </tr>
+ </tbody>
+ </table>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <table class="table4">
+ <tbody>
+ <tr class="thead">
+ <td class="cell20">Driver Skeleton Example</td>
+ <td class="cell80">Description</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a
+ href="./Database/DriverSkeleton/OSubComponent.hxx"
+ title="link to Database/DriverSkeleton/OSubComponent.hxx">OSubComponent.hxx</a></td>
+ <td class="cell80">Helper class to delegate special
+dispose handling.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a
+ href="./Database/DriverSkeleton/OTypeInfo.hxx"
+ title="link to Database/DriverSkeleton/OTypeInfo.hxx">OTypeInfo.hxx</a></td>
+ <td class="cell80">Contains the database types from
+the DatabaseMetaData getTypes call.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a
+ href="./Database/DriverSkeleton/SConnection.hxx"
+ title="link to Database/DriverSkeleton/SConnection.hxx">SConnection.hxx</a></td>
+ <td class="cell80">This file contains the declaration
+of a class implementing the service <code>com.sun.star.sdbc.Connection</code>.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a
+ href="./Database/DriverSkeleton/SConnection.cxx"
+ title="link to Database/DriverSkeleton/SConnection.cxx">SConnection.cxx</a></td>
+ <td class="cell80">This file contains the
+implementation of the class declared in SConnection.hxx.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a
+ href="./Database/DriverSkeleton/SDatabaseMetaData.hxx"
+ title="link to Database/DriverSkeleton/SDatabaseMetaData.hxx">SDatabaseMetaData.hxx</a></td>
+ <td class="cell80">This file contains the declaration
+of a class implementing the interface <code>com.sun.star.sdbc.XDatabaseMetaData</code>.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a
+ href="./Database/DriverSkeleton/SDatabaseMetaData.cxx"
+ title="link to Database/DriverSkeleton/SDatabaseMetaData.cxx">SDatabaseMetaData.cxx</a></td>
+ <td class="cell80">This file contains the
+implementation of the class declared in SDatabaseMetaData.hxx.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a
+ href="./Database/DriverSkeleton/SDriver.hxx"
+ title="link to Database/DriverSkeleton/SDriver.hxx">SDriver.hxx</a></td>
+ <td class="cell80">This file contains the declaration
+of a class implementing the service <code>com.sun.star.sdbc.Driver</code>.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a
+ href="./Database/DriverSkeleton/SDriver.cxx"
+ title="link to Database/DriverSkeleton/SDriver.cxx">SDriver.cxx</a></td>
+ <td class="cell80">This file contains the
+implementation of the class declared in SDriver.hxx.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a
+ href="./Database/DriverSkeleton/SPreparedStatement.hxx"
+ title="link to Database/DriverSkeleton/SPreparedStatement.hxx">SPreparedStatement.hxx</a></td>
+ <td class="cell80">This file contains the declaration
+of a class implementing the service <code>com.sun.star.sdbc.PreparedStatement</code>.
+ </td>
+ </tr>
+ <tr>
+ <td class="cell20"><a
+ href="./Database/DriverSkeleton/SPreparedStatement.cxx"
+ title="link to Database/DriverSkeleton/SPreparedStatement.cxx">SPreparedStatement.cxx</a></td>
+ <td class="cell80">This file contains the
+implementation of the class declared in SPreparedStatement.hxx.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a
+ href="./Database/DriverSkeleton/SResultSet.hxx"
+ title="link to Database/DriverSkeleton/SResultSet.hxx">SResultSet.hxx</a></td>
+ <td class="cell80">This file contains the declaration
+of a class implementing the service <code>com.sun.star.sdbc.ResultSet</code>.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a
+ href="./Database/DriverSkeleton/SResultSet.cxx"
+ title="link to Database/DriverSkeleton/SResultSet.cxx">SResultSet.cxx</a></td>
+ <td class="cell80">This file contains the
+implementation of the class declared in SResultSet.hxx.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a
+ href="./Database/DriverSkeleton/SResultSetMetaData.hxx"
+ title="link to Database/DriverSkeleton/SResultSetMetaData.hxx">SResultSetMetaData.hxx</a></td>
+ <td class="cell80">This file contains the declaration
+of a class implementing the interface <code>com.sun.star.sdbc.XResultSetMetaData</code>.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a
+ href="./Database/DriverSkeleton/SResultSetMetaData.cxx"
+ title="link to Database/DriverSkeleton/SResultSetMetaData.cxx">SResultSetMetaData.cxx</a></td>
+ <td class="cell80">This file contains the
+implementation of the class declared in SResultSetMetaData.hxx.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a
+ href="./Database/DriverSkeleton/SServices.cxx"
+ title="link to Database/DriverSkeleton/SServices.cxx">SServices.cxx</a></td>
+ <td class="cell80">This file contains a class
+implementing the service needed to register the driver.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a
+ href="./Database/DriverSkeleton/SStatement.hxx"
+ title="link to Database/DriverSkeleton/SStatement.hxx">SStatement.hxx</a></td>
+ <td class="cell80">This file contains the declaration
+of a class implementing the service <code>com.sun.star.sdbc.Statement</code>.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a
+ href="./Database/DriverSkeleton/SStatement.cxx"
+ title="link to Database/DriverSkeleton/SStatement.cxx">SStatement.cxx</a></td>
+ <td class="cell80">This file contains the
+implementation of the class declared in SStatement.hxx.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a
+ href="./Database/DriverSkeleton/propertyids.hxx"
+ title="link to Database/DriverSkeleton/propertyids.hxx">propertyids.hxx</a></td>
+ <td class="cell80">Defines some common used strings
+and declare a helper class for properties.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a
+ href="./Database/DriverSkeleton/propertyids.cxx"
+ title="link to Database/DriverSkeleton/propertyids.cxx">propertyids.cxx</a></td>
+ <td class="cell80">Implements the property helper
+class.</td>
+ </tr>
+ </tbody>
+ </table>
+ </td>
+ </tr>
+ </tbody>
+ </table>
+ </td>
+ <td class="content1"><img class="nothing8"
+ src="../../docs/images/nada.gif"/></td>
+ </tr>
+ <tr>
+ <td colspan="3"><img class="line"
+ src="../../docs/images/sdk_line-1.gif"/></td>
+ </tr>
+ <tr>
+ <td class="content1"><img class="nothing8"
+ src="../../docs/images/nada.gif"/></td>
+ <td>
+ <table class="table2">
+ <tbody>
+ <tr>
+ <td>
+ <table class="table3">
+ <tbody>
+ <tr>
+ <td colspan="2" class="head1"><a name="Forms">Forms
+examples</a></td>
+ <td align="right"> <a href="#examples"
+ title="link to the Developer's Guide examples overview"><img
+ class="navigate" src="../../docs/images/nav_up.png"/></a> <a
+ href="../../index.html" title="link to the SDK start page"><img
+ class="navigate" src="../../docs/images/nav_home.png"/></a> </td>
+ </tr>
+ </tbody>
+ </table>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <table class="table4">
+ <tbody>
+ <tr class="thead">
+ <td class="cell20">Example</td>
+ <td class="cell80">Description</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a
+ href="./Forms/BooleanValidator.java"
+ title="link to Forms/BooleanValidator.java">BooleanValidator</a></td>
+ <td class="cell80">The class <code>BooleanOperator</code>
+implements an <a
+ href="%DOXYGEN_PREFIX2%/docs/idl/ref/interfacecom_1_1sun_1_1star_1_1form_1_1validation_1_1XValidator.html"
+ title="link to the reference documentation of com.sun.star.form.validation.XValidator">validator</a>
+for a form control, which can veto certain radio button or check box
+states.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a
+ href="./Forms/ButtonOperator.java"
+ title="link to Forms/ButtonOperator.java">ButtonOperator</a></td>
+ <td class="cell80">The form created by the sample
+program contains various buttons which are tied to certain
+functionality. The class ButtonOperator, well, operates these buttons.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a
+ href="./Forms/ComponentTreeTraversal.java"
+ title="link to Forms/ComponentTreeTraversal.java">ComponentTreeTraversal</a></td>
+ <td class="cell80">Helper classes for traveling
+through a tree of <a
+ href="%DOXYGEN_PREFIX2%/docs/idl/ref/servicecom_1_1sun_1_1star_1_1form_1_1FormComponent.html"
+ title="link to the reference documentation of com.sun.star.form.FormComponent">
+ <code>FormComponent's</code></a>.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a href="./Forms/ControlLock.java"
+ title="link to Forms/ControlLock.java">ControlLock</a></td>
+ <td class="cell80">Helper class for implementing the
+locking of control depending on the state of the underlying <a
+ href="%DOXYGEN_PREFIX2%/docs/idl/ref/servicecom_1_1sun_1_1star_1_1sdb_1_1RowSet.html"
+ title="link to the reference documentation of com.sun.star.sdb.RowSet"><code>RowSet</code></a>.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><img
+ src="../../docs/images/bluball.gif"/> <a
+ href="./Forms/ControlValidation.java"
+ title="link to Forms/ControlValidation.java">ControlValidation</a></td>
+ <td class="cell80">This is the main class for the
+control validation example. It creates a sample document, fills it with
+controls, and attaches several validators to those controls</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a
+ href="./Forms/ControlValidator.java"
+ title="link to Forms/ControlValidator.java">ControlValidator</a></td>
+ <td class="cell80">Base class implementing the common
+denominator for components <a
+ href="%DOXYGEN_PREFIX2%/docs/idl/ref/servicecom_1_1sun_1_1star_1_1form_1_1validation_1_1ValidatableControlModel.html"
+ title="link to the reference documentation of com.sun.star.form.validation.ValidatableControlModel">validating
+form controls.</a></td>
+ </tr>
+ <tr>
+ <td class="cell20"><img
+ src="../../docs/images/bluball.gif"/> <a
+ href="./Forms/DataAwareness.java"
+ title="link to Forms/DataAwareness.java">DataAwareness</a></td>
+ <td class="cell80">This class implements the basic
+example for a form working on a database. Two tables will be created
+and a form (writer document) with a business example will fill its
+fields from these tables.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a
+ href="./Forms/DateValidator.java"
+ title="link to Forms/DateValidator.java">DateValidator</a></td>
+ <td class="cell80">The class <code>DateValidator</code>
+implements an <a
+ href="%DOXYGEN_PREFIX2%/docs/idl/ref/interfacecom_1_1sun_1_1star_1_1form_1_1validation_1_1XValidator.html"
+ title="link to the reference documentation of com.sun.star.form.validation.XValidator">validator</a>
+for a form control, which can check the content of a form date field. </td>
+ </tr>
+ <tr>
+ <td class="cell20"><a
+ href="./Forms/DocumentBasedExample.java"
+ title="link to Forms/DocumentBasedExample.java">DocumentBasedExample</a></td>
+ <td class="cell80">This class collects common
+functionality of examples which require a document.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a
+ href="./Forms/DocumentHelper.java"
+ title="link to Forms/DocumentHelper.java">DocumentHelper</a></td>
+ <td class="cell80">Helper class for encapsulating
+working with a document.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a href="./Forms/DocumentType.java"
+ title="link to Forms/DocumentType.java">DocumentType</a></td>
+ <td class="cell80">A simple enumeration class for
+classifying a document.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a
+ href="./Forms/DocumentViewHelper.java"
+ title="link to Forms/DocumentViewHelper.java">DocumentViewHelper</a></td>
+ <td class="cell80">Helper class for encapsulating
+working with a view for a document.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a href="./Forms/FLTools.java"
+ title="link to Forms/FLTools.java">FLTools</a></td>
+ <td class="cell80">Various small tools for the form
+layer sample program.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a href="./Forms/FormLayer.java"
+ title="link to Forms/FormLayer.java">FormLayer</a></td>
+ <td class="cell80">Helper class for accessing and
+manipulating the form layer of a document.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a
+ href="./Forms/GridFieldValidator.java"
+ title="link to Forms/GridFieldValidator.java">GridFieldValidator</a></td>
+ <td class="cell80"><code>GridFieldValidator</code> is
+responsible for validating the input in a specific grid control column.
+This is not to be mixed up with the control-based validation as
+described in the <a
+ href="%DOXYGEN_PREFIX2%/docs/idl/ref/namespacecom_1_1sun_1_1star_1_1form_1_1validation.html"
+ title="link to the reference documentation of com.sun.star.form.validation">validation</a>
+module. Instead, a <code>GridFieldValidator</code> assembles and uses
+various other concepts.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a
+ href="./Forms/InteractionRequest.java"
+ title="link to Forms/InteractionRequest.java">InteractionRequest</a></td>
+ <td class="cell80">A simple implementation of a <a
+ href="%DOXYGEN_PREFIX2%/docs/idl/ref/interfacecom_1_1sun_1_1star_1_1task_1_1XInteractionRequest.html"
+ title="link to the reference documentation of com.sun.star.task.XInteractionRequest"><code>XInteractionRequest</code></a>.
+Not tied to the form layer example, but a general helper.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a href="./Forms/KeyGenerator.java"
+ title="link to Forms/KeyGenerator.java">KeyGenerator</a></td>
+ <td class="cell80">Helper class which is able to
+generate (unique) keys for a (<a
+ href="%DOXYGEN_PREFIX2%/docs/idl/ref/servicecom_1_1sun_1_1star_1_1sdb_1_1RowSet.html"
+ title="link to the reference documentation of com.sun.star.sdb.RowSet"><code>RowSet</code>
+ </a>) column. An instance of this class can be tied
+to a specific row set column. It then monitors the state of the
+underlying row set, and upon inserting a new record into it (two
+operation modi are possible here), it automatically inserts a newly
+created (two modi, too) key into the column.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a
+ href="./Forms/ListSelectionValidator.java"
+ title="link to Forms/ListSelectionValidator.java">ListSelectionValidator</a></td>
+ <td class="cell80">The class <code>ListSelectionValidator</code>
+implements an <a
+ href="%DOXYGEN_PREFIX2%/docs/idl/ref/interfacecom_1_1sun_1_1star_1_1form/validation_1_1XValidator.html"
+ title="link to the reference documentation of com.sun.star.form.validation.XValidator">validator</a>
+for a form control, which can veto certain selections in a list box
+control.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a
+ href="./Forms/NumericValidator.java"
+ title="link to Forms/NumericValidator.java">NumericValidator</a></td>
+ <td class="cell80">The class <code>NumericValidator</code>
+implements an <a
+ href="%DOXYGEN_PREFIX2%/docs/idl/ref/interfacecom_1_1sun_1_1star_1_1form/validation_1_1XValidator.html"
+ title="link to the reference documentation of com.sun.star.form.validation.XValidator">validator</a>
+for a form control, which can veto certain values in every control
+which allows exchanging numerical values.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a
+ href="./Forms/SingleControlValidation.java"
+ title="link to Forms/SingleControlValidation.java">SingleControlValidation</a></td>
+ <td class="cell80">Though form documents feature
+inbuilt mechanisms for visually indicating invalid control content (see
+ <a
+ href="%DOXYGEN_PREFIX2%/docs/idl/ref/namespacecom_1_1sun_1_1star_1_1form_1_1validation.html"
+ title="link to the reference documentation of com.sun.star.form.validation"><code>com.sun.star.form.validation</code>
+ </a> for discussions about validity), the <a
+ href="./Forms/ControlValidation.java"
+ title="link to Forms/ControlValidation.java">ControlValidation</a>
+example extends this. The validity state of every control in this
+example, as well as possible explanations for invalidity, are displayed
+in dedicated texts. The <code>SingleControlValidation</code> class
+ties together a validatable control and those status texts.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a
+ href="./Forms/SpreadsheetDocument.java"
+ title="link to Forms/SpreadsheetDocument.java">SpreadsheetDocument</a></td>
+ <td class="cell80">A specialized <a
+ href="./Forms/DocumentHelper.java"
+ title="link to Forms/DocumentHelper.java"><code>DocumentHelper</code></a>
+which represents a spreadsheet document, and offers some form related
+functionality. For instance, this class allows the creation of <a
+ href="%DOXYGEN_PREFIX2%/docs/idl/ref/servicecom_1_1sun_1_1star_1_1table_1_1CellValueBinding.html"
+ title="link to the reference documentation of com.sun.star.table.CellValueBinding">
+ <code>CellValueBinding</code></a> instances, which
+can be used to couple the content of a form control with the content of
+a spreadsheet cell.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><img
+ src="../../docs/images/bluball.gif"/> <a
+ href="./Forms/SpreadsheetValueBinding.java"
+ title="link to Forms/SpreadsheetValueBinding.java">SpreadsheetValueBinding</a></td>
+ <td class="cell80">This example demonstrates how to
+bind form controls to spreadsheet cells.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a
+ href="./Forms/SpreadsheetView.java"
+ title="link to Forms/SpreadsheetView.java">SpreadsheetView</a></td>
+ <td class="cell80">A specialized <a
+ href="./Forms/DocumentViewHelper.java"
+ title="link to Forms/DocumentViewHelper.java"><code>DocumentViewHelper</code></a>
+which represents a view to a spreadsheet document.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a
+ href="./Forms/TableCellTextBinding.java"
+ title="link to Forms/TableCellTextBinding.java">TableCellTextBinding</a></td>
+ <td class="cell80">This class allows binding the
+control of a form control with a table cell in a text document. For
+this, it uses the mechanisms of the <a
+ href="%DOXYGEN_PREFIX2%/docs/idl/ref/namespacecom_1_1sun_1_1star_1_1form_1_1binding.html"
+ title="link to the reference documentation of com.sun.star.form.binding">
+ <code>com.sun.star.form.binding</code></a> module.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a
+ href="./Forms/TextValidator.java"
+ title="link to Forms/TextValidator.java">TextValidator</a></td>
+ <td class="cell80">The class <code>TextValidator</code>
+implements an <a
+ href="%DOXYGEN_PREFIX2%/docs/idl/ref/interfacecom_1_1sun_1_1star_1_1form_1_1validation_1_1XValidator.html"
+ title="link to the reference documentation of com.sun.star.form.validation.XValidator">validator</a>
+for a form control, which can monitor a form text field.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a
+ href="./Forms/TimeValidator.java"
+ title="link to Forms/TimeValidator.java">TimeValidator</a></td>
+ <td class="cell80">The class <code>TimeValidator</code>
+implements an <a
+ href="%DOXYGEN_PREFIX2%/docs/idl/ref/interfacecom_1_1sun_1_1star_1_1form_1_1validation_1_1XValidator.html"
+ title="link to the reference documentation of com.sun.star.form.validation.XValidator">validator</a>
+for a form control, which can monitor the content of a form time field.
+ </td>
+ </tr>
+ <tr>
+ <td class="cell20"><a href="./Forms/UNO.java"
+ title="link to Forms/UNO.java">UNO</a></td>
+ <td class="cell80">A small UNO-syntax related helper
+class.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><img
+ src="../../docs/images/bluball.gif"/> <a
+ href="./Forms/ValueBinding.java"
+ title="link to Forms/ValueBinding.java">ValueBinding</a></td>
+ <td class="cell80">An example how to bind the content
+of a form control to a table cell in a text document.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a href="./Forms/WaitForInput.java"
+ title="link to Forms/WaitForInput.java">WaitForInput</a></td>
+ <td class="cell80">A pretty small helper for the
+interactive examples, which notifies another instance when the user
+pressed key on the console.</td>
+ </tr>
+ </tbody>
+ </table>
+ </td>
+ </tr>
+ </tbody>
+ </table>
+ </td>
+ <td class="content1"><img class="nothing8"
+ src="../../docs/images/nada.gif"/></td>
+ </tr>
+ <tr>
+ <td colspan="3"><img class="line"
+ src="../../docs/images/sdk_line-1.gif"/></td>
+ </tr>
+ <tr>
+ <td class="content1"><img class="nothing8"
+ src="../../docs/images/nada.gif"/></td>
+ <td>
+ <table class="table2">
+ <tbody>
+ <tr>
+ <td>
+ <table class="table3">
+ <tbody>
+ <tr>
+ <td colspan="2" class="head1"><a
+ name="UniversalContentBroker">Universal Content Broker (UCB)
+examples</a></td>
+ <td align="right"> <a href="#examples"
+ title="link to the Developer's Guide examples overview"><img
+ class="navigate" src="../../docs/images/nav_up.png"/></a> <a
+ href="../../index.html" title="link to the SDK start page"><img
+ class="navigate" src="../../docs/images/nav_home.png"/></a> </td>
+ </tr>
+ </tbody>
+ </table>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <table class="table4">
+ <tbody>
+ <tr class="thead">
+ <td class="cell20">Example</td>
+ <td class="cell80">Description</td>
+ </tr>
+ <tr>
+ <td class="cell20"><img
+ src="../../docs/images/bluball.gif"/> <a
+ href="./UCB/ChildrenRetriever.java"
+ title="link to UCB/ChildrenRetriever.java">ChildrenRetriever</a></td>
+ <td class="cell80">Shows child entries of a given
+folder. Try -help or -? on the command line to view optional parameters.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><img
+ src="../../docs/images/bluball.gif"/> <a
+ href="./UCB/DataStreamComposer.java"
+ title="link to UCB/DataStreamComposer.java">DataStreamComposer</a></td>
+ <td class="cell80">Demonstrates usage of the data
+stream by copying the data from one UCB node to another.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><img
+ src="../../docs/images/bluball.gif"/> <a
+ href="./UCB/DataStreamRetriever.java"
+ title="link to UCB/DataStreamRetriever.java">DataStreamRetriever</a></td>
+ <td class="cell80">Shows how to obtain the data
+stream from a document resource.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a href="./UCB/Helper.java"
+ title="link to UCB/Helper.java">Helper</a></td>
+ <td class="cell80">Some helper methods to access the
+UCB which are used by the other examples.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a
+ href="./UCB/MyActiveDataSink.java"
+ title="link to UCB/MyActiveDataSink.java">MyActiveDataSink</a></td>
+ <td class="cell80">A helper class for the <code>DataStreamRetriever</code>
+example which implements a data sink.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><img
+ src="../../docs/images/bluball.gif"/> <a
+ href="./UCB/PropertiesComposer.java"
+ title="link to UCB/PropertiesComposer.java">PropertiesComposer</a></td>
+ <td class="cell80">Shows how to set property values
+of a UCB resource.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><img
+ src="../../docs/images/bluball.gif"/> <a
+ href="./UCB/PropertiesRetriever.java"
+ title="link to UCB/PropertiesRetriever.java">PropertiesRetriever</a></td>
+ <td class="cell80">Shows how to access property
+values of a UCB resource.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><img
+ src="../../docs/images/bluball.gif"/> <a
+ href="./UCB/ResourceCreator.java"
+ title="link to UCB/ResourceCreator.java">ResourceCreator</a></td>
+ <td class="cell80">Creates a new file in an existing
+file system folder.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><img
+ src="../../docs/images/bluball.gif"/> <a
+ href="./UCB/ResourceManager.java"
+ title="link to UCB/ResourceManager.java">ResourceManager</a></td>
+ <td class="cell80">Demonstrates how to copy and move
+UCB resources.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><img
+ src="../../docs/images/bluball.gif"/> <a
+ href="./UCB/ResourceRemover.java"
+ title="link to UCB/ResourceRemover.java">ResourceRemover</a></td>
+ <td class="cell80">Demonstrates how to remove UCB
+resources.</td>
+ </tr>
+ </tbody>
+ </table>
+ </td>
+ </tr>
+ </tbody>
+ </table>
+ </td>
+ <td class="content1"><img class="nothing8"
+ src="../../docs/images/nada.gif"/></td>
+ </tr>
+ <tr>
+ <td colspan="3"><img class="line"
+ src="../../docs/images/sdk_line-1.gif"/></td>
+ </tr>
+ <tr>
+ <td class="content1"><img class="nothing8"
+ src="../../docs/images/nada.gif"/></td>
+ <td>
+ <table class="table2">
+ <tbody>
+ <tr>
+ <td>
+ <table class="table3">
+ <tbody>
+ <tr>
+ <td colspan="2" class="head1"><a name="Configuration">Configuration
+Management examples</a></td>
+ <td align="right"> <a href="#examples"
+ title="link to the Developer's Guide examples overview"><img
+ class="navigate" src="../../docs/images/nav_up.png"/></a> <a
+ href="../../index.html" title="link to the SDK start page"><img
+ class="navigate" src="../../docs/images/nav_home.png"/></a> </td>
+ </tr>
+ </tbody>
+ </table>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <table class="table4">
+ <tbody>
+ <tr class="thead">
+ <td class="cell20">Example</td>
+ <td class="cell80">Description</td>
+ </tr>
+ <tr>
+ <td class="cell20"><img
+ src="../../docs/images/bluball.gif"/> <a
+ href="./Config/ConfigExamples.java"
+ title="link to Config/ConfigExamples.java">ConfigExamples</a></td>
+ <td class="cell80">This example connects to a
+LibreOffice %PRODUCT_RELEASE%, gets the configuration manager and accesses the
+configuration in various ways.</td>
+ </tr>
+ </tbody>
+ </table>
+ </td>
+ </tr>
+ </tbody>
+ </table>
+ </td>
+ <td class="content1"><img class="nothing8"
+ src="../../docs/images/nada.gif"/></td>
+ </tr>
+ <tr>
+ <td colspan="3"><img class="line"
+ src="../../docs/images/sdk_line-1.gif"/></td>
+ </tr>
+ <tr>
+ <td class="content1"><img class="nothing8"
+ src="../../docs/images/nada.gif"/></td>
+ <td>
+ <table class="table2">
+ <tbody>
+ <tr>
+ <td>
+ <table class="table3">
+ <tbody>
+ <tr>
+ <td colspan="2" class="head1"><a name="OfficeBean">Office
+Bean example</a></td>
+ <td align="right"> <a href="#examples"
+ title="link to the Developer's Guide examples overview"><img
+ class="navigate" src="../../docs/images/nav_up.png"/></a> <a
+ href="../../index.html" title="link to the SDK start page"><img
+ class="navigate" src="../../docs/images/nav_home.png"/></a> </td>
+ </tr>
+ </tbody>
+ </table>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <table class="table4">
+ <tbody>
+ <tr class="thead">
+ <td class="cell20"> Example</td>
+ <td class="cell80">Description</td>
+ </tr>
+ <tr>
+ <td class="cell20"><img
+ src="../../docs/images/bluball.gif"/> <a
+ href="./OfficeBean/OOoBeanViewer.java"
+ title="link to OfficeBean/OOoBeanViewer.java">OOoBeanViewer</a></td>
+ <td class="cell80">Shows how to use the <code>OOoBean</code>
+embedded in a Java AWT component. It shows how to load and store
+documents as well as how to control toolbar visibility.</td>
+ </tr>
+ </tbody>
+ </table>
+ </td>
+ </tr>
+ </tbody>
+ </table>
+ </td>
+ <td class="content1"><img class="nothing8"
+ src="../../docs/images/nada.gif"/></td>
+ </tr>
+ <tr>
+ <td colspan="3"><img class="line"
+ src="../../docs/images/sdk_line-1.gif"/></td>
+ </tr>
+ <tr>
+ <td class="content1"><img class="nothing8"
+ src="../../docs/images/nada.gif"/></td>
+ <td>
+ <table class="table2">
+ <tbody>
+ <tr>
+ <td>
+ <table class="table3">
+ <tbody>
+ <tr>
+ <td colspan="2" class="head1"><a
+ name="ScriptingFramework">Scripting Framework Examples</a></td>
+ <td align="right"> <a href="#examples"
+ title="link to the Developer's Guide examples overview"><img
+ class="navigate" src="../../docs/images/nav_up.png"/></a> <a
+ href="../../index.html" title="link to the SDK start page"><img
+ class="navigate" src="../../docs/images/nav_home.png"/></a> </td>
+ </tr>
+ </tbody>
+ </table>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <table class="table4">
+ <tbody>
+ <tr class="thead">
+ <td class="cell20"> Example</td>
+ <td class="cell80">Description</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a
+ href="./ScriptingFramework/SayHello/SayHello/SayHello.java"
+ title="link to ScriptingFramework/SayHello/SayHello/SayHello.java">SayHello</a></td>
+ <td class="cell80">A Scripting Framework Java macro
+that opens a new Writer document and inserts the word Hello in it.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a
+ href="./ScriptingFramework/ScriptSelector/ScriptSelector/ScriptSelector.java"
+ title="link to ScriptingFramework/ScriptSelector/ScriptSelector/ScriptSelector.java">ScriptSelector</a></td>
+ <td class="cell80">A Scripting Framework Java macro
+that opens a Java Swing dialog with a tree view of the macro hierarchy
+for the Office application.</td>
+ </tr>
+ </tbody>
+ </table>
+ </td>
+ </tr>
+ </tbody>
+ </table>
+ </td>
+ </tr>
+ <tr>
+ <td colspan="3"><img class="line"
+ src="../../docs/images/sdk_line-1.gif"/></td>
+ </tr>
+ <tr>
+ <td class="content1"><img class="nothing8"
+ src="../../docs/images/nada.gif"/></td>
+ <td>
+ <table class="table2">
+ <tbody>
+ <tr>
+ <td>
+ <table class="table3">
+ <tbody>
+ <tr>
+ <td colspan="2" class="head1"><a
+ name="GraphicalUserInterfaces">Graphical User Interfaces</a></td>
+ <td align="right"> <a href="#examples"
+ title="link to the Developer's Guide examples overview"><img
+ class="navigate" src="../../docs/images/nav_up.png"/></a> <a
+ href="../../index.html" title="link to the SDK start page"><img
+ class="navigate" src="../../docs/images/nav_home.png"/></a> </td>
+ </tr>
+ </tbody>
+ </table>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <table class="table4">
+ <tbody>
+ <tr class="thead">
+ <td class="cell20"> Example</td>
+ <td class="cell80">Description</td>
+ </tr>
+ <tr>
+ <td class="cell20"><img src="../../docs/images/bluball.gif"/>
+<a href="./GUI/DialogDocument.java" title="link to GUI/DialogDocument.java">DialogDocument</a></td>
+ <td class="cell80">A sample showing how to display an office document in a dialog window.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><img src="../../docs/images/bluball.gif"/>
+<a href="./GUI/Messagebox.java" title="link to GUI/MessageBox.java">MessageBox</a></td>
+ <td class="cell80">A sample showing how to display a simple message box.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><img src="../../docs/images/bluball.gif"/>
+<a href="./GUI/UnoDialogSample.java" title="link to GUI/UnoDialogSample.java">UnoDialogSample</a></td>
+ <td class="cell80">A sample showing how to create various controls in a dialog (fixed text field, currency field, progress bar, fixed line, group box, edit field, time field, date field, pattern field, numeric field, progressbar, check box, radio button, list box, combo box, formatted field, file control, button control, roadmap control)</td>
+ </tr>
+ <tr>
+ <td class="cell20"><img src="../../docs/images/bluball.gif"/>
+<a href="./GUI/UnoDialogSample2.java" title="link to GUI/UnoDialogSample2.java">UnoDialogSample2</a></td>
+ <td class="cell80">A dialog sample showing how to use a roadmap control.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><img src="../../docs/images/bluball.gif"/>
+<a href="./GUI/UnoMenu.java" title="link to GUI/UnoMenu.java">UnoMenu</a></td>
+ <td class="cell80">A sample showing a top window with some menus.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><img src="../../docs/images/bluball.gif"/>
+<a href="./GUI/UnoMenu2.java" title="link to GUI/UnoMenu2.java">UnoMenu2</a></td>
+ <td class="cell80">A dialog sample showing how to use or work with a context menu.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><img src="../../docs/images/bluball.gif"/>
+<a href="./GUI/ImageControlSample.java" title="link to GUI/ImageControlSample.java">ImageControlSample2</a></td>
+ <td class="cell80">Dialog sample showing how to use an image control.</td>
+ </tr>
+ </tbody>
+ </table>
+ </td>
+ </tr>
+ </tbody>
+ </table>
+ </td>
+ </tr>
+ <tr>
+ <td colspan="3"><img class="nothing30"
+ src="../../docs/images/nada.gif"/></td>
+ </tr>
+</table>
+ </div>
+ <div id="Footer">
+ <div id="FooterText">
+ <p>
+ Copyright © 2000–2022 LibreOffice contributors. All rights reserved.
+ <br/>
+ LibreOffice was created by The Document Foundation,
+ based on OpenOffice.org.
+ <br/>
+ The Document Foundation acknowledges all community members, please find more info <a href="https://www.libreoffice.org/about-us/credits/" target="_blank">at our website</a>.
+ </p>
+ <p>
+ &nbsp;
+ </p>
+ <p>
+ <a href="http://www.documentfoundation.org/privacy" target="_blank">Privacy Policy</a> | <a href="http://www.documentfoundation.org/imprint" target="_blank">Impressum (Legal Info)</a>
+ | Copyright information: The source code of LibreOffice is licensed under the Mozilla Public License v2.0 (<a href="http://www.libreoffice.org/download/license/" target="_blank">MPLv2</a>). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our <a href="http://wiki.documentfoundation.org/TradeMark_Policy" target="_blank">trademark policy</a>.
+ </p>
+ </div>
+ </div>
+ </div>
+ </div>
+ </div>
+ </body>
+</html>