summaryrefslogtreecommitdiff
path: root/odk/examples/DevelopersGuide
diff options
context:
space:
mode:
Diffstat (limited to 'odk/examples/DevelopersGuide')
-rw-r--r--odk/examples/DevelopersGuide/Accessibility/ConnectionTask.java208
-rw-r--r--odk/examples/DevelopersGuide/Accessibility/EventHandler.java447
-rw-r--r--odk/examples/DevelopersGuide/Accessibility/EventListenerProxy.java232
-rw-r--r--odk/examples/DevelopersGuide/Accessibility/GraphicalDisplay.java189
-rw-r--r--odk/examples/DevelopersGuide/Accessibility/IAccessibleObjectDisplay.java46
-rw-r--r--odk/examples/DevelopersGuide/Accessibility/Makefile113
-rw-r--r--odk/examples/DevelopersGuide/Accessibility/MessageArea.java133
-rw-r--r--odk/examples/DevelopersGuide/Accessibility/NameProvider.java290
-rw-r--r--odk/examples/DevelopersGuide/Accessibility/RegistrationThread.java156
-rw-r--r--odk/examples/DevelopersGuide/Accessibility/SSR.java171
-rw-r--r--odk/examples/DevelopersGuide/Accessibility/TextualDisplay.java230
-rw-r--r--odk/examples/DevelopersGuide/Accessibility/makefile.mk73
-rw-r--r--odk/examples/DevelopersGuide/BasicAndDialogs/CreatingDialogs/CreatingDialogs.odtbin0 -> 8654 bytes
-rw-r--r--odk/examples/DevelopersGuide/BasicAndDialogs/CreatingDialogs/Makefile139
-rw-r--r--odk/examples/DevelopersGuide/BasicAndDialogs/CreatingDialogs/SampleDialog.java275
-rw-r--r--odk/examples/DevelopersGuide/BasicAndDialogs/FirstStepsBasic.odtbin0 -> 18560 bytes
-rw-r--r--odk/examples/DevelopersGuide/BasicAndDialogs/ToolkitControls/Makefile126
-rw-r--r--odk/examples/DevelopersGuide/BasicAndDialogs/ToolkitControls/ToolkitControls.odtbin0 -> 7793 bytes
-rw-r--r--odk/examples/DevelopersGuide/BasicAndDialogs/ToolkitControls/ToolkitControls/FileDialog.xba73
-rw-r--r--odk/examples/DevelopersGuide/BasicAndDialogs/ToolkitControls/ToolkitControls/FileDialogDlg.xdl12
-rw-r--r--odk/examples/DevelopersGuide/BasicAndDialogs/ToolkitControls/ToolkitControls/MultiPage.xba286
-rw-r--r--odk/examples/DevelopersGuide/BasicAndDialogs/ToolkitControls/ToolkitControls/MultiPageDlg.xdl75
-rw-r--r--odk/examples/DevelopersGuide/BasicAndDialogs/ToolkitControls/ToolkitControls/ProgressBar.xba76
-rw-r--r--odk/examples/DevelopersGuide/BasicAndDialogs/ToolkitControls/ToolkitControls/ProgressBarDlg.xdl11
-rw-r--r--odk/examples/DevelopersGuide/BasicAndDialogs/ToolkitControls/ToolkitControls/ScrollBar.xba86
-rw-r--r--odk/examples/DevelopersGuide/BasicAndDialogs/ToolkitControls/ToolkitControls/ScrollBarDlg.xdl13
-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/BasicAndDialogs/makefile.mk84
-rw-r--r--odk/examples/DevelopersGuide/Charts/AddInChart.odsbin0 -> 18045 bytes
-rw-r--r--odk/examples/DevelopersGuide/Charts/CalcHelper.java412
-rw-r--r--odk/examples/DevelopersGuide/Charts/ChartHelper.java261
-rw-r--r--odk/examples/DevelopersGuide/Charts/ChartInCalc.java424
-rw-r--r--odk/examples/DevelopersGuide/Charts/ChartInDraw.java308
-rw-r--r--odk/examples/DevelopersGuide/Charts/ChartInWriter.java178
-rw-r--r--odk/examples/DevelopersGuide/Charts/Helper.java170
-rw-r--r--odk/examples/DevelopersGuide/Charts/JavaSampleChartAddIn.java476
-rw-r--r--odk/examples/DevelopersGuide/Charts/ListenAtCalcRangeInDraw.java211
-rw-r--r--odk/examples/DevelopersGuide/Charts/Makefile198
-rw-r--r--odk/examples/DevelopersGuide/Charts/SelectionChangeListener.java219
-rw-r--r--odk/examples/DevelopersGuide/Charts/bullet.gifbin0 -> 335 bytes
-rw-r--r--odk/examples/DevelopersGuide/Charts/makefile.mk75
-rw-r--r--odk/examples/DevelopersGuide/Components/Addons/JobsAddon/Addons.xcu81
-rw-r--r--odk/examples/DevelopersGuide/Components/Addons/JobsAddon/AsyncJob.java426
-rw-r--r--odk/examples/DevelopersGuide/Components/Addons/JobsAddon/Jobs.xcu27
-rw-r--r--odk/examples/DevelopersGuide/Components/Addons/JobsAddon/Makefile136
-rw-r--r--odk/examples/DevelopersGuide/Components/Addons/ProtocolHandlerAddon_cpp/Addons.xcu220
-rw-r--r--odk/examples/DevelopersGuide/Components/Addons/ProtocolHandlerAddon_cpp/Makefile148
-rw-r--r--odk/examples/DevelopersGuide/Components/Addons/ProtocolHandlerAddon_cpp/ProtocolHandler.xcu11
-rw-r--r--odk/examples/DevelopersGuide/Components/Addons/ProtocolHandlerAddon_cpp/addon.cxx250
-rw-r--r--odk/examples/DevelopersGuide/Components/Addons/ProtocolHandlerAddon_cpp/addon.hxx125
-rw-r--r--odk/examples/DevelopersGuide/Components/Addons/ProtocolHandlerAddon_cpp/component.cxx131
-rw-r--r--odk/examples/DevelopersGuide/Components/Addons/ProtocolHandlerAddon_java/Addons.xcu220
-rw-r--r--odk/examples/DevelopersGuide/Components/Addons/ProtocolHandlerAddon_java/Makefile138
-rw-r--r--odk/examples/DevelopersGuide/Components/Addons/ProtocolHandlerAddon_java/ProtocolHandler.xcu10
-rw-r--r--odk/examples/DevelopersGuide/Components/Addons/ProtocolHandlerAddon_java/ProtocolHandlerAddon.java283
-rw-r--r--odk/examples/DevelopersGuide/Components/CppComponent/Makefile220
-rw-r--r--odk/examples/DevelopersGuide/Components/CppComponent/SimpleComponent.odtbin0 -> 8841 bytes
-rw-r--r--odk/examples/DevelopersGuide/Components/CppComponent/TestCppComponent.cxx89
-rw-r--r--odk/examples/DevelopersGuide/Components/CppComponent/service1_impl.cxx309
-rw-r--r--odk/examples/DevelopersGuide/Components/CppComponent/service2_impl.cxx225
-rw-r--r--odk/examples/DevelopersGuide/Components/CppComponent/some.idl54
-rw-r--r--odk/examples/DevelopersGuide/Components/JavaComponent/Makefile204
-rw-r--r--odk/examples/DevelopersGuide/Components/JavaComponent/SomethingA.idl46
-rw-r--r--odk/examples/DevelopersGuide/Components/JavaComponent/SomethingB.idl46
-rw-r--r--odk/examples/DevelopersGuide/Components/JavaComponent/TestComponentA.java71
-rw-r--r--odk/examples/DevelopersGuide/Components/JavaComponent/TestComponentB.java100
-rw-r--r--odk/examples/DevelopersGuide/Components/JavaComponent/TestJavaComponent.java143
-rw-r--r--odk/examples/DevelopersGuide/Components/JavaComponent/TestServiceProvider.java71
-rw-r--r--odk/examples/DevelopersGuide/Components/JavaComponent/XSomethingA.idl48
-rw-r--r--odk/examples/DevelopersGuide/Components/JavaComponent/XSomethingB.idl48
-rw-r--r--odk/examples/DevelopersGuide/Components/SimpleLicense/LicenseTest.idl50
-rw-r--r--odk/examples/DevelopersGuide/Components/SimpleLicense/LicenseTest.java171
-rw-r--r--odk/examples/DevelopersGuide/Components/SimpleLicense/Makefile170
-rw-r--r--odk/examples/DevelopersGuide/Components/SimpleLicense/description.xml12
-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/Makefile81
-rw-r--r--odk/examples/DevelopersGuide/Components/Thumbs/org/openoffice/comp/test/ImageShrink.java158
-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/test/ImageShrink.idl46
-rw-r--r--odk/examples/DevelopersGuide/Components/Thumbs/org/openoffice/test/Makefile73
-rw-r--r--odk/examples/DevelopersGuide/Components/Thumbs/org/openoffice/test/XImageShrink.idl53
-rw-r--r--odk/examples/DevelopersGuide/Components/Thumbs/org/openoffice/test/XImageShrinkFilter.idl50
-rw-r--r--odk/examples/DevelopersGuide/Components/Thumbs/thumbs.mk27
-rw-r--r--odk/examples/DevelopersGuide/Components/dialogcomponent/DialogComponent.java324
-rw-r--r--odk/examples/DevelopersGuide/Components/dialogcomponent/DialogComponent.odtbin0 -> 11902 bytes
-rw-r--r--odk/examples/DevelopersGuide/Components/dialogcomponent/Makefile177
-rw-r--r--odk/examples/DevelopersGuide/Components/dialogcomponent/TestDialogHandler.idl47
-rw-r--r--odk/examples/DevelopersGuide/Components/dialogcomponent/XTestDialogHandler.idl53
-rw-r--r--odk/examples/DevelopersGuide/Components/makefile.mk123
-rw-r--r--odk/examples/DevelopersGuide/Config/ConfigExamples.java1202
-rw-r--r--odk/examples/DevelopersGuide/Config/Makefile99
-rw-r--r--odk/examples/DevelopersGuide/Config/makefile.mk64
-rw-r--r--odk/examples/DevelopersGuide/Database/CodeSamples.java356
-rw-r--r--odk/examples/DevelopersGuide/Database/DriverSkeleton/How_to_write_my_own_driver.txt25
-rw-r--r--odk/examples/DevelopersGuide/Database/DriverSkeleton/Makefile150
-rw-r--r--odk/examples/DevelopersGuide/Database/DriverSkeleton/OSubComponent.hxx252
-rw-r--r--odk/examples/DevelopersGuide/Database/DriverSkeleton/OTypeInfo.hxx98
-rw-r--r--odk/examples/DevelopersGuide/Database/DriverSkeleton/SConnection.cxx402
-rw-r--r--odk/examples/DevelopersGuide/Database/DriverSkeleton/SConnection.hxx155
-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.cxx210
-rw-r--r--odk/examples/DevelopersGuide/Database/DriverSkeleton/SDriver.hxx85
-rw-r--r--odk/examples/DevelopersGuide/Database/DriverSkeleton/SPreparedStatement.cxx388
-rw-r--r--odk/examples/DevelopersGuide/Database/DriverSkeleton/SPreparedStatement.hxx146
-rw-r--r--odk/examples/DevelopersGuide/Database/DriverSkeleton/SResultSet.cxx873
-rw-r--r--odk/examples/DevelopersGuide/Database/DriverSkeleton/SResultSet.hxx218
-rw-r--r--odk/examples/DevelopersGuide/Database/DriverSkeleton/SResultSetMetaData.cxx169
-rw-r--r--odk/examples/DevelopersGuide/Database/DriverSkeleton/SResultSetMetaData.hxx90
-rw-r--r--odk/examples/DevelopersGuide/Database/DriverSkeleton/SServices.cxx180
-rw-r--r--odk/examples/DevelopersGuide/Database/DriverSkeleton/SStatement.cxx368
-rw-r--r--odk/examples/DevelopersGuide/Database/DriverSkeleton/SStatement.hxx175
-rw-r--r--odk/examples/DevelopersGuide/Database/DriverSkeleton/propertyids.cxx182
-rw-r--r--odk/examples/DevelopersGuide/Database/DriverSkeleton/propertyids.hxx161
-rw-r--r--odk/examples/DevelopersGuide/Database/Makefile134
-rw-r--r--odk/examples/DevelopersGuide/Database/OpenQuery.java162
-rw-r--r--odk/examples/DevelopersGuide/Database/RowSet.java241
-rw-r--r--odk/examples/DevelopersGuide/Database/RowSetEventListener.java77
-rw-r--r--odk/examples/DevelopersGuide/Database/Sales.java250
-rw-r--r--odk/examples/DevelopersGuide/Database/SalesMan.java145
-rw-r--r--odk/examples/DevelopersGuide/Database/makefile.mk95
-rw-r--r--odk/examples/DevelopersGuide/Database/sdbcx.java420
-rw-r--r--odk/examples/DevelopersGuide/Drawing/ChangeOrderDemo.java115
-rw-r--r--odk/examples/DevelopersGuide/Drawing/ControlAndSelectDemo.java143
-rw-r--r--odk/examples/DevelopersGuide/Drawing/CustomShowDemo.java173
-rw-r--r--odk/examples/DevelopersGuide/Drawing/DrawViewDemo.java141
-rw-r--r--odk/examples/DevelopersGuide/Drawing/DrawingDemo.java426
-rw-r--r--odk/examples/DevelopersGuide/Drawing/FillAndLineStyleDemo.java133
-rw-r--r--odk/examples/DevelopersGuide/Drawing/GluePointDemo.java188
-rw-r--r--odk/examples/DevelopersGuide/Drawing/GraphicExportDemo.java152
-rw-r--r--odk/examples/DevelopersGuide/Drawing/Helper.java83
-rw-r--r--odk/examples/DevelopersGuide/Drawing/LayerDemo.java156
-rw-r--r--odk/examples/DevelopersGuide/Drawing/Makefile175
-rw-r--r--odk/examples/DevelopersGuide/Drawing/ObjectTransformationDemo.java133
-rw-r--r--odk/examples/DevelopersGuide/Drawing/Organigram.java191
-rw-r--r--odk/examples/DevelopersGuide/Drawing/PageHelper.java223
-rw-r--r--odk/examples/DevelopersGuide/Drawing/PresentationDemo.java239
-rw-r--r--odk/examples/DevelopersGuide/Drawing/ShapeHelper.java145
-rw-r--r--odk/examples/DevelopersGuide/Drawing/SimplePresentation.odpbin0 -> 74753 bytes
-rw-r--r--odk/examples/DevelopersGuide/Drawing/StyleDemo.java174
-rw-r--r--odk/examples/DevelopersGuide/Drawing/TextDemo.java155
-rw-r--r--odk/examples/DevelopersGuide/Drawing/makefile.mk81
-rw-r--r--odk/examples/DevelopersGuide/Extensions/DialogWithHelp/Addons.xcu58
-rw-r--r--odk/examples/DevelopersGuide/Extensions/DialogWithHelp/DialogWithHelp/Dialog1.xdl10
-rw-r--r--odk/examples/DevelopersGuide/Extensions/DialogWithHelp/DialogWithHelp/Module1.xba16
-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.xml6
-rw-r--r--odk/examples/DevelopersGuide/Extensions/DialogWithHelp/Makefile118
-rw-r--r--odk/examples/DevelopersGuide/Extensions/DialogWithHelp/description.xml8
-rw-r--r--odk/examples/DevelopersGuide/Extensions/DialogWithHelp/help/de/com.foocorp.foo-ext/page1.xhp73
-rw-r--r--odk/examples/DevelopersGuide/Extensions/DialogWithHelp/help/de/com.foocorp.foo-ext/page2.xhp27
-rw-r--r--odk/examples/DevelopersGuide/Extensions/DialogWithHelp/help/de/com.foocorp.foo-ext/subfolder/anotherpage.xhp100
-rw-r--r--odk/examples/DevelopersGuide/Extensions/DialogWithHelp/help/en/com.foocorp.foo-ext/page1.xhp73
-rw-r--r--odk/examples/DevelopersGuide/Extensions/DialogWithHelp/help/en/com.foocorp.foo-ext/page2.xhp26
-rw-r--r--odk/examples/DevelopersGuide/Extensions/DialogWithHelp/help/en/com.foocorp.foo-ext/subfolder/anotherpage.xhp100
-rw-r--r--odk/examples/DevelopersGuide/FirstSteps/FirstConnection.java58
-rw-r--r--odk/examples/DevelopersGuide/FirstSteps/FirstLoadComponent.java329
-rw-r--r--odk/examples/DevelopersGuide/FirstSteps/FirstUnoContact.java58
-rw-r--r--odk/examples/DevelopersGuide/FirstSteps/HelloTextTableShape.java462
-rw-r--r--odk/examples/DevelopersGuide/FirstSteps/Makefile101
-rw-r--r--odk/examples/DevelopersGuide/FirstSteps/build_FirstUnoContact.xml64
-rw-r--r--odk/examples/DevelopersGuide/FirstSteps/makefile.mk67
-rw-r--r--odk/examples/DevelopersGuide/Forms/BooleanValidator.java85
-rw-r--r--odk/examples/DevelopersGuide/Forms/ButtonOperator.java223
-rw-r--r--odk/examples/DevelopersGuide/Forms/ComponentTreeTraversal.java91
-rw-r--r--odk/examples/DevelopersGuide/Forms/ControlLock.java219
-rw-r--r--odk/examples/DevelopersGuide/Forms/ControlValidation.java100
-rw-r--r--odk/examples/DevelopersGuide/Forms/ControlValidator.java60
-rw-r--r--odk/examples/DevelopersGuide/Forms/DataAwareness.java932
-rw-r--r--odk/examples/DevelopersGuide/Forms/DateValidator.java102
-rw-r--r--odk/examples/DevelopersGuide/Forms/DocumentBasedExample.java228
-rw-r--r--odk/examples/DevelopersGuide/Forms/DocumentHelper.java320
-rw-r--r--odk/examples/DevelopersGuide/Forms/DocumentType.java59
-rw-r--r--odk/examples/DevelopersGuide/Forms/DocumentViewHelper.java230
-rw-r--r--odk/examples/DevelopersGuide/Forms/FLTools.java270
-rw-r--r--odk/examples/DevelopersGuide/Forms/FormLayer.java294
-rw-r--r--odk/examples/DevelopersGuide/Forms/GridFieldValidator.java176
-rw-r--r--odk/examples/DevelopersGuide/Forms/HsqlDatabase.java256
-rw-r--r--odk/examples/DevelopersGuide/Forms/InteractionRequest.java76
-rw-r--r--odk/examples/DevelopersGuide/Forms/KeyGenerator.java432
-rw-r--r--odk/examples/DevelopersGuide/Forms/ListSelectionValidator.java69
-rw-r--r--odk/examples/DevelopersGuide/Forms/Makefile197
-rw-r--r--odk/examples/DevelopersGuide/Forms/NumericValidator.java89
-rw-r--r--odk/examples/DevelopersGuide/Forms/ProgrammaticScriptAssignment.odtbin0 -> 19198 bytes
-rw-r--r--odk/examples/DevelopersGuide/Forms/RowSet.java290
-rw-r--r--odk/examples/DevelopersGuide/Forms/SalesFilter.java512
-rw-r--r--odk/examples/DevelopersGuide/Forms/SingleControlValidation.java187
-rw-r--r--odk/examples/DevelopersGuide/Forms/SpreadsheetDocument.java131
-rw-r--r--odk/examples/DevelopersGuide/Forms/SpreadsheetValueBinding.java136
-rw-r--r--odk/examples/DevelopersGuide/Forms/SpreadsheetView.java76
-rw-r--r--odk/examples/DevelopersGuide/Forms/TableCellTextBinding.java210
-rw-r--r--odk/examples/DevelopersGuide/Forms/TextValidator.java89
-rw-r--r--odk/examples/DevelopersGuide/Forms/TimeValidator.java94
-rw-r--r--odk/examples/DevelopersGuide/Forms/UNO.java90
-rw-r--r--odk/examples/DevelopersGuide/Forms/URLHelper.java72
-rw-r--r--odk/examples/DevelopersGuide/Forms/ValueBinding.java88
-rw-r--r--odk/examples/DevelopersGuide/Forms/WaitForInput.java64
-rw-r--r--odk/examples/DevelopersGuide/Forms/makefile.mk97
-rw-r--r--odk/examples/DevelopersGuide/GUI/DialogDocument.java145
-rw-r--r--odk/examples/DevelopersGuide/GUI/ImageControlSample.java163
-rw-r--r--odk/examples/DevelopersGuide/GUI/Makefile142
-rw-r--r--odk/examples/DevelopersGuide/GUI/MessageBox.java245
-rw-r--r--odk/examples/DevelopersGuide/GUI/RoadmapItemStateChangeListener.java68
-rw-r--r--odk/examples/DevelopersGuide/GUI/SystemDialog.java186
-rw-r--r--odk/examples/DevelopersGuide/GUI/UnoDialogSample.java1482
-rw-r--r--odk/examples/DevelopersGuide/GUI/UnoDialogSample2.java264
-rw-r--r--odk/examples/DevelopersGuide/GUI/UnoMenu.java167
-rw-r--r--odk/examples/DevelopersGuide/GUI/UnoMenu2.java95
-rw-r--r--odk/examples/DevelopersGuide/GUI/oologo.gifbin0 -> 2563 bytes
-rw-r--r--odk/examples/DevelopersGuide/OfficeBean/Makefile89
-rw-r--r--odk/examples/DevelopersGuide/OfficeBean/OOoBeanViewer.java407
-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/OfficeBean/makefile.mk68
-rw-r--r--odk/examples/DevelopersGuide/OfficeDev/Clipboard/Clipboard.java229
-rw-r--r--odk/examples/DevelopersGuide/OfficeDev/Clipboard/ClipboardListener.java55
-rw-r--r--odk/examples/DevelopersGuide/OfficeDev/Clipboard/ClipboardOwner.java60
-rw-r--r--odk/examples/DevelopersGuide/OfficeDev/Clipboard/Makefile99
-rw-r--r--odk/examples/DevelopersGuide/OfficeDev/Clipboard/TextTransferable.java85
-rw-r--r--odk/examples/DevelopersGuide/OfficeDev/ContextMenuInterceptor.java256
-rw-r--r--odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/CustomizeView.java298
-rw-r--r--odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/Desk.java96
-rw-r--r--odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/DocumentView.java430
-rw-r--r--odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/FunctionHelper.java1060
-rw-r--r--odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/IOnewayLink.java70
-rw-r--r--odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/IShutdownListener.java47
-rw-r--r--odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/Install.txt10
-rw-r--r--odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/Interceptor.java672
-rw-r--r--odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/JavaWindowPeerFake.java107
-rw-r--r--odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/Makefile128
-rw-r--r--odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/NativeView.java182
-rw-r--r--odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/OfficeConnect.java205
-rw-r--r--odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/OnewayExecutor.java240
-rw-r--r--odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/StatusListener.java478
-rw-r--r--odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/StatusView.java266
-rw-r--r--odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/ViewContainer.java269
-rw-r--r--odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/nativelib/unix/Makefile73
-rw-r--r--odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/nativelib/unix/nativeview.c111
-rw-r--r--odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/nativelib/unix/nativeview.h63
-rw-r--r--odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/nativelib/windows/Makefile78
-rw-r--r--odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/nativelib/windows/nativeview.c178
-rw-r--r--odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/nativelib/windows/nativeview.def3
-rw-r--r--odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/nativelib/windows/nativeview.h63
-rw-r--r--odk/examples/DevelopersGuide/OfficeDev/DisableCommands/DisableCommandsTest.java411
-rw-r--r--odk/examples/DevelopersGuide/OfficeDev/DisableCommands/Makefile92
-rw-r--r--odk/examples/DevelopersGuide/OfficeDev/FilterDevelopment/AsciiFilter/AsciiReplaceFilter.java733
-rw-r--r--odk/examples/DevelopersGuide/OfficeDev/FilterDevelopment/AsciiFilter/FilterOptions.java230
-rw-r--r--odk/examples/DevelopersGuide/OfficeDev/FilterDevelopment/AsciiFilter/Makefile138
-rw-r--r--odk/examples/DevelopersGuide/OfficeDev/FilterDevelopment/AsciiFilter/TypeDetection.xcu29
-rw-r--r--odk/examples/DevelopersGuide/OfficeDev/FilterDevelopment/FlatXmlFilterDetection/FlatXmlTypeDetection.xcu71
-rw-r--r--odk/examples/DevelopersGuide/OfficeDev/FilterDevelopment/FlatXmlFilterDetection/Makefile150
-rw-r--r--odk/examples/DevelopersGuide/OfficeDev/FilterDevelopment/FlatXmlFilterDetection/fdcomp.cxx109
-rw-r--r--odk/examples/DevelopersGuide/OfficeDev/FilterDevelopment/FlatXmlFilterDetection/filterdetect.cxx254
-rw-r--r--odk/examples/DevelopersGuide/OfficeDev/FilterDevelopment/FlatXmlFilterDetection/filterdetect.hxx118
-rw-r--r--odk/examples/DevelopersGuide/OfficeDev/FilterDevelopment/FlatXmlFilter_cpp/FlatXml.cxx373
-rw-r--r--odk/examples/DevelopersGuide/OfficeDev/FilterDevelopment/FlatXmlFilter_cpp/FlatXmlFilter_cpp.uno.xml59
-rw-r--r--odk/examples/DevelopersGuide/OfficeDev/FilterDevelopment/FlatXmlFilter_cpp/FlatXmlFilter_cpp.xcu86
-rw-r--r--odk/examples/DevelopersGuide/OfficeDev/FilterDevelopment/FlatXmlFilter_cpp/Makefile148
-rw-r--r--odk/examples/DevelopersGuide/OfficeDev/FilterDevelopment/FlatXmlFilter_java/FlatXml.java273
-rw-r--r--odk/examples/DevelopersGuide/OfficeDev/FilterDevelopment/FlatXmlFilter_java/FlatXmlFilter_java.xcu86
-rw-r--r--odk/examples/DevelopersGuide/OfficeDev/FilterDevelopment/FlatXmlFilter_java/Makefile141
-rw-r--r--odk/examples/DevelopersGuide/OfficeDev/Linguistic/LinguisticExamples.java368
-rw-r--r--odk/examples/DevelopersGuide/OfficeDev/Linguistic/Makefile237
-rw-r--r--odk/examples/DevelopersGuide/OfficeDev/Linguistic/OneInstanceFactory.java155
-rw-r--r--odk/examples/DevelopersGuide/OfficeDev/Linguistic/PropChgHelper.java194
-rw-r--r--odk/examples/DevelopersGuide/OfficeDev/Linguistic/PropChgHelper_Hyph.java86
-rw-r--r--odk/examples/DevelopersGuide/OfficeDev/Linguistic/PropChgHelper_Spell.java110
-rw-r--r--odk/examples/DevelopersGuide/OfficeDev/Linguistic/SampleHyphenator.java548
-rw-r--r--odk/examples/DevelopersGuide/OfficeDev/Linguistic/SampleSpellChecker.java491
-rw-r--r--odk/examples/DevelopersGuide/OfficeDev/Linguistic/SampleThesaurus.java328
-rw-r--r--odk/examples/DevelopersGuide/OfficeDev/Linguistic/XHyphenatedWord_impl.java97
-rw-r--r--odk/examples/DevelopersGuide/OfficeDev/Linguistic/XMeaning_impl.java69
-rw-r--r--odk/examples/DevelopersGuide/OfficeDev/Linguistic/XPossibleHyphens_impl.java89
-rw-r--r--odk/examples/DevelopersGuide/OfficeDev/Linguistic/XSpellAlternatives_impl.java92
-rw-r--r--odk/examples/DevelopersGuide/OfficeDev/Makefile106
-rw-r--r--odk/examples/DevelopersGuide/OfficeDev/MenuElement.java56
-rw-r--r--odk/examples/DevelopersGuide/OfficeDev/Number_Formats.java253
-rw-r--r--odk/examples/DevelopersGuide/OfficeDev/OfficeConnect.java184
-rw-r--r--odk/examples/DevelopersGuide/OfficeDev/PathSettings/Makefile92
-rw-r--r--odk/examples/DevelopersGuide/OfficeDev/PathSettings/PathSettingsTest.java168
-rw-r--r--odk/examples/DevelopersGuide/OfficeDev/PathSubstitution/Makefile92
-rw-r--r--odk/examples/DevelopersGuide/OfficeDev/PathSubstitution/PathSubstitutionTest.java119
-rw-r--r--odk/examples/DevelopersGuide/OfficeDev/TerminationTest/Makefile97
-rw-r--r--odk/examples/DevelopersGuide/OfficeDev/TerminationTest/TerminateListener.java60
-rw-r--r--odk/examples/DevelopersGuide/OfficeDev/TerminationTest/TerminationTest.java101
-rw-r--r--odk/examples/DevelopersGuide/OfficeDev/makefile.mk180
-rw-r--r--odk/examples/DevelopersGuide/ProfUNO/CppBinding/Makefile140
-rw-r--r--odk/examples/DevelopersGuide/ProfUNO/CppBinding/office_connect.cxx104
-rw-r--r--odk/examples/DevelopersGuide/ProfUNO/CppBinding/office_connect.ini2
-rw-r--r--odk/examples/DevelopersGuide/ProfUNO/CppBinding/office_connectrc2
-rw-r--r--odk/examples/DevelopersGuide/ProfUNO/CppBinding/string_samples.cxx84
-rw-r--r--odk/examples/DevelopersGuide/ProfUNO/InterprocessConn/ConnectionAwareClient.java260
-rw-r--r--odk/examples/DevelopersGuide/ProfUNO/InterprocessConn/Makefile86
-rw-r--r--odk/examples/DevelopersGuide/ProfUNO/InterprocessConn/UrlResolver.java111
-rw-r--r--odk/examples/DevelopersGuide/ProfUNO/Lifetime/Makefile113
-rw-r--r--odk/examples/DevelopersGuide/ProfUNO/Lifetime/MyUnoObject.java60
-rw-r--r--odk/examples/DevelopersGuide/ProfUNO/Lifetime/object_lifetime.cxx68
-rw-r--r--odk/examples/DevelopersGuide/ProfUNO/SimpleBootstrap_cpp/Makefile101
-rw-r--r--odk/examples/DevelopersGuide/ProfUNO/SimpleBootstrap_cpp/SimpleBootstrap_cpp.cxx102
-rw-r--r--odk/examples/DevelopersGuide/ProfUNO/SimpleBootstrap_java/Makefile91
-rw-r--r--odk/examples/DevelopersGuide/ProfUNO/SimpleBootstrap_java/SimpleBootstrap_java.java76
-rw-r--r--odk/examples/DevelopersGuide/ProfUNO/SimpleBootstrap_java/manifest.mf4
-rw-r--r--odk/examples/DevelopersGuide/ProfUNO/makefile.mk95
-rw-r--r--odk/examples/DevelopersGuide/ScriptingFramework/SayHello/META-INF/manifest.xml5
-rw-r--r--odk/examples/DevelopersGuide/ScriptingFramework/SayHello/Makefile129
-rw-r--r--odk/examples/DevelopersGuide/ScriptingFramework/SayHello/SayHello.odtbin0 -> 8874 bytes
-rw-r--r--odk/examples/DevelopersGuide/ScriptingFramework/SayHello/SayHello/SayHello.java46
-rw-r--r--odk/examples/DevelopersGuide/ScriptingFramework/SayHello/SayHello/parcel-descriptor.xml17
-rwxr-xr-xodk/examples/DevelopersGuide/ScriptingFramework/SayHello/build.xml81
-rw-r--r--odk/examples/DevelopersGuide/ScriptingFramework/ScriptSelector/META-INF/manifest.xml5
-rw-r--r--odk/examples/DevelopersGuide/ScriptingFramework/ScriptSelector/Makefile131
-rw-r--r--odk/examples/DevelopersGuide/ScriptingFramework/ScriptSelector/ScriptSelector.odtbin0 -> 8921 bytes
-rw-r--r--odk/examples/DevelopersGuide/ScriptingFramework/ScriptSelector/ScriptSelector/ScriptSelector.java397
-rw-r--r--odk/examples/DevelopersGuide/ScriptingFramework/ScriptSelector/ScriptSelector/container.gifbin0 -> 164 bytes
-rw-r--r--odk/examples/DevelopersGuide/ScriptingFramework/ScriptSelector/ScriptSelector/parcel-descriptor.xml17
-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
-rwxr-xr-xodk/examples/DevelopersGuide/ScriptingFramework/ScriptSelector/build.xml81
-rw-r--r--odk/examples/DevelopersGuide/ScriptingFramework/makefile.mk79
-rw-r--r--odk/examples/DevelopersGuide/Spreadsheet/DataPilotReadme.txt30
-rw-r--r--odk/examples/DevelopersGuide/Spreadsheet/ExampleAddIn.java314
-rw-r--r--odk/examples/DevelopersGuide/Spreadsheet/ExampleAddIn.odsbin0 -> 8961 bytes
-rw-r--r--odk/examples/DevelopersGuide/Spreadsheet/ExampleDataPilotSource.java981
-rw-r--r--odk/examples/DevelopersGuide/Spreadsheet/GeneralTableSample.java241
-rw-r--r--odk/examples/DevelopersGuide/Spreadsheet/Makefile306
-rw-r--r--odk/examples/DevelopersGuide/Spreadsheet/SpreadsheetDocHelper.java405
-rw-r--r--odk/examples/DevelopersGuide/Spreadsheet/SpreadsheetSample.java1417
-rw-r--r--odk/examples/DevelopersGuide/Spreadsheet/ViewSample.java170
-rw-r--r--odk/examples/DevelopersGuide/Spreadsheet/XExampleAddIn.idl60
-rw-r--r--odk/examples/DevelopersGuide/Spreadsheet/makefile.mk72
-rw-r--r--odk/examples/DevelopersGuide/Text/Makefile96
-rw-r--r--odk/examples/DevelopersGuide/Text/PrintDemo.odtbin0 -> 6909 bytes
-rw-r--r--odk/examples/DevelopersGuide/Text/TextDocuments.java1792
-rw-r--r--odk/examples/DevelopersGuide/Text/TextTemplateWithUserFields.odtbin0 -> 6641 bytes
-rw-r--r--odk/examples/DevelopersGuide/Text/makefile.mk67
-rw-r--r--odk/examples/DevelopersGuide/UCB/ChildrenRetriever.java348
-rw-r--r--odk/examples/DevelopersGuide/UCB/DataStreamComposer.java258
-rw-r--r--odk/examples/DevelopersGuide/UCB/DataStreamRetriever.java233
-rw-r--r--odk/examples/DevelopersGuide/UCB/Helper.java250
-rw-r--r--odk/examples/DevelopersGuide/UCB/Makefile156
-rw-r--r--odk/examples/DevelopersGuide/UCB/MyActiveDataSink.java73
-rw-r--r--odk/examples/DevelopersGuide/UCB/MyInputStream.java190
-rw-r--r--odk/examples/DevelopersGuide/UCB/PropertiesComposer.java299
-rw-r--r--odk/examples/DevelopersGuide/UCB/PropertiesRetriever.java254
-rw-r--r--odk/examples/DevelopersGuide/UCB/ResourceCreator.java313
-rw-r--r--odk/examples/DevelopersGuide/UCB/ResourceManager.java289
-rw-r--r--odk/examples/DevelopersGuide/UCB/ResourceRemover.java180
-rw-r--r--odk/examples/DevelopersGuide/UCB/data/data.txt1
-rw-r--r--odk/examples/DevelopersGuide/UCB/makefile.mk75
-rw-r--r--odk/examples/DevelopersGuide/examples.html3032
356 files changed, 64201 insertions, 0 deletions
diff --git a/odk/examples/DevelopersGuide/Accessibility/ConnectionTask.java b/odk/examples/DevelopersGuide/Accessibility/ConnectionTask.java
new file mode 100644
index 000000000000..7bf9bdb88cd5
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Accessibility/ConnectionTask.java
@@ -0,0 +1,208 @@
+/*************************************************************************
+ *
+ * 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.event.ActionListener;
+import javax.swing.*;
+import java.awt.*;
+import java.util.*;
+
+import com.sun.star.awt.XFocusListener;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.bridge.XUnoUrlResolver;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.accessibility.*;
+import com.sun.star.awt.XExtendedToolkit;
+
+
+/** This timer task tries to connect to a running Office application in regular
+ intervals until a connection can be successfully established.
+*/
+class ConnectionTask
+ extends TimerTask
+{
+ public ConnectionTask (EventListenerProxy xListener)
+ {
+ Init (xListener);
+ }
+
+ private void Init (EventListenerProxy xListener)
+ {
+ mxListener = xListener;
+ mbInitialized = false;
+
+ maTimer = new java.util.Timer ();
+ maTimer.schedule (this, 0, mnPeriod);
+ }
+
+
+ /** This method is run every time the task is executed. It tries to
+ connect to and register the listener at an Office application. If it
+ can establish a connection it terminates the timer task. Otherwise it
+ waits until the next activation.
+ */
+ public void run ()
+ {
+ if (registerListeners())
+ {
+ // Focus listener was successfully registered so we can cancel this task.
+ MessageArea.println ("\nconnected successfully to office");
+ cancel ();
+ maTimer = null;
+ }
+ }
+
+
+
+
+ /** Try to register the listener.
+ */
+ private boolean registerListeners ()
+ {
+ // Get toolkit.
+ XExtendedToolkit xToolkit = getToolkit ();
+
+ // Register at toolkit as focus event listener.
+ if (xToolkit != null)
+ {
+ xToolkit.addTopWindowListener (mxListener);
+ int nTopWindowCount = xToolkit.getTopWindowCount();
+ try
+ {
+ com.sun.star.lang.EventObject aEvent = new com.sun.star.lang.EventObject();
+ for (int i=0; i<nTopWindowCount; i++)
+ {
+ XAccessible xAccessible = (XAccessible) UnoRuntime.queryInterface(
+ XAccessible.class,
+ xToolkit.getTopWindow(i));
+ XAccessibleContext xContext = xAccessible.getAccessibleContext();
+ if (xContext.getAccessibleName().length() > 0)
+ {
+ // Simulate an event that leads to registration the
+ // listener at the window.
+ aEvent.Source = xToolkit.getTopWindow(i);
+ mxListener.windowOpened (aEvent);
+ }
+ }
+ }
+
+ catch (com.sun.star.lang.IndexOutOfBoundsException aException)
+ {
+ // This exception signals that the number of top windows has
+ // changed since our last call to getTopWindowCount().
+ }
+ return true;
+ }
+ else
+ return false;
+ }
+
+
+
+
+ /** Get the toolkit from an Office which can then be used to register
+ the listener.
+ */
+ private XExtendedToolkit getToolkit ()
+ {
+ XMultiServiceFactory xFactory = connectToOffice();
+
+ // Get toolkit.
+ XExtendedToolkit xToolkit = null;
+ try
+ {
+ if (xFactory != null)
+ {
+ xToolkit = (XExtendedToolkit) UnoRuntime.queryInterface(
+ XExtendedToolkit.class,
+ xFactory.createInstance ("stardiv.Toolkit.VCLXToolkit"));
+ }
+ }
+ catch (com.sun.star.uno.Exception aException)
+ {
+ MessageArea.println ("caught exception while creating extended toolkit");
+ // Ignored.
+ }
+
+ return xToolkit;
+ }
+
+
+
+
+ /** Connect to a running (Star|Open)Office application
+ */
+ private XMultiServiceFactory connectToOffice ()
+ {
+ // connect to a running office and get the ServiceManager
+ try
+ {
+ com.sun.star.uno.XComponentContext xCmpContext = null;
+
+ // get the remote office component context
+ xCmpContext = com.sun.star.comp.helper.Bootstrap.bootstrap();
+ if( xCmpContext != null )
+ System.out.println("Connected to a running office ...");
+
+ // get the remote office service manager
+ com.sun.star.lang.XMultiComponentFactory xMCF =
+ xCmpContext.getServiceManager();
+
+ return (XMultiServiceFactory) UnoRuntime.queryInterface (
+ XMultiServiceFactory.class, xMCF);
+ }
+
+ catch (Exception e)
+ {
+ if ( ! mbInitialized)
+ MessageArea.println ("Could not connect to office");
+ else
+ MessageArea.print (".");
+ }
+ mbInitialized = true;
+ return null;
+ }
+
+ /** Time in milliseconds between two attempts to connect to an Office
+ application.
+ */
+ private int mnPeriod = 1000;
+
+ private EventListenerProxy mxListener;
+ private boolean mbInitialized;
+
+ /** This timer is used for the registration loop to retry to connect to
+ the Office until a connection can be established.
+ */
+ private java.util.Timer maTimer;
+}
diff --git a/odk/examples/DevelopersGuide/Accessibility/EventHandler.java b/odk/examples/DevelopersGuide/Accessibility/EventHandler.java
new file mode 100644
index 000000000000..61395bba7d70
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Accessibility/EventHandler.java
@@ -0,0 +1,447 @@
+/*************************************************************************
+ *
+ * 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.Vector;
+
+import com.sun.star.uno.AnyConverter;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.Type;
+import com.sun.star.accessibility.*;
+
+/** Handle all the events send from accessibility objects. The events
+ denoting new or removed top windows are handled as well.
+
+ It does not implement any listener interface as does the
+ EventListenerProxy class because it is interested only in a sub set of
+ the event types.
+*/
+public class EventHandler
+{
+ public EventHandler ()
+ {
+ mnTopWindowCount = 0;
+ maListenerProxy = new EventListenerProxy (this);
+ maConnectionTask = new ConnectionTask (maListenerProxy);
+ maObjectDisplays = new Vector ();
+ }
+
+ public synchronized void addObjectDisplay (IAccessibleObjectDisplay aDisplay)
+ {
+ maObjectDisplays.add (aDisplay);
+ }
+
+
+ public void finalize ()
+ {
+ // When it is running then cancel the timer that tries to connect to
+ // the Office.
+ if (maConnectionTask != null)
+ maConnectionTask.cancel();
+ }
+
+
+
+ public void disposing (com.sun.star.lang.EventObject aEvent)
+ {
+ // Ignored: We are not holding references to accessibility objects.
+ }
+
+
+
+
+ /** This method is called back when a new top level window has been opened.
+ */
+ public void windowOpened (XAccessible xAccessible)
+ {
+ if (xAccessible != null)
+ {
+ // Update the counter of currently open top level windows
+ // observed by this object.
+ mnTopWindowCount += 1;
+
+ XAccessibleContext xContext = xAccessible.getAccessibleContext();
+ if (xContext != null)
+ {
+ MessageArea.println ("new top level window has accessible name "
+ + xContext.getAccessibleName());
+
+ // Register at all accessible objects of the new window.
+ new RegistrationThread (
+ maListenerProxy,
+ xContext,
+ true,
+ true);
+ }
+ else
+ MessageArea.println ("new top level window is not accessible.");
+ }
+ else
+ MessageArea.println ("new top level window is not accessible.");
+ }
+
+
+
+
+ public void windowClosed (XAccessible xAccessible)
+ {
+ mnTopWindowCount -= 1;
+ MessageArea.println ("window closed, " + mnTopWindowCount + " still open");
+ if (mnTopWindowCount == 0)
+ {
+ // This was the last window. Wait for a new connection.
+ MessageArea.println ("lost connection to office");
+ new ConnectionTask (maListenerProxy);
+ }
+ if (xAccessible != null)
+ new RegistrationThread (
+ maListenerProxy,
+ xAccessible.getAccessibleContext(),
+ false,
+ true);
+ }
+
+
+
+
+ /** Print a message that the given object just received the focus. Call
+ all accessible object diplays and tell them to update.
+ */
+ private synchronized void focusGained (XAccessibleContext xContext)
+ {
+ if (xContext != null)
+ {
+ MessageArea.println ("focusGained: " + xContext.getAccessibleName()
+ + " with role "
+ + NameProvider.getRoleName (xContext.getAccessibleRole()));
+
+ // Tell the object displays to update their views.
+ for (int i=0; i<maObjectDisplays.size(); i++)
+ {
+ IAccessibleObjectDisplay aDisplay =
+ (IAccessibleObjectDisplay)maObjectDisplays.get(i);
+ if (aDisplay != null)
+ aDisplay.setAccessibleObject (xContext);
+ }
+
+ // Remember the currently focused object.
+ mxFocusedObject = xContext;
+ }
+ else
+ MessageArea.println ("focusGained: null");
+ }
+
+
+
+
+ /** Print a message that the given object just lost the focus. Call
+ all accessible object diplays and tell them to update.
+ */
+ private synchronized void focusLost (XAccessibleContext xContext)
+ {
+ if (xContext != null)
+ {
+ MessageArea.println ("focusLost: "
+ + xContext.getAccessibleName()
+ + " with role "
+ + NameProvider.getRoleName (xContext.getAccessibleRole()));
+
+ // Tell the object displays to update their views.
+ for (int i=0; i<maObjectDisplays.size(); i++)
+ {
+ IAccessibleObjectDisplay aDisplay =
+ (IAccessibleObjectDisplay)maObjectDisplays.get(i);
+ if (aDisplay != null)
+ aDisplay.setAccessibleObject (null);
+ }
+ mxFocusedObject = null;
+ }
+ else
+ MessageArea.println ("focusLost: null");
+ }
+
+
+
+
+ /** Handle a change of the caret position. Ignore this on all objects
+ but the one currently focused.
+ */
+ private void handleCaretEvent (XAccessibleContext xContext,
+ long nOldPosition, long nNewPosition)
+ {
+ if (xContext == mxFocusedObject)
+ MessageArea.println ("caret moved from " + nOldPosition + " to " + nNewPosition);
+ }
+
+
+
+
+ /** Print a message that a state has been changed.
+ @param xContext
+ The accessible context of the object whose state has changed.
+ @param nOldState
+ When not zero then this value describes a state that has been reset.
+ @param nNewValue
+ When not zero then this value describes a state that has been set.
+ */
+ private void handleStateChange (XAccessibleContext xContext, short nOldState, short nNewState)
+ {
+ // Determine which state has changed and what is its new value.
+ short nState;
+ boolean aNewValue;
+ if (nOldState >= 0)
+ {
+ nState = nOldState;
+ aNewValue = false;
+ }
+ else
+ {
+ nState = nNewState;
+ aNewValue = true;
+ }
+
+ // Print a message about the changed state.
+ MessageArea.print ("setting state " + NameProvider.getStateName(nState)
+ + " to " + aNewValue);
+ if (xContext != null)
+ {
+ MessageArea.println (" at " + xContext.getAccessibleName() + " with role "
+ + NameProvider.getRoleName(xContext.getAccessibleRole()));
+ }
+ else
+ MessageArea.println (" at null");
+
+ // Further handling of some states
+ switch (nState)
+ {
+ case AccessibleStateType.FOCUSED:
+ if (aNewValue)
+ focusGained (xContext);
+ else
+ focusLost (xContext);
+ }
+ }
+
+
+
+
+ /** Handle a child event that describes the creation of removal of a
+ single child.
+ */
+ private void handleChildEvent (
+ XAccessibleContext aOldChild,
+ XAccessibleContext aNewChild)
+ {
+ if (aOldChild != null)
+ // Remove event listener from the child and all of its descendants.
+ new RegistrationThread (maListenerProxy, aOldChild, false, false);
+ else if (aNewChild != null)
+ // Add event listener to the new child and all of its descendants.
+ new RegistrationThread (maListenerProxy, aNewChild, true, false);
+ }
+
+
+
+
+ /** Handle the change of some visible data of an object.
+ */
+ private void handleVisibleDataEvent (XAccessibleContext xContext)
+ {
+ // The given object may affect the visible appearance of the focused
+ // object even when the two are not identical when the given object
+ // is an ancestor of the focused object.
+ // In order to not check this we simply call an update on the
+ // focused object.
+ if (mxFocusedObject != null)
+ for (int i=0; i<maObjectDisplays.size(); i++)
+ {
+ IAccessibleObjectDisplay aDisplay =
+ (IAccessibleObjectDisplay)maObjectDisplays.get(i);
+ if (aDisplay != null)
+ aDisplay.updateAccessibleObject (mxFocusedObject);
+ }
+ }
+
+
+
+
+ /** Print some information about an event that is not handled by any
+ more specialized handler.
+ */
+ private void handleGenericEvent (
+ int nEventId,
+ Object aSource,
+ Object aOldValue,
+ Object aNewValue)
+ {
+ // Print event to message area.
+ MessageArea.print ("received event "
+ + NameProvider.getEventName (nEventId) + " from ");
+ XAccessibleContext xContext = objectToContext (aSource);
+ if (xContext != null)
+ MessageArea.print (xContext.getAccessibleName());
+ else
+ MessageArea.print ("null");
+ MessageArea.println (" / "
+ + NameProvider.getRoleName(xContext.getAccessibleRole()));
+ }
+
+
+
+ /** This is the main method for handling accessibility events. It is
+ assumed that it is not called directly from the Office but from a
+ listener proxy that runs in a separate thread so that calls back to
+ the Office do not result in dead-locks.
+ */
+ public void notifyEvent (com.sun.star.accessibility.AccessibleEventObject aEvent)
+ {
+ try // Guard against disposed objects.
+ {
+ switch (aEvent.EventId)
+ {
+ case AccessibleEventId.CHILD:
+ handleChildEvent (
+ objectToContext (aEvent.OldValue),
+ objectToContext (aEvent.NewValue));
+ break;
+
+ case AccessibleEventId.STATE_CHANGED:
+ {
+ short nOldState = -1;
+ short nNewState = -1;
+ try
+ {
+ if (AnyConverter.isShort (aEvent.NewValue))
+ nNewState = AnyConverter.toShort (aEvent.NewValue);
+ if (AnyConverter.isShort (aEvent.OldValue))
+ nOldState = AnyConverter.toShort (aEvent.OldValue);
+ }
+ catch (com.sun.star.lang.IllegalArgumentException e)
+ {}
+ handleStateChange (
+ objectToContext (aEvent.Source),
+ nOldState,
+ nNewState);
+ }
+ break;
+
+ case AccessibleEventId.VISIBLE_DATA_CHANGED:
+ case AccessibleEventId.BOUNDRECT_CHANGED:
+ handleVisibleDataEvent (objectToContext (aEvent.Source));
+ break;
+
+ case AccessibleEventId.CARET_CHANGED:
+ try
+ {
+ handleCaretEvent (
+ objectToContext (aEvent.Source),
+ AnyConverter.toLong(aEvent.OldValue),
+ AnyConverter.toLong(aEvent.NewValue));
+ }
+ catch (com.sun.star.lang.IllegalArgumentException e)
+ {}
+ break;
+
+ default:
+ handleGenericEvent (aEvent.EventId,
+ aEvent.Source, aEvent.OldValue, aEvent.NewValue);
+ break;
+ }
+ }
+ catch (com.sun.star.lang.DisposedException e)
+ {}
+ }
+
+
+
+
+ /** Convert the given object into an accessible context. The object is
+ interpreted as UNO Any and may contain either an XAccessible or
+ XAccessibleContext reference.
+ @return
+ The returned value is null when the given object can not be
+ converted to an XAccessibleContext reference.
+ */
+ private XAccessibleContext objectToContext (Object aObject)
+ {
+ XAccessibleContext xContext = null;
+ XAccessible xAccessible = null;
+ try
+ {
+ xAccessible = (XAccessible)AnyConverter.toObject(
+ new Type(XAccessible.class), aObject);
+ }
+ catch (com.sun.star.lang.IllegalArgumentException e)
+ {}
+ if (xAccessible != null)
+ xContext = xAccessible.getAccessibleContext();
+ else
+ try
+ {
+ xContext = (XAccessibleContext)AnyConverter.toObject(
+ new Type(XAccessibleContext.class), aObject);
+ }
+ catch (com.sun.star.lang.IllegalArgumentException e)
+ {}
+ return xContext;
+ }
+
+
+
+
+ /** The proxy that runs in a seperate thread and allows to call back to
+ the Office without running into dead-locks.
+ */
+ private EventListenerProxy maListenerProxy;
+
+ /** The currently focused object. A value of null means that no object
+ has the focus.
+ */
+ private XAccessibleContext mxFocusedObject;
+
+ /** Keep track of the currently open top windows to start a registration
+ loop when the last window (and the Office) is closed.
+ */
+ private long mnTopWindowCount;
+
+ /** A list of objects that can display accessible objects in specific
+ ways such as showing a graphical representation or some textual
+ descriptions.
+ */
+ private Vector maObjectDisplays;
+
+ /** The timer task that attempts in regular intervals to connect to a
+ running Office application.
+ */
+ private ConnectionTask maConnectionTask;
+}
diff --git a/odk/examples/DevelopersGuide/Accessibility/EventListenerProxy.java b/odk/examples/DevelopersGuide/Accessibility/EventListenerProxy.java
new file mode 100644
index 000000000000..273f6146a6cc
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Accessibility/EventListenerProxy.java
@@ -0,0 +1,232 @@
+/*************************************************************************
+ *
+ * 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.accessibility.XAccessible;
+import com.sun.star.accessibility.XAccessibleEventListener;
+import com.sun.star.accessibility.AccessibleEventObject;
+import com.sun.star.lang.EventObject;
+import com.sun.star.awt.XTopWindowListener;
+import com.sun.star.uno.UnoRuntime;
+
+import java.util.LinkedList;
+
+/** This class acts as a proxy for the simple screen reader. It waits for
+ two types of events:
+ 1. Accessibility events signal modifications concerning accessibility
+ objects.
+ 2. Top window events inform the listener about new or removed windows.
+
+ This class exists because events had to be handled in a seperate thread
+ to avoid dead locks: The thread that receives an event must no call back
+ to the Office directly.
+
+ Soon this should not be necessary anymore. There is now a flag which
+ switches between synchronous and asynchronous callbacks.
+
+ All reveived events are eventually forwarded to the actual listener. In
+ this way it decouples the Office from the listener.
+*/
+class EventListenerProxy
+ implements Runnable, XAccessibleEventListener, XTopWindowListener
+{
+ public EventListenerProxy (EventHandler aListener)
+ {
+ maListener = aListener;
+ mbAsynchron = true;
+ if (mbAsynchron)
+ {
+ maEventQueue = new LinkedList();
+ new Thread (this, "EventListenerProxy").start();
+ }
+ }
+
+ private void addEvent (Runnable aEventObject)
+ {
+ if (mbAsynchron)
+ synchronized (maEventQueue)
+ {
+ maEventQueue.addLast (aEventObject);
+ // Tell the queue that there is a new event in the queue.
+ maEventQueue.notify();
+ }
+ else
+ {
+ System.out.println ("running " + aEventObject);
+ aEventObject.run();
+ System.out.println (" done");
+ }
+ }
+
+
+
+
+ /** In an infinite loop, check for events to deliver, then wait on lock
+ (which will be notified when new events arrive)
+ */
+ public void run ()
+ {
+ while (true)
+ {
+ // Process all events that are currently in the queue.
+ Runnable aEvent;
+ do
+ {
+ synchronized (maEventQueue)
+ {
+ if (maEventQueue.size() > 0)
+ aEvent = (Runnable)maEventQueue.removeFirst();
+ else
+ aEvent = null;
+ }
+
+ if (aEvent != null)
+ {
+ try
+ {
+ aEvent.run();
+ }
+ catch (Throwable aException)
+ {
+ MessageArea.println(
+ "Exception during event delivery: " + aException);
+ aException.printStackTrace();
+ }
+ }
+ }
+ while (aEvent != null);
+
+ // Now that the queue is empty go to sleep again.
+ try
+ {
+ synchronized (maEventQueue)
+ {
+ maEventQueue.wait();
+ }
+ }
+ catch (Exception aException)
+ {
+ // Ignore this exception since there is not much
+ // that we can do about it.
+ }
+ }
+ }
+
+
+ public void disposing( final EventObject aEvent)
+ {
+ addEvent (new Runnable()
+ {
+ public void run()
+ {
+ maListener.disposing (aEvent);
+ }
+ } );
+ }
+
+ public void notifyEvent (final AccessibleEventObject aEvent)
+ {
+ addEvent (
+ new Runnable()
+ {
+ public void run()
+ {
+ maListener.notifyEvent (aEvent);
+ }
+ } );
+ }
+
+ public void windowOpened (final com.sun.star.lang.EventObject aEvent)
+ {
+ addEvent (
+ new Runnable()
+ {
+ public void run()
+ {
+ maListener.windowOpened (
+ (XAccessible) UnoRuntime.queryInterface(
+ XAccessible.class,
+ aEvent.Source));
+ }
+ } );
+ }
+ public void windowClosing (final com.sun.star.lang.EventObject aEvent)
+ {
+ // Ignored.
+ }
+ public void windowClosed (final com.sun.star.lang.EventObject aEvent)
+ {
+ addEvent (
+ new Runnable()
+ {
+ public void run()
+ {
+ maListener.windowClosed (
+ (XAccessible) UnoRuntime.queryInterface(
+ XAccessible.class,
+ aEvent.Source));
+ }
+ } );
+ }
+ public void windowMinimized (com.sun.star.lang.EventObject aEvent)
+ {
+ // Ignored.
+ }
+ public void windowNormalized (com.sun.star.lang.EventObject aEvent)
+ {
+ // Ignored.
+ }
+ public void windowActivated (com.sun.star.lang.EventObject aEvent)
+ {
+ // Ignored.
+ }
+ public void windowDeactivated (com.sun.star.lang.EventObject aEvent)
+ {
+ // Ignored.
+ }
+
+ /** The queue of event objects, LinkedList<Runnable>.
+ The queue object will also serve as lock for the consumer/producer type
+ syncronization.
+ */
+ private LinkedList maEventQueue;
+
+ /** This is the actual listener that the events will eventually forwarded to.
+ */
+ private EventHandler maListener;
+
+ /** This flag determines whether event forwarding is done asynchroniously
+ or synchroniously.
+ */
+ private boolean mbAsynchron;
+}
diff --git a/odk/examples/DevelopersGuide/Accessibility/GraphicalDisplay.java b/odk/examples/DevelopersGuide/Accessibility/GraphicalDisplay.java
new file mode 100644
index 000000000000..37579e1c3242
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Accessibility/GraphicalDisplay.java
@@ -0,0 +1,189 @@
+/*************************************************************************
+ *
+ * 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 javax.swing.*;
+import java.awt.Dimension;
+import java.awt.*;
+import java.awt.geom.*;
+
+import com.sun.star.accessibility.XAccessible;
+import com.sun.star.accessibility.XAccessibleContext;
+import com.sun.star.accessibility.XAccessibleComponent;
+
+import com.sun.star.awt.Point;
+import com.sun.star.awt.Size;
+import com.sun.star.uno.UnoRuntime;
+
+
+/** Display the currently focused accessible object graphically.
+*/
+public class GraphicalDisplay
+ extends JPanel
+ implements IAccessibleObjectDisplay
+{
+ /** Create a new graphical widget the displays some of the geometrical
+ information availbable from accessible objects.
+ */
+ public GraphicalDisplay ()
+ {
+ setPreferredSize (new Dimension (300,200));
+ }
+
+
+ /** Paint some or all of the area of this widget with the outlines of
+ the currently focues object and its ancestors.
+ */
+ public synchronized void paintComponent (Graphics g)
+ {
+ super.paintComponent (g);
+
+ setupTransformation ();
+
+ // Draw the screen representation to give a hint of the location of the
+ // accessible object on the screen.
+ Dimension aScreenSize = Toolkit.getDefaultToolkit().getScreenSize();
+ // Fill the screen rectangle.
+ g.setColor (new Color (250,240,230));
+ g.fillRect (
+ (int)(mnHOffset+0.5),
+ (int)(mnVOffset+0.5),
+ (int)(mnScale*aScreenSize.getWidth()),
+ (int)(mnScale*aScreenSize.getHeight()));
+ // Draw a frame arround the screen rectangle to increase its visibility.
+ g.setColor (Color.BLACK);
+ g.drawRect (
+ (int)(mnHOffset+0.5),
+ (int)(mnVOffset+0.5),
+ (int)(mnScale*aScreenSize.getWidth()),
+ (int)(mnScale*aScreenSize.getHeight()));
+
+ // Now do the actual display of the accessible object.
+ drawAccessibleObject (g, mxContext, Color.GREEN);
+ }
+ public synchronized void paintChildren (Graphics g)
+ {
+ }
+ public synchronized void paintBorder (Graphics g)
+ {
+ }
+
+
+
+
+ /** Draw a simple representation of the given accessible object in the
+ specified color.
+ */
+ public void drawAccessibleObject (Graphics g, XAccessibleContext xContext, Color aColor)
+ {
+ if (xContext != null)
+ {
+ // First draw our parent.
+ XAccessible xParent = xContext.getAccessibleParent();
+ if (xParent != null)
+ drawAccessibleObject (g, xParent.getAccessibleContext(), Color.GRAY);
+
+ // When the context supports the XAccessibleComponent interface
+ // then draw its outline.
+ XAccessibleComponent xComponent =
+ (XAccessibleComponent)UnoRuntime.queryInterface(
+ XAccessibleComponent.class, xContext);
+ if (xComponent != null)
+ {
+ // Get size and location on screen and transform them to fit
+ // everything inside this widget.
+ Point aLocation = xComponent.getLocationOnScreen();
+ Size aSize = xComponent.getSize();
+ g.setColor (aColor);
+ g.drawRect (
+ (int)(mnHOffset + mnScale*aLocation.X+0.5),
+ (int)(mnVOffset + mnScale*aLocation.Y+0.5),
+ (int)(mnScale*aSize.Width),
+ (int)(mnScale*aSize.Height));
+ }
+ }
+ }
+
+
+ public synchronized void setAccessibleObject (XAccessibleContext xContext)
+ {
+ mxContext = xContext;
+ repaint ();
+ }
+
+ public synchronized void updateAccessibleObject (XAccessibleContext xContext)
+ {
+ repaint ();
+ }
+
+
+ /** Set up the transformation so that the graphical display can show a
+ centered representation of the whole screen.
+ */
+ private void setupTransformation ()
+ {
+ Dimension aScreenSize = Toolkit.getDefaultToolkit().getScreenSize();
+ Dimension aWidgetSize = getSize();
+ if ((aScreenSize.getWidth() > 0) && (aScreenSize.getHeight() > 0))
+ {
+ // Calculate the scales that would map the screen onto the
+ // widget in both of the coordinate axes and select the smaller
+ // of the two: it maps the screen onto the widget in both axes
+ // at the same time.
+ double nHScale = (aWidgetSize.getWidth() - 10) / aScreenSize.getWidth();
+ double nVScale = (aWidgetSize.getHeight() - 10) / aScreenSize.getHeight();
+ if (nHScale < nVScale)
+ mnScale = nHScale;
+ else
+ mnScale = nVScale;
+
+ // Calculate offsets that center the scaled screen inside the widget.
+ mnHOffset = (aWidgetSize.getWidth() - mnScale*aScreenSize.getWidth()) / 2.0;
+ mnVOffset = (aWidgetSize.getHeight() - mnScale*aScreenSize.getHeight()) / 2.0;
+ }
+ else
+ {
+ // In case of a degenerate (not yet initialized?) screen size
+ // use some meaningless default values.
+ mnScale = 1;
+ mnHOffset = 0;
+ mnVOffset = 0;
+ }
+ }
+
+
+ private XAccessibleContext mxContext;
+ private double mnScale;
+ private double mnHOffset;
+ private double mnVOffset;
+}
diff --git a/odk/examples/DevelopersGuide/Accessibility/IAccessibleObjectDisplay.java b/odk/examples/DevelopersGuide/Accessibility/IAccessibleObjectDisplay.java
new file mode 100644
index 000000000000..5e8eb3a2655c
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Accessibility/IAccessibleObjectDisplay.java
@@ -0,0 +1,46 @@
+/*************************************************************************
+ *
+ * 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.accessibility.XAccessibleContext;
+
+interface IAccessibleObjectDisplay
+{
+
+ /** Set the accessible object to display. Call this method e.g. when a
+ new object has been focused.
+ */
+ public void setAccessibleObject (XAccessibleContext xContext);
+
+ public void updateAccessibleObject (XAccessibleContext xContext);
+}
diff --git a/odk/examples/DevelopersGuide/Accessibility/Makefile b/odk/examples/DevelopersGuide/Accessibility/Makefile
new file mode 100644
index 000000000000..6eda8233a326
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Accessibility/Makefile
@@ -0,0 +1,113 @@
+#*************************************************************************
+#
+# 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.
+#
+#**************************************************************************
+
+# Build the simple screen reader (SSR) described in the Developers
+# Guide Accessibility chapter.
+
+PRJ=../../..
+SETTINGS=$(PRJ)/settings
+
+include $(SETTINGS)/settings.mk
+include $(SETTINGS)/std.mk
+include $(SETTINGS)/dk.mk
+
+# Define non-platform/compiler specific settings
+EXAMPLE_NAME=DevGuideAccessibilityExample
+OUT_APP_CLASS = $(OUT_CLASS)/$(EXAMPLE_NAME)
+
+APP1_NAME =SSR
+APP1_JAR =$(OUT_APP_CLASS)/$(APP1_NAME).jar
+
+JAVAFILES = \
+ MessageArea.java \
+ ConnectionTask.java \
+ EventHandler.java \
+ EventListenerProxy.java \
+ GraphicalDisplay.java \
+ NameProvider.java \
+ IAccessibleObjectDisplay.java \
+ RegistrationThread.java \
+ SSR.java \
+ TextualDisplay.java
+
+APP1_CLASSFILES = $(patsubst %.java,$(OUT_APP_CLASS)/%.class,$(JAVAFILES))
+APP1_CLASSNAMES = $(patsubst %.java,%.class,$(JAVAFILES)) \
+ EventListenerProxy$(ICL)1.class \
+ EventListenerProxy$(ICL)2.class \
+ EventListenerProxy$(ICL)3.class \
+ EventListenerProxy$(ICL)4.class
+
+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) $(JAVAFILES)
+
+$(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 Before you run this example you should start your office with at least a
+ @echo new empty document and you should have enabled the accessibility support.
+ @echo Please use the following command to execute the Simple Screen Reader 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/Accessibility/MessageArea.java b/odk/examples/DevelopersGuide/Accessibility/MessageArea.java
new file mode 100644
index 000000000000..9f3280a591a1
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Accessibility/MessageArea.java
@@ -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.
+ *
+ *************************************************************************/
+
+import java.awt.Font;
+import java.awt.Rectangle;
+import java.awt.Color;
+import java.awt.Graphics;
+import javax.swing.JScrollPane;
+import javax.swing.JTextArea;
+import javax.swing.JScrollBar;
+
+
+
+/** A message area displays text in a scrollable text widget. It is a
+ singleton. Other objects can access it directly to display messages.
+*/
+public class MessageArea
+ extends JScrollPane
+{
+ public static synchronized MessageArea Instance ()
+ {
+ if (saInstance == null)
+ saInstance = new MessageArea ();
+ return saInstance;
+ }
+
+
+
+
+ /** Create a new message area. This method is private because the class is
+ a singleton and may therefore not be instanciated from the outside.
+ */
+ private MessageArea ()
+ {
+ maText = new JTextArea();
+ maText.setBackground (new Color (255,250,240));
+ maText.setFont (new Font ("Helvetica", Font.PLAIN, 9));
+ setViewportView (maText);
+ setVerticalScrollBarPolicy (JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
+ setHorizontalScrollBarPolicy (JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
+
+ printMessage (
+ "class path is " + System.getProperty ("java.class.path") + "\n");
+ }
+
+
+
+
+ /** Show the given string at the end of the message area and scroll to make
+ it visible.
+ */
+ public static synchronized void print (String aMessage)
+ {
+ Instance().printMessage(aMessage);
+ }
+
+
+
+
+ /** Show the given string at the end of the message area and scroll to make
+ it visible.
+ */
+ public static void println (String aMessage)
+ {
+ Instance().printMessage (aMessage+"\n");
+ }
+
+
+ public void paintComponent (Graphics g)
+ {
+ // Synchronize with the graphics object to prevent paint problems.
+ // Remember that this is not done by Swing itself.
+ synchronized (g)
+ {
+ JScrollBar sb = getVerticalScrollBar();
+ if (sb != null)
+ {
+ int nScrollBarValue = sb.getMaximum() - sb.getVisibleAmount() - 1;
+ sb.setValue (nScrollBarValue);
+ }
+ super.paintComponent (g);
+ }
+ }
+
+
+
+
+ /** Append the given string to the end of the text and scroll so that it
+ becomes visible. This is an internal method. Use one of the static
+ and public ones.
+ */
+ private synchronized void printMessage (String aMessage)
+ {
+ maText.append (aMessage);
+ }
+
+
+
+
+ private static MessageArea saInstance = null;
+ private JTextArea maText;
+}
diff --git a/odk/examples/DevelopersGuide/Accessibility/NameProvider.java b/odk/examples/DevelopersGuide/Accessibility/NameProvider.java
new file mode 100644
index 000000000000..9eeba18f83fd
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Accessibility/NameProvider.java
@@ -0,0 +1,290 @@
+/*************************************************************************
+ *
+ * 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 com.sun.star.accessibility.AccessibleStateType;
+import com.sun.star.accessibility.AccessibleEventId;
+import com.sun.star.accessibility.AccessibleRole;
+import com.sun.star.accessibility.AccessibleRelationType;
+
+
+/** Provide names for several accessibility constants groups.
+*/
+public class NameProvider
+{
+ /** Return the name of the specified state.
+ @param nStateId
+ Id of the state for which to return its name. This is one of
+ the ids listed in the <type>AccessibleStateType</const>
+ constants group.
+ @return
+ Returns the name of the specified state or an empty string if an
+ invalid / unknown state id was given.
+ */
+ public static String getStateName (int nStateId)
+ {
+ return (String)maStateMap.get (new Integer(nStateId));
+ }
+
+
+ /** Return the name of the specified event.
+ @param nEventId
+ Id of the event type for which to return its name. This is one
+ of the ids listed in the <type>AccessibleEventId</const>
+ constants group.
+ @return
+ Returns the name of the specified event type or an empty string
+ if an invalid / unknown event id was given.
+ */
+ public static String getEventName (int nEventId)
+ {
+ return (String)maEventMap.get (new Integer(nEventId));
+ }
+
+
+ /** Return the name of the specified role.
+ @param nRole
+ Id of the role for which to return its name. This is one of
+ the ids listed in the <type>AccessibleRole</const>
+ constants group.
+ @return
+ Returns the name of the specified role or an empty string if an
+ invalid / unknown role id was given.
+ */
+ public static String getRoleName (int nRole)
+ {
+ return (String)maRoleMap.get (new Integer(nRole));
+ }
+
+
+ /** Return the name of the specified relation.
+ @param nRelation
+ Id of the relation for which to return its name. This is one of
+ the ids listed in the <type>AccessibleRelationType</const>
+ constants group.
+ @return
+ Returns the name of the specified relation type or an empty
+ string if an invalid / unknown role id was given.
+ */
+ public static String getRelationName (int nRelation)
+ {
+ return (String)maRelationMap.get (new Integer(nRelation));
+ }
+
+
+ private static HashMap maStateMap = new HashMap();
+ private static HashMap maEventMap = new HashMap();
+ private static HashMap maRoleMap = new HashMap();
+ private static HashMap maRelationMap = new HashMap();
+
+ static {
+ maStateMap.put (new Integer (AccessibleStateType.INVALID), "INVALID");
+ maStateMap.put (new Integer (AccessibleStateType.ACTIVE), "ACTIVE");
+ maStateMap.put (new Integer (AccessibleStateType.ARMED), "ARMED");
+ maStateMap.put (new Integer (AccessibleStateType.BUSY), "BUSY");
+ maStateMap.put (new Integer (AccessibleStateType.CHECKED), "CHECKED");
+ maStateMap.put (new Integer (AccessibleStateType.DEFUNC), "DEFUNC");
+ maStateMap.put (new Integer (AccessibleStateType.EDITABLE), "EDITABLE");
+ maStateMap.put (new Integer (AccessibleStateType.ENABLED), "ENABLED");
+ maStateMap.put (new Integer (AccessibleStateType.EXPANDABLE), "EXPANDABLE");
+ maStateMap.put (new Integer (AccessibleStateType.EXPANDED), "EXPANDED");
+ maStateMap.put (new Integer (AccessibleStateType.FOCUSABLE), "FOCUSABLE");
+ maStateMap.put (new Integer (AccessibleStateType.FOCUSED), "FOCUSED");
+ maStateMap.put (new Integer (AccessibleStateType.HORIZONTAL), "HORIZONTAL");
+ maStateMap.put (new Integer (AccessibleStateType.ICONIFIED), "ICONIFIED");
+ maStateMap.put (new Integer (AccessibleStateType.MODAL), "MODAL");
+ maStateMap.put (new Integer (AccessibleStateType.MULTI_LINE), "MULTI_LINE");
+ maStateMap.put (new Integer (AccessibleStateType.MULTI_SELECTABLE), "MULTI_SELECTABLE");
+ maStateMap.put (new Integer (AccessibleStateType.OPAQUE), "OPAQUE");
+ maStateMap.put (new Integer (AccessibleStateType.PRESSED), "PRESSED");
+ maStateMap.put (new Integer (AccessibleStateType.RESIZABLE), "RESIZABLE");
+ maStateMap.put (new Integer (AccessibleStateType.SELECTABLE), "SELECTABLE");
+ maStateMap.put (new Integer (AccessibleStateType.SELECTED), "SELECTED");
+ maStateMap.put (new Integer (AccessibleStateType.SENSITIVE), "SENSITIVE");
+ maStateMap.put (new Integer (AccessibleStateType.SHOWING), "SHOWING");
+ maStateMap.put (new Integer (AccessibleStateType.SINGLE_LINE), "SINGLE_LINE");
+ maStateMap.put (new Integer (AccessibleStateType.STALE), "STALE");
+ maStateMap.put (new Integer (AccessibleStateType.TRANSIENT), "TRANSIENT");
+ maStateMap.put (new Integer (AccessibleStateType.VERTICAL), "VERTICAL");
+ maStateMap.put (new Integer (AccessibleStateType.VISIBLE), "VISIBLE");
+ maStateMap.put (new Integer (AccessibleStateType.MANAGES_DESCENDANTS),
+ "MANAGES_DESCENDANTS");
+ // maStateMap.put (new Integer (AccessibleStateType.INCONSISTENT),"INCONSISTENT");
+
+
+ maEventMap.put (new Integer (0),
+ "[UNKNOWN]");
+ maEventMap.put (new Integer (AccessibleEventId.NAME_CHANGED),
+ "NAME_CHANGED");
+ maEventMap.put (new Integer (AccessibleEventId.DESCRIPTION_CHANGED),
+ "DESCRIPTION_CHANGED");
+ maEventMap.put (new Integer (AccessibleEventId.ACTION_CHANGED),
+ "ACTION_CHANGED");
+ maEventMap.put (new Integer (AccessibleEventId.STATE_CHANGED),
+ "STATE_CHANGED");
+ maEventMap.put (new Integer (AccessibleEventId.ACTIVE_DESCENDANT_CHANGED),
+ "ACTIVE_DESCENDANT_CHANGED");
+ maEventMap.put (new Integer (AccessibleEventId.BOUNDRECT_CHANGED),
+ "BOUNDRECT_CHANGED");
+ maEventMap.put (new Integer (AccessibleEventId.CHILD),
+ "CHILD");
+ maEventMap.put (new Integer (AccessibleEventId.INVALIDATE_ALL_CHILDREN),
+ "INVALIDATE_ALL_CHILDREN");
+ maEventMap.put (new Integer (AccessibleEventId.SELECTION_CHANGED),
+ "SELECTION_CHANGED");
+ maEventMap.put (new Integer (AccessibleEventId.VISIBLE_DATA_CHANGED),
+ "VISIBLE_DATA_CHANGED");
+ maEventMap.put (new Integer (AccessibleEventId.VALUE_CHANGED),
+ "VALUE_CHANGED");
+ maEventMap.put (new Integer (AccessibleEventId.CONTENT_FLOWS_FROM_RELATION_CHANGED),
+ "CONTENT_FLOWS_FROM_RELATION_CHANGED");
+ maEventMap.put (new Integer (AccessibleEventId.CONTENT_FLOWS_TO_RELATION_CHANGED),
+ "CONTENT_FLOWS_TO_RELATION_CHANGED");
+ maEventMap.put (new Integer (AccessibleEventId.CONTROLLED_BY_RELATION_CHANGED),
+ "CONTROLLED_BY_RELATION_CHANGED");
+ maEventMap.put (new Integer (AccessibleEventId.CONTROLLER_FOR_RELATION_CHANGED),
+ "CONTROLLER_FOR_RELATION_CHANGED");
+ maEventMap.put (new Integer (AccessibleEventId.LABEL_FOR_RELATION_CHANGED),
+ "LABEL_FOR_RELATION_CHANGED");
+ maEventMap.put (new Integer (AccessibleEventId.LABELED_BY_RELATION_CHANGED),
+ "LABELED_BY_RELATION_CHANGED");
+ maEventMap.put (new Integer (AccessibleEventId.MEMBER_OF_RELATION_CHANGED),
+ "MEMBER_OF_RELATION_CHANGED");
+ maEventMap.put (new Integer (AccessibleEventId.SUB_WINDOW_OF_RELATION_CHANGED),
+ "SUB_WINDOW_OF_RELATION_CHANGED");
+ maEventMap.put (new Integer (AccessibleEventId.CARET_CHANGED),
+ "CARET_CHANGED");
+ maEventMap.put (new Integer (AccessibleEventId.TEXT_SELECTION_CHANGED),
+ "TEXT_SELECTION_CHANGED");
+ maEventMap.put (new Integer (AccessibleEventId.TEXT_CHANGED),
+ "TEXT_CHANGED");
+ maEventMap.put (new Integer (AccessibleEventId.TEXT_ATTRIBUTE_CHANGED),
+ "TEXT_ATTRIBUTE_CHANGED");
+ maEventMap.put (new Integer (AccessibleEventId.HYPERTEXT_CHANGED),
+ "HYPERTEXT_CHANGED");
+ maEventMap.put (new Integer (AccessibleEventId.TABLE_CAPTION_CHANGED),
+ "TABLE_CAPTION_CHANGED");
+ maEventMap.put (new Integer (AccessibleEventId.TABLE_COLUMN_DESCRIPTION_CHANGED),
+ "TABLE_COLUMN_DESCRIPTION_CHANGED");
+ maEventMap.put (new Integer (AccessibleEventId.TABLE_COLUMN_HEADER_CHANGED),
+ "TABLE_COLUMN_HEADER_CHANGED");
+ maEventMap.put (new Integer (AccessibleEventId.TABLE_MODEL_CHANGED),
+ "TABLE_MODEL_CHANGED");
+ maEventMap.put (new Integer (AccessibleEventId.TABLE_ROW_DESCRIPTION_CHANGED),
+ "TABLE_ROW_DESCRIPTION_CHANGED");
+ maEventMap.put (new Integer (AccessibleEventId.TABLE_ROW_HEADER_CHANGED),
+ "TABLE_ROW_HEADER_CHANGED");
+ maEventMap.put (new Integer (AccessibleEventId.TABLE_SUMMARY_CHANGED),
+ "TABLE_SUMMARY_CHANGED");
+
+ maRoleMap.put (new Integer(AccessibleRole.UNKNOWN), "UNKNOWN");
+ maRoleMap.put (new Integer (AccessibleRole.UNKNOWN), "UNKNOWN");
+ maRoleMap.put (new Integer (AccessibleRole.ALERT), "ALERT");
+ maRoleMap.put (new Integer (AccessibleRole.COLUMN_HEADER), "COLUMN_HEADER");
+ maRoleMap.put (new Integer (AccessibleRole.CANVAS), "CANVAS");
+ maRoleMap.put (new Integer (AccessibleRole.CHECK_BOX), "CHECK_BOX");
+ maRoleMap.put (new Integer (AccessibleRole.CHECK_MENU_ITEM), "CHECK_MENU_ITEM");
+ maRoleMap.put (new Integer (AccessibleRole.COLOR_CHOOSER), "COLOR_CHOOSER");
+ maRoleMap.put (new Integer (AccessibleRole.COMBO_BOX), "COMBO_BOX");
+ maRoleMap.put (new Integer (AccessibleRole.DESKTOP_ICON), "DESKTOP_ICON");
+ maRoleMap.put (new Integer (AccessibleRole.DESKTOP_PANE), "DESKTOP_PANE");
+ maRoleMap.put (new Integer (AccessibleRole.DIRECTORY_PANE), "DIRECTORY_PANE");
+ maRoleMap.put (new Integer (AccessibleRole.DIALOG), "DIALOG");
+ maRoleMap.put (new Integer (AccessibleRole.DOCUMENT), "DOCUMENT");
+ maRoleMap.put (new Integer (AccessibleRole.EMBEDDED_OBJECT), "EMBEDDED_OBJECT");
+ maRoleMap.put (new Integer (AccessibleRole.END_NOTE), "END_NOTE");
+ maRoleMap.put (new Integer (AccessibleRole.FILE_CHOOSER), "FILE_CHOOSER");
+ maRoleMap.put (new Integer (AccessibleRole.FILLER), "FILLER");
+ maRoleMap.put (new Integer (AccessibleRole.FONT_CHOOSER), "FONT_CHOOSER");
+ maRoleMap.put (new Integer (AccessibleRole.FOOTER), "FOOTER");
+ maRoleMap.put (new Integer (AccessibleRole.FOOTNOTE), "FOOTNOTE");
+ maRoleMap.put (new Integer (AccessibleRole.FRAME), "FRAME");
+ maRoleMap.put (new Integer (AccessibleRole.GLASS_PANE), "GLASS_PANE");
+ maRoleMap.put (new Integer (AccessibleRole.GRAPHIC), "GRAPHIC");
+ maRoleMap.put (new Integer (AccessibleRole.GROUP_BOX), "GROUP_BOX");
+ maRoleMap.put (new Integer (AccessibleRole.HEADER), "HEADER");
+ maRoleMap.put (new Integer (AccessibleRole.HEADING), "HEADING");
+ maRoleMap.put (new Integer (AccessibleRole.HYPER_LINK), "HYPER_LINK");
+ maRoleMap.put (new Integer (AccessibleRole.ICON), "ICON");
+ maRoleMap.put (new Integer (AccessibleRole.INTERNAL_FRAME), "INTERNAL_FRAME");
+ maRoleMap.put (new Integer (AccessibleRole.LABEL), "LABEL");
+ maRoleMap.put (new Integer (AccessibleRole.LAYERED_PANE), "LAYERED_PANE");
+ maRoleMap.put (new Integer (AccessibleRole.LIST), "LIST");
+ maRoleMap.put (new Integer (AccessibleRole.LIST_ITEM), "LIST_ITEM");
+ maRoleMap.put (new Integer (AccessibleRole.MENU), "MENU");
+ maRoleMap.put (new Integer (AccessibleRole.MENU_BAR), "MENU_BAR");
+ maRoleMap.put (new Integer (AccessibleRole.MENU_ITEM), "MENU_ITEM");
+ maRoleMap.put (new Integer (AccessibleRole.OPTION_PANE), "OPTION_PANE");
+ maRoleMap.put (new Integer (AccessibleRole.PAGE_TAB), "PAGE_TAB");
+ maRoleMap.put (new Integer (AccessibleRole.PAGE_TAB_LIST), "PAGE_TAB_LIST");
+ maRoleMap.put (new Integer (AccessibleRole.PANEL), "PANEL");
+ maRoleMap.put (new Integer (AccessibleRole.PARAGRAPH), "PARAGRAPH");
+ maRoleMap.put (new Integer (AccessibleRole.PASSWORD_TEXT), "PASSWORD_TEXT");
+ maRoleMap.put (new Integer (AccessibleRole.POPUP_MENU), "POPUP_MENU");
+ maRoleMap.put (new Integer (AccessibleRole.PUSH_BUTTON), "PUSH_BUTTON");
+ maRoleMap.put (new Integer (AccessibleRole.PROGRESS_BAR), "PROGRESS_BAR");
+ maRoleMap.put (new Integer (AccessibleRole.RADIO_BUTTON), "RADIO_BUTTON");
+ maRoleMap.put (new Integer (AccessibleRole.RADIO_MENU_ITEM), "RADIO_MENU_ITEM");
+ maRoleMap.put (new Integer (AccessibleRole.ROW_HEADER), "ROW_HEADER");
+ maRoleMap.put (new Integer (AccessibleRole.ROOT_PANE), "ROOT_PANE");
+ maRoleMap.put (new Integer (AccessibleRole.SCROLL_BAR), "SCROLL_BAR");
+ maRoleMap.put (new Integer (AccessibleRole.SCROLL_PANE), "SCROLL_PANE");
+ maRoleMap.put (new Integer (AccessibleRole.SHAPE), "SHAPE");
+ maRoleMap.put (new Integer (AccessibleRole.SEPARATOR), "SEPARATOR");
+ maRoleMap.put (new Integer (AccessibleRole.SLIDER), "SLIDER");
+ maRoleMap.put (new Integer (AccessibleRole.SPIN_BOX), "SPIN_BOX");
+ maRoleMap.put (new Integer (AccessibleRole.SPLIT_PANE), "SPLIT_PANE");
+ maRoleMap.put (new Integer (AccessibleRole.STATUS_BAR), "STATUS_BAR");
+ maRoleMap.put (new Integer (AccessibleRole.TABLE), "TABLE");
+ maRoleMap.put (new Integer (AccessibleRole.TABLE_CELL), "TABLE_CELL");
+ maRoleMap.put (new Integer (AccessibleRole.TEXT), "TEXT");
+ maRoleMap.put (new Integer (AccessibleRole.TEXT_FRAME), "TEXT_FRAME");
+ maRoleMap.put (new Integer (AccessibleRole.TOGGLE_BUTTON), "TOGGLE_BUTTON");
+ maRoleMap.put (new Integer (AccessibleRole.TOOL_BAR), "TOOL_BAR");
+ maRoleMap.put (new Integer (AccessibleRole.TOOL_TIP), "TOOL_TIP");
+ maRoleMap.put (new Integer (AccessibleRole.TREE), "TREE");
+ maRoleMap.put (new Integer (AccessibleRole.VIEW_PORT), "VIEW_PORT");
+ maRoleMap.put (new Integer (AccessibleRole.WINDOW), "WINDOW");
+
+ maRelationMap.put (new Integer (AccessibleRelationType.INVALID), "INVALID");
+ maRelationMap.put (new Integer (AccessibleRelationType.CONTENT_FLOWS_FROM), "CONTENT_FLOWS_FROM");
+ maRelationMap.put (new Integer (AccessibleRelationType.CONTENT_FLOWS_TO), "CONTENT_FLOWS_TO");
+ maRelationMap.put (new Integer (AccessibleRelationType.CONTROLLED_BY), "CONTROLLED_BY");
+ maRelationMap.put (new Integer (AccessibleRelationType.CONTROLLER_FOR), "CONTROLLER_FOR");
+ maRelationMap.put (new Integer (AccessibleRelationType.LABEL_FOR), "LABEL_FOR");
+ maRelationMap.put (new Integer (AccessibleRelationType.LABELED_BY), "LABELED_BY");
+ maRelationMap.put (new Integer (AccessibleRelationType.MEMBER_OF), "MEMBER_OF");
+ maRelationMap.put (new Integer (AccessibleRelationType.SUB_WINDOW_OF), "SUB_WINDOW_OF");
+ }
+}
diff --git a/odk/examples/DevelopersGuide/Accessibility/RegistrationThread.java b/odk/examples/DevelopersGuide/Accessibility/RegistrationThread.java
new file mode 100644
index 000000000000..092941b323a7
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Accessibility/RegistrationThread.java
@@ -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.
+ *
+ *************************************************************************/
+
+import java.awt.event.ActionListener;
+import javax.swing.*;
+import java.awt.*;
+import java.util.*;
+
+import com.sun.star.awt.XTopWindowListener;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.bridge.XUnoUrlResolver;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.accessibility.*;
+import com.sun.star.awt.XExtendedToolkit;
+
+/** This class is used as a thread and registers or unregsiters a listener
+ given the constructor at all nodes of a tree of accessibility objects.
+*/
+public class RegistrationThread
+ implements Runnable
+{
+ /** Start a new thread that adds or removes the given listener at all
+ accessible objects in the sub-tree rooted in the given accessible
+ object.
+ @param aListener
+ The listener that is added or removed.
+ @param xRoot
+ The root of the sub-tree of accessibility objects.
+ @param bRegister
+ This flag decides whether to add or remove the listener.
+ */
+ public RegistrationThread (
+ EventListenerProxy aListener,
+ XAccessibleContext xRoot,
+ boolean bRegister,
+ boolean bShowMessages)
+ {
+ maListener = aListener;
+ mxRoot = xRoot;
+ mbRegister = bRegister;
+ mbShowMessages = bShowMessages;
+
+ if (mxRoot != null)
+ {
+ if (mbShowMessages)
+ MessageArea.println ("starting to register at " + mxRoot.getAccessibleName());
+ new Thread (this, "RegistrationThread").start();
+ }
+ }
+
+
+
+ public void run ()
+ {
+ System.out.println ("starting registration");
+ long nNodeCount = traverseTree (mxRoot);
+ System.out.println ("ending registration");
+ if (mbShowMessages)
+ {
+ if ( ! mbRegister)
+ MessageArea.print ("un");
+ MessageArea.println ("registered at " + nNodeCount
+ + " objects in accessibility tree of " + mxRoot.getAccessibleName());
+ }
+ }
+
+
+
+
+ /** Register this object as listener for accessibility events at all nodes
+ of the given tree.
+ @param xRoot
+ The root node of the tree at which to register.
+ */
+ public long traverseTree (XAccessibleContext xRoot)
+ {
+ long nNodeCount = 0;
+ if (xRoot != null)
+ {
+ // Register the root node.
+ XAccessibleEventBroadcaster xBroadcaster =
+ (XAccessibleEventBroadcaster) UnoRuntime.queryInterface (
+ XAccessibleEventBroadcaster.class,
+ xRoot);
+ if (xBroadcaster != null)
+ {
+ if (mbRegister)
+ xBroadcaster.addEventListener (maListener);
+ else
+ xBroadcaster.removeEventListener (maListener);
+ nNodeCount += 1;
+ }
+
+ // Call this method recursively to register all sub-trees.
+ try
+ {
+ int nChildCount = xRoot.getAccessibleChildCount();
+ for (int i=0; i<nChildCount; i++)
+ {
+ XAccessible xChild = xRoot.getAccessibleChild (i);
+ if (xChild != null)
+ nNodeCount += traverseTree (xChild.getAccessibleContext());
+ }
+ }
+ catch (com.sun.star.lang.IndexOutOfBoundsException aException)
+ {
+ // The set of children has changed since our last call to
+ // getAccesibleChildCount(). Don't try any further on this
+ // sub-tree.
+ }
+ catch (com.sun.star.lang.DisposedException aException)
+ {
+ // The child has been destroyed since our last call to
+ // getAccesibleChildCount(). That is OK. Don't try any
+ // further on this sub-tree.
+ }
+ }
+ return nNodeCount;
+ }
+
+ private EventListenerProxy maListener;
+ private XAccessibleContext mxRoot;
+ private boolean mbRegister;
+ private boolean mbShowMessages;
+}
diff --git a/odk/examples/DevelopersGuide/Accessibility/SSR.java b/odk/examples/DevelopersGuide/Accessibility/SSR.java
new file mode 100644
index 000000000000..e1830cfa2630
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Accessibility/SSR.java
@@ -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.
+ *
+ *************************************************************************/
+
+import java.awt.event.ActionListener;
+import java.awt.GridBagLayout;
+import java.awt.GridBagConstraints;
+import javax.swing.*;
+
+
+/** The simple screen reader (SSR) registers at the toolkit as focus listener
+ and displays information about the currently focused object.
+*/
+public class SSR
+ implements ActionListener
+{
+ /** Just pass the control to the SSR class.
+ */
+ public static void main (String args[])
+ {
+ new SSR ();
+ }
+
+
+
+
+ /** Create a new instance of the simple screen reader.
+ */
+ public SSR ()
+ {
+ Layout ();
+
+ // Create the event handler and tell it where to display information
+ // about the currently focused accessible object.
+ maEventHandler = new EventHandler ();
+ maEventHandler.addObjectDisplay (maTextualDisplay);
+ maEventHandler.addObjectDisplay (maGraphicalDisplay);
+ }
+
+
+
+
+ /** Setup the GUI. It is divided into three areas. The lower half is
+ ocupied by a message area that logs all the events received from
+ accessibility objects. The upper half is shared by two different
+ displays of the currently focused object. On left there is a textual
+ representation. On the right there is a graphical view of the
+ objects's outline.
+ */
+ private void Layout ()
+ {
+ GridBagConstraints constraints;
+
+ JPanel aPanel = new JPanel (true);
+ aPanel.setLayout (new GridBagLayout());
+ aPanel.setOpaque (true);
+
+ mFrame = new JFrame ("Simple Screen Reader 0.3");
+ mFrame.setContentPane(aPanel);
+ mFrame.setSize (600,400);
+
+
+ addComponent (new JLabel ("Focused Object:"),
+ 0,0, 1,1, 0,0, GridBagConstraints.WEST, GridBagConstraints.NONE);
+
+
+ maTextualDisplay = new TextualDisplay ();
+ addComponent (maTextualDisplay,
+ 0,1, 1,1, 1,1, GridBagConstraints.CENTER, GridBagConstraints.BOTH);
+
+ maGraphicalDisplay = new GraphicalDisplay ();
+ addComponent (maGraphicalDisplay,
+ 1,0, 1,2, 1,1, GridBagConstraints.CENTER, GridBagConstraints.BOTH);
+
+ addComponent (new JLabel ("Messages:"),
+ 0,2, 1,1, 0,0, GridBagConstraints.WEST, GridBagConstraints.NONE);
+
+ addComponent (MessageArea.Instance(),
+ 0,3, 2,1, 1,1, GridBagConstraints.CENTER, GridBagConstraints.BOTH);
+
+
+ JButton aButton = new JButton ("Quit SSR");
+ addComponent (aButton,
+ 0,4, 1,1, 0,0, GridBagConstraints.WEST,GridBagConstraints.NONE);
+ aButton.addActionListener (this);
+
+ mFrame.show();
+ }
+
+
+
+
+ /** Add a GUI element with the given constraints to the main window.
+ */
+ private JComponent addComponent (JComponent aComponent,
+ int x, int y, int width, int height, double weightx, double weighty,
+ int anchor, int fill)
+ {
+ aComponent.setDoubleBuffered (false);
+ GridBagConstraints aConstraints = new GridBagConstraints();
+ aConstraints.gridx = x;
+ aConstraints.gridy = y;
+ aConstraints.gridwidth = width;
+ aConstraints.gridheight = height;
+ aConstraints.weightx = weightx;
+ aConstraints.weighty = weighty;
+ aConstraints.anchor = anchor;
+ aConstraints.fill = fill;
+
+ mFrame.getContentPane().add (aComponent, aConstraints);
+
+ return aComponent;
+ }
+
+
+
+
+ /** This call-back handles button presses.
+ */
+ public void actionPerformed (java.awt.event.ActionEvent e)
+ {
+ if (e.getActionCommand().equals ("Quit SSR"))
+ {
+ maEventHandler.finalize ();
+ System.exit(0);
+ }
+ }
+
+
+ /// The main frame that contains all other GUI elements.
+ private JFrame mFrame;
+
+ /// A textutal representation of the currently focused object.
+ private TextualDisplay maTextualDisplay;
+
+ /// A graphical representation of the currently focused object.
+ private GraphicalDisplay maGraphicalDisplay;
+
+ /// The event handler that reacts to all the accessibility events.
+ private EventHandler maEventHandler;
+}
diff --git a/odk/examples/DevelopersGuide/Accessibility/TextualDisplay.java b/odk/examples/DevelopersGuide/Accessibility/TextualDisplay.java
new file mode 100644
index 000000000000..0d8ce96d978d
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Accessibility/TextualDisplay.java
@@ -0,0 +1,230 @@
+/*************************************************************************
+ *
+ * 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.Color;
+import java.awt.Font;
+import java.awt.Dimension;
+import javax.swing.JTextArea;
+import javax.swing.JScrollPane;
+import java.util.Vector;
+
+import com.sun.star.accessibility.XAccessible;
+import com.sun.star.accessibility.XAccessibleContext;
+import com.sun.star.accessibility.XAccessibleComponent;
+import com.sun.star.accessibility.XAccessibleStateSet;
+
+import com.sun.star.uno.AnyConverter;
+import com.sun.star.uno.UnoRuntime;
+
+import com.sun.star.awt.Point;
+import com.sun.star.awt.Size;
+
+/** Display textual information for a given accessible object. This
+ includes the names of that object of its ancestors as well as some
+ information retrieved from the XAccessibleContext and
+ XAccessibleComponent interfaces.
+*/
+class TextualDisplay
+ extends JScrollPane
+ implements IAccessibleObjectDisplay
+{
+ /** Create a new scroll pane that contains a text widget which display
+ information about given accessible objects.
+ */
+ public TextualDisplay ()
+ {
+ // Create a text widget for displaying the text information...
+ maText = new JTextArea (80,10);
+ maText.setBackground (new Color (250,240,230));
+ maText.setFont (new Font ("Courier", Font.PLAIN, 11));
+
+ // ...and set-up the scroll pane to show this widget.
+ setViewportView (maText);
+ setVerticalScrollBarPolicy (JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
+ setHorizontalScrollBarPolicy (JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
+ }
+
+
+
+
+ /** Set the accessible object to display. Call this method e.g. when a
+ new object has been focused.
+ */
+ public synchronized void setAccessibleObject (XAccessibleContext xContext)
+ {
+ // First clear the display area.
+ msTextContent = new String ();
+
+ if (xContext != null)
+ {
+ String sIndentation = showParents (xContext);
+ showContextInfo (xContext, sIndentation);
+ showComponentInfo (xContext, sIndentation);
+ }
+
+ maText.setText (msTextContent);
+ }
+
+
+
+
+ public synchronized void updateAccessibleObject (XAccessibleContext xContext)
+ {
+ setAccessibleObject (xContext);
+ }
+
+
+
+ /** Show some of the information available over the given object's
+ XAccessibleContext interface.
+ */
+ private void showContextInfo (XAccessibleContext xContext, String sIndentation)
+ {
+ // Show the description.
+ msTextContent += sIndentation + "Description: "
+ + xContext.getAccessibleDescription() + "\n";
+
+ showStates (xContext, sIndentation);
+ }
+
+
+
+
+ /** Show a list of all of the the given object's states. Use the
+ NameConverter class to transform the numerical state ids into human
+ readable names.
+ @param xContext
+ The accessible context for which to show the state names.
+ */
+ private void showStates (XAccessibleContext xContext, String sIndentation)
+ {
+ // Get the state set object...
+ XAccessibleStateSet xStateSet = xContext.getAccessibleStateSet();
+ // ...and retrieve an array of numerical ids.
+ short aStates[] = xStateSet.getStates();
+
+ // Iterate over the array and print the names of the states.
+ msTextContent += sIndentation + "States : ";
+ for (int i=0; i<aStates.length; i++)
+ {
+ if (i > 0)
+ msTextContent += ", ";
+ msTextContent += NameProvider.getStateName(aStates[i]);
+ }
+ msTextContent += "\n";
+ }
+
+
+
+
+ /** When the given object supports the XAccessibleComponent interface then
+ show its size and location on the screen.
+ */
+ private void showComponentInfo (XAccessibleContext xContext, String sIndentation)
+ {
+ // Try to cast the given accessible context to the
+ // XAccessibleComponent interface.
+ XAccessibleComponent xComponent =
+ (XAccessibleComponent)UnoRuntime.queryInterface(
+ XAccessibleComponent.class, xContext);
+ if (xComponent != null)
+ {
+ Point aLocation = xComponent.getLocationOnScreen();
+ msTextContent += sIndentation + "Position : "
+ + aLocation.X + ", " + aLocation.Y + "\n";
+
+ Size aSize = xComponent.getSize();
+ msTextContent += sIndentation + "Size : "
+ + aSize.Width + ", " + aSize.Height + "\n";
+ }
+ }
+
+
+
+
+
+ /** Print the names of the given object and its parents and return an
+ indentation string that can be used to print further information
+ about the object.
+ */
+ private String showParents (XAccessibleContext xContext)
+ {
+ // Create the path from the given object to its tree's root.
+ Vector aPathToRoot = new Vector();
+ while (xContext != null)
+ {
+ aPathToRoot.add (xContext);
+ // Go up the hierarchy one level to the object's parent.
+ try
+ {
+ XAccessible xParent = xContext.getAccessibleParent();
+ if (xParent != null)
+ xContext = xParent.getAccessibleContext();
+ else
+ xContext = null;
+ }
+ catch (Exception e)
+ {
+ System.err.println ("caught exception " + e + " while getting path to root");
+ }
+ }
+
+ // Print the path in the accessibility tree from the given context to
+ // the root.
+ String sIndentation = new String ();
+ for (int i=aPathToRoot.size()-1; i>=0; i--)
+ {
+ XAccessibleContext xParentContext = (XAccessibleContext)aPathToRoot.get(i);
+ String sParentName = xParentContext.getAccessibleName();
+ if (sParentName.length() == 0)
+ sParentName = "<unnamed> / Role "
+ + NameProvider.getRoleName(xParentContext.getAccessibleRole());
+ msTextContent += sIndentation + sParentName + "\n";
+ sIndentation += msIndentation;
+ }
+
+ return sIndentation;
+ }
+
+
+
+ /// The text widget that is used for the actual text display.
+ private JTextArea maText;
+
+ /// The indentation with which an object's child is indented.
+ private final String msIndentation = new String(" ");
+
+ /// The text content displayed by this object.
+ private String msTextContent = new String ();
+}
diff --git a/odk/examples/DevelopersGuide/Accessibility/makefile.mk b/odk/examples/DevelopersGuide/Accessibility/makefile.mk
new file mode 100644
index 000000000000..5efa8ee709ff
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Accessibility/makefile.mk
@@ -0,0 +1,73 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ=..$/..$/..
+PRJNAME=odk
+TARGET=copying
+
+#----------------------------------------------------------------
+.INCLUDE: settings.mk
+.INCLUDE: $(PRJ)$/util$/makefile.pmk
+#----------------------------------------------------------------
+
+#----------------------------------------------------
+# this makefile is only used for copying the example
+# files into the SDK
+#----------------------------------------------------
+
+ACCESSIBILITY_FILES=\
+ $(DESTDIRDEVGUIDEEXAMPLES)$/Accessibility$/ConnectionTask.java \
+ $(DESTDIRDEVGUIDEEXAMPLES)$/Accessibility$/EventHandler.java \
+ $(DESTDIRDEVGUIDEEXAMPLES)$/Accessibility$/EventListenerProxy.java \
+ $(DESTDIRDEVGUIDEEXAMPLES)$/Accessibility$/GraphicalDisplay.java \
+ $(DESTDIRDEVGUIDEEXAMPLES)$/Accessibility$/IAccessibleObjectDisplay.java \
+ $(DESTDIRDEVGUIDEEXAMPLES)$/Accessibility$/Makefile \
+ $(DESTDIRDEVGUIDEEXAMPLES)$/Accessibility$/MessageArea.java \
+ $(DESTDIRDEVGUIDEEXAMPLES)$/Accessibility$/NameProvider.java \
+ $(DESTDIRDEVGUIDEEXAMPLES)$/Accessibility$/RegistrationThread.java \
+ $(DESTDIRDEVGUIDEEXAMPLES)$/Accessibility$/SSR.java \
+ $(DESTDIRDEVGUIDEEXAMPLES)$/Accessibility$/TextualDisplay.java
+
+DIR_FILE_LIST= \
+ $(ACCESSIBILITY_FILES)
+
+DIR_DIRECTORY_LIST=$(uniq $(DIR_FILE_LIST:d))
+DIR_CREATE_FLAG=$(MISC)$/devguide_accessibility_dirs_created.txt
+DIR_FILE_FLAG=$(MISC)$/devguide_accessibility.txt
+
+#--------------------------------------------------
+# TARGETS
+#--------------------------------------------------
+all : \
+ $(DIR_FILE_LIST) \
+ $(DIR_FILE_FLAG)
+
+#--------------------------------------------------
+# use global rules
+#--------------------------------------------------
+.INCLUDE: $(PRJ)$/util$/odk_rules.pmk
+
diff --git a/odk/examples/DevelopersGuide/BasicAndDialogs/CreatingDialogs/CreatingDialogs.odt b/odk/examples/DevelopersGuide/BasicAndDialogs/CreatingDialogs/CreatingDialogs.odt
new file mode 100644
index 000000000000..dd55f9076ec1
--- /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 000000000000..e6549be017c5
--- /dev/null
+++ b/odk/examples/DevelopersGuide/BasicAndDialogs/CreatingDialogs/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 CreatingDialogs example of the Developers Guide.
+
+PRJ=../../../..
+SETTINGS=$(PRJ)/settings
+
+include $(SETTINGS)/settings.mk
+include $(SETTINGS)/std.mk
+include $(SETTINGS)/dk.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)
+ifneq "$(SDK_AUTO_DEPLOYMENT)" ""
+ -$(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 000000000000..27a97ec40345
--- /dev/null
+++ b/odk/examples/DevelopersGuide/BasicAndDialogs/CreatingDialogs/SampleDialog.java
@@ -0,0 +1,275 @@
+/*************************************************************************
+ *
+ * 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.compareTo( "execute" ) == 0 ) {
+ try {
+ createDialog();
+ }
+ catch ( Exception e ) {
+ throw new com.sun.star.lang.WrappedTargetRuntimeException( 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", new Integer( 100 ) );
+ xPSetDialog.setPropertyValue( "PositionY", new Integer( 100 ) );
+ xPSetDialog.setPropertyValue( "Width", new Integer( 150 ) );
+ xPSetDialog.setPropertyValue( "Height", new Integer( 100 ) );
+ xPSetDialog.setPropertyValue( "Title", new String( "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", new Integer( 20 ) );
+ xPSetButton.setPropertyValue( "PositionY", new Integer( 70 ) );
+ xPSetButton.setPropertyValue( "Width", new Integer( 50 ) );
+ xPSetButton.setPropertyValue( "Height", new Integer( 14 ) );
+ xPSetButton.setPropertyValue( "Name", _buttonName );
+ xPSetButton.setPropertyValue( "TabIndex", new Short( (short)0 ) );
+ xPSetButton.setPropertyValue( "Label", new String( "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", new Integer( 40 ) );
+ xPSetLabel.setPropertyValue( "PositionY", new Integer( 30 ) );
+ xPSetLabel.setPropertyValue( "Width", new Integer( 100 ) );
+ xPSetLabel.setPropertyValue( "Height", new Integer( 14 ) );
+ xPSetLabel.setPropertyValue( "Name", _labelName );
+ xPSetLabel.setPropertyValue( "TabIndex", new Short( (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", new Integer( 80 ) );
+ xPSetCancelButton.setPropertyValue( "PositionY", new Integer( 70 ) );
+ xPSetCancelButton.setPropertyValue( "Width", new Integer( 50 ) );
+ xPSetCancelButton.setPropertyValue( "Height", new Integer( 14 ) );
+ xPSetCancelButton.setPropertyValue( "Name", _cancelButtonName );
+ xPSetCancelButton.setPropertyValue( "TabIndex", new Short( (short)2 ) );
+ xPSetCancelButton.setPropertyValue( "PushButtonType", new Short( (short)2 ) );
+ xPSetCancelButton.setPropertyValue( "Label", new String( "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 );
+ }
+ }
+}
diff --git a/odk/examples/DevelopersGuide/BasicAndDialogs/FirstStepsBasic.odt b/odk/examples/DevelopersGuide/BasicAndDialogs/FirstStepsBasic.odt
new file mode 100644
index 000000000000..4024740f1a41
--- /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 000000000000..c5f17ec68b88
--- /dev/null
+++ b/odk/examples/DevelopersGuide/BasicAndDialogs/ToolkitControls/Makefile
@@ -0,0 +1,126 @@
+#*************************************************************************
+#
+# 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
+include $(SETTINGS)/dk.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 000000000000..ffedaa7565af
--- /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 000000000000..4a36d76217e2
--- /dev/null
+++ b/odk/examples/DevelopersGuide/BasicAndDialogs/ToolkitControls/ToolkitControls/FileDialog.xba
@@ -0,0 +1,73 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!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 000000000000..06f1c4cd2219
--- /dev/null
+++ b/odk/examples/DevelopersGuide/BasicAndDialogs/ToolkitControls/ToolkitControls/FileDialogDlg.xdl
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!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 000000000000..3a9571581983
--- /dev/null
+++ b/odk/examples/DevelopersGuide/BasicAndDialogs/ToolkitControls/ToolkitControls/MultiPage.xba
@@ -0,0 +1,286 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!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;Vegeterian&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> \ No newline at end of file
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 000000000000..bc6360b3b33f
--- /dev/null
+++ b/odk/examples/DevelopersGuide/BasicAndDialogs/ToolkitControls/ToolkitControls/MultiPageDlg.xdl
@@ -0,0 +1,75 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!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;&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;&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> \ No newline at end of file
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 000000000000..648b4091b034
--- /dev/null
+++ b/odk/examples/DevelopersGuide/BasicAndDialogs/ToolkitControls/ToolkitControls/ProgressBar.xba
@@ -0,0 +1,76 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!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 000000000000..f39f5bfdf3b7
--- /dev/null
+++ b/odk/examples/DevelopersGuide/BasicAndDialogs/ToolkitControls/ToolkitControls/ProgressBarDlg.xdl
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!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 000000000000..6ea6bddb8b86
--- /dev/null
+++ b/odk/examples/DevelopersGuide/BasicAndDialogs/ToolkitControls/ToolkitControls/ScrollBar.xba
@@ -0,0 +1,86 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!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 000000000000..95957e370f06
--- /dev/null
+++ b/odk/examples/DevelopersGuide/BasicAndDialogs/ToolkitControls/ToolkitControls/ScrollBarDlg.xdl
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!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 000000000000..a74e020a1d66
--- /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 000000000000..03741ae35805
--- /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/BasicAndDialogs/makefile.mk b/odk/examples/DevelopersGuide/BasicAndDialogs/makefile.mk
new file mode 100644
index 000000000000..3dd72c264c7b
--- /dev/null
+++ b/odk/examples/DevelopersGuide/BasicAndDialogs/makefile.mk
@@ -0,0 +1,84 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ=..$/..$/..
+PRJNAME=odk
+TARGET=copying
+
+#----------------------------------------------------------------
+.INCLUDE: settings.mk
+.INCLUDE: $(PRJ)$/util$/makefile.pmk
+#----------------------------------------------------------------
+
+#----------------------------------------------------
+# this makefile is only used for copying the example
+# files into the SDK
+#----------------------------------------------------
+
+BASICANDDIALOGS_FILES=\
+ $(DESTDIRDEVGUIDEEXAMPLES)$/BasicAndDialogs$/FirstStepsBasic.odt
+
+CREATINGDIALOGS_FILES=\
+ $(DESTDIRDEVGUIDEEXAMPLES)$/BasicAndDialogs$/CreatingDialogs$/SampleDialog.java \
+ $(DESTDIRDEVGUIDEEXAMPLES)$/BasicAndDialogs$/CreatingDialogs$/CreatingDialogs.odt \
+ $(DESTDIRDEVGUIDEEXAMPLES)$/BasicAndDialogs$/CreatingDialogs$/Makefile
+
+TOOLKITCONTROLS_FILES=\
+ $(DESTDIRDEVGUIDEEXAMPLES)$/BasicAndDialogs$/ToolkitControls$/Makefile \
+ $(DESTDIRDEVGUIDEEXAMPLES)$/BasicAndDialogs$/ToolkitControls$/ToolkitControls.odt \
+ $(DESTDIRDEVGUIDEEXAMPLES)$/BasicAndDialogs$/ToolkitControls$/ToolkitControls$/dialog.xlb \
+ $(DESTDIRDEVGUIDEEXAMPLES)$/BasicAndDialogs$/ToolkitControls$/ToolkitControls$/FileDialog.xba \
+ $(DESTDIRDEVGUIDEEXAMPLES)$/BasicAndDialogs$/ToolkitControls$/ToolkitControls$/FileDialogDlg.xdl \
+ $(DESTDIRDEVGUIDEEXAMPLES)$/BasicAndDialogs$/ToolkitControls$/ToolkitControls$/MultiPage.xba \
+ $(DESTDIRDEVGUIDEEXAMPLES)$/BasicAndDialogs$/ToolkitControls$/ToolkitControls$/MultiPageDlg.xdl \
+ $(DESTDIRDEVGUIDEEXAMPLES)$/BasicAndDialogs$/ToolkitControls$/ToolkitControls$/ProgressBar.xba \
+ $(DESTDIRDEVGUIDEEXAMPLES)$/BasicAndDialogs$/ToolkitControls$/ToolkitControls$/ProgressBarDlg.xdl \
+ $(DESTDIRDEVGUIDEEXAMPLES)$/BasicAndDialogs$/ToolkitControls$/ToolkitControls$/script.xlb \
+ $(DESTDIRDEVGUIDEEXAMPLES)$/BasicAndDialogs$/ToolkitControls$/ToolkitControls$/ScrollBar.xba \
+ $(DESTDIRDEVGUIDEEXAMPLES)$/BasicAndDialogs$/ToolkitControls$/ToolkitControls$/ScrollBarDlg.xdl
+
+DIR_FILE_LIST= \
+ $(BASICANDDIALOGS_FILES) \
+ $(CREATINGDIALOGS_FILES) \
+ $(TOOLKITCONTROLS_FILES)
+
+DIR_DIRECTORY_LIST=$(uniq $(DIR_FILE_LIST:d))
+DIR_CREATE_FLAG=$(MISC)$/devguide_basicanddialogs_dirs_created.txt
+DIR_FILE_FLAG=$(MISC)$/devguide_basicanddialogs.txt
+
+#--------------------------------------------------
+# TARGETS
+#--------------------------------------------------
+all : \
+ $(DIR_FILE_LIST) \
+ $(DIR_FILE_FLAG)
+
+#--------------------------------------------------
+# use global rules
+#--------------------------------------------------
+.INCLUDE: $(PRJ)$/util$/odk_rules.pmk
+
diff --git a/odk/examples/DevelopersGuide/Charts/AddInChart.ods b/odk/examples/DevelopersGuide/Charts/AddInChart.ods
new file mode 100644
index 000000000000..01708ed7ba51
--- /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 000000000000..c7a82f327118
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Charts/CalcHelper.java
@@ -0,0 +1,412 @@
+/*************************************************************************
+ *
+ * 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;
+
+// base classes
+import com.sun.star.uno.XInterface;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.lang.*;
+
+// factory for creating components
+import com.sun.star.comp.servicemanager.ServiceManager;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.bridge.XUnoUrlResolver;
+import com.sun.star.uno.XNamingService;
+import com.sun.star.frame.XDesktop;
+import com.sun.star.frame.XComponentLoader;
+
+// property access
+import com.sun.star.beans.*;
+
+// 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;
+import com.sun.star.frame.XController;
+
+// 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;
+import com.sun.star.beans.UnknownPropertyException;
+import com.sun.star.lang.IndexOutOfBoundsException;
+
+// __________ Implementation __________
+
+/** Helper for accessing a calc document
+ @author Bj&ouml;rn Milcke
+ */
+public class CalcHelper
+{
+ public CalcHelper( XSpreadsheetDocument aDoc )
+ {
+ maSpreadSheetDoc = aDoc;
+ initSpreadSheet();
+ }
+
+ // ____________________
+
+ public XSpreadsheet getChartSheet() throws RuntimeException
+ {
+ XNameAccess aSheetsNA = (XNameAccess) UnoRuntime.queryInterface(
+ XNameAccess.class, maSpreadSheetDoc.getSheets() );
+
+ XSpreadsheet aSheet = null;
+ try
+ {
+ aSheet = (XSpreadsheet) 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 = (XNameAccess) UnoRuntime.queryInterface(
+ XNameAccess.class, maSpreadSheetDoc.getSheets() );
+
+ XSpreadsheet aSheet = null;
+ if( aSheetsNA != null )
+ {
+ try
+ {
+ aSheet = (XSpreadsheet) 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 correspoding
+ 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 = (XTableChartsSupplier) UnoRuntime.queryInterface(
+ XTableChartsSupplier.class, getChartSheet() );
+ }
+ catch( Exception ex )
+ {
+ System.out.println( "Sheet not found" + ex );
+ return aResult;
+ }
+
+ XTableCharts aChartCollection = aSheet.getCharts();
+ XNameAccess aChartCollectionNA = (XNameAccess) 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 = (XTableChart) UnoRuntime.queryInterface(
+ XTableChart.class, aChartCollectionNA.getByName( sChartName ));
+
+ // the table chart is an embedded object which contains the chart document
+ aResult = (XChartDocument) UnoRuntime.queryInterface(
+ XChartDocument.class,
+ ((XEmbeddedObjectSupplier) UnoRuntime.queryInterface(
+ XEmbeddedObjectSupplier.class,
+ aTableChart )).getEmbeddedObject());
+
+ // create a diagram via the factory and set this as new diagram
+ aResult.setDiagram(
+ (XDiagram) UnoRuntime.queryInterface(
+ XDiagram.class,
+ ((XMultiServiceFactory) 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 = (XCellRange) 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 = (double)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 = (XCellRange) UnoRuntime.queryInterface( XCellRange.class, aSheet );
+
+ aRange = aSheetRange.getCellRangeByPosition(
+ 0, 0,
+ nColumnCount - 1, nRowCount - 1 );
+
+ int nCol, nRow;
+ double fValue;
+ double fFactor = 2.0 * java.lang.Math.PI / (double)(nRowCount - 1);
+ String aFormula;
+
+ // set variable factor for cos formula
+ int nFactorCol = nColumnCount + 2;
+ (aSheet.getCellByPosition( nFactorCol - 1, 0 )).setValue( 0.2 );
+
+ XText xCellText = (XText) 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 = (double)nRow * fFactor;
+ (aSheet.getCellByPosition( nCol, nRow )).setValue( fValue );
+ }
+ else
+ {
+ aFormula = new String( "=" );
+ 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()
+ {
+ ((XSpreadsheetView) UnoRuntime.queryInterface(
+ XSpreadsheetView.class,
+ ((XModel) UnoRuntime.queryInterface(
+ XModel.class,
+ maSpreadSheetDoc )).getCurrentController()) ).setActiveSheet( getChartSheet() );
+ }
+
+
+ // __________ private members and methods __________
+
+ private final String msDataSheetName = "Data";
+ private final String msChartSheetName = "Chart";
+
+ private 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 = (XNameContainer) UnoRuntime.queryInterface(
+ XNameContainer.class, aSheets );
+ XIndexAccess aSheetsIA = (XIndexAccess) 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(
+ ( (XNamed) UnoRuntime.queryInterface(
+ XNamed.class, aSheetsIA.getByIndex( i ) )).getName() );
+ }
+
+ XNamed aFirstSheet = (XNamed) 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 );
+ }
+ }
+ }
+ }
+}
diff --git a/odk/examples/DevelopersGuide/Charts/ChartHelper.java b/odk/examples/DevelopersGuide/Charts/ChartHelper.java
new file mode 100644
index 000000000000..0cffc0e3e954
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Charts/ChartHelper.java
@@ -0,0 +1,261 @@
+/*************************************************************************
+ *
+ * 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 classes
+import com.sun.star.uno.XInterface;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.Any;
+
+// factory for creating components
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.lang.XComponent;
+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.*;
+import com.sun.star.frame.XModel;
+import com.sun.star.text.XTextDocument;
+import com.sun.star.text.XTextContent;
+import com.sun.star.text.XTextCursor;
+import com.sun.star.text.XText;
+//import com.sun.star.text.VertOrientation;
+//import com.sun.star.text.HoriOrientation;
+import com.sun.star.document.XEmbeddedObjectSupplier;
+
+// base graphics things
+import com.sun.star.awt.Point;
+import com.sun.star.awt.Size;
+
+// Exceptions
+import com.sun.star.uno.RuntimeException;
+import com.sun.star.container.NoSuchElementException;
+import com.sun.star.beans.UnknownPropertyException;
+import com.sun.star.lang.IndexOutOfBoundsException;
+
+// __________ Implementation __________
+
+/** Helper for creating an OLE chart
+ @author Bj&ouml;rn Milcke
+ */
+public class ChartHelper
+{
+ public ChartHelper( XModel aContainerDoc )
+ {
+ maContainerDocument = aContainerDoc;
+ }
+
+ public XChartDocument insertOLEChartInWriter(
+ String sChartName,
+ Point aUpperLeft,
+ Size aExtent,
+ String sChartServiceName )
+ {
+ XChartDocument aResult = null;
+
+ XMultiServiceFactory aFact = (XMultiServiceFactory)
+ UnoRuntime.queryInterface(XMultiServiceFactory.class,
+ maContainerDocument );
+
+ if( aFact != null )
+ {
+ try
+ {
+ XTextContent xTextContent = (XTextContent)UnoRuntime.queryInterface(
+ XTextContent.class,
+ aFact.createInstance("com.sun.star.text.TextEmbeddedObject"));
+
+ if ( xTextContent != null )
+ {
+ XPropertySet xPropSet = (XPropertySet)UnoRuntime.queryInterface(
+ XPropertySet.class, xTextContent);
+
+ Any aAny = new Any(String.class, msChartClassID);
+ xPropSet.setPropertyValue("CLSID", aAny );
+
+ XTextDocument xTextDoc = (XTextDocument)
+ 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 = (XShape)UnoRuntime.queryInterface(
+ XShape.class, xTextContent);
+ xShape.setSize( aExtent );
+
+ aAny = new Any(Short.class,
+ new Short(com.sun.star.text.VertOrientation.NONE));
+ xPropSet.setPropertyValue("VertOrient", aAny );
+ aAny = new Any(Short.class,
+ new Short(com.sun.star.text.HoriOrientation.NONE));
+ xPropSet.setPropertyValue("HoriOrient", aAny );
+ aAny = new Any(Integer.class, new Integer(aUpperLeft.Y));
+ xPropSet.setPropertyValue("VertOrientPosition", aAny );
+ aAny = new Any(Integer.class, new Integer(aUpperLeft.X));
+ xPropSet.setPropertyValue("HoriOrientPosition", aAny );
+
+ // retrieve the chart document as model of the OLE shape
+ aResult = (XChartDocument) UnoRuntime.queryInterface(
+ XChartDocument.class,
+ xPropSet.getPropertyValue( "Model" ));
+
+ // create a diagram via the factory and set this as
+ // new diagram
+ aResult.setDiagram(
+ (XDiagram) UnoRuntime.queryInterface(
+ XDiagram.class,
+ ((XMultiServiceFactory) UnoRuntime.queryInterface(
+ XMultiServiceFactory.class,
+ aResult )).createInstance(sChartServiceName )));
+ }
+ } catch( Exception ex)
+ {
+ System.out.println( "caught exception: " + ex );
+ }
+ }
+
+ return aResult;
+ }
+
+ public XChartDocument insertOLEChartInDraw(
+ String sChartName,
+ Point aUpperLeft,
+ Size aExtent,
+ String sChartServiceName )
+ {
+ XChartDocument aResult = null;
+
+ XShapes aPage = null;
+
+ // try interface for multiple pages in a document
+ XDrawPagesSupplier aSupplier = (XDrawPagesSupplier)
+ UnoRuntime.queryInterface(XDrawPagesSupplier.class,
+ maContainerDocument );
+
+ if( aSupplier != null )
+ {
+ try
+ {
+ // get first page
+ aPage = (XShapes) 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 = (XDrawPageSupplier)
+ UnoRuntime.queryInterface(XDrawPageSupplier.class,
+ maContainerDocument );
+
+ if( aOnePageSupplier != null )
+ {
+ aPage = (XShapes) UnoRuntime.queryInterface(
+ XShapes.class, aOnePageSupplier.getDrawPage());
+ }
+ }
+
+ if( aPage != null )
+ {
+ XMultiServiceFactory aFact = (XMultiServiceFactory)
+ UnoRuntime.queryInterface(XMultiServiceFactory.class,
+ maContainerDocument );
+
+ if( aFact != null )
+ {
+ try
+ {
+ // create an OLE shape
+ XShape aShape = (XShape) 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 = (XPropertySet)
+ 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 = (XChartDocument) UnoRuntime.queryInterface(
+ XChartDocument.class,
+ aShapeProp.getPropertyValue( "Model" ));
+
+ // create a diagram via the factory and set this as
+ // new diagram
+ aResult.setDiagram(
+ (XDiagram) UnoRuntime.queryInterface(
+ XDiagram.class,
+ ((XMultiServiceFactory) 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 final String msChartClassID = "12dcae26-281f-416f-a234-c3086127382e";
+
+ private XModel maContainerDocument;
+}
diff --git a/odk/examples/DevelopersGuide/Charts/ChartInCalc.java b/odk/examples/DevelopersGuide/Charts/ChartInCalc.java
new file mode 100644
index 000000000000..06f571bec304
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Charts/ChartInCalc.java
@@ -0,0 +1,424 @@
+/*************************************************************************
+ *
+ * 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 classes
+import com.sun.star.uno.XInterface;
+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.frame.XController;
+
+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.Rectangle;
+import com.sun.star.awt.FontWeight;
+import com.sun.star.awt.FontRelief;
+
+// 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
+ @author Bj&ouml;rn Milcke
+ */
+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 = ((XCellRangeAddressable) 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
+ {
+ ((XModel) UnoRuntime.queryInterface( XModel.class, maChartDocument )).lockControllers();
+ }
+
+ // ____________________
+
+ public void unlockControllers()
+ throws RuntimeException
+ {
+ ((XModel) UnoRuntime.queryInterface( XModel.class, maChartDocument )).unlockControllers();
+ }
+
+ // ____________________
+
+ public void testDiagram()
+ throws RuntimeException, UnknownPropertyException, PropertyVetoException,
+ com.sun.star.lang.IllegalArgumentException, WrappedTargetException
+ {
+ XPropertySet aDiaProp = (XPropertySet) UnoRuntime.queryInterface( XPropertySet.class, maDiagram );
+
+ if( aDiaProp != null )
+ {
+ // change chart type
+ aDiaProp.setPropertyValue( "Lines", new Boolean( true ));
+
+ // change attributes for all series
+ // set line width to 0.5mm
+ aDiaProp.setPropertyValue( "LineWidth", new Integer( 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", new Integer(
+ 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", new Integer( ChartSymbolType.BITMAPURL ));
+ aSeriesProp.setPropertyValue( "SymbolBitmapURL", sUrl.toString() );
+ }
+ else
+ {
+ aSeriesProp.setPropertyValue( "SymbolType", new Integer( 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
+ int nMaxIndex = 0;
+
+ XChartDataArray aDataArray = (XChartDataArray) 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 ];
+ nMaxIndex = i;
+ }
+ }
+
+ // 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", new Integer( ChartSymbolType.SYMBOL6 ));
+ aPointProp.setPropertyValue( "SymbolSize", new Size( 600, 600 ));
+
+ // add a label text with bold font, bordeaux red 14pt
+ aPointProp.setPropertyValue( "DataCaption", new Integer( ChartDataCaption.VALUE ));
+ aPointProp.setPropertyValue( "CharHeight", new Float( 14.0 ));
+ aPointProp.setPropertyValue( "CharColor", new Integer( 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", new Integer( 0xeeeeee ));
+ }
+ }
+
+ // ____________________
+
+ public void testWall()
+ throws RuntimeException, UnknownPropertyException, PropertyVetoException,
+ com.sun.star.lang.IllegalArgumentException, WrappedTargetException
+ {
+ XPropertySet aWall = ((X3DDisplay) UnoRuntime.queryInterface(
+ X3DDisplay.class, maDiagram )).getWall();
+
+ // change background color of area
+ aWall.setPropertyValue( "FillStyle", FillStyle.SOLID );
+ aWall.setPropertyValue( "FillColor", new Integer( 0xcccccc ));
+ }
+
+ // ____________________
+
+ public void testTitle()
+ throws RuntimeException, UnknownPropertyException, PropertyVetoException,
+ com.sun.star.lang.IllegalArgumentException, WrappedTargetException
+ {
+ // change main title
+ XPropertySet aDocProp = (XPropertySet) UnoRuntime.queryInterface(
+ XPropertySet.class, maChartDocument );
+ aDocProp.setPropertyValue( "HasMainTitle", new Boolean( true ));
+
+ XShape aTitle = maChartDocument.getTitle();
+ XPropertySet aTitleProp = (XPropertySet) 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 = (XShape) UnoRuntime.queryInterface(
+ XShape.class, ((XAxisYSupplier) 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 = ((XAxisXSupplier) UnoRuntime.queryInterface(
+ XAxisXSupplier.class, maDiagram )).getXAxis();
+ if( aAxisProp != null )
+ {
+ aAxisProp.setPropertyValue( "Max", new Integer( 24 ));
+ aAxisProp.setPropertyValue( "StepMain", new Integer( 3 ));
+ }
+
+ // change number format for y axis
+ aAxisProp = ((XAxisYSupplier) UnoRuntime.queryInterface(
+ XAxisYSupplier.class, maDiagram )).getYAxis();
+
+ // add a new custom number format and get the new key
+ int nNewNumberFormat = 0;
+ XNumberFormatsSupplier aNumFmtSupp = (XNumberFormatsSupplier) 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", new Integer( nNewNumberFormat ));
+ }
+ }
+
+ // ____________________
+
+ public void testGrid()
+ throws RuntimeException, UnknownPropertyException, PropertyVetoException,
+ com.sun.star.lang.IllegalArgumentException, WrappedTargetException
+ {
+ // y major grid
+ XPropertySet aGridProp = (XPropertySet) UnoRuntime.queryInterface(
+ XPropertySet.class,
+ ( (XAxisYSupplier) 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", new Integer( 0x999999 ));
+ aGridProp.setPropertyValue( "LineStyle", LineStyle.DASH );
+ aGridProp.setPropertyValue( "LineDash", aDash );
+ aGridProp.setPropertyValue( "LineWidth", new Integer( 30 ));
+ }
+ }
+
+
+ // ______________________________
+ //
+ // private members
+ // ______________________________
+
+ private XChartDocument maChartDocument;
+ private XDiagram maDiagram;
+}
diff --git a/odk/examples/DevelopersGuide/Charts/ChartInDraw.java b/odk/examples/DevelopersGuide/Charts/ChartInDraw.java
new file mode 100644
index 000000000000..9b206f5f7635
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Charts/ChartInDraw.java
@@ -0,0 +1,308 @@
+/*************************************************************************
+ *
+ * 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 classes
+import com.sun.star.uno.XInterface;
+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.frame.XModel;
+import com.sun.star.frame.XController;
+
+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.Rectangle;
+import com.sun.star.awt.FontWeight;
+import com.sun.star.awt.FontRelief;
+
+// 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
+ @author Bj&ouml;rn Milcke
+ */
+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(
+ "BarChart",
+ 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
+ {
+ ((XModel) UnoRuntime.queryInterface( XModel.class, maChartDocument )).lockControllers();
+ }
+
+ // ____________________
+
+ public void unlockControllers()
+ throws RuntimeException
+ {
+ ((XModel) 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", new Integer( 0xeeeeee ));
+ }
+ }
+
+ // ____________________
+
+ public void testWall()
+ throws RuntimeException, UnknownPropertyException, PropertyVetoException,
+ com.sun.star.lang.IllegalArgumentException, WrappedTargetException
+ {
+ XPropertySet aWall = ((X3DDisplay) UnoRuntime.queryInterface(
+ X3DDisplay.class, maDiagram )).getWall();
+
+ // change background color of area
+ aWall.setPropertyValue( "FillColor", new Integer( 0xcccccc ));
+ aWall.setPropertyValue( "FillStyle", FillStyle.SOLID );
+ }
+
+ // ____________________
+
+ public void testTitle()
+ throws RuntimeException, UnknownPropertyException, PropertyVetoException,
+ com.sun.star.lang.IllegalArgumentException, WrappedTargetException
+ {
+ // change main title
+ XPropertySet aDocProp = (XPropertySet) UnoRuntime.queryInterface(
+ XPropertySet.class, maChartDocument );
+ aDocProp.setPropertyValue( "HasMainTitle", new Boolean( true ));
+
+ XShape aTitle = maChartDocument.getTitle();
+ XPropertySet aTitleProp = (XPropertySet) 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 = (XPropertySet) UnoRuntime.queryInterface( XPropertySet.class, aLegend );
+
+ aLegendProp.setPropertyValue( "Alignment", ChartLegendPosition.LEFT );
+ aLegendProp.setPropertyValue( "FillStyle", FillStyle.SOLID );
+ aLegendProp.setPropertyValue( "FillColor", new Integer( 0xeeddee ));
+ }
+
+ // ____________________
+
+ public void testThreeD()
+ throws RuntimeException, UnknownPropertyException, PropertyVetoException,
+ com.sun.star.lang.IllegalArgumentException, WrappedTargetException,
+ com.sun.star.lang.IndexOutOfBoundsException
+ {
+ XPropertySet aDiaProp = (XPropertySet) UnoRuntime.queryInterface( XPropertySet.class, maDiagram );
+ Boolean aTrue = new Boolean( true );
+
+ aDiaProp.setPropertyValue( "Dim3D", aTrue );
+ aDiaProp.setPropertyValue( "Deep", aTrue );
+ // from Chart3DBarProperties:
+ aDiaProp.setPropertyValue( "SolidType", new Integer( ChartSolidType.CYLINDER ));
+
+ // change floor color to Magenta6
+ XPropertySet aFloor = ((X3DDisplay) UnoRuntime.queryInterface(
+ X3DDisplay.class, maDiagram )).getFloor();
+ aFloor.setPropertyValue( "FillColor", new Integer( 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 = java.lang.Math.cos( java.lang.Math.PI / 180.0 * fAngle );
+ double fSinX = java.lang.Math.sin( java.lang.Math.PI / 180.0 * fAngle );
+
+ // rotate -20 degrees along the y axis
+ fAngle = -20.0;
+ double fCosY = java.lang.Math.cos( java.lang.Math.PI / 180.0 * fAngle );
+ double fSinY = java.lang.Math.sin( java.lang.Math.PI / 180.0 * fAngle );
+
+ // rotate -5 degrees along the z axis
+ fAngle = -5.0;
+ double fCosZ = java.lang.Math.cos( java.lang.Math.PI / 180.0 * fAngle );
+ double fSinZ = java.lang.Math.sin( java.lang.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", new Integer( 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", new Boolean( true ));
+ }
+
+ // ______________________________
+ //
+ // private members
+ // ______________________________
+
+ private XChartDocument maChartDocument;
+ private XDiagram maDiagram;
+}
diff --git a/odk/examples/DevelopersGuide/Charts/ChartInWriter.java b/odk/examples/DevelopersGuide/Charts/ChartInWriter.java
new file mode 100644
index 000000000000..9f64e1f49c22
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Charts/ChartInWriter.java
@@ -0,0 +1,178 @@
+/*************************************************************************
+ *
+ * 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 classes
+import com.sun.star.uno.XInterface;
+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.text.XTextDocument;
+
+import com.sun.star.table.CellRangeAddress;
+import com.sun.star.frame.XModel;
+import com.sun.star.frame.XController;
+
+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.Rectangle;
+import com.sun.star.awt.FontWeight;
+import com.sun.star.awt.FontRelief;
+
+// 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 __________
+
+/** 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!
+
+ @author Bj&ouml;rn Milcke
+ */
+public class ChartInWriter
+{
+ // ____________________
+
+ public static void main( String args[] )
+ {
+ Helper aHelper = new Helper( args );
+
+ ChartHelper aChartHelper = new ChartHelper(
+ (XModel) 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(
+ "BarChart",
+ 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
+ {
+ ((XModel) UnoRuntime.queryInterface( XModel.class, maChartDocument )).lockControllers();
+ }
+
+ // ____________________
+
+ public void unlockControllers()
+ throws RuntimeException
+ {
+ ((XModel) UnoRuntime.queryInterface( XModel.class, maChartDocument )).unlockControllers();
+ }
+
+ // ____________________
+
+ public void testWall()
+ throws RuntimeException, UnknownPropertyException, PropertyVetoException,
+ com.sun.star.lang.IllegalArgumentException, WrappedTargetException
+ {
+ XPropertySet aWall = ((X3DDisplay) UnoRuntime.queryInterface(
+ X3DDisplay.class, maDiagram )).getWall();
+
+ // change background color of area
+ aWall.setPropertyValue( "FillColor", new Integer( 0xeecc99 ));
+ aWall.setPropertyValue( "FillStyle", FillStyle.SOLID );
+ }
+
+ // ______________________________
+ //
+ // private members
+ // ______________________________
+
+ private XChartDocument maChartDocument;
+ private XDiagram maDiagram;
+}
diff --git a/odk/examples/DevelopersGuide/Charts/Helper.java b/odk/examples/DevelopersGuide/Charts/Helper.java
new file mode 100644
index 000000000000..13efc37d177a
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Charts/Helper.java
@@ -0,0 +1,170 @@
+/*************************************************************************
+ *
+ * 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;
+
+// base classes
+import com.sun.star.uno.XInterface;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.XComponentContext;
+import com.sun.star.lang.*;
+
+// factory for creating components
+import com.sun.star.comp.servicemanager.ServiceManager;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.bridge.XUnoUrlResolver;
+import com.sun.star.uno.XNamingService;
+import com.sun.star.frame.XDesktop;
+import com.sun.star.frame.XComponentLoader;
+
+// property access
+import com.sun.star.beans.*;
+
+// container access
+import com.sun.star.container.*;
+
+// application specific classes
+import com.sun.star.sheet.XSpreadsheetDocument;
+import com.sun.star.text.XTextDocument;
+
+import com.sun.star.document.XEmbeddedObjectSupplier;
+import com.sun.star.frame.XModel;
+import com.sun.star.frame.XController;
+
+// Exceptions
+import com.sun.star.uno.RuntimeException;
+import com.sun.star.container.NoSuchElementException;
+import com.sun.star.beans.UnknownPropertyException;
+import com.sun.star.lang.IndexOutOfBoundsException;
+
+// __________ Implementation __________
+
+/** Helper for creating a calc document adding cell values and charts
+ @author Bj&ouml;rn Milcke
+ */
+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 (XSpreadsheetDocument) UnoRuntime.queryInterface(
+ XSpreadsheetDocument.class, createDocument( "scalc" ));
+ }
+
+ // ____________________
+
+ public XModel createPresentationDocument()
+ {
+ return createDocument( "simpress" );
+ }
+
+ // ____________________
+
+ public XModel createDrawingDocument()
+ {
+ return createDocument( "sdraw" );
+ }
+
+ // ____________________
+
+ public XModel createTextDocument()
+ {
+ return createDocument( "swriter" );
+ }
+
+ // ____________________
+
+ public XModel createDocument( String sDocType )
+ {
+ XModel aResult = null;
+ try
+ {
+ XComponentLoader aLoader = (XComponentLoader)
+ UnoRuntime.queryInterface(XComponentLoader.class,
+ maMCFactory.createInstanceWithContext("com.sun.star.frame.Desktop",
+ maContext) );
+
+ aResult = (XModel) 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 final String msDataSheetName = "Data";
+ private final String msChartSheetName = "Chart";
+ private final String msChartName = "SampleChart";
+
+ private XComponentContext maContext;
+ private XMultiComponentFactory maMCFactory;
+ private XSpreadsheetDocument maSpreadSheetDoc;
+}
diff --git a/odk/examples/DevelopersGuide/Charts/JavaSampleChartAddIn.java b/odk/examples/DevelopersGuide/Charts/JavaSampleChartAddIn.java
new file mode 100644
index 000000000000..10a137a316d5
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Charts/JavaSampleChartAddIn.java
@@ -0,0 +1,476 @@
+/*************************************************************************
+ *
+ * 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.
+ *
+ *************************************************************************/
+
+// base classes
+import com.sun.star.uno.XInterface;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.Type;
+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.Rectangle;
+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;
+import com.sun.star.lang.XTypeProvider;
+
+// 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
+{
+ public JavaSampleChartAddIn()
+ {}
+
+ // __________ interface methods __________
+
+ // XInitialization
+ public void initialize( Object[] aArguments )
+ throws Exception, RuntimeException
+ {
+ if( aArguments.length > 0 )
+ {
+ maChartDocument = (XChartDocument) UnoRuntime.queryInterface(
+ XChartDocument.class, aArguments[ 0 ]);
+
+ XPropertySet aDocProp = (XPropertySet) 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 = (XDrawPageSupplier) UnoRuntime.queryInterface(
+ XDrawPageSupplier.class, maChartDocument );
+ if( aPageSupp != null )
+ maDrawPage = (XDrawPage) UnoRuntime.queryInterface(
+ XDrawPage.class, aPageSupp.getDrawPage() );
+
+ // get a factory for creating shapes
+ maShapeFactory = (XMultiServiceFactory) 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 = (XPropertySet) UnoRuntime.queryInterface(
+ XPropertySet.class, maChartDocument );
+ if( aDocProp != null )
+ {
+ try
+ {
+ XIndexAccess aShapesIA = (XIndexAccess) 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 = (XShape) UnoRuntime.queryInterface(
+ XShape.class, aShapesIA.getByIndex( i ));
+ if( aShape != null )
+ {
+ XPropertySet aProp = (XPropertySet) 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 = (XShape) UnoRuntime.queryInterface(
+ XShape.class, maShapeFactory.createInstance( "com.sun.star.drawing.LineShape" ));
+ maDrawPage.add( maTopLine );
+
+ // make line red and thicker
+ XPropertySet aShapeProp = (XPropertySet) UnoRuntime.queryInterface(
+ XPropertySet.class, maTopLine );
+
+ aShapeProp.setPropertyValue( "LineColor", new Integer( 0xe01010 ));
+ aShapeProp.setPropertyValue( "LineWidth", new Integer( 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 = (XShape) UnoRuntime.queryInterface(
+ XShape.class, maShapeFactory.createInstance( "com.sun.star.drawing.LineShape" ));
+ maDrawPage.add( maBottomLine );
+
+ // make line green and thicker
+ XPropertySet aShapeProp = (XPropertySet) UnoRuntime.queryInterface(
+ XPropertySet.class, maBottomLine );
+
+ aShapeProp.setPropertyValue( "LineColor", new Integer( 0x10e010 ));
+ aShapeProp.setPropertyValue( "LineWidth", new Integer( 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 = (XChartDataArray) UnoRuntime.queryInterface(
+ XChartDataArray.class, maChartDocument.getData());
+ double aData[][] = aDataArray.getData();
+
+ // get axes
+ XDiagram aDiagram = maChartDocument.getDiagram();
+ XShape aXAxis = (XShape) UnoRuntime.queryInterface(
+ XShape.class, ((XAxisXSupplier) UnoRuntime.queryInterface(
+ XAxisXSupplier.class, aDiagram )).getXAxis() );
+ XShape aYAxis = (XShape) UnoRuntime.queryInterface(
+ XShape.class, ((XAxisYSupplier) 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 = (XPropertySet) UnoRuntime.queryInterface(
+ XPropertySet.class, maTopLine );
+ aShapeProp.setPropertyValue( "PolyPolygon", aMaxPtSeq );
+
+ aShapeProp = (XPropertySet) 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 new String( 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 new String( 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 ((XShape) UnoRuntime.queryInterface( XShape.class, maChartDocument.getDiagram())).getSize();
+ }
+ public void setSize( Size aSize ) throws RuntimeException, PropertyVetoException
+ {
+ ((XShape) UnoRuntime.queryInterface( XShape.class, maChartDocument.getDiagram())).setSize( aSize );
+ }
+
+ public Point getPosition() throws RuntimeException
+ {
+ return ((XShape) UnoRuntime.queryInterface( XShape.class, maChartDocument.getDiagram())).getPosition();
+ }
+ public void setPosition( Point aPos ) throws RuntimeException
+ {
+ ((XShape) UnoRuntime.queryInterface( XShape.class, maChartDocument.getDiagram())).setPosition( aPos );
+ }
+
+ // XShapeDescriptor : XShape : XDiagram
+ public String getShapeType() throws RuntimeException
+ {
+ return new String( "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 = (XPropertySet) 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)((double)(aAxis.getSize().Height) *
+ (1.0 - (( fValue - fMin ) / fRange )));
+ }
+ else
+ {
+ nResult = aAxis.getPosition().X +
+ (int)((double)(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;
+ }
+
+ /**
+ * Writes the service information into the given registry key.
+ * This method is called by the <code>JavaLoader</code>
+ * <p>
+ * @return returns true if the operation succeeded
+ * @param regKey the registryKey
+ * @see com.sun.star.comp.loader.JavaLoader
+ */
+ public static boolean __writeRegistryServiceInfo( com.sun.star.registry.XRegistryKey regKey )
+ {
+ boolean bResult = true;
+
+ String[] aServices = getSupportedServiceNames_Static();
+ int i, nLength = aServices.length;
+
+ for( i = 0; i < nLength; ++i )
+ {
+ bResult = bResult && com.sun.star.comp.loader.FactoryHelper.writeRegistryServiceInfo(
+ JavaSampleChartAddIn.class.getName(), aServices[ i ], regKey );
+ }
+ return bResult;
+ }
+}
diff --git a/odk/examples/DevelopersGuide/Charts/ListenAtCalcRangeInDraw.java b/odk/examples/DevelopersGuide/Charts/ListenAtCalcRangeInDraw.java
new file mode 100644
index 000000000000..9c37b4d19954
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Charts/ListenAtCalcRangeInDraw.java
@@ -0,0 +1,211 @@
+/*************************************************************************
+ *
+ * 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 classes
+import com.sun.star.uno.XInterface;
+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.XSpreadsheetDocument;
+
+import com.sun.star.frame.XModel;
+import com.sun.star.frame.XController;
+
+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.Rectangle;
+import com.sun.star.awt.FontWeight;
+import com.sun.star.awt.FontRelief;
+
+// 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.
+ Create a presentation and add a chart.
+ Connect the chart to a calc range via a listener
+ @author Bj&ouml;rn Milcke
+ */
+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();
+ maDrawDoc = aHelper.createDrawingDocument();
+ CalcHelper aCalcHelper = new CalcHelper( maSheetDoc );
+ ChartHelper aChartHelper = new ChartHelper( maDrawDoc );
+
+ 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(
+ "ChartWithCalcData",
+ aPos,
+ aExtent,
+ "com.sun.star.chart.XYDiagram" );
+
+ // attach the data coming from the cell range to the chart
+ maChartData = (XChartData) UnoRuntime.queryInterface( XChartData.class, aRange );
+ maChartDocument.attachData( maChartData );
+ }
+
+ // ____________________
+
+ public void run()
+ {
+ try
+ {
+ ((XPropertySet) UnoRuntime.queryInterface(
+ XPropertySet.class, maChartDocument )).setPropertyValue(
+ "HasSubTitle", new Boolean( true ));
+
+ // start listening for death of spreadsheet
+ ((XComponent) UnoRuntime.queryInterface(
+ XComponent.class, maSheetDoc )).addEventListener( this );
+
+ // start listening for death of chart
+ ((XComponent) 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
+ ((XComponent) UnoRuntime.queryInterface(
+ XComponent.class, maSheetDoc )).removeEventListener( this );
+ ((XComponent) UnoRuntime.queryInterface(
+ XComponent.class, maChartDocument )).removeEventListener( this );
+
+ System.exit( 0 );
+ }
+
+ // ____________________
+
+ // XChartDataChangeEventListener
+ public void chartDataChanged( ChartDataChangeEvent aEvent )
+ {
+ // update subtitle
+ String aTitle = new String( "Last Update: " + new java.util.Date( System.currentTimeMillis() ));
+
+ try
+ {
+ XPropertySet aDocProp = (XPropertySet) UnoRuntime.queryInterface(
+ XPropertySet.class, maChartDocument );
+ aDocProp.setPropertyValue( "HasMainTitle", new Boolean( true ));
+
+ ((XPropertySet) 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 XSpreadsheetDocument maSheetDoc;
+ private XModel maDrawDoc;
+ private XChartDocument maChartDocument;
+ private XChartData maChartData;
+}
diff --git a/odk/examples/DevelopersGuide/Charts/Makefile b/odk/examples/DevelopersGuide/Charts/Makefile
new file mode 100644
index 000000000000..f35f8fcbb9f7
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Charts/Makefile
@@ -0,0 +1,198 @@
+#*************************************************************************
+#
+# 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
+include $(SETTINGS)/dk.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
+
+COMPONENT_NAME=JavaSampleChartAddIn
+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 = $(SAMPLE_CLASS_OUT)/$(COMPONENT_JAR_NAME)
+COMPONENT_MANIFESTFILE = $(SAMPLE_CLASS_OUT)/$(COMPONENT_NAME).uno.Manifest
+COMPONENT_UNOPKG_MANIFEST = $(SAMPLE_CLASS_OUT)/$(COMPONENT_NAME)/META-INF/manifest.xml
+COMP_REGISTERFLAG = $(SAMPLE_GEN_OUT)/devguide_$(COMPONENT_NAME)_register_component.flag
+
+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))
+
+$(COMPONENT_NAME)_CLASSFILES = $(COMPONENT_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
+$(COMPONENT_JAR) : $(COMPONENT_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-component;type=Java$(QM)" >> $@
+ @echo $(SQM) $(SQM)manifest:full-path="$(QM)$(subst /META-INF,,$(subst $(SAMPLE_CLASS_OUT)/,,$(@D))).uno.jar$(QM)"/$(CSEP) >> $@
+ @echo $(OSEP)/manifest:manifest$(CSEP) >> $@
+
+# rule for component pacakge file
+$(COMPONENT_PACKAGE) : $(COMPONENT_JAR) $(COMPONENT_UNOPKG_MANIFEST)
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ cd $(subst /,$(PS),$(SAMPLE_CLASS_OUT)) && $(SDK_ZIP) ../../bin/$(@F) $(<F)
+ cd $(subst /,$(PS),$(SAMPLE_CLASS_OUT)/$(subst .$(UNOOXT_EXT),,$(@F))) && $(SDK_ZIP) ../../../bin/$(@F) -u META-INF/manifest.xml
+
+$(COMP_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
+
+$(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),$(COMPONENT_PACKAGE_URL)))
diff --git a/odk/examples/DevelopersGuide/Charts/SelectionChangeListener.java b/odk/examples/DevelopersGuide/Charts/SelectionChangeListener.java
new file mode 100644
index 000000000000..3a90b2d63313
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Charts/SelectionChangeListener.java
@@ -0,0 +1,219 @@
+/*************************************************************************
+ *
+ * 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.Rectangle;
+import com.sun.star.awt.Size;
+import com.sun.star.awt.XMessageBoxFactory;
+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.
+ *
+ * @author Bj&ouml;rn Milcke
+ */
+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 = ((XCellRangeAddressable) 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 = (XSelectionSupplier) UnoRuntime.queryInterface(
+ XSelectionSupplier.class,
+ (((XModel) 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 = (XComponent) UnoRuntime.queryInterface( XComponent.class, aSelSupp );
+ if( aComp != null ) {
+ aComp.addEventListener( this );
+ System.out.println( "Successfully attached as dispose listener" );
+ }
+
+ try {
+ Thread.currentThread().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 = (XSelectionSupplier) UnoRuntime.queryInterface(
+ XSelectionSupplier.class, aSourceObj );
+ if( aCtrl != null )
+ aCtrl.removeSelectionChangeListener( this );
+
+ // remove as dispose listener
+ XComponent aComp = (XComponent) UnoRuntime.queryInterface( XComponent.class, aSourceObj );
+ if( aComp != null )
+ aComp.removeEventListener( this );
+
+ // bail out
+ System.exit( 0 );
+ }
+
+ // ____________________
+
+ // XSelectionChangeListener
+ public void selectionChanged( EventObject aEvent ) {
+ XController aCtrl = (XController) 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 XMultiComponentFactory mMCF;
+
+ public MyMessageBox(XMultiComponentFactory xMCF){
+ mMCF = xMCF;
+ }
+
+ 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 = (XDesktop) UnoRuntime.queryInterface(XDesktop.class, oDesktop);
+ aToolKit = (XInterface) UnoRuntime.queryInterface(XInterface.class, oToolKit);
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ }
+
+ XWindow xWin = aDesktop.getCurrentFrame().getContainerWindow();
+ XWindowPeer aWinPeer = (XWindowPeer) UnoRuntime.queryInterface(XWindowPeer.class, xWin);
+
+ Rectangle aRect = new Rectangle();
+ int button = com.sun.star.awt.MessageBoxButtons.BUTTONS_OK;
+ XMessageBoxFactory aMBF = (XMessageBoxFactory) UnoRuntime.queryInterface(XMessageBoxFactory.class, aToolKit);
+ XMessageBox xMB = aMBF.createMessageBox(aWinPeer, aRect, "infobox" , button, "Event-Notify", "Listener was called, selcetion has changed");
+ xMB.execute();
+ }
+ }
+
+ private XChartDocument maChartDocument;
+ private XComponentContext maContext;
+}
diff --git a/odk/examples/DevelopersGuide/Charts/bullet.gif b/odk/examples/DevelopersGuide/Charts/bullet.gif
new file mode 100644
index 000000000000..0f8efd140b98
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Charts/bullet.gif
Binary files differ
diff --git a/odk/examples/DevelopersGuide/Charts/makefile.mk b/odk/examples/DevelopersGuide/Charts/makefile.mk
new file mode 100644
index 000000000000..225d8d7e111e
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Charts/makefile.mk
@@ -0,0 +1,75 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ=..$/..$/..
+PRJNAME=odk
+TARGET=copying
+
+#----------------------------------------------------------------
+.INCLUDE: settings.mk
+.INCLUDE: $(PRJ)$/util$/makefile.pmk
+#----------------------------------------------------------------
+
+#----------------------------------------------------
+# this makefile is only used for copying the example
+# files into the SDK
+#----------------------------------------------------
+
+CHARTS_FILES=\
+ $(DESTDIRDEVGUIDEEXAMPLES)$/Charts$/AddInChart.ods \
+ $(DESTDIRDEVGUIDEEXAMPLES)$/Charts$/CalcHelper.java \
+ $(DESTDIRDEVGUIDEEXAMPLES)$/Charts$/ChartHelper.java \
+ $(DESTDIRDEVGUIDEEXAMPLES)$/Charts$/ChartInCalc.java \
+ $(DESTDIRDEVGUIDEEXAMPLES)$/Charts$/ChartInDraw.java \
+ $(DESTDIRDEVGUIDEEXAMPLES)$/Charts$/ChartInWriter.java \
+ $(DESTDIRDEVGUIDEEXAMPLES)$/Charts$/Helper.java \
+ $(DESTDIRDEVGUIDEEXAMPLES)$/Charts$/JavaSampleChartAddIn.java \
+ $(DESTDIRDEVGUIDEEXAMPLES)$/Charts$/ListenAtCalcRangeInDraw.java \
+ $(DESTDIRDEVGUIDEEXAMPLES)$/Charts$/SelectionChangeListener.java \
+ $(DESTDIRDEVGUIDEEXAMPLES)$/Charts$/bullet.gif \
+ $(DESTDIRDEVGUIDEEXAMPLES)$/Charts$/Makefile
+
+DIR_FILE_LIST= \
+ $(CHARTS_FILES)
+
+DIR_DIRECTORY_LIST=$(uniq $(DIR_FILE_LIST:d))
+DIR_CREATE_FLAG=$(MISC)$/devguide_charts_dirs_created.txt
+DIR_FILE_FLAG=$(MISC)$/devguide_charts.txt
+
+#--------------------------------------------------
+# TARGETS
+#--------------------------------------------------
+all : \
+ $(DIR_FILE_LIST) \
+ $(DIR_FILE_FLAG)
+
+#--------------------------------------------------
+# use global rules
+#--------------------------------------------------
+.INCLUDE: $(PRJ)$/util$/odk_rules.pmk
+
+
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 000000000000..d3d8d7411ed2
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Components/Addons/JobsAddon/Addons.xcu
@@ -0,0 +1,81 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<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="ImageIdentifier" oor:type="xs:string">
+ <value>private:image/3216</value>
+
+ </prop>
+
+ <prop oor:name="Title" oor:type="xs:string">
+ <!-- The x-no-translate entry is a marker to prevent l10n tooling from translation. It 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="ImageIdentifier" oor:type="xs:string">
+ <value>private:image/3216</value>
+
+ </prop>
+
+ <prop oor:name="Title" oor:type="xs:string">
+ <!-- The x-no-translate entry is a marker to prevent l10n tooling from translation. It 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="ImageIdentifier" oor:type="xs:string">
+ <value>private:image/3216</value>
+
+ </prop>
+
+ <prop oor:name="Title" oor:type="xs:string">
+ <!-- The x-no-translate entry is a marker to prevent l10n tooling from translation. It 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.java b/odk/examples/DevelopersGuide/Components/Addons/JobsAddon/AsyncJob.java
new file mode 100644
index 000000000000..14c2659e48a7
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Components/Addons/JobsAddon/AsyncJob.java
@@ -0,0 +1,426 @@
+/*************************************************************************
+ *
+ * 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.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.awt.*;
+import com.sun.star.beans.*;
+import com.sun.star.task.*;
+import com.sun.star.uno.*;
+import java.lang.*;
+import javax.swing.*;
+
+//_______________________________________________
+// implementation
+
+/** 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
+{
+ //___________________________________________
+ // const
+ public final XComponentContext m_xCmpCtx;
+
+ /** the const list of supported uno service names. */
+ public static final java.lang.String[] SERVICENAMES = {"com.sun.star.task.AsyncJob"};
+
+ /** the const uno implementation name.
+ * It must be an unique value! The best naming schema seams to use
+ * a registered domain in reverse order ...
+ */
+ public static final java.lang.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 informations</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 seams 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 guranteed normaly ...
+ 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 guarenteed one!
+ if (lEnvironment == null)
+ throw new com.sun.star.lang.IllegalArgumentException("no environment");
+
+ java.lang.String sEnvType = null;
+ java.lang.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"))
+ )
+ )
+ {
+ java.lang.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.
+ java.lang.String sAlias = null;
+ if (lGenericConfig!=null)
+ {
+ c = lGenericConfig.length;
+ for (int i=0; i<c; ++i)
+ {
+ if (lGenericConfig[i].Name.equals("Alias"))
+ sAlias = com.sun.star.uno.AnyConverter.toString(lGenericConfig[i].Value);
+ }
+ }
+
+ // do your job ...
+ // Here we print out all found arguments.
+ java.lang.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 usefull 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 usefull 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 it's 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
+ * inclused the message body, which is shown as info.
+ */
+
+ private void showInfoModal( com.sun.star.awt.XWindow xParent ,
+ java.lang.String sTitle ,
+ java.lang.String sMessage )
+ {
+ try
+ {
+ // get access to the office toolkit environment
+ com.sun.star.awt.XToolkit xKit = (com.sun.star.awt.XToolkit)UnoRuntime.queryInterface(
+ com.sun.star.awt.XToolkit.class,
+ m_xCmpCtx.getServiceManager().createInstanceWithContext("com.sun.star.awt.Toolkit",
+ m_xCmpCtx));
+
+ // describe the info box ini it's 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 = (com.sun.star.awt.XWindowPeer)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 = (com.sun.star.awt.XMessageBox)UnoRuntime.queryInterface(
+ com.sun.star.awt.XMessageBox.class,
+ xPeer);
+ if (xInfoBox == null)
+ return;
+
+ // fill it with all given informations and show it
+ xInfoBox.setCaptionText(sTitle);
+ xInfoBox.setMessageText(sMessage);
+ xInfoBox.execute();
+ }
+ catch(java.lang.Throwable exIgnore)
+ {
+ // ignore any problem, which can occure here.
+ // It's not realy a bug for this example job, if
+ // it's message could not be printed out!
+ }
+ }
+
+ //___________________________________________
+
+ private void showInfoNonModal( java.lang.String sTitle ,
+ java.lang.String sMessage )
+ {
+ // Couldnt be implemented realy 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.
+ javax.swing.JOptionPane.showMessageDialog(null, sMessage, sTitle, javax.swing.JOptionPane.INFORMATION_MESSAGE);
+ }
+
+ //___________________________________________
+
+ /** helper to print out the given argument list.
+ *
+ * @param lGenericConfig
+ * contains all shared configuration items for a job
+ *
+ * @param lJobConfig
+ * contains all job sepcific configuration items
+ *
+ * @param lEnvironment
+ * contains some environment informations
+ *
+ * @param lDynamicData
+ * contains optional data of a might corresponding dispatch() request
+ */
+
+ private java.lang.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 )
+ {
+ java.lang.StringBuffer sOut = new java.lang.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(java.lang.String sImplName)
+ {
+ com.sun.star.lang.XSingleComponentFactory xFactory = null;
+ if (sImplName.equals(AsyncJob.IMPLEMENTATIONNAME))
+ xFactory = Factory.createComponentFactory(AsyncJob.class, SERVICENAMES);
+
+ return xFactory;
+ }
+
+ //___________________________________________
+
+ public synchronized static boolean __writeRegistryServiceInfo(com.sun.star.registry.XRegistryKey xRegKey)
+ {
+ return Factory.writeRegistryServiceInfo(
+ AsyncJob.IMPLEMENTATIONNAME,
+ AsyncJob.SERVICENAMES,
+ xRegKey);
+ }
+}
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 000000000000..f33c68e5a3da
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Components/Addons/JobsAddon/Jobs.xcu
@@ -0,0 +1,27 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<oor:component-data oor:name="Jobs" oor:package="org.openoffice.Office" xmlns:oor="http://openoffice.org/2001/registry" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <node oor:name="Jobs">
+ <node oor:name="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: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 000000000000..8b40d9ec87ff
--- /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
+include $(SETTINGS)/dk.mk
+
+# Define non-platform/compiler specific settings
+COMPONENT_NAME=AsyncJob
+OUT_COMP_CLASS=$(OUT_CLASS)/$(COMPONENT_NAME)
+OUT_COMP_MISC=$(OUT_MISC)/$(COMPONENT_NAME)
+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_COMP_MISC)$(PS)java_$(COMPONENT_NAME)_register_component.flag
+
+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
+$(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.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-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) Addons.xcu Jobs.xcu $(COMPONENT_UNOPKG_MANIFEST)
+ -$(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
+ 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
+
+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),$(COMPONENT_PACKAGE_URL)))
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$(COMPONENT_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 000000000000..579bcd3eef58
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Components/Addons/ProtocolHandlerAddon_cpp/Addons.xcu
@@ -0,0 +1,220 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<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="ImageIdentifier" oor:type="xs:string">
+ <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="ImageIdentifier" oor:type="xs:string">
+ <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>
+ <prop oor:name="Target" oor:type="xs:string">
+ <value>_self</value>
+ </prop>
+ <prop oor:name="ImageIdentifier" oor:type="xs:string">
+ <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="ImageIdentifier" oor:type="xs:string">
+ <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="ImageIdentifier" 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="ImageIdentifier" oor:type="xs:string">
+ <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="ImageIdentifier" oor:type="xs:string">
+ <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="ImageIdentifier" oor:type="xs:string">
+ <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="ImageIdentifier" oor:type="xs:string">
+ <value/>
+ </prop>
+ <prop oor:name="Title" oor:type="xs:string">
+ <!-- The x-no-translate entry is a marker to prevent l10n tooling from translation. It 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 000000000000..c5429565e406
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Components/Addons/ProtocolHandlerAddon_cpp/Makefile
@@ -0,0 +1,148 @@
+#*************************************************************************
+#
+# 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
+include $(SETTINGS)/dk.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_MAPFILE = $(OUT_COMP_GEN)/$(COMP_NAME).uno.map
+
+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),$@) $<
+
+$(COMP_MAPFILE) : $(SLOFILES)
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ cat $(PRJ)/settings/component.uno.map > $(COMP_MAPFILE)
+ifeq "$(OS)" "MACOSX"
+ nm -gx $(SLOFILES) | $(ADDSYMBOLS) >> $(COMP_MAPFILE)
+endif
+
+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) $(STLPORTLIB) msvcrt.lib kernel32.lib
+ $(LINK_MANIFEST)
+else
+$(SHAREDLIB_OUT)/%.$(SHAREDLIB_EXT) : $(SLOFILES) $(COMP_MAPFILE)
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ $(LINK) $(COMP_LINK_FLAGS) $(LINK_LIBS) -o $@ $(SLOFILES) \
+ $(CPPUHELPERLIB) $(CPPULIB) $(SALLIB) $(STLPORTLIB) $(STC++LIB) $(CPPUHELPERDYLIB) $(CPPUDYLIB) $(SALDYLIB)
+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-component;type=native;platform=$(UNOPKG_PLATFORM)$(QM)" >> $@
+ @echo $(SQM) $(SQM)manifest:full-path="$(QM)$(subst /META-INF,,$(subst $(OUT_COMP_GEN)/,,$(UNOPKG_PLATFORM)/$(@D))).uno.$(SHAREDLIB_EXT)$(QM)"/$(CSEP) >> $@
+ @echo $(OSEP)/manifest:manifest$(CSEP) >> $@
+
+# rule for component package file
+$(COMP_PACKAGE) : $(SHAREDLIB_OUT)/$(COMP_IMPL_NAME) Addons.xcu ProtocolHandler.xcu $(COMP_UNOPKG_MANIFEST)
+ -$(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) $(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),$(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 000000000000..c71e8c387306
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Components/Addons/ProtocolHandlerAddon_cpp/ProtocolHandler.xcu
@@ -0,0 +1,11 @@
+<?xml version='1.0' encoding='UTF-8'?>
+
+<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 000000000000..e2ec638cbc02
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Components/Addons/ProtocolHandlerAddon_cpp/addon.cxx
@@ -0,0 +1,250 @@
+/*************************************************************************
+ *
+ * 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 <osl/diagnose.h>
+#include <rtl/ustring.hxx>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#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/XToolkit.hpp>
+#include <com/sun/star/awt/XWindowPeer.hpp>
+#include <com/sun/star/awt/WindowAttribute.hpp>
+#include <com/sun/star/awt/XMessageBox.hpp>
+
+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::lang::XMultiServiceFactory;
+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 = OUString( RTL_CONSTASCII_USTRINGPARAM( "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 ) throw ( Exception, RuntimeException)
+{
+ Reference < XFrame > xFrame;
+ if ( aArguments.getLength() )
+ {
+ aArguments[0] >>= xFrame;
+ mxFrame = xFrame;
+ }
+
+ // Create the toolkit to have access to it later
+ mxToolkit = Reference< XToolkit >( mxMSF->createInstance(
+ OUString( RTL_CONSTASCII_USTRINGPARAM(
+ "com.sun.star.awt.Toolkit" ))), UNO_QUERY );
+}
+
+/**
+ * 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 )
+ throw( RuntimeException )
+{
+ Reference < XDispatch > xRet;
+ if ( aURL.Protocol.compareToAscii("org.openoffice.Office.addon.example:") == 0 )
+ {
+ if ( aURL.Path.compareToAscii( "Function1" ) == 0 )
+ xRet = this;
+ else if ( aURL.Path.compareToAscii( "Function2" ) == 0 )
+ xRet = this;
+ else if ( aURL.Path.compareToAscii( "Help" ) == 0 )
+ 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 ) throw (RuntimeException)
+{
+ if ( aURL.Protocol.compareToAscii("org.openoffice.Office.addon.example:") == 0 )
+ {
+ if ( aURL.Path.compareToAscii( "Function1" ) == 0 )
+ {
+ ShowMessageBox( mxToolkit, mxFrame,
+ OUString( RTL_CONSTASCII_USTRINGPARAM( "SDK Add-On example" )),
+ OUString( RTL_CONSTASCII_USTRINGPARAM( "Function 1 activated" )) );
+ }
+ else if ( aURL.Path.compareToAscii( "Function2" ) == 0 )
+ {
+ ShowMessageBox( mxToolkit, mxFrame,
+ OUString( RTL_CONSTASCII_USTRINGPARAM( "SDK Add-On example" )),
+ OUString( RTL_CONSTASCII_USTRINGPARAM( "Function 2 activated" )) );
+ }
+ else if ( aURL.Path.compareToAscii( "Help" ) == 0 )
+ {
+ // Show info box
+ ShowMessageBox( mxToolkit, mxFrame,
+ OUString( RTL_CONSTASCII_USTRINGPARAM( "About SDK Add-On example" )),
+ OUString( RTL_CONSTASCII_USTRINGPARAM( "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 )
+ throw( RuntimeException )
+{
+ 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 ) throw (RuntimeException)
+{
+}
+
+/**
+ * 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 ) throw (RuntimeException)
+{
+}
+
+//##################################################################################################
+//#### Helper functions for the implementation of UNO component interfaces #########################
+//##################################################################################################
+
+::rtl::OUString Addon_getImplementationName()
+throw (RuntimeException)
+{
+ return ::rtl::OUString ( RTL_CONSTASCII_USTRINGPARAM ( IMPLEMENTATION_NAME ) );
+}
+
+sal_Bool SAL_CALL Addon_supportsService( const ::rtl::OUString& ServiceName )
+throw (RuntimeException)
+{
+ return ServiceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM ( SERVICE_NAME ) );
+}
+
+Sequence< ::rtl::OUString > SAL_CALL Addon_getSupportedServiceNames()
+throw (RuntimeException)
+{
+ Sequence < ::rtl::OUString > aRet(1);
+ ::rtl::OUString* pArray = aRet.getArray();
+ pArray[0] = ::rtl::OUString ( RTL_CONSTASCII_USTRINGPARAM ( SERVICE_NAME ) );
+ return aRet;
+}
+
+Reference< XInterface > SAL_CALL Addon_createInstance( const Reference< XMultiServiceFactory > & rSMgr)
+ throw( Exception )
+{
+ return (cppu::OWeakObject*) new Addon( rSMgr );
+}
+
+//##################################################################################################
+//#### Implementation of the recommended/mandatory interfaces of a UNO component ###################
+//##################################################################################################
+
+// XServiceInfo
+::rtl::OUString SAL_CALL Addon::getImplementationName( )
+ throw (RuntimeException)
+{
+ return Addon_getImplementationName();
+}
+
+sal_Bool SAL_CALL Addon::supportsService( const ::rtl::OUString& rServiceName )
+ throw (RuntimeException)
+{
+ return Addon_supportsService( rServiceName );
+}
+
+Sequence< ::rtl::OUString > SAL_CALL Addon::getSupportedServiceNames( )
+ throw (RuntimeException)
+{
+ return Addon_getSupportedServiceNames();
+}
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 000000000000..c0b8dedd385a
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Components/Addons/ProtocolHandlerAddon_cpp/addon.hxx
@@ -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.
+ *
+ *************************************************************************/
+
+#ifndef _Addon_HXX
+#define _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;
+ }
+ }
+ }
+}
+
+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::lang::XMultiServiceFactory > mxMSF;
+ ::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::lang::XMultiServiceFactory > &rxMSF)
+ : mxMSF( rxMSF ) {}
+
+ // 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 )
+ throw( ::com::sun::star::uno::RuntimeException );
+ virtual ::com::sun::star::uno::Sequence < ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch > >
+ SAL_CALL queryDispatches(
+ const ::com::sun::star::uno::Sequence < ::com::sun::star::frame::DispatchDescriptor >& seqDescriptor )
+ throw( ::com::sun::star::uno::RuntimeException );
+
+ // 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 )
+ throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL addStatusListener( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XStatusListener >& xControl,
+ const ::com::sun::star::util::URL& aURL ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL removeStatusListener( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XStatusListener >& xControl,
+ const ::com::sun::star::util::URL& aURL ) throw (::com::sun::star::uno::RuntimeException);
+
+ // XInitialization
+ virtual void SAL_CALL initialize( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments )
+ throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
+
+ // XServiceInfo
+ virtual ::rtl::OUString SAL_CALL getImplementationName( )
+ throw (::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName )
+ throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( )
+ throw (::com::sun::star::uno::RuntimeException);
+};
+
+::rtl::OUString Addon_getImplementationName()
+ throw ( ::com::sun::star::uno::RuntimeException );
+
+sal_Bool SAL_CALL Addon_supportsService( const ::rtl::OUString& ServiceName )
+ throw ( ::com::sun::star::uno::RuntimeException );
+
+::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL Addon_getSupportedServiceNames( )
+ throw ( ::com::sun::star::uno::RuntimeException );
+
+::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >
+SAL_CALL Addon_createInstance( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & rSMgr)
+ throw ( ::com::sun::star::uno::Exception );
+
+#endif // _Addon_HXX
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 000000000000..724c4996f308
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Components/Addons/ProtocolHandlerAddon_cpp/component.cxx
@@ -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.
+ *
+ *************************************************************************/
+
+#include <stdio.h>
+#include <rtl/ustring.hxx>
+#include <cppuhelper/queryinterface.hxx> // helper for queryInterface() impl
+#include <cppuhelper/factory.hxx> // helper for component factory
+// generated c++ interfaces
+#include <com/sun/star/lang/XSingleServiceFactory.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/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;
+
+//##################################################################################################
+//#### EXPORTED ####################################################################################
+//##################################################################################################
+
+
+/**
+ * Gives the environment this component belongs to.
+ */
+extern "C" void SAL_CALL component_getImplementationEnvironment(const sal_Char ** ppEnvTypeName, uno_Environment ** ppEnv)
+{
+ *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
+}
+
+/**
+ * This function creates an implementation section in the registry and another subkey
+ *
+ * for each supported service.
+ * @param pServiceManager the service manager
+ * @param pRegistryKey the registry key
+ */
+extern "C" sal_Bool SAL_CALL component_writeInfo(void * pServiceManager, void * pRegistryKey)
+{
+ sal_Bool result = sal_False;
+
+ if (pRegistryKey)
+ {
+ try
+ {
+ Reference< XRegistryKey > xNewKey(
+ reinterpret_cast< XRegistryKey * >( pRegistryKey )->createKey(
+ OUString( RTL_CONSTASCII_USTRINGPARAM("/" IMPLEMENTATION_NAME "/UNO/SERVICES") ) ) );
+
+ const Sequence< OUString > & rSNL =
+ Addon_getSupportedServiceNames();
+ const OUString * pArray = rSNL.getConstArray();
+ for ( sal_Int32 nPos = rSNL.getLength(); nPos--; )
+ xNewKey->createKey( pArray[nPos] );
+
+ return sal_True;
+ }
+ catch (InvalidRegistryException &)
+ {
+ // we should not ignore exceptions
+ }
+ }
+ return result;
+}
+
+/**
+ * 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" void * SAL_CALL component_getFactory(const sal_Char * pImplName, void * pServiceManager, void * pRegistryKey)
+{
+ void * pRet = 0;
+
+ if (rtl_str_compare( pImplName, IMPLEMENTATION_NAME ) == 0)
+ {
+ Reference< XSingleServiceFactory > xFactory( createSingleFactory(
+ reinterpret_cast< XMultiServiceFactory * >( pServiceManager ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM( IMPLEMENTATION_NAME ) ),
+ Addon_createInstance,
+ Addon_getSupportedServiceNames() ) );
+
+ if (xFactory.is())
+ {
+ xFactory->acquire();
+ pRet = xFactory.get();
+ }
+ }
+
+ return pRet;
+}
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 000000000000..fb904e9ac452
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Components/Addons/ProtocolHandlerAddon_java/Addons.xcu
@@ -0,0 +1,220 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<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="ImageIdentifier" oor:type="xs:string">
+ <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="ImageIdentifier" oor:type="xs:string">
+ <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>
+ <prop oor:name="Target" oor:type="xs:string">
+ <value>_self</value>
+ </prop>
+ <prop oor:name="ImageIdentifier" oor:type="xs:string">
+ <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="ImageIdentifier" oor:type="xs:string">
+ <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="ImageIdentifier" 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="ImageIdentifier" oor:type="xs:string">
+ <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="ImageIdentifier" oor:type="xs:string">
+ <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="ImageIdentifier" oor:type="xs:string">
+ <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="ImageIdentifier" oor:type="xs:string">
+ <value/>
+ </prop>
+ <prop oor:name="Title" oor:type="xs:string">
+ <!-- The x-no-translate entry is a marker to prevent l10n tooling from translation. It 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 000000000000..ac6a0670a05a
--- /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 ProtoclHandlerAddon Java component example of the SDK.
+
+PRJ=../../../../..
+SETTINGS=$(PRJ)/settings
+
+include $(SETTINGS)/settings.mk
+include $(SETTINGS)/std.mk
+include $(SETTINGS)/dk.mk
+
+# Define non-platform/compiler specific settings
+COMPONENT_NAME=ProtocolHandlerAddon_java
+OUT_COMP_CLASS=$(OUT_CLASS)/$(COMPONENT_NAME)
+OUT_COMP_MISC=$(OUT_MISC)/$(COMPONENT_NAME)
+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_COMP_MISC)$(PS)java_$(COMPONENT_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
+$(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.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-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) Addons.xcu ProtocolHandler.xcu $(COMPONENT_UNOPKG_MANIFEST)
+ -$(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
+ 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
+
+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),$(COMPONENT_PACKAGE_URL)))
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$(COMPONENT_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 000000000000..27444dd1c5e0
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Components/Addons/ProtocolHandlerAddon_java/ProtocolHandler.xcu
@@ -0,0 +1,10 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<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 000000000000..ad3b0efe8747
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Components/Addons/ProtocolHandlerAddon_java/ProtocolHandlerAddon.java
@@ -0,0 +1,283 @@
+/*************************************************************************
+ *
+ * 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.registry.XRegistryKey;
+import com.sun.star.lang.XInitialization;
+import com.sun.star.lang.XTypeProvider;
+import com.sun.star.lang.XServiceInfo;
+import com.sun.star.uno.Type;
+import com.sun.star.frame.XStatusListener;
+import com.sun.star.frame.XDispatchProvider;
+import com.sun.star.frame.XDispatch;
+import com.sun.star.frame.XModel;
+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.
+ */
+ static private final String[] m_serviceNames = { "com.sun.star.frame.ProtocolHandler" };
+
+ /** The component context, that gives access to the service manager and all registered services.
+ */
+ private 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;
+ private XStatusListener m_xStatusListener;
+
+
+ /** The constructor of the inner class has a XMultiServiceFactory parameter.
+ * @param xmultiservicefactoryInitialization 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 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 = ( XFrame ) UnoRuntime.queryInterface(
+ XFrame.class, object[ 0 ] );
+ }
+
+ // Create the toolkit to have access to it later
+ m_xToolkit = (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.
+ * @param stringService Service name.
+ * @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.compareTo("org.openoffice.Office.addon.example:") == 0 ) {
+ if ( aURL.Path.compareTo( "Function1" ) == 0 )
+ xRet = this;
+ if ( aURL.Path.compareTo( "Function2" ) == 0 )
+ xRet = this;
+ if ( aURL.Path.compareTo( "Help" ) == 0 )
+ 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.compareTo("org.openoffice.Office.addon.example:") == 0 )
+ {
+ if ( aURL.Path.compareTo( "Function1" ) == 0 )
+ {
+ showMessageBox("SDK DevGuide Add-On example", "Function 1 activated");
+ }
+ if ( aURL.Path.compareTo( "Function2" ) == 0 )
+ {
+ showMessageBox("SDK DevGuide Add-On example", "Function 2 activated");
+ }
+ if ( aURL.Path.compareTo( "Help" ) == 0 )
+ {
+ 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) {
+ try {
+ if ( null != m_xFrame && null != m_xToolkit ) {
+
+ // describe window properties.
+ WindowDescriptor aDescriptor = new WindowDescriptor();
+ aDescriptor.Type = WindowClass.MODALTOP;
+ aDescriptor.WindowServiceName = new String( "infobox" );
+ aDescriptor.ParentIndex = -1;
+ aDescriptor.Parent = (XWindowPeer)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 = (XMessageBox)UnoRuntime.queryInterface(
+ XMessageBox.class, xPeer);
+ if ( null != xMsgBox )
+ {
+ xMsgBox.setCaptionText( sTitle );
+ xMsgBox.setMessageText( sMessage );
+ xMsgBox.execute();
+ }
+ }
+ }
+ } catch ( com.sun.star.uno.Exception e) {
+ // do your error handling
+ }
+ }
+ }
+
+
+ /** 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 stringImplementationName The implementation name of the component.
+ * @param xmultiservicefactory The service manager, who gives access to every
+ * known service.
+ * @param xregistrykey Makes structural information (except regarding tree
+ * structures) of a single
+ * registry key accessible.
+ */
+ public static XSingleComponentFactory __getComponentFactory( String sImplementationName ) {
+ XSingleComponentFactory xFactory = null;
+
+ if ( sImplementationName.equals( ProtocolHandlerAddonImpl.class.getName() ) )
+ xFactory = Factory.createComponentFactory(ProtocolHandlerAddonImpl.class,
+ ProtocolHandlerAddonImpl.getServiceNames());
+
+ return xFactory;
+ }
+
+ /** Writes the service information into the given registry key.
+ * This method is called by the <code>JavaLoader</code>.
+ * @return returns true if the operation succeeded
+ * @see com.sun.star.comp.loader.JavaLoader#
+ * @see com.sun.star.lib.uno.helper.Factory#
+ * @param xregistrykey Makes structural information (except regarding tree
+ * structures) of a single
+ * registry key accessible.
+ */
+ public static boolean __writeRegistryServiceInfo(
+ XRegistryKey xRegistryKey ) {
+ return Factory.writeRegistryServiceInfo(
+ ProtocolHandlerAddonImpl.class.getName(),
+ ProtocolHandlerAddonImpl.getServiceNames(),
+ xRegistryKey );
+ }
+}
diff --git a/odk/examples/DevelopersGuide/Components/CppComponent/Makefile b/odk/examples/DevelopersGuide/Components/CppComponent/Makefile
new file mode 100644
index 000000000000..0a4e7eee4cae
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Components/CppComponent/Makefile
@@ -0,0 +1,220 @@
+#*************************************************************************
+#
+# 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
+include $(SETTINGS)/dk.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_MAPFILE = $(SAMPLE_GEN_OUT)/$(COMP_NAME).uno.map
+
+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))
+
+GENURDFILES = $(patsubst %.idl,$(SAMPLE_GEN_OUT)/%.urd,$(IDLFILES))
+
+TYPELIST=-Tmy_module.XSomething \
+ -Tmy_modules.MyService1 \
+ -Tmy_module.MyService2
+
+# Targets
+.PHONY: ALL
+ALL : \
+ $(SAMPLE_NAME)
+
+include $(SETTINGS)/stdtarget.mk
+
+$(SAMPLE_GEN_OUT)/%.urd : %.idl
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ $(IDLC) -I. -I$(IDL_DIR) -O$(SAMPLE_GEN_OUT) $<
+
+$(SAMPLE_GEN_OUT)/%.rdb : $(GENURDFILES)
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ $(REGMERGE) $@ /UCR $(GENURDFILES)
+
+$(COMP_TYPEFLAG) : $(COMP_RDB) $(SDKTYPEFLAG)
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ $(CPPUMAKER) -Gc -BUCR -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),$@) $<
+
+$(COMP_MAPFILE) : $(SLOFILES)
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ cat $(PRJ)/settings/component.uno.map > $(COMP_MAPFILE)
+ifeq "$(OS)" "MACOSX"
+ nm -gx $(SLOFILES) | $(ADDSYMBOLS) >> $(COMP_MAPFILE)
+endif
+
+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) $(STLPORTLIB) msvcrt.lib kernel32.lib
+ $(LINK_MANIFEST)
+else
+$(SHAREDLIB_OUT)/%.$(SHAREDLIB_EXT) : $(SLOFILES) $(COMP_MAPFILE)
+ -$(MKDIR) $(subst /,$(PS),$(@D)) && $(DEL) $(subst \\,\,$(subst /,$(PS),$@))
+ $(LINK) $(COMP_LINK_FLAGS) $(LINK_LIBS) -o $@ $(SLOFILES) \
+ $(CPPUHELPERLIB) $(CPPULIB) $(SALLIB) $(STLPORTLIB) $(STC++LIB) $(CPPUHELPERDYLIB) $(CPPUDYLIB) $(SALDYLIB)
+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-component;type=native;platform=$(UNOPKG_PLATFORM)$(QM)" >> $@
+ @echo $(SQM) $(SQM)manifest:full-path="$(QM)$(subst /META-INF,,$(subst $(SAMPLE_GEN_OUT)/,,$(UNOPKG_PLATFORM)/$(@D))).uno.$(SHAREDLIB_EXT)$(QM)"/$(CSEP) >> $@
+ @echo $(OSEP)/manifest:manifest$(CSEP) >> $@
+
+$(COMP_PACKAGE) : $(SHAREDLIB_OUT)/$(COMP_IMPL_NAME) $(COMP_RDB) $(COMP_UNOPKG_MANIFEST)
+ -$(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_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) $(STLPORTLIB)
+else
+ $(LINK) $(EXE_LINK_FLAGS) $(LINK_LIBS) -o $@ $< \
+ $(CPPUHELPERLIB) $(CPPULIB) $(SALHELPERLIB) $(SALLIB) $(STLPORTLIB) $(STDC++LIB) $(CPPUHELPERDYLIB) $(CPPUDYLIB) $(SALHELPERDYLIB) $(SALDYLIB)
+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),$(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 000000000000..e8d7e9133284
--- /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 000000000000..93416f65c3e9
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Components/CppComponent/TestCppComponent.cxx
@@ -0,0 +1,89 @@
+/*************************************************************************
+ *
+ * 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 <my_module/MyService1.hpp>
+#include <my_module/MyService2.hpp>
+
+using namespace rtl;
+using namespace com::sun::star::uno;
+//namespace cssuno = ::com::sun::star::uno;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::frame;
+
+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<my_module::XSomething> xSomething =
+ my_module::MyService1::create(xContext);
+
+ // call methodOne and print the return value on stdout
+ OUString s = xSomething->methodOne(OUString(RTL_CONSTASCII_USTRINGPARAM("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 = my_module::MyService2::create(xContext, OUString(RTL_CONSTASCII_USTRINGPARAM("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;
+}
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 000000000000..a3c13216066d
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Components/CppComponent/service1_impl.cxx
@@ -0,0 +1,309 @@
+/*************************************************************************
+ *
+ * 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 <rtl/uuid.h>
+#include <cppuhelper/factory.hxx>
+
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/lang/XTypeProvider.hpp>
+#include <my_module/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] = OUString(RTL_CONSTASCII_USTRINGPARAM("my_module.MyService1"));
+ return names;
+}
+
+OUString SAL_CALL getImplementationName_MyService1Impl()
+{
+ return OUString( RTL_CONSTASCII_USTRINGPARAM(
+ "my_module.my_sc_implementation.MyService1") );
+}
+
+
+class MyService1Impl
+ : public ::my_module::XSomething
+ , public lang::XServiceInfo
+ , public lang::XTypeProvider
+{
+ oslInterlockedCount m_refcount;
+ OUString m_sData;
+ // it's good practise 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 )
+ throw (RuntimeException);
+ virtual void SAL_CALL acquire()
+ throw ();
+ virtual void SAL_CALL release()
+ throw ();
+ // XTypeProvider
+ virtual Sequence< Type > SAL_CALL getTypes()
+ throw (RuntimeException);
+ virtual Sequence< sal_Int8 > SAL_CALL getImplementationId()
+ throw (RuntimeException);
+ // XSomething
+ virtual OUString SAL_CALL methodOne( OUString const & str )
+ throw (RuntimeException);
+ virtual OUString SAL_CALL methodTwo( )
+ throw (RuntimeException);
+ // XServiceInfo
+ virtual OUString SAL_CALL getImplementationName()
+ throw (RuntimeException);
+ virtual sal_Bool SAL_CALL supportsService( OUString const & serviceName )
+ throw (RuntimeException);
+ virtual Sequence< OUString > SAL_CALL getSupportedServiceNames()
+ throw (RuntimeException);
+};
+
+// XInterface implementation
+Any MyService1Impl::queryInterface( Type const & type )
+ throw (RuntimeException)
+{
+ if (type.equals(::cppu::UnoType< Reference< 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< Reference< lang::XTypeProvider > >::get()))
+ {
+ // return XInterface interface
+ Reference< XInterface > x(
+ static_cast< lang::XTypeProvider * >( this ) );
+ return makeAny( x );
+ }
+ if (type.equals(::cppu::UnoType< Reference< lang::XServiceInfo > >::get()))
+ {
+ // return XServiceInfo interface
+ Reference< lang::XServiceInfo > x(
+ static_cast< lang::XServiceInfo * >( this ) );
+ return makeAny( x );
+ }
+ if (type.equals(::cppu::UnoType< Reference< ::my_module::XSomething > >::get()))
+ {
+ // return sample interface
+ Reference< ::my_module::XSomething > x(
+ static_cast< ::my_module::XSomething * >( this ) );
+ return makeAny( x );
+ }
+ // querying for unsupported type
+ return Any();
+}
+
+void MyService1Impl::acquire()
+ throw ()
+{
+ // thread-safe incrementation of reference count
+ ::osl_incrementInterlockedCount( &m_refcount );
+}
+
+void MyService1Impl::release()
+ throw ()
+{
+ // thread-safe decrementation of reference count
+ if (0 == ::osl_decrementInterlockedCount( &m_refcount ))
+ {
+ delete this; // shutdown this object
+ }
+}
+
+// XTypeProvider implementation
+Sequence< Type > MyService1Impl::getTypes()
+ throw (RuntimeException)
+{
+ Sequence< Type > seq( 3 );
+ seq[ 0 ] = ::cppu::UnoType< Reference< lang::XTypeProvider > >::get();
+ seq[ 1 ] = ::cppu::UnoType< Reference< lang::XServiceInfo > >::get();
+ seq[ 2 ] = ::cppu::UnoType< Reference< ::my_module::XSomething > >::get();
+ return seq;
+}
+Sequence< sal_Int8 > MyService1Impl::getImplementationId()
+ throw (RuntimeException)
+{
+ static Sequence< sal_Int8 > * s_pId = 0;
+ if (! s_pId)
+ {
+ // create unique id
+ Sequence< sal_Int8 > id( 16 );
+ ::rtl_createUuid( (sal_uInt8 *)id.getArray(), 0, sal_True );
+ // guard initialization with some mutex
+ ::osl::MutexGuard guard( ::osl::Mutex::getGlobalMutex() );
+ if (! s_pId)
+ {
+ static Sequence< sal_Int8 > s_id( id );
+ s_pId = &s_id;
+ }
+ }
+ return *s_pId;
+}
+
+// XSomething implementation
+OUString MyService1Impl::methodOne( OUString const & str )
+ throw (RuntimeException)
+{
+ m_sData = str;
+ return OUString( RTL_CONSTASCII_USTRINGPARAM(
+ "called methodOne() of MyService1 implementation: ") ) + m_sData;
+}
+
+OUString MyService1Impl::methodTwo( )
+ throw (RuntimeException)
+{
+ return OUString( RTL_CONSTASCII_USTRINGPARAM(
+ "called methodTwo() of MyService1 implementation: ") ) + m_sData;
+}
+
+// XServiceInfo implementation
+OUString MyService1Impl::getImplementationName()
+ throw (RuntimeException)
+{
+ // unique implementation name
+ return OUString( RTL_CONSTASCII_USTRINGPARAM(
+ "my_module.my_sc_implementation.MyService1") );
+}
+sal_Bool MyService1Impl::supportsService( OUString const & serviceName )
+ throw (RuntimeException)
+{
+ // this object only supports one service, so the test is simple
+ return serviceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM(
+ "my_module.MyService1") );
+}
+Sequence< OUString > MyService1Impl::getSupportedServiceNames()
+ throw (RuntimeException)
+{
+ // this object only supports one service
+ OUString serviceName( RTL_CONSTASCII_USTRINGPARAM("my_module.MyService1") );
+ return Sequence< OUString >( &serviceName, 1 );
+}
+
+Reference< XInterface > SAL_CALL create_MyService1Impl(
+ Reference< XComponentContext > const & xContext )
+ SAL_THROW( () )
+{
+ return static_cast< lang::XTypeProvider * >( new MyService1Impl( xContext) );
+}
+
+// forward decl: implemented in service2_impl.cxx
+Reference< XInterface > SAL_CALL create_MyService2Impl(
+ Reference< XComponentContext > const & ) SAL_THROW( () );
+
+}
+
+/*
+extern "C" void SAL_CALL component_getImplementationEnvironment(
+ sal_Char const ** ppEnvTypeName, uno_Environment ** )
+{
+ *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
+}
+
+extern "C" sal_Bool SAL_CALL component_writeInfo(
+ lang::XMultiServiceFactory * xMgr, registry::XRegistryKey * xRegistry )
+{
+ if (xRegistry)
+ {
+ try
+ {
+ // implementation of MyService1A
+ Reference< registry::XRegistryKey > xKey(
+ xRegistry->createKey( OUString( RTL_CONSTASCII_USTRINGPARAM(
+ "my_module.my_sc_implementation.MyService1/UNO/SERVICES") ) ) );
+ // subkeys denote implemented services of implementation
+ xKey->createKey( OUString( RTL_CONSTASCII_USTRINGPARAM(
+ "my_module.MyService1") ) );
+ // implementation of MyService1B
+ xKey = xRegistry->createKey( OUString( RTL_CONSTASCII_USTRINGPARAM(
+ "my_module.my_sc_implementation.MyService2/UNO/SERVICES") ) );
+ // subkeys denote implemented services of implementation
+ xKey->createKey( OUString( RTL_CONSTASCII_USTRINGPARAM(
+ "my_module.MyService2") ) );
+ return sal_True; // success
+ }
+ catch (registry::InvalidRegistryException &)
+ {
+ // function fails if exception caught
+ }
+ }
+ return sal_False;
+}
+extern "C" void * SAL_CALL component_getFactory(
+ sal_Char const * implName, lang::XMultiServiceFactory * xMgr, void * )
+{
+ Reference< lang::XSingleComponentFactory > xFactory;
+ if (0 == ::rtl_str_compare( implName, "my_module.my_sc_implementation.MyService1" ))
+ {
+ // create component factory for MyService1 implementation
+ OUString serviceName( RTL_CONSTASCII_USTRINGPARAM("my_module.MyService1") );
+ xFactory = ::cppu::createSingleComponentFactory(
+ ::my_sc_impl::create_MyService1Impl,
+ OUString( RTL_CONSTASCII_USTRINGPARAM("my_module.my_sc_implementation.MyService1") ),
+ Sequence< OUString >( &serviceName, 1 ) );
+ }
+ else if (0 == ::rtl_str_compare( implName, "my_module.my_sc_implementation.MyService2" ))
+ {
+ // create component factory for MyService12 implementation
+ OUString serviceName( RTL_CONSTASCII_USTRINGPARAM("my_module.MyService2") );
+ xFactory = ::cppu::createSingleComponentFactory(
+ ::my_sc_impl::create_MyService2Impl,
+ OUString( RTL_CONSTASCII_USTRINGPARAM("my_module.my_sc_implementation.MyService2") ),
+ Sequence< OUString >( &serviceName, 1 ) );
+ }
+ if (xFactory.is())
+ xFactory->acquire();
+ return xFactory.get(); // return acquired interface pointer or null
+}
+*/
+
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 000000000000..8589f8e88ab7
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Components/CppComponent/service2_impl.cxx
@@ -0,0 +1,225 @@
+/*************************************************************************
+ *
+ * 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> // "3" implementing three interfaces
+#include <cppuhelper/factory.hxx>
+#include <cppuhelper/implementationentry.hxx>
+
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/lang/XInitialization.hpp>
+#include <com/sun/star/lang/IllegalArgumentException.hpp>
+#include <my_module/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 )
+ SAL_THROW( () );
+
+static Sequence< OUString > getSupportedServiceNames_MyService2Impl()
+{
+ Sequence<OUString> names(1);
+ names[0] = OUString(RTL_CONSTASCII_USTRINGPARAM("my_module.MyService2"));
+ return names;
+}
+
+static OUString getImplementationName_MyService2Impl()
+{
+ return OUString( RTL_CONSTASCII_USTRINGPARAM(
+ "my_module.my_sc_implementation.MyService2") );
+}
+
+class MyService2Impl : public ::cppu::WeakImplHelper3<
+ ::my_module::XSomething, lang::XServiceInfo, lang::XInitialization >
+{
+ OUString m_sData;
+ // it's good practise 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 )
+ throw (Exception);
+ // XSomething
+ virtual OUString SAL_CALL methodOne( OUString const & str )
+ throw (RuntimeException);
+ virtual OUString SAL_CALL methodTwo( )
+ throw (RuntimeException);
+ // XServiceInfo
+ virtual OUString SAL_CALL getImplementationName()
+ throw (RuntimeException);
+ virtual sal_Bool SAL_CALL supportsService( OUString const & serviceName )
+ throw (RuntimeException);
+ virtual Sequence< OUString > SAL_CALL getSupportedServiceNames()
+ throw (RuntimeException);
+};
+
+// XInitialization implemention
+void MyService2Impl::initialize( Sequence< Any > const & args )
+ throw (Exception)
+{
+ if (args.getLength() != 1)
+ {
+ throw lang::IllegalArgumentException(
+ OUString( RTL_CONSTASCII_USTRINGPARAM(
+ "give a string instanciating this component!") ),
+ // resolve to XInterface reference:
+ static_cast< ::cppu::OWeakObject * >(this),
+ 0 ); // argument pos
+ }
+ if (! (args[ 0 ] >>= m_sData))
+ {
+ throw lang::IllegalArgumentException(
+ OUString( RTL_CONSTASCII_USTRINGPARAM(
+ "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 )
+ throw (RuntimeException)
+{
+ m_sData = str;
+ return OUString( RTL_CONSTASCII_USTRINGPARAM(
+ "called methodOne() of MyService2 implementation: ") ) + m_sData;
+}
+
+OUString MyService2Impl::methodTwo( )
+ throw (RuntimeException)
+{
+ return OUString( RTL_CONSTASCII_USTRINGPARAM(
+ "called methodTwo() of MyService2 implementation: ") ) + m_sData;
+}
+
+// XServiceInfo implementation
+OUString MyService2Impl::getImplementationName()
+ throw (RuntimeException)
+{
+ // unique implementation name
+ return OUString( RTL_CONSTASCII_USTRINGPARAM(
+ "my_module.my_sc_implementation.MyService2") );
+}
+
+sal_Bool MyService2Impl::supportsService( OUString const & serviceName )
+ throw (RuntimeException)
+{
+ // this object only supports one service, so the test is simple
+ return serviceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM(
+ "my_module.MyService2") );
+}
+
+Sequence< OUString > MyService2Impl::getSupportedServiceNames()
+ throw (RuntimeException)
+{
+ return getSupportedServiceNames_MyService2Impl();
+}
+
+Reference< XInterface > SAL_CALL create_MyService2Impl(
+ Reference< XComponentContext > const & xContext )
+ SAL_THROW( () )
+{
+ return static_cast< ::cppu::OWeakObject * >( new MyService2Impl( xContext ) );
+}
+
+}
+
+/* shared lib exports implemented without helpers in service_impl1.cxx */
+namespace my_sc_impl
+{
+static 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"
+{
+void SAL_CALL component_getImplementationEnvironment(
+ sal_Char const ** ppEnvTypeName, uno_Environment ** )
+{
+ *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
+}
+
+sal_Bool SAL_CALL component_writeInfo(
+ lang::XMultiServiceFactory * xMgr, registry::XRegistryKey * xRegistry )
+{
+ return ::cppu::component_writeInfoHelper(
+ xMgr, xRegistry, ::my_sc_impl::s_component_entries );
+}
+
+void * SAL_CALL component_getFactory(
+ sal_Char const * implName, lang::XMultiServiceFactory * xMgr,
+ registry::XRegistryKey * xRegistry )
+{
+ return ::cppu::component_getFactoryHelper(
+ implName, xMgr, xRegistry, ::my_sc_impl::s_component_entries );
+}
+
+}
+
+
diff --git a/odk/examples/DevelopersGuide/Components/CppComponent/some.idl b/odk/examples/DevelopersGuide/Components/CppComponent/some.idl
new file mode 100644
index 000000000000..342f03560a93
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Components/CppComponent/some.idl
@@ -0,0 +1,54 @@
+/*************************************************************************
+ *
+ * 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 my_module
+{
+
+ 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);
+ };
+};
diff --git a/odk/examples/DevelopersGuide/Components/JavaComponent/Makefile b/odk/examples/DevelopersGuide/Components/JavaComponent/Makefile
new file mode 100644
index 000000000000..55f8cbc12425
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Components/JavaComponent/Makefile
@@ -0,0 +1,204 @@
+#*************************************************************************
+#
+# 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 $(SETTINGS)/dk.mk
+
+# Define non-platform/compiler specific settings
+
+COMPONENT_NAME=JavaComponent
+OUT_COMP_CLASS = $(OUT_CLASS)/$(COMPONENT_NAME)
+OUT_COMP_GEN = $(OUT_MISC)/$(COMPONENT_NAME)
+COMPONENT_RDB_NAME = $(COMPONENT_NAME).uno.rdb
+COMPONENT_RDB = $(OUT_COMP_GEN)/$(COMPONENT_RDB_NAME)
+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_COMP_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
+APP1_NAME=TestJavaComponent
+APP1_JAR=$(OUT_COMP_CLASS)/$(APP1_NAME).jar
+
+REGISTERFLAG = $(OUT_MISC)$(PS)devguide_$(COMPONENT_NAME)_register_component.flag
+
+IDLFILES = XSomethingA.idl \
+ XSomethingB.idl \
+ SomethingA.idl \
+ SomethingB.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 = 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)))
+GENURDFILES = $(patsubst %.idl,$(OUT_COMP_GEN)/%.urd,$(IDLFILES))
+
+COMPCLASSFILES = $(patsubst %.java,$(OUT_COMP_CLASS)/%.class,$(COMPJAVAFILES))
+
+$(COMPONENT_NAME)_CLASSFILES = $(patsubst %.java,%.class,$(COMPJAVAFILES))
+
+$(COMPONENT_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)/%.urd : %.idl
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ $(IDLC) -I. -I$(IDL_DIR) -O$(OUT_COMP_GEN) $^
+
+$(OUT_COMP_GEN)/%.rdb : $(GENURDFILES)
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ $(REGMERGE) $@ /UCR $(GENURDFILES)
+
+$(OUT_COMP_CLASS)/$(PACKAGE)/%.class : $(COMPONENT_RDB)
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ $(JAVAMAKER) -BUCR -nD $(GENTYPELIST) -O$(OUT_COMP_CLASS) $(COMPONENT_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 $($(COMPONENT_NAME)_CLASSFILES)
+ +$(SDK_JAR) uvf $@ $(SDK_JAVA_UNO_BOOTSTRAP_FILES)
+
+# rule for component jar file
+$(COMPONENT_JAR) : $(COMPONENT_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-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 pacakge file
+$(COMPONENT_PACKAGE) : $(COMPONENT_RDB) $(COMPONENT_JAR) $(COMPONENT_UNOPKG_MANIFEST)
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ $(COPY) $(subst /,$(PS),$(COMPONENT_RDB)) $(subst /,$(PS),$(OUT_COMP_CLASS))
+ cd $(subst /,$(PS),$(OUT_COMP_CLASS)) && $(SDK_ZIP) ../../bin/$(@F) $(COMPONENT_RDB_NAME) $(COMPONENT_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)/$(COMPONENT_RDB_NAME)))
+
+$(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
+
+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),$(COMPONENT_PACKAGE_URL)))
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$(REGISTERFLAG)))
diff --git a/odk/examples/DevelopersGuide/Components/JavaComponent/SomethingA.idl b/odk/examples/DevelopersGuide/Components/JavaComponent/SomethingA.idl
new file mode 100644
index 000000000000..a98a3047dba6
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Components/JavaComponent/SomethingA.idl
@@ -0,0 +1,46 @@
+/*************************************************************************
+ *
+ * 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
+
+
diff --git a/odk/examples/DevelopersGuide/Components/JavaComponent/SomethingB.idl b/odk/examples/DevelopersGuide/Components/JavaComponent/SomethingB.idl
new file mode 100644
index 000000000000..0281ba751794
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Components/JavaComponent/SomethingB.idl
@@ -0,0 +1,46 @@
+/*************************************************************************
+ *
+ * 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
+
+
diff --git a/odk/examples/DevelopersGuide/Components/JavaComponent/TestComponentA.java b/odk/examples/DevelopersGuide/Components/JavaComponent/TestComponentA.java
new file mode 100644
index 000000000000..540328e2bff2
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Components/JavaComponent/TestComponentA.java
@@ -0,0 +1,71 @@
+/*************************************************************************
+ *
+ * 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.lib.uno.helper.WeakBase;
+import com.sun.star.lang.XServiceInfo;
+import com.sun.star.test.XSomethingA;
+import com.sun.star.uno.Type;
+
+// 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;
+
+ public TestComponentA() {
+ }
+
+ // 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;
+ }
+
+}
diff --git a/odk/examples/DevelopersGuide/Components/JavaComponent/TestComponentB.java b/odk/examples/DevelopersGuide/Components/JavaComponent/TestComponentB.java
new file mode 100644
index 000000000000..006cdceedb2c
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Components/JavaComponent/TestComponentB.java
@@ -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.
+ *
+ *************************************************************************/
+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 impelmentation WeakBase or
+// ComponentBase, see implementation of TestComponentA.
+public class TestComponentB implements XTypeProvider, XServiceInfo, XSomethingB {
+ static final String __serviceName= "com.sun.star.test.SomethingB";
+
+ static byte[] _implementationId;
+ private XComponentContext context;
+ private Object[] args;
+
+ public TestComponentB(XComponentContext context, Object[] args) {
+ this.context= context;
+ 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
+ synchronized public byte[] getImplementationId( ) {
+ if (_implementationId == null) {
+ _implementationId= new byte[16];
+ int hash = hashCode();
+ _implementationId[0] = (byte)(hash & 0xff);
+ _implementationId[1] = (byte)((hash >>> 8) & 0xff);
+ _implementationId[2] = (byte)((hash >>> 16) & 0xff);
+ _implementationId[3] = (byte)((hash >>>24) & 0xff);
+ }
+ return _implementationId;
+ }
+
+ //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;
+ }
+}
diff --git a/odk/examples/DevelopersGuide/Components/JavaComponent/TestJavaComponent.java b/odk/examples/DevelopersGuide/Components/JavaComponent/TestJavaComponent.java
new file mode 100644
index 000000000000..ab07ccc4564e
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Components/JavaComponent/TestJavaComponent.java
@@ -0,0 +1,143 @@
+/*************************************************************************
+ *
+ * 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.bridge.XUnoUrlResolver;
+import com.sun.star.test.XSomethingB;
+import com.sun.star.test.SomethingB;
+import com.sun.star.lang.XSingleComponentFactory;
+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 = (XSet ) UnoRuntime.queryInterface( XSet.class, serviceManager );
+ set.insert( singleFactory );
+ }
+
+ public static void removeFromServiceManager(
+ XMultiComponentFactory serviceManager, Object singleFactory )
+ throws com.sun.star.uno.Exception
+ {
+ XSet set = (XSet ) 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.out);
+ }
+
+ // quit, even when a remote bridge is running
+ System.exit(0);
+ }
+}
diff --git a/odk/examples/DevelopersGuide/Components/JavaComponent/TestServiceProvider.java b/odk/examples/DevelopersGuide/Components/JavaComponent/TestServiceProvider.java
new file mode 100644
index 000000000000..dee8899510e4
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Components/JavaComponent/TestServiceProvider.java
@@ -0,0 +1,71 @@
+/*************************************************************************
+ *
+ * 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.lang.XTypeProvider;
+import com.sun.star.lang.XServiceInfo;
+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;
+ }
+
+ public static boolean __writeRegistryServiceInfo(XRegistryKey regKey){
+ boolean bregA= FactoryHelper.writeRegistryServiceInfo(
+ TestComponentA.class.getName(),
+ TestComponentA.__serviceName, regKey);
+ boolean bregB= FactoryHelper.writeRegistryServiceInfo(
+ TestComponentB.class.getName(),
+ TestComponentB.__serviceName, regKey);
+ return bregA && bregB;
+ }
+}
+
+
diff --git a/odk/examples/DevelopersGuide/Components/JavaComponent/XSomethingA.idl b/odk/examples/DevelopersGuide/Components/JavaComponent/XSomethingA.idl
new file mode 100644
index 000000000000..f353cd3c7d98
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Components/JavaComponent/XSomethingA.idl
@@ -0,0 +1,48 @@
+/*************************************************************************
+ *
+ * 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
+
+
diff --git a/odk/examples/DevelopersGuide/Components/JavaComponent/XSomethingB.idl b/odk/examples/DevelopersGuide/Components/JavaComponent/XSomethingB.idl
new file mode 100644
index 000000000000..a06532c3ad48
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Components/JavaComponent/XSomethingB.idl
@@ -0,0 +1,48 @@
+/*************************************************************************
+ *
+ * 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
+
+
diff --git a/odk/examples/DevelopersGuide/Components/SimpleLicense/LicenseTest.idl b/odk/examples/DevelopersGuide/Components/SimpleLicense/LicenseTest.idl
new file mode 100644
index 000000000000..f93cb2279358
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Components/SimpleLicense/LicenseTest.idl
@@ -0,0 +1,50 @@
+/*************************************************************************
+ *
+ * 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
diff --git a/odk/examples/DevelopersGuide/Components/SimpleLicense/LicenseTest.java b/odk/examples/DevelopersGuide/Components/SimpleLicense/LicenseTest.java
new file mode 100644
index 000000000000..211638c46c58
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Components/SimpleLicense/LicenseTest.java
@@ -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.
+ *
+ *************************************************************************/
+
+import com.sun.star.lib.uno.helper.Factory;
+import com.sun.star.lang.XMultiComponentFactory;
+import com.sun.star.lang.XSingleComponentFactory;
+import com.sun.star.lib.uno.helper.WeakBase;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.XComponentContext;
+import com.sun.star.registry.XRegistryKey;
+import com.sun.star.lang.XInitialization;
+import com.sun.star.lang.XTypeProvider;
+import com.sun.star.lang.XServiceInfo;
+import com.sun.star.uno.Type;
+
+/** 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.
+ */
+ static private final String __serviceName =
+ "org.openoffice.LicenseTest";
+
+ /** The initial component contextr, that gives access to
+ * the service manager, supported singletons, ...
+ * It's often later used
+ */
+ private XComponentContext m_cmpCtx;
+
+ /** The service manager, that gives access to all registered services.
+ * It's often later used
+ */
+ private XMultiComponentFactory m_xMCF;
+
+ /** The constructor of the inner class has a XMultiServiceFactory parameter.
+ * @param xmultiservicefactoryInitialization A special service factory
+ * could be introduced while initializing.
+ */
+ public _LicenseTest(XComponentContext xCompContext) {
+ try {
+ m_cmpCtx = xCompContext;
+ m_xMCF = m_cmpCtx.getServiceManager();
+ }
+ catch( Exception e ) {
+ e.printStackTrace();
+ }
+ }
+
+ /** 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;
+ }
+
+ /**
+ * Writes the service information into the given registry key.
+ * This method is called by the <code>JavaLoader</code>
+ * <p>
+ * @return returns true if the operation succeeded
+ * @param regKey the registryKey
+ * @see com.sun.star.comp.loader.JavaLoader
+ */
+ public static boolean __writeRegistryServiceInfo(XRegistryKey regKey) {
+ return Factory.writeRegistryServiceInfo(_LicenseTest.class.getName(),
+ _LicenseTest.getServiceNames(),
+ regKey);
+ }
+ /** 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 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 its expected and in which
+ * order!At this point you can read the objects and can intialize
+ * your component using these objects.
+ */
+ }
+
+}
diff --git a/odk/examples/DevelopersGuide/Components/SimpleLicense/Makefile b/odk/examples/DevelopersGuide/Components/SimpleLicense/Makefile
new file mode 100644
index 000000000000..976de2d07b40
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Components/SimpleLicense/Makefile
@@ -0,0 +1,170 @@
+#*************************************************************************
+#
+# 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
+include $(SETTINGS)/dk.mk
+
+# Define non-platform/compiler specific settings
+
+# we use the sample directory name dor 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
+
+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)))
+GEN_URDFILES = $(patsubst %.idl,$(SAMPLE_GEN_OUT)/%.urd,$(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 $*)>> $@
+
+$(SAMPLE_GEN_OUT)/%.urd : %.idl
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ $(IDLC) -C -I. -I$(IDL_DIR) -O$(SAMPLE_GEN_OUT) $<
+
+$(COMP_GEN_OUT)/%.rdb : $(GEN_URDFILES)
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ $(REGMERGE) $@ /UCR $(GEN_URDFILES)
+
+$(GEN_CLASSFILES) : $(COMP_RDB)
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ $(JAVAMAKER) -BUCR -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-component;type=Java$(QM)" >> $@
+ @echo $(SQM) $(SQM)manifest:full-path="$(QM)$(subst /META-INF,,$(subst $(SAMPLE_GEN_OUT)/,,$(@D))).uno.jar$(QM)"/$(CSEP) >> $@
+ @echo $(OSEP)/manifest:manifest$(CSEP) >> $@
+
+# rule for component package file
+$(COMP_PACKAGE) : $(COMP_RDB) $(COMP_JAR) $(COMP_UNOPKG_MANIFEST) $(COMP_LOCAL_FILES)
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ cd $(subst /,$(PS),$(COMP_GEN_OUT)) && $(SDK_ZIP) ../../../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 000000000000..aa465ab8d288
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Components/SimpleLicense/description.xml
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<description xmlns="http://openoffice.org/extensions/description/2006"
+ xmlns:xlink="http://www.w3.org/1999/xlink">
+
+ <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 000000000000..6deedf8b44d4
--- /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 000000000000..127a4569b377
--- /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 000000000000..6dffc4cbad7a
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Components/Thumbs/Makefile
@@ -0,0 +1,81 @@
+#*************************************************************************
+#
+# 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 Comonent Thumbs of the Developers Guide.
+
+PRJ=../../../..
+SETTINGS=$(PRJ)/settings
+
+include $(SETTINGS)/settings.mk
+include $(SETTINGS)/std.mk
+include $(SETTINGS)/dk.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
+
+ComponentsThumbsExample : $(COMPONENT_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.java b/odk/examples/DevelopersGuide/Components/Thumbs/org/openoffice/comp/test/ImageShrink.java
new file mode 100644
index 000000000000..7fe4307d8a80
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Components/Thumbs/org/openoffice/comp/test/ImageShrink.java
@@ -0,0 +1,158 @@
+/*************************************************************************
+ *
+ * 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;
+
+
+/*
+ * ImageShrink.java
+ *
+ * Created on 4. Mai 2002, 20:25
+ */
+
+
+/**
+ *
+ * @author dschulten
+ */
+
+import com.sun.star.lang.XSingleServiceFactory;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.registry.XRegistryKey;
+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;
+
+
+ // maintain a static implementation id for all instances of ImageShrink
+ // initialized by the first call to getImplementationId()
+ static byte[] _implementationId;
+
+
+ // 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();
+
+ /** Creates a new instance of ImageShrink */
+ public ImageShrink() {
+ }
+
+
+ // 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;
+ }
+ public static boolean __writeRegistryServiceInfo(XRegistryKey regKey) {
+ //System.out.println(ImageShrink.class.getName());
+ return FactoryHelper.writeRegistryServiceInfo( ImageShrink.class.getName(),
+ __serviceName,
+ regKey);
+ }
+
+ // 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 };
+ }
+
+}
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 000000000000..2b990e22ae2e
--- /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 $(SETTINGS)/dk.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
+$(COMPONENT_JAR) : $(COMPONENT_MANIFESTFILE) $(OUT_COMP_CLASS)/$(PACKAGE)/$(COMPONENT_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-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_RDB) $(COMPONENT_JAR) $(COMPONENT_UNOPKG_MANIFEST)
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ $(COPY) $(subst /,$(PS),$(COMPONENT_RDB)) $(subst /,$(PS),$(OUT_COMP_CLASS))
+ cd $(subst /,$(PS),$(OUT_COMP_CLASS)) && $(SDK_ZIP) ../../bin/$(@F) $(COMPONENT_RDB_NAME) $(COMPONENT_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)/$(COMPONENT_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) : $(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
+
+.PHONY: clean
+clean :
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$(COMPONENT_PACKAGE_URL)))
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$(COMPONENT_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 000000000000..3ef79b89e9c0
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Components/Thumbs/org/openoffice/comp/test/Thumbs.java
@@ -0,0 +1,79 @@
+/*************************************************************************
+ *
+ * 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.uno.UnoRuntime;
+
+
+/**
+ * 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 succesfully instantiated");
+
+ java.io.File f = new java.io.File(".");
+ System.out.println("set SourceDrectory ...");
+ 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);
+ }
+ }
+}
+
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 000000000000..b891982f5133
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Components/Thumbs/org/openoffice/test/ImageShrink.idl
@@ -0,0 +1,46 @@
+/*************************************************************************
+ *
+ * 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
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 000000000000..698670084a23
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Components/Thumbs/org/openoffice/test/Makefile
@@ -0,0 +1,73 @@
+#*************************************************************************
+#
+# 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 $(SETTINGS)/dk.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)/%.urd : %.idl
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ $(IDLC) -I. -I../../.. -I$(IDL_DIR) -O$(OUT_COMP_GEN) $^
+
+$(OUT_COMP_GEN)/%.rdb : $(GENURDFILES)
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ $(REGMERGE) $@ /UCR $(GENURDFILES)
+
+$(OUT_COMP_CLASS)/%.class : $(COMPONENT_RDB)
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ $(JAVAMAKER) -BUCR -nD $(GENTYPELIST) -O$(OUT_COMP_CLASS) $(COMPONENT_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 000000000000..361e9914e10e
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Components/Thumbs/org/openoffice/test/XImageShrink.idl
@@ -0,0 +1,53 @@
+/*************************************************************************
+ *
+ * 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
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 000000000000..18a59aa667c4
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Components/Thumbs/org/openoffice/test/XImageShrinkFilter.idl
@@ -0,0 +1,50 @@
+/*************************************************************************
+ *
+ * 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
diff --git a/odk/examples/DevelopersGuide/Components/Thumbs/thumbs.mk b/odk/examples/DevelopersGuide/Components/Thumbs/thumbs.mk
new file mode 100644
index 000000000000..ae6a5c94f0fa
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Components/Thumbs/thumbs.mk
@@ -0,0 +1,27 @@
+OUT_COMP_CLASS = $(OUT_CLASS)/ComponentThumbsExample
+OUT_COMP_GEN = $(OUT_MISC)/ComponentThumbsExample
+
+COMPONENT_NAME=ImageShrink
+COMPONENT_RDB_NAME = $(COMPONENT_NAME).uno.rdb
+COMPONENT_RDB = $(OUT_COMP_GEN)/$(COMPONENT_RDB_NAME)
+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_COMP_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)$(PS)devguide_$(COMPONENT_NAME)_register_component.flag
+
+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)))
+GENURDFILES = $(patsubst %.idl,$(OUT_COMP_GEN)/%.urd,$(IDLFILES))
+
+APP1_NAME=Thumbs
+APP1_JAR=$(OUT_COMP_CLASS)/$(APP1_NAME).jar
diff --git a/odk/examples/DevelopersGuide/Components/dialogcomponent/DialogComponent.java b/odk/examples/DevelopersGuide/Components/dialogcomponent/DialogComponent.java
new file mode 100644
index 000000000000..f7ad9ad4b7c8
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Components/dialogcomponent/DialogComponent.java
@@ -0,0 +1,324 @@
+/*************************************************************************
+ *
+ * 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.Type;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.XComponentContext;
+import com.sun.star.registry.XRegistryKey;
+import com.sun.star.lang.XTypeProvider;
+import com.sun.star.lang.XServiceInfo;
+import com.sun.star.lang.XSingleServiceFactory;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.lang.XSingleComponentFactory;
+import com.sun.star.lang.XMultiComponentFactory;
+import com.sun.star.lib.uno.helper.Factory;
+import com.sun.star.comp.loader.FactoryHelper;
+import com.sun.star.awt.XDialog;
+import com.sun.star.awt.XDialogProvider2;
+import com.sun.star.awt.XDialogEventHandler;
+import com.sun.star.awt.XControl;
+import com.sun.star.awt.XControlModel;
+import com.sun.star.awt.XControlContainer;
+import com.sun.star.beans.XPropertySet;
+import com.sun.star.frame.XModel;
+import com.sun.star.frame.XFrame;
+
+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 impelmentation WeakBase or
+// ComponentBase, see implementation of TestComponentA.
+public class DialogComponent {
+
+ // public static class _DialogComponent extends WeakBase
+ public static class _DialogComponent
+ implements XTypeProvider, XServiceInfo, XTestDialogHandler, XDialogEventHandler {
+
+ static final String __serviceName= "com.sun.star.test.TestDialogHandler";
+
+ static byte[] _implementationId;
+ private 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 = (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 = (XDialogProvider2)
+ 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 = (XControlContainer)UnoRuntime.queryInterface(
+ XControlContainer.class, xDialog );
+ String aTextPropertyStr = "Text";
+ String aText = "";
+ XControl xTextField1Control = xControlContainer.getControl( "TextField1" );
+ XControlModel xControlModel1 = xTextField1Control.getModel();
+ XPropertySet xPropertySet1 = (XPropertySet)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 = (XPropertySet)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 final String aHandlerMethod1 = "doit1";
+ private final String aHandlerMethod2 = "doit2";
+ private 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[3];
+ retValue[0]= aHandlerMethod1;
+ retValue[1]= aHandlerMethod2;
+ retValue[2]= 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
+ synchronized public byte[] getImplementationId( ) {
+ if (_implementationId == null) {
+ _implementationId= new byte[16];
+ int hash = hashCode();
+ _implementationId[0] = (byte)(hash & 0xff);
+ _implementationId[1] = (byte)((hash >>> 8) & 0xff);
+ _implementationId[2] = (byte)((hash >>> 16) & 0xff);
+ _implementationId[3] = (byte)((hash >>>24) & 0xff);
+ }
+ return _implementationId;
+ }
+
+
+
+ /** 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;
+ }
+
+ //XServiceInfo
+ public String[] getSupportedServiceNames() {
+ return getServiceNames();
+ }
+
+ //XServiceInfo
+ public boolean supportsService( String sServiceName ) {
+ return sServiceName.equals( __serviceName );
+ }
+
+ //XServiceInfo
+ public String getImplementationName() {
+ // return DialogComponent.class.getName();
+ return _DialogComponent.class.getName();
+ }
+
+ public void showMessageBox(String sTitle, String sMessage) {
+ try {
+ if ( null != m_xFrame && null != m_xToolkit ) {
+
+ // describe window properties.
+ WindowDescriptor aDescriptor = new WindowDescriptor();
+ aDescriptor.Type = WindowClass.MODALTOP;
+ aDescriptor.WindowServiceName = new String( "infobox" );
+ aDescriptor.ParentIndex = -1;
+ aDescriptor.Parent = (XWindowPeer)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 = (XMessageBox)UnoRuntime.queryInterface(
+ XMessageBox.class, xPeer);
+ if ( null != xMsgBox )
+ {
+ xMsgBox.setCaptionText( sTitle );
+ xMsgBox.setMessageText( sMessage );
+ xMsgBox.execute();
+ }
+ }
+ }
+ } catch ( com.sun.star.uno.Exception e) {
+ // do your error handling
+ }
+ }
+ }
+
+ /**
+ * 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;
+ }
+
+ /**
+ * Writes the service information into the given registry key.
+ * This method is called by the <code>JavaLoader</code>
+ * <p>
+ * @return returns true if the operation succeeded
+ * @param regKey the registryKey
+ * @see com.sun.star.comp.loader.JavaLoader
+ */
+ public static boolean __writeRegistryServiceInfo(XRegistryKey regKey) {
+ return Factory.writeRegistryServiceInfo(_DialogComponent.class.getName(),
+ _DialogComponent.getServiceNames(),
+ regKey);
+ }
+}
diff --git a/odk/examples/DevelopersGuide/Components/dialogcomponent/DialogComponent.odt b/odk/examples/DevelopersGuide/Components/dialogcomponent/DialogComponent.odt
new file mode 100644
index 000000000000..bd6a9b40f5b6
--- /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 000000000000..8726029ec222
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Components/dialogcomponent/Makefile
@@ -0,0 +1,177 @@
+#*************************************************************************
+#
+# 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
+include $(SETTINGS)/dk.mk
+
+# Define non-platform/compiler specific settings
+
+# we use the sample directory name dor 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
+
+IDLFILES = XTestDialogHandler.idl \
+ TestDialogHandler.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 = 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)))
+GEN_URDFILES = $(patsubst %.idl,$(SAMPLE_GEN_OUT)/%.urd,$(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 $*)>> $@
+
+$(SAMPLE_GEN_OUT)/%.urd : %.idl
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ $(IDLC) -C -I. -I$(IDL_DIR) -O$(SAMPLE_GEN_OUT) $<
+
+$(COMP_GEN_OUT)/%.rdb : $(GEN_URDFILES)
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ $(REGMERGE) $@ /UCR $(GEN_URDFILES)
+
+$(GEN_CLASSFILES) : $(COMP_RDB)
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ $(JAVAMAKER) -BUCR -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-component;type=Java$(QM)" >> $@
+ @echo $(SQM) $(SQM)manifest:full-path="$(QM)$(subst /META-INF,,$(subst $(SAMPLE_GEN_OUT)/,,$(@D))).uno.jar$(QM)"/$(CSEP) >> $@
+ @echo $(OSEP)/manifest:manifest$(CSEP) >> $@
+
+# rule for component package file
+$(COMP_PACKAGE) : $(COMP_RDB) $(COMP_JAR) $(COMP_UNOPKG_MANIFEST)
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ cd $(subst /,$(PS),$(COMP_GEN_OUT)) && $(SDK_ZIP) ../../../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/TestDialogHandler.idl b/odk/examples/DevelopersGuide/Components/dialogcomponent/TestDialogHandler.idl
new file mode 100644
index 000000000000..7196b173b4fa
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Components/dialogcomponent/TestDialogHandler.idl
@@ -0,0 +1,47 @@
+/*************************************************************************
+ *
+ * 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
+
+
+
+
diff --git a/odk/examples/DevelopersGuide/Components/dialogcomponent/XTestDialogHandler.idl b/odk/examples/DevelopersGuide/Components/dialogcomponent/XTestDialogHandler.idl
new file mode 100644
index 000000000000..aa968917d5c9
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Components/dialogcomponent/XTestDialogHandler.idl
@@ -0,0 +1,53 @@
+/*************************************************************************
+ *
+ * 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
diff --git a/odk/examples/DevelopersGuide/Components/makefile.mk b/odk/examples/DevelopersGuide/Components/makefile.mk
new file mode 100644
index 000000000000..7c399b33c109
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Components/makefile.mk
@@ -0,0 +1,123 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ=..$/..$/..
+PRJNAME=odk
+TARGET=copying
+
+#----------------------------------------------------------------
+.INCLUDE: settings.mk
+.INCLUDE: $(PRJ)$/util$/makefile.pmk
+#----------------------------------------------------------------
+
+#----------------------------------------------------
+# this makefile is only used for copying the example
+# files into the SDK
+#----------------------------------------------------
+
+DESTJOBSADDON=$(DESTDIRDEVGUIDEEXAMPLES)$/Components$/Addons$/JobsAddon
+JOBSADDON_FILES=\
+ $(DESTJOBSADDON)$/Addons.xcu \
+ $(DESTJOBSADDON)$/AsyncJob.java \
+ $(DESTJOBSADDON)$/Jobs.xcu \
+ $(DESTJOBSADDON)$/Makefile
+
+DESTPROTOCOLHANDLERADDONCPP=$(DESTDIRDEVGUIDEEXAMPLES)$/Components$/Addons$/ProtocolHandlerAddon_cpp
+PROTOCOLHANLDERADDONCPP_FILES=\
+ $(DESTPROTOCOLHANDLERADDONCPP)$/addon.cxx \
+ $(DESTPROTOCOLHANDLERADDONCPP)$/addon.hxx \
+ $(DESTPROTOCOLHANDLERADDONCPP)$/Addons.xcu \
+ $(DESTPROTOCOLHANDLERADDONCPP)$/component.cxx \
+ $(DESTPROTOCOLHANDLERADDONCPP)$/Makefile \
+ $(DESTPROTOCOLHANDLERADDONCPP)$/ProtocolHandler.xcu \
+ $(DESTPROTOCOLHANDLERADDONCPP)$/ProtocolHandlerAddon_cpp.uno.xml
+
+DESTPROTOCOLHANDLERADDONJAVA=$(DESTDIRDEVGUIDEEXAMPLES)$/Components$/Addons$/ProtocolHandlerAddon_java
+PROTOCOLHANLDERADDONJAVA_FILES=\
+ $(DESTPROTOCOLHANDLERADDONJAVA)$/Addons.xcu \
+ $(DESTPROTOCOLHANDLERADDONJAVA)$/Makefile \
+ $(DESTPROTOCOLHANDLERADDONJAVA)$/ProtocolHandler.xcu \
+ $(DESTPROTOCOLHANDLERADDONJAVA)$/ProtocolHandlerAddon.java \
+ $(DESTPROTOCOLHANDLERADDONJAVA)$/ProtocolHandlerAddon_java.uno.xml
+
+CPPCOMPONENT_FILES=\
+ $(DESTDIRDEVGUIDEEXAMPLES)$/Components$/CppComponent$/CppComponent.uno.xml \
+ $(DESTDIRDEVGUIDEEXAMPLES)$/Components$/CppComponent$/Makefile \
+ $(DESTDIRDEVGUIDEEXAMPLES)$/Components$/CppComponent$/service1_impl.cxx \
+ $(DESTDIRDEVGUIDEEXAMPLES)$/Components$/CppComponent$/service2_impl.cxx \
+ $(DESTDIRDEVGUIDEEXAMPLES)$/Components$/CppComponent$/TestCppComponent.cxx \
+ $(DESTDIRDEVGUIDEEXAMPLES)$/Components$/CppComponent$/SimpleComponent.odt \
+ $(DESTDIRDEVGUIDEEXAMPLES)$/Components$/CppComponent$/some.idl
+
+JAVACOMPONENT_FILES=\
+ $(DESTDIRDEVGUIDEEXAMPLES)$/Components$/JavaComponent$/Makefile \
+ $(DESTDIRDEVGUIDEEXAMPLES)$/Components$/JavaComponent$/TestComponentA.java \
+ $(DESTDIRDEVGUIDEEXAMPLES)$/Components$/JavaComponent$/TestComponentB.java \
+ $(DESTDIRDEVGUIDEEXAMPLES)$/Components$/JavaComponent$/TestServiceProvider.java \
+ $(DESTDIRDEVGUIDEEXAMPLES)$/Components$/JavaComponent$/TestJavaComponent.java \
+ $(DESTDIRDEVGUIDEEXAMPLES)$/Components$/JavaComponent$/XSomethingA.idl \
+ $(DESTDIRDEVGUIDEEXAMPLES)$/Components$/JavaComponent$/XSomethingB.idl \
+ $(DESTDIRDEVGUIDEEXAMPLES)$/Components$/JavaComponent$/SomethingA.idl \
+ $(DESTDIRDEVGUIDEEXAMPLES)$/Components$/JavaComponent$/SomethingB.idl
+
+DESTTHUMBS=$(DESTDIRDEVGUIDEEXAMPLES)$/Components$/Thumbs
+THUMBS_FILES=\
+ $(DESTTHUMBS)$/org$/openoffice$/comp$/test$/ImageShrink.java \
+ $(DESTTHUMBS)$/org$/openoffice$/comp$/test$/Thumbs.java \
+ $(DESTTHUMBS)$/org$/openoffice$/comp$/test$/Makefile \
+ $(DESTTHUMBS)$/org$/openoffice$/test$/ImageShrink.idl \
+ $(DESTTHUMBS)$/org$/openoffice$/test$/XImageShrink.idl \
+ $(DESTTHUMBS)$/org$/openoffice$/test$/XImageShrinkFilter.idl \
+ $(DESTTHUMBS)$/org$/openoffice$/test$/Makefile \
+ $(DESTTHUMBS)$/thumbs.mk \
+ $(DESTTHUMBS)$/Makefile
+
+
+DIR_FILE_LIST= \
+ $(JOBSADDON_FILES) \
+ $(PROTOCOLHANLDERADDONCPP_FILES) \
+ $(PROTOCOLHANLDERADDONJAVA_FILES) \
+ $(CPPCOMPONENT_FILES) \
+ $(JAVACOMPONENT_FILES) \
+ $(THUMBS_FILES)
+
+DIR_DIRECTORY_LIST=$(uniq $(DIR_FILE_LIST:d))
+DIR_CREATE_FLAG=$(MISC)$/devguide_components_dirs_created.txt
+DIR_FILE_FLAG=$(MISC)$/devguide_components.txt
+
+#--------------------------------------------------
+# TARGETS
+#--------------------------------------------------
+all : \
+ $(DIR_FILE_LIST) \
+ $(DIR_FILE_FLAG)
+
+#--------------------------------------------------
+# use global rules
+#--------------------------------------------------
+.INCLUDE: $(PRJ)$/util$/odk_rules.pmk
+
diff --git a/odk/examples/DevelopersGuide/Config/ConfigExamples.java b/odk/examples/DevelopersGuide/Config/ConfigExamples.java
new file mode 100644
index 000000000000..a88127ef1053
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Config/ConfigExamples.java
@@ -0,0 +1,1202 @@
+/*************************************************************************
+ *
+ * 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.bridge.XUnoUrlResolver;
+
+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.XMultiComponentFactory;
+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.XNamingService;
+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
+ @author Joerg Barfurth
+ */
+
+/* These examples show how to use the following features of the Config API:
+
+ o Accessing data
+ o Updating data synchronously and asynchronously
+ 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 XComponentContext mxContext = null;
+
+ // The MultiComponentFactory interface of the ServiceManager
+ private XMultiComponentFactory mxServiceManager = null;
+
+ // 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 it's 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 an AdministrationProvider
+ */
+ public void runForAdmin(Object [] aAdminArgs)
+ throws com.sun.star.uno.Exception
+ {
+ mxProvider = createAdminProvider(aAdminArgs);
+
+ runExamples( );
+
+ // this is not the default ConfigurationProvider, so we can dispose it
+ ((XComponent)UnoRuntime.queryInterface( XComponent.class, mxProvider )).dispose();
+ mxProvider = null;
+ }
+
+ /** Run the examples with a given ConfigurationProvider
+ */
+ public void runExamples( )
+ {
+ if (checkProvider(mxProvider))
+ {
+ System.out.println("\nStarting examples.");
+
+ readDataExample();
+
+ browseDataExample();
+
+ updateGroupSyncExample();
+
+ resetGroupExample();
+
+ updateSetAsyncExample();
+
+ System.out.println("\nAll Examples completed.");
+ }
+ else
+ System.out.println("ERROR: Cannot run examples without ConfigurationProvider.");
+
+ }
+
+ /** Do some simple checks, if tehre 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 =
+ (XServiceInfo) 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 = (XMultiServiceFactory)
+ UnoRuntime.queryInterface(XMultiServiceFactory.class,
+ mxServiceManager.createInstanceWithContext(sProviderService,
+ mxContext));
+
+ return xProvider;
+ }
+
+ /** Create an administration provider
+
+ @param aAdminArguments
+ An array of extra arguments to be used to create the provider
+ */
+ public XMultiServiceFactory createAdminProvider(Object[] aAdminArguments)
+ throws com.sun.star.uno.Exception
+ {
+ final String sAdminService = "com.sun.star.configuration.AdministrationProvider";
+
+ // create the provider and remember it as a XMultiServiceFactory
+ XMultiServiceFactory xAdminProvider = (XMultiServiceFactory)
+ UnoRuntime.queryInterface(XMultiServiceFactory.class,
+ mxServiceManager.createInstanceWithArgumentsAndContext(
+ sAdminService, aAdminArguments, mxContext));
+
+ return xAdminProvider;
+ }
+
+ /** 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 using default synchronicity
+ */
+ 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;
+ }
+
+ /** Create a specified updatable configuration view
+ */
+ Object createUpdatableView( String sPath, boolean bAsync )
+ 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;
+
+ // creation arguments: commit mode - write-through or write-back
+ com.sun.star.beans.PropertyValue aModeArgument = new com.sun.star.beans.PropertyValue();
+ aModeArgument.Name = "lazywrite";
+ aModeArgument.Value = new Boolean(bAsync);
+
+ Object[] aArguments = new Object[2];
+ aArguments[0] = aPathArgument;
+ aArguments[1] = aModeArgument;
+
+ // 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 synchronous update access to group data
+ */
+ protected void updateGroupSyncExample ()
+ {
+ try
+ {
+ System.out.println("\n--- starting example: update group data synchronously --------------");
+ 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 asynchronous update access to set data
+ */
+ protected void updateSetAsyncExample ()
+ {
+ try
+ {
+ System.out.println("\n--- starting example: update set data asynchronously ---------------");
+ storeSampleDataSource( );
+ }
+ catch ( Exception e )
+ {
+ e.printStackTrace();
+ }
+ }
+
+// READ example
+ /// class to hold information about grid settings
+ public static class GridOptions
+ {
+ public boolean visible;
+ public int resolution_x;
+ public int resolution_y;
+ public int subdivision_x;
+ public int subdivision_y;
+
+ 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 =
+ (XHierarchicalPropertySet)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 =
+ (XMultiPropertySet)UnoRuntime.queryInterface(XMultiPropertySet.class, xSubdivision);
+
+ // variables for multi-element access
+ String[] aElementNames = new String[2];
+
+ aElementNames[0] = "XAxis";
+ aElementNames[1] = "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 =
+ (XMultiHierarchicalPropertySet)
+ 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
+
+ ((XComponent)UnoRuntime.queryInterface(XComponent.class, xViewRoot)).dispose();
+
+ return options;
+ }
+
+// BROWSE example
+ /// Interface to procees information when browsing the configuration tree
+ public static interface IConfigurationProcessor
+ {
+ /// process a value item
+ public abstract void processValueElement( String sPath_, Object aValue_ );
+ /// process a structural item
+ public abstract 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 =
+ (XHierarchicalName) UnoRuntime.queryInterface(XHierarchicalName.class, xElement);
+
+ String sPath = xElementPath.getHierarchicalName();
+
+ aProcessor.processStructuralElement( sPath, xElement);
+
+ // now process this as a container
+ XNameAccess xChildAccess =
+ (XNameAccess) 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] );
+ AnyConverter aAnyConv = new AnyConverter();
+ // is it a structural element (object) ...
+ if ( aAnyConv.isObject(aChild) && !aAnyConv.isArray(aChild) )
+ {
+ // then get an interface
+ XInterface xChildElement = (XInterface)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
+
+ ((XComponent) 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 sProviderService = "com.sun.star.configuration.ConfigurationProvider";
+ 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 (new 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 =
+ ( XTemplateInstance )UnoRuntime.queryInterface( XTemplateInstance .class,xElement_);
+
+ // only select the Filter entries
+ if (xInstance != null && xInstance.getTemplateName().endsWith("Filter")) {
+ XNamed 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 SYNCHRONOUS view for better error handling
+ Object xViewRoot = createUpdatableView( cGridOptionsPath, false);
+
+ // 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 =
+ (XMultiHierarchicalPropertySet)
+ 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 =
+ (XChangesNotifier)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 =
+ (XChangesBatch) 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
+ ((XComponent)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 zuser
+ 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 =
+ (XHierarchicalPropertySet)UnoRuntime.queryInterface(XHierarchicalPropertySet.class, mxModel);
+
+ final String sSetting = "Option/VisibleGrid";
+
+ System.out.println("GridEditor: toggling Visibility");
+
+ Boolean bOldValue = (Boolean)xHPS.getHierarchicalPropertyValue(sSetting);
+
+ Boolean bNewValue = new Boolean( ! 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, false);
+
+ XNameReplace aReplace = (XNameReplace)UnoRuntime.queryInterface(XNameReplace.class, xOtherViewRoot);
+
+ String aItemNames [] = aReplace.getElementNames();
+ for (int i=0; i < aItemNames.length; ++i) {
+ Object aItem = aReplace.getByName( aItemNames [i] );
+ AnyConverter aAnyConv = new AnyConverter();
+ // replace integers by a 'complement' value
+ if ( aAnyConv.isInt(aItem) )
+ {
+ int nOld = aAnyConv.toInt(aItem);
+ int nNew = 9999 - nOld;
+
+ System.out.println("Replacing integer value: " + aItemNames [i]);
+ aReplace.replaceByName( aItemNames [i], new Integer( nNew ) );
+ }
+
+ // and booleans by their negated value
+ else if ( aAnyConv.isBoolean(aItem) )
+ {
+ boolean bOld = aAnyConv.toBoolean(aItem);
+ boolean bNew = ! bOld;
+
+ System.out.println("Replacing boolean value: " + aItemNames [i]);
+ aReplace.replaceByName( aItemNames [i], new Boolean( bNew ) );
+ }
+ }
+
+ // commit the changes
+ XChangesBatch xUpdateControl =
+ (XChangesBatch) UnoRuntime.queryInterface(XChangesBatch.class,xOtherViewRoot);
+
+ xUpdateControl.commitChanges();
+
+ // we are done with the view - dispose it
+ ((XComponent)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 =
+ (XHierarchicalNameAccess)UnoRuntime.queryInterface(XHierarchicalNameAccess.class, xViewRoot);
+
+ // get using absolute name
+ Object xOptions = xHierarchicalAccess.getByHierarchicalName(cGridOptionsPath + "/Option");
+
+ XPropertyState xOptionState =
+ (XPropertyState)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 =
+ (XPropertyState)UnoRuntime.queryInterface(XPropertyState.class, xResolutionX);
+ XPropertyState xResolutionStateY =
+ (XPropertyState)UnoRuntime.queryInterface(XPropertyState.class, xResolutionY);
+
+ xResolutionStateX.setPropertyToDefault("Metric");
+ xResolutionStateY.setPropertyToDefault("Metric");
+
+ // resetting multiple sibling values
+ Object xSubdivision = xHierarchicalAccess.getByHierarchicalName("Subdivision");
+
+ XMultiPropertyStates xSubdivisionStates =
+ (XMultiPropertyStates)UnoRuntime.queryInterface(XMultiPropertyStates.class, xSubdivision);
+
+ xSubdivisionStates.setAllPropertiesToDefault();
+
+ // commit the changes
+ XChangesBatch xUpdateControl =
+ (XChangesBatch) UnoRuntime.queryInterface(XChangesBatch.class,xViewRoot);
+
+ xUpdateControl.commitChanges();
+
+ // we are done with the view - dispose it
+ ((XComponent)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 currenty 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";
+ // String sSampleDataSourceURL = "sdbc:flat:file:///usr/local/database/SampleTextDatabase";
+ // String sSampleDataSourceURL = "sdbc:flat:file:///C:/data/database/SampleTextDatabase";
+
+ com.sun.star.beans.NamedValue [] aSettings = new com.sun.star.beans.NamedValue [2];
+ aSettings[0] = new com.sun.star.beans.NamedValue("HeaderLine",new Boolean(true));
+ aSettings[1] = new com.sun.star.beans.NamedValue("FieldDelimiter",";");
+
+ String [] aTableFilter = new String[2];
+ aTableFilter[0] = "table.txt";
+ aTableFilter[1] = "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 =
+ (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, xDataSource);
+
+ xDataSourceProperties.setPropertyValue("URL", sDataSourceURL );
+ xDataSourceProperties.setPropertyValue("User", sUser );
+ xDataSourceProperties.setPropertyValue("IsPasswordRequired", new Boolean( bNeedsPassword ) );
+ xDataSourceProperties.setPropertyValue("LoginTimeout", new Integer( 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 =
+ (XChangesBatch) UnoRuntime.queryInterface(XChangesBatch.class,xViewRoot);
+
+ xUpdateControl.commitChanges();
+
+ // now clean up
+ ((XComponent) 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.
+
+ The method attempts to keep the view used as small as possible. In particular there
+ is no view created, that contains data for all data source that are registered.
+ */
+ 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 ;
+
+ // creation arguments: commit mode
+ com.sun.star.beans.PropertyValue aModeArgument = new com.sun.star.beans.PropertyValue();
+ aModeArgument.Name = "lazywrite";
+ aModeArgument.Value = new Boolean( true );
+
+ // creation arguments: depth
+ com.sun.star.beans.PropertyValue aDepthArgument = new com.sun.star.beans.PropertyValue();
+ aDepthArgument.Name = "depth";
+ aDepthArgument.Value = new Integer( 1 );
+
+ Object[] aArguments = new Object[3];
+ aArguments[0] = aPathArgument;
+ aArguments[1] = aModeArgument;
+ aArguments[2] = aDepthArgument;
+
+ // create the view: asynchronously updatable, with depth 1
+ Object xViewRoot =
+ xProvider.createInstanceWithArguments(cUpdatableView, aArguments);
+
+ XNameAccess xSetOfDataSources =
+ (XNameAccess) UnoRuntime.queryInterface(XNameAccess.class,xViewRoot);
+
+ Object xDataSourceDescriptor = null; // the result
+ if ( xSetOfDataSources .hasByName( sDataSourceName ))
+ {
+ // the element is there, but it is loaded only with depth zero !
+ try
+ {
+ // the view should point to the element directly, so we need to extend the path
+ XHierarchicalName xComposePath = (XHierarchicalName)
+ UnoRuntime.queryInterface(XHierarchicalName.class, xSetOfDataSources );
+
+ String sElementPath = xComposePath.composeHierarchicalName( sDataSourceName );
+
+ // use the name of the element now
+ aPathArgument.Value = sElementPath;
+
+ // create another view now (without depth limit)
+ Object[] aDeepArguments = new Object[2];
+ aDeepArguments[0] = aPathArgument;
+ aDeepArguments[1] = aModeArgument;
+
+ // create the view: asynchronously updatable, with unlimited depth
+ xDataSourceDescriptor =
+ xProvider.createInstanceWithArguments(cUpdatableView, aDeepArguments);
+
+ if ( xDataSourceDescriptor != null) // all went fine
+ {
+ // dispose the other view
+ ((XComponent)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 =
+ (XNameContainer)UnoRuntime.queryInterface(XNameContainer.class, xViewRoot);
+
+ // create a new detached set element (instance of DataSourceDescription)
+ XSingleServiceFactory xElementFactory =
+ (XSingleServiceFactory)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 =
+ (XNameContainer) UnoRuntime.queryInterface( XNameContainer.class, xSettingsSet);
+
+ // and get a factory interface for creating the entries
+ XSingleServiceFactory xSettingsFactory =
+ (XSingleServiceFactory) UnoRuntime.queryInterface(XSingleServiceFactory.class, xSettingsSet);
+
+ // now insert the individual settings
+ for (int i = 0; i < aSettings.length; ++i) {
+ // create a DataSourceSetting object
+ XPropertySet xSetting = (XPropertySet)
+ 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 =
+ (XChild) 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 = (XChild)
+ UnoRuntime.queryInterface(XChild.class, xNamedItem);
+
+ XNameContainer xParentSet = (XNameContainer)
+ 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 = (XNamed)
+ UnoRuntime.queryInterface(XNamed.class, xChildItem);
+
+ XNameContainer xOldParent = (XNameContainer)
+ UnoRuntime.queryInterface( XNameContainer.class, xChildItem.getParent() );
+
+ String sItemName = xNamedItem.getName();
+
+ // now rename the item
+ xOldParent.removeByName(sItemName);
+ xNewParent.insertByName(sItemName,xChildItem);
+ }
+
+
+// ------- the end -----------
+}
diff --git a/odk/examples/DevelopersGuide/Config/Makefile b/odk/examples/DevelopersGuide/Config/Makefile
new file mode 100644
index 000000000000..9b1e54fc341a
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Config/Makefile
@@ -0,0 +1,99 @@
+#*************************************************************************
+#
+# 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
+include $(SETTINGS)/dk.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/Config/makefile.mk b/odk/examples/DevelopersGuide/Config/makefile.mk
new file mode 100644
index 000000000000..d65ce2682fd3
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Config/makefile.mk
@@ -0,0 +1,64 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ=..$/..$/..
+PRJNAME=odk
+TARGET=copying
+
+#----------------------------------------------------------------
+.INCLUDE: settings.mk
+.INCLUDE: $(PRJ)$/util$/makefile.pmk
+#----------------------------------------------------------------
+
+#----------------------------------------------------
+# this makefile is only used for copying the example
+# files into the SDK
+#----------------------------------------------------
+
+CONFIG_FILES=\
+ $(DESTDIRDEVGUIDEEXAMPLES)$/Config$/ConfigExamples.java \
+ $(DESTDIRDEVGUIDEEXAMPLES)$/Config$/Makefile
+
+DIR_FILE_LIST= \
+ $(CONFIG_FILES) \
+
+DIR_DIRECTORY_LIST=$(uniq $(DIR_FILE_LIST:d))
+DIR_CREATE_FLAG=$(MISC)$/devguide_config_dirs_created.txt
+DIR_FILE_FLAG=$(MISC)$/devguide_config.txt
+
+#--------------------------------------------------
+# TARGETS
+#--------------------------------------------------
+all : \
+ $(DIR_FILE_LIST) \
+ $(DIR_FILE_FLAG)
+
+#--------------------------------------------------
+# use global rules
+#--------------------------------------------------
+.INCLUDE: $(PRJ)$/util$/odk_rules.pmk
+
diff --git a/odk/examples/DevelopersGuide/Database/CodeSamples.java b/odk/examples/DevelopersGuide/Database/CodeSamples.java
new file mode 100644
index 000000000000..79b3405a4602
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Database/CodeSamples.java
@@ -0,0 +1,356 @@
+/*************************************************************************
+ *
+ * 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.*;
+
+import com.sun.star.comp.helper.RegistryServiceFactory;
+import com.sun.star.comp.servicemanager.ServiceManager;
+import com.sun.star.lang.XMultiComponentFactory;
+import com.sun.star.lang.XSingleServiceFactory;
+import com.sun.star.lang.XServiceInfo;
+import com.sun.star.lang.XComponent;
+import com.sun.star.bridge.XUnoUrlResolver;
+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 );
+ }
+ // printDataSources();
+ }
+ catch(Exception e)
+ {
+ System.err.println(e);
+ e.printStackTrace();
+ }
+ System.exit(0);
+ }
+
+ // check if the connection is not null aand dispose it later on.
+ public static void checkConnection(XConnection con) throws com.sun.star.uno.Exception
+ {
+ if(con != null)
+ {
+ System.out.println("Connection was created!");
+ // now we dispose the connection to close it
+ XComponent 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 = (XDriverManager)UnoRuntime.queryInterface(XDriverManager.class,driverManager);
+ if(xDriverManager != null)
+ {
+ // first create the needed url
+ String adabasURL = "sdbc:adabas::MYDB0";
+ // second create the necessary properties
+ com.sun.star.beans.PropertyValue [] adabasProps = 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 adabas
+ con = xDriverManager.getConnectionWithInfo(adabasURL,adabasProps);
+ }
+ return con;
+ }
+
+ // uses the driver manager to create a new connection and dispose it.
+ public static XConnection openToJDBC() 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 = (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 adabas
+ 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("com.sun.star.comp.sdbcx.adabas.ODriver",
+ xContext);
+ // query for the interface
+ com.sun.star.sdbc.XDriver xDriver;
+ xDriver = (XDriver)UnoRuntime.queryInterface(XDriver.class,aDriver);
+ if(xDriver != null)
+ {
+ // first create the needed url
+ String adabasURL = "sdbc:adabas::MYDB0";
+ // second create the necessary properties
+ com.sun.star.beans.PropertyValue [] adabasProps = 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 adabas
+ con = xDriver.connect(adabasURL,adabasProps);
+ }
+ 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 = (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 = (XRow)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 = (XRow)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 = (XNameAccess)UnoRuntime.queryInterface(
+ XNameAccess.class,
+ xMCF.createInstanceWithContext("com.sun.star.sdb.DatabaseContext",
+ xContext));
+ // we use the first datasource
+ XQueryDefinitionsSupplier xQuerySup = (XQueryDefinitionsSupplier)
+ UnoRuntime.queryInterface(XQueryDefinitionsSupplier.class,
+ xNameAccess.getByName( "Bibliography" ));
+ XNameAccess xQDefs = xQuerySup.getQueryDefinitions();
+ // create new query definition
+ XSingleServiceFactory xSingleFac = (XSingleServiceFactory)
+ UnoRuntime.queryInterface(XSingleServiceFactory.class, xQDefs);
+
+ XPropertySet xProp = (XPropertySet) UnoRuntime.queryInterface(
+ XPropertySet.class,xSingleFac.createInstance());
+ xProp.setPropertyValue("Command","SELECT * FROM biblio");
+ xProp.setPropertyValue("EscapeProcessing",new Boolean(true));
+
+ XNameContainer xCont = (XNameContainer) 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 = (XDocumentDataSource)UnoRuntime.queryInterface(XDocumentDataSource.class, xQuerySup);
+
+ XStorable xStore = (XStorable)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 = (XNameAccess)UnoRuntime.queryInterface(
+ XNameAccess.class,
+ xMCF.createInstanceWithContext("com.sun.star.sdb.DatabaseContext",
+ xContext));
+ // we use the first datasource
+ XDataSource xDS = (XDataSource)UnoRuntime.queryInterface(
+ XDataSource.class, xNameAccess.getByName( "Bibliography" ));
+ XConnection con = xDS.getConnection("","");
+ XQueriesSupplier xQuerySup = (XQueriesSupplier)
+ UnoRuntime.queryInterface(XQueriesSupplier.class, con);
+
+ XNameAccess xQDefs = xQuerySup.getQueries();
+
+ XColumnsSupplier xColsSup = (XColumnsSupplier) 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]);
+ }
+}
+
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 000000000000..910137ac5bc0
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Database/DriverSkeleton/How_to_write_my_own_driver.txt
@@ -0,0 +1,25 @@
+How to write my own sdbc driver
+
+Pre implementation steps
+- search all occurances 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 000000000000..cbd28b982eac
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Database/DriverSkeleton/Makefile
@@ -0,0 +1,150 @@
+#*************************************************************************
+#
+# 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 Databse SDBC driver skeleton example of the Developers Guide.
+
+PRJ=../../../..
+SETTINGS=$(PRJ)/settings
+
+include $(SETTINGS)/settings.mk
+include $(SETTINGS)/std.mk
+include $(SETTINGS)/dk.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_MAPFILE = $(OUT_COMP_MISC)/$(COMP_NAME).uno.map
+
+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),$@) $<
+
+$(COMP_MAPFILE) : $(SLOFILES)
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ cat $(PRJ)/settings/component.uno.map > $(COMP_MAPFILE)
+ifeq "$(OS)" "MACOSX"
+ nm -gx $(SLOFILES) | $(ADDSYMBOLS) >> $(COMP_MAPFILE)
+endif
+
+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) $(STLPORTLIB) msvcrt.lib kernel32.lib
+ $(LINK_MANIFEST)
+else
+$(SHAREDLIB_OUT)/%.$(SHAREDLIB_EXT) : $(SLOFILES) $(COMP_MAPFILE)
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ $(LINK) $(COMP_LINK_FLAGS) $(LINK_LIBS) -o $@ $(SLOFILES) \
+ $(CPPUHELPERLIB) $(CPPULIB) $(SALLIB) $(STLPORTLIB) $(STC++LIB) $(CPPUHELPERDYLIB) $(CPPUDYLIB) $(SALDYLIB)
+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-component;type=native;platform=$(UNOPKG_PLATFORM)$(QM)" >> $@
+ @echo $(SQM) $(SQM)manifest:full-path="$(QM)$(subst /META-INF,,$(subst $(OUT_COMP_MISC)/,,$(UNOPKG_PLATFORM)/$(@D))).uno.$(SHAREDLIB_EXT)$(QM)"/$(CSEP) >> $@
+ @echo $(OSEP)/manifest:manifest$(CSEP) >> $@
+
+$(COMP_PACKAGE) : $(COMP_LIBRARY) $(COMP_UNOPKG_MANIFEST)
+ -$(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) $(UNOPKG_PLATFORM)/$(<F)
+ cd $(subst /,$(PS),$(OUT_COMP_MISC)/$(subst .$(UNOOXT_EXT),,$(@F))) && $(SDK_ZIP) -u ../../../bin/$(@F) META-INF/manifest.xml
+
+$(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 : $(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_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 000000000000..57ff6e0a3f09
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Database/DriverSkeleton/OSubComponent.hxx
@@ -0,0 +1,252 @@
+/*************************************************************************
+ *
+ * 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 _CONNECTIVITY_OSUBCOMPONENT_HXX_
+#define _CONNECTIVITY_OSUBCOMPONENT_HXX_
+
+#include <cppuhelper/weak.hxx>
+#include <cppuhelper/interfacecontainer.h>
+#include <com/sun/star/lang/DisposedException.hpp>
+#include <cppuhelper/propshlp.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) throw ( ::com::sun::star::lang::DisposedException );
+ //************************************************************
+ // OSubComponent
+ //************************************************************
+ 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 relase_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()
+ { // ARGHHHHHHH ..... would like to implement this in proparrhlp_impl.hxx (as we do with all other methods)
+ // but SUNPRO 5 compiler (linker) doesn't like this
+ ::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;
+ }
+ }
+
+ /** call this in the getInfoHelper method of your derived class. The method returns the array helper of the
+ class, which is created if neccessary.
+ */
+ ::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.
+ <BR>
+ as long as IPropertyArrayHelper has no virtual destructor, the implementation of ~OPropertyArrayUsageHelper
+ assumes that you created an ::cppu::OPropertyArrayHelper when deleting s_pProps.
+ @return an 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>
+ ::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( ) throw (::com::sun::star::uno::RuntimeException); \
+ virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw(::com::sun::star::uno::RuntimeException); \
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw(::com::sun::star::uno::RuntimeException) \
+
+#define IMPLEMENT_SERVICE_INFO(classname, implasciiname, serviceasciiname) \
+ ::rtl::OUString SAL_CALL classname::getImplementationName( ) throw (::com::sun::star::uno::RuntimeException) \
+ { \
+ return ::rtl::OUString::createFromAscii(implasciiname); \
+ } \
+ ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL classname::getSupportedServiceNames( ) throw(::com::sun::star::uno::RuntimeException) \
+ { \
+ ::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 ) throw(::com::sun::star::uno::RuntimeException) \
+ { \
+ Sequence< ::rtl::OUString > aSupported(getSupportedServiceNames()); \
+ const ::rtl::OUString* pSupported = aSupported.getConstArray(); \
+ const ::rtl::OUString* pEnd = pSupported + aSupported.getLength(); \
+ for (;pSupported != pEnd && !pSupported->equals(_rServiceName); ++pSupported) \
+ ; \
+ \
+ return pSupported != pEnd; \
+ } \
+
+
+ }
+}
+#endif // _CONNECTIVITY_OSUBCOMPONENT_HXX_
+
diff --git a/odk/examples/DevelopersGuide/Database/DriverSkeleton/OTypeInfo.hxx b/odk/examples/DevelopersGuide/Database/DriverSkeleton/OTypeInfo.hxx
new file mode 100644
index 000000000000..84f44d1c7e08
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Database/DriverSkeleton/OTypeInfo.hxx
@@ -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.
+ *
+ *************************************************************************/
+
+#ifndef _CONNECTIVITY_OTYPEINFO_HXX_
+#define _CONNECTIVITY_OTYPEINFO_HXX_
+
+#include <com/sun/star/sdbc/ColumnSearch.hpp>
+#include <com/sun/star/sdbc/DataType.hpp>
+
+namespace connectivity
+{
+ struct OTypeInfo
+ {
+ ::rtl::OUString aTypeName; // Name des Types in der Datenbank
+ ::rtl::OUString aLiteralPrefix; // Prefix zum Quoten
+ ::rtl::OUString aLiteralSuffix; // Suffix zum Quoten
+ ::rtl::OUString aCreateParams; // Parameter zum Erstellen
+ ::rtl::OUString aLocalTypeName;
+
+ sal_Int32 nPrecision; // Laenge des Types
+
+ sal_Int16 nMaximumScale; // Nachkommastellen
+ sal_Int16 nMinimumScale; // Min Nachkommastellen
+
+ sal_Int16 nType; // Datenbanktyp
+ sal_Int16 nSearchType; // kann nach dem Typen gesucht werden
+ sal_Int16 nNumPrecRadix; // indicating the radix, which is usually 2 or 10
+
+ sal_Bool bCurrency : 1, // Waehrung
+ bAutoIncrement : 1, // Ist es ein automatisch incrementierendes Feld
+ bNullable : 1, // Kann das Feld NULL annehmen
+ bCaseSensitive : 1, // Ist der Type Casesensitive
+ bUnsigned : 1, // Ist der 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 ) SAL_THROW( () )
+ { return ::rtl_allocateMemory( nSize ); }
+ inline static void * SAL_CALL operator new( size_t nSize,void* _pHint ) SAL_THROW( () )
+ { return _pHint; }
+ inline static void SAL_CALL operator delete( void * pMem ) SAL_THROW( () )
+ { ::rtl_freeMemory( pMem ); }
+ inline static void SAL_CALL operator delete( void * pMem,void* _pHint ) SAL_THROW( () )
+ { }
+
+ 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 // _CONNECTIVITY_OTYPEINFO_HXX_
+
+
diff --git a/odk/examples/DevelopersGuide/Database/DriverSkeleton/SConnection.cxx b/odk/examples/DevelopersGuide/Database/DriverSkeleton/SConnection.cxx
new file mode 100644
index 000000000000..f96cfd8ed93b
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Database/DriverSkeleton/SConnection.cxx
@@ -0,0 +1,402 @@
+/*************************************************************************
+ *
+ * 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()
+{
+ relase_ChildImpl();
+}
+// -----------------------------------------------------------------------------
+//-----------------------------------------------------------------------------
+void OConnection::construct(const ::rtl::OUString& url,const Sequence< PropertyValue >& info) throw(SQLException)
+{
+ osl_incrementInterlockedCount( &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(RTL_CONSTASCII_USTRINGPARAM("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.compareToAscii(pTimeout))
+ pBegin->Value >>= nTimeout;
+ else if(!pBegin->Name.compareToAscii(pSilent))
+ pBegin->Value >>= bSilent;
+ else if(!pBegin->Name.compareToAscii(pUser))
+ {
+ pBegin->Value >>= aUID;
+ aDSN = aDSN + ::rtl::OUString::createFromAscii(";UID=") + aUID;
+ }
+ else if(!pBegin->Name.compareToAscii(pPwd))
+ {
+ pBegin->Value >>= aPWD;
+ aDSN = aDSN + ::rtl::OUString::createFromAscii(";PWD=") + aPWD;
+ }
+ else if(!pBegin->Name.compareToAscii(pUseCatalog))
+ {
+ pBegin->Value >>= m_bUseCatalog;
+ }
+ else if(!pBegin->Name.compareToAscii(pSysDrv))
+ {
+ pBegin->Value >>= aSysDrvSettings;
+ aDSN += ::rtl::OUString::createFromAscii(";");
+ aDSN += aSysDrvSettings;
+ }
+ }
+ m_sUser = aUID;
+
+ osl_decrementInterlockedCount( &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( ) throw(SQLException, RuntimeException)
+{
+ ::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 ) throw(SQLException, RuntimeException)
+{
+ ::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 ) throw(SQLException, RuntimeException)
+{
+ ::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 ) throw(SQLException, RuntimeException)
+{
+ ::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 ) throw(SQLException, RuntimeException)
+{
+ ::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( ) throw(SQLException, RuntimeException)
+{
+ ::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( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OConnection_BASE::rBHelper.bDisposed);
+
+ // when you database does support transactions you should commit here
+}
+// --------------------------------------------------------------------------------
+void SAL_CALL OConnection::rollback( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OConnection_BASE::rBHelper.bDisposed);
+
+
+ // same as commit but for the other case
+}
+// --------------------------------------------------------------------------------
+sal_Bool SAL_CALL OConnection::isClosed( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ // just simple -> we are close when we are disposed taht means someone called dispose(); (XComponent)
+ return OConnection_BASE::rBHelper.bDisposed;
+}
+// --------------------------------------------------------------------------------
+Reference< XDatabaseMetaData > SAL_CALL OConnection::getMetaData( ) throw(SQLException, RuntimeException)
+{
+ ::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 ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OConnection_BASE::rBHelper.bDisposed);
+
+ // set you connection to readonly
+}
+// --------------------------------------------------------------------------------
+sal_Bool SAL_CALL OConnection::isReadOnly( ) throw(SQLException, RuntimeException)
+{
+ ::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 ) throw(SQLException, RuntimeException)
+{
+ ::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 kjnow what to do
+}
+// --------------------------------------------------------------------------------
+::rtl::OUString SAL_CALL OConnection::getCatalog( ) throw(SQLException, RuntimeException)
+{
+ ::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 ) throw(SQLException, RuntimeException)
+{
+ ::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( ) throw(SQLException, RuntimeException)
+{
+ ::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( ) throw(SQLException, RuntimeException)
+{
+ ::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 ) throw(SQLException, RuntimeException)
+{
+ // the other way around
+}
+// --------------------------------------------------------------------------------
+// XCloseable
+void SAL_CALL OConnection::close( ) throw(SQLException, RuntimeException)
+{
+ // we just dispose us
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OConnection_BASE::rBHelper.bDisposed);
+
+ }
+ dispose();
+}
+// --------------------------------------------------------------------------------
+// XWarningsSupplier
+Any SAL_CALL OConnection::getWarnings( ) throw(SQLException, RuntimeException)
+{
+ // when you collected some warnings -> return it
+ return Any();
+}
+// --------------------------------------------------------------------------------
+void SAL_CALL OConnection::clearWarnings( ) throw(SQLException, RuntimeException)
+{
+ // you should clear your collected warnings here
+}
+//--------------------------------------------------------------------
+void OConnection::buildTypeInfo() throw( SQLException)
+{
+ ::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) == ColumnValue::NULLABLE;
+ 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 destroied 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();
+}
+// -----------------------------------------------------------------------------
+
+
+
diff --git a/odk/examples/DevelopersGuide/Database/DriverSkeleton/SConnection.hxx b/odk/examples/DevelopersGuide/Database/DriverSkeleton/SConnection.hxx
new file mode 100644
index 000000000000..17714d035f87
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Database/DriverSkeleton/SConnection.hxx
@@ -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.
+ *
+ *************************************************************************/
+
+#ifndef CONNECTIVITY_SCONNECTION_HXX
+#define CONNECTIVITY_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() throw( ::com::sun::star::sdbc::SQLException);
+
+ public:
+ virtual void construct( const ::rtl::OUString& url,const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& info) throw(::com::sun::star::sdbc::SQLException);
+
+ OConnection(SkeletonDriver* _pDriver);
+ virtual ~OConnection();
+
+ void closeAllStatements () throw( ::com::sun::star::sdbc::SQLException);
+
+ // OComponentHelper
+ virtual void SAL_CALL disposing(void);
+ // 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( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XPreparedStatement > SAL_CALL prepareStatement( const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XPreparedStatement > SAL_CALL prepareCall( const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL nativeSQL( const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setAutoCommit( sal_Bool autoCommit ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL getAutoCommit( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL commit( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL rollback( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL isClosed( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData > SAL_CALL getMetaData( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setReadOnly( sal_Bool readOnly ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL isReadOnly( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setCatalog( const ::rtl::OUString& catalog ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getCatalog( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setTransactionIsolation( sal_Int32 level ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getTransactionIsolation( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > SAL_CALL getTypeMap( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setTypeMap( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& typeMap ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ // XCloseable
+ virtual void SAL_CALL close( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ // XWarningsSupplier
+ virtual ::com::sun::star::uno::Any SAL_CALL getWarnings( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL clearWarnings( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ //
+
+ // 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 // CONNECTIVITY_SCONNECTION_HXX
+
diff --git a/odk/examples/DevelopersGuide/Database/DriverSkeleton/SDatabaseMetaData.cxx b/odk/examples/DevelopersGuide/Database/DriverSkeleton/SDatabaseMetaData.cxx
new file mode 100644
index 000000000000..8704efd6ca64
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Database/DriverSkeleton/SDatabaseMetaData.cxx
@@ -0,0 +1,887 @@
+/*************************************************************************
+ *
+ * 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_incrementInterlockedCount( &m_refCount );
+ m_bUseCatalog = !(usesLocalFiles() || usesLocalFilePerTable());
+ osl_decrementInterlockedCount( &m_refCount );
+ }
+}
+// -------------------------------------------------------------------------
+ODatabaseMetaData::~ODatabaseMetaData()
+{
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL ODatabaseMetaData::getCatalogSeparator( ) throw(SQLException, RuntimeException)
+{
+ ::rtl::OUString aVal;
+ if(m_bUseCatalog)
+ { // do some special here for you database
+ }
+
+ return aVal;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL ODatabaseMetaData::getMaxBinaryLiteralLength( ) throw(SQLException, RuntimeException)
+{
+ sal_Int32 nValue = 0; // 0 means no limit
+ return nValue;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL ODatabaseMetaData::getMaxRowSize( ) throw(SQLException, RuntimeException)
+{
+ sal_Int32 nValue = 0; // 0 means no limit
+ return nValue;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL ODatabaseMetaData::getMaxCatalogNameLength( ) throw(SQLException, RuntimeException)
+{
+ sal_Int32 nValue = 0; // 0 means no limit
+ return nValue;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL ODatabaseMetaData::getMaxCharLiteralLength( ) throw(SQLException, RuntimeException)
+{
+ sal_Int32 nValue = 0; // 0 means no limit
+ return nValue;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL ODatabaseMetaData::getMaxColumnNameLength( ) throw(SQLException, RuntimeException)
+{
+ sal_Int32 nValue = 0; // 0 means no limit
+ return nValue;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL ODatabaseMetaData::getMaxColumnsInIndex( ) throw(SQLException, RuntimeException)
+{
+ sal_Int32 nValue = 0; // 0 means no limit
+ return nValue;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL ODatabaseMetaData::getMaxCursorNameLength( ) throw(SQLException, RuntimeException)
+{
+ sal_Int32 nValue = 0; // 0 means no limit
+ return nValue;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL ODatabaseMetaData::getMaxConnections( ) throw(SQLException, RuntimeException)
+{
+ sal_Int32 nValue = 0; // 0 means no limit
+ return nValue;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL ODatabaseMetaData::getMaxColumnsInTable( ) throw(SQLException, RuntimeException)
+{
+ sal_Int32 nValue = 0; // 0 means no limit
+ return nValue;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL ODatabaseMetaData::getMaxStatementLength( ) throw(SQLException, RuntimeException)
+{
+ sal_Int32 nValue = 0; // 0 means no limit
+ return nValue;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL ODatabaseMetaData::getMaxTableNameLength( ) throw(SQLException, RuntimeException)
+{
+ sal_Int32 nValue = 0; // 0 means no limit
+ return nValue;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL ODatabaseMetaData::getMaxTablesInSelect( ) throw(SQLException, RuntimeException)
+{
+ sal_Int32 nValue = 0; // 0 means no limit
+ return nValue;
+}
+// -------------------------------------------------------------------------
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::doesMaxRowSizeIncludeBlobs( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::storesLowerCaseQuotedIdentifiers( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::storesLowerCaseIdentifiers( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::storesMixedCaseQuotedIdentifiers( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::storesMixedCaseIdentifiers( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::storesUpperCaseQuotedIdentifiers( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::storesUpperCaseIdentifiers( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsAlterTableWithAddColumn( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsAlterTableWithDropColumn( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL ODatabaseMetaData::getMaxIndexLength( ) throw(SQLException, RuntimeException)
+{
+ sal_Int32 nValue = 0; // 0 means no limit
+ return nValue;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsNonNullableColumns( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL ODatabaseMetaData::getCatalogTerm( ) throw(SQLException, RuntimeException)
+{
+ ::rtl::OUString aVal;
+ if(m_bUseCatalog)
+ {
+ }
+ return aVal;
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL ODatabaseMetaData::getIdentifierQuoteString( ) throw(SQLException, RuntimeException)
+{
+ // normally this is "
+ ::rtl::OUString aVal = ::rtl::OUString::createFromAscii("\"");
+ return aVal;
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL ODatabaseMetaData::getExtraNameCharacters( ) throw(SQLException, RuntimeException)
+{
+ ::rtl::OUString aVal;
+ return aVal;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsDifferentTableCorrelationNames( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::isCatalogAtStart( ) throw(SQLException, RuntimeException)
+{
+ sal_Bool bValue = sal_False;
+ if(m_bUseCatalog)
+ {
+ }
+ return bValue;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::dataDefinitionIgnoredInTransactions( ) throw(SQLException, RuntimeException)
+{
+ return sal_True;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::dataDefinitionCausesTransactionCommit( ) throw(SQLException, RuntimeException)
+{
+ return sal_True;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsDataManipulationTransactionsOnly( ) throw(SQLException, RuntimeException)
+{
+ return sal_True;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsDataDefinitionAndDataManipulationTransactions( ) throw(SQLException, RuntimeException)
+{
+ return sal_True;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsPositionedDelete( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsPositionedUpdate( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsOpenStatementsAcrossRollback( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsOpenStatementsAcrossCommit( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsOpenCursorsAcrossCommit( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsOpenCursorsAcrossRollback( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsTransactionIsolationLevel( sal_Int32 level ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsSchemasInDataManipulation( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsANSI92FullSQL( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsANSI92EntryLevelSQL( ) throw(SQLException, RuntimeException)
+{
+ return sal_True; // should be supported at least
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsIntegrityEnhancementFacility( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsSchemasInIndexDefinitions( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsSchemasInTableDefinitions( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsCatalogsInTableDefinitions( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsCatalogsInIndexDefinitions( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsCatalogsInDataManipulation( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsOuterJoins( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL ODatabaseMetaData::getMaxStatements( ) throw(SQLException, RuntimeException)
+{
+ sal_Int32 nValue = 0; // 0 means no limit
+ return nValue;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL ODatabaseMetaData::getMaxProcedureNameLength( ) throw(SQLException, RuntimeException)
+{
+ sal_Int32 nValue = 0; // 0 means no limit
+ return nValue;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL ODatabaseMetaData::getMaxSchemaNameLength( ) throw(SQLException, RuntimeException)
+{
+ sal_Int32 nValue = 0; // 0 means no limit
+ return nValue;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsTransactions( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::allProceduresAreCallable( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsStoredProcedures( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsSelectForUpdate( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::allTablesAreSelectable( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::isReadOnly( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::usesLocalFiles( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::usesLocalFilePerTable( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsTypeConversion( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::nullPlusNonNullIsNull( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsColumnAliasing( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsTableCorrelationNames( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsConvert( sal_Int32 fromType, sal_Int32 toType ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsExpressionsInOrderBy( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsGroupBy( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsGroupByBeyondSelect( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsGroupByUnrelated( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsMultipleTransactions( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsMultipleResultSets( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsLikeEscapeClause( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsOrderByUnrelated( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsUnion( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsUnionAll( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsMixedCaseIdentifiers( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsMixedCaseQuotedIdentifiers( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::nullsAreSortedAtEnd( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::nullsAreSortedAtStart( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::nullsAreSortedHigh( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::nullsAreSortedLow( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsSchemasInProcedureCalls( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsSchemasInPrivilegeDefinitions( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsCatalogsInProcedureCalls( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsCatalogsInPrivilegeDefinitions( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsCorrelatedSubqueries( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsSubqueriesInComparisons( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsSubqueriesInExists( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsSubqueriesInIns( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsSubqueriesInQuantifieds( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsANSI92IntermediateSQL( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL ODatabaseMetaData::getURL( ) throw(SQLException, RuntimeException)
+{
+ ::rtl::OUString aValue = ::rtl::OUString::createFromAscii("sdbc:skeleton:");
+ return aValue;
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL ODatabaseMetaData::getUserName( ) throw(SQLException, RuntimeException)
+{
+ ::rtl::OUString aValue;
+ return aValue;
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL ODatabaseMetaData::getDriverName( ) throw(SQLException, RuntimeException)
+{
+ ::rtl::OUString aValue;
+ return aValue;
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL ODatabaseMetaData::getDriverVersion() throw(SQLException, RuntimeException)
+{
+ ::rtl::OUString aValue;
+ return aValue;
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL ODatabaseMetaData::getDatabaseProductVersion( ) throw(SQLException, RuntimeException)
+{
+ ::rtl::OUString aValue;
+ return aValue;
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL ODatabaseMetaData::getDatabaseProductName( ) throw(SQLException, RuntimeException)
+{
+ ::rtl::OUString aValue;
+ return aValue;
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL ODatabaseMetaData::getProcedureTerm( ) throw(SQLException, RuntimeException)
+{
+ ::rtl::OUString aValue;
+ return aValue;
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL ODatabaseMetaData::getSchemaTerm( ) throw(SQLException, RuntimeException)
+{
+ ::rtl::OUString aValue;
+ return aValue;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL ODatabaseMetaData::getDriverMajorVersion( ) throw(RuntimeException)
+{
+ return 1;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL ODatabaseMetaData::getDefaultTransactionIsolation( ) throw(SQLException, RuntimeException)
+{
+ return TransactionIsolation::NONE;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL ODatabaseMetaData::getDriverMinorVersion( ) throw(RuntimeException)
+{
+ return 0;
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL ODatabaseMetaData::getSQLKeywords( ) throw(SQLException, RuntimeException)
+{
+ ::rtl::OUString aValue;
+ return aValue;
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL ODatabaseMetaData::getSearchStringEscape( ) throw(SQLException, RuntimeException)
+{
+ ::rtl::OUString aValue;
+ return aValue;
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL ODatabaseMetaData::getStringFunctions( ) throw(SQLException, RuntimeException)
+{
+ return ::rtl::OUString();
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL ODatabaseMetaData::getTimeDateFunctions( ) throw(SQLException, RuntimeException)
+{
+ return ::rtl::OUString();
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL ODatabaseMetaData::getSystemFunctions( ) throw(SQLException, RuntimeException)
+{
+ return ::rtl::OUString();
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL ODatabaseMetaData::getNumericFunctions( ) throw(SQLException, RuntimeException)
+{
+ return ::rtl::OUString();
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsExtendedSQLGrammar( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsCoreSQLGrammar( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsMinimumSQLGrammar( ) throw(SQLException, RuntimeException)
+{
+ return sal_True;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsFullOuterJoins( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsLimitedOuterJoins( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL ODatabaseMetaData::getMaxColumnsInGroupBy( ) throw(SQLException, RuntimeException)
+{
+ sal_Int32 nValue = 0; // 0 means no limit
+ return nValue;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL ODatabaseMetaData::getMaxColumnsInOrderBy( ) throw(SQLException, RuntimeException)
+{
+ sal_Int32 nValue = 0; // 0 means no limit
+ return nValue;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL ODatabaseMetaData::getMaxColumnsInSelect( ) throw(SQLException, RuntimeException)
+{
+ sal_Int32 nValue = 0; // 0 means no limit
+ return nValue;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL ODatabaseMetaData::getMaxUserNameLength( ) throw(SQLException, RuntimeException)
+{
+ sal_Int32 nValue = 0; // 0 means no limit
+ return nValue;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsResultSetType( sal_Int32 setType ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsResultSetConcurrency( sal_Int32 setType, sal_Int32 concurrency ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::ownUpdatesAreVisible( sal_Int32 setType ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::ownDeletesAreVisible( sal_Int32 setType ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::ownInsertsAreVisible( sal_Int32 setType ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::othersUpdatesAreVisible( sal_Int32 setType ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::othersDeletesAreVisible( sal_Int32 setType ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::othersInsertsAreVisible( sal_Int32 setType ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::updatesAreDetected( sal_Int32 setType ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::deletesAreDetected( sal_Int32 setType ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::insertsAreDetected( sal_Int32 setType ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsBatchUpdates( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+Reference< XConnection > SAL_CALL ODatabaseMetaData::getConnection( ) throw(SQLException, RuntimeException)
+{
+ 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( ) throw(SQLException, RuntimeException)
+{
+ return NULL;
+}
+// -------------------------------------------------------------------------
+Reference< XResultSet > SAL_CALL ODatabaseMetaData::getTypeInfo( ) throw(SQLException, RuntimeException)
+{
+ return NULL;
+}
+// -------------------------------------------------------------------------
+Reference< XResultSet > SAL_CALL ODatabaseMetaData::getCatalogs( ) throw(SQLException, RuntimeException)
+{
+ return NULL;
+}
+// -----------------------------------------------------------------------------
+Reference< XResultSet > SAL_CALL ODatabaseMetaData::getSchemas( ) throw(SQLException, RuntimeException)
+{
+ return NULL;
+}
+// -------------------------------------------------------------------------
+Reference< XResultSet > SAL_CALL ODatabaseMetaData::getColumnPrivileges(
+ const Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table,
+ const ::rtl::OUString& columnNamePattern ) throw(SQLException, RuntimeException)
+{
+ return NULL;
+}
+// -------------------------------------------------------------------------
+Reference< XResultSet > SAL_CALL ODatabaseMetaData::getColumns(
+ const Any& catalog, const ::rtl::OUString& schemaPattern, const ::rtl::OUString& tableNamePattern,
+ const ::rtl::OUString& columnNamePattern ) throw(SQLException, RuntimeException)
+{
+ return NULL;
+}
+// -------------------------------------------------------------------------
+Reference< XResultSet > SAL_CALL ODatabaseMetaData::getTables(
+ const Any& catalog, const ::rtl::OUString& schemaPattern,
+ const ::rtl::OUString& tableNamePattern, const Sequence< ::rtl::OUString >& types ) throw(SQLException, RuntimeException)
+{
+ return NULL;
+}
+// -------------------------------------------------------------------------
+Reference< XResultSet > SAL_CALL ODatabaseMetaData::getProcedureColumns(
+ const Any& catalog, const ::rtl::OUString& schemaPattern,
+ const ::rtl::OUString& procedureNamePattern, const ::rtl::OUString& columnNamePattern ) throw(SQLException, RuntimeException)
+{
+ return NULL;
+}
+// -------------------------------------------------------------------------
+Reference< XResultSet > SAL_CALL ODatabaseMetaData::getProcedures(
+ const Any& catalog, const ::rtl::OUString& schemaPattern,
+ const ::rtl::OUString& procedureNamePattern ) throw(SQLException, RuntimeException)
+{
+ return NULL;
+}
+// -------------------------------------------------------------------------
+Reference< XResultSet > SAL_CALL ODatabaseMetaData::getVersionColumns(
+ const Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table ) throw(SQLException, RuntimeException)
+{
+ return NULL;
+}
+// -------------------------------------------------------------------------
+Reference< XResultSet > SAL_CALL ODatabaseMetaData::getExportedKeys(
+ const Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table ) throw(SQLException, RuntimeException)
+{
+ return NULL;
+}
+// -------------------------------------------------------------------------
+Reference< XResultSet > SAL_CALL ODatabaseMetaData::getImportedKeys(
+ const Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table ) throw(SQLException, RuntimeException)
+{
+ return NULL;
+}
+// -------------------------------------------------------------------------
+Reference< XResultSet > SAL_CALL ODatabaseMetaData::getPrimaryKeys(
+ const Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table ) throw(SQLException, RuntimeException)
+{
+ 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 ) throw(SQLException, RuntimeException)
+{
+ 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 ) throw(SQLException, RuntimeException)
+{
+ return NULL;
+}
+// -------------------------------------------------------------------------
+Reference< XResultSet > SAL_CALL ODatabaseMetaData::getTablePrivileges(
+ const Any& catalog, const ::rtl::OUString& schemaPattern, const ::rtl::OUString& tableNamePattern ) throw(SQLException, RuntimeException)
+{
+ 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 ) throw(SQLException, RuntimeException)
+{
+ return NULL;
+}
+// -------------------------------------------------------------------------
+Reference< XResultSet > SAL_CALL ODatabaseMetaData::getUDTs( const Any& catalog, const ::rtl::OUString& schemaPattern, const ::rtl::OUString& typeNamePattern, const Sequence< sal_Int32 >& types ) throw(SQLException, RuntimeException)
+{
+ OSL_ENSURE(0,"Not implemented yet!");
+ throw SQLException();
+ return NULL;
+}
+// -----------------------------------------------------------------------------
+
+
+
diff --git a/odk/examples/DevelopersGuide/Database/DriverSkeleton/SDatabaseMetaData.hxx b/odk/examples/DevelopersGuide/Database/DriverSkeleton/SDatabaseMetaData.hxx
new file mode 100644
index 000000000000..8f0a3f506a13
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Database/DriverSkeleton/SDatabaseMetaData.hxx
@@ -0,0 +1,218 @@
+/*************************************************************************
+ *
+ * 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 CONNECTIVITY_SDATABASEMETADATA_HXX
+#define CONNECTIVITY_SDATABASEMETADATA_HXX
+
+#include "SConnection.hxx"
+#include <com/sun/star/sdbc/XDatabaseMetaData.hpp>
+#include <cppuhelper/implbase1.hxx>
+
+namespace connectivity
+{
+ namespace skeleton
+ {
+ //**************************************************************
+ //************ Class: ODatabaseMetaData
+ //**************************************************************
+
+ 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( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL allTablesAreSelectable( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getURL( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getUserName( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL isReadOnly( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL nullsAreSortedHigh( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL nullsAreSortedLow( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL nullsAreSortedAtStart( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL nullsAreSortedAtEnd( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getDatabaseProductName( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getDatabaseProductVersion( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getDriverName( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getDriverVersion( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getDriverMajorVersion( ) throw(::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getDriverMinorVersion( ) throw(::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL usesLocalFiles( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL usesLocalFilePerTable( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsMixedCaseIdentifiers( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL storesUpperCaseIdentifiers( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL storesLowerCaseIdentifiers( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL storesMixedCaseIdentifiers( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsMixedCaseQuotedIdentifiers( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL storesUpperCaseQuotedIdentifiers( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL storesLowerCaseQuotedIdentifiers( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL storesMixedCaseQuotedIdentifiers( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getIdentifierQuoteString( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getSQLKeywords( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getNumericFunctions( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getStringFunctions( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getSystemFunctions( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getTimeDateFunctions( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getSearchStringEscape( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getExtraNameCharacters( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsAlterTableWithAddColumn( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsAlterTableWithDropColumn( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsColumnAliasing( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL nullPlusNonNullIsNull( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsTypeConversion( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsConvert( sal_Int32 fromType, sal_Int32 toType ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsTableCorrelationNames( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsDifferentTableCorrelationNames( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsExpressionsInOrderBy( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsOrderByUnrelated( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsGroupBy( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsGroupByUnrelated( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsGroupByBeyondSelect( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsLikeEscapeClause( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsMultipleResultSets( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsMultipleTransactions( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsNonNullableColumns( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsMinimumSQLGrammar( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsCoreSQLGrammar( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsExtendedSQLGrammar( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsANSI92EntryLevelSQL( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsANSI92IntermediateSQL( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsANSI92FullSQL( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsIntegrityEnhancementFacility( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsOuterJoins( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsFullOuterJoins( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsLimitedOuterJoins( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getSchemaTerm( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getProcedureTerm( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getCatalogTerm( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL isCatalogAtStart( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getCatalogSeparator( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsSchemasInDataManipulation( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsSchemasInProcedureCalls( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsSchemasInTableDefinitions( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsSchemasInIndexDefinitions( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsSchemasInPrivilegeDefinitions( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsCatalogsInDataManipulation( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsCatalogsInProcedureCalls( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsCatalogsInTableDefinitions( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsCatalogsInIndexDefinitions( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsCatalogsInPrivilegeDefinitions( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsPositionedDelete( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsPositionedUpdate( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsSelectForUpdate( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsStoredProcedures( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsSubqueriesInComparisons( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsSubqueriesInExists( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsSubqueriesInIns( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsSubqueriesInQuantifieds( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsCorrelatedSubqueries( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsUnion( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsUnionAll( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsOpenCursorsAcrossCommit( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsOpenCursorsAcrossRollback( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsOpenStatementsAcrossCommit( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsOpenStatementsAcrossRollback( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getMaxBinaryLiteralLength( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getMaxCharLiteralLength( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getMaxColumnNameLength( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getMaxColumnsInGroupBy( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getMaxColumnsInIndex( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getMaxColumnsInOrderBy( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getMaxColumnsInSelect( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getMaxColumnsInTable( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getMaxConnections( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getMaxCursorNameLength( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getMaxIndexLength( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getMaxSchemaNameLength( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getMaxProcedureNameLength( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getMaxCatalogNameLength( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getMaxRowSize( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL doesMaxRowSizeIncludeBlobs( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getMaxStatementLength( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getMaxStatements( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getMaxTableNameLength( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getMaxTablesInSelect( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getMaxUserNameLength( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getDefaultTransactionIsolation( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsTransactions( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsTransactionIsolationLevel( sal_Int32 level ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsDataDefinitionAndDataManipulationTransactions( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsDataManipulationTransactionsOnly( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL dataDefinitionCausesTransactionCommit( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL dataDefinitionIgnoredInTransactions( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ 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 ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ 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 ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ 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 ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getSchemas( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getCatalogs( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getTableTypes( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ 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 ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ 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 ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ 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 ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ 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 ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ 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 ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ 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 ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ 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 ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ 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 ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ 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 ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getTypeInfo( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ 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 ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsResultSetType( sal_Int32 setType ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsResultSetConcurrency( sal_Int32 setType, sal_Int32 concurrency ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL ownUpdatesAreVisible( sal_Int32 setType ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL ownDeletesAreVisible( sal_Int32 setType ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL ownInsertsAreVisible( sal_Int32 setType ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL othersUpdatesAreVisible( sal_Int32 setType ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL othersDeletesAreVisible( sal_Int32 setType ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL othersInsertsAreVisible( sal_Int32 setType ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL updatesAreDetected( sal_Int32 setType ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL deletesAreDetected( sal_Int32 setType ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL insertsAreDetected( sal_Int32 setType ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsBatchUpdates( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ 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 ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > SAL_CALL getConnection( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ };
+ }
+}
+
+#endif // CONNECTIVITY_SDATABASEMETADATA_HXX
diff --git a/odk/examples/DevelopersGuide/Database/DriverSkeleton/SDriver.cxx b/odk/examples/DevelopersGuide/Database/DriverSkeleton/SDriver.cxx
new file mode 100644
index 000000000000..39fd5ce42f32
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Database/DriverSkeleton/SDriver.cxx
@@ -0,0 +1,210 @@
+/*************************************************************************
+ *
+ * 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 "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) throw( ::com::sun::star::uno::Exception )
+ {
+ return *(new SkeletonDriver());
+ }
+ }
+}
+// --------------------------------------------------------------------------------
+SkeletonDriver::SkeletonDriver()
+ : ODriver_BASE(m_aMutex)
+{
+}
+// --------------------------------------------------------------------------------
+void SkeletonDriver::disposing()
+{
+ ::osl::MutexGuard aGuard(m_aMutex);
+
+ // when driver will be destroied so all our connections have to be destroied 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( ) throw(RuntimeException)
+{
+ return rtl::OUString::createFromAscii("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( ) throw (RuntimeException)
+{
+ // which service is supported
+ // for more information @see com.sun.star.sdbc.Driver
+ Sequence< ::rtl::OUString > aSNS( 1 );
+ aSNS[0] = ::rtl::OUString::createFromAscii("com.sun.star.sdbc.Driver");
+ return aSNS;
+}
+
+//------------------------------------------------------------------
+::rtl::OUString SAL_CALL SkeletonDriver::getImplementationName( ) throw(RuntimeException)
+{
+ return getImplementationName_Static();
+}
+
+//------------------------------------------------------------------
+sal_Bool SAL_CALL SkeletonDriver::supportsService( const ::rtl::OUString& _rServiceName ) throw(RuntimeException)
+{
+ Sequence< ::rtl::OUString > aSupported(getSupportedServiceNames());
+ const ::rtl::OUString* pSupported = aSupported.getConstArray();
+ const ::rtl::OUString* pEnd = pSupported + aSupported.getLength();
+ for (;pSupported != pEnd && !pSupported->equals(_rServiceName); ++pSupported)
+ ;
+
+ return pSupported != pEnd;
+}
+
+//------------------------------------------------------------------
+Sequence< ::rtl::OUString > SAL_CALL SkeletonDriver::getSupportedServiceNames( ) throw(RuntimeException)
+{
+ return getSupportedServiceNames_Static();
+}
+
+// --------------------------------------------------------------------------------
+Reference< XConnection > SAL_CALL SkeletonDriver::connect( const ::rtl::OUString& url, const Sequence< PropertyValue >& info ) throw(SQLException, RuntimeException)
+{
+ // 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 )
+ throw(SQLException, RuntimeException)
+{
+ // 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.compareTo(::rtl::OUString::createFromAscii("sdbc:skeleton:"),14));
+}
+// --------------------------------------------------------------------------------
+Sequence< DriverPropertyInfo > SAL_CALL SkeletonDriver::getPropertyInfo( const ::rtl::OUString& url, const Sequence< PropertyValue >& info ) throw(SQLException, RuntimeException)
+{
+ // if you have somthing special to say, return it here :-)
+ return Sequence< DriverPropertyInfo >();
+}
+// --------------------------------------------------------------------------------
+sal_Int32 SAL_CALL SkeletonDriver::getMajorVersion( ) throw(RuntimeException)
+{
+ return 0; // depends on you
+}
+// --------------------------------------------------------------------------------
+sal_Int32 SAL_CALL SkeletonDriver::getMinorVersion( ) throw(RuntimeException)
+{
+ 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_decrementInterlockedCount( &_refCount ) == 0)
+ {
+ osl_incrementInterlockedCount( &_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_incrementInterlockedCount( &_refCount );
+}
+
+void checkDisposed(sal_Bool _bThrow) throw ( DisposedException )
+{
+ if (_bThrow)
+ throw DisposedException();
+
+}
+//.........................................................................
+ }
+}
+//.........................................................................
+
diff --git a/odk/examples/DevelopersGuide/Database/DriverSkeleton/SDriver.hxx b/odk/examples/DevelopersGuide/Database/DriverSkeleton/SDriver.hxx
new file mode 100644
index 000000000000..077ebab73d50
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Database/DriverSkeleton/SDriver.hxx
@@ -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.
+ *
+ *************************************************************************/
+
+#ifndef CONNECTIVITY_SDRIVER_HXX
+#define CONNECTIVITY_SDRIVER_HXX
+
+#include <com/sun/star/sdbc/XDriver.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <cppuhelper/compbase2.hxx>
+#include "SConnection.hxx"
+
+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) throw( ::com::sun::star::uno::Exception );
+
+ 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(void);
+ // XInterface
+ static ::rtl::OUString getImplementationName_Static( ) throw(::com::sun::star::uno::RuntimeException);
+ static ::com::sun::star::uno::Sequence< ::rtl::OUString > getSupportedServiceNames_Static( ) throw (::com::sun::star::uno::RuntimeException);
+
+ // XServiceInfo
+ virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw(::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw(::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw(::com::sun::star::uno::RuntimeException);
+
+ // 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 ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL acceptsURL( const ::rtl::OUString& url ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ 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 ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getMajorVersion( ) throw(::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getMinorVersion( ) throw(::com::sun::star::uno::RuntimeException);
+ };
+ }
+
+}
+
+#endif // CONNECTIVITY_SDRIVER_HXX
diff --git a/odk/examples/DevelopersGuide/Database/DriverSkeleton/SPreparedStatement.cxx b/odk/examples/DevelopersGuide/Database/DriverSkeleton/SPreparedStatement.cxx
new file mode 100644
index 000000000000..2f6cd42e96f7
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Database/DriverSkeleton/SPreparedStatement.cxx
@@ -0,0 +1,388 @@
+/*************************************************************************
+ *
+ * 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/diagnose.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 ) throw(RuntimeException)
+{
+ 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( ) throw(::com::sun::star::uno::RuntimeException)
+{
+ return concatSequences(OPreparedStatement_BASE::getTypes(),OStatement_BASE2::getTypes());
+}
+// -------------------------------------------------------------------------
+
+Reference< XResultSetMetaData > SAL_CALL OPreparedStatement::getMetaData( ) throw(SQLException, RuntimeException)
+{
+ ::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( ) throw(SQLException, RuntimeException)
+{
+ ::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( ) throw(SQLException, RuntimeException)
+{
+ ::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( ) throw(SQLException, RuntimeException)
+{
+ ::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 ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OStatement_BASE::rBHelper.bDisposed);
+}
+// -------------------------------------------------------------------------
+
+Reference< XConnection > SAL_CALL OPreparedStatement::getConnection( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OStatement_BASE::rBHelper.bDisposed);
+
+ return (Reference< XConnection >)m_pConnection;
+}
+// -------------------------------------------------------------------------
+
+Reference< XResultSet > SAL_CALL OPreparedStatement::executeQuery( ) throw(SQLException, RuntimeException)
+{
+ ::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 ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OStatement_BASE::rBHelper.bDisposed);
+
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OPreparedStatement::setByte( sal_Int32 parameterIndex, sal_Int8 x ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OStatement_BASE::rBHelper.bDisposed);
+
+
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OPreparedStatement::setDate( sal_Int32 parameterIndex, const Date& aData ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OStatement_BASE::rBHelper.bDisposed);
+
+}
+// -------------------------------------------------------------------------
+
+
+void SAL_CALL OPreparedStatement::setTime( sal_Int32 parameterIndex, const Time& aVal ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OStatement_BASE::rBHelper.bDisposed);
+
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OPreparedStatement::setTimestamp( sal_Int32 parameterIndex, const DateTime& aVal ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OStatement_BASE::rBHelper.bDisposed);
+
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OPreparedStatement::setDouble( sal_Int32 parameterIndex, double x ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OStatement_BASE::rBHelper.bDisposed);
+
+}
+
+// -------------------------------------------------------------------------
+
+void SAL_CALL OPreparedStatement::setFloat( sal_Int32 parameterIndex, float x ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OStatement_BASE::rBHelper.bDisposed);
+
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OPreparedStatement::setInt( sal_Int32 parameterIndex, sal_Int32 x ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OStatement_BASE::rBHelper.bDisposed);
+
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OPreparedStatement::setLong( sal_Int32 parameterIndex, sal_Int64 aVal ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OStatement_BASE::rBHelper.bDisposed);
+
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OPreparedStatement::setNull( sal_Int32 parameterIndex, sal_Int32 sqlType ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OStatement_BASE::rBHelper.bDisposed);
+
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OPreparedStatement::setClob( sal_Int32 parameterIndex, const Reference< XClob >& x ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OStatement_BASE::rBHelper.bDisposed);
+
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OPreparedStatement::setBlob( sal_Int32 parameterIndex, const Reference< XBlob >& x ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OStatement_BASE::rBHelper.bDisposed);
+
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OPreparedStatement::setArray( sal_Int32 parameterIndex, const Reference< XArray >& x ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OStatement_BASE::rBHelper.bDisposed);
+
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OPreparedStatement::setRef( sal_Int32 parameterIndex, const Reference< XRef >& x ) throw(SQLException, RuntimeException)
+{
+ ::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 ) throw(SQLException, RuntimeException)
+{
+ 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 ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OStatement_BASE::rBHelper.bDisposed);
+
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OPreparedStatement::setObject( sal_Int32 parameterIndex, const Any& x ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OStatement_BASE::rBHelper.bDisposed);
+
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OPreparedStatement::setShort( sal_Int32 parameterIndex, sal_Int16 x ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OStatement_BASE::rBHelper.bDisposed);
+
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OPreparedStatement::setBytes( sal_Int32 parameterIndex, const Sequence< sal_Int8 >& x ) throw(SQLException, RuntimeException)
+{
+ ::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 ) throw(SQLException, RuntimeException)
+{
+ ::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 ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OStatement_BASE::rBHelper.bDisposed);
+
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OPreparedStatement::clearParameters( ) throw(SQLException, RuntimeException)
+{
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OPreparedStatement::clearBatch( ) throw(SQLException, RuntimeException)
+{
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OPreparedStatement::addBatch( ) throw(SQLException, RuntimeException)
+{
+}
+// -------------------------------------------------------------------------
+
+Sequence< sal_Int32 > SAL_CALL OPreparedStatement::executeBatch( ) throw(SQLException, RuntimeException)
+{
+ return Sequence< sal_Int32 > ();
+}
+// -------------------------------------------------------------------------
+void OPreparedStatement::setFastPropertyValue_NoBroadcast(sal_Int32 nHandle,const Any& rValue) throw (Exception)
+{
+ 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();
+}
+// -----------------------------------------------------------------------------
+
+
diff --git a/odk/examples/DevelopersGuide/Database/DriverSkeleton/SPreparedStatement.hxx b/odk/examples/DevelopersGuide/Database/DriverSkeleton/SPreparedStatement.hxx
new file mode 100644
index 000000000000..21c22e46792a
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Database/DriverSkeleton/SPreparedStatement.hxx
@@ -0,0 +1,146 @@
+/*************************************************************************
+ *
+ * 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 CONNECTIVITY_SPREPAREDSTATEMENT_HXX
+#define CONNECTIVITY_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)
+ throw (::com::sun::star::uno::Exception);
+ virtual ~OPreparedStatement();
+ public:
+ DECLARE_SERVICE_INFO();
+ // ein Konstruktor, der fuer das Returnen des Objektes benoetigt wird:
+ 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 ) throw(::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL acquire() throw();
+ virtual void SAL_CALL release() throw();
+ //XTypeProvider
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes( ) throw(::com::sun::star::uno::RuntimeException);
+
+ // XPreparedStatement
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL executeQuery( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL executeUpdate( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL execute( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > SAL_CALL getConnection( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ // XParameters
+ virtual void SAL_CALL setNull( sal_Int32 parameterIndex, sal_Int32 sqlType ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setObjectNull( sal_Int32 parameterIndex, sal_Int32 sqlType, const ::rtl::OUString& typeName ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setBoolean( sal_Int32 parameterIndex, sal_Bool x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setByte( sal_Int32 parameterIndex, sal_Int8 x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setShort( sal_Int32 parameterIndex, sal_Int16 x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setInt( sal_Int32 parameterIndex, sal_Int32 x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setLong( sal_Int32 parameterIndex, sal_Int64 x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setFloat( sal_Int32 parameterIndex, float x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setDouble( sal_Int32 parameterIndex, double x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setString( sal_Int32 parameterIndex, const ::rtl::OUString& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setBytes( sal_Int32 parameterIndex, const ::com::sun::star::uno::Sequence< sal_Int8 >& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setDate( sal_Int32 parameterIndex, const ::com::sun::star::util::Date& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setTime( sal_Int32 parameterIndex, const ::com::sun::star::util::Time& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setTimestamp( sal_Int32 parameterIndex, const ::com::sun::star::util::DateTime& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setBinaryStream( sal_Int32 parameterIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setCharacterStream( sal_Int32 parameterIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setObject( sal_Int32 parameterIndex, const ::com::sun::star::uno::Any& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setObjectWithInfo( sal_Int32 parameterIndex, const ::com::sun::star::uno::Any& x, sal_Int32 targetSqlType, sal_Int32 scale ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setRef( sal_Int32 parameterIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRef >& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setBlob( sal_Int32 parameterIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XBlob >& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setClob( sal_Int32 parameterIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XClob >& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setArray( sal_Int32 parameterIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XArray >& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL clearParameters( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ // XPreparedBatchExecution
+ virtual void SAL_CALL addBatch( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL clearBatch( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< sal_Int32 > SAL_CALL executeBatch( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ // XCloseable
+ virtual void SAL_CALL close( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ // XResultSetMetaDataSupplier
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSetMetaData > SAL_CALL getMetaData( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ };
+ }
+}
+#endif // CONNECTIVITY_SPREPAREDSTATEMENT_HXX
diff --git a/odk/examples/DevelopersGuide/Database/DriverSkeleton/SResultSet.cxx b/odk/examples/DevelopersGuide/Database/DriverSkeleton/SResultSet.cxx
new file mode 100644
index 000000000000..be4e1f92e3b6
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Database/DriverSkeleton/SResultSet.cxx
@@ -0,0 +1,873 @@
+/*************************************************************************
+ *
+ * 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 <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( ) throw ( RuntimeException) \
+{
+ return ::rtl::OUString::createFromAscii("com.sun.star.sdbcx.skeleton.ResultSet");
+}
+// -------------------------------------------------------------------------
+ Sequence< ::rtl::OUString > SAL_CALL OResultSet::getSupportedServiceNames( ) throw( RuntimeException)
+{
+ Sequence< ::rtl::OUString > aSupported(2);
+ aSupported[0] = ::rtl::OUString::createFromAscii("com.sun.star.sdbc.ResultSet");
+ aSupported[1] = ::rtl::OUString::createFromAscii("com.sun.star.sdbcx.ResultSet");
+ return aSupported;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OResultSet::supportsService( const ::rtl::OUString& _rServiceName ) throw( RuntimeException)
+{
+ Sequence< ::rtl::OUString > aSupported(getSupportedServiceNames());
+ const ::rtl::OUString* pSupported = aSupported.getConstArray();
+ const ::rtl::OUString* pEnd = pSupported + aSupported.getLength();
+ for (;pSupported != pEnd && !pSupported->equals(_rServiceName); ++pSupported)
+ ;
+
+ return pSupported != pEnd;
+}
+
+// -------------------------------------------------------------------------
+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(void)
+{
+ OPropertySetHelper::disposing();
+
+ ::osl::MutexGuard aGuard(m_aMutex);
+
+ m_aStatement = NULL;
+ m_xMetaData = NULL;
+}
+// -------------------------------------------------------------------------
+Any SAL_CALL OResultSet::queryInterface( const Type & rType ) throw(RuntimeException)
+{
+ Any aRet = OPropertySetHelper::queryInterface(rType);
+ if(!aRet.hasValue())
+ aRet = OResultSet_BASE::queryInterface(rType);
+ return aRet;
+}
+// -------------------------------------------------------------------------
+ Sequence< Type > SAL_CALL OResultSet::getTypes( ) throw( RuntimeException)
+{
+ OTypeCollection aTypes(
+ ::cppu::UnoType< Reference< ::com::sun::star::beans::XMultiPropertySet > >::get(),
+ ::cppu::UnoType< Reference< ::com::sun::star::beans::XFastPropertySet > >::get(),
+ ::cppu::UnoType< Reference< ::com::sun::star::beans::XPropertySet > >::get());
+
+ return concatSequences(aTypes.getTypes(),OResultSet_BASE::getTypes());
+}
+// -------------------------------------------------------------------------
+
+sal_Int32 SAL_CALL OResultSet::findColumn( const ::rtl::OUString& columnName ) throw(SQLException, RuntimeException)
+{
+
+ 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 ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+
+ return NULL;
+}
+// -------------------------------------------------------------------------
+Reference< XInputStream > SAL_CALL OResultSet::getCharacterStream( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+
+ return NULL;
+}
+
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OResultSet::getBoolean( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+
+sal_Int8 SAL_CALL OResultSet::getByte( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ ::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 ) throw(SQLException, RuntimeException)
+{
+
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ return Sequence< sal_Int8 >();
+}
+// -------------------------------------------------------------------------
+
+Date SAL_CALL OResultSet::getDate( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+
+ Date nRet;
+ return nRet;
+}
+// -------------------------------------------------------------------------
+
+double SAL_CALL OResultSet::getDouble( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+
+ double nRet = 0;
+ return nRet;
+}
+// -------------------------------------------------------------------------
+
+float SAL_CALL OResultSet::getFloat( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+
+ float nVal(0);
+ return nVal;
+}
+// -------------------------------------------------------------------------
+
+sal_Int32 SAL_CALL OResultSet::getInt( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+ sal_Int32 nRet=0;
+ return nRet;
+}
+// -------------------------------------------------------------------------
+
+sal_Int32 SAL_CALL OResultSet::getRow( ) throw(SQLException, RuntimeException)
+{
+ ::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 ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+ return sal_Int64();
+}
+// -------------------------------------------------------------------------
+
+Reference< XResultSetMetaData > SAL_CALL OResultSet::getMetaData( ) throw(SQLException, RuntimeException)
+{
+ ::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 ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+ return NULL;
+}
+
+// -------------------------------------------------------------------------
+
+Reference< XClob > SAL_CALL OResultSet::getClob( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+ return NULL;
+}
+// -------------------------------------------------------------------------
+Reference< XBlob > SAL_CALL OResultSet::getBlob( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+ return NULL;
+}
+// -------------------------------------------------------------------------
+
+Reference< XRef > SAL_CALL OResultSet::getRef( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ ::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 ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+ return Any();
+}
+// -------------------------------------------------------------------------
+
+sal_Int16 SAL_CALL OResultSet::getShort( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ ::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 ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+
+ ::rtl::OUString nRet;
+ return nRet;
+}
+// -------------------------------------------------------------------------
+
+Time SAL_CALL OResultSet::getTime( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ Time nRet;
+ return nRet;
+}
+// -------------------------------------------------------------------------
+
+
+DateTime SAL_CALL OResultSet::getTimestamp( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ DateTime nRet;
+ return nRet;
+}
+// -------------------------------------------------------------------------
+
+sal_Bool SAL_CALL OResultSet::isBeforeFirst( ) throw(SQLException, RuntimeException)
+{
+ ::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( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+ return sal_True;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OResultSet::isFirst( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OResultSet::isLast( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OResultSet::beforeFirst( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+ // move before the first row so that isBeforeFirst returns false
+ // the smae for other movement methods
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OResultSet::afterLast( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OResultSet::close( ) throw(SQLException, RuntimeException)
+{
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+ }
+ dispose();
+}
+// -------------------------------------------------------------------------
+
+sal_Bool SAL_CALL OResultSet::first( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+
+sal_Bool SAL_CALL OResultSet::last( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OResultSet::absolute( sal_Int32 row ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OResultSet::relative( sal_Int32 row ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OResultSet::previous( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+Reference< XInterface > SAL_CALL OResultSet::getStatement( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+
+ return m_aStatement.get();
+}
+// -------------------------------------------------------------------------
+
+sal_Bool SAL_CALL OResultSet::rowDeleted( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OResultSet::rowInserted( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OResultSet::rowUpdated( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+
+sal_Bool SAL_CALL OResultSet::next( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+
+sal_Bool SAL_CALL OResultSet::wasNull( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+
+ return m_bWasNull;
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OResultSet::cancel( ) throw(RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OResultSet::clearWarnings( ) throw(SQLException, RuntimeException)
+{
+}
+// -------------------------------------------------------------------------
+Any SAL_CALL OResultSet::getWarnings( ) throw(SQLException, RuntimeException)
+{
+ return Any();
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OResultSet::insertRow( ) throw(SQLException, RuntimeException)
+{
+ ::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( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+
+ // only when you allow updates
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OResultSet::deleteRow( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OResultSet::cancelRowUpdates( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OResultSet::moveToInsertRow( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+
+ // only when you allow insert's
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OResultSet::moveToCurrentRow( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OResultSet::updateNull( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OResultSet::updateBoolean( sal_Int32 columnIndex, sal_Bool x ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OResultSet::updateByte( sal_Int32 columnIndex, sal_Int8 x ) throw(SQLException, RuntimeException)
+{
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OResultSet::updateShort( sal_Int32 columnIndex, sal_Int16 x ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OResultSet::updateInt( sal_Int32 columnIndex, sal_Int32 x ) throw(SQLException, RuntimeException)
+{
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OResultSet::updateLong( sal_Int32 columnIndex, sal_Int64 x ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+}
+// -----------------------------------------------------------------------
+void SAL_CALL OResultSet::updateFloat( sal_Int32 columnIndex, float x ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OResultSet::updateDouble( sal_Int32 columnIndex, double x ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OResultSet::updateString( sal_Int32 columnIndex, const ::rtl::OUString& x ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OResultSet::updateBytes( sal_Int32 columnIndex, const Sequence< sal_Int8 >& x ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OResultSet::updateDate( sal_Int32 columnIndex, const Date& x ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OResultSet::updateTime( sal_Int32 columnIndex, const Time& x ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OResultSet::updateTimestamp( sal_Int32 columnIndex, const DateTime& x ) throw(SQLException, RuntimeException)
+{
+ ::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 ) throw(SQLException, RuntimeException)
+{
+ ::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 ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OResultSet::refreshRow( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OResultSet::updateObject( sal_Int32 columnIndex, const Any& x ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OResultSet::updateNumericObject( sal_Int32 columnIndex, const Any& x, sal_Int32 scale ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+}
+// -------------------------------------------------------------------------
+// XRowLocate
+Any SAL_CALL OResultSet::getBookmark( ) throw( SQLException, RuntimeException)
+{
+ ::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 ) throw( SQLException, RuntimeException)
+{
+ ::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 ) throw( SQLException, RuntimeException)
+{
+ ::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 ) throw( SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+
+ return CompareBookmark::NOT_EQUAL;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OResultSet::hasOrderedBookmarks( ) throw( SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL OResultSet::hashBookmark( const Any& bookmark ) throw( SQLException, RuntimeException)
+{
+ throw SQLException();
+}
+// -------------------------------------------------------------------------
+// XDeleteRows
+Sequence< sal_Int32 > SAL_CALL OResultSet::deleteRows( const Sequence< Any >& rows ) throw( SQLException, RuntimeException)
+{
+ ::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;
+ DECL_PROP1IMPL(CURSORNAME, ::rtl::OUString) PropertyAttribute::READONLY);
+ DECL_PROP0(FETCHDIRECTION, sal_Int32);
+ DECL_PROP0(FETCHSIZE, sal_Int32);
+ DECL_BOOL_PROP1IMPL(ISBOOKMARKABLE) PropertyAttribute::READONLY);
+ DECL_PROP1IMPL(RESULTSETCONCURRENCY,sal_Int32) PropertyAttribute::READONLY);
+ DECL_PROP1IMPL(RESULTSETTYPE, sal_Int32) 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 )
+ throw (::com::sun::star::lang::IllegalArgumentException)
+{
+ 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
+ )
+ throw (Exception)
+{
+ 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( ) throw(::com::sun::star::uno::RuntimeException)
+{
+ return ::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper());
+}
+// -----------------------------------------------------------------------------
+
+
+
diff --git a/odk/examples/DevelopersGuide/Database/DriverSkeleton/SResultSet.hxx b/odk/examples/DevelopersGuide/Database/DriverSkeleton/SResultSet.hxx
new file mode 100644
index 000000000000..3849c06f865e
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Database/DriverSkeleton/SResultSet.hxx
@@ -0,0 +1,218 @@
+/*************************************************************************
+ *
+ * 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 CONNECTIVITY_SRESULTSET_HXX
+#define CONNECTIVITY_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 )
+ throw (::com::sun::star::lang::IllegalArgumentException);
+ virtual void SAL_CALL setFastPropertyValue_NoBroadcast(
+ sal_Int32 nHandle,
+ const ::com::sun::star::uno::Any& rValue
+ )
+ throw (::com::sun::star::uno::Exception);
+ virtual void SAL_CALL getFastPropertyValue(
+ ::com::sun::star::uno::Any& rValue,
+ sal_Int32 nHandle
+ ) const;
+
+ // 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(void);
+ // XInterface
+ virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL acquire() throw();
+ virtual void SAL_CALL release() throw();
+ //XTypeProvider
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes( ) throw(::com::sun::star::uno::RuntimeException);
+ // XPropertySet
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException);
+ // XResultSet
+ virtual sal_Bool SAL_CALL next( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL isBeforeFirst( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL isAfterLast( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL isFirst( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL isLast( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL beforeFirst( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL afterLast( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL first( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL last( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getRow( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL absolute( sal_Int32 row ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL relative( sal_Int32 rows ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL previous( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL refreshRow( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL rowUpdated( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL rowInserted( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL rowDeleted( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL getStatement( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ // XRow
+ virtual sal_Bool SAL_CALL wasNull( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getString( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL getBoolean( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int8 SAL_CALL getByte( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int16 SAL_CALL getShort( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getInt( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int64 SAL_CALL getLong( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual float SAL_CALL getFloat( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual double SAL_CALL getDouble( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getBytes( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::util::Date SAL_CALL getDate( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::util::Time SAL_CALL getTime( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::util::DateTime SAL_CALL getTimestamp( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > SAL_CALL getBinaryStream( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > SAL_CALL getCharacterStream( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Any SAL_CALL getObject( sal_Int32 columnIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& typeMap ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRef > SAL_CALL getRef( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XBlob > SAL_CALL getBlob( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XClob > SAL_CALL getClob( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XArray > SAL_CALL getArray( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ // XResultSetMetaDataSupplier
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSetMetaData > SAL_CALL getMetaData( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ // XCancellable
+ virtual void SAL_CALL cancel( ) throw(::com::sun::star::uno::RuntimeException);
+ // XCloseable
+ virtual void SAL_CALL close( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ // XWarningsSupplier
+ virtual ::com::sun::star::uno::Any SAL_CALL getWarnings( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL clearWarnings( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ // XResultSetUpdate
+ virtual void SAL_CALL insertRow( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL updateRow( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL deleteRow( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL cancelRowUpdates( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL moveToInsertRow( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL moveToCurrentRow( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ // XRowUpdate
+ virtual void SAL_CALL updateNull( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL updateBoolean( sal_Int32 columnIndex, sal_Bool x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL updateByte( sal_Int32 columnIndex, sal_Int8 x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL updateShort( sal_Int32 columnIndex, sal_Int16 x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL updateInt( sal_Int32 columnIndex, sal_Int32 x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL updateLong( sal_Int32 columnIndex, sal_Int64 x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL updateFloat( sal_Int32 columnIndex, float x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL updateDouble( sal_Int32 columnIndex, double x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL updateString( sal_Int32 columnIndex, const ::rtl::OUString& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL updateBytes( sal_Int32 columnIndex, const ::com::sun::star::uno::Sequence< sal_Int8 >& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL updateDate( sal_Int32 columnIndex, const ::com::sun::star::util::Date& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL updateTime( sal_Int32 columnIndex, const ::com::sun::star::util::Time& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL updateTimestamp( sal_Int32 columnIndex, const ::com::sun::star::util::DateTime& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL updateBinaryStream( sal_Int32 columnIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL updateCharacterStream( sal_Int32 columnIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL updateObject( sal_Int32 columnIndex, const ::com::sun::star::uno::Any& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL updateNumericObject( sal_Int32 columnIndex, const ::com::sun::star::uno::Any& x, sal_Int32 scale ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ // XColumnLocate
+ virtual sal_Int32 SAL_CALL findColumn( const ::rtl::OUString& columnName ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ // XRowLocate
+ virtual ::com::sun::star::uno::Any SAL_CALL getBookmark( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL moveToBookmark( const ::com::sun::star::uno::Any& bookmark ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL moveRelativeToBookmark( const ::com::sun::star::uno::Any& bookmark, sal_Int32 rows ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL compareBookmarks( const ::com::sun::star::uno::Any& first, const ::com::sun::star::uno::Any& second ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL hasOrderedBookmarks( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL hashBookmark( const ::com::sun::star::uno::Any& bookmark ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ // XDeleteRows
+ virtual ::com::sun::star::uno::Sequence< sal_Int32 > SAL_CALL deleteRows( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& rows ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ };
+ }
+}
+#endif // CONNECTIVITY_SRESULTSET_HXX
diff --git a/odk/examples/DevelopersGuide/Database/DriverSkeleton/SResultSetMetaData.cxx b/odk/examples/DevelopersGuide/Database/DriverSkeleton/SResultSetMetaData.cxx
new file mode 100644
index 000000000000..fd5d0791f4a9
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Database/DriverSkeleton/SResultSetMetaData.cxx
@@ -0,0 +1,169 @@
+/*************************************************************************
+ *
+ * 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 ) throw(SQLException, RuntimeException)
+{
+ return 50;
+}
+// -------------------------------------------------------------------------
+
+sal_Int32 SAL_CALL OResultSetMetaData::getColumnType( sal_Int32 column ) throw(SQLException, RuntimeException)
+{
+ sal_Int32 nType = 0;
+ return nType;
+}
+// -------------------------------------------------------------------------
+
+sal_Int32 SAL_CALL OResultSetMetaData::getColumnCount( ) throw(SQLException, RuntimeException)
+{
+ // this make no sense here so you have to change this
+ return 0;
+}
+// -------------------------------------------------------------------------
+
+sal_Bool SAL_CALL OResultSetMetaData::isCaseSensitive( sal_Int32 column ) throw(SQLException, RuntimeException)
+{
+ return sal_True;
+}
+// -------------------------------------------------------------------------
+
+::rtl::OUString SAL_CALL OResultSetMetaData::getSchemaName( sal_Int32 column ) throw(SQLException, RuntimeException)
+{
+ return ::rtl::OUString();
+}
+// -------------------------------------------------------------------------
+
+::rtl::OUString SAL_CALL OResultSetMetaData::getColumnName( sal_Int32 column ) throw(SQLException, RuntimeException)
+{
+ return ::rtl::OUString::createFromAscii("Column") + ::rtl::OUString::valueOf(column);
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL OResultSetMetaData::getTableName( sal_Int32 column ) throw(SQLException, RuntimeException)
+{
+ return ::rtl::OUString();
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL OResultSetMetaData::getCatalogName( sal_Int32 column ) throw(SQLException, RuntimeException)
+{
+ return ::rtl::OUString();
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL OResultSetMetaData::getColumnTypeName( sal_Int32 column ) throw(SQLException, RuntimeException)
+{
+ return ::rtl::OUString();
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL OResultSetMetaData::getColumnLabel( sal_Int32 column ) throw(SQLException, RuntimeException)
+{
+ return ::rtl::OUString();
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL OResultSetMetaData::getColumnServiceName( sal_Int32 column ) throw(SQLException, RuntimeException)
+{
+ return ::rtl::OUString();
+}
+// -------------------------------------------------------------------------
+
+sal_Bool SAL_CALL OResultSetMetaData::isCurrency( sal_Int32 column ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+
+sal_Bool SAL_CALL OResultSetMetaData::isAutoIncrement( sal_Int32 column ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+
+
+sal_Bool SAL_CALL OResultSetMetaData::isSigned( sal_Int32 column ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL OResultSetMetaData::getPrecision( sal_Int32 column ) throw(SQLException, RuntimeException)
+{
+ return 0;
+}
+// -----------------------------------------------------------------------------
+sal_Int32 SAL_CALL OResultSetMetaData::getScale( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
+{
+ return 0;
+}
+// -------------------------------------------------------------------------
+
+sal_Int32 SAL_CALL OResultSetMetaData::isNullable( sal_Int32 column ) throw(SQLException, RuntimeException)
+{
+ return 0;
+}
+// -------------------------------------------------------------------------
+
+sal_Bool SAL_CALL OResultSetMetaData::isSearchable( sal_Int32 column ) throw(SQLException, RuntimeException)
+{
+ return sal_True;
+}
+// -------------------------------------------------------------------------
+
+sal_Bool SAL_CALL OResultSetMetaData::isReadOnly( sal_Int32 column ) throw(SQLException, RuntimeException)
+{
+ return sal_True;
+}
+// -------------------------------------------------------------------------
+
+sal_Bool SAL_CALL OResultSetMetaData::isDefinitelyWritable( sal_Int32 column ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OResultSetMetaData::isWritable( sal_Int32 column ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+
diff --git a/odk/examples/DevelopersGuide/Database/DriverSkeleton/SResultSetMetaData.hxx b/odk/examples/DevelopersGuide/Database/DriverSkeleton/SResultSetMetaData.hxx
new file mode 100644
index 000000000000..0657c74af719
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Database/DriverSkeleton/SResultSetMetaData.hxx
@@ -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.
+ *
+ *************************************************************************/
+
+#ifndef CONNECTIVITY_SRESULSETMETADATA_HXX
+#define CONNECTIVITY_SRESULSETMETADATA_HXX
+
+#include <com/sun/star/sdbc/XResultSetMetaData.hpp>
+#include <cppuhelper/implbase1.hxx>
+#include "SConnection.hxx"
+
+namespace connectivity
+{
+ namespace skeleton
+ {
+ //**************************************************************
+ //************ Class: ResultSetMetaData
+ //**************************************************************
+ typedef ::cppu::WeakImplHelper1< ::com::sun::star::sdbc::XResultSetMetaData> OResultSetMetaData_BASE;
+
+ class OResultSetMetaData : public OResultSetMetaData_BASE
+ {
+ OConnection* m_pConnection;
+
+ protected:
+ virtual ~OResultSetMetaData();
+ public:
+ // ein Konstruktor, der fuer das Returnen des Objektes benoetigt wird:
+ OResultSetMetaData(OConnection* _pConnection) : m_pConnection(_pConnection){}
+
+ /// Avoid ambigous 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( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL isAutoIncrement( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL isCaseSensitive( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL isSearchable( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL isCurrency( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL isNullable( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL isSigned( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getColumnDisplaySize( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getColumnLabel( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getColumnName( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getSchemaName( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getPrecision( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getScale( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getTableName( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getCatalogName( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getColumnType( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getColumnTypeName( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL isReadOnly( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL isWritable( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL isDefinitelyWritable( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getColumnServiceName( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ };
+ }
+}
+
+#endif // CONNECTIVITY_SRESULSETMETADATA_HXX
diff --git a/odk/examples/DevelopersGuide/Database/DriverSkeleton/SServices.cxx b/odk/examples/DevelopersGuide/Database/DriverSkeleton/SServices.cxx
new file mode 100644
index 000000000000..820d96f83c46
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Database/DriverSkeleton/SServices.cxx
@@ -0,0 +1,180 @@
+/*************************************************************************
+ *
+ * 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 "SDriver.hxx"
+#include <cppuhelper/factory.hxx>
+#include <osl/diagnose.h>
+
+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* _pTemp
+ );
+
+//***************************************************************************************
+//
+// Die vorgeschriebene C-Api muss erfuellt werden!
+// Sie besteht aus drei Funktionen, die von dem Modul exportiert werden muessen.
+//
+
+//---------------------------------------------------------------------------------------
+void REGISTER_PROVIDER(
+ const OUString& aServiceImplName,
+ const Sequence< OUString>& Services,
+ const Reference< ::com::sun::star::registry::XRegistryKey > & xKey)
+{
+ OUString aMainKeyName;
+ aMainKeyName = OUString::createFromAscii("/");
+ aMainKeyName += aServiceImplName;
+ aMainKeyName += OUString::createFromAscii("/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,
+ sal_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" void SAL_CALL component_getImplementationEnvironment(
+ const sal_Char **ppEnvTypeName,
+ uno_Environment **ppEnv
+ )
+{
+ *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
+}
+
+//---------------------------------------------------------------------------------------
+extern "C" sal_Bool SAL_CALL component_writeInfo(
+ void* pServiceManager,
+ void* pRegistryKey
+ )
+{
+ if (pRegistryKey)
+ try
+ {
+ Reference< ::com::sun::star::registry::XRegistryKey > xKey(reinterpret_cast< ::com::sun::star::registry::XRegistryKey*>(pRegistryKey));
+
+ REGISTER_PROVIDER(
+ SkeletonDriver::getImplementationName_Static(),
+ SkeletonDriver::getSupportedServiceNames_Static(), xKey);
+
+ return sal_True;
+ }
+ catch (::com::sun::star::registry::InvalidRegistryException& )
+ {
+ OSL_ENSURE(sal_False, "SKELETON::component_writeInfo : could not create a registry key ! ## InvalidRegistryException !");
+ }
+
+ return sal_False;
+}
+
+//---------------------------------------------------------------------------------------
+extern "C" void* SAL_CALL component_getFactory(
+ const sal_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;
+};
+
+
diff --git a/odk/examples/DevelopersGuide/Database/DriverSkeleton/SStatement.cxx b/odk/examples/DevelopersGuide/Database/DriverSkeleton/SStatement.cxx
new file mode 100644
index 000000000000..b8f0fb4f01bd
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Database/DriverSkeleton/SStatement.cxx
@@ -0,0 +1,368 @@
+/*************************************************************************
+ *
+ * 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/diagnose.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 "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 = Reference< XResultSet>();
+}
+//------------------------------------------------------------------------------
+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()
+{
+ relase_ChildImpl();
+}
+//-----------------------------------------------------------------------------
+Any SAL_CALL OStatement_Base::queryInterface( const Type & rType ) throw(RuntimeException)
+{
+ Any aRet = OStatement_BASE::queryInterface(rType);
+ if(!aRet.hasValue())
+ aRet = OPropertySetHelper::queryInterface(rType);
+ return aRet;
+}
+// -------------------------------------------------------------------------
+Sequence< Type > SAL_CALL OStatement_Base::getTypes( ) throw(RuntimeException)
+{
+ ::cppu::OTypeCollection aTypes(
+ ::cppu::UnoType< Reference< XMultiPropertySet > >::get(),
+ ::cppu::UnoType< Reference< XFastPropertySet > >::get(),
+ ::cppu::UnoType< Reference< XPropertySet > >::get());
+
+ return concatSequences(aTypes.getTypes(),OStatement_BASE::getTypes());
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OStatement_Base::cancel( ) throw(RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OStatement_BASE::rBHelper.bDisposed);
+ // cancel the current sql statement
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OStatement_Base::close( ) throw(SQLException, RuntimeException)
+{
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OStatement_BASE::rBHelper.bDisposed);
+
+ }
+ dispose();
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OStatement::clearBatch( ) throw(SQLException, RuntimeException)
+{
+ // if you support batches clear it here
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OStatement_Base::execute( const ::rtl::OUString& sql ) throw(SQLException, RuntimeException)
+{
+ ::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 ) throw(SQLException, RuntimeException)
+{
+ ::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 nedd a reference to it for later use
+ return xRS;
+}
+// -------------------------------------------------------------------------
+
+Reference< XConnection > SAL_CALL OStatement_Base::getConnection( ) throw(SQLException, RuntimeException)
+{
+ ::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( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
+{
+ return 0;
+}
+// -------------------------------------------------------------------------
+
+Any SAL_CALL OStatement::queryInterface( const Type & rType ) throw(RuntimeException)
+{
+ 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 ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OStatement_BASE::rBHelper.bDisposed);
+
+
+ m_aBatchList.push_back(sql);
+}
+// -------------------------------------------------------------------------
+Sequence< sal_Int32 > SAL_CALL OStatement::executeBatch( ) throw(SQLException, RuntimeException)
+{
+ ::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 ) throw(SQLException, RuntimeException)
+{
+ ::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( ) throw(SQLException, RuntimeException)
+{
+ ::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( ) throw(SQLException, RuntimeException)
+{
+ ::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( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OStatement_BASE::rBHelper.bDisposed);
+
+
+ return makeAny(m_aLastWarning);
+}
+// -------------------------------------------------------------------------
+
+// -------------------------------------------------------------------------
+void SAL_CALL OStatement_Base::clearWarnings( ) throw(SQLException, RuntimeException)
+{
+ ::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;
+ DECL_PROP0(CURSORNAME, ::rtl::OUString);
+ DECL_BOOL_PROP0(ESCAPEPROCESSING);
+ DECL_PROP0(FETCHDIRECTION,sal_Int32);
+ DECL_PROP0(FETCHSIZE, sal_Int32);
+ DECL_PROP0(MAXFIELDSIZE,sal_Int32);
+ DECL_PROP0(MAXROWS, sal_Int32);
+ DECL_PROP0(QUERYTIMEOUT,sal_Int32);
+ DECL_PROP0(RESULTSETCONCURRENCY,sal_Int32);
+ DECL_PROP0(RESULTSETTYPE,sal_Int32);
+ DECL_BOOL_PROP0(USEBOOKMARKS);
+
+ 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 )
+ throw (::com::sun::star::lang::IllegalArgumentException)
+{
+ 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) throw (Exception)
+{
+ // set the value to what ever is nescessary
+ 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( ) throw(RuntimeException)
+{
+ return ::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper());
+}
+// -----------------------------------------------------------------------------
+
diff --git a/odk/examples/DevelopersGuide/Database/DriverSkeleton/SStatement.hxx b/odk/examples/DevelopersGuide/Database/DriverSkeleton/SStatement.hxx
new file mode 100644
index 000000000000..014e84f48423
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Database/DriverSkeleton/SStatement.hxx
@@ -0,0 +1,175 @@
+/*************************************************************************
+ *
+ * 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 CONNECTIVITY_SSTATEMENT_HXX
+#define CONNECTIVITY_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 <list>
+#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;
+
+ //**************************************************************
+ //************ Class: OStatement_Base
+ // is 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::list< ::rtl::OUString> m_aBatchList;
+
+ 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 )
+ throw (::com::sun::star::lang::IllegalArgumentException);
+ virtual void SAL_CALL setFastPropertyValue_NoBroadcast(
+ sal_Int32 nHandle,
+ const ::com::sun::star::uno::Any& rValue) throw (::com::sun::star::uno::Exception);
+ virtual void SAL_CALL getFastPropertyValue(
+ ::com::sun::star::uno::Any& rValue,
+ sal_Int32 nHandle) const;
+ 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(void){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 ) throw(::com::sun::star::uno::RuntimeException);
+ //XTypeProvider
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes( ) throw(::com::sun::star::uno::RuntimeException);
+
+ // XPropertySet
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException);
+ // XStatement
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL executeQuery( const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) ;
+ virtual sal_Int32 SAL_CALL executeUpdate( const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) ;
+ virtual sal_Bool SAL_CALL execute( const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) ;
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > SAL_CALL getConnection( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) ;
+ // XWarningsSupplier
+ virtual ::com::sun::star::uno::Any SAL_CALL getWarnings( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL clearWarnings( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ // XCancellable
+ virtual void SAL_CALL cancel( ) throw(::com::sun::star::uno::RuntimeException);
+ // XCloseable
+ virtual void SAL_CALL close( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ // XMultipleResults
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getResultSet( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getUpdateCount( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL getMoreResults( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+
+ // 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(void);
+ // 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:
+ // ein Konstruktor, der fuer das Returnen des Objektes benoetigt wird:
+ 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 ) throw(::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL acquire() throw();
+ virtual void SAL_CALL release() throw();
+ // XBatchExecution
+ virtual void SAL_CALL addBatch( const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL clearBatch( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< sal_Int32 > SAL_CALL executeBatch( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ };
+ }
+}
+#endif // CONNECTIVITY_SSTATEMENT_HXX
diff --git a/odk/examples/DevelopersGuide/Database/DriverSkeleton/propertyids.cxx b/odk/examples/DevelopersGuide/Database/DriverSkeleton/propertyids.cxx
new file mode 100644
index 000000000000..2079cf9da77c
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Database/DriverSkeleton/propertyids.cxx
@@ -0,0 +1,182 @@
+/*************************************************************************
+ *
+ * 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/diagnose.h>
+#include "propertyids.hxx"
+namespace connectivity
+{
+namespace skeleton
+{
+ const sal_Char* getPROPERTY_QUERYTIMEOUT() { return "QueryTimeOut"; }
+ const sal_Char* getPROPERTY_MAXFIELDSIZE() { return "MaxFieldSize"; }
+ const sal_Char* getPROPERTY_MAXROWS() { return "MaxRows"; }
+ const sal_Char* getPROPERTY_CURSORNAME() { return "CursorName"; }
+ const sal_Char* getPROPERTY_RESULTSETCONCURRENCY() { return "ResultSetConcurrency"; }
+ const sal_Char* getPROPERTY_RESULTSETTYPE() { return "ResultSetType"; }
+ const sal_Char* getPROPERTY_FETCHDIRECTION() { return "FetchDirection"; }
+ const sal_Char* getPROPERTY_FETCHSIZE() { return "FetchSize"; }
+ const sal_Char* getPROPERTY_ESCAPEPROCESSING() { return "EscapeProcessing"; }
+ const sal_Char* getPROPERTY_USEBOOKMARKS() { return "UseBookmarks"; }
+
+ const sal_Char* getPROPERTY_NAME() { return "Name"; }
+ const sal_Char* getPROPERTY_TYPE() { return "Type"; }
+ const sal_Char* getPROPERTY_TYPENAME() { return "TypeName"; }
+ const sal_Char* getPROPERTY_PRECISION() { return "Precision"; }
+ const sal_Char* getPROPERTY_SCALE() { return "Scale"; }
+ const sal_Char* getPROPERTY_ISNULLABLE() { return "IsNullable"; }
+ const sal_Char* getPROPERTY_ISAUTOINCREMENT() { return "IsAutoIncrement"; }
+ const sal_Char* getPROPERTY_ISROWVERSION() { return "IsRowVersion"; }
+ const sal_Char* getPROPERTY_DESCRIPTION() { return "Description"; }
+ const sal_Char* getPROPERTY_DEFAULTVALUE() { return "DefaultValue"; }
+
+ const sal_Char* getPROPERTY_REFERENCEDTABLE() { return "ReferencedTable"; }
+ const sal_Char* getPROPERTY_UPDATERULE() { return "UpdateRule"; }
+ const sal_Char* getPROPERTY_DELETERULE() { return "DeleteRule"; }
+ const sal_Char* getPROPERTY_CATALOG() { return "Catalog"; }
+ const sal_Char* getPROPERTY_ISUNIQUE() { return "IsUnique"; }
+ const sal_Char* getPROPERTY_ISPRIMARYKEYINDEX() { return "IsPrimaryKeyIndex"; }
+ const sal_Char* getPROPERTY_ISCLUSTERED() { return "IsClustered"; }
+ const sal_Char* getPROPERTY_ISASCENDING() { return "IsAscending"; }
+ const sal_Char* getPROPERTY_SCHEMANAME() { return "SchemaName"; }
+ const sal_Char* getPROPERTY_CATALOGNAME() { return "CatalogName"; }
+ const sal_Char* getPROPERTY_COMMAND() { return "Command"; }
+ const sal_Char* getPROPERTY_CHECKOPTION() { return "CheckOption"; }
+ const sal_Char* getPROPERTY_PASSWORD() { return "Password"; }
+ const sal_Char* getPROPERTY_RELATEDCOLUMN() { return "RelatedColumn"; }
+
+ const sal_Char* getSTAT_INVALID_INDEX() { return "Invalid descriptor index"; }
+
+ const sal_Char* getPROPERTY_FUNCTION() { return "Function"; }
+ const sal_Char* getPROPERTY_TABLENAME() { return "TableName"; }
+ const sal_Char* getPROPERTY_REALNAME() { return "RealName"; }
+ const sal_Char* getPROPERTY_DBASEPRECISIONCHANGED() { return "DbasePrecisionChanged"; }
+ const sal_Char* getPROPERTY_ISCURRENCY() { return "IsCurrency"; }
+ const sal_Char* getPROPERTY_ISBOOKMARKABLE() { return "IsBookmarkable"; }
+
+ const sal_Char* getPROPERTY_FORMATKEY() { return "FormatKey"; }
+ const sal_Char* getPROPERTY_LOCALE() { return "Locale"; }
+
+ const sal_Char* getPROPERTY_AUTOINCREMENTCREATION() { return "AutoIncrementCreation"; }
+ const sal_Char* getPROPERTY_PRIVILEGES() { return "Privileges"; }
+ //============================================================
+ //= error messages
+ //============================================================
+ const sal_Char* getERRORMSG_SEQUENCE() { return "Function sequence error"; }
+ const sal_Char* getSQLSTATE_SEQUENCE() { return "HY010"; }
+ const sal_Char* getSQLSTATE_GENERAL() { return "HY0000"; }
+ const sal_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;
+ }
+ }
+}
diff --git a/odk/examples/DevelopersGuide/Database/DriverSkeleton/propertyids.hxx b/odk/examples/DevelopersGuide/Database/DriverSkeleton/propertyids.hxx
new file mode 100644
index 000000000000..e3b37580bd36
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Database/DriverSkeleton/propertyids.hxx
@@ -0,0 +1,161 @@
+/*************************************************************************
+ *
+ * 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 _CONNECTIVITY_PROPERTYIDS_HXX_
+#define _CONNECTIVITY_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>
+#ifndef _MAP_
+#include <map>
+#endif
+
+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 sal_Char* (*PVFN)();
+
+ struct UStringDescription
+ {
+ const sal_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 DECL_PROP1IMPL(varname, type) \
+pProperties[nPos++] = ::com::sun::star::beans::Property(OPropertyMap::getPropMap().getNameByIndex(PROPERTY_ID_##varname), PROPERTY_ID_##varname, ::cppu::UnoType< type >::get(),
+//------------------------------------------------------------------------------
+#define DECL_PROP0(varname, type) \
+ DECL_PROP1IMPL(varname, type) 0)
+//------------------------------------------------------------------------------
+#define DECL_BOOL_PROP1IMPL(varname) \
+ pProperties[nPos++] = ::com::sun::star::beans::Property(OPropertyMap::getPropMap().getNameByIndex(PROPERTY_ID_##varname), PROPERTY_ID_##varname, ::getBooleanCppuType(),
+//------------------------------------------------------------------------------
+#define DECL_BOOL_PROP0(varname) \
+ DECL_BOOL_PROP1IMPL(varname) 0)
+
+
+#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 // _CONNECTIVITY_PROPERTYIDS_HXX_
+
+
diff --git a/odk/examples/DevelopersGuide/Database/Makefile b/odk/examples/DevelopersGuide/Database/Makefile
new file mode 100644
index 000000000000..8f9dd84e5767
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Database/Makefile
@@ -0,0 +1,134 @@
+#*************************************************************************
+#
+# 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
+include $(SETTINGS)/dk.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 000000000000..c62d560039f0
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Database/OpenQuery.java
@@ -0,0 +1,162 @@
+/*************************************************************************
+ *
+ * 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;
+import com.sun.star.beans.XPropertySet;
+
+
+
+/*
+ * OpenQuery.java
+ *
+ * Created on 6. Juli 2002, 10:25
+ */
+
+/**
+ *
+ * @author dschulten
+ */
+public class OpenQuery {
+
+ private XComponentContext xContext = null;
+ private XMultiComponentFactory xMCF = null;
+
+ /** Creates a new instance of OpenQuery */
+ public 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 {
+ 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 = (com.sun.star.sdbc.XRowSet)
+ UnoRuntime.queryInterface(com.sun.star.sdbc.XRowSet.class, rowSet);
+
+ // set the properties needed to connect to a database
+ XPropertySet xProp = (XPropertySet)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",new Integer(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 = (com.sun.star.sdbc.XRow)UnoRuntime.queryInterface(
+ com.sun.star.sdbc.XRow.class, xRowSet);
+ // XColumnLocate finds columns by name
+ com.sun.star.sdbc.XColumnLocate xLoc = (com.sun.star.sdbc.XColumnLocate)
+ 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 != null && 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 = (com.sun.star.sdbc.XResultSetUpdate)
+ UnoRuntime.queryInterface(
+ com.sun.star.sdbc.XResultSetUpdate.class, xRowSet);
+
+ // XRowUpdate for row updates
+ com.sun.star.sdbc.XRowUpdate xRowUpdate = (com.sun.star.sdbc.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 = (com.sun.star.lang.XComponent)UnoRuntime.queryInterface(
+ com.sun.star.lang.XComponent.class, xRowSet);
+ xComp.dispose();
+ }
+
+}
diff --git a/odk/examples/DevelopersGuide/Database/RowSet.java b/odk/examples/DevelopersGuide/Database/RowSet.java
new file mode 100644
index 000000000000..bffcca51b663
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Database/RowSet.java
@@ -0,0 +1,241 @@
+/*************************************************************************
+ *
+ * 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.*;
+
+import com.sun.star.comp.helper.RegistryServiceFactory;
+import com.sun.star.comp.servicemanager.ServiceManager;
+import com.sun.star.lang.XMultiComponentFactory;
+import com.sun.star.lang.XServiceInfo;
+import com.sun.star.lang.XComponent;
+import com.sun.star.bridge.XUnoUrlResolver;
+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.sdbc.*;
+import com.sun.star.sdbcx.Privilege;
+import com.sun.star.sdb.CommandType;
+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.out);
+ System.exit(1);
+ }
+
+ try{
+ showRowSetEvents();
+ showRowSetRowCount();
+ showRowSetPrivileges();
+ useRowSet();
+ }
+ catch(com.sun.star.uno.Exception e)
+ {
+ System.err.println(e);
+ e.printStackTrace();
+ }
+ System.exit(0);
+ }
+
+ public static void printDataSources() throws com.sun.star.uno.Exception
+ {
+ // create a DatabaseContext and print all DataSource names
+ XNameAccess 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]);
+ }
+
+ public static void useRowSet() throws com.sun.star.uno.Exception
+ {
+ // first we create our RowSet object
+ XRowSet xRowRes = (XRowSet)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 = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class,xRowRes);
+ xProp.setPropertyValue("DataSourceName","Bibliography");
+ xProp.setPropertyValue("Command","biblio");
+ xProp.setPropertyValue("CommandType",new Integer(com.sun.star.sdb.CommandType.TABLE));
+
+ xRowRes.execute();
+ System.out.println("RowSet executed!");
+
+
+ XComponent xComp = (XComponent)UnoRuntime.queryInterface(XComponent.class,xRowRes);
+ xComp.dispose();
+ System.out.println("RowSet destroyed!");
+ }
+
+ public static void showRowSetPrivileges() throws com.sun.star.uno.Exception
+ {
+ // first we create our RowSet object
+ XRowSet xRowRes = (XRowSet)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 = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class,xRowRes);
+ xProp.setPropertyValue("DataSourceName","Bibliography");
+ xProp.setPropertyValue("Command","biblio");
+ xProp.setPropertyValue("CommandType",new Integer(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 = (XComponent)UnoRuntime.queryInterface(XComponent.class,xRowRes);
+ xComp.dispose();
+ System.out.println("RowSet destroyed!");
+ }
+
+ public static void showRowSetRowCount() throws com.sun.star.uno.Exception
+ {
+ // first we create our RowSet object
+ XRowSet xRowRes = (XRowSet)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 = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class,xRowRes);
+ xProp.setPropertyValue("DataSourceName","Bibliography");
+ xProp.setPropertyValue("Command","biblio");
+ xProp.setPropertyValue("CommandType",new Integer(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 = (XResultSet)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 = (XComponent)UnoRuntime.queryInterface(XComponent.class,xRowRes);
+ xComp.dispose();
+ System.out.println("RowSet destroyed!");
+ }
+
+ public static void showRowSetEvents() throws com.sun.star.uno.Exception
+ {
+ // first we create our RowSet object
+ XRowSet xRowRes = (XRowSet)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 = (XRowSetApproveBroadcaster)UnoRuntime.queryInterface(XRowSetApproveBroadcaster.class,xRowRes);
+ xApBroad.addRowSetApproveListener(pRow);
+ xRowRes.addRowSetListener(pRow);
+
+ // set the properties needed to connect to a database
+ XPropertySet xProp = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class,xRowRes);
+ xProp.setPropertyValue("DataSourceName","Bibliography");
+ xProp.setPropertyValue("Command","biblio");
+ xProp.setPropertyValue("CommandType",new Integer(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 = (XResultSet)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 = (XComponent)UnoRuntime.queryInterface(XComponent.class,xRowRes);
+ xComp.dispose();
+ System.out.println("RowSet destroyed!");
+ }
+}
+
diff --git a/odk/examples/DevelopersGuide/Database/RowSetEventListener.java b/odk/examples/DevelopersGuide/Database/RowSetEventListener.java
new file mode 100644
index 000000000000..ba0f03f2cc02
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Database/RowSetEventListener.java
@@ -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.
+ *
+ *************************************************************************/
+
+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!");
+ }
+}
diff --git a/odk/examples/DevelopersGuide/Database/Sales.java b/odk/examples/DevelopersGuide/Database/Sales.java
new file mode 100644
index 000000000000..efa3422e21f2
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Database/Sales.java
@@ -0,0 +1,250 @@
+/*************************************************************************
+ *
+ * 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.*;
+
+// import com.sun.star.comp.helper.RegistryServiceFactory;
+// import com.sun.star.comp.servicemanager.ServiceManager;
+// import com.sun.star.lang.XMultiServiceFactory;
+// import com.sun.star.lang.XServiceInfo;
+import com.sun.star.lang.XComponent;
+// import com.sun.star.bridge.XUnoUrlResolver;
+import com.sun.star.uno.*;
+import com.sun.star.util.Date;
+import com.sun.star.beans.XPropertySet;
+import com.sun.star.container.XNameAccess;
+import com.sun.star.sdbc.*;
+
+public class Sales
+{
+ private 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 = (XRow)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 + ".");
+ }
+ }
+
+ // create a scrollable resultset.
+ public void retrieveSalesData2() throws com.sun.star.uno.Exception
+ {
+ // example for a programmatic way to do updates. This doesn't work with adabas.
+ XStatement stmt = con.createStatement();
+ XPropertySet xProp = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class,stmt);
+
+ xProp.setPropertyValue("ResultSetType", new java.lang.Integer(ResultSetType.SCROLL_INSENSITIVE));
+ xProp.setPropertyValue("ResultSetConcurrency", new java.lang.Integer(ResultSetConcurrency.UPDATABLE));
+
+ XResultSet srs = stmt.executeQuery("SELECT NAME, PRICE FROM SALES");
+ XRow row = (XRow)UnoRuntime.queryInterface(XRow.class,srs);
+
+ srs.afterLast();
+ while (srs.previous()) {
+ String name = row.getString(1);
+ float price = row.getFloat(2);
+ System.out.println(name + " " + price);
+ }
+
+ srs.last();
+ XRowUpdate updateRow = (XRowUpdate)UnoRuntime.queryInterface(XRowUpdate.class,srs);
+ updateRow.updateFloat(2, (float)0.69);
+
+ XResultSetUpdate updateRs = ( XResultSetUpdate )UnoRuntime.queryInterface(
+ XResultSetUpdate.class,srs);
+ updateRs.updateRow(); // this call updates the data in DBMS
+
+ srs.last();
+ updateRow.updateFloat(2, (float)0.99);
+ updateRs.cancelRowUpdates();
+ updateRow.updateFloat(2, (float)0.79);
+ updateRs.updateRow();
+ }
+
+ // inserts a row programmatically.
+ public void insertRow() throws com.sun.star.uno.Exception
+ {
+ // example for a programmatic way to do updates. This doesn't work with adabas.
+ XStatement stmt = con.createStatement();
+// stmt.executeUpdate("INSERT INTO SALES " +
+// "VALUES (4, 102, 5, 'FTOP Darjeeling tea', '2002-01-02',150)");
+//
+// stmt = con.createStatement();
+ XPropertySet xProp = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class,stmt);
+ xProp.setPropertyValue("ResultSetType", new java.lang.Integer(ResultSetType.SCROLL_INSENSITIVE));
+ xProp.setPropertyValue("ResultSetConcurrency", new java.lang.Integer(ResultSetConcurrency.UPDATABLE));
+ XResultSet rs = stmt.executeQuery("SELECT * FROM SALES");
+ XRow row = (XRow)UnoRuntime.queryInterface(XRow.class,rs);
+
+ // insert a new row
+ XRowUpdate updateRow = (XRowUpdate)UnoRuntime.queryInterface(XRowUpdate.class,rs);
+ XResultSetUpdate updateRs = ( XResultSetUpdate )UnoRuntime. queryInterface(XResultSetUpdate.class,rs);
+ updateRs.moveToInsertRow();
+ updateRow.updateInt(1, 4);
+ updateRow.updateInt(2, 102);
+ updateRow.updateInt(3, 5);
+ updateRow.updateString(4, "FTOP Darjeeling tea");
+ updateRow.updateDate(5, new Date((short)1,(short)2,(short)2002));
+ updateRow.updateFloat(6, 150);
+ updateRs.insertRow();
+ }
+
+ // deletes a row programmatically.
+ public void deleteRow() throws com.sun.star.uno.Exception
+ {
+ // example for a programmatic way to do updates. This doesn't work with adabas.
+ XStatement stmt = con.createStatement();
+ XPropertySet xProp = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class,stmt);
+ xProp.setPropertyValue("ResultSetType", new java.lang.Integer(ResultSetType.SCROLL_INSENSITIVE));
+ xProp.setPropertyValue("ResultSetConcurrency", new java.lang.Integer(ResultSetConcurrency.UPDATABLE));
+ XResultSet rs = stmt.executeQuery("SELECT * FROM SALES");
+ XRow row = (XRow)UnoRuntime.queryInterface(XRow.class,rs);
+
+ XResultSetUpdate updateRs = ( XResultSetUpdate )UnoRuntime. queryInterface(XResultSetUpdate.class,rs);
+ // move to the inserted row
+ rs.absolute(4);
+ updateRs.deleteRow();
+ }
+
+ // refresh a row
+ public void refreshRow() throws com.sun.star.uno.Exception
+ {
+ // example for a programmatic way to do updates. This doesn't work with adabas.
+ // first we need the 4 row
+ insertRow();
+
+ XStatement stmt = con.createStatement();
+ XPropertySet xProp = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class,stmt);
+ xProp.setPropertyValue("ResultSetType", new java.lang.Integer(ResultSetType.SCROLL_INSENSITIVE));
+ xProp.setPropertyValue("ResultSetConcurrency", new java.lang.Integer(ResultSetConcurrency.READ_ONLY));
+ XResultSet rs = stmt.executeQuery("SELECT NAME, PRICE FROM SALES");
+ XRow row = (XRow)UnoRuntime.queryInterface(XRow.class, rs);
+ rs.absolute(4);
+ float price1 = row.getFloat(2);
+
+ // modifiy the 4 row
+ XRowUpdate updateRow = (XRowUpdate)UnoRuntime.queryInterface(XRowUpdate.class,rs);
+ XResultSetUpdate updateRs = ( XResultSetUpdate )UnoRuntime. queryInterface(XResultSetUpdate.class,rs);
+ updateRow.updateFloat(2, 150);
+ updateRs.updateRow();
+ // repositioning
+ rs.absolute(4);
+ rs.refreshRow();
+ float price2 = row.getFloat(2);
+ if (price2 != price1) {
+ System.out.println("Prices are different.");
+ }
+ else
+ System.out.println("Prices are equal.");
+ deleteRow();
+ }
+
+ // displays the column names
+ public void displayColumnNames() throws com.sun.star.uno.Exception
+ {
+ XStatement stmt = con.createStatement();
+ XPropertySet xProp = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class,stmt);
+ xProp.setPropertyValue("ResultSetType", new java.lang.Integer(ResultSetType.SCROLL_INSENSITIVE));
+ xProp.setPropertyValue("ResultSetConcurrency", new java.lang.Integer(ResultSetConcurrency.READ_ONLY));
+ XResultSet rs = stmt.executeQuery("SELECT NAME, PRICE FROM SALES");
+ XResultSetMetaDataSupplier xRsMetaSup = (XResultSetMetaDataSupplier)
+ 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));
+ }
+ }
+}
+
diff --git a/odk/examples/DevelopersGuide/Database/SalesMan.java b/odk/examples/DevelopersGuide/Database/SalesMan.java
new file mode 100644
index 000000000000..e19bca758bdd
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Database/SalesMan.java
@@ -0,0 +1,145 @@
+/*************************************************************************
+ *
+ * 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.*;
+
+// import com.sun.star.comp.helper.RegistryServiceFactory;
+// import com.sun.star.comp.servicemanager.ServiceManager;
+// import com.sun.star.lang.XMultiServiceFactory;
+// import com.sun.star.lang.XServiceInfo;
+import com.sun.star.lang.XComponent;
+// import com.sun.star.bridge.XUnoUrlResolver;
+import com.sun.star.uno.*;
+import com.sun.star.util.Date;
+import com.sun.star.beans.XPropertySet;
+import com.sun.star.container.XNameAccess;
+import com.sun.star.sdbc.*;
+
+public class SalesMan
+{
+ private 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 = (XParameters)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 = (XRow)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);
+ }
+ }
+}
+
diff --git a/odk/examples/DevelopersGuide/Database/makefile.mk b/odk/examples/DevelopersGuide/Database/makefile.mk
new file mode 100644
index 000000000000..35fed3e39f01
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Database/makefile.mk
@@ -0,0 +1,95 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ=..$/..$/..
+PRJNAME=odk
+TARGET=copying
+
+#----------------------------------------------------------------
+.INCLUDE: settings.mk
+.INCLUDE: $(PRJ)$/util$/makefile.pmk
+#----------------------------------------------------------------
+
+#----------------------------------------------------
+# this makefile is only used for copying the example
+# files into the SDK
+#----------------------------------------------------
+
+DATABASE_FILES=\
+ $(DESTDIRDEVGUIDEEXAMPLES)$/Database$/CodeSamples.java \
+ $(DESTDIRDEVGUIDEEXAMPLES)$/Database$/Makefile \
+ $(DESTDIRDEVGUIDEEXAMPLES)$/Database$/OpenQuery.java \
+ $(DESTDIRDEVGUIDEEXAMPLES)$/Database$/RowSet.java \
+ $(DESTDIRDEVGUIDEEXAMPLES)$/Database$/RowSetEventListener.java \
+ $(DESTDIRDEVGUIDEEXAMPLES)$/Database$/Sales.java \
+ $(DESTDIRDEVGUIDEEXAMPLES)$/Database$/SalesMan.java \
+ $(DESTDIRDEVGUIDEEXAMPLES)$/Database$/sdbcx.java
+
+DATABASEDRIVERSKELETON_FILES=\
+ $(DESTDIRDEVGUIDEEXAMPLES)$/Database$/DriverSkeleton$/How_to_write_my_own_driver.txt \
+ $(DESTDIRDEVGUIDEEXAMPLES)$/Database$/DriverSkeleton$/Makefile \
+ $(DESTDIRDEVGUIDEEXAMPLES)$/Database$/DriverSkeleton$/OSubComponent.hxx \
+ $(DESTDIRDEVGUIDEEXAMPLES)$/Database$/DriverSkeleton$/OTypeInfo.hxx \
+ $(DESTDIRDEVGUIDEEXAMPLES)$/Database$/DriverSkeleton$/propertyids.cxx \
+ $(DESTDIRDEVGUIDEEXAMPLES)$/Database$/DriverSkeleton$/propertyids.hxx \
+ $(DESTDIRDEVGUIDEEXAMPLES)$/Database$/DriverSkeleton$/SConnection.cxx \
+ $(DESTDIRDEVGUIDEEXAMPLES)$/Database$/DriverSkeleton$/SConnection.hxx \
+ $(DESTDIRDEVGUIDEEXAMPLES)$/Database$/DriverSkeleton$/SDatabaseMetaData.cxx \
+ $(DESTDIRDEVGUIDEEXAMPLES)$/Database$/DriverSkeleton$/SDatabaseMetaData.hxx \
+ $(DESTDIRDEVGUIDEEXAMPLES)$/Database$/DriverSkeleton$/SDriver.cxx \
+ $(DESTDIRDEVGUIDEEXAMPLES)$/Database$/DriverSkeleton$/SDriver.hxx \
+ $(DESTDIRDEVGUIDEEXAMPLES)$/Database$/DriverSkeleton$/skeleton.xml \
+ $(DESTDIRDEVGUIDEEXAMPLES)$/Database$/DriverSkeleton$/SPreparedStatement.cxx \
+ $(DESTDIRDEVGUIDEEXAMPLES)$/Database$/DriverSkeleton$/SPreparedStatement.hxx \
+ $(DESTDIRDEVGUIDEEXAMPLES)$/Database$/DriverSkeleton$/SResultSet.cxx \
+ $(DESTDIRDEVGUIDEEXAMPLES)$/Database$/DriverSkeleton$/SResultSet.hxx \
+ $(DESTDIRDEVGUIDEEXAMPLES)$/Database$/DriverSkeleton$/SResultSetMetaData.cxx \
+ $(DESTDIRDEVGUIDEEXAMPLES)$/Database$/DriverSkeleton$/SResultSetMetaData.hxx \
+ $(DESTDIRDEVGUIDEEXAMPLES)$/Database$/DriverSkeleton$/SServices.cxx \
+ $(DESTDIRDEVGUIDEEXAMPLES)$/Database$/DriverSkeleton$/SStatement.cxx \
+ $(DESTDIRDEVGUIDEEXAMPLES)$/Database$/DriverSkeleton$/SStatement.hxx
+
+DIR_FILE_LIST= \
+ $(DATABASE_FILES) \
+ $(DATABASEDRIVERSKELETON_FILES)
+
+DIR_DIRECTORY_LIST=$(uniq $(DIR_FILE_LIST:d))
+DIR_CREATE_FLAG=$(MISC)$/devguide_database_dirs_created.txt
+DIR_FILE_FLAG=$(MISC)$/devguide_database.txt
+
+#--------------------------------------------------
+# TARGETS
+#--------------------------------------------------
+all : \
+ $(DIR_FILE_LIST) \
+ $(DIR_FILE_FLAG)
+
+#--------------------------------------------------
+# use global rules
+#--------------------------------------------------
+.INCLUDE: $(PRJ)$/util$/odk_rules.pmk
+
diff --git a/odk/examples/DevelopersGuide/Database/sdbcx.java b/odk/examples/DevelopersGuide/Database/sdbcx.java
new file mode 100644
index 000000000000..62a4f7007fe6
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Database/sdbcx.java
@@ -0,0 +1,420 @@
+/*************************************************************************
+ *
+ * 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.*;
+
+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 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 = (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 = (XUnoUrlResolver)UnoRuntime.queryInterface(
+ XUnoUrlResolver.class, xUrlResolver );
+
+ Object rInitialObject = urlResolver.resolve( "uno:" + connectStr + ";urp;StarOffice.NamingService" );
+
+ XNamingService rName = (XNamingService)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 = (XMultiServiceFactory)
+ 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("com.sun.star.comp.sdbcx.adabas.ODriver");
+ // query for the interface
+ com.sun.star.sdbc.XDriver xDriver;
+ xDriver = (XDriver)UnoRuntime.queryInterface(XDriver.class,aDriver);
+ if(xDriver != null)
+ {
+ // first create the needed url
+ String adabasURL = "sdbc:adabas::MYDB0";
+ // second create the necessary properties
+ com.sun.star.beans.PropertyValue [] adabasProps = 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 adabas
+ con = xDriver.connect(adabasURL,adabasProps);
+ if(con != null)
+ {
+ System.out.println("Connection could be created!");
+ // we the XDatabaseDefinitionSupplier interface from the driver to get the XTablesSupplier
+ XDataDefinitionSupplier xDDSup = (XDataDefinitionSupplier)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 = (XPropertySet)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) throws com.sun.star.uno.Exception,SQLException
+ {
+ 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,SQLException
+ {
+ System.out.println("Example printKeys");
+ XKeysSupplier xKeysSup = (XKeysSupplier)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 = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class,key);
+ System.out.println(" " + xProp.getPropertyValue("Name"));
+ XColumnsSupplier xKeyColumnsSup = ( XColumnsSupplier ) 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,SQLException
+ {
+ System.out.println("Example printIndexes");
+ XIndexesSupplier xIndexesSup = (XIndexesSupplier)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 = (XColumnsSupplier)UnoRuntime.queryInterface(XColumnsSupplier.class,index);
+ printColumns(xIndexColumnsSup);
+ }
+ }
+ }
+
+ //###########################################################
+ // 18. example
+ // column properties
+ //###########################################################
+ public static void printColumnProperties(Object column) throws com.sun.star.uno.Exception,SQLException
+ {
+ System.out.println("Example printColumnProperties");
+ XPropertySet xProp = (XPropertySet)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,SQLException
+ {
+ System.out.println("Example printIndexProperties");
+ XPropertySet xProp = (XPropertySet)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,SQLException
+ {
+ System.out.println("Example printKeyProperties");
+ XPropertySet xProp = (XPropertySet)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 = (XGroupsSupplier)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 = (XUsersSupplier)UnoRuntime.queryInterface(XUsersSupplier.class,xGroups.getByName(aGroupNames[i]));
+ if(xUsersSup != null)
+ {
+ XAuthorizable xAuth = (XAuthorizable)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 = (XDataDescriptorFactory)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 = (XColumnsSupplier)UnoRuntime.queryInterface(XColumnsSupplier.class,xTable);
+ XDataDescriptorFactory xColFac = (XDataDescriptorFactory)UnoRuntime.queryInterface(XDataDescriptorFactory.class,xColumSup.getColumns());
+ XAppend 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",new Integer(DataType.INTEGER));
+ xCol.setPropertyValue("IsNullable",new Integer(ColumnValue.NO_NULLS));
+ xAppend.appendByDescriptor(xCol);
+ // 2nd only set the properties which differs
+ xCol.setPropertyValue("Name","FIRSTNAME");
+ xCol.setPropertyValue("Type",new Integer(DataType.VARCHAR));
+ xCol.setPropertyValue("IsNullable",new Integer(ColumnValue.NULLABLE));
+ xCol.setPropertyValue("Precision",new Integer(50));
+ xAppend.appendByDescriptor(xCol);
+ // 3nd only set the properties which differs
+ xCol.setPropertyValue("Name","LASTNAME");
+ xCol.setPropertyValue("Precision",new Integer(100));
+ xAppend.appendByDescriptor(xCol);
+ // 4nd only set the properties which differs
+ xCol.setPropertyValue("Name","STREET");
+ xCol.setPropertyValue("Precision",new Integer(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",new Integer(DataType.INTEGER));
+ xCol.setPropertyValue("Precision",new Integer(10)); // default value integer
+ xAppend.appendByDescriptor(xCol);
+ // 7nd only set the properties which differs
+ xCol.setPropertyValue("Name","BIRTHDATE");
+ xCol.setPropertyValue("Type",new Integer(DataType.DATE));
+ xCol.setPropertyValue("Precision",new Integer(10)); // default value integer
+ xAppend.appendByDescriptor(xCol);
+ // now we create the primary key
+ XKeysSupplier xKeySup = (XKeysSupplier)UnoRuntime.queryInterface(XKeysSupplier.class,xTable);
+ XDataDescriptorFactory xKeyFac = (XDataDescriptorFactory)UnoRuntime.queryInterface(XDataDescriptorFactory.class,xKeySup.getKeys());
+ XAppend xKeyAppend = (XAppend)UnoRuntime.queryInterface(XAppend.class,xKeyFac);
+ XPropertySet xKey = xKeyFac.createDataDescriptor();
+ xKey.setPropertyValue("Type",new Integer(KeyType.PRIMARY));
+ // now append the columns to key
+ XColumnsSupplier xKeyColumSup = (XColumnsSupplier)UnoRuntime.queryInterface(XColumnsSupplier.class,xKey);
+ XDataDescriptorFactory xKeyColFac = (XDataDescriptorFactory)UnoRuntime.queryInterface(XDataDescriptorFactory.class,xKeyColumSup.getColumns());
+ XAppend xKeyColAppend = (XAppend)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);
+ // apend the key
+ xKeyAppend.appendByDescriptor(xKey);
+ // the last step is to append the new table to the tables collection
+ XAppend xTableAppend = (XAppend)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 = (XDataDescriptorFactory)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 = (XAppend)UnoRuntime.queryInterface(XAppend.class,xUserFac);
+ xAppend.appendByDescriptor(xUser);
+ }
+ }
+}
diff --git a/odk/examples/DevelopersGuide/Drawing/ChangeOrderDemo.java b/odk/examples/DevelopersGuide/Drawing/ChangeOrderDemo.java
new file mode 100644
index 000000000000..7adbd41ba6a0
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Drawing/ChangeOrderDemo.java
@@ -0,0 +1,115 @@
+/*************************************************************************
+ *
+ * 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
+ @author Sven Jacobi
+ */
+
+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 = new Boolean( true );
+
+ xDrawDoc = Helper.createDocument( xOfficeContext,
+ "private:factory/sdraw", "_blank", 0, pPropValues );
+
+ // create two rectangles
+ XDrawPage xPage = PageHelper.getDrawPageByIndex( xDrawDoc, 0 );
+ XShapes 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 = (XPropertySet)
+ UnoRuntime.queryInterface( XPropertySet.class, xShape1 );
+ XPropertySet xPropSet2 = (XPropertySet)
+ UnoRuntime.queryInterface( XPropertySet.class, xShape2 );
+
+ int nOrderOfShape1 = ((Integer)xPropSet1.getPropertyValue( "ZOrder" )).intValue();
+ int nOrderOfShape2 = ((Integer)xPropSet2.getPropertyValue( "ZOrder" )).intValue();
+
+ xPropSet1.setPropertyValue( "ZOrder", new Integer( nOrderOfShape2 ) );
+ xPropSet2.setPropertyValue( "ZOrder", new Integer( nOrderOfShape1 ) );
+ }
+ catch( Exception ex )
+ {
+ System.out.println( ex );
+ }
+ System.exit( 0 );
+ }
+}
diff --git a/odk/examples/DevelopersGuide/Drawing/ControlAndSelectDemo.java b/odk/examples/DevelopersGuide/Drawing/ControlAndSelectDemo.java
new file mode 100644
index 000000000000..1628f0c59ff8
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Drawing/ControlAndSelectDemo.java
@@ -0,0 +1,143 @@
+/*************************************************************************
+ *
+ * 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
+ @author Sven Jacobi
+
+ 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 = new Boolean( true );
+
+ xComponent = Helper.createDocument( xOfficeContext,
+ "private:factory/sdraw", "_blank", 0, pPropValues );
+
+ XMultiServiceFactory xFactory =
+ (XMultiServiceFactory )UnoRuntime.queryInterface(
+ XMultiServiceFactory.class, xComponent );
+
+ XDrawPagesSupplier xDrawPagesSupplier =
+ (XDrawPagesSupplier)UnoRuntime.queryInterface(
+ XDrawPagesSupplier.class, xComponent );
+ XDrawPages xDrawPages = xDrawPagesSupplier.getDrawPages();
+ XDrawPage xDrawPage = (XDrawPage)UnoRuntime.queryInterface(
+ XDrawPage.class, xDrawPages.getByIndex( 0 ));
+ XShapes xShapes = (XShapes)UnoRuntime.queryInterface(XShapes.class,
+ xDrawPage );
+
+
+ // create and insert the ControlShape
+ Object xObj = xFactory.createInstance(
+ "com.sun.star.drawing.ControlShape" );
+ XShape 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 = (XControlModel)UnoRuntime.queryInterface(
+ XControlModel.class,
+ xFactory.createInstance( "com.sun.star.form.component.GroupBox" ) );
+ XControlShape 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 = (XModel)UnoRuntime.queryInterface( XModel.class,
+ xComponent );
+ XController xController = xModel.getCurrentController();
+ XSelectionSupplier 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 ShapeColletion
+ XShapes xSelection = (XShapes)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 );
+ }
+}
diff --git a/odk/examples/DevelopersGuide/Drawing/CustomShowDemo.java b/odk/examples/DevelopersGuide/Drawing/CustomShowDemo.java
new file mode 100644
index 000000000000..de42d7ce426e
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Drawing/CustomShowDemo.java
@@ -0,0 +1,173 @@
+/*************************************************************************
+ *
+ * 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
+ @author Sven Jacobi
+ */
+
+// 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 = new Boolean( true );
+
+ xDrawDoc = Helper.createDocument( xOfficeContext,
+ "private:factory/simpress", "_blank", 0, pPropValues );
+
+ XDrawPagesSupplier 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 = (XDrawPage)UnoRuntime.queryInterface(
+ XDrawPage.class, xDrawPages.getByIndex( i ));
+ XNamed xPageName = (XNamed)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 = (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 = (XCustomPresentationSupplier)
+ 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 = (XSingleServiceFactory)
+ UnoRuntime.queryInterface( XSingleServiceFactory.class, xNameContainer );
+
+ Object xObj;
+ XIndexContainer xContainer;
+
+ /* instanciate an IndexContainer that will take
+ a list of draw pages for the first custom show */
+ xObj = xFactory.createInstance();
+ xContainer = (XIndexContainer)UnoRuntime.queryInterface( XIndexContainer.class, xObj );
+ for ( i = 5; i < 10; i++ )
+ xContainer.insertByIndex( xContainer.getCount(), xDrawPages.getByIndex( i ) );
+ xNameContainer.insertByName( "ShortVersion", xContainer );
+
+ /* instanciate an IndexContainer that will take
+ a list of draw page for the second custom show */
+ xObj = xFactory.createInstance();
+ xContainer = (XIndexContainer)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 = (XPresentationSupplier)
+ UnoRuntime.queryInterface( XPresentationSupplier.class, xDrawDoc );
+ XPresentation xPresentation = xPresSupplier.getPresentation();
+ XPropertySet xPresPropSet = (XPropertySet)
+ UnoRuntime.queryInterface( XPropertySet.class, xPresentation );
+ xPresPropSet.setPropertyValue( "CustomShow", "ShortVersion" );
+ }
+ catch( Exception ex )
+ {
+ System.out.println( ex );
+ }
+ System.exit( 0 );
+ }
+}
diff --git a/odk/examples/DevelopersGuide/Drawing/DrawViewDemo.java b/odk/examples/DevelopersGuide/Drawing/DrawViewDemo.java
new file mode 100644
index 000000000000..43fbe81f1713
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Drawing/DrawViewDemo.java
@@ -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.
+ *
+ *************************************************************************/
+
+// __________ 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
+ @author Sven Jacobi
+ */
+
+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 = new 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 =
+ (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 =
+ (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 =
+ (XPropertySet)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", new Boolean( true ) );
+
+ }
+ catch( Exception ex )
+ {
+ System.out.println( ex.getMessage() );
+ ex.printStackTrace(System.out);
+ }
+
+ System.exit( 0 );
+ }
+}
diff --git a/odk/examples/DevelopersGuide/Drawing/DrawingDemo.java b/odk/examples/DevelopersGuide/Drawing/DrawingDemo.java
new file mode 100644
index 000000000000..78b4b981da7c
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Drawing/DrawingDemo.java
@@ -0,0 +1,426 @@
+/*************************************************************************
+ *
+ * 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
+ @author Sven Jacobi
+ */
+
+// 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 = new 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 = (XNamed)UnoRuntime.queryInterface(
+ XNamed.class, xLastPage );
+
+ // beware, the page must have an 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 = (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 = (XShapes)
+ UnoRuntime.queryInterface( XShapes.class, xDrawPage );
+ xShapes.add( xPolyPolygonBezier );
+
+ XPropertySet xShapeProperties = (XPropertySet)
+ UnoRuntime.queryInterface( XPropertySet.class, xPolyPolygonBezier );
+
+ // get pagesize
+ XPropertySet xPageProperties = (XPropertySet)
+ 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", new Integer( 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 = (XShapes)
+ UnoRuntime.queryInterface( XShapes.class, xDrawPage );
+ xShapes.add( xGroup );
+
+ XShapes xShapesGroup = (XShapes)
+ 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 = (XShapeGrouper)
+ UnoRuntime.queryInterface( XShapeGrouper.class, xDrawPage );
+
+ XShapes xShapesPage = (XShapes)
+ UnoRuntime.queryInterface( XShapes.class, xDrawPage );
+
+ xShapeGrouper.group( xShapesPage );
+ }
+ catch ( Exception ex )
+ {
+ System.out.println( "Demo_Group2:" + ex );
+ }
+ }
+}
diff --git a/odk/examples/DevelopersGuide/Drawing/FillAndLineStyleDemo.java b/odk/examples/DevelopersGuide/Drawing/FillAndLineStyleDemo.java
new file mode 100644
index 000000000000..132338870fee
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Drawing/FillAndLineStyleDemo.java
@@ -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.
+ *
+ *************************************************************************/
+
+// __________ 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
+ @author Sven Jacobi
+ */
+
+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 = new 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 = (XShapes)
+ UnoRuntime.queryInterface( XShapes.class, xPage );
+ xShapes.add( xRectangle );
+
+ XPropertySet xPropSet = (XPropertySet)
+ 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", new Integer( 0x0000ff ) );
+ xPropSet.setPropertyValue( "LineWidth", new Integer( 200 ) );
+
+ }
+ catch( Exception ex )
+ {
+ System.out.println( ex );
+ }
+ System.exit( 0 );
+ }
+}
diff --git a/odk/examples/DevelopersGuide/Drawing/GluePointDemo.java b/odk/examples/DevelopersGuide/Drawing/GluePointDemo.java
new file mode 100644
index 000000000000..2835770e2ae5
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Drawing/GluePointDemo.java
@@ -0,0 +1,188 @@
+/*************************************************************************
+ *
+ * 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
+ @author Sven Jacobi
+ */
+
+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 = new Boolean( true );
+
+ xDrawDoc = Helper.createDocument( xOfficeContext,
+ "private:factory/sdraw", "_blank", 0, pPropValues );
+
+
+ XDrawPage xPage = PageHelper.getDrawPageByIndex( xDrawDoc, 0 );
+ XShapes 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 = (XPropertySet)
+ 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",
+ new Integer( nStartIndex ) );
+
+ xConnectorPropSet.setPropertyValue( "EndShape", xShape2 );
+ xConnectorPropSet.setPropertyValue( "EndGluePointIndex",
+ new Integer( 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 glue point at shape1
+ xGluePointsSupplier = (XGluePointsSupplier)
+ UnoRuntime.queryInterface( XGluePointsSupplier.class, xShape1 );
+ xIndexContainer = xGluePointsSupplier.getGluePoints();
+ xIdentifierContainer = (XIdentifierContainer)
+ UnoRuntime.queryInterface( XIdentifierContainer.class,
+ xIndexContainer );
+ int nIndexOfGluePoint1 = xIdentifierContainer.insert( aGluePoint );
+
+ // create and insert a glue point at shape2
+ xGluePointsSupplier = (XGluePointsSupplier)
+ UnoRuntime.queryInterface( XGluePointsSupplier.class, xShape2 );
+ xIndexContainer = xGluePointsSupplier.getGluePoints();
+ xIdentifierContainer = (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 = (XPropertySet)
+ UnoRuntime.queryInterface( XPropertySet.class, xConnector2 );
+
+ xConnector2PropSet.setPropertyValue( "StartShape", xShape1 );
+ xConnector2PropSet.setPropertyValue( "StartGluePointIndex",
+ new Integer( nIndexOfGluePoint1 ) );
+
+ xConnector2PropSet.setPropertyValue( "EndShape", xShape2 );
+ xConnector2PropSet.setPropertyValue( "EndGluePointIndex",
+ new Integer( nIndexOfGluePoint2 ) );
+
+
+ }
+ catch( Exception ex )
+ {
+ System.out.println( ex );
+ }
+ System.exit( 0 );
+ }
+}
diff --git a/odk/examples/DevelopersGuide/Drawing/GraphicExportDemo.java b/odk/examples/DevelopersGuide/Drawing/GraphicExportDemo.java
new file mode 100644
index 000000000000..65c9ecf99b4f
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Drawing/GraphicExportDemo.java
@@ -0,0 +1,152 @@
+/*************************************************************************
+ *
+ * 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
+ @author Sven Jacobi
+ */
+
+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 = new 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 = (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.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 = (XComponent)
+ UnoRuntime.queryInterface( XComponent.class, xPage );
+ xExporter.setSourceDocument( xComp );
+ XFilter 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 = (com.sun.star.util.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 );
+ }
+}
+
diff --git a/odk/examples/DevelopersGuide/Drawing/Helper.java b/odk/examples/DevelopersGuide/Drawing/Helper.java
new file mode 100644
index 000000000000..efd952ac0ce9
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Drawing/Helper.java
@@ -0,0 +1,83 @@
+/*************************************************************************
+ *
+ * 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;
+
+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 manger from the running
+ * offic eis returned.
+ */
+ static public com.sun.star.uno.XComponentContext connect()
+ throws Exception
+ {
+ // get the remote office component context
+ com.sun.star.uno.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
+ */
+ static public 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
+ {
+ com.sun.star.lang.XComponent xComponent = null;
+ com.sun.star.frame.XComponentLoader aLoader =
+ (com.sun.star.frame.XComponentLoader)UnoRuntime.queryInterface(
+ com.sun.star.frame.XComponentLoader.class,
+ xOfficeContext.getServiceManager().createInstanceWithContext(
+ "com.sun.star.frame.Desktop", xOfficeContext));
+
+ xComponent = (com.sun.star.lang.XComponent)UnoRuntime.queryInterface(
+ com.sun.star.lang.XComponent.class, aLoader.loadComponentFromURL(
+ sURL, sTargetFrame, nSearchFlags, aArgs ) );
+
+ if ( xComponent == null )
+ throw new Exception( "could not create document: " + sURL );
+ return xComponent;
+ }
+}
diff --git a/odk/examples/DevelopersGuide/Drawing/LayerDemo.java b/odk/examples/DevelopersGuide/Drawing/LayerDemo.java
new file mode 100644
index 000000000000..005468ed037f
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Drawing/LayerDemo.java
@@ -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.
+ *
+ *************************************************************************/
+
+// __________ 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
+ @author Sven Jacobi
+ */
+
+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 = new Boolean( true );
+
+ xDrawDoc = Helper.createDocument( xOfficeContext,
+ "private:factory/sdraw", "_blank", 0, pPropValues );
+
+
+ // create two rectangles
+ XDrawPage xPage = PageHelper.getDrawPageByIndex( xDrawDoc, 0 );
+ XShapes 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 = (XLayerSupplier)
+ (XLayerSupplier)UnoRuntime.queryInterface(
+ XLayerSupplier.class, xDrawDoc );
+ XNameAccess xNameAccess = xLayerSupplier.getLayerManager();
+ XLayerManager xLayerManager = (XLayerManager)
+ (XLayerManager)UnoRuntime.queryInterface(
+ XLayerManager.class, xNameAccess );
+
+ // create a layer and set its properties
+ XPropertySet xLayerPropSet;
+ XLayer xNotVisibleAndEditable = xLayerManager.insertNewByIndex(
+ xLayerManager.getCount() );
+
+ xLayerPropSet = (XPropertySet)
+ (XPropertySet)UnoRuntime.queryInterface(
+ XPropertySet.class, xNotVisibleAndEditable );
+ xLayerPropSet.setPropertyValue( "Name", "NotVisibleAndEditable" );
+ xLayerPropSet.setPropertyValue( "IsVisible", new Boolean( false ) );
+ xLayerPropSet.setPropertyValue( "IsLocked", new Boolean( true ) );
+
+ // create a second layer
+ XLayer xNotEditable = xLayerManager.insertNewByIndex(
+ xLayerManager.getCount() );
+
+ xLayerPropSet = (XPropertySet)
+ (XPropertySet)UnoRuntime.queryInterface(
+ XPropertySet.class, xNotEditable );
+ xLayerPropSet.setPropertyValue( "Name", "NotEditable" );
+ xLayerPropSet.setPropertyValue( "IsVisible", new Boolean( true ) );
+ xLayerPropSet.setPropertyValue( "IsLocked", new 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 );
+ }
+}
diff --git a/odk/examples/DevelopersGuide/Drawing/Makefile b/odk/examples/DevelopersGuide/Drawing/Makefile
new file mode 100644
index 000000000000..2bf39023d4fd
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Drawing/Makefile
@@ -0,0 +1,175 @@
+#*************************************************************************
+#
+# 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
+include $(SETTINGS)/dk.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 000000000000..787c0434be7f
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Drawing/ObjectTransformationDemo.java
@@ -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.
+ *
+ *************************************************************************/
+
+// __________ 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
+ @author Sven Jacobi
+ */
+
+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 = new Boolean( true );
+
+ xDrawDoc = Helper.createDocument( xOfficeContext,
+ "private:factory/simpress", "_blank", 0, pPropValues );
+
+ XDrawPage xPage = PageHelper.getDrawPageByIndex( xDrawDoc, 0 );
+ XPropertySet xPagePropSet= (XPropertySet)
+ UnoRuntime.queryInterface( XPropertySet.class, xPage );
+
+ XShapes 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 = (XPropertySet)
+ 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 );
+ }
+}
diff --git a/odk/examples/DevelopersGuide/Drawing/Organigram.java b/odk/examples/DevelopersGuide/Drawing/Organigram.java
new file mode 100644
index 000000000000..c564fd273178
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Drawing/Organigram.java
@@ -0,0 +1,191 @@
+/*************************************************************************
+ *
+ * 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.bridge.XUnoUrlResolver;
+
+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;
+
+
+/*
+ * OpenQuery.java
+ *
+ * Created on 6. Juli 2002, 10:25
+ */
+
+/**
+ *
+ * @author dschulten
+ */
+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 = (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 =
+ (com.sun.star.drawing.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 = (com.sun.star.drawing.XDrawPage)
+ UnoRuntime.queryInterface(com.sun.star.drawing.XDrawPage.class,
+ drawPage);
+
+ com.sun.star.lang.XMultiServiceFactory xDocumentFactory =
+ (com.sun.star.lang.XMultiServiceFactory)UnoRuntime.queryInterface(
+ com.sun.star.lang.XMultiServiceFactory.class, xDrawComponent);
+
+ com.sun.star.beans.XPropertySet xPageProps =
+ (com.sun.star.beans.XPropertySet)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 = (com.sun.star.drawing.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 = (com.sun.star.text.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 =
+ (com.sun.star.beans.XPropertySet)UnoRuntime.queryInterface(
+ com.sun.star.beans.XPropertySet.class, connector);
+ com.sun.star.drawing.XShape xConnector =
+ (com.sun.star.drawing.XShape)UnoRuntime.queryInterface(
+ com.sun.star.drawing.XShape.class, connector);
+ xDrawPage.add(xConnector);
+ xConnectorProps.setPropertyValue("StartShape", xStartShape);
+ xConnectorProps.setPropertyValue("EndShape", xShape);
+ xConnectorProps.setPropertyValue("StartGluePointIndex",
+ new Integer(2)); // 2 = bottom glue point
+ xConnectorProps.setPropertyValue("EndGluePointIndex",
+ new Integer(0)); // 0 = top glue point
+ }
+ }
+ }
+ }
+}
diff --git a/odk/examples/DevelopersGuide/Drawing/PageHelper.java b/odk/examples/DevelopersGuide/Drawing/PageHelper.java
new file mode 100644
index 000000000000..c612afa4e61b
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Drawing/PageHelper.java
@@ -0,0 +1,223 @@
+/*************************************************************************
+ *
+ * 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
+ */
+ static public int getDrawPageCount( XComponent xComponent )
+ {
+ XDrawPagesSupplier xDrawPagesSupplier =
+ (XDrawPagesSupplier)UnoRuntime.queryInterface(
+ XDrawPagesSupplier.class, xComponent );
+ XDrawPages xDrawPages = xDrawPagesSupplier.getDrawPages();
+ return xDrawPages.getCount();
+ }
+
+ /** get draw page by index
+ */
+ static public XDrawPage getDrawPageByIndex( XComponent xComponent, int nIndex )
+ throws com.sun.star.lang.IndexOutOfBoundsException,
+ com.sun.star.lang.WrappedTargetException
+ {
+ XDrawPagesSupplier xDrawPagesSupplier =
+ (XDrawPagesSupplier)UnoRuntime.queryInterface(
+ XDrawPagesSupplier.class, xComponent );
+ XDrawPages xDrawPages = xDrawPagesSupplier.getDrawPages();
+ return (XDrawPage)UnoRuntime.queryInterface(XDrawPage.class, xDrawPages.getByIndex( nIndex ));
+ }
+
+ /** creates and inserts a draw page into the giving position,
+ the method returns the new created page
+ */
+ static public XDrawPage insertNewDrawPageByIndex( XComponent xComponent, int nIndex )
+ throws Exception
+ {
+ XDrawPagesSupplier xDrawPagesSupplier =
+ (XDrawPagesSupplier)UnoRuntime.queryInterface(
+ XDrawPagesSupplier.class, xComponent );
+ XDrawPages xDrawPages = xDrawPagesSupplier.getDrawPages();
+ return xDrawPages.insertNewByIndex( nIndex );
+ }
+
+ /** removes the given page
+ */
+ static public void removeDrawPage( XComponent xComponent, XDrawPage xDrawPage )
+ {
+ XDrawPagesSupplier xDrawPagesSupplier =
+ (XDrawPagesSupplier)UnoRuntime.queryInterface(
+ XDrawPagesSupplier.class, xComponent );
+ XDrawPages xDrawPages = xDrawPagesSupplier.getDrawPages();
+ xDrawPages.remove( xDrawPage );
+ }
+
+ /** get size of the given page
+ */
+ static public Size getPageSize( XDrawPage xDrawPage )
+ throws com.sun.star.beans.UnknownPropertyException,
+ com.sun.star.lang.WrappedTargetException
+ {
+ XPropertySet xPageProperties = (XPropertySet)
+ 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
+ */
+ static public int getMasterPageCount( XComponent xComponent )
+ {
+ XMasterPagesSupplier xMasterPagesSupplier =
+ (XMasterPagesSupplier)UnoRuntime.queryInterface(
+ XMasterPagesSupplier.class, xComponent );
+ XDrawPages xDrawPages = xMasterPagesSupplier.getMasterPages();
+ return xDrawPages.getCount();
+ }
+
+ /** get master page by index
+ */
+ static public XDrawPage getMasterPageByIndex( XComponent xComponent, int nIndex )
+ throws com.sun.star.lang.IndexOutOfBoundsException,
+ com.sun.star.lang.WrappedTargetException
+ {
+ XMasterPagesSupplier xMasterPagesSupplier =
+ (XMasterPagesSupplier)UnoRuntime.queryInterface(
+ XMasterPagesSupplier.class, xComponent );
+ XDrawPages xDrawPages = xMasterPagesSupplier.getMasterPages();
+ return (XDrawPage)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
+ */
+ static public XDrawPage insertNewMasterPageByIndex( XComponent xComponent, int nIndex )
+ {
+ XMasterPagesSupplier xMasterPagesSupplier =
+ (XMasterPagesSupplier)UnoRuntime.queryInterface(
+ XMasterPagesSupplier.class, xComponent );
+ XDrawPages xDrawPages = xMasterPagesSupplier.getMasterPages();
+ return xDrawPages.insertNewByIndex( nIndex );
+ }
+
+ /** removes the given page
+ */
+ static public void removeMasterPage( XComponent xComponent, XDrawPage xDrawPage )
+ {
+ XMasterPagesSupplier xMasterPagesSupplier =
+ (XMasterPagesSupplier)UnoRuntime.queryInterface(
+ XMasterPagesSupplier.class, xComponent );
+ XDrawPages xDrawPages = xMasterPagesSupplier.getMasterPages();
+ xDrawPages.remove( xDrawPage );
+ }
+
+ /** return the corresponding masterpage for the giving drawpage
+ */
+ static public XDrawPage getMasterPage( XDrawPage xDrawPage )
+ {
+ XMasterPageTarget xMasterPageTarget =
+ (XMasterPageTarget)UnoRuntime.queryInterface(
+ XMasterPageTarget.class, xDrawPage );
+ return xMasterPageTarget.getMasterPage();
+ }
+
+ /** sets given masterpage at the drawpage
+ */
+ static public void setMasterPage( XDrawPage xDrawPage, XDrawPage xMasterPage )
+ {
+ XMasterPageTarget 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
+ */
+ static public boolean isImpressDocument( XComponent xComponent )
+ {
+ XServiceInfo xInfo = (XServiceInfo)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
+ */
+ static public XDrawPage getNotesPage( XDrawPage xDrawPage )
+ {
+ XPresentationPage aPresentationPage =
+ (XPresentationPage)UnoRuntime.queryInterface(
+ XPresentationPage.class, xDrawPage );
+ return aPresentationPage.getNotesPage();
+ }
+
+ /** in impress each documents has one handout page
+ */
+ static public XDrawPage getHandoutMasterPage( XComponent xComponent )
+ {
+ XHandoutMasterSupplier aHandoutMasterSupplier =
+ (XHandoutMasterSupplier)UnoRuntime.queryInterface(
+ XHandoutMasterSupplier.class, xComponent );
+ return aHandoutMasterSupplier.getHandoutMasterPage();
+ }
+}
diff --git a/odk/examples/DevelopersGuide/Drawing/PresentationDemo.java b/odk/examples/DevelopersGuide/Drawing/PresentationDemo.java
new file mode 100644
index 000000000000..88c100e877f3
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Drawing/PresentationDemo.java
@@ -0,0 +1,239 @@
+/*************************************************************************
+ *
+ * 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
+ @author Sven Jacobi
+ */
+
+// 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 = new 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 = (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", new Boolean( false ) );
+ xShapePropSet.setPropertyValue( "DimPrevious", new Boolean( true ) );
+ xShapePropSet.setPropertyValue( "DimColor", new Integer( 0xff0000 ) );
+
+
+ // set the slide transition for the second page
+ xPage = PageHelper.getDrawPageByIndex( xDrawDoc, 1 );
+ xShapes = (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 = (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 = (XPropertySet)
+ 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 = (XPropertySet)
+ 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 = (XNamed)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 = (XPresentationSupplier)
+ UnoRuntime.queryInterface( XPresentationSupplier.class, xDrawDoc );
+ XPresentation xPresentation = xPresSupplier.getPresentation();
+ XPropertySet xPresPropSet = (XPropertySet)
+ UnoRuntime.queryInterface( XPropertySet.class, xPresentation );
+ xPresPropSet.setPropertyValue( "IsEndless", new Boolean( true ) );
+ xPresPropSet.setPropertyValue( "IsAlwaysOnTop", new Boolean( true ) );
+ xPresPropSet.setPropertyValue( "Pause", new Integer( 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 = (XServiceInfo)UnoRuntime.queryInterface(
+ XServiceInfo.class, xPage );
+ if ( xInfo.supportsService( "com.sun.star.presentation.DrawPage" ) == true )
+ {
+ try
+ {
+ XPropertySet xPropSet = (XPropertySet)
+ UnoRuntime.queryInterface( XPropertySet.class, xPage );
+ xPropSet.setPropertyValue( "Effect", eEffect );
+ xPropSet.setPropertyValue( "Speed", eSpeed );
+ xPropSet.setPropertyValue( "Change", new Integer( nChange ) );
+ xPropSet.setPropertyValue( "Duration", new Integer( nDuration ) );
+ }
+ catch( Exception ex )
+ {
+ }
+ }
+ }
+}
diff --git a/odk/examples/DevelopersGuide/Drawing/ShapeHelper.java b/odk/examples/DevelopersGuide/Drawing/ShapeHelper.java
new file mode 100644
index 000000000000..7959b642fe0f
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Drawing/ShapeHelper.java
@@ -0,0 +1,145 @@
+/*************************************************************************
+ *
+ * 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 = (XPropertySet)
+ 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 =
+ (XMultiServiceFactory )UnoRuntime.queryInterface(
+ XMultiServiceFactory.class, xDrawDoc );
+ Object xObj = xFactory.createInstance( sShapeType );
+ xShape = (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 = (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 = (XTextRange)
+ UnoRuntime.queryInterface( XTextRange.class, xTextCursor );
+ xTextRange.setString( sText );
+ xTextCursor.gotoEnd( true );
+ XPropertySet xPropSet = (XPropertySet)
+ 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 = (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 = (XTextContent)UnoRuntime.queryInterface(
+ XTextContent.class, xObj );
+ XPropertySet xParaPropSet = (XPropertySet)
+ UnoRuntime.queryInterface( XPropertySet.class, xTextContent );
+ xParaPropSet.setPropertyValue( sPropName, aValue );
+ }
+ }
+ }
+ }
+}
diff --git a/odk/examples/DevelopersGuide/Drawing/SimplePresentation.odp b/odk/examples/DevelopersGuide/Drawing/SimplePresentation.odp
new file mode 100644
index 000000000000..3f40f76608ff
--- /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 000000000000..452526c1fcec
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Drawing/StyleDemo.java
@@ -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.
+ *
+ *************************************************************************/
+
+// __________ 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.container.XNameAccess;
+
+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
+ @author Sven Jacobi
+ */
+
+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 = new 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 =
+ (XModel)UnoRuntime.queryInterface(
+ XModel.class, xComponent );
+ com.sun.star.style.XStyleFamiliesSupplier xSFS =
+ (com.sun.star.style.XStyleFamiliesSupplier)
+ 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 =
+ (com.sun.star.container.XNameAccess)
+ 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 = (com.sun.star.style.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 = (XPropertySet)
+ UnoRuntime.queryInterface( XPropertySet.class, xStyle );
+ XPropertySetInfo xStylePropSetInfo =
+ xStylePropSet.getPropertySetInfo();
+ if ( xStylePropSetInfo.hasPropertyByName( "CharColor" ) )
+ {
+ xStylePropSet.setPropertyValue( "CharColor",
+ new Integer( 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 = (XNameAccess)
+ UnoRuntime.queryInterface(com.sun.star.container.XNameAccess.class,
+ obj );
+ obj = xStyles.getByName( "title1" );
+ com.sun.star.style.XStyle xTitle1Style = (com.sun.star.style.XStyle)
+ UnoRuntime.queryInterface( com.sun.star.style.XStyle.class, obj );
+
+ XDrawPagesSupplier xDrawPagesSupplier =
+ (XDrawPagesSupplier)UnoRuntime.queryInterface(
+ XDrawPagesSupplier.class, xComponent );
+ XDrawPages xDrawPages = xDrawPagesSupplier.getDrawPages();
+ XDrawPage xDrawPage = (XDrawPage)UnoRuntime.queryInterface(
+ XDrawPage.class, xDrawPages.getByIndex( 0 ));
+ XShapes 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 = (XPropertySet)
+ UnoRuntime.queryInterface( XPropertySet.class, xShape );
+ xPropSet.setPropertyValue( "Style", xTitle1Style );
+
+ }
+ catch( Exception ex )
+ {
+ System.out.println( ex );
+ }
+ System.exit( 0 );
+ }
+}
diff --git a/odk/examples/DevelopersGuide/Drawing/TextDemo.java b/odk/examples/DevelopersGuide/Drawing/TextDemo.java
new file mode 100644
index 000000000000..579f2167da09
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Drawing/TextDemo.java
@@ -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.
+ *
+ *************************************************************************/
+
+// __________ 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
+ @author Sven Jacobi
+ */
+
+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 = new Boolean( true );
+
+ xDrawDoc = Helper.createDocument( xOfficeContext,
+ "private:factory/sdraw", "_blank", 0, pPropValues );
+
+ XDrawPage xPage = PageHelper.getDrawPageByIndex( xDrawDoc, 0 );
+ XShapes 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 = (XPropertySet)
+ UnoRuntime.queryInterface( XPropertySet.class, xRectangle );
+
+
+ // first paragraph
+ xTextPropSet = ShapeHelper.addPortion( xRectangle, "Portion1", false );
+ xTextPropSet.setPropertyValue( "CharColor", new Integer( 0xff0000 ) );
+ xTextPropSet = ShapeHelper.addPortion( xRectangle, "Portion2", false );
+ xTextPropSet.setPropertyValue( "CharColor", new Integer( 0x8080ff ) );
+ aLineSpacing.Height = 100;
+ ShapeHelper.setPropertyForLastParagraph( xRectangle, "ParaLineSpacing",
+ aLineSpacing );
+
+ // second paragraph
+ xTextPropSet = ShapeHelper.addPortion( xRectangle, "Portion3", true );
+ xTextPropSet.setPropertyValue( "CharColor", new Integer( 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 = (XPropertySet)
+ UnoRuntime.queryInterface( XPropertySet.class, xRectangle );
+ xShapePropSet.setPropertyValue( "TextFitToSize",
+ TextFitToSizeType.PROPORTIONAL );
+ xShapePropSet.setPropertyValue( "TextLeftDistance", new Integer(2500));
+ xShapePropSet.setPropertyValue( "TextRightDistance", new Integer(2500));
+ xShapePropSet.setPropertyValue( "TextUpperDistance", new Integer(2500));
+ xShapePropSet.setPropertyValue( "TextLowerDistance", new Integer(2500));
+ xTextPropSet = ShapeHelper.addPortion( xRectangle,
+ "using TextFitToSize", false );
+ xTextPropSet.setPropertyValue( "ParaAdjust", ParagraphAdjust.CENTER );
+ xTextPropSet.setPropertyValue( "CharColor", new Integer(0xff00));
+ xTextPropSet = ShapeHelper.addPortion(xRectangle,
+ "and a Border distance of 2,5 cm",
+ true );
+ xTextPropSet.setPropertyValue( "CharColor", new Integer( 0xff0000 ) );
+
+ }
+ catch( Exception ex )
+ {
+ System.out.println( ex );
+ }
+ System.exit( 0 );
+ }
+}
diff --git a/odk/examples/DevelopersGuide/Drawing/makefile.mk b/odk/examples/DevelopersGuide/Drawing/makefile.mk
new file mode 100644
index 000000000000..50c892f61f74
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Drawing/makefile.mk
@@ -0,0 +1,81 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ=..$/..$/..
+PRJNAME=odk
+TARGET=copying
+
+#----------------------------------------------------------------
+.INCLUDE: settings.mk
+.INCLUDE: $(PRJ)$/util$/makefile.pmk
+#----------------------------------------------------------------
+
+#----------------------------------------------------
+# this makefile is only used for copying the example
+# files into the SDK
+#----------------------------------------------------
+
+DRAWING_FILES=\
+ $(DESTDIRDEVGUIDEEXAMPLES)$/Drawing$/ChangeOrderDemo.java \
+ $(DESTDIRDEVGUIDEEXAMPLES)$/Drawing$/ControlAndSelectDemo.java \
+ $(DESTDIRDEVGUIDEEXAMPLES)$/Drawing$/CustomShowDemo.java \
+ $(DESTDIRDEVGUIDEEXAMPLES)$/Drawing$/DrawingDemo.java \
+ $(DESTDIRDEVGUIDEEXAMPLES)$/Drawing$/DrawViewDemo.java \
+ $(DESTDIRDEVGUIDEEXAMPLES)$/Drawing$/FillAndLineStyleDemo.java \
+ $(DESTDIRDEVGUIDEEXAMPLES)$/Drawing$/GluePointDemo.java \
+ $(DESTDIRDEVGUIDEEXAMPLES)$/Drawing$/GraphicExportDemo.java \
+ $(DESTDIRDEVGUIDEEXAMPLES)$/Drawing$/Helper.java \
+ $(DESTDIRDEVGUIDEEXAMPLES)$/Drawing$/LayerDemo.java \
+ $(DESTDIRDEVGUIDEEXAMPLES)$/Drawing$/Makefile \
+ $(DESTDIRDEVGUIDEEXAMPLES)$/Drawing$/ObjectTransformationDemo.java \
+ $(DESTDIRDEVGUIDEEXAMPLES)$/Drawing$/Organigram.java \
+ $(DESTDIRDEVGUIDEEXAMPLES)$/Drawing$/PageHelper.java \
+ $(DESTDIRDEVGUIDEEXAMPLES)$/Drawing$/PresentationDemo.java \
+ $(DESTDIRDEVGUIDEEXAMPLES)$/Drawing$/ShapeHelper.java \
+ $(DESTDIRDEVGUIDEEXAMPLES)$/Drawing$/SimplePresentation.odp \
+ $(DESTDIRDEVGUIDEEXAMPLES)$/Drawing$/StyleDemo.java \
+ $(DESTDIRDEVGUIDEEXAMPLES)$/Drawing$/TextDemo.java
+
+DIR_FILE_LIST= \
+ $(DRAWING_FILES) \
+
+DIR_DIRECTORY_LIST=$(uniq $(DIR_FILE_LIST:d))
+DIR_CREATE_FLAG=$(MISC)$/devguide_drawing_dirs_created.txt
+DIR_FILE_FLAG=$(MISC)$/devguide_drawing.txt
+
+#--------------------------------------------------
+# TARGETS
+#--------------------------------------------------
+all : \
+ $(DIR_FILE_LIST) \
+ $(DIR_FILE_FLAG)
+
+#--------------------------------------------------
+# use global rules
+#--------------------------------------------------
+.INCLUDE: $(PRJ)$/util$/odk_rules.pmk
+
diff --git a/odk/examples/DevelopersGuide/Extensions/DialogWithHelp/Addons.xcu b/odk/examples/DevelopersGuide/Extensions/DialogWithHelp/Addons.xcu
new file mode 100644
index 000000000000..4d25fee331e8
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Extensions/DialogWithHelp/Addons.xcu
@@ -0,0 +1,58 @@
+<?xml version='1.0' encoding='UTF-8'?>
+
+<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>
+ <prop oor:name="Target" oor:type="xs:string">
+ <value>_self</value>
+ </prop>
+ <prop oor:name="ImageIdentifier" oor:type="xs:string">
+ <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="ImageIdentifier" oor:type="xs:string">
+ <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 000000000000..e9e84bf4e9c4
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Extensions/DialogWithHelp/DialogWithHelp/Dialog1.xdl
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!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> \ No newline at end of file
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 000000000000..9e7745e228aa
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Extensions/DialogWithHelp/DialogWithHelp/Module1.xba
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!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 000000000000..bd7d00efd279
--- /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 000000000000..423177601caf
--- /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 000000000000..a7b501ba1b82
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Extensions/DialogWithHelp/META-INF/manifest.xml
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<manifest: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 000000000000..d46590ef5e22
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Extensions/DialogWithHelp/Makefile
@@ -0,0 +1,118 @@
+#*************************************************************************
+#
+# 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
+include $(SETTINGS)/dk.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 000000000000..c2f2e3986706
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Extensions/DialogWithHelp/description.xml
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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 000000000000..34909072f097
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Extensions/DialogWithHelp/help/de/com.foocorp.foo-ext/page1.xhp
@@ -0,0 +1,73 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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 fuer 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 Section 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 Fuell-Text</paragraph>
+<paragraph role="paragraph" id="par_id0005" xml-lang="de">Ich mag Fuell-Text. Ich mag Fuell-Text. Ich mag Fuell-Text.</paragraph>
+<paragraph role="paragraph" id="par_id0006" xml-lang="de">Ich mag Fuell-Text. Ich mag Fuell-Text. Ich mag Fuell-Text.</paragraph>
+<paragraph role="paragraph" id="par_id0007" xml-lang="de">Ich mag Fuell-Text. Ich mag Fuell-Text. Ich mag Fuell-Text.</paragraph>
+<paragraph role="paragraph" id="par_id0008" xml-lang="de">Ich mag Fuell-Text. Ich mag Fuell-Text. Ich mag Fuell-Text.</paragraph>
+<paragraph role="paragraph" id="par_id0009" xml-lang="de">Ich mag Fuell-Text. Ich mag Fuell-Text. Ich mag Fuell-Text.</paragraph>
+<paragraph role="paragraph" id="par_id0010" xml-lang="de">Ich mag Fuell-Text. Ich mag Fuell-Text. Ich mag Fuell-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 Fuell-Text</paragraph>
+<paragraph role="paragraph" id="par_id0012" xml-lang="de" >Dieser Text fuellt die Seite um die Section "target" oben anzeigen zu koennen.</paragraph>
+<paragraph role="paragraph" id="par_id0013" xml-lang="de" >Dieser Text fuellt die Seite um die Section "target" oben anzeigen zu koennen.</paragraph>
+<paragraph role="paragraph" id="par_id0014" xml-lang="de" >Dieser Text fuellt die Seite um die Section "target" oben anzeigen zu koennen.</paragraph>
+<paragraph role="paragraph" id="par_id0015" xml-lang="de" >Dieser Text fuellt die Seite um die Section "target" oben anzeigen zu koennen.</paragraph>
+<paragraph role="paragraph" id="par_id0016" xml-lang="de" >Dieser Text fuellt die Seite um die Section "target" oben anzeigen zu koennen.</paragraph>
+<paragraph role="paragraph" id="par_id0017" xml-lang="de" >Dieser Text fuellt die Seite um die Section "target" oben anzeigen zu koennen.</paragraph>
+<paragraph role="paragraph" id="par_id0018" xml-lang="de" >Dieser Text fuellt die Seite um die Section "target" oben anzeigen zu koennen.</paragraph>
+<paragraph role="paragraph" id="par_id0019" xml-lang="de" >Dieser Text fuellt die Seite um die Section "target" oben anzeigen zu koennen.</paragraph>
+<paragraph role="paragraph" id="par_id0020" xml-lang="de" >Dieser Text fuellt die Seite um die Section "target" oben anzeigen zu koennen.</paragraph>
+<paragraph role="paragraph" id="par_id0021" xml-lang="de" >Dieser Text fuellt die Seite um die Section "target" oben anzeigen zu koennen.</paragraph>
+<paragraph role="paragraph" id="par_id0022" xml-lang="de" >Dieser Text fuellt die Seite um die Section "target" oben anzeigen zu koennen.</paragraph>
+<paragraph role="paragraph" id="par_id0023" xml-lang="de" >Dieser Text fuellt die Seite um die Section "target" oben anzeigen zu koennen.</paragraph>
+<paragraph role="paragraph" id="par_id0024" xml-lang="de" >Dieser Text fuellt die Seite um die Section "target" oben anzeigen zu koennen.</paragraph>
+<paragraph role="paragraph" id="par_id0025" xml-lang="de" >Dieser Text fuellt die Seite um die Section "target" oben anzeigen zu koennen.</paragraph>
+<paragraph role="paragraph" id="par_id0026" xml-lang="de" >Dieser Text fuellt die Seite um die Section "target" oben anzeigen zu koennen.</paragraph>
+<paragraph role="paragraph" id="par_id0027" xml-lang="de" >Dieser Text fuellt die Seite um die Section "target" oben anzeigen zu koennen.</paragraph>
+<paragraph role="paragraph" id="par_id0028" xml-lang="de" >Dieser Text fuellt die Seite um die Section "target" oben anzeigen zu koennen.</paragraph>
+<paragraph role="paragraph" id="par_id0029" xml-lang="de" >Dieser Text fuellt die Seite um die Section "target" oben anzeigen zu koennen.</paragraph>
+<paragraph role="paragraph" id="par_id0030" xml-lang="de" >Dieser Text fuellt die Seite um die Section "target" oben anzeigen zu koennen.</paragraph>
+<paragraph role="paragraph" id="par_id0031" xml-lang="de" >Dieser Text fuellt die Seite um die Section "target" oben anzeigen zu koennen.</paragraph>
+<paragraph role="paragraph" id="par_id0032" xml-lang="de" >Dieser Text fuellt die Seite um die Section "target" oben anzeigen zu koennen.</paragraph>
+<paragraph role="paragraph" id="par_id0033" xml-lang="de" >Dieser Text fuellt die Seite um die Section "target" oben anzeigen zu koennen.</paragraph>
+<paragraph role="paragraph" id="par_id0034" xml-lang="de" >Dieser Text fuellt die Seite um die Section "target" oben anzeigen zu koennen.</paragraph>
+<paragraph role="paragraph" id="par_id0035" xml-lang="de" >Dieser Text fuellt die Seite um die Section "target" oben anzeigen zu koennen.</paragraph>
+<paragraph role="paragraph" id="par_id0036" xml-lang="de" >Dieser Text fuellt die Seite um die Section "target" oben anzeigen zu koennen.</paragraph>
+<section id="relatedtopics">
+<paragraph role="paragraph" id="par_id0037" xml-lang="de">
+Diese Section zeigt einen Link der durch Einfuegen 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 000000000000..7436b51b6ca2
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Extensions/DialogWithHelp/help/de/com.foocorp.foo-ext/page2.xhp
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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 Section 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 Einfuegen 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 000000000000..50358d066245
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Extensions/DialogWithHelp/help/de/com.foocorp.foo-ext/subfolder/anotherpage.xhp
@@ -0,0 +1,100 @@
+<?xml version="1.0" encoding="utf-8"?>
+<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 oeffnen</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 fuer 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 fuer 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 fuelltext</paragraph>
+<paragraph role="paragraph" id="par_id0006" xml-lang="de">Dieser Text fuellt die Seite.</paragraph>
+<paragraph role="paragraph" id="par_id0007" xml-lang="de">Dieser Text fuellt die Seite.</paragraph>
+<paragraph role="paragraph" id="par_id0008" xml-lang="de">Dieser Text fuellt die Seite.</paragraph>
+<paragraph role="paragraph" id="par_id0009" xml-lang="de">Dieser Text fuellt die Seite.</paragraph>
+<paragraph role="paragraph" id="par_id0010" xml-lang="de">Dieser Text fuellt die Seite.</paragraph>
+<paragraph role="paragraph" id="par_id0011" xml-lang="de">Dieser Text fuellt die Seite.</paragraph>
+<paragraph role="paragraph" id="par_id0012" xml-lang="de">Dieser Text fuellt die Seite.</paragraph>
+<paragraph role="paragraph" id="par_id0013" xml-lang="de">Dieser Text fuellt die Seite.</paragraph>
+<paragraph role="paragraph" id="par_id0014" xml-lang="de">Dieser Text fuellt die Seite.</paragraph>
+<paragraph role="paragraph" id="par_id0015" xml-lang="de">Dieser Text fuellt die Seite.</paragraph>
+<paragraph role="paragraph" id="par_id0016" xml-lang="de">Dieser Text fuellt die Seite.</paragraph>
+<paragraph role="paragraph" id="par_id0017" xml-lang="de">Dieser Text fuellt die Seite.</paragraph>
+<paragraph role="paragraph" id="par_id0018" xml-lang="de">Dieser Text fuellt die Seite.</paragraph>
+<paragraph role="paragraph" id="par_id0019" xml-lang="de">Dieser Text fuellt die Seite.</paragraph>
+<paragraph role="paragraph" id="par_id0020" xml-lang="de">Dieser Text fuellt die Seite.</paragraph>
+<paragraph role="paragraph" id="par_id0021" xml-lang="de">Dieser Text fuellt die Seite.</paragraph>
+<paragraph role="paragraph" id="par_id0022" xml-lang="de">Dieser Text fuellt die Seite.</paragraph>
+<paragraph role="paragraph" id="par_id0023" xml-lang="de">Dieser Text fuellt die Seite.</paragraph>
+<paragraph role="paragraph" id="par_id0024" xml-lang="de">Dieser Text fuellt die Seite.</paragraph>
+<paragraph role="paragraph" id="par_id0025" xml-lang="de">Dieser Text fuellt die Seite.</paragraph>
+<paragraph role="paragraph" id="par_id0026" xml-lang="de">Dieser Text fuellt die Seite.</paragraph>
+<paragraph role="paragraph" id="par_id0027" xml-lang="de">Dieser Text fuellt die Seite.</paragraph>
+<paragraph role="paragraph" id="par_id0028" xml-lang="de">Dieser Text fuellt die Seite.</paragraph>
+<paragraph role="paragraph" id="par_id0029" xml-lang="de">Dieser Text fuellt die Seite.</paragraph>
+<paragraph role="paragraph" id="par_id0030" xml-lang="de">Dieser Text fuellt die Seite.</paragraph>
+<paragraph role="paragraph" id="par_id0031" xml-lang="de">Dieser Text fuellt die Seite.</paragraph>
+<paragraph role="paragraph" id="par_id0032" xml-lang="de">Dieser Text fuellt die Seite.</paragraph>
+<paragraph role="paragraph" id="par_id0033" xml-lang="de">Dieser Text fuellt die Seite.</paragraph>
+<paragraph role="paragraph" id="par_id0034" xml-lang="de">Dieser Text fuellt die Seite.</paragraph>
+<paragraph role="paragraph" id="par_id0035" xml-lang="de">Dieser Text fuellt die Seite.</paragraph>
+<paragraph role="paragraph" id="par_id0036" xml-lang="de">Dieser Text fuellt die Seite.</paragraph>
+<paragraph role="paragraph" id="par_id0037" xml-lang="de">Dieser Text fuellt die Seite.</paragraph>
+<paragraph role="paragraph" id="par_id0038" xml-lang="de">Dieser Text fuellt die Seite.</paragraph>
+<paragraph role="paragraph" id="par_id0039" xml-lang="de">Dieser Text fuellt die Seite.</paragraph>
+<paragraph role="paragraph" id="par_id0040" xml-lang="de">Dieser Text fuellt die Seite.</paragraph>
+<paragraph role="paragraph" id="par_id0041" xml-lang="de">Dieser Text fuellt die Seite.</paragraph>
+<paragraph role="paragraph" id="par_id0042" xml-lang="de">Dieser Text fuellt die Seite.</paragraph>
+<paragraph role="paragraph" id="par_id0043" xml-lang="de">Dieser Text fuellt die Seite.</paragraph>
+<paragraph role="paragraph" id="par_id0044" xml-lang="de">Dieser Text fuellt die Seite.</paragraph>
+<paragraph role="paragraph" id="par_id0045" xml-lang="de">Dieser Text fuellt die Seite.</paragraph>
+<paragraph role="paragraph" id="par_id0046" xml-lang="de">Dieser Text fuellt die Seite.</paragraph>
+<paragraph role="paragraph" id="par_id0047" xml-lang="de">Dieser Text fuellt die Seite.</paragraph>
+<paragraph role="paragraph" id="par_id0048" xml-lang="de">Dieser Text fuellt die Seite.</paragraph>
+<paragraph role="paragraph" id="par_id0049" xml-lang="de">Dieser Text fuellt die Seite.</paragraph>
+<paragraph role="paragraph" id="par_id0050" xml-lang="de">Dieser Text fuellt die Seite.</paragraph>
+<paragraph role="paragraph" id="par_id0051" xml-lang="de">Dieser Text fuellt die Seite.</paragraph>
+<paragraph role="paragraph" id="par_id0052" xml-lang="de">Dieser Text fuellt die Seite.</paragraph>
+<paragraph role="paragraph" id="par_id0053" xml-lang="de">Dieser Text fuellt die Seite.</paragraph>
+<paragraph role="paragraph" id="par_id0054" xml-lang="de">Dieser Text fuellt die Seite.</paragraph>
+<paragraph role="paragraph" id="par_id0055" xml-lang="de">Dieser Text fuellt die Seite.</paragraph>
+<paragraph role="paragraph" id="par_id0056" xml-lang="de">Dieser Text fuellt die Seite.</paragraph>
+<paragraph role="paragraph" id="par_id0057" xml-lang="de">Dieser Text fuellt die Seite.</paragraph>
+<paragraph role="paragraph" id="par_id0058" xml-lang="de">Dieser Text fuellt die Seite.</paragraph>
+<paragraph role="paragraph" id="par_id0059" xml-lang="de">Dieser Text fuellt die Seite.</paragraph>
+<paragraph role="paragraph" id="par_id0060" xml-lang="de">Dieser Text fuellt die Seite.</paragraph>
+<paragraph role="paragraph" id="par_id0061" xml-lang="de">Dieser Text fuellt die Seite.</paragraph>
+<paragraph role="paragraph" id="par_id0062" xml-lang="de">Dieser Text fuellt die Seite.</paragraph>
+<paragraph role="paragraph" id="par_id0063" xml-lang="de">Dieser Text fuellt die Seite.</paragraph>
+<paragraph role="paragraph" id="par_id0064" xml-lang="de">Dieser Text fuellt die Seite.</paragraph>
+<paragraph role="paragraph" id="par_id0065" xml-lang="de">Dieser Text fuellt die Seite.</paragraph>
+<paragraph role="paragraph" id="par_id0066" xml-lang="de">Dieser Text fuellt die Seite.</paragraph>
+<paragraph role="paragraph" id="par_id0067" xml-lang="de">Dieser Text fuellt die Seite.</paragraph>
+<paragraph role="paragraph" id="par_id0068" xml-lang="de">Dieser Text fuellt die Seite.</paragraph>
+<paragraph role="paragraph" id="par_id0069" xml-lang="de">Dieser Text fuellt 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 000000000000..4d4974206908
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Extensions/DialogWithHelp/help/en/com.foocorp.foo-ext/page1.xhp
@@ -0,0 +1,73 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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 000000000000..02bee1ce058e
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Extensions/DialogWithHelp/help/en/com.foocorp.foo-ext/page2.xhp
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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 000000000000..e2ccaa4e1ba9
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Extensions/DialogWithHelp/help/en/com.foocorp.foo-ext/subfolder/anotherpage.xhp
@@ -0,0 +1,100 @@
+<?xml version="1.0" encoding="utf-8"?>
+<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/FirstConnection.java b/odk/examples/DevelopersGuide/FirstSteps/FirstConnection.java
new file mode 100644
index 000000000000..d38357fe4574
--- /dev/null
+++ b/odk/examples/DevelopersGuide/FirstSteps/FirstConnection.java
@@ -0,0 +1,58 @@
+/*************************************************************************
+ *
+ * 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 FirstConnection extends java.lang.Object {
+
+ 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 = (null != xMCF ? "available" : "not available");
+ System.out.println( "remote ServiceManager is " + available );
+ }
+ catch (java.lang.Exception e){
+ e.printStackTrace();
+ }
+ finally {
+ System.exit(0);
+ }
+ }
+}
diff --git a/odk/examples/DevelopersGuide/FirstSteps/FirstLoadComponent.java b/odk/examples/DevelopersGuide/FirstSteps/FirstLoadComponent.java
new file mode 100644
index 000000000000..6382c600a143
--- /dev/null
+++ b/odk/examples/DevelopersGuide/FirstSteps/FirstLoadComponent.java
@@ -0,0 +1,329 @@
+/*************************************************************************
+ *
+ * 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 {
+
+ /** Creates a new instance of FirstLoadComponent */
+ public 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 = (XComponentLoader)
+ UnoRuntime.queryInterface(XComponentLoader.class, desktop);
+
+ PropertyValue[] loadProps = new PropertyValue[0];
+ XComponent xSpreadsheetComponent = xComponentLoader.loadComponentFromURL("private:factory/scalc", "_blank", 0, loadProps);
+
+ XSpreadsheetDocument 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 = (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 = (XPropertySet)UnoRuntime.queryInterface(
+ XPropertySet.class, xCell);
+ xCellProps.setPropertyValue("CellStyle", "Result");
+
+ XModel xSpreadsheetModel = (XModel)UnoRuntime.queryInterface(
+ XModel.class, xSpreadsheetComponent);
+ XController xSpreadsheetController = xSpreadsheetModel.getCurrentController();
+ XSpreadsheetView 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 = new 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 = (XCellRangesQuery)
+ 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 = (XCell)UnoRuntime.queryInterface(XCell.class, formulaCell);
+ XCellAddressable xCellAddress = (XCellAddressable)
+ 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 );
+ }
+ }
+
+}
+
+
+// import com.sun.star.uno.UnoRuntime;
+// import com.sun.star.uno.XComponentContext;
+// import com.sun.star.lang.XMultiComponentFactory;
+// import com.sun.star.lang.XComponent;
+// import com.sun.star.beans.XPropertySet;
+// import com.sun.star.beans.PropertyValue;
+// import com.sun.star.sheet.XSpreadsheetDocument;
+// import com.sun.star.sheet.XSpreadsheets;
+// import com.sun.star.sheet.XSpreadsheet;
+// import com.sun.star.sheet.XSpreadsheetView;
+// import com.sun.star.sheet.XCellRangesQuery;
+// import com.sun.star.sheet.XSheetCellRanges;
+// import com.sun.star.sheet.XCellAddressable;
+// import com.sun.star.table.XCell;
+// import com.sun.star.frame.XModel;
+// import com.sun.star.frame.XController;
+// import com.sun.star.frame.XComponentLoader;
+// import com.sun.star.container.XEnumeration;
+// import com.sun.star.container.XEnumerationAccess;
+
+// import com.sun.star.uno.AnyConverter;
+
+
+// /**
+// *
+// * @author dschulten
+// */
+// public class FirstLoadComponent {
+
+// /** Creates a new instance of FirstLoadComponent */
+// public FirstLoadComponent() {
+// }
+
+// /**
+// * @param args the command line arguments
+// */
+// private XComponentContext xRemoteContext = null;
+// private XMultiComponentFactory xRemoteServiceManager = null;
+
+// public static void main(String[] args) {
+// FirstLoadComponent firstLoadComponent1 = new FirstLoadComponent();
+// try {
+// firstLoadComponent1.useConnection();
+// }
+// catch (java.lang.Exception e){
+// System.out.println(e.getMessage());
+// e.printStackTrace();
+// }
+// finally {
+// System.exit(0);
+// }
+// }
+
+// private void useConnection() throws java.lang.Exception {
+// try {
+// // 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);
+// }
+
+// try {
+// Object desktop = xRemoteServiceManager.createInstanceWithContext(
+// "com.sun.star.frame.Desktop", xRemoteContext);
+// XComponentLoader xComponentLoader = (XComponentLoader)
+// UnoRuntime.queryInterface(XComponentLoader.class, desktop);
+
+// PropertyValue[] loadProps = new PropertyValue[0];
+// XComponent xSpreadsheetComponent = xComponentLoader.loadComponentFromURL("private:factory/scalc", "_blank", 0, loadProps);
+
+// XSpreadsheetDocument 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 = (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 = (XPropertySet)UnoRuntime.queryInterface(
+// XPropertySet.class, xCell);
+// xCellProps.setPropertyValue("CellStyle", "Result");
+
+// XModel xSpreadsheetModel = (XModel)UnoRuntime.queryInterface(
+// XModel.class, xSpreadsheetComponent);
+// XController xSpreadsheetController = xSpreadsheetModel.getCurrentController();
+// XSpreadsheetView 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 = new 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 = (XCellRangesQuery)
+// 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 = (XCell)UnoRuntime.queryInterface(XCell.class, formulaCell);
+// XCellAddressable xCellAddress = (XCellAddressable)
+// UnoRuntime.queryInterface(XCellAddressable.class, xCell);
+// System.out.println("Formula cell in column " +
+// xCellAddress.getCellAddress().Column
+// + ", row " + xCellAddress.getCellAddress().Row
+// + " contains " + xCell.getFormula());
+// }
+
+// }
+// catch( com.sun.star.lang.DisposedException e ) { //works from Patch 1
+// xRemoteContext = null;
+// throw e;
+// }
+// }
+// }
diff --git a/odk/examples/DevelopersGuide/FirstSteps/FirstUnoContact.java b/odk/examples/DevelopersGuide/FirstSteps/FirstUnoContact.java
new file mode 100644
index 000000000000..24a5efa32154
--- /dev/null
+++ b/odk/examples/DevelopersGuide/FirstSteps/FirstUnoContact.java
@@ -0,0 +1,58 @@
+/*************************************************************************
+ *
+ * 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);
+ }
+ }
+}
diff --git a/odk/examples/DevelopersGuide/FirstSteps/HelloTextTableShape.java b/odk/examples/DevelopersGuide/FirstSteps/HelloTextTableShape.java
new file mode 100644
index 000000000000..7c40da707d2d
--- /dev/null
+++ b/odk/examples/DevelopersGuide/FirstSteps/HelloTextTableShape.java
@@ -0,0 +1,462 @@
+/*************************************************************************
+ *
+ * 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.uno.AnyConverter;
+import com.sun.star.bridge.XUnoUrlResolver;
+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.XPropertySetInfo;
+import com.sun.star.beans.PropertyValue;
+import com.sun.star.beans.UnknownPropertyException;
+import com.sun.star.beans.PropertyVetoException;
+import com.sun.star.text.XTextDocument;
+import com.sun.star.text.XText;
+import com.sun.star.text.XTextCursor;
+import com.sun.star.text.XWordCursor;
+import com.sun.star.text.XTextContent;
+import com.sun.star.text.XTextTable;
+import com.sun.star.text.XTextTableCursor;
+import com.sun.star.table.XTableRows;
+import com.sun.star.table.XCellRange;
+import com.sun.star.table.XCell;
+import com.sun.star.table.XCellCursor;
+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.sheet.XSpreadsheet;
+import com.sun.star.sheet.XSheetCellCursor;
+import com.sun.star.container.XIndexAccess;
+import com.sun.star.drawing.XDrawPagesSupplier;
+import com.sun.star.drawing.XDrawPageSupplier;
+import com.sun.star.drawing.XDrawPage;
+
+import com.sun.star.text.XTextTablesSupplier;
+import com.sun.star.container.XNameAccess;
+import com.sun.star.container.XNamed;
+import com.sun.star.text.XBookmarksSupplier;
+import com.sun.star.text.XTextRange;
+
+/**
+ *
+ * @author dschulten
+ */
+public class HelloTextTableShape {
+
+ private XComponentContext xRemoteContext = null;
+ private XMultiComponentFactory xRemoteServiceManager = null;
+
+ /** Creates a new instance of HelloTextTableShape */
+ public HelloTextTableShape() {
+ }
+
+ /**
+ * @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 = (XTextDocument)UnoRuntime.queryInterface(
+ XTextDocument.class, xWriterComponent);
+ XText xText = xTextDocument.getText();
+
+ manipulateText(xText);
+
+ // get internal service factory of the document
+ XMultiServiceFactory xWriterFactory = (XMultiServiceFactory)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 = (XTextContent)UnoRuntime.queryInterface(
+ XTextContent.class, table);
+
+ xText.insertTextContent(xText.getEnd(), xTextContentTable, false);
+
+ XCellRange xCellRange = (XCellRange)UnoRuntime.queryInterface(
+ XCellRange.class, table);
+ XCell xCell = xCellRange.getCellByPosition(0, 1);
+ XText xCellText = (XText)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 = (XShape)UnoRuntime.queryInterface(
+ XShape.class, writerShape);
+ xWriterShape.setSize(new Size(10000, 10000));
+ XTextContent xTextContentShape = (XTextContent)UnoRuntime.queryInterface(
+ XTextContent.class, writerShape);
+
+ xText.insertTextContent(xText.getEnd(), xTextContentShape, false);
+
+ XPropertySet xShapeProps = (XPropertySet)UnoRuntime.queryInterface(
+ XPropertySet.class, writerShape);
+ // wrap text inside shape
+ xShapeProps.setPropertyValue("TextContourFrame", new Boolean(true));
+
+
+ XText xShapeText = (XText)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", new Integer(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 =
+ (XSpreadsheetDocument)UnoRuntime.queryInterface(
+ XSpreadsheetDocument .class, xCalcComponent);
+ Object sheets = xSpreadsheetDocument.getSheets();
+ XIndexAccess xIndexedSheets = (XIndexAccess)UnoRuntime.queryInterface(
+ XIndexAccess.class, sheets);
+ Object sheet = xIndexedSheets.getByIndex(0);
+
+ //get cell A2 in first sheet
+ XCellRange xSpreadsheetCells = (XCellRange)UnoRuntime.queryInterface(
+ XCellRange.class, sheet);
+ XCell xCell = xSpreadsheetCells.getCellByPosition(0,1);
+ XPropertySet xCellProps = (XPropertySet)UnoRuntime.queryInterface(
+ XPropertySet.class, xCell);
+ xCellProps.setPropertyValue("IsTextWrapped", new Boolean(true));
+
+ XText xCellText = (XText)UnoRuntime.queryInterface(XText.class, xCell);
+
+ manipulateText(xCellText);
+ manipulateTable(xSpreadsheetCells);
+
+ // get internal service factory of the document
+ XMultiServiceFactory xCalcFactory = (XMultiServiceFactory)UnoRuntime.queryInterface(
+ XMultiServiceFactory.class, xCalcComponent);
+ // get Drawpage
+ XDrawPageSupplier 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 = (XShape)UnoRuntime.queryInterface(
+ XShape.class, calcShape);
+ xCalcShape.setSize(new Size(10000, 10000));
+ xCalcShape.setPosition(new Point(7000, 3000));
+
+ xDrawPage.add(xCalcShape);
+
+ XPropertySet xShapeProps = (XPropertySet)UnoRuntime.queryInterface(
+ XPropertySet.class, calcShape);
+ // wrap text inside shape
+ xShapeProps.setPropertyValue("TextContourFrame", new Boolean(true));
+
+
+ XText xShapeText = (XText)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 =
+ (XDrawPagesSupplier)UnoRuntime.queryInterface(
+ XDrawPagesSupplier.class, xDrawComponent);
+
+ Object drawPages = xDrawPagesSupplier.getDrawPages();
+ XIndexAccess xIndexedDrawPages = (XIndexAccess)UnoRuntime.queryInterface(
+ XIndexAccess.class, drawPages);
+ Object drawPage = xIndexedDrawPages.getByIndex(0);
+ XDrawPage xDrawPage = (XDrawPage)UnoRuntime.queryInterface(XDrawPage.class, drawPage);
+
+ // get internal service factory of the document
+ XMultiServiceFactory xDrawFactory =
+ (XMultiServiceFactory)UnoRuntime.queryInterface(
+ XMultiServiceFactory.class, xDrawComponent);
+
+ Object drawShape = xDrawFactory.createInstance(
+ "com.sun.star.drawing.RectangleShape");
+ XShape xDrawShape = (XShape)UnoRuntime.queryInterface(XShape.class, drawShape);
+ xDrawShape.setSize(new Size(10000, 20000));
+ xDrawShape.setPosition(new Point(5000, 5000));
+ xDrawPage.add(xDrawShape);
+
+ XText xShapeText = (XText)UnoRuntime.queryInterface(XText.class, drawShape);
+ XPropertySet xShapeProps = (XPropertySet)UnoRuntime.queryInterface(
+ XPropertySet.class, drawShape);
+
+ // wrap text inside shape
+ xShapeProps.setPropertyValue("TextContourFrame", new 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 = (XPropertySet)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 = (XText)UnoRuntime.queryInterface(XText.class, xCell);
+ xCellText.setString("Quotation");
+ xCell = xCellRange.getCellByPosition(1,0);
+ xCellText = (XText)UnoRuntime.queryInterface(XText.class, xCell);
+ xCellText.setString("Year");
+ xCell = xCellRange.getCellByPosition(1,1);
+ xCell.setValue(1940);
+ XCellRange xSelectedCells = xCellRange.getCellRangeByName("A1:B1");
+ XPropertySet xCellProps = (XPropertySet)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 = (XServiceInfo)UnoRuntime.queryInterface(
+ XServiceInfo.class, xCellRange);
+ if (xServiceInfo.supportsService("com.sun.star.sheet.Spreadsheet")) {
+ backColorPropertyName = "CellBackColor";
+ xSelectedCells = xCellRange.getCellRangeByName("A1:B2");
+ xTableProps = (XPropertySet)UnoRuntime.queryInterface(
+ XPropertySet.class, xSelectedCells);
+ }
+ else if (xServiceInfo.supportsService("com.sun.star.text.TextTable")) {
+ backColorPropertyName = "BackColor";
+ xTableProps = (XPropertySet)UnoRuntime.queryInterface(
+ XPropertySet.class, xCellRange);
+ }
+ // set cell background color
+ xCellProps.setPropertyValue(backColorPropertyName, new Integer(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 = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, xShape);
+ xShapeProps.setPropertyValue("FillColor", new Integer(0x99CCFF));
+ xShapeProps.setPropertyValue("LineColor", new Integer(0x000099));
+ xShapeProps.setPropertyValue("RotateAngle", new Integer(3000));
+
+ xShapeProps.setPropertyValue("TextLeftDistance", new Integer(0));
+ xShapeProps.setPropertyValue("TextRightDistance", new Integer(0));
+ xShapeProps.setPropertyValue("TextUpperDistance", new Integer(0));
+ xShapeProps.setPropertyValue("TextLowerDistance", new Integer(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 = (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;
+ }
+}
diff --git a/odk/examples/DevelopersGuide/FirstSteps/Makefile b/odk/examples/DevelopersGuide/FirstSteps/Makefile
new file mode 100644
index 000000000000..782e9d1fdb86
--- /dev/null
+++ b/odk/examples/DevelopersGuide/FirstSteps/Makefile
@@ -0,0 +1,101 @@
+#*************************************************************************
+#
+# 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
+include $(SETTINGS)/dk.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 000000000000..15184aba7e4d
--- /dev/null
+++ b/odk/examples/DevelopersGuide/FirstSteps/build_FirstUnoContact.xml
@@ -0,0 +1,64 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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="jurt.jar,unoil.jar,ridl.jar,juh.jar"/>
+ </path>
+
+ <fileset id="bootstrap.glue.code" dir="${OO_SDK_HOME}/classes">
+ <patternset>
+ <include name="com/sun/star/lib/loader/*.class"/>
+ <include name="win/unowinreg.dll"/>
+ </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/makefile.mk b/odk/examples/DevelopersGuide/FirstSteps/makefile.mk
new file mode 100644
index 000000000000..3582a1e123dc
--- /dev/null
+++ b/odk/examples/DevelopersGuide/FirstSteps/makefile.mk
@@ -0,0 +1,67 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ=..$/..$/..
+PRJNAME=odk
+TARGET=copying
+
+#----------------------------------------------------------------
+.INCLUDE: settings.mk
+.INCLUDE: $(PRJ)$/util$/makefile.pmk
+#----------------------------------------------------------------
+
+#----------------------------------------------------
+# this makefile is only used for copying the example
+# files into the SDK
+#----------------------------------------------------
+
+FIRSTSTEPS_FILES=\
+ $(DESTDIRDEVGUIDEEXAMPLES)$/FirstSteps$/FirstUnoContact.java \
+ $(DESTDIRDEVGUIDEEXAMPLES)$/FirstSteps$/build_FirstUnoContact.xml \
+ $(DESTDIRDEVGUIDEEXAMPLES)$/FirstSteps$/FirstLoadComponent.java \
+ $(DESTDIRDEVGUIDEEXAMPLES)$/FirstSteps$/HelloTextTableShape.java \
+ $(DESTDIRDEVGUIDEEXAMPLES)$/FirstSteps$/Makefile
+
+DIR_FILE_LIST= \
+ $(FIRSTSTEPS_FILES) \
+
+DIR_DIRECTORY_LIST=$(uniq $(DIR_FILE_LIST:d))
+DIR_CREATE_FLAG=$(MISC)$/devguide_firststeps_dirs_created.txt
+DIR_FILE_FLAG=$(MISC)$/devguide_firststeps.txt
+
+#--------------------------------------------------
+# TARGETS
+#--------------------------------------------------
+all : \
+ $(DIR_FILE_LIST) \
+ $(DIR_FILE_FLAG)
+
+#--------------------------------------------------
+# use global rules
+#--------------------------------------------------
+.INCLUDE: $(PRJ)$/util$/odk_rules.pmk
+
diff --git a/odk/examples/DevelopersGuide/Forms/BooleanValidator.java b/odk/examples/DevelopersGuide/Forms/BooleanValidator.java
new file mode 100644
index 000000000000..84e6a8a90d30
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Forms/BooleanValidator.java
@@ -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.
+ *
+ *************************************************************************/
+
+/**
+ *
+ * @author fs93730
+ */
+public class BooleanValidator extends ControlValidator
+{
+ private boolean m_preventChecked;
+ private com.sun.star.uno.AnyConverter m_converter;
+
+ /** Creates a new instance of BooleanValidator */
+ public BooleanValidator( boolean preventChecked )
+ {
+ m_preventChecked = preventChecked;
+ m_converter = new com.sun.star.uno.AnyConverter();
+ }
+
+ public String explainInvalid( Object Value )
+ {
+ try
+ {
+ if ( m_converter.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 ( m_converter.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;
+ }
+}
diff --git a/odk/examples/DevelopersGuide/Forms/ButtonOperator.java b/odk/examples/DevelopersGuide/Forms/ButtonOperator.java
new file mode 100644
index 000000000000..3b792e28ea22
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Forms/ButtonOperator.java
@@ -0,0 +1,223 @@
+/*************************************************************************
+ *
+ * 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 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;
+import java.util.Vector;
+
+
+/**************************************************************************/
+/** 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 Vector m_aButtons;
+
+ /* ------------------------------------------------------------------ */
+ /** ctor
+ */
+ public ButtonOperator( XComponentContext xCtx, DocumentHelper aDocument, XPropertySet _form )
+ {
+ m_componentContext = xCtx;
+ m_aDocument = aDocument;
+ m_form = _form;
+ m_aButtons = new Vector();
+ }
+
+ /* ------------------------------------------------------------------ */
+ 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;
+ }
+
+ /* ------------------------------------------------------------------ */
+ /** get's 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 = (XPropertySet)m_aButtons.elementAt( 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.elementAt( 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 = (XButton)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 = (XPropertySet)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()
+ {
+ try
+ {
+ m_formOperations = FormOperations.createWithFormController(
+ m_componentContext, m_aDocument.getCurrentView().getFormController( m_form ) );
+ m_formOperations.setFeatureInvalidation( this );
+ invalidateAllFeatures();
+ }
+ catch( final com.sun.star.uno.Exception e )
+ {
+ }
+ }
+
+ /* ==================================================================
+ = 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 ( int i=0; i < m_aButtons.size(); ++i )
+ {
+ XPropertySet buttonModel = (XPropertySet)m_aButtons.elementAt( i );
+ updateButtonState( buttonModel, getAssociatedFormFeature( buttonModel ) );
+ }
+ }
+};
+
diff --git a/odk/examples/DevelopersGuide/Forms/ComponentTreeTraversal.java b/odk/examples/DevelopersGuide/Forms/ComponentTreeTraversal.java
new file mode 100644
index 000000000000..60f46b54eca1
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Forms/ComponentTreeTraversal.java
@@ -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.
+ *
+ *************************************************************************/
+
+import com.sun.star.uno.*;
+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 wether 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 ) throws com.sun.star.uno.Exception
+ {
+ // 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 ) );
+ }
+ }
+ }
+}
+
diff --git a/odk/examples/DevelopersGuide/Forms/ControlLock.java b/odk/examples/DevelopersGuide/Forms/ControlLock.java
new file mode 100644
index 000000000000..5dada0d8fca7
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Forms/ControlLock.java
@@ -0,0 +1,219 @@
+/*************************************************************************
+ *
+ * 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.util.*;
+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 = new Boolean( bLockIt );
+ m_nLevel = 0;
+ }
+
+ /* ------------------------------------------------------------------ */
+ protected boolean shouldStepInto( XIndexContainer xContainer ) throws com.sun.star.uno.Exception
+ {
+ if ( !super.shouldStepInto( xContainer ) )
+ return false; // don't try to be more clever than our base class
+
+ XForm 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;
+ }
+
+ /* ------------------------------------------------------------------ */
+ 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
+ */
+ protected 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 = (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
+ }
+}
diff --git a/odk/examples/DevelopersGuide/Forms/ControlValidation.java b/odk/examples/DevelopersGuide/Forms/ControlValidation.java
new file mode 100644
index 000000000000..38e019ea72b0
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Forms/ControlValidation.java
@@ -0,0 +1,100 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+import com.sun.star.uno.*;
+import com.sun.star.util.*;
+import com.sun.star.lang.*;
+import com.sun.star.accessibility.*;
+import com.sun.star.container.*;
+import com.sun.star.beans.*;
+import com.sun.star.form.binding.*;
+
+/**
+ *
+ * @author fs@openoffice.org
+ */
+public class ControlValidation extends DocumentBasedExample
+{
+ /** Creates a new instance of ControlValidation */
+ public ControlValidation()
+ {
+ super( DocumentType.WRITER );
+ }
+
+ /* ------------------------------------------------------------------ */
+ /* public test methods */
+ /* ------------------------------------------------------------------ */
+ 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", new 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", new 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", new 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 );
+ }
+}
diff --git a/odk/examples/DevelopersGuide/Forms/ControlValidator.java b/odk/examples/DevelopersGuide/Forms/ControlValidator.java
new file mode 100644
index 000000000000..0ce594633590
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Forms/ControlValidator.java
@@ -0,0 +1,60 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+/** base class for components validating the content of form controls
+ *
+ * @author fs@openoffice.org
+ */
+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;
+ }
+}
diff --git a/odk/examples/DevelopersGuide/Forms/DataAwareness.java b/odk/examples/DevelopersGuide/Forms/DataAwareness.java
new file mode 100644
index 000000000000..1bbe299872d0
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Forms/DataAwareness.java
@@ -0,0 +1,932 @@
+/*************************************************************************
+ *
+ * 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 = new String();
+ }
+
+ public void handle( Object aFormComponent ) throws com.sun.star.uno.Exception
+ {
+ // the name of the child
+ XNamed xName = (XNamed)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;
+ }
+
+ 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 SalesFilter m_aSalesFilter;
+
+ 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 = (XNamed)UnoRuntime.queryInterface( XNamed.class, xContainer );
+ if ( null == xNameAcc )
+ sObjectName = new String( "<unnamed>" );
+ else
+ sObjectName = xNameAcc.getName();
+ System.out.println( new String( "enumerating the container named \"" ) + sObjectName +
+ new String( "\"\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 occured becase 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 = (XColumnsSupplier)UnoRuntime.queryInterface(
+ XColumnsSupplier.class, xFormProps );
+ XNameAccess xCols = xSuppCols.getColumns();
+
+ // and update the date column with a NULL value
+ XColumnUpdate xDateColumn = (XColumnUpdate)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" ) )
+ { // generat 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
+ /* ------------------------------------------------------------------ */
+ 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 it's 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, XConnection xConn, 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 witht 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 (amonst 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", new Boolean( false ) );
+ // similar, they should not steal the focus when clicked
+ xButton.setPropertyValue( "FocusOnClick", new 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 = (XGridColumnFactory)UnoRuntime.queryInterface(
+ XGridColumnFactory.class, aGridModel );
+
+ // (let) create the new col
+ XInterface xNewCol = (XInterface)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 it's parent
+ xColProps.setPropertyValue( "Name", sDataField );
+
+ if ( nWidth > 0 )
+ xColProps.setPropertyValue( "Width", new Integer( 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
+ */
+ 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", new Short( (short)0 ) );
+ xZipField.setPropertyValue( "DecimalAccuracy", new Short( (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", new Integer( 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 for 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", new Integer( CommandType.COMMAND ) );
+
+ String sCommand = new String( "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", new Short( (short)0 ) );
+
+ // init the list box which is for choosing the customer a sale belongs to
+ xCustomerColumn.setPropertyValue( "BoundColumn", new Short( (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", new Boolean( true ) );
+ m_aSalesFilter = 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 );
+
+ // initally, we want to generate keys when moving to a new record
+ xKeyGen.setPropertyValue( "DefaultState", new Short( (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( );
+ }
+
+ /* ------------------------------------------------------------------ */
+ protected void onFormsAlive()
+ {
+ m_aOperator.onFormsAlive();
+ }
+
+ /* ------------------------------------------------------------------ */
+ /** performs any cleanup before exiting the program
+ */
+ 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 = (XNameAccess)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 );
+ }
+}
diff --git a/odk/examples/DevelopersGuide/Forms/DateValidator.java b/odk/examples/DevelopersGuide/Forms/DateValidator.java
new file mode 100644
index 000000000000..daa60523bffa
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Forms/DateValidator.java
@@ -0,0 +1,102 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+import com.sun.star.form.binding.*;
+
+/**
+ *
+ * @author fs@openoffice.org
+ */
+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;
+ }
+}
diff --git a/odk/examples/DevelopersGuide/Forms/DocumentBasedExample.java b/odk/examples/DevelopersGuide/Forms/DocumentBasedExample.java
new file mode 100644
index 000000000000..fe055575bba5
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Forms/DocumentBasedExample.java
@@ -0,0 +1,228 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+import com.sun.star.bridge.XUnoUrlResolver;
+import com.sun.star.lang.XMultiComponentFactory;
+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 intial remote context from the office
+ protected XComponentContext m_xCtx;
+ /// our current test document
+ protected DocumentHelper m_document;
+ protected FormLayer m_formLayer;
+ protected 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
+ */
+ protected 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 = (XCloseable)
+ 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.out );
+ }
+ }
+
+ /* ------------------------------------------------------------------ */
+ /* 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();
+ }
+ }
+ }
+}
diff --git a/odk/examples/DevelopersGuide/Forms/DocumentHelper.java b/odk/examples/DevelopersGuide/Forms/DocumentHelper.java
new file mode 100644
index 000000000000..85aab025d7bd
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Forms/DocumentHelper.java
@@ -0,0 +1,320 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+/**************************************************************************/
+import com.sun.star.uno.*;
+import com.sun.star.lang.*;
+import com.sun.star.util.*;
+import com.sun.star.awt.*;
+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.*;
+import com.sun.star.container.*;
+
+/**************************************************************************/
+/** provides a small wrapper around a document
+*/
+public class DocumentHelper
+{
+ /// the remote office context
+ protected XComponentContext m_remoteContext;
+ /// the remote service manager
+ protected 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 = (XMultiServiceFactory)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 = (XComponentLoader)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 blankTextDocument( XComponentContext xCtx ) throws com.sun.star.uno.Exception
+ {
+ return blankDocument( xCtx, DocumentType.WRITER );
+ }
+
+ /* ------------------------------------------------------------------ */
+ 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 = (XModel)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.
+ */
+ protected 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 (XIndexContainer)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 = (XIndexContainer)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 = (XChild)UnoRuntime.queryInterface( XChild.class, aForm );
+ XIndexContainer xContainer = (XIndexContainer)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
+ */
+ static public DocumentHelper getDocumentForComponent( Object aFormComponent, XComponentContext xCtx )
+ {
+ XChild xChild = (XChild)UnoRuntime.queryInterface( XChild.class, aFormComponent );
+ XModel xModel = null;
+ while ( ( null != xChild ) && ( null == xModel ) )
+ {
+ XInterface xParent = (XInterface)xChild.getParent();
+ xModel = (XModel)UnoRuntime.queryInterface( XModel.class, xParent );
+ xChild = (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
+ */
+ public 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 = (XServiceInfo)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 = (XDrawPagesSupplier)UnoRuntime.queryInterface(
+ XDrawPagesSupplier.class, getDocument() );
+ XDrawPages xPages = xSuppPages.getDrawPages();
+
+ return (XDrawPage)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 = (XDrawPageSupplier)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 = (XDrawPagesSupplier)UnoRuntime.queryInterface(
+ XDrawPagesSupplier.class, getDocument() );
+ XDrawPages xPages = xSuppPages.getDrawPages();
+
+ xReturn = (XDrawPage)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 = (XFormsSupplier)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 = (XMultiServiceFactory)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 = (XMultiServiceFactory)UnoRuntime.queryInterface( XMultiServiceFactory.class,
+ m_documentComponent );
+ return (XInterface) xORB.createInstanceWithArguments( serviceSpecifier, arguments );
+ }
+};
+
diff --git a/odk/examples/DevelopersGuide/Forms/DocumentType.java b/odk/examples/DevelopersGuide/Forms/DocumentType.java
new file mode 100644
index 000000000000..5ac8e3e1c5c3
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Forms/DocumentType.java
@@ -0,0 +1,59 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+import com.sun.star.uno.*;
+
+/** 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 DocumentType getDefault()
+ {
+ return WRITER;
+ }
+
+ 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);
+
+ public static DocumentType fromInt(int value)
+ {
+ switch(value)
+ {
+ case 0: return WRITER;
+ case 1: return CALC;
+ case 2: return DRAWING;
+ default: return UNKNOWN;
+ }
+ }
+};
+
diff --git a/odk/examples/DevelopersGuide/Forms/DocumentViewHelper.java b/odk/examples/DevelopersGuide/Forms/DocumentViewHelper.java
new file mode 100644
index 000000000000..d95fbe452ce5
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Forms/DocumentViewHelper.java
@@ -0,0 +1,230 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+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.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
+ */
+ public Object get( Class 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
+ */
+ public XDispatch getDispatcher( URL[] aURL ) throws java.lang.Exception
+ {
+ XDispatch xReturn = null;
+
+ // go get the current view
+ XController xController = (XController)get( XController.class );
+ // go get the dispatch provider of it's frame
+ XDispatchProvider xProvider = (XDispatchProvider)UnoRuntime.queryInterface(
+ XDispatchProvider.class, xController.getFrame() );
+ if ( null != xProvider )
+ {
+ // need an URLTransformer
+ XURLTransformer xTransformer = (XURLTransformer)UnoRuntime.queryInterface(
+ XURLTransformer.class, m_orb.createInstance( "com.sun.star.util.URLTransformer" ) );
+ xTransformer.parseStrict( aURL );
+
+ xReturn = xProvider.queryDispatch( aURL[0], new String( ), 0 );
+ }
+ return xReturn;
+ }
+
+ /* ------------------------------------------------------------------ */
+ /** retrieves a dispatcher for the given URL, obtained at the current view of the document
+ */
+ public XDispatch getDispatcher( String sURL ) throws java.lang.Exception
+ {
+ URL[] aURL = new URL[] { new URL() };
+ aURL[0].Complete = sURL;
+ return getDispatcher( aURL );
+ }
+
+ /* ------------------------------------------------------------------ */
+ /* retrieves the form controller belonging to a given logical form
+ */
+ public XFormController getFormController( Object _form )
+ {
+ XFormLayerAccess formLayer = (XFormLayerAccess)get( XFormLayerAccess.class );
+ return formLayer.getFormController( (XForm)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
+ */
+ public XControl getFormControl( XControlModel xModel ) throws com.sun.star.uno.Exception
+ {
+ // the current view of the document
+ XControlAccess xCtrlAcc = (XControlAccess)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 = (XControlModel)UnoRuntime.queryInterface( XControlModel.class, aModel );
+ return getFormControl( xModel );
+ }
+
+ /* ------------------------------------------------------------------ */
+ public Object getFormControl( Object aModel, Class aInterfaceClass ) throws com.sun.star.uno.Exception
+ {
+ XControlModel xModel = (XControlModel)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 = new String( ".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 = (XWindow)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 = (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.
+ }
+};
+
diff --git a/odk/examples/DevelopersGuide/Forms/FLTools.java b/odk/examples/DevelopersGuide/Forms/FLTools.java
new file mode 100644
index 000000000000..3f87e77e1bd6
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Forms/FLTools.java
@@ -0,0 +1,270 @@
+/*************************************************************************
+ *
+ * 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.util.*;
+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
+{
+ /* ------------------------------------------------------------------ */
+ static void dump_Object( Object aObject )
+ {
+ XServiceInfo xSI = UNO.queryServiceInfo( aObject );
+ if ( null != xSI )
+ System.out.println( "dumping object with name \"" + xSI.getImplementationName() + "\"" );
+ else
+ System.out.println( "object has no service info!" );
+ }
+
+ /* ------------------------------------------------------------------ */
+ /** translates a string containing an URL into a complete
+ <type scope="com.sun.star.util">URL</type> object.
+ */
+ static public URL parseURL( String sURL, XComponentContext xCtx ) throws java.lang.Exception
+ {
+ URL[] aURL = new URL[] { new URL() };
+ aURL[0].Complete = sURL;
+ // need an URLTransformer
+ XURLTransformer xTransformer = (XURLTransformer)UnoRuntime.queryInterface(
+ XURLTransformer.class,
+ xCtx.getServiceManager().createInstanceWithContext(
+ "com.sun.star.util.URLTransformer", xCtx ) );
+ xTransformer.parseStrict( aURL );
+
+ return aURL[0];
+ }
+
+ /* ------------------------------------------------------------------ */
+ /** returns the name of the given form component
+ */
+ public static String getName( Object aFormComponent ) throws com.sun.star.uno.Exception
+ {
+ XNamed 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 index of a form component within it's parent
+ */
+ static public int getIndexInParent( Object aContainer, Object aElement ) throws com.sun.star.uno.Exception
+ {
+ int nIndex = -1;
+
+ // norm the element
+ XInterface xElement = (XInterface)UnoRuntime.queryInterface(
+ XInterface.class, aElement );
+
+ // get the container
+ XIndexContainer xIndexCont = UNO.queryIndexContainer( aContainer );
+ if ( null != xIndexCont )
+ {
+ // loop through all children
+ int nCount = xIndexCont.getCount();
+ for ( int i = 0; i < nCount; ++i )
+ {
+ // compare with the element
+ XInterface xCurrent = (XInterface)UnoRuntime.queryInterface(
+ XInterface.class, xIndexCont.getByIndex( 0 ) );
+ if ( xCurrent.equals( xElement ) )
+ { // found
+ nIndex = i;
+ break;
+ }
+ }
+ }
+
+ // outta here
+ return nIndex;
+ }
+
+ /* ------------------------------------------------------------------ */
+ /** retrieves the parent of the given object
+ */
+ static Object getParent( Object aComponent, Class aInterfaceClass )
+ {
+ XChild xAsChild = (XChild)UnoRuntime.queryInterface( XChild.class, aComponent );
+
+ return UnoRuntime.queryInterface( aInterfaceClass, xAsChild.getParent() );
+ }
+
+ /* ------------------------------------------------------------------ */
+ /** retrieves the parent of the given object
+ */
+ static XPropertySet getParent( Object aComponent )
+ {
+ return (XPropertySet)getParent( aComponent, XPropertySet.class );
+ }
+
+ /* ------------------------------------------------------------------ */
+ /** disposes the component given
+ */
+ static public void disposeComponent( Object xComp ) throws java.lang.RuntimeException
+ {
+ XComponent xComponent = (XComponent)UnoRuntime.queryInterface( XComponent.class,
+ xComp );
+ if ( null != xComponent )
+ xComponent.dispose();
+ }
+
+ /* ------------------------------------------------------------------ */
+ /** get's the XControlModel for a control
+ */
+ static public Object getModel( Object aControl, Class aInterfaceClass )
+ {
+ XControl 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>
+ */
+ static public 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;
+ }
+
+};
diff --git a/odk/examples/DevelopersGuide/Forms/FormLayer.java b/odk/examples/DevelopersGuide/Forms/FormLayer.java
new file mode 100644
index 000000000000..468937aacb83
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Forms/FormLayer.java
@@ -0,0 +1,294 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+import 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;
+
+/**
+ *
+ * @author fs@openoffice.org
+ */
+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;
+ }
+
+ /* ------------------------------------------------------------------ */
+ /** sets the page which is to be used for subsequent insertions of controls/shapes
+ */
+ void setInsertPage( int page )
+ {
+ m_insertPage = page;
+ }
+
+ /* ------------------------------------------------------------------ */
+ /** retrieves the page which is to be used for subsequent insertions of controls/shapes
+ */
+ final int getInsertPage( )
+ {
+ return m_insertPage;
+ }
+
+ /* ------------------------------------------------------------------ */
+ /** 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 = (XMultiServiceFactory)UnoRuntime.queryInterface(
+ XMultiServiceFactory.class, m_document.getDocument() );
+ XControlShape xShape = (XControlShape)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 = (XControlModel)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 = (XShapes)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", new Short( com.sun.star.awt.VisualEffect.FLAT ) );
+ }
+ if ( xPSI.hasPropertyByName( "VisualEffect" ) )
+ xModelProps.setPropertyValue( "VisualEffect", new Short( com.sun.star.awt.VisualEffect.FLAT ) );
+ if ( m_document.classify() != DocumentType.CALC )
+ if ( xPSI.hasPropertyByName( "BorderColor" ) )
+ xModelProps.setPropertyValue( "BorderColor", new Integer( 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 it's 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 = (XIndexAccess)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 refValue
+ * 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 = (XIndexAccess)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;
+ }
+}
diff --git a/odk/examples/DevelopersGuide/Forms/GridFieldValidator.java b/odk/examples/DevelopersGuide/Forms/GridFieldValidator.java
new file mode 100644
index 000000000000..03e8a931d528
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Forms/GridFieldValidator.java
@@ -0,0 +1,176 @@
+/*************************************************************************
+ *
+ * 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.*;
+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 DocumentHelper m_aDocument;
+ 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;
+ m_aDocument = DocumentHelper.getDocumentForComponent(xWatchedGridColumn,
+ xCtx);
+
+ m_bWatching = false;
+ }
+
+ /* ------------------------------------------------------------------ */
+ public void enableColumnWatch( boolean bEnable )
+ {
+ if ( bEnable == m_bWatching )
+ return;
+
+ XUpdateBroadcaster xUpdate = (XUpdateBroadcaster)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(
+ new String( "Invalid Value Entered" ),
+ null,
+ new String( "S1000" ),
+ 0,
+ new Any( new Type(), null ),
+ sMessage
+ );
+
+ // instantiate an interaction handler who can handle SQLExceptions
+ XInteractionHandler xHandler = (XInteractionHandler)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
+ }
+};
diff --git a/odk/examples/DevelopersGuide/Forms/HsqlDatabase.java b/odk/examples/DevelopersGuide/Forms/HsqlDatabase.java
new file mode 100644
index 000000000000..2d1ba453d914
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Forms/HsqlDatabase.java
@@ -0,0 +1,256 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+import 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.frame.XModel;
+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.sdbc.XStatement;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.io.IOException;
+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;
+import java.io.File;
+
+/**
+ *
+ * @author fs93730
+ */
+public class HsqlDatabase
+{
+ XComponentContext m_context;
+ // the URL of the temporary file used for the database document
+ String m_databaseDocumentFile;
+ // the database document
+ XOfficeDatabaseDocument m_databaseDocument;
+ // the data source belonging to the database document
+ // the default connection
+ 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 = (XNameAccess)UnoRuntime.queryInterface( XNameAccess.class,
+ m_context.getServiceManager().createInstanceWithContext( "com.sun.star.sdb.DatabaseContext", m_context ) );
+ XDocumentDataSource dataSource = (XDocumentDataSource)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 = (XOfficeDatabaseDocument)UnoRuntime.queryInterface(
+ XOfficeDatabaseDocument.class, m_context.getServiceManager().createInstanceWithContext(
+ "com.sun.star.sdb.OfficeDatabaseDocument", m_context ) );
+
+ XPropertySet dsProperties = (XPropertySet)UnoRuntime.queryInterface( XPropertySet.class, m_databaseDocument.getDataSource() );
+ dsProperties.setPropertyValue("URL", "sdbc:embedded:hsqldb");
+
+ XStorable storable = (XStorable)UnoRuntime.queryInterface( XStorable.class, m_databaseDocument );
+ storable.storeAsURL( m_databaseDocumentFile, new PropertyValue[]{} );
+ }
+
+ /** returns a connection to the database
+ *
+ * Multiple calls to this method return the same connection. The HsqlDatabase object keeps
+ * the ownership of the connection, so you don't need to (and should not) dispose/close it.
+ *
+ */
+ public XConnection defaultConnection() throws SQLException
+ {
+ if ( m_connection != null )
+ return m_connection;
+ m_connection = m_databaseDocument.getDataSource().getConnection(new String(),new String());
+ return m_connection;
+ }
+
+ /** executes the given SQL statement via the defaultConnection
+ */
+ public void executeSQL( String statementString ) throws SQLException
+ {
+ XStatement statement = defaultConnection().createStatement();
+ statement.execute( statementString );
+ }
+
+ /** stores the database document
+ */
+ public void store() throws IOException
+ {
+ if ( m_databaseDocument != null )
+ {
+ XStorable storeDoc = (XStorable)UnoRuntime.queryInterface( XStorable.class,
+ m_databaseDocument );
+ storeDoc.store();
+ }
+ }
+
+ /** closes the database document
+ *
+ * Any CloseVetoExceptions fired by third parties are ignored, and any reference to the
+ * database document is released.
+ */
+ public void close()
+ {
+ // close connection
+ XCloseable closeConn = (XCloseable)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 = (com.sun.star.util.XCloseable)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
+ */
+ public 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 model interface of the underlying database document
+ */
+ XModel getModel()
+ {
+ return (XModel)UnoRuntime.queryInterface( XModel.class, m_databaseDocument );
+ }
+
+ /** drops the table with a given name
+
+ @param _name
+ the name of the table to drop
+ @param _ifExists
+ TRUE if it should be dropped only when it exists.
+ */
+ public void dropTable( String _name, boolean _ifExists ) throws SQLException
+ {
+ String dropStatement = "DROP TABLE \"" + _name;
+ if ( _ifExists )
+ dropStatement += "\" IF EXISTS";
+ executeSQL( dropStatement );
+ }
+
+ /** returns the URL of the ODB document represented by this instance
+ */
+ public String getDocumentURL()
+ {
+ return m_databaseDocumentFile;
+ }
+
+ /** creates a row set operating the database, with a given command/type
+ */
+ public RowSet createRowSet( int _commandType, String _command )
+ {
+ return new RowSet( m_context, getDocumentURL(), _commandType, _command );
+ }
+
+ protected void finalize() throws Throwable
+ {
+ closeAndDelete();
+ super.finalize();
+ }
+}
diff --git a/odk/examples/DevelopersGuide/Forms/InteractionRequest.java b/odk/examples/DevelopersGuide/Forms/InteractionRequest.java
new file mode 100644
index 000000000000..31b31c9ebd92
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Forms/InteractionRequest.java
@@ -0,0 +1,76 @@
+/*************************************************************************
+ *
+ * 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.task.*;
+import java.util.Vector;
+
+/**************************************************************************/
+/** helper class for implementing an interaction request.
+*/
+class InteractionRequest implements XInteractionRequest
+{
+ private Object m_aRequest;
+ private Vector m_aContinuations;
+
+ /* ------------------------------------------------------------------ */
+ public InteractionRequest( Object aRequest )
+ {
+ m_aRequest = aRequest;
+ m_aContinuations = new Vector();
+ }
+
+ /* ------------------------------------------------------------------ */
+ public void addContinuation( XInteractionContinuation xCont )
+ {
+ if ( null != xCont )
+ m_aContinuations.add( xCont );
+ }
+
+ /* ------------------------------------------------------------------ */
+ public Object getRequest( )
+ {
+ return m_aRequest;
+ }
+
+ /* ------------------------------------------------------------------ */
+ public XInteractionContinuation[] getContinuations( )
+ {
+ XInteractionContinuation[] aContinuations = new XInteractionContinuation[ m_aContinuations.size() ];
+ for ( int i=0; i<m_aContinuations.size(); ++i )
+ aContinuations[ i ] = (XInteractionContinuation)m_aContinuations.elementAt( i );
+ return aContinuations;
+ }
+};
+
diff --git a/odk/examples/DevelopersGuide/Forms/KeyGenerator.java b/odk/examples/DevelopersGuide/Forms/KeyGenerator.java
new file mode 100644
index 000000000000..21012abb046e
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Forms/KeyGenerator.java
@@ -0,0 +1,432 @@
+/*************************************************************************
+ *
+ * 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>
+ */
+ protected 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 = (XConnection)UnoRuntime.queryInterface( XConnection.class,
+ xForm.getPropertyValue( "ActiveConnection" ) );
+ // and let it create a composer for us
+ XSQLQueryComposerFactory xComposerFac =
+ (XSQLQueryComposerFactory)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 = (XTablesSupplier)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 a execution contains the value in it's first column.
+ */
+ protected String composeUniqueyKeyStatement( XPropertySet xForm, String sFieldName ) throws com.sun.star.uno.Exception
+ {
+ String sStatement = new String( "SELECT MAX( " );
+ sStatement += sFieldName;
+ sStatement += new String( ") + 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
+ */
+ protected int generatePrimaryKey( XPropertySet xForm, String sFieldName ) throws com.sun.star.uno.Exception
+ {
+ // get the current connection of the form
+ XConnection xConn = (XConnection)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 = (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 = (XColumnsSupplier)UnoRuntime.queryInterface(
+ XColumnsSupplier.class, xForm );
+ XNameAccess xCols = xSuppCols.getColumns();
+ XColumnUpdate xCol = (XColumnUpdate)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
+ */
+ public void defaultNewRecordFocus( XPropertySet xForm ) throws com.sun.star.uno.Exception
+ {
+ XIndexAccess xFormAsContainer = (XIndexAccess)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 occured becase 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 DocumentHelper m_aDocument;
+ 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 = (XRowSetApproveBroadcaster)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 = (XRowSetApproveBroadcaster)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;
+ }
+ }
+};
diff --git a/odk/examples/DevelopersGuide/Forms/ListSelectionValidator.java b/odk/examples/DevelopersGuide/Forms/ListSelectionValidator.java
new file mode 100644
index 000000000000..6f605eaa3592
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Forms/ListSelectionValidator.java
@@ -0,0 +1,69 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+/**
+ *
+ * @author fs@openoffice.org
+ */
+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;
+ }
+
+}
diff --git a/odk/examples/DevelopersGuide/Forms/Makefile b/odk/examples/DevelopersGuide/Forms/Makefile
new file mode 100644
index 000000000000..95867588f9ad
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Forms/Makefile
@@ -0,0 +1,197 @@
+#*************************************************************************
+#
+# 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
+include $(SETTINGS)/dk.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 whith 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 000000000000..220996666e95
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Forms/NumericValidator.java
@@ -0,0 +1,89 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+import com.sun.star.form.binding.*;
+
+/**
+ *
+ * @author fs@openoffice.org
+ */
+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 ( java.lang.Math.floor( value * 10 ) == value * 10 );
+ }
+}
diff --git a/odk/examples/DevelopersGuide/Forms/ProgrammaticScriptAssignment.odt b/odk/examples/DevelopersGuide/Forms/ProgrammaticScriptAssignment.odt
new file mode 100644
index 000000000000..40b952d94a15
--- /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 000000000000..f21b26b4d7f8
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Forms/RowSet.java
@@ -0,0 +1,290 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+import 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.lang.XMultiServiceFactory;
+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 = (XPropertySet)UnoRuntime.queryInterface(
+ XPropertySet.class, _context.getServiceManager().createInstanceWithContext( "com.sun.star.sdb.RowSet", _context ) );
+ m_rowSetProps.setPropertyValue( "DataSourceName", _dataSource );
+ m_rowSetProps.setPropertyValue( "CommandType", new Integer( _commandType ) );
+ m_rowSetProps.setPropertyValue( "Command", _command );
+
+ m_rowSet = (XRowSet)UnoRuntime.queryInterface( XRowSet.class, m_rowSetProps );
+ m_row = (XRow)UnoRuntime.queryInterface( XRow.class, m_rowSetProps );
+ }
+ catch ( Exception e )
+ {
+ e.printStackTrace(System.err);
+ throw new java.lang.InstantiationError();
+ }
+ }
+
+ // misc
+ public int getColumnCount()
+ {
+ XColumnsSupplier suppCols = (XColumnsSupplier)UnoRuntime.queryInterface(
+ XColumnsSupplier.class, m_rowSet );
+ XIndexAccess columns = (XIndexAccess)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);
+ }
+};
diff --git a/odk/examples/DevelopersGuide/Forms/SalesFilter.java b/odk/examples/DevelopersGuide/Forms/SalesFilter.java
new file mode 100644
index 000000000000..fa6e9d19abc7
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Forms/SalesFilter.java
@@ -0,0 +1,512 @@
+/*************************************************************************
+ *
+ * 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.*;
+
+import java.util.Vector;
+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.Vector m_aFilterDates;
+
+ /* ------------------------------------------------------------------ */
+ public SalesFilter( DocumentHelper aDocument, XPropertySet xSalesForm,
+ XPropertySet xFilterListBox, XPropertySet xManualFilterEdit, XPropertySet xStartFilterButton )
+ {
+ m_aFilterDates = new java.util.Vector();
+ 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", new Boolean( true ) );
+ m_xFilterList.setPropertyValue( "LineCount", new Short( (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[] { 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 beeing 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 = (XButton)aView.getFormControl( m_xApplyFilter, XButton.class );
+ xButton.addActionListener( this );
+ }
+ catch ( com.sun.star.uno.Exception e )
+ {
+ System.out.println(e);
+ e.printStackTrace();
+ }
+ }
+
+ /* ==================================================================
+ = helper
+ ================================================================== */
+ /* ------------------------------------------------------------------ */
+ protected 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.
+ */
+ protected 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 = new Integer( 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
+ */
+ protected 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 += new String( "{D '" );
+ sOdbcDate += (new Integer( aCal.get( Calendar.YEAR ) ) ).toString();
+ sOdbcDate += "-";
+
+ int nMonth = aCal.get( Calendar.MONTH ) + 1;
+ if ( nMonth < 10 )
+ sOdbcDate += "0";
+ sOdbcDate += (new Integer( nMonth ) ).toString();
+ sOdbcDate += "-";
+
+ int nDay = aCal.get( Calendar.DAY_OF_MONTH );
+ if ( nDay < 10 )
+ sOdbcDate += "0";
+ sOdbcDate += (new Integer( nDay ) ).toString();
+ sOdbcDate += "'}";
+ }
+ }
+ return sOdbcDate;
+ }
+
+ /* ------------------------------------------------------------------ */
+ protected void updateApplyButton()
+ {
+ try
+ {
+ m_xApplyFilter.setPropertyValue( "Enabled", new Boolean( 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
+ */
+ protected 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 protected 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 referes to the "<other>" entry which
+ allows the user to manually enter a date
+ */
+ final protected boolean isManualFilter( short nFilterIndex )
+ {
+ return ( 5 == nFilterIndex );
+ }
+
+ /* ------------------------------------------------------------------ */
+ protected 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", new Boolean( bCustomFilter ) );
+ if ( bCustomFilter )
+ m_aDocument.getCurrentView().grabControlFocus( m_xManualFilter );
+
+ m_bSettingDate = true;
+ Object aSelectedDateLimit = m_aFilterDates.elementAt( 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>
+ */
+ protected 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
+ */
+ protected 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.Vector aFilterItems = new java.util.Vector();
+ 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.elementAt( 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 oldes) user defined item
+ aFilterItems.removeElementAt( 6 );
+ // keep our date vector synchron
+ m_aFilterDates.removeElementAt( 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.elementAt( i );
+ m_xFilterList.setPropertyValue( "StringItemList", aNewFilterItems );
+ m_bAdjustingFilterList = false;
+
+ return (short)(aNewFilterItems.length - 1 );
+ }
+
+ /* ------------------------------------------------------------------ */
+ protected 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", new Boolean( true ) );
+
+ // and reload the form
+ XLoadable xLoad = (XLoadable)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 it's content
+ // to the current date
+ // Note that another possible solution would be to wait for the resetted
+ // 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
+ }
+
+};
diff --git a/odk/examples/DevelopersGuide/Forms/SingleControlValidation.java b/odk/examples/DevelopersGuide/Forms/SingleControlValidation.java
new file mode 100644
index 000000000000..f12d813f9a9c
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Forms/SingleControlValidation.java
@@ -0,0 +1,187 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+import com.sun.star.uno.*;
+import com.sun.star.util.*;
+import com.sun.star.lang.*;
+import com.sun.star.accessibility.*;
+import com.sun.star.container.*;
+import com.sun.star.beans.*;
+import com.sun.star.form.binding.*;
+import com.sun.star.form.validation.*;
+
+/**
+ *
+ * @author fs@openoffice.org
+ */
+public class SingleControlValidation implements XFormComponentValidityListener
+{
+ private DocumentHelper m_document; /// our current test document
+ private FormLayer m_formLayer; /// quick access to the form layer
+ private XMultiServiceFactory m_orb; /// our service factory
+
+ 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", new 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", new Short( (short)2 ) );
+
+ XValidatableFormComponent xComp = (XValidatableFormComponent)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", new String( "Status:" ) );
+ controlPos += 4;
+ m_statusField = m_formLayer.createControlAndShape( "FixedText", columnPos, controlPos, 70, 4, null );
+ m_statusField.setPropertyValue( "Label", new String( "" ) );
+
+ // ----------------------------------
+ controlPos += 6;
+ xLabel = m_formLayer.createControlAndShape( "FixedText", columnPos, controlPos, 70, 4, null );
+ xLabel.setPropertyValue( "Label", new String( "Explanation for invalidity:" ) );
+ controlPos += 4;
+ m_explanationField = m_formLayer.createControlAndShape( "FixedText", columnPos, controlPos, 70, 4, null );
+ m_explanationField.setPropertyValue( "Label", new String( "" ) );
+
+ XValidatable xValidatable = (XValidatable)UnoRuntime.queryInterface( XValidatable.class, m_inputField );
+ xValidatable.setValidator( m_validator );
+ }
+ catch( java.lang.Exception e )
+ {
+ e.printStackTrace( System.out );
+ }
+ }
+
+ /* ------------------------------------------------------------------ */
+ /* 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 = (XValidatableFormComponent)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", new Integer( 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.out );
+ }
+ }
+
+}
diff --git a/odk/examples/DevelopersGuide/Forms/SpreadsheetDocument.java b/odk/examples/DevelopersGuide/Forms/SpreadsheetDocument.java
new file mode 100644
index 000000000000..b0abe5139c30
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Forms/SpreadsheetDocument.java
@@ -0,0 +1,131 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+import com.sun.star.uno.*;
+import com.sun.star.lang.XMultiServiceFactory;
+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;
+
+/**
+ *
+ * @author fs93730
+ */
+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 ) throws com.sun.star.uno.Exception
+ {
+ super( xCtx, document );
+ }
+
+ public XCellRange getSheet( int index ) throws com.sun.star.uno.Exception
+ {
+ XSpreadsheetDocument spreadsheetDoc = (XSpreadsheetDocument)UnoRuntime.queryInterface( XSpreadsheetDocument.class,
+ m_documentComponent
+ );
+ XIndexAccess sheets = (XIndexAccess)UnoRuntime.queryInterface( XIndexAccess.class,
+ spreadsheetDoc.getSheets()
+ );
+ return (XCellRange)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 = (com.sun.star.form.binding.XValueBinding)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 = (com.sun.star.form.binding.XListEntrySource)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;
+ }
+}
diff --git a/odk/examples/DevelopersGuide/Forms/SpreadsheetValueBinding.java b/odk/examples/DevelopersGuide/Forms/SpreadsheetValueBinding.java
new file mode 100644
index 000000000000..716cc72dc2f4
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Forms/SpreadsheetValueBinding.java
@@ -0,0 +1,136 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+import com.sun.star.uno.UnoRuntime;
+
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.beans.XPropertySet;
+import com.sun.star.table.XCellRange;
+import com.sun.star.table.XCell;
+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.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 );
+ }
+
+ /* ------------------------------------------------------------------ */
+ 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 = new Integer( 0x00E0E0E0 );
+
+ // ----------------------------------------------------------------------
+ // a numeric control
+ XPropertySet numericControl = m_formLayer.insertControlLine( "NumericField",
+ "enter a value", "", 30 );
+ numericControl.setPropertyValue( "ValueMin", new Short( (short)1 ) );
+ numericControl.setPropertyValue( "ValueMax", new Short( (short)5 ) );
+ numericControl.setPropertyValue( "Value", new Short( (short)1 ) );
+ numericControl.setPropertyValue( "DecimalAccuracy", new Short( (short)0 ) );
+ numericControl.setPropertyValue( "Spin", new 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", new 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 = (XListEntrySink)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 = (XTextRange)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 = (XBindableValue)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 );
+ }
+ }
diff --git a/odk/examples/DevelopersGuide/Forms/SpreadsheetView.java b/odk/examples/DevelopersGuide/Forms/SpreadsheetView.java
new file mode 100644
index 000000000000..77b37e3b2258
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Forms/SpreadsheetView.java
@@ -0,0 +1,76 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+/*
+ * SpreadsheetView.java
+ *
+ * Created on 2. Oktober 2003, 14:02
+ */
+
+import com.sun.star.uno.*;
+import com.sun.star.lang.*;
+import com.sun.star.frame.*;
+import com.sun.star.sheet.*;
+import com.sun.star.container.*;
+
+/**
+ *
+ * @author fs93730
+ */
+public class SpreadsheetView extends DocumentViewHelper
+{
+
+ /** Creates a new instance of SpreadsheetView */
+ public SpreadsheetView( XMultiServiceFactory orb, DocumentHelper document, XController controller )
+ {
+ super( orb, document, controller );
+ }
+
+ /** activates the sheet with the given index
+ */
+ void activateSheet( int sheetIndex )
+ {
+ try
+ {
+ // get the sheet to activate
+ XSpreadsheetDocument doc = (XSpreadsheetDocument)UnoRuntime.queryInterface(
+ XSpreadsheetDocument.class, getDocument().getDocument() );
+ XIndexAccess sheets = (XIndexAccess)UnoRuntime.queryInterface(
+ XIndexAccess.class, doc.getSheets() );
+
+ XSpreadsheet sheet = (XSpreadsheet)UnoRuntime.queryInterface(
+ XSpreadsheet.class, sheets.getByIndex( sheetIndex ) );
+
+ // activate
+ XSpreadsheetView view = (XSpreadsheetView)UnoRuntime.queryInterface(
+ XSpreadsheetView.class, getController() );
+ view.setActiveSheet( sheet );
+ }
+ catch( com.sun.star.uno.Exception e )
+ {
+ }
+ }
+}
diff --git a/odk/examples/DevelopersGuide/Forms/TableCellTextBinding.java b/odk/examples/DevelopersGuide/Forms/TableCellTextBinding.java
new file mode 100644
index 000000000000..40bd460ad2b8
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Forms/TableCellTextBinding.java
@@ -0,0 +1,210 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+import 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.beans.XPropertySet;
+import com.sun.star.text.XTextRange;
+import com.sun.star.form.binding.IncompatibleTypesException;
+
+/** 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 m_listeners;
+
+ /** Creates a new instance of TableCellTextBinding */
+ public TableCellTextBinding( XCell cell )
+ {
+ m_cellText = (XTextRange)UnoRuntime.queryInterface( XTextRange.class, cell );
+
+ m_newCellText = new String();
+ m_listeners = new java.util.LinkedList();
+
+ 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
+ */
+ 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 loop = m_listeners.iterator();
+ while ( loop.hasNext() )
+ {
+ ((XModifyListener)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 );
+ }
+ }
+
+ public void disposing(com.sun.star.lang.EventObject eventObject)
+ {
+ // not interested in
+ }
+}
diff --git a/odk/examples/DevelopersGuide/Forms/TextValidator.java b/odk/examples/DevelopersGuide/Forms/TextValidator.java
new file mode 100644
index 000000000000..6ca0528137cc
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Forms/TextValidator.java
@@ -0,0 +1,89 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+import com.sun.star.form.binding.*;
+
+/**
+ *
+ * @author fs@openoffice.org
+ */
+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;
+ }
+}
diff --git a/odk/examples/DevelopersGuide/Forms/TimeValidator.java b/odk/examples/DevelopersGuide/Forms/TimeValidator.java
new file mode 100644
index 000000000000..d98b66b19416
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Forms/TimeValidator.java
@@ -0,0 +1,94 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+import com.sun.star.form.binding.*;
+
+/**
+ *
+ * @author fs@openoffice.org
+ */
+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.HundredthSeconds == -1 );
+ }
+
+ private boolean isFullHour( com.sun.star.util.Time timeValue )
+ {
+ return ( timeValue.Minutes == 0 ) && ( timeValue.Seconds == 0 ) && ( timeValue.HundredthSeconds == 0 );
+ }
+}
diff --git a/odk/examples/DevelopersGuide/Forms/UNO.java b/odk/examples/DevelopersGuide/Forms/UNO.java
new file mode 100644
index 000000000000..39540613d478
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Forms/UNO.java
@@ -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.
+ *
+ *************************************************************************/
+
+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.*;
+import com.sun.star.sdbcx.*;
+
+public class UNO
+{
+ public static XPropertySet queryPropertySet( Object aObject )
+ {
+ return (XPropertySet)UnoRuntime.queryInterface( XPropertySet.class, aObject );
+ }
+ public static XControlModel queryControlModel( Object aObject )
+ {
+ return (XControlModel)UnoRuntime.queryInterface( XControlModel.class, aObject );
+ }
+ public static XIndexContainer queryIndexContainer( Object aObject )
+ {
+ return (XIndexContainer)UnoRuntime.queryInterface( XIndexContainer.class, aObject );
+ }
+ public static XReset queryReset( Object aObject )
+ {
+ return (XReset)UnoRuntime.queryInterface( XReset.class, aObject );
+ }
+ public static XServiceInfo queryServiceInfo( Object aObject )
+ {
+ return (XServiceInfo)UnoRuntime.queryInterface( XServiceInfo.class, aObject );
+ }
+ public static XColumn queryColumn( Object aObject )
+ {
+ return (XColumn)UnoRuntime.queryInterface( XColumn.class, aObject );
+ }
+
+ public static XComponent queryComponent( Object aObject )
+ {
+ return (XComponent)UnoRuntime.queryInterface( XComponent.class, aObject );
+ }
+
+ public static XTablesSupplier queryTablesSupplier( Object aObject )
+ {
+ return (XTablesSupplier)UnoRuntime.queryInterface( XTablesSupplier.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 );
+ }
+*/
+};
diff --git a/odk/examples/DevelopersGuide/Forms/URLHelper.java b/odk/examples/DevelopersGuide/Forms/URLHelper.java
new file mode 100644
index 000000000000..97c9a6bb8403
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Forms/URLHelper.java
@@ -0,0 +1,72 @@
+/*
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ */
+
+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 pathes.
+ * 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
+ */
+ @SuppressWarnings("deprecation")
+ public static String getFileURLFromSystemPath( File aSystemPath )
+ {
+ String sFileURL = null;
+ try
+ {
+ sFileURL = aSystemPath.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;
+ }
+}
diff --git a/odk/examples/DevelopersGuide/Forms/ValueBinding.java b/odk/examples/DevelopersGuide/Forms/ValueBinding.java
new file mode 100644
index 000000000000..0446ba313f37
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Forms/ValueBinding.java
@@ -0,0 +1,88 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+import com.sun.star.uno.UnoRuntime;
+
+import com.sun.star.lang.XMultiServiceFactory;
+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 );
+ }
+
+ /* ------------------------------------------------------------------ */
+ 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 = (XTextDocument)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 = (XTextTable)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 = (XBindableValue)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 );
+ }
+ }
diff --git a/odk/examples/DevelopersGuide/Forms/WaitForInput.java b/odk/examples/DevelopersGuide/Forms/WaitForInput.java
new file mode 100644
index 000000000000..4017906f1bcb
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Forms/WaitForInput.java
@@ -0,0 +1,64 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+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;
+ }
+
+ 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 );
+ }
+ }
+};
+
diff --git a/odk/examples/DevelopersGuide/Forms/makefile.mk b/odk/examples/DevelopersGuide/Forms/makefile.mk
new file mode 100644
index 000000000000..5fd059fcb969
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Forms/makefile.mk
@@ -0,0 +1,97 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ=..$/..$/..
+PRJNAME=odk
+TARGET=copying
+
+#----------------------------------------------------------------
+.INCLUDE: settings.mk
+.INCLUDE: $(PRJ)$/util$/makefile.pmk
+#----------------------------------------------------------------
+
+#----------------------------------------------------
+# this makefile is only used for copying the example
+# files into the SDK
+#----------------------------------------------------
+
+FORMS_FILES=\
+ $(DESTDIRDEVGUIDEEXAMPLES)$/Forms$/BooleanValidator.java \
+ $(DESTDIRDEVGUIDEEXAMPLES)$/Forms$/ButtonOperator.java \
+ $(DESTDIRDEVGUIDEEXAMPLES)$/Forms$/ComponentTreeTraversal.java \
+ $(DESTDIRDEVGUIDEEXAMPLES)$/Forms$/ControlLock.java \
+ $(DESTDIRDEVGUIDEEXAMPLES)$/Forms$/ControlValidation.java \
+ $(DESTDIRDEVGUIDEEXAMPLES)$/Forms$/ControlValidator.java \
+ $(DESTDIRDEVGUIDEEXAMPLES)$/Forms$/DataAwareness.java \
+ $(DESTDIRDEVGUIDEEXAMPLES)$/Forms$/DateValidator.java \
+ $(DESTDIRDEVGUIDEEXAMPLES)$/Forms$/DocumentBasedExample.java \
+ $(DESTDIRDEVGUIDEEXAMPLES)$/Forms$/DocumentHelper.java \
+ $(DESTDIRDEVGUIDEEXAMPLES)$/Forms$/DocumentType.java \
+ $(DESTDIRDEVGUIDEEXAMPLES)$/Forms$/DocumentViewHelper.java \
+ $(DESTDIRDEVGUIDEEXAMPLES)$/Forms$/FLTools.java \
+ $(DESTDIRDEVGUIDEEXAMPLES)$/Forms$/FormLayer.java \
+ $(DESTDIRDEVGUIDEEXAMPLES)$/Forms$/GridFieldValidator.java \
+ $(DESTDIRDEVGUIDEEXAMPLES)$/Forms$/InteractionRequest.java \
+ $(DESTDIRDEVGUIDEEXAMPLES)$/Forms$/KeyGenerator.java \
+ $(DESTDIRDEVGUIDEEXAMPLES)$/Forms$/ListSelectionValidator.java \
+ $(DESTDIRDEVGUIDEEXAMPLES)$/Forms$/Makefile \
+ $(DESTDIRDEVGUIDEEXAMPLES)$/Forms$/NumericValidator.java \
+ $(DESTDIRDEVGUIDEEXAMPLES)$/Forms$/ProgrammaticScriptAssignment.odt \
+ $(DESTDIRDEVGUIDEEXAMPLES)$/Forms$/SalesFilter.java \
+ $(DESTDIRDEVGUIDEEXAMPLES)$/Forms$/SingleControlValidation.java \
+ $(DESTDIRDEVGUIDEEXAMPLES)$/Forms$/SpreadsheetDocument.java \
+ $(DESTDIRDEVGUIDEEXAMPLES)$/Forms$/SpreadsheetValueBinding.java \
+ $(DESTDIRDEVGUIDEEXAMPLES)$/Forms$/SpreadsheetView.java \
+ $(DESTDIRDEVGUIDEEXAMPLES)$/Forms$/TableCellTextBinding.java \
+ $(DESTDIRDEVGUIDEEXAMPLES)$/Forms$/TextValidator.java \
+ $(DESTDIRDEVGUIDEEXAMPLES)$/Forms$/TimeValidator.java \
+ $(DESTDIRDEVGUIDEEXAMPLES)$/Forms$/UNO.java \
+ $(DESTDIRDEVGUIDEEXAMPLES)$/Forms$/ValueBinding.java \
+ $(DESTDIRDEVGUIDEEXAMPLES)$/Forms$/URLHelper.java \
+ $(DESTDIRDEVGUIDEEXAMPLES)$/Forms$/HsqlDatabase.java \
+ $(DESTDIRDEVGUIDEEXAMPLES)$/Forms$/RowSet.java \
+ $(DESTDIRDEVGUIDEEXAMPLES)$/Forms$/WaitForInput.java
+
+DIR_FILE_LIST= \
+ $(FORMS_FILES)
+
+DIR_DIRECTORY_LIST=$(uniq $(DIR_FILE_LIST:d))
+DIR_CREATE_FLAG=$(MISC)$/devguide_forms_dirs_created.txt
+DIR_FILE_FLAG=$(MISC)$/devguide_forms.txt
+
+#--------------------------------------------------
+# TARGETS
+#--------------------------------------------------
+all : \
+ $(DIR_FILE_LIST) \
+ $(DIR_FILE_FLAG)
+
+#--------------------------------------------------
+# use global rules
+#--------------------------------------------------
+.INCLUDE: $(PRJ)$/util$/odk_rules.pmk
+
diff --git a/odk/examples/DevelopersGuide/GUI/DialogDocument.java b/odk/examples/DevelopersGuide/GUI/DialogDocument.java
new file mode 100644
index 000000000000..5edefb8b118e
--- /dev/null
+++ b/odk/examples/DevelopersGuide/GUI/DialogDocument.java
@@ -0,0 +1,145 @@
+/*************************************************************************
+ *
+ * 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[] { new Integer(400), Boolean.TRUE, "Dialog1", new Integer(102),new Integer(41), new Integer(1), new Short((short) 0), "Document-Dialog", new Integer(300)});
+ oDialogDocument.createWindowPeer();
+ Object oFTHeaderModel = oDialogDocument.m_xMSFDialogModel.createInstance("com.sun.star.awt.UnoControlFixedTextModel");
+ XMultiPropertySet xFTHeaderModelMPSet = (XMultiPropertySet) UnoRuntime.queryInterface(XMultiPropertySet.class, oFTHeaderModel);
+ xFTHeaderModelMPSet.setPropertyValues(
+ new String[] {"Height", "Label", "Name", "PositionX", "PositionY", "Width"},
+ new Object[] { new Integer(8), "This code-sample demonstrates how to display an office document in a dialog window", "HeaderLabel", new Integer(6), new Integer(6), new Integer(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.out);
+ } 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 = (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 = (XWindow) UnoRuntime.queryInterface(XWindow.class, xWindowPeer);
+ XView 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 = (XFrame) UnoRuntime.queryInterface(XFrame.class, oFrame);
+ m_xFrame.initialize(xWindow);
+
+ // load the document and open it in preview mode
+ XComponentLoader 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) {
+ ex.printStackTrace();
+ throw new java.lang.RuntimeException("cannot happen...");
+ } catch (com.sun.star.uno.Exception ex) {
+ ex.printStackTrace();
+ throw new java.lang.RuntimeException("cannot happen...");
+ }
+ }
+
+}
diff --git a/odk/examples/DevelopersGuide/GUI/ImageControlSample.java b/odk/examples/DevelopersGuide/GUI/ImageControlSample.java
new file mode 100644
index 000000000000..024894ae840b
--- /dev/null
+++ b/odk/examples/DevelopersGuide/GUI/ImageControlSample.java
@@ -0,0 +1,163 @@
+/*************************************************************************
+ *
+ * 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[] { new Integer(100), Boolean.TRUE, "MyTestDialog", new Integer(102),new Integer(41), new Integer(0), new Short((short) 0), "OpenOffice", new Integer(230)});
+ Object oFTHeaderModel = oImageControlSample.m_xMSFDialogModel.createInstance("com.sun.star.awt.UnoControlFixedTextModel");
+ XMultiPropertySet xFTHeaderModelMPSet = (XMultiPropertySet) UnoRuntime.queryInterface(XMultiPropertySet.class, oFTHeaderModel);
+ xFTHeaderModelMPSet.setPropertyValues(
+ new String[] {"Height", "Label", "MultiLine", "Name", "PositionX", "PositionY", "Width"},
+ new Object[] { new Integer(16), "This code-sample demonstrates how to create an ImageControlSample within a dialog", Boolean.TRUE, "HeaderLabel", new Integer(6), new Integer(6), new Integer(210)});
+ // add the model to the NameContainer of the dialog model
+ oImageControlSample.m_xDlgModelNameContainer.insertByName("Headerlabel", oFTHeaderModel);
+ XPropertySet xICModelPropertySet = oImageControlSample.insertImageControl(xMCF, 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 = (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(XMultiComponentFactory _xMCF, 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 = (XMultiPropertySet) UnoRuntime.queryInterface(XMultiPropertySet.class, oICModel);
+ xICModelPropertySet =(XPropertySet) 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[] { new Short((short) 1), new Integer(_nHeight), sName, new Integer(_nPosX), new Integer(_nPosY), Boolean.FALSE, new Integer(_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.out);
+ }
+ 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 = (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 = (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...");
+ }}
+}
diff --git a/odk/examples/DevelopersGuide/GUI/Makefile b/odk/examples/DevelopersGuide/GUI/Makefile
new file mode 100644
index 000000000000..4ec70489cedf
--- /dev/null
+++ b/odk/examples/DevelopersGuide/GUI/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 GUI examples of the Developers Guide.
+
+PRJ=../../..
+SETTINGS=$(PRJ)/settings
+
+include $(SETTINGS)/settings.mk
+include $(SETTINGS)/std.mk
+include $(SETTINGS)/dk.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 000000000000..745b25951cd5
--- /dev/null
+++ b/odk/examples/DevelopersGuide/GUI/MessageBox.java
@@ -0,0 +1,245 @@
+/*************************************************************************
+ *
+ * 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.Rectangle;
+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.beans.PropertyValue;
+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 = (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 = (XCloseable)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 avtive frame
+ // which is potentially dangerous
+ public XWindowPeer getWindowPeerOfFrame(XComponent xComp) {
+ try {
+ XFrame xFrame = null;
+
+ if (xComp != null) {
+ XModel 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 = (XFramesSupplier) UnoRuntime.queryInterface(XFramesSupplier.class, oDesktop);
+ xFrame = xFramesSupplier.getActiveFrame();
+ }
+
+ if (xFrame != null){
+ XWindow xWindow = xFrame.getContainerWindow();
+ if (xWindow != null){
+ XWindowPeer 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 =(com.sun.star.frame.XComponentLoader)
+ 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 = new 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 = (XMessageBoxFactory) UnoRuntime.queryInterface(XMessageBoxFactory.class, oToolkit);
+ // rectangle may be empty if position is in the center of the parent peer
+ Rectangle aRectangle = new Rectangle();
+ XMessageBox xMessageBox = xMessageBoxFactory.createMessageBox(_xParentWindowPeer, aRectangle, "errorbox", com.sun.star.awt.MessageBoxButtons.BUTTONS_OK, _sTitle, _sMessage);
+ xComponent = (XComponent) UnoRuntime.queryInterface(XComponent.class, xMessageBox);
+ if (xMessageBox != null){
+ short nResult = xMessageBox.execute();
+ }
+ } catch (com.sun.star.uno.Exception ex) {
+ ex.printStackTrace(System.out);
+ } 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.out);
+ }
+ return bIsActivated;
+ }
+
+ public static int getRedColorShare(int _nColor) {
+ int nRed = (int) _nColor/65536;
+ int nRedModulo = _nColor % 65536;
+ int nGreen = (int) (nRedModulo / 256);
+ int nGreenModulo = (nRedModulo % 256);
+ int nBlue = nGreenModulo;
+ return nRed;
+ }
+
+ public static int getGreenColorShare(int _nColor) {
+ int nRed = (int) _nColor/65536;
+ int nRedModulo = _nColor % 65536;
+ int nGreen = (int) (nRedModulo / 256);
+ return nGreen;
+ }
+
+ public static int getBlueColorShare(int _nColor) {
+ int nRed = (int) _nColor/65536;
+ int nRedModulo = _nColor % 65536;
+ int nGreen = (int) (nRedModulo / 256);
+ int nGreenModulo = (nRedModulo % 256);
+ int nBlue = nGreenModulo;
+ return nBlue;
+ }
+
+}
diff --git a/odk/examples/DevelopersGuide/GUI/RoadmapItemStateChangeListener.java b/odk/examples/DevelopersGuide/GUI/RoadmapItemStateChangeListener.java
new file mode 100644
index 000000000000..a52928cb4be0
--- /dev/null
+++ b/odk/examples/DevelopersGuide/GUI/RoadmapItemStateChangeListener.java
@@ -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.
+ *
+ *************************************************************************/
+
+import com.sun.star.awt.ItemEvent;
+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 {
+ protected 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 = (XPropertySet) 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 denot the same
+ if (nNewID != nOldStep){
+ xDialogModelPropertySet.setPropertyValue("Step", new Integer(nNewID));
+ }
+ } catch (com.sun.star.uno.Exception exception) {
+ exception.printStackTrace(System.out);
+ }
+ }
+
+ public void disposing(EventObject eventObject) {
+ }
+}
+
diff --git a/odk/examples/DevelopersGuide/GUI/SystemDialog.java b/odk/examples/DevelopersGuide/GUI/SystemDialog.java
new file mode 100644
index 000000000000..00aa44162442
--- /dev/null
+++ b/odk/examples/DevelopersGuide/GUI/SystemDialog.java
@@ -0,0 +1,186 @@
+/*************************************************************************
+ *
+ * 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.XFolderPicker;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.XComponentContext;
+
+
+
+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 = (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 = m_xMCF.createInstanceWithContext("com.sun.star.util.PathSettings",m_xContext);
+ XPropertySet 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.services.openoffice.org/wiki/Framework/Article/Filter
+ XFilterManager 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 = (XInitialization) UnoRuntime.queryInterface(XInitialization.class, xFilePicker);
+ Short[] listAny = new Short[] { 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 = (XFilePickerControlAccess) UnoRuntime.queryInterface(XFilePickerControlAccess.class, xFilePicker);
+ xFilePickerControlAccess.setValue(com.sun.star.ui.dialogs.ExtendedFilePickerElementIds.CHECKBOX_AUTOEXTENSION, (short) 0, new Boolean(true));
+
+ xComponent = (XComponent) UnoRuntime.queryInterface(XComponent.class, xFilePicker);
+
+ // execute the dialog...
+ XExecutableDialog xExecutable = (XExecutableDialog) 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 = m_xMCF.createInstanceWithContext("com.sun.star.util.PathSettings",m_xContext);
+ XPropertySet 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);
+ XFolderPicker xFolderPicker = (XFolderPicker) UnoRuntime.queryInterface(XFolderPicker.class, oFolderPicker);
+ XExecutableDialog xExecutable = (XExecutableDialog) UnoRuntime.queryInterface(XExecutableDialog.class, oFolderPicker);
+ xComponent = (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.out);
+ } 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;
+ }
+}
+
diff --git a/odk/examples/DevelopersGuide/GUI/UnoDialogSample.java b/odk/examples/DevelopersGuide/GUI/UnoDialogSample.java
new file mode 100644
index 000000000000..4013dbb79e66
--- /dev/null
+++ b/odk/examples/DevelopersGuide/GUI/UnoDialogSample.java
@@ -0,0 +1,1482 @@
+/*************************************************************************
+ *
+ * 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.PosSize;
+import com.sun.star.awt.PushButtonType;
+import com.sun.star.awt.Rectangle;
+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.XMessageBoxFactory;
+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.PropertyValue;
+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.text.XTextDocument;
+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.XMacroExpander;
+import com.sun.star.util.XNumberFormats;
+import com.sun.star.util.XNumberFormatsSupplier;
+
+
+// Anregung von DV:
+// Position und Weite als Parameter uebergeben
+
+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;
+ protected XModel m_xModel;
+ protected XNameContainer m_xDlgModelNameContainer;
+ protected XControlContainer m_xDlgContainer;
+// protected XNameAccess m_xDlgModelNameAccess;
+ protected XControl m_xDialogControl;
+ protected XDialog xDialog;
+ protected XReschedule mxReschedule;
+ protected XWindowPeer m_xWindowPeer = null;
+ protected XTopWindow m_xTopWindow = 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[] { new Integer(380), Boolean.TRUE, "MyTestDialog", new Integer(102),new Integer(41), new Integer(0), new Short((short) 0), "OpenOffice", new Integer(380)});
+ Object oFTHeaderModel = oUnoDialogSample.m_xMSFDialogModel.createInstance("com.sun.star.awt.UnoControlFixedTextModel");
+ XMultiPropertySet xFTHeaderModelMPSet = (XMultiPropertySet) UnoRuntime.queryInterface(XMultiPropertySet.class, oFTHeaderModel);
+ xFTHeaderModelMPSet.setPropertyValues(
+ new String[] {"Height", "Label", "Name", "PositionX", "PositionY", "Width"},
+ new Object[] { new Integer(8), "This code-sample demonstrates how to create various controls in a dialog", "HeaderLabel", new Integer(106), new Integer(6), new Integer(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, 0, 170000, 1000);
+ 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.getRoadmapItemStateChangeListener());
+ oUnoDialogSample.insertRoadmapItem(0, true, "Introduction", 1);
+ oUnoDialogSample.insertRoadmapItem(1, true, "Documents", 2);
+ oUnoDialogSample.xDialog = (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 );
+ }
+
+
+ /**
+ * @param _sKeyName
+ * @return
+ */
+ public XNameAccess getRegistryKeyContent(String _sKeyName){
+ try {
+ Object oConfigProvider;
+ PropertyValue[] aNodePath = new PropertyValue[1];
+ oConfigProvider = m_xMCF.createInstanceWithContext("com.sun.star.configuration.ConfigurationProvider", this.m_xContext);
+ aNodePath[0] = new PropertyValue();
+ aNodePath[0].Name = "nodepath";
+ aNodePath[0].Value = _sKeyName;
+ XMultiServiceFactory xMSFConfig = (XMultiServiceFactory) UnoRuntime.queryInterface(XMultiServiceFactory.class, oConfigProvider);
+ Object oNode = xMSFConfig.createInstanceWithArguments("com.sun.star.configuration.ConfigurationAccess", aNodePath);
+ XNameAccess xNameAccess = (XNameAccess) UnoRuntime.queryInterface(XNameAccess.class, oNode);
+ return xNameAccess;
+ } catch (Exception exception) {
+ exception.printStackTrace(System.out);
+ return null;
+ }
+ }
+
+
+ /**
+ * @param _sRegistryPath the path a registryNode
+ * @param _sImageName the name of the image
+ */
+ public String getImageUrl(String _sRegistryPath, String _sImageName) {
+ String sImageUrl = "";
+ try {
+ // retrive the configuration node of the extension
+ XNameAccess xNameAccess = getRegistryKeyContent(_sRegistryPath);
+ if (xNameAccess != null){
+ if (xNameAccess.hasByName(_sImageName)){
+ // get the Image Url and process the Url by the macroexpander...
+ sImageUrl = (String) xNameAccess.getByName(_sImageName);
+ Object oMacroExpander = this.m_xContext.getValueByName("/singletons/com.sun.star.util.theMacroExpander");
+ XMacroExpander xMacroExpander = (XMacroExpander) UnoRuntime.queryInterface(XMacroExpander.class, oMacroExpander);
+ sImageUrl = xMacroExpander.expandMacros(sImageUrl);
+ sImageUrl = sImageUrl.substring(new String("vnd.sun.star.expand:").length(), sImageUrl.length());
+ sImageUrl = sImageUrl.trim();
+ sImageUrl += "/" + _sImageName;
+ }
+ }
+ } catch (Exception ex) {
+ /* perform individual exception handling here.
+ * Possible exception types are:
+ * com.sun.star.lang.IllegalArgumentException,
+ * com.sun.star.lang.WrappedTargetException,
+ */
+ ex.printStackTrace(System.out);
+ }
+ return sImageUrl;
+ }
+
+ 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 = (XMultiServiceFactory) UnoRuntime.queryInterface(XMultiServiceFactory.class, oDialogModel);
+
+ // The named container is used to insert the created controls into...
+ m_xDlgModelNameContainer = (XNameContainer) UnoRuntime.queryInterface(XNameContainer.class, oDialogModel);
+
+ // create the dialog...
+ Object oUnoDialog = _xMCF.createInstanceWithContext("com.sun.star.awt.UnoControlDialog", m_xContext);
+ m_xDialogControl = (XControl) UnoRuntime.queryInterface(XControl.class, oUnoDialog);
+
+ // The scope of the control container is public...
+ m_xDlgContainer = (XControlContainer) UnoRuntime.queryInterface(XControlContainer.class, oUnoDialog);
+
+ m_xTopWindow = (XTopWindow) UnoRuntime.queryInterface(XTopWindow.class, m_xDlgContainer);
+
+ // link the dialog and its model...
+ XControlModel xControlModel = (XControlModel) UnoRuntime.queryInterface(XControlModel.class, oDialogModel);
+ m_xDialogControl.setModel(xControlModel);
+ } catch (com.sun.star.uno.Exception exception) {
+ exception.printStackTrace(System.out);
+ }
+ }
+
+
+
+ public short executeDialogWithembeddedExampleSnippets() throws com.sun.star.script.BasicErrorException {
+ if (m_xWindowPeer == null){
+ createWindowPeer();
+ }
+ addRoadmap(getRoadmapItemStateChangeListener());
+ insertRoadmapItem(0, true, "Introduction", 1);
+ insertRoadmapItem(1, true, "Documents", 2);
+ xDialog = (XDialog) UnoRuntime.queryInterface(XDialog.class, m_xDialogControl);
+ return xDialog.execute();
+ }
+
+
+ public short executeDialog() throws com.sun.star.script.BasicErrorException {
+ if (m_xWindowPeer == null) {
+ createWindowPeer();
+ }
+ xDialog = (XDialog) UnoRuntime.queryInterface(XDialog.class, m_xDialogControl);
+ m_xComponent = (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) throws com.sun.star.script.BasicErrorException{
+ try{
+ XMultiPropertySet xMultiPropertySet = (XMultiPropertySet) UnoRuntime.queryInterface(XMultiPropertySet.class, m_xDlgModelNameContainer);
+ xMultiPropertySet.setPropertyValues(PropertyNames, PropertyValues);
+ } catch (com.sun.star.uno.Exception ex) {
+ ex.printStackTrace(System.out);
+ }}
+
+
+
+ /**
+ * create a peer for this
+ * dialog, using the given
+ * peer as a parent.
+ * @param parentPeer
+ * @return
+ * @throws java.lang.Exception
+ */
+ public XWindowPeer createWindowPeer(XWindowPeer _xWindowParentPeer) throws com.sun.star.script.BasicErrorException{
+ try{
+ if (_xWindowParentPeer == null){
+ XWindow 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 = (XToolkit) UnoRuntime.queryInterface(XToolkit.class, tk);
+ mxReschedule = (XReschedule) 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.out);
+ }
+ return null;
+ }
+
+
+ public void calculateDialogPosition(XWindow _xWindow) {
+ Rectangle aFramePosSize = m_xModel.getCurrentController().getFrame().getComponentWindow().getPosSize();
+ Rectangle CurPosSize = _xWindow.getPosSize();
+ int WindowHeight = aFramePosSize.Height;
+ int WindowWidth = aFramePosSize.Width;
+ int DialogWidth = CurPosSize.Width;
+ int DialogHeight = CurPosSize.Height;
+ int iXPos = ((WindowWidth / 2) - (DialogWidth / 2));
+ int iYPos = ((WindowHeight / 2) - (DialogHeight / 2));
+ _xWindow.setPosSize(iXPos, iYPos, DialogWidth, DialogHeight, PosSize.POS);
+ }
+
+
+
+ /**
+ * Creates a peer for this
+ * dialog, using the active OO frame
+ * as the parent window.
+ * @return
+ * @throws java.lang.Exception
+ */
+ public XWindowPeer createWindowPeer() throws com.sun.star.script.BasicErrorException{
+ return createWindowPeer(null);
+ }
+
+ public void endExecute() {
+ xDialog.endExecute();
+ }
+
+
+ public Object insertControlModel(String ServiceName, String sName, String[] sProperties, Object[] sValues) throws com.sun.star.script.BasicErrorException{
+ try {
+ Object oControlModel = m_xMSFDialogModel.createInstance(ServiceName);
+ XMultiPropertySet xControlMultiPropertySet = (XMultiPropertySet) UnoRuntime.queryInterface(XMultiPropertySet.class, oControlModel);
+ xControlMultiPropertySet.setPropertyValues(sProperties, sValues);
+ m_xDlgModelNameContainer.insertByName(sName, oControlModel);
+ return oControlModel;
+ } catch (com.sun.star.uno.Exception exception) {
+ exception.printStackTrace(System.out);
+ return null;
+ }
+ }
+
+
+ public 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 = (XMultiPropertySet) 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[] { new Integer(8), sName, new Integer(_nPosX), new Integer(_nPosY), new Integer(_nStep), new Integer(_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 = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, oFTModel);
+ xFTPSet.setPropertyValue("Label", _sLabel);
+
+ // reference the control by the Name
+ XControl xFTControl = m_xDlgContainer.getControl(sName);
+ xFixedText = (XFixedText) UnoRuntime.queryInterface(XFixedText.class, xFTControl);
+ XWindow 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.out);
+ }
+ return xFixedText;
+ }
+
+
+ public 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 = (XMultiPropertySet) 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[] { new Integer(12), sName, new Integer(_nPositionX), new Integer(_nPositionY), new Integer(_nWidth)});
+
+ // The controlmodel is not really available until inserted to the Dialog container
+ m_xDlgModelNameContainer.insertByName(sName, oCFModel);
+ XPropertySet xCFModelPSet = (XPropertySet) 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 = (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.out);
+ }
+ return xTextComponent;
+ }
+
+
+
+ public 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 = (XMultiPropertySet) 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[] { new Integer(8), sName, new Integer(_nPosX), new Integer(_nPosY), new Integer(_nWidth)});
+
+ // The controlmodel is not really available until inserted to the Dialog container
+ m_xDlgModelNameContainer.insertByName(sName, oPBModel);
+ xPBModelPSet = (XPropertySet) 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", new Integer(0));
+ xPBModelPSet.setPropertyValue("ProgressValueMax", new Integer(_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.out);
+ }
+ 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 = (XMultiPropertySet) 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[] { new Integer(8), sName, new Integer(0), new Integer(_nPosX), new Integer(_nPosY), new Integer(_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 = (XPropertySet) 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.out);
+ }
+ }
+
+
+
+ public 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 = (XMultiPropertySet) 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[] { new Integer(_nHeight), sName, new Integer(_nPosX), new Integer(_nPosY), new Integer(_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 = (XPropertySet) 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.out);
+ }
+ }
+
+
+
+ public 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 = (XMultiPropertySet) 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[] { new Integer(12), sName, new Integer(_nPosX), new Integer(_nPosY), "MyText", new Integer(_nWidth)});
+
+ // The controlmodel is not really available until inserted to the Dialog container
+ m_xDlgModelNameContainer.insertByName(sName, oTFModel);
+ XPropertySet xTFModelPSet = (XPropertySet) 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", new Short((short) '*'));
+ XControl xTFControl = m_xDlgContainer.getControl(sName);
+
+ // add a textlistener that is notified on each change of the controlvalue...
+ xTextComponent = (XTextComponent) UnoRuntime.queryInterface(XTextComponent.class, xTFControl);
+ XWindow xTFWindow = (XWindow) 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.out);
+ }
+ return xTextComponent;
+ }
+
+ public XPropertySet insertTimeField(int _nPosX, int _nPosY, int _nWidth, int _nTime, int _nTimeMin, int _nTimeMax){
+ 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 = (XMultiPropertySet) 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[] { new Integer(12), sName, new Integer(_nPosX), new Integer(_nPosY), Boolean.TRUE, new Integer(_nWidth)});
+
+ // The controlmodel is not really available until inserted to the Dialog container
+ m_xDlgModelNameContainer.insertByName(sName, oTFModel);
+ xTFModelPSet = (XPropertySet) 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", new Short((short) 5));
+ xTFModelPSet.setPropertyValue("TimeMin", new Integer(_nTimeMin));
+ xTFModelPSet.setPropertyValue("TimeMax", new Integer(_nTimeMax));
+ xTFModelPSet.setPropertyValue("Time", new Integer(_nTime));
+ } 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.out);
+ }
+ return xTFModelPSet;
+ }
+
+
+
+ public 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 = (XMultiPropertySet) 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, new Integer(12), sName, new Integer(_nPosX), new Integer(_nPosY), new Integer(_nWidth)});
+
+ // The controlmodel is not really available until inserted to the Dialog container
+ m_xDlgModelNameContainer.insertByName(sName, oDFModel);
+ xDFModelPSet = (XPropertySet) 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", new Short((short) 7));
+ xDFModelPSet.setPropertyValue("DateMin", new Integer(20070401));
+ xDFModelPSet.setPropertyValue("DateMax", new Integer(20070501));
+ xDFModelPSet.setPropertyValue("Date", new Integer(20000415));
+ Object oDFControl = m_xDlgContainer.getControl(sName);
+
+ // add a SpinListener that is notified on each change of the controlvalue...
+ XSpinField 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.out);
+ }
+ return xDFModelPSet;
+ }
+
+
+ public 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 = (XMultiPropertySet) 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[] { new Integer(12), sName, new Integer(_nPosX), new Integer(_nPosY), new Integer(_nWidth)});
+
+ // The controlmodel is not really available until inserted to the Dialog container
+ m_xDlgModelNameContainer.insertByName(sName, oPFModel);
+ xPFModelPSet = (XPropertySet) 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.out);
+ }
+ return xPFModelPSet;
+ }
+
+
+ public 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 = (XMultiPropertySet) 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[] { new Integer(12), sName, new Integer(_nPosX), new Integer(_nPosY), Boolean.TRUE, Boolean.TRUE, new Integer(_nWidth)});
+
+ // The controlmodel is not really available until inserted to the Dialog container
+ m_xDlgModelNameContainer.insertByName(sName, oNFModel);
+ xNFModelPSet = (XPropertySet) 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", new Short(_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.out);
+ }
+ return xNFModelPSet;
+ }
+
+
+
+ public 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 = new Integer(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 = (XMultiPropertySet) 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[] { new Integer(_nHeight), sName, NOrientation, new Integer(_nPosX), new Integer(_nPosY), new Integer(8)});
+
+ // The controlmodel is not really available until inserted to the Dialog container
+ m_xDlgModelNameContainer.insertByName(sName, oSBModel);
+
+ xSBModelPSet = (XPropertySet) 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", new Integer(0));
+ xSBModelPSet.setPropertyValue("ScrollValueMax", new Integer(100));
+ xSBModelPSet.setPropertyValue("ScrollValue", new Integer(5));
+ xSBModelPSet.setPropertyValue("LineIncrement", new Integer(2));
+ xSBModelPSet.setPropertyValue("BlockIncrement", new Integer(10));
+
+ // Add an Adjustment that will listen to changes of the scrollbar...
+ XControl xSBControl = m_xDlgContainer.getControl(sName);
+ XScrollBar 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.out);
+ }
+ 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 sIncSuffix = "";
+ String BaseName = _sElementName;
+ while (bElementexists) {
+ bElementexists = _xElementContainer.hasByName(_sElementName);
+ if (bElementexists) {
+ i += 1;
+ _sElementName = BaseName + Integer.toString(i);
+ }
+ }
+ return _sElementName;
+ }
+
+
+ public 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 = (XMultiPropertySet) UnoRuntime.queryInterface(XMultiPropertySet.class, oCBModel);
+ xCBMPSet.setPropertyValues(
+ new String[] {"Height", "Label", "Name", "PositionX", "PositionY", "Width" } ,
+ new Object[] {new Integer(8), "~Include page number", sName, new Integer(_nPosX), new Integer(_nPosY), new Integer(_nWidth)});
+
+ // The following property may also be set with XMultiPropertySet but we
+ // use the XPropertySet interface merely for reasons of demonstration
+ XPropertySet xCBModelPSet = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xCBMPSet);
+ xCBModelPSet.setPropertyValue("TriState", Boolean.TRUE);
+ xCBModelPSet.setPropertyValue("State", new Short((short) 1));
+
+ // add the model to the NameContainer of the dialog model
+ m_xDlgModelNameContainer.insertByName(sName, oCBModel);
+ XControl xCBControl = m_xDlgContainer.getControl(sName);
+ xCheckBox = (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.out);
+ }
+ return xCheckBox;
+ }
+
+
+
+
+ public 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 = (XMultiPropertySet) 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[] {new Integer(8), "~First Option", sName, new Integer(_nPosX), new Integer(_nPosY), new Short((short) 1), new Short(_nTabIndex++),new Integer(_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 = (XMultiPropertySet) 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[] {new Integer(8), "~Second Option", sName, new Integer(130), new Integer(214), new Short(_nTabIndex), new Integer(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.out);
+ }
+ }
+
+
+ public 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 = (XMultiPropertySet) 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, new Integer(12), sName, new Integer(_nPosX), new Integer(_nPosY), new Integer(_nStep), _sStringItemList, new Integer(_nWidth)});
+ // The following property may also be set with XMultiPropertySet but we
+ // use the XPropertySet interface merely for reasons of demonstration
+ XPropertySet xLBModelPSet = (XPropertySet) 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 = (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.out);
+ }
+ return xListBox;
+ }
+
+
+ public 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 = (XMultiPropertySet) 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, new Integer(12), sName, new Integer(_nPosX), new Integer(_nPosY), sStringItemList, new Integer(_nWidth)});
+
+ // The following property may also be set with XMultiPropertySet but we
+ // use the XPropertySet interface merely for reasons of demonstration
+ XPropertySet xCbBModelPSet = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xCbBModelMPSet);
+ xCbBModelPSet.setPropertyValue("MaxTextLen", new Short((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 = (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.out);
+ }
+ return xComboBox;
+ }
+
+
+
+ public 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 = (XMultiPropertySet) 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), new Integer(12), sName, new Integer(_nPosX), new Integer(_nPosY), Boolean.TRUE, Boolean.TRUE, new Integer(_nWidth)});
+
+ xFFModelPSet = (XPropertySet) 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 = (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", new Integer(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 = (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.out);
+ }
+ return xFFModelPSet;
+ }
+
+ public void convertUnits(){
+ // iXPixelFactor = (int) (100000/xDevice.getInfo().PixelPerMeterX);
+ }
+
+
+ public 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 = m_xMCF.createInstanceWithContext("com.sun.star.util.PathSettings",m_xContext);
+ XPropertySet 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 = (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 = (XMultiPropertySet) UnoRuntime.queryInterface(XMultiPropertySet.class, oFCModel);
+ xFCModelMPSet.setPropertyValues(
+ new String[] {"Height", "Name", "PositionX", "PositionY", "Text", "Width"},
+ new Object[] { new Integer(14), sName, new Integer(_nPosX), new Integer(_nPosY), sSystemWorkPath, new Integer(_nWidth)});
+
+ // The controlmodel is not really available until inserted to the Dialog container
+ m_xDlgModelNameContainer.insertByName(sName, oFCModel);
+ XPropertySet xFCModelPSet = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, oFCModel);
+
+ // add a textlistener that is notified on each change of the controlvalue...
+ XControl xFCControl = m_xDlgContainer.getControl(sName);
+ xTextComponent = (XTextComponent) UnoRuntime.queryInterface(XTextComponent.class, xFCControl);
+ XWindow xFCWindow = (XWindow) 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.out);
+ }
+ 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 = (XMultiPropertySet) 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[] {new Integer(14), _sLabel, sName, new Integer(_nPosX), new Integer(_nPosY), new Short(_nPushButtonType), new Integer(_nWidth)});
+
+ // add the model to the NameContainer of the dialog model
+ m_xDlgModelNameContainer.insertByName(sName, oButtonModel);
+ XControl xButtonControl = m_xDlgContainer.getControl(sName);
+ xButton = (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.out);
+ }
+ return xButton;
+ }
+
+ /** gets the WindowPeer of a frame
+ * @param _XTextDocument the instance of a textdocument
+ * @return the windowpeer of the frame
+ */
+ public XWindowPeer getWindowPeer(XTextDocument _xTextDocument){
+ XModel xModel = (XModel) UnoRuntime.queryInterface(XModel.class, _xTextDocument);
+ XFrame xFrame = xModel.getCurrentController().getFrame();
+ XWindow xWindow = xFrame.getContainerWindow();
+ XWindowPeer xWindowPeer = (XWindowPeer) UnoRuntime.queryInterface(XWindowPeer.class, xWindow);
+ return xWindowPeer;
+ }
+
+ public XFrame getCurrentFrame(){
+ XFrame xRetFrame = null;
+ try {
+ Object oDesktop = m_xMCF.createInstanceWithContext("com.sun.star.frame.Desktop", m_xContext);
+ XDesktop 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 = (XControl) UnoRuntime.queryInterface(XControl.class, textEvent.Source);
+ XControlModel xControlModel = xControl.getModel();
+ XPropertySet xPSet = (XPropertySet) 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.out);
+ }
+ }
+
+
+
+ public void up(SpinEvent spinEvent) {
+ try {
+ // get the control that has fired the event,
+ XControl xControl = (XControl) UnoRuntime.queryInterface(XControl.class, spinEvent.Source);
+ XControlModel xControlModel = xControl.getModel();
+ XPropertySet xPSet = (XPropertySet) 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.out);
+ }
+ }
+
+
+ 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 = (XControl) UnoRuntime.queryInterface(XControl.class, rEvent.Source);
+ XControlModel xControlModel = xControl.getModel();
+ XPropertySet xPSet = (XPropertySet) 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.out);
+ }
+ }
+
+
+ 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 = (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 = (XControl) UnoRuntime.queryInterface(XControl.class, _mouseEvent.Source);
+ Object tk = m_xMCF.createInstanceWithContext("com.sun.star.awt.Toolkit", m_xContext);
+ XToolkit 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 = (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...");
+ }
+ }
+
+
+
+ public void itemStateChanged(ItemEvent itemEvent) {
+ try{
+ // retrieve the control that the event has been invoked at...
+ XCheckBox xCheckBox = (XCheckBox) UnoRuntime.queryInterface(XCheckBox.class, itemEvent.Source);
+ // retrieve the control that we want to disable or enable
+ XControl xControl = (XControl) UnoRuntime.queryInterface(XControl.class, m_xDlgContainer.getControl("CommandButton1"));
+ XPropertySet xModelPropertySet = (XPropertySet) 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", new Boolean(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.out);
+ }
+ }
+
+
+ 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;
+ XSingleServiceFactory m_xSSFRoadmap;
+ XIndexContainer m_xRMIndexCont;
+
+ public void addRoadmap(XItemListener _xItemListener) {
+ XPropertySet xDialogModelPropertySet = null;
+ try {
+ // create a unique name by means of an own implementation...
+ String sRoadmapName = createUniqueName(m_xDlgModelNameContainer, "Roadmap");
+
+ xDialogModelPropertySet = (XPropertySet) 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 = (XMultiPropertySet) UnoRuntime.queryInterface(XMultiPropertySet.class, oRoadmapModel);
+ xRMMPSet.setPropertyValues( new String[] {"Complete", "Height", "Name", "PositionX", "PositionY", "Text", "Width" },
+ new Object[] {Boolean.FALSE, new Integer(nDialogHeight - 26), sRoadmapName, new Integer(0), new Integer(0), "Steps", new Integer(85)});
+ m_xRMPSet = (XPropertySet) 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 = (XSingleServiceFactory) UnoRuntime.queryInterface(XSingleServiceFactory.class, oRoadmapModel);
+ m_xRMIndexCont = (XIndexContainer) UnoRuntime.queryInterface(XIndexContainer.class, oRoadmapModel);
+
+ // add the itemlistener to the control...
+ XControl xRMControl = this.m_xDlgContainer.getControl(sRoadmapName);
+ XItemEventBroadcaster xRMBroadcaster = (XItemEventBroadcaster) UnoRuntime.queryInterface(XItemEventBroadcaster.class, xRMControl);
+ xRMBroadcaster.addItemListener( getRoadmapItemStateChangeListener() );
+ } catch (java.lang.Exception jexception) {
+ jexception.printStackTrace(System.out);
+ }
+ }
+
+ /**
+ *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??? directyl 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 = (XPropertySet) 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", new Boolean(_bEnabled));
+ // in this context the "ID" is meant to refer to a step of the dialog
+ xRMItemPSet.setPropertyValue("ID", new Integer(_ID));
+ m_xRMIndexCont.insertByIndex(Index, oRoadmapItem);
+ } catch (com.sun.star.uno.Exception exception) {
+ exception.printStackTrace(System.out);
+ }
+ }
+
+
+ public void keyReleased(KeyEvent keyEvent) {
+ int i = keyEvent.KeyChar;
+ int n = keyEvent.KeyCode;
+ int m = keyEvent.KeyFunc;
+ }
+
+ public void keyPressed(KeyEvent keyEvent) {
+ }
+
+}
diff --git a/odk/examples/DevelopersGuide/GUI/UnoDialogSample2.java b/odk/examples/DevelopersGuide/GUI/UnoDialogSample2.java
new file mode 100644
index 000000000000..3b85eb57d306
--- /dev/null
+++ b/odk/examples/DevelopersGuide/GUI/UnoDialogSample2.java
@@ -0,0 +1,264 @@
+/*************************************************************************
+ *
+ * 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.XControl;
+import com.sun.star.awt.XDialog;
+import com.sun.star.awt.XFixedText;
+import com.sun.star.awt.XListBox;
+import com.sun.star.awt.XWindow;
+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.beans.XPropertySet;
+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
+ final static int nFixedTextHeight = 8;
+ final static int nControlMargin = 6;
+ final static int nDialogWidth = 250;
+ final static int nDialogHeight = 140;
+ // the default roadmap width == 80 MAPs
+ final static int nRoadmapWidth = 80;
+ final static int nButtonHeight = 14;
+ final static 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 m_xIntrospection = ( XIntrospection ) UnoRuntime.queryInterface(XIntrospection.class, o );
+ // the variable m_xIntrospectionAccess offers functionality to access all methods and properties
+ // of a variable
+ m_xIntrospectionAccess = m_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 = (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 = (int)((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[] { new Integer(nDialogHeight), Boolean.TRUE, "Dialog1", new Integer(102),new Integer(41), new Integer(1), new Short((short) 0), "Inspect a Uno-Object", new Integer(nDialogWidth)});
+ String sIntroLabel = "This Dialog lists information about a given Uno-Object.\nIt offers a view to inspect all suppported 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.getRoadmapItemStateChangeListener());
+ 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", new Short((short) 1));
+ oUnoDialogSample2.m_xRMPSet.setPropertyValue("Complete", Boolean.TRUE);
+ oUnoDialogSample2.xDialog = (XDialog) UnoRuntime.queryInterface(XDialog.class, oUnoDialogSample2.m_xDialogControl);
+ oUnoDialogSample2.xDialog.execute();
+ }catch( Exception ex ) {
+ ex.printStackTrace(System.out);
+ }
+ 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 = ( 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 = ( 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 = (XMultiPropertySet) 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, new Integer(_nHeight), sName, new Integer(_nPosX), new Integer(_nPosY), Boolean.TRUE, new Integer(_nStep), _sStringItemList, new Integer(_nWidth)});
+ m_xDlgModelNameContainer.insertByName(sName, xLBModelMPSet);
+ }catch (com.sun.star.uno.Exception ex) {
+ throw new java.lang.RuntimeException("cannot happen...");
+ }
+ 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 = (XMultiPropertySet) 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[] { new Integer(nHeight), _sLabel, Boolean.TRUE, sName, new Integer(_nPosX), new Integer(_nPosY), new Integer(_nStep), new Integer(_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.out);
+ }
+ }
+
+}// end of class
diff --git a/odk/examples/DevelopersGuide/GUI/UnoMenu.java b/odk/examples/DevelopersGuide/GUI/UnoMenu.java
new file mode 100644
index 000000000000..2fba20245d57
--- /dev/null
+++ b/odk/examples/DevelopersGuide/GUI/UnoMenu.java
@@ -0,0 +1,167 @@
+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.XMenuExtended;
+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;
+ XComponent xComponent = 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.out);
+ }
+ }
+
+
+ public XPopupMenu getPopupMenu(){
+ XPopupMenu xPopupMenu = null;
+ try{
+ // create a popup menu
+ Object oPopupMenu = m_xMCF.createInstanceWithContext("stardiv.Toolkit.VCLXPopupMenu", m_xContext);
+ xPopupMenu = (XPopupMenu) UnoRuntime.queryInterface(XPopupMenu.class, oPopupMenu);
+ XMenuExtended xMenuExtended = (XMenuExtended) UnoRuntime.queryInterface(XMenuExtended.class, xPopupMenu);
+
+ xPopupMenu.insertItem((short) 0, "~First Entry", MenuItemStyle.AUTOCHECK, (short) 0);
+ xPopupMenu.insertItem((short) 1, "First ~Radio Entry", (short) (MenuItemStyle.RADIOCHECK + MenuItemStyle.AUTOCHECK), (short) 1);
+ xPopupMenu.insertItem((short) 2, "~Second Radio Entry", (short) (MenuItemStyle.RADIOCHECK + MenuItemStyle.AUTOCHECK), (short) 2);
+ xPopupMenu.insertItem((short) 3, "~Third RadioEntry",(short) (MenuItemStyle.RADIOCHECK + MenuItemStyle.AUTOCHECK), (short) 3);
+ xPopupMenu.insertSeparator((short)4);
+ xPopupMenu.insertItem((short) 4, "F~ifth Entry", (short) (MenuItemStyle.CHECKABLE + MenuItemStyle.AUTOCHECK), (short) 5);
+ xPopupMenu.insertItem((short) 5, "~Fourth Entry", (short) (MenuItemStyle.CHECKABLE + MenuItemStyle.AUTOCHECK), (short) 6);
+ xPopupMenu.enableItem((short) 1, false);
+ xPopupMenu.insertItem((short) 6, "~Sixth Entry", (short) 0, (short) 7);
+ xPopupMenu.insertItem((short) 7, "~Close Dialog", (short) 0, (short) 8);
+ xPopupMenu.checkItem((short) 2, true);
+ xPopupMenu.addMenuListener(this);
+ }catch( Exception e ) {
+ throw new java.lang.RuntimeException("cannot happen...");
+ }
+ return xPopupMenu;
+ }
+
+
+ public void addMenuBar(XTopWindow _xTopWindow, XMenuListener _xMenuListener){
+ try{
+ // create a menubar at the global MultiComponentFactory...
+ Object oMenuBar = m_xMCF.createInstanceWithContext("stardiv.Toolkit.VCLXMenuBar", m_xContext);
+ // add the menu items...
+ XMenuBar xMenuBar = (XMenuBar) UnoRuntime.queryInterface(XMenuBar.class, oMenuBar);
+ xMenuBar.insertItem((short) 0, "~First MenuBar Item", com.sun.star.awt.MenuItemStyle.AUTOCHECK, (short) 0);
+ xMenuBar.insertItem((short) 1, "~Second MenuBar Item", com.sun.star.awt.MenuItemStyle.AUTOCHECK, (short) 1);
+ xMenuBar.setPopupMenu((short) 0, getPopupMenu());
+ xMenuBar.addMenuListener(_xMenuListener);
+ _xTopWindow.setMenuBar(xMenuBar);
+ }catch( Exception e ) {
+ throw new java.lang.RuntimeException("cannot happen...");
+ }}
+
+ protected void closeDialog(){
+ XComponent xComponent = (XComponent) UnoRuntime.queryInterface(XComponent.class, mxTopWindow);
+ if (xComponent != null){
+ xComponent.dispose();
+ }
+
+ // to ensure that the Java application terminates
+ System.exit( 0 );
+ }
+
+ public 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 = (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 inlude 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 = (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 = (XFrame) UnoRuntime.queryInterface(XFrame.class, oFrame);
+
+ Object oDesktop = m_xMCF.createInstanceWithContext("com.sun.star.frame.Desktop", m_xContext);
+ XFramesSupplier xFramesSupplier = (XFramesSupplier) UnoRuntime.queryInterface(XFramesSupplier.class, oDesktop);
+ m_xFrame.setCreator(xFramesSupplier);
+ // get the XTopWindow interface..
+ xTopWindow = (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 addMenuBar(XWindow _xWindow){
+ XTopWindow xTopWindow = (XTopWindow) UnoRuntime.queryInterface(XTopWindow.class, _xWindow);
+ addMenuBar(xTopWindow, this);
+ }
+
+ public void select(MenuEvent menuEvent){
+ // find out which menu item has been triggered,
+ // by getting the menu-id...
+ switch (menuEvent.MenuId){
+ case 0:
+ // add your menu-item-specific code here:
+ break;
+ case 1:
+ // add your menu-item-specific code here:
+ break;
+ case 7:
+ closeDialog();
+ default:
+ //..
+ }
+ }
+
+ public void highlight(MenuEvent menuEvent) {
+ int i = 0;
+ }
+
+ public void deactivate(MenuEvent menuEvent) {
+ int i = 0; }
+
+ public void activate(MenuEvent menuEvent) {
+ int i = 0;
+ }
+
+}
diff --git a/odk/examples/DevelopersGuide/GUI/UnoMenu2.java b/odk/examples/DevelopersGuide/GUI/UnoMenu2.java
new file mode 100644
index 000000000000..d9f9ed92c741
--- /dev/null
+++ b/odk/examples/DevelopersGuide/GUI/UnoMenu2.java
@@ -0,0 +1,95 @@
+import com.sun.star.awt.MouseEvent;
+import com.sun.star.awt.Rectangle;
+import com.sun.star.awt.XControl;
+import com.sun.star.awt.XMouseListener;
+import com.sun.star.awt.XTopWindow;
+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 implements XMouseListener{
+
+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[] { new Integer(140), Boolean.TRUE, "Dialog1", new Integer(102),new Integer(41), new Integer(1), new Short((short) 0), "Menu-Dialog", new Integer(200)});
+
+ Object oFTHeaderModel = oUnoMenu2.m_xMSFDialogModel.createInstance("com.sun.star.awt.UnoControlFixedTextModel");
+ XMultiPropertySet xFTHeaderModelMPSet = (XMultiPropertySet) UnoRuntime.queryInterface(XMultiPropertySet.class, oFTHeaderModel);
+ xFTHeaderModelMPSet.setPropertyValues(
+ new String[] {"Height", "Label", "Name", "PositionX", "PositionY", "Width"},
+ new Object[] { new Integer(8), "This code-sample demonstrates the creation of a popup-menu", "HeaderLabel", new Integer(6), new Integer(6), new Integer(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.out);
+ }
+ 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 = (XMultiPropertySet) 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[] { new Integer(8), "Right-click here", sName, new Integer(50), new Integer(50), new Integer(100)});
+ // add the model to the NameContainer of the dialog model
+ m_xDlgModelNameContainer.insertByName(sName, oFTModel);
+ XWindow xWindow = (XWindow) UnoRuntime.queryInterface(XWindow.class, m_xDlgContainer.getControl(sName));
+ xWindow.addMouseListener(this);
+ }catch( Exception e ) {
+ System.err.println( e + e.getMessage());
+ e.printStackTrace();
+ }}
+
+ protected void closeDialog(){
+ xDialog.endExecute();
+ }
+
+ public void mouseReleased(MouseEvent mouseEvent) {
+ }
+
+ public void mousePressed(MouseEvent mouseEvent) {
+ if (mouseEvent.PopupTrigger){
+ Rectangle aRectangle = new Rectangle(mouseEvent.X, mouseEvent.Y, 0, 0);
+ XControl xControl = (XControl) UnoRuntime.queryInterface(XControl.class, mouseEvent.Source);
+ getPopupMenu().execute( xControl.getPeer(), aRectangle, com.sun.star.awt.PopupMenuDirection.DEFAULT);
+ }
+ }
+
+ public void mouseExited(MouseEvent mouseEvent) {
+ }
+
+ public void mouseEntered(MouseEvent mouseEvent) {
+ }
+
+ public void disposing(EventObject eventObject) {
+ }
+}
diff --git a/odk/examples/DevelopersGuide/GUI/oologo.gif b/odk/examples/DevelopersGuide/GUI/oologo.gif
new file mode 100644
index 000000000000..eb5e679c0f34
--- /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 000000000000..5aab7ead06e4
--- /dev/null
+++ b/odk/examples/DevelopersGuide/OfficeBean/Makefile
@@ -0,0 +1,89 @@
+#*************************************************************************
+#
+# 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
+
+# normally the idl file should be stored in a directory tree fitting the module structure,
+# for the example we know the module structure
+PACKAGE = com/sun/star/comp/beans
+
+JAVAFILES = \
+ OOoBeanViewer.java \
+
+CLASSFILES = $(patsubst %.java,$(OUT_COMP_CLASS)/$(PACKAGE)/%.class,$(JAVAFILES))
+
+SDK_CLASSPATH = $(subst $(EMPTYSTRING) $(PATH_SEPARATOR),$(PATH_SEPARATOR),$(URE_CLASSES_DIR)/jurt.jar\
+ $(PATH_SEPARATOR)$(URE_CLASSES_DIR)/ridl.jar\
+ $(PATH_SEPARATOR)$(URE_CLASSES_DIR)/juh.jar\
+ $(PATH_SEPARATOR)$(OFFICE_CLASSES_DIR)/unoil.jar\
+ $(PATH_SEPARATOR)$(OFFICE_CLASSES_DIR)/officebean.jar\
+ $(PATH_SEPARATOR)$(OUT_COMP_CLASS))
+
+# Targets
+.PHONY: ALL
+ALL : \
+ OOoBeanViewer
+
+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 000000000000..0bbe5475f23f
--- /dev/null
+++ b/odk/examples/DevelopersGuide/OfficeBean/OOoBeanViewer.java
@@ -0,0 +1,407 @@
+/*************************************************************************
+ *
+ * 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.beans;
+
+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 initally loaded the applet has two buttons
+ * one for opening an existant 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 Appplet
+ */
+ 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/aquire");
+
+ 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();
+ }
+}
+
diff --git a/odk/examples/DevelopersGuide/OfficeBean/OfficeIconColor16.jpg b/odk/examples/DevelopersGuide/OfficeBean/OfficeIconColor16.jpg
new file mode 100644
index 000000000000..cd9c5a602eff
--- /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 000000000000..ccab06b516a7
--- /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 000000000000..cd9c5a602eff
--- /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 000000000000..ccab06b516a7
--- /dev/null
+++ b/odk/examples/DevelopersGuide/OfficeBean/OfficeIconMono32.jpg
Binary files differ
diff --git a/odk/examples/DevelopersGuide/OfficeBean/makefile.mk b/odk/examples/DevelopersGuide/OfficeBean/makefile.mk
new file mode 100644
index 000000000000..4d56dbe7f13e
--- /dev/null
+++ b/odk/examples/DevelopersGuide/OfficeBean/makefile.mk
@@ -0,0 +1,68 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ=..$/..$/..
+PRJNAME=odk
+TARGET=copying
+
+#----------------------------------------------------------------
+.INCLUDE: settings.mk
+.INCLUDE: $(PRJ)$/util$/makefile.pmk
+#----------------------------------------------------------------
+
+#----------------------------------------------------
+# this makefile is only used for copying the example
+# files into the SDK
+#----------------------------------------------------
+
+OFFICEBEAN_FILES=\
+ $(DESTDIRDEVGUIDEEXAMPLES)$/OfficeBean$/OOoBeanViewer.java \
+ $(DESTDIRDEVGUIDEEXAMPLES)$/OfficeBean$/OfficeIconColor16.jpg \
+ $(DESTDIRDEVGUIDEEXAMPLES)$/OfficeBean$/OfficeIconColor32.jpg \
+ $(DESTDIRDEVGUIDEEXAMPLES)$/OfficeBean$/OfficeIconMono16.jpg \
+ $(DESTDIRDEVGUIDEEXAMPLES)$/OfficeBean$/OfficeIconMono32.jpg \
+ $(DESTDIRDEVGUIDEEXAMPLES)$/OfficeBean$/Makefile
+
+DIR_FILE_LIST= \
+ $(OFFICEBEAN_FILES)
+
+DIR_DIRECTORY_LIST=$(uniq $(DIR_FILE_LIST:d))
+DIR_CREATE_FLAG=$(MISC)$/devguide_officebean_dirs_created.txt
+DIR_FILE_FLAG=$(MISC)$/devguide_officebean.txt
+
+#--------------------------------------------------
+# TARGETS
+#--------------------------------------------------
+all : \
+ $(DIR_FILE_LIST) \
+ $(DIR_FILE_FLAG)
+
+#--------------------------------------------------
+# use global rules
+#--------------------------------------------------
+.INCLUDE: $(PRJ)$/util$/odk_rules.pmk
+
diff --git a/odk/examples/DevelopersGuide/OfficeDev/Clipboard/Clipboard.java b/odk/examples/DevelopersGuide/OfficeDev/Clipboard/Clipboard.java
new file mode 100644
index 000000000000..0d79e1e6bc25
--- /dev/null
+++ b/odk/examples/DevelopersGuide/OfficeDev/Clipboard/Clipboard.java
@@ -0,0 +1,229 @@
+/*************************************************************************
+ *
+ * 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.lang.XMultiComponentFactory;
+import com.sun.star.uno.XComponentContext;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.frame.XComponentLoader;
+import com.sun.star.beans.PropertyValue;
+import com.sun.star.beans.XPropertySet;
+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.XClipboardNotifier;
+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 ...");
+ // get the service manager from the office context
+ XMultiComponentFactory xServiceManager =
+ xOfficeContext.getServiceManager();
+
+ // create a new test document
+ Object oDesktop = xServiceManager.createInstanceWithContext(
+ "com.sun.star.frame.Desktop", xOfficeContext);
+
+ XComponentLoader xCompLoader =(XComponentLoader)
+ 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 =(XTextDocument)
+ 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 =
+ (com.sun.star.frame.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 =
+ (com.sun.star.view.XViewSettingsSupplier)UnoRuntime.queryInterface(
+ com.sun.star.view.XViewSettingsSupplier.class,
+ xModel.getCurrentController());
+ xViewSettings.getViewSettings().setPropertyValue(
+ "ZoomType", new Short((short)0));
+ }
+ // test document will be closed later
+
+ Object oClipboard = xServiceManager.createInstanceWithContext(
+ "com.sun.star.datatransfer.clipboard.SystemClipboard",
+ xOfficeContext);
+
+ XClipboard xClipboard = (XClipboard)
+ UnoRuntime.queryInterface(XClipboard.class, oClipboard);
+
+ //---------------------------------------------------
+ // registering as clipboard listener
+ //---------------------------------------------------
+
+ XClipboardNotifier xClipNotifier = (XClipboardNotifier)
+ UnoRuntime.queryInterface(XClipboardNotifier.class, oClipboard);
+
+ ClipboardListener aClipListener= new ClipboardListener();
+
+ xClipNotifier.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
+ //---------------------------------------------------
+ xClipNotifier.removeClipboardListener(aClipListener);
+
+ // close test document
+ com.sun.star.util.XCloseable xCloseable = (com.sun.star.util.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();
+ }
+ }
+}
diff --git a/odk/examples/DevelopersGuide/OfficeDev/Clipboard/ClipboardListener.java b/odk/examples/DevelopersGuide/OfficeDev/Clipboard/ClipboardListener.java
new file mode 100644
index 000000000000..49efd28c0ea8
--- /dev/null
+++ b/odk/examples/DevelopersGuide/OfficeDev/Clipboard/ClipboardListener.java
@@ -0,0 +1,55 @@
+/*************************************************************************
+ *
+ * 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("");
+ }
+}
diff --git a/odk/examples/DevelopersGuide/OfficeDev/Clipboard/ClipboardOwner.java b/odk/examples/DevelopersGuide/OfficeDev/Clipboard/ClipboardOwner.java
new file mode 100644
index 000000000000..eb745bae4119
--- /dev/null
+++ b/odk/examples/DevelopersGuide/OfficeDev/Clipboard/ClipboardOwner.java
@@ -0,0 +1,60 @@
+/*************************************************************************
+ *
+ * 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;
+}
diff --git a/odk/examples/DevelopersGuide/OfficeDev/Clipboard/Makefile b/odk/examples/DevelopersGuide/OfficeDev/Clipboard/Makefile
new file mode 100644
index 000000000000..6c7b7c5496d8
--- /dev/null
+++ b/odk/examples/DevelopersGuide/OfficeDev/Clipboard/Makefile
@@ -0,0 +1,99 @@
+#*************************************************************************
+#
+# 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
+include $(SETTINGS)/dk.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 000000000000..291cbbb97e22
--- /dev/null
+++ b/odk/examples/DevelopersGuide/OfficeDev/Clipboard/TextTransferable.java
@@ -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.
+ *
+ *************************************************************************/
+
+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 final String UNICODE_CONTENT_TYPE = "text/plain;charset=utf-16";
+}
diff --git a/odk/examples/DevelopersGuide/OfficeDev/ContextMenuInterceptor.java b/odk/examples/DevelopersGuide/OfficeDev/ContextMenuInterceptor.java
new file mode 100644
index 000000000000..1b10f7d50dcb
--- /dev/null
+++ b/odk/examples/DevelopersGuide/OfficeDev/ContextMenuInterceptor.java
@@ -0,0 +1,256 @@
+/*************************************************************************
+ *
+ * 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
+ *@since
+ */
+ public static void main(String args[])
+ {
+ try {
+ OfficeConnect aConnect = OfficeConnect.createConnection();
+
+ com.sun.star.frame.XDesktop xDesktop =
+ (com.sun.star.frame.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 =
+ (com.sun.star.frame.XComponentLoader)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]);
+
+ // intialize the test document
+ com.sun.star.frame.XFrame xFrame = null;
+ {
+ com.sun.star.text.XTextDocument xDoc =(com.sun.star.text.XTextDocument)
+ UnoRuntime.queryInterface(com.sun.star.text.XTextDocument.class,
+ xComponent);
+
+ String infoMsg = new String("All context menus of the created document frame contains now a 'Help' entry with the submenus 'Content', 'Help Agent' 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 =
+ (com.sun.star.frame.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 =
+ (com.sun.star.view.XViewSettingsSupplier)UnoRuntime.queryInterface(
+ com.sun.star.view.XViewSettingsSupplier.class, xModel.getCurrentController());
+ xViewSettings.getViewSettings().setPropertyValue(
+ "ZoomType", new Short((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 =
+ (com.sun.star.ui.XContextMenuInterception)UnoRuntime.queryInterface(
+ com.sun.star.ui.XContextMenuInterception.class, xController );
+ if( xContextMenuInterception != null ) {
+ ContextMenuInterceptor aContextMenuInterceptor = new ContextMenuInterceptor();
+ com.sun.star.ui.XContextMenuInterceptor xContextMenuInterceptor =
+ (com.sun.star.ui.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 Agent' 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 = (com.sun.star.util.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 happend!
+ 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
+ *
+ *@param args Description of Parameter
+ *@since
+ */
+ 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 =
+ (com.sun.star.lang.XMultiServiceFactory)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 =
+ (XPropertySet)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 =
+ (com.sun.star.beans.XPropertySet)UnoRuntime.queryInterface(
+ com.sun.star.beans.XPropertySet.class,
+ xMenuElementFactory.createInstance( "com.sun.star.ui.ActionTriggerSeparator" ));
+
+ Short aSeparatorType = new Short( ActionTriggerSeparatorType.LINE );
+ xSeparator.setPropertyValue( "SeparatorType", (Object)aSeparatorType );
+
+ // query sub menu for index container to get access
+ com.sun.star.container.XIndexContainer xSubMenuContainer =
+ (com.sun.star.container.XIndexContainer)UnoRuntime.queryInterface(
+ com.sun.star.container.XIndexContainer.class,
+ xMenuElementFactory.createInstance(
+ "com.sun.star.ui.ActionTriggerContainer" ));
+
+ // intialize root menu entry
+ xRootMenuEntry.setPropertyValue( "Text", new String( "Help" ));
+ xRootMenuEntry.setPropertyValue( "CommandURL", new String( "slot:5410" ));
+ xRootMenuEntry.setPropertyValue( "HelpURL", new String( "5410" ));
+ xRootMenuEntry.setPropertyValue( "SubContainer", (Object)xSubMenuContainer );
+
+ // create menu entries for the new sub menu
+
+ // intialize help/content menu entry
+ XPropertySet xMenuEntry = (XPropertySet)UnoRuntime.queryInterface(
+ XPropertySet.class, xMenuElementFactory.createInstance(
+ "com.sun.star.ui.ActionTrigger" ));
+
+ xMenuEntry.setPropertyValue( "Text", new String( "Content" ));
+ xMenuEntry.setPropertyValue( "CommandURL", new String( "slot:5401" ));
+ xMenuEntry.setPropertyValue( "HelpURL", new String( "5401" ));
+
+ // insert menu entry to sub menu
+ xSubMenuContainer.insertByIndex( 0, (Object)xMenuEntry );
+
+ // intialize help/help agent
+ xMenuEntry = (com.sun.star.beans.XPropertySet)UnoRuntime.queryInterface(
+ com.sun.star.beans.XPropertySet.class,
+ xMenuElementFactory.createInstance(
+ "com.sun.star.ui.ActionTrigger" ));
+ xMenuEntry.setPropertyValue( "Text", new String( "Help Agent" ));
+ xMenuEntry.setPropertyValue( "CommandURL", new String( "slot:5962" ));
+ xMenuEntry.setPropertyValue( "HelpURL", new String( "5962" ));
+
+ // insert menu entry to sub menu
+ xSubMenuContainer.insertByIndex( 1, (Object)xMenuEntry );
+
+ // intialize help/tips
+ xMenuEntry = (com.sun.star.beans.XPropertySet)UnoRuntime.queryInterface(
+ com.sun.star.beans.XPropertySet.class,
+ xMenuElementFactory.createInstance(
+ "com.sun.star.ui.ActionTrigger" ));
+ xMenuEntry.setPropertyValue( "Text", new String( "Tips" ));
+ xMenuEntry.setPropertyValue( "CommandURL", new String( "slot:5404" ));
+ xMenuEntry.setPropertyValue( "HelpURL", new String( "5404" ));
+
+ // insert menu entry to sub menu
+ xSubMenuContainer.insertByIndex( 2, (Object)xMenuEntry );
+
+ // add separator into the given context menu
+ xContextMenu.insertByIndex( 0, (Object)xSeparator );
+
+ // add new sub menu into the given context menu
+ xContextMenu.insertByIndex( 0, (Object)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 a 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 happend!
+ }
+ catch ( java.lang.Exception ex ) {
+ // catch java exceptions and something useful
+ }
+
+ return com.sun.star.ui.ContextMenuInterceptorAction.IGNORED;
+ }
+}
diff --git a/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/CustomizeView.java b/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/CustomizeView.java
new file mode 100644
index 000000000000..0a53b9a1e0b9
--- /dev/null
+++ b/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/CustomizeView.java
@@ -0,0 +1,298 @@
+/*************************************************************************
+ *
+ * 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 javax.swing.*;
+import java.lang.String;
+import java.awt.event.*;
+import java.awt.*;
+
+// __________ Implementation __________
+
+/**
+ * Makes it possible to change some states of currently loaded
+ * document (e.g. enable/disable menubar, toolbar, objectbar)
+ *
+ * @author Andreas Schl&uuml;ns
+ * @created 20.06.2002 09:28
+ */
+public class CustomizeView extends JPanel
+ implements IShutdownListener
+{
+ // ____________________
+ // const
+
+ /**
+ * 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 = "toogle_menu" ;
+ private static final String ACTION_TOOLBAR = "toogle_toolbar" ;
+ private static final String ACTION_OBJECTBAR = "toogle_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 JCheckBox m_cbMenuBar ;
+ private JCheckBox m_cbToolBar ;
+ private 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 occure we use it to synchronize our controls
+ * with states of a (my be) new document view of this frame.
+ *
+ * @param xFrame
+ * the reference to the frame, which provides the
+ * possibility to get the required status informations
+ *
+ * Attention: We don't accept new frames here.
+ * We get one after startup and work with him.
+ * That's it!
+ */
+ public void setFrame(com.sun.star.frame.XFrame xFrame)
+ {
+ if (xFrame==null)
+ return;
+
+ // be listener for click events
+ // They will toogle 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 automaticly!
+ 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 toogle the menu/object- or toolbar.
+ * Note: Because we are listener status events too - hopefully
+ * we get a notification, if toogling was successfully or not.
+ * We use this information to update our check boxes again.
+ * But such update doesn't force (hopefully) an action event. Otherwhise
+ * we can produce a never ending recursion!
+ *
+ * @param aEvent
+ * describes the used check box and his current state
+ * we can use to dispatch the right URL to the office
+ */
+ class ClickListener implements ActionListener,
+ com.sun.star.lang.XEventListener
+ {
+ /// URL, to toogle the requested UI item
+ String m_sURL;
+ /// name of the property which must be used in combination with the URL
+ String m_sProp;
+ /// we must use this frame to dispatch a request
+ com.sun.star.frame.XFrame m_xFrame;
+
+ //_____________________
+
+ /**
+ * ctor
+ * It initialize an instance of this clas only.
+ */
+ 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 occure if somehwere click the
+ * JCheckBox control on which we are registered.
+ * Such events doesn't occure if we set it programmaticly
+ * (e.g. if we get status events to -> see class StatusListener too)
+ *
+ * @param aEvent
+ * describes the check box and his state
+ * we can use to toogle the requested office
+ * ressource.
+ */
+ 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 = new Boolean(bState);
+
+ // execute (dispatch) it into the frame
+ if (m_xFrame==null)
+ return;
+ FunctionHelper.execute(m_xFrame,aURL,lProperties,null);
+ }
+
+ // ____________________
+
+ /**
+ * callback for disposing events
+ * Internaly 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. Otherwhise
+ * 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. Otherwhise 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;
+ }
+}
diff --git a/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/Desk.java b/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/Desk.java
new file mode 100644
index 000000000000..8f635dfdcf6e
--- /dev/null
+++ b/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/Desk.java
@@ -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.
+ *
+ *************************************************************************/
+
+// __________ Imports __________
+
+import com.sun.star.uno.UnoRuntime;
+
+import java.lang.String;
+
+// __________ Implementation __________
+
+/**
+ * TODO
+ *
+ * @author Andreas Schl&uuml;ns
+ * @created 08.02.2002 14:05
+ */
+public class Desk
+{
+ // ____________________
+
+ /**
+ * main
+ * Establish connection to a remote office and starts the demo application.
+ * User can overwrite some of neccessary start options by using command line parameters.
+ *
+ * syntax: Desk [mode={inplace|outplace}] [file=<filename>]
+ *
+ * @param args 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 = new String("inplace");
+ String sFile = new String("private:factory/swriter");
+
+ for(int i=0; i<lArguments.length; ++i)
+ {
+ lArguments[i] = lArguments[i].toLowerCase();
+ if(lArguments[i].startsWith("mode=")==true)
+ sMode = lArguments[i].substring(5);
+ else
+ if(lArguments[i].startsWith("file=")==true)
+ sFile = lArguments[i].substring(5);
+ }
+
+ ViewContainer.mbInplace = (sMode.compareTo("inplace")==0);
+
+ // Connect to remote office.
+ OfficeConnect.createConnection();
+
+ // Create first document view.
+ // This one will register himself at the global
+ // ViewContainer. Further views will be open
+ // automaticly started from this first one.
+ DocumentView aView = new DocumentView();
+ aView.setVisible(true);
+ aView.createFrame();
+ aView.load(sFile);
+ }
+}
diff --git a/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/DocumentView.java b/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/DocumentView.java
new file mode 100644
index 000000000000..a45294c5affe
--- /dev/null
+++ b/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/DocumentView.java
@@ -0,0 +1,430 @@
+/*************************************************************************
+ *
+ * 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 java.lang.*;
+import java.net.*;
+import javax.swing.*;
+import javax.swing.border.*;
+import java.awt.AWTEvent;
+import java.awt.event.WindowEvent;
+
+// __________ Implementation __________
+
+/**
+ * This implement a java frame wich contains
+ * an office document, shows some status informations
+ * 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.
+ *
+ * @author Andreas Schl&uuml;ns
+ * @created 06.03.2002 09:38
+ */
+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.
+ */
+ public static final String COMMAND_OPEN = "open" ;
+ public static final String COMMAND_SAVE = "save" ;
+ public static final String COMMAND_EXPORT = "export" ;
+ public static final String COMMAND_EXIT = "exit" ;
+
+ // ____________________
+
+ /**
+ * @member mxFrame office frame which contains the document of this view
+ *
+ * @member maStatusView special panel wich show available status informations 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 String msName ;
+
+ private JButton mbtOpen ;
+ private JButton mbtSave ;
+ private JButton mbtExport ;
+ private JButton mbtExit ;
+
+ 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
+ mbtOpen = new JButton("Open ..." );
+ mbtSave = new JButton("Save" );
+ mbtExport = new JButton("Save as HTML ...");
+ 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 informations 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 Informations") );
+ 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==true)
+ {
+ // create view to show opened documents
+ // This special view is neccessary 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.
+ * Dependend from 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 setted by user command line parameter.
+ // First try to get a new unambigous frame name from our global ViewContainer.
+ if(ViewContainer.mbInplace==true)
+ {
+ // inplace document view can't be initialized without a visible parent window hierarchy!
+ // So make shure 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 = (com.sun.star.lang.XComponent)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);
+ }
+ }
+
+ // ____________________
+
+ public 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);
+ }
+
+ // ____________________
+
+ public 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.
+ */
+ 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() normaly.
+ * 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
+ // refrences too!
+ maStatusView.shutdown();
+ maCustomizeView.shutdown();
+
+ maStatusView = null;
+ maCustomizeView = null;
+
+ // disable all interceptions
+ maInterceptor.shutdown();
+ maInterceptor = null;
+
+ // close the frame and his document
+ // Relaesing of our listener connections for disposing()
+ // will be forced automaticly then. Because the frame
+ // will call us back ...
+ if (mxFrame!=null)
+ FunctionHelper.closeFrame(mxFrame);
+
+ // deregister this view in the global container
+ // Normaly 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 wish to die. Its not neccessary to remove listener connections
+ * here. Because the broadcaster do it automaticly.
+ * 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.compareTo(COMMAND_OPEN) == 0 )
+ {
+ String sURL = FunctionHelper.askUserForFileURL(DocumentView.this,true);
+ if(sURL!=null)
+ DocumentView.this.load(sURL);
+ }
+ else
+ //-----------------------------
+ // save current document
+ if( sCommand.compareTo(COMMAND_SAVE) == 0 )
+ {
+ DocumentView.this.save();
+ }
+ else
+ //-----------------------------
+ // export current document to html
+ if( sCommand.compareTo(COMMAND_EXPORT) == 0 )
+ {
+ String sURL = FunctionHelper.askUserForFileURL(DocumentView.this,false);
+ if(sURL!=null)
+ DocumentView.this.exportHTML(sURL);
+ }
+ else
+ //-----------------------------
+ // exit application
+ if( sCommand.compareTo(COMMAND_EXIT) == 0 )
+ {
+ // This will force deleting of this and
+ // all other currently opened views automaticly!
+ System.exit(0);
+ }
+ }
+ }
+}
diff --git a/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/FunctionHelper.java b/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/FunctionHelper.java
new file mode 100644
index 000000000000..75af2ab7f35d
--- /dev/null
+++ b/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/FunctionHelper.java
@@ -0,0 +1,1060 @@
+/*************************************************************************
+ *
+ * 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.lang.*;
+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
+ *
+ * @author Andreas Schl&uuml;ns
+ * @created 28.02.2002 15:31
+ */
+public class FunctionHelper
+{
+ // ____________________
+
+ /**
+ * This convert an URL (formated 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 =
+ (com.sun.star.util.XURLTransformer)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.
+ aURL = null;
+ }
+ 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 realy parsed URL.
+ aURL = null;
+ }
+
+ 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 nee 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 otherwhise
+ */
+ private static com.sun.star.frame.XFrame impl_createEmptyFrame(
+ com.sun.star.uno.XComponentContext xCtx )
+ {
+ com.sun.star.frame.XFrame xFrame = null;
+
+ try{
+ xFrame = (com.sun.star.frame.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 = (com.sun.star.frame.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 - otherwhise
+ * 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 an 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 = (com.sun.star.awt.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 normaly nobody outside the office knows this id.
+ // New version of this method ignore the id parameter and creation will
+ // work.
+ // Note: You must be shure if your window handle can be realy used by
+ // the remote office. Means if this java client and the remote office
+ // use the same display!
+ com.sun.star.awt.XSystemChildFactory xChildFactory =
+ (com.sun.star.awt.XSystemChildFactory)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((Object)nHandle,
+ lProcID, nSystem);
+
+ if (xPeer==null)
+ {
+ // mode 3) OK - new version doesn't work. It requires the
+ // process id which we doesn'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 =
+ (com.sun.star.awt.XWindowPeer)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 ressources (which was created before)
+ // will be freed automaticly if scope wil be leaved.
+ System.out.println("May be the NativeView object wasn't realy 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 = (com.sun.star.awt.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 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 informations)
+ // 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 neccessary to do it first - before you call anything else there.
+ // Otherwhise 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 = (com.sun.star.frame.XFramesSupplier)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 ressources (e.g. the container window) automaticly.
+ // 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 occure ... no generell solution exist then.
+ // Nobody can guarantee if next call will work or not.
+ com.sun.star.lang.XComponent xComponent = (com.sun.star.lang.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 occured during creation of desktop service the frame already was created.
+ // Free it by decresing 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 = (com.sun.star.lang.XComponent)UnoRuntime.queryInterface(
+ com.sun.star.lang.XComponent.class,
+ xFrame);
+ xComponent.dispose();
+ xComponent = null;
+ xFrame = null;
+ }
+ }
+
+ return xFrame;
+ }
+
+ // ____________________
+
+ /**
+ * Dispatch an URL to given frame.
+ * Caller can register himself for following status events for dispatched
+ * URL too. But nobody guarantee that such notifications will occure.
+ * (see dispatchWithNotification() if you interest on that)
+ * The returned dispatch object should be hold alive by caller
+ * till he deosn't need it any longer. Otherwise the dispatcher can(!)
+ * die by decreasing his refcount.
+ *
+ * @param xFrame frame wich 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 automaticly 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.
+ * Otherwhise 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 = (com.sun.star.frame.XDispatchProvider)UnoRuntime.queryInterface(
+ com.sun.star.frame.XDispatchProvider.class,
+ xFrame);
+
+ // Ask himn 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;
+ }
+
+ // ____________________
+
+ /**
+ * Dispatch an URL to given frame.
+ * Caller can register himself for following result events for dispatched
+ * URL too. Notifications are guaranteed (instead of dispatch())
+ * Returning of the dispatch object isn't neccessary.
+ * Nobody must hold it alive longer the dispatch needs.
+ *
+ * @param xFrame frame wich 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 automaticly for status events
+ * (Note: Deregistration is not supported. Dispatcher does it automaticly.)
+ */
+ public static void executeWithNotification(com.sun.star.frame.XFrame xFrame ,
+ com.sun.star.util.URL aURL ,
+ com.sun.star.beans.PropertyValue[] lProperties,
+ com.sun.star.frame.XDispatchResultListener xListener )
+ {
+ try
+ {
+ // Query the frame for right interface which provides access to all available dispatch objects.
+ com.sun.star.frame.XDispatchProvider xProvider = (com.sun.star.frame.XDispatchProvider)UnoRuntime.queryInterface(
+ com.sun.star.frame.XDispatchProvider.class,
+ xFrame);
+
+ // Ask himn for right dispatch object for given URL.
+ // Force THIS frame as target for following dispatch.
+ // Attention: The interface XNotifyingDispatch is an optional one!
+ com.sun.star.frame.XDispatch xDispatcher = xProvider.queryDispatch(aURL,"",0);
+ com.sun.star.frame.XNotifyingDispatch xNotifyingDispatcher = (com.sun.star.frame.XNotifyingDispatch)UnoRuntime.queryInterface(
+ com.sun.star.frame.XNotifyingDispatch.class,
+ xDispatcher);
+
+ // Dispatch the URL.
+ if(xNotifyingDispatcher!=null)
+ xNotifyingDispatcher.dispatchWithNotification(aURL,lProperties,xListener);
+ }
+ 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();
+ }
+ }
+
+ // ____________________
+
+ /**
+ * Load document specified by an 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 wich 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 adress it inside the frame tree without any complications.
+ // So we set an unambigous (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 =
+ (com.sun.star.frame.XComponentLoader)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);
+
+ // dont 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.
+ // Normaly 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 = (com.sun.star.frame.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 = (com.sun.star.util.XModifiable)UnoRuntime.queryInterface(
+ com.sun.star.util.XModifiable.class,
+ xModel);
+ if(xModified.isModified()==true)
+ {
+ com.sun.star.frame.XStorable xStore = (com.sun.star.frame.XStorable)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 automaticly 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 wich
+ // filter exist for HTML export. Normaly 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
+ // informations 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 = (com.sun.star.lang.XServiceInfo)
+ 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")==true)
+ sFilter = new String("HTML (StarWriter)");
+ else
+ if(xInfo.supportsService("com.sun.star.text.WebDocument")==true)
+ sFilter = new String("HTML");
+ else
+ if(xInfo.supportsService("com.sun.star.sheet.SpreadsheetDocument")==true)
+ sFilter = new String("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 =
+ (com.sun.star.container.XNameAccess)
+ UnoRuntime.queryInterface(
+ com.sun.star.container.XNameAccess.class,
+ xCtx.getServiceManager().createInstanceWithContext(
+ "com.sun.star.document.FilterFactory", xCtx));
+
+ if(xFilterContainer.hasByName(sFilter)==false)
+ 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
+ // neccessary 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 =
+ (com.sun.star.frame.XStorable)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 document without any saving of modifications.
+ * We can try it only! Controller and/or model of this document
+ * can disagree with that. But mostly they doesn't do so.
+ *
+ * @param xDocument document which should be clcosed
+ */
+ public static void closeDocument(com.sun.star.lang.XComponent xDocument)
+ {
+ try
+ {
+ // Check supported functionality of the document (model or controller).
+ com.sun.star.frame.XModel xModel =
+ (com.sun.star.frame.XModel)UnoRuntime.queryInterface(
+ com.sun.star.frame.XModel.class, xDocument);
+
+ if(xModel!=null)
+ {
+ // It's a full featured office document.
+ // Reset the modify state of it and close it.
+ // Note: Model can disgree by throwing a veto exception.
+ com.sun.star.util.XModifiable xModify =
+ (com.sun.star.util.XModifiable)UnoRuntime.queryInterface(
+ com.sun.star.util.XModifiable.class, xModel);
+
+ xModify.setModified(false);
+ xDocument.dispose();
+ }
+ else
+ {
+ // It's a document which supports a controller .. or may by a pure
+ // window only. If it's at least a controller - we can try to
+ // suspend him. But - he can disagree with that!
+ com.sun.star.frame.XController xController =
+ (com.sun.star.frame.XController)UnoRuntime.queryInterface(
+ com.sun.star.frame.XController.class, xDocument);
+
+ if(xController!=null)
+ {
+ if(xController.suspend(true)==true)
+ {
+ // Note: Don't dispose the controller - destroy the frame
+ // to make it right!
+ com.sun.star.frame.XFrame xFrame = xController.getFrame();
+ xFrame.dispose();
+ }
+ }
+ }
+ }
+ catch(com.sun.star.beans.PropertyVetoException exVeto)
+ {
+ // Can be thrown by "setModified()" call on model.
+ // He disagree with our request.
+ // But there is nothing to do then. Following "dispose()" call wasn't
+ // never called (because we catch it before). Closing failed -that's it.
+ exVeto.printStackTrace();
+ }
+ catch(com.sun.star.lang.DisposedException exDisposed)
+ {
+ // If an UNO object was already disposed before - he throw this special
+ // runtime exception. Of course every UNO call must be look for that -
+ // but it's a question of error handling.
+ // For demonstration this exception is handled here.
+ exDisposed.printStackTrace();
+ }
+ catch(com.sun.star.uno.RuntimeException exRuntime)
+ {
+ // Every uno call can throw that.
+ // Do nothing - closing failed - that's it.
+ exRuntime.printStackTrace();
+ }
+ }
+
+ // ____________________
+
+ /**
+ * Try to close the frame instead of the document.
+ * It shows the possible interface to do so.
+ *
+ * @param xFrame
+ * frame which should be clcosed
+ *
+ * @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 =
+ (com.sun.star.util.XCloseable)UnoRuntime.queryInterface(
+ com.sun.star.util.XCloseable.class, xFrame);
+ if (xCloseable!=null)
+ {
+ // We deliver the owner ship of this frame not to the (possible)
+ // source which throw a CloseVetoException. We whishto 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 = (com.sun.star.frame.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 an 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.
+ *
+ * @return [String]
+ * should represent an 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 =
+ (com.sun.star.frame.XFramesSupplier)UnoRuntime.queryInterface(
+ com.sun.star.frame.XFramesSupplier.class,
+ xCtx.getServiceManager().createInstanceWithContext(
+ "com.sun.star.frame.Desktop", xCtx));
+
+ com.sun.star.container.XIndexAccess xContainer =
+ (com.sun.star.container.XIndexAccess)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 = new String(BASEFRAMENAME+mnViewCount);
+ while(sName.compareTo(xFrame.getName())==0)
+ {
+ ++mnViewCount;
+ sName = new String(BASEFRAMENAME+mnViewCount);
+ }
+ }
+ }
+ catch(com.sun.star.uno.Exception exCreateFailed)
+ {
+ sName = new String(BASEFRAMENAME);
+ }
+
+ if (sName==null)
+ {
+ System.out.println("invalid name!");
+ sName = new String(BASEFRAMENAME);
+ }
+
+ return sName;
+ }
+
+ // ____________________
+
+ /**
+ * helper to get a file URL selected by user
+ * This method doesn't show any API concepts ...
+ * but is neccessary rof this demo application.
+ *
+ * @param aParent parent window of this dialog
+ * @param bOpen If it is set to true =>
+ * dialog is opend 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==true )
+ 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().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:/") ==true ) &&
+ ( sFileURL.startsWith("file://")==false )
+ )
+ {
+ 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 ;
+}
diff --git a/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/IOnewayLink.java b/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/IOnewayLink.java
new file mode 100644
index 000000000000..935f788b8c03
--- /dev/null
+++ b/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/IOnewayLink.java
@@ -0,0 +1,70 @@
+/*************************************************************************
+ *
+ * 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.Vector;
+
+// __________ 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 synchronoues back to the office if a java object
+ * was called in a oneway declared interface method. Then it must be
+ * executed asynchronoues. To do so - a thread can be created which use this
+ * interface. It get the object, which whis to be called back and the type and
+ * parameter of the original request.
+ *
+ * @author Andreas Schl&uuml;ns
+ * @created 17.07.2002 08:09
+ */
+public interface IOnewayLink
+{
+ // _______________________________
+
+ /**
+ * @param nRequest
+ * The two user of this callback can define an unique number,
+ * which identify the type of original interface method. So the called
+ * interface object can decide, which action will be neccessary.
+ *
+ * @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 abstract void execOneway( int nRequest, Vector lParams );
+}
diff --git a/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/IShutdownListener.java b/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/IShutdownListener.java
new file mode 100644
index 000000000000..ba9035383d24
--- /dev/null
+++ b/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/IShutdownListener.java
@@ -0,0 +1,47 @@
+/*************************************************************************
+ *
+ * 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.
+ *
+ * @author Andreas Schl&uuml;ns
+ * @created 03.05.2002 13:51
+ */
+public interface IShutdownListener
+{
+ public abstract void shutdown();
+}
diff --git a/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/Install.txt b/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/Install.txt
new file mode 100644
index 000000000000..fc7c95afbb98
--- /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 000000000000..da1b68bc059d
--- /dev/null
+++ b/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/Interceptor.java
@@ -0,0 +1,672 @@
+/*************************************************************************
+ *
+ * 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.lang.*;
+import javax.swing.*;
+import java.util.Vector;
+
+// __________ Implementation __________
+
+/**
+ * This class can be used to intercept dispatched URL's
+ * on any frame used in this demo application.
+ * It intercept all URL's wich try to create a new empty frame.
+ * (e.g. "private:factory/swriter")
+ * Nobody can guarantee that this interception will be realy 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 occure 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
+ *
+ * @author Andreas Schl&uuml;ns
+ * @created 06.03.2002 09:38
+ */
+public class Interceptor implements com.sun.star.frame.XFrameActionListener,
+ com.sun.star.frame.XDispatchProviderInterceptor,
+ com.sun.star.frame.XDispatchProvider,
+ 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 then 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 automaticly 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 realy.
+ * 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 interecptor
+ * 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==true)
+ return;
+ xFrame = m_xFrame;
+ }
+ m_xFrame.addFrameActionListener(this);
+ synchronized(this)
+ {
+ m_bIsActionListener=true;
+ }
+ }
+
+ //_____________________
+
+ /**
+ * In case we got an 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
+ * funtionality.
+ *
+ * @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*/ Vector lParams )
+ {
+ synchronized(this)
+ {
+ if (m_bDead)
+ return;
+ }
+
+ // was it frameAction()?
+ if (nRequest==OnewayExecutor.REQUEST_FRAMEACTION)
+ {
+ com.sun.star.frame.FrameActionEvent[] lOutAction = new com.sun.star.frame.FrameActionEvent[1];
+ Vector[] lInParams = new Vector[1];
+ lInParams[0] = lParams;
+
+ OnewayExecutor.codeFrameAction( OnewayExecutor.DECODE_PARAMS ,
+ lInParams ,
+ lOutAction );
+ impl_frameAction(lOutAction[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][];
+ Vector[] lInParams = new Vector[1];
+ lInParams[0] = lParams;
+
+ OnewayExecutor.codeDispatch( OnewayExecutor.DECODE_PARAMS ,
+ lInParams ,
+ lOutURL ,
+ lOutProps );
+ impl_dispatch(lOutURL[0],lOutProps[0]);
+ }
+ }
+
+ // ____________________
+
+ /**
+ * call back 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. Otherwhise 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
+ Vector[] lOutParams = new Vector[1];
+ com.sun.star.frame.FrameActionEvent[] lInAction = new com.sun.star.frame.FrameActionEvent[1];
+ lInAction[0] = aEvent;
+
+ OnewayExecutor.codeFrameAction( OnewayExecutor.ENCODE_PARAMS ,
+ lOutParams ,
+ lInAction );
+ OnewayExecutor aExecutor = new OnewayExecutor( (IOnewayLink)this ,
+ OnewayExecutor.REQUEST_FRAMEACTION ,
+ lOutParams[0] );
+ 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;
+ }
+
+ Vector[] lOutParams = new Vector[1];
+ 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;
+
+ OnewayExecutor.codeDispatch( OnewayExecutor.ENCODE_PARAMS ,
+ lOutParams ,
+ lInURL ,
+ lInArguments );
+ OnewayExecutor aExecutor = new OnewayExecutor( (IOnewayLink)this ,
+ OnewayExecutor.REQUEST_DISPATCH ,
+ lOutParams[0] );
+ aExecutor.start();
+ }
+
+
+ //_____________________
+
+ /**
+ * Internal call back 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
+ */
+ public void impl_frameAction(/*IN*/ com.sun.star.frame.FrameActionEvent aEvent)
+ {
+ synchronized(this)
+ {
+ if (m_bDead)
+ return;
+ }
+
+ // deregistration will be done everytime ...
+ // But may it's not neccessary 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 usefull
+ 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 = (com.sun.star.frame.XDispatchProviderInterception)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 whish 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 willn't 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") == true)
+ )
+ {
+ System.out.println("intercept private:factory");
+ return this;
+ }
+
+ // intercept opening the SaveAs dialog
+ if (aURL.Complete.startsWith(".uno:SaveAs") == true)
+ {
+ System.out.println("intercept SaveAs by returning null!");
+ return null;
+ }
+
+ // intercept "File->Exit" inside the menu
+ if (
+ (aURL.Complete.startsWith("slot:5300") == true) ||
+ (aURL.Complete.startsWith(".uno:Quit") == true)
+ )
+ {
+ 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 seperatly by using own "dispatch()" method.
+ // Note: Don't pack return list if "null" objects occure!
+ 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
+ */
+ public 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") == true) ||
+ (aURL.Complete.startsWith(".uno:Quit") == true)
+ )
+ {
+ System.exit(0);
+ }
+ else
+ if (aURL.Complete.startsWith("private:factory") == true)
+ {
+ // Create view frame for showing loaded documents on demand.
+ // The visible state is neccessary 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 realy ...
+ */
+ 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 SavAs 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 automaticly
+ * 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 whish to intercept same URL then this one
+ * This interceptor whish to intercept creation of new documents.
+ */
+ public String[] getInterceptedURLs()
+ {
+ return INTERCEPTED_URLS;
+ }
+
+ // ____________________
+
+ /**
+ * This class listen on the intercepted frame to free all used ressources on closing.
+ * We forget the reference to the frame only here. Deregistration
+ * isn't neccessary here - because this frame dies and wish to forgoten.
+ *
+ * @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. Otherwhise 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 idead to cancel listening for frame action events
+ // before(!) we deregister us as an interceptor.
+ // Because registration and deregistratio nof interceptor objects
+ // will force sending of frame action events ...!
+ if (bIsActionListener)
+ xFrame.removeFrameActionListener(this);
+
+ if (bIsRegistered)
+ {
+ com.sun.star.frame.XDispatchProviderInterception xRegistration = (com.sun.star.frame.XDispatchProviderInterception)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;
+ }
+ }
+}
diff --git a/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/JavaWindowPeerFake.java b/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/JavaWindowPeerFake.java
new file mode 100644
index 000000000000..24cd05e2f526
--- /dev/null
+++ b/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/JavaWindowPeerFake.java
@@ -0,0 +1,107 @@
+/*************************************************************************
+ *
+ * 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.*;
+
+
+/** <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
+{
+ 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 = (Object)maView.maHandle;
+ return aReturn;
+ }
+
+ /** not really neaded.
+ */
+ 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
+ {
+ }
+}
+
diff --git a/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/Makefile b/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/Makefile
new file mode 100644
index 000000000000..bbabb215d48a
--- /dev/null
+++ b/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/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 OfficeDevDestopEnvironment example of the Developers Guide.
+
+PRJ=../../../..
+SETTINGS=$(PRJ)/settings
+
+include $(SETTINGS)/settings.mk
+include $(SETTINGS)/std.mk
+include $(SETTINGS)/dk.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)$$1.class \
+ DocumentView$(QUOTE)$$Reactor.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
+ALL : $(SUBDIR) \
+ $(EXAMPLE_NAME)
+
+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 000000000000..ead6d7745287
--- /dev/null
+++ b/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/NativeView.java
@@ -0,0 +1,182 @@
+/*************************************************************************
+ *
+ * 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 java.lang.*;
+import java.awt.event.*;
+
+// __________ 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.
+ *
+ * @author Andreas Schl&uuml;ns
+ * @created 22.02.2002 08:47
+ */
+
+public class NativeView extends java.awt.Canvas
+{
+ // ____________________
+
+ /**
+ * ctor
+ * Does nothing realy.
+ * We can use our JNI mechanism for an already visible
+ * canvas only. So we overload the method for showing ("setVisible()")
+ * and make our intialization there. BUt we try to show an empty clean
+ * window till there.
+ */
+ public NativeView()
+ {
+ maHandle = null;
+ maSystem = 0;
+ this.setBackground(Color.white);
+ }
+
+ // ____________________
+
+ /**
+ * Overload this method to make neccessary initializations here.
+ * (e.g. get the window handle and neccessary system informations)
+ *
+ * Why here?
+ * Because the handle seams to be available for already visible windows
+ * only. So it's the best place to get it. Special helper method
+ * can be called more then ones - but call native code one times only
+ * and safe the handle and the system type on our members maHandle/maSystem!
+ */
+ public void setVisible(boolean bState)
+ {
+ getHWND();
+ }
+
+ // ____________________
+
+ /**
+ * to guarantee right resize handling inside a swing container
+ * (e.g. JSplitPane) we must provide some informations about our
+ * prefered/minimum and maximum size.
+ */
+ public Dimension getPreferredSize()
+ {
+ return new Dimension(500,300);
+ }
+
+ public Dimension getMaximumSize()
+ {
+ return new Dimension(1024,768);
+ }
+
+ public Dimension getMinimumSize()
+ {
+ return new Dimension(100,100);
+ }
+
+ // ____________________
+
+ /**
+ * overload paint routine to show provide against
+ * repaint errors if no office view is realy 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.
+ */
+ 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 register 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 call herself in a never ending loop ...
+ * So we try to use the JNI code one times only and safe already getted
+ * informations inside this class.
+ */
+ public native int getNativeWindowSystemType();
+ private native long getNativeWindow(); // private! => use getHWND() with cache mechanism!
+
+ public Integer getHWND()
+ {
+ if(maHandle==null)
+ {
+ maHandle = new Integer((int)getNativeWindow());
+ maSystem = getNativeWindowSystemType();
+ }
+ return maHandle;
+ }
+
+ // ____________________
+
+ /**
+ * for using of the JNI methods it's neccessary 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 ;
+}
diff --git a/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/OfficeConnect.java b/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/OfficeConnect.java
new file mode 100644
index 000000000000..e1a8b3f9f35b
--- /dev/null
+++ b/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/OfficeConnect.java
@@ -0,0 +1,205 @@
+/*************************************************************************
+ *
+ * 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.Any;
+
+import java.lang.String;
+
+
+// __________ Implementation __________
+
+/**
+ * support ONE singleton uno connection to an 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.
+ *
+ * @author Andreas Schl&uuml;ns
+ * @created 7. Februar 2002
+ * @modified 05.02.2002 12:10
+ */
+public class OfficeConnect
+{
+ // ____________________
+
+ /**
+ * At first call we create static connection object and open connection to an
+ * office - anew offic einstance 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();
+ }
+
+ // ____________________
+
+ /**
+ * close connection to remote office if it exist
+ */
+ public static synchronized void disconnect()
+ {
+ if(maConnection!=null)
+ {
+ mxServiceManager=null;
+ mxOfficeContext=null;
+ maConnection=null;
+ }
+ }
+
+ // ____________________
+
+ /**
+ * ctor
+ * We try to open the connection in our ctor ... transparently for user.
+ * After it was successfully you will find an internal set member
+ * m_xRemoteContext wich 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 informations
+ */
+ 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.out);
+ System.exit(1);
+
+ }
+ }
+
+ // ____________________
+
+ /**
+ * create uno components inside remote office process
+ * After connection of these proccess 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 automaticly.
+ * @param sServiceSpecifier name of service which should be created
+ * @return the new created service object
+ */
+ public static synchronized Object createRemoteInstance(
+ Class aType, String sServiceSpecifier)
+ {
+ Object 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);
+ System.exit(0);
+ }
+ return aResult;
+ }
+
+ // ____________________
+
+ /**
+ * same as "createRemoteInstance()" but supports additional parameter for
+ * initializing created object
+ *
+ * @param lArguments optional arguments
+ * They are used to initialize new created service.
+ * @param aType Description of Parameter
+ * @param sServiceSpecifier Description of Parameter
+ * @return the new create service object
+ */
+ public static synchronized Object createRemoteInstanceWithArguments(
+ Class aType, String sServiceSpecifier, Any[] lArguments)
+ {
+ Object aResult = null;
+ try
+ {
+ aResult = UnoRuntime.queryInterface(aType,
+ mxServiceManager.createInstanceWithArgumentsAndContext(
+ sServiceSpecifier, lArguments, mxOfficeContext));
+ }
+ catch (com.sun.star.uno.Exception ex)
+ {
+ System.err.println("Couldn't create Service of type "
+ + sServiceSpecifier + ": " + ex);
+ System.exit(0);
+ }
+ return aResult;
+ }
+
+ // ____________________
+
+ /**
+ * 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;
+}
+
diff --git a/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/OnewayExecutor.java b/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/OnewayExecutor.java
new file mode 100644
index 000000000000..7d84d7c5fcca
--- /dev/null
+++ b/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/OnewayExecutor.java
@@ -0,0 +1,240 @@
+/*************************************************************************
+ *
+ * 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.Vector;
+
+// __________ Implementation __________
+
+/**
+ * It's not allowed to call synchronoues back inside an oneway interface call.
+ * (see IOnewayLink too). So we start a thread (implemented by this class), which
+ * gets all neccessary 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.
+ *
+ * @author Andreas Schl&uuml;ns
+ * @created 17.07.2002 08:18
+ */
+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 then 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_STATUSCHANGED = 2 ;
+ public static final int REQUEST_ADDSTATUSLISTENER = 3 ;
+ public static final int REQUEST_REMOVESTATUSLISTENER = 4 ;
+ public static final int REQUEST_DISPATCH = 5 ;
+
+ public static final boolean ENCODE_PARAMS = true ;
+ public static final boolean DECODE_PARAMS = false ;
+
+ // _______________________________
+
+ /**
+ * @member m_rLink the object, which wish to be called back by this thread
+ * @member m_nRequest describes the type of the original request (means the
+ * called oneyway method)
+ * @member m_lParams list of parameters of the original request
+ */
+ private IOnewayLink m_rLink ;
+ private int m_nRequest ;
+ private Vector m_lParams ;
+
+ // _______________________________
+
+ /**
+ * ctor
+ * It's initialize this thread with all neccessary parameters.
+ * It gets the object, which wish to be called back and the type
+ * and parameters of the original request.
+ *
+ * @param nRequest
+ * The two user of this callback can define an unique number,
+ * which identify the type of original interface method.
+ * So the called interface object can decide, which action will be
+ * neccessary.
+ *
+ * @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 ,
+ Vector 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 neccessary parameters.
+ * After that we die by ouerself ...
+ */
+ 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 convertion of the generic parameter list to the original
+ * one easier - you can use this helper methods. They know how suchlist
+ * must be coded. It's not a must to use it - but you can ...
+ */
+ public static void codeFrameAction(
+ boolean bEncode, Vector[] lParams,
+ com.sun.star.frame.FrameActionEvent[] aAction)
+ {
+ if (bEncode)
+ {
+ lParams[0] = new Vector(1);
+ lParams[0].add( (Object)(aAction[0]) );
+ }
+ else
+ {
+ aAction[0] = (com.sun.star.frame.FrameActionEvent)
+ (lParams[0].elementAt(0));
+ }
+ }
+
+ // _______________________________
+
+ public static void codeStatusChanged(
+ boolean bEncode, Vector[] lParams,
+ com.sun.star.frame.FeatureStateEvent[] aStatus)
+ {
+ if (bEncode)
+ {
+ lParams[0] = new Vector(1);
+ lParams[0].add( (Object)aStatus[0] );
+ }
+ else
+ {
+ aStatus[0] = (com.sun.star.frame.FeatureStateEvent)
+ (lParams[0].elementAt(0));
+ }
+ }
+
+ // _______________________________
+
+ public static void codeAddOrRemoveStatusListener(
+ boolean bEncode, Vector[] lParams,
+ com.sun.star.frame.XStatusListener[] xListener,
+ com.sun.star.util.URL[] aURL)
+ {
+ if (bEncode)
+ {
+ lParams[0] = new Vector(2);
+ lParams[0].add( (Object)xListener[0] );
+ lParams[0].add( (Object)aURL[0] );
+ }
+ else
+ {
+ xListener[0] = (com.sun.star.frame.XStatusListener)
+ (lParams[0].elementAt(0));
+ aURL[0] = (com.sun.star.util.URL)(lParams[0].elementAt(1));
+ }
+ }
+
+ // _______________________________
+
+ public static void codeDispatch(
+ boolean bEncode, Vector[] lParams,
+ com.sun.star.util.URL[] aURL,
+ com.sun.star.beans.PropertyValue[][] lArgs)
+ {
+ if (bEncode)
+ {
+ int nLength = lArgs.length+1;
+ int nPos = 0;
+ lParams[0] = new Vector(nLength);
+
+ lParams[0].add( (Object)aURL[0] );
+ --nLength;
+
+ while (nLength>0)
+ {
+ lParams[0].add( (Object)lArgs[0][nPos] );
+ --nLength;
+ ++nPos ;
+ }
+ }
+ else
+ {
+ int nLength = lParams[0].size()-1;
+ int nPos = 0;
+
+ lArgs[0] = new com.sun.star.beans.PropertyValue[nLength];
+ aURL[0] = (com.sun.star.util.URL)(lParams[0].elementAt(0));
+
+ while (nPos<nLength)
+ {
+ lArgs[0][nPos] = (com.sun.star.beans.PropertyValue)
+ (lParams[0].elementAt(nPos+1));
+ ++nPos;
+ }
+ }
+ }
+}
diff --git a/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/StatusListener.java b/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/StatusListener.java
new file mode 100644
index 000000000000..de369dcd8c16
--- /dev/null
+++ b/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/StatusListener.java
@@ -0,0 +1,478 @@
+/*************************************************************************
+ *
+ * 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.lang.String;
+import java.awt.Component;
+import javax.swing.JCheckBox;
+import javax.swing.JLabel;
+import java.util.Vector;
+
+// __________ 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. Otherwhise 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 automaticly.
+ *
+ * Another reason for such extra class for listening:
+ * Most listener callbacks are asynchronoues [oneay] requests.
+ * And it's not allowed to call back synchronously there.
+ * So we must start threads for updating something internaly.
+ *
+ * @author Andreas Schl&uuml;ns
+ * @created 15.07.2002 12:36
+ */
+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 neccessary 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 then one way to finish an object of this class - we must know it sometimes
+ */
+ private Component m_rControl ;
+ private String m_sTrueText ;
+ private 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 sett all neccessary informations 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 realy.
+ * 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 automaticly. 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 everytime.
+ */
+ public void startListening()
+ {
+ com.sun.star.frame.XFrame xFrame = null;
+ synchronized(this)
+ {
+ if (m_bDead)
+ return;
+ if (m_xFrame==null)
+ return;
+ if (m_bIsActionListener==true)
+ return;
+ xFrame = m_xFrame;
+ }
+ xFrame.addFrameActionListener(this);
+ synchronized(this)
+ {
+ m_bIsActionListener=true;
+ }
+ }
+
+ //_____________________
+
+ /**
+ * In case we got an 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
+ * funtionality.
+ *
+ * @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*/ Vector lParams )
+ {
+ synchronized(this)
+ {
+ if (m_bDead)
+ return;
+ }
+ // was it frameAction()?
+ if (nRequest==OnewayExecutor.REQUEST_FRAMEACTION)
+ {
+ com.sun.star.frame.FrameActionEvent[] lOutAction = new com.sun.star.frame.FrameActionEvent[1];
+ Vector[] lInParams = new Vector[1];
+ lInParams[0] = lParams;
+
+ OnewayExecutor.codeFrameAction( OnewayExecutor.DECODE_PARAMS ,
+ lInParams ,
+ lOutAction );
+ impl_frameAction(lOutAction[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 neccessary things there.
+ * But we shouldn't start such action - if it's not realy neccessary.
+ * So we check before, if we are intereested on this event realy.
+ *
+ * @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;
+
+ Vector[] lOutParams = new Vector[1];
+ com.sun.star.frame.FrameActionEvent[] lInAction = new com.sun.star.frame.FrameActionEvent[1];
+ lInAction[0] = aEvent;
+
+ OnewayExecutor.codeFrameAction( OnewayExecutor.ENCODE_PARAMS ,
+ lOutParams ,
+ lInAction );
+ OnewayExecutor aExecutor = new OnewayExecutor( (IOnewayLink)this ,
+ OnewayExecutor.REQUEST_FRAMEACTION ,
+ lOutParams[0] );
+ aExecutor.start();
+ }
+
+ //_____________________
+
+ /**
+ * This is the callback method for the status we listen for an wish to show it
+ * on our UI control. Of yourse it's a oneway method ... but we doesn'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 neccessary 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/dsiable th control.
+ // Means: If the feature isn't available currently - we can't show an status realy 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 ofthe 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. Otherwhise 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 realy 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
+ */
+ public 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 everytime - but registration only, if neccessary!
+ 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 = (com.sun.star.frame.XDispatchProvider)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 neccessary to
+ * remove listener connections here. Because the broadcaster
+ * forget us automaticly. 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. Otherwhise
+ * 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. Otherwhise 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 ;
+ }
+}
diff --git a/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/StatusView.java b/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/StatusView.java
new file mode 100644
index 000000000000..64923f539516
--- /dev/null
+++ b/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/StatusView.java
@@ -0,0 +1,266 @@
+/*************************************************************************
+ *
+ * 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 javax.swing.*;
+import java.lang.String;
+
+// __________ Implementation __________
+
+/**
+ * Implement a view to show status informations
+ * of currently loaded document of a document view.
+ * It use seperate listener threads to get this informations
+ * and actualize it automaticly if frame broadcast changes of
+ * his contained document.
+ * Threads are neccessary to prevent this view against deadlocks.
+ * These deadlocks can occure 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 occure.
+ * Why? UNO had created a new thread for our synchronous call
+ * inside the office process and so exist different threads
+ * for this constallation.
+ *
+ * @author Andreas Schl&uuml;ns
+ * @created 20.06.2002 15:08
+ */
+public class StatusView extends JPanel
+ implements IShutdownListener
+{
+ // ____________________
+
+ /**
+ * const
+ * These URL's describe available feature states.
+ */
+ public static final String FEATUREURL_FONT = "slot:10007";
+ public static final String FEATUREURL_SIZE = "slot:10015";
+ public static final String FEATUREURL_BOLD = "slot:10009";
+ public static final String FEATUREURL_ITALIC = "slot:10008";
+ public static final String FEATUREURL_UNDERLINE = "slot:10014";
+
+ // ____________________
+
+ /**
+ * const
+ * These values are used to show current state of showed feature.
+ */
+ public static final String FONT_OFF = "unknown" ;
+ public static final String SIZE_OFF = "0.0" ;
+ public static final String BOLD_OFF = "-" ;
+ public static final String ITALIC_OFF = "-" ;
+ public static final String UNDERLINE_OFF = "-" ;
+
+ public static final String FONT_ON = "" ;
+ public static final String SIZE_ON = "" ;
+ public static final String BOLD_ON = "X" ;
+ public static final String ITALIC_ON = "X" ;
+ public 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 JLabel m_laFontValue ;
+ private JLabel m_laSizeValue ;
+ private JLabel m_laBoldValue ;
+ private JLabel m_laUnderlineValue ;
+ private 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 imedatly.
+ * We create one status listener for every control we whish to update.
+ * And because the environment of the frame can be changed - these
+ * listener refresh himself internaly for frame action events too.
+ * So we register it as such frame action listener only here.
+ * Rest is done automaticly ...
+ *
+ * @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 herself on this frame and
+ // show her received informations automaticly on setted 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. Otherwhise 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;
+ }
+}
diff --git a/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/ViewContainer.java b/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/ViewContainer.java
new file mode 100644
index 000000000000..e35e3c0d7b99
--- /dev/null
+++ b/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/ViewContainer.java
@@ -0,0 +1,269 @@
+/*************************************************************************
+ *
+ * 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.lang.*;
+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.
+ *
+ * @author Andreas Schl&uuml;ns
+ * @created 01.03.2002 08:42
+ */
+public class ViewContainer extends Thread
+{
+ // ____________________
+
+ /**
+ * provides a singleton view container
+ * Neccessary 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 wil be created by ourself!
+ */
+ private ViewContainer()
+ {
+ mlViews = new Vector();
+ mlListener = new Vector();
+ mbShutdownActive = false ;
+ Runtime.getRuntime().addShutdownHook(this);
+ }
+
+ // ____________________
+
+ /**
+ * This register a new view inside this global container
+ * (if it doesnt already exist).
+ *
+ * @param aView view which whish to be registered inside this container
+ */
+ public void addView(Object aView)
+ {
+ synchronized(mlViews)
+ {
+ if(mlViews.contains(aView)==false)
+ mlViews.add(aView);
+ }
+ }
+
+ // ____________________
+
+ /**
+ * This deregister a view from this global container.
+ * Normaly 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 wish to be deregistered
+ */
+ public void removeView(Object aView)
+ {
+ int nViewCount = 0;
+ synchronized(mlViews)
+ {
+ if(mlViews.contains(aView)==true)
+ 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 neccessary to guarantee his dead ...
+ boolean bShutdownView = false;
+ synchronized(mlListener)
+ {
+ bShutdownView = mlListener.contains(aView);
+ if (bShutdownView==true)
+ mlListener.remove(aView);
+ }
+ if (bShutdownView==true)
+ ((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.
+ // Teh our view container should be empty - but
+ // our listener container can include some references.
+ // These objects wich to be informed then and release e.g. some
+ // remote references.
+ if (nViewCount<1)
+ {
+ boolean bNeccessary = false;
+ synchronized(this)
+ {
+ bNeccessary = ! mbShutdownActive;
+ }
+ if (bNeccessary==true)
+ {
+ System.out.println("call exit(0)!");
+ System.exit(0);
+ }
+ }
+ }
+
+ // ____________________
+
+ /**
+ * add/remove listener for possibe shutdown events
+ */
+ public void addListener( IShutdownListener rListener )
+ {
+ synchronized(mlListener)
+ {
+ if ( ! mlListener.contains(rListener) )
+ mlListener.add(rListener);
+ }
+ }
+
+ // ____________________
+
+ public 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.
+ */
+ public void run()
+ {
+ synchronized(this)
+ {
+ if (mbShutdownActive)
+ return;
+ mbShutdownActive=true;
+ }
+
+ while( true )
+ {
+ IShutdownListener aListener = null;
+ synchronized(mlListener)
+ {
+ try{
+ aListener = (IShutdownListener)mlListener.firstElement();
+ } catch(java.util.NoSuchElementException exEmpty) {}
+ }
+ if (aListener==null)
+ break;
+
+ aListener.shutdown();
+ // May this listener has dergeistered 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;
+ }
+ }
+ }
+
+ // ____________________
+
+ /**
+ * @const BASICNAME it's used to create uinque names for all regieterd views
+ */
+ private static final String BASICNAME = "Document View ";
+
+ // ____________________
+
+ /**
+ * @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 supress it by using this variable!
+ */
+ public static boolean mbInplace = false ;
+ private static ViewContainer maSingleton = null ;
+ private Vector mlViews ;
+ private Vector mlListener ;
+ private boolean mbShutdownActive ;
+}
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 000000000000..d6778b59be70
--- /dev/null
+++ b/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/nativelib/unix/Makefile
@@ -0,0 +1,73 @@
+#*************************************************************************
+#
+# 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
+include $(SETTINGS)/dk.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) $(CC_INCLUDES) $(SDK_JAVA_INCLUDES) $(CC_DEFINES) $(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) $(STLPORTLIB) $(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 000000000000..58bec5f9d088
--- /dev/null
+++ b/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/nativelib/unix/nativeview.c
@@ -0,0 +1,111 @@
+/*************************************************************************
+ *
+ * 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 0L;}
+
+#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;
+ Display* display ;
+
+ /* 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 0L;
+
+ /* 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;
+ display = dsi_x11->display;
+
+ /* 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);
+}
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 000000000000..371b685bd1cf
--- /dev/null
+++ b/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/nativelib/unix/nativeview.h
@@ -0,0 +1,63 @@
+/*************************************************************************
+ *
+ * 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
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 000000000000..71c50df5ea2e
--- /dev/null
+++ b/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/nativelib/windows/Makefile
@@ -0,0 +1,78 @@
+#*************************************************************************
+#
+# 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
+include $(SETTINGS)/dk.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) $(CC_INCLUDES) $(SDK_JAVA_INCLUDES) $(CC_DEFINES) $(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 msvcrt.lib kernel32.lib 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 000000000000..61b79b88cf39
--- /dev/null
+++ b/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/nativelib/windows/nativeview.c
@@ -0,0 +1,178 @@
+/*************************************************************************
+ *
+ * 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 0L;}
+
+#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 0L;
+
+ /* 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! Otherwhise
+ multiple instances will be registered
+ and calls on such construct produce
+ a stack overflow.
+ */
+ if (GetProp( hWnd, OLD_PROC_KEY )==0)
+ {
+ hFuncPtr = SetWindowLong( hWnd, GWL_WNDPROC, (DWORD)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);
+}
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 000000000000..f9ba2a78b6d1
--- /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 000000000000..371b685bd1cf
--- /dev/null
+++ b/odk/examples/DevelopersGuide/OfficeDev/DesktopEnvironment/nativelib/windows/nativeview.h
@@ -0,0 +1,63 @@
+/*************************************************************************
+ *
+ * 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
diff --git a/odk/examples/DevelopersGuide/OfficeDev/DisableCommands/DisableCommandsTest.java b/odk/examples/DevelopersGuide/OfficeDev/DisableCommands/DisableCommandsTest.java
new file mode 100644
index 000000000000..a74c0d102544
--- /dev/null
+++ b/odk/examples/DevelopersGuide/OfficeDev/DisableCommands/DisableCommandsTest.java
@@ -0,0 +1,411 @@
+/*************************************************************************
+ *
+ * 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;
+import com.sun.star.beans.PropertyValue;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.lang.XSingleServiceFactory;
+import com.sun.star.util.XURLTransformer;
+import com.sun.star.frame.XDesktop;
+import com.sun.star.frame.XComponentLoader;
+import com.sun.star.text.XTextDocument;
+
+/*
+ *
+ * @author Carsten Driesner
+ * Provides example code how to enable/disable
+ * commands.
+ */
+public class DisableCommandsTest extends java.lang.Object {
+
+ /*
+ * A list of command names
+ */
+ final static private String[] aCommandURLTestSet =
+ {
+ new String( "Open" ),
+ new String( "About" ),
+ new String( "SelectAll" ),
+ new String( "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 = (com.sun.star.util.XURLTransformer)
+ UnoRuntime.queryInterface(com.sun.star.util.XURLTransformer.class,
+ transformer );
+
+ Object configProvider = xRemoteServiceManager.createInstanceWithContext(
+ "com.sun.star.configuration.ConfigurationProvider",
+ xRemoteContext );
+ xConfigProvider = (com.sun.star.lang.XMultiServiceFactory)
+ UnoRuntime.queryInterface(
+ com.sun.star.lang.XMultiServiceFactory.class, configProvider );
+
+ // create a new test document
+ Object oDesktop = xRemoteServiceManager.createInstanceWithContext(
+ "com.sun.star.frame.Desktop", xRemoteContext);
+
+ XComponentLoader xCompLoader =(XComponentLoader)
+ 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 =(XTextDocument)
+ 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 =
+ (com.sun.star.frame.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 =
+ (com.sun.star.view.XViewSettingsSupplier)UnoRuntime.queryInterface(
+ com.sun.star.view.XViewSettingsSupplier.class,
+ xModel.getCurrentController());
+ xViewSettings.getViewSettings().setPropertyValue(
+ "ZoomType", new Short((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 = (com.sun.star.util.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 = (com.sun.star.frame.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 =
+ (com.sun.star.frame.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 = new String("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 =
+ (com.sun.star.container.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 =
+ (com.sun.star.container.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 =
+ (com.sun.star.util.XChangesBatch)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 = new String("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 =
+ (com.sun.star.lang.XSingleServiceFactory)UnoRuntime.queryInterface(
+ com.sun.star.lang.XSingleServiceFactory.class, xAccess );
+
+ com.sun.star.container.XNameContainer xNameContainer =
+ (com.sun.star.container.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 =
+ (com.sun.star.beans.XPropertySet)
+ UnoRuntime.queryInterface(
+ com.sun.star.beans.XPropertySet.class,
+ xNewElement );
+
+ if ( xPropertySet != null ) {
+ // Create a unique node name.
+ String aCmdNodeName = new String( "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 =
+ (com.sun.star.util.XChangesBatch)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 reseted
+ */
+ 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 = "";
+ }
+}
diff --git a/odk/examples/DevelopersGuide/OfficeDev/DisableCommands/Makefile b/odk/examples/DevelopersGuide/OfficeDev/DisableCommands/Makefile
new file mode 100644
index 000000000000..436871f49b87
--- /dev/null
+++ b/odk/examples/DevelopersGuide/OfficeDev/DisableCommands/Makefile
@@ -0,0 +1,92 @@
+#*************************************************************************
+#
+# 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
+include $(SETTINGS)/dk.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 000000000000..24eb92a3109c
--- /dev/null
+++ b/odk/examples/DevelopersGuide/OfficeDev/FilterDevelopment/AsciiFilter/AsciiReplaceFilter.java
@@ -0,0 +1,733 @@
+/*************************************************************************
+ *
+ * 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 OfficeDev.samples.Filter;
+
+import com.sun.star.lib.uno.helper.Factory;
+import com.sun.star.lib.uno.helper.WeakBase;
+import com.sun.star.registry.XRegistryKey;
+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.Type;
+import com.sun.star.uno.AnyConverter;
+import com.sun.star.beans.PropertyValue;
+
+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;
+
+
+import com.sun.star.lang.IllegalArgumentException;
+
+/*-************************************************************************
+ @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 realy should
+ be used by selecting it in an extra filter property dialog.
+
+ So we show how a filter works fro iport/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
+ {
+ //______________________________
+ // const
+
+ // the supported service names, the first one being the service name of the component itself
+ public static final String[] m_serviceNames = { "com.sun.star.comp.ansifilter.AsciiReplaceFilter" , "com.sun.star.document.ImportFilter", "com.sun.star.document.ExportFilter" };
+
+ // filterprocess states
+ public static final int FILTERPROC_RUNS = 0;
+ public static final int FILTERPROC_BREAK = 1;
+ public 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 realy.
+ * May be usefully for own purposes.
+ *
+ * To see the output inside an office environment
+ * use "soffice ...params... >output.txt"
+ */
+ private 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 xCompContext
+ * the component context of the office
+ */
+ //ctor
+ 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 = new String() ;
+ 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
+ * automaticly 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 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 then 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 furthe information about us.
+ * Otherwhise 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 unambigous ...
+ * So we doesn'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 seams 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 = (com.sun.star.lang.XServiceInfo)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 = (com.sun.star.text.XTextDocument)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 seams 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 = (com.sun.star.lang.XServiceInfo)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 = (com.sun.star.text.XTextDocument)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 an 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 successfully or not.
+ */
+
+ 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()==false)
+ 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 a internal "condition" variable wich 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 alloed 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 occures only.
+ *
+ * @param xTarget
+ * the target text model to put the data in
+ *
+ * @param aOptions
+ * capsulate all other neccessary informations for this filter request
+ * (streams, replace values ...)
+ *
+ * @return a bool value which describes if method was successfully or not.
+ */
+ private boolean implts_import( com.sun.star.text.XTextDocument xTarget ,
+ FilterOptions aOptions )
+ {
+ measure("implts_import {");
+
+ com.sun.star.text.XSimpleText xText = (com.sun.star.text.XSimpleText)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 readed - but that doesn't matter here.
+ // Reason: somewhere cancelled this function.
+ // But check for optioanl replace request before ...
+ int nStart = 0;
+ int nEnd = -1;
+ int nLength = sText.length();
+
+ com.sun.star.text.XTextRange xCursor = (com.sun.star.text.XTextRange)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 = (com.sun.star.util.XRefreshable)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==true)
+ {
+ 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 alloed 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 occures only.
+ *
+ * @param xSource
+ * the source text model to get the data from
+ *
+ * @param aOptions
+ * capsulate all other neccessary informations for this filter request
+ * (streams, replace values ...)
+ *
+ * @return a bool value which describes if method was successfully or not.
+ */
+ private boolean implts_export( com.sun.star.text.XTextDocument xSource ,
+ FilterOptions aOptions)
+ {
+ measure("implts_export {");
+
+ com.sun.star.text.XTextRange xText = (com.sun.star.text.XSimpleText)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");
+
+ // Normaly this function isn't realy 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==true)
+ {
+ 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 Strig 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 easiear 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==true)
+ {
+ if (aOptions.m_bLower==true)
+ 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 otherwhise.
+ */
+ 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;
+ }
+
+
+ /**
+ * Writes the service information into the given registry key.
+ * This method is called by the <code>JavaLoader</code>.
+ *
+ * @param xRegistryKey
+ * Makes structural information (except regarding tree
+ * structures) of a single registry key accessible.
+ *
+ * @return returns true if the operation succeeded
+ *
+ * @see com.sun.star.comp.loader.JavaLoader
+ */
+ public static boolean __writeRegistryServiceInfo( com.sun.star.registry.XRegistryKey xRegistryKey )
+ {
+ return Factory.writeRegistryServiceInfo(
+ _AsciiReplaceFilter.class.getName(),
+ _AsciiReplaceFilter.m_serviceNames,
+ xRegistryKey );
+ }
+}
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 000000000000..013f93a304f5
--- /dev/null
+++ b/odk/examples/DevelopersGuide/OfficeDev/FilterDevelopment/AsciiFilter/FilterOptions.java
@@ -0,0 +1,230 @@
+/*************************************************************************
+ *
+ * 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 OfficeDev.samples.Filter;
+
+import com.sun.star.uno.AnyConverter;
+import com.sun.star.beans.PropertyValue;
+import com.sun.star.io.XInputStream;
+import com.sun.star.io.XOutputStream;
+import com.sun.star.ucb.XSimpleFileAccess;
+import com.sun.star.uno.XComponentContext;
+import com.sun.star.lang.XMultiComponentFactory;
+import com.sun.star.uno.UnoRuntime;
+
+import com.sun.star.uno.Exception;
+import com.sun.star.ucb.CommandAbortedException;
+import com.sun.star.lang.IllegalArgumentException;
+
+/*-************************************************************************
+ @title helper to analyze neccessary option properties of our filter
+ @description Our filter needs some neccessary properties for working:
+ - a stream for input or output
+ - or an URL for creating such streams
+ - informations 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 occure.
+ Another reason: It wuold 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 ;
+ public 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 XMultiComponentFactory m_xMCF ;
+ private 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 xSMGR
+ * 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
+ */
+ public void analyze( boolean bImport ,
+ com.sun.star.beans.PropertyValue[] lDescriptor )
+ {
+ m_xInput = null ;
+ m_xOutput = null ;
+ m_bStreamOwner = false ;
+ m_sURL = null ;
+ m_sOld = new String();
+ m_sNew = new String();
+ 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 occure 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 setted
+ // default values for every neccessary item we need.
+ // In case this exception occures - this default exist
+ // and we can live with it.
+ }
+ }
+
+ // Decide if it's neccessary AND possible to open streams.
+ // Outside user can check for valid FilterOptions by using
+ // corresponding method isValid(). So it's not neccessary 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 realy or not.
+ * That means especialy if neccessary 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
+ * inidcates which stream member must be valid as result of this call
+ */
+ private void impl_openStreams( boolean bImport )
+ {
+ try{
+ com.sun.star.ucb.XSimpleFileAccess xHelper = (com.sun.star.ucb.XSimpleFileAccess)UnoRuntime.queryInterface(
+ com.sun.star.ucb.XSimpleFileAccess.class,
+ m_xMCF.createInstanceWithContext("com.sun.star.ucb.SimpleFileAccess", m_Ctx));
+ if (xHelper!=null)
+ {
+ if (bImport==true)
+ 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 ) {}
+ }
+}
diff --git a/odk/examples/DevelopersGuide/OfficeDev/FilterDevelopment/AsciiFilter/Makefile b/odk/examples/DevelopersGuide/OfficeDev/FilterDevelopment/AsciiFilter/Makefile
new file mode 100644
index 000000000000..e84e53ed3fc0
--- /dev/null
+++ b/odk/examples/DevelopersGuide/OfficeDev/FilterDevelopment/AsciiFilter/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 OfficeDevFilter example of the Developers Guide.
+
+PRJ=../../../../..
+SETTINGS=$(PRJ)/settings
+
+include $(SETTINGS)/settings.mk
+include $(SETTINGS)/std.mk
+include $(SETTINGS)/dk.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
+
+# 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-component;type=Java$(QM)" >> $@
+ @echo $(SQM) $(SQM)manifest:full-path="$(QM)$(subst /META-INF,,$(subst $(SAMPLE_GEN_OUT)/,,$(@D))).uno.jar$(QM)"/$(CSEP) >> $@
+ @echo $(OSEP)/manifest:manifest$(CSEP) >> $@
+
+# rule for component package file
+$(COMP_PACKAGE) : $(COMP_JAR) TypeDetection.xcu $(COMP_UNOPKG_MANIFEST)
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ $(SDK_ZIP) $@ TypeDetection.xcu
+ 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/TypeDetection.xcu b/odk/examples/DevelopersGuide/OfficeDev/FilterDevelopment/AsciiFilter/TypeDetection.xcu
new file mode 100644
index 000000000000..a03358394d72
--- /dev/null
+++ b/odk/examples/DevelopersGuide/OfficeDev/FilterDevelopment/AsciiFilter/TypeDetection.xcu
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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. It 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 000000000000..67f8006db558
--- /dev/null
+++ b/odk/examples/DevelopersGuide/OfficeDev/FilterDevelopment/FlatXmlFilterDetection/FlatXmlTypeDetection.xcu
@@ -0,0 +1,71 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!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 000000000000..11a200398426
--- /dev/null
+++ b/odk/examples/DevelopersGuide/OfficeDev/FilterDevelopment/FlatXmlFilterDetection/Makefile
@@ -0,0 +1,150 @@
+#*************************************************************************
+#
+# 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
+include $(SETTINGS)/dk.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_MAPFILE = $(OUT_COMP_GEN)/$(COMP_NAME).uno.map
+
+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),$@) $<
+
+$(COMP_MAPFILE) : $(SLOFILES)
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ cat $(PRJ)/settings/component.uno.map > $(COMP_MAPFILE)
+ifeq "$(OS)" "MACOSX"
+ nm -gx $(SLOFILES) | $(ADDSYMBOLS) >> $(COMP_MAPFILE)
+endif
+
+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) $(STLPORTLIB) msvcrt.lib kernel32.lib
+ $(LINK_MANIFEST)
+else
+$(SHAREDLIB_OUT)/%.$(SHAREDLIB_EXT) : $(SLOFILES) $(COMP_MAPFILE)
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ $(LINK) $(COMP_LINK_FLAGS) $(LINK_LIBS) -o $@ $(SLOFILES) \
+ $(CPPUHELPERLIB) $(CPPULIB) $(SALLIB) $(STLPORTLIB) $(STC++LIB) $(CPPUHELPERDYLIB) $(CPPUDYLIB) $(SALDYLIB)
+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-component;type=native;platform=$(UNOPKG_PLATFORM)$(QM)" >> $@
+ @echo $(SQM) $(SQM)manifest:full-path="$(QM)$(subst /META-INF,,$(subst $(OUT_COMP_GEN)/,,$(UNOPKG_PLATFORM)/$(@D))).uno.$(SHAREDLIB_EXT)$(QM)"/$(CSEP) >> $@
+ @echo $(OSEP)/manifest:manifest$(CSEP) >> $@
+
+# rule for component package file
+$(COMP_PACKAGE) : $(SHAREDLIB_OUT)/$(COMP_IMPL_NAME) FlatXmlTypeDetection.xcu $(COMP_UNOPKG_MANIFEST)
+ -$(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) $(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),$(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 000000000000..92c164d348c8
--- /dev/null
+++ b/odk/examples/DevelopersGuide/OfficeDev/FilterDevelopment/FlatXmlFilterDetection/fdcomp.cxx
@@ -0,0 +1,109 @@
+/*************************************************************************
+ *
+ * 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 <cppuhelper/factory.hxx>
+#include <com/sun/star/lang/XSingleServiceFactory.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"
+{
+//==================================================================================================
+void SAL_CALL component_getImplementationEnvironment(
+ const sal_Char ** ppEnvTypeName, uno_Environment ** ppEnv )
+{
+ *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
+}
+
+//==================================================================================================
+sal_Bool SAL_CALL component_writeInfo(
+ void * pServiceManager, void * pRegistryKey )
+{
+ if (pRegistryKey)
+ {
+ try
+ {
+ Reference< XRegistryKey > xNewKey(
+ reinterpret_cast< XRegistryKey * >( pRegistryKey )->createKey( FilterDetect_getImplementationName() ) );
+ xNewKey = xNewKey->createKey( OUString::createFromAscii( "/UNO/SERVICES" ) );
+
+ const Sequence< OUString > & rSNL = FilterDetect_getSupportedServiceNames();
+ const OUString * pArray = rSNL.getConstArray();
+ for ( sal_Int32 nPos = rSNL.getLength(); nPos--; )
+ xNewKey->createKey( pArray[nPos] );
+
+ return sal_True;
+ }
+ catch (InvalidRegistryException &)
+ {
+ OSL_ENSURE( sal_False, "### InvalidRegistryException!" );
+ }
+ }
+ return sal_False;
+}
+
+//==================================================================================================
+void * SAL_CALL component_getFactory(
+ const sal_Char * pImplName, void * pServiceManager, void * pRegistryKey )
+{
+ void * pRet = 0;
+
+ OUString implName = OUString::createFromAscii( pImplName );
+ if ( pServiceManager && implName.equals(FilterDetect_getImplementationName()) )
+ {
+ Reference< XSingleServiceFactory > xFactory( createSingleFactory(
+ reinterpret_cast< XMultiServiceFactory * >( pServiceManager ),
+ OUString::createFromAscii( pImplName ),
+ FilterDetect_createInstance, FilterDetect_getSupportedServiceNames() ) );
+
+ if (xFactory.is())
+ {
+ xFactory->acquire();
+ pRet = xFactory.get();
+ }
+ }
+ return pRet;
+}
+
+}
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 000000000000..e7d49cb21a8c
--- /dev/null
+++ b/odk/examples/DevelopersGuide/OfficeDev/FilterDevelopment/FlatXmlFilterDetection/filterdetect.cxx
@@ -0,0 +1,254 @@
+/*************************************************************************
+ *
+ * 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 <osl/diagnose.h>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#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/io/XInputStream.hpp>
+#include <com/sun/star/document/XExtendedFilterDetection.hpp>
+#include <com/sun/star/beans/PropertyState.hpp>
+#include <com/sun/star/ucb/XSimpleFileAccess.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+
+
+using namespace rtl;
+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;
+
+
+OUString SAL_CALL FilterDetect::detect(Sequence< PropertyValue >& aArguments )
+ throw( RuntimeException )
+{
+ // 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.equalsAscii("TypeName" ) )
+ aArguments[i].Value >>= sOriginalTypeName;
+ if (aName.equalsAscii("URL" ) )
+ aArguments[i].Value >>= sURL;
+ if (aName.equalsAscii("InputStream" ) )
+ aArguments[i].Value >>= xInStream;
+ }
+
+ if (!xInStream.is())
+ {
+ // open the stream if it was not suplied by the framework
+ Reference< XSimpleFileAccess > xSFI(mxMSF->createInstance(
+ OUString::createFromAscii("com.sun.star.ucb.SimpleFileAccess" )), UNO_QUERY);
+ if (sURL.getLength() > 0 && xSFI.is())
+ {
+ 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
+ // conatains a clas="..." attribut 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 it's 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 sal_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 = OUString::createFromAscii("devguide_FlatXMLType_Cpp_writer");
+ else if (aMimeType.equals("application/x-vnd.oasis.opendocument.text-master") ||
+ aMimeType.equals("application/vnd.oasis.opendocument.text-master"))
+ sTypeName = OUString::createFromAscii("devguide_FlatXMLType_Cpp_master");
+ else if (aMimeType.equals("application/x-vnd.oasis.openoffice.text-global") ||
+ aMimeType.equals("application/vnd.oasis.openoffice.text-global"))
+ sTypeName = OUString::createFromAscii("devguide_FlatXMLType_Cpp_master");
+ else if (aMimeType.equals("application/x-vnd.oasis.opendocument.spreadsheet") ||
+ aMimeType.equals("application/vnd.oasis.opendocument.spreadsheet"))
+ sTypeName = OUString::createFromAscii("devguide_FlatXMLType_Cpp_calc");
+ else if (aMimeType.equals("application/x-vnd.oasis.opendocument.drawing") ||
+ aMimeType.equals("application/vnd.oasis.opendocument.drawing"))
+ sTypeName = OUString::createFromAscii("devguide_FlatXMLType_Cpp_draw");
+ else if (aMimeType.equals("application/x-vnd.oasis.opendocument.presentation") ||
+ aMimeType.equals("application/vnd.oasis.opendocument.presentation"))
+ sTypeName = OUString::createFromAscii("devguide_FlatXMLType_Cpp_impress");
+ else if (aMimeType.equals("application/x-vnd.oasis.opendocument.presentation") ||
+ aMimeType.equals("application/vnd.oasis.opendocument.presentation"))
+ sTypeName = OUString::createFromAscii("devguide_FlatXMLType_Cpp_impress");
+ }
+ }
+ return sTypeName;
+}
+
+
+// XInitialization
+void SAL_CALL FilterDetect::initialize( const Sequence< Any >& aArguments )
+ throw (Exception, RuntimeException)
+{
+ 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.equalsAsciiL ( RTL_CONSTASCII_STRINGPARAM ( "Type" ) ) )
+ {
+ pValue[i].Value >>= msFilterName;
+ }
+ else if ( pValue[i].Name.equalsAsciiL ( RTL_CONSTASCII_STRINGPARAM ( "UserData" ) ) )
+ {
+ pValue[i].Value >>= msUserData;
+ }
+ else if ( pValue[i].Name.equalsAsciiL ( RTL_CONSTASCII_STRINGPARAM ( "TemplateName" ) ) )
+ {
+ pValue[i].Value>>=msTemplateName;
+ }
+ }
+ }
+}
+
+OUString FilterDetect_getImplementationName ()
+ throw (RuntimeException)
+{
+ return OUString ( RTL_CONSTASCII_USTRINGPARAM ( "devguide.officedev.samples.filter.FlatXmlDetect" ) );
+}
+
+#define SERVICE_NAME1 "com.sun.star.document.ExtendedTypeDetection"
+
+sal_Bool SAL_CALL FilterDetect_supportsService( const OUString& ServiceName )
+ throw (RuntimeException)
+{
+ return ServiceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM ( SERVICE_NAME1 ) );
+}
+
+Sequence< OUString > SAL_CALL FilterDetect_getSupportedServiceNames( )
+ throw (RuntimeException)
+{
+ Sequence < OUString > aRet(2);
+ OUString* pArray = aRet.getArray();
+ pArray[0] = OUString ( RTL_CONSTASCII_USTRINGPARAM ( SERVICE_NAME1 ) );
+ return aRet;
+}
+#undef SERVICE_NAME1
+#undef SERVICE_NAME2
+
+Reference< XInterface > SAL_CALL FilterDetect_createInstance( const Reference< XMultiServiceFactory > & rSMgr)
+ throw( Exception )
+{
+ return (cppu::OWeakObject*) new FilterDetect( rSMgr );
+}
+
+// XServiceInfo
+OUString SAL_CALL FilterDetect::getImplementationName( )
+ throw (RuntimeException)
+{
+ return FilterDetect_getImplementationName();
+}
+
+sal_Bool SAL_CALL FilterDetect::supportsService( const OUString& rServiceName )
+ throw (RuntimeException)
+{
+ return FilterDetect_supportsService( rServiceName );
+}
+
+Sequence< OUString > SAL_CALL FilterDetect::getSupportedServiceNames( )
+ throw (RuntimeException)
+{
+ return FilterDetect_getSupportedServiceNames();
+}
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 000000000000..c0f423d5fd61
--- /dev/null
+++ b/odk/examples/DevelopersGuide/OfficeDev/FilterDevelopment/FlatXmlFilterDetection/filterdetect.hxx
@@ -0,0 +1,118 @@
+/*************************************************************************
+ *
+ * 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 _FILTERDETECT_HXX
+#define _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>
+
+#ifndef _CPPUHELPER_IMPLBASE4_HXX_
+#include <cppuhelper/implbase3.hxx>
+#endif
+
+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::lang::XMultiServiceFactory > mxMSF;
+ ::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 )
+ throw (::com::sun::star::uno::RuntimeException);
+
+ sal_Bool SAL_CALL importImpl( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& aDescriptor )
+ throw (::com::sun::star::uno::RuntimeException);
+
+public:
+ FilterDetect( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > &rxMSF)
+ : mxMSF( rxMSF ) {}
+
+ virtual ~FilterDetect() {}
+
+ //XExtendedFilterDetection
+ virtual ::rtl::OUString SAL_CALL detect( com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue >& lDescriptor )
+ throw( com::sun::star::uno::RuntimeException );
+
+ // XInitialization
+
+ virtual void SAL_CALL initialize( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments )
+ throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
+
+ // XServiceInfo
+ virtual ::rtl::OUString SAL_CALL getImplementationName( )
+ throw (::com::sun::star::uno::RuntimeException);
+
+ virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName )
+ throw (::com::sun::star::uno::RuntimeException);
+
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( )
+ throw (::com::sun::star::uno::RuntimeException);
+};
+
+
+::rtl::OUString FilterDetect_getImplementationName()
+ throw ( ::com::sun::star::uno::RuntimeException );
+
+sal_Bool SAL_CALL FilterDetect_supportsService( const ::rtl::OUString& ServiceName )
+ throw ( ::com::sun::star::uno::RuntimeException );
+
+::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL FilterDetect_getSupportedServiceNames( )
+ throw ( ::com::sun::star::uno::RuntimeException );
+
+::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >
+SAL_CALL FilterDetect_createInstance( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & rSMgr)
+ throw ( ::com::sun::star::uno::Exception );
+
+#endif
+
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 000000000000..b1cf3afbf536
--- /dev/null
+++ b/odk/examples/DevelopersGuide/OfficeDev/FilterDevelopment/FlatXmlFilter_cpp/FlatXml.cxx
@@ -0,0 +1,373 @@
+/*************************************************************************
+ *
+ * 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/servicefactory.hxx>
+#include <cppuhelper/implbase1.hxx>
+#include <cppuhelper/implbase2.hxx>
+#include <cppuhelper/implbase3.hxx>
+#include <cppuhelper/implbase.hxx>
+
+#include <com/sun/star/lang/XComponent.hpp>
+
+#include <com/sun/star/uno/Any.hxx>
+#include <com/sun/star/uno/Type.hxx>
+
+#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)
+ throw(RuntimeException);
+
+ // XExportFilter
+ virtual sal_Bool SAL_CALL exporter(
+ const Sequence<PropertyValue>& aSourceData,
+ const Sequence<OUString>& msUserData)
+ throw(RuntimeException);
+
+ // XDocumentHandler
+ virtual void SAL_CALL startDocument()
+ throw (SAXException,RuntimeException);
+ virtual void SAL_CALL endDocument()
+ throw (SAXException, RuntimeException);
+ virtual void SAL_CALL startElement(const OUString& str, const Reference<XAttributeList>& attriblist)
+ throw (SAXException,RuntimeException);
+ virtual void SAL_CALL endElement(const OUString& str)
+ throw (SAXException, RuntimeException);
+ virtual void SAL_CALL characters(const OUString& str)
+ throw (SAXException, RuntimeException);
+ virtual void SAL_CALL ignorableWhitespace(const OUString& str)
+ throw (SAXException, RuntimeException);
+ virtual void SAL_CALL processingInstruction(const OUString& str, const OUString& str2)
+ throw (com::sun::star::xml::sax::SAXException,RuntimeException);
+ virtual void SAL_CALL setDocumentLocator(const Reference<XLocator>& doclocator)
+ throw (SAXException,RuntimeException);
+};
+
+sal_Bool XFlatXml::importer(
+ const Sequence<PropertyValue>& aSourceData,
+ const Reference<XDocumentHandler>& xHandler,
+ const Sequence<OUString>& msUserData)
+ throw (RuntimeException)
+{
+ // get information from media descriptor
+ // the imput 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.equalsAscii("InputStream"))
+ aSourceData[i].Value >>= xInputStream;
+ else if ( aName.equalsAscii("FileName"))
+ aSourceData[i].Value >>= aFileName;
+ else if ( aName.equalsAscii("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(
+ OUString::createFromAscii("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_ENSURE(0, exc.Message);
+ return sal_False;
+ }
+
+ // done
+ return sal_True;
+}
+
+sal_Bool XFlatXml::exporter(
+ const Sequence<PropertyValue>& aSourceData,
+ const Sequence<OUString>& msUserData)
+ throw (RuntimeException)
+{
+
+ // read source data
+ // we are especialy interested in the output stream
+ // since that is where our xml-writer will push the data
+ // from it's 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.equalsAscii("OutputStream"))
+ aSourceData[i].Value >>= rOutputStream;
+ else if ( aName.equalsAscii("URL" ))
+ aSourceData[i].Value >>= sURL;
+ }
+
+ if (!m_rDocumentHandler.is()) {
+ // get the document writer
+ m_rDocumentHandler = Reference<XExtendedDocumentHandler>(
+ m_rServiceFactory->createInstance(
+ OUString::createFromAscii("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 the
+// events to the XML writer that we created upon the output stream
+// that was provided by the XMLFilterAdapter
+void XFlatXml::startDocument() throw (SAXException,RuntimeException){
+ OSL_ASSERT(m_rDocumentHandler.is());
+ m_rDocumentHandler->startDocument();
+}
+
+void XFlatXml::endDocument() throw (SAXException,RuntimeException){
+ OSL_ASSERT(m_rDocumentHandler.is());
+ m_rDocumentHandler->endDocument();
+}
+
+void XFlatXml::startElement(const OUString& str, const Reference<XAttributeList>& attriblist)
+ throw (SAXException, RuntimeException)
+{
+ OSL_ASSERT(m_rDocumentHandler.is());
+ m_rDocumentHandler->startElement(str, attriblist);
+}
+
+void XFlatXml::endElement(const OUString& str)
+ throw (SAXException, RuntimeException)
+{
+ OSL_ASSERT(m_rDocumentHandler.is());
+ m_rDocumentHandler->endElement(str);
+}
+
+void XFlatXml::characters(const OUString& str)
+ throw (SAXException, RuntimeException)
+{
+ OSL_ASSERT(m_rDocumentHandler.is());
+ m_rDocumentHandler->characters(str);
+}
+
+void XFlatXml::ignorableWhitespace(const OUString& str)
+ throw (SAXException, RuntimeException)
+{
+ OSL_ASSERT(m_rDocumentHandler.is());
+ if (!m_bPrettyPrint) return;
+ m_rDocumentHandler->ignorableWhitespace(str);
+}
+
+void XFlatXml::processingInstruction(const OUString& str, const OUString& str2)
+ throw (SAXException, RuntimeException)
+{
+ OSL_ASSERT(m_rDocumentHandler.is());
+ m_rDocumentHandler->processingInstruction(str, str2);
+}
+
+void XFlatXml::setDocumentLocator(const Reference<XLocator>& doclocator)
+ throw (SAXException, RuntimeException)
+{
+ 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::createFromAscii(
+ "devguide.officedev.samples.filter.FlatXmlCpp");
+ pNames = &seqNames;
+ }
+ }
+ return *pNames;
+}
+
+}
+
+using namespace XFlatXml;
+#define IMPLEMENTATION_NAME "devguide.officedev.samples.filter.FlatXmlCpp"
+
+
+extern "C"
+{
+void SAL_CALL component_getImplementationEnvironment(
+ const sal_Char ** ppEnvTypeName, uno_Environment ** ppEnv )
+{
+ *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
+}
+
+sal_Bool SAL_CALL component_writeInfo(void * pServiceManager, void * pRegistryKey )
+{
+ if (pRegistryKey)
+ {
+ try
+ {
+ Reference< XRegistryKey > xNewKey(
+ reinterpret_cast< XRegistryKey * >( pRegistryKey )->createKey(
+ OUString::createFromAscii( "/" IMPLEMENTATION_NAME "/UNO/SERVICES" ) ) );
+
+ const Sequence< OUString > & rSNL = getSupportedServiceNames();
+ const OUString * pArray = rSNL.getConstArray();
+ for ( sal_Int32 nPos = rSNL.getLength(); nPos--; )
+ xNewKey->createKey( pArray[nPos] );
+
+ return sal_True;
+ }
+ catch (InvalidRegistryException &)
+ {
+ OSL_ENSURE( sal_False, "### InvalidRegistryException!" );
+ }
+ }
+ return sal_False;
+}
+
+void * SAL_CALL component_getFactory(
+ const sal_Char * pImplName, void * pServiceManager, void * pRegistryKey )
+{
+ void * pRet = 0;
+
+ if (pServiceManager && rtl_str_compare( pImplName, IMPLEMENTATION_NAME ) == 0)
+ {
+ Reference< XSingleServiceFactory > xFactory( createSingleFactory(
+ reinterpret_cast< XMultiServiceFactory * >( pServiceManager ),
+ OUString::createFromAscii( pImplName ),
+ CreateInstance, getSupportedServiceNames() ) );
+
+ if (xFactory.is())
+ {
+ xFactory->acquire();
+ pRet = xFactory.get();
+ }
+ }
+ return pRet;
+}
+
+} // extern "C"
diff --git a/odk/examples/DevelopersGuide/OfficeDev/FilterDevelopment/FlatXmlFilter_cpp/FlatXmlFilter_cpp.uno.xml b/odk/examples/DevelopersGuide/OfficeDev/FilterDevelopment/FlatXmlFilter_cpp/FlatXmlFilter_cpp.uno.xml
new file mode 100644
index 000000000000..9202844eef76
--- /dev/null
+++ b/odk/examples/DevelopersGuide/OfficeDev/FilterDevelopment/FlatXmlFilter_cpp/FlatXmlFilter_cpp.uno.xml
@@ -0,0 +1,59 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE module-description PUBLIC "-//StarOffice//DTD ComponentDescription 1.0//EN" "module-description.dtd">
+<module-description xmlns:xlink="http://www.w3.org/1999/xlink">
+ <module-name> FlatXml </module-name>
+ <component-description>
+ <author> Aidan Butler </author>
+ <name>devguide.officedev.samples.filter.FlatXmlCpp</name>
+
+<description>
+ This component is a sample implementation, which describes how a filter may be written that uses the XmlFilterAdaptor component. This filter opens and saves Flat Xml files.
+ </description>
+ <loader-name> com.sun.star.loader.SharedLibrary </loader-name>
+ <language> c++ </language>
+ <status value="final"/>
+ <supported-service>devguide.officedev.samples.filter.FlatXmlCpp</supported-service>
+ <type>com.sun.star.lang.XSingleServiceFactory</type>
+ <type>com.sun.star.uno.XNamingService</type>
+ <type>com.sun.star.uno.XComponentContext</type>
+ <type>com.sun.star.uno.XWeak</type>
+ <type>com.sun.star.lang.XMain</type>
+ <type>com.sun.star.uno.XAggregation</type>
+ <type>com.sun.star.lang.XMultiServiceFactory</type>
+ <type>com.sun.star.lang.XSingleComponentFactory</type>
+ <type>com.sun.star.lang.XTypeProvider</type>
+ <type>com.sun.star.frame.XComponentLoader</type>
+ <type>com.sun.star.registry.XSimpleRegistry</type>
+ <type>com.sun.star.loader.XImplementationLoader</type>
+ <type>com.sun.star.registry.XImplementationRegistration</type>
+ <type>com.sun.star.lang.XComponent</type>
+ <type>com.sun.star.bridge.XBridgeFactory</type>
+ <type>com.sun.star.bridge.XUnoUrlResolver</type>
+ <type>com.sun.star.connection.XAcceptor</type>
+ <type>com.sun.star.connection.XConnector</type>
+ <type>com.sun.star.container.XHierarchicalNameAccess</type>
+ <type>com.sun.star.lang.XServiceInfo</type>
+ <type>com.sun.star.xml.sax.XDocumentHandler</type>
+ <type>com.sun.star.xml.sax.XExtendedDocumentHandler</type>
+ <type>com.sun.star.text.XTextDocument</type>
+ <type>com.sun.star.xml.XImportFilter</type>
+ <type>com.sun.star.xml.XExportFilter</type>
+ <type>com.sun.star.io.XInputStream</type>
+ <type>com.sun.star.io.XOutputStream</type>
+ <type>com.sun.star.io.XActiveDataSource</type>
+ <type>com.sun.star.io.XSeekable</type>
+ <type>com.sun.star.frame.XConfigManager</type>
+ <type>com.sun.star.xml.sax.XParser</type>
+ <type>com.sun.star.ucb.XSimpleFileAccess</type>
+ <type>com.sun.star.beans.XPropertySet</type>
+ </component-description>
+ <project-build-dependency> cppuhelper </project-build-dependency>
+ <project-build-dependency> cppu </project-build-dependency>
+ <project-build-dependency> sal </project-build-dependency>
+ <runtime-module-dependency> cppuhelper$(UDK_MAJOR)$(COM) </runtime-module-dependency>
+ <runtime-module-dependency> salhelper$(UDK_MAJOR)$(COM) </runtime-module-dependency>
+ <runtime-module-dependency> cppu$(UDK_MAJOR) </runtime-module-dependency>
+ <runtime-module-dependency> reg$(UDK_MAJOR) </runtime-module-dependency>
+ <runtime-module-dependency> store$(UDK_MAJOR) </runtime-module-dependency>
+ <runtime-module-dependency> sal$(UDK_MAJOR) </runtime-module-dependency>
+</module-description>
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 000000000000..8244bbd3a810
--- /dev/null
+++ b/odk/examples/DevelopersGuide/OfficeDev/FilterDevelopment/FlatXmlFilter_cpp/FlatXmlFilter_cpp.xcu
@@ -0,0 +1,86 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!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. It 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. It 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. It 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. It 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. It it is not necessary. -->
+ <value xml:lang="x-no-translate"></value>
+ <value xml:lang="de">DevGuide FlatXML Matser</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 000000000000..09a4cfafa4dd
--- /dev/null
+++ b/odk/examples/DevelopersGuide/OfficeDev/FilterDevelopment/FlatXmlFilter_cpp/Makefile
@@ -0,0 +1,148 @@
+#*************************************************************************
+#
+# 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
+include $(SETTINGS)/dk.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_MAPFILE = $(OUT_COMP_GEN)/$(COMP_NAME).uno.map
+
+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),$@) $<
+
+$(COMP_MAPFILE) : $(SLOFILES)
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ cat $(PRJ)/settings/component.uno.map > $(COMP_MAPFILE)
+ifeq "$(OS)" "MACOSX"
+ nm -gx $(SLOFILES) | $(ADDSYMBOLS) >> $(COMP_MAPFILE)
+endif
+
+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) $(STLPORTLIB) msvcrt.lib kernel32.lib
+ $(LINK_MANIFEST)
+else
+$(SHAREDLIB_OUT)/%.$(SHAREDLIB_EXT) : $(SLOFILES) $(COMP_MAPFILE)
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ $(LINK) $(COMP_LINK_FLAGS) $(LINK_LIBS) -o $@ $(SLOFILES) \
+ $(CPPUHELPERLIB) $(CPPULIB) $(SALLIB) $(STLPORTLIB) $(STC++LIB) $(CPPUHELPERDYLIB) $(CPPUDYLIB) $(SALDYLIB)
+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-component;type=native;platform=$(UNOPKG_PLATFORM)$(QM)" >> $@
+ @echo $(SQM) $(SQM)manifest:full-path="$(QM)$(subst /META-INF,,$(subst $(OUT_COMP_GEN)/,,$(UNOPKG_PLATFORM)/$(@D))).uno.$(SHAREDLIB_EXT)$(QM)"/$(CSEP) >> $@
+ @echo $(OSEP)/manifest:manifest$(CSEP) >> $@
+
+# rule for component package file
+$(COMP_PACKAGE) : $(SHAREDLIB_OUT)/$(COMP_IMPL_NAME) FlatXmlFilter_cpp.xcu $(COMP_UNOPKG_MANIFEST)
+ -$(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) $(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
+
+FlatXmlFilterCppExample : $(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),$(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 000000000000..cf95e1637c08
--- /dev/null
+++ b/odk/examples/DevelopersGuide/OfficeDev/FilterDevelopment/FlatXmlFilter_java/FlatXml.java
@@ -0,0 +1,273 @@
+/*************************************************************************
+ *
+ * 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.*;
+import java.util.*;
+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 XMultiServiceFactory m_xServiceFactory;
+ private XExtendedDocumentHandler m_xHandler;
+ private boolean m_bPrettyPrint = true;
+
+ static private final String __serviceName = "devguide.officedev.samples.filter.FlatXmlJava";
+ static private final String __implName = "FlatXml";
+ static private final String[] __supportedServiceNames = {
+ "devguide.officedev.samples.filter.FlatXmlJava"
+ };
+
+ public FlatXml(XMultiServiceFactory f) {
+ m_xServiceFactory = f;
+ }
+
+ // --- XTypeProvider ---
+ public byte[] getImplementationId() {
+ return Integer.toString(this.hashCode()).getBytes();
+ }
+
+ // --- 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 = (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 = (XExtendedDocumentHandler)UnoRuntime.queryInterface(XExtendedDocumentHandler.class, tmpObj);
+ }
+ if (m_xHandler == null)
+ return false;
+
+ // Connect the provided output stream to the writer
+ XActiveDataSource xADSource = (XActiveDataSource)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;
+ }
+
+ public static boolean __writeRegistryServiceInfo(XRegistryKey regKey)
+ {
+ return FactoryHelper.writeRegistryServiceInfo(__implName,
+ __serviceName, regKey);
+ }
+
+}
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 000000000000..16a04144c5e7
--- /dev/null
+++ b/odk/examples/DevelopersGuide/OfficeDev/FilterDevelopment/FlatXmlFilter_java/FlatXmlFilter_java.xcu
@@ -0,0 +1,86 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!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. It 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. It 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. It 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. It 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. It 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 000000000000..afd060aee7be
--- /dev/null
+++ b/odk/examples/DevelopersGuide/OfficeDev/FilterDevelopment/FlatXmlFilter_java/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 Java FlatXMLFilter component example of the Developers Guide.
+
+PRJ=../../../../..
+SETTINGS=$(PRJ)/settings
+
+include $(SETTINGS)/settings.mk
+include $(SETTINGS)/std.mk
+include $(SETTINGS)/dk.mk
+
+# Define non-platform/compiler specific settings
+COMPONENT_NAME=FlatXmlFilter_java
+OUT_COMP_CLASS = $(OUT_CLASS)/$(COMPONENT_NAME)
+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_COMP_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)$(PS)devguide_$(COMPONENT_NAME)_register_component.flag
+
+JAVAFILES = \
+ FlatXml.java \
+
+CLASSFILES = $(patsubst %.java,$(OUT_COMP_CLASS)/%.class,$(JAVAFILES))
+
+
+#$(COMPONENT_NAME)_CLASSFILES = FlatXml.class FlatXml$(dlr)_FlatXml.class
+
+$(COMPONENT_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
+$(COMPONENT_JAR) : $(COMPONENT_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-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) FlatXmlFilter_java.xcu $(COMPONENT_UNOPKG_MANIFEST)
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ $(SDK_ZIP) $@ FlatXmlFilter_java.xcu
+ cd $(subst /,$(PS),$(OUT_COMP_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
+
+FlatXmlFilterJavaExample : $(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),$(COMPONENT_PACKAGE_URL)))
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$(REGISTERFLAG)))
diff --git a/odk/examples/DevelopersGuide/OfficeDev/Linguistic/LinguisticExamples.java b/odk/examples/DevelopersGuide/OfficeDev/Linguistic/LinguisticExamples.java
new file mode 100644
index 000000000000..60829600861f
--- /dev/null
+++ b/odk/examples/DevelopersGuide/OfficeDev/Linguistic/LinguisticExamples.java
@@ -0,0 +1,368 @@
+/*************************************************************************
+ *
+ * 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.uno.XComponentContext;
+import com.sun.star.uno.XNamingService;
+import com.sun.star.lang.XMultiComponentFactory;
+import com.sun.star.lang.EventObject;
+import com.sun.star.lang.Locale;
+import com.sun.star.bridge.XUnoUrlResolver;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.Any;
+import com.sun.star.lang.XComponent;
+
+public class LinguisticExamples
+{
+ // The remote office ocntext
+ 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 it's 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 = (XLinguServiceManager)
+ UnoRuntime.queryInterface(XLinguServiceManager.class, aObj);
+ }
+ return mxLinguSvcMgr != null;
+ }
+
+
+ /** Get the SpellChecker to be used.
+ */
+ public boolean GetSpell()
+ throws com.sun.star.uno.Exception,
+ 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.Exception,
+ 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.Exception,
+ 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
+ // form 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 = new 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 detectetd!" );
+ 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 = (XPropertySet) UnoRuntime.queryInterface(
+ XPropertySet.class,aObj);
+
+ // set a spellchecker and hyphenator property value to a defined state
+ try {
+ aLinguProps.setPropertyValue("IsGermanPreReform", new 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", new 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 programm termination.
+ //! should not be omitted.
+ mxLinguSvcMgr.removeLinguServiceManagerListener(aClient);
+
+
+ System.exit(0);
+ }
+
+ /** simple sample implementation of a clients XLinguServiceEventListener
+ * interface implementation
+ */
+ public 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 recieved (e.g. trigger background spellchecking
+ //! or hyphenation again.)
+
+ System.out.println("Listener called");
+ }
+ };
+
+}
+
diff --git a/odk/examples/DevelopersGuide/OfficeDev/Linguistic/Makefile b/odk/examples/DevelopersGuide/OfficeDev/Linguistic/Makefile
new file mode 100644
index 000000000000..c2ac5900e862
--- /dev/null
+++ b/odk/examples/DevelopersGuide/OfficeDev/Linguistic/Makefile
@@ -0,0 +1,237 @@
+#*************************************************************************
+#
+# 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
+include $(SETTINGS)/dk.mk
+
+# Define non-platform/compiler specific settings
+EXAMPLE_NAME=OfficeDevLinguisticExample
+OUT_COMP_CLASS = $(OUT_CLASS)/$(EXAMPLE_NAME)
+
+COMPONENT1_NAME=SampleHyphenator
+COMPONENT1_PACKAGE = $(OUT_BIN)/$(COMPONENT1_NAME).$(UNOOXT_EXT)
+COMPONENT1_PACKAGE_URL = $(subst \\,\,"$(COMP_PACKAGE_DIR)$(PS)$(COMPONENT1_NAME).$(UNOOXT_EXT)")
+COMPONENT1_JAR_NAME = $(COMPONENT1_NAME).uno.jar
+COMPONENT1_JAR = $(OUT_COMP_CLASS)/$(COMPONENT1_JAR_NAME)
+COMPONENT1_MANIFESTFILE = $(OUT_COMP_CLASS)/$(COMPONENT1_NAME).uno.Manifest
+COMPONENT1_UNOPKG_MANIFEST = $(OUT_COMP_CLASS)/$(COMPONENT1_NAME)/META-INF/manifest.xml
+
+COMPONENT2_NAME=SampleSpellChecker
+COMPONENT2_PACKAGE = $(OUT_BIN)/$(COMPONENT2_NAME).$(UNOOXT_EXT)
+COMPONENT2_PACKAGE_URL = $(subst \\,\,"$(COMP_PACKAGE_DIR)$(PS)$(COMPONENT2_NAME).$(UNOOXT_EXT)")
+COMPONENT2_JAR_NAME = $(COMPONENT2_NAME).uno.jar
+COMPONENT2_JAR = $(OUT_COMP_CLASS)/$(COMPONENT2_JAR_NAME)
+COMPONENT2_MANIFESTFILE = $(OUT_COMP_CLASS)/$(COMPONENT2_NAME).uno.Manifest
+COMPONENT2_UNOPKG_MANIFEST = $(OUT_COMP_CLASS)/$(COMPONENT2_NAME)/META-INF/manifest.xml
+
+COMPONENT3_NAME=SampleThesaurus
+COMPONENT3_PACKAGE = $(OUT_BIN)/$(COMPONENT3_NAME).$(UNOOXT_EXT)
+COMPONENT3_PACKAGE_URL = $(subst \\,\,"$(COMP_PACKAGE_DIR)$(PS)$(COMPONENT3_NAME).$(UNOOXT_EXT)")
+COMPONENT3_JAR_NAME = $(COMPONENT3_NAME).uno.jar
+COMPONENT3_JAR = $(OUT_COMP_CLASS)/$(COMPONENT3_JAR_NAME)
+COMPONENT3_MANIFESTFILE = $(OUT_COMP_CLASS)/$(COMPONENT3_NAME).uno.Manifest
+COMPONENT3_UNOPKG_MANIFEST = $(OUT_COMP_CLASS)/$(COMPONENT3_NAME)/META-INF/manifest.xml
+
+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))
+
+$(COMPONENT1_NAME)_CLASSFILES = XHyphenatedWord_impl.class \
+ XPossibleHyphens_impl.class \
+ PropChgHelper.class \
+ PropChgHelper_Hyph.class \
+ OneInstanceFactory.class \
+ $(COMPONENT1_NAME).class
+
+$(COMPONENT2_NAME)_CLASSFILES = XSpellAlternatives_impl.class \
+ PropChgHelper_Spell.class \
+ PropChgHelper.class \
+ OneInstanceFactory.class \
+ $(COMPONENT2_NAME).class
+
+$(COMPONENT3_NAME)_CLASSFILES = XMeaning_impl.class \
+ OneInstanceFactory.class \
+ $(COMPONENT3_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
+
+#$(OUT_COMP_CLASS)/%.jar : $(OUT_COMP_CLASS)/%.Manifest $(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.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) >> $@
+
+#$(OUT_BIN)/%.uno.pkg : $(OUT_COMP_CLASS)/%.uno.jar $(OUT_COMP_CLASS)/%/META-INF/manifest.xml
+# -$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
+# -$(MKDIR) $(subst /,$(PS),$(@D))
+# cd $(subst /,$(PS),$(OUT_COMP_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
+
+$(COMPONENT1_JAR) : $(COMPONENT1_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)
+
+$(COMPONENT1_PACKAGE) : $(COMPONENT1_JAR) $(COMPONENT1_UNOPKG_MANIFEST)
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ cd $(subst /,$(PS),$(OUT_COMP_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
+
+$(COMPONENT2_JAR) : $(COMPONENT2_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)
+
+$(COMPONENT2_PACKAGE) : $(COMPONENT2_JAR) $(COMPONENT2_UNOPKG_MANIFEST)
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ cd $(subst /,$(PS),$(OUT_COMP_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
+
+$(COMPONENT3_JAR) : $(COMPONENT3_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)
+
+$(COMPONENT3_PACKAGE) : $(COMPONENT3_JAR) $(COMPONENT3_UNOPKG_MANIFEST)
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ cd $(subst /,$(PS),$(OUT_COMP_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) : $(COMPONENT1_PACKAGE) $(COMPONENT2_PACKAGE) $(COMPONENT3_PACKAGE)
+ifeq "$(SDK_AUTO_DEPLOYMENT)" "YES"
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
+ $(DEPLOYTOOL) $(COMPONENT1_PACKAGE_URL)
+ $(DEPLOYTOOL) $(COMPONENT2_PACKAGE_URL)
+ $(DEPLOYTOOL) $(COMPONENT3_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)$(COMPONENT1_NAME)$(QM)",
+ @echo "$(QM)$(COMPONENT2_NAME)$(QM)" and "$(QM)$(COMPONENT3_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),$(COMPONENT1_PACKAGE_URL)))
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$(COMPONENT2_PACKAGE_URL)))
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$(COMPONENT3_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 000000000000..9b2a22403caa
--- /dev/null
+++ b/odk/examples/DevelopersGuide/OfficeDev/Linguistic/OneInstanceFactory.java
@@ -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.
+ *
+ *************************************************************************/
+
+import com.sun.star.lang.XSingleServiceFactory;
+import com.sun.star.lang.XServiceInfo;
+import com.sun.star.lang.XInitialization;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.beans.XPropertySet;
+import com.sun.star.uno.XInterface;
+import com.sun.star.uno.Any;
+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
+ XSingleServiceFactory,
+ XServiceInfo
+{
+ Class aMyClass;
+ String aSvcImplName;
+ String[] aSupportedSvcNames;
+ XInterface xInstantiatedService;
+ XMultiServiceFactory xMultiFactory;
+
+ public OneInstanceFactory(
+ Class aMyClass,
+ String aSvcImplName,
+ String[] aSupportedSvcNames,
+ XMultiServiceFactory xMultiFactory )
+ {
+ this.aMyClass = aMyClass;
+ this.aSvcImplName = aSvcImplName;
+ this.aSupportedSvcNames = aSupportedSvcNames;
+ this.xMultiFactory = xMultiFactory;
+ xInstantiatedService = null;
+ }
+
+ //**********************
+ // XSingleServiceFactory
+ //**********************
+ public Object createInstance()
+ 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 = (XInitialization) UnoRuntime.queryInterface(
+ XInitialization.class, createInstance());
+ if (xIni != null)
+ {
+ Object[] aArguments = new Object[]{ null, null };
+ if (xMultiFactory != null)
+ {
+ XPropertySet xPropSet = (XPropertySet) UnoRuntime.queryInterface(
+ XPropertySet.class , xMultiFactory.createInstance(
+ "com.sun.star.linguistic2.LinguProperties" ) );
+ aArguments[0] = xPropSet;
+ }
+ xIni.initialize( aArguments );
+ }
+ }
+ return xInstantiatedService;
+ }
+
+ public Object createInstanceWithArguments( Object[] aArguments )
+ throws com.sun.star.uno.Exception,
+ com.sun.star.uno.RuntimeException
+ {
+ if (xInstantiatedService == null)
+ {
+ XInitialization xIni = (XInitialization) UnoRuntime.queryInterface(
+ XInitialization.class, createInstance());
+ 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;
+ }
+};
+
diff --git a/odk/examples/DevelopersGuide/OfficeDev/Linguistic/PropChgHelper.java b/odk/examples/DevelopersGuide/OfficeDev/Linguistic/PropChgHelper.java
new file mode 100644
index 000000000000..87b1ea3b5b3b
--- /dev/null
+++ b/odk/examples/DevelopersGuide/OfficeDev/Linguistic/PropChgHelper.java
@@ -0,0 +1,194 @@
+/*************************************************************************
+ *
+ * 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
+{
+ XInterface xEvtSource;
+ String[] aPropNames;
+ XPropertySet xPropSet;
+ ArrayList aLngSvcEvtListeners;
+
+ public PropChgHelper(
+ XInterface xEvtSource,
+ String[] aPropNames )
+ {
+ this.xEvtSource = xEvtSource;
+ this.aPropNames = aPropNames;
+ xPropSet = null;
+ aLngSvcEvtListeners = new ArrayList();
+ }
+
+ public XInterface GetEvtSource()
+ {
+ return xEvtSource;
+ }
+
+ public XPropertySet GetPropSet()
+ {
+ return xPropSet;
+ }
+
+ public String[] GetPropNames()
+ {
+ return aPropNames;
+ }
+
+ public void LaunchEvent( LinguServiceEvent aEvt )
+ {
+ int nCnt = aLngSvcEvtListeners.size();
+ for (int i = 0; i < nCnt; ++i)
+ {
+ XLinguServiceEventListener xLstnr =
+ (XLinguServiceEventListener) 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], (XPropertyChangeListener) this );
+ }
+ catch( Exception e ) {
+ }
+ }
+ }
+ }
+ }
+
+ public 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], (XPropertyChangeListener) 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 overloaded 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;
+ }
+};
+
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 000000000000..00d67df8485a
--- /dev/null
+++ b/odk/examples/DevelopersGuide/OfficeDev/Linguistic/PropChgHelper_Hyph.java
@@ -0,0 +1,86 @@
+/*************************************************************************
+ *
+ * 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.linguistic2.LinguServiceEventFlags;
+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 com.sun.star.uno.UnoRuntime;
+
+import java.util.ArrayList;
+
+public class PropChgHelper_Hyph extends PropChgHelper
+{
+ public PropChgHelper_Hyph(
+ XInterface xEvtSource,
+ String[] aPropNames )
+ {
+ super( xEvtSource, aPropNames );
+ }
+
+ //************************
+ // XPropertyChangeListener
+ //************************
+ 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 );
+ }
+ }
+ }
+};
+
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 000000000000..d399e13477e1
--- /dev/null
+++ b/odk/examples/DevelopersGuide/OfficeDev/Linguistic/PropChgHelper_Spell.java
@@ -0,0 +1,110 @@
+/*************************************************************************
+ *
+ * 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.linguistic2.LinguServiceEventFlags;
+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 com.sun.star.uno.UnoRuntime;
+
+import java.util.ArrayList;
+
+public class PropChgHelper_Spell extends PropChgHelper
+{
+ public PropChgHelper_Spell(
+ XInterface xEvtSource,
+ String[] aPropNames )
+ {
+ super( xEvtSource, aPropNames );
+ }
+
+ //************************
+ // XPropertyChangeListener
+ //************************
+ 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 = false == bVal; // FALSE->TRUE change?
+ bSWWA = !bSCWA; // TRUE->FALSE change?
+ }
+ else if (aEvt.PropertyName.equals( "IsSpellWithDigits" ))
+ {
+ bSCWA = false == bVal; // FALSE->TRUE change?
+ bSWWA = !bSCWA; // TRUE->FALSE change?
+ }
+ else if (aEvt.PropertyName.equals( "IsSpellCapitalization" ))
+ {
+ bSCWA = false == 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 );
+ }
+ }
+ }
+};
+
diff --git a/odk/examples/DevelopersGuide/OfficeDev/Linguistic/SampleHyphenator.java b/odk/examples/DevelopersGuide/OfficeDev/Linguistic/SampleHyphenator.java
new file mode 100644
index 000000000000..adad109f9a87
--- /dev/null
+++ b/odk/examples/DevelopersGuide/OfficeDev/Linguistic/SampleHyphenator.java
@@ -0,0 +1,548 @@
+/*************************************************************************
+ *
+ * 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.XMultiServiceFactory;
+import com.sun.star.lang.XSingleServiceFactory;
+
+// 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.XComponent;
+import com.sun.star.lang.XServiceInfo;
+import com.sun.star.lang.XServiceDisplayName;
+
+// Exceptions
+import com.sun.star.uno.Exception;
+import com.sun.star.uno.RuntimeException;
+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.lang.XEventListener;
+import com.sun.star.lang.EventObject;
+import com.sun.star.beans.XPropertySet;
+import com.sun.star.beans.PropertyValue;
+import com.sun.star.uno.AnyConverter;
+import com.sun.star.lang.XTypeProvider;
+import com.sun.star.uno.XInterface;
+import com.sun.star.uno.Type;
+
+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( (XHyphenator) this, aProps );
+ aEvtListeners = new ArrayList();;
+ 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 = (XPropertySet)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 = "com.sun.star.linguistic2.JavaSamples.SampleHyphenator";
+
+ 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>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 aImplName,
+ XMultiServiceFactory xMultiFactory,
+ com.sun.star.registry.XRegistryKey xRegKey )
+ {
+ XSingleServiceFactory xSingleServiceFactory = null;
+ if( aImplName.equals( _aSvcImplName ) )
+ {
+ xSingleServiceFactory = new OneInstanceFactory(
+ SampleHyphenator.class, _aSvcImplName,
+ getSupportedServiceNames_Static(),
+ xMultiFactory );
+ }
+ return xSingleServiceFactory;
+ }
+
+ /**
+ * Writes the service information into the given registry key.
+ * This method is called by the <code>JavaLoader</code>
+ * <p>
+ * @return returns true if the operation succeeded
+ * @param xRegKey the registryKey
+ * @see com.sun.star.comp.loader.JavaLoader
+ */
+ public static boolean __writeRegistryServiceInfo(
+ com.sun.star.registry.XRegistryKey xRegKey )
+ {
+ boolean bResult = true;
+ String[] aServices = getSupportedServiceNames_Static();
+ int i, nLength = aServices.length;
+ for( i = 0; i < nLength; ++i )
+ {
+ bResult = bResult && com.sun.star.comp.loader.FactoryHelper.writeRegistryServiceInfo(
+ _aSvcImplName, aServices[i], xRegKey );
+ }
+ return bResult;
+ }
+}
+
diff --git a/odk/examples/DevelopersGuide/OfficeDev/Linguistic/SampleSpellChecker.java b/odk/examples/DevelopersGuide/OfficeDev/Linguistic/SampleSpellChecker.java
new file mode 100644
index 000000000000..9e2cd5a81853
--- /dev/null
+++ b/odk/examples/DevelopersGuide/OfficeDev/Linguistic/SampleSpellChecker.java
@@ -0,0 +1,491 @@
+/*************************************************************************
+ *
+ * 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.XMultiServiceFactory;
+import com.sun.star.lang.XSingleServiceFactory;
+
+// 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.XComponent;
+import com.sun.star.lang.XServiceInfo;
+import com.sun.star.lang.XServiceDisplayName;
+
+// Exceptions
+import com.sun.star.uno.Exception;
+import com.sun.star.uno.RuntimeException;
+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.lang.XEventListener;
+import com.sun.star.lang.EventObject;
+import com.sun.star.beans.XPropertySet;
+import com.sun.star.beans.PropertyValue;
+import com.sun.star.uno.AnyConverter;
+import com.sun.star.lang.XTypeProvider;
+import com.sun.star.uno.XInterface;
+import com.sun.star.uno.Type;
+
+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( (XSpellChecker) this, aProps );
+ aEvtListeners = new ArrayList();
+ 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 = (XPropertySet)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 = "com.sun.star.linguistic2.JavaSamples.SampleSpellChecker";
+
+ 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>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 aImplName,
+ XMultiServiceFactory xMultiFactory,
+ com.sun.star.registry.XRegistryKey xRegKey )
+ {
+ XSingleServiceFactory xSingleServiceFactory = null;
+ if( aImplName.equals( _aSvcImplName ) )
+ {
+ xSingleServiceFactory = new OneInstanceFactory(
+ SampleSpellChecker.class, _aSvcImplName,
+ getSupportedServiceNames_Static(),
+ xMultiFactory );
+ }
+ return xSingleServiceFactory;
+ }
+
+ /**
+ * Writes the service information into the given registry key.
+ * This method is called by the <code>JavaLoader</code>
+ * <p>
+ * @return returns true if the operation succeeded
+ * @param xRegKey the registryKey
+ * @see com.sun.star.comp.loader.JavaLoader
+ */
+ public static boolean __writeRegistryServiceInfo(
+ com.sun.star.registry.XRegistryKey xRegKey )
+ {
+ boolean bResult = true;
+ String[] aServices = getSupportedServiceNames_Static();
+ int i, nLength = aServices.length;
+ for( i = 0; i < nLength; ++i )
+ {
+ bResult = bResult && com.sun.star.comp.loader.FactoryHelper.writeRegistryServiceInfo(
+ _aSvcImplName, aServices[i], xRegKey );
+ }
+ return bResult;
+ }
+}
+
diff --git a/odk/examples/DevelopersGuide/OfficeDev/Linguistic/SampleThesaurus.java b/odk/examples/DevelopersGuide/OfficeDev/Linguistic/SampleThesaurus.java
new file mode 100644
index 000000000000..7e5bbb1bf442
--- /dev/null
+++ b/odk/examples/DevelopersGuide/OfficeDev/Linguistic/SampleThesaurus.java
@@ -0,0 +1,328 @@
+/*************************************************************************
+ *
+ * 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.XMultiServiceFactory;
+import com.sun.star.lang.XSingleServiceFactory;
+
+// supported Interfaces
+import com.sun.star.linguistic2.XThesaurus;
+import com.sun.star.lang.XInitialization;
+import com.sun.star.lang.XComponent;
+import com.sun.star.lang.XServiceInfo;
+import com.sun.star.lang.XServiceDisplayName;
+
+// Exceptions
+import com.sun.star.uno.Exception;
+import com.sun.star.uno.RuntimeException;
+import com.sun.star.lang.IllegalArgumentException;
+
+//used Interfaces
+import com.sun.star.linguistic2.XMeaning;
+import com.sun.star.lang.Locale;
+import com.sun.star.lang.XEventListener;
+import com.sun.star.lang.EventObject;
+import com.sun.star.beans.XPropertySet;
+import com.sun.star.beans.PropertyValue;
+import com.sun.star.uno.AnyConverter;
+import com.sun.star.lang.XTypeProvider;
+import com.sun.star.uno.Type;
+
+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 it's lifetime) since it gets used in the
+ // 'GetValueToUse' function
+ aPropChgHelper = new PropChgHelper( (XThesaurus) this, aProps );
+
+ aEvtListeners = new ArrayList();
+ 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 = (XPropertySet)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 = "com.sun.star.linguistic2.JavaSamples.SampleThesaurus";
+
+ 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>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 aImplName,
+ XMultiServiceFactory xMultiFactory,
+ com.sun.star.registry.XRegistryKey xRegKey )
+ {
+ XSingleServiceFactory xSingleServiceFactory = null;
+ if( aImplName.equals( _aSvcImplName ) )
+ {
+ xSingleServiceFactory = new OneInstanceFactory(
+ SampleThesaurus.class, _aSvcImplName,
+ getSupportedServiceNames_Static(),
+ xMultiFactory );
+ }
+ return xSingleServiceFactory;
+ }
+
+ /**
+ * Writes the service information into the given registry key.
+ * This method is called by the <code>JavaLoader</code>
+ * <p>
+ * @return returns true if the operation succeeded
+ * @param xRegKey the registryKey
+ * @see com.sun.star.comp.loader.JavaLoader
+ */
+ public static boolean __writeRegistryServiceInfo(
+ com.sun.star.registry.XRegistryKey xRegKey )
+ {
+ boolean bResult = true;
+ String[] aServices = getSupportedServiceNames_Static();
+ int i, nLength = aServices.length;
+ for( i = 0; i < nLength; ++i )
+ {
+ bResult = bResult && com.sun.star.comp.loader.FactoryHelper.writeRegistryServiceInfo(
+ _aSvcImplName, aServices[i], xRegKey );
+ }
+ return bResult;
+ }
+}
+
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 000000000000..47405dd38a89
--- /dev/null
+++ b/odk/examples/DevelopersGuide/OfficeDev/Linguistic/XHyphenatedWord_impl.java
@@ -0,0 +1,97 @@
+/*************************************************************************
+ *
+ * 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
+{
+ String aWord;
+ String aHyphenatedWord;
+ short nHyphenPos;
+ short nHyphenationPos;
+ Locale aLang;
+ 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 = new String();
+ if (this.aLang == null)
+ this.aLang = new Locale();
+ if (this.aHyphenatedWord == null)
+ this.aHyphenatedWord = new String();
+ }
+
+
+ // 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;
+ }
+};
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 000000000000..b1fc2e1ea710
--- /dev/null
+++ b/odk/examples/DevelopersGuide/OfficeDev/Linguistic/XMeaning_impl.java
@@ -0,0 +1,69 @@
+/*************************************************************************
+ *
+ * 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 XMeaning_impl implements
+ com.sun.star.linguistic2.XMeaning
+{
+ String aMeaning;
+ 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 = new String();
+
+ // 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;
+ }
+};
+
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 000000000000..dce63f8d8ec9
--- /dev/null
+++ b/odk/examples/DevelopersGuide/OfficeDev/Linguistic/XPossibleHyphens_impl.java
@@ -0,0 +1,89 @@
+/*************************************************************************
+ *
+ * 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
+{
+ String aWord;
+ String aHyphWord;
+ short[] aOrigHyphenPos;
+ 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 = new String();
+ if (this.aLang == null)
+ this.aLang = new Locale();
+ if (this.aHyphWord == null)
+ this.aHyphWord = new String();
+
+ // 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;
+ }
+};
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 000000000000..0c3cdd0bf89e
--- /dev/null
+++ b/odk/examples/DevelopersGuide/OfficeDev/Linguistic/XSpellAlternatives_impl.java
@@ -0,0 +1,92 @@
+/*************************************************************************
+ *
+ * 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
+{
+ String aWord;
+ Locale aLanguage;
+ String[] aAlt; // list of alternatives, may be empty.
+ 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 = new String();
+ 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;
+ }
+};
+
diff --git a/odk/examples/DevelopersGuide/OfficeDev/Makefile b/odk/examples/DevelopersGuide/OfficeDev/Makefile
new file mode 100644
index 000000000000..17b4eafc3d69
--- /dev/null
+++ b/odk/examples/DevelopersGuide/OfficeDev/Makefile
@@ -0,0 +1,106 @@
+#*************************************************************************
+#
+# 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
+include $(SETTINGS)/dk.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 000000000000..71ec62d69098
--- /dev/null
+++ b/odk/examples/DevelopersGuide/OfficeDev/MenuElement.java
@@ -0,0 +1,56 @@
+/*************************************************************************
+ *
+ * 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.XServiceInfo;
+import com.sun.star.uno.UnoRuntime;
+
+// A helper class to determine the menu element type
+public class MenuElement
+{
+ static public boolean IsMenuEntry( com.sun.star.beans.XPropertySet xMenuElement ) {
+ com.sun.star.lang.XServiceInfo xServiceInfo =
+ (com.sun.star.lang.XServiceInfo)UnoRuntime.queryInterface(
+ com.sun.star.lang.XServiceInfo.class, xMenuElement );
+
+ return xServiceInfo.supportsService( "com.sun.star.ui.ActionTrigger" );
+ }
+
+ static public boolean IsMenuSeparator( com.sun.star.beans.XPropertySet xMenuElement ) {
+ com.sun.star.lang.XServiceInfo xServiceInfo =
+ (com.sun.star.lang.XServiceInfo)UnoRuntime.queryInterface(
+ com.sun.star.lang.XServiceInfo.class, xMenuElement );
+
+ return xServiceInfo.supportsService( "com.sun.star.ui.ActionTriggerSeparator" );
+ }
+}
diff --git a/odk/examples/DevelopersGuide/OfficeDev/Number_Formats.java b/odk/examples/DevelopersGuide/OfficeDev/Number_Formats.java
new file mode 100644
index 000000000000..de05e4caa2f1
--- /dev/null
+++ b/odk/examples/DevelopersGuide/OfficeDev/Number_Formats.java
@@ -0,0 +1,253 @@
+/*************************************************************************
+ *
+ * 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.
+ @author Eike Rathke
+ */
+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 =
+ (com.sun.star.util.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 =
+ (com.sun.star.util.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 =
+ (com.sun.star.beans.XPropertySet)
+ UnoRuntime.queryInterface(
+ com.sun.star.beans.XPropertySet.class, xCellRange );
+
+ // Set number format to default currency
+ xCellProp.setPropertyValue( "NumberFormat", new Integer(nCurrencyKey) );
+
+ // Get cell B3
+ com.sun.star.table.XCell xCell = maSheet.getCellByPosition( 1, 2 );
+
+ // Query the property set of the cell
+ xCellProp = (com.sun.star.beans.XPropertySet)
+ 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", new Integer(nIndexKey) );
+
+
+ // Set column containing the example values to optimal width to show
+ // the new format of cell B3
+ com.sun.star.table.XColumnRowRange xColRowRange =
+ (com.sun.star.table.XColumnRowRange)
+ UnoRuntime.queryInterface(com.sun.star.table.XColumnRowRange.class,
+ maSheet);
+
+ com.sun.star.container.XIndexAccess xIndexAccess =
+ (com.sun.star.container.XIndexAccess)
+ UnoRuntime.queryInterface(com.sun.star.container.XIndexAccess.class,
+ xColRowRange.getColumns());
+
+ com.sun.star.beans.XPropertySet xColPropSet =
+ (com.sun.star.beans.XPropertySet)
+ UnoRuntime.queryInterface(com.sun.star.beans.XPropertySet.class,
+ xIndexAccess.getByIndex(1));
+
+ xColPropSet.setPropertyValue( "OptimalWidth", new Boolean(true) );
+ }
+
+ // ____________________
+
+ public Number_Formats( String[] args ) throws java.lang.Exception
+ {
+ // get the remote office context. If necessary a new office
+ // process is started
+ maOfficeContext = com.sun.star.comp.helper.Bootstrap.bootstrap();
+ System.out.println("Connected to a running office ...");
+ maServiceManager = maOfficeContext.getServiceManager();
+
+ // create a new spreadsheet document
+ XComponentLoader aLoader = (XComponentLoader) UnoRuntime.queryInterface(
+ XComponentLoader.class, maServiceManager.createInstanceWithContext(
+ "com.sun.star.frame.Desktop", maOfficeContext) );
+
+ maSpreadsheetDoc = (XSpreadsheetDocument) 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 String msDataSheetName = "Data";
+
+ private XComponentContext maOfficeContext;
+ private XMultiComponentFactory maServiceManager;
+ private 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 = (XIndexAccess) UnoRuntime.queryInterface( XIndexAccess.class, aSheets );
+ maSheet = (XSpreadsheet) 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( (double) iCounter );
+ }
+ }
+ catch( Exception ex )
+ {
+ System.err.println( "Couldn't initialize Spreadsheet Document: " + ex );
+ ex.printStackTrace();
+ bOk = false;
+ }
+ return bOk;
+ }
+}
diff --git a/odk/examples/DevelopersGuide/OfficeDev/OfficeConnect.java b/odk/examples/DevelopersGuide/OfficeDev/OfficeConnect.java
new file mode 100644
index 000000000000..7f0bd79b99e4
--- /dev/null
+++ b/odk/examples/DevelopersGuide/OfficeDev/OfficeConnect.java
@@ -0,0 +1,184 @@
+/*************************************************************************
+ *
+ * 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 __________
+
+// structs, const, ...
+import com.sun.star.beans.PropertyValue;
+import com.sun.star.bridge.XUnoUrlResolver;
+
+// exceptions
+import com.sun.star.container.NoSuchElementException;
+
+// interfaces
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.uno.Any;
+import com.sun.star.uno.Exception;
+
+import com.sun.star.uno.UnoRuntime;
+
+// others
+import java.lang.String;
+
+// __________ Implementation __________
+
+/**
+ * support ONE singleton uno connection to an 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.
+ *
+ * @author Andreas Schl&uuml;ns
+ * @created 7. Februar 2002
+ * @modified 05.02.2002 12:10
+ */
+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;
+ }
+
+ // ____________________
+
+ public static synchronized OfficeConnect getConnection()
+ {
+ 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 informations
+ */
+ 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 proccess 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 automaticly.
+ * @param sServiceSpecifier name of service which should be created
+ * @return Description of the Returned Value
+ */
+ public Object createRemoteInstance(Class aType, String sServiceSpecifier)
+ {
+ Object 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;
+ }
+
+ // ____________________
+
+ /**
+ * same as "createRemoteInstance()" but supports additional parameter for initializing created object
+ *
+ * @param lArguments optional arguments
+ * They are used to initialize new created service.
+ * @param aType Description of Parameter
+ * @param sServiceSpecifier Description of Parameter
+ * @return Description of the Returned Value
+ */
+ public Object createRemoteInstanceWithArguments(Class aType, String sServiceSpecifier, Any[] lArguments)
+ {
+ Object aResult = null;
+ try
+ {
+ aResult = UnoRuntime.queryInterface(
+ aType, mxServiceManager.createInstanceWithArgumentsAndContext(
+ sServiceSpecifier, lArguments, 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 com.sun.star.uno.XComponentContext mxOfficeContext;
+ // reference to remote service manager
+ private com.sun.star.lang.XMultiComponentFactory mxServiceManager;
+}
+
diff --git a/odk/examples/DevelopersGuide/OfficeDev/PathSettings/Makefile b/odk/examples/DevelopersGuide/OfficeDev/PathSettings/Makefile
new file mode 100644
index 000000000000..663468b74d4c
--- /dev/null
+++ b/odk/examples/DevelopersGuide/OfficeDev/PathSettings/Makefile
@@ -0,0 +1,92 @@
+#*************************************************************************
+#
+# 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
+include $(SETTINGS)/dk.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 000000000000..9aaeadc74f79
--- /dev/null
+++ b/odk/examples/DevelopersGuide/OfficeDev/PathSettings/PathSettingsTest.java
@@ -0,0 +1,168 @@
+/*************************************************************************
+ *
+ * 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;
+import com.sun.star.beans.PropertyValue;
+import com.sun.star.beans.UnknownPropertyException;
+
+/*
+ *
+ * @author Carsten Driesner
+ * Provides example code how to access and use the
+ * path pathsettings servce.
+ */
+public class PathSettingsTest extends java.lang.Object {
+
+ /*
+ * 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;
+ XMultiComponentFactory xRemoteServiceManager = 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 ...");
+ xRemoteServiceManager = xRemoteContext.getServiceManager();
+
+ Object pathSubst = xRemoteServiceManager.createInstanceWithContext(
+ "com.sun.star.comp.framework.PathSettings", xRemoteContext );
+ xPathSettingsService = (XPropertySet)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 modfiy 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");
+ }
+ }
+ }
+}
diff --git a/odk/examples/DevelopersGuide/OfficeDev/PathSubstitution/Makefile b/odk/examples/DevelopersGuide/OfficeDev/PathSubstitution/Makefile
new file mode 100644
index 000000000000..19dabe19b33e
--- /dev/null
+++ b/odk/examples/DevelopersGuide/OfficeDev/PathSubstitution/Makefile
@@ -0,0 +1,92 @@
+#*************************************************************************
+#
+# 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
+include $(SETTINGS)/dk.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 000000000000..26faedd97da9
--- /dev/null
+++ b/odk/examples/DevelopersGuide/OfficeDev/PathSubstitution/PathSubstitutionTest.java
@@ -0,0 +1,119 @@
+/*************************************************************************
+ *
+ * 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;
+import com.sun.star.beans.PropertyValue;
+
+import com.sun.star.util.XStringSubstitution;
+
+/*
+ * @author Carsten Driesner
+ */
+public class PathSubstitutionTest extends java.lang.Object {
+
+ /*
+ * List of pre-defined path variables supported by
+ * the path substitution service.
+ */
+ private static String[] predefinedPathVariables = {
+ "$(home)","$(inst)","$(prog)","$(temp)","$(user)",
+ "$(work)","$(path)","$(lang)","$(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 = (XStringSubstitution)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]);
+ }
+ }
+ }
+}
diff --git a/odk/examples/DevelopersGuide/OfficeDev/TerminationTest/Makefile b/odk/examples/DevelopersGuide/OfficeDev/TerminationTest/Makefile
new file mode 100644
index 000000000000..babc895e3265
--- /dev/null
+++ b/odk/examples/DevelopersGuide/OfficeDev/TerminationTest/Makefile
@@ -0,0 +1,97 @@
+#*************************************************************************
+#
+# 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
+include $(SETTINGS)/dk.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 000000000000..65343e967c69
--- /dev/null
+++ b/odk/examples/DevelopersGuide/OfficeDev/TerminationTest/TerminateListener.java
@@ -0,0 +1,60 @@
+/*************************************************************************
+ *
+ * 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;
+
+/**
+ *
+ * @author dschulten
+ */
+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() == true) {
+ 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) {
+ }
+}
diff --git a/odk/examples/DevelopersGuide/OfficeDev/TerminationTest/TerminationTest.java b/odk/examples/DevelopersGuide/OfficeDev/TerminationTest/TerminationTest.java
new file mode 100644
index 000000000000..8c0a0c556cbe
--- /dev/null
+++ b/odk/examples/DevelopersGuide/OfficeDev/TerminationTest/TerminationTest.java
@@ -0,0 +1,101 @@
+/*************************************************************************
+ *
+ * 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;
+
+/**
+ *
+ * @author dschulten
+ */
+public class TerminationTest extends java.lang.Object {
+
+ 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 = (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 == true ?
+ "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 == true ?
+ "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;
+ }
+
+}
diff --git a/odk/examples/DevelopersGuide/OfficeDev/makefile.mk b/odk/examples/DevelopersGuide/OfficeDev/makefile.mk
new file mode 100644
index 000000000000..f2ffe0cd1ac2
--- /dev/null
+++ b/odk/examples/DevelopersGuide/OfficeDev/makefile.mk
@@ -0,0 +1,180 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ=..$/..$/..
+PRJNAME=odk
+TARGET=copying
+
+#----------------------------------------------------------------
+.INCLUDE: settings.mk
+.INCLUDE: $(PRJ)$/util$/makefile.pmk
+#----------------------------------------------------------------
+
+#----------------------------------------------------
+# this makefile is only used for copying the example
+# files into the SDK
+#----------------------------------------------------
+
+
+OFFICEDEV_FILES=\
+ $(DESTDIRDEVGUIDEEXAMPLES)$/OfficeDev$/ContextMenuInterceptor.java \
+ $(DESTDIRDEVGUIDEEXAMPLES)$/OfficeDev$/Makefile \
+ $(DESTDIRDEVGUIDEEXAMPLES)$/OfficeDev$/MenuElement.java \
+ $(DESTDIRDEVGUIDEEXAMPLES)$/OfficeDev$/Number_Formats.java \
+ $(DESTDIRDEVGUIDEEXAMPLES)$/OfficeDev$/OfficeConnect.java
+
+DESTCLIPBOARD=$(DESTDIRDEVGUIDEEXAMPLES)$/OfficeDev$/Clipboard
+CLIPBOARD_FILES=\
+ $(DESTCLIPBOARD)$/Clipboard.java \
+ $(DESTCLIPBOARD)$/ClipboardListener.java \
+ $(DESTCLIPBOARD)$/ClipboardOwner.java \
+ $(DESTCLIPBOARD)$/Makefile \
+ $(DESTCLIPBOARD)$/TextTransferable.java
+
+DESTDESKTOPENV=$(DESTDIRDEVGUIDEEXAMPLES)$/OfficeDev$/DesktopEnvironment
+DESKTOPENV_FILES=\
+ $(DESTDESKTOPENV)$/nativelib$/unix$/exports.dxp \
+ $(DESTDESKTOPENV)$/nativelib$/unix$/Makefile \
+ $(DESTDESKTOPENV)$/nativelib$/unix$/nativeview.c \
+ $(DESTDESKTOPENV)$/nativelib$/unix$/nativeview.h \
+ $(DESTDESKTOPENV)$/nativelib$/windows$/exports.dxp \
+ $(DESTDESKTOPENV)$/nativelib$/windows$/Makefile \
+ $(DESTDESKTOPENV)$/nativelib$/windows$/nativeview.c \
+ $(DESTDESKTOPENV)$/nativelib$/windows$/nativeview.h \
+ $(DESTDESKTOPENV)$/CustomizeView.java \
+ $(DESTDESKTOPENV)$/Desk.java \
+ $(DESTDESKTOPENV)$/DocumentView.java \
+ $(DESTDESKTOPENV)$/FunctionHelper.java \
+ $(DESTDESKTOPENV)$/Install.txt \
+ $(DESTDESKTOPENV)$/Interceptor.java \
+ $(DESTDESKTOPENV)$/IOnewayLink.java \
+ $(DESTDESKTOPENV)$/IShutdownListener.java \
+ $(DESTDESKTOPENV)$/JavaWindowPeerFake.java \
+ $(DESTDESKTOPENV)$/Makefile \
+ $(DESTDESKTOPENV)$/NativeView.java \
+ $(DESTDESKTOPENV)$/OfficeConnect.java \
+ $(DESTDESKTOPENV)$/OnewayExecutor.java \
+ $(DESTDESKTOPENV)$/StatusListener.java \
+ $(DESTDESKTOPENV)$/StatusView.java \
+ $(DESTDESKTOPENV)$/ViewContainer.java
+
+DESTASCIIFILTER=$(DESTDIRDEVGUIDEEXAMPLES)$/OfficeDev$/FilterDevelopment$/AsciiFilter
+ASCIIFILTER_FILES=\
+ $(DESTASCIIFILTER)$/AsciiReplaceFilter.java \
+ $(DESTASCIIFILTER)$/FilterOptions.java \
+ $(DESTASCIIFILTER)$/Makefile \
+ $(DESTASCIIFILTER)$/TypeDetection.xcu
+
+DESTFILTERDETECTION=$(DESTDIRDEVGUIDEEXAMPLES)$/OfficeDev$/FilterDevelopment$/FlatXmlFilterDetection
+FILTERDETECTION_FILES=\
+ $(DESTFILTERDETECTION)$/fdcomp.cxx \
+ $(DESTFILTERDETECTION)$/filterdetect.cxx \
+ $(DESTFILTERDETECTION)$/filterdetect.hxx \
+ $(DESTFILTERDETECTION)$/FlatXmlTypeDetection.uno.xml \
+ $(DESTFILTERDETECTION)$/FlatXmlTypeDetection.xcu \
+ $(DESTFILTERDETECTION)$/Makefile
+
+DESTFLATXMLCPP=$(DESTDIRDEVGUIDEEXAMPLES)$/OfficeDev$/FilterDevelopment$/FlatXmlFilter_cpp
+FLATXMLCPP_FILES=\
+ $(DESTFLATXMLCPP)$/FlatXml.cxx \
+ $(DESTFLATXMLCPP)$/FlatXmlFilter_cpp.uno.xml \
+ $(DESTFLATXMLCPP)$/Makefile \
+ $(DESTFLATXMLCPP)$/FlatXmlFilter_cpp.xcu
+
+DESTFLATXMLJAVA=$(DESTDIRDEVGUIDEEXAMPLES)$/OfficeDev$/FilterDevelopment$/FlatXmlFilter_java
+FLATXMLJAVA_FILES=\
+ $(DESTFLATXMLJAVA)$/Makefile \
+ $(DESTFLATXMLJAVA)$/FlatXmlFilter_java.xcu \
+ $(DESTFLATXMLJAVA)$/FlatXml.java
+
+DESTLINGUISTIC=$(DESTDIRDEVGUIDEEXAMPLES)$/OfficeDev$/Linguistic
+LINGUISTIC_FILES=\
+ $(DESTLINGUISTIC)$/LinguisticExamples.java \
+ $(DESTLINGUISTIC)$/Makefile \
+ $(DESTLINGUISTIC)$/OneInstanceFactory.java \
+ $(DESTLINGUISTIC)$/PropChgHelper.java \
+ $(DESTLINGUISTIC)$/PropChgHelper_Hyph.java \
+ $(DESTLINGUISTIC)$/PropChgHelper_Spell.java \
+ $(DESTLINGUISTIC)$/SampleHyphenator.java \
+ $(DESTLINGUISTIC)$/SampleSpellChecker.java \
+ $(DESTLINGUISTIC)$/SampleThesaurus.java \
+ $(DESTLINGUISTIC)$/XHyphenatedWord_impl.java \
+ $(DESTLINGUISTIC)$/XMeaning_impl.java \
+ $(DESTLINGUISTIC)$/XPossibleHyphens_impl.java \
+ $(DESTLINGUISTIC)$/XSpellAlternatives_impl.java
+
+DESTPATHSETTINGS=$(DESTDIRDEVGUIDEEXAMPLES)$/OfficeDev$/PathSettings
+PATHSETTINGS_FILES=\
+ $(DESTPATHSETTINGS)$/Makefile \
+ $(DESTPATHSETTINGS)$/PathSettingsTest.java
+
+DESTPATHSUBSTITUTION=$(DESTDIRDEVGUIDEEXAMPLES)$/OfficeDev$/PathSubstitution
+PATHSUBSTITUTION_FILES=\
+ $(DESTPATHSUBSTITUTION)$/Makefile \
+ $(DESTPATHSUBSTITUTION)$/PathSubstitutionTest.java
+
+DESTTERMINATIONTEST=$(DESTDIRDEVGUIDEEXAMPLES)$/OfficeDev$/TerminationTest
+TERMINATION_FILES=\
+ $(DESTTERMINATIONTEST)$/Makefile \
+ $(DESTTERMINATIONTEST)$/TerminateListener.java \
+ $(DESTTERMINATIONTEST)$/TerminationTest.java
+
+DESTDISABLECOMMANDS=$(DESTDIRDEVGUIDEEXAMPLES)$/OfficeDev$/DisableCommands
+DISABLECOMMANDS_FILES=\
+ $(DESTDISABLECOMMANDS)$/Makefile \
+ $(DESTDISABLECOMMANDS)$/DisableCommandsTest.java
+
+DIR_FILE_LIST= \
+ $(OFFICEDEV_FILES) \
+ $(CLIPBOARD_FILES) \
+ $(DESKTOPENV_FILES) \
+ $(ASCIIFILTER_FILES) \
+ $(FILTERDETECTION_FILES) \
+ $(FLATXMLCPP_FILES) \
+ $(FLATXMLJAVA_FILES) \
+ $(LINGUISTIC_FILES) \
+ $(PATHSETTINGS_FILES) \
+ $(PATHSUBSTITUTION_FILES) \
+ $(TERMINATION_FILES) \
+ $(DISABLECOMMANDS_FILES)
+
+DIR_DIRECTORY_LIST=$(uniq $(DIR_FILE_LIST:d))
+DIR_CREATE_FLAG=$(MISC)$/devguide_officedev_dirs_created.txt
+DIR_FILE_FLAG=$(MISC)$/devguide_officedev.txt
+
+#--------------------------------------------------
+# TARGETS
+#--------------------------------------------------
+all : \
+ $(DIR_FILE_LIST) \
+ $(DIR_FILE_FLAG)
+
+#--------------------------------------------------
+# use global rules
+#--------------------------------------------------
+.INCLUDE: $(PRJ)$/util$/odk_rules.pmk
+
diff --git a/odk/examples/DevelopersGuide/ProfUNO/CppBinding/Makefile b/odk/examples/DevelopersGuide/ProfUNO/CppBinding/Makefile
new file mode 100644
index 000000000000..05880e3acf72
--- /dev/null
+++ b/odk/examples/DevelopersGuide/ProfUNO/CppBinding/Makefile
@@ -0,0 +1,140 @@
+#*************************************************************************
+#
+# 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
+include $(SETTINGS)/dk.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)
+APP1_RDB=$(OUT_BIN)/office_connect.rdb
+APP1_ENV_FLAG = $(SAMPLE_GEN_OUT)/cpp_$(SAMPLE_NAME)_prepare_env.flag
+
+APP2_NAME=string_samples
+APP2_BINARY=$(OUT_BIN)/$(APP2_NAME)$(EXE_EXT)
+
+ifeq "$(OS)" "WIN"
+INI_EXTENSION=.ini
+else
+INI_EXTENSION=rc
+endif
+
+CXXFILES = \
+ office_connect.cxx \
+ string_samples.cxx
+
+# Targets
+.PHONY: ALL
+ALL : \
+ ProUNOCppBindingExample
+
+include $(SETTINGS)/stdtarget.mk
+
+$(OUT_BIN)/%$(INI_EXTENSION) : %$(INI_EXTENSION)
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ $(COPY) $< $(subst /,$(PS),$@)
+
+$(OUT_BIN)/%.rdb :
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ $(REGMERGE) $@ / $(URE_TYPES) $(OFFICE_TYPES)
+
+$(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) $(STLPORTLIB)
+else
+ $(LINK) $(EXE_LINK_FLAGS) $(LINK_LIBS) -o $@ $< \
+ $(CPPUHELPERLIB) $(CPPULIB) $(SALHELPERLIB) $(SALLIB) $(STLPORTLIB) $(STDC++LIB) $(CPPUHELPERDYLIB) $(CPPUDYLIB) $(SALHELPERDYLIB) $(SALDYLIB)
+ifeq "$(OS)" "MACOSX"
+ $(INSTALL_NAME_URELIBS_BIN) $@
+endif
+endif
+
+$(OUT_BIN)/office_connect$(EXE_EXT) : $(APP1_ENV_FLAG) $(OUT_BIN)/office_connect$(INI_EXTENSION) $(SAMPLE_OBJ_OUT)/office_connect.$(OBJ_EXT)
+
+$(OUT_BIN)/string_samples$(EXE_EXT) : $(SAMPLE_OBJ_OUT)/string_samples.$(OBJ_EXT)
+
+$(APP1_ENV_FLAG) : $(APP1_RDB)
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
+ @echo --------------------------------------------------------------------------------
+ @echo Register necessary runtime components in $(APP1_RDB)
+ @echo --------------------------------------------------------------------------------
+ $(REGCOMP) -register -r $(APP1_RDB) -c connector.uno.$(SHAREDLIB_EXT)
+ $(REGCOMP) -register -r $(APP1_RDB) -c remotebridge.uno.$(SHAREDLIB_EXT)
+ $(REGCOMP) -register -r $(APP1_RDB) -c bridgefac.uno.$(SHAREDLIB_EXT)
+ $(REGCOMP) -register -r $(APP1_RDB) -c uuresolver.uno.$(SHAREDLIB_EXT)
+ @echo bla > $@
+
+
+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. Before you run the example 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) $(APP1_NAME).run
+ @echo $(MAKE) $(APP2_NAME).run
+ @echo --------------------------------------------------------------------------------
+
+%.run: $(OUT_BIN)/%$(EXE_EXT)
+ cd $(subst /,$(PS),$(OUT_BIN)) && $(basename $@)
+
+.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 000000000000..5dd69f19d37a
--- /dev/null
+++ b/odk/examples/DevelopersGuide/ProfUNO/CppBinding/office_connect.cxx
@@ -0,0 +1,104 @@
+/*************************************************************************
+ *
+ * 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 rtl;
+using namespace cppu;
+
+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(
+ OUString::createFromAscii("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::createFromAscii(
+ "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 sucessfully 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;
+}
diff --git a/odk/examples/DevelopersGuide/ProfUNO/CppBinding/office_connect.ini b/odk/examples/DevelopersGuide/ProfUNO/CppBinding/office_connect.ini
new file mode 100644
index 000000000000..c10b97b57bd3
--- /dev/null
+++ b/odk/examples/DevelopersGuide/ProfUNO/CppBinding/office_connect.ini
@@ -0,0 +1,2 @@
+UNO_TYPES=$SYSBINDIR/office_connect.rdb
+UNO_SERVICES=$SYSBINDIR/office_connect.rdb \ No newline at end of file
diff --git a/odk/examples/DevelopersGuide/ProfUNO/CppBinding/office_connectrc b/odk/examples/DevelopersGuide/ProfUNO/CppBinding/office_connectrc
new file mode 100644
index 000000000000..ab2c6f10b7e5
--- /dev/null
+++ b/odk/examples/DevelopersGuide/ProfUNO/CppBinding/office_connectrc
@@ -0,0 +1,2 @@
+UNO_TYPES=$SYSBINDIR/office_connect.rdb
+UNO_SERVICES=$SYSBINDIR/office_connect.rdb
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 000000000000..f9d4bf8e79d9
--- /dev/null
+++ b/odk/examples/DevelopersGuide/ProfUNO/CppBinding/string_samples.cxx
@@ -0,0 +1,84 @@
+/*************************************************************************
+ *
+ * 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 <rtl/ustrbuf.hxx>
+#include <rtl/string.hxx>
+
+using rtl::OUString;
+using rtl::OUStringBuffer;
+using rtl::OString;
+
+SAL_IMPLEMENT_MAIN()
+{
+ // string concatination
+
+ sal_Int32 n = 42;
+ double pi = 3.14159;
+
+ // give it an initial size, should be a good guess.
+ // stringbuffer extends if necessary
+ OUStringBuffer buf( 128 );
+
+ // append an ascii string
+ buf.appendAscii( "pi ( here " );
+
+ // numbers can be simply appended
+ buf.append( 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.appendAscii( RTL_CONSTASCII_STRINGPARAM(" ) multiplied with " ) );
+ buf.append( n );
+ buf.appendAscii( RTL_CONSTASCII_STRINGPARAM(" gives ") );
+ buf.append( (double)( n * pi ) );
+ buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( "." ) );
+
+ // 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;
+}
+
diff --git a/odk/examples/DevelopersGuide/ProfUNO/InterprocessConn/ConnectionAwareClient.java b/odk/examples/DevelopersGuide/ProfUNO/InterprocessConn/ConnectionAwareClient.java
new file mode 100644
index 000000000000..5e7d8715c45d
--- /dev/null
+++ b/odk/examples/DevelopersGuide/ProfUNO/InterprocessConn/ConnectionAwareClient.java
@@ -0,0 +1,260 @@
+/*************************************************************************
+ *
+ * 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.uno.XComponentContext;
+import com.sun.star.io.IOException;
+import com.sun.star.connection.XConnector;
+import com.sun.star.connection.XConnection;
+
+import com.sun.star.beans.XPropertySet;
+
+import com.sun.star.lang.XEventListener;
+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 Button _btnWriter,_btnCalc;
+ private Label _txtLabel;
+ private String _url;
+
+ private 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");
+ _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()
+ {
+ 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() );
+ exc.printStackTrace();
+ throw new java.lang.RuntimeException( exc.getMessage() );
+ }
+ }
+
+ /** separtates 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 = (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 = (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 = (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 = ( XMultiComponentFactory )
+ UnoRuntime.queryInterface( XMultiComponentFactory.class, x );
+
+ // retrieve the component context (it's not yet exported from the office)
+ // Query for the XPropertySet interface.
+ XPropertySet xProperySet = ( XPropertySet )
+ 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 =
+ ( XComponentContext ) 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 = ( XComponentLoader )
+ 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 );
+ }
+}
+
diff --git a/odk/examples/DevelopersGuide/ProfUNO/InterprocessConn/Makefile b/odk/examples/DevelopersGuide/ProfUNO/InterprocessConn/Makefile
new file mode 100644
index 000000000000..deaade0b9d81
--- /dev/null
+++ b/odk/examples/DevelopersGuide/ProfUNO/InterprocessConn/Makefile
@@ -0,0 +1,86 @@
+#*************************************************************************
+#
+# 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
+include $(SETTINGS)/dk.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 000000000000..854fbea0580b
--- /dev/null
+++ b/odk/examples/DevelopersGuide/ProfUNO/InterprocessConn/UrlResolver.java
@@ -0,0 +1,111 @@
+/*************************************************************************
+ *
+ * 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.XInterface;
+import com.sun.star.uno.XNamingService;
+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 =
+ (XUnoUrlResolver) 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);
+ }
+ }
+}
diff --git a/odk/examples/DevelopersGuide/ProfUNO/Lifetime/Makefile b/odk/examples/DevelopersGuide/ProfUNO/Lifetime/Makefile
new file mode 100644
index 000000000000..ca4ff8462f32
--- /dev/null
+++ b/odk/examples/DevelopersGuide/ProfUNO/Lifetime/Makefile
@@ -0,0 +1,113 @@
+#*************************************************************************
+#
+# 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
+include $(SETTINGS)/dk.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) $(STLPORTLIB)
+else
+ $(LINK) $(EXE_LINK_FLAGS) $(LINK_LIBS) -o $@ $(OBJFILES) \
+ $(CPPUHELPERLIB) $(CPPULIB) $(SALHELPERLIB) $(SALLIB) $(STLPORTLIB) $(STDC++LIB) $(CPPUHELPERDYLIB) $(CPPUDYLIB) $(SALHELPERDYLIB) $(SALDYLIB)
+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 000000000000..1e2051a5a1b6
--- /dev/null
+++ b/odk/examples/DevelopersGuide/ProfUNO/Lifetime/MyUnoObject.java
@@ -0,0 +1,60 @@
+/*************************************************************************
+ *
+ * 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
+{
+ public MyUnoObject() {}
+
+ protected void finalize() throws Throwable {
+ super.finalize();
+ System.out.println( "finalizer called" );
+ }
+
+ public static void main( String args[] ) throws java.lang.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 dependend, whether the finalizer was called or not
+ }
+}
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 000000000000..ac9d4baa5147
--- /dev/null
+++ b/odk/examples/DevelopersGuide/ProfUNO/Lifetime/object_lifetime.cxx
@@ -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.
+ *
+ *************************************************************************/
+
+#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( char * argv[] )
+{
+ simple_object_creation_and_destruction();
+ return 0;
+}
diff --git a/odk/examples/DevelopersGuide/ProfUNO/SimpleBootstrap_cpp/Makefile b/odk/examples/DevelopersGuide/ProfUNO/SimpleBootstrap_cpp/Makefile
new file mode 100644
index 000000000000..5f2a577ca079
--- /dev/null
+++ b/odk/examples/DevelopersGuide/ProfUNO/SimpleBootstrap_cpp/Makefile
@@ -0,0 +1,101 @@
+#*************************************************************************
+#
+# 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
+include $(SETTINGS)/dk.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) $(STLPORTLIB)
+else
+ $(LINK) $(EXE_LINK_FLAGS) $(LINK_LIBS) -o $@ $< \
+ $(CPPUHELPERLIB) $(CPPULIB) $(SALHELPERLIB) $(SALLIB) $(STLPORTLIB) $(STDC++LIB) $(CPPUHELPERDYLIB) $(CPPUDYLIB) $(SALHELPERDYLIB) $(SALDYLIB)
+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 000000000000..452c5cd112c1
--- /dev/null
+++ b/odk/examples/DevelopersGuide/ProfUNO/SimpleBootstrap_cpp/SimpleBootstrap_cpp.cxx
@@ -0,0 +1,102 @@
+/*************************************************************************
+ *
+ * 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 <com/sun/star/lang/XMultiComponentFactory.hpp>
+
+using namespace rtl;
+using namespace com::sun::star::uno;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::frame;
+
+
+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 < XComponentLoader > xComponentLoader(
+ xServiceManager->createInstanceWithContext(
+ OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.frame.Desktop" ) ),
+ xContext ), UNO_QUERY_THROW );
+
+ // open a spreadsheet document
+ Reference< XComponent > xComponent( xComponentLoader->loadComponentFromURL(
+ OUString( RTL_CONSTASCII_USTRINGPARAM( "private:factory/scalc" ) ),
+ OUString( RTL_CONSTASCII_USTRINGPARAM( "_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;
+}
diff --git a/odk/examples/DevelopersGuide/ProfUNO/SimpleBootstrap_java/Makefile b/odk/examples/DevelopersGuide/ProfUNO/SimpleBootstrap_java/Makefile
new file mode 100644
index 000000000000..fd89206c58cd
--- /dev/null
+++ b/odk/examples/DevelopersGuide/ProfUNO/SimpleBootstrap_java/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 SimpleBootstrap_java example.
+
+PRJ=../../../..
+SETTINGS=$(PRJ)/settings
+
+include $(SETTINGS)/settings.mk
+include $(SETTINGS)/std.mk
+include $(SETTINGS)/dk.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 conmfigured 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 000000000000..a4bce5125f4e
--- /dev/null
+++ b/odk/examples/DevelopersGuide/ProfUNO/SimpleBootstrap_java/SimpleBootstrap_java.java
@@ -0,0 +1,76 @@
+/*************************************************************************
+ *
+ * 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.bridge.XUnoUrlResolver;
+import com.sun.star.frame.XComponentLoader;
+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 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 =
+ (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 );
+ }
+}
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 000000000000..e1326fa0b1b4
--- /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/ProfUNO/makefile.mk b/odk/examples/DevelopersGuide/ProfUNO/makefile.mk
new file mode 100644
index 000000000000..fbacdfc63b63
--- /dev/null
+++ b/odk/examples/DevelopersGuide/ProfUNO/makefile.mk
@@ -0,0 +1,95 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ=..$/..$/..
+PRJNAME=odk
+TARGET=copying
+
+#----------------------------------------------------------------
+.INCLUDE: settings.mk
+.INCLUDE: $(PRJ)$/util$/makefile.pmk
+#----------------------------------------------------------------
+
+#----------------------------------------------------
+# this makefile is only used for copying the example
+# files into the SDK
+#----------------------------------------------------
+
+CPPBINDING_FILES=\
+ $(DESTDIRDEVGUIDEEXAMPLES)$/ProfUNO$/CppBinding$/Makefile \
+ $(DESTDIRDEVGUIDEEXAMPLES)$/ProfUNO$/CppBinding$/office_connect.cxx \
+ $(DESTDIRDEVGUIDEEXAMPLES)$/ProfUNO$/CppBinding$/office_connect.ini \
+ $(DESTDIRDEVGUIDEEXAMPLES)$/ProfUNO$/CppBinding$/office_connectrc \
+ $(DESTDIRDEVGUIDEEXAMPLES)$/ProfUNO$/CppBinding$/string_samples.cxx
+
+INTERPROCESSCONN_FILES=\
+ $(DESTDIRDEVGUIDEEXAMPLES)$/ProfUNO$/InterprocessConn$/ConnectionAwareClient.java \
+ $(DESTDIRDEVGUIDEEXAMPLES)$/ProfUNO$/InterprocessConn$/Makefile \
+ $(DESTDIRDEVGUIDEEXAMPLES)$/ProfUNO$/InterprocessConn$/UrlResolver.java
+
+LIFETIME_FILES=\
+ $(DESTDIRDEVGUIDEEXAMPLES)$/ProfUNO$/Lifetime$/Makefile \
+ $(DESTDIRDEVGUIDEEXAMPLES)$/ProfUNO$/Lifetime$/MyUnoObject.java \
+ $(DESTDIRDEVGUIDEEXAMPLES)$/ProfUNO$/Lifetime$/object_lifetime.cxx
+
+SIMPLEBOOTSTRAP_JAVA_FILES=\
+ $(DESTDIRDEVGUIDEEXAMPLES)$/ProfUNO$/SimpleBootstrap_java$/SimpleBootstrap_java.java \
+ $(DESTDIRDEVGUIDEEXAMPLES)$/ProfUNO$/SimpleBootstrap_java$/manifest.mf \
+ $(DESTDIRDEVGUIDEEXAMPLES)$/ProfUNO$/SimpleBootstrap_java$/Makefile
+
+SIMPLEBOOTSTRAP_CPP_FILES=\
+ $(DESTDIRDEVGUIDEEXAMPLES)$/ProfUNO$/SimpleBootstrap_cpp$/SimpleBootstrap_cpp.cxx \
+ $(DESTDIRDEVGUIDEEXAMPLES)$/ProfUNO$/SimpleBootstrap_cpp$/Makefile
+
+DIR_FILE_LIST= \
+ $(CPPBINDING_FILES) \
+ $(INTERPROCESSCONN_FILES) \
+ $(LIFETIME_FILES) \
+ $(SIMPLEBOOTSTRAP_JAVA_FILES) \
+ $(SIMPLEBOOTSTRAP_CPP_FILES)
+
+DIR_DIRECTORY_LIST=$(uniq $(DIR_FILE_LIST:d))
+DIR_CREATE_FLAG=$(MISC)$/devguide_profuno_dirs_created.txt
+DIR_FILE_FLAG=$(MISC)$/devguide_profuno.txt
+
+#--------------------------------------------------
+# TARGETS
+#--------------------------------------------------
+all : \
+ $(DIR_FILE_LIST) \
+ $(DIR_FILE_FLAG)
+
+#--------------------------------------------------
+# use global rules
+#--------------------------------------------------
+.INCLUDE: $(PRJ)$/util$/odk_rules.pmk
+
+$(DESTDIREXAMPLES)$/%$/office_connectrc : $(PRJ)$/examples$/%$/office_connectrc
+ -$(MKDIRHIER) $(@:d)
+ @@-rm -f $@
+ $(MY_TEXTCOPY) $(MY_TEXTCOPY_SOURCEPRE) $< $(MY_TEXTCOPY_TARGETPRE) $@
+
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 000000000000..e7bf06b4eba9
--- /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 000000000000..9017df49dd6b
--- /dev/null
+++ b/odk/examples/DevelopersGuide/ScriptingFramework/SayHello/Makefile
@@ -0,0 +1,129 @@
+#*************************************************************************
+#
+# 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
+include $(SETTINGS)/dk.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 000000000000..e18331915ca2
--- /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 000000000000..b120c4cfa9f9
--- /dev/null
+++ b/odk/examples/DevelopersGuide/ScriptingFramework/SayHello/SayHello/SayHello.java
@@ -0,0 +1,46 @@
+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 = (XComponentLoader)
+ UnoRuntime.queryInterface(
+ XComponentLoader.class, ctxt.getDesktop());
+
+ XComponent comp = loader.loadComponentFromURL(
+ "private:factory/swriter", "_blank", 4, new PropertyValue[0]);
+
+ XTextDocument doc = (XTextDocument)
+ UnoRuntime.queryInterface( XTextDocument.class, comp);
+
+ return doc;
+ }
+}
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 000000000000..3f317a3495a2
--- /dev/null
+++ b/odk/examples/DevelopersGuide/ScriptingFramework/SayHello/SayHello/parcel-descriptor.xml
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<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 100755
index 000000000000..dd0b0cfcfd10
--- /dev/null
+++ b/odk/examples/DevelopersGuide/ScriptingFramework/SayHello/build.xml
@@ -0,0 +1,81 @@
+<project default="build">
+
+ <!-- =================== Global Properties ============================= -->
+ <property environment="env"/>
+ <property name="macroname" value="SayHello"/>
+ <property name="unopkgfile" value="${basedir}/${macroname}.uno.pkg"/>
+
+ <!-- ==================== intialise 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/unoil.jar"/>
+ <pathelement location="${opp}/classes/ridl.jar"/>
+ <pathelement location="${opp}/classes/jurt.jar"/>
+ <pathelement location="${opp}/classes/juh.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 000000000000..0b86e92ad399
--- /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 000000000000..1088fe5db0de
--- /dev/null
+++ b/odk/examples/DevelopersGuide/ScriptingFramework/ScriptSelector/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 OOoBean of the Developers Guide
+
+PRJ=../../../..
+SETTINGS=$(PRJ)/settings
+
+include $(SETTINGS)/settings.mk
+include $(SETTINGS)/std.mk
+include $(SETTINGS)/dk.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 000000000000..323bb6edd411
--- /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 000000000000..f461b9ddfb5d
--- /dev/null
+++ b/odk/examples/DevelopersGuide/ScriptingFramework/ScriptSelector/ScriptSelector/ScriptSelector.java
@@ -0,0 +1,397 @@
+import javax.swing.*;
+import javax.swing.tree.*;
+import javax.swing.table.*;
+import javax.swing.event.*;
+import javax.swing.border.*;
+import java.awt.*;
+import java.awt.event.*;
+import java.util.*;
+import java.beans.*;
+
+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.lang.XComponent;
+import com.sun.star.frame.XModel;
+import com.sun.star.frame.FrameSearchFlag;
+import com.sun.star.frame.XDispatchProvider;
+import com.sun.star.frame.XDispatchHelper;
+import com.sun.star.frame.XDispatch;
+import com.sun.star.util.XURLTransformer;
+import com.sun.star.beans.*;
+import com.sun.star.script.XInvocation;
+
+import com.sun.star.lib.uno.helper.PropertySet;
+
+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 ScriptSelector()
+ {
+ }
+
+ public void show(final XScriptContext ctxt)
+ {
+ try {
+ XBrowseNode root = getRootNode(ctxt);
+
+ Object obj = ctxt.getComponentContext().getValueByName(MSP_FACTORY);
+
+ XScriptProviderFactory fac = (XScriptProviderFactory)
+ 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 = (XPropertySet)
+ 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 void checkEnabled(XPropertySet props, String name,
+ JButton button)
+ {
+ boolean enable = false;
+
+ try
+ {
+ if (props != null)
+ {
+ Object o = props.getPropertyValue(name);
+ enable = AnyConverter.toBoolean(
+ props.getPropertyValue(name));
+ }
+ }
+ catch (com.sun.star.lang.IllegalArgumentException iae)
+ {
+ // leave enable set to false
+ }
+ catch (com.sun.star.beans.UnknownPropertyException upe)
+ {
+ // leave enable set to false
+ }
+ catch (com.sun.star.lang.WrappedTargetException wte)
+ {
+ // leave enable set to false
+ }
+
+ button.setEnabled(enable);
+ }
+
+ private XBrowseNode getRootNode(XScriptContext ctxt) {
+
+ XBrowseNode result = null;
+
+ XComponentContext xcc = ctxt.getComponentContext();
+ XBrowseNodeFactory xBrowseFac = (XBrowseNodeFactory)
+ UnoRuntime.queryInterface(
+ XBrowseNodeFactory.class, xcc.getValueByName(BROWSE_FACTORY));
+
+ result = (XBrowseNode)UnoRuntime.queryInterface(
+ XBrowseNode.class, xBrowseFac.createView(
+ BrowseNodeFactoryViewTypes.MACROSELECTOR ) );
+
+ return result;
+ }
+}
+
+class ScriptSelectorPanel extends JPanel {
+
+ private XBrowseNode myrootnode = null;
+ public JTextField textField;
+ public JTree tree;
+ public DefaultTreeModel treeModel;
+
+ 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) {
+ public String toString() {
+ return ((XBrowseNode)getUserObject()).getName();
+ }
+ };
+ initNodes(myrootnode, top);
+ 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 = (XPropertySet)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);
+ }
+
+ public void removeNode(DefaultMutableTreeNode node) {
+ MutableTreeNode parent = (MutableTreeNode)(node.getParent());
+ if (parent != null) {
+ treeModel.removeNodeFromParent(node);
+ }
+ }
+
+ public void addNode(DefaultMutableTreeNode parent, XBrowseNode xbn) {
+ DefaultMutableTreeNode newNode =
+ new DefaultMutableTreeNode(xbn) {
+ public String toString() {
+ return ((XBrowseNode)getUserObject()).getName();
+ }
+ };
+
+ treeModel.insertNodeInto(newNode, parent, parent.getChildCount());
+ tree.scrollPathToVisible(new TreePath(newNode.getPath()));
+ }
+
+ private void initNodes(XBrowseNode parent, DefaultMutableTreeNode top) {
+ if ( parent == null || parent.hasChildNodes() == false )
+ {
+ 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]) {
+ 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 ImageIcon sofficeIcon;
+ private ImageIcon scriptIcon;
+ private 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"));
+ }
+
+ 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;
+ }
+}
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 000000000000..3a345f9bf94a
--- /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 000000000000..758fc3f677d2
--- /dev/null
+++ b/odk/examples/DevelopersGuide/ScriptingFramework/ScriptSelector/ScriptSelector/parcel-descriptor.xml
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<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 000000000000..d3b3768cae11
--- /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 000000000000..88124d87d1e6
--- /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 100755
index 000000000000..572e7c4c459a
--- /dev/null
+++ b/odk/examples/DevelopersGuide/ScriptingFramework/ScriptSelector/build.xml
@@ -0,0 +1,81 @@
+<project default="build">
+
+ <!-- =================== Global Properties ============================= -->
+ <property environment="env"/>
+ <property name="macroname" value="ScriptSelector"/>
+ <property name="unopkgfile" value="${basedir}/${macroname}.uno.pkg"/>
+
+ <!-- ==================== intialise 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/unoil.jar"/>
+ <pathelement location="${opp}/classes/ridl.jar"/>
+ <pathelement location="${opp}/classes/jurt.jar"/>
+ <pathelement location="${opp}/classes/juh.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/makefile.mk b/odk/examples/DevelopersGuide/ScriptingFramework/makefile.mk
new file mode 100644
index 000000000000..615a8c131a4f
--- /dev/null
+++ b/odk/examples/DevelopersGuide/ScriptingFramework/makefile.mk
@@ -0,0 +1,79 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ=..$/..$/..
+PRJNAME=odk
+TARGET=copying
+
+#----------------------------------------------------------------
+.INCLUDE: settings.mk
+.INCLUDE: $(PRJ)$/util$/makefile.pmk
+#----------------------------------------------------------------
+
+#----------------------------------------------------
+# this makefile is only used for copying the example
+# files into the SDK
+#----------------------------------------------------
+
+DESTSF=$(DESTDIRDEVGUIDEEXAMPLES)$/ScriptingFramework
+SF_FILES=\
+ $(DESTSF)$/SayHello$/SayHello$/parcel-descriptor.xml \
+ $(DESTSF)$/SayHello$/SayHello$/SayHello.java \
+ $(DESTSF)$/SayHello$/Makefile \
+ $(DESTSF)$/SayHello$/SayHello.odt \
+ $(DESTSF)$/SayHello$/build.xml \
+ $(DESTSF)$/SayHello$/META-INF$/manifest.xml \
+ $(DESTSF)$/ScriptSelector$/ScriptSelector.odt \
+ $(DESTSF)$/ScriptSelector$/Makefile \
+ $(DESTSF)$/ScriptSelector$/build.xml \
+ $(DESTSF)$/ScriptSelector$/META-INF$/manifest.xml \
+ $(DESTSF)$/ScriptSelector$/ScriptSelector$/container.gif \
+ $(DESTSF)$/ScriptSelector$/ScriptSelector$/script.gif \
+ $(DESTSF)$/ScriptSelector$/ScriptSelector$/soffice.gif \
+ $(DESTSF)$/ScriptSelector$/ScriptSelector$/ScriptSelector.java \
+ $(DESTSF)$/ScriptSelector$/ScriptSelector$/parcel-descriptor.xml
+
+DIR_FILE_LIST= \
+ $(SF_FILES) \
+
+DIR_DIRECTORY_LIST=$(uniq $(DIR_FILE_LIST:d))
+DIR_CREATE_FLAG=$(MISC)$/devguide_sf_dirs_created.txt
+DIR_FILE_FLAG=$(MISC)$/devguide_sf.txt
+
+#--------------------------------------------------
+# TARGETS
+#--------------------------------------------------
+all : \
+ $(DIR_FILE_LIST) \
+ $(DIR_FILE_FLAG)
+
+#--------------------------------------------------
+# use global rules
+#--------------------------------------------------
+.INCLUDE: $(PRJ)$/util$/odk_rules.pmk
+
+
diff --git a/odk/examples/DevelopersGuide/Spreadsheet/DataPilotReadme.txt b/odk/examples/DevelopersGuide/Spreadsheet/DataPilotReadme.txt
new file mode 100644
index 000000000000..39aecb281881
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Spreadsheet/DataPilotReadme.txt
@@ -0,0 +1,30 @@
+ExampleDataPilotSource
+======================
+
+This example shows how you can implement an external DataPilot
+component.
+
+Simple usage scenario:
+======================
+1. build and deploay 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 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 colums 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.java b/odk/examples/DevelopersGuide/Spreadsheet/ExampleAddIn.java
new file mode 100644
index 000000000000..44f17a50c83d
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Spreadsheet/ExampleAddIn.java
@@ -0,0 +1,314 @@
+/*************************************************************************
+ *
+ * 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 String aName;
+ private int nValue;
+ private java.util.Vector aListeners = new java.util.Vector();
+
+ 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 + " " + String.valueOf( nValue );
+ aEvent.Source = this;
+ return aEvent;
+ }
+
+ public void addResultListener(com.sun.star.sheet.XResultListener aListener)
+ {
+ aListeners.addElement( aListener );
+
+ // immediately notify of initial value
+ aListener.modified( getResult() );
+ }
+
+ public void removeResultListener(com.sun.star.sheet.XResultListener aListener)
+ {
+ aListeners.removeElement( aListener );
+ }
+
+ public void incrementValue()
+ {
+ ++nValue;
+ com.sun.star.sheet.ResultEvent aEvent = getResult();
+
+ java.util.Enumeration aEnum = aListeners.elements();
+ while (aEnum.hasMoreElements())
+ ((com.sun.star.sheet.XResultListener)aEnum.nextElement()).modified(
+ aEvent);
+ }
+}
+
+class ExampleAddInThread extends Thread
+{
+ private java.util.Hashtable aCounters;
+
+ public ExampleAddInThread( java.util.Hashtable aResults )
+ {
+ aCounters = aResults;
+ }
+
+ public void run()
+ {
+ while ( true )
+ {
+ try
+ {
+ sleep(1000);
+ }
+ catch( InterruptedException exception )
+ {
+ }
+
+ // increment all counters
+ java.util.Enumeration aEnum = aCounters.elements();
+ while (aEnum.hasMoreElements())
+ ((ExampleAddInResult)aEnum.nextElement()).incrementValue();
+ }
+ }
+}
+
+public class ExampleAddIn
+{
+ static public 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
+ {
+ static private final String aExampleService = "org.openoffice.sheet.addin.ExampleAddIn";
+ static private final String aAddInService = "com.sun.star.sheet.AddIn";
+ static private final String aImplName = "ExampleAddIn";
+
+ private static final short FUNCTION_INVALID = -1;
+ private static final short FUNCTION_INCREMENT = 0;
+ private static final short FUNCTION_COUNTER = 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.Hashtable 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.Hashtable();
+ ExampleAddInThread aThread = new ExampleAddInThread( aResults );
+ aThread.start();
+ }
+
+ ExampleAddInResult aResult = (ExampleAddInResult) 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;
+ }
+
+ public static boolean __writeRegistryServiceInfo(
+ com.sun.star.registry.XRegistryKey regKey)
+ {
+ // register for both the base AddIn and the own service
+ return com.sun.star.comp.loader.FactoryHelper.writeRegistryServiceInfo(
+ _ExampleAddIn.aImplName, _ExampleAddIn.aExampleService, regKey)
+ && com.sun.star.comp.loader.FactoryHelper.writeRegistryServiceInfo(
+ _ExampleAddIn.aImplName, _ExampleAddIn.aAddInService, regKey);
+ }
+}
+
diff --git a/odk/examples/DevelopersGuide/Spreadsheet/ExampleAddIn.ods b/odk/examples/DevelopersGuide/Spreadsheet/ExampleAddIn.ods
new file mode 100644
index 000000000000..b86f24915b54
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Spreadsheet/ExampleAddIn.ods
Binary files differ
diff --git a/odk/examples/DevelopersGuide/Spreadsheet/ExampleDataPilotSource.java b/odk/examples/DevelopersGuide/Spreadsheet/ExampleDataPilotSource.java
new file mode 100644
index 000000000000..80f5ff15a4d2
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Spreadsheet/ExampleDataPilotSource.java
@@ -0,0 +1,981 @@
+/*************************************************************************
+ *
+ * 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
+{
+ static public final int nDimensionCount = 6;
+ static public final int nValueDimension = 4;
+ static public final int nDataDimension = 5;
+ static public final String [] aDimensionNames = {
+ "ones", "tens", "hundreds", "thousands", "value", "" };
+
+ static public final String getMemberName( int nMember )
+ {
+ return String.valueOf( nMember );
+ }
+
+ public int nMemberCount = 3;
+ public java.util.List aColDimensions = new java.util.ArrayList();
+ public java.util.List aRowDimensions = new java.util.ArrayList();
+}
+
+// XPropertySetInfo implementation for getPropertySetInfo
+
+class ExamplePropertySetInfo implements com.sun.star.beans.XPropertySetInfo
+{
+ private 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 ExampleSettings aSettings;
+ private int nDimension;
+ private int nMember;
+
+ public ExampleMember( ExampleSettings aSet, int nDim, int nMbr )
+ {
+ aSettings = aSet;
+ nDimension = nDim;
+ 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 new 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.container.XNameAccess
+{
+ private ExampleSettings aSettings;
+ private int nDimension;
+ private ExampleMember[] aMembers;
+
+ public ExampleMembers( ExampleSettings aSet, int nDim )
+ {
+ aSettings = aSet;
+ nDimension = nDim;
+ 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( aSettings, nDimension, 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;
+ }
+}
+
+// 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 ExampleSettings aSettings;
+ private 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.container.XNameAccess getMembers()
+ {
+ if ( aMembers == null )
+ aMembers = new ExampleMembers( aSettings, nDimension );
+ return aMembers;
+ }
+
+ // XDataPilotMemberResults
+
+ public com.sun.star.sheet.MemberResult[] getResults()
+ {
+ int nDimensions = 0;
+ int nPosition = aSettings.aColDimensions.indexOf( new Integer(nDimension));
+ if ( nPosition >= 0 )
+ nDimensions = aSettings.aColDimensions.size();
+ else
+ {
+ nPosition = aSettings.aRowDimensions.indexOf( new Integer(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 new 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 ExampleSettings aSettings;
+ private 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 ExampleSettings aSettings;
+ private 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 ExampleSettings aSettings;
+ private 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 ExampleSettings aSettings;
+ private 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),
+ (short) com.sun.star.beans.PropertyAttribute.READONLY ),
+ new com.sun.star.beans.Property( "IsDataLayoutDimension", -1,
+ new com.sun.star.uno.Type( Boolean.class),
+ (short) 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 = new Integer(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 = new Integer(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 new Boolean( 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( new Integer(nDimension) );
+ else if ( eOrientation == com.sun.star.sheet.DataPilotFieldOrientation.ROW )
+ nPosition = aSettings.aRowDimensions.indexOf( new Integer(nDimension) );
+ else
+ nPosition = nDimension;
+ return new Integer( nPosition );
+ }
+ else if ( aPropertyName.equals( "Function" ) )
+ return com.sun.star.sheet.GeneralFunction.SUM;
+ else if ( aPropertyName.equals( "UsedHierarchy" ) )
+ return new Integer(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 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
+
+ static public 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
+ {
+ static private final String aServiceName = "com.sun.star.sheet.DataPilotSource";
+ static private final String aImplName = "ExampleDataPilotSource";
+
+ private 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.
+ if ( aArguments.length >= 1 )
+ {
+ String aSource = (String) aArguments[0];
+ if ( aSource != null )
+ {
+ try
+ {
+ 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();
+ }
+ }
+ }
+ }
+
+ // 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 = ((Integer)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 = ((Integer)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;
+ }
+
+ // 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 new 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;
+ }
+
+ public static boolean __writeRegistryServiceInfo(
+ com.sun.star.registry.XRegistryKey regKey)
+ {
+ return com.sun.star.comp.loader.FactoryHelper.writeRegistryServiceInfo(
+ _ExampleDataPilotSource.aImplName,
+ _ExampleDataPilotSource.aServiceName, regKey);
+ }
+}
+
diff --git a/odk/examples/DevelopersGuide/Spreadsheet/GeneralTableSample.java b/odk/examples/DevelopersGuide/Spreadsheet/GeneralTableSample.java
new file mode 100644
index 000000000000..30bd5c143aa1
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Spreadsheet/GeneralTableSample.java
@@ -0,0 +1,241 @@
+/*************************************************************************
+ *
+ * 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 = (com.sun.star.text.XText)
+ 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 = (com.sun.star.beans.XPropertySet)
+ UnoRuntime.queryInterface( com.sun.star.beans.XPropertySet.class, xCell );
+ xPropSet.setPropertyValue( "CellBackColor", new Integer( 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 = (com.sun.star.beans.XPropertySet)
+ UnoRuntime.queryInterface( com.sun.star.beans.XPropertySet.class, xCellRange );
+ xPropSet.setPropertyValue( "CellBackColor", new Integer( 0x8080FF ) );
+
+ // Accessing a cell range over its name.
+ xCellRange = xSheet.getCellRangeByName( "C4:D5" );
+
+ // Change properties of the range.
+ xPropSet = (com.sun.star.beans.XPropertySet)
+ UnoRuntime.queryInterface( com.sun.star.beans.XPropertySet.class, xCellRange );
+ xPropSet.setPropertyValue( "CellBackColor", new Integer( 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 = (com.sun.star.sheet.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 = (com.sun.star.table.XCellCursor)
+ 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 = (com.sun.star.table.XColumnRowRange)
+ 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 = (com.sun.star.beans.XPropertySet)
+ UnoRuntime.queryInterface( com.sun.star.beans.XPropertySet.class, aColumnObj );
+ xPropSet.setPropertyValue( "Width", new Integer( 5000 ) );
+
+ // Get the name of the column.
+ com.sun.star.container.XNamed xNamed = (com.sun.star.container.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 = (com.sun.star.container.XNameAccess)
+ UnoRuntime.queryInterface( com.sun.star.container.XNameAccess.class, xColumns );
+
+ aColumnObj = xColumnsName.getByName( "D" );
+ xPropSet = (com.sun.star.beans.XPropertySet)
+ UnoRuntime.queryInterface( com.sun.star.beans.XPropertySet.class, aColumnObj );
+ xPropSet.setPropertyValue( "IsVisible", new Boolean( false ) );
+
+ // Get row 7 by index (interface XIndexAccess)
+ Object aRowObj = xRows.getByIndex( 6 );
+ xPropSet = (com.sun.star.beans.XPropertySet)
+ UnoRuntime.queryInterface( com.sun.star.beans.XPropertySet.class, aRowObj );
+ xPropSet.setPropertyValue( "Height", new Integer( 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 =
+ (com.sun.star.table.XTableChartsSupplier) 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 = (com.sun.star.table.XTableChart)
+ 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 );
+ }
+
+// ________________________________________________________________
+}
diff --git a/odk/examples/DevelopersGuide/Spreadsheet/Makefile b/odk/examples/DevelopersGuide/Spreadsheet/Makefile
new file mode 100644
index 000000000000..3c1748327bac
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Spreadsheet/Makefile
@@ -0,0 +1,306 @@
+#*************************************************************************
+#
+# 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 $(SETTINGS)/dk.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
+
+# 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
+
+#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_GENURDFILES = $(patsubst %.idl,$(COMP1_GEN_OUT)/%.urd,$(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_GEN_OUT)/%.urd : %.idl
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ $(IDLC) -I. -I$(IDL_DIR) -O$(COMP1_GEN_OUT) $^
+
+$(COMP1_RDB) : $(COMP1_GENURDFILES)
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ $(REGMERGE) $@ /UCR $<
+
+$(COMP1_CLASS_OUT)/$(PACKAGE)/%.class : $(COMP1_RDB)
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ $(JAVAMAKER) -BUCR -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-component;type=Java$(QM)" >> $@
+ @echo $(SQM) $(SQM)manifest:full-path="$(QM)$(subst /META-INF,,$(subst $(COMP1_GEN_OUT)/,,$(@D))).uno.jar$(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-component;type=Java$(QM)" >> $@
+ @echo $(SQM) $(SQM)manifest:full-path="$(QM)$(subst /META-INF,,$(subst $(COMP2_GEN_OUT)/,,$(@D))).uno.jar$(QM)"/$(CSEP) >> $@
+ @echo $(OSEP)/manifest:manifest$(CSEP) >> $@
+
+$(COMP1_PACKAGE) : $(COMP1_RDB) $(COMP1_JAR) $(COMP1_UNOPKG_MANIFEST)
+ echo "####" $(@)
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ cd $(subst /,$(PS),$(COMP1_GEN_OUT)) && $(SDK_ZIP) ../../../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)
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
+ -$(MKDIR) $(subst /,$(PS),$(@D))
+ cd $(subst /,$(PS),$(SAMPLE_CLASS_OUT)) && $(SDK_ZIP) ../../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 000000000000..35beab5053e2
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Spreadsheet/SpreadsheetDocHelper.java
@@ -0,0 +1,405 @@
+/*************************************************************************
+ *
+ * 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.comp.servicemanager.ServiceManager;
+import com.sun.star.bridge.XUnoUrlResolver;
+import com.sun.star.uno.XNamingService;
+import com.sun.star.frame.XDesktop;
+import com.sun.star.frame.XComponentLoader;
+import com.sun.star.lang.XMultiServiceFactory;
+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 final String msDataSheetName = "Data";
+
+ private com.sun.star.uno.XComponentContext mxRemoteContext;
+ private com.sun.star.lang.XMultiComponentFactory mxRemoteServiceManager;
+// private com.sun.star.lang.XMultiServiceFactory mxMSFactory;
+ 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 =
+ (com.sun.star.container.XIndexAccess)UnoRuntime.queryInterface(
+ com.sun.star.container.XIndexAccess.class, xSheets );
+ xSheet = (com.sun.star.sheet.XSpreadsheet) 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 = (com.sun.star.sheet.XSpreadsheet)
+ 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 =
+ (com.sun.star.util.XNumberFormatsSupplier) UnoRuntime.queryInterface(
+ com.sun.star.util.XNumberFormatsSupplier.class, getDocument() );
+ com.sun.star.util.XNumberFormatTypes xFormatTypes =
+ (com.sun.star.util.XNumberFormatTypes) 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 = (com.sun.star.beans.XPropertySet)
+ UnoRuntime.queryInterface( com.sun.star.beans.XPropertySet.class, xCell );
+ xPropSet.setPropertyValue( "NumberFormat", new Integer( 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 = (com.sun.star.beans.XPropertySet)
+ 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 = (com.sun.star.sheet.XCellRangeAddressable)
+ 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 = (com.sun.star.beans.XPropertySet)
+ UnoRuntime.queryInterface( com.sun.star.beans.XPropertySet.class, xCellRange );
+ xPropSet.setPropertyValue( "CellBackColor", new Integer( 0x99CCFF ) );
+ // write headline
+ com.sun.star.table.XCell xCell = xCellRange.getCellByPosition( 0, 0 );
+ xCell.setFormula( aHeadline );
+ xPropSet = (com.sun.star.beans.XPropertySet)
+ UnoRuntime.queryInterface( com.sun.star.beans.XPropertySet.class, xCell );
+ xPropSet.setPropertyValue( "CharColor", new Integer( 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 = (com.sun.star.sheet.XCellAddressable)
+ 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 = (com.sun.star.sheet.XCellRangeAddressable)
+ 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 = (com.sun.star.container.XNamed)
+ UnoRuntime.queryInterface( com.sun.star.container.XNamed.class, xSheet );
+ aStr += xNamed.getName() + ".";
+ }
+ com.sun.star.sheet.XCellRangeAddressable xAddr = (com.sun.star.sheet.XCellRangeAddressable)
+ 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 = (com.sun.star.sheet.XSheetCellRange)
+ 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 = (XComponentLoader)
+ 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 (com.sun.star.sheet.XSpreadsheetDocument)UnoRuntime.queryInterface(
+ com.sun.star.sheet.XSpreadsheetDocument.class, xComponent );
+ }
+
+// ________________________________________________________________
+}
diff --git a/odk/examples/DevelopersGuide/Spreadsheet/SpreadsheetSample.java b/odk/examples/DevelopersGuide/Spreadsheet/SpreadsheetSample.java
new file mode 100644
index 000000000000..fcae70c91ec4
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Spreadsheet/SpreadsheetSample.java
@@ -0,0 +1,1417 @@
+/*************************************************************************
+ *
+ * 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: Dota 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 = (com.sun.star.text.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 = (com.sun.star.lang.XMultiServiceFactory)
+ UnoRuntime.queryInterface( com.sun.star.lang.XMultiServiceFactory.class, getDocument() );
+ Object aHyperlinkObj = xServiceMan.createInstance( "com.sun.star.text.TextField.URL" );
+ xPropSet = (com.sun.star.beans.XPropertySet)
+ 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 = (com.sun.star.text.XTextContent)
+ UnoRuntime.queryInterface( com.sun.star.text.XTextContent.class, aHyperlinkObj );
+ xText.insertTextContent( xTextCursor, xContent, false );
+
+
+ // --- Query the separate paragraphs. ---
+ com.sun.star.container.XEnumerationAccess xParaEA =
+ (com.sun.star.container.XEnumerationAccess) 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 =
+ (com.sun.star.container.XEnumerationAccess) 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.
+ Object nextElement;
+ while( xPortionEnum.hasMoreElements() )
+ {
+ com.sun.star.text.XTextRange xRange = (com.sun.star.text.XTextRange)
+ UnoRuntime.queryInterface(com.sun.star.text.XTextRange.class,
+ xPortionEnum.nextElement());
+ aText += xRange.getString();
+ }
+ System.out.println( "Paragraph text: " + aText );
+ }
+
+
+ // --- Change cell properties. ---
+ xPropSet = (com.sun.star.beans.XPropertySet)
+ UnoRuntime.queryInterface( com.sun.star.beans.XPropertySet.class, xCell );
+ // from styles.CharacterProperties
+ xPropSet.setPropertyValue( "CharColor", new Integer( 0x003399 ) );
+ xPropSet.setPropertyValue( "CharHeight", new Float( 20.0 ) );
+ // from styles.ParagraphProperties
+ xPropSet.setPropertyValue( "ParaLeftMargin", new Integer( 500 ) );
+ // from table.CellProperties
+ xPropSet.setPropertyValue( "IsCellBackgroundTransparent", new Boolean( false ) );
+ xPropSet.setPropertyValue( "CellBackColor", new Integer( 0x99CCFF ) );
+
+
+ // --- Get cell address. ---
+ com.sun.star.sheet.XCellAddressable xCellAddr = (com.sun.star.sheet.XCellAddressable)
+ 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 =
+ (com.sun.star.sheet.XSheetAnnotationsSupplier) 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 = (com.sun.star.sheet.XSheetAnnotationAnchor)
+ 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;
+ String aText;
+
+ // 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 = (com.sun.star.beans.XPropertySet)
+ UnoRuntime.queryInterface( com.sun.star.beans.XPropertySet.class, xCellRange );
+ // from com.sun.star.styles.CharacterProperties
+ xPropSet.setPropertyValue( "CharColor", new Integer( 0x003399 ) );
+ xPropSet.setPropertyValue( "CharHeight", new Float( 20.0 ) );
+ // from com.sun.star.styles.ParagraphProperties
+ xPropSet.setPropertyValue( "ParaLeftMargin", new Integer( 500 ) );
+ // from com.sun.star.table.CellProperties
+ xPropSet.setPropertyValue( "IsCellBackgroundTransparent", new Boolean( false ) );
+ xPropSet.setPropertyValue( "CellBackColor", new Integer( 0x99CCFF ) );
+
+
+ // --- Replace text in all cells. ---
+ com.sun.star.util.XReplaceable xReplace = (com.sun.star.util.XReplaceable)
+ 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", new 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 = (com.sun.star.util.XMergeable)
+ 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 = (com.sun.star.table.XColumnRowRange)
+ UnoRuntime.queryInterface( com.sun.star.table.XColumnRowRange.class, xCellRange );
+ com.sun.star.table.XTableColumns xColumns = xColRowRange.getColumns();
+
+ Object aColumnObj = xColumns.getByIndex( 0 );
+ xPropSet = (com.sun.star.beans.XPropertySet) UnoRuntime.queryInterface(
+ com.sun.star.beans.XPropertySet.class, aColumnObj );
+ xPropSet.setPropertyValue( "Width", new Integer( 6000 ) );
+
+ com.sun.star.container.XNamed xNamed = (com.sun.star.container.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 = (com.sun.star.sheet.XCellRangeData)
+ 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 = (com.sun.star.sheet.XCellRangeAddressable)
+ 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 = (com.sun.star.sheet.XSheetOperation)
+ 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 = (com.sun.star.sheet.XArrayFormulaRange)
+ 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 = (com.sun.star.sheet.XMultipleOperation)
+ 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 = (com.sun.star.sheet.XMultipleOperation)
+ 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 = (com.sun.star.sheet.XCellRangesQuery)
+ 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 (com.sun.star.sheet.XCellSeries) 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 =
+ (com.sun.star.lang.XMultiServiceFactory) UnoRuntime.queryInterface(
+ com.sun.star.lang.XMultiServiceFactory.class, getDocument() );
+ com.sun.star.sheet.XSheetCellRangeContainer xRangeCont =
+ (com.sun.star.sheet.XSheetCellRangeContainer) 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 = (com.sun.star.sheet.XCellAddressable)
+ 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 = (com.sun.star.sheet.XSheetCellRange)
+ 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 = (com.sun.star.sheet.XArrayFormulaRange)
+ 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 = (com.sun.star.sheet.XUsedAreaCursor)
+ 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 = (com.sun.star.style.XStyleFamiliesSupplier)
+ 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 = (com.sun.star.container.XNameContainer)
+ UnoRuntime.queryInterface( com.sun.star.container.XNameContainer.class, aCellStylesObj );
+
+ // create a new cell style
+ xDocServiceManager = (com.sun.star.lang.XMultiServiceFactory)
+ 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 = (com.sun.star.beans.XPropertySet)
+ UnoRuntime.queryInterface( com.sun.star.beans.XPropertySet.class, aCellStyle );
+ xPropSet.setPropertyValue( "CellBackColor", new Integer( 0x888888 ) );
+ xPropSet.setPropertyValue( "IsCellBackgroundTransparent", new Boolean( false ) );
+
+
+
+ // --- Query equal-formatted cell ranges ---
+ // prepare example, use the new cell style
+ xCellRange = xSheet.getCellRangeByName( "D2:F2" );
+ xPropSet = (com.sun.star.beans.XPropertySet) UnoRuntime.queryInterface(
+ com.sun.star.beans.XPropertySet.class, xCellRange );
+ xPropSet.setPropertyValue( "CellStyle", aStyleName );
+
+ xCellRange = xSheet.getCellRangeByName( "A3:G3" );
+ xPropSet = (com.sun.star.beans.XPropertySet) 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 =
+ (com.sun.star.sheet.XCellFormatRangesSupplier) 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 =
+ (com.sun.star.sheet.XUniqueCellFormatRangesSupplier) 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 = (com.sun.star.container.XIndexAccess) 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 =
+ (com.sun.star.container.XNameContainer)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
+ {
+ // create a new auto format (with document service manager!)
+// xDocServiceManager = (com.sun.star.lang.XMultiServiceFactory)
+// UnoRuntime.queryInterface( com.sun.star.lang.XMultiServiceFactory.class, getDocument() );
+ 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 =
+ (com.sun.star.container.XIndexAccess)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 = (com.sun.star.beans.XPropertySet)
+ UnoRuntime.queryInterface(
+ com.sun.star.beans.XPropertySet.class, aFieldObj );
+ xPropSet.setPropertyValue( "CellBackColor", new Integer( nColor ) );
+ }
+ }
+
+ // set the auto format to the spreadsheet
+ xCellRange = xSheet.getCellRangeByName( "A5:H25" );
+ com.sun.star.table.XAutoFormattable xAutoForm = (com.sun.star.table.XAutoFormattable)
+ 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 = (com.sun.star.beans.XPropertySet)
+ UnoRuntime.queryInterface( com.sun.star.beans.XPropertySet.class, xCellRange );
+ com.sun.star.sheet.XSheetConditionalEntries xEntries =
+ (com.sun.star.sheet.XSheetConditionalEntries) 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 = (com.sun.star.sheet.XCellRangeMovement)
+ 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 = (com.sun.star.sheet.XSheetPageBreak)
+ 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 = (com.sun.star.beans.XPropertySet)
+ UnoRuntime.queryInterface( com.sun.star.beans.XPropertySet.class, getDocument() );
+
+ AnyConverter aAnyConv = new AnyConverter();
+ String aText = "Value of property IsIterationEnabled: ";
+ aText += aAnyConv.toBoolean(xPropSet.getPropertyValue( "IsIterationEnabled" ));
+ System.out.println( aText );
+ aText = "Value of property IterationCount: ";
+ aText += aAnyConv.toInt(xPropSet.getPropertyValue( "IterationCount" ));
+ System.out.println( aText );
+ aText = "Value of property NullDate: ";
+ com.sun.star.util.Date aDate = (com.sun.star.util.Date)
+ aAnyConv.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 = (com.sun.star.beans.XPropertySet)
+ UnoRuntime.queryInterface( com.sun.star.beans.XPropertySet.class, xCellRange );
+ // validation properties
+ com.sun.star.beans.XPropertySet xValidPropSet = (com.sun.star.beans.XPropertySet)
+ UnoRuntime.queryInterface(com.sun.star.beans.XPropertySet.class,
+ xCellPropSet.getPropertyValue( "Validation" ));
+ xValidPropSet.setPropertyValue( "Type", com.sun.star.sheet.ValidationType.DECIMAL );
+ xValidPropSet.setPropertyValue( "ShowErrorMessage", new 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 = (com.sun.star.sheet.XSheetCondition)
+ 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 = (com.sun.star.sheet.XCellRangeAddressable)
+ 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 = (com.sun.star.sheet.XScenariosSupplier)
+ 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 = (com.sun.star.sheet.XCellRangeData)
+ 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 = (com.sun.star.sheet.XScenariosSupplier)
+ 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 = (com.sun.star.sheet.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 = (com.sun.star.beans.XPropertySet)
+ UnoRuntime.queryInterface( com.sun.star.beans.XPropertySet.class, xDocument );
+ Object aRangesObj = xDocProp.getPropertyValue( "NamedRanges" );
+ com.sun.star.sheet.XNamedRanges xNamedRanges = (com.sun.star.sheet.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 = ( com.sun.star.sheet.XCellRangeData )
+ 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 = (com.sun.star.sheet.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 =
+ (com.sun.star.container.XNameAccess) 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 = (com.sun.star.container.XNameAccess)
+ UnoRuntime.queryInterface( com.sun.star.container.XNameAccess.class,
+ xServiceManager.createInstanceWithContext(
+ "com.sun.star.sdb.DatabaseContext", getContext()) );
+ com.sun.star.sdb.XCompletedConnection xSource =
+ (com.sun.star.sdb.XCompletedConnection)UnoRuntime.queryInterface(
+ com.sun.star.sdb.XCompletedConnection.class,
+ xContext.getByName( aDatabase ) );
+ com.sun.star.task.XInteractionHandler xHandler =
+ (com.sun.star.task.XInteractionHandler)UnoRuntime.queryInterface(
+ com.sun.star.task.XInteractionHandler.class,
+ xServiceManager.createInstanceWithContext(
+ "com.sun.star.task.InteractionHandler", getContext()) );
+ com.sun.star.sdbcx.XTablesSupplier xSupplier =
+ (com.sun.star.sdbcx.XTablesSupplier)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 = ( com.sun.star.sheet.XCellRangeData )
+ 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 = ( com.sun.star.sheet.XSheetFilterable )
+ 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 = (com.sun.star.beans.XPropertySet)
+ UnoRuntime.queryInterface( com.sun.star.beans.XPropertySet.class, xFilterDesc );
+ xFilterProp.setPropertyValue( "ContainsHeader", new 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 = ( com.sun.star.sheet.XCellRangeData )
+ UnoRuntime.queryInterface( com.sun.star.sheet.XCellRangeData.class, xCritRange );
+ Object[][] aCritValues =
+ {
+ { "Year" },
+ { ">= 1998" }
+ };
+ xCritData.setDataArray( aCritValues );
+ com.sun.star.sheet.XSheetFilterableEx xCriteria = ( com.sun.star.sheet.XSheetFilterableEx )
+ 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 = new Boolean( true );
+
+ com.sun.star.util.XSortable xSort = ( com.sun.star.util.XSortable )
+ UnoRuntime.queryInterface( com.sun.star.util.XSortable.class, xRange );
+ xSort.sort( aSortDesc );
+
+
+ // --- insert subtotals ---
+ com.sun.star.sheet.XSubTotalCalculatable xSub = ( com.sun.star.sheet.XSubTotalCalculatable )
+ 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 = ( com.sun.star.util.XImportable )
+ 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 = (com.sun.star.beans.XPropertySet)
+ UnoRuntime.queryInterface( com.sun.star.beans.XPropertySet.class, getDocument() );
+ Object aRangesObj = xDocProp.getPropertyValue( "DatabaseRanges" );
+ com.sun.star.container.XNameAccess xRanges =
+ (com.sun.star.container.XNameAccess) UnoRuntime.queryInterface(
+ com.sun.star.container.XNameAccess.class, aRangesObj );
+ String[] aNames = xRanges.getElementNames();
+ AnyConverter aAnyConv = new AnyConverter();
+ for ( int i=0; i<aNames.length; i++ )
+ {
+ Object aRangeObj = xRanges.getByName( aNames[i] );
+ com.sun.star.beans.XPropertySet xRangeProp = (com.sun.star.beans.XPropertySet)
+ UnoRuntime.queryInterface( com.sun.star.beans.XPropertySet.class, aRangeObj );
+ boolean bUser = aAnyConv.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 = ( com.sun.star.sheet.XCellRangeReferrer )
+ UnoRuntime.queryInterface( com.sun.star.sheet.XCellRangeReferrer.class, aRangeObj );
+ com.sun.star.table.XCellRange xResultRange = xRef.getReferredCells();
+ com.sun.star.beans.XPropertySet xResultProp = (com.sun.star.beans.XPropertySet)
+ UnoRuntime.queryInterface( com.sun.star.beans.XPropertySet.class, xResultRange );
+ xResultProp.setPropertyValue( "IsCellBackgroundTransparent", new Boolean( false ) );
+ xResultProp.setPropertyValue( "CellBackColor", new Integer( 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 = (com.sun.star.sheet.XDataPilotTablesSupplier)
+ 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 = (com.sun.star.beans.XPropertySet)
+ 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 = (com.sun.star.beans.XPropertySet)
+ 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 = (com.sun.star.beans.XPropertySet)
+ 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 = (com.sun.star.sheet.XDataPilotDescriptor)
+ 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 = (com.sun.star.beans.XPropertySet)
+ 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 =
+ (com.sun.star.sheet.XFunctionAccess)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 =
+ (com.sun.star.sheet.XRecentFunctions)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 =
+ (com.sun.star.sheet.XFunctionDescriptions)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 =
+ (com.sun.star.beans.XPropertySet)UnoRuntime.queryInterface(
+ com.sun.star.beans.XPropertySet.class, aSettings );
+ AnyConverter aAnyConv = new AnyConverter();
+ String[] aEntries = (String[])
+ aAnyConv.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] );
+ }
+
+// ________________________________________________________________
+
+}
diff --git a/odk/examples/DevelopersGuide/Spreadsheet/ViewSample.java b/odk/examples/DevelopersGuide/Spreadsheet/ViewSample.java
new file mode 100644
index 000000000000..dd89ce017ead
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Spreadsheet/ViewSample.java
@@ -0,0 +1,170 @@
+/*************************************************************************
+ *
+ * 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 = (com.sun.star.frame.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 = (com.sun.star.sheet.XViewFreezable)
+ 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 = (com.sun.star.container.XIndexAccess)
+ UnoRuntime.queryInterface( com.sun.star.container.XIndexAccess.class, xController );
+ Object aPane = xIndex.getByIndex(1);
+ com.sun.star.sheet.XCellRangeReferrer xRefer = (com.sun.star.sheet.XCellRangeReferrer)
+ UnoRuntime.queryInterface( com.sun.star.sheet.XCellRangeReferrer.class, aPane );
+ com.sun.star.table.XCellRange xRange = xRefer.getReferredCells();
+ com.sun.star.beans.XPropertySet xRangeProp = (com.sun.star.beans.XPropertySet)
+ UnoRuntime.queryInterface( com.sun.star.beans.XPropertySet.class, xRange );
+ xRangeProp.setPropertyValue( "IsCellBackgroundTransparent", new Boolean( false ) );
+ xRangeProp.setPropertyValue( "CellBackColor", new Integer( 0xFFFFCC ) );
+
+ // --- View settings ---
+ // change the view to display green grid lines
+ com.sun.star.beans.XPropertySet xProp = (com.sun.star.beans.XPropertySet)
+ UnoRuntime.queryInterface( com.sun.star.beans.XPropertySet.class, xController );
+ xProp.setPropertyValue( "ShowGrid", new Boolean(true) );
+ xProp.setPropertyValue( "GridColor", new Integer(0x00CC00) );
+
+ // --- Range selection ---
+ // let the user select a range and use it as the view's selection
+ com.sun.star.sheet.XRangeSelection xRngSel = (com.sun.star.sheet.XRangeSelection)
+ 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 = new 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 = (com.sun.star.view.XSelectionSupplier)
+ UnoRuntime.queryInterface( com.sun.star.view.XSelectionSupplier.class, xController );
+ com.sun.star.sheet.XSpreadsheetView xView = (com.sun.star.sheet.XSpreadsheetView)
+ 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 )
+ {
+ }
+ }
+
+// ________________________________________________________________
+
+}
diff --git a/odk/examples/DevelopersGuide/Spreadsheet/XExampleAddIn.idl b/odk/examples/DevelopersGuide/Spreadsheet/XExampleAddIn.idl
new file mode 100644
index 000000000000..7834fc8b3c6d
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Spreadsheet/XExampleAddIn.idl
@@ -0,0 +1,60 @@
+/*************************************************************************
+ *
+ * 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
+
diff --git a/odk/examples/DevelopersGuide/Spreadsheet/makefile.mk b/odk/examples/DevelopersGuide/Spreadsheet/makefile.mk
new file mode 100644
index 000000000000..e853066e8ecf
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Spreadsheet/makefile.mk
@@ -0,0 +1,72 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ=..$/..$/..
+PRJNAME=odk
+TARGET=copying
+
+#----------------------------------------------------------------
+.INCLUDE: settings.mk
+.INCLUDE: $(PRJ)$/util$/makefile.pmk
+#----------------------------------------------------------------
+
+#----------------------------------------------------
+# this makefile is only used for copying the example
+# files into the SDK
+#----------------------------------------------------
+
+SPREADSHEET_FILES=\
+ $(DESTDIRDEVGUIDEEXAMPLES)$/Spreadsheet$/ExampleAddIn.java \
+ $(DESTDIRDEVGUIDEEXAMPLES)$/Spreadsheet$/ExampleAddIn.ods \
+ $(DESTDIRDEVGUIDEEXAMPLES)$/Spreadsheet$/ExampleDataPilotSource.java \
+ $(DESTDIRDEVGUIDEEXAMPLES)$/Spreadsheet$/GeneralTableSample.java \
+ $(DESTDIRDEVGUIDEEXAMPLES)$/Spreadsheet$/Makefile \
+ $(DESTDIRDEVGUIDEEXAMPLES)$/Spreadsheet$/SpreadsheetDocHelper.java \
+ $(DESTDIRDEVGUIDEEXAMPLES)$/Spreadsheet$/SpreadsheetSample.java \
+ $(DESTDIRDEVGUIDEEXAMPLES)$/Spreadsheet$/ViewSample.java \
+ $(DESTDIRDEVGUIDEEXAMPLES)$/Spreadsheet$/XExampleAddIn.idl \
+ $(DESTDIRDEVGUIDEEXAMPLES)$/Spreadsheet$/DataPilotReadme.txt
+
+DIR_FILE_LIST= \
+ $(SPREADSHEET_FILES) \
+
+DIR_DIRECTORY_LIST=$(uniq $(DIR_FILE_LIST:d))
+DIR_CREATE_FLAG=$(MISC)$/devguide_spreadsheet_dirs_created.txt
+DIR_FILE_FLAG=$(MISC)$/devguide_spreadsheet.txt
+
+#--------------------------------------------------
+# TARGETS
+#--------------------------------------------------
+all : \
+ $(DIR_FILE_LIST) \
+ $(DIR_FILE_FLAG)
+
+#--------------------------------------------------
+# use global rules
+#--------------------------------------------------
+.INCLUDE: $(PRJ)$/util$/odk_rules.pmk
+
diff --git a/odk/examples/DevelopersGuide/Text/Makefile b/odk/examples/DevelopersGuide/Text/Makefile
new file mode 100644
index 000000000000..3f192809d16f
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Text/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 Text example of the Developers Guide.
+
+PRJ=../../..
+SETTINGS=$(PRJ)/settings
+
+include $(SETTINGS)/settings.mk
+include $(SETTINGS)/std.mk
+include $(SETTINGS)/dk.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 000000000000..1b02d883a52b
--- /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 000000000000..4696b41ffe59
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Text/TextDocuments.java
@@ -0,0 +1,1792 @@
+/*************************************************************************
+ *
+ * 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.Point;
+import com.sun.star.awt.Size;
+import com.sun.star.awt.FontWeight;
+
+import com.sun.star.beans.PropertyState;
+import com.sun.star.beans.PropertyValue;
+import com.sun.star.beans.XPropertySet;
+import com.sun.star.beans.XPropertyState;
+
+import com.sun.star.bridge.XUnoUrlResolver;
+
+import com.sun.star.comp.servicemanager.ServiceManager;
+
+import com.sun.star.connection.XConnector;
+import com.sun.star.connection.XConnection;
+
+import com.sun.star.container.XNameAccess;
+import com.sun.star.container.XNameContainer;
+import com.sun.star.container.XNamed;
+import com.sun.star.container.XIndexAccess;
+import com.sun.star.container.XIndexReplace;
+import com.sun.star.container.XEnumeration;
+import com.sun.star.container.XEnumerationAccess;
+
+import com.sun.star.drawing.XShape;
+import com.sun.star.drawing.XShapeGrouper;
+import com.sun.star.drawing.XShapes;
+import com.sun.star.drawing.XDrawPageSupplier;
+
+import com.sun.star.frame.XDesktop;
+import com.sun.star.frame.XComponentLoader;
+import com.sun.star.frame.XModel;
+import com.sun.star.frame.XController;
+
+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.table.XCell;
+
+import com.sun.star.text.ControlCharacter;
+import com.sun.star.text.ReferenceFieldSource;
+import com.sun.star.text.ReferenceFieldPart;
+import com.sun.star.text.TextColumn;
+import com.sun.star.text.TextContentAnchorType;
+import com.sun.star.text.XAutoTextContainer;
+import com.sun.star.text.XAutoTextGroup;
+import com.sun.star.text.XAutoTextEntry;
+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.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.XTextFrame;
+import com.sun.star.text.XTextRange;
+import com.sun.star.text.XTextSection;
+import com.sun.star.text.XTextTable;
+import com.sun.star.text.XTextTableCursor;
+import com.sun.star.text.XTextTablesSupplier;
+import com.sun.star.text.XTextFieldsSupplier;
+import com.sun.star.text.XBookmarksSupplier;
+import com.sun.star.text.XTextViewCursorSupplier;
+import com.sun.star.text.XTextViewCursor;
+import com.sun.star.text.XPageCursor;
+
+import com.sun.star.text.XWordCursor;
+
+import com.sun.star.uno.AnyConverter;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.XComponentContext;
+import com.sun.star.uno.XInterface;
+import com.sun.star.uno.XNamingService;
+
+import com.sun.star.util.XRefreshable;
+
+import com.sun.star.frame.XStorable;
+import com.sun.star.view.XPrintable;
+
+import java.lang.Math;
+import java.util.Random;
+import java.util.Hashtable;
+
+/*
+ * TextDocuments.java
+ *
+ * Created on 11. April 2002, 08:47
+ */
+
+/**
+ *
+ * @author Martin Gallwey, Dietrich Schulten
+ */
+public class TextDocuments {
+ // adjust these constant to your local printer!
+ private static String sOutputDir;
+
+ private 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 XPropertySet mxDocProps = null;
+ private XText mxDocText = null;
+ private XTextCursor mxDocCursor = null;
+ private XTextContent mxFishSection = null;
+ private Random maRandom = null;
+
+ /** Creates a new instance of TextDocuments */
+ public TextDocuments() {
+ }
+
+ /**
+ * @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
+ Hashtable recipient = new Hashtable();
+ 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 = (XTextFieldsSupplier)
+ UnoRuntime.queryInterface(XTextFieldsSupplier.class,
+ xTemplateComponent);
+ XBookmarksSupplier 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
+ java.util.Enumeration keys = recipient.keys();
+ while(keys.hasMoreElements()) {
+ // get column name
+ String key = (String)keys.nextElement();
+
+ // 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 = (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 = (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 = (XTextContent)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 = (XDesktop)UnoRuntime.queryInterface(
+ XDesktop.class, desktop);
+ // retrieve the current component and access the controller
+ XComponent xCurrentComponent = xDesktop.getCurrentComponent();
+ XModel xModel = (XModel)UnoRuntime.queryInterface(XModel.class,
+ xCurrentComponent);
+ XController xController = xModel.getCurrentController();
+ // the controller gives us the TextViewCursor
+ XTextViewCursorSupplier xViewCursorSupplier =
+ (XTextViewCursorSupplier)UnoRuntime.queryInterface(
+ XTextViewCursorSupplier.class, xController);
+ XTextViewCursor xViewCursor = xViewCursorSupplier.getViewCursor();
+
+ // query its XPropertySet interface, we want to set character and paragraph
+ // properties
+ XPropertySet xCursorPropertySet = (XPropertySet)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 = (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 = (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 = (XTextDocument)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
+ mxDocProps = (XPropertySet) 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 = (XMultiServiceFactory) UnoRuntime.queryInterface(
+ XMultiServiceFactory.class, mxDoc );
+
+ // Examples of text fields, dependant 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 = (XMultiServiceFactory)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 = (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.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 = (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 = (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 = new 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 = (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 = (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 refering 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 refering 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 = (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 = (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 = (XPropertySet) 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 it's XTextField interface
+ XTextField xDateField = (XTextField) 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 it's XDependentTextField interface
+ XDependentTextField xUserField =
+ (XDependentTextField) UnoRuntime.queryInterface (
+ XDependentTextField.class, mxDocFactory.createInstance (
+ "com.sun.star.text.TextField.User" ) );
+
+ // Create a fieldmaster for our newly created User Text field, and
+ // access it's XPropertySet interface
+ XPropertySet xMasterPropSet = (XPropertySet)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", new Integer ( 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 = (XEnumerationAccess)
+ 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 = (XServiceInfo) 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 = (XPropertySet) 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 refered 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 = (XText) 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 = (XPropertySet)UnoRuntime.queryInterface(
+ XPropertySet.class, xCellCursor );
+
+ try
+ {
+ // Set the colour of the text to white
+ xCellCursorProps.setPropertyValue( "CharColor", new Integer(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 = (XTextTable) 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 = (XPropertySet) UnoRuntime.queryInterface(
+ XPropertySet.class, xRows.getByIndex ( 0 ) );
+ // If BackTransparant is false, then the background color is visible
+ xRow.setPropertyValue( "BackTransparent", new Boolean(false));
+ // Specify the color of the background to be dark blue
+ xRow.setPropertyValue( "BackColor", new Integer(6710932));
+
+ // Access the property set of the whole table
+ XPropertySet xTableProps = (XPropertySet)UnoRuntime.queryInterface(
+ XPropertySet.class, xTable );
+ // We want visible background colors
+ xTableProps.setPropertyValue( "BackTransparent", new Boolean(false));
+ // Set the background colour to light blue
+ xTableProps.setPropertyValue( "BackColor", new Integer(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 it's XTextFrame interface
+ XTextFrame xFrame = (XTextFrame) UnoRuntime.queryInterface (
+ XTextFrame.class, mxDocFactory.createInstance (
+ "com.sun.star.text.TextFrame" ) );
+
+ // Access the XShape interface of the TextFrame
+ XShape xShape = (XShape)UnoRuntime.queryInterface(XShape.class, xFrame);
+ // Access the XPropertySet interface of the TextFrame
+ XPropertySet xFrameProps = (XPropertySet)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 = (XParagraphCursor)
+ UnoRuntime.queryInterface(XParagraphCursor.class, mxDocCursor );
+ xParaCursor.gotoPreviousParagraph ( false );
+
+ // Get an XNameAccess interface to all auto text groups from the
+ // document factory
+ XNameAccess xContainer = (XNameAccess) UnoRuntime.queryInterface(
+ XNameAccess.class, mxFactory.createInstance (
+ "com.sun.star.text.AutoTextContainer" ) );
+
+ // Create a new table at the document factory
+ XTextTable xTable = (XTextTable) 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 = (XPropertySet)UnoRuntime.queryInterface(
+ XPropertySet.class, xTable );
+
+ // We want a visible background
+ xTableProps.setPropertyValue( "BackTransparent",
+ new Boolean(false));
+
+ // We want the background to be light blue
+ xTableProps.setPropertyValue( "BackColor", new Integer(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 = (XPropertySet) UnoRuntime.queryInterface(
+ XPropertySet.class, xRows.getByIndex ( 0 ) );
+
+ // We want the background of the first row to be visible too
+ xRow.setPropertyValue( "BackTransparent", new Boolean(false));
+
+ // And let's make it dark blue
+ xRow.setPropertyValue( "BackColor", new Integer(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 = (XText) 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 = (XAutoTextGroup)
+ 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 seperate 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 seperate 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 = (XText) 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 = ( XAutoTextGroup ) 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 containg blocks...
+ if ( aBlockNames.length > 0 )
+ {
+ // Pick a random block in this group and get it's
+ // XAutoTextEntry interface
+ int nRandom = Math.abs ( maRandom.nextInt()
+ % aBlockNames.length );
+ XAutoTextEntry xEntry = ( XAutoTextEntry )
+ 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 = ( XNamed ) 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 = (XParagraphCursor)
+ UnoRuntime.queryInterface( XParagraphCursor.class, mxDocCursor );
+ xParaCursor.gotoPreviousParagraph ( false );
+
+ // Create a new ContentIndexMark and get it's XPropertySet interface
+ XPropertySet xEntry = (XPropertySet)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", new Short ( (short) 1 ) );
+
+ // Create a ContentIndex and access it's XPropertySet interface
+ XPropertySet xIndex = (XPropertySet) UnoRuntime.queryInterface(
+ XPropertySet.class,
+ mxDocFactory.createInstance ( "com.sun.star.text.ContentIndex" ) );
+
+ // Again, the Level property _must_ be set
+ xIndex.setPropertyValue ( "Level", new Short ( (short) 10 ) );
+
+ // Access the XTextContent interfaces of both the Index and the
+ // IndexMark
+ XTextContent xIndexContent = (XTextContent) UnoRuntime.queryInterface(
+ XTextContent.class, xIndex );
+ XTextContent xEntryContent = (XTextContent) 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 = (XDocumentIndex) UnoRuntime.queryInterface(
+ XDocumentIndex.class, xIndex );
+
+ // And call it's 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 = (XParagraphCursor)
+ UnoRuntime.queryInterface( XParagraphCursor.class, mxDocCursor );
+
+ // Move the cursor into the new paragraph
+ xParaCursor.gotoPreviousParagraph ( false );
+
+ // Create a new ReferenceMark and get it's XNamed interface
+ XNamed xRefMark = (XNamed) 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 = ( XTextTablesSupplier )
+ UnoRuntime.queryInterface(XTextTablesSupplier.class, mxDoc);
+
+ // Get an XIndexAccess of TextTables
+ XIndexAccess xTables = (XIndexAccess)UnoRuntime.queryInterface(
+ XIndexAccess.class, xTableSupplier.getTextTables());
+
+ // We've only inserted one table, so get the first one from index zero
+ XTextTable xTable = ( XTextTable ) UnoRuntime.queryInterface (
+ XTextTable.class, xTables.getByIndex( 0 ) );
+
+ // Get the first cell from the table
+ XText xTableText = (XText) 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 = ( XTextContent ) 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 it's XPropertySet interface
+ XPropertySet xFieldProps = (XPropertySet) UnoRuntime.queryInterface(
+ XPropertySet.class, mxDocFactory.createInstance (
+ "com.sun.star.text.TextField.GetReference" ) );
+
+ // Get the XReferenceMarksSupplier interface of the document
+ XReferenceMarksSupplier xRefSupplier = ( XReferenceMarksSupplier )
+ UnoRuntime.queryInterface( XReferenceMarksSupplier.class, mxDoc );
+
+ // Get an XNameAccess which refers to all inserted reference marks
+ XNameAccess xMarks = ( XNameAccess ) 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",
+ new Short(ReferenceFieldSource.REFERENCE_MARK));
+
+ // We want the reference displayed as 'above' or 'below'
+ xFieldProps.setPropertyValue ( "ReferenceFieldPart",
+ new Short(ReferenceFieldPart.UP_DOWN));
+
+
+ // Get the XTextContent interface of the GetReference text field
+ XTextContent xRefContent = (XTextContent) 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 = (XRefreshable) 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 it's
+ // XFootnote interface
+ XFootnote 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 = ( XTextContent ) UnoRuntime.queryInterface (
+ XTextContent.class, xFootnote );
+
+ // ...insert it into the document
+ mxDocText.insertTextContent ( mxDocCursor, xContent, false );
+
+ // Get the XFootnotesSupplier interface of the document
+ XFootnotesSupplier xFootnoteSupplier = (XFootnotesSupplier)
+ UnoRuntime.queryInterface(XFootnotesSupplier.class, mxDoc );
+
+ // Get an XIndexAccess interface to all footnotes
+ XIndexAccess xFootnotes = ( XIndexAccess ) UnoRuntime.queryInterface (
+ XIndexAccess.class, xFootnoteSupplier.getFootnotes() );
+
+ // Get the XFootnote interface to the first footnote inserted ('Numbers')
+ XFootnote xNumbers = ( XFootnote ) UnoRuntime.queryInterface (
+ XFootnote.class, xFootnotes.getByIndex( 0 ) );
+
+ // Get the XSimpleText interface to the Footnote
+ XSimpleText xSimple = (XSimpleText ) UnoRuntime.queryInterface (
+ XSimpleText.class, xNumbers );
+
+ // Create a text cursor for the foot note text
+ XTextRange xRange = (XTextRange ) 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 = (XParagraphCursor)
+ UnoRuntime.queryInterface( XParagraphCursor.class, mxDocCursor );
+
+ // Position the cursor in the 2nd paragraph
+ xParaCursor.gotoPreviousParagraph ( false );
+
+ // Create a RectangleShape using the document factory
+ XShape xRect = (XShape) UnoRuntime.queryInterface(
+ XShape.class, mxDocFactory.createInstance (
+ "com.sun.star.drawing.RectangleShape" ) );
+
+ // Create an EllipseShape using the document factory
+ XShape xEllipse = (XShape) 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 = (XPropertySet) UnoRuntime.queryInterface(
+ XPropertySet.class, xRect );
+ XPropertySet xEllipseProps = (XPropertySet) 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 = (XDrawPageSupplier)
+ UnoRuntime.queryInterface (XDrawPageSupplier.class, mxDoc );
+
+ // Get the XShapes interface of the draw page
+ XShapes 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 = (XStyle) UnoRuntime.queryInterface(
+ XStyle.class, mxDocFactory.createInstance(
+ "com.sun.star.style.ParagraphStyle" ) );
+
+ // Access the XPropertySet interface of the new style
+ XPropertySet xStyleProps = (XPropertySet) UnoRuntime.queryInterface(
+ XPropertySet.class, xStyle );
+
+ // Give the new style a light blue background
+ xStyleProps.setPropertyValue ( "ParaBackColor", new Integer (13421823));
+
+ // Get the StyleFamiliesSupplier interface of the document
+ XStyleFamiliesSupplier xSupplier = (XStyleFamiliesSupplier)
+ UnoRuntime.queryInterface(XStyleFamiliesSupplier.class, mxDoc);
+
+ // Use the StyleFamiliesSupplier interface to get the XNameAccess
+ // interface of the actual style families
+ XNameAccess xFamilies = ( XNameAccess ) UnoRuntime.queryInterface (
+ XNameAccess.class, xSupplier.getStyleFamilies() );
+
+ // Access the 'ParagraphStyles' Family
+ XNameContainer xFamily = (XNameContainer ) 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 = (XParagraphCursor)
+ 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 = (XPropertySet) 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 it's 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 =
+ (XRelativeTextContentInsert ) UnoRuntime.queryInterface (
+ XRelativeTextContentInsert.class, mxDocText );
+
+ // Use the document's factory to create the NumberingRules service,
+ // and get it's XIndexAccess interface
+ XIndexAccess xNum = (XIndexAccess) UnoRuntime.queryInterface(
+ XIndexAccess.class,
+ mxDocFactory.createInstance( "com.sun.star.text.NumberingRules" ) );
+
+ // Also get the NumberingRule's XIndexReplace interface
+ XIndexReplace xReplace = (XIndexReplace) 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 = (XTextContent) 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] = (XPropertySet) 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 it's value to a new type,
+ // dependent on which numbering level we're currently on
+ switch ( i )
+ {
+ case 0 : aProps[j].Value =
+ new Short(NumberingType.ROMAN_UPPER);
+ break;
+ case 1 : aProps[j].Value =
+ new Short(NumberingType.CHARS_UPPER_LETTER);
+ break;
+ case 2 : aProps[j].Value =
+ new Short(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 cursro
+ XParagraphCursor xParaCursor = (XParagraphCursor)
+ 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 = (XPropertySet) 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", new Short((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", new Short((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", new Short((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
+ // it's XNamed interface
+ XNamed xChildNamed = (XNamed) 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 = (XTextContent) UnoRuntime.queryInterface(
+ XTextContent.class, xChildNamed );
+ mxDocText.insertTextContent ( mxDocCursor, xChildSection, false );
+
+ // Access the XParagraphCursor interface of our text cursor
+ XParagraphCursor xParaCursor = (XParagraphCursor)
+ 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 it's XNamed interface
+ XNamed xParentNamed = (XNamed) 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 = (XTextContent) 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 pargraph
+ xParaCursor.gotoPreviousParagraph ( true );
+
+ // Create a new Text Section and access it's XNamed interface
+ XNamed xLinkNamed = (XNamed) 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 = (XTextContent) 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 = (XPropertySet)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 = (XPropertySet) UnoRuntime.queryInterface(
+ XPropertySet.class, xChildNamed );
+ // Set the Child_Section's background colour to blue
+ xChildProps.setPropertyValue( "BackColor", new Integer(13421823));
+
+ // Refresh the document, so the linked section matches the Child_Section
+ XRefreshable xRefresh = (XRefreshable) 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 doucment
+ 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 = (XParagraphCursor)
+ 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 it's XNamed interface
+ XNamed xSectionNamed = (XNamed) UnoRuntime.queryInterface(XNamed.class,
+ mxDocFactory.createInstance("com.sun.star.text.TextSection"));
+
+ // Set the name of our new section (appropiately) to 'Fish'
+ xSectionNamed.setName ( "Fish" );
+
+ // Create the TextColumns service and get it's XTextColumns interface
+ XTextColumns xColumns = (XTextColumns) 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 = (XPropertySet) 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 = (XTextContent) 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 = (XRelativeTextContentInsert )
+ UnoRuntime.queryInterface (
+ XRelativeTextContentInsert.class, mxDocText );
+
+ // Create a new empty paragraph and get it's XTextContent interface
+ XTextContent xNewPara = (XTextContent) 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();
+ }
+ }
+}
diff --git a/odk/examples/DevelopersGuide/Text/TextTemplateWithUserFields.odt b/odk/examples/DevelopersGuide/Text/TextTemplateWithUserFields.odt
new file mode 100644
index 000000000000..7c6814039c9e
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Text/TextTemplateWithUserFields.odt
Binary files differ
diff --git a/odk/examples/DevelopersGuide/Text/makefile.mk b/odk/examples/DevelopersGuide/Text/makefile.mk
new file mode 100644
index 000000000000..dbb2000e941d
--- /dev/null
+++ b/odk/examples/DevelopersGuide/Text/makefile.mk
@@ -0,0 +1,67 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ=..$/..$/..
+PRJNAME=odk
+TARGET=copying
+
+#----------------------------------------------------------------
+.INCLUDE: settings.mk
+.INCLUDE: $(PRJ)$/util$/makefile.pmk
+#----------------------------------------------------------------
+
+#----------------------------------------------------
+# this makefile is only used for copying the example
+# files into the SDK
+#----------------------------------------------------
+
+TEXT_FILES=\
+ $(DESTDIRDEVGUIDEEXAMPLES)$/Text$/Makefile \
+ $(DESTDIRDEVGUIDEEXAMPLES)$/Text$/PrintDemo.odt \
+ $(DESTDIRDEVGUIDEEXAMPLES)$/Text$/TextDocuments.java \
+ $(DESTDIRDEVGUIDEEXAMPLES)$/Text$/TextTemplateWithUserFields.odt
+# $(DESTDIRDEVGUIDEEXAMPLES)$/Text$/ViewCursorExample.sxw
+
+DIR_FILE_LIST= \
+ $(TEXT_FILES) \
+
+DIR_DIRECTORY_LIST=$(uniq $(DIR_FILE_LIST:d))
+DIR_CREATE_FLAG=$(MISC)$/devguide_text_dirs_created.txt
+DIR_FILE_FLAG=$(MISC)$/devguide_text.txt
+
+#--------------------------------------------------
+# TARGETS
+#--------------------------------------------------
+all : \
+ $(DIR_FILE_LIST) \
+ $(DIR_FILE_FLAG)
+
+#--------------------------------------------------
+# use global rules
+#--------------------------------------------------
+.INCLUDE: $(PRJ)$/util$/odk_rules.pmk
+
diff --git a/odk/examples/DevelopersGuide/UCB/ChildrenRetriever.java b/odk/examples/DevelopersGuide/UCB/ChildrenRetriever.java
new file mode 100644
index 000000000000..24d627111f38
--- /dev/null
+++ b/odk/examples/DevelopersGuide/UCB/ChildrenRetriever.java
@@ -0,0 +1,348 @@
+/*************************************************************************
+ *
+ * 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.ucb.XContentAccess;
+import com.sun.star.ucb.XDynamicResultSet;
+import com.sun.star.beans.Property;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.sdbc.XRow;
+import com.sun.star.sdbc.XResultSet;
+
+import java.util.Vector;
+import java.util.Enumeration;
+import java.util.StringTokenizer;
+
+/**
+ * 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 Vector m_propnames = new Vector();
+
+ /**
+ * Constructor. Create a new connection with the specific args to a running office
+ *
+ *@param String[] This construtor requires the arguments:
+ * -url=... (optional)
+ * -propNames=... (optional)
+ * See Help (method printCmdLineUsage()).
+ * Without the arguments a new connection to a
+ * running office cannot created.
+ *@exception java.lang.Exception
+ */
+ 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 Vector Returns children properties values if values successfully retrieved,
+ * null otherwise
+ *@exception com.sun.star.ucb.CommandAbortedException
+ *@exception com.sun.star.uno.Exception
+ */
+ public Vector getChildren()
+ throws com.sun.star.ucb.CommandAbortedException, com.sun.star.uno.Exception {
+ Vector properties = getProperties();
+ return getChildren ( properties );
+ }
+
+ /**
+ * Open a folder content, get properties values for the properties.
+ *
+ *@param Vector Properties
+ *@return Vector Returns children properties values if values successfully retrieved,
+ * null otherwise
+ *@exception com.sun.star.ucb.CommandAbortedException
+ *@exception com.sun.star.uno.Exception
+ */
+ public Vector getChildren( Vector properties )
+ throws com.sun.star.ucb.CommandAbortedException, com.sun.star.uno.Exception {
+
+ Vector 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 = ( String )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; // Final static for 32768
+ arg.Properties = props;
+
+ XDynamicResultSet set;
+
+ // Execute command "open".
+ set = ( XDynamicResultSet )UnoRuntime.queryInterface(
+ XDynamicResultSet.class, m_helper.executeCommand( m_content, "open", arg ));
+ XResultSet resultSet = ( XResultSet )set.getStaticResultSet();
+
+ result = new Vector();
+
+ /////////////////////////////////////////////////////////////////////
+ // Iterate over children, access children and property values...
+ /////////////////////////////////////////////////////////////////////
+
+ // Move to begin.
+ if ( resultSet.first() ) {
+ XContentAccess contentAccess = ( XContentAccess )UnoRuntime.queryInterface(
+ XContentAccess.class, resultSet );
+ XRow row = ( XRow )UnoRuntime.queryInterface( XRow.class, resultSet );
+
+ do {
+ Vector propsValues = new Vector();
+
+ // 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 Vector getProperties() {
+ return m_propnames;
+ }
+
+ /**
+ * Parse arguments
+ *
+ *@param String[] Arguments
+ *@exception java.lang.Exception
+ */
+ 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 .
+ *
+ *@param Vector
+ */
+ public void printLine( Vector 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.
+ *
+ *@param String[] Arguments
+ */
+ 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.
+ Vector 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() ) {
+
+ Vector cont = new Vector();
+ cont.add("URL:");
+ Vector 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 ( Enumeration e = result.elements(); e.hasMoreElements(); ) {
+ Vector propsV = ( Vector )e.nextElement();
+ 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 );
+ }
+}
diff --git a/odk/examples/DevelopersGuide/UCB/DataStreamComposer.java b/odk/examples/DevelopersGuide/UCB/DataStreamComposer.java
new file mode 100644
index 000000000000..2d67cde0e4ae
--- /dev/null
+++ b/odk/examples/DevelopersGuide/UCB/DataStreamComposer.java
@@ -0,0 +1,258 @@
+/*************************************************************************
+ *
+ * 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 String[] This construtor 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.
+ *@exception java.lang.Exception
+ */
+ 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
+ *@exception com.sun.star.ucb.CommandAbortedException
+ *@exception com.sun.star.uno.Exception
+ *@exception java.lang.Exception
+ */
+ 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 String Source URL
+ *@return boolean Returns true if data stream successfully seted, false otherwise
+ *@exception com.sun.star.ucb.CommandAbortedException
+ *@exception com.sun.star.uno.Exception
+ *@exception java.lang.Exception
+ */
+ 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...
+ *
+ *@param XInputStream Stream
+ *@return boolean Returns true if data stream successfully seted, false otherwise
+ *@exception com.sun.star.ucb.CommandAbortedException
+ *@exception com.sun.star.uno.Exception
+ */
+ 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
+ *
+ *@param String[] Arguments
+ *@exception java.lang.Exception
+ */
+ 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.
+ *
+ *@param String[] Arguments
+ */
+ 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 );
+ }
+}
diff --git a/odk/examples/DevelopersGuide/UCB/DataStreamRetriever.java b/odk/examples/DevelopersGuide/UCB/DataStreamRetriever.java
new file mode 100644
index 000000000000..84529ab39533
--- /dev/null
+++ b/odk/examples/DevelopersGuide/UCB/DataStreamRetriever.java
@@ -0,0 +1,233 @@
+/*************************************************************************
+ *
+ * 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 String[] This construtor requires the arguments:
+ * -url=... (optional)
+ * See Help (method printCmdLineUsage()).
+ * Without the arguments a new connection to a
+ * running office cannot created.
+ *@exception java.lang.Exception
+ */
+ 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
+ *@exception com.sun.star.ucb.CommandAbortedException
+ *@exception com.sun.star.uno.Exception
+ */
+ 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; // Final static 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 String[] Arguments
+ *@exception java.lang.Exception
+ */
+ 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( "-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
+ */
+ public 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.
+ *
+ *@param XInputStream
+ *@exception com.sun.star.uno.Exception
+ */
+ public 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.
+ *
+ *@param String[] Arguments
+ */
+ 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 );
+ }
+}
diff --git a/odk/examples/DevelopersGuide/UCB/Helper.java b/odk/examples/DevelopersGuide/UCB/Helper.java
new file mode 100644
index 000000000000..ea5f5536365b
--- /dev/null
+++ b/odk/examples/DevelopersGuide/UCB/Helper.java
@@ -0,0 +1,250 @@
+/*************************************************************************
+ *
+ * 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.Vector;
+
+import java.io.File;
+import java.io.FileOutputStream;
+
+import com.sun.star.lang.XMultiComponentFactory;
+
+import com.sun.star.ucb.Command;
+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 manger is used to create the ucb. If necessary
+ * a new office process is started.
+ *
+ * @exception java.lang.Exception
+ */
+ 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 ...");
+ }
+
+ XMultiComponentFactory xMCF = m_xContext.getServiceManager();
+
+ m_ucb = (XInterface)UnoRuntime.queryInterface(XInterface.class,
+ xMCF.createInstanceWithContext(
+ "com.sun.star.ucb.UniversalContentBroker", m_xContext));
+ }
+
+ /**
+ * Returns created identifier object for given URL..
+ *
+ *@return XContent Created identifier object for given URL
+ *@exception java.lang.Exception
+ */
+ public XContent createUCBContent() throws java.lang.Exception {
+ return createUCBContent( getContentURL() );
+ }
+
+ /**
+ * Returned created identifier object for given URL.
+ *
+ *@param String Connect URL. Example : -url=file:///
+ *@return XContent Created identifier object for given URL
+ *@exception java.lang.Exception
+ */
+ public XContent createUCBContent( String connectURL ) throws java.lang.Exception {
+ XContent content = null;
+ if ( connectURL != null && !connectURL.equals( "" )) {
+
+ // Obtain required UCB interfaces...
+ XContentIdentifierFactory idFactory
+ = ( XContentIdentifierFactory )UnoRuntime.queryInterface(
+ XContentIdentifierFactory.class, m_ucb );
+ XContentProvider provider
+ = ( XContentProvider )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
+ = (XCommandProcessor)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.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 new String();
+ }
+
+ 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.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 = new String(
+ "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 new String();
+ }
+}
diff --git a/odk/examples/DevelopersGuide/UCB/Makefile b/odk/examples/DevelopersGuide/UCB/Makefile
new file mode 100644
index 000000000000..a6b172bfa602
--- /dev/null
+++ b/odk/examples/DevelopersGuide/UCB/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 UCB examples of the Developers Guide.
+
+PRJ=../../..
+SETTINGS=$(PRJ)/settings
+
+include $(SETTINGS)/settings.mk
+include $(SETTINGS)/std.mk
+include $(SETTINGS)/dk.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 000000000000..4d111dc740a8
--- /dev/null
+++ b/odk/examples/DevelopersGuide/UCB/MyActiveDataSink.java
@@ -0,0 +1,73 @@
+/*************************************************************************
+ *
+ * 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
+ */
+ XInputStream m_aStream = null;
+
+ /**
+ * Constructor
+ */
+ public MyActiveDataSink() {
+ super();
+ }
+
+ /**
+ * Plugs the input stream.
+ *
+ *@param XInputStream
+ */
+ public void setInputStream( XInputStream aStream ) {
+ m_aStream = aStream;
+ }
+
+ /**
+ * Get the plugged stream.
+ *
+ *@return XInputStream The plugged stream
+ */
+ public XInputStream getInputStream() {
+ return m_aStream;
+ }
+}
diff --git a/odk/examples/DevelopersGuide/UCB/MyInputStream.java b/odk/examples/DevelopersGuide/UCB/MyInputStream.java
new file mode 100644
index 000000000000..d3c701c71776
--- /dev/null
+++ b/odk/examples/DevelopersGuide/UCB/MyInputStream.java
@@ -0,0 +1,190 @@
+/*************************************************************************
+ *
+ * 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.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.
+ *
+ *@param long
+ */
+ 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.
+ *
+ *@param byte[][]
+ *@param int
+ *@return int
+ */
+ 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.
+ *
+ *@param byte[][]
+ *@param int
+ *@return int
+ */
+ 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.
+ *
+ *@param int
+ */
+ 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;
+ }
+}
diff --git a/odk/examples/DevelopersGuide/UCB/PropertiesComposer.java b/odk/examples/DevelopersGuide/UCB/PropertiesComposer.java
new file mode 100644
index 000000000000..3807447a0dfa
--- /dev/null
+++ b/odk/examples/DevelopersGuide/UCB/PropertiesComposer.java
@@ -0,0 +1,299 @@
+/*************************************************************************
+ *
+ * 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.Vector;
+import java.util.StringTokenizer;
+
+import com.sun.star.beans.PropertyValue;
+import com.sun.star.ucb.XContent;
+import com.sun.star.uno.UnoRuntime;
+
+/**
+ * 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 Vector m_propNames = new Vector();
+ private Vector m_propValues = new Vector();
+
+ /**
+ * Constructor.
+ *
+ *@param String[] This construtor 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.
+ *@exception java.lang.Exception
+ */
+ 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
+ *@exception com.sun.star.ucb.CommandAbortedException
+ *@exception com.sun.star.uno.Exception
+ */
+ public Object[] setProperties()
+ throws com.sun.star.ucb.CommandAbortedException, com.sun.star.uno.Exception {
+ Vector properties = getProperties();
+ Vector propertyValues = getPropertyValues();
+ return setProperties( properties, propertyValues );
+ }
+
+ /**
+ * Set values of the properties.
+ *
+ *@param Vector Properties
+ *@param Vector Properties value
+ *@return Object[] Returns null or instance object of com.sun.star.uno.Any
+ * if values successfully seted, properties otherwise
+ *@exception com.sun.star.ucb.CommandAbortedException
+ *@exception com.sun.star.uno.Exception
+ */
+ public Object[] setProperties( Vector properties, Vector 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 = ( String )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 Vector getProperties() {
+ return m_propNames;
+ }
+
+ /**
+ * Get properties values.
+ *
+ *@return Vector That contains the properties values
+ */
+ public Vector getPropertyValues() {
+ return m_propValues;
+ }
+
+ /**
+ * Get connect URL.
+ *
+ *@return String That contains the connect URL
+ */
+ public String getContentURL() {
+ return m_contenturl;
+ }
+
+ /**
+ * Parse arguments
+ *
+ *@param String[] Arguments
+ *@exception java.lang.Exception
+ */
+ 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.
+ *
+ *@param String[] Arguments
+ */
+ 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 );
+ Vector properties = setProp.getProperties();
+ Vector 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 );
+ }
+}
diff --git a/odk/examples/DevelopersGuide/UCB/PropertiesRetriever.java b/odk/examples/DevelopersGuide/UCB/PropertiesRetriever.java
new file mode 100644
index 000000000000..2d000c1a3b90
--- /dev/null
+++ b/odk/examples/DevelopersGuide/UCB/PropertiesRetriever.java
@@ -0,0 +1,254 @@
+/*************************************************************************
+ *
+ * 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.Vector;
+import java.util.StringTokenizer;
+
+import com.sun.star.beans.Property;
+import com.sun.star.ucb.XContent;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.sdbc.XRow;
+
+
+/**
+ * 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 Vector m_propNames = new Vector();
+
+ /**
+ * Constructor.
+ *
+ *@param String[] This construtor requires the arguments:
+ * -url=... (optional)
+ * -propNames=... (optional)
+ * See Help (method printCmdLineUsage()).
+ * Without the arguments a new connection to a
+ * running office cannot created.
+ *@exception java.lang.Exception
+ */
+ 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.
+ *
+ *@param Vector Properties
+ *@return Vector Returns Properties values if values successfully retrieved, null otherwise
+ *@exception com.sun.star.ucb.CommandAbortedException
+ *@exception com.sun.star.uno.Exception
+ */
+ public Vector getPropertyValues()
+ throws com.sun.star.ucb.CommandAbortedException, com.sun.star.uno.Exception {
+ Vector properties = getProperties();
+ return getPropertyValues ( properties );
+ }
+
+ /**
+ * Get values of the properties.
+ *
+ *@param Vector Properties
+ *@return Vector Returns Properties values if values successfully retrieved, null otherwise
+ *@exception com.sun.star.ucb.CommandAbortedException
+ *@exception com.sun.star.uno.Exception
+ */
+ public Vector getPropertyValues( Vector properties )
+ throws com.sun.star.ucb.CommandAbortedException, com.sun.star.uno.Exception {
+ Vector 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 = ( String )properties.get( index );
+ prop.Handle = -1; // n/a
+ props[ index ] = prop;
+ }
+
+ // Execute command "getPropertyValues".
+ XRow values =
+ ( XRow )UnoRuntime.queryInterface(
+ XRow.class, m_helper.executeCommand( m_content,"getPropertyValues", props ));
+
+ m_propValues = new Vector();
+
+ /*
+ 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 Vector getProperties() {
+ return m_propNames;
+ }
+
+ /**
+ * Parse arguments
+ *
+ *@param String[] Arguments
+ *@exception java.lang.Exception
+ */
+ 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.
+ *
+ *@param String[] Arguments
+ */
+ 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 );
+ Vector properties = obtProperty.getProperties();
+ Vector 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 = ( String )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 );
+ }
+}
diff --git a/odk/examples/DevelopersGuide/UCB/ResourceCreator.java b/odk/examples/DevelopersGuide/UCB/ResourceCreator.java
new file mode 100644
index 000000000000..4dc1946c752e
--- /dev/null
+++ b/odk/examples/DevelopersGuide/UCB/ResourceCreator.java
@@ -0,0 +1,313 @@
+/*************************************************************************
+ *
+ * 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 String[] This construtor 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.
+ *@exception java.lang.Exception
+ */
+ 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
+ *@exception com.sun.star.ucb.CommandAbortedException
+ *@exception com.sun.star.uno.Exception
+ */
+ 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 String Source resource URL
+ *@param String New resource name
+ *@return boolean Returns true if resource successfully created, false otherwise
+ *@exception com.sun.star.ucb.CommandAbortedException
+ *@exception com.sun.star.uno.Exception
+ */
+ 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 XInputStream Source resource stream
+ *@param String New resource name
+ *@return boolean Returns true if resource successfully created, false otherwise
+ *@exception com.sun.star.ucb.CommandAbortedException
+ *@exception com.sun.star.uno.Exception
+ */
+ 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 = ( XContent )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
+ *
+ *@param String[] Arguments
+ *@exception java.lang.Exception
+ */
+ 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.
+ *
+ *@param String[] Arguments
+ */
+ 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 );
+ }
+}
diff --git a/odk/examples/DevelopersGuide/UCB/ResourceManager.java b/odk/examples/DevelopersGuide/UCB/ResourceManager.java
new file mode 100644
index 000000000000..bfe94ed59667
--- /dev/null
+++ b/odk/examples/DevelopersGuide/UCB/ResourceManager.java
@@ -0,0 +1,289 @@
+/*************************************************************************
+ *
+ * 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.UnoRuntime;
+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_srcURL = "";
+ private String m_targetFolderURL = "";
+ private String m_newTitle = "";
+ private String m_transOperation = "";
+
+ /**
+ * Constructor.
+ *
+ *@param String[] This construtor 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.
+ *@exception java.lang.Exception
+ */
+ 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 boolean Returns true if resource successfully transfered, false otherwise
+ *@exception com.sun.star.ucb.CommandAbortedException
+ *@exception com.sun.star.uno.Exception
+ */
+ 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 String Source URL
+ *@param String Target folder URL
+ *@param String Transfering operation (copy, move, link)
+ *@return boolean Returns true if resource successfully transfered, false otherwise
+ *@exception com.sun.star.ucb.CommandAbortedException
+ *@exception com.sun.star.uno.Exception
+ */
+ 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 trasfering Operation.
+ *
+ *@return String That contains the trasfering 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 transfered.
+ *
+ *@return String That contains a new title for the transfered
+ * 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
+ *
+ *@param String[] Arguments
+ *@exception java.lang.Exception
+ */
+ 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 = "transfered-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=transfered-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.
+ *
+ *@param String[] Arguments
+ */
+ 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( "\nTransfering resource succeeded." );
+ else
+ System.out.println( "Transfering 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 );
+ }
+}
diff --git a/odk/examples/DevelopersGuide/UCB/ResourceRemover.java b/odk/examples/DevelopersGuide/UCB/ResourceRemover.java
new file mode 100644
index 000000000000..f08740889cdb
--- /dev/null
+++ b/odk/examples/DevelopersGuide/UCB/ResourceRemover.java
@@ -0,0 +1,180 @@
+/*************************************************************************
+ *
+ * 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 String[] This construtor requires the arguments:
+ * -url=... (optional)
+ * -workdir=... (optional)
+ * See Help (method printCmdLineUsage()).
+ * Without the arguments a new connection to a
+ * running office cannot created.
+ *@exception java.lang.Exception
+ */
+ 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 boolean Returns true if resource successfully deleted, false otherwise
+ *@exception com.sun.star.ucb.CommandAbortedException
+ *@exception com.sun.star.uno.Exception
+ */
+ 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 = new 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
+ *
+ *@param String[] Arguments
+ *@exception java.lang.Exception
+ */
+ 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.
+ *
+ *@param String[] Arguments
+ */
+ 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 );
+ }
+}
diff --git a/odk/examples/DevelopersGuide/UCB/data/data.txt b/odk/examples/DevelopersGuide/UCB/data/data.txt
new file mode 100644
index 000000000000..dd47db97da34
--- /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/UCB/makefile.mk b/odk/examples/DevelopersGuide/UCB/makefile.mk
new file mode 100644
index 000000000000..c95d3769e49a
--- /dev/null
+++ b/odk/examples/DevelopersGuide/UCB/makefile.mk
@@ -0,0 +1,75 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ=..$/..$/..
+PRJNAME=odk
+TARGET=copying
+
+#----------------------------------------------------------------
+.INCLUDE: settings.mk
+.INCLUDE: $(PRJ)$/util$/makefile.pmk
+#----------------------------------------------------------------
+
+#----------------------------------------------------
+# this makefile is only used for copying the example
+# files into the SDK
+#----------------------------------------------------
+
+UCB_FILES=\
+ $(DESTDIRDEVGUIDEEXAMPLES)$/UCB$/data$/data.txt \
+ $(DESTDIRDEVGUIDEEXAMPLES)$/UCB$/ChildrenRetriever.java \
+ $(DESTDIRDEVGUIDEEXAMPLES)$/UCB$/DataStreamComposer.java \
+ $(DESTDIRDEVGUIDEEXAMPLES)$/UCB$/DataStreamRetriever.java \
+ $(DESTDIRDEVGUIDEEXAMPLES)$/UCB$/Helper.java \
+ $(DESTDIRDEVGUIDEEXAMPLES)$/UCB$/Makefile \
+ $(DESTDIRDEVGUIDEEXAMPLES)$/UCB$/MyActiveDataSink.java \
+ $(DESTDIRDEVGUIDEEXAMPLES)$/UCB$/MyInputStream.java \
+ $(DESTDIRDEVGUIDEEXAMPLES)$/UCB$/PropertiesComposer.java \
+ $(DESTDIRDEVGUIDEEXAMPLES)$/UCB$/PropertiesRetriever.java \
+ $(DESTDIRDEVGUIDEEXAMPLES)$/UCB$/ResourceCreator.java \
+ $(DESTDIRDEVGUIDEEXAMPLES)$/UCB$/ResourceManager.java \
+ $(DESTDIRDEVGUIDEEXAMPLES)$/UCB$/ResourceRemover.java
+
+DIR_FILE_LIST= \
+ $(UCB_FILES) \
+
+DIR_DIRECTORY_LIST=$(uniq $(DIR_FILE_LIST:d))
+DIR_CREATE_FLAG=$(MISC)$/devguide_ucb_dirs_created.txt
+DIR_FILE_FLAG=$(MISC)$/devguide_ucb.txt
+
+#--------------------------------------------------
+# TARGETS
+#--------------------------------------------------
+all : \
+ $(DIR_FILE_LIST) \
+ $(DIR_FILE_FLAG)
+
+#--------------------------------------------------
+# use global rules
+#--------------------------------------------------
+.INCLUDE: $(PRJ)$/util$/odk_rules.pmk
+
diff --git a/odk/examples/DevelopersGuide/examples.html b/odk/examples/DevelopersGuide/examples.html
new file mode 100644
index 000000000000..1a48788f0991
--- /dev/null
+++ b/odk/examples/DevelopersGuide/examples.html
@@ -0,0 +1,3032 @@
+<html>
+<head>
+ <title>OpenOffice.org 3.2 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=iso-8859-1">
+ <meta name="author" content="J&uuml;rgen Schmidt">
+ <meta name="created" content="2004-12-14">
+</head>
+<body class="sdkbody">
+<a name="examples"></a>
+<table class="table1" cellpadding="0">
+ <tbody>
+ <tr style="background-image:url(../../docs/images/sdk_head-2.png); backgorund-position: bottom; ">
+ <td class="background" colspan="3" align="left"><img src="../../docs/images/sdk_head-1.png" width="800" height="120" usemap="#Map" border="0"></td>
+ </tr>
+ <tr>
+ <td colspan="3"><img class="nothing10"
+ 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 colspan="3"><img class="nothing1"
+ src="../../docs/images/nada.gif"></td>
+ </tr>
+ <tr>
+ <td>
+ <table class="table3">
+ <tbody>
+ <tr>
+ <td colspan="2" class="head1">Developer's Guide
+Examples</td>
+ <td align="right"> <a href="../examples.html"
+ title="link to the examples overview"><img class="navigate"
+ src="../../docs/images/nav_left.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="table3">
+ <tbody>
+ <tr>
+ <td colspan="3">
+ <p>The <a
+ href="http://doc.services.openoffice.org/wiki/index.php/Documentation/DevGuide/OpenOffice.org_Developers_Guide"
+ 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 fo 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">OpenOffice.org 3.2 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%28UCB%29"
+ 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>
+ <td class="content3"><img
+ src="../../docs/images/arrow-1.gif"></td>
+ <td><a href="#Accessibility"
+ title="link to the Accessibility examples">Accessibility</a></td>
+ </tr>
+ <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>
+ </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="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 OpenOffice.org 3.2 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 OpenOffice.org 3.2 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 OpenOffice.org 3.2.</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
+OpenOffice.org 3.2 using the URL given on the command line. This example
+shows the usage of <a
+ href="../../docs/common/ref/com/sun/star/bridge/XUnoUrlResolver.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
+OpenOffice.org 3.2 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="../../docs/cpp/ref/names/rtl/c-OString.html"
+ title="link to the reference documentation of rtl::OString"><code>OString</code></a>,
+ <a href="../../docs/cpp/ref/names/rtl/c-OUString.html"
+ title="link to the reference documentation of rtl::OUString"><code>OUString</code></a>
+and <a href="../../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).</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="../../docs/common/ref/com/sun/star/lang/XTypeProvider.html"
+ title="link to the reference documentation of com.sun.star.lang.XTypeProvider"><code>XTypeProvider</code></a>,
+ <a
+ href="../../docs/common/ref/com/sun/star/lang/XServiceInfo.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="../../docs/common/ref/com/sun/star/lang/XTypeProvider.html"
+ title="link to the reference documentation of com.sun.star.lang.XTypeProvider">
+ <code>XTypeProvider</code></a>, <a
+ href="../../docs/common/ref/com/sun/star/lang/XServiceInfo.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 OpenOffice.org 3.2 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).</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 OpenOffice.org 3.2 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
+OpenOffice.org 3.2 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 OpenOffice.org 3.2.</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="../../docs/common/ref/com/sun/star/awt/XWindowPeer.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
+OpenOffice.org 3.2 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="../../docs/common/ref/com/sun/star/frame/FeatureStateEvent.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 OpenOffice.org 3.2 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
+OpenOffice.org 3.2 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="../../docs/common/ref/com/sun/star/frame/XTerminateListener.html"
+ title="link to the reference documentation of com.sun.star.frame.XTerminationListener">
+ <code>XTerminateListener</code></a>. It is called
+when OpenOffice.org 3.2 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 OpenOffice.org 3.2 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>
+ </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>
+ </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="../../docs/common/ref/com/sun/star/linguistic2/Hyphenator.html"
+ title="link to the reference documentation of com.sun.star.linguistic2.Hypenator"><code>Hyphenator</code></a>
+service.</td>
+ </tr>
+ <tr>
+ </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="../../docs/common/ref/com/sun/star/linguistic2/SpellChecker.html"
+ title="link to the reference documentation of com.sun.star.linguistic2.SpellChecker"><code>SpellChecker</code></a>
+service.</td>
+ </tr>
+ <tr>
+ </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="../../docs/common/ref/com/sun/star/linguistic2/Thesaurus.html"
+ title="link to the reference documentation of com.sun.star.linguistic2.Thesaurus"><code>Thesaurus</code></a>
+service.</td>
+ </tr>
+ <tr>
+ </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="../../docs/common/ref/com/sun/star/linguistic2/XHyphenatedWord.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>
+ </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="../../docs/common/ref/com/sun/star/linguistic2/XMeaning.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>
+ </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="../../docs/common/ref/com/sun/star/linguistic2/XPossibleHyphens.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>
+ </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="../../docs/common/ref/com/sun/star/linguistic2/XSpellAlternatives.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>
+ <tr>
+ </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="../../docs/common/ref/com/sun/star/util/PathSettings.html"
+ title="link to the reference documentation of com.sun.star.util.PathSettingst">
+ <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="../../docs/common/ref/com/sun/star/beans/XPropertySet.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="../../docs/common/ref/com/sun/star/util/PathSubstitution.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="../../docs/common/ref/com/sun/star/sheet/XCellRangeData.html"
+ title="link to the reference documentation of com.sun.star.sheet.XCellRangeData">
+ <code>XCellRangeData</code></a>, <a
+ href="../../docs/common/ref/com/sun/star/sheet/XCellSeries.html"
+ title="link to the reference documentation of com.sun.star.sheet.XCellSeries"><code>XCellSeries</code></a>,
+ <a
+ href="../../docs/common/ref/com/sun/star/sheet/XArrayFormulaRange.html"
+ title="link to the reference documentation of com.sun.star.sheet.XArrayFormularRange"><code>XArrayFormulaRange</code></a>
+and <a
+ href="../../docs/common/ref/com/sun/star/sheet/XMultipleOperation.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 OpenOffice.org 3.2 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 homogenous 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
+OpenOffice.org 3.2 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">OpenOffice.org 3.2 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 StarBasc 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
+OpenOffice.org 3.2 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="../../docs/common/ref/com/sun/star/sdbc/XResultSetUpdate.html"
+ title="link to the reference documentation of com.sun.star.sdbc.XResultSetUpdate"><code>XResultSetUpdate</code></a>
+and <a href="../../docs/common/ref/com/sun/star/sdbc/XRowUpdate.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="../../docs/common/ref/com/sun/star/form/validation/XValidator.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="../../docs/common/ref/com/sun/star/form/FormComponent.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="../../docs/common/ref/com/sun/star/sdb/RowSet.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="../../docs/common/ref/com/sun/star/form/validation/ValidatableControlModel.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 bussiness 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="../../docs/common/ref/com/sun/star/form/validation/XValidator.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="../../docs/common/ref/com/sun/star/form/validation/module-ix.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="../../docs/common/ref/com/sun/star/task/XInteractionRequest.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="../../docs/common/ref/com/sun/star/sdb/RowSet.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="../../docs/common/ref/com/sun/star/form/validation/XValidator.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="../../docs/common/ref/com/sun/star/form/validation/XValidator.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="../../docs/common/ref/com/sun/star/form/validation/module-ix.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></code></code></a>
+which represents a spreadsheet document, and offers some form related
+functionality. For instance, this class allows the creation of <a
+ href="../../docs/common/ref/com/sun/star/table/CellValueBinding.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="../../docs/common/ref/com/sun/star/form/binding/module-ix.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="../../docs/common/ref/com/sun/star/form/validation/XValidator.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="../../docs/common/ref/com/sun/star/form/validation/XValidator.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(UCB)">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 an 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 an 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
+OpenOffice.org 3.2, 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="Accessibility">Accessibility
+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="./Accessibility/ConnectionTask.java"
+ title="link to Accessibility/ConnectionTask.java">ConnectionTask</a></td>
+ <td class="cell80">A timer task that tries to
+(re-)connect to a running Office application. When it can not detect an
+Office application that accepts connections then it waits for some time
+and tries again.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a
+ href="./Accessibility/EventHandler.java"
+ title="link to Accessibility/EventHandler.java">EventHandler</a></td>
+ <td class="cell80">Handle all events that are used by
+this tool. It is called by the EventListenerProxy class with somewhat
+preprocessed events.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a
+ href="./Accessibility/EventListenerProxy.java"
+ title="link to Accessibility/EventListenerProxy.java">EventListenerProxy</a></td>
+ <td class="cell80">This proxy runs in its own thread
+to avoid deadlocks with the Office it listens to. It waits for top
+window events to be informed of new or removed top level windows and
+for some accessibility events that are relevant to display the
+currently focused object.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a
+ href="./Accessibility/GraphicalDisplay.java"
+ title="link to Accessibility/GraphicalDisplay.java">GraphicalDisplay</a></td>
+ <td class="cell80">This widget displays a graphical
+representation of the currently focused object. The focused object is
+painted as a green rectangle and its ancestors as gray rectangles to
+give an impression of the relative location of the objects.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a
+ href="./Accessibility/IAccessibleObjectDisplay.java"
+ title="link to Accessibility/IAccessibleObjectDisplay.java">IAccessibleObjectDisplay</a></td>
+ <td class="cell80">This interface is implemented by
+all classes that display the currently focused object, namely
+GraphicalDisplay and TextualDisplay. It allows the owner of the display
+classes to tell them to display a specific object: usually the focused
+object.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a
+ href="./Accessibility/MessageArea.java"
+ title="link to Accessibility/MessageArea.java">MessageArea</a></td>
+ <td class="cell80">A text area that shows messages
+about what the tools is currently doing.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a
+ href="./Accessibility/NameProvider.java"
+ title="link to Accessibility/NameProvider.java">NameProvider</a></td>
+ <td class="cell80">In contrast to the Java
+Accessibility API which uses Strings for event types, roles, states,
+and relation types, the UNO Accessibility API uses numbers for this
+task. In order to present them to the user in a more readable form this
+class returns the string name for each event, role, state, or relation.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a
+ href="./Accessibility/RegistrationThread.java"
+ title="link to Accessibility/RegistrationThread.java">RegistrationThread</a></td>
+ <td class="cell80">When a new window appears or an
+existing one is removed the tool registers or unregisters at all the
+window's children as accessibility event listener. This is handled by
+RegistrationThread objects in their own threads so that the user
+interface is not blocked.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><img
+ src="../../docs/images/bluball.gif"> <a
+ href="./Accessibility/SSR.java" title="link to Accessibility/SSR.java">SSR</a></td>
+ <td class="cell80">The main class sets up the user
+interface and starts the ConnectionTask object that eventually will
+initiate a connection to a running Office application and in turn will
+create RegistrationThread objects to register at all Office windows as
+accessibility event listener and thus gets informed about the currently
+focused object.</td>
+ </tr>
+ <tr>
+ <td class="cell20"><a
+ href="./Accessibility/TextualDisplay.java"
+ title="link to Accessibility/TextualDisplay.java">TextualDisplay</a></td>
+ <td class="cell80">Show some textual information
+about the currently focused object like its name, description, and role.</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>
+ <tr>
+ <td colspan="3"><img class="line"
+ src="../../docs/images/sdk_line-1.gif"></td>
+ </tr>
+ <tr>
+ <td colspan="3">
+ <div class="centertext">
+ <p><img class="oraclelogo" src="../../docs/images/odk-footer-logo.gif" title="Sponsored by Oracle" alt="Oracle Logo" />
+ Copyright &copy; 2010, Oracle and/or its affiliates. All rights reserved. Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners.<p>
+ </div>
+ </td>
+ </tr>
+ </tbody>
+</table>
+<map name="Map">
+<area shape="rect" coords="10,68,93,105" href="http://www.oracle.com">
+</map>
+</body>
+</html>